diff --git a/.gitignore b/.gitignore index 5fe4d243..549b13c4 100644 --- a/.gitignore +++ b/.gitignore @@ -67,4 +67,7 @@ Debug/ tmp/ bin/ ipch/ +ref/ *.aps + +builds/ \ No newline at end of file diff --git a/AirCoupler.cpp b/AirCoupler.cpp index 62b72624..cbf67e24 100644 --- a/AirCoupler.cpp +++ b/AirCoupler.cpp @@ -10,6 +10,9 @@ http://mozilla.org/MPL/2.0/. #include "stdafx.h" #include "AirCoupler.h" +#include "model3d.h" +#include "parser.h" + TAirCoupler::TAirCoupler() { Clear(); @@ -42,9 +45,9 @@ void TAirCoupler::Init(std::string const &asName, TModel3d *pModel) { // wyszukanie submodeli if (!pModel) return; // nie ma w czym szukać - pModelOn = pModel->GetFromName( (asName + "_on").c_str() ); // połączony na wprost - pModelOff = pModel->GetFromName( (asName + "_off").c_str() ); // odwieszony - pModelxOn = pModel->GetFromName( (asName + "_xon").c_str() ); // połączony na skos + pModelOn = pModel->GetFromName( asName + "_on" ); // połączony na wprost + pModelOff = pModel->GetFromName( asName + "_off" ); // odwieszony + pModelxOn = pModel->GetFromName( asName + "_xon" ); // połączony na skos } void TAirCoupler::Load(cParser *Parser, TModel3d *pModel) diff --git a/AirCoupler.h b/AirCoupler.h index 8cdebaea..bb9cae27 100644 --- a/AirCoupler.h +++ b/AirCoupler.h @@ -9,8 +9,7 @@ http://mozilla.org/MPL/2.0/. #pragma once -#include "Model3d.h" -#include "parser.h" +#include "classes.h" class TAirCoupler { diff --git a/AnimModel.cpp b/AnimModel.cpp index f19210f3..c004a647 100644 --- a/AnimModel.cpp +++ b/AnimModel.cpp @@ -15,15 +15,15 @@ http://mozilla.org/MPL/2.0/. #include "stdafx.h" #include "AnimModel.h" -#include "Globals.h" -#include "Logs.h" -#include "usefull.h" -#include "McZapkie/mctools.h" -#include "Timer.h" +#include "renderer.h" #include "MdlMngr.h" -// McZapkie: -#include "Texture.h" -//--------------------------------------------------------------------------- +#include "simulation.h" +#include "simulationtime.h" +#include "event.h" +#include "Globals.h" +#include "Timer.h" +#include "Logs.h" + TAnimContainer *TAnimModel::acAnimList = NULL; TAnimAdvanced::TAnimAdvanced(){}; @@ -74,11 +74,11 @@ int TAnimAdvanced::SortByBone() TAnimContainer::TAnimContainer() { pNext = NULL; - vRotateAngles = vector3(0.0f, 0.0f, 0.0f); // aktualne kąty obrotu - vDesiredAngles = vector3(0.0f, 0.0f, 0.0f); // docelowe kąty obrotu + vRotateAngles = Math3D::vector3(0.0f, 0.0f, 0.0f); // aktualne kąty obrotu + vDesiredAngles = Math3D::vector3(0.0f, 0.0f, 0.0f); // docelowe kąty obrotu fRotateSpeed = 0.0; - vTranslation = vector3(0.0f, 0.0f, 0.0f); // aktualne przesunięcie - vTranslateTo = vector3(0.0f, 0.0f, 0.0f); // docelowe przesunięcie + vTranslation = Math3D::vector3(0.0f, 0.0f, 0.0f); // aktualne przesunięcie + vTranslateTo = Math3D::vector3(0.0f, 0.0f, 0.0f); // docelowe przesunięcie fTranslateSpeed = 0.0; fAngleSpeed = 0.0; pSubModel = NULL; @@ -102,7 +102,7 @@ bool TAnimContainer::Init(TSubModel *pNewSubModel) return (pSubModel != NULL); } -void TAnimContainer::SetRotateAnim(vector3 vNewRotateAngles, double fNewRotateSpeed) +void TAnimContainer::SetRotateAnim( Math3D::vector3 vNewRotateAngles, double fNewRotateSpeed) { if (!this) return; // wywoływane z eventu, gdy brak modelu @@ -125,7 +125,7 @@ void TAnimContainer::SetRotateAnim(vector3 vNewRotateAngles, double fNewRotateSp } } -void TAnimContainer::SetTranslateAnim(vector3 vNewTranslate, double fNewSpeed) +void TAnimContainer::SetTranslateAnim( Math3D::vector3 vNewTranslate, double fNewSpeed) { if (!this) return; // wywoływane z eventu, gdy brak modelu @@ -156,8 +156,11 @@ void TAnimContainer::AnimSetVMD(double fNewSpeed) // X-w lewo, Y-w górę, Z-do tyłu // minimalna wysokość to -7.66, a nadal musi być ponad podłogą // if (pMovementData->iFrame>0) return; //tylko pierwsza ramka - vTranslateTo = vector3(0.1 * pMovementData->f3Vector.x, 0.1 * pMovementData->f3Vector.z, - 0.1 * pMovementData->f3Vector.y); + vTranslateTo = + Math3D::vector3( + 0.1 * pMovementData->f3Vector.x, + 0.1 * pMovementData->f3Vector.z, + 0.1 * pMovementData->f3Vector.y); if (LengthSquared3(vTranslateTo) > 0.0 ? true : LengthSquared3(vTranslation) > 0.0) { // jeśli ma być przesunięte albo jest przesunięcie iAnim |= 2; // wyłączy się samo @@ -205,17 +208,18 @@ void TAnimContainer::AnimSetVMD(double fNewSpeed) // "+AnsiString(pMovementData->f3Vector.y)+" "+AnsiString(pMovementData->f3Vector.z)); } -void TAnimContainer::UpdateModel() -{ // przeliczanie animacji wykonać tylko raz na model +// przeliczanie animacji wykonać tylko raz na model +void TAnimContainer::UpdateModel() { + if (pSubModel) // pozbyć się tego - sprawdzać wcześniej { if (fTranslateSpeed != 0.0) { - vector3 dif = vTranslateTo - vTranslation; // wektor w kierunku docelowym + auto dif = vTranslateTo - vTranslation; // wektor w kierunku docelowym double l = LengthSquared3(dif); // długość wektora potrzebnego przemieszczenia if (l >= 0.0001) { // jeśli do przemieszczenia jest ponad 1cm - vector3 s = SafeNormalize(dif); // jednostkowy wektor kierunku + auto s = Math3D::SafeNormalize(dif); // jednostkowy wektor kierunku s = s * (fTranslateSpeed * Timer::GetDeltaTime()); // przemieszczenie w podanym czasie z daną prędkością @@ -231,12 +235,13 @@ void TAnimContainer::UpdateModel() fTranslateSpeed = 0.0; // wyłączenie przeliczania wektora if (LengthSquared3(vTranslation) <= 0.0001) // jeśli jest w punkcie początkowym iAnim &= ~2; // wyłączyć zmianę pozycji submodelu - if (evDone) - Global::AddToQuery(evDone, NULL); // wykonanie eventu informującego o - // zakończeniu + if( evDone ) { + // wykonanie eventu informującego o zakończeniu + simulation::Events.AddToQuery( evDone, nullptr ); + } } } - if (fRotateSpeed != 0) + if (fRotateSpeed != 0.0) { /* @@ -253,7 +258,7 @@ void TAnimContainer::UpdateModel() */ bool anim = false; - vector3 dif = vDesiredAngles - vRotateAngles; + auto dif = vDesiredAngles - vRotateAngles; double s; s = fRotateSpeed * sign(dif.x) * Timer::GetDeltaTime(); if (fabs(s) >= fabs(dif.x)) @@ -298,13 +303,15 @@ void TAnimContainer::UpdateModel() if (!anim) { // nie potrzeba przeliczać już fRotateSpeed = 0.0; - if (evDone) - Global::AddToQuery(evDone, NULL); // wykonanie eventu informującego o - // zakończeniu + if( evDone ) { + // wykonanie eventu informującego o zakończeniu + simulation::Events.AddToQuery( evDone, nullptr ); + } } } - if (fAngleSpeed != 0.0) - { // obrót kwaternionu (interpolacja) + if( fAngleSpeed != 0.f ) { + // NOTE: this is angle- not quaternion-based rotation TBD, TODO: switch to quaternion rotations? + fAngleCurrent += fAngleSpeed * Timer::GetDeltaTime(); // aktualny parametr interpolacji } } }; @@ -322,15 +329,14 @@ void TAnimContainer::PrepareModel() { if (fAngleSpeed > 0.0f) { - fAngleCurrent += - fAngleSpeed * Timer::GetDeltaTime(); // aktualny parametr interpolacji if (fAngleCurrent >= 1.0f) { // interpolacja zakończona, ustawienie na pozycję końcową qCurrent = qDesired; fAngleSpeed = 0.0; // wyłączenie przeliczania wektora - if (evDone) - Global::AddToQuery(evDone, - NULL); // wykonanie eventu informującego o zakończeniu + if( evDone ) { + // wykonanie eventu informującego o zakończeniu + simulation::Events.AddToQuery( evDone, nullptr ); + } } else { // obliczanie pozycji pośredniej @@ -356,13 +362,14 @@ void TAnimContainer::UpdateModelIK() { // odwrotna kinematyka wyliczana dopiero po ustawieniu macierzy w submodelach if (pSubModel) // pozbyć się tego - sprawdzać wcześniej { - if (pSubModel->b_Anim & at_IK) + if ((pSubModel->b_Anim == TAnimType::at_IK) + ||(pSubModel->b_Anim == TAnimType::at_IK22)) { // odwrotna kinematyka float3 d, k; TSubModel *ch = pSubModel->ChildGet(); switch (pSubModel->b_Anim) { - case at_IK11: // stopa: ustawić w kierunku czubka (pierwszy potomny) + case TAnimType::at_IK11: // stopa: ustawić w kierunku czubka (pierwszy potomny) d = ch->Translation1Get(); // wektor względem aktualnego układu (nie uwzględnia // obrotu) k = float3(RadToDeg(atan2(d.z, hypot(d.x, d.y))), 0.0, @@ -372,7 +379,7 @@ void TAnimContainer::UpdateModelIK() // WriteLog("--> "+AnsiString(k.x)+" "+AnsiString(k.y)+" "+AnsiString(k.z)); // Ra: to już jest dobrze, może być inna ćwiartka i znak break; - case at_IK22: // udo: ustawić w kierunku pierwszej potomnej pierwszej potomnej (kostki) + case TAnimType::at_IK22: // udo: ustawić w kierunku pierwszej potomnej pierwszej potomnej (kostki) // pozycję kostki należy określić względem kości centralnej (+biodro może być // pochylone) // potem wyliczyć ewentualne odchylenie w tej i następnej @@ -396,7 +403,7 @@ bool TAnimContainer::InMovement() return (fRotateSpeed != 0.0) || (fTranslateSpeed != 0.0); } -void TAnimContainer::EventAssign(TEvent *ev) +void TAnimContainer::EventAssign(basic_event *ev) { // przypisanie eventu wykonywanego po zakończeniu animacji evDone = ev; }; @@ -405,68 +412,51 @@ void TAnimContainer::EventAssign(TEvent *ev) //------------------------------------------------------------------------------ //------------------------------------------------------------------------------ -TAnimModel::TAnimModel() -{ - pRoot = NULL; - pModel = NULL; - iNumLights = 0; - fBlinkTimer = 0; - ReplacableSkinId[0] = 0; - ReplacableSkinId[1] = 0; - ReplacableSkinId[2] = 0; - ReplacableSkinId[3] = 0; - ReplacableSkinId[4] = 0; - for (int i = 0; i < iMaxNumLights; i++) - { - LightsOn[i] = LightsOff[i] = NULL; // normalnie nie ma - lsLights[i] = ls_Off; // a jeśli są, to wyłączone +TAnimModel::TAnimModel( scene::node_data const &Nodedata ) : basic_node( Nodedata ) { + // TODO: wrap these in a tuple and move to underlying model + for( int index = 0; index < iMaxNumLights; ++index ) { + LightsOn[ index ] = LightsOff[ index ] = nullptr; // normalnie nie ma + lsLights[ index ] = ls_Off; // a jeśli są, to wyłączone } - vAngle.x = vAngle.y = vAngle.z = 0.0; // zerowanie obrotów egzemplarza - pAdvanced = NULL; // nie ma zaawansowanej animacji - fDark = 0.25; // standardowy próg zaplania - fOnTime = 0.66; - fOffTime = fOnTime + 0.66; } TAnimModel::~TAnimModel() { - delete pAdvanced; // nie ma zaawansowanej animacji + SafeDelete(pAdvanced); // nie ma zaawansowanej animacji SafeDelete(pRoot); } -bool TAnimModel::Init(TModel3d *pNewModel) -{ - fBlinkTimer = double(Random(1000 * fOffTime)) / (1000 * fOffTime); - ; - pModel = pNewModel; - return (pModel != NULL); -} - bool TAnimModel::Init(std::string const &asName, std::string const &asReplacableTexture) { - if (asReplacableTexture.substr(0, 1) == - "*") // od gwiazdki zaczynają się teksty na wyświetlaczach - asText = asReplacableTexture.substr(1, asReplacableTexture.length() - 1); // zapamiętanie tekstu - else if (asReplacableTexture != "none") - ReplacableSkinId[1] = - TextureManager.GetTextureId( asReplacableTexture, "" ); - if( ( ReplacableSkinId[ 1 ] != 0 ) - && ( TextureManager.Texture( ReplacableSkinId[ 1 ] ).has_alpha ) ) { + if( asReplacableTexture.substr( 0, 1 ) == "*" ) { + // od gwiazdki zaczynają się teksty na wyświetlaczach + asText = asReplacableTexture.substr( 1, asReplacableTexture.length() - 1 ); // zapamiętanie tekstu + } + else if( asReplacableTexture != "none" ) { + m_materialdata.replacable_skins[ 1 ] = GfxRenderer.Fetch_Material( asReplacableTexture ); + } + if( ( m_materialdata.replacable_skins[ 1 ] != null_handle ) + && ( GfxRenderer.Material( m_materialdata.replacable_skins[ 1 ] ).has_alpha ) ) { // tekstura z kanałem alfa - nie renderować w cyklu nieprzezroczystych - iTexAlpha = 0x31310031; + m_materialdata.textures_alpha = 0x31310031; } else{ - // tekstura nieprzezroczysta - nie renderować w cyklu - iTexAlpha = 0x30300030; + // tekstura nieprzezroczysta - nie renderować w cyklu przezroczystych + m_materialdata.textures_alpha = 0x30300030; } - // przezroczystych - return (Init(TModelsManager::GetModel(asName.c_str()))); + +// TODO: redo the random timer initialization +// fBlinkTimer = Random() * ( fOnTime + fOffTime ); + + pModel = TModelsManager::GetModel( asName ); + return ( pModel != nullptr ); } bool TAnimModel::Load(cParser *parser, bool ter) { // rozpoznanie wpisu modelu i ustawienie świateł std::string name = parser->getToken(); - std::string texture = parser->getToken(false); // tekstura (zmienia na małe) + std::string texture = parser->getToken(); // tekstura (zmienia na małe) + replace_slashes( name ); if (!Init( name, texture )) { if (name != "notload") @@ -474,10 +464,12 @@ bool TAnimModel::Load(cParser *parser, bool ter) if (ter) // jeśli teren { if( name.substr( name.rfind( '.' ) ) == ".t3d" ) { - name[ name.length() - 2 ] = 'e'; + name[ name.length() - 3 ] = 'e'; } - Global::asTerrainModel = name; +#ifdef EU07_USE_OLD_TERRAINCODE + Global.asTerrainModel = name; WriteLog("Terrain model \"" + name + "\" will be created."); +#endif } else ErrorLog("Missed file: " + name); @@ -513,7 +505,7 @@ bool TAnimModel::Load(cParser *parser, bool ter) while( ( token != "" ) && ( token != "endmodel" ) ) { - LightSet( i, std::stod( token ) ); // stan światła jest liczbą z ułamkiem + LightSet( i, std::stof( token ) ); // stan światła jest liczbą z ułamkiem ++i; token = ""; @@ -523,11 +515,11 @@ bool TAnimModel::Load(cParser *parser, bool ter) return true; } -TAnimContainer * TAnimModel::AddContainer(char *pName) +TAnimContainer * TAnimModel::AddContainer(std::string const &Name) { // dodanie sterowania submodelem dla egzemplarza if (!pModel) return NULL; - TSubModel *tsb = pModel->GetFromName(pName); + TSubModel *tsb = pModel->GetFromName(Name); if (tsb) { TAnimContainer *tmp = new TAnimContainer(); @@ -539,55 +531,160 @@ TAnimContainer * TAnimModel::AddContainer(char *pName) return NULL; } -TAnimContainer * TAnimModel::GetContainer(char *pName) +TAnimContainer * TAnimModel::GetContainer(std::string const &Name) { // szukanie/dodanie sterowania submodelem dla egzemplarza - if (!pName) + if (true == Name.empty()) return pRoot; // pobranie pierwszego (dla obrotnicy) TAnimContainer *pCurrent; for (pCurrent = pRoot; pCurrent != NULL; pCurrent = pCurrent->pNext) // if (pCurrent->GetName()==pName) - if (stricmp(pCurrent->NameGet(), pName) == 0) + if (Name == pCurrent->NameGet()) return pCurrent; - return AddContainer(pName); + return AddContainer(Name); } -void TAnimModel::RaAnimate() -{ // przeliczenie animacji - jednorazowo na klatkę +// przeliczenie animacji - jednorazowo na klatkę +void TAnimModel::RaAnimate( unsigned int const Framestamp ) { + + if( Framestamp == m_framestamp ) { return; } + + auto const timedelta { Timer::GetDeltaTime() }; + + // interpretacja ułamka zależnie od typu + // case ls_Off: ustalenie czasu migotania, t<1s (f>1Hz), np. 0.1 => t=0.1 (f=10Hz) + // case ls_On: ustalenie wypełnienia ułamkiem, np. 1.25 => zapalony przez 1/4 okresu + // case ls_Blink: ustalenie częstotliwości migotania, f<1Hz (t>1s), np. 2.2 => f=0.2Hz (t=5s) + float modeintegral, modefractional; + for( int idx = 0; idx < iNumLights; ++idx ) { + + modefractional = std::modf( std::abs( lsLights[ idx ] ), &modeintegral ); + + if( modeintegral >= ls_Dark ) { + // light threshold modes don't use timers + continue; + } + auto const mode { static_cast( modeintegral ) }; + + auto &opacity { m_lightopacities[ idx ] }; + auto &timer { m_lighttimers[ idx ] }; + if( ( modeintegral < ls_Blink ) && ( modefractional < 0.01f ) ) { + // simple flip modes + switch( mode ) { + case ls_Off: { + // reduce to zero + timer = std::max( 0.f, timer - timedelta ); + break; + } + case ls_On: { + // increase to max value + timer = std::min( fTransitionTime, timer + timedelta ); + break; + } + default: { + break; + } + } + opacity = timer / fTransitionTime; + } + else { + // blink modes + auto const ontime { ( + ( mode == ls_Blink ) ? ( ( modefractional < 0.01f ) ? fOnTime : ( 1.f / modefractional ) * 0.5f ) : + ( mode == ls_Off ) ? modefractional * 0.5f : + ( mode == ls_On ) ? modefractional * ( fOnTime + fOffTime ) : + fOnTime ) }; // fallback + auto const offtime { ( + ( mode == ls_Blink ) ? ( ( modefractional < 0.01f ) ? fOffTime : ontime ) : + ( mode == ls_Off ) ? ontime : + ( mode == ls_On ) ? ( fOnTime + fOffTime ) - ontime : + fOffTime ) }; // fallback + auto const transitiontime { + std::min( + 1.f, + std::min( ontime, offtime ) * 0.9f ) }; + + timer = clamp_circular( timer + timedelta * ( lsLights[ idx ] > 0.f ? 1.f : -1.f ), ontime + offtime ); + // set opacity depending on blink stage + if( timer < ontime ) { + // blink on + opacity = clamp( timer / transitiontime, 0.f, 1.f ); + } + else { + // blink off + opacity = 1.f - clamp( ( timer - ontime ) / transitiontime, 0.f, 1.f ); + } + } + } + // Ra 2F1I: to by można pomijać dla modeli bez animacji, których jest większość TAnimContainer *pCurrent; - for (pCurrent = pRoot; pCurrent != NULL; pCurrent = pCurrent->pNext) + for (pCurrent = pRoot; pCurrent != nullptr; pCurrent = pCurrent->pNext) if (!pCurrent->evDone) // jeśli jest bez eventu pCurrent->UpdateModel(); // przeliczenie animacji każdego submodelu // if () //tylko dla modeli z IK !!!! for (pCurrent = pRoot; pCurrent != NULL; pCurrent = pCurrent->pNext) // albo osobny łańcuch pCurrent->UpdateModelIK(); // przeliczenie odwrotnej kinematyki + + m_framestamp = Framestamp; }; void TAnimModel::RaPrepare() { // ustawia światła i animacje we wzorcu modelu przed renderowaniem egzemplarza - fBlinkTimer -= Timer::GetDeltaTime(); - if (fBlinkTimer <= 0) - fBlinkTimer = fOffTime; bool state; // stan światła - for (int i = 0; i < iNumLights; i++) + for (int i = 0; i < iNumLights; ++i) { - switch (lsLights[i]) - { - case ls_Blink: // migotanie - state = fBlinkTimer < fOnTime; - break; - case ls_Dark: // zapalone, gdy ciemno - state = Global::fLuminance <= fDark; - break; - default: // zapalony albo zgaszony - state = (lsLights[i] == ls_On); + auto const lightmode { static_cast( std::abs( lsLights[ i ] ) ) }; + switch( lightmode ) { + case ls_On: + case ls_Off: + case ls_Blink: { + if (LightsOn[i]) { + LightsOn[i]->iVisible = ( m_lightopacities[i] > 0.f ); + LightsOn[i]->SetVisibilityLevel( m_lightopacities[i], true, false ); + } + if (LightsOff[i]) { + LightsOff[i]->iVisible = ( m_lightopacities[i] < 1.f ); + LightsOff[i]->SetVisibilityLevel( 1.f, true, false ); + } + break; + } + case ls_Dark: { + // zapalone, gdy ciemno + state = ( + Global.fLuminance - std::max( 0.f, Global.Overcast - 1.f ) <= ( + lsLights[ i ] == static_cast( ls_Dark ) ? + DefaultDarkThresholdLevel : + ( lsLights[ i ] - static_cast( ls_Dark ) ) ) ); + break; + } + case ls_Home: { + // like ls_dark but off late at night + auto const simulationhour { simulation::Time.data().wHour }; + state = ( + Global.fLuminance - std::max( 0.f, Global.Overcast - 1.f ) <= ( + lsLights[ i ] == static_cast( ls_Home ) ? + DefaultDarkThresholdLevel : + ( lsLights[ i ] - static_cast( ls_Home ) ) ) ); + // force the lights off between 1-5am + state = state && (( simulationhour < 1 ) || ( simulationhour >= 5 )); + break; + } + default: { + break; + } + } + if( lightmode >= ls_Dark ) { + // crude as hell but for test will do :x + if (LightsOn[i]) { + LightsOn[i]->iVisible = state; + // TODO: set visibility for the entire submodel's children as well + LightsOn[i]->fVisible = m_lightopacities[i]; + } + if (LightsOff[i]) + LightsOff[i]->iVisible = !state; } - if (LightsOn[i]) - LightsOn[i]->iVisible = state; - if (LightsOff[i]) - LightsOff[i]->iVisible = !state; } - TSubModel::iInstance = (int)this; //żeby nie robić cudzych animacji + TSubModel::iInstance = reinterpret_cast( this ); //żeby nie robić cudzych animacji TSubModel::pasText = &asText; // przekazanie tekstu do wyświetlacza (!!!! do przemyślenia) if (pAdvanced) // jeśli jest zaawansowana animacja Advanced(); // wykonać co tam trzeba @@ -598,87 +695,17 @@ void TAnimModel::RaPrepare() // for (pCurrent=pRoot;pCurrent!=NULL;pCurrent=pCurrent->pNext) //albo osobny łańcuch // pCurrent->UpdateModelIK(); //przeliczenie odwrotnej kinematyki } -/* -void TAnimModel::RenderVBO(vector3 pPosition, double fAngle) -{ // sprawdza światła i rekurencyjnie renderuje TModel3d - RaAnimate(); // jednorazowe przeliczenie animacji - RaPrepare(); - if (pModel) // renderowanie rekurencyjne submodeli - pModel->RaRender(pPosition, fAngle, ReplacableSkinId, iTexAlpha); -} -void TAnimModel::RenderAlphaVBO(vector3 pPosition, double fAngle) -{ - RaPrepare(); - if (pModel) // renderowanie rekurencyjne submodeli - pModel->RaRenderAlpha(pPosition, fAngle, ReplacableSkinId, iTexAlpha); -}; - -void TAnimModel::RenderDL(vector3 pPosition, double fAngle) -{ - RaAnimate(); // jednorazowe przeliczenie animacji - RaPrepare(); - if (pModel) // renderowanie rekurencyjne submodeli - pModel->Render(pPosition, fAngle, ReplacableSkinId, iTexAlpha); -} - -void TAnimModel::RenderAlphaDL(vector3 pPosition, double fAngle) -{ - RaPrepare(); - if (pModel) - pModel->RenderAlpha(pPosition, fAngle, ReplacableSkinId, iTexAlpha); -}; -*/ int TAnimModel::Flags() { // informacja dla TGround, czy ma być w Render, RenderAlpha, czy RenderMixed int i = pModel ? pModel->Flags() : 0; // pobranie flag całego modelu - if (ReplacableSkinId[1] > 0) // jeśli ma wymienną teksturę 0 - i |= (i & 0x01010001) * ((iTexAlpha & 1) ? 0x20 : 0x10); - // if (ReplacableSkinId[2]>0) //jeśli ma wymienną teksturę 1 - // i|=(i&0x02020002)*((iTexAlpha&1)?0x10:0x08); - // if (ReplacableSkinId[3]>0) //jeśli ma wymienną teksturę 2 - // i|=(i&0x04040004)*((iTexAlpha&1)?0x08:0x04); - // if (ReplacableSkinId[4]>0) //jeśli ma wymienną teksturę 3 - // i|=(i&0x08080008)*((iTexAlpha&1)?0x04:0x02); + if( m_materialdata.replacable_skins[ 1 ] > 0 ) // jeśli ma wymienną teksturę 0 + i |= (i & 0x01010001) * ((m_materialdata.textures_alpha & 1) ? 0x20 : 0x10); return i; }; -//----------------------------------------------------------------------------- -// 2011-03-16 cztery nowe funkcje renderowania z możliwością pochylania obiektów -//----------------------------------------------------------------------------- - -void TAnimModel::RenderDL(vector3 *vPosition) -{ - RaAnimate(); // jednorazowe przeliczenie animacji - RaPrepare(); - if (pModel) // renderowanie rekurencyjne submodeli - pModel->Render(vPosition, &vAngle, ReplacableSkinId, iTexAlpha); -}; -void TAnimModel::RenderAlphaDL(vector3 *vPosition) -{ - RaPrepare(); - if (pModel) // renderowanie rekurencyjne submodeli - pModel->RenderAlpha(vPosition, &vAngle, ReplacableSkinId, iTexAlpha); -}; -void TAnimModel::RenderVBO(vector3 *vPosition) -{ - RaAnimate(); // jednorazowe przeliczenie animacji - RaPrepare(); - if (pModel) // renderowanie rekurencyjne submodeli - pModel->RaRender(vPosition, &vAngle, ReplacableSkinId, iTexAlpha); -}; -void TAnimModel::RenderAlphaVBO(vector3 *vPosition) -{ - RaPrepare(); - if (pModel) // renderowanie rekurencyjne submodeli - pModel->RaRenderAlpha(vPosition, &vAngle, ReplacableSkinId, iTexAlpha); -}; - //--------------------------------------------------------------------------- -bool TAnimModel::TerrainLoaded() -{ // zliczanie kwadratów kilometrowych (główna linia po Next) do tworznia tablicy - return (this ? pModel != NULL : false); -}; + int TAnimModel::TerrainCount() { // zliczanie kwadratów kilometrowych (główna linia po Next) do tworznia tablicy return pModel ? pModel->TerrainCount() : 0; @@ -687,11 +714,7 @@ TSubModel * TAnimModel::TerrainSquare(int n) { // pobieranie wskaźników do pierwszego submodelu return pModel ? pModel->TerrainSquare(n) : 0; }; -void TAnimModel::TerrainRenderVBO(int n) -{ // renderowanie terenu z VBO - if (pModel) - pModel->TerrainRenderVBO(n); -}; + //--------------------------------------------------------------------------- void TAnimModel::Advanced() @@ -822,40 +845,89 @@ void TAnimModel::AnimationVND(void *pData, double a, double b, double c, double }; //--------------------------------------------------------------------------- -void TAnimModel::LightSet(int n, float v) +void TAnimModel::LightSet(int const n, float const v) { // ustawienie światła (n) na wartość (v) - if (n >= iMaxNumLights) + if( n >= iMaxNumLights ) { return; // przekroczony zakres - lsLights[n] = TLightState(int(v)); - switch (lsLights[n]) - { // interpretacja ułamka zależnie od typu - case 0: // ustalenie czasu migotania, t<1s (f>1Hz), np. 0.1 => t=0.1 (f=10Hz) - break; - case 1: // ustalenie wypełnienia ułamkiem, np. 1.25 => zapalony przez 1/4 okresu - break; - case 2: // ustalenie częstotliwości migotania, f<1Hz (t>1s), np. 2.2 => f=0.2Hz (t=5s) - break; - case 3: // zapalenie świateł zależne od oświetlenia scenerii - if (v > 3.0) - fDark = v - 3.0; // ustawienie indywidualnego progu zapalania - else - fDark = 0.25; // standardowy próg zaplania - break; } + lsLights[ n ] = v; }; -//--------------------------------------------------------------------------- + void TAnimModel::AnimUpdate(double dt) { // wykonanie zakolejkowanych animacji, nawet gdy modele nie są aktualnie wyświetlane TAnimContainer *p = TAnimModel::acAnimList; - while (p) - { // jeśli w ogóle jest co animować - // if ((*p)->fTranslateSpeed==0.0) - // if ((*p)->fRotateSpeed==0.0) - // {//jak się naanimował, to usunąć z listy - // *p=(*p)->ListRemove(); //zwraca wskaźnik do kolejnego z listy - // } + while( p ) { + p->UpdateModel(); p = p->acAnimNext; // na razie bez usuwania z listy, bo głównie obrotnica na nią wchodzi } }; + +// radius() subclass details, calculates node's bounding radius +float +TAnimModel::radius_() { + + return ( + pModel ? + pModel->bounding_radius() : + 0.f ); +} + +// serialize() subclass details, sends content of the subclass to provided stream +void +TAnimModel::serialize_( std::ostream &Output ) const { + + // TODO: implement +} +// deserialize() subclass details, restores content of the subclass from provided stream +void +TAnimModel::deserialize_( std::istream &Input ) { + + // TODO: implement +} + +// export() subclass details, sends basic content of the class in legacy (text) format to provided stream +void +TAnimModel::export_as_text_( std::ostream &Output ) const { + // header + Output << "model "; + // location and rotation + Output + << location().x << ' ' + << location().y << ' ' + << location().z << ' ' + << vAngle.y << ' '; + // 3d shape + auto modelfile { ( + pModel ? + pModel->NameGet() + ".t3d" : // rainsted requires model file names to include an extension + "none" ) }; + if( modelfile.find( szModelPath ) == 0 ) { + // don't include 'models/' in the path + modelfile.erase( 0, std::string{ szModelPath }.size() ); + } + Output << modelfile << ' '; + // texture + auto texturefile { ( + m_materialdata.replacable_skins[ 1 ] != null_handle ? + GfxRenderer.Material( m_materialdata.replacable_skins[ 1 ] ).name : + "none" ) }; + if( texturefile.find( szTexturePath ) == 0 ) { + // don't include 'textures/' in the path + texturefile.erase( 0, std::string{ szTexturePath }.size() ); + } + Output << texturefile << ' '; + // light submodels activation configuration + if( iNumLights > 0 ) { + Output << "lights "; + for( int lightidx = 0; lightidx < iNumLights; ++lightidx ) { + Output << lsLights[ lightidx ] << ' '; + } + } + // footer + Output + << "endmodel" + << "\n"; +} + //--------------------------------------------------------------------------- diff --git a/AnimModel.h b/AnimModel.h index bc688a5d..63f06a59 100644 --- a/AnimModel.h +++ b/AnimModel.h @@ -12,22 +12,26 @@ http://mozilla.org/MPL/2.0/. */ -#ifndef AnimModelH -#define AnimModelH +#pragma once -#include "Model3d.h" -#include "Texture.h" +#include "classes.h" +#include "dumb3d.h" +#include "float3d.h" +#include "model3d.h" +#include "dynobj.h" +#include "scenenode.h" const int iMaxNumLights = 8; +float const DefaultDarkThresholdLevel { 0.325f }; // typy stanu świateł -typedef enum -{ +enum TLightState { ls_Off = 0, // zgaszone ls_On = 1, // zapalone ls_Blink = 2, // migające - ls_Dark = 3 // Ra: zapalajce się automatycznie, gdy zrobi się ciemno -} TLightState; + ls_Dark = 3, // Ra: zapalajce się automatycznie, gdy zrobi się ciemno + ls_Home = 4 // like ls_dark but off late at night +}; class TAnimVocaloidFrame { // ramka animacji typu Vocaloid Motion Data z programu MikuMikuDance @@ -39,18 +43,18 @@ class TAnimVocaloidFrame char cBezier[64]; // krzywe Béziera do interpolacji dla x,y,z i obrotu }; -class TEvent; +class basic_event; class TAnimContainer { // opakowanie submodelu, określające animację egzemplarza - obsługiwane jako lista - friend class TAnimModel; + friend TAnimModel; private: - vector3 vRotateAngles; // dla obrotów Eulera - vector3 vDesiredAngles; + Math3D::vector3 vRotateAngles; // dla obrotów Eulera + Math3D::vector3 vDesiredAngles; double fRotateSpeed; - vector3 vTranslation; - vector3 vTranslateTo; + Math3D::vector3 vTranslation; + Math3D::vector3 vTranslateTo; double fTranslateSpeed; // może tu dać wektor? float4 qCurrent; // aktualny interpolowany float4 qStart; // pozycja początkowa (0 dla interpolacji) @@ -69,7 +73,7 @@ class TAnimContainer { // mogą być animacje klatkowe różnego typu, wskaźniki używa AnimModel TAnimVocaloidFrame *pMovementData; // wskaźnik do klatki }; - TEvent *evDone; // ewent wykonywany po zakończeniu animacji, np. zapór, obrotnicy + basic_event *evDone; // ewent wykonywany po zakończeniu animacji, np. zapór, obrotnicy public: TAnimContainer *pNext; TAnimContainer *acAnimNext; // lista animacji z eventem, które muszą być przeliczane również bez @@ -77,41 +81,30 @@ class TAnimContainer TAnimContainer(); ~TAnimContainer(); bool Init(TSubModel *pNewSubModel); - // std::string inline GetName() { return - // std::string(pSubModel?pSubModel->asName.c_str():""); }; - // std::string inline GetName() { return std::string(pSubModel?pSubModel->pName:""); - // }; - char * NameGet() - { - return (pSubModel ? pSubModel->pName : NULL); - }; - // void SetRotateAnim(vector3 vNewRotateAxis, double fNewDesiredAngle, double - // fNewRotateSpeed, bool bResetAngle=false); - void SetRotateAnim(vector3 vNewRotateAngles, double fNewRotateSpeed); - void SetTranslateAnim(vector3 vNewTranslate, double fNewSpeed); + inline + std::string NameGet() { + return (pSubModel ? pSubModel->pName : ""); }; + void SetRotateAnim( Math3D::vector3 vNewRotateAngles, double fNewRotateSpeed); + void SetTranslateAnim( Math3D::vector3 vNewTranslate, double fNewSpeed); void AnimSetVMD(double fNewSpeed); void PrepareModel(); void UpdateModel(); void UpdateModelIK(); bool InMovement(); // czy w trakcie animacji? - double _fastcall AngleGet() - { - return vRotateAngles.z; - }; // jednak ostatnia, T3D ma inny układ - vector3 _fastcall TransGet() - { - return vector3(-vTranslation.x, vTranslation.z, vTranslation.y); - }; // zmiana, bo T3D ma inny układ - void WillBeAnimated() - { + inline + double AngleGet() { + return vRotateAngles.z; }; // jednak ostatnia, T3D ma inny układ + inline + Math3D::vector3 TransGet() { + return Math3D::vector3(-vTranslation.x, vTranslation.z, vTranslation.y); }; // zmiana, bo T3D ma inny układ + inline + void WillBeAnimated() { if (pSubModel) - pSubModel->WillBeAnimated(); - }; - void EventAssign(TEvent *ev); - TEvent * Event() - { - return evDone; - }; + pSubModel->WillBeAnimated(); }; + void EventAssign(basic_event *ev); + inline + basic_event * Event() { + return evDone; }; }; class TAnimAdvanced @@ -128,61 +121,87 @@ class TAnimAdvanced int SortByBone(); }; -class TAnimModel -{ // opakowanie modelu, określające stan egzemplarza - private: - TAnimContainer *pRoot; // pojemniki sterujące, tylko dla aniomowanych submodeli - TModel3d *pModel; - double fBlinkTimer; - int iNumLights; - TSubModel *LightsOn[iMaxNumLights]; // Ra: te wskaźniki powinny być w ramach TModel3d - TSubModel *LightsOff[iMaxNumLights]; - vector3 vAngle; // bazowe obroty egzemplarza względem osi - int iTexAlpha; //żeby nie sprawdzać za każdym razem, dla 4 wymiennych tekstur - std::string asText; // tekst dla wyświetlacza znakowego - TAnimAdvanced *pAdvanced; - void Advanced(); - TLightState lsLights[iMaxNumLights]; - float fDark; // poziom zapalanie światła (powinno być chyba powiązane z danym światłem?) - float fOnTime, fOffTime; // były stałymi, teraz mogą być zmienne dla każdego egzemplarza - private: - void RaAnimate(); // przeliczenie animacji egzemplarza - void RaPrepare(); // ustawienie animacji egzemplarza na wzorcu - public: - texture_manager::size_type ReplacableSkinId[5]; // McZapkie-020802: zmienialne skory - static TAnimContainer *acAnimList; // lista animacji z eventem, które muszą być przeliczane - // również bez wyświetlania - TAnimModel(); +// opakowanie modelu, określające stan egzemplarza +class TAnimModel : public scene::basic_node { + + friend opengl_renderer; + friend itemproperties_panel; + +public: +// constructors + explicit TAnimModel( scene::node_data const &Nodedata ); +// destructor ~TAnimModel(); - bool Init(TModel3d *pNewModel); +// methods + static void AnimUpdate( double dt ); bool Init(std::string const &asName, std::string const &asReplacableTexture); bool Load(cParser *parser, bool ter = false); - TAnimContainer * AddContainer(char *pName); - TAnimContainer * GetContainer(char *pName); -/* void RenderDL(vector3 pPosition = vector3(0, 0, 0), double fAngle = 0); - void RenderAlphaDL(vector3 pPosition = vector3(0, 0, 0), double fAngle = 0); - void RenderVBO(vector3 pPosition = vector3(0, 0, 0), double fAngle = 0); - void RenderAlphaVBO(vector3 pPosition = vector3(0, 0, 0), double fAngle = 0); -*/ void RenderDL(vector3 *vPosition); - void RenderAlphaDL(vector3 *vPosition); - void RenderVBO(vector3 *vPosition); - void RenderAlphaVBO(vector3 *vPosition); - int Flags(); - void RaAnglesSet(double a, double b, double c) - { - vAngle.x = a; - vAngle.y = b; - vAngle.z = c; - }; - bool TerrainLoaded(); + TAnimContainer * AddContainer(std::string const &Name); + TAnimContainer * GetContainer(std::string const &Name = ""); + void LightSet( int const n, float const v ); + void AnimationVND( void *pData, double a, double b, double c, double d ); int TerrainCount(); TSubModel * TerrainSquare(int n); - void TerrainRenderVBO(int n); - void AnimationVND(void *pData, double a, double b, double c, double d); - void LightSet(int n, float v); - static void AnimUpdate(double dt); + int Flags(); + inline + material_data const * + Material() const { + return &m_materialdata; } + inline + TModel3d * + Model() const { + return pModel; } + inline + void + Angles( glm::vec3 const &Angles ) { + vAngle = Angles; } + inline + glm::vec3 + Angles() const { + return vAngle; } +// members + static TAnimContainer *acAnimList; // lista animacji z eventem, które muszą być przeliczane również bez wyświetlania + +private: +// methods + void RaPrepare(); // ustawienie animacji egzemplarza na wzorcu + void RaAnimate( unsigned int const Framestamp ); // przeliczenie animacji egzemplarza + void Advanced(); + // radius() subclass details, calculates node's bounding radius + float radius_(); + // serialize() subclass details, sends content of the subclass to provided stream + void serialize_( std::ostream &Output ) const; + // deserialize() subclass details, restores content of the subclass from provided stream + void deserialize_( std::istream &Input ); + // export() subclass details, sends basic content of the class in legacy (text) format to provided stream + void export_as_text_( std::ostream &Output ) const; + +// members + TAnimContainer *pRoot { nullptr }; // pojemniki sterujące, tylko dla aniomowanych submodeli + TModel3d *pModel { nullptr }; +// double fBlinkTimer { 0.0 }; + int iNumLights { 0 }; + TSubModel *LightsOn[ iMaxNumLights ]; // Ra: te wskaźniki powinny być w ramach TModel3d + TSubModel *LightsOff[ iMaxNumLights ]; + glm::vec3 vAngle; // bazowe obroty egzemplarza względem osi + material_data m_materialdata; + + std::string asText; // tekst dla wyświetlacza znakowego + TAnimAdvanced *pAdvanced { nullptr }; + // TODO: wrap into a light state struct + float lsLights[ iMaxNumLights ]; + std::array m_lighttimers { 0.f }; + std::array m_lightopacities { 1.f }; + float fOnTime { 1.f / 2 };// { 60.f / 45.f / 2 }; + float fOffTime { 1.f / 2 };// { 60.f / 45.f / 2 }; // były stałymi, teraz mogą być zmienne dla każdego egzemplarza + float fTransitionTime { fOnTime * 0.9f }; // time + unsigned int m_framestamp { 0 }; // id of last rendered gfx frame }; + +class instance_table : public basic_table { + +}; + //--------------------------------------------------------------------------- -#endif diff --git a/Button.cpp b/Button.cpp index 77016856..0c9df08b 100644 --- a/Button.cpp +++ b/Button.cpp @@ -9,75 +9,153 @@ http://mozilla.org/MPL/2.0/. #include "stdafx.h" #include "Button.h" +#include "parser.h" +#include "Model3d.h" #include "Console.h" - -//--------------------------------------------------------------------------- - -TButton::TButton() -{ - iFeedbackBit = 0; - bData = NULL; - Clear(); -}; - -TButton::~TButton(){}; +#include "logs.h" +#include "renderer.h" void TButton::Clear(int i) { - pModelOn = NULL; - pModelOff = NULL; - bOn = false; + pModelOn = nullptr; + pModelOff = nullptr; + m_state = false; if (i >= 0) FeedbackBitSet(i); Update(); // kasowanie bitu Feedback, o ile jakiś ustawiony }; -void TButton::Init(std::string const &asName, TModel3d *pModel, bool bNewOn) -{ - if (!pModel) - return; // nie ma w czym szukać - pModelOn = pModel->GetFromName( (asName + "_on").c_str() ); - pModelOff = pModel->GetFromName( (asName + "_off").c_str() ); - bOn = bNewOn; +void TButton::Init( std::string const &asName, TModel3d *pModel, bool bNewOn ) { + + if( pModel == nullptr ) { return; } + + pModelOn = pModel->GetFromName( asName + "_on" ); + pModelOff = pModel->GetFromName( asName + "_off" ); + m_state = bNewOn; Update(); }; -void TButton::Load(cParser &Parser, TModel3d *pModel1, TModel3d *pModel2) -{ - std::string const token = Parser.getToken(); - if (pModel1) - { // poszukiwanie submodeli w modelu - Init(token, pModel1, false); - if (pModel2) - if (!pModelOn && !pModelOff) - Init(token, pModel2, false); // może w drugim będzie (jak nie w kabinie, - // to w zewnętrznym) - } - else - { - pModelOn = NULL; - pModelOff = NULL; - } -}; +void TButton::Load( cParser &Parser, TDynamicObject const *Owner, TModel3d *pModel1, TModel3d *pModel2 ) { -void TButton::Update() -{ - if (bData != NULL) - bOn = (*bData); - if (pModelOn) - pModelOn->iVisible = bOn; - if (pModelOff) - pModelOff->iVisible = !bOn; - if (iFeedbackBit) // jeżeli generuje informację zwrotną - { - if (bOn) // zapalenie + std::string submodelname; + + Parser.getTokens(); + if( Parser.peek() != "{" ) { + // old fixed size config + Parser >> submodelname; + } + else { + // new, block type config + // TODO: rework the base part into yaml-compatible flow style mapping + submodelname = Parser.getToken( false ); + while( true == Load_mapping( Parser ) ) { + ; // all work done by while() + } + } + + // bind defined sounds with the button owner + m_soundfxincrease.owner( Owner ); + m_soundfxdecrease.owner( Owner ); + + if( pModel1 ) { + // poszukiwanie submodeli w modelu + Init( submodelname, pModel1, false ); + } + if( ( pModelOn == nullptr ) + && ( pModelOff == nullptr ) + && ( pModel2 != nullptr ) ) { + // poszukiwanie submodeli w modelu + Init( submodelname, pModel2, false ); + } + + if( ( pModelOn == nullptr ) + && ( pModelOff == nullptr ) ) { + // if we failed to locate even one state submodel, cry + ErrorLog( "Bad model: failed to locate sub-model \"" + submodelname + "\" in 3d model \"" + pModel1->NameGet() + "\"", logtype::model ); + } + + // pass submodel location to defined sounds + auto const nulloffset { glm::vec3{} }; + auto const offset { model_offset() }; + if( m_soundfxincrease.offset() == nulloffset ) { + m_soundfxincrease.offset( offset ); + } + if( m_soundfxdecrease.offset() == nulloffset ) { + m_soundfxdecrease.offset( offset ); + } +} + +bool +TButton::Load_mapping( cParser &Input ) { + + // token can be a key or block end + std::string const key { Input.getToken( true, "\n\r\t ,;" ) }; + if( ( true == key.empty() ) || ( key == "}" ) ) { return false; } + // if not block end then the key is followed by assigned value or sub-block + if( key == "soundinc:" ) { m_soundfxincrease.deserialize( Input, sound_type::single ); } + else if( key == "sounddec:" ) { m_soundfxdecrease.deserialize( Input, sound_type::single ); } + + return true; // return value marks a key: value pair was extracted, nothing about whether it's recognized +} + +// returns offset of submodel associated with the button from the model centre +glm::vec3 +TButton::model_offset() const { + + auto const + submodel { ( + pModelOn ? pModelOn : + pModelOff ? pModelOff : + nullptr ) }; + + return ( + submodel != nullptr ? + submodel->offset( std::numeric_limits::max() ) : + glm::vec3() ); +} + +void +TButton::Turn( bool const State ) { + + if( State != m_state ) { + + m_state = State; + play(); + Update(); + } +} + +void TButton::Update() { + + if( ( bData != nullptr ) + && ( *bData != m_state ) ) { + + m_state = ( *bData ); + play(); + } + + if( pModelOn != nullptr ) { pModelOn->iVisible = m_state; } + if( pModelOff != nullptr ) { pModelOff->iVisible = (!m_state); } + +#ifdef _WIN32 + if (iFeedbackBit) { + // jeżeli generuje informację zwrotną + if (m_state) // zapalenie Console::BitsSet(iFeedbackBit); else Console::BitsClear(iFeedbackBit); } +#endif }; -void TButton::AssignBool(bool *bValue) -{ +void TButton::AssignBool(bool const *bValue) { + bData = bValue; } + +void +TButton::play() { + + if( m_state == true ) { m_soundfxincrease.play(); } + else { m_soundfxdecrease.play(); } +} diff --git a/Button.h b/Button.h index 0b79c19f..bfb993ac 100644 --- a/Button.h +++ b/Button.h @@ -7,59 +7,54 @@ obtain one at http://mozilla.org/MPL/2.0/. */ -#ifndef ButtonH -#define ButtonH +#pragma once -#include -#include "Model3d.h" -#include "parser.h" +#include "Classes.h" +#include "sound.h" -class TButton -{ // animacja dwustanowa, włącza jeden z dwóch submodeli (jednego - // z nich może nie być) - private: - TSubModel *pModelOn, *pModelOff; // submodel dla stanu załączonego i wyłączonego - bool bOn; - bool *bData; - int iFeedbackBit; // Ra: bit informacji zwrotnej, do wyprowadzenia na pulpit +// animacja dwustanowa, włącza jeden z dwóch submodeli (jednego z nich może nie być) +class TButton { - public: - TButton(); - ~TButton(); - void Clear(int i = -1); - inline void FeedbackBitSet(int i) - { - iFeedbackBit = 1 << i; - }; - inline void Turn(bool to) - { - bOn = to; - Update(); - }; - inline void TurnOn() - { - bOn = true; - Update(); - }; - inline void TurnOff() - { - bOn = false; - Update(); - }; - inline void Switch() - { - bOn = !bOn; - Update(); - }; - inline bool Active() - { - return (pModelOn) || (pModelOff); - }; +public: +// methods + TButton() = default; + void Clear(int const i = -1); + inline + void FeedbackBitSet( int const i ) { + iFeedbackBit = 1 << i; }; + void Turn( bool const State ); + inline + bool GetValue() const { + return m_state; } + inline + bool Active() { + return ( ( pModelOn != nullptr ) + || ( pModelOff != nullptr ) ); } void Update(); - void Init(std::string const &asName, TModel3d *pModel, bool bNewOn = false); - void Load(cParser &Parser, TModel3d *pModel1, TModel3d *pModel2 = NULL); - void AssignBool(bool *bValue); + void Init( std::string const &asName, TModel3d *pModel, bool bNewOn = false ); + void Load( cParser &Parser, TDynamicObject const *Owner, TModel3d *pModel1, TModel3d *pModel2 = nullptr ); + void AssignBool(bool const *bValue); + // returns offset of submodel associated with the button from the model centre + glm::vec3 model_offset() const; + +private: +// methods + // imports member data pair from the config file + bool + Load_mapping( cParser &Input ); + // plays the sound associated with current state + void + play(); + +// members + TSubModel + *pModelOn { nullptr }, + *pModelOff { nullptr }; // submodel dla stanu załączonego i wyłączonego + bool m_state { false }; + bool const *bData { nullptr }; + int iFeedbackBit { 0 }; // Ra: bit informacji zwrotnej, do wyprowadzenia na pulpit + sound_source m_soundfxincrease { sound_placement::internal, EU07_SOUND_CABCONTROLSCUTOFFRANGE }; // sound associated with increasing control's value + sound_source m_soundfxdecrease { sound_placement::internal, EU07_SOUND_CABCONTROLSCUTOFFRANGE }; // sound associated with decreasing control's value }; //--------------------------------------------------------------------------- -#endif diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 00000000..bd25b5ac --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,107 @@ +cmake_minimum_required(VERSION 3.0) +set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/CMake_modules/") +project("eu07++ng") + +include_directories("." "Console" "McZapkie") +file(GLOB HEADERS "*.h" "Console/*.h" "McZapkie/*.h") + +set(SOURCES +"Texture.cpp" +"TextureDDS.cpp" +"Timer.cpp" +"Track.cpp" +"Traction.cpp" +"TractionPower.cpp" +"Train.cpp" +"TrkFoll.cpp" +"VBO.cpp" +"wavread.cpp" +"World.cpp" +"AdvSound.cpp" +"AirCoupler.cpp" +"AnimModel.cpp" +"Button.cpp" +"Camera.cpp" +"Console.cpp" +"console/LPT.cpp" +"Console/MWD.cpp" +"console/PoKeys55.cpp" +"Driver.cpp" +"dumb3d.cpp" +"DynObj.cpp" +"EU07.cpp" +"Event.cpp" +"EvLaunch.cpp" +"FadeSound.cpp" +"Float3d.cpp" +"Gauge.cpp" +"Globals.cpp" +"Ground.cpp" +"Logs.cpp" +"mczapkie/friction.cpp" +"mczapkie/hamulce.cpp" +"mczapkie/mctools.cpp" +"mczapkie/Mover.cpp" +"mczapkie/Oerlikon_ESt.cpp" +"MdlMngr.cpp" +"MemCell.cpp" +"Model3d.cpp" +"mtable.cpp" +"parser.cpp" +"renderer.cpp" +"PyInt.cpp" +"RealSound.cpp" +"ResourceManager.cpp" +"sn_utils.cpp" +"Segment.cpp" +"sky.cpp" +"sun.cpp" +"stars.cpp" +"lightarray.cpp" +"skydome.cpp" +"Sound.cpp" +"Spring.cpp" +"shader.cpp" +) + +if (WIN32) + add_definitions(-DHAVE_ROUND) # to make pymath to not redefine round + set(SOURCES ${SOURCES} "windows.cpp") +endif() + +if (${CMAKE_CXX_COMPILER_ID} STREQUAL MSVC) + set(SOURCES ${SOURCES} "eu07.rc") + set(SOURCES ${SOURCES} "eu07.ico") +endif() + +add_executable(${PROJECT_NAME} ${SOURCES} ${HEADERS}) + +if (${CMAKE_CXX_COMPILER_ID} STREQUAL MSVC) + # /wd4996: disable "deprecation" warnings + # /wd4244: disable warnings for conversion with possible loss of data + set_target_properties(${PROJECT_NAME} PROPERTIES COMPILE_FLAGS "/wd4996 /wd4244") +endif() + +find_package(OpenGL REQUIRED) +include_directories(${OPENGL_INCLUDE_DIR}) +target_link_libraries(${PROJECT_NAME} ${OPENGL_LIBRARIES}) + +find_package(GLEW REQUIRED) +include_directories(${GLEW_INCLUDE_DIRS}) +target_link_libraries(${PROJECT_NAME} ${GLEW_LIBRARIES}) + +find_package(GLFW3 REQUIRED) +include_directories(${GLFW3_INCLUDE_DIR}) +target_link_libraries(${PROJECT_NAME} ${GLFW3_LIBRARIES}) + +find_package(GLUT REQUIRED) +include_directories(${GLUT_INCLUDE_DIR}) +target_link_libraries(${PROJECT_NAME} ${GLUT_LIBRARIES}) + +find_package(PythonLibs 2 REQUIRED) +include_directories(${PYTHON_INCLUDE_DIRS}) +target_link_libraries(${PROJECT_NAME} ${PYTHON_LIBRARIES}) + +find_package(PNG REQUIRED) +include_directories(${PNG_INCLUDE_DIRS}) +target_link_libraries(${PROJECT_NAME} ${PNG_LIBRARIES}) \ No newline at end of file diff --git a/CMake_modules/FindGLFW3.cmake b/CMake_modules/FindGLFW3.cmake new file mode 100644 index 00000000..a92f95a8 --- /dev/null +++ b/CMake_modules/FindGLFW3.cmake @@ -0,0 +1,75 @@ +# - Try to find GLFW3 +# +# If no pkgconfig, define GLFW_ROOT to installation tree +# Will define the following: +# GLFW3_FOUND +# GLFW3_INCLUDE_DIR +# GLFW3_LIBRARIES + +IF(PKG_CONFIG_FOUND) + IF(APPLE) + # homebrew or macports pkgconfig locations + SET(ENV{PKG_CONFIG_PATH} "/usr/local/opt/glfw3/lib/pkgconfig:/opt/local/lib/pkgconfig") + ENDIF() + SET(ENV{PKG_CONFIG_PATH} "${DEPENDS_DIR}/glfw/lib/pkgconfig:$ENV{PKG_CONFIG_PATH}") + PKG_CHECK_MODULES(GLFW3 glfw3) + + FIND_LIBRARY(GLFW3_LIBRARY + NAMES ${GLFW3_LIBRARIES} + HINTS ${GLFW3_LIBRARY_DIR} + ) + SET(GLFW3_LIBRARIES ${GLFW3_LIBRARY}) + + RETURN() +ENDIF() + +FIND_PATH(GLFW3_INCLUDE_DIR + GLFW/glfw3.h + DOC "GLFW include directory " + PATHS + "${DEPENDS_DIR}/glfw" + "$ENV{ProgramW6432}/glfw" + ${GLFW3_ROOT_PATH} + PATH_SUFFIXES + include +) + +# directories in the official binary package +IF(MINGW) + SET(_SUFFIX lib-mingw) +ELSEIF(MSVC11) + SET(_SUFFIX lib-vc2012) +ELSEIF(MSVC12) + SET(_SUFFIX lib-vc2013) +ELSEIF(MSVC14) + SET(_SUFFIX lib-vc2015) +ELSEIF(MSVC) + SET(_SUFFIX lib-vc2012) +ENDIF() + +FIND_LIBRARY(GLFW3_LIBRARIES + NAMES glfw3dll glfw3 + PATHS + "${DEPENDS_DIR}/glfw" + "$ENV{ProgramW6432}/glfw" + ${GLFW3_ROOT_PATH} + PATH_SUFFIXES + lib + ${_SUFFIX} +) + +IF(WIN32) +FIND_FILE(GLFW3_DLL + glfw3.dll + PATHS + "${DEPENDS_DIR}/glfw" + "$ENV{ProgramW6432}/glfw" + ${GLFW3_ROOT_PATH} + PATH_SUFFIXES + ${_SUFFIX} +) +ENDIF() + +INCLUDE(FindPackageHandleStandardArgs) +FIND_PACKAGE_HANDLE_STANDARD_ARGS(GLFW3 FOUND_VAR GLFW3_FOUND + REQUIRED_VARS GLFW3_LIBRARIES GLFW3_INCLUDE_DIR) diff --git a/Camera.cpp b/Camera.cpp index 4c20b7e5..47272eb3 100644 --- a/Camera.cpp +++ b/Camera.cpp @@ -11,195 +11,229 @@ http://mozilla.org/MPL/2.0/. #include "Camera.h" #include "Globals.h" -#include "Usefull.h" +#include "utilities.h" #include "Console.h" #include "Timer.h" #include "mover.h" + //--------------------------------------------------------------------------- -// TViewPyramid TCamera::OrgViewPyramid; -//={vector3(-1,1,1),vector3(1,1,1),vector3(-1,-1,1),vector3(1,-1,1),vector3(0,0,0)}; +void TCamera::Init( Math3D::vector3 const &NPos, Math3D::vector3 const &NAngle, TCameraType const NType ) { -const vector3 OrgCrossPos = vector3(0, -10, 0); - -void TCamera::Init(vector3 NPos, vector3 NAngle) -{ - - pOffset = vector3(-0.0, 0, 0); - vUp = vector3(0, 1, 0); - // pOffset= vector3(-0.8,0,0); - CrossPos = OrgCrossPos; - CrossDist = 10; - Velocity = vector3(0, 0, 0); - OldVelocity = vector3(0, 0, 0); + vUp = { 0, 1, 0 }; + Velocity = { 0, 0, 0 }; Pitch = NAngle.x; Yaw = NAngle.y; Roll = NAngle.z; Pos = NPos; - // Type= tp_Follow; - Type = (Global::bFreeFly ? tp_Free : tp_Follow); - // Type= tp_Free; + Type = NType; }; -void TCamera::OnCursorMove(double x, double y) -{ - // McZapkie-170402: zeby mysz dzialala zawsze if (Type==tp_Follow) - Pitch += y; - Yaw += -x; - if (Yaw > M_PI) +void TCamera::Reset() { + + Pitch = Yaw = Roll = 0; + m_rotationoffsets = {}; +}; + + +void TCamera::OnCursorMove(double x, double y) { +/* + Yaw -= x; + while( Yaw > M_PI ) { Yaw -= 2 * M_PI; - else if (Yaw < -M_PI) - Yaw += 2 * M_PI; - if (Type == tp_Follow) // jeżeli jazda z pojazdem - { - Fix(Pitch, -M_PI_4, M_PI_4); // ograniczenie kąta spoglądania w dół i w górę - // Fix(Yaw,-M_PI,M_PI); } + while( Yaw < -M_PI ) { + Yaw += 2 * M_PI; + } + Pitch -= y; + if (Type == tp_Follow) { + // jeżeli jazda z pojazdem ograniczenie kąta spoglądania w dół i w górę + Pitch = clamp( Pitch, -M_PI_4, M_PI_4 ); + } +*/ + m_rotationoffsets += glm::dvec3 { y, x, 0.0 }; +} + +bool +TCamera::OnCommand( command_data const &Command ) { + + auto const walkspeed { 1.0 }; + auto const runspeed { 10.0 }; + + bool iscameracommand { true }; + switch( Command.command ) { + + case user_command::viewturn: { + + OnCursorMove( + Command.param1 * 0.005 * Global.fMouseXScale / Global.ZoomFactor, + Command.param2 * 0.01 * Global.fMouseYScale / Global.ZoomFactor ); + break; + } + + case user_command::movehorizontal: + case user_command::movehorizontalfast: { + + auto const movespeed = ( + Type == TCameraType::tp_Free ? runspeed : + Type == TCameraType::tp_Follow ? walkspeed : + 0.0 ); + + auto const speedmultiplier = ( + ( ( Type == TCameraType::tp_Free ) && ( Command.command == user_command::movehorizontalfast ) ) ? + 30.0 : + 1.0 ); + + // left-right + auto const movexparam { Command.param1 }; + // 2/3rd of the stick range enables walk speed, past that we lerp between walk and run speed + auto const movex { walkspeed + ( std::max( 0.0, std::abs( movexparam ) - 0.65 ) / 0.35 ) * ( movespeed - walkspeed ) }; + + m_moverate.x = ( + movexparam > 0.0 ? movex * speedmultiplier : + movexparam < 0.0 ? -movex * speedmultiplier : + 0.0 ); + + // forward-back + double const movezparam { Command.param2 }; + auto const movez { walkspeed + ( std::max( 0.0, std::abs( movezparam ) - 0.65 ) / 0.35 ) * ( movespeed - walkspeed ) }; + // NOTE: z-axis is flipped given world coordinate system + m_moverate.z = ( + movezparam > 0.0 ? -movez * speedmultiplier : + movezparam < 0.0 ? movez * speedmultiplier : + 0.0 ); + + break; + } + + case user_command::movevertical: + case user_command::moveverticalfast: { + + auto const movespeed = ( + Type == TCameraType::tp_Free ? runspeed * 0.5 : + Type == TCameraType::tp_Follow ? walkspeed : + 0.0 ); + + auto const speedmultiplier = ( + ( ( Type == TCameraType::tp_Free ) && ( Command.command == user_command::moveverticalfast ) ) ? + 10.0 : + 1.0 ); + + // up-down + auto const moveyparam { Command.param1 }; + // 2/3rd of the stick range enables walk speed, past that we lerp between walk and run speed + auto const movey { walkspeed + ( std::max( 0.0, std::abs( moveyparam ) - 0.65 ) / 0.35 ) * ( movespeed - walkspeed ) }; + + m_moverate.y = ( + moveyparam > 0.0 ? movey * speedmultiplier : + moveyparam < 0.0 ? -movey * speedmultiplier : + 0.0 ); + + break; + } + + default: { + + iscameracommand = false; + break; + } + } // switch + + return iscameracommand; } void TCamera::Update() { - // ABu: zmiana i uniezaleznienie predkosci od FPS - double a = (Console::Pressed(VK_SHIFT) ? 5.00 : 1.00); - if (Console::Pressed(VK_CONTROL)) - a = a * 100; - // OldVelocity=Velocity; - if (FreeFlyModeFlag == true) - Type = tp_Free; - else - Type = tp_Follow; - if (Type == tp_Free) - { - if (Console::Pressed(Global::Keys[k_MechUp])) - Velocity.y += a; - if (Console::Pressed(Global::Keys[k_MechDown])) - Velocity.y -= a; - // McZapkie-170402: zeby nie bylo konfliktow - /* - if (Console::Pressed(VkKeyScan('d'))) - Velocity.x+= a*Timer::GetDeltaTime(); - if (Console::Pressed(VkKeyScan('a'))) - Velocity.x-= a*Timer::GetDeltaTime(); - if (Console::Pressed(VkKeyScan('w'))) - Velocity.z-= a*Timer::GetDeltaTime(); - if (Console::Pressed(VkKeyScan('s'))) - Velocity.z+= a*Timer::GetDeltaTime(); + if( FreeFlyModeFlag == true ) { Type = TCameraType::tp_Free; } + else { Type = TCameraType::tp_Follow; } - if (Console::Pressed(VK_NUMPAD4) || Console::Pressed(VK_NUMPAD7) || - Console::Pressed(VK_NUMPAD1)) - Yaw+= +1*M_PI*Timer::GetDeltaTime(); + // check for sent user commands + // NOTE: this is a temporary arrangement, for the transition period from old command setup to the new one + // ultimately we'll need to track position of camera/driver for all human entities present in the scenario + command_data command; + // NOTE: currently we're only storing commands for local entity and there's no id system in place, + // so we're supplying 'default' entity id of 0 + while( simulation::Commands.pop( command, static_cast( command_target::entity ) | 0 ) ) { - if (Console::Pressed(VK_NUMPAD6) || Console::Pressed(VK_NUMPAD9) || - Console::Pressed(VK_NUMPAD3)) - Yaw+= -1*M_PI*Timer::GetDeltaTime(); + OnCommand( command ); + } - if (Pressed(VK_NUMPAD2) || Console::Pressed(VK_NUMPAD1) || - Console::Pressed(VK_NUMPAD3)) - Pitch+= -1*M_PI*Timer::GetDeltaTime(); - - if (Console::Pressed(VK_NUMPAD8) || Console::Pressed(VK_NUMPAD7) || - Console::Pressed(VK_NUMPAD9)) - Pitch+= +1*M_PI*Timer::GetDeltaTime(); - if (Console::Pressed(VkKeyScan('.'))) - Roll+= -1*M_PI*Timer::GetDeltaTime(); - if (Console::Pressed(VkKeyScan(','))) - Roll+= +1*M_PI*Timer::GetDeltaTime(); - - if (Console::Pressed(VK_NUMPAD5)) - Pitch=Roll= 0.0f; - */ + auto const deltatime { Timer::GetDeltaRenderTime() }; // czas bez pauzy + // update position + if( ( Type == TCameraType::tp_Free ) + || ( false == Global.ctrlState ) + || ( true == DebugCameraFlag ) ) { + // ctrl is used for mirror view, so we ignore the controls when in vehicle if ctrl is pressed // McZapkie-170402: poruszanie i rozgladanie we free takie samo jak w follow - if (Console::Pressed(Global::Keys[k_MechRight])) - Velocity.x += a; - if (Console::Pressed(Global::Keys[k_MechLeft])) - Velocity.x -= a; - if (Console::Pressed(Global::Keys[k_MechForward])) - Velocity.z -= a; - if (Console::Pressed(Global::Keys[k_MechBackward])) - Velocity.z += a; - // gora-dol - // if (Console::Pressed(VK_NUMPAD9)) Pos.y+=0.1; - // if (Console::Pressed(VK_NUMPAD3)) Pos.y-=0.1; + Velocity.x = clamp( Velocity.x + m_moverate.x * 10.0 * deltatime, -std::abs( m_moverate.x ), std::abs( m_moverate.x ) ); + Velocity.z = clamp( Velocity.z + m_moverate.z * 10.0 * deltatime, -std::abs( m_moverate.z ), std::abs( m_moverate.z ) ); + Velocity.y = clamp( Velocity.y + m_moverate.y * 10.0 * deltatime, -std::abs( m_moverate.y ), std::abs( m_moverate.y ) ); + } - // McZapkie: zeby nie hustalo przy malym FPS: - // Velocity= (Velocity+OldVelocity)/2; - // matrix4x4 mat; - vector3 Vec = Velocity; - Vec.RotateY(Yaw); - Pos = Pos + Vec * Timer::GetDeltaRenderTime(); // czas bez pauzy - Velocity = Velocity / 2; // płynne hamowanie ruchu - // double tmp= 10*DeltaTime; - // Velocity+= -Velocity*10 * Timer::GetDeltaTime();//( tmp<1 ? tmp : 1 ); - // Type= tp_Free; + if( ( Type == TCameraType::tp_Free ) + || ( true == DebugCameraFlag ) ) { + // free movement position update is handled here, movement while in vehicle is handled by train update + Math3D::vector3 Vec = Velocity; + Vec.RotateY( Yaw ); + Pos += Vec * 5.0 * deltatime; + } + // update rotation + auto const rotationfactor { std::min( 1.0, 20 * deltatime ) }; + + Yaw -= rotationfactor * m_rotationoffsets.y; + m_rotationoffsets.y *= ( 1.0 - rotationfactor ); + while( Yaw > M_PI ) { + Yaw -= 2 * M_PI; + } + while( Yaw < -M_PI ) { + Yaw += 2 * M_PI; + } + + Pitch -= rotationfactor * m_rotationoffsets.x; + m_rotationoffsets.x *= ( 1.0 - rotationfactor ); + if( Type == TCameraType::tp_Follow ) { + // jeżeli jazda z pojazdem ograniczenie kąta spoglądania w dół i w górę + Pitch = clamp( Pitch, -M_PI_4, M_PI_4 ); } } -vector3 TCamera::GetDirection() -{ - matrix4x4 mat; - vector3 Vec; - Vec = vector3(0, 0, 1); - Vec.RotateY(Yaw); +Math3D::vector3 TCamera::GetDirection() { - return (Normalize(Vec)); + return glm::normalize( glm::rotateY( glm::vec3{ 0.f, 0.f, 1.f }, Yaw ) ); } -// bool TCamera::GetMatrix(matrix4x4 &Matrix) -bool TCamera::SetMatrix() -{ - glRotated(-Roll * 180.0f / M_PI, 0, 0, 1); // po wyłączeniu tego kręci się pojazd, a sceneria - // nie - glRotated(-Pitch * 180.0f / M_PI, 1, 0, 0); - glRotated(-Yaw * 180.0f / M_PI, 0, 1, 0); // w zewnętrznym widoku: kierunek patrzenia +bool TCamera::SetMatrix( glm::dmat4 &Matrix ) { - if (Type == tp_Follow) - { - // gluLookAt(Pos.x+pOffset.x,Pos.y+pOffset.y,Pos.z+pOffset.z, - // LookAt.x+pOffset.x,LookAt.y+pOffset.y,LookAt.z+pOffset.z,vUp.x,vUp.y,vUp.z); - // gluLookAt(Pos.x+pOffset.x,Pos.y+pOffset.y,Pos.z+pOffset.z, - // LookAt.x+pOffset.x,LookAt.y+pOffset.y,LookAt.z+pOffset.z,vUp.x,vUp.y,vUp.z); - gluLookAt(Pos.x, Pos.y, Pos.z, LookAt.x, LookAt.y, LookAt.z, vUp.x, vUp.y, - vUp.z); // Ra: pOffset is zero - // gluLookAt(Pos.x,Pos.y,Pos.z,Pos.x+Velocity.x,Pos.y+Velocity.y,Pos.z+Velocity.z,0,1,0); - // return true; + Matrix = glm::rotate( Matrix, -Roll, glm::dvec3( 0.0, 0.0, 1.0 ) ); // po wyłączeniu tego kręci się pojazd, a sceneria nie + Matrix = glm::rotate( Matrix, -Pitch, glm::dvec3( 1.0, 0.0, 0.0 ) ); + Matrix = glm::rotate( Matrix, -Yaw, glm::dvec3( 0.0, 1.0, 0.0 ) ); // w zewnętrznym widoku: kierunek patrzenia + + if( ( Type == TCameraType::tp_Follow ) && ( false == DebugCameraFlag ) ) { + + Matrix *= glm::lookAt( + glm::dvec3{ Pos }, + glm::dvec3{ LookAt }, + glm::dvec3{ vUp } ); + } + else { + Matrix = glm::translate( Matrix, glm::dvec3{ -Pos } ); // nie zmienia kierunku patrzenia } - if (Type == tp_Satelite) - Pitch = M_PI * 0.5; - - if (Type != tp_Follow) - { - glTranslated(-Pos.x, -Pos.y, -Pos.z); // nie zmienia kierunku patrzenia - } - - Global::SetCameraPosition(Pos); // było +pOffset return true; } -void TCamera::SetCabMatrix(vector3 &p) -{ // ustawienie widoku z kamery bez przesunięcia robionego przez OpenGL - nie powinno tak trząść - glRotated(-Roll * 180.0f / M_PI, 0, 0, 1); - glRotated(-Pitch * 180.0f / M_PI, 1, 0, 0); - glRotated(-Yaw * 180.0f / M_PI, 0, 1, 0); // w zewnętrznym widoku: kierunek patrzenia - if (Type == tp_Follow) - gluLookAt(Pos.x - p.x, Pos.y - p.y, Pos.z - p.z, LookAt.x - p.x, LookAt.y - p.y, - LookAt.z - p.z, vUp.x, vUp.y, vUp.z); // Ra: pOffset is zero -} - void TCamera::RaLook() { // zmiana kierunku patrzenia - przelicza Yaw - vector3 where = LookAt - Pos + vector3(0, 3, 0); // trochę w górę od szyn - if ((where.x != 0.0) || (where.z != 0.0)) - Yaw = atan2(-where.x, -where.z); // kąt horyzontalny - double l = Length3(where); - if (l > 0.0) - Pitch = asin(where.y / l); // kąt w pionie -}; - -void TCamera::Stop() -{ // wyłącznie bezwładnego ruchu po powrocie do kabiny - Type = tp_Follow; - Velocity = vector3(0, 0, 0); + Math3D::vector3 where = LookAt - Pos + Math3D::vector3(0, 3, 0); // trochę w górę od szyn + if( ( where.x != 0.0 ) || ( where.z != 0.0 ) ) { + Yaw = atan2( -where.x, -where.z ); // kąt horyzontalny + m_rotationoffsets.y = 0.0; + } + double l = Math3D::Length3(where); + if( l > 0.0 ) { + Pitch = asin( where.y / l ); // kąt w pionie + m_rotationoffsets.x = 0.0; + } }; diff --git a/Camera.h b/Camera.h index 0d1ab315..b2792b18 100644 --- a/Camera.h +++ b/Camera.h @@ -7,51 +7,42 @@ obtain one at http://mozilla.org/MPL/2.0/. */ -#ifndef CameraH -#define CameraH +#pragma once #include "dumb3d.h" -using namespace Math3D; +#include "command.h" //--------------------------------------------------------------------------- -enum TCameraType +enum class TCameraType { // tryby pracy kamery tp_Follow, // jazda z pojazdem tp_Free, // stoi na scenerii tp_Satelite // widok z góry (nie używany) }; -class TCamera -{ - private: - vector3 pOffset; // nie używane (zerowe) +class TCamera { + public: // McZapkie: potrzebuje do kiwania na boki + void Init( Math3D::vector3 const &Location, Math3D::vector3 const &Angle, TCameraType const Type ); + void Reset(); + void OnCursorMove(double const x, double const y); + bool OnCommand( command_data const &Command ); + void Update(); + Math3D::vector3 GetDirection(); + bool SetMatrix(glm::dmat4 &Matrix); + void RaLook(); + + TCameraType Type; double Pitch; double Yaw; // w środku: 0=do przodu; na zewnątrz: 0=na południe double Roll; - TCameraType Type; - vector3 Pos; // współrzędne obserwatora - vector3 LookAt; // współrzędne punktu, na który ma patrzeć - vector3 vUp; - vector3 Velocity; - vector3 OldVelocity; // lepiej usredniac zeby nie bylo rozbiezne przy malym FPS - vector3 CrossPos; - double CrossDist; - void Init(vector3 NPos, vector3 NAngle); - void Reset() - { - Pitch = Yaw = Roll = 0; - }; - void OnCursorMove(double x, double y); - void Update(); - vector3 GetDirection(); - // vector3 inline GetCrossPos() { return Pos+GetDirection()*CrossDist+CrossPos; }; + Math3D::vector3 Pos; // współrzędne obserwatora + Math3D::vector3 LookAt; // współrzędne punktu, na który ma patrzeć + Math3D::vector3 vUp; + Math3D::vector3 Velocity; + +private: + glm::dvec3 m_moverate; + glm::dvec3 m_rotationoffsets; // requested changes to pitch, yaw and roll - bool SetMatrix(); - void SetCabMatrix(vector3 &p); - void RaLook(); - void Stop(); - // bool GetMatrix(matrix4x4 &Matrix); - vector3 PtNext, PtPrev; }; -#endif diff --git a/Classes.h b/Classes.h index 5bafa69d..1fe63ed0 100644 --- a/Classes.h +++ b/Classes.h @@ -12,22 +12,39 @@ http://mozilla.org/MPL/2.0/. //--------------------------------------------------------------------------- // Ra: zestaw klas do robienia wskaźników, aby uporządkować nagłówki //--------------------------------------------------------------------------- +class opengl_renderer; class TTrack; // odcinek trajektorii -class TEvent; +class basic_event; class TTrain; // pojazd sterowany class TDynamicObject; // pojazd w scenerii -class TGroundNode; // statyczny obiekt scenerii +struct material_data; class TAnimModel; // opakowanie egzemplarz modelu class TAnimContainer; // fragment opakowania egzemplarza modelu class TModel3d; //siatka modelu wspólna dla egzemplarzy class TSubModel; // fragment modelu (tu do wyświetlania terenu) class TMemCell; // komórka pamięci class cParser; -class TRealSound; // dźwięk ze współrzędnymi XYZ -class TTextSound; // dźwięk ze stenogramem +class sound_source; class TEventLauncher; class TTraction; // drut class TTractionPowerSource; // zasilanie drutów +class TCamera; +class scenario_time; +class TMoverParameters; +class ui_layer; +class editor_ui; +class itemproperties_panel; +class event_manager; +class memory_table; +class powergridsource_table; +class instance_table; +class vehicle_table; +struct light_array; + +namespace scene { +struct node_data; +class basic_node; +} namespace Mtable { @@ -36,11 +53,8 @@ class TMtableTime; // czas dla danego posterunku }; class TController; // obiekt sterujący pociągiem (AI) -#ifdef EU07_USE_OLD_TNAMES_CLASS -class TNames; // obiekt sortujący nazwy -#endif -typedef enum +enum class TCommandType { // binarne odpowiedniki komend w komórce pamięci cm_Unknown, // ciąg nierozpoznany (nie jest komendą) cm_Ready, // W4 zezwala na odjazd, ale semafor może zatrzymać @@ -54,6 +68,8 @@ typedef enum cm_OutsideStation, cm_Shunt, cm_Command // komenda pobierana z komórki -} TCommandType; +}; + +using material_handle = int; #endif diff --git a/Console.cpp b/Console.cpp index 00157d5f..4556b727 100644 --- a/Console.cpp +++ b/Console.cpp @@ -10,11 +10,11 @@ http://mozilla.org/MPL/2.0/. #include "stdafx.h" #include "Console.h" #include "Globals.h" +#include "application.h" #include "LPT.h" #include "Logs.h" -#include "MWD.h" // maciek001: obsluga portu COM #include "PoKeys55.h" -#include "mczapkie/mctools.h" +#include "utilities.h" //--------------------------------------------------------------------------- // Ra: klasa statyczna gromadząca sygnały sterujące oraz informacje zwrotne @@ -54,57 +54,17 @@ Działanie jest następujące: /*******************************/ -/* //kod do przetrawienia: -//aby się nie włączacz wygaszacz ekranu, co jakiś czas naciska się wirtualnie ScrollLock - -[DllImport("user32.dll")] -static extern void keybd_event(byte bVk, byte bScan, uint dwFlags, UIntPtr dwExtraInfo); - -private static void PressScrollLock() -{//przyciska i zwalnia ScrollLock - const byte vkScroll = 0x91; - const byte keyeventfKeyup = 0x2; - keybd_event(vkScroll, 0x45, 0, (UIntPtr)0); - keybd_event(vkScroll, 0x45, keyeventfKeyup, (UIntPtr)0); -}; - -[DllImport("user32.dll")] -private static extern bool SystemParametersInfo(int uAction,int uParam,int &lpvParam,int flags); - -public static Int32 GetScreenSaverTimeout() -{ - Int32 value=0; - SystemParametersInfo(14,0,&value,0); - return value; -}; -*/ - // static class member storage allocation TKeyTrans Console::ktTable[4 * 256]; -// Ra: do poprawienia -void SetLedState(char Code, bool bOn){ - // Ra: bajer do migania LED-ami w klawiaturze - // NOTE: disabled for the time being - // TODO: find non Borland specific equivalent, or get rid of it - /* if (Win32Platform == VER_PLATFORM_WIN32_NT) - { - // WriteLog(AnsiString(int(GetAsyncKeyState(Code)))); - if (bool(GetAsyncKeyState(Code)) != bOn) - { - keybd_event(Code, MapVirtualKey(Code, 0), KEYEVENTF_EXTENDEDKEY, 0); - keybd_event(Code, MapVirtualKey(Code, 0), KEYEVENTF_EXTENDEDKEY | KEYEVENTF_KEYUP, - 0); - } - } - else - { - TKeyboardState KBState; - GetKeyboardState(KBState); - KBState[Code] = bOn ? 1 : 0; - SetKeyboardState(KBState); - }; - */ +// Ra: bajer do migania LED-ami w klawiaturze +void SetLedState( unsigned char Code, bool bOn ) { +#ifdef _WIN32 + if( bOn != ( ::GetKeyState( Code ) != 0 ) ) { + keybd_event( Code, MapVirtualKey( Code, 0 ), KEYEVENTF_EXTENDEDKEY | 0, 0 ); + keybd_event( Code, MapVirtualKey( Code, 0 ), KEYEVENTF_EXTENDEDKEY | KEYEVENTF_KEYUP, 0 ); + } +#endif }; //--------------------------------------------------------------------------- @@ -114,7 +74,6 @@ int Console::iMode = 0; int Console::iConfig = 0; TPoKeys55 *Console::PoKeys55[2] = {NULL, NULL}; TLPT *Console::LPT = NULL; -TMWDComm *Console::MWDComm = NULL; // maciek001: obiekt dla MWD int Console::iSwitch[8]; // bistabilne w kabinie, załączane z [Shift], wyłączane bez int Console::iButton[8]; // monostabilne w kabinie, załączane podczas trzymania klawisza @@ -126,14 +85,11 @@ Console::Console() iSwitch[i] = 0; // bity 0..127 - bez [Ctrl], 128..255 - z [Ctrl] iButton[i] = 0; // bity 0..127 - bez [Shift], 128..255 - z [Shift] } - MWDComm = NULL; }; Console::~Console() { - delete PoKeys55[0]; - delete PoKeys55[1]; - delete MWDComm; + Console::Off(); }; void Console::ModeSet(int m, int h) @@ -146,7 +102,7 @@ int Console::On() { // załączenie konsoli (np. nawiązanie komunikacji) iSwitch[0] = iSwitch[1] = iSwitch[2] = iSwitch[3] = 0; // bity 0..127 - bez [Ctrl] iSwitch[4] = iSwitch[5] = iSwitch[6] = iSwitch[7] = 0; // bity 128..255 - z [Ctrl] - switch (iMode) + switch (iMode) { case 1: // kontrolki klawiatury case 2: // kontrolki klawiatury @@ -176,22 +132,11 @@ int Console::On() { // połączenie nie wyszło, ma być NULL delete PoKeys55[0]; PoKeys55[0] = NULL; + WriteLog("PoKeys not found!"); } break; } - if (Global::bMWDmasterEnable) - { - WriteLog("Opening ComPort"); - MWDComm = new TMWDComm(); - if (!(MWDComm->Open())) // jeżeli nie otwarł portu - { - WriteLog("ERROR: ComPort is NOT OPEN!"); - delete MWDComm; - MWDComm = NULL; - } - } - return 0; }; @@ -204,14 +149,9 @@ void Console::Off() SetLedState(VK_SCROLL, true); // przyciśnięty SetLedState(VK_SCROLL, false); // zwolniony } - delete PoKeys55[0]; - PoKeys55[0] = NULL; - delete PoKeys55[1]; - PoKeys55[1] = NULL; - delete LPT; - LPT = NULL; - delete MWDComm; - MWDComm = NULL; + SafeDelete( PoKeys55[0] ); + SafeDelete( PoKeys55[1] ); + SafeDelete( LPT ); }; void Console::BitsSet(int mask, int entry) @@ -242,22 +182,24 @@ void Console::BitsUpdate(int mask) switch (iMode) { case 1: // sterowanie światełkami klawiatury: CA/SHP+opory - if (mask & 3) // gdy SHP albo CA - SetLedState(VK_CAPITAL, iBits & 3); - if (mask & 4) // gdy jazda na oporach - { // Scroll Lock ma jakoś dziwnie... zmiana stanu na przeciwny - SetLedState(VK_SCROLL, true); // przyciśnięty - SetLedState(VK_SCROLL, false); // zwolniony + if( mask & 3 ) { + // gdy SHP albo CA + SetLedState( VK_CAPITAL, ( iBits & 3 ) != 0 ); + } + if (mask & 4) { + // gdy jazda na oporach + SetLedState( VK_SCROLL, ( iBits & 4 ) != 0 ); ++iConfig; // licznik użycia Scroll Lock } break; case 2: // sterowanie światełkami klawiatury: CA+SHP - if (mask & 2) // gdy CA - SetLedState(VK_CAPITAL, iBits & 2); - if (mask & 1) // gdy SHP - { // Scroll Lock ma jakoś dziwnie... zmiana stanu na przeciwny - SetLedState(VK_SCROLL, true); // przyciśnięty - SetLedState(VK_SCROLL, false); // zwolniony + if( mask & 2 ) { + // gdy CA + SetLedState( VK_CAPITAL, ( iBits & 2 ) != 0 ); + } + if (mask & 1) { + // gdy SHP + SetLedState( VK_SCROLL, ( iBits & 1 ) != 0 ); ++iConfig; // licznik użycia Scroll Lock } break; @@ -301,152 +243,67 @@ void Console::BitsUpdate(int mask) } break; } - if (Global::bMWDmasterEnable) - { - // maciek001: MWDComm lampki i kontrolki - // out3: ogrzewanie sk?adu, opory rozruchowe, poslizg, zaluzjewent, -, -, czuwak, shp - // out4: stycz.liniowe, pezekaznikr??nicobwpomoc, nadmiarprzetw, roznicowy obw. g?, nadmiarsilniki, wylszybki, zanikpr?duprzyje?dzienaoporach, nadmiarsprezarki - // out5: HASLER */ - if (mask & 0x0001) if (iBits & 1) { - MWDComm->WriteDataBuff[4] |= 1 << 7; // SHP HASLER też - if (!MWDComm->bSHPstate) { - MWDComm->bSHPstate = true; - MWDComm->bPrzejazdSHP = true; - } - else MWDComm->bPrzejazdSHP = false; - } - else { - MWDComm->WriteDataBuff[4] &= ~(1 << 7); - MWDComm->bPrzejazdSHP = false; - MWDComm->bSHPstate = false; - } - if (mask & 0x0002) if (iBits & 2) MWDComm->WriteDataBuff[4] |= 1 << 6; // CA - else MWDComm->WriteDataBuff[4] &= ~(1 << 6); - if (mask & 0x0004) if (iBits & 4) MWDComm->WriteDataBuff[4] |= 1 << 1; // jazda na oporach rozruchowych - else MWDComm->WriteDataBuff[4] &= ~(1 << 1); - if (mask & 0x0008) if (iBits & 8) MWDComm->WriteDataBuff[5] |= 1 << 5; // wy??cznik szybki - else MWDComm->WriteDataBuff[5] &= ~(1 << 5); - if (mask & 0x0010) if (iBits & 0x10) MWDComm->WriteDataBuff[5] |= 1 << 4; // nadmiarowy silnik?w trakcyjnych - else MWDComm->WriteDataBuff[5] &= ~(1 << 4); - if (mask & 0x0020) if (iBits & 0x20) MWDComm->WriteDataBuff[4] |= 1 << 0; // styczniki liniowe - else MWDComm->WriteDataBuff[5] &= ~(1 << 0); - if (mask & 0x0040) if (iBits & 0x40) MWDComm->WriteDataBuff[4] |= 1 << 2; // po?lizg - else MWDComm->WriteDataBuff[4] &= ~(1 << 2); - if (mask & 0x0080) if (iBits & 0x80) MWDComm->WriteDataBuff[5] |= 1 << 2; // (nadmiarowy) przetwornicy? ++ - else MWDComm->WriteDataBuff[5] &= ~(1 << 2); - if (mask & 0x0100) if (iBits & 0x100) MWDComm->WriteDataBuff[5] |= 1 << 7; // nadmiarowy spr??arki - else MWDComm->WriteDataBuff[5] &= ~(1 << 7); - if (mask & 0x0200) if (iBits & 0x200) MWDComm->WriteDataBuff[2] |= 1 << 1; // wentylatory i opory - else MWDComm->WriteDataBuff[2] &= ~(1 << 1); - if (mask & 0x0400) if (iBits & 0x400) MWDComm->WriteDataBuff[2] |= 1 << 2; // wysoki rozruch - else MWDComm->WriteDataBuff[2] &= ~(1 << 2); - if (mask & 0x0800) if (iBits & 0x800) MWDComm->WriteDataBuff[4] |= 1 << 0; // ogrzewanie poci?gu - else MWDComm->WriteDataBuff[4] &= ~(1 << 0); - if (mask & 0x1000) if (iBits & 0x1000) MWDComm->bHamowanie = true; // hasler: ci?nienie w hamulcach HASLER rysik 2 - else MWDComm->bHamowanie = false; - if (mask & 0x2000) if (iBits & 0x2000) MWDComm->WriteDataBuff[6] |= 1 << 4; // hasler: pr?d "na" silnikach HASLER rysik 3 - else MWDComm->WriteDataBuff[6] &= ~(1 << 4); - if (mask & 0x4000) if (iBits & 0x4000) MWDComm->WriteDataBuff[6] |= 1 << 7; // brz?czyk SHP/CA - else MWDComm->WriteDataBuff[6] &= ~(1 << 7); - //if(mask & 0x8000) if(iBits & 0x8000) MWDComm->WriteDataBuff[1] |= 1<<7; (puste) - //else MWDComm->WriteDataBuff[0] &= ~(1<<7); - } }; bool Console::Pressed(int x) { // na razie tak - czyta się tylko klawiatura - return Global::bActive && (GetKeyState(x) < 0); + if (glfwGetKey(Application.window(), x) == GLFW_TRUE) + return true; + else + return false; }; void Console::ValueSet(int x, double y) { // ustawienie wartości (y) na kanale analogowym (x) - if (iMode == 4) - if (PoKeys55[0]) - { - x = Global::iPoKeysPWM[x]; - if (Global::iCalibrateOutDebugInfo == x) - WriteLog("CalibrateOutDebugInfo: oryginal=" + std::to_string(y), false); - if (Global::fCalibrateOutMax[x] > 0) - { - y = Global::CutValueToRange(0, y, Global::fCalibrateOutMax[x]); - if (Global::iCalibrateOutDebugInfo == x) - WriteLog(" cutted=" + std::to_string(y), false); - y = y / Global::fCalibrateOutMax[x]; // sprowadzenie do <0,1> jeśli podana - // maksymalna wartość - if (Global::iCalibrateOutDebugInfo == x) - WriteLog(" fraction=" + std::to_string(y), false); - } - double temp = (((((Global::fCalibrateOut[x][5] * y) + Global::fCalibrateOut[x][4]) * y + - Global::fCalibrateOut[x][3]) * - y + - Global::fCalibrateOut[x][2]) * - y + - Global::fCalibrateOut[x][1]) * - y + - Global::fCalibrateOut[x][0]; // zakres <0;1> - if (Global::iCalibrateOutDebugInfo == x) - WriteLog(" calibrated=" + std::to_string(temp)); - PoKeys55[0]->PWM(x, temp); + if( iMode != 4 ) { return; } + + if (PoKeys55[0]) + { + x = Global.iPoKeysPWM[x]; + if( Global.iCalibrateOutDebugInfo == x ) { + WriteLog( "CalibrateOutDebugInfo: oryginal=" + std::to_string( y ) ); } - if (Global::bMWDmasterEnable) - { - unsigned int iliczba; - switch (x) - { - case 0: iliczba = (unsigned int)floor((y / (Global::fMWDzg[0] * 10) * Global::fMWDzg[1]) + 0.5); // zbiornik g??wny - MWDComm->WriteDataBuff[12] = (unsigned char)(iliczba >> 8); - MWDComm->WriteDataBuff[11] = (unsigned char)iliczba; - break; - case 1: iliczba = (unsigned int)floor((y / (Global::fMWDpg[0] * 10) * Global::fMWDpg[1]) + 0.5); // przew?d g??wny - MWDComm->WriteDataBuff[10] = (unsigned char)(iliczba >> 8); - MWDComm->WriteDataBuff[9] = (unsigned char)iliczba; - break; - case 2: iliczba = (unsigned int)floor((y / (Global::fMWDph[0] * 10) * Global::fMWDph[1]) + 0.5); // cylinder hamulcowy - MWDComm->WriteDataBuff[8] = (unsigned char)(iliczba >> 8); - MWDComm->WriteDataBuff[7] = (unsigned char)iliczba; - break; - case 3: iliczba = (unsigned int)floor((y / Global::fMWDvolt[0] * Global::fMWDvolt[1]) + 0.5); // woltomierz WN - MWDComm->WriteDataBuff[14] = (unsigned char)(iliczba >> 8); - MWDComm->WriteDataBuff[13] = (unsigned char)iliczba; - break; - case 4: iliczba = (unsigned int)floor((y / Global::fMWDamp[0] * Global::fMWDamp[1]) + 0.5); // amp WN 1 - MWDComm->WriteDataBuff[16] = (unsigned char)(iliczba >> 8); - MWDComm->WriteDataBuff[15] = (unsigned char)iliczba; - break; - case 5: iliczba = (unsigned int)floor((y / Global::fMWDamp[0] * Global::fMWDamp[1]) + 0.5); // amp WN 2 - MWDComm->WriteDataBuff[18] = (unsigned char)(iliczba >> 8); - MWDComm->WriteDataBuff[17] = (unsigned char)iliczba; - break; - case 6: iliczba = (unsigned int)floor((y / Global::fMWDamp[0] * Global::fMWDamp[1]) + 0.5); // amp WN 3 - MWDComm->WriteDataBuff[20] = (unsigned int)(iliczba >> 8); - MWDComm->WriteDataBuff[19] = (unsigned char)iliczba; - break; - case 7: MWDComm->WriteDataBuff[0] = (unsigned char)floor(y); // prędkość - break; - } - } + if (Global.fCalibrateOutMax[x] > 0) + { + y = clamp( y, 0.0, Global.fCalibrateOutMax[x]); + if( Global.iCalibrateOutDebugInfo == x ) { + WriteLog( " cutted=" + std::to_string( y ) ); + } + // sprowadzenie do <0,1> jeśli podana maksymalna wartość + y = y / Global.fCalibrateOutMax[x]; + if( Global.iCalibrateOutDebugInfo == x ) { + WriteLog( " fraction=" + std::to_string( y ) ); + } + } + double temp = ((((( + Global.fCalibrateOut[x][5] * y) + + Global.fCalibrateOut[x][4]) * y + + Global.fCalibrateOut[x][3]) * y + + Global.fCalibrateOut[x][2]) * y + + Global.fCalibrateOut[x][1]) * y + + Global.fCalibrateOut[x][0]; // zakres <0;1> + if( Global.iCalibrateOutDebugInfo == x ) { + WriteLog( " calibrated=" + std::to_string( temp ) ); + } + PoKeys55[0]->PWM(x, temp); + } }; void Console::Update() { // funkcja powinna być wywoływana regularnie, np. raz w każdej ramce ekranowej if (iMode == 4) if (PoKeys55[0]) - if (PoKeys55[0]->Update((Global::iPause & 8) > 0)) + if (PoKeys55[0]->Update((Global.iPause & 8) > 0)) { // wykrycie przestawionych przełączników? - Global::iPause &= ~8; + Global.iPause &= ~8; } else { // błąd komunikacji - zapauzować symulację? - if (!(Global::iPause & 8)) // jeśli jeszcze nie oflagowana - Global::iTextMode = VK_F1; // pokazanie czasu/pauzy - Global::iPause |= 8; // tak??? + if (!(Global.iPause & 8)) // jeśli jeszcze nie oflagowana + Global.iTextMode = GLFW_KEY_F1; // pokazanie czasu/pauzy + Global.iPause |= 8; // tak??? PoKeys55[0]->Connect(); // próba ponownego podłączenia } - if (Global::bMWDmasterEnable) - { - if (MWDComm->GetMWDState()) MWDComm->Run(); - else MWDComm->Close(); - } }; float Console::AnalogGet(int x) @@ -461,28 +318,17 @@ float Console::AnalogCalibrateGet(int x) { // pobranie i kalibracja wartości analogowej, jeśli nie ma PoKeys zwraca NULL if (iMode == 4 && PoKeys55[0]) { - float b = PoKeys55[0]->fAnalog[x]; - return (((((Global::fCalibrateIn[x][5] * b) + Global::fCalibrateIn[x][4]) * b + - Global::fCalibrateIn[x][3]) * - b + - Global::fCalibrateIn[x][2]) * - b + - Global::fCalibrateIn[x][1]) * - b + - Global::fCalibrateIn[x][0]; - } - if (Global::bMWDmasterEnable && Global::bMWDBreakEnable) - { - float b = (float)MWDComm->uiAnalog[x]; - b = (b - Global::fMWDAnalogInCalib[x][0]) / (Global::fMWDAnalogInCalib[x][1] - Global::fMWDAnalogInCalib[x][0]); - switch (x) - { - case 0: return (b * 8 - 2); - break; - case 1: return (b * 10); - break; - default: return 0; - } + float b = PoKeys55[0]->fAnalog[x]; + b = ((((( + Global.fCalibrateIn[x][5] * b) + + Global.fCalibrateIn[x][4]) * b + + Global.fCalibrateIn[x][3]) * b + + Global.fCalibrateIn[x][2]) * b + + Global.fCalibrateIn[x][1]) * b + + Global.fCalibrateIn[x][0]; + if (x == 0) return (b + 2) / 8; + if (x == 1) return b/10; + else return b; } return -1.0; // odcięcie }; @@ -518,6 +364,7 @@ void Console::OnKeyDown(int k) } } }; + void Console::OnKeyUp(int k) { // puszczenie klawisza w zasadzie nie ma znaczenia dla iSwitch, ale zeruje iButton if ((k & 0x20000) == 0) // monostabilne tylko bez [Ctrl] @@ -526,10 +373,12 @@ void Console::OnKeyUp(int k) else iButton[char(k) >> 5] &= ~(1 << (k & 31)); // wyłącz monostabilny podstawowy }; + int Console::KeyDownConvert(int k) { return int(ktTable[k & 0x3FF].iDown); }; + int Console::KeyUpConvert(int k) { return int(ktTable[k & 0x3FF].iUp); diff --git a/Console.h b/Console.h index aedaff1f..fd9f6631 100644 --- a/Console.h +++ b/Console.h @@ -13,7 +13,6 @@ http://mozilla.org/MPL/2.0/. class TConsoleDevice; // urządzenie podłączalne za pomocą DLL class TPoKeys55; class TLPT; -class TMWDComm; // maciek001: dodana obsluga portu COM // klasy konwersji znaków wprowadzanych z klawiatury class TKeyTrans @@ -32,7 +31,6 @@ class Console static int iBits; // podstawowy zestaw lampek static TPoKeys55 *PoKeys55[2]; // może ich być kilka static TLPT *LPT; - static TMWDComm *MWDComm; // maciek001: na potrzeby MWD static void BitsUpdate(int mask); // zmienne dla trybu "jednokabinowego", potrzebne do współpracy z pulpitem (PoKeys) // używając klawiatury, każdy pojazd powinien mieć własny stan przełączników diff --git a/Console/LPT.cpp b/Console/LPT.cpp index 2c22fa7c..3f6b2752 100644 --- a/Console/LPT.cpp +++ b/Console/LPT.cpp @@ -45,7 +45,7 @@ bool TLPT::Connect(int port) case 0xBD00: OutPort(address + 0x006, 0); // 0xBC06? czysta improwizacja } - return bool(OutPort); + return OutPort != 0; }; void TLPT::Out(int x) diff --git a/Console/MWD.cpp b/Console/MWD.cpp deleted file mode 100644 index 5f546ce3..00000000 --- a/Console/MWD.cpp +++ /dev/null @@ -1,775 +0,0 @@ -/* -This Source Code Form is subject to the -terms of the Mozilla Public License, v. -2.0. If a copy of the MPL was not -distributed with this file, You can -obtain one at -http://mozilla.org/MPL/2.0/. -*/ - -/* - Program obsługi portu COM i innych na potrzeby sterownika MWDevice - (oraz innych wykorzystujących komunikację przez port COM) - dla Symulatora Pojazdów Szynowych MaSzyna - author: Maciej Witek 2016 - Autor nie ponosi odpowiedzialności za niewłaciwe używanie lub działanie programu! -*/ -#include "stdafx.h" -#include "MWD.h" -#include "Globals.h" -#include "Logs.h" -#include "World.h" - -#include - -HANDLE hComm; - -TMWDComm::TMWDComm() // konstruktor -{ - MWDTime = 0; - bSHPstate = false; - bPrzejazdSHP = false; - bKabina1 = true; // pasuje wyciągnąć dane na temat kabiny i ustawiać te dwa parametry! - bKabina2 = false; - bHamowanie = false; - bCzuwak = false; - - bRysik1H = false; - bRysik1L = false; - bRysik2H = false; - bRysik2L = false; - - bocznik = 0; - nastawnik = 0; - kierunek = 0; - bnkMask = 0; - - int i = 6; - - while (i) - { - i--; - lastStateData[i] = 0; - maskData[i] = 0; - maskSwitch[i] = 0; - bitSwitch[i] = 0; - } - - i = 0; - while (i 0) - return 1; - else - return 0; -} - -bool TMWDComm::ReadData() // odbieranie danych + odczyta danych analogowych i zapis do zmiennych -{ - DWORD bytes_read; - ReadFile(hComm, &ReadDataBuff[0], BYTETOREAD, &bytes_read, NULL); - - if (Global::bMWDBreakEnable) - { - uiAnalog[0] = (ReadDataBuff[9] << 8) + ReadDataBuff[8]; - uiAnalog[1] = (ReadDataBuff[11] << 8) + ReadDataBuff[10]; - uiAnalog[2] = (ReadDataBuff[13] << 8) + ReadDataBuff[12]; - uiAnalog[3] = (ReadDataBuff[15] << 8) + ReadDataBuff[14]; - if (Global::bMWDdebugEnable && (Global::iMWDDebugMode & 1)) - { - WriteLog("Main Break = " + to_string(uiAnalog[0])); - WriteLog("Locomotiv Break = " + to_string(uiAnalog[1])); - } - if (Global::bMWDdebugEnable && (Global::iMWDDebugMode & 2)) - { - WriteLog("Analog input 1 = " + to_string(uiAnalog[2])); - WriteLog("Analog imput 2 = " + to_string(uiAnalog[3])); - } - } - if (Global::bMWDInputEnable) CheckData(); - return TRUE; -} - -bool TMWDComm::SendData() // wysyłanie danych -{ - DWORD bytes_write; - DWORD fdwEvtMask; - - WriteFile(hComm, &WriteDataBuff[0], BYTETOWRITE, &bytes_write, NULL); - - return TRUE; -} - -bool TMWDComm::Run() // wywoływanie obsługi MWD + generacja większego opóźnienia -{ - if (GetMWDState()) - { - MWDTime++; - if (!(MWDTime % Global::iMWDdivider)) - { - MWDTime = 0; - SendData(); - ReadData(); - return 1; - } - } - else - { - WriteLog("Port COM: connection ERROR!"); - Close(); - // może spróbować się połączyć znowu? - return 0; - } - return 1; -} - -void TMWDComm::CheckData() // sprawdzanie wejść cyfrowych i odpowiednie sterowanie maszyną -{ - int i = 0; - while (i < 6) - { - maskData[i] = ReadDataBuff[i] ^ lastStateData[i]; - lastStateData[i] = ReadDataBuff[i]; - i++; - } - /* - Rozpiska portów! - Port0: 0 NC odblok. przek. sprężarki i wentyl. oporów - 1 M wyłącznik wył. szybkiego - 2 Shift+M impuls załączający wył. szybki - 3 N odblok. przekaźników nadmiarowych - i różnicowego obwodu głównego - 4 NC rezerwa - 5 Ctrl+N odblok. przek. nadmiarowych - przetwornicy, ogrzewania pociągu i różnicowych obw. pomocniczych - 6 L wył. styczników liniowych - 7 SPACE kasowanie czuwaka - - Port1: 0 NC - 1 (Shift) X przetwornica - 2 (Shift) C sprężarka - 3 S piasecznice - 4 (Shift) H ogrzewanie składu - 5 przel. hamowania Shift+B - pspbpwy Ctrl+B pospieszny B towarowy - 6 przel. hamowania - 7 (Shift) F rozruch w/n - - Port2: 0 (Shift) P pantograf przedni - 1 (Shift) O pantograf tylni - 2 ENTER przyhamowanie przy poślizgu - 3 () przyciemnienie świateł - 4 () przyciemnienie świateł - 5 NUM6 odluźniacz - 6 a syrena lok W - 7 A syrena lok N - - Port3: 0 Shift+J bateria - 1 - 2 - 3 - 4 - 5 - 6 - 7 - */ - - /* po przełączeniu bistabilnego najpierw wciskamy klawisz i przy następnym - wejściu w pętlę MWD puszczamy bo inaczej nie działa - */ - - // wciskanie przycisków klawiatury - /*PORT0*/ - if (maskData[0] & 0x02) if (lastStateData[0] & 0x02) KeyBoard('M', 1); // wyłączenie wyłącznika szybkiego - else KeyBoard('M', 0); // monostabilny - if (maskData[0] & 0x04) if (lastStateData[0] & 0x04) { // impuls załączający wyłącznik szybki - KeyBoard(0x10, 1); // monostabilny - KeyBoard('M', 1); - } - else { - KeyBoard('M', 0); - KeyBoard(0x10, 0); - } - if (maskData[0] & 0x08) if (lastStateData[0] & 0x08) KeyBoard('N', 1); // odblok nadmiarowego silników trakcyjnych - else KeyBoard('N', 0); // monostabilny - if (maskData[0] & 0x20) if (lastStateData[0] & 0x20) { // odblok nadmiarowego przetwornicy, ogrzewania poc. - KeyBoard(0x11, 1); // różnicowego obwodów pomocniczych - KeyBoard('N', 1); // monostabilny - } - else { - KeyBoard('N', 0); - KeyBoard(0x11, 0); - } - if (maskData[0] & 0x40) if (lastStateData[0] & 0x40) KeyBoard('L', 1); // wył. styczników liniowych - else KeyBoard('L', 0); // monostabilny - if (maskData[0] & 0x80) if (lastStateData[0] & 0x80) KeyBoard(0x20, 1); // kasowanie czuwaka/SHP - else KeyBoard(0x20, 0); // kasowanie czuwaka/SHP - - /*PORT1*/ - - // puszczanie przycisku bistabilnego klawiatury - if (maskSwitch[1] & 0x02) { - if (bitSwitch[1] & 0x02) { - KeyBoard('X', 0); - KeyBoard(0x10, 0); - } - else KeyBoard('X', 0); - maskSwitch[1] &= ~0x02; - } - if (maskSwitch[1] & 0x04) { - if (bitSwitch[1] & 0x04) { - KeyBoard('C', 0); - KeyBoard(0x10, 0); - } - else KeyBoard('C', 0); - maskSwitch[1] &= ~0x04; - } - if (maskSwitch[1] & 0x10) { - if (bitSwitch[1] & 0x10) { - KeyBoard('H', 0); - KeyBoard(0x10, 0); - } - else KeyBoard('H', 0); - maskSwitch[1] &= ~0x10; - } - if (maskSwitch[1] & 0x20 || maskSwitch[1] & 0x40) { - if (maskSwitch[1] & 0x20) KeyBoard(0x10, 0); - if (maskSwitch[1] & 0x40) KeyBoard(0x11, 0); - KeyBoard('B', 0); - maskSwitch[1] &= ~0x60; - } - if (maskSwitch[1] & 0x80) { - if (bitSwitch[1] & 0x80) { - KeyBoard('F', 0); - KeyBoard(0x10, 0); - } - else KeyBoard('F', 0); - maskSwitch[1] &= ~0x80; - } - - - if (maskData[1] & 0x02) if (lastStateData[1] & 0x02) { // przetwornica - KeyBoard(0x10, 1); // bistabilny - KeyBoard('X', 1); - maskSwitch[1] |= 0x02; - bitSwitch[1] |= 0x02; - } - else { - maskSwitch[1] |= 0x02; - bitSwitch[1] &= ~0x02; - KeyBoard('X', 1); - } - if (maskData[1] & 0x04) if (lastStateData[1] & 0x04) { // sprężarka - KeyBoard(0x10, 1); // bistabilny - KeyBoard('C', 1); - maskSwitch[1] |= 0x04; - bitSwitch[1] |= 0x04; - } - else { - maskSwitch[1] |= 0x04; - bitSwitch[1] &= ~0x04; - KeyBoard('C', 1); - } - if (maskData[1] & 0x08) if (lastStateData[1] & 0x08) KeyBoard('S', 1); // piasecznica - else KeyBoard('S', 0); // monostabilny - if (maskData[1] & 0x10) if (lastStateData[1] & 0x10) { // ogrzewanie składu - KeyBoard(0x11, 1); // bistabilny - KeyBoard('H', 1); - maskSwitch[1] |= 0x10; - bitSwitch[1] |= 0x10; - } - else { - maskSwitch[1] |= 0x10; - bitSwitch[1] &= ~0x10; - KeyBoard('H', 1); - } - if (maskData[1] & 0x20 || maskData[1] & 0x40) { // przełącznik hamowania - if (lastStateData[1] & 0x20) { // Shift+B - KeyBoard(0x10, 1); - maskSwitch[1] |= 0x20; - } - else if (lastStateData[1] & 0x40) { // Ctrl+B - KeyBoard(0x11, 1); - maskSwitch[1] |= 0x40; - } - KeyBoard('B', 1); - } - - if (maskData[1] & 0x80) if (lastStateData[1] & 0x80) { // rozruch wysoki/niski - KeyBoard(0x10, 1); // bistabilny - KeyBoard('F', 1); - maskSwitch[1] |= 0x80; - bitSwitch[1] |= 0x80; - } - else { - maskSwitch[1] |= 0x80; - bitSwitch[1] &= ~0x80; - KeyBoard('F', 1); - } - - - //PORT2 - if (maskSwitch[2] & 0x01) { - if (bitSwitch[2] & 0x01) { - KeyBoard('P', 0); - KeyBoard(0x10, 0); - } - else KeyBoard('P', 0); - maskSwitch[2] &= ~0x01; - } - if (maskSwitch[2] & 0x02) { - if (bitSwitch[2] & 0x02) { - KeyBoard('O', 0); - KeyBoard(0x10, 0); - } - else KeyBoard('O', 0); - maskSwitch[2] &= ~0x02; - } - - - if (maskData[2] & 0x01) if (lastStateData[2] & 0x01) { // pantograf przedni - KeyBoard(0x10, 1); // bistabilny - KeyBoard('P', 1); - maskSwitch[2] |= 0x01; - bitSwitch[2] |= 0x01; - } - else { - maskSwitch[2] |= 0x01; - bitSwitch[2] &= ~0x01; - KeyBoard('P', 1); - } - if (maskData[2] & 0x02) if (lastStateData[2] & 0x02) { // pantograf tylni - KeyBoard(0x10, 1); // bistabilny - KeyBoard('O', 1); - maskSwitch[2] |= 0x02; - bitSwitch[2] |= 0x02; - } - else { - maskSwitch[2] |= 0x02; - bitSwitch[2] &= ~0x02; - KeyBoard('O', 1); - } - if (maskData[2] & 0x04) if (lastStateData[2] & 0x04) { // przyhamowanie przy poślizgu - KeyBoard(0x10, 1); // monostabilny - KeyBoard(0x0D, 1); - } - else { - - KeyBoard(0x0D, 0); - KeyBoard(0x10, 0); - } - /*if(maskData[2] & 0x08) if (lastStateData[2] & 0x08){ // przyciemnienie świateł - KeyBoard(' ',0); // bistabilny - KeyBoard(0x10,1); - KeyBoard(' ',1); - }else{ - KeyBoard(' ',0); - KeyBoard(0x10,0); - KeyBoard(' ',1); - } - if(maskData[2] & 0x10) if (lastStateData[2] & 0x10) { // przyciemnienie świateł - KeyBoard(' ',0); // bistabilny - KeyBoard(0x11,1); - KeyBoard(' ',1); - }else{ - KeyBoard(' ',0); - KeyBoard(0x11,0); - KeyBoard(' ',1); - }*/ - if (maskData[2] & 0x20) if (lastStateData[2] & 0x20) KeyBoard(0x66, 1); // odluźniacz - else KeyBoard(0x66, 0); // monostabilny - if (maskData[2] & 0x40) if (lastStateData[2] & 0x40) { // syrena wysoka - KeyBoard(0x10, 1); // monostabilny - KeyBoard('A', 1); - } - else { - KeyBoard('A', 0); - KeyBoard(0x10, 0); - } - if (maskData[2] & 0x80) if (lastStateData[2] & 0x80) KeyBoard('A', 1); // syrena niska - else KeyBoard('A', 0); // monostabilny - - - //PORT3 - - if (maskSwitch[3] & 0x01) { - if (bitSwitch[3] & 0x01) { - KeyBoard('J', 0); - KeyBoard(0x10, 0); - } - else KeyBoard('J', 0); - maskSwitch[3] &= ~0x01; - } - - if (maskData[3] & 0x01) if (lastStateData[3] & 0x01) { // bateria - KeyBoard(0x10, 1); // bistabilny - KeyBoard('J', 1); - maskSwitch[3] |= 0x01; - bitSwitch[3] |= 0x01; - } - else { - maskSwitch[3] |= 0x01; - bitSwitch[3] &= ~0x01; - KeyBoard('J', 1); - } - - /* - if(maskData[3] & 0x04 && lastStateData[1] & 0x04) { KeyBoard(0x10,1); - KeyBoard('C',1); // - KeyBoard('C',0); - KeyBoard(0x10,0); - }else{ KeyBoard('C',1); // - KeyBoard('C',0); - } - if(maskData[3] & 0x08 && lastStateData[1] & 0x08) KeyBoard('S',1); // - else KeyBoard('S',0); - - - if(maskData[3] & 0x10 && lastStateData[1] & 0x10) { - KeyBoard(0x11,1); - KeyBoard('H',1); - }else{ KeyBoard('H',0); - KeyBoard(0x11,0); - } - if(maskData[3] & 0x20 && lastStateData[1] & 0x20) { - KeyBoard(0x11,1); - KeyBoard(' ',1); - }else{ KeyBoard(' ',0); - KeyBoard(0x11,0); - } - if(maskData[3] & 0x40 && lastStateData[1] & 0x40) { - KeyBoard(0x10,1); - KeyBoard(' ',1); - }else{ KeyBoard(' ',0); - KeyBoard(0x10,0); - } - if(maskData[3] & 0x80 && lastStateData[1] & 0x80) { - KeyBoard(0x10,1); - KeyBoard('F',1); - }else{ KeyBoard('F',0); - KeyBoard(0x10,0); - } - - /*PORT4*/ /* - if(maskData[4] & 0x02 && lastStateData[1] & 0x02) { - KeyBoard(0x10,1); - KeyBoard('X',1); // - KeyBoard('X',0); - KeyBoard(0x10,0); - }else{ KeyBoard('X',1); // - KeyBoard('X',0); - } - if(maskData[4] & 0x04 && lastStateData[1] & 0x04) { - KeyBoard(0x10,1); - KeyBoard('C',1); // - KeyBoard('C',0); - KeyBoard(0x10,0); - }else{ KeyBoard('C',1); // - KeyBoard('C',0); - } - if(maskData[4] & 0x08 && lastStateData[1] & 0x08) KeyBoard('S',1); // - else KeyBoard('S',0); - - - if(maskData[4] & 0x10 && lastStateData[1] & 0x10) { - KeyBoard(0x11,1); - KeyBoard('H',1); - }else{ KeyBoard('H',0); - KeyBoard(0x11,0); - } - if(maskData[4] & 0x20 && lastStateData[1] & 0x20) { - KeyBoard(0x11,1); - KeyBoard(' ',1); - }else{ KeyBoard(' ',0); - KeyBoard(0x11,0); - } - if(maskData[4] & 0x40 && lastStateData[1] & 0x40) { - KeyBoard(0x10,1); - KeyBoard(' ',1); - }else{ KeyBoard(' ',0); - KeyBoard(0x10,0); - } - if(maskData[4] & 0x80 && lastStateData[1] & 0x80) { - KeyBoard(0x10,1); - KeyBoard('F',1); - }else{ KeyBoard('F',0); - KeyBoard(0x10,0); - } - - /*PORT5*/ /* - if(maskData[5] & 0x02 && lastStateData[1] & 0x02) { - KeyBoard(0x10,1); - KeyBoard('X',1); // - KeyBoard('X',0); - KeyBoard(0x10,0); - }else{ - KeyBoard('X',1); // - KeyBoard('X',0); - } - if(maskData[5] & 0x04 && lastStateData[1] & 0x04) { - KeyBoard(0x10,1); - KeyBoard('C',1); // - KeyBoard('C',0); - KeyBoard(0x10,0); - }else{ - KeyBoard('C',1); // - KeyBoard('C',0); - } - if(maskData[5] & 0x08 && lastStateData[1] & 0x08) KeyBoard('S',1); // - else - KeyBoard('S',0); - - - if(maskData[5] & 0x10 && lastStateData[1] & 0x10) { - KeyBoard(0x11,1); - KeyBoard('H',1); - }else{ - KeyBoard('H',0); - KeyBoard(0x11,0); - } - if(maskData[5] & 0x20 && lastStateData[1] & 0x20) { - KeyBoard(0x11,1); - KeyBoard(' ',1); - }else{ - KeyBoard(' ',0); - KeyBoard(0x11,0); - } - if(maskData[5] & 0x40 && lastStateData[1] & 0x40) { - KeyBoard(0x10,1); - KeyBoard(' ',1); - }else{ - KeyBoard(' ',0); - KeyBoard(0x10,0); - } - if(maskData[5] & 0x80 && lastStateData[1] & 0x80) { - KeyBoard(0x10,1); - KeyBoard('F',1); - }else{ - KeyBoard('F',0); - KeyBoard(0x10,0); - }//*/ - - /* NASTAWNIK, BOCZNIK i KIERUNEK */ - - if (bnkMask & 1) - { // puszczanie klawiszy - KeyBoard(0x6B, 0); - bnkMask &= ~1; - } - if (bnkMask & 2) - { - KeyBoard(0x6D, 0); - bnkMask &= ~2; - } - if (bnkMask & 4) - { - KeyBoard(0x6F, 0); - bnkMask &= ~4; - } - if (bnkMask & 8) - { - KeyBoard(0x6A, 0); - bnkMask &= ~8; - } - - if (nastawnik < ReadDataBuff[6]) - { - bnkMask |= 1; - nastawnik++; - KeyBoard(0x6B, 1); // wciśnij + i dodaj 1 do nastawnika - } - if (nastawnik > ReadDataBuff[6]) - { - bnkMask |= 2; - nastawnik--; - KeyBoard(0x6D, 1); // wciśnij - i odejmij 1 do nastawnika - } - if (bocznik < ReadDataBuff[7]) - { - bnkMask |= 4; - bocznik++; - KeyBoard(0x6F, 1); // wciśnij / i dodaj 1 do bocznika - } - if (bocznik > ReadDataBuff[7]) - { - bnkMask |= 8; - bocznik--; - KeyBoard(0x6A, 1); // wciśnij * i odejmij 1 do bocznika - } - - /* Obsługa HASLERA */ - if (ReadDataBuff[0] & 0x80) - bCzuwak = true; - - if (bKabina1) - { // logika rysika 1 - bRysik1H = true; - bRysik1L = false; - if (bPrzejazdSHP) - bRysik1H = false; - } - else if (bKabina2) - { - bRysik1L = true; - bRysik1H = false; - if (bPrzejazdSHP) - bRysik1L = false; - } - else - { - bRysik1H = false; - bRysik1L = false; - } - - if (bHamowanie) - { // logika rysika 2 - bRysik2H = false; - bRysik2L = true; - } - else - { - if (bCzuwak) - bRysik2H = true; - else - bRysik2H = false; - bRysik2L = false; - } - bCzuwak = false; - if (bRysik1H) - WriteDataBuff[6] |= 1 << 0; - else - WriteDataBuff[6] &= ~(1 << 0); - if (bRysik1L) - WriteDataBuff[6] |= 1 << 1; - else - WriteDataBuff[6] &= ~(1 << 1); - if (bRysik2H) - WriteDataBuff[6] |= 1 << 2; - else - WriteDataBuff[6] &= ~(1 << 2); - if (bRysik2L) - WriteDataBuff[6] |= 1 << 3; - else - WriteDataBuff[6] &= ~(1 << 3); -} - -void TMWDComm::KeyBoard(int key, bool s) // emulacja klawiatury -{ - INPUT ip; - // Set up a generic keyboard event. - ip.type = INPUT_KEYBOARD; - ip.ki.wScan = 0; // hardware scan code for key - ip.ki.time = 0; - ip.ki.dwExtraInfo = 0; - - ip.ki.wVk = key; // virtual-key code for the "a" key - - if (s) - { // Press the "A" key - ip.ki.dwFlags = 0; // 0 for key press - SendInput(1, &ip, sizeof(INPUT)); - } - else - { - ip.ki.dwFlags = KEYEVENTF_KEYUP; // KEYEVENTF_KEYUP for key release - SendInput(1, &ip, sizeof(INPUT)); - } - - // return 1; -} diff --git a/Console/PoKeys55.cpp b/Console/PoKeys55.cpp index d642b3fb..abe24616 100644 --- a/Console/PoKeys55.cpp +++ b/Console/PoKeys55.cpp @@ -10,7 +10,8 @@ http://mozilla.org/MPL/2.0/. #include "stdafx.h" #include "PoKeys55.h" #include -#include "mczapkie/mctools.h" +#include "utilities.h" + //--------------------------------------------------------------------------- // HIDscaner: http://forum.simflight.com/topic/68257-latest-lua-package-for-fsuipc-and-wideclient/ //#define MY_DEVICE_ID "Vid_04d8&Pid_003F" @@ -70,7 +71,6 @@ bool TPoKeys55::Connect() PBYTE PropertyValueBuffer; bool MatchFound; DWORD ErrorStatus; - HDEVINFO hDevInfo; std::string DeviceIDFromRegistry; std::string DeviceIDToFind = "Vid_1dc3&Pid_1001&Rev_1000&MI_01"; // First populate a list of plugged in devices (by specifying "DIGCF_PRESENT"), which are of the @@ -157,7 +157,7 @@ bool TPoKeys55::Connect() // get the structure (after we have allocated enough memory for the structure.) DetailedInterfaceDataStructure->cbSize = sizeof(SP_DEVICE_INTERFACE_DETAIL_DATA); // First call populates "StructureSize" with the correct value - SetupDiGetDeviceInterfaceDetail(DeviceInfoTable, InterfaceDataStructure, NULL, NULL, + SetupDiGetDeviceInterfaceDetail(DeviceInfoTable, InterfaceDataStructure, NULL, 0, &StructureSize, NULL); DetailedInterfaceDataStructure = (PSP_DEVICE_INTERFACE_DETAIL_DATA)(malloc(StructureSize)); // Allocate enough memory diff --git a/DirectX/DSOUND.LIB b/DirectX/DSOUND.LIB deleted file mode 100644 index 6bae0a24..00000000 Binary files a/DirectX/DSOUND.LIB and /dev/null differ diff --git a/Dokumentacja zmiennych Python.docx b/Dokumentacja zmiennych Python.docx deleted file mode 100644 index f421014b..00000000 Binary files a/Dokumentacja zmiennych Python.docx and /dev/null differ diff --git a/Driver.cpp b/Driver.cpp index 57ec94a6..3de429cd 100644 --- a/Driver.cpp +++ b/Driver.cpp @@ -18,20 +18,86 @@ http://mozilla.org/MPL/2.0/. #include #include "Globals.h" #include "Logs.h" +#include "train.h" #include "mtable.h" #include "DynObj.h" #include "Event.h" -#include "Ground.h" #include "MemCell.h" -#include "World.h" -#include "McZapkie/mctools.h" -#include "McZapkie/MOVER.h" +#include "simulation.h" +#include "simulationtime.h" +#include "track.h" +#include "station.h" +#include "keyboardinput.h" +#include "utilities.h" #define LOGVELOCITY 0 #define LOGORDERS 1 #define LOGSTOPS 1 #define LOGBACKSCAN 0 #define LOGPRESS 0 + +// finds point of specified track nearest to specified event. returns: distance to that point from the specified end of the track +// TODO: move this to file with all generic routines, too easy to forget it's here and it may come useful +double +ProjectEventOnTrack( basic_event const *Event, TTrack const *Track, double const Direction ) { + + auto const segment = Track->CurrentSegment(); + auto const nearestpoint = segment->find_nearest_point( Event->input_location() ); + return ( + Direction > 0 ? + nearestpoint * segment->GetLength() : // measure from point1 + ( 1.0 - nearestpoint ) * segment->GetLength() ); // measure from point2 +}; + +double GetDistanceToEvent(TTrack const *track, basic_event const *event, double scan_dir, double start_dist, int iter = 0, bool back = false) +{ + if( track == nullptr ) { return start_dist; } + + auto const segment = track->CurrentSegment(); + auto const pos_event = event->input_location(); + double len1, len2; + double sd = scan_dir; + double seg_len = scan_dir > 0 ? 0.0 : 1.0; + double const dzielnik = 1.0 / segment->GetLength();// rozdzielczosc mniej wiecej 1m + int krok = 0; // krok obliczeniowy do sprawdzania czy odwracamy + len2 = (pos_event - segment->FastGetPoint(seg_len)).LengthSquared(); + do + { + len1 = len2; + seg_len += scan_dir > 0 ? dzielnik : -dzielnik; + len2 = (pos_event - segment->FastGetPoint(seg_len)).LengthSquared(); + ++krok; + } while ((len1 > len2) && (seg_len >= dzielnik && (seg_len <= (1.0 - dzielnik)))); + //trzeba sprawdzić czy seg_len nie osiągnął skrajnych wartości, bo wtedy + // trzeba sprawdzić tor obok + if (1 == krok) + sd = -sd; // jeśli tylko jeden krok tzn, że event przy poprzednim sprawdzaym torze + if (((1 == krok) || (seg_len <= dzielnik) || (seg_len > (1.0 - dzielnik))) && (iter < 3)) + { // przejście na inny tor + track = track->Connected(int(sd), sd); + start_dist += (1 == krok) ? 0 : back ? -segment->GetLength() : segment->GetLength(); + if( ( track != nullptr ) + && ( track->eType == tt_Cross ) ) { + // NOTE: tracing through crossroads currently poses risk of tracing through wrong segment + // as it's possible to be performerd before setting a route through the crossroads + // as a stop-gap measure we don't trace through crossroads which should be reasonable in most cases + // TODO: establish route before the scan, or a way for the function to know which route to pick + return start_dist; + } + else { + return GetDistanceToEvent( track, event, sd, start_dist, ++iter, 1 == krok ? true : false ); + } + } + else + { // obliczenie mojego toru + seg_len -= scan_dir > 0 ? dzielnik : -dzielnik; //trzeba wrócić do pozycji len1 + seg_len = scan_dir < 0 ? 1 - seg_len : seg_len; + seg_len = back ? 1 - seg_len : seg_len; // odwracamy jeśli idzie do tyłu + start_dist -= back ? segment->GetLength() : 0; + return start_dist + (segment->GetLength() * seg_len); + } +}; + /* Moduł obsługujący sterowanie pojazdami (składami pociągów, samochodami). @@ -70,6 +136,8 @@ Tutaj łączymy teorię z praktyką - tu nic nie działa i nikt nie wie dlaczego // 17. otwieranie/zamykanie drzwi // 18. Ra: odczepianie z zahamowaniem i podczepianie // 19. dla Humandriver: tasma szybkosciomierza - zapis do pliku! +// 20. wybór pozycji zaworu maszynisty w oparciu o zadane opoznienie hamowania + // do zrobienia: // 1. kierownik pociagu @@ -82,12 +150,12 @@ Tutaj łączymy teorię z praktyką - tu nic nie działa i nikt nie wie dlaczego // stałe const double EasyReactionTime = 0.5; //[s] przebłyski świadomości dla zwykłej jazdy const double HardReactionTime = 0.2; -const double EasyAcceleration = 0.5; //[m/ss] -const double HardAcceleration = 0.9; +const double EasyAcceleration = 0.85; //[m/ss] +const double HardAcceleration = 9.81; const double PrepareTime = 2.0; //[s] przebłyski świadomości przy odpalaniu bool WriteLogFlag = false; -string StopReasonTable[] = { +std::string StopReasonTable[] = { // przyczyny zatrzymania ruchu AI "", // stopNone, //nie ma powodu - powinien jechać "Off", // stopSleep, //nie został odpalony, to nie pojedzie @@ -108,29 +176,39 @@ string StopReasonTable[] = { //--------------------------------------------------------------------------- //--------------------------------------------------------------------------- +TSpeedPos::TSpeedPos(TTrack *track, double dist, int flag) +{ + Set(track, dist, flag); +}; + +TSpeedPos::TSpeedPos(basic_event *event, double dist, TOrders order) +{ + Set(event, dist, order); +}; + void TSpeedPos::Clear() { iFlags = 0; // brak flag to brak reakcji fVelNext = -1.0; // prędkość bez ograniczeń fSectionVelocityDist = 0.0; //brak długości fDist = 0.0; - vPos = vector3(0, 0, 0); + vPos = Math3D::vector3(0, 0, 0); trTrack = NULL; // brak wskaźnika }; void TSpeedPos::CommandCheck() { // sprawdzenie typu komendy w evencie i określenie prędkości - TCommandType command = evEvent->Command(); - double value1 = evEvent->ValueGet(1); - double value2 = evEvent->ValueGet(2); + TCommandType command = evEvent->input_command(); + double value1 = evEvent->input_value(1); + double value2 = evEvent->input_value(2); switch (command) { - case cm_ShuntVelocity: + case TCommandType::cm_ShuntVelocity: // prędkość manewrową zapisać, najwyżej AI zignoruje przy analizie tabelki fVelNext = value1; // powinno być value2, bo druga określa "za"? iFlags |= spShuntSemaphor; break; - case cm_SetVelocity: + case TCommandType::cm_SetVelocity: // w semaforze typu "m" jest ShuntVelocity dla Ms2 i SetVelocity dla S1 // SetVelocity * 0 -> można jechać, ale stanąć przed // SetVelocity 0 20 -> stanąć przed, potem można jechać 20 (SBL) @@ -146,31 +224,38 @@ void TSpeedPos::CommandCheck() iFlags |= spStopOnSBL; // flaga, że ma zatrzymać; na pewno nie zezwoli na manewry } break; - case cm_SectionVelocity: + case TCommandType::cm_SectionVelocity: // odcinek z ograniczeniem prędkości fVelNext = value1; fSectionVelocityDist = value2; iFlags |= spSectionVel; break; - case cm_RoadVelocity: + case TCommandType::cm_RoadVelocity: // prędkość drogowa (od tej pory będzie jako domyślna najwyższa) fVelNext = value1; iFlags |= spRoadVel; break; - case cm_PassengerStopPoint: + case TCommandType::cm_PassengerStopPoint: // nie ma dostępu do rozkładu // przystanek, najwyżej AI zignoruje przy analizie tabelki -// if ((iFlags & spPassengerStopPoint) == 0) - fVelNext = 0.0; // TrainParams->IsStop()?0.0:-1.0; //na razie tak + fVelNext = 0.0; iFlags |= spPassengerStopPoint; // niestety nie da się w tym miejscu współpracować z rozkładem +/* + // NOTE: not used for now as it might be unnecessary + // special case, potentially override any set speed limits if requested + // NOTE: we test it here because for the time being it's only used for passenger stops + if( TestFlag( iFlags, spDontApplySpeedLimit ) ) { + fVelNext = -1; + } +*/ break; - case cm_SetProximityVelocity: + case TCommandType::cm_SetProximityVelocity: // musi zostać gdyż inaczej nie działają manewry fVelNext = -1; iFlags |= spProximityVelocity; // fSectionVelocityDist = value2; break; - case cm_OutsideStation: + case TCommandType::cm_OutsideStation: // w trybie manewrowym: skanować od niej wstecz i stanąć po wyjechaniu za sygnalizator i // zmienić kierunek // w trybie pociągowym: można przyspieszyć do wskazanej prędkości (po zjechaniu z rozjazdów) @@ -179,153 +264,86 @@ void TSpeedPos::CommandCheck() break; default: // inna komenda w evencie skanowanym powoduje zatrzymanie i wysłanie tej komendy - iFlags &= ~(spShuntSemaphor | spPassengerStopPoint | - spStopOnSBL); // nie manewrowa, nie przystanek, nie zatrzymać na SBL - fVelNext = 0.0; // jak nieznana komenda w komórce sygnałowej, to zatrzymujemy + // nie manewrowa, nie przystanek, nie zatrzymać na SBL + iFlags &= ~(spShuntSemaphor | spPassengerStopPoint | spStopOnSBL); + // jak nieznana komenda w komórce sygnałowej, to zatrzymujemy + fVelNext = 0.0; } }; -bool TSpeedPos::Update(vector3 *p, vector3 *dir, double &len) -{ // przeliczenie odległości od punktu (*p), w kierunku (*dir), zaczynając od pojazdu - // dla kolejnych pozycji podawane są współrzędne poprzedniego obiektu w (*p) - vector3 v = vPos - *p; // wektor od poprzedniego obiektu (albo pojazdu) do punktu zmiany - fDist = - v.Length(); // długość wektora to odległość pomiędzy czołem a sygnałem albo początkiem toru - // v.SafeNormalize(); //normalizacja w celu określenia znaku (nie potrzebna?) - if (len == 0.0) - { // jeżeli liczymy względem pojazdu - double iska = dir ? dir->x * v.x + dir->z * v.z : - fDist; // iloczyn skalarny to rzut na chwilową prostą ruchu - if (iska < 0.0) // iloczyn skalarny jest ujemny, gdy punkt jest z tyłu - { // jeśli coś jest z tyłu, to dokładna odległość nie ma już większego znaczenia - fDist = -fDist; // potrzebne do badania wyjechania składem poza ograniczenie - if (iFlags & spElapsed) // 32 ustawione, gdy obiekt już został minięty - { // jeśli minięty (musi być minięty również przez końcówkę składu) - } - else - { - iFlags ^= spElapsed; // 32-minięty - będziemy liczyć odległość względem przeciwnego końca - // toru (nadal może być z przodu i ograniczać) - if ((iFlags & 0x43) == 3) // tylko jeśli (istotny) tor, bo eventy są punktowe - if (trTrack) // może być NULL, jeśli koniec toru (????) - vPos = - (iFlags & spReverse) ? - trTrack->CurrentSegment()->FastGetPoint_0() : - trTrack->CurrentSegment()->FastGetPoint_1(); // drugi koniec istotny - } - } - else if (fDist < 50.0) // przy dużym kącie łuku iloczyn skalarny bardziej zaniży odległość - // niż cięciwa - fDist = iska; // ale przy małych odległościach rzut na chwilową prostą ruchu da - // dokładniejsze wartości +bool TSpeedPos::Update() +{ + if( fDist < 0.0 ) { + // trzeba zazanaczyć, że minięty + iFlags |= spElapsed; } - if (fDist > 0.0) // nie może być 0.0, a przypadkiem mogło by się trafić i było by źle - if ((iFlags & spElapsed) == 0) // 32 ustawione, gdy obiekt już został minięty - { // jeśli obiekt nie został minięty, można od niego zliczać narastająco (inaczej może być - // problem z wektorem kierunku) - len = fDist = len + fDist; // zliczanie dlugości narastająco - *p = vPos; // nowy punkt odniesienia - *dir = Normalize(v); // nowy wektor kierunku od poprzedniego obiektu do aktualnego - } - if (iFlags & spTrack) // jeśli tor - { - if (trTrack) // może być NULL, jeśli koniec toru (???) - { - fVelNext = trTrack->VelocityGet(); // aktualizacja prędkości (może być zmieniana - // eventem) - int i; - if ((i = iFlags & 0xF0000000) != 0) - { // jeśli skrzyżowanie, ograniczyć prędkość przy skręcaniu - if (abs(i) > 0x10000000) //±1 to jazda na wprost, ±2 nieby też, ale z przecięciem - // głównej drogi - chyba że jest równorzędne... - fVelNext = 30.0; // uzależnić prędkość od promienia; albo niech będzie - // ograniczona w skrzyżowaniu (velocity z ujemną wartością) - if ((iFlags & spElapsed) == 0) // jeśli nie wjechał -#ifdef EU07_USE_OLD_TTRACK_DYNAMICS_ARRAY - if (trTrack->iNumDynamics > 0) // a skrzyżowanie zawiera pojazd - { - if (Global::iWriteLogEnabled & 8) - WriteLog("Tor " + trTrack->NameGet() + " zajety przed pojazdem. Num=" + std::to_string(trTrack->iNumDynamics) + "Dist= " + std::to_string(fDist)); - fVelNext = - 0.0; // to zabronić wjazdu (chyba że ten z przodu też jedzie prosto) - } -#else - if( false == trTrack->Dynamics.empty() ) { - if( Global::iWriteLogEnabled & 8 ) { - WriteLog( "Tor " + trTrack->NameGet() + " zajety przed pojazdem. Num=" + std::to_string( trTrack->Dynamics.size() ) + "Dist= " + std::to_string( fDist ) ); - fVelNext = 0.0; // to zabronić wjazdu (chyba że ten z przodu też jedzie prosto) + if (iFlags & spTrack) { + // road/track + if (trTrack) { + // może być NULL, jeśli koniec toru (???) + fVelNext = trTrack->VelocityGet(); // aktualizacja prędkości (może być zmieniana eventem) + + if( trTrack->iCategoryFlag & 1 ) { + // railways + if( iFlags & spSwitch ) { + // jeśli odcinek zmienny + if( ( ( trTrack->GetSwitchState() & 1 ) != 0 ) != + ( ( iFlags & spSwitchStatus ) != 0 ) ) { + // czy stan się zmienił? + // Ra: zakładam, że są tylko 2 możliwe stany + iFlags ^= spSwitchStatus; + if( ( iFlags & spElapsed ) == 0 ) { + // jeszcze trzeba skanowanie wykonać od tego toru + // problem jest chyba, jeśli zwrotnica się przełoży zaraz po zjechaniu z niej + // na Mydelniczce potrafi skanować na wprost mimo pojechania na bok + return true; } } -#endif + } } - if (iFlags & spSwitch) // jeśli odcinek zmienny - { - if (bool(trTrack->GetSwitchState() & 1) != - bool(iFlags & spSwitchStatus)) // czy stan się zmienił? - { // Ra: zakładam, że są tylko 2 możliwe stany - iFlags ^= spSwitchStatus; - // fVelNext=trTrack->VelocityGet(); //nowa prędkość - if ((iFlags & spElapsed) == 0) - return true; // jeszcze trzeba skanowanie wykonać od tego toru - // problem jest chyba, jeśli zwrotnica się przełoży zaraz po zjechaniu z niej - // na Mydelniczce potrafi skanować na wprost mimo pojechania na bok - } - // poniższe nie dotyczy trybu łączenia? -#ifdef EU07_USE_OLD_TTRACK_DYNAMICS_ARRAY - if ((iFlags & spElapsed) ? false : - trTrack->iNumDynamics > - 0) // jeśli jeszcze nie wjechano na tor, a coś na nim jest - { - if (Global::iWriteLogEnabled & 8) - WriteLog("Rozjazd " + trTrack->NameGet() + " zajety przed pojazdem. Num=" + std::to_string(trTrack->iNumDynamics) + "Dist= "+std::to_string(fDist)); - //fDist -= 30.0; - fVelNext = 0.0; // to niech stanie w zwiększonej odległości - // else if (fVelNext==0.0) //jeśli została wyzerowana - // fVelNext=trTrack->VelocityGet(); //odczyt prędkości - } -#else - if( ( ( iFlags & spElapsed ) == 0 ) - && ( false == trTrack->Dynamics.empty() ) ) { - // jeśli jeszcze nie wjechano na tor, a coś na nim jest - if( Global::iWriteLogEnabled & 8 ) { - WriteLog( "Rozjazd " + trTrack->NameGet() + " zajety przed pojazdem. Num=" + std::to_string( trTrack->Dynamics.size() ) + "Dist= " + std::to_string( fDist ) ); + else { + // roads and others + if( iFlags & 0xF0000000 ) { + // jeśli skrzyżowanie, ograniczyć prędkość przy skręcaniu + if( ( iFlags & 0xF0000000 ) > 0x10000000 ) { + // ±1 to jazda na wprost, ±2 nieby też, ale z przecięciem głównej drogi - chyba że jest równorzędne... + // TODO: uzależnić prędkość od promienia; + // albo niech będzie ograniczona w skrzyżowaniu (velocity z ujemną wartością) + fVelNext = 30.0; } - fVelNext = 0.0; // to niech stanie w zwiększonej odległości } -#endif } } } - else if (iFlags & spEvent) // jeśli event - { // odczyt komórki pamięci najlepiej by było zrobić jako notyfikację, czyli zmiana komórki - // wywoła jakąś podaną funkcję - CommandCheck(); // sprawdzenie typu komendy w evencie i określenie prędkości + else if (iFlags & spEvent) { + // jeśli event + if( ( ( iFlags & spElapsed ) == 0 ) + || ( fVelNext == 0.0 ) ) { + // ignore already passed signals, but keep an eye on overrun stops + // odczyt komórki pamięci najlepiej by było zrobić jako notyfikację, + // czyli zmiana komórki wywoła jakąś podaną funkcję + CommandCheck(); // sprawdzenie typu komendy w evencie i określenie prędkości + } } return false; }; -std::string TSpeedPos::GetName() +std::string TSpeedPos::GetName() const { if (iFlags & spTrack) // jeśli tor - return trTrack->NameGet(); + return trTrack->name(); else if( iFlags & spEvent ) // jeśli event - return evEvent->asName; + return evEvent->m_name; else return ""; } -std::string TSpeedPos::TableText() +std::string TSpeedPos::TableText() const { // pozycja tabelki pr?dko?ci if (iFlags & spEnabled) { // o ile pozycja istotna - return "Flags:" + to_hex_str(iFlags, 6) + ", Dist:" + to_string(fDist, 1, 6) + - ", Vel:" + (fVelNext == -1.0 ? " * " : to_string(static_cast(fVelNext), 0, 3)) + ", Name:" + GetName(); - //if (iFlags & spTrack) // jeśli tor - // return "Flags=#" + IntToHex(iFlags, 8) + ", Dist=" + FloatToStrF(fDist, ffFixed, 7, 1) + - // ", Vel=" + AnsiString(fVelNext) + ", Track=" + trTrack->NameGet(); - //else if (iFlags & spEvent) // jeśli event - // return "Flags=#" + IntToHex(iFlags, 8) + ", Dist=" + FloatToStrF(fDist, ffFixed, 7, 1) + - // ", Vel=" + AnsiString(fVelNext) + ", Event=" + evEvent->asName; + return to_hex_str(iFlags, 8) + " " + to_string(fDist, 1, 6) + + " " + (fVelNext == -1.0 ? " -" : to_string(static_cast(fVelNext), 0, 3)) + " " + GetName(); } return "Empty"; } @@ -347,12 +365,12 @@ bool TSpeedPos::IsProperSemaphor(TOrders order) return false; // true gdy zatrzymanie, wtedy nie ma po co skanować dalej } -bool TSpeedPos::Set(TEvent *event, double dist, TOrders order) +bool TSpeedPos::Set(basic_event *event, double dist, TOrders order) { // zapamiętanie zdarzenia fDist = dist; iFlags = spEnabled | spEvent; // event+istotny evEvent = event; - vPos = event->PositionGet(); // współrzędne eventu albo komórki pamięci (zrzutować na tor?) + vPos = event->input_location(); // współrzędne eventu albo komórki pamięci (zrzutować na tor?) CommandCheck(); // sprawdzenie typu komendy w evencie i określenie prędkości // zależnie od trybu sprawdzenie czy jest tutaj gdzieś semafor lub tarcza manewrowa // jeśli wskazuje stop wtedy wystawiamy true jako koniec sprawdzania @@ -378,7 +396,7 @@ void TSpeedPos::Set(TTrack *track, double dist, int flag) trTrack = track; // TODO: (t) może być NULL i nie odczytamy końca poprzedniego :/ if (trTrack) { - iFlags = flag | (trTrack->eType == tt_Normal ? 2 : 10); // zapamiętanie kierunku wraz z typem + iFlags = flag | (trTrack->eType == tt_Normal ? spTrack : (spTrack | spSwitch) ); // zapamiętanie kierunku wraz z typem if (iFlags & spSwitch) if (trTrack->GetSwitchState() & 1) iFlags |= spSwitchStatus; @@ -389,423 +407,424 @@ void TSpeedPos::Set(TTrack *track, double dist, int flag) fVelNext = (trTrack->iCategoryFlag & 1) ? 0.0 : 20.0; // jeśli koniec, to pociąg stój, a samochód zwolnij - vPos = (bool(iFlags & spReverse) != bool(iFlags & spEnd)) ? - trTrack->CurrentSegment()->FastGetPoint_1() : - trTrack->CurrentSegment()->FastGetPoint_0(); + vPos = + ( iFlags & spReverse ) ? + trTrack->CurrentSegment()->FastGetPoint_1() : + trTrack->CurrentSegment()->FastGetPoint_0(); } }; -//--------------------------------------------------------------------------- -//--------------------------------------------------------------------------- //--------------------------------------------------------------------------- void TController::TableClear() { // wyczyszczenie tablicy - iFirst = iLast = 0; + sSpeedTable.clear(); + iLast = -1; iTableDirection = 0; // nieznany - for (int i = 0; i < iSpeedTableSize; ++i) // czyszczenie tabeli prędkości - sSpeedTable[i].Clear(); - tLast = NULL; - fLastVel = -1; - eSignSkip = NULL; // nic nie pomijamy + tLast = nullptr; + fLastVel = -1.0; + SemNextIndex = -1; + SemNextStopIndex = -1; + eSignSkip = nullptr; // nic nie pomijamy }; -TEvent * TController::CheckTrackEvent(double fDirection, TTrack *Track) +std::vector TController::CheckTrackEvent( TTrack *Track, double const fDirection ) const { // sprawdzanie eventów na podanym torze do podstawowego skanowania - TEvent *e = (fDirection > 0) ? Track->evEvent2 : Track->evEvent1; - if (!e) - return NULL; - if (e->bEnabled) - return NULL; - // jednak wszystkie W4 do tabelki, bo jej czyszczenie na przystanku wprowadza zamieszanie - return e; + std::vector events; + auto const &eventsequence { ( fDirection > 0 ? Track->m_events2 : Track->m_events1 ) }; + for( auto const &event : eventsequence ) { + if( ( event.second != nullptr ) + && ( event.second->m_passive ) ) { + events.emplace_back( event.second ); + } + } + return events; } bool TController::TableAddNew() { // zwiększenie użytej tabelki o jeden rekord - iLast = (iLast + 1) % iSpeedTableSize; - // TODO: jeszcze sprawdzić, czy się na iFirst nie nałoży - // TODO: wstawić tu wywołanie odtykacza - teraz jest to w TableTraceRoute() - // TODO: jeśli ostatnia pozycja zajęta, ustawiać dodatkowe flagi - teraz jest to w - // TableTraceRoute() - // TODO: przydało by się też posortować tabelkę wg odległości (ale nie w tym miejscu) + sSpeedTable.emplace_back(); // add a new slot + iLast = sSpeedTable.size() - 1; return true; // false gdy się nałoży }; -bool TController::TableNotFound(TEvent *e) +bool TController::TableNotFound(basic_event const *Event) const { // sprawdzenie, czy nie został już dodany do tabelki (np. podwójne W4 robi problemy) - int j = (iLast + 1) % iSpeedTableSize; // j, aby sprawdzić też ostatnią pozycję - for (int i = iFirst; i != j; i = (i + 1) % iSpeedTableSize) - if ((sSpeedTable[i].iFlags & (spEnabled | spEvent)) == (spEnabled | - spEvent)) // o ile używana pozycja - if (sSpeedTable[i].evEvent == e) - { - if (Global::iWriteLogEnabled & 8) - WriteLog("TableNotFound: Event already in SpeedTable: " + sSpeedTable[i].evEvent->asName); - return false; // już jest, drugi raz dodawać nie ma po co - } - return true; // nie ma, czyli można dodać + auto lookup = + std::find_if( + sSpeedTable.begin(), + sSpeedTable.end(), + [Event]( TSpeedPos const &speedpoint ){ + return ( ( true == TestFlag( speedpoint.iFlags, spEnabled | spEvent ) ) + && ( speedpoint.evEvent == Event ) ); } ); + + if( ( Global.iWriteLogEnabled & 8 ) + && ( lookup != sSpeedTable.end() ) ) { + WriteLog( "Speed table for " + OwnerName() + " already contains event " + lookup->evEvent->m_name ); + } + + return lookup == sSpeedTable.end(); }; void TController::TableTraceRoute(double fDistance, TDynamicObject *pVehicle) { // skanowanie trajektorii na odległość (fDistance) od (pVehicle) w kierunku przodu składu i // uzupełnianie tabelki // WriteLog("Starting TableTraceRoute"); - if (!iDirection) // kierunek pojazdu z napędem - { // jeśli kierunek jazdy nie jest okreslony - iTableDirection = 0; // czekamy na ustawienie kierunku - } - TTrack *pTrack; // zaczynamy od ostatniego analizowanego toru - // double fDistChVel=-1; //odległość do toru ze zmianą prędkości - double fTrackLength; // długość aktualnego toru (krótsza dla pierwszego) - double fCurrentDistance; // aktualna przeskanowana długość - TEvent *pEvent; - double fLastDir; // kierunek na ostatnim torze - if (iTableDirection != iDirection) - { // jeśli zmiana kierunku, zaczynamy od toru ze wskazanym pojazdem + + TTrack *pTrack{ nullptr }; // zaczynamy od ostatniego analizowanego toru + double fTrackLength{ 0.0 }; // długość aktualnego toru (krótsza dla pierwszego) + double fCurrentDistance{ 0.0 }; // aktualna przeskanowana długość + double fLastDir{ 0.0 }; + + if (iTableDirection != iDirection ) { + // jeśli zmiana kierunku, zaczynamy od toru ze wskazanym pojazdem + iTableDirection = iDirection; // ustalenie w jakim kierunku jest wypełniana tabelka względem pojazdu pTrack = pVehicle->RaTrackGet(); // odcinek, na którym stoi - fLastDir = pVehicle->DirectionGet() * - pVehicle->RaDirectionGet(); // ustalenie kierunku skanowania na torze - fCurrentDistance = 0; // na razie nic nie przeskanowano fTrackLength = pVehicle->RaTranslationGet(); // pozycja na tym torze (odległość od Point1) - if (fLastDir > 0) // jeśli w kierunku Point2 toru - fTrackLength = - pTrack->Length() - fTrackLength; // przeskanowana zostanie odległość do Point2 - fLastVel = pTrack->VelocityGet(); // aktualna prędkość - iTableDirection = - iDirection; // ustalenie w jakim kierunku jest wypełniana tabelka względem pojazdu - iFirst = iLast = 0; - tLast = NULL; //żaden nie sprawdzony + fLastDir = pVehicle->DirectionGet() * pVehicle->RaDirectionGet(); // ustalenie kierunku skanowania na torze + if( fLastDir < 0.0 ) { + // jeśli w kierunku Point2 toru + fTrackLength = pTrack->Length() - fTrackLength; // przeskanowana zostanie odległość do Point2 + } + // account for the fact tracing begins from active axle, not the actual front of the vehicle + // NOTE: position of the couplers is modified by track offset, but the axles ain't, so we need to account for this as well + fTrackLength -= ( + pVehicle->AxlePositionGet() + - pVehicle->RearPosition() + + pVehicle->VectorLeft() * pVehicle->MoverParameters->OffsetTrackH ) + .Length(); + // aktualna odległość ma być ujemna gdyż jesteśmy na końcu składu + fCurrentDistance = -fLength - fTrackLength; + // aktualna prędkość // changed to -1 to recognize speed limit, if any + fLastVel = -1.0; + sSpeedTable.clear(); + iLast = -1; + tLast = nullptr; //żaden nie sprawdzony + SemNextIndex = -1; + SemNextStopIndex = -1; + if( VelSignalLast == 0.0 ) { + // don't allow potential red light overrun keep us from reversing + VelSignalLast = -1.0; + } + fTrackLength = pTrack->Length(); //skasowanie zmian w zmiennej żeby poprawnie liczyło w dalszych krokach + MoveDistanceReset(); // AI startuje 1s po zaczęciu jazdy i mógł już coś przejechać } - else - { // kontynuacja skanowania od ostatnio sprawdzonego toru (w ostatniej pozycji zawsze jest tor) - // WriteLog("TableTraceRoute: check last track"); - if (sSpeedTable[iLast].iFlags & spEndOfTable) // zatkanie - { // jeśli zapełniła się tabelka - if ((iLast + 1) % iSpeedTableSize == iFirst) // jeśli nadal jest zapełniona - { - TablePurger(); // nic się nie da zrobić + else { + if( iTableDirection == 0 ) { return; } + // NOTE: provisory fix for BUG: sempahor indices no longer matching table size + // TODO: find and really fix the reason it happens + if( ( SemNextIndex != -1 ) + && ( SemNextIndex >= sSpeedTable.size() ) ) { + SemNextIndex = -1; + } + if( ( SemNextStopIndex != -1 ) + && ( SemNextStopIndex >= sSpeedTable.size() ) ) { + SemNextStopIndex = -1; + } + // kontynuacja skanowania od ostatnio sprawdzonego toru (w ostatniej pozycji zawsze jest tor) + if( ( SemNextStopIndex != -1 ) + && ( sSpeedTable[SemNextStopIndex].fVelNext == 0.0 ) ) { + // znaleziono semafor lub tarczę lub tor z prędkością zero, trzeba sprawdzić czy to nadał semafor + // jeśli jest następny semafor to sprawdzamy czy to on nadał zero + if( ( OrderCurrentGet() & Obey_train ) + && ( sSpeedTable[SemNextStopIndex].iFlags & spSemaphor ) ) { return; } - if ((iLast + 2) % iSpeedTableSize == iFirst) // musi być jeszcze miejsce wolne na - // ewentualny event, bo tor jeszcze nie - // sprawdzony - { - TablePurger(); - return; // już lepiej, ale jeszcze nie tym razem + else { + if( ( OrderCurrentGet() < 0x40 ) + && ( sSpeedTable[SemNextStopIndex].iFlags & ( spSemaphor | spShuntSemaphor | spOutsideStation ) ) ) { + return; + } } - sSpeedTable[iLast].iFlags &= 0xBE; // kontynuować próby doskanowania } - // znaleziono semafor lub tarczę lub tor z prędkością zero - // trzeba sprawdzić czy to nadał semafor - // WriteLog("TableTraceRoute: "+OwnerName()+" check semaphor... "); - // if (sSemNext) - // WriteLog(sSemNext->TableText()); - if (sSemNextStop && - sSemNextStop->fVelNext == - 0.0) // jeśli jest następny semafor to sprawdzamy czy to on nadał zero - { - // WriteLog("TableTraceRoute: "+sSemNext->TableText()); - if ((OrderCurrentGet() & Obey_train) && (sSemNextStop->iFlags & spSemaphor)) - return; - else if ((OrderCurrentGet() < 0x40) && - (sSemNextStop->iFlags & (spSemaphor | spShuntSemaphor | spOutsideStation))) - return; - } - pTrack = sSpeedTable[iLast].trTrack; // ostatnio sprawdzony tor - if (!pTrack) - return; // koniec toru, to nie ma co sprawdzać (nie ma prawa tak być) - fLastDir = (sSpeedTable[iLast].iFlags & spReverse) ? -1.0 : 1.0; // flaga ustawiona, gdy Point2 toru jest bli�ej - fCurrentDistance = sSpeedTable[iLast].fDist; // aktualna odleg�o�� do jego Point1 - fTrackLength = (sSpeedTable[iLast].iFlags & (spElapsed | spEnd)) ? 0.0 : pTrack->Length(); // nie dolicza� d�ugo�ci gdy: - // 32-minięty początek, - // 64-jazda do końca toru + + auto const &lastspeedpoint = sSpeedTable[ iLast ]; + pTrack = lastspeedpoint.trTrack; + assert( pTrack != nullptr ); + // flaga ustawiona, gdy Point2 toru jest blizej + fLastDir = ( ( ( lastspeedpoint.iFlags & spReverse ) != 0 ) ? -1.0 : 1.0 ); + fCurrentDistance = lastspeedpoint.fDist; // aktualna odleglosc do jego Point1 + fTrackLength = pTrack->Length(); } - if (fCurrentDistance < fDistance) - { // jeśli w ogóle jest po co analizować - // WriteLog("TableTraceRoute: checking next tracks"); - --iLast; // jak coś się znajdzie, zostanie wpisane w tę pozycję, którą właśnie odczytano - while (fCurrentDistance < fDistance) - { - if (pTrack != tLast) // ostatni zapisany w tabelce nie był jeszcze sprawdzony - { // jeśli tor nie był jeszcze sprawdzany - // if (pTrack) - // WriteLog("TableTraceRoute: " + OwnerName() + " checking track " + - // pTrack->NameGet()); - if ((pEvent = CheckTrackEvent(fLastDir, pTrack)) != - NULL) // jeśli jest semafor na tym torze - { // trzeba sprawdzić tabelkę, bo dodawanie drugi raz tego samego przystanku nie - // jest korzystne + + if( iTableDirection == 0 ) { + // don't bother + return; + } + + while (fCurrentDistance < fDistance) + { + if (pTrack != tLast) // ostatni zapisany w tabelce nie był jeszcze sprawdzony + { // jeśli tor nie był jeszcze sprawdzany + if( Global.iWriteLogEnabled & 8 ) { + WriteLog( "Speed table for " + OwnerName() + " tracing through track " + pTrack->name() ); + } + + auto const events { CheckTrackEvent( pTrack, fLastDir ) }; + for( auto *pEvent : events ) { + if( pEvent != nullptr ) // jeśli jest semafor na tym torze + { // trzeba sprawdzić tabelkę, bo dodawanie drugi raz tego samego przystanku nie jest korzystne if (TableNotFound(pEvent)) // jeśli nie ma - if (TableAddNew()) - { - if (Global::iWriteLogEnabled & 8) - WriteLog("TableTraceRoute: new event found " + pEvent->asName + " by " + OwnerName()); - if (sSpeedTable[iLast].Set( pEvent, fCurrentDistance, OrderCurrentGet())) // dodanie odczytu sygnału - { - fDistance = fCurrentDistance; // jeśli sygnał stop, to nie ma - // potrzeby dalej skanować - sSemNextStop = &sSpeedTable[iLast]; - if (!sSemNext) - sSemNext = &sSpeedTable[iLast]; - if (Global::iWriteLogEnabled & 8) - WriteLog("Signal stop. Next Semaphor ", false); - if (sSemNextStop) - { - if (Global::iWriteLogEnabled & 8) - WriteLog(sSemNextStop->GetName()); - } - else - { - if (Global::iWriteLogEnabled & 8) - WriteLog("none"); - } + { + TableAddNew(); // zawsze jest true + + if (Global.iWriteLogEnabled & 8) { + WriteLog("Speed table for " + OwnerName() + " found new event, " + pEvent->m_name); + } + auto &newspeedpoint = sSpeedTable[iLast]; +/* + if( newspeedpoint.Set( + pEvent, + fCurrentDistance + ProjectEventOnTrack( pEvent, pTrack, fLastDir ), + OrderCurrentGet() ) ) { +*/ + if( newspeedpoint.Set( + pEvent, + GetDistanceToEvent( pTrack, pEvent, fLastDir, fCurrentDistance ), + OrderCurrentGet() ) ) { + + fDistance = newspeedpoint.fDist; // jeśli sygnał stop, to nie ma potrzeby dalej skanować + SemNextStopIndex = iLast; + if (SemNextIndex == -1) { + SemNextIndex = iLast; } - else - { - if (sSpeedTable[iLast].IsProperSemaphor(OrderCurrentGet()) && - sSemNext == NULL) - sSemNext = - &sSpeedTable[iLast]; // sprawdzamy czy pierwszy na drodze - if (Global::iWriteLogEnabled & 8) - WriteLog("Signal forward. Next Semaphor ", false); - if (sSemNext) - { - if (Global::iWriteLogEnabled & 8) - WriteLog(sSemNext->GetName()); - } - else - { - if (Global::iWriteLogEnabled & 8) - WriteLog("none"); - } + if (Global.iWriteLogEnabled & 8) { + WriteLog("(stop signal from " + + (SemNextStopIndex != -1 ? sSpeedTable[SemNextStopIndex].GetName() : "unknown semaphor") + + ")"); } } - } // event dodajemy najpierw, żeby móc sprawdzić, czy tor został dodany po - // odczytaniu prędkości następnego - if ((pTrack->VelocityGet() == 0.0) // zatrzymanie - || (pTrack->iAction) // jeśli tor ma własności istotne dla skanowania - || (pTrack->VelocityGet() != fLastVel)) // następuje zmiana prędkości - { // odcinek dodajemy do tabelki, gdy jest istotny dla ruchu - if (TableAddNew()) - { // teraz dodatkowo zapamiętanie wybranego segmentu dla skrzyżowania - sSpeedTable[iLast].Set( - pTrack, fCurrentDistance, - fLastDir < 0 ? - 5 : - 1); // dodanie odcinka do tabelki z flagą kierunku wejścia - if (pTrack->eType == tt_Cross) // na skrzyżowaniach trzeba wybrać segment, - // po którym pojedzie pojazd - { // dopiero tutaj jest ustalany kierunek segmentu na skrzyżowaniu - sSpeedTable[iLast].iFlags |= - (pTrack->CrossSegment((fLastDir < 0) ? tLast->iPrevDirection : - tLast->iNextDirection, - iRouteWanted) & - 15) - << 28; // ostatnie 4 bity pola flag - sSpeedTable[iLast].iFlags &= - ~spReverse; // usunięcie flagi kierunku, bo może być błędna - if (sSpeedTable[iLast].iFlags < 0) - sSpeedTable[iLast].iFlags |= - spReverse; // ustawienie flagi kierunku na podstawie wybranego segmentu - if (int(fLastDir) * sSpeedTable[iLast].iFlags < 0) - fLastDir = -fLastDir; - if (AIControllFlag) // dla AI na razie losujemy kierunek na kolejnym - // skrzyżowaniu - iRouteWanted = 1 + Random(3); + else { + if( ( true == newspeedpoint.IsProperSemaphor( OrderCurrentGet() ) ) + && ( SemNextIndex == -1 ) ) { + SemNextIndex = iLast; // sprawdzamy czy pierwszy na drodze + } + if (Global.iWriteLogEnabled & 8) { + WriteLog("(forward signal for " + + (SemNextIndex != -1 ? sSpeedTable[SemNextIndex].GetName() : "unknown semaphor") + + ")"); + } } } } - else if ((pTrack->fRadius != 0.0) // odległość na łuku lepiej aproksymować cięciwami - || (tLast ? tLast->fRadius != 0.0 : false)) // koniec łuku też jest istotny - { // albo dla liczenia odległości przy pomocy cięciw - te usuwać po przejechaniu - if (TableAddNew()) - sSpeedTable[iLast].Set(pTrack, fCurrentDistance, - fLastDir < 0 ? 0x85 : - 0x81); // dodanie odcinka do tabelki - // 0x85 = spEnabled, spReverse, SpCurve + } // event dodajemy najpierw, żeby móc sprawdzić, czy tor został dodany po odczytaniu prędkości następnego + + if( ( pTrack->VelocityGet() == 0.0 ) // zatrzymanie + || ( pTrack->iAction ) // jeśli tor ma własności istotne dla skanowania + || ( pTrack->VelocityGet() != fLastVel ) ) // następuje zmiana prędkości + { // odcinek dodajemy do tabelki, gdy jest istotny dla ruchu + TableAddNew(); + sSpeedTable[ iLast ].Set( + pTrack, fCurrentDistance, + ( fLastDir < 0 ? + spEnabled | spReverse : + spEnabled ) ); // dodanie odcinka do tabelki z flagą kierunku wejścia + if (pTrack->eType == tt_Cross) { + // na skrzyżowaniach trzeba wybrać segment, po którym pojedzie pojazd + // dopiero tutaj jest ustalany kierunek segmentu na skrzyżowaniu + int routewanted; + if( false == AIControllFlag ) { + routewanted = ( + input::keys[ GLFW_KEY_LEFT ] != GLFW_RELEASE ? 1 : + input::keys[ GLFW_KEY_RIGHT ] != GLFW_RELEASE ? 2 : + 3 ); + } + else { + routewanted = 1 + std::floor( Random( static_cast( pTrack->RouteCount() ) - 0.001 ) ); + } + + sSpeedTable[iLast].iFlags |= + ( ( pTrack->CrossSegment( + (fLastDir < 0 ? + tLast->iPrevDirection : + tLast->iNextDirection), +/* + iRouteWanted ) +*/ + routewanted ) + & 0xf ) << 28 ); // ostatnie 4 bity pola flag + sSpeedTable[iLast].iFlags &= ~spReverse; // usunięcie flagi kierunku, bo może być błędna + if (sSpeedTable[iLast].iFlags < 0) { + sSpeedTable[iLast].iFlags |= spReverse; // ustawienie flagi kierunku na podstawie wybranego segmentu + } + if (int(fLastDir) * sSpeedTable[iLast].iFlags < 0) { + fLastDir = -fLastDir; + } +/* + if (AIControllFlag) { + // dla AI na razie losujemy kierunek na kolejnym skrzyżowaniu + iRouteWanted = 1 + Random(3); + } +*/ } } - fCurrentDistance += - fTrackLength; // doliczenie kolejnego odcinka do przeskanowanej długości - tLast = pTrack; // odhaczenie, że sprawdzony - // Track->ScannedFlag=true; //do pokazywania przeskanowanych torów - fLastVel = pTrack->VelocityGet(); // prędkość na poprzednio sprawdzonym odcinku - pTrack = pTrack->Neightbour( - (pTrack->eType == tt_Cross) ? (sSpeedTable[iLast].iFlags >> 28) : int(fLastDir), - fLastDir); // może być NULL - /* - if (fLastDir>0) - {//jeśli szukanie od Point1 w kierunku Point2 - pTrack=pTrack->CurrentNext(); //może być NULL - if (pTrack) //jeśli dalej brakuje toru, to zostajemy na tym samym, z tą samą - orientacją - if (tLast->iNextDirection) - fLastDir=-fLastDir; //można by zamiętać i zmienić tylko jeśli jest pTrack - } - else //if (fDirection<0) - {//jeśli szukanie od Point2 w kierunku Point1 - pTrack=pTrack->CurrentPrev(); //może być NULL - if (pTrack) //jeśli dalej brakuje toru, to zostajemy na tym samym, z tą samą - orientacją - if (!tLast->iPrevDirection) - fLastDir=-fLastDir; - } - */ - if (pTrack) - { // jeśli kolejny istnieje - if (tLast) - if (pTrack->VelocityGet() < 0 ? tLast->VelocityGet() > 0 : - pTrack->VelocityGet() > tLast->VelocityGet()) - { // jeśli kolejny ma większą prędkość niż poprzedni, to zapamiętać poprzedni - // (do czasu wyjechania) - if ((sSpeedTable[iLast].iFlags & 3) == 3 ? - (sSpeedTable[iLast].trTrack != tLast) : - true) // jeśli nie był dodany do tabelki - if (TableAddNew()) - sSpeedTable[iLast].Set( - tLast, fCurrentDistance, - (fLastDir > 0 ? pTrack->iPrevDirection : - pTrack->iNextDirection) ? - 1 : - 5); // zapisanie toru z ograniczeniem prędkości - } - if (((iLast + 3) % iSpeedTableSize == iFirst) ? - true : - ((iLast + 2) % iSpeedTableSize == iFirst)) // czy tabelka się nie zatka? - { // jest ryzyko nieznalezienia ograniczenia - ograniczyć prędkość do pozwalającej - // na zatrzymanie na końcu przeskanowanej drogi - TablePurger(); // usunąć pilnie zbędne pozycje - if (((iLast + 3) % iSpeedTableSize == iFirst) ? - true : - ((iLast + 2) % iSpeedTableSize == iFirst)) // czy tabelka się nie zatka? - { // jeśli odtykacz nie pomógł (TODO: zwiększyć rozmiar tabelki) - if (TableAddNew()) - sSpeedTable[iLast].Set( - pTrack, fCurrentDistance, - fLastDir < 0 ? - 0x10045 : - 0x10041); // zapisanie toru jako końcowego (ogranicza prędkosć) - // zapisać w logu, że należy poprawić scenerię? - return; // nie skanujemy dalej, bo nie ma miejsca - } - } - fTrackLength = pTrack->Length(); // zwiększenie skanowanej odległości tylko jeśli - // istnieje dalszy tor - } - else - { // definitywny koniec skanowania, chyba że dalej puszczamy samochód po gruncie... - if (TableAddNew()) // kolejny, bo się cofnęliśmy o 1 + else if ( ( pTrack->fRadius != 0.0 ) // odległość na łuku lepiej aproksymować cięciwami + || ( ( tLast != nullptr ) + && ( tLast->fRadius != 0.0 ) )) // koniec łuku też jest istotny + { // albo dla liczenia odległości przy pomocy cięciw - te usuwać po przejechaniu + if (TableAddNew()) { + // dodanie odcinka do tabelki sSpeedTable[iLast].Set( - tLast, fCurrentDistance, - fLastDir < 0 ? 0x45 : 0x41); // zapisanie ostatniego sprawdzonego toru - return; // to ostatnia pozycja, bo NULL nic nie da, a może się podpiąć obrotnica, - // czy jakieś transportery + pTrack, fCurrentDistance, + ( fLastDir < 0 ? + spEnabled | spCurve | spReverse : + spEnabled | spCurve ) ); + } } } - if (TableAddNew()) - sSpeedTable[iLast].Set(pTrack, fCurrentDistance, - fLastDir < 0 ? 4 : 0); // zapisanie ostatniego sprawdzonego toru + + fCurrentDistance += fTrackLength; // doliczenie kolejnego odcinka do przeskanowanej długości + tLast = pTrack; // odhaczenie, że sprawdzony + fLastVel = pTrack->VelocityGet(); // prędkość na poprzednio sprawdzonym odcinku + pTrack = pTrack->Connected( + ( pTrack->eType == tt_Cross ? + (sSpeedTable[iLast].iFlags >> 28) : + static_cast(fLastDir) ), + fLastDir); // może być NULL + + if (pTrack != nullptr ) + { // jeśli kolejny istnieje + if( tLast != nullptr ) { + + if( ( tLast->VelocityGet() > 0 ) + && ( ( tLast->VelocityGet() < pTrack->VelocityGet() ) + || ( pTrack->VelocityGet() < 0 ) ) ) { + + if( ( iLast != -1 ) + && ( sSpeedTable[ iLast ].trTrack == tLast ) ) { + // if the track is already in the table we only need to mark it as relevant + sSpeedTable[ iLast ].iFlags |= spEnabled; + } + else { + // otherwise add it + TableAddNew(); + sSpeedTable[ iLast ].Set( + tLast, + fCurrentDistance - fTrackLength, // by now the current distance points to beginning of next track + ( fLastDir > 0 ? + pTrack->iPrevDirection : + pTrack->iNextDirection ) ? + spEnabled : + spEnabled | spReverse ); + } + } + } + // zwiększenie skanowanej odległości tylko jeśli istnieje dalszy tor + fTrackLength = pTrack->Length(); + } + else + { // definitywny koniec skanowania, chyba że dalej puszczamy samochód po gruncie... + if( ( iLast == -1 ) + || ( ( false == TestFlag( sSpeedTable[iLast].iFlags, spEnabled | spEnd ) ) + && ( sSpeedTable[iLast].trTrack != tLast ) ) ) { + // only if we haven't already marked end of the track and if the new track doesn't duplicate last one + if( TableAddNew() ) { + // zapisanie ostatniego sprawdzonego toru + sSpeedTable[iLast].Set( + tLast, fCurrentDistance - fTrackLength, // by now the current distance points to beginning of next track, + ( fLastDir < 0 ? + spEnabled | spEnd | spReverse : + spEnabled | spEnd )); + } + } + else if( sSpeedTable[ iLast ].trTrack == tLast ) { + // otherwise just mark the last added track as the final one + // TODO: investigate exactly how we can wind up not marking the last existing track as actual end + sSpeedTable[ iLast ].iFlags |= spEnd; + } + // to ostatnia pozycja, bo NULL nic nie da, a może się podpiąć obrotnica, czy jakieś transportery + return; + } + } + if( TableAddNew() ) { + // zapisanie ostatniego sprawdzonego toru + sSpeedTable[ iLast ].Set( + pTrack, fCurrentDistance, + ( fLastDir < 0 ? + spNone | spReverse : + spNone ) ); } }; void TController::TableCheck(double fDistance) { // przeliczenie odległości w tabelce, ewentualnie doskanowanie (bez analizy prędkości itp.) - if (iTableDirection != iDirection) - TableTraceRoute(fDistance, - pVehicles[1]); // jak zmiana kierunku, to skanujemy od końca składu + if( iTableDirection != iDirection ) { + // jak zmiana kierunku, to skanujemy od końca składu + TableTraceRoute( fDistance, pVehicles[ 1 ] ); + TableSort(); + } else if (iTableDirection) { // trzeba sprawdzić, czy coś się zmieniło - vector3 dir = - pVehicles[0]->VectorFront() * pVehicles[0]->DirectionGet(); // wektor kierunku jazdy - vector3 pos = pVehicles[0]->HeadPosition(); // zaczynamy od pozycji pojazdu - // double lastspeed=-1; //prędkość na torze do usunięcia - double len = 0.0; // odległość będziemy zliczać narastająco - for (int i = iFirst; i != iLast; i = (i + 1) % iSpeedTableSize) + auto const distance = MoveDistanceGet(); + for (auto &sp : sSpeedTable) { + // aktualizacja odległości dla wszystkich pozycji tabeli + sp.UpdateDistance(distance); + } + MoveDistanceReset(); // kasowanie odległości po aktualizacji tabelki + for( int i = 0; i < iLast; ++i ) { // aktualizacja rekordów z wyjątkiem ostatniego if (sSpeedTable[i].iFlags & spEnabled) // jeśli pozycja istotna { - if (sSpeedTable[i].Update(&pos, &dir, len)) + if (sSpeedTable[i].Update()) { - if (Global::iWriteLogEnabled & 8) - WriteLog("TableCheck: Switch change. Delete next entries. (" + sSpeedTable[i].trTrack->NameGet() + ")"); - int k = (iLast + 1) % iSpeedTableSize; // skanujemy razem z ostatnią pozycją - for (int j = (i+1) % iSpeedTableSize; j != k; j = (j + 1) % iSpeedTableSize) - { // kasowanie wszystkich rekordów za zmienioną zwrotnicą - if (Global::iWriteLogEnabled & 8) - WriteLog("TableCheck: Delete from table: " + sSpeedTable[j].GetName()); - sSpeedTable[j].iFlags = 0; - if (&sSpeedTable[j] == sSemNext) - sSemNext = NULL; // przy kasowaniu tabelki zrzucamy także semafor - if (&sSpeedTable[j] == sSemNextStop) - sSemNextStop = NULL; // przy kasowaniu tabelki zrzucamy także semafor + if( Global.iWriteLogEnabled & 8 ) { + WriteLog( "Speed table for " + OwnerName() + " detected switch change at " + sSpeedTable[ i ].trTrack->name() + " (generating fresh trace)" ); } - if (Global::iWriteLogEnabled & 8) - { - WriteLog("TableCheck: Delete entries OK."); - WriteLog("TableCheck: New last element: " + sSpeedTable[i].GetName()); + // usuwamy wszystko za tym torem + while (sSpeedTable.back().trTrack != sSpeedTable[i].trTrack) + { // usuwamy wszystko dopóki nie trafimy na tą zwrotnicę + sSpeedTable.pop_back(); + --iLast; } - iLast = i; // pokazujemy gdzie jest ostatni kawałek - break; // nie kontynuujemy pętli, trzeba doskanować ciąg dalszy + tLast = sSpeedTable[ i ].trTrack; + TableTraceRoute( fDistance, pVehicles[ 1 ] ); + TableSort(); + // nie kontynuujemy pętli, trzeba doskanować ciąg dalszy + break; } if (sSpeedTable[i].iFlags & spTrack) // jeśli odcinek { - if (sSpeedTable[i].fDist < -fLength) // a skład wyjechał całą długością poza + if( sSpeedTable[ i ].fDist + sSpeedTable[ i ].trTrack->Length() < -fLength ) // a skład wyjechał całą długością poza { // degradacja pozycji - // WriteLog( "TableCheck: Track is behind. Delete from table: " + sSpeedTable[i].trTrack->NameGet()); sSpeedTable[i].iFlags &= ~spEnabled; // nie liczy się } - else if ((sSpeedTable[i].iFlags & 0xF0000028) == - spElapsed) // jest z tyłu (najechany) i nie jest zwrotnicą ani skrzyżowaniem - if (sSpeedTable[i].fVelNext < 0) // a nie ma ograniczenia prędkości + else if( ( sSpeedTable[ i ].iFlags & 0xF0000028 ) == spElapsed ) { + // jest z tyłu (najechany) i nie jest zwrotnicą ani skrzyżowaniem + if( sSpeedTable[ i ].fVelNext < 0 ) // a nie ma ograniczenia prędkości { - sSpeedTable[i].iFlags = - 0; // to nie ma go po co trzymać (odtykacz usunie ze środka) - // WriteLog("TableCheck: Track without speed. Delete from table: " + sSpeedTable[i].trTrack->NameGet()); + sSpeedTable[ i ].iFlags = 0; // to nie ma go po co trzymać (odtykacz usunie ze środka) } + } } else if (sSpeedTable[i].iFlags & spEvent) // jeśli event { - if (sSpeedTable[i].fDist < (sSpeedTable[i].evEvent->Type == tp_PutValues ? - -fLength : - 0)) // jeśli jest z tyłu + if (sSpeedTable[i].fDist < ( + typeid( *(sSpeedTable[i].evEvent) ) == typeid( putvalues_event ) ? + -fLength : + 0)) // jeśli jest z tyłu if ((mvOccupied->CategoryFlag & 1) ? false : sSpeedTable[i].fDist < -fLength) - { // pociąg staje zawsze, a samochód tylko jeśli nie przejedzie całą - // długością (może być zaskoczony zmianą) + { // pociąg staje zawsze, a samochód tylko jeśli nie przejedzie całą długością (może być zaskoczony zmianą) // WriteLog("TableCheck: Event is behind. Delete from table: " + sSpeedTable[i].evEvent->asName); - sSpeedTable[i].iFlags &= ~1; // degradacja pozycji dla samochodu; - // semafory usuwane tylko przy sprawdzaniu, - // bo wysyłają komendy + sSpeedTable[i].iFlags &= ~spEnabled; // degradacja pozycji dla samochodu; + // semafory usuwane tylko przy sprawdzaniu, bo wysyłają komendy } } - // if (sSpeedTable[i].fDist<-20.0*fLength) //jeśli to coś jest 20 razy dalej niż - // długość składu - //{sSpeedTable[i].iFlags&=~1; //to jest to jakby błąd w scenerii - // //WriteLog("Error: too distant object in scan table"); - //} - // if (sSpeedTable[i].fDist>20.0*fLength) //jeśli to coś jest 20 razy dalej niż - // długość składu - //{sSpeedTable[i].iFlags&=~1; //to jest to jakby błąd w scenerii - // //WriteLog("Error: too distant object in scan table"); - //} - } - if (i == iFirst) // jeśli jest pierwszą pozycją tabeli - { // pozbycie się początkowej pozycji - if ((sSpeedTable[i].iFlags & 1) == - 0) // jeśli pozycja istotna (po Update() może się zmienić) - // if (iFirst!=iLast) //ostatnia musi zostać - to załatwia for() - iFirst = (iFirst + 1) % - iSpeedTableSize; // kolejne sprawdzanie będzie już od następnej pozycji } } - sSpeedTable[iLast].Update(&pos, &dir, len); // aktualizacja ostatniego + sSpeedTable[iLast].Update(); // aktualizacja ostatniego // WriteLog("TableCheck: Upate last track. Dist=" + AnsiString(sSpeedTable[iLast].fDist)); - if (sSpeedTable[iLast].fDist < fDistance) - TableTraceRoute(fDistance, pVehicles[1]); // doskanowanie dalszego odcinka + if( sSpeedTable[ iLast ].fDist < fDistance ) { + TableTraceRoute( fDistance, pVehicles[ 1 ] ); // doskanowanie dalszego odcinka + TableSort(); + } + // garbage collection + TablePurger(); } }; +auto const passengerstopmaxdistance { 400.0 }; // maximum allowed distance between passenger stop point and consist head + TCommandType TController::TableUpdate(double &fVelDes, double &fDist, double &fNext, double &fAcc) { // ustalenie parametrów, zwraca typ komendy, jeśli sygnał podaje prędkość do jazdy // fVelDes - prędkość zadana @@ -816,261 +835,263 @@ TCommandType TController::TableUpdate(double &fVelDes, double &fDist, double &fN double v; // prędkość double d; // droga double d_to_next_sem = 10000.0; //ustaiwamy na pewno dalej niż widzi AI - TCommandType go = cm_Unknown; + bool isatpassengerstop { false }; // true if the consist is within acceptable range of w4 post + TCommandType go = TCommandType::cm_Unknown; eSignNext = NULL; - int i, k = iLast - iFirst + 1; - if (k < 0) - k += iSpeedTableSize; // ilość pozycji do przeanalizowania - iDrivigFlags &= ~(moveTrackEnd | moveSwitchFound | moveSemaphorFound | - moveSpeedLimitFound); // te flagi są ustawiane tutaj, w razie potrzeby - for (i = iFirst; k > 0; --k, i = (i + 1) % iSpeedTableSize) + // te flagi są ustawiane tutaj, w razie potrzeby + iDrivigFlags &= ~(moveTrackEnd | moveSwitchFound | moveSemaphorFound | /*moveSpeedLimitFound*/ moveStopPointFound ); + + for( std::size_t i = 0; i < sSpeedTable.size(); ++i ) { // sprawdzenie rekordów od (iFirst) do (iLast), o ile są istotne if (sSpeedTable[i].iFlags & spEnabled) // badanie istotności { // o ile dana pozycja tabelki jest istotna - if (sSpeedTable[i].iFlags & spPassengerStopPoint) - { // jeśli przystanek, trzeba obsłużyć wg rozkładu + if (sSpeedTable[i].iFlags & spPassengerStopPoint) { + // jeśli przystanek, trzeba obsłużyć wg rozkładu + iDrivigFlags |= moveStopPointFound; + // stop points are irrelevant when not in one of the basic modes + if( ( OrderCurrentGet() & ( Obey_train | Shunt ) ) == 0 ) { continue; } // first 19 chars of the command is expected to be "PassengerStopPoint:" so we skip them - if ( ToLower(sSpeedTable[i].evEvent->CommandGet()).compare( 19, sizeof(asNextStop), ToLower(asNextStop)) != 0 ) + if ( ToLower(sSpeedTable[i].evEvent->input_text()).compare( 19, sizeof(asNextStop), ToLower(asNextStop)) != 0 ) { // jeśli nazwa nie jest zgodna - if (sSpeedTable[i].fDist < -fLength) // jeśli został przejechany - sSpeedTable[i].iFlags = - 0; // to można usunąć (nie mogą być usuwane w skanowaniu) + if (sSpeedTable[i].fDist < 300.0 && sSpeedTable[i].fDist > 0) // tylko jeśli W4 jest blisko, przy dwóch może zaczać szaleć + { + // porównuje do następnej stacji, więc trzeba przewinąć do poprzedniej + // nastepnie ustawić następną na aktualną tak żeby prawidłowo ją obsłużył w następnym kroku + if( true == TrainParams->RewindTimeTable( sSpeedTable[ i ].evEvent->input_text() ) ) { + asNextStop = TrainParams->NextStop(); + iStationStart = TrainParams->StationIndex; + } + } + else if( sSpeedTable[ i ].fDist < -fLength ) { + // jeśli został przejechany + sSpeedTable[ i ].iFlags = 0; // to można usunąć (nie mogą być usuwane w skanowaniu) + } continue; // ignorowanie jakby nie było tej pozycji } - else if (iDrivigFlags & - moveStopPoint) // jeśli pomijanie W4, to nie sprawdza czasu odjazdu + else if (iDrivigFlags & moveStopPoint) // jeśli pomijanie W4, to nie sprawdza czasu odjazdu { // tylko gdy nazwa zatrzymania się zgadza if (!TrainParams->IsStop()) { // jeśli nie ma tu postoju sSpeedTable[i].fVelNext = -1; // maksymalna prędkość w tym miejscu - if (sSpeedTable[i].fDist < - 200.0) // przy 160km/h jedzie 44m/s, to da dokładność rzędu 5 sekund - { // zaliczamy posterunek w pewnej odległości przed (choć W4 nie zasłania -// już semafora) + // przy 160km/h jedzie 44m/s, to da dokładność rzędu 5 sekund + if (sSpeedTable[i].fDist < passengerstopmaxdistance * 0.5 ) { + // zaliczamy posterunek w pewnej odległości przed (choć W4 nie zasłania już semafora) #if LOGSTOPS - WriteLog(pVehicle->asName + " as " + TrainParams->TrainName + ": at " + - std::to_string(GlobalTime->hh) + ":" + std::to_string(GlobalTime->mm) + - " skipped " + asNextStop); // informacja + WriteLog( + pVehicle->asName + " as " + TrainParams->TrainName + + ": at " + std::to_string(simulation::Time.data().wHour) + ":" + std::to_string(simulation::Time.data().wMinute) + + " passed " + asNextStop); // informacja #endif - fLastStopExpDist = mvOccupied->DistCounter + 0.250 + - 0.001 * fLength; // przy jakim dystansie (stanie - // licznika) ma przesunąć na - // następny postój - TrainParams->UpdateMTable( - GlobalTime->hh, GlobalTime->mm, asNextStop); + // przy jakim dystansie (stanie licznika) ma przesunąć na następny postój + fLastStopExpDist = mvOccupied->DistCounter + 0.250 + 0.001 * fLength; + TrainParams->UpdateMTable( simulation::Time, asNextStop ); TrainParams->StationIndexInc(); // przejście do następnej - asNextStop = - TrainParams->NextStop(); // pobranie kolejnego miejsca zatrzymania + asNextStop = TrainParams->NextStop(); // pobranie kolejnego miejsca zatrzymania // TableClear(); //aby od nowa sprawdziło W4 z inną nazwą już - to nie // jest dobry pomysł sSpeedTable[i].iFlags = 0; // nie liczy się już - sSpeedTable[i].fVelNext = -1; // jechać continue; // nie analizować prędkości } } // koniec obsługi przelotu na W4 - else - { // zatrzymanie na W4 - if (!eSignNext) //jeśli nie widzi następnego sygnału - eSignNext = sSpeedTable[i].evEvent; //ustawia dotychczasową - if (mvOccupied->Vel > 0.3) // jeśli jedzie (nie trzeba czekać, aż się - // drgania wytłumią - drzwi zamykane od 1.0) - sSpeedTable[i].fVelNext = 0; // to będzie zatrzymanie - // else if - // ((iDrivigFlags&moveStopCloser)?sSpeedTable[i].fDist<=fMaxProximityDist*(AIControllFlag?1.0:10.0):true) - else if ((iDrivigFlags & moveStopCloser) ? - sSpeedTable[i].fDist + fLength <= - Max0R(sSpeedTable[i].evEvent->ValueGet(2), - fMaxProximityDist + fLength) : - sSpeedTable[i].fDist < d_to_next_sem) - // Ra 2F1I: odległość plus długość pociągu musi być mniejsza od długości - // peronu, chyba że pociąg jest dłuższy, to wtedy minimalna - // jeśli długość peronu ((sSpeedTable[i].evEvent->ValueGet(2)) nie podana, - // przyjąć odległość fMinProximityDist - { // jeśli się zatrzymał przy W4, albo stał w momencie zobaczenia W4 - if (!AIControllFlag) // AI tylko sobie otwiera drzwi - iDrivigFlags &= ~moveStopCloser; // w razie przełączenia na AI ma - // nie podciągać do W4, gdy - // użytkownik zatrzymał za daleko - if ((iDrivigFlags & moveDoorOpened) == 0) - { // drzwi otwierać jednorazowo + else { + // zatrzymanie na W4 + if ( false == sSpeedTable[i].bMoved ) { + // potentially shift the stop point in accordance with its defined parameters + /* + // https://rainsted.com/pl/Wersja/18.2.133#Okr.C4.99gi_dla_W4_i_W32 + Pierwszy parametr ujemny - preferowane zatrzymanie czoła składu (np. przed przejściem). + Pierwszy parametr dodatni - preferowane zatrzymanie środka składu (np. przy wiacie, przejściu podziemnym). + Drugi parametr ujemny - wskazanie zatrzymania dla krótszych składów (W32). + Drugi paramer dodatni - długość peronu (W4). + */ + auto L = 0.0; + auto Par1 = sSpeedTable[i].evEvent->input_value(1); + auto Par2 = sSpeedTable[i].evEvent->input_value(2); + if ((Par2 >= 0) || (fLength < -Par2)) { //użyj tego W4 + if (Par1 < 0) { + L = -Par1; + } + else { + //środek + L = Par1 - fMinProximityDist - fLength * 0.5; + } + L = std::max(0.0, std::min(L, std::abs(Par2) - fMinProximityDist - fLength)); + sSpeedTable[i].UpdateDistance(L); + sSpeedTable[i].bMoved = true; + } + else { + sSpeedTable[i].iFlags = 0; + } + } + isatpassengerstop = ( + ( sSpeedTable[ i ].fDist <= passengerstopmaxdistance ) + // Ra 2F1I: odległość plus długość pociągu musi być mniejsza od długości + // peronu, chyba że pociąg jest dłuższy, to wtedy minimalna. + // jeśli długość peronu ((sSpeedTable[i].evEvent->ValueGet(2)) nie podana, + // przyjąć odległość fMinProximityDist + && ( ( iDrivigFlags & moveStopCloser ) != 0 ? + sSpeedTable[ i ].fDist + fLength <= + std::max( + std::abs( sSpeedTable[ i ].evEvent->input_value( 2 ) ), + 2.0 * fMaxProximityDist + fLength ) : // fmaxproximitydist typically equals ~50 m + sSpeedTable[ i ].fDist < d_to_next_sem ) ); + + if( !eSignNext ) { + //jeśli nie widzi następnego sygnału ustawia dotychczasową + eSignNext = sSpeedTable[ i ].evEvent; + } + if( mvOccupied->Vel > 0.3 ) { + // jeśli jedzie (nie trzeba czekać, aż się drgania wytłumią - drzwi zamykane od 1.0) to będzie zatrzymanie + sSpeedTable[ i ].fVelNext = 0; + } else if( true == isatpassengerstop ) { + // jeśli się zatrzymał przy W4, albo stał w momencie zobaczenia W4 + if( !AIControllFlag ) { + // w razie przełączenia na AI ma nie podciągać do W4, gdy użytkownik zatrzymał za daleko + iDrivigFlags &= ~moveStopCloser; + } + + if( ( iDrivigFlags & moveDoorOpened ) == 0 ) { + // drzwi otwierać jednorazowo iDrivigFlags |= moveDoorOpened; // nie wykonywać drugi raz - if (mvOccupied->DoorOpenCtrl == 1) //(mvOccupied->TrainType==dt_EZT) - { // otwieranie drzwi w EZT - if (AIControllFlag) // tylko AI otwiera drzwi EZT, użytkownik - // musi samodzielnie - if (!mvOccupied->DoorLeftOpened && - !mvOccupied->DoorRightOpened) - { // otwieranie drzwi - int p2 = - int(floor(sSpeedTable[i].evEvent->ValueGet(2))) % - 10; // p7=platform side (1:left, 2:right, 3:both) - int lewe = (iDirection > 0) ? 1 : 2; // jeśli jedzie do - // tyłu, to drzwi - // otwiera - // odwrotnie - int prawe = (iDirection > 0) ? 2 : 1; - if (p2 & lewe) - mvOccupied->DoorLeft(true); - if (p2 & prawe) - mvOccupied->DoorRight(true); - // if (p2&3) //żeby jeszcze poczekał chwilę, zanim - // zamknie - // WaitingSet(10); //10 sekund (wziąć z rozkładu????) - } - } - else - { // otwieranie drzwi w składach wagonowych - docelowo wysyłać - // komendę zezwolenia na otwarcie drzwi - int p7, lewe, - prawe; // p7=platform side (1:left, 2:right, 3:both) - p7 = int(floor(sSpeedTable[i].evEvent->ValueGet(2))) % - 10; // tu będzie jeszcze długość peronu zaokrąglona do 10m - // (20m bezpieczniej, bo nie modyfikuje bitu 1) - TDynamicObject *p = pVehicles[0]; // pojazd na czole składu - while (p) - { // otwieranie drzwi w pojazdach - flaga zezwolenia była by - // lepsza - lewe = (p->DirectionGet() > 0) ? 1 : 2; // jeśli jedzie do - // tyłu, to drzwi - // otwiera odwrotnie - prawe = 3 - lewe; - p->MoverParameters->BatterySwitch(true); // wagony muszą - // mieć baterię - // załączoną do - // otwarcia - // drzwi... - if (p7 & lewe) - p->MoverParameters->DoorLeft(true); - if (p7 & prawe) - p->MoverParameters->DoorRight(true); - p = p->Next(); // pojazd podłączony z tyłu (patrząc od - // czoła) - } - // if (p7&3) //żeby jeszcze poczekał chwilę, zanim zamknie - // WaitingSet(10); //10 sekund (wziąć z rozkładu????) - } - if (fStopTime > - -5) // na końcu rozkładu się ustawia 60s i tu by było skrócenie - WaitingSet(10); // 10 sekund (wziąć z rozkładu????) - czekanie - // niezależne od sposobu obsługi drzwi, bo - // opóźnia również kierownika + Doors( true, static_cast( std::floor( std::abs( sSpeedTable[ i ].evEvent->input_value( 2 ) ) ) ) % 10 ); } - if (TrainParams->UpdateMTable( - GlobalTime->hh, GlobalTime->mm, asNextStop) ) - { // to się wykona tylko raz po zatrzymaniu na W4 - if (TrainParams->CheckTrainLatency() < 0.0) - iDrivigFlags |= moveLate; // odnotowano spóźnienie - else - iDrivigFlags &= ~moveLate; // przyjazd o czasie - if (TrainParams->DirectionChange()) // jeśli "@" w rozkładzie, to - // wykonanie dalszych komend - { // wykonanie kolejnej komendy, nie dotyczy ostatniej stacji - if (iDrivigFlags & movePushPull) // SN61 ma się też nie ruszać, - // chyba że ma wagony - { + + if (TrainParams->UpdateMTable( simulation::Time, asNextStop) ) { + // to się wykona tylko raz po zatrzymaniu na W4 + if( TrainParams->StationIndex < TrainParams->StationCount ) { + // jeśli są dalsze stacje, bez trąbienia przed odjazdem + // also ignore any horn cue that may be potentially set below 1 km/h and before the actual full stop + iDrivigFlags &= ~( moveStartHorn | moveStartHornNow ); + } + + // perform loading/unloading + auto const platformside = static_cast( std::floor( std::abs( sSpeedTable[ i ].evEvent->input_value( 2 ) ) ) ) % 10; + auto const exchangetime = std::max( 5.0, simulation::Station.update_load( pVehicles[ 0 ], *TrainParams, platformside ) ); + WaitingSet( std::max( -fStopTime, exchangetime ) ); // na końcu rozkładu się ustawia 60s i tu by było skrócenie + + if( TrainParams->CheckTrainLatency() < 0.0 ) { + // odnotowano spóźnienie + iDrivigFlags |= moveLate; + } + else { + // przyjazd o czasie + iDrivigFlags &= ~moveLate; + } + + if (TrainParams->DirectionChange()) { + // jeśli "@" w rozkładzie, to wykonanie dalszych komend + // wykonanie kolejnej komendy, nie dotyczy ostatniej stacji + if (iDrivigFlags & movePushPull) { + // SN61 ma się też nie ruszać, chyba że ma wagony iDrivigFlags |= moveStopHere; // EZT ma stać przy peronie - if (OrderNextGet() != Change_direction) - { + if (OrderNextGet() != Change_direction) { OrderPush(Change_direction); // zmiana kierunku - OrderPush(TrainParams->StationIndex < - TrainParams->StationCount ? - Obey_train : - Shunt); // to dalej wg rozkładu + OrderPush( + TrainParams->StationIndex < TrainParams->StationCount ? + Obey_train : + Shunt); // to dalej wg rozkładu } } - else // a dla lokomotyw... - iDrivigFlags &= - ~(moveStopPoint | moveStopHere); // pozwolenie na - // przejechanie za W4 - // przed czasem i nie - // ma stać - JumpToNextOrder(); // przejście do kolejnego rozkazu (zmiana - // kierunku, odczepianie) - iDrivigFlags &= ~moveStopCloser; // ma nie podjeżdżać pod W4 po - // przeciwnej stronie - sSpeedTable[i].iFlags = 0; // ten W4 nie liczy się już zupełnie - // (nie wyśle SetVelocity) - sSpeedTable[i].fVelNext = -1; // jechać - continue; // nie analizować prędkości + else { + // a dla lokomotyw... + // pozwolenie na przejechanie za W4 przed czasem i nie ma stać + iDrivigFlags &= ~( moveStopPoint | moveStopHere ); + } + // przejście do kolejnego rozkazu (zmiana kierunku, odczepianie) + JumpToNextOrder(); + // ma nie podjeżdżać pod W4 po przeciwnej stronie + iDrivigFlags &= ~moveStopCloser; + // ten W4 nie liczy się już zupełnie (nie wyśle SetVelocity) + sSpeedTable[i].iFlags = 0; + // jechać + sSpeedTable[i].fVelNext = -1; + // nie analizować prędkości + continue; } } - if (OrderCurrentGet() == Shunt) - { + + if (OrderCurrentGet() & Shunt) { OrderNext(Obey_train); // uruchomić jazdę pociągową CheckVehicles(); // zmienić światła } - if (TrainParams->StationIndex < TrainParams->StationCount) - { // jeśli są dalsze stacje, czekamy do godziny odjazdu - if (TrainParams->IsTimeToGo(GlobalTime->hh, GlobalTime->mm)) - { // z dalszą akcją czekamy do godziny odjazdu - /* potencjalny problem z ruszaniem z w4 - if (TrainParams->CheckTrainLatency() < 0) - WaitingSet(20); //Jak spóźniony to czeka 20s - */ - // iDrivigFlags|=moveLate1; //oflagować, gdy odjazd ze - // spóźnieniem, będzie jechał forsowniej - fLastStopExpDist = - mvOccupied->DistCounter + 0.050 + - 0.001 * fLength; // przy jakim dystansie (stanie licznika) - // ma przesunąć na następny postój - // Controlled-> //zapisać odległość do przejechania + if (TrainParams->StationIndex < TrainParams->StationCount) { + // jeśli są dalsze stacje, czekamy do godziny odjazdu + if (TrainParams->IsTimeToGo(simulation::Time.data().wHour, simulation::Time.data().wMinute)) { + // z dalszą akcją czekamy do godziny odjazdu + isatpassengerstop = false; + // przy jakim dystansie (stanie licznika) ma przesunąć na następny postój + fLastStopExpDist = mvOccupied->DistCounter + 0.050 + 0.001 * fLength; TrainParams->StationIndexInc(); // przejście do następnej asNextStop = TrainParams->NextStop(); // pobranie kolejnego miejsca zatrzymania -// TableClear(); //aby od nowa sprawdziło W4 z inną nazwą już - to nie jest dobry pomysł #if LOGSTOPS - WriteLog(pVehicle->asName + " as " + TrainParams->TrainName + - ": at " + std::to_string(GlobalTime->hh) + ":" + - std::to_string(GlobalTime->mm) + " next " + - asNextStop); // informacja + WriteLog( + pVehicle->asName + " as " + TrainParams->TrainName + + ": at " + std::to_string(simulation::Time.data().wHour) + ":" + std::to_string(simulation::Time.data().wMinute) + + " next " + asNextStop); // informacja #endif - if (int(floor(sSpeedTable[i].evEvent->ValueGet(1))) & 1) - iDrivigFlags |= moveStopHere; // nie podjeżdżać do semafora, - // jeśli droga nie jest wolna - else - iDrivigFlags &= ~moveStopHere; //po czasie jedź dalej - iDrivigFlags |= moveStopCloser; // do następnego W4 podjechać - // blisko (z dociąganiem) - iDrivigFlags &= ~moveStartHorn; // bez trąbienia przed odjazdem - sSpeedTable[i].iFlags = - 0; // nie liczy się już zupełnie (nie wyśle SetVelocity) + // update brake settings and ai braking tables + // NOTE: this calculation is expected to run after completing loading/unloading + AutoRewident(); // nastawianie hamulca do jazdy pociągowej + + if( static_cast( std::floor( std::abs( sSpeedTable[ i ].evEvent->input_value( 1 ) ) ) ) % 2 ) { + // nie podjeżdżać do semafora, jeśli droga nie jest wolna + iDrivigFlags |= moveStopHere; + } + else { + //po czasie jedź dalej + iDrivigFlags &= ~moveStopHere; + } + iDrivigFlags |= moveStopCloser; // do następnego W4 podjechać blisko (z dociąganiem) + sSpeedTable[i].iFlags = 0; // nie liczy się już zupełnie (nie wyśle SetVelocity) sSpeedTable[i].fVelNext = -1; // można jechać za W4 - if (go == cm_Unknown) // jeśli nie było komendy wcześniej - go = cm_Ready; // gotów do odjazdu z W4 (semafor może - // zatrzymać) - if (tsGuardSignal) // jeśli mamy głos kierownika, to odegrać + if( ( sSpeedTable[ i ].fDist <= 0.0 ) && ( eSignNext == sSpeedTable[ i ].evEvent ) ) { + // sanity check, if we're held by this stop point, let us go + VelSignalLast = -1; + } + if (go == TCommandType::cm_Unknown) // jeśli nie było komendy wcześniej + go = TCommandType::cm_Ready; // gotów do odjazdu z W4 (semafor może zatrzymać) + if( false == tsGuardSignal.empty() ) { + // jeśli mamy głos kierownika, to odegrać iDrivigFlags |= moveGuardSignal; + } continue; // nie analizować prędkości } // koniec startu z zatrzymania } // koniec obsługi początkowych stacji - else - { // jeśli dojechaliśmy do końca rozkładu + else { + // jeśli dojechaliśmy do końca rozkładu #if LOGSTOPS - WriteLog(pVehicle->asName + " as " + TrainParams->TrainName + - ": at " + std::to_string(GlobalTime->hh) + ":" + - std::to_string(GlobalTime->mm) + - " end of route."); // informacja + WriteLog( + pVehicle->asName + " as " + TrainParams->TrainName + + ": at " + std::to_string(simulation::Time.data().wHour) + ":" + std::to_string(simulation::Time.data().wMinute) + + " end of route."); // informacja #endif asNextStop = TrainParams->NextStop(); // informacja o końcu trasy TrainParams->NewName("none"); // czyszczenie nieaktualnego rozkładu - // TableClear(); //aby od nowa sprawdziło W4 z inną nazwą już - to - // nie jest dobry pomysł - iDrivigFlags &= - ~(moveStopCloser | - moveStopPoint); // ma nie podjeżdżać pod W4 i ma je pomijać - sSpeedTable[i].iFlags = - 0; // W4 nie liczy się już (nie wyśle SetVelocity) - sSpeedTable[i].fVelNext = -1; // można jechać za W4 + // ma nie podjeżdżać pod W4 i ma je pomijać + iDrivigFlags &= ~( moveStopCloser ); + if( false == TestFlag( iDrivigFlags, movePushPull ) ) { + // if the consist can change direction through a simple cab change it doesn't need fiddling with recognition of passenger stops + iDrivigFlags &= ~( moveStopPoint ); + } fLastStopExpDist = -1.0f; // nie ma rozkładu, nie ma usuwania stacji - WaitingSet(60); // tak ze 2 minuty, aż wszyscy wysiądą - JumpToNextOrder(); // wykonanie kolejnego rozkazu (Change_direction - // albo Shunt) - iDrivigFlags |= moveStopHere | moveStartHorn; // ma się nie ruszać - // aż do momentu - // podania sygnału + sSpeedTable[i].iFlags = 0; // W4 nie liczy się już (nie wyśle SetVelocity) + sSpeedTable[i].fVelNext = -1; // można jechać za W4 + if( ( sSpeedTable[ i ].fDist <= 0.0 ) && ( eSignNext == sSpeedTable[ i ].evEvent ) ) { + // sanity check, if we're held by this stop point, let us go + VelSignalLast = -1; + } + // wykonanie kolejnego rozkazu (Change_direction albo Shunt) + JumpToNextOrder(); + // ma się nie ruszać aż do momentu podania sygnału + iDrivigFlags |= moveStopHere | moveStartHorn; continue; // nie analizować prędkości } // koniec obsługi ostatniej stacji - } // if (MoverParameters->Vel==0.0) + } // vel 0, at passenger stop + else { + // HACK: momentarily deactivate W4 to trick the controller into moving closer + sSpeedTable[ i ].fVelNext = -1; + } // vel 0, outside of passenger stop } // koniec obsługi zatrzymania na W4 } // koniec warunku pomijania W4 podczas zmiany czoła else @@ -1080,56 +1101,59 @@ TCommandType TController::TableUpdate(double &fVelDes, double &fDist, double &fN continue; // nie analizować prędkości } } // koniec obsługi W4 - v = sSpeedTable[i].fVelNext; // odczyt prędkości do zmiennej pomocniczej - if (sSpeedTable[i].iFlags & - spSwitch) // zwrotnice są usuwane z tabelki dopiero po zjechaniu z nich - iDrivigFlags |= - moveSwitchFound; // rozjazd z przodu/pod ogranicza np. sens skanowania wstecz + v = sSpeedTable[ i ].fVelNext; // odczyt prędkości do zmiennej pomocniczej + if( sSpeedTable[ i ].iFlags & spSwitch ) { + // zwrotnice są usuwane z tabelki dopiero po zjechaniu z nich + iDrivigFlags |= moveSwitchFound; // rozjazd z przodu/pod ogranicza np. sens skanowania wstecz + } else if (sSpeedTable[i].iFlags & spEvent) // W4 może się deaktywować { // jeżeli event, może być potrzeba wysłania komendy, aby ruszył - // sprawdzanie eventów pasywnych miniętych - if (sSpeedTable[i].fDist < 0.0 && sSemNext == &sSpeedTable[i]) - { - if (Global::iWriteLogEnabled & 8) - WriteLog("TableUpdate: semaphor " + sSemNext->GetName() + " passed by " + OwnerName()); - sSemNext = NULL; // jeśli minęliśmy semafor od ograniczenia to go kasujemy ze - // zmiennej sprawdzającej dla skanowania w przód - } - if (sSpeedTable[i].fDist < 0.0 && sSemNextStop == &sSpeedTable[i]) - { - if (Global::iWriteLogEnabled & 8) - WriteLog("TableUpdate: semaphor " + sSemNextStop->GetName() + " passed by " + OwnerName()); - sSemNextStop = NULL; // jeśli minęliśmy semafor od ograniczenia to go kasujemy ze - // zmiennej sprawdzającej dla skanowania w przód - } - if (sSpeedTable[i].fDist > 0.0 && - sSpeedTable[i].IsProperSemaphor(OrderCurrentGet())) - { - if (!sSemNext) - { - sSemNext = &sSpeedTable[i]; // jeśli jest mienięty poprzedni - // semafor a wcześniej - // byl nowy to go dorzucamy do zmiennej, żeby cały - // czas widział najbliższy - if (Global::iWriteLogEnabled & 8) - WriteLog("TableUpdate: Next semaphor: " + sSemNext->GetName() + " by " + OwnerName()); + if( sSpeedTable[ i ].fDist < 0.0 ) { + // sprawdzanie eventów pasywnych miniętych +/* + if( ( eSignNext != nullptr ) && ( sSpeedTable[ i ].evEvent == eSignNext ) ) { + VelSignalLast = sSpeedTable[ i ].fVelNext; + } +*/ + if( SemNextIndex == i ) { + if( Global.iWriteLogEnabled & 8 ) { + WriteLog( "Speed table update for " + OwnerName() + ", passed semaphor " + sSpeedTable[ SemNextIndex ].GetName() ); + } + SemNextIndex = -1; // jeśli minęliśmy semafor od ograniczenia to go kasujemy ze zmiennej sprawdzającej dla skanowania w przód + } + if( SemNextStopIndex == i ) { + if( Global.iWriteLogEnabled & 8 ) { + WriteLog( "Speed table update for " + OwnerName() + ", passed semaphor " + sSpeedTable[ SemNextStopIndex ].GetName() ); + } + SemNextStopIndex = -1; // jeśli minęliśmy semafor od ograniczenia to go kasujemy ze zmiennej sprawdzającej dla skanowania w przód + } + } + if( sSpeedTable[ i ].fDist > 0.0 ) { + // check signals ahead + if( sSpeedTable[ i ].IsProperSemaphor( OrderCurrentGet() ) ) { + if( SemNextIndex == -1 ) { + // jeśli jest mienięty poprzedni semafor a wcześniej + // byl nowy to go dorzucamy do zmiennej, żeby cały czas widział najbliższy + SemNextIndex = i; + if( Global.iWriteLogEnabled & 8 ) { + WriteLog( "Speed table update for " + OwnerName() + ", next semaphor is " + sSpeedTable[ SemNextIndex ].GetName() ); + } + } + if( ( SemNextStopIndex == -1 ) + || ( ( sSpeedTable[ SemNextStopIndex ].fVelNext != 0 ) + && ( sSpeedTable[ i ].fVelNext == 0 ) ) ) { + SemNextStopIndex = i; + } } - if (!sSemNextStop || (sSemNextStop && sSemNextStop->fVelNext != 0 && - sSpeedTable[i].fVelNext == 0)) - sSemNextStop = &sSpeedTable[i]; } if (sSpeedTable[i].iFlags & spOutsideStation) { // jeśli W5, to reakcja zależna od trybu jazdy if (OrderCurrentGet() & Obey_train) - { // w trybie pociągowym: można przyspieszyć do wskazanej prędkości (po - // zjechaniu z rozjazdów) + { // w trybie pociągowym: można przyspieszyć do wskazanej prędkości (po zjechaniu z rozjazdów) v = -1.0; // ignorować? -//TODO trzeba zmienić przypisywanie VelSignal na VelSignalLast if (sSpeedTable[i].fDist < 0.0) // jeśli wskaźnik został minięty { VelSignalLast = v; //ustawienie prędkości na -1 - // iStationStart=TrainParams->StationIndex; //zaktualizować - // wyświetlanie rozkładu } else if (!(iDrivigFlags & moveSwitchFound)) // jeśli rozjazdy już minięte VelSignalLast = v; //!!! to też koniec ograniczenia @@ -1144,23 +1168,28 @@ TCommandType TController::TableUpdate(double &fVelDes, double &fDist, double &fN // koniec toru) } } - else if (sSpeedTable[i].iFlags & spStopOnSBL) - { // jeśli S1 na SBL - if (mvOccupied->Vel < 2.0) // stanąć nie musi, ale zwolnić przynajmniej - if (sSpeedTable[i].fDist < fMaxProximityDist) // jest w maksymalnym zasięgu - { - eSignSkip = sSpeedTable[i] - .evEvent; // to można go pominąć (wziąć drugą prędkosć) - iDrivigFlags |= moveVisibility; // jazda na widoczność - skanować - // możliwość kolizji i nie podjeżdżać - // zbyt blisko + else if (sSpeedTable[i].iFlags & spStopOnSBL) { + // jeśli S1 na SBL + if( mvOccupied->Vel < 2.0 ) { + // stanąć nie musi, ale zwolnić przynajmniej + if( ( sSpeedTable[ i ].fDist < fMaxProximityDist ) + && ( TrackBlock() > 1000.0 ) ) { + // jest w maksymalnym zasięgu to można go pominąć (wziąć drugą prędkosć) + // as long as there isn't any obstacle in arbitrary view range + eSignSkip = sSpeedTable[ i ].evEvent; + // jazda na widoczność - skanować możliwość kolizji i nie podjeżdżać zbyt blisko // usunąć flagę po podjechaniu blisko semafora zezwalającego na jazdę - // ostrożnie interpretować sygnały - semafor może zezwalać na jazdę - // pociągu z przodu! + // ostrożnie interpretować sygnały - semafor może zezwalać na jazdę pociągu z przodu! + iDrivigFlags |= moveVisibility; + // store the ordered restricted speed and don't exceed it until the flag is cleared + VelRestricted = sSpeedTable[ i ].evEvent->input_value( 2 ); } - if (eSignSkip != sSpeedTable[i].evEvent) // jeśli ten SBL nie jest do pominięcia - // TODO sprawdzić do której zmiennej jest przypisywane v i zmienić to tutaj - v = sSpeedTable[i].evEvent->ValueGet(1); // to ma 0 odczytywać + } + if( eSignSkip != sSpeedTable[ i ].evEvent ) { + // jeśli ten SBL nie jest do pominięcia to ma 0 odczytywać + v = sSpeedTable[ i ].evEvent->input_value( 1 ); + // TODO sprawdzić do której zmiennej jest przypisywane v i zmienić to tutaj + } } else if (sSpeedTable[i].IsProperSemaphor(OrderCurrentGet())) { // to semaphor @@ -1169,7 +1198,11 @@ TCommandType TController::TableUpdate(double &fVelDes, double &fDist, double &fN else { iDrivigFlags |= moveSemaphorFound; //jeśli z przodu to dajemy falgę, że jest - d_to_next_sem = Min0R(sSpeedTable[i].fDist, d_to_next_sem); + d_to_next_sem = std::min(sSpeedTable[i].fDist, d_to_next_sem); + } + if( sSpeedTable[ i ].fDist <= d_to_next_sem ) + { + VelSignalNext = sSpeedTable[ i ].fVelNext; } } else if (sSpeedTable[i].iFlags & spRoadVel) @@ -1183,13 +1216,13 @@ TCommandType TController::TableUpdate(double &fVelDes, double &fDist, double &fN { if (sSpeedTable[i].fSectionVelocityDist == 0.0) { - if (Global::iWriteLogEnabled & 8) - WriteLog("TableUpdate: Event is behind. SVD = 0: " + sSpeedTable[i].evEvent->asName); + if (Global.iWriteLogEnabled & 8) + WriteLog("TableUpdate: Event is behind. SVD = 0: " + sSpeedTable[i].evEvent->m_name); sSpeedTable[i].iFlags = 0; // jeśli punktowy to kasujemy i nie dajemy ograniczenia na stałe } else if (sSpeedTable[i].fSectionVelocityDist < 0.0) { // ograniczenie obowiązujące do następnego - if (sSpeedTable[i].fVelNext == Global::Min0RSpeed(sSpeedTable[i].fVelNext, VelLimitLast) && + if (sSpeedTable[i].fVelNext == min_speed(sSpeedTable[i].fVelNext, VelLimitLast) && sSpeedTable[i].fVelNext != VelLimitLast) { // jeśli ograniczenie jest mniejsze niż obecne to obowiązuje od zaraz VelLimitLast = sSpeedTable[i].fVelNext; @@ -1197,14 +1230,14 @@ TCommandType TController::TableUpdate(double &fVelDes, double &fDist, double &fN else if (sSpeedTable[i].fDist < -fLength) { // jeśli większe to musi wyjechać za poprzednie VelLimitLast = sSpeedTable[i].fVelNext; - if (Global::iWriteLogEnabled & 8) - WriteLog("TableUpdate: Event is behind. SVD < 0: " + sSpeedTable[i].evEvent->asName); + if (Global.iWriteLogEnabled & 8) + WriteLog("TableUpdate: Event is behind. SVD < 0: " + sSpeedTable[i].evEvent->m_name); sSpeedTable[i].iFlags = 0; // wyjechaliśmy poza poprzednie, można skasować } } else { // jeśli większe to ograniczenie ma swoją długość - if (sSpeedTable[i].fVelNext == Global::Min0RSpeed(sSpeedTable[i].fVelNext, VelLimitLast) && + if (sSpeedTable[i].fVelNext == min_speed(sSpeedTable[i].fVelNext, VelLimitLast) && sSpeedTable[i].fVelNext != VelLimitLast) { // jeśli ograniczenie jest mniejsze niż obecne to obowiązuje od zaraz VelLimitLast = sSpeedTable[i].fVelNext; @@ -1216,8 +1249,8 @@ TCommandType TController::TableUpdate(double &fVelDes, double &fDist, double &fN else if (sSpeedTable[i].fDist < -fLength - sSpeedTable[i].fSectionVelocityDist) { // VelLimitLast = -1.0; - if (Global::iWriteLogEnabled & 8) - WriteLog("TableUpdate: Event is behind. SVD > 0: " + sSpeedTable[i].evEvent->asName); + if (Global.iWriteLogEnabled & 8) + WriteLog("TableUpdate: Event is behind. SVD > 0: " + sSpeedTable[i].evEvent->m_name); sSpeedTable[i].iFlags = 0; // wyjechaliśmy poza poprzednie, można skasować } } @@ -1225,150 +1258,173 @@ TCommandType TController::TableUpdate(double &fVelDes, double &fDist, double &fN } //sprawdzenie eventów pasywnych przed nami - if ((mvOccupied->CategoryFlag & 1) ? - sSpeedTable[i].fDist > pVehicles[0]->fTrackBlock - 20.0 : - false) // jak sygnał jest dalej niż zawalidroga + if( ( mvOccupied->CategoryFlag & 1 ) + && ( sSpeedTable[ i ].fDist > pVehicles[ 0 ]->fTrackBlock - 20.0 ) ) { + // jak sygnał jest dalej niż zawalidroga v = 0.0; // to może być podany dla tamtego: jechać tak, jakby tam stop był + } else { // zawalidrogi nie ma (albo pojazd jest samochodem), sprawdzić sygnał - if (sSpeedTable[i].iFlags & spShuntSemaphor) // jeśli Tm - w zasadzie to sprawdzić - // komendę! + if (sSpeedTable[i].iFlags & spShuntSemaphor) // jeśli Tm - w zasadzie to sprawdzić komendę! { // jeśli podana prędkość manewrowa - if ((OrderCurrentGet() & Obey_train) ? v == 0.0 : false) - { // jeśli tryb pociągowy a tarcze ma ShuntVelocity 0 0 + if( ( v == 0.0 ) && ( true == TestFlag( OrderCurrentGet(), Obey_train ) ) ) { + // jeśli tryb pociągowy a tarcze ma ShuntVelocity 0 0 v = -1; // ignorować, chyba że prędkość stanie się niezerowa - if (sSpeedTable[i].iFlags & spElapsed) // a jak przejechana - sSpeedTable[i].iFlags = 0; // to można usunąć, bo podstawowy automat - // usuwa tylko niezerowe + if( true == TestFlag( sSpeedTable[ i ].iFlags, spElapsed ) ) { + // a jak przejechana to można usunąć, bo podstawowy automat usuwa tylko niezerowe + sSpeedTable[ i ].iFlags = 0; + } } - else if (go == cm_Unknown) // jeśli jeszcze nie ma komendy - if (v != 0.0) // komenda jest tylko gdy ma jechać, bo stoi na podstawie - // tabelki - { // jeśli nie było komendy wcześniej - pierwsza się liczy - ustawianie - // VelSignal - go = cm_ShuntVelocity; // w trybie pociągowym tylko jeśli włącza + else if( go == TCommandType::cm_Unknown ) { + // jeśli jeszcze nie ma komendy + // komenda jest tylko gdy ma jechać, bo stoi na podstawietabelki + if( v != 0.0 ) { + // jeśli nie było komendy wcześniej - pierwsza się liczy - ustawianie VelSignal + go = TCommandType::cm_ShuntVelocity; // w trybie pociągowym tylko jeśli włącza // tryb manewrowy (v!=0.0) // Ra 2014-06: (VelSignal) nie może być tu ustawiane, bo Tm może być // daleko // VelSignal=v; //nie do końca tak, to jest druga prędkość - if (VelSignal == 0.0) - VelSignal = v; // aby stojący ruszył - if (sSpeedTable[i].fDist < 0.0) // jeśli przejechany - { - VelSignal = v; //!!! ustawienie, gdy przejechany jest lepsze niż - // wcale, ale to jeszcze nie to - sSpeedTable[i].iFlags = - 0; // to można usunąć (nie mogą być usuwane w skanowaniu) + if( VelSignal == 0.0 ) { + // aby stojący ruszył + VelSignal = v; + } + if( sSpeedTable[ i ].fDist < 0.0 ) { + // jeśli przejechany + //!!! ustawienie, gdy przejechany jest lepsze niż wcale, ale to jeszcze nie to + VelSignal = v; + // to można usunąć (nie mogą być usuwane w skanowaniu) + sSpeedTable[ i ].iFlags = 0; } } + } } - else if (!(sSpeedTable[i].iFlags & spSectionVel)) //jeśli jakiś event pasywny ale nie ograniczenie - if (go == cm_Unknown) // jeśli nie było komendy wcześniej - pierwsza się liczy - // - ustawianie VelSignal - if (v < 0.0 ? true : v >= 1.0) // bo wartość 0.1 służy do hamowania tylko - { - go = cm_SetVelocity; // może odjechać - // Ra 2014-06: (VelSignal) nie może być tu ustawiane, bo semafor może - // być daleko - // VelSignal=v; //nie do końca tak, to jest druga prędkość; -1 nie - // wpisywać... - if (VelSignal == 0.0) - VelSignal = -1.0; // aby stojący ruszył - if (sSpeedTable[i].fDist < 0.0) // jeśli przejechany - { - VelSignal = (v != 0 ? -1.0 : 0.0); - // ustawienie, gdy przejechany jest lepsze niż - // wcale, ale to jeszcze nie to - if (sSpeedTable[i].iFlags & spEvent) // jeśli event - if ((sSpeedTable[i].evEvent != eSignSkip) ? - true : - (sSpeedTable[i].fVelNext != 0.0)) // ale inny niż ten, - // na którym minięto - // S1, chyba że się - // już zmieniło - iDrivigFlags &= ~moveVisibility; // sygnał zezwalający na - // jazdę wyłącza jazdę na - // widoczność (S1 na SBL) - - // usunąć jeśli nie jest ograniczeniem prędkości - sSpeedTable[i].iFlags = - 0; // to można usunąć (nie mogą być usuwane w skanowaniu) + else if( !( sSpeedTable[ i ].iFlags & spSectionVel ) ) { + //jeśli jakiś event pasywny ale nie ograniczenie + if( go == TCommandType::cm_Unknown ) { + // jeśli nie było komendy wcześniej - pierwsza się liczy - ustawianie VelSignal + if( ( v < 0.0 ) + || ( v >= 1.0 ) ) { + // bo wartość 0.1 służy do hamowania tylko + go = TCommandType::cm_SetVelocity; // może odjechać + // Ra 2014-06: (VelSignal) nie może być tu ustawiane, bo semafor może być daleko + // VelSignal=v; //nie do końca tak, to jest druga prędkość; -1 nie wpisywać... + if( VelSignal == 0.0 ) { + // aby stojący ruszył + VelSignal = -1.0; + } + if( sSpeedTable[ i ].fDist < 0.0 ) { + // jeśli przejechany + VelSignal = ( v == 0.0 ? 0.0 : -1.0 ); + // ustawienie, gdy przejechany jest lepsze niż wcale, ale to jeszcze nie to + if( sSpeedTable[ i ].iFlags & spEvent ) { + // jeśli event + if( ( sSpeedTable[ i ].evEvent != eSignSkip ) + || ( sSpeedTable[ i ].fVelNext != VelRestricted ) ) { + // ale inny niż ten, na którym minięto S1, chyba że się już zmieniło + // sygnał zezwalający na jazdę wyłącza jazdę na widoczność (po S1 na SBL) + iDrivigFlags &= ~moveVisibility; + // remove restricted speed + VelRestricted = -1.0; + } + } + // jeśli nie jest ograniczeniem prędkości to można usunąć + // (nie mogą być usuwane w skanowaniu) + sSpeedTable[ i ].iFlags = 0; } } - else if (sSpeedTable[i].evEvent->StopCommand()) - { // jeśli prędkość jest zerowa, a komórka zawiera komendę - eSignNext = sSpeedTable[i].evEvent; // dla informacji - if (iDrivigFlags & - moveStopHere) // jeśli ma stać, dostaje komendę od razu - go = cm_Command; // komenda z komórki, do wykonania po zatrzymaniu - else if (sSpeedTable[i].fDist <= 20.0) // jeśli ma dociągnąć, to niech - // dociąga (moveStopCloser - // dotyczy dociągania do W4, nie - // semafora) - go = cm_Command; // komenda z komórki, do wykonania po zatrzymaniu + else if( sSpeedTable[ i ].evEvent->is_command() ) { + // jeśli prędkość jest zerowa, a komórka zawiera komendę + eSignNext = sSpeedTable[ i ].evEvent; // dla informacji + if( true == TestFlag( iDrivigFlags, moveStopHere ) ) { + // jeśli ma stać, dostaje komendę od razu + go = TCommandType::cm_Command; // komenda z komórki, do wykonania po zatrzymaniu + } + else if( sSpeedTable[ i ].fDist <= fMaxProximityDist ) { + // jeśli ma dociągnąć, to niech dociąga + // (moveStopCloser dotyczy dociągania do W4, nie semafora) + go = TCommandType::cm_Command; // komenda z komórki, do wykonania po zatrzymaniu + } } + } + } } // jeśli nie ma zawalidrogi } // jeśli event - if (v >= 0.0) - { // pozycje z prędkością -1 można spokojnie pomijać + + if (v >= 0.0) { + // pozycje z prędkością -1 można spokojnie pomijać d = sSpeedTable[i].fDist; - if ((sSpeedTable[i].iFlags & spElapsed) ? - false : - d > 0.0) // sygnał lub ograniczenie z przodu (+32=przejechane) - { // 2014-02: jeśli stoi, a ma do przejechania kawałek, to niech jedzie - if ((mvOccupied->Vel == 0.0) ? - ((sSpeedTable[i].iFlags & - (spEnabled | spEvent | spPassengerStopPoint)) == - (spEnabled | spEvent | spPassengerStopPoint)) && - (d > fMaxProximityDist) : - false) - a = (iDrivigFlags & moveStopCloser) ? fAcc : 0.0; // ma podjechać bliżej - - // czy na pewno w tym - // miejscu taki warunek? - else - { - a = (v * v - mvOccupied->Vel * mvOccupied->Vel) / - (25.92 * d); // przyspieszenie: ujemne, gdy trzeba hamować - if (d < fMinProximityDist) // jak jest już blisko - if (v < fVelDes) - fVelDes = v; // ograniczenie aktualnej prędkości + if( ( d > 0.0 ) + && ( false == TestFlag( sSpeedTable[ i ].iFlags, spElapsed ) ) ) { + // sygnał lub ograniczenie z przodu (+32=przejechane) + // 2014-02: jeśli stoi, a ma do przejechania kawałek, to niech jedzie + if( ( mvOccupied->Vel < 0.01 ) + && ( true == TestFlag( sSpeedTable[ i ].iFlags, ( spEnabled | spEvent | spPassengerStopPoint ) ) ) + && ( false == isatpassengerstop ) ) { + // ma podjechać bliżej - czy na pewno w tym miejscu taki warunek? + a = ( ( d > passengerstopmaxdistance ) || ( ( iDrivigFlags & moveStopCloser ) != 0 ) ? + fAcc : + 0.0 ); + } + else { + // przyspieszenie: ujemne, gdy trzeba hamować + a = ( v * v - mvOccupied->Vel * mvOccupied->Vel ) / ( 25.92 * d ); + if( ( mvOccupied->Vel < v ) + || ( v == 0.0 ) ) { + // if we're going slower than the target velocity and there's enough room for safe stop, speed up + auto const brakingdistance = fBrakeDist * braking_distance_multiplier( v ); + if( brakingdistance > 0.0 ) { + // maintain desired acc while we have enough room to brake safely, when close enough start paying attention + // try to make a smooth transition instead of sharp change + a = interpolate( a, AccPreferred, clamp( ( d - brakingdistance ) / brakingdistance, 0.0, 1.0 ) ); + } + } + if( ( d < fMinProximityDist ) + && ( v < fVelDes ) ) { + // jak jest już blisko, ograniczenie aktualnej prędkości + fVelDes = v; + } } } else if (sSpeedTable[i].iFlags & spTrack) // jeśli tor { // tor ogranicza prędkość, dopóki cały skład nie przejedzie, // d=fLength+d; //zamiana na długość liczoną do przodu - if (v >= 1.0) // EU06 się zawieszało po dojechaniu na koniec toru postojowego - if (d < -fLength) + if( v >= 1.0 ) // EU06 się zawieszało po dojechaniu na koniec toru postojowego + if( d + sSpeedTable[ i ].trTrack->Length() < -fLength ) continue; // zapętlenie, jeśli już wyjechał za ten odcinek - if (v < fVelDes) - fVelDes = - v; // ograniczenie aktualnej prędkości aż do wyjechania za ograniczenie + if( v < fVelDes ) { + // ograniczenie aktualnej prędkości aż do wyjechania za ograniczenie + fVelDes = v; + } + if( ( sSpeedTable[ i ].iFlags & spEnd ) + && ( mvOccupied->CategoryFlag & 1 ) ) { + // if the railway track ends here set the velnext accordingly as well + // TODO: test this with turntables and such + fNext = 0.0; + } // if (v==0.0) fAcc=-0.9; //hamowanie jeśli stop continue; // i tyle wystarczy } else // event trzyma tylko jeśli VelNext=0, nawet po przejechaniu (nie powinno // dotyczyć samochodów?) a = (v == 0.0 ? -1.0 : fAcc); // ruszanie albo hamowanie - if (a < fAcc && v == Min0R(v, fNext)) - { // mniejsze przyspieszenie to mniejsza możliwość rozpędzenia się albo konieczność - // hamowania + + if ((a < fAcc) && (v == std::min(v, fNext))) { + // mniejsze przyspieszenie to mniejsza możliwość rozpędzenia się albo konieczność hamowania // jeśli droga wolna, to może być a>1.0 i się tu nie załapuje - // if (mvOccupied->Vel>10.0) fAcc = a; // zalecane przyspieszenie (nie musi być uwzględniane przez AI) fNext = v; // istotna jest prędkość na końcu tego odcinka fDist = d; // dlugość odcinka } - else if ((fAcc > 0) && (v > 0) && (v <= fNext)) - { // jeśli nie ma wskazań do hamowania, można podać drogę i prędkość na jej końcu + else if ((fAcc > 0) && (v >= 0) && (v <= fNext)) { + // jeśli nie ma wskazań do hamowania, można podać drogę i prędkość na jej końcu fNext = v; // istotna jest prędkość na końcu tego odcinka - fDist = d; // dlugość odcinka (kolejne pozycje mogą wydłużać drogę, jeśli - // prędkość jest stała) + fDist = d; // dlugość odcinka (kolejne pozycje mogą wydłużać drogę, jeśli prędkość jest stała) } } // if (v>=0.0) if (fNext >= 0.0) { // jeśli ograniczenie - if ((sSpeedTable[i].iFlags & (spEnabled | spEvent)) == - (spEnabled | spEvent)) // tylko sygnał przypisujemy + if ((sSpeedTable[i].iFlags & (spEnabled | spEvent)) == (spEnabled | spEvent)) // tylko sygnał przypisujemy if (!eSignNext) // jeśli jeszcze nic nie zapisane tam eSignNext = sSpeedTable[i].evEvent; // dla informacji if (fNext == 0.0) @@ -1377,74 +1433,144 @@ TCommandType TController::TableUpdate(double &fVelDes, double &fDist, double &fN } // if (sSpeedTable[i].iFlags&1) } // for - if (VelSignalLast >= 0.0 && !(iDrivigFlags & (moveSemaphorFound | moveSwitchFound)) && - (OrderCurrentGet() & Obey_train)) - VelSignalLast = -1.0; // jeśli mieliśmy ograniczenie z semafora i nie ma przed nami + // jeśli mieliśmy ograniczenie z semafora i nie ma przed nami + if( ( VelSignalLast >= 0.0 ) + && ( ( iDrivigFlags & ( moveSemaphorFound | moveSwitchFound | moveStopPointFound ) ) == 0 ) + && ( true == TestFlag( OrderCurrentGet(), Obey_train ) ) ) { + VelSignalLast = -1.0; + } - if (VelSignalLast >= 0.0) //analiza spisanych z tabelki ograniczeń i nadpisanie aktualnego - fVelDes = Min0R(fVelDes, VelSignalLast); - if (VelLimitLast >= 0.0) - fVelDes = Min0R(fVelDes, VelLimitLast); - if (VelRoad >= 0.0) - fVelDes = Min0R(fVelDes, VelRoad); - // nastepnego semafora albo zwrotnicy to uznajemy, że mijamy W5 + //analiza spisanych z tabelki ograniczeń i nadpisanie aktualnego + if( ( true == isatpassengerstop ) && ( mvOccupied->Vel < 0.01 ) ) { + // if stopped at a valid passenger stop, hold there + fVelDes = 0.0; + } + else { + fVelDes = min_speed( fVelDes, VelSignalLast ); + fVelDes = min_speed( fVelDes, VelLimitLast ); + fVelDes = min_speed( fVelDes, VelRoad ); + fVelDes = min_speed( fVelDes, VelRestricted ); + } + // nastepnego semafora albo zwrotnicy to uznajemy, że mijamy W5 FirstSemaphorDist = d_to_next_sem; // przepisanie znalezionej wartosci do zmiennej return go; }; +// modifies brake distance for low target speeds, to ease braking rate in such situations +float +TController::braking_distance_multiplier( float const Targetvelocity ) const { + + if( Targetvelocity > 65.f ) { return 1.f; } + if( Targetvelocity < 5.f ) { + // HACK: engaged automatic transmission means extra/earlier braking effort is needed for the last leg before full stop + if( ( mvOccupied->TrainType == dt_DMU ) + && ( mvOccupied->Vel < 40.0 ) + && ( Targetvelocity == 0.f ) ) { + return interpolate( 2.f, 1.f, static_cast( mvOccupied->Vel / 40.0 ) ); + } + // HACK: cargo trains or trains going downhill with high braking threshold need more distance to come to a full stop + if( ( fBrake_a0[ 1 ] > 0.2 ) + && ( ( true == IsCargoTrain ) + || ( fAccGravity > 0.025 ) ) ) { + return interpolate( + 1.f, 2.f, + clamp( + ( fBrake_a0[ 1 ] - 0.2 ) / 0.2, + 0.0, 1.0 ) ); + } + + return 1.f; + } + // stretch the braking distance up to 3 times; the lower the speed, the greater the stretch + return interpolate( 3.f, 1.f, ( Targetvelocity - 5.f ) / 60.f ); +} + void TController::TablePurger() { // odtykacz: usuwa mniej istotne pozycje ze środka tabelki, aby uniknąć zatkania //(np. brak ograniczenia pomiędzy zwrotnicami, usunięte sygnały, minięte odcinki łuku) - if (Global::iWriteLogEnabled & 8) - WriteLog("TablePurger: Czyszczenie tabelki."); - int i, j, k = iLast - iFirst; // może być 15 albo 16 pozycji, ostatniej nie ma co sprawdzać - if (k < 0) - k += iSpeedTableSize; // ilość pozycji do przeanalizowania - for (i = iFirst; k > 0; --k, i = (i + 1) % iSpeedTableSize) - { // sprawdzenie rekordów od (iFirst) do (iLast), o ile są istotne - if ((sSpeedTable[i].iFlags & spEnabled) ? - (sSpeedTable[i].fVelNext < 0) && ((sSpeedTable[i].iFlags & 0xAB) == 0xA3) : - true) - { // jeśli jest to minięty (0x20) tor (0x03) do liczenia cięciw (0x80), a nie zwrotnica - // (0x08) - for (; k > 0; --k, i = (i + 1) % iSpeedTableSize) - { - sSpeedTable[i] = sSpeedTable[(i + 1) % iSpeedTableSize]; // skopiowanie - if (&sSpeedTable[(i + 1) % iSpeedTableSize] == sSemNext) - sSemNext = &sSpeedTable[i]; // przeniesienie znacznika o semaforze - if (&sSpeedTable[(i + 1) % iSpeedTableSize] == sSemNextStop) - sSemNextStop = &sSpeedTable[i]; // przeniesienie znacznika o semaforze - } - if (Global::iWriteLogEnabled & 8) - WriteLog("Odtykacz usuwa pozycję"); - iLast = (iLast - 1 + iSpeedTableSize) % iSpeedTableSize; // cofnięcie z zawinięciem - return; + if( sSpeedTable.size() < 2 ) { + return; + } + // simplest approach should be good enough for start -- just copy whatever is still relevant, then swap + // do a trial run first, to see if we need to bother at all + std::size_t trimcount{ 0 }; + for( std::size_t idx = 0; idx < sSpeedTable.size() - 1; ++idx ) { + auto const &speedpoint = sSpeedTable[ idx ]; + if( ( 0 == ( speedpoint.iFlags & spEnabled ) ) + || ( ( ( speedpoint.iFlags & ( spElapsed | spTrack | spCurve | spSwitch ) ) == ( spElapsed | spTrack | spCurve ) ) + && ( speedpoint.fVelNext < 0.0 ) ) ) { + // NOTE: we could break out early here, but running through entire thing gives us exact size needed for new table + ++trimcount; } } - // jeśli powyższe odtykane nie pomoże, można usunąć coś więcej, albo powiększyć tabelkę - TSpeedPos *t = new TSpeedPos[iSpeedTableSize + 16]; // zwiększenie - k = iLast - iFirst + 1; // tym razem wszystkie - if (k < 0) - k += iSpeedTableSize; // ilość pozycji do przeanalizowania - for (j = -1, i = iFirst; k > 0; --k) - { // przepisywanie rekordów iFirst..iLast na 0..k - t[++j] = sSpeedTable[i]; - if (&sSpeedTable[i] == sSemNext) - sSemNext = &t[j]; // przeniesienie znacznika o semaforze - if (&sSpeedTable[i] == sSemNextStop) - sSemNextStop = &t[j]; // przeniesienie znacznika o semaforze - i = (i + 1) % iSpeedTableSize; // kolejna pozycja mogą być zawinięta + if( trimcount == 0 ) { + // there'd be no gain, may as well bail + return; } - iFirst = 0; // teraz będzie od zera - iLast = j; // ostatnia - delete[] sSpeedTable; // to już nie potrzebne - sSpeedTable = t; // bo jest nowe - iSpeedTableSize += 16; - if (Global::iWriteLogEnabled & 8) - WriteLog("Tabelka powiększona do "+std::to_string(iSpeedTableSize)+" pozycji"); + std::vector trimmedtable; trimmedtable.reserve( sSpeedTable.size() - trimcount ); + // we can only update pointers safely after new table is finalized, so record their indices until then + for( std::size_t idx = 0; idx < sSpeedTable.size() - 1; ++idx ) { + // cache placement of semaphors in the new table, if we encounter them + if( idx == SemNextIndex ) { + SemNextIndex = trimmedtable.size(); + } + if( idx == SemNextStopIndex ) { + SemNextStopIndex = trimmedtable.size(); + } + auto const &speedpoint = sSpeedTable[ idx ]; + if( ( 0 == ( speedpoint.iFlags & spEnabled ) ) + || ( ( ( speedpoint.iFlags & ( spElapsed | spTrack | spCurve | spSwitch ) ) == ( spElapsed | spTrack | spCurve ) ) + && ( speedpoint.fVelNext < 0.0 ) ) ) { + // if the trimmed point happens to be currently active semaphor we need to invalidate their placements + if( idx == SemNextIndex ) { + SemNextIndex = -1; + } + if( idx == SemNextStopIndex ) { + SemNextStopIndex = -1; + } + continue; + } + // we're left with useful speed point record we should copy + trimmedtable.emplace_back( speedpoint ); + } + // always copy the last entry + trimmedtable.emplace_back( sSpeedTable.back() ); + + if( Global.iWriteLogEnabled & 8 ) { + WriteLog( "Speed table garbage collection for " + OwnerName() + " cut away " + std::to_string( trimcount ) + ( trimcount == 1 ? " record" : " records" ) ); + } + // update the data + std::swap( sSpeedTable, trimmedtable ); + iLast = sSpeedTable.size() - 1; }; -//--------------------------------------------------------------------------- -//--------------------------------------------------------------------------- + +void TController::TableSort() { + + if( sSpeedTable.size() < 3 ) { + // we skip last slot and no point in checking if there's only one other entry + return; + } + TSpeedPos sp_temp = TSpeedPos(); // uzywany do przenoszenia + for( int i = 0; i < ( iLast - 1 ); ++i ) { + // pętla tylko do dwóch pozycji od końca bo ostatniej nie modyfikujemy + if (sSpeedTable[i].fDist > sSpeedTable[i + 1].fDist) + { // jesli pozycja wcześniejsza jest dalej to źle + sp_temp = sSpeedTable[i + 1]; + sSpeedTable[i + 1] = sSpeedTable[i]; // zamiana + sSpeedTable[i] = sp_temp; + // jeszcze sprawdzenie czy pozycja nie była indeksowana dla eventów + if (SemNextIndex == i) + ++SemNextIndex; + else if (SemNextIndex == i + 1) + --SemNextIndex; + if (SemNextStopIndex == i) + ++SemNextStopIndex; + else if (SemNextStopIndex == i + 1) + --SemNextStopIndex; + } + } +} + //--------------------------------------------------------------------------- TController::TController(bool AI, TDynamicObject *NewControll, bool InitPsyche, bool primary) :// czy ma aktywnie prowadzić? @@ -1478,8 +1604,11 @@ TController::TController(bool AI, TDynamicObject *NewControll, bool InitPsyche, } // fAccThreshold może podlegać uczeniu się - hamowanie powinno być rejestrowane, a potem analizowane - fAccThreshold = - ( mvOccupied->TrainType & dt_EZT ) ? -0.6 : -0.2; // próg opóźnienia dla zadziałania hamulca + // próg opóźnienia dla zadziałania hamulca + fAccThreshold = ( + mvOccupied->TrainType == dt_EZT ? -0.55 : + mvOccupied->TrainType == dt_DMU ? -0.45 : + -0.2 ); } // TrainParams=NewTrainParams; // if (TrainParams) @@ -1495,20 +1624,26 @@ TController::TController(bool AI, TDynamicObject *NewControll, bool InitPsyche, } SetDriverPsyche(); // na końcu, bo wymaga ustawienia zmiennych - sSpeedTable = new TSpeedPos[iSpeedTableSize]; TableClear(); if( WriteLogFlag ) { - mkdir( "physicslog\\" ); - LogFile.open( string( "physicslog\\" + VehicleName + ".dat" ).c_str(), +#ifdef _WIN32 + _mkdir( "physicslog" ); +#elif __linux__ + mkdir( "physicslog", 0644 ); +#endif + LogFile.open( std::string( "physicslog/" + VehicleName + ".dat" ), std::ios::in | std::ios::out | std::ios::trunc ); #if LOGPRESS == 0 - LogFile << string( " Time [s] Velocity [m/s] Acceleration [m/ss] Coupler.Dist[m] " - "Coupler.Force[N] TractionForce [kN] FrictionForce [kN] " - "BrakeForce [kN] BrakePress [MPa] PipePress [MPa] " - "MotorCurrent [A] MCP SCP BCP LBP DmgFlag Command CVal1 CVal2" ) - .c_str() + LogFile + << "Time[s] Velocity[m/s] Acceleration[m/ss] " + << "Coupler.Dist[m] Coupler.Force[N] TractionForce[kN] FrictionForce[kN] BrakeForce[kN] " + << "BrakePress[MPa] PipePress[MPa] MotorCurrent[A] " + << "MCP SCP BCP LBP Direction Command CVal1 CVal2 " + << "Security Wheelslip " + << "EngineTemp[Deg] OilTemp[Deg] WaterTemp[Deg] WaterAuxTemp[Deg]" << "\r\n"; + LogFile << std::fixed << std::setprecision( 4 ); #endif #if LOGPRESS == 1 LogFile << string( "t\tVel\tAcc\tPP\tVVP\tBP\tBVP\tCVP" ).c_str() << "\n"; @@ -1532,50 +1667,34 @@ void TController::CloseLog() TController::~TController() { // wykopanie mechanika z roboty - delete tsGuardSignal; delete TrainParams; - delete[] sSpeedTable; CloseLog(); }; -std::string TController::Order2Str(TOrders Order) -{ // zamiana kodu rozkazu na opis - if (Order & Change_direction) - return "Change_direction"; // może być nałożona na inną i wtedy ma priorytet - if (Order == Wait_for_orders) - return "Wait_for_orders"; - if (Order == Prepare_engine) - return "Prepare_engine"; - if (Order == Shunt) - return "Shunt"; - if (Order == Connect) - return "Connect"; - if (Order == Disconnect) - return "Disconnect"; - if (Order == Obey_train) - return "Obey_train"; - if (Order == Release_engine) - return "Release_engine"; - if (Order == Jump_to_first_order) - return "Jump_to_first_order"; - /* Ra: wersja ze switch nie działa prawidłowo (czemu?) - switch (Order) - { - Wait_for_orders: return "Wait_for_orders"; - Prepare_engine: return "Prepare_engine"; - Shunt: return "Shunt"; - Change_direction: return "Change_direction"; - Obey_train: return "Obey_train"; - Release_engine: return "Release_engine"; - Jump_to_first_order: return "Jump_to_first_order"; - } - */ - return "Undefined!"; +// zamiana kodu rozkazu na opis +std::string TController::Order2Str(TOrders Order) const { + + if( Order & Change_direction ) { + // może być nałożona na inną i wtedy ma priorytet + return "Change_direction"; + } + switch( Order ) { + case Wait_for_orders: return "Wait_for_orders"; + case Prepare_engine: return "Prepare_engine"; + case Release_engine: return "Release_engine"; + case Change_direction: return "Change_direction"; + case Connect: return "Connect"; + case Disconnect: return "Disconnect"; + case Shunt: return "Shunt"; + case Obey_train: return "Obey_train"; + case Jump_to_first_order: return "Jump_to_first_order"; + default: return "Undefined"; + } } -std::string TController::OrderCurrent() +std::string TController::OrderCurrent() const { // pobranie aktualnego rozkazu celem wyświetlenia - return std::to_string(OrderPos) + ". " + Order2Str(OrderList[OrderPos]); + return "[" + std::to_string(OrderPos) + "] " + Order2Str(OrderList[OrderPos]); }; void TController::OrdersClear() @@ -1598,7 +1717,7 @@ void TController::Activation() TDynamicObject *old = pVehicle, *d = pVehicle; // w tym siedzi AI TController *drugi; // jakby były dwa, to zamienić miejscami, a nie robić wycieku pamięci // poprzez nadpisanie - int brake = mvOccupied->LocalBrakePos; + auto const localbrakelevel { mvOccupied->LocalBrakePosA }; while (mvControlling->MainCtrlPos) // samo zapętlenie DecSpeed() nie wystarcza :/ DecSpeed(true); // wymuszenie zerowania nastawnika jazdy while (mvOccupied->ActiveDir < 0) @@ -1610,7 +1729,7 @@ void TController::Activation() { mvControlling->MainSwitch( false); // dezaktywacja czuwaka, jeśli przejście do innego członu - mvOccupied->DecLocalBrakeLevel(10); // zwolnienie hamulca w opuszczanym pojeździe + mvOccupied->DecLocalBrakeLevel(LocalBrakePosNo); // zwolnienie hamulca w opuszczanym pojeździe // mvOccupied->BrakeLevelSet((mvOccupied->BrakeHandle==FVel6)?4:-2); //odcięcie na // zaworze maszynisty, FVel6 po drugiej stronie nie luzuje mvOccupied->BrakeLevelSet( @@ -1644,16 +1763,22 @@ void TController::Activation() } if (pVehicle != old) { // jeśli zmieniony został pojazd prowadzony - Global::pWorld->CabChange(old, pVehicle); // ewentualna zmiana kabiny użytkownikowi + if( ( simulation::Train ) + && ( simulation::Train->Dynamic() == old ) ) { + // ewentualna zmiana kabiny użytkownikowi + Global.changeDynObj = pVehicle; // uruchomienie protezy + } ControllingSet(); // utworzenie połączenia do sterowanego pojazdu (może się zmienić) - // silnikowy dla EZT } - if (mvControlling->EngineType == - DieselEngine) // dla 2Ls150 - przed ustawieniem kierunku - można zmienić tryb pracy - if (mvControlling->ShuntModeAllow) + if( mvControlling->EngineType == TEngineType::DieselEngine ) { + // dla 2Ls150 - przed ustawieniem kierunku - można zmienić tryb pracy + if( mvControlling->ShuntModeAllow ) { mvControlling->CurrentSwitch( - (OrderList[OrderPos] & Shunt) || - (fMass > 224000.0)); // do tego na wzniesieniu może nie dać rady na liniowym + ( ( OrderList[ OrderPos ] & Shunt ) == Shunt ) + || ( fMass > 224000.0 ) ); // do tego na wzniesieniu może nie dać rady na liniowym + } + } // Ra: to przełączanie poniżej jest tu bez sensu mvOccupied->ActiveCab = iDirection; // aktywacja kabiny w prowadzonym pojeżdzie (silnikowy może być odwrotnie?) @@ -1661,8 +1786,8 @@ void TController::Activation() // mvOccupied->ActiveDir=0; //żeby sam ustawił kierunek mvOccupied->CabActivisation(); // uruchomienie kabin w członach DirectionForward(true); // nawrotnik do przodu - if (brake) // hamowanie tylko jeśli był wcześniej zahamowany (bo możliwe, że jedzie!) - mvOccupied->IncLocalBrakeLevel(brake); // zahamuj jak wcześniej + if (localbrakelevel > 0.0) // hamowanie tylko jeśli był wcześniej zahamowany (bo możliwe, że jedzie!) + mvOccupied->LocalBrakePosA = localbrakelevel; // zahamuj jak wcześniej CheckVehicles(); // sprawdzenie składu, AI zapali światła TableClear(); // resetowanie tabelki skanowania torów } @@ -1694,7 +1819,7 @@ void TController::AutoRewident() ustaw = 16 + bdelay_R; // lokomotywa luzem (może być wieloczłonowa) else { // jeśli są wagony - ustaw = (g < min(4, r + p) ? 16 : 0); + ustaw = (g < std::min(4, r + p) ? 16 : 0); if (ustaw) // jeśli towarowe < Min(4, pospieszne+osobowe) { // to skład pasażerski - nastawianie pasażerskiego ustaw += (g && (r < g + p)) ? bdelay_P : bdelay_R; @@ -1717,47 +1842,180 @@ void TController::AutoRewident() p = 0; // będziemy tu liczyć wagony od lokomotywy dla nastawy GP while (d) { // 3. Nastawianie - switch (ustaw) - { - case bdelay_P: // towarowy P - lokomotywa na G, reszta na P. - d->MoverParameters->BrakeDelaySwitch(d->MoverParameters->Power > 1 ? bdelay_G : - bdelay_P); - break; - case bdelay_G: // towarowy G - wszystko na G, jeśli nie ma to P (powinno się wyłączyć - // hamulec) - d->MoverParameters->BrakeDelaySwitch( - TestFlag(d->MoverParameters->BrakeDelays, bdelay_G) ? bdelay_G : bdelay_P); - break; - case bdelay_R: // towarowy GP - lokomotywa oraz 5 pierwszych pojazdów przy niej na G, reszta - // na P - if (d->MoverParameters->Power > 1) - { - d->MoverParameters->BrakeDelaySwitch(bdelay_G); - p = 0; // a jak będzie druga w środku? + if( ( true == AIControllFlag ) + || ( d != pVehicle ) ) { + // don't touch human-controlled vehicle, but others are free game + switch( ustaw ) { + + case bdelay_P: { + // towarowy P - lokomotywa na G, reszta na P. + d->MoverParameters->BrakeDelaySwitch( + d->MoverParameters->Power > 1 ? + bdelay_G : + bdelay_P ); + break; + } + case bdelay_G: { + // towarowy G - wszystko na G, jeśli nie ma to P (powinno się wyłączyć hamulec) + d->MoverParameters->BrakeDelaySwitch( + TestFlag( d->MoverParameters->BrakeDelays, bdelay_G ) ? + bdelay_G : + bdelay_P ); + break; + } + case bdelay_R: { + // towarowy GP - lokomotywa oraz 5 pierwszych pojazdów przy niej na G, reszta na P + if( d->MoverParameters->Power > 1 ) { + d->MoverParameters->BrakeDelaySwitch( bdelay_G ); + p = 0; // a jak będzie druga w środku? + } + else { + d->MoverParameters->BrakeDelaySwitch( + ++p <= 5 ? + bdelay_G : + bdelay_P ); + } + break; + } + case 16 + bdelay_R: { + // pasażerski R - na R, jeśli nie ma to P + d->MoverParameters->BrakeDelaySwitch( + TestFlag( d->MoverParameters->BrakeDelays, bdelay_R ) ? + bdelay_R : + bdelay_P ); + break; + } + case 16 + bdelay_P: { + // pasażerski P - wszystko na P + d->MoverParameters->BrakeDelaySwitch( bdelay_P ); + break; + } } - else - d->MoverParameters->BrakeDelaySwitch(++p <= 5 ? bdelay_G : bdelay_P); - break; - case 16 + bdelay_R: // pasażerski R - na R, jeśli nie ma to P - d->MoverParameters->BrakeDelaySwitch( - TestFlag(d->MoverParameters->BrakeDelays, bdelay_R) ? bdelay_R : bdelay_P); - break; - case 16 + bdelay_P: // pasażerski P - wszystko na P - d->MoverParameters->BrakeDelaySwitch(bdelay_P); - break; } d = d->Next(); // kolejny pojazd, podłączony od tyłu (licząc od czoła) } -}; + //ustawianie trybu pracy zadajnika hamulca, wystarczy raz po inicjalizacji AI + for( int i = 1; i <= 8; i *= 2 ) { + if( ( mvOccupied->BrakeOpModes & i ) > 0 ) { + mvOccupied->BrakeOpModeFlag = i; + } + } + // teraz zerujemy tabelkę opóźnienia hamowania + for (int i = 0; i < BrakeAccTableSize; ++i) + { + fBrake_a0[i+1] = 0; + fBrake_a1[i+1] = 0; + } + // 4. Przeliczanie siły hamowania + double const velstep = ( mvOccupied->Vmax*0.5 ) / BrakeAccTableSize; + d = pVehicles[0]; // pojazd na czele składu + while (d) { + for( int i = 0; i < BrakeAccTableSize; ++i ) { + fBrake_a0[ i + 1 ] += d->MoverParameters->BrakeForceR( 0.25, velstep*( 1 + 2 * i ) ); + fBrake_a1[ i + 1 ] += d->MoverParameters->BrakeForceR( 1.00, velstep*( 1 + 2 * i ) ); + } + d = d->Next(); // kolejny pojazd, podłączony od tyłu (licząc od czoła) + } + for (int i = 0; i < BrakeAccTableSize; ++i) + { + fBrake_a1[i+1] -= fBrake_a0[i+1]; + fBrake_a0[i+1] /= fMass; + fBrake_a0[i + 1] += 0.001*velstep*(1 + 2 * i); + fBrake_a1[i+1] /= (12*fMass); + } + + IsCargoTrain = ( mvOccupied->CategoryFlag == 1 ) && ( ( mvOccupied->BrakeDelayFlag & bdelay_G ) != 0 ); + IsHeavyCargoTrain = ( true == IsCargoTrain ) && ( fBrake_a0[ 1 ] > 0.4 ); + + BrakingInitialLevel = ( + IsHeavyCargoTrain ? 1.25 : + IsCargoTrain ? 1.25 : + 1.00 ); + + BrakingLevelIncrease = ( + IsHeavyCargoTrain ? 0.25 : + IsCargoTrain ? 0.25 : + 0.25 ); + + if( mvOccupied->TrainType == dt_EZT ) { + fNominalAccThreshold = std::max( -0.75, -fBrake_a0[ BrakeAccTableSize ] - 8 * fBrake_a1[ BrakeAccTableSize ] ); + fBrakeReaction = 0.25; + } + else if( mvOccupied->TrainType == dt_DMU ) { + fNominalAccThreshold = std::max( -0.45, -fBrake_a0[ BrakeAccTableSize ] - 8 * fBrake_a1[ BrakeAccTableSize ] ); + fBrakeReaction = 0.25; + } + else if (ustaw > 16) { + fNominalAccThreshold = -fBrake_a0[ BrakeAccTableSize ] - 4 * fBrake_a1[ BrakeAccTableSize ]; + fBrakeReaction = 1.00 + fLength*0.004; + } + else { + fNominalAccThreshold = -fBrake_a0[ BrakeAccTableSize ] - 1 * fBrake_a1[ BrakeAccTableSize ]; + fBrakeReaction = 1.00 + fLength*0.005; + } + fAccThreshold = fNominalAccThreshold; +/* + if( IsHeavyCargoTrain ) { + // HACK: heavy cargo trains don't activate brakes early enough + fAccThreshold = std::max( -0.2, fAccThreshold ); + } +*/ +} + +double TController::ESMVelocity(bool Main) +{ + double fCurrentCoeff = 0.9; + double fFrictionCoeff = 0.85; + double ESMVel = 9999; + int MCPN = mvControlling->MainCtrlActualPos; + int SCPN = mvControlling->ScndCtrlActualPos; + if (Main) + MCPN += 1; + else + SCPN += 1; + if ((mvControlling->RList[MCPN].ScndAct < 255)&&(mvControlling->ScndCtrlActualPos==0)) + SCPN = mvControlling->RList[MCPN].ScndAct; + double FrictionMax = mvControlling->Mass*9.81*mvControlling->Adhesive(mvControlling->RunningTrack.friction)*fFrictionCoeff; + double IF = mvControlling->Imax; + double MS = 0; + double Fmax = 0; + for (int i = 0; i < 5; i++) + { + MS = mvControlling->MomentumF(IF, IF, SCPN); + Fmax = MS * mvControlling->RList[MCPN].Bn * mvControlling->RList[MCPN].Mn * 2 / mvControlling->WheelDiameter * mvControlling->Transmision.Ratio; + if( Fmax != 0.0 ) { + IF = 0.5 * IF * ( 1 + FrictionMax / Fmax ); + } + else { + // NOTE: gets trimmed to actual highest acceptable value after the loop + IF = std::numeric_limits::max(); + break; + } + } + IF = std::min(IF, mvControlling->Imax*fCurrentCoeff); + double R = mvControlling->RList[MCPN].R + mvControlling->CircuitRes + mvControlling->RList[MCPN].Mn*mvControlling->WindingRes; + double pole = mvControlling->MotorParam[SCPN].fi * + std::max(abs(IF) / (abs(IF) + mvControlling->MotorParam[SCPN].Isat) - mvControlling->MotorParam[SCPN].fi0, 0.0); + double Us = abs(mvControlling->Voltage) - IF*R; + double ns = std::max(0.0, Us / (pole*mvControlling->RList[MCPN].Mn)); + ESMVel = ns * mvControlling->WheelDiameter*M_PI*3.6/mvControlling->Transmision.Ratio; + return ESMVel; +} + +int TController::CheckDirection() { + + int d = mvOccupied->DirAbsolute; // który sprzęg jest z przodu + if( !d ) // jeśli nie ma ustalonego kierunku + d = mvOccupied->CabNo; // to jedziemy wg aktualnej kabiny + iDirection = d; // ustalenie kierunku jazdy (powinno zrobić PrepareEngine?) + return d; +} bool TController::CheckVehicles(TOrders user) { // sprawdzenie stanu posiadanych pojazdów w składzie i zapalenie świateł TDynamicObject *p; // roboczy wskaźnik na pojazd iVehicles = 0; // ilość pojazdów w składzie - int d = mvOccupied->DirAbsolute; // który sprzęg jest z przodu - if (!d) // jeśli nie ma ustalonego kierunku - d = mvOccupied->CabNo; // to jedziemy wg aktualnej kabiny - iDirection = d; // ustalenie kierunku jazdy (powinno zrobić PrepareEngine?) + int d = CheckDirection(); d = d >= 0 ? 0 : 1; // kierunek szukania czoła (numer sprzęgu) pVehicles[0] = p = pVehicle->FirstFind(d); // pojazd na czele składu // liczenie pojazdów w składzie i ustalenie parametrów @@ -1767,8 +2025,7 @@ bool TController::CheckVehicles(TOrders user) fVelMax = -1; // ustalenie prędkości dla składu bool main = true; // czy jest głównym sterującym iDrivigFlags |= moveOerlikons; // zakładamy, że są same Oerlikony - // Ra 2014-09: ustawić moveMultiControl, jeśli wszystkie są w ukrotnieniu (i skrajne mają - // kabinę?) + // Ra 2014-09: ustawić moveMultiControl, jeśli wszystkie są w ukrotnieniu (i skrajne mają kabinę?) while (p) { // sprawdzanie, czy jest głównym sterującym, żeby nie było konfliktu if (p->Mechanik) // jeśli ma obsadę @@ -1783,23 +2040,16 @@ bool TController::CheckVehicles(TOrders user) pVehicles[1] = p; // zapamiętanie ostatniego fLength += p->MoverParameters->Dim.L; // dodanie długości pojazdu fMass += p->MoverParameters->TotalMass; // dodanie masy łącznie z ładunkiem - if (fVelMax < 0 ? true : p->MoverParameters->Vmax < fVelMax) - fVelMax = p->MoverParameters->Vmax; // ustalenie maksymalnej prędkości dla składu - /* //youBy: bez przesady, to jest proteza, napelniac mozna, a nawet trzeba, ale z umiarem! - //uwzględnić jeszcze wyłączenie hamulca - if - ((p->MoverParameters->BrakeSystem!=Pneumatic)&&(p->MoverParameters->BrakeSystem!=ElectroPneumatic)) - iDrivigFlags&=~moveOerlikons; //no jednak nie - else if (p->MoverParameters->BrakeSubsystem!=Oerlikon) - iDrivigFlags&=~moveOerlikons; //wtedy też nie */ + fVelMax = min_speed( fVelMax, p->MoverParameters->Vmax ); // ustalenie maksymalnej prędkości dla składu + // reset oerlikon brakes consist flag as different type was detected + if( ( p->MoverParameters->BrakeSubsystem != TBrakeSubSystem::ss_ESt ) + && ( p->MoverParameters->BrakeSubsystem != TBrakeSubSystem::ss_LSt ) ) { + iDrivigFlags &= ~( moveOerlikons ); + } p = p->Neightbour(dir); // pojazd podłączony od wskazanej strony } if (main) iDrivigFlags |= movePrimary; // nie znaleziono innego, można się porządzić - /* //tabelka z listą pojazdów jest na razie nie potrzebna - delete[] pVehicles; - pVehicles=new TDynamicObject*[iVehicles]; - */ ControllingSet(); // ustalenie członu do sterowania (może być inny niż zasiedziany) int pantmask = 1; if (iDrivigFlags & movePrimary) @@ -1807,12 +2057,11 @@ bool TController::CheckVehicles(TOrders user) p = pVehicles[0]; while (p) { - if (TrainParams) - if (p->asDestination == "none") - p->DestinationSet(TrainParams->Relation2, TrainParams->TrainName); // relacja docelowa, jeśli nie było + if (p->asDestination == "none") + p->DestinationSet(TrainParams->Relation2, TrainParams->TrainName); // relacja docelowa, jeśli nie było if (AIControllFlag) // jeśli prowadzi komputer p->RaLightsSet(0, 0); // gasimy światła - if (p->MoverParameters->EnginePowerSource.SourceType == CurrentCollector) + if (p->MoverParameters->EnginePowerSource.SourceType == TPowerSource::CurrentCollector) { // jeśli pojazd posiada pantograf, to przydzielamy mu maskę, którą będzie informował o // jeździe bezprądowej p->iOverheadMask = pantmask; @@ -1820,35 +2069,60 @@ bool TController::CheckVehicles(TOrders user) } d = p->DirectionSet(d ? 1 : -1); // zwraca położenie następnego (1=zgodny,0=odwrócony - // względem czoła składu) - p->fScanDist = 300.0; // odległość skanowania w poszukiwaniu innych pojazdów p->ctOwner = this; // dominator oznacza swoje terytorium p = p->Next(); // pojazd podłączony od tyłu (licząc od czoła) } if (AIControllFlag) { // jeśli prowadzi komputer - if (OrderCurrentGet() == Obey_train) // jeśli jazda pociągowa - { - Lights(1 + 4 + 16, 2 + 32 + 64); //światła pociągowe (Pc1) i końcówki (Pc5) + if( true == TestFlag( OrderCurrentGet(), Obey_train ) ) { + // jeśli jazda pociągowa + // światła pociągowe (Pc1) i końcówki (Pc5) + auto const frontlights { ( + ( m_lighthints[ side::front ] != -1 ) ? + m_lighthints[ side::front ] : + light::headlight_left | light::headlight_right | light::headlight_upper ) }; + auto const rearlights { ( + ( m_lighthints[ side::rear ] != -1 ) ? + m_lighthints[ side::rear ] : + light::redmarker_left | light::redmarker_right | light::rearendsignals ) }; + Lights( + frontlights, + rearlights ); #if LOGPRESS == 0 AutoRewident(); // nastawianie hamulca do jazdy pociągowej #endif } else if (OrderCurrentGet() & (Shunt | Connect)) { - Lights(16, (pVehicles[1]->MoverParameters->CabNo) ? - 1 : - 0); //światła manewrowe (Tb1) na pojeździe z napędem - if (OrderCurrentGet() & Connect) // jeśli łączenie, skanować dalej - pVehicles[0]->fScanDist = - 5000.0; // odległość skanowania w poszukiwaniu innych pojazdów + // HACK: the 'front' and 'rear' of the consist is determined by current consist direction + // since direction shouldn't affect Tb1 light configuration, we 'counter' this behaviour by virtually swapping end vehicles + if( mvOccupied->ActiveDir > 0 ) { + Lights( + light::headlight_right, + ( pVehicles[ 1 ]->MoverParameters->CabNo != 0 ? + light::headlight_left : + 0 ) ); //światła manewrowe (Tb1) na pojeździe z napędem + } + else { + Lights( + ( pVehicles[ 1 ]->MoverParameters->CabNo != 0 ? + light::headlight_left : + 0 ), + light::headlight_right ); //światła manewrowe (Tb1) na pojeździe z napędem + } + } + else if( true == TestFlag( OrderCurrentGet(), Disconnect ) ) { + if( mvOccupied->ActiveDir > 0 ) { + // jak ma kierunek do przodu + // światła manewrowe (Tb1) tylko z przodu, aby nie pozostawić odczepionego ze światłem + Lights( light::headlight_right, 0 ); + } + else { + // jak dociska + // światła manewrowe (Tb1) tylko z przodu, aby nie pozostawić odczepionego ze światłem + Lights( 0, light::headlight_right ); + } } - else if (OrderCurrentGet() == Disconnect) - if (mvOccupied->ActiveDir > 0) // jak ma kierunek do przodu - Lights(16, 0); //światła manewrowe (Tb1) tylko z przodu, aby nie pozostawić - // odczepionego ze światłem - else // jak dociska - Lights(0, 16); //światła manewrowe (Tb1) tylko z przodu, aby nie pozostawić - // odczepionego ze światłem } else // Ra 2014-02: lepiej tu niż w pętli obsługującej komendy, bo tam się zmieni informacja // o składzie @@ -1885,12 +2159,21 @@ bool TController::CheckVehicles(TOrders user) JumpToNextOrder(); // zmianę kierunku też można olać, ale zmienić kierunek // skanowania! } + break; + default: + break; } // Ra 2014-09: tymczasowo prymitywne ustawienie warunku pod kątem SN61 - if ((mvOccupied->TrainType == dt_EZT) || (iVehicles == 1)) - iDrivigFlags |= movePushPull; // zmiana czoła przez zmianę kabiny - else - iDrivigFlags &= ~movePushPull; // zmiana czoła przez manewry + if( ( mvOccupied->TrainType == dt_EZT ) + || ( mvOccupied->TrainType == dt_DMU ) + || ( iVehicles == 1 ) ) { + // zmiana czoła przez zmianę kabiny + iDrivigFlags |= movePushPull; + } + else { + // zmiana czoła przez manewry + iDrivigFlags &= ~movePushPull; + } } // blok wykonywany, gdy aktywnie prowadzi return true; } @@ -1951,17 +2234,7 @@ void TController::WaitingSet(double Seconds) void TController::SetVelocity(double NewVel, double NewVelNext, TStopReason r) { // ustawienie nowej prędkości - WaitingTime = -WaitingExpireTime; // przypisujemy -WaitingExpireTime, a potem porównujemy z - // zerem - MaxVelFlag = false; // Ra: to nie jest używane - MinVelFlag = false; // Ra: to nie jest używane - /* nie używane - if ((NewVel>NewVelNext) //jeśli oczekiwana większa niż następna - || (NewVelVel)) //albo aktualna jest mniejsza niż aktualna - fProximityDist=-800.0; //droga hamowania do zmiany prędkości - else - fProximityDist=-300.0; //Ra: ujemne wartości są ignorowane - */ + WaitingTime = -WaitingExpireTime; // przypisujemy -WaitingExpireTime, a potem porównujemy z zerem if (NewVel == 0.0) // jeśli ma stanąć { if (r != stopNone) // a jest powód podany @@ -1974,53 +2247,37 @@ void TController::SetVelocity(double NewVel, double NewVelNext, TStopReason r) if (OrderList[OrderPos] ? OrderList[OrderPos] & (Obey_train | Shunt | Connect | Prepare_engine) : true) // jeśli jedzie w dowolnym trybie - if ((mvOccupied->Vel < - 1.0)) // jesli stoi (na razie, bo chyba powinien też, gdy hamuje przed semaforem) + if ((mvOccupied->Vel < 1.0)) // jesli stoi (na razie, bo chyba powinien też, gdy hamuje przed semaforem) if (iDrivigFlags & moveStartHorn) // jezeli trąbienie włączone - if (!(iDrivigFlags & (moveStartHornDone | moveConnect))) // jeśli nie zatrąbione - // i nie jest to moment - // podłączania składu - if (mvOccupied->CategoryFlag & 1) // tylko pociągi trąbią (unimogi tylko na - // torach, więc trzeba raczej sprawdzać - // tor) - if ((NewVel >= 1.0) || (NewVel < 0.0)) // o ile prędkość jest znacząca - { // fWarningDuration=0.3; //czas trąbienia - // if (AIControllFlag) //jak siedzi krasnoludek, to włączy trąbienie - // mvOccupied->WarningSignal=pVehicle->iHornWarning; //wysokość tonu - // (2=wysoki) - // iDrivigFlags|=moveStartHornDone; //nie trąbić aż do ruszenia - iDrivigFlags |= moveStartHornNow; // zatrąb po odhamowaniu + if (!(iDrivigFlags & (moveStartHornDone | moveConnect))) + // jeśli nie zatrąbione i nie jest to moment podłączania składu + if (mvOccupied->CategoryFlag & 1) + // tylko pociągi trąbią (unimogi tylko na torach, więc trzeba raczej sprawdzać tor) + if ((NewVel >= 1.0) || (NewVel < 0.0)) { + // o ile prędkość jest znacząca + // zatrąb po odhamowaniu + iDrivigFlags |= moveStartHornNow; } } VelSignal = NewVel; // prędkość zezwolona na aktualnym odcinku VelNext = NewVelNext; // prędkość przy następnym obiekcie } -/* //funkcja do niczego nie potrzebna (ew. do przesunięcia pojazdu o odległość NewDist) -bool TController::SetProximityVelocity(double NewDist,double NewVelNext) -{//informacja o prędkości w pewnej odległości -#if 0 - if (NewVelNext==0.0) - WaitingTime=0.0; //nie trzeba już czekać - //if ((NewVelNext>=0)&&((VelNext>=0)&&(NewVelNext fMinProximityDist ) + || ( mvOccupied->Vel > VelDesired + fVelPlus ) ) { + Factor += ( fBrakeReaction * ( mvOccupied->BrakeCtrlPosR < 0.5 ? 1.5 : 1 ) ) * mvOccupied->Vel / ( std::max( 0.0, ActualProximityDist ) + 1 ) * ( ( AccDesired - AbsAccS_pub ) / fAccThreshold ); + } + return Factor; } -*/ void TController::SetDriverPsyche() { - // double maxdist=0.5; //skalowanie dystansu od innego pojazdu, zmienic to!!! if ((Psyche == Aggressive) && (OrderList[OrderPos] == Obey_train)) { ReactionTime = HardReactionTime; // w zaleznosci od charakteru maszynisty - // if (pOccupied) if (mvOccupied->CategoryFlag & 2) { WaitingExpireTime = 1; // tyle ma czekać samochód, zanim się ruszy @@ -2052,48 +2309,6 @@ void TController::SetDriverPsyche() ReactionTime = mvControlling->InitialCtrlDelay + ReactionTime; if (mvOccupied->BrakeCtrlPos > 1) ReactionTime = 0.5 * ReactionTime; - /* - if (mvOccupied->Vel>0.1) //o ile jedziemy - {//sprawdzenie jazdy na widoczność - TCoupling - *c=pVehicles[0]->MoverParameters->Couplers+(pVehicles[0]->DirectionGet()>0?0:1); //sprzęg - z przodu składu - if (c->Connected) //a mamy coś z przodu - if (c->CouplingFlag==0) //jeśli to coś jest podłączone sprzęgiem wirtualnym - {//wyliczanie optymalnego przyspieszenia do jazdy na widoczność (Ra: na pewno tutaj?) - double k=c->Connected->Vel; //prędkość pojazdu z przodu (zakładając, że jedzie w tę - samą stronę!!!) - if (k<=mvOccupied->Vel) //porównanie modułów prędkości [km/h] - {if (pVehicles[0]->fTrackBlockfTrackBlock-0.5*fabs(mvOccupied->V)-fMaxProximityDist); - //bezpieczna odległość za poprzednim - //a=(v2*v2-v1*v1)/(25.92*(d-0.5*v1)) - //(v2*v2-v1*v1)/2 to różnica energii kinetycznych na jednostkę masy - //jeśli v2=50km/h,v1=60km/h,d=200m => k=(192.9-277.8)/(25.92*(200-0.5*16.7)=-0.0171 - [m/s^2] - //jeśli v2=50km/h,v1=60km/h,d=100m => k=(192.9-277.8)/(25.92*(100-0.5*16.7)=-0.0357 - [m/s^2] - //jeśli v2=50km/h,v1=60km/h,d=50m => k=(192.9-277.8)/(25.92*( 50-0.5*16.7)=-0.0786 - [m/s^2] - //jeśli v2=50km/h,v1=60km/h,d=25m => k=(192.9-277.8)/(25.92*( 25-0.5*16.7)=-0.1967 - [m/s^2] - if (d>0) //bo jak ujemne, to zacznie przyspieszać, aby się zderzyć - k=(k*k-mvOccupied->Vel*mvOccupied->Vel)/(25.92*d); //energia kinetyczna dzielona - przez masę i drogę daje przyspieszenie - else - k=0.0; //może lepiej nie przyspieszać -AccPreferred; //hamowanie - //WriteLog(pVehicle->asName+" "+AnsiString(k)); - } - if (dEnginePowerSource.SourceType == CurrentCollector ) -/* - || ( (mvOccupied->TrainType==dt_EZT) - && (mvControlling->GetTrainsetVoltage() > 0.0 ) ) ) // sprawdzanie, czy zasilanie jest może w innym członie -*/ - { + + if ( mvControlling->EnginePowerSource.SourceType == TPowerSource::CurrentCollector ) { voltfront = true; voltrear = true; } - // begin - // if Couplers[0].Connected<>nil) - // begin - // if Couplers[0].Connected^.PantFrontVolt or Couplers[0].Connected^.PantRearVolt) - // voltfront:=true - // else - // voltfront:=false; - // end - // else - // voltfront:=false; - // if Couplers[1].Connected<>nil) - // begin - // if Couplers[1].Connected^.PantFrontVolt or Couplers[1].Connected^.PantRearVolt) - // voltrear:=true - // else - // voltrear:=false; - // end - // else - // voltrear:=false; - // end - else - // if EnginePowerSource.SourceType<>CurrentCollector) - if (mvOccupied->TrainType != dt_EZT) - voltfront = true; // Ra 2014-06: to jest wirtualny prąd dla spalinowych??? - if (AIControllFlag) // jeśli prowadzi komputer - { // część wykonawcza dla sterowania przez komputer - mvOccupied->BatterySwitch(true); - if (mvControlling->EnginePowerSource.SourceType == CurrentCollector) + else { + if( mvOccupied->TrainType != dt_EZT ) { + // Ra 2014-06: to jest wirtualny prąd dla spalinowych??? + voltfront = true; + } + } + auto workingtemperature { true }; + if (AIControllFlag) { + // część wykonawcza dla sterowania przez komputer + mvOccupied->BatterySwitch( true ); + if( ( mvControlling->EngineType == TEngineType::DieselElectric ) + || ( mvControlling->EngineType == TEngineType::DieselEngine ) ) { + mvControlling->OilPumpSwitch( true ); + workingtemperature = UpdateHeating(); + if( true == workingtemperature ) { + mvControlling->FuelPumpSwitch( true ); + } + } + if (mvControlling->EnginePowerSource.SourceType == TPowerSource::CurrentCollector) { // jeśli silnikowy jest pantografującym - if (mvControlling->PantPress > 4.3) - { // jeżeli jest wystarczające ciśnienie w pantografach + mvOccupied->PantFront( true ); + mvOccupied->PantRear( true ); + if (mvControlling->PantPress < 4.2) { + // załączenie małej sprężarki + if( mvControlling->TrainType != dt_EZT ) { + // odłączenie zbiornika głównego, bo z nim nie da rady napompować + mvControlling->bPantKurek3 = false; + } + mvControlling->PantCompFlag = true; // załączenie sprężarki pantografów + } + else { + // jeżeli jest wystarczające ciśnienie w pantografach if ((!mvControlling->bPantKurek3) || (mvControlling->PantPress <= mvControlling->ScndPipePress)) // kurek przełączony albo główna już pompuje mvControlling->PantCompFlag = false; // sprężarkę pantografów można już wyłączyć - mvControlling->PantFront(true); - mvControlling->PantRear(true); - } - else if (mvControlling->PantPress < 4.2) //żeby nie załączał zaraz po przekroczeniu 4.0 - { // załączenie małej sprężarki - mvControlling->bPantKurek3 = - false; // odłączenie zbiornika głównego, bo z nim nie da rady napompować - mvControlling->PantCompFlag = true; // załączenie sprężarki pantografów } } - // if (mvOccupied->TrainType==dt_EZT) - //{//Ra 2014-12: po co to tutaj? - // mvControlling->PantFront(true); - // mvControlling->PantRear(true); - //} - // if (mvControlling->EngineType==DieselElectric) - // mvControlling->Battery=true; //Ra: to musi być tak? } + if (mvControlling->PantFrontVolt || mvControlling->PantRearVolt || voltfront || voltrear) { // najpierw ustalamy kierunek, jeśli nie został ustalony - if (!iDirection) // jeśli nie ma ustalonego kierunku - if (mvOccupied->V == 0) - { // ustalenie kierunku, gdy stoi + if( !iDirection ) { + // jeśli nie ma ustalonego kierunku + if( mvOccupied->Vel < 0.01 ) { // ustalenie kierunku, gdy stoi iDirection = mvOccupied->CabNo; // wg wybranej kabiny - if (!iDirection) // jeśli nie ma ustalonego kierunku - if ((mvControlling->PantFrontVolt != 0.0) || - (mvControlling->PantRearVolt != 0.0) || voltfront || voltrear) - { - if (mvOccupied->Couplers[1].CouplingFlag == - ctrain_virtual) // jeśli z tyłu nie ma nic + if( !iDirection ) { + // jeśli nie ma ustalonego kierunku + if( ( mvControlling->PantFrontVolt != 0.0 ) || ( mvControlling->PantRearVolt != 0.0 ) || voltfront || voltrear ) { + if( mvOccupied->Couplers[ 1 ].CouplingFlag == coupling::faux ) { + // jeśli z tyłu nie ma nic iDirection = -1; // jazda w kierunku sprzęgu 1 - if (mvOccupied->Couplers[0].CouplingFlag == - ctrain_virtual) // jeśli z przodu nie ma nic + } + if( mvOccupied->Couplers[ 0 ].CouplingFlag == coupling::faux ) { + // jeśli z przodu nie ma nic iDirection = 1; // jazda w kierunku sprzęgu 0 + } } + } } - else // ustalenie kierunku, gdy jedzie - if ((mvControlling->PantFrontVolt != 0.0) || (mvControlling->PantRearVolt != 0.0) || - voltfront || voltrear) - if (mvOccupied->V < 0) // jedzie do tyłu - iDirection = -1; // jazda w kierunku sprzęgu 1 - else // jak nie do tyłu, to do przodu - iDirection = 1; // jazda w kierunku sprzęgu 0 + else { + // ustalenie kierunku, gdy jedzie + if( ( mvControlling->PantFrontVolt != 0.0 ) || ( mvControlling->PantRearVolt != 0.0 ) || voltfront || voltrear ) { + if( mvOccupied->V < 0 ) { + // jedzie do tyłu + iDirection = -1; // jazda w kierunku sprzęgu 1 + } + else { + // jak nie do tyłu, to do przodu + iDirection = 1; // jazda w kierunku sprzęgu 0 + } + } + } + } if (AIControllFlag) // jeśli prowadzi komputer { // część wykonawcza dla sterowania przez komputer if (mvControlling->ConvOvldFlag) @@ -2201,38 +2407,48 @@ bool TController::PrepareEngine() ; // zerowanie napędu mvControlling->ConvOvldFlag = false; // reset nadmiarowego } - else if (!mvControlling->Mains) - { - // if TrainType=dt_SN61) - // begin - // OK:=(OrderDirectionChange(ChangeDir,Controlling)=-1); - // OK:=IncMainCtrl(1); - // end; + else if (false == mvControlling->Mains) { while (DecSpeed(true)) ; // zerowanie napędu - OK = mvControlling->MainSwitch(true); - if (mvControlling->EngineType == DieselEngine) - { // Ra 2014-06: dla SN61 trzeba wrzucić pierwszą pozycję - nie wiem, czy tutaj... - // kiedyś działało... - if (!mvControlling->MainCtrlPos) - { - if (mvControlling->RList[0].R == - 0.0) // gdy na pozycji 0 dawka paliwa jest zerowa, to zgaśnie - mvControlling->IncMainCtrl(1); // dlatego trzeba zwiększyć pozycję - if (!mvControlling->ScndCtrlPos) // jeśli bieg nie został ustawiony - if (!mvControlling->MotorParam[0].AutoSwitch) // gdy biegi ręczne - if (mvControlling->MotorParam[0].mIsat == 0.0) // bl,mIsat,fi,mfi - mvControlling->IncScndCtrl(1); // pierwszy bieg + if( mvOccupied->TrainType == dt_SN61 ) { + // specjalnie dla SN61 żeby nie zgasł + if( mvControlling->RList[ mvControlling->MainCtrlPos ].Mn == 0 ) { + mvControlling->IncMainCtrl( 1 ); } } + if( ( mvControlling->EnginePowerSource.SourceType != TPowerSource::CurrentCollector ) + || ( std::max( mvControlling->GetTrainsetVoltage(), std::abs( mvControlling->RunningTraction.TractionVoltage ) ) > mvControlling->EnginePowerSource.CollectorParameters.MinV ) ) { + mvControlling->MainSwitch( true ); + } +/* + if (mvControlling->EngineType == DieselEngine) { + // Ra 2014-06: dla SN61 trzeba wrzucić pierwszą pozycję - nie wiem, czy tutaj... + // kiedyś działało... + if (!mvControlling->MainCtrlPos) { + if( mvControlling->RList[ 0 ].R == 0.0 ) { + // gdy na pozycji 0 dawka paliwa jest zerowa, to zgaśnie dlatego trzeba zwiększyć pozycję + mvControlling->IncMainCtrl( 1 ); + } + if( ( !mvControlling->ScndCtrlPos ) // jeśli bieg nie został ustawiony + && ( !mvControlling->MotorParam[ 0 ].AutoSwitch ) // gdy biegi ręczne + && ( mvControlling->MotorParam[ 0 ].mIsat == 0.0 ) ) { // bl,mIsat,fi,mfi + // pierwszy bieg + mvControlling->IncScndCtrl( 1 ); + } + } + } +*/ } - else - { // Ra: iDirection określa, w którą stronę jedzie skład względem sprzęgów pojazdu z AI - OK = (OrderDirectionChange(iDirection, mvOccupied) == -1); + else { + OK = ( OrderDirectionChange( iDirection, mvOccupied ) == -1 ); + mvOccupied->ConverterSwitch( true ); // w EN57 sprężarka w ra jest zasilana z silnikowego - mvControlling->CompressorSwitch(true); - mvControlling->ConverterSwitch(true); - mvControlling->CompressorSwitch(true); + mvOccupied->CompressorSwitch( true ); + // enable motor blowers + mvOccupied->MotorBlowersSwitchOff( false, side::front ); + mvOccupied->MotorBlowersSwitch( true, side::front ); + mvOccupied->MotorBlowersSwitchOff( false, side::rear ); + mvOccupied->MotorBlowersSwitch( true, side::rear ); } } else @@ -2240,77 +2456,134 @@ bool TController::PrepareEngine() } else OK = false; - OK = OK && (mvOccupied->ActiveDir != 0) && (mvControlling->CompressorAllow); - if (OK) - { - if (eStopReason == stopSleep) // jeśli dotychczas spał - eStopReason = stopNone; // teraz nie ma powodu do stania + + if( ( true == OK ) + && ( mvOccupied->ActiveDir != 0 ) + && ( true == workingtemperature ) + && ( ( mvControlling->ScndPipePress > 4.5 ) || ( mvControlling->VeselVolume == 0.0 ) ) ) { + + if( eStopReason == stopSleep ) { + // jeśli dotychczas spał teraz nie ma powodu do stania + eStopReason = stopNone; + } + eAction = TAction::actUnknown; iEngineActive = 1; return true; } - else - { + else { iEngineActive = 0; return false; } }; -bool TController::ReleaseEngine() -{ // wyłączanie silnika (test wyłączenia, a część wykonawcza tylko jeśli steruje komputer) - bool OK = false; +// wyłączanie silnika (test wyłączenia, a część wykonawcza tylko jeśli steruje komputer) +bool TController::ReleaseEngine() { + + if( mvOccupied->Vel > 0.01 ) { + // TBD, TODO: make a dedicated braking procedure out of it for potential reuse + VelDesired = 0.0; + AccDesired = std::min( AccDesired, -1.25 ); // hamuj solidnie + ReactionTime = 0.1; + while( DecSpeed( true ) ) { + ; // zerowanie nastawników + } + IncBrake(); + // don't bother with the rest until we're standing still + return false; + } + LastReactionTime = 0.0; ReactionTime = PrepareTime; - if (AIControllFlag) - { // jeśli steruje komputer - if (mvOccupied->DoorOpenCtrl == 1) - { // zamykanie drzwi - if (mvOccupied->DoorLeftOpened) - mvOccupied->DoorLeft(false); - if (mvOccupied->DoorRightOpened) - mvOccupied->DoorRight(false); - } - if (mvOccupied->ActiveDir == 0) - if (mvControlling->Mains) - { - mvControlling->CompressorSwitch(false); - mvControlling->ConverterSwitch(false); - if (mvControlling->EnginePowerSource.SourceType == CurrentCollector) - { - mvControlling->PantFront(false); - mvControlling->PantRear(false); - } - OK = mvControlling->MainSwitch(false); - } - else - OK = true; + + bool OK { false }; + + if( false == AIControllFlag ) { + // tylko to testujemy dla pojazdu człowieka + OK = ( ( mvOccupied->ActiveDir == 0 ) && ( mvControlling->Mains ) ); } - else if (mvOccupied->ActiveDir == 0) - OK = mvControlling->Mains; // tylko to testujemy dla pojazdu człowieka - if (AIControllFlag) - if (!mvOccupied->DecBrakeLevel()) // tu moze zmieniać na -2, ale to bez znaczenia - if (!mvOccupied->IncLocalBrakeLevel(1)) - { - while (DecSpeed(true)) - ; // zerowanie nastawników - while (mvOccupied->ActiveDir > 0) - mvOccupied->DirectionBackward(); - while (mvOccupied->ActiveDir < 0) - mvOccupied->DirectionForward(); + else { + // jeśli steruje komputer + mvOccupied->BrakeReleaser( 0 ); + if( std::abs( fAccGravity ) < 0.01 ) { + // release train brake if on flats... + // TODO: check if we shouldn't leave it engaged instead + while( true == mvOccupied->DecBrakeLevel() ) { + // tu moze zmieniać na -2, ale to bez znaczenia + ; } - OK = OK && (mvOccupied->Vel < 0.01); - if (OK) - { // jeśli się zatrzymał + // ...and engage independent brake + while( true == mvOccupied->IncLocalBrakeLevel( 1 ) ) { + ; + } + } + else { + // on slopes engage train brake + AccDesired = std::min( AccDesired, -0.9 ); + while( true == IncBrake() ) { + ; + } + } + while( DecSpeed( true ) ) { + ; // zerowanie nastawników + } + // set direction to neutral + while( ( mvOccupied->ActiveDir > 0 ) && ( mvOccupied->DirectionBackward() ) ) { ; } + while( ( mvOccupied->ActiveDir < 0 ) && ( mvOccupied->DirectionForward() ) ) { ; } + + if( mvOccupied->DoorCloseCtrl == control_t::driver ) { + // zamykanie drzwi + if( mvOccupied->DoorLeftOpened ) { + mvOccupied->DoorLeft( false ); + } + if( mvOccupied->DoorRightOpened ) { + mvOccupied->DoorRight( false ); + } + } + + if( true == mvControlling->Mains ) { + mvControlling->CompressorSwitch( false ); + mvControlling->ConverterSwitch( false ); + // line breaker/engine + OK = mvControlling->MainSwitch( false ); + if( mvControlling->EnginePowerSource.SourceType == TPowerSource::CurrentCollector ) { + mvControlling->PantFront( false ); + mvControlling->PantRear( false ); + } + } + else { + OK = true; + } + + if( OK ) { + // finish vehicle shutdown + if( ( mvControlling->EngineType == TEngineType::DieselElectric ) + || ( mvControlling->EngineType == TEngineType::DieselEngine ) ) { + // heating/cooling subsystem + mvControlling->WaterHeaterSwitch( false ); + // optionally turn off the water pump as well + if( mvControlling->WaterPump.start_type != start_t::battery ) { + mvControlling->WaterPumpSwitch( false ); + } + // fuel and oil subsystems + mvControlling->FuelPumpSwitch( false ); + mvControlling->OilPumpSwitch( false ); + } + // gasimy światła + Lights( 0, 0 ); + mvOccupied->BatterySwitch( false ); + } + } + + if (OK) { + // jeśli się zatrzymał iEngineActive = 0; eStopReason = stopSleep; // stoimy z powodu wyłączenia - eAction = actSleep; //śpi (wygaszony) - if (AIControllFlag) - { - Lights(0, 0); // gasimy światła - mvOccupied->BatterySwitch(false); - } + eAction = TAction::actSleep; //śpi (wygaszony) + OrderNext(Wait_for_orders); //żeby nie próbował coś robić dalej - TableClear(); // zapominamy ograniczenia iDrivigFlags &= ~moveActive; // ma nie skanować sygnałów i nie reagować na komendy + TableClear(); // zapominamy ograniczenia + VelSignalLast = -1.0; } return OK; } @@ -2318,75 +2591,145 @@ bool TController::ReleaseEngine() bool TController::IncBrake() { // zwiększenie hamowania bool OK = false; - switch (mvOccupied->BrakeSystem) - { - case Individual: - if (mvOccupied->LocalBrake == ManualBrake) - OK = mvOccupied->IncManualBrakeLevel( 1 + static_cast( std::floor( 0.5 + std::fabs(AccDesired))) ); - else - OK = mvOccupied->IncLocalBrakeLevel( 1 + static_cast( std::floor( 0.5 + std::fabs(AccDesired))) ); - break; - case Pneumatic: - if ((mvOccupied->Couplers[0].Connected == NULL) && - (mvOccupied->Couplers[1].Connected == NULL)) - OK = mvOccupied->IncLocalBrakeLevel( - 1 + static_cast( std::floor( 0.5 + std::fabs(AccDesired))) ); // hamowanie lokalnym bo luzem jedzie - else - { - if (mvOccupied->BrakeCtrlPos + 1 == mvOccupied->BrakeCtrlPosNo) - { - if (AccDesired < -1.5) // hamowanie nagle - OK = mvOccupied->IncBrakeLevel(); - else - OK = false; + switch( mvOccupied->BrakeSystem ) { + case TBrakeSystem::Individual: { + if( mvOccupied->LocalBrake == TLocalBrake::ManualBrake ) { + OK = mvOccupied->IncManualBrakeLevel( 1 + static_cast( std::floor( 0.5 + std::fabs( AccDesired ) ) ) ); + } + else { + OK = mvOccupied->IncLocalBrakeLevel( std::floor( 1.5 + std::abs( AccDesired ) ) ); + } + break; + } + case TBrakeSystem::Pneumatic: { + // NOTE: can't perform just test whether connected vehicle == nullptr, due to virtual couplers formed with nearby vehicles + bool standalone { true }; + if( ( mvOccupied->TrainType == dt_ET41 ) + || ( mvOccupied->TrainType == dt_ET42 ) ) { + // NOTE: we're doing simplified checks full of presuptions here. + // they'll break if someone does strange thing like turning around the second unit + if( ( mvOccupied->Couplers[ 1 ].CouplingFlag & coupling::permanent ) + && ( mvOccupied->Couplers[ 1 ].Connected->Couplers[ 1 ].CouplingFlag > 0 ) ) { + standalone = false; + } + if( ( mvOccupied->Couplers[ 0 ].CouplingFlag & coupling::permanent ) + && ( mvOccupied->Couplers[ 0 ].Connected->Couplers[ 0 ].CouplingFlag > 0 ) ) { + standalone = false; + } + } + else if( mvOccupied->TrainType == dt_DMU ) { + // enforce use of train brake for DMUs + standalone = false; + } + else { +/* + standalone = + ( ( mvOccupied->Couplers[ 0 ].CouplingFlag == 0 ) + && ( mvOccupied->Couplers[ 1 ].CouplingFlag == 0 ) ); +*/ + if( pVehicles[ 0 ] != pVehicles[ 1 ] ) { + // more detailed version, will use manual braking also for coupled sets of controlled vehicles + auto *vehicle = pVehicles[ 0 ]; // start from first + while( ( true == standalone ) + && ( vehicle != nullptr ) ) { + // NOTE: we could simplify this by doing only check of the rear coupler, but this can be quite tricky in itself + // TODO: add easier ways to access front/rear coupler taking into account vehicle's direction + standalone = + ( ( ( vehicle->MoverParameters->Couplers[ 0 ].CouplingFlag == 0 ) || ( vehicle->MoverParameters->Couplers[ 0 ].CouplingFlag & coupling::control ) ) + && ( ( vehicle->MoverParameters->Couplers[ 1 ].CouplingFlag == 0 ) || ( vehicle->MoverParameters->Couplers[ 1 ].CouplingFlag & coupling::control ) ) ); + vehicle = vehicle->Next(); // kolejny pojazd, podłączony od tyłu (licząc od czoła) + } + } + } + if( true == standalone ) { + OK = mvOccupied->IncLocalBrakeLevel( + 1 + static_cast( std::floor( 0.5 + std::fabs( AccDesired ) ) ) ); // hamowanie lokalnym bo luzem jedzie + } + else { + if( mvOccupied->BrakeCtrlPos + 1 == mvOccupied->BrakeCtrlPosNo ) { + if (AccDesired < -1.5) // hamowanie nagle + OK = mvOccupied->BrakeLevelAdd(1.0); + else + OK = false; + } + else { + // dodane dla towarowego + float pos_corr = 0; + + TDynamicObject *d; + d = pVehicles[0]; // pojazd na czele składu + while (d) + { // przeliczanie dodatkowego potrzebnego spadku ciśnienia + if( ( d->MoverParameters->Hamulec->GetBrakeStatus() & b_dmg ) == 0 ) { + pos_corr += ( d->MoverParameters->Hamulec->GetCRP() - 5.0 ) * d->MoverParameters->TotalMass; + } + d = d->Next(); // kolejny pojazd, podłączony od tyłu (licząc od czoła) + } + pos_corr = pos_corr / fMass * 2.5; + + if (mvOccupied->BrakeHandle == TBrakeHandle::FV4a) + { + pos_corr += mvOccupied->Handle->GetCP()*0.2; + + } + double deltaAcc = -AccDesired*BrakeAccFactor() - (fBrake_a0[0] + 4.0 * (mvOccupied->BrakeCtrlPosR - 1 - pos_corr)*fBrake_a1[0]); + + if( deltaAcc > fBrake_a1[0]) + { + if( mvOccupied->BrakeCtrlPosR < 0.1 ) { + OK = mvOccupied->BrakeLevelAdd( BrakingInitialLevel ); +/* + // HACK: stronger braking to overcome SA134 engine behaviour + if( ( mvOccupied->TrainType == dt_DMU ) + && ( VelNext == 0.0 ) + && ( fBrakeDist < 200.0 ) ) { + mvOccupied->BrakeLevelAdd( + fBrakeDist / ActualProximityDist < 0.8 ? + 1.0 : + 3.0 ); + } +*/ + } + else + { + OK = mvOccupied->BrakeLevelAdd( BrakingLevelIncrease ); + // brake harder if the acceleration is much higher than desired + if( ( deltaAcc > 2 * fBrake_a1[ 0 ] ) + && ( mvOccupied->BrakeCtrlPosR + BrakingLevelIncrease <= 5.0 ) ) { + mvOccupied->BrakeLevelAdd( BrakingLevelIncrease ); + } + } + } + else + OK = false; + } + } + if( mvOccupied->BrakeCtrlPos > 0 ) { + mvOccupied->BrakeReleaser( 0 ); + } + break; + } + case TBrakeSystem::ElectroPneumatic: { + if( mvOccupied->EngineType == TEngineType::ElectricInductionMotor ) { + if (mvOccupied->BrakeHandle == TBrakeHandle::MHZ_EN57) { + if (mvOccupied->BrakeCtrlPos < mvOccupied->Handle->GetPos(bh_FB)) + OK = mvOccupied->BrakeLevelAdd(1.0); + } + else { + OK = mvOccupied->IncLocalBrakeLevel(1); + } + } + else if( mvOccupied->fBrakeCtrlPos != mvOccupied->Handle->GetPos( bh_EPB ) ) { + mvOccupied->BrakeLevelSet( mvOccupied->Handle->GetPos( bh_EPB ) ); + if( mvOccupied->Handle->GetPos( bh_EPR ) - mvOccupied->Handle->GetPos( bh_EPN ) < 0.1 ) + mvOccupied->SwitchEPBrake( 1 ); // to nie chce działać + OK = true; } else - { - /* - if (AccDesired>-0.2) and ((Vel<20) or (Vel-VelNext<10))) - begin - if BrakeCtrlPos>0) - OK:=IncBrakeLevel - else; - OK:=IncLocalBrakeLevel(1); //finezyjne hamowanie lokalnym - end - else - */ - // dodane dla towarowego - if (mvOccupied->BrakeDelayFlag == bdelay_G ? - -AccDesired * 6.6 > std::min(2, mvOccupied->BrakeCtrlPos) : - true) - { - OK = mvOccupied->IncBrakeLevel(); - } - else - OK = false; - } + OK = false; + break; } - if (mvOccupied->BrakeCtrlPos > 0) - mvOccupied->BrakeReleaser(0); - break; - case ElectroPneumatic: - if (mvOccupied->EngineType == ElectricInductionMotor) - { - OK = mvOccupied->IncLocalBrakeLevel(1); - } - else if (mvOccupied->fBrakeCtrlPos != mvOccupied->Handle->GetPos(bh_EPB)) - { - mvOccupied->BrakeLevelSet(mvOccupied->Handle->GetPos(bh_EPB)); - if (mvOccupied->Handle->GetPos(bh_EPR) - mvOccupied->Handle->GetPos(bh_EPN) < 0.1) - mvOccupied->SwitchEPBrake(1); // to nie chce działać - OK = true; - } - else - OK = false; - // if (mvOccupied->BrakeCtrlPosBrakeCtrlPosNo) - // if - // (mvOccupied->BrakePressureTable[mvOccupied->BrakeCtrlPos+1+2].BrakeType==ElectroPneumatic) - // //+2 to indeks Pascala - // OK=mvOccupied->IncBrakeLevel(); - // else - // OK=false; + default: { break; } } return OK; } @@ -2394,27 +2737,43 @@ bool TController::IncBrake() bool TController::DecBrake() { // zmniejszenie siły hamowania bool OK = false; + double deltaAcc = 0; switch (mvOccupied->BrakeSystem) { - case Individual: - if (mvOccupied->LocalBrake == ManualBrake) + case TBrakeSystem::Individual: + if (mvOccupied->LocalBrake == TLocalBrake::ManualBrake) OK = mvOccupied->DecManualBrakeLevel(1 + floor(0.5 + fabs(AccDesired))); else OK = mvOccupied->DecLocalBrakeLevel(1 + floor(0.5 + fabs(AccDesired))); break; - case Pneumatic: - if (mvOccupied->BrakeCtrlPos > 0) - OK = mvOccupied->DecBrakeLevel(); + case TBrakeSystem::Pneumatic: + deltaAcc = -AccDesired*BrakeAccFactor() - (fBrake_a0[0] + 4 * (mvOccupied->BrakeCtrlPosR-1.0)*fBrake_a1[0]); + if (deltaAcc < 0) + { + if (mvOccupied->BrakeCtrlPosR > 0) + { + OK = mvOccupied->BrakeLevelAdd(-0.25); + //if ((deltaAcc < 5 * fBrake_a1[0]) && (mvOccupied->BrakeCtrlPosR >= 1.2)) + // mvOccupied->BrakeLevelAdd(-1.0); + if (mvOccupied->BrakeCtrlPosR < 0.74) + mvOccupied->BrakeLevelSet(0.0); + } + } if (!OK) OK = mvOccupied->DecLocalBrakeLevel(2); if (mvOccupied->PipePress < 3.0) Need_BrakeRelease = true; break; - case ElectroPneumatic: - if (mvOccupied->EngineType == ElectricInductionMotor) - { - OK = mvOccupied->DecLocalBrakeLevel(1); - } + case TBrakeSystem::ElectroPneumatic: + if (mvOccupied->EngineType == TEngineType::ElectricInductionMotor) { + if (mvOccupied->BrakeHandle == TBrakeHandle::MHZ_EN57) { + if (mvOccupied->BrakeCtrlPos > mvOccupied->Handle->GetPos(bh_RP)) + OK = mvOccupied->BrakeLevelAdd(-1.0); + } + else { + OK = mvOccupied->DecLocalBrakeLevel(1); + } + } else if (mvOccupied->fBrakeCtrlPos != mvOccupied->Handle->GetPos(bh_EPR)) { mvOccupied->BrakeLevelSet(mvOccupied->Handle->GetPos(bh_EPR)); @@ -2433,25 +2792,34 @@ bool TController::DecBrake() bool TController::IncSpeed() { // zwiększenie prędkości; zwraca false, jeśli dalej się nie da zwiększać - if (tsGuardSignal) // jeśli jest dźwięk kierownika - if (tsGuardSignal->GetStatus() & DSBSTATUS_PLAYING) // jeśli gada, to nie jedziemy - return false; - bool OK = true; - if ((iDrivigFlags & moveDoorOpened) - &&(mvOccupied->Vel > 0.1)) // added velocity threshold to prevent door shuffle on stop - Doors(false); // zamykanie drzwi - tutaj wykonuje tylko AI (zmienia fActionTime) - if (fActionTime < 0.0) // gdy jest nakaz poczekać z jazdą, to nie ruszać + if( true == tsGuardSignal.is_playing() ) { + // jeśli gada, to nie jedziemy return false; + } + bool OK = true; + if( ( iDrivigFlags & moveDoorOpened ) + && ( VelDesired > 0.0 ) ) { // to prevent door shuffle on stop + // zamykanie drzwi - tutaj wykonuje tylko AI (zmienia fActionTime) + Doors( false ); + } + if( fActionTime < 0.0 ) { + // gdy jest nakaz poczekać z jazdą, to nie ruszać + return false; + } + if( true == mvOccupied->DepartureSignal ) { + // shut off departure warning + mvOccupied->signal_departure( false ); + } if (mvControlling->SlippingWheels) return false; // jak poślizg, to nie przyspieszamy switch (mvOccupied->EngineType) { - case None: // McZapkie-041003: wagon sterowniczy + case TEngineType::None: // McZapkie-041003: wagon sterowniczy if (mvControlling->MainCtrlPosNo > 0) // jeśli ma czym kręcić iDrivigFlags |= moveIncSpeed; // ustawienie flagi jazdy return false; - case ElectricSeriesMotor: - if (mvControlling->EnginePowerSource.SourceType == CurrentCollector) // jeśli pantografujący + case TEngineType::ElectricSeriesMotor: + if (mvControlling->EnginePowerSource.SourceType == TPowerSource::CurrentCollector) // jeśli pantografujący { if (fOverhead2 >= 0.0) // a jazda bezprądowa ustawiana eventami (albo opuszczenie) return false; // to nici z ruszania @@ -2461,57 +2829,86 @@ bool TController::IncSpeed() if (!mvControlling->FuseFlag) //&&mvControlling->StLinFlag) //yBARC if ((mvControlling->MainCtrlPos == 0) || (mvControlling->StLinFlag)) // youBy polecił dodać 2012-09-08 v367 - // na pozycji 0 przejdzie, a na pozostałych będzie czekać, aż się załączą liniowe - // (zgaśnie DelayCtrlFlag) - if (Ready || (iDrivigFlags & movePress)) - if (fabs(mvControlling->Im) < - (fReady < 0.4 ? mvControlling->Imin : mvControlling->IminLo)) - { // Ra: wywalał nadmiarowy, bo Im może być ujemne; jak nie odhamowany, to nie - // przesadzać z prądem - if ((mvOccupied->Vel <= 30) || - (mvControlling->Imax > mvControlling->ImaxLo) || - (fVoltage + fVoltage < - mvControlling->EnginePowerSource.CollectorParameters.MinV + - mvControlling->EnginePowerSource.CollectorParameters.MaxV)) - { // bocznik na szeregowej przy ciezkich bruttach albo przy wysokim rozruchu - // pod górę albo przy niskim napięciu - if (mvControlling->MainCtrlPos ? - mvControlling->RList[mvControlling->MainCtrlPos].R > 0.0 : - true) // oporowa - { - OK = (mvControlling->DelayCtrlFlag ? - true : - mvControlling->IncMainCtrl(1)); // kręcimy nastawnik jazdy - if ((OK) && - (mvControlling->MainCtrlPos == - 1)) // czekaj na 1 pozycji, zanim się nie włączą liniowe - iDrivigFlags |= moveIncSpeed; - else - iDrivigFlags &= ~moveIncSpeed; // usunięcie flagi czekania - } - else // jeśli bezoporowa (z wyjątekiem 0) - OK = false; // to dać bocznik - } - else - { // przekroczone 30km/h, można wejść na jazdę równoległą - if (mvControlling->ScndCtrlPos) // jeśli ustawiony bocznik - if (mvControlling->MainCtrlPos < - mvControlling->MainCtrlPosNo - 1) // a nie jest ostatnia pozycja - mvControlling->DecScndCtrl(2); // to bocznik na zero po chamsku - // (ktoś miał to poprawić...) - OK = mvControlling->IncMainCtrl(1); - } - if ((mvControlling->MainCtrlPos > 2) && - (mvControlling->Im == 0)) // brak prądu na dalszych pozycjach - Need_TryAgain = true; // nie załączona lokomotywa albo wywalił - // nadmiarowy - else if (!OK) // nie da się wrzucić kolejnej pozycji - OK = mvControlling->IncScndCtrl(1); // to dać bocznik + // na pozycji 0 przejdzie, a na pozostałych będzie czekać, aż się załączą liniowe (zgaśnie DelayCtrlFlag) + if (Ready || (iDrivigFlags & movePress)) { + // use series mode: + // if high threshold is set for motor overload relay, + // if the power station is heavily burdened, + // if it generates enough traction force + // to build up speed to 30/40 km/h for passenger/cargo train (10 km/h less if going uphill) + auto const sufficienttractionforce { std::abs( mvControlling->Ft ) > ( IsHeavyCargoTrain ? 125 : 100 ) * 1000.0 }; + auto const seriesmodefieldshunting { ( mvControlling->ScndCtrlPos > 0 ) && ( mvControlling->RList[ mvControlling->MainCtrlPos ].Bn == 1 ) }; + auto const parallelmodefieldshunting { ( mvControlling->ScndCtrlPos > 0 ) && ( mvControlling->RList[ mvControlling->MainCtrlPos ].Bn > 1 ) }; + auto const useseriesmodevoltage { 0.80 * mvControlling->EnginePowerSource.CollectorParameters.MaxV }; + auto const useseriesmode = ( + ( mvControlling->Imax > mvControlling->ImaxLo ) + || ( fVoltage < useseriesmodevoltage ) + || ( ( true == sufficienttractionforce ) + && ( mvOccupied->Vel <= ( IsCargoTrain ? 35 : 25 ) + ( seriesmodefieldshunting ? 5 : 0 ) - ( ( fAccGravity < -0.025 ) ? 10 : 0 ) ) ) ); + // when not in series mode use the first available parallel mode configuration until 50/60 km/h for passenger/cargo train + // (if there's only one parallel mode configuration it'll be used regardless of current speed) + auto const usefieldshunting = ( + ( mvControlling->StLinFlag ) + && ( mvControlling->RList[ mvControlling->MainCtrlPos ].R < 0.01 ) + && ( useseriesmode ? + mvControlling->RList[ mvControlling->MainCtrlPos ].Bn == 1 : + ( ( true == sufficienttractionforce ) + && ( mvOccupied->Vel <= ( IsCargoTrain ? 55 : 45 ) + ( parallelmodefieldshunting ? 5 : 0 ) ) ? + mvControlling->RList[ mvControlling->MainCtrlPos ].Bn > 1 : + mvControlling->MainCtrlPos == mvControlling->MainCtrlPosNo ) ) ); + + double Vs = 99999; + if( usefieldshunting ? + ( mvControlling->ScndCtrlPos < mvControlling->ScndCtrlPosNo ) : + ( mvControlling->MainCtrlPos < mvControlling->MainCtrlPosNo ) ) { + Vs = ESMVelocity( !usefieldshunting ); } + + if( ( std::abs( mvControlling->Im ) < ( fReady < 0.4 ? mvControlling->Imin : mvControlling->IminLo ) ) + || ( mvControlling->Vel > Vs ) ) { + // Ra: wywalał nadmiarowy, bo Im może być ujemne; jak nie odhamowany, to nie przesadzać z prądem + if( usefieldshunting ) { + // to dać bocznik + // engage the shuntfield only if there's sufficient power margin to draw from + OK = ( + fVoltage > useseriesmodevoltage + 0.0125 * mvControlling->EnginePowerSource.CollectorParameters.MaxV ? + mvControlling->IncScndCtrl( 1 ) : + false ); + } + else { + // jeśli ustawiony bocznik to bocznik na zero po chamsku + if( mvControlling->ScndCtrlPos ) { + mvControlling->DecScndCtrl( 2 ); + } + // kręcimy nastawnik jazdy + OK = ( + mvControlling->DelayCtrlFlag ? + true : + mvControlling->IncMainCtrl( 1 ) ); + // czekaj na 1 pozycji, zanim się nie włączą liniowe + if( true == mvControlling->StLinFlag ) { + iDrivigFlags |= moveIncSpeed; + } + else { + iDrivigFlags &= ~moveIncSpeed; + } + + if( ( mvControlling->Im == 0 ) + && ( mvControlling->MainCtrlPos > 2 ) ) { + // brak prądu na dalszych pozycjach + // nie załączona lokomotywa albo wywalił nadmiarowy + Need_TryAgain = true; + } + } + } + else { + OK = false; + } + } mvControlling->AutoRelayCheck(); // sprawdzenie logiki sterowania break; - case Dumb: - case DieselElectric: + case TEngineType::Dumb: + case TEngineType::DieselElectric: if (!mvControlling->FuseFlag) if (Ready || (iDrivigFlags & movePress)) //{(BrakePress<=0.01*MaxBrakePress)} { @@ -2520,14 +2917,20 @@ bool TController::IncSpeed() OK = mvControlling->IncScndCtrl(1); } break; - case ElectricInductionMotor: + case TEngineType::ElectricInductionMotor: if (!mvControlling->FuseFlag) if (Ready || (iDrivigFlags & movePress) || (mvOccupied->ShuntMode)) //{(BrakePress<=0.01*MaxBrakePress)} { - OK = mvControlling->IncMainCtrl(1); + OK = mvControlling->IncMainCtrl(std::max(1,mvOccupied->MainCtrlPosNo/10)); + // cruise control + auto const SpeedCntrlVel { ( + ( ActualProximityDist > std::max( 50.0, fMaxProximityDist ) ) ? + VelDesired : + min_speed( VelDesired, VelNext ) ) }; + SpeedCntrl(SpeedCntrlVel); } break; - case WheelsDriven: + case TEngineType::WheelsDriven: if (!mvControlling->CabNo) mvControlling->CabActivisation(); if (sin(mvControlling->eAngle) > 0) @@ -2535,22 +2938,24 @@ bool TController::IncSpeed() else mvControlling->DecMainCtrl(3 + 3 * floor(0.5 + fabs(AccDesired))); break; - case DieselEngine: + case TEngineType::DieselEngine: if (mvControlling->ShuntModeAllow) - { // dla 2Ls150 można zmienić tryb pracy, jeśli jest w liniowym i nie daje rady (wymaga - // zerowania kierunku) + { // dla 2Ls150 można zmienić tryb pracy, jeśli jest w liniowym i nie daje rady (wymaga zerowania kierunku) // mvControlling->ShuntMode=(OrderList[OrderPos]&Shunt)||(fMass>224000.0); } - if ((mvControlling->Vel > mvControlling->dizel_minVelfullengage) && - (mvControlling->RList[mvControlling->MainCtrlPos].Mn > 0)) - OK = mvControlling->IncMainCtrl(1); - if (mvControlling->RList[mvControlling->MainCtrlPos].Mn == 0) - OK = mvControlling->IncMainCtrl(1); - if (!mvControlling->Mains) - { - mvControlling->MainSwitch(true); - mvControlling->ConverterSwitch(true); - mvControlling->CompressorSwitch(true); + if( true == Ready ) { + if( ( mvControlling->Vel > mvControlling->dizel_minVelfullengage ) + && ( mvControlling->RList[ mvControlling->MainCtrlPos ].Mn > 0 ) ) { + OK = mvControlling->IncMainCtrl( 1 ); + } + if( mvControlling->RList[ mvControlling->MainCtrlPos ].Mn == 0 ) { + OK = mvControlling->IncMainCtrl( 1 ); + } + } + if( false == mvControlling->Mains ) { + mvControlling->MainSwitch( true ); + mvControlling->ConverterSwitch( true ); + mvControlling->CompressorSwitch( true ); } break; } @@ -2562,27 +2967,29 @@ bool TController::DecSpeed(bool force) bool OK = false; // domyślnie false, aby wyszło z pętli while switch (mvOccupied->EngineType) { - case None: // McZapkie-041003: wagon sterowniczy + case TEngineType::None: // McZapkie-041003: wagon sterowniczy iDrivigFlags &= ~moveIncSpeed; // usunięcie flagi jazdy if (force) // przy aktywacji kabiny jest potrzeba natychmiastowego wyzerowania if (mvControlling->MainCtrlPosNo > 0) // McZapkie-041003: wagon sterowniczy, np. EZT mvControlling->DecMainCtrl(1 + (mvControlling->MainCtrlPos > 2 ? 1 : 0)); mvControlling->AutoRelayCheck(); // sprawdzenie logiki sterowania return false; - case ElectricSeriesMotor: + case TEngineType::ElectricSeriesMotor: OK = mvControlling->DecScndCtrl(2); // najpierw bocznik na zero if (!OK) OK = mvControlling->DecMainCtrl(1 + (mvControlling->MainCtrlPos > 2 ? 1 : 0)); mvControlling->AutoRelayCheck(); // sprawdzenie logiki sterowania break; - case Dumb: - case DieselElectric: - case ElectricInductionMotor: + case TEngineType::Dumb: + case TEngineType::DieselElectric: OK = mvControlling->DecScndCtrl(2); if (!OK) OK = mvControlling->DecMainCtrl(2 + (mvControlling->MainCtrlPos / 2)); break; - case WheelsDriven: + case TEngineType::ElectricInductionMotor: + OK = mvControlling->DecMainCtrl(1); + break; + case TEngineType::WheelsDriven: if (!mvControlling->CabNo) mvControlling->CabActivisation(); if (sin(mvControlling->eAngle) < 0) @@ -2590,7 +2997,7 @@ bool TController::DecSpeed(bool force) else mvControlling->DecMainCtrl(3 + 3 * floor(0.5 + fabs(AccDesired))); break; - case DieselEngine: + case TEngineType::DieselEngine: if ((mvControlling->Vel > mvControlling->dizel_minVelfullengage)) { if (mvControlling->RList[mvControlling->MainCtrlPos].Mn > 0) @@ -2612,9 +3019,7 @@ void TController::SpeedSet() // ma dokręcać do bezoporowych i zdejmować pozycje w przypadku przekroczenia prądu switch (mvOccupied->EngineType) { - case None: // McZapkie-041003: wagon sterowniczy - if (fActionTime >= -1.0) - mvOccupied->DepartureSignal = false; // trochę niech pobuczy, zanim pojedzie + case TEngineType::None: // McZapkie-041003: wagon sterowniczy if (mvControlling->MainCtrlPosNo > 0) { // jeśli ma czym kręcić // TODO: sprawdzanie innego czlonu //if (!FuseFlagCheck()) @@ -2631,10 +3036,8 @@ void TController::SpeedSet() mvOccupied->DirectionForward(); //żeby EN57 jechały na drugiej nastawie { if (mvControlling->MainCtrlPos && - !mvControlling - ->StLinFlag) // jak niby jedzie, ale ma rozłączone liniowe - mvControlling->DecMainCtrl( - 2); // to na zero i czekać na przewalenie kułakowego + !mvControlling->StLinFlag) // jak niby jedzie, ale ma rozłączone liniowe + mvControlling->DecMainCtrl(2); // to na zero i czekać na przewalenie kułakowego else switch (mvControlling->MainCtrlPos) { // ruch nastawnika uzależniony jest od aktualnie ustawionej @@ -2679,33 +3082,25 @@ void TController::SpeedSet() } } break; - case ElectricSeriesMotor: + case TEngineType::ElectricSeriesMotor: if( ( false == mvControlling->StLinFlag ) - && ( false == mvControlling->DelayCtrlFlag ) - && ( 0 == ( iDrivigFlags & moveIncSpeed ) ) ) // styczniki liniowe rozłączone yBARC - { - // if (iDrivigFlags&moveIncSpeed) {} //jeśli czeka na załączenie liniowych - // else + && ( false == mvControlling->DelayCtrlFlag ) ) { + // styczniki liniowe rozłączone yBARC while( DecSpeed() ) ; // zerowanie napędu } else if (Ready || (iDrivigFlags & movePress)) // o ile może jechać if (fAccGravity < -0.10) // i jedzie pod górę większą niż 10 promil { // procedura wjeżdżania na ekstremalne wzniesienia - if (fabs(mvControlling->Im) > - 0.85 * mvControlling->Imax) // a prąd jest większy niż 85% nadmiarowego - // if (mvControlling->Imin*mvControlling->Voltage/(fMass*fAccGravity)<-2.8) //a - // na niskim się za szybko nie pojedzie - if (mvControlling->Imax * mvControlling->Voltage / (fMass * fAccGravity) < - -2.8) // a na niskim się za szybko nie pojedzie + if (fabs(mvControlling->Im) > 0.85 * mvControlling->Imax) // a prąd jest większy niż 85% nadmiarowego + if (mvControlling->Imax * mvControlling->Voltage / (fMass * fAccGravity) < -2.8) // a na niskim się za szybko nie pojedzie { // włączenie wysokiego rozruchu; // (I*U)[A*V=W=kg*m*m/sss]/(m[kg]*a[m/ss])=v[m/s]; 2.8m/ss=10km/h if (mvControlling->RList[mvControlling->MainCtrlPos].Bn > 1) { // jeśli jedzie na równoległym, to zbijamy do szeregowego, aby włączyć // wysoki rozruch if (mvControlling->ScndCtrlPos > 0) // jeżeli jest bocznik - mvControlling->DecScndCtrl( - 2); // wyłączyć bocznik, bo może blokować skręcenie NJ + mvControlling->DecScndCtrl(2); // wyłączyć bocznik, bo może blokować skręcenie NJ do // skręcanie do bezoporowej na szeregowym mvControlling->DecMainCtrl(1); // kręcimy nastawnik jazdy o 1 wstecz while (mvControlling->MainCtrlPos ? @@ -2713,13 +3108,22 @@ void TController::SpeedSet() false); // oporowa zapętla } if (mvControlling->Imax < mvControlling->ImaxHi) // jeśli da się na wysokim - mvControlling->CurrentSwitch( - true); // rozruch wysoki (za to może się ślizgać) + mvControlling->CurrentSwitch(true); // rozruch wysoki (za to może się ślizgać) if (ReactionTime > 0.1) ReactionTime = 0.1; // orientuj się szybciej } // if (Im>Imin) - if (fabs(mvControlling->Im) > 0.75 * mvControlling->ImaxHi) // jeśli prąd jest duży - mvControlling->SandDoseOn(); // piaskujemy tory, coby się nie ślizgać + // NOTE: this step is likely to conflict with directive to operate sandbox based on the state of slipping wheels + // TODO: gather all sandbox operating logic in one place + if( fabs( mvControlling->Im ) > 0.75 * mvControlling->ImaxHi ) { + // jeśli prąd jest duży + mvControlling->Sandbox( true ); // piaskujemy tory, coby się nie ślizgać + } + else { + // otherwise we switch the sander off, if it's active + if( mvControlling->SandDose ) { + mvControlling->Sandbox( false ); + } + } if ((fabs(mvControlling->Im) > 0.96 * mvControlling->Imax) || mvControlling->SlippingWheels) // jeśli prąd jest duży (można 690 na 750) if (mvControlling->ScndCtrlPos > 0) // jeżeli jest bocznik @@ -2733,24 +3137,13 @@ void TController::SpeedSet() if (mvOccupied->Vel >= 30.0) // jak się rozpędził if (fAccGravity > -0.02) // a i pochylenie mnijsze niż 2‰ mvControlling->CurrentSwitch(false); // rozruch wysoki wyłącz - // dokręcanie do bezoporowej, bo IncSpeed() może nie być wywoływane - // if (mvOccupied->Vel-0.1) //nie ma hamować - // if (Controlling->RList[MainCtrlPos].R>0.0) - // if (Im<1.3*Imin) //lekkie przekroczenie miimalnego prądu jest dopuszczalne - // IncMainCtrl(1); //zwieksz nastawnik skoro możesz - tak aby się ustawic na - // bezoporowej } break; - case Dumb: - case DieselElectric: - case ElectricInductionMotor: + case TEngineType::Dumb: + case TEngineType::DieselElectric: + case TEngineType::ElectricInductionMotor: break; - // WheelsDriven : - // begin - // OK:=False; - // end; - case DieselEngine: + case TEngineType::DieselEngine: // Ra 2014-06: "automatyczna" skrzynia biegów... if (!mvControlling->MotorParam[mvControlling->ScndCtrlPos].AutoSwitch) // gdy biegi ręczne if ((mvControlling->ShuntMode ? mvControlling->AnPos : 1.0) * mvControlling->Vel > @@ -2780,43 +3173,110 @@ void TController::SpeedSet() } }; -void TController::Doors(bool what) -{ // otwieranie/zamykanie drzwi w składzie albo (tylko AI) EZT - if (what) - { // otwarcie - } - else - { // zamykanie - if (mvOccupied->DoorOpenCtrl == 1) - { // jeśli drzwi sterowane z kabiny - if (AIControllFlag) - if (mvOccupied->DoorLeftOpened || mvOccupied->DoorRightOpened) - { // AI zamyka drzwi przed odjazdem - if (mvOccupied->DoorClosureWarning) - mvOccupied->DepartureSignal = true; // załącenie bzyczka - mvOccupied->DoorLeft(false); // zamykanie drzwi - mvOccupied->DoorRight(false); - // Ra: trzeba by ustawić jakiś czas oczekiwania na zamknięcie się drzwi - fActionTime = -1.5 - 0.1 * Random(10); // czekanie sekundę, może trochę dłużej - iDrivigFlags &= ~moveDoorOpened; // nie wykonywać drugi raz - } - } - else - { // jeśli nie, to zamykanie w składzie wagonowym - TDynamicObject *p = pVehicles[0]; // pojazd na czole składu - while (p) - { // zamykanie drzwi w pojazdach - flaga zezwolenia była by lepsza - p->MoverParameters->DoorLeft(false); // w lokomotywie można by nie zamykać... - p->MoverParameters->DoorRight(false); - p = p->Next(); // pojazd podłączony z tyłu (patrząc od czoła) - } - // WaitingSet(5); //10 sekund tu to za długo, opóźnia odjazd o pół minuty - fActionTime = -1.5 - 0.1 * Random(10); // czekanie sekundę, może trochę dłużej - iDrivigFlags &= ~moveDoorOpened; // zostały zamknięte - nie wykonywać drugi raz - } - } +void TController::SpeedCntrl(double DesiredSpeed) +{ + if (mvControlling->ScndCtrlPosNo == 1) + { + mvControlling->IncScndCtrl(1); + mvControlling->RunCommand("SpeedCntrl", DesiredSpeed, mvControlling->CabNo); + } + else if (mvControlling->ScndCtrlPosNo > 1) + { + int DesiredPos = 1 + mvControlling->ScndCtrlPosNo * ((DesiredSpeed - 1.0) / mvControlling->Vmax); + while (mvControlling->ScndCtrlPos > DesiredPos) mvControlling->DecScndCtrl(1); + while (mvControlling->ScndCtrlPos < DesiredPos) mvControlling->IncScndCtrl(1); + } }; +// otwieranie/zamykanie drzwi w składzie albo (tylko AI) EZT +void TController::Doors( bool const Open, int const Side ) { + + if( true == Open ) { + // otwieranie drzwi + // otwieranie drzwi w składach wagonowych - docelowo wysyłać komendę zezwolenia na otwarcie drzwi + // tu będzie jeszcze długość peronu zaokrąglona do 10m (20m bezpieczniej, bo nie modyfikuje bitu 1) + auto *vehicle = pVehicles[0]; // pojazd na czole składu + while( vehicle != nullptr ) { + // wagony muszą mieć baterię załączoną do otwarcia drzwi... + vehicle->MoverParameters->BatterySwitch( true ); + // otwieranie drzwi w pojazdach - flaga zezwolenia była by lepsza + if( vehicle->MoverParameters->DoorOpenCtrl != control_t::passenger ) { + // if the door are controlled by the driver, we let the user operate them... + if( true == AIControllFlag ) { + // ...unless this user is an ai + // Side=platform side (1:left, 2:right, 3:both) + // jeśli jedzie do tyłu, to drzwi otwiera odwrotnie + auto const lewe = ( vehicle->DirectionGet() > 0 ) ? 1 : 2; + auto const prawe = 3 - lewe; + if( Side & lewe ) + vehicle->MoverParameters->DoorLeft( true, range_t::local ); + if( Side & prawe ) + vehicle->MoverParameters->DoorRight( true, range_t::local ); + } + } + // pojazd podłączony z tyłu (patrząc od czoła) + vehicle = vehicle->Next(); + } + } + else { + // zamykanie + if( false == doors_open() ) { + // the doors are already closed, we can skip all hard work + iDrivigFlags &= ~moveDoorOpened; + } + + if( AIControllFlag ) { + if( ( true == mvOccupied->DoorClosureWarning ) + && ( false == mvOccupied->DepartureSignal ) + && ( true == TestFlag( iDrivigFlags, moveDoorOpened ) ) ) { + mvOccupied->signal_departure( true ); // załącenie bzyczka + fActionTime = -1.5 - 0.1 * Random( 10 ); // 1.5-2.5 second wait + } + } + + if( ( true == TestFlag( iDrivigFlags, moveDoorOpened ) ) + && ( ( fActionTime > -0.5 ) + || ( false == AIControllFlag ) ) ) { + // ai doesn't close the door until it's free to depart, but human driver has free reign to do stupid things + auto *vehicle = pVehicles[ 0 ]; // pojazd na czole składu + while( vehicle != nullptr ) { + // zamykanie drzwi w pojazdach - flaga zezwolenia była by lepsza + if( vehicle->MoverParameters->DoorCloseCtrl != control_t::autonomous ) { + vehicle->MoverParameters->DoorLeft( false, range_t::local ); // w lokomotywie można by nie zamykać... + vehicle->MoverParameters->DoorRight( false, range_t::local ); + } + vehicle = vehicle->Next(); // pojazd podłączony z tyłu (patrząc od czoła) + } + fActionTime = -2.0 - 0.1 * Random( 15 ); // 2.0-3.5 sec wait, +potentially 0.5 remaining + iDrivigFlags &= ~moveDoorOpened; // zostały zamknięte - nie wykonywać drugi raz + + if( Random( 100 ) < Random( 100 ) ) { + // potentially turn off the warning before actual departure + // TBD, TODO: dedicated buzzer duration counter + mvOccupied->signal_departure( false ); + } + + } + } +} + +// returns true if any vehicle in the consist has open doors +bool +TController::doors_open() const { + + auto *vehicle = pVehicles[ 0 ]; // pojazd na czole składu + while( vehicle != nullptr ) { + if( ( vehicle->MoverParameters->DoorRightOpened == true ) + || ( vehicle->MoverParameters->DoorLeftOpened == true ) ) { + // any open door is enough + return true; + } + vehicle = vehicle->Next(); + } + // if we're still here there's nothing open + return false; +} + void TController::RecognizeCommand() { // odczytuje i wykonuje komendę przekazaną lokomotywie TCommand *c = &mvOccupied->CommandIn; @@ -2824,20 +3284,15 @@ void TController::RecognizeCommand() c->Command = ""; // usunięcie obsłużonej komendy } -void TController::PutCommand(std::string NewCommand, double NewValue1, double NewValue2, - const TLocation &NewLocation, TStopReason reason) -{ // wysłanie komendy przez event PutValues, jak pojazd ma obsadę, to wysyła tutaj, a nie do pojazdu - // bezpośrednio - vector3 sl; - sl.x = -NewLocation.X; // zamiana na współrzędne scenerii - sl.z = NewLocation.Y; - sl.y = NewLocation.Z; +void TController::PutCommand(std::string NewCommand, double NewValue1, double NewValue2, const TLocation &NewLocation, TStopReason reason) +{ // wysłanie komendy przez event PutValues, jak pojazd ma obsadę, to wysyła tutaj, a nie do pojazdu bezpośrednio + // zamiana na współrzędne scenerii + glm::dvec3 sl { -NewLocation.X, NewLocation.Z, NewLocation.Y }; if (!PutCommand(NewCommand, NewValue1, NewValue2, &sl, reason)) mvOccupied->PutCommand(NewCommand, NewValue1, NewValue2, NewLocation); } -bool TController::PutCommand(std::string NewCommand, double NewValue1, double NewValue2, - const vector3 *NewLocation, TStopReason reason) +bool TController::PutCommand( std::string NewCommand, double NewValue1, double NewValue2, glm::dvec3 const *NewLocation, TStopReason reason ) { // analiza komendy if (NewCommand == "CabSignal") { // SHP wyzwalane jest przez człon z obsadą, ale obsługiwane przez silnikowy @@ -2847,6 +3302,7 @@ bool TController::PutCommand(std::string NewCommand, double NewValue1, double Ne mvOccupied->RunInternalCommand(); // rozpoznaj komende bo lokomotywa jej nie rozpoznaje return true; // załatwione } + if (NewCommand == "Overhead") { // informacja o stanie sieci trakcyjnej fOverhead1 = @@ -2855,13 +3311,15 @@ bool TController::PutCommand(std::string NewCommand, double NewValue1, double Ne // opuszczonym i ograniczeniem prędkości) return true; // załatwione } - else if (NewCommand == "Emergency_brake") // wymuszenie zatrzymania, niezależnie kto prowadzi + + if (NewCommand == "Emergency_brake") // wymuszenie zatrzymania, niezależnie kto prowadzi { // Ra: no nadal nie jest zbyt pięknie SetVelocity(0, 0, reason); mvOccupied->PutCommand("Emergency_brake", 1.0, 1.0, mvOccupied->Loc); return true; // załatwione } - else if (NewCommand.compare(0, 10, "Timetable:") == 0) + + if (NewCommand.compare(0, 10, "Timetable:") == 0) { // przypisanie nowego rozkładu jazdy, również prowadzonemu przez użytkownika NewCommand.erase(0, 10); // zostanie nazwa pliku z rozkładem #if LOGSTOPS @@ -2871,12 +3329,11 @@ bool TController::PutCommand(std::string NewCommand, double NewValue1, double Ne TrainParams = new TTrainParameters(NewCommand); // rozkład jazdy else TrainParams->NewName(NewCommand); // czyści tabelkę przystanków - delete tsGuardSignal; - tsGuardSignal = NULL; // wywalenie kierownika + tsGuardSignal = sound_source { sound_placement::internal, 2 * EU07_SOUND_CABCONTROLSCUTOFFRANGE }; // wywalenie kierownika if (NewCommand != "none") { if (!TrainParams->LoadTTfile( - std::string(Global::asCurrentSceneryPath.c_str()), floor(NewValue2 + 0.5), + std::string(Global.asCurrentSceneryPath.c_str()), floor(NewValue2 + 0.5), NewValue1)) // pierwszy parametr to przesunięcie rozkładu w czasie { if (ConversionError == -8) @@ -2887,29 +3344,33 @@ bool TController::PutCommand(std::string NewCommand, double NewValue1, double Ne } else { // inicjacja pierwszego przystanku i pobranie jego nazwy - TrainParams->UpdateMTable(GlobalTime->hh, GlobalTime->mm, - TrainParams->NextStationName); + // HACK: clear the potentially set door state flag to ensure door get opened if applicable + iDrivigFlags &= ~( moveDoorOpened ); + + TrainParams->UpdateMTable( simulation::Time, TrainParams->NextStationName ); TrainParams->StationIndexInc(); // przejście do następnej iStationStart = TrainParams->StationIndex; asNextStop = TrainParams->NextStop(); iDrivigFlags |= movePrimary; // skoro dostał rozkład, to jest teraz głównym - NewCommand = Global::asCurrentSceneryPath + NewCommand + ".wav"; // na razie jeden - if (FileExists(NewCommand)) - { // wczytanie dźwięku odjazdu podawanego bezpośrenido - tsGuardSignal = new TTextSound(NewCommand, 30, pVehicle->GetPosition().x, - pVehicle->GetPosition().y, pVehicle->GetPosition().z, - false); - // rsGuardSignal->Stop(); +// NewCommand = Global.asCurrentSceneryPath + NewCommand; + auto lookup = + FileExists( + { Global.asCurrentSceneryPath + NewCommand, szSoundPath + NewCommand }, + { ".ogg", ".flac", ".wav" } ); + if( false == lookup.first.empty() ) { + // wczytanie dźwięku odjazdu podawanego bezpośrenido + tsGuardSignal = sound_source( sound_placement::external, 75.f ).deserialize( lookup.first + lookup.second, sound_type::single ); iGuardRadio = 0; // nie przez radio } - else - { - NewCommand = NewCommand.insert(NewCommand.find_last_of("."),"radio"); // wstawienie przed kropkč - if (FileExists(NewCommand)) - { // wczytanie dźwięku odjazdu w wersji radiowej (słychać tylko w kabinie) - tsGuardSignal = new TTextSound(NewCommand, -1, pVehicle->GetPosition().x, - pVehicle->GetPosition().y, pVehicle->GetPosition().z, - false); + else { + NewCommand += "radio"; + auto lookup = + FileExists( + { Global.asCurrentSceneryPath + NewCommand, szSoundPath + NewCommand }, + { ".ogg", ".flac", ".wav" } ); + if( false == lookup.first.empty() ) { + // wczytanie dźwięku odjazdu w wersji radiowej (słychać tylko w kabinie) + tsGuardSignal = sound_source( sound_placement::internal, 2 * EU07_SOUND_CABCONTROLSCUTOFFRANGE ).deserialize( lookup.first + lookup.second, sound_type::single ); iGuardRadio = iRadioChannel; } } @@ -2926,8 +3387,8 @@ bool TController::PutCommand(std::string NewCommand, double NewValue1, double Ne if (NewLocation) // jeśli podane współrzędne eventu/komórki ustawiającej rozkład (trainset // nie podaje) { - vector3 v = *NewLocation - pVehicle->GetPosition(); // wektor do punktu sterującego - vector3 d = pVehicle->VectorFront(); // wektor wskazujący przód + auto v = *NewLocation - pVehicle->GetPosition(); // wektor do punktu sterującego + auto d = pVehicle->VectorFront(); // wektor wskazujący przód iDirectionOrder = ((v.x * d.x + v.z * d.z) * NewValue1 > 0) ? 1 : -1; // do przodu, gdy iloczyn skalarny i prędkość dodatnie @@ -2963,26 +3424,25 @@ bool TController::PutCommand(std::string NewCommand, double NewValue1, double Ne // CheckVehicles(); //sprawdzenie składu, AI zapali światła TableClear(); // wyczyszczenie tabelki prędkości, bo na nowo trzeba określić kierunek i // sprawdzić przystanki - OrdersInit( - fabs(NewValue1)); // ustalenie tabelki komend wg rozkładu oraz prędkości początkowej + OrdersInit(fabs(NewValue1)); // ustalenie tabelki komend wg rozkładu oraz prędkości początkowej // if (NewValue1!=0.0) if (!AIControllFlag) DirectionForward(NewValue1>0.0); //ustawienie // nawrotnika użytkownikowi (propaguje się do członów) // if (NewValue1>0) // TrainNumber=floor(NewValue1); //i co potem ??? return true; // załatwione } + if (NewCommand == "SetVelocity") { if (NewLocation) vCommandLocation = *NewLocation; if ((NewValue1 != 0.0) && (OrderList[OrderPos] != Obey_train)) { // o ile jazda - if (!iEngineActive) - OrderNext(Prepare_engine); // trzeba odpalić silnik najpierw, światła ustawi - // JumpToNextOrder() - // if (OrderList[OrderPos]!=Obey_train) //jeśli nie pociągowa - OrderNext(Obey_train); // to uruchomić jazdę pociągową (od razu albo po odpaleniu - // silnika + if( iEngineActive == 0 ) { + // trzeba odpalić silnik najpierw, światła ustawi + OrderNext( Prepare_engine ); + } + OrderNext(Obey_train); // to uruchomić jazdę pociągową (od razu albo po odpaleniu silnika OrderCheck(); // jeśli jazda pociągowa teraz, to wykonać niezbędne operacje } if (NewValue1 != 0.0) // jeśli jechać @@ -2991,16 +3451,20 @@ bool TController::PutCommand(std::string NewCommand, double NewValue1, double Ne iDrivigFlags |= moveStopHere; // stać do momentu podania komendy jazdy SetVelocity(NewValue1, NewValue2, reason); // bylo: nic nie rob bo SetVelocity zewnetrznie // jest wywolywane przez dynobj.cpp + return true; } - else if (NewCommand == "SetProximityVelocity") + + if (NewCommand == "SetProximityVelocity") { /* if (SetProximityVelocity(NewValue1,NewValue2)) if (NewLocation) vCommandLocation=*NewLocation; */ + return true; } - else if (NewCommand == "ShuntVelocity") + + if (NewCommand == "ShuntVelocity") { // uruchomienie jazdy manewrowej bądź zmiana prędkości if (NewLocation) vCommandLocation = *NewLocation; @@ -3024,15 +3488,21 @@ bool TController::PutCommand(std::string NewCommand, double NewValue1, double Ne iDrivigFlags |= moveStopHere; // ma stać w miejscu if (fabs(NewValue1) > 2.0) // o ile wartość jest sensowna (-1 nie jest konkretną wartością) fShuntVelocity = fabs(NewValue1); // zapamiętanie obowiązującej prędkości dla manewrów + + return true; } - else if (NewCommand == "Wait_for_orders") + + if (NewCommand == "Wait_for_orders") { // oczekiwanie; NewValue1 - czas oczekiwania, -1 = na inną komendę if (NewValue1 > 0.0 ? NewValue1 > fStopTime : false) fStopTime = NewValue1; // Ra: włączenie czekania bez zmiany komendy else OrderList[OrderPos] = Wait_for_orders; // czekanie na komendę (albo dać OrderPos=0) + + return true; } - else if (NewCommand == "Prepare_engine") + + if (NewCommand == "Prepare_engine") { // włączenie albo wyłączenie silnika (w szerokim sensie) OrdersClear(); // czyszczenie tabelki rozkazów, aby nic dalej nie robił if (NewValue1 == 0.0) @@ -3040,8 +3510,10 @@ bool TController::PutCommand(std::string NewCommand, double NewValue1, double Ne else if (NewValue1 > 0.0) OrderNext(Prepare_engine); // odpalić silnik (wyłączyć wszystko, co się da) // po załączeniu przejdzie do kolejnej komendy, po wyłączeniu na Wait_for_orders + return true; } - else if (NewCommand == "Change_direction") + + if (NewCommand == "Change_direction") { TOrders o = OrderList[OrderPos]; // co robił przed zmianą kierunku if (!iEngineActive) @@ -3051,8 +3523,8 @@ bool TController::PutCommand(std::string NewCommand, double NewValue1, double Ne else if (NewLocation) // jeśli podane współrzędne eventu/komórki ustawiającej rozkład // (trainset nie podaje) { - vector3 v = *NewLocation - pVehicle->GetPosition(); // wektor do punktu sterującego - vector3 d = pVehicle->VectorFront(); // wektor wskazujący przód + auto v = *NewLocation - pVehicle->GetPosition(); // wektor do punktu sterującego + auto d = pVehicle->VectorFront(); // wektor wskazujący przód iDirectionOrder = ((v.x * d.x + v.z * d.z) * NewValue1 > 0) ? 1 : -1; // do przodu, gdy iloczyn skalarny i prędkość dodatnie @@ -3067,16 +3539,21 @@ bool TController::PutCommand(std::string NewCommand, double NewValue1, double Ne if (mvOccupied->Vel >= 1.0) // jeśli jedzie iDrivigFlags &= ~moveStartHorn; // to bez trąbienia po ruszeniu z zatrzymania // Change_direction wykona się samo i następnie przejdzie do kolejnej komendy + return true; } - else if (NewCommand == "Obey_train") + + if (NewCommand == "Obey_train") { if (!iEngineActive) OrderNext(Prepare_engine); // trzeba odpalić silnik najpierw OrderNext(Obey_train); // if (NewValue1>0) TrainNumber=floor(NewValue1); //i co potem ??? OrderCheck(); // jeśli jazda pociągowa teraz, to wykonać niezbędne operacje + + return true; } - else if (NewCommand == "Shunt") + + if (NewCommand == "Shunt") { // NewValue1 - ilość wagonów (-1=wszystkie); NewValue2: 0=odczep, 1..63=dołącz, -1=bez zmian //-3,-y - podłączyć do całego stojącego składu (sprzęgiem y>=1), zmienić kierunek i czekać w // trybie pociągowym @@ -3108,8 +3585,7 @@ bool TController::PutCommand(std::string NewCommand, double NewValue1, double Ne iDirectionOrder = -iDirection; // jak się podczepi, to jazda w przeciwną stronę OrderNext(Change_direction); } - WaitingTime = - 0.0; // nie ma co dalej czekać, można zatrąbić i jechać, chyba że już jedzie + WaitingTime = 0.0; // nie ma co dalej czekać, można zatrąbić i jechać, chyba że już jedzie } else // if (NewValue2==0.0) //zerowy sprzęg if (NewValue1 >= 0.0) // jeśli ilość wagonów inna niż wszystkie @@ -3126,8 +3602,7 @@ bool TController::PutCommand(std::string NewCommand, double NewValue1, double Ne else if (mvOccupied->Couplers[mvOccupied->DirAbsolute > 0 ? 1 : 0].CouplingFlag > 0) // z tyłu coś OrderNext(Disconnect); // jak ciągnie, to tylko odczep (NewValue1) wagonów - WaitingTime = - 0.0; // nie ma co dalej czekać, można zatrąbić i jechać, chyba że już jedzie + WaitingTime = 0.0; // nie ma co dalej czekać, można zatrąbić i jechać, chyba że już jedzie } if (NewValue1 == -1.0) { @@ -3152,70 +3627,73 @@ bool TController::PutCommand(std::string NewCommand, double NewValue1, double Ne if (VelDesired==0) SetVelocity(20,0); //to niech jedzie */ + return true; } - else if (NewCommand == "Jump_to_first_order") + + if( NewCommand == "Jump_to_first_order" ) { JumpToFirstOrder(); - else if (NewCommand == "Jump_to_order") + return true; + } + + if (NewCommand == "Jump_to_order") { - if (NewValue1 == -1.0) + if( NewValue1 == -1.0 ) { JumpToNextOrder(); + } else if ((NewValue1 >= 0) && (NewValue1 < maxorders)) { OrderPos = floor(NewValue1); - if (!OrderPos) - OrderPos = 1; // zgodność wstecz: dopiero pierwsza uruchamia + if( !OrderPos ) { + // zgodność wstecz: dopiero pierwsza uruchamia + OrderPos = 1; + } #if LOGORDERS WriteLog("--> Jump_to_order"); OrdersDump(); #endif } - /* - if (WriteLogFlag) - { - append(AIlogFile); - writeln(AILogFile,ElapsedTime:5:2," - new order: ",Order2Str( OrderList[OrderPos])," @ - ",OrderPos); - close(AILogFile); - } - */ + return true; } - /* //ta komenda jest teraz skanowana, więc wysyłanie jej eventem nie ma sensu - else if (NewCommand=="OutsideStation") //wskaznik W5 - { - if (OrderList[OrderPos]==Obey_train) - SetVelocity(NewValue1,NewValue2,stopOut); //koniec stacji - predkosc szlakowa - else //manewry - zawracaj - { - iDirectionOrder=-iDirection; //zmiana na przeciwny niż obecny - OrderNext(Change_direction); //zmiana kierunku - OrderNext(Shunt); //a dalej manewry - iDrivigFlags&=~moveStartHorn; //bez trąbienia po zatrzymaniu - } - } - */ - else if (NewCommand == "Warning_signal") + + if (NewCommand == "Warning_signal") { - if (AIControllFlag) // poniższa komenda nie jest wykonywana przez użytkownika - if (NewValue1 > 0) - { + if( AIControllFlag ) { + // poniższa komenda nie jest wykonywana przez użytkownika + if( NewValue1 > 0 ) { fWarningDuration = NewValue1; // czas trąbienia - mvOccupied->WarningSignal = (NewValue2 > 1) ? 2 : 1; // wysokość tonu + mvOccupied->WarningSignal = NewValue2; // horn combination flag } + } + return true; } - else if (NewCommand == "Radio_channel") - { // wybór kanału radiowego (którego powinien używać AI, ręczny maszynista musi go ustawić sam) - if (NewValue1 >= 0) // wartości ujemne są zarezerwowane, -1 = nie zmieniać kanału - { + + if (NewCommand == "Radio_channel") { + // wybór kanału radiowego (którego powinien używać AI, ręczny maszynista musi go ustawić sam) + if (NewValue1 >= 0) { + // wartości ujemne są zarezerwowane, -1 = nie zmieniać kanału iRadioChannel = NewValue1; - if (iGuardRadio) - iGuardRadio = iRadioChannel; // kierownikowi też zmienić + if( iGuardRadio ) { + // kierownikowi też zmienić + iGuardRadio = iRadioChannel; + } } // NewValue2 może zawierać dodatkowo oczekiwany kod odpowiedzi, np. dla W29 "nawiązać // łączność radiową z dyżurnym ruchu odcinkowym" + return true; } - else - return false; // nierozpoznana - wysłać bezpośrednio do pojazdu - return true; // komenda została przetworzona + + if( NewCommand == "SetLights" ) { + // set consist lights pattern hints + m_lighthints[ side::front ] = static_cast( NewValue1 ); + m_lighthints[ side::rear ] = static_cast( NewValue2 ); + if( true == TestFlag( OrderCurrentGet(), Obey_train ) ) { + // light hints only apply in the obey_train mode + CheckVehicles(); + } + return true; + } + + return false; // nierozpoznana - wysłać bezpośrednio do pojazdu }; void TController::PhysicsLog() @@ -3223,20 +3701,40 @@ void TController::PhysicsLog() if (LogFile.is_open()) { #if LOGPRESS == 0 - LogFile << ElapsedTime << " " << fabs(11.31 * mvOccupied->WheelDiameter * mvOccupied->nrot) - << " "; - LogFile << mvControlling->AccS << " " << mvOccupied->Couplers[1].Dist << " " - << mvOccupied->Couplers[1].CForce << " "; - LogFile << mvOccupied->Ft << " " << mvOccupied->Ff << " " << mvOccupied->Fb << " " - << mvOccupied->BrakePress << " "; - LogFile << mvOccupied->PipePress << " " << mvControlling->Im << " " - << int(mvControlling->MainCtrlPos) << " "; - LogFile << int(mvControlling->ScndCtrlPos) << " " << int(mvOccupied->BrakeCtrlPos) - << " " << int(mvOccupied->LocalBrakePos) << " "; - LogFile << int(mvControlling->ActiveDir) << " " << mvOccupied->CommandIn.Command.c_str() - << " " << mvOccupied->CommandIn.Value1 << " "; - LogFile << mvOccupied->CommandIn.Value2 << " " << int(mvControlling->SecuritySystem.Status) - << " " << int(mvControlling->SlippingWheels) << "\r\n"; +/* +<< "Time[s] Velocity[m/s] Acceleration[m/ss] " +<< "Coupler.Dist[m] Coupler.Force[N] TractionForce[kN] FrictionForce[kN] BrakeForce[kN] " +<< "BrakePress[MPa] PipePress[MPa] MotorCurrent[A] " +<< "MCP SCP BCP LBP DmgFlag Command CVal1 CVal2 " +<< "EngineTemp[Deg] OilTemp[Deg] WaterTemp[Deg] WaterAuxTemp[Deg]" +*/ + LogFile + << ElapsedTime << " " + << fabs(11.31 * mvOccupied->WheelDiameter * mvOccupied->nrot) << " " + << mvControlling->AccS << " " + << mvOccupied->Couplers[1].Dist << " " + << mvOccupied->Couplers[1].CForce << " " + << mvOccupied->Ft << " " + << mvOccupied->Ff << " " + << mvOccupied->Fb << " " + << mvOccupied->BrakePress << " " + << mvOccupied->PipePress << " " + << mvControlling->Im << " " + << int(mvControlling->MainCtrlPos) << " " + << int(mvControlling->ScndCtrlPos) << " " + << mvOccupied->fBrakeCtrlPos << " " + << mvOccupied->LocalBrakePosA << " " + << int(mvControlling->ActiveDir) << " " + << ( mvOccupied->CommandIn.Command.empty() ? "none" : mvOccupied->CommandIn.Command.c_str() ) << " " + << mvOccupied->CommandIn.Value1 << " " + << mvOccupied->CommandIn.Value2 << " " + << int(mvControlling->SecuritySystem.Status) << " " + << int(mvControlling->SlippingWheels) << " " + << mvControlling->dizel_heat.Ts << " " + << mvControlling->dizel_heat.To << " " + << mvControlling->dizel_heat.temperatura1 << " " + << mvControlling->dizel_heat.temperatura2 + << "\r\n"; #endif #if LOGPRESS == 1 LogFile << ElapsedTime << "\t" << fabs(11.31 * mvOccupied->WheelDiameter * mvOccupied->nrot) @@ -3250,1469 +3748,1784 @@ void TController::PhysicsLog() } }; -bool TController::UpdateSituation(double dt) -{ // uruchamiać przynajmniej raz na sekundę - if ((iDrivigFlags & movePrimary) == 0) - return true; // pasywny nic nie robi +void +TController::UpdateSituation(double dt) { + // uruchamiać przynajmniej raz na sekundę + if( ( iDrivigFlags & movePrimary ) == 0 ) { return; } // pasywny nic nie robi - double AbsAccS; - // double VelReduced; //o ile km/h może przekroczyć dozwoloną prędkość bez hamowania - bool UpdateOK = false; - if (AIControllFlag) - { // yb: zeby EP nie musial sie bawic z ciesnieniem w PG - // if (mvOccupied->BrakeSystem==ElectroPneumatic) - // mvOccupied->PipePress=0.5; //yB: w SPKS są poprawnie zrobione pozycje - if (mvControlling->SlippingWheels) - { - mvControlling->SandDoseOn(); // piasku! - // Controlling->SlippingWheels=false; //a to tu nie ma sensu, flaga używana w dalszej - // części - } + // update timers + ElapsedTime += dt; + WaitingTime += dt; + fBrakeTime -= dt; // wpisana wartość jest zmniejszana do 0, gdy ujemna należy zmienić nastawę hamulca + if( mvOccupied->fBrakeCtrlPos != mvOccupied->Handle->GetPos( bh_FS ) ) { + // brake charging timeout starts after charging ends + BrakeChargingCooldown += dt; } + fStopTime += dt; // zliczanie czasu postoju, nie ruszy dopóki ujemne + fActionTime += dt; // czas używany przy regulacji prędkości i zamykaniu drzwi + LastReactionTime += dt; + LastUpdatedTime += dt; + if( ( mvOccupied->Vel < 0.05 ) + && ( ( OrderCurrentGet() & ( Obey_train | Shunt ) ) != 0 ) ) { + IdleTime += dt; + } + else { + IdleTime = 0.0; + } + + // log vehicle data + if( ( WriteLogFlag ) + && ( LastUpdatedTime > deltalog ) ) { + // zapis do pliku DAT + PhysicsLog(); + LastUpdatedTime -= deltalog; + } + + if( ( fLastStopExpDist > 0.0 ) + && ( mvOccupied->DistCounter > fLastStopExpDist ) ) { + // zaktualizować wyświetlanie rozkładu + iStationStart = TrainParams->StationIndex; + fLastStopExpDist = -1.0; // usunąć licznik + } + // ABu-160305 testowanie gotowości do jazdy - // Ra: przeniesione z DynObj, skład użytkownika też jest testowany, żeby mu przekazać, że ma - // odhamować + // Ra: przeniesione z DynObj, skład użytkownika też jest testowany, żeby mu przekazać, że ma odhamować + int index = double(BrakeAccTableSize) * (mvOccupied->Vel / mvOccupied->Vmax); + index = std::min(BrakeAccTableSize, std::max(1, index)); + fBrake_a0[0] = fBrake_a0[index]; + fBrake_a1[0] = fBrake_a1[index]; + + if ((mvOccupied->TrainType == dt_EZT) || (mvOccupied->TrainType == dt_DMU)) { + auto Coeff = clamp( mvOccupied->Vel*0.015 , 0.5 , 1.0); + fAccThreshold = fNominalAccThreshold * Coeff - fBrake_a0[BrakeAccTableSize] * (1.0 - Coeff); + } + Ready = true; // wstępnie gotowy fReady = 0.0; // założenie, że odhamowany fAccGravity = 0.0; // przyspieszenie wynikające z pochylenia double dy; // składowa styczna grawitacji, w przedziale <0,1> + double AbsAccS = 0; TDynamicObject *p = pVehicles[0]; // pojazd na czole składu while (p) { // sprawdzenie odhamowania wszystkich połączonych pojazdów - if (Ready) // bo jak coś nie odhamowane, to dalej nie ma co sprawdzać - // if (p->MoverParameters->BrakePress>=0.03*p->MoverParameters->MaxBrakePress) + if (Ready) { + // bo jak coś nie odhamowane, to dalej nie ma co sprawdzać if (p->MoverParameters->BrakePress >= 0.4) // wg UIC określone sztywno na 0.04 { Ready = false; // nie gotowy // Ra: odluźnianie przeładowanych lokomotyw, ciągniętych na zimno - prowizorka... if (AIControllFlag) // skład jak dotąd był wyluzowany { - if (mvOccupied->BrakeCtrlPos == 0) // jest pozycja jazdy - if ((p->MoverParameters->PipePress - 5.0) > - -0.1) // jeśli ciśnienie jak dla jazdy - if (p->MoverParameters->Hamulec->GetCRP() > - p->MoverParameters->PipePress + 0.12) // za dużo w zbiorniku - p->MoverParameters->BrakeReleaser(1); // indywidualne luzowanko + if( ( mvOccupied->BrakeCtrlPos == 0 ) // jest pozycja jazdy + && ( ( p->MoverParameters->Hamulec->GetBrakeStatus() & b_dmg ) == 0 ) // brake isn't broken + && ( p->MoverParameters->PipePress - 5.0 > -0.1 ) // jeśli ciśnienie jak dla jazdy + && ( p->MoverParameters->Hamulec->GetCRP() > p->MoverParameters->PipePress + 0.12 ) ) { // za dużo w zbiorniku + // indywidualne luzowanko + p->MoverParameters->BrakeReleaser( 1 ); + } if (p->MoverParameters->Power > 0.01) // jeśli ma silnik if (p->MoverParameters->FuseFlag) // wywalony nadmiarowy Need_TryAgain = true; // reset jak przy wywaleniu nadmiarowego } } + } if (fReady < p->MoverParameters->BrakePress) fReady = p->MoverParameters->BrakePress; // szukanie najbardziej zahamowanego - if ((dy = p->VectorFront().y) != 0.0) // istotne tylko dla pojazdów na pochyleniu - fAccGravity -= p->DirectionGet() * p->MoverParameters->TotalMassxg * - dy; // ciężar razy składowa styczna grawitacji + if( ( dy = p->VectorFront().y ) != 0.0 ) { + // istotne tylko dla pojazdów na pochyleniu + // ciężar razy składowa styczna grawitacji + fAccGravity -= p->MoverParameters->TotalMassxg * dy * ( p->DirectionGet() == iDirection ? 1 : -1 ); + } p = p->Next(); // pojazd podłączony z tyłu (patrząc od czoła) } - if (iDirection) - fAccGravity /= - iDirection * - fMass; // siłę generują pojazdy na pochyleniu ale działa ona całość składu, więc a=F/m + if( iDirection ) { + // siłę generują pojazdy na pochyleniu ale działa ona całość składu, więc a=F/m + fAccGravity *= iDirection; + fAccGravity /= fMass; + } if (!Ready) // v367: jeśli wg powyższych warunków skład nie jest odhamowany if (fAccGravity < -0.05) // jeśli ma pod górę na tyle, by się stoczyć - // if (mvOccupied->BrakePress<0.08) //to wystarczy, że zadziałają liniowe (nie ma ich - // jeszcze!!!) + // if (mvOccupied->BrakePress<0.08) //to wystarczy, że zadziałają liniowe (nie ma ich jeszcze!!!) if (fReady < 0.8) // delikatniejszy warunek, obejmuje wszystkie wagony Ready = true; //żeby uznać za odhamowany - HelpMeFlag = false; - // Winger 020304 - if (AIControllFlag) - { - if (mvControlling->EnginePowerSource.SourceType == CurrentCollector) - { - if (mvOccupied->ScndPipePress > 4.3) // gdy główna sprężarka bezpiecznie nabije - // ciśnienie - mvControlling->bPantKurek3 = - true; // to można przestawić kurek na zasilanie pantografów z głównej pneumatyki - fVoltage = - 0.5 * (fVoltage + - fabs(mvControlling->RunningTraction.TractionVoltage)); // uśrednione napięcie - // sieci: przy spadku - // poniżej wartości - // minimalnej opóźnić - // rozruch o losowy - // czas - if (fVoltage < mvControlling->EnginePowerSource.CollectorParameters - .MinV) // gdy rozłączenie WS z powodu niskiego napięcia - if (fActionTime >= 0) // jeśli czas oczekiwania nie został ustawiony - fActionTime = - -2 - Random(10); // losowy czas oczekiwania przed ponownym załączeniem jazdy + // second pass, for diesel engines verify the (live) engines are fully started + // TODO: cache presence of diesel engines in the consist, to skip this test if there isn't any + p = pVehicles[ 0 ]; // pojazd na czole składu + while( ( true == Ready ) + && ( p != nullptr ) ) { + + auto const *vehicle { p->MoverParameters }; + + if( ( vehicle->EngineType == TEngineType::DieselEngine ) + || ( vehicle->EngineType == TEngineType::DieselElectric ) ) { + + Ready = ( + ( vehicle->Vel > 0.5 ) // already moving + || ( false == vehicle->Mains ) // deadweight vehicle + || ( vehicle->enrot > 0.8 * ( + vehicle->EngineType == TEngineType::DieselEngine ? + vehicle->dizel_nmin : + vehicle->DElist[ 0 ].RPM / 60.0 ) ) ); } - if (mvOccupied->Vel > 0.0) - { // jeżeli jedzie - if (iDrivigFlags & moveDoorOpened) // jeśli drzwi otwarte - if (mvOccupied->Vel > 1.0) // nie zamykać drzwi przy drganiach, bo zatrzymanie na W4 - // akceptuje niewielkie prędkości - Doors(false); + p = p->Next(); // pojazd podłączony z tyłu (patrząc od czoła) + } + + // crude way to deal with automatic door opening on W4 preventing further ride + // for human-controlled vehicles with no door control and dynamic brake auto-activating with door open + if( ( false == AIControllFlag ) + && ( iDrivigFlags & moveDoorOpened ) + && ( mvOccupied->DoorCloseCtrl != control_t::driver ) + && ( mvControlling->MainCtrlPos > 0 ) ) { + Doors( false ); + } + + // basic situational ai operations + // TBD, TODO: move these to main routine, if it's not neccessary for them to fire every time? + if( AIControllFlag ) { + + // wheel slip + if( mvControlling->SlippingWheels ) { + mvControlling->Sandbox( true ); // piasku! + } + else { + // deactivate sandbox if we aren't slipping + if( mvControlling->SandDose ) { + mvControlling->Sandbox( false ); + } + } + + if (mvControlling->EnginePowerSource.SourceType == TPowerSource::CurrentCollector) { + + if( mvOccupied->ScndPipePress > 4.3 ) { + // gdy główna sprężarka bezpiecznie nabije ciśnienie to można przestawić kurek na zasilanie pantografów z głównej pneumatyki + mvControlling->bPantKurek3 = true; + } + + // uśrednione napięcie sieci: przy spadku poniżej wartości minimalnej opóźnić rozruch o losowy czas + fVoltage = 0.5 * (fVoltage + std::abs(mvControlling->RunningTraction.TractionVoltage)); + if( fVoltage < mvControlling->EnginePowerSource.CollectorParameters.MinV ) { + // gdy rozłączenie WS z powodu niskiego napięcia + if( fActionTime >= 0 ) { + // jeśli czas oczekiwania nie został ustawiony, losowy czas oczekiwania przed ponownym załączeniem jazdy + fActionTime = -2.0 - Random( 10 ); + } + } + } + + if( mvOccupied->Vel > 1.0 ) { + // jeżeli jedzie + if( iDrivigFlags & moveDoorOpened ) { + // jeśli drzwi otwarte + // nie zamykać drzwi przy drganiach, bo zatrzymanie na W4 akceptuje niewielkie prędkości + Doors( false ); + } +/* + // NOTE: this section moved all cars to the edge of their respective roads + // it may have some use eventually for collision avoidance, + // but when enabled all the time it produces silly effect // przy prowadzeniu samochodu trzeba każdą oś odsuwać oddzielnie, inaczej kicha wychodzi if (mvOccupied->CategoryFlag & 2) // jeśli samochód - // if (fabs(mvOccupied->OffsetTrackH)Dim.W) //Ra: szerokość drogi tu - // powinna być? - if (!mvOccupied->ChangeOffsetH(-0.01 * mvOccupied->Vel * dt)) // ruch w poprzek - // drogi - mvOccupied->ChangeOffsetH(0.01 * mvOccupied->Vel * - dt); // Ra: co to miało być, to nie wiem - if (mvControlling->EnginePowerSource.SourceType == CurrentCollector) - { - if ((fOverhead2 >= 0.0) || iOverheadZero) - { // jeśli jazda bezprądowa albo z opuszczonym pantografem - while (DecSpeed(true)) - ; // zerowanie napędu + // if (fabs(mvOccupied->OffsetTrackH)Dim.W) //Ra: szerokość drogi tu powinna być? + if (!mvOccupied->ChangeOffsetH(-0.01 * mvOccupied->Vel * dt)) // ruch w poprzek drogi + mvOccupied->ChangeOffsetH(0.01 * mvOccupied->Vel * dt); // Ra: co to miało być, to nie wiem +*/ + } + + if (mvControlling->EnginePowerSource.SourceType == TPowerSource::CurrentCollector) { + + if( mvOccupied->Vel > 0.05 ) { + // is moving + if( ( fOverhead2 >= 0.0 ) || iOverheadZero ) { + // jeśli jazda bezprądowa albo z opuszczonym pantografem + while( DecSpeed( true ) ) { ; } // zerowanie napędu } - if ((fOverhead2 > 0.0) || iOverheadDown) - { // jazda z opuszczonymi pantografami - mvControlling->PantFront(false); - mvControlling->PantRear(false); + if( ( fOverhead2 > 0.0 ) || iOverheadDown ) { + // jazda z opuszczonymi pantografami + mvControlling->PantFront( false ); + mvControlling->PantRear( false ); } - else - { // jeśli nie trzeba opuszczać pantografów - if (iDirection >= 0) // jak jedzie w kierunku sprzęgu 0 - mvControlling->PantRear(true); // jazda na tylnym - else - mvControlling->PantFront(true); + else { + // jeśli nie trzeba opuszczać pantografów + // jazda na tylnym + if( iDirection >= 0 ) { + // jak jedzie w kierunku sprzęgu 0 + mvControlling->PantRear( true ); + } + else { + mvControlling->PantFront( true ); + } } - if (mvOccupied->Vel > 10) // opuszczenie przedniego po rozpędzeniu się - { - if (mvControlling->EnginePowerSource.CollectorParameters.CollectorsNo > - 1) // o ile jest więcej niż jeden - if (iDirection >= 0) // jak jedzie w kierunku sprzęgu 0 + if( mvOccupied->Vel > 10 ) { + // opuszczenie przedniego po rozpędzeniu się o ile jest więcej niż jeden + if( mvControlling->EnginePowerSource.CollectorParameters.CollectorsNo > 1 ) { + if( iDirection >= 0 ) // jak jedzie w kierunku sprzęgu 0 { // poczekać na podniesienie tylnego - if (mvControlling->PantRearVolt != - 0.0) // czy jest napięcie zasilające na tylnym? - mvControlling->PantFront(false); // opuszcza od sprzęgu 0 + if( mvControlling->PantRearVolt != 0.0 ) { + // czy jest napięcie zasilające na tylnym? + mvControlling->PantFront( false ); // opuszcza od sprzęgu 0 + } } - else - { // poczekać na podniesienie przedniego - if (mvControlling->PantFrontVolt != - 0.0) // czy jest napięcie zasilające na przednim? - mvControlling->PantRear(false); // opuszcza od sprzęgu 1 + else { // poczekać na podniesienie przedniego + if( mvControlling->PantFrontVolt != 0.0 ) { + // czy jest napięcie zasilające na przednim? + mvControlling->PantRear( false ); // opuszcza od sprzęgu 1 + } } + } + } + if( fVoltage < 0.75 * mvControlling->EnginePowerSource.CollectorParameters.MaxV ) { + // if the power station is heavily burdened try to reduce the load + switch( mvControlling->EngineType ) { + + case TEngineType::ElectricSeriesMotor: { + if( mvControlling->RList[ mvControlling->MainCtrlPos ].Bn > 1 ) { + // limit yourself to series mode + if( mvControlling->ScndCtrlPos ) { + mvControlling->DecScndCtrl( 2 ); + } + while( ( mvControlling->RList[ mvControlling->MainCtrlPos ].Bn > 1 ) + && ( mvControlling->DecMainCtrl( 1 ) ) ) { + ; // all work is performed in the header + } + } + break; + } + default: { + break; + } + } + } + } + else { + if( ( IdleTime > 45.0 ) + // NOTE: abs(stoptime) covers either at least 15 sec remaining for a scheduled stop, or 15+ secs spent at a basic stop + && ( std::abs( fStopTime ) > 15.0 ) ) { + // spending a longer at a stop, raise also front pantograph + if( iDirection >= 0 ) // jak jedzie w kierunku sprzęgu 0 + mvControlling->PantFront( true ); + else + mvControlling->PantRear( true ); } } } - if (iDrivigFlags & moveStartHornNow) // czy ma zatrąbić przed ruszeniem? - if (Ready) // gotów do jazdy - if (iEngineActive) // jeszcze się odpalić musi - if (fStopTime >= 0) // i nie musi czekać - { // uruchomienie trąbienia - fWarningDuration = 0.3; // czas trąbienia - // if (AIControllFlag) //jak siedzi krasnoludek, to włączy trąbienie - mvOccupied->WarningSignal = - pVehicle->iHornWarning; // wysokość tonu (2=wysoki) - iDrivigFlags |= moveStartHornDone; // nie trąbić aż do ruszenia - iDrivigFlags &= ~moveStartHornNow; // trąbienie zostało zorganizowane - } - } - ElapsedTime += dt; - WaitingTime += dt; - fBrakeTime -= - dt; // wpisana wartość jest zmniejszana do 0, gdy ujemna należy zmienić nastawę hamulca - fStopTime += dt; // zliczanie czasu postoju, nie ruszy dopóki ujemne - fActionTime += dt; // czas używany przy regulacji prędkości i zamykaniu drzwi - if (WriteLogFlag) - { - if (LastUpdatedTime > deltalog) - { // zapis do pliku DAT - PhysicsLog(); - if (fabs(mvOccupied->V) > 0.1) // Ra: [m/s] - deltalog = 0.05; // 0.2; - else - deltalog = 0.05; // 1.0; - LastUpdatedTime = 0.0; - } - else - LastUpdatedTime = LastUpdatedTime + dt; - } - // Ra: skanowanie również dla prowadzonego ręcznie, aby podpowiedzieć prędkość - if ((LastReactionTime > Min0R(ReactionTime, 2.0))) - { - // Ra: nie wiem czemu ReactionTime potrafi dostać 12 sekund, to jest przegięcie, bo przeżyna - // STÓJ - // yB: otóż jest to jedna trzecia czasu napełniania na towarowym; może się przydać przy - // wdrażaniu hamowania, żeby nie ruszało kranem jak głupie - // Ra: ale nie może się budzić co pół minuty, bo przeżyna semafory - // Ra: trzeba by tak: - // 1. Ustalić istotną odległość zainteresowania (np. 3×droga hamowania z V.max). - fBrakeDist = fDriverBraking * mvOccupied->Vel * - (40.0 + mvOccupied->Vel); // przybliżona droga hamowania - // dla hamowania -0.2 [m/ss] droga wynosi 0.389*Vel*Vel [km/h], czyli 600m dla 40km/h, 3.8km - // dla 100km/h i 9.8km dla 160km/h - // dla hamowania -0.4 [m/ss] droga wynosi 0.096*Vel*Vel [km/h], czyli 150m dla 40km/h, 1.0km - // dla 100km/h i 2.5km dla 160km/h - // ogólnie droga hamowania przy stałym opóźnieniu to Vel*Vel/(3.6*3.6*a) [m] - // fBrakeDist powinno być wyznaczane dla danego składu za pomocą sieci neuronowych, w - // zależności od prędkości i siły (ciśnienia) hamowania - // następnie w drugą stronę, z drogi hamowania i chwilowej prędkości powinno być wyznaczane - // zalecane ciśnienie - if (fMass > 1000000.0) - fBrakeDist *= 2.0; // korekta dla ciężkich, bo przeżynają - da to coś? - if (mvOccupied->BrakeDelayFlag == bdelay_G) - fBrakeDist = fBrakeDist + 2 * mvOccupied->Vel; // dla nastawienia G - // koniecznie należy wydłużyć drogę na czas reakcji - // double scanmax=(mvOccupied->Vel>0.0)?3*fDriverDist+fBrakeDist:10.0*fDriverDist; - double scanmax = (mvOccupied->Vel > 5.0) ? - 400 + fBrakeDist : - 30.0 * fDriverDist; // 1500m dla stojących pociągów; Ra 2015-01: przy - //double scanmax = Max0R(400 + fBrakeDist, 1500); - // dłuższej drodze skanowania AI jeździ spokojniej - // 2. Sprawdzić, czy tabelka pokrywa założony odcinek (nie musi, jeśli jest STOP). - // 3. Sprawdzić, czy trajektoria ruchu przechodzi przez zwrotnice - jeśli tak, to sprawdzić, - // czy stan się nie zmienił. - // 4. Ewentualnie uzupełnić tabelkę informacjami o sygnałach i ograniczeniach, jeśli się - // "zużyła". - TableCheck(scanmax); // wypełnianie tabelki i aktualizacja odległości - // 5. Sprawdzić stany sygnalizacji zapisanej w tabelce, wyznaczyć prędkości. - // 6. Z tabelki wyznaczyć krytyczną odległość i prędkość (najmniejsze przyspieszenie). - // 7. Jeśli jest inny pojazd z przodu, ewentualnie skorygować odległość i prędkość. - // 8. Ustalić częstotliwość świadomości AI (zatrzymanie precyzyjne - częściej, brak atrakcji - // - rzadziej). - if (AIControllFlag) - { // tu bedzie logika sterowania - if (mvOccupied->CommandIn.Command != "") - if (!mvOccupied->RunInternalCommand()) // rozpoznaj komende bo lokomotywa jej nie - // rozpoznaje - RecognizeCommand(); // samo czyta komendę wstawioną do pojazdu? - if (mvOccupied->SecuritySystem.Status > 1) // jak zadziałało CA/SHP - if (!mvOccupied->SecuritySystemReset()) // to skasuj - // if - // ((TestFlag(mvOccupied->SecuritySystem.Status,s_ebrake))&&(mvOccupied->BrakeCtrlPos==0)&&(AccDesired>0.0)) - if ((TestFlag(mvOccupied->SecuritySystem.Status, s_SHPebrake) || - TestFlag(mvOccupied->SecuritySystem.Status, s_CAebrake)) && - (mvOccupied->BrakeCtrlPos == 0) && (AccDesired > 0.0)) - mvOccupied->BrakeLevelSet( - 0); //!!! hm, może po prostu normalnie sterować hamulcem? - } - switch (OrderList[OrderPos]) - { // ustalenie prędkości przy doczepianiu i odczepianiu, dystansów w pozostałych przypadkach - case Connect: // podłączanie do składu - if (iDrivigFlags & moveConnect) - { // jeśli stanął już blisko, unikając zderzenia i można próbować podłączyć - fMinProximityDist = -0.01; - fMaxProximityDist = 0.0; //[m] dojechać maksymalnie - fVelPlus = 0.5; // dopuszczalne przekroczenie prędkości na ograniczeniu bez - // hamowania - fVelMinus = 0.5; // margines prędkości powodujący załączenie napędu - if (AIControllFlag) - { // to robi tylko AI, wersję dla człowieka trzeba dopiero zrobić - // sprzęgi sprawdzamy w pierwszej kolejności, bo jak połączony, to koniec - bool ok; // true gdy się podłączy (uzyskany sprzęg będzie zgodny z żądanym) - if (pVehicles[0]->DirectionGet() > 0) // jeśli sprzęg 0 - { // sprzęg 0 - próba podczepienia - if (pVehicles[0]->MoverParameters->Couplers[0].Connected) // jeśli jest coś - // wykryte (a - // chyba jest, - // nie?) - if (pVehicles[0]->MoverParameters->Attach( - 0, 2, pVehicles[0]->MoverParameters->Couplers[0].Connected, - iCoupler)) - { - // pVehicles[0]->dsbCouplerAttach->SetVolume(DSBVOLUME_MAX); - // pVehicles[0]->dsbCouplerAttach->Play(0,0,0); - } - // WriteLog("CoupleDist[0]="+AnsiString(pVehicles[0]->MoverParameters->Couplers[0].CoupleDist)+", - // Connected[0]="+AnsiString(pVehicles[0]->MoverParameters->Couplers[0].CouplingFlag)); - ok = (pVehicles[0]->MoverParameters->Couplers[0].CouplingFlag == - iCoupler); // udało się? (mogło częściowo) - } - else // if (pVehicles[0]->MoverParameters->DirAbsolute<0) //jeśli sprzęg 1 - { // sprzęg 1 - próba podczepienia - if (pVehicles[0]->MoverParameters->Couplers[1].Connected) // jeśli jest coś - // wykryte (a - // chyba jest, - // nie?) - if (pVehicles[0]->MoverParameters->Attach( - 1, 2, pVehicles[0]->MoverParameters->Couplers[1].Connected, - iCoupler)) - { - // pVehicles[0]->dsbCouplerAttach->SetVolume(DSBVOLUME_MAX); - // pVehicles[0]->dsbCouplerAttach->Play(0,0,0); - } - // WriteLog("CoupleDist[1]="+AnsiString(Controlling->Couplers[1].CoupleDist)+", - // Connected[0]="+AnsiString(Controlling->Couplers[1].CouplingFlag)); - ok = (pVehicles[0]->MoverParameters->Couplers[1].CouplingFlag == - iCoupler); // udało się? (mogło częściowo) - } - if (ok) - { // jeżeli został podłączony - iCoupler = 0; // dalsza jazda manewrowa już bez łączenia - iDrivigFlags &= ~moveConnect; // zdjęcie flagi doczepiania - SetVelocity(0, 0, stopJoin); // wyłączyć przyspieszanie - CheckVehicles(); // sprawdzić światła nowego składu - JumpToNextOrder(); // wykonanie następnej komendy - } - else - SetVelocity(2.0, 0.0); // jazda w ustawionym kierunku z prędkością 2 (18s) - } // if (AIControllFlag) //koniec zblokowania, bo była zmienna lokalna - /* //Ra 2014-02: lepiej tam, bo jak tam się odźwieży skład, to tu pVehicles[0] - będzie czymś innym - else - {//jeśli człowiek ma podłączyć, to czekamy na zmianę stanu sprzęgów na końcach - dotychczasowego składu - bool ok; //true gdy się podłączy (uzyskany sprzęg będzie zgodny z żądanym) - if (pVehicles[0]->DirectionGet()>0) //jeśli sprzęg 0 - ok=(pVehicles[0]->MoverParameters->Couplers[0].CouplingFlag>0); - //==iCoupler); //udało się? (mogło częściowo) - else //if (pVehicles[0]->MoverParameters->DirAbsolute<0) //jeśli sprzęg 1 - ok=(pVehicles[0]->MoverParameters->Couplers[1].CouplingFlag>0); - //==iCoupler); //udało się? (mogło częściowo) - if (ok) - {//jeżeli został podłączony - iDrivigFlags&=~moveConnect; //zdjęcie flagi doczepiania - JumpToNextOrder(); //wykonanie następnej komendy - } - } - */ - } - else - { // jak daleko, to jazda jak dla Shunt na kolizję - fMinProximityDist = 0.0; - fMaxProximityDist = 5.0; //[m] w takim przedziale odległości powinien stanąć - fVelPlus = 2.0; // dopuszczalne przekroczenie prędkości na ograniczeniu bez - // hamowania - fVelMinus = 1.0; // margines prędkości powodujący załączenie napędu - // VelReduced=5; //[km/h] - // if (mvOccupied->Vel<0.5) //jeśli już prawie stanął - if (pVehicles[0]->fTrackBlock <= - 20.0) // przy zderzeniu fTrackBlock nie jest miarodajne - iDrivigFlags |= - moveConnect; // początek podczepiania, z wyłączeniem sprawdzania fTrackBlock - } - break; - case Disconnect: // 20.07.03 - manewrowanie wagonami - fMinProximityDist = 1.0; - fMaxProximityDist = 10.0; //[m] - fVelPlus = 1.0; // dopuszczalne przekroczenie prędkości na ograniczeniu bez hamowania - fVelMinus = 0.5; // margines prędkości powodujący załączenie napędu - if (AIControllFlag) - { - if (iVehicleCount >= 0) // jeśli była podana ilość wagonów - { - if (iDrivigFlags & movePress) // jeśli dociskanie w celu odczepienia - { // 3. faza odczepiania. - SetVelocity(2, 0); // jazda w ustawionym kierunku z prędkością 2 - if ((mvControlling->MainCtrlPos > 0) || - (mvOccupied->BrakeSystem == ElectroPneumatic)) // jeśli jazda - { - WriteLog(mvOccupied->Name + " odczepianie w kierunku " + std::to_string(mvOccupied->DirAbsolute)); - TDynamicObject *p = - pVehicle; // pojazd do odczepienia, w (pVehicle) siedzi AI - int d; // numer sprzęgu, który sprawdzamy albo odczepiamy - int n = iVehicleCount; // ile wagonów ma zostać - do - { // szukanie pojazdu do odczepienia - d = p->DirectionGet() > 0 ? - 0 : - 1; // numer sprzęgu od strony czoła składu - // if (p->MoverParameters->Couplers[d].CouplerType==Articulated) - // //jeśli sprzęg typu wózek (za mało) - if (p->MoverParameters->Couplers[d].CouplingFlag & - ctrain_depot) // jeżeli sprzęg zablokowany - // if (p->GetTrack()->) //a nie stoi na torze warsztatowym - // (ustalić po czym poznać taki tor) - ++n; // to liczymy człony jako jeden - p->MoverParameters->BrakeReleaser( - 1); // wyluzuj pojazd, aby dało się dopychać - p->MoverParameters->BrakeLevelSet( - 0); // hamulec na zero, aby nie hamował - if (n) - { // jeśli jeszcze nie koniec - p = p->Prev(); // kolejny w stronę czoła składu (licząc od - // tyłu), bo dociskamy - if (!p) - iVehicleCount = -2, - n = 0; // nie ma co dalej sprawdzać, doczepianie zakończone - } - } while (n--); - if (p ? p->MoverParameters->Couplers[d].CouplingFlag == 0 : true) - iVehicleCount = -2; // odczepiono, co było do odczepienia - else if (!p->Dettach(d)) // zwraca maskę bitową połączenia; usuwa - // własność pojazdów - { // tylko jeśli odepnie - WriteLog( mvOccupied->Name + " odczepiony." ); - iVehicleCount = -2; - } // a jak nie, to dociskać dalej - } - if (iVehicleCount >= 0) // zmieni się po odczepieniu - if (!mvOccupied->DecLocalBrakeLevel(1)) - { // dociśnij sklad - WriteLog( mvOccupied->Name + " dociskanie..." ); - // mvOccupied->BrakeReleaser(); //wyluzuj lokomotywę - // Ready=true; //zamiast sprawdzenia odhamowania całego składu - IncSpeed(); // dla (Ready)==false nie ruszy - } - } - if ((mvOccupied->Vel == 0.0) && !(iDrivigFlags & movePress)) - { // 2. faza odczepiania: zmień kierunek na przeciwny i dociśnij - // za radą yB ustawiamy pozycję 3 kranu (ruszanie kranem w innych miejscach - // powino zostać wyłączone) - // WriteLog("Zahamowanie składu"); - // while ((mvOccupied->BrakeCtrlPos>3)&&mvOccupied->DecBrakeLevel()); - // while ((mvOccupied->BrakeCtrlPos<3)&&mvOccupied->IncBrakeLevel()); - mvOccupied->BrakeLevelSet(mvOccupied->BrakeSystem == ElectroPneumatic ? 1 : - 3); - double p = mvOccupied->BrakePressureActual - .PipePressureVal; // tu może być 0 albo -1 nawet - if (p < 3.9) - p = 3.9; // TODO: zabezpieczenie przed dziwnymi CHK do czasu wyjaśnienia - // sensu 0 oraz -1 w tym miejscu - if (mvOccupied->BrakeSystem == ElectroPneumatic ? - mvOccupied->BrakePress > 2 : - mvOccupied->PipePress < p + 0.1) - { // jeśli w miarę został zahamowany (ciśnienie mniejsze niż podane na - // pozycji 3, zwyle 0.37) - if (mvOccupied->BrakeSystem == ElectroPneumatic) - mvOccupied->BrakeLevelSet(0); // wyłączenie EP, gdy wystarczy (może - // nie być potrzebne, bo na początku - // jest) - WriteLog("Luzowanie lokomotywy i zmiana kierunku"); - mvOccupied->BrakeReleaser(1); // wyluzuj lokomotywę; a ST45? - mvOccupied->DecLocalBrakeLevel(10); // zwolnienie hamulca - iDrivigFlags |= movePress; // następnie będzie dociskanie - DirectionForward(mvOccupied->ActiveDir < - 0); // zmiana kierunku jazdy na przeciwny (dociskanie) - CheckVehicles(); // od razu zmienić światła (zgasić) - bez tego się nie - // odczepi - fStopTime = 0.0; // nie ma na co czekać z odczepianiem - } - } - } // odczepiania - else // to poniżej jeśli ilość wagonów ujemna - if (iDrivigFlags & movePress) - { // 4. faza odczepiania: zwolnij i zmień kierunek - SetVelocity(0, 0, stopJoin); // wyłączyć przyspieszanie - if (!DecSpeed()) // jeśli już bardziej wyłączyć się nie da - { // ponowna zmiana kierunku - WriteLog( mvOccupied->Name + " ponowna zmiana kierunku" ); - DirectionForward(mvOccupied->ActiveDir < - 0); // zmiana kierunku jazdy na właściwy - iDrivigFlags &= ~movePress; // koniec dociskania - JumpToNextOrder(); // zmieni światła - TableClear(); // skanowanie od nowa - iDrivigFlags &= ~moveStartHorn; // bez trąbienia przed ruszeniem - SetVelocity(fShuntVelocity, fShuntVelocity); // ustawienie prędkości jazdy - } - } - } - break; - case Shunt: - // na jaką odleglość i z jaką predkością ma podjechać - fMinProximityDist = 2.0; - fMaxProximityDist = 4.0; //[m] - fVelPlus = 2.0; // dopuszczalne przekroczenie prędkości na ograniczeniu bez hamowania - fVelMinus = 3.0; // margines prędkości powodujący załączenie napędu - if (fVelMinus > 0.1 * fShuntVelocity) - fVelMinus = - 0.1 * - fShuntVelocity; // były problemy z jazdą np. 3km/h podczas ładowania wagonów - break; - case Obey_train: - // na jaka odleglosc i z jaka predkoscia ma podjechac do przeszkody - if (mvOccupied->CategoryFlag & 1) // jeśli pociąg - { - fMinProximityDist = 10.0; - fMaxProximityDist = - (mvOccupied->Vel > 0.0) ? - 20.0 : - 50.0; //[m] jak stanie za daleko, to niech nie dociąga paru metrów - if (iDrivigFlags & moveLate) - { - fVelMinus = 1.0; // jeśli spóźniony, to gna - fVelPlus = - 5.0; // dopuszczalne przekroczenie prędkości na ograniczeniu bez hamowania - } - else - { // gdy nie musi się sprężać - fVelMinus = - int(0.05 * VelDesired); // margines prędkości powodujący załączenie napędu - if (fVelMinus > 5.0) - fVelMinus = 5.0; - else if (fVelMinus < 1.0) - fVelMinus = 1.0; //żeby nie ruszał przy 0.1 - fVelPlus = int( - 0.5 + - 0.05 * VelDesired); // normalnie dopuszczalne przekroczenie to 5% prędkości - if (fVelPlus > 5.0) - fVelPlus = 5.0; // ale nie więcej niż 5km/h - } - } - else // samochod (sokista też) - { - fMinProximityDist = 7.0; - fMaxProximityDist = 10.0; //[m] - fVelPlus = - 10.0; // dopuszczalne przekroczenie prędkości na ograniczeniu bez hamowania - fVelMinus = 2.0; // margines prędkości powodujący załączenie napędu - } - // VelReduced=4; //[km/h] - break; - default: - fMinProximityDist = 0.01; - fMaxProximityDist = 2.0; //[m] - fVelPlus = 2.0; // dopuszczalne przekroczenie prędkości na ograniczeniu bez hamowania - fVelMinus = 5.0; // margines prędkości powodujący załączenie napędu - } // switch - switch (OrderList[OrderPos]) - { // co robi maszynista - case Prepare_engine: // odpala silnik - // if (AIControllFlag) - if (PrepareEngine()) // dla użytkownika tylko sprawdza, czy uruchomił - { // gotowy do drogi? - SetDriverPsyche(); - // OrderList[OrderPos]:=Shunt; //Ra: to nie może tak być, bo scenerie robią - // Jump_to_first_order i przechodzi w manewrowy - JumpToNextOrder(); // w następnym jest Shunt albo Obey_train, moze też być - // Change_direction, Connect albo Disconnect - // if OrderList[OrderPos]<>Wait_for_Orders) - // if BrakeSystem=Pneumatic) //napelnianie uderzeniowe na wstepie - // if BrakeSubsystem=Oerlikon) - // if (BrakeCtrlPos=0)) - // DecBrakeLevel; - } - break; - case Release_engine: - if( ReleaseEngine() ) // zdana maszyna? - JumpToNextOrder(); - break; - case Jump_to_first_order: - if (OrderPos > 1) - OrderPos = 1; // w zerowym zawsze jest czekanie - else - ++OrderPos; -#if LOGORDERS - WriteLog("--> Jump_to_first_order"); - OrdersDump(); -#endif - break; - case Wait_for_orders: // jeśli czeka, też ma skanować, żeby odpalić się od semafora - /* - if ((mvOccupied->ActiveDir!=0)) - {//jeśli jest wybrany kierunek jazdy, można ustalić prędkość jazdy - VelDesired=fVelMax; //wstępnie prędkość maksymalna dla pojazdu(-ów), będzie następnie - ograniczana - SetDriverPsyche(); //ustawia AccPreferred (potrzebne tu?) - //Ra: odczyt (ActualProximityDist), (VelNext) i (AccPreferred) z tabelki prędkosci - AccDesired=AccPreferred; //AccPreferred wynika z osobowości mechanika - VelNext=VelDesired; //maksymalna prędkość wynikająca z innych czynników niż - trajektoria ruchu - ActualProximityDist=scanmax; //funkcja Update() może pozostawić wartości bez zmian - //hm, kiedyś semafory wysyłały SetVelocity albo ShuntVelocity i ustawły tak VelSignal - - a teraz jak to zrobić? - TCommandType - comm=TableUpdate(mvOccupied->Vel,VelDesired,ActualProximityDist,VelNext,AccDesired); - //szukanie optymalnych wartości - } - */ - // break; - case Shunt: - case Obey_train: - case Connect: - case Disconnect: - case Change_direction: // tryby wymagające jazdy - case Change_direction | Shunt: // zmiana kierunku podczas manewrów - case Change_direction | Connect: // zmiana kierunku podczas podłączania - if (OrderList[OrderPos] != Obey_train) // spokojne manewry - { - VelSignal = Global::Min0RSpeed(VelSignal, 40); // jeśli manewry, to ograniczamy prędkość - if (AIControllFlag) - { // to poniżej tylko dla AI - if (iVehicleCount >= 0) // jeśli jest co odczepić - if (!(iDrivigFlags & movePress)) - if (mvOccupied->Vel > 0.0) - if (!iCoupler) // jeśli nie ma wcześniej potrzeby podczepienia - { - SetVelocity(0, 0, stopJoin); // 1. faza odczepiania: zatrzymanie - // WriteLog("Zatrzymanie w celu odczepienia"); - } - } - } - else - SetDriverPsyche(); // Ra: było w PrepareEngine(), potrzebne tu? - // no albo przypisujemy -WaitingExpireTime, albo porównujemy z WaitingExpireTime - // if - // ((VelSignal==0.0)&&(WaitingTime>WaitingExpireTime)&&(mvOccupied->RunningTrack.Velmax!=0.0)) - if (OrderList[OrderPos] & - (Shunt | Obey_train | Connect)) // odjechać sam może tylko jeśli jest w trybie jazdy - { // automatyczne ruszanie po odstaniu albo spod SBL - if ((VelSignal == 0.0) && (WaitingTime > 0.0) && - (mvOccupied->RunningTrack.Velmax != 0.0)) - { // jeśli stoi, a upłynął czas oczekiwania i tor ma niezerową prędkość - /* - if (WriteLogFlag) - { - append(AIlogFile); - writeln(AILogFile,ElapsedTime:5:2,": ",Name," V=0 waiting time expired! - (",WaitingTime:4:1,")"); - close(AILogFile); - } - */ - if ((OrderList[OrderPos] & (Obey_train | Shunt)) ? - (iDrivigFlags & moveStopHere) : - false) - WaitingTime = -WaitingExpireTime; // zakaz ruszania z miejsca bez otrzymania - // wolnej drogi - else if (mvOccupied->CategoryFlag & 1) - { // jeśli pociąg - if (AIControllFlag) - { - PrepareEngine(); // zmieni ustawiony kierunek - SetVelocity(20, 20); // jak się nastał, to niech jedzie 20km/h - WaitingTime = 0.0; - fWarningDuration = 1.5; // a zatrąbić trochę - mvOccupied->WarningSignal = 1; - } - else - SetVelocity(20, 20); // użytkownikowi zezwalamy jechać - } - else - { // samochód ma stać, aż dostanie odjazd, chyba że stoi przez kolizję - if (eStopReason == stopBlock) - if (pVehicles[0]->fTrackBlock > fDriverDist) - if (AIControllFlag) - { - PrepareEngine(); // zmieni ustawiony kierunek - SetVelocity(-1, -1); // jak się nastał, to niech jedzie - WaitingTime = 0.0; - } - else - SetVelocity(-1, - -1); // użytkownikowi pozwalamy jechać (samochodem?) - } - } - else if ((VelSignal == 0.0) && (VelNext > 0.0) && (mvOccupied->Vel < 1.0)) - if (iCoupler ? true : (iDrivigFlags & moveStopHere) == 0) // Ra: tu jest coś nie - // tak, bo bez tego - // warunku ruszało w - // manewrowym !!!! - SetVelocity(VelNext, VelNext, stopSem); // omijanie SBL - } // koniec samoistnego odjeżdżania - if (AIControllFlag) - if ((HelpMeFlag) || (mvControlling->DamageFlag > 0)) - { - HelpMeFlag = false; - /* - if (WriteLogFlag) - with Controlling do - { - append(AIlogFile); - writeln(AILogFile,ElapsedTime:5:2,": ",Name," HelpMe! - (",DamageFlag,")"); - close(AILogFile); - } - */ - } - if (AIControllFlag) - if (OrderList[OrderPos] & - Change_direction) // może być zmieszane z jeszcze jakąś komendą - { // sprobuj zmienic kierunek - SetVelocity(0, 0, stopDir); // najpierw trzeba się zatrzymać - if (mvOccupied->Vel < 0.1) - { // jeśli się zatrzymał, to zmieniamy kierunek jazdy, a nawet kabinę/człon - Activation(); // ustawienie zadanego wcześniej kierunku i ewentualne - // przemieszczenie AI - PrepareEngine(); - JumpToNextOrder(); // następnie robimy, co jest do zrobienia (Shunt albo - // Obey_train) - if (OrderList[OrderPos] & (Shunt | Connect)) // jeśli dalej mamy manewry - if ((iDrivigFlags & moveStopHere) == 0) // o ile nie stać w miejscu - { // jechać od razu w przeciwną stronę i nie trąbić z tego tytułu - iDrivigFlags &= ~moveStartHorn; // bez trąbienia przed ruszeniem - SetVelocity(fShuntVelocity, fShuntVelocity); // to od razu jedziemy - } - // iDrivigFlags|=moveStartHorn; //a później już można trąbić - /* - if (WriteLogFlag) - { - append(AIlogFile); - writeln(AILogFile,ElapsedTime:5:2,": ",Name," Direction changed!"); - close(AILogFile); - } - */ - } - // else - // VelSignal:=0.0; //na wszelki wypadek niech zahamuje - } // Change_direction (tylko dla AI) - // ustalanie zadanej predkosci - if (AIControllFlag) // jeśli prowadzi AI - if (!iEngineActive) // jeśli silnik nie odpalony, to próbować naprawić - if (OrderList[OrderPos] & (Change_direction | Connect | Disconnect | Shunt | - Obey_train)) // jeśli coś ma robić - PrepareEngine(); // to niech odpala do skutku - if (iDrivigFlags & moveActive) // jeśli może skanować sygnały i reagować na komendy - { // jeśli jest wybrany kierunek jazdy, można ustalić prędkość jazdy - // Ra: tu by jeszcze trzeba było wstawić uzależnienie (VelDesired) od odległości od - // przeszkody - // no chyba żeby to uwzgldnić już w (ActualProximityDist) - VelDesired = fVelMax; // wstępnie prędkość maksymalna dla pojazdu(-ów), będzie - // następnie ograniczana - if (TrainParams) // jeśli ma rozkład - if (TrainParams->TTVmax > 0.0) // i ograniczenie w rozkładzie - VelDesired = Global::Min0RSpeed(VelDesired, - TrainParams->TTVmax); // to nie przekraczać rozkladowej - SetDriverPsyche(); // ustawia AccPreferred (potrzebne tu?) - // Ra: odczyt (ActualProximityDist), (VelNext) i (AccPreferred) z tabelki prędkosci - AccDesired = AccPreferred; // AccPreferred wynika z osobowości mechanika - VelNext = VelDesired; // maksymalna prędkość wynikająca z innych czynników niż - // trajektoria ruchu - ActualProximityDist = scanmax; // funkcja Update() może pozostawić wartości bez - // zmian - // hm, kiedyś semafory wysyłały SetVelocity albo ShuntVelocity i ustawły tak - // VelSignal - a teraz jak to zrobić? - TCommandType comm = TableUpdate(VelDesired, ActualProximityDist, VelNext, - AccDesired); // szukanie optymalnych wartości - // if (VelSignal!=VelDesired) //jeżeli prędkość zalecana jest inna (ale tryb też - // może być inny) - switch (comm) - { // ustawienie VelSignal - trochę proteza = do przemyślenia - case cm_Ready: // W4 zezwolił na jazdę - TableCheck( - scanmax); // ewentualne doskanowanie trasy za W4, który zezwolił na jazdę - TableUpdate(VelDesired, ActualProximityDist, VelNext, - AccDesired); // aktualizacja po skanowaniu - // if (comm!=cm_SetVelocity) //jeśli dalej jest kolejny W4, to ma zwrócić - // cm_SetVelocity - if (VelNext == 0.0) - break; // ale jak coś z przodu zamyka, to ma stać - if (iDrivigFlags & moveStopCloser) - VelSignal = -1.0; // niech jedzie, jak W4 puściło - nie, ma czekać na - // sygnał z sygnalizatora! - case cm_SetVelocity: // od wersji 357 semafor nie budzi wyłączonej lokomotywy - if (!(OrderList[OrderPos] & - ~(Obey_train | Shunt))) // jedzie w dowolnym trybie albo Wait_for_orders - if (fabs(VelSignal) >= - 1.0) // 0.1 nie wysyła się do samochodow, bo potem nie ruszą - PutCommand("SetVelocity", VelSignal, VelNext, - NULL); // komenda robi dodatkowe operacje - break; - case cm_ShuntVelocity: // od wersji 357 Tm nie budzi wyłączonej lokomotywy - if (!(OrderList[OrderPos] & - ~(Obey_train | Shunt))) // jedzie w dowolnym trybie albo Wait_for_orders - PutCommand("ShuntVelocity", VelSignal, VelNext, NULL); - else if (iCoupler) // jeśli jedzie w celu połączenia - SetVelocity(VelSignal, VelNext); - break; - case cm_Command: // komenda z komórki - if (!(OrderList[OrderPos] & - ~(Obey_train | Shunt))) // jedzie w dowolnym trybie albo Wait_for_orders - if (mvOccupied->Vel < 0.1) // dopiero jak stanie - // iDrivigFlags|=moveStopHere moveStopCloser) //chyba że stanął za daleko - // (SU46 w WK staje za daleko) - { - PutCommand(eSignNext->CommandGet(), eSignNext->ValueGet(1), - eSignNext->ValueGet(2), NULL); - eSignNext->StopCommandSent(); // się wykonało już - } - break; - } - if (VelNext == 0.0) - if (!(OrderList[OrderPos] & - ~(Shunt | Connect))) // jedzie w Shunt albo Connect, albo Wait_for_orders - { // jeżeli wolnej drogi nie ma, a jest w trybie manewrowym albo oczekiwania - // if - // ((OrderList[OrderPos]&Connect)?pVehicles[0]->fTrackBlock>ActualProximityDist:true) - // //pomiar odległości nie działa dobrze? - // w trybie Connect skanować do tyłu tylko jeśli przed kolejnym sygnałem nie - // ma taboru do podłączenia - // Ra 2F1H: z tym (fTrackBlock) to nie jest najlepszy pomysł, bo lepiej by - // było porównać z odległością od sygnalizatora z przodu - if ((OrderList[OrderPos] & Connect) ? (pVehicles[0]->fTrackBlock > 2000 || pVehicles[0]->fTrackBlock > FirstSemaphorDist) : - true) - if ((comm = BackwardScan()) != cm_Unknown) // jeśli w drugą można jechać - { // należy sprawdzać odległość od znalezionego sygnalizatora, - // aby w przypadku prędkości 0.1 wyciągnąć najpierw skład za - // sygnalizator - // i dopiero wtedy zmienić kierunek jazdy, oczekując podania - // prędkości >0.5 - if (comm == cm_Command) // jeśli komenda Shunt - iDrivigFlags |= - moveStopHere; // to ją odbierz bez przemieszczania się (np. - // odczep wagony po dopchnięciu do końca toru) - iDirectionOrder = -iDirection; // zmiana kierunku jazdy - OrderList[OrderPos] = TOrders(OrderList[OrderPos] | - Change_direction); // zmiana kierunku - // bez psucia - // kolejnych komend - } - } - double vel = mvOccupied->Vel; // prędkość w kierunku jazdy - if (iDirection * mvOccupied->V < 0) - vel = -vel; // ujemna, gdy jedzie w przeciwną stronę, niż powinien - if (VelDesired < 0.0) - VelDesired = fVelMax; // bo VelDesired<0 oznacza prędkość maksymalną - // Ra: jazda na widoczność - if (pVehicles[0]->fTrackBlock < 1000.0) // przy 300m stał z zapamiętaną kolizją - { // Ra 2F3F: przy jeździe pociągowej nie powinien dojeżdżać do poprzedzającego - // składu - if ((mvOccupied->CategoryFlag & 1) ? - ((OrderCurrentGet() & (Connect | Obey_train)) == Obey_train) : - false) // jeśli jesteśmy pociągiem a jazda pociągowa i nie ściąganie ze - // szlaku - { - pVehicles[0]->ABuScanObjects(pVehicles[0]->DirectionGet(), - 1000.0); // skanowanie sprawdzające - // Ra 2F3F: i jest problem, jak droga za semaforem kieruje na jakiś pojazd - // (np. w Skwarkach na ET22) - if (pVehicles[0]->fTrackBlock < 1000.0) // i jeśli nadal coś jest - if (VelNext != 0.0) // a następny sygnał zezwala na jazdę - if (pVehicles[0]->fTrackBlock < - ActualProximityDist) // i jest bliżej (tu by trzeba było wstawić - // odległość do semafora, z pominięciem SBL - VelDesired = 0.0; // to stoimy - } - else - pVehicles[0]->ABuScanObjects(pVehicles[0]->DirectionGet(), - 300.0); // skanowanie sprawdzające - } - // if (mvOccupied->Vel>=0.1) //o ile jedziemy; jak stoimy to też trzeba jakoś - // zatrzymywać - if ((iDrivigFlags & moveConnect) == 0) // przy końcówce podłączania nie hamować - { // sprawdzenie jazdy na widoczność - TCoupling *c = - pVehicles[0]->MoverParameters->Couplers + - (pVehicles[0]->DirectionGet() > 0 ? 0 : 1); // sprzęg z przodu składu - if (c->Connected) // a mamy coś z przodu - if (c->CouplingFlag == - 0) // jeśli to coś jest podłączone sprzęgiem wirtualnym - { // wyliczanie optymalnego przyspieszenia do jazdy na widoczność - double k = c->Connected->Vel; // prędkość pojazdu z przodu (zakładając, - // że jedzie w tę samą stronę!!!) - if (k < vel + 10) // porównanie modułów prędkości [km/h] - { // zatroszczyć się trzeba, jeśli tamten nie jedzie znacząco szybciej - double d = - pVehicles[0]->fTrackBlock - 0.5 * vel - - fMaxProximityDist; // odległość bezpieczna zależy od prędkości - if (d < 0) // jeśli odległość jest zbyt mała - { // AccPreferred=-0.9; //hamowanie maksymalne, bo jest za blisko - if (k < 10.0) // k - prędkość tego z przodu - { // jeśli tamten porusza się z niewielką prędkością albo stoi - if (OrderCurrentGet() & Connect) - { // jeśli spinanie, to jechać dalej - AccPreferred = 0.2; // nie hamuj - VelNext = VelDesired = 2.0; // i pakuj się na tamtego - } - else // a normalnie to hamować - { - AccPreferred = -1.0; // to hamuj maksymalnie - VelNext = VelDesired = 0.0; // i nie pakuj się na - // tamtego - } - } - else // jeśli oba jadą, to przyhamuj lekko i ogranicz prędkość - { - if (k < vel) // jak tamten jedzie wolniej - if (d < fBrakeDist) // a jest w drodze hamowania - { - if (AccPreferred > fAccThreshold) - AccPreferred = - fAccThreshold; // to przyhamuj troszkę - VelNext = VelDesired = int(k); // to chyba już sobie - // dohamuje według - // uznania - } - } - ReactionTime = 0.1; // orientuj się, bo jest goraco - } - else - { // jeśli odległość jest większa, ustalić maksymalne możliwe - // przyspieszenie (hamowanie) - k = (k * k - vel * vel) / (25.92 * d); // energia kinetyczna - // dzielona przez masę i - // drogę daje - // przyspieszenie - if (k > 0.0) - k *= 1.5; // jedź szybciej, jeśli możesz - // double ak=(c->Connected->V>0?1.0:-1.0)*c->Connected->AccS; - // //przyspieszenie tamtego - if (d < fBrakeDist) // a jest w drodze hamowania - if (k < AccPreferred) - { // jeśli nie ma innych powodów do wolniejszej jazdy - AccPreferred = k; - if (VelNext > c->Connected->Vel) - { - VelNext = - c->Connected - ->Vel; // ograniczenie do prędkości tamtego - ActualProximityDist = - d; // i odległość od tamtego jest istotniejsza - } - ReactionTime = 0.2; // zwiększ czujność - } -#if LOGVELOCITY - WriteLog("Collision: AccPreferred=" + AnsiString(k)); -#endif - } - } - } - } - // sprawdzamy możliwe ograniczenia prędkości - if (OrderCurrentGet() & (Shunt | Obey_train)) // w Connect nie, bo moveStopHere - // odnosi się do stanu po połączeniu - if (iDrivigFlags & moveStopHere) // jeśli ma czekać na wolną drogę - if (vel == 0.0) // a stoi - if (VelNext == 0.0) // a wyjazdu nie ma - VelDesired = 0.0; // to ma stać - if (fStopTime < 0) // czas postoju przed dalszą jazdą (np. na przystanku) - VelDesired = 0.0; // jak ma czekać, to nie ma jazdy - // else if (VelSignal<0) - // VelDesired=fVelMax; //ile fabryka dala (Ra: uwzględione wagony) - else if (VelSignal >= 0) // jeśli skład był zatrzymany na początku i teraz już może jechać - VelDesired = Global::Min0RSpeed(VelDesired, VelSignal); - - if (mvOccupied->RunningTrack.Velmax >= - 0) // ograniczenie prędkości z trajektorii ruchu - VelDesired = - Global::Min0RSpeed(VelDesired, - mvOccupied->RunningTrack.Velmax); // uwaga na ograniczenia szlakowej! - if (VelforDriver >= 0) // tu jest zero przy zmianie kierunku jazdy - VelDesired = Global::Min0RSpeed(VelDesired, VelforDriver); // Ra: tu może być 40, jeśli - // mechanik nie ma znajomości - // szlaaku, albo kierowca jeździ - // 70 - if (TrainParams) - if (TrainParams->CheckTrainLatency() < 5.0) - if (TrainParams->TTVmax > 0.0) - VelDesired = Global::Min0RSpeed( - VelDesired, - TrainParams - ->TTVmax); // jesli nie spozniony to nie przekraczać rozkladowej - if (VelDesired > 0.0) - if ((sSemNext && sSemNext->fVelNext != 0.0) || (iDrivigFlags & moveStopHere)==0) - { // jeśli można jechać, to odpalić dźwięk kierownika oraz zamknąć drzwi w - // składzie, jeśli nie mamy czekać na sygnał też trzeba odpalić - - if (iDrivigFlags & moveGuardSignal) - { // komunikat od kierownika tu, bo musi być wolna droga i odczekany czas - // stania - iDrivigFlags &= ~moveGuardSignal; // tylko raz nadać - - if( iDrivigFlags & moveDoorOpened ) // jeśli drzwi otwarte - if( !mvOccupied - ->DoorOpenCtrl ) // jeśli drzwi niesterowane przez maszynistę - Doors( false ); // a EZT zamknie dopiero po odegraniu komunikatu kierownika - - tsGuardSignal->Stop(); - // w zasadzie to powinien mieć flagę, czy jest dźwiękiem radiowym, czy - // bezpośrednim - // albo trzeba zrobić dwa dźwięki, jeden bezpośredni, słyszalny w - // pobliżu, a drugi radiowy, słyszalny w innych lokomotywach - // na razie zakładam, że to nie jest dźwięk radiowy, bo trzeba by zrobić - // obsługę kanałów radiowych itd. - if (!iGuardRadio) // jeśli nie przez radio - tsGuardSignal->Play( - 1.0, 0, !FreeFlyModeFlag, - pVehicle->GetPosition()); // dla true jest głośniej - else - // if (iGuardRadio==iRadioChannel) //zgodność kanału - // if (!FreeFlyModeFlag) //obserwator musi być w środku pojazdu - // (albo może mieć radio przenośne) - kierownik mógłby powtarzać - // przy braku reakcji - if (SquareMagnitude(pVehicle->GetPosition() - - Global::pCameraPosition) < - 2000 * 2000) // w odległości mniejszej niż 2km - tsGuardSignal->Play( - 1.0, 0, true, - pVehicle->GetPosition()); // dźwięk niby przez radio - } - } - if (mvOccupied->V == 0.0) - AbsAccS = fAccGravity; // Ra 2014-03: jesli skład stoi, to działa na niego - // składowa styczna grawitacji - else - AbsAccS = iDirection * mvOccupied->AccS; // przyspieszenie chwilowe, liczone -// jako różnica skierowanej prędkości w -// czasie -// if (mvOccupied->V<0.0) AbsAccS=-AbsAccS; //Ra 2014-03: to trzeba przemyśleć -// if (vel<0) //jeżeli się stacza w tył; 2014-03: to jest bez sensu, bo vel>=0 -// AbsAccS=-AbsAccS; //to przyspieszenie też działa wtedy w nieodpowiednią stronę -// AbsAccS+=fAccGravity; //wypadkowe przyspieszenie (czy to ma sens?) -#if LOGVELOCITY - // WriteLog("VelDesired="+AnsiString(VelDesired)+", - // VelSignal="+AnsiString(VelSignal)); - WriteLog("Vel=" + AnsiString(vel) + ", AbsAccS=" + AnsiString(AbsAccS) + - ", AccGrav=" + AnsiString(fAccGravity)); -#endif - // ustalanie zadanego przyspieszenia - //(ActualProximityDist) - odległość do miejsca zmniejszenia prędkości - //(AccPreferred) - wynika z psychyki oraz uwzglęnia już ewentualne zderzenie z - // pojazdem z przodu, ujemne gdy należy hamować - //(AccDesired) - uwzględnia sygnały na drodze ruchu, ujemne gdy należy hamować - //(fAccGravity) - chwilowe przspieszenie grawitacyjne, ujemne działa przeciwnie do - // zadanego kierunku jazdy - //(AbsAccS) - chwilowe przyspieszenie pojazu (uwzględnia grawitację), ujemne działa - // przeciwnie do zadanego kierunku jazdy - //(AccDesired) porównujemy z (fAccGravity) albo (AbsAccS) - // if ((VelNext>=0.0)&&(ActualProximityDist>=0)&&(mvOccupied->Vel>=VelNext)) //gdy - // zbliza sie i jest za szybko do NOWEGO - if ((VelNext >= 0.0) && (ActualProximityDist <= scanmax) && (vel >= VelNext)) - { // gdy zbliża się i jest za szybki do nowej prędkości, albo stoi na zatrzymaniu - if (vel > 0.0) - { // jeśli jedzie - if ((vel < VelNext) ? - (ActualProximityDist > fMaxProximityDist * (1 + 0.1 * vel)) : - false) // dojedz do semafora/przeszkody - { // jeśli jedzie wolniej niż można i jest wystarczająco daleko, to można - // przyspieszyć - if (AccPreferred > 0.0) // jeśli nie ma zawalidrogi - AccDesired = AccPreferred; - // VelDesired:=Min0R(VelDesired,VelReduced+VelNext); - } - else if (ActualProximityDist > fMinProximityDist) - { // jedzie szybciej, niż trzeba na końcu ActualProximityDist, ale jeszcze - // jest daleko - if (vel < - VelNext + 40.0) // dwustopniowe hamowanie - niski przy małej różnicy - { // jeśli jedzie wolniej niż VelNext+35km/h //Ra: 40, żeby nie - // kombinował na zwrotnicach - if (VelNext == 0.0) - { // jeśli ma się zatrzymać, musi być to robione precyzyjnie i - // skutecznie - if (ActualProximityDist < - fMaxProximityDist) // jak minął już maksymalny dystans - { // po prostu hamuj (niski stopień) //ma stanąć, a jest w - // drodze hamowania albo ma jechać - AccDesired = fAccThreshold; // hamowanie tak, aby stanąć - VelDesired = 0.0; // Min0R(VelDesired,VelNext); - } - else if (ActualProximityDist > fBrakeDist) - { // jeśli ma stanąć, a mieści się w drodze hamowania - if (vel < 10.0) // jeśli prędkość jest łatwa do zatrzymania - { // tu jest trochę problem, bo do punktu zatrzymania dobija - // na raty - // AccDesired=AccDesired<0.0?0.0:0.1*AccPreferred; - AccDesired = AccPreferred; // proteza trochę; jak tu - // wychodzi 0.05, to loki - // mają problem utrzymać - // takie przyspieszenie - } - else if (vel <= 30.0) // trzymaj 30 km/h - AccDesired = Min0R(0.5 * AccDesired, - AccPreferred); // jak jest tu 0.5, to - // samochody się - // dobijają do siebie - else - AccDesired = 0.0; - } - else // 25.92 (=3.6*3.6*2) - przelicznik z km/h na m/s - if (vel < - VelNext + fVelPlus) // jeśli niewielkie przekroczenie - // AccDesired=0.0; - AccDesired = Min0R(0.0, AccPreferred); // proteza trochę: to - // niech nie hamuje, - // chyba że coś z - // przodu - else - AccDesired = -(vel * vel) / - (25.92 * (ActualProximityDist + - 0.1)); //-fMinProximityDist));//-0.1; - ////mniejsze opóźnienie przy - // małej różnicy - ReactionTime = 0.1; // i orientuj się szybciej, jak masz stanąć - } - else if (vel < VelNext + fVelPlus) // jeśli niewielkie - // przekroczenie, ale ma jechać - AccDesired = - Min0R(0.0, AccPreferred); // to olej (zacznij luzować) - else - { // jeśli większe przekroczenie niż fVelPlus [km/h], ale ma jechać - // Ra 2F1I: jak było (VelNext+fVelPlus) tu, to hamował zbyt - // późno przed 40, a potem zbyt mocno i zwalniał do 30 - AccDesired = (VelNext * VelNext - vel * vel) / - (25.92 * ActualProximityDist + - 0.1); // mniejsze opóźnienie przy małej różnicy - if (ActualProximityDist < fMaxProximityDist) - ReactionTime = 0.1; // i orientuj się szybciej, jeśli w - // krytycznym przedziale - } - } - else // przy dużej różnicy wysoki stopień (1,25 potrzebnego opoznienia) - AccDesired = (VelNext * VelNext - vel * vel) / - (20.73 * ActualProximityDist + - 0.1); // najpierw hamuje mocniej, potem zluzuje - if (AccPreferred < AccDesired) - AccDesired = AccPreferred; //(1+abs(AccDesired)) - // ReactionTime=0.5*mvOccupied->BrakeDelay[2+2*mvOccupied->BrakeDelayFlag]; - // //aby szybkosc hamowania zalezala od przyspieszenia i opoznienia - // hamulcow - // fBrakeTime=0.5*mvOccupied->BrakeDelay[2+2*mvOccupied->BrakeDelayFlag]; - // //aby szybkosc hamowania zalezala od przyspieszenia i opoznienia - // hamulcow - } - else - { // jest bliżej niż fMinProximityDist - VelDesired = - Min0R(VelDesired, VelNext); // utrzymuj predkosc bo juz blisko - if (vel < - VelNext + fVelPlus) // jeśli niewielkie przekroczenie, ale ma jechać - AccDesired = Min0R(0.0, AccPreferred); // to olej (zacznij luzować) - ReactionTime = 0.1; // i orientuj się szybciej - } - } - else // zatrzymany (vel==0.0) - // if (iDrivigFlags&moveStopHere) //to nie dotyczy podczepiania - // if ((VelNext>0.0)||(ActualProximityDist>fMaxProximityDist*1.2)) - if (VelNext > 0.0) - AccDesired = AccPreferred; // można jechać - else // jeśli daleko jechać nie można - if (ActualProximityDist > - fMaxProximityDist) // ale ma kawałek do sygnalizatora - { // if ((iDrivigFlags&moveStopHere)?false:AccPreferred>0) - if (AccPreferred > 0) - AccDesired = AccPreferred; // dociagnij do semafora; - else - VelDesired = 0.0; //,AccDesired=-fabs(fAccGravity); //stoj (hamuj z siłą - // równą składowej stycznej grawitacji) - } - else - VelDesired = 0.0; // VelNext=0 i stoi bliżej niż fMaxProximityDist - } - else // gdy jedzie wolniej niż potrzeba, albo nie ma przeszkód na drodze - AccDesired = (VelDesired != 0.0 ? AccPreferred : -0.01); // normalna jazda - // koniec predkosci nastepnej - if ((VelDesired >= 0.0) && - (vel > VelDesired)) // jesli jedzie za szybko do AKTUALNEGO - if (VelDesired == 0.0) // jesli stoj, to hamuj, ale i tak juz za pozno :) - AccDesired = -0.9; // hamuj solidnie - else if ((vel < VelDesired + fVelPlus)) // o 5 km/h to olej - { - if ((AccDesired > 0.0)) - AccDesired = 0.0; - } - else - AccDesired = fAccThreshold; // hamuj tak średnio - // koniec predkosci aktualnej - if (fAccThreshold > -0.3) // bez sensu, ale dla towarowych korzystnie - { // Ra 2014-03: to nie uwzględnia odległości i zaczyna hamować, jak tylko zobaczy - // W4 - if ((AccDesired > 0.0) && - (VelNext >= 0.0)) // wybieg bądź lekkie hamowanie, warunki byly zamienione - if (vel > VelNext + 100.0) // lepiej zaczac hamowac - AccDesired = fAccThreshold; - else if (vel > VelNext + 70.0) - AccDesired = 0.0; // nie spiesz się, bo będzie hamowanie - // koniec wybiegu i hamowania - } - if (AIControllFlag) - { // część wykonawcza tylko dla AI, dla człowieka jedynie napisy - if (mvControlling->ConvOvldFlag || - !mvControlling->Mains) // WS może wywalić z powodu błędu w drutach - { // wywalił bezpiecznik nadmiarowy przetwornicy - // while (DecSpeed()); //zerowanie napędu - // Controlling->ConvOvldFlag=false; //reset nadmiarowego - PrepareEngine(); // próba ponownego załączenia - } - // włączanie bezpiecznika - if ((mvControlling->EngineType == ElectricSeriesMotor) || - (mvControlling->TrainType & dt_EZT) || - (mvControlling->EngineType == DieselElectric)) - if (mvControlling->FuseFlag || Need_TryAgain) - { - Need_TryAgain = - false; // true, jeśli druga pozycja w elektryku nie załapała - // if (!Controlling->DecScndCtrl(1)) //kręcenie po mału - // if (!Controlling->DecMainCtrl(1)) //nastawnik jazdy na 0 - mvControlling->DecScndCtrl(2); // nastawnik bocznikowania na 0 - mvControlling->DecMainCtrl(2); // nastawnik jazdy na 0 - mvControlling->MainSwitch( - true); // Ra: dodałem, bo EN57 stawały po wywaleniu - if (!mvControlling->FuseOn()) - HelpMeFlag = true; - else - { - ++iDriverFailCount; - if (iDriverFailCount > maxdriverfails) - Psyche = Easyman; - if (iDriverFailCount > maxdriverfails * 2) - SetDriverPsyche(); - } - } - if (mvOccupied->BrakeSystem == Pneumatic) // napełnianie uderzeniowe - if (mvOccupied->BrakeHandle == FV4a) - { - if (mvOccupied->BrakeCtrlPos == -2) - mvOccupied->BrakeLevelSet(0); - // if - // ((mvOccupied->BrakeCtrlPos<0)&&(mvOccupied->PipeBrakePress<0.01))//{(CntrlPipePress-(Volume/BrakeVVolume/10)<0.01)}) - // mvOccupied->IncBrakeLevel(); - if ((mvOccupied->PipePress < 3.0) && (AccDesired > -0.03)) - mvOccupied->BrakeReleaser(1); - if ((mvOccupied->BrakeCtrlPos == 0) && (AbsAccS < 0.0) && - (AccDesired > -0.03)) - // if FuzzyLogicAI(CntrlPipePress-PipePress,0.01,1)) - // if - // ((mvOccupied->BrakePress>0.5)&&(mvOccupied->LocalBrakePos<0.5))//{((Volume/BrakeVVolume/10)<0.485)}) - if ((mvOccupied->EqvtPipePress < 4.95) && - (fReady > 0.35)) //{((Volume/BrakeVVolume/10)<0.485)}) - { - if (iDrivigFlags & - moveOerlikons) // a reszta składu jest na to gotowa - mvOccupied->BrakeLevelSet(-1); // napełnianie w Oerlikonie - } - else if (Need_BrakeRelease) - { - Need_BrakeRelease = false; - mvOccupied->BrakeReleaser(1); - // DecBrakeLevel(); //z tym by jeszcze miało jakiś sens - } - // if - // ((mvOccupied->BrakeCtrlPos<0)&&(mvOccupied->BrakePress<0.3))//{(CntrlPipePress-(Volume/BrakeVVolume/10)<0.01)}) - if ((mvOccupied->BrakeCtrlPos < 0) && - (mvOccupied->EqvtPipePress > - (fReady < 0.25 ? - 5.1 : - 5.2))) //{(CntrlPipePress-(Volume/BrakeVVolume/10)<0.01)}) - mvOccupied->IncBrakeLevel(); - } -#if LOGVELOCITY - WriteLog("Dist=" + FloatToStrF(ActualProximityDist, ffFixed, 7, 1) + - ", VelDesired=" + FloatToStrF(VelDesired, ffFixed, 7, 1) + - ", AccDesired=" + FloatToStrF(AccDesired, ffFixed, 7, 3) + - ", VelSignal=" + AnsiString(VelSignal) + ", VelNext=" + - AnsiString(VelNext)); -#endif - if (AccDesired > 0.1) - if (vel < 10.0) // Ra 2F1H: jeśli prędkość jest mała, a można przyspieszać, - // to nie ograniczać przyspieszenia do 0.5m/ss - AccDesired = 0.9; // przy małych prędkościach może być trudno utrzymać - // małe przyspieszenie - // Ra 2F1I: wyłączyć kiedyś to uśrednianie i przeanalizować skanowanie, czemu - // migocze - if (AccDesired > -0.15) // hamowania lepeiej nie uśredniać - AccDesired = fAccDesiredAv = - 0.2 * AccDesired + - 0.8 * fAccDesiredAv; // uśrednione, żeby ograniczyć migotanie - if (VelDesired == 0.0) - if (AccDesired >= -0.01) - AccDesired = -0.01; // Ra 2F1J: jeszcze jedna prowizoryczna łatka - if (AccDesired >= 0.0) - if (iDrivigFlags & movePress) - mvOccupied->BrakeReleaser(1); // wyluzuj lokomotywę - może być więcej! - else if (OrderList[OrderPos] != - Disconnect) // przy odłączaniu nie zwalniamy tu hamulca - if ((AccDesired > 0.0) || - (fAccGravity * fAccGravity < - 0.001)) // luzuj tylko na plaskim lub przy ruszaniu - { - while (DecBrake()) - ; // jeśli przyspieszamy, to nie hamujemy - if (mvOccupied->BrakePress > 0.4) - mvOccupied->BrakeReleaser( - 1); // wyluzuj lokomotywę, to szybciej ruszymy - } - // margines dla prędkości jest doliczany tylko jeśli oczekiwana prędkość jest - // większa od 5km/h - if (!(iDrivigFlags & movePress)) - { // jeśli nie dociskanie - if (AccDesired < -0.1) - while (DecSpeed()) - ; // jeśli hamujemy, to nie przyspieszamy - else if (((fAccGravity < -0.01) ? AccDesired < 0.0 : - AbsAccS > AccDesired) || - (vel > VelDesired)) // jak za bardzo przyspiesza albo prędkość - // przekroczona - DecSpeed(); // pojedyncze cofnięcie pozycji, bo na zero to przesada - } - // yB: usunięte różne dziwne warunki, oddzielamy część zadającą od wykonawczej - // zwiekszanie predkosci - // Ra 2F1H: jest konflikt histerezy pomiędzy nastawioną pozycją a uzyskiwanym - // przyspieszeniem - utrzymanie pozycji powoduje przekroczenie przyspieszenia - if (AbsAccS < - AccDesired) // jeśli przyspieszenie pojazdu jest mniejsze niż żądane oraz - if (vel < VelDesired - fVelMinus) // jeśli prędkość w kierunku czoła jest - // mniejsza od dozwolonej o margines - if ((ActualProximityDist > fMaxProximityDist) ? true : (vel < VelNext)) - IncSpeed(); // to można przyspieszyć - // if ((AbsAccS0) and - // (EngineType=ElectricSeriesMotor) - // and (RList[MainCtrlPos].R>0.0) and (not DelayCtrlFlag)) - // if (ImTrainType & - dt_EZT) // właściwie, to warunek powinien być na działający EP - { // Ra: to dobrze hamuje EP w EZT - if ((AccDesired <= fAccThreshold) ? // jeśli hamować - u góry ustawia się - // hamowanie na fAccThreshold - ((AbsAccS > AccDesired) || (mvOccupied->BrakeCtrlPos < 0)) : - false) // hamować bardziej, gdy aktualne opóźnienie hamowania - // mniejsze niż (AccDesired) - IncBrake(); - else if (OrderList[OrderPos] != - Disconnect) // przy odłączaniu nie zwalniamy tu hamulca - if (AbsAccS < - AccDesired - - 0.05) // jeśli opóźnienie większe od wymaganego (z histerezą) - { // luzowanie, gdy za dużo - if (mvOccupied->BrakeCtrlPos >= 0) - DecBrake(); // tutaj zmniejszało o 1 przy odczepianiu - } - else if (mvOccupied->Handle->TimeEP) - { - if (mvOccupied->Handle->GetPos(bh_EPR) - - mvOccupied->Handle->GetPos(bh_EPN) < - 0.1) - mvOccupied->SwitchEPBrake(0); - else - mvOccupied->BrakeLevelSet(mvOccupied->Handle->GetPos(bh_EPN)); - } - // else if (mvOccupied->BrakeCtrlPos<0) IncBrake(); //ustawienie - // jazdy (pozycja 0) - // else if (mvOccupied->BrakeCtrlPos>0) DecBrake(); - } - else - { // a stara wersja w miarę dobrze działa na składy wagonowe - // if (mvOccupied->Handle->Time) - // mvOccupied->BrakeLevelSet(mvOccupied->Handle->GetPos(bh_MB)); - // //najwyzej sobie przestawi - if (((fAccGravity < -0.05) && (vel < 0)) || - ((AccDesired < fAccGravity - 0.1) && - (AbsAccS > - AccDesired + 0.05))) // u góry ustawia się hamowanie na fAccThreshold - // if not MinVelFlag) - if (fBrakeTime < 0 ? true : (AccDesired < fAccGravity - 0.3) || - (mvOccupied->BrakeCtrlPos <= 0)) - if (!IncBrake()) // jeśli upłynął czas reakcji hamulca, chyba że - // nagłe albo luzował - MinVelFlag = true; - else - { - MinVelFlag = false; - fBrakeTime = - 3 + - 0.5 * - (mvOccupied - ->BrakeDelay[2 + 2 * mvOccupied->BrakeDelayFlag] - - 3); - // Ra: ten czas należy zmniejszyć, jeśli czas dojazdu do - // zatrzymania jest mniejszy - fBrakeTime *= 0.5; // Ra: tymczasowo, bo przeżyna S1 - } - if ((AccDesired < fAccGravity - 0.05) && (AbsAccS < AccDesired - 0.2)) - // if ((AccDesired<0.0)&&(AbsAccSBrakeDelay[1 + 2 * mvOccupied->BrakeDelayFlag]) / 3.0; - fBrakeTime *= 0.5; // Ra: tymczasowo, bo przeżyna S1 - } - } - // Mietek-end1 - SpeedSet(); // ciągla regulacja prędkości -#if LOGVELOCITY - WriteLog("BrakePos=" + AnsiString(mvOccupied->BrakeCtrlPos) + ", MainCtrl=" + - AnsiString(mvControlling->MainCtrlPos)); -#endif - - /* //Ra: mamy teraz wskażnik na człon silnikowy, gorzej jak są dwa w - ukrotnieniu... - //zapobieganie poslizgowi w czlonie silnikowym; Ra: Couplers[1] powinno - być - if (Controlling->Couplers[0].Connected!=NULL) - if (TestFlag(Controlling->Couplers[0].CouplingFlag,ctrain_controll)) - if (Controlling->Couplers[0].Connected->SlippingWheels) - if (Controlling->ScndCtrlPos>0?!Controlling->DecScndCtrl(1):true) - { - if (!Controlling->DecMainCtrl(1)) - if (mvOccupied->BrakeCtrlPos==mvOccupied->BrakeCtrlPosNo) - mvOccupied->DecBrakeLevel(); - ++iDriverFailCount; - } - */ - // zapobieganie poslizgowi u nas - if (mvControlling->SlippingWheels) - { - if (!mvControlling->DecScndCtrl(2)) // bocznik na zero - mvControlling->DecMainCtrl(1); - if (mvOccupied->BrakeCtrlPos == - mvOccupied->BrakeCtrlPosNo) // jeśli ostatnia pozycja hamowania - mvOccupied->DecBrakeLevel(); // to cofnij hamulec - else - mvControlling->AntiSlippingButton(); - ++iDriverFailCount; - mvControlling->SlippingWheels = false; // flaga już wykorzystana - } - if (iDriverFailCount > maxdriverfails) - { - Psyche = Easyman; - if (iDriverFailCount > maxdriverfails * 2) - SetDriverPsyche(); - } - } // if (AIControllFlag) - else - { // tu mozna dać komunikaty tekstowe albo słowne: przyspiesz, hamuj (lekko, - // średnio, mocno) - } - } // kierunek różny od zera - else - { // tutaj, gdy pojazd jest wyłączony - if (!AIControllFlag) // jeśli sterowanie jest w gestii użytkownika - if (mvOccupied->Battery) // czy użytkownik załączył baterię? - if (mvOccupied->ActiveDir) // czy ustawił kierunek - { // jeśli tak, to uruchomienie skanowania - CheckVehicles(); // sprawdzić skład - TableClear(); // resetowanie tabelki skanowania - PrepareEngine(); // uruchomienie - } - } - if (AIControllFlag) - { // odhamowywanie składu po zatrzymaniu i zabezpieczanie lokomotywy - if ((OrderList[OrderPos] & (Disconnect | Connect)) == - 0) // przy (p)odłączaniu nie zwalniamy tu hamulca - if ((mvOccupied->V == 0.0) && ((VelDesired == 0.0) || (AccDesired == 0.0))) - if ((mvOccupied->BrakeCtrlPos < 1) || !mvOccupied->DecBrakeLevel()) - mvOccupied->IncLocalBrakeLevel(1); // dodatkowy na pozycję 1 - } - break; // rzeczy robione przy jezdzie - } // switch (OrderList[OrderPos]) - // kasowanie licznika czasu - LastReactionTime = 0.0; - UpdateOK = true; - } // if ((LastReactionTime>Min0R(ReactionTime,2.0))) - else - LastReactionTime += dt; - - if ((fLastStopExpDist > 0.0) && (mvOccupied->DistCounter > fLastStopExpDist)) - { - iStationStart = TrainParams->StationIndex; // zaktualizować wyświetlanie rozkładu - fLastStopExpDist = -1.0f; // usunąć licznik - } - - if (AIControllFlag) - { - if (fWarningDuration > 0.0) // jeśli pozostało coś do wytrąbienia - { // trąbienie trwa nadal - fWarningDuration = fWarningDuration - dt; - if (fWarningDuration < 0.05) + // horn control + if( fWarningDuration > 0.0 ) { + // jeśli pozostało coś do wytrąbienia trąbienie trwa nadal + fWarningDuration -= dt; + if( fWarningDuration < 0.05 ) mvOccupied->WarningSignal = 0; // a tu się kończy - if (ReactionTime > fWarningDuration) - ReactionTime = - fWarningDuration; // wcześniejszy przebłysk świadomości, by zakończyć trąbienie } - if (mvOccupied->Vel >= - 3.0) // jesli jedzie, można odblokować trąbienie, bo się wtedy nie włączy - { + if( mvOccupied->Vel >= 5.0 ) { + // jesli jedzie, można odblokować trąbienie, bo się wtedy nie włączy iDrivigFlags &= ~moveStartHornDone; // zatrąbi dopiero jak następnym razem stanie iDrivigFlags |= moveStartHorn; // i trąbić przed następnym ruszeniem } - return UpdateOK; + + if( ( true == TestFlag( iDrivigFlags, moveStartHornNow ) ) + && ( true == Ready ) + && ( iEngineActive != 0 ) + && ( mvControlling->MainCtrlPos > 0 ) ) { + // uruchomienie trąbienia przed ruszeniem + fWarningDuration = 0.3; // czas trąbienia + mvOccupied->WarningSignal = pVehicle->iHornWarning; // wysokość tonu (2=wysoki) + iDrivigFlags |= moveStartHornDone; // nie trąbić aż do ruszenia + iDrivigFlags &= ~moveStartHornNow; // trąbienie zostało zorganizowane + } + } + + // main ai update routine + auto const reactiontime = std::min( ReactionTime, 2.0 ); + if( LastReactionTime < reactiontime ) { return; } + + LastReactionTime -= reactiontime; + // Ra: nie wiem czemu ReactionTime potrafi dostać 12 sekund, to jest przegięcie, bo przeżyna STÓJ + // yB: otóż jest to jedna trzecia czasu napełniania na towarowym; może się przydać przy + // wdrażaniu hamowania, żeby nie ruszało kranem jak głupie + // Ra: ale nie może się budzić co pół minuty, bo przeżyna semafory + // Ra: trzeba by tak: + // 1. Ustalić istotną odległość zainteresowania (np. 3×droga hamowania z V.max). + // dla hamowania -0.2 [m/ss] droga wynosi 0.389*Vel*Vel [km/h], czyli 600m dla 40km/h, 3.8km + // dla 100km/h i 9.8km dla 160km/h + // dla hamowania -0.4 [m/ss] droga wynosi 0.096*Vel*Vel [km/h], czyli 150m dla 40km/h, 1.0km + // dla 100km/h i 2.5km dla 160km/h + // ogólnie droga hamowania przy stałym opóźnieniu to Vel*Vel/(3.6*3.6*a) [m] + // fBrakeDist powinno być wyznaczane dla danego składu za pomocą sieci neuronowych, w + // zależności od prędkości i siły (ciśnienia) hamowania + // następnie w drugą stronę, z drogi hamowania i chwilowej prędkości powinno być wyznaczane zalecane ciśnienie + + // przybliżona droga hamowania + fBrakeDist = fDriverBraking * mvOccupied->Vel * ( 40.0 + mvOccupied->Vel ); + if( fMass > 1000000.0 ) { + // korekta dla ciężkich, bo przeżynają - da to coś? + fBrakeDist *= 2.0; + } + if( ( -fAccThreshold > 0.05 ) + && ( mvOccupied->CategoryFlag == 1 ) ) { + fBrakeDist = mvOccupied->Vel * mvOccupied->Vel / 25.92 / -fAccThreshold; + } + if( mvOccupied->BrakeDelayFlag == bdelay_G ) { + // dla nastawienia G koniecznie należy wydłużyć drogę na czas reakcji + fBrakeDist += 2 * mvOccupied->Vel; + } +/* + // take into account effect of gravity (but to stay on safe side of calculations, only downhill) + if( fAccGravity > 0.025 ) { + fBrakeDist *= ( 1.0 + fAccGravity ); + // TBD: use version which shortens route going uphill, too + //fBrakeDist = std::max( fBrakeDist, fBrakeDist * ( 1.0 + fAccGravity ) ); + } +*/ + // route scan + auto const routescanrange { + std::max( + 750.0, + mvOccupied->Vel > 5.0 ? + 400 + fBrakeDist : + 30.0 * fDriverDist ) }; // 1500m dla stojących pociągów; + // Ra 2015-01: przy dłuższej drodze skanowania AI jeździ spokojniej + // 2. Sprawdzić, czy tabelka pokrywa założony odcinek (nie musi, jeśli jest STOP). + // 3. Sprawdzić, czy trajektoria ruchu przechodzi przez zwrotnice - jeśli tak, to sprawdzić, + // czy stan się nie zmienił. + // 4. Ewentualnie uzupełnić tabelkę informacjami o sygnałach i ograniczeniach, jeśli się + // "zużyła". + TableCheck( routescanrange ); // wypełnianie tabelki i aktualizacja odległości + // 5. Sprawdzić stany sygnalizacji zapisanej w tabelce, wyznaczyć prędkości. + // 6. Z tabelki wyznaczyć krytyczną odległość i prędkość (najmniejsze przyspieszenie). + // 7. Jeśli jest inny pojazd z przodu, ewentualnie skorygować odległość i prędkość. + // 8. Ustalić częstotliwość świadomości AI (zatrzymanie precyzyjne - częściej, brak atrakcji + // - rzadziej). + + // check for potential colliders + { + auto rearvehicle = ( + pVehicles[ 0 ] == pVehicles[ 1 ] ? + pVehicles[ 0 ] : + pVehicles[ 1 ] ); + // for moving vehicle determine heading from velocity; for standing fall back on the set direction + if( ( std::abs( mvOccupied->V ) < 0.1 ? // ignore potential micro-stutters in oposite direction during "almost stop" + iDirection > 0 : + mvOccupied->V > 0.0 ) ) { + // towards coupler 0 + if( ( mvOccupied->V * iDirection < 0.0 ) + || ( ( rearvehicle->NextConnected != nullptr ) + && ( rearvehicle->MoverParameters->Couplers[ ( rearvehicle->DirectionGet() > 0 ? 1 : 0 ) ].CouplingFlag == coupling::faux ) ) ) { + // scan behind if we're moving backward, or if we had something connected there and are moving away + rearvehicle->ABuScanObjects( ( + pVehicle->DirectionGet() == rearvehicle->DirectionGet() ? + -1 : + 1 ), + fMaxProximityDist ); + } + pVehicles[ 0 ]->ABuScanObjects( ( + pVehicle->DirectionGet() == pVehicles[ 0 ]->DirectionGet() ? + 1 : + -1 ), + routescanrange ); + } + else { + // towards coupler 1 + if( ( mvOccupied->V * iDirection < 0.0 ) + || ( ( rearvehicle->PrevConnected != nullptr ) + && ( rearvehicle->MoverParameters->Couplers[ ( rearvehicle->DirectionGet() > 0 ? 0 : 1 ) ].CouplingFlag == coupling::faux ) ) ) { + // scan behind if we're moving backward, or if we had something connected there and are moving away + rearvehicle->ABuScanObjects( ( + pVehicle->DirectionGet() == rearvehicle->DirectionGet() ? + 1 : + -1 ), + fMaxProximityDist ); + } + pVehicles[ 0 ]->ABuScanObjects( ( + pVehicle->DirectionGet() == pVehicles[ 0 ]->DirectionGet() ? + -1 : + 1 ), + routescanrange ); + } + } + + + + // tu bedzie logika sterowania + if (AIControllFlag) { + + if (mvOccupied->CommandIn.Command != "") + if( !mvOccupied->RunInternalCommand() ) { + // rozpoznaj komende bo lokomotywa jej nie rozpoznaje + RecognizeCommand(); // samo czyta komendę wstawioną do pojazdu? + } + if( mvOccupied->SecuritySystem.Status > 1 ) { + // jak zadziałało CA/SHP + if( !mvOccupied->SecuritySystemReset() ) { // to skasuj + if( ( mvOccupied->BrakeCtrlPos == 0 ) + && ( AccDesired > 0.0 ) + && ( ( TestFlag( mvOccupied->SecuritySystem.Status, s_SHPebrake ) ) + || ( TestFlag( mvOccupied->SecuritySystem.Status, s_CAebrake ) ) ) ) { + //!!! hm, może po prostu normalnie sterować hamulcem? + mvOccupied->BrakeLevelSet( 0 ); + } + } + } + // basic emergency stop handling, while at it + if( ( true == mvOccupied->RadioStopFlag ) // radio-stop + && ( mvOccupied->Vel == 0.0 ) // and actual stop + && ( true == mvOccupied->Radio ) ) { // and we didn't touch the radio yet + // turning off the radio should reset the flag, during security system check + if( m_radiocontroltime > 5.0 ) { + // arbitrary delay between stop and disabling the radio + mvOccupied->Radio = false; + m_radiocontroltime = 0.0; + } + else { + m_radiocontroltime += reactiontime; + } + } + if( ( false == mvOccupied->Radio ) + && ( false == mvOccupied->RadioStopFlag ) ) { + // otherwise if it's safe to do so, turn the radio back on + if( m_radiocontroltime > 10.0 ) { + // arbitrary 5 sec delay before switching radio back on + mvOccupied->Radio = true; + m_radiocontroltime = 0.0; + } + else { + m_radiocontroltime += reactiontime; + } + } + } + + switch (OrderList[OrderPos]) + { // ustalenie prędkości przy doczepianiu i odczepianiu, dystansów w pozostałych przypadkach + case Connect: { + // podłączanie do składu + if (iDrivigFlags & moveConnect) { + // jeśli stanął już blisko, unikając zderzenia i można próbować podłączyć + fMinProximityDist = -1.0; + fMaxProximityDist = 0.0; //[m] dojechać maksymalnie + fVelPlus = 1.0; // dopuszczalne przekroczenie prędkości na ograniczeniu bez hamowania + fVelMinus = 0.5; // margines prędkości powodujący załączenie napędu + if (AIControllFlag) + { // to robi tylko AI, wersję dla człowieka trzeba dopiero zrobić + // sprzęgi sprawdzamy w pierwszej kolejności, bo jak połączony, to koniec + bool ok; // true gdy się podłączy (uzyskany sprzęg będzie zgodny z żądanym) + if (pVehicles[0]->DirectionGet() > 0) // jeśli sprzęg 0 + { // sprzęg 0 - próba podczepienia + if( pVehicles[ 0 ]->MoverParameters->Couplers[ 0 ].Connected ) { + // jeśli jest coś wykryte (a chyba jest, nie?) + if( pVehicles[ 0 ]->MoverParameters->Attach( + 0, 2, pVehicles[ 0 ]->MoverParameters->Couplers[ 0 ].Connected, + iCoupler ) ) { + // pVehicles[0]->dsbCouplerAttach->SetVolume(DSBVOLUME_MAX); + // pVehicles[0]->dsbCouplerAttach->Play(0,0,0); + } + } + // udało się? (mogło częściowo) + ok = (pVehicles[0]->MoverParameters->Couplers[0].CouplingFlag == iCoupler); + } + else // if (pVehicles[0]->MoverParameters->DirAbsolute<0) //jeśli sprzęg 1 + { // sprzęg 1 - próba podczepienia + if( pVehicles[ 0 ]->MoverParameters->Couplers[ 1 ].Connected ) { + // jeśli jest coś wykryte (a chyba jest, nie?) + if( pVehicles[ 0 ]->MoverParameters->Attach( + 1, 2, pVehicles[ 0 ]->MoverParameters->Couplers[ 1 ].Connected, + iCoupler ) ) { + // pVehicles[0]->dsbCouplerAttach->SetVolume(DSBVOLUME_MAX); + // pVehicles[0]->dsbCouplerAttach->Play(0,0,0); + } + } + // udało się? (mogło częściowo) + ok = (pVehicles[0]->MoverParameters->Couplers[1].CouplingFlag == iCoupler); + } + if (ok) + { // jeżeli został podłączony + iCoupler = 0; // dalsza jazda manewrowa już bez łączenia + iDrivigFlags &= ~moveConnect; // zdjęcie flagi doczepiania + SetVelocity(0, 0, stopJoin); // wyłączyć przyspieszanie + CheckVehicles(); // sprawdzić światła nowego składu + JumpToNextOrder(); // wykonanie następnej komendy + } + + } // if (AIControllFlag) //koniec zblokowania, bo była zmienna lokalna + } + else { + // jak daleko, to jazda jak dla Shunt na kolizję + fMinProximityDist = 2.0; + fMaxProximityDist = 5.0; //[m] w takim przedziale odległości powinien stanąć + fVelPlus = 2.0; // dopuszczalne przekroczenie prędkości na ograniczeniu bez hamowania + fVelMinus = 1.0; // margines prędkości powodujący załączenie napędu + if( pVehicles[ 0 ]->fTrackBlock <= 20.0 ) { + // przy zderzeniu fTrackBlock nie jest miarodajne + // początek podczepiania, z wyłączeniem sprawdzania fTrackBlock + iDrivigFlags |= moveConnect; + } + } + break; + } + case Disconnect: { + // 20.07.03 - manewrowanie wagonami + fMinProximityDist = 1.0; + fMaxProximityDist = 10.0; //[m] + fVelPlus = 1.0; // dopuszczalne przekroczenie prędkości na ograniczeniu bez hamowania + fVelMinus = 0.5; // margines prędkości powodujący załączenie napędu + break; + } + case Shunt: { + // na jaką odleglość i z jaką predkością ma podjechać + // TODO: test if we can use the distances calculation from obey_train + fMinProximityDist = std::min( 5 + iVehicles, 25 ); + fMaxProximityDist = std::min( 10 + iVehicles, 50 ); +/* + if( IsHeavyCargoTrain ) { + fMaxProximityDist *= 1.5; + } +*/ + fVelPlus = 2.0; // dopuszczalne przekroczenie prędkości na ograniczeniu bez hamowania + // margines prędkości powodujący załączenie napędu + // były problemy z jazdą np. 3km/h podczas ładowania wagonów + fVelMinus = std::min( 0.1 * fShuntVelocity, 3.0 ); + break; + } + case Obey_train: { + // na jaka odleglosc i z jaka predkoscia ma podjechac do przeszkody + if( mvOccupied->CategoryFlag & 1 ) { + // jeśli pociąg + fMinProximityDist = clamp( 5 + iVehicles, 10, 15 ); + fMaxProximityDist = clamp( 10 + iVehicles, 15, 40 ); + + if( IsCargoTrain ) { + // increase distances for cargo trains to take into account slower reaction to brakes + fMinProximityDist += 10.0; + fMaxProximityDist += 10.0; +/* + if( IsHeavyCargoTrain ) { + // cargo trains with high braking threshold may require even larger safety margin + fMaxProximityDist += 20.0; + } +*/ + } + if( mvOccupied->Vel < 0.1 ) { + // jak stanie za daleko, to niech nie dociąga paru metrów + fMaxProximityDist = 50.0; + } + + if( iDrivigFlags & moveLate ) { + // jeśli spóźniony, to gna + fVelMinus = 1.0; + // dopuszczalne przekroczenie prędkości na ograniczeniu bez hamowania + fVelPlus = 5.0; + } + else { + // gdy nie musi się sprężać + // margines prędkości powodujący załączenie napędu; min 1.0 żeby nie ruszał przy 0.1 + fVelMinus = clamp( std::round( 0.05 * VelDesired ), 1.0, 5.0 ); + // normalnie dopuszczalne przekroczenie to 5% prędkości ale nie więcej niż 5km/h + // bottom margin raised to 2 km/h to give the AI more leeway at low speed limits + fVelPlus = clamp( std::ceil( 0.05 * VelDesired ), 2.0, 5.0 ); + } + } + else { + // samochod (sokista też) + fMinProximityDist = std::max( 3.5, mvOccupied->Vel * 0.2 ); + fMaxProximityDist = std::max( 9.5, mvOccupied->Vel * 0.375 ); //[m] + // margines prędkości powodujący załączenie napędu + fVelMinus = 2.0; + // dopuszczalne przekroczenie prędkości na ograniczeniu bez hamowania + fVelPlus = std::min( 10.0, mvOccupied->Vel * 0.1 ); + } + break; + } + default: { + fMinProximityDist = 5.0; + fMaxProximityDist = 10.0; //[m] + fVelPlus = 2.0; // dopuszczalne przekroczenie prędkości na ograniczeniu bez hamowania + fVelMinus = 5.0; // margines prędkości powodujący załączenie napędu + } + } // switch OrderList[OrderPos] + + switch (OrderList[OrderPos]) + { // co robi maszynista + case Prepare_engine: // odpala silnik + // if (AIControllFlag) + if (PrepareEngine()) // dla użytkownika tylko sprawdza, czy uruchomił + { // gotowy do drogi? + SetDriverPsyche(); + // OrderList[OrderPos]:=Shunt; //Ra: to nie może tak być, bo scenerie robią + // Jump_to_first_order i przechodzi w manewrowy + JumpToNextOrder(); // w następnym jest Shunt albo Obey_train, moze też być + // Change_direction, Connect albo Disconnect + // if OrderList[OrderPos]<>Wait_for_Orders) + // if BrakeSystem=Pneumatic) //napelnianie uderzeniowe na wstepie + // if BrakeSubsystem=Oerlikon) + // if (BrakeCtrlPos=0)) + // DecBrakeLevel; + } + break; + case Release_engine: + if( ReleaseEngine() ) // zdana maszyna? + JumpToNextOrder(); + break; + case Jump_to_first_order: + if (OrderPos > 1) + OrderPos = 1; // w zerowym zawsze jest czekanie + else + ++OrderPos; +#if LOGORDERS + WriteLog("--> Jump_to_first_order"); + OrdersDump(); +#endif + break; + case Wait_for_orders: // jeśli czeka, też ma skanować, żeby odpalić się od semafora + case Shunt: + case Obey_train: + case Connect: + case Disconnect: + case Change_direction: // tryby wymagające jazdy + case Change_direction | Shunt: // zmiana kierunku podczas manewrów + case Change_direction | Connect: // zmiana kierunku podczas podłączania + if (OrderList[OrderPos] != Obey_train) // spokojne manewry + { + VelSignal = min_speed( VelSignal, 40.0 ); // jeśli manewry, to ograniczamy prędkość + + // NOTE: this section should be moved to disconnect or plain removed, but it seems to be (mis)used by some scenarios + // to keep vehicle idling without moving :| + if( ( true == AIControllFlag ) + && ( iVehicleCount >= 0 ) + && ( false == TestFlag( iDrivigFlags, movePress ) ) + && ( iCoupler == 0 ) +// && ( mvOccupied->Vel > 0.0 ) + && ( pVehicle->MoverParameters->Couplers[ side::front ].CouplingFlag == coupling::faux ) + && ( pVehicle->MoverParameters->Couplers[ side::rear ].CouplingFlag == coupling::faux ) ) { + SetVelocity(0, 0, stopJoin); // 1. faza odczepiania: zatrzymanie + // WriteLog("Zatrzymanie w celu odczepienia"); + AccPreferred = std::min( 0.0, AccPreferred ); + } + + } + else + SetDriverPsyche(); // Ra: było w PrepareEngine(), potrzebne tu? + + if (OrderList[OrderPos] & (Shunt | Obey_train | Connect)) { + // odjechać sam może tylko jeśli jest w trybie jazdy + // automatyczne ruszanie po odstaniu albo spod SBL + if( ( VelSignal == 0.0 ) + && ( WaitingTime > 0.0 ) + && ( mvOccupied->RunningTrack.Velmax != 0.0 ) ) { + // jeśli stoi, a upłynął czas oczekiwania i tor ma niezerową prędkość + if( ( OrderList[ OrderPos ] & ( Obey_train | Shunt ) ) + && ( iDrivigFlags & moveStopHere ) ) { + // zakaz ruszania z miejsca bez otrzymania wolnej drogi + WaitingTime = -WaitingExpireTime; + } + else if (mvOccupied->CategoryFlag & 1) + { // jeśli pociąg + if (AIControllFlag) + { + PrepareEngine(); // zmieni ustawiony kierunek + SetVelocity(20, 20); // jak się nastał, to niech jedzie 20km/h + WaitingTime = 0.0; + fWarningDuration = 1.5; // a zatrąbić trochę + mvOccupied->WarningSignal = 1; + } + else + SetVelocity(20, 20); // użytkownikowi zezwalamy jechać + } + else + { // samochód ma stać, aż dostanie odjazd, chyba że stoi przez kolizję + if (eStopReason == stopBlock) + if (pVehicles[0]->fTrackBlock > fDriverDist) + if (AIControllFlag) + { + PrepareEngine(); // zmieni ustawiony kierunek + SetVelocity(-1, -1); // jak się nastał, to niech jedzie + WaitingTime = 0.0; + } + else { + // użytkownikowi pozwalamy jechać (samochodem?) + SetVelocity( -1, -1 ); + } + } + } + else if( ( VelSignal == 0.0 ) && ( VelNext > 0.0 ) && ( mvOccupied->Vel < 1.0 ) ) { + if( iCoupler ? true : ( iDrivigFlags & moveStopHere ) == 0 ) { + // Ra: tu jest coś nie tak, bo bez tego warunku ruszało w manewrowym !!!! + SetVelocity( VelNext, VelNext, stopSem ); // omijanie SBL + } + } + } // koniec samoistnego odjeżdżania + + if( ( true == AIControllFlag) + && ( true == TestFlag( OrderList[ OrderPos ], Change_direction ) ) ) { + // sprobuj zmienic kierunek (może być zmieszane z jeszcze jakąś komendą) + if( mvOccupied->Vel < 0.1 ) { + // jeśli się zatrzymał, to zmieniamy kierunek jazdy, a nawet kabinę/człon + Activation(); // ustawienie zadanego wcześniej kierunku i ewentualne przemieszczenie AI + PrepareEngine(); + JumpToNextOrder(); // następnie robimy, co jest do zrobienia (Shunt albo Obey_train) + if( OrderList[ OrderPos ] & ( Shunt | Connect ) ) { + // jeśli dalej mamy manewry + if( false == TestFlag( iDrivigFlags, moveStopHere ) ) { + // o ile nie ma stać w miejscu, + // jechać od razu w przeciwną stronę i nie trąbić z tego tytułu: + iDrivigFlags &= ~moveStartHorn; + SetVelocity( fShuntVelocity, fShuntVelocity ); + } + } + } + } // Change_direction (tylko dla AI) + + if( ( true == AIControllFlag ) + && ( iEngineActive == 0 ) + && ( OrderList[ OrderPos ] & ( Change_direction | Connect | Disconnect | Shunt | Obey_train ) ) ) { + // jeśli coś ma robić to niech odpala do skutku + PrepareEngine(); + } + + // ustalanie zadanej predkosci + if (iDrivigFlags & moveActive) { + + SetDriverPsyche(); // ustawia AccPreferred (potrzebne tu?) + + // jeśli może skanować sygnały i reagować na komendy + // jeśli jest wybrany kierunek jazdy, można ustalić prędkość jazdy + // Ra: tu by jeszcze trzeba było wstawić uzależnienie (VelDesired) od odległości od przeszkody + // no chyba żeby to uwzgldnić już w (ActualProximityDist) + VelDesired = fVelMax; // wstępnie prędkość maksymalna dla pojazdu(-ów), będzie + // następnie ograniczana + if( ( TrainParams ) + && ( TrainParams->TTVmax > 0.0 ) ) { + // jeśli ma rozkład i ograniczenie w rozkładzie to nie przekraczać rozkladowej + VelDesired = min_speed( VelDesired, TrainParams->TTVmax ); + } + // szukanie optymalnych wartości + AccDesired = AccPreferred; // AccPreferred wynika z osobowości mechanika + VelNext = VelDesired; // maksymalna prędkość wynikająca z innych czynników niż trajektoria ruchu + ActualProximityDist = routescanrange; // funkcja Update() może pozostawić wartości bez zmian + // Ra: odczyt (ActualProximityDist), (VelNext) i (AccPreferred) z tabelki prędkosci + TCommandType comm = TableUpdate(VelDesired, ActualProximityDist, VelNext, AccDesired); + + switch (comm) { + // ustawienie VelSignal - trochę proteza = do przemyślenia + case TCommandType::cm_Ready: // W4 zezwolił na jazdę + // ewentualne doskanowanie trasy za W4, który zezwolił na jazdę + TableCheck( routescanrange); + TableUpdate(VelDesired, ActualProximityDist, VelNext, AccDesired); // aktualizacja po skanowaniu + if (VelNext == 0.0) + break; // ale jak coś z przodu zamyka, to ma stać + if (iDrivigFlags & moveStopCloser) + VelSignal = -1.0; // ma czekać na sygnał z sygnalizatora! + case TCommandType::cm_SetVelocity: // od wersji 357 semafor nie budzi wyłączonej lokomotywy + if (!(OrderList[OrderPos] & + ~(Obey_train | Shunt))) // jedzie w dowolnym trybie albo Wait_for_orders + if (fabs(VelSignal) >= + 1.0) // 0.1 nie wysyła się do samochodow, bo potem nie ruszą + PutCommand("SetVelocity", VelSignal, VelNext, nullptr); // komenda robi dodatkowe operacje + break; + case TCommandType::cm_ShuntVelocity: // od wersji 357 Tm nie budzi wyłączonej lokomotywy + if (!(OrderList[OrderPos] & + ~(Obey_train | Shunt))) // jedzie w dowolnym trybie albo Wait_for_orders + PutCommand("ShuntVelocity", VelSignal, VelNext, nullptr); + else if (iCoupler) // jeśli jedzie w celu połączenia + SetVelocity(VelSignal, VelNext); + break; + case TCommandType::cm_Command: // komenda z komórki + if( !( OrderList[ OrderPos ] & ~( Obey_train | Shunt ) ) ) { + // jedzie w dowolnym trybie albo Wait_for_orders + if( mvOccupied->Vel < 0.1 ) { + // dopiero jak stanie +/* + PutCommand( eSignNext->text(), eSignNext->value( 1 ), eSignNext->value( 2 ), nullptr ); + eSignNext->StopCommandSent(); // się wykonało już +*/ // replacement of the above + eSignNext->send_command( *this ); + } + } + break; + default: + break; + } + // disconnect mode potentially overrides scan results + // TBD: when in this mode skip scanning altogether? + if( ( OrderCurrentGet() & Disconnect ) != 0 ) { + + if (AIControllFlag) { + if (iVehicleCount >= 0) { + // jeśli była podana ilość wagonów + if (iDrivigFlags & movePress) { + // jeśli dociskanie w celu odczepienia + // 3. faza odczepiania. + SetVelocity(2, 0); // jazda w ustawionym kierunku z prędkością 2 + if ((mvControlling->MainCtrlPos > 0) || + (mvOccupied->BrakeSystem == TBrakeSystem::ElectroPneumatic)) // jeśli jazda + { + WriteLog(mvOccupied->Name + " odczepianie w kierunku " + std::to_string(mvOccupied->DirAbsolute)); + TDynamicObject *p = + pVehicle; // pojazd do odczepienia, w (pVehicle) siedzi AI + int d; // numer sprzęgu, który sprawdzamy albo odczepiamy + int n = iVehicleCount; // ile wagonów ma zostać + do + { // szukanie pojazdu do odczepienia + d = p->DirectionGet() > 0 ? + 0 : + 1; // numer sprzęgu od strony czoła składu + // if (p->MoverParameters->Couplers[d].CouplerType==Articulated) + // //jeśli sprzęg typu wózek (za mało) + if (p->MoverParameters->Couplers[d].CouplingFlag & ctrain_depot) // jeżeli sprzęg zablokowany + // if (p->GetTrack()->) //a nie stoi na torze warsztatowym + // (ustalić po czym poznać taki tor) + ++n; // to liczymy człony jako jeden + p->MoverParameters->BrakeReleaser(1); // wyluzuj pojazd, aby dało się dopychać + p->MoverParameters->BrakeLevelSet(0); // hamulec na zero, aby nie hamował + if (n) + { // jeśli jeszcze nie koniec + p = p->Prev(); // kolejny w stronę czoła składu (licząc od + // tyłu), bo dociskamy + if (!p) + iVehicleCount = -2, + n = 0; // nie ma co dalej sprawdzać, doczepianie zakończone + } + } while (n--); + if( p ? p->MoverParameters->Couplers[ d ].CouplingFlag == coupling::faux : true ) { + // no target, or already just virtual coupling + WriteLog( mvOccupied->Name + " didn't find anything to disconnect." ); + iVehicleCount = -2; // odczepiono, co było do odczepienia + } else if ( p->Dettach(d) == coupling::faux ) { + // tylko jeśli odepnie + WriteLog( mvOccupied->Name + " odczepiony." ); + iVehicleCount = -2; + } // a jak nie, to dociskać dalej + } + if (iVehicleCount >= 0) // zmieni się po odczepieniu + if (!mvOccupied->DecLocalBrakeLevel(1)) + { // dociśnij sklad + WriteLog( mvOccupied->Name + " dociskanie..." ); + // mvOccupied->BrakeReleaser(); //wyluzuj lokomotywę + // Ready=true; //zamiast sprawdzenia odhamowania całego składu + IncSpeed(); // dla (Ready)==false nie ruszy + } + } + if ((mvOccupied->Vel < 0.01) && !(iDrivigFlags & movePress)) + { // 2. faza odczepiania: zmień kierunek na przeciwny i dociśnij + // za radą yB ustawiamy pozycję 3 kranu (ruszanie kranem w innych miejscach + // powino zostać wyłączone) + // WriteLog("Zahamowanie składu"); + mvOccupied->BrakeLevelSet( + mvOccupied->BrakeSystem == TBrakeSystem::ElectroPneumatic ? + 1 : + 3 ); + double p = mvOccupied->BrakePressureActual.PipePressureVal; + if( p < 3.9 ) { + // tu może być 0 albo -1 nawet + // TODO: zabezpieczenie przed dziwnymi CHK do czasu wyjaśnienia sensu 0 oraz -1 w tym miejscu + p = 3.9; + } + if (mvOccupied->BrakeSystem == TBrakeSystem::ElectroPneumatic ? + mvOccupied->BrakePress > 2 : + mvOccupied->PipePress < p + 0.1) + { // jeśli w miarę został zahamowany (ciśnienie mniejsze niż podane na + // pozycji 3, zwyle 0.37) + if (mvOccupied->BrakeSystem == TBrakeSystem::ElectroPneumatic) + mvOccupied->BrakeLevelSet(0); // wyłączenie EP, gdy wystarczy (może + // nie być potrzebne, bo na początku jest) + WriteLog("Luzowanie lokomotywy i zmiana kierunku"); + mvOccupied->BrakeReleaser(1); // wyluzuj lokomotywę; a ST45? + mvOccupied->DecLocalBrakeLevel(LocalBrakePosNo); // zwolnienie hamulca + iDrivigFlags |= movePress; // następnie będzie dociskanie + DirectionForward(mvOccupied->ActiveDir < 0); // zmiana kierunku jazdy na przeciwny (dociskanie) + CheckVehicles(); // od razu zmienić światła (zgasić) - bez tego się nie odczepi + /* + // NOTE: disabled to prevent closing the door before passengers can disembark + fStopTime = 0.0; // nie ma na co czekać z odczepianiem + */ + } + } + else { + if( mvOccupied->Vel > 0.01 ) { + // 1st phase(?) + // bring it to stop if it's not already stopped + SetVelocity( 0, 0, stopJoin ); // wyłączyć przyspieszanie + } + } + } // odczepiania + else // to poniżej jeśli ilość wagonów ujemna + if (iDrivigFlags & movePress) + { // 4. faza odczepiania: zwolnij i zmień kierunek + SetVelocity(0, 0, stopJoin); // wyłączyć przyspieszanie + if (!DecSpeed()) // jeśli już bardziej wyłączyć się nie da + { // ponowna zmiana kierunku + WriteLog( mvOccupied->Name + " ponowna zmiana kierunku" ); + DirectionForward(mvOccupied->ActiveDir < 0); // zmiana kierunku jazdy na właściwy + iDrivigFlags &= ~movePress; // koniec dociskania + JumpToNextOrder(); // zmieni światła + TableClear(); // skanowanie od nowa + iDrivigFlags &= ~moveStartHorn; // bez trąbienia przed ruszeniem + SetVelocity(fShuntVelocity, fShuntVelocity); // ustawienie prędkości jazdy + } + } + } + } + + if( true == TestFlag( OrderList[ OrderPos ], Change_direction ) ) { + // if ordered to change direction, try to stop + SetVelocity( 0, 0, stopDir ); + } + + if( VelNext == 0.0 ) { + if( !( OrderList[ OrderPos ] & ~( Shunt | Connect ) ) ) { + // jedzie w Shunt albo Connect, albo Wait_for_orders + // w trybie Connect skanować do tyłu tylko jeśli przed kolejnym sygnałem nie ma taboru do podłączenia + // Ra 2F1H: z tym (fTrackBlock) to nie jest najlepszy pomysł, bo lepiej by + // było porównać z odległością od sygnalizatora z przodu + if( ( OrderList[ OrderPos ] & Connect ) ? + ( pVehicles[ 0 ]->fTrackBlock > 2000 || pVehicles[ 0 ]->fTrackBlock > FirstSemaphorDist ) : + true ) { + if( ( comm = BackwardScan() ) != TCommandType::cm_Unknown ) { + // jeśli w drugą można jechać + // należy sprawdzać odległość od znalezionego sygnalizatora, + // aby w przypadku prędkości 0.1 wyciągnąć najpierw skład za sygnalizator + // i dopiero wtedy zmienić kierunek jazdy, oczekując podania prędkości >0.5 + if( comm == TCommandType::cm_Command ) { + // jeśli komenda Shunt to ją odbierz bez przemieszczania się (np. odczep wagony po dopchnięciu do końca toru) + iDrivigFlags |= moveStopHere; + } + iDirectionOrder = -iDirection; // zmiana kierunku jazdy + // zmiana kierunku bez psucia kolejnych komend + OrderList[ OrderPos ] = TOrders( OrderList[ OrderPos ] | Change_direction ); + } + } + } + } + + double vel = mvOccupied->Vel; // prędkość w kierunku jazdy + if (iDirection * mvOccupied->V < 0) + vel = -vel; // ujemna, gdy jedzie w przeciwną stronę, niż powinien + if (VelDesired < 0.0) + VelDesired = fVelMax; // bo VelDesired<0 oznacza prędkość maksymalną + + // Ra: jazda na widoczność +/* + // condition disabled, it'd prevent setting reduced acceleration in the last connect stage + if ((iDrivigFlags & moveConnect) == 0) // przy końcówce podłączania nie hamować +*/ + { // sprawdzenie jazdy na widoczność + auto const vehicle = pVehicles[ 0 ]; // base calculactions off relevant end of the consist + auto const coupler = + vehicle->MoverParameters->Couplers + ( + vehicle->DirectionGet() > 0 ? + 0 : + 1 ); // sprzęg z przodu składu + if( ( coupler->Connected ) + && ( coupler->CouplingFlag == coupling::faux ) ) { + // mamy coś z przodu podłączone sprzęgiem wirtualnym + // wyliczanie optymalnego przyspieszenia do jazdy na widoczność +/* + ActualProximityDist = std::min( + ActualProximityDist, + vehicle->fTrackBlock - ( + mvOccupied->CategoryFlag & 2 ? + fMinProximityDist : // cars can bunch up tighter + fMaxProximityDist ) ); // other vehicle types less so +*/ + double k = coupler->Connected->Vel; // prędkość pojazdu z przodu (zakładając, + // że jedzie w tę samą stronę!!!) + if( k - vel < 5 ) { + // porównanie modułów prędkości [km/h] + // zatroszczyć się trzeba, jeśli tamten nie jedzie znacząco szybciej + ActualProximityDist = std::min( + ActualProximityDist, + vehicle->fTrackBlock ); + + double const distance = vehicle->fTrackBlock - fMaxProximityDist - ( fBrakeDist * 1.15 ); // odległość bezpieczna zależy od prędkości + if( distance < 0.0 ) { + // jeśli odległość jest zbyt mała + if( k < 10.0 ) // k - prędkość tego z przodu + { // jeśli tamten porusza się z niewielką prędkością albo stoi + if( OrderCurrentGet() & Connect ) { + // jeśli spinanie, to jechać dalej + AccPreferred = std::min( 0.35, AccPreferred ); // nie hamuj + VelDesired = + min_speed( + VelDesired, + ( vehicle->fTrackBlock > 150.0 ? + 20.0: + 4.0 ) ); + VelNext = 2.0; // i pakuj się na tamtego + } + else { + // a normalnie to hamować + VelNext = 0.0; + if( vehicle->fTrackBlock <= fMinProximityDist ) { + VelDesired = 0.0; + } + + if( ( mvOccupied->CategoryFlag & 1 ) + && ( OrderCurrentGet() & Obey_train ) ) { + // trains which move normally should try to stop at safe margin + ActualProximityDist -= fDriverDist; + } + } + } + else { + // jeśli oba jadą, to przyhamuj lekko i ogranicz prędkość + if( vehicle->fTrackBlock < ( + ( mvOccupied->CategoryFlag & 2 ) ? + fMaxProximityDist + 0.5 * vel : // cars + 2.0 * fMaxProximityDist + 2.0 * vel ) ) { //others + // jak tamten jedzie wolniej a jest w drodze hamowania + AccPreferred = std::min( -0.9, AccPreferred ); + VelNext = min_speed( std::round( k ) - 5.0, VelDesired ); + if( vehicle->fTrackBlock <= ( + ( mvOccupied->CategoryFlag & 2 ) ? + fMaxProximityDist : // cars + 2.0 * fMaxProximityDist ) ) { //others + // try to force speed change if obstacle is really close + VelDesired = VelNext; + } + } + } + ReactionTime = ( + vel != 0.0 ? + 0.1 : // orientuj się, bo jest goraco + 2.0 ); // we're already standing still, so take it easy + } + else { + if( OrderCurrentGet() & Connect ) { + // if there's something nearby in the connect mode don't speed up too much + VelDesired = + min_speed( + VelDesired, + ( vehicle->fTrackBlock > 100.0 ? + 20.0 : + 4.0 ) ); + } + } + } + } + } + + // sprawdzamy możliwe ograniczenia prędkości + if( VelSignal >= 0 ) { + // jeśli skład był zatrzymany na początku i teraz już może jechać + VelDesired = + min_speed( + VelDesired, + VelSignal ); + } + if( mvOccupied->RunningTrack.Velmax >= 0 ) { + // ograniczenie prędkości z trajektorii ruchu + VelDesired = + min_speed( + VelDesired, + mvOccupied->RunningTrack.Velmax ); // uwaga na ograniczenia szlakowej! + } + if( VelforDriver >= 0 ) { + // tu jest zero przy zmianie kierunku jazdy + // Ra: tu może być 40, jeśli mechanik nie ma znajomości szlaaku, albo kierowca jeździ 70 + VelDesired = + min_speed( + VelDesired, + VelforDriver ); + } + if( fStopTime < 0 ) { + // czas postoju przed dalszą jazdą (np. na przystanku) + VelDesired = 0.0; // jak ma czekać, to nie ma jazdy + } + + if( ( OrderCurrentGet() & Obey_train ) != 0 ) { + + if( ( TrainParams->CheckTrainLatency() < 5.0 ) + && ( TrainParams->TTVmax > 0.0 ) ) { + // jesli nie spozniony to nie przekraczać rozkladowej + VelDesired = + min_speed( + VelDesired, + TrainParams->TTVmax ); + } + } + + if( ( OrderCurrentGet() & ( Shunt | Obey_train ) ) != 0 ) { + // w Connect nie, bo moveStopHere odnosi się do stanu po połączeniu + if( ( ( iDrivigFlags & moveStopHere ) != 0 ) + && ( vel < 0.01 ) + && ( VelSignalNext == 0.0 ) ) { + // jeśli ma czekać na wolną drogę, stoi a wyjazdu nie ma, to ma stać + VelDesired = 0.0; + } + } + + if( OrderCurrentGet() == Wait_for_orders ) { + // wait means sit and wait + VelDesired = 0.0; + } + // end of speed caps checks + + if( ( ( OrderCurrentGet() & Obey_train ) != 0 ) + && ( ( iDrivigFlags & moveGuardSignal ) != 0 ) + && ( VelDesired > 0.0 ) ) { + // komunikat od kierownika tu, bo musi być wolna droga i odczekany czas stania + iDrivigFlags &= ~moveGuardSignal; // tylko raz nadać + if( false == tsGuardSignal.empty() ) { + tsGuardSignal.stop(); + // w zasadzie to powinien mieć flagę, czy jest dźwiękiem radiowym, czy bezpośrednim + // albo trzeba zrobić dwa dźwięki, jeden bezpośredni, słyszalny w + // pobliżu, a drugi radiowy, słyszalny w innych lokomotywach + // na razie zakładam, że to nie jest dźwięk radiowy, bo trzeba by zrobić + // obsługę kanałów radiowych itd. + if( iGuardRadio == 0 ) { + // jeśli nie przez radio + tsGuardSignal.owner( pVehicle ); + // place virtual conductor some distance away + tsGuardSignal.offset( { pVehicle->MoverParameters->Dim.W * -0.75f, 1.7f, std::min( -20.0, -0.2 * fLength ) } ); + tsGuardSignal.play( sound_flags::exclusive ); + } + else { + // if (iGuardRadio==iRadioChannel) //zgodność kanału + // if (!FreeFlyModeFlag) //obserwator musi być w środku pojazdu + // (albo może mieć radio przenośne) - kierownik mógłby powtarzać przy braku reakcji + // TODO: proper system for sending/receiving radio messages + // place the sound in appropriate cab of the manned vehicle + tsGuardSignal.owner( pVehicle ); + tsGuardSignal.offset( { 0.f, 2.f, pVehicle->MoverParameters->Dim.L * 0.4f * ( pVehicle->MoverParameters->ActiveCab < 0 ? -1 : 1 ) } ); + tsGuardSignal.play( sound_flags::exclusive ); + } + } + } + + if( mvOccupied->Vel < 0.01 ) { + // Ra 2014-03: jesli skład stoi, to działa na niego składowa styczna grawitacji + AbsAccS = fAccGravity; + } + else { + AbsAccS = 0; + TDynamicObject *d = pVehicles[0]; // pojazd na czele składu + while (d) + { + AbsAccS += d->MoverParameters->TotalMass * d->MoverParameters->AccS * ( d->DirectionGet() == iDirection ? 1 : -1 ); + d = d->Next(); // kolejny pojazd, podłączony od tyłu (licząc od czoła) + } + AbsAccS *= iDirection; + AbsAccS /= fMass; + } + AbsAccS_pub = AbsAccS; + +#if LOGVELOCITY + // WriteLog("VelDesired="+AnsiString(VelDesired)+", + // VelSignal="+AnsiString(VelSignal)); + WriteLog("Vel=" + AnsiString(vel) + ", AbsAccS=" + AnsiString(AbsAccS) + + ", AccGrav=" + AnsiString(fAccGravity)); +#endif + // ustalanie zadanego przyspieszenia + //(ActualProximityDist) - odległość do miejsca zmniejszenia prędkości + //(AccPreferred) - wynika z psychyki oraz uwzglęnia już ewentualne zderzenie z pojazdem z przodu, ujemne gdy należy hamować + //(AccDesired) - uwzględnia sygnały na drodze ruchu, ujemne gdy należy hamować + //(fAccGravity) - chwilowe przspieszenie grawitacyjne, ujemne działa przeciwnie do zadanego kierunku jazdy + //(AbsAccS) - chwilowe przyspieszenie pojazu (uwzględnia grawitację), ujemne działa przeciwnie do zadanego kierunku jazdy + //(AccDesired) porównujemy z (fAccGravity) albo (AbsAccS) + if( ( VelNext >= 0.0 ) + && ( ActualProximityDist <= routescanrange ) + && ( vel >= VelNext ) ) { + // gdy zbliża się i jest za szybki do nowej prędkości, albo stoi na zatrzymaniu + if (vel > 0.0) { + // jeśli jedzie + if( ( vel < VelNext ) + && ( ActualProximityDist > fMaxProximityDist * ( 1.0 + 0.1 * vel ) ) ) { + // jeśli jedzie wolniej niż można i jest wystarczająco daleko, to można przyspieszyć + if( AccPreferred > 0.0 ) { + // jeśli nie ma zawalidrogi dojedz do semafora/przeszkody + AccDesired = AccPreferred; + } + } + else if (ActualProximityDist > fMinProximityDist) { + // jedzie szybciej, niż trzeba na końcu ActualProximityDist, ale jeszcze jest daleko + if (ActualProximityDist < fMaxProximityDist) { + // jak minął już maksymalny dystans po prostu hamuj (niski stopień) + // ma stanąć, a jest w drodze hamowania albo ma jechać +/* + VelDesired = min_speed( VelDesired, VelNext ); +*/ + if( VelNext == 0.0 ) { + if( mvOccupied->CategoryFlag & 1 ) { + // trains + if( ( OrderCurrentGet() & ( Shunt | Connect ) ) + && ( pVehicles[0]->fTrackBlock < 50.0 ) ) { + // crude detection of edge case, if approaching another vehicle coast slowly until min distance + // this should allow to bunch up trainsets more on sidings + VelDesired = min_speed( 5.0, VelDesired ); + } + else { + // hamowanie tak, aby stanąć + VelDesired = VelNext; + AccDesired = ( VelNext * VelNext - vel * vel ) / ( 25.92 * ( ActualProximityDist + 0.1 - 0.5*fMinProximityDist ) ); + AccDesired = std::min( AccDesired, fAccThreshold ); + } + } + else { + // for cars (and others) coast at low speed until we hit min proximity range + VelDesired = min_speed( VelDesired, 5.0 ); + } + } + } + else { + // outside of max safe range + AccDesired = AccPreferred; + if( vel > min_speed( (ActualProximityDist > 10.0 ? 10.0 : 5.0 ), VelDesired ) ) { + // allow to coast at reasonably low speed + auto const brakingdistance { fBrakeDist * braking_distance_multiplier( VelNext ) }; + auto const slowdowndistance { ( + mvOccupied->CategoryFlag == 2 ? // cars can stop on a dime, for bigger vehicles we enforce some minimal braking distance + brakingdistance : + std::max( + ( ( OrderCurrentGet() & Connect ) == 0 ? 100.0 : 25.0 ), + brakingdistance ) ) }; + if( ( brakingdistance + std::max( slowdowndistance, fMaxProximityDist ) ) >= ( ActualProximityDist - fMaxProximityDist ) ) { + // don't slow down prematurely; as long as we have room to come to a full stop at a safe distance, we're good + // ensure some minimal coasting speed, otherwise a vehicle entering this zone at very low speed will be crawling forever + auto const brakingpointoffset = VelNext * braking_distance_multiplier( VelNext ); + AccDesired = std::min( + AccDesired, + ( VelNext * VelNext - vel * vel ) + / ( 25.92 + * std::max( + ActualProximityDist - brakingpointoffset, + std::min( + ActualProximityDist, + brakingpointoffset ) ) + + 0.1 ) ); // najpierw hamuje mocniej, potem zluzuje + } + } + } + AccDesired = std::min( AccDesired, AccPreferred ); + } + else { + // jest bliżej niż fMinProximityDist + // utrzymuj predkosc bo juz blisko +/* + VelDesired = min_speed( VelDesired, VelNext ); +*/ + if( VelNext == 0.0 ) { + VelDesired = VelNext; + } + else { + if( vel <= VelNext + fVelPlus ) { + // jeśli niewielkie przekroczenie, ale ma jechać + AccDesired = std::max( 0.0, AccPreferred ); // to olej (zacznij luzować) + } + } + ReactionTime = 0.1; // i orientuj się szybciej + } + } + else { + // zatrzymany (vel==0.0) + if( VelNext > 0.0 ) { + // można jechać + AccDesired = AccPreferred; + } + else { + // jeśli daleko jechać nie można + if( ActualProximityDist > ( + ( mvOccupied->CategoryFlag & 2 ) ? + fMinProximityDist : // cars + fMaxProximityDist ) ) { // trains and others + // ale ma kawałek do sygnalizatora + if( AccPreferred > 0.0 ) { + // dociagnij do semafora; + AccDesired = AccPreferred; + } + else { + //stoj + VelDesired = 0.0; + } + } + else { + // VelNext=0 i stoi bliżej niż fMaxProximityDist + VelDesired = 0.0; + } + } + } + } + else { + // gdy jedzie wolniej niż potrzeba, albo nie ma przeszkód na drodze + // normalna jazda + AccDesired = ( + VelDesired != 0.0 ? + AccPreferred : + -0.01 ); + } + // koniec predkosci nastepnej + + // decisions based on current speed + if( mvOccupied->CategoryFlag == 1 ) { + + // on flats or uphill we can be less careful + if( vel > VelDesired ) { + // jesli jedzie za szybko do AKTUALNEGO + if( VelDesired == 0.0 ) { + // jesli stoj, to hamuj, ale i tak juz za pozno :) + AccDesired = std::min( AccDesired, -0.85 ); // hamuj solidnie + } + else { + // slow down, not full stop + if( vel > ( VelDesired + fVelPlus ) ) { + // hamuj tak średnio + AccDesired = std::min( AccDesired, -0.25 ); + } + else { + // o 5 km/h to olej (zacznij luzować) + AccDesired = std::min( + AccDesired, // but don't override decceleration for VelNext + std::max( 0.0, AccPreferred ) ); + } + } + } + + if( fAccGravity > 0.025 ) { + // going sharply downhill we may need to start braking sooner than usual + // try to estimate increase of current velocity before engaged brakes start working + auto const speedestimate = vel + ( 1.0 - fBrake_a0[ 0 ] ) * 30.0 * AbsAccS; + if( speedestimate > VelDesired ) { + // jesli jedzie za szybko do AKTUALNEGO + if( VelDesired == 0.0 ) { + // jesli stoj, to hamuj, ale i tak juz za pozno :) + AccDesired = std::min( AccDesired, -0.85 ); // hamuj solidnie + } + else { + // if it looks like we'll exceed maximum speed start thinking about slight slowing down + AccDesired = std::min( AccDesired, -0.25 ); + // HACK: for cargo trains with high braking threshold ensure we cross that threshold + if( ( true == IsCargoTrain ) + && ( fBrake_a0[ 0 ] > 0.2 ) ) { + AccDesired -= clamp( fBrake_a0[ 0 ] - 0.2, 0.0, 0.15 ); + } + } + } + else { + // stop accelerating when close enough to target speed + AccDesired = std::min( + AccDesired, // but don't override decceleration for VelNext + interpolate( // ease off as you close to the target velocity + -0.06, AccPreferred, + clamp( VelDesired - speedestimate, 0.0, fVelMinus ) / fVelMinus ) ); + } + // final tweaks + if( vel > 0.1 ) { + // going downhill also take into account impact of gravity + AccDesired -= fAccGravity; + // HACK: if the max allowed speed was exceeded something went wrong; brake harder + AccDesired -= 0.15 * clamp( vel - VelDesired, 0.0, 5.0 ); +/* + if( ( vel > VelDesired ) + && ( ( mvOccupied->BrakeDelayFlag & bdelay_G ) != 0 ) + && ( fBrake_a0[ 0 ] > 0.2 ) ) { + AccDesired = clamp( + AccDesired - clamp( fBrake_a0[ 0 ] - 0.2, 0.0, 0.15 ), + -0.9, 0.9 ); + } +*/ + } + } + } + else { + // for cars the older version works better + if( vel > VelDesired ) { + // jesli jedzie za szybko do AKTUALNEGO + if( VelDesired == 0.0 ) { + // jesli stoj, to hamuj, ale i tak juz za pozno :) + AccDesired = std::min( AccDesired, -0.9 ); // hamuj solidnie + } + else { + // slow down, not full stop + if( vel > ( VelDesired + fVelPlus ) ) { + // hamuj tak średnio + AccDesired = std::min( AccDesired, -fBrake_a0[ 0 ] * 0.5 ); + } + else { + // o 5 km/h to olej (zacznij luzować) + AccDesired = std::min( + AccDesired, // but don't override decceleration for VelNext + std::max( 0.0, AccPreferred ) ); + } + } + } + } + // koniec predkosci aktualnej + + // last step sanity check, until the whole calculation is straightened out + AccDesired = std::min( AccDesired, AccPreferred ); + AccDesired = clamp( + AccDesired, + ( mvControlling->CategoryFlag == 2 ? -2.0 : -0.9 ), + ( mvControlling->CategoryFlag == 2 ? 2.0 : 0.9 ) ); + + if (AIControllFlag) { + // część wykonawcza tylko dla AI, dla człowieka jedynie napisy + + // zapobieganie poslizgowi u nas + if (mvControlling->SlippingWheels) { + + if( false == mvControlling->DecScndCtrl( 2 ) ) { + // bocznik na zero + mvControlling->DecMainCtrl( 1 ); + } + DecBrake(); // cofnij hamulec + mvControlling->AntiSlippingButton(); + ++iDriverFailCount; + } + if (iDriverFailCount > maxdriverfails) { + + Psyche = Easyman; + if (iDriverFailCount > maxdriverfails * 2) + SetDriverPsyche(); + } + + if( ( true == mvOccupied->RadioStopFlag ) // radio-stop + && ( mvOccupied->Vel > 0.0 ) ) { // and still moving + // if the radio-stop was issued don't waste effort trying to fight it + while( true == DecSpeed() ) { ; } // just throttle down... + return; // ...and don't touch any other controls + } + + if (mvControlling->ConvOvldFlag || + !mvControlling->Mains) // WS może wywalić z powodu błędu w drutach + { // wywalił bezpiecznik nadmiarowy przetwornicy + PrepareEngine(); // próba ponownego załączenia + } + // włączanie bezpiecznika + if ((mvControlling->EngineType == TEngineType::ElectricSeriesMotor) || + (mvControlling->TrainType & dt_EZT) || + (mvControlling->EngineType == TEngineType::DieselElectric)) + if (mvControlling->FuseFlag || Need_TryAgain) + { + Need_TryAgain = false; // true, jeśli druga pozycja w elektryku nie załapała + mvControlling->DecScndCtrl(2); // nastawnik bocznikowania na 0 + mvControlling->DecMainCtrl(2); // nastawnik jazdy na 0 + mvControlling->MainSwitch(true); // Ra: dodałem, bo EN57 stawały po wywaleniu + if (mvControlling->FuseOn()) { + ++iDriverFailCount; + if (iDriverFailCount > maxdriverfails) + Psyche = Easyman; + if (iDriverFailCount > maxdriverfails * 2) + SetDriverPsyche(); + } + } + // NOTE: as a stop-gap measure the routine is limited to trains only while car calculations seem off + if( mvControlling->CategoryFlag == 1 ) { + if( vel < VelDesired ) { + // don't adjust acceleration when going above current goal speed + if( -AccDesired * BrakeAccFactor() < ( + ( ( fReady > 0.4 ) + || ( VelNext > vel - 40.0 ) ) ? + fBrake_a0[ 0 ] * 0.8 : + -fAccThreshold ) + / braking_distance_multiplier( VelNext ) ) { + AccDesired = std::max( -0.06, AccDesired ); + } + } + else { + // i orientuj się szybciej, jeśli hamujesz + ReactionTime = 0.25; + } + } + if (mvOccupied->BrakeSystem == TBrakeSystem::Pneumatic) // napełnianie uderzeniowe + if (mvOccupied->BrakeHandle == TBrakeHandle::FV4a) + { + if( mvOccupied->BrakeCtrlPos == -2 ) { + mvOccupied->BrakeLevelSet( 0 ); + } + if( ( mvOccupied->PipePress < 3.0 ) + && ( AccDesired > -0.03 ) ) { + mvOccupied->BrakeReleaser( 1 ); + } + + if( ( mvOccupied->BrakeCtrlPos == 0 ) + && ( AbsAccS < 0.03 ) + && ( AccDesired > -0.03 ) + && ( VelDesired - mvOccupied->Vel > 2.0 ) ) { + + if( ( mvOccupied->EqvtPipePress < 4.95 ) + && ( fReady > 0.35 ) + && ( BrakeChargingCooldown >= 0.0 ) ) { + + if( ( iDrivigFlags & moveOerlikons ) + || ( true == IsCargoTrain ) ) { + // napełnianie w Oerlikonie + mvOccupied->BrakeLevelSet( mvOccupied->Handle->GetPos( bh_FS ) ); + // don't charge the brakes too often, or we risk overcharging + BrakeChargingCooldown = -120.0; + } + } + else if( Need_BrakeRelease ) { + Need_BrakeRelease = false; + mvOccupied->BrakeReleaser( 1 ); + } + } + + if( ( mvOccupied->BrakeCtrlPos < 0 ) + && ( mvOccupied->EqvtPipePress > ( fReady < 0.25 ? 5.1 : 5.2 ) ) ) { + mvOccupied->BrakeLevelSet( mvOccupied->Handle->GetPos( bh_RP ) ); + } + } +#if LOGVELOCITY + WriteLog("Dist=" + FloatToStrF(ActualProximityDist, ffFixed, 7, 1) + + ", VelDesired=" + FloatToStrF(VelDesired, ffFixed, 7, 1) + + ", AccDesired=" + FloatToStrF(AccDesired, ffFixed, 7, 3) + + ", VelSignal=" + AnsiString(VelSignal) + ", VelNext=" + + AnsiString(VelNext)); +#endif + if( ( vel < 10.0 ) + && ( AccDesired > 0.1 ) ) { + // Ra 2F1H: jeśli prędkość jest mała, a można przyspieszać, + // to nie ograniczać przyspieszenia do 0.5m/ss + // przy małych prędkościach może być trudno utrzymać + AccDesired = std::max( 0.9, AccDesired ); + } + // małe przyspieszenie + // Ra 2F1I: wyłączyć kiedyś to uśrednianie i przeanalizować skanowanie, czemu migocze + if (AccDesired > -0.05) // hamowania lepeiej nie uśredniać + AccDesired = fAccDesiredAv = + 0.2 * AccDesired + + 0.8 * fAccDesiredAv; // uśrednione, żeby ograniczyć migotanie + if( VelDesired == 0.0 ) { + // Ra 2F1J: jeszcze jedna prowizoryczna łatka + if( AccDesired >= -0.01 ) { + AccDesired = -0.01; + } + } + if( AccDesired >= 0.0 ) { + if( true == TestFlag( iDrivigFlags, movePress ) ) { + // wyluzuj lokomotywę - może być więcej! + mvOccupied->BrakeReleaser( 1 ); + } + else if( OrderList[ OrderPos ] != Disconnect ) { + // przy odłączaniu nie zwalniamy tu hamulca + if( ( fAccGravity * fAccGravity < 0.001 ? + true : + AccDesired > 0.0 ) ) { + // on slopes disengage the brakes only if you actually intend to accelerate + while( true == DecBrake() ) { ; } // jeśli przyspieszamy, to nie hamujemy + if( ( mvOccupied->BrakePress > 0.4 ) + && ( mvOccupied->Hamulec->GetCRP() > 4.9 ) ) { + // wyluzuj lokomotywę, to szybciej ruszymy + mvOccupied->BrakeReleaser( 1 ); + } + else { + if( mvOccupied->PipePress >= 3.0 ) { + // TODO: combine all releaser handling in single decision tree instead of having bits all over the place + mvOccupied->BrakeReleaser( 0 ); + } + } + } + } + } + // yB: usunięte różne dziwne warunki, oddzielamy część zadającą od wykonawczej + // zwiekszanie predkosci + // Ra 2F1H: jest konflikt histerezy pomiędzy nastawioną pozycją a uzyskiwanym + // przyspieszeniem - utrzymanie pozycji powoduje przekroczenie przyspieszenia + if( ( AccDesired - AbsAccS > 0.01 ) ) { + // jeśli przyspieszenie pojazdu jest mniejsze niż żądane oraz... + if( vel < ( + VelDesired == 1.0 ? // work around for trains getting stuck on tracks with speed limit = 1 + VelDesired : + VelDesired - fVelMinus ) ) { + // ...jeśli prędkość w kierunku czoła jest mniejsza od dozwolonej o margines + if( ( ActualProximityDist > ( + ( mvOccupied->CategoryFlag & 2 ) ? + fMinProximityDist : // cars are allowed to move within min proximity distance + fMaxProximityDist ) ? // other vehicle types keep wider margin + true : + ( vel + 1.0 ) < VelNext ) ) { + // to można przyspieszyć + IncSpeed(); + } + } + } + // yB: usunięte różne dziwne warunki, oddzielamy część zadającą od wykonawczej + // zmniejszanie predkosci + // margines dla prędkości jest doliczany tylko jeśli oczekiwana prędkość jest większa od 5km/h + if( false == TestFlag( iDrivigFlags, movePress ) ) { + // jeśli nie dociskanie + if( AccDesired < -0.05 ) { + while( true == DecSpeed() ) { ; } // jeśli hamujemy, to nie przyspieszamy + } + else if( ( vel > VelDesired ) + || ( fAccGravity < -0.01 ? + AccDesired < 0.0 : + AbsAccS > AccDesired ) ) { + // jak za bardzo przyspiesza albo prędkość przekroczona + DecSpeed(); // pojedyncze cofnięcie pozycji, bo na zero to przesada + } + } + if( mvOccupied->TrainType == dt_EZT ) { + // właściwie, to warunek powinien być na działający EP + // Ra: to dobrze hamuje EP w EZT + // HACK: when going downhill be more responsive to desired deceleration + auto const accthreshold { ( + fAccGravity < 0.025 ? + fAccThreshold : + std::max( -0.2, fAccThreshold ) ) }; + if( ( AccDesired <= accthreshold ) // jeśli hamować - u góry ustawia się hamowanie na fAccThreshold + && ( ( AbsAccS > AccDesired ) + || ( mvOccupied->BrakeCtrlPos < 0 ) ) ) { + // hamować bardziej, gdy aktualne opóźnienie hamowania mniejsze niż (AccDesired) + IncBrake(); + } + else if( OrderList[ OrderPos ] != Disconnect ) { + // przy odłączaniu nie zwalniamy tu hamulca + if( AbsAccS < AccDesired - 0.05 ) { + // jeśli opóźnienie większe od wymaganego (z histerezą) luzowanie, gdy za dużo + if( mvOccupied->BrakeCtrlPos >= 0 ) { + DecBrake(); // tutaj zmniejszało o 1 przy odczepianiu + } + } + else if( mvOccupied->Handle->TimeEP ) { + if( mvOccupied->Handle->GetPos( bh_EPR ) - + mvOccupied->Handle->GetPos( bh_EPN ) < + 0.1 ) { + mvOccupied->SwitchEPBrake( 0 ); + } + else { + mvOccupied->BrakeLevelSet( mvOccupied->Handle->GetPos( bh_EPN ) ); + } + } + } // order != disconnect + } // type & dt_ezt + else { + // a stara wersja w miarę dobrze działa na składy wagonowe + if( ( ( fAccGravity < -0.05 ) && ( vel < -0.1 ) ) // brake if uphill and slipping back + || ( ( AccDesired < fAccGravity - 0.1 ) && ( AbsAccS > AccDesired + fBrake_a1[ 0 ] ) ) ) { + // u góry ustawia się hamowanie na fAccThreshold + if( ( fBrakeTime < 0.0 ) + || ( AccDesired < fAccGravity - 0.5 ) + || ( mvOccupied->BrakeCtrlPos <= 0 ) ) { + // jeśli upłynął czas reakcji hamulca, chyba że nagłe albo luzował + if( true == IncBrake() ) { + fBrakeTime = + 3.0 + + 0.5 * ( ( + mvOccupied->BrakeDelayFlag > bdelay_G ? + mvOccupied->BrakeDelay[ 1 ] : + mvOccupied->BrakeDelay[ 3 ] ) + - 3.0 ); + // Ra: ten czas należy zmniejszyć, jeśli czas dojazdu do zatrzymania jest mniejszy + fBrakeTime *= 0.5; // Ra: tymczasowo, bo przeżyna S1 + } + } + } + if ((AccDesired < fAccGravity - 0.05) && (AbsAccS < AccDesired - fBrake_a1[0]*0.51)) { + // jak hamuje, to nie tykaj kranu za często + // yB: luzuje hamulec dopiero przy różnicy opóźnień rzędu 0.2 + if( OrderList[ OrderPos ] != Disconnect ) { + // przy odłączaniu nie zwalniamy tu hamulca + DecBrake(); // tutaj zmniejszało o 1 przy odczepianiu + } + fBrakeTime = ( + mvOccupied->BrakeDelayFlag > bdelay_G ? + mvOccupied->BrakeDelay[ 0 ] : + mvOccupied->BrakeDelay[ 2 ] ) + / 3.0; + fBrakeTime *= 0.5; // Ra: tymczasowo, bo przeżyna S1 + } + // stop-gap measure to ensure cars actually brake to stop even when above calculactions go awry + // instead of releasing the brakes and creeping into obstacle at 1-2 km/h + if( mvControlling->CategoryFlag == 2 ) { + if( ( VelDesired == 0.0 ) + && ( vel > VelDesired ) + && ( ActualProximityDist <= fMinProximityDist ) + && ( mvOccupied->LocalBrakePosA < 0.01 ) ) { + IncBrake(); + } + } + } + // Mietek-end1 + SpeedSet(); // ciągla regulacja prędkości +#if LOGVELOCITY + WriteLog("BrakePos=" + AnsiString(mvOccupied->BrakeCtrlPos) + ", MainCtrl=" + + AnsiString(mvControlling->MainCtrlPos)); +#endif + } // if (AIControllFlag) + } // kierunek różny od zera + else + { // tutaj, gdy pojazd jest wyłączony + if (!AIControllFlag) // jeśli sterowanie jest w gestii użytkownika + if (mvOccupied->Battery) // czy użytkownik załączył baterię? + if (mvOccupied->ActiveDir) // czy ustawił kierunek + { // jeśli tak, to uruchomienie skanowania + CheckVehicles(); // sprawdzić skład + TableClear(); // resetowanie tabelki skanowania + PrepareEngine(); // uruchomienie + } + } + if (AIControllFlag) + { // odhamowywanie składu po zatrzymaniu i zabezpieczanie lokomotywy + if( ( ( OrderList[ OrderPos ] & ( Disconnect | Connect ) ) == 0 ) + && ( std::abs( fAccGravity ) < 0.01 ) ) { + // przy (p)odłączaniu nie zwalniamy tu hamulca + // only do this on flats, on slopes keep applied the train brake + if( ( mvOccupied->Vel < 0.01 ) + && ( ( VelDesired == 0.0 ) + || ( AccDesired == 0.0 ) ) ) { + if( mvOccupied->BrakeCtrlPos == mvOccupied->Handle->GetPos( bh_RP ) ) { + // dodatkowy na pozycję 1 + mvOccupied->IncLocalBrakeLevel( 1 ); + } + else { + mvOccupied->BrakeLevelSet( mvOccupied->Handle->GetPos( bh_RP ) ); + } + } + } + } + break; // rzeczy robione przy jezdzie + } // switch (OrderList[OrderPos]) +} + +// configures vehicle heating given current situation; returns: true if vehicle can be operated normally, false otherwise +bool +TController::UpdateHeating() { + + switch( mvControlling->EngineType ) { + + case TEngineType::DieselElectric: + case TEngineType::DieselEngine: { + + auto const &heat { mvControlling->dizel_heat }; + + // determine whether there's need to enable the water heater + // if the heater has configured maximum temperature, it'll disable itself automatically, so we can leave it always running + // otherwise enable the heater only to maintain minimum required temperature + auto const lowtemperature { ( + ( ( heat.water.config.temp_min > 0 ) && ( heat.temperatura1 < heat.water.config.temp_min + ( mvControlling->WaterHeater.is_active ? 5 : 0 ) ) ) + || ( ( heat.water_aux.config.temp_min > 0 ) && ( heat.temperatura2 < heat.water_aux.config.temp_min + ( mvControlling->WaterHeater.is_active ? 5 : 0 ) ) ) + || ( ( heat.oil.config.temp_min > 0 ) && ( heat.To < heat.oil.config.temp_min + ( mvControlling->WaterHeater.is_active ? 5 : 0 ) ) ) ) }; + auto const heateron { ( + ( mvControlling->WaterHeater.config.temp_max > 0 ) + || ( true == lowtemperature ) ) }; + if( true == heateron ) { + // make sure the water pump is running before enabling the heater + if( false == mvControlling->WaterPump.is_active ) { + mvControlling->WaterPumpBreakerSwitch( true ); + mvControlling->WaterPumpSwitch( true ); + } + if( true == mvControlling->WaterPump.is_active ) { + mvControlling->WaterHeaterBreakerSwitch( true ); + mvControlling->WaterHeaterSwitch( true ); + mvControlling->WaterCircuitsLinkSwitch( true ); + } + } + else { + // no need to heat anything up, switch the heater off + mvControlling->WaterCircuitsLinkSwitch( false ); + mvControlling->WaterHeaterSwitch( false ); + mvControlling->WaterHeaterBreakerSwitch( false ); + // optionally turn off the water pump as well + if( mvControlling->WaterPump.start_type != start_t::battery ) { + mvControlling->WaterPumpSwitch( false ); + mvControlling->WaterPumpBreakerSwitch( false ); + } + } + + return ( false == lowtemperature ); + } + default: { + return true; + } } - else // if (AIControllFlag) - return false; // AI nie obsługuje } void TController::JumpToNextOrder() @@ -4754,8 +5567,18 @@ void TController::JumpToFirstOrder() void TController::OrderCheck() { // reakcja na zmianę rozkazu - if (OrderList[OrderPos] & (Shunt | Connect | Obey_train)) + + if( OrderList[ OrderPos ] != Obey_train ) { + // reset light hints + m_lighthints[ side::front ] = m_lighthints[ side::rear ] = -1; + } + if( OrderList[ OrderPos ] & ( Shunt | Connect | Obey_train ) ) { CheckVehicles(); // sprawdzić światła + } + if( OrderList[ OrderPos ] & ( Shunt | Connect ) ) { + // HACK: ensure consist doors will be closed on departure + iDrivigFlags |= moveDoorOpened; + } if (OrderList[OrderPos] & Change_direction) // może być nałożona na inną i wtedy ma priorytet iDirectionOrder = -iDirection; // trzeba zmienić jawnie, bo się nie domyśli else if (OrderList[OrderPos] == Obey_train) @@ -4805,7 +5628,7 @@ void TController::OrderPush(TOrders NewOrder) if (OrderTop >= maxorders) ErrorLog("Commands overflow: The program will now crash"); #if LOGORDERS - WriteLog("--> OrderPush"); + WriteLog("--> OrderPush: [" + Order2Str( NewOrder ) + "]"); OrdersDump(); // normalnie nie ma po co tego wypisywać #endif } @@ -4835,8 +5658,6 @@ inline TOrders TController::OrderNextGet() void TController::OrdersInit(double fVel) { // wypełnianie tabelki rozkazów na podstawie rozkładu // ustawienie kolejności komend, niezależnie kto prowadzi - // Mechanik->OrderPush(Wait_for_orders); //czekanie na lepsze czasy - // OrderPos=OrderTop=0; //wypełniamy od pozycji 0 OrdersClear(); // usunięcie poprzedniej tabeli OrderPush(Prepare_engine); // najpierw odpalenie silnika if (TrainParams->TrainName == "none") @@ -4850,16 +5671,14 @@ void TController::OrdersInit(double fVel) OrderPush(Shunt); // dla prędkości 0.01 włączamy jazdę manewrową else if (TrainParams ? (TrainParams->DirectionChange() ? // jeśli obrót na pierwszym przystanku - ((iDrivigFlags & - movePushPull) ? // SZT również! SN61 zależnie od wagonów... + ((iDrivigFlags & movePushPull) ? // SZT również! SN61 zależnie od wagonów... (TrainParams->TimeTable[1].StationName == TrainParams->Relation1) : false) : false) : true) OrderPush(Shunt); // a teraz start będzie w manewrowym, a tryb pociągowy włączy W4 else - // jeśli start z pierwszej stacji i jednocześnie jest na niej zmiana kierunku, to EZT ma - // mieć Shunt + // jeśli start z pierwszej stacji i jednocześnie jest na niej zmiana kierunku, to EZT ma mieć Shunt OrderPush(Obey_train); // dla starych scenerii start w trybie pociagowym if (DebugModeFlag) // normalnie nie ma po co tego wypisywać WriteLog("/* Timetable: " + TrainParams->ShowRelation()); @@ -4867,10 +5686,14 @@ void TController::OrdersInit(double fVel) for (int i = 0; i <= TrainParams->StationCount; ++i) { t = TrainParams->TimeTable + i; - if (DebugModeFlag) // normalnie nie ma po co tego wypisywa? - WriteLog(t->StationName + " " + std::to_string(t->Ah) + ":" + - std::to_string(t->Am) + ", " + std::to_string(t->Dh) + ":" + - std::to_string(t->Dm) + " " + t->StationWare); + if (DebugModeFlag) { + // normalnie nie ma po co tego wypisywa? + WriteLog( + t->StationName + + " " + std::to_string(t->Ah) + ":" + std::to_string(t->Am) + + ", " + std::to_string(t->Dh) + ":" + std::to_string(t->Dm) + + " " + t->StationWare); + } if (t->StationWare.find('@') != std::string::npos) { // zmiana kierunku i dalsza jazda wg rozk?adu if (iDrivigFlags & movePushPull) // SZT również! SN61 zależnie od wagonów... @@ -4881,33 +5704,34 @@ void TController::OrdersInit(double fVel) { // dla zwykłego składu wagonowego odczepiamy lokomotywę OrderPush(Disconnect); // odczepienie lokomotywy OrderPush(Shunt); // a dalej manewry - if (i <= TrainParams->StationCount) // 130827: to się jednak nie sprawdza - { //"@" na ostatniej robi tylko odpięcie - // OrderPush(Change_direction); //zmiana kierunku - // OrderPush(Shunt); //jazda na drugą stronę składu - // OrderPush(Change_direction); //zmiana kierunku - // OrderPush(Connect); //jazda pod wagony - } } if (i < TrainParams->StationCount) // jak nie ostatnia stacja OrderPush(Obey_train); // to dalej wg rozkładu } } - if (DebugModeFlag) // normalnie nie ma po co tego wypisywać - WriteLog("*/"); + if( DebugModeFlag ) { + // normalnie nie ma po co tego wypisywać + WriteLog( "*/" ); + } OrderPush(Shunt); // po wykonaniu rozkładu przełączy się na manewry } // McZapkie-100302 - to ma byc wyzwalane ze scenerii - if (fVel == 0.0) - SetVelocity(0, 0, stopSleep); // jeśli nie ma prędkości początkowej, to śpi - else - { // jeśli podana niezerowa prędkość - if ((fVel >= 1.0) || - (fVel < 0.02)) // jeśli ma jechać - dla 0.01 ma podjechać manewrowo po podaniu sygnału - iDrivigFlags = (iDrivigFlags & ~moveStopHere) | - moveStopCloser; // to do następnego W4 ma podjechać blisko - else - iDrivigFlags |= moveStopHere; // czekać na sygnał + if( fVel == 0.0 ) { + // jeśli nie ma prędkości początkowej, to śpi + SetVelocity( 0, 0, stopSleep ); + } + else { + // jeśli podana niezerowa prędkość + if( ( fVel >= 1.0 ) + || ( fVel < 0.02 ) ) { + // jeśli ma jechać - dla 0.01 ma podjechać manewrowo po podaniu sygnału + // to do następnego W4 ma podjechać blisko + iDrivigFlags = ( iDrivigFlags & ~( moveStopHere ) ) | moveStopCloser; + } + else { + // czekać na sygnał + iDrivigFlags |= moveStopHere; + } JumpToFirstOrder(); if (fVel >= 1.0) // jeśli ma jechać SetVelocity(fVel, -1); // ma ustawić żądaną prędkość @@ -4923,12 +5747,12 @@ void TController::OrdersInit(double fVel) // Ale mozna by je zapodac ze scenerii }; -string TController::StopReasonText() +std::string TController::StopReasonText() { // informacja tekstowa o przyczynie zatrzymania if (eStopReason != 7) // zawalidroga będzie inaczej return StopReasonTable[eStopReason]; else - return "Blocked by " + (pVehicles[0]->PrevAny()->GetName()); + return "Blocked by " + (pVehicles[0]->PrevAny()->name()); }; //---------------------------------------------------------------------------------------------------------------------- @@ -4938,25 +5762,8 @@ string TController::StopReasonText() //- rozpoznają tylko zerową prędkość (jako koniec toru i brak podstaw do dalszego skanowania) //---------------------------------------------------------------------------------------------------------------------- -/* //nie używane -double TController::Distance(vector3 &p1,vector3 &n,vector3 &p2) -{//Ra:obliczenie odległości punktu (p1) od płaszczyzny o wektorze normalnym (n) przechodzącej przez -(p2) - return n.x*(p1.x-p2.x)+n.y*(p1.y-p2.y)+n.z*(p1.z-p2.z); //ax1+by1+cz1+d, gdzie d=-(ax2+by2+cz2) -}; -*/ - bool TController::BackwardTrackBusy(TTrack *Track) { // najpierw sprawdzamy, czy na danym torze są pojazdy z innego składu -#ifdef EU07_USE_OLD_TTRACK_DYNAMICS_ARRAY - if (Track->iNumDynamics) - { // jeśli tylko z własnego składu, to tor jest wolny - for (int i = 0; i < Track->iNumDynamics; ++i) - if (Track->Dynamics[i]->ctOwner != this) // jeśli jest jakiś cudzy - return true; // to tor jest zajęty i skanowanie nie obowiązuje - } - return false; // wolny -#else if( false == Track->Dynamics.empty() ) { for( auto dynamic : Track->Dynamics ) { if( dynamic->ctOwner != this ) { @@ -4966,21 +5773,24 @@ bool TController::BackwardTrackBusy(TTrack *Track) } } return false; // wolny -#endif }; -TEvent * TController::CheckTrackEventBackward(double fDirection, TTrack *Track) +basic_event * TController::CheckTrackEventBackward(double fDirection, TTrack *Track) { // sprawdzanie eventu w torze, czy jest sygnałowym - skanowanie do tyłu - TEvent *e = (fDirection > 0) ? Track->evEvent2 : Track->evEvent1; - if (e) - if (!e->bEnabled) // jeśli sygnałowy (nie dodawany do kolejki) - if (e->Type == tp_GetValues) // PutValues nie może się zmienić - return e; - return NULL; + // NOTE: this method returns only one event which meets the conditions, due to limitations in the caller + // TBD, TODO: clean up the caller and return all suitable events, as in theory things will go awry if the track has more than one signal + auto const &eventsequence { ( fDirection > 0 ? Track->m_events2 : Track->m_events1 ) }; + for( auto const &event : eventsequence ) { + if( ( event.second != nullptr ) + && ( event.second->m_passive ) + && ( typeid(*(event.second)) == typeid( getvalues_event ) ) ) { + return event.second; + } + } + return nullptr; }; -TTrack * TController::BackwardTraceRoute(double &fDistance, double &fDirection, - TTrack *Track, TEvent *&Event) +TTrack * TController::BackwardTraceRoute(double &fDistance, double &fDirection, TTrack *Track, basic_event *&Event) { // szukanie sygnalizatora w kierunku przeciwnym jazdy (eventu odczytu komórki pamięci) TTrack *pTrackChVel = Track; // tor ze zmianą prędkości TTrack *pTrackFrom; // odcinek poprzedni, do znajdywania końca dróg @@ -5023,10 +5833,11 @@ TTrack * TController::BackwardTraceRoute(double &fDistance, double &fDirection, } if (Track == pTrackFrom) Track = NULL; // koniec, tak jak dla torów - if (Track ? - (Track->VelocityGet() == 0.0) || (Track->iDamageFlag & 128) || - BackwardTrackBusy(Track) : - true) + if( ( Track ? + ( ( Track->VelocityGet() == 0.0 ) + || ( Track->iDamageFlag & 128 ) + || ( true == BackwardTrackBusy( Track ) ) ) : + true ) ) { // gdy dalej toru nie ma albo zerowa prędkość, albo uszkadza pojazd fDistance = s; return NULL; // zwraca NULL, że skanowanie nie dało sensownych rezultatów @@ -5049,7 +5860,7 @@ TTrack * TController::BackwardTraceRoute(double &fDistance, double &fDirection, } // sprawdzanie zdarzeń semaforów i ograniczeń szlakowych -void TController::SetProximityVelocity(double dist, double vel, const vector3 *pos) +void TController::SetProximityVelocity( double dist, double vel, glm::dvec3 const *pos ) { // Ra:przeslanie do AI prędkości /* //!!!! zastąpić prawidłową reakcją AI na SetProximityVelocity !!!! @@ -5061,7 +5872,7 @@ void TController::SetProximityVelocity(double dist, double vel, const vector3 *p if ((vel<0)?true:dist>0.1*(MoverParameters->Vel*MoverParameters->Vel-vel*vel)+50) {//jeśli jest dalej od umownej drogi hamowania */ - PutCommand("SetProximityVelocity", dist, vel, pos); + PutCommand( "SetProximityVelocity", dist, vel, pos ); /* } else @@ -5073,114 +5884,117 @@ void TController::SetProximityVelocity(double dist, double vel, const vector3 *p TCommandType TController::BackwardScan() { // sprawdzanie zdarzeń semaforów z tyłu pojazdu, zwraca komendę - // dzięki temu będzie można stawać za wskazanym sygnalizatorem, a zwłaszcza jeśli będzie jazda - // na kozioł - // ograniczenia prędkości nie są wtedy istotne, również koniec toru jest do niczego nie - // przydatny + // dzięki temu będzie można stawać za wskazanym sygnalizatorem, a zwłaszcza jeśli będzie jazda na kozioł + // ograniczenia prędkości nie są wtedy istotne, również koniec toru jest do niczego nie przydatny // zwraca true, jeśli należy odwrócić kierunek jazdy pojazdu - if ((OrderList[OrderPos] & ~(Shunt | Connect))) - return cm_Unknown; // skanowanie sygnałów tylko gdy jedzie w trybie manewrowym albo czeka na - // rozkazy - vector3 sl; - int startdir = - -pVehicles[0]->DirectionGet(); // kierunek jazdy względem sprzęgów pojazdu na czele - if (startdir == 0) // jeśli kabina i kierunek nie jest określony - return cm_Unknown; // nie robimy nic - double scandir = - startdir * pVehicles[0]->RaDirectionGet(); // szukamy od pierwszej osi w wybranym kierunku - if (scandir != - 0.0) // skanowanie toru w poszukiwaniu eventów GetValues (PutValues nie są przydatne) - { // Ra: przy wstecznym skanowaniu prędkość nie ma znaczenia - // scanback=pVehicles[1]->NextDistance(fLength+1000.0); //odległość do następnego pojazdu, - // 1000 gdy nic nie ma + if( ( OrderList[ OrderPos ] & ~( Shunt | Connect ) ) ) { + // skanowanie sygnałów tylko gdy jedzie w trybie manewrowym albo czeka na rozkazy + return TCommandType::cm_Unknown; + } + // kierunek jazdy względem sprzęgów pojazdu na czele + int const startdir = -pVehicles[0]->DirectionGet(); + if( startdir == 0 ) { + // jeśli kabina i kierunek nie jest określony nie robimy nic + return TCommandType::cm_Unknown; + } + // szukamy od pierwszej osi w wybranym kierunku + double scandir = startdir * pVehicles[0]->RaDirectionGet(); + if (scandir != 0.0) { + // skanowanie toru w poszukiwaniu eventów GetValues (PutValues nie są przydatne) + // Ra: przy wstecznym skanowaniu prędkość nie ma znaczenia double scanmax = 1000; // 1000m do tyłu, żeby widział przeciwny koniec stacji double scandist = scanmax; // zmodyfikuje na rzeczywiście przeskanowane - TEvent *e = NULL; // event potencjalnie od semafora - // opcjonalnie może być skanowanie od "wskaźnika" z przodu, np. W5, Tm=Ms1, koniec toru - TTrack *scantrack = BackwardTraceRoute(scandist, scandir, pVehicles[0]->RaTrackGet(), - e); // wg drugiej osi w kierunku ruchu - vector3 dir = startdir * pVehicles[0]->VectorFront(); // wektor w kierunku jazdy/szukania - if (!scantrack) // jeśli wstecz wykryto koniec toru - return cm_Unknown; // to raczej nic się nie da w takiej sytuacji zrobić - else - { // a jeśli są dalej tory + basic_event *e = NULL; // event potencjalnie od semafora + // opcjonalnie może być skanowanie od "wskaźnika" z przodu, np. W5, Tm=Ms1, koniec toru wg drugiej osi w kierunku ruchu + TTrack *scantrack = BackwardTraceRoute(scandist, scandir, pVehicles[0]->RaTrackGet(), e); + auto const dir = startdir * pVehicles[0]->VectorFront(); // wektor w kierunku jazdy/szukania + if( !scantrack ) { + // jeśli wstecz wykryto koniec toru to raczej nic się nie da w takiej sytuacji zrobić + return TCommandType::cm_Unknown; + } + else { + // a jeśli są dalej tory double vmechmax; // prędkość ustawiona semaforem - if (e) - { // jeśli jest jakiś sygnał na widoku + if( e != nullptr ) { + // jeśli jest jakiś sygnał na widoku #if LOGBACKSCAN - AnsiString edir = - pVehicle->asName + " - " + AnsiString((scandir > 0) ? "Event2 " : "Event1 "); + std::string edir { + "Backward scan by " + + pVehicle->asName + " - " + + ( ( scandir > 0 ) ? + "Event2 " : + "Event1 " ) }; #endif // najpierw sprawdzamy, czy semafor czy inny znak został przejechany - vector3 pos = pVehicles[1]->RearPosition(); // pozycja tyłu - vector3 sem; // wektor do sygnału - if (e->Type == tp_GetValues) + auto pos = pVehicles[1]->RearPosition(); // pozycja tyłu + if( typeid( *e ) == typeid( getvalues_event ) ) { // przesłać info o zbliżającym się semaforze #if LOGBACKSCAN - edir += "(" + (e->Params[8].asGroundNode->asName) + "): "; + edir += "(" + ( e->asNodeName ) + ")"; #endif - sl = e->PositionGet(); // położenie komórki pamięci - sem = sl - pos; // wektor do komórki pamięci od końca składu - // sem=e->Params[8].asGroundNode->pCenter-pos; //wektor do komórki pamięci - if (dir.x * sem.x + dir.z * sem.z < 0) // jeśli został minięty - // if ((mvOccupied->CategoryFlag&1)?(VelNext!=0.0):true) //dla pociągu wymagany - // sygnał zezwalający - { // iloczyn skalarny jest ujemny, gdy sygnał stoi z tyłu + auto sl = e->input_location(); // położenie komórki pamięci + auto sem = sl - pos; // wektor do komórki pamięci od końca składu + if (dir.x * sem.x + dir.z * sem.z < 0) { + // jeśli został minięty + // iloczyn skalarny jest ujemny, gdy sygnał stoi z tyłu #if LOGBACKSCAN - WriteLog(edir + "- ignored as not passed yet"); + WriteLog(edir + " - ignored as not passed yet"); #endif - return cm_Unknown; // nic + return TCommandType::cm_Unknown; // nic } - vmechmax = e->ValueGet(1); // prędkość przy tym semaforze - // przeliczamy odległość od semafora - potrzebne by były współrzędne początku - // składu - // scandist=(pos-e->Params[8].asGroundNode->pCenter).Length()-0.5*mvOccupied->Dim.L-10; - // //10m luzu + vmechmax = e->input_value(1); // prędkość przy tym semaforze + // przeliczamy odległość od semafora - potrzebne by były współrzędne początku składu scandist = sem.Length() - 2; // 2m luzu przy manewrach wystarczy - if (scandist < 0) - scandist = 0; // ujemnych nie ma po co wysyłać + if( scandist < 0 ) { + // ujemnych nie ma po co wysyłać + scandist = 0; + } bool move = false; // czy AI w trybie manewerowym ma dociągnąć pod S1 - if (e->Command() == cm_SetVelocity) - if ((vmechmax == 0.0) ? (OrderCurrentGet() & (Shunt | Connect)) : - (OrderCurrentGet() & - Connect)) // przy podczepianiu ignorować wyjazd? + if( e->input_command() == TCommandType::cm_SetVelocity ) { + if( ( vmechmax == 0.0 ) ? + ( OrderCurrentGet() & ( Shunt | Connect ) ) : + ( OrderCurrentGet() & Connect ) ) { // przy podczepianiu ignorować wyjazd? move = true; // AI w trybie manewerowym ma dociągnąć pod S1 - else - { // - if ((scandist > fMinProximityDist) ? - (mvOccupied->Vel > 0.0) && (OrderCurrentGet() != Shunt) : - false) - { // jeśli semafor jest daleko, a pojazd jedzie, to informujemy o -// zmianie prędkości -// jeśli jedzie manewrowo, musi dostać SetVelocity, żeby sie na pociągowy przełączył -// Mechanik->PutCommand("SetProximityVelocity",scandist,vmechmax,sl); + } + else { + if( ( scandist > fMinProximityDist ) + && ( ( mvOccupied->Vel > 0.0 ) + && ( OrderCurrentGet() != Shunt ) ) ) { + // jeśli semafor jest daleko, a pojazd jedzie, to informujemy o zmianie prędkości + // jeśli jedzie manewrowo, musi dostać SetVelocity, żeby sie na pociągowy przełączył #if LOGBACKSCAN - // WriteLog(edir+"SetProximityVelocity "+AnsiString(scandist)+" - // "+AnsiString(vmechmax)); + // WriteLog(edir+"SetProximityVelocity "+AnsiString(scandist) + AnsiString(vmechmax)); WriteLog(edir); #endif // SetProximityVelocity(scandist,vmechmax,&sl); - return (vmechmax > 0) ? cm_SetVelocity : cm_Unknown; + return ( + vmechmax > 0 ? + TCommandType::cm_SetVelocity : + TCommandType::cm_Unknown ); } - else // ustawiamy prędkość tylko wtedy, gdy ma ruszyć, stanąć albo ma - // stać - // if ((MoverParameters->Vel==0.0)||(vmechmax==0.0)) //jeśli stoi lub ma - // stanąć/stać - { // semafor na tym torze albo lokomtywa stoi, a ma ruszyć, albo ma -// stanąć, albo nie ruszać -// stop trzeba powtarzać, bo inaczej zatrąbi i pojedzie sam -// PutCommand("SetVelocity",vmechmax,e->Params[9].asMemCell->Value2(),&sl,stopSem); + else { + // ustawiamy prędkość tylko wtedy, gdy ma ruszyć, stanąć albo ma stać + // if ((MoverParameters->Vel==0.0)||(vmechmax==0.0)) //jeśli stoi lub ma stanąć/stać + // semafor na tym torze albo lokomtywa stoi, a ma ruszyć, albo ma stanąć, albo nie ruszać + // stop trzeba powtarzać, bo inaczej zatrąbi i pojedzie sam + // PutCommand("SetVelocity",vmechmax,e->Params[9].asMemCell->Value2(),&sl,stopSem); #if LOGBACKSCAN - WriteLog(edir + "SetVelocity " + AnsiString(vmechmax) + " " + - AnsiString(e->Params[9].asMemCell->Value2())); + WriteLog( + edir + " - [SetVelocity] [" + + to_string( vmechmax, 2 ) + "] [" + + to_string( e->Params[ 9 ].asMemCell->Value2(), 2 ) + "]" ); #endif - return (vmechmax > 0) ? cm_SetVelocity : cm_Unknown; + return ( + vmechmax > 0 ? + TCommandType::cm_SetVelocity : + TCommandType::cm_Unknown ); } } + } if (OrderCurrentGet() ? OrderCurrentGet() & (Shunt | Connect) : true) // w Wait_for_orders też widzi tarcze { // reakcja AI w trybie manewrowym dodatkowo na sygnały manewrowe - if (move ? true : e->Command() == cm_ShuntVelocity) + if (move ? true : e->input_command() == TCommandType::cm_ShuntVelocity) { // jeśli powyżej było SetVelocity 0 0, to dociągamy pod S1 if ((scandist > fMinProximityDist) ? (mvOccupied->Vel > 0.0) || (vmechmax == 0.0) : @@ -5198,47 +6012,53 @@ TCommandType TController::BackwardScan() #endif // SetProximityVelocity(scandist,vmechmax,&sl); return (iDrivigFlags & moveTrackEnd) ? - cm_ChangeDirection : - cm_Unknown; // jeśli jedzie na W5 albo koniec toru, + TCommandType::cm_ChangeDirection : + TCommandType::cm_Unknown; // jeśli jedzie na W5 albo koniec toru, // to można zmienić kierunek } } - else // ustawiamy prędkość tylko wtedy, gdy ma ruszyć, albo stanąć albo - // ma stać pod tarczą - { // stop trzeba powtarzać, bo inaczej zatrąbi i pojedzie sam - // if ((MoverParameters->Vel==0.0)||(vmechmax==0.0)) //jeśli jedzie - // lub ma stanąć/stać + else { + // ustawiamy prędkość tylko wtedy, gdy ma ruszyć, albo stanąć albo ma stać pod tarczą + // stop trzeba powtarzać, bo inaczej zatrąbi i pojedzie sam + // if ((MoverParameters->Vel==0.0)||(vmechmax==0.0)) //jeśli jedzie lub ma stanąć/stać { // nie dostanie komendy jeśli jedzie i ma jechać -// PutCommand("ShuntVelocity",vmechmax,e->Params[9].asMemCell->Value2(),&sl,stopSem); + // PutCommand("ShuntVelocity",vmechmax,e->Params[9].asMemCell->Value2(),&sl,stopSem); #if LOGBACKSCAN - WriteLog(edir + "ShuntVelocity " + AnsiString(vmechmax) + " " + - AnsiString(e->ValueGet(2))); + WriteLog( + edir + " - [ShuntVelocity] [" + + to_string( vmechmax, 2 ) + "] [" + + to_string( e->value( 2 ), 2 ) + "]" ); #endif - return (vmechmax > 0) ? cm_ShuntVelocity : cm_Unknown; + return ( + vmechmax > 0 ? + TCommandType::cm_ShuntVelocity : + TCommandType::cm_Unknown ); } } - if ((vmechmax != 0.0) && (scandist < 100.0)) - { // jeśli Tm w odległości do 100m podaje zezwolenie na jazdę, to od -// razu ją ignorujemy, aby móc szukać kolejnej -// eSignSkip=e; //wtedy uznajemy ignorowaną przy poszukiwaniu nowej + if ((vmechmax != 0.0) && (scandist < 100.0)) { + // jeśli Tm w odległości do 100m podaje zezwolenie na jazdę, to od razu ją ignorujemy, aby móc szukać kolejnej + // eSignSkip=e; //wtedy uznajemy ignorowaną przy poszukiwaniu nowej #if LOGBACKSCAN - WriteLog(edir + "- will be ignored due to Ms2"); + WriteLog(edir + " - will be ignored due to Ms2"); #endif - return (vmechmax > 0) ? cm_ShuntVelocity : cm_Unknown; + return ( + vmechmax > 0 ? + TCommandType::cm_ShuntVelocity : + TCommandType::cm_Unknown ); } } // if (move?... } // if (OrderCurrentGet()==Shunt) - if (!e->bEnabled) // jeśli skanowany - if (e->StopCommand()) // a podłączona komórka ma komendę - return cm_Command; // to też się obrócić + if (e->m_passive) // jeśli skanowany + if (e->is_command()) // a podłączona komórka ma komendę + return TCommandType::cm_Command; // to też się obrócić } // if (e->Type==tp_GetValues) } // if (e) } // if (scantrack) } // if (scandir!=0.0) - return cm_Unknown; // nic + return TCommandType::cm_Unknown; // nic }; -std::string TController::NextStop() +std::string TController::NextStop() const { // informacja o następnym zatrzymaniu, wyświetlane pod [F1] if (asNextStop == "[End of route]") return ""; // nie zawiera nazwy stacji, gdy dojechał do końca @@ -5329,37 +6149,51 @@ void TController::DirectionForward(bool forward) else while (mvOccupied->ActiveDir >= 0) mvOccupied->DirectionBackward(); // do tyłu w obecnej kabinie - if (mvOccupied->EngineType == DieselEngine) // specjalnie dla SN61 - if (iDrivigFlags & moveActive) // jeśli był już odpalony - if (mvControlling->RList[mvControlling->MainCtrlPos].Mn == 0) - mvControlling->IncMainCtrl(1); //żeby nie zgasł + if( mvOccupied->TrainType == dt_SN61 ) { + // specjalnie dla SN61 żeby nie zgasł + if( mvControlling->RList[ mvControlling->MainCtrlPos ].Mn == 0 ) { + mvControlling->IncMainCtrl( 1 ); + } + } }; -std::string TController::Relation() +Mtable::TTrainParameters const * +TController::TrainTimetable() const { + return TrainParams; +} + +std::string TController::Relation() const { // zwraca relację pociągu return TrainParams->ShowRelation(); }; -std::string TController::TrainName() +std::string TController::TrainName() const { // zwraca numer pociągu return TrainParams->TrainName; }; -int TController::StationCount() +int TController::StationCount() const { // zwraca ilość stacji (miejsc zatrzymania) return TrainParams->StationCount; }; -int TController::StationIndex() +int TController::StationIndex() const { // zwraca indeks aktualnej stacji (miejsca zatrzymania) return TrainParams->StationIndex; }; -bool TController::IsStop() +bool TController::IsStop() const { // informuje, czy jest zatrzymanie na najbliższej stacji return TrainParams->IsStop(); }; +// returns most recently calculated distance to potential obstacle ahead +double +TController::TrackBlock() const { + + return pVehicles[ side::front ]->fTrackBlock; +} + void TController::MoveTo(TDynamicObject *to) { // przesunięcie AI do innego pojazdu (przy zmianie kabiny) // mvOccupied->CabDeactivisation(); //wyłączenie kabiny w opuszczanym @@ -5379,13 +6213,14 @@ void TController::ControllingSet() mvControlling = pVehicle->ControlledFind()->MoverParameters; // poszukiwanie członu sterowanego }; -std::string TController::TableText(int i) +std::string TController::TableText( std::size_t const Index ) const { // pozycja tabelki prędkości - i = (iFirst + i) % iSpeedTableSize; // numer pozycji - if (i != iLast) // w (iLast) znajduje się kolejny tor do przeskanowania, ale nie jest ona - // aktywną - return sSpeedTable[i].TableText(); - return ""; // wskaźnik końca + if( Index < sSpeedTable.size() ) { + return sSpeedTable[ Index ].TableText(); + } + else { + return ""; + } }; int TController::CrossRoute(TTrack *tr) @@ -5393,43 +6228,51 @@ int TController::CrossRoute(TTrack *tr) // pożądany numer segmentu jest określany podczas skanowania drogi // droga powinna być określona sposobem przejazdu przez skrzyżowania albo współrzędnymi miejsca // docelowego - for (int i = iFirst; i != iLast; i = (i + 1) % iSpeedTableSize) + for( std::size_t i = 0; i < sSpeedTable.size(); ++i ) { // trzeba przejrzeć tabelę skanowania w poszukiwaniu (tr) // i jak się znajdzie, to zwrócić zapamiętany numer segmentu i kierunek przejazdu // (-6..-1,1..6) - if ((sSpeedTable[i].iFlags & 3) == 3) // jeśli pozycja istotna (1) oraz odcinek (2) - if (sSpeedTable[i].trTrack == tr) // jeśli pozycja odpowiadająca skrzyżowaniu (tr) - return (sSpeedTable[i].iFlags >> 28); // najstarsze 4 bity jako liczba -8..7 + if( ( true == TestFlag( sSpeedTable[ i ].iFlags, spEnabled | spTrack ) ) + && ( sSpeedTable[ i ].trTrack == tr ) ) { + // jeśli pozycja odpowiadająca skrzyżowaniu (tr) + return ( sSpeedTable[ i ].iFlags >> 28 ); // najstarsze 4 bity jako liczba -8..7 + } } return 0; // nic nie znaleziono? }; - +/* void TController::RouteSwitch(int d) { // ustawienie kierunku jazdy z kabiny d &= 3; - if (d) - if (iRouteWanted != d) - { // nowy kierunek - iRouteWanted = d; // zapamiętanie - if (mvOccupied->CategoryFlag & 2) // jeśli samochód - for (int i = iFirst; i != iLast; i = (i + 1) % iSpeedTableSize) - { // szukanie pierwszego skrzyżowania i resetowanie kierunku na nim - if ((sSpeedTable[i].iFlags & 3) == - 3) // jeśli pozycja istotna (1) oraz odcinek (2) - if ((sSpeedTable[i].iFlags & 32) == 0) // odcinek nie może być miniętym - if (sSpeedTable[i].trTrack->eType == tt_Cross) // jeśli skrzyżowanie - { // obcięcie tabelki skanowania przed skrzyżowaniem, aby ponownie - // wybrać drogę - iLast = i - 1; // ponowne skanowanie skrzyżowania (w zwrotnicach - // jest iLast=i, ale tam jest prościej) - if (iLast < 0) - iLast += iSpeedTableSize; // bo tabelka jest zapętlona - return; + if( ( d != 0 ) + && ( iRouteWanted != d ) ) { // nowy kierunek + iRouteWanted = d; // zapamiętanie + if( mvOccupied->CategoryFlag & 2 ) { + // jeśli samochód + for( std::size_t i = 0; i < sSpeedTable.size(); ++i ) { + // szukanie pierwszego skrzyżowania i resetowanie kierunku na nim + if( true == TestFlag( sSpeedTable[ i ].iFlags, spEnabled | spTrack ) ) { + // jeśli pozycja istotna (1) oraz odcinek (2) + if( false == TestFlag( sSpeedTable[ i ].iFlags, spElapsed ) ) { + // odcinek nie może być miniętym + if( sSpeedTable[ i ].trTrack->eType == tt_Cross ) // jeśli skrzyżowanie + { + while( sSpeedTable.size() >= i ) { + // NOTE: we're ignoring semaphor flags and not resetting them like we do for train route trimming + // but what if there's street lights? + // TODO: investigate + sSpeedTable.pop_back(); } + iLast = sSpeedTable.size(); + } + } } + } } + } }; -std::string TController::OwnerName() +*/ +std::string TController::OwnerName() const { - return pVehicle ? pVehicle->MoverParameters->Name : string("none"); + return ( pVehicle ? pVehicle->MoverParameters->Name : "none" ); }; diff --git a/Driver.h b/Driver.h index 4f27d920..dce4b815 100644 --- a/Driver.h +++ b/Driver.h @@ -9,13 +9,11 @@ http://mozilla.org/MPL/2.0/. #pragma once -//#include -#include "Classes.h" -#include "dumb3d.h" -#include "mczapkie/mover.h" #include -using namespace Math3D; -using namespace Mtable; +#include "Classes.h" +#include "mczapkie/mover.h" +#include "sound.h" +#include "dynobj.h" enum TOrders { // rozkazy dla AI @@ -52,13 +50,14 @@ enum TMovementStatus moveGuardSignal = 0x8000, // sygnał od kierownika (minął czas postoju) moveVisibility = 0x10000, // jazda na widoczność po przejechaniu S1 na SBL moveDoorOpened = 0x20000, // drzwi zostały otwarte - doliczyć czas na zamknięcie - movePushPull = - 0x40000, // zmiana czoła przez zmianę kabiny - nie odczepiać przy zmianie kierunku + movePushPull = 0x40000, // zmiana czoła przez zmianę kabiny - nie odczepiać przy zmianie kierunku moveSemaphorFound = 0x80000, // na drodze skanowania został znaleziony semafor + moveStopPointFound = 0x100000 // stop point detected ahead +/* moveSemaphorWasElapsed = 0x100000, // minięty został semafor - moveTrainInsideStation = - 0x200000, // pociąg między semaforem a rozjazdami lub następnym semaforem + moveTrainInsideStation = 0x200000, // pociąg między semaforem a rozjazdami lub następnym semaforem moveSpeedLimitFound = 0x400000 // pociąg w ograniczeniu z podaną jego długością +*/ }; enum TStopReason @@ -78,7 +77,7 @@ enum TStopReason stopError // z powodu błędu w obliczeniu drogi hamowania }; -enum TAction +enum class TAction : int { // przechowanie aktualnego stanu AI od poprzedniego przebłysku świadomości actUnknown, // stan nieznany (domyślny na początku) actPantUp, // podnieś pantograf (info dla użytkownika) @@ -102,6 +101,7 @@ enum TAction enum TSpeedPosFlag { // wartości dla iFlag w TSpeedPos + spNone = 0x0, spEnabled = 0x1, // pozycja brana pod uwagę spTrack = 0x2, // to jest tor spReverse = 0x4, // odwrotnie @@ -119,37 +119,46 @@ enum TSpeedPosFlag spSemaphor = 0x4000, // semafor pociągowy spRoadVel = 0x8000, // zadanie prędkości drogowej spSectionVel = 0x20000, // odcinek z ograniczeniem - spProximityVelocity = 0x40000, // odcinek z ograniczeniem i podaną jego długościa - spEndOfTable = 0x10000 // zatkanie tabelki + spProximityVelocity = 0x40000 // odcinek z ograniczeniem i podaną jego długościa +// spDontApplySpeedLimit = 0x10000 // this point won't apply its speed limit. potentially set by the scanning vehicle }; class TSpeedPos { // pozycja tabeli prędkości dla AI public: - double fDist; // aktualna odległość (ujemna gdy minięte) - double fVelNext; // prędkość obowiązująca od tego miejsca - double fSectionVelocityDist; // długość ograniczenia prędkości + double fDist{ 0.0 }; // aktualna odległość (ujemna gdy minięte) + double fVelNext{ -1.0 }; // prędkość obowiązująca od tego miejsca + double fSectionVelocityDist{ 0.0 }; // długość ograniczenia prędkości // double fAcc; - int iFlags; // flagi typu wpisu do tabelki + int iFlags{ spNone }; // flagi typu wpisu do tabelki // 1=istotny,2=tor,4=odwrotnie,8-zwrotnica (może się zmienić),16-stan // zwrotnicy,32-minięty,64=koniec,128=łuk // 0x100=event,0x200=manewrowa,0x400=przystanek,0x800=SBL,0x1000=wysłana komenda,0x2000=W5 // 0x4000=semafor,0x10000=zatkanie - vector3 vPos; // współrzędne XYZ do liczenia odległości + bool bMoved{ false }; // czy przesunięty (dotyczy punktu zatrzymania w peronie) + Math3D::vector3 vPos; // współrzędne XYZ do liczenia odległości struct { - TTrack *trTrack; // wskaźnik na tor o zmiennej prędkości (zwrotnica, obrotnica) - TEvent *evEvent; // połączenie z eventem albo komórką pamięci + TTrack *trTrack{ nullptr }; // wskaźnik na tor o zmiennej prędkości (zwrotnica, obrotnica) + basic_event *evEvent{ nullptr }; // połączenie z eventem albo komórką pamięci }; void CommandCheck(); public: + TSpeedPos(TTrack *track, double dist, int flag); + TSpeedPos(basic_event *event, double dist, TOrders order); + TSpeedPos() = default; void Clear(); - bool Update(vector3 *p, vector3 *dir, double &len); - bool Set(TEvent *e, double d, TOrders order = Wait_for_orders); + bool Update(); + // aktualizuje odległość we wpisie + inline + void + UpdateDistance( double dist ) { + fDist -= dist; } + bool Set(basic_event *e, double d, TOrders order = Wait_for_orders); void Set(TTrack *t, double d, int f); - std::string TableText(); - std::string GetName(); + std::string TableText() const; + std::string GetName() const; bool IsProperSemaphor(TOrders order = Wait_for_orders); }; @@ -158,37 +167,37 @@ static const bool Aggressive = true; static const bool Easyman = false; static const bool AIdriver = true; static const bool Humandriver = false; -static const int maxorders = 32; // ilość rozkazów w tabelce +static const int maxorders = 64; // ilość rozkazów w tabelce static const int maxdriverfails = 4; // ile błędów może zrobić AI zanim zmieni nastawienie extern bool WriteLogFlag; // logowanie parametrów fizycznych +static const int BrakeAccTableSize = 20; //---------------------------------------------------------------------------- -class TController -{ +class TController { + private: // obsługa tabelki prędkości (musi mieć możliwość odhaczania stacji w rozkładzie) - TSpeedPos *sSpeedTable = nullptr; // najbliższe zmiany prędkości - int iSpeedTableSize = 16; // wielkość tabelki - int iFirst = 0; // aktualna pozycja w tabeli (modulo iSpeedTableSize) - int iLast = 0; // ostatnia wypełniona pozycja w tabeli sSpeedTable; double fLastVel = 0.0; // prędkość na poprzednio sprawdzonym torze TTrack *tLast = nullptr; // ostatni analizowany tor - TEvent *eSignSkip = nullptr; // można pominąć ten SBL po zatrzymaniu - TSpeedPos *sSemNext = nullptr; // następny semafor na drodze zależny od trybu jazdy - TSpeedPos *sSemNextStop = nullptr; // następny semafor na drodze zależny od trybu jazdy i na stój - private: // parametry aktualnego składu + basic_event *eSignSkip = nullptr; // można pominąć ten SBL po zatrzymaniu + std::size_t SemNextIndex{ std::size_t(-1) }; + std::size_t SemNextStopIndex{ std::size_t( -1 ) }; + double dMoveLen = 0.0; // odległość przejechana od ostatniego sprawdzenia tabelki + // parametry aktualnego składu double fLength = 0.0; // długość składu (do wyciągania z ograniczeń) double fMass = 0.0; // całkowita masa do liczenia stycznej składowej grawitacji +public: double fAccGravity = 0.0; // przyspieszenie składowej stycznej grawitacji - public: - TEvent *eSignNext = nullptr; // sygnał zmieniający prędkość, do pokazania na [F2] + basic_event *eSignNext = nullptr; // sygnał zmieniający prędkość, do pokazania na [F2] std::string asNextStop; // nazwa następnego punktu zatrzymania wg rozkładu int iStationStart = 0; // numer pierwszej stacji pokazywanej na podglądzie rozkładu - private: // parametry sterowania pojazdem (stan, hamowanie) + // parametry sterowania pojazdem (stan, hamowanie) + private: double fShuntVelocity = 40.0; // maksymalna prędkość manewrowania, zależy m.in. od składu // domyślna prędkość manewrowa int iVehicles = 0; // ilość pojazdów w składzie int iEngineActive = 0; // ABu: Czy silnik byl juz zalaczony; Ra: postęp w załączaniu - // vector3 vMechLoc; //pozycja pojazdu do liczenia odległości od semafora (?) bool Psyche = false; int iDrivigFlags = // flagi bitowe ruchu moveStopPoint | // podjedź do W4 możliwie blisko @@ -197,77 +206,80 @@ class TController double fDriverBraking = 0.0; // po pomnożeniu przez v^2 [km/h] daje ~drogę hamowania [m] double fDriverDist = 0.0; // dopuszczalna odległość podjechania do przeszkody double fVelMax = -1.0; // maksymalna prędkość składu (sprawdzany każdy pojazd) - double fBrakeDist = 0.0; // przybliżona droga hamowania - double fAccThreshold = 0.0; // próg opóźnienia dla zadziałania hamulca public: + double fBrakeDist = 0.0; // przybliżona droga hamowania + double BrakeAccFactor() const; + double fBrakeReaction = 1.0; //opóźnienie zadziałania hamulca - czas w s / (km/h) + double fNominalAccThreshold = 0.0; // nominalny próg opóźnienia dla zadziałania hamulca + double fAccThreshold = 0.0; // aktualny próg opóźnienia dla zadziałania hamulca + double AbsAccS_pub = 0.0; // próg opóźnienia dla zadziałania hamulca + // dla fBrake_aX: + // indeks [0] - wartości odpowiednie dla aktualnej prędkości + // a potem jest 20 wartości dla różnych prędkości zmieniających się co 5 % Vmax pojazdu obsadzonego + double fBrake_a0[BrakeAccTableSize+1] = { 0.0 }; // opóźnienia hamowania przy ustawieniu zaworu maszynisty w pozycji 1.0 + double fBrake_a1[BrakeAccTableSize+1] = { 0.0 }; // przyrost opóźnienia hamowania po przestawieniu zaworu maszynisty o 0,25 pozycji + double BrakingInitialLevel{ 1.0 }; + double BrakingLevelIncrease{ 0.25 }; + bool IsCargoTrain{ false }; + bool IsHeavyCargoTrain{ false }; double fLastStopExpDist = -1.0; // odległość wygasania ostateniego przystanku double ReactionTime = 0.0; // czas reakcji Ra: czego i na co? świadomości AI - double fBrakeTime = 0.0; // wpisana wartość jest zmniejszana do 0, gdy ujemna należy zmienić nastawę - // hamulca - private: + double fBrakeTime = 0.0; // wpisana wartość jest zmniejszana do 0, gdy ujemna należy zmienić nastawę hamulca + double BrakeChargingCooldown {}; // prevents the ai from trying to charge the train brake too frequently double fReady = 0.0; // poziom odhamowania wagonów bool Ready = false; // ABu: stan gotowosci do odjazdu - sprawdzenie odhamowania wagonow +private: double LastUpdatedTime = 0.0; // czas od ostatniego logu double ElapsedTime = 0.0; // czas od poczatku logu double deltalog = 0.05; // przyrost czasu double LastReactionTime = 0.0; double fActionTime = 0.0; // czas używany przy regulacji prędkości i zamykaniu drzwi - TAction eAction = actSleep; // aktualny stan - bool HelpMeFlag = false; // wystawiane True jesli cos niedobrego sie dzieje + double m_radiocontroltime{ 0.0 }; // timer used to control speed of radio operations + TAction eAction { TAction::actUnknown }; // aktualny stan public: - inline TAction GetAction() - { - return eAction; - } + inline + TAction GetAction() { + return eAction; } bool AIControllFlag = false; // rzeczywisty/wirtualny maszynista - int iRouteWanted = 3; // oczekiwany kierunek jazdy (0-stop,1-lewo,2-prawo,3-prosto) np. odpala - // migacz lub czeka na stan zwrotnicy +/* + int iRouteWanted = 3; // oczekiwany kierunek jazdy (0-stop,1-lewo,2-prawo,3-prosto) np. odpala migacz lub czeka na stan zwrotnicy +*/ private: TDynamicObject *pVehicle = nullptr; // pojazd w którym siedzi sterujący - TDynamicObject - *pVehicles[2]; // skrajne pojazdy w składzie (niekoniecznie bezpośrednio sterowane) + TDynamicObject *pVehicles[2]; // skrajne pojazdy w składzie (niekoniecznie bezpośrednio sterowane) TMoverParameters *mvControlling = nullptr; // jakim pojazdem steruje (może silnikowym w EZT) TMoverParameters *mvOccupied = nullptr; // jakim pojazdem hamuje - TTrainParameters *TrainParams = nullptr; // rozkład jazdy zawsze jest, nawet jeśli pusty - // int TrainNumber; //numer rozkladowy tego pociagu - // AnsiString OrderCommand; //komenda pobierana z pojazdu - // double OrderValue; //argument komendy + Mtable::TTrainParameters *TrainParams = nullptr; // rozkład jazdy zawsze jest, nawet jeśli pusty int iRadioChannel = 1; // numer aktualnego kanału radiowego - TTextSound *tsGuardSignal = nullptr; // komunikat od kierownika int iGuardRadio = 0; // numer kanału radiowego kierownika (0, gdy nie używa radia) + sound_source tsGuardSignal { sound_placement::internal }; + std::array m_lighthints { -1 }; // suggested light patterns public: double AccPreferred = 0.0; // preferowane przyspieszenie (wg psychiki kierującego, zmniejszana przy wykryciu kolizji) double AccDesired = AccPreferred; // przyspieszenie, jakie ma utrzymywać (<0:nie przyspieszaj,<-0.1:hamuj) double VelDesired = 0.0; // predkość, z jaką ma jechać, wynikająca z analizy tableki; <=VelSignal - double fAccDesiredAv = 0.0; // uśrednione przyspieszenie z kolejnych przebłysków świadomości, żeby - // ograniczyć migotanie - public: + double fAccDesiredAv = 0.0; // uśrednione przyspieszenie z kolejnych przebłysków świadomości, żeby ograniczyć migotanie double VelforDriver = -1.0; // prędkość, używana przy zmianie kierunku (ograniczenie przy nieznajmości szlaku?) double VelSignal = 0.0; // ograniczenie prędkości z kompilacji znaków i sygnałów // normalnie na początku ma stać, no chyba że jedzie double VelLimit = -1.0; // predkość zadawana przez event jednokierunkowego ograniczenia prędkości // -1: brak ograniczenia prędkości - public: double VelSignalLast = -1.0; // prędkość zadana na ostatnim semaforze // ostatni semafor też bez ograniczenia double VelSignalNext = 0.0; // prędkość zadana na następnym semaforze double VelLimitLast = -1.0; // prędkość zadana przez ograniczenie // ostatnie ograniczenie bez ograniczenia double VelRoad = -1.0; // aktualna prędkość drogowa (ze znaku W27) (PutValues albo komendą) // prędkość drogowa bez ograniczenia - public: double VelNext = 120.0; // prędkość, jaka ma być po przejechaniu długości ProximityDist + double VelRestricted = -1.0; // speed of travel after passing a permissive signal at stop private: - double fProximityDist = 0.0; // odleglosc podawana w SetProximityVelocity(); >0:przeliczać do punktu, <0:podana wartość double FirstSemaphorDist = 10000.0; // odległość do pierwszego znalezionego semafora public: - double - ActualProximityDist = 1.0; // odległość brana pod uwagę przy wyliczaniu prędkości i przyspieszenia + double ActualProximityDist = 1.0; // odległość brana pod uwagę przy wyliczaniu prędkości i przyspieszenia private: - vector3 vCommandLocation; // polozenie wskaznika, sygnalizatora lub innego obiektu do ktorego + Math3D::vector3 vCommandLocation; // polozenie wskaznika, sygnalizatora lub innego obiektu do ktorego // odnosi sie komenda TOrders OrderList[maxorders]; // lista rozkazów int OrderPos = 0, OrderTop = 0; // rozkaz aktualny oraz wolne miejsce do wstawiania nowych std::ofstream LogFile; // zapis parametrow fizycznych std::ofstream AILogFile; // log AI - bool MaxVelFlag = false; - bool MinVelFlag = false; // Ra: to nie jest używane int iDirection = 0; // kierunek jazdy względem sprzęgów pojazdu, w którym siedzi AI (1=przód,-1=tył) int iDirectionOrder = 0; //żadany kierunek jazdy (służy do zmiany kierunku) int iVehicleCount = -2; // wartość neutralna // ilość pojazdów do odłączenia albo zabrania ze składu (-1=wszystkie) @@ -283,17 +295,19 @@ class TController int iOverheadZero = 0; // suma bitowa jezdy bezprądowej, bity ustawiane przez pojazdy z podniesionymi pantografami int iOverheadDown = 0; // suma bitowa opuszczenia pantografów, bity ustawiane przez pojazdy z podniesionymi pantografami double fVoltage = 0.0; // uśrednione napięcie sieci: przy spadku poniżej wartości minimalnej opóźnić rozruch o losowy czas - private: + private: double fMaxProximityDist = 50.0; // stawanie między 30 a 60 m przed przeszkodą // akceptowalna odległość stanięcia przed przeszkodą TStopReason eStopReason = stopSleep; // powód zatrzymania przy ustawieniu zerowej prędkości // na początku śpi std::string VehicleName; double fVelPlus = 0.0; // dopuszczalne przekroczenie prędkości na ograniczeniu bez hamowania double fVelMinus = 0.0; // margines obniżenia prędkości, powodujący załączenie napędu double fWarningDuration = 0.0; // ile czasu jeszcze trąbić - double fStopTime = 0.0; // czas postoju przed dalszą jazdą (np. na przystanku) double WaitingTime = 0.0; // zliczany czas oczekiwania do samoistnego ruszenia double WaitingExpireTime = 31.0; // tyle ma czekać, zanim się ruszy // maksymlany czas oczekiwania do samoistnego ruszenia - // TEvent* eSignLast; //ostatnio znaleziony sygnał, o ile nie minięty + double IdleTime {}; // keeps track of time spent at a stop + public: + double fStopTime = 0.0; // czas postoju przed dalszą jazdą (np. na przystanku) + private: //---//---//---//---// koniec zmiennych, poniżej metody //---//---//---//---// void SetDriverPsyche(); bool PrepareEngine(); @@ -303,27 +317,23 @@ class TController bool IncSpeed(); bool DecSpeed(bool force = false); void SpeedSet(); - void Doors(bool what); + void SpeedCntrl(double DesiredSpeed); + void Doors(bool const Open, int const Side = 0); + // returns true if any vehicle in the consist has an open door + bool doors_open() const; void RecognizeCommand(); // odczytuje komende przekazana lokomotywie void Activation(); // umieszczenie obsady w odpowiednim członie void ControllingSet(); // znajduje człon do sterowania void AutoRewident(); // ustawia hamulce w składzie + double ESMVelocity(bool Main); public: - Mtable::TTrainParameters *Timetable() - { - return TrainParams; - }; - void PutCommand(std::string NewCommand, double NewValue1, double NewValue2, - const TLocation &NewLocation, TStopReason reason = stopComm); - bool PutCommand(std::string NewCommand, double NewValue1, double NewValue2, - const vector3 *NewLocation, TStopReason reason = stopComm); - bool UpdateSituation(double dt); // uruchamiac przynajmniej raz na sekundę + void PutCommand(std::string NewCommand, double NewValue1, double NewValue2, const TLocation &NewLocation, TStopReason reason = stopComm); + bool PutCommand( std::string NewCommand, double NewValue1, double NewValue2, glm::dvec3 const *NewLocation, TStopReason reason = stopComm ); + void UpdateSituation(double dt); // uruchamiac przynajmniej raz na sekundę + bool UpdateHeating(); // procedury dotyczace rozkazow dla maszynisty - void SetVelocity(double NewVel, double NewVelNext, - TStopReason r = stopNone); // uaktualnia informacje o prędkości - bool SetProximityVelocity( - double NewDist, - double NewVelNext); // uaktualnia informacje o prędkości przy nastepnym semaforze + // uaktualnia informacje o prędkości + void SetVelocity(double NewVel, double NewVelNext, TStopReason r = stopNone); public: void JumpToNextOrder(); void JumpToFirstOrder(); @@ -332,6 +342,7 @@ class TController inline TOrders OrderCurrentGet(); inline TOrders OrderNextGet(); bool CheckVehicles(TOrders user = Wait_for_orders); + int CheckDirection(); private: void CloseLog(); @@ -341,62 +352,79 @@ class TController void OrdersInit(double fVel); void OrdersClear(); void OrdersDump(); - TController(bool AI, TDynamicObject *NewControll, bool InitPsyche, - bool primary = true // czy ma aktywnie prowadzić? - ); - std::string OrderCurrent(); + TController( bool AI, TDynamicObject *NewControll, bool InitPsyche, bool primary = true ); + std::string OrderCurrent() const; void WaitingSet(double Seconds); private: - std::string Order2Str(TOrders Order); + std::string Order2Str(TOrders Order) const; void DirectionForward(bool forward); int OrderDirectionChange(int newdir, TMoverParameters *Vehicle); void Lights(int head, int rear); - double Distance(vector3 &p1, vector3 &n, vector3 &p2); - - private: // Ra: metody obsługujące skanowanie toru - TEvent *CheckTrackEvent(double fDirection, TTrack *Track); - bool TableCheckEvent(TEvent *e); + // Ra: metody obsługujące skanowanie toru + std::vector CheckTrackEvent(TTrack *Track, double const fDirection ) const; bool TableAddNew(); - bool TableNotFound(TEvent *e); - void TableClear(); - TEvent *TableCheckTrackEvent(double fDirection, TTrack *Track); - void TableTraceRoute(double fDistance, TDynamicObject *pVehicle = NULL); + bool TableNotFound(basic_event const *Event) const; + void TableTraceRoute(double fDistance, TDynamicObject *pVehicle); void TableCheck(double fDistance); TCommandType TableUpdate(double &fVelDes, double &fDist, double &fNext, double &fAcc); + // modifies brake distance for low target speeds, to ease braking rate in such situations + float + braking_distance_multiplier( float const Targetvelocity ) const; void TablePurger(); + void TableSort(); + inline double MoveDistanceGet() const { + return dMoveLen; } + inline void MoveDistanceReset() { + dMoveLen = 0.0; } + public: + inline void MoveDistanceAdd(double distance) { + dMoveLen += distance * iDirection; //jak jedzie do tyłu to trzeba uwzględniać, że distance jest ujemna + } + std::size_t TableSize() const { return sSpeedTable.size(); } + void TableClear(); + int TableDirection() { return iTableDirection; } private: // Ra: stare funkcje skanujące, używane do szukania sygnalizatora z tyłu bool BackwardTrackBusy(TTrack *Track); - TEvent *CheckTrackEventBackward(double fDirection, TTrack *Track); - TTrack *BackwardTraceRoute(double &fDistance, double &fDirection, TTrack *Track, - TEvent *&Event); - void SetProximityVelocity(double dist, double vel, const vector3 *pos); + basic_event *CheckTrackEventBackward(double fDirection, TTrack *Track); + TTrack *BackwardTraceRoute(double &fDistance, double &fDirection, TTrack *Track, basic_event *&Event); + void SetProximityVelocity( double dist, double vel, glm::dvec3 const *pos ); TCommandType BackwardScan(); public: void PhysicsLog(); std::string StopReasonText(); ~TController(); - std::string NextStop(); void TakeControl(bool yes); - std::string Relation(); - std::string TrainName(); - int StationCount(); - int StationIndex(); - bool IsStop(); - bool Primary() - { - return this ? ((iDrivigFlags & movePrimary) != 0) : false; - }; - int inline DrivigFlags() - { - return iDrivigFlags; - }; + Mtable::TTrainParameters const * TrainTimetable() const; + std::string TrainName() const; + std::string Relation() const; + int StationCount() const; + int StationIndex() const; + bool IsStop() const; + std::string NextStop() const; + inline + bool Primary() const { + return ( ( iDrivigFlags & movePrimary ) != 0 ); }; + inline + int DrivigFlags() const { + return iDrivigFlags; }; + // returns most recently calculated distance to potential obstacle ahead + double + TrackBlock() const; void MoveTo(TDynamicObject *to); void DirectionInitial(); - std::string TableText(int i); + std::string TableText(std::size_t const Index) const; int CrossRoute(TTrack *tr); +/* void RouteSwitch(int d); - std::string OwnerName(); +*/ + std::string OwnerName() const; + TMoverParameters const *Controlling() const { + return mvControlling; } + int Direction() const { + return iDirection; } + TDynamicObject const *Vehicle() const { + return pVehicle; } }; diff --git a/DynObj.cpp b/DynObj.cpp index 9dba3343..fc522fe6 100644 --- a/DynObj.cpp +++ b/DynObj.cpp @@ -15,40 +15,60 @@ http://mozilla.org/MPL/2.0/. #include "stdafx.h" #include "DynObj.h" -#include "logs.h" -#include "MdlMngr.h" -#include "Timer.h" -#include "Usefull.h" -// McZapkie-260202 +#include "simulation.h" +#include "camera.h" +#include "train.h" +#include "driver.h" #include "Globals.h" -#include "Texture.h" -#include "AirCoupler.h" - -#include "TractionPower.h" -#include "Ground.h" //bo Global::pGround->bDynamicRemove -#include "Event.h" -#include "Driver.h" -#include "Camera.h" //bo likwidujemy trzęsienie +#include "Timer.h" +#include "logs.h" #include "Console.h" -#include "Traction.h" +#include "MdlMngr.h" +#include "model3d.h" +#include "renderer.h" +#include "uitranscripts.h" +#include "messaging.h" // Ra: taki zapis funkcjonuje lepiej, ale może nie jest optymalny #define vWorldFront Math3D::vector3(0, 0, 1) #define vWorldUp Math3D::vector3(0, 1, 0) #define vWorldLeft CrossProduct(vWorldUp, vWorldFront) -// Ra: bo te poniżej to się powielały w każdym module odobno -// vector3 vWorldFront=vector3(0,0,1); -// vector3 vWorldUp=vector3(0,1,0); -// vector3 vWorldLeft=CrossProduct(vWorldUp,vWorldFront); - #define M_2PI 6.283185307179586476925286766559; -const float maxrot = (M_PI / 3.0); // 60° +const float maxrot = (float)(M_PI / 3.0); // 60° + +std::string const TDynamicObject::MED_labels[] = { + "masa: ", "amax: ", "Fzad: ", "FmPN: ", "FmED: ", "FrED: ", "FzPN: ", "nPrF: " +}; + +bool TDynamicObject::bDynamicRemove { false }; + +// helper, locates submodel with specified name in specified 3d model; returns: pointer to the submodel, or null +TSubModel * +GetSubmodelFromName( TModel3d * const Model, std::string const Name ) { + + return ( + Model ? + Model->GetFromName( Name ) : + nullptr ); +} + +// Ra 2015-01: sprawdzenie dostępności tekstury o podanej nazwie +std::string +TextureTest( std::string const &Name ) { + + auto const lookup { + FileExists( + { Global.asCurrentTexturePath + Name, Name, szTexturePath + Name }, + { ".mat", ".dds", ".tga", ".bmp" } ) }; + + return ( lookup.first + lookup.second ); +} //--------------------------------------------------------------------------- void TAnimPant::AKP_4E() { // ustawienie wymiarów dla pantografu AKP-4E - vPos = vector3(0, 0, 0); // przypisanie domyśnych współczynników do pantografów + vPos = Math3D::vector3(0, 0, 0); // przypisanie domyśnych współczynników do pantografów fLenL1 = 1.22; // 1.176289 w modelach fLenU1 = 1.755; // 1.724482197 w modelach fHoriz = 0.535; // 0.54555075 przesunięcie ślizgu w długości pojazdu względem @@ -65,18 +85,17 @@ void TAnimPant::AKP_4E() PantWys = fLenL1 * sin(fAngleL) + fLenU1 * sin(fAngleU) + fHeight; // wysokość początkowa PantTraction = PantWys; hvPowerWire = NULL; - fWidthExtra = 0.381; //(2.032m-1.027)/2 + fWidthExtra = 0.381f; //(2.032m-1.027)/2 // poza obszarem roboczym jest aproksymacja łamaną o 5 odcinkach - fHeightExtra[0] = 0.0; //+0.0762 - fHeightExtra[1] = -0.01; //+0.1524 - fHeightExtra[2] = -0.03; //+0.2286 - fHeightExtra[3] = -0.07; //+0.3048 - fHeightExtra[4] = -0.15; //+0.3810 + fHeightExtra[0] = 0.0f; //+0.0762 + fHeightExtra[1] = -0.01f; //+0.1524 + fHeightExtra[2] = -0.03f; //+0.2286 + fHeightExtra[3] = -0.07f; //+0.3048 + fHeightExtra[4] = -0.15f; //+0.3810 }; //--------------------------------------------------------------------------- int TAnim::TypeSet(int i, int fl) -{ // ustawienie typu animacji i zależnej od - // niego ilości animowanych submodeli +{ // ustawienie typu animacji i zależnej od niego ilości animowanych submodeli fMaxDist = -1.0; // normalnie nie pokazywać switch (i) { // maska 0x000F: ile używa wskaźników na submodele (0 gdy jeden, @@ -109,16 +128,19 @@ int TAnim::TypeSet(int i, int fl) case 6: iFlags = 0x068; break; // 6-tłok i rozrząd - 8 submodeli + case 7: + iFlags = 0x070; + break; // doorstep + case 8: + iFlags = 0x080; + break; // mirror default: iFlags = 0; } yUpdate = nullptr; return iFlags & 15; // ile wskaźników rezerwować dla danego typu animacji }; -TAnim::TAnim() -{ // potrzebne to w ogóle? - iFlags = -1; // nieznany typ - destruktor nic nie usuwa -}; + TAnim::~TAnim() { // usuwanie animacji switch (iFlags & 0xF0) @@ -129,13 +151,15 @@ TAnim::~TAnim() case 0x50: // 5-pantograf delete fParamPants; break; - case 0x60: // 6-tłok i rozrząd + default: break; } }; +/* void TAnim::Parovoz(){ // animowanie tłoka i rozrządu parowozu }; +*/ //--------------------------------------------------------------------------- TDynamicObject * TDynamicObject::FirstFind(int &coupler_nr, int cf) { // szukanie skrajnego połączonego pojazdu w pociagu @@ -180,9 +204,10 @@ float TDynamicObject::GetEPP() // od strony sprzegu (coupler_nr) obiektu (start) TDynamicObject *temp = this; int coupler_nr = 0; - float eq = 0, am = 0; + double eq = 0.0; + double am = 0.0; - for (int i = 0; i < 300; i++) // ograniczenie do 300 na wypadek zapętlenia składu + for (int i = 0; i < 300; ++i) // ograniczenie do 300 na wypadek zapętlenia składu { if (!temp) break; // Ra: zabezpieczenie przed ewentaulnymi błędami sprzęgów @@ -294,7 +319,7 @@ odwrócony }; */ -void TDynamicObject::ABuSetModelShake(vector3 mShake) +void TDynamicObject::ABuSetModelShake( Math3D::vector3 mShake ) { modelShake = mShake; }; @@ -404,28 +429,29 @@ void TDynamicObject::UpdateBoogie(TAnim *pAnim) void TDynamicObject::UpdateDoorTranslate(TAnim *pAnim) { // animacja drzwi - przesuw - // WriteLog("Dla drzwi nr:", i); - // WriteLog("Wspolczynnik", DoorSpeedFactor[i]); - // Ra: te współczynniki są bez sensu, bo modyfikują wektor przesunięcia - // w efekcie drzwi otwierane na zewnątrz będą odlatywac dowolnie daleko :) - // ograniczyłem zakres ruchu funkcją max - if (pAnim->smAnimated) - { - if (pAnim->iNumber & 1) + if (pAnim->smAnimated) { + + if( pAnim->iNumber & 1 ) { pAnim->smAnimated->SetTranslate( - vector3(0, 0, Min0R(dDoorMoveR * pAnim->fSpeed, dDoorMoveR))); - else + Math3D::vector3{ + 0.0, + 0.0, + dDoorMoveR } ); + } + else { pAnim->smAnimated->SetTranslate( - vector3(0, 0, Min0R(dDoorMoveL * pAnim->fSpeed, dDoorMoveL))); + Math3D::vector3{ + 0.0, + 0.0, + dDoorMoveL } ); + } } }; void TDynamicObject::UpdateDoorRotate(TAnim *pAnim) { // animacja drzwi - obrót if (pAnim->smAnimated) - { // if (MoverParameters->DoorOpenMethod==2) //obrotowe - // albo dwójłomne (trzeba kombinowac - // submodelami i ShiftL=90,R=180) + { if (pAnim->iNumber & 1) pAnim->smAnimated->SetRotate(float3(1, 0, 0), dDoorMoveR); else @@ -436,9 +462,7 @@ void TDynamicObject::UpdateDoorRotate(TAnim *pAnim) void TDynamicObject::UpdateDoorFold(TAnim *pAnim) { // animacja drzwi - obrót if (pAnim->smAnimated) - { // if (MoverParameters->DoorOpenMethod==2) //obrotowe - // albo dwójłomne (trzeba kombinowac - // submodelami i ShiftL=90,R=180) + { if (pAnim->iNumber & 1) { pAnim->smAnimated->SetRotate(float3(0, 0, 1), dDoorMoveR); @@ -454,7 +478,6 @@ void TDynamicObject::UpdateDoorFold(TAnim *pAnim) else { pAnim->smAnimated->SetRotate(float3(0, 0, 1), dDoorMoveL); - // SubModel->SetRotate(float3(0,1,0),fValue*360.0); TSubModel *sm = pAnim->smAnimated->ChildGet(); // skrzydło mniejsze if (sm) { @@ -467,6 +490,35 @@ void TDynamicObject::UpdateDoorFold(TAnim *pAnim) } }; +void TDynamicObject::UpdateDoorPlug(TAnim *pAnim) +{ // animacja drzwi - odskokprzesuw + if (pAnim->smAnimated) { + + if( pAnim->iNumber & 1 ) { + pAnim->smAnimated->SetTranslate( + Math3D::vector3 { + std::min( + dDoorMoveR * 2, + MoverParameters->DoorMaxPlugShift ), + 0.0, + std::max( + 0.0, + dDoorMoveR - MoverParameters->DoorMaxPlugShift * 0.5f ) } ); + } + else { + pAnim->smAnimated->SetTranslate( + Math3D::vector3 { + std::min( + dDoorMoveL * 2, + MoverParameters->DoorMaxPlugShift ), + 0.0, + std::max( + 0.0, + dDoorMoveL - MoverParameters->DoorMaxPlugShift * 0.5f ) } ); + } + } +} + void TDynamicObject::UpdatePant(TAnim *pAnim) { // animacja pantografu - 4 obracane ramiona, ślizg piąty float a, b, c; @@ -483,25 +535,66 @@ void TDynamicObject::UpdatePant(TAnim *pAnim) pAnim->smElement[3]->SetRotate(float3(-1, 0, 0), c); if (pAnim->smElement[4]) pAnim->smElement[4]->SetRotate(float3(-1, 0, 0), b); //ślizg -}; +} -void TDynamicObject::UpdateDoorPlug(TAnim *pAnim) -{ // animacja drzwi - odskokprzesuw - if (pAnim->smAnimated) - { - if (pAnim->iNumber & 1) - pAnim->smAnimated->SetTranslate( - vector3(Min0R(dDoorMoveR * 2, MoverParameters->DoorMaxPlugShift), 0, - Max0R(0, Min0R(dDoorMoveR * pAnim->fSpeed, dDoorMoveR) - - MoverParameters->DoorMaxPlugShift * 0.5f))); - else - pAnim->smAnimated->SetTranslate( - vector3(Min0R(dDoorMoveL * 2, MoverParameters->DoorMaxPlugShift), 0, - Max0R(0, Min0R(dDoorMoveL * pAnim->fSpeed, dDoorMoveL) - - MoverParameters->DoorMaxPlugShift * 0.5f))); +// doorstep animation, shift +void TDynamicObject::UpdatePlatformTranslate( TAnim *pAnim ) { + + if( pAnim->smAnimated == nullptr ) { return; } + + if( pAnim->iNumber & 1 ) { + pAnim->smAnimated->SetTranslate( + Math3D::vector3{ + interpolate( 0.0, MoverParameters->PlatformMaxShift, dDoorstepMoveR ), + 0.0, + 0.0 } ); } -}; + else { + pAnim->smAnimated->SetTranslate( + Math3D::vector3{ + interpolate( 0.0, MoverParameters->PlatformMaxShift, dDoorstepMoveL ), + 0.0, + 0.0 } ); + } +} +// doorstep animation, rotate +void TDynamicObject::UpdatePlatformRotate( TAnim *pAnim ) { + + if( pAnim->smAnimated == nullptr ) { return; } + + if( pAnim->iNumber & 1 ) + pAnim->smAnimated->SetRotate( + float3( 0, 1, 0 ), + interpolate( 0.0, MoverParameters->PlatformMaxShift, dDoorstepMoveR ) ); + else + pAnim->smAnimated->SetRotate( + float3( 0, 1, 0 ), + interpolate( 0.0, MoverParameters->PlatformMaxShift, dDoorstepMoveL ) ); +} + +// mirror animation, rotate +void TDynamicObject::UpdateMirror( TAnim *pAnim ) { + + if( pAnim->smAnimated == nullptr ) { return; } + + // only animate the mirror if it's located on the same end of the vehicle as the active cab + auto const isactive { ( + MoverParameters->ActiveCab > 0 ? ( ( pAnim->iNumber >> 4 ) == side::front ? 1.0 : 0.0 ) : + MoverParameters->ActiveCab < 0 ? ( ( pAnim->iNumber >> 4 ) == side::rear ? 1.0 : 0.0 ) : + 0.0 ) }; + + if( pAnim->iNumber & 1 ) + pAnim->smAnimated->SetRotate( + float3( 0, 1, 0 ), + interpolate( 0.0, MoverParameters->MirrorMaxShift, dMirrorMoveR * isactive ) ); + else + pAnim->smAnimated->SetRotate( + float3( 0, 1, 0 ), + interpolate( 0.0, MoverParameters->MirrorMaxShift, dMirrorMoveL * isactive ) ); +} + +/* void TDynamicObject::UpdateLeverDouble(TAnim *pAnim) { // animacja gałki zależna od double pAnim->smAnimated->SetRotate(float3(1, 0, 0), pAnim->fSpeed * *pAnim->fDoubleBase); @@ -521,9 +614,41 @@ void TDynamicObject::UpdateLeverEnum(TAnim *pAnim) // pAnim->fParam[0]; - dodać lepkość pAnim->smAnimated->SetRotate(float3(1, 0, 0), pAnim->fParam[*pAnim->iIntBase]); }; +*/ +// sets light levels for registered interior sections +void +TDynamicObject::toggle_lights() { + + if( true == SectionLightsActive ) { + // switch all lights off + for( auto §ion : Sections ) { + section.light_level = 0.0f; + } + SectionLightsActive = false; + } + else { + // set lights with probability depending on the compartment type. TODO: expose this in .mmd file + for( auto §ion : Sections ) { + + auto const sectionname { section.compartment->pName }; + if( ( sectionname.find( "corridor" ) == 0 ) + || ( sectionname.find( "korytarz" ) == 0 ) ) { + // corridors are lit 100% of time + section.light_level = 0.75f; + } + else if( + ( sectionname.find( "compartment" ) == 0 ) + || ( sectionname.find( "przedzial" ) == 0 ) ) { + // compartments are lit with 75% probability + section.light_level = ( Random() < 0.75 ? 0.75f : 0.15f ); + } + } + SectionLightsActive = true; + } +} // ABu 29.01.05 przeklejone z render i renderalpha: ********************* -void __inline TDynamicObject::ABuLittleUpdate(double ObjSqrDist) +void TDynamicObject::ABuLittleUpdate(double ObjSqrDist) { // ABu290105: pozbierane i uporzadkowane powtarzajace // sie rzeczy z Render i RenderAlpha // dodatkowy warunek, if (ObjSqrDist<...) zeby niepotrzebnie nie zmianiec w @@ -536,18 +661,20 @@ void __inline TDynamicObject::ABuLittleUpdate(double ObjSqrDist) if (vFloor.z > 0.0) mdLoad->GetSMRoot()->SetTranslate(modelShake + vFloor); - if (ObjSqrDist < 160000) // gdy bliżej niż 400m + if (ObjSqrDist < ( 400 * 400 ) ) // gdy bliżej niż 400m { - for (int i = 0; i < iAnimations; ++i) // wykonanie kolejnych animacji - if (ObjSqrDist < pAnimations[i].fMaxDist) - if (pAnimations[i].yUpdate) // jeśli zdefiniowana funkcja - pAnimations[ i ].yUpdate( &pAnimations[i] ); // aktualizacja animacji (położenia submodeli -/* - pAnimations[i].yUpdate(pAnimations + - i); // aktualizacja animacji (położenia submodeli -*/ - if( ObjSqrDist < 2500 ) // gdy bliżej niż 50m - { + for( auto &animation : pAnimations ) { + // wykonanie kolejnych animacji + if( ( ObjSqrDist < animation.fMaxDist ) + && ( animation.yUpdate ) ) { + // jeśli zdefiniowana funkcja aktualizacja animacji (położenia submodeli + animation.yUpdate( &animation ); + } + } + + if( ( mdModel != nullptr ) + && ( ObjSqrDist < ( 50 * 50 ) ) ) { + // gdy bliżej niż 50m // ABu290105: rzucanie pudlem // te animacje wymagają bananów w modelach! mdModel->GetSMRoot()->SetTranslate(modelShake); @@ -557,8 +684,6 @@ void __inline TDynamicObject::ABuLittleUpdate(double ObjSqrDist) mdLoad->GetSMRoot()->SetTranslate(modelShake + vFloor); if (mdLowPolyInt) mdLowPolyInt->GetSMRoot()->SetTranslate(modelShake); - if (mdPrzedsionek) - mdPrzedsionek->GetSMRoot()->SetTranslate(modelShake); // ABu: koniec rzucania // ABu011104: liczenie obrotow wozkow ABuBogies(); @@ -569,14 +694,14 @@ void __inline TDynamicObject::ABuLittleUpdate(double ObjSqrDist) if ((TestFlag(MoverParameters->Couplers[0].CouplingFlag, ctrain_coupler)) && (MoverParameters->Couplers[0].Render)) { - btCoupler1.TurnOn(); + btCoupler1.Turn( true ); btnOn = true; } // else btCoupler1.TurnOff(); if ((TestFlag(MoverParameters->Couplers[1].CouplingFlag, ctrain_coupler)) && (MoverParameters->Couplers[1].Render)) { - btCoupler2.TurnOn(); + btCoupler2.Turn( true ); btnOn = true; } // else btCoupler2.TurnOff(); @@ -585,7 +710,7 @@ void __inline TDynamicObject::ABuLittleUpdate(double ObjSqrDist) // 'render' - juz // nie // przewody powietrzne, yB: decyzja na podstawie polaczen w t3d - if (Global::bnewAirCouplers) + if (Global.bnewAirCouplers) { SetPneumatic(false, false); // wczytywanie z t3d ulozenia wezykow SetPneumatic(true, false); // i zapisywanie do zmiennej @@ -611,11 +736,6 @@ void __inline TDynamicObject::ABuLittleUpdate(double ObjSqrDist) } btnOn = true; } - // else - //{ - // btCPneumatic1.TurnOff(); - // btCPneumatic1r.TurnOff(); - //} if (TestFlag(MoverParameters->Couplers[1].CouplingFlag, ctrain_pneumatic)) { @@ -636,11 +756,6 @@ void __inline TDynamicObject::ABuLittleUpdate(double ObjSqrDist) } btnOn = true; } - // else - //{ - // btCPneumatic2.TurnOff(); - // btCPneumatic2r.TurnOff(); - //} // przewody zasilajace, j.w. (yB) if (TestFlag(MoverParameters->Couplers[0].CouplingFlag, ctrain_scndpneumatic)) @@ -662,11 +777,6 @@ void __inline TDynamicObject::ABuLittleUpdate(double ObjSqrDist) } btnOn = true; } - // else - //{ - // btPneumatic1.TurnOff(); - // btPneumatic1r.TurnOff(); - //} if (TestFlag(MoverParameters->Couplers[1].CouplingFlag, ctrain_scndpneumatic)) { @@ -687,11 +797,6 @@ void __inline TDynamicObject::ABuLittleUpdate(double ObjSqrDist) } btnOn = true; } - // else - //{ - // btPneumatic2.TurnOff(); - // btPneumatic2r.TurnOff(); - //} } //*********************************************************************************/ else // po staremu ABu'oewmu @@ -706,11 +811,6 @@ void __inline TDynamicObject::ABuLittleUpdate(double ObjSqrDist) btCPneumatic1r.TurnOn(); btnOn = true; } - // else - //{ - // btCPneumatic1.TurnOff(); - // btCPneumatic1r.TurnOff(); - //} if (TestFlag(MoverParameters->Couplers[1].CouplingFlag, ctrain_pneumatic)) { @@ -720,11 +820,6 @@ void __inline TDynamicObject::ABuLittleUpdate(double ObjSqrDist) btCPneumatic2r.TurnOn(); btnOn = true; } - // else - //{ - // btCPneumatic2.TurnOff(); - // btCPneumatic2r.TurnOff(); - //} // przewody powietrzne j.w., ABu: decyzja czy rysowac tylko na podstawie // 'render' @@ -737,11 +832,6 @@ void __inline TDynamicObject::ABuLittleUpdate(double ObjSqrDist) btPneumatic1r.TurnOn(); btnOn = true; } - // else - //{ - // btPneumatic1.TurnOff(); - // btPneumatic1r.TurnOff(); - //} if (TestFlag(MoverParameters->Couplers[1].CouplingFlag, ctrain_scndpneumatic)) { @@ -751,11 +841,6 @@ void __inline TDynamicObject::ABuLittleUpdate(double ObjSqrDist) btPneumatic2r.TurnOn(); btnOn = true; } - // else - //{ - // btPneumatic2.TurnOff(); - // btPneumatic2r.TurnOff(); - //} } //*************************************************************/// koniec // wezykow @@ -765,48 +850,48 @@ void __inline TDynamicObject::ABuLittleUpdate(double ObjSqrDist) double dist = MoverParameters->Couplers[i].Dist / 2.0; if (smBuforLewy[i]) if (dist < 0) - smBuforLewy[i]->SetTranslate(vector3(dist, 0, 0)); + smBuforLewy[i]->SetTranslate( Math3D::vector3(dist, 0, 0)); if (smBuforPrawy[i]) if (dist < 0) - smBuforPrawy[i]->SetTranslate(vector3(dist, 0, 0)); + smBuforPrawy[i]->SetTranslate( Math3D::vector3(dist, 0, 0)); } - } + } // vehicle within 50m // Winger 160204 - podnoszenie pantografow // przewody sterowania ukrotnionego if (TestFlag(MoverParameters->Couplers[0].CouplingFlag, ctrain_controll)) { - btCCtrl1.TurnOn(); + btCCtrl1.Turn( true ); btnOn = true; } // else btCCtrl1.TurnOff(); if (TestFlag(MoverParameters->Couplers[1].CouplingFlag, ctrain_controll)) { - btCCtrl2.TurnOn(); + btCCtrl2.Turn( true ); btnOn = true; } // else btCCtrl2.TurnOff(); // McZapkie-181103: mostki przejsciowe if (TestFlag(MoverParameters->Couplers[0].CouplingFlag, ctrain_passenger)) { - btCPass1.TurnOn(); + btCPass1.Turn( true ); btnOn = true; } // else btCPass1.TurnOff(); if (TestFlag(MoverParameters->Couplers[1].CouplingFlag, ctrain_passenger)) { - btCPass2.TurnOn(); + btCPass2.Turn( true ); btnOn = true; } // else btCPass2.TurnOff(); - if (MoverParameters->Battery) + if (MoverParameters->Battery || MoverParameters->ConverterFlag) { // sygnaly konca pociagu if (btEndSignals1.Active()) { if (TestFlag(iLights[0], 2) || TestFlag(iLights[0], 32)) { - btEndSignals1.TurnOn(); + btEndSignals1.Turn( true ); btnOn = true; } // else btEndSignals1.TurnOff(); @@ -815,13 +900,13 @@ void __inline TDynamicObject::ABuLittleUpdate(double ObjSqrDist) { if (TestFlag(iLights[0], 2)) { - btEndSignals11.TurnOn(); + btEndSignals11.Turn( true ); btnOn = true; } // else btEndSignals11.TurnOff(); if (TestFlag(iLights[0], 32)) { - btEndSignals13.TurnOn(); + btEndSignals13.Turn( true ); btnOn = true; } // else btEndSignals13.TurnOff(); @@ -830,7 +915,7 @@ void __inline TDynamicObject::ABuLittleUpdate(double ObjSqrDist) { if (TestFlag(iLights[1], 2) || TestFlag(iLights[1], 32)) { - btEndSignals2.TurnOn(); + btEndSignals2.Turn( true ); btnOn = true; } // else btEndSignals2.TurnOff(); @@ -839,28 +924,28 @@ void __inline TDynamicObject::ABuLittleUpdate(double ObjSqrDist) { if (TestFlag(iLights[1], 2)) { - btEndSignals21.TurnOn(); + btEndSignals21.Turn( true ); btnOn = true; } // else btEndSignals21.TurnOff(); if (TestFlag(iLights[1], 32)) { - btEndSignals23.TurnOn(); + btEndSignals23.Turn( true ); btnOn = true; } // else btEndSignals23.TurnOff(); } } // tablice blaszane: - if (TestFlag(iLights[0], 64)) + if (TestFlag(iLights[side::front], light::rearendsignals)) { - btEndSignalsTab1.TurnOn(); + btEndSignalsTab1.Turn( true ); btnOn = true; } // else btEndSignalsTab1.TurnOff(); - if (TestFlag(iLights[1], 64)) + if (TestFlag(iLights[side::rear], light::rearendsignals)) { - btEndSignalsTab2.TurnOn(); + btEndSignalsTab2.Turn( true ); btnOn = true; } // else btEndSignalsTab2.TurnOff(); @@ -870,168 +955,127 @@ void __inline TDynamicObject::ABuLittleUpdate(double ObjSqrDist) if (smWahacze[i]) smWahacze[i]->SetRotate(float3(1, 0, 0), fWahaczeAmp * cos(MoverParameters->eAngle)); - - if (Mechanik) - { // rysowanie figurki mechanika - /* - if (smMechanik0) // mechanik od strony sprzęgu 0 - if (smMechanik1) // jak jest drugi, to pierwszego jedynie pokazujemy - smMechanik0->iVisible = MoverParameters->ActiveCab > 0; - else - { // jak jest tylko jeden, to do drugiej kabiny go obracamy - smMechanik0->iVisible = (MoverParameters->ActiveCab != 0); - smMechanik0->SetRotate( - float3(0, 0, 1), - MoverParameters->ActiveCab >= 0 ? 0 : 180); // obrót względem osi Z - } - if (smMechanik1) // mechanik od strony sprzęgu 1 - smMechanik1->iVisible = MoverParameters->ActiveCab < 0; - */ - if (MoverParameters->ActiveCab > 0) - { - btMechanik1.TurnOn(); - btnOn = true; - } - if (MoverParameters->ActiveCab < 0) - { - btMechanik2.TurnOn(); - btnOn = true; - } + + // cooling shutters + // NOTE: shutters display _on state when they're closed, _off otherwise + if( ( true == MoverParameters->dizel_heat.water.config.shutters ) + && ( false == MoverParameters->dizel_heat.zaluzje1 ) ) { + btShutters1.Turn( true ); + btnOn = true; } - // ABu: Przechyly na zakretach - // Ra: przechyłkę załatwiamy na etapie przesuwania modelu - // if (ObjSqrDist<80000) ABuModelRoll(); //przechyłki od 400m - } - if (MoverParameters->Battery) + if( ( true == MoverParameters->dizel_heat.water_aux.config.shutters ) + && ( false == MoverParameters->dizel_heat.zaluzje2 ) ) { + btShutters2.Turn( true ); + btnOn = true; + } + + if( ( Mechanik != nullptr ) + && ( ( Mechanik->GetAction() != TAction::actSleep ) + || ( MoverParameters->Battery ) ) ) { + // rysowanie figurki mechanika + btMechanik1.Turn( MoverParameters->ActiveCab > 0 ); + btMechanik2.Turn( MoverParameters->ActiveCab < 0 ); + if( MoverParameters->ActiveCab != 0 ) { + btnOn = true; + } + } + + } // vehicle within 400m + + if( MoverParameters->Battery || MoverParameters->ConverterFlag ) { // sygnały czoła pociagu //Ra: wyświetlamy bez // ograniczeń odległości, by były widoczne z // daleka if (TestFlag(iLights[0], 1)) { - btHeadSignals11.TurnOn(); + btHeadSignals11.Turn( true ); btnOn = true; } // else btHeadSignals11.TurnOff(); if (TestFlag(iLights[0], 4)) { - btHeadSignals12.TurnOn(); + btHeadSignals12.Turn( true ); btnOn = true; } // else btHeadSignals12.TurnOff(); if (TestFlag(iLights[0], 16)) { - btHeadSignals13.TurnOn(); + btHeadSignals13.Turn( true ); btnOn = true; } // else btHeadSignals13.TurnOff(); if (TestFlag(iLights[1], 1)) { - btHeadSignals21.TurnOn(); + btHeadSignals21.Turn( true ); btnOn = true; } // else btHeadSignals21.TurnOff(); if (TestFlag(iLights[1], 4)) { - btHeadSignals22.TurnOn(); + btHeadSignals22.Turn( true ); btnOn = true; } // else btHeadSignals22.TurnOff(); if (TestFlag(iLights[1], 16)) { - btHeadSignals23.TurnOn(); + btHeadSignals23.Turn( true ); btnOn = true; } // else btHeadSignals23.TurnOff(); } + // interior light levels + for( auto const §ion : Sections ) { + section.compartment->SetLightLevel( section.light_level, true ); + if( section.load != nullptr ) { + section.load->SetLightLevel( section.light_level, true ); + } + } + // load chunks visibility + for( auto const §ion : SectionLoadVisibility ) { + section.submodel->iVisible = section.visible; + if( false == section.visible ) { + // if the section root isn't visible we can skip meddling with its children + continue; + } + // if the section root is visible set the state of section chunks + auto *sectionchunk { section.submodel->ChildGet() }; + auto visiblechunkcount { section.visible_chunks }; + while( sectionchunk != nullptr ) { + sectionchunk->iVisible = ( visiblechunkcount > 0 ); + --visiblechunkcount; + sectionchunk = sectionchunk->NextGet(); + } + } + } // ABu 29.01.05 koniec przeklejenia ************************************* -double ABuAcos(const vector3 &calc_temp) -{ // Odpowiednik funkcji Arccos, bo cos - // mi tam nie dzialalo. - return atan2(-calc_temp.x, calc_temp.z); // Ra: tak prościej -} - -TDynamicObject * TDynamicObject::ABuFindNearestObject(TTrack *Track, - TDynamicObject *MyPointer, - int &CouplNr) -{ // zwraca wskaznik do obiektu znajdujacego sie na torze - // (Track), którego sprzęg jest najblizszy - // kamerze +TDynamicObject * TDynamicObject::ABuFindNearestObject(TTrack *Track, TDynamicObject *MyPointer, int &CouplNr) +{ + // zwraca wskaznik do obiektu znajdujacego sie na torze (Track), którego sprzęg jest najblizszy kamerze // służy np. do łączenia i rozpinania sprzęgów // WE: Track - tor, na ktorym odbywa sie poszukiwanie // MyPointer - wskaznik do obiektu szukajacego // WY: CouplNr - który sprzęg znalezionego obiektu jest bliższy kamerze // Uwaga! Jesli CouplNr==-2 to szukamy njblizszego obiektu, a nie sprzegu!!! - -#ifdef EU07_USE_OLD_TTRACK_DYNAMICS_ARRAY - if ((Track->iNumDynamics) > 0) - { // o ile w ogóle jest co przeglądać na tym torze - // vector3 poz; //pozycja pojazdu XYZ w scenerii - // vector3 kon; //wektor czoła względem środka pojazdu wzglęem początku toru - vector3 tmp; // wektor pomiędzy kamerą i sprzęgiem - double dist; // odległość - for (int i = 0; i < Track->iNumDynamics; i++) - { - if (CouplNr == -2) - { // wektor [kamera-obiekt] - poszukiwanie obiektu - tmp = Global::GetCameraPosition() - Track->Dynamics[i]->vPosition; - dist = tmp.x * tmp.x + tmp.y * tmp.y + tmp.z * tmp.z; // odległość do kwadratu - if (dist < 100.0) // 10 metrów - return Track->Dynamics[i]; - } - else // jeśli (CouplNr) inne niz -2, szukamy sprzęgu - { // wektor [kamera-sprzeg0], potem [kamera-sprzeg1] - // Powinno byc wyliczone, ale nie zaszkodzi drugi raz: - //(bo co, jesli nie wykonuje sie obrotow wozkow?) - Ra: ale zawsze są - // liczone - // współrzędne sprzęgów - // Track->Dynamics[i]->modelRot.z=ABuAcos(Track->Dynamics[i]->Axle0.pPosition-Track->Dynamics[i]->Axle1.pPosition); - // poz=Track->Dynamics[i]->vPosition; //pozycja środka pojazdu - // kon=vector3( //położenie przodu względem środka - // -((0.5*Track->Dynamics[i]->MoverParameters->Dim.L)*sin(Track->Dynamics[i]->modelRot.z)), - // 0, //yyy... jeśli duże pochylenie i długi pojazd, to może być problem - // +((0.5*Track->Dynamics[i]->MoverParameters->Dim.L)*cos(Track->Dynamics[i]->modelRot.z)) - //); - tmp = - Global::GetCameraPosition() - - Track->Dynamics[i]->vCoulpler[0]; // Ra: pozycje sprzęgów też są zawsze liczone - dist = tmp.x * tmp.x + tmp.y * tmp.y + tmp.z * tmp.z; // odległość do kwadratu - if (dist < 25.0) // 5 metrów - { - CouplNr = 0; - return Track->Dynamics[i]; - } - tmp = Global::GetCameraPosition() - Track->Dynamics[i]->vCoulpler[1]; - dist = tmp.x * tmp.x + tmp.y * tmp.y + tmp.z * tmp.z; // odległość do kwadratu - if (dist < 25.0) // 5 metrów - { - CouplNr = 1; - return Track->Dynamics[i]; - } - } - } - return NULL; - } -#else for( auto dynamic : Track->Dynamics ) { if( CouplNr == -2 ) { // wektor [kamera-obiekt] - poszukiwanie obiektu - if( LengthSquared3( Global::GetCameraPosition() - dynamic->vPosition ) < 100.0 ) { + if( Math3D::LengthSquared3( Global.pCamera.Pos - dynamic->vPosition ) < 100.0 ) { // 10 metrów return dynamic; } } else { // jeśli (CouplNr) inne niz -2, szukamy sprzęgu - if( LengthSquared3( Global::GetCameraPosition() - dynamic->vCoulpler[ 0 ] ) < 25.0 ) { + if( Math3D::LengthSquared3( Global.pCamera.Pos - dynamic->vCoulpler[ 0 ] ) < 25.0 ) { // 5 metrów CouplNr = 0; return dynamic; } - if( LengthSquared3( Global::GetCameraPosition() - dynamic->vCoulpler[ 1 ] ) < 25.0 ) { + if( Math3D::LengthSquared3( Global.pCamera.Pos - dynamic->vCoulpler[ 1 ] ) < 25.0 ) { // 5 metrów CouplNr = 1; return dynamic; @@ -1040,14 +1084,10 @@ TDynamicObject * TDynamicObject::ABuFindNearestObject(TTrack *Track, } // empty track or nothing found return nullptr; -#endif } -TDynamicObject * TDynamicObject::ABuScanNearestObject(TTrack *Track, double ScanDir, - double ScanDist, int &CouplNr) -{ // skanowanie toru w poszukiwaniu obiektu najblizszego - // kamerze - // double MyScanDir=ScanDir; //Moja orientacja na torze. //Ra: nie używane +TDynamicObject * TDynamicObject::ABuScanNearestObject(TTrack *Track, double ScanDir, double ScanDist, int &CouplNr) +{ // skanowanie toru w poszukiwaniu obiektu najblizszego kamerze if (ABuGetDirection() < 0) ScanDir = -ScanDir; TDynamicObject *FoundedObj; @@ -1137,246 +1177,114 @@ void TDynamicObject::ABuCheckMyTrack() // do jednej tablicy. Wykonuje sie tylko raz - po to 'ABuChecked' TTrack *OldTrack = MyTrack; TTrack *NewTrack = Axle0.GetTrack(); - if ((NewTrack != OldTrack) && OldTrack) - { - OldTrack->RemoveDynamicObject(this); + if( NewTrack != OldTrack ) { + if( OldTrack ) { + OldTrack->RemoveDynamicObject( this ); + } NewTrack->AddDynamicObject(this); } iAxleFirst = 0; // pojazd powiązany z przednią osią - Axle0 } // Ra: w poniższej funkcji jest problem ze sprzęgami -TDynamicObject * TDynamicObject::ABuFindObject(TTrack *Track, int ScanDir, - BYTE &CouplFound, double &dist) +TDynamicObject * +TDynamicObject::ABuFindObject( int &Foundcoupler, double &Distance, TTrack const *Track, int const Direction, int const Mycoupler ) { // Zwraca wskaźnik najbliższego obiektu znajdującego się // na torze w określonym kierunku, ale tylko wtedy, kiedy // obiekty mogą się zderzyć, tzn. nie mijają się. + // WE: + // Track - tor, na ktorym odbywa sie poszukiwanie, + // Direction - kierunek szukania na torze (+1:w stronę Point2, -1:w stronę Point1) + // Mycoupler - nr sprzegu obiektu szukajacego; + // WY: + // wskaznik do znalezionego obiektu. + // Foundcoupler - nr sprzegu znalezionego obiektu + // Distance - distance to found object - // WE: Track - tor, na ktorym odbywa sie poszukiwanie, - // MyPointer - wskaznik do obiektu szukajacego. //Ra: zamieniłem na "this" - // ScanDir - kierunek szukania na torze (+1:w stronę Point2, -1:w stronę - // Point1) - // MyScanDir - kierunek szukania obiektu szukajacego (na jego torze); Ra: - // nie potrzebne - // MyCouplFound - nr sprzegu obiektu szukajacego; Ra: nie potrzebne - - // WY: wskaznik do znalezionego obiektu. - // CouplFound - nr sprzegu znalezionego obiektu -#ifdef EU07_USE_OLD_TTRACK_DYNAMICS_ARRAY - if (Track->iNumDynamics > 0) -#else - if( false == Track->Dynamics.empty() ) -#endif - { // sens szukania na tym torze jest tylko, gdy są na nim pojazdy - double ObjTranslation; // pozycja najblizszego obiektu na torze - double MyTranslation; // pozycja szukającego na torze - double MinDist = Track->Length(); // najmniejsza znaleziona odleglość - // (zaczynamy od długości toru) - double TestDist; // robocza odległość od kolejnych pojazdów na danym odcinku -#ifdef EU07_USE_OLD_TTRACK_DYNAMICS_ARRAY - int iMinDist = -1; // indeks wykrytego obiektu -#else - TDynamicObject *collider = nullptr; -#endif - // if (Track->iNumDynamics>1) - // iMinDist+=0; //tymczasowo pułapka - if (MyTrack == Track) // gdy szukanie na tym samym torze - MyTranslation = RaTranslationGet(); // położenie wózka względem Point1 toru - else // gdy szukanie na innym torze - if (ScanDir > 0) - MyTranslation = 0; // szukanie w kierunku Point2 (od zera) - jesteśmy w Point1 - else - MyTranslation = MinDist; // szukanie w kierunku Point1 (do zera) - jesteśmy w Point2 - if (ScanDir >= 0) - { // jeśli szukanie w kierunku Point2 -#ifdef EU07_USE_OLD_TTRACK_DYNAMICS_ARRAY - for( int i = 0; i < Track->iNumDynamics; i++ ) - { // pętla po pojazdach - if (Track->Dynamics[i] != this) // szukający się nie liczy - { - TestDist = (Track->Dynamics[i]->RaTranslationGet()) - - MyTranslation; // odległogłość tamtego od szukającego - if ((TestDist > 0) && (TestDist <= MinDist)) - { // gdy jest po właściwej stronie i bliżej - // niż jakiś wcześniejszy - CouplFound = (Track->Dynamics[i]->RaDirectionGet() > 0) ? - 1 : - 0; // to, bo (ScanDir>=0) - if (Track->iCategoryFlag & 254) // trajektoria innego typu niż tor kolejowy - { // dla torów nie ma sensu tego sprawdzać, rzadko co jedzie po - // jednej - // szynie i się mija - // Ra: mijanie samochodów wcale nie jest proste - // Przesuniecie wzgledne pojazdow. Wyznaczane, zeby sprawdzic, - // czy pojazdy faktycznie sie zderzaja (moga byc przesuniete - // w/m siebie tak, ze nie zachodza na siebie i wtedy sie mijaja). - double RelOffsetH; // wzajemna odległość poprzeczna - if (CouplFound) // my na tym torze byśmy byli w kierunku Point2 - // dla CouplFound=1 są zwroty zgodne - istotna różnica - // przesunięć - RelOffsetH = (MoverParameters->OffsetTrackH - - Track->Dynamics[i]->MoverParameters->OffsetTrackH); - else - // dla CouplFound=0 są zwroty przeciwne - przesunięcia sumują - // się - RelOffsetH = (MoverParameters->OffsetTrackH + - Track->Dynamics[i]->MoverParameters->OffsetTrackH); - if (RelOffsetH < 0) - RelOffsetH = -RelOffsetH; - if (RelOffsetH + RelOffsetH > - MoverParameters->Dim.W + Track->Dynamics[i]->MoverParameters->Dim.W) - continue; // odległość większa od połowy sumy szerokości - - // kolizji - // nie będzie - // jeśli zahaczenie jest niewielkie, a jest miejsce na poboczu, to - // zjechać na pobocze - } - iMinDist = i; // potencjalna kolizja - MinDist = TestDist; // odleglość pomiędzy aktywnymi osiami pojazdów - } - } - } -#else - for( auto dynamic : Track->Dynamics ) { - // pętla po pojazdach - if( dynamic == this ) { - // szukający się nie liczy - continue; - } - - TestDist = ( dynamic->RaTranslationGet() ) - MyTranslation; // odległogłość tamtego od szukającego - if( ( TestDist > 0 ) && ( TestDist <= MinDist ) ) { // gdy jest po właściwej stronie i bliżej - // niż jakiś wcześniejszy - CouplFound = ( dynamic->RaDirectionGet() > 0 ) ? 1 : 0; // to, bo (ScanDir>=0) - if( Track->iCategoryFlag & 254 ) { - // trajektoria innego typu niż tor kolejowy - // dla torów nie ma sensu tego sprawdzać, rzadko co jedzie po jednej szynie i się mija - // Ra: mijanie samochodów wcale nie jest proste - // Przesuniecie wzgledne pojazdow. Wyznaczane, zeby sprawdzic, - // czy pojazdy faktycznie sie zderzaja (moga byc przesuniete - // w/m siebie tak, ze nie zachodza na siebie i wtedy sie mijaja). - double RelOffsetH; // wzajemna odległość poprzeczna - if( CouplFound ) { - // my na tym torze byśmy byli w kierunku Point2 - // dla CouplFound=1 są zwroty zgodne - istotna różnica przesunięć - RelOffsetH = ( MoverParameters->OffsetTrackH - dynamic->MoverParameters->OffsetTrackH ); - } - else { - // dla CouplFound=0 są zwroty przeciwne - przesunięcia sumują się - RelOffsetH = ( MoverParameters->OffsetTrackH + dynamic->MoverParameters->OffsetTrackH ); - } - if( RelOffsetH < 0 ) { - RelOffsetH = -RelOffsetH; - } - if( RelOffsetH + RelOffsetH > MoverParameters->Dim.W + dynamic->MoverParameters->Dim.W ) { - // odległość większa od połowy sumy szerokości - kolizji nie będzie - continue; - } - // jeśli zahaczenie jest niewielkie, a jest miejsce na poboczu, to - // zjechać na pobocze - } - collider = dynamic; // potencjalna kolizja - MinDist = TestDist; // odleglość pomiędzy aktywnymi osiami pojazdów - } - - } -#endif - } - else //(ScanDir<0) - { -#ifdef EU07_USE_OLD_TTRACK_DYNAMICS_ARRAY - for( int i = 0; i < Track->iNumDynamics; i++ ) - { - if (Track->Dynamics[i] != this) - { - TestDist = MyTranslation - - (Track->Dynamics[i]->RaTranslationGet()); //???-przesunięcie wózka - // względem Point1 toru - if ((TestDist > 0) && (TestDist < MinDist)) - { - CouplFound = (Track->Dynamics[i]->RaDirectionGet() > 0) ? - 0 : - 1; // odwrotnie, bo (ScanDir<0) - if (Track->iCategoryFlag & 254) // trajektoria innego typu niż tor kolejowy - { // dla torów nie ma sensu tego sprawdzać, rzadko co jedzie po - // jednej - // szynie i się mija - // Ra: mijanie samochodów wcale nie jest proste - // Przesunięcie względne pojazdów. Wyznaczane, żeby sprawdzić, - // czy pojazdy faktycznie się zderzają (mogą być przesunięte - // w/m siebie tak, że nie zachodzą na siebie i wtedy sie mijają). - double RelOffsetH; // wzajemna odległość poprzeczna - if (CouplFound) // my na tym torze byśmy byli w kierunku Point1 - // dla CouplFound=1 są zwroty zgodne - istotna różnica - // przesunięć - RelOffsetH = (MoverParameters->OffsetTrackH - - Track->Dynamics[i]->MoverParameters->OffsetTrackH); - else - // dla CouplFound=0 są zwroty przeciwne - przesunięcia sumują - // się - RelOffsetH = (MoverParameters->OffsetTrackH + - Track->Dynamics[i]->MoverParameters->OffsetTrackH); - if (RelOffsetH < 0) - RelOffsetH = -RelOffsetH; - if (RelOffsetH + RelOffsetH > - MoverParameters->Dim.W + Track->Dynamics[i]->MoverParameters->Dim.W) - continue; // odległość większa od połowy sumy szerokości - - // kolizji - // nie będzie - } - iMinDist = i; // potencjalna kolizja - MinDist = TestDist; // odleglość pomiędzy aktywnymi osiami pojazdów - } - } - } -#else - for( auto dynamic : Track->Dynamics ) { - - if( dynamic == this ) { continue; } - - TestDist = MyTranslation - ( dynamic->RaTranslationGet() ); //???-przesunięcie wózka względem Point1 toru - if( ( TestDist > 0 ) && ( TestDist < MinDist ) ) { - CouplFound = ( dynamic->RaDirectionGet() > 0 ) ? 0 : 1; // odwrotnie, bo (ScanDir<0) - if( Track->iCategoryFlag & 254 ) // trajektoria innego typu niż tor kolejowy - { // dla torów nie ma sensu tego sprawdzać, rzadko co jedzie po jednej szynie i się mija - // Ra: mijanie samochodów wcale nie jest proste - // Przesunięcie względne pojazdów. Wyznaczane, żeby sprawdzić, - // czy pojazdy faktycznie się zderzają (mogą być przesunięte - // w/m siebie tak, że nie zachodzą na siebie i wtedy sie mijają). - double RelOffsetH; // wzajemna odległość poprzeczna - if( CouplFound ) { - // my na tym torze byśmy byli w kierunku Point1 - // dla CouplFound=1 są zwroty zgodne - istotna różnica przesunięć - RelOffsetH = ( MoverParameters->OffsetTrackH - dynamic->MoverParameters->OffsetTrackH ); - } - else { - // dla CouplFound=0 są zwroty przeciwne - przesunięcia sumują się - RelOffsetH = ( MoverParameters->OffsetTrackH + dynamic->MoverParameters->OffsetTrackH ); - } - if( RelOffsetH < 0 ) { - RelOffsetH = -RelOffsetH; - } - if( RelOffsetH + RelOffsetH > MoverParameters->Dim.W + dynamic->MoverParameters->Dim.W ) { - // odległość większa od połowy sumy szerokości - kolizji nie będzie - continue; - } - } - collider = dynamic; // potencjalna kolizja - MinDist = TestDist; // odleglość pomiędzy aktywnymi osiami pojazdów - } - } -#endif - } - dist += MinDist; // doliczenie odległości przeszkody albo długości odcinka do przeskanowanej odległości -#ifdef EU07_USE_OLD_TTRACK_DYNAMICS_ARRAY - return ( iMinDist >= 0 ) ? Track->Dynamics[ iMinDist ] : NULL; -#else - return collider; -#endif + if( true == Track->Dynamics.empty() ) { + // sens szukania na tym torze jest tylko, gdy są na nim pojazdy + Distance += Track->Length(); // doliczenie długości odcinka do przeskanowanej odległości + return nullptr; // nie ma pojazdów na torze, to jest NULL } - dist += Track->Length(); // doliczenie długości odcinka do przeskanowanej - // odległości - return nullptr; // nie ma pojazdów na torze, to jest NULL + + double distance = Track->Length(); // najmniejsza znaleziona odleglość (zaczynamy od długości toru) + double myposition; // pozycja szukającego na torze + TDynamicObject *foundobject = nullptr; + if( MyTrack == Track ) { + // gdy szukanie na tym samym torze + myposition = RaTranslationGet(); // położenie wózka względem Point1 toru + } + else { + // gdy szukanie na innym torze + if( Direction > 0 ) { + // szukanie w kierunku Point2 (od zera) - jesteśmy w Point1 + myposition = 0; + } + else { + // szukanie w kierunku Point1 (do zera) - jesteśmy w Point2 + myposition = distance; + } + } + + double objectposition; // robocza odległość od kolejnych pojazdów na danym odcinku + for( auto dynamic : Track->Dynamics ) { + + if( dynamic == this ) { continue; } // szukający się nie liczy +/* + if( ( ( dynamic == PrevConnected ) && ( MoverParameters->Couplers[ TMoverParameters::side::front ].CouplingFlag != coupling::faux ) ) + || ( ( dynamic == NextConnected ) && ( MoverParameters->Couplers[ TMoverParameters::side::rear ].CouplingFlag != coupling::faux ) ) ){ + // stop-gap check to prevent 'detection' of attached vehicles + // which seems to be a side-effect of inaccurate location calculation in 'simple' mode? + // TODO: investigate actual cause + continue; + } +*/ + if( Direction > 0 ) { + // jeśli szukanie w kierunku Point2 + objectposition = ( dynamic->RaTranslationGet() ) - myposition; // odległogłość tamtego od szukającego + if( ( objectposition > 0 ) + && ( objectposition < distance ) ) { + // gdy jest po właściwej stronie i bliżej niż jakiś wcześniejszy + Foundcoupler = ( dynamic->RaDirectionGet() > 0 ) ? 1 : 0; // to, bo (ScanDir>=0) + } + else { continue; } + } + else { + objectposition = myposition - ( dynamic->RaTranslationGet() ); //???-przesunięcie wózka względem Point1 toru + if( ( objectposition > 0 ) + && ( objectposition < distance ) ) { + Foundcoupler = ( dynamic->RaDirectionGet() > 0 ) ? 0 : 1; // odwrotnie, bo (ScanDir<0) + } + else { continue; } + } + + if( Track->iCategoryFlag & 254 ) { + // trajektoria innego typu niż tor kolejowy + // dla torów nie ma sensu tego sprawdzać, rzadko co jedzie po jednej szynie i się mija + // Ra: mijanie samochodów wcale nie jest proste + // Przesuniecie wzgledne pojazdow. Wyznaczane, zeby sprawdzic, + // czy pojazdy faktycznie sie zderzaja (moga byc przesuniete + // w/m siebie tak, ze nie zachodza na siebie i wtedy sie mijaja). + double relativeoffset; // wzajemna odległość poprzeczna + if( Foundcoupler != Mycoupler ) { + // facing the same direction + relativeoffset = std::abs( MoverParameters->OffsetTrackH - dynamic->MoverParameters->OffsetTrackH ); + } + else { + relativeoffset = std::abs( MoverParameters->OffsetTrackH + dynamic->MoverParameters->OffsetTrackH ); + } + if( relativeoffset + relativeoffset > MoverParameters->Dim.W + dynamic->MoverParameters->Dim.W ) { + // odległość większa od połowy sumy szerokości - kolizji nie będzie + continue; + } + // jeśli zahaczenie jest niewielkie, a jest miejsce na poboczu, to zjechać na pobocze + } + foundobject = dynamic; // potencjalna kolizja + distance = objectposition; // odleglość pomiędzy aktywnymi osiami pojazdów + } + + Distance += distance; // doliczenie odległości przeszkody albo długości odcinka do przeskanowanej odległości + return foundobject; } int TDynamicObject::DettachStatus(int dir) @@ -1384,8 +1292,9 @@ int TDynamicObject::DettachStatus(int dir) // rzeczywistych od strony (dir): // 0=przód,1=tył // Ra: dziwne, że ta funkcja nie jest używana - if (!MoverParameters->Couplers[dir].CouplingFlag) + if( MoverParameters->Couplers[ dir ].CouplingFlag == coupling::faux ) { return 0; // jeśli nic nie podłączone, to jest OK + } return (MoverParameters->DettachStatus(dir)); // czy jest w odpowiedniej odległości? } @@ -1409,251 +1318,375 @@ int TDynamicObject::Dettach(int dir) d = d->Next(); // i w drugą stronę } } - if (MoverParameters->Couplers[dir].CouplingFlag) // odczepianie, o ile coś podłączone - MoverParameters->Dettach(dir); - return MoverParameters->Couplers[dir] - .CouplingFlag; // sprzęg po rozłączaniu (czego się nie da odpiąć + if( MoverParameters->Couplers[ dir ].CouplingFlag ) { + // odczepianie, o ile coś podłączone + MoverParameters->Dettach( dir ); + } + // sprzęg po rozłączaniu (czego się nie da odpiąć + return MoverParameters->Couplers[dir].CouplingFlag; } -void TDynamicObject::CouplersDettach(double MinDist, int MyScanDir) -{ // funkcja rozłączajaca podłączone sprzęgi, - // jeśli odległość przekracza (MinDist) +void +TDynamicObject::couple( int const Side ) { + + if( MoverParameters->Couplers[ Side ].Connected == nullptr ) { return; } + + if( MoverParameters->Couplers[ Side ].CouplingFlag == coupling::faux ) { + // najpierw hak + if( ( MoverParameters->Couplers[ Side ].Connected->Couplers[ Side ].AllowedFlag + & MoverParameters->Couplers[ Side ].AllowedFlag + & coupling::coupler ) == coupling::coupler ) { + if( MoverParameters->Attach( + Side, 2, + MoverParameters->Couplers[ Side ].Connected, + coupling::coupler ) ) { + // tmp->MoverParameters->Couplers[CouplNr].Render=true; //podłączony sprzęg będzie widoczny + m_couplersounds[ Side ].dsbCouplerAttach.play(); + // one coupling type per key press + return; + } + else { + WriteLog( "Mechanical coupling failed." ); + } + } + } + if( false == TestFlag( MoverParameters->Couplers[ Side ].CouplingFlag, coupling::brakehose ) ) { + // pneumatyka + if( ( MoverParameters->Couplers[ Side ].Connected->Couplers[ Side ].AllowedFlag + & MoverParameters->Couplers[ Side ].AllowedFlag + & coupling::brakehose ) == coupling::brakehose ) { + if( MoverParameters->Attach( + Side, 2, + MoverParameters->Couplers[ Side ].Connected, + ( MoverParameters->Couplers[ Side ].CouplingFlag | coupling::brakehose ) ) ) { + // TODO: dedicated sound for connecting cable-type connections + m_couplersounds[ Side ].dsbCouplerDetach.play(); + + SetPneumatic( Side != 0, true ); + if( Side == side::front ) { + PrevConnected->SetPneumatic( Side != 0, true ); + } + else { + NextConnected->SetPneumatic( Side != 0, true ); + } + // one coupling type per key press + return; + } + } + } + if( false == TestFlag( MoverParameters->Couplers[ Side ].CouplingFlag, coupling::mainhose ) ) { + // zasilajacy + if( ( MoverParameters->Couplers[ Side ].Connected->Couplers[ Side ].AllowedFlag + & MoverParameters->Couplers[ Side ].AllowedFlag + & coupling::mainhose ) == coupling::mainhose ) { + if( MoverParameters->Attach( + Side, 2, + MoverParameters->Couplers[ Side ].Connected, + ( MoverParameters->Couplers[ Side ].CouplingFlag | coupling::mainhose ) ) ) { + // TODO: dedicated sound for connecting cable-type connections + m_couplersounds[ Side ].dsbCouplerDetach.play(); + + SetPneumatic( Side != 0, false ); + if( Side == side::front ) { + PrevConnected->SetPneumatic( Side != 0, false ); + } + else { + NextConnected->SetPneumatic( Side != 0, false ); + } + // one coupling type per key press + return; + } + } + } + if( false == TestFlag( MoverParameters->Couplers[ Side ].CouplingFlag, coupling::control ) ) { + // ukrotnionko + if( ( MoverParameters->Couplers[ Side ].Connected->Couplers[ Side ].AllowedFlag + & MoverParameters->Couplers[ Side ].AllowedFlag + & coupling::control ) == coupling::control ) { + if( MoverParameters->Attach( + Side, 2, + MoverParameters->Couplers[ Side ].Connected, + ( MoverParameters->Couplers[ Side ].CouplingFlag | coupling::control ) ) ) { + // TODO: dedicated sound for connecting cable-type connections + m_couplersounds[ Side ].dsbCouplerAttach.play(); + // one coupling type per key press + return; + } + } + } + if( false == TestFlag( MoverParameters->Couplers[ Side ].CouplingFlag, coupling::gangway ) ) { + // mostek + if( ( MoverParameters->Couplers[ Side ].Connected->Couplers[ Side ].AllowedFlag + & MoverParameters->Couplers[ Side ].AllowedFlag + & coupling::gangway ) == coupling::gangway ) { + if( MoverParameters->Attach( + Side, 2, + MoverParameters->Couplers[ Side ].Connected, + ( MoverParameters->Couplers[ Side ].CouplingFlag | coupling::gangway ) ) ) { + // TODO: dedicated gangway sound + m_couplersounds[ Side ].dsbCouplerAttach.play(); + // one coupling type per key press + return; + } + } + } + if( false == TestFlag( MoverParameters->Couplers[ Side ].CouplingFlag, coupling::heating ) ) { + // heating + if( ( MoverParameters->Couplers[ Side ].Connected->Couplers[ Side ].AllowedFlag + & MoverParameters->Couplers[ Side ].AllowedFlag + & coupling::heating ) == coupling::heating ) { + if( MoverParameters->Attach( + Side, 2, + MoverParameters->Couplers[ Side ].Connected, + ( MoverParameters->Couplers[ Side ].CouplingFlag | coupling::heating ) ) ) { + + // TODO: dedicated 'click' sound for connecting cable-type connections + m_couplersounds[ Side ].dsbCouplerDetach.play(); + // one coupling type per key press + return; + } + } + } + +} + +int +TDynamicObject::uncouple( int const Side ) { + + if( ( DettachStatus( Side ) >= 0 ) + || ( true == TestFlag( MoverParameters->Couplers[ Side ].CouplingFlag, coupling::permanent ) ) ) { + // can't uncouple, return existing coupling state + return MoverParameters->Couplers[ Side ].CouplingFlag; + } + // jeżeli sprzęg niezablokowany, jest co odczepić i się da + auto const couplingflag { Dettach( Side ) }; + if( couplingflag == coupling::faux ) { + // dźwięk odczepiania + m_couplersounds[ Side ].dsbCouplerAttach.play(); + m_couplersounds[ Side ].dsbCouplerDetach.play(); + } + return couplingflag; +} + +void TDynamicObject::CouplersDettach(double MinDist, int MyScanDir) { + // funkcja rozłączajaca podłączone sprzęgi, jeśli odległość przekracza (MinDist) // MinDist - dystans minimalny, dla ktorego mozna rozłączać - if (MyScanDir > 0) - { - if (PrevConnected) // pojazd od strony sprzęgu 0 - { - if (MoverParameters->Couplers[0].CoupleDist > - MinDist) // sprzęgi wirtualne zawsze przekraczają - { - if ((PrevConnectedNo ? PrevConnected->NextConnected : - PrevConnected->PrevConnected) == this) - { // Ra: nie rozłączamy znalezionego, jeżeli nie do nas - // podłączony (może jechać w - // innym kierunku) - PrevConnected->MoverParameters->Couplers[PrevConnectedNo].Connected = NULL; - if (PrevConnectedNo == 0) - { - PrevConnected->PrevConnectedNo = 2; // sprzęg 0 nie podłączony - PrevConnected->PrevConnected = NULL; - } - else if (PrevConnectedNo == 1) - { - PrevConnected->NextConnectedNo = 2; // sprzęg 1 nie podłączony - PrevConnected->NextConnected = NULL; - } + if (MyScanDir > 0) { + // pojazd od strony sprzęgu 0 + if( ( PrevConnected != nullptr ) + && ( MoverParameters->Couplers[ side::front ].CoupleDist > MinDist ) ) { + // sprzęgi wirtualne zawsze przekraczają + if( ( PrevConnectedNo == side::front ? + PrevConnected->PrevConnected : + PrevConnected->NextConnected ) + == this ) { + // Ra: nie rozłączamy znalezionego, jeżeli nie do nas podłączony + // (może jechać w innym kierunku) + PrevConnected->MoverParameters->Couplers[PrevConnectedNo].Connected = nullptr; + if( PrevConnectedNo == side::front ) { + // sprzęg 0 nie podłączony + PrevConnected->PrevConnectedNo = 2; + PrevConnected->PrevConnected = nullptr; + } + else if( PrevConnectedNo == side::rear ) { + // sprzęg 1 nie podłączony + PrevConnected->NextConnectedNo = 2; + PrevConnected->NextConnected = nullptr; } - // za to zawsze odłączamy siebie - PrevConnected = NULL; - PrevConnectedNo = 2; // sprzęg 0 nie podłączony - MoverParameters->Couplers[0].Connected = NULL; } + // za to zawsze odłączamy siebie + PrevConnected = nullptr; + PrevConnectedNo = 2; // sprzęg 0 nie podłączony + MoverParameters->Couplers[ side::front ].Connected = nullptr; } } - else - { - if (NextConnected) // pojazd od strony sprzęgu 1 - { - if (MoverParameters->Couplers[1].CoupleDist > - MinDist) // sprzęgi wirtualne zawsze przekraczają - { - if ((NextConnectedNo ? NextConnected->NextConnected : - NextConnected->PrevConnected) == this) - { // Ra: nie rozłączamy znalezionego, jeżeli nie do nas - // podłączony (może jechać w - // innym kierunku) - NextConnected->MoverParameters->Couplers[NextConnectedNo].Connected = NULL; - if (NextConnectedNo == 0) - { - NextConnected->PrevConnectedNo = 2; // sprzęg 0 nie podłączony - NextConnected->PrevConnected = NULL; - } - else if (NextConnectedNo == 1) - { - NextConnected->NextConnectedNo = 2; // sprzęg 1 nie podłączony - NextConnected->NextConnected = NULL; - } + else { + // pojazd od strony sprzęgu 1 + if( ( NextConnected != nullptr ) + && ( MoverParameters->Couplers[ side::rear ].CoupleDist > MinDist ) ) { + // sprzęgi wirtualne zawsze przekraczają + if( ( NextConnectedNo == side::front ? + NextConnected->PrevConnected : + NextConnected->NextConnected ) + == this) { + // Ra: nie rozłączamy znalezionego, jeżeli nie do nas podłączony + // (może jechać w innym kierunku) + NextConnected->MoverParameters->Couplers[ NextConnectedNo ].Connected = nullptr; + if( NextConnectedNo == side::front ) { + // sprzęg 0 nie podłączony + NextConnected->PrevConnectedNo = 2; + NextConnected->PrevConnected = nullptr; + } + else if( NextConnectedNo == side::rear ) { + // sprzęg 1 nie podłączony + NextConnected->NextConnectedNo = 2; + NextConnected->NextConnected = nullptr; } - NextConnected = NULL; - NextConnectedNo = 2; // sprzęg 1 nie podłączony - MoverParameters->Couplers[1].Connected = NULL; } + // za to zawsze odłączamy siebie + NextConnected = nullptr; + NextConnectedNo = 2; // sprzęg 1 nie podłączony + MoverParameters->Couplers[1].Connected = nullptr; } } } -void TDynamicObject::ABuScanObjects(int ScanDir, double ScanDist) +void TDynamicObject::ABuScanObjects( int Direction, double Distance ) { // skanowanie toru w poszukiwaniu kolidujących pojazdów // ScanDir - określa kierunek poszukiwania zależnie od zwrotu prędkości // pojazdu // ScanDir=1 - od strony Coupler0, ScanDir=-1 - od strony Coupler1 - int MyScanDir = ScanDir; // zapamiętanie kierunku poszukiwań na torze - // początkowym, względem sprzęgów - TTrackFollower *FirstAxle = (MyScanDir > 0 ? &Axle0 : &Axle1); // można by to trzymać w trainset - TTrack *Track = FirstAxle->GetTrack(); // tor na którym "stoi" skrajny wózek - // (może być inny niż tor pojazdu) - if (FirstAxle->GetDirection() < 0) // czy oś jest ustawiona w stronę Point1? - ScanDir = -ScanDir; // jeśli tak, to kierunek szukania będzie przeciwny - // (teraz względem - // toru) - BYTE MyCouplFound; // numer sprzęgu do podłączenia w obiekcie szukajacym - MyCouplFound = (MyScanDir < 0) ? 1 : 0; - BYTE CouplFound; // numer sprzęgu w znalezionym obiekcie (znaleziony wypełni) - TDynamicObject *FoundedObj; // znaleziony obiekt - double ActDist = 0; // przeskanowana odleglość; odległość do zawalidrogi - FoundedObj = ABuFindObject(Track, ScanDir, CouplFound, - ActDist); // zaczynamy szukać na tym samym torze + auto const initialdirection = Direction; // zapamiętanie kierunku poszukiwań na torze początkowym, względem sprzęgów - /* - if (FoundedObj) //jak coś znajdzie, to śledzimy - {//powtórzenie wyszukiwania tylko do zastawiania pułepek podczas testów - if (ABuGetDirection()<0) ScanDir=ScanDir; //ustalenie kierunku względem toru - FoundedObj=ABuFindObject(Track,this,ScanDir,CouplFound); - } - */ + TTrack const *track = RaTrackGet(); + if( RaDirectionGet() < 0 ) { + // czy oś jest ustawiona w stronę Point1? + Direction = -Direction; + } - if (DebugModeFlag) - if (FoundedObj) // kod służący do logowania błędów - if (CouplFound == 0) - { - if (FoundedObj->PrevConnected) - if (FoundedObj->PrevConnected != this) // odświeżenie tego samego się nie liczy - WriteLog("0! Coupler warning on " + asName + ":" + - to_string(MyCouplFound) + " - " + FoundedObj->asName + - ":0 connected to " + FoundedObj->PrevConnected->asName + ":" + - to_string(FoundedObj->PrevConnectedNo)); - } - else - { - if (FoundedObj->NextConnected) - if (FoundedObj->NextConnected != this) // odświeżenie tego samego się nie liczy - WriteLog("0! Coupler warning on " + asName + ":" + - to_string(MyCouplFound) + " - " + FoundedObj->asName + - ":1 connected to " + FoundedObj->NextConnected->asName + ":" + - to_string(FoundedObj->NextConnectedNo)); - } + // (teraz względem toru) + int const mycoupler = ( initialdirection < 0 ? 1 : 0 ); // numer sprzęgu do podłączenia w obiekcie szukajacym + int foundcoupler { -1 }; // numer sprzęgu w znalezionym obiekcie (znaleziony wypełni) + double distance = 0; // przeskanowana odleglość; odległość do zawalidrogi + TDynamicObject *foundobject = ABuFindObject( foundcoupler, distance, track, Direction, mycoupler ); // zaczynamy szukać na tym samym torze - if (FoundedObj == NULL) // jeśli nie ma na tym samym, szukamy po okolicy - { // szukanie najblizszego toru z jakims obiektem + if( foundobject == nullptr ) { + // jeśli nie ma na tym samym, szukamy po okolicy szukanie najblizszego toru z jakims obiektem // praktycznie przeklejone z TraceRoute()... - // double CurrDist=0; //aktualna dlugosc toru - if (ScanDir >= 0) // uwzględniamy kawalek przeanalizowanego wcześniej toru - ActDist = Track->Length() - FirstAxle->GetTranslation(); // odległość osi od Point2 toru + if (Direction >= 0) // uwzględniamy kawalek przeanalizowanego wcześniej toru + distance = track->Length() - RaTranslationGet(); // odległość osi od Point2 toru else - ActDist = FirstAxle->GetTranslation(); // odległość osi od Point1 toru - while (ActDist < ScanDist) - { - // ActDist+=CurrDist; //odległość już przeanalizowana - if (ScanDir > 0) // w kierunku Point2 toru - { - if (Track ? Track->iNextDirection : - false) // jeśli następny tor jest podpięty od Point2 - ScanDir = -ScanDir; // to zmieniamy kierunek szukania na tym torze - Track = Track->CurrentNext(); // potem dopiero zmieniamy wskaźnik + distance = RaTranslationGet(); // odległość osi od Point1 toru + + while (distance < Distance) { + if (Direction > 0) { + // w kierunku Point2 toru + if( track ? + track->iNextDirection : + false ) { + // jeśli następny tor jest podpięty od Point2 + Direction = -Direction; // to zmieniamy kierunek szukania na tym torze + } + track = track->CurrentNext(); // potem dopiero zmieniamy wskaźnik } - else // w kierunku Point1 - { - if (Track ? !Track->iPrevDirection : - true) // jeśli poprzedni tor nie jest podpięty od Point2 - ScanDir = -ScanDir; // to zmieniamy kierunek szukania na tym torze - Track = Track->CurrentPrev(); // potem dopiero zmieniamy wskaźnik + else { + // w kierunku Point1 + if( track ? + !track->iPrevDirection : + true ) { + // jeśli poprzedni tor nie jest podpięty od Point2 + Direction = -Direction; // to zmieniamy kierunek szukania na tym torze + } + track = track->CurrentPrev(); // potem dopiero zmieniamy wskaźnik } - if (Track) - { // jesli jest kolejny odcinek toru - // CurrDist=Track->Length(); //doliczenie tego toru do przejrzanego - // dystandu - FoundedObj = ABuFindObject(Track, ScanDir, CouplFound, - ActDist); // przejrzenie pojazdów tego toru - if (FoundedObj) - { - // ActDist=ScanDist; //wyjście z pętli poszukiwania + if (track) { + // jesli jest kolejny odcinek toru + foundobject = ABuFindObject(foundcoupler, distance, track, Direction, mycoupler); // przejrzenie pojazdów tego toru + if (foundobject) { break; } } - else // jeśli toru nie ma, to wychodzimy - { - ActDist = ScanDist + 1.0; // koniec przeglądania torów + else { + // jeśli toru nie ma, to wychodzimy + distance = Distance + 1.0; // koniec przeglądania torów break; } } } // Koniec szukania najbliższego toru z jakimś obiektem. + // teraz odczepianie i jeśli coś się znalazło, doczepianie. - if (MyScanDir > 0 ? PrevConnected : NextConnected) - if ((MyScanDir > 0 ? PrevConnected : NextConnected) != FoundedObj) - CouplersDettach(1.0, MyScanDir); // odłączamy, jeśli dalej niż metr - // i łączenie sprzęgiem wirtualnym - if (FoundedObj) - { // siebie można bezpiecznie podłączyć jednostronnie do - // znalezionego - MoverParameters->Attach(MyCouplFound, CouplFound, FoundedObj->MoverParameters, - ctrain_virtual); - // MoverParameters->Couplers[MyCouplFound].Render=false; //wirtualnego nie - // renderujemy - if (MyCouplFound == 0) - { - PrevConnected = FoundedObj; // pojazd od strony sprzęgu 0 - PrevConnectedNo = CouplFound; - } - else - { - NextConnected = FoundedObj; // pojazd od strony sprzęgu 1 - NextConnectedNo = CouplFound; - } - if (FoundedObj->MoverParameters->Couplers[CouplFound].CouplingFlag == ctrain_virtual) - { // Ra: wpinamy się wirtualnym tylko jeśli znaleziony - // ma wirtualny sprzęg - FoundedObj->MoverParameters->Attach(CouplFound, MyCouplFound, this->MoverParameters, - ctrain_virtual); - if (CouplFound == 0) // jeśli widoczny sprzęg 0 znalezionego - { - if (DebugModeFlag) - if (FoundedObj->PrevConnected) - if (FoundedObj->PrevConnected != this) - WriteLog("1! Coupler warning on " + asName + ":" + - to_string(MyCouplFound) + " - " + FoundedObj->asName + - ":0 connected to " + FoundedObj->PrevConnected->asName + ":" + - to_string(FoundedObj->PrevConnectedNo)); - FoundedObj->PrevConnected = this; - FoundedObj->PrevConnectedNo = MyCouplFound; - } - else // jeśli widoczny sprzęg 1 znalezionego - { - if (DebugModeFlag) - if (FoundedObj->NextConnected) - if (FoundedObj->NextConnected != this) - WriteLog("1! Coupler warning on " + asName + ":" + - to_string(MyCouplFound) + " - " + FoundedObj->asName + - ":1 connected to " + FoundedObj->NextConnected->asName + ":" + - to_string(FoundedObj->NextConnectedNo)); - FoundedObj->NextConnected = this; - FoundedObj->NextConnectedNo = MyCouplFound; - } - } - // Ra: jeśli dwa samochody się mijają na odcinku przed zawrotką, to - // odległość między nimi - // nie może być liczona w linii prostej! - fTrackBlock = MoverParameters->Couplers[MyCouplFound] - .CoupleDist; // odległość do najbliższego pojazdu w linii prostej - if (Track->iCategoryFlag > 1) // jeśli samochód - if (ActDist > MoverParameters->Dim.L + - FoundedObj->MoverParameters->Dim - .L) // przeskanowana odległość większa od długości pojazdów - // else if (ActDistasName); + auto connectedobject = ( + initialdirection > 0 ? + PrevConnected : + NextConnected ); + if( ( connectedobject != nullptr ) + && ( connectedobject != foundobject ) ) { + // odłączamy, jeśli dalej niż metr i łączenie sprzęgiem wirtualnym + CouplersDettach( 1.0, initialdirection ); } - else // nic nie znalezione, to nie ma przeszkód + + if (foundobject) { + // siebie można bezpiecznie podłączyć jednostronnie do znalezionego + MoverParameters->Attach( mycoupler, foundcoupler, foundobject->MoverParameters, coupling::faux ); + // MoverParameters->Couplers[MyCouplFound].Render=false; //wirtualnego nie renderujemy + if( mycoupler == side::front ) { + PrevConnected = foundobject; // pojazd od strony sprzęgu 0 + PrevConnectedNo = foundcoupler; + } + else { + NextConnected = foundobject; // pojazd od strony sprzęgu 1 + NextConnectedNo = foundcoupler; + } + + if( foundobject->MoverParameters->Couplers[ foundcoupler ].CouplingFlag == coupling::faux ) { + // Ra: wpinamy się wirtualnym tylko jeśli znaleziony ma wirtualny sprzęg + if( ( foundcoupler == side::front ? + foundobject->PrevConnected : + foundobject->NextConnected ) + != this ) { + // but first break existing connection of the target, + // otherwise we risk leaving the target's connected vehicle with active one-side connection + foundobject->CouplersDettach( + 1.0, + ( foundcoupler == side::front ? + 1 : + -1 ) ); + } + foundobject->MoverParameters->Attach( foundcoupler, mycoupler, this->MoverParameters, coupling::faux ); + + if( foundcoupler == side::front ) { + // jeśli widoczny sprzęg 0 znalezionego + if( ( DebugModeFlag ) + && ( foundobject->PrevConnected ) + && ( foundobject->PrevConnected != this ) ) { + WriteLog( "ScanObjects(): formed virtual link between \"" + asName + "\" (coupler " + to_string( mycoupler ) + ") and \"" + foundobject->asName + "\" (coupler " + to_string( foundcoupler ) + ")" ); + } + foundobject->PrevConnected = this; + foundobject->PrevConnectedNo = mycoupler; + } + else { + // jeśli widoczny sprzęg 1 znalezionego + if( ( DebugModeFlag ) + && ( foundobject->NextConnected ) + && ( foundobject->NextConnected != this ) ) { + WriteLog( "ScanObjects(): formed virtual link between \"" + asName + "\" (coupler " + to_string( mycoupler ) + ") and \"" + foundobject->asName + "\" (coupler " + to_string( foundcoupler ) + ")" ); + } + foundobject->NextConnected = this; + foundobject->NextConnectedNo = mycoupler; + } + } + + // NOTE: the distance we get is approximated as it's measured between active axles, not vehicle ends + fTrackBlock = distance; + if( distance < 100.0 ) { + // at short distances start to calculate range between couplers directly + // odległość do najbliższego pojazdu w linii prostej + fTrackBlock = MoverParameters->Couplers[ mycoupler ].CoupleDist; + } + if( ( false == TestFlag( track->iCategoryFlag, 1 ) ) + && ( distance > 50.0 ) ) { + // Ra: jeśli dwa samochody się mijają na odcinku przed zawrotką, to odległość między nimi nie może być liczona w linii prostej! + // NOTE: the distance is approximated, and additionally less accurate for cars heading in opposite direction + fTrackBlock = distance - ( 0.5 * ( MoverParameters->Dim.L + foundobject->MoverParameters->Dim.L ) ); + } + } + else { + // nic nie znalezione, to nie ma przeszkód fTrackBlock = 10000.0; + } + +#ifdef EU07_DEBUG_COLLISIONS + // debug collider scans + if( ( PrevConnected != nullptr ) + && ( PrevConnected == NextConnected ) ) { + ErrorLog( "Bad coupling: " + asName + " has the same vehicle detected attached to both couplers" ); + } +#endif } //----------ABu: koniec skanowania pojazdow -TDynamicObject::TDynamicObject() -{ - modelShake = vector3(0, 0, 0); +TDynamicObject::TDynamicObject() { + modelShake = Math3D::vector3(0, 0, 0); fTrackBlock = 10000.0; // brak przeszkody na drodze btnOn = false; vUp = vWorldUp; @@ -1666,20 +1699,11 @@ TDynamicObject::TDynamicObject() // McZapkie-270202 Controller = AIdriver; bDisplayCab = false; // 030303 - bBrakeAcc = false; NextConnected = PrevConnected = NULL; NextConnectedNo = PrevConnectedNo = 2; // ABu: Numery sprzegow. 2=nie podłączony - CouplCounter = 50; // będzie sprawdzać na początku - asName = ""; bEnabled = true; MyTrack = NULL; // McZapkie-260202 - dRailLength = 25.0; - for (int i = 0; i < MaxAxles; i++) - dRailPosition[i] = 0.0; - for (int i = 0; i < MaxAxles; i++) - dWheelsPosition[i] = 0.0; // będzie wczytane z MMD - iAxles = 0; dWheelAngle[0] = 0.0; dWheelAngle[1] = 0.0; dWheelAngle[2] = 0.0; @@ -1688,19 +1712,8 @@ TDynamicObject::TDynamicObject() NoVoltTime = 0; dDoorMoveL = 0.0; dDoorMoveR = 0.0; - // for (int i=0;i<8;i++) - //{ - // DoorSpeedFactor[i]=random(150); - // DoorSpeedFactor[i]=(DoorSpeedFactor[i]+100)/100; - //} mdModel = NULL; mdKabina = NULL; - ReplacableSkinID[0] = 0; - ReplacableSkinID[1] = 0; - ReplacableSkinID[2] = 0; - ReplacableSkinID[3] = 0; - ReplacableSkinID[4] = 0; - iAlpha = 0x30300030; // tak gdy tekstury wymienne nie mają przezroczystości // smWiazary[0]=smWiazary[1]=NULL; smWahacze[0] = smWahacze[1] = smWahacze[2] = smWahacze[3] = NULL; fWahaczeAmp = 0; @@ -1708,41 +1721,23 @@ TDynamicObject::TDynamicObject() smLoadMode = NULL; mdLoad = NULL; mdLowPolyInt = NULL; - mdPrzedsionek = NULL; //smMechanik0 = smMechanik1 = NULL; smBuforLewy[0] = smBuforLewy[1] = NULL; smBuforPrawy[0] = smBuforPrawy[1] = NULL; - enginevolume = 0; smBogie[0] = smBogie[1] = NULL; - bogieRot[0] = bogieRot[1] = vector3(0, 0, 0); - modelRot = vector3(0, 0, 0); - eng_vol_act = 0.8; - eng_dfrq = 0; - eng_frq_act = 1; - eng_turbo = 0; + bogieRot[0] = bogieRot[1] = Math3D::vector3(0, 0, 0); + modelRot = Math3D::vector3(0, 0, 0); cp1 = cp2 = sp1 = sp2 = 0; iDirection = 1; // stoi w kierunku tradycyjnym (0, gdy jest odwrócony) iAxleFirst = 0; // numer pierwszej osi w kierunku ruchu (przełączenie // następuje, gdy osie sa na // tym samym torze) - iInventory = 0; // flagi bitowe posiadanych submodeli (zaktualizuje się po - // wczytaniu MMD) RaLightsSet(0, 0); // początkowe zerowanie stanu świateł // Ra: domyślne ilości animacji dla zgodności wstecz (gdy brak ilości podanych // w MMD) // ustawienie liczby modeli animowanych podczas konstruowania obiektu a nie na 0 // prowadzi prosto do wysypów jeśli źle zdefiniowane mmd - iAnimType[ANIM_WHEELS] = 0; // 0-osie (8) - iAnimType[ANIM_DOORS] = 0; // 1-drzwi (8) - iAnimType[ANIM_LEVERS] = 0; // 2-wahacze (4) - np. nogi konia - iAnimType[ANIM_BUFFERS] = 0; // 3-zderzaki (4) - iAnimType[ANIM_BOOGIES] = 0; // 4-wózki (2) - iAnimType[ANIM_PANTS] = 0; // 5-pantografy (2) - iAnimType[ANIM_STEAMS] = 0; // 6-tłoki (napęd parowozu) iAnimations = 0; // na razie nie ma żadnego -/* - pAnimations = NULL; -*/ pAnimated = NULL; fShade = 0.0; // standardowe oświetlenie na starcie iHornWarning = 1; // numer syreny do użycia po otrzymaniu sygnału do jazdy @@ -1752,7 +1747,6 @@ TDynamicObject::TDynamicObject() smBrakeSet = NULL; // nastawa hamulca (wajcha) smLoadSet = NULL; // nastawa ładunku (wajcha) smWiper = NULL; // wycieraczka (poniekąd też wajcha) - fScanDist = 300.0; // odległość skanowania, zwiększana w trybie łączenia ctOwner = NULL; // na początek niczyj iOverheadMask = 0; // maska przydzielana przez AI pojazdom posiadającym // pantograf, aby wymuszały @@ -1763,30 +1757,10 @@ TDynamicObject::TDynamicObject() fAdjustment = 0.0; // korekcja odległości pomiędzy wózkami (np. na łukach) } -TDynamicObject::~TDynamicObject() -{ // McZapkie-250302 - zamykanie logowania - // parametrow fizycznych - SafeDelete(Mechanik); - SafeDelete(MoverParameters); - // Ra: wyłączanie dźwięków powinno być dodane w ich destruktorach, ale się - // sypie - /* to też się sypie - for (int i=0;iiLights; // wskaźnik na stan własnych świateł - // (zmienimy dla rozrządczych EZT) // McZapkie: TypeName musi byc nazwą CHK/MMD pojazdu if (!MoverParameters->LoadFIZ(asBaseDir)) { // jak wczytanie CHK się nie uda, to błąd - if (ConversionError == -8) - ErrorLog("Missed file: " + BaseDir + "\\" + Type_Name + ".fiz"); - Error("Cannot load dynamic object " + asName + " from:\r\n" + BaseDir + "\\" + Type_Name + - ".fiz\r\nError " + to_string(ConversionError) + " in line " + to_string(LineCount)); + if (ConversionError == 666) + ErrorLog( "Bad vehicle: failed do locate definition file \"" + BaseDir + "/" + Type_Name + ".fiz" + "\"" ); + else { + ErrorLog( "Bad vehicle: failed to load definition from file \"" + BaseDir + "/" + Type_Name + ".fiz\" (error " + to_string( ConversionError ) + ")" ); + } return 0.0; // zerowa długość to brak pojazdu } + // load the cargo now that we know whether the vehicle will allow it + MoverParameters->AssignLoad( LoadType, Load ); + bool driveractive = (fVel != 0.0); // jeśli prędkość niezerowa, to aktywujemy ruch if (!MoverParameters->CheckLocomotiveParameters( driveractive, (fVel > 0 ? 1 : -1) * Cab * (iDirection ? 1 : -1))) // jak jedzie lub obsadzony to gotowy do drogi { - Error("Parameters mismatch: dynamic object " + asName + " from\n" + BaseDir + "\\" + - Type_Name); + Error("Parameters mismatch: dynamic object " + asName + " from \"" + BaseDir + "/" + Type_Name + "\"" ); return 0.0; // zerowa długość to brak pojazdu } // ustawienie pozycji hamulca - MoverParameters->LocalBrakePos = 0; + MoverParameters->LocalBrakePosA = 0.0; if (driveractive) { if (Cab == 0) @@ -1888,14 +1855,13 @@ TDynamicObject::Init(std::string Name, // nazwa pojazdu, np. "EU07-424" // dodatkowe parametry yB MoreParams += "."; // wykonuje o jedną iterację za mało, więc trzeba mu dodać // kropkę na koniec - int kropka = MoreParams.find("."); // znajdź kropke + size_t kropka = MoreParams.find("."); // znajdź kropke std::string ActPar; // na parametry while (kropka != std::string::npos) // jesli sa kropki jeszcze { - int dlugosc = MoreParams.length(); + size_t dlugosc = MoreParams.length(); ActPar = ToUpper(MoreParams.substr(0, kropka)); // pierwszy parametr; - MoreParams = MoreParams.substr(kropka + 1, dlugosc - kropka); // reszta do dalszej - // obrobki + MoreParams = MoreParams.substr(kropka + 1, dlugosc - kropka); // reszta do dalszej obrobki kropka = MoreParams.find("."); if (ActPar.substr(0, 1) == "B") // jesli hamulce @@ -1921,52 +1887,45 @@ TDynamicObject::Init(std::string Name, // nazwa pojazdu, np. "EU07-424" // wylaczanie hamulca if (ActPar.find("<>") != std::string::npos) // wylaczanie na probe hamowania naglego { - MoverParameters->BrakeStatus |= 128; // wylacz + MoverParameters->Hamulec->SetBrakeStatus( MoverParameters->Hamulec->GetBrakeStatus() | b_dmg ); // wylacz } if (ActPar.find('0') != std::string::npos) // wylaczanie na sztywno { - MoverParameters->BrakeStatus |= 128; // wylacz MoverParameters->Hamulec->ForceEmptiness(); - MoverParameters->BrakeReleaser(1); // odluznij automatycznie + MoverParameters->Hamulec->SetBrakeStatus( MoverParameters->Hamulec->GetBrakeStatus() | b_dmg ); // wylacz } if (ActPar.find('E') != std::string::npos) // oprozniony { MoverParameters->Hamulec->ForceEmptiness(); - MoverParameters->BrakeReleaser(1); // odluznij automatycznie MoverParameters->Pipe->CreatePress(0); MoverParameters->Pipe2->CreatePress(0); } if (ActPar.find('Q') != std::string::npos) // oprozniony { - // MoverParameters->Hamulec->ForceEmptiness(); //TODO: sprawdzic, - // dlaczego - // pojawia sie blad przy uzyciu tej linijki w lokomotywie - MoverParameters->BrakeReleaser(1); // odluznij automatycznie + MoverParameters->Hamulec->ForceEmptiness(); MoverParameters->Pipe->CreatePress(0.0); MoverParameters->PipePress = 0.0; MoverParameters->Pipe2->CreatePress(0.0); MoverParameters->ScndPipePress = 0.0; - MoverParameters->PantVolume = 1; - MoverParameters->PantPress = 0; - MoverParameters->CompressedVolume = 0; + MoverParameters->PantVolume = 0.1; + MoverParameters->PantPress = 0.0; + MoverParameters->CompressedVolume = 0.0; } if (ActPar.find('1') != std::string::npos) // wylaczanie 10% { if (Random(10) < 1) // losowanie 1/10 { - MoverParameters->BrakeStatus |= 128; // wylacz MoverParameters->Hamulec->ForceEmptiness(); - MoverParameters->BrakeReleaser(1); // odluznij automatycznie + MoverParameters->Hamulec->SetBrakeStatus( MoverParameters->Hamulec->GetBrakeStatus() | b_dmg ); // wylacz } } if (ActPar.find('X') != std::string::npos) // agonalny wylaczanie 20%, usrednienie przekladni { if (Random(100) < 20) // losowanie 20/100 { - MoverParameters->BrakeStatus |= 128; // wylacz MoverParameters->Hamulec->ForceEmptiness(); - MoverParameters->BrakeReleaser(1); // odluznij automatycznie + MoverParameters->Hamulec->SetBrakeStatus( MoverParameters->Hamulec->GetBrakeStatus() | b_dmg ); // wylacz } if (MoverParameters->BrakeCylMult[2] * MoverParameters->BrakeCylMult[1] > 0.01) // jesli jest nastawiacz mechaniczny PL @@ -2014,6 +1973,89 @@ TDynamicObject::Init(std::string Name, // nazwa pojazdu, np. "EU07-424" { } } // koniec hamulce + else if( ( ActPar.size() >= 3 ) + && ( ActPar[ 0 ] == 'W' ) ) { + // wheel + ActPar.erase( 0, 1 ); + + auto fixedflatsize { 0 }; + auto randomflatsize { 0 }; + auto flatchance { 100 }; + + while( false == ActPar.empty() ) { + // TODO: convert this whole copy and paste mess to something more elegant one day + switch( ActPar[ 0 ] ) { + case 'F': { + // fixed flat size + auto const indexstart { 1 }; + auto const indexend { ActPar.find_first_not_of( "1234567890", indexstart ) }; + fixedflatsize = std::atoi( ActPar.substr( indexstart, indexend ).c_str() ); + ActPar.erase( 0, indexend ); + break; + } + case 'R': { + // random flat size + auto const indexstart { 1 }; + auto const indexend { ActPar.find_first_not_of( "1234567890", indexstart ) }; + randomflatsize = std::atoi( ActPar.substr( indexstart, indexend ).c_str() ); + ActPar.erase( 0, indexend ); + break; + } + case 'P': { + // random flat probability + auto const indexstart { 1 }; + auto const indexend { ActPar.find_first_not_of( "1234567890", indexstart ) }; + flatchance = std::atoi( ActPar.substr( indexstart, indexend ).c_str() ); + ActPar.erase( 0, indexend ); + break; + } + case 'H': { + // truck hunting + auto const indexstart { 1 }; + auto const indexend { ActPar.find_first_not_of( "1234567890", indexstart ) }; + auto const huntingchance { std::atoi( ActPar.substr( indexstart, indexend ).c_str() ) }; + MoverParameters->TruckHunting = ( Random( 0, 100 ) < huntingchance ); + ActPar.erase( 0, indexend ); + break; + } + default: { + // unrecognized key + ActPar.erase( 0, 1 ); + break; + } + } + } + if( Random( 0, 100 ) <= flatchance ) { + MoverParameters->WheelFlat += fixedflatsize + Random( 0, randomflatsize ); + } + } // wheel + else if( ( ActPar.size() >= 2 ) + && ( ActPar[ 0 ] == 'T' ) ) { + // temperature + ActPar.erase( 0, 1 ); + + auto setambient { false }; + + while( false == ActPar.empty() ) { + switch( ActPar[ 0 ] ) { + case 'A': { + // cold start, set all temperatures to ambient level + setambient = true; + ActPar.erase( 0, 1 ); + break; + } + default: { + // unrecognized key + ActPar.erase( 0, 1 ); + break; + } + } + } + if( true == setambient ) { + // TODO: pull ambient temperature from environment data + MoverParameters->dizel_HeatSet( Global.AirTemperature ); + } + } // temperature /* else if (ActPar.substr(0, 1) == "") // tu mozna wpisac inny prefiks i inne rzeczy { // jakies inne prefiksy @@ -2023,14 +2065,20 @@ TDynamicObject::Init(std::string Name, // nazwa pojazdu, np. "EU07-424" if (MoverParameters->CategoryFlag & 2) // jeśli samochód { // ustawianie samochodow na poboczu albo na środku drogi - if (Track->fTrackWidth < 3.5) // jeśli droga wąska + if( Track->fTrackWidth < 3.5 ) // jeśli droga wąska MoverParameters->OffsetTrackH = 0.0; // to stawiamy na środku, niezależnie od stanu // ruchu - else if (driveractive) // od 3.5m do 8.0m jedzie po środku pasa, dla + else if( driveractive ) {// od 3.5m do 8.0m jedzie po środku pasa, dla // szerszych w odległości // 1.5m - MoverParameters->OffsetTrackH = - Track->fTrackWidth <= 8.0 ? -Track->fTrackWidth * 0.25 : -1.5; + auto const lanefreespace = 0.5 * Track->fTrackWidth - MoverParameters->Dim.W; + MoverParameters->OffsetTrackH = ( + lanefreespace > 1.5 ? + -0.5 * MoverParameters->Dim.W - 0.75 : // wide road, keep near centre with safe margin + ( lanefreespace > 0.1 ? + -0.25 * Track->fTrackWidth : // narrow fit, stay on the middle + -0.5 * MoverParameters->Dim.W - 0.075 ) ); // too narrow, just keep some minimal clearance + } else // jak stoi, to kołem na poboczu i pobieramy szerokość razem z // poboczem, ale nie z // chodnikiem @@ -2042,177 +2090,159 @@ TDynamicObject::Init(std::string Name, // nazwa pojazdu, np. "EU07-424" // wygenerować fDist = -fDist; // to traktujemy, jakby przesunięcie było w drugą stronę } - // w wagonie tez niech jedzie - // if (MoverParameters->MainCtrlPosNo>0 && - // if (MoverParameters->CabNo!=0) - if (DriverType != "") - { // McZapkie-040602: jeśli coś siedzi w pojeździe - if (Name == Global::asHumanCtrlVehicle) // jeśli pojazd wybrany do prowadzenia - { - if (DebugModeFlag ? false : MoverParameters->EngineType != - Dumb) // jak nie Debugmode i nie jest dumbem - Controller = Humandriver; // wsadzamy tam sterującego - else // w przeciwnym razie trzeba włączyć pokazywanie kabiny - bDisplayCab = true; - } - // McZapkie-151102: rozkład jazdy czytany z pliku *.txt z katalogu w którym - // jest sceneria - if (DriverType == "1" || DriverType == "2") - { // McZapkie-110303: mechanik i rozklad tylko gdy jest obsada - // MoverParameters->ActiveCab=MoverParameters->CabNo; //ustalenie aktywnej - // kabiny - // (rozrząd) - Mechanik = new TController(Controller, this, Aggressive); - if (TrainName.empty()) // jeśli nie w składzie - { - Mechanik->DirectionInitial(); // załączenie rozrządu (wirtualne kabiny) itd. - Mechanik->PutCommand( - "Timetable:", iDirection ? -fVel : fVel, 0, - NULL); // tryb pociągowy z ustaloną prędkością (względem sprzęgów) - } - // if (TrainName!="none") - // Mechanik->PutCommand("Timetable:"+TrainName,fVel,0,NULL); - } - else if (DriverType == "p") - { // obserwator w charakterze pasażera - // Ra: to jest niebezpieczne, bo w razie co będzie pomagał hamulcem - // bezpieczeństwa - Mechanik = new TController(Controller, this, Easyman, false); - } - } + + create_controller( DriverType, !TrainName.empty() ); + // McZapkie-250202 - iAxles = (MaxAxles < MoverParameters->NAxles) ? MaxAxles : MoverParameters->NAxles; // ilość osi +/* + iAxles = std::min( MoverParameters->NAxles, MaxAxles ); // ilość osi +*/ // wczytywanie z pliku nazwatypu.mmd, w tym model - LoadMMediaFile(asBaseDir, Type_Name, asReplacableSkin); + erase_extension( asReplacableSkin ); + LoadMMediaFile(Type_Name, asReplacableSkin); // McZapkie-100402: wyszukiwanie submodeli sprzegów - btCoupler1.Init("coupler1", mdModel, false); // false - ma być wyłączony - btCoupler2.Init("coupler2", mdModel, false); + btCoupler1.Init( "coupler1", mdModel, false ); // false - ma być wyłączony + btCoupler2.Init( "coupler2", mdModel, false); + // brake hoses btCPneumatic1.Init("cpneumatic1", mdModel); btCPneumatic2.Init("cpneumatic2", mdModel); btCPneumatic1r.Init("cpneumatic1r", mdModel); btCPneumatic2r.Init("cpneumatic2r", mdModel); + // main hoses btPneumatic1.Init("pneumatic1", mdModel); btPneumatic2.Init("pneumatic2", mdModel); btPneumatic1r.Init("pneumatic1r", mdModel); btPneumatic2r.Init("pneumatic2r", mdModel); - btCCtrl1.Init("cctrl1", mdModel, false); - btCCtrl2.Init("cctrl2", mdModel, false); - btCPass1.Init("cpass1", mdModel, false); - btCPass2.Init("cpass2", mdModel, false); + // control cables + btCCtrl1.Init( "cctrl1", mdModel, false); + btCCtrl2.Init( "cctrl2", mdModel, false); + // gangways + btCPass1.Init( "cpass1", mdModel, false); + btCPass2.Init( "cpass2", mdModel, false); // sygnaly // ABu 060205: Zmiany dla koncowek swiecacych: - btEndSignals11.Init("endsignal13", mdModel, false); - btEndSignals21.Init("endsignal23", mdModel, false); - btEndSignals13.Init("endsignal12", mdModel, false); - btEndSignals23.Init("endsignal22", mdModel, false); - iInventory |= btEndSignals11.Active() ? 0x01 : 0; // informacja, czy ma poszczególne światła - iInventory |= btEndSignals21.Active() ? 0x02 : 0; - iInventory |= btEndSignals13.Active() ? 0x04 : 0; - iInventory |= btEndSignals23.Active() ? 0x08 : 0; + btEndSignals11.Init( "endsignal13", mdModel, false); + btEndSignals21.Init( "endsignal23", mdModel, false); + btEndSignals13.Init( "endsignal12", mdModel, false); + btEndSignals23.Init( "endsignal22", mdModel, false); + iInventory[ side::front ] |= btEndSignals11.Active() ? light::redmarker_left : 0; // informacja, czy ma poszczególne światła + iInventory[ side::front ] |= btEndSignals13.Active() ? light::redmarker_right : 0; + iInventory[ side::rear ] |= btEndSignals21.Active() ? light::redmarker_left : 0; + iInventory[ side::rear ] |= btEndSignals23.Active() ? light::redmarker_right : 0; // ABu: to niestety zostawione dla kompatybilnosci modeli: - btEndSignals1.Init("endsignals1", mdModel, false); - btEndSignals2.Init("endsignals2", mdModel, false); - btEndSignalsTab1.Init("endtab1", mdModel, false); - btEndSignalsTab2.Init("endtab2", mdModel, false); - iInventory |= btEndSignals1.Active() ? 0x10 : 0; - iInventory |= btEndSignals2.Active() ? 0x20 : 0; - iInventory |= btEndSignalsTab1.Active() ? 0x40 : 0; // tabliczki blaszane - iInventory |= btEndSignalsTab2.Active() ? 0x80 : 0; + btEndSignals1.Init( "endsignals1", mdModel, false); + btEndSignals2.Init( "endsignals2", mdModel, false); + btEndSignalsTab1.Init( "endtab1", mdModel, false); + btEndSignalsTab2.Init( "endtab2", mdModel, false); + iInventory[ side::front ] |= btEndSignals1.Active() ? ( light::redmarker_left | light::redmarker_right ) : 0; + iInventory[ side::front ] |= btEndSignalsTab1.Active() ? light::rearendsignals : 0; // tabliczki blaszane + iInventory[ side::rear ] |= btEndSignals2.Active() ? ( light::redmarker_left | light::redmarker_right ) : 0; + iInventory[ side::rear ] |= btEndSignalsTab2.Active() ? light::rearendsignals : 0; // ABu Uwaga! tu zmienic w modelu! - btHeadSignals11.Init("headlamp13", mdModel, false); // lewe - btHeadSignals12.Init("headlamp11", mdModel, false); // górne - btHeadSignals13.Init("headlamp12", mdModel, false); // prawe - btHeadSignals21.Init("headlamp23", mdModel, false); - btHeadSignals22.Init("headlamp21", mdModel, false); - btHeadSignals23.Init("headlamp22", mdModel, false); - btMechanik1.Init("mechanik1", mdLowPolyInt, false); - btMechanik2.Init("mechanik2", mdLowPolyInt, false); + btHeadSignals11.Init( "headlamp13", mdModel, false); // lewe + btHeadSignals12.Init( "headlamp11", mdModel, false); // górne + btHeadSignals13.Init( "headlamp12", mdModel, false); // prawe + btHeadSignals21.Init( "headlamp23", mdModel, false); + btHeadSignals22.Init( "headlamp21", mdModel, false); + btHeadSignals23.Init( "headlamp22", mdModel, false); + iInventory[ side::front ] |= btHeadSignals11.Active() ? light::headlight_left : 0; + iInventory[ side::front ] |= btHeadSignals12.Active() ? light::headlight_upper : 0; + iInventory[ side::front ] |= btHeadSignals13.Active() ? light::headlight_right : 0; + iInventory[ side::rear ] |= btHeadSignals21.Active() ? light::headlight_left : 0; + iInventory[ side::rear ] |= btHeadSignals22.Active() ? light::headlight_upper : 0; + iInventory[ side::rear ] |= btHeadSignals23.Active() ? light::headlight_right : 0; + btMechanik1.Init( "mechanik1", mdLowPolyInt, false); + btMechanik2.Init( "mechanik2", mdLowPolyInt, false); + if( MoverParameters->dizel_heat.water.config.shutters ) { + btShutters1.Init( "shutters1", mdModel, false ); + } + if( MoverParameters->dizel_heat.water_aux.config.shutters ) { + btShutters2.Init( "shutters2", mdModel, false ); + } TurnOff(); // resetowanie zmiennych submodeli - // wyszukiwanie zderzakow - if (mdModel) // jeśli ma w czym szukać - for (int i = 0; i < 2; i++) - { - asAnimName = std::string("buffer_left0") + to_string(i + 1); - smBuforLewy[i] = mdModel->GetFromName(asAnimName.c_str()); - if (smBuforLewy[i]) - smBuforLewy[i]->WillBeAnimated(); // ustawienie flagi animacji - asAnimName = std::string("buffer_right0") + to_string(i + 1); - smBuforPrawy[i] = mdModel->GetFromName(asAnimName.c_str()); - if (smBuforPrawy[i]) - smBuforPrawy[i]->WillBeAnimated(); + + if( mdLowPolyInt != nullptr ) { + // check the low poly interior for potential compartments of interest, ie ones which can be individually lit + // TODO: definition of relevant compartments in the .mmd file + TSubModel *submodel { nullptr }; + if( ( submodel = mdLowPolyInt->GetFromName( "cab1" ) ) != nullptr ) { Sections.push_back( { submodel, nullptr, 0.0f } ); } + if( ( submodel = mdLowPolyInt->GetFromName( "cab2" ) ) != nullptr ) { Sections.push_back( { submodel, nullptr, 0.0f } ); } + if( ( submodel = mdLowPolyInt->GetFromName( "cab0" ) ) != nullptr ) { Sections.push_back( { submodel, nullptr, 0.0f } ); } + // passenger car compartments + std::vector nameprefixes = { "corridor", "korytarz", "compartment", "przedzial" }; + for( auto const &nameprefix : nameprefixes ) { + init_sections( mdLowPolyInt, nameprefix ); } - for (int i = 0; i < iAxles; i++) // wyszukiwanie osi (0 jest na końcu, dlatego dodajemy - // długość?) - dRailPosition[i] = - (Reversed ? -dWheelsPosition[i] : (dWheelsPosition[i] + MoverParameters->Dim.L)) + - fDist; + } + // 'external_load' is an optional special section in the main model, pointing to submodel of external load + if( mdModel ) { + init_sections( mdModel, "external_load" ); + } + update_load_sections(); + update_load_visibility(); + // wyszukiwanie zderzakow + if( mdModel ) { + // jeśli ma w czym szukać + for( int i = 0; i < 2; i++ ) { + asAnimName = std::string( "buffer_left0" ) + to_string( i + 1 ); + smBuforLewy[ i ] = mdModel->GetFromName( asAnimName ); + if( smBuforLewy[ i ] ) + smBuforLewy[ i ]->WillBeAnimated(); // ustawienie flagi animacji + asAnimName = std::string( "buffer_right0" ) + to_string( i + 1 ); + smBuforPrawy[ i ] = mdModel->GetFromName( asAnimName ); + if( smBuforPrawy[ i ] ) + smBuforPrawy[ i ]->WillBeAnimated(); + } + } + for( auto &axle : m_axlesounds ) { + // wyszukiwanie osi (0 jest na końcu, dlatego dodajemy długość?) + axle.distance = ( + Reversed ? + -axle.offset : + ( axle.offset + MoverParameters->Dim.L ) ) + fDist; + } // McZapkie-250202 end. Track->AddDynamicObject(this); // wstawiamy do toru na pozycję 0, a potem przesuniemy // McZapkie: zmieniono na ilosc osi brane z chk // iNumAxles=(MoverParameters->NAxles>3 ? 4 : 2 ); iNumAxles = 2; // McZapkie-090402: odleglosc miedzy czopami skretu lub osiami - fAxleDist = Max0R(MoverParameters->BDist, MoverParameters->ADist); - if (fAxleDist < 0.2) - fAxleDist = 0.2; //żeby się dało wektory policzyć - if (fAxleDist > MoverParameters->Dim.L - 0.2) // nie mogą być za daleko - fAxleDist = MoverParameters->Dim.L - 0.2; // bo będzie "walenie w mur" + fAxleDist = clamp( + std::max( MoverParameters->BDist, MoverParameters->ADist ), + 0.2, //żeby się dało wektory policzyć + MoverParameters->Dim.L - 0.2 ); // nie mogą być za daleko bo będzie "walenie w mur" double fAxleDistHalf = fAxleDist * 0.5; - // WriteLog("Dynamic "+Type_Name+" of length "+MoverParameters->Dim.L+" at - // "+AnsiString(fDist)); - // if (Cab) //jeśli ma obsadę - zgodność wstecz, jeśli tor startowy ma Event0 - // if (Track->Event0) //jeśli tor ma Event0 - // if (fDist>=0.0) //jeśli jeśli w starych sceneriach początek składu byłby - // wysunięty na ten - // tor - // if (fDist<=0.5*MoverParameters->Dim.L+0.2) //ale nie jest wysunięty - // fDist+=0.5*MoverParameters->Dim.L+0.2; //wysunąć go na ten tor // przesuwanie pojazdu tak, aby jego początek był we wskazanym miejcu - fDist -= 0.5 * MoverParameters->Dim.L; // dodajemy pół długości pojazdu, bo - // ustawiamy jego środek (zliczanie na - // minus) - switch (iNumAxles) - { // Ra: pojazdy wstawiane są na tor początkowy, a potem - // przesuwane + fDist -= 0.5 * MoverParameters->Dim.L; // dodajemy pół długości pojazdu, bo ustawiamy jego środek (zliczanie na minus) + switch (iNumAxles) { + // Ra: pojazdy wstawiane są na tor początkowy, a potem przesuwane case 2: // ustawianie osi na torze Axle0.Init(Track, this, iDirection ? 1 : -1); Axle0.Move((iDirection ? fDist : -fDist) + fAxleDistHalf, false); Axle1.Init(Track, this, iDirection ? 1 : -1); - Axle1.Move((iDirection ? fDist : -fDist) - fAxleDistHalf, - false); // false, żeby nie generować eventów - // Axle2.Init(Track,this,iDirection?1:-1); - // Axle2.Move((iDirection?fDist:-fDist)-fAxleDistHalft+0.01),false); - // Axle3.Init(Track,this,iDirection?1:-1); - // Axle3.Move((iDirection?fDist:-fDist)+fAxleDistHalf-0.01),false); + Axle1.Move((iDirection ? fDist : -fDist) - fAxleDistHalf, false); // false, żeby nie generować eventów break; case 4: Axle0.Init(Track, this, iDirection ? 1 : -1); - Axle0.Move((iDirection ? fDist : -fDist) + (fAxleDistHalf + MoverParameters->ADist * 0.5), - false); + Axle0.Move((iDirection ? fDist : -fDist) + (fAxleDistHalf + MoverParameters->ADist * 0.5), false); Axle1.Init(Track, this, iDirection ? 1 : -1); - Axle1.Move((iDirection ? fDist : -fDist) - (fAxleDistHalf + MoverParameters->ADist * 0.5), - false); + Axle1.Move((iDirection ? fDist : -fDist) - (fAxleDistHalf + MoverParameters->ADist * 0.5), false); // Axle2.Init(Track,this,iDirection?1:-1); // Axle2.Move((iDirection?fDist:-fDist)-(fAxleDistHalf-MoverParameters->ADist*0.5),false); // Axle3.Init(Track,this,iDirection?1:-1); // Axle3.Move((iDirection?fDist:-fDist)+(fAxleDistHalf-MoverParameters->ADist*0.5),false); break; } - Move(0.0001); // potrzebne do wyliczenia aktualnej pozycji; nie może być zero, - // bo nie przeliczy - // pozycji - // teraz jeszcze trzeba przypisać pojazdy do nowego toru, bo przesuwanie - // początkowe osi nie + // potrzebne do wyliczenia aktualnej pozycji; nie może być zero, bo nie przeliczy pozycji + // teraz jeszcze trzeba przypisać pojazdy do nowego toru, bo przesuwanie początkowe osi nie // zrobiło tego + Move( 0.0001 ); ABuCheckMyTrack(); // zmiana toru na ten, co oś Axle0 (oś z przodu) - TLocation loc; // Ra: ustawienie pozycji do obliczania sprzęgów - loc.X = -vPosition.x; - loc.Y = vPosition.z; - loc.Z = vPosition.y; - MoverParameters->Loc = loc; // normalnie przesuwa ComputeMovement() w Update() - // pOldPos4=Axle1.pPosition; //Ra: nie używane - // pOldPos1=Axle0.pPosition; - // ActualTrack= GetTrack(); //McZapkie-030303 + // Ra: ustawienie pozycji do obliczania sprzęgów + MoverParameters->Loc = { + -vPosition.x, + vPosition.z, + vPosition.y }; // normalnie przesuwa ComputeMovement() w Update() // ABuWozki 060504 if (mdModel) // jeśli ma w czym szukać { @@ -2227,17 +2257,84 @@ TDynamicObject::Init(std::string Name, // nazwa pojazdu, np. "EU07-424" if (smBogie[1]) smBogie[1]->WillBeAnimated(); } - // ABu: zainicjowanie zmiennej, zeby nic sie nie ruszylo - // w pierwszej klatce, potem juz liczona prawidlowa wartosc masy + // ABu: zainicjowanie zmiennej, zeby nic sie nie ruszylo w pierwszej klatce, + // potem juz liczona prawidlowa wartosc masy MoverParameters->ComputeConstans(); - /*Ra: to nie działa - Event0 musi być wykonywany ciągle - if (fVel==0.0) //jeśli stoi - if (MoverParameters->CabNo!=0) //i ma kogoś w kabinie - if (Track->Event0) //a jest w tym torze event od stania - RaAxleEvent(Track->Event0); //dodanie eventu stania do kolejki - */ - vFloor = vector3(0, 0, MoverParameters->Floor); // wektor podłogi dla wagonów, przesuwa ładunek - return MoverParameters->Dim.L; // długość większa od zera oznacza OK; 2mm docisku? + // wektor podłogi dla wagonów, przesuwa ładunek + vFloor = Math3D::vector3(0, 0, MoverParameters->Floor); + + // długość większa od zera oznacza OK; 2mm docisku? + return MoverParameters->Dim.L; +} + +int +TDynamicObject::init_sections( TModel3d const *Model, std::string const &Nameprefix ) { + + std::string sectionname; + auto sectioncount = 0; + auto sectionindex = 0; + TSubModel *sectionsubmodel { nullptr }; + + do { + sectionname = + Nameprefix + ( + sectionindex < 10 ? + "0" + std::to_string( sectionindex ) : + std::to_string( sectionindex ) ); + sectionsubmodel = Model->GetFromName( sectionname ); + if( sectionsubmodel != nullptr ) { + Sections.push_back( { + sectionsubmodel, + nullptr, // pointers to load sections are generated afterwards + 0.0f } ); + ++sectioncount; + } + ++sectionindex; + } while( ( sectionsubmodel != nullptr ) + || ( sectionindex < 2 ) ); // chain can start from prefix00 or prefix01 + + return sectioncount; +} + +void +TDynamicObject::create_controller( std::string const Type, bool const Trainset ) { + + if( Type == "" ) { return; } + + if( asName == Global.asHumanCtrlVehicle ) { + // jeśli pojazd wybrany do prowadzenia + if( MoverParameters->EngineType != TEngineType::Dumb ) { + // wsadzamy tam sterującego + Controller = Humandriver; + } + else { + // w przeciwnym razie trzeba włączyć pokazywanie kabiny + bDisplayCab = true; + } + } + // McZapkie-151102: rozkład jazdy czytany z pliku *.txt z katalogu w którym jest sceneria + if( ( Type == "1" ) + || ( Type == "2" ) ) { + // McZapkie-110303: mechanik i rozklad tylko gdy jest obsada + Mechanik = new TController( Controller, this, Aggressive ); + + if( false == Trainset ) { + // jeśli nie w składzie + // załączenie rozrządu (wirtualne kabiny) itd. + Mechanik->DirectionInitial(); + // tryb pociągowy z ustaloną prędkością (względem sprzęgów) + Mechanik->PutCommand( + "Timetable:", + MoverParameters->V * 3.6 * ( iDirection ? -1.0 : 1.0 ), + 0, + nullptr ); + } + } + else if( Type == "p" ) { + // obserwator w charakterze pasażera + // Ra: to jest niebezpieczne, bo w razie co będzie pomagał hamulcem bezpieczeństwa + Mechanik = new TController( Controller, this, Easyman, false ); + } } void TDynamicObject::FastMove(double fDistance) @@ -2264,18 +2361,18 @@ void TDynamicObject::Move(double fDistance) } if (fDistance > 0.0) { // gdy ruch w stronę sprzęgu 0, doliczyć korektę do osi 1 - bEnabled &= Axle0.Move(fDistance, !iAxleFirst); // oś z przodu pojazdu - bEnabled &= Axle1.Move(fDistance /*-fAdjustment*/, iAxleFirst); // oś z tyłu pojazdu + bEnabled &= Axle0.Move(fDistance, iAxleFirst == 0); // oś z przodu pojazdu + bEnabled &= Axle1.Move(fDistance /*-fAdjustment*/, iAxleFirst != 0); // oś z tyłu pojazdu } else if (fDistance < 0.0) { // gdy ruch w stronę sprzęgu 1, doliczyć korektę do osi 0 - bEnabled &= Axle1.Move(fDistance, iAxleFirst); // oś z tyłu pojazdu prusza się pierwsza - bEnabled &= Axle0.Move(fDistance /*-fAdjustment*/, !iAxleFirst); // oś z przodu pojazdu + bEnabled &= Axle1.Move(fDistance, iAxleFirst != 0); // oś z tyłu pojazdu prusza się pierwsza + bEnabled &= Axle0.Move(fDistance /*-fAdjustment*/, iAxleFirst == 0); // oś z przodu pojazdu } else // gf: bez wywolania Move na postoju nie ma event0 { - bEnabled &= Axle1.Move(fDistance, iAxleFirst); // oś z tyłu pojazdu prusza się pierwsza - bEnabled &= Axle0.Move(fDistance, !iAxleFirst); // oś z przodu pojazdu + bEnabled &= Axle1.Move(fDistance, iAxleFirst != 0); // oś z tyłu pojazdu prusza się pierwsza + bEnabled &= Axle0.Move(fDistance, iAxleFirst == 0); // oś z przodu pojazdu } if (fDistance != 0.0) // nie liczyć ponownie, jeśli stoi { // liczenie pozycji pojazdu tutaj, bo jest używane w wielu miejscach @@ -2296,16 +2393,15 @@ void TDynamicObject::Move(double fDistance) // fAdjustment=0.0; vFront = Normalize(vFront); // kierunek ustawienia pojazdu (wektor jednostkowy) vLeft = Normalize(CrossProduct(vWorldUp, vFront)); // wektor poziomy w lewo, - // normalizacja potrzebna z powodu - // pochylenia (vFront) + // normalizacja potrzebna z powodu pochylenia (vFront) vUp = CrossProduct(vFront, vLeft); // wektor w górę, będzie jednostkowy modelRot.z = atan2(-vFront.x, vFront.z); // kąt obrotu pojazdu [rad]; z ABuBogies() - double a = ((Axle1.GetRoll() + Axle0.GetRoll())); // suma przechyłek - if (a != 0.0) + auto const roll { Roll() }; // suma przechyłek + if (roll != 0.0) { // wyznaczanie przechylenia tylko jeśli jest przechyłka // można by pobrać wektory normalne z toru... mMatrix.Identity(); // ta macierz jest potrzebna głównie do wyświetlania - mMatrix.Rotation(a * 0.5, vFront); // obrót wzdłuż osi o przechyłkę + mMatrix.Rotation(roll * 0.5, vFront); // obrót wzdłuż osi o przechyłkę vUp = mMatrix * vUp; // wektor w górę pojazdu (przekręcenie na przechyłce) // vLeft=mMatrix*DynamicObject->vLeft; // vUp=CrossProduct(vFront,vLeft); //wektor w górę @@ -2313,17 +2409,13 @@ void TDynamicObject::Move(double fDistance) vLeft = Normalize(CrossProduct(vUp, vFront)); // wektor w lewo // vUp=CrossProduct(vFront,vLeft); //wektor w górę } - mMatrix.Identity(); // to też można by od razu policzyć, ale potrzebne jest - // do wyświetlania - mMatrix.BasisChange(vLeft, vUp, vFront); // przesuwanie jest jednak rzadziej niż - // renderowanie - mMatrix = Inverse(mMatrix); // wyliczenie macierzy dla pojazdu (potrzebna - // tylko do wyświetlania?) + mMatrix.Identity(); // to też można by od razu policzyć, ale potrzebne jest do wyświetlania + mMatrix.BasisChange(vLeft, vUp, vFront); // przesuwanie jest jednak rzadziej niż renderowanie + mMatrix = Inverse(mMatrix); // wyliczenie macierzy dla pojazdu (potrzebna tylko do wyświetlania?) // if (MoverParameters->CategoryFlag&2) { // przesunięcia są używane po wyrzuceniu pociągu z toru vPosition.x += MoverParameters->OffsetTrackH * vLeft.x; // dodanie przesunięcia w bok - vPosition.z += - MoverParameters->OffsetTrackH * vLeft.z; // vLeft jest wektorem poprzecznym + vPosition.z += MoverParameters->OffsetTrackH * vLeft.z; // vLeft jest wektorem poprzecznym // if () na przechyłce będzie dodatkowo zmiana wysokości samochodu vPosition.y += MoverParameters->OffsetTrackV; // te offsety są liczone przez moverparam } @@ -2332,18 +2424,17 @@ void TDynamicObject::Move(double fDistance) // MoverParameters->Loc.Y= vPosition.z; // MoverParameters->Loc.Z= vPosition.y; // obliczanie pozycji sprzęgów do liczenia zderzeń - vector3 dir = (0.5 * MoverParameters->Dim.L) * vFront; // wektor sprzęgu - vCoulpler[0] = vPosition + dir; // współrzędne sprzęgu na początku - vCoulpler[1] = vPosition - dir; // współrzędne sprzęgu na końcu - MoverParameters->vCoulpler[0] = vCoulpler[0]; // tymczasowo kopiowane na inny poziom - MoverParameters->vCoulpler[1] = vCoulpler[1]; + auto dir = (0.5 * MoverParameters->Dim.L) * vFront; // wektor sprzęgu + vCoulpler[side::front] = vPosition + dir; // współrzędne sprzęgu na początku + vCoulpler[side::rear] = vPosition - dir; // współrzędne sprzęgu na końcu + MoverParameters->vCoulpler[side::front] = vCoulpler[side::front]; // tymczasowo kopiowane na inny poziom + MoverParameters->vCoulpler[side::rear] = vCoulpler[side::rear]; // bCameraNear= // if (bCameraNear) //jeśli istotne są szczegóły (blisko kamery) { // przeliczenie cienia TTrack *t0 = Axle0.GetTrack(); // już po przesunięciu TTrack *t1 = Axle1.GetTrack(); - if ((t0->eEnvironment == e_flat) && (t1->eEnvironment == e_flat)) // może być - // e_bridge... + if ((t0->eEnvironment == e_flat) && (t1->eEnvironment == e_flat)) // może być e_bridge... fShade = 0.0; // standardowe oświetlenie else { // jeżeli te tory mają niestandardowy stopień zacienienia @@ -2353,10 +2444,10 @@ void TDynamicObject::Move(double fDistance) switch (t0->eEnvironment) { // typ zmiany oświetlenia case e_canyon: - fShade = 0.65; + fShade = 0.65f; break; // zacienienie w kanionie case e_tunnel: - fShade = 0.20; + fShade = 0.20f; break; // zacienienie w tunelu } } @@ -2364,8 +2455,23 @@ void TDynamicObject::Move(double fDistance) { // liczymy proporcję double d = Axle0.GetTranslation(); // aktualne położenie na torze if (Axle0.GetDirection() < 0) - d = t0->fTrackLength - d; // od drugiej strony liczona długość + d = t0->Length() - d; // od drugiej strony liczona długość d /= fAxleDist; // rozsataw osi procentowe znajdowanie się na torze + + float shadefrom = 1.0f, shadeto = 1.0f; + // NOTE, TODO: calculating brightness level is used enough times to warrant encapsulation into a function + switch( t0->eEnvironment ) { + case e_canyon: { shadeto = 0.65f; break; } + case e_tunnel: { shadeto = 0.2f; break; } + default: {break; } + } + switch( t1->eEnvironment ) { + case e_canyon: { shadefrom = 0.65f; break; } + case e_tunnel: { shadefrom = 0.2f; break; } + default: {break; } + } + fShade = interpolate( shadefrom, shadeto, static_cast( d ) ); +/* switch (t0->eEnvironment) { // typ zmiany oświetlenia - zakładam, że // drugi tor ma e_flat @@ -2386,6 +2492,7 @@ void TDynamicObject::Move(double fDistance) fShade = d + (1.0 - d) * 0.20; break; // zacienienie w tunelu } +*/ } } } @@ -2411,13 +2518,10 @@ void TDynamicObject::AttachPrev(TDynamicObject *Object, int iType) loc.Z=Object->vPosition.y; Object->MoverParameters->Loc=loc; //ustawienie dodawanego pojazdu */ - MoverParameters->Attach(iDirection, Object->iDirection ^ 1, Object->MoverParameters, iType, - true); + MoverParameters->Attach(iDirection, Object->iDirection ^ 1, Object->MoverParameters, iType, true); MoverParameters->Couplers[iDirection].Render = false; - Object->MoverParameters->Attach(Object->iDirection ^ 1, iDirection, MoverParameters, iType, - true); - Object->MoverParameters->Couplers[Object->iDirection ^ 1].Render = - true; // rysowanie sprzęgu w dołączanym + Object->MoverParameters->Attach(Object->iDirection ^ 1, iDirection, MoverParameters, iType, true); + Object->MoverParameters->Couplers[Object->iDirection ^ 1].Render = true; // rysowanie sprzęgu w dołączanym if (iDirection) { //łączenie standardowe NextConnected = Object; // normalnie doczepiamy go sobie do sprzęgu 1 @@ -2438,19 +2542,18 @@ void TDynamicObject::AttachPrev(TDynamicObject *Object, int iType) Object->NextConnected = this; // on ma nas z tyłu Object->NextConnectedNo = iDirection; } +/* + // NOTE: this appears unnecessary and only messes things for the programmable lights function, which walks along + // whole trainset and expects each module to point to its own lights. Disabled, TBD, TODO: test for side-effects and delete if there's none if (MoverParameters->TrainType & dt_EZT) // w przypadku łączenia członów, - // światła w rozrządczym zależą od - // stanu w silnikowym - if (MoverParameters->Couplers[iDirection].AllowedFlag & - ctrain_depot) // gdy sprzęgi łączone warsztatowo (powiedzmy) - if ((MoverParameters->Power < 1.0) && - (Object->MoverParameters->Power > 1.0)) // my nie mamy mocy, ale ten drugi ma - iLights = Object->MoverParameters->iLights; // to w tym z mocą będą światła - // załączane, a w tym bez tylko widoczne + // światła w rozrządczym zależą od stanu w silnikowym + if (MoverParameters->Couplers[iDirection].AllowedFlag & ctrain_depot) // gdy sprzęgi łączone warsztatowo (powiedzmy) + if ((MoverParameters->Power < 1.0) && (Object->MoverParameters->Power > 1.0)) // my nie mamy mocy, ale ten drugi ma + iLights = Object->MoverParameters->iLights; // to w tym z mocą będą światła załączane, a w tym bez tylko widoczne else if ((MoverParameters->Power > 1.0) && (Object->MoverParameters->Power < 1.0)) // my mamy moc, ale ten drugi nie ma - Object->iLights = MoverParameters->iLights; // to w tym z mocą będą światła - // załączane, a w tym bez tylko widoczne + Object->iLights = MoverParameters->iLights; // to w tym z mocą będą światła załączane, a w tym bez tylko widoczne +*/ return; // SetPneumatic(1,1); //Ra: to i tak się nie wykonywało po return // SetPneumatic(1,0); @@ -2462,117 +2565,221 @@ bool TDynamicObject::UpdateForce(double dt, double dt1, bool FullVer) { if (!bEnabled) return false; - if (dt > 0) - MoverParameters->ComputeTotalForce(dt, dt1, - FullVer); // wywalenie WS zależy od ustawienia kierunku + if( dt > 0 ) { + // wywalenie WS zależy od ustawienia kierunku + MoverParameters->ComputeTotalForce( dt, dt1, FullVer ); + } return true; } -void TDynamicObject::LoadUpdate() -{ // przeładowanie modelu ładunku +// initiates load change by specified amounts, with a platform on specified side +void TDynamicObject::LoadExchange( int const Disembark, int const Embark, int const Platform ) { + + if( ( MoverParameters->DoorOpenCtrl == control_t::passenger ) + || ( MoverParameters->DoorOpenCtrl == control_t::mixed ) ) { + // jeśli jedzie do tyłu, to drzwi otwiera odwrotnie + auto const lewe = ( DirectionGet() > 0 ) ? 1 : 2; + auto const prawe = 3 - lewe; + if( Platform & lewe ) { + MoverParameters->DoorLeft( true, range_t::local ); + } + if( Platform & prawe ) { + MoverParameters->DoorRight( true, range_t::local ); + } + } + m_exchange.unload_count += Disembark; + m_exchange.load_count += Embark; + m_exchange.speed_factor = ( + Platform == 3 ? + 2.0 : + 1.0 ); + m_exchange.time = 0.0; +} + +// update state of load exchange operation +void TDynamicObject::update_exchange( double const Deltatime ) { + + // TODO: move offset calculation after initial check, when the loading system is all unified + update_load_offset(); + + if( ( m_exchange.unload_count < 0.01 ) && ( m_exchange.load_count < 0.01 ) ) { return; } + + if( ( MoverParameters->Vel < 2.0 ) + && ( ( true == MoverParameters->DoorLeftOpened ) + || ( true == MoverParameters->DoorRightOpened ) ) ) { + + m_exchange.time += Deltatime; + while( ( m_exchange.unload_count > 0.01 ) + && ( m_exchange.time >= 1.0 ) ) { + + m_exchange.time -= 1.0; + auto const exchangesize = std::min( m_exchange.unload_count, MoverParameters->UnLoadSpeed * m_exchange.speed_factor ); + m_exchange.unload_count -= exchangesize; + MoverParameters->LoadStatus = 1; + MoverParameters->LoadAmount = std::max( 0.f, MoverParameters->LoadAmount - exchangesize ); + update_load_visibility(); + } + if( m_exchange.unload_count < 0.01 ) { + // finish any potential unloading operation before adding new load + // don't load more than can fit + m_exchange.load_count = std::min( m_exchange.load_count, MoverParameters->MaxLoad - MoverParameters->LoadAmount ); + while( ( m_exchange.load_count > 0.01 ) + && ( m_exchange.time >= 1.0 ) ) { + + m_exchange.time -= 1.0; + auto const exchangesize = std::min( m_exchange.load_count, MoverParameters->LoadSpeed * m_exchange.speed_factor ); + m_exchange.load_count -= exchangesize; + MoverParameters->LoadStatus = 2; + MoverParameters->LoadAmount = std::min( MoverParameters->MaxLoad, MoverParameters->LoadAmount + exchangesize ); // std::max not strictly needed but, eh + update_load_visibility(); + } + } + } + + if( MoverParameters->Vel > 2.0 ) { + // if the vehicle moves too fast cancel the exchange + m_exchange.unload_count = 0; + m_exchange.load_count = 0; + } + + if( ( m_exchange.unload_count < 0.01 ) + && ( m_exchange.load_count < 0.01 ) ) { + + MoverParameters->LoadStatus = 0; + // if the exchange is completed (or canceled) close the door, if applicable + if( ( MoverParameters->DoorCloseCtrl == control_t::passenger ) + || ( MoverParameters->DoorCloseCtrl == control_t::mixed ) ) { + + if( ( MoverParameters->Vel > 2.0 ) + || ( Random() < ( + // remotely controlled door are more likely to be left open + MoverParameters->DoorCloseCtrl == control_t::passenger ? + 0.75 : + 0.50 ) ) ) { + + MoverParameters->DoorLeft( false, range_t::local ); + MoverParameters->DoorRight( false, range_t::local ); + } + } + } +} + +void TDynamicObject::LoadUpdate() { + // przeładowanie modelu ładunku // Ra: nie próbujemy wczytywać modeli miliony razy podczas renderowania!!! - if ((mdLoad == NULL) && (MoverParameters->Load > 0)) - { - std::string asLoadName = - asBaseDir + MoverParameters->LoadType + ".t3d"; // zapamiętany katalog pojazdu - // asLoadName=MoverParameters->LoadType; - // if (MoverParameters->LoadType!=AnsiString("passengers")) - Global::asCurrentTexturePath = asBaseDir; // bieżąca ścieżka do tekstur to dynamic/... - mdLoad = TModelsManager::GetModel(asLoadName.c_str()); // nowy ładunek - Global::asCurrentTexturePath = - std::string(szTexturePath); // z powrotem defaultowa sciezka do tekstur - // Ra: w MMD można by zapisać położenie modelu ładunku (np. węgiel) w - // zależności od - // załadowania + if( ( mdLoad == nullptr ) + && ( MoverParameters->LoadAmount > 0 ) ) { + + if( false == MoverParameters->LoadType.name.empty() ) { + // bieżąca ścieżka do tekstur to dynamic/... + Global.asCurrentTexturePath = asBaseDir; + + mdLoad = LoadMMediaFile_mdload( MoverParameters->LoadType.name ); + // TODO: discern from vehicle component which merely uses vehicle directory and has no animations, so it can be initialized outright + // and actual vehicles which get their initialization after their animations are set up + if( mdLoad != nullptr ) { + mdLoad->Init(); + } + // update bindings between lowpoly sections and potential load chunks placed inside them + update_load_sections(); + // z powrotem defaultowa sciezka do tekstur + Global.asCurrentTexturePath = std::string( szTexturePath ); + } + // Ra: w MMD można by zapisać położenie modelu ładunku (np. węgiel) w zależności od załadowania + } + else if( MoverParameters->LoadAmount == 0 ) { + // nie ma ładunku +// MoverParameters->AssignLoad( "" ); + mdLoad = nullptr; + // erase bindings between lowpoly sections and potential load chunks placed inside them + update_load_sections(); } - else if (MoverParameters->Load == 0) - mdLoad = NULL; // nie ma ładunku - // if ((mdLoad==NULL)&&(MoverParameters->Load>0)) - // { - // mdLoad=NULL; //Ra: to jest tu bez sensu - co autor miał na myśli? - // } MoverParameters->LoadStatus &= 3; // po zakończeniu będzie równe zero -}; - -/* -double ComputeRadius(double p1x, double p1z, double p2x, double p2z, - double p3x, double p3z, double p4x, double p4z) -{ - - double v1z= p1x-p2x; - double v1x= p1z-p2z; - double v4z= p3x-p4x; - double v4x= p3z-p4z; - double A1= p2z-p1z; - double B1= p1x-p2x; - double C1= -p1z*B1-p1x*A1; - double A2= p4z-p3z; - double B2= p3x-p4x; - double C2= -p3z*B1-p3x*A1; - double y= (A1*C2/A2-C1)/(B1-A1*B2/A2); - double x= (-B2*y-C2)/A2; } -*/ -double TDynamicObject::ComputeRadius(vector3 p1, vector3 p2, vector3 p3, vector3 p4) -{ - // vector3 v1 - // TLine l1= TLine(p1,p1-p2); - // TLine l4= TLine(p4,p4-p3); - // TPlane p1= l1.GetPlane(); - // vector3 pt; - // CrossPoint(pt,l4,p1); - double R = 0.0; - vector3 p12 = p1 - p2; - vector3 p34 = p3 - p4; - p12 = CrossProduct(p12, vector3(0.0, 0.1, 0.0)); - p12 = Normalize(p12); - p34 = CrossProduct(p34, vector3(0.0, 0.1, 0.0)); - p34 = Normalize(p34); - if (fabs(p1.x - p2.x) > 0.01) - { - if (fabs(p12.x - p34.x) > 0.001) - R = (p1.x - p4.x) / (p34.x - p12.x); +void +TDynamicObject::update_load_sections() { + + SectionLoadVisibility.clear(); + + for( auto §ion : Sections ) { + + section.load = ( + mdLoad != nullptr ? + mdLoad->GetFromName( section.compartment->pName ) : + nullptr ); + + if( ( section.load != nullptr ) + && ( section.load->count_children() > 0 ) ) { + SectionLoadVisibility.push_back( { section.load, false } ); + } } - else - { - if (fabs(p12.z - p34.z) > 0.001) - R = (p1.z - p4.z) / (p34.z - p12.z); - } - return (R); + shuffle_load_sections(); } +void +TDynamicObject::update_load_visibility() { /* -double TDynamicObject::ComputeRadius() -{ - double L=0; - double d=0; - d=sqrt(SquareMagnitude(Axle0.pPosition-Axle1.pPosition)); - L=Axle1.GetLength(Axle1.pPosition,Axle1.pPosition-Axle2.pPosition,Axle0.pPosition-Axle3.pPosition,Axle0.pPosition); - - double eps=0.01; - double R= 0; - double L_d; - if ((L>0) || (d>0)) - { - L_d= L-d; - if (L_d>eps) - { - R=L*sqrt(L/(24*(L_d))); - } - } - return R; -} + if( Random() < 0.25 ) { + shuffle_load_sections(); + } */ - -/* Ra: na razie nie potrzebne -void TDynamicObject::UpdatePos() -{ - MoverParameters->Loc.X= -vPosition.x; - MoverParameters->Loc.Y= vPosition.z; - MoverParameters->Loc.Z= vPosition.y; + auto loadpercentage { ( + MoverParameters->MaxLoad == 0.0 ? + 0.0 : + 100.0 * MoverParameters->LoadAmount / MoverParameters->MaxLoad ) }; + auto const sectionloadpercentage { ( + SectionLoadVisibility.empty() ? + 0.0 : + 100.0 / SectionLoadVisibility.size() ) }; + // set as many sections as we can, given overall load percentage and how much of full percentage is covered by each chunk + std::for_each( + std::begin( SectionLoadVisibility ), std::end( SectionLoadVisibility ), + [&]( section_visibility §ion ) { + section.visible = ( loadpercentage > 0.0 ); + section.visible_chunks = 0; + auto const sectionchunkcount { section.submodel->count_children() }; + auto const sectionchunkloadpercentage{ ( + sectionchunkcount == 0 ? + 0.0 : + sectionloadpercentage / sectionchunkcount ) }; + auto *sectionchunk { section.submodel->ChildGet() }; + while( sectionchunk != nullptr ) { + if( loadpercentage > 0.0 ) { + ++section.visible_chunks; + loadpercentage -= sectionchunkloadpercentage; + } + sectionchunk = sectionchunk->NextGet(); + } } ); +} + +void +TDynamicObject::update_load_offset() { + + if( MoverParameters->LoadType.offset_min == 0.f ) { return; } + + auto const loadpercentage { ( + MoverParameters->MaxLoad == 0.0 ? + 0.0 : + 100.0 * MoverParameters->LoadAmount / MoverParameters->MaxLoad ) }; + + LoadOffset = interpolate( MoverParameters->LoadType.offset_min, 0.f, clamp( 0.0, 1.0, loadpercentage * 0.01 ) ); +} + +void +TDynamicObject::shuffle_load_sections() { + + std::shuffle( std::begin( SectionLoadVisibility ), std::end( SectionLoadVisibility ), Global.random_engine ); + // shift chunks assigned to corridors to the end of the list, so they show up last + std::stable_partition( + std::begin( SectionLoadVisibility ), std::end( SectionLoadVisibility ), + []( section_visibility const §ion ) { + return ( + ( section.submodel->pName.find( "compartment" ) == 0 ) + || ( section.submodel->pName.find( "przedzial" ) == 0 ) ); } ); + // NOTE: potentially we're left with a mix of corridor and external section loads + // but that's not necessarily a wrong outcome, so we leave it this way for the time being } -*/ /* Ra: @@ -2587,7 +2794,7 @@ histerezę czasową, aby te tryby pracy nie przełączały się zbyt szybko. bool TDynamicObject::Update(double dt, double dt1) { - if (dt == 0) + if (dt1 == 0) return true; // Ra: pauza if (!MoverParameters->PhysicActivation && !MechInside) // to drugie, bo będąc w maszynowym blokuje się fizyka @@ -2597,58 +2804,8 @@ bool TDynamicObject::Update(double dt, double dt1) if (!bEnabled) return false; // a normalnie powinny mieć bEnabled==false - // Ra: przeniosłem - no już lepiej tu, niż w wyświetlaniu! - // if ((MoverParameters->ConverterFlag==false) && - // (MoverParameters->TrainType!=dt_ET22)) - // Ra: to nie może tu być, bo wyłącza sprężarkę w rozrządczym EZT! - // if - // ((MoverParameters->ConverterFlag==false)&&(MoverParameters->CompressorPower!=0)) - // MoverParameters->CompressorFlag=false; - // if (MoverParameters->CompressorPower==2) - // MoverParameters->CompressorAllow=MoverParameters->ConverterFlag; - - // McZapkie-260202 - if ((MoverParameters->EnginePowerSource.SourceType == CurrentCollector) && - (MoverParameters->Power > 1.0)) // aby rozrządczy nie opuszczał silnikowemu - if ((MechInside) || (MoverParameters->TrainType == dt_EZT)) - { - // if - // ((!MoverParameters->PantCompFlag)&&(MoverParameters->CompressedVolume>=2.8)) - // MoverParameters->PantVolume=MoverParameters->CompressedVolume; - if (MoverParameters->PantPress < (MoverParameters->TrainType == dt_EZT ? 2.4 : 3.5)) - { // 3.5 wg - // http://www.transportszynowy.pl/eu06-07pneumat.php - //"Wyłączniki ciśnieniowe odbieraków prądu wyłączają sterowanie - // wyłącznika szybkiego - // oraz uniemożliwiają podniesienie odbieraków prądu, gdy w instalacji - // rozrządu - // ciśnienie spadnie poniżej wartości 3,5 bara." - // Ra 2013-12: Niebugocław mówi, że w EZT podnoszą się przy 2.5 - // if (!MoverParameters->PantCompFlag) - // MoverParameters->PantVolume=MoverParameters->CompressedVolume; - MoverParameters->PantFront(false); // opuszczenie pantografów przy niskim ciśnieniu - MoverParameters->PantRear(false); // to idzie w ukrotnieniu, a nie powinno... - } - // Winger - automatyczne wylaczanie malej sprezarki - else if (MoverParameters->PantPress >= 4.8) - MoverParameters->PantCompFlag = false; - } // Ra: do Mover to trzeba przenieść, żeby AI też mogło sobie podpompować - double dDOMoveLen; - - TLocation l; - l.X = -vPosition.x; // przekazanie pozycji do fizyki - l.Y = vPosition.z; - l.Z = vPosition.y; - TRotation r; - r.Rx = r.Ry = r.Rz = 0; // McZapkie: parametry powinny byc pobierane z toru - - // TTrackShape ts; - // ts.R=MyTrack->fRadius; - // if (ABuGetDirection()<0) ts.R=-ts.R; - // ts.R=MyTrack->fRadius; //ujemne promienie są już zamienione przy - // wczytywaniu if (Axle0.vAngles.z != Axle1.vAngles.z) { // wyliczenie promienia z obrotów osi - modyfikację zgłosił youBy ts.R = Axle0.vAngles.z - Axle1.vAngles.z; // różnica może dawać stałą ±M_2PI @@ -2681,115 +2838,78 @@ bool TDynamicObject::Update(double dt, double dt1) // TTrackParam tp; tp.Width = MyTrack->fTrackWidth; // McZapkie-250202 - tp.friction = MyTrack->fFriction * Global::fFriction; + tp.friction = MyTrack->fFriction * Global.fFriction * Global.FrictionWeatherFactor; tp.CategoryFlag = MyTrack->iCategoryFlag & 15; tp.DamageFlag = MyTrack->iDamageFlag; tp.QualityFlag = MyTrack->iQualityFlag; - if ((MoverParameters->Couplers[0].CouplingFlag > 0) && - (MoverParameters->Couplers[1].CouplingFlag > 0)) - { + + // couplers + if( ( MoverParameters->Couplers[ 0 ].CouplingFlag != coupling::faux ) + && ( MoverParameters->Couplers[ 1 ].CouplingFlag != coupling::faux ) ) { + MoverParameters->InsideConsist = true; } - else - { + else { + MoverParameters->InsideConsist = false; } + // + // napiecie sieci trakcyjnej // Ra 15-01: przeliczenie poboru prądu powinno być robione wcześniej, żeby na // tym etapie były // znane napięcia // TTractionParam tmpTraction; // tmpTraction.TractionVoltage=0; - if (MoverParameters->EnginePowerSource.SourceType == CurrentCollector) + if (MoverParameters->EnginePowerSource.SourceType == TPowerSource::CurrentCollector) { // dla EZT tylko silnikowy - // if (Global::bLiveTraction) + // if (Global.bLiveTraction) { // Ra 2013-12: to niżej jest chyba trochę bez sensu double v = MoverParameters->PantRearVolt; - if (v == 0.0) - { + if (v == 0.0) { v = MoverParameters->PantFrontVolt; - if (v == 0.0) - if ((MoverParameters->TrainType & (dt_EZT | dt_ET40 | dt_ET41 | dt_ET42)) && - MoverParameters->EngineType != - ElectricInductionMotor) // dwuczłony mogą mieć sprzęg WN + if( v == 0.0 ) { + if( MoverParameters->TrainType & ( dt_EZT | dt_ET40 | dt_ET41 | dt_ET42 ) ) { + // dwuczłony mogą mieć sprzęg WN v = MoverParameters->GetTrainsetVoltage(); // ostatnia szansa + } + } } if (v != 0.0) { // jeśli jest zasilanie NoVoltTime = 0; tmpTraction.TractionVoltage = v; } - else - { - /* - if (MoverParameters->Vel>0.1f) //jeśli jedzie - if (NoVoltTime==0.0) //tylko przy pierwszym zaniku napięcia - if (MoverParameters->PantFrontUp||MoverParameters->PantRearUp) - //if - ((pants[0].fParamPants->PantTraction>1.0)||(pants[1].fParamPants->PantTraction>1.0)) - {//wspomagacz usuwania problemów z siecią - if (!Global::iPause) - {//Ra: tymczasowa teleportacja do miejsca, gdzie brakuje prądu - Global::SetCameraPosition(vPosition+vector3(0,0,5)); //nowa - pozycja dla - generowania obiektów - Global::pCamera->Init(vPosition+vector3(0,0,5),Global::pFreeCameraInitAngle[0]); - //przestawienie - } - Global:l::pGround->Silence(Global::pCamera->Pos); //wyciszenie - wszystkiego - z poprzedniej pozycji - Globa:iPause|=1; //tymczasowe zapauzowanie, gdy problem z - siecią - } - */ - NoVoltTime = NoVoltTime + dt; - if (NoVoltTime > 0.2) // jeśli brak zasilania dłużej niż 0.2 sekundy (25km/h pod - // izolatorem daje 0.15s) - { // Ra 2F1H: prowizorka, trzeba przechować napięcie, żeby nie wywalało - // WS pod - // izolatorem - if (MoverParameters->Vel > 0.5) // jeśli jedzie - if (MoverParameters->PantFrontUp || - MoverParameters->PantRearUp) // Ra 2014-07: doraźna blokada logowania - // zimnych lokomotyw - zrobić to trzeba - // inaczej - // if (NoVoltTime>0.02) //tu można ograniczyć czas rozłączenia - // if (DebugModeFlag) //logowanie nie zawsze - if ((MoverParameters->Mains) && - ((MoverParameters->EngineType != ElectricInductionMotor) - || (MoverParameters->GetTrainsetVoltage() < 0.1f))) - { // Ra 15-01: logować tylko, jeśli WS załączony - // yB 16-03: i nie jest to asynchron zasilany z daleka - // if (MoverParameters->PantFrontUp&&pants) - // Ra 15-01: bezwzględne współrzędne pantografu nie są dostępne, - // więc lepiej się tego nie zaloguje - ErrorLog("Voltage loss: by " + MoverParameters->Name + " at " + - to_string(vPosition.x, 2, 7) + " " + - to_string(vPosition.y, 2, 7) + " " + - to_string(vPosition.z, 2, 7) + ", time " + - to_string(NoVoltTime, 2, 7)); - // if (MoverParameters->PantRearUp) - // if (iAnimType[ANIM_PANTS]>1) - // if (pants[1]) - // ErrorLog("Voltage loss: by "+MoverParameters->Name+" at - // "+FloatToStrF(vPosition.x,ffFixed,7,2)+" - // "+FloatToStrF(vPosition.y,ffFixed,7,2)+" - // "+FloatToStrF(vPosition.z,ffFixed,7,2)+", time - // "+FloatToStrF(NoVoltTime,ffFixed,7,2)); + else { + NoVoltTime += dt1; + if( NoVoltTime > 0.2 ) { + // jeśli brak zasilania dłużej niż 0.2 sekundy (25km/h pod izolatorem daje 0.15s) + // Ra 2F1H: prowizorka, trzeba przechować napięcie, żeby nie wywalało WS pod izolatorem + if( MoverParameters->Vel > 0.5 ) { + // jeśli jedzie + // Ra 2014-07: doraźna blokada logowania zimnych lokomotyw - zrobić to trzeba inaczej + if( MoverParameters->PantFrontUp + || MoverParameters->PantRearUp ) { + + if( ( MoverParameters->Mains ) + && ( MoverParameters->GetTrainsetVoltage() < 0.1f ) ) { + // Ra 15-01: logować tylko, jeśli WS załączony + // yB 16-03: i nie jest to asynchron zasilany z daleka + // Ra 15-01: bezwzględne współrzędne pantografu nie są dostępne, + // więc lepiej się tego nie zaloguje + ErrorLog( + "Bad traction: " + MoverParameters->Name + + " lost power for " + to_string( NoVoltTime, 2 ) + " sec. at " + + to_string( glm::dvec3{ vPosition } ) ); } - // Ra 2F1H: nie było sensu wpisywać tu zera po upływie czasu, bo - // zmienna była + } + } + // Ra 2F1H: nie było sensu wpisywać tu zera po upływie czasu, bo zmienna była // tymczasowa, a napięcie zerowane od razu tmpTraction.TractionVoltage = 0; // Ra 2013-12: po co tak? - // pControlled->MainSwitch(false); //może tak? } } } - // else //Ra: nie no, trzeba podnieść pantografy, jak nie będzie drutu, to - // będą miały prąd - // po osiągnięciu 1.4m - // tmpTraction.TractionVoltage=0.95*MoverParameters->EnginePowerSource.MaxVoltage; } else tmpTraction.TractionVoltage = 0.95 * MoverParameters->EnginePowerSource.MaxVoltage; @@ -2805,26 +2925,20 @@ bool TDynamicObject::Update(double dt, double dt1) if (Mechanik) { // Ra 2F3F: do Driver.cpp to przenieść? MoverParameters->EqvtPipePress = GetEPP(); // srednie cisnienie w PG - if ((Mechanik->Primary()) && - (MoverParameters->EngineType == ElectricInductionMotor)) // jesli glowny i z - // asynchronami, to - // niech steruje - { // hamulcem lacznie dla calego pociagu/ezt - bool kier = (DirectionGet() * MoverParameters->ActiveCab > 0); - float FED = 0; - int np = 0; - float masa = 0; - float FrED = 0; - float masamax = 0; - float FmaxPN = 0; - float FfulED = 0; - float FmaxED = 0; - float Fzad = 0; - float FzadED = 0; - float FzadPN = 0; - float Frj = 0; - float amax = 0; - float osie = 0; + if( ( Mechanik->Primary() ) + && ( MoverParameters->EngineType == TEngineType::ElectricInductionMotor ) ) { + // jesli glowny i z asynchronami, to niech steruje hamulcem lacznie dla calego pociagu/ezt + auto const kier = (DirectionGet() * MoverParameters->ActiveCab > 0); + auto FED { 0.0 }; + auto np { 0 }; + auto masa { 0.0 }; + auto FrED { 0.0 }; + auto masamax { 0.0 }; + auto FmaxPN { 0.0 }; + auto FfulED { 0.0 }; + auto FmaxED { 0.0 }; + auto Frj { 0.0 }; + auto osie { 0 }; // 1. ustal wymagana sile hamowania calego pociagu // - opoznienie moze byc ustalane na podstawie charakterystyki // - opoznienie moze byc ustalane na podstawie mas i cisnien granicznych @@ -2835,36 +2949,45 @@ bool TDynamicObject::Update(double dt, double dt1) for (TDynamicObject *p = GetFirstDynamic(MoverParameters->ActiveCab < 0 ? 1 : 0, 4); p; (kier ? p = p->NextC(4) : p = p->PrevC(4))) { - np++; - masamax += p->MoverParameters->MBPM + - (p->MoverParameters->MBPM > 1 ? 0 : p->MoverParameters->Mass) + - p->MoverParameters->Mred; - float Nmax = ((p->MoverParameters->P2FTrans * p->MoverParameters->MaxBrakePress[0] - + ++np; + masamax += + p->MoverParameters->MBPM + + ( p->MoverParameters->MBPM > 1.0 ? + 0.0 : + p->MoverParameters->Mass ) + + p->MoverParameters->Mred; + auto const Nmax = ((p->MoverParameters->P2FTrans * p->MoverParameters->MaxBrakePress[0] - p->MoverParameters->BrakeCylSpring) * p->MoverParameters->BrakeCylMult[0] - p->MoverParameters->BrakeSlckAdj) * p->MoverParameters->BrakeCylNo * p->MoverParameters->BrakeRigEff; FmaxPN += Nmax * p->MoverParameters->Hamulec->GetFC( Nmax / (p->MoverParameters->NAxles * p->MoverParameters->NBpA), - p->MoverParameters->Vmax) * + p->MoverParameters->MED_Vref) * 1000; // sila hamowania pn FmaxED += ((p->MoverParameters->Mains) && (p->MoverParameters->ActiveDir != 0) && (p->MoverParameters->eimc[eimc_p_Fh] * p->MoverParameters->NPoweredAxles > 0) ? p->MoverParameters->eimc[eimc_p_Fh] * 1000 : 0); // chwilowy max ED -> do rozdzialu sil - FED -= Min0R(p->MoverParameters->eimv[eimv_Fmax], 0) * + FED -= std::min(p->MoverParameters->eimv[eimv_Fmax], 0.0) * 1000; // chwilowy max ED -> do rozdzialu sil - FfulED = Min0R(p->MoverParameters->eimv[eimv_Fful], 0) * + FfulED = std::min(p->MoverParameters->eimv[eimv_Fful], 0.0) * 1000; // chwilowy max ED -> do rozdzialu sil - FrED -= Min0R(p->MoverParameters->eimv[eimv_Fr], 0) * + FrED -= std::min(p->MoverParameters->eimv[eimv_Fmax], 0.0) * 1000; // chwilowo realizowane ED -> do pneumatyki - Frj += Max0R(p->MoverParameters->eimv[eimv_Fr], 0) * + Frj += std::max(p->MoverParameters->eimv[eimv_Fmax], 0.0) * 1000;// chwilowo realizowany napęd -> do utrzymującego masa += p->MoverParameters->TotalMass; osie += p->MoverParameters->NAxles; } - amax = FmaxPN / masamax; + double RapidMult = 1.0; + if (((MoverParameters->BrakeDelays & (bdelay_P + bdelay_R)) == (bdelay_P + bdelay_R)) + && (MoverParameters->BrakeDelayFlag & bdelay_P)) + RapidMult = MoverParameters->RapidMult; + + auto const amax = RapidMult * std::min(FmaxPN / masamax, MoverParameters->MED_amax); + if ((MoverParameters->Vel < 0.5) && (MoverParameters->BrakePress > 0.2) || (dDoorMoveL > 0.001) || (dDoorMoveR > 0.001)) { @@ -2881,24 +3004,48 @@ bool TDynamicObject::Update(double dt, double dt1) MoverParameters->ShuntModeAllow = (MoverParameters->BrakePress > 0.2) && (MoverParameters->LocalBrakeRatio() < 0.01); } - Fzad = amax * MoverParameters->LocalBrakeRatio() * masa; + auto Fzad = amax * MoverParameters->LocalBrakeRatio() * masa; + if ((MoverParameters->BrakeCtrlPos == MoverParameters->Handle->GetPos(bh_EB)) + && (MoverParameters->eimc[eimc_p_abed] < 0.001)) + Fzad = amax * masa; //pętla bezpieczeństwa - pełne służbowe if ((MoverParameters->ScndS) && (MoverParameters->Vel > MoverParameters->eimc[eimc_p_Vh1]) && (FmaxED > 0)) { - Fzad = Min0R(MoverParameters->LocalBrakeRatio() * FmaxED, FfulED); + Fzad = std::min(MoverParameters->LocalBrakeRatio() * FmaxED, FfulED); } if (((MoverParameters->ShuntMode) && (Frj < 0.0015 * masa)) || (MoverParameters->V * MoverParameters->DirAbsolute < -0.2)) { - Fzad = Max0R(MoverParameters->StopBrakeDecc * masa, Fzad); + Fzad = std::max(MoverParameters->StopBrakeDecc * masa, Fzad); } - - if (MoverParameters->BrakeHandle == MHZ_EN57?MoverParameters->BrakeOpModeFlag & bom_MED:MoverParameters->EpFuse) - FzadED = Min0R(Fzad, FmaxED); - else - FzadED = 0; - FzadPN = Fzad - FrED; + if ((Fzad > 1) && (!MEDLogFile.is_open()) && (MoverParameters->Vel > 1)) + { + MEDLogFile.open( + "MEDLOGS/" + MoverParameters->Name + "_" + to_string( ++MEDLogCount ) + ".csv", + std::ios::in | std::ios::out | std::ios::trunc ); + MEDLogFile << "t\tVel\tMasa\tOsie\tFmaxPN\tFmaxED\tFfulED\tFrED\tFzad\tFzadED\tFzadPN"; + for(int k=1;k<=np;k++) + { + MEDLogFile << "\tBP" << k; + } + MEDLogFile << "\n"; + MEDLogFile.flush(); + MEDLogInactiveTime = 0; + MEDLogTime = 0; + } + auto FzadED { 0.0 }; + if( ( MoverParameters->EpFuse && (MoverParameters->BrakeHandle != TBrakeHandle::MHZ_EN57)) + || ( ( MoverParameters->BrakeHandle == TBrakeHandle::MHZ_EN57 ) + && ( MoverParameters->BrakeOpModeFlag & bom_MED ) ) ) { + FzadED = std::min( Fzad, FmaxED ); + } + if ((MoverParameters->BrakeCtrlPos == MoverParameters->Handle->GetPos(bh_EB)) + && (MoverParameters->eimc[eimc_p_abed] < 0.001)) + FzadED = 0; //pętla bezpieczeństwa - bez ED + auto const FzadPN = Fzad - FrED; //np = 0; + // BUG: likely memory leak, allocation per inner loop, deleted only once outside + // TODO: sort this shit out bool* PrzekrF = new bool[np]; float nPrzekrF = 0; bool test = true; @@ -2922,7 +3069,7 @@ bool TDynamicObject::Update(double dt, double dt1) for (TDynamicObject *p = GetFirstDynamic(MoverParameters->ActiveCab < 0 ? 1 : 0, 4); p; p = (kier == true ? p->NextC(4) : p->PrevC(4)) ) { - float Nmax = ((p->MoverParameters->P2FTrans * p->MoverParameters->MaxBrakePress[0] - + auto const Nmax = ((p->MoverParameters->P2FTrans * p->MoverParameters->MaxBrakePress[0] - p->MoverParameters->BrakeCylSpring) * p->MoverParameters->BrakeCylMult[0] - p->MoverParameters->BrakeSlckAdj) * @@ -2930,15 +3077,15 @@ bool TDynamicObject::Update(double dt, double dt1) FmaxEP[i] = Nmax * p->MoverParameters->Hamulec->GetFC( Nmax / (p->MoverParameters->NAxles * p->MoverParameters->NBpA), - p->MoverParameters->Vmax) * + p->MoverParameters->MED_Vref) * 1000; // sila hamowania pn PrzekrF[i] = false; FzED[i] = (FmaxED > 0 ? FzadED / FmaxED : 0); p->MoverParameters->AnPos = (MoverParameters->ScndS ? MoverParameters->LocalBrakeRatio() : FzED[i]); - FzEP[i] = FzadPN * p->MoverParameters->NAxles / osie; - i++; + FzEP[ i ] = static_cast( FzadPN * p->MoverParameters->NAxles ) / static_cast( osie ); + ++i; p->MoverParameters->ShuntMode = MoverParameters->ShuntMode; p->MoverParameters->ShuntModeAllow = MoverParameters->ShuntModeAllow; } @@ -2953,10 +3100,10 @@ bool TDynamicObject::Update(double dt, double dt1) if ((FzEP[i] > 0.01) && (FzEP[i] > p->MoverParameters->TotalMass * p->MoverParameters->eimc[eimc_p_eped] + - Min0R(p->MoverParameters->eimv[eimv_Fr], 0) * 1000) && + Min0R(p->MoverParameters->eimv[eimv_Fmax], 0) * 1000) && (!PrzekrF[i])) { - float przek1 = -Min0R(p->MoverParameters->eimv[eimv_Fr], 0) * 1000 + + float przek1 = -Min0R(p->MoverParameters->eimv[eimv_Fmax], 0) * 1000 + FzEP[i] - p->MoverParameters->TotalMass * p->MoverParameters->eimc[eimc_p_eped] * 0.999; @@ -2969,7 +3116,7 @@ bool TDynamicObject::Update(double dt, double dt1) FzEP[i] = 0; przek += przek1; } - i++; + ++i; } i = 0; przek = przek / (np - nPrzekrF); @@ -2980,7 +3127,7 @@ bool TDynamicObject::Update(double dt, double dt1) { FzEP[i] += przek; } - i++; + ++i; } } i = 0; @@ -2992,50 +3139,32 @@ bool TDynamicObject::Update(double dt, double dt1) p->MoverParameters->BrakeCylMult[0] - p->MoverParameters->BrakeSlckAdj) * p->MoverParameters->BrakeCylNo * p->MoverParameters->BrakeRigEff; + if (FrED > 0.1) + p->MoverParameters->MED_EPVC_CurrentTime = 0; + else + p->MoverParameters->MED_EPVC_CurrentTime += dt1; + bool EPVC = ((p->MoverParameters->MED_EPVC) && ((p->MoverParameters->MED_EPVC_Time < 0) || (p->MoverParameters->MED_EPVC_CurrentTime < p->MoverParameters->MED_EPVC_Time))); + float VelC = (EPVC ? clamp(p->MoverParameters->Vel, p->MoverParameters->MED_Vmin, p->MoverParameters->MED_Vmax) : p->MoverParameters->MED_Vref);//korekcja EP po prędkości float FmaxPoj = Nmax * p->MoverParameters->Hamulec->GetFC( - Nmax / (p->MoverParameters->NAxles * p->MoverParameters->NBpA), - p->MoverParameters->Vel) * + Nmax / (p->MoverParameters->NAxles * p->MoverParameters->NBpA), VelC) * 1000; // sila hamowania pn - p->MoverParameters->LocalBrakePosA = (p->MoverParameters->SlippingWheels ? 0 : FzEP[i] / FmaxPoj); - if (p->MoverParameters->LocalBrakePosA>0.009) + p->MoverParameters->LocalBrakePosAEIM = FzEP[i] / FmaxPoj; + if (p->MoverParameters->LocalBrakePosAEIM>0.009) if (p->MoverParameters->P2FTrans * p->MoverParameters->BrakeCylMult[0] * p->MoverParameters->MaxBrakePress[0] != 0) { float x = (p->MoverParameters->BrakeSlckAdj / p->MoverParameters->BrakeCylMult[0] + p->MoverParameters->BrakeCylSpring) / (p->MoverParameters->P2FTrans * p->MoverParameters->MaxBrakePress[0]); - p->MoverParameters->LocalBrakePosA = x + (1 - x) * p->MoverParameters->LocalBrakePosA; + p->MoverParameters->LocalBrakePosAEIM = x + (1 - x) * p->MoverParameters->LocalBrakePosAEIM; } else - p->MoverParameters->LocalBrakePosA = p->MoverParameters->LocalBrakePosA; + p->MoverParameters->LocalBrakePosAEIM = p->MoverParameters->LocalBrakePosAEIM; else - p->MoverParameters->LocalBrakePosA = 0; - i++; + p->MoverParameters->LocalBrakePosAEIM = 0; + ++i; } - /* ////ALGORYTM 1 - KAZDEMU PO ROWNO - for (TDynamicObject *p = GetFirstDynamic(MoverParameters->ActiveCab < 0 ? 1 : 0); p; - (iDirection > 0 ? p = p->NextC(4) : p = p->PrevC(4))) - { - - float Nmax = ((p->MoverParameters->P2FTrans * p->MoverParameters->MaxBrakePress[0] - - p->MoverParameters->BrakeCylSpring) * - p->MoverParameters->BrakeCylMult[0] - - p->MoverParameters->BrakeSlckAdj) * - p->MoverParameters->BrakeCylNo * p->MoverParameters->BrakeRigEff; - float FmaxPoj = Nmax * - p->MoverParameters->Hamulec->GetFC( - Nmax / (p->MoverParameters->NAxles * p->MoverParameters->NBpA), - p->MoverParameters->Vel) * - 1000; // sila hamowania pn - // Fpoj=(FED>0?-FzadED*p->MoverParameters->eimv[eimv_Fmax]*1000/FED:0); - // p->MoverParameters->AnPos=(p->MoverParameters->eimc[eimc_p_Fh]>1?0.001f*Fpoj/(p->MoverParameters->eimc[eimc_p_Fh]):0); - p->MoverParameters->AnPos = (FmaxED > 0 ? FzadED / FmaxED : 0); - // Fpoj = FzadPN * Min0R(p->MoverParameters->TotalMass / masa, 1); - // p->MoverParameters->LocalBrakePosA = - // (p->MoverParameters->SlippingWheels ? 0 : Min0R(Max0R(Fpoj / FmaxPoj, 0), 1)); - p->MoverParameters->LocalBrakePosA = (p->MoverParameters->SlippingWheels ? 0 : FzadPN / FmaxPN); - } */ MED[0][0] = masa*0.001; MED[0][1] = amax; @@ -3046,164 +3175,160 @@ bool TDynamicObject::Update(double dt, double dt1) MED[0][6] = FzadPN*0.001; MED[0][7] = nPrzekrF; + if (MEDLogFile.is_open()) + { + MEDLogFile << MEDLogTime << "\t" << MoverParameters->Vel << "\t" << masa*0.001 << "\t" << osie << "\t" << FmaxPN*0.001 << "\t" << FmaxED*0.001 << "\t" + << FfulED*0.001 << "\t" << FrED*0.001 << "\t" << Fzad*0.001 << "\t" << FzadED*0.001 << "\t" << FzadPN*0.001; + for (TDynamicObject *p = GetFirstDynamic(MoverParameters->ActiveCab < 0 ? 1 : 0, 4); p; + (true == kier ? p = p->NextC(4) : p = p->PrevC(4))) + { + MEDLogFile << "\t" << p->MoverParameters->BrakePress; + } + MEDLogFile << "\n"; + if (floor(MEDLogTime + dt1) > floor(MEDLogTime)) + { + MEDLogFile.flush(); + } + MEDLogTime += dt1; + + if ((MoverParameters->Vel < 0.1) || (MoverParameters->MainCtrlPos > 0)) + { + MEDLogInactiveTime += dt1; + } + else + { + MEDLogInactiveTime = 0; + } + if (MEDLogInactiveTime > 5) + { + MEDLogFile.flush(); + MEDLogFile.close(); + } + + } + delete[] PrzekrF; delete[] FzED; delete[] FzEP; delete[] FmaxEP; } - // yB: cos (AI) tu jest nie kompatybilne z czyms (hamulce) - // if (Controller!=Humandriver) - // if (Mechanik->LastReactionTime>0.5) - // { - // MoverParameters->BrakeCtrlPos=0; - // Mechanik->LastReactionTime=0; - // } - Mechanik->UpdateSituation(dt1); // przebłyski świadomości AI } // fragment "z EXE Kursa" - if (MoverParameters->Mains) // nie wchodzić w funkcję bez potrzeby - if ((!MoverParameters->Battery) && (Controller == Humandriver) && - (MoverParameters->EngineType != DieselEngine) && - (MoverParameters->EngineType != WheelsDriven)) - { // jeśli bateria wyłączona, a nie diesel ani drezyna - // reczna - if (MoverParameters->MainSwitch(false)) // wyłączyć zasilanie + if( MoverParameters->Mains ) { // nie wchodzić w funkcję bez potrzeby + if( ( false == MoverParameters->Battery ) + && ( false == MoverParameters->ConverterFlag ) // added alternative power source. TODO: more generic power check +/* + // NOTE: disabled on account of multi-unit setups, where the unmanned unit wouldn't be affected + && ( Controller == Humandriver ) +*/ + && ( MoverParameters->EngineType != TEngineType::DieselEngine ) + && ( MoverParameters->EngineType != TEngineType::WheelsDriven ) ) { // jeśli bateria wyłączona, a nie diesel ani drezyna reczna + if( MoverParameters->MainSwitch( false, ( MoverParameters->TrainType == dt_EZT ? range_t::unit : range_t::local ) ) ) { + // wyłączyć zasilanie + // NOTE: we turn off entire EMU, but only the affected unit for other multi-unit consists MoverParameters->EventFlag = true; + // drop pantographs + // NOTE: this isn't universal behaviour + // TODO: have this dependant on .fiz-driven flag + // NOTE: moved to pantspeed calculation part a little later in the function. all remarks and todo still apply +/* + MoverParameters->PantFront( false, ( MoverParameters->TrainType == dt_EZT ? range::unit : range::local ) ); + MoverParameters->PantRear( false, ( MoverParameters->TrainType == dt_EZT ? range::unit : range::local ) ); +*/ + } } - if (MoverParameters->TrainType == dt_ET42) - { // powinny być wszystkie dwuczłony oraz EZT - /* - //Ra: to jest bez sensu, bo wyłącza WS przy przechodzeniu przez - "wewnętrzne" kabiny (z - powodu ActiveCab) - //trzeba to zrobić inaczej, np. dla członu A sprawdzać, czy jest B - //albo sprawdzać w momencie załączania WS i zmiany w sprzęgach - if - (((TestFlag(MoverParameters->Couplers[1].CouplingFlag,ctrain_controll))&&(MoverParameters->ActiveCab>0)&&(NextConnected->MoverParameters->TrainType!=dt_ET42))||((TestFlag(MoverParameters->Couplers[0].CouplingFlag,ctrain_controll))&&(MoverParameters->ActiveCab<0)&&(PrevConnected->MoverParameters->TrainType!=dt_ET42))) - {//sprawdzenie, czy z tyłu kabiny mamy drugi człon - if (MoverParameters->MainSwitch(false)) - MoverParameters->EventFlag=true; - } - if - ((!(TestFlag(MoverParameters->Couplers[1].CouplingFlag,ctrain_controll))&&(MoverParameters->ActiveCab>0))||(!(TestFlag(MoverParameters->Couplers[0].CouplingFlag,ctrain_controll))&&(MoverParameters->ActiveCab<0))) - { - if (MoverParameters->MainSwitch(false)) - MoverParameters->EventFlag=true; - } - */ } + // przekazanie pozycji do fizyki + // NOTE: coordinate system swap + // TODO: replace with regular glm vectors + TLocation const l { + -vPosition.x, + vPosition.z, + vPosition.y }; + TRotation r { 0.0, 0.0, 0.0 }; // McZapkie-260202 - dMoveLen przyda sie przy stukocie kol - dDOMoveLen = - GetdMoveLen() + MoverParameters->ComputeMovement(dt, dt1, ts, tp, tmpTraction, l, r); - // yB: zeby zawsze wrzucalo w jedna strone zakretu - MoverParameters->AccN *= -ABuGetDirection(); - // if (dDOMoveLen!=0.0) //Ra: nie może być, bo blokuje Event0 + dDOMoveLen = GetdMoveLen() + MoverParameters->ComputeMovement(dt, dt1, ts, tp, tmpTraction, l, r); + if( Mechanik ) + Mechanik->MoveDistanceAdd( dDOMoveLen ); // dodanie aktualnego przemieszczenia Move(dDOMoveLen); if (!bEnabled) // usuwane pojazdy nie mają toru { // pojazd do usunięcia - Global::pGround->bDynamicRemove = true; // sprawdzić + bDynamicRemove = true; // sprawdzić return false; } - Global::ABuDebug = dDOMoveLen / dt1; ResetdMoveLen(); + // McZapkie-260202 // tupot mew, tfu, stukot kol: - DWORD stat; - // taka prowizorka zeby sciszyc stukot dalekiej lokomotywy - double ObjectDist; - double vol = 0; - // double freq; //Ra: nie używane - ObjectDist = SquareMagnitude(Global::pCameraPosition - vPosition); - // McZapkie-270202 - if (MyTrack->fSoundDistance != -1) - { - if (ObjectDist < rsStukot[0].dSoundAtt * rsStukot[0].dSoundAtt * 15.0) - { - vol = (20.0 + MyTrack->iDamageFlag) / 21; - if (MyTrack->eEnvironment == e_tunnel) - { - vol *= 1.1; - // freq=1.02; + if( MyTrack->fSoundDistance != -1 ) { + + if( MyTrack->fSoundDistance != dRailLength ) { + dRailLength = MyTrack->fSoundDistance; + for( auto &axle : m_axlesounds ) { + axle.distance = axle.offset + MoverParameters->Dim.L; } - else if (MyTrack->eEnvironment == e_bridge) - { - vol *= 1.2; - // freq=0.99; //MC: stukot w zaleznosci od - // tego gdzie - // jest tor - } - if (MyTrack->fSoundDistance != dRailLength) - { - dRailLength = MyTrack->fSoundDistance; - for (int i = 0; i < iAxles; i++) - { - dRailPosition[i] = dWheelsPosition[i] + MoverParameters->Dim.L; + } + if( dRailLength != -1 ) { + if( MoverParameters->Vel > 0 ) { + // TODO: track quality and/or environment factors as separate subroutine + auto volume = + interpolate( + 0.8, 1.2, + clamp( + MyTrack->iQualityFlag / 20.0, + 0.0, 1.0 ) ); + switch( MyTrack->eEnvironment ) { + case e_tunnel: { + volume *= 1.1; + break; + } + case e_bridge: { + volume *= 1.2; + break; + } + default: { + break; + } } - } - if (dRailLength != -1) - { - if (abs(MoverParameters->V) > 0) - { - for (int i = 0; i < iAxles; i++) - { - dRailPosition[i] -= dDOMoveLen * Sign(dDOMoveLen); - if (dRailPosition[i] < 0) - { - // McZapkie-040302 - if (i == iAxles - 1) - { - rsStukot[0].Stop(); - MoverParameters->AccV += - 0.5 * GetVelocity() / (1 + MoverParameters->Vmax); - } - else - { - rsStukot[i + 1].Stop(); - } - rsStukot[i].Play(vol, 0, MechInside, - vPosition); // poprawic pozycje o uklad osi - if (i == 1) - MoverParameters->AccV -= - 0.5 * GetVelocity() / (1 + MoverParameters->Vmax); - dRailPosition[i] += dRailLength; + + auto axleindex { 0 }; + for( auto &axle : m_axlesounds ) { + axle.distance -= dDOMoveLen * Sign( dDOMoveLen ); + if( axle.distance < 0 ) { + axle.distance += dRailLength; + if( MoverParameters->Vel > 2.5 ) { + // NOTE: for combined clatter sound we supply 1/100th of actual value, as the sound module converts does the opposite, converting received (typically) 0-1 values to 0-100 range + auto const frequency = ( + true == axle.clatter.is_combined() ? + MoverParameters->Vel * 0.01 : + 1.0 ); + axle.clatter + .pitch( frequency ) + .gain( volume ) + .play(); + // crude bump simulation, drop down on even axles, move back up on the odd ones + MoverParameters->AccVert += + interpolate( + 0.01, 0.05, + clamp( + GetVelocity() / ( 1 + MoverParameters->Vmax ), + 0.0, 1.0 ) ) + * ( ( axleindex % 2 ) != 0 ? + 1 : + -1 ); } } + ++axleindex; } } } } // McZapkie-260202 end - // yB: przyspieszacz (moze zadziala, ale dzwiek juz jest) - int flag = MoverParameters->Hamulec->GetSoundFlag(); - if ((bBrakeAcc) && (TestFlag(flag, sf_Acc)) && (ObjectDist < 2500)) - { - sBrakeAcc->SetVolume(-ObjectDist * 3 - (FreeFlyModeFlag ? 0 : 2000)); - sBrakeAcc->Play(0, 0, 0); - sBrakeAcc->SetPan(10000 * sin(ModCamRot)); - } - if ((rsUnbrake.AM != 0) && (ObjectDist < 5000)) - { - if ((TestFlag(flag, sf_CylU)) && - ((MoverParameters->BrakePress * MoverParameters->MaxBrakePress[3]) > 0.05)) - { - vol = Min0R( - 0.2 + - 1.6 * sqrt((MoverParameters->BrakePress > 0 ? MoverParameters->BrakePress : 0) / - MoverParameters->MaxBrakePress[3]), - 1); - vol = vol + (FreeFlyModeFlag ? 0 : -0.5) - ObjectDist / 5000; - rsUnbrake.SetPan(10000 * sin(ModCamRot)); - rsUnbrake.Play(vol, DSBPLAY_LOOPING, MechInside, GetPosition()); - } - else - rsUnbrake.Stop(); - } - // fragment z EXE Kursa /* if (MoverParameters->TrainType==dt_ET42) { @@ -3222,25 +3347,6 @@ bool TDynamicObject::Update(double dt, double dt1) } } */ - if ((MoverParameters->TrainType == dt_ET40) || (MoverParameters->TrainType == dt_EP05)) - { // dla ET40 i EU05 automatyczne cofanie nastawnika - i tak - // nie będzie to działać dobrze... - /* if - ((MoverParameters->MainCtrlPos>MoverParameters->MainCtrlActualPos)&&(abs(MoverParameters->Im)>MoverParameters->IminHi)) - { - MoverParameters->DecMainCtrl(1); - } */ - if ((!Console::Pressed(Global::Keys[k_IncMainCtrl])) && - (MoverParameters->MainCtrlPos > MoverParameters->MainCtrlActualPos)) - { - MoverParameters->DecMainCtrl(1); - } - if ((!Console::Pressed(Global::Keys[k_DecMainCtrl])) && - (MoverParameters->MainCtrlPos < MoverParameters->MainCtrlActualPos)) - { - MoverParameters->IncMainCtrl(1); // Ra 15-01: a to nie miało być tylko cofanie? - } - } if (MoverParameters->Vel != 0) { // McZapkie-050402: krecenie kolami: @@ -3262,10 +3368,11 @@ bool TDynamicObject::Update(double dt, double dt1) double k; // tymczasowy kąt double PantDiff; TAnimPant *p; // wskaźnik do obiektu danych pantografu - double fCurrent = (MoverParameters->DynamicBrakeFlag && MoverParameters->ResistorsFlag ? - 0 : - MoverParameters->Itot) + - MoverParameters->TotalCurrent; // prąd pobierany przez pojazd - bez + double fCurrent = ( + ( MoverParameters->DynamicBrakeFlag && MoverParameters->ResistorsFlag ) ? + 0 : + MoverParameters->Itot ) + + MoverParameters->TotalCurrent; // prąd pobierany przez pojazd - bez // sensu z tym (TotalCurrent) // TotalCurrent to bedzie prad nietrakcyjny (niezwiazany z napedem) // fCurrent+=fabs(MoverParameters->Voltage)*1e-6; //prąd płynący przez @@ -3302,8 +3409,8 @@ bool TDynamicObject::Update(double dt, double dt1) switch (i) // numer pantografu { // trzeba usunąć to rozróżnienie case 0: - if( ( Global::bLiveTraction == false ) - && ( p->hvPowerWire == nullptr ) ) { + if( ( Global.bLiveTraction == false ) + && ( p->hvPowerWire == nullptr ) ) { // jeśli nie ma drutu, może pooszukiwać MoverParameters->PantFrontVolt = ( p->PantWys >= 1.2 ) ? @@ -3313,16 +3420,21 @@ bool TDynamicObject::Update(double dt, double dt1) else if( ( true == MoverParameters->PantFrontUp ) && ( PantDiff < 0.01 ) ) // tolerancja niedolegania { - if ((MoverParameters->PantFrontVolt == 0.0) && - (MoverParameters->PantRearVolt == 0.0)) - sPantUp.Play(vol, 0, MechInside, vPosition); - if (p->hvPowerWire) // TODO: wyliczyć trzeba prąd przypadający na - // pantograf i - // wstawić do GetVoltage() - { - MoverParameters->PantFrontVolt = - p->hvPowerWire->VoltageGet(MoverParameters->Voltage, fPantCurrent); + if (p->hvPowerWire) { + auto const lastvoltage { MoverParameters->PantFrontVolt }; + // TODO: wyliczyć trzeba prąd przypadający na pantograf i wstawić do GetVoltage() + MoverParameters->PantFrontVolt = p->hvPowerWire->VoltageGet( MoverParameters->Voltage, fPantCurrent ); fCurrent -= fPantCurrent; // taki prąd płynie przez powyższy pantograf + // TODO: refactor reaction to voltage change to mover as sound event for specific pantograph + if( ( lastvoltage == 0.0 ) + && ( MoverParameters->PantFrontVolt > 0.0 ) ) { + for( auto &pantograph : m_pantographsounds ) { + if( pantograph.sPantUp.offset().z > 0 ) { + // limit to pantographs located in the front half of the vehicle + pantograph.sPantUp.play( sound_flags::exclusive ); + } + } + } } else MoverParameters->PantFrontVolt = 0.0; @@ -3331,7 +3443,7 @@ bool TDynamicObject::Update(double dt, double dt1) MoverParameters->PantFrontVolt = 0.0; break; case 1: - if( ( false == Global::bLiveTraction ) + if( ( false == Global.bLiveTraction ) && ( nullptr == p->hvPowerWire ) ) { // jeśli nie ma drutu, może pooszukiwać MoverParameters->PantRearVolt = @@ -3342,61 +3454,69 @@ bool TDynamicObject::Update(double dt, double dt1) else if ( ( true == MoverParameters->PantRearUp ) && ( PantDiff < 0.01 ) ) { - if ((MoverParameters->PantRearVolt == 0.0) && - (MoverParameters->PantFrontVolt == 0.0)) - sPantUp.Play(vol, 0, MechInside, vPosition); - if (p->hvPowerWire) // TODO: wyliczyć trzeba prąd przypadający na - // pantograf i - // wstawić do GetVoltage() - { - MoverParameters->PantRearVolt = - p->hvPowerWire->VoltageGet(MoverParameters->Voltage, fPantCurrent); + if (p->hvPowerWire) { + auto const lastvoltage { MoverParameters->PantRearVolt }; + // TODO: wyliczyć trzeba prąd przypadający na pantograf i wstawić do GetVoltage() + MoverParameters->PantRearVolt = p->hvPowerWire->VoltageGet( MoverParameters->Voltage, fPantCurrent ); fCurrent -= fPantCurrent; // taki prąd płynie przez powyższy pantograf + // TODO: refactor reaction to voltage change to mover as sound event for specific pantograph + if( ( lastvoltage == 0.0 ) + && ( MoverParameters->PantRearVolt > 0.0 ) ) { + for( auto &pantograph : m_pantographsounds ) { + if( pantograph.sPantUp.offset().z < 0 ) { + // limit to pantographs located in the rear half of the vehicle + pantograph.sPantUp.play( sound_flags::exclusive ); + } + } + } } else MoverParameters->PantRearVolt = 0.0; } - else + else { +// Global.iPause ^= 2; MoverParameters->PantRearVolt = 0.0; + } break; } // pozostałe na razie nie obsługiwane - if (MoverParameters->PantPress > - (MoverParameters->TrainType == dt_EZT ? 2.5 : 3.3)) // Ra 2013-12: - // Niebugocław - // mówi, że w EZT - // podnoszą się - // przy 2.5 - pantspeedfactor = 0.015 * (MoverParameters->PantPress) * - dt1; // z EXE Kursa //Ra: wysokość zależy od ciśnienia !!! - else + if( MoverParameters->PantPress > ( + MoverParameters->TrainType == dt_EZT ? + 2.45 : // Ra 2013-12: Niebugocław mówi, że w EZT podnoszą się przy 2.5 + 3.45 ) ) { + // z EXE Kursa + // Ra: wysokość zależy od ciśnienia !!! + pantspeedfactor = 0.015 * ( MoverParameters->PantPress ) * dt1; + } + else { pantspeedfactor = 0.0; - if (pantspeedfactor < 0) - pantspeedfactor = 0; + } + if( ( false == MoverParameters->Battery ) + && ( false == MoverParameters->ConverterFlag ) ) { + pantspeedfactor = 0.0; + } + pantspeedfactor = std::max( 0.0, pantspeedfactor ); k = p->fAngleL; - if (i ? MoverParameters->PantRearUp : - MoverParameters->PantFrontUp) // jeśli ma być podniesiony + if( ( pantspeedfactor > 0.0 ) + && ( i ? + MoverParameters->PantRearUp : + MoverParameters->PantFrontUp ) )// jeśli ma być podniesiony { if (PantDiff > 0.001) // jeśli nie dolega do drutu - { // jeśli poprzednia wysokość jest mniejsza niż pożądana, zwiększyć kąt - // dolnego + { // jeśli poprzednia wysokość jest mniejsza niż pożądana, zwiększyć kąt dolnego // ramienia zgodnie z ciśnieniem if (pantspeedfactor > 0.55 * PantDiff) // 0.55 to około pochodna kąta po wysokości k += 0.55 * PantDiff; // ograniczenie "skoku" w danej klatce else k += pantspeedfactor; // dolne ramię - // jeśli przekroczono kąt graniczny, zablokować pantograf (wymaga - // interwencji - // pociągu sieciowego) + // jeśli przekroczono kąt graniczny, zablokować pantograf + // (wymaga interwencji pociągu sieciowego) } - else if (PantDiff < -0.001) - { // drut się obniżył albo pantograf - // podniesiony za wysoko + else if (PantDiff < -0.001) { + // drut się obniżył albo pantograf podniesiony za wysoko // jeśli wysokość jest zbyt duża, wyznaczyć zmniejszenie kąta - // jeśli zmniejszenie kąta jest zbyt duże, przejść do trybu łamania - // pantografu - // if (PantFrontDiff<-0.05) //skok w dół o 5cm daje złąmanie - // pantografu + // jeśli zmniejszenie kąta jest zbyt duże, przejść do trybu łamania pantografu + // if (PantFrontDiff<-0.05) //skok w dół o 5cm daje złąmanie pantografu k += 0.4 * PantDiff; // mniej niż pochodna kąta po wysokości } // jeśli wysokość jest dobra, nic więcej nie liczyć } @@ -3418,34 +3538,47 @@ bool TDynamicObject::Update(double dt, double dt1) p->fAngleU = acos((p->fLenL1 * cos(k) + p->fHoriz) / p->fLenU1); // górne ramię // wyliczyć aktualną wysokość z wzoru sinusowego // h=a*sin()+b*sin() - p->PantWys = p->fLenL1 * sin(k) + p->fLenU1 * sin(p->fAngleU) + - p->fHeight; // wysokość całości + // wysokość całości + p->PantWys = p->fLenL1 * sin(k) + p->fLenU1 * sin(p->fAngleU) + p->fHeight; } } } // koniec pętli po pantografach if ((MoverParameters->PantFrontSP == false) && (MoverParameters->PantFrontUp == false)) { - sPantDown.Play(vol, 0, MechInside, vPosition); + for( auto &pantograph : m_pantographsounds ) { + if( pantograph.sPantDown.offset().z > 0 ) { + // limit to pantographs located in the front half of the vehicle + pantograph.sPantDown.play( sound_flags::exclusive ); + } + } MoverParameters->PantFrontSP = true; } if ((MoverParameters->PantRearSP == false) && (MoverParameters->PantRearUp == false)) { - sPantDown.Play(vol, 0, MechInside, vPosition); + for( auto &pantograph : m_pantographsounds ) { + if( pantograph.sPantDown.offset().z < 0 ) { + // limit to pantographs located in the rear half of the vehicle + pantograph.sPantDown.play( sound_flags::exclusive ); + } + } MoverParameters->PantRearSP = true; } +/* + // NOTE: disabled because it's both redundant and doesn't take into account alternative power sources + // converter and compressor will (should) turn off during their individual checks, in the mover's (fast)computemovement() calls if (MoverParameters->EnginePowerSource.SourceType == CurrentCollector) { // Winger 240404 - wylaczanie sprezarki i // przetwornicy przy braku napiecia if (tmpTraction.TractionVoltage == 0) { // to coś wyłączało dźwięk silnika w ST43! MoverParameters->ConverterFlag = false; - MoverParameters->CompressorFlag = false; // Ra: to jest wątpliwe - wyłączenie - // sprężarki powinno być w jednym miejscu! + MoverParameters->CompressorFlag = false; // Ra: to jest wątpliwe - wyłączenie sprężarki powinno być w jednym miejscu! } } +*/ } - else if (MoverParameters->EnginePowerSource.SourceType == InternalSource) - if (MoverParameters->EnginePowerSource.PowerType == SteamPower) + else if (MoverParameters->EnginePowerSource.SourceType == TPowerSource::InternalSource) + if (MoverParameters->EnginePowerSource.PowerType == TPowerType::SteamPower) // if (smPatykird1[0]) { // Ra: animacja rozrządu parowozu, na razie nieoptymalizowane /* //Ra: tymczasowo wyłączone ze względu na porządkowanie animacji @@ -3528,70 +3661,158 @@ bool TDynamicObject::Update(double dt, double dt1) } // NBMX Obsluga drzwi, MC: zuniwersalnione - if ((dDoorMoveL < MoverParameters->DoorMaxShiftL) && (MoverParameters->DoorLeftOpened)) - { - rsDoorOpen.Play(vol, 0, MechInside, vPosition); - dDoorMoveL += dt1 * 0.5 * MoverParameters->DoorOpenSpeed; - } - if ((dDoorMoveL > 0) && (!MoverParameters->DoorLeftOpened)) - { - rsDoorClose.Play(vol, 0, MechInside, vPosition); - dDoorMoveL -= dt1 * MoverParameters->DoorCloseSpeed; - if (dDoorMoveL < 0) - dDoorMoveL = 0; - } - if ((dDoorMoveR < MoverParameters->DoorMaxShiftR) && (MoverParameters->DoorRightOpened)) - { - rsDoorOpen.Play(vol, 0, MechInside, vPosition); - dDoorMoveR += dt1 * 0.5 * MoverParameters->DoorOpenSpeed; - } - if ((dDoorMoveR > 0) && (!MoverParameters->DoorRightOpened)) - { - rsDoorClose.Play(vol, 0, MechInside, vPosition); - dDoorMoveR -= dt1 * MoverParameters->DoorCloseSpeed; - if (dDoorMoveR < 0) - dDoorMoveR = 0; - } - - // ABu-160303 sledzenie toru przed obiektem: ******************************* - // Z obserwacji: v>0 -> Coupler 0; v<0 ->coupler1 (Ra: prędkość jest związana - // z pojazdem) - // Rozroznienie jest tutaj, zeby niepotrzebnie nie skakac do funkcji. Nie jest - // uzaleznione - // od obecnosci AI, zeby uwzglednic np. jadace bez lokomotywy wagony. - // Ra: można by przenieść na poziom obiektu reprezentującego skład, aby nie - // sprawdzać środkowych - if (CouplCounter > 25) // licznik, aby nie robić za każdym razem - { // poszukiwanie czegoś do zderzenia się - fTrackBlock = 10000.0; // na razie nie ma przeszkód (na wypadek nie - // uruchomienia skanowania) - // jeśli nie ma zwrotnicy po drodze, to tylko przeliczyć odległość? - if (MoverParameters->V > 0.03) //[m/s] jeśli jedzie do przodu (w kierunku Coupler 0) - { - if (MoverParameters->Couplers[0].CouplingFlag == - ctrain_virtual) // brak pojazdu podpiętego? - { - ABuScanObjects(1, fScanDist); // szukanie czegoś do podłączenia - // WriteLog(asName+" - block 0: "+AnsiString(fTrackBlock)); + // TODO: fully generalized door assembly + if( ( dDoorMoveL < MoverParameters->DoorMaxShiftL ) + && ( true == MoverParameters->DoorLeftOpened ) ) { + // open left door + if( ( MoverParameters->TrainType == dt_EZT ) + || ( MoverParameters->TrainType == dt_DMU ) ) { + // multi-unit vehicles typically open door only after unfolding the doorstep + if( ( MoverParameters->PlatformMaxShift == 0.0 ) // no wait if no doorstep + || ( MoverParameters->PlatformOpenMethod == 2 ) // no wait for rotating doorstep + || ( dDoorstepMoveL == 1.0 ) ) { + dDoorMoveL = std::min( + MoverParameters->DoorMaxShiftL, + dDoorMoveL + MoverParameters->DoorOpenSpeed * dt1 ); } } - else if (MoverParameters->V < -0.03) //[m/s] jeśli jedzie do tyłu (w kierunku Coupler 1) - if (MoverParameters->Couplers[1].CouplingFlag == - ctrain_virtual) // brak pojazdu podpiętego? - { - ABuScanObjects(-1, fScanDist); - // WriteLog(asName+" - block 1: "+AnsiString(fTrackBlock)); + else { + dDoorMoveL = std::min( + MoverParameters->DoorMaxShiftL, + dDoorMoveL + MoverParameters->DoorOpenSpeed * dt1 ); + } + DoorDelayL = 0.f; + } + if( ( dDoorMoveL > 0.0 ) + && ( false == MoverParameters->DoorLeftOpened ) ) { + // close left door + DoorDelayL += dt1; + if( DoorDelayL > MoverParameters->DoorCloseDelay ) { + dDoorMoveL -= dt1 * MoverParameters->DoorCloseSpeed; + dDoorMoveL = std::max( dDoorMoveL, 0.0 ); + } + } + if( ( dDoorMoveR < MoverParameters->DoorMaxShiftR ) + && ( true == MoverParameters->DoorRightOpened ) ) { + // open right door + if( ( MoverParameters->TrainType == dt_EZT ) + || ( MoverParameters->TrainType == dt_DMU ) ) { + // multi-unit vehicles typically open door only after unfolding the doorstep + if( ( MoverParameters->PlatformMaxShift == 0.0 ) // no wait if no doorstep + || ( MoverParameters->PlatformOpenMethod == 2 ) // no wait for rotating doorstep + || ( dDoorstepMoveR == 1.0 ) ) { + dDoorMoveR = std::min( + MoverParameters->DoorMaxShiftR, + dDoorMoveR + MoverParameters->DoorOpenSpeed * dt1 ); } - CouplCounter = Random(20); // ponowne sprawdzenie po losowym czasie + } + else { + dDoorMoveR = std::min( + MoverParameters->DoorMaxShiftR, + dDoorMoveR + MoverParameters->DoorOpenSpeed * dt1 ); + } + DoorDelayR = 0.f; } - if (MoverParameters->Vel > 0.1) //[km/h] - ++CouplCounter; // jazda sprzyja poszukiwaniu połączenia - else - { - CouplCounter = 25; // a bezruch nie, ale trzeba zaktualizować odległość, bo - // zawalidroga może - // sobie pojechać + if( ( dDoorMoveR > 0.0 ) + && ( false == MoverParameters->DoorRightOpened ) ) { + // close right door + DoorDelayR += dt1; + if( DoorDelayR > MoverParameters->DoorCloseDelay ) { + dDoorMoveR -= dt1 * MoverParameters->DoorCloseSpeed; + dDoorMoveR = std::max( dDoorMoveR, 0.0 ); + } } + // doorsteps + if( ( dDoorstepMoveL < 1.0 ) + && ( true == MoverParameters->DoorLeftOpened ) ) { + // unfold left doorstep + dDoorstepMoveL = std::min( + 1.0, + dDoorstepMoveL + MoverParameters->PlatformSpeed * dt1 ); + } + if( ( dDoorstepMoveL > 0.0 ) + && ( false == MoverParameters->DoorLeftOpened ) + && ( DoorDelayL > MoverParameters->DoorCloseDelay ) ) { + // fold left doorstep + if( ( MoverParameters->TrainType == dt_EZT ) + || ( MoverParameters->TrainType == dt_DMU ) ) { + // multi-unit vehicles typically fold the doorstep only after closing the door + if( dDoorMoveL == 0.0 ) { + dDoorstepMoveL = std::max( + 0.0, + dDoorstepMoveL - MoverParameters->PlatformSpeed * dt1 ); + } + } + else { + dDoorstepMoveL = std::max( + 0.0, + dDoorstepMoveL - MoverParameters->PlatformSpeed * dt1 ); + } + } + if( ( dDoorstepMoveR < 1.0 ) + && ( true == MoverParameters->DoorRightOpened ) ) { + // unfold right doorstep + dDoorstepMoveR = std::min( + 1.0, + dDoorstepMoveR + MoverParameters->PlatformSpeed * dt1 ); + } + if( ( dDoorstepMoveR > 0.0 ) + && ( false == MoverParameters->DoorRightOpened ) + && ( DoorDelayR > MoverParameters->DoorCloseDelay ) ) { + // fold right doorstep + if( ( MoverParameters->TrainType == dt_EZT ) + || ( MoverParameters->TrainType == dt_DMU ) ) { + // multi-unit vehicles typically fold the doorstep only after closing the door + if( dDoorMoveR == 0.0 ) { + dDoorstepMoveR = std::max( + 0.0, + dDoorstepMoveR - MoverParameters->PlatformSpeed * dt1 ); + } + } + else { + dDoorstepMoveR = std::max( + 0.0, + dDoorstepMoveR - MoverParameters->PlatformSpeed * dt1 ); + } + } + // mirrors + if( MoverParameters->Vel > 5.0 ) { + // automatically fold mirrors when above velocity threshold + if( dMirrorMoveL > 0.0 ) { + dMirrorMoveL = std::max( + 0.0, + dMirrorMoveL - 1.0 * dt1 ); + } + if( dMirrorMoveR > 0.0 ) { + dMirrorMoveR = std::max( + 0.0, + dMirrorMoveR - 1.0 * dt1 ); + } + } + else { + // unfold mirror on the side with open doors, if not moving too fast + if( ( dMirrorMoveL < 1.0 ) + && ( true == MoverParameters->DoorLeftOpened ) ) { + dMirrorMoveL = std::min( + 1.0, + dMirrorMoveL + 1.0 * dt1 ); + } + if( ( dMirrorMoveR < 1.0 ) + && ( true == MoverParameters->DoorRightOpened ) ) { + dMirrorMoveR = std::min( + 1.0, + dMirrorMoveR + 1.0 * dt1 ); + } + } + + // compartment lights + // if the vehicle has a controller, we base the light state on state of the controller otherwise we check the vehicle itself + if( ( ctOwner != nullptr ? + ctOwner->Controlling()->Battery != SectionLightsActive : + SectionLightsActive == true ) ) { // without controller lights are off. NOTE: this likely mess up the EMU + toggle_lights(); + } + if (MoverParameters->DerailReason > 0) { switch (MoverParameters->DerailReason) @@ -3611,9 +3832,12 @@ bool TDynamicObject::Update(double dt, double dt1) } MoverParameters->DerailReason = 0; //żeby tylko raz } - if (MoverParameters->LoadStatus) + + if( MoverParameters->LoadStatus ) { LoadUpdate(); // zmiana modelu ładunku - + } + update_exchange( dt ); + return true; // Ra: chyba tak? } @@ -3628,13 +3852,13 @@ bool TDynamicObject::FastUpdate(double dt) if (!bEnabled) return false; - TLocation l; - l.X = -vPosition.x; - l.Y = vPosition.z; - l.Z = vPosition.y; - TRotation r; - r.Rx = r.Ry = r.Rz = 0.0; - + // NOTE: coordinate system swap + // TODO: replace with regular glm vectors + TLocation const l { + -vPosition.x, + vPosition.z, + vPosition.y }; + TRotation r { 0.0, 0.0, 0.0 }; // McZapkie: parametry powinny byc pobierane z toru // ts.R=MyTrack->fRadius; // ts.Len= Max0R(MoverParameters->BDist,MoverParameters->ADist); @@ -3651,8 +3875,11 @@ bool TDynamicObject::FastUpdate(double dt) // ResetdMoveLen(); FastMove(dDOMoveLen); - if (MoverParameters->LoadStatus) + if( MoverParameters->LoadStatus ) { LoadUpdate(); // zmiana modelu ładunku + } + update_exchange( dt ); + return true; // Ra: chyba tak? } @@ -3666,8 +3893,8 @@ void TDynamicObject::TurnOff() { // wyłączenie rysowania submodeli zmiennych dla // egemplarza pojazdu btnOn = false; - btCoupler1.TurnOff(); - btCoupler2.TurnOff(); + btCoupler1.Turn( false ); + btCoupler2.Turn( false ); btCPneumatic1.TurnOff(); btCPneumatic1r.TurnOff(); btCPneumatic2.TurnOff(); @@ -3676,921 +3903,709 @@ void TDynamicObject::TurnOff() btPneumatic1r.TurnOff(); btPneumatic2.TurnOff(); btPneumatic2r.TurnOff(); - btCCtrl1.TurnOff(); - btCCtrl2.TurnOff(); - btCPass1.TurnOff(); - btCPass2.TurnOff(); - btEndSignals11.TurnOff(); - btEndSignals13.TurnOff(); - btEndSignals21.TurnOff(); - btEndSignals23.TurnOff(); - btEndSignals1.TurnOff(); - btEndSignals2.TurnOff(); - btEndSignalsTab1.TurnOff(); - btEndSignalsTab2.TurnOff(); - btHeadSignals11.TurnOff(); - btHeadSignals12.TurnOff(); - btHeadSignals13.TurnOff(); - btHeadSignals21.TurnOff(); - btHeadSignals22.TurnOff(); - btHeadSignals23.TurnOff(); - btMechanik1.TurnOff(); - btMechanik2.TurnOff(); + btCCtrl1.Turn( false ); + btCCtrl2.Turn( false ); + btCPass1.Turn( false ); + btCPass2.Turn( false ); + btEndSignals11.Turn( false ); + btEndSignals13.Turn( false ); + btEndSignals21.Turn( false ); + btEndSignals23.Turn( false ); + btEndSignals1.Turn( false ); + btEndSignals2.Turn( false ); + btEndSignalsTab1.Turn( false ); + btEndSignalsTab2.Turn( false ); + btHeadSignals11.Turn( false ); + btHeadSignals12.Turn( false ); + btHeadSignals13.Turn( false ); + btHeadSignals21.Turn( false ); + btHeadSignals22.Turn( false ); + btHeadSignals23.Turn( false ); + btMechanik1.Turn( false ); + btMechanik2.Turn( false ); + btShutters1.Turn( false ); + btShutters2.Turn( false ); }; -void TDynamicObject::Render() -{ // rysowanie elementów nieprzezroczystych - // youBy - sprawdzamy, czy jest sens renderowac - double modelrotate; - vector3 tempangle; - // zmienne - renderme = false; - // przeklejka - double ObjSqrDist = SquareMagnitude(Global::pCameraPosition - vPosition); - // koniec przeklejki - if (ObjSqrDist < 500) // jak jest blisko - do 70m - modelrotate = 0.01; // mały kąt, żeby nie znikało - else - { // Global::pCameraRotation to kąt bewzględny w świecie (zero - na - // północ) - tempangle = (vPosition - Global::pCameraPosition); // wektor od kamery - modelrotate = ABuAcos(tempangle); // określenie kąta - // if (modelrotate>M_PI) modelrotate-=(2*M_PI); - modelrotate += Global::pCameraRotation; +// przeliczanie dźwięków, bo będzie słychać bez wyświetlania sektora z pojazdem +void TDynamicObject::RenderSounds() { + + if( Global.iPause != 0 ) { return; } + + double const dt{ Timer::GetDeltaRenderTime() }; + double volume{ 0.0 }; + double frequency{ 1.0 }; + + m_powertrainsounds.render( *MoverParameters, dt ); + + // NBMX dzwiek przetwornicy + if( MoverParameters->ConverterFlag ) { + frequency = ( + MoverParameters->EngineType == TEngineType::ElectricSeriesMotor ? + ( MoverParameters->RunningTraction.TractionVoltage / MoverParameters->NominalVoltage ) * MoverParameters->RList[ MoverParameters->RlistSize ].Mn : + 1.0 ); + frequency = sConverter.m_frequencyoffset + sConverter.m_frequencyfactor * frequency; + sConverter + .pitch( clamp( frequency, 0.5, 1.25 ) ) // arbitrary limits ) + .play( sound_flags::exclusive | sound_flags::looping ); + } + else { + sConverter.stop(); } - if (modelrotate > M_PI) - modelrotate -= (2 * M_PI); - if (modelrotate < -M_PI) - modelrotate += (2 * M_PI); - ModCamRot = modelrotate; - modelrotate = abs(modelrotate); - - if (modelrotate < maxrot) - renderme = true; - - if (renderme) - { - TSubModel::iInstance = (int)this; //żeby nie robić cudzych animacji - // AnsiString asLoadName=""; - double ObjSqrDist = SquareMagnitude(Global::pCameraPosition - vPosition); - ABuLittleUpdate(ObjSqrDist); // ustawianie zmiennych submodeli dla wspólnego modelu - -// Cone(vCoulpler[0],modelRot.z,0); -// Cone(vCoulpler[1],modelRot.z,1); - -// ActualTrack= GetTrack(); //McZapkie-240702 - -#if RENDER_CONE - { // Ra: testowe renderowanie pozycji wózków w postaci ostrosłupów, wymaga - // GLUT32.DLL - double dir = RadToDeg(atan2(vLeft.z, vLeft.x)); - Axle0.Render(0); - Axle1.Render(1); // bogieRot[0] - // if (PrevConnected) //renderowanie połączenia + if( MoverParameters->CompressorSpeed > 0.0 ) { + // McZapkie! - dzwiek compressor.wav tylko gdy dziala sprezarka + if( MoverParameters->CompressorFlag ) { + sCompressor.play( sound_flags::exclusive | sound_flags::looping ); } -#endif + else { + sCompressor.stop(); + } + } - glPushMatrix(); - // vector3 pos= vPosition; - // double ObjDist= SquareMagnitude(Global::pCameraPosition-pos); - if (this == Global::pUserDynamic) - { // specjalne ustawienie, aby nie trzęsło - if (Global::bSmudge) - { // jak jest widoczna smuga, to pojazd renderować po - // wyrenderowaniu smugi - glPopMatrix(); // a to trzeba zebrać przed wyjściem - return; + // Winger 160404 - dzwiek malej sprezarki + if( MoverParameters->PantCompFlag ) { + sSmallCompressor.play( sound_flags::exclusive | sound_flags::looping ); + } + else { + sSmallCompressor.stop(); + } + + // heater sound + if( ( true == MoverParameters->Heating ) + && ( std::abs( MoverParameters->enrot ) > 0.01 ) ) { + // TBD: check whether heating should depend on 'engine rotations' for electric vehicles + sHeater + .pitch( true == sHeater.is_combined() ? + std::abs( MoverParameters->enrot ) * 60.f * 0.01f : + 1.f ) + .play( sound_flags::exclusive | sound_flags::looping ); + } + else { + sHeater.stop(); + } + + // brake system and braking sounds: + + // brake cylinder piston + auto const brakepressureratio { std::max( 0.0, MoverParameters->BrakePress ) / std::max( 1.0, MoverParameters->MaxBrakePress[ 3 ] ) }; + if( m_lastbrakepressure != -1.f ) { + auto const quantizedratio { static_cast( 15 * brakepressureratio ) }; + auto const lastbrakepressureratio { std::max( 0.f, m_lastbrakepressure ) / std::max( 1.0, MoverParameters->MaxBrakePress[ 3 ] ) }; + auto const quantizedratiochange { quantizedratio - static_cast( 15 * lastbrakepressureratio ) }; + if( quantizedratiochange > 0 ) { + m_brakecylinderpistonadvance + .pitch( + true == m_brakecylinderpistonadvance.is_combined() ? + quantizedratio * 0.01f : + m_brakecylinderpistonadvance.m_frequencyoffset + m_brakecylinderpistonadvance.m_frequencyfactor * 1.f ) + .play(); + } + else if( quantizedratiochange < 0 ) { + m_brakecylinderpistonrecede + .pitch( true == m_brakecylinderpistonrecede.is_combined() ? + quantizedratio * 0.01f : + m_brakecylinderpistonrecede.m_frequencyoffset + m_brakecylinderpistonrecede.m_frequencyfactor * 1.f ) + .play(); + } + } + + // air release + if( m_lastbrakepressure != -1.f ) { + // calculate rate of pressure drop in brake cylinder, once it's been initialized + auto const brakepressuredifference{ m_lastbrakepressure - MoverParameters->BrakePress }; + m_brakepressurechange = interpolate( m_brakepressurechange, brakepressuredifference / dt, 0.005f ); + } + m_lastbrakepressure = MoverParameters->BrakePress; + // ensure some basic level of volume and scale it up depending on pressure in the cylinder; scale this by the air release rate + volume = 20 * m_brakepressurechange * ( 0.25 + 0.75 * brakepressureratio ); + if( volume > 0.075f ) { + rsUnbrake + .gain( volume ) + .play( sound_flags::exclusive | sound_flags::looping ); + } + else { + // don't stop the sound too abruptly + volume = std::max( 0.0, rsUnbrake.gain() - 0.2 * dt ); + rsUnbrake.gain( volume ); + if( volume < 0.05 ) { + rsUnbrake.stop(); + } + } + + // Dzwiek odluzniacza + if( MoverParameters->Hamulec->GetStatus() & b_rls ) { + sReleaser + .gain( + clamp( + MoverParameters->BrakePress * 1.25f, // arbitrary multiplier + 0.f, 1.f ) ) + .play( sound_flags::exclusive | sound_flags::looping ); + } + else { + sReleaser.stop(); + } + + // slipping wheels + if( MoverParameters->SlippingWheels ) { + + if( ( MoverParameters->UnitBrakeForce > 100.0 ) + && ( GetVelocity() > 1.0 ) ) { + + auto const velocitydifference{ GetVelocity() / MoverParameters->Vmax }; + rsSlippery + .gain( rsSlippery.m_amplitudeoffset + rsSlippery.m_amplitudefactor * velocitydifference ) + .play( sound_flags::exclusive | sound_flags::looping ); + } + } + else { + rsSlippery.stop(); + } + + // Dzwiek piasecznicy + if( MoverParameters->SandDose ) { + sSand.play( sound_flags::exclusive | sound_flags::looping ); + } + else { + sSand.stop(); + } + + // brakes + auto brakeforceratio{ 0.0 }; + if( //( false == mvOccupied->SlippingWheels ) && + ( MoverParameters->UnitBrakeForce > 10.0 ) + && ( MoverParameters->Vel > 0.05 ) ) { + + brakeforceratio = + clamp( + MoverParameters->UnitBrakeForce / std::max( 1.0, MoverParameters->BrakeForceR( 1.0, MoverParameters->Vel ) / ( MoverParameters->NAxles * std::max( 1, MoverParameters->NBpA ) ) ), + 0.0, 1.0 ); + rsBrake + .pitch( rsBrake.m_frequencyoffset + MoverParameters->Vel * rsBrake.m_frequencyfactor ) + .gain( rsBrake.m_amplitudeoffset + std::sqrt( brakeforceratio * interpolate( 0.4, 1.0, ( MoverParameters->Vel / ( 1 + MoverParameters->Vmax ) ) ) ) * rsBrake.m_amplitudefactor ) + .play( sound_flags::exclusive | sound_flags::looping ); + } + else { + rsBrake.stop(); + } + + // yB: przyspieszacz (moze zadziala, ale dzwiek juz jest) + if( true == bBrakeAcc ) { + if( true == TestFlag( MoverParameters->Hamulec->GetSoundFlag(), sf_Acc ) ) { + sBrakeAcc.play( sound_flags::exclusive ); + } + } + + // McZapkie-280302 - pisk mocno zacisnietych hamulcow + if( MoverParameters->Vel > 2.5 ) { + + volume = rsPisk.m_amplitudeoffset + interpolate( -1.0, 1.0, brakeforceratio ) * rsPisk.m_amplitudefactor; + if( volume > 0.075 ) { + rsPisk + .gain( volume ) + .play( sound_flags::exclusive | sound_flags::looping ); + } + } + else { + // don't stop the sound too abruptly + volume = std::max( 0.0, rsPisk.gain() - ( rsPisk.gain() * 2.5 * dt ) ); + rsPisk.gain( volume ); + } + if( volume < 0.05 ) { + rsPisk.stop(); + } + + // other sounds + // load exchange + if( MoverParameters->LoadStatus & 1 ) { + m_exchangesounds.unloading.play( sound_flags::exclusive ); + } + else { + m_exchangesounds.unloading.stop(); + } + if( MoverParameters->LoadStatus & 2 ) { + m_exchangesounds.loading.play( sound_flags::exclusive ); + } + else { + m_exchangesounds.loading.stop(); + } + // NBMX sygnal odjazdu + if( MoverParameters->DoorClosureWarning ) { + if( ( MoverParameters->DepartureSignal ) +/* + || ( ( MoverParameters->DoorCloseCtrl = control::autonomous ) + && ( ( ( false == MoverParameters->DoorLeftOpened ) && ( dDoorMoveL > 0.0 ) ) + || ( ( false == MoverParameters->DoorRightOpened ) && ( dDoorMoveR > 0.0 ) ) ) ) +*/ + ) { + // for the autonomous doors play the warning automatically whenever a door is closing + // MC: pod warunkiem ze jest zdefiniowane w chk + sDepartureSignal.play( sound_flags::exclusive | sound_flags::looping ); + } + else { + sDepartureSignal.stop(); + } + } + // NBMX Obsluga drzwi, MC: zuniwersalnione + // TODO: fully generalized door assembly + if( true == MoverParameters->DoorLeftOpened ) { + // open left door + // door sounds + // due to potential wait for the doorstep we play the sound only during actual animation + if( ( dDoorMoveL > 0.0 ) + && ( dDoorMoveL < MoverParameters->DoorMaxShiftL ) ) { + for( auto &door : m_doorsounds ) { + if( door.rsDoorClose.offset().x > 0.f ) { + // determine left side doors from their offset + door.rsDoorOpen.play( sound_flags::exclusive ); + door.rsDoorClose.stop(); + } } - // if (Global::pWorld->) //tu trzeba by ustawić animacje na modelu - // zewnętrznym - glLoadIdentity(); // zacząć od macierzy jedynkowej - Global::pCamera->SetCabMatrix(vPosition); // specjalne ustawienie kamery } - else - glTranslated(vPosition.x, vPosition.y, - vPosition.z); // standardowe przesunięcie względem początku scenerii - glMultMatrixd(mMatrix.getArray()); - if (fShade > 0.0) - { // Ra: zmiana oswietlenia w tunelu, wykopie - GLfloat ambientLight[4] = {0.5f, 0.5f, 0.5f, 1.0f}; - GLfloat diffuseLight[4] = {0.5f, 0.5f, 0.5f, 1.0f}; - GLfloat specularLight[4] = {0.5f, 0.5f, 0.5f, 1.0f}; - // trochę problem z ambientem w wykopie... - for (int li = 0; li < 3; li++) - { - ambientLight[li] = Global::ambientDayLight[li] * fShade; - diffuseLight[li] = Global::diffuseDayLight[li] * fShade; - specularLight[li] = Global::specularDayLight[li] * fShade; + // doorstep sounds + if( dDoorstepMoveL < 1.0 ) { + for( auto &door : m_doorsounds ) { + if( door.step_close.offset().x > 0.f ) { + door.step_open.play( sound_flags::exclusive ); + door.step_close.stop(); + } } - glLightfv(GL_LIGHT0, GL_AMBIENT, ambientLight); - glLightfv(GL_LIGHT0, GL_DIFFUSE, diffuseLight); - glLightfv(GL_LIGHT0, GL_SPECULAR, specularLight); } - if (Global::bUseVBO) - { // wersja VBO - if (mdLowPolyInt) - if (FreeFlyModeFlag ? true : !mdKabina || !bDisplayCab) - mdLowPolyInt->RaRender(ObjSqrDist, ReplacableSkinID, iAlpha); - mdModel->RaRender(ObjSqrDist, ReplacableSkinID, iAlpha); - if (mdLoad) // renderowanie nieprzezroczystego ładunku - mdLoad->RaRender(ObjSqrDist, ReplacableSkinID, iAlpha); - if (mdPrzedsionek) - mdPrzedsionek->RaRender(ObjSqrDist, ReplacableSkinID, iAlpha); - } - else - { // wersja Display Lists - if (mdLowPolyInt) - if (FreeFlyModeFlag ? true : !mdKabina || !bDisplayCab) - mdLowPolyInt->Render(ObjSqrDist, ReplacableSkinID, iAlpha); - mdModel->Render(ObjSqrDist, ReplacableSkinID, iAlpha); - if (mdLoad) // renderowanie nieprzezroczystego ładunku - mdLoad->Render(ObjSqrDist, ReplacableSkinID, iAlpha); - if (mdPrzedsionek) - mdPrzedsionek->Render(ObjSqrDist, ReplacableSkinID, iAlpha); - } - - // Ra: czy ta kabina tu ma sens? - // Ra: czy nie renderuje się dwukrotnie? - // Ra: dlaczego jest zablokowana w przezroczystych? - if (mdKabina) // jeśli ma model kabiny - if ((mdKabina != mdModel) && bDisplayCab && FreeFlyModeFlag) - { // rendering kabiny gdy jest oddzielnym modelem i - // ma byc wyswietlana - // ABu: tylko w trybie FreeFly, zwykly tryb w world.cpp - // Ra: świetła są ustawione dla zewnętrza danego pojazdu - // oswietlenie kabiny - GLfloat ambientCabLight[4] = {0.5f, 0.5f, 0.5f, 1.0f}; - GLfloat diffuseCabLight[4] = {0.5f, 0.5f, 0.5f, 1.0f}; - GLfloat specularCabLight[4] = {0.5f, 0.5f, 0.5f, 1.0f}; - for (int li = 0; li < 3; li++) - { - ambientCabLight[li] = Global::ambientDayLight[li] * 0.9; - diffuseCabLight[li] = Global::diffuseDayLight[li] * 0.5; - specularCabLight[li] = Global::specularDayLight[li] * 0.5; + } + if( false == MoverParameters->DoorLeftOpened ) { + // close left door + // door sounds can start playing before the door begins moving + if( dDoorMoveL > 0.0 ) { + for( auto &door : m_doorsounds ) { + if( door.rsDoorClose.offset().x > 0.f ) { + // determine left side doors from their offset + door.rsDoorClose.play( sound_flags::exclusive ); + door.rsDoorOpen.stop(); } - switch (MyTrack->eEnvironment) - { - case e_canyon: - { - for (int li = 0; li < 3; li++) - { - diffuseCabLight[li] *= 0.6; - specularCabLight[li] *= 0.7; - } - } - break; - case e_tunnel: - { - for (int li = 0; li < 3; li++) - { - ambientCabLight[li] *= 0.3; - diffuseCabLight[li] *= 0.1; - specularCabLight[li] *= 0.2; - } - } - break; - } - glLightfv(GL_LIGHT0, GL_AMBIENT, ambientCabLight); - glLightfv(GL_LIGHT0, GL_DIFFUSE, diffuseCabLight); - glLightfv(GL_LIGHT0, GL_SPECULAR, specularCabLight); - if (Global::bUseVBO) - mdKabina->RaRender(ObjSqrDist, 0); - else - mdKabina->Render(ObjSqrDist, 0); - glLightfv(GL_LIGHT0, GL_AMBIENT, Global::ambientDayLight); - glLightfv(GL_LIGHT0, GL_DIFFUSE, Global::diffuseDayLight); - glLightfv(GL_LIGHT0, GL_SPECULAR, Global::specularDayLight); } - if (fShade != 0.0) // tylko jeśli było zmieniane - { // przywrócenie standardowego oświetlenia - glLightfv(GL_LIGHT0, GL_AMBIENT, Global::ambientDayLight); - glLightfv(GL_LIGHT0, GL_DIFFUSE, Global::diffuseDayLight); - glLightfv(GL_LIGHT0, GL_SPECULAR, Global::specularDayLight); } - glPopMatrix(); - if (btnOn) - TurnOff(); // przywrócenie domyślnych pozycji submodeli - } // yB - koniec mieszania z grafika -}; - -void TDynamicObject::RenderSounds() -{ // przeliczanie dźwięków, bo będzie - // słychać bez wyświetlania sektora z - // pojazdem - // McZapkie-010302: ulepszony dzwiek silnika - double freq; - double vol = 0; - double dt = Timer::GetDeltaTime(); - - // double sounddist; - // sounddist=SquareMagnitude(Global::pCameraPosition-vPosition); - - if (MoverParameters->Power > 0) - { - if ((rsSilnik.AM != 0) && ((MoverParameters->Mains) || (MoverParameters->EngineType == - DieselEngine))) // McZapkie-280503: - // zeby dla dumb - // dzialal silnik na - // jalowych obrotach - { - if ((fabs(MoverParameters->enrot) > 0.01) || - (MoverParameters->EngineType == Dumb)) //&& (MoverParameters->EnginePower>0.1)) - { - freq = rsSilnik.FM * fabs(MoverParameters->enrot) + rsSilnik.FA; - if (MoverParameters->EngineType == Dumb) - freq = freq - - 0.2 * MoverParameters->EnginePower / (1 + MoverParameters->Power * 1000); - rsSilnik.AdjFreq(freq, dt); - if (MoverParameters->EngineType == DieselEngine) - { - if (MoverParameters->enrot > 0) - { - if (MoverParameters->EnginePower > 0) - vol = rsSilnik.AM * MoverParameters->dizel_fill + rsSilnik.AA; - else - vol = - rsSilnik.AM * fabs(MoverParameters->enrot / MoverParameters->dizel_nmax) + - rsSilnik.AA * 0.9; - } - else - vol = 0; + // doorstep sounds are played only when the doorstep is moving + if( ( dDoorstepMoveL > 0.0 ) + && ( dDoorstepMoveL < 1.0 ) ) { + for( auto &door : m_doorsounds ) { + if( door.step_close.offset().x > 0.f ) { + // determine left side doors from their offset + door.step_close.play( sound_flags::exclusive ); + door.step_open.stop(); } - else if (MoverParameters->EngineType == DieselElectric) - vol = rsSilnik.AM * - (MoverParameters->EnginePower / 1000 / MoverParameters->Power) + - 0.2 * (MoverParameters->enrot * 60) / - (MoverParameters->DElist[MoverParameters->MainCtrlPosNo].RPM) + - rsSilnik.AA; - else if (MoverParameters->EngineType == ElectricInductionMotor) - vol = rsSilnik.AM * - (MoverParameters->EnginePower + fabs(MoverParameters->enrot * 2)) + - rsSilnik.AA; - else - vol = rsSilnik.AM * (MoverParameters->EnginePower / 1000 + - fabs(MoverParameters->enrot) * 60.0) + - rsSilnik.AA; - // McZapkie-250302 - natezenie zalezne od obrotow i mocy - if ((vol < 1) && (MoverParameters->EngineType == ElectricSeriesMotor) && - (MoverParameters->EnginePower < 100)) - { - float volrnd = - Random(100) * MoverParameters->enrot / (1 + MoverParameters->nmax); - if (volrnd < 2) - vol = vol + volrnd / 200.0; - } - switch (MyTrack->eEnvironment) - { - case e_tunnel: - { - vol += 0.1; - } - break; - case e_canyon: - { - vol += 0.05; - } - break; - } - if ((MoverParameters->DynamicBrakeFlag) && (MoverParameters->EnginePower > 0.1) && - (MoverParameters->EngineType == - ElectricSeriesMotor)) // Szociu - 29012012 - jeżeli uruchomiony - // jest hamulec - // elektrodynamiczny, odtwarzany jest dźwięk silnika - vol += 0.8; - - if (enginevolume > 0.0001) - if (MoverParameters->EngineType != DieselElectric) - { - rsSilnik.Play(enginevolume, DSBPLAY_LOOPING, MechInside, GetPosition()); - } - else - { - sConverter.UpdateAF(vol, freq, MechInside, GetPosition()); - - float fincvol; - fincvol = 0; - if ((MoverParameters->ConverterFlag) && - (MoverParameters->enrot * 60 > MoverParameters->DElist[0].RPM)) - { - fincvol = (MoverParameters->DElist[MoverParameters->MainCtrlPos].RPM - - (MoverParameters->enrot * 60)); - fincvol /= (0.05 * MoverParameters->DElist[0].RPM); - }; - if (fincvol > 0.02) - rsDiesielInc.Play(fincvol, DSBPLAY_LOOPING, MechInside, GetPosition()); - else - rsDiesielInc.Stop(); - } } - else - rsSilnik.Stop(); } - enginevolume = (enginevolume + vol) * 0.5; - if( enginevolume < 0.01 ) { - rsSilnik.Stop(); - } - if ( ( MoverParameters->EngineType == ElectricSeriesMotor ) - || ( MoverParameters->EngineType == ElectricInductionMotor ) - && ( rsWentylator.AM != 0 ) ) - { - if (MoverParameters->RventRot > 0.1) { - // play ventilator sound if the ventilators are rotating fast enough... - freq = rsWentylator.FM * MoverParameters->RventRot + rsWentylator.FA; - rsWentylator.AdjFreq(freq, dt); - if( MoverParameters->EngineType == ElectricInductionMotor ) { - - vol = rsWentylator.AM * std::sqrt( std::fabs( MoverParameters->dizel_fill ) ) + rsWentylator.AA; - } - else { + } - vol = rsWentylator.AM * MoverParameters->RventRot + rsWentylator.AA; + if( true == MoverParameters->DoorRightOpened ) { + // open right door + // door sounds + // due to potential wait for the doorstep we play the sound only during actual animation + if( ( dDoorMoveR > 0.0 ) + && ( dDoorMoveR < MoverParameters->DoorMaxShiftR ) ) { + for( auto &door : m_doorsounds ) { + if( door.rsDoorClose.offset().x < 0.f ) { + // determine right side doors from their offset + door.rsDoorOpen.play( sound_flags::exclusive ); + door.rsDoorClose.stop(); } - rsWentylator.Play(vol, DSBPLAY_LOOPING, MechInside, GetPosition()); + } + } + // doorstep sounds + if( dDoorstepMoveR < 1.0 ) { + for( auto &door : m_doorsounds ) { + if( door.step_close.offset().x < 0.f ) { + door.step_open.play( sound_flags::exclusive ); + door.step_close.stop(); + } + } + } + } + if( false == MoverParameters->DoorRightOpened ) { + // close right door + // door sounds can start playing before the door begins moving + if( dDoorMoveR > 0.0 ) { + for( auto &door : m_doorsounds ) { + if( door.rsDoorClose.offset().x < 0.f ) { + // determine left side doors from their offset + door.rsDoorClose.play( sound_flags::exclusive ); + door.rsDoorOpen.stop(); + } + } + } + // doorstep sounds are played only when the doorstep is moving + if( ( dDoorstepMoveR > 0.0 ) + && ( dDoorstepMoveR < 1.0 ) ) { + for( auto &door : m_doorsounds ) { + if( door.step_close.offset().x < 0.f ) { + // determine left side doors from their offset + door.step_close.play( sound_flags::exclusive ); + door.step_open.stop(); + } + } + } + } + // door locks + if( MoverParameters->DoorBlockedFlag() != m_doorlocks ) { + // toggle state of the locks... + m_doorlocks = !m_doorlocks; + // ...and play relevant sounds + for( auto &door : m_doorsounds ) { + if( m_doorlocks ) { + door.lock.play( sound_flags::exclusive ); } else { - // ...otherwise shut down the sound - rsWentylator.Stop(); + door.unlock.play( sound_flags::exclusive ); } } - if (MoverParameters->TrainType == dt_ET40) - { - if (MoverParameters->Vel > 0.1) - { - freq = rsPrzekladnia.FM * (MoverParameters->Vel) + rsPrzekladnia.FA; - rsPrzekladnia.AdjFreq(freq, dt); - vol = rsPrzekladnia.AM * (MoverParameters->Vel) + rsPrzekladnia.AA; - rsPrzekladnia.Play(vol, DSBPLAY_LOOPING, MechInside, GetPosition()); + } + + // horns + if( TestFlag( MoverParameters->WarningSignal, 1 ) ) { + sHorn1.play( sound_flags::exclusive | sound_flags::looping ); + } + else { + sHorn1.stop(); + } + if( TestFlag( MoverParameters->WarningSignal, 2 ) ) { + sHorn2.play( sound_flags::exclusive | sound_flags::looping ); + } + else { + sHorn2.stop(); + } + if( TestFlag( MoverParameters->WarningSignal, 4 ) ) { + sHorn3.play( sound_flags::exclusive | sound_flags::looping ); + } + else { + sHorn3.stop(); + } + // szum w czasie jazdy + if( ( GetVelocity() > 0.5 ) + && ( false == m_bogiesounds.empty() ) + && ( // compound test whether the vehicle belongs to user-driven consist (as these don't emit outer noise in cab view) + FreeFlyModeFlag ? true : // in external view all vehicles emit outer noise + // Global.pWorld->train() == nullptr ? true : // (can skip this check, with no player train the external view is a given) + ctOwner == nullptr ? true : // standalone vehicle, can't be part of user-driven train + ctOwner != simulation::Train->Dynamic()->ctOwner ? true : // confirmed isn't a part of the user-driven train + Global.CabWindowOpen ? true : // sticking head out we get to hear outer noise + false ) ) { + + auto const &bogiesound { m_bogiesounds.front() }; + // frequency calculation + auto const normalizer { ( + true == bogiesound.is_combined() ? + MoverParameters->Vmax * 0.01f : + 1.f ) }; + frequency = + bogiesound.m_frequencyoffset + + bogiesound.m_frequencyfactor * MoverParameters->Vel * normalizer; + + // volume calculation + volume = + bogiesound.m_amplitudeoffset + + bogiesound.m_amplitudefactor * MoverParameters->Vel; + if( brakeforceratio > 0.0 ) { + // hamulce wzmagaja halas + volume *= 1 + 0.125 * brakeforceratio; + } + // scale volume by track quality + // TODO: track quality and/or environment factors as separate subroutine + volume *= + interpolate( + 0.8, 1.2, + clamp( + MyTrack->iQualityFlag / 20.0, + 0.0, 1.0 ) ); + // for single sample sounds muffle the playback at low speeds + if( false == bogiesound.is_combined() ) { + volume *= + interpolate( + 0.0, 1.0, + clamp( + MoverParameters->Vel / 40.0, + 0.0, 1.0 ) ); + } + + if( volume > 0.05 ) { + // apply calculated parameters to all motor instances + for( auto &bogiesound : m_bogiesounds ) { + bogiesound + .pitch( frequency ) // arbitrary limits to prevent the pitch going out of whack + .gain( volume ) + .play( sound_flags::exclusive | sound_flags::looping ); } - else - rsPrzekladnia.Stop(); + } + else { + // stop all noise instances + for( auto &bogiesound : m_bogiesounds ) { + bogiesound.stop(); + } + } + } + else { + // don't play the optional ending sound if the listener switches views + for( auto &bogiesound : m_bogiesounds ) { + bogiesound.stop( false == FreeFlyModeFlag ); + } + } + // flat spot sound + if( MoverParameters->CategoryFlag == 1 ) { + // trains only + if( ( GetVelocity() > 1.0 ) + && ( MoverParameters->WheelFlat > 5.0 ) ) { + m_wheelflat + .pitch( m_wheelflat.m_frequencyoffset + std::abs( MoverParameters->nrot ) * m_wheelflat.m_frequencyfactor ) + .gain( m_wheelflat.m_amplitudeoffset + m_wheelflat.m_amplitudefactor * ( ( 1.0 + ( MoverParameters->Vel / MoverParameters->Vmax ) + clamp( MoverParameters->WheelFlat / 60.0, 0.0, 1.0 ) ) / 3.0 ) ) + .play( sound_flags::exclusive | sound_flags::looping ); + } + else { + m_wheelflat.stop(); } } // youBy: dzwiek ostrych lukow i ciasnych zwrotek - - if ((ts.R * ts.R > 1) && (MoverParameters->Vel > 0)) - vol = MoverParameters->AccN * MoverParameters->AccN; - else - vol = 0; - // vol+=(50000/ts.R*ts.R); - - if (vol > 0.001) - { - rscurve.Play(2 * vol, DSBPLAY_LOOPING, MechInside, GetPosition()); + if( ( ts.R * ts.R > 1 ) + && ( MoverParameters->Vel > 0 ) ) { + // scale volume with curve radius and vehicle speed + volume = + MoverParameters->AccN * MoverParameters->AccN + * interpolate( + 0.0, 1.0, + clamp( + MoverParameters->Vel / 40.0, + 0.0, 1.0 ) ); } - else - rscurve.Stop(); - - // McZapkie-280302 - pisk mocno zacisnietych hamulcow - trzeba jeszcze - // zabezpieczyc przed - // brakiem deklaracji w mmedia.dta - if (rsPisk.AM != 0) - { - if ((MoverParameters->Vel > (rsPisk.GetStatus() != 0 ? 0.01 : 0.5)) && - (!MoverParameters->SlippingWheels) && (MoverParameters->UnitBrakeForce > rsPisk.AM)) - { - vol = MoverParameters->UnitBrakeForce / (rsPisk.AM + 1) + rsPisk.AA; - rsPisk.Play(vol, DSBPLAY_LOOPING, MechInside, GetPosition()); - } - else - rsPisk.Stop(); + else { + volume = 0; } - - if (MoverParameters->SandDose) // Dzwiek piasecznicy - sSand.TurnOn(MechInside, GetPosition()); - else - sSand.TurnOff(MechInside, GetPosition()); - sSand.Update(MechInside, GetPosition()); - if (MoverParameters->Hamulec->GetStatus() & b_rls) // Dzwiek odluzniacza - sReleaser.TurnOn(MechInside, GetPosition()); - else - sReleaser.TurnOff(MechInside, GetPosition()); - //sReleaser.Update(MechInside, GetPosition()); - double releaser_vol = 1; - if (MoverParameters->BrakePress < 0.1) - releaser_vol = MoverParameters->BrakePress * 10; - sReleaser.UpdateAF(releaser_vol, 1, MechInside, GetPosition()); - // if ((MoverParameters->ConverterFlag==false) && - // (MoverParameters->TrainType!=dt_ET22)) - // if - // ((MoverParameters->ConverterFlag==false)&&(MoverParameters->CompressorPower!=0)) - // MoverParameters->CompressorFlag=false; //Ra: wywalić to stąd, tu tylko dla - // wyświetlanych! - // Ra: no to już wiemy, dlaczego pociągi jeżdżą lepiej, gdy się na nie patrzy! - // if (MoverParameters->CompressorPower==2) - // MoverParameters->CompressorAllow=MoverParameters->ConverterFlag; - - // McZapkie! - dzwiek compressor.wav tylko gdy dziala sprezarka - if (MoverParameters->VeselVolume != 0) - { - if (MoverParameters->CompressorFlag) - sCompressor.TurnOn(MechInside, GetPosition()); - else - sCompressor.TurnOff(MechInside, GetPosition()); - sCompressor.Update(MechInside, GetPosition()); + if( volume > 0.05 ) { + rscurve + .gain( 2.5 * volume ) + .play( sound_flags::exclusive | sound_flags::looping ); } - if (MoverParameters->PantCompFlag) // Winger 160404 - dzwiek malej sprezarki - sSmallCompressor.TurnOn(MechInside, GetPosition()); - else - sSmallCompressor.TurnOff(MechInside, GetPosition()); - sSmallCompressor.Update(MechInside, GetPosition()); - - // youBy - przenioslem, bo diesel tez moze miec turbo - if ((MoverParameters->MainCtrlPos) >= - (MoverParameters->TurboTest)) // hunter-250312: dlaczego zakomentowane? - // Ra: bo nie działało dobrze - { - // udawanie turbo: (6.66*(eng_vol-0.85)) - if (eng_turbo > 6.66 * (enginevolume - 0.8) + 0.2 * dt) - eng_turbo = eng_turbo - 0.2 * dt; // 0.125 - else if (eng_turbo < 6.66 * (enginevolume - 0.8) - 0.4 * dt) - eng_turbo = eng_turbo + 0.4 * dt; // 0.333 - else - eng_turbo = 6.66 * (enginevolume - 0.8); - - sTurbo.TurnOn(MechInside, GetPosition()); - // sTurbo.UpdateAF(eng_turbo,0.7+(eng_turbo*0.6),MechInside,GetPosition()); - sTurbo.UpdateAF(3 * eng_turbo - 1, 0.4 + eng_turbo * 0.4, MechInside, GetPosition()); - // eng_vol_act=enginevolume; - // eng_frq_act=eng_frq; + else { + rscurve.stop(); } - else - sTurbo.TurnOff(MechInside, GetPosition()); - if (MoverParameters->TrainType == dt_PseudoDiesel) - { - // ABu: udawanie woodwarda dla lok. spalinowych - // jesli silnik jest podpiety pod dzwiek przetwornicy - if (MoverParameters->ConverterFlag) // NBMX dzwiek przetwornicy - { - sConverter.TurnOn(MechInside, GetPosition()); - } - else - sConverter.TurnOff(MechInside, GetPosition()); + // McZapkie! - to wazne - SoundFlag wystawiane jest przez moje moduly + // gdy zachodza pewne wydarzenia komentowane dzwiekiem. + if( TestFlag( MoverParameters->SoundFlag, sound::pneumatic ) ) { + // pneumatic relay + dsbPneumaticRelay + .gain( + true == TestFlag( MoverParameters->SoundFlag, sound::loud ) ? + 1.0f : + 0.8f ) + .play(); + } + // couplers + int couplerindex { 0 }; + for( auto &couplersounds : m_couplersounds ) { - // glosnosc zalezy od stosunku mocy silnika el. do mocy max - double eng_vol; - if (MoverParameters->Power > 1) - // 0.85+0.000015*(...) - eng_vol = 0.8 + 0.00002 * (MoverParameters->EnginePower / MoverParameters->Power); - else - eng_vol = 1; + auto &coupler { MoverParameters->Couplers[ couplerindex ] }; - eng_dfrq = eng_dfrq + (eng_vol_act - eng_vol); - if (eng_dfrq > 0) - { - eng_dfrq = eng_dfrq - 0.025 * dt; - if (eng_dfrq < 0.025 * dt) - eng_dfrq = 0; - } - else if (eng_dfrq < 0) - { - eng_dfrq = eng_dfrq + 0.025 * dt; - if (eng_dfrq > -0.025 * dt) - eng_dfrq = 0; - } - double defrot; - if (MoverParameters->MainCtrlPos != 0) - { - double CtrlPos = MoverParameters->MainCtrlPos; - double CtrlPosNo = MoverParameters->MainCtrlPosNo; - // defrot=1+0.4*(CtrlPos/CtrlPosNo); - defrot = 1 + 0.5 * (CtrlPos / CtrlPosNo); - } - else - defrot = 1; - - if (eng_frq_act < defrot) - { - // if (MoverParameters->MainCtrlPos==1) eng_frq_act=eng_frq_act+0.1*dt; - eng_frq_act = eng_frq_act + 0.4 * dt; // 0.05 - if (eng_frq_act > defrot - 0.4 * dt) - eng_frq_act = defrot; - } - else if (eng_frq_act > defrot) - { - eng_frq_act = eng_frq_act - 0.1 * dt; // 0.05 - if (eng_frq_act < defrot + 0.1 * dt) - eng_frq_act = defrot; - } - sConverter.UpdateAF(eng_vol_act, eng_frq_act + eng_dfrq, MechInside, GetPosition()); - // udawanie turbo: (6.66*(eng_vol-0.85)) - if (eng_turbo > 6.66 * (eng_vol - 0.8) + 0.2 * dt) - eng_turbo = eng_turbo - 0.2 * dt; // 0.125 - else if (eng_turbo < 6.66 * (eng_vol - 0.8) - 0.4 * dt) - eng_turbo = eng_turbo + 0.4 * dt; // 0.333 - else - eng_turbo = 6.66 * (eng_vol - 0.8); - - sTurbo.TurnOn(MechInside, GetPosition()); - // sTurbo.UpdateAF(eng_turbo,0.7+(eng_turbo*0.6),MechInside,GetPosition()); - sTurbo.UpdateAF(3 * eng_turbo - 1, 0.4 + eng_turbo * 0.4, MechInside, GetPosition()); - eng_vol_act = eng_vol; - // eng_frq_act=eng_frq; - } - else - { - if (MoverParameters->ConverterFlag) // NBMX dzwiek przetwornicy - sConverter.TurnOn(MechInside, GetPosition()); - else - sConverter.TurnOff(MechInside, GetPosition()); - sConverter.Update(MechInside, GetPosition()); - } - if (MoverParameters->WarningSignal > 0) - { - if (TestFlag(MoverParameters->WarningSignal, 1)) - sHorn1.TurnOn(MechInside, GetPosition()); - else - sHorn1.TurnOff(MechInside, GetPosition()); - if (TestFlag(MoverParameters->WarningSignal, 2)) - sHorn2.TurnOn(MechInside, GetPosition()); - else - sHorn2.TurnOff(MechInside, GetPosition()); - } - else - { - sHorn1.TurnOff(MechInside, GetPosition()); - sHorn2.TurnOff(MechInside, GetPosition()); - } - if (MoverParameters->DoorClosureWarning) - { - if (MoverParameters->DepartureSignal) // NBMX sygnal odjazdu, MC: pod warunkiem ze jest - // zdefiniowane w chk - sDepartureSignal.TurnOn(MechInside, GetPosition()); - else - sDepartureSignal.TurnOff(MechInside, GetPosition()); - sDepartureSignal.Update(MechInside, GetPosition()); - } - sHorn1.Update(MechInside, GetPosition()); - sHorn2.Update(MechInside, GetPosition()); - // McZapkie: w razie wykolejenia - if (MoverParameters->EventFlag) - { - if (TestFlag(MoverParameters->DamageFlag, dtrain_out) && GetVelocity() > 0) - rsDerailment.Play(1, 0, true, GetPosition()); - if (GetVelocity() == 0) - rsDerailment.Stop(); - } - /* //Ra: dwa razy? - if (MoverParameters->EventFlag) - { - if (TestFlag(MoverParameters->DamageFlag,dtrain_out) && GetVelocity()>0) - rsDerailment.Play(1,0,true,GetPosition()); - if (GetVelocity()==0) - rsDerailment.Stop(); - } - */ -}; - -void TDynamicObject::RenderAlpha() -{ // rysowanie elementów półprzezroczystych - if (renderme) - { - TSubModel::iInstance = (int)this; //żeby nie robić cudzych animacji - double ObjSqrDist = SquareMagnitude(Global::pCameraPosition - vPosition); - ABuLittleUpdate(ObjSqrDist); // ustawianie zmiennych submodeli dla wspólnego modelu - glPushMatrix(); - if (this == Global::pUserDynamic) - { // specjalne ustawienie, aby nie trzęsło - if (Global::bSmudge) - { // jak smuga, to rysować po smudze - glPopMatrix(); // to trzeba zebrać przed wyściem - return; - } - glLoadIdentity(); // zacząć od macierzy jedynkowej - Global::pCamera->SetCabMatrix(vPosition); // specjalne ustawienie kamery - } - else - glTranslated(vPosition.x, vPosition.y, - vPosition.z); // standardowe przesunięcie względem początku scenerii - glMultMatrixd(mMatrix.getArray()); - if (fShade > 0.0) - { // Ra: zmiana oswietlenia w tunelu, wykopie - GLfloat ambientLight[4] = {0.5f, 0.5f, 0.5f, 1.0f}; - GLfloat diffuseLight[4] = {0.5f, 0.5f, 0.5f, 1.0f}; - GLfloat specularLight[4] = {0.5f, 0.5f, 0.5f, 1.0f}; - // trochę problem z ambientem w wykopie... - for (int li = 0; li < 3; li++) - { - ambientLight[li] = Global::ambientDayLight[li] * fShade; - diffuseLight[li] = Global::diffuseDayLight[li] * fShade; - specularLight[li] = Global::specularDayLight[li] * fShade; - } - glLightfv(GL_LIGHT0, GL_AMBIENT, ambientLight); - glLightfv(GL_LIGHT0, GL_DIFFUSE, diffuseLight); - glLightfv(GL_LIGHT0, GL_SPECULAR, specularLight); - } - if (Global::bUseVBO) - { // wersja VBO - if (mdLowPolyInt) - if (FreeFlyModeFlag ? true : !mdKabina || !bDisplayCab) - mdLowPolyInt->RaRenderAlpha(ObjSqrDist, ReplacableSkinID, iAlpha); - mdModel->RaRenderAlpha(ObjSqrDist, ReplacableSkinID, iAlpha); - if (mdLoad) - mdLoad->RaRenderAlpha(ObjSqrDist, ReplacableSkinID, iAlpha); - // if (mdPrzedsionek) //Ra: przedsionków tu wcześniej nie było - włączyć? - // mdPrzedsionek->RaRenderAlpha(ObjSqrDist,ReplacableSkinID,iAlpha); - } - else - { // wersja Display Lists - if (mdLowPolyInt) - if (FreeFlyModeFlag ? true : !mdKabina || !bDisplayCab) - mdLowPolyInt->RenderAlpha(ObjSqrDist, ReplacableSkinID, iAlpha); - mdModel->RenderAlpha(ObjSqrDist, ReplacableSkinID, iAlpha); - if (mdLoad) - mdLoad->RenderAlpha(ObjSqrDist, ReplacableSkinID, iAlpha); - // if (mdPrzedsionek) //Ra: przedsionków tu wcześniej nie było - włączyć? - // mdPrzedsionek->RenderAlpha(ObjSqrDist,ReplacableSkinID,iAlpha); - } - /* skoro false to można wyciąc - //ABu: Tylko w trybie freefly - if (false)//((mdKabina!=mdModel) && bDisplayCab && FreeFlyModeFlag) - { - //oswietlenie kabiny - GLfloat ambientCabLight[4]= { 0.5f, 0.5f, 0.5f, 1.0f }; - GLfloat diffuseCabLight[4]= { 0.5f, 0.5f, 0.5f, 1.0f }; - GLfloat specularCabLight[4]= { 0.5f, 0.5f, 0.5f, 1.0f }; - for (int li=0; li<3; li++) - { - ambientCabLight[li]= Global::ambientDayLight[li]*0.9; - diffuseCabLight[li]= Global::diffuseDayLight[li]*0.5; - specularCabLight[li]= Global::specularDayLight[li]*0.5; - } - switch (MyTrack->eEnvironment) - { - case e_canyon: - { - for (int li=0; li<3; li++) - { - diffuseCabLight[li]*= 0.6; - specularCabLight[li]*= 0.8; - } + if( true == TestFlag( coupler.sounds, sound::bufferclash ) ) { + // zderzaki uderzaja o siebie + if( true == TestFlag( coupler.sounds, sound::loud ) ) { + // loud clash + if( false == couplersounds.dsbBufferClamp_loud.empty() ) { + // dedicated sound for loud clash + couplersounds.dsbBufferClamp_loud + .gain( 1.f ) + .play( sound_flags::exclusive ); } - break; - case e_tunnel: - { - for (int li=0; li<3; li++) - { - ambientCabLight[li]*= 0.3; - diffuseCabLight[li]*= 0.1; - specularCabLight[li]*= 0.2; - } + else { + // fallback on the standard sound + couplersounds.dsbBufferClamp + .gain( 1.f ) + .play( sound_flags::exclusive ); } - break; - } - // dorobic swiatlo od drugiej strony szyby - - glLightfv(GL_LIGHT0,GL_AMBIENT,ambientCabLight); - glLightfv(GL_LIGHT0,GL_DIFFUSE,diffuseCabLight); - glLightfv(GL_LIGHT0,GL_SPECULAR,specularCabLight); - - mdKabina->RenderAlpha(ObjSqrDist,0); - //smierdzi - // mdModel->RenderAlpha(SquareMagnitude(Global::pCameraPosition-pos),0); - - glLightfv(GL_LIGHT0,GL_AMBIENT,Global::ambientDayLight); - glLightfv(GL_LIGHT0,GL_DIFFUSE,Global::diffuseDayLight); - glLightfv(GL_LIGHT0,GL_SPECULAR,Global::specularDayLight); } - */ - if (fShade != 0.0) // tylko jeśli było zmieniane - { // przywrócenie standardowego oświetlenia - glLightfv(GL_LIGHT0, GL_AMBIENT, Global::ambientDayLight); - glLightfv(GL_LIGHT0, GL_DIFFUSE, Global::diffuseDayLight); - glLightfv(GL_LIGHT0, GL_SPECULAR, Global::specularDayLight); + else { + // basic clash + couplersounds.dsbBufferClamp + .gain( 0.65f ) + .play( sound_flags::exclusive ); + } } - glPopMatrix(); - if (btnOn) - TurnOff(); // przywrócenie domyślnych pozycji submodeli + if( true == TestFlag( coupler.sounds, sound::couplerstretch ) ) { + // sprzegi sie rozciagaja + if( true == TestFlag( coupler.sounds, sound::loud ) ) { + // loud stretch + if( false == couplersounds.dsbCouplerStretch_loud.empty() ) { + // dedicated sound for loud stretch + couplersounds.dsbCouplerStretch_loud + .gain( 1.f ) + .play( sound_flags::exclusive ); + } + else { + // fallback on the standard sound + couplersounds.dsbCouplerStretch + .gain( 1.f ) + .play( sound_flags::exclusive ); + } + } + else { + // basic clash + couplersounds.dsbCouplerStretch + .gain( 0.65f ) + .play( sound_flags::exclusive ); + } + } + + coupler.sounds = 0; + ++couplerindex; } - return; -} // koniec renderalpha + + MoverParameters->SoundFlag = 0; + // McZapkie! - koniec obslugi dzwiekow z mover.pas + +// special events + if( MoverParameters->EventFlag ) { + // McZapkie: w razie wykolejenia + if( true == TestFlag( MoverParameters->DamageFlag, dtrain_out ) ) { + if( GetVelocity() > 0 ) { + rsDerailment.play(); + } + else { + rsDerailment.stop(); + } + } + + MoverParameters->EventFlag = false; + } +} + +// calculates distance between event-starting axle and front of the vehicle +double +TDynamicObject::tracing_offset() const { + + auto const axletoend{ ( GetLength() - fAxleDist ) * 0.5 }; + return ( + iAxleFirst ? + axletoend : + axletoend + iDirection * fAxleDist ); +} // McZapkie-250202 // wczytywanie pliku z danymi multimedialnymi (dzwieki) -void TDynamicObject::LoadMMediaFile(std::string BaseDir, std::string TypeName, - std::string ReplacableSkin) -{ - double dSDist; - // asBaseDir=BaseDir; - Global::asCurrentDynamicPath = BaseDir; - std::string asFileName = BaseDir + TypeName + ".mmd"; - std::string asLoadName; - if( false == MoverParameters->LoadType.empty() ) { - asLoadName = BaseDir + MoverParameters->LoadType + ".t3d"; - } +void TDynamicObject::LoadMMediaFile( std::string const &TypeName, std::string const &ReplacableSkin ) { + Global.asCurrentDynamicPath = asBaseDir; + std::string asFileName = asBaseDir + TypeName + ".mmd"; std::string asAnimName; bool Stop_InternalData = false; pants = NULL; // wskaźnik pierwszego obiektu animującego dla pantografów - cParser parser( TypeName + ".mmd", cParser::buffer_FILE, BaseDir ); + cParser parser( TypeName + ".mmd", cParser::buffer_FILE, asBaseDir ); + if( false == parser.ok() ) { + ErrorLog( "Failed to load appearance data for vehicle " + MoverParameters->Name ); + return; + } std::string token; do { token = ""; parser.getTokens(); parser >> token; - if( token == "models:") { + if( ( token == "models:" ) + || ( token == "\xef\xbb\xbfmodels:" ) ) { // crude way to handle utf8 bom potentially appearing before the first token // modele i podmodele - iMultiTex = 0; // czy jest wiele tekstur wymiennych? + m_materialdata.multi_textures = 0; // czy jest wiele tekstur wymiennych? parser.getTokens(); parser >> asModel; + replace_slashes( asModel ); if( asModel[asModel.size() - 1] == '#' ) // Ra 2015-01: nie podoba mi siê to { // model wymaga wielu tekstur wymiennych - iMultiTex = 1; + m_materialdata.multi_textures = 1; asModel.erase( asModel.length() - 1 ); } + // name can contain leading slash, erase it to avoid creation of double slashes when the name is combined with current directory + if( asModel[ 0 ] == '/' ) { + asModel.erase( 0, 1 ); + } std::size_t i = asModel.find( ',' ); if ( i != std::string::npos ) - { // Ra 2015-01: może szukać przecinka w - // nazwie modelu, a po przecinku była by - // liczba - // tekstur? - if (i < asModel.length()) - iMultiTex = asModel[i + 1] - '0'; - if (iMultiTex < 0) - iMultiTex = 0; - else if (iMultiTex > 1) - iMultiTex = 1; // na razie ustawiamy na 1 + { // Ra 2015-01: może szukać przecinka w nazwie modelu, a po przecinku była by liczba tekstur? + if( i < asModel.length() ) { + m_materialdata.multi_textures = asModel[ i + 1 ] - '0'; + } + m_materialdata.multi_textures = clamp( m_materialdata.multi_textures, 0, 1 ); // na razie ustawiamy na 1 } - asModel = BaseDir + asModel; // McZapkie 2002-07-20: dynamics maja swoje - // modele w dynamics/basedir - Global::asCurrentTexturePath = BaseDir; // biezaca sciezka do tekstur to dynamic/... + asModel = asBaseDir + asModel; // McZapkie 2002-07-20: dynamics maja swoje modele w dynamics/basedir + Global.asCurrentTexturePath = asBaseDir; // biezaca sciezka do tekstur to dynamic/... mdModel = TModelsManager::GetModel(asModel, true); - assert( mdModel != nullptr ); // TODO: handle this more gracefully than all going to shit if (ReplacableSkin != "none") - { // tekstura wymienna jest raczej jedynie w "dynamic\" - ReplacableSkin = - Global::asCurrentTexturePath + ReplacableSkin; // skory tez z dynamic/... - std::string x = TextureTest(Global::asCurrentTexturePath + "nowhere"); // na razie prymitywnie - if (!x.empty()) - ReplacableSkinID[4] = TextureManager.GetTextureId( Global::asCurrentTexturePath + "nowhere", "", 9); - /* - if ((i = ReplacableSkin.Pos("|")) > 0) // replacable dzielone - { - iMultiTex = -1; - ReplacableSkinID[-iMultiTex] = TTexturesManager::GetTextureID( - NULL, NULL, ReplacableSkin.SubString(1, i - 1).c_str(), - Global::iDynamicFiltering); - ReplacableSkin.Delete(1, i); // usunięcie razem z pionową kreską - ReplacableSkin = Global::asCurrentTexturePath + - ReplacableSkin; // odtworzenie początku ścieżki - // sprawdzić, ile jest i ustawić iMultiTex na liczbę podanych tekstur - if (!ReplacableSkin.IsEmpty()) - { // próba wycięcia drugiej nazwy - iMultiTex = -2; // skoro zostało coś po kresce, to są co najmniej dwie - if ((i = ReplacableSkin.Pos("|")) == 0) // gdy nie ma już kreski - ReplacableSkinID[-iMultiTex] = TTexturesManager::GetTextureID( - NULL, NULL, ReplacableSkin.SubString(1, i - 1).c_str(), - Global::iDynamicFiltering); - else - { // jak jest kreska, to wczytać drugą i próbować trzecią - ReplacableSkinID[-iMultiTex] = TTexturesManager::GetTextureID( - NULL, NULL, ReplacableSkin.SubString(1, i - 1).c_str(), - Global::iDynamicFiltering); - ReplacableSkin.Delete(1, i); // usunięcie razem z pionową kreską - ReplacableSkin = Global::asCurrentTexturePath + - ReplacableSkin; // odtworzenie początku ścieżki - if (!ReplacableSkin.IsEmpty()) - { // próba wycięcia trzeciej nazwy - iMultiTex = - -3; // skoro zostało coś po kresce, to są co najmniej trzy - if ((i = ReplacableSkin.Pos("|")) == 0) // gdy nie ma już kreski - ReplacableSkinID[-iMultiTex] = TTexturesManager::GetTextureID( - NULL, NULL, ReplacableSkin.SubString(1, i - 1).c_str(), - Global::iDynamicFiltering); - else - { // jak jest kreska, to wczytać trzecią i próbować czwartą - ReplacableSkinID[-iMultiTex] = TTexturesManager::GetTextureID( - NULL, NULL, ReplacableSkin.SubString(1, i - 1).c_str(), - Global::iDynamicFiltering); - ReplacableSkin.Delete(1, i); // usunięcie razem z pionową kreską - ReplacableSkin = Global::asCurrentTexturePath + - ReplacableSkin; // odtworzenie początku ścieżki - if (!ReplacableSkin.IsEmpty()) - { // próba wycięcia trzeciej nazwy - iMultiTex = -4; // skoro zostało coś po kresce, to są co - // najmniej cztery - ReplacableSkinID[-iMultiTex] = - TTexturesManager::GetTextureID( - NULL, NULL, - ReplacableSkin.SubString(1, i - 1).c_str(), - Global::iDynamicFiltering); - // więcej na razie nie zadziała, a u tak trzeba to do modeli - // przenieść - } - } - } - } - } - } - */ - if (iMultiTex > 0) - { // jeśli model ma 4 tekstury - ReplacableSkinID[1] = TextureManager.GetTextureId( - ReplacableSkin + ",1", "", Global::iDynamicFiltering); - if (ReplacableSkinID[1]) - { // pierwsza z zestawu znaleziona - ReplacableSkinID[2] = TextureManager.GetTextureId( - ReplacableSkin + ",2", "", Global::iDynamicFiltering); - if (ReplacableSkinID[2]) - { - iMultiTex = 2; // już są dwie - ReplacableSkinID[3] = TextureManager.GetTextureId( - ReplacableSkin + ",3", "", Global::iDynamicFiltering); - if (ReplacableSkinID[3]) - { - iMultiTex = 3; // a teraz nawet trzy - ReplacableSkinID[4] = TextureManager.GetTextureId( - ReplacableSkin + ",4", "", Global::iDynamicFiltering); - if (ReplacableSkinID[4]) - iMultiTex = 4; // jak są cztery, to blokujemy podmianę tekstury - // rozkładem - } - } - } - else - { // zestaw nie zadziałał, próbujemy normanie - iMultiTex = 0; - ReplacableSkinID[1] = TextureManager.GetTextureId( - ReplacableSkin, "", Global::iDynamicFiltering); - } - } - else - ReplacableSkinID[1] = TextureManager.GetTextureId( - ReplacableSkin, "", Global::iDynamicFiltering); - if (TextureManager.Texture(ReplacableSkinID[1]).has_alpha) - iAlpha = 0x31310031; // tekstura -1 z kanałem alfa - nie renderować w cyklu - // nieprzezroczystych - else - iAlpha = 0x30300030; // wszystkie tekstury nieprzezroczyste - nie - // renderować w - // cyklu przezroczystych - if (ReplacableSkinID[2]) - if (TextureManager.Texture(ReplacableSkinID[2]).has_alpha) - iAlpha |= 0x02020002; // tekstura -2 z kanałem alfa - nie renderować - // w cyklu - // nieprzezroczystych - if (ReplacableSkinID[3]) - if (TextureManager.Texture(ReplacableSkinID[3]).has_alpha) - iAlpha |= 0x04040004; // tekstura -3 z kanałem alfa - nie renderować - // w cyklu - // nieprzezroczystych - if (ReplacableSkinID[4]) - if (TextureManager.Texture(ReplacableSkinID[4]).has_alpha) - iAlpha |= 0x08080008; // tekstura -4 z kanałem alfa - nie renderować - // w cyklu - // nieprzezroczystych - } -/* - // Winger 040304 - ladowanie przedsionkow dla EZT - if (MoverParameters->TrainType == dt_EZT) { - asModel = "przedsionki.t3d"; - asModel = BaseDir + asModel; - mdPrzedsionek = TModelsManager::GetModel(asModel, true); + std::string nowheretexture = TextureTest( "nowhere" ); // na razie prymitywnie + if( false == nowheretexture.empty() ) { + m_materialdata.replacable_skins[ 4 ] = GfxRenderer.Fetch_Material( nowheretexture ); + } + + if (m_materialdata.multi_textures > 0) { + // jeśli model ma 4 tekstury + // check for the pipe method first + if( ReplacableSkin.find( '|' ) != std::string::npos ) { + cParser nameparser( ReplacableSkin ); + nameparser.getTokens( 4, true, "|" ); + int skinindex = 0; + std::string texturename; nameparser >> texturename; + while( ( texturename != "" ) && ( skinindex < 4 ) ) { + m_materialdata.replacable_skins[ skinindex + 1 ] = GfxRenderer.Fetch_Material( texturename ); + ++skinindex; + texturename = ""; nameparser >> texturename; + } + m_materialdata.multi_textures = skinindex; + } + else { + // otherwise try the basic approach + int skinindex = 0; + do { + material_handle material = GfxRenderer.Fetch_Material( ReplacableSkin + "," + std::to_string( skinindex + 1 ), true ); + if( material == null_handle ) { + break; + } + m_materialdata.replacable_skins[ skinindex + 1 ] = material; + ++skinindex; + } while( skinindex < 4 ); + m_materialdata.multi_textures = skinindex; + if( m_materialdata.multi_textures == 0 ) { + // zestaw nie zadziałał, próbujemy normanie + m_materialdata.replacable_skins[ 1 ] = GfxRenderer.Fetch_Material( ReplacableSkin ); + } + } + } + else { + m_materialdata.replacable_skins[ 1 ] = GfxRenderer.Fetch_Material( ReplacableSkin ); + } + if( GfxRenderer.Material( m_materialdata.replacable_skins[ 1 ] ).has_alpha ) { + // tekstura -1 z kanałem alfa - nie renderować w cyklu nieprzezroczystych + m_materialdata.textures_alpha = 0x31310031; + } + else { + // wszystkie tekstury nieprzezroczyste - nie renderować w cyklu przezroczystych + m_materialdata.textures_alpha = 0x30300030; + } + + if( ( m_materialdata.replacable_skins[ 2 ] ) + && ( GfxRenderer.Material( m_materialdata.replacable_skins[ 2 ] ).has_alpha ) ) { + // tekstura -2 z kanałem alfa - nie renderować w cyklu nieprzezroczystych + m_materialdata.textures_alpha |= 0x02020002; + } + if( ( m_materialdata.replacable_skins[ 3 ] ) + && ( GfxRenderer.Material( m_materialdata.replacable_skins[ 3 ] ).has_alpha ) ) { + // tekstura -3 z kanałem alfa - nie renderować w cyklu nieprzezroczystych + m_materialdata.textures_alpha |= 0x04040004; + } + if( ( m_materialdata.replacable_skins[ 4 ] ) + && ( GfxRenderer.Material( m_materialdata.replacable_skins[ 4 ] ).has_alpha ) ) { + // tekstura -4 z kanałem alfa - nie renderować w cyklu nieprzezroczystych + m_materialdata.textures_alpha |= 0x08080008; + } } -*/ - if (!MoverParameters->LoadAccepted.empty()) - // if (MoverParameters->LoadAccepted!=AnsiString("")); // && - // MoverParameters->LoadType!=AnsiString("passengers")) - if (MoverParameters->EnginePowerSource.SourceType == CurrentCollector) - { // wartość niby "pantstate" - nazwa dla formalności, ważna jest ilość - if (MoverParameters->Load == 1) - MoverParameters->PantFront(true); - else if (MoverParameters->Load == 2) - MoverParameters->PantRear(true); - else if (MoverParameters->Load == 3) - { - MoverParameters->PantFront(true); - MoverParameters->PantRear(true); - } - else if (MoverParameters->Load == 4) - MoverParameters->DoubleTr = -1; - else if (MoverParameters->Load == 5) - { - MoverParameters->DoubleTr = -1; - MoverParameters->PantRear(true); - } - else if (MoverParameters->Load == 6) - { - MoverParameters->DoubleTr = -1; - MoverParameters->PantFront(true); - } - else if (MoverParameters->Load == 7) - { - MoverParameters->DoubleTr = -1; - MoverParameters->PantFront(true); - MoverParameters->PantRear(true); - } - } - else // Ra: tu wczytywanie modelu ładunku jest w porządku - { - if( false == asLoadName.empty() ) { - mdLoad = TModelsManager::GetModel( asLoadName, true ); // ladunek - } - } - Global::asCurrentTexturePath = szTexturePath; // z powrotem defaultowa sciezka do tekstur + if( false == MoverParameters->LoadAttributes.empty() ) { + // Ra: tu wczytywanie modelu ładunku jest w porządku + mdLoad = LoadMMediaFile_mdload( MoverParameters->LoadType.name ); + } + Global.asCurrentTexturePath = szTexturePath; // z powrotem defaultowa sciezka do tekstur do { token = ""; parser.getTokens(); parser >> token; @@ -4602,119 +4617,92 @@ void TDynamicObject::LoadMMediaFile(std::string BaseDir, std::string TypeName, */ if( true == pAnimations.empty() ) { // jeśli nie ma jeszcze tabeli animacji, można odczytać nowe ilości - int co = 0, ile = -1; + int co = 0; iAnimations = 0; + int ile; do { // kolejne liczby to ilość animacj, -1 to znacznik końca + ile = -1; parser.getTokens( 1, false ); parser >> ile; // ilość danego typu animacji - // if (co==ANIM_PANTS) - // if (!Global::bLoadTraction) - // if (!DebugModeFlag) //w debugmode pantografy mają "niby działać" - // ile=0; //wyłączenie animacji pantografów - if (co < ANIM_TYPES) - if (ile >= 0) - { - iAnimType[co] = ile; // zapamiętanie - iAnimations += ile; // ogólna ilość animacji - } + if (ile >= 0) + { + iAnimType[co] = ile; // zapamiętanie + iAnimations += ile; // ogólna ilość animacji + } + else { + iAnimType[co] = 0; + } ++co; - } while (ile >= 0); //-1 to znacznik końca + } while ( (ile >= 0) && (co < ANIM_TYPES) ); //-1 to znacznik końca - while( co < ANIM_TYPES ) { - iAnimType[ co++ ] = 0; // zerowanie pozostałych - } - parser.getTokens(); parser >> token; // NOTE: should this be here? seems at best superfluous - } - // WriteLog("Total animations: "+AnsiString(iAnimations)); - } -/* - if( nullptr == pAnimations ) -*/ - if( true == pAnimations.empty() ) - { // Ra: tworzenie tabeli animacji, jeśli jeszcze nie było -/* - // disabled as default animation amounts are no longer supported - if( !iAnimations ) { - // jeśli nie podano jawnie, ile ma być animacji - iAnimations = 28; // tyle było kiedyś w każdym pojeździe (2 wiązary wypadły) - } -*/ - /* //pojazd może mieć pantograf do innych celów niż napęd - if (MoverParameters->EnginePowerSource.SourceType!=CurrentCollector) - {//nie będzie pantografów, to się trochę uprości - iAnimations-=iAnimType[ANIM_PANTS]; //domyślnie były 2 pantografy - iAnimType[ANIM_PANTS]=0; - } - */ -/* - pAnimations = new TAnim[iAnimations]; -*/ - pAnimations.resize( iAnimations ); - int i, j, k = 0, sm = 0; - for (j = 0; j < ANIM_TYPES; ++j) - for (i = 0; i < iAnimType[j]; ++i) + pAnimations.resize( iAnimations ); + int i, j, k = 0, sm = 0; + for (j = 0; j < ANIM_TYPES; ++j) + for (i = 0; i < iAnimType[j]; ++i) + { + if (j == ANIM_PANTS) // zliczamy poprzednie animacje + if (!pants) + if (iAnimType[ANIM_PANTS]) // o ile jakieś pantografy są (a domyślnie są) + pants = &pAnimations[k]; // zapamiętanie na potrzeby wyszukania submodeli + pAnimations[k].iShift = sm; // przesunięcie do przydzielenia wskaźnika + sm += pAnimations[k++].TypeSet(j); // ustawienie typu animacji i zliczanie tablicowanych submodeli + } + if (sm) // o ile są bardziej złożone animacje { - if (j == ANIM_PANTS) // zliczamy poprzednie animacje - if (!pants) - if (iAnimType[ANIM_PANTS]) // o ile jakieś pantografy są (a domyślnie są) - pants = &pAnimations[k]; // zapamiętanie na potrzeby wyszukania submodeli -/* - pants = pAnimations + k; // zapamiętanie na potrzeby wyszukania submodeli -*/ - pAnimations[k].iShift = sm; // przesunięcie do przydzielenia wskaźnika - sm += pAnimations[k++].TypeSet(j); // ustawienie typu animacji i zliczanie tablicowanych submodeli + pAnimated = new TSubModel *[sm]; // tabela na animowane submodele + for (k = 0; k < iAnimations; ++k) + pAnimations[k].smElement = pAnimated + pAnimations[k].iShift; // przydzielenie wskaźnika do tabelki } - if (sm) // o ile są bardziej złożone animacje - { - pAnimated = new TSubModel *[sm]; // tabela na animowane submodele - for (k = 0; k < iAnimations; ++k) - pAnimations[k].smElement = pAnimated + pAnimations[k].iShift; // przydzielenie wskaźnika do tabelki } } - if(token == "lowpolyinterior:") { + else if(token == "lowpolyinterior:") { // ABu: wnetrze lowpoly parser.getTokens(); parser >> asModel; - asModel = BaseDir + asModel; // McZapkie-200702 - dynamics maja swoje modele w dynamic/basedir - Global::asCurrentTexturePath = BaseDir; // biezaca sciezka do tekstur to dynamic/... + replace_slashes( asModel ); + if( asModel[ 0 ] == '/' ) { + // filename can potentially begin with a slash, and we don't need it + asModel.erase( 0, 1 ); + } + asModel = asBaseDir + asModel; // McZapkie-200702 - dynamics maja swoje modele w dynamic/basedir + Global.asCurrentTexturePath = asBaseDir; // biezaca sciezka do tekstur to dynamic/... mdLowPolyInt = TModelsManager::GetModel(asModel, true); - // Global::asCurrentTexturePath=AnsiString(szTexturePath); //kiedyś uproszczone wnętrze mieszało tekstury nieba } - if( token == "brakemode:" ) { + else if( token == "brakemode:" ) { // Ra 15-01: gałka nastawy hamulca parser.getTokens(); parser >> asAnimName; - smBrakeMode = mdModel->GetFromName(asAnimName.c_str()); + smBrakeMode = GetSubmodelFromName( mdModel, asAnimName ); // jeszcze wczytać kąty obrotu dla poszczególnych ustawień } - if( token == "loadmode:" ) { + else if( token == "loadmode:" ) { // Ra 15-01: gałka nastawy hamulca parser.getTokens(); parser >> asAnimName; - smLoadMode = mdModel->GetFromName(asAnimName.c_str()); + smLoadMode = GetSubmodelFromName( mdModel, asAnimName ); // jeszcze wczytać kąty obrotu dla poszczególnych ustawień } else if (token == "animwheelprefix:") { // prefiks kręcących się kół - int i, j, k, m; + int i, k, m; + unsigned int j; parser.getTokens( 1, false ); parser >> token; for (i = 0; i < iAnimType[ANIM_WHEELS]; ++i) // liczba osi { // McZapkie-050402: wyszukiwanie kol o nazwie str* asAnimName = token + std::to_string(i + 1); - pAnimations[i].smAnimated = mdModel->GetFromName(asAnimName.c_str()); // ustalenie submodelu + pAnimations[i].smAnimated = GetSubmodelFromName( mdModel, asAnimName ); if (pAnimations[i].smAnimated) { //++iAnimatedAxles; pAnimations[i].smAnimated->WillBeAnimated(); // wyłączenie optymalizacji transformu -/* pAnimations[i].yUpdate = UpdateAxle; // animacja osi -*/ pAnimations[ i ].yUpdate = std::bind( &TDynamicObject::UpdateAxle, this, std::placeholders::_1 ); + pAnimations[i].yUpdate = std::bind( &TDynamicObject::UpdateAxle, this, std::placeholders::_1 ); pAnimations[i].fMaxDist = 50 * MoverParameters->WheelDiameter; // nie kręcić w większej odległości pAnimations[i].fMaxDist *= pAnimations[i].fMaxDist * MoverParameters->WheelDiameter; // 50m do kwadratu, a średnica do trzeciej - pAnimations[i].fMaxDist *= Global::fDistanceFactor; // współczynnik przeliczeniowy jakości ekranu + pAnimations[i].fMaxDist *= Global.fDistanceFactor; // współczynnik przeliczeniowy jakości ekranu } } // Ra: ustawianie indeksów osi @@ -4761,7 +4749,7 @@ void TDynamicObject::LoadMMediaFile(std::string BaseDir, std::string TypeName, // Ra: pantografy po nowemu mają literki i numerki } // Pantografy - Winger 160204 - if( token == "animpantrd1prefix:" ) { + else if( token == "animpantrd1prefix:" ) { // prefiks ramion dolnych 1 parser.getTokens(); parser >> token; float4x4 m; // macierz do wyliczenia pozycji i wektora ruchu pantografu @@ -4770,7 +4758,7 @@ void TDynamicObject::LoadMMediaFile(std::string BaseDir, std::string TypeName, for (int i = 0; i < iAnimType[ANIM_PANTS]; i++) { // Winger 160204: wyszukiwanie max 2 patykow o nazwie str* asAnimName = token + std::to_string(i + 1); - sm = mdModel->GetFromName(asAnimName.c_str()); + sm = GetSubmodelFromName( mdModel, asAnimName ); pants[i].smElement[0] = sm; // jak NULL, to nie będzie animowany if (sm) { // w EP09 wywalało się tu z powodu NULL @@ -4779,27 +4767,22 @@ void TDynamicObject::LoadMMediaFile(std::string BaseDir, std::string TypeName, // m(3)[1]=m[3][1]+0.054; //w górę o wysokość ślizgu (na razie tak) if ((mdModel->Flags() & 0x8000) == 0) // jeśli wczytano z T3D m.InitialRotate(); // może być potrzebny dodatkowy obrót, jeśli wczytano z T3D, tzn. przed wykonaniem Init() - pants[i].fParamPants->vPos.z = - m[3][0]; // przesunięcie w bok (asymetria) - pants[i].fParamPants->vPos.y = - m[3][1]; // przesunięcie w górę odczytane z modelu + pants[i].fParamPants->vPos.z = m[3][0]; // przesunięcie w bok (asymetria) + pants[i].fParamPants->vPos.y = m[3][1]; // przesunięcie w górę odczytane z modelu if ((sm = pants[i].smElement[0]->ChildGet()) != NULL) { // jeśli ma potomny, można policzyć długość (odległość potomnego od osi obrotu) m = float4x4(*sm->GetMatrix()); // wystarczyłby wskaźnik, nie trzeba kopiować // może trzeba: pobrać macierz dolnego ramienia, wyzerować przesunięcie, przemnożyć przez macierz górnego pants[i].fParamPants->fHoriz = -fabs(m[3][1]); - pants[i].fParamPants->fLenL1 = - hypot(m[3][1], m[3][2]); // po osi OX nie potrzeba - pants[i].fParamPants->fAngleL0 = - atan2(fabs(m[3][2]), fabs(m[3][1])); + pants[i].fParamPants->fLenL1 = hypot(m[3][1], m[3][2]); // po osi OX nie potrzeba + pants[i].fParamPants->fAngleL0 = atan2(fabs(m[3][2]), fabs(m[3][1])); // if (pants[i].fParamPants->fAngleL0fAngleL0+=M_PI; //gdyby w odwrotną stronę wyszło // if // ((pants[i].fParamPants->fAngleL0<0.03)||(pants[i].fParamPants->fAngleL0>0.09)) // //normalnie ok. 0.05 // pants[i].fParamPants->fAngleL0=pants[i].fParamPants->fAngleL; - pants[i].fParamPants->fAngleL = pants[i].fParamPants->fAngleL0; // początkowy kąt dolnego - // ramienia + pants[i].fParamPants->fAngleL = pants[i].fParamPants->fAngleL0; // początkowy kąt dolnego ramienia if ((sm = sm->ChildGet()) != NULL) { // jeśli dalej jest ślizg, można policzyć długość górnego ramienia m = float4x4(*sm->GetMatrix()); // wystarczyłby wskaźnik, @@ -4825,12 +4808,9 @@ void TDynamicObject::LoadMMediaFile(std::string BaseDir, std::string TypeName, float det = Det(m); if (std::fabs(det - 1.0) < 0.001) // dopuszczamy 1 promil błędu na skalowaniu ślizgu { // skalowanie jest w normie, można pobrać wymiary z modelu - pants[i].fParamPants->fHeight = - sm->MaxY(m); // przeliczenie maksimum wysokości wierzchołków względem macierzy - pants[i].fParamPants->fHeight -= - m[3][1]; // odjęcie wysokości pivota ślizgu - pants[i].fParamPants->vPos.x = - m[3][2]; // przy okazji odczytać z modelu pozycję w długości + pants[i].fParamPants->fHeight = sm->MaxY(m); // przeliczenie maksimum wysokości wierzchołków względem macierzy + pants[i].fParamPants->fHeight -= m[3][1]; // odjęcie wysokości pivota ślizgu + pants[i].fParamPants->vPos.x = m[3][2]; // przy okazji odczytać z modelu pozycję w długości // ErrorLog("Model OK: "+asModel+", // height="+pants[i].fParamPants->fHeight); // ErrorLog("Model OK: "+asModel+", @@ -4838,18 +4818,19 @@ void TDynamicObject::LoadMMediaFile(std::string BaseDir, std::string TypeName, } else { // gdy ktoś przesadził ze skalowaniem - pants[i].fParamPants->fHeight = - 0.0; // niech będzie odczyt z pantfactors: - ErrorLog("Bad model: " + asModel + ", scale of " + - (sm->pName) + " is " + - std::to_string(100.0 * det) + "%"); + pants[i].fParamPants->fHeight = 0.0; // niech będzie odczyt z pantfactors: + ErrorLog( + "Bad model: " + asModel + ", scale of " + (sm->pName) + " is " + std::to_string(100.0 * det) + "%", + logtype::model ); } } } } - else - ErrorLog("Bad model: " + asFileName + " - missed submodel " + - asAnimName); // brak ramienia + else { + // brak ramienia + pants[ i ].fParamPants->fHeight = 0.0; // niech będzie odczyt z pantfactors: + ErrorLog( "Bad model: " + asFileName + " - missed submodel " + asAnimName, logtype::model ); + } } } @@ -4862,7 +4843,7 @@ void TDynamicObject::LoadMMediaFile(std::string BaseDir, std::string TypeName, for( int i = 0; i < iAnimType[ ANIM_PANTS ]; i++ ) { // Winger 160204: wyszukiwanie max 2 patykow o nazwie str* asAnimName = token + std::to_string( i + 1 ); - sm = mdModel->GetFromName( asAnimName.c_str() ); + sm = GetSubmodelFromName( mdModel, asAnimName ); pants[ i ].smElement[ 1 ] = sm; // jak NULL, to nie będzie animowany if( sm ) { // w EP09 wywalało się tu z powodu NULL sm->WillBeAnimated(); @@ -4883,54 +4864,59 @@ void TDynamicObject::LoadMMediaFile(std::string BaseDir, std::string TypeName, } } else - ErrorLog( "Bad model: " + asFileName + " - missed submodel " + - asAnimName ); // brak ramienia + ErrorLog( "Bad model: " + asFileName + " - missed submodel " + asAnimName, logtype::model ); // brak ramienia } - } + } } else if( token == "animpantrg1prefix:" ) { // prefiks ramion górnych 1 parser.getTokens(); parser >> token; - if( pants ) { - for( int i = 0; i < iAnimType[ ANIM_PANTS ]; i++ ) { + if( pants ) { + for( int i = 0; i < iAnimType[ ANIM_PANTS ]; i++ ) { // Winger 160204: wyszukiwanie max 2 patykow o nazwie str* - asAnimName = token + std::to_string( i + 1 ); - pants[ i ].smElement[ 2 ] = mdModel->GetFromName( asAnimName.c_str() ); - pants[ i ].smElement[ 2 ]->WillBeAnimated(); - } + asAnimName = token + std::to_string( i + 1 ); + pants[ i ].smElement[ 2 ] = GetSubmodelFromName( mdModel, asAnimName ); + if( pants[ i ].smElement[ 2 ] ) { + pants[ i ].smElement[ 2 ]->WillBeAnimated(); + } } + } } else if( token == "animpantrg2prefix:" ) { // prefiks ramion górnych 2 - parser.getTokens(); parser >> token; - if( pants ) { - for( int i = 0; i < iAnimType[ ANIM_PANTS ]; i++ ) { + parser.getTokens(); parser >> token; + if( pants ) { + for( int i = 0; i < iAnimType[ ANIM_PANTS ]; i++ ) { // Winger 160204: wyszukiwanie max 2 patykow o nazwie str* - asAnimName = token + std::to_string( i + 1 ); - pants[ i ].smElement[ 3 ] = mdModel->GetFromName( asAnimName.c_str() ); - pants[ i ].smElement[ 3 ]->WillBeAnimated(); - } + asAnimName = token + std::to_string( i + 1 ); + pants[ i ].smElement[ 3 ] = GetSubmodelFromName( mdModel, asAnimName ); + if( pants[ i ].smElement[ 3 ] ) { + pants[ i ].smElement[ 3 ]->WillBeAnimated(); + } } + } } else if( token == "animpantslprefix:" ) { // prefiks ślizgaczy parser.getTokens(); parser >> token; - if( pants ) { - for( int i = 0; i < iAnimType[ ANIM_PANTS ]; i++ ) { + if( pants ) { + for( int i = 0; i < iAnimType[ ANIM_PANTS ]; i++ ) { // Winger 160204: wyszukiwanie max 2 patykow o nazwie str* - asAnimName = token + std::to_string( i + 1 ); - pants[ i ].smElement[ 4 ] = mdModel->GetFromName( asAnimName.c_str() ); - pants[ i ].smElement[ 4 ]->WillBeAnimated(); -/* pants[ i ].yUpdate = UpdatePant; -*/ pants[ i ].yUpdate = std::bind( &TDynamicObject::UpdatePant, this, std::placeholders::_1 ); - pants[ i ].fMaxDist = 300 * 300; // nie podnosić w większej odległości - pants[ i ].iNumber = i; - } + asAnimName = token + std::to_string( i + 1 ); + pants[ i ].smElement[ 4 ] = GetSubmodelFromName( mdModel, asAnimName ); + if( pants[ i ].smElement[ 4 ] ) { + pants[ i ].smElement[ 4 ]->WillBeAnimated(); + pants[ i ].yUpdate = std::bind( &TDynamicObject::UpdatePant, this, std::placeholders::_1 ); + pants[ i ].fMaxDist = 300 * 300; // nie podnosić w większej odległości + pants[ i ].iNumber = i; + } } + } } + else if( token == "pantfactors:" ) { // Winger 010304: // parametry pantografow @@ -4950,39 +4936,46 @@ void TDynamicObject::LoadMMediaFile(std::string BaseDir, std::string TypeName, pant1x = -pant1x; pant2x = -pant2x; } - if( pants ) { - for( int i = 0; i < iAnimType[ ANIM_PANTS ]; ++i ) { // przepisanie współczynników do pantografów (na razie - // nie będzie lepiej) - pants[ i ].fParamPants->fAngleL = - pants[i].fParamPants->fAngleL0; // początkowy kąt dolnego ramienia - pants[ i ].fParamPants->fAngleU = - pants[i].fParamPants->fAngleU0; // początkowy kąt + if( pants ) { + for( int i = 0; i < iAnimType[ ANIM_PANTS ]; ++i ) { + // przepisanie współczynników do pantografów (na razie nie będzie lepiej) + auto &pantograph { *(pants[ i ].fParamPants) }; + + pantograph.fAngleL = pantograph.fAngleL0; // początkowy kąt dolnego ramienia + pantograph.fAngleU = pantograph.fAngleU0; // początkowy kąt // pants[i].fParamPants->PantWys=1.22*sin(pants[i].fParamPants->fAngleL)+1.755*sin(pants[i].fParamPants->fAngleU); // //wysokość początkowa // pants[i].fParamPants->PantWys=1.176289*sin(pants[i].fParamPants->fAngleL)+1.724482197*sin(pants[i].fParamPants->fAngleU); // //wysokość początkowa - if( pants[ i ].fParamPants->fHeight == 0.0 ) // gdy jest nieprawdopodobna wartość (np. nie znaleziony ślizg) + if( pantograph.fHeight == 0.0 ) // gdy jest nieprawdopodobna wartość (np. nie znaleziony ślizg) { // gdy pomiary modelu nie udały się, odczyt podanych parametrów z MMD - pants[ i ].fParamPants->vPos.x = ( i & 1 ) ? pant2x : pant1x; - pants[ i ].fParamPants->fHeight = - ( i & 1 ) ? pant2h : - pant1h; // wysokość ślizgu jest zapisana w MMD + pantograph.vPos.x = + ( i & 1 ) ? + pant2x : + pant1x; + pantograph.fHeight = + ( i & 1 ) ? + pant2h : + pant1h; // wysokość ślizgu jest zapisana w MMD } - pants[ i ].fParamPants->PantWys = - pants[ i ].fParamPants->fLenL1 * sin( pants[ i ].fParamPants->fAngleL ) + - pants[ i ].fParamPants->fLenU1 * sin( pants[ i ].fParamPants->fAngleU ) + - pants[i].fParamPants->fHeight; // wysokość początkowa - // pants[i].fParamPants->vPos.y=panty-panth-pants[i].fParamPants->PantWys; - // //np. 4.429-0.097=4.332=~4.335 - // pants[i].fParamPants->vPos.z=0; //niezerowe dla pantografów - // asymetrycznych - pants[ i ].fParamPants->PantTraction = pants[ i ].fParamPants->PantWys; - pants[ i ].fParamPants->fWidth = - 0.5 * - MoverParameters->EnginePowerSource.CollectorParameters - .CSW; // połowa szerokości ślizgu; jest w "Power: CSW=" + pantograph.PantWys = + pantograph.fLenL1 * sin( pantograph.fAngleL ) + + pantograph.fLenU1 * sin( pantograph.fAngleU ) + + pantograph.fHeight; // wysokość początkowa + // pants[i].fParamPants->vPos.y=panty-panth-pants[i].fParamPants->PantWys; //np. 4.429-0.097=4.332=~4.335 + if( pantograph.vPos.y == 0.0 ) { + // crude fallback, place the pantograph(s) atop of the vehicle-sized box + pantograph.vPos.y = MoverParameters->Dim.H - pantograph.fHeight - pantograph.PantWys; + } + // pants[i].fParamPants->vPos.z=0; //niezerowe dla pantografów asymetrycznych + pantograph.PantTraction = pantograph.PantWys; + // połowa szerokości ślizgu; jest w "Power: CSW=" + pantograph.fWidth = 0.5 * MoverParameters->EnginePowerSource.CollectorParameters.CSW; + + // create sound emitters for the pantograph + m_pantographsounds.emplace_back(); } - } + } } else if (token == "animpistonprefix:") { @@ -5024,7 +5017,7 @@ void TDynamicObject::LoadMMediaFile(std::string BaseDir, std::string TypeName, (k) */ MoverParameters->EnginePowerSource.PowerType = - SteamPower; // Ra: po chamsku, ale z CHK nie działa + TPowerType::SteamPower; // Ra: po chamsku, ale z CHK nie działa } else if( token == "animreturnprefix:" ) { @@ -5053,11 +5046,13 @@ void TDynamicObject::LoadMMediaFile(std::string BaseDir, std::string TypeName, // prefiks wahaczy parser.getTokens(); parser >> token; asAnimName = ""; - for (int i = 1; i <= 4; i++) - { // McZapkie-050402: wyszukiwanie max 4 wahaczy o nazwie str* - asAnimName = token + std::to_string(i); - smWahacze[i - 1] = mdModel->GetFromName(asAnimName.c_str()); - smWahacze[i - 1]->WillBeAnimated(); + for( int i = 1; i <= 4; ++i ) { + // McZapkie-050402: wyszukiwanie max 4 wahaczy o nazwie str* + asAnimName = token + std::to_string( i ); + smWahacze[ i - 1 ] = GetSubmodelFromName( mdModel, asAnimName ); + if( smWahacze[ i - 1 ] ) { + smWahacze[ i - 1 ]->WillBeAnimated(); + } } parser.getTokens(); parser >> token; if( token == "pendulumamplitude:" ) { @@ -5065,64 +5060,114 @@ void TDynamicObject::LoadMMediaFile(std::string BaseDir, std::string TypeName, parser >> fWahaczeAmp; } } - /* - else if (str == AnsiString("engineer:")) - { // nazwa submodelu maszynisty - str = Parser->GetNextSymbol(); - smMechanik0 = mdModel->GetFromName(str.c_str()); - if (!smMechanik0) - { // jak nie ma bez numerka, to może jest z - // numerkiem? - smMechanik0 = mdModel->GetFromName(AnsiString(str + "1").c_str()); - smMechanik1 = mdModel->GetFromName(AnsiString(str + "2").c_str()); - } - // aby dało się go obracać, musi mieć włączoną animację w T3D! - // if (!smMechanik1) //jeśli drugiego nie ma - // if (smMechanik0) //a jest pierwszy - // smMechanik0->WillBeAnimated(); //to będziemy go obracać - } - */ else if( token == "animdoorprefix:" ) { - // nazwa animowanych drzwi - int i, j, k, m; + // nazwa animowanych drzwi + int i, j; parser.getTokens(1, false); parser >> token; for (i = 0, j = 0; i < ANIM_DOORS; ++i) j += iAnimType[i]; // zliczanie wcześniejszych animacji for (i = 0; i < iAnimType[ANIM_DOORS]; ++i) // liczba drzwi { // NBMX wrzesien 2003: wyszukiwanie drzwi o nazwie str* + // ustalenie submodelu asAnimName = token + std::to_string(i + 1); - pAnimations[i + j].smAnimated = - mdModel->GetFromName(asAnimName.c_str()); // ustalenie submodelu + pAnimations[ i + j ].smAnimated = GetSubmodelFromName( mdModel, asAnimName ); if (pAnimations[i + j].smAnimated) { //++iAnimatedDoors; pAnimations[i + j].smAnimated->WillBeAnimated(); // wyłączenie optymalizacji transformu switch (MoverParameters->DoorOpenMethod) { // od razu zapinamy potrzebny typ animacji case 1: -/* pAnimations[i + j].yUpdate = UpdateDoorTranslate; -*/ pAnimations[ i + j ].yUpdate = std::bind( &TDynamicObject::UpdateDoorTranslate, this, std::placeholders::_1 ); + pAnimations[ i + j ].yUpdate = std::bind( &TDynamicObject::UpdateDoorTranslate, this, std::placeholders::_1 ); break; case 2: -/* pAnimations[i + j].yUpdate = UpdateDoorRotate; -*/ pAnimations[ i + j ].yUpdate = std::bind( &TDynamicObject::UpdateDoorRotate, this, std::placeholders::_1 ); + pAnimations[ i + j ].yUpdate = std::bind( &TDynamicObject::UpdateDoorRotate, this, std::placeholders::_1 ); break; case 3: -/* pAnimations[i + j].yUpdate = UpdateDoorFold; -*/ pAnimations[ i + j ].yUpdate = std::bind( &TDynamicObject::UpdateDoorFold, this, std::placeholders::_1 ); + pAnimations[ i + j ].yUpdate = std::bind( &TDynamicObject::UpdateDoorFold, this, std::placeholders::_1 ); break; // obrót 3 kolejnych submodeli case 4: -/* pAnimations[i + j].yUpdate = UpdateDoorPlug; -*/ pAnimations[ i + j ].yUpdate = std::bind( &TDynamicObject::UpdateDoorPlug, this, std::placeholders::_1 ); + pAnimations[ i + j ].yUpdate = std::bind( &TDynamicObject::UpdateDoorPlug, this, std::placeholders::_1 ); break; default: break; } pAnimations[i + j].iNumber = i; // parzyste działają inaczej niż nieparzyste pAnimations[i + j].fMaxDist = 300 * 300; // drzwi to z daleka widać +/* + // NOTE: no longer used pAnimations[i + j].fSpeed = Random(150); // oryginalny koncept z DoorSpeedFactor pAnimations[i + j].fSpeed = (pAnimations[i + j].fSpeed + 100) / 100; - // Ra: te współczynniki są bez sensu, bo modyfikują wektor przesunięcia +*/ + } + } + } + + else if( token == "animstepprefix:" ) { + // animated doorstep submodel name prefix + int i, j; + parser.getTokens(1, false); parser >> token; + for (i = 0, j = 0; i < ANIM_DOORSTEPS; ++i) + j += iAnimType[i]; // zliczanie wcześniejszych animacji + for (i = 0; i < iAnimType[ANIM_DOORSTEPS]; ++i) // liczba drzwi + { // NBMX wrzesien 2003: wyszukiwanie drzwi o nazwie str* + // ustalenie submodelu + asAnimName = token + std::to_string(i + 1); + pAnimations[i + j].smAnimated = GetSubmodelFromName( mdModel, asAnimName ); + if (pAnimations[i + j].smAnimated) + { //++iAnimatedDoors; + pAnimations[i + j].smAnimated->WillBeAnimated(); // wyłączenie optymalizacji transformu + switch (MoverParameters->PlatformOpenMethod) + { // od razu zapinamy potrzebny typ animacji + case 1: // shift + pAnimations[ i + j ].yUpdate = std::bind( &TDynamicObject::UpdatePlatformTranslate, this, std::placeholders::_1 ); + break; + case 2: // rotate + pAnimations[ i + j ].yUpdate = std::bind( &TDynamicObject::UpdatePlatformRotate, this, std::placeholders::_1 ); + break; + default: + break; + } + pAnimations[i + j].iNumber = i; // parzyste działają inaczej niż nieparzyste + pAnimations[i + j].fMaxDist = 150 * 150; // drzwi to z daleka widać +/* + // NOTE: no longer used + pAnimations[i + j].fSpeed = Random(150); // oryginalny koncept z DoorSpeedFactor + pAnimations[i + j].fSpeed = (pAnimations[i + j].fSpeed + 100) / 100; +*/ + } + } + } + + else if( token == "animmirrorprefix:" ) { + // animated mirror submodel name prefix + int i, j; + parser.getTokens( 1, false ); parser >> token; + for( i = 0, j = 0; i < ANIM_MIRRORS; ++i ) + j += iAnimType[ i ]; // zliczanie wcześniejszych animacji + for( i = 0; i < iAnimType[ ANIM_MIRRORS ]; ++i ) // liczba drzwi + { // NBMX wrzesien 2003: wyszukiwanie drzwi o nazwie str* + // ustalenie submodelu + asAnimName = token + std::to_string( i + 1 ); + pAnimations[ i + j ].smAnimated = GetSubmodelFromName( mdModel, asAnimName ); + if( pAnimations[ i + j ].smAnimated ) { + pAnimations[ i + j ].smAnimated->WillBeAnimated(); // wyłączenie optymalizacji transformu + // od razu zapinamy potrzebny typ animacji + auto const offset { pAnimations[ i + j ].smAnimated->offset() }; + pAnimations[ i + j ].yUpdate = std::bind( &TDynamicObject::UpdateMirror, this, std::placeholders::_1 ); + // we don't expect more than 2-4 mirrors, so it should be safe to store submodel location (front/rear) in the higher bits + // parzyste działają inaczej niż nieparzyste + pAnimations[ i + j ].iNumber = + ( ( pAnimations[ i + j ].smAnimated->offset().z > 0 ? + side::front : + side::rear ) << 4 ) + + i; + pAnimations[ i + j ].fMaxDist = 150 * 150; // drzwi to z daleka widać +/* + // NOTE: no longer used + pAnimations[i + j].fSpeed = Random(150); // oryginalny koncept z DoorSpeedFactor + pAnimations[i + j].fSpeed = (pAnimations[i + j].fSpeed + 100) / 100; +*/ } } } @@ -5130,7 +5175,7 @@ void TDynamicObject::LoadMMediaFile(std::string BaseDir, std::string TypeName, } while( ( token != "" ) && ( token != "endmodels" ) ); - } + } // models else if( token == "sounds:" ) { // dzwieki @@ -5139,360 +5184,780 @@ void TDynamicObject::LoadMMediaFile(std::string BaseDir, std::string TypeName, parser.getTokens(); parser >> token; if( token == "wheel_clatter:" ){ // polozenia osi w/m srodka pojazdu + double dSDist; parser.getTokens( 1, false ); parser >> dSDist; - for( int i = 0; i < iAxles; i++ ) { - parser.getTokens( 1, false ); - parser >> dWheelsPosition[ i ]; - parser.getTokens(); - parser >> token; - if( token != "end" ) { - rsStukot[ i ].Init( token, dSDist, GetPosition().x, - GetPosition().y + dWheelsPosition[ i ], GetPosition().z, - true ); - } + while( ( ( token = parser.getToken() ) != "" ) + && ( token != "end" ) ) { + // add another axle entry to the list + axle_sounds axle { + 0, + std::atof( token.c_str() ), + { sound_placement::external, static_cast( dSDist ) } }; + axle.clatter.deserialize( parser, sound_type::single ); + axle.clatter.owner( this ); + axle.clatter.offset( { 0, 0, -axle.offset } ); // vehicle faces +Z in 'its' space, for axle locations negative value means ahead of centre + m_axlesounds.emplace_back( axle ); } - if( token != "end" ) { - // TODO: double-check if this if() and/or retrieval makes sense here - parser.getTokens( 1, false ); parser >> token; - } + // arrange the axles in case they're listed out of order + std::sort( + std::begin( m_axlesounds ), std::end( m_axlesounds ), + []( axle_sounds const &Left, axle_sounds const &Right ) { + return ( Left.offset < Right.offset ); } ); } else if( ( token == "engine:" ) && ( MoverParameters->Power > 0 ) ) { // plik z dzwiekiem silnika, mnozniki i ofsety amp. i czest. - double attenuation; - parser.getTokens( 2, false ); - parser - >> token - >> attenuation; - rsSilnik.Init( - token, attenuation, - GetPosition().x, GetPosition().y, GetPosition().z, - true, true ); - if( rsSilnik.GetWaveTime() == 0 ) { - ErrorLog( "Missed sound: \"" + token + "\" for " + asFileName ); - } - parser.getTokens( 1, false ); - parser >> rsSilnik.AM; - if( MoverParameters->EngineType == DieselEngine ) { + m_powertrainsounds.engine.deserialize( parser, sound_type::single, sound_parameters::range | sound_parameters::amplitude | sound_parameters::frequency ); + m_powertrainsounds.engine.owner( this ); - rsSilnik.AM /= ( MoverParameters->Power + MoverParameters->nmax * 60 ); - } - else if( MoverParameters->EngineType == DieselElectric ) { - - rsSilnik.AM /= ( MoverParameters->Power * 3 ); - } - else { - - rsSilnik.AM /= ( MoverParameters->Power + MoverParameters->nmax * 60 + MoverParameters->Power + MoverParameters->Power ); - } - parser.getTokens( 3, false ); - parser - >> rsSilnik.AA - >> rsSilnik.FM // MoverParameters->nmax; - >> rsSilnik.FA; + auto const amplitudedivisor = static_cast( ( + MoverParameters->EngineType == TEngineType::DieselEngine ? 1 : + MoverParameters->EngineType == TEngineType::DieselElectric ? 1 : + MoverParameters->nmax * 60 + MoverParameters->Power * 3 ) ); + m_powertrainsounds.engine.m_amplitudefactor /= amplitudedivisor; } - else if( ( token == "ventilator:" ) - && ( ( MoverParameters->EngineType == ElectricSeriesMotor ) - || ( MoverParameters->EngineType == ElectricInductionMotor ) ) ) { + else if( token == "dieselinc:" ) { + // dzwiek przy wlazeniu na obroty woodwarda + m_powertrainsounds.engine_revving.deserialize( parser, sound_type::single, sound_parameters::range ); + m_powertrainsounds.engine_revving.owner( this ); + } + + else if( token == "oilpump:" ) { + // plik z dzwiekiem wentylatora, mnozniki i ofsety amp. i czest. + m_powertrainsounds.oil_pump.deserialize( parser, sound_type::single ); + m_powertrainsounds.oil_pump.owner( this ); + } + + else if( ( token == "tractionmotor:" ) + && ( MoverParameters->Power > 0 ) ) { + // plik z dzwiekiem silnika, mnozniki i ofsety amp. i czest. + sound_source motortemplate { sound_placement::external }; + motortemplate.deserialize( parser, sound_type::single, sound_parameters::range | sound_parameters::amplitude | sound_parameters::frequency ); + motortemplate.owner( this ); + + auto const amplitudedivisor = static_cast( MoverParameters->nmax * 60 + MoverParameters->Power * 3 ); + motortemplate.m_amplitudefactor /= amplitudedivisor; + + if( true == m_powertrainsounds.motors.empty() ) { + // fallback for cases without specified motor locations, convert sound template to a single sound source + m_powertrainsounds.motors.emplace_back( motortemplate ); + } + else { + // apply configuration to all defined motors + for( auto &motor : m_powertrainsounds.motors ) { + // combine potential x- and y-axis offsets of the sound template with z-axis offsets of individual motors + auto motoroffset { motortemplate.offset() }; + motoroffset.z = motor.offset().z; + motor = motortemplate; + motor.offset( motoroffset ); + } + } + } + + else if( token == "motorblower:" ) { + + sound_source blowertemplate { sound_placement::engine }; + blowertemplate.deserialize( parser, sound_type::single, sound_parameters::range | sound_parameters::amplitude | sound_parameters::frequency ); + blowertemplate.owner( this ); + + auto const amplitudedivisor = static_cast( + MoverParameters->MotorBlowers[ side::front ].speed > 0.f ? + MoverParameters->MotorBlowers[ side::front ].speed * MoverParameters->nmax * 60 + MoverParameters->Power * 3 : + MoverParameters->MotorBlowers[ side::front ].speed * -1 ); + blowertemplate.m_amplitudefactor /= amplitudedivisor; + blowertemplate.m_frequencyfactor /= amplitudedivisor; + + if( true == m_powertrainsounds.motors.empty() ) { + // fallback for cases without specified motor locations, convert sound template to a single sound source + m_powertrainsounds.motorblowers.emplace_back( blowertemplate ); + } + else { + // apply configuration to all defined motor blowers + for( auto &blower : m_powertrainsounds.motorblowers ) { + // combine potential x- and y-axis offsets of the sound template with z-axis offsets of individual blowers + auto bloweroffset { blowertemplate.offset() }; + bloweroffset.z = blower.offset().z; + blower = blowertemplate; + blower.offset( bloweroffset ); + } + } + } + + else if( token == "inverter:" ) { // plik z dzwiekiem wentylatora, mnozniki i ofsety amp. i czest. - double attenuation; - parser.getTokens( 2, false ); - parser - >> token - >> attenuation; - rsWentylator.Init( - token, attenuation, - GetPosition().x, GetPosition().y, GetPosition().z, - true, true ); - parser.getTokens( 4, false ); - parser - >> rsWentylator.AM - >> rsWentylator.AA - >> rsWentylator.FM - >> rsWentylator.FA; - rsWentylator.AM /= MoverParameters->RVentnmax; - rsWentylator.FM /= MoverParameters->RVentnmax; + m_powertrainsounds.inverter.deserialize( parser, sound_type::single, sound_parameters::range | sound_parameters::amplitude | sound_parameters::frequency ); + m_powertrainsounds.inverter.owner( this ); } - else if( ( token == "transmission:" ) - && ( MoverParameters->EngineType == ElectricSeriesMotor ) ) { - // plik z dzwiekiem, mnozniki i ofsety amp. i czest. - double attenuation; - parser.getTokens( 2, false ); - parser - >> token - >> attenuation; - rsPrzekladnia.Init( - token, attenuation, - GetPosition().x, GetPosition().y, GetPosition().z, - true ); - rsPrzekladnia.AM = 0.029; - rsPrzekladnia.AA = 0.1; - rsPrzekladnia.FM = 0.005; - rsPrzekladnia.FA = 1.0; + else if( token == "ventilator:" ) { + // plik z dzwiekiem wentylatora, mnozniki i ofsety amp. i czest. + m_powertrainsounds.rsWentylator.deserialize( parser, sound_type::single, sound_parameters::range | sound_parameters::amplitude | sound_parameters::frequency ); + m_powertrainsounds.rsWentylator.owner( this ); + + m_powertrainsounds.rsWentylator.m_amplitudefactor /= MoverParameters->RVentnmax; + m_powertrainsounds.rsWentylator.m_frequencyfactor /= MoverParameters->RVentnmax; + } + + else if( token == "radiatorfan1:" ) { + // primary circuit radiator fan + m_powertrainsounds.radiator_fan.deserialize( parser, sound_type::single ); + m_powertrainsounds.radiator_fan.owner( this ); } - else if( token == "brake:" ){ + else if( token == "radiatorfan2" ) { + // auxiliary circuit radiator fan + m_powertrainsounds.radiator_fan.deserialize( parser, sound_type::single ); + m_powertrainsounds.radiator_fan.owner( this ); + } + + else if( token == "transmission:" ) { + // plik z dzwiekiem, mnozniki i ofsety amp. i czest. + // NOTE, fixed default parameters, legacy system leftover + m_powertrainsounds.transmission.m_amplitudefactor = 0.029; + m_powertrainsounds.transmission.m_amplitudeoffset = 0.1; + m_powertrainsounds.transmission.m_frequencyfactor = 0.005; + m_powertrainsounds.transmission.m_frequencyoffset = 1.0; + + m_powertrainsounds.transmission.deserialize( parser, sound_type::single, sound_parameters::range ); + m_powertrainsounds.transmission.owner( this ); + } + + else if( token == "brake:" ) { // plik z piskiem hamulca, mnozniki i ofsety amplitudy. - double attenuation; - parser.getTokens( 2, false ); - parser - >> token - >> attenuation; - rsPisk.Init( - token, attenuation, - GetPosition().x, GetPosition().y, GetPosition().z, - true ); - rsPisk.AM = parser.getToken(); - rsPisk.AA = parser.getToken() * ( 105 - Random( 10 ) ) / 100; - rsPisk.FM = 1.0; - rsPisk.FA = 0.0; + rsPisk.deserialize( parser, sound_type::single, sound_parameters::range | sound_parameters::amplitude ); + rsPisk.owner( this ); + + if( rsPisk.m_amplitudefactor > 10.f ) { + // HACK: convert old style activation point threshold to the new, regular amplitude adjustment system + rsPisk.m_amplitudefactor = 1.f; + rsPisk.m_amplitudeoffset = 0.f; + } + rsPisk.m_amplitudeoffset *= ( 105.f - Random( 10.f ) ) / 100.f; + } + + else if( token == "brakecylinderinc:" ) { + // brake cylinder pressure increase sounds + m_brakecylinderpistonadvance.deserialize( parser, sound_type::single ); + m_brakecylinderpistonadvance.owner( this ); + } + + else if( token == "brakecylinderdec:" ) { + // brake cylinder pressure decrease sounds + m_brakecylinderpistonrecede.deserialize( parser, sound_type::single ); + m_brakecylinderpistonrecede.owner( this ); } else if( token == "brakeacc:" ) { // plik z przyspieszaczem (upust po zlapaniu hamowania) - // sBrakeAcc.Init(str.c_str(),Parser->GetNextSymbol().ToDouble(),GetPosition().x,GetPosition().y,GetPosition().z,true); - parser.getTokens( 1, false ); parser >> token; - sBrakeAcc = TSoundsManager::GetFromName( token.c_str(), true ); + sBrakeAcc.deserialize( parser, sound_type::single ); + sBrakeAcc.owner( this ); + bBrakeAcc = true; - // sBrakeAcc.AM=1.0; - // sBrakeAcc.AA=0.0; - // sBrakeAcc.FM=1.0; - // sBrakeAcc.FA=0.0; } else if( token == "unbrake:" ) { // plik z piskiem hamulca, mnozniki i ofsety amplitudy. - double attenuation; - parser.getTokens( 2, false ); - parser - >> token - >> attenuation; - rsUnbrake.Init( - token, attenuation, - GetPosition().x, GetPosition().y, GetPosition().z, - true ); - rsUnbrake.AM = 1.0; - rsUnbrake.AA = 0.0; - rsUnbrake.FM = 1.0; - rsUnbrake.FA = 0.0; + rsUnbrake.deserialize( parser, sound_type::single, sound_parameters::range ); + rsUnbrake.owner( this ); } else if( token == "derail:" ) { // dzwiek przy wykolejeniu - double attenuation; - parser.getTokens( 2, false ); - parser - >> token - >> attenuation; - rsDerailment.Init( - token, attenuation, - GetPosition().x, GetPosition().y, GetPosition().z, - true ); - rsDerailment.AM = 1.0; - rsDerailment.AA = 0.0; - rsDerailment.FM = 1.0; - rsDerailment.FA = 0.0; - } - - else if( token == "dieselinc:" ) { - // dzwiek przy wlazeniu na obroty woodwarda - double attenuation; - parser.getTokens( 2, false ); - parser - >> token - >> attenuation; - rsDiesielInc.Init( - token, attenuation, - GetPosition().x, GetPosition().y, GetPosition().z, - true ); - rsDiesielInc.AM = 1.0; - rsDiesielInc.AA = 0.0; - rsDiesielInc.FM = 1.0; - rsDiesielInc.FA = 0.0; + rsDerailment.deserialize( parser, sound_type::single, sound_parameters::range ); + rsDerailment.owner( this ); } else if( token == "curve:" ) { - - double attenuation; - parser.getTokens( 2, false ); - parser - >> token - >> attenuation; - rscurve.Init( - token, attenuation, - GetPosition().x, GetPosition().y, GetPosition().z, - true ); - rscurve.AM = 1.0; - rscurve.AA = 0.0; - rscurve.FM = 1.0; - rscurve.FA = 0.0; + rscurve.deserialize( parser, sound_type::single, sound_parameters::range ); + rscurve.owner( this ); } else if( token == "horn1:" ) { // pliki z trabieniem - sHorn1.Load( parser, GetPosition() ); + sHorn1.deserialize( parser, sound_type::multipart, sound_parameters::range ); + sHorn1.owner( this ); } else if( token == "horn2:" ) { // pliki z trabieniem wysokoton. - sHorn2.Load( parser, GetPosition() ); - if( iHornWarning ) { + sHorn2.deserialize( parser, sound_type::multipart, sound_parameters::range ); + sHorn2.owner( this ); + // TBD, TODO: move horn selection to ai config file + if( iHornWarning ) { iHornWarning = 2; // numer syreny do użycia po otrzymaniu sygnału do jazdy - } + } } + else if( token == "horn3:" ) { + sHorn3.deserialize( parser, sound_type::multipart, sound_parameters::range ); + sHorn3.owner( this ); + } + else if( token == "departuresignal:" ) { // pliki z sygnalem odjazdu - sDepartureSignal.Load( parser, GetPosition() ); + sDepartureSignal.deserialize( parser, sound_type::multipart, sound_parameters::range ); + sDepartureSignal.owner( this ); } else if( token == "pantographup:" ) { // pliki dzwiekow pantografow - parser.getTokens( 1, false ); parser >> token; - sPantUp.Init( - token, 50, - GetPosition().x, GetPosition().y, GetPosition().z, - true ); - sPantUp.AM = 50000; - sPantUp.AA = -1 * ( 105 - Random( 10 ) ) / 100; - sPantUp.FM = 1.0; - sPantUp.FA = 0.0; + sound_source pantographup { sound_placement::external }; + pantographup.deserialize( parser, sound_type::single ); + pantographup.owner( this ); + for( auto &pantograph : m_pantographsounds ) { + pantograph.sPantUp = pantographup; + } } else if( token == "pantographdown:" ) { // pliki dzwiekow pantografow - parser.getTokens( 1, false ); parser >> token; - sPantDown.Init( - token, 50, - GetPosition().x, GetPosition().y, GetPosition().z, - true ); - sPantDown.AM = 50000; - sPantDown.AA = -1 * ( 105 - Random( 10 ) ) / 100; - sPantDown.FM = 1.0; - sPantDown.FA = 0.0; + sound_source pantographdown { sound_placement::external }; + pantographdown.deserialize( parser, sound_type::single ); + pantographdown.owner( this ); + for( auto &pantograph : m_pantographsounds ) { + pantograph.sPantDown = pantographdown; + } } else if( token == "compressor:" ) { // pliki ze sprezarka - sCompressor.Load( parser, GetPosition() ); + sCompressor.deserialize( parser, sound_type::multipart, sound_parameters::range ); + sCompressor.owner( this ); } else if( token == "converter:" ) { // pliki z przetwornica - // if (MoverParameters->EngineType==DieselElectric) //będzie modulowany? - sConverter.Load( parser, GetPosition() ); + sConverter.deserialize( parser, sound_type::multipart, sound_parameters::range ); + sConverter.owner( this ); + } + + else if( token == "heater:" ) { + // train heating device + sHeater.deserialize( parser, sound_type::single ); + sHeater.owner( this ); } else if( token == "turbo:" ) { // pliki z turbogeneratorem - sTurbo.Load( parser, GetPosition() ); + m_powertrainsounds.engine_turbo.deserialize( parser, sound_type::multipart, sound_parameters::range ); + m_powertrainsounds.engine_turbo.owner( this ); + m_powertrainsounds.engine_turbo.gain( 0 ); } else if( token == "small-compressor:" ) { // pliki z przetwornica - sSmallCompressor.Load( parser, GetPosition() ); + sSmallCompressor.deserialize( parser, sound_type::multipart, sound_parameters::range ); + sSmallCompressor.owner( this ); } else if( token == "dooropen:" ) { - - parser.getTokens( 1, false ); parser >> token; - rsDoorOpen.Init( - token, 50, - GetPosition().x, GetPosition().y, GetPosition().z, - true ); - rsDoorOpen.AM = 50000; - rsDoorOpen.AA = -1 * ( 105 - Random( 10 ) ) / 100; - rsDoorOpen.FM = 1.0; - rsDoorOpen.FA = 0.0; + sound_source soundtemplate { sound_placement::general, 25.f }; + soundtemplate.deserialize( parser, sound_type::single ); + soundtemplate.owner( this ); + for( auto &door : m_doorsounds ) { + // apply configuration to all defined doors, but preserve their individual offsets + auto const dooroffset { door.rsDoorOpen.offset() }; + door.rsDoorOpen = soundtemplate; + door.rsDoorOpen.offset( dooroffset ); + } } else if( token == "doorclose:" ) { + sound_source soundtemplate { sound_placement::general, 25.f }; + soundtemplate.deserialize( parser, sound_type::single ); + soundtemplate.owner( this ); + for( auto &door : m_doorsounds ) { + // apply configuration to all defined doors, but preserve their individual offsets + auto const dooroffset { door.rsDoorClose.offset() }; + door.rsDoorClose = soundtemplate; + door.rsDoorClose.offset( dooroffset ); + } + } - parser.getTokens( 1, false ); parser >> token; - rsDoorClose.Init( - token, 50, - GetPosition().x, GetPosition().y, GetPosition().z, - true ); - rsDoorClose.AM = 50000; - rsDoorClose.AA = -1 * ( 105 - Random( 10 ) ) / 100; - rsDoorClose.FM = 1.0; - rsDoorClose.FA = 0.0; + else if( token == "doorlock:" ) { + sound_source soundtemplate { sound_placement::general, 12.5f }; + soundtemplate.deserialize( parser, sound_type::single ); + soundtemplate.owner( this ); + for( auto &door : m_doorsounds ) { + // apply configuration to all defined doors, but preserve their individual offsets + auto const dooroffset { door.lock.offset() }; + door.lock = soundtemplate; + door.lock.offset( dooroffset ); + } + } + + else if( token == "doorunlock:" ) { + sound_source soundtemplate { sound_placement::general, 12.5f }; + soundtemplate.deserialize( parser, sound_type::single ); + soundtemplate.owner( this ); + for( auto &door : m_doorsounds ) { + // apply configuration to all defined doors, but preserve their individual offsets + auto const dooroffset { door.unlock.offset() }; + door.unlock = soundtemplate; + door.unlock.offset( dooroffset ); + } + } + + else if( token == "doorstepopen:" ) { + sound_source soundtemplate { sound_placement::general, 20.f }; + soundtemplate.deserialize( parser, sound_type::single ); + soundtemplate.owner( this ); + for( auto &door : m_doorsounds ) { + // apply configuration to all defined doors, but preserve their individual offsets + auto const dooroffset { door.step_open.offset() }; + door.step_open = soundtemplate; + door.step_open.offset( dooroffset ); + } + } + + else if( token == "doorstepclose:" ) { + sound_source soundtemplate { sound_placement::general, 20.f }; + soundtemplate.deserialize( parser, sound_type::single ); + soundtemplate.owner( this ); + for( auto &door : m_doorsounds ) { + // apply configuration to all defined doors, but preserve their individual offsets + auto const dooroffset { door.step_close.offset() }; + door.step_close = soundtemplate; + door.step_close.offset( dooroffset ); + } + } + + else if( token == "unloading:" ) { + m_exchangesounds.unloading.deserialize( parser, sound_type::single ); + m_exchangesounds.unloading.owner( this ); + } + + else if( token == "loading:" ) { + m_exchangesounds.loading.deserialize( parser, sound_type::single ); + m_exchangesounds.loading.owner( this ); } else if( token == "sand:" ) { - // pliki z piasecznica - sSand.Load( parser, GetPosition() ); + sSand.deserialize( parser, sound_type::multipart, sound_parameters::range ); + sSand.owner( this ); } else if( token == "releaser:" ) { // pliki z odluzniaczem - sReleaser.Load( parser, GetPosition() ); + sReleaser.deserialize( parser, sound_type::multipart, sound_parameters::range ); + sReleaser.owner( this ); + } + + else if( token == "outernoise:" ) { + // szum podczas jazdy: + sound_source noisetemplate { sound_placement::external, EU07_SOUND_RUNNINGNOISECUTOFFRANGE }; + noisetemplate.deserialize( parser, sound_type::single, sound_parameters::amplitude | sound_parameters::frequency, MoverParameters->Vmax ); + noisetemplate.owner( this ); + + noisetemplate.m_amplitudefactor /= ( 1 + MoverParameters->Vmax ); + noisetemplate.m_frequencyfactor /= ( 1 + MoverParameters->Vmax ); + + if( true == m_bogiesounds.empty() ) { + // fallback for cases without specified noise locations, convert sound template to a single sound source + m_bogiesounds.emplace_back( noisetemplate ); + } + else { + // apply configuration to all defined bogies + for( auto &bogie : m_bogiesounds ) { + // combine potential x- and y-axis offsets of the sound template with z-axis offsets of individual motors + auto bogieoffset { noisetemplate.offset() }; + bogieoffset.z = bogie.offset().z; + bogie = noisetemplate; + bogie.offset( bogieoffset ); + } + } + } + + else if( token == "wheelflat:" ) { + // szum podczas jazdy: + m_wheelflat.deserialize( parser, sound_type::single, sound_parameters::frequency ); + m_wheelflat.owner( this ); } } while( ( token != "" ) && ( token != "endsounds" ) ); - } + } // sounds: - else if (token == "internaldata:") { - // dalej nie czytaj - do { - // zbieranie informacji o kabinach - token = ""; - parser.getTokens(); parser >> token; - if(token == "cab0model:") - { - parser.getTokens(); parser >> token; - if( token != "none" ) { iCabs = 2; } + else if( token == "locations:" ) { + do { + token = ""; + parser.getTokens(); parser >> token; + + if( token == "doors:" ) { + // a list of pairs: offset along vehicle's z-axis and sides on which the door is present; followed with "end" + while( ( ( token = parser.getToken() ) != "" ) + && ( token != "end" ) ) { + // vehicle faces +Z in 'its' space, for door locations negative value means ahead of centre + auto const offset { std::atof( token.c_str() ) * -1.f }; + // recognized side specifications are "right", "left" and "both" + auto const sides { parser.getToken() }; + // NOTE: we skip setting owner of the sounds, it'll be done during individual sound deserialization + door_sounds door; + // add entries to the list: + if( ( sides == "both" ) + || ( sides == "left" ) ) { + // left... + auto const location { glm::vec3 { MoverParameters->Dim.W * 0.5f, MoverParameters->Dim.H * 0.5f, offset } }; + door.rsDoorClose.offset( location ); + door.rsDoorOpen.offset( location ); + door.lock.offset( location ); + door.unlock.offset( location ); + door.step_close.offset( location ); + door.step_open.offset( location ); + m_doorsounds.emplace_back( door ); + } + if( ( sides == "both" ) + || ( sides == "right" ) ) { + // ...and right + auto const location { glm::vec3 { MoverParameters->Dim.W * -0.5f, MoverParameters->Dim.H * 0.5f, offset } }; + door.rsDoorClose.offset( location ); + door.rsDoorOpen.offset( location ); + door.lock.offset( location ); + door.unlock.offset( location ); + door.step_close.offset( location ); + door.step_open.offset( location ); + m_doorsounds.emplace_back( door ); + } + } } - else if (token == "cab1model:") - { - parser.getTokens(); parser >> token; - if( token != "none" ) { iCabs = 1; } + + else if( token == "tractionmotors:" ) { + // a list of offsets along vehicle's z-axis; followed with "end" + while( ( ( token = parser.getToken() ) != "" ) + && ( token != "end" ) ) { + // vehicle faces +Z in 'its' space, for motor locations negative value means ahead of centre + auto const offset { std::atof( token.c_str() ) * -1.f }; + // NOTE: we skip setting owner of the sounds, it'll be done during individual sound deserialization + sound_source motor { sound_placement::external }; // generally traction motor + sound_source motorblower { sound_placement::engine }; // associated motor blowers + // add entry to the list + auto const location { glm::vec3 { 0.f, 0.f, offset } }; + motor.offset( location ); + m_powertrainsounds.motors.emplace_back( motor ); + motorblower.offset( location ); + m_powertrainsounds.motorblowers.emplace_back( motorblower ); + } } - else if (token == "cab2model:") - { - parser.getTokens(); parser >> token; - if( token != "none" ) { iCabs = 4; } - } - } while( token != "" ); + else if( token == "bogies:" ) { + // a list of offsets along vehicle's z-axis; followed with "end" + while( ( ( token = parser.getToken() ) != "" ) + && ( token != "end" ) ) { + // vehicle faces +Z in 'its' space, for bogie locations negative value means ahead of centre + auto const offset { std::atof( token.c_str() ) * -1.f }; + // NOTE: we skip setting owner of the sounds, it'll be done during individual sound deserialization + sound_source bogienoise { sound_placement::external, EU07_SOUND_RUNNINGNOISECUTOFFRANGE }; + // add entry to the list + auto const location { glm::vec3 { 0.f, 0.f, offset } }; + bogienoise.offset( location ); + m_bogiesounds.emplace_back( bogienoise ); + } + } - Stop_InternalData = true; - } + } while( ( token != "" ) + && ( token != "endlocations" ) ); - } while( ( token != "" ) - && ( false == Stop_InternalData ) ); + } // locations: + + else if( token == "internaldata:" ) { + // dalej nie czytaj + do { + // zbieranie informacji o kabinach + token = ""; + parser.getTokens(); parser >> token; + if( token == "cab0model:" ) { + parser.getTokens(); parser >> token; + if( token != "none" ) { iCabs |= 0x2; } + } + else if( token == "cab1model:" ) { + parser.getTokens(); parser >> token; + if( token != "none" ) { iCabs |= 0x1; } + } + else if( token == "cab2model:" ) { + parser.getTokens(); parser >> token; + if( token != "none" ) { iCabs |= 0x4; } + } + // engine sounds + else if( token == "ignition:" ) { + // odpalanie silnika + m_powertrainsounds.engine_ignition.deserialize( parser, sound_type::single ); + m_powertrainsounds.engine_ignition.owner( this ); + } else if (token == "shutdown:") { + m_powertrainsounds.engine_shutdown.deserialize(parser, sound_type::single); + m_powertrainsounds.engine_shutdown.owner(this); + } + else if( token == "engageslippery:" ) { + // tarcie tarcz sprzegla: + m_powertrainsounds.rsEngageSlippery.deserialize( parser, sound_type::single, sound_parameters::amplitude | sound_parameters::frequency ); + m_powertrainsounds.rsEngageSlippery.owner( this ); + + m_powertrainsounds.rsEngageSlippery.m_frequencyfactor /= ( 1 + MoverParameters->nmax ); + } + else if( token == "linebreakerclose:" ) { + m_powertrainsounds.linebreaker_close.deserialize( parser, sound_type::single ); + m_powertrainsounds.linebreaker_close.owner( this ); + } + else if( token == "linebreakeropen:" ) { + m_powertrainsounds.linebreaker_open.deserialize( parser, sound_type::single ); + m_powertrainsounds.linebreaker_open.owner( this ); + } + else if( token == "relay:" ) { + // styczniki itp: + m_powertrainsounds.motor_relay.deserialize( parser, sound_type::single ); + m_powertrainsounds.motor_relay.owner( this ); + } + else if( token == "shuntfield:" ) { + // styczniki itp: + m_powertrainsounds.motor_shuntfield.deserialize( parser, sound_type::single ); + m_powertrainsounds.motor_shuntfield.owner( this ); + } + else if( token == "wejscie_na_bezoporow:" ) { + // hunter-111211: wydzielenie wejscia na bezoporowa i na drugi uklad do pliku + m_powertrainsounds.dsbWejscie_na_bezoporow.deserialize( parser, sound_type::single ); + m_powertrainsounds.dsbWejscie_na_bezoporow.owner( this ); + } + else if( token == "wejscie_na_drugi_uklad:" ) { + m_powertrainsounds.motor_parallel.deserialize( parser, sound_type::single ); + m_powertrainsounds.motor_parallel.owner( this ); + } + else if( token == "pneumaticrelay:" ) { + // wylaczniki pneumatyczne: + dsbPneumaticRelay.deserialize( parser, sound_type::single ); + dsbPneumaticRelay.owner( this ); + } + // braking sounds + else if( token == "brakesound:" ) { + // hamowanie zwykle: + rsBrake.deserialize( parser, sound_type::single, sound_parameters::amplitude | sound_parameters::frequency ); + rsBrake.owner( this ); + // NOTE: can't pre-calculate amplitude normalization based on max brake force, as this varies depending on vehicle speed + rsBrake.m_frequencyfactor /= ( 1 + MoverParameters->Vmax ); + } + else if( token == "slipperysound:" ) { + // sanie: + rsSlippery.deserialize( parser, sound_type::single, sound_parameters::amplitude ); + rsSlippery.owner( this ); + + rsSlippery.m_amplitudefactor /= ( 1 + MoverParameters->Vmax ); + } + // coupler sounds + else if( token == "couplerattach:" ) { + // laczenie: + sound_source couplerattach { sound_placement::external }; + couplerattach.deserialize( parser, sound_type::single ); + couplerattach.owner( this ); + for( auto &couplersounds : m_couplersounds ) { + couplersounds.dsbCouplerAttach = couplerattach; + } + } + else if( token == "couplerdetach:" ) { + // rozlaczanie: + sound_source couplerdetach { sound_placement::external }; + couplerdetach.deserialize( parser, sound_type::single ); + couplerdetach.owner( this ); + for( auto &couplersounds : m_couplersounds ) { + couplersounds.dsbCouplerDetach = couplerdetach; + } + } + else if( token == "couplerstretch:" ) { + // coupler stretching + sound_source couplerstretch { sound_placement::external }; + couplerstretch.deserialize( parser, sound_type::single ); + couplerstretch.owner( this ); + for( auto &couplersounds : m_couplersounds ) { + couplersounds.dsbCouplerStretch = couplerstretch; + } + } + else if( token == "couplerstretch_loud:" ) { + // coupler stretching + sound_source couplerstretch { sound_placement::external }; + couplerstretch.deserialize( parser, sound_type::single ); + couplerstretch.owner( this ); + for( auto &couplersounds : m_couplersounds ) { + couplersounds.dsbCouplerStretch_loud = couplerstretch; + } + } + else if( token == "bufferclamp:" ) { + // buffers hitting one another + sound_source bufferclash { sound_placement::external }; + bufferclash.deserialize( parser, sound_type::single ); + bufferclash.owner( this ); + for( auto &couplersounds : m_couplersounds ) { + couplersounds.dsbBufferClamp = bufferclash; + } + } + else if( token == "bufferclamp_loud:" ) { + // buffers hitting one another + sound_source bufferclash { sound_placement::external }; + bufferclash.deserialize( parser, sound_type::single ); + bufferclash.owner( this ); + for( auto &couplersounds : m_couplersounds ) { + couplersounds.dsbBufferClamp_loud = bufferclash; + } + } + + } while( token != "" ); + + } // internaldata: + + } while( token != "" ); if( !iAnimations ) { // if the animations weren't defined the model is likely to be non-functional. warrants a warning. ErrorLog( "Animations tag is missing from the .mmd file \"" + asFileName + "\"" ); } + // assign default samples to sound emitters which weren't included in the config file + // engine + if( MoverParameters->Power > 0 ) { + if( true == m_powertrainsounds.dsbWejscie_na_bezoporow.empty() ) { + // hunter-111211: domyslne, gdy brak + m_powertrainsounds.dsbWejscie_na_bezoporow.deserialize( "wejscie_na_bezoporow.wav", sound_type::single ); + m_powertrainsounds.dsbWejscie_na_bezoporow.owner( this ); + } + if( true == m_powertrainsounds.motor_parallel.empty() ) { + m_powertrainsounds.motor_parallel.deserialize( "wescie_na_drugi_uklad.wav", sound_type::single ); + m_powertrainsounds.motor_parallel.owner( this ); + } + } + // braking sounds + if( true == rsUnbrake.empty() ) { + rsUnbrake.deserialize( "[1007]estluz.wav", sound_type::single ); + rsUnbrake.owner( this ); + } + // couplers + for( auto &couplersounds : m_couplersounds ) { + if( true == couplersounds.dsbCouplerAttach.empty() ) { + couplersounds.dsbCouplerAttach.deserialize( "couplerattach.wav", sound_type::single ); + couplersounds.dsbCouplerAttach.owner( this ); + } + if( true == couplersounds.dsbCouplerDetach.empty() ) { + couplersounds.dsbCouplerDetach.deserialize( "couplerdetach.wav", sound_type::single ); + couplersounds.dsbCouplerDetach.owner( this ); + } + if( true == couplersounds.dsbCouplerStretch.empty() ) { + couplersounds.dsbCouplerStretch.deserialize( "en57_couplerstretch.wav", sound_type::single ); + couplersounds.dsbCouplerStretch.owner( this ); + } + if( true == couplersounds.dsbBufferClamp.empty() ) { + couplersounds.dsbBufferClamp.deserialize( "en57_bufferclamp.wav", sound_type::single ); + couplersounds.dsbBufferClamp.owner( this ); + } + } + // other sounds + if( true == m_wheelflat.empty() ) { + m_wheelflat.deserialize( "lomotpodkucia.wav 0.23 0.0", sound_type::single, sound_parameters::frequency ); + m_wheelflat.owner( this ); + } + if( true == rscurve.empty() ) { + // hunter-111211: domyslne, gdy brak + rscurve.deserialize( "curve.wav", sound_type::single ); + rscurve.owner( this ); + } + + if (mdModel) - mdModel->Init(); // obrócenie modelu oraz optymalizacja, również zapisanie - // binarnego + mdModel->Init(); // obrócenie modelu oraz optymalizacja, również zapisanie binarnego if (mdLoad) mdLoad->Init(); - if (mdPrzedsionek) - mdPrzedsionek->Init(); if (mdLowPolyInt) mdLowPolyInt->Init(); - // sHorn2.CopyIfEmpty(sHorn1); ///żeby jednak trąbił też drugim - Global::asCurrentTexturePath = szTexturePath; // kiedyś uproszczone wnętrze mieszało tekstury nieba + + Global.asCurrentTexturePath = szTexturePath; // kiedyś uproszczone wnętrze mieszało tekstury nieba + Global.asCurrentDynamicPath = ""; + + // position sound emitters which weren't defined in the config file + // engine sounds, centre of the vehicle + auto const enginelocation { glm::vec3 {0.f, MoverParameters->Dim.H * 0.5f, 0.f } }; + m_powertrainsounds.position( enginelocation ); + // other engine compartment sounds + auto const nullvector { glm::vec3() }; + std::vector enginesounds = { + &sConverter, &sCompressor, &sSmallCompressor, &sHeater + }; + for( auto sound : enginesounds ) { + if( sound->offset() == nullvector ) { + sound->offset( enginelocation ); + } + } + + // pantographs + if( pants != nullptr ) { + std::size_t pantographindex { 0 }; + for( auto &pantographsounds : m_pantographsounds ) { + auto const pantographoffset { + glm::vec3( + 0.f, + pants[ pantographindex ].fParamPants->vPos.y, + -pants[ pantographindex ].fParamPants->vPos.x ) }; + pantographsounds.sPantUp.offset( pantographoffset ); + pantographsounds.sPantDown.offset( pantographoffset ); + ++pantographindex; + } + } + // doors + std::size_t dooranimationfirstindex { 0 }; + for( std::size_t i = 0; i < ANIM_DOORS; ++i ) { + // zliczanie wcześniejszych animacji + dooranimationfirstindex += iAnimType[ i ]; + } + // couplers + auto const frontcoupleroffset { glm::vec3{ 0.f, 1.f, MoverParameters->Dim.L * 0.5f } }; + m_couplersounds[ side::front ].dsbCouplerAttach.offset( frontcoupleroffset ); + m_couplersounds[ side::front ].dsbCouplerDetach.offset( frontcoupleroffset ); + m_couplersounds[ side::front ].dsbCouplerStretch.offset( frontcoupleroffset ); + m_couplersounds[ side::front ].dsbCouplerStretch_loud.offset( frontcoupleroffset ); + m_couplersounds[ side::front ].dsbBufferClamp.offset( frontcoupleroffset ); + m_couplersounds[ side::front ].dsbBufferClamp_loud.offset( frontcoupleroffset ); + auto const rearcoupleroffset { glm::vec3{ 0.f, 1.f, MoverParameters->Dim.L * -0.5f } }; + m_couplersounds[ side::rear ].dsbCouplerAttach.offset( rearcoupleroffset ); + m_couplersounds[ side::rear ].dsbCouplerDetach.offset( rearcoupleroffset ); + m_couplersounds[ side::rear ].dsbCouplerStretch.offset( rearcoupleroffset ); + m_couplersounds[ side::rear ].dsbCouplerStretch_loud.offset( rearcoupleroffset ); + m_couplersounds[ side::rear ].dsbBufferClamp.offset( rearcoupleroffset ); + m_couplersounds[ side::rear ].dsbBufferClamp_loud.offset( rearcoupleroffset ); +} + +TModel3d * +TDynamicObject::LoadMMediaFile_mdload( std::string const &Name ) const { + + if( Name.empty() ) { return nullptr; } + + // try first specialized version of the load model, vehiclename_loadname + TModel3d *loadmodel { nullptr }; + auto const specializedloadfilename { asBaseDir + MoverParameters->TypeName + "_" + Name }; + if( ( true == FileExists( specializedloadfilename + ".e3d" ) ) + || ( true == FileExists( specializedloadfilename + ".t3d" ) ) ) { + loadmodel = TModelsManager::GetModel( specializedloadfilename, true ); + } + if( loadmodel == nullptr ) { + // if this fails, try generic load model + loadmodel = TModelsManager::GetModel( asBaseDir + Name, true ); + } + return loadmodel; } //--------------------------------------------------------------------------- void TDynamicObject::RadioStop() { // zatrzymanie pojazdu - if (Mechanik) // o ile ktoś go prowadzi - if (MoverParameters->SecuritySystem.RadioStop && - MoverParameters->Radio) // jeśli pojazd ma RadioStop i jest on aktywny - Mechanik->PutCommand("Emergency_brake", 1.0, 1.0, &vPosition, stopRadio); + if( Mechanik ) { + // o ile ktoś go prowadzi + if( ( MoverParameters->SecuritySystem.RadioStop ) + && ( MoverParameters->Radio ) ) { + // jeśli pojazd ma RadioStop i jest on aktywny + // HACK cast until math types unification + Mechanik->PutCommand( "Emergency_brake", 1.0, 1.0, &static_cast(vPosition), stopRadio ); + // add onscreen notification for human driver + // TODO: do it selectively for the 'local' driver once the multiplayer is in + if( false == Mechanik->AIControllFlag ) { + ui::Transcripts.AddLine( "!! RADIO-STOP !!", 0.0, 10.0, false ); + } + } + } }; //--------------------------------------------------------------------------- @@ -5573,7 +6038,7 @@ void TDynamicObject::RaLightsSet(int head, int rear) // pojazdu if (!MoverParameters) return; // może tego nie być na początku - if (rear == 2 + 32 + 64) + if (rear == ( light::redmarker_left | light::redmarker_right | light::rearendsignals ) ) { // jeśli koniec pociągu, to trzeba ustalić, czy // jest tam czynna lokomotywa // EN57 może nie mieć końcówek od środka członu @@ -5582,15 +6047,20 @@ void TDynamicObject::RaLightsSet(int head, int rear) { // jeśli ma zarówno światła jak i końcówki, ustalić, czy jest w stanie // aktywnym // np. lokomotywa na zimno będzie mieć końcówki a nie światła - rear = 64; // tablice blaszane + rear = light::rearendsignals; // tablice blaszane // trzeba to uzależnić od "załączenia baterii" w pojeździe } - if (rear == 2 + 32 + 64) // jeśli nadal obydwie możliwości - if (iInventory & - (iDirection ? 0x2A : 0x15)) // czy ma jakieś światła czerowone od danej strony - rear = 2 + 32; // dwa światła czerwone - else - rear = 64; // tablice blaszane + if( rear == ( light::redmarker_left | light::redmarker_right | light::rearendsignals ) ) // jeśli nadal obydwie możliwości + if( iInventory[ + ( iDirection ? + side::rear : + side::front ) ] & ( light::redmarker_left | light::redmarker_right ) ) { + // czy ma jakieś światła czerowone od danej strony + rear = ( light::redmarker_left | light::redmarker_right ); // dwa światła czerwone + } + else { + rear = light::rearendsignals; // tablice blaszane + } } if (iDirection) // w zależności od kierunku pojazdu w składzie { // jesli pojazd stoi sprzęgiem 0 w stronę czoła @@ -5611,7 +6081,6 @@ void TDynamicObject::RaLightsSet(int head, int rear) int TDynamicObject::DirectionSet(int d) { // ustawienie kierunku w składzie (wykonuje AI) iDirection = d > 0 ? 1 : 0; // d:1=zgodny,-1=przeciwny; iDirection:1=zgodny,0=przeciwny; - CouplCounter = 20; //żeby normalnie skanować kolizje, to musi ruszyć z miejsca if (MyTrack) { // podczas wczytywania wstawiane jest AI, ale może jeszcze nie // być toru @@ -5694,7 +6163,7 @@ void TDynamicObject::CoupleDist() // double d1=MoverParameters->Couplers[1].CoupleDist; //sprzęg z tyłu // samochodu można olać, // dopóki nie jeździ na wstecznym - vector3 p1, p2; + Math3D::vector3 p1, p2; double d, w; // dopuszczalny dystans w poprzek MoverParameters->SetCoupleDist(); // liczenie standardowe if (MoverParameters->Couplers[0].Connected) // jeśli cokolwiek podłączone @@ -5770,22 +6239,27 @@ TDynamicObject * TDynamicObject::ControlledFind() // jeździć dobrze // również hamowanie wykonuje się zaworem w członie, a nie w silnikowym... TDynamicObject *d = this; // zaczynamy od aktualnego - if (d->MoverParameters->TrainType & dt_EZT) // na razie dotyczy to EZT - if (d->NextConnected ? d->MoverParameters->Couplers[1].AllowedFlag & ctrain_depot : false) - { // gdy jest człon od sprzęgu 1, a sprzęg łączony - // warsztatowo (powiedzmy) - if ((d->MoverParameters->Power < 1.0) && (d->NextConnected->MoverParameters->Power > - 1.0)) // my nie mamy mocy, ale ten drugi ma + if( d->MoverParameters->TrainType & dt_EZT ) { + // na razie dotyczy to EZT + if( ( d->NextConnected != nullptr ) + && ( true == TestFlag( d->MoverParameters->Couplers[ 1 ].AllowedFlag, coupling::permanent ) ) ) { + // gdy jest człon od sprzęgu 1, a sprzęg łączony warsztatowo (powiedzmy) + if( ( d->MoverParameters->Power < 1.0 ) + && ( d->NextConnected->MoverParameters->Power > 1.0 ) ) { + // my nie mamy mocy, ale ten drugi ma d = d->NextConnected; // będziemy sterować tym z mocą + } } - else if (d->PrevConnected ? d->MoverParameters->Couplers[0].AllowedFlag & ctrain_depot : - false) - { // gdy jest człon od sprzęgu 0, a sprzęg łączony - // warsztatowo (powiedzmy) - if ((d->MoverParameters->Power < 1.0) && (d->PrevConnected->MoverParameters->Power > - 1.0)) // my nie mamy mocy, ale ten drugi ma + else if( ( d->PrevConnected != nullptr ) + && ( true == TestFlag( d->MoverParameters->Couplers[ 0 ].AllowedFlag, coupling::permanent ) ) ) { + // gdy jest człon od sprzęgu 0, a sprzęg łączony warsztatowo (powiedzmy) + if( ( d->MoverParameters->Power < 1.0 ) + && ( d->PrevConnected->MoverParameters->Power > 1.0 ) ) { + // my nie mamy mocy, ale ten drugi ma d = d->PrevConnected; // będziemy sterować tym z mocą + } } + } return d; }; //--------------------------------------------------------------------------- @@ -5838,62 +6312,44 @@ int TDynamicObject::RouteWish(TTrack *tr) return Mechanik ? Mechanik->CrossRoute(tr) : 0; // wg AI albo prosto }; -std::string TDynamicObject::TextureTest(std::string const &name) -{ // Ra 2015-01: sprawdzenie dostępności tekstury o podanej nazwie - std::vector extensions = { ".dds", ".tga", ".bmp" }; - for( auto const &extension : extensions ) { - if( true == FileExists( name + extension ) ) { - return name + extension; - } - } - return ""; // nie znaleziona -}; - void TDynamicObject::DestinationSet(std::string to, std::string numer) -{ // ustawienie stacji - // docelowej oraz wymiennej - // tekstury 4, jeśli - // istnieje plik +{ // ustawienie stacji docelowej oraz wymiennej tekstury 4, jeśli istnieje plik // w zasadzie, to każdy wagon mógłby mieć inną stację docelową // zwłaszcza w towarowych, pod kątem zautomatyzowania maewrów albo pracy górki // ale to jeszcze potrwa, zanim będzie możliwe, na razie można wpisać stację z // rozkładu - if (abs(iMultiTex) >= 4) - return; // jak są 4 tekstury wymienne, to nie zmieniać rozkładem - numer = Global::Bezogonkow(numer); + if( std::abs( m_materialdata.multi_textures ) >= 4 ) { + // jak są 4 tekstury wymienne, to nie zmieniać rozkładem + return; + } + numer = Bezogonkow(numer); asDestination = to; - to = Global::Bezogonkow(to); // do szukania pliku obcinamy ogonki - std::string x = TextureTest(asBaseDir + numer + "@" + MoverParameters->TypeName); - if (!x.empty()) - { - ReplacableSkinID[4] = TextureManager.GetTextureId( x, "", 9); // rozmywania 0,1,4,5 nie nadają się - return; - } - x = TextureTest(asBaseDir + numer ); - if (!x.empty()) - { - ReplacableSkinID[4] = TextureManager.GetTextureId( x, "", 9); // rozmywania 0,1,4,5 nie nadają się - return; - } - if (to.empty()) + to = Bezogonkow(to); // do szukania pliku obcinamy ogonki + if( true == to.empty() ) { to = "nowhere"; - x = TextureTest(asBaseDir + to + "@" + MoverParameters->TypeName); // w pierwszej kolejności z nazwą FIZ/MMD - if (!x.empty()) - { - ReplacableSkinID[4] = TextureManager.GetTextureId( x, "", 9); // rozmywania 0,1,4,5 nie nadają się - return; } - x = TextureTest(asBaseDir + to); // na razie prymitywnie - if (!x.empty()) - ReplacableSkinID[4] = TextureManager.GetTextureId( x, "", 9); // rozmywania 0,1,4,5 nie nadają się - else - { - x = TextureTest(asBaseDir + "nowhere"); // jak nie znalazł dedykowanej, to niech daje nowhere - if (!x.empty()) - ReplacableSkinID[4] = TextureManager.GetTextureId( x, "", 9); - } - // Ra 2015-01: żeby zalogować błąd, trzeba by mieć pewność, że model używa - // tekstury nr 4 + // destination textures are kept in the vehicle's directory so we point the current texture path there + auto const currenttexturepath { Global.asCurrentTexturePath }; + Global.asCurrentTexturePath = asBaseDir; + // now see if we can find any version of the texture + std::vector destinations = { + numer + '@' + MoverParameters->TypeName, + numer, + to + '@' + MoverParameters->TypeName, + to, + "nowhere" + '@' + MoverParameters->TypeName, + "nowhere" }; + + for( auto const &destination : destinations ) { + + auto material = TextureTest( ToLower( destination ) ); + if( false == material.empty() ) { + m_materialdata.replacable_skins[ 4 ] = GfxRenderer.Fetch_Material( material ); + break; + } + } + // whether we got anything, restore previous texture path + Global.asCurrentTexturePath = currenttexturepath; }; void TDynamicObject::OverheadTrack(float o) @@ -5956,3 +6412,680 @@ TDynamicObject::ConnectedEnginePowerSource( TDynamicObject const *Caller ) const // ...if we're still here, report lack of power source return MoverParameters->EnginePowerSource.SourceType; } + + +void +TDynamicObject::powertrain_sounds::position( glm::vec3 const Location ) { + + auto const nullvector { glm::vec3() }; + std::vector enginesounds = { + &inverter, + &motor_relay, &dsbWejscie_na_bezoporow, &motor_parallel, &motor_shuntfield, &rsWentylator, + &engine, &engine_ignition, &engine_shutdown, &engine_revving, &engine_turbo, &oil_pump, &radiator_fan, &radiator_fan_aux, + &transmission, &rsEngageSlippery + }; + for( auto sound : enginesounds ) { + if( sound->offset() == nullvector ) { + sound->offset( Location ); + } + } +} + +void +TDynamicObject::powertrain_sounds::render( TMoverParameters const &Vehicle, double const Deltatime ) { + + if( Vehicle.Power == 0 ) { return; } + + double frequency { 1.0 }; + double volume { 0.0 }; + + // oil pump + if( true == Vehicle.OilPump.is_active ) { + oil_pump + .pitch( oil_pump.m_frequencyoffset + oil_pump.m_frequencyfactor * 1.f ) + .gain( oil_pump.m_amplitudeoffset + oil_pump.m_amplitudefactor * 1.f ) + .play( sound_flags::exclusive | sound_flags::looping ); + } + else { + oil_pump.stop(); + } + + // engine sounds + // ignition + if( engine_state_last != Vehicle.Mains ) { + + if( true == Vehicle.Mains ) { + // TODO: separate engine and main circuit + // engine activation + engine_shutdown.stop(); + engine_ignition + .pitch( engine_ignition.m_frequencyoffset + engine_ignition.m_frequencyfactor * 1.f ) + .gain( engine_ignition.m_amplitudeoffset + engine_ignition.m_amplitudefactor * 1.f ) + .play( sound_flags::exclusive ); + // main circuit activation + linebreaker_close + .pitch( linebreaker_close.m_frequencyoffset + linebreaker_close.m_frequencyfactor * 1.f ) + .gain( linebreaker_close.m_amplitudeoffset + linebreaker_close.m_amplitudefactor * 1.f ) + .play(); + } + else { + // engine deactivation + engine_ignition.stop(); + engine_shutdown.pitch( engine_shutdown.m_frequencyoffset + engine_shutdown.m_frequencyfactor * 1.f ) + .gain( engine_shutdown.m_amplitudeoffset + engine_shutdown.m_amplitudefactor * 1.f ) + .play( sound_flags::exclusive ); + // main circuit deactivation + linebreaker_open + .pitch( linebreaker_open.m_frequencyoffset + linebreaker_open.m_frequencyfactor * 1.f ) + .gain( linebreaker_open.m_amplitudeoffset + linebreaker_open.m_amplitudefactor * 1.f ) + .play(); + } + engine_state_last = Vehicle.Mains; + } + // main engine sound + if( true == Vehicle.Mains ) { + + if( ( std::abs( Vehicle.enrot ) > 0.01 ) + // McZapkie-280503: zeby dla dumb dzialal silnik na jalowych obrotach + || ( Vehicle.EngineType == TEngineType::Dumb ) ) { + + // frequency calculation + auto const normalizer { ( + true == engine.is_combined() ? + // for combined engine sound we calculate sound point in rpm, to make .mmd files setup easier + // NOTE: we supply 1/100th of actual value, as the sound module converts does the opposite, converting received (typically) 0-1 values to 0-100 range + 60.f * 0.01f : + // for legacy single-piece sounds the standard frequency calculation is left untouched + 1.f ) }; + frequency = + engine.m_frequencyoffset + + engine.m_frequencyfactor * std::abs( Vehicle.enrot ) * normalizer; + + if( Vehicle.EngineType == TEngineType::Dumb ) { + frequency -= 0.2 * Vehicle.EnginePower / ( 1 + Vehicle.Power * 1000 ); + } + + // base volume calculation + switch( Vehicle.EngineType ) { + // TODO: check calculated values + case TEngineType::DieselElectric: { + + volume = + engine.m_amplitudeoffset + + engine.m_amplitudefactor * ( + 0.25 * ( Vehicle.EnginePower / Vehicle.Power ) + + 0.75 * ( Vehicle.enrot * 60 ) / ( Vehicle.DElist[ Vehicle.MainCtrlPosNo ].RPM ) ); + break; + } + case TEngineType::DieselEngine: { + if( Vehicle.enrot > 0.0 ) { + volume = ( + Vehicle.EnginePower > 0 ? + engine.m_amplitudeoffset + engine.m_amplitudefactor * Vehicle.dizel_fill : + engine.m_amplitudeoffset + engine.m_amplitudefactor * std::fabs( Vehicle.enrot / Vehicle.dizel_nmax ) ); + } + break; + } + default: { + volume = + engine.m_amplitudeoffset + + engine.m_amplitudefactor * ( Vehicle.EnginePower + std::fabs( Vehicle.enrot ) * 60.0 ); + break; + } + } + + if( engine_volume >= 0.05 ) { + + auto enginerevvolume { 0.f }; + if( ( Vehicle.EngineType == TEngineType::DieselElectric ) + || ( Vehicle.EngineType == TEngineType::DieselEngine ) ) { + // diesel engine revolutions increase; it can potentially decrease volume of base engine sound + if( engine_revs_last != -1.f ) { + // calculate potential recent increase of engine revolutions + auto const revolutionsperminute { Vehicle.enrot * 60 }; + auto const revolutionsdifference { revolutionsperminute - engine_revs_last }; + auto const idlerevolutionsthreshold { 1.01 * ( + Vehicle.EngineType == TEngineType::DieselElectric ? + Vehicle.DElist[ 0 ].RPM : + Vehicle.dizel_nmin * 60 ) }; + + engine_revs_change = std::max( 0.0, engine_revs_change - 2.5 * Deltatime ); + if( ( revolutionsperminute > idlerevolutionsthreshold ) + && ( revolutionsdifference > 1.0 * Deltatime ) ) { + engine_revs_change = clamp( engine_revs_change + 5.0 * Deltatime, 0.0, 1.25 ); + } + enginerevvolume = 0.8 * engine_revs_change; + } + engine_revs_last = Vehicle.enrot * 60; + + auto const enginerevfrequency { ( + true == engine_revving.is_combined() ? + // if the sound contains multiple samples we reuse rpm-based calculation from the engine + frequency : + engine_revving.m_frequencyoffset + 1.f * engine_revving.m_frequencyfactor ) }; + + if( enginerevvolume > 0.02 ) { + engine_revving + .pitch( enginerevfrequency ) + .gain( enginerevvolume ) + .play( sound_flags::exclusive ); + } + else { + engine_revving.stop(); + } + } // diesel engines + + // multi-part revving sound pieces replace base engine sound, single revving simply gets mixed with the base + auto const enginevolume { ( + ( ( enginerevvolume > 0.02 ) && ( true == engine_revving.is_combined() ) ) ? + std::max( 0.0, engine_volume - enginerevvolume ) : + engine_volume ) }; + engine + .pitch( frequency ) + .gain( enginevolume ) + .play( sound_flags::exclusive | sound_flags::looping ); + } // enginevolume > 0.05 + } + else { + engine.stop(); + } + } + engine_volume = interpolate( engine_volume, volume, 0.25 ); + if( engine_volume < 0.05 ) { + engine.stop(); + } + + // youBy - przenioslem, bo diesel tez moze miec turbo + if( Vehicle.TurboTest > 0 ) { + // udawanie turbo: + auto const goalpitch { std::max( 0.025, ( engine_volume + engine_turbo.m_frequencyoffset ) * engine_turbo.m_frequencyfactor ) }; + auto const goalvolume { ( + ( ( Vehicle.MainCtrlPos >= Vehicle.TurboTest ) && ( Vehicle.enrot > 0.1 ) ) ? + std::max( 0.0, ( engine_turbo_pitch + engine_turbo.m_amplitudeoffset ) * engine_turbo.m_amplitudefactor ) : + 0.0 ) }; + auto const currentvolume { engine_turbo.gain() }; + auto const changerate { 0.4 * Deltatime }; + + engine_turbo_pitch = ( + engine_turbo_pitch > goalpitch ? + std::max( goalpitch, engine_turbo_pitch - changerate * 0.5 ) : + std::min( goalpitch, engine_turbo_pitch + changerate ) ); + + volume = ( + currentvolume > goalvolume ? + std::max( goalvolume, currentvolume - changerate ) : + std::min( goalvolume, currentvolume + changerate ) ); + + engine_turbo + .pitch( 0.4 + engine_turbo_pitch * 0.4 ) + .gain( volume ); + + if( volume > 0.05 ) { + engine_turbo.play( sound_flags::exclusive | sound_flags::looping ); + } + else { + engine_turbo.stop(); + } + } + + if( Vehicle.dizel_engage > 0.1 ) { + if( std::abs( Vehicle.dizel_engagedeltaomega ) > 0.2 ) { + frequency = rsEngageSlippery.m_frequencyoffset + rsEngageSlippery.m_frequencyfactor * std::fabs( Vehicle.dizel_engagedeltaomega ); + volume = rsEngageSlippery.m_amplitudeoffset + rsEngageSlippery.m_amplitudefactor * ( Vehicle.dizel_engage ); + } + else { + frequency = 1.f; // rsEngageSlippery.FA+0.7*rsEngageSlippery.FM*(fabs(mvControlled->enrot)+mvControlled->nmax); + volume = ( + Vehicle.dizel_engage > 0.2 ? + rsEngageSlippery.m_amplitudeoffset + 0.2 * rsEngageSlippery.m_amplitudefactor * ( Vehicle.enrot / Vehicle.nmax ) : + 0.f ); + } + + rsEngageSlippery + .pitch( frequency ) + .gain( volume ) + .play( sound_flags::exclusive | sound_flags::looping ); + } + else { + rsEngageSlippery.stop(); + } + + // motor sounds + volume = 0.0; + if( ( true == Vehicle.Mains ) + && ( false == motors.empty() ) ) { + + if( std::abs( Vehicle.enrot ) > 0.01 ) { + + auto const &motor { motors.front() }; + // frequency calculation + auto normalizer { 1.f }; + if( true == motor.is_combined() ) { + // for combined motor sound we calculate sound point in rpm, to make .mmd files setup easier + // NOTE: we supply 1/100th of actual value, as the sound module converts does the opposite, converting received (typically) 0-1 values to 0-100 range + normalizer = 60.f * 0.01f; + } + auto const motorrevolutions { std::abs( Vehicle.nrot ) * Vehicle.Transmision.Ratio }; + frequency = + motor.m_frequencyoffset + + motor.m_frequencyfactor * motorrevolutions * normalizer; + + // base volume calculation + switch( Vehicle.EngineType ) { + case TEngineType::ElectricInductionMotor: { + volume = + motor.m_amplitudeoffset + + motor.m_amplitudefactor * ( Vehicle.EnginePower + motorrevolutions * 2 ); + break; + } + case TEngineType::ElectricSeriesMotor: { + volume = + motor.m_amplitudeoffset + + motor.m_amplitudefactor * ( Vehicle.EnginePower + motorrevolutions * 60.0 ); + break; + } + default: { + volume = + motor.m_amplitudeoffset + + motor.m_amplitudefactor * motorrevolutions * 60.0; + break; + } + } + + if( Vehicle.EngineType == TEngineType::ElectricSeriesMotor ) { + // volume variation + if( ( volume < 1.0 ) + && ( Vehicle.EnginePower < 100 ) ) { + + auto const volumevariation { Random( 100 ) * Vehicle.enrot / ( 1 + Vehicle.nmax ) }; + if( volumevariation < 2 ) { + volume += volumevariation / 200; + } + } + + if( ( Vehicle.DynamicBrakeFlag ) + && ( Vehicle.EnginePower > 0.1 ) ) { + // Szociu - 29012012 - jeżeli uruchomiony jest hamulec elektrodynamiczny, odtwarzany jest dźwięk silnika + volume += 0.8; + } + } + // scale motor volume based on whether they're active + motor_momentum = + clamp( + motor_momentum + - 1.0 * Deltatime // smooth out decay + + std::abs( Vehicle.Mm ) / 60.0 * Deltatime, + 0.0, 1.25 ); + volume *= std::max( 0.25f, motor_momentum ); + + if( motor_volume >= 0.05 ) { + // apply calculated parameters to all motor instances + for( auto &motor : motors ) { + motor + .pitch( frequency ) + .gain( motor_volume ) + .play( sound_flags::exclusive | sound_flags::looping ); + } + } + } + else { + // stop all motor instances + for( auto &motor : motors ) { + motor.stop(); + } + } + } + motor_volume = interpolate( motor_volume, volume, 0.25 ); + if( motor_volume < 0.05 ) { + // stop all motor instances + for( auto &motor : motors ) { + motor.stop(); + } + } + // motor blowers + if( false == motorblowers.empty() ) { + for( auto &blowersound : motorblowers ) { + // match the motor blower and the sound source based on whether they're located in the front or the back of the vehicle + auto const &blower { Vehicle.MotorBlowers[ ( blowersound.offset().z > 0 ? side::front : side::rear ) ] }; + if( blower.revolutions > 1 ) { + + blowersound + .pitch( + true == blowersound.is_combined() ? + blower.revolutions * 0.01f : + blowersound.m_frequencyoffset + blowersound.m_frequencyfactor * blower.revolutions ) + .gain( blowersound.m_amplitudeoffset + blowersound.m_amplitudefactor * blower.revolutions ) + .play( sound_flags::exclusive | sound_flags::looping ); + } + else { + blowersound.stop(); + } + } + } + + // inverter sounds + if( Vehicle.EngineType == TEngineType::ElectricInductionMotor ) { + if( Vehicle.InverterFrequency > 0.1 ) { + + volume = inverter.m_amplitudeoffset + inverter.m_amplitudefactor * std::sqrt( std::abs( Vehicle.dizel_fill ) ); + + inverter + .pitch( inverter.m_frequencyoffset + inverter.m_frequencyfactor * Vehicle.InverterFrequency ) + .gain( volume ) + .play( sound_flags::exclusive | sound_flags::looping ); + } + else { + inverter.stop(); + } + } + // ventillator sounds + if( Vehicle.RventRot > 0.1 ) { + + rsWentylator + .pitch( rsWentylator.m_frequencyoffset + rsWentylator.m_frequencyfactor * Vehicle.RventRot ) + .gain( rsWentylator.m_amplitudeoffset + rsWentylator.m_amplitudefactor * Vehicle.RventRot ) + .play( sound_flags::exclusive | sound_flags::looping ); + } + else { + // ...otherwise shut down the sound + rsWentylator.stop(); + } + // radiator fan sounds + if( ( Vehicle.EngineType == TEngineType::DieselEngine ) + || ( Vehicle.EngineType == TEngineType::DieselElectric ) ) { + + if( Vehicle.dizel_heat.rpmw > 0.1 ) { + // NOTE: fan speed tends to max out at ~100 rpm; by default we try to get pitch range of 0.5-1.5 and volume range of 0.5-1.0 + radiator_fan + .pitch( 0.5 + radiator_fan.m_frequencyoffset + radiator_fan.m_frequencyfactor * Vehicle.dizel_heat.rpmw * 0.01 ) + .gain( 0.5 + radiator_fan.m_amplitudeoffset + 0.5 * radiator_fan.m_amplitudefactor * Vehicle.dizel_heat.rpmw * 0.01 ) + .play( sound_flags::exclusive | sound_flags::looping ); + } + else { + // ...otherwise shut down the sound + radiator_fan.stop(); + } + + if( Vehicle.dizel_heat.rpmw2 > 0.1 ) { + // NOTE: fan speed tends to max out at ~100 rpm; by default we try to get pitch range of 0.5-1.5 and volume range of 0.5-1.0 + radiator_fan_aux + .pitch( 0.5 + radiator_fan_aux.m_frequencyoffset + radiator_fan_aux.m_frequencyfactor * Vehicle.dizel_heat.rpmw2 * 0.01 ) + .gain( 0.5 + radiator_fan_aux.m_amplitudeoffset + 0.5 * radiator_fan_aux.m_amplitudefactor * Vehicle.dizel_heat.rpmw2 * 0.01 ) + .play( sound_flags::exclusive | sound_flags::looping ); + } + else { + // ...otherwise shut down the sound + radiator_fan_aux.stop(); + } + } + + // relay sounds + auto const soundflags { Vehicle.SoundFlag }; + if( TestFlag( soundflags, sound::relay ) ) { + // przekaznik - gdy bezpiecznik, automatyczny rozruch itp + if( true == TestFlag( soundflags, sound::shuntfield ) ) { + // shunt field + motor_shuntfield + .pitch( + true == motor_shuntfield.is_combined() ? + Vehicle.ScndCtrlActualPos * 0.01f : + motor_shuntfield.m_frequencyoffset + motor_shuntfield.m_frequencyfactor * 1.f ) + .gain( + motor_shuntfield.m_amplitudeoffset + ( + true == TestFlag( soundflags, sound::loud ) ? + 1.0f : + 0.8f ) + * motor_shuntfield.m_amplitudefactor ) + .play(); + } + else if( true == TestFlag( soundflags, sound::parallel ) ) { + // parallel mode + if( TestFlag( soundflags, sound::loud ) ) { + dsbWejscie_na_bezoporow.play(); + } + else { + motor_parallel.play(); + } + } + else { + // series mode + motor_relay + .pitch( + true == motor_relay.is_combined() ? + Vehicle.MainCtrlActualPos * 0.01f : + motor_relay.m_frequencyoffset + motor_relay.m_frequencyfactor * 1.f ) + .gain( + motor_relay.m_amplitudeoffset + ( + true == TestFlag( soundflags, sound::loud ) ? + 1.0f : + 0.8f ) + * motor_relay.m_amplitudefactor ) + .play(); + } + } + + if( Vehicle.Vel > 0.1 ) { + transmission + .pitch( transmission.m_frequencyoffset + transmission.m_frequencyfactor * Vehicle.Vel ) + .gain( transmission.m_amplitudeoffset + transmission.m_amplitudefactor * Vehicle.Vel ) + .play( sound_flags::exclusive | sound_flags::looping ); + } + else { + transmission.stop(); + } +} + + +// legacy method, calculates changes in simulation state over specified time +void +vehicle_table::update( double Deltatime, int Iterationcount ) { + // Ra: w zasadzie to trzeba by utworzyć oddzielną listę taboru do liczenia fizyki + // na którą by się zapisywały wszystkie pojazdy będące w ruchu + // pojazdy stojące nie potrzebują aktualizacji, chyba że np. ktoś im zmieni nastawę hamulca + // oddzielną listę można by zrobić na pojazdy z napędem, najlepiej posortowaną wg typu napędu + for( auto *vehicle : m_items ) { + if( false == vehicle->bEnabled ) { continue; } + // Ra: zmienić warunek na sprawdzanie pantografów w jednej zmiennej: czy pantografy i czy podniesione + if( vehicle->MoverParameters->EnginePowerSource.SourceType == TPowerSource::CurrentCollector ) { + update_traction( vehicle ); + } + vehicle->MoverParameters->ComputeConstans(); + vehicle->CoupleDist(); + } + if( Iterationcount > 1 ) { + // ABu: ponizsze wykonujemy tylko jesli wiecej niz jedna iteracja + for( int iteration = 0; iteration < ( Iterationcount - 1 ); ++iteration ) { + for( auto *vehicle : m_items ) { + vehicle->UpdateForce( Deltatime, Deltatime, false ); + } + for( auto *vehicle : m_items ) { + vehicle->FastUpdate( Deltatime ); + } + } + } + + auto const totaltime { Deltatime * Iterationcount }; // całkowity czas + + for( auto *vehicle : m_items ) { + vehicle->UpdateForce( Deltatime, totaltime, true ); + } + for( auto *vehicle : m_items ) { + // Ra 2015-01: tylko tu przelicza sieć trakcyjną + vehicle->Update( Deltatime, totaltime ); + } + + // jeśli jest coś do usunięcia z listy, to trzeba na końcu + erase_disabled(); +} + +// legacy method, checks for presence and height of traction wire for specified vehicle +void +vehicle_table::update_traction( TDynamicObject *Vehicle ) { + + auto const vFront = glm::make_vec3( Vehicle->VectorFront().getArray() ); // wektor normalny dla płaszczyzny ruchu pantografu + auto const vUp = glm::make_vec3( Vehicle->VectorUp().getArray() ); // wektor pionu pudła (pochylony od pionu na przechyłce) + auto const vLeft = glm::make_vec3( Vehicle->VectorLeft().getArray() ); // wektor odległości w bok (odchylony od poziomu na przechyłce) + auto const position = glm::dvec3 { Vehicle->GetPosition() }; // współrzędne środka pojazdu + + for( int pantographindex = 0; pantographindex < Vehicle->iAnimType[ ANIM_PANTS ]; ++pantographindex ) { + // pętla po pantografach + auto pantograph { Vehicle->pants[ pantographindex ].fParamPants }; + if( true == ( + pantographindex == side::front ? + Vehicle->MoverParameters->PantFrontUp : + Vehicle->MoverParameters->PantRearUp ) ) { + // jeśli pantograf podniesiony + auto const pant0 { position + ( vLeft * pantograph->vPos.z ) + ( vUp * pantograph->vPos.y ) + ( vFront * pantograph->vPos.x ) }; + if( pantograph->hvPowerWire != nullptr ) { + // jeżeli znamy drut z poprzedniego przebiegu + for( int attempts = 0; attempts < 30; ++attempts ) { + // powtarzane aż do znalezienia odpowiedniego odcinka na liście dwukierunkowej + if( pantograph->hvPowerWire->iLast & 0x3 ) { + // dla ostatniego i przedostatniego przęsła wymuszamy szukanie innego + // nie to, że nie ma, ale trzeba sprawdzić inne + pantograph->hvPowerWire = nullptr; + break; + } + if( pantograph->hvPowerWire->hvParallel ) { + // jeśli przęsło tworzy bieżnię wspólną, to trzeba sprawdzić pozostałe + // nie to, że nie ma, ale trzeba sprawdzić inne + pantograph->hvPowerWire = nullptr; + break; + } + // obliczamy wyraz wolny równania płaszczyzny (to miejsce nie jest odpowienie) + // podstawiamy równanie parametryczne drutu do równania płaszczyzny pantografu + auto const fRaParam = + -( glm::dot( pantograph->hvPowerWire->pPoint1, vFront ) - glm::dot( pant0, vFront ) ) + / glm::dot( pantograph->hvPowerWire->vParametric, vFront ); + + if( fRaParam < -0.001 ) { + // histereza rzędu 7cm na 70m typowego przęsła daje 1 promil + pantograph->hvPowerWire = pantograph->hvPowerWire->hvNext[ 0 ]; + continue; + } + if( fRaParam > 1.001 ) { + pantograph->hvPowerWire = pantograph->hvPowerWire->hvNext[ 1 ]; + continue; + } + // jeśli t jest w przedziale, wyznaczyć odległość wzdłuż wektorów vUp i vLeft + // punkt styku płaszczyzny z drutem (dla generatora łuku el.) + auto const vStyk { pantograph->hvPowerWire->pPoint1 + fRaParam * pantograph->hvPowerWire->vParametric }; + auto const vGdzie { vStyk - pant0 }; // wektor + // odległość w pionie musi być w zasięgu ruchu "pionowego" pantografu + // musi się mieścić w przedziale ruchu pantografu + auto const fVertical { glm::dot( vGdzie, vUp ) }; + // odległość w bok powinna być mniejsza niż pół szerokości pantografu + // to się musi mieścić w przedziale zależnym od szerokości pantografu + auto const fHorizontal { std::abs( glm::dot( vGdzie, vLeft ) ) - pantograph->fWidth }; + // jeśli w pionie albo w bok jest za daleko, to dany drut jest nieużyteczny + if( fHorizontal <= 0.0 ) { + // koniec pętli, aktualny drut pasuje + pantograph->PantTraction = fVertical; + break; + } + else { + // the wire is outside contact area and as of now we don't have good detection of parallel sections + // as such there's no guaratee there isn't parallel section present. + // therefore we don't bother checking if the wire is still within range of guide horns + // but simply force area search for potential better option + pantograph->hvPowerWire = nullptr; + break; + } + } + } + + if( pantograph->hvPowerWire == nullptr ) { + // look in the region for a suitable traction piece if we don't already have any + simulation::Region->update_traction( Vehicle, pantographindex ); + } + + if( ( pantograph->hvPowerWire == nullptr ) + && ( false == Global.bLiveTraction ) ) { + // jeśli drut nie znaleziony ale można oszukiwać to dajemy coś tam dla picu + Vehicle->pants[ pantographindex ].fParamPants->PantTraction = 1.4; + } + } + else { + // pantograph is down + pantograph->hvPowerWire = nullptr; + } + } +} + +// legacy method, sends list of vehicles over network +void +vehicle_table::DynamicList( bool const Onlycontrolled ) const { + // odesłanie nazw pojazdów dostępnych na scenerii (nazwy, szczególnie wagonów, mogą się powtarzać!) + for( auto const *vehicle : m_items ) { + if( ( false == Onlycontrolled ) + || ( vehicle->Mechanik != nullptr ) ) { + // same nazwy pojazdów + multiplayer::WyslijString( vehicle->asName, 6 ); + } + } + // informacja o końcu listy + multiplayer::WyslijString( "none", 6 ); +} + +// maintenance; removes from tracks consists with vehicles marked as disabled +bool +vehicle_table::erase_disabled() { + + if( false == TDynamicObject::bDynamicRemove ) { return false; } + + // go through the list and retrieve vehicles scheduled for removal... + type_sequence disabledvehicles; + for( auto *vehicle : m_items ) { + if( false == vehicle->bEnabled ) { + disabledvehicles.emplace_back( vehicle ); + } + } + // ...now propagate removal flag through affected consists... + for( auto *vehicle : disabledvehicles ) { + TDynamicObject *coupledvehicle { vehicle }; + while( ( coupledvehicle = coupledvehicle->Next() ) != nullptr ) { + coupledvehicle->bEnabled = false; + } + // (try to) run propagation in both directions, it's simpler than branching based on direction etc + coupledvehicle = vehicle; + while( ( coupledvehicle = coupledvehicle->Prev() ) != nullptr ) { + coupledvehicle->bEnabled = false; + } + } + // ...then actually remove all disabled vehicles... + auto vehicleiter = std::begin( m_items ); + while( vehicleiter != std::end( m_items ) ) { + + auto *vehicle { *vehicleiter }; + + if( true == vehicle->bEnabled ) { + ++vehicleiter; + } + else { + if( ( vehicle->MyTrack != nullptr ) + && ( true == vehicle->MyTrack->RemoveDynamicObject( vehicle ) ) ) { + vehicle->MyTrack = nullptr; + } + if( ( simulation::Train != nullptr ) + && ( simulation::Train->Dynamic() == vehicle ) ) { + // clear potential train binding + // TBD, TODO: kill vehicle sounds + SafeDelete( simulation::Train ); + } + // remove potential entries in the light array + simulation::Lights.remove( vehicle ); +/* + // finally get rid of the vehicle and its record themselves + // BUG: deleting the vehicle leaves dangling pointers in event->Activator and potentially elsewhere + // TBD, TODO: either mark 'dead' vehicles with additional flag, or delete the references as well + SafeDelete( vehicle ); + vehicleiter = m_items.erase( vehicleiter ); +*/ + ++vehicleiter; // NOTE: instead of the erase in the disabled section + } + } + // ...and call it a day + TDynamicObject::bDynamicRemove = false; + + return true; +} diff --git a/DynObj.h b/DynObj.h index bda873a7..f0731d3a 100644 --- a/DynObj.h +++ b/DynObj.h @@ -12,17 +12,17 @@ http://mozilla.org/MPL/2.0/. #include #include +#include "classes.h" +#include "material.h" +#include "mczapkie/mover.h" #include "TrkFoll.h" -// McZapkie: -#include "RealSound.h" -#include "AdvSound.h" #include "Button.h" #include "AirCoupler.h" +#include "sound.h" //--------------------------------------------------------------------------- //--------------------------------------------------------------------------- //--------------------------------------------------------------------------- -int const ANIM_TYPES = 7; // Ra: ilość typów animacji int const ANIM_WHEELS = 0; // koła int const ANIM_DOORS = 1; // drzwi int const ANIM_LEVERS = 2; // elementy obracane (wycieraczki, koła skrętne, przestawiacze, klocki ham.) @@ -30,6 +30,9 @@ int const ANIM_BUFFERS = 3; // elementy przesuwane (zderzaki) int const ANIM_BOOGIES = 4; // wózki (są skręcane w dwóch osiach) int const ANIM_PANTS = 5; // pantografy int const ANIM_STEAMS = 6; // napęd parowozu +int const ANIM_DOORSTEPS = 7; +int const ANIM_MIRRORS = 8; +int const ANIM_TYPES = 9; // Ra: ilość typów animacji class TAnim; //typedef void(__closure *TUpdate)(TAnim *pAnim); // typ funkcji aktualizującej położenie submodeli @@ -77,7 +80,7 @@ class TAnimValveGear class TAnimPant { // współczynniki do animacji pantografu public: - vector3 vPos; // Ra: współrzędne punktu zerowego pantografu (X dodatnie dla przedniego) + Math3D::vector3 vPos; // Ra: współrzędne punktu zerowego pantografu (X dodatnie dla przedniego) double fLenL1; // długość dolnego ramienia 1, odczytana z modelu double fLenU1; // długość górnego ramienia 1, odczytana z modelu double fLenL2; // długość dolnego ramienia 2, odczytana z modelu @@ -102,7 +105,14 @@ class TAnimPant class TAnim { // klasa animowanej części pojazdu (koła, drzwi, pantografy, burty, napęd parowozu, siłowniki // itd.) - public: +public: +// constructor + TAnim() = default; +// destructor + ~TAnim(); +// methods + int TypeSet( int i, int fl = 0 ); // ustawienie typu +// members union { TSubModel *smAnimated; // animowany submodel (jeśli tylko jeden, np. oś) @@ -124,80 +134,105 @@ class TAnim int *iIntBase; // jakiś int w fizyce }; // void _fastcall Update(); //wskaźnik do funkcji aktualizacji animacji - int iFlags; // flagi animacji + int iFlags{ 0 }; // flagi animacji float fMaxDist; // do jakiej odległości wykonywana jest animacja float fSpeed; // parametr szybkości animacji int iNumber; // numer kolejny obiektu - public: - TAnim(); - ~TAnim(); + TUpdate yUpdate; // metoda TDynamicObject aktualizująca animację - int TypeSet(int i, int fl = 0); // ustawienie typu +/* void Parovoz(); // wykonanie obliczeń animacji +*/ }; -//--------------------------------------------------------------------------- -//--------------------------------------------------------------------------- //--------------------------------------------------------------------------- -class TDynamicObject -{ // klasa pojazdu - private: // położenie pojazdu w świecie oraz parametry ruchu - vector3 vPosition; // Ra: pozycja pojazdu liczona zaraz po przesunięciu - vector3 vCoulpler[2]; // współrzędne sprzęgów do liczenia zderzeń czołowych - vector3 vUp, vFront, vLeft; // wektory jednostkowe ustawienia pojazdu +// parameters for the material object, as currently used by various simulator models +struct material_data { + + int textures_alpha{ 0x30300030 }; // maska przezroczystości tekstur. default: tekstury wymienne nie mają przezroczystości + material_handle replacable_skins[ 5 ] = { null_handle, null_handle, null_handle, null_handle, null_handle }; // McZapkie:zmienialne nadwozie + int multi_textures{ 0 }; //<0 tekstury wskazane wpisem, >0 tekstury z przecinkami, =0 jedna +}; + +class TDynamicObject { // klasa pojazdu + + friend opengl_renderer; + +public: + static bool bDynamicRemove; // moved from ground + +private: // położenie pojazdu w świecie oraz parametry ruchu + Math3D::vector3 vPosition; // Ra: pozycja pojazdu liczona zaraz po przesunięciu + Math3D::vector3 vCoulpler[ 2 ]; // współrzędne sprzęgów do liczenia zderzeń czołowych + Math3D::vector3 vUp, vFront, vLeft; // wektory jednostkowe ustawienia pojazdu int iDirection; // kierunek pojazdu względem czoła składu (1=zgodny,0=przeciwny) TTrackShape ts; // parametry toru przekazywane do fizyki TTrackParam tp; // parametry toru przekazywane do fizyki TTrackFollower Axle0; // oś z przodu (od sprzęgu 0) TTrackFollower Axle1; // oś z tyłu (od sprzęgu 1) - int iAxleFirst; // numer pierwszej osi w kierunku ruchu (oś wiążąca pojazd z torem i wyzwalająca - // eventy) + int iAxleFirst; // numer pierwszej osi w kierunku ruchu (oś wiążąca pojazd z torem i wyzwalająca eventy) float fAxleDist; // rozstaw wózków albo osi do liczenia proporcji zacienienia - vector3 modelRot; // obrot pudła względem świata - do przeanalizowania, czy potrzebne!!! - // bool bCameraNear; //blisko kamer są potrzebne dodatkowe obliczenia szczegółów - TDynamicObject * ABuFindNearestObject(TTrack *Track, TDynamicObject *MyPointer, - int &CouplNr); + Math3D::vector3 modelRot; // obrot pudła względem świata - do przeanalizowania, czy potrzebne!!! + TDynamicObject * ABuFindNearestObject( TTrack *Track, TDynamicObject *MyPointer, int &CouplNr ); - public: // parametry położenia pojazdu dostępne publicznie +public: + // parametry położenia pojazdu dostępne publicznie std::string asTrack; // nazwa toru początkowego; wywalić? std::string asDestination; // dokąd pojazd ma być kierowany "(stacja):(tor)" - matrix4x4 mMatrix; // macierz przekształcenia do renderowania modeli + Math3D::matrix4x4 mMatrix; // macierz przekształcenia do renderowania modeli TMoverParameters *MoverParameters; // parametry fizyki ruchu oraz przeliczanie - // TMoverParameters *pControlled; //wskaźnik do sterowanego członu silnikowego TDynamicObject *NextConnected; // pojazd podłączony od strony sprzęgu 1 (kabina -1) TDynamicObject *PrevConnected; // pojazd podłączony od strony sprzęgu 0 (kabina 1) int NextConnectedNo; // numer sprzęgu podłączonego z tyłu int PrevConnectedNo; // numer sprzęgu podłączonego z przodu double fScanDist; // odległość skanowania torów na obecność innych pojazdów + double fTrackBlock; // odległość do przeszkody do dalszego ruchu (wykrywanie kolizji z innym pojazdem) TPowerSource ConnectedEnginePowerSource( TDynamicObject const *Caller ) const; -private: - // returns type of the nearest functional power source present in the trainset - public: // modele składowe pojazdu + // modele składowe pojazdu TModel3d *mdModel; // model pudła TModel3d *mdLoad; // model zmiennego ładunku - TModel3d *mdPrzedsionek; // model przedsionków dla EZT - może użyć mdLoad zamiast? TModel3d *mdKabina; // model kabiny dla użytkownika; McZapkie-030303: to z train.h TModel3d *mdLowPolyInt; // ABu 010305: wnetrze lowpoly float fShade; // zacienienie: 0:normalnie, -1:w ciemności, +1:dodatkowe światło (brak koloru?) + float LoadOffset { 0.f }; + glm::vec3 InteriorLight { 0.9f * 255.f / 255.f, 0.9f * 216.f / 255.f, 0.9f * 176.f / 255.f }; // tungsten light. TODO: allow definition of light type? + float InteriorLightLevel { 0.0f }; // current level of interior lighting + struct vehicle_section { + TSubModel *compartment; + TSubModel *load; + float light_level; + }; + std::vector Sections; // table of recognized vehicle sections + bool SectionLightsActive { false }; // flag indicating whether section lights were set. + struct section_visibility { + TSubModel *submodel; + bool visible; + int visible_chunks; + }; + std::vector SectionLoadVisibility; // visibility of specific sections of the load 3d model - private: // zmienne i metody do animacji submodeli; Ra: sprzatam animacje w pojeździe - public: // tymczasowo udostępnione do wyszukiwania drutu - int iAnimType[ ANIM_TYPES ]; // 0-osie,1-drzwi,2-obracane,3-zderzaki,4-wózki,5-pantografy,6-tłoki - private: +private: + // zmienne i metody do animacji submodeli; Ra: sprzatam animacje w pojeździe + material_data m_materialdata; + +public: + inline + material_data const + *Material() const { + return &m_materialdata; } + // tymczasowo udostępnione do wyszukiwania drutu + std::array iAnimType{ 0 }; // 0-osie,1-drzwi,2-obracane,3-zderzaki,4-wózki,5-pantografy,6-tłoki +private: int iAnimations; // liczba obiektów animujących -/* - TAnim *pAnimations; // obiekty animujące (zawierają wskaźnik do funkcji wykonującej animację) -*/ std::vector pAnimations; - TSubModel ** - pAnimated; // lista animowanych submodeli (może być ich więcej niż obiektów animujących) - double dWheelAngle[3]; // kąty obrotu kół: 0=przednie toczne, 1=napędzające i wiązary, 2=tylne - // toczne - void - UpdateNone(TAnim *pAnim){}; // animacja pusta (funkcje ustawiania submodeli, gdy blisko kamery) + TSubModel ** pAnimated; // lista animowanych submodeli (może być ich więcej niż obiektów animujących) + double dWheelAngle[3]; // kąty obrotu kół: 0=przednie toczne, 1=napędzające i wiązary, 2=tylne toczne +/* + void UpdateNone(TAnim *pAnim){}; // animacja pusta (funkcje ustawiania submodeli, gdy blisko kamery) +*/ void UpdateAxle(TAnim *pAnim); // animacja osi void UpdateBoogie(TAnim *pAnim); // animacja wózka void UpdateDoorTranslate(TAnim *pAnim); // animacja drzwi - przesuw @@ -205,13 +240,19 @@ private: void UpdateDoorFold(TAnim *pAnim); // animacja drzwi - składanie void UpdateDoorPlug(TAnim *pAnim); // animacja drzwi - odskokowo-przesuwne void UpdatePant(TAnim *pAnim); // animacja pantografu + void UpdatePlatformTranslate(TAnim *pAnim); // doorstep animation, shift + void UpdatePlatformRotate(TAnim *pAnim); // doorstep animation, rotate + void UpdateMirror(TAnim *pAnim); // mirror animation +/* void UpdateLeverDouble(TAnim *pAnim); // animacja gałki zależna od double void UpdateLeverFloat(TAnim *pAnim); // animacja gałki zależna od float void UpdateLeverInt(TAnim *pAnim); // animacja gałki zależna od int (wartość) void UpdateLeverEnum(TAnim *pAnim); // animacja gałki zależna od int (lista kątów) +*/ + void toggle_lights(); // switch light levels for registered interior sections private: // Ra: ciąg dalszy animacji, dopiero do ogarnięcia // ABuWozki 060504 - vector3 bogieRot[2]; // Obroty wozkow w/m korpusu + Math3D::vector3 bogieRot[2]; // Obroty wozkow w/m korpusu TSubModel *smBogie[2]; // Wyszukiwanie max 2 wozkow TSubModel *smWahacze[4]; // wahacze (np. nogi, dźwignia w drezynie) TSubModel *smBrakeMode; // Ra 15-01: nastawa hamulca też @@ -223,27 +264,112 @@ private: TSubModel *smBuforLewy[2]; TSubModel *smBuforPrawy[2]; TAnimValveGear *pValveGear; - vector3 vFloor; // podłoga dla ładunku + Math3D::vector3 vFloor; // podłoga dla ładunku public: TAnim *pants; // indeks obiektu animującego dla pantografu 0 double NoVoltTime; // czas od utraty zasilania + float DoorDelayL{ 0.f }; // left side door closing delay timer + float DoorDelayR{ 0.f }; // right side door closing delay timer double dDoorMoveL; // NBMX double dDoorMoveR; // NBMX + double dDoorstepMoveL{ 0.0 }; + double dDoorstepMoveR{ 0.0 }; + double dMirrorMoveL{ 0.0 }; + double dMirrorMoveR{ 0.0 }; TSubModel *smBrakeSet; // nastawa hamulca (wajcha) TSubModel *smLoadSet; // nastawa ładunku (wajcha) TSubModel *smWiper; // wycieraczka (poniekąd też wajcha) // Ra: koneic animacji do ogarnięcia - private: - void ABuLittleUpdate(double ObjSqrDist); - bool btnOn; // ABu: czy byly uzywane buttony, jesli tak, to po renderingu wylacz - // bo ten sam model moze byc jeszcze wykorzystany przez inny obiekt! - double ComputeRadius(vector3 p1, vector3 p2, vector3 p3, vector3 p4); +private: +// types + struct exchange_data { + float unload_count { 0.f }; // amount to unload + float load_count { 0.f }; // amount to load + float speed_factor { 1.f }; // operation speed modifier + float time { 0.f }; // time spent on the operation + }; + struct coupler_sounds { + sound_source dsbCouplerAttach { sound_placement::external }; // moved from cab + sound_source dsbCouplerDetach { sound_placement::external }; // moved from cab + sound_source dsbCouplerStretch { sound_placement::external }; // moved from cab + sound_source dsbCouplerStretch_loud { sound_placement::external }; + sound_source dsbBufferClamp { sound_placement::external }; // moved from cab + sound_source dsbBufferClamp_loud { sound_placement::external }; + }; + + struct pantograph_sounds { + // TODO: split pantograph sound into one for contact of arm with the wire, and electric arc sound + sound_source sPantUp { sound_placement::external }; + sound_source sPantDown { sound_placement::external }; + }; + + struct door_sounds { + sound_source rsDoorOpen { sound_placement::general }; // Ra: przeniesione z kabiny + sound_source rsDoorClose { sound_placement::general }; + sound_source lock { sound_placement::general }; + sound_source unlock { sound_placement::general }; + sound_source step_open { sound_placement::general }; + sound_source step_close { sound_placement::general }; + }; + + struct exchange_sounds { + sound_source loading { sound_placement::general }; + sound_source unloading { sound_placement::general }; + }; + + struct axle_sounds { + double distance; // distance to rail joint + double offset; // axle offset from centre of the vehicle + sound_source clatter; // clatter emitter + }; + + struct powertrain_sounds { + sound_source inverter { sound_placement::engine }; + std::vector motorblowers; + std::vector motors; // generally traction motor(s) + double motor_volume { 0.0 }; // MC: pomocnicze zeby gladziej silnik buczal + float motor_momentum { 0.f }; // recent change in motor revolutions + sound_source motor_relay { sound_placement::engine }; + sound_source dsbWejscie_na_bezoporow { sound_placement::engine }; // moved from cab + sound_source motor_parallel { sound_placement::engine }; // moved from cab + sound_source motor_shuntfield { sound_placement::engine }; + sound_source linebreaker_close { sound_placement::engine }; + sound_source linebreaker_open { sound_placement::engine }; + sound_source rsWentylator { sound_placement::engine }; // McZapkie-030302 + sound_source engine { sound_placement::engine }; // generally diesel engine + sound_source engine_ignition { sound_placement::engine }; // moved from cab + sound_source engine_shutdown { sound_placement::engine }; + bool engine_state_last { false }; // helper, cached previous state of the engine + double engine_volume { 0.0 }; // MC: pomocnicze zeby gladziej silnik buczal + sound_source engine_revving { sound_placement::engine }; // youBy + float engine_revs_last { -1.f }; // helper, cached rpm of the engine + float engine_revs_change { 0.f }; // recent change in engine revolutions + sound_source engine_turbo { sound_placement::engine }; + double engine_turbo_pitch { 1.0 }; + sound_source oil_pump { sound_placement::engine }; + sound_source radiator_fan { sound_placement::engine }; + sound_source radiator_fan_aux { sound_placement::engine }; + sound_source transmission { sound_placement::engine }; + sound_source rsEngageSlippery { sound_placement::engine }; // moved from cab + + void position( glm::vec3 const Location ); + void render( TMoverParameters const &Vehicle, double const Deltatime ); + }; + +// methods + void ABuLittleUpdate(double ObjSqrDist); + void ABuBogies(); + void ABuModelRoll(); + void TurnOff(); + // update state of load exchange operation + void update_exchange( double const Deltatime ); + +// members TButton btCoupler1; // sprzegi TButton btCoupler2; - TAirCoupler - btCPneumatic1; // sprzegi powietrzne //yB - zmienione z Button na AirCoupler - krzyzyki + TAirCoupler btCPneumatic1; // sprzegi powietrzne //yB - zmienione z Button na AirCoupler - krzyzyki TAirCoupler btCPneumatic2; TAirCoupler btCPneumatic1r; // ABu: to zeby nie bylo problemow przy laczeniu wagonow, TAirCoupler btCPneumatic2r; // jesli beda polaczone sprzegami 1<->1 lub 0<->0 @@ -274,105 +400,94 @@ private: TButton btHeadSignals23; TButton btMechanik1; TButton btMechanik2; - //TSubModel *smMechanik0; // Ra: mechanik wbudowany w model jako submodel? - //TSubModel *smMechanik1; // mechanik od strony sprzęgu 1 - double enginevolume; // MC: pomocnicze zeby gladziej silnik buczal + TButton btShutters1; // cooling shutters for primary water circuit + TButton btShutters2; // cooling shutters for auxiliary water circuit - int iAxles; // McZapkie: to potem mozna skasowac i zastapic iNumAxles - double dRailLength; - double dRailPosition[MaxAxles]; // licznik pozycji osi w/m szyny - double dWheelsPosition[MaxAxles]; // pozycja osi w/m srodka pojazdu - TRealSound rsStukot[MaxAxles]; // dzwieki poszczegolnych osi //McZapkie-270202 - TRealSound rsSilnik; // McZapkie-010302 - silnik - TRealSound rsWentylator; // McZapkie-030302 - TRealSound rsPisk; // McZapkie-260302 - TRealSound rsDerailment; // McZapkie-051202 - TRealSound rsPrzekladnia; - TAdvancedSound sHorn1; - TAdvancedSound sHorn2; - TAdvancedSound sCompressor; // NBMX wrzesien 2003 - TAdvancedSound sConverter; - TAdvancedSound sSmallCompressor; - TAdvancedSound sDepartureSignal; - TAdvancedSound sTurbo; - TAdvancedSound sSand; - TAdvancedSound sReleaser; + double dRailLength { 0.0 }; + std::vector m_axlesounds; + // engine sounds + powertrain_sounds m_powertrainsounds; + sound_source sConverter { sound_placement::engine }; + sound_source sCompressor { sound_placement::engine }; // NBMX wrzesien 2003 + sound_source sSmallCompressor { sound_placement::engine }; + sound_source sHeater { sound_placement::engine }; + // braking sounds + sound_source dsbPneumaticRelay { sound_placement::external }; + sound_source rsBrake { sound_placement::external, EU07_SOUND_BRAKINGCUTOFFRANGE }; // moved from cab + sound_source sBrakeAcc { sound_placement::external }; + bool bBrakeAcc { false }; + sound_source rsPisk { sound_placement::external, EU07_SOUND_BRAKINGCUTOFFRANGE }; // McZapkie-260302 + sound_source rsUnbrake { sound_placement::external }; // yB - odglos luzowania + sound_source m_brakecylinderpistonadvance { sound_placement::external }; + sound_source m_brakecylinderpistonrecede { sound_placement::external }; + float m_lastbrakepressure { -1.f }; // helper, cached level of pressure in the brake cylinder + float m_brakepressurechange { 0.f }; // recent change of pressure in the brake cylinder + sound_source sReleaser { sound_placement::external }; + sound_source rsSlippery { sound_placement::external, EU07_SOUND_BRAKINGCUTOFFRANGE }; // moved from cab + sound_source sSand { sound_placement::external }; + // moving part and other external sounds + std::array m_couplersounds; // always front and rear + std::vector m_pantographsounds; // typically 2 but can be less (or more?) + std::vector m_doorsounds; // can expect symmetrical arrangement, but don't count on it + bool m_doorlocks { false }; // sound helper, current state of door locks + sound_source sDepartureSignal { sound_placement::general }; + sound_source sHorn1 { sound_placement::external, 5 * EU07_SOUND_RUNNINGNOISECUTOFFRANGE }; + sound_source sHorn2 { sound_placement::external, 5 * EU07_SOUND_RUNNINGNOISECUTOFFRANGE }; + sound_source sHorn3 { sound_placement::external, 5 * EU07_SOUND_RUNNINGNOISECUTOFFRANGE }; + std::vector m_bogiesounds; // TBD, TODO: wrapper for all bogie-related sounds (noise, brakes, squeal etc) + sound_source m_wheelflat { sound_placement::external, EU07_SOUND_RUNNINGNOISECUTOFFRANGE }; + sound_source rscurve { sound_placement::external, EU07_SOUND_RUNNINGNOISECUTOFFRANGE }; // youBy + sound_source rsDerailment { sound_placement::external, 250.f }; // McZapkie-051202 - // Winger 010304 - // TRealSound rsPanTup; //PSound sPantUp; - TRealSound sPantUp; - TRealSound sPantDown; - TRealSound rsDoorOpen; // Ra: przeniesione z kabiny - TRealSound rsDoorClose; + exchange_data m_exchange; // state of active load exchange procedure, if any + exchange_sounds m_exchangesounds; // sounds associated with the load exchange - double eng_vol_act; - double eng_frq_act; - double eng_dfrq; - double eng_turbo; - void ABuBogies(); - void ABuModelRoll(); - vector3 modelShake; + Math3D::vector3 modelShake; bool renderme; // yB - czy renderowac - // TRealSound sBrakeAcc; //dźwięk przyspieszacza - PSound sBrakeAcc; - bool bBrakeAcc; - TRealSound rsUnbrake; // yB - odglos luzowania float ModCamRot; - int iInventory; // flagi bitowe posiadanych submodeli (np. świateł) - void TurnOff(); + int iInventory[ 2 ] { 0, 0 }; // flagi bitowe posiadanych submodeli (np. świateł) + bool btnOn; // ABu: czy byly uzywane buttony, jesli tak, to po renderingu wylacz + // bo ten sam model moze byc jeszcze wykorzystany przez inny obiekt! public: int iHornWarning; // numer syreny do użycia po otrzymaniu sygnału do jazdy bool bEnabled; // Ra: wyjechał na portal i ma być usunięty protected: - // TTrackFollower Axle2; //dwie osie z czterech (te są protected) - // TTrackFollower Axle3; //Ra: wyłączyłem, bo kąty są liczone w Segment.cpp int iNumAxles; // ilość osi - int CouplCounter; std::string asModel; public: void ABuScanObjects(int ScanDir, double ScanDist); - protected: - TDynamicObject * ABuFindObject(TTrack *Track, int ScanDir, BYTE &CouplFound, - double &dist); + private: + TDynamicObject *ABuFindObject( int &Foundcoupler, double &Distance, TTrack const *Track, int const Direction, int const Mycoupler ); void ABuCheckMyTrack(); public: int *iLights; // wskaźnik na bity zapalonych świateł (własne albo innego członu) - double fTrackBlock; // odległość do przeszkody do dalszego ruchu (wykrywanie kolizji z innym - // pojazdem) + bool DimHeadlights{ false }; // status of the headlight dimming toggle. NOTE: single toggle for all lights is a simplification. TODO: separate per-light switches TDynamicObject * PrevAny(); TDynamicObject * Prev(); TDynamicObject * Next(); TDynamicObject * PrevC(int C); TDynamicObject * NextC(int C); double NextDistance(double d = -1.0); - void SetdMoveLen(double dMoveLen) - { - MoverParameters->dMoveLen = dMoveLen; - } - void ResetdMoveLen() - { - MoverParameters->dMoveLen = 0; - } - double GetdMoveLen() - { - return MoverParameters->dMoveLen; - } + void SetdMoveLen(double dMoveLen) { + MoverParameters->dMoveLen = dMoveLen; } + void ResetdMoveLen() { + MoverParameters->dMoveLen = 0; } + double GetdMoveLen() { + return MoverParameters->dMoveLen; } int GetPneumatic(bool front, bool red); void SetPneumatic(bool front, bool red); std::string asName; - std::string GetName() - { - return this ? asName : std::string(""); - }; + std::string name() const { + return this ? + asName : + std::string(); }; - TRealSound rsDiesielInc; // youBy - TRealSound rscurve; // youBy // std::ofstream PneuLogFile; //zapis parametrow pneumatycznych // youBy - dym // TSmoke Smog; @@ -382,8 +497,7 @@ private: TDynamicObject * ABuScanNearestObject(TTrack *Track, double ScanDir, double ScanDist, int &CouplNr); TDynamicObject * GetFirstDynamic(int cpl_type, int cf = 1); - // TDynamicObject* GetFirstCabDynamic(int cpl_type); - void ABuSetModelShake(vector3 mShake); + void ABuSetModelShake( Math3D::vector3 mShake); // McZapkie-010302 TController *Mechanik; @@ -395,127 +509,153 @@ private: int iCabs; // maski bitowe modeli kabin TTrack *MyTrack; // McZapkie-030303: tor na ktorym stoi, ABu std::string asBaseDir; - texture_manager::size_type ReplacableSkinID[5]; // McZapkie:zmienialne nadwozie - int iAlpha; // maska przezroczystości tekstur - int iMultiTex; //<0 tekstury wskazane wpisem, >0 tekstury z przecinkami, =0 jedna - int iOverheadMask; // maska przydzielana przez AI pojazdom posiadającym pantograf, aby wymuszały - // jazdę bezprądową + int iOverheadMask; // maska przydzielana przez AI pojazdom posiadającym pantograf, aby wymuszały jazdę bezprądową TTractionParam tmpTraction; - double fAdjustment; // korekcja - docelowo przenieść do TrkFoll.cpp wraz z odległością od - // poprzedniego + double fAdjustment; // korekcja - docelowo przenieść do TrkFoll.cpp wraz z odległością od poprzedniego + TDynamicObject(); ~TDynamicObject(); - double TDynamicObject::Init( // zwraca długość pojazdu albo 0, jeśli błąd + // zwraca długość pojazdu albo 0, jeśli błąd + double Init( std::string Name, std::string BaseDir, std::string asReplacableSkin, std::string Type_Name, TTrack *Track, double fDist, std::string DriverType, double fVel, std::string TrainName, float Load, std::string LoadType, bool Reversed, std::string); + int init_sections( TModel3d const *Model, std::string const &Nameprefix ); + void create_controller( std::string const Type, bool const Trainset ); void AttachPrev(TDynamicObject *Object, int iType = 1); bool UpdateForce(double dt, double dt1, bool FullVer); + // initiates load change by specified amounts, with a platform on specified side + void LoadExchange( int const Disembark, int const Embark, int const Platform ); void LoadUpdate(); + void update_load_sections(); + void update_load_visibility(); + void update_load_offset(); + void shuffle_load_sections(); bool Update(double dt, double dt1); bool FastUpdate(double dt); void Move(double fDistance); void FastMove(double fDistance); - void Render(); - void RenderAlpha(); void RenderSounds(); - inline vector3 GetPosition() - { - return vPosition; - }; - inline vector3 HeadPosition() - { - return vCoulpler[iDirection ^ 1]; - }; // pobranie współrzędnych czoła - inline vector3 RearPosition() - { - return vCoulpler[iDirection]; - }; // pobranie współrzędnych tyłu - inline vector3 AxlePositionGet() - { - return iAxleFirst ? Axle1.pPosition : Axle0.pPosition; - }; - inline vector3 VectorFront() - { - return vFront; - }; - inline vector3 VectorUp() - { - return vUp; - }; - inline vector3 VectorLeft() - { - return vLeft; - }; - inline double * Matrix() - { - return mMatrix.getArray(); - }; - inline double GetVelocity() - { - return MoverParameters->Vel; - }; - inline double GetLength() - { - return MoverParameters->Dim.L; - }; - inline double GetWidth() - { - return MoverParameters->Dim.W; - }; - inline TTrack * GetTrack() - { - return (iAxleFirst ? Axle1.GetTrack() : Axle0.GetTrack()); - }; - // void UpdatePos(); + inline Math3D::vector3 GetPosition() const { + return vPosition; }; + // pobranie współrzędnych czoła + inline Math3D::vector3 HeadPosition() { + return vCoulpler[iDirection ^ 1]; }; + // pobranie współrzędnych tyłu + inline Math3D::vector3 RearPosition() { + return vCoulpler[iDirection]; }; + inline Math3D::vector3 AxlePositionGet() { + return iAxleFirst ? + Axle1.pPosition : + Axle0.pPosition; }; + inline double Roll() { + return ( ( Axle1.GetRoll() + Axle0.GetRoll() ) ); } +/* + // TODO: check if scanning takes into account direction when selecting axle + // if it does, replace the version above + // if it doesn't, fix it so it does + inline Math3D::vector3 AxlePositionGet() { + return ( + iDirection ? + ( iAxleFirst ? Axle1.pPosition : Axle0.pPosition ) : + ( iAxleFirst ? Axle0.pPosition : Axle1.pPosition ) ); } +*/ + inline Math3D::vector3 VectorFront() const { + return vFront; }; + inline Math3D::vector3 VectorUp() const { + return vUp; }; + inline Math3D::vector3 VectorLeft() const { + return vLeft; }; + inline double const * Matrix() const { + return mMatrix.readArray(); }; + inline double * Matrix() { + return mMatrix.getArray(); }; + inline double GetVelocity() const { + return MoverParameters->Vel; }; + inline double GetLength() const { + return MoverParameters->Dim.L; }; + inline double GetWidth() const { + return MoverParameters->Dim.W; }; + // calculates distance between event-starting axle and front of the vehicle + double tracing_offset() const; + inline TTrack * GetTrack() { + return (iAxleFirst ? + Axle1.GetTrack() : + Axle0.GetTrack()); }; // McZapkie-260202 - void LoadMMediaFile(std::string BaseDir, std::string TypeName, std::string ReplacableSkin); + void LoadMMediaFile(std::string const &TypeName, std::string const &ReplacableSkin); + TModel3d *LoadMMediaFile_mdload( std::string const &Name ) const; - inline double ABuGetDirection() // ABu. - { - return (Axle1.GetTrack() == MyTrack ? Axle1.GetDirection() : Axle0.GetDirection()); - }; - // inline double ABuGetTranslation() //ABu. - // {//zwraca przesunięcie wózka względem Point1 toru - // return (Axle1.GetTrack()==MyTrack?Axle1.GetTranslation():Axle0.GetTranslation()); - // }; - inline double RaDirectionGet() - { // zwraca kierunek pojazdu na torze z aktywną osą - return iAxleFirst ? Axle1.GetDirection() : Axle0.GetDirection(); - }; - inline double RaTranslationGet() - { // zwraca przesunięcie wózka względem Point1 toru z aktywną osią - return iAxleFirst ? Axle1.GetTranslation() : Axle0.GetTranslation(); - }; - inline TTrack * RaTrackGet() - { // zwraca tor z aktywną osią - return iAxleFirst ? Axle1.GetTrack() : Axle0.GetTrack(); - }; + inline double ABuGetDirection() const { // ABu. + return (Axle1.GetTrack() == MyTrack ? Axle1.GetDirection() : Axle0.GetDirection()); }; + // zwraca kierunek pojazdu na torze z aktywną osą + inline double RaDirectionGet() const { + return iAxleFirst ? + Axle1.GetDirection() : + Axle0.GetDirection(); }; + // zwraca przesunięcie wózka względem Point1 toru z aktywną osią + inline double RaTranslationGet() const { + return iAxleFirst ? + Axle1.GetTranslation() : + Axle0.GetTranslation(); }; + // zwraca tor z aktywną osią + inline TTrack * RaTrackGet() { + return iAxleFirst ? + Axle1.GetTrack() : + Axle0.GetTrack(); }; + + void couple( int const Side ); + int uncouple( int const Side ); void CouplersDettach(double MinDist, int MyScanDir); void RadioStop(); void Damage(char flag); void RaLightsSet(int head, int rear); - // void RaAxleEvent(TEvent *e); + int LightList( side const Side ) const { return iInventory[ Side ]; } TDynamicObject * FirstFind(int &coupler_nr, int cf = 1); float GetEPP(); // wyliczanie sredniego cisnienia w PG int DirectionSet(int d); // ustawienie kierunku w składzie - int DirectionGet() - { - return iDirection + iDirection - 1; - }; // odczyt kierunku w składzie + // odczyt kierunku w składzie + int DirectionGet() const { + return iDirection + iDirection - 1; }; int DettachStatus(int dir); int Dettach(int dir); TDynamicObject * Neightbour(int &dir); void CoupleDist(); TDynamicObject * ControlledFind(); void ParamSet(int what, int into); - int RouteWish(TTrack *tr); // zapytanie do AI, po którym segmencie skrzyżowania - // jechać + // zapytanie do AI, po którym segmencie skrzyżowania jechać + int RouteWish(TTrack *tr); void DestinationSet(std::string to, std::string numer); - std::string TextureTest(std::string const &name); void OverheadTrack(float o); + double MED[9][8]; // lista zmiennych do debugowania hamulca ED + static std::string const MED_labels[ 8 ]; + std::ofstream MEDLogFile; // zapis parametrów hamowania + double MEDLogTime = 0; + double MEDLogInactiveTime = 0; + int MEDLogCount = 0; +}; + + + +class vehicle_table : public basic_table { + +public: + // legacy method, calculates changes in simulation state over specified time + void + update( double dt, int iter ); + // legacy method, checks for presence and height of traction wire for specified vehicle + void + update_traction( TDynamicObject *Vehicle ); + // legacy method, sends list of vehicles over network + void + DynamicList( bool const Onlycontrolled = false ) const; + +private: + // maintenance; removes from tracks consists with vehicles marked as disabled + bool + erase_disabled(); }; //--------------------------------------------------------------------------- diff --git a/EU07.bpr b/EU07.bpr deleted file mode 100644 index 74206a6d..00000000 --- a/EU07.bpr +++ /dev/null @@ -1,144 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -[Version Info] -IncludeVerInfo=1 -AutoIncBuild=0 -MajorVer=16 -MinorVer=1 -Release=1174 -Build=483 -Debug=1 -PreRelease=0 -Special=0 -Private=0 -DLL=0 -Locale=1045 -CodePage=1250 - -[Version Info Keys] -CompanyName=EU07 Team -FileDescription=MaSzyna EU07-424 -FileVersion=16.1.1174.483 -InternalName=DP+SPKS+asynch+python -LegalCopyright= -LegalTrademarks= -OriginalFilename=eu07.exe -ProductName=MaSzyna EU07-424 -ProductVersion=16.1 -Comments= - -[Excluded Packages] -$(BCB)\Bin\bcbsmp50.bpl=Borland C++ Sample Components -$(BCB)\Bin\dclqrt50.bpl=QuickReport Components -C:\Windows\system32\ibsmp50.bpl=Borland C++ InterBase Alerter Component -$(BCB)\Bin\dcltee50.bpl=TeeChart 5.0 Components -$(BCB)\Bin\applet50.bpl=Borland Control Panel Applet Package - -[HistoryLists\hlIncludePath] -Count=2 -Item0=Console;opengl;McZapkie;$(BCB)\include;$(BCB)\include\vcl;python\include -Item1=Console;opengl;McZapkie;$(BCB)\include;$(BCB)\include\vcl - -[HistoryLists\hlLibraryPath] -Count=2 -Item0=Console;opengl;McZapkie;$(BCB)\lib\obj;$(BCB)\lib;python\libs -Item1=Console;opengl;McZapkie;$(BCB)\lib\obj;$(BCB)\lib - -[HistoryLists\hlDebugSourcePath] -Count=2 -Item0=McZapkie\ -Item1=$(BCB)\source\vcl - -[HistoryLists\hlConditionals] -Count=8 -Item0=GLEW_STATIC;_DEBUG -Item1=GLEW_STATIC -Item2=GLEW_STATIC;_DEBUG;USE_VBO -Item3=GLEW_STATIC;_DEBUG;_USE_OLD_RW_STL -Item4=GLEW_STATIC;USE_VERTEX_ARRAYS;_DEBUG -Item5=GLEW_STATIC;USE_VERTEX_ARRAYS -Item6=GLEW_STATIC;_DEBUG;USE_VERTEX_ARRAYS -Item7=_DEBUG - -[HistoryLists\hlFinalOutputDir] -Count=5 -Item0=E:\Gry\MaSzyna_15_04\ -Item1=D:\Maszyna -Item2=E:\Gry\MaSzyna_15_04 -Item3=D:\EU07\ -Item4=E:\EU07\ - -[Debugging] -DebugSourceDirs=McZapkie\ - -[Parameters] -RunParams=-s td.scn -v EP07-424 -HostApplication= -RemoteHost= -RemotePath= -RemoteDebug=0 - -[Compiler] -ShowInfoMsgs=0 -LinkDebugVcl=0 -LinkCGLIB=0 - -[Language] -ActiveLang= -ProjectLang= -RootDir= - - \ No newline at end of file diff --git a/EU07.cpp b/EU07.cpp index 3a071cd3..24f64e84 100644 --- a/EU07.cpp +++ b/EU07.cpp @@ -7,770 +7,36 @@ obtain one at http://mozilla.org/MPL/2.0/. */ /* - MaSzyna EU07 locomotive simulator - Copyright (C) 2001-2004 Marcin Wozniak, Maciej Czapkiewicz and others - +MaSzyna EU07 locomotive simulator +Copyright (C) 2001-2004 Marcin Wozniak, Maciej Czapkiewicz and others */ /* Authors: MarcinW, McZapkie, Shaxbee, ABu, nbmx, youBy, Ra, winger, mamut, Q424, Stele, firleju, szociu, hunter, ZiomalCl, OLI_EU and others */ - #include "stdafx.h" -#include //_clear87() itp. +#include "application.h" +#include "logs.h" -#include "opengl/glew.h" -#include "opengl/wglew.h" -#include "opengl/ARB_Multisample.h" - -#include "Globals.h" -#include "Logs.h" -#include "Console.h" -#include "PyInt.h" -#include "World.h" -#include "Mover.h" - -#pragma comment( lib, "glew32.lib" ) -#pragma comment( lib, "glu32.lib" ) -#pragma comment( lib, "opengl32.lib" ) -#pragma comment( lib, "dsound.lib" ) -#pragma comment( lib, "winmm.lib" ) -#pragma comment( lib, "setupapi.lib" ) -#pragma comment( lib, "python27.lib" ) -#pragma comment (lib, "dbghelp.lib") - -HDC hDC = NULL; // Private GDI Device Context -HGLRC hRC = NULL; // Permanent Rendering Context -HWND hWnd = NULL; // Holds Our Window Handle - -TWorld World; - -// bool active=TRUE; //window active flag set to TRUE by default -bool fullscreen = TRUE; // fullscreen flag set to fullscreen mode by default -int WindowWidth = 800; -int WindowHeight = 600; -int Bpp = 32; - -LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM); // Declaration For WndProc - -//#include "dbgForm.h" -//--------------------------------------------------------------------------- - -int InitGL(GLvoid) // All Setup For OpenGL Goes Here -{ -// _clear87(); -// _control87(MCW_EM, MCW_EM); - glewInit(); - - if( !GLEW_VERSION_1_4 ) { - // experimental: require at least openGL 1.4 - Error( "This application requires openGL version 1.4 (or better)" ); - return 0; - } - - // hunter-271211: przeniesione - // AllocConsole(); - // SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),FOREGROUND_GREEN); - - // ShaXbee-121209: Wlaczenie obslugi tablic wierzcholkow - glEnableClientState(GL_VERTEX_ARRAY); - glEnableClientState(GL_NORMAL_ARRAY); - glEnableClientState(GL_TEXTURE_COORD_ARRAY); - Global::pWorld = &World; // Ra: wskaźnik potrzebny do usuwania pojazdów - return World.Init(hWnd, hDC); // true jeśli wszystko pójdzie dobrze -} -//--------------------------------------------------------------------------- - -GLvoid ReSizeGLScene(GLsizei width, GLsizei height) // resize and initialize the GL Window -{ - WindowWidth = width; - WindowHeight = height; - if (height == 0) // prevent a divide by zero by - height = 1; // making height equal one - glViewport(0, 0, width, height); // Reset The Current Viewport - glMatrixMode(GL_PROJECTION); // select the Projection Matrix - glLoadIdentity(); // reset the Projection Matrix - // calculate the aspect ratio of the window - gluPerspective(45.0f, (GLdouble)width / (GLdouble)height, 0.2f, 2500.0f); - glMatrixMode(GL_MODELVIEW); // select the Modelview Matrix - glLoadIdentity(); // reset the Modelview Matrix -} - -//--------------------------------------------------------------------------- -GLvoid KillGLWindow(GLvoid) // properly kill the window -{ - if (hRC) // Do We Have A Rendering Context? - { - if (!wglMakeCurrent(NULL, NULL)) // are we able to release the DC and RC contexts? - { - ErrorLog("Fail: window releasing"); - MessageBox(NULL, "Release of DC and RC failed.", "SHUTDOWN ERROR", - MB_OK | MB_ICONINFORMATION); - } - - if (!wglDeleteContext(hRC)) // are we able to delete the RC? - { - ErrorLog("Fail: rendering context releasing"); - MessageBox(NULL, "Release rendering context failed.", "SHUTDOWN ERROR", - MB_OK | MB_ICONINFORMATION); - } - hRC = NULL; // set RC to NULL - } - - if (hDC && !ReleaseDC(hWnd, hDC)) // are we able to release the DC? - { - ErrorLog("Fail: device context releasing"); - MessageBox(NULL, "Release device context failed.", "SHUTDOWN ERROR", - MB_OK | MB_ICONINFORMATION); - hDC = NULL; // set DC to NULL - } - - if (hWnd && !DestroyWindow(hWnd)) // are we able to destroy the window? - { - ErrorLog("Fail: window destroying"); - MessageBox(NULL, "Could not release hWnd.", "SHUTDOWN ERROR", MB_OK | MB_ICONINFORMATION); - hWnd = NULL; // set hWnd to NULL - } - - if (fullscreen) // Are We In Fullscreen Mode? - { - ChangeDisplaySettings(NULL, 0); // if so switch back to the desktop - ShowCursor(TRUE); // show mouse pointer - } - // KillFont(); -} - -/* This code creates our OpenGL Window. Parameters are: * - * title - title to appear at the top of the window * - * width - width of the GL Window or fullscreen mode * - * height - height of the GL Window or fullscreen mode * - * bits - number of bits to use for color (8/16/24/32) * - * fullscreenflag - use fullscreen mode (TRUE) or windowed mode (FALSE) */ - -BOOL CreateGLWindow(char *title, int width, int height, int bits, bool fullscreenflag) -{ - GLuint PixelFormat; // holds the results after searching for a match - HINSTANCE hInstance; // holds the instance of the application - WNDCLASS wc; // windows class structure - DWORD dwExStyle; // window extended style - DWORD dwStyle; // window style - RECT WindowRect; // grabs rectangle upper left / lower right values - WindowRect.left = (long)0; // set left value to 0 - WindowRect.right = (long)width; // set right value to requested width - WindowRect.top = (long)0; // set top value to 0 - WindowRect.bottom = (long)height; // set bottom value to requested height - - fullscreen = fullscreenflag; // set the global fullscreen flag - - hInstance = GetModuleHandle(NULL); // grab an instance for our window - wc.style = CS_HREDRAW | CS_VREDRAW | CS_OWNDC; // redraw on size, and own DC for window. - wc.lpfnWndProc = (WNDPROC)WndProc; // wndproc handles messages - wc.cbClsExtra = 0; // no extra window data - wc.cbWndExtra = 0; // no extra window data - wc.hInstance = hInstance; // set the instance - wc.hIcon = LoadIcon(NULL, IDI_WINLOGO); // load the default icon - wc.hCursor = LoadCursor(NULL, IDC_ARROW); // load the arrow pointer - wc.hbrBackground = NULL; // no background required for GL - wc.lpszMenuName = NULL; // we don't want a menu - wc.lpszClassName = "EU07"; // nazwa okna do komunikacji zdalnej - // // Set The Class Name - - if (!arbMultisampleSupported) // tylko dla pierwszego okna - if (!RegisterClass(&wc)) // Attempt To Register The Window Class - { - ErrorLog("Fail: window class registeration"); - MessageBox(NULL, "Failed to register the window class.", "ERROR", - MB_OK | MB_ICONEXCLAMATION); - return FALSE; // Return FALSE - } - - if (fullscreen) // Attempt Fullscreen Mode? - { - DEVMODE dmScreenSettings; // device mode - memset(&dmScreenSettings, 0, sizeof(dmScreenSettings)); // makes sure memory's cleared - dmScreenSettings.dmSize = sizeof(dmScreenSettings); // size of the devmode structure - - // tolaris-240403: poprawka na odswiezanie monitora - // locate primary monitor... - if (Global::bAdjustScreenFreq) - { - POINT point; - point.x = 0; - point.y = 0; - MONITORINFOEX monitorinfo; - monitorinfo.cbSize = sizeof(MONITORINFOEX); - ::GetMonitorInfo(::MonitorFromPoint(point, MONITOR_DEFAULTTOPRIMARY), &monitorinfo); - // ..and query for highest supported refresh rate - unsigned int refreshrate = 0; - int i = 0; - while (::EnumDisplaySettings(monitorinfo.szDevice, i, &dmScreenSettings)) - { - if (i > 0) - if (dmScreenSettings.dmPelsWidth == (unsigned int)width) - if (dmScreenSettings.dmPelsHeight == (unsigned int)height) - if (dmScreenSettings.dmBitsPerPel == (unsigned int)bits) - if (dmScreenSettings.dmDisplayFrequency > refreshrate) - refreshrate = dmScreenSettings.dmDisplayFrequency; - ++i; - } - // fill refresh rate info for screen mode change - dmScreenSettings.dmDisplayFrequency = refreshrate; - dmScreenSettings.dmFields = DM_DISPLAYFREQUENCY; - } - dmScreenSettings.dmPelsWidth = width; // selected screen width - dmScreenSettings.dmPelsHeight = height; // selected screen height - dmScreenSettings.dmBitsPerPel = bits; // selected bits per pixel - dmScreenSettings.dmFields = - dmScreenSettings.dmFields | DM_BITSPERPEL | DM_PELSWIDTH | DM_PELSHEIGHT; - - // Try to set selected mode and get results. NOTE: CDS_FULLSCREEN gets rid of start bar. - if (ChangeDisplaySettings(&dmScreenSettings, CDS_FULLSCREEN) != DISP_CHANGE_SUCCESSFUL) - { - // If the mode fails, offer two options. Quit or use windowed mode. - ErrorLog("Fail: full screen"); - if (MessageBox(NULL, "The requested fullscreen mode is not supported by\nyour video " - "card. Use windowed mode instead?", - "EU07", MB_YESNO | MB_ICONEXCLAMATION) == IDYES) - { - fullscreen = FALSE; // Windowed Mode Selected. Fullscreen = FALSE - } - else - { - // Pop Up A Message Box Letting User Know The Program Is Closing. - Error("Program will now close."); - return FALSE; // Return FALSE - } - } - } - - if (fullscreen) // Are We Still In Fullscreen Mode? - { - dwExStyle = WS_EX_APPWINDOW; // Window Extended Style - dwStyle = WS_POPUP | WS_CLIPSIBLINGS | WS_CLIPCHILDREN; // Windows Style - ShowCursor(FALSE); // Hide Mouse Pointer - } - else - { - dwExStyle = WS_EX_APPWINDOW | WS_EX_WINDOWEDGE; // Window Extended Style - dwStyle = WS_OVERLAPPEDWINDOW | WS_CLIPSIBLINGS | WS_CLIPCHILDREN; // Windows Style - } - - AdjustWindowRectEx(&WindowRect, dwStyle, FALSE, - dwExStyle); // Adjust Window To True Requested Size - - // Create The Window - if (NULL == - (hWnd = CreateWindowEx(dwExStyle, // Extended Style For The Window - "EU07", // Class Name - title, // Window Title - dwStyle | // Defined Window Style - WS_CLIPSIBLINGS | // Required Window Style - WS_CLIPCHILDREN, // Required Window Style - 0, - 0, // Window Position - WindowRect.right - WindowRect.left, // Calculate Window Width - WindowRect.bottom - WindowRect.top, // Calculate Window Height - NULL, // No Parent Window - NULL, // No Menu - hInstance, // Instance - NULL))) // Dont Pass Anything To WM_CREATE - { - KillGLWindow(); // Reset The Display - ErrorLog("Fail: window creation"); - MessageBox(NULL, "Window creation error.", "ERROR", MB_OK | MB_ICONEXCLAMATION); - return FALSE; // Return FALSE - } - - static PIXELFORMATDESCRIPTOR pfd = // pfd Tells Windows How We Want Things To Be - { - sizeof(PIXELFORMATDESCRIPTOR), // Size Of This Pixel Format Descriptor - 1, // Version Number - PFD_DRAW_TO_WINDOW | // Format Must Support Window - PFD_SUPPORT_OPENGL | // Format Must Support OpenGL - PFD_DOUBLEBUFFER, // Must Support Double Buffering - PFD_TYPE_RGBA, // Request An RGBA Format - bits, // Select Our Color Depth - 0, - 0, 0, 0, 0, 0, // Color Bits Ignored - 0, // No Alpha Buffer - 0, // Shift Bit Ignored - 0, // No Accumulation Buffer - 0, 0, 0, 0, // Accumulation Bits Ignored - 24, // 32Bit Z-Buffer (Depth Buffer) - 0, // No Stencil Buffer - 0, // No Auxiliary Buffer - PFD_MAIN_PLANE, // Main Drawing Layer - 0, // Reserved - 0, 0, 0 // Layer Masks Ignored - }; - - if (NULL == (hDC = GetDC(hWnd))) // Did We Get A Device Context? - { - KillGLWindow(); // Reset The Display - ErrorLog("Fail: device context"); - MessageBox(NULL, "Can't create a GL device context.", "ERROR", MB_OK | MB_ICONEXCLAMATION); - return FALSE; // Return FALSE - } - - /* - Our first pass, Multisampling hasn't been created yet, so we create a window normally - If it is supported, then we're on our second pass - that means we want to use our pixel format for sampling - so set PixelFormat to arbMultiSampleformat instead - */ - if (!arbMultisampleSupported) - { - if (NULL == (PixelFormat = - ChoosePixelFormat(hDC, &pfd))) // Did Windows Find A Matching Pixel Format? - { - KillGLWindow(); // Reset The Display - ErrorLog("Fail: pixelformat"); - MessageBox(NULL, "Can't find a suitable pixelformat.", "ERROR", - MB_OK | MB_ICONEXCLAMATION); - return FALSE; // Return FALSE - } - } - else - PixelFormat = arbMultisampleFormat; - - if (!SetPixelFormat(hDC, PixelFormat, &pfd)) // Are We Able To Set The Pixel Format? - { - KillGLWindow(); // Reset The Display - ErrorLog("Fail: pixelformat"); - MessageBox(NULL, "Can't set the pixelformat.", "ERROR", MB_OK | MB_ICONEXCLAMATION); - return FALSE; // Return FALSE - } - - if (NULL == (hRC = wglCreateContext(hDC))) // Are We Able To Get A Rendering Context? - { - KillGLWindow(); // Reset The Display - ErrorLog("Fail: OpenGL rendering context creation"); - MessageBox(NULL, "Can't create a GL rendering context.", "ERROR", - MB_OK | MB_ICONEXCLAMATION); - return FALSE; // Return FALSE - } - - if (!wglMakeCurrent(hDC, hRC)) // Try To Activate The Rendering Context - { - KillGLWindow(); // Reset The Display - ErrorLog("Fail: OpenGL rendering context activation"); - MessageBox(NULL, "Can't activate the GL rendering context.", "ERROR", - MB_OK | MB_ICONEXCLAMATION); - return FALSE; // Return FALSE - } - - /* - Now that our window is created, we want to queary what samples are available - we call our InitMultiSample window - if we return a valid context, we want to destroy our current window - and create a new one using the multisample interface. - */ - if (Global::iMultisampling) - if (!arbMultisampleSupported) - if ((Global::iMultisampling = - InitMultisample(hInstance, hWnd, pfd, 1 << Global::iMultisampling)) != 0) - { - // WriteConsoleOnly("Opening second window for multisampling of - // "+AnsiString(Global::iMultisampling)+" samples."); - KillGLWindow(); // reset the display - return CreateGLWindow(title, width, height, bits, fullscreenflag); // rekurencja - } - - ShowWindow(hWnd, SW_SHOW); // show the window - SetForegroundWindow(hWnd); // slightly higher priority - SetFocus(hWnd); // sets keyboard focus to the window - ReSizeGLScene(width, height); // set up our perspective GL screen - - if (!InitGL()) // initialize our newly created GL Window - { - KillGLWindow(); // reset the display - ErrorLog("Fail: OpenGL initialization"); - MessageBox(NULL, "Initialization Failed.", "ERROR", MB_OK | MB_ICONEXCLAMATION); - return FALSE; // return FALSE - } - return TRUE; // success -} - -static int mx = 0, my = 0; -static POINT mouse; - -static int test = 0; -/**/ -// ************ Globals ************ -// -#define MYDISPLAY 1 - -PCOPYDATASTRUCT pDane; - -LRESULT CALLBACK WndProc(HWND hWnd, // handle for this window - UINT uMsg, // message for this window - WPARAM wParam, // additional message information - LPARAM lParam) // additional message information -{ - RECT rect; - switch (uMsg) // check for windows messages - { - case WM_PASTE: //[Ctrl]+[V] potrzebujemy do innych celów - return 0; - case WM_COPYDATA: // obsługa danych przesłanych przez program sterujący - pDane = (PCOPYDATASTRUCT)lParam; - if (pDane->dwData == 'EU07') // sygnatura danych - World.OnCommandGet((DaneRozkaz *)(pDane->lpData)); - break; - case WM_ACTIVATE: // watch for window activate message - // case WM_ACTIVATEAPP: - { // Ra: uzależnienie aktywności od bycia na wierzchu - Global::bActive = (LOWORD(wParam) != WA_INACTIVE); - if (Global::bInactivePause) // jeśli ma być pauzowanie okna w tle - if (Global::bActive) - Global::iPause &= ~4; // odpauzowanie, gdy jest na pierwszym planie - else - Global::iPause |= 4; // włączenie pauzy, gdy nieaktywy - if (Global::bActive) - SetCursorPos(mx, my); - ShowCursor(!Global::bActive); - /* - if (!HIWORD(wParam)) //check minimization state - active=TRUE; //program is active - else - active=FALSE; //program is no longer active - */ - return 0; // return to the message loop - } - case WM_SYSCOMMAND: // intercept system commands - { - switch (wParam) // check system calls - { - case 61696: // F10 - World.OnKeyDown(VK_F10); - return 0; - case SC_SCREENSAVE: // screensaver trying to start? - case SC_MONITORPOWER: // monitor trying to enter powersave? - return 0; // prevent from happening - } - break; // exit - } - case WM_CLOSE: // did we receive a close message? - { - PostQuitMessage(0); // send a quit message [Alt]+[F4] - return 0; // jump back - } - case WM_MOUSEMOVE: - { - // mx= 100;//Global::iWindowWidth/2; - // my= 100;//Global::iWindowHeight/2; - // SetCursorPos(Global::iWindowWidth/2,Global::iWindowHeight/2); - // m_x= LOWORD(lParam); - // m_y= HIWORD(lParam); - GetCursorPos(&mouse); - if (Global::bActive && ((mouse.x != mx) || (mouse.y != my))) - { - World.OnMouseMove(double(mouse.x - mx) * 0.005, double(mouse.y - my) * 0.01); - SetCursorPos(mx, my); - } - return 0; // jump back - } - case WM_KEYUP: - if (Global::bActive) - { - World.OnKeyUp(wParam); - return 0; - } - case WM_KEYDOWN: - if (Global::bActive) - { - if (wParam != 17) // bo naciśnięcia [Ctrl] nie ma po co przekazywać - if (wParam != 145) //[Scroll Lock] też nie - World.OnKeyDown(wParam); - switch (wParam) - { - case VK_ESCAPE: //[Esc] pauzuje tylko bez Debugmode - if (DebugModeFlag) - break; - case 19: //[Pause] - if (Global::iPause & 1) // jeśli pauza startowa - Global::iPause &= ~1; // odpauzowanie, gdy po wczytaniu miało nie startować - else if (!(Global::iMultiplayer & 2)) // w multiplayerze pauza nie ma sensu - if (!Console::Pressed(VK_CONTROL)) // z [Ctrl] to radiostop jest - // Ra: poniższe nie ma sensu, bo brak komunikacji natychmiast zapauzuje - // ponownie - // if (Global::iPause&8) //jeśli pauza związana z brakiem komunikacji z - // PoKeys - // Global::iPause&=~10; //odpauzowanie pauzy PoKeys (chyba nic nie da) i - // ewentualnie klawiszowej również - // else - Global::iPause ^= 2; // zmiana stanu zapauzowania - if (Global::iPause) // jak pauza - Global::iTextMode = VK_F1; // to wyświetlić zegar i informację - break; - case VK_F7: - if (DebugModeFlag) - { // siatki wyświetlane tyko w trybie testowym - Global::bWireFrame = !Global::bWireFrame; - ++Global::iReCompile; // odświeżyć siatki - // Ra: jeszcze usunąć siatki ze skompilowanych obiektów! - } - break; - } - } - return 0; // jump back - case WM_CHAR: - { - /* - switch ((TCHAR) wParam) - { - // case 'q': - // done= true; - // KillGLWindow(); - // PostQuitMessage(0); - // DestroyWindow( hWnd ); - // break; - }; - */ - return 0; - } - case WM_SIZE: // resize the OpenGL window - { - ReSizeGLScene(LOWORD(lParam), HIWORD(lParam)); // LoWord=Width, HiWord=Height - if (GetWindowRect(hWnd, &rect)) - { // Ra: zmiana rozmiaru okna bez przesuwania myszy - // mx=WindowWidth/2+rect.left; // horizontal position - // my=WindowHeight/2+rect.top; // vertical position - // SetCursorPos(mx,my); - } - return 0; // jump back - } - case WM_MOVE: // przesuwanie okna? - { - mx = WindowWidth / 2 + LOWORD(lParam); // horizontal position - my = WindowHeight / 2 + HIWORD(lParam); // vertical position - // SetCursorPos(mx,my); - break; - } - case WM_PAINT: - { // odrysowanie okna - break; - } - // case WM_ERASEBKGND: //Process this message to keep Windows from erasing background. - case MM_JOY1BUTTONDOWN: - { - // WriteLog("Joystick button "+AnsiString(wParam)); - break; - } - case WM_CREATE: - /* Capture the joystick. If this fails, beep and display - * error, then quit. - */ - if (joySetCapture(hWnd, JOYSTICKID1, 0, FALSE)) - { - // MessageBeep(MB_ICONEXCLAMATION); - // MessageBox(hWnd,"Couldn't capture the joystick",NULL,MB_OK|MB_ICONEXCLAMATION); - // return -1; - } - break; - } - // pass all unhandled messages to DefWindowProc - return DefWindowProc(hWnd, uMsg, wParam, lParam); -}; - -#ifdef _WINDOWS -void make_minidump( ::EXCEPTION_POINTERS* e ) { - - auto hDbgHelp = ::LoadLibraryA( "dbghelp" ); - if( hDbgHelp == nullptr ) - return; - auto pMiniDumpWriteDump = (decltype( &MiniDumpWriteDump ))::GetProcAddress( hDbgHelp, "MiniDumpWriteDump" ); - if( pMiniDumpWriteDump == nullptr ) - return; - - char name[ MAX_PATH ]; - { - auto nameEnd = name + ::GetModuleFileNameA( ::GetModuleHandleA( 0 ), name, MAX_PATH ); - ::SYSTEMTIME t; - ::GetSystemTime( &t ); - wsprintfA( nameEnd - strlen( ".exe" ), - "_crashdump_%4d%02d%02d_%02d%02d%02d.dmp", - t.wYear, t.wMonth, t.wDay, t.wHour, t.wMinute, t.wSecond ); - } - - auto hFile = ::CreateFileA( name, GENERIC_WRITE, FILE_SHARE_READ, 0, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, 0 ); - if( hFile == INVALID_HANDLE_VALUE ) - return; - - ::MINIDUMP_EXCEPTION_INFORMATION exceptionInfo; - exceptionInfo.ThreadId = ::GetCurrentThreadId(); - exceptionInfo.ExceptionPointers = e; - exceptionInfo.ClientPointers = FALSE; - - auto dumped = pMiniDumpWriteDump( - ::GetCurrentProcess(), - ::GetCurrentProcessId(), - hFile, - ::MINIDUMP_TYPE( ::MiniDumpWithIndirectlyReferencedMemory | ::MiniDumpScanMemory ), - e ? &exceptionInfo : nullptr, - nullptr, - nullptr ); - - ::CloseHandle( hFile ); - - return; -} - -LONG CALLBACK unhandled_handler( ::EXCEPTION_POINTERS* e ) { - make_minidump( e ); - return EXCEPTION_CONTINUE_SEARCH; -} +#ifdef _MSC_VER +#pragma comment(linker, "/subsystem:windows /ENTRY:mainCRTStartup") #endif -int WINAPI WinMain(HINSTANCE hInstance, // instance - HINSTANCE hPrevInstance, // previous instance - LPSTR lpCmdLine, // command line parameters - int nCmdShow) // window show state -{ -#if defined(_MSC_VER) && defined (_DEBUG) - // memory leaks - _CrtSetDbgFlag( _CrtSetDbgFlag( _CRTDBG_REPORT_FLAG ) | _CRTDBG_LEAK_CHECK_DF ); - // floating point operation errors - auto state = _clearfp(); - state = _control87( 0, 0 ); - // this will turn on FPE for #IND and zerodiv - state = _control87( state & ~( _EM_ZERODIVIDE | _EM_INVALID ), _MCW_EM ); -#endif -#ifdef _WINDOWS - ::SetUnhandledExceptionFilter( unhandled_handler ); -#endif +int main( int argc, char *argv[] ) { - MSG msg; // windows message structure - BOOL done = FALSE; // bool variable to exit loop - fullscreen = true; - DeleteFile("errors.txt"); // usunięcie starego - Global::LoadIniFile("eu07.ini"); // teraz dopiero można przejrzeć plik z ustawieniami - Global::InitKeys("keys.ini"); // wczytanie mapowania klawiszy - jest na stałe - - // hunter-271211: ukrywanie konsoli - if (Global::iWriteLogEnabled & 2) - { - AllocConsole(); - SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_GREEN); - } - std::string commandline( lpCmdLine ); // parametry uruchomienia - if( false == commandline.empty() ) - { // analizowanie parametrďż˝w - cParser parser( commandline ); - std::string token; - do { - parser.getTokens(); - token.clear(); - parser >> token; - - if( token == "-s" ) - { // nazwa scenerii - parser.getTokens(); - parser >> Global::SceneryFile; - } - else if( token == "-v") - { // nazwa wybranego pojazdu - parser.getTokens(); - parser >> Global::asHumanCtrlVehicle; - } - else if( token == "-modifytga" ) - { // wykonanie modyfikacji wszystkich plików TGA - Global::iModifyTGA = -1; // specjalny tryb wykonania totalnej modyfikacji - } - else if( token == "-e3d" ) - { // wygenerowanie wszystkich plików E3D - if (Global::iConvertModels > 0) - Global::iConvertModels = -Global::iConvertModels; // specjalny tryb - else - Global::iConvertModels = -7; // z optymalizacją, bananami i prawidłowym Opacity - } - else - Error( - "Program usage: EU07 [-s sceneryfilepath] [-v vehiclename] [-modifytga] [-e3d]", - !Global::iWriteLogEnabled); - } - while( false == token.empty() ); - } - /* MC: usunalem tymczasowo bo sie gryzlo z nowym parserem - 8.6.2003 - AnsiString csp=AnsiString(Global::szSceneryFile); - csp=csp.Delete(csp.Pos(AnsiString(strrchr(Global::szSceneryFile,'/')))+1,csp.Length()); - Global::asCurrentSceneryPath=csp; - */ - - fullscreen = Global::bFullScreen; - WindowWidth = Global::iWindowWidth; - WindowHeight = Global::iWindowHeight; - Bpp = Global::iBpp; - if (Bpp != 32) - Bpp = 16; - // create our OpenGL window - if (!CreateGLWindow(const_cast(Global::asHumanCtrlVehicle.c_str()), WindowWidth, WindowHeight, Bpp, - fullscreen)) - return 0; // quit if window was not created - SetForegroundWindow(hWnd); - // McZapkie: proba przeplukania klawiatury - Console *pConsole = new Console(); // Ra: nie wiem, czy ma to sens, ale jakoś zainicjowac trzeba - while (Console::Pressed(VK_F10)) - Error("Keyboard buffer problem - press F10"); // na Windows 98 lubi się to pojawiać - int iOldSpeed, iOldDelay; - SystemParametersInfo(SPI_GETKEYBOARDSPEED, 0, &iOldSpeed, 0); - SystemParametersInfo(SPI_GETKEYBOARDDELAY, 0, &iOldDelay, 0); - SystemParametersInfo(SPI_SETKEYBOARDSPEED, 20, NULL, 0); - // SystemParametersInfo(SPI_SETKEYBOARDDELAY,10,NULL,0); - if (!joyGetNumDevs()) - WriteLog("No joystick"); - if (Global::iModifyTGA < 0) - { // tylko modyfikacja TGA, bez uruchamiania symulacji - Global::iMaxTextureSize = 64; //żeby nie zamulać pamięci - World.ModifyTGA(); // rekurencyjne przeglądanie katalogów - } - else - { - if (Global::iConvertModels < 0) - { - Global::iConvertModels = -Global::iConvertModels; - World.CreateE3D("models\\"); // rekurencyjne przeglądanie katalogów - World.CreateE3D("dynamic\\", true); - } // po zrobieniu E3D odpalamy normalnie scenerię, by ją zobaczyć - // else - //{//główna pętla programu - Console::On(); // włączenie konsoli - while (!done) // loop that runs while done=FALSE - { - if (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)) // is there a message waiting? - { - if (msg.message == WM_QUIT) // have we received a quit message? - done = TRUE; // if so - else // if not, deal with window messages - { - // if (msg.message==WM_CHAR) - // World.OnKeyDown(msg.wParam); - TranslateMessage(&msg); // translate the message - DispatchMessage(&msg); // dispatch the message - } - } - else // if there are no messages - { - // draw the scene, watch for quit messages - // DrawGLScene() - // if (!pause) - // if (Global::bInactivePause?Global::bActive:true) //tak nie, bo spada z góry - if (World.Update()) // Was There A Quit Received? - SwapBuffers(hDC); // Swap Buffers (Double Buffering) - else - done = true; //[F10] or DrawGLScene signalled a quit - } + try { + auto result { Application.init( argc, argv ) }; + if( result == 0 ) { + result = Application.run(); } - Console::Off(); // wyłączenie konsoli (komunikacji zwrotnej) + Application.exit(); + return result; } - SystemParametersInfo(SPI_SETKEYBOARDSPEED, iOldSpeed, NULL, 0); - SystemParametersInfo(SPI_SETKEYBOARDDELAY, iOldDelay, NULL, 0); - delete pConsole; // deaktywania sterownika - TPythonInterpreter::killInstance(); + catch( std::bad_alloc const &Error ) { - // shutdown - KillGLWindow(); // kill the window - return (msg.wParam); // exit the program + ErrorLog( "Critical error, memory allocation failure: " + std::string( Error.what() ) ); + return -1; + } } diff --git a/EvLaunch.cpp b/EvLaunch.cpp index 72b815e9..aa41b9e4 100644 --- a/EvLaunch.cpp +++ b/EvLaunch.cpp @@ -15,44 +15,36 @@ http://mozilla.org/MPL/2.0/. #include "stdafx.h" #include "EvLaunch.h" + #include "Globals.h" #include "Logs.h" -#include "Usefull.h" -#include "McZapkie/mctools.h" #include "Event.h" #include "MemCell.h" -#include "mtable.h" #include "Timer.h" #include "parser.h" #include "Console.h" - -using namespace Mtable; +#include "simulationtime.h" +#include "utilities.h" //--------------------------------------------------------------------------- -TEventLauncher::TEventLauncher() -{ // ustawienie początkowych wartości dla wszystkich zmiennych - iKey = 0; - DeltaTime = -1; - UpdatedTime = 0; - fVal1 = fVal2 = 0; -#ifdef EU07_USE_OLD_TEVENTLAUNCHER_TEXT_ARRAY - szText = NULL; +// encodes expected key in a short, where low byte represents the actual key, +// and the high byte holds modifiers: 0x1 = shift, 0x2 = ctrl, 0x4 = alt +int vk_to_glfw_key( int const Keycode ) { + +#ifdef _WIN32 + auto const code = VkKeyScan( Keycode ); + char key = code & 0xff; + char shiftstate = ( code & 0xff00 ) >> 8; + + if( (key >= 'A') && (key <= 'Z') ) { + key = GLFW_KEY_A + key - 'A'; + } + else if( ( key >= '0' ) && ( key <= '9' ) ) { + key = GLFW_KEY_0 + key - '0'; + } + return key + ( shiftstate << 8 ); #endif - iHour = iMinute = -1; // takiego czasu nigdy nie będzie - dRadius = 0; - Event1 = Event2 = NULL; - MemCell = NULL; - iCheckMask = 0; -} -#ifdef EU07_USE_OLD_TEVENTLAUNCHER_TEXT_ARRAY -TEventLauncher::~TEventLauncher() -{ - SafeDeleteArray(szText); -} -#endif -void TEventLauncher::Init() -{ } bool TEventLauncher::Load(cParser *parser) @@ -66,10 +58,10 @@ bool TEventLauncher::Load(cParser *parser) *parser >> token; if (token != "none") { - if (token.size() == 1) - iKey = VkKeyScan(token[0]); // jeden znak jest konwertowany na kod klawisza + if( token.size() == 1 ) + iKey = vk_to_glfw_key( token[ 0 ] ); else - iKey = stol_def(token,0); // a jak więcej, to jakby numer klawisza jest + iKey = vk_to_glfw_key(stol_def( token, 0 )); // a jak więcej, to jakby numer klawisza jest } parser->getTokens(); *parser >> DeltaTime; @@ -80,8 +72,17 @@ bool TEventLauncher::Load(cParser *parser) iMinute = int(DeltaTime) % 100; // minuty są najmłodszymi cyframi dziesietnymi iHour = int(DeltaTime - iMinute) / 100; // godzina to setki DeltaTime = 0; // bez powtórzeń - WriteLog("EventLauncher at " + std::to_string(iHour) + ":" + - std::to_string(iMinute)); // wyświetlenie czasu + // potentially shift the provided time by requested offset + auto const timeoffset { static_cast( Global.ScenarioTimeOffset * 60 ) }; + if( timeoffset != 0 ) { + auto const adjustedtime { clamp_circular( iHour * 60 + iMinute + timeoffset, 24 * 60 ) }; + iHour = ( adjustedtime / 60 ) % 24; + iMinute = adjustedtime % 60; + } + WriteLog( + "EventLauncher at " + + std::to_string( iHour ) + ":" + + ( iMinute < 10 ? "0" : "" ) + to_string( iMinute ) ); // wyświetlenie czasu } parser->getTokens(); *parser >> token; @@ -107,20 +108,14 @@ bool TEventLauncher::Load(cParser *parser) asMemCellName = token; parser->getTokens(); *parser >> token; -#ifdef EU07_USE_OLD_TEVENTLAUNCHER_TEXT_ARRAY - SafeDeleteArray(szText); - szText = new char[256]; - strcpy(szText, token.c_str()); -#else szText = token; -#endif if (token != "*") //*=nie brać command pod uwagę - iCheckMask |= conditional_memstring; + iCheckMask |= basic_event::flags::text; parser->getTokens(); *parser >> token; if (token != "*") //*=nie brać wartości 1. pod uwagę { - iCheckMask |= conditional_memval1; + iCheckMask |= basic_event::flags::value_1; fVal1 = atof(token.c_str()); } else @@ -129,7 +124,7 @@ bool TEventLauncher::Load(cParser *parser) *parser >> token; if (token.compare("*") != 0) //*=nie brać wartości 2. pod uwagę { - iCheckMask |= conditional_memval2; + iCheckMask |= basic_event::flags::value_2; fVal2 = atof(token.c_str()); } else @@ -138,57 +133,160 @@ bool TEventLauncher::Load(cParser *parser) *parser >> token; } return true; -}; +} -bool TEventLauncher::Render() -{ //"renderowanie" wyzwalacza - bool bCond = false; - if (iKey != 0) - { - if (Global::bActive) // tylko jeśli okno jest aktywne - bCond = (Console::Pressed(iKey)); // czy klawisz wciśnięty +bool TEventLauncher::check_activation() { + + auto bCond { false }; + + if( iKey != 0 ) { + if( iKey > 255 ) { + // key and modifier + auto const modifier = ( iKey & 0xff00 ) >> 8; + bCond = ( Console::Pressed( iKey & 0xff ) ) + && ( ( modifier & 1 ) ? Global.shiftState : true ) + && ( ( modifier & 2 ) ? Global.ctrlState : true ); + } + else { + // just key + bCond = ( Console::Pressed( iKey & 0xff ) ); // czy klawisz wciśnięty + } } - if (DeltaTime > 0) - { - if (UpdatedTime > DeltaTime) - { + if( DeltaTime > 0 ) { + if( UpdatedTime > DeltaTime ) { UpdatedTime = 0; // naliczanie od nowa bCond = true; } - else - UpdatedTime += Timer::GetDeltaTime(); // aktualizacja naliczania czasu + else { + // aktualizacja naliczania czasu + UpdatedTime += Timer::GetDeltaTime(); + } } - else - { // jeśli nie cykliczny, to sprawdzić czas - if (GlobalTime->hh == iHour) - { - if (GlobalTime->mm == iMinute) - { // zgodność czasu uruchomienia - if (UpdatedTime < 10) - { + else { + // jeśli nie cykliczny, to sprawdzić czas + if( simulation::Time.data().wHour == iHour ) { + if( simulation::Time.data().wMinute == iMinute ) { + // zgodność czasu uruchomienia + if( UpdatedTime < 10 ) { UpdatedTime = 20; // czas do kolejnego wyzwolenia? bCond = true; } } } - else + else { UpdatedTime = 1; + } } - if (bCond) // jeśli spełniony został warunek - { - if ((iCheckMask != 0) && MemCell) // sprawdzanie warunku na komórce pamięci - bCond = MemCell->Compare(szText, fVal1, fVal2, iCheckMask); + + return bCond; +} + +bool TEventLauncher::check_conditions() { + + auto bCond { true }; + + if( ( iCheckMask != 0 ) + && ( MemCell != nullptr ) ) { + // sprawdzanie warunku na komórce pamięci + bCond = MemCell->Compare( szText, fVal1, fVal2, iCheckMask ); } + return bCond; // sprawdzanie dRadius w Ground.cpp } -bool TEventLauncher::IsGlobal() -{ // sprawdzenie, czy jest globalnym wyzwalaczem czasu - if (DeltaTime == 0) - if (iHour >= 0) - if (iMinute >= 0) - if (dRadius < 0.0) // bez ograniczenia zasięgu - return true; - return false; -}; +// sprawdzenie, czy jest globalnym wyzwalaczem czasu +bool TEventLauncher::IsGlobal() const { + + return ( ( DeltaTime == 0 ) + && ( iHour >= 0 ) + && ( iMinute >= 0 ) + && ( dRadius < 0.0 ) ); // bez ograniczenia zasięgu +} + +// radius() subclass details, calculates node's bounding radius +float +TEventLauncher::radius_() { + + return std::sqrt( dRadius ); +} + +// serialize() subclass details, sends content of the subclass to provided stream +void +TEventLauncher::serialize_( std::ostream &Output ) const { + + // TODO: implement +} +// deserialize() subclass details, restores content of the subclass from provided stream +void +TEventLauncher::deserialize_( std::istream &Input ) { + + // TODO: implement +} + +// export() subclass details, sends basic content of the class in legacy (text) format to provided stream +void +TEventLauncher::export_as_text_( std::ostream &Output ) const { + // header + Output << "eventlauncher "; + // location + Output + << location().x << ' ' + << location().y << ' ' + << location().z << ' '; + // activation radius + Output + << ( dRadius > 0 ? std::sqrt( dRadius ) : dRadius ) << ' '; + // activation key + if( iKey != 0 ) { + auto const key { iKey & 0xff }; + auto const modifier { ( iKey & 0xff00 ) >> 8 }; + if( ( key >= GLFW_KEY_A ) && ( key <= GLFW_KEY_Z ) ) { + Output << static_cast(( 'A' + key - GLFW_KEY_A + ( ( modifier & 1 ) == 0 ? 32 : 0 ) )) << ' '; + } + else if( ( key >= GLFW_KEY_0 ) && ( key <= GLFW_KEY_9 ) ) { + Output << static_cast(( '0' + key - GLFW_KEY_0 )) << ' '; + } + } + else { + Output << "none "; + } + // activation interval or hour + if( DeltaTime != 0 ) { + // cyclical launcher + Output << -DeltaTime << ' '; + } + else { + // single activation at specified time + if( ( iHour < 0 ) + && ( iMinute < 0 ) ) { + Output << DeltaTime << ' '; + } + else { + // NOTE: activation hour might be affected by user-requested time offset + auto const timeoffset{ static_cast( Global.ScenarioTimeOffset * 60 ) }; + auto const adjustedtime{ clamp_circular( iHour * 60 + iMinute - timeoffset, 24 * 60 ) }; + Output + << ( adjustedtime / 60 ) % 24 + << ( adjustedtime % 60 ) + << ' '; + } + } + // associated event(s) + Output << ( asEvent1Name.empty() ? "none" : asEvent1Name ) << ' '; + Output << ( asEvent2Name.empty() ? "none" : asEvent2Name ) << ' '; + if( false == asMemCellName.empty() ) { + // conditional event + Output + << "condition " + << asMemCellName << ' ' + << szText << ' ' + << ( ( iCheckMask & basic_event::flags::value_1 ) != 0 ? to_string( fVal1 ) : "*" ) << ' ' + << ( ( iCheckMask & basic_event::flags::value_2 ) != 0 ? to_string( fVal2 ) : "*" ) << ' '; + } + // footer + Output + << "end" + << "\n"; +} + //--------------------------------------------------------------------------- diff --git a/EvLaunch.h b/EvLaunch.h index 491c14b3..84512e56 100644 --- a/EvLaunch.h +++ b/EvLaunch.h @@ -7,44 +7,57 @@ obtain one at http://mozilla.org/MPL/2.0/. */ -#ifndef EvLaunchH -#define EvLaunchH +#pragma once #include -#include "Classes.h" -class TEventLauncher -{ - private: - int iKey; - double DeltaTime; - double UpdatedTime; - double fVal1; - double fVal2; -#ifdef EU07_USE_OLD_TEVENTLAUNCHER_TEXT_ARRAY - char * szText; -#else - std::string szText; -#endif - int iHour, iMinute; // minuta uruchomienia - public: - double dRadius; +#include "Classes.h" +#include "scenenode.h" + +class TEventLauncher : public scene::basic_node { + +public: +// constructor + explicit TEventLauncher( scene::node_data const &Nodedata ) : basic_node( Nodedata ) {} + // legacy constructor + TEventLauncher() = default; + +// methods + bool Load( cParser *parser ); + bool check_activation(); + // checks conditions associated with the event. returns: true if the conditions are met + bool check_conditions(); + bool IsGlobal() const; +// members std::string asEvent1Name; std::string asEvent2Name; std::string asMemCellName; - TEvent *Event1; - TEvent *Event2; - TMemCell *MemCell; - int iCheckMask; - TEventLauncher(); -#ifdef EU07_USE_OLD_TEVENTLAUNCHER_TEXT_ARRAY - ~TEventLauncher(); -#endif - void Init(); - bool Load(cParser *parser); - bool Render(); - bool IsGlobal(); + basic_event *Event1 { nullptr }; + basic_event *Event2 { nullptr }; + TMemCell *MemCell { nullptr }; + int iCheckMask { 0 }; + double dRadius { 0.0 }; + +private: +// methods + // radius() subclass details, calculates node's bounding radius + float radius_(); + // serialize() subclass details, sends content of the subclass to provided stream + void serialize_( std::ostream &Output ) const; + // deserialize() subclass details, restores content of the subclass from provided stream + void deserialize_( std::istream &Input ); + // export() subclass details, sends basic content of the class in legacy (text) format to provided stream + void export_as_text_( std::ostream &Output ) const; + +// members + int iKey { 0 }; + double DeltaTime { -1.0 }; + double UpdatedTime { 0.0 }; + double fVal1 { 0.0 }; + double fVal2 { 0.0 }; + std::string szText; + int iHour { -1 }; + int iMinute { -1 }; // minuta uruchomienia }; //--------------------------------------------------------------------------- -#endif diff --git a/Event.cpp b/Event.cpp index de274e49..498d231f 100644 --- a/Event.cpp +++ b/Event.cpp @@ -14,685 +14,2155 @@ http://mozilla.org/MPL/2.0/. */ #include "stdafx.h" -#include "Event.h" -#include "Globals.h" -#include "Logs.h" -#include "Usefull.h" -#include "parser.h" -#include "Timer.h" -#include "MemCell.h" -#include "Ground.h" -#include "McZapkie\mctools.h" +#include "event.h" -TEvent::TEvent( std::string const &m ) : - asNodeName( m ) -{ - if( false == m.empty() ) { - // utworzenie niejawnego odczytu komórki pamięci w torze - Type = tp_GetValues; - } - for( int i = 0; i < 13; ++i ) { - Params[ i ].asPointer = nullptr; - } -}; +#include "simulation.h" +#include "messaging.h" +#include "globals.h" +#include "memcell.h" +#include "track.h" +#include "traction.h" +#include "tractionpower.h" +#include "sound.h" +#include "animmodel.h" +#include "dynobj.h" +#include "driver.h" +#include "timer.h" +#include "logs.h" -TEvent::~TEvent() -{ - switch (Type) - { // sprzątanie - case tp_Multiple: - // SafeDeleteArray(Params[9].asText); //nie usuwać - nazwa obiektu powiązanego zamieniana na - // wskaźnik - if (iFlags & conditional_memstring) // o ile jest łańcuch do porównania w memcompare - SafeDeleteArray(Params[10].asText); - break; - case tp_UpdateValues: - case tp_AddValues: - SafeDeleteArray(Params[0].asText); - if (iFlags & conditional_memstring) // o ile jest łańcuch do porównania w memcompare - SafeDeleteArray(Params[10].asText); - break; - case tp_Animation: // nic - // SafeDeleteArray(Params[9].asText); //nie usuwać - nazwa jest zamieniana na wskaźnik do - // submodelu - if (Params[0].asInt == 4) // jeśli z pliku VMD - delete[] Params[8].asPointer; // zwolnić obszar - case tp_GetValues: // nic - break; - case tp_PutValues: // params[0].astext stores the token - SafeDeleteArray( Params[ 0 ].asText ); - break; - } - evJoined = NULL; // nie usuwać podczepionych tutaj -}; +void +basic_event::event_conditions::bind( basic_event::node_sequence *Nodes ) { -void TEvent::Init(){ + cells = Nodes; +} -}; +void +basic_event::event_conditions::init() { -void TEvent::Conditions(cParser *parser, string s) -{ // przetwarzanie warunków, wspólne dla Multiple i UpdateValues - if (s == "condition") - { // jesli nie "endevent" - std::string token, str; - if (!asNodeName.empty()) - { // podczepienie łańcucha, jeśli nie jest pusty - // BUG: source of a memory leak -- the array never gets deleted. fix the destructor - Params[9].asText = new char[asNodeName.length() + 1]; // usuwane i zamieniane na - // wskaźnik - strcpy(Params[9].asText, asNodeName.c_str()); - } - parser->getTokens(); - *parser >> token; - str = token; - if (str == "trackoccupied") - iFlags |= conditional_trackoccupied; - else if (str == "trackfree") - iFlags |= conditional_trackfree; - else if (str == "propability") - { - iFlags |= conditional_propability; - parser->getTokens(); - *parser >> Params[10].asdouble; - } - else if (str == "memcompare") - { - iFlags |= conditional_memcompare; - parser->getTokens(1, false); // case sensitive - *parser >> token; - str = token; - if (str != "*") //"*" - nie brac command pod uwage - { // zapamiętanie łańcucha do porównania - Params[10].asText = new char[255]; - strcpy(Params[10].asText, str.c_str()); - iFlags |= conditional_memstring; - } - parser->getTokens(); - *parser >> token; - str = token; - if (str != "*") //"*" - nie brac val1 pod uwage - { - Params[11].asdouble = atof(str.c_str()); - iFlags |= conditional_memval1; - } - parser->getTokens(); - *parser >> token; - str = token; - if (str != "*") //"*" - nie brac val2 pod uwage - { - Params[12].asdouble = atof(str.c_str()); - iFlags |= conditional_memval2; + tracks.clear(); + + if( flags & ( flags::track_busy | flags::track_free ) ) { + for( auto &target : *cells ) { + tracks.emplace_back( simulation::Paths.find( std::get( target ) ) ); + if( tracks.back() == nullptr ) { + // legacy compatibility behaviour, instead of disabling the event we disable the memory cell comparison test +// m_ignored = true; // deaktywacja +// ErrorLog( "Bad event: track \"" + std::get( target ) + "\" referenced in event \"" + asName + "\" doesn't exist" ); + flags &= ~( flags::track_busy | flags::track_free ); // zerowanie flag } } - parser->getTokens(); - *parser >> token; - s = token; // ewentualnie dalej losowe opóźnienie } - if (s == "randomdelay") - { // losowe opóźnienie - std::string token; - parser->getTokens(); - *parser >> fRandomDelay; // Ra 2014-03-11 - parser->getTokens(); - *parser >> token; // endevent - } -}; +} + +bool +basic_event::event_conditions::test() const { + + if( flags == 0 ) { + return true; // bezwarunkowo + } + // if there's conditions, check them + if( flags & flags::probability ) { + auto const randomroll { static_cast( Random() ) }; + WriteLog( "Test: Random integer - [" + std::to_string( randomroll ) + "] / [" + std::to_string( probability ) + "]" ); + if( randomroll > probability ) { + return false; + } + } + if( flags & flags::track_busy ) { + for( auto *track : tracks ) { + if( true == track->IsEmpty() ) { + return false; + } + } + } + if( flags & flags::track_free ) { + for( auto *track : tracks ) { + if( false == track->IsEmpty() ) { + return false; + } + } + } + if( flags & ( flags::text | flags::value_1 | flags::value_2 ) ) { + // porównanie wartości + for( auto &cellwrapper : *cells ) { + auto *cell { static_cast( std::get( cellwrapper ) ) }; + if( cell == nullptr ) { +// ErrorLog( "Event " + asName + " trying conditional_memcompare with nonexistent memcell" ); + continue; // though this is technically error, we treat it as a success to maintain backward compatibility + } + auto const comparisonresult = + cell->Compare( + match_text, + match_value_1, + match_value_2, + flags ); + + std::string comparisonlog = "Test: MemCompare - "; + + comparisonlog += + "[" + cell->Text() + "]" + + " [" + to_string( cell->Value1(), 2 ) + "]" + + " [" + to_string( cell->Value2(), 2 ) + "]"; + + comparisonlog += ( + true == comparisonresult ? + " == " : + " != " ); + + comparisonlog += ( + TestFlag( flags, flags::text ) ? + "[" + std::string( match_text ) + "]" : + "[*]" ); + comparisonlog += ( + TestFlag( flags, flags::value_1 ) ? + " [" + to_string( match_value_1, 2 ) + "]" : + " [*]" ); + comparisonlog += ( + TestFlag( flags, flags::value_2 ) ? + " [" + to_string( match_value_2, 2 ) + "]" : + " [*]" ); + + WriteLog( comparisonlog ); + + if( false == comparisonresult ) { + return false; + } + } + } + // if we made it here it means we passed all checks + return true; +} + +void +basic_event::event_conditions::deserialize( cParser &Input ) { // przetwarzanie warunków, wspólne dla Multiple i UpdateValues -void TEvent::Load(cParser *parser, vector3 *org) -{ - int i; - int ti; - double tf; std::string token; - //string str; - char *ptr; + while( ( true == Input.getTokens() ) + && ( false == ( token = Input.peek() ).empty() ) + && ( false == basic_event::is_keyword( token ) ) ) { - bEnabled = true; // zmieniane na false dla eventów używanych do skanowania sygnałów - - parser->getTokens(); - *parser >> token; - asName = ToLower(token); // użycie parametrów może dawać wielkie - - parser->getTokens(); - *parser >> token; - // str = AnsiString(token.c_str()); - - if (token == "exit") - Type = tp_Exit; - else if (token == "updatevalues") - Type = tp_UpdateValues; - else if (token == "getvalues") - Type = tp_GetValues; - else if (token == "putvalues") - Type = tp_PutValues; - else if (token == "disable") - Type = tp_Disable; - else if (token == "sound") - Type = tp_Sound; - else if (token == "velocity") - Type = tp_Velocity; - else if (token == "animation") - Type = tp_Animation; - else if (token == "lights") - Type = tp_Lights; - else if (token == "visible") - Type = tp_Visible; // zmiana wyświetlania obiektu - else if (token == "switch") - Type = tp_Switch; - else if (token == "dynvel") - Type = tp_DynVel; - else if (token == "trackvel") - Type = tp_TrackVel; - else if (token == "multiple") - Type = tp_Multiple; - else if (token == "addvalues") - Type = tp_AddValues; - else if (token == "copyvalues") - Type = tp_CopyValues; - else if (token == "whois") - Type = tp_WhoIs; - else if (token == "logvalues") - Type = tp_LogValues; - else if (token == "voltage") - Type = tp_Voltage; // zmiana napięcia w zasilaczu (TractionPowerSource) - else if (token == "message") - Type = tp_Message; // wyświetlenie komunikatu - else if (token == "friction") - Type = tp_Friction; // zmiana tarcia na scenerii - else - Type = tp_Unknown; - - parser->getTokens(); - *parser >> fDelay; - - parser->getTokens(); - *parser >> token; - // str = AnsiString(token.c_str()); - - if (token != "none") - asNodeName = token; // nazwa obiektu powiązanego - - if (asName.substr(0, 5) == "none_") - Type = tp_Ignored; // Ra: takie są ignorowane - - switch (Type) - { - case tp_AddValues: - iFlags = update_memadd; // dodawanko - case tp_UpdateValues: - // if (Type==tp_UpdateValues) iFlags=0; //co modyfikować - parser->getTokens(1, false); // case sensitive - *parser >> token; - // str = AnsiString(token.c_str()); - Params[0].asText = new char[token.length() + 1]; - strcpy(Params[0].asText, token.c_str()); - if (token != "*") // czy ma zostać bez zmian? - iFlags |= update_memstring; - parser->getTokens(); - *parser >> token; - // str = AnsiString(token.c_str()); - if (token != "*") // czy ma zostać bez zmian? - { - Params[1].asdouble = atof(token.c_str()); - iFlags |= update_memval1; + if( token == "trackoccupied" ) { + flags |= flags::track_busy; } - else - Params[1].asdouble = 0; - parser->getTokens(); - *parser >> token; - // str = AnsiString(token.c_str()); - if (token != "*") // czy ma zostać bez zmian? - { - Params[2].asdouble = atof(token.c_str()); - iFlags |= update_memval2; + else if( token == "trackfree" ) { + flags |= flags::track_free; } - else - Params[2].asdouble = 0; - parser->getTokens(); - *parser >> token; - Conditions(parser, token); // sprawdzanie warunków - break; - case tp_CopyValues: - Params[9].asText = NULL; - iFlags = update_memstring | update_memval1 | update_memval2; // normalanie trzy - i = 0; - parser->getTokens(); - *parser >> token; // nazwa drugiej komórki (źródłowej) - while (token.compare("endevent") != 0) - { - switch (++i) - { // znaczenie kolejnych parametrów - case 1: // nazwa drugiej komórki (źródłowej) - Params[9].asText = new char[token.length() + 1]; // usuwane i zamieniane na wskaźnik - strcpy(Params[9].asText, token.c_str()); - break; - case 2: // maska wartości - iFlags = stol_def(token, - (update_memstring | update_memval1 | update_memval2)); - break; + else if( token == "propability" ) { + flags |= flags::probability; + Input.getTokens(); + Input >> probability; + } + else if( token == "memcompare" ) { + Input.getTokens( 1, false ); // case sensitive + if( Input.peek() != "*" ) //"*" - nie brac command pod uwage + { // zapamiętanie łańcucha do porównania + Input >> match_text; + flags |= flags::text; } - parser->getTokens(); - *parser >> token; - } - break; - case tp_WhoIs: - iFlags = update_memstring | update_memval1 | update_memval2; // normalanie trzy - i = 0; - parser->getTokens(); - *parser >> token; // nazwa drugiej komórki (źródłowej) - while (token.compare("endevent") != 0) - { - switch (++i) - { // znaczenie kolejnych parametrów - case 1: // maska wartości - iFlags = stol_def(token, - (update_memstring | update_memval1 | update_memval2)); - break; - } - parser->getTokens(); - *parser >> token; - } - break; - case tp_GetValues: - case tp_LogValues: - parser->getTokens(); //"endevent" - *parser >> token; - break; - case tp_PutValues: - parser->getTokens(3); - *parser >> Params[3].asdouble >> Params[4].asdouble >> Params[5].asdouble; // położenie - // X,Y,Z - if (org) - { // przesunięcie - // tmp->pCenter.RotateY(aRotate.y/180.0*M_PI); //Ra 2014-11: uwzględnienie rotacji - Params[3].asdouble += org->x; // współrzędne w scenerii - Params[4].asdouble += org->y; - Params[5].asdouble += org->z; - } - // Params[12].asInt=0; - parser->getTokens(1, false); // komendy 'case sensitive' - *parser >> token; - // str = AnsiString(token.c_str()); - if (token.substr(0, 19) == "PassengerStopPoint:") - { - if (token.find('#') != std::string::npos) - token.erase(token.find('#')); // obcięcie unikatowości - win1250_to_ascii( token ); // get rid of non-ascii chars - bEnabled = false; // nie do kolejki (dla SetVelocity też, ale jak jest do toru - // dowiązany) - Params[6].asCommand = cm_PassengerStopPoint; - } - else if (token == "SetVelocity") - { - bEnabled = false; - Params[6].asCommand = cm_SetVelocity; - } - else if (token == "RoadVelocity") - { - bEnabled = false; - Params[6].asCommand = cm_RoadVelocity; - } - else if (token == "SectionVelocity") - { - bEnabled = false; - Params[6].asCommand = cm_SectionVelocity; - } - else if (token == "ShuntVelocity") - { - bEnabled = false; - Params[6].asCommand = cm_ShuntVelocity; - } - //else if (str == "SetProximityVelocity") - //{ - // bEnabled = false; - // Params[6].asCommand = cm_SetProximityVelocity; - //} - else if (token == "OutsideStation") - { - bEnabled = false; // ma być skanowny, aby AI nie przekraczało W5 - Params[6].asCommand = cm_OutsideStation; - } - else - Params[6].asCommand = cm_Unknown; - Params[0].asText = new char[token.length() + 1]; - strcpy(Params[0].asText, token.c_str()); - parser->getTokens(); - *parser >> token; - // str = AnsiString(token.c_str()); - if (token == "none") - Params[1].asdouble = 0.0; - else - try + Input.getTokens(); + if( Input.peek() != "*" ) //"*" - nie brac val1 pod uwage { - Params[1].asdouble = atof(token.c_str()); + Input >> match_value_1; + flags |= flags::value_1; } - catch (...) + Input.getTokens(); + if( Input.peek() != "*" ) //"*" - nie brac val2 pod uwage { - Params[1].asdouble = 0.0; - WriteLog("Error: number expected in PutValues event, found: " + token); + Input >> match_value_2; + flags |= flags::value_2; } - parser->getTokens(); - *parser >> token; - // str = AnsiString(token.c_str()); - if (token == "none") - Params[2].asdouble = 0.0; - else - try - { - Params[2].asdouble = atof(token.c_str()); - } - catch (...) - { - Params[2].asdouble = 0.0; - WriteLog("Error: number expected in PutValues event, found: " + token); - } - parser->getTokens(); - *parser >> token; - break; - case tp_Lights: - i = 0; - do - { - parser->getTokens(); - *parser >> token; - if (token.compare("endevent") != 0) - { - // str = AnsiString(token.c_str()); - if (i < 8) - Params[i].asdouble = atof(token.c_str()); // teraz może mieć ułamek - i++; - } - } while (token.compare("endevent") != 0); - break; - case tp_Visible: // zmiana wyświetlania obiektu - parser->getTokens(); - *parser >> token; - // str = AnsiString(token.c_str()); - Params[0].asInt = atoi(token.c_str()); - parser->getTokens(); - *parser >> token; - break; - case tp_Velocity: - parser->getTokens(); - *parser >> token; - // str = AnsiString(token.c_str()); - Params[0].asdouble = atof(token.c_str()) * 0.28; - parser->getTokens(); - *parser >> token; - break; - case tp_Sound: - // Params[0].asRealSound->Init(asNodeName.c_str(),Parser->GetNextSymbol().ToDouble(),Parser->GetNextSymbol().ToDouble(),Parser->GetNextSymbol().ToDouble(),Parser->GetNextSymbol().ToDouble()); - // McZapkie-070502: dzwiek przestrzenny (ale do poprawy) - // Params[1].asdouble=Parser->GetNextSymbol().ToDouble(); - // Params[2].asdouble=Parser->GetNextSymbol().ToDouble(); - // Params[3].asdouble=Parser->GetNextSymbol().ToDouble(); //polozenie X,Y,Z - do poprawy! - parser->getTokens(); - *parser >> Params[0].asInt; // 0: wylaczyc, 1: wlaczyc; -1: wlaczyc zapetlone - parser->getTokens(); - *parser >> token; - break; - case tp_Exit: - while ((ptr = strchr(strdup(asNodeName.c_str()), '_')) != NULL) - *ptr = ' '; - parser->getTokens(); - *parser >> token; - break; - case tp_Disable: - parser->getTokens(); - *parser >> token; - break; - case tp_Animation: - parser->getTokens(); - *parser >> token; - Params[0].asInt = 0; // na razie nieznany typ - if (token.compare("rotate") == 0) - { // obrót względem osi - parser->getTokens(); - *parser >> token; - Params[9].asText = new char[token.size() + 1]; // nazwa submodelu - std::strcpy(Params[9].asText, token.c_str()); - Params[0].asInt = 1; - parser->getTokens(4); - *parser - >> Params[1].asdouble - >> Params[2].asdouble - >> Params[3].asdouble - >> Params[4].asdouble; } - else if (token.compare("translate") == 0) - { // przesuw o wektor - parser->getTokens(); - *parser >> token; - Params[9].asText = new char[token.size() + 1]; // nazwa submodelu - std::strcpy(Params[9].asText, token.c_str()); - Params[0].asInt = 2; - parser->getTokens(4); - *parser - >> Params[1].asdouble - >> Params[2].asdouble - >> Params[3].asdouble - >> Params[4].asdouble; + } +} + +// sends basic content of the class in legacy (text) format to provided stream +void +basic_event::event_conditions::export_as_text( std::ostream &Output ) const { + + if( flags != 0 ) { + Output << "condition "; + if( ( flags & flags::track_busy ) != 0 ) { + Output << "trackoccupied "; } - else if (token.compare("digital") == 0) - { // licznik cyfrowy - parser->getTokens(); - *parser >> token; - Params[9].asText = new char[token.size() + 1]; // nazwa submodelu - std::strcpy(Params[9].asText, token.c_str()); - Params[0].asInt = 8; - parser->getTokens(4); // jaki ma być sens tych parametrów? - *parser - >> Params[1].asdouble - >> Params[2].asdouble - >> Params[3].asdouble - >> Params[4].asdouble; + if( ( flags & flags::track_free ) != 0 ) { + Output << "trackfree "; } - else if (token.substr(token.length() - 4, 4) == ".vmd") // na razie tu, może będzie inaczej - { // animacja z pliku VMD -// TFileStream *fs = new TFileStream( "models\\" + AnsiString( token.c_str() ), fmOpenRead ); - { - std::ifstream file( "models\\" + token, std::ios::binary | std::ios::ate ); file.unsetf( std::ios::skipws ); - auto size = file.tellg(); // ios::ate already positioned us at the end of the file - file.seekg( 0, std::ios::beg ); // rewind the caret afterwards - Params[ 7 ].asInt = size; - Params[8].asPointer = new char[size]; - file.read( static_cast(Params[ 8 ].asPointer), size ); // wczytanie pliku - } - parser->getTokens(); - *parser >> token; - Params[9].asText = new char[token.size() + 1]; // nazwa submodelu - std::strcpy(Params[9].asText, token.c_str()); - Params[0].asInt = 4; // rodzaj animacji - parser->getTokens(4); - *parser - >> Params[1].asdouble - >> Params[2].asdouble - >> Params[3].asdouble - >> Params[4].asdouble; + if( ( flags & flags::probability ) != 0 ) { + Output + << "propability " + << probability << ' '; } - parser->getTokens(); - *parser >> token; - break; - case tp_Switch: - parser->getTokens(); - *parser >> Params[0].asInt; - parser->getTokens(); - *parser >> token; - // str = AnsiString(token.c_str()); - if (token != "endevent") - { - Params[1].asdouble = atof(token.c_str()); // prędkość liniowa ruchu iglic - parser->getTokens(); - *parser >> token; - // str = AnsiString(token.c_str()); + if( ( flags & ( flags::text | flags::value_1 | flags::value_2 ) ) != 0 ) { + Output + << "memcompare " + << ( ( flags & flags::text ) == 0 ? "*" : match_text ) << ' ' + << ( ( flags & flags::value_1 ) == 0 ? "*" : to_string( match_value_1 ) ) << ' ' + << ( ( flags & flags::value_2 ) == 0 ? "*" : to_string( match_value_2 ) ) << ' '; } - else - Params[1].asdouble = -1.0; // użyć domyślnej - if (token != "endevent") - { - Params[2].asdouble = - atof(token.c_str()); // dodatkowy ruch drugiej iglicy (zamknięcie nastawnicze) - parser->getTokens(); - *parser >> token; + } +} + +basic_event::~basic_event() { + + m_sibling = nullptr; // nie usuwać podczepionych tutaj +} + +void +basic_event::deserialize( cParser &Input, scene::scratch_data &Scratchpad ) { + + std::string token; + + Input.getTokens(); + Input >> m_delay; + + Input.getTokens(); + Input >> token; + deserialize_targets( token ); + + if (m_name.substr(0, 5) == "none_") + m_ignored = true; // Ra: takie są ignorowane + + deserialize_( Input, Scratchpad ); + // subclass method is expected to leave next token past its own data preloaded on its exit + while( ( false == ( token = Input.peek() ).empty() ) + && ( token != "endevent" ) ) { + + if( token == "randomdelay" ) { // losowe opóźnienie + Input.getTokens(); + Input >> m_delayrandom; // Ra 2014-03-11 } - else - Params[2].asdouble = -1.0; // użyć domyślnej - break; - case tp_DynVel: - parser->getTokens(); - *parser >> Params[0].asdouble; // McZapkie-090302 *0.28; - parser->getTokens(); - *parser >> token; - break; - case tp_TrackVel: - parser->getTokens(); - *parser >> Params[0].asdouble; // McZapkie-090302 *0.28; - parser->getTokens(); - *parser >> token; - break; - case tp_Multiple: - i = 0; - ti = 0; // flaga dla else - parser->getTokens(); - *parser >> token; - // str = AnsiString(token.c_str()); - while (token != "endevent" && token != "condition" && - token != "randomdelay") - { - if ((token.substr(0, 5) != "none_") ? (i < 8) : false) - { // eventy rozpoczynające się od "none_" są ignorowane - if (token != "else") - { - Params[i].asText = new char[255]; - strcpy(Params[i].asText, token.c_str()); - if (ti) - iFlags |= conditional_else << i; // oflagowanie dla eventów "else" - i++; - } - else - ti = !ti; // zmiana flagi dla słowa "else" - } - else if (i >= 8) - ErrorLog("Bad event: \"" + token + "\" ignored in multiple \"" + asName + "\"!"); - else - WriteLog("Event \"" + token + "\" ignored in multiple \"" + asName + "\"!"); - parser->getTokens(); - *parser >> token; - // str = AnsiString(token.c_str()); + Input.getTokens(); + } +} + +void +basic_event::deserialize_targets( std::string const &Input ) { + + cParser targetparser { Input }; + std::string target; + while( false == ( target = targetparser.getToken( true, "|," ) ).empty() ) { + // actual bindings to targets of proper type are created during scenario initialization + if( target != "none" ) { + m_targets.emplace_back( target, nullptr ); } - Conditions(parser, token); // sprawdzanie warunków - break; - case tp_Voltage: // zmiana napięcia w zasilaczu (TractionPowerSource) - case tp_Friction: // zmiana przyczepnosci na scenerii - parser->getTokens(); - *parser >> Params[0].asdouble; // Ra 2014-01-27 - parser->getTokens(); - *parser >> token; - break; - case tp_Message: // wyświetlenie komunikatu - do - { - parser->getTokens(); - *parser >> token; - // str = AnsiString(token.c_str()); - } while (token != "endevent"); - break; - case tp_Ignored: // ignorowany - case tp_Unknown: // nieznany - do - { - parser->getTokens(); - *parser >> token; - // str = AnsiString(token.c_str()); - } while (token != "endevent"); - WriteLog("Bad event: \"" + asName + - (Type == tp_Unknown ? "\" has unknown type." : "\" is ignored.")); - break; + } +} + +void +basic_event::run() { + + WriteLog( "EVENT LAUNCHED" + ( m_activator ? ( " by " + m_activator->asName ) : "" ) + ": " + m_name ); + run_(); +} + +// sends basic content of the class in legacy (text) format to provided stream +void +basic_event::export_as_text( std::ostream &Output ) const { + // header + Output << "event "; + // name + Output << m_name << ' '; + // type + Output << type() << ' '; + // delay + Output << m_delay << ' '; + // target node(s) + if( m_targets.empty() ) { + Output << "none"; + } + else { + auto targetidx { 0 }; + for( auto &target : m_targets ) { + auto *targetnode { std::get( target ) }; + Output + << ( targetnode != nullptr ? targetnode->name() : std::get( target ) ) + << ( ++targetidx < m_targets.size() ? '|' : ' ' ); + } + } + // type-specific attributes + export_as_text_( Output ); + + if( m_delayrandom != 0.0 ) { + Output + << "randomdelay " + << m_delayrandom << ' '; + } + // footer + Output + << "endevent" + << "\n"; +} + +void +basic_event::append( basic_event *Event ) { + // doczepienie kolejnych z tą samą nazwą + // TODO: remove recursion + if( m_sibling ) + m_sibling->append( Event ); // rekurencja! - góra kilkanaście eventów będzie potrzebne + else { + m_sibling = Event; + Event->m_passive = false; // ten doczepiony może być tylko kolejkowany } }; -void TEvent::AddToQuery(TEvent *e) -{ // dodanie eventu do kolejki - if (evNext ? (e->fStartTime >= evNext->fStartTime) : false) - evNext->AddToQuery(e); // sortowanie wg czasu - else - { // dodanie z przodu - e->evNext = evNext; - evNext = e; +// returns: true if the event should be executed immediately +bool +basic_event::is_instant() const { + + return false; +} + +// sends content of associated data cell to specified vehicle controller +void +basic_event::send_command( TController &Controller ) { + + return; +} + +// returns: true if associated data cell contains a command for vehicle controller +bool +basic_event::is_command() const { + + return false; +}; + +std::string +basic_event::input_text() const { + // odczytanie komendy z eventu + return ""; +}; + +TCommandType +basic_event::input_command() const { + // odczytanie komendy z eventu + return TCommandType::cm_Unknown; +}; + +double +basic_event::input_value( int Index ) const { + // odczytanie komendy z eventu + return 0.0; +}; + +glm::dvec3 +basic_event::input_location() const { + // pobranie współrzędnych eventu + return glm::dvec3( 0, 0, 0 ); +}; + +bool +basic_event::is_keyword( std::string const &Token ) { + + return ( Token == "endevent" ) + || ( Token == "randomdelay" ); +} + + + +TMemCell const * +input_event::input_data::data_cell() const { + + return static_cast( std::get( data_source ) ); +} +TMemCell * +input_event::input_data::data_cell() { + + return static_cast( std::get( data_source ) ); +} + + + +// prepares event for use +void +updatevalues_event::init() { + // sumowanie wartości // zmiana wartości + init_targets( simulation::Memory, "memory cell" ); + // conditional data + m_conditions.bind( &m_targets ); + m_conditions.init(); +} + +// event type string +std::string +updatevalues_event::type() const { + + return ( + ( m_input.flags & flags::mode_add ) == 0 ? + "updatevalues" : + "addvalues" ); +} + +// deserialize() subclass details +void +updatevalues_event::deserialize_( cParser &Input, scene::scratch_data &Scratchpad ) { + + Input.getTokens( 1, false ); // case sensitive + Input >> m_input.data_text; + if( m_input.data_text != "*" ) { //"*" - nie brac command pod uwage + m_input.flags |= flags::text; } + Input.getTokens(); + if( Input.peek() != "*" ) { //"*" - nie brac val1 pod uwage + Input >> m_input.data_value_1; + m_input.flags |= flags::value_1; + } + Input.getTokens(); + if( Input.peek() != "*" ) { //"*" - nie brac val2 pod uwage + Input >> m_input.data_value_2; + m_input.flags |= flags::value_2; + } + Input.getTokens(); + // optional blocks + std::string token; + while( ( false == ( token = Input.peek() ).empty() ) + && ( false == is_keyword( token ) ) ) { + + if( token == "condition" ) { + m_conditions.deserialize( Input ); + // NOTE: condition deserialization leaves preloaded next token + } + } +} + +// run() subclass details +// TODO: update and copy values run_ methods are largely identical, refactor to a single helper +void +updatevalues_event::run_() { + + if( false == m_conditions.test() ) { return; } + + WriteLog( "Type: " + std::string( ( m_input.flags & flags::mode_add ) ? "AddValues" : "UpdateValues" ) + " & Track command - [" + + ( ( m_input.flags & flags::text ) ? m_input.data_text : "X" ) + "] [" + + ( ( m_input.flags & flags::value_1 ) ? to_string( m_input.data_value_1, 2 ) : "X" ) + "] [" + + ( ( m_input.flags & flags::value_2 ) ? to_string( m_input.data_value_2, 2 ) : "X" ) + "]" ); + // TODO: dump status of target cells after the operation + for( auto &target : m_targets ) { + auto *targetcell { static_cast( std::get( target ) ) }; + if( targetcell == nullptr ) { continue; } + targetcell->UpdateValues( + m_input.data_text, + m_input.data_value_1, + m_input.data_value_2, + m_input.flags ); + if( targetcell->Track == nullptr ) { continue; } + // McZapkie-100302 - updatevalues oprocz zmiany wartosci robi putcommand dla wszystkich 'dynamic' na danym torze + auto const location { targetcell->location() }; + for( auto dynamic : targetcell->Track->Dynamics ) { + targetcell->PutCommand( + dynamic->Mechanik, + &location ); + } + } +} + +// export_as_text() subclass details +void +updatevalues_event::export_as_text_( std::ostream &Output ) const { + + Output + << ( ( m_input.flags & flags::text ) == 0 ? "*" : m_input.data_text ) << ' ' + << ( ( m_input.flags & flags::value_1 ) == 0 ? "*" : to_string( m_input.data_value_1 ) ) << ' ' + << ( ( m_input.flags & flags::value_2 ) == 0 ? "*" : to_string( m_input.data_value_2 ) ) << ' '; + + m_conditions.export_as_text( Output ); +} + +// returns: true if the event should be executed immediately +bool +updatevalues_event::is_instant() const { + + return ( ( ( m_input.flags & flags::mode_add ) != 0 ) && ( m_delay == 0.0 ) ); +} + + + +// prepares event for use +void +getvalues_event::init() { + + init_targets( simulation::Memory, "memory cell" ); + // custom target initialization code + for( auto &target : m_targets ) { + auto *targetcell { static_cast( std::get( target ) ) }; + if( targetcell == nullptr ) { continue; } + if( targetcell->IsVelocity() ) { + // jeśli odczyt komórki a komórka zawiera komendę SetVelocity albo ShuntVelocity + // to event nie będzie dodawany do kolejki + m_passive = true; + } + } + // NOTE: GetValues retrieves data only from first specified memory cell + // TBD, TODO: allow retrieval from more than one cell? + m_input.data_source = m_targets.front(); +} + +// event type string +std::string +getvalues_event::type() const { + + return "getvalues"; +} + +// deserialize() subclass details +void +getvalues_event::deserialize_( cParser &Input, scene::scratch_data &Scratchpad ) { + // nothing to do here, just preload next token + Input.getTokens(); +} + +// run() subclass details +void +getvalues_event::run_() { + + WriteLog( "Type: GetValues" ); + + if( m_activator == nullptr ) { return; } + + m_input.data_cell()->PutCommand( + m_activator->Mechanik, + &( m_input.data_cell()->location() ) ); + + // potwierdzenie wykonania dla serwera (odczyt semafora już tak nie działa) + if( Global.iMultiplayer ) { + multiplayer::WyslijEvent( m_name, m_activator->name() ); + } +} + +// export_as_text() subclass details +void +getvalues_event::export_as_text_( std::ostream &Output ) const { + // nothing to do here +} + +// sends content of associated data cell to specified vehicle controller +void +getvalues_event::send_command( TController &Controller ) { + + Controller.PutCommand( input_text(), input_value( 1 ), input_value( 2 ), nullptr ); + m_input.data_cell()->StopCommandSent(); // komenda z komórki została wysłana +} +// returns: true if associated data cell contains a command for vehicle controller +bool +getvalues_event::is_command() const { + // info o komendzie z komórki + return m_input.data_cell()->StopCommand(); +} + +// input data access +std::string +getvalues_event::input_text() const { + + return m_input.data_cell()->Text(); +} + +TCommandType +getvalues_event::input_command() const { + + return m_input.data_cell()->Command(); +} + +double +getvalues_event::input_value( int Index ) const { + + Index &= 1; // tylko 1 albo 2 jest prawidłowy + return ( Index == 1 ? m_input.data_cell()->Value1() : m_input.data_cell()->Value2() ); +} + +glm::dvec3 +getvalues_event::input_location() const { + + return m_input.data_cell()->location(); // współrzędne podłączonej komórki pamięci +} + + + +// prepares event for use +void +putvalues_event::init() { + // nothing to do here +} + +// event type string +std::string +putvalues_event::type() const { + + return "putvalues"; +} + +// deserialize() subclass details +void +putvalues_event::deserialize_( cParser &Input, scene::scratch_data &Scratchpad ) { + + Input.getTokens( 3 ); + // location, previously held in param 3, 4, 5 + Input + >> m_input.location.x + >> m_input.location.y + >> m_input.location.z; + // przesunięcie + // tmp->pCenter.RotateY(aRotate.y/180.0*M_PI); //Ra 2014-11: uwzględnienie rotacji + // TBD, TODO: take into account rotation as well? + if( false == Scratchpad.location.offset.empty() ) { + m_input.location += Scratchpad.location.offset.top(); + } + + std::string token; + Input.getTokens( 1, false ); // komendy 'case sensitive' + Input >> token; + // command type, previously held in param 6 + if( token.substr( 0, 19 ) == "PassengerStopPoint:" ) { + if( token.find( '#' ) != std::string::npos ) + token.erase( token.find( '#' ) ); // obcięcie unikatowości + win1250_to_ascii( token ); // get rid of non-ascii chars + m_input.command_type = TCommandType::cm_PassengerStopPoint; + // nie do kolejki (dla SetVelocity też, ale jak jest do toru dowiązany) + m_passive = true; + } + else if( token == "SetVelocity" ) { + m_input.command_type = TCommandType::cm_SetVelocity; + m_passive = true; + } + else if( token == "RoadVelocity" ) { + m_input.command_type = TCommandType::cm_RoadVelocity; + m_passive = true; + } + else if( token == "SectionVelocity" ) { + m_input.command_type = TCommandType::cm_SectionVelocity; + m_passive = true; + } + else if( token == "ShuntVelocity" ) { + m_input.command_type = TCommandType::cm_ShuntVelocity; + m_passive = true; + } + else if( token == "OutsideStation" ) { + m_input.command_type = TCommandType::cm_OutsideStation; + m_passive = true; // ma być skanowny, aby AI nie przekraczało W5 + } + else { + m_input.command_type = TCommandType::cm_Unknown; + } + // update data, previously stored in params 0, 1, 2 + m_input.data_text = token; + Input.getTokens(); + if( Input.peek() != "none" ) { + Input >> m_input.data_value_1; + } + Input.getTokens(); + if( Input.peek() != "none" ) { + Input >> m_input.data_value_2; + } + // preload next token + Input.getTokens(); +} + +// run() subclass details +void +putvalues_event::run_() { + + WriteLog( + "Type: PutValues - [" + + m_input.data_text + "] [" + + to_string( m_input.data_value_1, 2 ) + "] [" + + to_string( m_input.data_value_2, 2 ) + "]" ); + + if( m_activator == nullptr ) { return; } + // zamiana, bo fizyka ma inaczej niż sceneria + // NOTE: y & z swap, negative x + TLocation const loc { + -m_input.location.x, + m_input.location.z, + m_input.location.y }; + + if( m_activator->Mechanik ) { + // przekazanie rozkazu do AI + m_activator->Mechanik->PutCommand( + m_input.data_text, + m_input.data_value_1, + m_input.data_value_2, + loc ); + } + else { + // przekazanie do pojazdu + m_activator->MoverParameters->PutCommand( + m_input.data_text, + m_input.data_value_1, + m_input.data_value_2, + loc ); + } +} + +// export_as_text() subclass details +void +putvalues_event::export_as_text_( std::ostream &Output ) const { + + Output + // location + << m_input.location.x << ' ' + << m_input.location.y << ' ' + << m_input.location.z << ' ' + // command + << m_input.data_text << ' ' + << m_input.data_value_1 << ' ' + << m_input.data_value_2 << ' '; +} + +// input data access +std::string +putvalues_event::input_text() const { + + return m_input.data_text; +} + +TCommandType +putvalues_event::input_command() const { + + return m_input.command_type; // komenda zakodowana binarnie +} + +double +putvalues_event::input_value( int Index ) const { + + Index &= 1; // tylko 1 albo 2 jest prawidłowy + return ( Index == 1 ? m_input.data_value_1 : m_input.data_value_2 ); +} + +glm::dvec3 +putvalues_event::input_location() const { + + return m_input.location; +} + + + +// prepares event for use +void +copyvalues_event::init() { + // skopiowanie komórki do innej + init_targets( simulation::Memory, "memory cell" ); + // source cell + std::get( m_input.data_source ) = simulation::Memory.find( std::get( m_input.data_source ) ); + if( std::get( m_input.data_source ) == nullptr ) { + m_ignored = true; // deaktywacja + ErrorLog( "Bad event: \"" + m_name + "\" (type: " + type() + ") can't find memory cell \"" + std::get( m_input.data_source ) + "\"" ); + } +} + +// event type string +std::string +copyvalues_event::type() const { + + return "copyvalues"; +} + +// deserialize() subclass details +void +copyvalues_event::deserialize_( cParser &Input, scene::scratch_data &Scratchpad ) { + + m_input.flags = ( flags::text | flags::value_1 | flags::value_2 ); // normalnie trzy + + std::string token; + int paramidx { 0 }; + + while( ( true == Input.getTokens() ) + && ( false == ( token = Input.peek() ).empty() ) + && ( false == is_keyword( token ) ) ) { + + Input >> token; + switch( ++paramidx ) { + case 1: { // nazwa drugiej komórki (źródłowej) // previously stored in param 9 + std::get( m_input.data_source ) = token; + break; + } + case 2: { // maska wartości + m_input.flags = stol_def( token, ( flags::text | flags::value_1 | flags::value_2 ) ); + break; + } + default: { + break; + } + } + } +} + +// run() subclass details +// TODO: update and copy values run_ methods are largely identical, refactor to a single helper +void +copyvalues_event::run_() { + // skopiowanie wartości z innej komórki + auto const *datasource { static_cast( std::get( m_input.data_source ) ) }; + m_input.data_text = datasource->Text(); + m_input.data_value_1 = datasource->Value1(); + m_input.data_value_2 = datasource->Value2(); + + WriteLog( "Type: CopyValues - [" + + ( ( m_input.flags & flags::text ) ? m_input.data_text : "X" ) + "] [" + + ( ( m_input.flags & flags::value_1 ) ? to_string( m_input.data_value_1, 2 ) : "X" ) + "] [" + + ( ( m_input.flags & flags::value_2 ) ? to_string( m_input.data_value_2, 2 ) : "X" ) + "]" ); + // TODO: dump status of target cells after the operation + for( auto &target : m_targets ) { + auto *targetcell { static_cast( std::get( target ) ) }; + if( targetcell == nullptr ) { continue; } + targetcell->UpdateValues( + m_input.data_text, + m_input.data_value_1, + m_input.data_value_2, + m_input.flags ); + if( targetcell->Track == nullptr ) { continue; } + // McZapkie-100302 - updatevalues oprocz zmiany wartosci robi putcommand dla wszystkich 'dynamic' na danym torze + auto const location { targetcell->location() }; + for( auto dynamic : targetcell->Track->Dynamics ) { + targetcell->PutCommand( + dynamic->Mechanik, + &location ); + } + } +} + +// export_as_text() subclass details +void +copyvalues_event::export_as_text_( std::ostream &Output ) const { + + auto const *datasource { static_cast( std::get( m_input.data_source ) ) }; + Output + << ( datasource != nullptr ? + datasource->name() : + std::get( m_input.data_source ) ) + << ' ' << ( m_input.flags & ( flags::text | flags::value_1 | flags::value_2 ) ) << ' '; +} + + + +// prepares event for use +void +whois_event::init() { + + init_targets( simulation::Memory, "memory cell" ); +} + +// event type string +std::string +whois_event::type() const { + + return "whois"; +} + +// deserialize() subclass details +void +whois_event::deserialize_( cParser &Input, scene::scratch_data &Scratchpad ) { + + m_input.flags = ( flags::text | flags::value_1 | flags::value_2 ); // normalnie trzy + + std::string token; + int paramidx { 0 }; + + while( ( true == Input.getTokens() ) + && ( false == ( token = Input.peek() ).empty() ) + && ( false == is_keyword( token ) ) ) { + + Input >> token; + switch( ++paramidx ) { + case 1: { // maska wartości + m_input.flags = stol_def( token, ( flags::text | flags::value_1 | flags::value_2 ) ); + break; + } + default: { + break; + } + } + } +} + +// run() subclass details +void +whois_event::run_() { + + for( auto &target : m_targets ) { + auto *targetcell { static_cast( std::get( target ) ) }; + if( targetcell == nullptr ) { continue; } + // event effect code + if( m_input.flags & flags::load ) { + // jeśli pytanie o ładunek + if( m_input.flags & flags::mode_add ) { + // jeśli typ pojazdu + // TODO: define and recognize individual request types + auto const owner { ( + ( ( m_activator->Mechanik != nullptr ) && ( m_activator->Mechanik->Primary() ) ) ? + m_activator->Mechanik : + m_activator->ctOwner ) }; + auto const consistbrakelevel { ( + owner != nullptr ? + owner->fReady : + -1.0 ) }; + auto const collisiondistance { ( + owner != nullptr ? + owner->TrackBlock() : + -1.0 ) }; + + targetcell->UpdateValues( + m_activator->MoverParameters->TypeName, // typ pojazdu + consistbrakelevel, + collisiondistance, + m_input.flags & ( flags::text | flags::value_1 | flags::value_2 ) ); + + WriteLog( + "Type: WhoIs (" + to_string( m_input.flags ) + ") - " + + "[name: " + m_activator->MoverParameters->TypeName + "], " + + "[consist brake level: " + to_string( consistbrakelevel, 2 ) + "], " + + "[obstacle distance: " + to_string( collisiondistance, 2 ) + " m]" ); + } + else { + // jeśli parametry ładunku + targetcell->UpdateValues( + m_activator->MoverParameters->LoadType.name, // nazwa ładunku + m_activator->MoverParameters->LoadAmount, // aktualna ilość + m_activator->MoverParameters->MaxLoad, // maksymalna ilość + m_input.flags & ( flags::text | flags::value_1 | flags::value_2 ) ); + + WriteLog( + "Type: WhoIs (" + to_string( m_input.flags ) + ") - " + + "[load type: " + m_activator->MoverParameters->LoadType.name + "], " + + "[current load: " + to_string( m_activator->MoverParameters->LoadAmount, 2 ) + "], " + + "[max load: " + to_string( m_activator->MoverParameters->MaxLoad, 2 ) + "]" ); + } + } + else if( m_input.flags & flags::mode_add ) { // jeśli miejsce docelowe pojazdu + targetcell->UpdateValues( + m_activator->asDestination, // adres docelowy + m_activator->DirectionGet(), // kierunek pojazdu względem czoła składu (1=zgodny,-1=przeciwny) + m_activator->MoverParameters->Power, // moc pojazdu silnikowego: 0 dla wagonu + m_input.flags & ( flags::text | flags::value_1 | flags::value_2 ) ); + + WriteLog( + "Type: WhoIs (" + to_string( m_input.flags ) + ") - " + + "[destination: " + m_activator->asDestination + "], " + + "[direction: " + to_string( m_activator->DirectionGet() ) + "], " + + "[engine power: " + to_string( m_activator->MoverParameters->Power, 2 ) + "]" ); + } + else if( m_activator->Mechanik ) { + if( m_activator->Mechanik->Primary() ) { // tylko jeśli ktoś tam siedzi - nie powinno dotyczyć pasażera! + targetcell->UpdateValues( + m_activator->Mechanik->TrainName(), + m_activator->Mechanik->StationCount() - m_activator->Mechanik->StationIndex(), // ile przystanków do końca + m_activator->Mechanik->IsStop() ? + 1 : + 0, // 1, gdy ma tu zatrzymanie + m_input.flags ); + WriteLog( "Train detected: " + m_activator->Mechanik->TrainName() ); + } + } + } +} + +// export_as_text() subclass details +void +whois_event::export_as_text_( std::ostream &Output ) const { + + Output << ( m_input.flags & ( flags::text | flags::value_1 | flags::value_2 ) ) << ' '; +} + + + +// prepares event for use +void +logvalues_event::init() { + + init_targets( simulation::Memory, "memory cell" ); +} + +// event type string +std::string +logvalues_event::type() const { + + return "logvalues"; +} + +// deserialize() subclass details +void +logvalues_event::deserialize_( cParser &Input, scene::scratch_data &Scratchpad ) { + // nothing to do here, just preload next token + Input.getTokens(); +} + +// run() subclass details +void +logvalues_event::run_() { + // zapisanie zawartości komórki pamięci do logu + if( m_targets.empty() ) { + // lista wszystkich + simulation::Memory.log_all(); + } + else { + // jeśli była podana nazwa komórki + for( auto &target : m_targets ) { + auto *targetcell { static_cast( std::get( target ) ) }; + if( targetcell == nullptr ) { continue; } + WriteLog( + "Memcell \"" + targetcell->name() + "\": [" + + targetcell->Text() + "] [" + + to_string( targetcell->Value1(), 2 ) + "] [" + + to_string( targetcell->Value2(), 2 ) + "]" ); + } + } +} + +// export_as_text() subclass details +void +logvalues_event::export_as_text_( std::ostream &Output ) const { + +} + + + +// prepares event for use +void +multi_event::init() { + + auto const conditiontchecksmemcell { m_conditions.flags & ( flags::text | flags::value_1 | flags::value_2 ) }; + // not all multi-events have memory cell checks, for the ones which don't we can keep quiet about it + init_targets( simulation::Memory, "memory cell", ( false == conditiontchecksmemcell ) ); + if( m_ignored ) { + // legacy compatibility behaviour, instead of disabling the event we disable the memory cell comparison test + m_conditions.flags &= ~( flags::text | flags::value_1 | flags::value_2 ); + m_ignored = false; + } + // conditional data + m_conditions.bind( &m_targets ); + m_conditions.init(); + // child events bindings + for( auto &childevent : m_children ) { + std::get( childevent ) = simulation::Events.FindEvent( std::get( childevent ) ); + if( std::get( childevent ) == nullptr ) { + ErrorLog( "Bad event: \"" + m_name + "\" (type: " + type() + ") can't find event \"" + std::get( childevent ) + "\"" ); + } + } +} + +// event type string +std::string +multi_event::type() const { + + return "multiple"; +} + +// deserialize() subclass details +void +multi_event::deserialize_( cParser &Input, scene::scratch_data &Scratchpad ) { + + m_conditions.has_else = false; + + std::string token; + while( ( true == Input.getTokens() ) + && ( false == ( token = Input.peek() ).empty() ) + && ( false == is_keyword( token ) ) ) { + + if( token == "condition" ) { + m_conditions.deserialize( Input ); + // NOTE: condition block comes last so we can bail out afterwards + break; + } + + else if( token == "else" ) { + // zmiana flagi dla słowa "else" + m_conditions.has_else = !m_conditions.has_else; + } + else { + // potentially valid event name + if( token.substr( 0, 5 ) != "none_" ) { + // eventy rozpoczynające się od "none_" są ignorowane + m_children.emplace_back( token, nullptr, ( m_conditions.has_else == false ) ); + } + else { + WriteLog( "Multi-event \"" + m_name + "\" ignored link to event \"" + token + "\"" ); + } + } + } +} + +// run() subclass details +void +multi_event::run_() { + + auto const conditiontest { m_conditions.test() }; + if( conditiontest + || m_conditions.has_else ) { + // warunek spelniony albo było użyte else + WriteLog( "Type: Multi-event" ); + for( auto &childwrapper : m_children ) { + auto *childevent { std::get( childwrapper ) }; + if( childevent == nullptr ) { continue; } + if( std::get( childwrapper ) != conditiontest ) { continue; } + + if( childevent != this ) { + // normalnie dodać + simulation::Events.AddToQuery( childevent, m_activator ); + } + else { + // jeśli ma być rekurencja to musi mieć sensowny okres powtarzania + if( m_delay >= 5.0 ) { + simulation::Events.AddToQuery( this, m_activator ); + } + } + } + if( Global.iMultiplayer ) { + // dajemy znać do serwera o wykonaniu + if( false == m_conditions.has_else ) { + // jednoznaczne tylko, gdy nie było else + if( m_activator ) { + multiplayer::WyslijEvent( m_name, m_activator->name() ); + } + else { + multiplayer::WyslijEvent( m_name, "" ); + } + } + } + } +} + +// export_as_text() subclass details +void +multi_event::export_as_text_( std::ostream &Output ) const { + + for( auto const &childevent : m_children ) { + if( true == std::get( childevent ) ) { + auto *childeventdata { std::get( childevent ) }; + Output + << ( childeventdata != nullptr ? + childeventdata->m_name : + std::get( childevent ) ) + << ' '; + } + } + // optional 'else' block + if( true == m_conditions.has_else ) { + Output << "else "; + for( auto const &childevent : m_children ) { + if( false == std::get( childevent ) ) { + auto *childeventdata{ std::get( childevent ) }; + Output + << ( childeventdata != nullptr ? + childeventdata->m_name : + std::get( childevent ) ) + << ' '; + } + } + } + + m_conditions.export_as_text( Output ); +} + + + +// prepares event for use +void +sound_event::init() { + // odtworzenie dźwięku + for( auto &target : m_sounds ) { + std::get( target ) = simulation::Sounds.find( std::get( target ) ); + if( std::get( target ) == nullptr ) { + m_ignored = true; // deaktywacja + ErrorLog( "Bad event: \"" + m_name + "\" (type: " + type() + ") can't find static sound \"" + std::get( target ) + "\"" ); + } + } +} + +// event type string +std::string +sound_event::type() const { + + return "sound"; +} + +// deserialize() subclass details +void +sound_event::deserialize_( cParser &Input, scene::scratch_data &Scratchpad ) { + + Input.getTokens(); + // playback mode, previously held in param 0 // 0: wylaczyc, 1: wlaczyc; -1: wlaczyc zapetlone + Input >> m_soundmode; + Input.getTokens(); + if( false == is_keyword( Input.peek() ) ) { + // optional parameter, radio channel to receive/broadcast the sound, previously held in param 1 + Input >> m_soundradiochannel; + Input.getTokens(); // preload next token + } +} + +// run() subclass details +void +sound_event::run_() { + + WriteLog( + "Type: Sound - [" + std::string( m_soundmode == 1 ? "play" : m_soundmode == -1 ? "loop" : "stop" ) + "]" + + ( m_soundradiochannel > 0 ? " [channel " + to_string( m_soundradiochannel ) + "]" : "" ) ); + for( auto &target : m_sounds ) { + auto *targetsound = std::get( target ); + if( targetsound == nullptr ) { continue; } + // event effect code + switch( m_soundmode ) { + // trzy możliwe przypadki: + case 0: { + targetsound->stop(); + break; + } + case 1: { + if( m_soundradiochannel > 0 ) { + simulation::radio_message( + targetsound, + m_soundradiochannel ); + } + else { + targetsound->play( sound_flags::exclusive | sound_flags::event ); + } + break; + } + case -1: { + targetsound->play( sound_flags::exclusive | sound_flags::looping | sound_flags::event ); + break; + } + default: { + break; + } + } + } +} + +// export_as_text() subclass details +void +sound_event::export_as_text_( std::ostream &Output ) const { + + // playback mode + Output << m_soundmode << ' '; + // optional radio channel + if( m_soundradiochannel > 0 ) { + Output << m_soundradiochannel << ' '; + } +} + +void +sound_event::deserialize_targets( std::string const &Input ) { + // sound objects don't inherit from scene node, so we can't use the same container + // TODO: fix this, having sounds as scene nodes (or a node wrapper for one) might have benefits elsewhere + cParser targetparser{ Input }; + std::string target; + while( false == ( target = targetparser.getToken( true, "|," ) ).empty() ) { + // actual bindings to targets of proper type are created during scenario initialization + if( target != "none" ) { + m_sounds.emplace_back( target, nullptr ); + } + } +} + + + +// destructor +animation_event::~animation_event() { + + if( m_animationtype == 4 ) { + // jeśli z pliku VMD + SafeDeleteArray( m_animationfiledata ); // zwolnić obszar + } +} + +// prepares event for use +void +animation_event::init() { + // animacja modelu + init_targets( simulation::Instances, "model instance" ); + // custom target initialization code + if( m_animationtype == 4 ) { + // vmd animations target whole model + return; + } + // locate and set up animated submodels + m_animationcontainers.clear(); + for( auto &target : m_targets ) { + auto *targetmodel { static_cast( std::get( target ) ) }; + if( targetmodel == nullptr ) { continue; } + auto *targetcontainer{ targetmodel->GetContainer( m_animationsubmodel ) }; + if( targetcontainer == nullptr ) { + m_ignored = true; + ErrorLog( "Bad event: \"" + m_name + "\" (type: " + type() + ") can't find submodel " + m_animationsubmodel + " in model instance \"" + targetmodel->name() + "\"" ); + break; + } + targetcontainer->WillBeAnimated(); // oflagowanie animacji + if( targetcontainer->Event() == nullptr ) { + // nie szukać, gdy znaleziony + targetcontainer->EventAssign( simulation::Events.FindEvent( targetmodel->name() + '.' + m_animationsubmodel + ":done" ) ); + } + m_animationcontainers.emplace_back( targetcontainer ); + } +} + +// event type string +std::string +animation_event::type() const { + + return "animation"; +} + +// deserialize() subclass details +void +animation_event::deserialize_( cParser &Input, scene::scratch_data &Scratchpad ) { + + std::string token; + + Input.getTokens(); + Input >> token; + if( token.compare( "rotate" ) == 0 ) { // obrót względem osi + Input.getTokens(); + // animation submodel, previously held in param 9 + Input >> m_animationsubmodel; + // animation type, previously held in param 0 + m_animationtype = 1; + Input.getTokens( 4 ); + // animation params, previously held in param 1, 2, 3, 4 + Input + >> m_animationparams[ 0 ] + >> m_animationparams[ 1 ] + >> m_animationparams[ 2 ] + >> m_animationparams[ 3 ]; + } + else if( token.compare( "translate" ) == 0 ) { // przesuw o wektor + Input.getTokens(); + // animation submodel, previously held in param 9 + Input >> m_animationsubmodel; + // animation type, previously held in param 0 + m_animationtype = 2; + Input.getTokens( 4 ); + // animation params, previously held in param 1, 2, 3, 4 + Input + >> m_animationparams[ 0 ] + >> m_animationparams[ 1 ] + >> m_animationparams[ 2 ] + >> m_animationparams[ 3 ]; + } + else if( token.compare( "digital" ) == 0 ) { // licznik cyfrowy + Input.getTokens(); + // animation submodel, previously held in param 9 + Input >> m_animationsubmodel; + // animation type, previously held in param 0 + m_animationtype = 8; + Input.getTokens( 4 ); + // animation params, previously held in param 1, 2, 3, 4 + Input + >> m_animationparams[ 0 ] + >> m_animationparams[ 1 ] + >> m_animationparams[ 2 ] + >> m_animationparams[ 3 ]; + } + else if( token.substr( token.length() - 4, 4 ) == ".vmd" ) // na razie tu, może będzie inaczej + { // animacja z pliku VMD + { + m_animationfilename = token; + std::ifstream file( szModelPath + m_animationfilename, std::ios::binary | std::ios::ate ); file.unsetf( std::ios::skipws ); + auto size = file.tellg(); // ios::ate already positioned us at the end of the file + file.seekg( 0, std::ios::beg ); // rewind the caret afterwards + // animation size, previously held in param 7 + m_animationfilesize = size; + // animation data, previously held in param 8 + m_animationfiledata = new char[ size ]; + file.read( m_animationfiledata, size ); // wczytanie pliku + } + Input.getTokens(); + // animation submodel, previously held in param 9 + Input >> m_animationsubmodel; + // animation type, previously held in param 0 + m_animationtype = 4; + Input.getTokens( 4 ); + // animation params, previously held in param 1, 2, 3, 4 + Input + >> m_animationparams[ 0 ] + >> m_animationparams[ 1 ] + >> m_animationparams[ 2 ] + >> m_animationparams[ 3 ]; + } + // preload next token + Input.getTokens(); +} + +// run() subclass details +void +animation_event::run_() { + + WriteLog( "Type: Animation" ); + if( m_animationtype == 4 ) { + // vmd mode targets the entire model + for( auto &target : m_targets ) { + auto *targetmodel = static_cast( std::get( target ) ); + if( targetmodel == nullptr ) { continue; } + // event effect code + targetmodel->AnimationVND( + m_animationfiledata, + m_animationparams[ 0 ], // tu mogą być dodatkowe parametry, np. od-do + m_animationparams[ 1 ], + m_animationparams[ 2 ], + m_animationparams[ 3 ] ); + } + } + else { + // other animation modes target specific submodels + for( auto *targetcontainer : m_animationcontainers ) { + switch( m_animationtype ) { + case 1: { // rotate + targetcontainer->SetRotateAnim( + glm::make_vec3( m_animationparams.data() ), + m_animationparams[ 3 ] ); + break; + } + case 2: { // translate + targetcontainer->SetTranslateAnim( + glm::make_vec3( m_animationparams.data() ), + m_animationparams[ 3 ] ); + break; + } + // TODO: implement digital mode + default: { + break; + } + } + } + } +} + +// export_as_text() subclass details +void +animation_event::export_as_text_( std::ostream &Output ) const { + + // animation type + Output << ( + m_animationtype == 1 ? "rotate" : + m_animationtype == 2 ? "translate" : + m_animationtype == 4 ? m_animationfilename : + m_animationtype == 8 ? "digital" : + "none" ) + << ' '; + // submodel + Output << m_animationsubmodel << ' '; + // animation parameters + Output + << m_animationparams[ 0 ] << ' ' + << m_animationparams[ 1 ] << ' ' + << m_animationparams[ 2 ] << ' ' + << m_animationparams[ 3 ] << ' '; +} + + + +// prepares event for use +void +lights_event::init() { + // zmiana świeteł modelu + init_targets( simulation::Instances, "model instance" ); +} + +// event type string +std::string +lights_event::type() const { + + return "lights"; +} + +// deserialize() subclass details +void +lights_event::deserialize_( cParser &Input, scene::scratch_data &Scratchpad ) { + + // TBD, TODO: remove light count limit? + auto const lightcountlimit { 8 }; + m_lights.resize( lightcountlimit ); + int lightidx { 0 }; + + std::string token; + while( ( true == Input.getTokens() ) + && ( false == ( token = Input.peek() ).empty() ) + && ( false == is_keyword( token ) ) ) { + + if( lightidx < lightcountlimit ) { + Input >> m_lights[ lightidx++ ]; + } + else { + ErrorLog( "Bad event: \"" + m_name + "\" (type: " + type() + ") with more than " + to_string( lightcountlimit ) + " parameters" ); + } + } + while( lightidx < lightcountlimit ) { + // HACK: mark unspecified lights with magic value + m_lights[ lightidx++ ] = -2.f; + } +} + +// run() subclass details +void +lights_event::run_() { + + for( auto &target : m_targets ) { + auto *targetmodel = static_cast( std::get( target ) ); + if( targetmodel == nullptr ) { continue; } + // event effect code + for( auto lightidx = 0; lightidx < iMaxNumLights; ++lightidx ) { + if( m_lights[ lightidx ] == -2.f ) { + // processed all supplied values, bail out + break; + } + if( m_lights[ lightidx ] >= 0.f ) { + // -1 zostawia bez zmiany + targetmodel->LightSet( + lightidx, + m_lights[ lightidx ] ); + } + } + } +} + +// export_as_text() subclass details +void +lights_event::export_as_text_( std::ostream &Output ) const { + + auto lightidx{ 0 }; + while( ( lightidx < iMaxNumLights ) + && ( m_lights[ lightidx ] > -2.0 ) ) { + Output << m_lights[ lightidx ] << ' '; + ++lightidx; + } +} + + + +// prepares event for use +void +switch_event::init() { + // przełożenie zwrotnicy albo zmiana stanu obrotnicy + init_targets( simulation::Paths, "track" ); + // custom target initialization code + for( auto &target : m_targets ) { + auto *targettrack = static_cast( std::get( target ) ); + if( targettrack == nullptr ) { continue; } + // dowiązanie toru + if( targettrack->iAction == 0 ) { + // jeśli nie jest zwrotnicą ani obrotnicą to będzie się zmieniał stan uszkodzenia + targettrack->iAction |= 0x100; + } + if( ( m_switchstate == 0 ) + && ( m_switchmovedelay >= 0.0 ) ) { + // jeśli przełącza do stanu 0 & jeśli jest zdefiniowany dodatkowy ruch iglic + // przesłanie parametrów + targettrack->Switch( + m_switchstate, + m_switchmoverate, + m_switchmovedelay ); + } + } +} + +// event type string +std::string +switch_event::type() const { + + return "switch"; +} + +// deserialize() subclass details +void +switch_event::deserialize_( cParser &Input, scene::scratch_data &Scratchpad ) { + + Input.getTokens(); + // switch state, previously held in param 0 + Input >> m_switchstate; + Input.getTokens(); + if( false == is_keyword( Input.peek() ) ) { + // prędkość liniowa ruchu iglic + // previously held in param 1 + Input >> m_switchmoverate; + Input.getTokens(); + } + if( false == is_keyword( Input.peek() ) ) { + // dodatkowy ruch drugiej iglicy (zamknięcie nastawnicze) + // previously held in param 2 + Input >> m_switchmovedelay; + Input.getTokens(); + } +} + +// run() subclass details +void +switch_event::run_() { + + for( auto &target : m_targets ) { + auto *targettrack { static_cast( std::get( target ) ) }; + if( targettrack == nullptr ) { continue; } + // event effect code + targettrack->Switch( + m_switchstate, + m_switchmoverate, + m_switchmovedelay ); + } + if( Global.iMultiplayer ) { + // dajemy znać do serwera o przełożeniu + multiplayer::WyslijEvent( m_name, "" ); // wysłanie nazwy eventu przełączajacego + } + // Ra: bardziej by się przydała nazwa toru, ale nie ma do niej stąd dostępu +} + +// export_as_text() subclass details +void +switch_event::export_as_text_( std::ostream &Output ) const { + + Output << m_switchstate << ' '; + if( ( m_switchmoverate < 0.f ) + || ( m_switchmovedelay < 0.f ) ) { + Output << m_switchmoverate << ' '; + } + if( m_switchmovedelay < 0.f ) { + Output << m_switchmovedelay << ' '; + } +} + + + +// prepares event for use +void +track_event::init() { + // ustawienie prędkości na torze + init_targets( simulation::Paths, "track" ); + // custom target initialization code + for( auto &target : m_targets ) { + auto *targettrack = static_cast( std::get( target ) ); + if( targettrack == nullptr ) { continue; } + // flaga zmiany prędkości toru jest istotna dla skanowania + targettrack->iAction |= 0x200; + } +} + +// event type string +std::string +track_event::type() const { + + return "trackvel"; +} + +// deserialize() subclass details +void +track_event::deserialize_( cParser &Input, scene::scratch_data &Scratchpad ) { + + Input.getTokens(); + Input >> m_velocity; + // preload next token + Input.getTokens(); +} + +// run() subclass details +void +track_event::run_() { + + WriteLog( "Type: TrackVel - [" + to_string( m_velocity, 2 ) + "]" ); + for( auto &target : m_targets ) { + auto *targettrack = static_cast( std::get( target ) ); + if( targettrack == nullptr ) { continue; } + // event effect code + targettrack->VelocitySet( m_velocity ); + if( DebugModeFlag ) { + WriteLog( "actual track velocity for " + targettrack->name() + " [" + to_string( targettrack->VelocityGet(), 2 ) + "]" ); + } + } +} + +// export_as_text() subclass details +void +track_event::export_as_text_( std::ostream &Output ) const { + + Output << m_velocity << ' '; +} + + + +// prepares event for use +void +voltage_event::init() { + // zmiana napięcia w zasilaczu (TractionPowerSource) + init_targets( simulation::Powergrid, "power source" ); +} + +// event type string +std::string +voltage_event::type() const { + + return "voltage"; +} + +// deserialize() subclass details +void +voltage_event::deserialize_( cParser &Input, scene::scratch_data &Scratchpad ) { + // zmiana napięcia w zasilaczu (TractionPowerSource) + Input.getTokens(); + Input >> m_voltage; + // preload next token + Input.getTokens(); +} + +// run() subclass details +void +voltage_event::run_() { + // zmiana napięcia w zasilaczu (TractionPowerSource) + WriteLog( "Type: Voltage [" + to_string( m_voltage, 2 ) + "]" ); + for( auto &target : m_targets ) { + auto *targetpowersource = static_cast( std::get( target ) ); + if( targetpowersource == nullptr ) { continue; } + // na razie takie chamskie ustawienie napięcia zasilania + targetpowersource->VoltageSet( m_voltage ); + } +} + +// export_as_text() subclass details +void +voltage_event::export_as_text_( std::ostream &Output ) const { + + Output << m_voltage << ' '; +} + + + +// prepares event for use +void +visible_event::init() { + // ukrycie albo przywrócenie obiektu + for( auto &target : m_targets ) { + auto &targetnode{ std::get( target ) }; + auto &targetname{ std::get( target ) }; + // najpierw model + targetnode = simulation::Instances.find( targetname ); + if( targetnode == nullptr ) { + // albo tory? + targetnode = simulation::Paths.find( targetname ); + } + if( targetnode == nullptr ) { + // może druty? + targetnode = simulation::Traction.find( targetname ); + } + if( targetnode == nullptr ) { + m_ignored = true; // deaktywacja + ErrorLog( "Bad event: \"" + m_name + "\" (type: " + type() + ") can't find item \"" + std::get( target ) + "\"" ); + } + } +} + +// event type string +std::string +visible_event::type() const { + + return "visible"; +} + +// deserialize() subclass details +void +visible_event::deserialize_( cParser &Input, scene::scratch_data &Scratchpad ) { + // zmiana wyświetlania obiektu + Input.getTokens(); + Input >> m_visible; + // preload next token + Input.getTokens(); +} + +// run() subclass details +void +visible_event::run_() { + + for( auto &target : m_targets ) { + auto *targetnode = std::get( target ); + if( targetnode == nullptr ) { continue; } + // event effect code + targetnode->visible( m_visible ); + } +} + +// export_as_text() subclass details +void +visible_event::export_as_text_( std::ostream &Output ) const { + + Output << ( m_visible ? 1 : 0 ) << ' '; +} + + + +// prepares event for use +void +friction_event::init() { + // nothing to do here +} + +// event type string +std::string +friction_event::type() const { + + return "friction"; +} + +// deserialize() subclass details +void +friction_event::deserialize_( cParser &Input, scene::scratch_data &Scratchpad ) { + // zmiana przyczepnosci na scenerii + Input.getTokens(); + Input >> m_friction; + // preload next token + Input.getTokens(); +} + +// run() subclass details +void +friction_event::run_() { + // zmiana tarcia na scenerii + WriteLog( "Type: Friction" ); + Global.fFriction = ( m_friction ); +} + +// export_as_text() subclass details +void +friction_event::export_as_text_( std::ostream &Output ) const { + + Output << m_friction << ' '; +} + + + +// prepares event for use +void +message_event::init() { + // nothing to do here +} + +// event type string +std::string +message_event::type() const { + + return "message"; +} + +// deserialize() subclass details +void +message_event::deserialize_( cParser &Input, scene::scratch_data &Scratchpad ) { + // wyświetlenie komunikatu + std::string token; + while( ( true == Input.getTokens() ) + && ( false == ( token = Input.peek() ).empty() ) + && ( false == is_keyword( token ) ) ) { + m_message += ( m_message.empty() ? "" : " " ) + token; + } +} + +// run() subclass details +void +message_event::run_() { + // TODO: implement +} + +// export_as_text() subclass details +void +message_event::export_as_text_( std::ostream &Output ) const { + + Output << '\"' << m_message << '\"' << ' '; } //--------------------------------------------------------------------------- -string TEvent::CommandGet() -{ // odczytanie komendy z eventu - switch (Type) - { // to się wykonuje również składu jadącego bez obsługi - case tp_GetValues: - return string(Params[9].asMemCell->Text()); - case tp_PutValues: - return string(Params[0].asText); +basic_event * +make_event( cParser &Input, scene::scratch_data &Scratchpad ) { + + auto const name = ToLower( Input.getToken() ); + auto const type = Input.getToken(); + + basic_event *event { nullptr }; + + if( type == "addvalues" ) { event = new updatevalues_event(); } + else if( type == "updatevalues" ) { event = new updatevalues_event(); } + else if( type == "copyvalues" ) { event = new copyvalues_event(); } + else if( type == "getvalues" ) { event = new getvalues_event(); } + else if( type == "putvalues" ) { event = new putvalues_event(); } + else if( type == "whois" ) { event = new whois_event(); } + else if( type == "logvalues" ) { event = new logvalues_event(); } + else if( type == "multiple" ) { event = new multi_event(); } + else if( type == "switch" ) { event = new switch_event(); } + else if( type == "trackvel" ) { event = new track_event(); } + else if( type == "sound" ) { event = new sound_event(); } + else if( type == "animation" ) { event = new animation_event(); } + else if( type == "lights" ) { event = new lights_event(); } + else if( type == "voltage" ) { event = new voltage_event(); } + else if( type == "visible" ) { event = new visible_event(); } + else if( type == "friction" ) { event = new friction_event(); } + else if( type == "message" ) { event = new message_event(); } + + if( event == nullptr ) { + WriteLog( "Bad event: unrecognized type \"" + type + "\" specified for event \"" + name + "\"." ); + return event; } - return ""; // inne eventy się nie liczą -}; -TCommandType TEvent::Command() -{ // odczytanie komendy z eventu - switch (Type) - { // to się wykonuje również dla składu jadącego bez obsługi - case tp_GetValues: - return Params[9].asMemCell->Command(); - case tp_PutValues: - return Params[6].asCommand; // komenda zakodowana binarnie + event->m_name = name; + if( type == "addvalues" ) { + static_cast( event )->m_input.flags = basic_event::flags::mode_add; } - return cm_Unknown; // inne eventy się nie liczą -}; + return event; +} -double TEvent::ValueGet(int n) -{ // odczytanie komendy z eventu - n &= 1; // tylko 1 albo 2 jest prawidłowy - switch (Type) - { // to się wykonuje również składu jadącego bez obsługi - case tp_GetValues: - return n ? Params[9].asMemCell->Value1() : Params[9].asMemCell->Value2(); - case tp_PutValues: - return Params[2 - n].asdouble; +//--------------------------------------------------------------------------- + +event_manager::~event_manager() { + + for( auto *event : m_events ) { + delete event; } - return 0.0; // inne eventy się nie liczą -}; +} -vector3 TEvent::PositionGet() -{ // pobranie współrzędnych eventu - switch (Type) - { // - case tp_GetValues: - return Params[9].asMemCell->Position(); // współrzędne podłączonej komórki pamięci - case tp_PutValues: - return vector3(Params[3].asdouble, Params[4].asdouble, Params[5].asdouble); +// adds specified event launcher to the list of global launchers +void +event_manager::queue( TEventLauncher *Launcher ) { + + m_launcherqueue.emplace_back( Launcher ); +} + +// legacy method, updates event queues +void +event_manager::update() { + + // process currently queued events + CheckQuery(); + // test list of global events for possible new additions to the queue + for( auto *launcher : m_launcherqueue ) { + + if( true == ( launcher->check_activation() && launcher->check_conditions() ) ) { + // NOTE: we're presuming global events aren't going to use event2 + WriteLog( "Eventlauncher " + launcher->name() ); + if( launcher->Event1 ) { + AddToQuery( launcher->Event1, nullptr ); + } + } } - return vector3(0, 0, 0); // inne eventy się nie liczą -}; +} -bool TEvent::StopCommand() -{ // - if (Type == tp_GetValues) - return Params[9].asMemCell->StopCommand(); // info o komendzie z komórki - return false; -}; +// adds provided event to the collection. returns: true on success +// TBD, TODO: return handle instead of pointer +bool +event_manager::insert( basic_event *Event ) { + // najpierw sprawdzamy, czy nie ma, a potem dopisujemy + auto lookup = m_eventmap.find( Event->m_name ); + if( lookup != m_eventmap.end() ) { + // duplicate of already existing event + auto const size = Event->m_name.size(); + // zawsze jeden znak co najmniej jest + if( Event->m_name[ 0 ] == '#' ) { + // utylizacja duplikatu z krzyżykiem + return false; + } + // tymczasowo wyjątki: + else if( ( size > 8 ) + && ( Event->m_name.substr( 0, 9 ) == "lineinfo:" ) ) { + // tymczasowa utylizacja duplikatów W5 + return false; + } + else if( ( size > 8 ) + && ( Event->m_name.substr( size - 8 ) == "_warning" ) ) { + // tymczasowa utylizacja duplikatu z trąbieniem + return false; + } + else if( ( size > 4 ) + && ( Event->m_name.substr( size - 4 ) == "_shp" ) ) { + // nie podlegają logowaniu + // tymczasowa utylizacja duplikatu SHP + return false; + } -void TEvent::StopCommandSent() -{ - if (Type == tp_GetValues) - Params[9].asMemCell->StopCommandSent(); // komenda z komórki została wysłana -}; - -void TEvent::Append(TEvent *e) -{ // doczepienie kolejnych z tą samą nazwą - if (evJoined) - evJoined->Append(e); // rekurencja! - góra kilkanaście eventów będzie potrzebne - else - { - evJoined = e; - e->bEnabled = true; // ten doczepiony może być tylko kolejkowany + auto *duplicate = m_events[ lookup->second ]; + if( Global.bJoinEvents ) { + // doczepka (taki wirtualny multiple bez warunków) + duplicate->append( Event ); + } + else { + // NOTE: somewhat convoluted way to deal with 'replacing' events without leaving dangling pointers + // can be cleaned up if pointers to events were replaced with handles + ErrorLog( "Bad scenario: duplicate event name \"" + Event->m_name + "\"" ); + duplicate->append( Event ); // doczepka (taki wirtualny multiple bez warunków) + duplicate->m_ignored = true; // dezaktywacja pierwotnego - taka proteza na wsteczną zgodność + } } -}; + + m_events.emplace_back( Event ); + if( lookup == m_eventmap.end() ) { + // if it's first event with such name, it's potential candidate for the execution queue + m_eventmap.emplace( Event->m_name, m_events.size() - 1 ); + if( ( Event->m_ignored != true ) + && ( Event->m_name.find( "onstart" ) != std::string::npos ) ) { + // event uruchamiany automatycznie po starcie + AddToQuery( Event, nullptr ); + } + } + + return true; +} + +// legacy method, returns pointer to specified event, or null +basic_event * +event_manager::FindEvent( std::string const &Name ) { + + if( Name.empty() ) { return nullptr; } + + auto const lookup = m_eventmap.find( Name ); + return ( + lookup != m_eventmap.end() ? + m_events[ lookup->second ] : + nullptr ); +} + +// legacy method, inserts specified event in the event query +bool +event_manager::AddToQuery( basic_event *Event, TDynamicObject const *Owner ) { + + if( Event->m_passive ) { return false; } // jeśli może być dodany do kolejki (nie używany w skanowaniu) + if( Event->m_inqueue > 0 ) { return false; } // jeśli nie dodany jeszcze do kolejki + + // kolejka eventów jest posortowana względem (fStartTime) + Event->m_activator = Owner; + if( Event->is_instant() ) { + // eventy AddValues trzeba wykonywać natychmiastowo, inaczej kolejka może zgubić jakieś dodawanie + if( false == Event->m_ignored ) { + Event->run(); + } + // jeśli jest kolejny o takiej samej nazwie, to idzie do kolejki (and if there's no joint event it'll be set to null and processing will end here) + do { + Event = Event->m_sibling; + // NOTE: we could've received a new event from joint event above, so we need to check conditions just in case and discard the bad events + // TODO: refactor this arrangement, it's hardly optimal + } while( ( Event != nullptr ) + && ( ( Event->m_passive ) + || ( Event->m_inqueue > 0 ) ) ); + } + if( ( Event != nullptr ) + && ( false == Event->m_ignored ) ) { + // standardowe dodanie do kolejki + ++(Event->m_inqueue); // zabezpieczenie przed podwójnym dodaniem do kolejki + WriteLog( "EVENT ADDED TO QUEUE" + ( Owner ? ( " by " + Owner->asName ) : "" ) + ": " + Event->m_name ); + Event->m_launchtime = std::abs( Event->m_delay ) + Timer::GetTime(); // czas od uruchomienia scenerii + if( Event->m_delayrandom > 0.0 ) { + // doliczenie losowego czasu opóźnienia + Event->m_launchtime += Event->m_delayrandom * Random(); + } + if( QueryRootEvent != nullptr ) { + basic_event *target { QueryRootEvent }; + basic_event *previous { nullptr }; + while( ( Event->m_launchtime >= target->m_launchtime ) + && ( target->m_next != nullptr ) ) { + previous = target; + target = target->m_next; + } + // the new event will be either before or after the one we located + if( Event->m_launchtime >= target->m_launchtime ) { + assert( target->m_next == nullptr ); + target->m_next = Event; + // if we have resurrected event land at the end of list, the link from previous run could potentially "add" unwanted events to the queue + Event->m_next = nullptr; + } + else { + if( previous != nullptr ) { + previous->m_next = Event; + Event->m_next = target; + } + else { + // special case, we're inserting our event at the very start + Event->m_next = QueryRootEvent; + QueryRootEvent = Event; + } + } + } + else { + QueryRootEvent = Event; + QueryRootEvent->m_next = nullptr; + } + } + + return true; +} + +// legacy method, executes queued events +bool +event_manager::CheckQuery() { + + while( ( QueryRootEvent != nullptr ) + && ( QueryRootEvent->m_launchtime < Timer::GetTime() ) ) + { // eventy są posortowana wg czasu wykonania + m_workevent = QueryRootEvent; // wyjęcie eventu z kolejki + if (QueryRootEvent->m_sibling) // jeśli jest kolejny o takiej samej nazwie + { // to teraz on będzie następny do wykonania + QueryRootEvent = QueryRootEvent->m_sibling; // następny będzie ten doczepiony + QueryRootEvent->m_next = m_workevent->m_next; // pamiętając o następnym z kolejki + QueryRootEvent->m_launchtime = m_workevent->m_launchtime; // czas musi być ten sam, bo nie jest aktualizowany + QueryRootEvent->m_activator = m_workevent->m_activator; // pojazd aktywujący + QueryRootEvent->m_inqueue = 1; + // w sumie można by go dodać normalnie do kolejki, ale trzeba te połączone posortować wg czasu wykonania + } + else // a jak nazwa jest unikalna, to kolejka idzie dalej + QueryRootEvent = QueryRootEvent->m_next; // NULL w skrajnym przypadku + if( ( false == m_workevent->m_ignored ) && ( false == m_workevent->m_passive ) ) { + // w zasadzie te wyłączone są skanowane i nie powinny się nigdy w kolejce znaleźć + --(m_workevent->m_inqueue); // teraz moze być ponownie dodany do kolejki + m_workevent->run(); + } // if (tmpEvent->bEnabled) + } // while + return true; +} + +// legacy method, initializes events after deserialization from scenario file +void +event_manager::InitEvents() { + //łączenie eventów z pozostałymi obiektami + for( auto *event : m_events ) { + event->init(); + if( event->m_delay < 0 ) { AddToQuery( event, nullptr ); } + } +} + +// legacy method, initializes event launchers after deserialization from scenario file +void +event_manager::InitLaunchers() { + + for( auto *launcher : m_launchers.sequence() ) { + + if( launcher->iCheckMask != 0 ) { + if( launcher->asMemCellName != "none" ) { + // jeśli jest powiązana komórka pamięci + launcher->MemCell = simulation::Memory.find( launcher->asMemCellName ); + if( launcher->MemCell == nullptr ) { + ErrorLog( "Bad scenario: event launcher \"" + launcher->name() + "\" can't find memcell \"" + launcher->asMemCellName + "\"" ); + } + } + else { + launcher->MemCell = nullptr; + } + } + + if( launcher->asEvent1Name != "none" ) { + launcher->Event1 = simulation::Events.FindEvent( launcher->asEvent1Name ); + if( launcher->Event1 == nullptr ) { + ErrorLog( "Bad scenario: event launcher \"" + launcher->name() + "\" can't find event \"" + launcher->asEvent1Name + "\"" ); + } + } + + if( launcher->asEvent2Name != "none" ) { + launcher->Event2 = simulation::Events.FindEvent( launcher->asEvent2Name ); + if( launcher->Event2 == nullptr ) { + ErrorLog( "Bad scenario: event launcher \"" + launcher->name() + "\" can't find event \"" + launcher->asEvent2Name + "\"" ); + } + } + } +} + +// sends basic content of the class in legacy (text) format to provided stream +void +event_manager::export_as_text( std::ostream &Output ) const { + + Output << "// events\n"; + for( auto const *event : m_events ) { + if( event->group() == null_handle ) { + event->export_as_text( Output ); + } + } + Output << "// event launchers\n"; + for( auto const *launcher : m_launchers.sequence() ) { + if( launcher->group() == null_handle ) { + launcher->export_as_text( Output ); + } + } +} diff --git a/Event.h b/Event.h index 110e3abc..d32c0381 100644 --- a/Event.h +++ b/Event.h @@ -9,110 +9,634 @@ http://mozilla.org/MPL/2.0/. #pragma once -#include -#include "dumb3d.h" -#include "Classes.h" +#include "classes.h" +#include "scene.h" +#include "names.h" +#include "evlaunch.h" -using namespace Math3D; +// common event interface +class basic_event { -typedef enum -{ - tp_Unknown, - tp_Sound, - tp_SoundPos, - tp_Exit, - tp_Disable, - tp_Velocity, - tp_Animation, - tp_Lights, - tp_UpdateValues, - tp_GetValues, - tp_PutValues, - tp_Switch, - tp_DynVel, - tp_TrackVel, - tp_Multiple, - tp_AddValues, - tp_Ignored, - tp_CopyValues, - tp_WhoIs, - tp_LogValues, - tp_Visible, - tp_Voltage, - tp_Message, - tp_Friction -} TEventType; +public: +// types + enum flags { + // shared values + text = 1 << 0, + value_1 = 1 << 1, + value_2 = 1 << 2, + // update values + load = 1 << 3, + mode_add = 1 << 4, + // condition values + track_busy = 1 << 3, + track_free = 1 << 4, + probability = 1 << 5 + }; +// constructor + basic_event() = default; +// destructor + virtual ~basic_event(); +// methods + // restores event data from provided stream + virtual + void + deserialize( cParser &Input, scene::scratch_data &Scratchpad ); + // prepares event for use + virtual + void + init() = 0; + // executes event + virtual + void + run(); + // sends basic content of the class in legacy (text) format to provided stream + virtual + void + export_as_text( std::ostream &Output ) const; + // adds a sibling event executed together + void + append( basic_event *Event ); + // returns: true if the event should be executed immediately + virtual + bool + is_instant() const; + // sends content of associated data cell to specified vehicle controller + virtual + void + send_command( TController &Controller ); + // returns: true if associated data cell contains a command for vehicle controller + virtual + bool + is_command() const; + // input data access + virtual std::string input_text() const; + virtual TCommandType input_command() const; + virtual double input_value( int Index ) const; + virtual glm::dvec3 input_location() const; + void group( scene::group_handle Group ); + scene::group_handle group() const; +// members + basic_event *m_next { nullptr }; // następny w kolejce // TODO: replace with event list in the manager + basic_event *m_sibling { nullptr }; // kolejny event z tą samą nazwą - od wersji 378 + std::string m_name; + bool m_ignored { false }; // replacement for tp_ignored + bool m_passive { false }; // false gdy ma nie być dodawany do kolejki (skanowanie sygnałów) + int m_inqueue { 0 }; // ile razy dodany do kolejki + TDynamicObject const *m_activator { nullptr }; + double m_launchtime { 0.0 }; + double m_delay { 0.0 }; + double m_delayrandom { 0.0 }; // zakres dodatkowego opóźnienia // standardowo nie będzie dodatkowego losowego opóźnienia -const int update_memstring = 0x0000001; // zmodyfikować tekst (UpdateValues) -const int update_memval1 = 0x0000002; // zmodyfikować pierwszą wartosć -const int update_memval2 = 0x0000004; // zmodyfikować drugą wartosć -const int update_memadd = 0x0000008; // dodać do poprzedniej zawartości -const int update_load = 0x0000010; // odczytać ładunek -const int update_only = 0x00000FF; // wartość graniczna -const int conditional_memstring = 0x0000100; // porównanie tekstu -const int conditional_memval1 = 0x0000200; // porównanie pierwszej wartości liczbowej -const int conditional_memval2 = 0x0000400; // porównanie drugiej wartości -const int conditional_else = 0x0010000; // flaga odwrócenia warunku (przesuwana bitowo) -const int conditional_anyelse = 0x0FF0000; // do sprawdzania, czy są odwrócone warunki -const int conditional_trackoccupied = 0x1000000; // jeśli tor zajęty -const int conditional_trackfree = 0x2000000; // jeśli tor wolny -const int conditional_propability = 0x4000000; // zależnie od generatora lizcb losowych -const int conditional_memcompare = 0x8000000; // porównanie zawartości +protected: +// types + using basic_node = std::tuple; + using node_sequence = std::vector; -union TParam -{ - void *asPointer; - TMemCell *asMemCell; - TGroundNode *nGroundNode; - TTrack *asTrack; - TAnimModel *asModel; - TAnimContainer *asAnimContainer; - TTrain *asTrain; - TDynamicObject *asDynamic; - TEvent *asEvent; - bool asBool; - double asdouble; - int asInt; - TTextSound *tsTextSound; - char *asText; - TCommandType asCommand; - TTractionPowerSource *psPower; + struct event_conditions { + unsigned int flags { 0 }; + float probability { 0.0 }; // used by conditional_probability + double match_value_1 { 0.0 }; // used by conditional_memcompare + double match_value_2 { 0.0 }; // used by conditional_memcompare + std::string match_text; // used by conditional_memcompare + basic_event::node_sequence *cells; // used by conditional_memcompare + std::vector tracks; // used by conditional_track + bool has_else { false }; + + void deserialize( cParser &Input ); + void bind( basic_event::node_sequence *Nodes ); + void init(); + // verifies whether event meets execution condition(s) + bool test() const; + // sends basic content of the class in legacy (text) format to provided stream + void export_as_text( std::ostream &Output ) const; + }; +// methods + template + void init_targets( TableType_ &Repository, std::string const &Targettype, bool const Logerrors = true ); + // returns true if provided token is a an event desription keyword, false otherwise + static bool is_keyword( std::string const &Token ); + +// members + node_sequence m_targets; // targets of operation performed when this event is executed + +private: +// methods + // event type string + virtual std::string type() const = 0; + // deserialization helper, converts provided string to a list of target nodes + virtual void deserialize_targets( std::string const &Input ); + // deserialize() subclass details + virtual void deserialize_( cParser &Input, scene::scratch_data &Scratchpad ) = 0; + // run() subclass details + virtual void run_() = 0; + // export_as_text() subclass details + virtual void export_as_text_( std::ostream &Output ) const = 0; +// members + scene::group_handle m_group { null_handle }; // group this event belongs to, if any }; -class TEvent // zmienne: ev* -{ // zdarzenie - private: - void Conditions(cParser *parser, std::string s); - public: - std::string asName; - bool bEnabled = false; // false gdy ma nie być dodawany do kolejki (skanowanie sygnałów) - int iQueued = 0; // ile razy dodany do kolejki - // bool bIsHistory; - TEvent *evNext = nullptr; // następny w kolejce - TEvent *evNext2 = nullptr; - TEventType Type = tp_Unknown; - double fStartTime = 0.0; - double fDelay = 0.0; - TDynamicObject *Activator = nullptr; - TParam Params[13]; // McZapkie-070502 //Ra: zamienić to na union/struct - unsigned int iFlags = 0; // zamiast Params[8] z flagami warunku - std::string asNodeName; // McZapkie-100302 - dodalem zeby zapamietac nazwe toru - TEvent *evJoined = nullptr; // kolejny event z tą samą nazwą - od wersji 378 - double fRandomDelay = 0.0; // zakres dodatkowego opóźnienia // standardowo nie będzie dodatkowego losowego opóźnienia - public: // metody - TEvent(std::string const &m = ""); - ~TEvent(); - void Init(); - void Load(cParser *parser, vector3 *org); - void AddToQuery(TEvent *e); - std::string CommandGet(); - TCommandType Command(); - double ValueGet(int n); - vector3 PositionGet(); - bool StopCommand(); - void StopCommandSent(); - void Append(TEvent *e); + +// specialized event, sends received input to its target(s) +// TBD: replace the generic module with specialized mixins +class input_event : public basic_event { + + friend basic_event * make_event( cParser &Input, scene::scratch_data &Scratchpad ); + +protected: +// types + struct input_data { + unsigned int flags { 0 }; + std::string data_text; + double data_value_1 { 0.0 }; + double data_value_2 { 0.0 }; + basic_node data_source { "", nullptr }; + glm::dvec3 location { 0.0 }; + TCommandType command_type { TCommandType::cm_Unknown }; + + TMemCell const * data_cell() const; + TMemCell * data_cell(); + }; + +// members + input_data m_input; }; + + +class updatevalues_event : public input_event { + +public: +// methods + // prepares event for use + void init() override; + // returns: true if the event should be executed immediately + bool is_instant() const override; + +private: +// methods + // event type string + std::string type() const override; + // deserialize() subclass details + void deserialize_( cParser &Input, scene::scratch_data &Scratchpad ) override; + // run() subclass details + void run_() override; + // export_as_text() subclass details + void export_as_text_( std::ostream &Output ) const override; +// members + event_conditions m_conditions; +}; + + + +class copyvalues_event : public input_event { + +public: +// methods + // prepares event for use + void init() override; + +private: +// methods + // event type string + std::string type() const override; + // deserialize() subclass details + void deserialize_( cParser &Input, scene::scratch_data &Scratchpad ) override; + // run() subclass details + void run_() override; + // export_as_text() subclass details + void export_as_text_( std::ostream &Output ) const override; +}; + + + +class getvalues_event : public input_event { + +public: +// methods + // prepares event for use + void init() override; + // sends content of associated data cell to specified vehicle controller + void send_command( TController &Controller ) override; + // returns: true if associated data cell contains a command for vehicle controller + bool is_command() const override; + // input data access + std::string input_text() const override; + TCommandType input_command() const override; + double input_value( int Index ) const override; + glm::dvec3 input_location() const override; + +private: +// methods + // event type string + std::string type() const override; + // deserialize() subclass details + void deserialize_( cParser &Input, scene::scratch_data &Scratchpad ) override; + // run() subclass details + void run_() override; + // export_as_text() subclass details + void export_as_text_( std::ostream &Output ) const override; +}; + + + +class putvalues_event : public input_event { + +public: +// methods + // prepares event for use + void init() override; + // input data access + std::string input_text() const override; + TCommandType input_command() const override; + double input_value( int Index ) const override; + glm::dvec3 input_location() const override; + +private: +// methods + // event type string + std::string type() const override; + // deserialize() subclass details + void deserialize_( cParser &Input, scene::scratch_data &Scratchpad ) override; + // run() subclass details + void run_() override; + // export_as_text() subclass details + void export_as_text_( std::ostream &Output ) const override; +}; + + + +class whois_event : public input_event { + +public: +// methods + // prepares event for use + void init() override; + +private: +// methods + // event type string + std::string type() const override; + // deserialize() subclass details + void deserialize_( cParser &Input, scene::scratch_data &Scratchpad ) override; + // run() subclass details + void run_() override; + // export_as_text() subclass details + void export_as_text_( std::ostream &Output ) const override; +}; + + + +class logvalues_event : public basic_event { + +public: +// methods + // prepares event for use + void init() override; + +private: +// methods + // event type string + std::string type() const override; + // deserialize() subclass details + void deserialize_( cParser &Input, scene::scratch_data &Scratchpad ) override; + // run() subclass details + void run_() override; + // export_as_text() subclass details + void export_as_text_( std::ostream &Output ) const override; +}; + + + +class multi_event : public basic_event { + +public: +// methods + // prepares event for use + void init() override; + +private: +// types + // wrapper for binding between editor-supplied name, event, and execution conditional flag + using conditional_event = std::tuple; +// methods + // event type string + std::string type() const override; + // deserialize() subclass details + void deserialize_( cParser &Input, scene::scratch_data &Scratchpad ) override; + // run() subclass details + void run_() override; + // export_as_text() subclass details + void export_as_text_( std::ostream &Output ) const override; +// members + std::vector m_children; // events which are placed in the query when this event is executed + event_conditions m_conditions; +}; + +class sound_event : public basic_event { + +public: +// methods + // prepares event for use + void init() override; + +private: +// types + // wrapper for binding between editor-supplied name and sound object + using basic_sound = std::tuple; +// methods + // event type string + std::string type() const override; + // deserialization helper, converts provided string to a list of target nodes + void deserialize_targets( std::string const &Input ) override; + // deserialize() subclass details + void deserialize_( cParser &Input, scene::scratch_data &Scratchpad ) override; + // run() subclass details + void run_() override; + // export_as_text() subclass details + void export_as_text_( std::ostream &Output ) const override; +// members + std::vector m_sounds; + int m_soundmode{ 0 }; + int m_soundradiochannel{ 0 }; +}; + +class animation_event : public basic_event { + +public: +// destuctor + ~animation_event() override; +// methods + // prepares event for use + void init() override; + +private: +// methods + // event type string + std::string type() const override; + // deserialize() subclass details + void deserialize_( cParser &Input, scene::scratch_data &Scratchpad ) override; + // run() subclass details + void run_() override; + // export_as_text() subclass details + void export_as_text_( std::ostream &Output ) const override; +// members + int m_animationtype{ 0 }; + std::array m_animationparams{ 0.0 }; + std::string m_animationsubmodel; + std::vector m_animationcontainers; + std::string m_animationfilename; + std::size_t m_animationfilesize{ 0 }; + char *m_animationfiledata{ nullptr }; +}; + +class lights_event : public basic_event { + +public: +// methods + // prepares event for use + void init() override; + +private: +// methods + // event type string + std::string type() const override; + // deserialize() subclass details + void deserialize_( cParser &Input, scene::scratch_data &Scratchpad ) override; + // run() subclass details + void run_() override; + // export_as_text() subclass details + void export_as_text_( std::ostream &Output ) const override; +// members + std::vector m_lights; +}; + +class switch_event : public basic_event { + +public: +// methods + // prepares event for use + void init() override; + +private: +// methods + // event type string + std::string type() const override; + // deserialize() subclass details + void deserialize_( cParser &Input, scene::scratch_data &Scratchpad ) override; + // run() subclass details + void run_() override; + // export_as_text() subclass details + void export_as_text_( std::ostream &Output ) const override; +// members + int m_switchstate{ 0 }; + float m_switchmoverate{ -1.f }; + float m_switchmovedelay{ -1.f }; +}; + +class track_event : public basic_event { + +public: +// methods + // prepares event for use + void init() override; + +private: +// methods + // event type string + std::string type() const override; + // deserialize() subclass details + void deserialize_( cParser &Input, scene::scratch_data &Scratchpad ) override; + // run() subclass details + void run_() override; + // export_as_text() subclass details + void export_as_text_( std::ostream &Output ) const override; +// members + float m_velocity{ 0.f }; +}; + +class voltage_event : public basic_event { + +public: +// methods + // prepares event for use + void init() override; + +private: +// methods + // event type string + std::string type() const override; + // deserialize() subclass details + void deserialize_( cParser &Input, scene::scratch_data &Scratchpad ) override; + // run() subclass details + void run_() override; + // export_as_text() subclass details + void export_as_text_( std::ostream &Output ) const override; +// members + float m_voltage{ -1.f }; +}; + +class visible_event : public basic_event { + +public: +// methods + // prepares event for use + void init() override; + +private: +// methods + // event type string + std::string type() const override; + // deserialize() subclass details + void deserialize_( cParser &Input, scene::scratch_data &Scratchpad ) override; + // run() subclass details + void run_() override; + // export_as_text() subclass details + void export_as_text_( std::ostream &Output ) const override; +// members + bool m_visible{ true }; +}; + +class friction_event : public basic_event { + +public: +// methods + // prepares event for use + void init() override; + +private: +// methods + // event type string + std::string type() const override; + // deserialize() subclass details + void deserialize_( cParser &Input, scene::scratch_data &Scratchpad ) override; + // run() subclass details + void run_() override; + // export_as_text() subclass details + void export_as_text_( std::ostream &Output ) const override; +// members + float m_friction{ -1.f }; +}; + +class message_event : public basic_event { + +public: +// methods + // prepares event for use + void init() override; + +private: +// methods + // event type string + std::string type() const override; + // deserialize() subclass details + void deserialize_( cParser &Input, scene::scratch_data &Scratchpad ) override; + // run() subclass details + void run_() override; + // export_as_text() subclass details + void export_as_text_( std::ostream &Output ) const override; +// members + std::string m_message; +}; + + + +basic_event * +make_event( cParser &Input, scene::scratch_data &Scratchpad ); + + + +class event_manager { + +public: +// constructors + event_manager() = default; +// destructor + ~event_manager(); +// methods + // adds specified event launcher to the list of global launchers + void + queue( TEventLauncher *Launcher ); + // legacy method, updates event queues + void + update(); + // adds provided event to the collection. returns: true on success + // TBD, TODO: return handle to the event + bool + insert( basic_event *Event ); + inline + bool + insert( TEventLauncher *Launcher ) { + return m_launchers.insert( Launcher ); } + // returns first event in the queue + inline + basic_event * + begin() { + return QueryRootEvent; } + // legacy method, returns pointer to specified event, or null + basic_event * + FindEvent( std::string const &Name ); + // legacy method, inserts specified event in the event query + bool + AddToQuery( basic_event *Event, TDynamicObject const *Owner ); + // legacy method, executes queued events + bool + CheckQuery(); + // legacy method, initializes events after deserialization from scenario file + void + InitEvents(); + // legacy method, initializes event launchers after deserialization from scenario file + void + InitLaunchers(); + // sends basic content of the class in legacy (text) format to provided stream + void + export_as_text( std::ostream &Output ) const; + +private: +// types + using event_sequence = std::deque; + using event_map = std::unordered_map; + using eventlauncher_sequence = std::vector; +// members + event_sequence m_events; +/* + // NOTE: disabled until event class refactoring + event_sequence m_eventqueue; +*/ + // legacy version of the above + basic_event *QueryRootEvent { nullptr }; + basic_event *m_workevent { nullptr }; + event_map m_eventmap; + basic_table m_launchers; + eventlauncher_sequence m_launcherqueue; +}; + + + +inline +void +basic_event::group( scene::group_handle Group ) { + m_group = Group; +} + +inline +scene::group_handle +basic_event::group() const { + return m_group; +} + +template +void +basic_event::init_targets( TableType_ &Repository, std::string const &Targettype, bool const Logerrors ) { + + for( auto &target : m_targets ) { + std::get( target ) = Repository.find( std::get( target ) ); + if( std::get( target ) == nullptr ) { + m_ignored = true; // deaktywacja + if( Logerrors ) + ErrorLog( "Bad event: \"" + m_name + "\" (type: " + type() + ") can't find " + Targettype +" \"" + std::get( target ) + "\"" ); + } + } +} + //--------------------------------------------------------------------------- diff --git a/Float3d.cpp b/Float3d.cpp index 2f82507e..e2f37d7c 100644 --- a/Float3d.cpp +++ b/Float3d.cpp @@ -9,9 +9,28 @@ http://mozilla.org/MPL/2.0/. #include "stdafx.h" #include "float3d.h" +#include "sn_utils.h" //--------------------------------------------------------------------------- +void float4x4::deserialize_float32(std::istream &s) +{ + for (size_t i = 0; i < 16; i++) + e[i] = sn_utils::ld_float32(s); +} + +void float4x4::deserialize_float64(std::istream &s) +{ + for (size_t i = 0; i < 16; i++) + e[i] = (float)sn_utils::ld_float64(s); +} + +void float4x4::serialize_float32(std::ostream &s) +{ + for (size_t i = 0; i < 16; i++) + sn_utils::ls_float32(s, e[i]); +} + void float4x4::Quaternion(float4 *q) { // konwersja kwaternionu obrotu na macierz obrotu float xx = q->x * q->x, yy = q->y * q->y, zz = q->z * q->z; diff --git a/Float3d.h b/Float3d.h index c3ee39a7..0216b000 100644 --- a/Float3d.h +++ b/Float3d.h @@ -23,7 +23,8 @@ class float3 y = b; z = c; }; - double inline Length() const; + float Length() const; + float LengthSquared() const; }; inline bool operator==(const float3 &v1, const float3 &v2) @@ -49,17 +50,23 @@ inline float3 operator+(const float3 &v1, const float3 &v2) { return float3(v1.x + v2.x, v1.y + v2.y, v1.z + v2.z); }; -double inline float3::Length() const +inline float float3::Length() const { - return sqrt(x * x + y * y + z * z); + return std::sqrt(LengthSquared()); }; -inline float3 operator/(const float3 &v, double k) +inline float float3::LengthSquared() const { + return ( x * x + y * y + z * z ); +} +inline float3 operator*( float3 const &v, float const k ) { + return float3( v.x * k, v.y * k, v.z * k ); +}; +inline float3 operator/( float3 const &v, float const k ) { return float3(v.x / k, v.y / k, v.z / k); }; inline float3 SafeNormalize(const float3 &v) { // bezpieczna normalizacja (wektor długości 1.0) - double l = v.Length(); + auto const l = v.Length(); float3 retVal; if (l == 0) retVal.x = retVal.y = retVal.z = 0; @@ -67,10 +74,19 @@ inline float3 SafeNormalize(const float3 &v) retVal = v / l; return retVal; }; -inline float3 CrossProduct(const float3 &v1, const float3 &v2) +inline float3 CrossProduct( float3 const &v1, float3 const &v2 ) { return float3(v1.y * v2.z - v1.z * v2.y, v2.x * v1.z - v2.z * v1.x, v1.x * v2.y - v1.y * v2.x); } +inline float DotProduct( float3 const &v1, float3 const &v2 ) { + + return v1.x * v2.x + v1.y * v2.y + v1.z * v2.z; +} + +inline float3 Interpolate( float3 const &First, float3 const &Second, float const Factor ) { + + return ( First * ( 1.0f - Factor ) ) + ( Second * Factor ); +} class float4 { // kwaternion obrotu @@ -88,11 +104,11 @@ class float4 z = c; w = d; }; - double inline float4::LengthSquared() const + float inline LengthSquared() const { return x * x + y * y + z * z + w * w; }; - double inline float4::Length() const + float inline Length() const { return sqrt(x * x + y * y + z * z + w * w); }; @@ -116,26 +132,26 @@ inline float4 operator+(const float4 &v1, const float4 &v2) { return float4(v1.x + v2.x, v1.y + v2.y, v1.z + v2.z, v1.w + v2.w); }; -inline float4 operator/(const float4 &v, double k) +inline float4 operator/(const float4 &v, float const k) { return float4(v.x / k, v.y / k, v.z / k, v.w / k); }; inline float4 Normalize(const float4 &v) { // bezpieczna normalizacja (wektor długości 1.0) - double l = v.LengthSquared(); - if (l == 1.0) + auto const lengthsquared = v.LengthSquared(); + if (lengthsquared == 1.0) return v; - if (l == 0.0) + if (lengthsquared == 0.0) return float4(); // wektor zerowy, w=1 else - return v / sqrt(l); // pierwiastek liczony tylko jeśli trzeba wykonać dzielenia + return v / std::sqrt(lengthsquared); // pierwiastek liczony tylko jeśli trzeba wykonać dzielenia }; inline float Dot(const float4 &q1, const float4 &q2) { // iloczyn skalarny return q1.x * q2.x + q1.y * q2.y + q1.z * q2.z + q1.w * q2.w; } -inline float4 &operator*=(float4 &v1, double d) +inline float4 &operator*=(float4 &v1, float const d) { // mnożenie przez skalar, jaki ma sens? v1.x *= d; v1.y *= d; @@ -156,7 +172,7 @@ inline float4 Slerp(const float4 &q0, const float4 &q1, float t) new_q1.w = -new_q1.w; cosOmega = -cosOmega; } - double k0, k1; + float k0, k1; if (cosOmega > 0.9999f) { // jeśli jesteśmy z (t) na maksimum kosinusa, to tam prawie liniowo jest k0 = 1.0f - t; @@ -164,9 +180,9 @@ inline float4 Slerp(const float4 &q0, const float4 &q1, float t) } else { // a w ogólnym przypadku trzeba liczyć na trygonometrię - double sinOmega = sqrt(1.0f - cosOmega * cosOmega); // sinus z jedynki tryg. - double omega = atan2(sinOmega, cosOmega); // wyznaczenie kąta - double oneOverSinOmega = 1.0f / sinOmega; // odwrotność sinusa, bo sinus w mianowniku + auto const sinOmega = std::sqrt(1.0f - cosOmega * cosOmega); // sinus z jedynki tryg. + auto const omega = std::atan2(sinOmega, cosOmega); // wyznaczenie kąta + auto const oneOverSinOmega = 1.0f / sinOmega; // odwrotność sinusa, bo sinus w mianowniku k0 = sin((1.0f - t) * omega) * oneOverSinOmega; k1 = sin(t * omega) * oneOverSinOmega; } @@ -184,9 +200,12 @@ struct float8 class float4x4 { // macierz transformacji pojedynczej precyzji +public: float e[16]; - public: + void deserialize_float32(std::istream&); + void deserialize_float64(std::istream&); + void serialize_float32(std::ostream&); float4x4(void){}; float4x4(float f[16]) { @@ -197,7 +216,7 @@ class float4x4 { return &e[i << 2]; } - const float * readArray(void) + const float * readArray(void) const { return e; } @@ -222,7 +241,7 @@ class float4x4 e[i + 2] = f; // zamiana Y i Z } }; - inline float4x4 &Rotation(double angle, float3 axis); + inline float4x4 &Rotation(float const angle, float3 const &axis); inline bool IdentityIs() { // sprawdzenie jednostkowości for (int i = 0; i < 16; ++i) @@ -244,34 +263,37 @@ inline float3 operator*(const float4x4 &m, const float3 &v) v.x * m[0][2] + v.y * m[1][2] + v.z * m[2][2] + m[3][2]); } -inline float4x4 &float4x4::Rotation(double angle, float3 axis) +inline glm::vec3 operator*( const float4x4 &m, const glm::vec3 &v ) { // mnożenie wektora przez macierz + return glm::vec3( + v.x * m[ 0 ][ 0 ] + v.y * m[ 1 ][ 0 ] + v.z * m[ 2 ][ 0 ] + m[ 3 ][ 0 ], + v.x * m[ 0 ][ 1 ] + v.y * m[ 1 ][ 1 ] + v.z * m[ 2 ][ 1 ] + m[ 3 ][ 1 ], + v.x * m[ 0 ][ 2 ] + v.y * m[ 1 ][ 2 ] + v.z * m[ 2 ][ 2 ] + m[ 3 ][ 2 ] ); +} + +inline float4x4 &float4x4::Rotation(float const Angle, float3 const &Axis) { - double c = cos(angle); - double s = sin(angle); + auto const c = std::cos(Angle); + auto const s = std::sin(Angle); // One minus c (short name for legibility of formulai) - double omc = (1 - c); - if (axis.Length() != 1.0f) - axis = SafeNormalize(axis); - double x = axis.x; - double y = axis.y; - double z = axis.z; - double xs = x * s; - double ys = y * s; - double zs = z * s; - double xyomc = x * y * omc; - double xzomc = x * z * omc; - double yzomc = y * z * omc; - e[0] = x * x * omc + c; + auto const omc = (1.f - c); + auto const axis = SafeNormalize(Axis); + auto const xs = axis.x * s; + auto const ys = axis.y * s; + auto const zs = axis.z * s; + auto const xyomc = axis.x * axis.y * omc; + auto const xzomc = axis.x * axis.z * omc; + auto const yzomc = axis.y * axis.z * omc; + e[0] = axis.x * axis.x * omc + c; e[1] = xyomc + zs; e[2] = xzomc - ys; e[3] = 0; e[4] = xyomc - zs; - e[5] = y * y * omc + c; + e[5] = axis.y * axis.y * omc + c; e[6] = yzomc + xs; e[7] = 0; e[8] = xzomc + ys; e[9] = yzomc - xs; - e[10] = z * z * omc + c; + e[10] = axis.z * axis.z * omc + c; e[11] = 0; e[12] = 0; e[13] = 0; @@ -280,6 +302,16 @@ inline float4x4 &float4x4::Rotation(double angle, float3 axis) return *this; }; +inline bool operator==(const float4x4& v1, const float4x4& v2) +{ + for (size_t i = 0; i < 16; i++) + { + if (v1.e[i] != v2.e[i]) + return false; + } + return true; +} + inline float4x4 operator*(const float4x4 &m1, const float4x4 &m2) { // iloczyn macierzy float4x4 retVal; diff --git a/Gauge.cpp b/Gauge.cpp index 04091419..1f87a7b8 100644 --- a/Gauge.cpp +++ b/Gauge.cpp @@ -15,213 +15,390 @@ http://mozilla.org/MPL/2.0/. #include "stdafx.h" #include "Gauge.h" -#include "Timer.h" #include "parser.h" #include "Model3d.h" +#include "Timer.h" +#include "logs.h" +#include "renderer.h" -TGauge::TGauge() +TGauge::TGauge( sound_source const &Soundtemplate ) : + m_soundtemplate( Soundtemplate ) { - eType = gt_Unknown; - fFriction = 0.0; - fDesiredValue = 0.0; - fValue = 0.0; - fOffset = 0.0; - fScale = 1.0; - fStepSize = 5; - // iChannel=-1; //kanał analogowej komunikacji zwrotnej - SubModel = NULL; -}; + m_soundfxincrease = m_soundtemplate; + m_soundfxdecrease = m_soundtemplate; +} -TGauge::~TGauge(){}; - -void TGauge::Clear() -{ - SubModel = NULL; - eType = gt_Unknown; - fValue = 0; - fDesiredValue = 0; -}; - -void TGauge::Init(TSubModel *NewSubModel, TGaugeType eNewType, double fNewScale, double fNewOffset, - double fNewFriction, double fNewValue) +void TGauge::Init(TSubModel *Submodel, TGaugeAnimation Type, float Scale, float Offset, float Friction, float Value, float const Endvalue, float const Endscale, bool const Interpolatescale ) { // ustawienie parametrów animacji submodelu - if (NewSubModel) - { // warunek na wszelki wypadek, gdyby się submodel nie - // podłączył - fFriction = fNewFriction; - fValue = fNewValue; - fOffset = fNewOffset; - fScale = fNewScale; - SubModel = NewSubModel; - eType = eNewType; - if (eType == gt_Digital) - { - TSubModel *sm = SubModel->ChildGet(); - do - { // pętla po submodelach potomnych i obracanie ich o kąt zależy od - // cyfry w (fValue) - if (sm->pName) - { // musi mieć niepustą nazwę - if (sm->pName[0] >= '0') - if (sm->pName[0] <= '9') - sm->WillBeAnimated(); // wyłączenie optymalizacji - } - sm = sm->NextGet(); - } while (sm); - } - else // a banan może być z optymalizacją? - NewSubModel->WillBeAnimated(); // wyłączenie ignowania jedynkowego transformu + SubModel = Submodel; + m_value = Value; + m_animation = Type; + m_scale = Scale; + m_offset = Offset; + m_friction = Friction; + m_interpolatescale = Interpolatescale; + m_endvalue = Endvalue; + m_endscale = Endscale; + + if( Submodel == nullptr ) { + // warunek na wszelki wypadek, gdyby się submodel nie podłączył + return; } -}; -bool TGauge::Load(cParser &Parser, TModel3d *md1, TModel3d *md2, double mul) -{ - std::string str1 = Parser.getToken(false); - std::string str2 = Parser.getToken(); - Parser.getTokens( 3, false ); - double val3, val4, val5; - Parser - >> val3 - >> val4 - >> val5; - val3 *= mul; - TSubModel *sm = md1->GetFromName( str1.c_str() ); - if (sm) // jeśli nie znaleziony - md2 = NULL; // informacja, że znaleziony - else if (md2) // a jest podany drugi model (np. zewnętrzny) - sm = md2->GetFromName(str1.c_str()); // to może tam będzie, co za różnica gdzie - if (str2 == "mov") - Init(sm, gt_Move, val3, val4, val5); - else if (str2 == "wip") - Init(sm, gt_Wiper, val3, val4, val5); - else if (str2 == "dgt") - Init(sm, gt_Digital, val3, val4, val5); - else - Init(sm, gt_Rotate, val3, val4, val5); - return (md2); // true, gdy podany model zewnętrzny, a w kabinie nie było -}; + if( m_animation == TGaugeAnimation::gt_Digital ) { -void TGauge::PermIncValue(double fNewDesired) -{ - fDesiredValue = fDesiredValue + fNewDesired * fScale + fOffset; - if (fDesiredValue - fOffset > 360 / fScale) - { - fDesiredValue = fDesiredValue - (360 / fScale); - fValue = fValue - (360 / fScale); - } -}; - -void TGauge::IncValue(double fNewDesired) -{ // używane tylko dla uniwersali - fDesiredValue = fDesiredValue + fNewDesired * fScale + fOffset; - if (fDesiredValue > fScale + fOffset) - fDesiredValue = fScale + fOffset; -}; - -void TGauge::DecValue(double fNewDesired) -{ // używane tylko dla uniwersali - fDesiredValue = fDesiredValue - fNewDesired * fScale + fOffset; - if (fDesiredValue < 0) - fDesiredValue = 0; -}; - -void TGauge::UpdateValue(double fNewDesired) -{ // ustawienie wartości docelowej - fDesiredValue = fNewDesired * fScale + fOffset; -}; - -void TGauge::PutValue(double fNewDesired) -{ // McZapkie-281102: natychmiastowe wpisanie wartosci - fDesiredValue = fNewDesired * fScale + fOffset; - fValue = fDesiredValue; -}; - -void TGauge::Update() -{ - float dt = Timer::GetDeltaTime(); - if ((fFriction > 0) && (dt < 0.5 * fFriction)) // McZapkie-281102: - // zabezpieczenie przed - // oscylacjami dla dlugich - // czasow - fValue += dt * (fDesiredValue - fValue) / fFriction; - else - fValue = fDesiredValue; - if (SubModel) - { // warunek na wszelki wypadek, gdyby się submodel nie - // podłączył - TSubModel *sm; - switch (eType) - { - case gt_Rotate: - SubModel->SetRotate(float3(0, 1, 0), fValue * 360.0); - break; - case gt_Move: - SubModel->SetTranslate(float3(0, 0, fValue)); - break; - case gt_Wiper: - SubModel->SetRotate(float3(0, 1, 0), fValue * 360.0); - sm = SubModel->ChildGet(); - if (sm) - { - sm->SetRotate(float3(0, 1, 0), fValue * 360.0); - sm = sm->ChildGet(); - if (sm) - sm->SetRotate(float3(0, 1, 0), fValue * 360.0); + TSubModel *sm = SubModel->ChildGet(); + do { + // pętla po submodelach potomnych i obracanie ich o kąt zależy od cyfry w (fValue) + if( sm->pName.size() ) { // musi mieć niepustą nazwę + if( sm->pName[ 0 ] >= '0' ) + if( sm->pName[ 0 ] <= '9' ) + sm->WillBeAnimated(); // wyłączenie optymalizacji } - break; - case gt_Digital: // Ra 2014-07: licznik cyfrowy - sm = SubModel->ChildGet(); -/* std::string n = FormatFloat( "0000000000", floor( fValue ) ); // na razie tak trochę bez sensu -*/ std::string n( "000000000" + std::to_string( static_cast( std::floor( fValue ) ) ) ); - if( n.length() > 10 ) { n.erase( 0, n.length() - 10 ); } // also dumb but should work for now - do - { // pętla po submodelach potomnych i obracanie ich o kąt zależy od - // cyfry w (fValue) - if (sm->pName) - { // musi mieć niepustą nazwę - if (sm->pName[0] >= '0') - if (sm->pName[0] <= '9') - sm->SetRotate(float3(0, 1, 0), - -36.0 * (n['0' + 10 - sm->pName[0]] - '0')); - } - sm = sm->NextGet(); - } while (sm); - break; + sm = sm->NextGet(); + } while( sm ); + } + else // a banan może być z optymalizacją? + Submodel->WillBeAnimated(); // wyłączenie ignowania jedynkowego transformu + // pass submodel location to defined sounds + auto const nulloffset { glm::vec3{} }; + auto const offset{ model_offset() }; + if( m_soundfxincrease.offset() == nulloffset ) { + m_soundfxincrease.offset( offset ); + } + if( m_soundfxdecrease.offset() == nulloffset ) { + m_soundfxdecrease.offset( offset ); + } + for( auto &soundfxrecord : m_soundfxvalues ) { + if( soundfxrecord.second.offset() == nulloffset ) { + soundfxrecord.second.offset( offset ); } } }; -void TGauge::Render(){}; +bool TGauge::Load( cParser &Parser, TDynamicObject const *Owner, TModel3d *md1, TModel3d *md2, double mul ) { + + std::string submodelname, gaugetypename; + float scale, endscale, endvalue, offset, friction; + endscale = -1; + endvalue = -1; + bool interpolatescale { false }; + + Parser.getTokens(); + if( Parser.peek() != "{" ) { + // old fixed size config + Parser >> submodelname; + gaugetypename = Parser.getToken( true ); + Parser.getTokens( 3, false ); + Parser + >> scale + >> offset + >> friction; + if( ( gaugetypename == "rotvar" ) + || ( gaugetypename == "movvar" ) ) { + interpolatescale = true; + Parser.getTokens( 2, false ); + Parser + >> endvalue + >> endscale; + } + } + else { + // new, block type config + // TODO: rework the base part into yaml-compatible flow style mapping + submodelname = Parser.getToken( false ); + gaugetypename = Parser.getToken( true ); + Parser.getTokens( 3, false ); + Parser + >> scale + >> offset + >> friction; + if( ( gaugetypename == "rotvar" ) + || ( gaugetypename == "movvar" ) ) { + interpolatescale = true; + Parser.getTokens( 2, false ); + Parser + >> endvalue + >> endscale; + } + // new, variable length section + while( true == Load_mapping( Parser ) ) { + ; // all work done by while() + } + } + + // bind defined sounds with the button owner + m_soundfxincrease.owner( Owner ); + m_soundfxdecrease.owner( Owner ); + for( auto &soundfxrecord : m_soundfxvalues ) { + soundfxrecord.second.owner( Owner ); + } + + scale *= mul; + if( interpolatescale ) { + endscale *= mul; + } + TSubModel *submodel = md1->GetFromName( submodelname ); + if (submodel) // jeśli nie znaleziony + md2 = nullptr; // informacja, że znaleziony + else if (md2) // a jest podany drugi model (np. zewnętrzny) + submodel = md2->GetFromName(submodelname); // to może tam będzie, co za różnica gdzie + if( submodel == nullptr ) { + ErrorLog( "Bad model: failed to locate sub-model \"" + submodelname + "\" in 3d model \"" + md1->NameGet() + "\"", logtype::model ); + } + + std::map gaugetypes { + { "rot", TGaugeAnimation::gt_Rotate }, + { "rotvar", TGaugeAnimation::gt_Rotate }, + { "mov", TGaugeAnimation::gt_Move }, + { "movvar", TGaugeAnimation::gt_Move }, + { "wip", TGaugeAnimation::gt_Wiper }, + { "dgt", TGaugeAnimation::gt_Digital } + }; + auto lookup = gaugetypes.find( gaugetypename ); + auto const type = ( + lookup != gaugetypes.end() ? + lookup->second : + TGaugeAnimation::gt_Unknown ); + + Init( submodel, type, scale, offset, friction, 0, endvalue, endscale, interpolatescale ); + + return md2 != nullptr; // true, gdy podany model zewnętrzny, a w kabinie nie było +}; + +bool +TGauge::Load_mapping( cParser &Input ) { + + // token can be a key or block end + auto const key { Input.getToken( true, "\n\r\t ,;" ) }; + if( ( true == key.empty() ) || ( key == "}" ) ) { return false; } + // if not block end then the key is followed by assigned value or sub-block + if( key == "type:" ) { + auto const gaugetype { Input.getToken( true, "\n\r\t ,;" ) }; + m_type = ( + gaugetype == "impulse" ? TGaugeType::push : + gaugetype == "return" ? TGaugeType::push : + TGaugeType::toggle ); // default + } + else if( key == "soundinc:" ) { + m_soundfxincrease.deserialize( Input, sound_type::single ); + } + else if( key == "sounddec:" ) { + m_soundfxdecrease.deserialize( Input, sound_type::single ); + } + else if( key.compare( 0, std::min( key.size(), 5 ), "sound" ) == 0 ) { + // sounds assigned to specific gauge values, defined by key soundFoo: where Foo = value + auto const indexstart { key.find_first_of( "-1234567890" ) }; + auto const indexend { key.find_first_not_of( "-1234567890", indexstart ) }; + if( indexstart != std::string::npos ) { + m_soundfxvalues.emplace( + std::stoi( key.substr( indexstart, indexend - indexstart ) ), + sound_source( m_soundtemplate ).deserialize( Input, sound_type::single ) ); + } + } + return true; // return value marks a key: value pair was extracted, nothing about whether it's recognized +} + +void +TGauge::UpdateValue( float fNewDesired ) { + + return UpdateValue( fNewDesired, nullptr ); +} + +void +TGauge::UpdateValue( float fNewDesired, sound_source &Fallbacksound ) { + + return UpdateValue( fNewDesired, &Fallbacksound ); +} + +// ustawienie wartości docelowej. plays provided fallback sound, if no sound was defined in the control itself +void +TGauge::UpdateValue( float fNewDesired, sound_source *Fallbacksound ) { + + auto const desiredtimes100 = static_cast( std::round( 100.0 * fNewDesired ) ); + if( desiredtimes100 == static_cast( std::round( 100.0 * m_targetvalue ) ) ) { + return; + } + m_targetvalue = fNewDesired; + // if there's any sound associated with new requested value, play it + // check value-specific table first... + auto const fullinteger { desiredtimes100 % 100 == 0 }; + if( fullinteger ) { + // filter out values other than full integers + auto const lookup = m_soundfxvalues.find( desiredtimes100 / 100 ); + if( lookup != m_soundfxvalues.end() ) { + lookup->second.play(); + return; + } + } + else { + // toggle the control to continous range/exclusive sound mode from now on + m_soundtype = sound_flags::exclusive; + } + // ...and if there isn't any, fall back on the basic set... + auto const currentvalue = GetValue(); + // HACK: crude way to discern controls with continuous and quantized value range + if( ( currentvalue < fNewDesired ) + && ( false == m_soundfxincrease.empty() ) ) { + // shift up + m_soundfxincrease.play( m_soundtype ); + } + else if( ( currentvalue > fNewDesired ) + && ( false == m_soundfxdecrease.empty() ) ) { + // shift down + m_soundfxdecrease.play( m_soundtype ); + } + else if( Fallbacksound != nullptr ) { + // ...and if that fails too, try the provided fallback sound from legacy system + Fallbacksound->play( m_soundtype ); + } +}; + +void TGauge::PutValue(float fNewDesired) +{ // McZapkie-281102: natychmiastowe wpisanie wartosci + m_targetvalue = fNewDesired; + m_value = m_targetvalue; +}; + +float TGauge::GetValue() const { + // we feed value in range 0-1 so we should be getting it reported in the same range + return m_value; +} + +float TGauge::GetDesiredValue() const { + // we feed value in range 0-1 so we should be getting it reported in the same range + return m_targetvalue; +} + +void TGauge::Update() { + + if( m_value != m_targetvalue ) { + float dt = Timer::GetDeltaTime(); + if( ( m_friction > 0 ) && ( dt < 0.5 * m_friction ) ) { + // McZapkie-281102: zabezpieczenie przed oscylacjami dla dlugich czasow + m_value += dt * ( m_targetvalue - m_value ) / m_friction; + if( std::abs( m_targetvalue - m_value ) <= 0.0001 ) { + // close enough, we can stop updating the model + m_value = m_targetvalue; // set it exactly as requested just in case it matters + } + } + else { + m_value = m_targetvalue; + } + } + if( SubModel ) + { // warunek na wszelki wypadek, gdyby się submodel nie podłączył + switch (m_animation) { + case TGaugeAnimation::gt_Rotate: { + SubModel->SetRotate( float3( 0, 1, 0 ), GetScaledValue() * 360.0 ); + break; + } + case TGaugeAnimation::gt_Move: { + SubModel->SetTranslate( float3( 0, 0, GetScaledValue() ) ); + break; + } + case TGaugeAnimation::gt_Wiper: { + auto const scaledvalue { GetScaledValue() }; + SubModel->SetRotate( float3( 0, 1, 0 ), scaledvalue * 360.0 ); + auto *sm = SubModel->ChildGet(); + if( sm ) { + sm->SetRotate( float3( 0, 1, 0 ), scaledvalue * 360.0 ); + sm = sm->ChildGet(); + if( sm ) + sm->SetRotate( float3( 0, 1, 0 ), scaledvalue * 360.0 ); + } + break; + } + case TGaugeAnimation::gt_Digital: { + // Ra 2014-07: licznik cyfrowy + auto *sm = SubModel->ChildGet(); +/* std::string n = FormatFloat( "0000000000", floor( fValue ) ); // na razie tak trochę bez sensu +*/ std::string n( "000000000" + std::to_string( static_cast( std::floor( GetScaledValue() ) ) ) ); + if( n.length() > 10 ) { n.erase( 0, n.length() - 10 ); } // also dumb but should work for now + do { // pętla po submodelach potomnych i obracanie ich o kąt zależy od cyfry w (fValue) + if( sm->pName.size() ) { + // musi mieć niepustą nazwę + if( ( sm->pName[ 0 ] >= '0' ) + && ( sm->pName[ 0 ] <= '9' ) ) { + + sm->SetRotate( + float3( 0, 1, 0 ), + -36.0 * ( n[ '0' + 9 - sm->pName[ 0 ] ] - '0' ) ); + } + } + sm = sm->NextGet(); + } while( sm ); + break; + } + default: { + break; + } + } + } +}; void TGauge::AssignFloat(float *fValue) { - cDataType = 'f'; + m_datatype = 'f'; fData = fValue; }; + void TGauge::AssignDouble(double *dValue) { - cDataType = 'd'; + m_datatype = 'd'; dData = dValue; }; + void TGauge::AssignInt(int *iValue) { - cDataType = 'i'; + m_datatype = 'i'; iData = iValue; }; + void TGauge::UpdateValue() { // ustawienie wartości docelowej z parametru - switch (cDataType) + switch (m_datatype) { // to nie jest zbyt optymalne, można by zrobić osobne funkcje case 'f': - fDesiredValue = (*fData) * fScale + fOffset; + UpdateValue( *fData ); break; case 'd': - fDesiredValue = (*dData) * fScale + fOffset; + UpdateValue( *dData ); break; case 'i': - fDesiredValue = (*iData) * fScale + fOffset; + UpdateValue( *iData ); + break; + default: break; } }; +float TGauge::GetScaledValue() const { + + return ( + ( false == m_interpolatescale ) ? + m_value * m_scale + m_offset : + m_value + * interpolate( + m_scale, m_endscale, + clamp( + m_value / m_endvalue, + 0.f, 1.f ) ) + + m_offset ); +} + +// returns offset of submodel associated with the button from the model centre +glm::vec3 +TGauge::model_offset() const { + + return ( + SubModel != nullptr ? + SubModel->offset( 1.f ) : + glm::vec3() ); +} + +TGaugeType +TGauge::type() const { + return m_type; +} //--------------------------------------------------------------------------- diff --git a/Gauge.h b/Gauge.h index de6ba90b..82de24af 100644 --- a/Gauge.h +++ b/Gauge.h @@ -10,58 +10,85 @@ http://mozilla.org/MPL/2.0/. #pragma once #include "Classes.h" +#include "sound.h" -typedef enum -{ // typ ruchu +enum class TGaugeAnimation { + // typ ruchu gt_Unknown, // na razie nie znany gt_Rotate, // obrót gt_Move, // przesunięcie równoległe - gt_Wiper, // obrót trzech kolejnych submodeli o ten sam kąt (np. wycieraczka, drzwi - // harmonijkowe) + gt_Wiper, // obrót trzech kolejnych submodeli o ten sam kąt (np. wycieraczka, drzwi harmonijkowe) gt_Digital // licznik cyfrowy, np. kilometrów -} TGaugeType; +}; -class TGauge // zmienne "gg" -{ // animowany wskaźnik, mogący przyjmować wiele stanów pośrednich - private: - TGaugeType eType; // typ ruchu - double fFriction; // hamowanie przy zliżaniu się do zadanej wartości - double fDesiredValue; // wartość docelowa - double fValue; // wartość obecna - double fOffset; // wartość początkowa ("0") - double fScale; // wartość końcowa ("1") - double fStepSize; // nie używane - char cDataType; // typ zmiennej parametru: f-float, d-double, i-int - union - { // wskaźnik na parametr pokazywany przez animację - float *fData; - double *dData; - int *iData; - }; +enum class TGaugeType { + toggle, + push +}; - public: - TGauge(); - ~TGauge(); - void Clear(); - void Init(TSubModel *NewSubModel, TGaugeType eNewTyp, double fNewScale = 1, - double fNewOffset = 0, double fNewFriction = 0, double fNewValue = 0); - bool Load(cParser &Parser, TModel3d *md1, TModel3d *md2 = NULL, double mul = 1.0); - void PermIncValue(double fNewDesired); - void IncValue(double fNewDesired); - void DecValue(double fNewDesired); - void UpdateValue(double fNewDesired); - void PutValue(double fNewDesired); - float GetValue() - { - return fValue; - }; +// animowany wskaźnik, mogący przyjmować wiele stanów pośrednich +class TGauge { + +public: +// methods + TGauge() = default; + explicit TGauge( sound_source const &Soundtemplate ); + + inline + void Clear() { + *this = TGauge(); } + void Init(TSubModel *Submodel, TGaugeAnimation Type, float Scale = 1, float Offset = 0, float Friction = 0, float Value = 0, float const Endvalue = -1.0, float const Endscale = -1.0, bool const Interpolate = false ); + bool Load(cParser &Parser, TDynamicObject const *Owner, TModel3d *md1, TModel3d *md2 = nullptr, double mul = 1.0); + void UpdateValue( float fNewDesired ); + void UpdateValue( float fNewDesired, sound_source &Fallbacksound ); + void PutValue(float fNewDesired); + float GetValue() const; + float GetDesiredValue() const; void Update(); - void Render(); void AssignFloat(float *fValue); void AssignDouble(double *dValue); void AssignInt(int *iValue); void UpdateValue(); - TSubModel *SubModel; // McZapkie-310302: zeby mozna bylo sprawdzac czy zainicjowany poprawnie + // returns offset of submodel associated with the button from the model centre + glm::vec3 model_offset() const; + TGaugeType type() const; +// members + TSubModel *SubModel { nullptr }; // McZapkie-310302: zeby mozna bylo sprawdzac czy zainicjowany poprawnie + +private: +// methods +// imports member data pair from the config file + bool + Load_mapping( cParser &Input ); + void + UpdateValue( float fNewDesired, sound_source *Fallbacksound ); + float + GetScaledValue() const; + +// members + TGaugeAnimation m_animation { TGaugeAnimation::gt_Unknown }; // typ ruchu + TGaugeType m_type { TGaugeType::toggle }; // switch type + float m_friction { 0.f }; // hamowanie przy zliżaniu się do zadanej wartości + float m_targetvalue { 0.f }; // wartość docelowa + float m_value { 0.f }; // wartość obecna + float m_offset { 0.f }; // wartość początkowa ("0") + float m_scale { 1.f }; // scale applied to the value at the start of accepted value range + float m_endscale { -1.f }; // scale applied to the value at the end of accepted value range + float m_endvalue { -1.f }; // end value of accepted value range + bool m_interpolatescale { false }; + char m_datatype; // typ zmiennej parametru: f-float, d-double, i-int + union { + // wskaźnik na parametr pokazywany przez animację + float *fData; + double *dData { nullptr }; + int *iData; + }; + int m_soundtype { 0 }; // toggle between exclusive and multiple sound generation + sound_source m_soundtemplate { sound_placement::internal, EU07_SOUND_CABCONTROLSCUTOFFRANGE }; // shared properties for control's sounds + sound_source m_soundfxincrease { m_soundtemplate }; // sound associated with increasing control's value + sound_source m_soundfxdecrease { m_soundtemplate }; // sound associated with decreasing control's value + std::map m_soundfxvalues; // sounds associated with specific values + }; //--------------------------------------------------------------------------- diff --git a/Globals.cpp b/Globals.cpp index d8cabf78..a6a01fd6 100644 --- a/Globals.cpp +++ b/Globals.cpp @@ -12,230 +12,26 @@ http://mozilla.org/MPL/2.0/. */ #include "stdafx.h" +#include "globals.h" -#include "Globals.h" -#include "usefull.h" -//#include "Mover.h" +#include "simulation.h" +#include "simulationenvironment.h" +#include "driver.h" +#include "logs.h" #include "Console.h" -#include "Driver.h" -#include "Logs.h" #include "PyInt.h" -#include "World.h" -#include "parser.h" -// namespace Global { +global_settings Global; -// parametry do użytku wewnętrznego -// double Global::tSinceStart=0; -TGround *Global::pGround = NULL; -// char Global::CreatorName1[30]="2001-2004 Maciej Czapkiewicz "; -// char Global::CreatorName2[30]="2001-2003 Marcin Woźniak "; -// char Global::CreatorName3[20]="2004-2005 Adam Bugiel "; -// char Global::CreatorName4[30]="2004 Arkadiusz Ślusarczyk "; -// char Global::CreatorName5[30]="2003-2009 Łukasz Kirchner "; -std::string Global::asCurrentSceneryPath = "scenery/"; -std::string Global::asCurrentTexturePath = std::string(szTexturePath); -std::string Global::asCurrentDynamicPath = ""; -int Global::iSlowMotion = - 0; // info o malym FPS: 0-OK, 1-wyłączyć multisampling, 3-promień 1.5km, 7-1km -TDynamicObject *Global::changeDynObj = NULL; // info o zmianie pojazdu -bool Global::detonatoryOK; // info o nowych detonatorach -double Global::ABuDebug = 0; -std::string Global::asSky = "1"; -double Global::fOpenGL = 0.0; // wersja OpenGL - do sprawdzania obecności rozszerzeń -/* -bool Global::bOpenGL_1_5 = false; // czy są dostępne funkcje OpenGL 1.5 -*/ -double Global::fLuminance = 1.0; // jasność światła do automatycznego zapalania -int Global::iReCompile = 0; // zwiększany, gdy trzeba odświeżyć siatki -HWND Global::hWnd = NULL; // uchwyt okna -int Global::iCameraLast = -1; -std::string Global::asRelease = "16.0.1172.482"; -std::string Global::asVersion = - "Compilation 2017-01-10, release " + Global::asRelease + "."; // tutaj, bo wysyłany -int Global::iViewMode = 0; // co aktualnie widać: 0-kabina, 1-latanie, 2-sprzęgi, 3-dokumenty -int Global::iTextMode = 0; // tryb pracy wyświetlacza tekstowego -int Global::iScreenMode[12] = {0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0}; // numer ekranu wyświetlacza tekstowego -double Global::fSunDeclination = 0.0; // deklinacja Słońca -double Global::fTimeAngleDeg = 0.0; // godzina w postaci kąta -float Global::fClockAngleDeg[6]; // kąty obrotu cylindrów dla zegara cyfrowego -std::string Global::szTexturesTGA = ".tga"; // lista tekstur od TGA -std::string Global::szTexturesDDS = ".dds"; // lista tekstur od DDS -int Global::iKeyLast = 0; // ostatnio naciśnięty klawisz w celu logowania -GLuint Global::iTextureId = 0; // ostatnio użyta tekstura 2D -int Global::iPause = 0x10; // globalna pauza ruchu -bool Global::bActive = true; // czy jest aktywnym oknem -int Global::iErorrCounter = 0; // licznik sprawdzań do śledzenia błędów OpenGL -int Global::iTextures = 0; // licznik użytych tekstur -TWorld *Global::pWorld = NULL; -cParser *Global::pParser = NULL; -int Global::iSegmentsRendered = 90; // ilość segmentów do regulacji wydajności -TCamera *Global::pCamera = NULL; // parametry kamery -TDynamicObject *Global::pUserDynamic = NULL; // pojazd użytkownika, renderowany bez trzęsienia -bool Global::bSmudge = false; // czy wyświetlać smugę, a pojazd użytkownika na końcu -/* -std::string Global::asTranscript[5]; // napisy na ekranie (widoczne) -*/ -TTranscripts Global::tranTexts; // obiekt obsługujący stenogramy dźwięków na ekranie +void +global_settings::LoadIniFile(std::string asFileName) { -// parametry scenerii -vector3 Global::pCameraPosition; -double Global::pCameraRotation; -double Global::pCameraRotationDeg; -vector3 Global::pFreeCameraInit[10]; -vector3 Global::pFreeCameraInitAngle[10]; -double Global::fFogStart = 1700; -double Global::fFogEnd = 2000; -float Global::Background[3] = {0.2, 0.4, 0.33}; -GLfloat Global::AtmoColor[] = {0.423f, 0.702f, 1.0f}; -GLfloat Global::FogColor[] = {0.6f, 0.7f, 0.8f}; -GLfloat Global::ambientDayLight[] = {0.40f, 0.40f, 0.45f, 1.0f}; // robocze -GLfloat Global::diffuseDayLight[] = {0.55f, 0.54f, 0.50f, 1.0f}; -GLfloat Global::specularDayLight[] = {0.95f, 0.94f, 0.90f, 1.0f}; -GLfloat Global::ambientLight[] = {0.80f, 0.80f, 0.85f, 1.0f}; // stałe -GLfloat Global::diffuseLight[] = {0.85f, 0.85f, 0.80f, 1.0f}; -GLfloat Global::specularLight[] = {0.95f, 0.94f, 0.90f, 1.0f}; -GLfloat Global::whiteLight[] = {1.00f, 1.00f, 1.00f, 1.0f}; -GLfloat Global::noLight[] = {0.00f, 0.00f, 0.00f, 1.0f}; -GLfloat Global::darkLight[] = {0.03f, 0.03f, 0.03f, 1.0f}; //śladowe -GLfloat Global::lightPos[4]; -bool Global::bRollFix = true; // czy wykonać przeliczanie przechyłki -bool Global::bJoinEvents = false; // czy grupować eventy o tych samych nazwach -int Global::iHiddenEvents = 1; // czy łączyć eventy z torami poprzez nazwę toru - -// parametry użytkowe (jak komu pasuje) -int Global::Keys[MaxKeys]; -int Global::iWindowWidth = 800; -int Global::iWindowHeight = 600; -float Global::fDistanceFactor = 768.0; // baza do przeliczania odległości dla LoD -int Global::iFeedbackMode = 1; // tryb pracy informacji zwrotnej -int Global::iFeedbackPort = 0; // dodatkowy adres dla informacji zwrotnych -bool Global::bFreeFly = false; -bool Global::bFullScreen = false; -bool Global::bInactivePause = true; // automatyczna pauza, gdy okno nieaktywne -float Global::fMouseXScale = 1.5; -float Global::fMouseYScale = 0.2; -std::string Global::SceneryFile = "td.scn"; -std::string Global::asHumanCtrlVehicle = "EU07-424"; -int Global::iMultiplayer = 0; // blokada działania niektórych funkcji na rzecz komunikacji -double Global::fMoveLight = -1; // ruchome światło -double Global::fLatitudeDeg = 52.0; // szerokość geograficzna -float Global::fFriction = 1.0; // mnożnik tarcia - KURS90 -double Global::fBrakeStep = 1.0; // krok zmiany hamulca dla klawiszy [Num3] i [Num9] -std::string Global::asLang = "pl"; // domyślny język - http://tools.ietf.org/html/bcp47 - -// parametry wydajnościowe (np. regulacja FPS, szybkość wczytywania) -bool Global::bAdjustScreenFreq = true; -bool Global::bEnableTraction = true; -bool Global::bLoadTraction = true; -bool Global::bLiveTraction = true; -int Global::iDefaultFiltering = 9; // domyślne rozmywanie tekstur TGA bez alfa -int Global::iBallastFiltering = 9; // domyślne rozmywanie tekstur podsypki -int Global::iRailProFiltering = 5; // domyślne rozmywanie tekstur szyn -int Global::iDynamicFiltering = 5; // domyślne rozmywanie tekstur pojazdów -bool Global::bUseVBO = false; // czy jest VBO w karcie graficznej (czy użyć) -GLint Global::iMaxTextureSize = 16384; // maksymalny rozmiar tekstury -bool Global::bSmoothTraction = false; // wygładzanie drutów starym sposobem -std::string Global::szDefaultExt = Global::szTexturesDDS; // domyślnie od DDS -int Global::iMultisampling = 2; // tryb antyaliasingu: 0=brak,1=2px,2=4px,3=8px,4=16px -bool Global::bGlutFont = false; // czy tekst generowany przez GLUT32.DLL -int Global::iConvertModels = 7; // tworzenie plików binarnych, +2-optymalizacja transformów -int Global::iSlowMotionMask = -1; // maska wyłączanych właściwości dla zwiększenia FPS -int Global::iModifyTGA = 7; // czy korygować pliki TGA dla szybszego wczytywania -// bool Global::bTerrainCompact=true; //czy zapisać teren w pliku -TAnimModel *Global::pTerrainCompact = NULL; // do zapisania terenu w pliku -std::string Global::asTerrainModel = ""; // nazwa obiektu terenu do zapisania w pliku -double Global::fFpsAverage = 20.0; // oczekiwana wartosć FPS -double Global::fFpsDeviation = 5.0; // odchylenie standardowe FPS -double Global::fFpsMin = 0.0; // dolna granica FPS, przy której promień scenerii będzie zmniejszany -double Global::fFpsMax = 0.0; // górna granica FPS, przy której promień scenerii będzie zwiększany -double Global::fFpsRadiusMax = 3000.0; // maksymalny promień renderowania -int Global::iFpsRadiusMax = 225; // maksymalny promień renderowania -double Global::fRadiusFactor = 1.1; // współczynnik jednorazowej zmiany promienia scenerii -bool Global::bOldSmudge = false; // Używanie starej smugi - -// parametry testowe (do testowania scenerii i obiektów) -bool Global::bWireFrame = false; -bool Global::bSoundEnabled = true; -int Global::iWriteLogEnabled = 3; // maska bitowa: 1-zapis do pliku, 2-okienko, 4-nazwy torów -bool Global::bManageNodes = true; -bool Global::bDecompressDDS = false; // czy programowa dekompresja DDS - -// parametry do kalibracji -// kolejno współczynniki dla potęg 0, 1, 2, 3 wartości odczytanej z urządzenia -double Global::fCalibrateIn[6][6] = {{0, 1, 0, 0, 0, 0}, - {0, 1, 0, 0, 0, 0}, - {0, 1, 0, 0, 0, 0}, - {0, 1, 0, 0, 0, 0}, - {0, 1, 0, 0, 0, 0}, - {0, 1, 0, 0, 0, 0}}; -double Global::fCalibrateOut[7][6] = {{0, 1, 0, 0, 0, 0}, - {0, 1, 0, 0, 0, 0}, - {0, 1, 0, 0, 0, 0}, - {0, 1, 0, 0, 0, 0}, - {0, 1, 0, 0, 0, 0}, - {0, 1, 0, 0, 0, 0}, - {0, 1, 0, 0, 0, 0}}; -double Global::fCalibrateOutMax[7] = {0, 0, 0, 0, 0, 0, 0}; -int Global::iCalibrateOutDebugInfo = -1; -int Global::iPoKeysPWM[7] = {0, 1, 2, 3, 4, 5, 6}; -// parametry przejściowe (do usunięcia) -// bool Global::bTimeChange=false; //Ra: ZiomalCl wyłączył starą wersję nocy -// bool Global::bRenderAlpha=true; //Ra: wywaliłam tę flagę -bool Global::bnewAirCouplers = true; -bool Global::bDoubleAmbient = false; // podwójna jasność ambient -double Global::fTimeSpeed = 1.0; // przyspieszenie czasu, zmienna do testów -bool Global::bHideConsole = false; // hunter-271211: ukrywanie konsoli -int Global::iBpp = 32; // chyba już nie używa się kart, na których 16bpp coś poprawi -//randomizacja -std::mt19937 Global::random_engine = std::mt19937(std::time(NULL)); -// maciek001: konfiguracja wstępna portu COM -bool Global::bMWDmasterEnable = false; // główne włączenie portu! -bool Global::bMWDdebugEnable = false; // włącz dodawanie do logu -int Global::iMWDDebugMode = 0; // co ma wyświetlać w logu -std::string Global::sMWDPortId = "COM1"; // nazwa portu z którego korzystamy -unsigned long int Global::iMWDBaudrate = 9600; // prędkość transmisji danych -bool Global::bMWDInputEnable = false; // włącz wejścia -bool Global::bMWDBreakEnable = false; // włącz wejścia analogowe -double Global::fMWDAnalogInCalib[4][2] = { { 0, 1023 },{ 0, 1023 },{ 0, 1023 },{ 0, 1023 } }; // wartość max potencjometru, wartość min potencjometru, rozdzielczość (max. wartość jaka może być) -double Global::fMWDzg[2] = { 0.9, 1023 }; -double Global::fMWDpg[2] = { 0.8, 1023 }; -double Global::fMWDph[2] = { 0.6, 1023 }; -double Global::fMWDvolt[2] = { 4000, 1023 }; -double Global::fMWDamp[2] = { 800, 1023 }; -int Global::iMWDdivider = 5; - -//--------------------------------------------------------------------------- -//--------------------------------------------------------------------------- -//--------------------------------------------------------------------------- - -std::string Global::GetNextSymbol() -{ // pobranie tokenu z aktualnego parsera - - std::string token; - if (pParser != nullptr) - { - - pParser->getTokens(); - *pParser >> token; - }; - return token; -}; - -void Global::LoadIniFile(std::string asFileName) -{ - for (int i = 0; i < 10; ++i) - { // zerowanie pozycji kamer - pFreeCameraInit[i] = vector3(0, 0, 0); // współrzędne w scenerii - pFreeCameraInitAngle[i] = vector3(0, 0, 0); // kąty obrotu w radianach - } cParser parser(asFileName, cParser::buffer_FILE); ConfigParse(parser); }; -void Global::ConfigParse(cParser &Parser) -{ +void +global_settings::ConfigParse(cParser &Parser) { std::string token; do @@ -249,77 +45,89 @@ void Global::ConfigParse(cParser &Parser) { Parser.getTokens(); - Parser >> Global::SceneryFile; + Parser >> SceneryFile; } else if (token == "humanctrlvehicle") { Parser.getTokens(); - Parser >> Global::asHumanCtrlVehicle; + Parser >> asHumanCtrlVehicle; + } + else if( token == "fieldofview" ) { + + Parser.getTokens( 1, false ); + Parser >> FieldOfView; + // guard against incorrect values + FieldOfView = clamp( FieldOfView, 15.0f, 75.0f ); } else if (token == "width") { Parser.getTokens(1, false); - Parser >> Global::iWindowWidth; + Parser >> iWindowWidth; } else if (token == "height") { Parser.getTokens(1, false); - Parser >> Global::iWindowHeight; + Parser >> iWindowHeight; } else if (token == "heightbase") { Parser.getTokens(1, false); - Parser >> Global::fDistanceFactor; - } - else if (token == "bpp") - { - - Parser.getTokens(); - Parser >> token; - Global::iBpp = (token == "32" ? 32 : 16); + Parser >> fDistanceFactor; } else if (token == "fullscreen") { Parser.getTokens(); - Parser >> token; - Global::bFullScreen = (token == "yes"); + Parser >> bFullScreen; + } + else if( token == "vsync" ) { + + Parser.getTokens(); + Parser >> VSync; } else if (token == "freefly") { // Mczapkie-130302 Parser.getTokens(); - Parser >> token; - Global::bFreeFly = (token == "yes"); + Parser >> FreeFlyModeFlag; Parser.getTokens(3, false); - Parser >> Global::pFreeCameraInit[0].x, Global::pFreeCameraInit[0].y, - Global::pFreeCameraInit[0].z; + Parser >> + FreeCameraInit[0].x, + FreeCameraInit[0].y, + FreeCameraInit[0].z; } else if (token == "wireframe") { Parser.getTokens(); - Parser >> token; - Global::bWireFrame = (token == "yes"); + Parser >> bWireFrame; } else if (token == "debugmode") { // McZapkie! - DebugModeFlag uzywana w mover.pas, // warto tez blokowac cheaty gdy false Parser.getTokens(); - Parser >> token; - DebugModeFlag = (token == "yes"); + Parser >> DebugModeFlag; } else if (token == "soundenabled") { // McZapkie-040302 - blokada dzwieku - przyda // sie do debugowania oraz na komp. bez karty // dzw. Parser.getTokens(); - Parser >> token; - Global::bSoundEnabled = (token == "yes"); + Parser >> bSoundEnabled; + } + else if( token == "sound.openal.renderer" ) { + // selected device for audio renderer + AudioRenderer = Parser.getToken( false ); // case-sensitive + } + else if( token == "sound.volume" ) { + // selected device for audio renderer + Parser.getTokens(); + Parser >> AudioVolume; + AudioVolume = clamp( AudioVolume, 0.0f, 2.f ); } // else if (str==AnsiString("renderalpha")) //McZapkie-1312302 - dwuprzebiegowe renderowanie // bRenderAlpha=(GetNextSymbol().LowerCase()==AnsiString("yes")); @@ -327,15 +135,13 @@ void Global::ConfigParse(cParser &Parser) { // McZapkie-030402 - logowanie parametrow // fizycznych dla kazdego pojazdu z maszynista Parser.getTokens(); - Parser >> token; - WriteLogFlag = (token == "yes"); + Parser >> WriteLogFlag; } - else if (token == "physicsdeactivation") + else if (token == "fullphysics") { // McZapkie-291103 - usypianie fizyki Parser.getTokens(); - Parser >> token; - PhysicActivationFlag = (token == "yes"); + Parser >> FullPhysics; } else if (token == "debuglog") { @@ -344,78 +150,73 @@ void Global::ConfigParse(cParser &Parser) Parser >> token; if (token == "yes") { - Global::iWriteLogEnabled = 3; + iWriteLogEnabled = 3; } else if (token == "no") { - Global::iWriteLogEnabled = 0; + iWriteLogEnabled = 0; } else { - Global::iWriteLogEnabled = stol_def(token,3); + iWriteLogEnabled = stol_def(token,3); } } - else if (token == "adjustscreenfreq") + else if( token == "multiplelogs" ) { + Parser.getTokens(); + Parser >> MultipleLogs; + } + else if( token == "logs.filter" ) { + Parser.getTokens(); + Parser >> DisabledLogTypes; + } + else if( token == "adjustscreenfreq" ) { // McZapkie-240403 - czestotliwosc odswiezania ekranu Parser.getTokens(); - Parser >> token; - Global::bAdjustScreenFreq = (token == "yes"); + Parser >> bAdjustScreenFreq; } else if (token == "mousescale") { // McZapkie-060503 - czulosc ruchu myszy (krecenia glowa) Parser.getTokens(2, false); - Parser >> Global::fMouseXScale >> Global::fMouseYScale; + Parser >> fMouseXScale >> fMouseYScale; + } + else if( token == "mousecontrol" ) { + // whether control pick mode can be activated + Parser.getTokens(); + Parser >> InputMouse; } else if (token == "enabletraction") { // Winger 040204 - 'zywe' patyki dostosowujace sie do trakcji; Ra 2014-03: teraz łamanie Parser.getTokens(); - Parser >> token; - Global::bEnableTraction = (token == "yes"); + Parser >> bEnableTraction; } else if (token == "loadtraction") { // Winger 140404 - ladowanie sie trakcji Parser.getTokens(); - Parser >> token; - Global::bLoadTraction = (token == "yes"); + Parser >> bLoadTraction; } else if (token == "friction") { // mnożnik tarcia - KURS90 Parser.getTokens(1, false); - Parser >> Global::fFriction; + Parser >> fFriction; } else if (token == "livetraction") { // Winger 160404 - zaleznosc napiecia loka od trakcji; // Ra 2014-03: teraz prąd przy braku sieci Parser.getTokens(); - Parser >> token; - Global::bLiveTraction = (token == "yes"); + Parser >> bLiveTraction; } else if (token == "skyenabled") { // youBy - niebo Parser.getTokens(); Parser >> token; - Global::asSky = (token == "yes" ? "1" : "0"); - } - else if (token == "managenodes") - { - - Parser.getTokens(); - Parser >> token; - Global::bManageNodes = (token == "yes"); - } - else if (token == "decompressdds") - { - - Parser.getTokens(); - Parser >> token; - Global::bDecompressDDS = (token == "yes"); + asSky = (token == "yes" ? "1" : "0"); } else if (token == "defaultext") { @@ -425,10 +226,10 @@ void Global::ConfigParse(cParser &Parser) if (token == "tga") { // domyślnie od TGA - Global::szDefaultExt = Global::szTexturesTGA; + szDefaultExt = szTexturesTGA; } else { - Global::szDefaultExt = + szDefaultExt = ( token[ 0 ] == '.' ? token : "." + token ); @@ -438,57 +239,36 @@ void Global::ConfigParse(cParser &Parser) { Parser.getTokens(); - Parser >> token; - Global::bnewAirCouplers = (token == "yes"); + Parser >> bnewAirCouplers; } - else if (token == "defaultfiltering") - { + else if( token == "anisotropicfiltering" ) { - Parser.getTokens(1, false); - Parser >> Global::iDefaultFiltering; + Parser.getTokens( 1, false ); + Parser >> AnisotropicFiltering; } - else if (token == "ballastfiltering") - { - - Parser.getTokens(1, false); - Parser >> Global::iBallastFiltering; - } - else if (token == "railprofiltering") - { - - Parser.getTokens(1, false); - Parser >> Global::iRailProFiltering; - } - else if (token == "dynamicfiltering") - { - - Parser.getTokens(1, false); - Parser >> Global::iDynamicFiltering; - } - else if (token == "usevbo") + else if( token == "usevbo" ) { Parser.getTokens(); - Parser >> token; - Global::bUseVBO = (token == "yes"); + Parser >> bUseVBO; } else if (token == "feedbackmode") { Parser.getTokens(1, false); - Parser >> Global::iFeedbackMode; + Parser >> iFeedbackMode; } else if (token == "feedbackport") { Parser.getTokens(1, false); - Parser >> Global::iFeedbackPort; + Parser >> iFeedbackPort; } else if (token == "multiplayer") { Parser.getTokens(1, false); - Parser >> Global::iMultiplayer; + Parser >> iMultiplayer; } else if (token == "maxtexturesize") { @@ -496,169 +276,184 @@ void Global::ConfigParse(cParser &Parser) Parser.getTokens(1, false); int size; Parser >> size; - if (size <= 64) - { - Global::iMaxTextureSize = 64; - } - else if (size <= 128) - { - Global::iMaxTextureSize = 128; - } - else if (size <= 256) - { - Global::iMaxTextureSize = 256; - } - else if (size <= 512) - { - Global::iMaxTextureSize = 512; - } - else if (size <= 1024) - { - Global::iMaxTextureSize = 1024; - } - else if (size <= 2048) - { - Global::iMaxTextureSize = 2048; - } - else if (size <= 4096) - { - Global::iMaxTextureSize = 4096; - } - else if (size <= 8192) - { - Global::iMaxTextureSize = 8192; - } - else - { - Global::iMaxTextureSize = 16384; - } - } - else if (token == "doubleambient") - { - // podwójna jasność ambient - Parser.getTokens(); - Parser >> token; - Global::bDoubleAmbient = (token == "yes"); + if (size <= 64) { iMaxTextureSize = 64; } + else if (size <= 128) { iMaxTextureSize = 128; } + else if (size <= 256) { iMaxTextureSize = 256; } + else if (size <= 512) { iMaxTextureSize = 512; } + else if (size <= 1024) { iMaxTextureSize = 1024; } + else if (size <= 2048) { iMaxTextureSize = 2048; } + else if (size <= 4096) { iMaxTextureSize = 4096; } + else if (size <= 8192) { iMaxTextureSize = 8192; } + else { iMaxTextureSize = 16384; } } else if (token == "movelight") { // numer dnia w roku albo -1 Parser.getTokens(1, false); - Parser >> Global::fMoveLight; - if (Global::fMoveLight == 0.f) + Parser >> fMoveLight; + if (fMoveLight == 0.f) { // pobranie daty z systemu std::time_t timenow = std::time(0); std::tm *localtime = std::localtime(&timenow); - Global::fMoveLight = localtime->tm_yday + 1; // numer bieżącego dnia w roku + fMoveLight = localtime->tm_yday + 1; // numer bieżącego dnia w roku } - if (fMoveLight > 0.f) // tu jest nadal zwiększone o 1 - { // obliczenie deklinacji wg: - // http://naturalfrequency.com/Tregenza_Sharples/Daylight_Algorithms/algorithm_1_11.htm - // Spencer J W Fourier series representation of the position of the sun Search 2 (5) - // 172 (1971) - Global::fMoveLight = - M_PI / 182.5 * (Global::fMoveLight - 1.0); // numer dnia w postaci kąta - fSunDeclination = - 0.006918 - 0.3999120 * std::cos(fMoveLight) + 0.0702570 * std::sin(fMoveLight) - - 0.0067580 * std::cos(2 * fMoveLight) + 0.0009070 * std::sin(2 * fMoveLight) - - 0.0026970 * std::cos(3 * fMoveLight) + 0.0014800 * std::sin(3 * fMoveLight); + simulation::Environment.compute_season( fMoveLight ); + } + else if( token == "dynamiclights" ) { + // number of dynamic lights in the scene + Parser.getTokens( 1, false ); + Parser >> DynamicLightCount; + // clamp the light number + // max 8 lights per opengl specs, minus one used for sun. at least one light for controlled vehicle + DynamicLightCount = clamp( DynamicLightCount, 1, 7 ); + } + else if( token == "scenario.time.override" ) { + // shift (in hours) applied to train timetables + Parser.getTokens( 1, false ); + Parser >> ScenarioTimeOverride; + ScenarioTimeOverride = clamp( ScenarioTimeOverride, 0.f, 24 * 1439 / 1440.f ); + } + else if( token == "scenario.time.offset" ) { + // shift (in hours) applied to train timetables + Parser.getTokens( 1, false ); + Parser >> ScenarioTimeOffset; + } + else if( token == "scenario.time.current" ) { + // sync simulation time with local clock + Parser.getTokens( 1, false ); + Parser >> ScenarioTimeCurrent; + } + else if( token == "scenario.weather.temperature" ) { + // selected device for audio renderer + Parser.getTokens(); + Parser >> AirTemperature; + if( false == DebugModeFlag ) { + AirTemperature = clamp( AirTemperature, -15.f, 45.f ); } } + else if( token == "scalespeculars" ) { + // whether strength of specular highlights should be adjusted (generally needed for legacy 3d models) + Parser.getTokens(); + Parser >> ScaleSpecularValues; + } + else if( token == "gfxrenderer" ) { + // shadow render toggle + std::string gfxrenderer; + Parser.getTokens(); + Parser >> gfxrenderer; + BasicRenderer = ( gfxrenderer == "simple" ); + } + else if( token == "shadows" ) { + // shadow render toggle + Parser.getTokens(); + Parser >> RenderShadows; + } + else if( token == "shadowtune" ) { + Parser.getTokens( 4, false ); + Parser + >> shadowtune.map_size + >> shadowtune.width + >> shadowtune.depth + >> shadowtune.distance; + } else if (token == "smoothtraction") { // podwójna jasność ambient Parser.getTokens(); - Parser >> token; - Global::bSmoothTraction = (token == "yes"); + Parser >> bSmoothTraction; + } + else if( token == "splinefidelity" ) { + // segment size during spline->geometry conversion + float splinefidelity; + Parser.getTokens(); + Parser >> splinefidelity; + SplineFidelity = clamp( splinefidelity, 1.f, 4.f ); + } + else if( token == "createswitchtrackbeds" ) { + // podwójna jasność ambient + Parser.getTokens(); + Parser >> CreateSwitchTrackbeds; + } + else if( token == "gfx.resource.sweep" ) { + + Parser.getTokens(); + Parser >> ResourceSweep; + } + else if( token == "gfx.resource.move" ) { + + Parser.getTokens(); + Parser >> ResourceMove; } else if (token == "timespeed") { // przyspieszenie czasu, zmienna do testów Parser.getTokens(1, false); - Parser >> Global::fTimeSpeed; + Parser >> fTimeSpeed; } else if (token == "multisampling") { // tryb antyaliasingu: 0=brak,1=2px,2=4px Parser.getTokens(1, false); - Parser >> Global::iMultisampling; + Parser >> iMultisampling; } else if (token == "glutfont") { // tekst generowany przez GLUT Parser.getTokens(); - Parser >> token; - Global::bGlutFont = (token == "yes"); + Parser >> bGlutFont; } else if (token == "latitude") { // szerokość geograficzna Parser.getTokens(1, false); - Parser >> Global::fLatitudeDeg; + Parser >> fLatitudeDeg; } else if (token == "convertmodels") { // tworzenie plików binarnych Parser.getTokens(1, false); - Parser >> Global::iConvertModels; + Parser >> iConvertModels; + // temporary override, to prevent generation of .e3d not compatible with old exe + iConvertModels = + ( iConvertModels > 128 ? + iConvertModels - 128 : + 0 ); } else if (token == "inactivepause") { // automatyczna pauza, gdy okno nieaktywne Parser.getTokens(); - Parser >> token; - Global::bInactivePause = (token == "yes"); + Parser >> bInactivePause; } else if (token == "slowmotion") { // tworzenie plików binarnych Parser.getTokens(1, false); - Parser >> Global::iSlowMotionMask; - } - else if (token == "modifytga") - { - // czy korygować pliki TGA dla szybszego wczytywania - Parser.getTokens(1, false); - Parser >> Global::iModifyTGA; + Parser >> iSlowMotionMask; } else if (token == "hideconsole") { // hunter-271211: ukrywanie konsoli Parser.getTokens(); - Parser >> token; - Global::bHideConsole = (token == "yes"); - } - else if (token == "oldsmudge") - { - - Parser.getTokens(); - Parser >> token; - Global::bOldSmudge = (token == "yes"); + Parser >> bHideConsole; } else if (token == "rollfix") { // Ra: poprawianie przechyłki, aby wewnętrzna szyna była "pozioma" Parser.getTokens(); - Parser >> token; - Global::bRollFix = (token == "yes"); + Parser >> bRollFix; } else if (token == "fpsaverage") { // oczekiwana wartość FPS Parser.getTokens(1, false); - Parser >> Global::fFpsAverage; + Parser >> fFpsAverage; } else if (token == "fpsdeviation") { // odchylenie standardowe FPS Parser.getTokens(1, false); - Parser >> Global::fFpsDeviation; - } - else if (token == "fpsradiusmax") - { - // maksymalny promień renderowania - Parser.getTokens(1, false); - Parser >> Global::fFpsRadiusMax; + Parser >> fFpsDeviation; } else if (token == "calibratein") { @@ -671,12 +466,13 @@ void Global::ConfigParse(cParser &Parser) in = 5; // na ostatni, bo i tak trzeba pominąć wartości } Parser.getTokens(4, false); - Parser >> Global::fCalibrateIn[in][0] // wyraz wolny - >> Global::fCalibrateIn[in][1] // mnożnik - >> Global::fCalibrateIn[in][2] // mnożnik dla kwadratu - >> Global::fCalibrateIn[in][3]; // mnożnik dla sześcianu - Global::fCalibrateIn[in][4] = 0.0; // mnożnik 4 potęgi - Global::fCalibrateIn[in][5] = 0.0; // mnożnik 5 potęgi + Parser + >> fCalibrateIn[in][0] // wyraz wolny + >> fCalibrateIn[in][1] // mnożnik + >> fCalibrateIn[in][2] // mnożnik dla kwadratu + >> fCalibrateIn[in][3]; // mnożnik dla sześcianu + fCalibrateIn[in][4] = 0.0; // mnożnik 4 potęgi + fCalibrateIn[in][5] = 0.0; // mnożnik 5 potęgi } else if (token == "calibrate5din") { @@ -689,12 +485,12 @@ void Global::ConfigParse(cParser &Parser) in = 5; // na ostatni, bo i tak trzeba pominąć wartości } Parser.getTokens(6, false); - Parser >> Global::fCalibrateIn[in][0] // wyraz wolny - >> Global::fCalibrateIn[in][1] // mnożnik - >> Global::fCalibrateIn[in][2] // mnożnik dla kwadratu - >> Global::fCalibrateIn[in][3] // mnożnik dla sześcianu - >> Global::fCalibrateIn[in][4] // mnożnik 4 potęgi - >> Global::fCalibrateIn[in][5]; // mnożnik 5 potęgi + Parser >> fCalibrateIn[in][0] // wyraz wolny + >> fCalibrateIn[in][1] // mnożnik + >> fCalibrateIn[in][2] // mnożnik dla kwadratu + >> fCalibrateIn[in][3] // mnożnik dla sześcianu + >> fCalibrateIn[in][4] // mnożnik 4 potęgi + >> fCalibrateIn[in][5]; // mnożnik 5 potęgi } else if (token == "calibrateout") { @@ -707,12 +503,12 @@ void Global::ConfigParse(cParser &Parser) out = 6; // na ostatni, bo i tak trzeba pominąć wartości } Parser.getTokens(4, false); - Parser >> Global::fCalibrateOut[out][0] // wyraz wolny - >> Global::fCalibrateOut[out][1] // mnożnik liniowy - >> Global::fCalibrateOut[out][2] // mnożnik dla kwadratu - >> Global::fCalibrateOut[out][3]; // mnożnik dla sześcianu - Global::fCalibrateOut[out][4] = 0.0; // mnożnik dla 4 potęgi - Global::fCalibrateOut[out][5] = 0.0; // mnożnik dla 5 potęgi + Parser >> fCalibrateOut[out][0] // wyraz wolny + >> fCalibrateOut[out][1] // mnożnik liniowy + >> fCalibrateOut[out][2] // mnożnik dla kwadratu + >> fCalibrateOut[out][3]; // mnożnik dla sześcianu + fCalibrateOut[out][4] = 0.0; // mnożnik dla 4 potęgi + fCalibrateOut[out][5] = 0.0; // mnożnik dla 5 potęgi } else if (token == "calibrate5dout") { @@ -725,27 +521,27 @@ void Global::ConfigParse(cParser &Parser) out = 6; // na ostatni, bo i tak trzeba pominąć wartości } Parser.getTokens(6, false); - Parser >> Global::fCalibrateOut[out][0] // wyraz wolny - >> Global::fCalibrateOut[out][1] // mnożnik liniowy - >> Global::fCalibrateOut[out][2] // mnożnik dla kwadratu - >> Global::fCalibrateOut[out][3] // mnożnik dla sześcianu - >> Global::fCalibrateOut[out][4] // mnożnik dla 4 potęgi - >> Global::fCalibrateOut[out][5]; // mnożnik dla 5 potęgi + Parser >> fCalibrateOut[out][0] // wyraz wolny + >> fCalibrateOut[out][1] // mnożnik liniowy + >> fCalibrateOut[out][2] // mnożnik dla kwadratu + >> fCalibrateOut[out][3] // mnożnik dla sześcianu + >> fCalibrateOut[out][4] // mnożnik dla 4 potęgi + >> fCalibrateOut[out][5]; // mnożnik dla 5 potęgi } else if (token == "calibrateoutmaxvalues") { // maksymalne wartości jakie można wyświetlić na mierniku Parser.getTokens(7, false); - Parser >> Global::fCalibrateOutMax[0] >> Global::fCalibrateOutMax[1] >> - Global::fCalibrateOutMax[2] >> Global::fCalibrateOutMax[3] >> - Global::fCalibrateOutMax[4] >> Global::fCalibrateOutMax[5] >> - Global::fCalibrateOutMax[6]; + Parser >> fCalibrateOutMax[0] >> fCalibrateOutMax[1] >> + fCalibrateOutMax[2] >> fCalibrateOutMax[3] >> + fCalibrateOutMax[4] >> fCalibrateOutMax[5] >> + fCalibrateOutMax[6]; } else if (token == "calibrateoutdebuginfo") { // wyjście z info o przebiegu kalibracji Parser.getTokens(1, false); - Parser >> Global::iCalibrateOutDebugInfo; + Parser >> iCalibrateOutDebugInfo; } else if (token == "pwm") { @@ -753,26 +549,25 @@ void Global::ConfigParse(cParser &Parser) Parser.getTokens(2, false); int pwm_out, pwm_no; Parser >> pwm_out >> pwm_no; - Global::iPoKeysPWM[pwm_out] = pwm_no; + iPoKeysPWM[pwm_out] = pwm_no; } else if (token == "brakestep") { // krok zmiany hamulca dla klawiszy [Num3] i [Num9] Parser.getTokens(1, false); - Parser >> Global::fBrakeStep; + Parser >> fBrakeStep; } else if (token == "joinduplicatedevents") { // czy grupować eventy o tych samych nazwach Parser.getTokens(); - Parser >> token; - Global::bJoinEvents = (token == "yes"); + Parser >> bJoinEvents; } else if (token == "hiddenevents") { // czy łączyć eventy z torami poprzez nazwę toru Parser.getTokens(1, false); - Parser >> Global::iHiddenEvents; + Parser >> iHiddenEvents; } else if (token == "pause") { @@ -785,118 +580,83 @@ void Global::ConfigParse(cParser &Parser) { // domyślny język - http://tools.ietf.org/html/bcp47 Parser.getTokens(1, false); - Parser >> Global::asLang; + Parser >> asLang; } - else if (token == "opengl") + else if( token == "pyscreenrendererpriority" ) { - // deklarowana wersja OpenGL, żeby powstrzymać błędy - Parser.getTokens(1, false); - Parser >> Global::fOpenGL; - } - else if (token == "pyscreenrendererpriority") - { - // priority of python screen renderer + // old variable, repurposed as update rate of python screen renderer Parser.getTokens(); Parser >> token; - TPythonInterpreter::getInstance()->setScreenRendererPriority(token.c_str()); + auto const priority { ToLower( token ) }; + PythonScreenUpdateRate = ( + priority == "lower" ? 500 : + priority == "lowest" ? 1000 : + 200 ); } - else if (token == "background") - { - - Parser.getTokens(3, false); - Parser >> Global::Background[0] // r - >> Global::Background[1] // g - >> Global::Background[2]; // b + else if( token == "uitextcolor" ) { + // color of the ui text. NOTE: will be obsolete once the real ui is in place + Parser.getTokens( 3, false ); + Parser + >> UITextColor.r + >> UITextColor.g + >> UITextColor.b; + glm::clamp( UITextColor, 0.f, 255.f ); + UITextColor = UITextColor / 255.f; + UITextColor.a = 1.f; + } + else if( token == "ui.bg.opacity" ) { + // czy grupować eventy o tych samych nazwach + Parser.getTokens(); + Parser >> UIBgOpacity; + UIBgOpacity = clamp( UIBgOpacity, 0.f, 1.f ); + } + else if( token == "input.gamepad" ) { + // czy grupować eventy o tych samych nazwach + Parser.getTokens(); + Parser >> InputGamepad; + } + else if( token == "uart" ) { + uart_conf.enable = true; + Parser.getTokens( 3, false ); + Parser + >> uart_conf.port + >> uart_conf.baud + >> uart_conf.updatetime; + } + else if( token == "uarttune" ) { + Parser.getTokens( 14 ); + Parser + >> uart_conf.mainbrakemin + >> uart_conf.mainbrakemax + >> uart_conf.localbrakemin + >> uart_conf.localbrakemax + >> uart_conf.tankmax + >> uart_conf.tankuart + >> uart_conf.pipemax + >> uart_conf.pipeuart + >> uart_conf.brakemax + >> uart_conf.brakeuart + >> uart_conf.hvmax + >> uart_conf.hvuart + >> uart_conf.currentmax + >> uart_conf.currentuart; + } + else if( token == "uartfeature" ) { + Parser.getTokens( 4 ); + Parser + >> uart_conf.mainenable + >> uart_conf.scndenable + >> uart_conf.trainenable + >> uart_conf.localenable; + } + else if( token == "uartdebug" ) { + Parser.getTokens( 1 ); + Parser >> uart_conf.debug; + } + else if( token == "compresstex" ) { + Parser.getTokens( 1 ); + Parser >> compress_tex; } - // maciek001: ustawienia MWD - else if (token == "mwdmasterenable") { // główne włączenie maszyny! - Parser.getTokens(); - Parser >> token; - bMWDmasterEnable = (token == "yes"); - if (bMWDdebugEnable) WriteLog("SerialPort Master Enable"); - } - else if (token == "mwddebugenable") { // logowanie pracy - Parser.getTokens(); - Parser >> token; - bMWDdebugEnable = (token == "yes"); - if (bMWDdebugEnable) WriteLog("MWD Debug Mode On"); - } - else if (token == "mwddebugmode") { // co ma być debugowane? - Parser.getTokens(1, false); - Parser >> iMWDDebugMode; - if (bMWDdebugEnable) WriteLog("Debug Mode = " + to_string(iMWDDebugMode)); - } - else if (token == "mwdcomportname") { // nazwa portu COM - Parser.getTokens(); - Parser >> sMWDPortId; - if (bMWDdebugEnable) WriteLog("PortName " + sMWDPortId); - } - else if (token == "mwdbaudrate") { // prędkość transmisji danych - Parser.getTokens(1, false); - Parser >> iMWDBaudrate; - if (bMWDdebugEnable) WriteLog("Baud rate = " + to_string((int)(iMWDBaudrate / 1000)) + (" kbps")); - } - else if (token == "mwdinputenable") { // włącz wejścia - Parser.getTokens(); - Parser >> token; - bMWDInputEnable = (token == "yes"); - if (bMWDdebugEnable && bMWDInputEnable) WriteLog("MWD Input Enable"); - } - else if (token == "mwdbreakenable") { // włącz obsługę hamulców - Parser.getTokens(); - Parser >> token; - bMWDBreakEnable = (token == "yes"); - if (bMWDdebugEnable && bMWDBreakEnable) WriteLog("MWD Break Enable"); - } - else if (token == "mwdmainbreakconfig") { // ustawienia hamulca zespolonego - Parser.getTokens(2, false); - Parser >> fMWDAnalogInCalib[0][0] >> fMWDAnalogInCalib[0][1]; - if (bMWDdebugEnable) WriteLog("Main break settings: " + to_string(fMWDAnalogInCalib[0][0]) + (" ") + to_string(fMWDAnalogInCalib[0][1])); - } - else if (token == "mwdlocbreakconfig") { // ustawienia hamulca lokomotywy - Parser.getTokens(2, false); - Parser >> fMWDAnalogInCalib[1][0] >> fMWDAnalogInCalib[1][1]; - if (bMWDdebugEnable) WriteLog("Locomotive break settings: " + to_string(fMWDAnalogInCalib[1][0]) + to_string(" ") + to_string(fMWDAnalogInCalib[1][1])); - } - else if (token == "mwdanalogin1config") { // ustawienia hamulca zespolonego - Parser.getTokens(2, false); - Parser >> fMWDAnalogInCalib[2][0] >> fMWDAnalogInCalib[2][1]; - if (bMWDdebugEnable) WriteLog("Analog input 1 settings: " + to_string(fMWDAnalogInCalib[2][0]) + to_string(" ") + to_string(fMWDAnalogInCalib[2][1])); - } - else if (token == "mwdanalogin2config") { // ustawienia hamulca lokomotywy - Parser.getTokens(2, false); - Parser >> fMWDAnalogInCalib[3][0] >> fMWDAnalogInCalib[3][1]; - if (bMWDdebugEnable) WriteLog("Analog input 2 settings: " + to_string(fMWDAnalogInCalib[3][0]) + to_string(" ") + to_string(fMWDAnalogInCalib[3][1])); - } - else if (token == "mwdmaintankpress") { // max ciśnienie w zbiorniku głownym i rozdzielczość - Parser.getTokens(2, false); - Parser >> fMWDzg[0] >> fMWDzg[1]; - if (bMWDdebugEnable) WriteLog("MainAirTank settings: " + to_string(fMWDzg[0]) + to_string(" ") + to_string(fMWDzg[1])); - } - else if (token == "mwdmainpipepress") { // max ciśnienie w przewodzie głownym i rozdzielczość - Parser.getTokens(2, false); - Parser >> fMWDpg[0] >> fMWDpg[1]; - if (bMWDdebugEnable) WriteLog("MainAirPipe settings: " + to_string(fMWDpg[0]) + to_string(" ") + to_string(fMWDpg[1])); - } - else if (token == "mwdbreakpress") { // max ciśnienie w hamulcach i rozdzielczość - Parser.getTokens(2, false); - Parser >> fMWDph[0] >> fMWDph[1]; - if (bMWDdebugEnable) WriteLog("AirPipe settings: " + to_string(fMWDph[0]) + to_string(" ") + to_string(fMWDph[1])); - } - else if (token == "mwdhivoltmeter") { // max napięcie na woltomierzu WN - Parser.getTokens(2, false); - Parser >> fMWDvolt[0] >> fMWDvolt[1]; - if (bMWDdebugEnable) WriteLog("VoltMeter settings: " + to_string(fMWDvolt[0]) + to_string(" ") + to_string(fMWDvolt[1])); - } - else if (token == "mwdhiampmeter") { - Parser.getTokens(2, false); - Parser >> fMWDamp[0] >> fMWDamp[1]; - if (bMWDdebugEnable) WriteLog("Amp settings: " + to_string(fMWDamp[0]) + to_string(" ") + to_string(fMWDamp[1])); - } - else if (token == "mwddivider") { - Parser.getTokens(1, false); - Parser >> iMWDdivider; - } } while ((token != "") && (token != "endconfig")); //(!Parser->EndOfFile) // na koniec trochę zależności if (!bLoadTraction) // wczytywanie drutów i słupów @@ -904,8 +664,6 @@ void Global::ConfigParse(cParser &Parser) bEnableTraction = false; // false = pantograf się nie połamie bLiveTraction = false; // false = pantografy zawsze zbierają 95% MaxVoltage } - // if (fMoveLight>0) bDoubleAmbient=false; //wtedy tylko jedno światło ruchome - // if (fOpenGL<1.3) iMultisampling=0; //można by z góry wyłączyć, ale nie mamy jeszcze fOpenGL if (iMultisampling) { // antyaliasing całoekranowy wyłącza rozmywanie drutów bSmoothTraction = false; @@ -916,18 +674,22 @@ void Global::ConfigParse(cParser &Parser) // pauzowanie jest zablokowane dla (iMultiplayer&2)>0, więc iMultiplayer=1 da się zapauzować // (tryb instruktora) } +/* fFpsMin = fFpsAverage - fFpsDeviation; // dolna granica FPS, przy której promień scenerii będzie zmniejszany fFpsMax = fFpsAverage + fFpsDeviation; // górna granica FPS, przy której promień scenerii będzie zwiększany +*/ if (iPause) - iTextMode = VK_F1; // jak pauza, to pokazać zegar + iTextMode = GLFW_KEY_F1; // jak pauza, to pokazać zegar /* this won't execute anymore with the old parser removed // TBD: remove, or launch depending on passed flag? if (qp) - { // to poniżej wykonywane tylko raz, jedynie po wczytaniu eu07.ini - Console::ModeSet(iFeedbackMode, iFeedbackPort); // tryb pracy konsoli sterowniczej - iFpsRadiusMax = 0.000025 * fFpsRadiusMax * + { // to poniżej wykonywane tylko raz, jedynie po wczytaniu eu07.ini*/ +#ifdef _WIN32 + Console::ModeSet(iFeedbackMode, iFeedbackPort); // tryb pracy konsoli sterowniczej +#endif + /*iFpsRadiusMax = 0.000025 * fFpsRadiusMax * fFpsRadiusMax; // maksymalny promień renderowania 3000.0 -> 225 if (iFpsRadiusMax > 400) iFpsRadiusMax = 400; @@ -943,403 +705,3 @@ void Global::ConfigParse(cParser &Parser) } */ } - -void Global::InitKeys(std::string asFileName) -{ - // if (FileExists(asFileName)) - // { - // Error("Chwilowo plik keys.ini nie jest obsługiwany. Ładuję standardowe - // ustawienia.\nKeys.ini file is temporarily not functional, loading default keymap..."); - /* TQueryParserComp *Parser; - Parser=new TQueryParserComp(NULL); - Parser->LoadStringToParse(asFileName); - - for (int keycount=0; keycountGetNextSymbol().ToInt(); - } - - delete Parser; - */ - // } - // else - { - Keys[k_IncMainCtrl] = VK_ADD; - Keys[k_IncMainCtrlFAST] = VK_ADD; - Keys[k_DecMainCtrl] = VK_SUBTRACT; - Keys[k_DecMainCtrlFAST] = VK_SUBTRACT; - Keys[k_IncScndCtrl] = VK_DIVIDE; - Keys[k_IncScndCtrlFAST] = VK_DIVIDE; - Keys[k_DecScndCtrl] = VK_MULTIPLY; - Keys[k_DecScndCtrlFAST] = VK_MULTIPLY; - ///*NORMALNE - Keys[k_IncLocalBrakeLevel] = VK_NUMPAD1; // VK_NUMPAD7; - // Keys[k_IncLocalBrakeLevelFAST]=VK_END; //VK_HOME; - Keys[k_DecLocalBrakeLevel] = VK_NUMPAD7; // VK_NUMPAD1; - // Keys[k_DecLocalBrakeLevelFAST]=VK_HOME; //VK_END; - Keys[k_IncBrakeLevel] = VK_NUMPAD3; // VK_NUMPAD9; - Keys[k_DecBrakeLevel] = VK_NUMPAD9; // VK_NUMPAD3; - Keys[k_Releaser] = VK_NUMPAD6; - Keys[k_EmergencyBrake] = VK_NUMPAD0; - Keys[k_Brake3] = VK_NUMPAD8; - Keys[k_Brake2] = VK_NUMPAD5; - Keys[k_Brake1] = VK_NUMPAD2; - Keys[k_Brake0] = VK_NUMPAD4; - Keys[k_WaveBrake] = VK_DECIMAL; - //*/ - /*MOJE - Keys[k_IncLocalBrakeLevel]=VK_NUMPAD3; //VK_NUMPAD7; - Keys[k_IncLocalBrakeLevelFAST]=VK_NUMPAD3; //VK_HOME; - Keys[k_DecLocalBrakeLevel]=VK_DECIMAL; //VK_NUMPAD1; - Keys[k_DecLocalBrakeLevelFAST]=VK_DECIMAL; //VK_END; - Keys[k_IncBrakeLevel]=VK_NUMPAD6; //VK_NUMPAD9; - Keys[k_DecBrakeLevel]=VK_NUMPAD9; //VK_NUMPAD3; - Keys[k_Releaser]=VK_NUMPAD5; - Keys[k_EmergencyBrake]=VK_NUMPAD0; - Keys[k_Brake3]=VK_NUMPAD2; - Keys[k_Brake2]=VK_NUMPAD1; - Keys[k_Brake1]=VK_NUMPAD4; - Keys[k_Brake0]=VK_NUMPAD7; - Keys[k_WaveBrake]=VK_NUMPAD8; - */ - Keys[k_AntiSlipping] = VK_RETURN; - Keys[k_Sand] = VkKeyScan('s'); - Keys[k_Main] = VkKeyScan('m'); - Keys[k_Active] = VkKeyScan('w'); - Keys[k_Battery] = VkKeyScan('j'); - Keys[k_DirectionForward] = VkKeyScan('d'); - Keys[k_DirectionBackward] = VkKeyScan('r'); - Keys[k_Fuse] = VkKeyScan('n'); - Keys[k_Compressor] = VkKeyScan('c'); - Keys[k_Converter] = VkKeyScan('x'); - Keys[k_MaxCurrent] = VkKeyScan('f'); - Keys[k_CurrentAutoRelay] = VkKeyScan('g'); - Keys[k_BrakeProfile] = VkKeyScan('b'); - Keys[k_CurrentNext] = VkKeyScan('z'); - - Keys[k_Czuwak] = VkKeyScan(' '); - Keys[k_Horn] = VkKeyScan('a'); - Keys[k_Horn2] = VkKeyScan('a'); - - Keys[k_FailedEngineCutOff] = VkKeyScan('e'); - - Keys[k_MechUp] = VK_PRIOR; - Keys[k_MechDown] = VK_NEXT; - Keys[k_MechLeft] = VK_LEFT; - Keys[k_MechRight] = VK_RIGHT; - Keys[k_MechForward] = VK_UP; - Keys[k_MechBackward] = VK_DOWN; - - Keys[k_CabForward] = VK_HOME; - Keys[k_CabBackward] = VK_END; - - Keys[k_Couple] = VK_INSERT; - Keys[k_DeCouple] = VK_DELETE; - - Keys[k_ProgramQuit] = VK_F10; - // Keys[k_ProgramPause]=VK_F3; - Keys[k_ProgramHelp] = VK_F1; - // Keys[k_FreeFlyMode]=VK_F4; - Keys[k_WalkMode] = VK_F5; - - Keys[k_OpenLeft] = VkKeyScan(','); - Keys[k_OpenRight] = VkKeyScan('.'); - Keys[k_CloseLeft] = VkKeyScan(','); - Keys[k_CloseRight] = VkKeyScan('.'); - Keys[k_DepartureSignal] = VkKeyScan('/'); - - // Winger 160204 - obsluga pantografow - Keys[k_PantFrontUp] = VkKeyScan('p'); // Ra: zamieniony przedni z tylnym - Keys[k_PantFrontDown] = VkKeyScan('p'); - Keys[k_PantRearUp] = VkKeyScan('o'); - Keys[k_PantRearDown] = VkKeyScan('o'); - // Winger 020304 - ogrzewanie - Keys[k_Heating] = VkKeyScan('h'); - Keys[k_LeftSign] = VkKeyScan('y'); - Keys[k_UpperSign] = VkKeyScan('u'); - Keys[k_RightSign] = VkKeyScan('i'); - Keys[k_EndSign] = VkKeyScan('t'); - - Keys[k_SmallCompressor] = VkKeyScan('v'); - Keys[k_StLinOff] = VkKeyScan('l'); - // ABu 090305 - przyciski uniwersalne, do roznych bajerow :) - Keys[k_Univ1] = VkKeyScan('['); - Keys[k_Univ2] = VkKeyScan(']'); - Keys[k_Univ3] = VkKeyScan(';'); - Keys[k_Univ4] = VkKeyScan('\''); - } -} -/* -vector3 Global::GetCameraPosition() -{ - return pCameraPosition; -} -*/ -void Global::SetCameraPosition(vector3 pNewCameraPosition) -{ - pCameraPosition = pNewCameraPosition; -} - -void Global::SetCameraRotation(double Yaw) -{ // ustawienie bezwzględnego kierunku kamery z korekcją do przedziału <-M_PI,M_PI> - pCameraRotation = Yaw; - while (pCameraRotation < -M_PI) - pCameraRotation += 2 * M_PI; - while (pCameraRotation > M_PI) - pCameraRotation -= 2 * M_PI; - pCameraRotationDeg = pCameraRotation * 180.0 / M_PI; -} - -void Global::BindTexture(GLuint t) -{ // ustawienie aktualnej tekstury, tylko gdy się zmienia - if (t != iTextureId) - { - iTextureId = t; - } -}; - -void Global::TrainDelete(TDynamicObject *d) -{ // usunięcie pojazdu prowadzonego przez użytkownika - if (pWorld) - pWorld->TrainDelete(d); -}; - -TDynamicObject *Global::DynamicNearest() -{ // ustalenie pojazdu najbliższego kamerze - return pGround->DynamicNearest(pCamera->Pos); -}; - -TDynamicObject *Global::CouplerNearest() -{ // ustalenie pojazdu najbliższego kamerze - return pGround->CouplerNearest(pCamera->Pos); -}; - -bool Global::AddToQuery(TEvent *event, TDynamicObject *who) -{ - return pGround->AddToQuery(event, who); -}; -//--------------------------------------------------------------------------- - -bool Global::DoEvents() -{ // wywoływać czasem, żeby nie robił wrażenia zawieszonego - MSG msg; - while (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)) - { - if (msg.message == WM_QUIT) - return FALSE; - TranslateMessage(&msg); - DispatchMessage(&msg); - } - return TRUE; -} -//--------------------------------------------------------------------------- - -TTranscripts::TTranscripts() -{ -/* - iCount = 0; // brak linijek do wyświetlenia - iStart = 0; // wypełniać od linijki 0 - for (int i = 0; i < MAX_TRANSCRIPTS; ++i) - { // to do konstruktora można by dać - aLines[i].fHide = -1.0; // wolna pozycja (czas symulacji, 360.0 to doba) - aLines[i].iNext = -1; // nie ma kolejnej - } -*/ - fRefreshTime = 360.0; // wartośc zaporowa -}; -TTranscripts::~TTranscripts(){}; - -void TTranscripts::AddLine(std::string const &txt, float show, float hide, bool it) -{ // dodanie linii do tabeli, (show) i (hide) w [s] od aktualnego czasu - if (show == hide) - return; // komentarz jest ignorowany - show = Global::fTimeAngleDeg + show / 240.0; // jeśli doba to 360, to 1s będzie równe 1/240 - hide = Global::fTimeAngleDeg + hide / 240.0; - - TTranscript transcript; - transcript.asText = txt; - transcript.fShow = show; - transcript.fHide = hide; - transcript.bItalic = it; - aLines.emplace_back( transcript ); - // set the next refresh time while at it - // TODO, TBD: sort the transcript lines? in theory, they should be coming arranged in the right order anyway - // short of cases with multiple sounds overleaping - fRefreshTime = aLines.front().fHide; -/* - int i = iStart, j, k; // od czegoś trzeba zacząć - while ((aLines[i].iNext >= 0) ? (aLines[aLines[i].iNext].fShow <= show) : - false) // póki nie koniec i wcześniej puszczane - i = aLines[i].iNext; // przejście do kolejnej linijki -*/ -/* - //(i) wskazuje na linię, po której należy wstawić dany tekst, chyba że - while (txt ? *txt : false) - for (j = 0; j < MAX_TRANSCRIPTS; ++j) - if (aLines[j].fHide < 0.0) - { // znaleziony pierwszy wolny - aLines[j].iNext = aLines[i].iNext; // dotychczasowy następny będzie za nowym - if (aLines[iStart].fHide < 0.0) // jeśli tablica jest pusta - iStart = j; // fHide trzeba sprawdzić przed ewentualnym nadpisaniem, gdy i=j=0 - else - aLines[i].iNext = j; // a nowy będzie za tamtym wcześniejszym - aLines[j].fShow = show; // wyświetlać od - aLines[j].fHide = hide; // wyświetlać do - aLines[j].bItalic = it; - aLines[j].asText = std::string(txt); // bez sensu, wystarczyłby wskaźnik - if ((k = aLines[j].asText.find("|")) != std::string::npos) - { // jak jest podział linijki na wiersze - aLines[j].asText = aLines[j].asText.substr(0, k - 1); - txt += k; - i = j; // kolejna linijka dopisywana będzie na koniec właśnie dodanej - } - else - txt = NULL; // koniec dodawania - if (fRefreshTime > show) // jeśli odświeżacz ustawiony jest na później - fRefreshTime = show; // to odświeżyć wcześniej - break; // więcej już nic - } -*/ -}; -void TTranscripts::Add(std::string const &txt, float len, bool backgorund) -{ // dodanie tekstów, długość dźwięku, czy istotne - if (true == txt.empty()) - return; // pusty tekst -/* - int i = 0, j = int(0.5 + 10.0 * len); //[0.1s] - if (*txt == '[') - { // powinny być dwa nawiasy - while (*++txt ? *txt != ']' : false) - if ((*txt >= '0') && (*txt <= '9')) - i = 10 * i + int(*txt - '0'); // pierwsza liczba aż do ] - if (*txt ? *++txt == '[' : false) - { - j = 0; // drugi nawias określa czas zakończenia wyświetlania - while (*++txt ? *txt != ']' : false) - if ((*txt >= '0') && (*txt <= '9')) - j = 10 * j + int(*txt - '0'); // druga liczba aż do ] - if (*txt) - ++txt; // pominięcie drugiego ] - } - } -*/ - std::string asciitext{ txt }; win1250_to_ascii( asciitext ); // TODO: launch relevant conversion table based on language - cParser parser( asciitext ); - while( true == parser.getTokens( 3, false, "[]\n" ) ) { - - float begin, end; - std::string transcript; - parser - >> begin - >> end - >> transcript; - AddLine( transcript, 0.10 * begin, 0.12 * end, false ); - } - // try to handle malformed(?) cases with no show/hide times - std::string transcript; parser >> transcript; - while( false == transcript.empty() ) { - - WriteLog( "Transcript text with no display/hide times: \"" + transcript + "\"" ); - AddLine( transcript, 0.0, 0.12 * transcript.size(), false ); - transcript = ""; parser >> transcript; - } -}; -void TTranscripts::Update() -{ // usuwanie niepotrzebnych (nie częściej niż 10 razy na sekundę) - if( Global::fTimeAngleDeg < fRefreshTime ) - return; // nie czas jeszcze na zmiany - // czas odświeżenia można ustalić wg tabelki, kiedy coś się w niej zmienia - // fRefreshTime = Global::fTimeAngleDeg + 360.0; // wartość zaporowa - - while( ( false == aLines.empty() ) - && ( Global::fTimeAngleDeg >= aLines.front().fHide ) ) { - // remove expired lines - aLines.pop_front(); - } - // update next refresh time - if( false == aLines.empty() ) { fRefreshTime = aLines.front().fHide; } - else { fRefreshTime = 360.0f; } -/* - int i = iStart, j = -1; // od czegoś trzeba zacząć - bool change = false; // czy zmieniać napisy? - do - { - if (aLines[i].fHide >= 0.0) // o ile aktywne - if (aLines[i].fHide < Global::fTimeAngleDeg) - { // gdy czas wyświetlania upłynął - aLines[i].fHide = -1.0; // teraz będzie wolną pozycją - if (i == iStart) - iStart = aLines[i].iNext >= 0 ? aLines[i].iNext : 0; // przestawienie pierwszego - else if (j >= 0) - aLines[j].iNext = aLines[i].iNext; // usunięcie ze środka - change = true; - } - else - { // gdy ma być pokazane - if (aLines[i].fShow > Global::fTimeAngleDeg) // będzie pokazane w przyszłości - if (fRefreshTime > aLines[i].fShow) // a nie ma nic wcześniej - fRefreshTime = aLines[i].fShow; - if (fRefreshTime > aLines[i].fHide) - fRefreshTime = aLines[i].fHide; - } - // można by jeszcze wykrywać, które nowe mają być pokazane - j = i; - i = aLines[i].iNext; // kolejna linijka - } while (i >= 0); // póki po tablicy - change = true; // bo na razie nie ma warunku, że coś się dodało - if (change) - { // aktualizacja linijek ekranowych - i = iStart; - j = -1; - do - { - if (aLines[i].fHide > 0.0) // jeśli nie ukryte - if (aLines[i].fShow < Global::fTimeAngleDeg) // to dodanie linijki do wyświetlania - if (j < 5 - 1) // ograniczona liczba linijek - Global::asTranscript[++j] = aLines[i].asText; // skopiowanie tekstu - i = aLines[i].iNext; // kolejna linijka - } while (i >= 0); // póki po tablicy - for (++j; j < 5; ++j) - Global::asTranscript[j] = ""; // i czyszczenie nieużywanych linijek - } -*/ -}; - -// Ra: tymczasowe rozwiązanie kwestii zagranicznych (czeskich) napisów -char bezogonkowo[] = "E?,?\"_++?%Sstzz" - " ^^L$A|S^CS<--RZo±,l'uP.,as>L\"lz" - "RAAAALCCCEEEEIIDDNNOOOOxRUUUUYTB" - "raaaalccceeeeiiddnnoooo-ruuuuyt?"; - -std::string Global::Bezogonkow(std::string str, bool _) -{ // wycięcie liter z ogonkami, bo OpenGL nie umie wyświetlić - for (unsigned int i = 1; i < str.length(); ++i) - if (str[i] & 0x80) - str[i] = bezogonkowo[str[i] & 0x7F]; - else if (str[i] < ' ') // znaki sterujące nie są obsługiwane - str[i] = ' '; - else if (_) - if (str[i] == '_') // nazwy stacji nie mogą zawierać spacji - str[i] = ' '; // więc trzeba wyświetlać inaczej - return str; -}; - -double Global::Min0RSpeed(double vel1, double vel2) -{ // rozszerzenie funkcji Min0R o wartości -1.0 - if (vel1 == -1.0) - { - vel1 = std::numeric_limits::max(); - } - if (vel2 == -1.0) - { - vel2 = std::numeric_limits::max(); - } - return Min0R(vel1, vel2); -}; - -double Global::CutValueToRange(double min, double value, double max) -{ // przycinanie wartosci do podanych granic - value = Max0R(value, min); - value = Min0R(value, max); - return value; -}; diff --git a/Globals.h b/Globals.h index c2b2b708..2dc2c7c1 100644 --- a/Globals.h +++ b/Globals.h @@ -9,343 +9,174 @@ http://mozilla.org/MPL/2.0/. #pragma once -#include -#include -#include "opengl/glew.h" +#include "classes.h" +#include "camera.h" #include "dumb3d.h" +#include "float3d.h" +#include "light.h" +#include "uart.h" +#include "utilities.h" -// definicje klawiszy -const int k_IncMainCtrl = 0; //[Num+] -const int k_IncMainCtrlFAST = 1; //[Num+] [Shift] -const int k_DecMainCtrl = 2; //[Num-] -const int k_DecMainCtrlFAST = 3; //[Num-] [Shift] -const int k_IncScndCtrl = 4; //[Num/] -const int k_IncScndCtrlFAST = 5; -const int k_DecScndCtrl = 6; -const int k_DecScndCtrlFAST = 7; -const int k_IncLocalBrakeLevel = 8; -const int k_IncLocalBrakeLevelFAST = 9; -const int k_DecLocalBrakeLevel = 10; -const int k_DecLocalBrakeLevelFAST = 11; -const int k_IncBrakeLevel = 12; -const int k_DecBrakeLevel = 13; -const int k_Releaser = 14; -const int k_EmergencyBrake = 15; -const int k_Brake3 = 16; -const int k_Brake2 = 17; -const int k_Brake1 = 18; -const int k_Brake0 = 19; -const int k_WaveBrake = 20; -const int k_AntiSlipping = 21; -const int k_Sand = 22; +struct global_settings { +// members + // data items + // TODO: take these out of the settings + bool shiftState{ false }; //m7todo: brzydko + bool ctrlState{ false }; + bool altState{ false }; + std::mt19937 random_engine{ std::mt19937( static_cast( std::time( NULL ) ) ) }; + TDynamicObject *changeDynObj{ nullptr };// info o zmianie pojazdu + TCamera pCamera; // parametry kamery + TCamera pDebugCamera; + std::array FreeCameraInit; // pozycje kamery + std::array FreeCameraInitAngle; + int iCameraLast{ -1 }; + int iSlowMotion{ 0 }; // info o malym FPS: 0-OK, 1-wyłączyć multisampling, 3-promień 1.5km, 7-1km + basic_light DayLight; + float SunAngle{ 0.f }; // angle of the sun relative to horizon + double fLuminance{ 1.0 }; // jasność światła do automatycznego zapalania + double fTimeAngleDeg{ 0.0 }; // godzina w postaci kąta + float fClockAngleDeg[ 6 ]; // kąty obrotu cylindrów dla zegara cyfrowego + std::string LastGLError; + float ZoomFactor{ 1.f }; // determines current camera zoom level. TODO: move it to the renderer + bool CabWindowOpen{ false }; // controls sound attenuation between cab and outside + bool ControlPicking{ true }; // indicates controls pick mode is active + bool DLFont{ false }; // switch indicating presence of basic font + bool bActive{ true }; // czy jest aktywnym oknem + int iPause{ 0 }; // globalna pauza ruchu: b0=start,b1=klawisz,b2=tło,b3=lagi,b4=wczytywanie + float AirTemperature{ 15.f }; + std::string asCurrentSceneryPath{ "scenery/" }; + std::string asCurrentTexturePath{ szTexturePath }; + std::string asCurrentDynamicPath; + // settings + // filesystem + bool bLoadTraction{ true }; + bool CreateSwitchTrackbeds { true }; + std::string szTexturesTGA{ ".tga" }; // lista tekstur od TGA + std::string szTexturesDDS{ ".dds" }; // lista tekstur od DDS + std::string szDefaultExt{ szTexturesDDS }; + std::string SceneryFile{ "td.scn" }; + std::string asHumanCtrlVehicle{ "EU07-424" }; + int iConvertModels{ 0 }; // tworzenie plików binarnych + // logs + int iWriteLogEnabled{ 3 }; // maska bitowa: 1-zapis do pliku, 2-okienko, 4-nazwy torów + bool MultipleLogs{ false }; + unsigned int DisabledLogTypes{ 0 }; + // simulation + bool RealisticControlMode{ false }; // controls ability to steer the vehicle from outside views + bool bEnableTraction{ true }; + float fFriction{ 1.f }; // mnożnik tarcia - KURS90 + float FrictionWeatherFactor { 1.f }; + bool bLiveTraction{ true }; + float Overcast{ 0.1f }; // NOTE: all this weather stuff should be moved elsewhere + glm::vec3 FogColor = { 0.6f, 0.7f, 0.8f }; + double fFogStart{ 1700 }; + double fFogEnd{ 2000 }; + std::string Season{}; // season of the year, based on simulation date + std::string Weather{ "cloudy:" }; // current weather + bool FullPhysics{ true }; // full calculations performed for each simulation step + bool bnewAirCouplers{ true }; + double fMoveLight{ -1 }; // numer dnia w roku albo -1 + bool FakeLight{ false }; // toggle between fixed and dynamic daylight + double fTimeSpeed{ 1.0 }; // przyspieszenie czasu, zmienna do testów + double fLatitudeDeg{ 52.0 }; // szerokość geograficzna + float ScenarioTimeOverride { std::numeric_limits::quiet_NaN() }; // requested scenario start time + float ScenarioTimeOffset { 0.f }; // time shift (in hours) applied to train timetables + bool ScenarioTimeCurrent { false }; // automatic time shift to match scenario time with local clock + bool bInactivePause{ true }; // automatyczna pauza, gdy okno nieaktywne + int iSlowMotionMask{ -1 }; // maska wyłączanych właściwości + bool bHideConsole{ false }; // hunter-271211: ukrywanie konsoli + bool bRollFix{ true }; // czy wykonać przeliczanie przechyłki + bool bJoinEvents{ false }; // czy grupować eventy o tych samych nazwach + int iHiddenEvents{ 1 }; // czy łączyć eventy z torami poprzez nazwę toru + // ui + int PythonScreenUpdateRate { 200 }; // delay between python-based screen updates, in milliseconds + int iTextMode{ 0 }; // tryb pracy wyświetlacza tekstowego + int iScreenMode[ 12 ] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; // numer ekranu wyświetlacza tekstowego + glm::vec4 UITextColor { glm::vec4( 225.f / 255.f, 225.f / 255.f, 225.f / 255.f, 1.f ) }; // base color of UI text + float UIBgOpacity { 0.65f }; // opacity of ui windows + std::string asLang{ "pl" }; // domyślny język - http://tools.ietf.org/html/bcp47 + // gfx + int iWindowWidth{ 800 }; + int iWindowHeight{ 600 }; + float fDistanceFactor{ iWindowHeight / 768.f }; // baza do przeliczania odległości dla LoD + bool bFullScreen{ false }; + bool VSync{ false }; + bool bWireFrame{ false }; + bool bAdjustScreenFreq{ true }; + float BaseDrawRange{ 2500.f }; + int DynamicLightCount{ 3 }; + bool ScaleSpecularValues{ true }; + bool BasicRenderer{ false }; + bool RenderShadows{ true }; + struct shadowtune_t { + unsigned int map_size{ 2048 }; + float width{ 250.f }; // no longer used + float depth{ 250.f }; + float distance{ 500.f }; // no longer used + } shadowtune; + bool bUseVBO{ true }; // czy jest VBO w karcie graficznej (czy użyć) + float AnisotropicFiltering{ 8.f }; // requested level of anisotropic filtering. TODO: move it to renderer object + float FieldOfView{ 45.f }; // vertical field of view for the camera. TODO: move it to the renderer + GLint iMaxTextureSize{ 4096 }; // maksymalny rozmiar tekstury + int iMultisampling{ 2 }; // tryb antyaliasingu: 0=brak,1=2px,2=4px,3=8px,4=16px + bool bSmoothTraction{ true }; // wygładzanie drutów starym sposobem + float SplineFidelity{ 1.f }; // determines segment size during conversion of splines to geometry + bool ResourceSweep{ true }; // gfx resource garbage collection + bool ResourceMove{ false }; // gfx resources are moved between cpu and gpu side instead of sending a copy + bool compress_tex{ true }; // all textures are compressed on gpu side + std::string asSky{ "1" }; + bool bGlutFont{ false }; // czy tekst generowany przez GLUT32.DLL + double fFpsAverage{ 20.0 }; // oczekiwana wartosć FPS + double fFpsDeviation{ 5.0 }; // odchylenie standardowe FPS + double fFpsMin{ 30.0 }; // dolna granica FPS, przy której promień scenerii będzie zmniejszany + double fFpsMax{ 65.0 }; // górna granica FPS, przy której promień scenerii będzie zwiększany + // audio + bool bSoundEnabled{ true }; + float AudioVolume{ 1.25f }; + std::string AudioRenderer; + // input + float fMouseXScale{ 1.5f }; + float fMouseYScale{ 0.2f }; + int iFeedbackMode{ 1 }; // tryb pracy informacji zwrotnej + int iFeedbackPort{ 0 }; // dodatkowy adres dla informacji zwrotnych + bool InputGamepad{ true }; // whether gamepad support is enabled + bool InputMouse{ true }; // whether control pick mode can be activated + double fBrakeStep{ 1.0 }; // krok zmiany hamulca dla klawiszy [Num3] i [Num9] + // parametry kalibracyjne wejść z pulpitu + double fCalibrateIn[ 6 ][ 6 ] = { + { 0, 0, 0, 0, 0, 0 }, + { 0, 0, 0, 0, 0, 0 }, + { 0, 0, 0, 0, 0, 0 }, + { 0, 0, 0, 0, 0, 0 }, + { 0, 0, 0, 0, 0, 0 }, + { 0, 0, 0, 0, 0, 0 } }; + // parametry kalibracyjne wyjść dla pulpitu + double fCalibrateOut[ 7 ][ 6 ] = { + { 0, 1, 0, 0, 0, 0 }, + { 0, 1, 0, 0, 0, 0 }, + { 0, 1, 0, 0, 0, 0 }, + { 0, 1, 0, 0, 0, 0 }, + { 0, 1, 0, 0, 0, 0 }, + { 0, 1, 0, 0, 0, 0 }, + { 0, 1, 0, 0, 0, 0 } }; + // wartości maksymalne wyjść dla pulpitu + double fCalibrateOutMax[ 7 ] = { + 0, 0, 0, 0, 0, 0, 0 }; + int iCalibrateOutDebugInfo { -1 }; // numer wyjścia kalibrowanego dla którego wyświetlać informacje podczas kalibracji + int iPoKeysPWM[ 7 ] = { 0, 1, 2, 3, 4, 5, 6 }; // numery wejść dla PWM + uart_input::conf_t uart_conf; + // multiplayer + int iMultiplayer{ 0 }; // blokada działania niektórych eventów na rzecz kominikacji + // other + std::string AppName{ "EU07" }; + std::string asVersion{ "UNKNOWN" }; // z opisem -const int k_Main = 23; -const int k_DirectionForward = 24; -const int k_DirectionBackward = 25; - -const int k_Fuse = 26; -const int k_Compressor = 27; -const int k_Converter = 28; -const int k_MaxCurrent = 29; -const int k_CurrentAutoRelay = 30; -const int k_BrakeProfile = 31; - -const int k_Czuwak = 32; -const int k_Horn = 33; -const int k_Horn2 = 34; - -const int k_FailedEngineCutOff = 35; - -const int k_MechUp = 36; -const int k_MechDown = 37; -const int k_MechLeft = 38; -const int k_MechRight = 39; -const int k_MechForward = 40; -const int k_MechBackward = 41; - -const int k_CabForward = 42; -const int k_CabBackward = 43; - -const int k_Couple = 44; -const int k_DeCouple = 45; - -const int k_ProgramQuit = 46; -// const int k_ProgramPause= 47; -const int k_ProgramHelp = 48; -// NBMX -const int k_OpenLeft = 49; -const int k_OpenRight = 50; -const int k_CloseLeft = 51; -const int k_CloseRight = 52; -const int k_DepartureSignal = 53; -// NBMX -const int k_PantFrontUp = 54; -const int k_PantRearUp = 55; -const int k_PantFrontDown = 56; -const int k_PantRearDown = 57; - -const int k_Heating = 58; - -// const int k_FreeFlyMode= 59; - -const int k_LeftSign = 60; -const int k_UpperSign = 61; -const int k_RightSign = 62; - -const int k_SmallCompressor = 63; - -const int k_StLinOff = 64; - -const int k_CurrentNext = 65; - -const int k_Univ1 = 66; -const int k_Univ2 = 67; -const int k_Univ3 = 68; -const int k_Univ4 = 69; -const int k_EndSign = 70; - -const int k_Active = 71; -// Winger 020304 -const int k_Battery = 72; -const int k_WalkMode = 73; -const int MaxKeys = 74; - -// klasy dla wskaźników globalnych -class TGround; -class TWorld; -class TCamera; -class TDynamicObject; -class TAnimModel; // obiekt terenu -class cParser; // nowy (powolny!) parser -class TEvent; -class TTextSound; - -class TTranscript -{ // klasa obsługująca linijkę napisu do dźwięku - public: - float fShow; // czas pokazania - float fHide; // czas ukrycia/usunięcia - std::string asText; // tekst gotowy do wyświetlenia (usunięte znaczniki czasu) - bool bItalic; // czy kursywa (dźwięk nieistotny dla prowadzącego) - int iNext; // następna używana linijka, żeby nie przestawiać fizycznie tabeli +// methods + void LoadIniFile( std::string asFileName ); + void ConfigParse( cParser &parser ); }; -/* -#define MAX_TRANSCRIPTS 30 -*/ -class TTranscripts -{ // klasa obsługująca napisy do dźwięków -/* - TTranscript aLines[MAX_TRANSCRIPTS]; // pozycje na napisy do wyświetlenia -*/ -public: - std::deque aLines; -/* - int iCount; // liczba zajętych pozycji - int iStart; // pierwsza istotna pozycja w tabeli, żeby sortować przestawiając numerki -*/ -private: - float fRefreshTime; +extern global_settings Global; - public: - TTranscripts(); - ~TTranscripts(); - void AddLine(std::string const &txt, float show, float hide, bool it); - // dodanie tekstów, długość dźwięku, czy istotne - void Add(std::string const &txt, float len, bool background = false); - // usuwanie niepotrzebnych (ok. 10 razy na sekundę) - void Update(); -}; - -class Global -{ - private: - static GLuint iTextureId; // ostatnio użyta tekstura 2D - public: - // double Global::tSinceStart; - static int Keys[MaxKeys]; - static Math3D::vector3 pCameraPosition; // pozycja kamery w świecie - static double - pCameraRotation; // kierunek bezwzględny kamery w świecie: 0=północ, 90°=zachód (-azymut) - static double pCameraRotationDeg; // w stopniach, dla animacji billboard - static Math3D::vector3 pFreeCameraInit[10]; // pozycje kamery - static Math3D::vector3 pFreeCameraInitAngle[10]; - static int iWindowWidth; - static int iWindowHeight; - static float fDistanceFactor; - static int iBpp; - static bool bFullScreen; - static bool bFreeFly; - // float RunningTime; - static bool bWireFrame; - static bool bSoundEnabled; - // McZapkie-131202 - // static bool bRenderAlpha; - static bool bAdjustScreenFreq; - static bool bEnableTraction; - static bool bLoadTraction; - static float fFriction; - static bool bLiveTraction; - static bool bManageNodes; - static bool bDecompressDDS; - // bool WFreeFly; - static float Global::fMouseXScale; - static float Global::fMouseYScale; - static double fFogStart; - static double fFogEnd; - static TGround *pGround; - static std::string szDefaultExt; - static std::string SceneryFile; - static char CreatorName1[20]; - static char CreatorName2[20]; - static char CreatorName3[20]; - static char CreatorName4[30]; - static char CreatorName5[30]; - static std::string asCurrentSceneryPath; - static std::string asCurrentTexturePath; - static std::string asCurrentDynamicPath; - // McZapkie-170602: zewnetrzna definicja pojazdu uzytkownika - static std::string asHumanCtrlVehicle; - static void LoadIniFile(std::string asFileName); - static void InitKeys(std::string asFileName); - inline static Math3D::vector3 GetCameraPosition() - { - return pCameraPosition; - }; - static void SetCameraPosition(Math3D::vector3 pNewCameraPosition); - static void SetCameraRotation(double Yaw); - static int iWriteLogEnabled; // maska bitowa: 1-zapis do pliku, 2-okienko - // McZapkie-221002: definicja swiatla dziennego - static float Background[3]; - static GLfloat AtmoColor[]; - static GLfloat FogColor[]; - // static bool bTimeChange; - static GLfloat ambientDayLight[]; - static GLfloat diffuseDayLight[]; - static GLfloat specularDayLight[]; - static GLfloat ambientLight[]; - static GLfloat diffuseLight[]; - static GLfloat specularLight[]; - static GLfloat whiteLight[]; - static GLfloat noLight[]; - static GLfloat darkLight[]; - static GLfloat lightPos[4]; - static int iSlowMotion; - static TDynamicObject *changeDynObj; - static double ABuDebug; - static bool detonatoryOK; - static std::string asSky; - static bool bnewAirCouplers; - // Ra: nowe zmienne globalne - static int iDefaultFiltering; // domyślne rozmywanie tekstur TGA - static int iBallastFiltering; // domyślne rozmywanie tekstury podsypki - static int iRailProFiltering; // domyślne rozmywanie tekstury szyn - static int iDynamicFiltering; // domyślne rozmywanie tekstur pojazdów - static int iReCompile; // zwiększany, gdy trzeba odświeżyć siatki - static bool bUseVBO; // czy jest VBO w karcie graficznej - static int iFeedbackMode; // tryb pracy informacji zwrotnej - static int iFeedbackPort; // dodatkowy adres dla informacji zwrotnych - static double fOpenGL; // wersja OpenGL - przyda się -/* - static bool bOpenGL_1_5; // czy są dostępne funkcje OpenGL 1.5 -*/ - static double fLuminance; // jasność światła do automatycznego zapalania - static int iMultiplayer; // blokada działania niektórych eventów na rzecz kominikacji - static HWND hWnd; // uchwyt okna - static int iCameraLast; - static std::string asRelease; // numer - static std::string asVersion; // z opisem - static int - iViewMode; // co aktualnie widać: 0-kabina, 1-latanie, 2-sprzęgi, 3-dokumenty, 4-obwody - static GLint iMaxTextureSize; // maksymalny rozmiar tekstury - static int iTextMode; // tryb pracy wyświetlacza tekstowego - static int iScreenMode[12]; // numer ekranu wyświetlacza tekstowego - static bool bDoubleAmbient; // podwójna jasność ambient - static double fMoveLight; // numer dnia w roku albo -1 - static bool bSmoothTraction; // wygładzanie drutów - static double fSunDeclination; // deklinacja Słońca - static double fTimeSpeed; // przyspieszenie czasu, zmienna do testów - static double fTimeAngleDeg; // godzina w postaci kąta - static float fClockAngleDeg[6]; // kąty obrotu cylindrów dla zegara cyfrowego - static double fLatitudeDeg; // szerokość geograficzna - static std::string szTexturesTGA; // lista tekstur od TGA - static std::string szTexturesDDS; // lista tekstur od DDS - static int iMultisampling; // tryb antyaliasingu: 0=brak,1=2px,2=4px,3=8px,4=16px - static bool bGlutFont; // tekst generowany przez GLUT - static int iKeyLast; // ostatnio naciśnięty klawisz w celu logowania - static int iPause; // globalna pauza ruchu: b0=start,b1=klawisz,b2=tło,b3=lagi,b4=wczytywanie - static bool bActive; // czy jest aktywnym oknem - static void BindTexture(GLuint t); - static int iConvertModels; // tworzenie plików binarnych - static int iErorrCounter; // licznik sprawdzań do śledzenia błędów OpenGL - static bool bInactivePause; // automatyczna pauza, gdy okno nieaktywne - static int iTextures; // licznik użytych tekstur - static int iSlowMotionMask; // maska wyłączanych właściwości - static int iModifyTGA; // czy korygować pliki TGA dla szybszego wczytywania - static bool bHideConsole; // hunter-271211: ukrywanie konsoli - static bool bOldSmudge; // Używanie starej smugi - - static TWorld *pWorld; // wskaźnik na świat do usuwania pojazdów - static TAnimModel *pTerrainCompact; // obiekt terenu do ewentualnego zapisania w pliku - static std::string asTerrainModel; // nazwa obiektu terenu do zapisania w pliku - static bool bRollFix; // czy wykonać przeliczanie przechyłki - static cParser *pParser; - static int iSegmentsRendered; // ilość segmentów do regulacji wydajności - static double fFpsAverage; // oczekiwana wartosć FPS - static double fFpsDeviation; // odchylenie standardowe FPS - static double fFpsMin; // dolna granica FPS, przy której promień scenerii będzie zmniejszany - static double fFpsMax; // górna granica FPS, przy której promień scenerii będzie zwiększany - static double fFpsRadiusMax; // maksymalny promień renderowania - static int iFpsRadiusMax; // maksymalny promień renderowania w rozmiarze tabeli sektorów - static double fRadiusFactor; // współczynnik zmiany promienia - static TCamera *pCamera; // parametry kamery - static TDynamicObject *pUserDynamic; // pojazd użytkownika, renderowany bez trzęsienia - static double fCalibrateIn[6][6]; // parametry kalibracyjne wejść z pulpitu - static double fCalibrateOut[7][6]; // parametry kalibracyjne wyjść dla pulpitu - static double fCalibrateOutMax[7]; // wartości maksymalne wyjść dla pulpitu - static int iCalibrateOutDebugInfo; // numer wyjścia kalibrowanego dla którego wyświetlać - // informacje podczas kalibracji - static double fBrakeStep; // krok zmiany hamulca dla klawiszy [Num3] i [Num9] - static bool bJoinEvents; // czy grupować eventy o tych samych nazwach - static bool bSmudge; // czy wyświetlać smugę, a pojazd użytkownika na końcu -/* - static std::string asTranscript[5]; // napisy na ekranie (widoczne) -*/ - static TTranscripts tranTexts; // obiekt obsługujący stenogramy dźwięków na ekranie - static std::string asLang; // domyślny język - http://tools.ietf.org/html/bcp47 - static int iHiddenEvents; // czy łączyć eventy z torami poprzez nazwę toru - static TTextSound *tsRadioBusy[10]; // zajętość kanałów radiowych (wskaźnik na odgrywany dźwięk) - static int iPoKeysPWM[7]; // numery wejść dla PWM - - //randomizacja - static std::mt19937 random_engine; - - // metody - static void TrainDelete(TDynamicObject *d); - static void ConfigParse(cParser &parser); - static std::string GetNextSymbol(); - static TDynamicObject * DynamicNearest(); - static TDynamicObject * CouplerNearest(); - static bool AddToQuery(TEvent *event, TDynamicObject *who); - static bool DoEvents(); - static std::string Bezogonkow(std::string str, bool _ = false); - static double Min0RSpeed(double vel1, double vel2); - static double CutValueToRange(double min, double value, double max); - - // maciek001: zmienne dla MWD - static bool bMWDmasterEnable; // główne włączenie portu COM - static bool bMWDdebugEnable; // logowanie pracy - static int iMWDDebugMode; - static std::string sMWDPortId; // nazwa portu COM - static unsigned long int iMWDBaudrate; // prędkość transmisji - static bool bMWDInputEnable; // włącz wejścia - static bool bMWDBreakEnable; // włącz wejścia analogowe (hamulce) - static double fMWDAnalogInCalib[4][2]; // ustawienia kranów hamulca zespolonego i dodatkowego - min i max - static double fMWDzg[2]; // max wartość wskazywana i max wartość generowana (rozdzielczość) - static double fMWDpg[2]; - static double fMWDph[2]; - static double fMWDvolt[2]; - static double fMWDamp[2]; - static int iMWDdivider; -}; //--------------------------------------------------------------------------- diff --git a/Ground.cpp b/Ground.cpp deleted file mode 100644 index b1d55d3c..00000000 --- a/Ground.cpp +++ /dev/null @@ -1,5460 +0,0 @@ -/* -This Source Code Form is subject to the -terms of the Mozilla Public License, v. -2.0. If a copy of the MPL was not -distributed with this file, You can -obtain one at -http://mozilla.org/MPL/2.0/. -*/ - -/* - MaSzyna EU07 locomotive simulator - Copyright (C) 2001-2004 Marcin Wozniak and others - -*/ - -#include "stdafx.h" -#include "Ground.h" - -#include "opengl/glew.h" -#include "opengl/glut.h" - -#include "Globals.h" -#include "Logs.h" -#include "usefull.h" -#include "Timer.h" -#include "Texture.h" -#include "Event.h" -#include "EvLaunch.h" -#include "TractionPower.h" -#include "Traction.h" -#include "Track.h" -#include "RealSound.h" -#include "AnimModel.h" -#include "MemCell.h" -#include "mtable.h" -#include "DynObj.h" -#include "Data.h" -#include "parser.h" //Tolaris-010603 -#include "Driver.h" -#include "Console.h" -#include "Names.h" - -#define _PROBLEND 1 -//--------------------------------------------------------------------------- - -bool bCondition; // McZapkie: do testowania warunku na event multiple -string LogComment; - -//--------------------------------------------------------------------------- -// Obiekt renderujący siatkę jest sztucznie tworzonym obiektem pomocniczym, -// grupującym siatki obiektów dla danej tekstury. Obiektami składowymi mogą -// byc trójkąty terenu, szyny, podsypki, a także proste modele np. słupy. -// Obiekty składowe dodane są do listy TSubRect::nMeshed z listą zrobioną na -// TGroundNode::nNext3, gdzie są posortowane wg tekstury. Obiekty renderujące -// są wpisane na listę TSubRect::nRootMesh (TGroundNode::nNext2) oraz na -// odpowiednie listy renderowania, gdzie zastępują obiekty składowe (nNext3). -// Problematyczne są tory/drogi/rzeki, gdzie używane sa 2 tekstury. Dlatego -// tory są zdublowane jako TP_TRACK oraz TP_DUMMYTRACK. Jeśli tekstura jest -// tylko jedna (np. zwrotnice), nie jest używany TP_DUMMYTRACK. -//--------------------------------------------------------------------------- -TGroundNode::TGroundNode() -{ // nowy obiekt terenu - pusty - iType = GL_POINTS; - Vertices = NULL; - nNext = nNext2 = NULL; - pCenter = vector3(0, 0, 0); - iCount = 0; // wierzchołków w trójkącie - // iNumPts=0; //punktów w linii - TextureID = 0; - iFlags = 0; // tryb przezroczystości nie zbadany - DisplayListID = 0; - Pointer = NULL; // zerowanie wskaźnika kontekstowego - bVisible = false; // czy widoczny - fSquareRadius = 10000 * 10000; - fSquareMinRadius = 0; - asName = ""; - // Color= TMaterialColor(1); - // fAngle=0; //obrót dla modelu - fLineThickness=1.0; //mm dla linii - for (int i = 0; i < 3; i++) - { - Ambient[i] = Global::whiteLight[i] * 255; - Diffuse[i] = Global::whiteLight[i] * 255; - Specular[i] = Global::noLight[i] * 255; - } - nNext3 = NULL; // nie wyświetla innych - iVboPtr = -1; // indeks w VBO sektora (-1: nie używa VBO) - iVersion = 0; // wersja siatki -} - -TGroundNode::~TGroundNode() -{ - // if (iFlags&0x200) //czy obiekt został utworzony? - switch (iType) - { - case TP_MEMCELL: - SafeDelete(MemCell); - break; - case TP_EVLAUNCH: - SafeDelete(EvLaunch); - break; - case TP_TRACTION: - SafeDelete(hvTraction); - break; - case TP_TRACTIONPOWERSOURCE: - SafeDelete(psTractionPowerSource); - break; - case TP_TRACK: - SafeDelete(pTrack); - break; - case TP_DYNAMIC: - SafeDelete(DynamicObject); - break; - case TP_MODEL: - if (iFlags & 0x200) // czy model został utworzony? - delete Model; - Model = NULL; - break; - case TP_SOUND: - SafeDelete(tsStaticSound); - break; - case TP_TERRAIN: - { // pierwsze nNode zawiera model E3D, reszta to trójkąty - for (int i = 1; i < iCount; ++i) - nNode->Vertices = - NULL; // zerowanie wskaźników w kolejnych elementach, bo nie są do usuwania - delete[] nNode; // usunięcie tablicy i pierwszego elementu - } - case TP_SUBMODEL: // dla formalności, nie wymaga usuwania - break; - case GL_LINES: - case GL_LINE_STRIP: - case GL_LINE_LOOP: - SafeDeleteArray(Points); - break; - case GL_TRIANGLE_STRIP: - case GL_TRIANGLE_FAN: - case GL_TRIANGLES: - SafeDeleteArray(Vertices); - break; - } -} - -void TGroundNode::Init(int n) -{ // utworzenie tablicy wierzchołków - bVisible = false; - iNumVerts = n; - Vertices = new TGroundVertex[iNumVerts]; -} - -TGroundNode::TGroundNode(TGroundNodeType t, int n) -{ // utworzenie obiektu - TGroundNode(); // domyślne ustawienia - iNumVerts = n; - if (iNumVerts) - Vertices = new TGroundVertex[iNumVerts]; - iType = t; - switch (iType) - { // zależnie od typu - case TP_TRACK: - pTrack = new TTrack(this); - break; - } -} - -void TGroundNode::InitCenter() -{ // obliczenie środka ciężkości obiektu - for (int i = 0; i < iNumVerts; i++) - pCenter += Vertices[i].Point; - pCenter /= iNumVerts; -} - -void TGroundNode::InitNormals() -{ // obliczenie wektorów normalnych - vector3 v1, v2, v3, v4, v5, n1, n2, n3, n4; - int i; - float tu, tv; - switch (iType) - { - case GL_TRIANGLE_STRIP: - v1 = Vertices[0].Point - Vertices[1].Point; - v2 = Vertices[1].Point - Vertices[2].Point; - n1 = SafeNormalize(CrossProduct(v1, v2)); - if (Vertices[0].Normal == vector3(0, 0, 0)) - Vertices[0].Normal = n1; - v3 = Vertices[2].Point - Vertices[3].Point; - n2 = SafeNormalize(CrossProduct(v3, v2)); - if (Vertices[1].Normal == vector3(0, 0, 0)) - Vertices[1].Normal = (n1 + n2) * 0.5; - - for (i = 2; i < iNumVerts - 2; i += 2) - { - v4 = Vertices[i - 1].Point - Vertices[i].Point; - v5 = Vertices[i].Point - Vertices[i + 1].Point; - n3 = SafeNormalize(CrossProduct(v3, v4)); - n4 = SafeNormalize(CrossProduct(v5, v4)); - if (Vertices[i].Normal == vector3(0, 0, 0)) - Vertices[i].Normal = (n1 + n2 + n3) / 3; - if (Vertices[i + 1].Normal == vector3(0, 0, 0)) - Vertices[i + 1].Normal = (n2 + n3 + n4) / 3; - n1 = n3; - n2 = n4; - v3 = v5; - } - if (Vertices[i].Normal == vector3(0, 0, 0)) - Vertices[i].Normal = (n1 + n2) / 2; - if (Vertices[i + 1].Normal == vector3(0, 0, 0)) - Vertices[i + 1].Normal = n2; - break; - case GL_TRIANGLE_FAN: - - break; - case GL_TRIANGLES: - for (i = 0; i < iNumVerts; i += 3) - { - v1 = Vertices[i + 0].Point - Vertices[i + 1].Point; - v2 = Vertices[i + 1].Point - Vertices[i + 2].Point; - n1 = SafeNormalize(CrossProduct(v1, v2)); - if (Vertices[i + 0].Normal == vector3(0, 0, 0)) - Vertices[i + 0].Normal = (n1); - if (Vertices[i + 1].Normal == vector3(0, 0, 0)) - Vertices[i + 1].Normal = (n1); - if (Vertices[i + 2].Normal == vector3(0, 0, 0)) - Vertices[i + 2].Normal = (n1); - tu = floor(Vertices[i + 0].tu); - tv = floor(Vertices[i + 0].tv); - Vertices[i + 1].tv -= tv; - Vertices[i + 2].tv -= tv; - Vertices[i + 0].tv -= tv; - Vertices[i + 1].tu -= tu; - Vertices[i + 2].tu -= tu; - Vertices[i + 0].tu -= tu; - } - break; - } -} - -void TGroundNode::MoveMe(vector3 pPosition) -{ // przesuwanie obiektów scenerii o wektor w celu redukcji trzęsienia - pCenter += pPosition; - switch (iType) - { - case TP_TRACTION: - hvTraction->pPoint1 += pPosition; - hvTraction->pPoint2 += pPosition; - hvTraction->pPoint3 += pPosition; - hvTraction->pPoint4 += pPosition; - hvTraction->Optimize(); - break; - case TP_MODEL: - case TP_DYNAMIC: - case TP_MEMCELL: - case TP_EVLAUNCH: - break; - case TP_TRACK: - pTrack->MoveMe(pPosition); - break; - case TP_SOUND: // McZapkie - dzwiek zapetlony w zaleznosci od odleglosci - tsStaticSound->vSoundPosition += pPosition; - break; - case GL_LINES: - case GL_LINE_STRIP: - case GL_LINE_LOOP: - for (int i = 0; i < iNumPts; i++) - Points[i] += pPosition; - ResourceManager::Unregister(this); - break; - default: - for (int i = 0; i < iNumVerts; i++) - Vertices[i].Point += pPosition; - ResourceManager::Unregister(this); - } -} - -void TGroundNode::RaRenderVBO() -{ // renderowanie z domyslnego bufora VBO - glColor3ub(Diffuse[0], Diffuse[1], Diffuse[2]); - if (TextureID) - TextureManager.Bind(TextureID); // Ustaw aktywną teksturę - glDrawArrays(iType, iVboPtr, iNumVerts); // Narysuj naraz wszystkie trójkąty -} - -void TGroundNode::RenderVBO() -{ // renderowanie obiektu z VBO - faza nieprzezroczystych - double mgn = SquareMagnitude(pCenter - Global::pCameraPosition); - if ((mgn > fSquareRadius || (mgn < fSquareMinRadius)) && - (iType != TP_EVLAUNCH)) // McZapkie-070602: nie rysuj odleglych obiektow ale sprawdzaj - // wyzwalacz zdarzen - return; - int i, a; - switch (iType) - { - case TP_TRACTION: - return; - case TP_TRACK: - if (iNumVerts) - pTrack->RaRenderVBO(iVboPtr); - return; - case TP_MODEL: - Model->RenderVBO(&pCenter); - return; - // case TP_SOUND: //McZapkie - dzwiek zapetlony w zaleznosci od odleglosci - // if ((pStaticSound->GetStatus()&DSBSTATUS_PLAYING)==DSBPLAY_LOOPING) - // { - // pStaticSound->Play(1,DSBPLAY_LOOPING,true,pStaticSound->vSoundPosition); - // pStaticSound->AdjFreq(1.0,Timer::GetDeltaTime()); - // } - // return; //Ra: TODO sprawdzić, czy dźwięki nie są tylko w RenderHidden - case TP_MEMCELL: - return; - case TP_EVLAUNCH: - if (EvLaunch->Render()) - if ((EvLaunch->dRadius < 0) || (mgn < EvLaunch->dRadius)) - { - if (Console::Pressed(VK_SHIFT) && EvLaunch->Event2 != NULL) - Global::AddToQuery(EvLaunch->Event2, NULL); - else if (EvLaunch->Event1 != NULL) - Global::AddToQuery(EvLaunch->Event1, NULL); - } - return; - case GL_LINES: - case GL_LINE_STRIP: - case GL_LINE_LOOP: - if (iNumPts) - { - float linealpha = 255000 * fLineThickness / (mgn + 1.0); - if (linealpha > 255) - linealpha = 255; - float r, g, b; - r = floor(Diffuse[0] * Global::ambientDayLight[0]); // w zaleznosci od koloru swiatla - g = floor(Diffuse[1] * Global::ambientDayLight[1]); - b = floor(Diffuse[2] * Global::ambientDayLight[2]); - glColor4ub(r, g, b, linealpha); // przezroczystosc dalekiej linii - // glDisable(GL_LIGHTING); //nie powinny świecić - glDrawArrays(iType, iVboPtr, iNumPts); // rysowanie linii - // glEnable(GL_LIGHTING); - } - return; - default: - if (iVboPtr >= 0) - RaRenderVBO(); - }; - return; -}; - -void TGroundNode::RenderAlphaVBO() -{ // renderowanie obiektu z VBO - faza przezroczystych - double mgn = SquareMagnitude(pCenter - Global::pCameraPosition); - float r, g, b; - if (mgn < fSquareMinRadius) - return; - if (mgn > fSquareRadius) - return; - int i, a; -#ifdef _PROBLEND - if ((PROBLEND)) // sprawdza, czy w nazwie nie ma @ //Q: 13122011 - Szociu: 27012012 - { - glDisable(GL_BLEND); - glAlphaFunc(GL_GREATER, 0.45); // im mniejsza wartość, tym większa ramka, domyślnie 0.1f - }; -#endif - switch (iType) - { - case TP_TRACTION: - if (bVisible) - { -#ifdef _PROBLEND - glEnable(GL_BLEND); - glAlphaFunc(GL_GREATER, 0.04); - glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); -#endif - hvTraction->RenderVBO(mgn, iVboPtr); - } - return; - case TP_MODEL: -#ifdef _PROBLEND - glEnable(GL_BLEND); - glAlphaFunc(GL_GREATER, 0.04); - glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); -#endif - Model->RenderAlphaVBO(&pCenter); - return; - case GL_LINES: - case GL_LINE_STRIP: - case GL_LINE_LOOP: - if (iNumPts) - { - float linealpha = 255000 * fLineThickness / (mgn + 1.0); - if (linealpha > 255) - linealpha = 255; - r = Diffuse[0] * Global::ambientDayLight[0]; // w zaleznosci od koloru swiatla - g = Diffuse[1] * Global::ambientDayLight[1]; - b = Diffuse[2] * Global::ambientDayLight[2]; - glColor4ub(r, g, b, linealpha); // przezroczystosc dalekiej linii - // glDisable(GL_LIGHTING); //nie powinny świecić - glDrawArrays(iType, iVboPtr, iNumPts); // rysowanie linii -// glEnable(GL_LIGHTING); -#ifdef _PROBLEND - glEnable(GL_BLEND); - glAlphaFunc(GL_GREATER, 0.04); - glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); -#endif - } -#ifdef _PROBLEND - glEnable(GL_BLEND); - glAlphaFunc(GL_GREATER, 0.04); - glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); -#endif - return; - default: - if (iVboPtr >= 0) - { - RaRenderVBO(); -#ifdef _PROBLEND - glEnable(GL_BLEND); - glAlphaFunc(GL_GREATER, 0.04); - glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); -#endif - return; - } - } -#ifdef _PROBLEND - glEnable(GL_BLEND); - glAlphaFunc(GL_GREATER, 0.04); - glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); -#endif - return; -} - -void TGroundNode::Compile(bool many) -{ // tworzenie skompilowanej listy w wyświetlaniu DL - if (!many) - { // obsługa pojedynczej listy - if (DisplayListID) - Release(); - if (Global::bManageNodes) - { - DisplayListID = glGenLists(1); - glNewList(DisplayListID, GL_COMPILE); - iVersion = Global::iReCompile; // aktualna wersja siatek (do WireFrame) - } - } - if ((iType == GL_LINES) || (iType == GL_LINE_STRIP) || (iType == GL_LINE_LOOP)) - { -#ifdef USE_VERTEX_ARRAYS - glVertexPointer(3, GL_DOUBLE, sizeof(vector3), &Points[0].x); -#endif - TextureManager.Bind(0); -#ifdef USE_VERTEX_ARRAYS - glDrawArrays(iType, 0, iNumPts); -#else - glBegin(iType); - for (int i = 0; i < iNumPts; i++) - glVertex3dv(&Points[i].x); - glEnd(); -#endif - } - else if (iType == GL_TRIANGLE_STRIP || iType == GL_TRIANGLE_FAN || iType == GL_TRIANGLES) - { // jak nie linie, to trójkąty - TGroundNode *tri = this; - do - { // pętla po obiektach w grupie w celu połączenia siatek -#ifdef USE_VERTEX_ARRAYS - glVertexPointer(3, GL_DOUBLE, sizeof(TGroundVertex), &tri->Vertices[0].Point.x); - glNormalPointer(GL_DOUBLE, sizeof(TGroundVertex), &tri->Vertices[0].Normal.x); - glTexCoordPointer(2, GL_FLOAT, sizeof(TGroundVertex), &tri->Vertices[0].tu); -#endif - glColor3ub(tri->Diffuse[0], tri->Diffuse[1], tri->Diffuse[2]); - TextureManager.Bind(Global::bWireFrame ? 0 : tri->TextureID); -#ifdef USE_VERTEX_ARRAYS - glDrawArrays(Global::bWireFrame ? GL_LINE_LOOP : tri->iType, 0, tri->iNumVerts); -#else - glBegin(Global::bWireFrame ? GL_LINE_LOOP : tri->iType); - for (int i = 0; i < tri->iNumVerts; i++) - { - glNormal3d(tri->Vertices[i].Normal.x, tri->Vertices[i].Normal.y, - tri->Vertices[i].Normal.z); - glTexCoord2f(tri->Vertices[i].tu, tri->Vertices[i].tv); - glVertex3dv(&tri->Vertices[i].Point.x); - }; - glEnd(); -#endif - /* - if (tri->pTriGroup) //jeśli z grupy - {tri=tri->pNext2; //następny w sektorze - while (tri?!tri->pTriGroup:false) tri=tri->pNext2; //szukamy kolejnego należącego do - grupy - } - else - */ - tri = NULL; // a jak nie, to koniec - } while (tri); - } - else if (iType == TP_MESH) - { // grupa ze wspólną teksturą - wrzucanie do wspólnego Display List - if (TextureID) - TextureManager.Bind(TextureID); // Ustaw aktywną teksturę - TGroundNode *n = nNode; - while (n ? n->TextureID == TextureID : false) - { // wszystkie obiekty o tej samej testurze - switch (n->iType) - { // poszczególne typy różnie się tworzy - case TP_TRACK: - case TP_DUMMYTRACK: - n->pTrack->Compile(TextureID); // dodanie trójkątów dla podanej tekstury - break; - } - n = n->nNext3; // następny z listy - } - } - if (!many) - if (Global::bManageNodes) - glEndList(); -}; - -void TGroundNode::Release() -{ - if (DisplayListID) - glDeleteLists(DisplayListID, 1); - DisplayListID = 0; -}; - -void TGroundNode::RenderHidden() -{ // renderowanie obiektów niewidocznych - double mgn = SquareMagnitude(pCenter - Global::pCameraPosition); - switch (iType) - { - case TP_SOUND: // McZapkie - dzwiek zapetlony w zaleznosci od odleglosci - if ((tsStaticSound->GetStatus() & DSBSTATUS_PLAYING) == DSBPLAY_LOOPING) - { - tsStaticSound->Play(1, DSBPLAY_LOOPING, true, tsStaticSound->vSoundPosition); - tsStaticSound->AdjFreq(1.0, Timer::GetDeltaTime()); - } - return; - case TP_EVLAUNCH: - if (EvLaunch->Render()) - if ((EvLaunch->dRadius < 0) || (mgn < EvLaunch->dRadius)) - { - WriteLog("Eventlauncher " + asName); - if (Console::Pressed(VK_SHIFT) && (EvLaunch->Event2)) - Global::AddToQuery(EvLaunch->Event2, NULL); - else if (EvLaunch->Event1) - Global::AddToQuery(EvLaunch->Event1, NULL); - } - return; - } -}; - -void TGroundNode::RenderDL() -{ // wyświetlanie obiektu przez Display List - switch (iType) - { // obiekty renderowane niezależnie od odległości - case TP_SUBMODEL: - TSubModel::fSquareDist = 0; - return smTerrain->RenderDL(); - } - // if (pTriGroup) if (pTriGroup!=this) return; //wyświetla go inny obiekt - double mgn = SquareMagnitude(pCenter - Global::pCameraPosition); - if ((mgn > fSquareRadius) || (mgn < fSquareMinRadius)) // McZapkie-070602: nie rysuj odleglych - // obiektow ale sprawdzaj wyzwalacz - // zdarzen - return; - int i, a; - switch (iType) - { - case TP_TRACK: - return pTrack->Render(); - case TP_MODEL: - return Model->RenderDL(&pCenter); - } - // TODO: sprawdzic czy jest potrzebny warunek fLineThickness < 0 - // if ((iNumVerts&&(iFlags&0x10))||(iNumPts&&(fLineThickness<0))) - if ((iFlags & 0x10) || (fLineThickness < 0)) - { - if (!DisplayListID || (iVersion != Global::iReCompile)) // Ra: wymuszenie rekompilacji - { - Compile(); - if (Global::bManageNodes) - ResourceManager::Register(this); - }; - - if ((iType == GL_LINES) || (iType == GL_LINE_STRIP) || (iType == GL_LINE_LOOP)) - // if (iNumPts) - { // wszelkie linie są rysowane na samym końcu - float r, g, b; - r = Diffuse[0] * Global::ambientDayLight[0]; // w zaleznosci od koloru swiatla - g = Diffuse[1] * Global::ambientDayLight[1]; - b = Diffuse[2] * Global::ambientDayLight[2]; - glColor4ub(r, g, b, 1.0); - glCallList(DisplayListID); - // glColor4fv(Diffuse); //przywrócenie koloru - // glColor3ub(Diffuse[0],Diffuse[1],Diffuse[2]); - } - // GL_TRIANGLE etc - else - glCallList(DisplayListID); - SetLastUsage(Timer::GetSimulationTime()); - }; -}; - -void TGroundNode::RenderAlphaDL() -{ - // SPOSOB NA POZBYCIE SIE RAMKI DOOKOLA TEXTURY ALPHA DLA OBIEKTOW ZAGNIEZDZONYCH W SCN JAKO - // NODE - - // W GROUND.H dajemy do klasy TGroundNode zmienna bool PROBLEND to samo robimy w klasie TGround - // nastepnie podczas wczytywania textury dla TRIANGLES w TGround::AddGroundNode - // sprawdzamy czy w nazwie jest @ i wg tego - // ustawiamy PROBLEND na true dla wlasnie wczytywanego trojkata (kazdy trojkat jest osobnym - // nodem) - // nastepnie podczas renderowania w bool TGroundNode::RenderAlpha() - // na poczatku ustawiamy standardowe GL_GREATER = 0.04 - // pozniej sprawdzamy czy jest wlaczony PROBLEND dla aktualnie renderowanego noda TRIANGLE, - // wlasciwie dla kazdego node'a - // i jezeli tak to odpowiedni GL_GREATER w przeciwnym wypadku standardowy 0.04 - - // if (pTriGroup) if (pTriGroup!=this) return; //wyświetla go inny obiekt - double mgn = SquareMagnitude(pCenter - Global::pCameraPosition); - float r, g, b; - if (mgn < fSquareMinRadius) - return; - if (mgn > fSquareRadius) - return; - int i, a; - switch (iType) - { - case TP_TRACTION: - if (bVisible) - hvTraction->RenderDL(mgn); - return; - case TP_MODEL: - Model->RenderAlphaDL(&pCenter); - return; - case TP_TRACK: - // pTrack->RenderAlpha(); - return; - }; - - // TODO: sprawdzic czy jest potrzebny warunek fLineThickness < 0 - if ((iNumVerts && (iFlags & 0x20)) || (iNumPts && (fLineThickness > 0))) - { -#ifdef _PROBLEND - if ((PROBLEND)) // sprawdza, czy w nazwie nie ma @ //Q: 13122011 - Szociu: 27012012 - { - glDisable(GL_BLEND); - glAlphaFunc(GL_GREATER, 0.45); // im mniejsza wartość, tym większa ramka, domyślnie 0.1f - }; -#endif - if (!DisplayListID) //||Global::bReCompile) //Ra: wymuszenie rekompilacji - { - Compile(); - if (Global::bManageNodes) - ResourceManager::Register(this); - }; - - // GL_LINE, GL_LINE_STRIP, GL_LINE_LOOP - if (iNumPts) - { - float linealpha = 255000 * fLineThickness / (mgn + 1.0); - if (linealpha > 255) - linealpha = 255; - r = Diffuse[0] * Global::ambientDayLight[0]; // w zaleznosci od koloru swiatla - g = Diffuse[1] * Global::ambientDayLight[1]; - b = Diffuse[2] * Global::ambientDayLight[2]; - glColor4ub(r, g, b, linealpha); // przezroczystosc dalekiej linii - glCallList(DisplayListID); - } - // GL_TRIANGLE etc - else - glCallList(DisplayListID); - SetLastUsage(Timer::GetSimulationTime()); - }; -#ifdef _PROBLEND - if ((PROBLEND)) // sprawdza, czy w nazwie nie ma @ //Q: 13122011 - Szociu: 27012012 - { - glEnable(GL_BLEND); - glAlphaFunc(GL_GREATER, 0.04); - glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); - }; -#endif -} - -//------------------------------------------------------------------------------ -//------------------ Podstawowy pojemnik terenu - sektor ----------------------- -//------------------------------------------------------------------------------ -TSubRect::~TSubRect() -{ - if (Global::bManageNodes) // Ra: tu się coś sypie - ResourceManager::Unregister(this); // wyrejestrowanie ze sprzątacza - // TODO: usunąć obiekty z listy (nRootMesh), bo są one tworzone dla sektora - delete[] tTracks; -} - -void TSubRect::NodeAdd(TGroundNode *Node) -{ // przyczepienie obiektu do sektora, wstępna kwalifikacja na listy renderowania - if (!this) - return; // zabezpiecznie przed obiektami przekraczającymi obszar roboczy - // Ra: sortowanie obiektów na listy renderowania: - // nRenderHidden - lista obiektów niewidocznych, "renderowanych" również z tyłu - // nRenderRect - lista grup renderowanych z sektora - // nRenderRectAlpha - lista grup renderowanych z sektora z przezroczystością - // nRender - lista grup renderowanych z własnych VBO albo DL - // nRenderAlpha - lista grup renderowanych z własnych VBO albo DL z przezroczystością - // nRenderWires - lista grup renderowanych z własnych VBO albo DL - druty i linie - // nMeshed - obiekty do pogrupowania wg tekstur - GLuint t; // pomocniczy kod tekstury - switch (Node->iType) - { - case TP_SOUND: // te obiekty są sprawdzanie niezależnie od kierunku patrzenia - case TP_EVLAUNCH: - Node->nNext3 = nRenderHidden; - nRenderHidden = Node; // do listy koniecznych - break; - case TP_TRACK: // TODO: tory z cieniem (tunel, canyon) też dać bez łączenia? - ++iTracks; // jeden tor więcej - Node->pTrack->RaOwnerSet(this); // do którego sektora ma zgłaszać animację - // if (Global::bUseVBO?false:!Node->pTrack->IsGroupable()) - if (Global::bUseVBO ? true : - !Node->pTrack->IsGroupable()) // TODO: tymczasowo dla VBO wyłączone - RaNodeAdd( - Node); // tory ruchome nie są grupowane przy Display Lists (wymagają odświeżania DL) - else - { // tory nieruchome mogą być pogrupowane wg tekstury, przy VBO wszystkie - Node->TextureID = Node->pTrack->TextureGet(0); // pobranie tekstury do sortowania - t = Node->pTrack->TextureGet(1); - if (Node->TextureID) // jeżeli jest pierwsza - { - if (t && (Node->TextureID != t)) - { // jeśli są dwie różne tekstury, dodajemy drugi obiekt dla danego toru - TGroundNode *n = new TGroundNode(); // BUG: source of a memory leak here - n->iType = TP_DUMMYTRACK; // obiekt renderujący siatki dla tekstury - n->TextureID = t; - n->pTrack = Node->pTrack; // wskazuje na ten sam tor - n->pCenter = Node->pCenter; - n->fSquareRadius = Node->fSquareRadius; - n->fSquareMinRadius = Node->fSquareMinRadius; - n->iFlags = Node->iFlags; - n->nNext2 = nRootMesh; - nRootMesh = n; // podczepienie do listy, żeby usunąć na końcu - n->nNext3 = nMeshed; - nMeshed = n; - } - } - else - Node->TextureID = t; // jest tylko druga tekstura - if (Node->TextureID) - { - Node->nNext3 = nMeshed; - nMeshed = Node; - } // do podzielenia potem - } - break; - case GL_TRIANGLE_STRIP: - case GL_TRIANGLE_FAN: - case GL_TRIANGLES: - // Node->nNext3=nMeshed; nMeshed=Node; //do podzielenia potem - if (Node->iFlags & 0x20) // czy jest przezroczyste? - { - Node->nNext3 = nRenderRectAlpha; - nRenderRectAlpha = Node; - } // DL: do przezroczystych z sektora - else if (Global::bUseVBO) - { - Node->nNext3 = nRenderRect; - nRenderRect = Node; - } // VBO: do nieprzezroczystych z sektora - else - { - Node->nNext3 = nRender; - nRender = Node; - } // DL: do nieprzezroczystych wszelakich - /* - //Ra: na razie wyłączone do testów VBO - //if - ((Node->iType==GL_TRIANGLE_STRIP)||(Node->iType==GL_TRIANGLE_FAN)||(Node->iType==GL_TRIANGLES)) - if (Node->fSquareMinRadius==0.0) //znikające z bliska nie mogą być optymalizowane - if (Node->fSquareRadius>=160000.0) //tak od 400m to już normalne trójkąty muszą być - //if (Node->iFlags&0x10) //i nieprzezroczysty - {if (pTriGroup) //jeżeli był już jakiś grupujący - {if (pTriGroup->fSquareRadius>Node->fSquareRadius) //i miał większy zasięg - Node->fSquareRadius=pTriGroup->fSquareRadius; //zwiększenie zakresu widoczności - grupującego - pTriGroup->pTriGroup=Node; //poprzedniemu doczepiamy nowy - } - Node->pTriGroup=Node; //nowy lider ma się sam wyświetlać - wskaźnik na siebie - pTriGroup=Node; //zapamiętanie lidera - } - */ - break; - case TP_TRACTION: - case GL_LINES: - case GL_LINE_STRIP: - case GL_LINE_LOOP: // te renderowane na końcu, żeby nie łapały koloru nieba - Node->nNext3 = nRenderWires; - nRenderWires = Node; // lista drutów - break; - case TP_MODEL: // modele zawsze wyświetlane z własnego VBO - // jeśli model jest prosty, można próbować zrobić wspólną siatkę (słupy) - if ((Node->iFlags & 0x20200020) == 0) // czy brak przezroczystości? - { - Node->nNext3 = nRender; - nRender = Node; - } // do nieprzezroczystych - else if ((Node->iFlags & 0x10100010) == 0) // czy brak nieprzezroczystości? - { - Node->nNext3 = nRenderAlpha; - nRenderAlpha = Node; - } // do przezroczystych - else // jak i take i takie, to będzie dwa razy renderowane... - { - Node->nNext3 = nRenderMixed; - nRenderMixed = Node; - } // do mieszanych - // Node->nNext3=nMeshed; //dopisanie do listy sortowania - // nMeshed=Node; - break; - case TP_MEMCELL: - case TP_TRACTIONPOWERSOURCE: // a te w ogóle pomijamy - // case TP_ISOLATED: //lista torów w obwodzie izolowanym - na razie ignorowana - break; - case TP_DYNAMIC: - return; // tych nie dopisujemy wcale - } - Node->nNext2 = nRootNode; // dopisanie do ogólnej listy - nRootNode = Node; - ++iNodeCount; // licznik obiektów -} - -void TSubRect::RaNodeAdd(TGroundNode *Node) -{ // finalna kwalifikacja na listy renderowania, jeśli nie obsługiwane grupowo - switch (Node->iType) - { - case TP_TRACK: - if (Global::bUseVBO) - { - Node->nNext3 = nRenderRect; - nRenderRect = Node; - } // VBO: do nieprzezroczystych z sektora - else - { - Node->nNext3 = nRender; - nRender = Node; - } // DL: do nieprzezroczystych - break; - case GL_TRIANGLE_STRIP: - case GL_TRIANGLE_FAN: - case GL_TRIANGLES: - if (Node->iFlags & 0x20) // czy jest przezroczyste? - { - Node->nNext3 = nRenderRectAlpha; - nRenderRectAlpha = Node; - } // DL: do przezroczystych z sektora - else if (Global::bUseVBO) - { - Node->nNext3 = nRenderRect; - nRenderRect = Node; - } // VBO: do nieprzezroczystych z sektora - else - { - Node->nNext3 = nRender; - nRender = Node; - } // DL: do nieprzezroczystych wszelakich - break; - case TP_MODEL: // modele zawsze wyświetlane z własnego VBO - if ((Node->iFlags & 0x20200020) == 0) // czy brak przezroczystości? - { - Node->nNext3 = nRender; - nRender = Node; - } // do nieprzezroczystych - else if ((Node->iFlags & 0x10100010) == 0) // czy brak nieprzezroczystości? - { - Node->nNext3 = nRenderAlpha; - nRenderAlpha = Node; - } // do przezroczystych - else // jak i take i takie, to będzie dwa razy renderowane... - { - Node->nNext3 = nRenderMixed; - nRenderMixed = Node; - } // do mieszanych - break; - case TP_MESH: // grupa ze wspólną teksturą - //{Node->nNext3=nRenderRect; nRenderRect=Node;} //do nieprzezroczystych z sektora - { - Node->nNext3 = nRender; - nRender = Node; - } // do nieprzezroczystych - break; - case TP_SUBMODEL: // submodele terenu w kwadracie kilometrowym idą do nRootMesh - // WriteLog("nRootMesh was "+AnsiString(nRootMesh?"not null ":"null - // ")+IntToHex(int(this),8)); - Node->nNext3 = nRootMesh; // przy VBO musi być inaczej - nRootMesh = Node; - break; - } -} - -void TSubRect::Sort() -{ // przygotowanie sektora do renderowania - TGroundNode **n0, *n1, *n2; // wskaźniki robocze - delete[] tTracks; // usunięcie listy - tTracks = - iTracks ? new TTrack *[iTracks] : NULL; // tworzenie tabeli torów do renderowania pojazdów - if (tTracks) - { // wypełnianie tabeli torów - int i = 0; - for (n1 = nRootNode; n1; n1 = n1->nNext2) // kolejne obiekty z sektora - if (n1->iType == TP_TRACK) - tTracks[i++] = n1->pTrack; - } - // sortowanie obiektów w sektorze na listy renderowania - if (!nMeshed) - return; // nie ma nic do sortowania - bool sorted = false; - while (!sorted) - { // sortowanie bąbelkowe obiektów wg tekstury - sorted = true; // zakładamy posortowanie - n0 = &nMeshed; // wskaźnik niezbędny do zamieniania obiektów - n1 = nMeshed; // lista obiektów przetwarzanych na statyczne siatki - while (n1) - { // sprawdzanie stanu posortowania obiektów i ewentualne zamiany - n2 = n1->nNext3; // kolejny z tej listy - if (n2) // jeśli istnieje - if (n1->TextureID > n2->TextureID) - { // zamiana elementów miejscami - *n0 = n2; // drugi będzie na początku - n1->nNext3 = n2->nNext3; // ten zza drugiego będzie za pierwszym - n2->nNext3 = n1; // a za drugim będzie pierwszy - sorted = false; // potrzebny kolejny przebieg - } - n0 = &(n1->nNext3); - n1 = n2; - }; - } - // wyrzucenie z listy obiektów pojedynczych (nie ma z czym ich grupować) - // nawet jak są pojedyncze, to i tak lepiej, aby były w jednym Display List - /* - else - {//dodanie do zwykłej listy renderowania i usunięcie z grupowego - *n0=n2; //drugi będzie na początku - RaNodeAdd(n1); //nie ma go z czym zgrupować; (n1->nNext3) zostanie nadpisane - n1=n2; //potrzebne do ustawienia (n0) - } - */ - //... - // przeglądanie listy i tworzenie obiektów renderujących dla danej tekstury - GLuint t = 0; // pomocniczy kod tekstury - n1 = nMeshed; // lista obiektów przetwarzanych na statyczne siatki - while (n1) - { // dla każdej tekstury powinny istnieć co najmniej dwa obiekty, ale dla DL nie ma to znaczenia - if (t < n1->TextureID) // jeśli (n1) ma inną teksturę niż poprzednie - { // można zrobić obiekt renderujący - t = n1->TextureID; - n2 = new TGroundNode(); // BUG: source of a memory leak here - n2->nNext2 = nRootMesh; - nRootMesh = n2; // podczepienie na początku listy - nRootMesh->iType = TP_MESH; // obiekt renderujący siatki dla tekstury - nRootMesh->TextureID = t; - nRootMesh->nNode = n1; // pierwszy element z listy - nRootMesh->pCenter = n1->pCenter; - nRootMesh->fSquareRadius = 1e8; // widać bez ograniczeń - nRootMesh->fSquareMinRadius = 0.0; - nRootMesh->iFlags = 0x10; - RaNodeAdd(nRootMesh); // dodanie do odpowiedniej listy renderowania - } - n1 = n1->nNext3; // kolejny z tej listy - }; -} - -TTrack * TSubRect::FindTrack(vector3 *Point, int &iConnection, TTrack *Exclude) -{ // szukanie toru, którego koniec jest najbliższy (*Point) - TTrack *Track; - for (int i = 0; i < iTracks; ++i) - if (tTracks[i] != Exclude) // można użyć tabelę torów, bo jest mniejsza - { - iConnection = tTracks[i]->TestPoint(Point); - if (iConnection >= 0) - return tTracks[i]; // szukanie TGroundNode nie jest potrzebne - } - /* - TGroundNode *Current; - for (Current=nRootNode;Current;Current=Current->Next) - if ((Current->iType==TP_TRACK)&&(Current->pTrack!=Exclude)) //można użyć tabelę torów - { - iConnection=Current->pTrack->TestPoint(Point); - if (iConnection>=0) return Current; - } - */ - return NULL; -}; - -bool TSubRect::RaTrackAnimAdd(TTrack *t) -{ // aktywacja animacji torów w VBO (zwrotnica, obrotnica) - if (m_nVertexCount < 0) - return true; // nie ma animacji, gdy nie widać - if (tTrackAnim) - tTrackAnim->RaAnimListAdd(t); - else - tTrackAnim = t; - return false; // będzie animowane... -} - -void TSubRect::RaAnimate() -{ // wykonanie animacji - if (!tTrackAnim) - return; // nie ma nic do animowania - if (Global::bUseVBO) - { // odświeżenie VBO sektora - if (true == GLEW_VERSION_1_5) // modyfikacje VBO są dostępne od OpenGL 1.5 - glBindBuffer(GL_ARRAY_BUFFER, m_nVBOVertices); - else // dla OpenGL 1.4 z GL_ARB_vertex_buffer_object odświeżenie całego sektora - Release(); // opróżnienie VBO sektora, aby się odświeżył z nowymi ustawieniami - } - tTrackAnim = tTrackAnim->RaAnimate(); // przeliczenie animacji kolejnego -}; - -TTraction * TSubRect::FindTraction(vector3 *Point, int &iConnection, TTraction *Exclude) -{ // szukanie przęsła w sektorze, którego koniec jest najbliższy (*Point) - TGroundNode *Current; - for (Current = nRenderWires; Current; Current = Current->nNext3) - if ((Current->iType == TP_TRACTION) && (Current->hvTraction != Exclude)) - { - iConnection = Current->hvTraction->TestPoint(Point); - if (iConnection >= 0) - return Current->hvTraction; - } - return NULL; -}; - -void TSubRect::LoadNodes() -{ // utworzenie siatek VBO dla wszystkich node w sektorze - if (m_nVertexCount >= 0) - return; // obiekty były już sprawdzone - m_nVertexCount = 0; //-1 oznacza, że nie sprawdzono listy obiektów - if (!nRootNode) - return; - TGroundNode *n = nRootNode; - while (n) - { - switch (n->iType) - { - case GL_TRIANGLE_STRIP: - case GL_TRIANGLE_FAN: - case GL_TRIANGLES: - n->iVboPtr = m_nVertexCount; // nowy początek - m_nVertexCount += n->iNumVerts; - break; - case GL_LINES: - case GL_LINE_STRIP: - case GL_LINE_LOOP: - n->iVboPtr = m_nVertexCount; // nowy początek - m_nVertexCount += - n->iNumPts; // miejsce w tablicach normalnych i teksturowania się zmarnuje... - break; - case TP_TRACK: - n->iVboPtr = m_nVertexCount; // nowy początek - n->iNumVerts = n->pTrack->RaArrayPrepare(); // zliczenie wierzchołków - m_nVertexCount += n->iNumVerts; - break; - case TP_TRACTION: - n->iVboPtr = m_nVertexCount; // nowy początek - n->iNumVerts = n->hvTraction->RaArrayPrepare(); // zliczenie wierzchołków - m_nVertexCount += n->iNumVerts; - break; - } - n = n->nNext2; // następny z sektora - } - if (!m_nVertexCount) - return; // jeśli nie ma obiektów do wyświetlenia z VBO, to koniec - if (Global::bUseVBO) - { // tylko liczenie wierzchołów, gdy nie ma VBO - MakeArray(m_nVertexCount); - n = nRootNode; - int i; - while (n) - { - if (n->iVboPtr >= 0) - switch (n->iType) - { - case GL_TRIANGLE_STRIP: - case GL_TRIANGLE_FAN: - case GL_TRIANGLES: - for (i = 0; i < n->iNumVerts; ++i) - { // Ra: trójkąty można od razu wczytywać do takich tablic... to może poczekać - m_pVNT[n->iVboPtr + i].x = n->Vertices[i].Point.x; - m_pVNT[n->iVboPtr + i].y = n->Vertices[i].Point.y; - m_pVNT[n->iVboPtr + i].z = n->Vertices[i].Point.z; - m_pVNT[n->iVboPtr + i].nx = n->Vertices[i].Normal.x; - m_pVNT[n->iVboPtr + i].ny = n->Vertices[i].Normal.y; - m_pVNT[n->iVboPtr + i].nz = n->Vertices[i].Normal.z; - m_pVNT[n->iVboPtr + i].u = n->Vertices[i].tu; - m_pVNT[n->iVboPtr + i].v = n->Vertices[i].tv; - } - break; - case GL_LINES: - case GL_LINE_STRIP: - case GL_LINE_LOOP: - for (i = 0; i < n->iNumPts; ++i) - { - m_pVNT[n->iVboPtr + i].x = n->Points[i].x; - m_pVNT[n->iVboPtr + i].y = n->Points[i].y; - m_pVNT[n->iVboPtr + i].z = n->Points[i].z; - // miejsce w tablicach normalnych i teksturowania się marnuje... - } - break; - case TP_TRACK: - if (n->iNumVerts) // bo tory zabezpieczające są niewidoczne - n->pTrack->RaArrayFill(m_pVNT + n->iVboPtr, m_pVNT); - break; - case TP_TRACTION: - if (n->iNumVerts) // druty mogą być niewidoczne...? - n->hvTraction->RaArrayFill(m_pVNT + n->iVboPtr); - break; - } - n = n->nNext2; // następny z sektora - } - BuildVBOs(); - } - if (Global::bManageNodes) - ResourceManager::Register(this); // dodanie do automatu zwalniającego pamięć -} - -bool TSubRect::StartVBO() -{ // początek rysowania elementów z VBO w sektorze - SetLastUsage(Timer::GetSimulationTime()); // te z tyłu będą niepotrzebnie zwalniane - return CMesh::StartVBO(); -}; - -void TSubRect::Release() -{ // wirtualne zwolnienie zasobów przez sprzątacz albo destruktor - if (Global::bUseVBO) - CMesh::Clear(); // usuwanie buforów -}; - -void TSubRect::RenderDL() -{ // renderowanie nieprzezroczystych (DL) - TGroundNode *node; - RaAnimate(); // przeliczenia animacji torów w sektorze - for (node = nRender; node; node = node->nNext3) - node->RenderDL(); // nieprzezroczyste obiekty (oprócz pojazdów) - for (node = nRenderMixed; node; node = node->nNext3) - node->RenderDL(); // nieprzezroczyste z mieszanych modeli - for (int j = 0; j < iTracks; ++j) - tTracks[j]->RenderDyn(); // nieprzezroczyste fragmenty pojazdów na torach -}; - -void TSubRect::RenderAlphaDL() -{ // renderowanie przezroczystych modeli oraz pojazdów (DL) - TGroundNode *node; - for (node = nRenderMixed; node; node = node->nNext3) - node->RenderAlphaDL(); // przezroczyste z mieszanych modeli - for (node = nRenderAlpha; node; node = node->nNext3) - node->RenderAlphaDL(); // przezroczyste modele - // for (node=tmp->nRender;node;node=node->nNext3) - // if (node->iType==TP_TRACK) - // node->pTrack->RenderAlpha(); //przezroczyste fragmenty pojazdów na torach - for (int j = 0; j < iTracks; ++j) - tTracks[j]->RenderDynAlpha(); // przezroczyste fragmenty pojazdów na torach -}; - -void TSubRect::RenderVBO() -{ // renderowanie nieprzezroczystych (VBO) - TGroundNode *node; - RaAnimate(); // przeliczenia animacji torów w sektorze - LoadNodes(); // czemu tutaj? - if (StartVBO()) - { - for (node = nRenderRect; node; node = node->nNext3) - if (node->iVboPtr >= 0) - node->RenderVBO(); // nieprzezroczyste obiekty terenu - EndVBO(); - } - for (node = nRender; node; node = node->nNext3) - node->RenderVBO(); // nieprzezroczyste obiekty (oprócz pojazdów) - for (node = nRenderMixed; node; node = node->nNext3) - node->RenderVBO(); // nieprzezroczyste z mieszanych modeli - for (int j = 0; j < iTracks; ++j) - tTracks[j]->RenderDyn(); // nieprzezroczyste fragmenty pojazdów na torach -}; - -void TSubRect::RenderAlphaVBO() -{ // renderowanie przezroczystych modeli oraz pojazdów (VBO) - TGroundNode *node; - for (node = nRenderMixed; node; node = node->nNext3) - node->RenderAlphaVBO(); // przezroczyste z mieszanych modeli - for (node = nRenderAlpha; node; node = node->nNext3) - node->RenderAlphaVBO(); // przezroczyste modele - // for (node=tmp->nRender;node;node=node->nNext3) - // if (node->iType==TP_TRACK) - // node->pTrack->RenderAlpha(); //przezroczyste fragmenty pojazdów na torach - for (int j = 0; j < iTracks; ++j) - tTracks[j]->RenderDynAlpha(); // przezroczyste fragmenty pojazdów na torach -}; - -void TSubRect::RenderSounds() -{ // aktualizacja dźwięków w pojazdach sektora (sektor może nie być wyświetlany) - for (int j = 0; j < iTracks; ++j) - tTracks[j]->RenderDynSounds(); // dźwięki pojazdów idą niezależnie od wyświetlania -}; -//--------------------------------------------------------------------------- -//------------------ Kwadrat kilometrowy ------------------------------------ -//--------------------------------------------------------------------------- -int TGroundRect::iFrameNumber = 0; // licznik wyświetlanych klatek - -TGroundRect::TGroundRect() -{ - pSubRects = NULL; - nTerrain = NULL; -}; - -TGroundRect::~TGroundRect() -{ - SafeDeleteArray(pSubRects); -}; - -void TGroundRect::RenderDL() -{ // renderowanie kwadratu kilometrowego (DL), jeśli jeszcze nie zrobione - if (iLastDisplay != iFrameNumber) - { // tylko jezeli dany kwadrat nie był jeszcze renderowany - // for (TGroundNode* node=pRender;node;node=node->pNext3) - // node->Render(); //nieprzezroczyste trójkąty kwadratu kilometrowego - if (nRender) - { //łączenie trójkątów w jedną listę - trochę wioska - if (!nRender->DisplayListID || (nRender->iVersion != Global::iReCompile)) - { // jeżeli nie skompilowany, kompilujemy wszystkie trójkąty w jeden - nRender->fSquareRadius = 5000.0 * 5000.0; // aby agregat nigdy nie znikał - nRender->DisplayListID = glGenLists(1); - glNewList(nRender->DisplayListID, GL_COMPILE); - nRender->iVersion = Global::iReCompile; // aktualna wersja siatek - for (TGroundNode *node = nRender; node; node = node->nNext3) // następny tej grupy - node->Compile(true); - glEndList(); - } - nRender->RenderDL(); // nieprzezroczyste trójkąty kwadratu kilometrowego - } - if (nRootMesh) - nRootMesh->RenderDL(); - iLastDisplay = iFrameNumber; // drugi raz nie potrzeba - } -}; - -void TGroundRect::RenderVBO() -{ // renderowanie kwadratu kilometrowego (VBO), jeśli jeszcze nie zrobione - if (iLastDisplay != iFrameNumber) - { // tylko jezeli dany kwadrat nie był jeszcze renderowany - LoadNodes(); // ewentualne tworzenie siatek - if (StartVBO()) - { - for (TGroundNode *node = nRenderRect; node; node = node->nNext3) // następny tej grupy - node->RaRenderVBO(); // nieprzezroczyste trójkąty kwadratu kilometrowego - EndVBO(); - iLastDisplay = iFrameNumber; - } - if (nTerrain) - nTerrain->smTerrain->iVisible = iFrameNumber; // ma się wyświetlić w tej ramce - } -}; - -//--------------------------------------------------------------------------- -//--------------------------------------------------------------------------- -//--------------------------------------------------------------------------- - -void TGround::MoveGroundNode(vector3 pPosition) -{ // Ra: to wymaga gruntownej reformy - /* - TGroundNode *Current; - for (Current=RootNode;Current!=NULL;Current=Current->Next) - Current->MoveMe(pPosition); - - TGroundRect *Rectx=new TGroundRect; //kwadrat kilometrowy - for(int i=0;iNext) - {//rozłożenie obiektów na mapie - if (Current->iType!=TP_DYNAMIC) - {//pojazdów to w ogóle nie dotyczy - if ((Current->iType!=GL_TRIANGLES)&&(Current->iType!=GL_TRIANGLE_STRIP)?true //~czy trójkąt? - :(Current->iFlags&0x20)?true //~czy teksturę ma nieprzezroczystą? - //:(Current->iNumVerts!=3)?true //~czy tylko jeden trójkąt? - :(Current->fSquareMinRadius!=0.0)?true //~czy widoczny z bliska? - :(Current->fSquareRadius<=90000.0)) //~czy widoczny z daleka? - GetSubRect(Current->pCenter.x,Current->pCenter.z)->AddNode(Current); - else //dodajemy do kwadratu kilometrowego - GetRect(Current->pCenter.x,Current->pCenter.z)->AddNode(Current); - } - } - for (Current=RootDynamic;Current!=NULL;Current=Current->Next) - { - Current->pCenter+=pPosition; - Current->DynamicObject->UpdatePos(); - } - for (Current=RootDynamic;Current!=NULL;Current=Current->Next) - Current->DynamicObject->MoverParameters->Physic_ReActivation(); - */ -} - -std::vector TempVerts; -/* -TGroundVertex TempVerts[ 10000 ]; // tu wczytywane s¹ trójk¹ty -*/ -BYTE TempConnectionType[ 200 ]; // Ra: sprzêgi w sk³adzie; ujemne, gdy odwrotnie - -TGround::TGround() -{ - Global::pGround = this; - - for( int i = 0; i < TP_LAST; ++i ) { - nRootOfType[ i ] = nullptr; // zerowanie tablic wyszukiwania - } -#ifdef EU07_USE_OLD_TNAMES_CLASS - sTracks = new TNames(); // nazwy torów - na razie tak -#endif - ::SecureZeroMemory( TempConnectionType, sizeof( TempConnectionType ) ); - ::SecureZeroMemory( pRendered, sizeof( pRendered ) ); -} - -TGround::~TGround() -{ - Free(); -} - -void TGround::Free() -{ - TEvent *tmp; - for (TEvent *Current = RootEvent; Current;) - { - tmp = Current; - Current = Current->evNext2; - delete tmp; - } - TGroundNode *tmpn; - for (int i = 0; i < TP_LAST; ++i) - { - for (TGroundNode *Current = nRootOfType[i]; Current;) - { - tmpn = Current; - Current = Current->nNext; - delete tmpn; - } - nRootOfType[i] = NULL; - } - for (TGroundNode *Current = nRootDynamic; Current;) - { - tmpn = Current; - Current = Current->nNext; - delete tmpn; - } - iNumNodes = 0; - // RootNode=NULL; - nRootDynamic = NULL; -#ifdef EU07_USE_OLD_TNAMES_CLASS - delete sTracks; -#endif -} - -TGroundNode * TGround::DynamicFindAny(std::string asNameToFind) -{ // wyszukanie pojazdu o podanej nazwie, szukanie po wszystkich (użyć drzewa!) - for (TGroundNode *Current = nRootDynamic; Current; Current = Current->nNext) - if ((Current->asName == asNameToFind)) - return Current; - return NULL; -}; - -TGroundNode * TGround::DynamicFind(std::string asNameToFind) -{ // wyszukanie pojazdu z obsadą o podanej nazwie (użyć drzewa!) - for (TGroundNode *Current = nRootDynamic; Current; Current = Current->nNext) - if (Current->DynamicObject->Mechanik) - if ((Current->asName == asNameToFind)) - return Current; - return NULL; -}; - -void TGround::DynamicList(bool all) -{ // odesłanie nazw pojazdów dostępnych na scenerii (nazwy, szczególnie wagonów, mogą się - // powtarzać!) - for (TGroundNode *Current = nRootDynamic; Current; Current = Current->nNext) - if (all || Current->DynamicObject->Mechanik) - WyslijString(Current->asName, 6); // same nazwy pojazdów - WyslijString("none", 6); // informacja o końcu listy -}; - -TGroundNode * TGround::FindGroundNode(std::string asNameToFind, TGroundNodeType iNodeType) -{ // wyszukiwanie obiektu o podanej nazwie i konkretnym typie - if ((iNodeType == TP_TRACK) || (iNodeType == TP_MEMCELL) || (iNodeType == TP_MODEL)) - { // wyszukiwanie w drzewie binarnym -#ifdef EU07_USE_OLD_TNAMES_CLASS - return (TGroundNode *)sTracks->Find(iNodeType, asNameToFind.c_str()); -#else -/* - switch( iNodeType ) { - - case TP_TRACK: { - auto const lookup = m_trackmap.find( asNameToFind ); - return - lookup != m_trackmap.end() ? - lookup->second : - nullptr; - } - case TP_MODEL: { - auto const lookup = m_modelmap.find( asNameToFind ); - return - lookup != m_modelmap.end() ? - lookup->second : - nullptr; - } - case TP_MEMCELL: { - auto const lookup = m_memcellmap.find( asNameToFind ); - return - lookup != m_memcellmap.end() ? - lookup->second : - nullptr; - } - } - return nullptr; -*/ - return m_trackmap.Find( iNodeType, asNameToFind ); -#endif - } - // standardowe wyszukiwanie liniowe - TGroundNode *Current; - for (Current = nRootOfType[iNodeType]; Current; Current = Current->nNext) - if (Current->asName == asNameToFind) - return Current; - return NULL; -} - -double fTrainSetVel = 0; -double fTrainSetDir = 0; -double fTrainSetDist = 0; // odległość składu od punktu 1 w stronę punktu 2 -string asTrainSetTrack = ""; -int iTrainSetConnection = 0; -bool bTrainSet = false; -string asTrainName = ""; -int iTrainSetWehicleNumber = 0; -TGroundNode *nTrainSetNode = NULL; // poprzedni pojazd do łączenia -TGroundNode *nTrainSetDriver = NULL; // pojazd, któremu zostanie wysłany rozkład - -void TGround::RaTriangleDivider(TGroundNode *node) -{ // tworzy dodatkowe trójkąty i zmiejsza podany - // to jest wywoływane przy wczytywaniu trójkątów - // dodatkowe trójkąty są dodawane do głównej listy trójkątów - // podział trójkątów na sektory i kwadraty jest dokonywany później w FirstInit - if (node->iType != GL_TRIANGLES) - return; // tylko pojedyncze trójkąty - if (node->iNumVerts != 3) - return; // tylko gdy jeden trójkąt - double x0 = 1000.0 * floor(0.001 * node->pCenter.x) - 200.0; - double x1 = x0 + 1400.0; - double z0 = 1000.0 * floor(0.001 * node->pCenter.z) - 200.0; - double z1 = z0 + 1400.0; - if ((node->Vertices[0].Point.x >= x0) && (node->Vertices[0].Point.x <= x1) && - (node->Vertices[0].Point.z >= z0) && (node->Vertices[0].Point.z <= z1) && - (node->Vertices[1].Point.x >= x0) && (node->Vertices[1].Point.x <= x1) && - (node->Vertices[1].Point.z >= z0) && (node->Vertices[1].Point.z <= z1) && - (node->Vertices[2].Point.x >= x0) && (node->Vertices[2].Point.x <= x1) && - (node->Vertices[2].Point.z >= z0) && (node->Vertices[2].Point.z <= z1)) - return; // trójkąt wystający mniej niż 200m z kw. kilometrowego jest do przyjęcia - // Ra: przerobić na dzielenie na 2 trójkąty, podział w przecięciu z siatką kilometrową - // Ra: i z rekurencją będzie dzielić trzy trójkąty, jeśli będzie taka potrzeba - int divide = -1; // bok do podzielenia: 0=AB, 1=BC, 2=CA; +4=podział po OZ; +8 na x1/z1 - double min = 0, mul; // jeśli przechodzi przez oś, iloczyn będzie ujemny - x0 += 200.0; - x1 -= 200.0; // przestawienie na siatkę - z0 += 200.0; - z1 -= 200.0; - mul = (node->Vertices[0].Point.x - x0) * (node->Vertices[1].Point.x - x0); // AB na wschodzie - if (mul < min) - min = mul, divide = 0; - mul = (node->Vertices[1].Point.x - x0) * (node->Vertices[2].Point.x - x0); // BC na wschodzie - if (mul < min) - min = mul, divide = 1; - mul = (node->Vertices[2].Point.x - x0) * (node->Vertices[0].Point.x - x0); // CA na wschodzie - if (mul < min) - min = mul, divide = 2; - mul = (node->Vertices[0].Point.x - x1) * (node->Vertices[1].Point.x - x1); // AB na zachodzie - if (mul < min) - min = mul, divide = 8; - mul = (node->Vertices[1].Point.x - x1) * (node->Vertices[2].Point.x - x1); // BC na zachodzie - if (mul < min) - min = mul, divide = 9; - mul = (node->Vertices[2].Point.x - x1) * (node->Vertices[0].Point.x - x1); // CA na zachodzie - if (mul < min) - min = mul, divide = 10; - mul = (node->Vertices[0].Point.z - z0) * (node->Vertices[1].Point.z - z0); // AB na południu - if (mul < min) - min = mul, divide = 4; - mul = (node->Vertices[1].Point.z - z0) * (node->Vertices[2].Point.z - z0); // BC na południu - if (mul < min) - min = mul, divide = 5; - mul = (node->Vertices[2].Point.z - z0) * (node->Vertices[0].Point.z - z0); // CA na południu - if (mul < min) - min = mul, divide = 6; - mul = (node->Vertices[0].Point.z - z1) * (node->Vertices[1].Point.z - z1); // AB na północy - if (mul < min) - min = mul, divide = 12; - mul = (node->Vertices[1].Point.z - z1) * (node->Vertices[2].Point.z - z1); // BC na północy - if (mul < min) - min = mul, divide = 13; - mul = (node->Vertices[2].Point.z - z1) * (node->Vertices[0].Point.z - z1); // CA na północy - if (mul < min) - divide = 14; - // tworzymy jeden dodatkowy trójkąt, dzieląc jeden bok na przecięciu siatki kilometrowej - TGroundNode *ntri; // wskaźnik na nowy trójkąt - ntri = new TGroundNode(); // a ten jest nowy - ntri->iType = GL_TRIANGLES; // kopiowanie parametrów, przydałby się konstruktor kopiujący - ntri->Init(3); - ntri->TextureID = node->TextureID; - ntri->iFlags = node->iFlags; - for (int j = 0; j < 4; ++j) - { - ntri->Ambient[j] = node->Ambient[j]; - ntri->Diffuse[j] = node->Diffuse[j]; - ntri->Specular[j] = node->Specular[j]; - } - ntri->asName = node->asName; - ntri->fSquareRadius = node->fSquareRadius; - ntri->fSquareMinRadius = node->fSquareMinRadius; - ntri->bVisible = node->bVisible; // a są jakieś niewidoczne? - ntri->nNext = nRootOfType[GL_TRIANGLES]; - nRootOfType[GL_TRIANGLES] = ntri; // dopisanie z przodu do listy - iNumNodes++; - switch (divide & 3) - { // podzielenie jednego z boków, powstaje wierzchołek D - case 0: // podział AB (0-1) -> ADC i DBC - ntri->Vertices[2] = node->Vertices[2]; // wierzchołek C jest wspólny - ntri->Vertices[1] = node->Vertices[1]; // wierzchołek B przechodzi do nowego - // node->Vertices[1].HalfSet(node->Vertices[0],node->Vertices[1]); //na razie D tak - if (divide & 4) - node->Vertices[1].SetByZ(node->Vertices[0], node->Vertices[1], (divide & 8) ? z1 : z0); - else - node->Vertices[1].SetByX(node->Vertices[0], node->Vertices[1], (divide & 8) ? x1 : x0); - ntri->Vertices[0] = node->Vertices[1]; // wierzchołek D jest wspólny - break; - case 1: // podział BC (1-2) -> ABD i ADC - ntri->Vertices[0] = node->Vertices[0]; // wierzchołek A jest wspólny - ntri->Vertices[2] = node->Vertices[2]; // wierzchołek C przechodzi do nowego - // node->Vertices[2].HalfSet(node->Vertices[1],node->Vertices[2]); //na razie D tak - if (divide & 4) - node->Vertices[2].SetByZ(node->Vertices[1], node->Vertices[2], (divide & 8) ? z1 : z0); - else - node->Vertices[2].SetByX(node->Vertices[1], node->Vertices[2], (divide & 8) ? x1 : x0); - ntri->Vertices[1] = node->Vertices[2]; // wierzchołek D jest wspólny - break; - case 2: // podział CA (2-0) -> ABD i DBC - ntri->Vertices[1] = node->Vertices[1]; // wierzchołek B jest wspólny - ntri->Vertices[2] = node->Vertices[2]; // wierzchołek C przechodzi do nowego - // node->Vertices[2].HalfSet(node->Vertices[2],node->Vertices[0]); //na razie D tak - if (divide & 4) - node->Vertices[2].SetByZ(node->Vertices[2], node->Vertices[0], (divide & 8) ? z1 : z0); - else - node->Vertices[2].SetByX(node->Vertices[2], node->Vertices[0], (divide & 8) ? x1 : x0); - ntri->Vertices[0] = node->Vertices[2]; // wierzchołek D jest wspólny - break; - } - // przeliczenie środków ciężkości obu - node->pCenter = - (node->Vertices[0].Point + node->Vertices[1].Point + node->Vertices[2].Point) / 3.0; - ntri->pCenter = - (ntri->Vertices[0].Point + ntri->Vertices[1].Point + ntri->Vertices[2].Point) / 3.0; - RaTriangleDivider(node); // rekurencja, bo nawet na TD raz nie wystarczy - RaTriangleDivider(ntri); -}; - -TGroundNode * TGround::AddGroundNode(cParser *parser) -{ // wczytanie wpisu typu "node" - // parser->LoadTraction=Global::bLoadTraction; //Ra: tu nie potrzeba powtarzać - string str, str1, str2, str3, str4, Skin, DriverType, asNodeName; - int nv, ti, i, n; - double tf, r, rmin, tf1, tf2, tf3, tf4, l, dist, mgn; - int int1, int2; - bool bError = false, curve; - vector3 pt, front, up, left, pos, tv; - matrix4x4 mat2, mat1, mat; - GLuint TexID; - TGroundNode *tmp1; - TTrack *Track; - TTextSound *tmpsound; - std::string token; - parser->getTokens(2); - *parser >> r >> rmin; - parser->getTokens(); - *parser >> token; - asNodeName = token; - parser->getTokens(); - *parser >> token; - str = token; - //str = AnsiString(token.c_str()); - TGroundNode *tmp, *tmp2; - tmp = new TGroundNode(); - tmp->asName = (asNodeName == "none" ? string("") : asNodeName); - if (r >= 0) - tmp->fSquareRadius = r * r; - tmp->fSquareMinRadius = rmin * rmin; - if (str == "triangles") - tmp->iType = GL_TRIANGLES; - else if (str == "triangle_strip") - tmp->iType = GL_TRIANGLE_STRIP; - else if (str == "triangle_fan") - tmp->iType = GL_TRIANGLE_FAN; - else if (str == "lines") - tmp->iType = GL_LINES; - else if (str == "line_strip") - tmp->iType = GL_LINE_STRIP; - else if (str == "line_loop") - tmp->iType = GL_LINE_LOOP; - else if (str == "model") - tmp->iType = TP_MODEL; - // else if (str=="terrain") tmp->iType=TP_TERRAIN; //tymczasowo do odwołania - else if (str == "dynamic") - tmp->iType = TP_DYNAMIC; - else if (str == "sound") - tmp->iType = TP_SOUND; - else if (str == "track") - tmp->iType = TP_TRACK; - else if (str == "memcell") - tmp->iType = TP_MEMCELL; - else if (str == "eventlauncher") - tmp->iType = TP_EVLAUNCH; - else if (str == "traction") - tmp->iType = TP_TRACTION; - else if (str == "tractionpowersource") - tmp->iType = TP_TRACTIONPOWERSOURCE; - // else if (str=="isolated") tmp->iType=TP_ISOLATED; - else - bError = true; - // WriteLog("-> node "+str+" "+tmp->asName); - if (bError) - { - Error("Scene parse error near " + str); - for (int i = 0; i < 60; ++i) - { // Ra: skopiowanie dalszej części do logu - taka prowizorka, lepsza niż nic - parser->getTokens(); // pobranie linijki tekstu nie działa - *parser >> token; - WriteLog(token); - } - // if (tmp==RootNode) RootNode=NULL; - delete tmp; - return NULL; - } - switch (tmp->iType) - { - case TP_TRACTION: - tmp->hvTraction = new TTraction(); - parser->getTokens(); - *parser >> token; - tmp->hvTraction->asPowerSupplyName = token; // nazwa zasilacza - parser->getTokens(3); - *parser >> tmp->hvTraction->NominalVoltage >> tmp->hvTraction->MaxCurrent >> - tmp->hvTraction->fResistivity; - if (tmp->hvTraction->fResistivity == 0.01) // tyle jest w sceneriach [om/km] - tmp->hvTraction->fResistivity = 0.075; // taka sensowniejsza wartość za - // http://www.ikolej.pl/fileadmin/user_upload/Seminaria_IK/13_05_07_Prezentacja_Kruczek.pdf - tmp->hvTraction->fResistivity *= 0.001; // teraz [om/m] - parser->getTokens(); - *parser >> token; - // Ra 2014-02: a tutaj damy symbol sieci i jej budowę, np.: - // SKB70-C, CuCd70-2C, KB95-2C, C95-C, C95-2C, YC95-2C, YpC95-2C, YC120-2C - // YpC120-2C, YzC120-2C, YwsC120-2C, YC150-C150, YC150-2C150, C150-C150 - // C120-2C, 2C120-2C, 2C120-2C-1, 2C120-2C-2, 2C120-2C-3, 2C120-2C-4 - if (token.compare("none") == 0) - tmp->hvTraction->Material = 0; - else if (token.compare("al") == 0) - tmp->hvTraction->Material = 2; // 1=aluminiowa, rysuje się na czarno - else - tmp->hvTraction->Material = 1; // 1=miedziana, rysuje się na zielono albo czerwono - parser->getTokens(); - *parser >> tmp->hvTraction->WireThickness; - parser->getTokens(); - *parser >> tmp->hvTraction->DamageFlag; - parser->getTokens(3); - *parser >> tmp->hvTraction->pPoint1.x >> tmp->hvTraction->pPoint1.y >> - tmp->hvTraction->pPoint1.z; - tmp->hvTraction->pPoint1 += pOrigin; - parser->getTokens(3); - *parser >> tmp->hvTraction->pPoint2.x >> tmp->hvTraction->pPoint2.y >> - tmp->hvTraction->pPoint2.z; - tmp->hvTraction->pPoint2 += pOrigin; - parser->getTokens(3); - *parser >> tmp->hvTraction->pPoint3.x >> tmp->hvTraction->pPoint3.y >> - tmp->hvTraction->pPoint3.z; - tmp->hvTraction->pPoint3 += pOrigin; - parser->getTokens(3); - *parser >> tmp->hvTraction->pPoint4.x >> tmp->hvTraction->pPoint4.y >> - tmp->hvTraction->pPoint4.z; - tmp->hvTraction->pPoint4 += pOrigin; - parser->getTokens(); - *parser >> tf1; - tmp->hvTraction->fHeightDifference = - (tmp->hvTraction->pPoint3.y - tmp->hvTraction->pPoint1.y + tmp->hvTraction->pPoint4.y - - tmp->hvTraction->pPoint2.y) * - 0.5f - - tf1; - parser->getTokens(); - *parser >> tf1; - if (tf1 > 0) - tmp->hvTraction->iNumSections = - (tmp->hvTraction->pPoint1 - tmp->hvTraction->pPoint2).Length() / tf1; - else - tmp->hvTraction->iNumSections = 0; - parser->getTokens(); - *parser >> tmp->hvTraction->Wires; - parser->getTokens(); - *parser >> tmp->hvTraction->WireOffset; - parser->getTokens(); - *parser >> token; - tmp->bVisible = (token.compare("vis") == 0); - parser->getTokens(); - *parser >> token; - if (token.compare("parallel") == 0) - { // jawne wskazanie innego przęsła, na które może przestawić się pantograf - parser->getTokens(); - *parser >> token; // wypadało by to zapamiętać... - tmp->hvTraction->asParallel = token; - parser->getTokens(); - *parser >> token; // a tu już powinien być koniec - } - if (token.compare("endtraction") != 0) - Error("ENDTRACTION delimiter missing! " + str2 + " found instead."); - tmp->hvTraction->Init(); // przeliczenie parametrów - // if (Global::bLoadTraction) - // tmp->hvTraction->Optimize(); //generowanie DL dla wszystkiego przy wczytywaniu? - tmp->pCenter = (tmp->hvTraction->pPoint2 + tmp->hvTraction->pPoint1) * 0.5f; - // if (!Global::bLoadTraction) SafeDelete(tmp); //Ra: tak być nie może, bo NULL to błąd - break; - case TP_TRACTIONPOWERSOURCE: - parser->getTokens(3); - *parser >> tmp->pCenter.x >> tmp->pCenter.y >> tmp->pCenter.z; - tmp->pCenter += pOrigin; - tmp->psTractionPowerSource = new TTractionPowerSource(tmp); - tmp->psTractionPowerSource->Load(parser); - break; - case TP_MEMCELL: - parser->getTokens(3); - *parser >> tmp->pCenter.x >> tmp->pCenter.y >> tmp->pCenter.z; - tmp->pCenter.RotateY(aRotate.y / 180.0 * M_PI); // Ra 2014-11: uwzględnienie rotacji - tmp->pCenter += pOrigin; - tmp->MemCell = new TMemCell(&tmp->pCenter); - tmp->MemCell->Load(parser); - if (!tmp->asName.empty()) // jest pusta gdy "none" - { // dodanie do wyszukiwarki -#ifdef EU07_USE_OLD_TNAMES_CLASS - if (sTracks->Update(TP_MEMCELL, tmp->asName.c_str(), - tmp)) // najpierw sprawdzić, czy już jest - { // przy zdublowaniu wskaźnik zostanie podmieniony w drzewku na późniejszy (zgodność - // wsteczna) - ErrorLog("Duplicated memcell: " + tmp->asName); // to zgłaszać duplikat - } - else - sTracks->Add(TP_MEMCELL, tmp->asName.c_str(), tmp); // nazwa jest unikalna -#else - if( false == m_trackmap.Add( TP_MEMCELL, tmp->asName, tmp ) ) { - // przy zdublowaniu wskaźnik zostanie podmieniony w drzewku na późniejszy (zgodność wsteczna) - ErrorLog( "Duplicated memcell: " + tmp->asName ); // to zgłaszać duplikat - } -#endif - } - break; - case TP_EVLAUNCH: - parser->getTokens(3); - *parser >> tmp->pCenter.x >> tmp->pCenter.y >> tmp->pCenter.z; - tmp->pCenter.RotateY(aRotate.y / 180.0 * M_PI); // Ra 2014-11: uwzględnienie rotacji - tmp->pCenter += pOrigin; - tmp->EvLaunch = new TEventLauncher(); - tmp->EvLaunch->Load(parser); - break; - case TP_TRACK: - tmp->pTrack = new TTrack(tmp); - if (Global::iWriteLogEnabled & 4) - if (!tmp->asName.empty()) - WriteLog(tmp->asName); - tmp->pTrack->Load(parser, pOrigin, - tmp->asName); // w nazwie może być nazwa odcinka izolowanego - if (!tmp->asName.empty()) // jest pusta gdy "none" - { // dodanie do wyszukiwarki -#ifdef EU07_USE_OLD_TNAMES_CLASS - if (sTracks->Update(TP_TRACK, tmp->asName.c_str(), - tmp)) // najpierw sprawdzić, czy już jest - { // przy zdublowaniu wskaźnik zostanie podmieniony w drzewku na późniejszy (zgodność - // wsteczna) - if (tmp->pTrack->iCategoryFlag & 1) // jeśli jest zdublowany tor kolejowy - ErrorLog("Duplicated track: " + tmp->asName); // to zgłaszać duplikat - } - else - sTracks->Add(TP_TRACK, tmp->asName.c_str(), tmp); // nazwa jest unikalna -#else - if( false == m_trackmap.Add( TP_TRACK, tmp->asName, tmp ) ) { - // przy zdublowaniu wskaźnik zostanie podmieniony w drzewku na późniejszy (zgodność wsteczna) - ErrorLog( "Duplicated track: " + tmp->asName ); // to zgłaszać duplikat - } -#endif - } - tmp->pCenter = (tmp->pTrack->CurrentSegment()->FastGetPoint_0() + - tmp->pTrack->CurrentSegment()->FastGetPoint(0.5) + - tmp->pTrack->CurrentSegment()->FastGetPoint_1()) / - 3.0; - break; - case TP_SOUND: - parser->getTokens(3); - *parser >> tmp->pCenter.x >> tmp->pCenter.y >> tmp->pCenter.z; - tmp->pCenter.RotateY(aRotate.y / 180.0 * M_PI); // Ra 2014-11: uwzględnienie rotacji - tmp->pCenter += pOrigin; - parser->getTokens(); - *parser >> token; - str = token; - //str = AnsiString(token.c_str()); - tmp->tsStaticSound = new TTextSound(str, sqrt(tmp->fSquareRadius), tmp->pCenter.x, tmp->pCenter.y, tmp->pCenter.z, false, rmin); - if (rmin < 0.0) - rmin = - 0.0; // przywrócenie poprawnej wartości, jeśli służyła do wyłączenia efektu Dopplera - - // tmp->pDirectSoundBuffer=TSoundsManager::GetFromName(str.c_str()); - // tmp->iState=(Parser->GetNextSymbol().LowerCase()=="loop"?DSBPLAY_LOOPING:0); - parser->getTokens(); - *parser >> token; - break; - case TP_DYNAMIC: - tmp->DynamicObject = new TDynamicObject(); - // tmp->DynamicObject->Load(Parser); - parser->getTokens(); - *parser >> token; - str1 = token; // katalog - // McZapkie: doszedl parametr ze zmienialna skora - parser->getTokens(); - *parser >> token; - Skin = token; // tekstura wymienna - parser->getTokens(); - *parser >> token; - str3 = token; // McZapkie-131102: model w MMD - if (bTrainSet) - { // jeśli pojazd jest umieszczony w składzie - str = asTrainSetTrack; - parser->getTokens(); - *parser >> tf1; // Ra: -1 oznacza odwrotne wstawienie, normalnie w składzie 0 - parser->getTokens(); - *parser >> token; - DriverType = token; // McZapkie:010303 - w przyszlosci rozne - // konfiguracje mechanik/pomocnik itp - tf3 = fTrainSetVel; // prędkość - parser->getTokens(); - *parser >> token; - str4 = token; - int2 = str4.find("."); // yB: wykorzystuje tutaj zmienna, ktora potem bedzie ladunkiem - if (int2 != string::npos) // yB: jesli znalazl kropke, to ja przetwarza jako parametry - { - int dlugosc = str4.length(); - int1 = atoi(str4.substr(0, int2).c_str()); // niech sprzegiem bedzie do kropki cos - str4 = str4.substr(int2 + 1, dlugosc - int2); - } - else - { - int1 = atoi(str4.c_str()); - str4 = ""; - } - int2 = 0; // zeruje po wykorzystaniu - // *parser >> int1; //yB: nastawy i takie tam TUTAJ!!!!! - if (int1 < 0) - int1 = (-int1) | - ctrain_depot; // sprzęg zablokowany (pojazdy nierozłączalne przy manewrach) - if (tf1 != -1.0) - if (fabs(tf1) > 0.5) // maksymalna odległość między sprzęgami - do przemyślenia - int1 = 0; // likwidacja sprzęgu, jeśli odległość zbyt duża - to powinno być - // uwzględniane w fizyce sprzęgów... - TempConnectionType[iTrainSetWehicleNumber] = int1; // wartość dodatnia - } - else - { // pojazd wstawiony luzem - fTrainSetDist = 0; // zerowanie dodatkowego przesunięcia - asTrainName = ""; // puste oznacza jazdę pojedynczego bez rozkładu, "none" jest dla - // składu (trainset) - parser->getTokens(); - *parser >> token; - str = token; // track - parser->getTokens(); - *parser >> tf1; // Ra: -1 oznacza odwrotne wstawienie - parser->getTokens(); - *parser >> token; - DriverType = token; // McZapkie:010303: obsada - parser->getTokens(); - *parser >> - tf3; // prędkość, niektórzy wpisują tu "3" jako sprzęg, żeby nie było tabliczki - iTrainSetWehicleNumber = 0; - TempConnectionType[iTrainSetWehicleNumber] = 3; // likwidacja tabliczki na końcu? - } - parser->getTokens(); - *parser >> int2; // ilość ładunku - if (int2 > 0) - { // jeżeli ładunku jest więcej niż 0, to rozpoznajemy jego typ - parser->getTokens(); - *parser >> token; - str2 = token; // LoadType - if (str2 == "enddynamic") // idiotoodporność: ładunek bez podanego typu - { - str2 = ""; - int2 = 0; // ilość bez typu się nie liczy jako ładunek - } - } - else - str2 = ""; // brak ladunku - - tmp1 = FindGroundNode(str, TP_TRACK); // poszukiwanie toru - if (tmp1 ? tmp1->pTrack != NULL : false) - { // jeśli tor znaleziony - Track = tmp1->pTrack; - if (!iTrainSetWehicleNumber) // jeśli pierwszy pojazd - if (Track->evEvent0) // jeśli tor ma Event0 - if (fabs(fTrainSetVel) <= 1.0) // a skład stoi - if (fTrainSetDist >= 0.0) // ale może nie sięgać na owy tor - if (fTrainSetDist < 8.0) // i raczej nie sięga - fTrainSetDist = - 8.0; // przesuwamy około pół EU07 dla wstecznej zgodności - // WriteLog("Dynamic shift: "+AnsiString(fTrainSetDist)); - /* //Ra: to jednak robi duże problemy - przesunięcie w dynamic jest przesunięciem do - tyłu, odwrotnie niż w trainset - if (!iTrainSetWehicleNumber) //dla pierwszego jest to przesunięcie (ujemne = do - tyłu) - if (tf1!=-1.0) //-1 wyjątkowo oznacza odwrócenie - tf1=-tf1; //a dla kolejnych odległość między sprzęgami (ujemne = wbite) - */ - tf3 = tmp->DynamicObject->Init(asNodeName, str1, Skin, str3, Track, - (tf1 == -1.0 ? fTrainSetDist : fTrainSetDist - tf1), - DriverType, tf3, asTrainName, int2, str2, (tf1 == -1.0), - str4); - if (tf3 != 0.0) // zero oznacza błąd - { - fTrainSetDist -= - tf3; // przesunięcie dla kolejnego, minus bo idziemy w stronę punktu 1 - tmp->pCenter = tmp->DynamicObject->GetPosition(); -/* // NOTE: the ctrain_depot flag is used to mark merged together parts of modular trains - // clearing it here breaks this connection, so i'm disabling this piece of code. - // if it has some actual purpose and disabling it breaks that, a different solution has to be found - // either for modular trains, or whatever it is this code does. - if (TempConnectionType[iTrainSetWehicleNumber]) // jeśli jest sprzęg - if (tmp->DynamicObject->MoverParameters->Couplers[tf1 == -1.0 ? 0 : 1] - .AllowedFlag & - ctrain_depot) // jesli zablokowany - TempConnectionType[iTrainSetWehicleNumber] |= ctrain_depot; // będzie blokada -*/ - iTrainSetWehicleNumber++; - } - else - { // LastNode=NULL; - delete tmp; - tmp = NULL; // nie może być tu return, bo trzeba pominąć jeszcze enddynamic - } - } - else - { // gdy tor nie znaleziony - ErrorLog("Missed track: dynamic placed on \"" + tmp->DynamicObject->asTrack + "\""); - delete tmp; - tmp = NULL; // nie może być tu return, bo trzeba pominąć jeszcze enddynamic - } - parser->getTokens(); - *parser >> token; - if (token.compare("destination") == 0) - { // dokąd wagon ma jechać, uwzględniane przy manewrach - parser->getTokens(); - *parser >> token; - if (tmp) - tmp->DynamicObject->asDestination = token; - *parser >> token; - } - if (token.compare("enddynamic") != 0) - Error("enddynamic statement missing"); - break; - case TP_MODEL: - if (rmin < 0) - { - tmp->iType = TP_TERRAIN; - tmp->fSquareMinRadius = 0; // to w ogóle potrzebne? - } - parser->getTokens(3); - *parser >> tmp->pCenter.x >> tmp->pCenter.y >> tmp->pCenter.z; - parser->getTokens(); - *parser >> tf1; - // OlO_EU&KAKISH-030103: obracanie punktow zaczepien w modelu - tmp->pCenter.RotateY(aRotate.y / 180.0 * M_PI); - // McZapkie-260402: model tez ma wspolrzedne wzgledne - tmp->pCenter += pOrigin; - // tmp->fAngle+=aRotate.y; // /180*M_PI - /* - if (tmp->iType==TP_MODEL) - {//jeśli standardowy model - */ - tmp->Model = new TAnimModel(); - tmp->Model->RaAnglesSet(aRotate.x, tf1 + aRotate.y, - aRotate.z); // dostosowanie do pochylania linii - if (tmp->Model->Load( - parser, tmp->iType == TP_TERRAIN)) // wczytanie modelu, tekstury i stanu świateł... - tmp->iFlags = - tmp->Model->Flags() | 0x200; // ustalenie, czy przezroczysty; flaga usuwania - else if (tmp->iType != TP_TERRAIN) - { // model nie wczytał się - ignorowanie node - delete tmp; - tmp = NULL; // nie może być tu return - break; // nie może być tu return? - } - /* - } - else if (tmp->iType==TP_TERRAIN) - {//nie potrzeba nakładki animującej submodele - *parser >> token; - tmp->pModel3D=TModelsManager::GetModel(token.c_str(),false); - do //Ra: z tym to trochę bez sensu jest - {parser->getTokens(); - *parser >> token; - str=AnsiString(token.c_str()); - } while (str!="endterrains"); - } - */ - if (tmp->iType == TP_TERRAIN) - { // jeśli model jest terenem, trzeba utworzyć dodatkowe obiekty - // po wczytaniu model ma już utworzone DL albo VBO - Global::pTerrainCompact = tmp->Model; // istnieje co najmniej jeden obiekt terenu - tmp->iCount = Global::pTerrainCompact->TerrainCount() + 1; // zliczenie submodeli - tmp->nNode = new TGroundNode[tmp->iCount]; // sztuczne node dla kwadratów - tmp->nNode[0].iType = TP_MODEL; // pierwszy zawiera model (dla delete) - tmp->nNode[0].Model = Global::pTerrainCompact; - tmp->nNode[0].iFlags = 0x200; // nie wyświetlany, ale usuwany - for (i = 1; i < tmp->iCount; ++i) - { // a reszta to submodele - tmp->nNode[i].iType = TP_SUBMODEL; // - tmp->nNode[i].smTerrain = Global::pTerrainCompact->TerrainSquare(i - 1); - tmp->nNode[i].iFlags = 0x10; // nieprzezroczyste; nie usuwany - tmp->nNode[i].bVisible = true; - tmp->nNode[i].pCenter = tmp->pCenter; // nie przesuwamy w inne miejsce - // tmp->nNode[i].asName= - } - } - else if (!tmp->asName.empty()) // jest pusta gdy "none" - { // dodanie do wyszukiwarki -#ifdef EU07_USE_OLD_TNAMES_CLASS - if (sTracks->Update(TP_MODEL, tmp->asName.c_str(), - tmp)) // najpierw sprawdzić, czy już jest - { // przy zdublowaniu wskaźnik zostanie podmieniony w drzewku na późniejszy (zgodność - // wsteczna) - ErrorLog("Duplicated model: " + tmp->asName); // to zgłaszać duplikat - } - else - sTracks->Add(TP_MODEL, tmp->asName.c_str(), tmp); // nazwa jest unikalna -#else - if( false == m_trackmap.Add( TP_MODEL, tmp->asName, tmp ) ) { - // przy zdublowaniu wskaźnik zostanie podmieniony w drzewku na późniejszy (zgodność wsteczna) - ErrorLog( "Duplicated model: " + tmp->asName ); // to zgłaszać duplikat - } -#endif - } - // str=Parser->GetNextSymbol().LowerCase(); - break; - // case TP_GEOMETRY : - case GL_TRIANGLES: - case GL_TRIANGLE_STRIP: - case GL_TRIANGLE_FAN: - parser->getTokens(); - *parser >> token; - // McZapkie-050702: opcjonalne wczytywanie parametrow materialu (ambient,diffuse,specular) - if (token.compare("material") == 0) - { - parser->getTokens(); - *parser >> token; - while (token.compare("endmaterial") != 0) - { - if (token.compare("ambient:") == 0) - { - parser->getTokens(); - *parser >> tmp->Ambient[0]; - parser->getTokens(); - *parser >> tmp->Ambient[1]; - parser->getTokens(); - *parser >> tmp->Ambient[2]; - } - else if (token.compare("diffuse:") == 0) - { // Ra: coś jest nie tak, bo w jednej linijce nie działa - parser->getTokens(); - *parser >> tmp->Diffuse[0]; - parser->getTokens(); - *parser >> tmp->Diffuse[1]; - parser->getTokens(); - *parser >> tmp->Diffuse[2]; - } - else if (token.compare("specular:") == 0) - { - parser->getTokens(); - *parser >> tmp->Specular[0]; - parser->getTokens(); - *parser >> tmp->Specular[1]; - parser->getTokens(); - *parser >> tmp->Specular[2]; - } - else - Error("Scene material failure!"); - parser->getTokens(); - *parser >> token; - } - } - if (token.compare("endmaterial") == 0) - { - parser->getTokens(); - *parser >> token; - } - str = token; -#ifdef _PROBLEND - // PROBLEND Q: 13122011 - Szociu: 27012012 - PROBLEND = true; // domyslnie uruchomione nowe wyświetlanie - tmp->PROBLEND = true; // odwolanie do tgroundnode, bo rendering jest w tej klasie - if (str.find('@') != string::npos) // sprawdza, czy w nazwie tekstury jest znak "@" - { - PROBLEND = false; // jeśli jest, wyswietla po staremu - tmp->PROBLEND = false; - } -#endif - tmp->TextureID = TextureManager.GetTextureId( str, szTexturePath ); - tmp->iFlags = TextureManager.Texture(tmp->TextureID).has_alpha ? 0x220 : 0x210; // z usuwaniem - if (((tmp->iType == GL_TRIANGLES) && (tmp->iFlags & 0x10)) ? - Global::pTerrainCompact->TerrainLoaded() : - false) - { // jeśli jest tekstura nieprzezroczysta, a teren załadowany, to pomijamy trójkąty - do - { // pomijanie trójkątów - parser->getTokens(); - *parser >> token; - } while (token.compare("endtri") != 0); - // delete tmp; //nie ma co tego trzymać - // tmp=NULL; //to jest błąd - } - else - { -/* - i = 0; -*/ - TempVerts.clear(); - TGroundVertex vertex; - do - { -/* - if (i < 9999) // 3333 trójkąty - { // liczba wierzchołków nie jest nieograniczona -*/ -/* - parser->getTokens(3); - *parser >> TempVerts[i].Point.x >> TempVerts[i].Point.y >> TempVerts[i].Point.z; - parser->getTokens(3); - *parser >> TempVerts[i].Normal.x >> TempVerts[i].Normal.y >> - TempVerts[i].Normal.z; -*/ - parser->getTokens( 8, false ); - *parser - >> vertex.Point.x - >> vertex.Point.y - >> vertex.Point.z - >> vertex.Normal.x - >> vertex.Normal.y - >> vertex.Normal.z - >> vertex.tu - >> vertex.tv; - /* - str=Parser->GetNextSymbol().LowerCase(); - if (str==AnsiString("x")) - TempVerts[i].tu=(TempVerts[i].Point.x+Parser->GetNextSymbol().ToDouble())/Parser->GetNextSymbol().ToDouble(); - else - if (str==AnsiString("y")) - TempVerts[i].tu=(TempVerts[i].Point.y+Parser->GetNextSymbol().ToDouble())/Parser->GetNextSymbol().ToDouble(); - else - if (str==AnsiString("z")) - TempVerts[i].tu=(TempVerts[i].Point.z+Parser->GetNextSymbol().ToDouble())/Parser->GetNextSymbol().ToDouble(); - else - TempVerts[i].tu=str.ToDouble();; - - str=Parser->GetNextSymbol().LowerCase(); - if (str==AnsiString("x")) - TempVerts[i].tv=(TempVerts[i].Point.x+Parser->GetNextSymbol().ToDouble())/Parser->GetNextSymbol().ToDouble(); - else - if (str==AnsiString("y")) - TempVerts[i].tv=(TempVerts[i].Point.y+Parser->GetNextSymbol().ToDouble())/Parser->GetNextSymbol().ToDouble(); - else - if (str==AnsiString("z")) - TempVerts[i].tv=(TempVerts[i].Point.z+Parser->GetNextSymbol().ToDouble())/Parser->GetNextSymbol().ToDouble(); - else - TempVerts[i].tv=str.ToDouble();; - */ -/* - parser->getTokens(2); - *parser >> TempVerts[i].tu >> TempVerts[i].tv; -*/ - // tf=Parser->GetNextSymbol().ToDouble(); - // TempVerts[i].tu=tf; - // tf=Parser->GetNextSymbol().ToDouble(); - // TempVerts[i].tv=tf; -/* - TempVerts[i].Point.RotateZ(aRotate.z / 180 * M_PI); - TempVerts[i].Point.RotateX(aRotate.x / 180 * M_PI); - TempVerts[i].Point.RotateY(aRotate.y / 180 * M_PI); - TempVerts[i].Normal.RotateZ(aRotate.z / 180 * M_PI); - TempVerts[i].Normal.RotateX(aRotate.x / 180 * M_PI); - TempVerts[i].Normal.RotateY(aRotate.y / 180 * M_PI); - TempVerts[i].Point += pOrigin; - tmp->pCenter += TempVerts[i].Point; -*/ - vertex.Point.RotateZ( aRotate.z / 180 * M_PI ); - vertex.Point.RotateX( aRotate.x / 180 * M_PI ); - vertex.Point.RotateY( aRotate.y / 180 * M_PI ); - vertex.Normal.RotateZ( aRotate.z / 180 * M_PI ); - vertex.Normal.RotateX( aRotate.x / 180 * M_PI ); - vertex.Normal.RotateY( aRotate.y / 180 * M_PI ); - vertex.Point += pOrigin; - tmp->pCenter += vertex.Point; - - TempVerts.emplace_back( vertex ); -/* - } - else if (i == 9999) - ErrorLog("Bad triangles: too many verices"); - i++; -*/ - parser->getTokens(); - *parser >> token; - - // } - - } while (token.compare("endtri") != 0); -/* - nv = i; -*/ - nv = TempVerts.size(); - tmp->Init(nv); // utworzenie tablicy wierzchołków - tmp->pCenter /= (nv > 0 ? nv : 1); - - // memcpy(tmp->Vertices,TempVerts,nv*sizeof(TGroundVertex)); - - r = 0; - for (int i = 0; i < nv; i++) - { - tmp->Vertices[i] = TempVerts[i]; - tf = SquareMagnitude(tmp->Vertices[i].Point - tmp->pCenter); - if (tf > r) - r = tf; - } - - // tmp->fSquareRadius=2000*2000+r; - tmp->fSquareRadius += r; - RaTriangleDivider(tmp); // Ra: dzielenie trójkątów jest teraz całkiem wydajne - } // koniec wczytywania trójkątów - break; - case GL_LINES: - case GL_LINE_STRIP: - case GL_LINE_LOOP: { - parser->getTokens( 3 ); - *parser >> tmp->Diffuse[ 0 ] >> tmp->Diffuse[ 1 ] >> tmp->Diffuse[ 2 ]; - // tmp->Diffuse[0]=Parser->GetNextSymbol().ToDouble()/255; - // tmp->Diffuse[1]=Parser->GetNextSymbol().ToDouble()/255; - // tmp->Diffuse[2]=Parser->GetNextSymbol().ToDouble()/255; - parser->getTokens(); - *parser >> tmp->fLineThickness; - TempVerts.clear(); - TGroundVertex vertex; - i = 0; - parser->getTokens(); - *parser >> token; - do { - str = token; -/* - TempVerts[ i ].Point.x = atof( str.c_str() ); - parser->getTokens( 2 ); - *parser >> TempVerts[ i ].Point.y >> TempVerts[ i ].Point.z; - TempVerts[ i ].Point.RotateZ( aRotate.z / 180 * M_PI ); - TempVerts[ i ].Point.RotateX( aRotate.x / 180 * M_PI ); - TempVerts[ i ].Point.RotateY( aRotate.y / 180 * M_PI ); - TempVerts[ i ].Point += pOrigin; - tmp->pCenter += TempVerts[ i ].Point; -*/ - vertex.Point.x = std::atof( str.c_str() ); - parser->getTokens( 2 ); - *parser - >> vertex.Point.y - >> vertex.Point.z; - vertex.Point.RotateZ( aRotate.z / 180 * M_PI ); - vertex.Point.RotateX( aRotate.x / 180 * M_PI ); - vertex.Point.RotateY( aRotate.y / 180 * M_PI ); - vertex.Point += pOrigin; - tmp->pCenter += vertex.Point; - TempVerts.emplace_back( vertex ); - - ++i; - parser->getTokens(); - *parser >> token; - } while( token.compare( "endline" ) != 0 ); - nv = i; - // tmp->Init(nv); - tmp->Points = new vector3[ nv ]; - tmp->iNumPts = nv; - tmp->pCenter /= ( nv > 0 ? nv : 1 ); - for( int i = 0; i < nv; i++ ) - tmp->Points[ i ] = TempVerts[ i ].Point; - break; - } - } - return tmp; -} - -TSubRect * TGround::FastGetSubRect(int iCol, int iRow) -{ - int br, bc, sr, sc; - br = iRow / iNumSubRects; - bc = iCol / iNumSubRects; - sr = iRow - br * iNumSubRects; - sc = iCol - bc * iNumSubRects; - if ((br < 0) || (bc < 0) || (br >= iNumRects) || (bc >= iNumRects)) - return NULL; - return (Rects[br][bc].FastGetRect(sc, sr)); -} - -TSubRect * TGround::GetSubRect(int iCol, int iRow) -{ // znalezienie małego kwadratu mapy - int br, bc, sr, sc; - br = iRow / iNumSubRects; // współrzędne kwadratu kilometrowego - bc = iCol / iNumSubRects; - sr = iRow - br * iNumSubRects; // współrzędne wzglęne małego kwadratu - sc = iCol - bc * iNumSubRects; - if ((br < 0) || (bc < 0) || (br >= iNumRects) || (bc >= iNumRects)) - return NULL; // jeśli poza mapą - return (Rects[br][bc].SafeGetRect(sc, sr)); // pobranie małego kwadratu -} - -TEvent * TGround::FindEvent(const string &asEventName) -{ -#ifdef EU07_USE_OLD_TNAMES_CLASS - return (TEvent *)sTracks->Find(0, asEventName.c_str()); // wyszukiwanie w drzewie -#else - auto const lookup = m_eventmap.find( asEventName ); - return - lookup != m_eventmap.end() ? - lookup->second : - nullptr; -#endif - /* //powolna wyszukiwarka - for (TEvent *Current=RootEvent;Current;Current=Current->Next2) - { - if (Current->asName==asEventName) - return Current; - } - return NULL; - */ -} - -TEvent * TGround::FindEventScan(const string &asEventName) -{ // wyszukanie eventu z opcją utworzenia niejawnego dla komórek skanowanych -#ifdef EU07_USE_OLD_TNAMES_CLASS - TEvent *e = (TEvent *)sTracks->Find( 0, asEventName.c_str() ); // wyszukiwanie w drzewie eventów -#else - auto const lookup = m_eventmap.find( asEventName ); - auto e = - lookup != m_eventmap.end() ? - lookup->second : - nullptr; -#endif - if (e) - return e; // jak istnieje, to w porządku - if (asEventName.rfind(":scan") != std::string::npos) // jeszcze może być event niejawny - { // no to szukamy komórki pamięci o nazwie zawartej w evencie - string n = asEventName.substr(0, asEventName.length() - 5); // do dwukropka -#ifdef EU07_USE_OLD_TNAMES_CLASS - if( sTracks->Find( TP_MEMCELL, n.c_str() ) ) // jeśli jest takowa komórka pamięci -#else - if( m_trackmap.Find( TP_MEMCELL, n ) != nullptr ) // jeśli jest takowa komórka pamięci -#endif - e = new TEvent(n); // utworzenie niejawnego eventu jej odczytu - } - return e; // utworzony albo się nie udało -} - -void TGround::FirstInit() -{ // ustalanie zależności na scenerii przed wczytaniem pojazdów - if (bInitDone) - return; // Ra: żeby nie robiło się dwa razy - bInitDone = true; - WriteLog("InitNormals"); - int i, j; - for (i = 0; i < TP_LAST; ++i) - { - for (TGroundNode *Current = nRootOfType[i]; Current; Current = Current->nNext) - { - Current->InitNormals(); - if (Current->iType != TP_DYNAMIC) - { // pojazdów w ogóle nie dotyczy dodawanie do mapy - if (i == TP_EVLAUNCH ? Current->EvLaunch->IsGlobal() : false) - srGlobal.NodeAdd(Current); // dodanie do globalnego obiektu - else if (i == TP_TERRAIN) - { // specjalne przetwarzanie terenu wczytanego z pliku E3D - TGroundRect *gr; - for (j = 1; j < Current->iCount; ++j) - { // od 1 do końca są zestawy trójkątów - std::string xxxzzz = Current->nNode[j].smTerrain->pName; // pobranie nazwy - gr = GetRect( - ( std::stoi( xxxzzz.substr( 0, 3 )) - 500 ) * 1000, - ( std::stoi( xxxzzz.substr( 3, 3 )) - 500 ) * 1000 ); - if (Global::bUseVBO) - gr->nTerrain = Current->nNode + j; // zapamiętanie - else - gr->RaNodeAdd(&Current->nNode[j]); - } - } - // else if - // ((Current->iType!=GL_TRIANGLES)&&(Current->iType!=GL_TRIANGLE_STRIP)?true - // //~czy trójkąt? - else if ((Current->iType != GL_TRIANGLES) ? - true //~czy trójkąt? - : - (Current->iFlags & 0x20) ? - true //~czy teksturę ma nieprzezroczystą? - : - (Current->fSquareMinRadius != 0.0) ? - true //~czy widoczny z bliska? - : - (Current->fSquareRadius <= 90000.0)) //~czy widoczny z daleka? - GetSubRect(Current->pCenter.x, Current->pCenter.z)->NodeAdd(Current); - else // dodajemy do kwadratu kilometrowego - GetRect(Current->pCenter.x, Current->pCenter.z)->NodeAdd(Current); - } - // if (Current->iType!=TP_DYNAMIC) - // GetSubRect(Current->pCenter.x,Current->pCenter.z)->AddNode(Current); - } - } - for (i = 0; i < iNumRects; ++i) - for (j = 0; j < iNumRects; ++j) - Rects[i][j].Optimize(); // optymalizacja obiektów w sektorach - WriteLog("InitNormals OK"); - WriteLog("InitTracks"); - InitTracks(); //łączenie odcinków ze sobą i przyklejanie eventów - WriteLog("InitTracks OK"); - WriteLog("InitTraction"); - InitTraction(); //łączenie drutów ze sobą - WriteLog("InitTraction OK"); - WriteLog("InitEvents"); - InitEvents(); - WriteLog("InitEvents OK"); - WriteLog("InitLaunchers"); - InitLaunchers(); - WriteLog("InitLaunchers OK"); - WriteLog("InitGlobalTime"); - // ABu 160205: juz nie TODO :) - Mtable::GlobalTime = std::make_shared( hh, mm, srh, srm, ssh, ssm ); // McZapkie-300302: inicjacja czasu rozkladowego - TODO: czytac z trasy! - WriteLog("InitGlobalTime OK"); - // jeszcze ustawienie pogody, gdyby nie było w scenerii wpisów - glClearColor(Global::AtmoColor[0], Global::AtmoColor[1], Global::AtmoColor[2], - 0.0); // Background Color - if (Global::fFogEnd > 0) - { - glFogi(GL_FOG_MODE, GL_LINEAR); - glFogfv(GL_FOG_COLOR, Global::FogColor); // set fog color - glFogf(GL_FOG_START, Global::fFogStart); // fog start depth - glFogf(GL_FOG_END, Global::fFogEnd); // fog end depth - glEnable(GL_FOG); - } - else - glDisable(GL_FOG); - glDisable(GL_LIGHTING); - glLightfv(GL_LIGHT0, GL_POSITION, Global::lightPos); // daylight position - glLightfv(GL_LIGHT0, GL_AMBIENT, Global::ambientDayLight); // kolor wszechobceny - glLightfv(GL_LIGHT0, GL_DIFFUSE, Global::diffuseDayLight); // kolor padający - glLightfv(GL_LIGHT0, GL_SPECULAR, Global::specularDayLight); // kolor odbity - // musi być tutaj, bo wcześniej nie mieliśmy wartości światła -/* - if (Global::fMoveLight >= 0.0) // albo tak, albo niech ustala minimum ciemności w nocy - { -*/ - Global::fLuminance = // obliczenie luminacji "światła w ciemności" - +0.150 * Global::ambientDayLight[0] // R - + 0.295 * Global::ambientDayLight[1] // G - + 0.055 * Global::ambientDayLight[2]; // B - if (Global::fLuminance > 0.1) // jeśli miało by być za jasno - for (int i = 0; i < 3; i++) - Global::ambientDayLight[i] *= - 0.1 / Global::fLuminance; // ograniczenie jasności w nocy - glLightModelfv(GL_LIGHT_MODEL_AMBIENT, Global::ambientDayLight); -/* - } - else if (Global::bDoubleAmbient) // Ra: wcześniej było ambient dawane na obydwa światła - glLightModelfv(GL_LIGHT_MODEL_AMBIENT, Global::ambientDayLight); -*/ - glEnable(GL_LIGHTING); - WriteLog("FirstInit is done"); -}; - -bool TGround::Init(std::string asFile, HDC hDC) -{ // główne wczytywanie scenerii - if (ToLower(asFile).substr(0, 7) == "scenery") - asFile = asFile.erase(0, 8); // Ra: usunięcie niepotrzebnych znaków - zgodność wstecz z 2003 - WriteLog("Loading scenery from " + asFile); - Global::pGround = this; - // pTrain=NULL; - pOrigin = aRotate = vector3(0, 0, 0); // zerowanie przesunięcia i obrotu - string str = ""; - // TFileStream *fs; - // int size; - std::string subpath = Global::asCurrentSceneryPath; // "scenery/"; - cParser parser(asFile, cParser::buffer_FILE, subpath, Global::bLoadTraction); - std::string token; - - /* - TFileStream *fs; - fs=new TFileStream(asFile , fmOpenRead | fmShareCompat ); - AnsiString str=""; - int size=fs->Size; - str.SetLength(size); - fs->Read(str.c_str(),size); - str+=""; - delete fs; - TQueryParserComp *Parser; - Parser=new TQueryParserComp(NULL); - Parser->TextToParse=str; - // Parser->LoadStringToParse(asFile); - Parser->First(); - AnsiString Token,asFileName; - */ - const int OriginStackMaxDepth = 100; // rozmiar stosu dla zagnieżdżenia origin - int OriginStackTop = 0; - vector3 OriginStack[OriginStackMaxDepth]; // stos zagnieżdżenia origin - - double tf; - int ParamCount, ParamPos; - - // ABu: Jezeli nie ma definicji w scenerii to ustawiane ponizsze wartosci: - hh = 10; // godzina startu - mm = 30; // minuty startu - srh = 6; // godzina wschodu slonca - srm = 0; // minuty wschodu slonca - ssh = 20; // godzina zachodu slonca - ssm = 0; // minuty zachodu slonca - TGroundNode *LastNode = NULL; // do użycia w trainset - iNumNodes = 0; - token = ""; - parser.getTokens(); - parser >> token; - int refresh = 0; - - while (token != "") //(!Parser->EndOfFile) - { - if (refresh == 50) - { // SwapBuffers(hDC); //Ra: bez ogranicznika za bardzo spowalnia :( a u niektórych miga - refresh = 0; - Global::DoEvents(); - } - else - ++refresh; - str = token; - if (str == "node") - { - LastNode = AddGroundNode(&parser); // rozpoznanie węzła - if (LastNode) - { // jeżeli przetworzony poprawnie - if (LastNode->iType == GL_TRIANGLES) - { - if (!LastNode->Vertices) - SafeDelete(LastNode); // usuwamy nieprzezroczyste trójkąty terenu - } - else if (Global::bLoadTraction ? false : LastNode->iType == TP_TRACTION) - SafeDelete(LastNode); // usuwamy druty, jeśli wyłączone - if (LastNode) // dopiero na koniec dopisujemy do tablic - if (LastNode->iType != TP_DYNAMIC) - { // jeśli nie jest pojazdem - LastNode->nNext = nRootOfType[LastNode->iType]; // ostatni dodany dołączamy - // na końcu nowego - nRootOfType[LastNode->iType] = - LastNode; // ustawienie nowego na początku listy - iNumNodes++; - } - else - { // jeśli jest pojazdem - // if (!bInitDone) FirstInit(); //jeśli nie było w scenerii - if (LastNode->DynamicObject->Mechanik) // ale może być pasażer - if (LastNode->DynamicObject->Mechanik - ->Primary()) // jeśli jest głównym (pasażer nie jest) - nTrainSetDriver = - LastNode; // pojazd, któremu zostanie wysłany rozkład - LastNode->nNext = nRootDynamic; - nRootDynamic = LastNode; // dopisanie z przodu do listy - // if (bTrainSet && (LastNode?(LastNode->iType==TP_DYNAMIC):false)) - if (nTrainSetNode) // jeżeli istnieje wcześniejszy TP_DYNAMIC - nTrainSetNode->DynamicObject->AttachPrev( - LastNode->DynamicObject, - TempConnectionType[iTrainSetWehicleNumber - 2]); - nTrainSetNode = LastNode; // ostatnio wczytany - if (TempConnectionType[iTrainSetWehicleNumber - 1] == - 0) // jeśli sprzęg jest zerowy, to wysłać rozkład do składu - { // powinien też tu wchodzić, gdy pojazd bez trainset - if (nTrainSetDriver) // pojazd, któremu zostanie wysłany rozkład - { // wysłanie komendy "Timetable" ustawia odpowiedni tryb jazdy - nTrainSetDriver->DynamicObject->Mechanik->DirectionInitial(); - nTrainSetDriver->DynamicObject->Mechanik->PutCommand( - "Timetable:" + asTrainName, fTrainSetVel, 0, NULL); - nTrainSetDriver = - NULL; // a przy "endtrainset" już wtedy nie potrzeba - } - } - } - } - else - { - Error("Scene parse error near " + token); - // break; - } - } - else if (str == "trainset") - { - iTrainSetWehicleNumber = 0; - nTrainSetNode = NULL; - nTrainSetDriver = NULL; // pojazd, któremu zostanie wysłany rozkład - bTrainSet = true; - parser.getTokens(); - parser >> token; - asTrainName = token; // McZapkie: rodzaj+nazwa pociagu w SRJP - parser.getTokens(); - parser >> token; - asTrainSetTrack = token; //ścieżka startowa - parser.getTokens(2); - parser >> fTrainSetDist >> fTrainSetVel; // przesunięcie i prędkość - } - else if (str == "endtrainset") - { // McZapkie-110103: sygnaly konca pociagu ale tylko dla pociagow rozkladowych - if (nTrainSetNode) // trainset bez dynamic się sypał - { // powinien też tu wchodzić, gdy pojazd bez trainset - if (nTrainSetDriver) // pojazd, któremu zostanie wysłany rozkład - { // wysłanie komendy "Timetable" ustawia odpowiedni tryb jazdy - nTrainSetDriver->DynamicObject->Mechanik->DirectionInitial(); - nTrainSetDriver->DynamicObject->Mechanik->PutCommand("Timetable:" + asTrainName, - fTrainSetVel, 0, NULL); - } - } - if (LastNode) // ostatni wczytany obiekt - if (LastNode->iType == - TP_DYNAMIC) // o ile jest pojazdem (na ogół jest, ale kto wie...) - if (iTrainSetWehicleNumber ? !TempConnectionType[iTrainSetWehicleNumber - 1] : - false) // jeśli ostatni pojazd ma sprzęg 0 - LastNode->DynamicObject->RaLightsSet(-1, 2 + 32 + 64); // to założymy mu - // końcówki blaszane - // (jak AI się - // odpali, to sobie - // poprawi) - bTrainSet = false; - fTrainSetVel = 0; - // iTrainSetConnection=0; - nTrainSetNode = nTrainSetDriver = NULL; - iTrainSetWehicleNumber = 0; - } - else if (str == "event") - { - TEvent *tmp = new TEvent(); - tmp->Load(&parser, &pOrigin); - if (tmp->Type == tp_Unknown) - delete tmp; - else - { // najpierw sprawdzamy, czy nie ma, a potem dopisujemy - TEvent *found = FindEvent(tmp->asName); - if (found) - { // jeśli znaleziony duplikat - auto const size = tmp->asName.size(); - if( tmp->asName[0] == '#' ) // zawsze jeden znak co najmniej jest - { - delete tmp; - tmp = nullptr; - } // utylizacja duplikatu z krzyżykiem - else if( ( size > 8 ) - && ( tmp->asName.substr( 0, 9 ) == "lineinfo:" )) - // tymczasowo wyjątki - { - delete tmp; - tmp = nullptr; - } // tymczasowa utylizacja duplikatów W5 - else if( ( size > 8 ) - && ( tmp->asName.substr( size - 8 ) == "_warning")) - // tymczasowo wyjątki - { - delete tmp; - tmp = nullptr; - } // tymczasowa utylizacja duplikatu z trąbieniem - else if( ( size > 4 ) - && ( tmp->asName.substr( size - 4 ) == "_shp" )) - // nie podlegają logowaniu - { - delete tmp; - tmp = NULL; - } // tymczasowa utylizacja duplikatu SHP - if (tmp) // jeśli nie został zutylizowany - if (Global::bJoinEvents) - found->Append(tmp); // doczepka (taki wirtualny multiple bez warunków) - else - { - ErrorLog("Duplicated event: " + tmp->asName); - found->Append(tmp); // doczepka (taki wirtualny multiple bez warunków) - found->Type = tp_Ignored; // dezaktywacja pierwotnego - taka proteza na - // wsteczną zgodność - // SafeDelete(tmp); //bezlitośnie usuwamy wszelkie duplikaty, żeby nie - // zaśmiecać drzewka - } - } - if ( nullptr != tmp ) - { // jeśli nie duplikat - tmp->evNext2 = RootEvent; // lista wszystkich eventów (m.in. do InitEvents) - RootEvent = tmp; - if (!found) - { // jeśli nazwa wystąpiła, to do kolejki i wyszukiwarki dodawany jest tylko - // pierwszy - if (RootEvent->Type != tp_Ignored) - if (RootEvent->asName.find( - "onstart") != string::npos) // event uruchamiany automatycznie po starcie - AddToQuery(RootEvent, NULL); // dodanie do kolejki -#ifdef EU07_USE_OLD_TNAMES_CLASS - sTracks->Add(0, tmp->asName.c_str(), tmp); // dodanie do wyszukiwarki -#else - m_eventmap.emplace( tmp->asName, tmp ); // dodanie do wyszukiwarki -#endif - } - } - } - } - // else - // if (str==AnsiString("include")) //Tolaris to zrobil wewnatrz parsera - // { - // Include(Parser); - // } - else if (str == "rotate") - { - // parser.getTokens(3); - // parser >> aRotate.x >> aRotate.y >> aRotate.z; //Ra: to potrafi dawać błędne - // rezultaty - parser.getTokens(); - parser >> aRotate.x; - parser.getTokens(); - parser >> aRotate.y; - parser.getTokens(); - parser >> aRotate.z; - // WriteLog("*** rotate "+AnsiString(aRotate.x)+" "+AnsiString(aRotate.y)+" - // "+AnsiString(aRotate.z)); - } - else if (str == "origin") - { - // str=Parser->GetNextSymbol().LowerCase(); - // if (str=="begin") - { - if (OriginStackTop >= OriginStackMaxDepth - 1) - { - MessageBox(0, "Origin stack overflow ", "Error", MB_OK); - break; - } - parser.getTokens(3); - parser >> OriginStack[OriginStackTop].x >> OriginStack[OriginStackTop].y >> - OriginStack[OriginStackTop].z; - pOrigin += OriginStack[OriginStackTop]; // sumowanie całkowitego przesunięcia - OriginStackTop++; // zwiększenie wskaźnika stosu - } - } - else if (str == "endorigin") - { - // else - // if (str=="end") - { - if (OriginStackTop <= 0) - { - MessageBox(0, "Origin stack underflow ", "Error", MB_OK); - break; - } - - OriginStackTop--; // zmniejszenie wskaźnika stosu - pOrigin -= OriginStack[OriginStackTop]; - } - } - else if (str == "atmo") // TODO: uporzadkowac gdzie maja byc parametry mgly! - { // Ra: ustawienie parametrów OpenGL przeniesione do FirstInit - WriteLog("Scenery atmo definition"); - parser.getTokens(3); - parser >> Global::AtmoColor[0] >> Global::AtmoColor[1] >> Global::AtmoColor[2]; - parser.getTokens(2); - parser >> Global::fFogStart >> Global::fFogEnd; - if (Global::fFogEnd > 0.0) - { // ostatnie 3 parametry są opcjonalne - parser.getTokens(3); - parser >> Global::FogColor[0] >> Global::FogColor[1] >> Global::FogColor[2]; - } - parser.getTokens(); - parser >> token; - while (token.compare("endatmo") != 0) - { // a kolejne parametry są pomijane - parser.getTokens(); - parser >> token; - } - } - else if (str == "time") - { - WriteLog("Scenery time definition"); - char temp_in[9]; - char temp_out[9]; - int i, j; - parser.getTokens(); - parser >> temp_in; - for (j = 0; j <= 8; j++) - temp_out[j] = ' '; - for (i = 0; temp_in[i] != ':'; i++) - temp_out[i] = temp_in[i]; - hh = atoi(temp_out); - for (j = 0; j <= 8; j++) - temp_out[j] = ' '; - for (j = i + 1; j <= 8; j++) - temp_out[j - (i + 1)] = temp_in[j]; - mm = atoi(temp_out); - - parser.getTokens(); - parser >> temp_in; - for (j = 0; j <= 8; j++) - temp_out[j] = ' '; - for (i = 0; temp_in[i] != ':'; i++) - temp_out[i] = temp_in[i]; - srh = atoi(temp_out); - for (j = 0; j <= 8; j++) - temp_out[j] = ' '; - for (j = i + 1; j <= 8; j++) - temp_out[j - (i + 1)] = temp_in[j]; - srm = atoi(temp_out); - - parser.getTokens(); - parser >> temp_in; - for (j = 0; j <= 8; j++) - temp_out[j] = ' '; - for (i = 0; temp_in[i] != ':'; i++) - temp_out[i] = temp_in[i]; - ssh = atoi(temp_out); - for (j = 0; j <= 8; j++) - temp_out[j] = ' '; - for (j = i + 1; j <= 8; j++) - temp_out[j - (i + 1)] = temp_in[j]; - ssm = atoi(temp_out); - while (token.compare("endtime") != 0) - { - parser.getTokens(); - parser >> token; - } - } - else if (str == "light") - { // Ra: ustawianie światła przeniesione do FirstInit - WriteLog("Scenery light definition"); - vector3 lp; - parser.getTokens(); - parser >> lp.x; - parser.getTokens(); - parser >> lp.y; - parser.getTokens(); - parser >> lp.z; - lp = Normalize(lp); // kierunek padania - Global::lightPos[0] = lp.x; // daylight position - Global::lightPos[1] = lp.y; - Global::lightPos[2] = lp.z; - parser.getTokens(); - parser >> Global::ambientDayLight[0]; // kolor wszechobceny - parser.getTokens(); - parser >> Global::ambientDayLight[1]; - parser.getTokens(); - parser >> Global::ambientDayLight[2]; - - parser.getTokens(); - parser >> Global::diffuseDayLight[0]; // kolor padający - parser.getTokens(); - parser >> Global::diffuseDayLight[1]; - parser.getTokens(); - parser >> Global::diffuseDayLight[2]; - - parser.getTokens(); - parser >> Global::specularDayLight[0]; // kolor odbity - parser.getTokens(); - parser >> Global::specularDayLight[1]; - parser.getTokens(); - parser >> Global::specularDayLight[2]; - - do - { - parser.getTokens(); - parser >> token; - } while (token.compare("endlight") != 0); - } - else if (str == "camera") - { - vector3 xyz, abc; - xyz = abc = vector3(0, 0, 0); // wartości domyślne, bo nie wszystie muszą być - int i = -1, into = -1; // do której definicji kamery wstawić - WriteLog("Scenery camera definition"); - do - { // opcjonalna siódma liczba określa numer kamery, a kiedyś były tylko 3 - parser.getTokens(); - parser >> token; - switch (++i) - { // kiedyś camera miało tylko 3 współrzędne - case 0: - xyz.x = atof(token.c_str()); - break; - case 1: - xyz.y = atof(token.c_str()); - break; - case 2: - xyz.z = atof(token.c_str()); - break; - case 3: - abc.x = atof(token.c_str()); - break; - case 4: - abc.y = atof(token.c_str()); - break; - case 5: - abc.z = atof(token.c_str()); - break; - case 6: - into = atoi(token.c_str()); // takie sobie, bo można wpisać -1 - } - } while (token.compare("endcamera") != 0); - if (into < 0) - into = ++Global::iCameraLast; - if ((into >= 0) && (into < 10)) - { // przepisanie do odpowiedniego miejsca w tabelce - Global::pFreeCameraInit[into] = xyz; - abc.x = DegToRad(abc.x); - abc.y = DegToRad(abc.y); - abc.z = DegToRad(abc.z); - Global::pFreeCameraInitAngle[into] = abc; - Global::iCameraLast = into; // numer ostatniej - } - } - else if (str == "sky") - { // youBy - niebo z pliku - WriteLog("Scenery sky definition"); - parser.getTokens(); - parser >> token; - string SkyTemp = token; - if (Global::asSky == "1") - Global::asSky = SkyTemp; - do - { // pożarcie dodatkowych parametrów - parser.getTokens(); - parser >> token; - } while (token.compare("endsky") != 0); - WriteLog(Global::asSky.c_str()); - } - else if (str == "firstinit") - FirstInit(); - else if (str == "description") - { - do - { - parser.getTokens(); - parser >> token; - } while (token.compare("enddescription") != 0); - } - else if (str == "test") - { // wypisywanie treści po przetworzeniu - WriteLog("---> Parser test:"); - do - { - parser.getTokens(); - parser >> token; - WriteLog(token.c_str()); - } while (token.compare("endtest") != 0); - WriteLog("---> End of parser test."); - } - else if (str == "config") - { // możliwość przedefiniowania parametrów w scenerii - Global::ConfigParse(parser); // parsowanie dodatkowych ustawień - } - else if (str != "") - { // pomijanie od nierozpoznanej komendy do jej zakończenia - if ((token.length() > 2) && (atof(token.c_str()) == 0.0)) - { // jeśli nie liczba, to spróbować pominąć komendę - WriteLog("Unrecognized command: " + str); - str = "end" + str; - do - { - parser.getTokens(); - token = ""; - parser >> token; - } while ((token != "") && (token.compare(str.c_str()) != 0)); - } - else // jak liczba to na pewno błąd - Error("Unrecognized command: " + str); - } -/* else if (str == "") - break; -*/ - // LastNode=NULL; - - token = ""; - parser.getTokens(); - parser >> token; - } - -#ifdef EU07_USE_OLD_TNAMES_CLASS - sTracks->Sort(TP_TRACK); // finalne sortowanie drzewa torów - sTracks->Sort(TP_MEMCELL); // finalne sortowanie drzewa komórek pamięci - sTracks->Sort(TP_MODEL); // finalne sortowanie drzewa modeli - sTracks->Sort(0); // finalne sortowanie drzewa eventów -#endif - if (!bInitDone) - FirstInit(); // jeśli nie było w scenerii - if (Global::pTerrainCompact) - TerrainWrite(); // Ra: teraz można zapisać teren w jednym pliku - Global::iPause &= ~0x10; // koniec pauzy wczytywania - return true; -} - -bool TGround::InitEvents() -{ //łączenie eventów z pozostałymi obiektami - TGroundNode *tmp, *trk; - char buff[255]; - int i; - for (TEvent *Current = RootEvent; Current; Current = Current->evNext2) - { - switch (Current->Type) - { - case tp_AddValues: // sumowanie wartości - case tp_UpdateValues: // zmiana wartości - tmp = FindGroundNode(Current->asNodeName, - TP_MEMCELL); // nazwa komórki powiązanej z eventem - if (tmp) - { // McZapkie-100302 - if (Current->iFlags & (conditional_trackoccupied | conditional_trackfree)) - { // jeśli chodzi o zajetosc toru (tor może być inny, niż wpisany w komórce) - trk = FindGroundNode(Current->asNodeName, - TP_TRACK); // nazwa toru ta sama, co nazwa komórki - if (trk) - Current->Params[9].asTrack = trk->pTrack; - if (!Current->Params[9].asTrack) - ErrorLog("Bad event: track \"" + Current->asNodeName + - "\" does not exists in \"" + Current->asName + "\""); - } - Current->Params[4].nGroundNode = tmp; - Current->Params[5].asMemCell = tmp->MemCell; // komórka do aktualizacji - if (Current->iFlags & (conditional_memcompare)) - Current->Params[9].asMemCell = tmp->MemCell; // komórka do badania warunku - if (!tmp->MemCell->asTrackName - .empty()) // tor powiązany z komórką powiązaną z eventem - { // tu potrzebujemy wskaźnik do komórki w (tmp) - trk = FindGroundNode(tmp->MemCell->asTrackName, TP_TRACK); - if (trk) - Current->Params[6].asTrack = trk->pTrack; - else - ErrorLog("Bad memcell: track \"" + tmp->MemCell->asTrackName + - "\" not exists in memcell \"" + tmp->asName + "\""); - } - else - Current->Params[6].asTrack = NULL; - } - else - { // nie ma komórki, to nie będzie działał poprawnie - Current->Type = tp_Ignored; // deaktywacja - ErrorLog("Bad event: \"" + Current->asName + "\" cannot find memcell \"" + - Current->asNodeName + "\""); - } - break; - case tp_LogValues: // skojarzenie z memcell - if (Current->asNodeName.empty()) - { // brak skojarzenia daje logowanie wszystkich - Current->Params[9].asMemCell = NULL; - break; - } - case tp_GetValues: - case tp_WhoIs: - tmp = FindGroundNode(Current->asNodeName, TP_MEMCELL); - if (tmp) - { - Current->Params[8].nGroundNode = tmp; - Current->Params[9].asMemCell = tmp->MemCell; - if (Current->Type == tp_GetValues) // jeśli odczyt komórki - if (tmp->MemCell->IsVelocity()) // a komórka zawiera komendę SetVelocity albo - // ShuntVelocity - Current->bEnabled = false; // to event nie będzie dodawany do kolejki - } - else - { // nie ma komórki, to nie będzie działał poprawnie - Current->Type = tp_Ignored; // deaktywacja - ErrorLog("Bad event: \"" + Current->asName + "\" cannot find memcell \"" + - Current->asNodeName + "\""); - } - break; - case tp_CopyValues: // skopiowanie komórki do innej - tmp = FindGroundNode(Current->asNodeName, TP_MEMCELL); // komórka docelowa - if (tmp) - { - Current->Params[4].nGroundNode = tmp; - Current->Params[5].asMemCell = tmp->MemCell; // komórka docelowa - if (!tmp->MemCell->asTrackName - .empty()) // tor powiązany z komórką powiązaną z eventem - { // tu potrzebujemy wskaźnik do komórki w (tmp) - trk = FindGroundNode(tmp->MemCell->asTrackName, TP_TRACK); - if (trk) - Current->Params[6].asTrack = trk->pTrack; - else - ErrorLog("Bad memcell: track \"" + tmp->MemCell->asTrackName + - "\" not exists in memcell \"" + tmp->asName + "\""); - } - else - Current->Params[6].asTrack = NULL; - } - else - ErrorLog("Bad copyvalues: event \"" + Current->asName + - "\" cannot find memcell \"" + Current->asNodeName + "\""); - strcpy( - buff, - Current->Params[9].asText); // skopiowanie nazwy drugiej komórki do bufora roboczego - SafeDeleteArray(Current->Params[9].asText); // usunięcie nazwy komórki - tmp = FindGroundNode(buff, TP_MEMCELL); // komórka źódłowa - if (tmp) - { - Current->Params[8].nGroundNode = tmp; - Current->Params[9].asMemCell = tmp->MemCell; // komórka źródłowa - } - else - ErrorLog("Bad copyvalues: event \"" + Current->asName + - "\" cannot find memcell \"" + buff + "\""); - break; - case tp_Animation: // animacja modelu - tmp = FindGroundNode(Current->asNodeName, TP_MODEL); // egzemplarza modelu do animowania - if (tmp) - { - strcpy( - buff, - Current->Params[9].asText); // skopiowanie nazwy submodelu do bufora roboczego - SafeDeleteArray(Current->Params[9].asText); // usunięcie nazwy submodelu - if (Current->Params[0].asInt == 4) - Current->Params[9].asModel = tmp->Model; // model dla całomodelowych animacji - else - { // standardowo przypisanie submodelu - Current->Params[9].asAnimContainer = tmp->Model->GetContainer(buff); // submodel - if (Current->Params[9].asAnimContainer) - { - Current->Params[9].asAnimContainer->WillBeAnimated(); // oflagowanie - // animacji - if (!Current->Params[9] - .asAnimContainer->Event()) // nie szukać, gdy znaleziony - Current->Params[9].asAnimContainer->EventAssign( - FindEvent(Current->asNodeName + "." + buff + ":done")); - } - } - } - else - ErrorLog("Bad animation: event \"" + Current->asName + "\" cannot find model \"" + - Current->asNodeName + "\""); - Current->asNodeName = ""; - break; - case tp_Lights: // zmiana świeteł modelu - tmp = FindGroundNode(Current->asNodeName, TP_MODEL); - if (tmp) - Current->Params[9].asModel = tmp->Model; - else - ErrorLog("Bad lights: event \"" + Current->asName + "\" cannot find model \"" + - Current->asNodeName + "\""); - Current->asNodeName = ""; - break; - case tp_Visible: // ukrycie albo przywrócenie obiektu - tmp = FindGroundNode(Current->asNodeName, TP_MODEL); // najpierw model - if (!tmp) - tmp = FindGroundNode(Current->asNodeName, TP_TRACTION); // może druty? - if (!tmp) - tmp = FindGroundNode(Current->asNodeName, TP_TRACK); // albo tory? - if (tmp) - Current->Params[9].nGroundNode = tmp; - else - ErrorLog("Bad visibility: event \"" + Current->asName + "\" cannot find model \"" + - Current->asNodeName + "\""); - Current->asNodeName = ""; - break; - case tp_Switch: // przełożenie zwrotnicy albo zmiana stanu obrotnicy - tmp = FindGroundNode(Current->asNodeName, TP_TRACK); - if (tmp) - { // dowiązanie toru - if (!tmp->pTrack->iAction) // jeśli nie jest zwrotnicą ani obrotnicą - tmp->pTrack->iAction |= 0x100; // to będzie się zmieniał stan uszkodzenia - Current->Params[9].asTrack = tmp->pTrack; - if (!Current->Params[0].asInt) // jeśli przełącza do stanu 0 - if (Current->Params[2].asdouble >= - 0.0) // jeśli jest zdefiniowany dodatkowy ruch iglic - Current->Params[9].asTrack->Switch( - 0, Current->Params[1].asdouble, - Current->Params[2].asdouble); // przesłanie parametrów - } - else - ErrorLog("Bad switch: event \"" + Current->asName + "\" cannot find track \"" + - Current->asNodeName + "\""); - Current->asNodeName = ""; - break; - case tp_Sound: // odtworzenie dźwięku - tmp = FindGroundNode(Current->asNodeName, TP_SOUND); - if (tmp) - Current->Params[9].tsTextSound = tmp->tsStaticSound; - else - ErrorLog("Bad sound: event \"" + Current->asName + - "\" cannot find static sound \"" + Current->asNodeName + "\""); - Current->asNodeName = ""; - break; - case tp_TrackVel: // ustawienie prędkości na torze - if (!Current->asNodeName.empty()) - { - tmp = FindGroundNode(Current->asNodeName, TP_TRACK); - if (tmp) - { - tmp->pTrack->iAction |= - 0x200; // flaga zmiany prędkości toru jest istotna dla skanowania - Current->Params[9].asTrack = tmp->pTrack; - } - else - ErrorLog("Bad velocity: event \"" + Current->asName + - "\" cannot find track \"" + Current->asNodeName + "\""); - } - Current->asNodeName = ""; - break; - case tp_DynVel: // komunikacja z pojazdem o konkretnej nazwie - if (Current->asNodeName == "activator") - Current->Params[9].asDynamic = NULL; - else - { - tmp = FindGroundNode(Current->asNodeName, TP_DYNAMIC); - if (tmp) - Current->Params[9].asDynamic = tmp->DynamicObject; - else - Error("Event \"" + Current->asName + "\" cannot find dynamic \"" + - Current->asNodeName + "\""); - } - Current->asNodeName = ""; - break; - case tp_Multiple: - if (Current->Params[9].asText != NULL) - { // przepisanie nazwy do bufora - strcpy(buff, Current->Params[9].asText); - SafeDeleteArray(Current->Params[9].asText); - Current->Params[9].asPointer = NULL; // zerowanie wskaźnika, aby wykryć brak obeiktu - } - else - buff[0] = '\0'; - if (Current->iFlags & (conditional_trackoccupied | conditional_trackfree)) - { // jeśli chodzi o zajetosc toru - tmp = FindGroundNode(buff, TP_TRACK); - if (tmp) - Current->Params[9].asTrack = tmp->pTrack; - if (!Current->Params[9].asTrack) - { - ErrorLog("Bad event: Track \"" + string(buff) + - "\" does not exist in \"" + Current->asName + "\""); - Current->iFlags &= - ~(conditional_trackoccupied | conditional_trackfree); // zerowanie flag - } - } - else if (Current->iFlags & - (conditional_memstring | conditional_memval1 | conditional_memval2)) - { // jeśli chodzi o komorke pamieciową - tmp = FindGroundNode(buff, TP_MEMCELL); - if (tmp) - Current->Params[9].asMemCell = tmp->MemCell; - if (!Current->Params[9].asMemCell) - { - ErrorLog("Bad event: MemCell \"" + string(buff) + - "\" does not exist in \"" + Current->asName + "\""); - Current->iFlags &= - ~(conditional_memstring | conditional_memval1 | conditional_memval2); - } - } - for (i = 0; i < 8; i++) - { - if (Current->Params[i].asText != NULL) - { - strcpy(buff, Current->Params[i].asText); - SafeDeleteArray(Current->Params[i].asText); - Current->Params[i].asEvent = FindEvent(buff); - if( !Current->Params[ i ].asEvent ) { // Ra: tylko w logu informacja o braku - if( ( Current->Params[ i ].asText == NULL ) - || ( std::string( Current->Params[ i ].asText ).substr( 0, 5 ) != "none_" ) ) { - WriteLog( "Event \"" + string( buff ) + "\" does not exist" ); - ErrorLog( "Missed event: " + string( buff ) + " in multiple " + Current->asName ); - } - } - } - } - break; - case tp_Voltage: // zmiana napięcia w zasilaczu (TractionPowerSource) - if (!Current->asNodeName.empty()) - { - tmp = FindGroundNode(Current->asNodeName, - TP_TRACTIONPOWERSOURCE); // podłączenie zasilacza - if (tmp) - Current->Params[9].psPower = tmp->psTractionPowerSource; - else - ErrorLog("Bad voltage: event \"" + Current->asName + - "\" cannot find power source \"" + Current->asNodeName + "\""); - } - Current->asNodeName = ""; - break; - case tp_Message: // wyświetlenie komunikatu - break; - } - if (Current->fDelay < 0) - AddToQuery(Current, NULL); - } - for (TGroundNode *Current = nRootOfType[TP_MEMCELL]; Current; Current = Current->nNext) - { // Ra: eventy komórek pamięci, wykonywane po wysłaniu komendy do zatrzymanego pojazdu - Current->MemCell->AssignEvents(FindEvent(Current->asName + ":sent")); - } - return true; -} - -void TGround::InitTracks() -{ //łączenie torów ze sobą i z eventami - TGroundNode *Current, *Model; - TTrack *tmp; // znaleziony tor - TTrack *Track; - int iConnection, state; - string name; - // tracks=tracksfar=0; - for (Current = nRootOfType[TP_TRACK]; Current; Current = Current->nNext) - { - Track = Current->pTrack; - if (Global::iHiddenEvents & 1) - if (!Current->asName.empty()) - { // jeśli podana jest nazwa torów, można szukać eventów skojarzonych przez nazwę - if (Track->asEvent0Name.empty()) - if (FindEvent(Current->asName + ":event0")) - Track->asEvent0Name = Current->asName + ":event0"; - if (Track->asEvent1Name.empty()) - if (FindEvent(Current->asName + ":event1")) - Track->asEvent1Name = Current->asName + ":event1"; - if (Track->asEvent2Name.empty()) - if (FindEvent(Current->asName + ":event2")) - Track->asEvent2Name = Current->asName + ":event2"; - - if (Track->asEventall0Name.empty()) - if (FindEvent(Current->asName + ":eventall0")) - Track->asEventall0Name = Current->asName + ":eventall0"; - if (Track->asEventall1Name.empty()) - if (FindEvent(Current->asName + ":eventall1")) - Track->asEventall1Name = Current->asName + ":eventall1"; - if (Track->asEventall2Name.empty()) - if (FindEvent(Current->asName + ":eventall2")) - Track->asEventall2Name = Current->asName + ":eventall2"; - } - Track->AssignEvents( - Track->asEvent0Name.empty() ? NULL : FindEvent(Track->asEvent0Name), - Track->asEvent1Name.empty() ? NULL : FindEventScan(Track->asEvent1Name), - Track->asEvent2Name.empty() ? NULL : FindEventScan(Track->asEvent2Name)); - Track->AssignallEvents( - Track->asEventall0Name.empty() ? NULL : FindEvent(Track->asEventall0Name), - Track->asEventall1Name.empty() ? NULL : FindEvent(Track->asEventall1Name), - Track->asEventall2Name.empty() ? NULL : - FindEvent(Track->asEventall2Name)); // MC-280503 - switch (Track->eType) - { - case tt_Table: // obrotnicę też łączymy na starcie z innymi torami - Model = FindGroundNode(Current->asName, TP_MODEL); // szukamy modelu o tej samej nazwie - // if (tmp) //mamy model, trzeba zapamiętać wskaźnik do jego animacji - { // jak coś pójdzie źle, to robimy z tego normalny tor - // Track->ModelAssign(tmp->Model->GetContainer(NULL)); //wiązanie toru z modelem - // obrotnicy - Track->RaAssign( - Current, Model ? Model->Model : NULL, FindEvent(Current->asName + ":done"), - FindEvent(Current->asName + ":joined")); // wiązanie toru z modelem obrotnicy - // break; //jednak połączę z sąsiednim, jak ma się wysypywać null track - } - if (!Model) // jak nie ma modelu - break; // to pewnie jest wykolejnica, a ta jest domyślnie zamknięta i wykoleja - case tt_Normal: // tylko proste są podłączane do rozjazdów, stąd dwa rozjazdy się nie - // połączą ze sobą - if (Track->CurrentPrev() == NULL) // tylko jeśli jeszcze nie podłączony - { - tmp = FindTrack(Track->CurrentSegment()->FastGetPoint_0(), iConnection, Current); - switch (iConnection) - { - case -1: // Ra: pierwsza koncepcja zawijania samochodów i statków - // if ((Track->iCategoryFlag&1)==0) //jeśli nie jest torem szynowym - // Track->ConnectPrevPrev(Track,0); //łączenie końca odcinka do samego siebie - break; - case 0: - Track->ConnectPrevPrev(tmp, 0); - break; - case 1: - Track->ConnectPrevNext(tmp, 1); - break; - case 2: - Track->ConnectPrevPrev(tmp, 0); // do Point1 pierwszego - tmp->SetConnections(0); // zapamiętanie ustawień w Segmencie - break; - case 3: - Track->ConnectPrevNext(tmp, 1); // do Point2 pierwszego - tmp->SetConnections(0); // zapamiętanie ustawień w Segmencie - break; - case 4: - tmp->Switch(1); - Track->ConnectPrevPrev(tmp, 2); // do Point1 drugiego - tmp->SetConnections(1); // robi też Switch(0) - tmp->Switch(0); - break; - case 5: - tmp->Switch(1); - Track->ConnectPrevNext(tmp, 3); // do Point2 drugiego - tmp->SetConnections(1); // robi też Switch(0) - tmp->Switch(0); - break; - } - } - if (Track->CurrentNext() == NULL) // tylko jeśli jeszcze nie podłączony - { - tmp = FindTrack(Track->CurrentSegment()->FastGetPoint_1(), iConnection, Current); - switch (iConnection) - { - case -1: // Ra: pierwsza koncepcja zawijania samochodów i statków - // if ((Track->iCategoryFlag&1)==0) //jeśli nie jest torem szynowym - // Track->ConnectNextNext(Track,1); //łączenie końca odcinka do samego siebie - break; - case 0: - Track->ConnectNextPrev(tmp, 0); - break; - case 1: - Track->ConnectNextNext(tmp, 1); - break; - case 2: - Track->ConnectNextPrev(tmp, 0); - tmp->SetConnections(0); // zapamiętanie ustawień w Segmencie - break; - case 3: - Track->ConnectNextNext(tmp, 1); - tmp->SetConnections(0); // zapamiętanie ustawień w Segmencie - break; - case 4: - tmp->Switch(1); - Track->ConnectNextPrev(tmp, 2); - tmp->SetConnections(1); // robi też Switch(0) - // tmp->Switch(0); - break; - case 5: - tmp->Switch(1); - Track->ConnectNextNext(tmp, 3); - tmp->SetConnections(1); // robi też Switch(0) - // tmp->Switch(0); - break; - } - } - break; - case tt_Switch: // dla rozjazdów szukamy eventów sygnalizacji rozprucia - Track->AssignForcedEvents(FindEvent(Current->asName + ":forced+"), - FindEvent(Current->asName + ":forced-")); - break; - } - name = Track->IsolatedName(); // pobranie nazwy odcinka izolowanego - if (!name.empty()) // jeśli została zwrócona nazwa - Track->IsolatedEventsAssign(FindEvent(name + ":busy"), FindEvent(name + ":free")); - if (Current->asName.substr(0, 1) == - "*") // możliwy portal, jeśli nie podłączony od striny 1 - if (!Track->CurrentPrev() && Track->CurrentNext()) - Track->iCategoryFlag |= 0x100; // ustawienie flagi portalu - } - // WriteLog("Total "+AnsiString(tracks)+", far "+AnsiString(tracksfar)); - TIsolated *p = TIsolated::Root(); - while (p) - { // jeśli się znajdzie, to podać wskaźnik - Current = FindGroundNode(p->asName, TP_MEMCELL); // czy jest komóka o odpowiedniej nazwie - if (Current) - p->pMemCell = Current->MemCell; // przypisanie powiązanej komórki - else - { // utworzenie automatycznej komórki - Current = new TGroundNode(); // to nie musi mieć nazwy, nazwa w wyszukiwarce wystarczy - // Current->asName=p->asName; //mazwa identyczna, jak nazwa odcinka izolowanego - Current->MemCell = new TMemCell(NULL); // nowa komórka -#ifdef EU07_USE_OLD_TNAMES_CLASS - sTracks->Add(TP_MEMCELL, p->asName.c_str(), Current); // dodanie do wyszukiwarki -#else - m_trackmap.Add( TP_MEMCELL, p->asName, Current ); -#endif - Current->nNext = - nRootOfType[TP_MEMCELL]; // to nie powinno tutaj być, bo robi się śmietnik - nRootOfType[TP_MEMCELL] = Current; - iNumNodes++; - p->pMemCell = Current->MemCell; // wskaźnik komóki przekazany do odcinka izolowanego - } - p = p->Next(); - } - // for (Current=nRootOfType[TP_TRACK];Current;Current=Current->nNext) - // if (Current->pTrack->eType==tt_Cross) - // Current->pTrack->ConnectionsLog(); //zalogowanie informacji o połączeniach -} - -void TGround::InitTraction() -{ //łączenie drutów ze sobą oraz z torami i eventami - TGroundNode *nCurrent, *nTemp; - TTraction *tmp; // znalezione przęsło - TTraction *Traction; - int iConnection; - string name; - for (nCurrent = nRootOfType[TP_TRACTION]; nCurrent; nCurrent = nCurrent->nNext) - { // podłączenie do zasilacza, żeby można było sumować prąd kilku pojazdów - // a jednocześnie z jednego miejsca zmieniać napięcie eventem - // wykonywane najpierw, żeby można było logować podłączenie 2 zasilaczy do jednego drutu - // izolator zawieszony na przęśle jest ma być osobnym odcinkiem drutu o długości ok. 1m, - // podłączonym do zasilacza o nazwie "*" (gwiazka); "none" nie będzie odpowiednie - Traction = nCurrent->hvTraction; - nTemp = FindGroundNode(Traction->asPowerSupplyName, TP_TRACTIONPOWERSOURCE); - if (nTemp) // jak zasilacz znaleziony - Traction->PowerSet(nTemp->psTractionPowerSource); // to podłączyć do przęsła - else if (Traction->asPowerSupplyName != "*") // gwiazdka dla przęsła z izolatorem - if (Traction->asPowerSupplyName != "none") // dopuszczamy na razie brak podłączenia? - { // logowanie błędu i utworzenie zasilacza o domyślnej zawartości - ErrorLog("Missed TractionPowerSource: " + Traction->asPowerSupplyName); - nTemp = new TGroundNode(); - nTemp->iType = TP_TRACTIONPOWERSOURCE; - nTemp->asName = Traction->asPowerSupplyName; - nTemp->psTractionPowerSource = new TTractionPowerSource(nTemp); - nTemp->psTractionPowerSource->Init(Traction->NominalVoltage, Traction->MaxCurrent); - nTemp->nNext = nRootOfType[nTemp->iType]; // ostatni dodany dołączamy na końcu - // nowego - nRootOfType[nTemp->iType] = nTemp; // ustawienie nowego na początku listy - iNumNodes++; - } - } - for (nCurrent = nRootOfType[TP_TRACTION]; nCurrent; nCurrent = nCurrent->nNext) - { - Traction = nCurrent->hvTraction; - if (!Traction->hvNext[0]) // tylko jeśli jeszcze nie podłączony - { - tmp = FindTraction(&Traction->pPoint1, iConnection, nCurrent); - switch (iConnection) - { - case 0: - Traction->Connect(0, tmp, 0); - break; - case 1: - Traction->Connect(0, tmp, 1); - break; - } - if (Traction->hvNext[0]) // jeśli został podłączony - if (Traction->psSection && tmp->psSection) // tylko przęsło z izolatorem może nie - // mieć zasilania, bo ma 2, trzeba - // sprawdzać sąsiednie - if (Traction->psSection != - tmp->psSection) // połączone odcinki mają różne zasilacze - { // to może być albo podłączenie podstacji lub kabiny sekcyjnej do sekcji, albo - // błąd - if (Traction->psSection->bSection && !tmp->psSection->bSection) - { //(tmp->psSection) jest podstacją, a (Traction->psSection) nazwą sekcji - tmp->PowerSet(Traction->psSection); // zastąpienie wskazaniem sekcji - } - else if (!Traction->psSection->bSection && tmp->psSection->bSection) - { //(Traction->psSection) jest podstacją, a (tmp->psSection) nazwą sekcji - Traction->PowerSet(tmp->psSection); // zastąpienie wskazaniem sekcji - } - else // jeśli obie to sekcje albo obie podstacje, to będzie błąd - ErrorLog("Bad power: at " + - to_string(Traction->pPoint1.x, 2, 6) + " " + - to_string(Traction->pPoint1.y, 2, 6) + " " + - to_string(Traction->pPoint1.z, 2, 6)); - } - } - if (!Traction->hvNext[1]) // tylko jeśli jeszcze nie podłączony - { - tmp = FindTraction(&Traction->pPoint2, iConnection, nCurrent); - switch (iConnection) - { - case 0: - Traction->Connect(1, tmp, 0); - break; - case 1: - Traction->Connect(1, tmp, 1); - break; - } - if (Traction->hvNext[1]) // jeśli został podłączony - if (Traction->psSection && tmp->psSection) // tylko przęsło z izolatorem może nie - // mieć zasilania, bo ma 2, trzeba - // sprawdzać sąsiednie - if (Traction->psSection != tmp->psSection) - { // to może być albo podłączenie podstacji lub kabiny sekcyjnej do sekcji, albo - // błąd - if (Traction->psSection->bSection && !tmp->psSection->bSection) - { //(tmp->psSection) jest podstacją, a (Traction->psSection) nazwą sekcji - tmp->PowerSet(Traction->psSection); // zastąpienie wskazaniem sekcji - } - else if (!Traction->psSection->bSection && tmp->psSection->bSection) - { //(Traction->psSection) jest podstacją, a (tmp->psSection) nazwą sekcji - Traction->PowerSet(tmp->psSection); // zastąpienie wskazaniem sekcji - } - else // jeśli obie to sekcje albo obie podstacje, to będzie błąd - ErrorLog("Bad power: at " + - to_string(Traction->pPoint2.x, 2, 6) + " " + - to_string(Traction->pPoint2.y, 2, 6) + " " + - to_string(Traction->pPoint2.z, 2, 6)); - } - } - } - iConnection = 0; // teraz będzie licznikiem końców - for (nCurrent = nRootOfType[TP_TRACTION]; nCurrent; nCurrent = nCurrent->nNext) - { // operacje mające na celu wykrywanie bieżni wspólnych i łączenie przęseł naprążania - if (nCurrent->hvTraction->WhereIs()) // oznakowanie przedostatnich przęseł - { // poszukiwanie bieżni wspólnej dla przedostatnich przęseł, również w celu połączenia - // zasilania - // to się nie sprawdza, bo połączyć się mogą dwa niezasilane odcinki jako najbliższe - // sobie - // nCurrent->hvTraction->hvParallel=TractionNearestFind(nCurrent->pCenter,0,nCurrent); - // //szukanie najbliższego przęsła - // trzeba by zliczać końce, a potem wpisać je do tablicy, aby sukcesywnie podłączać do - // zasilaczy - nCurrent->hvTraction->iTries = 5; // oznaczanie końcowych - ++iConnection; - } - if (nCurrent->hvTraction->fResistance[0] == 0.0) - { - nCurrent->hvTraction - ->ResistanceCalc(); // obliczanie przęseł w segmencie z bezpośrednim zasilaniem - // ErrorLog("Section "+nCurrent->hvTraction->asPowerSupplyName+" connected"); //jako - // niby błąd będzie bardziej widoczne - nCurrent->hvTraction->iTries = 0; // nie potrzeba mu szukać zasilania - } - // if (!Traction->hvParallel) //jeszcze utworzyć pętle z bieżni wspólnych - } - int zg = 0; // zgodność kierunku przęseł, tymczasowo iterator do tabeli końców - TGroundNode **nEnds = new TGroundNode *[iConnection]; // końców jest ok. 10 razy mniej niż - // wszystkich przęseł (Quark: 216) - for (nCurrent = nRootOfType[TP_TRACTION]; nCurrent; nCurrent = nCurrent->nNext) - { //łączenie bieżni wspólnych, w tym oznaczanie niepodanych jawnie - Traction = nCurrent->hvTraction; - if (!Traction->asParallel.empty()) // będzie wskaźnik na inne przęsło - if ((Traction->asParallel == "none") || - (Traction->asParallel == "*")) // jeśli nieokreślone - Traction->iLast = - 2; // jakby przedostatni - niech po prostu szuka (iLast już przeliczone) - else if (!Traction->hvParallel) // jeśli jeszcze nie został włączony w kółko - { - nTemp = FindGroundNode(Traction->asParallel, TP_TRACTION); - if (nTemp) - { // o ile zostanie znalezione przęsło o takiej nazwie - if (!nTemp->hvTraction - ->hvParallel) // jeśli tamten jeszcze nie ma wskaźnika bieżni wspólnej - Traction->hvParallel = - nTemp->hvTraction; // wpisać siebie i dalej dać mu wskaźnik zwrotny - else // a jak ma, to albo dołączyć się do kółeczka - Traction->hvParallel = - nTemp->hvTraction->hvParallel; // przjąć dotychczasowy wskaźnik od niego - nTemp->hvTraction->hvParallel = - Traction; // i na koniec ustawienie wskaźnika zwrotnego - } - if (!Traction->hvParallel) - ErrorLog("Missed overhead: " + Traction->asParallel); // logowanie braku - } - if (Traction->iTries > 0) // jeśli zaznaczony do podłączenia - // if (!nCurrent->hvTraction->psPower[0]||!nCurrent->hvTraction->psPower[1]) - if (zg < iConnection) // zabezpieczenie - nEnds[zg++] = nCurrent; // wypełnianie tabeli końców w celu szukania im połączeń - } - while (zg < iConnection) - nEnds[zg++] = NULL; // zapełnienie do końca tablicy, jeśli by jakieś końce wypadły - zg = 1; // nieefektywny przebieg kończy łączenie - while (zg) - { // ustalenie zastępczej rezystancji dla każdego przęsła - zg = 0; // flaga podłączonych przęseł końcowych: -1=puste wskaźniki, 0=coś zostało, - // 1=wykonano łączenie - for (int i = 0; i < iConnection; ++i) - if (nEnds[i]) // załatwione będziemy zerować - { // każdy przebieg to próba podłączenia końca segmentu naprężania do innego zasilanego - // przęsła - if (nEnds[i]->hvTraction->hvNext[0]) - { // jeśli końcowy ma ciąg dalszy od strony 0 (Point1), szukamy odcinka najbliższego - // do Point2 - if (TractionNearestFind(nEnds[i]->hvTraction->pPoint2, 0, - nEnds[i])) // poszukiwanie przęsła - { - nEnds[i] = NULL; - zg = 1; // jak coś zostało podłączone, to może zasilanie gdzieś dodatkowo - // dotrze - } - } - else if (nEnds[i]->hvTraction->hvNext[1]) - { // jeśli końcowy ma ciąg dalszy od strony 1 (Point2), szukamy odcinka najbliższego - // do Point1 - if (TractionNearestFind(nEnds[i]->hvTraction->pPoint1, 1, - nEnds[i])) // poszukiwanie przęsła - { - nEnds[i] = NULL; - zg = 1; // jak coś zostało podłączone, to może zasilanie gdzieś dodatkowo - // dotrze - } - } - else - { // gdy koniec jest samotny, to na razie nie zostanie podłączony (nie powinno - // takich być) - nEnds[i] = NULL; - } - } - } - delete[] nEnds; // nie potrzebne już -}; - -void TGround::TrackJoin(TGroundNode *Current) -{ // wyszukiwanie sąsiednich torów do podłączenia (wydzielone na użytek obrotnicy) - TTrack *Track = Current->pTrack; - TTrack *tmp; - int iConnection; - if (!Track->CurrentPrev()) - { - tmp = FindTrack(Track->CurrentSegment()->FastGetPoint_0(), iConnection, - Current); // Current do pominięcia - switch (iConnection) - { - case 0: - Track->ConnectPrevPrev(tmp, 0); - break; - case 1: - Track->ConnectPrevNext(tmp, 1); - break; - } - } - if (!Track->CurrentNext()) - { - tmp = FindTrack(Track->CurrentSegment()->FastGetPoint_1(), iConnection, Current); - switch (iConnection) - { - case 0: - Track->ConnectNextPrev(tmp, 0); - break; - case 1: - Track->ConnectNextNext(tmp, 1); - break; - } - } -} - -// McZapkie-070602: wyzwalacze zdarzen -bool TGround::InitLaunchers() -{ - TGroundNode *Current, *tmp; - TEventLauncher *EventLauncher; - int i; - for (Current = nRootOfType[TP_EVLAUNCH]; Current; Current = Current->nNext) - { - EventLauncher = Current->EvLaunch; - if (EventLauncher->iCheckMask != 0) - if (EventLauncher->asMemCellName != "none") - { // jeśli jest powiązana komórka pamięci - tmp = FindGroundNode(EventLauncher->asMemCellName, TP_MEMCELL); - if (tmp) - EventLauncher->MemCell = tmp->MemCell; // jeśli znaleziona, dopisać - else - MessageBox(0, "Cannot find Memory Cell for Event Launcher", "Error", MB_OK); - } - else - EventLauncher->MemCell = NULL; - EventLauncher->Event1 = (EventLauncher->asEvent1Name != "none") ? - FindEvent(EventLauncher->asEvent1Name) : - NULL; - EventLauncher->Event2 = (EventLauncher->asEvent2Name != "none") ? - FindEvent(EventLauncher->asEvent2Name) : - NULL; - } - return true; -} - -TTrack * TGround::FindTrack(vector3 Point, int &iConnection, TGroundNode *Exclude) -{ // wyszukiwanie innego toru kończącego się w (Point) - TTrack *Track; - TGroundNode *Current; - TTrack *tmp; - iConnection = -1; - TSubRect *sr; - // najpierw szukamy w okolicznych segmentach - int c = GetColFromX(Point.x); - int r = GetRowFromZ(Point.z); - if ((sr = FastGetSubRect(c, r)) != NULL) // 75% torów jest w tym samym sektorze - if ((tmp = sr->FindTrack(&Point, iConnection, Exclude->pTrack)) != NULL) - return tmp; - int i, x, y; - for (i = 1; i < 9; - ++i) // sektory w kolejności odległości, 4 jest tu wystarczające, 9 na wszelki wypadek - { // niemal wszystkie podłączone tory znajdują się w sąsiednich 8 sektorach - x = SectorOrder[i].x; - y = SectorOrder[i].y; - if ((sr = FastGetSubRect(c + y, r + x)) != NULL) - if ((tmp = sr->FindTrack(&Point, iConnection, Exclude->pTrack)) != NULL) - return tmp; - if (x) - if ((sr = FastGetSubRect(c + y, r - x)) != NULL) - if ((tmp = sr->FindTrack(&Point, iConnection, Exclude->pTrack)) != NULL) - return tmp; - if (y) - if ((sr = FastGetSubRect(c - y, r + x)) != NULL) - if ((tmp = sr->FindTrack(&Point, iConnection, Exclude->pTrack)) != NULL) - return tmp; - if ((sr = FastGetSubRect(c - y, r - x)) != NULL) - if ((tmp = sr->FindTrack(&Point, iConnection, Exclude->pTrack)) != NULL) - return tmp; - } -#if 0 - //wyszukiwanie czołgowe (po wszystkich jak leci) - nie ma chyba sensu - for (Current=nRootOfType[TP_TRACK];Current;Current=Current->Next) - { - if ((Current->iType==TP_TRACK) && (Current!=Exclude)) - { - iConnection=Current->pTrack->TestPoint(&Point); - if (iConnection>=0) return Current->pTrack; - } - } -#endif - return NULL; -} - -TTraction * TGround::FindTraction(vector3 *Point, int &iConnection, TGroundNode *Exclude) -{ // wyszukiwanie innego przęsła kończącego się w (Point) - TTraction *Traction; - TGroundNode *Current; - TTraction *tmp; - iConnection = -1; - TSubRect *sr; - // najpierw szukamy w okolicznych segmentach - int c = GetColFromX(Point->x); - int r = GetRowFromZ(Point->z); - if ((sr = FastGetSubRect(c, r)) != NULL) // większość będzie w tym samym sektorze - if ((tmp = sr->FindTraction(Point, iConnection, Exclude->hvTraction)) != NULL) - return tmp; - int i, x, y; - for (i = 1; i < 9; - ++i) // sektory w kolejności odległości, 4 jest tu wystarczające, 9 na wszelki wypadek - { // wszystkie przęsła powinny zostać znajdować się w sąsiednich 8 sektorach - x = SectorOrder[i].x; - y = SectorOrder[i].y; - if ((sr = FastGetSubRect(c + y, r + x)) != NULL) - if ((tmp = sr->FindTraction(Point, iConnection, Exclude->hvTraction)) != NULL) - return tmp; - if (x & y) - { - if ((sr = FastGetSubRect(c + y, r - x)) != NULL) - if ((tmp = sr->FindTraction(Point, iConnection, Exclude->hvTraction)) != NULL) - return tmp; - if ((sr = FastGetSubRect(c - y, r + x)) != NULL) - if ((tmp = sr->FindTraction(Point, iConnection, Exclude->hvTraction)) != NULL) - return tmp; - } - if ((sr = FastGetSubRect(c - y, r - x)) != NULL) - if ((tmp = sr->FindTraction(Point, iConnection, Exclude->hvTraction)) != NULL) - return tmp; - } - return NULL; -}; - -TTraction * TGround::TractionNearestFind(vector3 &p, int dir, TGroundNode *n) -{ // wyszukanie najbliższego do (p) przęsła o tej samej nazwie sekcji (ale innego niż podłączone) - // oraz zasilanego z kierunku (dir) - TGroundNode *nCurrent, *nBest = NULL; - int i, j, k, zg; - double d, dist = 200.0 * 200.0; //[m] odległość graniczna - // najpierw szukamy w okolicznych segmentach - int c = GetColFromX(n->pCenter.x); - int r = GetRowFromZ(n->pCenter.z); - TSubRect *sr; - for (i = -1; i <= 1; ++i) // przeglądamy 9 najbliższych sektorów - for (j = -1; j <= 1; ++j) // - if ((sr = FastGetSubRect(c + i, r + j)) != NULL) // o ile w ogóle sektor jest - for (nCurrent = sr->nRenderWires; nCurrent; nCurrent = nCurrent->nNext3) - if (nCurrent->iType == TP_TRACTION) - if (nCurrent->hvTraction->psSection == - n->hvTraction->psSection) // jeśli ta sama sekcja - if (nCurrent != n) // ale nie jest tym samym - if (nCurrent->hvTraction != - n->hvTraction - ->hvNext[0]) // ale nie jest bezpośrednio podłączonym - if (nCurrent->hvTraction != n->hvTraction->hvNext[1]) - if (nCurrent->hvTraction->psPower - [k = (DotProduct( - n->hvTraction->vParametric, - nCurrent->hvTraction->vParametric) >= 0 ? - dir ^ 1 : - dir)]) // ma zasilanie z odpowiedniej - // strony - if (nCurrent->hvTraction->fResistance[k] >= - 0.0) //żeby się nie propagowały jakieś ujemne - { // znaleziony kandydat do połączenia - d = SquareMagnitude( - p - - nCurrent - ->pCenter); // kwadrat odległości środków - if (dist > d) - { // zapamiętanie nowego najbliższego - dist = d; // nowy rekord odległości - nBest = nCurrent; - zg = k; // z którego końca brać wskaźnik - // zasilacza - } - } - if (nBest) // jak znalezione przęsło z zasilaniem, to podłączenie "równoległe" - { - n->hvTraction->ResistanceCalc(dir, nBest->hvTraction->fResistance[zg], - nBest->hvTraction->psPower[zg]); - // testowo skrzywienie przęsła tak, aby pokazać skąd ma zasilanie - // if (dir) //1 gdy ciąg dalszy jest od strony Point2 - // n->hvTraction->pPoint3=0.25*(nBest->pCenter+3*(zg?nBest->hvTraction->pPoint4:nBest->hvTraction->pPoint3)); - // else - // n->hvTraction->pPoint4=0.25*(nBest->pCenter+3*(zg?nBest->hvTraction->pPoint4:nBest->hvTraction->pPoint3)); - } - return (nBest ? nBest->hvTraction : NULL); -}; - -bool TGround::AddToQuery(TEvent *Event, TDynamicObject *Node) -{ - if (Event->bEnabled) // jeśli może być dodany do kolejki (nie używany w skanowaniu) - if (!Event->iQueued) // jeśli nie dodany jeszcze do kolejki - { // kolejka eventów jest posortowana względem (fStartTime) - Event->Activator = Node; - if (Event->Type == tp_AddValues ? (Event->fDelay == 0.0) : false) - { // eventy AddValues trzeba wykonywać natychmiastowo, inaczej kolejka może zgubić - // jakieś dodawanie - // Ra: kopiowanie wykonania tu jest bez sensu, lepiej by było wydzielić funkcję - // wykonującą eventy i ją wywołać - if (EventConditon(Event)) - { // teraz mogą być warunki do tych eventów - Event->Params[5].asMemCell->UpdateValues( - Event->Params[0].asText, Event->Params[1].asdouble, - Event->Params[2].asdouble, Event->iFlags); - if (Event->Params[6].asTrack) - { // McZapkie-100302 - updatevalues oprocz zmiany wartosci robi putcommand dla - // wszystkich 'dynamic' na danym torze -#ifdef EU07_USE_OLD_TTRACK_DYNAMICS_ARRAY - for (int i = 0; i < Event->Params[6].asTrack->iNumDynamics; ++i) - Event->Params[5].asMemCell->PutCommand( - Event->Params[6].asTrack->Dynamics[i]->Mechanik, - &Event->Params[4].nGroundNode->pCenter); -#else - for( auto dynamic : Event->Params[ 6 ].asTrack->Dynamics ) { - Event->Params[ 5 ].asMemCell->PutCommand( - dynamic->Mechanik, - &Event->Params[ 4 ].nGroundNode->pCenter ); - } -#endif - //if (DebugModeFlag) - WriteLog("EVENT EXECUTED: AddValues & Track command - " + - std::string(Event->Params[0].asText) + " " + - std::to_string(Event->Params[1].asdouble) + " " + - std::to_string(Event->Params[2].asdouble)); - } - //else if (DebugModeFlag) - WriteLog("EVENT EXECUTED: AddValues - " + - std::string(Event->Params[0].asText) + " " + - std::to_string(Event->Params[1].asdouble) + " " + - std::to_string(Event->Params[2].asdouble)); - } - Event = - Event - ->evJoined; // jeśli jest kolejny o takiej samej nazwie, to idzie do kolejki - } - if (Event) - { // standardowe dodanie do kolejki - WriteLog("EVENT ADDED TO QUEUE: " + Event->asName + - (Node ? (" by " + Node->asName) : string(""))); - Event->fStartTime = - fabs(Event->fDelay) + Timer::GetTime(); // czas od uruchomienia scenerii - if (Event->fRandomDelay > 0.0) - Event->fStartTime += Event->fRandomDelay * Random(10000) * - 0.0001; // doliczenie losowego czasu opóźnienia - ++Event->iQueued; // zabezpieczenie przed podwójnym dodaniem do kolejki - if (QueryRootEvent ? Event->fStartTime >= QueryRootEvent->fStartTime : false) - QueryRootEvent->AddToQuery(Event); // dodanie gdzieś w środku - else - { // dodanie z przodu: albo nic nie ma, albo ma być wykonany szybciej niż pierwszy - Event->evNext = QueryRootEvent; - QueryRootEvent = Event; - } - } - } - return true; -} - -bool TGround::EventConditon(TEvent *e) -{ // sprawdzenie spelnienia warunków dla eventu - if (e->iFlags <= update_only) - return true; // bezwarunkowo - if (e->iFlags & conditional_trackoccupied) - return (!e->Params[9].asTrack->IsEmpty()); - else if (e->iFlags & conditional_trackfree) - return (e->Params[9].asTrack->IsEmpty()); - else if (e->iFlags & conditional_propability) - { - double rprobability = 1.0 * rand() / RAND_MAX; - WriteLog("Random integer: " + std::to_string(rprobability) + "/" + - std::to_string(e->Params[10].asdouble)); - return (e->Params[10].asdouble > rprobability); - } - else if (e->iFlags & conditional_memcompare) - { // porównanie wartości - if (tmpEvent->Params[9].asMemCell->Compare(e->Params[10].asText, e->Params[11].asdouble, - e->Params[12].asdouble, e->iFlags)) - { //logowanie spełnionych warunków - LogComment = e->Params[9].asMemCell->Text() + string(" ") + - to_string(e->Params[9].asMemCell->Value1(), 2, 8) + " " + - to_string(tmpEvent->Params[9].asMemCell->Value2(), 2, 8) + - " = "; - if (TestFlag(e->iFlags, conditional_memstring)) - LogComment += string(tmpEvent->Params[10].asText); - else - LogComment += "*"; - if (TestFlag(tmpEvent->iFlags, conditional_memval1)) - LogComment += " " + to_string(tmpEvent->Params[11].asdouble, 2, 8); - else - LogComment += " *"; - if (TestFlag(tmpEvent->iFlags, conditional_memval2)) - LogComment += " " + to_string(tmpEvent->Params[12].asdouble, 2, 8); - else - LogComment += " *"; - WriteLog(LogComment); - return true; - } - //else if (Global::iWriteLogEnabled && DebugModeFlag) //zawsze bo to bardzo istotne w debugowaniu scenariuszy - else - { // nie zgadza się, więc sprawdzmy, co - LogComment = e->Params[9].asMemCell->Text() + string(" ") + - to_string(e->Params[9].asMemCell->Value1(), 2, 8) + " " + - to_string(tmpEvent->Params[9].asMemCell->Value2(), 2, 8) + - " != "; - if (TestFlag(e->iFlags, conditional_memstring)) - LogComment += (tmpEvent->Params[10].asText); - else - LogComment += "*"; - if (TestFlag(tmpEvent->iFlags, conditional_memval1)) - LogComment += " " + to_string(tmpEvent->Params[11].asdouble, 2, 8); - else - LogComment += " *"; - if (TestFlag(tmpEvent->iFlags, conditional_memval2)) - LogComment += " " + to_string(tmpEvent->Params[12].asdouble, 2, 8); - else - LogComment += " *"; - WriteLog(LogComment); - } - } - return false; -}; - -bool TGround::CheckQuery() -{ // sprawdzenie kolejki eventów oraz wykonanie tych, którym czas minął - TLocation loc; - int i; - /* //Ra: to w ogóle jakiś chory kod jest; wygląda jak wyszukanie eventu z najlepszym czasem - Double evtime,evlowesttime; //Ra: co to za typ? - //evlowesttime=1000000; - if (QueryRootEvent) - { - OldQRE=QueryRootEvent; - tmpEvent=QueryRootEvent; - } - if (QueryRootEvent) - { - for (i=0;i<90;++i) - { - evtime=((tmpEvent->fStartTime)-(Timer::GetTime())); //pobranie wartości zmiennej - if (evtimeNext) - tmpEvent=tmpEvent->Next; - else - i=100; - } - if (OldQRE!=tmp2Event) - { - QueryRootEvent->AddToQuery(QueryRootEvent); - QueryRootEvent=tmp2Event; - } - } - */ - /* - if (QueryRootEvent) - {//wypisanie kolejki - tmpEvent=QueryRootEvent; - WriteLog("--> Event queue:"); - while (tmpEvent) - { - WriteLog(tmpEvent->asName+" "+AnsiString(tmpEvent->fStartTime)); - tmpEvent=tmpEvent->Next; - } - } - */ - while (QueryRootEvent ? QueryRootEvent->fStartTime < Timer::GetTime() : false) - { // eventy są posortowana wg czasu wykonania - tmpEvent = QueryRootEvent; // wyjęcie eventu z kolejki - if (QueryRootEvent->evJoined) // jeśli jest kolejny o takiej samej nazwie - { // to teraz on będzie następny do wykonania - QueryRootEvent = QueryRootEvent->evJoined; // następny będzie ten doczepiony - QueryRootEvent->evNext = tmpEvent->evNext; // pamiętając o następnym z kolejki - QueryRootEvent->fStartTime = - tmpEvent->fStartTime; // czas musi być ten sam, bo nie jest aktualizowany - QueryRootEvent->Activator = tmpEvent->Activator; // pojazd aktywujący - // w sumie można by go dodać normalnie do kolejki, ale trzeba te połączone posortować wg - // czasu wykonania - } - else // a jak nazwa jest unikalna, to kolejka idzie dalej - QueryRootEvent = QueryRootEvent->evNext; // NULL w skrajnym przypadku - if (tmpEvent->bEnabled) - { // w zasadzie te wyłączone są skanowane i nie powinny się nigdy w kolejce znaleźć - WriteLog("EVENT LAUNCHED: " + tmpEvent->asName + - (tmpEvent->Activator ? string(" by " + tmpEvent->Activator->asName) : - string(""))); - switch (tmpEvent->Type) - { - case tp_CopyValues: // skopiowanie wartości z innej komórki - tmpEvent->Params[5].asMemCell->UpdateValues( - tmpEvent->Params[9].asMemCell->Text(), - tmpEvent->Params[9].asMemCell->Value1(), - tmpEvent->Params[9].asMemCell->Value2(), - tmpEvent->iFlags // flagi określają, co ma być skopiowane - ); - // break; //żeby się wysłało do torów i nie było potrzeby na AddValues * 0 0 - case tp_AddValues: // różni się jedną flagą od UpdateValues - case tp_UpdateValues: - if (EventConditon(tmpEvent)) - { // teraz mogą być warunki do tych eventów - if (tmpEvent->Type != tp_CopyValues) // dla CopyValues zrobiło się wcześniej - tmpEvent->Params[5].asMemCell->UpdateValues( - tmpEvent->Params[0].asText, - tmpEvent->Params[1].asdouble, - tmpEvent->Params[2].asdouble, - tmpEvent->iFlags); - if (tmpEvent->Params[6].asTrack) - { // McZapkie-100302 - updatevalues oprocz zmiany wartosci robi putcommand dla - // wszystkich 'dynamic' na danym torze -#ifdef EU07_USE_OLD_TTRACK_DYNAMICS_ARRAY - for (int i = 0; i < tmpEvent->Params[6].asTrack->iNumDynamics; ++i) - tmpEvent->Params[5].asMemCell->PutCommand( - tmpEvent->Params[6].asTrack->Dynamics[i]->Mechanik, - &tmpEvent->Params[4].nGroundNode->pCenter); -#else - for( auto dynamic : tmpEvent->Params[ 6 ].asTrack->Dynamics ) { - tmpEvent->Params[ 5 ].asMemCell->PutCommand( - dynamic->Mechanik, - &tmpEvent->Params[ 4 ].nGroundNode->pCenter ); - } -#endif - //if (DebugModeFlag) - WriteLog("Type: UpdateValues & Track command - " + - tmpEvent->Params[5].asMemCell->Text() + " " + - std::to_string( tmpEvent->Params[ 5 ].asMemCell->Value1() ) + " " + - std::to_string( tmpEvent->Params[ 5 ].asMemCell->Value2() ) ); - } - else //if (DebugModeFlag) - WriteLog("Type: UpdateValues - " + - tmpEvent->Params[5].asMemCell->Text() + " " + - std::to_string( tmpEvent->Params[ 5 ].asMemCell->Value1() ) + " " + - std::to_string( tmpEvent->Params[ 5 ].asMemCell->Value2() ) ); - } - break; - case tp_GetValues: - if (tmpEvent->Activator) - { - // loc.X= -tmpEvent->Params[8].nGroundNode->pCenter.x; - // loc.Y= tmpEvent->Params[8].nGroundNode->pCenter.z; - // loc.Z= tmpEvent->Params[8].nGroundNode->pCenter.y; - if (Global::iMultiplayer) // potwierdzenie wykonania dla serwera (odczyt - // semafora już tak nie działa) - WyslijEvent(tmpEvent->asName, tmpEvent->Activator->GetName()); - // tmpEvent->Params[9].asMemCell->PutCommand(tmpEvent->Activator->Mechanik,loc); - tmpEvent->Params[9].asMemCell->PutCommand( - tmpEvent->Activator->Mechanik, &tmpEvent->Params[8].nGroundNode->pCenter); - } - WriteLog("Type: GetValues"); - break; - case tp_PutValues: - if (tmpEvent->Activator) - { - loc.X = - -tmpEvent->Params[3].asdouble; // zamiana, bo fizyka ma inaczej niż sceneria - loc.Y = tmpEvent->Params[5].asdouble; - loc.Z = tmpEvent->Params[4].asdouble; - if (tmpEvent->Activator->Mechanik) // przekazanie rozkazu do AI - tmpEvent->Activator->Mechanik->PutCommand( - tmpEvent->Params[0].asText, tmpEvent->Params[1].asdouble, - tmpEvent->Params[2].asdouble, loc); - else - { // przekazanie do pojazdu - tmpEvent->Activator->MoverParameters->PutCommand( - tmpEvent->Params[0].asText, tmpEvent->Params[1].asdouble, - tmpEvent->Params[2].asdouble, loc); - } - } - WriteLog("Type: PutValues"); - break; - case tp_Lights: - if (tmpEvent->Params[9].asModel) - for (i = 0; i < iMaxNumLights; i++) - if (tmpEvent->Params[i].asdouble >= 0) //-1 zostawia bez zmiany - tmpEvent->Params[9].asModel->LightSet( - i, tmpEvent->Params[i].asdouble); // teraz też ułamek - break; - case tp_Visible: - if (tmpEvent->Params[9].nGroundNode) - tmpEvent->Params[9].nGroundNode->bVisible = (tmpEvent->Params[i].asInt > 0); - break; - case tp_Velocity: - Error("Not implemented yet :("); - break; - case tp_Exit: - MessageBox(0, tmpEvent->asNodeName.c_str(), " THE END ", MB_OK); - Global::iTextMode = -1; // wyłączenie takie samo jak sekwencja F10 -> Y - return false; - case tp_Sound: - switch (tmpEvent->Params[0].asInt) - { // trzy możliwe przypadki: - case 0: - tmpEvent->Params[9].tsTextSound->Stop(); - break; - case 1: - tmpEvent->Params[9].tsTextSound->Play( - 1, 0, true, tmpEvent->Params[9].tsTextSound->vSoundPosition); - break; - case -1: - tmpEvent->Params[9].tsTextSound->Play( - 1, DSBPLAY_LOOPING, true, tmpEvent->Params[9].tsTextSound->vSoundPosition); - break; - } - break; - case tp_Disable: - Error("Not implemented yet :("); - break; - case tp_Animation: // Marcin: dorobic translacje - Ra: dorobiłem ;-) - if (tmpEvent->Params[0].asInt == 1) - tmpEvent->Params[9].asAnimContainer->SetRotateAnim( - vector3(tmpEvent->Params[1].asdouble, tmpEvent->Params[2].asdouble, - tmpEvent->Params[3].asdouble), - tmpEvent->Params[4].asdouble); - else if (tmpEvent->Params[0].asInt == 2) - tmpEvent->Params[9].asAnimContainer->SetTranslateAnim( - vector3(tmpEvent->Params[1].asdouble, tmpEvent->Params[2].asdouble, - tmpEvent->Params[3].asdouble), - tmpEvent->Params[4].asdouble); - else if (tmpEvent->Params[0].asInt == 4) - tmpEvent->Params[9].asModel->AnimationVND( - tmpEvent->Params[8].asPointer, - tmpEvent->Params[1].asdouble, // tu mogą być dodatkowe parametry, np. od-do - tmpEvent->Params[2].asdouble, tmpEvent->Params[3].asdouble, - tmpEvent->Params[4].asdouble); - break; - case tp_Switch: - if (tmpEvent->Params[9].asTrack) - tmpEvent->Params[9].asTrack->Switch(tmpEvent->Params[0].asInt, - tmpEvent->Params[1].asdouble, - tmpEvent->Params[2].asdouble); - if (Global::iMultiplayer) // dajemy znać do serwera o przełożeniu - WyslijEvent(tmpEvent->asName, ""); // wysłanie nazwy eventu przełączajacego - // Ra: bardziej by się przydała nazwa toru, ale nie ma do niej stąd dostępu - break; - case tp_TrackVel: - if (tmpEvent->Params[9].asTrack) - { // prędkość na zwrotnicy może być ograniczona z góry we wpisie, większej się nie - // ustawi eventem - WriteLog("type: TrackVel"); - // WriteLog("Vel: ",tmpEvent->Params[0].asdouble); - tmpEvent->Params[9].asTrack->VelocitySet(tmpEvent->Params[0].asdouble); - if (DebugModeFlag) // wyświetlana jest ta faktycznie ustawiona - WriteLog("vel: ", tmpEvent->Params[9].asTrack->VelocityGet()); - } - break; - case tp_DynVel: - Error("Event \"DynVel\" is obsolete"); - break; - case tp_Multiple: - { - bCondition = EventConditon(tmpEvent); - if (bCondition || (tmpEvent->iFlags & - conditional_anyelse)) // warunek spelniony albo było użyte else - { - WriteLog("Multiple passed"); - for (i = 0; i < 8; ++i) - { // dodawane do kolejki w kolejności zapisania - if (tmpEvent->Params[i].asEvent) - if (bCondition != bool(tmpEvent->iFlags & (conditional_else << i))) - { - if (tmpEvent->Params[i].asEvent != tmpEvent) - AddToQuery(tmpEvent->Params[i].asEvent, - tmpEvent->Activator); // normalnie dodać - else // jeśli ma być rekurencja - if (tmpEvent->fDelay >= - 5.0) // to musi mieć sensowny okres powtarzania - if (tmpEvent->iQueued < 2) - { // trzeba zrobić wyjątek, aby event mógł się sam dodać do - // kolejki, raz już jest, ale będzie usunięty - // pętla eventowa może być uruchomiona wiele razy, ale tylko - // pierwsze uruchomienie zadziała - tmpEvent->iQueued = - 0; // tymczasowo, aby był ponownie dodany do kolejki - AddToQuery(tmpEvent, tmpEvent->Activator); - tmpEvent->iQueued = - 2; // kolejny raz już absolutnie nie dodawać - } - } - } - if (Global::iMultiplayer) // dajemy znać do serwera o wykonaniu - if ((tmpEvent->iFlags & conditional_anyelse) == - 0) // jednoznaczne tylko, gdy nie było else - { - if (tmpEvent->Activator) - WyslijEvent(tmpEvent->asName, tmpEvent->Activator->GetName()); - else - WyslijEvent(tmpEvent->asName, ""); - } - } - } - break; - case tp_WhoIs: // pobranie nazwy pociągu do komórki pamięci - if (tmpEvent->iFlags & update_load) - { // jeśli pytanie o ładunek - if (tmpEvent->iFlags & update_memadd) // jeśli typ pojazdu -#ifdef EU07_USE_OLD_TMEMCELL_TEXT_ARRAY - tmpEvent->Params[ 9 ].asMemCell->UpdateValues( - strdup(tmpEvent->Activator->MoverParameters->TypeName.c_str()), // typ pojazdu - 0, // na razie nic - 0, // na razie nic - tmpEvent->iFlags & - (update_memstring | update_memval1 | update_memval2)); -#else - tmpEvent->Params[ 9 ].asMemCell->UpdateValues( - tmpEvent->Activator->MoverParameters->TypeName, // typ pojazdu - 0, // na razie nic - 0, // na razie nic - tmpEvent->iFlags & - (update_memstring | update_memval1 | update_memval2)); -#endif - else // jeśli parametry ładunku -#ifdef EU07_USE_OLD_TMEMCELL_TEXT_ARRAY - tmpEvent->Params[ 9 ].asMemCell->UpdateValues( - tmpEvent->Activator->MoverParameters->LoadType != "" ? - strdup(tmpEvent->Activator->MoverParameters->LoadType.c_str()) : - (char*)"none", // nazwa ładunku - tmpEvent->Activator->MoverParameters->Load, // aktualna ilość - tmpEvent->Activator->MoverParameters->MaxLoad, // maksymalna ilość - tmpEvent->iFlags & - (update_memstring | update_memval1 | update_memval2)); -#else - tmpEvent->Params[ 9 ].asMemCell->UpdateValues( - tmpEvent->Activator->MoverParameters->LoadType, // nazwa ładunku - tmpEvent->Activator->MoverParameters->Load, // aktualna ilość - tmpEvent->Activator->MoverParameters->MaxLoad, // maksymalna ilość - tmpEvent->iFlags & - (update_memstring | update_memval1 | update_memval2)); -#endif - } - else if (tmpEvent->iFlags & update_memadd) - { // jeśli miejsce docelowe pojazdu -#ifdef EU07_USE_OLD_TMEMCELL_TEXT_ARRAY - tmpEvent->Params[ 9 ].asMemCell->UpdateValues( - strdup(tmpEvent->Activator->asDestination.c_str()), // adres docelowy - tmpEvent->Activator->DirectionGet(), // kierunek pojazdu względem czoła - // składu (1=zgodny,-1=przeciwny) - tmpEvent->Activator->MoverParameters - ->Power, // moc pojazdu silnikowego: 0 dla wagonu - tmpEvent->iFlags & (update_memstring | update_memval1 | update_memval2)); -#else - tmpEvent->Params[ 9 ].asMemCell->UpdateValues( - tmpEvent->Activator->asDestination, // adres docelowy - tmpEvent->Activator->DirectionGet(), // kierunek pojazdu względem czoła składu (1=zgodny,-1=przeciwny) - tmpEvent->Activator->MoverParameters ->Power, // moc pojazdu silnikowego: 0 dla wagonu - tmpEvent->iFlags & (update_memstring | update_memval1 | update_memval2)); -#endif - } - else if (tmpEvent->Activator->Mechanik) - if (tmpEvent->Activator->Mechanik->Primary()) - { // tylko jeśli ktoś tam siedzi - nie powinno dotyczyć pasażera! -#ifdef EU07_USE_OLD_TMEMCELL_TEXT_ARRAY - tmpEvent->Params[ 9 ].asMemCell->UpdateValues( - const_cast(tmpEvent->Activator->Mechanik->TrainName().c_str()), - tmpEvent->Activator->Mechanik->StationCount() - - tmpEvent->Activator->Mechanik - ->StationIndex(), // ile przystanków do końca - tmpEvent->Activator->Mechanik->IsStop() ? 1 : - 0, // 1, gdy ma tu zatrzymanie - tmpEvent->iFlags); -#else - tmpEvent->Params[ 9 ].asMemCell->UpdateValues( - tmpEvent->Activator->Mechanik->TrainName(), - tmpEvent->Activator->Mechanik->StationCount() - - tmpEvent->Activator->Mechanik - ->StationIndex(), // ile przystanków do końca - tmpEvent->Activator->Mechanik->IsStop() ? 1 : - 0, // 1, gdy ma tu zatrzymanie - tmpEvent->iFlags); -#endif - WriteLog("Train detected: " + tmpEvent->Activator->Mechanik->TrainName()); - } - break; - case tp_LogValues: // zapisanie zawartości komórki pamięci do logu - if (tmpEvent->Params[9].asMemCell) // jeśli była podana nazwa komórki - WriteLog("Memcell \"" + tmpEvent->asNodeName + "\": " + - tmpEvent->Params[9].asMemCell->Text() + " " + - std::to_string(tmpEvent->Params[9].asMemCell->Value1()) + " " + - std::to_string(tmpEvent->Params[9].asMemCell->Value2())); - else // lista wszystkich - for (TGroundNode *Current = nRootOfType[TP_MEMCELL]; Current; - Current = Current->nNext) - WriteLog("Memcell \"" + Current->asName + "\": " + - Current->MemCell->Text() + " " + std::to_string(Current->MemCell->Value1()) + " " + - std::to_string(Current->MemCell->Value2())); - break; - case tp_Voltage: // zmiana napięcia w zasilaczu (TractionPowerSource) - if (tmpEvent->Params[9].psPower) - { // na razie takie chamskie ustawienie napięcia zasilania - WriteLog("type: Voltage"); - tmpEvent->Params[9].psPower->VoltageSet(tmpEvent->Params[0].asdouble); - } - case tp_Friction: // zmiana tarcia na scenerii - { // na razie takie chamskie ustawienie napięcia zasilania - WriteLog("type: Friction"); - Global::fFriction = (tmpEvent->Params[0].asdouble); - } - break; - case tp_Message: // wyświetlenie komunikatu - break; - } // switch (tmpEvent->Type) - } // if (tmpEvent->bEnabled) - --tmpEvent->iQueued; // teraz moze być ponownie dodany do kolejki - /* - if (QueryRootEvent->eJoined) //jeśli jest kolejny o takiej samej nazwie - {//to teraz jego dajemy do wykonania - QueryRootEvent->eJoined->Next=QueryRootEvent->Next; //pamiętając o następnym z kolejki - QueryRootEvent->eJoined->fStartTime=QueryRootEvent->fStartTime; //czas musi być ten sam, - bo nie jest aktualizowany - //QueryRootEvent->fStartTime=0; - QueryRootEvent=QueryRootEvent->eJoined; //a wykonać ten doczepiony - } - else - {//a jak nazwa jest unikalna, to kolejka idzie dalej - //QueryRootEvent->fStartTime=0; - QueryRootEvent=QueryRootEvent->Next; //NULL w skrajnym przypadku - } - */ - } // while - return true; -} - -void TGround::OpenGLUpdate(HDC hDC) -{ - SwapBuffers(hDC); // swap buffers (double buffering) -}; - -void TGround::UpdatePhys(double dt, int iter) -{ // aktualizacja fizyki stałym krokiem: dt=krok czasu [s], dt*iter=czas od ostatnich przeliczeń - for (TGroundNode *Current = nRootOfType[TP_TRACTIONPOWERSOURCE]; Current; - Current = Current->nNext) - Current->psTractionPowerSource->Update(dt * iter); // zerowanie sumy prądów -}; - -bool TGround::Update(double dt, int iter) -{ // aktualizacja animacji krokiem FPS: dt=krok czasu [s], dt*iter=czas od ostatnich przeliczeń - if (dt == 0.0) - { // jeśli załączona jest pauza, to tylko obsłużyć ruch w kabinie trzeba - return true; - } - // Ra: w zasadzie to trzeba by utworzyć oddzielną listę taboru do liczenia fizyki - // na którą by się zapisywały wszystkie pojazdy będące w ruchu - // pojazdy stojące nie potrzebują aktualizacji, chyba że np. ktoś im zmieni nastawę hamulca - // oddzielną listę można by zrobić na pojazdy z napędem, najlepiej posortowaną wg typu napędu - if (iter > 1) // ABu: ponizsze wykonujemy tylko jesli wiecej niz jedna iteracja - { // pierwsza iteracja i wyznaczenie stalych: - for (TGroundNode *Current = nRootDynamic; Current; Current = Current->nNext) - { // - Current->DynamicObject->MoverParameters->ComputeConstans(); - Current->DynamicObject->CoupleDist(); - Current->DynamicObject->UpdateForce(dt, dt, false); - } - for (TGroundNode *Current = nRootDynamic; Current; Current = Current->nNext) - Current->DynamicObject->FastUpdate(dt); - // pozostale iteracje - for (int i = 1; i < (iter - 1); ++i) // jeśli iter==5, to wykona się 3 razy - { - for (TGroundNode *Current = nRootDynamic; Current; Current = Current->nNext) - Current->DynamicObject->UpdateForce(dt, dt, false); - for (TGroundNode *Current = nRootDynamic; Current; Current = Current->nNext) - Current->DynamicObject->FastUpdate(dt); - } - // ABu 200205: a to robimy tylko raz, bo nie potrzeba więcej - // Winger 180204 - pantografy - double dt1 = dt * iter; // całkowity czas - UpdatePhys(dt1, 1); - TAnimModel::AnimUpdate(dt1); // wykonanie zakolejkowanych animacji - for (TGroundNode *Current = nRootDynamic; Current; Current = Current->nNext) - { // Ra: zmienić warunek na sprawdzanie pantografów w jednej zmiennej: czy pantografy i czy - // podniesione - if (Current->DynamicObject->MoverParameters->EnginePowerSource.SourceType == - CurrentCollector) - GetTraction(Current->DynamicObject); // poszukiwanie drutu dla pantografów - Current->DynamicObject->UpdateForce(dt, dt1, true); //,true); - } - for (TGroundNode *Current = nRootDynamic; Current; Current = Current->nNext) - Current->DynamicObject->Update(dt, dt1); // Ra 2015-01: tylko tu przelicza sieć - // trakcyjną - } - else - { // jezeli jest tylko jedna iteracja - UpdatePhys(dt, 1); - TAnimModel::AnimUpdate(dt); // wykonanie zakolejkowanych animacji - for (TGroundNode *Current = nRootDynamic; Current; Current = Current->nNext) - { - if (Current->DynamicObject->MoverParameters->EnginePowerSource.SourceType == - CurrentCollector) - GetTraction(Current->DynamicObject); - Current->DynamicObject->MoverParameters->ComputeConstans(); - Current->DynamicObject->CoupleDist(); - Current->DynamicObject->UpdateForce(dt, dt, true); //,true); - } - for (TGroundNode *Current = nRootDynamic; Current; Current = Current->nNext) - Current->DynamicObject->Update(dt, dt); // Ra 2015-01: tylko tu przelicza sieć trakcyjną - } - if (bDynamicRemove) - { // jeśli jest coś do usunięcia z listy, to trzeba na końcu - for (TGroundNode *Current = nRootDynamic; Current; Current = Current->nNext) - if (!Current->DynamicObject->bEnabled) - { - DynamicRemove(Current->DynamicObject); // usunięcie tego i podłączonych - Current = nRootDynamic; // sprawdzanie listy od początku - } - bDynamicRemove = false; // na razie koniec - } - return true; -}; - -// Winger 170204 - szukanie trakcji nad pantografami -bool TGround::GetTraction(TDynamicObject *model) -{ // aktualizacja drutu zasilającego dla każdego pantografu, żeby odczytać napięcie - // jeśli pojazd się nie porusza, to nie ma sensu przeliczać tego więcej niż raz - double fRaParam; // parametr równania parametrycznego odcinka drutu - double fVertical; // odległość w pionie; musi być w zasięgu ruchu "pionowego" pantografu - double fHorizontal; // odległość w bok; powinna być mniejsza niż pół szerokości pantografu - vector3 vLeft, vUp, vFront, dwys; - vector3 pant0; - vector3 vParam; // współczynniki równania parametrycznego drutu - vector3 vStyk; // punkt przebicia drutu przez płaszczyznę ruchu pantografu - vector3 vGdzie; // wektor położenia drutu względem pojazdu - vFront = model->VectorFront(); // wektor normalny dla płaszczyzny ruchu pantografu - vUp = model->VectorUp(); // wektor pionu pudła (pochylony od pionu na przechyłce) - vLeft = model->VectorLeft(); // wektor odległości w bok (odchylony od poziomu na przechyłce) - dwys = model->GetPosition(); // współrzędne środka pojazdu - TAnimPant *p; // wskaźnik do obiektu danych pantografu - for (int k = 0; k < model->iAnimType[ANIM_PANTS]; ++k) - { // pętla po pantografach - p = model->pants[k].fParamPants; - if (k ? model->MoverParameters->PantRearUp : model->MoverParameters->PantFrontUp) - { // jeśli pantograf podniesiony - pant0 = dwys + (vLeft * p->vPos.z) + (vUp * p->vPos.y) + (vFront * p->vPos.x); - if (p->hvPowerWire) - { // jeżeli znamy drut z poprzedniego przebiegu - int n = 30; //żeby się nie zapętlił - while (p->hvPowerWire) - { // powtarzane aż do znalezienia odpowiedniego odcinka na liście dwukierunkowej - // obliczamy wyraz wolny równania płaszczyzny (to miejsce nie jest odpowienie) - vParam = p->hvPowerWire->vParametric; // współczynniki równania parametrycznego - fRaParam = -DotProduct(pant0, vFront); - // podstawiamy równanie parametryczne drutu do równania płaszczyzny pantografu - // vFront.x*(t1x+t*vParam.x)+vFront.y*(t1y+t*vParam.y)+vFront.z*(t1z+t*vParam.z)+fRaDist=0; - fRaParam = -(DotProduct(p->hvPowerWire->pPoint1, vFront) + fRaParam) / - DotProduct(vParam, vFront); - if (fRaParam < - -0.001) // histereza rzędu 7cm na 70m typowego przęsła daje 1 promil - p->hvPowerWire = p->hvPowerWire->hvNext[0]; - else if (fRaParam > 1.001) - p->hvPowerWire = p->hvPowerWire->hvNext[1]; - else if (p->hvPowerWire->iLast & 3) - { // dla ostatniego i przedostatniego przęsła wymuszamy szukanie innego - p->hvPowerWire = NULL; // nie to, że nie ma, ale trzeba sprawdzić inne - // p->fHorizontal=fHorizontal; //zapamiętanie położenia drutu - break; - } - else if (p->hvPowerWire->hvParallel) - { // jeśli przęsło tworzy bieżnię wspólną, to trzeba sprawdzić pozostałe - p->hvPowerWire = NULL; // nie to, że nie ma, ale trzeba sprawdzić inne - // p->fHorizontal=fHorizontal; //zapamiętanie położenia drutu - break; // tymczasowo dla bieżni wspólnych poszukiwanie po całości - } - else - { // jeśli t jest w przedziale, wyznaczyć odległość wzdłuż wektorów vUp i vLeft - vStyk = p->hvPowerWire->pPoint1 + fRaParam * vParam; // punkt styku - // płaszczyzny z drutem - // (dla generatora łuku - // el.) - vGdzie = vStyk - pant0; // wektor - // odległość w pionie musi być w zasięgu ruchu "pionowego" pantografu - fVertical = DotProduct( - vGdzie, vUp); // musi się mieścić w przedziale ruchu pantografu - // odległość w bok powinna być mniejsza niż pół szerokości pantografu - fHorizontal = fabs(DotProduct(vGdzie, vLeft)) - - p->fWidth; // to się musi mieścić w przedziale zależnym od - // szerokości pantografu - // jeśli w pionie albo w bok jest za daleko, to dany drut jest nieużyteczny - if (fHorizontal > 0) // 0.635 dla AKP-1 AKP-4E - { // drut wyszedł poza zakres roboczy, ale jeszcze jest nabieżnik - - // pantograf się unosi bez utraty prądu - if (fHorizontal > p->fWidthExtra) // czy wyszedł za nabieżnik - { - p->hvPowerWire = NULL; // dotychczasowy drut nie liczy się - // p->fHorizontal=fHorizontal; //zapamiętanie położenia drutu - } - else - { // problem jest, gdy nowy drut jest wyżej, wtedy pantograf odłącza się - // od starego, a na podniesienie do nowego potrzebuje czasu - p->PantTraction = - fVertical + - 0.15 * fHorizontal / p->fWidthExtra; // na razie liniowo na - // nabieżniku, dokładność - // poprawi się później - // p->fHorizontal=fHorizontal; //zapamiętanie położenia drutu - } - } - else - { // po wyselekcjonowaniu drutu, przypisać go do toru, żeby nie trzeba było - // szukać - // dla 3 końcowych przęseł sprawdzić wszystkie dostępne przęsła - // bo mogą być umieszczone równolegle nad torem - połączyć w pierścień - // najlepiej, jakby odcinki równoległe były oznaczone we wpisach - // WriteLog("Drut: "+AnsiString(fHorizontal)+" "+AnsiString(fVertical)); - p->PantTraction = fVertical; - // p->fHorizontal=fHorizontal; //zapamiętanie położenia drutu - break; // koniec pętli, aktualny drut pasuje - } - } - if (--n <= 0) // coś za długo to szukanie trwa - p->hvPowerWire = NULL; - } - } - if (!p->hvPowerWire) // else nie, bo mógł zostać wyrzucony - { // poszukiwanie po okolicznych sektorach - int c = GetColFromX(dwys.x) + 1; - int r = GetRowFromZ(dwys.z) + 1; - TSubRect *tmp; - TGroundNode *node; - p->PantTraction = 5.0; // taka za duża wartość - for (int j = r - 2; j <= r; j++) - for (int i = c - 2; i <= c; i++) - { // poszukiwanie po najbliższych sektorach niewiele da przy większym - // zagęszczeniu - tmp = FastGetSubRect(i, j); - if (tmp) - { // dany sektor może nie mieć nic w środku - for (node = tmp->nRenderWires; node; - node = node->nNext3) // następny z grupy - if (node->iType == - TP_TRACTION) // w grupie tej są druty oraz inne linie - { - vParam = - node->hvTraction - ->vParametric; // współczynniki równania parametrycznego - fRaParam = -DotProduct(pant0, vFront); - fRaParam = -(DotProduct(node->hvTraction->pPoint1, vFront) + - fRaParam) / - DotProduct(vParam, vFront); - if ((fRaParam >= -0.001) ? (fRaParam <= 1.001) : false) - { // jeśli tylko jest w przedziale, wyznaczyć odległość wzdłuż - // wektorów vUp i vLeft - vStyk = node->hvTraction->pPoint1 + - fRaParam * vParam; // punkt styku płaszczyzny z - // drutem (dla generatora łuku - // el.) - vGdzie = vStyk - pant0; // wektor - fVertical = DotProduct( - vGdzie, - vUp); // musi się mieścić w przedziale ruchu pantografu - if (fVertical >= 0.0) // jeśli ponad pantografem (bo może - // łapać druty spod wiaduktu) - if (Global::bEnableTraction ? - fVertical < p->PantWys - 0.15 : - false) // jeśli drut jest niżej niż 15cm pod - // ślizgiem - { // przełączamy w tryb połamania, o ile jedzie; - // (bEnableTraction) aby dało się jeździć na - // koślawych - // sceneriach - fHorizontal = fabs(DotProduct(vGdzie, vLeft)) - - p->fWidth; // i do tego jeszcze - // wejdzie pod ślizg - if (fHorizontal <= 0.0) // 0.635 dla AKP-1 AKP-4E - { - p->PantWys = - -1.0; // ujemna liczba oznacza połamanie - p->hvPowerWire = NULL; // bo inaczej się zasila - // w nieskończoność z - // połamanego - // p->fHorizontal=fHorizontal; //zapamiętanie - // położenia drutu - if (model->MoverParameters->EnginePowerSource - .CollectorParameters.CollectorsNo > - 0) // liczba pantografów - --model->MoverParameters->EnginePowerSource - .CollectorParameters - .CollectorsNo; // teraz będzie - // mniejsza - if (DebugModeFlag) - ErrorLog( - "Pant. break: at " + - to_string(pant0.x, 2, 7) + - " " + - to_string(pant0.y, 2, 7) + - " " + - to_string(pant0.z, 2, 7)); - } - } - else if (fVertical < p->PantTraction) // ale niżej, niż - // poprzednio - // znaleziony - { - fHorizontal = - fabs(DotProduct(vGdzie, vLeft)) - p->fWidth; - if (fHorizontal <= 0.0) // 0.635 dla AKP-1 AKP-4E - { // to się musi mieścić w przedziale zaleznym od - // szerokości pantografu - p->hvPowerWire = - node->hvTraction; // jakiś znaleziony - p->PantTraction = - fVertical; // zapamiętanie nowej wysokości - // p->fHorizontal=fHorizontal; //zapamiętanie - // położenia drutu - } - else if (fHorizontal < - p->fWidthExtra) // czy zmieścił się w - // zakresie nabieżnika? - { // problem jest, gdy nowy drut jest wyżej, wtedy - // pantograf odłącza się od starego, a na - // podniesienie do nowego potrzebuje czasu - fVertical += - 0.15 * fHorizontal / - p->fWidthExtra; // korekta wysokości o - // nabieżnik - drut nad - // nabieżnikiem jest - // geometrycznie jakby nieco - // wyżej - if (fVertical < - p->PantTraction) // gdy po korekcie jest - // niżej, niż poprzednio - // znaleziony - { // gdyby to wystarczyło, to możemy go uznać - p->hvPowerWire = - node->hvTraction; // może być - p->PantTraction = - fVertical; // na razie liniowo na - // nabieżniku, dokładność - // poprawi się później - // p->fHorizontal=fHorizontal; - // //zapamiętanie położenia drutu - } - } - } - } // warunek na parametr drutu <0;1> - } // pętla po drutach - } // sektor istnieje - } // pętla po sektorach - } // koniec poszukiwania w sektorach - if (!p->hvPowerWire) // jeśli drut nie znaleziony - if (!Global::bLiveTraction) // ale można oszukiwać - model->pants[k].fParamPants->PantTraction = 1.4; // to dajemy coś tam dla picu - } // koniec obsługi podniesionego - else - p->hvPowerWire = NULL; // pantograf opuszczony - } - // if (model->fWahaczeAmpMoverParameters->DistCounter) - //{//nieużywana normalnie zmienna ogranicza powtórzone logowania - // model->fWahaczeAmp=model->MoverParameters->DistCounter; - // ErrorLog(FloatToStrF(1000.0*model->MoverParameters->DistCounter,ffFixed,7,3)+","+FloatToStrF(p->PantTraction,ffFixed,7,3)+","+FloatToStrF(p->fHorizontal,ffFixed,7,3)+","+FloatToStrF(p->PantWys,ffFixed,7,3)+","+AnsiString(p->hvPowerWire?1:0)); - // // - // if (p->fHorizontal>1.0) - //{ - // //Global::iPause|=1; //zapauzowanie symulacji - // Global::fTimeSpeed=1; //spowolnienie czasu do obejrzenia pantografu - // return true; //łapacz - //} - //} - return true; -}; - -bool TGround::RenderDL(vector3 pPosition) -{ // renderowanie scenerii z Display List - faza nieprzezroczystych - glDisable(GL_BLEND); - glAlphaFunc(GL_GREATER, 0.45); // im mniejsza wartość, tym większa ramka, domyślnie 0.1f - ++TGroundRect::iFrameNumber; // zwięszenie licznika ramek (do usuwniania nadanimacji) - CameraDirection.x = sin(Global::pCameraRotation); // wektor kierunkowy - CameraDirection.z = cos(Global::pCameraRotation); - int tr, tc; - TGroundNode *node; - glColor3f(1.0f, 1.0f, 1.0f); - glEnable(GL_LIGHTING); - int n = 2 * iNumSubRects; //(2*==2km) promień wyświetlanej mapy w sektorach - int c = GetColFromX(pPosition.x); - int r = GetRowFromZ(pPosition.z); - TSubRect *tmp; - for (node = srGlobal.nRenderHidden; node; node = node->nNext3) - node->RenderHidden(); // rednerowanie globalnych (nie za często?) - int i, j, k; - // renderowanie czołgowe dla obiektów aktywnych a niewidocznych - for (j = r - n; j <= r + n; j++) - for (i = c - n; i <= c + n; i++) - if ((tmp = FastGetSubRect(i, j)) != NULL) - { - tmp->LoadNodes(); // oznaczanie aktywnych sektorów - for (node = tmp->nRenderHidden; node; node = node->nNext3) - node->RenderHidden(); - tmp->RenderSounds(); // jeszcze dźwięki pojazdów by się przydały, również - // niewidocznych - } - // renderowanie progresywne - zależne od FPS oraz kierunku patrzenia - iRendered = 0; // ilość renderowanych sektorów - vector3 direction; - for (k = 0; k < Global::iSegmentsRendered; ++k) // sektory w kolejności odległości - { // przerobione na użycie SectorOrder - i = SectorOrder[k].x; // na starcie oba >=0 - j = SectorOrder[k].y; - do - { - if (j <= 0) - i = -i; // pierwszy przebieg: j<=0, i>=0; drugi: j>=0, i<=0; trzeci: j<=0, i<=0 - // czwarty: j>=0, i>=0; - j = -j; // i oraz j musi być zmienione wcześniej, żeby continue działało - direction = vector3(i, 0, j); // wektor od kamery do danego sektora - if (LengthSquared3(direction) > 5) // te blisko są zawsze wyświetlane - { - direction = SafeNormalize(direction); // normalizacja - if (CameraDirection.x * direction.x + CameraDirection.z * direction.z < 0.55) - continue; // pomijanie sektorów poza kątem patrzenia - } - Rects[(i + c) / iNumSubRects][(j + r) / iNumSubRects] - .RenderDL(); // kwadrat kilometrowy nie zawsze, bo szkoda FPS - if ((tmp = FastGetSubRect(i + c, j + r)) != NULL) - if (tmp->iNodeCount) // o ile są jakieś obiekty, bo po co puste sektory przelatywać - pRendered[iRendered++] = tmp; // tworzenie listy sektorów do renderowania - } while ((i < 0) || (j < 0)); // są 4 przypadki, oprócz i=j=0 - } - for (i = 0; i < iRendered; i++) - pRendered[i]->RenderDL(); // renderowanie nieprzezroczystych - return true; -} - -bool TGround::RenderAlphaDL(vector3 pPosition) -{ // renderowanie scenerii z Display List - faza przezroczystych - glEnable(GL_BLEND); - glAlphaFunc(GL_GREATER, 0.04); // im mniejsza wartość, tym większa ramka, domyślnie 0.1f - TGroundNode *node; - glColor4f(1.0f, 1.0f, 1.0f, 1.0f); - TSubRect *tmp; - // Ra: renderowanie progresywne - zależne od FPS oraz kierunku patrzenia - int i; - for (i = iRendered - 1; i >= 0; --i) // od najdalszych - { // przezroczyste trójkąty w oddzielnym cyklu przed modelami - tmp = pRendered[i]; - for (node = tmp->nRenderRectAlpha; node; node = node->nNext3) - node->RenderAlphaDL(); // przezroczyste modele - } - for (i = iRendered - 1; i >= 0; --i) // od najdalszych - { // renderowanie przezroczystych modeli oraz pojazdów - pRendered[i]->RenderAlphaDL(); - } - glDisable(GL_LIGHTING); // linie nie powinny świecić - for (i = iRendered - 1; i >= 0; --i) // od najdalszych - { // druty na końcu, żeby się nie robiły białe plamy na tle lasu - tmp = pRendered[i]; - for (node = tmp->nRenderWires; node; node = node->nNext3) - node->RenderAlphaDL(); // druty - } - return true; -} - -bool TGround::RenderVBO(vector3 pPosition) -{ // renderowanie scenerii z VBO - faza nieprzezroczystych - glDisable(GL_BLEND); - glAlphaFunc(GL_GREATER, 0.45); // im mniejsza wartość, tym większa ramka, domyślnie 0.1f - ++TGroundRect::iFrameNumber; // zwięszenie licznika ramek - CameraDirection.x = sin(Global::pCameraRotation); // wektor kierunkowy - CameraDirection.z = cos(Global::pCameraRotation); - int tr, tc; - TGroundNode *node; - glColor3f(1.0f, 1.0f, 1.0f); - glEnable(GL_LIGHTING); - int n = 2 * iNumSubRects; //(2*==2km) promień wyświetlanej mapy w sektorach - int c = GetColFromX(pPosition.x); - int r = GetRowFromZ(pPosition.z); - TSubRect *tmp; - for (node = srGlobal.nRenderHidden; node; node = node->nNext3) - node->RenderHidden(); // rednerowanie globalnych (nie za często?) - int i, j, k; - // renderowanie czołgowe dla obiektów aktywnych a niewidocznych - for (j = r - n; j <= r + n; j++) - for (i = c - n; i <= c + n; i++) - { - if ((tmp = FastGetSubRect(i, j)) != NULL) - { - for (node = tmp->nRenderHidden; node; node = node->nNext3) - node->RenderHidden(); - tmp->RenderSounds(); // jeszcze dźwięki pojazdów by się przydały, również - // niewidocznych - } - } - // renderowanie progresywne - zależne od FPS oraz kierunku patrzenia - iRendered = 0; // ilość renderowanych sektorów - vector3 direction; - for (k = 0; k < Global::iSegmentsRendered; ++k) // sektory w kolejności odległości - { // przerobione na użycie SectorOrder - i = SectorOrder[k].x; // na starcie oba >=0 - j = SectorOrder[k].y; - do - { - if (j <= 0) - i = -i; // pierwszy przebieg: j<=0, i>=0; drugi: j>=0, i<=0; trzeci: j<=0, i<=0 - // czwarty: j>=0, i>=0; - j = -j; // i oraz j musi być zmienione wcześniej, żeby continue działało - direction = vector3(i, 0, j); // wektor od kamery do danego sektora - if (LengthSquared3(direction) > 5) // te blisko są zawsze wyświetlane - { - direction = SafeNormalize(direction); // normalizacja - if (CameraDirection.x * direction.x + CameraDirection.z * direction.z < 0.55) - continue; // pomijanie sektorów poza kątem patrzenia - } - Rects[(i + c) / iNumSubRects][(j + r) / iNumSubRects] - .RenderVBO(); // kwadrat kilometrowy nie zawsze, bo szkoda FPS - if ((tmp = FastGetSubRect(i + c, j + r)) != NULL) - if (tmp->iNodeCount) // jeżeli są jakieś obiekty, bo po co puste sektory przelatywać - pRendered[iRendered++] = tmp; // tworzenie listy sektorów do renderowania - } while ((i < 0) || (j < 0)); // są 4 przypadki, oprócz i=j=0 - } - // dodać rednerowanie terenu z E3D - jedno VBO jest używane dla całego modelu, chyba że jest ich - // więcej - if (Global::pTerrainCompact) - Global::pTerrainCompact->TerrainRenderVBO(TGroundRect::iFrameNumber); - for (i = 0; i < iRendered; i++) - { // renderowanie nieprzezroczystych - pRendered[i]->RenderVBO(); - } - return true; -} - -bool TGround::RenderAlphaVBO(vector3 pPosition) -{ // renderowanie scenerii z VBO - faza przezroczystych - glEnable(GL_BLEND); - glAlphaFunc(GL_GREATER, 0.04); // im mniejsza wartość, tym większa ramka, domyślnie 0.1f - TGroundNode *node; - glColor4f(1.0f, 1.0f, 1.0f, 1.0f); - TSubRect *tmp; - int i; - for (i = iRendered - 1; i >= 0; --i) // od najdalszych - { // renderowanie przezroczystych trójkątów sektora - tmp = pRendered[i]; - tmp->LoadNodes(); // ewentualne tworzenie siatek - if (tmp->StartVBO()) - { - for (node = tmp->nRenderRectAlpha; node; node = node->nNext3) - if (node->iVboPtr >= 0) - node->RenderAlphaVBO(); // nieprzezroczyste obiekty terenu - tmp->EndVBO(); - } - } - for (i = iRendered - 1; i >= 0; --i) // od najdalszych - pRendered[i]->RenderAlphaVBO(); // przezroczyste modeli oraz pojazdy - glDisable(GL_LIGHTING); // linie nie powinny świecić - for (i = iRendered - 1; i >= 0; --i) // od najdalszych - { // druty na końcu, żeby się nie robiły białe plamy na tle lasu - tmp = pRendered[i]; - if (tmp->StartVBO()) - { - for (node = tmp->nRenderWires; node; node = node->nNext3) - node->RenderAlphaVBO(); // przezroczyste modele - tmp->EndVBO(); - } - } - return true; -}; - -//--------------------------------------------------------------------------- -void TGround::Navigate(std::string const &ClassName, UINT Msg, WPARAM wParam, LPARAM lParam) -{ // wysłanie komunikatu do sterującego - HWND h = FindWindow(ClassName.c_str(), 0); // można by to zapamiętać - if (h == 0) - h = FindWindow(0, ClassName.c_str()); // można by to zapamiętać - SendMessage(h, Msg, wParam, lParam); -}; -//-------------------------------- -void TGround::WyslijEvent(const std::string &e, const std::string &d) -{ // Ra: jeszcze do wyczyszczenia - DaneRozkaz r; - r.iSygn = 'EU07'; - r.iComm = 2; // 2 - event - int i = e.length(), j = d.length(); - r.cString[0] = char(i); - strcpy(r.cString + 1, e.c_str()); // zakończony zerem - r.cString[i + 2] = char(j); // licznik po zerze kończącym - strcpy(r.cString + 3 + i, d.c_str()); // zakończony zerem - COPYDATASTRUCT cData; - cData.dwData = 'EU07'; // sygnatura - cData.cbData = 12 + i + j; // 8+dwa liczniki i dwa zera kończące - cData.lpData = &r; - Navigate("TEU07SRK", WM_COPYDATA, (WPARAM)Global::hWnd, (LPARAM)&cData); - CommLog( Now() + " " + std::to_string(r.iComm) + " " + e + " sent" ); -}; -//--------------------------------------------------------------------------- -void TGround::WyslijUszkodzenia(const std::string &t, char fl) -{ // wysłanie informacji w postaci pojedynczego tekstu - DaneRozkaz r; - r.iSygn = 'EU07'; - r.iComm = 13; // numer komunikatu - int i = t.length(); - r.cString[0] = char(fl); - r.cString[1] = char(i); - strcpy(r.cString + 2, t.c_str()); // z zerem kończącym - COPYDATASTRUCT cData; - cData.dwData = 'EU07'; // sygnatura - cData.cbData = 11 + i; // 8+licznik i zero kończące - cData.lpData = &r; - Navigate("TEU07SRK", WM_COPYDATA, (WPARAM)Global::hWnd, (LPARAM)&cData); - CommLog( Now() + " " + std::to_string(r.iComm) + " " + t + " sent"); -}; -//--------------------------------------------------------------------------- -void TGround::WyslijString(const std::string &t, int n) -{ // wysłanie informacji w postaci pojedynczego tekstu - DaneRozkaz r; - r.iSygn = 'EU07'; - r.iComm = n; // numer komunikatu - int i = t.length(); - r.cString[0] = char(i); - strcpy(r.cString + 1, t.c_str()); // z zerem kończącym - COPYDATASTRUCT cData; - cData.dwData = 'EU07'; // sygnatura - cData.cbData = 10 + i; // 8+licznik i zero kończące - cData.lpData = &r; - Navigate("TEU07SRK", WM_COPYDATA, (WPARAM)Global::hWnd, (LPARAM)&cData); - CommLog( Now() + " " + std::to_string(r.iComm) + " " + t + " sent"); -}; -//--------------------------------------------------------------------------- -void TGround::WyslijWolny(const std::string &t) -{ // Ra: jeszcze do wyczyszczenia - WyslijString(t, 4); // tor wolny -}; -//-------------------------------- -void TGround::WyslijNamiary(TGroundNode *t) -{ // wysłanie informacji o pojeździe - (float), długość ramki będzie zwiększana w miarę potrzeby - // WriteLog("Wysylam pojazd"); - DaneRozkaz r; - r.iSygn = 'EU07'; - r.iComm = 7; // 7 - dane pojazdu - int i = 32, j = t->asName.length(); - r.iPar[0] = i; // ilość danych liczbowych - r.fPar[1] = Global::fTimeAngleDeg / 360.0; // aktualny czas (1.0=doba) - r.fPar[2] = t->DynamicObject->MoverParameters->Loc.X; // pozycja X - r.fPar[3] = t->DynamicObject->MoverParameters->Loc.Y; // pozycja Y - r.fPar[4] = t->DynamicObject->MoverParameters->Loc.Z; // pozycja Z - r.fPar[5] = t->DynamicObject->MoverParameters->V; // prędkość ruchu X - r.fPar[6] = t->DynamicObject->MoverParameters->nrot * M_PI * - t->DynamicObject->MoverParameters->WheelDiameter; // prędkość obrotowa kóŁ - r.fPar[7] = 0; // prędkość ruchu Z - r.fPar[8] = t->DynamicObject->MoverParameters->AccS; // przyspieszenie X - r.fPar[9] = t->DynamicObject->MoverParameters->AccN; // przyspieszenie Y //na razie nie - r.fPar[10] = t->DynamicObject->MoverParameters->AccV; // przyspieszenie Z - r.fPar[11] = t->DynamicObject->MoverParameters->DistCounter; // przejechana odległość w km - r.fPar[12] = t->DynamicObject->MoverParameters->PipePress; // ciśnienie w PG - r.fPar[13] = t->DynamicObject->MoverParameters->ScndPipePress; // ciśnienie w PZ - r.fPar[14] = t->DynamicObject->MoverParameters->BrakePress; // ciśnienie w CH - r.fPar[15] = t->DynamicObject->MoverParameters->Compressor; // ciśnienie w ZG - r.fPar[16] = t->DynamicObject->MoverParameters->Itot; // Prąd całkowity - r.iPar[17] = t->DynamicObject->MoverParameters->MainCtrlPos; // Pozycja NJ - r.iPar[18] = t->DynamicObject->MoverParameters->ScndCtrlPos; // Pozycja NB - r.iPar[19] = t->DynamicObject->MoverParameters->MainCtrlActualPos; // Pozycja jezdna - r.iPar[20] = t->DynamicObject->MoverParameters->ScndCtrlActualPos; // Pozycja bocznikowania - r.iPar[21] = t->DynamicObject->MoverParameters->ScndCtrlActualPos; // Pozycja bocznikowania - r.iPar[22] = t->DynamicObject->MoverParameters->ResistorsFlag * 1 + - t->DynamicObject->MoverParameters->ConverterFlag * 2 + - +t->DynamicObject->MoverParameters->CompressorFlag * 4 + - t->DynamicObject->MoverParameters->Mains * 8 + - +t->DynamicObject->MoverParameters->DoorLeftOpened * 16 + - t->DynamicObject->MoverParameters->DoorRightOpened * 32 + - +t->DynamicObject->MoverParameters->FuseFlag * 64 + - t->DynamicObject->MoverParameters->DepartureSignal * 128; - // WriteLog("Zapisalem stare"); - // WriteLog("Mam patykow "+IntToStr(t->DynamicObject->iAnimType[ANIM_PANTS])); - for (int p = 0; p < 4; p++) - { - // WriteLog("Probuje pant "+IntToStr(p)); - if (p < t->DynamicObject->iAnimType[ANIM_PANTS]) - { - r.fPar[23 + p] = t->DynamicObject->pants[p].fParamPants->PantWys; // stan pantografów 4 - // WriteLog("Zapisalem pant "+IntToStr(p)); - } - else - { - r.fPar[23 + p] = -2; - // WriteLog("Nie mam pant "+IntToStr(p)); - } - } - // WriteLog("Zapisalem pantografy"); - for (int p = 0; p < 3; p++) - r.fPar[27 + p] = - t->DynamicObject->MoverParameters->ShowCurrent(p + 1); // amperomierze kolejnych grup - // WriteLog("zapisalem prady"); - r.iPar[30] = t->DynamicObject->MoverParameters->WarningSignal; // trabienie - r.fPar[31] = t->DynamicObject->MoverParameters->RunningTraction.TractionVoltage; // napiecie WN - // WriteLog("Parametry gotowe"); - i <<= 2; // ilość bajtów - r.cString[i] = char(j); // na końcu nazwa, żeby jakoś zidentyfikować - strcpy(r.cString + i + 1, t->asName.c_str()); // zakończony zerem - COPYDATASTRUCT cData; - cData.dwData = 'EU07'; // sygnatura - cData.cbData = 10 + i + j; // 8+licznik i zero kończące - cData.lpData = &r; - // WriteLog("Ramka gotowa"); - Navigate("TEU07SRK", WM_COPYDATA, (WPARAM)Global::hWnd, (LPARAM)&cData); - // WriteLog("Ramka poszla!"); - CommLog( Now() + " " + std::to_string(r.iComm) + " " + t->asName + " sent"); -}; -// -void TGround::WyslijObsadzone() -{ // wysłanie informacji o pojeździe - DaneRozkaz2 r; - r.iSygn = 'EU07'; - r.iComm = 12; // kod 12 - for (int i=0; i<1984; ++i) r.cString[i] = 0; - - int i = 0; - for (TGroundNode *Current = nRootDynamic; Current; Current = Current->nNext) - if (Current->DynamicObject->Mechanik) - { - strcpy(r.cString + 64 * i, Current->DynamicObject->asName.c_str()); - r.fPar[16 * i + 4] = Current->DynamicObject->GetPosition().x; - r.fPar[16 * i + 5] = Current->DynamicObject->GetPosition().y; - r.fPar[16 * i + 6] = Current->DynamicObject->GetPosition().z; - r.iPar[16 * i + 7] = Current->DynamicObject->Mechanik->GetAction(); - strcpy(r.cString + 64 * i + 32, Current->DynamicObject->GetTrack()->IsolatedName().c_str()); - strcpy(r.cString + 64 * i + 48, Current->DynamicObject->Mechanik->Timetable()->TrainName.c_str()); - i++; - if (i>30) break; - } - while (i <= 30) - { - strcpy(r.cString + 64 * i, string("none").c_str()); - r.fPar[16 * i + 4] = 1; - r.fPar[16 * i + 5] = 2; - r.fPar[16 * i + 6] = 3; - r.iPar[16 * i + 7] = 0; - strcpy(r.cString + 64 * i + 32, string("none").c_str()); - strcpy(r.cString + 64 * i + 48, string("none").c_str()); - i++; - } - - COPYDATASTRUCT cData; - cData.dwData = 'EU07'; // sygnatura - cData.cbData = 8 + 1984; // 8+licznik i zero kończące - cData.lpData = &r; - // WriteLog("Ramka gotowa"); - Navigate("TEU07SRK", WM_COPYDATA, (WPARAM)Global::hWnd, (LPARAM)&cData); - CommLog( Now() + " " + std::to_string(r.iComm) + " obsadzone" + " sent"); -} - -//-------------------------------- -void TGround::WyslijParam(int nr, int fl) -{ // wysłanie parametrów symulacji w ramce (nr) z flagami (fl) - DaneRozkaz r; - r.iSygn = 'EU07'; - r.iComm = nr; // zwykle 5 - r.iPar[0] = fl; // flagi istotności kolejnych parametrów - int i = 0; // domyślnie brak danych - switch (nr) - { // można tym przesyłać różne zestawy parametrów - case 5: // czas i pauza - r.fPar[1] = Global::fTimeAngleDeg / 360.0; // aktualny czas (1.0=doba) - r.iPar[2] = Global::iPause; // stan zapauzowania - i = 8; // dwa parametry po 4 bajty każdy - break; - } - COPYDATASTRUCT cData; - cData.dwData = 'EU07'; // sygnatura - cData.cbData = 12 + i; // 12+rozmiar danych - cData.lpData = &r; - Navigate("TEU07SRK", WM_COPYDATA, (WPARAM)Global::hWnd, (LPARAM)&cData); -}; -//--------------------------------------------------------------------------- -//--------------------------------------------------------------------------- -//--------------------------------------------------------------------------- -void TGround::RadioStop(vector3 pPosition) -{ // zatrzymanie pociągów w okolicy - TGroundNode *node; - TSubRect *tmp; - int c = GetColFromX(pPosition.x); - int r = GetRowFromZ(pPosition.z); - int i, j; - int n = 2 * iNumSubRects; // przeglądanie czołgowe okolicznych torów w kwadracie 4km×4km - for (j = r - n; j <= r + n; j++) - for (i = c - n; i <= c + n; i++) - if ((tmp = FastGetSubRect(i, j)) != NULL) - for (node = tmp->nRootNode; node != NULL; node = node->nNext2) - if (node->iType == TP_TRACK) - node->pTrack->RadioStop(); // przekazanie do każdego toru w każdym segmencie -}; - -TDynamicObject * TGround::DynamicNearest(vector3 pPosition, double distance, bool mech) -{ // wyszukanie pojazdu najbliższego względem (pPosition) - TGroundNode *node; - TSubRect *tmp; - TDynamicObject *dyn = NULL; - int c = GetColFromX(pPosition.x); - int r = GetRowFromZ(pPosition.z); - int i, j, k; - double sqm = distance * distance, sqd; // maksymalny promien poszukiwań do kwadratu - for (j = r - 1; j <= r + 1; j++) // plus dwa zewnętrzne sektory, łącznie 9 - for (i = c - 1; i <= c + 1; i++) - if ((tmp = FastGetSubRect(i, j)) != NULL) - for (node = tmp->nRootNode; node; node = node->nNext2) // następny z sektora - if (node->iType == TP_TRACK) // Ra: przebudować na użycie tabeli torów? -#ifdef EU07_USE_OLD_TTRACK_DYNAMICS_ARRAY - for( k = 0; k < node->pTrack->iNumDynamics; k++ ) - if (mech ? (node->pTrack->Dynamics[k]->Mechanik != NULL) : - true) // czy ma mieć obsadę - if ((sqd = SquareMagnitude( - node->pTrack->Dynamics[k]->GetPosition() - pPosition)) < - sqm) - { - sqm = sqd; // nowa odległość - dyn = node->pTrack->Dynamics[k]; // nowy lider - } -#else - for( auto dynamic : node->pTrack->Dynamics ) { - if( mech ? ( dynamic->Mechanik != nullptr ) : true ) { - // czy ma mieć obsadę - if( ( sqd = SquareMagnitude( dynamic->GetPosition() - pPosition ) ) < sqm ) { - sqm = sqd; // nowa odległość - dyn = dynamic; // nowy lider - } - } - } -#endif - return dyn; -}; -TDynamicObject * TGround::CouplerNearest(vector3 pPosition, double distance, bool mech) -{ // wyszukanie pojazdu, którego sprzęg jest najbliżej względem (pPosition) - TGroundNode *node; - TSubRect *tmp; - TDynamicObject *dyn = NULL; - int c = GetColFromX(pPosition.x); - int r = GetRowFromZ(pPosition.z); - int i, j, k; - double sqm = distance * distance, sqd; // maksymalny promien poszukiwań do kwadratu - for (j = r - 1; j <= r + 1; j++) // plus dwa zewnętrzne sektory, łącznie 9 - for (i = c - 1; i <= c + 1; i++) - if ((tmp = FastGetSubRect(i, j)) != NULL) - for (node = tmp->nRootNode; node; node = node->nNext2) // następny z sektora - if (node->iType == TP_TRACK) // Ra: przebudować na użycie tabeli torów? -#ifdef EU07_USE_OLD_TTRACK_DYNAMICS_ARRAY - for( k = 0; k < node->pTrack->iNumDynamics; k++ ) - if (mech ? (node->pTrack->Dynamics[k]->Mechanik != NULL) : - true) // czy ma mieć obsadę - { - if ((sqd = SquareMagnitude( - node->pTrack->Dynamics[k]->HeadPosition() - pPosition)) < - sqm) - { - sqm = sqd; // nowa odległość - dyn = node->pTrack->Dynamics[k]; // nowy lider - } - if ((sqd = SquareMagnitude( - node->pTrack->Dynamics[k]->RearPosition() - pPosition)) < - sqm) - { - sqm = sqd; // nowa odległość - dyn = node->pTrack->Dynamics[k]; // nowy lider - } - } -#else - for( auto dynamic : node->pTrack->Dynamics ) { - if( mech ? ( dynamic->Mechanik != nullptr ) : true ) { - // czy ma mieć obsadę - if( ( sqd = SquareMagnitude( dynamic->HeadPosition() - pPosition ) ) < sqm ) { - sqm = sqd; // nowa odległość - dyn = dynamic; // nowy lider - } - if( ( sqd = SquareMagnitude( dynamic->RearPosition() - pPosition ) ) < sqm ) { - sqm = sqd; // nowa odległość - dyn = dynamic; // nowy lider - } - } - } -#endif - return dyn; -}; -//--------------------------------------------------------------------------- -void TGround::DynamicRemove(TDynamicObject *dyn) -{ // Ra: usunięcie pojazdów ze scenerii (gdy dojadą na koniec i nie sa potrzebne) - TDynamicObject *d = dyn->Prev(); - if (d) // jeśli coś jest z przodu - DynamicRemove(d); // zaczynamy od tego z przodu - else - { // jeśli mamy już tego na początku - TGroundNode **n, *node; - d = dyn; // od pierwszego - while (d) - { - if (d->MyTrack) - d->MyTrack->RemoveDynamicObject(d); // usunięcie z toru o ile nie usunięty - n = &nRootDynamic; // lista pojazdów od początku - // node=NULL; //nie znalezione - while (*n ? (*n)->DynamicObject != d : false) - { // usuwanie z listy pojazdów - n = &((*n)->nNext); // sprawdzenie kolejnego pojazdu na liście - } - if ((*n)->DynamicObject == d) - { // jeśli znaleziony - node = (*n); // zapamiętanie węzła, aby go usunąć - (*n) = node->nNext; // pominięcie na liście - Global::TrainDelete(d); - d = d->Next(); // przejście do kolejnego pojazdu, póki jeszcze jest - delete node; // usuwanie fizyczne z pamięci - } - else - d = NULL; // coś nie tak! - } - } -}; - -//--------------------------------------------------------------------------- -void TGround::TerrainRead(std::string const &f){ - // Ra: wczytanie trójkątów terenu z pliku E3D -}; - -//--------------------------------------------------------------------------- -void TGround::TerrainWrite() -{ // Ra: zapisywanie trójkątów terenu do pliku E3D - if (Global::pTerrainCompact->TerrainLoaded()) - return; // jeśli zostało wczytane, to nie ma co dalej robić - if (Global::asTerrainModel.empty()) - return; - // Trójkąty są zapisywane kwadratami kilometrowymi. - // Kwadrat 500500 jest na środku (od 0.0 do 1000.0 na OX oraz OZ). - // Ewentualnie w numerowaniu kwadratów uwzględnic wpis //$g. - // Trójkąty są grupowane w submodele wg tekstury. - // Triangle_strip oraz triangle_fan są rozpisywane na pojedyncze trójkąty, - // chyba że dla danej tekstury wychodzi tylko jeden submodel. - TModel3d *m = new TModel3d(); // wirtualny model roboczy z oddzielnymi submodelami - TSubModel *sk; // wskaźnik roboczy na submodel kwadratu - TSubModel *st; // wskaźnik roboczy na submodel tekstury - // Zliczamy kwadraty z trójkątami, ilość tekstur oraz wierzchołków. - // Ilość kwadratów i ilość tekstur określi ilość submodeli. - // int sub=0; //całkowita ilość submodeli - // int ver=0; //całkowita ilość wierzchołków - int i, j, k; // indeksy w pętli - TGroundNode *Current; - float8 *ver; // trójkąty - TSubModel::iInstance = 0; // pozycja w tabeli wierzchołków liczona narastająco - for (i = 0; i < iNumRects; ++i) // pętla po wszystkich kwadratach kilometrowych - for (j = 0; j < iNumRects; ++j) - if (Rects[i][j].iNodeCount) - { // o ile są jakieś trójkąty w środku - sk = new TSubModel(); // nowy submodel dla kawadratu - // numer kwadratu XXXZZZ, przy czym X jest ujemne - XXX rośnie na wschód, ZZZ rośnie - // na północ - sk->NameSet( std::to_string(1000 * (500 + i - iNumRects / 2) + (500 + j - iNumRects / 2)).c_str() ); // nazwa=numer kwadratu - m->AddTo(NULL, sk); // dodanie submodelu dla kwadratu - for (Current = Rects[i][j].nRootNode; Current; Current = Current->nNext2) - if (Current->TextureID) - switch (Current->iType) - { // pętla po trójkątach - zliczanie wierzchołków, dodaje submodel dla - // każdej tekstury - case GL_TRIANGLES: - Current->iVboPtr = sk->TriangleAdd( - m, Current->TextureID, - Current->iNumVerts); // zwiększenie ilości trójkątów w submodelu - m->iNumVerts += - Current->iNumVerts; // zwiększenie całkowitej ilości wierzchołków - break; - case GL_TRIANGLE_STRIP: // na razie nie, bo trzeba przerabiać na pojedyncze - // trójkąty - break; - case GL_TRIANGLE_FAN: // na razie nie, bo trzeba przerabiać na pojedyncze - // trójkąty - break; - } - for (Current = Rects[i][j].nRootNode; Current; Current = Current->nNext2) - if (Current->TextureID) - switch (Current->iType) - { // pętla po trójkątach - dopisywanie wierzchołków - case GL_TRIANGLES: - // ver=sk->TrianglePtr(TTexturesManager::GetName(Current->TextureID).c_str(),Current->iNumVerts); - // //wskaźnik na początek - ver = sk->TrianglePtr(Current->TextureID, Current->iVboPtr, - Current->Ambient, Current->Diffuse, - Current->Specular); // wskaźnik na początek - // WriteLog("Zapis "+AnsiString(Current->iNumVerts)+" trójkątów w - // ("+AnsiString(i)+","+AnsiString(j)+") od - // "+AnsiString(Current->iVboPtr)+" dla - // "+AnsiString(Current->TextureID)); - Current->iVboPtr = -1; // bo to było tymczasowo używane - for (k = 0; k < Current->iNumVerts; ++k) - { // przepisanie współrzędnych - ver[k].Point.x = Current->Vertices[k].Point.x; - ver[k].Point.y = Current->Vertices[k].Point.y; - ver[k].Point.z = Current->Vertices[k].Point.z; - ver[k].Normal.x = Current->Vertices[k].Normal.x; - ver[k].Normal.y = Current->Vertices[k].Normal.y; - ver[k].Normal.z = Current->Vertices[k].Normal.z; - ver[k].tu = Current->Vertices[k].tu; - ver[k].tv = Current->Vertices[k].tv; - } - break; - case GL_TRIANGLE_STRIP: // na razie nie, bo trzeba przerabiać na pojedyncze - // trójkąty - break; - case GL_TRIANGLE_FAN: // na razie nie, bo trzeba przerabiać na pojedyncze - // trójkąty - break; - } - } - m->SaveToBinFile(strdup(("models\\" + Global::asTerrainModel).c_str())); -}; -//--------------------------------------------------------------------------- - -void TGround::TrackBusyList() -{ // wysłanie informacji o wszystkich zajętych odcinkach - TGroundNode *Current; - TTrack *Track; - for (Current = nRootOfType[TP_TRACK]; Current; Current = Current->nNext) - if (!Current->asName.empty()) // musi być nazwa -#ifdef EU07_USE_OLD_TTRACK_DYNAMICS_ARRAY - if( Current->pTrack->iNumDynamics ) // osi to chyba nie ma jak policzyć -#else - if( false == Current->pTrack->Dynamics.empty() ) -#endif - WyslijString(Current->asName, 8); // zajęty -}; -//--------------------------------------------------------------------------- - -void TGround::IsolatedBusyList() -{ // wysłanie informacji o wszystkich odcinkach izolowanych - TIsolated *Current; - for (Current = TIsolated::Root(); Current; Current = Current->Next()) - if (Current->Busy()) // sprawdź zajętość - WyslijString(Current->asName, 11); // zajęty - else - WyslijString(Current->asName, 10); // wolny - WyslijString("none", 10); // informacja o końcu listy -}; -//--------------------------------------------------------------------------- - -void TGround::IsolatedBusy(const std::string t) -{ // wysłanie informacji o odcinku izolowanym (t) - // Ra 2014-06: do wyszukania użyć drzewka nazw - TIsolated *Current; - for (Current = TIsolated::Root(); Current; Current = Current->Next()) - if (Current->asName == t) // wyszukiwanie odcinka o nazwie (t) - if (Current->Busy()) // sprawdź zajetość - { - WyslijString(Current->asName, 11); // zajęty - return; // nie sprawdzaj dalszych - } - WyslijString(t, 10); // wolny -}; -//--------------------------------------------------------------------------- - -void TGround::Silence(vector3 gdzie) -{ // wyciszenie wszystkiego w sektorach przed przeniesieniem kamery z (gdzie) - int tr, tc; - TGroundNode *node; - int n = 2 * iNumSubRects; //(2*==2km) promień wyświetlanej mapy w sektorach - int c = GetColFromX(gdzie.x); // sektory wg dotychczasowej pozycji kamery - int r = GetRowFromZ(gdzie.z); - TSubRect *tmp; - int i, j, k; - // renderowanie czołgowe dla obiektów aktywnych a niewidocznych - for (j = r - n; j <= r + n; j++) - for (i = c - n; i <= c + n; i++) - if ((tmp = FastGetSubRect(i, j)) != NULL) - { // tylko dźwięki interesują - for (node = tmp->nRenderHidden; node; node = node->nNext3) - node->RenderHidden(); - tmp->RenderSounds(); // dźwięki pojazdów by się przydało wyłączyć - } -}; -//--------------------------------------------------------------------------- diff --git a/Ground.h b/Ground.h deleted file mode 100644 index b78023d6..00000000 --- a/Ground.h +++ /dev/null @@ -1,436 +0,0 @@ -/* -This Source Code Form is subject to the -terms of the Mozilla Public License, v. -2.0. If a copy of the MPL was not -distributed with this file, You can -obtain one at -http://mozilla.org/MPL/2.0/. -*/ - -#pragma once - -#include -#include "opengl/glew.h" -#include "VBO.h" -#include "Classes.h" -#include "ResourceManager.h" -#include "Texture.h" -#include "dumb3d.h" -#include "Names.h" - -using namespace Math3D; - -// Ra: zmniejszone liczby, aby zrobić tabelkę i zoptymalizować wyszukiwanie -const int TP_MODEL = 10; -const int TP_MESH = 11; // Ra: specjalny obiekt grupujący siatki dla tekstury -const int TP_DUMMYTRACK = 12; // Ra: zdublowanie obiektu toru dla rozdzielenia tekstur -const int TP_TERRAIN = 13; // Ra: specjalny model dla terenu -const int TP_DYNAMIC = 14; -const int TP_SOUND = 15; -const int TP_TRACK = 16; -// const int TP_GEOMETRY=17; -const int TP_MEMCELL = 18; -const int TP_EVLAUNCH = 19; // MC -const int TP_TRACTION = 20; -const int TP_TRACTIONPOWERSOURCE = 21; // MC -// const int TP_ISOLATED=22; //Ra -const int TP_SUBMODEL = 22; // Ra: submodele terenu -const int TP_LAST = 25; // rozmiar tablicy - -struct DaneRozkaz -{ // struktura komunikacji z EU07.EXE - int iSygn; // sygnatura 'EU07' - int iComm; // rozkaz/status (kod ramki) - union - { - float fPar[62]; - int iPar[62]; - char cString[248]; // upakowane stringi - }; -}; - -struct DaneRozkaz2 -{ // struktura komunikacji z EU07.EXE - int iSygn; // sygnatura 'EU07' - int iComm; // rozkaz/status (kod ramki) - union - { - float fPar[496]; - int iPar[496]; - char cString[1984]; // upakowane stringi - }; -}; - -typedef int TGroundNodeType; - -struct TGroundVertex -{ - vector3 Point; - vector3 Normal; - float tu, tv; - void HalfSet(const TGroundVertex &v1, const TGroundVertex &v2) - { // wyliczenie współrzędnych i mapowania punktu na środku odcinka v1<->v2 - Point = 0.5 * (v1.Point + v2.Point); - Normal = 0.5 * (v1.Normal + v2.Normal); - tu = 0.5 * (v1.tu + v2.tu); - tv = 0.5 * (v1.tv + v2.tv); - } - void SetByX(const TGroundVertex &v1, const TGroundVertex &v2, double x) - { // wyliczenie współrzędnych i mapowania punktu na odcinku v1<->v2 - double i = (x - v1.Point.x) / (v2.Point.x - v1.Point.x); // parametr równania - double j = 1.0 - i; - Point = j * v1.Point + i * v2.Point; - Normal = j * v1.Normal + i * v2.Normal; - tu = j * v1.tu + i * v2.tu; - tv = j * v1.tv + i * v2.tv; - } - void SetByZ(const TGroundVertex &v1, const TGroundVertex &v2, double z) - { // wyliczenie współrzędnych i mapowania punktu na odcinku v1<->v2 - double i = (z - v1.Point.z) / (v2.Point.z - v1.Point.z); // parametr równania - double j = 1.0 - i; - Point = j * v1.Point + i * v2.Point; - Normal = j * v1.Normal + i * v2.Normal; - tu = j * v1.tu + i * v2.tu; - tv = j * v1.tv + i * v2.tv; - } -}; - -class TSubRect; // sektor (aktualnie 200m×200m, ale może być zmieniony) - -class TGroundNode : public Resource -{ // obiekt scenerii - private: - public: - TGroundNodeType iType; // typ obiektu - union - { // Ra: wskażniki zależne od typu - zrobić klasy dziedziczone zamiast - void *Pointer; // do przypisywania NULL - TSubModel *smTerrain; // modele terenu (kwadratow kilometrowych) - TAnimModel *Model; // model z animacjami - TDynamicObject *DynamicObject; // pojazd - vector3 *Points; // punkty dla linii - TTrack *pTrack; // trajektoria ruchu - TGroundVertex *Vertices; // wierzchołki dla trójkątów - TMemCell *MemCell; // komórka pamięci - TEventLauncher *EvLaunch; // wyzwalacz zdarzeń - TTraction *hvTraction; // drut zasilający - TTractionPowerSource *psTractionPowerSource; // zasilanie drutu (zaniedbane w sceneriach) - TTextSound *tsStaticSound; // dźwięk przestrzenny - TGroundNode *nNode; // obiekt renderujący grupowo ma tu wskaźnik na listę obiektów - }; - std::string asName; // nazwa (nie zawsze ma znaczenie) - union - { - int iNumVerts; // dla trójkątów - int iNumPts; // dla linii - int iCount; // dla terenu - // int iState; //Ra: nie używane - dźwięki zapętlone - }; - vector3 pCenter; // współrzędne środka do przydzielenia sektora - - union - { - // double fAngle; //kąt obrotu dla modelu - double fLineThickness; // McZapkie-120702: grubosc linii - // int Status; //McZapkie-170303: status dzwieku - }; - double fSquareRadius; // kwadrat widoczności do - double fSquareMinRadius; // kwadrat widoczności od - // TGroundNode *nMeshGroup; //Ra: obiekt grupujący trójkąty w TSubRect dla tekstury - int iVersion; // wersja siatki (do wykonania rekompilacji) - // union ? - GLuint DisplayListID; // numer siatki DisplayLists - bool PROBLEND; - int iVboPtr; // indeks w buforze VBO - texture_manager::size_type TextureID; // główna (jedna) tekstura obiektu - int iFlags; // tryb przezroczystości: 0x10-nieprz.,0x20-przezroczysty,0x30-mieszany - int Ambient[4], Diffuse[4], Specular[4]; // oświetlenie - bool bVisible; - TGroundNode *nNext; // lista wszystkich w scenerii, ostatni na początku - TGroundNode *nNext2; // lista obiektów w sektorze - TGroundNode *nNext3; // lista obiektów renderowanych we wspólnym cyklu - TGroundNode(); - TGroundNode(TGroundNodeType t, int n = 0); - ~TGroundNode(); - void Init(int n); - void InitCenter(); // obliczenie współrzędnych środka - void InitNormals(); - - void MoveMe(vector3 pPosition); // przesuwanie (nie działa) - - // bool Disable(); - inline TGroundNode * Find(const std::string &asNameToFind, TGroundNodeType iNodeType) - { // wyszukiwanie czołgowe z typem - if ((iNodeType == iType) && (asNameToFind == asName)) - return this; - else if (nNext) - return nNext->Find(asNameToFind, iNodeType); - return NULL; - }; - - void Compile(bool many = false); - void Release(); - bool GetTraction(); - - void RenderHidden(); // obsługa dźwięków i wyzwalaczy zdarzeń - void RenderDL(); // renderowanie nieprzezroczystych w Display Lists - void RenderAlphaDL(); // renderowanie przezroczystych w Display Lists - // (McZapkie-131202) - void RaRenderVBO(); // renderowanie (nieprzezroczystych) ze wspólnego VBO - void RenderVBO(); // renderowanie nieprzezroczystych z własnego VBO - void RenderAlphaVBO(); // renderowanie przezroczystych z (własnego) VBO -}; - -class TSubRect : public Resource, public CMesh -{ // sektor składowy kwadratu kilometrowego - public: - int iTracks = 0; // ilość torów w (tTracks) - TTrack **tTracks = nullptr; // tory do renderowania pojazdów - protected: - TTrack *tTrackAnim = nullptr; // obiekty do przeliczenia animacji - TGroundNode *nRootMesh = nullptr; // obiekty renderujące wg tekstury (wtórne, lista po nNext2) - TGroundNode *nMeshed = nullptr; // lista obiektów dla których istnieją obiekty renderujące grupowo - public: - TGroundNode * - nRootNode = nullptr; // wszystkie obiekty w sektorze, z wyjątkiem renderujących i pojazdów (nNext2) - TGroundNode * - nRenderHidden = nullptr; // lista obiektów niewidocznych, "renderowanych" również z tyłu (nNext3) - TGroundNode *nRenderRect = nullptr; // z poziomu sektora - nieprzezroczyste (nNext3) - TGroundNode *nRenderRectAlpha = nullptr; // z poziomu sektora - przezroczyste (nNext3) - TGroundNode *nRenderWires = nullptr; // z poziomu sektora - druty i inne linie (nNext3) - TGroundNode *nRender = nullptr; // indywidualnie - nieprzezroczyste (nNext3) - TGroundNode *nRenderMixed = nullptr; // indywidualnie - nieprzezroczyste i przezroczyste (nNext3) - TGroundNode *nRenderAlpha = nullptr; // indywidualnie - przezroczyste (nNext3) - int iNodeCount = 0; // licznik obiektów, do pomijania pustych sektorów - public: - void LoadNodes(); // utworzenie VBO sektora - public: -// TSubRect() = default; - virtual ~TSubRect(); - virtual void Release(); // zwalnianie VBO sektora - void NodeAdd(TGroundNode *Node); // dodanie obiektu do sektora na etapie rozdzielania na sektory - void RaNodeAdd(TGroundNode *Node); // dodanie obiektu do listy renderowania - void Sort(); // optymalizacja obiektów w sektorze (sortowanie wg tekstur) - TTrack * FindTrack(vector3 *Point, int &iConnection, TTrack *Exclude); - TTraction * FindTraction(vector3 *Point, int &iConnection, TTraction *Exclude); - bool StartVBO(); // ustwienie VBO sektora dla (nRenderRect), (nRenderRectAlpha) i - // (nRenderWires) - bool RaTrackAnimAdd(TTrack *t); // zgłoszenie toru do animacji - void RaAnimate(); // przeliczenie animacji torów - void RenderDL(); // renderowanie nieprzezroczystych w Display Lists - void RenderAlphaDL(); // renderowanie przezroczystych w Display Lists - // (McZapkie-131202) - void RenderVBO(); // renderowanie nieprzezroczystych z własnego VBO - void RenderAlphaVBO(); // renderowanie przezroczystych z (własnego) VBO - void RenderSounds(); // dźwięki pojazdów z niewidocznych sektorów -}; - -// Ra: trzeba sprawdzić wydajność siatki -const int iNumSubRects = 5; // na ile dzielimy kilometr -const int iNumRects = 500; -// const double fHalfNumRects=iNumRects/2.0; //połowa do wyznaczenia środka -const int iTotalNumSubRects = iNumRects * iNumSubRects; -const double fHalfTotalNumSubRects = iTotalNumSubRects / 2.0; -const double fSubRectSize = 1000.0 / iNumSubRects; -const double fRectSize = fSubRectSize * iNumSubRects; - -class TGroundRect : public TSubRect -{ // kwadrat kilometrowy - // obiekty o niewielkiej ilości wierzchołków będą renderowane stąd - // Ra: 2012-02 doszły submodele terenu - private: - int iLastDisplay; // numer klatki w której był ostatnio wyświetlany - TSubRect *pSubRects; - void Init() - { - pSubRects = new TSubRect[iNumSubRects * iNumSubRects]; - }; - - public: - static int iFrameNumber; // numer kolejny wyświetlanej klatki - TGroundNode *nTerrain; // model terenu z E3D - użyć nRootMesh? - TGroundRect(); - virtual ~TGroundRect(); - - TSubRect * SafeGetRect(int iCol, int iRow) - { // pobranie wskaźnika do małego kwadratu, utworzenie jeśli trzeba - if (!pSubRects) - Init(); // utworzenie małych kwadratów - return pSubRects + iRow * iNumSubRects + iCol; // zwrócenie właściwego - }; - TSubRect * FastGetRect(int iCol, int iRow) - { // pobranie wskaźnika do małego kwadratu, bez tworzenia jeśli nie ma - return (pSubRects ? pSubRects + iRow * iNumSubRects + iCol : NULL); - }; - void Optimize() - { // optymalizacja obiektów w sektorach - if (pSubRects) - for (int i = iNumSubRects * iNumSubRects - 1; i >= 0; --i) - pSubRects[i].Sort(); // optymalizacja obiektów w sektorach - }; - void RenderDL(); - void RenderVBO(); -}; - -class TGround -{ - vector3 CameraDirection; // zmienna robocza przy renderowaniu - int const *iRange = nullptr; // tabela widoczności - // TGroundNode *nRootNode; //lista wszystkich węzłów - TGroundNode *nRootDynamic = nullptr; // lista pojazdów - TGroundRect Rects[iNumRects][iNumRects]; // mapa kwadratów kilometrowych - TEvent *RootEvent = nullptr; // lista zdarzeń - TEvent *QueryRootEvent = nullptr, - *tmpEvent = nullptr, - *tmp2Event = nullptr, - *OldQRE = nullptr; - TSubRect *pRendered[1500]; // lista renderowanych sektorów - int iNumNodes = 0; - vector3 pOrigin; - vector3 aRotate; - bool bInitDone = false; - TGroundNode *nRootOfType[TP_LAST]; // tablica grupująca obiekty, przyspiesza szukanie - // TGroundNode *nLastOfType[TP_LAST]; //ostatnia - TSubRect srGlobal; // zawiera obiekty globalne (na razie wyzwalacze czasowe) - int hh = 0, - mm = 0, - srh = 0, - srm = 0, - ssh = 0, - ssm = 0; // ustawienia czasu - // int tracks,tracksfar; //liczniki torów -#ifdef EU07_USE_OLD_TNAMES_CLASS - TNames *sTracks = nullptr; // posortowane nazwy torów i eventów -#else - typedef std::unordered_map event_map; -// typedef std::unordered_map groundnode_map; - event_map m_eventmap; -// groundnode_map m_memcellmap, m_modelmap, m_trackmap; - TNames m_trackmap; -#endif - private: // metody prywatne - bool EventConditon(TEvent *e); - - public: - bool bDynamicRemove = false; // czy uruchomić procedurę usuwania pojazdów - TDynamicObject *LastDyn = nullptr; // ABu: paskudnie, ale na bardzo szybko moze jakos przejdzie... - // TTrain *pTrain; - // double fVDozwolona; - // bool bTrabil; - - TGround(); - ~TGround(); - void Free(); - bool Init(std::string asFile, HDC hDC); - void FirstInit(); - void InitTracks(); - void InitTraction(); - bool InitEvents(); - bool InitLaunchers(); - TTrack * FindTrack(vector3 Point, int &iConnection, TGroundNode *Exclude); - TTraction * FindTraction(vector3 *Point, int &iConnection, TGroundNode *Exclude); - TTraction * TractionNearestFind(vector3 &p, int dir, TGroundNode *n); - // TGroundNode* CreateGroundNode(); - TGroundNode * AddGroundNode(cParser *parser); - bool AddGroundNode(double x, double z, TGroundNode *Node) - { - TSubRect *tmp = GetSubRect(x, z); - if (tmp) - { - tmp->NodeAdd(Node); - return true; - } - else - return false; - }; - // bool Include(TQueryParserComp *Parser); - // TGroundNode* GetVisible(AnsiString asName); - TGroundNode * GetNode(std::string asName); - bool AddDynamic(TGroundNode *Node); - void MoveGroundNode(vector3 pPosition); - void UpdatePhys(double dt, int iter); // aktualizacja fizyki stałym krokiem - bool Update(double dt, int iter); // aktualizacja przesunięć zgodna z FPS - bool AddToQuery(TEvent *Event, TDynamicObject *Node); - bool GetTraction(TDynamicObject *model); - bool RenderDL(vector3 pPosition); - bool RenderAlphaDL(vector3 pPosition); - bool RenderVBO(vector3 pPosition); - bool RenderAlphaVBO(vector3 pPosition); - bool CheckQuery(); - // GetRect(double x, double z) { return - // &(Rects[int(x/fSubRectSize+fHalfNumRects)][int(z/fSubRectSize+fHalfNumRects)]); }; - /* - int GetRowFromZ(double z) { return (z/fRectSize+fHalfNumRects); }; - int GetColFromX(double x) { return (x/fRectSize+fHalfNumRects); }; - int GetSubRowFromZ(double z) { return (z/fSubRectSize+fHalfNumSubRects); }; - int GetSubColFromX(double x) { return (x/fSubRectSize+fHalfNumSubRects); }; - */ - /* - inline TGroundNode* FindGroundNode(const AnsiString &asNameToFind ) - { - if (RootNode) - return (RootNode->Find( asNameToFind )); - else - return NULL; - } - */ - TGroundNode * DynamicFindAny(std::string asNameToFind); - TGroundNode * DynamicFind(std::string asNameToFind); - void DynamicList(bool all = false); - TGroundNode * FindGroundNode(std::string asNameToFind, TGroundNodeType iNodeType); - TGroundRect * GetRect(double x, double z) - { - return &Rects[GetColFromX(x) / iNumSubRects][GetRowFromZ(z) / iNumSubRects]; - }; - TSubRect * GetSubRect(double x, double z) - { - return GetSubRect(GetColFromX(x), GetRowFromZ(z)); - }; - TSubRect * FastGetSubRect(double x, double z) - { - return FastGetSubRect(GetColFromX(x), GetRowFromZ(z)); - }; - TSubRect * GetSubRect(int iCol, int iRow); - TSubRect * FastGetSubRect(int iCol, int iRow); - int GetRowFromZ(double z) - { - return (z / fSubRectSize + fHalfTotalNumSubRects); - }; - int GetColFromX(double x) - { - return (x / fSubRectSize + fHalfTotalNumSubRects); - }; - TEvent * FindEvent(const std::string &asEventName); - TEvent * FindEventScan(const std::string &asEventName); - void TrackJoin(TGroundNode *Current); - - private: - void OpenGLUpdate(HDC hDC); - void RaTriangleDivider(TGroundNode *node); - void Navigate(std::string const &ClassName, UINT Msg, WPARAM wParam, LPARAM lParam); - bool PROBLEND; - - public: - void WyslijEvent(const std::string &e, const std::string &d); - int iRendered; // ilość renderowanych sektorów, pobierana przy pokazywniu FPS - void WyslijString(const std::string &t, int n); - void WyslijWolny(const std::string &t); - void WyslijNamiary(TGroundNode *t); - void WyslijParam(int nr, int fl); - void WyslijUszkodzenia(const std::string &t, char fl); - void WyslijPojazdy(int nr); // -> skladanie wielu pojazdow - void WyslijObsadzone(); // -> skladanie wielu pojazdow - void RadioStop(vector3 pPosition); - TDynamicObject * DynamicNearest(vector3 pPosition, double distance = 20.0, - bool mech = false); - TDynamicObject * CouplerNearest(vector3 pPosition, double distance = 20.0, - bool mech = false); - void DynamicRemove(TDynamicObject *dyn); - void TerrainRead(std::string const &f); - void TerrainWrite(); - void TrackBusyList(); - void IsolatedBusyList(); - void IsolatedBusy(const std::string t); - void Silence(vector3 gdzie); -}; -//--------------------------------------------------------------------------- diff --git a/Logs.cpp b/Logs.cpp index 563003b0..612d489f 100644 --- a/Logs.cpp +++ b/Logs.cpp @@ -11,113 +11,125 @@ http://mozilla.org/MPL/2.0/. #include "Logs.h" #include "Globals.h" +#include "utilities.h" std::ofstream output; // standardowy "log.txt", można go wyłączyć std::ofstream errors; // lista błędów "errors.txt", zawsze działa std::ofstream comms; // lista komunikatow "comms.txt", można go wyłączyć +char logbuffer[ 256 ]; char endstring[10] = "\n"; -void WriteConsoleOnly(const char *str, double value) -{ - char buf[255]; - sprintf(buf, "%s %f \n", str, value); - // stdout= GetStdHandle(STD_OUTPUT_HANDLE); - DWORD wr = 0; - WriteConsole(GetStdHandle(STD_OUTPUT_HANDLE), buf, strlen(buf), &wr, NULL); - // WriteConsole(GetStdHandle(STD_OUTPUT_HANDLE),endstring,strlen(endstring),&wr,NULL); +std::string filename_date() { + + ::SYSTEMTIME st; + ::GetLocalTime( &st ); + std::snprintf( + logbuffer, + sizeof(logbuffer), + "%d%02d%02d_%02d%02d", + st.wYear, + st.wMonth, + st.wDay, + st.wHour, + st.wMinute ); + + return std::string( logbuffer ); } -void WriteConsoleOnly(const char *str, bool newline) -{ - // printf("%n ffafaf /n",str); - SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), - FOREGROUND_GREEN | FOREGROUND_INTENSITY); - DWORD wr = 0; - WriteConsole(GetStdHandle(STD_OUTPUT_HANDLE), str, strlen(str), &wr, NULL); - if (newline) - WriteConsole(GetStdHandle(STD_OUTPUT_HANDLE), endstring, strlen(endstring), &wr, NULL); -} +std::string filename_scenery() { -void WriteLog(const char *str, double value) -{ - if (Global::iWriteLogEnabled) - { - if (str) - { - char buf[255]; - sprintf(buf, "%s %f", str, value); - WriteLog(buf); - } + auto extension = Global.SceneryFile.rfind( '.' ); + if( extension != std::string::npos ) { + return Global.SceneryFile.substr( 0, extension ); } -}; -void WriteLog(const char *str, bool newline) -{ - if (str) - { - if (Global::iWriteLogEnabled & 1) - { - if (!output.is_open()) - output.open("log.txt", std::ios::trunc); - output << str; - if (newline) - output << "\n"; - output.flush(); + else { + return Global.SceneryFile; + } +} + +void WriteLog( const char *str, logtype const Type ) { + + if( str == nullptr ) { return; } + if( true == TestFlag( Global.DisabledLogTypes, Type ) ) { return; } + + if (Global.iWriteLogEnabled & 1) { + if( !output.is_open() ) { + + std::string const filename = + ( Global.MultipleLogs ? + "logs/log (" + filename_scenery() + ") " + filename_date() + ".txt" : + "log.txt" ); + output.open( filename, std::ios::trunc ); } + output << str << "\n"; + output.flush(); + } + + if( Global.iWriteLogEnabled & 2 ) { // hunter-271211: pisanie do konsoli tylko, gdy nie jest ukrywana - if (Global::iWriteLogEnabled & 2) - WriteConsoleOnly(str, newline); + SetConsoleTextAttribute( GetStdHandle( STD_OUTPUT_HANDLE ), FOREGROUND_GREEN | FOREGROUND_INTENSITY ); + DWORD wr = 0; + WriteConsole( GetStdHandle( STD_OUTPUT_HANDLE ), str, (DWORD)strlen( str ), &wr, NULL ); + WriteConsole( GetStdHandle( STD_OUTPUT_HANDLE ), endstring, (DWORD)strlen( endstring ), &wr, NULL ); } -}; +} -void ErrorLog(const char *str) -{ // Ra: bezwarunkowa rejestracja poważnych błędów - if (!errors.is_open()) - { - errors.open("errors.txt", std::ios::trunc); - errors << "EU07.EXE " + Global::asRelease << "\n"; +// Ra: bezwarunkowa rejestracja poważnych błędów +void ErrorLog( const char *str, logtype const Type ) { + + if( str == nullptr ) { return; } + if( true == TestFlag( Global.DisabledLogTypes, Type ) ) { return; } + + if (!errors.is_open()) { + + std::string const filename = + ( Global.MultipleLogs ? + "logs/errors (" + filename_scenery() + ") " + filename_date() + ".txt" : + "errors.txt" ); + errors.open( filename, std::ios::trunc ); + errors << "EU07.EXE " + Global.asVersion << "\n"; } - if (str) - errors << str; - errors << "\n"; + + errors << str << "\n"; errors.flush(); }; void Error(const std::string &asMessage, bool box) { // if (box) - // MessageBox(NULL, asMessage.c_str(), string("EU07 " + Global::asRelease).c_str(), MB_OK); + // MessageBox(NULL, asMessage.c_str(), string("EU07 " + Global.asRelease).c_str(), MB_OK); ErrorLog(asMessage.c_str()); } void Error(const char *&asMessage, bool box) { // if (box) - // MessageBox(NULL, asMessage, string("EU07 " + Global::asRelease).c_str(), MB_OK); + // MessageBox(NULL, asMessage, string("EU07 " + Global.asRelease).c_str(), MB_OK); ErrorLog(asMessage); WriteLog(asMessage); } -void ErrorLog(const std::string &str, bool newline) +void ErrorLog(const std::string &str, logtype const Type ) { - ErrorLog(str.c_str()); - WriteLog(str.c_str(), newline); + ErrorLog( str.c_str(), Type ); + WriteLog( str.c_str(), Type ); } -void WriteLog(const std::string &str, bool newline) +void WriteLog(const std::string &str, logtype const Type ) { // Ra: wersja z AnsiString jest zamienna z Error() - WriteLog(str.c_str(), newline); + WriteLog( str.c_str(), Type ); }; void CommLog(const char *str) { // Ra: warunkowa rejestracja komunikatów WriteLog(str); - /* if (Global::iWriteLogEnabled & 4) + /* if (Global.iWriteLogEnabled & 4) { if (!comms.is_open()) { comms.open("comms.txt", std::ios::trunc); - comms << AnsiString("EU07.EXE " + Global::asRelease).c_str() << "\n"; + comms << AnsiString("EU07.EXE " + Global.asRelease).c_str() << "\n"; } if (str) comms << str; diff --git a/Logs.h b/Logs.h index 88bade05..dee95e5f 100644 --- a/Logs.h +++ b/Logs.h @@ -8,15 +8,21 @@ http://mozilla.org/MPL/2.0/. */ #pragma once + #include -void WriteConsoleOnly(const char *str, double value); -void WriteConsoleOnly(const char *str, bool newline = true); -void WriteLog(const char *str, double value); -void WriteLog(const char *str, bool newline = true); -void Error(const std::string &asMessage, bool box = false); -void Error(const char* &asMessage, bool box = false); -void ErrorLog(const std::string &str, bool newline = true); -void WriteLog(const std::string &str, bool newline = true); -void CommLog(const char *str); -void CommLog(const std::string &str); +enum logtype : unsigned int { + + generic = ( 1 << 0 ), + file = ( 1 << 1 ), + model = ( 1 << 2 ), + texture = ( 1 << 3 ) +}; + +void WriteLog( const char *str, logtype const Type = logtype::generic ); +void Error( const std::string &asMessage, bool box = false ); +void Error( const char* &asMessage, bool box = false ); +void ErrorLog( const std::string &str, logtype const Type = logtype::generic ); +void WriteLog( const std::string &str, logtype const Type = logtype::generic ); +void CommLog( const char *str ); +void CommLog( const std::string &str ); diff --git a/McZapkie/MOVER.h b/McZapkie/MOVER.h index ee072da9..57d948a1 100644 --- a/McZapkie/MOVER.h +++ b/McZapkie/MOVER.h @@ -78,15 +78,13 @@ zwiekszenie nacisku przy duzych predkosciach w hamulcach Oerlikona */ #include "dumb3d.h" -using namespace Math3D; + +extern int ConversionError; const double Steel2Steel_friction = 0.15; //tarcie statyczne const double g = 9.81; //przyspieszenie ziemskie const double SandSpeed = 0.1; //ile kg/s} -const double RVentSpeed = 0.4; //rozpedzanie sie wentylatora obr/s^2} -const double RVentMinI = 50.0; //przy jakim pradzie sie wylaczaja} const double Pirazy2 = 6.2831853071794f; -#define PI 3.1415926535897f //-- var, const, procedure --------------------------------------------------- static bool const Go = true; @@ -139,7 +137,57 @@ static int const ctrain_passenger = 16; //mostek przejściowy static int const ctrain_scndpneumatic = 32; //przewody 8 atm (żółte; zasilanie powietrzem) static int const ctrain_heating = 64; //przewody ogrzewania WN static int const ctrain_depot = 128; //nie rozłączalny podczas zwykłych manewrów (międzyczłonowy), we wpisie wartość ujemna +// vehicle sides; exclusive +enum side { + front = 0, + rear +}; +// possible coupling types; can be combined +enum coupling { + faux = 0x0, + coupler = 0x1, + brakehose = 0x2, + control = 0x4, + highvoltage = 0x8, + gangway = 0x10, + mainhose = 0x20, + heating = 0x40, + permanent = 0x80, + uic = 0x100 +}; +// possible effect ranges for control commands; exclusive +enum class range_t { + local, + unit, + consist +}; +// start method for devices; exclusive +enum class start_t { + manual, + automatic, + manualwithautofallback, + converter, + battery +}; +// recognized vehicle light locations and types; can be combined +enum light { + headlight_left = 0x01, + redmarker_left = 0x02, + headlight_upper = 0x04, + headlight_right = 0x10, + redmarker_right = 0x20, + rearendsignals = 0x40 +}; + +// door operation methods; exclusive +enum control_t { + passenger, // local, opened/closed for duration of loading + driver, // remote, operated by the driver + autonomous, // local, closed when vehicle moves and/or after timeout + conductor, // remote, operated by the conductor + mixed // primary manual but answers also to remote control +}; /*typ hamulca elektrodynamicznego*/ static int const dbrake_none = 0; static int const dbrake_passive = 1; @@ -159,19 +207,20 @@ static int const s_SHPebrake = 64; //hamuje static int const s_CAtest = 128; /*dzwieki*/ -static int const sound_none = 0; -static int const sound_loud = 1; -static int const sound_couplerstretch = 2; -static int const sound_bufferclamp = 4; -static int const sound_bufferbump = 8; -static int const sound_relay = 16; -static int const sound_manyrelay = 32; -static int const sound_brakeacc = 64; - -static bool PhysicActivationFlag = false; +enum sound { + none, + loud = 0x1, + couplerstretch = 0x2, + bufferclash = 0x4, + relay = 0x10, + parallel = 0x20, + shuntfield = 0x40, + pneumatic = 0x80 +}; //szczególne typy pojazdów (inna obsługa) dla zmiennej TrainType //zamienione na flagi bitowe, aby szybko wybierać grupę (np. EZT+SZT) +// TODO: convert to enums, they're used as specific checks anyway static int const dt_Default = 0; static int const dt_EZT = 1; static int const dt_ET41 = 2; @@ -182,6 +231,7 @@ static int const dt_SN61 = 0x20; //nie używane w warunkach, ale ustawiane z CHK static int const dt_EP05 = 0x40; static int const dt_ET40 = 0x80; static int const dt_181 = 0x100; +static int const dt_DMU = 0x200; //stałe dla asynchronów static int const eimc_s_dfic = 0; @@ -245,16 +295,16 @@ enum TProblem // lista problemów taboru, które uniemożliwiają jazdę /*lokacja*/ struct TLocation { - double X = 0.0; - double Y = 0.0; - double Z = 0.0; + double X; + double Y; + double Z; }; /*rotacja*/ struct TRotation { - double Rx = 0.0; - double Ry = 0.0; - double Rz = 0.0; + double Rx; + double Ry; + double Rz; }; /*wymiary*/ struct TDimension @@ -269,7 +319,8 @@ struct TCommand std::string Command; /*komenda*/ double Value1 = 0.0; /*argumenty komendy*/ double Value2 = 0.0; - TLocation Location; + int Coupling { coupling::control }; // coupler flag used to determine command propagation + TLocation Location; }; /*tory*/ @@ -301,13 +352,13 @@ struct TTractionParam /*powyzsze parametry zwiazane sa z torem po ktorym aktualnie pojazd jedzie*/ /*typy hamulcow zespolonych*/ -enum TBrakeSystem { Individual, Pneumatic, ElectroPneumatic }; +enum class TBrakeSystem { Individual, Pneumatic, ElectroPneumatic }; /*podtypy hamulcow zespolonych*/ -enum TBrakeSubSystem { ss_None, ss_W, ss_K, ss_KK, ss_Hik, ss_ESt, ss_KE, ss_LSt, ss_MT, ss_Dako }; -enum TBrakeValve { NoValve, W, W_Lu_VI, W_Lu_L, W_Lu_XR, K, Kg, Kp, Kss, Kkg, Kkp, Kks, Hikg1, Hikss, Hikp1, KE, SW, EStED, NESt3, ESt3, LSt, ESt4, ESt3AL2, EP1, EP2, M483, CV1_L_TR, CV1, CV1_R, Other }; -enum TBrakeHandle { NoHandle, West, FV4a, M394, M254, FVel1, FVel6, D2, Knorr, FD1, BS2, testH, St113, MHZ_P, MHZ_T, MHZ_EN57 }; +enum class TBrakeSubSystem { ss_None, ss_W, ss_K, ss_KK, ss_Hik, ss_ESt, ss_KE, ss_LSt, ss_MT, ss_Dako }; +enum class TBrakeValve { NoValve, W, W_Lu_VI, W_Lu_L, W_Lu_XR, K, Kg, Kp, Kss, Kkg, Kkp, Kks, Hikg1, Hikss, Hikp1, KE, SW, EStED, NESt3, ESt3, LSt, ESt4, ESt3AL2, EP1, EP2, M483, CV1_L_TR, CV1, CV1_R, Other }; +enum class TBrakeHandle { NoHandle, West, FV4a, M394, M254, FVel1, FVel6, D2, Knorr, FD1, BS2, testH, St113, MHZ_P, MHZ_T, MHZ_EN57, MHZ_K5P }; /*typy hamulcow indywidualnych*/ -enum TLocalBrake { NoBrake, ManualBrake, PneumaticBrake, HydraulicBrake }; +enum class TLocalBrake { NoBrake, ManualBrake, PneumaticBrake, HydraulicBrake }; /*dla osob/towar: opoznienie hamowania/odhamowania*/ typedef double TBrakeDelayTable[4]; @@ -316,17 +367,17 @@ struct TBrakePressure double PipePressureVal = 0.0; double BrakePressureVal = 0.0; double FlowSpeedVal = 0.0; - TBrakeSystem BrakeType = Pneumatic; + TBrakeSystem BrakeType = TBrakeSystem::Pneumatic; }; typedef std::map TBrakePressureTable; /*typy napedow*/ -enum TEngineTypes { None, Dumb, WheelsDriven, ElectricSeriesMotor, ElectricInductionMotor, DieselEngine, SteamEngine, DieselElectric }; +enum class TEngineType { None, Dumb, WheelsDriven, ElectricSeriesMotor, ElectricInductionMotor, DieselEngine, SteamEngine, DieselElectric }; /*postac dostarczanej energii*/ -enum TPowerType { NoPower, BioPower, MechPower, ElectricPower, SteamPower }; +enum class TPowerType { NoPower, BioPower, MechPower, ElectricPower, SteamPower }; /*rodzaj paliwa*/ -enum TFuelType { Undefined, Coal, Oil }; +enum class TFuelType { Undefined, Coal, Oil }; /*rodzaj rusztu*/ struct TGrateType { TFuelType FuelType; @@ -360,14 +411,14 @@ struct TBoilerType { }; /*rodzaj odbieraka pradu*/ struct TCurrentCollector { - long CollectorsNo; //musi być tu, bo inaczej się kopie - double MinH; double MaxH; //zakres ruchu pantografu, nigdzie nie używany - double CSW; //szerokość części roboczej (styku) ślizgacza - double MinV; double MaxV; //minimalne i maksymalne akceptowane napięcie - double OVP; //czy jest przekaznik nadnapieciowy - double InsetV; //minimalne napięcie wymagane do załączenia - double MinPress; //minimalne ciśnienie do załączenia WS - double MaxPress; //maksymalne ciśnienie za reduktorem + long CollectorsNo; //musi być tu, bo inaczej się kopie + double MinH; double MaxH; //zakres ruchu pantografu, nigdzie nie używany + double CSW; //szerokość części roboczej (styku) ślizgacza + double MinV; double MaxV; //minimalne i maksymalne akceptowane napięcie + bool OVP; //czy jest przekaznik nadnapieciowy + double InsetV; //minimalne napięcie wymagane do załączenia + double MinPress; //minimalne ciśnienie do załączenia WS + double MaxPress; //maksymalne ciśnienie za reduktorem //inline TCurrentCollector() { // CollectorsNo = 0; // MinH, MaxH, CSW, MinV, MaxV = 0.0; @@ -375,7 +426,7 @@ struct TCurrentCollector { //} }; /*typy źródeł mocy*/ -enum TPowerSource { NotDefined, InternalSource, Transducer, Generator, Accumulator, CurrentCollector, PowerCable, Heater }; +enum class TPowerSource { NotDefined, InternalSource, Transducer, Generator, Accumulator, CurrentCollector, PowerCable, Heater }; struct _mover__1 @@ -416,37 +467,30 @@ struct TPowerParameters struct { _mover__3 RHeater; - }; struct { _mover__2 RPowerCable; - }; struct { TCurrentCollector CollectorParameters; - }; struct { _mover__1 RAccumulator; - }; struct { - TEngineTypes GeneratorEngine; - + TEngineType GeneratorEngine; }; struct { double InputVoltage; - }; struct { TPowerType PowerType; - }; }; @@ -455,9 +499,9 @@ struct TPowerParameters MaxVoltage = 0.0; MaxCurrent = 0.0; IntR = 0.001; - SourceType = NotDefined; - PowerType = NoPower; - RPowerCable.PowerTrans = NoPower; + SourceType = TPowerSource::NotDefined; + PowerType = TPowerType::NoPower; + RPowerCable.PowerTrans = TPowerType::NoPower; } }; @@ -517,18 +561,18 @@ struct TMotorParameters struct TSecuritySystem { - int SystemType; /*0: brak, 1: czuwak aktywny, 2: SHP/sygnalizacja kabinowa*/ - double AwareDelay; // czas powtarzania czuwaka + int SystemType { 0 }; /*0: brak, 1: czuwak aktywny, 2: SHP/sygnalizacja kabinowa*/ + double AwareDelay { -1.0 }; // czas powtarzania czuwaka double AwareMinSpeed; // minimalna prędkość załączenia czuwaka, normalnie 10% Vmax - double SoundSignalDelay; - double EmergencyBrakeDelay; - int Status; /*0: wylaczony, 1: wlaczony, 2: czuwak, 4: shp, 8: alarm, 16: hamowanie awaryjne*/ - double SystemTimer; - double SystemSoundCATimer; - double SystemSoundSHPTimer; - double SystemBrakeCATimer; - double SystemBrakeSHPTimer; - double SystemBrakeCATestTimer; // hunter-091012 + double SoundSignalDelay { -1.0 }; + double EmergencyBrakeDelay { -1.0 }; + int Status { 0 }; /*0: wylaczony, 1: wlaczony, 2: czuwak, 4: shp, 8: alarm, 16: hamowanie awaryjne*/ + double SystemTimer { 0.0 }; + double SystemSoundCATimer { 0.0 }; + double SystemSoundSHPTimer { 0.0 }; + double SystemBrakeCATimer { 0.0 }; + double SystemBrakeSHPTimer { 0.0 }; + double SystemBrakeCATestTimer { 0.0 }; // hunter-091012 int VelocityAllowed; int NextVelocityAllowed; /*predkosc pokazywana przez sygnalizacje kabinowa*/ bool RadioStop; // czy jest RadioStop @@ -541,7 +585,13 @@ struct TTransmision double Ratio = 1.0; }; -enum TCouplerType { NoCoupler, Articulated, Bare, Chain, Screw, Automatic }; +enum class TCouplerType { NoCoupler, Articulated, Bare, Chain, Screw, Automatic }; + +struct power_coupling { + double current{ 0.0 }; + double voltage{ 0.0 }; + bool local{ false }; // whether the power comes from external or onboard source +}; struct TCoupling { /*parametry*/ @@ -552,7 +602,7 @@ struct TCoupling { double FmaxB = 1000.0; double DmaxC = 0.1; double FmaxC = 1000.0; - TCouplerType CouplerType = NoCoupler; /*typ sprzegu*/ + TCouplerType CouplerType = TCouplerType::NoCoupler; /*typ sprzegu*/ /*zmienne*/ int CouplingFlag = 0; /*0 - wirtualnie, 1 - sprzegi, 2 - pneumatycznie, 4 - sterowanie, 8 - kabel mocy*/ int AllowedFlag = 3; //Ra: znaczenie jak wyżej, maska dostępnych @@ -563,10 +613,129 @@ struct TCoupling { double CForce = 0.0; /*sila z jaka dzialal*/ double Dist = 0.0; /*strzalka ugiecia zderzaków*/ bool CheckCollision = false; /*czy sprawdzac sile czy pedy*/ + + power_coupling power_high; + power_coupling power_low; // TODO: implement this + + int sounds { 0 }; // sounds emitted by the coupling devices }; class TMoverParameters { // Ra: wrapper na kod pascalowy, przejmujący jego funkcje Q: 20160824 - juz nie wrapper a klasa bazowa :) +private: +// types + + // basic approximation of a generic device + // TBD: inheritance or composition? + struct basic_device { + // config + start_t start_type { start_t::manual }; + // ld inputs + bool is_enabled { false }; // device is allowed/requested to operate + bool is_disabled { false }; // device is requested to stop + // TODO: add remaining inputs; start conditions and potential breakers + // ld outputs + bool is_active { false }; // device is working + }; + + struct cooling_fan : public basic_device { + // config + float speed { 0.f }; // cooling fan rpm; either fraction of parent rpm, or absolute value if negative + // ld outputs + float revolutions { 0.f }; // current fan rpm + }; + + // basic approximation of a fuel pump + struct fuel_pump : public basic_device { + // TODO: fuel consumption, optional automatic engine start after activation + }; + + // basic approximation of an oil pump + struct oil_pump : public basic_device { + // config + float pressure_minimum { 0.f }; // lowest acceptable working pressure + float pressure_maximum { 0.65f }; // oil pressure at maximum engine revolutions + // ld inputs + float resource_amount { 1.f }; // amount of affected resource, compared to nominal value + // internal data + float pressure_target { 0.f }; + // ld outputs + float pressure { 0.f }; // current pressure + }; + + // basic approximation of a water pump + struct water_pump : public basic_device { + // ld inputs + // TODO: move to breaker list in the basic device once implemented + bool breaker { true }; // device is allowed to operate + }; + + struct water_heater { + // config + struct heater_config_t { + float temp_min { -1 }; // lowest accepted temperature + float temp_max { -1 }; // highest accepted temperature + } config; + // ld inputs + bool breaker { true }; // device is allowed to operate + bool is_enabled { false }; // device is requested to operate + // ld outputs + bool is_active { false }; // device is working + bool is_damaged { false }; // device is damaged + }; + + struct heat_data { + // input, state of relevant devices + bool cooling { false }; // TODO: user controlled device, implement + // bool okienko { true }; // window in the engine compartment + // system configuration + bool auxiliary_water_circuit { false }; // cooling system has an extra water circuit + double fan_speed { 0.075 }; // cooling fan rpm; either fraction of engine rpm, or absolute value if negative + // heat exchange factors + double kw { 0.35 }; + double kv { 0.6 }; + double kfe { 1.0 }; + double kfs { 80.0 }; + double kfo { 25.0 }; + double kfo2 { 25.0 }; + // system parts + struct fluid_circuit_t { + + struct circuit_config_t { + float temp_min { -1 }; // lowest accepted temperature + float temp_max { -1 }; // highest accepted temperature + float temp_cooling { -1 }; // active cooling activation point + float temp_flow { -1 }; // fluid flow activation point + bool shutters { false }; // the radiator has shutters to assist the cooling + } config; + bool is_cold { false }; // fluid is too cold + bool is_warm { false }; // fluid is too hot + bool is_hot { false }; // fluid temperature crossed cooling threshold + bool is_flowing { false }; // fluid is being pushed through the circuit + } water, + water_aux, + oil; + // output, state of affected devices + bool PA { false }; // malfunction flag + float rpmw { 0.0 }; // current main circuit fan revolutions + float rpmwz { 0.0 }; // desired main circuit fan revolutions + bool zaluzje1 { false }; + float rpmw2 { 0.0 }; // current auxiliary circuit fan revolutions + float rpmwz2 { 0.0 }; // desired auxiliary circuit fan revolutions + bool zaluzje2 { false }; + // output, temperatures + float Te { 15.0 }; // ambient temperature TODO: get it from environment data + // NOTE: by default the engine is initialized in warm, startup-ready state + float Ts { 50.0 }; // engine temperature + float To { 45.0 }; // oil temperature + float Tsr { 50.0 }; // main circuit radiator temperature (?) + float Twy { 50.0 }; // main circuit water temperature + float Tsr2 { 40.0 }; // secondary circuit radiator temperature (?) + float Twy2 { 40.0 }; // secondary circuit water temperature + float temperatura1 { 50.0 }; + float temperatura2 { 40.0 }; + }; + public: double dMoveLen = 0.0; @@ -578,7 +747,7 @@ public: std::string TypeName; /*nazwa serii/typu*/ //TrainType: string; {typ: EZT/elektrowoz - Winger 040304} int TrainType = 0; /*Ra: powinno być szybciej niż string*/ - TEngineTypes EngineType = None; /*typ napedu*/ + TEngineType EngineType = TEngineType::None; /*typ napedu*/ TPowerParameters EnginePowerSource; /*zrodlo mocy dla silnikow*/ TPowerParameters SystemPowerSource; /*zrodlo mocy dla systemow sterowania/przetwornic/sprezarek*/ TPowerParameters HeatingPowerSource; /*zrodlo mocy dla ogrzewania*/ @@ -591,21 +760,21 @@ public: double Mred = 0.0; /*Ra: zredukowane masy wirujące; potrzebne do obliczeń hamowania*/ double TotalMass = 0.0; /*wyliczane przez ComputeMass*/ double HeatingPower = 0.0; + double EngineHeatingRPM { 0.0 }; // guaranteed engine revolutions with heating enabled double LightPower = 0.0; /*moc pobierana na ogrzewanie/oswietlenie*/ double BatteryVoltage = 0.0; /*Winger - baterie w elektrykach*/ bool Battery = false; /*Czy sa zalavzone baterie*/ bool EpFuse = true; /*Czy sa zalavzone baterie*/ bool Signalling = false; /*Czy jest zalaczona sygnalizacja hamowania ostatniego wagonu*/ - bool DoorSignalling = false; /*Czy jest zalaczona sygnalizacja blokady drzwi*/ bool Radio = true; /*Czy jest zalaczony radiotelefon*/ - double NominalBatteryVoltage = 0.0; /*Winger - baterie w elektrykach*/ + float NominalBatteryVoltage = 0.f; /*Winger - baterie w elektrykach*/ TDimension Dim; /*wymiary*/ double Cx = 0.0; /*wsp. op. aerodyn.*/ - double Floor = 0.96; //poziom podłogi dla ładunków - double WheelDiameter = 1.0; /*srednica kol napednych*/ - double WheelDiameterL = 0.9; //Ra: srednica kol tocznych przednich - double WheelDiameterT = 0.9; //Ra: srednica kol tocznych tylnych - double TrackW = 1.435; /*nominalna szerokosc toru [m]*/ + float Floor = 0.96f; //poziom podłogi dla ładunków + float WheelDiameter = 1.f; /*srednica kol napednych*/ + float WheelDiameterL = 0.9f; //Ra: srednica kol tocznych przednich + float WheelDiameterT = 0.9f; //Ra: srednica kol tocznych tylnych + float TrackW = 1.435f; /*nominalna szerokosc toru [m]*/ double AxleInertialMoment = 0.0; /*moment bezwladnosci zestawu kolowego*/ std::string AxleArangement; /*uklad osi np. Bo'Bo' albo 1'C*/ int NPoweredAxles = 0; /*ilosc osi napednych liczona z powyzszego*/ @@ -615,11 +784,11 @@ public: /*hamulce:*/ int NBpA = 0; /*ilosc el. ciernych na os: 0 1 2 lub 4*/ int SandCapacity = 0; /*zasobnik piasku [kg]*/ - TBrakeSystem BrakeSystem = Individual;/*rodzaj hamulca zespolonego*/ - TBrakeSubSystem BrakeSubsystem = ss_None ; - TBrakeValve BrakeValve = NoValve; - TBrakeHandle BrakeHandle = NoHandle; - TBrakeHandle BrakeLocHandle = NoHandle; + TBrakeSystem BrakeSystem = TBrakeSystem::Individual;/*rodzaj hamulca zespolonego*/ + TBrakeSubSystem BrakeSubsystem = TBrakeSubSystem::ss_None ; + TBrakeValve BrakeValve = TBrakeValve::NoValve; + TBrakeHandle BrakeHandle = TBrakeHandle::NoHandle; + TBrakeHandle BrakeLocHandle = TBrakeHandle::NoHandle; double MBPM = 1.0; /*masa najwiekszego cisnienia*/ std::shared_ptr Hamulec; @@ -628,7 +797,7 @@ public: std::shared_ptr Pipe; std::shared_ptr Pipe2; - TLocalBrake LocalBrake = NoBrake; /*rodzaj hamulca indywidualnego*/ + TLocalBrake LocalBrake = TLocalBrake::NoBrake; /*rodzaj hamulca indywidualnego*/ TBrakePressureTable BrakePressureTable; /*wyszczegolnienie cisnien w rurze*/ TBrakePressure BrakePressureActual; //wartości ważone dla aktualnej pozycji kranu int ASBType = 0; /*0: brak hamulca przeciwposlizgowego, 1: reczny, 2: automat*/ @@ -658,6 +827,7 @@ public: double BrakeSlckAdj = 0.0; /*opor nastawiacza skoku tloka, kN*/ double BrakeRigEff = 0.0; /*sprawnosc przekladni dzwigniowej*/ double RapidMult = 1.0; /*przelozenie rapidu*/ + double RapidVel = 55.0; /*szybkosc przelaczania rapidu*/ int BrakeValveSize = 0; std::string BrakeValveParams; double Spg = 0.0; @@ -666,15 +836,16 @@ public: double CompressorSpeed = 0.0; /*cisnienie wlaczania, zalaczania sprezarki, wydajnosc sprezarki*/ TBrakeDelayTable BrakeDelay; /*opoznienie hamowania/odhamowania t/o*/ + double AirLeakRate{ 0.01 }; // base rate of air leak from brake system components ( 0.001 = 1 l/sec ) int BrakeCtrlPosNo = 0; /*ilosc pozycji hamulca*/ /*nastawniki:*/ int MainCtrlPosNo = 0; /*ilosc pozycji nastawnika*/ int ScndCtrlPosNo = 0; - int LightsPosNo = 0; // NOTE: values higher than 0 seem to break the current code for light switches + int LightsPosNo = 0; int LightsDefPos = 1; bool LightsWrap = false; int Lights[2][17]; // pozycje świateł, przód - tył, 1 .. 16 - bool ScndInMain = false; /*zaleznosc bocznika od nastawnika*/ + int ScndInMain{ 0 }; /*zaleznosc bocznika od nastawnika*/ bool MBrake = false; /*Czy jest hamulec reczny*/ double StopBrakeDecc = 0.0; TSecuritySystem SecuritySystem; @@ -695,7 +866,8 @@ public: double u = 0.0; //wspolczynnik tarcia yB wywalic!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! double CircuitRes = 0.0; /*rezystancje silnika i obwodu*/ int IminLo = 0; int IminHi = 0; /*prady przelacznika automatycznego rozruchu, uzywane tez przez ai_driver*/ - int ImaxLo = 0; int ImaxHi = 0; /*maksymalny prad niskiego i wysokiego rozruchu*/ + int ImaxLo = 0; // maksymalny prad niskiego rozruchu + int ImaxHi = 0; // maksymalny prad wysokiego rozruchu double nmax = 0.0; /*maksymalna dop. ilosc obrotow /s*/ double InitialCtrlDelay = 0.0; double CtrlDelay = 0.0; /* -//- -//- miedzy kolejnymi poz.*/ double CtrlDownDelay = 0.0; /* -//- -//- przy schodzeniu z poz.*/ /*hunter-101012*/ @@ -705,10 +877,19 @@ public: //CouplerNr: TCouplerNr; {ABu: nr sprzegu podlaczonego w drugim obiekcie} bool IsCoupled = false; /*czy jest sprzezony ale jedzie z tylu*/ int DynamicBrakeType = 0; /*patrz dbrake_**/ + int DynamicBrakeAmpmeters = 2; /*liczba amperomierzy przy hamowaniu ED*/ + double DynamicBrakeRes = 5.8; /*rezystancja oporników przy hamowaniu ED*/ + double TUHEX_Sum = 750; /*nastawa sterownika hamowania ED*/ + double TUHEX_Diff = 10; /*histereza działania sterownika hamowania ED*/ + double TUHEX_MinIw = 60; /*minimalny prąd wzbudzenia przy hamowaniu ED - wynika z chk silnika*/ + double TUHEX_MaxIw = 400; /*maksymalny prąd wzbudzenia przy hamowaniu ED - ograniczenie max siły*/ + int RVentType = 0; /*0 - brak, 1 - jest, 2 - automatycznie wlaczany*/ double RVentnmax = 1.0; /*maks. obroty wentylatorow oporow rozruchowych*/ double RVentCutOff = 0.0; /*rezystancja wylaczania wentylatorow dla RVentType=2*/ - int CompressorPower = 1; /*0: bezp. z obwodow silnika, 1: z przetwornicy, reczne, 2: w przetwornicy, stale, 5: z silnikowego*/ + double RVentSpeed { 0.5 }; //rozpedzanie sie wentylatora obr/s^2} + double RVentMinI { 50.0 }; //przy jakim pradzie sie wylaczaja} + int CompressorPower = 1; // 0: main circuit, 1: z przetwornicy, reczne, 2: w przetwornicy, stale, 3: diesel engine, 4: converter of unit in front, 5: converter of unit behind int SmallCompressorPower = 0; /*Winger ZROBIC*/ bool Trafo = false; /*pojazd wyposażony w transformator*/ @@ -726,6 +907,31 @@ public: double dizel_minVelfullengage = 0.0; /*najmniejsza predkosc przy jezdzie ze sprzeglem bez poslizgu*/ double dizel_AIM = 1.0; /*moment bezwladnosci walu itp*/ double dizel_engageDia = 0.5; double dizel_engageMaxForce = 6000.0; double dizel_engagefriction = 0.5; /*parametry sprzegla*/ + double engagedownspeed = 0.9; + double engageupspeed = 0.5; + /*parametry przetwornika momentu*/ + bool hydro_TC = false; /*obecnosc hydraulicznego przetwornika momentu*/ + double hydro_TC_TMMax = 2.0; /*maksymalne wzmocnienie momentu*/ + double hydro_TC_CouplingPoint = 0.85; /*wzgledna predkosc zasprzeglenia*/ + double hydro_TC_LockupTorque = 3000.0; /*moment graniczny sprzegla blokujacego*/ + double hydro_TC_LockupRate = 1.0; /*szybkosc zalaczania sprzegla blokujacego*/ + double hydro_TC_UnlockRate = 1.0; /*szybkosc rozlaczania sprzegla blokujacego*/ + double hydro_TC_FillRateInc = 1.0; /*szybkosc napelniania sprzegla*/ + double hydro_TC_FillRateDec = 1.0; /*szybkosc oprozniania sprzegla*/ + double hydro_TC_TorqueInIn = 4.5; /*stala momentu proporcjonalnego do kwadratu obrotow wejsciowych*/ + double hydro_TC_TorqueInOut = 0.0; /*stala momentu proporcjonalnego do roznica obrotow wejsciowych i wyjsciowych*/ + double hydro_TC_TorqueOutOut = 0.0; /*stala momentu proporcjonalnego do kwadratu obrotow wyjsciowych*/ + double hydro_TC_LockupSpeed = 1.0; /*prog predkosci zalaczania sprzegla blokujacego*/ + double hydro_TC_UnlockSpeed = 1.0; /*prog predkosci rozlaczania sprzegla blokujacego*/ + /*parametry retardera*/ + bool hydro_R = false; /*obecnosc retardera*/ + int hydro_R_Placement = 0; /*umiejscowienie retardera: 0 - za skrzynia biegow, 1 - miedzy przetwornikiem a biegami, 2 - przed skrzynia biegow */ + double hydro_R_TorqueInIn = 1.0; /*stala momentu proporcjonalnego do kwadratu obrotow wejsciowych*/ + double hydro_R_MaxTorque = 1.0; /*maksymalny moment retardera*/ + double hydro_R_MaxPower = 1.0; /*maksymalna moc retardera - ogranicza moment*/ + double hydro_R_FillRateInc = 1.0; /*szybkosc napelniania sprzegla*/ + double hydro_R_FillRateDec = 1.0; /*szybkosc oprozniania sprzegla*/ + double hydro_R_MinVel = 1.0; /*minimalna predkosc, przy ktorej retarder dziala*/ /*- dla lokomotyw spalinowo-elektrycznych -*/ double AnPos = 0.0; // pozycja sterowania dokladnego (analogowego) bool AnalogCtrl = false; // @@ -745,38 +951,70 @@ public: double Ftmax = 0.0; /*- dla lokomotyw z silnikami indukcyjnymi -*/ double eimc[26]; + bool EIMCLogForce = false; // + static std::vector const eimc_labels; + double InverterFrequency { 0.0 }; // current frequency of power inverters + /* -dla pojazdów z blendingiem EP/ED (MED) */ + double MED_Vmax = 0; // predkosc maksymalna dla obliczen chwilowej sily hamowania EP w MED + double MED_Vmin = 0; // predkosc minimalna dla obliczen chwilowej sily hamowania EP w MED + double MED_Vref = 0; // predkosc referencyjna dla obliczen dostepnej sily hamowania EP w MED + double MED_amax = 9.81; // maksymalne opoznienie hamowania sluzbowego MED + bool MED_EPVC = 0; // czy korekcja sily hamowania EP, gdy nie ma dostepnego ED + double MED_EPVC_Time = 7; // czas korekcji sily hamowania EP, gdy nie ma dostepnego ED + bool MED_Ncor = 0; // czy korekcja sily hamowania z uwzglednieniem nacisku /*-dla wagonow*/ - double MaxLoad = 0.0; /*masa w T lub ilosc w sztukach - ladownosc*/ - std::string LoadAccepted; std::string LoadQuantity; /*co moze byc zaladowane, jednostki miary*/ - double OverLoadFactor = 0.0; /*ile razy moze byc przekroczona ladownosc*/ - double LoadSpeed = 0.0; double UnLoadSpeed = 0.0;/*szybkosc na- i rozladunku jednostki/s*/ + struct load_attributes { + std::string name; // name of the cargo + float offset_min { 0.f }; // offset applied to cargo model when load amount is 0 + + load_attributes() = default; + load_attributes( std::string const &Name, float const Offsetmin ) : + name( Name ), offset_min( Offsetmin ) + {} + }; + std::vector LoadAttributes; + float MaxLoad = 0.f; /*masa w T lub ilosc w sztukach - ladownosc*/ + double OverLoadFactor = 0.0; /*ile razy moze byc przekroczona ladownosc*/ + float LoadSpeed = 0.f; float UnLoadSpeed = 0.f;/*szybkosc na- i rozladunku jednostki/s*/ int DoorOpenCtrl = 0; int DoorCloseCtrl = 0; /*0: przez pasazera, 1: przez maszyniste, 2: samoczynne (zamykanie)*/ double DoorStayOpen = 0.0; /*jak dlugo otwarte w przypadku DoorCloseCtrl=2*/ bool DoorClosureWarning = false; /*czy jest ostrzeganie przed zamknieciem*/ + bool DoorClosureWarningAuto = false; // departure signal plays automatically while door closing button is held down double DoorOpenSpeed = 1.0; double DoorCloseSpeed = 1.0; /*predkosc otwierania i zamykania w j.u. */ - double DoorMaxShiftL = 0.5; double DoorMaxShiftR = 0.5; double DoorMaxPlugShift = 0.5;/*szerokosc otwarcia lub kat*/ + double DoorMaxShiftL = 0.5; double DoorMaxShiftR = 0.5; double DoorMaxPlugShift = 0.1;/*szerokosc otwarcia lub kat*/ int DoorOpenMethod = 2; /*sposob otwarcia - 1: przesuwne, 2: obrotowe, 3: trójelementowe*/ - double PlatformSpeed = 0.25; /*szybkosc stopnia*/ - double PlatformMaxShift = 0.5; /*wysuniecie stopnia*/ - int PlatformOpenMethod = 1; /*sposob animacji stopnia*/ + float DoorCloseDelay { 0.f }; // delay (in seconds) before the door begin closing, once conditions to close are met + double PlatformSpeed = 0.5; /*szybkosc stopnia*/ + double PlatformMaxShift { 0.0 }; /*wysuniecie stopnia*/ + int PlatformOpenMethod { 2 }; /*sposob animacji stopnia*/ + double MirrorMaxShift { 90.0 }; bool ScndS = false; /*Czy jest bocznikowanie na szeregowej*/ + double SpeedCtrlDelay = 2; /*opoznienie dzialania tempomatu z wybieralna predkoscia*/ /*--sekcja zmiennych*/ /*--opis konkretnego egzemplarza taboru*/ - TLocation Loc; //pozycja pojazdów do wyznaczenia odległości pomiędzy sprzęgami - TRotation Rot; + TLocation Loc { 0.0, 0.0, 0.0 }; //pozycja pojazdów do wyznaczenia odległości pomiędzy sprzęgami + TRotation Rot { 0.0, 0.0, 0.0 }; std::string Name; /*nazwa wlasna*/ TCoupling Couplers[2]; //urzadzenia zderzno-sprzegowe, polaczenia miedzy wagonami - double HVCouplers[2][2]; //przewod WN - int ScanCounter = 0; /*pomocnicze do skanowania sprzegow*/ +#ifdef EU07_USE_OLD_HVCOUPLERS + double HVCouplers[ 2 ][ 2 ]; //przewod WN + enum hvcoupler { + current = 0, + voltage + }; +#endif bool EventFlag = false; /*!o true jesli cos nietypowego sie wydarzy*/ int SoundFlag = 0; /*!o patrz stale sound_ */ double DistCounter = 0.0; /*! licznik kilometrow */ double V = 0.0; //predkosc w [m/s] względem sprzęgów (dodania gdy jedzie w stronę 0) double Vel = 0.0; //moduł prędkości w [km/h], używany przez AI double AccS = 0.0; //efektywne przyspieszenie styczne w [m/s^2] (wszystkie siły) - double AccN = 0.0; //przyspieszenie normalne w [m/s^2] - double AccV = 0.0; + double AccSVBased {}; // tangential acceleration calculated from velocity change + double AccN = 0.0; // przyspieszenie normalne w [m/s^2] + double AccVert = 0.0; // vertical acceleration double nrot = 0.0; + double WheelFlat = 0.0; + bool TruckHunting { true }; // enable/disable truck hunting calculation /*! rotacja kol [obr/s]*/ double EnginePower = 0.0; /*! chwilowa moc silnikow*/ double dL = 0.0; double Fb = 0.0; double Ff = 0.0; /*przesuniecie, sila hamowania i tarcia*/ @@ -802,16 +1040,35 @@ public: bool CompressorFlag = false; /*!o czy wlaczona sprezarka*/ bool PantCompFlag = false; /*!o czy wlaczona sprezarka pantografow*/ bool CompressorAllow = false; /*! zezwolenie na uruchomienie sprezarki NBMX*/ - bool ConverterFlag = false ; /*! czy wlaczona przetwornica NBMX*/ + bool CompressorAllowLocal{ true }; // local device state override (most units don't have this fitted so it's set to true not to intefere) + bool CompressorGovernorLock{ false }; // indicates whether compressor pressure switch was activated due to reaching cut-out pressure + start_t CompressorStart{ start_t::manual }; // whether the compressor is started manually, or another way + // TODO converter parameters, for when we start cleaning up mover parameters + start_t ConverterStart{ start_t::manual }; // whether converter is started manually, or by other means + float ConverterStartDelay{ 0.0f }; // delay (in seconds) before the converter is started, once its activation conditions are met + double ConverterStartDelayTimer{ 0.0 }; // helper, for tracking whether converter start delay passed bool ConverterAllow = false; /*zezwolenie na prace przetwornicy NBMX*/ - int BrakeCtrlPos = -2; /*nastawa hamulca zespolonego*/ + bool ConverterAllowLocal{ true }; // local device state override (most units don't have this fitted so it's set to true not to intefere) + bool ConverterFlag = false; /*! czy wlaczona przetwornica NBMX*/ + fuel_pump FuelPump; + oil_pump OilPump; + water_pump WaterPump; + water_heater WaterHeater; + bool WaterCircuitsLink { false }; // optional connection between water circuits + heat_data dizel_heat; + std::array MotorBlowers; + + int BrakeCtrlPos = -2; /*nastawa hamulca zespolonego*/ double BrakeCtrlPosR = 0.0; /*nastawa hamulca zespolonego - plynna dla FV4a*/ double BrakeCtrlPos2 = 0.0; /*nastawa hamulca zespolonego - kapturek dla FV4a*/ - int LocalBrakePos = 0; /*nastawa hamulca indywidualnego*/ int ManualBrakePos = 0; /*nastawa hamulca recznego*/ - double LocalBrakePosA = 0.0; - int BrakeStatus = b_off; /*0 - odham, 1 - ham., 2 - uszk., 4 - odluzniacz, 8 - antyposlizg, 16 - uzyte EP, 32 - pozycja R, 64 - powrot z R*/ - bool EmergencyBrakeFlag = false; /*hamowanie nagle*/ + double LocalBrakePosA = 0.0; /*nastawa hamulca pomocniczego*/ + double LocalBrakePosAEIM = 0.0; /*pozycja hamulca pomocniczego ep dla asynchronicznych ezt*/ +/* + int BrakeStatus = b_off; //0 - odham, 1 - ham., 2 - uszk., 4 - odluzniacz, 8 - antyposlizg, 16 - uzyte EP, 32 - pozycja R, 64 - powrot z R +*/ + bool AlarmChainFlag = false; // manual emergency brake + bool RadioStopFlag = false; /*hamowanie nagle*/ int BrakeDelayFlag = 0; /*nastawa opoznienia ham. osob/towar/posp/exp 0/1/2/4*/ int BrakeDelays = 0; /*nastawy mozliwe do uzyskania*/ int BrakeOpModeFlag = 0; /*nastawa trybu pracy PS/PN/EP/MED 1/2/4/8*/ @@ -850,22 +1107,26 @@ public: int DirAbsolute = 0; //zadany kierunek jazdy względem sprzęgów (1=w strone 0,-1=w stronę 1) int ActiveCab = 0; //numer kabiny, w ktorej jest obsada (zwykle jedna na skład) double LastSwitchingTime = 0.0; /*czas ostatniego przelaczania czegos*/ - //WarningSignal: byte; {0: nie trabi, 1,2: trabi} + int WarningSignal = 0; // 0: nie trabi, 1,2,4: trabi bool DepartureSignal = false; /*sygnal odjazdu*/ bool InsideConsist = false; /*-zmienne dla lokomotywy elektrycznej*/ TTractionParam RunningTraction;/*parametry sieci trakcyjnej najblizej lokomotywy*/ - double enrot = 0.0; - double Im = 0.0; - double Itot = 0.0; + double enrot = 0.0; // ilosc obrotow silnika + double Im = 0.0; // prad silnika +/* + // currently not used double IHeating = 0.0; double ITraction = 0.0; +*/ + double Itot = 0.0; // prad calkowity double TotalCurrent = 0.0; + // momenty double Mm = 0.0; double Mw = 0.0; + // sily napedne double Fw = 0.0; double Ft = 0.0; - /*ilosc obrotow, prad silnika i calkowity, momenty, sily napedne*/ //Ra: Im jest ujemny, jeśli lok jedzie w stronę sprzęgu 1 //a ujemne powinien być przy odwróconej polaryzacji sieci... //w wielu miejscach jest używane abs(Im) @@ -879,22 +1140,51 @@ public: bool FuseFlag = false; /*!o bezpiecznik nadmiarowy*/ bool ConvOvldFlag = false; /*! nadmiarowy przetwornicy i ogrzewania*/ bool StLinFlag = false; /*!o styczniki liniowe*/ + bool StLinSwitchOff{ false }; // state of the button forcing motor connectors open bool ResistorsFlag = false; /*!o jazda rezystorowa*/ double RventRot = 0.0; /*!s obroty wentylatorow rozruchowych*/ - bool UnBrake = false; /*w EZT - nacisniete odhamowywanie*/ + bool UnBrake = false; /*w EZT - nacisniete odhamowywanie*/ double PantPress = 0.0; /*Cisnienie w zbiornikach pantografow*/ - bool s_CAtestebrake = false; //hunter-091012: zmienna dla testu ca + bool PantPressSwitchActive{ false }; // state of the pantograph pressure switch. gets primed at defined pressure level in pantograph air system + bool PantPressLockActive{ false }; // pwr system state flag. fires when pressure switch activates by pantograph pressure dropping below defined level + bool NoVoltRelay{ true }; // switches off if the power level drops below threshold + bool OvervoltageRelay{ true }; // switches off if the power level goes above threshold + bool s_CAtestebrake = false; //hunter-091012: zmienna dla testu ca /*-zmienne dla lokomotywy spalinowej z przekladnia mechaniczna*/ double dizel_fill = 0.0; /*napelnienie*/ double dizel_engagestate = 0.0; /*sprzeglo skrzyni biegow: 0 - luz, 1 - wlaczone, 0.5 - wlaczone 50% (z poslizgiem)*/ double dizel_engage = 0.0; /*sprzeglo skrzyni biegow: aktualny docisk*/ double dizel_automaticgearstatus = 0.0; /*0 - bez zmiany, -1 zmiana na nizszy +1 zmiana na wyzszy*/ - bool dizel_enginestart = false; /*czy trwa rozruch silnika*/ + bool dizel_startup { false }; // engine startup procedure request indicator + bool dizel_ignition { false }; // engine ignition request indicator + bool dizel_spinup { false }; // engine spin up to idle speed flag double dizel_engagedeltaomega = 0.0; /*roznica predkosci katowych tarcz sprzegla*/ + double dizel_n_old = 0.0; /*poredkosc na potrzeby obliczen sprzegiel*/ + double dizel_Torque = 0.0; /*poredkosc na potrzeby obliczen sprzegiel*/ + + /* - zmienne dla przetowrnika momentu */ + double hydro_TC_Fill = 0.0; /*napelnienie*/ + bool hydro_TC_Lockup = false; /*zapiecie sprzegla*/ + double hydro_TC_TorqueIn = 0.0; /*moment*/ + double hydro_TC_TorqueOut = 0.0; /*moment*/ + double hydro_TC_TMRatio = 1.0; /*aktualne przelozenie momentu*/ + double hydro_TC_Request = 0.0; /*zadanie sily*/ + double hydro_TC_nIn = 0.0; /*predkosc obrotowa walu wejsciowego*/ + double hydro_TC_nOut = 0.0; /*predkosc obrotowa walu wyjsciowego*/ + + /* - zmienne dla przetowrnika momentu */ + double hydro_R_Fill = 0.0; /*napelnienie*/ + double hydro_R_Torque = 0.0; /*moment*/ + double hydro_R_Request = 0.0; /*zadanie sily hamowania*/ + double hydro_R_n = 0.0; /*predkosc obrotowa retardera*/ /*- zmienne dla lokomotyw z silnikami indukcyjnymi -*/ double eimv[21]; + static std::vector const eimv_labels; + double SpeedCtrlTimer = 0; /*zegar dzialania tempomatu z wybieralna predkoscia*/ + double NewSpeed = 0; /*nowa predkosc do zadania*/ + double MED_EPVC_CurrentTime = 0; /*aktualny czas licznika czasu korekcji siły EP*/ /*-zmienne dla drezyny*/ double PulseForce = 0.0; /*przylozona sila*/ @@ -902,18 +1192,22 @@ public: int PulseForceCount = 0; /*dla drezyny, silnika spalinowego i parowego*/ - double eAngle = 1.5; + double eAngle = M_PI * 0.5; /*-dla wagonow*/ - double Load = 0.0; /*masa w T lub ilosc w sztukach - zaladowane*/ - std::string LoadType; /*co jest zaladowane*/ - int LoadStatus = 0; //+1=trwa rozladunek,+2=trwa zaladunek,+4=zakończono,0=zaktualizowany model + float LoadAmount = 0.f; /*masa w T lub ilosc w sztukach - zaladowane*/ + load_attributes LoadType; + std::string LoadQuantity; // jednostki miary + int LoadStatus = 0; //+1=trwa rozladunek,+2=trwa zaladunek,+4=zakończono,0=zaktualizowany model double LastLoadChangeTime = 0.0; //raz (roz)ładowania bool DoorBlocked = false; //Czy jest blokada drzwi + bool DoorLockEnabled { true }; bool DoorLeftOpened = false; //stan drzwi + double DoorLeftOpenTimer { -1.0 }; // left door closing timer for automatic door type bool DoorRightOpened = false; - bool PantFrontUp = false; //stan patykow 'Winger 160204 + double DoorRightOpenTimer{ -1.0 }; // right door closing timer for automatic door type + bool PantFrontUp = false; //stan patykow 'Winger 160204 bool PantRearUp = false; bool PantFrontSP = true; //dzwiek patykow 'Winger 010304 bool PantRearSP = true; @@ -921,8 +1215,10 @@ public: int PantRearStart = 0; double PantFrontVolt = 0.0; //pantograf pod napieciem? 'Winger 160404 double PantRearVolt = 0.0; + // TODO: move these switch types where they belong, cabin definition std::string PantSwitchType; std::string ConvSwitchType; + std::string StLinSwitchType; bool Heating = false; //ogrzewanie 'Winger 020304 int DoubleTr = 1; //trakcja ukrotniona - przedni pojazd 'Winger 160304 @@ -935,10 +1231,7 @@ public: double FrictConst2d= 0.0; double TotalMassxg = 0.0; /*TotalMass*g*/ - vector3 vCoulpler[2]; // powtórzenie współrzędnych sprzęgów z DynObj :/ - vector3 DimHalf; // połowy rozmiarów do obliczeń geometrycznych - // int WarningSignal; //0: nie trabi, 1,2: trabi syreną o podanym numerze - int WarningSignal = 0; // tymczasowo 8bit, ze względu na funkcje w MTools + Math3D::vector3 vCoulpler[2]; // powtórzenie współrzędnych sprzęgów z DynObj :/ double fBrakeCtrlPos = -2.0; // płynna nastawa hamulca zespolonego bool bPantKurek3 = true; // kurek trójdrogowy (pantografu): true=połączenie z ZG, false=połączenie z małą sprężarką // domyślnie zbiornik pantografu połączony jest ze zbiornikiem głównym int iProblem = 0; // flagi problemów z taborem, aby AI nie musiało porównywać; 0=może jechać @@ -947,7 +1240,7 @@ private: double CouplerDist(int Coupler); public: - TMoverParameters(double VelInitial, std::string TypeNameInit, std::string NameInit, int LoadInitial, std::string LoadTypeInitial, int Cab); + TMoverParameters(double VelInitial, std::string TypeNameInit, std::string NameInit, int Cab); // obsługa sprzęgów double Distance(const TLocation &Loc1, const TLocation &Loc2, const TDimension &Dim1, const TDimension &Dim2); /* double Distance(const vector3 &Loc1, const vector3 &Loc2, const vector3 &Dim1, const vector3 &Dim2); @@ -962,10 +1255,11 @@ public: bool IncBrakeLevel(); // wersja na użytek AI bool DecBrakeLevel(); bool ChangeCab(int direction); - bool CurrentSwitch(int direction); + bool CurrentSwitch(bool const State); void UpdateBatteryVoltage(double dt); double ComputeMovement(double dt, double dt1, const TTrackShape &Shape, TTrackParam &Track, TTractionParam &ElectricTraction, const TLocation &NewLoc, TRotation &NewRot); //oblicza przesuniecie pojazdu double FastComputeMovement(double dt, const TTrackShape &Shape, TTrackParam &Track, const TLocation &NewLoc, TRotation &NewRot); //oblicza przesuniecie pojazdu - wersja zoptymalizowana + void compute_movement_( double const Deltatime ); double ShowEngineRotation(int VehN); // Q ******************************************************************************************* @@ -975,15 +1269,15 @@ public: double ManualBrakeRatio(void); double PipeRatio(void);/*ile napelniac*/ double RealPipeRatio(void);/*jak szybko*/ - double BrakeVP(void); + double BrakeVP(void) const; /*! przesylanie komend sterujacych*/ bool SendCtrlBroadcast(std::string CtrlCommand, double ctrlvalue); - bool SendCtrlToNext(std::string CtrlCommand, double ctrlvalue, double dir); - bool SetInternalCommand(std::string NewCommand, double NewValue1, double NewValue2); + bool SendCtrlToNext(std::string const CtrlCommand, double const ctrlvalue, double const dir, int const Couplertype = ctrain_controll); + bool SetInternalCommand( std::string NewCommand, double NewValue1, double NewValue2, int const Couplertype = ctrain_controll ); double GetExternalCommand(std::string &Command); - bool RunCommand(std::string Command, double CValue1, double CValue2); - bool RunInternalCommand(void); + bool RunCommand( std::string Command, double CValue1, double CValue2, int const Couplertype = ctrain_controll ); + bool RunInternalCommand(); void PutCommand(std::string NewCommand, double NewValue1, double NewValue2, const TLocation &NewLocation); bool CabActivisation(void); bool CabDeactivisation(void); @@ -999,7 +1293,7 @@ public: bool AddPulseForce(int Multipler);/*dla drezyny*/ - bool SandDoseOn(void);/*wlacza/wylacza sypanie piasku*/ + bool Sandbox( bool const State, range_t const Notify = range_t::consist );/*wlacza/wylacza sypanie piasku*/ /*! zbijanie czuwaka/SHP*/ void SSReset(void); @@ -1012,15 +1306,14 @@ public: /*! stopnie hamowania - hamulec zasadniczy*/ bool IncBrakeLevelOld(void); bool DecBrakeLevelOld(void); - bool IncLocalBrakeLevel(int CtrlSpeed); - bool DecLocalBrakeLevel(int CtrlSpeed); + bool IncLocalBrakeLevel(float const CtrlSpeed); + bool DecLocalBrakeLevel(float const CtrlSpeed); /*! ABu 010205: - skrajne polozenia ham. pomocniczego*/ - bool IncLocalBrakeLevelFAST(void); - bool DecLocalBrakeLevelFAST(void); bool IncManualBrakeLevel(int CtrlSpeed); bool DecManualBrakeLevel(int CtrlSpeed); bool DynamicBrakeSwitch(bool Switch); - bool EmergencyBrakeSwitch(bool Switch); + bool RadiostopSwitch(bool Switch); + bool AlarmChainSwitch( bool const State ); bool AntiSlippingBrake(void); bool BrakeReleaser(int state); bool SwitchEPBrake(int state); @@ -1030,7 +1323,7 @@ public: bool IncBrakePress(double &brake, double PressLimit, double dp); bool DecBrakePress(double &brake, double PressLimit, double dp); bool BrakeDelaySwitch(int BDS);/*! przelaczanie nastawy opoznienia*/ - bool IncBrakeMult(void);/*przelaczanie prozny/ladowny*/ + bool IncBrakeMult(void);/*przelaczanie prozny/ladowny*/ bool DecBrakeMult(void); /*pomocnicze funkcje dla ukladow pneumatycznych*/ void UpdateBrakePressure(double dt); @@ -1044,9 +1337,11 @@ public: void ComputeConstans(void);//ABu: wczesniejsze wyznaczenie stalych dla liczenia sil double ComputeMass(void); void ComputeTotalForce(double dt, double dt1, bool FullVer); - double Adhesive(double staticfriction); + double Adhesive(double staticfriction) const; double TractionForce(double dt); double FrictionForce(double R, int TDamage); + double BrakeForceR(double ratio, double velocity); + double BrakeForceP(double press, double velocity); double BrakeForce(const TTrackParam &Track); double CouplerForce(int CouplerN, double dt); void CollisionDetect(int CouplerN, double dt); @@ -1055,23 +1350,40 @@ public: /*--funkcje dla lokomotyw*/ bool DirectionBackward(void);/*! kierunek ruchu*/ - bool MainSwitch(bool State);/*! wylacznik glowny*/ - bool ConverterSwitch(bool State);/*! wl/wyl przetwornicy*/ - bool CompressorSwitch(bool State);/*! wl/wyl sprezarki*/ + bool WaterPumpBreakerSwitch( bool State, range_t const Notify = range_t::consist ); // water pump breaker state toggle + bool WaterPumpSwitch( bool State, range_t const Notify = range_t::consist ); // water pump state toggle + bool WaterPumpSwitchOff( bool State, range_t const Notify = range_t::consist ); // water pump state toggle + bool WaterHeaterBreakerSwitch( bool State, range_t const Notify = range_t::consist ); // water heater breaker state toggle + bool WaterHeaterSwitch( bool State, range_t const Notify = range_t::consist ); // water heater state toggle + bool WaterCircuitsLinkSwitch( bool State, range_t const Notify = range_t::consist ); // water circuits link state toggle + bool FuelPumpSwitch( bool State, range_t const Notify = range_t::consist ); // fuel pump state toggle + bool FuelPumpSwitchOff( bool State, range_t const Notify = range_t::consist ); // fuel pump state toggle + bool OilPumpSwitch( bool State, range_t const Notify = range_t::consist ); // oil pump state toggle + bool OilPumpSwitchOff( bool State, range_t const Notify = range_t::consist ); // oil pump state toggle + bool MotorBlowersSwitch( bool State, side const Side, range_t const Notify = range_t::consist ); // traction motor fan state toggle + bool MotorBlowersSwitchOff( bool State, side const Side, range_t const Notify = range_t::consist ); // traction motor fan state toggle + bool MainSwitch( bool const State, range_t const Notify = range_t::consist );/*! wylacznik glowny*/ + bool ConverterSwitch( bool State, range_t const Notify = range_t::consist );/*! wl/wyl przetwornicy*/ + bool CompressorSwitch( bool State, range_t const Notify = range_t::consist );/*! wl/wyl sprezarki*/ /*-funkcje typowe dla lokomotywy elektrycznej*/ - void ConverterCheck(); // przetwornica - bool FuseOn(void); //bezpiecznik nadamiary - bool FuseFlagCheck(void); // sprawdzanie flagi nadmiarowego + void ConverterCheck( double const Timestep ); // przetwornica + void WaterPumpCheck( double const Timestep ); + void WaterHeaterCheck( double const Timestep ); + void FuelPumpCheck( double const Timestep ); + void OilPumpCheck( double const Timestep ); + void MotorBlowersCheck( double const Timestep ); + bool FuseOn(void); //bezpiecznik nadamiary + bool FuseFlagCheck(void) const; // sprawdzanie flagi nadmiarowego void FuseOff(void); // wylaczenie nadmiarowego - double ShowCurrent( int AmpN ); //pokazuje bezwgl. wartosc pradu na wybranym amperomierzu - double ShowCurrentP(int AmpN); //pokazuje bezwgl. wartosc pradu w wybranym pojezdzie //Q 20160722 + double ShowCurrent( int AmpN ) const; //pokazuje bezwgl. wartosc pradu na wybranym amperomierzu + double ShowCurrentP(int AmpN) const; //pokazuje bezwgl. wartosc pradu w wybranym pojezdzie //Q 20160722 /*!o pokazuje bezwgl. wartosc obrotow na obrotomierzu jednego z 3 pojazdow*/ /*function ShowEngineRotation(VehN:int): integer; //Ra 2014-06: przeniesione do C++*/ /*funkcje uzalezniajace sile pociagowa od predkosci: v2n, n2r, current, momentum*/ double v2n(void); - double current(double n, double U); + double Current(double n, double U); double Momentum(double I); double MomentumF(double I, double Iw, int SCP); @@ -1080,11 +1392,12 @@ public: bool MaxCurrentSwitch(bool State); //przelacznik pradu wysokiego rozruchu bool MinCurrentSwitch(bool State); //przelacznik pradu automatycznego rozruchu bool AutoRelaySwitch(bool State); //przelacznik automatycznego rozruchu - bool AutoRelayCheck(void);//symulacja automatycznego rozruchu + bool AutoRelayCheck();//symulacja automatycznego rozruchu + bool MotorConnectorsCheck(); - bool ResistorsFlagCheck(void); //sprawdzenie kontrolki oporow rozruchowych NBMX - bool PantFront(bool State); //obsluga pantografou przedniego - bool PantRear(bool State); //obsluga pantografu tylnego + bool ResistorsFlagCheck(void) const; //sprawdzenie kontrolki oporow rozruchowych NBMX + bool PantFront( bool const State, range_t const Notify = range_t::consist ); //obsluga pantografou przedniego + bool PantRear( bool const State, range_t const Notify = range_t::consist ); //obsluga pantografu tylnego /*-funkcje typowe dla lokomotywy spalinowej z przekladnia mechaniczna*/ bool dizel_EngageSwitch(double state); @@ -1092,21 +1405,27 @@ public: bool dizel_AutoGearCheck(void); double dizel_fillcheck(int mcp); double dizel_Momentum(double dizel_fill, double n, double dt); - bool dizel_Update(double dt); + void dizel_HeatSet( float const Value ); + void dizel_Heat( double const dt ); + bool dizel_StartupCheck(); + bool dizel_Update(double dt); /* funckje dla wagonow*/ - bool LoadingDone(double LSpeed, std::string LoadInit); - bool DoorLeft(bool State); //obsluga drzwi lewych - bool DoorRight(bool State); //obsluga drzwi prawych + bool AssignLoad( std::string const &Name, float const Amount = 0.f ); + bool LoadingDone(double LSpeed, std::string const &Loadname); + bool DoorLeft(bool State, range_t const Notify = range_t::consist ); //obsluga drzwi lewych + bool DoorRight(bool State, range_t const Notify = range_t::consist ); //obsluga drzwi prawych bool DoorBlockedFlag(void); //sprawdzenie blokady drzwi + bool signal_departure( bool const State, range_t const Notify = range_t::consist ); // toggles departure warning + void update_autonomous_doors( double const Deltatime ); // automatic door controller update - /* funkcje dla samochodow*/ + /* funkcje dla samochodow*/ bool ChangeOffsetH(double DeltaOffset); /*funkcje ladujace pliki opisujace pojazd*/ bool LoadFIZ(std::string chkpath); //Q 20160717 bool LoadChkFile(std::string chkpath); bool CheckLocomotiveParameters( bool ReadyFlag, int Dir ); - std::string EngineDescription( int what ); + std::string EngineDescription( int what ) const; private: void LoadFIZ_Param( std::string const &line ); void LoadFIZ_Load( std::string const &line ); @@ -1117,6 +1436,7 @@ private: void LoadFIZ_BuffCoupl( std::string const &line, int const Index ); void LoadFIZ_TurboPos( std::string const &line ); void LoadFIZ_Cntrl( std::string const &line ); + void LoadFIZ_Blending(std::string const &line); void LoadFIZ_Light( std::string const &line ); void LoadFIZ_Security( std::string const &line ); void LoadFIZ_Clima( std::string const &line ); @@ -1127,11 +1447,12 @@ private: void LoadFIZ_Circuit( std::string const &Input ); void LoadFIZ_RList( std::string const &Input ); void LoadFIZ_DList( std::string const &Input ); + void LoadFIZ_FFList( std::string const &Input ); void LoadFIZ_LightsList( std::string const &Input ); void LoadFIZ_PowerParamsDecode( TPowerParameters &Powerparameters, std::string const Prefix, std::string const &Input ); TPowerType LoadFIZ_PowerDecode( std::string const &Power ); TPowerSource LoadFIZ_SourceDecode( std::string const &Source ); - TEngineTypes LoadFIZ_EngineDecode( std::string const &Engine ); + TEngineType LoadFIZ_EngineDecode( std::string const &Engine ); bool readMPT0( std::string const &line ); bool readMPT( std::string const &line ); //Q 20160717 bool readMPTElectricSeries( std::string const &line ); @@ -1147,44 +1468,4 @@ private: void BrakeSubsystemDecode(); //Q 20160719 }; -extern double Distance(TLocation Loc1, TLocation Loc2, TDimension Dim1, TDimension Dim2); - -template -bool -extract_value( _Type &Variable, std::string const &Key, std::string const &Input, std::string const &Default ) { - - auto value = extract_value( Key, Input ); - if( false == value.empty() ) { - // set the specified variable to retrieved value - std::stringstream converter; - converter << value; - converter >> Variable; - return true; // located the variable - } - else { - // set the variable to provided default value - if( false == Default.empty() ) { - std::stringstream converter; - converter << Default; - converter >> Variable; - } - return false; // supplied the default - } -} - -inline -std::string -extract_value( std::string const &Key, std::string const &Input ) { - - std::string value; - auto lookup = Input.find( Key + "=" ); - if( lookup != std::string::npos ) { - value = Input.substr( Input.find_first_not_of( ' ', lookup + Key.size() + 1 ) ); - lookup = value.find( ' ' ); - if( lookup != std::string::npos ) { - // trim everything past the value - value.erase( lookup ); - } - } - return value; -} \ No newline at end of file +//double Distance(TLocation Loc1, TLocation Loc2, TDimension Dim1, TDimension Dim2); diff --git a/McZapkie/Mover.cpp b/McZapkie/Mover.cpp index 065df7a5..da6b7884 100644 --- a/McZapkie/Mover.cpp +++ b/McZapkie/Mover.cpp @@ -9,9 +9,11 @@ http://mozilla.org/MPL/2.0/. #include "stdafx.h" #include "Mover.h" + +#include "Oerlikon_ESt.h" +#include "../utilities.h" #include "../globals.h" #include "../logs.h" -#include "Oerlikon_ESt.h" #include "../parser.h" //--------------------------------------------------------------------------- @@ -22,17 +24,21 @@ http://mozilla.org/MPL/2.0/. const double dEpsilon = 0.01; // 1cm (zależy od typu sprzęgu...) const double CouplerTune = 0.1; // skalowanie tlumiennosci -inline long Trunc(float f) -{ - return (long)f; -} +int ConversionError = 0; -inline long ROUND(float f) -{ - return Trunc(f + 0.5f); -} +std::vector const TMoverParameters::eimc_labels = { + "dfic: ", "dfmax:", "p: ", "scfu: ", "cim: ", "icif: ", "Uzmax:", "Uzh: ", "DU: ", "I0: ", + "fcfu: ", "F0: ", "a1: ", "Pmax: ", "Fh: ", "Ph: ", "Vh0: ", "Vh1: ", "Imax: ", "abed: ", + "eped: " +}; -inline double sqr(double val) // SQR() zle liczylo w current() ... +std::vector const TMoverParameters::eimv_labels = { + "Fkrt:", "Fmax:", "ks: ", "df: ", "fp: ", "Us: ", "pole:", "Ic: ", "If: ", "M: ", + "Fr: ", "Ipoj:", "Pm: ", "Pe: ", "eta: ", "fkr: ", "Uzsm:", "Pmax:", "Fzad:", "Imax:", + "Fful:" +}; + +inline double square(double val) // SQR() zle liczylo w current() ... { return val * val; } @@ -76,13 +82,12 @@ int DirF(int CouplerN) // Q: 20160716 // Obliczanie natężenie prądu w silnikach // ************************************************************************************************* -double TMoverParameters::current(double n, double U) +double TMoverParameters::Current(double n, double U) { // wazna funkcja - liczy prad plynacy przez silniki polaczone szeregowo lub rownolegle // w zaleznosci od polozenia nastawnikow MainCtrl i ScndCtrl oraz predkosci obrotowej n // a takze wywala bezpiecznik nadmiarowy gdy za duzy prad lub za male napiecie // jest takze mozliwosc uszkodzenia silnika wskutek nietypowych parametrow - double const ep09resED = 5.8; // TODO: dobrac tak aby sie zgadzalo ze wbudzeniem double R, MotorCurrent; double Rz, Delta, Isf; @@ -129,46 +134,38 @@ double TMoverParameters::current(double n, double U) R = RList[MainCtrlActualPos].R * Bn + CircuitRes; - if ((TrainType != dt_EZT) || (Imin != IminLo) || - (!ScndS)) // yBARC - boczniki na szeregu poprawnie - Mn = RList[MainCtrlActualPos].Mn; // to jest wykonywane dla EU07 - else - Mn = RList[MainCtrlActualPos].Mn * RList[MainCtrlActualPos].Bn; - - // writepaslog("#", - // "C++-----------------------------------------------------------------------------"); - // writepaslog("MCAP ", IntToStr(MainCtrlActualPos)); - // writepaslog("SCAP ", IntToStr(ScndCtrlActualPos)); - // writepaslog("n ", FloatToStr(n)); - // writepaslog("StLinFlag ", BoolToYN(StLinFlag)); - // writepaslog("DelayCtrlFlag ", booltoYN(DelayCtrlFlag)); - // writepaslog("Bn ", FloatToStr(Bn)); - // writepaslog("R ", FloatToStr(R)); - // writepaslog("Mn ", IntToStr(Mn)); - // writepaslog("RList[MCAP].Bn ", FloatToStr(RList[MainCtrlActualPos].Bn)); - // writepaslog("RList[MCAP].Mn ", FloatToStr(RList[MainCtrlActualPos].Mn)); - // writepaslog("RList[MCAP].R ", FloatToStr(RList[MainCtrlActualPos].R)); - - // z Megapacka ... bylo tutaj zakomentowane Q: no to usuwam... + if( ( TrainType != dt_EZT ) + || ( Imin != IminLo ) + || ( false == ScndS ) ) { + // yBARC - boczniki na szeregu poprawnie + Mn = RList[ MainCtrlActualPos ].Mn; // to jest wykonywane dla EU07 + } + else { + Mn = RList[ MainCtrlActualPos ].Mn * RList[ MainCtrlActualPos ].Bn; + } if (DynamicBrakeFlag && (!FuseFlag) && (DynamicBrakeType == dbrake_automatic) && ConverterFlag && Mains) // hamowanie EP09 //TUHEX { + // TODO: zrobic bardziej uniwersalne nie tylko dla EP09 MotorCurrent = - -Max0R(MotorParam[0].fi * (Vadd / (Vadd + MotorParam[0].Isat) - MotorParam[0].fi0), 0) * - n * 2.0 / ep09resED; // TODO: zrobic bardziej uniwersalne nie tylko dla EP09 + -Max0R(MotorParam[0].fi * (Vadd / (Vadd + MotorParam[0].Isat) - MotorParam[0].fi0), 0) * n * 2.0 / DynamicBrakeRes; + } + else if( ( RList[ MainCtrlActualPos ].Bn == 0 ) + || ( false == StLinFlag ) ) { + // wylaczone + MotorCurrent = 0; } - else if ((RList[MainCtrlActualPos].Bn == 0) || (!StLinFlag)) - MotorCurrent = 0; // wylaczone else { // wlaczone... SP = ScndCtrlActualPos; if (ScndCtrlActualPos < 255) // tak smiesznie bede wylaczal { - if (ScndInMain) - if (!(RList[MainCtrlActualPos].ScndAct == 255)) - SP = RList[MainCtrlActualPos].ScndAct; + if( ( ScndInMain ) + && ( RList[ MainCtrlActualPos ].ScndAct != 255 ) ) { + SP = RList[ MainCtrlActualPos ].ScndAct; + } Rz = Mn * WindingRes + R; @@ -202,7 +199,7 @@ double TMoverParameters::current(double n, double U) // writepaslog("fi ", FloatToStr(MotorParam[SP].fi)); Isf = Sign(U1) * MotorParam[SP].Isat; // writepaslog("Isf ", FloatToStr(Isf)); - Delta = sqr(Isf * Rz + Mn * MotorParam[SP].fi * n - U1) + + Delta = square(Isf * Rz + Mn * MotorParam[SP].fi * n - U1) + 4.0 * U1 * Isf * Rz; // 105 * 1.67 + Mn * 140.9 * 20.532 - U1 // DeltaQ = Isf * Rz + Mn * MotorParam[SP].fi * n - U1 + 4 * U1 * Isf * Rz; // writepaslog("Delta ", FloatToStr(Delta)); @@ -212,10 +209,10 @@ double TMoverParameters::current(double n, double U) { if (U > 0) MotorCurrent = - (U1 - Isf * Rz - Mn * MotorParam[SP].fi * n + sqrt(Delta)) / (2.0 * Rz); + (U1 - Isf * Rz - Mn * MotorParam[SP].fi * n + std::sqrt(Delta)) / (2.0 * Rz); else MotorCurrent = - (U1 - Isf * Rz - Mn * MotorParam[SP].fi * n - sqrt(Delta)) / (2.0 * Rz); + (U1 - Isf * Rz - Mn * MotorParam[SP].fi * n - std::sqrt(Delta)) / (2.0 * Rz); } else MotorCurrent = 0; @@ -237,7 +234,7 @@ double TMoverParameters::current(double n, double U) else Im = MotorCurrent; - EnginePower = abs(Itot) * (1 + RList[MainCtrlActualPos].Mn) * abs(U); + EnginePower = abs(Itot) * (1 + RList[MainCtrlActualPos].Mn) * abs(U) / 1000.0; // awarie MotorCurrent = abs(Im); // zmienna pomocnicza @@ -265,25 +262,15 @@ double TMoverParameters::current(double n, double U) // ************************************************************************************************* // główny konstruktor // ************************************************************************************************* -TMoverParameters::TMoverParameters(double VelInitial, std::string TypeNameInit, - std::string NameInit, int LoadInitial, - std::string LoadTypeInitial, - int Cab) ://: T_MoverParameters(VelInitial, TypeNameInit, - //NameInit, LoadInitial, LoadTypeInitial, Cab) +TMoverParameters::TMoverParameters(double VelInitial, std::string TypeNameInit, std::string NameInit, int Cab) : TypeName( TypeNameInit ), -ActiveCab( Cab ), -LoadType( LoadTypeInitial ), -Load( LoadInitial ), -Name( NameInit ) +Name( NameInit ), +ActiveCab( Cab ) { WriteLog( "------------------------------------------------------"); - WriteLog("init default physic values for " + NameInit + ", [" + TypeNameInit + "], [" + - LoadTypeInitial + "]"); + WriteLog("init default physic values for " + NameInit + ", [" + TypeNameInit + "]"); Dim = TDimension(); - DimHalf.x = 0.5 * Dim.W; // połowa szerokości, OX jest w bok? - DimHalf.y = 0.5 * Dim.L; // połowa długości, OY jest do przodu? - DimHalf.z = 0.5 * Dim.H; // połowa wysokości, OZ jest w górę? // BrakeLevelSet(-2); //Pascal ustawia na 0, przestawimy na odcięcie (CHK jest jeszcze nie wczytane!) iLights[ 0 ] = 0; @@ -321,7 +308,7 @@ Name( NameInit ) for (int b = 0; b < 2; ++b) // Ra: kto tu zrobił "for b:=1 to 2 do" ??? { - Couplers[b].CouplerType = NoCoupler; + Couplers[b].CouplerType = TCouplerType::NoCoupler; Couplers[b].SpringKB = 1.0; Couplers[b].SpringKC = 1.0; Couplers[b].DmaxB = 0.1; @@ -329,11 +316,12 @@ Name( NameInit ) Couplers[b].DmaxC = 0.1; Couplers[b].FmaxC = 1000.0; } - for(int b = 0; b < 2; ++b ) { - HVCouplers[ b ][ 0 ] = 0.0; - HVCouplers[ b ][ 1 ] = 0.0; +#ifdef EU07_USE_OLD_HVCOUPLERS + for( int side = 0; side < 2; ++side ) { + HVCouplers[ side ][ hvcoupler::current ] = 0.0; + HVCouplers[ side ][ hvcoupler::voltage ] = 0.0; } - +#endif for( int b = 0; b < 3; ++b ) { BrakeCylMult[ b ] = 0.0; } @@ -343,10 +331,6 @@ Name( NameInit ) } eimc[eimc_p_eped] = 1.5; - // inicjalizacja zmiennych} - // Loc:=LocInitial; //Ra: to i tak trzeba potem przesunąć, po ustaleniu pozycji na torze - // (potrzebna długość) - // Rot:=RotInitial; for (int b = 0; b < 2; ++b) { Couplers[b].AllowedFlag = 3; // domyślnie hak i hamulec, inne trzeba włączyć jawnie w FIZ @@ -398,20 +382,6 @@ Name( NameInit ) SecuritySystem.RadioStop = false; // domyślnie nie ma SecuritySystem.AwareMinSpeed = 0.1 * Vmax; s_CAtestebrake = false; - // ABu 240105: - // CouplerNr[0]:=1; - // CouplerNr[1]:=0; - - // TO POTEM TU UAKTYWNIC A WYWALIC Z CHECKPARAM} - //{ - // if Pos(LoadTypeInitial,LoadAccepted)>0 then - // begin - //} - - //{ - // end - // else Load:=0; - // } }; double TMoverParameters::Distance(const TLocation &Loc1, const TLocation &Loc2, @@ -428,45 +398,47 @@ double TMoverParameters::Distance(const vector3 &s1, const vector3 &s2, const ve */ double TMoverParameters::CouplerDist(int Coupler) { // obliczenie odległości pomiędzy sprzęgami (kula!) - return Couplers[Coupler].CoupleDist = - Distance(Loc, Couplers[Coupler].Connected->Loc, Dim, - Couplers[Coupler].Connected->Dim); // odległość pomiędzy sprzęgami (kula!) + Couplers[Coupler].CoupleDist = + Distance( + Loc, Couplers[Coupler].Connected->Loc, + Dim, Couplers[Coupler].Connected->Dim); // odległość pomiędzy sprzęgami (kula!) + + return Couplers[ Coupler ].CoupleDist; }; -bool TMoverParameters::Attach(int ConnectNo, int ConnectToNr, TMoverParameters *ConnectTo, - int CouplingType, bool Forced) +bool TMoverParameters::Attach(int ConnectNo, int ConnectToNr, TMoverParameters *ConnectTo, int CouplingType, bool Forced) { //łączenie do swojego sprzęgu (ConnectNo) pojazdu (ConnectTo) stroną (ConnectToNr) // Ra: zwykle wykonywane dwukrotnie, dla każdego pojazdu oddzielnie // Ra: trzeba by odróżnić wymóg dociśnięcia od uszkodzenia sprzęgu przy podczepianiu AI do // składu if (ConnectTo) // jeśli nie pusty { + auto &coupler = Couplers[ ConnectNo ]; if (ConnectToNr != 2) - Couplers[ConnectNo].ConnectedNr = ConnectToNr; // 2=nic nie podłączone - TCouplerType ct = ConnectTo->Couplers[Couplers[ConnectNo].ConnectedNr] - .CouplerType; // typ sprzęgu podłączanego pojazdu - Couplers[ConnectNo].Connected = - ConnectTo; // tak podpiąć (do siebie) zawsze można, najwyżej będzie wirtualny - CouplerDist(ConnectNo); // przeliczenie odległości pomiędzy sprzęgami - if (CouplingType == ctrain_virtual) + coupler.ConnectedNr = ConnectToNr; // 2=nic nie podłączone + coupler.Connected = ConnectTo; // tak podpiąć (do siebie) zawsze można, najwyżej będzie wirtualny + CouplerDist( ConnectNo ); // przeliczenie odległości pomiędzy sprzęgami + + if (CouplingType == coupling::faux) return false; // wirtualny więcej nic nie robi - if (Forced ? true : ((Couplers[ConnectNo].CoupleDist <= dEpsilon) && - (Couplers[ConnectNo].CouplerType != NoCoupler) && - (Couplers[ConnectNo].CouplerType == ct))) + + auto &othercoupler = ConnectTo->Couplers[ coupler.ConnectedNr ]; + if( ( Forced ) + || ( ( coupler.CoupleDist <= dEpsilon ) + && ( coupler.CouplerType != TCouplerType::NoCoupler ) + && ( coupler.CouplerType == othercoupler.CouplerType ) ) ) { // stykaja sie zderzaki i kompatybilne typy sprzegow, chyba że łączenie na starcie - if (Couplers[ConnectNo].CouplingFlag == - ctrain_virtual) // jeśli wcześniej nie było połączone - { // ustalenie z której strony rysować sprzęg - Couplers[ConnectNo].Render = true; // tego rysować - ConnectTo->Couplers[Couplers[ConnectNo].ConnectedNr].Render = false; // a tego nie + if( coupler.CouplingFlag == ctrain_virtual ) { + // jeśli wcześniej nie było połączone, ustalenie z której strony rysować sprzęg + coupler.Render = true; // tego rysować + othercoupler.Render = false; // a tego nie }; - Couplers[ConnectNo].CouplingFlag = CouplingType; // ustawienie typu sprzęgu + coupler.CouplingFlag = CouplingType; // ustawienie typu sprzęgu // if (CouplingType!=ctrain_virtual) //Ra: wirtualnego nie łączymy zwrotnie! //{//jeśli łączenie sprzęgiem niewirtualnym, ustawiamy połączenie zwrotne - ConnectTo->Couplers[Couplers[ConnectNo].ConnectedNr].CouplingFlag = CouplingType; - ConnectTo->Couplers[Couplers[ConnectNo].ConnectedNr].Connected = this; - ConnectTo->Couplers[Couplers[ConnectNo].ConnectedNr].CoupleDist = - Couplers[ConnectNo].CoupleDist; + othercoupler.CouplingFlag = CouplingType; + othercoupler.Connected = this; + othercoupler.CoupleDist = coupler.CoupleDist; return true; //} // podłączenie nie udało się - jest wirtualne @@ -498,7 +470,7 @@ int TMoverParameters::DettachStatus(int ConnectNo) // if (CouplerType==Articulated) return false; //sprzęg nie do rozpięcia - może być tylko urwany // Couplers[ConnectNo].CoupleDist=Distance(Loc,Couplers[ConnectNo].Connected->Loc,Dim,Couplers[ConnectNo].Connected->Dim); CouplerDist(ConnectNo); - if (Couplers[ConnectNo].CouplerType == Screw ? Couplers[ConnectNo].CoupleDist < 0.0 : true) + if (Couplers[ConnectNo].CouplerType == TCouplerType::Screw ? Couplers[ConnectNo].CoupleDist < 0.0 : true) return -Couplers[ConnectNo].CouplingFlag; // można rozłączać, jeśli dociśnięty return (Couplers[ConnectNo].CoupleDist > 0.2) ? -Couplers[ConnectNo].CouplingFlag : Couplers[ConnectNo].CouplingFlag; @@ -529,21 +501,29 @@ bool TMoverParameters::Dettach(int ConnectNo) return false; // jeszcze nie rozłączony }; -void TMoverParameters::SetCoupleDist() -{ // przeliczenie odległości sprzęgów - if (Couplers[0].Connected) - { - CouplerDist(0); - if (CategoryFlag & 2) - { // Ra: dla samochodów zderzanie kul to za mało +// przeliczenie odległości sprzęgów +void TMoverParameters::SetCoupleDist() { +/* + double const MaxDist = 100.0; // 2x average max proximity distance. TODO: rearrange ito something more elegant +*/ + for( int coupleridx = 0; coupleridx <= 1; ++coupleridx ) { + + if( Couplers[ coupleridx ].Connected == nullptr ) { continue; } + + CouplerDist( coupleridx ); + if( CategoryFlag & 2 ) { + // Ra: dla samochodów zderzanie kul to za mało + // NOTE: whatever calculation was supposed to be here, ain't } - } - if (Couplers[1].Connected) - { - CouplerDist(1); - if (CategoryFlag & 2) - { // Ra: dla samochodów zderzanie kul to za mało +/* + if( ( Couplers[ coupleridx ].CouplingFlag == coupling::faux ) + && ( Couplers[ coupleridx ].CoupleDist > MaxDist ) ) { + // zerwij kontrolnie wirtualny sprzeg + // Connected.Couplers[CNext].Connected:=nil; //Ra: ten podłączony niekoniecznie jest wirtualny + Couplers[ coupleridx ].Connected = nullptr; + Couplers[ coupleridx ].ConnectedNr = 2; } +*/ } }; @@ -572,11 +552,12 @@ void TMoverParameters::BrakeLevelSet(double b) if (fBrakeCtrlPos == b) return; // nie przeliczać, jak nie ma zmiany fBrakeCtrlPos = b; - BrakeCtrlPosR = b; if (fBrakeCtrlPos < Handle->GetPos(bh_MIN)) fBrakeCtrlPos = Handle->GetPos(bh_MIN); // odcięcie else if (fBrakeCtrlPos > Handle->GetPos(bh_MAX)) fBrakeCtrlPos = Handle->GetPos(bh_MAX); + // TODO: verify whether BrakeCtrlPosR and fBrakeCtrlPos can be rolled into single variable + BrakeCtrlPosR = fBrakeCtrlPos; int x = static_cast(std::floor(fBrakeCtrlPos)); // jeśli odwołujemy się do BrakeCtrlPos w pośrednich, to musi być // obcięte a nie zaokrągone while ((x > BrakeCtrlPos) && (BrakeCtrlPos < BrakeCtrlPosNo)) // jeśli zwiększyło się o 1 @@ -630,7 +611,7 @@ bool TMoverParameters::ChangeCab(int direction) { // if (ActiveCab+direction=0) then LastCab:=ActiveCab; ActiveCab = ActiveCab + direction; - if ((BrakeSystem == Pneumatic) && (BrakeCtrlPosNo > 0)) + if ((BrakeSystem == TBrakeSystem::Pneumatic) && (BrakeCtrlPosNo > 0)) { // if (BrakeHandle==FV4a) //!!!POBIERAĆ WARTOŚĆ Z KLASY ZAWORU!!! // BrakeLevelSet(-2); //BrakeCtrlPos=-2; @@ -666,63 +647,119 @@ bool TMoverParameters::ChangeCab(int direction) return false; }; -bool TMoverParameters::CurrentSwitch(int direction) -{ // rozruch wysoki (true) albo niski (false) +// rozruch wysoki (true) albo niski (false) +bool +TMoverParameters::CurrentSwitch(bool const State) { // Ra: przeniosłem z Train.cpp, nie wiem czy ma to sens - if (MaxCurrentSwitch(direction != 0)) - { + if (MaxCurrentSwitch(State)) { if (TrainType != dt_EZT) - return (MinCurrentSwitch(direction != 0)); + return (MinCurrentSwitch(State)); } - if (EngineType == DieselEngine) // dla 2Ls150 - if (ShuntModeAllow) - if (ActiveDir == 0) // przed ustawieniem kierunku - ShuntMode = ( direction != 0 ); + // TBD, TODO: split off shunt mode toggle into a separate command? It doesn't make much sense to have these two together like that + // dla 2Ls150 + if( ( EngineType == TEngineType::DieselEngine ) + && ( true == ShuntModeAllow ) + && ( ActiveDir == 0 ) ) { + // przed ustawieniem kierunku + ShuntMode = State; + return true; + } + // for SM42/SP42 + if( ( EngineType == TEngineType::DieselElectric ) + && ( true == ShuntModeAllow ) + && ( MainCtrlPos == 0 ) ) { + ShuntMode = State; + return true; + } + return false; }; void TMoverParameters::UpdatePantVolume(double dt) -{ // KURS90 - sprężarka pantografów; Ra 2014-07: teraz jest to zbiornik rozrządu, chociaż to jeszcze - // nie tak - if (EnginePowerSource.SourceType == CurrentCollector) // tylko jeśli pantografujący +{ // KURS90 - sprężarka pantografów; Ra 2014-07: teraz jest to zbiornik rozrządu, chociaż to jeszcze nie tak + + // check the pantograph compressor while at it + if( PantCompFlag ) { + if( ( false == Battery ) + && ( false == ConverterFlag ) ) { + PantCompFlag = false; + } + } + + if (EnginePowerSource.SourceType == TPowerSource::CurrentCollector) // tylko jeśli pantografujący { - // Ra 2014-07: zasadniczo, to istnieje zbiornik rozrządu i zbiornik pantografów - na razie - // mamy razem - // Ra 2014-07: kurek trójdrogowy łączy spr.pom. z pantografami i wyłącznikiem ciśnieniowym - // WS + // Ra 2014-07: zasadniczo, to istnieje zbiornik rozrządu i zbiornik pantografów - na razie mamy razem + // Ra 2014-07: kurek trójdrogowy łączy spr.pom. z pantografami i wyłącznikiem ciśnieniowym WS // Ra 2014-07: zbiornika rozrządu nie pompuje się tu, tylko pantografy; potem można zamknąć // WS i odpalić resztę - if ((TrainType == dt_EZT) ? (PantPress < ScndPipePress) : - bPantKurek3) // kurek zamyka połączenie z ZG - { // zbiornik pantografu połączony ze zbiornikiem głównym - małą sprężarką się tego nie - // napompuje + if ((TrainType == dt_EZT) ? + (PantPress < ScndPipePress) : + bPantKurek3) // kurek zamyka połączenie z ZG + { // zbiornik pantografu połączony ze zbiornikiem głównym - małą sprężarką się tego nie napompuje // Ra 2013-12: Niebugocław mówi, że w EZT nie ma potrzeby odcinać kurkiem - PantPress = EnginePowerSource.CollectorParameters - .MaxPress; // ograniczenie ciśnienia do MaxPress (tylko w pantografach!) - if (PantPress > ScndPipePress) - PantPress = ScndPipePress; // oraz do ScndPipePress + PantPress = ScndPipePress; + // ograniczenie ciśnienia do MaxPress (tylko w pantografach!) + PantPress = clamp( ScndPipePress, 0.0, EnginePowerSource.CollectorParameters.MaxPress ); PantVolume = (PantPress + 1.0) * 0.1; // objętość, na wypadek odcięcia kurkiem } else { // zbiornik główny odcięty, można pompować pantografy - if (PantCompFlag && Battery) // włączona bateria i mała sprężarka - PantVolume += dt * (TrainType == dt_EZT ? 0.003 : 0.005) * - (2.0 * 0.45 - ((0.1 / PantVolume / 10) - 0.1)) / - 0.45; // napełnianie zbiornika pantografów - // Ra 2013-12: Niebugocław mówi, że w EZT nabija 1.5 raz wolniej niż jak było 0.005 - PantPress = (10.0 * PantVolume) - 1.0; // tu by się przydała objętość zbiornika + if( PantCompFlag ) { + // włączona mała sprężarka + PantVolume += + dt + // Ra 2013-12: Niebugocław mówi, że w EZT nabija 1.5 raz wolniej niż jak było 0.005 + * ( TrainType == dt_EZT ? 0.003 : 0.005 ) / std::max( 1.0, PantPress ) + * ( 0.45 - ( ( 0.1 / PantVolume / 10 ) - 0.1 ) ) / 0.45; + } + PantPress = clamp( ( 10.0 * PantVolume ) - 1.0, 0.0, EnginePowerSource.CollectorParameters.MaxPress ); // tu by się przydała objętość zbiornika } - if (!PantCompFlag && (PantVolume > 0.1)) - PantVolume -= dt * 0.0003; // nieszczelności: 0.0003=0.3l/s - if (Mains) // nie wchodzić w funkcję bez potrzeby - if (EngineType == ElectricSeriesMotor) // nie dotyczy... czego właściwie? - if (PantPress < EnginePowerSource.CollectorParameters.MinPress) - if ((TrainType & (dt_EZT | dt_ET40 | dt_ET41 | dt_ET42)) ? - (GetTrainsetVoltage() < EnginePowerSource.CollectorParameters.MinV) : - true) // to jest trochę proteza; zasilanie członu może być przez sprzęg - // WN - if (MainSwitch(false)) - EventFlag = true; // wywalenie szybkiego z powodu niskiego ciśnienia + if( !PantCompFlag && ( PantVolume > 0.1 ) ) + PantVolume -= dt * 0.0003 * std::max( 1.0, PantPress * 0.5 ); // nieszczelności: 0.0003=0.3l/s + + if( PantPress < EnginePowerSource.CollectorParameters.MinPress ) { + // 3.5 wg http://www.transportszynowy.pl/eu06-07pneumat.php + if( true == PantPressSwitchActive ) { + // opuszczenie pantografów przy niskim ciśnieniu + if( TrainType != dt_EZT ) { + // pressure switch safety measure -- open the line breaker, unless there's alternate source of traction voltage + if( GetTrainsetVoltage() < EnginePowerSource.CollectorParameters.MinV ) { + // TODO: check whether line breaker should be open EMU-wide + MainSwitch( false, ( TrainType == dt_EZT ? range_t::unit : range_t::local ) ); + } + } + else { + // specialized variant for EMU -- pwr system disables converter and heating, + // and prevents their activation until pressure switch is set again + PantPressLockActive = true; + // TODO: separate 'heating allowed' from actual heating flag, so we can disable it here without messing up heating toggle + ConverterSwitch( false, range_t::unit ); + } + // mark the pressure switch as spent + PantPressSwitchActive = false; + } + } + else { + if( PantPress >= 4.6 ) { + // NOTE: we require active low power source to prime the pressure switch + // this is a work-around for potential isssues caused by the switch activating on otherwise idle vehicles, but should check whether it's accurate + if( ( true == Battery ) + || ( true == ConverterFlag ) ) { + // prime the pressure switch + PantPressSwitchActive = true; + // turn off the subsystems lock + PantPressLockActive = false; + } + + if( PantPress >= 4.8 ) { + // Winger - automatyczne wylaczanie malej sprezarki + // TODO: governor lock, disables usage until pressure drop below 3.8 (should really make compressor object we could reuse) + PantCompFlag = false; + } + } + } +/* + // NOTE: pantograph tank pressure sharing experimentally disabled for more accurate simulation if (TrainType != dt_EZT) // w EN57 pompuje się tylko w silnikowym // pierwotnie w CHK pantografy miały również rozrządcze EZT for (int b = 0; b <= 1; ++b) @@ -734,6 +771,7 @@ void TMoverParameters::UpdatePantVolume(double dt) // czy np. w ET40, ET41, ET42 pantografy członów mają połączenie pneumatyczne? // Ra 2014-07: raczej nie - najpierw się załącza jeden człon, a potem można podnieść w // drugim +*/ } else { // a tu coś dla SM42 i SM31, aby pokazywać na manometrze @@ -748,9 +786,11 @@ void TMoverParameters::UpdateBatteryVoltage(double dt) sn3 = 0.0, sn4 = 0.0, sn5 = 0.0; // Ra: zrobić z tego amperomierz NN - if ((BatteryVoltage > 0) && (EngineType != DieselEngine) && (EngineType != WheelsDriven) && - (NominalBatteryVoltage > 0)) - { + if( ( BatteryVoltage > 0 ) + && ( EngineType != TEngineType::DieselEngine ) + && ( EngineType != TEngineType::WheelsDriven ) + && ( NominalBatteryVoltage > 0 ) ) { + if ((NominalBatteryVoltage / BatteryVoltage < 1.22) && Battery) { // 110V if (!ConverterFlag) @@ -811,17 +851,17 @@ void TMoverParameters::UpdateBatteryVoltage(double dt) }; BatteryVoltage -= (sn1 + sn2 + sn3 + sn4 + sn5); if (NominalBatteryVoltage / BatteryVoltage > 1.57) - if (MainSwitch(false) && (EngineType != DieselEngine) && (EngineType != WheelsDriven)) + if (MainSwitch(false) && (EngineType != TEngineType::DieselEngine) && (EngineType != TEngineType::WheelsDriven)) EventFlag = true; // wywalanie szybkiego z powodu zbyt niskiego napiecia if (BatteryVoltage > NominalBatteryVoltage) BatteryVoltage = NominalBatteryVoltage; // wstrzymanie ładowania pow. 110V if (BatteryVoltage < 0.01) BatteryVoltage = 0.01; } - else if (NominalBatteryVoltage == 0) - BatteryVoltage = 0; - else - BatteryVoltage = 90; + else { + // TODO: check and implement proper way to handle this for diesel engines + BatteryVoltage = NominalBatteryVoltage; + } }; /* Ukrotnienie EN57: @@ -870,7 +910,7 @@ ZN //masa double TMoverParameters::LocalBrakeRatio(void) { double LBR; - if (BrakeHandle == MHZ_EN57) + if (BrakeHandle == TBrakeHandle::MHZ_EN57) if ((BrakeOpModeFlag >= bom_EP)) LBR = Handle->GetEP(BrakeCtrlPosR); else @@ -878,7 +918,7 @@ double TMoverParameters::LocalBrakeRatio(void) else { if (LocalBrakePosNo > 0) - LBR = (double)LocalBrakePos / LocalBrakePosNo; + LBR = LocalBrakePosA; else LBR = 0; } @@ -906,7 +946,7 @@ double TMoverParameters::ManualBrakeRatio(void) // Q: 20160713 // Zwraca objętość // ***************************************************************************** -double TMoverParameters::BrakeVP(void) +double TMoverParameters::BrakeVP(void) const { if (BrakeVVolume > 0) return Volume / (10.0 * BrakeVVolume); @@ -1011,7 +1051,7 @@ void TMoverParameters::CollisionDetect(int CouplerN, double dt) EventFlag = true; if ((coupler.CouplingFlag & ctrain_pneumatic) == ctrain_pneumatic) - EmergencyBrakeFlag = true; // hamowanie nagle - zerwanie przewodow hamulcowych + AlarmChainFlag = true; // hamowanie nagle - zerwanie przewodow hamulcowych coupler.CouplingFlag = 0; switch (CouplerN) // wyzerowanie flag podlaczenia ale ciagle sa wirtualnie polaczone @@ -1023,6 +1063,7 @@ void TMoverParameters::CollisionDetect(int CouplerN, double dt) coupler.Connected->Couplers[0].CouplingFlag = 0; break; } + WriteLog( "Bad driving: " + Name + " broke a coupler" ); } } } @@ -1036,57 +1077,115 @@ double TMoverParameters::ComputeMovement(double dt, double dt1, const TTrackShap { const double Vepsilon = 1e-5; const double Aepsilon = 1e-3; // ASBSpeed=0.8; - int b; - double Vprev, AccSprev, d, hvc; // T_MoverParameters::ComputeMovement(dt, dt1, Shape, Track, ElectricTraction, NewLoc, NewRot); // // najpierw kawalek z funkcji w pliku mover.pas TotalCurrent = 0; - hvc = Max0R(Max0R(PantFrontVolt, PantRearVolt), ElectricTraction.TractionVoltage * 0.9); - for (b = 0; b < 2; b++) // przekazywanie napiec - if (((Couplers[b].CouplingFlag & ctrain_power) == ctrain_power) || - (((Couplers[b].CouplingFlag & ctrain_heating) == ctrain_heating) && (Heating))) - { - HVCouplers[1 - b][1] = - Max0R(abs(hvc), Couplers[b].Connected->HVCouplers[Couplers[b].ConnectedNr][1] - - HVCouplers[b][0] * 0.02); + double hvc = + std::max( + std::max( + PantFrontVolt, + PantRearVolt ), + ElectricTraction.TractionVoltage * 0.9 ); + + for( int side = 0; side < 2; ++side ) { + // przekazywanie napiec + auto const oppositeside = ( side == side::front ? side::rear : side::front ); + + if( ( Couplers[ side ].CouplingFlag & ctrain_power ) + || ( ( Heating ) + && ( Couplers[ side ].CouplingFlag & ctrain_heating ) ) ) { +#ifdef EU07_USE_OLD_HVCOUPLERS + HVCouplers[ oppositeside ][ hvcoupler::voltage ] = + std::max( + std::abs( hvc ), + Couplers[ side ].Connected->HVCouplers[ Couplers[ side ].ConnectedNr ][ hvcoupler::voltage ] - HVCouplers[ side ][ hvcoupler::current ] * 0.02 ); +#else + auto const &connectedcoupler = Couplers[ side ].Connected->Couplers[ Couplers[ side ].ConnectedNr ]; + Couplers[ oppositeside ].power_high.voltage = + std::max( + std::abs( hvc ), + connectedcoupler.power_high.voltage - Couplers[ side ].power_high.current * 0.02 ); +#endif } - else - HVCouplers[1 - b][1] = abs(hvc) - HVCouplers[b][0] * 0.02; - // Max0R(Abs(Voltage),0); - // end; + else { +#ifdef EU07_USE_OLD_HVCOUPLERS + HVCouplers[ oppositeside ][ hvcoupler::voltage ] = std::abs( hvc ) - HVCouplers[ side ][ hvcoupler::current ] * 0.02; +#else + Couplers[ oppositeside ].power_high.voltage = std::abs( hvc ) - Couplers[ side ].power_high.current * 0.02; +#endif + } + } - hvc = HVCouplers[0][1] + HVCouplers[1][1]; +#ifdef EU07_USE_OLD_HVCOUPLERS + hvc = HVCouplers[ side::front ][ hvcoupler::voltage ] + HVCouplers[ side::rear ][ hvcoupler::voltage ]; +#else + hvc = Couplers[ side::front ].power_high.voltage + Couplers[ side::rear ].power_high.voltage; +#endif - if ((abs(PantFrontVolt) + abs(PantRearVolt) < 1) && - (hvc > 1)) // bez napiecia, ale jest cos na sprzegach: - { - for (b = 0; b < 2; ++b) // przekazywanie pradow - if (((Couplers[b].CouplingFlag & ctrain_power) == ctrain_power) || - (((Couplers[b].CouplingFlag & ctrain_heating) == ctrain_heating) && - (Heating))) // jesli spiety - { - HVCouplers[b][0] = - Couplers[b].Connected->HVCouplers[1 - Couplers[b].ConnectedNr][0] + - Itot * HVCouplers[b][1] / hvc; // obciążenie rozkladane stosownie do napiec - } - else // pierwszy pojazd - { - HVCouplers[b][0] = Itot * HVCouplers[b][1] / hvc; - } + if( std::abs( PantFrontVolt ) + std::abs( PantRearVolt ) < 1.0 ) { + // bez napiecia... + if( hvc != 0.0 ) { + // ...ale jest cos na sprzegach: + // przekazywanie pradow + for( int side = 0; side < 2; ++side ) { + + Couplers[ side ].power_high.local = false; // power, if any, will be from external source + + if( ( Couplers[ side ].CouplingFlag & ctrain_power ) + || ( ( Heating ) + && ( Couplers[ side ].CouplingFlag & ctrain_heating ) ) ) { +#ifdef EU07_USE_OLD_HVCOUPLERS + auto const oppositeside = ( Couplers[side].ConnectedNr == side::front ? side::rear : side::front ); + HVCouplers[ side ][ hvcoupler::current ] = + Couplers[side].Connected->HVCouplers[oppositeside][hvcoupler::current] + + Itot * HVCouplers[side][hvcoupler::voltage] / hvc; // obciążenie rozkladane stosownie do napiec +#else + auto const &connectedsothercoupler = + Couplers[ side ].Connected->Couplers[ + ( Couplers[ side ].ConnectedNr == side::front ? + side::rear : + side::front ) ]; + Couplers[ side ].power_high.current = + connectedsothercoupler.power_high.current + + Itot * Couplers[ side ].power_high.voltage / hvc; // obciążenie rozkladane stosownie do napiec +#endif + } + else { +#ifdef EU07_USE_OLD_HVCOUPLERS + // pierwszy pojazd + HVCouplers[side][hvcoupler::current] = Itot * HVCouplers[side][hvcoupler::voltage] / hvc; +#else + Couplers[ side ].power_high.current = Itot * Couplers[ side ].power_high.voltage / hvc; +#endif + } + } + } } else { - if (((Couplers[0].CouplingFlag & ctrain_power) == ctrain_power) || - (((Couplers[0].CouplingFlag & ctrain_heating) == ctrain_heating) && (Heating))) - TotalCurrent += - Couplers[0].Connected->HVCouplers[1 - Couplers[0].ConnectedNr][0]; - if (((Couplers[1].CouplingFlag & ctrain_power) == ctrain_power) || - (((Couplers[1].CouplingFlag & ctrain_heating) == ctrain_heating) && (Heating))) - TotalCurrent += - Couplers[1].Connected->HVCouplers[1 - Couplers[1].ConnectedNr][0]; - HVCouplers[0][0] = 0; - HVCouplers[1][0] = 0; + for( int side = 0; side < 2; ++side ) { + + Couplers[ side ].power_high.local = true; // power is coming from local pantographs + + if( ( Couplers[ side ].CouplingFlag & ctrain_power ) + || ( ( Heating ) + && ( Couplers[ side ].CouplingFlag & ctrain_heating ) ) ) { +#ifdef EU07_USE_OLD_HVCOUPLERS + auto const oppositeside = ( Couplers[ side ].ConnectedNr == side::front ? side::rear : side::front ); + TotalCurrent += Couplers[ side ].Connected->HVCouplers[ oppositeside ][ hvcoupler::current ]; + HVCouplers[ side ][ hvcoupler::current ] = 0.0; +#else + auto const &connectedsothercoupler = + Couplers[ side ].Connected->Couplers[ + ( Couplers[ side ].ConnectedNr == side::front ? + side::rear : + side::front ) ]; + TotalCurrent += connectedsothercoupler.power_high.current; + Couplers[ side ].power_high.current = 0.0; +#endif + } + } } if (!TestFlag(DamageFlag, dtrain_out)) @@ -1115,6 +1214,7 @@ double TMoverParameters::ComputeMovement(double dt, double dt1, const TTrackShap OffsetTrackH = Sign(RunningShape.R) * 0.2; } + // TODO: investigate, seems supplied NewRot is always 0 although the code here suggests some actual values are expected Loc = NewLoc; Rot = NewRot; NewRot.Rx = 0; @@ -1123,33 +1223,58 @@ double TMoverParameters::ComputeMovement(double dt, double dt1, const TTrackShap if (dL == 0) // oblicz przesuniecie} { - Vprev = V; - AccSprev = AccS; - // dt:=ActualTime-LastUpdatedTime; //przyrost czasu + auto const AccSprev { AccS }; // przyspieszenie styczne - AccS = (FTotal / TotalMass + AccSprev) / - 2.0; // prawo Newtona ale z wygladzaniem (średnia z poprzednim) + AccS = interpolate( + AccSprev, + FTotal / TotalMass, + 0.5 ); + // clamp( dt * 3.0, 0.0, 1.0 ) ); // prawo Newtona ale z wygladzaniem (średnia z poprzednim) if (TestFlag(DamageFlag, dtrain_out)) AccS = -Sign(V) * g * 1; // random(0.0, 0.1) // przyspieszenie normalne if (abs(Shape.R) > 0.01) - AccN = sqr(V) / Shape.R + g * Shape.dHrail / TrackW; // Q: zamieniam SQR() na sqr() + AccN = square(V) / Shape.R + g * Shape.dHrail / TrackW; // Q: zamieniam SQR() na sqr() else AccN = g * Shape.dHrail / TrackW; + // velocity change + auto const Vprev { V }; + V += ( 3.0 * AccS - AccSprev ) * dt / 2.0; // przyrost predkosci + if( ( V * Vprev <= 0 ) + && ( std::abs( FStand ) > std::abs( FTrain ) ) ) { + // tlumienie predkosci przy hamowaniu + // zahamowany + V = 0; + } + + // tangential acceleration, from velocity change + AccSVBased = interpolate( + AccSVBased, + ( V - Vprev ) / dt, + clamp( dt * 3.0, 0.0, 1.0 ) ); + + // vertical acceleration + AccVert = ( + std::abs( AccVert ) < 0.01 ? + 0.0 : + AccVert * 0.5 ); // szarpanie - if (FuzzyLogic((10.0 + Track.DamageFlag) * Mass * Vel / Vmax, 500000.0, - p_accn)) // Ra: czemu tu masa bez ładunku? - AccV = sqrt((1.0 + Track.DamageFlag) * Random(floor(50.0 * Mass / 1000000.0)) * Vel / - (Vmax * (10.0 + (Track.QualityFlag & 31)))); +/* +#ifdef EU07_USE_FUZZYLOGIC + if( FuzzyLogic( ( 10.0 + Track.DamageFlag ) * Mass * Vel / Vmax, 500000.0, p_accn ) ) { + // Ra: czemu tu masa bez ładunku? + AccV /= ( 2.0 * 0.95 + 2.0 * Random() * 0.1 ); // 95-105% of base modifier (2.0) + } else +#endif AccV = AccV / 2.0; if (AccV > 1.0) AccN += (7.0 - Random(5)) * (100.0 + Track.DamageFlag / 2.0) * AccV / 2000.0; - +*/ // wykolejanie na luku oraz z braku szyn if (TestFlag(CategoryFlag, 1)) { @@ -1159,7 +1284,7 @@ double TMoverParameters::ComputeMovement(double dt, double dt1, const TTrackShap if (SetFlag(DamageFlag, dtrain_out)) { EventFlag = true; - Mains = false; + MainSwitch( false, range_t::local ); RunningShape.R = 0; if (TestFlag(Track.DamageFlag, dtrack_norail)) DerailReason = 1; // Ra: powód wykolejenia: brak szyn @@ -1171,7 +1296,7 @@ double TMoverParameters::ComputeMovement(double dt, double dt1, const TTrackShap if (SetFlag(DamageFlag, dtrain_out)) { EventFlag = true; - Mains = false; + MainSwitch( false, range_t::local ); RunningShape.R = 0; DerailReason = 3; // Ra: powód wykolejenia: za szeroki tor } @@ -1181,97 +1306,40 @@ double TMoverParameters::ComputeMovement(double dt, double dt1, const TTrackShap if (SetFlag(DamageFlag, dtrain_out)) { EventFlag = true; - Mains = false; + MainSwitch( false, range_t::local ); DerailReason = 4; // Ra: powód wykolejenia: nieodpowiednia trajektoria } - V += (3.0 * AccS - AccSprev) * dt / 2.0; // przyrost predkosci - if (TestFlag(DamageFlag, dtrain_out)) - if (Vel < 1) - { - V = 0; - AccS = 0; - } - - if ((V * Vprev <= 0) && (abs(FStand) > abs(FTrain))) // tlumienie predkosci przy hamowaniu - { // zahamowany - V = 0; - // AccS:=0; //Ra 2014-03: ale siła grawitacji działa, więc nie może być zerowe + if( ( true == TestFlag( DamageFlag, dtrain_out ) ) + && ( Vel < 1.0 ) ) { + V = 0.0; + AccS = 0.0; } - // { dL:=(V+AccS*dt/2)*dt; //przyrost dlugosci czyli - // przesuniecie + // dL:=(V+AccS*dt/2)*dt; + // przyrost dlugosci czyli przesuniecie dL = (3.0 * V - Vprev) * dt / 2.0; // metoda Adamsa-Bashfortha} // ale jesli jest kolizja (zas. zach. pedu) to...} - for (b = 0; b < 2; b++) + for (int b = 0; b < 2; b++) if (Couplers[b].CheckCollision) CollisionDetect(b, dt); // zmienia niejawnie AccS, V !!! } // liczone dL, predkosc i przyspieszenie - if (Power > 1.0) // w rozrządczym nie (jest błąd w FIZ!) - Ra 2014-07: teraz we wszystkich - UpdatePantVolume(dt); // Ra 2014-07: obsługa zbiornika rozrządu oraz pantografów + auto const d { ( + EngineType == TEngineType::WheelsDriven ? + dL * CabNo : // na chwile dla testu + dL ) }; - if (EngineType == WheelsDriven) - d = (double)CabNo * dL; // na chwile dla testu - else - d = dL; DistCounter += fabs(dL) / 1000.0; dL = 0; // koniec procedury, tu nastepuja dodatkowe procedury pomocnicze + compute_movement_( dt ); - // sprawdzanie i ewentualnie wykonywanie->kasowanie poleceń - if (LoadStatus > 0) // czas doliczamy tylko jeśli trwa (roz)ładowanie - LastLoadChangeTime += dt; // czas (roz)ładunku - - RunInternalCommand(); - - // automatyczny rozruch - if (EngineType == ElectricSeriesMotor) - - if (AutoRelayCheck()) - SetFlag(SoundFlag, sound_relay); - - if (EngineType == DieselEngine) - if (dizel_Update(dt)) - SetFlag(SoundFlag, sound_relay); - // uklady hamulcowe: - if (VeselVolume > 0) - Compressor = CompressedVolume / VeselVolume; - else - { - Compressor = 0; - CompressorFlag = false; - }; - ConverterCheck(); - if (CompressorSpeed > 0.0) // sprężarka musi mieć jakąś niezerową wydajność - CompressorCheck(dt); //żeby rozważać jej załączenie i pracę - UpdateBrakePressure(dt); - UpdatePipePressure(dt); - UpdateBatteryVoltage(dt); - UpdateScndPipePressure(dt); // druga rurka, youBy - // hamulec antypoślizgowy - wyłączanie - if ((BrakeSlippingTimer > 0.8) && (ASBType != 128)) // ASBSpeed=0.8 - Hamulec->ASB(0); - // SetFlag(BrakeStatus,-b_antislip); - BrakeSlippingTimer += dt; - // sypanie piasku - wyłączone i piasek się nie kończy - błędy AI - // if AIControllFlag then - // if SandDose then - // if Sand>0 then - // begin - // Sand:=Sand-NPoweredAxles*SandSpeed*dt; - // if Random
10) and (not DebugmodeFlag) then + // security system if (!DebugModeFlag) SecuritySystemCheck(dt1); + return d; }; @@ -1283,7 +1351,6 @@ double TMoverParameters::FastComputeMovement(double dt, const TTrackShape &Shape TTrackParam &Track, const TLocation &NewLoc, TRotation &NewRot) { - double Vprev, AccSprev, d; int b; // T_MoverParameters::FastComputeMovement(dt, Shape, Track, NewLoc, NewRot); @@ -1295,103 +1362,86 @@ double TMoverParameters::FastComputeMovement(double dt, const TTrackShape &Shape if (dL == 0) // oblicz przesuniecie { - Vprev = V; - AccSprev = AccS; - // dt =ActualTime-LastUpdatedTime; //przyrost czasu + auto const AccSprev { AccS }; // przyspieszenie styczne - AccS = (FTotal / TotalMass + AccSprev) / - 2.0; // prawo Newtona ale z wygladzaniem (średnia z poprzednim) + AccS = interpolate( + AccSprev, + FTotal / TotalMass, + 0.5 ); + // clamp( dt * 3.0, 0.0, 1.0 ) ); // prawo Newtona ale z wygladzaniem (średnia z poprzednim) if (TestFlag(DamageFlag, dtrain_out)) AccS = -Sign(V) * g * 1; // * random(0.0, 0.1) - // przyspieszenie normalne} - // if Abs(Shape.R)>0.01 then - // AccN:=SQR(V)/Shape.R+g*Shape.dHrail/TrackW - // else AccN:=g*Shape.dHrail/TrackW; - // szarpanie} - if (FuzzyLogic((10.0 + Track.DamageFlag) * Mass * Vel / Vmax, 500000.0, p_accn)) - { - AccV = sqrt((1.0 + Track.DamageFlag) * Random(floor(50.0 * Mass / 1000000.0)) * Vel / - (Vmax * (10.0 + (Track.QualityFlag & 31)))); // Trunc na floor, czy dobrze? - } - else - AccV = AccV / 2.0; + // simple mode skips calculation of normal acceleration - if (AccV > 1.0) - AccN += (7.0 - Random(5)) * (100.0 + Track.DamageFlag / 2.0) * AccV / 2000.0; - - // {wykolejanie na luku oraz z braku szyn} - // if TestFlag(CategoryFlag,1) then - // begin - // if FuzzyLogic((AccN/g)*(1+0.1*(Track.DamageFlag and - // dtrack_freerail)),TrackW/Dim.H,1) - // or TestFlag(Track.DamageFlag,dtrack_norail) then - // if SetFlag(DamageFlag,dtrain_out) then - // begin - // EventFlag:=true; - // MainS:=false; - // RunningShape.R:=0; - // end; - // {wykolejanie na poszerzeniu toru} - // if FuzzyLogic(Abs(Track.Width-TrackW),TrackW/10,1) then - // if SetFlag(DamageFlag,dtrain_out) then - // begin - // EventFlag:=true; - // MainS:=false; - // RunningShape.R:=0; - // end; - // end; - // {wykolejanie wkutek niezgodnosci kategorii toru i pojazdu} - // if not TestFlag(RunningTrack.CategoryFlag,CategoryFlag) then - // if SetFlag(DamageFlag,dtrain_out) then - // begin - // EventFlag:=true; - // MainS:=false; - // end; - - V += (3.0 * AccS - AccSprev) * dt / 2.0; // przyrost predkosci - - if (TestFlag(DamageFlag, dtrain_out)) - if (Vel < 1) - { - V = 0; - AccS = 0; // Ra 2014-03: ale siła grawitacji działa, więc nie może być zerowe - } - - if ((V * Vprev <= 0) && (abs(FStand) > abs(FTrain))) // tlumienie predkosci przy hamowaniu - { // zahamowany} + // velocity change + auto const Vprev { V }; + V += ( 3.0 * AccS - AccSprev ) * dt / 2.0; // przyrost predkosci + if( ( V * Vprev <= 0 ) + && ( std::abs( FStand ) > std::abs( FTrain ) ) ) { + // tlumienie predkosci przy hamowaniu + // zahamowany V = 0; - AccS = 0; } + + // simple mode skips calculation of tangential acceleration + + // simple mode skips calculation of vertical acceleration + AccVert = 0.0; + + if( ( true == TestFlag( DamageFlag, dtrain_out ) ) + && ( Vel < 1.0 ) ) { + V = 0.0; + AccS = 0.0; + } + dL = (3.0 * V - Vprev) * dt / 2.0; // metoda Adamsa-Bashfortha // ale jesli jest kolizja (zas. zach. pedu) to... for (b = 0; b < 2; b++) if (Couplers[b].CheckCollision) CollisionDetect(b, dt); // zmienia niejawnie AccS, V !!! } // liczone dL, predkosc i przyspieszenie - // QQQ - if (Power > 1.0) // w rozrządczym nie (jest błąd w FIZ!) - UpdatePantVolume(dt); // Ra 2014-07: obsługa zbiornika rozrządu oraz pantografów - if (EngineType == WheelsDriven) - d = (double)CabNo * dL; // na chwile dla testu - else - d = dL; + + auto const d { ( + EngineType == TEngineType::WheelsDriven ? + dL * CabNo : // na chwile dla testu + dL ) }; + DistCounter += fabs(dL) / 1000.0; dL = 0; // koniec procedury, tu nastepuja dodatkowe procedury pomocnicze + compute_movement_( dt ); + + return d; +}; + +// updates shared between 'fast' and regular movement computation methods +void TMoverParameters::compute_movement_( double const Deltatime ) { // sprawdzanie i ewentualnie wykonywanie->kasowanie poleceń if (LoadStatus > 0) // czas doliczamy tylko jeśli trwa (roz)ładowanie - LastLoadChangeTime += dt; // czas (roz)ładunku + LastLoadChangeTime += Deltatime; // czas (roz)ładunku RunInternalCommand(); - if (EngineType == DieselEngine) - if (dizel_Update(dt)) - SetFlag(SoundFlag, sound_relay); + // automatyczny rozruch + if (EngineType == TEngineType::ElectricSeriesMotor) + + if (AutoRelayCheck()) + SetFlag(SoundFlag, sound::relay); + + if( ( EngineType == TEngineType::DieselEngine ) + || ( EngineType == TEngineType::DieselElectric ) ) { + if( dizel_Update( Deltatime ) ) { + SetFlag( SoundFlag, sound::relay ); + } + } + // traction motors + MotorBlowersCheck( Deltatime ); // uklady hamulcowe: + ConverterCheck( Deltatime ); if (VeselVolume > 0) Compressor = CompressedVolume / VeselVolume; else @@ -1399,19 +1449,28 @@ double TMoverParameters::FastComputeMovement(double dt, const TTrackShape &Shape Compressor = 0; CompressorFlag = false; }; - ConverterCheck(); - if (CompressorSpeed > 0.0) // sprężarka musi mieć jakąś niezerową wydajność - CompressorCheck(dt); //żeby rozważać jej załączenie i pracę - UpdateBrakePressure(dt); - UpdatePipePressure(dt); - UpdateScndPipePressure(dt); // druga rurka, youBy - UpdateBatteryVoltage(dt); - // hamulec antyposlizgowy - wyłączanie - if ((BrakeSlippingTimer > 0.8) && (ASBType != 128)) // ASBSpeed=0.8 - Hamulec->ASB(0); - BrakeSlippingTimer += dt; - return d; -}; + if( CompressorSpeed > 0.0 ) { + // sprężarka musi mieć jakąś niezerową wydajność żeby rozważać jej załączenie i pracę + CompressorCheck( Deltatime ); + } + if( Power > 1.0 ) { + // w rozrządczym nie (jest błąd w FIZ!) - Ra 2014-07: teraz we wszystkich + UpdatePantVolume( Deltatime ); // Ra 2014-07: obsługa zbiornika rozrządu oraz pantografów + } + + UpdateBrakePressure(Deltatime); + UpdatePipePressure(Deltatime); + UpdateBatteryVoltage(Deltatime); + UpdateScndPipePressure(Deltatime); // druga rurka, youBy + + if( ( BrakeSlippingTimer > 0.8 ) && ( ASBType != 128 ) ) { // ASBSpeed=0.8 + // hamulec antypoślizgowy - wyłączanie + Hamulec->ASB( 0 ); + } + BrakeSlippingTimer += Deltatime; + // automatic doors + update_autonomous_doors( Deltatime ); +} double TMoverParameters::ShowEngineRotation(int VehN) { // Zwraca wartość prędkości obrotowej silnika wybranego pojazdu. Do 3 pojazdów (3×SN61). @@ -1419,7 +1478,7 @@ double TMoverParameters::ShowEngineRotation(int VehN) switch (VehN) { // numer obrotomierza case 1: - return fabs(enrot); + return std::abs(enrot); case 2: for (b = 0; b <= 1; ++b) if (TestFlag(Couplers[b].CouplingFlag, ctrain_controll)) @@ -1438,19 +1497,162 @@ double TMoverParameters::ShowEngineRotation(int VehN) return 0.0; }; -void TMoverParameters::ConverterCheck() -{ // sprawdzanie przetwornicy - if (ConverterAllow && Mains) - ConverterFlag = true; - else +// sprawdzanie przetwornicy +void TMoverParameters::ConverterCheck( double const Timestep ) { + // TODO: move other converter checks here, to have it all in one place for potential device object + if( ConverterStart == start_t::automatic ) { + ConverterAllow = Mains; + } + + if( ( ConverterAllow ) + && ( ConverterAllowLocal ) + && ( false == PantPressLockActive ) + && ( Mains ) ) { + // delay timer can be optionally configured, and is set anew whenever converter goes off + if( ConverterStartDelayTimer <= 0.0 ) { + ConverterFlag = true; + } + else { + ConverterStartDelayTimer -= Timestep; + } + } + else { ConverterFlag = false; + ConverterStartDelayTimer = static_cast( ConverterStartDelay ); + } }; -double TMoverParameters::ShowCurrent(int AmpN) +// water pump status check +void TMoverParameters::WaterPumpCheck( double const Timestep ) { + // NOTE: breaker override with start type is sm42 specific hack, replace with ability to define the presence of the breaker + WaterPump.is_active = ( + ( true == Battery ) + && ( true == WaterPump.breaker ) + && ( false == WaterPump.is_disabled ) + && ( ( true == WaterPump.is_active ) + || ( true == WaterPump.is_enabled ) || ( WaterPump.start_type == start_t::battery ) ) ); +} + +// water heater status check +void TMoverParameters::WaterHeaterCheck( double const Timestep ) { + + WaterHeater.is_damaged = ( + ( true == WaterHeater.is_damaged ) + || ( ( true == WaterHeater.is_active ) + && ( false == WaterPump.is_active ) ) ); + + WaterHeater.is_active = ( + ( false == WaterHeater.is_damaged ) + && ( true == Battery ) + && ( true == WaterHeater.is_enabled ) + && ( true == WaterHeater.breaker ) + && ( ( WaterHeater.is_active ) || ( WaterHeater.config.temp_min < 0 ) || ( dizel_heat.temperatura1 < WaterHeater.config.temp_min ) ) ); + + if( ( WaterHeater.config.temp_max > 0 ) + && ( dizel_heat.temperatura1 > WaterHeater.config.temp_max ) ) { + WaterHeater.is_active = false; + } +} + +// fuel pump status update +void TMoverParameters::FuelPumpCheck( double const Timestep ) { + + FuelPump.is_active = ( + ( true == Battery ) + && ( false == FuelPump.is_disabled ) + && ( ( FuelPump.is_active ) + || ( FuelPump.start_type == start_t::manual ? ( FuelPump.is_enabled ) : + FuelPump.start_type == start_t::automatic ? ( dizel_startup || Mains ) : + FuelPump.start_type == start_t::manualwithautofallback ? ( FuelPump.is_enabled || dizel_startup || Mains ) : + false ) ) ); // shouldn't ever get this far but, eh +} + +// oil pump status update +void TMoverParameters::OilPumpCheck( double const Timestep ) { + + OilPump.is_active = ( + ( true == Battery ) + && ( false == Mains ) + && ( false == OilPump.is_disabled ) + && ( ( OilPump.is_active ) + || ( OilPump.start_type == start_t::manual ? ( OilPump.is_enabled ) : + OilPump.start_type == start_t::automatic ? ( dizel_startup ) : + OilPump.start_type == start_t::manualwithautofallback ? ( OilPump.is_enabled || dizel_startup ) : + false ) ) ); // shouldn't ever get this far but, eh + + auto const maxrevolutions { + EngineType == TEngineType::DieselEngine ? + dizel_nmax : + DElist[ MainCtrlPosNo ].RPM / 60.0 }; + auto const minpressure { + OilPump.pressure_minimum > 0.f ? + OilPump.pressure_minimum : + 0.15f }; // arbitrary fallback value + + OilPump.pressure_target = ( + enrot > 0.1 ? interpolate( minpressure, OilPump.pressure_maximum, static_cast( clamp( enrot / maxrevolutions, 0.0, 1.0 ) ) ) * OilPump.resource_amount : + true == OilPump.is_active ? std::min( minpressure + 0.1f, OilPump.pressure_maximum ) : // slight pressure margin to give time to switch off the pump and start the engine + 0.f ); + + if( OilPump.pressure < OilPump.pressure_target ) { + // TODO: scale change rate from 0.01-0.05 with oil/engine temperature/idle time + OilPump.pressure = + std::min( + OilPump.pressure_target, + OilPump.pressure + ( enrot > 5.0 ? 0.05 : 0.035 ) * Timestep ); + } + if( OilPump.pressure > OilPump.pressure_target ) { + OilPump.pressure = + std::max( + OilPump.pressure_target, + OilPump.pressure - 0.01 * Timestep ); + } + OilPump.pressure = clamp( OilPump.pressure, 0.f, 1.5f ); +} + +void TMoverParameters::MotorBlowersCheck( double const Timestep ) { + // activation check + for( auto &blower : MotorBlowers ) { + + blower.is_active = ( + // TODO: bind properly power source when ld is in place + ( blower.start_type == start_t::battery ? Battery : + blower.start_type == start_t::converter ? ConverterFlag : + Mains ) // power source + // breaker condition disabled until it's implemented in the class data +// && ( true == blower.breaker ) + && ( false == blower.is_disabled ) + && ( ( true == blower.is_active ) + || ( blower.start_type == start_t::manual ? blower.is_enabled : true ) ) ); + } + // update + for( auto &fan : MotorBlowers ) { + + auto const revolutionstarget { ( + fan.is_active ? + ( fan.speed > 0.f ? fan.speed * static_cast( enrot ) * 60 : fan.speed * -1 ) : + 0.f ) }; + + if( std::abs( fan.revolutions - revolutionstarget ) < 0.01f ) { + fan.revolutions = revolutionstarget; + continue; + } + if( revolutionstarget > 0.f ) { + auto const speedincreasecap { std::max( 50.f, fan.speed * 0.05f * -1 ) }; // 5% of fixed revolution speed, or 50 + fan.revolutions += clamp( revolutionstarget - fan.revolutions, speedincreasecap * -2, speedincreasecap ) * Timestep; + } + else { + fan.revolutions *= std::max( 0.0, 1.0 - Timestep ); + } + } +} + + +double TMoverParameters::ShowCurrent(int AmpN) const { // Odczyt poboru prądu na podanym amperomierzu switch (EngineType) { - case ElectricInductionMotor: + case TEngineType::ElectricInductionMotor: switch (AmpN) { // do asynchronicznych case 1: @@ -1461,7 +1663,7 @@ double TMoverParameters::ShowCurrent(int AmpN) return ShowCurrentP(AmpN); // T_MoverParameters:: } break; - case DieselElectric: + case TEngineType::DieselElectric: return fabs(Im); break; default: @@ -1499,10 +1701,10 @@ bool TMoverParameters::IncMainCtrl(int CtrlSpeed) if (MainCtrlPos < MainCtrlPosNo) { switch( EngineType ) { - case None: - case Dumb: - case DieselElectric: - case ElectricInductionMotor: + case TEngineType::None: + case TEngineType::Dumb: + case TEngineType::DieselElectric: + case TEngineType::ElectricInductionMotor: { if( CtrlSpeed > 1 ) { OK = ( IncMainCtrl( 1 ) @@ -1515,7 +1717,7 @@ bool TMoverParameters::IncMainCtrl(int CtrlSpeed) break; } - case ElectricSeriesMotor: + case TEngineType::ElectricSeriesMotor: { if( ActiveDir == 0 ) { return false; } @@ -1523,20 +1725,12 @@ bool TMoverParameters::IncMainCtrl(int CtrlSpeed) // szybkie przejœcie na bezoporow¹ if( TrainType == dt_ET40 ) { break; // this means ET40 won't react at all to fast acceleration command. should it issue just IncMainCtrl(1) instead? - } + } while( ( RList[ MainCtrlPos ].R > 0.0 ) && IncMainCtrl( 1 ) ) { // all work is done in the loop header ; } - // OK:=true ; {takie chamskie, potem poprawie} <-Ra: kto mia³ to - // poprawiæ i po co? - if( ActiveDir == -1 ) { - while( ( RList[ MainCtrlPos ].Bn > 1 ) - && IncMainCtrl( 1 ) ) { - --MainCtrlPos; - } - } OK = false; // shouldn't this be part of the loop above? // if (TrainType=dt_ET40) then // while Abs (Im)>IminHi do @@ -1550,7 +1744,7 @@ bool TMoverParameters::IncMainCtrl(int CtrlSpeed) if( RList[ MainCtrlPos ].Bn > 1 ) { if( true == MaxCurrentSwitch( false )) { // wylaczanie wysokiego rozruchu - SetFlag( SoundFlag, sound_relay ); + SetFlag( SoundFlag, sound::relay ); } // Q TODO: // if (EngineType=ElectricSeriesMotor) and (MainCtrlPos=1) // then @@ -1562,14 +1756,6 @@ bool TMoverParameters::IncMainCtrl(int CtrlSpeed) } } } - if( ActiveDir == -1 ) { - if( ( TrainType != dt_PseudoDiesel ) - && ( RList[ MainCtrlPos ].Bn > 1 ) ) { - // blokada wejścia na równoległą podczas jazdy do tyłu - --MainCtrlPos; - OK = false; - } - } // // if (TrainType == "et40") // if (Abs(Im) > IminHi) @@ -1578,19 +1764,18 @@ bool TMoverParameters::IncMainCtrl(int CtrlSpeed) // OK = false; // } //} - } + } - if( ( TrainType == dt_ET42 ) && ( true == DynamicBrakeFlag ) ) { - if( MainCtrlPos > 20 ) { - MainCtrlPos = 20; + if( ( TrainType == dt_ET42 ) && ( true == DynamicBrakeFlag ) ) { + if( MainCtrlPos > 20 ) { + MainCtrlPos = 20; OK = false; } - } - // return OK; + } break; } - case DieselEngine: + case TEngineType::DieselEngine: { if( CtrlSpeed > 1 ) { while( MainCtrlPos < MainCtrlPosNo ) { @@ -1606,7 +1791,7 @@ bool TMoverParameters::IncMainCtrl(int CtrlSpeed) break; } - case WheelsDriven: + case TEngineType::WheelsDriven: { OK = AddPulseForce( CtrlSpeed ); break; @@ -1678,14 +1863,14 @@ bool TMoverParameters::DecMainCtrl(int CtrlSpeed) else switch (EngineType) { - case None: - case Dumb: - case DieselElectric: - case ElectricInductionMotor: + case TEngineType::None: + case TEngineType::Dumb: + case TEngineType::DieselElectric: + case TEngineType::ElectricInductionMotor: { if (((CtrlSpeed == 1) && - /*(ScndCtrlPos==0) and*/ (EngineType != DieselElectric)) || - ((CtrlSpeed == 1) && (EngineType == DieselElectric))) + /*(ScndCtrlPos==0) and*/ (EngineType != TEngineType::DieselElectric)) || + ((CtrlSpeed == 1) && (EngineType == TEngineType::DieselElectric))) { MainCtrlPos--; OK = true; @@ -1695,7 +1880,7 @@ bool TMoverParameters::DecMainCtrl(int CtrlSpeed) break; } - case ElectricSeriesMotor: + case TEngineType::ElectricSeriesMotor: { if (CtrlSpeed == 1) /*and (ScndCtrlPos=0)*/ { @@ -1719,7 +1904,7 @@ bool TMoverParameters::DecMainCtrl(int CtrlSpeed) break; } - case DieselEngine: + case TEngineType::DieselEngine: { if (CtrlSpeed == 1) { @@ -1737,7 +1922,7 @@ bool TMoverParameters::DecMainCtrl(int CtrlSpeed) } // switch EngineType } } - else if (EngineType == WheelsDriven) + else if (EngineType == TEngineType::WheelsDriven) OK = AddPulseForce(-CtrlSpeed); else OK = false; @@ -1783,7 +1968,7 @@ bool TMoverParameters::IncScndCtrl(int CtrlSpeed) // if (RList[MainCtrlPos].R=0) and (MainCtrlPos>0) and (ScndCtrlPos CtrlDelay) LastRelayTime = 0; - if ((OK) && (EngineType == ElectricInductionMotor)) + if ((OK) && (EngineType == TEngineType::ElectricInductionMotor) && (ScndCtrlPosNo == 1)) + { + // NOTE: round() already adds 0.5, are the ones added here as well correct? if ((Vmax < 250)) - ScndCtrlActualPos = Round(Vel + 0.5f); + ScndCtrlActualPos = Round(Vel); else - ScndCtrlActualPos = Round(Vel * 1.0 / 2 + 0.5); + ScndCtrlActualPos = Round(Vel * 0.5); + SendCtrlToNext("SpeedCntrl", ScndCtrlActualPos, CabNo); + } return OK; } @@ -1837,7 +2027,7 @@ bool TMoverParameters::DecScndCtrl(int CtrlSpeed) else if ((ScndCtrlPosNo > 0) && (CabNo != 0)) { if ((ScndCtrlPos > 0) && (!CoupledCtrl) && - ((EngineType != DieselElectric) || (!AutoRelayFlag))) + ((EngineType != TEngineType::DieselElectric) || (!AutoRelayFlag))) { if (CtrlSpeed == 1) { @@ -1865,8 +2055,11 @@ bool TMoverParameters::DecScndCtrl(int CtrlSpeed) if (LastRelayTime > CtrlDownDelay) LastRelayTime = 0; - if ((OK) && (EngineType == ElectricInductionMotor)) + if ((OK) && (EngineType == TEngineType::ElectricInductionMotor) && (ScndCtrlPosNo == 1)) + { ScndCtrlActualPos = 0; + SendCtrlToNext("SpeedCntrl", ScndCtrlActualPos, CabNo); + } return OK; } @@ -1884,6 +2077,7 @@ bool TMoverParameters::CabActivisation(void) { CabNo = ActiveCab; // sterowanie jest z kabiny z obsadą DirAbsolute = ActiveDir * CabNo; + SecuritySystem.Status |= s_waiting; // activate the alerter TODO: make it part of control based cab selection SendCtrlToNext("CabActivisation", 1, CabNo); } return OK; @@ -1903,6 +2097,8 @@ bool TMoverParameters::CabDeactivisation(void) CabNo = 0; DirAbsolute = ActiveDir * CabNo; DepartureSignal = false; // nie buczeć z nieaktywnej kabiny + SecuritySystem.Status = 0; // deactivate alerter TODO: make it part of control based cab selection + SendCtrlToNext("CabActivisation", 0, ActiveCab); // CabNo==0! } return OK; @@ -1915,8 +2111,8 @@ bool TMoverParameters::CabDeactivisation(void) bool TMoverParameters::AddPulseForce(int Multipler) { bool APF; - if ((EngineType == WheelsDriven) && (EnginePowerSource.SourceType == InternalSource) && - (EnginePowerSource.PowerType == BioPower)) + if ((EngineType == TEngineType::WheelsDriven) && (EnginePowerSource.SourceType == TPowerSource::InternalSource) && + (EnginePowerSource.PowerType == TPowerType::BioPower)) { ActiveDir = CabNo; DirAbsolute = ActiveDir * CabNo; @@ -1940,23 +2136,43 @@ bool TMoverParameters::AddPulseForce(int Multipler) // Q: 20160713 // sypanie piasku // ************************************************************************************************* -bool TMoverParameters::SandDoseOn(void) +bool TMoverParameters::Sandbox( bool const State, range_t const Notify ) { - bool SDO; - if (SandCapacity > 0) - { - SDO = true; - if (SandDose) - SandDose = false; - else if (Sand > 0) - SandDose = true; - if (CabNo != 0) - SendCtrlToNext("SandDoseOn", 1, CabNo); - } - else - SDO = false; + bool result{ false }; - return SDO; + if( SandDose != State ) { + if( SandDose == false ) { + // switch on + if( Sand > 0 ) { + SandDose = true; + result = true; + } + } + else { + // switch off + SandDose = false; + result = true; + } + } + + if( Notify != range_t::local ) { + // if requested pass the command on + auto const couplingtype = + ( Notify == range_t::unit ? + ctrain_controll | ctrain_depot : + ctrain_controll ); + + if( State == true ) { + // switch on + SendCtrlToNext( "Sandbox", 1, CabNo, couplingtype ); + } + else { + // switch off + SendCtrlToNext( "Sandbox", 0, CabNo, couplingtype ); + } + } + + return result; } void TMoverParameters::SSReset(void) @@ -2023,16 +2239,18 @@ void TMoverParameters::SecuritySystemCheck(double dt) // obsady // poza tym jest zdefiniowany we wszystkich 3 członach EN57 if ((!Radio)) - EmergencyBrakeSwitch(false); + RadiostopSwitch(false); if ((SecuritySystem.SystemType > 0) && (SecuritySystem.Status > 0) && (Battery)) // Ra: EZT ma teraz czuwak w rozrządczym { // CA - if (Vel >= - SecuritySystem - .AwareMinSpeed) // domyślnie predkość większa od 10% Vmax, albo podanej jawnie w FIZ - { + if( ( SecuritySystem.AwareMinSpeed > 0.0 ? + ( Vel >= SecuritySystem.AwareMinSpeed ) : + ( ActiveDir != 0 ) ) ) { + // domyślnie predkość większa od 10% Vmax, albo podanej jawnie w FIZ + // with defined minspeed of 0 the alerter will activate with reverser out of neutral position + // this emulates behaviour of engines like SM42 SecuritySystem.SystemTimer += dt; if (TestFlag(SecuritySystem.SystemType, 1) && TestFlag(SecuritySystem.Status, s_aware)) // jeśli świeci albo miga @@ -2092,7 +2310,7 @@ void TMoverParameters::SecuritySystemCheck(double dt) } else if (!Battery) { // wyłączenie baterii deaktywuje sprzęt - EmergencyBrakeSwitch(false); + RadiostopSwitch(false); // SecuritySystem.Status = 0; //deaktywacja czuwaka } } @@ -2155,7 +2373,7 @@ bool TMoverParameters::DirectionBackward(void) } if ((MainCtrlPosNo > 0) && (ActiveDir > -1) && (MainCtrlPos == 0)) { - if (EngineType == WheelsDriven) + if (EngineType == TEngineType::WheelsDriven) CabNo--; // else ActiveDir--; @@ -2177,74 +2395,407 @@ bool TMoverParameters::DirectionBackward(void) // ************************************************************************************************* bool TMoverParameters::AntiSlippingButton(void) { - return (AntiSlippingBrake() || SandDoseOn()); + // NOTE: disabled the sandbox part, it's already controlled by another part of the AI routine + return (AntiSlippingBrake() /*|| Sandbox(true)*/); +} + +// water pump breaker state toggle +bool TMoverParameters::WaterPumpBreakerSwitch( bool State, range_t const Notify ) { +/* + if( FuelPump.start_type == start::automatic ) { + // automatic fuel pump ignores 'manual' state commands + return false; + } +*/ + bool const initialstate { WaterPump.breaker }; + + WaterPump.breaker = State; + + if( Notify != range_t::local ) { + SendCtrlToNext( + "WaterPumpBreakerSwitch", + ( WaterPump.breaker ? 1 : 0 ), + CabNo, + ( Notify == range_t::unit ? + coupling::control | coupling::permanent : + coupling::control ) ); + } + + return ( WaterPump.breaker != initialstate ); +} + +// water pump state toggle +bool TMoverParameters::WaterPumpSwitch( bool State, range_t const Notify ) { + + if( WaterPump.start_type == start_t::battery ) { + // automatic fuel pump ignores 'manual' state commands + return false; + } + + bool const initialstate { WaterPump.is_enabled }; + + WaterPump.is_enabled = State; + + if( Notify != range_t::local ) { + SendCtrlToNext( + "WaterPumpSwitch", + ( WaterPump.is_enabled ? 1 : 0 ), + CabNo, + ( Notify == range_t::unit ? + coupling::control | coupling::permanent : + coupling::control ) ); + } + + return ( WaterPump.is_enabled != initialstate ); +} + +// water pump state toggle +bool TMoverParameters::WaterPumpSwitchOff( bool State, range_t const Notify ) { + + if( WaterPump.start_type == start_t::battery ) { + // automatic fuel pump ignores 'manual' state commands + return false; + } + + bool const initialstate { WaterPump.is_disabled }; + + WaterPump.is_disabled = State; + + if( Notify != range_t::local ) { + SendCtrlToNext( + "WaterPumpSwitchOff", + ( WaterPump.is_disabled ? 1 : 0 ), + CabNo, + ( Notify == range_t::unit ? + coupling::control | coupling::permanent : + coupling::control ) ); + } + + return ( WaterPump.is_disabled != initialstate ); +} + +// water heater breaker state toggle +bool TMoverParameters::WaterHeaterBreakerSwitch( bool State, range_t const Notify ) { +/* + if( FuelPump.start_type == start::automatic ) { + // automatic fuel pump ignores 'manual' state commands + return false; + } +*/ + bool const initialstate { WaterHeater.breaker }; + + WaterHeater.breaker = State; + + if( Notify != range_t::local ) { + SendCtrlToNext( + "WaterHeaterBreakerSwitch", + ( WaterHeater.breaker ? 1 : 0 ), + CabNo, + ( Notify == range_t::unit ? + coupling::control | coupling::permanent : + coupling::control ) ); + } + + return ( WaterHeater.breaker != initialstate ); +} + +// water heater state toggle +bool TMoverParameters::WaterHeaterSwitch( bool State, range_t const Notify ) { +/* + if( FuelPump.start_type == start::automatic ) { + // automatic fuel pump ignores 'manual' state commands + return false; + } +*/ + bool const initialstate { WaterHeater.is_enabled }; + + WaterHeater.is_enabled = State; + + if( Notify != range_t::local ) { + SendCtrlToNext( + "WaterHeaterSwitch", + ( WaterHeater.is_enabled ? 1 : 0 ), + CabNo, + ( Notify == range_t::unit ? + coupling::control | coupling::permanent : + coupling::control ) ); + } + + return ( WaterHeater.is_enabled != initialstate ); +} + +// water circuits link state toggle +bool TMoverParameters::WaterCircuitsLinkSwitch( bool State, range_t const Notify ) { + + if( false == dizel_heat.auxiliary_water_circuit ) { + // can't link the circuits if the vehicle only has one + return false; + } + + bool const initialstate { WaterCircuitsLink }; + + WaterCircuitsLink = State; + + if( Notify != range_t::local ) { + SendCtrlToNext( + "WaterCircuitsLinkSwitch", + ( WaterCircuitsLink ? 1 : 0 ), + CabNo, + ( Notify == range_t::unit ? + coupling::control | coupling::permanent : + coupling::control ) ); + } + + return ( WaterCircuitsLink != initialstate ); +} + +// fuel pump state toggle +bool TMoverParameters::FuelPumpSwitch( bool State, range_t const Notify ) { + + if( FuelPump.start_type == start_t::automatic ) { + // automatic fuel pump ignores 'manual' state commands + return false; + } + + bool const initialstate { FuelPump.is_enabled }; + + FuelPump.is_enabled = State; + + if( Notify != range_t::local ) { + SendCtrlToNext( + "FuelPumpSwitch", + ( FuelPump.is_enabled ? 1 : 0 ), + CabNo, + ( Notify == range_t::unit ? + coupling::control | coupling::permanent : + coupling::control ) ); + } + + return ( FuelPump.is_enabled != initialstate ); +} + +bool TMoverParameters::FuelPumpSwitchOff( bool State, range_t const Notify ) { + + if( FuelPump.start_type == start_t::automatic ) { + // automatic fuel pump ignores 'manual' state commands + return false; + } + + bool const initialstate { FuelPump.is_disabled }; + + FuelPump.is_disabled = State; + + if( Notify != range_t::local ) { + SendCtrlToNext( + "FuelPumpSwitchOff", + ( FuelPump.is_disabled ? 1 : 0 ), + CabNo, + ( Notify == range_t::unit ? + coupling::control | coupling::permanent : + coupling::control ) ); + } + + return ( FuelPump.is_disabled != initialstate ); +} + +// oil pump state toggle +bool TMoverParameters::OilPumpSwitch( bool State, range_t const Notify ) { + + if( OilPump.start_type == start_t::automatic ) { + // automatic pump ignores 'manual' state commands + return false; + } + + bool const initialstate { OilPump.is_enabled }; + + OilPump.is_enabled = State; + + if( Notify != range_t::local ) { + SendCtrlToNext( + "OilPumpSwitch", + ( OilPump.is_enabled ? 1 : 0 ), + CabNo, + ( Notify == range_t::unit ? + coupling::control | coupling::permanent : + coupling::control ) ); + } + + return ( OilPump.is_enabled != initialstate ); +} + +bool TMoverParameters::OilPumpSwitchOff( bool State, range_t const Notify ) { + + if( OilPump.start_type == start_t::automatic ) { + // automatic pump ignores 'manual' state commands + return false; + } + + bool const initialstate { OilPump.is_disabled }; + + OilPump.is_disabled = State; + + if( Notify != range_t::local ) { + SendCtrlToNext( + "OilPumpSwitchOff", + ( OilPump.is_disabled ? 1 : 0 ), + CabNo, + ( Notify == range_t::unit ? + coupling::control | coupling::permanent : + coupling::control ) ); + } + + return ( OilPump.is_disabled != initialstate ); +} + +bool TMoverParameters::MotorBlowersSwitch( bool State, side const Side, range_t const Notify ) { + + auto &fan { MotorBlowers[ Side ] }; + + if( ( fan.start_type != start_t::manual ) + && ( fan.start_type != start_t::manualwithautofallback ) ) { + // automatic device ignores 'manual' state commands + return false; + } + + bool const initialstate { fan.is_enabled }; + + fan.is_enabled = State; + + if( Notify != range_t::local ) { + SendCtrlToNext( + ( Side == side::front ? "MotorBlowersFrontSwitch" : "MotorBlowersRearSwitch" ), + ( fan.is_enabled ? 1 : 0 ), + CabNo, + ( Notify == range_t::unit ? + coupling::control | coupling::permanent : + coupling::control ) ); + } + + return ( fan.is_enabled != initialstate ); +} + +bool TMoverParameters::MotorBlowersSwitchOff( bool State, side const Side, range_t const Notify ) { + + auto &fan { MotorBlowers[ Side ] }; + + if( ( fan.start_type != start_t::manual ) + && ( fan.start_type != start_t::manualwithautofallback ) ) { + // automatic device ignores 'manual' state commands + return false; + } + + bool const initialstate { fan.is_disabled }; + + fan.is_disabled = State; + + if( Notify != range_t::local ) { + SendCtrlToNext( + ( Side == side::front ? "MotorBlowersFrontSwitchOff" : "MotorBlowersRearSwitchOff" ), + ( fan.is_disabled ? 1 : 0 ), + CabNo, + ( Notify == range_t::unit ? + coupling::control | coupling::permanent : + coupling::control ) ); + } + + return ( fan.is_disabled != initialstate ); } // ************************************************************************************************* // Q: 20160713 // włączenie / wyłączenie obwodu głownego // ************************************************************************************************* -bool TMoverParameters::MainSwitch(bool State) +bool TMoverParameters::MainSwitch( bool const State, range_t const Notify ) { - bool MS; + bool const initialstate { Mains || dizel_startup }; - MS = false; // Ra: przeniesione z końca - if ((Mains != State) && (MainCtrlPosNo > 0)) - { - if ((State == false) || - ((ScndCtrlPos == 0) && ((ConvOvldFlag == false) || (TrainType == dt_EZT)) && - (LastSwitchingTime > CtrlDelay) && !TestFlag(DamageFlag, dtrain_out) && - !TestFlag(EngDmgFlag, 1))) - { - if (Mains) // jeśli był załączony - SendCtrlToNext("MainSwitch", int(State), - CabNo); // wysłanie wyłączenia do pozostałych? - Mains = State; - if (Mains) // jeśli został załączony - SendCtrlToNext("MainSwitch", int(State), - CabNo); // wyslanie po wlaczeniu albo przed wylaczeniem - MS = true; // wartość zwrotna - LastSwitchingTime = 0; - if ((EngineType == DieselEngine) && Mains) - { - dizel_enginestart = State; + if( ( Mains != State ) + && ( MainCtrlPosNo > 0 ) ) { + + if( ( false == State ) + || ( ( ( ScndCtrlPos == 0 ) || ( EngineType == TEngineType::ElectricInductionMotor ) ) + && ( ( ConvOvldFlag == false ) || ( TrainType == dt_EZT ) ) + && ( true == NoVoltRelay ) + && ( true == OvervoltageRelay ) + && ( LastSwitchingTime > CtrlDelay ) + && ( false == TestFlag( DamageFlag, dtrain_out ) ) + && ( false == TestFlag( EngDmgFlag, 1 ) ) ) ) { + + if( true == State ) { + // switch on + if( ( EngineType == TEngineType::DieselEngine ) + || ( EngineType == TEngineType::DieselElectric ) ) { + // launch diesel engine startup procedure + dizel_startup = true; + } + else { + Mains = true; + } + } + else { + Mains = false; + // potentially knock out the pumps if their switch doesn't force them on + WaterPump.is_active &= WaterPump.is_enabled; + FuelPump.is_active &= FuelPump.is_enabled; + } + + if( ( TrainType == dt_EZT ) + && ( false == State ) ) { + + ConvOvldFlag = true; + } + + if( Mains != initialstate ) { + LastSwitchingTime = 0; + } + + if( Notify != range_t::local ) { + // pass the command to other vehicles + SendCtrlToNext( + "MainSwitch", + ( State ? 1 : 0 ), + CabNo, + ( Notify == range_t::unit ? + coupling::control | coupling::permanent : + coupling::control ) ); } - if (((TrainType == dt_EZT) && (!State))) - ConvOvldFlag = true; - // if (State=false) then //jeśli wyłączony - // begin - // SetFlag(SoundFlag,sound_relay); //hunter-091012: przeniesione do Train.cpp, zeby sie - // nie zapetlal - // if (SecuritySystem.Status<>12) then - // SecuritySystem.Status:=0; //deaktywacja czuwaka; Ra: a nie baterią? - // end - // else - // if (SecuritySystem.Status<>12) then - // SecuritySystem.Status:=s_waiting; //aktywacja czuwaka } } - // else MainSwitch:=false; - return MS; + + return ( ( Mains || dizel_startup ) != initialstate ); } // ************************************************************************************************* // Q: 20160713 // włączenie / wyłączenie przetwornicy // ************************************************************************************************* -bool TMoverParameters::ConverterSwitch(bool State) +bool TMoverParameters::ConverterSwitch( bool State, range_t const Notify ) { bool CS = false; // Ra: normalnie chyba false? + if (ConverterAllow != State) { ConverterAllow = State; CS = true; - if (CompressorPower == 2) - CompressorAllow = ConverterAllow; } - if (ConverterAllow == true) - SendCtrlToNext("ConverterSwitch", 1, CabNo); - else - SendCtrlToNext("ConverterSwitch", 0, CabNo); + if( ConverterAllow == true ) { + if( Notify != range_t::local ) { + SendCtrlToNext( + "ConverterSwitch", 1, CabNo, + ( Notify == range_t::unit ? + ctrain_controll | ctrain_depot : + ctrain_controll ) ); + } + } + else { + if( Notify != range_t::local ) { + SendCtrlToNext( + "ConverterSwitch", 0, CabNo, + ( Notify == range_t::unit ? + ctrain_controll | ctrain_depot : + ctrain_controll ) ); + } + } return CS; } @@ -2253,21 +2804,37 @@ bool TMoverParameters::ConverterSwitch(bool State) // Q: 20160713 // włączenie / wyłączenie sprężarki // ************************************************************************************************* -bool TMoverParameters::CompressorSwitch(bool State) +bool TMoverParameters::CompressorSwitch( bool State, range_t const Notify ) { + if( CompressorStart != start_t::manual ) { + // only pay attention if the compressor can be controlled manually + return false; + } + bool CS = false; // Ra: normalnie chyba tak? - // if State=true then - // if ((CompressorPower=2) and (not ConverterAllow)) then - // State:=false; //yB: to juz niepotrzebne - if ((CompressorAllow != State) && (CompressorPower < 2)) + if ( CompressorAllow != State ) { CompressorAllow = State; CS = true; } - if (CompressorAllow == true) - SendCtrlToNext("CompressorSwitch", 1, CabNo); - else - SendCtrlToNext("CompressorSwitch", 0, CabNo); + if( CompressorAllow == true ) { + if( Notify != range_t::local ) { + SendCtrlToNext( + "CompressorSwitch", 1, CabNo, + ( Notify == range_t::unit ? + ctrain_controll | ctrain_depot : + ctrain_controll ) ); + } + } + else { + if( Notify != range_t::local ) { + SendCtrlToNext( + "CompressorSwitch", 0, CabNo, + ( Notify == range_t::unit ? + ctrain_controll | ctrain_depot : + ctrain_controll ) ); + } + } return CS; } @@ -2280,61 +2847,21 @@ bool TMoverParameters::IncBrakeLevelOld(void) { bool IBLO = false; - if ((BrakeCtrlPosNo > 0) /*and (LocalBrakePos=0)*/) + if (BrakeCtrlPosNo > 0) { if (BrakeCtrlPos < BrakeCtrlPosNo) { - BrakeCtrlPos++; - // BrakeCtrlPosR = BrakeCtrlPos; - - // youBy: wywalilem to, jak jest EP, to sa przenoszone sygnaly nt. co ma robic, a nie - // poszczegolne pozycje; - // wystarczy spojrzec na Knorra i Oerlikona EP w EN57; mogly ze soba - // wspolapracowac - //{ - // if (BrakeSystem==ElectroPneumatic) - // if (BrakePressureActual.BrakeType==ElectroPneumatic) - // { - // BrakeStatus = ord(BrakeCtrlPos > 0); - // SendCtrlToNext("BrakeCtrl", BrakeCtrlPos, CabNo); - // } - // else SendCtrlToNext("BrakeCtrl", -2, CabNo); - // else - // if (!TestFlag(BrakeStatus,b_dmg)) - // BrakeStatus = b_on;} - + ++BrakeCtrlPos; // youBy: EP po nowemu - IBLO = true; if ((BrakePressureActual.PipePressureVal < 0) && (BrakePressureTable[BrakeCtrlPos - 1].PipePressureVal > 0)) LimPipePress = PipePress; - - //ten kawałek jest bez sensu gdyż nic nie robił. Zakomntowałem. GF 20161124 - //if (BrakeSystem == ElectroPneumatic) - // if (BrakeSubsystem != ss_K) - // { - // if ((BrakeCtrlPos * BrakeCtrlPos) == 1) - // { - // // SendCtrlToNext('Brake',BrakeCtrlPos,CabNo); - // // SetFlag(BrakeStatus,b_epused); - // } - // else - // { - // // SendCtrlToNext('Brake',0,CabNo); - // // SetFlag(BrakeStatus,-b_epused); - // } - // } } - else - { + else { IBLO = false; - // if (BrakeSystem == Pneumatic) - // EmergencyBrakeSwitch(true); } } - else - IBLO = false; return IBLO; } @@ -2347,69 +2874,20 @@ bool TMoverParameters::DecBrakeLevelOld(void) { bool DBLO = false; - if ((BrakeCtrlPosNo > 0) /*&& (LocalBrakePos == 0)*/) + if (BrakeCtrlPosNo > 0) { - if (BrakeCtrlPos > -1 - int(BrakeHandle == FV4a)) + if (BrakeCtrlPos > ( ( BrakeHandle == TBrakeHandle::FV4a ) ? -2 : -1 ) ) { - BrakeCtrlPos--; - // BrakeCtrlPosR:=BrakeCtrlPos; - //if (EmergencyBrakeFlag) - //{ - // EmergencyBrakeFlag = false; //!!! - // SendCtrlToNext("Emergency_brake", 0, CabNo); - //} - - // youBy: wywalilem to, jak jest EP, to sa przenoszone sygnaly nt. co ma robic, a nie - // poszczegolne pozycje; - // wystarczy spojrzec na Knorra i Oerlikona EP w EN57; mogly ze soba - // wspolapracowac - /* - if (BrakeSystem == ElectroPneumatic) - if (BrakePressureActual.BrakeType == ElectroPneumatic) - { - // BrakeStatus =ord(BrakeCtrlPos > 0); - SendCtrlToNext("BrakeCtrl",BrakeCtrlPos,CabNo); - } - else SendCtrlToNext('BrakeCtrl',-2,CabNo); - // else} - // if (not TestFlag(BrakeStatus,b_dmg) and (not - TestFlag(BrakeStatus,b_release))) then - // BrakeStatus:=b_off; {luzowanie jesli dziala oraz nie byl wlaczony - odluzniacz - */ - + --BrakeCtrlPos; // youBy: EP po nowemu DBLO = true; - // if ((BrakePressureTable[BrakeCtrlPos].PipePressureVal<0.0) && - // (BrakePressureTable[BrakeCtrlPos+1].PipePressureVal > 0)) - // LimPipePress:=PipePress; - - // to nic nie robi. Zakomentowałem. GF 20161124 - //if (BrakeSystem == ElectroPneumatic) - // if (BrakeSubsystem != ss_K) - // { - // if ((BrakeCtrlPos * BrakeCtrlPos) == 1) - // { - // // SendCtrlToNext("Brake", BrakeCtrlPos, CabNo); - // // SetFlag(BrakeStatus, b_epused); - // } - // else - // { - // // SendCtrlToNext("Brake", 0, CabNo); - // // SetFlag(BrakeStatus, -b_epused); - // } - // } - // for b:=0 to 1 do {poprawic to!} - // with Couplers[b] do - // if CouplingFlag and ctrain_controll=ctrain_controll then - // Connected^.BrakeCtrlPos:=BrakeCtrlPos; - // +// if ((BrakePressureTable[BrakeCtrlPos].PipePressureVal<0.0) && +// (BrakePressureTable[BrakeCtrlPos+1].PipePressureVal > 0)) +// LimPipePress=PipePress; } else DBLO = false; } - else - DBLO = false; return DBLO; } @@ -2418,17 +2896,12 @@ bool TMoverParameters::DecBrakeLevelOld(void) // Q: 20160711 // zwiększenie nastawy hamulca pomocnicznego // ************************************************************************************************* -bool TMoverParameters::IncLocalBrakeLevel(int CtrlSpeed) +bool TMoverParameters::IncLocalBrakeLevel(float const CtrlSpeed) { bool IBL; - if ((LocalBrakePos < LocalBrakePosNo) /*and (BrakeCtrlPos<1)*/) + if ((LocalBrakePosA < 1.0) /*and (BrakeCtrlPos<1)*/) { - while ((LocalBrakePos < LocalBrakePosNo) && (CtrlSpeed > 0)) - { - LocalBrakePos++; -// LocalBrakePosA = static_cast(LocalBrakePos) / LocalBrakePosNo; // temporary hack until i figure out how this element is supposed to work - CtrlSpeed--; - } + LocalBrakePosA = std::min( 1.0, LocalBrakePosA + CtrlSpeed / LocalBrakePosNo ); IBL = true; } else @@ -2442,17 +2915,12 @@ bool TMoverParameters::IncLocalBrakeLevel(int CtrlSpeed) // Q: 20160711 // zmniejszenie nastawy hamulca pomocniczego // ************************************************************************************************* -bool TMoverParameters::DecLocalBrakeLevel(int CtrlSpeed) +bool TMoverParameters::DecLocalBrakeLevel(float const CtrlSpeed) { bool DBL; - if (LocalBrakePos > 0) + if (LocalBrakePosA > 0) { - while ((CtrlSpeed > 0) && (LocalBrakePos > 0)) - { - LocalBrakePos--; -// LocalBrakePosA = static_cast( LocalBrakePos ) / LocalBrakePosNo; // temporary hack until i figure out how this element is supposed to work - CtrlSpeed--; - } + LocalBrakePosA = std::max( 0.0, LocalBrakePosA - CtrlSpeed / LocalBrakePosNo ); DBL = true; } else @@ -2462,44 +2930,6 @@ bool TMoverParameters::DecLocalBrakeLevel(int CtrlSpeed) return DBL; } -// ************************************************************************************************* -// Q: 20160711 -// ustawienie pozycji kranu pomocniczego na masymalną wartość -// ************************************************************************************************* -bool TMoverParameters::IncLocalBrakeLevelFAST(void) -{ - bool ILBLF; - if (LocalBrakePos < LocalBrakePosNo) - { - LocalBrakePos = LocalBrakePosNo; -// LocalBrakePosA = static_cast( LocalBrakePos ) / LocalBrakePosNo; // temporary hack until i figure out how this element is supposed to work - ILBLF = true; - } - else - ILBLF = false; - UnBrake = true; - return ILBLF; -} - -// ************************************************************************************************* -// Q: 20160711 -// ustawienie pozycji hamulca pomocniczego na minimalną -// ************************************************************************************************* -bool TMoverParameters::DecLocalBrakeLevelFAST(void) -{ - bool DLBLF; - if (LocalBrakePos > 0) - { - LocalBrakePos = 0; -// LocalBrakePosA = static_cast( LocalBrakePos ) / LocalBrakePosNo; // temporary hack until i figure out how this element is supposed to work - DLBLF = true; - } - else - DLBLF = false; - UnBrake = true; - return DLBLF; -} - // ************************************************************************************************* // Q: 20160711 // zwiększenie nastawy hamulca ręcznego @@ -2575,34 +3005,49 @@ bool TMoverParameters::DynamicBrakeSwitch(bool Switch) // Q: 20160711 // włączenie / wyłączenie hamowania awaryjnego // ************************************************************************************************* -bool TMoverParameters::EmergencyBrakeSwitch(bool Switch) +bool TMoverParameters::RadiostopSwitch(bool Switch) { bool EBS; - if ((BrakeSystem != Individual) && (BrakeCtrlPosNo > 0)) - { - if ((!EmergencyBrakeFlag) && Switch) - { - EmergencyBrakeFlag = Switch; + if( ( BrakeSystem != TBrakeSystem::Individual ) + && ( BrakeCtrlPosNo > 0 ) ) { + + if( ( true == Switch ) + && ( false == RadioStopFlag ) ) { + RadioStopFlag = Switch; EBS = true; } - else - { - if ((abs(V) < 0.1) && - (Switch == false)) // odblokowanie hamulca bezpieczenistwa tylko po zatrzymaniu - { - EmergencyBrakeFlag = Switch; + else { + if( ( Switch == false ) + && ( std::abs( V ) < 0.1 ) ) { + // odblokowanie hamulca bezpieczenistwa tylko po zatrzymaniu + RadioStopFlag = Switch; EBS = true; } - else + else { EBS = false; + } } } - else - EBS = false; // nie ma hamulca bezpieczenstwa gdy nie ma hamulca zesp. + else { + // nie ma hamulca bezpieczenstwa gdy nie ma hamulca zesp. + EBS = false; + } return EBS; } +bool TMoverParameters::AlarmChainSwitch( bool const State ) { + + bool stateswitched { false }; + + if( AlarmChainFlag != State ) { + // simple routine for the time being + AlarmChainFlag = State; + stateswitched = true; + } + return stateswitched; +} + // ************************************************************************************************* // Q: 20160710 // hamowanie przeciwpoślizgowe @@ -2642,7 +3087,7 @@ bool TMoverParameters::SwitchEPBrake(int state) double temp; OK = false; - if ((BrakeHandle == St113) && (ActiveCab != 0)) + if ((BrakeHandle == TBrakeHandle::St113) && (ActiveCab != 0)) { if (state > 0) temp = Handle->GetCP(); // TODO: przetlumaczyc @@ -2723,7 +3168,7 @@ bool TMoverParameters::BrakeDelaySwitch(int BDS) { bool rBDS; // if (BrakeCtrlPosNo > 0) - if (BrakeHandle == MHZ_EN57) + if (BrakeHandle == TBrakeHandle::MHZ_EN57) { if ((BDS != BrakeOpModeFlag) && ((BDS & BrakeOpModes) > 0)) { @@ -2737,13 +3182,14 @@ bool TMoverParameters::BrakeDelaySwitch(int BDS) { BrakeDelayFlag = BDS; rBDS = true; - BrakeStatus &= 191; + Hamulec->SetBrakeStatus( Hamulec->GetBrakeStatus() & ~64 ); // kopowanie nastawy hamulca do kolejnego czlonu - do przemyślenia if (CabNo != 0) SendCtrlToNext("BrakeDelay", BrakeDelayFlag, CabNo); } else rBDS = false; + return rBDS; } @@ -2806,6 +3252,8 @@ void TMoverParameters::UpdateBrakePressure(double dt) dpLocalValve = 0; dpBrake = 0; + Hamulec->ForceLeak( dt * AirLeakRate * 0.25 ); // fake air leaks from brake system reservoirs + BrakePress = Hamulec->GetBCP(); // BrakePress:=(Hamulec as TEst4).ImplsRes.pa; Volume = Hamulec->GetBRP(); @@ -2815,120 +3263,237 @@ void TMoverParameters::UpdateBrakePressure(double dt) // Q: 20160712 // Obliczanie pracy sprężarki // ************************************************************************************************* +// TODO: clean the method up, a lot of the code is redundant void TMoverParameters::CompressorCheck(double dt) { - // if (CompressorSpeed>0.0) then //ten warunek został sprawdzony przy wywołaniu funkcji - if (VeselVolume > 0) - { - if (MaxCompressor - MinCompressor < 0.0001) - { - // if (Mains && (MainCtrlPos > 1)) - if (CompressorAllow && Mains && (MainCtrlPos > 0)) - { - if (Compressor < MaxCompressor) - if ((EngineType == DieselElectric) && (CompressorPower > 0)) - CompressedVolume += dt * CompressorSpeed * - (2.0 * MaxCompressor - Compressor) / MaxCompressor * - (DElist[MainCtrlPos].RPM / DElist[MainCtrlPosNo].RPM); - else - { - CompressedVolume += - dt * CompressorSpeed * (2.0 * MaxCompressor - Compressor) / MaxCompressor; - TotalCurrent += 0.0015 - * Voltage; // tymczasowo tylko obciążenie sprężarki, tak z 5A na sprężarkę + if( VeselVolume == 0.0 ) { return; } + + CompressedVolume = std::max( 0.0, CompressedVolume - dt * AirLeakRate * 0.1 ); // nieszczelności: 0.001=1l/s + + if( ( true == CompressorGovernorLock ) + && ( Compressor < MinCompressor ) ) { + // if the pressure drops below the cut-in level, we can reset compressor governor + // TBD, TODO: don't operate the lock without battery power? + CompressorGovernorLock = false; + } + + if( CompressorPower == 2 ) { + CompressorAllow = ConverterAllow; + } + + if (MaxCompressor - MinCompressor < 0.0001) { + // TODO: investigate purpose of this branch and whether it can be removed as it duplicates later code + if( ( true == CompressorAllow ) + && ( true == CompressorAllowLocal ) + && ( true == Mains ) + && ( MainCtrlPos > 0 ) ) { + if( Compressor < MaxCompressor ) { + if( ( EngineType == TEngineType::DieselElectric ) + && ( CompressorPower > 0 ) ) { + CompressedVolume += + CompressorSpeed + * ( 2.0 * MaxCompressor - Compressor ) / MaxCompressor + * ( ( 60.0 * std::abs( enrot ) ) / DElist[ MainCtrlPosNo ].RPM ) + * dt; + } + else { + CompressedVolume += + CompressorSpeed + * ( 2.0 * MaxCompressor - Compressor ) / MaxCompressor + * dt; + TotalCurrent += 0.0015 * Voltage; // tymczasowo tylko obciążenie sprężarki, tak z 5A na sprężarkę + } + } + else { + CompressedVolume = CompressedVolume * 0.8; + SetFlag(SoundFlag, sound::relay | sound::loud); + } + } + } + else { + if( CompressorPower == 3 ) { + // experimental: make sure compressor coupled with diesel engine is always ready for work + CompressorStart = start_t::automatic; + } + if (CompressorFlag) // jeśli sprężarka załączona + { // sprawdzić możliwe warunki wyłączenia sprężarki + if (CompressorPower == 5) // jeśli zasilanie z sąsiedniego członu + { // zasilanie sprężarki w członie ra z członu silnikowego (sprzęg 1) + if( Couplers[ side::rear ].Connected != NULL ) { + CompressorFlag = ( + ( ( Couplers[ side::rear ].Connected->CompressorAllow ) || ( CompressorStart == start_t::automatic ) ) + && ( CompressorAllowLocal ) + && ( Couplers[ side::rear ].Connected->ConverterFlag ) ); + } + else { + // bez tamtego członu nie zadziała + CompressorFlag = false; + } + } + else if (CompressorPower == 4) // jeśli zasilanie z poprzedniego członu + { // zasilanie sprężarki w członie ra z członu silnikowego (sprzęg 1) + if( Couplers[ side::front ].Connected != NULL ) { + CompressorFlag = ( + ( ( Couplers[ side::front ].Connected->CompressorAllow ) || ( CompressorStart == start_t::automatic ) ) + && ( CompressorAllowLocal ) + && ( Couplers[ side::front ].Connected->ConverterFlag ) ); + } + else { + CompressorFlag = false; // bez tamtego członu nie zadziała + } + } + else + CompressorFlag = ( + ( ( CompressorAllow ) || ( CompressorStart == start_t::automatic ) ) + && ( CompressorAllowLocal ) + && ( Mains ) + && ( ( ConverterFlag ) + || ( CompressorPower == 0 ) + || ( CompressorPower == 3 ) ) ); + + if( Compressor > MaxCompressor ) { + // wyłącznik ciśnieniowy jest niezależny od sposobu zasilania + // TBD, TODO: don't operate the lock without battery power? + if( CompressorPower == 3 ) { + // if the compressor is powered directly by the engine the lock can't turn it off and instead just changes the output + if( false == CompressorGovernorLock ) { + // emit relay sound when the lock engages (the state change itself is below) and presumably changes where the air goes + SetFlag( SoundFlag, sound::relay | sound::loud ); } - else - { - CompressedVolume = CompressedVolume * 0.8; - SetFlag(SoundFlag, sound_relay | sound_loud); - // SetFlag(SoundFlag, sound_loud); + } + else { + // if the compressor isn't coupled with the engine the lock can control its state freely + CompressorFlag = false; + } + CompressorGovernorLock = true; // prevent manual activation until the pressure goes below cut-in level + } + + if( ( TrainType == dt_ET41 ) + || ( TrainType == dt_ET42 ) ) { + // for these multi-unit engines compressors turn off whenever any of them was affected by the governor + // NOTE: this is crude implementation, TODO: re-implement when a more elegant/flexible system is in place + if( ( Couplers[ 1 ].Connected != nullptr ) + && ( true == TestFlag( Couplers[ 1 ].CouplingFlag, coupling::permanent ) ) ) { + // the first unit isn't allowed to start its compressor until second unit can start its own as well + CompressorFlag &= ( Couplers[ 1 ].Connected->CompressorGovernorLock == false ); + } + if( ( Couplers[ 0 ].Connected != nullptr ) + && ( true == TestFlag( Couplers[ 0 ].CouplingFlag, coupling::permanent ) ) ) { + // the second unit isn't allowed to start its compressor until first unit can start its own as well + CompressorFlag &= ( Couplers[ 0 ].Connected->CompressorGovernorLock == false ); } } } - else - { - if (CompressorFlag) // jeśli sprężarka załączona - { // sprawdzić możliwe warunki wyłączenia sprężarki - if (CompressorPower == 5) // jeśli zasilanie z sąsiedniego członu + else { + // jeśli nie załączona + if( ( LastSwitchingTime > CtrlDelay ) + && ( ( Compressor < MinCompressor ) + || ( ( Compressor < MaxCompressor ) + && ( false == CompressorGovernorLock ) ) ) ) { + // załączenie przy małym ciśnieniu + // jeśli nie załączona, a ciśnienie za małe + // or if the switch is on and the pressure isn't maxed + if( CompressorPower == 5 ) // jeśli zasilanie z następnego członu { // zasilanie sprężarki w członie ra z członu silnikowego (sprzęg 1) - if (Couplers[1].Connected != NULL) - CompressorFlag = - (Couplers[1].Connected->CompressorAllow && - Couplers[1].Connected->ConverterFlag && Couplers[1].Connected->Mains); - else - CompressorFlag = false; // bez tamtego członu nie zadziała + if( Couplers[ side::rear ].Connected != NULL ) { + CompressorFlag = ( + ( ( Couplers[ side::rear ].Connected->CompressorAllow ) || ( CompressorStart == start_t::automatic ) ) + && ( CompressorAllowLocal ) + && ( Couplers[ side::rear ].Connected->ConverterFlag ) ); + } + else { + // bez tamtego członu nie zadziała + CompressorFlag = false; + } } - else if (CompressorPower == 4) // jeśli zasilanie z poprzedniego członu + else if( CompressorPower == 4 ) // jeśli zasilanie z poprzedniego członu { // zasilanie sprężarki w członie ra z członu silnikowego (sprzęg 1) - if (Couplers[0].Connected != NULL) - CompressorFlag = - (Couplers[0].Connected->CompressorAllow && - Couplers[0].Connected->ConverterFlag && Couplers[0].Connected->Mains); - else + if( Couplers[ side::front ].Connected != NULL ) { + CompressorFlag = ( + ( ( Couplers[ side::front ].Connected->CompressorAllow ) || ( CompressorStart == start_t::automatic ) ) + && ( CompressorAllowLocal ) + && ( Couplers[ side::front ].Connected->ConverterFlag ) ); + } + else { CompressorFlag = false; // bez tamtego członu nie zadziała + } } - else - CompressorFlag = (CompressorAllow) && - ((ConverterFlag) || (CompressorPower == 0)) && (Mains); - if (Compressor > - MaxCompressor) // wyłącznik ciśnieniowy jest niezależny od sposobu zasilania - CompressorFlag = false; - } - else // jeśli nie załączona - if ((Compressor < MinCompressor) && - (LastSwitchingTime > CtrlDelay)) // jeśli nie załączona, a ciśnienie za małe - { // załączenie przy małym ciśnieniu - if (CompressorPower == 5) // jeśli zasilanie z następnego członu - { // zasilanie sprężarki w członie ra z członu silnikowego (sprzęg 1) - if (Couplers[1].Connected != NULL) - CompressorFlag = - (Couplers[1].Connected->CompressorAllow && - Couplers[1].Connected->ConverterFlag && Couplers[1].Connected->Mains); - else - CompressorFlag = false; // bez tamtego członu nie zadziała + else { + CompressorFlag = ( + ( ( CompressorAllow ) || ( CompressorStart == start_t::automatic ) ) + && ( CompressorAllowLocal ) + && ( Mains ) + && ( ( ConverterFlag ) + || ( CompressorPower == 0 ) + || ( CompressorPower == 3 ) ) ); } - else if (CompressorPower == 4) // jeśli zasilanie z poprzedniego członu - { // zasilanie sprężarki w członie ra z członu silnikowego (sprzęg 1) - if (Couplers[0].Connected != NULL) - CompressorFlag = - (Couplers[0].Connected->CompressorAllow && - Couplers[0].Connected->ConverterFlag && Couplers[0].Connected->Mains); - else - CompressorFlag = false; // bez tamtego członu nie zadziała + + // NOTE: crude way to enforce simultaneous activation of compressors in multi-unit setups + // TODO: replace this with a more universal activation system down the road + if( ( TrainType == dt_ET41 ) + || ( TrainType == dt_ET42 ) ) { + + if( ( Couplers[1].Connected != nullptr ) + && ( true == TestFlag( Couplers[ 1 ].CouplingFlag, coupling::permanent ) ) ) { + // the first unit isn't allowed to start its compressor until second unit can start its own as well + CompressorFlag &= ( Couplers[ 1 ].Connected->CompressorGovernorLock == false ); + } + if( ( Couplers[ 0 ].Connected != nullptr ) + && ( true == TestFlag( Couplers[ 0 ].CouplingFlag, coupling::permanent ) ) ) { + // the second unit isn't allowed to start its compressor until first unit can start its own as well + CompressorFlag &= ( Couplers[ 0 ].Connected->CompressorGovernorLock == false ); + } } - else - CompressorFlag = (CompressorAllow) && - ((ConverterFlag) || (CompressorPower == 0)) && (Mains); - if (CompressorFlag) // jeśli została załączona + + if( CompressorFlag ) { + // jeśli została załączona LastSwitchingTime = 0; // to trzeba ograniczyć ponowne włączenie - } - // for b:=0 to 1 do //z Megapacka - // with Couplers[b] do - // if TestFlag(CouplingFlag,ctrain_scndpneumatic) then - // Connected.CompressorFlag:=CompressorFlag; - if (CompressorFlag) - if ((EngineType == DieselElectric) && (CompressorPower > 0)) - CompressedVolume += dt * CompressorSpeed * (2.0 * MaxCompressor - Compressor) / - MaxCompressor * - (DElist[MainCtrlPos].RPM / DElist[MainCtrlPosNo].RPM); - else - { - CompressedVolume += - dt * CompressorSpeed * (2.0 * MaxCompressor - Compressor) / MaxCompressor; - if ((CompressorPower == 5) && (Couplers[1].Connected != NULL)) - Couplers[1].Connected->TotalCurrent += - 0.0015 * Couplers[1].Connected->Voltage; // tymczasowo tylko obciążenie - // sprężarki, tak z 5A na - // sprężarkę - else if ((CompressorPower == 4) && (Couplers[0].Connected != NULL)) - Couplers[0].Connected->TotalCurrent += - 0.0015 * Couplers[0].Connected->Voltage; // tymczasowo tylko obciążenie - // sprężarki, tak z 5A na - // sprężarkę - else - TotalCurrent += 0.0015 * - Voltage; // tymczasowo tylko obciążenie sprężarki, tak z 5A na sprężarkę } + } + } + + if( CompressorFlag ) { + // working compressor adds air to the air reservoir + if( CompressorPower == 3 ) { + // the compressor is coupled with the diesel engine, engine revolutions affect the output + if( false == CompressorGovernorLock ) { + auto const enginefactor { ( + EngineType == TEngineType::DieselElectric ? ( ( 60.0 * std::abs( enrot ) ) / DElist[ MainCtrlPosNo ].RPM ) : + EngineType == TEngineType::DieselEngine ? ( std::abs( enrot ) / nmax ) : + 1.0 ) }; // shouldn't ever get here but, eh + CompressedVolume += + CompressorSpeed + * ( 2.0 * MaxCompressor - Compressor ) / MaxCompressor + * enginefactor + * dt; + } +/* + else { + // the lock is active, air is being vented out at arbitrary rate + CompressedVolume -= 0.01 * dt; + } +*/ + } + else { + // the compressor is a stand-alone device, working at steady pace + CompressedVolume += + CompressorSpeed + * ( 2.0 * MaxCompressor - Compressor ) / MaxCompressor + * dt; + + if( ( CompressorPower == 5 ) && ( Couplers[ 1 ].Connected != NULL ) ) { + // tymczasowo tylko obciążenie sprężarki, tak z 5A na sprężarkę + Couplers[ 1 ].Connected->TotalCurrent += 0.0015 * Couplers[ 1 ].Connected->Voltage; + } + else if( ( CompressorPower == 4 ) && ( Couplers[ 0 ].Connected != NULL ) ) { + // tymczasowo tylko obciążenie sprężarki, tak z 5A na sprężarkę + Couplers[ 0 ].Connected->TotalCurrent += 0.0015 * Couplers[ 0 ].Connected->Voltage; + } + else { + // tymczasowo tylko obciążenie sprężarki, tak z 5A na sprężarkę + TotalCurrent += 0.0015 * Voltage; + } + } } } } @@ -2939,6 +3504,11 @@ void TMoverParameters::CompressorCheck(double dt) // ************************************************************************************************* void TMoverParameters::UpdatePipePressure(double dt) { + if( PipePress > 1.0 ) { + Pipe->Flow( -(PipePress)* AirLeakRate * dt ); + Pipe->Act(); + } + const double LBDelay = 100; const double kL = 0.5; //double dV; @@ -2954,24 +3524,25 @@ void TMoverParameters::UpdatePipePressure(double dt) if ((BrakeCtrlPosNo > 1) /*&& (ActiveCab != 0)*/) // with BrakePressureTable[BrakeCtrlPos] do { - if ((EngineType != ElectricInductionMotor)) - dpLocalValve = - LocHandle->GetPF(std::max(static_cast(LocalBrakePos) / LocalBrakePosNo, LocalBrakePosA), - Hamulec->GetBCP(), ScndPipePress, dt, 0); - else - dpLocalValve = - LocHandle->GetPF(LocalBrakePosA, Hamulec->GetBCP(), ScndPipePress, dt, 0); - if ((BrakeHandle == FV4a) && - ((PipePress < 2.75) && ((Hamulec->GetStatus() & b_rls) == 0)) && - (BrakeSubsystem == ss_LSt) && (TrainType != dt_EZT)) + if ((EngineType != TEngineType::ElectricInductionMotor)) + dpLocalValve = LocHandle->GetPF(std::max(LocalBrakePosA, LocalBrakePosAEIM), Hamulec->GetBCP(), ScndPipePress, dt, 0); + else + dpLocalValve = LocHandle->GetPF(LocalBrakePosAEIM, Hamulec->GetBCP(), ScndPipePress, dt, 0); + if( ( BrakeHandle == TBrakeHandle::FV4a ) + && ( ( PipePress < 2.75 ) + && ( ( Hamulec->GetStatus() & b_rls ) == 0 ) ) + && ( BrakeSubsystem == TBrakeSubSystem::ss_LSt ) + && ( TrainType != dt_EZT ) ) { temp = PipePress + 0.00001; - else + } + else { temp = ScndPipePress; + } Handle->SetReductor(BrakeCtrlPos2); if ((BrakeOpModeFlag != bom_PS)) if ((BrakeOpModeFlag < bom_EP) || ((Handle->GetPos(bh_EB) - 0.5) < BrakeCtrlPosR) || - (BrakeHandle != MHZ_EN57)) + (BrakeHandle != TBrakeHandle::MHZ_EN57)) dpMainValve = Handle->GetPF(BrakeCtrlPosR, PipePress, temp, dt, EqvtPipePress); else dpMainValve = Handle->GetPF(0, PipePress, temp, dt, EqvtPipePress); @@ -2986,12 +3557,19 @@ void TMoverParameters::UpdatePipePressure(double dt) Pipe2->Flow(dpMainValve); } - // if(EmergencyBrakeFlag)and(BrakeCtrlPosNo=0)then //ulepszony hamulec bezp. - if ((EmergencyBrakeFlag) || (TestFlag(SecuritySystem.Status, s_SHPebrake)) || - (TestFlag(SecuritySystem.Status, s_CAebrake)) || - (s_CAtestebrake == true) || - (TestFlag(EngDmgFlag, 32)) /* or (not Battery)*/) // ulepszony hamulec bezp. - dpMainValve = dpMainValve + PF(0, PipePress, 0.15) * dt; + // ulepszony hamulec bezp. + if( ( true == RadioStopFlag ) + || ( true == AlarmChainFlag ) + || ( true == TestFlag( SecuritySystem.Status, s_SHPebrake ) ) + || ( true == TestFlag( SecuritySystem.Status, s_CAebrake ) ) +/* + // NOTE: disabled because 32 is 'load destroyed' flag, what does this have to do with emergency brake? + // (if it's supposed to be broken coupler, such event sets alarmchainflag instead when appropriate) + || ( true == TestFlag( EngDmgFlag, 32 ) ) +*/ + || ( true == s_CAtestebrake ) ) { + dpMainValve = dpMainValve + PF( 0, PipePress, 0.15 ) * dt; + } // 0.2*Spg Pipe->Flow(-dpMainValve); Pipe->Flow(-(PipePress)*0.001 * dt); @@ -3005,120 +3583,128 @@ void TMoverParameters::UpdatePipePressure(double dt) // if (Hamulec is typeid(TWest)) return 0; - switch (BrakeValve) - { - case W: - { - if (BrakeLocHandle != NoHandle) + switch (BrakeValve) { + + case TBrakeValve::K: + case TBrakeValve::W: { + + if( BrakeLocHandle != TBrakeHandle::NoHandle ) { + LocBrakePress = LocHandle->GetCP(); + + //(Hamulec as TWest).SetLBP(LocBrakePress); + Hamulec->SetLBP( LocBrakePress ); + } + if( MBPM < 2 ) + //(Hamulec as TWest).PLC(MaxBrakePress[LoadFlag]) + Hamulec->PLC( MaxBrakePress[ LoadFlag ] ); + else + //(Hamulec as TWest).PLC(TotalMass); + Hamulec->PLC( TotalMass ); + break; + } + + case TBrakeValve::LSt: + case TBrakeValve::EStED: { + + LocBrakePress = LocHandle->GetCP(); + for( int b = 0; b < 2; b++ ) + if( ( ( TrainType & ( dt_ET41 | dt_ET42 ) ) != 0 ) && + ( Couplers[ b ].Connected != NULL ) ) // nie podoba mi się to rozwiązanie, chyba trzeba + // dodać jakiś wpis do fizyki na to + if( ( ( Couplers[ b ].Connected->TrainType & ( dt_ET41 | dt_ET42 ) ) != 0 ) && + ( ( Couplers[ b ].CouplingFlag & 36 ) == 36 ) ) + LocBrakePress = std::max( Couplers[ b ].Connected->LocHandle->GetCP(), LocBrakePress ); + + //if ((DynamicBrakeFlag) && (EngineType == ElectricInductionMotor)) + //{ + // //if (Vel > 10) + // // LocBrakePress = 0; + // //else if (Vel > 5) + // // LocBrakePress = (10 - Vel) / 5 * LocBrakePress; + //} + + //(Hamulec as TLSt).SetLBP(LocBrakePress); + Hamulec->SetLBP( LocBrakePress ); + if( ( BrakeValve == TBrakeValve::EStED ) ) + if( MBPM < 2 ) + Hamulec->PLC( MaxBrakePress[ LoadFlag ] ); + else + Hamulec->PLC( TotalMass ); + break; + } + + case TBrakeValve::CV1_L_TR: { LocBrakePress = LocHandle->GetCP(); - - //(Hamulec as TWest).SetLBP(LocBrakePress); - Hamulec->SetLBP(LocBrakePress); + //(Hamulec as TCV1L_TR).SetLBP(LocBrakePress); + Hamulec->SetLBP( LocBrakePress ); + break; } - if (MBPM < 2) - //(Hamulec as TWest).PLC(MaxBrakePress[LoadFlag]) - Hamulec->PLC(MaxBrakePress[LoadFlag]); - else - //(Hamulec as TWest).PLC(TotalMass); - Hamulec->PLC(TotalMass); - break; - } - case LSt: - case EStED: - { - LocBrakePress = LocHandle->GetCP(); - for (int b = 0; b < 2; b++) - if (((TrainType & (dt_ET41 | dt_ET42)) != 0) && - (Couplers[b].Connected != NULL)) // nie podoba mi się to rozwiązanie, chyba trzeba - // dodać jakiś wpis do fizyki na to - if (((Couplers[b].Connected->TrainType & (dt_ET41 | dt_ET42)) != 0) && - ((Couplers[b].CouplingFlag & 36) == 36)) - LocBrakePress = Max0R(Couplers[b].Connected->LocHandle->GetCP(), LocBrakePress); - - //if ((DynamicBrakeFlag) && (EngineType == ElectricInductionMotor)) - //{ - // //if (Vel > 10) - // // LocBrakePress = 0; - // //else if (Vel > 5) - // // LocBrakePress = (10 - Vel) / 5 * LocBrakePress; - //} - - //(Hamulec as TLSt).SetLBP(LocBrakePress); - Hamulec->SetLBP(LocBrakePress); - if ((BrakeValve == EStED)) - if (MBPM < 2) - Hamulec->PLC(MaxBrakePress[LoadFlag]); - else - Hamulec->PLC(TotalMass); - break; - } - - case CV1_L_TR: - { - LocBrakePress = LocHandle->GetCP(); - //(Hamulec as TCV1L_TR).SetLBP(LocBrakePress); - Hamulec->SetLBP(LocBrakePress); - break; - } - - case EP2: - { - Hamulec->PLC(TotalMass); - break; - } - case ESt3AL2: - case NESt3: - case ESt4: - case ESt3: - { - if (MBPM < 2) - //(Hamulec as TNESt3).PLC(MaxBrakePress[LoadFlag]) - Hamulec->PLC(MaxBrakePress[LoadFlag]); - else - //(Hamulec as TNESt3).PLC(TotalMass); - Hamulec->PLC(TotalMass); - LocBrakePress = LocHandle->GetCP(); - //(Hamulec as TNESt3).SetLBP(LocBrakePress); - Hamulec->SetLBP(LocBrakePress); - break; - } - case KE: - { - LocBrakePress = LocHandle->GetCP(); - //(Hamulec as TKE).SetLBP(LocBrakePress); - Hamulec->SetLBP(LocBrakePress); - if (MBPM < 2) - //(Hamulec as TKE).PLC(MaxBrakePress[LoadFlag]) - Hamulec->PLC(MaxBrakePress[LoadFlag]); - else - //(Hamulec as TKE).PLC(TotalMass); - Hamulec->PLC(TotalMass); - break; - } + case TBrakeValve::EP2: + { + Hamulec->PLC( TotalMass ); + break; + } + case TBrakeValve::ESt3AL2: + case TBrakeValve::NESt3: + case TBrakeValve::ESt4: + case TBrakeValve::ESt3: + { + if( MBPM < 2 ) + //(Hamulec as TNESt3).PLC(MaxBrakePress[LoadFlag]) + Hamulec->PLC( MaxBrakePress[ LoadFlag ] ); + else + //(Hamulec as TNESt3).PLC(TotalMass); + Hamulec->PLC( TotalMass ); + LocBrakePress = LocHandle->GetCP(); + //(Hamulec as TNESt3).SetLBP(LocBrakePress); + Hamulec->SetLBP( LocBrakePress ); + break; + } + case TBrakeValve::KE: + { + LocBrakePress = LocHandle->GetCP(); + //(Hamulec as TKE).SetLBP(LocBrakePress); + Hamulec->SetLBP( LocBrakePress ); + if( MBPM < 2 ) + //(Hamulec as TKE).PLC(MaxBrakePress[LoadFlag]) + Hamulec->PLC( MaxBrakePress[ LoadFlag ] ); + else + //(Hamulec as TKE).PLC(TotalMass); + Hamulec->PLC( TotalMass ); + break; + } + default: + { + // unsupported brake valve type, we should never land here +// ErrorLog( "Unsupported brake valve type (" + std::to_string( BrakeValve ) + ") in " + TypeName ); +// ::PostQuitMessage( 0 ); + break; + } } // switch - if ((BrakeHandle == FVel6) && (ActiveCab != 0)) + if ((BrakeHandle == TBrakeHandle::FVel6) && (ActiveCab != 0)) { - if ((Battery) && (ActiveDir != 0) && - (EpFuse)) // tu powinien byc jeszcze bezpiecznik EP i baterie - + if ((Battery) + && (ActiveDir != 0) + && (EpFuse)) // tu powinien byc jeszcze bezpiecznik EP i baterie - // temp = (Handle as TFVel6).GetCP temp = Handle->GetCP(); else - temp = 0; + temp = 0.0; Hamulec->SetEPS(temp); - SendCtrlToNext("Brake", temp, - CabNo); // Ra 2014-11: na tym się wysypuje, ale nie wiem, w jakich warunkach + // Ra 2014-11: na tym się wysypuje, ale nie wiem, w jakich warunkach + SendCtrlToNext("Brake", temp, CabNo); } Pipe->Act(); PipePress = Pipe->P(); - if ((BrakeStatus & 128) == 128) // jesli hamulec wyłączony - temp = 0; // odetnij + if( ( Hamulec->GetBrakeStatus() & b_dmg ) == b_dmg ) // jesli hamulec wyłączony + temp = 0.0; // odetnij else - temp = 1; // połącz - Pipe->Flow(temp * Hamulec->GetPF(temp * PipePress, dt, Vel) + GetDVc(dt)); + temp = 1.0; // połącz + Pipe->Flow( temp * Hamulec->GetPF( temp * PipePress, dt, Vel ) + GetDVc( dt ) ); if (ASBType == 128) Hamulec->ASB(int(SlippingWheels)); @@ -3129,17 +3715,17 @@ void TMoverParameters::UpdatePipePressure(double dt) Pipe->Act(); PipePress = Pipe->P(); - dpMainValve = dpMainValve / (100 * dt); // normalizacja po czasie do syczenia; + dpMainValve = dpMainValve / (100.0 * dt); // normalizacja po czasie do syczenia; - if (PipePress < -1) + if (PipePress < -1.0) { - PipePress = -1; - Pipe->CreatePress(-1); + PipePress = -1.0; + Pipe->CreatePress(-1.0); Pipe->Act(); } - if (CompressedVolume < 0) - CompressedVolume = 0; + if (CompressedVolume < 0.0) + CompressedVolume = 0.0; } // ************************************************************************************************* @@ -3148,6 +3734,11 @@ void TMoverParameters::UpdatePipePressure(double dt) // ************************************************************************************************* void TMoverParameters::UpdateScndPipePressure(double dt) { + if( ScndPipePress > 1.0 ) { + Pipe2->Flow( -(ScndPipePress)* AirLeakRate * dt ); + Pipe2->Act(); + } + const double Spz = 0.5067; TMoverParameters *c; double dv1, dv2, dV; @@ -3186,14 +3777,12 @@ void TMoverParameters::UpdateScndPipePressure(double dt) } Pipe2->Flow(Hamulec->GetHPFlow(ScndPipePress, dt)); - - if (((Compressor > ScndPipePress) && (CompressorSpeed > 0.0001)) || (TrainType == dt_EZT)) - { + // NOTE: condition disabled to allow the air flow from the main hose to the main tank as well + if( /* ( ( Compressor > ScndPipePress ) && ( */ VeselVolume > 0.0 /* ) ) || ( TrainType == dt_EZT ) || ( TrainType == dt_DMU ) */ ) { dV = PF(Compressor, ScndPipePress, Spz) * dt; CompressedVolume += dV / 1000.0; Pipe2->Flow(-dV); } - Pipe2->Flow(dv1 + dv2); Pipe2->Act(); ScndPipePress = Pipe2->P(); @@ -3304,27 +3893,25 @@ void TMoverParameters::ComputeConstans(void) // ************************************************************************************************* double TMoverParameters::ComputeMass(void) { - double M; - LoadType = ToLower(LoadType); // po co zakładać jak można mieć na pewno - if (Load > 0) - { // zakładamy, że ładunek jest pisany małymi literami + double M { 0.0 }; + // TODO: unit weight table, pulled from external data file + if( LoadAmount > 0 ) { + if (ToLower(LoadQuantity) == "tonns") - M = Load * 1000; - else if (LoadType == "passengers") - M = Load * 80; - else if (LoadType == "luggage") - M = Load * 100; - else if (LoadType == "cars") - M = Load * 1200; // 800 kilo to miał maluch - else if (LoadType == "containers") - M = Load * 8000; - else if (LoadType == "transformers") - M = Load * 50000; + M = LoadAmount * 1000; + else if (LoadType.name == "passengers") + M = LoadAmount * 80; + else if (LoadType.name == "luggage") + M = LoadAmount * 100; + else if (LoadType.name == "cars") + M = LoadAmount * 1200; // 800 kilo to miał maluch + else if (LoadType.name == "containers") + M = LoadAmount * 8000; + else if (LoadType.name == "transformers") + M = LoadAmount * 50000; else - M = Load * 1000; + M = LoadAmount * 1000; } - else - M = 0; // Ra: na razie tak, ale nie wszędzie masy wirujące się wliczają return Mass + M + Mred; } @@ -3336,6 +3923,7 @@ double TMoverParameters::ComputeMass(void) void TMoverParameters::ComputeTotalForce(double dt, double dt1, bool FullVer) { int b; + double Fwheels = 0.0; if (PhysicActivation) { @@ -3360,46 +3948,77 @@ void TMoverParameters::ComputeTotalForce(double dt, double dt1, bool FullVer) // ABu: to dla optymalizacji, bo chyba te rzeczy wystarczy sprawdzac 1 raz na // klatke? LastSwitchingTime += dt1; - if (EngineType == ElectricSeriesMotor) + if (EngineType == TEngineType::ElectricSeriesMotor) LastRelayTime += dt1; - if (Mains && /*(abs(CabNo) < 2) &&*/ (EngineType == - ElectricSeriesMotor)) // potem ulepszyc! pantogtrafy! + if( Mains && /*(abs(CabNo) < 2) &&*/ ( EngineType == TEngineType::ElectricSeriesMotor ) ) // potem ulepszyc! pantogtrafy! { // Ra 2014-03: uwzględnienie kierunku jazdy w napięciu na silnikach, a powinien być - // zdefiniowany nawrotnik - if (CabNo == 0) + // zdefiniowany nawrotnik + if( CabNo == 0 ) Voltage = RunningTraction.TractionVoltage * ActiveDir; else Voltage = RunningTraction.TractionVoltage * DirAbsolute; // ActiveDir*CabNo; } // bo nie dzialalo - else if ((EngineType == ElectricInductionMotor) || - (((Couplers[0].CouplingFlag & ctrain_power) == ctrain_power) || - ((Couplers[1].CouplingFlag & ctrain_power) == - ctrain_power))) // potem ulepszyc! pantogtrafy! - Voltage = - Max0R(Max0R(RunningTraction.TractionVoltage, HVCouplers[0][1]), HVCouplers[1][1]); - else + else if( ( EngineType == TEngineType::ElectricInductionMotor ) + || ( ( ( Couplers[ side::front ].CouplingFlag & ctrain_power ) == ctrain_power ) + || ( ( Couplers[ side::rear ].CouplingFlag & ctrain_power ) == ctrain_power ) ) ) { + // potem ulepszyc! pantogtrafy! + Voltage = + std::max( + RunningTraction.TractionVoltage, +#ifdef EU07_USE_OLD_HVCOUPLERS + std::max( HVCouplers[side::front][hvcoupler::voltage], HVCouplers[side::rear][hvcoupler::voltage] ) ); +#else + std::max( Couplers[ side::front ].power_high.voltage, Couplers[ side::rear ].power_high.voltage ) ); +#endif + } + else { Voltage = 0; - //if (Mains && /*(abs(CabNo) < 2) &&*/ ( - // EngineType == ElectricInductionMotor)) // potem ulepszyc! pantogtrafy! - // Voltage = RunningTraction.TractionVoltage; + } if (Power > 0) FTrain = TractionForce(dt); else FTrain = 0; + Fb = BrakeForce(RunningTrack); - if( std::max( std::abs( FTrain ), Fb ) > TotalMassxg * Adhesive( RunningTrack.friction ) ) // poslizg + Fwheels = FTrain - Fb * Sign(V); + if( ( Vel > 0.001 ) // crude trap, to prevent braked stationary vehicles from passing fb > mass * adhesive test + && ( std::abs(Fwheels) > TotalMassxg * Adhesive( RunningTrack.friction ) ) ) // poslizg { SlippingWheels = true; } if( true == SlippingWheels ) { // TrainForce:=TrainForce-Fb; - nrot = ComputeRotatingWheel((FTrain - Fb * Sign(V) - FStand) / NAxles - + double temp_nrot = ComputeRotatingWheel(Fwheels - Sign(nrot * M_PI * WheelDiameter - V) * - Adhesive(RunningTrack.friction) * TotalMass, + Adhesive(RunningTrack.friction) * TotalMassxg, dt, nrot); - FTrain = Sign(FTrain) * TotalMassxg * Adhesive(RunningTrack.friction); - Fb = std::min(Fb, TotalMassxg * Adhesive(RunningTrack.friction)); + Fwheels = Sign(temp_nrot * M_PI * WheelDiameter - V) * TotalMassxg * Adhesive(RunningTrack.friction); + if (Fwheels*Sign(V)>0) + { + FTrain = Fwheels + Fb*Sign(V); + } + else if (FTrain*Sign(V)>0) + { + Fb = FTrain*Sign(V) - Fwheels*Sign(V); + } + else + { + Fb = -Fwheels*Sign(V); + FTrain = 0; + } + if (nrot < 0.1) + { + WheelFlat = sqrt(square(WheelFlat) + abs(Fwheels) / NAxles*Vel*0.000002); + } + if (Sign(nrot * M_PI * WheelDiameter - V)*Sign(temp_nrot * M_PI * WheelDiameter - V) < 0) + { + SlippingWheels = false; + temp_nrot = V / M_PI / WheelDiameter; + } + + + nrot = temp_nrot; } // else SlippingWheels:=false; // FStand:=0; @@ -3408,7 +4027,7 @@ void TMoverParameters::ComputeTotalForce(double dt, double dt1, bool FullVer) (Couplers[b].CouplerType<>Articulated)*/ { // doliczenie sił z innych pojazdów Couplers[b].CForce = CouplerForce(b, dt); - FTrain += Couplers[b].CForce; + FTrain += Couplers[b].CForce; } else Couplers[b].CForce = 0; @@ -3422,9 +4041,6 @@ void TMoverParameters::ComputeTotalForce(double dt, double dt1, bool FullVer) // McZapkie-031103: sprawdzanie czy warto liczyc fizyke i inne updaty // ABu 300105: cos tu mieszalem , dziala teraz troche lepiej, wiec zostawiam - // zakomentowalem PhysicActivationFlag bo cos nie dzialalo i fizyka byla liczona zawsze. - // if (PhysicActivationFlag) - //{ if ((CabNo == 0) && (Vel < 0.0001) && (abs(AccS) < 0.0001) && (TrainType != dt_EZT)) { if (!PhysicActivation) @@ -3443,38 +4059,66 @@ void TMoverParameters::ComputeTotalForce(double dt, double dt1, bool FullVer) } else PhysicActivation = true; - //}; +} + +double TMoverParameters::BrakeForceR(double ratio, double velocity) +{ + double press = 0; + if (MBPM>2) + { + press = MaxBrakePress[1] + (MaxBrakePress[3] - MaxBrakePress[1]) * std::min(1.0, (TotalMass - Mass) / (MBPM - Mass)); + } + else + { + if (MaxBrakePress[1] > 0.1) + { + press = MaxBrakePress[LoadFlag]; + } + else + { + press = MaxBrakePress[3]; + if (DynamicBrakeType == dbrake_automatic) + ratio = ratio + (1.5 - ratio)*std::min(1.0, Vel*0.02); + if ((BrakeDelayFlag&bdelay_R) && (BrakeMethod%128 != bp_Cosid) && (BrakeMethod % 128 != bp_D1) && (BrakeMethod % 128 != bp_D2) && (Power<1) && (velocity<40)) + ratio = ratio / 2; + if( ( TrainType == dt_DMU ) && ( velocity < 30.0 ) ) { + ratio -= 0.3; + } + } + + } + return BrakeForceP(press*ratio, velocity); +} + +double TMoverParameters::BrakeForceP(double press, double velocity) +{ + double BFP = 0; + double K = (((press * P2FTrans) - BrakeCylSpring) * BrakeCylMult[0] - BrakeSlckAdj) * BrakeRigEff; + K *= static_cast(BrakeCylNo) / (NAxles * std::max(1, NBpA)); + BFP = Hamulec->GetFC(velocity, K)*K*(NAxles * std::max(1, NBpA)) * 1000; + return BFP; } // ************************************************************************************************* // Q: 20160713 // oblicza siłę na styku koła i szyny // ************************************************************************************************* -double TMoverParameters::BrakeForce(const TTrackParam &Track) -{ - double K, Fb, NBrakeAxles, sm = 0; - // const OerlikonForceFactor=1.5; +double TMoverParameters::BrakeForce( TTrackParam const &Track ) { - if (NPoweredAxles > 0) - NBrakeAxles = NPoweredAxles; - else - NBrakeAxles = NAxles; - switch (LocalBrake) - { - case NoBrake: - K = 0; - break; - case ManualBrake: - K = MaxBrakeForce * ManualBrakeRatio(); - break; - case HydraulicBrake: - K = MaxBrakeForce * LocalBrakeRatio(); - break; - case PneumaticBrake: - if (Compressor < MaxBrakePress[3]) - K = MaxBrakeForce * LocalBrakeRatio() / 2.0; - else - K = 0; + double K{ 0 }, Fb{ 0 }, sm{ 0 }; + + switch( LocalBrake ) { + case TLocalBrake::ManualBrake: { + K = MaxBrakeForce * ManualBrakeRatio(); + break; + } + case TLocalBrake::HydraulicBrake: { + K = MaxBrakeForce * LocalBrakeRatio(); + break; + } + default: { + break; + } } if (MBrake == true) @@ -3482,41 +4126,31 @@ double TMoverParameters::BrakeForce(const TTrackParam &Track) K = MaxBrakeForce * ManualBrakeRatio(); } - // 0.03 - u = ((BrakePress * P2FTrans) - BrakeCylSpring) * BrakeCylMult[0] - BrakeSlckAdj; if (u * BrakeRigEff > Ntotal) // histereza na nacisku klockow Ntotal = u * BrakeRigEff; else { - u = (BrakePress * P2FTrans) * BrakeCylMult[0] - BrakeSlckAdj; + u = ((BrakePress * P2FTrans) - BrakeCylSpring) * BrakeCylMult[0] - BrakeSlckAdj; if (u * (2.0 - BrakeRigEff) < Ntotal) // histereza na nacisku klockow Ntotal = u * (2.0 - BrakeRigEff); } + auto const NBrakeAxles { NAxles }; + if (NBrakeAxles * NBpA > 0) { if (Ntotal > 0) // nie luz K += Ntotal; // w kN K *= static_cast(BrakeCylNo) / (NBrakeAxles * static_cast(NBpA)); // w kN na os } - if ((BrakeSystem == Pneumatic) || (BrakeSystem == ElectroPneumatic)) + if ((BrakeSystem == TBrakeSystem::Pneumatic) || (BrakeSystem == TBrakeSystem::ElectroPneumatic)) { u = Hamulec->GetFC(Vel, K); UnitBrakeForce = u * K * 1000.0; // sila na jeden klocek w N } else UnitBrakeForce = K * 1000.0; - if (((double)NBpA * UnitBrakeForce > TotalMassxg * Adhesive(RunningTrack.friction) / NAxles) && - (abs(V) > 0.001)) - // poslizg - { - // Fb = Adhesive(Track.friction) * Mass * g; - SlippingWheels = true; - } - //{ else - // begin - //{ SlippingWheels:=false;} // if (LocalBrake=ManualBrake)or(MBrake=true)) and (BrakePress<0.3) then // Fb:=UnitBrakeForce*NBpA {ham. reczny dziala na jedna os} // else //yB: to nie do konca ma sens, ponieważ ręczny w wagonie działa na jeden cylinder @@ -3543,13 +4177,19 @@ double TMoverParameters::FrictionForce(double R, int TDamage) return FF; } + + + // ************************************************************************************************* // Q: 20160713 // Oblicza przyczepność // ************************************************************************************************* -double TMoverParameters::Adhesive(double staticfriction) +double TMoverParameters::Adhesive(double staticfriction) const { - double adhesion; + double adhesion = 0.0; + const double adh_factor = 0.25; //współczynnik określający, jak bardzo spada tarcie przy poślizgu + const double slipfactor = 0.33; //współczynnik określający, jak szybko spada tarcie przy poślizgu + const double sandfactor = 1.25; //współczynnik określający, jak mocno pomaga piasek /* // ABu: male przerobki, tylko czy to da jakikolwiek skutek w FPS? // w kazdym razie zaciemni kod na pewno :) @@ -3571,7 +4211,8 @@ double TMoverParameters::Adhesive(double staticfriction) } // WriteLog(FloatToStr(adhesive)); // tutaj jest na poziomie 0.2 - 0.3 return adhesion; -*/ + + //wersja druga if( true == SlippingWheels ) { if( true == SandDose ) { adhesion = 0.48; } @@ -3582,7 +4223,15 @@ double TMoverParameters::Adhesive(double staticfriction) if( true == SandDose ) { adhesion = std::max( staticfriction * ( 100.0 + Vel ) / ( 50.0 + Vel ) * 1.1, 0.48 ); } else { adhesion = staticfriction * ( 100.0 + Vel ) / ( 50.0 + Vel ); } } - adhesion *= ( 11.0 - 2 * Random() ) / 10.0; +// adhesion *= ( 0.9 + 0.2 * Random() ); +*/ + //wersja3 by youBy - uwzględnia naturalne mikropoślizgi i wpływ piasecznicy, usuwa losowość z pojazdu + double Vwheels = nrot * M_PI * WheelDiameter; // predkosc liniowa koła wynikająca z obrotowej + double deltaV = V - Vwheels; //poślizg - różnica prędkości w punkcie styku koła i szyny + deltaV = std::max(0.0, std::abs(deltaV) - 0.25); //mikropoślizgi do ok. 0,25 m/s nie zrywają przyczepności + Vwheels = std::abs( Vwheels ); + adhesion = staticfriction * (28 + Vwheels) / (14 + Vwheels) * ((SandDose? sandfactor : 1) - (1 - adh_factor)*(deltaV / (deltaV + slipfactor))); + return adhesion; } @@ -3649,27 +4298,39 @@ double TMoverParameters::CouplerForce(int CouplerN, double dt) // tempdist:=tempdist+CoupleDist; //ABu: proby szybkiego naprawienia bledu } + dV = V - (double)DirPatch( CouplerN, CNext ) * Couplers[ CouplerN ].Connected->V; + absdV = abs( dV ); + // potentially generate sounds on clash or stretch + if( ( newdist < 0.0 ) + && ( Couplers[ CouplerN ].Dist > newdist ) + && ( dV < -0.5 ) ) { + // 090503: dzwieki pracy zderzakow + SetFlag( + Couplers[ CouplerN ].sounds, + ( absdV > 5.0 ? + ( sound::bufferclash | sound::loud ) : + sound::bufferclash ) ); + } + else if( ( Couplers[ CouplerN ].CouplingFlag != coupling::faux ) + && ( newdist > 0.001 ) + && ( Couplers[ CouplerN ].Dist <= 0.001 ) + && ( absdV > 0.005 ) ) { + // 090503: dzwieki pracy sprzegu + SetFlag( + Couplers[ CouplerN ].sounds, + ( absdV > 0.035 ? + ( sound::couplerstretch | sound::loud ) : + sound::couplerstretch ) ); + } + // blablabla // ABu: proby znalezienia problemu ze zle odbijajacymi sie skladami - //***if (Couplers[CouplerN].CouplingFlag=ctrain_virtual) and (newdist>0) then - if ((Couplers[CouplerN].CouplingFlag == ctrain_virtual) && (Couplers[CouplerN].CoupleDist > 0)) - { - CF = 0; // kontrola zderzania sie - OK - ScanCounter++; - if ((newdist > MaxDist) || ((ScanCounter > MaxCount) && (newdist > MinDist))) - //***if (tempdist>MaxDist) or ((ScanCounter>MaxCount)and(tempdist>MinDist)) then - { // zerwij kontrolnie wirtualny sprzeg - // Connected.Couplers[CNext].Connected:=nil; //Ra: ten podłączony niekoniecznie jest - // wirtualny - Couplers[CouplerN].Connected = NULL; - ScanCounter = static_cast(Random(500.0)); // Q: TODO: cy dobrze przetlumaczone? - // WriteLog(FloatToStr(ScanCounter)); - } - } - else - { - if (Couplers[CouplerN].CouplingFlag == ctrain_virtual) - { + //if (Couplers[CouplerN].CouplingFlag=ctrain_virtual) and (newdist>0) then + if( ( Couplers[ CouplerN ].CouplingFlag != coupling::faux ) + || ( Couplers[ CouplerN ].CoupleDist < 0 ) ) { + + if( Couplers[ CouplerN ].CouplingFlag == coupling::faux ) { + BetaAvg = Couplers[CouplerN].beta; Fmax = (Couplers[CouplerN].FmaxC + Couplers[CouplerN].FmaxB) * CouplerTune; } @@ -3683,23 +4344,6 @@ double TMoverParameters::CouplerForce(int CouplerN, double dt) Couplers[CouplerN].Connected->Couplers[CNext].FmaxB) * CouplerTune / 2.0; } - dV = V - (double)DirPatch(CouplerN, CNext) * Couplers[CouplerN].Connected->V; - absdV = abs(dV); - if ((newdist < -0.001) && (Couplers[CouplerN].Dist >= -0.001) && - (absdV > 0.010)) // 090503: dzwieki pracy zderzakow - { - if (SetFlag(SoundFlag, sound_bufferclamp)) - if (absdV > 0.5) - SetFlag(SoundFlag, sound_loud); - } - else if ((newdist > 0.002) && (Couplers[CouplerN].Dist <= 0.002) && - (absdV > 0.005)) // 090503: dzwieki pracy sprzegu - { - if (Couplers[CouplerN].CouplingFlag > 0) - if (SetFlag(SoundFlag, sound_couplerstretch)) - if (absdV > 0.1) - SetFlag(SoundFlag, sound_loud); - } distDelta = abs(newdist) - abs(Couplers[CouplerN].Dist); // McZapkie-191103: poprawka na histereze Couplers[CouplerN].Dist = newdist; @@ -3745,18 +4389,20 @@ double TMoverParameters::CouplerForce(int CouplerN, double dt) //***if -tempdist>(DmaxB+Connected^.Couplers[CNext].DmaxB)/10 then {zderzenie} { Couplers[CouplerN].CheckCollision = true; - if ((Couplers[CouplerN].CouplerType == Automatic) && - (Couplers[CouplerN].CouplingFlag == - 0)) // sprzeganie wagonow z samoczynnymi sprzegami} + if( ( Couplers[ CouplerN ].CouplerType == TCouplerType::Automatic ) + && ( Couplers[ CouplerN ].CouplingFlag == coupling::faux ) ) { + // sprzeganie wagonow z samoczynnymi sprzegami} // CouplingFlag:=ctrain_coupler+ctrain_pneumatic+ctrain_controll+ctrain_passenger+ctrain_scndpneumatic; - Couplers[CouplerN].CouplingFlag = - ctrain_coupler | ctrain_pneumatic | ctrain_controll; // EN57 + // EN57 + Couplers[ CouplerN ].CouplingFlag = coupling::coupler | coupling::brakehose | coupling::mainhose | coupling::control; + } } } } - if (Couplers[CouplerN].CouplingFlag != ctrain_virtual) + if( Couplers[ CouplerN ].CouplingFlag != coupling::faux ) { // uzgadnianie prawa Newtona - Couplers[CouplerN].Connected->Couplers[1 - CouplerN].CForce = -CF; + Couplers[ CouplerN ].Connected->Couplers[ 1 - CouplerN ].CForce = -CF; + } return CF; } @@ -3765,92 +4411,222 @@ double TMoverParameters::CouplerForce(int CouplerN, double dt) // Q: 20160714 // oblicza sile trakcyjna lokomotywy (dla elektrowozu tez calkowity prad) // ************************************************************************************************* -double TMoverParameters::TractionForce(double dt) -{ - double PosRatio, dmoment, dtrans, tmp, tmpV; - int i; +double TMoverParameters::TractionForce( double dt ) { + double PosRatio, dmoment, dtrans, tmp; Ft = 0; dtrans = 0; dmoment = 0; - // tmpV =Abs(nrot * WheelDiameter / 2); // youBy - if (EngineType == DieselElectric) - { - tmp = DElist[MainCtrlPos].RPM / 60.0; - if ((Heating) && (HeatingPower > 0) && (MainCtrlPosNo > MainCtrlPos)) - { - i = MainCtrlPosNo; - while (DElist[i - 2].RPM / 60.0 > tmp) - i--; - tmp = DElist[i].RPM / 60.0; - } + switch( EngineType ) { + case TEngineType::DieselElectric: { + if( ( true == Mains ) + && ( true == FuelPump.is_active ) ) { - if (enrot != tmp * int(ConverterFlag)) - if (abs(tmp * int(ConverterFlag) - enrot) < 0.001) - enrot = tmp * int(ConverterFlag); - else if ((enrot < DElist[0].RPM * 0.01) && (ConverterFlag)) - enrot += (tmp * int(ConverterFlag) - enrot) * dt / 5.0; - else - enrot += (tmp * int(ConverterFlag) - enrot) * 1.5 * dt; - } - else if (EngineType != DieselEngine) - enrot = Transmision.Ratio * nrot; - else // dla DieselEngine - { - if (ShuntMode) // dodatkowa przekładnia np. dla 2Ls150 - dtrans = AnPos * Transmision.Ratio * MotorParam[ScndCtrlActualPos].mIsat; - else - dtrans = Transmision.Ratio * MotorParam[ScndCtrlActualPos].mIsat; - dmoment = dizel_Momentum(dizel_fill, dtrans * nrot * ActiveDir, dt); // oblicza tez - // enrot - } + tmp = DElist[ MainCtrlPos ].RPM / 60.0; - eAngle += enrot * dt; - while (eAngle > M_PI * 2.0) - // eAngle = Pirazy2 - eAngle; <- ABu: a nie czasem tak, jak nizej? - eAngle -= M_PI * 2.0; + if( ( true == Heating ) + && ( HeatingPower > 0 ) + && ( EngineHeatingRPM > 0 ) ) { + // bump engine revolutions up if needed, when heating is on + tmp = + std::max( + tmp, + std::min( + DElist[ MainCtrlPosNo ].RPM, + EngineHeatingRPM ) + / 60.0 ); + } + } + else { + tmp = 0.0; + } - // hunter-091012: przeniesione z if ActiveDir<>0 (zeby po zejsciu z kierunku dalej spadala - // predkosc wentylatorow) - if (EngineType == ElectricSeriesMotor) - { - switch (RVentType) // wentylatory rozruchowe} - { - case 1: - { - if ((ActiveDir != 0) && (RList[MainCtrlActualPos].R > RVentCutOff)) - RventRot += (RVentnmax - RventRot) * RVentSpeed * dt; - else - RventRot *= (1.0 - RVentSpeed * dt); - break; - } - case 2: - { - if ((abs(Itot) > RVentMinI) && (RList[MainCtrlActualPos].R > RVentCutOff)) - RventRot += - (RVentnmax * abs(Itot) / (ImaxLo * RList[MainCtrlActualPos].Bn) - RventRot) * - RVentSpeed * dt; - else if ((DynamicBrakeType == dbrake_automatic) && (DynamicBrakeFlag)) - RventRot += (RVentnmax * Im / ImaxLo - RventRot) * RVentSpeed * dt; - else - { - RventRot *= (1.0 - RVentSpeed * dt); - if (RventRot < 0.1) - RventRot = 0; + if( enrot != tmp ) { + enrot = clamp( + enrot + ( dt / 1.25 ) * ( // TODO: equivalent of dizel_aim instead of fixed inertia + enrot < tmp ? + 1.0 : + -2.0 ), // NOTE: revolutions drop faster than they rise, maybe? TBD: maybe not + 0.0, std::max( tmp, enrot ) ); + if( std::abs( tmp - enrot ) < 0.001 ) { + enrot = tmp; + } } break; } + case TEngineType::DieselEngine: { + if( ShuntMode ) // dodatkowa przekładnia np. dla 2Ls150 + dtrans = AnPos * Transmision.Ratio * MotorParam[ ScndCtrlActualPos ].mIsat; + else + dtrans = Transmision.Ratio * MotorParam[ ScndCtrlActualPos ].mIsat; + + dmoment = dizel_Momentum( dizel_fill, dtrans * nrot * ActiveDir, dt ); // oblicza tez enrot + break; + } + default: { + enrot = Transmision.Ratio * nrot; + break; + } + } + + eAngle += enrot * dt; + if( eAngle > M_PI * 2.0 ) + eAngle = std::fmod( eAngle, M_PI * 2.0 ); +/* + while (eAngle > M_PI * 2.0) + // eAngle = Pirazy2 - eAngle; <- ABu: a nie czasem tak, jak nizej? + eAngle -= M_PI * 2.0; +*/ + // hunter-091012: przeniesione z if ActiveDir<>0 (zeby po zejsciu z kierunku dalej spadala predkosc wentylatorow) + // wentylatory rozruchowe + // TBD, TODO: move this to update, it doesn't exactly have much to do with traction + switch( EngineType ) { + + case TEngineType::ElectricSeriesMotor: { + if( true == Mains ) { + switch( RVentType ) { + + case 1: { // manual + if( ( ActiveDir != 0 ) + && ( RList[ MainCtrlActualPos ].R > RVentCutOff ) ) { + RventRot += ( RVentnmax - RventRot ) * RVentSpeed * dt; + } + else { + RventRot *= std::max( 0.0, 1.0 - RVentSpeed * dt ); + } + break; + } + + case 2: { // automatic + auto const motorcurrent{ std::min( ImaxHi, std::abs( Im ) ) }; + if( ( std::abs( Itot ) > RVentMinI ) + && ( RList[ MainCtrlActualPos ].R > RVentCutOff ) ) { + + RventRot += + ( RVentnmax + * std::min( 1.0, ( ( motorcurrent / NPoweredAxles ) / RVentMinI ) ) + * motorcurrent / ImaxLo + - RventRot ) + * RVentSpeed * dt; + } + else if( ( DynamicBrakeType == dbrake_automatic ) + && ( true == DynamicBrakeFlag ) ) { + RventRot += ( RVentnmax * motorcurrent / ImaxLo - RventRot ) * RVentSpeed * dt; + } + else { + RventRot *= std::max( 0.0, 1.0 - RVentSpeed * dt ); + } + break; + } + + default: { + break; + } + } // rventtype + } // mains + else { + RventRot *= std::max( 0.0, 1.0 - RVentSpeed * dt ); + } + break; + } + + case TEngineType::DieselElectric: { + // NOTE: for this type RventRot is the speed of motor blowers; we also update radiator fans while at it + if( true == Mains ) { + // TBD, TODO: currently ignores RVentType, fix this? + RventRot += clamp( enrot - RventRot, -100.0, 50.0 ) * dt; + dizel_heat.rpmw += clamp( dizel_heat.rpmwz - dizel_heat.rpmw, -100.f, 50.f ) * dt; + dizel_heat.rpmw2 += clamp( dizel_heat.rpmwz2 - dizel_heat.rpmw2, -100.f, 50.f ) * dt; + } + else { + RventRot *= std::max( 0.0, 1.0 - RVentSpeed * dt ); + dizel_heat.rpmw *= std::max( 0.0, 1.0 - dizel_heat.rpmw * dt ); + dizel_heat.rpmw2 *= std::max( 0.0, 1.0 - dizel_heat.rpmw2 * dt ); + } + break; + } + + case TEngineType::DieselEngine: { + // NOTE: we update only radiator fans, as vehicles with diesel engine don't have other ventilators + if( true == Mains ) { + dizel_heat.rpmw += clamp( dizel_heat.rpmwz - dizel_heat.rpmw, -100.f, 50.f ) * dt; + dizel_heat.rpmw2 += clamp( dizel_heat.rpmwz2 - dizel_heat.rpmw2, -100.f, 50.f ) * dt; + } + else { + dizel_heat.rpmw *= std::max( 0.0, 1.0 - dizel_heat.rpmw * dt ); + dizel_heat.rpmw2 *= std::max( 0.0, 1.0 - dizel_heat.rpmw2 * dt ); + } + break; + } + + default: { + break; + } + } + + switch( EngineType ) { + case TEngineType::Dumb: { + PosRatio = ( MainCtrlPos + ScndCtrlPos ) / ( MainCtrlPosNo + ScndCtrlPosNo + 0.01 ); + EnginePower = 1000.0 * Power * PosRatio; + break; + } + case TEngineType::DieselEngine: { + EnginePower = ( 2 * dizel_Mstand + dmoment ) * enrot * ( 2.0 * M_PI / 1000.0 ); + if( MainCtrlPos > 1 ) { + // dodatkowe opory z powodu sprezarki} + dmoment -= dizel_Mstand * ( 0.2 * enrot / dizel_nmax ); + } + break; + } + case TEngineType::DieselElectric: { + EnginePower = 0; // the actual calculation is done in two steps later in the method + break; + } + default: { + break; + } + } + + switch( EngineType ) { + + case TEngineType::ElectricSeriesMotor: { +/* + if ((Mains)) // nie wchodzić w funkcję bez potrzeby + if ( (std::max(GetTrainsetVoltage(), std::abs(Voltage)) < EnginePowerSource.CollectorParameters.MinV) || + (std::max(GetTrainsetVoltage(), std::abs(Voltage)) * EnginePowerSource.CollectorParameters.OVP > + EnginePowerSource.CollectorParameters.MaxV)) + if( MainSwitch( false, ( TrainType == dt_EZT ? range_t::unit : range_t::local ) ) ) // TODO: check whether we need to send this EMU-wide + EventFlag = true; // wywalanie szybkiego z powodu niewłaściwego napięcia +*/ + // update the state of voltage relays + auto const voltage { std::max( GetTrainsetVoltage(), std::abs( RunningTraction.TractionVoltage ) ) }; + NoVoltRelay = ( voltage >= EnginePowerSource.CollectorParameters.MinV ); + OvervoltageRelay = ( voltage <= EnginePowerSource.CollectorParameters.MaxV ) || ( false == EnginePowerSource.CollectorParameters.OVP ); + // wywalanie szybkiego z powodu niewłaściwego napięcia + EventFlag |= ( ( true == Mains ) + && ( ( false == NoVoltRelay ) || ( false == OvervoltageRelay ) ) + && ( MainSwitch( false, ( TrainType == dt_EZT ? range_t::unit : range_t::local ) ) ) ); // TODO: check whether we need to send this EMU-wide + break; + } + + case TEngineType::DieselElectric: { + // TODO: move this to the auto relay check when the electric engine code paths are unified + StLinFlag = MotorConnectorsCheck(); + break; + } + + default: { + break; } } if (ActiveDir != 0) switch (EngineType) { - case Dumb: + case TEngineType::Dumb: { - PosRatio = (MainCtrlPos + ScndCtrlPos) / (MainCtrlPosNo + ScndCtrlPosNo + 0.01); - if (Mains && (ActiveDir != 0) && (CabNo != 0)) + if (Mains && (CabNo != 0)) { if (Vel > 0.1) { @@ -3862,14 +4638,13 @@ double TMoverParameters::TractionForce(double dt) } else Ft = 0; - EnginePower = 1000.0 * Power * PosRatio; break; } // Dumb - case WheelsDriven: + case TEngineType::WheelsDriven: { - if (EnginePowerSource.SourceType == InternalSource) - if (EnginePowerSource.PowerType == BioPower) + if (EnginePowerSource.SourceType == TPowerSource::InternalSource) + if (EnginePowerSource.PowerType == TPowerType::BioPower) Ft = Sign(sin(eAngle)) * PulseForce * Transmision.Ratio; PulseForceTimer = PulseForceTimer + dt; if (PulseForceTimer > CtrlDelay) @@ -3882,13 +4657,13 @@ double TMoverParameters::TractionForce(double dt) break; } // WheelsDriven - case ElectricSeriesMotor: + case TEngineType::ElectricSeriesMotor: { // enrot:=Transmision.Ratio*nrot; // yB: szereg dwoch sekcji w ET42 if ((TrainType == dt_ET42) && (Imax == ImaxHi)) Voltage = Voltage / 2.0; - Mm = Momentum(current(enrot, Voltage)); // oblicza tez prad p/slinik + Mm = Momentum(Current(enrot, Voltage)); // oblicza tez prad p/slinik if (TrainType == dt_ET42) { @@ -3899,16 +4674,16 @@ double TMoverParameters::TractionForce(double dt) } if ((DynamicBrakeType == dbrake_automatic) && (DynamicBrakeFlag)) { - if (((Vadd + abs(Im)) > 760) || (Hamulec->GetEDBCP() < 0.25)) + if (((Vadd + abs(Im)) > TUHEX_Sum + TUHEX_Diff) || (Hamulec->GetEDBCP() < 0.25)) { Vadd -= 500.0 * dt; if (Vadd < 1) Vadd = 0; } - else if ((DynamicBrakeFlag) && ((Vadd + abs(Im)) < 740)) + else if ((DynamicBrakeFlag) && ((Vadd + abs(Im)) < TUHEX_Sum - TUHEX_Diff)) { Vadd += 70.0 * dt; - Vadd = Min0R(Max0R(Vadd, 60), 400); + Vadd = Min0R(Max0R(Vadd, TUHEX_MinIw), TUHEX_MaxIw); } if (Vadd > 0) Mm = MomentumF(Im, Vadd, 0); @@ -3926,18 +4701,9 @@ double TMoverParameters::TractionForce(double dt) if (Vhyp > CtrlDelay / 2) // jesli czas oddzialywania przekroczony FuseOff(); // wywalanie bezpiecznika z powodu przetezenia silnikow - if ((Mains)) // nie wchodzić w funkcję bez potrzeby - if ((abs(Voltage) < EnginePowerSource.CollectorParameters.MinV) || - (abs(Voltage) * EnginePowerSource.CollectorParameters.OVP > - EnginePowerSource.CollectorParameters.MaxV)) - if (MainSwitch(false)) - EventFlag = true; // wywalanie szybkiego z powodu niewłaściwego napięcia - - if (((DynamicBrakeType == dbrake_automatic) || (DynamicBrakeType == dbrake_switch)) && - (DynamicBrakeFlag)) + if (((DynamicBrakeType == dbrake_automatic) || (DynamicBrakeType == dbrake_switch)) && (DynamicBrakeFlag)) Itot = Im * 2; // 2x2 silniki w EP09 - else if ((TrainType == dt_EZT) && (Imin == IminLo) && - (ScndS)) // yBARC - boczniki na szeregu poprawnie + else if ((TrainType == dt_EZT) && (Imin == IminLo) && (ScndS)) // yBARC - boczniki na szeregu poprawnie Itot = Im; else Itot = Im * RList[MainCtrlActualPos].Bn; // prad silnika * ilosc galezi @@ -3947,57 +4713,70 @@ double TMoverParameters::TractionForce(double dt) break; } - case DieselEngine: + case TEngineType::DieselEngine: { - EnginePower = dmoment * enrot; - if (MainCtrlPos > 1) - dmoment -= - dizel_Mstand * (0.2 * enrot / dizel_nmax); // dodatkowe opory z powodu sprezarki} - Mm = dizel_engage * dmoment; + Mm = dmoment; //bylo * dizel_engage Mw = Mm * dtrans; // dmoment i dtrans policzone przy okazji enginerotation - Fw = Mw * 2.0 / WheelDiameter; + Fw = Mw * 2.0 / WheelDiameter / NPoweredAxles; Ft = Fw * NPoweredAxles; // sila trakcyjna Ft = Ft * DirAbsolute; // ActiveDir*CabNo; break; } - case DieselElectric: // youBy + case TEngineType::DieselElectric: // youBy { // tmpV:=V*CabNo*ActiveDir; - tmpV = nrot * Pirazy2 * 0.5 * WheelDiameter * DirAbsolute; //*CabNo*ActiveDir; + auto const tmpV { nrot * Pirazy2 * 0.5 * WheelDiameter * DirAbsolute }; //*CabNo*ActiveDir; // jazda manewrowa - if (ShuntMode) - { - Voltage = (SST[MainCtrlPos].Umax * AnPos) + (SST[MainCtrlPos].Umin * (1.0 - AnPos)); - tmp = (SST[MainCtrlPos].Pmax * AnPos) + (SST[MainCtrlPos].Pmin * (1.0 - AnPos)); - Ft = tmp * 1000.0 / (abs(tmpV) + 1.6); + if( true == ShuntMode ) { + if( ( true == Mains ) && ( MainCtrlPos > 0 ) ) { + Voltage = ( SST[ MainCtrlPos ].Umax * AnPos ) + ( SST[ MainCtrlPos ].Umin * ( 1.0 - AnPos ) ); + // NOTE: very crude way to approximate power generated at current rpm instead of instant top output + // NOTE, TODO: doesn't take into account potentially increased revolutions if heating is on, fix it + auto const rpmratio { 60.0 * enrot / DElist[ MainCtrlPos ].RPM }; + tmp = rpmratio * ( SST[ MainCtrlPos ].Pmax * AnPos ) + ( SST[ MainCtrlPos ].Pmin * ( 1.0 - AnPos ) ); + Ft = tmp * 1000.0 / ( abs( tmpV ) + 1.6 ); + } + else { + Voltage = 0; + Ft = 0; + } PosRatio = 1; } else // jazda ciapongowa { - auto power = Power; if( true == Heating ) { power -= HeatingPower; } if( power < 0.0 ) { power = 0.0; } - tmp = std::min( DElist[ MainCtrlPos ].GenPower, power );// Power - HeatingPower * double( Heating )); + // NOTE: very crude way to approximate power generated at current rpm instead of instant top output + // NOTE, TODO: doesn't take into account potentially increased revolutions if heating is on, fix it + auto const currentgenpower { ( + DElist[ MainCtrlPos ].RPM > 0 ? + DElist[ MainCtrlPos ].GenPower * ( 60.0 * enrot / DElist[ MainCtrlPos ].RPM ) : + 0.0 ) }; + + tmp = std::min( power, currentgenpower ); - PosRatio = DElist[MainCtrlPos].GenPower / DElist[MainCtrlPosNo].GenPower; + PosRatio = currentgenpower / DElist[MainCtrlPosNo].GenPower; // stosunek mocy teraz do mocy max - if ((MainCtrlPos > 0) && (ConverterFlag)) - if (tmpV < - (Vhyp * power / - DElist[MainCtrlPosNo].GenPower)) // czy na czesci prostej, czy na hiperboli - Ft = (Ftmax - - ((Ftmax - 1000.0 * DElist[MainCtrlPosNo].GenPower / (Vhyp + Vadd)) * - (tmpV / Vhyp) / PowerCorRatio)) * - PosRatio; // posratio - bo sila jakos tam sie rozklada + // NOTE: Mains in this context is working diesel engine + if( ( true == Mains ) && ( MainCtrlPos > 0 ) ) { - // Ft:=(Ftmax - (Ftmax - (1000.0 * DEList[MainCtrlPosNo].genpower / - //(Vhyp+Vadd) / PowerCorRatio)) * (tmpV/Vhyp)) * PosRatio //wersja z Megapacka - else // na hiperboli //1.107 - - // wspolczynnik sredniej nadwyzki Ft w symku nad charakterystyka - Ft = 1000.0 * tmp / (tmpV + Vadd) / - PowerCorRatio; // tu jest zawarty stosunek mocy + if( tmpV < ( Vhyp * power / DElist[ MainCtrlPosNo ].GenPower ) ) { + // czy na czesci prostej, czy na hiperboli + Ft = ( Ftmax + - ( ( Ftmax - 1000.0 * DElist[ MainCtrlPosNo ].GenPower / ( Vhyp + Vadd ) ) + * ( tmpV / Vhyp ) + / PowerCorRatio ) ) + * PosRatio; // posratio - bo sila jakos tam sie rozklada + } + else { + // na hiperboli + // 1.107 - wspolczynnik sredniej nadwyzki Ft w symku nad charakterystyka + Ft = 1000.0 * tmp / ( tmpV + Vadd ) / + PowerCorRatio; // tu jest zawarty stosunek mocy + } + } else Ft = 0; // jak nastawnik na zero, to sila tez zero @@ -4019,16 +4798,15 @@ double TMoverParameters::TractionForce(double dt) else Im = NPoweredAxles * sqrt(abs(Mm * MotorParam[ScndCtrlPos].Isat)); - if (ShuntMode) - { + if( ShuntMode ) { EnginePower = Voltage * Im / 1000.0; - if (EnginePower > tmp) - { - EnginePower = tmp * 1000.0; - Voltage = EnginePower / Im; + if( EnginePower > tmp ) { + EnginePower = tmp; + Voltage = EnginePower * 1000.0 / Im; + } + if( EnginePower < tmp ) { + Ft *= EnginePower / tmp; } - if (EnginePower < tmp) - Ft = Ft * EnginePower / tmp; } else { @@ -4038,32 +4816,40 @@ double TMoverParameters::TractionForce(double dt) Im = DElist[MainCtrlPos].Imax; } - if (Im > 0) // jak pod obciazeniem - if (Flat) // ograniczenie napiecia w pradnicy - plaszczak u gory - Voltage = 1000.0 * tmp / abs(Im); - else // charakterystyka pradnicy obcowzbudnej (elipsa) - twierdzenie Pitagorasa - - { - Voltage = sqrt(abs(sqr(DElist[MainCtrlPos].Umax) - - sqr(DElist[MainCtrlPos].Umax * Im / - DElist[MainCtrlPos].Imax))) * - (MainCtrlPos - 1) + - (1.0 - Im / DElist[MainCtrlPos].Imax) * DElist[MainCtrlPos].Umax * - (MainCtrlPosNo - MainCtrlPos); - Voltage = Voltage / (MainCtrlPosNo - 1); - Voltage = Min0R(Voltage, (1000.0 * tmp / abs(Im))); - if (Voltage < (Im * 0.05)) - Voltage = Im * 0.05; + if( Im > 0 ) { + // jak pod obciazeniem + if( true == Flat ) { + // ograniczenie napiecia w pradnicy - plaszczak u gory + Voltage = 1000.0 * tmp / std::abs( Im ); } - if ((Voltage > DElist[MainCtrlPos].Umax) || - (Im == 0)) // gdy wychodzi za duze napiecie - Voltage = DElist[MainCtrlPos].Umax * - int(ConverterFlag); // albo przy biegu jalowym (jest cos takiego?) + else { + // charakterystyka pradnicy obcowzbudnej (elipsa) - twierdzenie Pitagorasa + Voltage = + std::sqrt( + std::abs( + square( DElist[ MainCtrlPos ].Umax ) + - square( DElist[ MainCtrlPos ].Umax * Im / DElist[ MainCtrlPos ].Imax ) ) ) + * ( MainCtrlPos - 1 ) + + ( 1.0 - Im / DElist[ MainCtrlPos ].Imax ) * DElist[ MainCtrlPos ].Umax * ( MainCtrlPosNo - MainCtrlPos ); + Voltage /= ( MainCtrlPosNo - 1 ); + Voltage = clamp( + Voltage, + Im * 0.05, ( 1000.0 * tmp / std::abs( Im ) ) ); + } + } + + if( ( Voltage > DElist[ MainCtrlPos ].Umax ) + || ( Im == 0 ) ) { + // gdy wychodzi za duze napiecie albo przy biegu jalowym (jest cos takiego?) + Voltage = DElist[ MainCtrlPos ].Umax * ( ConverterFlag ? 1 : 0 ); + } EnginePower = Voltage * Im / 1000.0; - +/* + // NOTE: this part is experimentally disabled, as it generated early traction force drop for undetermined purpose if ((tmpV > 2) && (EnginePower < tmp)) Ft = Ft * EnginePower / tmp; +*/ } if ((Imax > 1) && (Im > Imax)) @@ -4072,117 +4858,207 @@ double TMoverParameters::TractionForce(double dt) Voltage = 0; // przekazniki bocznikowania, kazdy inny dla kazdej pozycji - if ((MainCtrlPos == 0) || (ShuntMode)) + if ((MainCtrlPos == 0) || (ShuntMode) || (false==Mains)) ScndCtrlPos = 0; - else if (AutoRelayFlag) - switch (RelayType) - { - case 0: - { - if ((Im <= (MPTRelay[ScndCtrlPos].Iup * PosRatio)) && - (ScndCtrlPos < ScndCtrlPosNo)) - ++ScndCtrlPos; - if ((Im >= (MPTRelay[ScndCtrlPos].Idown * PosRatio)) && (ScndCtrlPos > 0)) - --ScndCtrlPos; - break; - } - case 1: - { - if ((MPTRelay[ScndCtrlPos].Iup < Vel) && (ScndCtrlPos < ScndCtrlPosNo)) - ++ScndCtrlPos; - if ((MPTRelay[ScndCtrlPos].Idown > Vel) && (ScndCtrlPos > 0)) - --ScndCtrlPos; - break; - } - case 2: - { - if ((MPTRelay[ScndCtrlPos].Iup < Vel) && (ScndCtrlPos < ScndCtrlPosNo) && - (EnginePower < (tmp * 0.99))) - ++ScndCtrlPos; - if ((MPTRelay[ScndCtrlPos].Idown < Im) && (ScndCtrlPos > 0)) - --ScndCtrlPos; - break; - } - case 41: - { - if ((MainCtrlPos == MainCtrlPosNo) && - (tmpV * 3.6 > MPTRelay[ScndCtrlPos].Iup) && (ScndCtrlPos < ScndCtrlPosNo)) - { - ++ScndCtrlPos; - enrot = enrot * 0.73; + else { + if( AutoRelayFlag ) { + + auto const shuntfieldstate { ScndCtrlPos }; + + switch( RelayType ) { + + case 0: { + + if( ( ScndCtrlPos < ScndCtrlPosNo ) + && ( Im <= ( MPTRelay[ ScndCtrlPos ].Iup * PosRatio ) ) ) { + ++ScndCtrlPos; + } + if( ( ScndCtrlPos > 0 ) + && ( Im >= ( MPTRelay[ScndCtrlPos].Idown * PosRatio ) ) ) { + --ScndCtrlPos; + } + break; + } + case 1: { + + if( ( ScndCtrlPos < ScndCtrlPosNo ) + && ( MPTRelay[ ScndCtrlPos ].Iup < Vel ) ) { + ++ScndCtrlPos; + } + if( ( ScndCtrlPos > 0 ) + && ( MPTRelay[ ScndCtrlPos ].Idown > Vel ) ) { + --ScndCtrlPos; + } + break; + } + case 2: { + + if( ( ScndCtrlPos < ScndCtrlPosNo ) + && ( MPTRelay[ ScndCtrlPos ].Iup < Vel ) + && ( EnginePower < ( tmp * 0.99 ) ) ) { + ++ScndCtrlPos; + } + if( ( ScndCtrlPos > 0 ) + && ( MPTRelay[ ScndCtrlPos ].Idown < Im ) ) { + --ScndCtrlPos; + } + break; + } + case 41: + { + if( ( ScndCtrlPos < ScndCtrlPosNo ) + && ( MainCtrlPos == MainCtrlPosNo ) + && ( tmpV * 3.6 > MPTRelay[ ScndCtrlPos ].Iup ) ) { + ++ScndCtrlPos; + enrot = enrot * 0.73; + } + if( ( ScndCtrlPos > 0 ) + && ( Im > MPTRelay[ ScndCtrlPos ].Idown ) ) { + --ScndCtrlPos; + } + break; + } + case 45: + { + if( ( ScndCtrlPos < ScndCtrlPosNo ) + && ( MainCtrlPos >= 11 ) ) { + + if( Im < MPTRelay[ ScndCtrlPos ].Iup ) { + ++ScndCtrlPos; + } + // check for cases where the speed drops below threshold for level 2 or 3 + if( ( ScndCtrlPos > 1 ) + && ( Vel < MPTRelay[ ScndCtrlPos - 1 ].Idown ) ) { + --ScndCtrlPos; + } + } + // malenie + if( ( ScndCtrlPos > 0 ) && ( MainCtrlPos < 11 ) ) { + + if( ScndCtrlPos == 1 ) { + if( Im > MPTRelay[ ScndCtrlPos - 1 ].Idown ) { + --ScndCtrlPos; + } + } + else { + if( Vel < MPTRelay[ ScndCtrlPos ].Idown ) { + --ScndCtrlPos; + } + } + } + // 3rd level drops with master controller at position lower than 10... + if( MainCtrlPos < 11 ) { + ScndCtrlPos = std::min( 2, ScndCtrlPos ); + } + // ...and below position 7 field shunt drops altogether + if( MainCtrlPos < 8 ) { + ScndCtrlPos = 0; + } +/* + // crude woodward approximation; difference between rpm for consecutive positions is ~5% + // so we get full throttle until ~half way between desired and previous position, or zero on rpm reduction + auto const woodward { clamp( + ( DElist[ MainCtrlPos ].RPM / ( enrot * 60.0 ) - 1.0 ) * 50.0, + 0.0, 1.0 ) }; +*/ + break; + } + case 46: + { + // wzrastanie + if( ( MainCtrlPos >= 12 ) + && ( ScndCtrlPos < ScndCtrlPosNo ) ) { + if( ( ScndCtrlPos ) % 2 == 0 ) { + if( ( MPTRelay[ ScndCtrlPos ].Iup > Im ) ) { + ++ScndCtrlPos; + } + } + else { + if( ( MPTRelay[ ScndCtrlPos - 1 ].Iup > Im ) + && ( MPTRelay[ ScndCtrlPos ].Iup < Vel ) ) { + ++ScndCtrlPos; + } + } + } + // malenie + if( ( MainCtrlPos < 12 ) + && ( ScndCtrlPos > 0 ) ) { + if( Vel < 50.0 ) { + // above 50 km/h already active shunt field can be maintained until lower controller setting + if( ( ScndCtrlPos ) % 2 == 0 ) { + if( ( MPTRelay[ ScndCtrlPos ].Idown < Im ) ) { + --ScndCtrlPos; + } + } + else { + if( ( MPTRelay[ ScndCtrlPos + 1 ].Idown < Im ) + && ( MPTRelay[ ScndCtrlPos ].Idown > Vel ) ) { + --ScndCtrlPos; + } + } + } + } + if( MainCtrlPos < 11 ) { + ScndCtrlPos = std::min( 2, ScndCtrlPos ); + } + if( MainCtrlPos < 8 ) { + ScndCtrlPos = 0; + } + break; + } + default: { + break; + } + } // switch RelayType + + if( ScndCtrlPos != shuntfieldstate ) { + SetFlag( SoundFlag, ( sound::relay | sound::shuntfield ) ); } - if ((Im > MPTRelay[ScndCtrlPos].Idown) && (ScndCtrlPos > 0)) - --ScndCtrlPos; - break; } - case 45: - { - if ((MainCtrlPos > 11) && (ScndCtrlPos < ScndCtrlPosNo)) - if ((ScndCtrlPos == 0)) - if ((MPTRelay[ScndCtrlPos].Iup > Im)) - ++ScndCtrlPos; - else if ((MPTRelay[ScndCtrlPos].Iup < Vel)) - ++ScndCtrlPos; - - // malenie - if ((ScndCtrlPos > 0) && (MainCtrlPos < 12)) - if ((ScndCtrlPos == ScndCtrlPosNo)) - if ((MPTRelay[ScndCtrlPos].Idown < Im)) - --ScndCtrlPos; - else if ((MPTRelay[ScndCtrlPos].Idown > Vel)) - --ScndCtrlPos; - if ((MainCtrlPos < 11) && (ScndCtrlPos > 2)) - ScndCtrlPos = 2; - if ((MainCtrlPos < 9) && (ScndCtrlPos > 0)) - ScndCtrlPos = 0; - } - case 46: - { - // wzrastanie - if ((MainCtrlPos > 9) && (ScndCtrlPos < ScndCtrlPosNo)) - if ((ScndCtrlPos) % 2 == 0) - if ((MPTRelay[ScndCtrlPos].Iup > Im)) - ++ScndCtrlPos; - else if ((MPTRelay[ScndCtrlPos - 1].Iup > Im) && - (MPTRelay[ScndCtrlPos].Iup < Vel)) - ++ScndCtrlPos; - - // malenie - if ((MainCtrlPos < 10) && (ScndCtrlPos > 0)) - if ((ScndCtrlPos) % 2 == 0) - if ((MPTRelay[ScndCtrlPos].Idown < Im)) - --ScndCtrlPos; - else if ((MPTRelay[ScndCtrlPos + 1].Idown < Im) && - (MPTRelay[ScndCtrlPos].Idown > Vel)) - --ScndCtrlPos; - if ((MainCtrlPos < 9) && (ScndCtrlPos > 2)) - ScndCtrlPos = 2; - if ((MainCtrlPos < 6) && (ScndCtrlPos > 0)) - ScndCtrlPos = 0; - } - } // switch RelayType + } break; } // DieselElectric - case ElectricInductionMotor: + case TEngineType::ElectricInductionMotor: { - if ((Mains)) // nie wchodzić w funkcję bez potrzeby - if ((abs(Voltage) < EnginePowerSource.CollectorParameters.MinV) || - (abs(Voltage) > EnginePowerSource.CollectorParameters.MaxV + 200)) - { - MainSwitch(false); + if( ( Mains ) ) { + // nie wchodzić w funkcję bez potrzeby + if( ( std::max( std::abs( Voltage ), GetTrainsetVoltage() ) < EnginePowerSource.CollectorParameters.MinV ) + || ( std::max( std::abs( Voltage ), GetTrainsetVoltage() ) > EnginePowerSource.CollectorParameters.MaxV + 200 ) ) { + MainSwitch( false, ( TrainType == dt_EZT ? range_t::unit : range_t::local ) ); // TODO: check whether we need to send this EMU-wide } - tmpV = abs(nrot) * (PI * WheelDiameter) * - 3.6; //*DirAbsolute*eimc[eimc_s_p]; - do przemyslenia dzialanie pp - if ((Mains)) - { + } + if( true == Mains ) { + //tempomat + if (ScndCtrlPosNo > 1) + { + if (ScndCtrlPos != NewSpeed) + { + + SpeedCtrlTimer = 0; + NewSpeed = ScndCtrlPos; + } + else + { + SpeedCtrlTimer += dt; + if (SpeedCtrlTimer > SpeedCtrlDelay) + { + int NewSCAP = (Vmax < 250 ? 1 : 0.5) * (float)ScndCtrlPos / (float)ScndCtrlPosNo * Vmax; + if (NewSCAP != ScndCtrlActualPos) + { + ScndCtrlActualPos = NewSCAP; + SendCtrlToNext("SpeedCntrl", ScndCtrlActualPos, CabNo); + } + } + } + } dtrans = Hamulec->GetEDBCP(); if (((DoorLeftOpened) || (DoorRightOpened))) DynamicBrakeFlag = true; else if (((dtrans < 0.25) && (LocHandle->GetCP() < 0.25) && (AnPos < 0.01)) || - ((dtrans < 0.25) && (ShuntModeAllow) && (LocalBrakePos == 0))) + ((dtrans < 0.25) && (ShuntModeAllow) && (LocalBrakePosA < 0.01))) DynamicBrakeFlag = false; else if ((((BrakePress > 0.25) && (dtrans > 0.25) || (LocHandle->GetCP() > 0.25))) || (AnPos > 0.02)) @@ -4190,25 +5066,35 @@ double TMoverParameters::TractionForce(double dt) dtrans = Hamulec->GetEDBCP() * eimc[eimc_p_abed]; // stala napedu if ((DynamicBrakeFlag)) { + // ustalanie współczynnika blendingu do luzowania hamulca PN if (eimv[eimv_Fmax] * Sign(V) * DirAbsolute < -1) { PosRatio = -Sign(V) * DirAbsolute * eimv[eimv_Fr] / (eimc[eimc_p_Fh] * - Max0R(dtrans / MaxBrakePress[0], AnPos) /*dizel_fill*/); + Max0R(dtrans,Max0R(0.01,Hamulec->GetEDBCP())) / MaxBrakePress[0]); + PosRatio = clamp(PosRatio, 0.0, 1.0); } - else - PosRatio = 0; - PosRatio = Round(20.0 * PosRatio) / 20.0; + else + { + PosRatio = 0; + } + PosRatio = Round(20.0 * PosRatio) / 20.0; //stopniowanie PN/ED if (PosRatio < 19.5 / 20.0) - PosRatio *= 0.9; - // if PosRatio<0 then - // PosRatio:=2+PosRatio-2; - Hamulec->SetED(Max0R(0.0, std::min(PosRatio, 1.0))); - // (Hamulec as TLSt).SetLBP(LocBrakePress*(1-PosRatio)); - PosRatio = -std::max(std::min(dtrans * 1.0 / MaxBrakePress[0], 1.0), AnPos) * - std::max(0.0, std::min(1.0, (Vel - eimc[eimc_p_Vh0]) / - (eimc[eimc_p_Vh1] - eimc[eimc_p_Vh0]))); - eimv[eimv_Fzad] = -std::max(LocalBrakeRatio(), dtrans / MaxBrakePress[0]); + PosRatio *= 0.9; + Hamulec->SetED(Max0R(0.0, std::min(PosRatio, 1.0))); //ustalenie stopnia zmniejszenia ciśnienia + // ustalanie siły hamowania ED + if ((Hamulec->GetEDBCP() > 0.25) && (eimc[eimc_p_abed] < 0.001)) //jeśli PN wyłącza ED + { + PosRatio = 0; + eimv[eimv_Fzad] = 0; + } + else + { + PosRatio = -std::max(std::min(dtrans * 1.0 / MaxBrakePress[0], 1.0), AnPos) * + std::max(0.0, std::min(1.0, (Vel - eimc[eimc_p_Vh0]) / + (eimc[eimc_p_Vh1] - eimc[eimc_p_Vh0]))); + eimv[eimv_Fzad] = -std::max(LocalBrakeRatio(), dtrans / MaxBrakePress[0]); + } tmp = 5; } else @@ -4217,7 +5103,7 @@ double TMoverParameters::TractionForce(double dt) eimv[eimv_Fzad] = PosRatio; if ((Flat) && (eimc[eimc_p_F0] * eimv[eimv_Fful] > 0)) PosRatio = Min0R(PosRatio * eimc[eimc_p_F0] / eimv[eimv_Fful], 1); - if (ScndCtrlActualPos > 0) + if (ScndCtrlActualPos > 0) //speed control if (Vmax < 250) PosRatio = Min0R(PosRatio, Max0R(-1, 0.5 * (ScndCtrlActualPos - Vel))); else @@ -4227,40 +5113,24 @@ double TMoverParameters::TractionForce(double dt) Hamulec->SetED(0); // (Hamulec as TLSt).SetLBP(LocBrakePress); if ((PosRatio > dizel_fill)) - tmp = 1; + tmp = 4; else tmp = 4; // szybkie malenie, powolne wzrastanie } - // if SlippingWheels then begin PosRatio:=0; tmp:=10; SandDoseOn; - // end;//przeciwposlizg - - // if(Flat)then //PRZECIWPOŚLIZG dmoment = eimv[eimv_Fful]; - // else - // dmoment:=eimc[eimc_p_F0]*0.99; - if ((abs((PosRatio + 9.66 * dizel_fill) * dmoment * 100) > - 0.95 * Adhesive(RunningTrack.friction) * TotalMassxg)) - { + // NOTE: the commands to operate the sandbox are likely to conflict with other similar ai decisions + // TODO: gather these in single place so they can be resolved together + if( ( SlippingWheels ) ) { PosRatio = 0; - tmp = 4; - SandDoseOn(); - } // przeciwposlizg - if ((abs((PosRatio + 9.80 * dizel_fill) * dmoment * 100) > - 0.95 * Adhesive(RunningTrack.friction) * TotalMassxg)) - { - PosRatio = 0; - tmp = 9; - SandDoseOn(); - } // przeciwposlizg - if ((SlippingWheels)) - { - // PosRatio = -PosRatio * 0; // serio -0 ??? - PosRatio = 0; - tmp = 9; - SandDoseOn(); + tmp = 10; + Sandbox( true, range_t::unit ); } // przeciwposlizg + else { + // switch sandbox off + Sandbox( false, range_t::unit ); + } - dizel_fill += Max0R(Min0R(PosRatio - dizel_fill, 0.1), -0.1) * 2 * + dizel_fill += Max0R(Min0R(PosRatio - dizel_fill, 0.02), -0.02) * 12 * (tmp /*2{+4*byte(PosRatio 1) || (abs(tmpV) > 0.1)) && (RlistSize > 0)) - { - i = 0; - while ((i < RlistSize - 1) && (DElist[i + 1].RPM < abs(tmpV))) - i++; - RventRot = (abs(tmpV) - DElist[i].RPM) / - (DElist[i + 1].RPM - DElist[i].RPM) * - (DElist[i + 1].GenPower - DElist[i].GenPower) + - DElist[i].GenPower; + // power inverters + auto const tmpV { std::abs( eimv[ eimv_fp ] ) }; + + if( ( RlistSize > 0 ) + && ( ( std::abs( eimv[ eimv_If ] ) > 1.0 ) + || ( tmpV > 0.1 ) ) ) { + + int i = 0; + while( ( i < RlistSize - 1 ) + && ( DElist[ i + 1 ].RPM < tmpV ) ) { + ++i; + } + InverterFrequency = + ( tmpV - DElist[ i ].RPM ) + / std::max( 1.0, ( DElist[ i + 1 ].RPM - DElist[ i ].RPM ) ) + * ( DElist[ i + 1 ].GenPower - DElist[ i ].GenPower ) + + DElist[ i ].GenPower; + } + else { + InverterFrequency = 0.0; } - else - RventRot = 0; Mm = eimv[eimv_M] * DirAbsolute; Mw = Mm * Transmision.Ratio; Fw = Mw * 2.0 / WheelDiameter; Ft = Fw * NPoweredAxles; eimv[eimv_Fr] = DirAbsolute * Ft / 1000; - // RventRot; - } + } // mains else { - Im = 0; - Mm = 0; - Mw = 0; - Fw = 0; - Ft = 0; - Itot = 0; - dizel_fill = 0; - EnginePower = 0; + Im = 0.0; + Mm = 0.0; + Mw = 0.0; + Fw = 0.0; + Ft = 0.0; + Itot = 0.0; + dizel_fill = 0.0; + EnginePower = 0.0; { - for (i = 0; i < 21; i++) - eimv[i] = 0; + for (int i = 0; i < 21; ++i) + eimv[i] = 0.0; } - Hamulec->SetED(0); - RventRot = 0.0; //(Hamulec as TLSt).SetLBP(LocBrakePress); + Hamulec->SetED(0.0); + InverterFrequency = 0.0; //(Hamulec as TLSt).SetLBP(LocBrakePress); } break; } // ElectricInductionMotor - case None: - { + + case TEngineType::None: + default: { break; } } // case EngineType + + switch( EngineType ) { + case TEngineType::DieselElectric: { + // rough approximation of extra effort to overcome friction etc + auto const rpmratio{ 60.0 * enrot / DElist[ MainCtrlPosNo ].RPM }; + EnginePower += rpmratio * 0.15 * DElist[ MainCtrlPosNo ].GenPower; + break; + } + default: { + break; + } + } + + return Ft; } @@ -4414,7 +5323,7 @@ double TMoverParameters::ComputeRotatingWheel(double WForce, double dt, double n // Q: 20160713 // Sprawdzenie bezpiecznika nadmiarowego // ************************************************************************************************* -bool TMoverParameters::FuseFlagCheck(void) +bool TMoverParameters::FuseFlagCheck(void) const { bool FFC; @@ -4441,11 +5350,11 @@ bool TMoverParameters::FuseOn(void) ((Mains) || (TrainType != dt_EZT)) && (!TestFlag(EngDmgFlag, 1))) { // w ET40 jest blokada nastawnika, ale czy działa dobrze? SendCtrlToNext("FuseSwitch", 1, CabNo); - if (((EngineType == ElectricSeriesMotor) || ((EngineType == DieselElectric))) && FuseFlag) + if (((EngineType == TEngineType::ElectricSeriesMotor) || ((EngineType == TEngineType::DieselElectric))) && FuseFlag) { FuseFlag = false; // wlaczenie ponowne obwodu FO = true; - SetFlag(SoundFlag, sound_relay | sound_loud); + SetFlag(SoundFlag, sound::relay | sound::loud); } } return FO; @@ -4461,7 +5370,7 @@ void TMoverParameters::FuseOff(void) { FuseFlag = true; EventFlag = true; - SetFlag(SoundFlag, sound_relay | sound_loud); + SetFlag(SoundFlag, sound::relay | sound::loud); } } @@ -4478,7 +5387,7 @@ double TMoverParameters::v2n(void) n = V / (M_PI * WheelDiameter); // predkosc obrotowa wynikajaca z liniowej [obr/s] deltan = n - nrot; //"pochodna" prędkości obrotowej if (SlippingWheels) - if (std::abs(deltan) < 0.01) + if (std::abs(deltan) < 0.001) SlippingWheels = false; // wygaszenie poslizgu if (SlippingWheels) // nie ma zwiazku z predkoscia liniowa V { // McZapkie-221103: uszkodzenia kol podczas poslizgu @@ -4533,7 +5442,7 @@ double TMoverParameters::MomentumF(double I, double Iw, int SCP) bool TMoverParameters::CutOffEngine(void) { bool COE = false; // Ra: wartość domyślna, sprawdzić to trzeba - if ((NPoweredAxles > 0) && (CabNo == 0) && (EngineType == ElectricSeriesMotor)) + if ((NPoweredAxles > 0) && (CabNo == 0) && (EngineType == TEngineType::ElectricSeriesMotor)) { if (SetFlag(DamageFlag, -dtrain_engine)) { @@ -4551,7 +5460,7 @@ bool TMoverParameters::CutOffEngine(void) bool TMoverParameters::MaxCurrentSwitch(bool State) { bool MCS = false; - if (EngineType == ElectricSeriesMotor) + if (EngineType == TEngineType::ElectricSeriesMotor) if (ImaxHi > ImaxLo) { if (State && (Imax == ImaxLo) && (RList[MainCtrlPos].Bn < 2) && @@ -4582,7 +5491,7 @@ bool TMoverParameters::MaxCurrentSwitch(bool State) bool TMoverParameters::MinCurrentSwitch(bool State) { bool MCS = false; - if (((EngineType == ElectricSeriesMotor) && (IminHi > IminLo)) || (TrainType == dt_EZT)) + if (((EngineType == TEngineType::ElectricSeriesMotor) && (IminHi > IminLo)) || (TrainType == dt_EZT)) { if (State && (Imin == IminLo)) { @@ -4606,7 +5515,7 @@ bool TMoverParameters::MinCurrentSwitch(bool State) // Q: 20160713 // Sprawdzenie wskaźnika jazdy na oporach // ************************************************************************************************* -bool TMoverParameters::ResistorsFlagCheck(void) +bool TMoverParameters::ResistorsFlagCheck(void) const { bool RFC = false; @@ -4649,31 +5558,30 @@ bool TMoverParameters::AutoRelaySwitch(bool State) bool TMoverParameters::AutoRelayCheck(void) { bool OK = false; // b:int; - bool ARFASI = false; - bool ARFASI2 = false; // sprawdzenie wszystkich warunkow (AutoRelayFlag, AutoSwitch, Im 2.1) && (TrainType != dt_EZT)) || - (ActiveDir == 0)) // hunter-111211: wylacznik cisnieniowy - { - StLinFlag = false; // yBARC - rozlaczenie stycznikow liniowych + // yBARC - rozlaczenie stycznikow liniowych + if( false == motorconnectors ) { + StLinFlag = false; OK = false; - if (!DynamicBrakeFlag) - { + if( false == DynamicBrakeFlag ) { Im = 0; Itot = 0; ResistorsFlag = false; } } - ARFASI2 = (!AutoRelayFlag) || ((MotorParam[ScndCtrlActualPos].AutoSwitch) && - (abs(Im) < Imin)); // wszystkie warunki w jednym - ARFASI = (!AutoRelayFlag) || ((RList[MainCtrlActualPos].AutoSwitch) && (abs(Im) < Imin)) || - ((!RList[MainCtrlActualPos].AutoSwitch) && - (RList[MainCtrlActualPos].Relay < MainCtrlPos)); // wszystkie warunki w jednym + // sprawdzenie wszystkich warunkow (AutoRelayFlag, AutoSwitch, Im CtrlDelay) && (ARFASI2)) { - ScndCtrlActualPos++; + ++ScndCtrlActualPos; + SetFlag( SoundFlag, sound::shuntfield ); OK = true; } } @@ -4700,7 +5609,8 @@ bool TMoverParameters::AutoRelayCheck(void) { if ((LastRelayTime > CtrlDownDelay) && (TrainType != dt_EZT)) { - ScndCtrlActualPos--; + --ScndCtrlActualPos; + SetFlag( SoundFlag, sound::shuntfield ); OK = true; } } @@ -4717,85 +5627,102 @@ bool TMoverParameters::AutoRelayCheck(void) // IminLo } // main bez samoczynnego rozruchu + if( ( MainCtrlActualPos < ( sizeof( RList ) / sizeof( TScheme ) - 1 ) ) // crude guard against running out of current fixed table + && ( ( RList[ MainCtrlActualPos ].Relay < MainCtrlPos ) + || ( RList[ MainCtrlActualPos + 1 ].Relay == MainCtrlPos ) + || ( ( TrainType == dt_ET22 ) + && ( DelayCtrlFlag ) ) ) ) { - if ((RList[MainCtrlActualPos].Relay < MainCtrlPos) || - (RList[MainCtrlActualPos + 1].Relay == MainCtrlPos) || - ((TrainType == dt_ET22) && (DelayCtrlFlag))) - { - if ((RList[MainCtrlPos].R == 0) && (MainCtrlPos > 0) && - (!(MainCtrlPos == MainCtrlPosNo)) && (FastSerialCircuit == 1)) - { - MainCtrlActualPos++; - // MainCtrlActualPos:=MainCtrlPos; //hunter-111012: - // szybkie wchodzenie na bezoporowa (303E) - OK = true; - SetFlag(SoundFlag, sound_manyrelay | sound_loud); + if( ( RList[MainCtrlPos].R == 0 ) + && ( MainCtrlPos > 0 ) + && ( MainCtrlPos != MainCtrlPosNo ) + && ( FastSerialCircuit == 1 ) ) { + // szybkie wchodzenie na bezoporowa (303E) + // MainCtrlActualPos:=MainCtrlPos; //hunter-111012: + ++MainCtrlActualPos; + if( MainCtrlPos - MainCtrlActualPos == 1 ) { + // HACK: ensure we play only single sound of basic relays for entire trasition; return false + // for all but last step despite configuration change, to prevent playback of the basic relay sound + // TBD, TODO: move the basic sound event here and enable it with call parameter + OK = true; + } + if( RList[ MainCtrlActualPos ].R == 0 ) { + SetFlag( SoundFlag, sound::parallel | sound::loud ); + OK = true; + } } else if ((LastRelayTime > CtrlDelay) && (ARFASI)) { // WriteLog("LRT = " + FloatToStr(LastRelayTime) + ", " + // FloatToStr(CtrlDelay)); - if ((TrainType == dt_ET22) && (MainCtrlPos > 1) && - ((RList[MainCtrlActualPos].Bn < RList[MainCtrlActualPos + 1].Bn) || - (DelayCtrlFlag))) // et22 z walem grupowym - if (!DelayCtrlFlag) // najpierw przejscie + if( ( TrainType == dt_ET22 ) + && ( MainCtrlPos > 1 ) + && ( ( RList[ MainCtrlActualPos ].Bn < RList[ MainCtrlActualPos + 1 ].Bn ) + || ( DelayCtrlFlag ) ) ) { + // et22 z walem grupowym + if( !DelayCtrlFlag ) // najpierw przejscie { - MainCtrlActualPos++; + ++MainCtrlActualPos; DelayCtrlFlag = true; // tryb przejscia OK = true; } - else if (LastRelayTime > 4 * CtrlDelay) // przejscie + else if( LastRelayTime > 4 * CtrlDelay ) // przejscie { DelayCtrlFlag = false; OK = true; } +/* else ; +*/ + } else // nie ET22 z wałem grupowym { - MainCtrlActualPos++; + ++MainCtrlActualPos; OK = true; } //--------- // hunter-111211: poprawki - if (MainCtrlActualPos > 0) - if ((RList[MainCtrlActualPos].R == 0) && - (!(MainCtrlActualPos == MainCtrlPosNo))) // wejscie na bezoporowa - { - SetFlag(SoundFlag, sound_manyrelay | sound_loud); + if( MainCtrlActualPos > 0 ) { + if( ( RList[ MainCtrlActualPos ].R == 0 ) + && ( MainCtrlActualPos != MainCtrlPosNo ) ) { + // wejscie na bezoporowa + SetFlag( SoundFlag, sound::parallel | sound::loud ); } - else if ((RList[MainCtrlActualPos].R > 0) && - (RList[MainCtrlActualPos - 1].R == - 0)) // wejscie na drugi uklad - { - SetFlag(SoundFlag, sound_manyrelay); + else if( ( RList[ MainCtrlActualPos ].R > 0 ) + && ( RList[ MainCtrlActualPos - 1 ].R == 0 ) ) { + // wejscie na drugi uklad + SetFlag( SoundFlag, sound::parallel ); } + } } } else if (RList[MainCtrlActualPos].Relay > MainCtrlPos) { - if ((RList[MainCtrlPos].R == 0) && (MainCtrlPos > 0) && - (!(MainCtrlPos == MainCtrlPosNo)) && (FastSerialCircuit == 1)) - { - MainCtrlActualPos--; - // MainCtrlActualPos:=MainCtrlPos; //hunter-111012: - // szybkie wchodzenie na bezoporowa (303E) + if( ( RList[ MainCtrlPos ].R == 0 ) + && ( MainCtrlPos > 0 ) + && ( !( MainCtrlPos == MainCtrlPosNo ) ) + && ( FastSerialCircuit == 1 ) ) { + // szybkie wchodzenie na bezoporowa (303E) + // MainCtrlActualPos:=MainCtrlPos; //hunter-111012: + --MainCtrlActualPos; OK = true; - SetFlag(SoundFlag, sound_manyrelay); + if( RList[ MainCtrlActualPos ].R == 0 ) { + SetFlag( SoundFlag, sound::parallel ); + } } else if (LastRelayTime > CtrlDownDelay) { if (TrainType != dt_EZT) // tutaj powinien być tryb sterowania wałem { - MainCtrlActualPos--; + --MainCtrlActualPos; OK = true; } if (MainCtrlActualPos > 0) // hunter-111211: poprawki - if (RList[MainCtrlActualPos].R == - 0) // dzwieki schodzenia z bezoporowej} - { - SetFlag(SoundFlag, sound_manyrelay); + if (RList[MainCtrlActualPos].R == 0) { + // dzwieki schodzenia z bezoporowej} + SetFlag(SoundFlag, sound::parallel); } } } @@ -4803,7 +5730,8 @@ bool TMoverParameters::AutoRelayCheck(void) { if (LastRelayTime > CtrlDownDelay) { - ScndCtrlActualPos--; // boczniki nie dzialaja na poz. oporowych + --ScndCtrlActualPos; // boczniki nie dzialaja na poz. oporowych + SetFlag( SoundFlag, sound::shuntfield ); OK = true; } } @@ -4814,64 +5742,75 @@ bool TMoverParameters::AutoRelayCheck(void) else // not StLinFlag { OK = false; - // ybARC - tutaj sa wszystkie warunki, jakie musza byc spelnione, zeby mozna byla - // zalaczyc styczniki liniowe - if (((MainCtrlPos == 1) || ((TrainType == dt_EZT) && (MainCtrlPos > 0))) && - (!FuseFlag) && (Mains) && ((BrakePress < 1.0) || (TrainType == dt_EZT)) && - (MainCtrlActualPos == 0) && (ActiveDir != 0)) - { //^^ TODO: sprawdzic BUG, prawdopodobnie w CreateBrakeSys() + // ybARC - zalaczenie stycznikow liniowych + if( true == motorconnectors ) { DelayCtrlFlag = true; - if (LastRelayTime >= InitialCtrlDelay) - { - StLinFlag = true; // ybARC - zalaczenie stycznikow liniowych + if( LastRelayTime >= InitialCtrlDelay ) { + StLinFlag = true; MainCtrlActualPos = 1; DelayCtrlFlag = false; - SetFlag(SoundFlag, sound_relay | sound_loud); + SetFlag(SoundFlag, sound::relay | sound::loud); OK = true; } } else DelayCtrlFlag = false; - if ((!StLinFlag) && ((MainCtrlActualPos > 0) || (ScndCtrlActualPos > 0))) - if ((TrainType == dt_EZT) && (CoupledCtrl)) // EN57 wal jednokierunkowy calosciowy - { - if (MainCtrlActualPos == 1) - { - MainCtrlActualPos = 0; - OK = true; - } - else if (LastRelayTime > CtrlDownDelay) - { - if (MainCtrlActualPos < RlistSize) - MainCtrlActualPos++; // dojdz do konca - else if (ScndCtrlActualPos < ScndCtrlPosNo) - ScndCtrlActualPos++; // potem boki - else - { // i sie przewroc na koniec + if( ( false == StLinFlag ) + && ( ( MainCtrlActualPos > 0 ) + || ( ScndCtrlActualPos > 0 ) ) ) { + + if( true == CoupledCtrl ) { + + if( TrainType == dt_EZT ) { + // EN57 wal jednokierunkowy calosciowy + if( MainCtrlActualPos == 1 ) { + MainCtrlActualPos = 0; - ScndCtrlActualPos = 0; + OK = true; + } + else { + + if( LastRelayTime > CtrlDownDelay ) { + + if( MainCtrlActualPos < RlistSize ) { + // dojdz do konca + ++MainCtrlActualPos; + } + else if( ScndCtrlActualPos < ScndCtrlPosNo ) { + // potem boki + ++ScndCtrlActualPos; + SetFlag( SoundFlag, sound::shuntfield ); + } + else { + // i sie przewroc na koniec + MainCtrlActualPos = 0; + ScndCtrlActualPos = 0; + } + OK = true; + } + } + } + else { + // wal kulakowy dwukierunkowy + if( LastRelayTime > CtrlDownDelay ) { + if( ScndCtrlActualPos > 0 ) { + --ScndCtrlActualPos; + SetFlag( SoundFlag, sound::shuntfield ); + } + else { + --MainCtrlActualPos; + } + OK = true; } - OK = true; } } - else if (CoupledCtrl) // wal kulakowy dwukierunkowy - { - if (LastRelayTime > CtrlDownDelay) - { - if (ScndCtrlActualPos > 0) - ScndCtrlActualPos--; - else - MainCtrlActualPos--; - OK = true; - } - } - else - { + else { MainCtrlActualPos = 0; ScndCtrlActualPos = 0; OK = true; } + } } if (OK) LastRelayTime = 0; @@ -4880,87 +5819,138 @@ bool TMoverParameters::AutoRelayCheck(void) } } +bool TMoverParameters::MotorConnectorsCheck() { + + // hunter-111211: wylacznik cisnieniowy + auto const pressureswitch { + ( TrainType != dt_EZT ) + && ( ( BrakePress > 2.0 ) + || ( PipePress < 3.6 ) ) }; + + if( pressureswitch ) { return false; } + + auto const connectorsoff { + ( false == Mains ) + || ( true == FuseFlag ) + || ( true == StLinSwitchOff ) + || ( MainCtrlPos == 0 ) + || ( ActiveDir == 0 ) }; + + if( connectorsoff ) { return false; } + + auto const connectorson { + ( true == StLinFlag ) + || ( ( MainCtrlActualPos == 0 ) + && ( ( MainCtrlPos == 1 ) + || ( ( TrainType == dt_EZT ) && ( MainCtrlPos > 0 ) ) ) ) }; + + return connectorson; +} + // ************************************************************************************************* // Q: 20160713 -// Podnosi / opuszcza przedni pantograf +// Podnosi / opuszcza przedni pantograf. Returns: state of the pantograph after the operation // ************************************************************************************************* -bool TMoverParameters::PantFront(bool State) +bool TMoverParameters::PantFront( bool const State, range_t const Notify ) { - double pf1 = 0; - bool PF = false; - - if ((Battery == - true) /* and ((TrainType<>dt_ET40)or ((TrainType=dt_ET40) and (EnginePowerSource.CollectorsNo>1)))*/) - { - PF = true; - if (State == true) - pf1 = 1; - else - pf1 = 0; - if (PantFrontUp != State) - { +/* + if( ( true == Battery ) + || ( true == ConverterFlag ) ) { +*/ + if( PantFrontUp != State ) { PantFrontUp = State; - if (State == true) - { + if( State == true ) { PantFrontStart = 0; - SendCtrlToNext("PantFront", 1, CabNo); + if( Notify != range_t::local ) { + // wysłanie wyłączenia do pozostałych? + SendCtrlToNext( + "PantFront", 1, CabNo, + ( Notify == range_t::unit ? + ctrain_controll | ctrain_depot : + ctrain_controll ) ); + } } - else - { - PF = false; + else { PantFrontStart = 1; - SendCtrlToNext("PantFront", 0, CabNo); - //{Ra: nie ma potrzeby opuszczać obydwu na raz, jak mozemy każdy osobno - // if (TrainType == dt_EZT) && (ActiveCab == 1) - // { - // PantRearUp = false; - // PantRearStart = 1; - // SendCtrlToNext("PantRear", 0, CabNo); - // } - //} + if( Notify != range_t::local ) { + // wysłanie wyłączenia do pozostałych? + SendCtrlToNext( + "PantFront", 0, CabNo, + ( Notify == range_t::unit ? + ctrain_controll | ctrain_depot : + ctrain_controll ) ); + } } } - else - SendCtrlToNext("PantFront", pf1, CabNo); +/* } - return PF; + else { + // no power, drop the pantograph + // NOTE: this is a simplification as it should just drop on its own with loss of pressure without resupply from (dead) compressor + PantFrontStart = ( + PantFrontUp ? + 1 : + 0 ); + PantFrontUp = false; + if( true == Multiunitcontrol ) { + SendCtrlToNext( "PantFront", 0, CabNo ); + } + } +*/ + return PantFrontUp; } // ************************************************************************************************* // Q: 20160713 // Podnoszenie / opuszczanie pantografu tylnego // ************************************************************************************************* -bool TMoverParameters::PantRear(bool State) +bool TMoverParameters::PantRear( bool const State, range_t const Notify ) { - double pf1; - bool PR = false; - - if (Battery == true) - { - PR = true; - if (State == true) - pf1 = 1; - else - pf1 = 0; - if (PantRearUp != State) - { +/* + if( ( true == Battery ) + || ( true == ConverterFlag ) ) { +*/ + if( PantRearUp != State ) { PantRearUp = State; - if (State == true) - { + if( State == true ) { PantRearStart = 0; - SendCtrlToNext("PantRear", 1, CabNo); + if( Notify != range_t::local ) { + // wysłanie wyłączenia do pozostałych? + SendCtrlToNext( + "PantRear", 1, CabNo, + ( Notify == range_t::unit ? + ctrain_controll | ctrain_depot : + ctrain_controll ) ); + } } - else - { - PR = false; + else { PantRearStart = 1; - SendCtrlToNext("PantRear", 0, CabNo); + if( Notify != range_t::local ) { + // wysłanie wyłączenia do pozostałych? + SendCtrlToNext( + "PantRear", 0, CabNo, + ( Notify == range_t::unit ? + ctrain_controll | ctrain_depot : + ctrain_controll ) ); + } } } - else - SendCtrlToNext("PantRear", pf1, CabNo); +/* } - return PR; + else { + // no power, drop the pantograph + // NOTE: this is a simplification as it should just drop on its own with loss of pressure without resupply from (dead) compressor + PantRearStart = ( + PantRearUp ? + 1 : + 0 ); + PantRearUp = false; + if( true == Multiunitcontrol ) { + SendCtrlToNext( "PantRear", 0, CabNo ); + } + } +*/ + return PantRearUp; } // ************************************************************************************************* @@ -4969,7 +5959,7 @@ bool TMoverParameters::PantRear(bool State) // ************************************************************************************************* bool TMoverParameters::dizel_EngageSwitch(double state) { - if ((EngineType == DieselEngine) && (state <= 1) && (state >= 0) && + if ((EngineType == TEngineType::DieselEngine) && (state <= 1) && (state >= 0) && (state != dizel_engagestate)) { dizel_engagestate = state; @@ -4985,8 +5975,6 @@ bool TMoverParameters::dizel_EngageSwitch(double state) // ************************************************************************************************* bool TMoverParameters::dizel_EngageChange(double dt) { - const double engagedownspeed = 0.9; - const double engageupspeed = 0.5; double engagespeed = 0; // OK:boolean; bool DEC; @@ -5026,7 +6014,7 @@ bool TMoverParameters::dizel_AutoGearCheck(void) OK = false; if (MotorParam[ScndCtrlActualPos].AutoSwitch && Mains) { - if (RList[MainCtrlPos].Mn == 0) + if ((RList[MainCtrlPos].Mn == 0)&&(!hydro_TC)) { if (dizel_engagestate > 0) dizel_EngageSwitch(0); @@ -5038,16 +6026,19 @@ bool TMoverParameters::dizel_AutoGearCheck(void) if (MotorParam[ScndCtrlActualPos].AutoSwitch && (dizel_automaticgearstatus == 0)) // sprawdz czy zmienic biegi { - if ((Vel > MotorParam[ScndCtrlActualPos].mfi) && - (ScndCtrlActualPos < ScndCtrlPosNo)) - { - dizel_automaticgearstatus = 1; - OK = true; + if( Vel > MotorParam[ ScndCtrlActualPos ].mfi ) { + // shift up + if( ScndCtrlActualPos < ScndCtrlPosNo ) { + dizel_automaticgearstatus = 1; + OK = true; + } } - else if ((Vel < MotorParam[ScndCtrlActualPos].fi) && (ScndCtrlActualPos > 0)) - { - dizel_automaticgearstatus = -1; - OK = true; + else if( Vel < MotorParam[ ScndCtrlActualPos ].fi ) { + // shift down + if( ScndCtrlActualPos > 0 ) { + dizel_automaticgearstatus = -1; + OK = true; + } } } } @@ -5074,8 +6065,29 @@ bool TMoverParameters::dizel_AutoGearCheck(void) case 2: dizel_EngageSwitch(1.0); break; + case 3: + if (Vel>dizel_minVelfullengage) + dizel_EngageSwitch(1.0); + else + dizel_EngageSwitch(0.5); + break; + case 4: + if (Vel>dizel_minVelfullengage) + dizel_EngageSwitch(1.0); + else + dizel_EngageSwitch(0.66); + break; + case 5: + if (Vel>dizel_minVelfullengage) + dizel_EngageSwitch(1.0); + else + dizel_EngageSwitch(0.35*(1+RList[MainCtrlPos].R)*RList[MainCtrlPos].R); + break; default: - dizel_EngageSwitch(0.0); + if (hydro_TC && hydro_TC_Fill>0.01) + dizel_EngageSwitch(1.0); + else + dizel_EngageSwitch(0.0); } else dizel_EngageSwitch(0.0); @@ -5087,28 +6099,97 @@ bool TMoverParameters::dizel_AutoGearCheck(void) return OK; } +// performs diesel engine startup procedure; potentially clears startup switch; returns: true if the engine can be started, false otherwise +bool TMoverParameters::dizel_StartupCheck() { + + auto engineisready { true }; // make inital optimistic presumption, then watch the reality crush it + + // test the fuel pump + // TODO: add fuel pressure check + if( false == FuelPump.is_active ) { + engineisready = false; + if( FuelPump.start_type == start_t::manual ) { + // with manual pump control startup procedure is done only once per starter switch press + dizel_startup = false; + } + } + // test the oil pump + if( ( false == OilPump.is_active ) + || ( OilPump.pressure < OilPump.pressure_minimum ) ) { + engineisready = false; + if( OilPump.start_type == start_t::manual ) { + // with manual pump control startup procedure is done only once per starter switch press + dizel_startup = false; + } + } + // test the water circuits and water temperature + if( true == dizel_heat.PA ) { + engineisready = false; + // TBD, TODO: reset startup procedure depending on pump and heater control mode + dizel_startup = false; + } + + return engineisready; +} + // ************************************************************************************************* // Q: 20160715 // Aktualizacja stanu silnika // ************************************************************************************************* -bool TMoverParameters::dizel_Update(double dt) -{ - const double fillspeed = 2; - bool DU; +bool TMoverParameters::dizel_Update(double dt) { - // dizel_Update:=false; - if (dizel_enginestart && (LastSwitchingTime >= InitialCtrlDelay)) - { - dizel_enginestart = false; - LastSwitchingTime = 0; - enrot = dizel_nmin / 2.0; // TODO: dac zaleznie od temperatury i baterii + WaterPumpCheck( dt ); + WaterHeaterCheck( dt ); + OilPumpCheck( dt ); + FuelPumpCheck( dt ); + if( ( true == dizel_startup ) + && ( true == dizel_StartupCheck() ) ) { + dizel_ignition = true; } - /*OK=*/dizel_EngageChange(dt); - // if AutoRelayFlag then Poprawka na SM03 - DU = dizel_AutoGearCheck(); - // dizel_fill:=(dizel_fill+dizel_fillcheck(MainCtrlPos))/2; - dizel_fill = dizel_fill + fillspeed * dt * (dizel_fillcheck(MainCtrlPos) - dizel_fill); - // dizel_Update:=OK; + + if( ( true == dizel_ignition ) + && ( LastSwitchingTime >= InitialCtrlDelay ) ) { + + dizel_startup = false; + dizel_ignition = false; + // TODO: split engine and main circuit state indicator in two separate flags + LastSwitchingTime = 0; + Mains = true; + dizel_spinup = true; + enrot = std::max( + enrot, + 0.35 * ( // TODO: dac zaleznie od temperatury i baterii + EngineType == TEngineType::DieselEngine ? + dizel_nmin : + DElist[ 0 ].RPM / 60.0 ) ); + + } + + dizel_spinup = ( + dizel_spinup + && Mains + && ( enrot < 0.95 * ( + EngineType == TEngineType::DieselEngine ? + dizel_nmin : + DElist[ 0 ].RPM / 60.0 ) ) ); + + if( ( true == Mains ) + && ( false == FuelPump.is_active ) ) { + // knock out the engine if the fuel pump isn't feeding it + // TBD, TODO: grace period before the engine is starved for fuel and knocked out + MainSwitch( false ); + } + + bool DU { false }; + + if( EngineType == TEngineType::DieselEngine ) { + dizel_EngageChange( dt ); + DU = dizel_AutoGearCheck(); + double const fillspeed { 2 }; + dizel_fill = dizel_fill + fillspeed * dt * ( dizel_fillcheck( MainCtrlPos ) - dizel_fill ); + } + + dizel_Heat( dt ); return DU; } @@ -5119,19 +6200,26 @@ bool TMoverParameters::dizel_Update(double dt) // ************************************************************************************************* double TMoverParameters::dizel_fillcheck(int mcp) { - double realfill, nreg; + auto realfill { 0.0 }; - realfill = 0; - nreg = 0; - if (Mains && (MainCtrlPosNo > 0)) - { - if (dizel_enginestart && - (LastSwitchingTime >= 0.9 * InitialCtrlDelay)) // wzbogacenie przy rozruchu + if( ( true == Mains ) + && ( MainCtrlPosNo > 0 ) + && ( true == FuelPump.is_active ) ) { + + if( ( true == dizel_ignition ) + && ( LastSwitchingTime >= 0.9 * InitialCtrlDelay ) ) { + // wzbogacenie przy rozruchu + // NOTE: ignition flag is reset before this code is executed + // TODO: sort this out realfill = 1; - else - realfill = RList[mcp].R; // napelnienie zalezne od MainCtrlPos + } + else { + // napelnienie zalezne od MainCtrlPos + realfill = RList[ mcp ].R; + } if (dizel_nmax_cutoff > 0) { + auto nreg { 0.0 }; switch (RList[MainCtrlPos].Mn) { case 0: @@ -5139,27 +6227,43 @@ double TMoverParameters::dizel_fillcheck(int mcp) nreg = dizel_nmin; break; case 2: - if (dizel_automaticgearstatus == 0) + if ((dizel_automaticgearstatus == 0)&&(true/*(!hydro_TC) || (dizel_engage>dizel_fill)*/)) nreg = dizel_nmax; else nreg = dizel_nmin; break; + case 3: + if ((dizel_automaticgearstatus == 0) && (Vel > dizel_minVelfullengage)) + nreg = dizel_nmax; + else + nreg = dizel_nmin; + break; + case 4: + if ((dizel_automaticgearstatus == 0) && (Vel > dizel_minVelfullengage)) + nreg = dizel_nmax; + else + nreg = dizel_nmin * 0.75 + dizel_nmax * 0.25; + break; + case 5: + if (Vel > dizel_minVelfullengage) + nreg = dizel_nmax; + else + nreg = dizel_nmin + 0.8 * (dizel_nmax - dizel_nmin) * RList[mcp].R; + break; default: realfill = 0; // sluczaj + break; } - if (enrot > nreg) - realfill = realfill * (3.9 - 3.0 * abs(enrot) / nreg); - if (enrot > dizel_nmax_cutoff) - realfill = realfill * (9.8 - 9.0 * abs(enrot) / dizel_nmax_cutoff); - if (enrot < dizel_nmin) - realfill = realfill * (1.0 + (dizel_nmin - abs(enrot)) / dizel_nmin); + if (enrot > nreg) //nad predkoscia regulatora zeruj dawke + realfill = 0; + if (enrot < nreg) //pod predkoscia regulatora dawka zadana + realfill = realfill; + if ((enrot < dizel_nmin * 0.98)&&(RList[mcp].R>0.001)) //jesli ponizej biegu jalowego i niezerowa dawka, to dawaj pelna + realfill = 1; } } - if (realfill < 0) - realfill = 0; - if (realfill > 1) - realfill = 1; - return realfill; + + return clamp( realfill, 0.0, 1.0 ); } // ************************************************************************************************* @@ -5168,193 +6272,622 @@ double TMoverParameters::dizel_fillcheck(int mcp) // ************************************************************************************************* double TMoverParameters::dizel_Momentum(double dizel_fill, double n, double dt) { // liczy moment sily wytwarzany przez silnik spalinowy} - double Moment = 0, enMoment = 0, eps = 0, newn = 0, friction = 0; - - // friction =dizel_engagefriction*(11-2*random)/10; + double Moment = 0, enMoment = 0, gearMoment = 0, eps = 0, newn = 0, friction = 0, neps = 0; + double TorqueH = 0, TorqueL = 0, TorqueC = 0; + n = n * CabNo; + if ((MotorParam[ScndCtrlActualPos].mIsat < 0.001)||(ActiveDir == 0)) + n = enrot; friction = dizel_engagefriction; - if (enrot > 0) - { // sqr TODO: sqr c++ - Moment = dizel_Mmax * dizel_fill - - (dizel_Mmax - dizel_Mnmax * dizel_fill) * - sqr(enrot / (dizel_nmax - dizel_nMmax * dizel_fill)) - - dizel_Mstand; // Q: zamieniam SQR() na sqr() - // Moment:=Moment*(1+sin(eAngle*4))-dizel_Mstand*(1+cos(eAngle*4));} - } - else - Moment = -dizel_Mstand; - if (enrot < dizel_nmin / 10.0) - if (eAngle < PI / 2.0) - Moment -= dizel_Mstand; // wstrzymywanie przy malych obrotach - //!! abs - if (abs(abs(n) - enrot) < 0.1) - { - if ((Moment) > (dizel_engageMaxForce * dizel_engage * dizel_engageDia * friction * - 2)) // zerwanie przyczepnosci sprzegla - enrot += dt * Moment / dizel_AIM; - else - { - dizel_engagedeltaomega = 0; - enrot = abs(n); // jest przyczepnosc tarcz - } - } - else - { - if ((enrot == 0) && (Moment < 0)) - newn = 0; - else - { - //!! abs - dizel_engagedeltaomega = enrot - n; // sliganie tarcz - enMoment = Moment - - Sign(dizel_engagedeltaomega) * dizel_engageMaxForce * dizel_engage * - dizel_engageDia * friction; - Moment = Sign(dizel_engagedeltaomega) * dizel_engageMaxForce * dizel_engage * - dizel_engageDia * friction; - dizel_engagedeltaomega = abs(enrot - abs(n)); - eps = enMoment / dizel_AIM; - newn = enrot + eps * dt; - if ((newn * enrot <= 0) && (eps * enrot < 0)) - newn = 0; - } - enrot = newn; - } - if ((enrot == 0) && (!dizel_enginestart)) - Mains = false; + hydro_TC_nIn = enrot; //wal wejsciowy przetwornika momentu + hydro_TC_nOut = dizel_n_old; //wal wyjsciowy przetwornika momentu + neps = (n - dizel_n_old) / dt; //przyspieszenie katowe walu wejsciowego skrzyni biegow - return Moment; + if( enrot > 0 ) { + Moment = ( dizel_Mmax - ( dizel_Mmax - dizel_Mnmax ) * square( ( enrot - dizel_nMmax ) / ( dizel_nMmax - dizel_nmax ) ) ) * dizel_fill - dizel_Mstand; + } + else { + Moment = -dizel_Mstand; + } + if( ( enrot < dizel_nmin / 10.0 ) + && ( eAngle < M_PI_2 ) ) { + // wstrzymywanie przy malych obrotach + Moment -= dizel_Mstand; + } + if (true == dizel_spinup) + Moment += dizel_Mstand / (0.3 + std::max(0.0, enrot/dizel_nmin)); //rozrusznik + + dizel_Torque = Moment; + + if (hydro_TC) //jesli przetwornik momentu + { + //napelnianie przetwornika + if ((MainCtrlPos > 0) && (Mains) && (enrot>dizel_nmin*0.9)) + hydro_TC_Fill += hydro_TC_FillRateInc * dt; + //oproznianie przetwornika + if (((MainCtrlPos == 0) && (Vel<3)) + || (!Mains) + || (enrot hydro_TC_LockupSpeed) && (Mains) && (enrot > 0.9 * dizel_nmin) && (MainCtrlPos>0)) + hydro_TC_LockupRate += hydro_TC_FillRateInc*dt; + //luzowanie sprzegla blokujacego + if ((Vel < (MainCtrlPos>0 ? hydro_TC_LockupSpeed : hydro_TC_UnlockSpeed)) || (!Mains) || (enrot < 0.8 * dizel_nmin)) + hydro_TC_LockupRate -= hydro_TC_FillRateDec*dt; + //obcinanie zakresu + hydro_TC_LockupRate = clamp(hydro_TC_LockupRate, 0.0, 1.0); + } + else + { + hydro_TC_Fill = 0.0; + hydro_TC_LockupRate = 0.0; + } + + //obliczanie momentow poszczegolnych sprzegiel + //sprzeglo glowne (skrzynia biegow) + TorqueC = dizel_engageMaxForce * dizel_engage * dizel_engageDia * friction; + + if (hydro_TC) //jesli hydro + { + double HydroTorque = 0; + HydroTorque += hydro_TC_nIn * hydro_TC_nIn * hydro_TC_TorqueInIn; + HydroTorque += (hydro_TC_nIn - hydro_TC_nOut) * hydro_TC_TorqueInOut; + HydroTorque += hydro_TC_nOut * hydro_TC_nOut * hydro_TC_TorqueOutOut; + double nOut2In = hydro_TC_nOut / std::max(0.01, hydro_TC_nIn); + if (nOut2In < hydro_TC_CouplingPoint) + { + hydro_TC_TMRatio = 1 + (hydro_TC_TMMax - 1) * square(1 - nOut2In / hydro_TC_CouplingPoint); + hydro_TC_TorqueIn = HydroTorque * hydro_TC_Fill; + hydro_TC_TorqueOut = HydroTorque * hydro_TC_Fill * hydro_TC_TMRatio; + } + else + { + hydro_TC_TMRatio = (1 - nOut2In) / (1 - hydro_TC_CouplingPoint); + hydro_TC_TorqueIn = HydroTorque * hydro_TC_Fill * hydro_TC_TMRatio; + hydro_TC_TorqueOut = HydroTorque * hydro_TC_Fill * hydro_TC_TMRatio; + } + TorqueH = hydro_TC_TorqueOut; + TorqueL = hydro_TC_LockupTorque * hydro_TC_LockupRate; + } + else + { + TorqueH = 0; //brak przetwornika oznacza brak momentu + TorqueL = 1 + TorqueC * 2; //zabezpieczenie, polaczenie trwale + } + + //sprawdzanie dociskow poszczegolnych sprzegiel + if (abs(Moment) > Min0R(TorqueC, TorqueL + abs(hydro_TC_TorqueIn)) || (abs(dizel_n_old - enrot) > 0.1)) //slizga sie z powodu roznic predkosci albo przekroczenia momentu + { + dizel_engagedeltaomega = enrot - dizel_n_old; + + if (TorqueC > TorqueL) + { + if (TorqueC > TorqueL + abs(TorqueH)) + { + hydro_TC_nOut = n; + gearMoment = TorqueL + abs(TorqueH) * sign(dizel_engagedeltaomega); + enMoment = Moment - (TorqueL + abs(hydro_TC_TorqueIn))* sign(dizel_engagedeltaomega); + } + else + { + hydro_TC_nOut = enrot - (n - enrot)*(TorqueC - TorqueL) / TorqueH; //slizganie proporcjonalne, zeby przetwornik nadrabial + gearMoment = TorqueC * sign(dizel_engagedeltaomega); + enMoment = Moment - gearMoment; + } + + } + else + { + hydro_TC_nOut = enrot; + gearMoment = (TorqueC) * sign(dizel_engagedeltaomega); + enMoment = Moment - gearMoment; + } + eps = enMoment / dizel_AIM; + newn = enrot + eps * dt; + if (((newn - n)*(enrot - dizel_n_old) < 0)&&(TorqueC>0.1)) //przejscie przez zero - slizgalo sie i przestało + newn = n; + if ((newn * enrot <= 0) && (eps * enrot < 0)) //przejscie przez zero obrotow + newn = 0; + enrot = newn; + } + else //nie slizga sie (jeszcze) + { + dizel_engagedeltaomega = 0; + gearMoment = Moment; + enMoment = 0; + double enrot_min = enrot - (Min0R(TorqueC, TorqueL + abs(hydro_TC_TorqueIn)) - Moment) / dizel_AIM * dt; + double enrot_max = enrot + (Min0R(TorqueC, TorqueL + abs(hydro_TC_TorqueIn)) + Moment) / dizel_AIM * dt; + enrot = clamp(n,enrot_min,enrot_max); + } + + + if( ( enrot <= 0 ) && ( false == dizel_spinup ) ) { + MainSwitch( false ); + enrot = 0; + } + + dizel_n_old = n; //obecna predkosc katowa na potrzeby kolejnej klatki + + return gearMoment; +} + +// sets component temperatures to specified value +void TMoverParameters::dizel_HeatSet( float const Value ) { + + dizel_heat.Te = // TODO: don't include ambient temperature, pull it from environment data instead + dizel_heat.Ts = + dizel_heat.To = + dizel_heat.Tsr = + dizel_heat.Twy = + dizel_heat.Tsr2 = + dizel_heat.Twy2 = + dizel_heat.temperatura1 = + dizel_heat.temperatura2 = Value; +} + +// calculates diesel engine temperature and heat transfers +// adapted from scripts written by adamst +// NOTE: originally executed twice per second +void TMoverParameters::dizel_Heat( double const dt ) { + + auto const qs { 44700.0 }; + auto const Cs { 11000.0 }; + auto const Cw { 4.189 }; + auto const Co { 1.885 }; + auto const gwmin { 400.0 }; + auto const gwmax { 4000.0 }; + auto const gwmin2 { 400.0 }; + auto const gwmax2 { 4000.0 }; + + dizel_heat.Te = Global.AirTemperature; + + auto const engineon { ( Mains ? 1 : 0 ) }; + auto const engineoff { ( Mains ? 0 : 1 ) }; + auto const rpm { enrot * 60 }; + // TODO: calculate this once and cache for further use, instead of doing it repeatedly all over the place + auto const maxrevolutions { ( + EngineType == TEngineType::DieselEngine ? dizel_nmax * 60 : + EngineType == TEngineType::DieselElectric ? DElist[ MainCtrlPosNo ].RPM : + std::numeric_limits::max() ) }; // shouldn't ever get here but, eh + auto const revolutionsfactor { clamp( rpm / maxrevolutions, 0.0, 1.0 ) }; + auto const waterpump { WaterPump.is_active ? 1 : 0 }; + + auto const gw = engineon * interpolate( gwmin, gwmax, revolutionsfactor ) + waterpump * 1000 + engineoff * 200; + auto const gw2 = engineon * interpolate( gwmin2, gwmax2, revolutionsfactor ) + waterpump * 1000 + engineoff * 200; + auto const gwO = interpolate( gwmin, gwmax, revolutionsfactor ); + + dizel_heat.water.is_cold = ( + ( dizel_heat.water.config.temp_min > 0 ) + && ( dizel_heat.temperatura1 < dizel_heat.water.config.temp_min - ( Mains ? 5 : 0 ) ) ); + dizel_heat.water.is_hot = ( + ( dizel_heat.water.config.temp_max > 0 ) + && ( dizel_heat.temperatura1 > dizel_heat.water.config.temp_max - ( dizel_heat.water.is_hot ? 8 : 0 ) ) ); + dizel_heat.water_aux.is_cold = ( + ( dizel_heat.water_aux.config.temp_min > 0 ) + && ( dizel_heat.temperatura2 < dizel_heat.water_aux.config.temp_min - ( Mains ? 5 : 0 ) ) ); + dizel_heat.water_aux.is_hot = ( + ( dizel_heat.water_aux.config.temp_max > 0 ) + && ( dizel_heat.temperatura2 > dizel_heat.water_aux.config.temp_max - ( dizel_heat.water_aux.is_hot ? 8 : 0 ) ) ); + dizel_heat.oil.is_cold = ( + ( dizel_heat.oil.config.temp_min > 0 ) + && ( dizel_heat.To < dizel_heat.oil.config.temp_min - ( Mains ? 5 : 0 ) ) ); + dizel_heat.oil.is_hot = ( + ( dizel_heat.oil.config.temp_max > 0 ) + && ( dizel_heat.To > dizel_heat.oil.config.temp_max - ( dizel_heat.oil.is_hot ? 8 : 0 ) ) ); + + auto const PT = ( + ( false == dizel_heat.water.is_cold ) + && ( false == dizel_heat.water.is_hot ) + && ( false == dizel_heat.water_aux.is_cold ) + && ( false == dizel_heat.water_aux.is_hot ) + && ( false == dizel_heat.oil.is_cold ) + && ( false == dizel_heat.oil.is_hot ) /* && ( false == awaria_termostatow ) */ ) /* || PTp */; + auto const PPT = ( false == PT ) /* && ( false == PPTp ) */; + dizel_heat.PA = ( /* ( ( !zamkniecie or niedomkniecie ) and !WBD ) || */ PPT /* || nurnik || ( woda < 7 ) */ ) /* && ( !PAp ) */; + + // engine heat transfers + auto const Ge { engineon * ( 0.21 * EnginePower + 12 ) / 3600 }; + // TODO: replace fixed heating power cost with more accurate calculation + auto const obciazenie { engineon * ( ( EnginePower / 950 ) + ( Heating ? HeatingPower : 0 ) + 70 ) }; + auto const Qd { qs * Ge - obciazenie }; + // silnik oddaje czesc ciepla do wody chlodzacej, a takze pewna niewielka czesc do otoczenia, modyfikowane przez okienko + auto const Qs { ( Qd - ( dizel_heat.kfs * ( dizel_heat.Ts - dizel_heat.Tsr ) ) - ( dizel_heat.kfe * /* ( 0.3 + 0.7 * ( dizel_heat.okienko ? 1 : 0 ) ) * */ ( dizel_heat.Ts - dizel_heat.Te ) ) ) }; + auto const dTss { Qs / Cs }; + dizel_heat.Ts += ( dTss * dt ); + + // oil heat transfers + // olej oddaje cieplo do wody gdy krazy przez wymiennik ciepla == wlaczona pompka lub silnik + auto const dTo { ( + dizel_heat.auxiliary_water_circuit ? + ( ( dizel_heat.kfo * ( dizel_heat.Ts - dizel_heat.To ) ) - ( dizel_heat.kfo2 * ( dizel_heat.To - dizel_heat.Tsr2 ) ) ) / ( gwO * Co ) : + ( ( dizel_heat.kfo * ( dizel_heat.Ts - dizel_heat.To ) ) - ( dizel_heat.kfo2 * ( dizel_heat.To - dizel_heat.Tsr ) ) ) / ( gwO * Co ) ) }; + dizel_heat.To += ( dTo * dt ); + + // heater +/* + if( typ == "SP45" ) + Qp = (float)( podgrzewacz and ( true == WaterPump.is_active ) and ( Twy < 55 ) and ( Twy2 < 55 ) ) * 1000; + else +*/ + auto const Qp = ( ( ( true == WaterHeater.is_active ) && ( true == WaterPump.is_active ) && ( dizel_heat.Twy < 60 ) && ( dizel_heat.Twy2 < 60 ) ) ? 1 : 0 ) * 1000; + + auto const kurek07 { 1 }; // unknown/unimplemented device TBD, TODO: identify and implement? + + if( true == dizel_heat.auxiliary_water_circuit ) { + // auxiliary water circuit setup + dizel_heat.water_aux.is_warm = ( + ( true == dizel_heat.cooling ) + || ( ( true == Mains ) + && ( BatteryVoltage > ( 0.75 * NominalBatteryVoltage ) ) /* && !bezpompy && !awaria_chlodzenia && !WS10 */ + && ( dizel_heat.water_aux.config.temp_cooling > 0 ) + && ( dizel_heat.temperatura2 > dizel_heat.water_aux.config.temp_cooling - ( dizel_heat.water_aux.is_warm ? 8 : 0 ) ) ) ); + auto const PTC2 { ( dizel_heat.water_aux.is_warm /*or PTC2p*/ ? 1 : 0 ) }; + dizel_heat.rpmwz2 = PTC2 * ( dizel_heat.fan_speed >= 0 ? ( rpm * dizel_heat.fan_speed ) : ( dizel_heat.fan_speed * -1 ) ); + dizel_heat.zaluzje2 = ( dizel_heat.water_aux.config.shutters ? ( PTC2 == 1 ) : true ); // no shutters is an equivalent to having them open + auto const zaluzje2 { ( dizel_heat.zaluzje2 ? 1 : 0 ) }; + // auxiliary water circuit heat transfer values + auto const kf2 { kurek07 * ( ( dizel_heat.kw * ( 0.3 + 0.7 * zaluzje2 ) ) * dizel_heat.rpmw2 + ( dizel_heat.kv * ( 0.3 + 0.7 * zaluzje2 ) * Vel / 3.6 ) ) + 2 }; + auto const dTs2 { ( ( dizel_heat.kfo2 * ( dizel_heat.To - dizel_heat.Tsr2 ) ) ) / ( gw2 * Cw ) }; + // przy otwartym kurku B ma³y obieg jest dogrzewany przez du¿y - stosujemy przy korzystaniu z podgrzewacza oraz w zimie + auto const Qch2 { -kf2 * ( dizel_heat.Tsr2 - dizel_heat.Te ) + ( 80 * ( true == WaterCircuitsLink ? 1 : 0 ) * ( dizel_heat.Twy - dizel_heat.Tsr2 ) ) }; + auto const dTch2 { Qch2 / ( gw2 * Cw ) }; + // auxiliary water circuit heat transfers finalization + // NOTE: since primary circuit doesn't read data from the auxiliary one, we can pretty safely finalize auxiliary updates before touching the primary circuit + auto const Twe2 { dizel_heat.Twy2 + ( dTch2 * dt ) }; + dizel_heat.Twy2 = Twe2 + ( dTs2 * dt ); + dizel_heat.Tsr2 = 0.5 * ( dizel_heat.Twy2 + Twe2 ); + dizel_heat.temperatura2 = dizel_heat.Twy2; + } + // primary water circuit setup + dizel_heat.water.is_flowing = ( + ( dizel_heat.water.config.temp_flow < 0 ) + || ( dizel_heat.temperatura1 > dizel_heat.water.config.temp_flow - ( dizel_heat.water.is_flowing ? 5 : 0 ) ) ); + auto const obieg { ( dizel_heat.water.is_flowing ? 1 : 0 ) }; + dizel_heat.water.is_warm = ( + ( true == dizel_heat.cooling ) + || ( ( true == Mains ) + && ( BatteryVoltage > ( 0.75 * NominalBatteryVoltage ) ) /* && !bezpompy && !awaria_chlodzenia && !WS10 */ + && ( dizel_heat.water.config.temp_cooling > 0 ) + && ( dizel_heat.temperatura1 > dizel_heat.water.config.temp_cooling - ( dizel_heat.water.is_warm ? 8 : 0 ) ) ) ); + auto const PTC1 { ( dizel_heat.water.is_warm /*or PTC1p*/ ? 1 : 0 ) }; + dizel_heat.rpmwz = PTC1 * ( dizel_heat.fan_speed >= 0 ? ( rpm * dizel_heat.fan_speed ) : ( dizel_heat.fan_speed * -1 ) ); + dizel_heat.zaluzje1 = ( dizel_heat.water.config.shutters ? ( PTC1 == 1 ) : true ); // no shutters is an equivalent to having them open + auto const zaluzje1 { ( dizel_heat.zaluzje1 ? 1 : 0 ) }; + // primary water circuit heat transfer values + auto const kf { obieg * kurek07 * ( ( dizel_heat.kw * ( 0.3 + 0.7 * zaluzje1 ) ) * dizel_heat.rpmw + ( dizel_heat.kv * ( 0.3 + 0.7 * zaluzje1 ) * Vel / 3.6 ) + 3 ) + 2 }; + auto const dTs { ( + dizel_heat.auxiliary_water_circuit ? + ( ( dizel_heat.kfs * ( dizel_heat.Ts - dizel_heat.Tsr ) ) ) / ( gw * Cw ) : + ( ( dizel_heat.kfs * ( dizel_heat.Ts - dizel_heat.Tsr ) ) + ( dizel_heat.kfo2 * ( dizel_heat.To - dizel_heat.Tsr ) ) ) / ( gw * Cw ) ) }; + auto const Qch { -kf * ( dizel_heat.Tsr - dizel_heat.Te ) + Qp }; + auto const dTch { Qch / ( gw * Cw ) }; + // primary water circuit heat transfers finalization + auto const Twe { dizel_heat.Twy + ( dTch * dt ) }; + dizel_heat.Twy = Twe + ( dTs * dt ); + dizel_heat.Tsr = 0.5 * ( dizel_heat.Twy + Twe ); + dizel_heat.temperatura1 = dizel_heat.Twy; +/* + fuelConsumed = fuelConsumed + ( Ge * 0.5 ); + + while( fuelConsumed >= 0.83 ) { + fuelConsumed = fuelConsumed - 0.83; + fuelQueue.DestroyProductMatching( null, 1 ); + }//if + + if( engineon ) + temp_turbo = temp_turbo + 0.3 * ( t_pozycja ); + if( t_pozycja == 0 and cisnienie > 0.04 ) + temp_turbo = temp_turbo - 1; + + if( temp_turbo > 400 ) + temp_turbo = 400; + if( temp_turbo < 0 ) + temp_turbo = 0; + + if( temp_turbo > 50 and cisnienie < 0.05 ) + timer_turbo = timer_turbo + 1; + + if( temp_turbo == 0 ) + timer_turbo = 0; + + if( timer_turbo > 360 ) { + awaria_turbo = true; + timer_turbo = 400; + } + + if( Ts < 50 ) + p_odpal = 3; + if( Ts > 49 and Ts < 76 ) + p_odpal = 4; + if( Ts > 75 ) + p_odpal = 7; + + stukanie = stukanie or awaria_oleju; + + if( awaria_oleju == true and ilosc_oleju > 0 ) { + ilosc_oleju = ilosc_oleju - ( 0.002 * rpm / 1500 ); + } + if( awaria_oleju == true and cisnienie < 0.06 ) + damage = 1; +*/ +} + +bool +TMoverParameters::AssignLoad( std::string const &Name, float const Amount ) { + + if( Name == "pantstate" ) { + if( EnginePowerSource.SourceType == TPowerSource::CurrentCollector ) { + // wartość niby "pantstate" - nazwa dla formalności, ważna jest ilość + auto const pantographsetup { static_cast( Amount ) }; + if( pantographsetup & ( 1 << 2 ) ) { + DoubleTr = -1; + } + if( pantographsetup & ( 1 << 0 ) ) { + if( DoubleTr == 1 ) { PantFront( true ); } + else { PantRear( true ); } + } + if( pantographsetup & ( 1 << 1 ) ) { + if( DoubleTr == 1 ) { PantRear( true ); } + else { PantFront( true ); } + } + return true; + } + else { + return false; + } + } + + if( Name.empty() ) { + // empty the vehicle if requested + LoadType = load_attributes(); + LoadAmount = 0.f; + return true; + } + // can't mix load types, at least for the time being + if( ( LoadAmount > 0 ) && ( LoadType.name != Name ) ) { return false; } + + for( auto const &loadattributes : LoadAttributes ) { + if( Name == loadattributes.name ) { + LoadType = loadattributes; + LoadAmount = Amount; + return true; + } + } + // didn't find matching load configuration, this type is unsupported + return false; } // ************************************************************************************************* // Q: 20160713 // Test zakończenia załadunku / rozładunku // ************************************************************************************************* -bool TMoverParameters::LoadingDone(double LSpeed, std::string LoadInit) -{ - // test zakończenia załadunku/rozładunku - long LoadChange = 0; - bool LD = false; +bool TMoverParameters::LoadingDone(double const LSpeed, std::string const &Loadname) { - // ClearPendingExceptions; // zabezpieczenie dla Trunc() - // LoadingDone:=false; //nie zakończone - if (!LoadInit.empty()) // nazwa ładunku niepusta - { - if (Load > MaxLoad) - LoadChange = abs(long(LSpeed * LastLoadChangeTime / 2.0)); // przeładowanie? - else - LoadChange = abs(long(LSpeed * LastLoadChangeTime)); - if (LSpeed < 0) // gdy rozładunek - { - LoadStatus = 2; // trwa rozładunek (włączenie naliczania czasu) - if (LoadChange != 0) // jeśli coś przeładowano - { - LastLoadChangeTime = 0; // naliczony czas został zużyty - Load -= LoadChange; // zmniejszenie ilości ładunku - CommandIn.Value1 = - CommandIn.Value1 - LoadChange; // zmniejszenie ilości do rozładowania - if (Load < 0) - Load = 0; //ładunek nie może być ujemny - if ((Load == 0) || (CommandIn.Value1 < 0)) // pusto lub rozładowano żądaną ilość - LoadStatus = 4; // skończony rozładunek - if (Load == 0) - LoadType.clear(); // jak nic nie ma, to nie ma też nazwy - } - } - else if (LSpeed > 0) // gdy załadunek - { - LoadStatus = 1; // trwa załadunek (włączenie naliczania czasu) - if (LoadChange != 0) // jeśli coś przeładowano - { - LastLoadChangeTime = 0; // naliczony czas został zużyty - LoadType = LoadInit; // nazwa - Load += LoadChange; // zwiększenie ładunku - CommandIn.Value1 = CommandIn.Value1 - LoadChange; - if ((Load >= MaxLoad * (1.0 + OverLoadFactor)) || (CommandIn.Value1 < 0)) - LoadStatus = 4; // skończony załadunek - } - } - else - LoadStatus = 4; // zerowa prędkość zmiany, to koniec + if( LSpeed == 0.0 ) { + // zerowa prędkość zmiany, to koniec + LoadStatus = 4; + return true; } - return (LoadStatus >= 4); + + if( Loadname.empty() ) { return ( LoadStatus >= 4 ); } + if( Loadname != LoadType.name ) { return ( LoadStatus >= 4 ); } + + // test zakończenia załadunku/rozładunku + // load exchange speed is reduced if the wagon is overloaded + auto const loadchange { static_cast( std::abs( LSpeed * LastLoadChangeTime ) * ( LoadAmount > MaxLoad ? 0.5 : 1.0 ) ) }; + + if( LSpeed < 0 ) { + // gdy rozładunek + LoadStatus = 2; // trwa rozładunek (włączenie naliczania czasu) + if( loadchange > 0 ) // jeśli coś przeładowano + { + LastLoadChangeTime = 0; // naliczony czas został zużyty + LoadAmount -= loadchange; // zmniejszenie ilości ładunku + CommandIn.Value1 -= loadchange; // zmniejszenie ilości do rozładowania + if( ( LoadAmount <= 0 ) || ( CommandIn.Value1 <= 0 ) ) { + // pusto lub rozładowano żądaną ilość + LoadStatus = 4; // skończony rozładunek + LoadAmount = std::max( 0.f, LoadAmount ); //ładunek nie może być ujemny + } + if( LoadAmount == 0.f ) { + AssignLoad(""); // jak nic nie ma, to nie ma też nazwy + } + } + } + else if( LSpeed > 0 ) { + // gdy załadunek + LoadStatus = 1; // trwa załadunek (włączenie naliczania czasu) + if( loadchange > 0 ) // jeśli coś przeładowano + { + LastLoadChangeTime = 0; // naliczony czas został zużyty + LoadAmount += loadchange; // zwiększenie ładunku + CommandIn.Value1 -= loadchange; + if( ( LoadAmount >= MaxLoad * ( 1.0 + OverLoadFactor ) ) || ( CommandIn.Value1 <= 0 ) ) { + LoadStatus = 4; // skończony załadunek + LoadAmount = std::min( MaxLoad * ( 1.0 + OverLoadFactor ), LoadAmount ); + } + } + } + + return ( LoadStatus >= 4 ); } // ************************************************************************************************* // Q: 20160713 // Zwraca informacje o działającej blokadzie drzwi // ************************************************************************************************* -bool TMoverParameters::DoorBlockedFlag(void) -{ - // if (DoorBlocked=true) and (Vel<5.0) then - bool DBF = false; - if ((DoorBlocked == true) && (Vel >= 5.0)) - DBF = true; - - return DBF; +bool TMoverParameters::DoorBlockedFlag( void ) { + // TBD: configurable lock activation threshold? + return ( + ( true == DoorBlocked ) + && ( true == DoorLockEnabled ) + && ( Vel >= 10.0 ) ); } // ************************************************************************************************* // Q: 20160713 // Otwiera / zamyka lewe drzwi // ************************************************************************************************* -bool TMoverParameters::DoorLeft(bool State) -{ - bool DL = false; - if ((DoorLeftOpened != State) && (DoorBlockedFlag() == false) && (Battery == true)) - { - DL = true; +// NOTE: door methods work regardless of vehicle door control type, +// but commands issued through the command system work only for vehicles which accept remote door control +bool TMoverParameters::DoorLeft(bool State, range_t const Notify ) { + + if( DoorLeftOpened == State ) { + // TBD: should the command be passed to other vehicles regardless of whether it affected the primary target? + // (for the time being no, methods are often invoked blindly which would lead to commands spam) + return false; + } + + bool result { false }; + + if( ( Battery == true ) + && ( ( State == false ) // closing door works always, but if the lock is engaged they can't be opened + || ( DoorBlockedFlag() == false ) ) ) { + DoorLeftOpened = State; - if (State == true) - { - if (CabNo > 0) - SendCtrlToNext("DoorOpen", 1, CabNo); // 1=lewe, 2=prawe - else - SendCtrlToNext("DoorOpen", 2, CabNo); // zamiana - CompressedVolume -= 0.003; - } - else - { - if (CabNo > 0) - SendCtrlToNext("DoorClose", 1, CabNo); - else - SendCtrlToNext("DoorClose", 2, CabNo); + result = true; + + if( DoorCloseCtrl == control_t::autonomous ) { + // activate or disable the door timer depending on whether door were open or closed + // NOTE: this it a local-only operation but shouldn't be an issue as automatic door are operated locally anyway + DoorLeftOpenTimer = ( + State == true ? + DoorStayOpen : + -1.0 ); } } - else - DL = false; - return DL; + if( Notify != range_t::local ) { + + SendCtrlToNext( + ( State == true ? + "DoorOpen" : + "DoorClose" ), + ( CabNo > 0 ? // 1=lewe, 2=prawe (swap if reversed) + 1 : + 2 ), + CabNo, + ( Notify == range_t::unit ? + coupling::control | coupling::permanent : + coupling::control ) ); + } + + return result; } // ************************************************************************************************* // Q: 20160713 // Otwiera / zamyka prawe drzwi // ************************************************************************************************* -bool TMoverParameters::DoorRight(bool State) -{ - bool DR = false; - if ((DoorRightOpened != State) && (DoorBlockedFlag() == false) && (Battery == true)) - { - DR = true; +// NOTE: door methods work regardless of vehicle door control type, +// but commands issued through the command system work only for vehicles which accept remote door control +bool TMoverParameters::DoorRight(bool State, range_t const Notify ) { + + if( DoorRightOpened == State ) { + // TBD: should the command be passed to other vehicles regardless of whether it affected the primary target? + // (for the time being no, methods are often invoked blindly which would lead to commands spam) + return false; + } + + bool result { false }; + + if( ( Battery == true ) + && ( ( State == false ) + || ( DoorBlockedFlag() == false ) ) ) { + DoorRightOpened = State; - if (State == true) - { - if (CabNo > 0) - SendCtrlToNext("DoorOpen", 2, CabNo); // 1=lewe, 2=prawe - else - SendCtrlToNext("DoorOpen", 1, CabNo); // zamiana - CompressedVolume -= 0.003; - } - else - { - if (CabNo > 0) - SendCtrlToNext("DoorClose", 2, CabNo); - else - SendCtrlToNext("DoorClose", 1, CabNo); + result = true; + + if( DoorCloseCtrl == control_t::autonomous ) { + // activate or disable the door timer depending on whether door were open or closed + // NOTE: this it a local-only operation but shouldn't be an issue as automatic door are operated locally anyway + DoorRightOpenTimer = ( + State == true ? + DoorStayOpen : + -1.0 ); } } - else - DR = false; + if( Notify != range_t::local ) { - return DR; + SendCtrlToNext( + ( State == true ? + "DoorOpen" : + "DoorClose" ), + ( CabNo > 0 ? // 1=lewe, 2=prawe (swap if reversed) + 2 : + 1 ), + CabNo, + ( Notify == range_t::unit ? + coupling::control | coupling::permanent : + coupling::control ) ); + } + + return result; +} + +// toggles departure warning +bool +TMoverParameters::signal_departure( bool const State, range_t const Notify ) { + + if( DepartureSignal == State ) { + // TBD: should the command be passed to other vehicles regardless of whether it affected the primary target? + return false; + } + + DepartureSignal = State; + if( Notify != range_t::local ) { + // wysłanie wyłączenia do pozostałych? + SendCtrlToNext( + "DepartureSignal", + ( State == true ? + 1 : + 0 ), + CabNo, + ( Notify == range_t::unit ? + coupling::control | coupling::permanent : + coupling::control ) ); + } + + return true; +} + +// automatic door controller update +void +TMoverParameters::update_autonomous_doors( double const Deltatime ) { + + if( DoorCloseCtrl != control_t::autonomous ) { return; } + if( ( false == DoorLeftOpened ) + && ( false == DoorRightOpened ) ) { return; } + + if( DoorStayOpen > 0.0 ) { + // update door timers if the door close after defined time + if( DoorLeftOpenTimer >= 0.0 ) { DoorLeftOpenTimer -= Deltatime; } + if( DoorRightOpenTimer >= 0.0 ) { DoorRightOpenTimer -= Deltatime; } + } + if( ( LoadStatus & ( 2 | 1 ) ) != 0 ) { + // if there's load exchange in progress, reset the timer(s) for already open doors + if( true == DoorLeftOpened ) { DoorLeftOpenTimer = DoorStayOpen; } + if( true == DoorRightOpened ) { DoorRightOpenTimer = DoorStayOpen; } + } + // the door are closed if their timer goes below 0, or if the vehicle is moving at > 10 km/h + auto const closingspeed { 10.0 }; + // NOTE: timer value of 0 is 'special' as it means the door will stay open until vehicle is moving + if( true == DoorLeftOpened ) { + if( ( ( DoorStayOpen > 0.0 ) && ( DoorLeftOpenTimer < 0.0 ) ) + || ( Vel > closingspeed ) ) { + // close the door and set the timer to expired state (closing may happen sooner if vehicle starts moving) + DoorLeft( false, range_t::local ); + } + } + if( true == DoorRightOpened ) { + if( ( ( DoorStayOpen > 0.0 ) && ( DoorRightOpenTimer < 0.0 ) ) + || ( Vel > closingspeed ) ) { + // close the door and set the timer to expired state (closing may happen sooner if vehicle starts moving) + DoorRight( false, range_t::local ); + } + } } // ************************************************************************************************* @@ -5384,54 +6917,57 @@ bool TMoverParameters::ChangeOffsetH(double DeltaOffset) // Q: 20160713 // Testuje zmienną (narazie tylko 0) i na podstawie uszkodzenia zwraca informację tekstową // ************************************************************************************************* -std::string TMoverParameters::EngineDescription(int what) +std::string TMoverParameters::EngineDescription(int what) const { - std::string outstr; - - outstr = ""; - switch (what) - { - case 0: - { - if (DamageFlag == 255) - outstr = "Totally destroyed!"; - else - { - if (TestFlag(DamageFlag, dtrain_thinwheel)) - if (Power > 0.1) - outstr = "Thin wheel,"; + std::string outstr { "OK" }; + switch (what) { + case 0: { + if( DamageFlag == 255 ) { + outstr = "WRECKED"; + } + else { + if( TestFlag( DamageFlag, dtrain_thinwheel ) ) { + if( Power > 0.1 ) + outstr = "Thin wheel"; else - outstr = "Load shifted,"; - if (TestFlag(DamageFlag, dtrain_wheelwear)) - outstr = "Wheel wear,"; - if (TestFlag(DamageFlag, dtrain_bearing)) - outstr = "Bearing damaged,"; - if (TestFlag(DamageFlag, dtrain_coupling)) - outstr = "Coupler broken,"; - if (TestFlag(DamageFlag, dtrain_loaddamage)) - if (Power > 0.1) - outstr = "Ventilator damaged,"; + outstr = "Load shifted"; + } + if( ( WheelFlat > 5.0 ) + || ( TestFlag( DamageFlag, dtrain_wheelwear ) ) ) { + outstr = "Wheel wear"; + } + if( TestFlag( DamageFlag, dtrain_bearing ) ) { + outstr = "Bearing damaged"; + } + if( TestFlag( DamageFlag, dtrain_coupling ) ) { + outstr = "Coupler broken"; + } + if( TestFlag( DamageFlag, dtrain_loaddamage ) ) { + if( Power > 0.1 ) + outstr = "Ventilator damaged"; else - outstr = "Load damaged,"; - - if (TestFlag(DamageFlag, dtrain_loaddestroyed)) - if (Power > 0.1) - outstr = "Engine damaged,"; + outstr = "Load damaged"; + } + if( TestFlag( DamageFlag, dtrain_loaddestroyed ) ) { + if( Power > 0.1 ) + outstr = "Engine damaged"; else - outstr = "Load destroyed!,"; - if (TestFlag(DamageFlag, dtrain_axle)) - outstr = "Axle broken,"; - if (TestFlag(DamageFlag, dtrain_out)) - outstr = "DERAILED!"; - if (outstr == "") - outstr = "OK!"; + outstr = "LOAD DESTROYED"; + } + if( TestFlag( DamageFlag, dtrain_axle ) ) { + outstr = "Axle broken"; + } + if( TestFlag( DamageFlag, dtrain_out ) ) { + outstr = "DERAILED"; + } } break; } - default: + default: { outstr = "Invalid qualifier"; break; } + } return outstr; } @@ -5441,7 +6977,30 @@ std::string TMoverParameters::EngineDescription(int what) // ************************************************************************************************* double TMoverParameters::GetTrainsetVoltage(void) {//ABu: funkcja zwracajaca napiecie dla calego skladu, przydatna dla EZT - return Max0R(HVCouplers[1][1], HVCouplers[0][1]); +#ifdef EU07_USE_OLD_HVCOUPLERS + return std::max( + HVCouplers[ side::front ][ hvcoupler::voltage ], + HVCouplers[ side::rear ][ hvcoupler::voltage ] ); +#else +/* + return std::max( + Couplers[ side::front ].power_high.voltage, + Couplers[ side::rear ].power_high.voltage ); +*/ + return std::max( + ( ( ( Couplers[side::front].Connected ) + && ( ( Couplers[ side::front ].CouplingFlag & ctrain_power ) + || ( ( Heating ) + && ( Couplers[ side::front ].CouplingFlag & ctrain_heating ) ) ) ) ? + Couplers[side::front].Connected->Couplers[ Couplers[side::front].ConnectedNr ].power_high.voltage : + 0.0 ), + ( ( ( Couplers[side::rear].Connected ) + && ( ( Couplers[ side::rear ].CouplingFlag & ctrain_power ) + || ( ( Heating ) + && ( Couplers[ side::rear ].CouplingFlag & ctrain_heating ) ) ) ) ? + Couplers[ side::rear ].Connected->Couplers[ Couplers[ side::rear ].ConnectedNr ].power_high.voltage : + 0.0 ) ); +#endif } // ************************************************************************************************* @@ -5463,53 +7022,18 @@ bool TMoverParameters::Physic_ReActivation(void) // DO PRZETLUMACZENIA NA KONCU // ************************************************************************************************* // FUNKCJE PARSERA WCZYTYWANIA PLIKU FIZYKI POJAZDU // ************************************************************************************************* -std::string p0, p1, p2, p3, p4, p5, p6, p7; -std::string vS; -int vI; -double vD; bool startBPT; bool startMPT, startMPT0; bool startRLIST; bool startDLIST, startFFLIST, startWWLIST; bool startLIGHTSLIST; int LISTLINE; -std::vector x; -// ************************************************************************************************* -// Q: 20160717 -// ************************************************************************************************* -int Pos(std::string str_find, std::string in) -{ - size_t pos = in.find(str_find); - return (pos != std::string::npos ? pos+1 : 0); -} -/* -// ************************************************************************************************* -// Q: 20160717 -// ************************************************************************************************* -bool issection(std::string const &name) -{ - sectionname = name; - if (xline.compare(0, name.size(), name) == 0) - { - lastsectionname = name; - return true; - } - else - return false; -} -*/ bool issection( std::string const &Name, std::string const &Input ) { return ( Input.compare( 0, Name.size(), Name ) == 0 ); } -int MARKERROR(int code, std::string type, std::string msg) -{ - WriteLog(msg); - return code; -} - int s2NPW(std::string s) { // wylicza ilosc osi napednych z opisu ukladu osi const char A = 64; @@ -5571,10 +7095,10 @@ bool TMoverParameters::readMPT( std::string const &line ) { switch( EngineType ) { - case ElectricSeriesMotor: { return readMPTElectricSeries( line ); } - case DieselElectric: { return readMPTDieselElectric( line ); } - case DieselEngine: { return readMPTDieselEngine( line ); } - default: { return false; } + case TEngineType::ElectricSeriesMotor: { return readMPTElectricSeries( line ); } + case TEngineType::DieselElectric: { return readMPTDieselElectric( line ); } + case TEngineType::DieselEngine: { return readMPTDieselEngine( line ); } + default: { return false; } } } @@ -5662,9 +7186,9 @@ bool TMoverParameters::readBPT( std::string const &line ) { >> BrakePressureTable[ idx ].BrakePressureVal >> BrakePressureTable[ idx ].FlowSpeedVal >> braketype; - if( braketype == "Pneumatic" ) { BrakePressureTable[ idx ].BrakeType = Pneumatic; } - else if( braketype == "ElectroPneumatic" ) { BrakePressureTable[ idx ].BrakeType = ElectroPneumatic; } - else { BrakePressureTable[ idx ].BrakeType = Individual; } + if( braketype == "Pneumatic" ) { BrakePressureTable[ idx ].BrakeType = TBrakeSystem::Pneumatic; } + else if( braketype == "ElectroPneumatic" ) { BrakePressureTable[ idx ].BrakeType = TBrakeSystem::ElectroPneumatic; } + else { BrakePressureTable[ idx ].BrakeType = TBrakeSystem::Individual; } return true; } @@ -5678,7 +7202,7 @@ bool TMoverParameters::readRList( std::string const &Input ) { return false; } auto idx = LISTLINE++; - if( idx >= sizeof( RList ) ) { + if( idx >= sizeof( RList ) / sizeof( TScheme ) ) { WriteLog( "Read RList: number of entries exceeded capacity of the data table" ); return false; } @@ -5700,7 +7224,7 @@ bool TMoverParameters::readDList( std::string const &line ) { cParser parser( line ); parser.getTokens( 3, false ); auto idx = LISTLINE++; - if( idx >= sizeof( RList ) ) { + if( idx >= sizeof( RList ) / sizeof( TScheme ) ) { WriteLog( "Read DList: number of entries exceeded capacity of the data table" ); return false; } @@ -5720,7 +7244,7 @@ bool TMoverParameters::readFFList( std::string const &line ) { return false; } int idx = LISTLINE++; - if( idx >= sizeof( DElist ) ) { + if( idx >= sizeof( DElist ) / sizeof( TDEScheme ) ) { WriteLog( "Read FList: number of entries exceeded capacity of the data table" ); return false; } @@ -5740,7 +7264,7 @@ bool TMoverParameters::readWWList( std::string const &line ) { return false; } int idx = LISTLINE++; - if( idx >= sizeof( DElist ) ) { + if( idx >= sizeof( DElist ) / sizeof( TDEScheme ) ) { WriteLog( "Read WWList: number of entries exceeded capacity of the data table" ); return false; } @@ -5788,46 +7312,46 @@ bool TMoverParameters::readLightsList( std::string const &Input ) { // ************************************************************************************************* void TMoverParameters::BrakeValveDecode( std::string const &Valve ) { - std::map valvetypes{ - { "W", W }, - { "W_Lu_L", W_Lu_L }, - { "W_Lu_XR", W_Lu_XR }, - { "W_Lu_VI", W_Lu_VI }, - { "K", K }, - { "Kg", Kg }, - { "Kp", Kp }, - { "Kss", Kss }, - { "Kkg", Kkg }, - { "Kkp", Kkp }, - { "Kks", Kks }, - { "Hikp1", Hikp1 }, - { "Hikss", Hikss }, - { "Hikg1", Hikg1 }, - { "KE", KE }, - { "SW", SW }, - { "EStED", EStED }, - { "NESt3", NESt3 }, - { "ESt3", ESt3 }, - { "LSt", LSt }, - { "ESt4", ESt4 }, - { "ESt3AL2", ESt3AL2 }, - { "EP1", EP1 }, - { "EP2", EP2 }, - { "M483", M483 }, - { "CV1_L_TR", CV1_L_TR }, - { "CV1", CV1 }, - { "CV1_R", CV1_R } + std::map valvetypes { + { "W", TBrakeValve::W }, + { "W_Lu_L", TBrakeValve::W_Lu_L }, + { "W_Lu_XR", TBrakeValve::W_Lu_XR }, + { "W_Lu_VI", TBrakeValve::W_Lu_VI }, + { "K", TBrakeValve::K }, + { "Kg", TBrakeValve::Kg }, + { "Kp", TBrakeValve::Kp }, + { "Kss", TBrakeValve::Kss }, + { "Kkg", TBrakeValve::Kkg }, + { "Kkp", TBrakeValve::Kkp }, + { "Kks", TBrakeValve::Kks }, + { "Hikp1", TBrakeValve::Hikp1 }, + { "Hikss", TBrakeValve::Hikss }, + { "Hikg1", TBrakeValve::Hikg1 }, + { "KE", TBrakeValve::KE }, + { "SW", TBrakeValve::SW }, + { "EStED", TBrakeValve::EStED }, + { "NESt3", TBrakeValve::NESt3 }, + { "ESt3", TBrakeValve::ESt3 }, + { "LSt", TBrakeValve::LSt }, + { "ESt4", TBrakeValve::ESt4 }, + { "ESt3AL2", TBrakeValve::ESt3AL2 }, + { "EP1", TBrakeValve::EP1 }, + { "EP2", TBrakeValve::EP2 }, + { "M483", TBrakeValve::M483 }, + { "CV1_L_TR", TBrakeValve::CV1_L_TR }, + { "CV1", TBrakeValve::CV1 }, + { "CV1_R", TBrakeValve::CV1_R } }; auto lookup = valvetypes.find( Valve ); BrakeValve = lookup != valvetypes.end() ? lookup->second : - Other; + TBrakeValve::Other; - if( ( BrakeValve == Other ) + if( ( BrakeValve == TBrakeValve::Other ) && ( Valve.find( "ESt" ) != std::string::npos ) ) { - BrakeValve = ESt3; + BrakeValve = TBrakeValve::ESt3; } } @@ -5836,32 +7360,32 @@ void TMoverParameters::BrakeValveDecode( std::string const &Valve ) { // ************************************************************************************************* void TMoverParameters::BrakeSubsystemDecode() { - BrakeSubsystem = ss_None; + BrakeSubsystem = TBrakeSubSystem::ss_None; switch (BrakeValve) { - case W: - case W_Lu_L: - case W_Lu_VI: - case W_Lu_XR: - BrakeSubsystem = ss_W; + case TBrakeValve::W: + case TBrakeValve::W_Lu_L: + case TBrakeValve::W_Lu_VI: + case TBrakeValve::W_Lu_XR: + BrakeSubsystem = TBrakeSubSystem::ss_W; break; - case ESt3: - case ESt3AL2: - case ESt4: - case EP2: - case EP1: - BrakeSubsystem = ss_ESt; + case TBrakeValve::ESt3: + case TBrakeValve::ESt3AL2: + case TBrakeValve::ESt4: + case TBrakeValve::EP2: + case TBrakeValve::EP1: + BrakeSubsystem = TBrakeSubSystem::ss_ESt; break; - case KE: - BrakeSubsystem = ss_KE; + case TBrakeValve::KE: + BrakeSubsystem = TBrakeSubSystem::ss_KE; break; - case CV1: - case CV1_L_TR: - BrakeSubsystem = ss_Dako; + case TBrakeValve::CV1: + case TBrakeValve::CV1_L_TR: + BrakeSubsystem = TBrakeSubSystem::ss_Dako; break; - case LSt: - case EStED: - BrakeSubsystem = ss_LSt; + case TBrakeValve::LSt: + case TBrakeValve::EStED: + BrakeSubsystem = TBrakeSubSystem::ss_LSt; break; } } @@ -5914,10 +7438,15 @@ bool TMoverParameters::LoadFIZ(std::string chkpath) continue; } + if( inputline[ 0 ] == ' ' ) { + // guard against malformed config files with leading spaces + inputline.erase( 0, inputline.find_first_not_of( ' ' ) ); + } if( inputline.length() == 0 ) { startBPT = false; continue; } + // checking if table parsing should be switched off goes first... if( issection( "END-MPT", inputline ) ) { startBPT = false; @@ -6039,6 +7568,14 @@ bool TMoverParameters::LoadFIZ(std::string chkpath) continue; } + if (issection("Blending:", inputline)) { + + startBPT = true; LISTLINE = 0; + fizlines.emplace( "Blending", inputline); + LoadFIZ_Blending( inputline ); + continue; + } + if( issection( "Light:", inputline ) ) { startBPT = false; @@ -6129,7 +7666,8 @@ bool TMoverParameters::LoadFIZ(std::string chkpath) if( issection( "ffList:", inputline ) ) { startBPT = false; startFFLIST = true; LISTLINE = 0; - continue; + LoadFIZ_FFList( inputline ); + continue; } if( issection( "WWList:", inputline ) ) @@ -6230,6 +7768,7 @@ void TMoverParameters::LoadFIZ_Param( std::string const &line ) { std::map types{ { "pseudodiesel", dt_PseudoDiesel }, { "ezt", dt_EZT }, + { "dmu", dt_DMU }, { "sn61", dt_SN61 }, { "et22", dt_ET22 }, { "et40", dt_ET40 }, @@ -6257,11 +7796,24 @@ void TMoverParameters::LoadFIZ_Param( std::string const &line ) { void TMoverParameters::LoadFIZ_Load( std::string const &line ) { - extract_value( LoadAccepted, "LoadAccepted", line, "" ); - if( true == LoadAccepted.empty() ) { - return; + auto const acceptedloads { Split( extract_value( "LoadAccepted", line ), ',' ) }; + + if( acceptedloads.empty() ) { return; } + + auto const minoffsets { Split( extract_value( "LoadMinOffset", line ), ',' ) }; + auto minoffset { 0.f }; + auto minoffsetsiterator { std::begin( minoffsets ) }; + // NOTE: last (if any) offset parameter retrieved from the list applies to the remainder of the list + // TBD, TODO: include other load parameters in this system + for( auto &load : acceptedloads ) { + if( minoffsetsiterator != std::end( minoffsets ) ) { + minoffset = std::stof( *minoffsetsiterator ); + ++minoffsetsiterator; + } + LoadAttributes.emplace_back( + ToLower( load ), + minoffset ); } - LoadAccepted = ToLower( LoadAccepted ); extract_value( MaxLoad, "MaxLoad", line, "" ); extract_value( LoadQuantity, "LoadQ", line, "" ); @@ -6275,6 +7827,7 @@ void TMoverParameters::LoadFIZ_Dimensions( std::string const &line ) { extract_value( Dim.L, "L", line, "" ); extract_value( Dim.H, "H", line, "" ); extract_value( Dim.W, "W", line, "" ); + extract_value( Cx, "Cx", line, "0.3" ); if( Dim.H <= 2.0 ) { //gdyby nie było parametru, lepsze to niż zero @@ -6297,7 +7850,6 @@ void TMoverParameters::LoadFIZ_Wheels( std::string const &line ) { extract_value( TrackW, "Tw", line, "" ); extract_value( AxleInertialMoment, "AIM", line, "" ); - if( AxleInertialMoment <= 0.0 ) { AxleInertialMoment = 1.0; } extract_value( AxleArangement, "Axle", line, "" ); NPoweredAxles = s2NPW( AxleArangement ); @@ -6305,16 +7857,27 @@ void TMoverParameters::LoadFIZ_Wheels( std::string const &line ) { BearingType = ( extract_value( "BearingType", line ) == "Roll" ) ? - 1 : - 0; + 1 : + 0; extract_value( ADist, "Ad", line, "" ); extract_value( BDist, "Bd", line, "" ); + + if( AxleInertialMoment <= 0.0 ) { +/* + AxleInertialMoment = 1.0; +*/ + // approximation formula by youby + auto const k = 472.0; // arbitrary constant + AxleInertialMoment = k / 4.0 * std::pow( WheelDiameter, 4.0 ) * NAxles; + Mred = k * std::pow( WheelDiameter, 2.0 ) * NAxles; + } } void TMoverParameters::LoadFIZ_Brake( std::string const &line ) { - BrakeValveDecode( extract_value( "BrakeValve", line ) ); + extract_value( BrakeValveParams, "BrakeValve", line, "" ); + BrakeValveDecode( BrakeValveParams ); BrakeSubsystemDecode(); extract_value( NBpA, "NBpA", line, "" ); @@ -6374,6 +7937,7 @@ void TMoverParameters::LoadFIZ_Brake( std::string const &line ) { } extract_value( RapidMult, "RM", line, "1" ); + extract_value( RapidVel, "RV", line, "55" ); } } else { @@ -6389,62 +7953,83 @@ void TMoverParameters::LoadFIZ_Brake( std::string const &line ) { DeltaPipePress = HighPipePress - LowPipePress; extract_value( VeselVolume, "Vv", line, "" ); +/* if( VeselVolume == 0.0 ) { VeselVolume = 0.01; } - +*/ extract_value( MinCompressor, "MinCP", line, "" ); extract_value( MaxCompressor, "MaxCP", line, "" ); extract_value( CompressorSpeed, "CompressorSpeed", line, "" ); { std::map compressorpowers{ + { "Main", 0 }, + // 1: default, powered by converter, with manual state control { "Converter", 2 }, - { "Engine", 3 }, + { "Engine", 3 }, // equivalent of 0, TODO: separate 'main' and 'engine' in the code { "Coupler1", 4 },//włączana w silnikowym EZT z przodu - { "Coupler2", 5 },//włączana w silnikowym EZT z tyłu - { "Main", 0 } + { "Coupler2", 5 } //włączana w silnikowym EZT z tyłu }; auto lookup = compressorpowers.find( extract_value( "CompressorPower", line ) ); CompressorPower = lookup != compressorpowers.end() ? - lookup->second : - 1; + lookup->second : + 1; + } + + if( true == extract_value( AirLeakRate, "AirLeakRate", line, "" ) ) { + // the parameter is provided in form of a multiplier, where 1.0 means the default rate of 0.01 + AirLeakRate *= 0.01; } } void TMoverParameters::LoadFIZ_Doors( std::string const &line ) { - DoorOpenCtrl = 0; - std::string openctrl; extract_value( openctrl, "OpenCtrl", line, "" ); - if( openctrl == "DriverCtrl" ) { DoorOpenCtrl = 1; } - - DoorCloseCtrl = 0; - std::string closectrl; extract_value( closectrl, "CloseCtrl", line, "" ); - if( closectrl == "DriverCtrl" ) { DoorCloseCtrl = 1; } - else if( closectrl == "AutomaticCtrl" ) { DoorCloseCtrl = 2; } - - if( DoorCloseCtrl == 2 ) { extract_value( DoorStayOpen, "DoorStayOpen", line, "" ); } + std::map doorcontrols { + { "Passenger", control_t::passenger }, + { "AutomaticCtrl", control_t::autonomous }, + { "DriverCtrl", control_t::driver }, + { "Conductor", control_t::conductor }, + { "Mixed", control_t::mixed } + }; + // opening method + { + auto lookup = doorcontrols.find( extract_value( "OpenCtrl", line ) ); + DoorOpenCtrl = + lookup != doorcontrols.end() ? + lookup->second : + control_t::passenger; + } + // closing method + { + auto lookup = doorcontrols.find( extract_value( "CloseCtrl", line ) ); + DoorCloseCtrl = + lookup != doorcontrols.end() ? + lookup->second : + control_t::passenger; + } + // automatic closing timer + if( DoorCloseCtrl == control_t::autonomous ) { extract_value( DoorStayOpen, "DoorStayOpen", line, "" ); } extract_value( DoorOpenSpeed, "OpenSpeed", line, "" ); extract_value( DoorCloseSpeed, "CloseSpeed", line, "" ); + extract_value( DoorCloseDelay, "DoorCloseDelay", line, "" ); extract_value( DoorMaxShiftL, "DoorMaxShiftL", line, "" ); extract_value( DoorMaxShiftR, "DoorMaxShiftR", line, "" ); + extract_value( DoorMaxPlugShift, "DoorMaxShiftPlug", line, "" ); - DoorOpenMethod = 2; //obrót, default std::string openmethod; extract_value( openmethod, "DoorOpenMethod", line, "" ); if( openmethod == "Shift" ) { DoorOpenMethod = 1; } //przesuw else if( openmethod == "Fold" ) { DoorOpenMethod = 3; } //3 submodele się obracają else if( openmethod == "Plug" ) { DoorOpenMethod = 4; } //odskokowo-przesuwne - std::string closurewarning; extract_value( closurewarning, "DoorClosureWarning", line, "" ); - DoorClosureWarning = ( closurewarning == "Yes" ); + extract_value( DoorClosureWarning, "DoorClosureWarning", line, "" ); + extract_value( DoorClosureWarningAuto, "DoorClosureWarningAuto", line, "" ); + extract_value( DoorBlocked, "DoorBlocked", line, "" ); - std::string doorblocked; extract_value( doorblocked, "DoorBlocked", line, "" ); - DoorBlocked = ( doorblocked == "Yes" ); - - extract_value( DoorMaxPlugShift, "DoorMaxShiftPlug", line, "" ); extract_value( PlatformSpeed, "PlatformSpeed", line, "" ); - extract_value( PlatformMaxShift, "PlatformMaxSpeed", line, "" ); + extract_value( PlatformMaxShift, "PlatformMaxShift", line, "" ); + + extract_value( MirrorMaxShift, "MirrorMaxShift", line, "" ); - PlatformOpenMethod = 2; // obrót, default std::string platformopenmethod; extract_value( platformopenmethod, "PlatformOpenMethod", line, "" ); if( platformopenmethod == "Shift" ) { PlatformOpenMethod = 1; } // przesuw } @@ -6456,17 +8041,17 @@ void TMoverParameters::LoadFIZ_BuffCoupl( std::string const &line, int const Ind else { coupler = &Couplers[ 0 ]; } std::map couplertypes { - { "Automatic", Automatic }, - { "Screw", Screw }, - { "Chain", Chain }, - { "Bare", Bare }, - { "Articulated", Articulated }, + { "Automatic", TCouplerType::Automatic }, + { "Screw", TCouplerType::Screw }, + { "Chain", TCouplerType::Chain }, + { "Bare", TCouplerType::Bare }, + { "Articulated", TCouplerType::Articulated }, }; auto lookup = couplertypes.find( extract_value( "CType", line ) ); coupler->CouplerType = ( lookup != couplertypes.end() ? lookup->second : - NoCoupler ); + TCouplerType::NoCoupler ); extract_value( coupler->SpringKC, "kC", line, "" ); extract_value( coupler->DmaxC, "DmaxC", line, "" ); @@ -6482,16 +8067,16 @@ void TMoverParameters::LoadFIZ_BuffCoupl( std::string const &line, int const Ind coupler->AllowedFlag = ( ( -coupler->AllowedFlag ) | ctrain_depot ); } - if( ( coupler->CouplerType != NoCoupler ) - && ( coupler->CouplerType != Bare ) - && ( coupler->CouplerType != Articulated ) ) { + if( ( coupler->CouplerType != TCouplerType::NoCoupler ) + && ( coupler->CouplerType != TCouplerType::Bare ) + && ( coupler->CouplerType != TCouplerType::Articulated ) ) { coupler->SpringKC *= 1000; coupler->FmaxC *= 1000; coupler->SpringKB *= 1000; coupler->FmaxB *= 1000; } - else if( coupler->CouplerType == Bare ) { + else if( coupler->CouplerType == TCouplerType::Bare ) { coupler->SpringKC = 50.0 * Mass + Ftmax / 0.05; coupler->DmaxC = 0.05; @@ -6501,7 +8086,7 @@ void TMoverParameters::LoadFIZ_BuffCoupl( std::string const &line, int const Ind coupler->FmaxB = 50.0 * Mass + 2.0 * Ftmax; coupler->beta = 0.3; } - else if( coupler->CouplerType == Articulated ) { + else if( coupler->CouplerType == TCouplerType::Articulated ) { coupler->SpringKC = 60.0 * Mass + 1000; coupler->DmaxC = 0.05; @@ -6527,16 +8112,16 @@ void TMoverParameters::LoadFIZ_Cntrl( std::string const &line ) { { std::map brakesystems{ - { "Pneumatic", Pneumatic }, - { "ElectroPneumatic", ElectroPneumatic } + { "Pneumatic", TBrakeSystem::Pneumatic }, + { "ElectroPneumatic", TBrakeSystem::ElectroPneumatic } }; auto lookup = brakesystems.find( extract_value( "BrakeSystem", line ) ); BrakeSystem = lookup != brakesystems.end() ? lookup->second : - Individual; + TBrakeSystem::Individual; } - if( BrakeSystem != Individual ) { + if( BrakeSystem != TBrakeSystem::Individual ) { extract_value( BrakeCtrlPosNo, "BCPN", line, "" ); for( int idx = 0; idx < 4; ++idx ) { @@ -6545,7 +8130,7 @@ void TMoverParameters::LoadFIZ_Cntrl( std::string const &line ) { } // brakedelays, brakedelayflag { - std::map brakedelays{ + std::map brakedelays { { "GPR", bdelay_G + bdelay_P + bdelay_R }, { "PR", bdelay_P + bdelay_R }, { "GP", bdelay_G + bdelay_P }, @@ -6555,7 +8140,7 @@ void TMoverParameters::LoadFIZ_Cntrl( std::string const &line ) { { "GPR+Mg", bdelay_G + bdelay_P + bdelay_R + bdelay_M }, { "PR+Mg", bdelay_P + bdelay_R + bdelay_M } }; - std::map brakedelayflags{ + std::map brakedelayflags { { "R", bdelay_R }, { "P", bdelay_P }, { "G", bdelay_G } @@ -6566,7 +8151,7 @@ void TMoverParameters::LoadFIZ_Cntrl( std::string const &line ) { BrakeDelays = lookup != brakedelays.end() ? lookup->second : - Individual; + 0; lookup = brakedelayflags.find( brakedelay ); BrakeDelayFlag = lookup != brakedelayflags.end() ? @@ -6588,39 +8173,42 @@ void TMoverParameters::LoadFIZ_Cntrl( std::string const &line ) { // brakehandle { std::map brakehandles{ - { "FV4a", FV4a }, - { "test", testH }, - { "D2", D2 }, - { "MHZ_EN57", MHZ_EN57 }, - { "M394", M394 }, - { "Knorr", Knorr }, - { "Westinghouse", West }, - { "FVel6", FVel6 }, - { "St113", St113 } + { "FV4a", TBrakeHandle::FV4a }, + { "test", TBrakeHandle::testH }, + { "D2", TBrakeHandle::D2 }, + { "MHZ_EN57", TBrakeHandle::MHZ_EN57 }, + { "MHZ_K5P", TBrakeHandle::MHZ_K5P }, + { "M394", TBrakeHandle::M394 }, + { "Knorr", TBrakeHandle::Knorr }, + { "Westinghouse", TBrakeHandle::West }, + { "FVel6", TBrakeHandle::FVel6 }, + { "St113", TBrakeHandle::St113 } }; auto lookup = brakehandles.find( extract_value( "BrakeHandle", line ) ); BrakeHandle = lookup != brakehandles.end() ? lookup->second : - NoHandle; + TBrakeHandle::NoHandle; } // brakelochandle { std::map locbrakehandles{ - { "FD1", FD1 }, - { "Knorr", Knorr }, - { "Westinghouse", West } + { "FD1", TBrakeHandle::FD1 }, + { "Knorr", TBrakeHandle::Knorr }, + { "Westinghouse", TBrakeHandle::West } }; auto lookup = locbrakehandles.find( extract_value( "LocBrakeHandle", line ) ); BrakeLocHandle = lookup != locbrakehandles.end() ? lookup->second : - NoHandle; + TBrakeHandle::NoHandle; } // mbpm - extract_value( MBPM, "MaxBPMass", line, "" ); -// MBPM *= 1000; + if( true == extract_value( MBPM, "MaxBPMass", line, "" ) ) { + // NOTE: only convert the value from tons to kilograms if the entry is present in the config file + MBPM *= 1000.0; + } // asbtype std::string asb; @@ -6629,6 +8217,7 @@ void TMoverParameters::LoadFIZ_Cntrl( std::string const &line ) { if( asb == "Manual" ) { ASBType = 1; } else if( asb == "Automatic" ) { ASBType = 2; } + else if (asb == "Yes") { ASBType = 128; } } else { @@ -6639,15 +8228,15 @@ void TMoverParameters::LoadFIZ_Cntrl( std::string const &line ) { // localbrake { std::map localbrakes{ - { "ManualBrake", ManualBrake }, - { "PneumaticBrake", PneumaticBrake }, - { "HydraulicBrake", HydraulicBrake } + { "ManualBrake", TLocalBrake::ManualBrake }, + { "PneumaticBrake", TLocalBrake::PneumaticBrake }, + { "HydraulicBrake", TLocalBrake::HydraulicBrake } }; auto lookup = localbrakes.find( extract_value( "LocalBrake", line ) ); LocalBrake = lookup != localbrakes.end() ? lookup->second : - NoBrake; + TLocalBrake::NoBrake; } // mbrake MBrake = ( extract_value( "ManualBrake", line ) == "Yes" ); @@ -6664,6 +8253,7 @@ void TMoverParameters::LoadFIZ_Cntrl( std::string const &line ) { lookup != dynamicbrakes.end() ? lookup->second : dbrake_none; + extract_value(DynamicBrakeAmpmeters, "DBAM", line, ""); } extract_value( MainCtrlPosNo, "MCPN", line, "" ); @@ -6676,9 +8266,9 @@ void TMoverParameters::LoadFIZ_Cntrl( std::string const &line ) { else if( autorelay == "Yes" ) { AutoRelayType = 1; } else { AutoRelayType = 0; } - CoupledCtrl = ( extract_value( "CoupledCtrl", line ) == "Yes" ); + extract_value( CoupledCtrl, "CoupledCtrl", line, "" ); - ScndS = ( extract_value( "ScndS", line ) == "Yes" ); // brak pozycji rownoleglej przy niskiej nastawie PSR + extract_value( ScndS, "ScndS", line, "" ); // brak pozycji rownoleglej przy niskiej nastawie PSR extract_value( InitialCtrlDelay, "IniCDelay", line, "" ); extract_value( CtrlDelay, "SCDelay", line, "" ); @@ -6692,8 +8282,84 @@ void TMoverParameters::LoadFIZ_Cntrl( std::string const &line ) { 0; extract_value( StopBrakeDecc, "SBD", line, "" ); + + // speed control + extract_value( SpeedCtrlDelay, "SpeedCtrlDelay", line, "" ); + + // converter + { + std::map starts { + { "Manual", start_t::manual }, + { "Automatic", start_t::automatic } + }; + auto lookup = starts.find( extract_value( "ConverterStart", line ) ); + ConverterStart = + lookup != starts.end() ? + lookup->second : + start_t::manual; + } + extract_value( ConverterStartDelay, "ConverterStartDelay", line, "" ); + + // devices + std::map starts { + { "Manual", start_t::manual }, + { "Automatic", start_t::automatic }, + { "Mixed", start_t::manualwithautofallback }, + { "Battery", start_t::battery }, + { "Converter", start_t::converter } }; + // compressor + { + auto lookup = starts.find( extract_value( "CompressorStart", line ) ); + CompressorStart = + lookup != starts.end() ? + lookup->second : + start_t::manual; + } + // fuel pump + { + auto lookup = starts.find( extract_value( "FuelStart", line ) ); + FuelPump.start_type = + lookup != starts.end() ? + lookup->second : + start_t::manual; + } + // oil pump + { + auto lookup = starts.find( extract_value( "OilStart", line ) ); + OilPump.start_type = + lookup != starts.end() ? + lookup->second : + start_t::manual; + } + // water pump + { + auto lookup = starts.find( extract_value( "WaterStart", line ) ); + WaterPump.start_type = + lookup != starts.end() ? + lookup->second : + start_t::manual; + } + // traction motor fans + { + auto lookup = starts.find( extract_value( "MotorBlowersStart", line ) ); + MotorBlowers[side::front].start_type = + MotorBlowers[side::rear].start_type = + lookup != starts.end() ? + lookup->second : + start_t::manual; + } } +void TMoverParameters::LoadFIZ_Blending(std::string const &line) { + + extract_value(MED_Vmax, "MED_Vmax", line, to_string(Vmax)); + extract_value(MED_Vmin, "MED_Vmin", line, "0"); + extract_value(MED_Vref, "MED_Vref", line, to_string(Vmax)); + extract_value(MED_amax, "MED_amax", line, "9.81"); + extract_value(MED_EPVC, "MED_EPVC", line, ""); + extract_value(MED_Ncor, "MED_Ncor", line, ""); + +} void TMoverParameters::LoadFIZ_Light( std::string const &line ) { LightPowerSource.SourceType = LoadFIZ_SourceDecode( extract_value( "Light", line ) ); @@ -6722,7 +8388,7 @@ void TMoverParameters::LoadFIZ_Security( std::string const &line ) { extract_value( SecuritySystem.AwareMinSpeed, "AwareMinSpeed", line, "" ); extract_value( SecuritySystem.SoundSignalDelay, "SoundSignalDelay", line, "" ); extract_value( SecuritySystem.EmergencyBrakeDelay, "EmergencyBrakeDelay", line, "" ); - SecuritySystem.RadioStop = ( extract_value( "RadioStop", line ).find( "Yes" ) != std::string::npos ); + extract_value( SecuritySystem.RadioStop, "RadioStop", line, "" ); } void TMoverParameters::LoadFIZ_Clima( std::string const &line ) { @@ -6738,14 +8404,14 @@ void TMoverParameters::LoadFIZ_Power( std::string const &Line ) { EnginePowerSource.SourceType = LoadFIZ_SourceDecode( extract_value( "EnginePower", Line ) ); LoadFIZ_PowerParamsDecode( EnginePowerSource, "", Line ); - if( ( EnginePowerSource.SourceType == Generator ) - && ( EnginePowerSource.GeneratorEngine == WheelsDriven ) ) { + if( ( EnginePowerSource.SourceType == TPowerSource::Generator ) + && ( EnginePowerSource.GeneratorEngine == TEngineType::WheelsDriven ) ) { // perpetuum mobile? ConversionError = 666; } if( Power == 0.0 ) { //jeśli nie ma mocy, np. rozrządcze EZT - EnginePowerSource.SourceType = NotDefined; + EnginePowerSource.SourceType = TPowerSource::NotDefined; } SystemPowerSource.SourceType = LoadFIZ_SourceDecode( extract_value( "SystemPower", Line ) ); @@ -6776,7 +8442,7 @@ void TMoverParameters::LoadFIZ_Engine( std::string const &Input ) { switch( EngineType ) { - case ElectricSeriesMotor: { + case TEngineType::ElectricSeriesMotor: { extract_value( NominalVoltage, "Volt", Input, "" ); extract_value( WindingRes, "WindingRes", Input, "" ); @@ -6788,22 +8454,25 @@ void TMoverParameters::LoadFIZ_Engine( std::string const &Input ) { nmax /= 60.0; break; } - case WheelsDriven: - case Dumb: { + case TEngineType::WheelsDriven: + case TEngineType::Dumb: { extract_value( Ftmax, "Ftmax", Input, "" ); break; } - case DieselEngine: { + case TEngineType::DieselEngine: { extract_value( dizel_nmin, "nmin", Input, "" ); dizel_nmin /= 60.0; - extract_value( dizel_nmax, "nmax", Input, "" ); - dizel_nmax /= 60.0; - nmax = dizel_nmax; // not sure if this is needed, but just in case + // TODO: unify naming scheme and sort out which diesel engine params are used where and how + extract_value( nmax, "nmax", Input, "" ); + nmax /= 60.0; extract_value( dizel_nmax_cutoff, "nmax_cutoff", Input, "0.0" ); dizel_nmax_cutoff /= 60.0; extract_value( dizel_AIM, "AIM", Input, "1.0" ); + + extract_value(engageupspeed, "EUS", Input, "0.5"); + extract_value(engagedownspeed, "EDS", Input, "0.9"); if( true == extract_value( AnPos, "ShuntMode", Input, "" ) ) { //dodatkowa przekładnia dla SM03 (2Ls150) @@ -6813,10 +8482,37 @@ void TMoverParameters::LoadFIZ_Engine( std::string const &Input ) { //"rozruch wysoki" ma dawać większą siłę AnPos = 1.0 / AnPos; //im większa liczba, tym wolniej jedzie } + } + extract_value(hydro_TC, "IsTC", Input, ""); + if (true == hydro_TC) { + extract_value(hydro_TC_TMMax, "TC_TMMax", Input, ""); + extract_value(hydro_TC_CouplingPoint, "TC_CP", Input, ""); + extract_value(hydro_TC_LockupTorque, "TC_LT", Input, ""); + extract_value(hydro_TC_LockupRate, "TC_LR", Input, ""); + extract_value(hydro_TC_UnlockRate, "TC_ULR", Input, ""); + extract_value(hydro_TC_FillRateInc, "TC_FRI", Input, ""); + extract_value(hydro_TC_FillRateDec, "TC_FRD", Input, ""); + extract_value(hydro_TC_TorqueInIn, "TC_TII", Input, ""); + extract_value(hydro_TC_TorqueInOut, "TC_TIO", Input, ""); + extract_value(hydro_TC_TorqueOutOut, "TC_TOO", Input, ""); + extract_value(hydro_TC_LockupSpeed, "TC_LS", Input, ""); + extract_value(hydro_TC_UnlockSpeed, "TC_ULS", Input, ""); + + extract_value(hydro_R, "IsRetarder", Input, ""); + if (true == hydro_R) { + extract_value(hydro_R_Placement, "R_Place", Input, ""); + extract_value(hydro_R_TorqueInIn, "R_TII", Input, ""); + extract_value(hydro_R_MaxTorque, "R_MT", Input, ""); + extract_value(hydro_R_MaxPower, "R_MP", Input, ""); + extract_value(hydro_R_FillRateInc, "R_FRI", Input, ""); + extract_value(hydro_R_FillRateDec, "R_FRD", Input, ""); + extract_value(hydro_R_MinVel, "R_MinVel", Input, ""); + } + } break; } - case DieselElectric: { //youBy + case TEngineType::DieselElectric: { //youBy extract_value( Ftmax, "Ftmax", Input, "" ); Flat = ( extract_value( "Flat", Input ) == "1" ); @@ -6834,9 +8530,10 @@ void TMoverParameters::LoadFIZ_Engine( std::string const &Input ) { ImaxHi = 2; ImaxLo = 1; } + extract_value( EngineHeatingRPM, "HeatingRPM", Input, "" ); break; } - case ElectricInductionMotor: { + case TEngineType::ElectricInductionMotor: { RVentnmax = 1.0; extract_value( NominalVoltage, "Volt", Input, "" ); @@ -6862,28 +8559,69 @@ void TMoverParameters::LoadFIZ_Engine( std::string const &Input ) { extract_value( eimc[ eimc_p_Imax ], "Imax", Input, "" ); extract_value( eimc[ eimc_p_abed ], "abed", Input, "" ); extract_value( eimc[ eimc_p_eped ], "edep", Input, "" ); + extract_value( EIMCLogForce, "eimclf", Input, "" ); - Flat = ( extract_value( "Flat", Input ) == "1" ); - + extract_value( Flat, "Flat", Input, ""); break; } default: { // nothing here } + } // engine type + + // NOTE: elements shared by both diesel engine variants; crude but, eh + if( ( EngineType == TEngineType::DieselEngine ) + || ( EngineType == TEngineType::DieselElectric ) ) { + // oil pump + extract_value( OilPump.pressure_minimum, "OilMinPressure", Input, "" ); + extract_value( OilPump.pressure_maximum, "OilMaxPressure", Input, "" ); + // engine cooling factore + extract_value( dizel_heat.kw, "HeatKW", Input, "" ); + extract_value( dizel_heat.kv, "HeatKV", Input, "" ); + extract_value( dizel_heat.kfe, "HeatKFE", Input, "" ); + extract_value( dizel_heat.kfs, "HeatKFS", Input, "" ); + extract_value( dizel_heat.kfo, "HeatKFO", Input, "" ); + extract_value( dizel_heat.kfo2, "HeatKFO2", Input, "" ); + // engine cooling systems + extract_value( dizel_heat.water.config.temp_min, "WaterMinTemperature", Input, "" ); + extract_value( dizel_heat.water.config.temp_max, "WaterMaxTemperature", Input, "" ); + extract_value( dizel_heat.water.config.temp_flow, "WaterFlowTemperature", Input, "" ); + extract_value( dizel_heat.water.config.temp_cooling, "WaterCoolingTemperature", Input, "" ); + extract_value( dizel_heat.water.config.shutters, "WaterShutters", Input, "" ); + extract_value( dizel_heat.auxiliary_water_circuit, "WaterAuxCircuit", Input, "" ); + extract_value( dizel_heat.water_aux.config.temp_min, "WaterAuxMinTemperature", Input, "" ); + extract_value( dizel_heat.water_aux.config.temp_max, "WaterAuxMaxTemperature", Input, "" ); + extract_value( dizel_heat.water_aux.config.temp_cooling, "WaterAuxCoolingTemperature", Input, "" ); + extract_value( dizel_heat.water_aux.config.shutters, "WaterAuxShutters", Input, "" ); + extract_value( dizel_heat.oil.config.temp_min, "OilMinTemperature", Input, "" ); + extract_value( dizel_heat.oil.config.temp_max, "OilMaxTemperature", Input, "" ); + extract_value( dizel_heat.fan_speed, "WaterCoolingFanSpeed", Input, "" ); + // water heater + extract_value( WaterHeater.config.temp_min, "HeaterMinTemperature", Input, "" ); + extract_value( WaterHeater.config.temp_max, "HeaterMaxTemperature", Input, "" ); } + + // traction motors + extract_value( MotorBlowers[ side::front ].speed, "MotorBlowersSpeed", Input, "" ); + MotorBlowers[ side::rear ] = MotorBlowers[ side::front ]; } void TMoverParameters::LoadFIZ_Switches( std::string const &Input ) { extract_value( PantSwitchType, "Pantograph", Input, "" ); extract_value( ConvSwitchType, "Converter", Input, "" ); + extract_value( StLinSwitchType, "MotorConnectors", Input, "" ); + // because people can't make up their minds whether it's "impulse" or "Impulse"... + PantSwitchType = ToLower( PantSwitchType ); + ConvSwitchType = ToLower( ConvSwitchType ); + StLinSwitchType = ToLower( StLinSwitchType ); } void TMoverParameters::LoadFIZ_MotorParamTable( std::string const &Input ) { switch( EngineType ) { - case DieselEngine: { + case TEngineType::DieselEngine: { extract_value( dizel_minVelfullengage, "minVelfullengage", Input, "" ); extract_value( dizel_engageDia, "engageDia", Input, "" ); @@ -6906,10 +8644,16 @@ void TMoverParameters::LoadFIZ_Circuit( std::string const &Input ) { extract_value( ImaxHi, "ImaxHi", Input, "" ); Imin = IminLo; Imax = ImaxLo; + extract_value( TUHEX_Sum, "TUHEX_Sum", Input, "" ); + extract_value( TUHEX_Diff, "TUHEX_Diff", Input, "" ); + extract_value( TUHEX_MaxIw, "TUHEX_MaxIw", Input, "" ); + extract_value( TUHEX_MinIw, "TUHEX_MinIw", Input, "" ); } void TMoverParameters::LoadFIZ_RList( std::string const &Input ) { + extract_value( RlistSize, "Size", Input, "" ); + auto const venttype = extract_value( "RVent", Input ); if( venttype == "Automatic" ) { @@ -6929,6 +8673,9 @@ void TMoverParameters::LoadFIZ_RList( std::string const &Input ) { RVentnmax /= 60.0; extract_value( RVentCutOff, "RVentCutOff", Input, "" ); } + extract_value( RVentMinI, "RVentMinI", Input, "" ); + extract_value( RVentSpeed, "RVentSpeed", Input, "" ); + extract_value( DynamicBrakeRes, "DynBrakeRes", Input, ""); } void TMoverParameters::LoadFIZ_DList( std::string const &Input ) { @@ -6939,6 +8686,16 @@ void TMoverParameters::LoadFIZ_DList( std::string const &Input ) { extract_value( dizel_nmax, "nmax", Input, "" ); extract_value( dizel_nominalfill, "nominalfill", Input, "" ); extract_value( dizel_Mstand, "Mstand", Input, "" ); + + if( dizel_nMmax == dizel_nmax ) { + // HACK: guard against cases where nMmax == nmax, leading to division by 0 in momentum calculation + dizel_nMmax = dizel_nmax - 1.0 / 60.0; + } +} + +void TMoverParameters::LoadFIZ_FFList( std::string const &Input ) { + + extract_value( RlistSize, "Size", Input, "" ); } void TMoverParameters::LoadFIZ_LightsList( std::string const &Input ) { @@ -6952,41 +8709,40 @@ void TMoverParameters::LoadFIZ_PowerParamsDecode( TPowerParameters &Powerparamet switch( Powerparameters.SourceType ) { - case NotDefined: - case InternalSource: { + case TPowerSource::NotDefined: + case TPowerSource::InternalSource: { Powerparameters.PowerType = LoadFIZ_PowerDecode( extract_value( Prefix + "PowerType", Line ) ); break; } - case Transducer: { + case TPowerSource::Transducer: { extract_value( Powerparameters.InputVoltage, Prefix + "TransducerInputV", Line, "" ); break; } - case Generator: { + case TPowerSource::Generator: { Powerparameters.GeneratorEngine = LoadFIZ_EngineDecode( extract_value( Prefix + "GeneratorEngine", Line ) ); break; } - case Accumulator: { + case TPowerSource::Accumulator: { extract_value( Powerparameters.RAccumulator.MaxCapacity, Prefix + "Cap", Line, "" ); Powerparameters.RAccumulator.RechargeSource = LoadFIZ_SourceDecode( extract_value( Prefix + "RS", Line ) ); break; } - case CurrentCollector: { + case TPowerSource::CurrentCollector: { auto &collectorparameters = Powerparameters.CollectorParameters; + collectorparameters = TCurrentCollector { 0, 0, 0, 0, 0, 0, false, 0, 0, 0 }; + extract_value( collectorparameters.CollectorsNo, "CollectorsNo", Line, "" ); extract_value( collectorparameters.MinH, "MinH", Line, "" ); extract_value( collectorparameters.MaxH, "MaxH", Line, "" ); extract_value( collectorparameters.CSW, "CSW", Line, "" ); //szerokość części roboczej extract_value( collectorparameters.MaxV, "MaxVoltage", Line, "" ); - collectorparameters.OVP = //przekaźnik nadnapięciowy - extract_value( "OverVoltProt", Line ) == "Yes" ? - 1 : - 0; + extract_value( collectorparameters.OVP, "OverVoltProt", Line, "" ); //przekaźnik nadnapięciowy //napięcie rozłączające WS collectorparameters.MinV = 0.5 * collectorparameters.MaxV; //gdyby parametr nie podany extract_value( collectorparameters.MinV, "MinV", Line, "" ); @@ -6994,22 +8750,22 @@ void TMoverParameters::LoadFIZ_PowerParamsDecode( TPowerParameters &Powerparamet collectorparameters.InsetV = 0.6 * collectorparameters.MaxV; //gdyby parametr nie podany extract_value( collectorparameters.InsetV, "InsetV", Line, "" ); //ciśnienie rozłączające WS - extract_value( collectorparameters.MinPress, "MinPress", Line, "2.0" ); //domyślnie 2 bary do załączenia WS + extract_value( collectorparameters.MinPress, "MinPress", Line, "3.5" ); //domyślnie 2 bary do załączenia WS //maksymalne ciśnienie za reduktorem - collectorparameters.MaxPress = 5.0 + 0.001 * ( Random( 50 ) - Random( 50 ) ); - extract_value( collectorparameters.MaxPress, "MaxPress", Line, "" ); +// collectorparameters.MaxPress = 5.0 + 0.001 * ( Random( 50 ) - Random( 50 ) ); + extract_value( collectorparameters.MaxPress, "MaxPress", Line, "5.0" ); break; } - case PowerCable: { + case TPowerSource::PowerCable: { Powerparameters.RPowerCable.PowerTrans = LoadFIZ_PowerDecode( extract_value( Prefix + "PowerTrans", Line ) ); - if( Powerparameters.RPowerCable.PowerTrans == SteamPower ) { + if( Powerparameters.RPowerCable.PowerTrans == TPowerType::SteamPower ) { extract_value( Powerparameters.RPowerCable.SteamPressure, Prefix + "SteamPress", Line, "" ); } break; } - case Heater: { + case TPowerSource::Heater: { //jeszcze nie skonczone! break; } @@ -7017,8 +8773,8 @@ void TMoverParameters::LoadFIZ_PowerParamsDecode( TPowerParameters &Powerparamet ; // nothing here } - if( ( Powerparameters.SourceType != Heater ) - && ( Powerparameters.SourceType != InternalSource ) ) { + if( ( Powerparameters.SourceType != TPowerSource::Heater ) + && ( Powerparameters.SourceType != TPowerSource::InternalSource ) ) { extract_value( Powerparameters.MaxVoltage, Prefix + "MaxVoltage", Line, "" ); @@ -7030,53 +8786,53 @@ void TMoverParameters::LoadFIZ_PowerParamsDecode( TPowerParameters &Powerparamet TPowerType TMoverParameters::LoadFIZ_PowerDecode( std::string const &Power ) { std::map powertypes{ - { "BioPower", BioPower }, - { "MechPower", MechPower }, - { "ElectricPower", ElectricPower }, - { "SteamPower", SteamPower } + { "BioPower", TPowerType::BioPower }, + { "MechPower", TPowerType::MechPower }, + { "ElectricPower", TPowerType::ElectricPower }, + { "SteamPower", TPowerType::SteamPower } }; auto lookup = powertypes.find( Power ); return lookup != powertypes.end() ? lookup->second : - NoPower; + TPowerType::NoPower; } TPowerSource TMoverParameters::LoadFIZ_SourceDecode( std::string const &Source ) { std::map powersources{ - { "Transducer", Transducer }, - { "Generator", Generator }, - { "Accu", Accumulator }, - { "CurrentCollector", CurrentCollector }, - { "PowerCable", PowerCable }, - { "Heater", Heater }, - { "Internal", InternalSource } + { "Transducer", TPowerSource::Transducer }, + { "Generator", TPowerSource::Generator }, + { "Accu", TPowerSource::Accumulator }, + { "CurrentCollector", TPowerSource::CurrentCollector }, + { "PowerCable", TPowerSource::PowerCable }, + { "Heater", TPowerSource::Heater }, + { "Internal", TPowerSource::InternalSource } }; auto lookup = powersources.find( Source ); return lookup != powersources.end() ? lookup->second : - NotDefined; + TPowerSource::NotDefined; } -TEngineTypes TMoverParameters::LoadFIZ_EngineDecode( std::string const &Engine ) { +TEngineType TMoverParameters::LoadFIZ_EngineDecode( std::string const &Engine ) { - std::map enginetypes{ - { "ElectricSeriesMotor", ElectricSeriesMotor }, - { "DieselEngine", DieselEngine }, - { "SteamEngine", SteamEngine }, - { "WheelsDriven", WheelsDriven }, - { "Dumb", Dumb }, - { "DieselElectric", DieselElectric }, - { "DumbDE", DieselElectric }, - { "ElectricInductionMotor", ElectricInductionMotor } + std::map enginetypes { + { "ElectricSeriesMotor", TEngineType::ElectricSeriesMotor }, + { "DieselEngine", TEngineType::DieselEngine }, + { "SteamEngine", TEngineType::SteamEngine }, + { "WheelsDriven", TEngineType::WheelsDriven }, + { "Dumb", TEngineType::Dumb }, + { "DieselElectric", TEngineType::DieselElectric }, + { "DumbDE", TEngineType::DieselElectric }, + { "ElectricInductionMotor", TEngineType::ElectricInductionMotor } }; auto lookup = enginetypes.find( Engine ); return lookup != enginetypes.end() ? lookup->second : - None; + TEngineType::None; } // ************************************************************************************************* @@ -7093,24 +8849,26 @@ bool TMoverParameters::CheckLocomotiveParameters(bool ReadyFlag, int Dir) Sand = SandCapacity; + // NOTE: for diesel-powered vehicles we automatically convert legacy "main" power source to more accurate "engine" + if( ( CompressorPower == 0 ) + && ( ( EngineType == TEngineType::DieselEngine ) + || ( EngineType == TEngineType::DieselElectric ) ) ) { + CompressorPower = 3; + } + // WriteLog("aa = " + AxleArangement + " " + std::string( Pos("o", AxleArangement)) ); - if( ( AxleArangement.find( "o" ) != std::string::npos ) && ( EngineType == ElectricSeriesMotor ) ) { + if( ( AxleArangement.find( "o" ) != std::string::npos ) && ( EngineType == TEngineType::ElectricSeriesMotor ) ) { // test poprawnosci ilosci osi indywidualnie napedzanych OK = ( ( RList[ 1 ].Bn * RList[ 1 ].Mn ) == NPoweredAxles ); // WriteLogSS("aa ok", BoolToYN(OK)); } - if( ( LoadType.empty() == false ) && ( LoadAccepted.find( LoadType ) == std::string::npos ) ) { - // remove load if the type isn't supported - Load = 0.0; - } - - if (BrakeSystem == Individual) - if (BrakeSubsystem != ss_None) + if (BrakeSystem == TBrakeSystem::Individual) + if (BrakeSubsystem != TBrakeSubSystem::ss_None) OK = false; //! - if( ( BrakeVVolume == 0 ) && ( MaxBrakePress[ 3 ] > 0 ) && ( BrakeSystem != Individual ) ) { + if( ( BrakeVVolume == 0 ) && ( MaxBrakePress[ 3 ] > 0 ) && ( BrakeSystem != TBrakeSystem::Individual ) ) { BrakeVVolume = MaxBrakePress[ 3 ] / ( 5.0 - MaxBrakePress[ 3 ] ) * ( BrakeCylRadius * BrakeCylRadius * BrakeCylDist * BrakeCylNo * M_PI ) * 1000; @@ -7122,8 +8880,8 @@ bool TMoverParameters::CheckLocomotiveParameters(bool ReadyFlag, int Dir) switch( BrakeValve ) { - case W: - case K: + case TBrakeValve::W: + case TBrakeValve::K: { WriteLog( "XBT W, K" ); Hamulec = std::make_shared( MaxBrakePress[ 3 ], BrakeCylRadius, BrakeCylDist, BrakeVVolume, BrakeCylNo, BrakeDelays, BrakeMethod, NAxles, NBpA ); @@ -7133,7 +8891,7 @@ bool TMoverParameters::CheckLocomotiveParameters(bool ReadyFlag, int Dir) Hamulec->SetLP( Mass, MBPM, MaxBrakePress[ 1 ] ); break; } - case KE: + case TBrakeValve::KE: { WriteLog( "XBT WKE" ); Hamulec = std::make_shared( MaxBrakePress[ 3 ], BrakeCylRadius, BrakeCylDist, BrakeVVolume, BrakeCylNo, BrakeDelays, BrakeMethod, NAxles, NBpA ); @@ -7144,10 +8902,10 @@ bool TMoverParameters::CheckLocomotiveParameters(bool ReadyFlag, int Dir) Hamulec->SetLP( Mass, MBPM, MaxBrakePress[ 1 ] ); break; } - case NESt3: - case ESt3: - case ESt3AL2: - case ESt4: + case TBrakeValve::NESt3: + case TBrakeValve::ESt3: + case TBrakeValve::ESt3AL2: + case TBrakeValve::ESt4: { WriteLog( "XBT NESt3, ESt3, ESt3AL2, ESt4" ); Hamulec = std::make_shared( MaxBrakePress[ 3 ], BrakeCylRadius, BrakeCylDist, BrakeVVolume, BrakeCylNo, BrakeDelays, BrakeMethod, NAxles, NBpA ); @@ -7158,18 +8916,19 @@ bool TMoverParameters::CheckLocomotiveParameters(bool ReadyFlag, int Dir) Hamulec->SetLP( Mass, MBPM, MaxBrakePress[ 1 ] ); break; } - case LSt: + case TBrakeValve::LSt: { WriteLog( "XBT LSt" ); Hamulec = std::make_shared( MaxBrakePress[ 3 ], BrakeCylRadius, BrakeCylDist, BrakeVVolume, BrakeCylNo, BrakeDelays, BrakeMethod, NAxles, NBpA ); Hamulec->SetRM( RapidMult ); break; } - case EStED: + case TBrakeValve::EStED: { WriteLog( "XBT EStED" ); Hamulec = std::make_shared( MaxBrakePress[ 3 ], BrakeCylRadius, BrakeCylDist, BrakeVVolume, BrakeCylNo, BrakeDelays, BrakeMethod, NAxles, NBpA ); Hamulec->SetRM( RapidMult ); + Hamulec->SetRV( RapidVel ); if( MBPM < 2 ) { //jesli przystawka wazaca Hamulec->SetLP( 0, MaxBrakePress[ 3 ], 0 ); @@ -7179,20 +8938,20 @@ bool TMoverParameters::CheckLocomotiveParameters(bool ReadyFlag, int Dir) } break; } - case EP2: + case TBrakeValve::EP2: { WriteLog( "XBT EP2" ); Hamulec = std::make_shared( MaxBrakePress[ 3 ], BrakeCylRadius, BrakeCylDist, BrakeVVolume, BrakeCylNo, BrakeDelays, BrakeMethod, NAxles, NBpA ); Hamulec->SetLP( Mass, MBPM, MaxBrakePress[ 1 ] ); break; } - case CV1: + case TBrakeValve::CV1: { WriteLog( "XBT CV1" ); Hamulec = std::make_shared( MaxBrakePress[ 3 ], BrakeCylRadius, BrakeCylDist, BrakeVVolume, BrakeCylNo, BrakeDelays, BrakeMethod, NAxles, NBpA ); break; } - case CV1_L_TR: + case TBrakeValve::CV1_L_TR: { WriteLog( "XBT CV1_L_T" ); Hamulec = std::make_shared( MaxBrakePress[ 3 ], BrakeCylRadius, BrakeCylDist, BrakeVVolume, BrakeCylNo, BrakeDelays, BrakeMethod, NAxles, NBpA ); @@ -7205,33 +8964,36 @@ bool TMoverParameters::CheckLocomotiveParameters(bool ReadyFlag, int Dir) Hamulec->SetASBP( MaxBrakePress[ 4 ] ); switch( BrakeHandle ) { - case FV4a: + case TBrakeHandle::FV4a: Handle = std::make_shared(); break; - case MHZ_EN57: + case TBrakeHandle::MHZ_EN57: Handle = std::make_shared(); break; - case FVel6: + case TBrakeHandle::FVel6: Handle = std::make_shared(); break; - case testH: + case TBrakeHandle::testH: Handle = std::make_shared(); break; - case M394: + case TBrakeHandle::M394: Handle = std::make_shared(); break; - case Knorr: + case TBrakeHandle::Knorr: Handle = std::make_shared(); break; - case St113: + case TBrakeHandle::St113: Handle = std::make_shared(); break; + case TBrakeHandle::MHZ_K5P: + Handle = std::make_shared(); + break; default: Handle = std::make_shared(); } switch( BrakeLocHandle ) { - case FD1: + case TBrakeHandle::FD1: { LocHandle = std::make_shared(); LocHandle->Init( MaxBrakePress[ 0 ] ); @@ -7241,7 +9003,7 @@ bool TMoverParameters::CheckLocomotiveParameters(bool ReadyFlag, int Dir) } break; } - case Knorr: + case TBrakeHandle::Knorr: { LocHandle = std::make_shared(); LocHandle->Init( MaxBrakePress[ 0 ] ); @@ -7252,8 +9014,8 @@ bool TMoverParameters::CheckLocomotiveParameters(bool ReadyFlag, int Dir) } if ( ( true == TestFlag( BrakeDelays, bdelay_G ) ) - && ( false == TestFlag(BrakeDelays, bdelay_R) ) - || ( Power > 1.0 ) ) // ustalanie srednicy przewodu glownego (lokomotywa lub napędowy + && ( ( false == TestFlag(BrakeDelays, bdelay_R ) ) + || ( Power > 1.0 ) ) ) // ustalanie srednicy przewodu glownego (lokomotywa lub napędowy Spg = 0.792; else Spg = 0.507; @@ -7273,18 +9035,25 @@ bool TMoverParameters::CheckLocomotiveParameters(bool ReadyFlag, int Dir) { WriteLog( "Ready to depart" ); CompressedVolume = VeselVolume * MinCompressor * ( 9.8 ) / 10.0; - ScndPipePress = CompressedVolume / VeselVolume; + ScndPipePress = ( + VeselVolume > 0.0 ? CompressedVolume / VeselVolume : + ( Couplers[ side::front ].AllowedFlag & coupling::mainhose ) != 0 ? 5.0 : + ( Couplers[ side::rear ].AllowedFlag & coupling::mainhose ) != 0 ? 5.0 : + 0.0 ); PipePress = CntrlPipePress; BrakePress = 0.0; - LocalBrakePos = 0; + LocalBrakePosA = 0.0; if( CabNo == 0 ) BrakeCtrlPos = static_cast( Handle->GetPos( bh_NP ) ); else BrakeCtrlPos = static_cast( Handle->GetPos( bh_RP ) ); +/* + // NOTE: disabled and left up to the driver, if there's any MainSwitch( false ); PantFront( true ); PantRear( true ); MainSwitch( true ); +*/ ActiveDir = 0; // Dir; //nastawnik kierunkowy - musi być ustawiane osobno! DirAbsolute = ActiveDir * CabNo; // kierunek jazdy względem sprzęgów LimPipePress = CntrlPipePress; @@ -7293,11 +9062,18 @@ bool TMoverParameters::CheckLocomotiveParameters(bool ReadyFlag, int Dir) WriteLog( "Braked" ); Volume = BrakeVVolume * MaxBrakePress[ 3 ]; CompressedVolume = VeselVolume * MinCompressor * 0.55; +/* ScndPipePress = 5.1; +*/ + ScndPipePress = ( + VeselVolume > 0.0 ? CompressedVolume / VeselVolume : + ( Couplers[ side::front ].AllowedFlag & coupling::mainhose ) != 0 ? 5.1 : + ( Couplers[ side::rear ].AllowedFlag & coupling::mainhose ) != 0 ? 5.1 : + 0.0 ); PipePress = LowPipePress; PipeBrakePress = MaxBrakePress[ 3 ] * 0.5; BrakePress = MaxBrakePress[ 3 ] * 0.5; - LocalBrakePos = 0; + LocalBrakePosA = 0.0; BrakeCtrlPos = static_cast( Handle->GetPos( bh_NP ) ); LimPipePress = LowPipePress; } @@ -7305,8 +9081,8 @@ bool TMoverParameters::CheckLocomotiveParameters(bool ReadyFlag, int Dir) ActFlowSpeed = 0.0; BrakeCtrlPosR = BrakeCtrlPos; - if( BrakeLocHandle == Knorr ) - LocalBrakePos = 5; + if( BrakeLocHandle == TBrakeHandle::Knorr ) + LocalBrakePosA = 0.5; Pipe->CreatePress( PipePress ); Pipe2->CreatePress( ScndPipePress ); @@ -7321,16 +9097,16 @@ bool TMoverParameters::CheckLocomotiveParameters(bool ReadyFlag, int Dir) if( LoadFlag > 0 ) { - if( Load < MaxLoad * 0.45 ) { + if( LoadAmount < MaxLoad * 0.45 ) { IncBrakeMult(); IncBrakeMult(); DecBrakeMult(); // TODO: przeinesiono do mover.cpp - if( Load < MaxLoad * 0.35 ) + if( LoadAmount < MaxLoad * 0.35 ) DecBrakeMult(); } else { IncBrakeMult(); // TODO: przeinesiono do mover.cpp - if( Load >= MaxLoad * 0.55 ) + if( LoadAmount >= MaxLoad * 0.55 ) IncBrakeMult(); } } @@ -7361,9 +9137,9 @@ bool TMoverParameters::CheckLocomotiveParameters(bool ReadyFlag, int Dir) CompressorPower = 0; Hamulec->Init(PipePress, HighPipePress, LowPipePress, BrakePress, BrakeDelayFlag); - +/* ScndPipePress = Compressor; - +*/ // WriteLogSS("OK=", BoolTo10(OK)); // WriteLog(""); @@ -7420,18 +9196,20 @@ bool TMoverParameters::SendCtrlBroadcast(std::string CtrlCommand, double ctrlval // Q: 20160714 // Ustawienie komendy wraz z parametrami // ************************************************************************************************* -bool TMoverParameters::SetInternalCommand(std::string NewCommand, double NewValue1, - double NewValue2) +bool TMoverParameters::SetInternalCommand(std::string NewCommand, double NewValue1, double NewValue2, int const Couplertype) { bool SIC; - if ((CommandIn.Command == NewCommand) && (CommandIn.Value1 == NewValue1) && - (CommandIn.Value2 == NewValue2)) + if( ( CommandIn.Command == NewCommand ) + && ( CommandIn.Value1 == NewValue1 ) + && ( CommandIn.Value2 == NewValue2 ) + && ( CommandIn.Coupling == Couplertype ) ) SIC = false; else { CommandIn.Command = NewCommand; CommandIn.Value1 = NewValue1; CommandIn.Value2 = NewValue2; + CommandIn.Coupling = Couplertype; SIC = true; LastLoadChangeTime = 0; // zerowanie czasu (roz)ładowania } @@ -7443,7 +9221,7 @@ bool TMoverParameters::SetInternalCommand(std::string NewCommand, double NewValu // Q: 20160714 // wysyłanie komendy w kierunku dir (1=przód, -1=tył) do kolejnego pojazdu (jednego) // ************************************************************************************************* -bool TMoverParameters::SendCtrlToNext( std::string CtrlCommand, double ctrlvalue, double dir ) { +bool TMoverParameters::SendCtrlToNext( std::string const CtrlCommand, double const ctrlvalue, double const dir, int const Couplertype ) { bool OK; int d; // numer sprzęgu w kierunku którego wysyłamy @@ -7454,15 +9232,16 @@ bool TMoverParameters::SendCtrlToNext( std::string CtrlCommand, double ctrlvalue if( OK ) { // musi być wybrana niezerowa kabina if( ( Couplers[ d ].Connected != nullptr ) - && ( TestFlag( Couplers[ d ].CouplingFlag, ctrain_controll ) ) ) { + && ( TestFlag( Couplers[ d ].CouplingFlag, Couplertype ) ) ) { + if( Couplers[ d ].ConnectedNr != d ) { // jeśli ten nastpęny jest zgodny z aktualnym - if( Couplers[ d ].Connected->SetInternalCommand( CtrlCommand, ctrlvalue, dir ) ) + if( Couplers[ d ].Connected->SetInternalCommand( CtrlCommand, ctrlvalue, dir, Couplertype ) ) OK = ( Couplers[ d ].Connected->RunInternalCommand() && OK ); // tu jest rekurencja } else { // jeśli następny jest ustawiony przeciwnie, zmieniamy kierunek - if( Couplers[ d ].Connected->SetInternalCommand( CtrlCommand, ctrlvalue, -dir ) ) + if( Couplers[ d ].Connected->SetInternalCommand( CtrlCommand, ctrlvalue, -dir, Couplertype ) ) OK = ( Couplers[ d ].Connected->RunInternalCommand() && OK ); // tu jest rekurencja } } @@ -7481,31 +9260,21 @@ bool TMoverParameters::SendCtrlToNext( std::string CtrlCommand, double ctrlvalue // Komenda musi być zdefiniowana tutaj, a jeśli się wywołuje funkcję, to ona nie może // sama przesyłać do kolejnych pojazdów. Należy też się zastanowić, czy dla uzyskania // jakiejś zmiany (np. IncMainCtrl) lepiej wywołać funkcję, czy od razu wysłać komendę. -bool TMoverParameters::RunCommand(std::string Command, double CValue1, double CValue2) +bool TMoverParameters::RunCommand( std::string Command, double CValue1, double CValue2, int const Couplertype ) { - bool OK; - std::string testload; - OK = false; + bool OK { false }; if (Command == "MainCtrl") { if (MainCtrlPosNo >= floor(CValue1)) MainCtrlPos = static_cast(floor(CValue1)); - OK = SendCtrlToNext(Command, CValue1, CValue2); + OK = SendCtrlToNext(Command, CValue1, CValue2, Couplertype); } else if (Command == "ScndCtrl") { - if ((EngineType == ElectricInductionMotor)) - if ((ScndCtrlPos == 0) && (floor(CValue1) > 0)) - if ((Vmax < 250)) - ScndCtrlActualPos = Round(Vel + 0.5); - else - ScndCtrlActualPos = Round(Vel / 2 + 0.5); - else if ((floor(CValue1) == 0)) - ScndCtrlActualPos = 0; if (ScndCtrlPosNo >= floor(CValue1)) ScndCtrlPos = static_cast(floor(CValue1)); - OK = SendCtrlToNext(Command, CValue1, CValue2); + OK = SendCtrlToNext( Command, CValue1, CValue2, Couplertype ); } /* else if command='BrakeCtrl' then begin @@ -7520,30 +9289,154 @@ bool TMoverParameters::RunCommand(std::string Command, double CValue1, double CV Hamulec->SetEPS(CValue1); // fBrakeCtrlPos:=BrakeCtrlPos; //to powinnno być w jednym miejscu, aktualnie w C++!!! BrakePressureActual = BrakePressureTable[BrakeCtrlPos]; - OK = SendCtrlToNext(Command, CValue1, CValue2); + OK = SendCtrlToNext( Command, CValue1, CValue2, Couplertype ); } // youby - odluzniacz hamulcow, przyda sie else if (Command == "BrakeReleaser") { OK = BrakeReleaser(Round(CValue1)); // samo się przesyła dalej // OK:=SendCtrlToNext(command,CValue1,CValue2); //to robiło kaskadę 2^n } - else if (Command == "MainSwitch") + else if( Command == "WaterPumpBreakerSwitch" ) { +/* + if( FuelPump.start_type != start::automatic ) { + // automatic fuel pump ignores 'manual' state commands +*/ + WaterPump.breaker = ( CValue1 == 1 ); +/* + } +*/ + OK = SendCtrlToNext( Command, CValue1, CValue2, Couplertype ); + } + else if( Command == "WaterPumpSwitch" ) { + + if( WaterPump.start_type != start_t::battery ) { + // automatic fuel pump ignores 'manual' state commands + WaterPump.is_enabled = ( CValue1 == 1 ); + } + OK = SendCtrlToNext( Command, CValue1, CValue2, Couplertype ); + } + else if( Command == "WaterPumpSwitchOff" ) { + + if( WaterPump.start_type != start_t::battery ) { + // automatic fuel pump ignores 'manual' state commands + WaterPump.is_disabled = ( CValue1 == 1 ); + } + OK = SendCtrlToNext( Command, CValue1, CValue2, Couplertype ); + } + else if( Command == "WaterHeaterBreakerSwitch" ) { +/* + if( FuelPump.start_type != start::automatic ) { + // automatic fuel pump ignores 'manual' state commands +*/ + WaterHeater.breaker = ( CValue1 == 1 ); +/* + } +*/ + OK = SendCtrlToNext( Command, CValue1, CValue2, Couplertype ); + } + else if( Command == "WaterHeaterSwitch" ) { +/* + if( FuelPump.start_type != start::automatic ) { + // automatic fuel pump ignores 'manual' state commands +*/ + WaterHeater.is_enabled = ( CValue1 == 1 ); +/* + } +*/ + OK = SendCtrlToNext( Command, CValue1, CValue2, Couplertype ); + } + else if( Command == "WaterCircuitsLinkSwitch" ) { + if( true == dizel_heat.auxiliary_water_circuit ) { + // can only link circuits if the vehicle has more than one of them + WaterCircuitsLink = ( CValue1 == 1 ); + } + OK = SendCtrlToNext( Command, CValue1, CValue2, Couplertype ); + } + else if (Command == "FuelPumpSwitch") { + if( FuelPump.start_type != start_t::automatic ) { + // automatic fuel pump ignores 'manual' state commands + FuelPump.is_enabled = ( CValue1 == 1 ); + } + OK = SendCtrlToNext( Command, CValue1, CValue2, Couplertype ); + } + else if (Command == "FuelPumpSwitchOff") { + if( FuelPump.start_type != start_t::automatic ) { + // automatic fuel pump ignores 'manual' state commands + FuelPump.is_disabled = ( CValue1 == 1 ); + } + OK = SendCtrlToNext( Command, CValue1, CValue2, Couplertype ); + } + else if (Command == "OilPumpSwitch") { + if( OilPump.start_type != start_t::automatic ) { + // automatic pump ignores 'manual' state commands + OilPump.is_enabled = ( CValue1 == 1 ); + } + OK = SendCtrlToNext( Command, CValue1, CValue2, Couplertype ); + } + else if (Command == "OilPumpSwitchOff") { + if( OilPump.start_type != start_t::automatic ) { + // automatic pump ignores 'manual' state commands + OilPump.is_disabled = ( CValue1 == 1 ); + } + OK = SendCtrlToNext( Command, CValue1, CValue2, Couplertype ); + } + else if( Command == "MotorBlowersFrontSwitch" ) { + if( ( MotorBlowers[ side::front ].start_type != start_t::manual ) + && ( MotorBlowers[ side::front ].start_type != start_t::manualwithautofallback ) ) { + // automatic device ignores 'manual' state commands + MotorBlowers[side::front].is_enabled = ( CValue1 == 1 ); + } + OK = SendCtrlToNext( Command, CValue1, CValue2, Couplertype ); + } + else if( Command == "MotorBlowersFrontSwitchOff" ) { + if( ( MotorBlowers[ side::front ].start_type != start_t::manual ) + && ( MotorBlowers[ side::front ].start_type != start_t::manualwithautofallback ) ) { + // automatic device ignores 'manual' state commands + MotorBlowers[side::front].is_disabled = ( CValue1 == 1 ); + } + OK = SendCtrlToNext( Command, CValue1, CValue2, Couplertype ); + } + else if( Command == "MotorBlowersRearSwitch" ) { + if( ( MotorBlowers[ side::rear ].start_type != start_t::manual ) + && ( MotorBlowers[ side::rear ].start_type != start_t::manualwithautofallback ) ) { + // automatic device ignores 'manual' state commands + MotorBlowers[side::rear].is_enabled = ( CValue1 == 1 ); + } + OK = SendCtrlToNext( Command, CValue1, CValue2, Couplertype ); + } + else if( Command == "MotorBlowersRearSwitchOff" ) { + if( ( MotorBlowers[ side::rear ].start_type != start_t::manual ) + && ( MotorBlowers[ side::rear ].start_type != start_t::manualwithautofallback ) ) { + // automatic device ignores 'manual' state commands + MotorBlowers[side::rear].is_disabled = ( CValue1 == 1 ); + } + OK = SendCtrlToNext( Command, CValue1, CValue2, Couplertype ); + } + else if (Command == "MainSwitch") { - if (CValue1 == 1) - { - Mains = true; - if ((EngineType == DieselEngine) && Mains) - dizel_enginestart = true; + if (CValue1 == 1) { + + if( ( EngineType == TEngineType::DieselEngine ) + || ( EngineType == TEngineType::DieselElectric ) ) { + dizel_startup = true; + } + else { + Mains = true; + } } - else - Mains = false; - OK = SendCtrlToNext(Command, CValue1, CValue2); + else { + Mains = false; + // potentially knock out the pumps if their switch doesn't force them on + WaterPump.is_active &= WaterPump.is_enabled; + FuelPump.is_active &= FuelPump.is_enabled; + } + OK = SendCtrlToNext( Command, CValue1, CValue2, Couplertype ); } else if (Command == "Direction") { ActiveDir = static_cast(floor(CValue1)); DirAbsolute = ActiveDir * CabNo; - OK = SendCtrlToNext(Command, CValue1, CValue2); + OK = SendCtrlToNext( Command, CValue1, CValue2, Couplertype ); } else if (Command == "CabActivisation") { @@ -7564,7 +9457,7 @@ bool TMoverParameters::RunCommand(std::string Command, double CValue1, double CV } } DirAbsolute = ActiveDir * CabNo; - OK = SendCtrlToNext(Command, CValue1, CValue2); + OK = SendCtrlToNext( Command, CValue1, CValue2, Couplertype ); } else if (Command == "AutoRelaySwitch") { @@ -7572,11 +9465,11 @@ bool TMoverParameters::RunCommand(std::string Command, double CValue1, double CV AutoRelayFlag = true; else AutoRelayFlag = false; - OK = SendCtrlToNext(Command, CValue1, CValue2); + OK = SendCtrlToNext( Command, CValue1, CValue2, Couplertype ); } else if (Command == "FuseSwitch") { - if (((EngineType == ElectricSeriesMotor) || (EngineType == DieselElectric)) && FuseFlag && + if (((EngineType == TEngineType::ElectricSeriesMotor) || (EngineType == TEngineType::DieselElectric)) && FuseFlag && (CValue1 == 1) && (MainCtrlActualPos == 0) && (ScndCtrlActualPos == 0) && Mains) /* if (EngineType=ElectricSeriesMotor) and (CValue1=1) and (MainCtrlActualPos=0) and (ScndCtrlActualPos=0) and Mains then*/ @@ -7584,7 +9477,7 @@ bool TMoverParameters::RunCommand(std::string Command, double CValue1, double CV // if ((EngineType=ElectricSeriesMotor)or(EngineType=DieselElectric)) and not FuseFlag and // (CValue1=0) and Mains then // FuseFlag:=true; - OK = SendCtrlToNext(Command, CValue1, CValue2); + OK = SendCtrlToNext( Command, CValue1, CValue2, Couplertype ); } else if (Command == "ConverterSwitch") /*NBMX*/ { @@ -7592,7 +9485,7 @@ bool TMoverParameters::RunCommand(std::string Command, double CValue1, double CV ConverterAllow = true; else if ((CValue1 == 0)) ConverterAllow = false; - OK = SendCtrlToNext(Command, CValue1, CValue2); + OK = SendCtrlToNext( Command, CValue1, CValue2, Couplertype ); } else if (Command == "BatterySwitch") /*NBMX*/ { @@ -7604,7 +9497,7 @@ bool TMoverParameters::RunCommand(std::string Command, double CValue1, double CV SecuritySystem.Status = SecuritySystem.Status || s_waiting; // aktywacja czuwaka else SecuritySystem.Status = 0; // wyłączenie czuwaka - OK = SendCtrlToNext(Command, CValue1, CValue2); + OK = SendCtrlToNext( Command, CValue1, CValue2, Couplertype ); } // else if command='EpFuseSwitch' then {NBMX} // begin @@ -7614,52 +9507,101 @@ bool TMoverParameters::RunCommand(std::string Command, double CValue1, double CV // end else if (Command == "CompressorSwitch") /*NBMX*/ { - if ((CValue1 == 1)) - CompressorAllow = true; - else if ((CValue1 == 0)) - CompressorAllow = false; - OK = SendCtrlToNext(Command, CValue1, CValue2); + if( CompressorStart == start_t::manual ) { + CompressorAllow = ( CValue1 == 1 ); + } + OK = SendCtrlToNext( Command, CValue1, CValue2, Couplertype ); } else if (Command == "DoorOpen") /*NBMX*/ { // Ra: uwzględnić trzeba jeszcze zgodność sprzęgów - if ((CValue2 > 0)) - { // normalne ustawienie pojazdu - if ((CValue1 == 1) || (CValue1 == 3)) - DoorLeftOpened = true; - if ((CValue1 == 2) || (CValue1 == 3)) - DoorRightOpened = true; - } - else - { // odwrotne ustawienie pojazdu - if ((CValue1 == 2) || (CValue1 == 3)) - DoorLeftOpened = true; - if ((CValue1 == 1) || (CValue1 == 3)) - DoorRightOpened = true; - } - OK = SendCtrlToNext(Command, CValue1, CValue2); + if( ( DoorOpenCtrl == control_t::conductor ) + || ( DoorOpenCtrl == control_t::driver ) + || ( DoorOpenCtrl == control_t::mixed ) ) { + // ignore remote command if the door is only operated locally + if( CValue2 > 0 ) { + // normalne ustawienie pojazdu + if( ( CValue1 == 1 ) || ( CValue1 == 3 ) ) { + DoorLeftOpened = ( + ( ( true == Battery ) && ( false == DoorBlockedFlag() ) ) ? + true : + DoorLeftOpened ); + } + if( ( CValue1 == 2 ) || ( CValue1 == 3 ) ) { + DoorRightOpened = ( + ( ( true == Battery ) && ( false == DoorBlockedFlag() ) ) ? + true : + DoorRightOpened ); + } + } + else { + // odwrotne ustawienie pojazdu + if( ( CValue1 == 2 ) || ( CValue1 == 3 ) ) { + DoorLeftOpened = ( + ( ( true == Battery ) && ( false == DoorBlockedFlag() ) ) ? + true : + DoorLeftOpened ); + } + if( ( CValue1 == 1 ) || ( CValue1 == 3 ) ) { + DoorRightOpened = ( + ( ( true == Battery ) && ( false == DoorBlockedFlag() ) ) ? + true : + DoorRightOpened ); + } + } + } + OK = SendCtrlToNext( Command, CValue1, CValue2, Couplertype ); } else if (Command == "DoorClose") /*NBMX*/ { // Ra: uwzględnić trzeba jeszcze zgodność sprzęgów - if ((CValue2 > 0)) - { // normalne ustawienie pojazdu - if ((CValue1 == 1) || (CValue1 == 3)) - DoorLeftOpened = false; - if ((CValue1 == 2) || (CValue1 == 3)) - DoorRightOpened = false; - } - else - { // odwrotne ustawienie pojazdu - if ((CValue1 == 2) || (CValue1 == 3)) - DoorLeftOpened = false; - if ((CValue1 == 1) || (CValue1 == 3)) - DoorRightOpened = false; - } - OK = SendCtrlToNext(Command, CValue1, CValue2); + if( ( DoorCloseCtrl == control_t::conductor ) + || ( DoorCloseCtrl == control_t::driver ) + || ( DoorCloseCtrl == control_t::mixed ) ) { + // ignore remote command if the door is only operated locally + if( CValue2 > 0 ) { + // normalne ustawienie pojazdu + if( ( CValue1 == 1 ) || ( CValue1 == 3 ) ) { + DoorLeftOpened = ( + true == Battery ? + false : + DoorLeftOpened ); + } + if( ( CValue1 == 2 ) || ( CValue1 == 3 ) ) { + DoorRightOpened = ( + true == Battery ? + false : + DoorRightOpened ); + } + } + else { + // odwrotne ustawienie pojazdu + if( ( CValue1 == 2 ) || ( CValue1 == 3 ) ) { + DoorLeftOpened = ( + true == Battery ? + false : + DoorLeftOpened ); + } + if( ( CValue1 == 1 ) || ( CValue1 == 3 ) ) { + DoorRightOpened = ( + true == Battery ? + false : + DoorRightOpened ); + } + } + } + OK = SendCtrlToNext( Command, CValue1, CValue2, Couplertype ); } + else if( Command == "DepartureSignal" ) { + DepartureSignal = ( + CValue1 == 1 ? + true : + false ); + OK = SendCtrlToNext( Command, CValue1, CValue2, Couplertype ); + } else if (Command == "PantFront") /*Winger 160204*/ { // Ra: uwzględnić trzeba jeszcze zgodność sprzęgów // Czemu EZT ma być traktowane inaczej? Ukrotnienie ma, a człon może być odwrócony - if ((TrainType == dt_EZT)) + if ((TrainType == dt_EZT) + || (TrainType == dt_ET41)) { //'ezt' if ((CValue1 == 1)) { @@ -7699,12 +9641,13 @@ bool TMoverParameters::RunCommand(std::string Command, double CValue1, double CV PantRearStart = 1; } } - OK = SendCtrlToNext(Command, CValue1, CValue2); + OK = SendCtrlToNext( Command, CValue1, CValue2, Couplertype ); } else if (Command == "PantRear") /*Winger 160204, ABu 310105 i 030305*/ { // Ra: uwzględnić trzeba jeszcze zgodność sprzęgów - if ((TrainType == dt_EZT)) - { /*'ezt'*/ + if ((TrainType == dt_EZT) + ||(TrainType == dt_ET41)) + { //'ezt' if ((CValue1 == 1)) { PantRearUp = true; @@ -7717,9 +9660,9 @@ bool TMoverParameters::RunCommand(std::string Command, double CValue1, double CV } } else - { /*nie 'ezt'*/ + { //nie 'ezt' if ((CValue1 == 1)) - /*if ostatni polaczony sprz. sterowania*/ + //if ostatni polaczony sprz. sterowania if ((TestFlag(Couplers[1].CouplingFlag, ctrain_controll) && (CValue2 == 1)) || (TestFlag(Couplers[0].CouplingFlag, ctrain_controll) && (CValue2 == -1))) { @@ -7744,7 +9687,7 @@ bool TMoverParameters::RunCommand(std::string Command, double CValue1, double CV PantFrontStart = 1; } } - OK = SendCtrlToNext(Command, CValue1, CValue2); + OK = SendCtrlToNext( Command, CValue1, CValue2, Couplertype ); } else if (Command == "MaxCurrentSwitch") { @@ -7764,22 +9707,26 @@ bool TMoverParameters::RunCommand(std::string Command, double CValue1, double CV } else if (Command == "Emergency_brake") { - if (EmergencyBrakeSwitch(floor(CValue1) == 1)) // YB: czy to jest potrzebne? + if (RadiostopSwitch(floor(CValue1) == 1)) // YB: czy to jest potrzebne? OK = true; else OK = false; } else if (Command == "BrakeDelay") { - BrakeDelayFlag = static_cast(floor(CValue1)); - OK = true; + auto const brakesetting = static_cast( std::floor( CValue1 ) ); + if( true == Hamulec->SetBDF( brakesetting ) ) { + BrakeDelayFlag = brakesetting; + OK = true; + } + else { + OK = false; + } + SendCtrlToNext( Command, CValue1, CValue2, Couplertype ); } - else if (Command == "SandDoseOn") + else if (Command == "Sandbox") { - if (SandDoseOn()) - OK = true; - else - OK = false; + OK = Sandbox( CValue1 == 1, range_t::local ); } else if (Command == "CabSignal") /*SHP,Indusi*/ { // Ra: to powinno działać tylko w członie obsadzonym @@ -7797,30 +9744,49 @@ bool TMoverParameters::RunCommand(std::string Command, double CValue1, double CV OK = true; // true, gdy można usunąć komendę } /*naladunek/rozladunek*/ - else if (Pos("Load=", Command) == 1) + // TODO: have these commands leverage load exchange system instead + else if ( issection( "Load=", Command ) ) { OK = false; // będzie powtarzane aż się załaduje - if ((Vel == 0) && (MaxLoad > 0) && - (Load < MaxLoad * (1.0 + OverLoadFactor))) // czy można ładowac? - if (Distance(Loc, CommandIn.Location, Dim, Dim) < 10) // ten peron/rampa - { - testload = ToLower(DUE(Command)); - if (Pos(testload, LoadAccepted) > 0) // nazwa jest obecna w CHK - OK = LoadingDone(Min0R(CValue2, LoadSpeed), testload); // zmienia LoadStatus - } - // if OK then LoadStatus:=0; //nie udalo sie w ogole albo juz skonczone + if( ( Vel < 0.1 ) // tolerance margin for small vehicle movements in the consist + && ( MaxLoad > 0 ) + && ( LoadAmount < MaxLoad * ( 1.0 + OverLoadFactor ) ) + && ( Distance( Loc, CommandIn.Location, Dim, Dim ) < 10 ) ) { // ten peron/rampa + + auto const loadname { ToLower( extract_value( "Load", Command ) ) }; + if( LoadAmount == 0.f ) { + AssignLoad( loadname ); + } + OK = LoadingDone( + std::min( CValue2, LoadSpeed ), + loadname ); // zmienia LoadStatus + } + else { + // no loading can be done if conditions aren't met + LastLoadChangeTime = 0.0; + } } - else if (Pos("UnLoad=", Command) == 1) + else if( issection( "UnLoad=", Command ) ) { OK = false; // będzie powtarzane aż się rozładuje - if ((Vel == 0) && (Load > 0)) // czy jest co rozladowac? - if (Distance(Loc, CommandIn.Location, Dim, Dim) < 10) // ten peron - { - testload = DUE(Command); // zgodność nazwy ładunku z CHK - if (LoadType == testload) /*mozna to rozladowac*/ - OK = LoadingDone(-Min0R(CValue2, LoadSpeed), testload); - } - // if OK then LoadStatus:=0; + if( ( Vel < 0.1 ) // tolerance margin for small vehicle movements in the consist + && ( LoadAmount > 0 ) // czy jest co rozladowac? + && ( Distance( Loc, CommandIn.Location, Dim, Dim ) < 10 ) ) { // ten peron + /*mozna to rozladowac*/ + OK = LoadingDone( + -1.f * std::min( CValue2, LoadSpeed ), + ToLower( extract_value( "UnLoad", Command ) ) ); + } + else { + // no loading can be done if conditions aren't met + LastLoadChangeTime = 0.0; + } + } + else if (Command == "SpeedCntrl") + { + if ((EngineType == TEngineType::ElectricInductionMotor)) + ScndCtrlActualPos = static_cast(round(CValue1)); + OK = SendCtrlToNext(Command, CValue1, CValue2, Couplertype); } return OK; // dla true komenda będzie usunięta, dla false wykonana ponownie @@ -7830,19 +9796,19 @@ bool TMoverParameters::RunCommand(std::string Command, double CValue1, double CV // Q: 20160714 // Uruchamia funkcję RunCommand aż do skutku. Jeśli będzie pozytywny to kasuje komendę. // ************************************************************************************************* -bool TMoverParameters::RunInternalCommand(void) +bool TMoverParameters::RunInternalCommand() { bool OK; if (!CommandIn.Command.empty()) { - OK = RunCommand(CommandIn.Command, CommandIn.Value1, CommandIn.Value2); - if (OK) + OK = RunCommand( CommandIn.Command, CommandIn.Value1, CommandIn.Value2, CommandIn.Coupling ); + if (OK) { - { CommandIn.Command.clear(); // kasowanie bo rozkaz wykonany CommandIn.Value1 = 0; CommandIn.Value2 = 0; + CommandIn.Coupling = 0; CommandIn.Location.X = 0; CommandIn.Location.Y = 0; CommandIn.Location.Z = 0; @@ -7859,7 +9825,7 @@ bool TMoverParameters::RunInternalCommand(void) // Q: 20160714 // Zwraca wartość natężenia prądu na wybranym amperomierzu. Podfunkcja do ShowCurrent. // ************************************************************************************************* -double TMoverParameters::ShowCurrentP(int AmpN) +double TMoverParameters::ShowCurrentP(int AmpN) const { int b, Bn; bool Grupowy; @@ -7869,7 +9835,7 @@ double TMoverParameters::ShowCurrentP(int AmpN) Bn = RList[MainCtrlActualPos].Bn; // ile równoległych gałęzi silników if ((DynamicBrakeType == dbrake_automatic) && (DynamicBrakeFlag)) - Bn = 2; + Bn = DynamicBrakeAmpmeters; if (Power > 0.01) { if (AmpN > 0) // podać prąd w gałęzi diff --git a/McZapkie/Oerlikon_ESt.cpp b/McZapkie/Oerlikon_ESt.cpp index eded5cf6..8ae37298 100644 --- a/McZapkie/Oerlikon_ESt.cpp +++ b/McZapkie/Oerlikon_ESt.cpp @@ -63,10 +63,12 @@ void TPrzekladnik::Update(double dt) if ( BCP > P() ) dV = -PFVd(BCP, 0, d2A(10), P()) * dt; - else if ( BCP < P() ) - dV = PFVa(BVP, BCP, d2A(10), P()) * dt; - else - dV = 0; + else { + if( BCP < P() ) + dV = PFVa( BVP, BCP, d2A( 10 ), P() ) * dt; + else + dV = 0; + } Next->Flow(dV); if (dV > 0) @@ -86,8 +88,8 @@ void TRapid::SetRapidParams(double mult, double size) } else { - DN = d2A(5); - DL = d2A(5); + DN = d2A(5.0); + DL = d2A(5.0); } } @@ -117,10 +119,10 @@ void TRapid::Update(double dt) else if ((BCP * RapidMult) < (P() * ActMult)) dV = PFVa(BVP, BCP, DN, P() * ActMult / RapidMult) * dt; else - dV = 0; + dV = 0.0; Next->Flow(dV); - if (dV > 0) + if (dV > 0.0) BrakeRes->Flow(-dV); } @@ -128,7 +130,7 @@ void TRapid::Update(double dt) void TPrzekCiagly::SetMult(double m) { - mult = m; + Mult = m; } void TPrzekCiagly::Update(double dt) @@ -137,15 +139,15 @@ void TPrzekCiagly::Update(double dt) double const BCP{ Next->P() }; double dV; - if ( BCP > (P() * mult)) - dV = -PFVd(BCP, 0, d2A(8), P() * mult) * dt; - else if (BCP < (P() * mult)) - dV = PFVa(BVP, BCP, d2A(8), P() * mult) * dt; + if ( BCP > (P() * Mult)) + dV = -PFVd(BCP, 0, d2A(8.0), P() * Mult) * dt; + else if (BCP < (P() * Mult)) + dV = PFVa(BVP, BCP, d2A(8.0), P() * Mult) * dt; else - dV = 0; + dV = 0.0; Next->Flow(dV); - if (dV > 0) + if (dV > 0.0) BrakeRes->Flow(-dV); } @@ -165,14 +167,14 @@ void TPrzek_PZZ::Update(double dt) double dV; if (BCP > Pgr) - dV = -PFVd(BCP, 0, d2A(8), Pgr) * dt; + dV = -PFVd(BCP, 0, d2A(8.0), Pgr) * dt; else if (BCP < Pgr) - dV = PFVa(BVP, BCP, d2A(8), Pgr) * dt; + dV = PFVa(BVP, BCP, d2A(8.0), Pgr) * dt; else - dV = 0; + dV = 0.0; Next->Flow(dV); - if (dV > 0) + if (dV > 0.0) BrakeRes->Flow(-dV); } @@ -188,11 +190,11 @@ void TPrzekED::Update(double dt) if (Next->P() > MaxP) { BrakeRes->Flow(dVol); - Next->Flow(PFVd(Next->P(), 0, d2A(10) * dt, MaxP)); + Next->Flow(PFVd(Next->P(), 0, d2A(10.0) * dt, MaxP)); } else Next->Flow(dVol); - dVol = 0; + dVol = 0.0; } // ------ OERLIKON EST NA BOGATO ------ @@ -216,15 +218,17 @@ double TNESt3::GetPF( double const PP, double const dt, double const Vel ) // pr // luzowanie if ((BrakeStatus & b_hld) == b_off) - dV = PF(0, BCP, Nozzles[dTO] * nastG + (1.0 - nastG) * Nozzles[dOO]) * dt * - (0.1 + 4.9 * std::min(0.2, BCP - ((CVP - 0.05 - VVP) * BVM + 0.1))); + dV = + PF(0.0, BCP, Nozzles[dTO] * nastG + (1.0 - nastG) * Nozzles[dOO]) + * dt * (0.1 + 4.9 * std::min(0.2, BCP - ((CVP - 0.05 - VVP) * BVM + 0.1))); else - dV = 0; + dV = 0.0; // BrakeCyl.Flow(-dV); Przekladniki[1]->Flow(-dV); if ( ((BrakeStatus & b_on) == b_on) && (Przekladniki[1]->P() * HBG300 < MaxBP) ) - dV = PF( BVP, BCP, Nozzles[dTN] * (nastG + 2.0 * (BCP < Podskok ? 1.0 : 0.0)) + Nozzles[dON] * (1 - nastG) ) - * dt * (0.1 + 4.9 * std::min( 0.2, (CVP - 0.05 - VVP) * BVM - BCP ) ); + dV = + PF( BVP, BCP, Nozzles[dTN] * (nastG + 2.0 * (BCP < Podskok ? 1.0 : 0.0)) + Nozzles[dON] * (1.0 - nastG) ) + * dt * (0.1 + 4.9 * std::min( 0.2, (CVP - 0.05 - VVP) * BVM - BCP ) ); else dV = 0; // BrakeCyl.Flow(-dV); @@ -236,30 +240,32 @@ double TNESt3::GetPF( double const PP, double const dt, double const Vel ) // pr Przekladniki[i]->Update(dt); if (typeid(*Przekladniki[i]) == typeid(TRapid)) { - RapidStatus = - (((BrakeDelayFlag & bdelay_R) == bdelay_R) && - ((abs(Vel) > 70) || ((RapidStatus) && (abs(Vel) > 50)) || (RapidStaly))); + RapidStatus = ( ( ( BrakeDelayFlag & bdelay_R ) == bdelay_R ) + && ( ( std::abs( Vel ) > 70.0 ) + || ( ( std::abs( Vel ) > 50.0 ) && ( RapidStatus ) ) + || ( RapidStaly ) ) ); Przekladniki[i]->SetRapidStatus(RapidStatus); } - else if (typeid(*Przekladniki[i]) == typeid(TPrzeciwposlizg)) + else if( typeid( *Przekladniki[i] ) == typeid( TPrzeciwposlizg ) ) Przekladniki[i]->SetPoslizg((BrakeStatus & b_asb) == b_asb); - else if (typeid(*Przekladniki[i]) == typeid(TPrzekED)) - if (Vel < -15) - Przekladniki[i]->SetP(0); + else if( typeid( *Przekladniki[ i ] ) == typeid( TPrzekED ) ) { + if( Vel < -15.0 ) + Przekladniki[ i ]->SetP( 0.0 ); else - Przekladniki[i]->SetP(MaxBP * 3); - else if (typeid(*Przekladniki[i]) == typeid(TPrzekCiagly)) + Przekladniki[ i ]->SetP( MaxBP * 3.0 ); + } + else if( typeid( *Przekladniki[i] ) == typeid( TPrzekCiagly ) ) Przekladniki[i]->SetMult(LoadC); - else if (typeid(*Przekladniki[i]) == typeid(TPrzek_PZZ)) + else if( typeid( *Przekladniki[i] ) == typeid( TPrzek_PZZ ) ) Przekladniki[i]->SetLBP(LBP); } // przeplyw testowy miedzypojemnosci dV = PF(MPP, VVP, BVs(BCP)) + PF(MPP, CVP, CVs(BCP)); - if ((MPP - 0.05 > BVP)) + if ((MPP - 0.05) > BVP) dV += PF(MPP - 0.05, BVP, Nozzles[dPT] * nastG + (1.0 - nastG) * Nozzles[dPO]); if (MPP > VVP) - dV += PF(MPP, VVP, d2A(5)); + dV += PF(MPP, VVP, d2A(5.0)); Miedzypoj->Flow(dV * dt * 0.15); // przeplyw ZS <-> PG @@ -270,10 +276,10 @@ double TNESt3::GetPF( double const PP, double const dt, double const Vel ) // pr dV1 += 0.98 * dV; // przeplyw ZP <-> MPJ - if (MPP - 0.05 > BVP) + if ((MPP - 0.05) > BVP) dV = PF(BVP, MPP - 0.05, Nozzles[dPT] * nastG + (1.0 - nastG) * Nozzles[dPO]) * dt; else - dV = 0; + dV = 0.0; BrakeRes->Flow(dV); dV1 += dV * 0.98; ValveRes->Flow(-0.02 * dV); @@ -303,21 +309,23 @@ void TNESt3::Init( double const PP, double const HPP, double const LPP, double c BrakeCyl->CreatePress(BP); BrakeRes->CreatePress(PP); CntrlRes = std::make_shared(); - CntrlRes->CreateCap(15); + CntrlRes->CreateCap(15.0); CntrlRes->CreatePress(HPP); - BrakeStatus = static_cast(BP > 1.0); + BrakeStatus = (BP > 1.0 ? 1 : 0); Miedzypoj = std::make_shared(); - Miedzypoj->CreateCap(5); + Miedzypoj->CreateCap(5.0); Miedzypoj->CreatePress(PP); BVM = 1.0 / (HPP - 0.05 - LPP) * MaxBP; BrakeDelayFlag = BDF; - if (!(typeid(*FM) == typeid(TDisk1) || typeid(*FM) == typeid(TDisk2))) // jesli zeliwo to schodz - RapidStaly = false; - else + Zamykajacy = false; + + if ( (typeid(*FM) == typeid(TDisk1)) || (typeid(*FM) == typeid(TDisk2)) ) // jesli zeliwo to schodz RapidStaly = true; + else + RapidStaly = false; } double TNESt3::GetCRP() @@ -339,19 +347,19 @@ void TNESt3::CheckState(double const BCP, double &dV1) // glowny przyrzad rozrza // sprawdzanie stanu // if ((BrakeStatus and 1)=1)and(BCP>0.25)then - if ((VVP + 0.01 + BCP / BVM < CVP - 0.05) && (Przys_blok)) + if (((VVP + 0.01 + BCP / BVM) < (CVP - 0.05)) && (Przys_blok)) BrakeStatus |= ( b_on | b_hld ); // hamowanie stopniowe; - else if (VVP - 0.01 + (BCP - 0.1) / BVM > CVP - 0.05) + else if ((VVP - 0.01 + (BCP - 0.1) / BVM) > (CVP - 0.05)) BrakeStatus &= ~( b_on | b_hld ); // luzowanie; - else if (VVP + BCP / BVM > CVP - 0.05) + else if ((VVP + BCP / BVM) > (CVP - 0.05)) BrakeStatus &= ~b_on; // zatrzymanie napelaniania; - else if ((VVP + (BCP - 0.1) / BVM < CVP - 0.05) && (BCP > 0.25)) // zatrzymanie luzowania + else if (((VVP + (BCP - 0.1) / BVM) < (CVP - 0.05)) && (BCP > 0.25)) // zatrzymanie luzowania BrakeStatus |= b_hld; if( ( BrakeStatus & b_hld ) == 0 ) SoundFlag |= sf_CylU; - if ((VVP + 0.10 < CVP) && (BCP < 0.25)) // poczatek hamowania + if (((VVP + 0.10) < CVP) && (BCP < 0.25)) // poczatek hamowania if (false == Przys_blok) { ValveRes->CreatePress(0.1 * VVP); @@ -362,7 +370,7 @@ void TNESt3::CheckState(double const BCP, double &dV1) // glowny przyrzad rozrza if (BCP > 0.5) Zamykajacy = true; - else if (VVP - 0.6 < MPP) + else if ((VVP - 0.6) < MPP) Zamykajacy = false; } @@ -375,7 +383,7 @@ void TNESt3::CheckReleaser(double const dt) // odluzniacz if ((BrakeStatus & b_rls) == b_rls) { CntrlRes->Flow(PF(CVP, 0, 0.02) * dt); - if ((CVP < VVP + 0.3) || (false == autom)) + if ((CVP < (VVP + 0.3)) || (false == autom)) BrakeStatus &= ~b_rls; } } @@ -386,9 +394,9 @@ double TNESt3::CVs(double const BP) // napelniacz sterujacego double const MPP{ Miedzypoj->P() }; // przeplyw ZS <-> PG - if (MPP < CVP - 0.17) - return 0; - else if (MPP > CVP - 0.08) + if (MPP < (CVP - 0.17)) + return 0.0; + else if (MPP > (CVP - 0.08)) return Nozzles[dSd]; else return Nozzles[dSm]; @@ -400,15 +408,16 @@ double TNESt3::BVs(double const BCP) // napelniacz pomocniczego double const MPP{ Miedzypoj->P() }; // przeplyw ZP <-> rozdzielacz - if (MPP < CVP - 0.3) + if (MPP < (CVP - 0.3)) return Nozzles[dP]; - else if (BCP < 0.5) - if ( true == Zamykajacy) - return Nozzles[dPm]; // 1.25 + else if( BCP < 0.5 ) { + if( true == Zamykajacy ) + return Nozzles[ dPm ]; // 1.25 else - return Nozzles[dPd]; + return Nozzles[ dPd ]; + } else - return 0; + return 0.0; } void TNESt3::PLC(double const mass) @@ -426,8 +435,6 @@ void TNESt3::ForceEmptiness() Miedzypoj->CreatePress(0); CntrlRes->CreatePress(0); - BrakeStatus = 0; - ValveRes->Act(); BrakeRes->Act(); Miedzypoj->Act(); @@ -461,7 +468,7 @@ void TNESt3::SetSize( int const size, std::string const ¶ms ) // ustawianie } else { - Podskok = -1; + Podskok = -1.0; Przekladniki[1] = std::make_shared(); if (params.find("-s216") != std::string::npos) Przekladniki[1]->SetRapidParams(2, 16); @@ -489,9 +496,9 @@ void TNESt3::SetSize( int const size, std::string const ¶ms ) // ustawianie else autom = true; if ((params.find("HBG300") != std::string::npos)) - HBG300 = 1; + HBG300 = 1.0; else - HBG300 = 0; + HBG300 = 0.0; switch (size) { diff --git a/McZapkie/Oerlikon_ESt.h b/McZapkie/Oerlikon_ESt.h index 88b07d27..a6b6f3d0 100644 --- a/McZapkie/Oerlikon_ESt.h +++ b/McZapkie/Oerlikon_ESt.h @@ -20,7 +20,6 @@ http://mozilla.org/MPL/2.0/. #include #include "hamulce.h" // Pascal unit #include "friction.h" // Pascal unit -#include "mctools.h" // Pascal unit /* (C) youBy @@ -133,7 +132,7 @@ class TRapid : public TPrzekladnik { class TPrzekCiagly : public TPrzekladnik { private: - double mult = 0.0; + double Mult = 0.0; public: void SetMult(double m); diff --git a/McZapkie/hamulce.cpp b/McZapkie/hamulce.cpp index 4602622c..454f58c2 100644 --- a/McZapkie/hamulce.cpp +++ b/McZapkie/hamulce.cpp @@ -16,12 +16,14 @@ Copyright (C) 2007-2014 Maciej Cierniak #include "hamulce.h" #include #include "Mover.h" +#include "utilities.h" //---FUNKCJE OGOLNE--- static double const DPL = 0.25; double const TFV4aM::pos_table[11] = {-2, 6, -1, 0, -2, 1, 4, 6, 0, 0, 0}; -double const TMHZ_EN57::pos_table[11] = {-2, 10, -1, 0, 0, 2, 9, 10, 0, 0, 0}; +double const TMHZ_EN57::pos_table[11] = {-1, 10, -1, 0, 0, 2, 9, 10, 0, 0, 0}; +double const TMHZ_K5P::pos_table[11] = { -1, 3, -1, 0, 1, 1, 2, 3, 0, 0, 0 }; double const TM394::pos_table[11] = {-1, 5, -1, 0, 1, 2, 4, 5, 0, 0, 0}; double const TH14K1::BPT_K[6][2] = {{10, 0}, {4, 1}, {0, 1}, {4, 0}, {4, -1}, {15, -1}}; double const TH14K1::pos_table[11] = {-1, 4, -1, 0, 1, 2, 3, 4, 0, 0, 0}; @@ -51,10 +53,10 @@ double PF_old(double P1, double P2, double S) double PF( double const P1, double const P2, double const S, double const DP ) { - double PH = std::max(P1, P2) + 1; // wyzsze cisnienie absolutne - double PL = P1 + P2 - PH + 2; // nizsze cisnienie absolutne - double sg = PL / PH; // bezwymiarowy stosunek cisnien - double FM = PH * 197 * S * Sign(P2 - P1); // najwyzszy mozliwy przeplyw, wraz z kierunkiem + double const PH = std::max(P1, P2) + 1.0; // wyzsze cisnienie absolutne + double const PL = P1 + P2 - PH + 2.0; // nizsze cisnienie absolutne + double const sg = PL / PH; // bezwymiarowy stosunek cisnien + double const FM = PH * 197.0 * S * Sign(P2 - P1); // najwyzszy mozliwy przeplyw, wraz z kierunkiem if (sg > 0.5) // jesli ponizej stosunku krytycznego if ((PH - PL) < DP) // niewielka roznica cisnien return (1.0 - sg) / DPL * FM * 2.0 * std::sqrt((DP) * (PH - DP)); @@ -69,15 +71,15 @@ double PF1( double const P1, double const P2, double const S ) { static double const DPS = 0.001; - double PH = std::max(P1, P2) + 1; // wyzsze cisnienie absolutne - double PL = P1 + P2 - PH + 2; // nizsze cisnienie absolutne - double sg = PL / PH; // bezwymiarowy stosunek cisnien - double FM = PH * 197 * S * Sign(P2 - P1); // najwyzszy mozliwy przeplyw, wraz z kierunkiem - if ((sg > 0.5)) // jesli ponizej stosunku krytycznego - if ((sg < DPS)) // niewielka roznica cisnien - return (1 - sg) / DPS * FM * 2 * std::sqrt((DPS) * (1 - DPS)); + double const PH = std::max(P1, P2) + 1.0; // wyzsze cisnienie absolutne + double const PL = P1 + P2 - PH + 2.0; // nizsze cisnienie absolutne + double const sg = PL / PH; // bezwymiarowy stosunek cisnien + double const FM = PH * 197.0 * S * Sign(P2 - P1); // najwyzszy mozliwy przeplyw, wraz z kierunkiem + if (sg > 0.5) // jesli ponizej stosunku krytycznego + if (sg < DPS) // niewielka roznica cisnien + return (1.0 - sg) / DPS * FM * 2.0 * std::sqrt((DPS) * (1.0 - DPS)); else - return FM * 2 * std::sqrt((sg) * (1 - sg)); + return FM * 2.0 * std::sqrt((sg) * (1.0 - sg)); else // powyzej stosunku krytycznego return FM; } @@ -90,7 +92,7 @@ double PFVa( double PH, double PL, double const S, double LIM, double const DP ) LIM = LIM + 1; PH = PH + 1; // wyzsze cisnienie absolutne PL = PL + 1; // nizsze cisnienie absolutne - double sg = PL / PH; // bezwymiarowy stosunek cisnien + double sg = std::min( 1.0, PL / PH ); // bezwymiarowy stosunek cisnien. NOTE: sg is capped at 1 to prevent calculations from going awry. TODO, TBD: log these as errors? double FM = PH * 197 * S; // najwyzszy mozliwy przeplyw, wraz z kierunkiem if ((LIM - PL) < DP) FM = FM * (LIM - PL) / DP; // jesli jestesmy przy nastawieniu, to zawor sie przymyka @@ -112,17 +114,18 @@ double PFVd( double PH, double PL, double const S, double LIM, double const DP ) if (LIM < PH) { LIM = LIM + 1; - PH = PH + 1; // wyzsze cisnienie absolutne - PL = PL + 1; // nizsze cisnienie absolutne + PH = PH + 1.0; // wyzsze cisnienie absolutne + PL = PL + 1.0; // nizsze cisnienie absolutne + assert( PH != PL ); double sg = PL / PH; // bezwymiarowy stosunek cisnien - double FM = PH * 197 * S; // najwyzszy mozliwy przeplyw, wraz z kierunkiem + double FM = PH * 197.0 * S; // najwyzszy mozliwy przeplyw, wraz z kierunkiem if ((PH - LIM) < 0.1) FM = FM * (PH - LIM) / DP; // jesli jestesmy przy nastawieniu, to zawor sie przymyka if ((sg > 0.5)) // jesli ponizej stosunku krytycznego if ((PH - PL) < DPL) // niewielka roznica cisnien - return (PH - PL) / DPL * FM * 2 * std::sqrt((sg) * (1 - sg)); + return (PH - PL) / DPL * FM * 2.0 * std::sqrt((sg) * (1.0 - sg)); else - return FM * 2 * std::sqrt((sg) * (1 - sg)); + return FM * 2.0 * std::sqrt((sg) * (1.0 - sg)); else // powyzej stosunku krytycznego return FM; } @@ -149,7 +152,7 @@ void TReservoir::Flow(double dv) void TReservoir::Act() { - Vol = Vol + dVol; + Vol = std::max( 0.0, Vol + dVol ); dVol = 0; } @@ -193,7 +196,7 @@ double TBrakeCyl::P() static double const cD = 1; static double const pD = VD - cD; - double VtoC = ( Cap > 0.0 ) ? Vol / Cap : 0.0; // stosunek cisnienia do objetosci. + double VtoC = ( Cap > 0.0 ? Vol / Cap : 0.0 ); // stosunek cisnienia do objetosci. // Added div/0 trap for vehicles with incomplete definitions (cars etc) // P:=VtoC; if (VtoC < VS) @@ -245,10 +248,6 @@ TBrake::TBrake(double i_mbp, double i_bcr, double i_bcd, double i_brc, int i_bcn NBpA = i_nbpa; BrakeDelays = i_BD; BrakeDelayFlag = bdelay_P; - DCV = false; - ASBP = 0.0; - BrakeStatus = b_hld; - SoundFlag = 0; // 210.88 // SizeBR:=i_bcn*i_bcr*i_bcr*i_bcd*40.17*MaxBP/(5-MaxBP); //objetosc ZP w stosunku do cylindra // 14" i cisnienia 4.2 atm @@ -256,7 +255,6 @@ TBrake::TBrake(double i_mbp, double i_bcr, double i_bcd, double i_brc, int i_bcn SizeBC = i_bcn * i_bcr * i_bcr * i_bcd * 210.88 * MaxBP / 4.2; // objetosc CH w stosunku do cylindra 14" i cisnienia 4.2 atm - // BrakeCyl:=TReservoir.Create; BrakeCyl = std::make_shared(); BrakeRes = std::make_shared(); ValveRes = std::make_shared(); @@ -266,7 +264,6 @@ TBrake::TBrake(double i_mbp, double i_bcr, double i_bcd, double i_brc, int i_bcn BrakeRes->CreateCap(i_brc); ValveRes->CreateCap(0.25); - // FM.Free; // materialy cierne i_mat = i_mat & (255 - bp_MHS); switch (i_mat) @@ -411,10 +408,22 @@ void TBrake::ForceEmptiness() { ValveRes->CreatePress(0); BrakeRes->CreatePress(0); + ValveRes->Act(); BrakeRes->Act(); } +// removes specified amount of air from the reservoirs +// NOTE: experimental feature, for now limited only to brake reservoir +void TBrake::ForceLeak( double const Amount ) { + + BrakeRes->Flow( -Amount * BrakeRes->P() ); + ValveRes->Flow( -Amount * ValveRes->P() * 0.01 ); // this reservoir has hard coded, tiny capacity compared to other parts + + BrakeRes->Act(); + ValveRes->Act(); +} + //---WESTINGHOUSE--- void TWest::Init( double const PP, double const HPP, double const LPP, double const BP, int const BDF ) @@ -575,47 +584,58 @@ void TESt::CheckReleaser( double const dt ) } } -void TESt::CheckState( double const BCP, double &dV1 ) -{ - double VVP; - double BVP; - double CVP; +void TESt::CheckState( double const BCP, double &dV1 ) { - BVP = BrakeRes->P(); - VVP = ValveRes->P(); - // if (BVPP() - 0.0; + double const VVP { ValveRes->P() }; + double const BVP { BrakeRes->P() }; + double const CVP { CntrlRes->P() }; // sprawdzanie stanu - if (((BrakeStatus & b_hld) == b_hld) && (BCP > 0.25)) - if ((VVP + 0.003 + BCP / BVM < CVP)) - BrakeStatus |= b_on; // hamowanie stopniowe - else if ((VVP - 0.003 + (BCP - 0.1) / BVM > CVP)) - BrakeStatus &= ~( b_on | b_hld ); // luzowanie - else if ((VVP + BCP / BVM > CVP)) - BrakeStatus &= ~b_on; // zatrzymanie napelaniania - else - ; - else if ((VVP + 0.10 < CVP) && (BCP < 0.25)) // poczatek hamowania - { - if ((BrakeStatus & b_hld) == b_off) - { - ValveRes->CreatePress(0.02 * VVP); - SoundFlag |= sf_Acc; - ValveRes->Act(); + if( BCP > 0.25 ) { + + if( ( BrakeStatus & b_hld ) == b_hld ) { + + if( ( VVP + 0.003 + BCP / BVM ) < CVP ) { + // hamowanie stopniowe + BrakeStatus |= b_on; + } + else { + if( ( VVP + BCP / BVM ) > CVP ) { + // zatrzymanie napelaniania + BrakeStatus &= ~b_on; + } + if( ( VVP - 0.003 + ( BCP - 0.1 ) / BVM ) > CVP ) { + // luzowanie + BrakeStatus &= ~( b_on | b_hld ); + } + } } - BrakeStatus |= (b_on | b_hld); + else { - // ValveRes.CreatePress(0); - // dV1:=1; + if( ( VVP + BCP / BVM < CVP ) + && ( ( CVP - VVP ) * BVM > 0.25 ) ) { + // zatrzymanie luzowanie + BrakeStatus |= b_hld; + } + } } - else if ((VVP + (BCP - 0.1) / BVM < CVP) && ((CVP - VVP) * BVM > 0.25) && - (BCP > 0.25)) // zatrzymanie luzowanie - BrakeStatus |= b_hld; + else { - if ((BrakeStatus & b_hld) == b_off) + if( VVP + 0.1 < CVP ) { + // poczatek hamowania + if( ( BrakeStatus & b_hld ) == 0 ) { + // przyspieszacz + ValveRes->CreatePress( 0.02 * VVP ); + SoundFlag |= sf_Acc; + ValveRes->Act(); + } + BrakeStatus |= ( b_on | b_hld ); + } + } + + if( ( BrakeStatus & b_hld ) == 0 ) { SoundFlag |= sf_CylU; + } } double TESt::CVs( double const BP ) @@ -755,6 +775,17 @@ double TESt::GetCRP() return CntrlRes->P(); } +void TESt::ForceEmptiness() { + + ValveRes->CreatePress( 0 ); + BrakeRes->CreatePress( 0 ); + CntrlRes->CreatePress( 0 ); + + ValveRes->Act(); + BrakeRes->Act(); + CntrlRes->Act(); +} + //---EP2--- void TEStEP2::Init( double const PP, double const HPP, double const LPP, double const BP, int const BDF ) @@ -814,6 +845,10 @@ double TEStEP2::GetPF( double const PP, double const dt, double const Vel ) else if ((VVP + BCP / BVM < CVP - 0.12) && (BCP > 0.25)) // zatrzymanie luzowanie BrakeStatus |= b_hld; + if( ( BrakeStatus & b_hld ) == 0 ) { + SoundFlag |= sf_CylU; + } + // przeplyw ZS <-> PG if ((BVP < CVP - 0.2) || (BrakeStatus != b_off) || (BCP > 0.25)) temp = 0; @@ -1184,50 +1219,77 @@ void TESt3AL2::Init( double const PP, double const HPP, double const LPP, double double TLSt::GetPF( double const PP, double const dt, double const Vel ) { double result; - double dv; - double dV1; - double temp; - double VVP; - double BVP; - double BCP; - double CVP; // ValveRes.CreatePress(LBP); // LBP:=0; - BVP = BrakeRes->P(); - VVP = ValveRes->P(); - BCP = ImplsRes->P(); - CVP = CntrlRes->P(); + double const BVP{ BrakeRes->P() }; + double const VVP{ ValveRes->P() }; + double const BCP{ ImplsRes->P() }; + double const CVP{ CntrlRes->P() }; - dv = 0; - dV1 = 0; + double dV{ 0.0 }; + double dV1{ 0.0 }; // sprawdzanie stanu - if ((BrakeStatus & b_rls) == b_rls) - if ((CVP < 0)) + // NOTE: partial copypaste from checkstate() of base class + // TODO: clean inheritance for checkstate() and checkreleaser() and reuse these instead of manual copypaste + if( ( ( BrakeStatus & b_hld ) == b_hld ) && ( BCP > 0.25 ) ) { + if( ( VVP + 0.003 + BCP / BVM < CVP ) ) { + // hamowanie stopniowe + BrakeStatus |= b_on; + } + else if( ( VVP - 0.003 + ( BCP - 0.1 ) / BVM > CVP ) ) { + // luzowanie + BrakeStatus &= ~( b_on | b_hld ); + } + else if( ( VVP + BCP / BVM > CVP ) ) { + // zatrzymanie napelaniania + BrakeStatus &= ~b_on; + } + } + else if ((VVP + 0.10 < CVP) && (BCP < 0.25)) { + // poczatek hamowania + if ((BrakeStatus & b_hld) == b_off) + { + SoundFlag |= sf_Acc; + } + BrakeStatus |= (b_on | b_hld); + } + else if( ( VVP + ( BCP - 0.1 ) / BVM < CVP ) + && ( ( CVP - VVP ) * BVM > 0.25 ) + && ( BCP > 0.25 ) ) { + // zatrzymanie luzowanie + BrakeStatus |= b_hld; + } + if( ( BrakeStatus & b_hld ) == 0 ) { + SoundFlag |= sf_CylU; + } + // equivalent of checkreleaser() in the base class? + if( ( BrakeStatus & b_rls ) == b_rls ) { + if( CVP < 0.0 ) { BrakeStatus &= ~b_rls; + } else { // 008 - dv = PF1(CVP, BCP, 0.024) * dt; - CntrlRes->Flow(+dv); - // dV1:=+dV; //minus potem jest - // ImplsRes->Flow(-dV1); + dV = PF1( CVP, BCP, 0.024 ) * dt; + CntrlRes->Flow( dV ); } + } - VVP = ValveRes->P(); // przeplyw ZS <-> PG + double temp; if (((CVP - BCP) * BVM > 0.5)) - temp = 0; + temp = 0.0; else if ((VVP > CVP + 0.4)) temp = 0.5; else temp = 0.5; - dv = PF1(CVP, VVP, 0.0015 * temp / 1.8 / 2) * dt; - CntrlRes->Flow(+dv); - ValveRes->Flow(-0.04 * dv); - dV1 = dV1 - 0.96 * dv; + dV = PF1(CVP, VVP, 0.0015 * temp / 1.8 / 2) * dt; + CntrlRes->Flow(+dV); + ValveRes->Flow(-0.04 * dV); + dV1 = dV1 - 0.96 * dV; // luzowanie KI {G} // if VVP>BCP then @@ -1236,26 +1298,38 @@ double TLSt::GetPF( double const PP, double const dt, double const Vel ) // dV:=PF(VVP,BCP,0.00020*(1.33-int((CVP-BCP)*BVM>0.65)))*dt // else dV:=0; 0.00025 P /*P*/ - if (VVP > BCP) - dv = PF(VVP, BCP, - 0.00043 * (1.5 - int(((CVP - BCP) * BVM > 1) && (BrakeDelayFlag == bdelay_G))), - 0.1) * - dt; - else if ((CVP - BCP) < 1.5) - dv = PF(VVP, BCP, - 0.001472 * (1.36 - int(((CVP - BCP) * BVM > 1) && (BrakeDelayFlag == bdelay_G))), - 0.1) * - dt; - else - dv = 0; + if( VVP > BCP ) { + dV = + PF( VVP, BCP, + 0.00043 * ( 1.5 - ( + true == ( ( ( CVP - BCP ) * BVM > 1.0 ) + && ( BrakeDelayFlag == bdelay_G ) ) ? + 1.0 : + 0.0 ) ), + 0.1 ) + * dt; + } + else if( ( CVP - BCP ) < 1.5 ) { + dV = PF( VVP, BCP, + 0.001472 * ( 1.36 - ( + true == ( ( ( CVP - BCP ) * BVM > 1.0 ) + && ( BrakeDelayFlag == bdelay_G ) ) ? + 1.0 : + 0.0 ) ), + 0.1 ) + * dt; + } + else { + dV = 0; + } - ImplsRes->Flow(-dv); - ValveRes->Flow(+dv); + ImplsRes->Flow(-dV); + ValveRes->Flow(+dV); // przeplyw PG <-> rozdzielacz - dv = PF(PP, VVP, 0.01, 0.1) * dt; - ValveRes->Flow(-dv); + dV = PF(PP, VVP, 0.01, 0.1) * dt; + ValveRes->Flow(-dV); - result = dv - dV1; + result = dV - dV1; // if Vel>55 then temp:=0.72 else // temp:=1;{R} @@ -1272,18 +1346,18 @@ double TLSt::GetPF( double const PP, double const dt, double const Vel ) if ((BrakeCyl->P() > temp + 0.005) || (temp < 0.28)) // dV:=PF(0,BrakeCyl->P(),0.0015*3*sizeBC)*dt // dV:=PF(0,BrakeCyl->P(),0.005*3*sizeBC)*dt - dv = PFVd(BrakeCyl->P(), 0, 0.005 * 7 * SizeBC, temp) * dt; + dV = PFVd(BrakeCyl->P(), 0, 0.005 * 7 * SizeBC, temp) * dt; else - dv = 0; - BrakeCyl->Flow(-dv); + dV = 0; + BrakeCyl->Flow(-dV); // przeplyw ZP <-> CH if ((BrakeCyl->P() < temp - 0.005) && (temp > 0.29)) // dV:=PF(BVP,BrakeCyl->P(),0.002*3*sizeBC*2)*dt - dv = -PFVa(BVP, BrakeCyl->P(), 0.002 * 7 * SizeBC * 2, temp) * dt; + dV = -PFVa(BVP, BrakeCyl->P(), 0.002 * 7 * SizeBC * 2, temp) * dt; else - dv = 0; - BrakeRes->Flow(dv); - BrakeCyl->Flow(-dv); + dV = 0; + BrakeRes->Flow(dV); + BrakeCyl->Flow(-dV); ImplsRes->Act(); ValveRes->Act(); @@ -1441,16 +1515,22 @@ double TEStED::GetPF( double const PP, double const dt, double const Vel ) Miedzypoj->Flow(dv * dt * 0.15); RapidTemp = - RapidTemp + (RM * int((Vel > 55) && (BrakeDelayFlag == bdelay_R)) - RapidTemp) * dt / 2; + RapidTemp + (RM * int((Vel > RV) && (BrakeDelayFlag == bdelay_R)) - RapidTemp) * dt / 2; temp = Max0R(1 - RapidTemp, 0.001); // if EDFlag then temp:=1000; // temp:=temp/(1-); // powtarzacz — podwojny zawor zwrotny temp = Max0R(LoadC * BCP / temp * Min0R(Max0R(1 - EDFlag, 0), 1), LBP); + double speed = 1; + if ((ASBP < 0.1) && ((BrakeStatus & b_asb) == b_asb)) + { + temp = 0; + speed = 3; + } if ((BrakeCyl->P() > temp)) - dv = -PFVd(BrakeCyl->P(), 0, 0.02 * SizeBC, temp) * dt; + dv = -PFVd(BrakeCyl->P(), 0, 0.02 * SizeBC * speed, temp) * dt; else if ((BrakeCyl->P() < temp)) dv = PFVa(BVP, BrakeCyl->P(), 0.02 * SizeBC, temp) * dt; else @@ -1557,6 +1637,11 @@ void TEStED::SetLP( double const TM, double const LM, double const TBP ) TareBP = TBP; } +void TEStED::SetRV(double const RVR) +{ + RV = RVR; +} + //---DAKO CV1--- void TCV1::CheckState( double const BCP, double &dV1 ) @@ -1707,6 +1792,17 @@ double TCV1::GetCRP() return CntrlRes->P(); } +void TCV1::ForceEmptiness() { + + ValveRes->CreatePress( 0 ); + BrakeRes->CreatePress( 0 ); + CntrlRes->CreatePress( 0 ); + + ValveRes->Act(); + BrakeRes->Act(); + CntrlRes->Act(); +} + //---CV1-L-TR--- void TCV1L_TR::SetLBP( double const P ) @@ -1845,22 +1941,51 @@ void TKE::CheckState( double const BCP, double &dV1 ) CVP = CntrlRes->P(); // sprawdzanie stanu - if ((BrakeStatus & b_hld) == b_hld) - if ((VVP + 0.003 + BCP / BVM < CVP)) - BrakeStatus |= b_on; // hamowanie stopniowe; - else if ((VVP - 0.003 + BCP / BVM > CVP)) - BrakeStatus &= ~( b_on | b_hld ); // luzowanie; - else if ((VVP + BCP / BVM > CVP)) - BrakeStatus &= ~b_on; // zatrzymanie napelaniania; - else - ; - else if ((VVP + 0.10 < CVP) && (BCP < 0.1)) // poczatek hamowania - { - BrakeStatus |= (b_on | b_hld); - ValveRes->CreatePress(0.8 * VVP); // przyspieszacz + if( BCP > 0.1 ) { + + if( ( BrakeStatus & b_hld ) == b_hld ) { + + if( ( VVP + 0.003 + BCP / BVM ) < CVP ) { + // hamowanie stopniowe; + BrakeStatus |= b_on; + } + else { + if( ( VVP + BCP / BVM ) > CVP ) { + // zatrzymanie napelaniania; + BrakeStatus &= ~b_on; + } + if( ( VVP - 0.003 + BCP / BVM ) > CVP ) { + // luzowanie; + BrakeStatus &= ~( b_on | b_hld ); + } + } + } + else { + + if( ( VVP + BCP / BVM < CVP ) + && ( ( CVP - VVP ) * BVM > 0.25 ) ) { + // zatrzymanie luzowanie + BrakeStatus |= b_hld; + } + } + } + else { + + if( VVP + 0.1 < CVP ) { + // poczatek hamowania + if( ( BrakeStatus & b_hld ) == 0 ) { + // przyspieszacz + ValveRes->CreatePress( 0.8 * VVP ); + SoundFlag |= sf_Acc; + ValveRes->Act(); + } + BrakeStatus |= ( b_on | b_hld ); + } + } + + if( ( BrakeStatus & b_hld ) == 0 ) { + SoundFlag |= sf_CylU; } - else if ((VVP + BCP / BVM < CVP) && ((CVP - VVP) * BVM > 0.25)) // zatrzymanie luzowanie - BrakeStatus |= b_hld; } double TKE::CVs( double const BP ) @@ -1981,7 +2106,8 @@ double TKE::GetPF( double const PP, double const dt, double const Vel ) // luzowanie CH // temp:=Max0R(BCP,LBP); IMP = Max0R(IMP / temp, Max0R(LBP, ASBP * int((BrakeStatus & b_asb) == b_asb))); - + if ((ASBP < 0.1) && ((BrakeStatus & b_asb) == b_asb)) + IMP = 0; // luzowanie CH if ((BCP > IMP + 0.005) || (Max0R(ImplsRes->P(), 8 * LBP) < 0.25)) dv = PFVd(BCP, 0, 0.05, IMP) * dt; @@ -2076,6 +2202,21 @@ void TKE::SetLBP( double const P ) LBP = P; } +void TKE::ForceEmptiness() { + + ValveRes->CreatePress( 0 ); + BrakeRes->CreatePress( 0 ); + CntrlRes->CreatePress( 0 ); + ImplsRes->CreatePress( 0 ); + Brak2Res->CreatePress( 0 ); + + ValveRes->Act(); + BrakeRes->Act(); + CntrlRes->Act(); + ImplsRes->Act(); + Brak2Res->Act(); +} + //---KRANY--- double TDriverHandle::GetPF(double const i_bcp, double PP, double HP, double dt, double ep) @@ -2118,39 +2259,34 @@ double TFV4a::GetPF(double i_bcp, double PP, double HP, double dt, double ep) { static int const LBDelay = 100; - double LimPP; - double dpPipe; - double dpMainValve; - double ActFlowSpeed; - ep = PP; // SPKS!! - LimPP = Min0R(BPT[lround(i_bcp) + 2][1], HP); - ActFlowSpeed = BPT[lround(i_bcp) + 2][0]; + double LimPP = std::min(BPT[std::lround(i_bcp) + 2][1], HP); + double ActFlowSpeed = BPT[std::lround(i_bcp) + 2][0]; if ((i_bcp == i_bcpno)) LimPP = 2.9; - CP = CP + 20 * Min0R(abs(LimPP - CP), 0.05) * PR(CP, LimPP) * dt / 1; - RP = RP + 20 * Min0R(abs(ep - RP), 0.05) * PR(RP, ep) * dt / 2.5; + CP = CP + 20 * std::min(std::abs(LimPP - CP), 0.05) * PR(CP, LimPP) * dt / 1; + RP = RP + 20 * std::min(std::abs(ep - RP), 0.05) * PR(RP, ep) * dt / 2.5; LimPP = CP; - dpPipe = Min0R(HP, LimPP); + double dpPipe = std::min(HP, LimPP); - dpMainValve = PF(dpPipe, PP, ActFlowSpeed / LBDelay) * dt; + double dpMainValve = PF(dpPipe, PP, ActFlowSpeed / LBDelay) * dt; if ((CP > RP + 0.05)) - dpMainValve = PF(Min0R(CP + 0.1, HP), PP, 1.1 * ActFlowSpeed / LBDelay) * dt; + dpMainValve = PF(std::min(CP + 0.1, HP), PP, 1.1 * ActFlowSpeed / LBDelay) * dt; if ((CP < RP - 0.05)) dpMainValve = PF(CP - 0.1, PP, 1.1 * ActFlowSpeed / LBDelay) * dt; if (lround(i_bcp) == -1) { - CP = CP + 5 * Min0R(abs(LimPP - CP), 0.2) * PR(CP, LimPP) * dt / 2; + CP = CP + 5 * std::min(std::abs(LimPP - CP), 0.2) * PR(CP, LimPP) * dt / 2; if ((CP < RP + 0.03)) if ((TP < 5)) TP = TP + dt; // if(cp+0.03<5.4)then if ((RP + 0.03 < 5.4) || (CP + 0.03 < 5.4)) // fala - dpMainValve = PF(Min0R(HP, 17.1), PP, ActFlowSpeed / LBDelay) * dt; + dpMainValve = PF(std::min(HP, 17.1), PP, ActFlowSpeed / LBDelay) * dt; // dpMainValve:=20*Min0R(abs(ep-7.1),0.05)*PF(HP,pp,ActFlowSpeed/LBDelay)*dt; else { @@ -2170,9 +2306,9 @@ double TFV4a::GetPF(double i_bcp, double PP, double HP, double dt, double ep) TP = TP - dt / 12 / 2; } if ((CP > RP + 0.1) && (CP <= 5)) - dpMainValve = PF(Min0R(CP + 0.25, HP), PP, 2 * ActFlowSpeed / LBDelay) * dt; + dpMainValve = PF(std::min(CP + 0.25, HP), PP, 2 * ActFlowSpeed / LBDelay) * dt; else if (CP > 5) - dpMainValve = PF(Min0R(CP, HP), PP, 2 * ActFlowSpeed / LBDelay) * dt; + dpMainValve = PF(std::min(CP, HP), PP, 2 * ActFlowSpeed / LBDelay) * dt; else dpMainValve = PF(dpPipe, PP, ActFlowSpeed / LBDelay) * dt; } @@ -2195,127 +2331,145 @@ void TFV4a::Init(double Press) double TFV4aM::GetPF(double i_bcp, double PP, double HP, double dt, double ep) { - static int const LBDelay = 100; - static double const xpM = 0.3; // mnoznik membrany komory pod + int const LBDelay { 100 }; + double const xpM { 0.3 }; // mnoznik membrany komory pod - double LimPP; - double dpPipe; - double dpMainValve; - double ActFlowSpeed; - double DP; - double pom; - int i; + ep = (PP / 2.0) * 1.5 + (ep / 2.0) * 0.5; // SPKS!! - ep = PP / 2 * 1.5 + ep / 2 * 0.5; // SPKS!! - // ep:=pp; - // ep:=cp/3+pp/3+ep/3; - // ep:=cp; + for( int idx = 0; idx < 5; ++idx ) { + Sounds[ idx ] = 0; + } - for (i = 0; i < 5; ++i) - Sounds[i] = 0; - DP = 0; + // na wszelki wypadek, zeby nie wyszlo poza zakres + i_bcp = clamp( i_bcp, -1.999, 5.999 ); - i_bcp = Max0R(Min0R(i_bcp, 5.999), -1.999); // na wszelki wypadek, zeby nie wyszlo poza zakres - - if ((TP > 0)) - { // jesli czasowy jest niepusty - // dp:=0.07; //od cisnienia 5 do 0 w 60 sekund ((5-0)*dt/75) + double DP{ 0.0 }; + if( TP > 0.0 ) { + // jesli czasowy jest niepusty DP = 0.045; // 2.5 w 55 sekund (5,35->5,15 w PG) - TP = TP - DP * dt; + TP -= DP * dt; Sounds[s_fv4a_t] = DP; } - else //.08 - { - TP = 0; + else { + //.08 + TP = 0.0; } - if ((XP > 0)) // jesli komora pod niepusta jest niepusty - { + if (XP > 0) { + // jesli komora pod niepusta jest niepusty DP = 2.5; Sounds[s_fv4a_x] = DP * XP; - XP = XP - dt * DP * 2; // od cisnienia 5 do 0 w 10 sekund ((5-0)*dt/10) + XP -= dt * DP * 2.0; // od cisnienia 5 do 0 w 10 sekund ((5-0)*dt/10) + } + else { + // jak pusty, to pusty + XP = 0.0; } - else //.75 - XP = 0; // jak pusty, to pusty - LimPP = Min0R(LPP_RP(i_bcp) + TP * 0.08 + RedAdj, HP); // pozycja + czasowy lub zasilanie - ActFlowSpeed = BPT[lround(i_bcp) + 2][0]; + double pom; + if( EQ( i_bcp, -1.0 ) ) { + pom = std::min( HP, 5.4 + RedAdj ); + } + else { + pom = std::min( CP, HP ); + } - if ((EQ(i_bcp, -1))) - pom = Min0R(HP, 5.4 + RedAdj); - else - pom = Min0R(CP, HP); - - if ((pom > RP + 0.25)) + if( pom > RP + 0.25 ) { Fala = true; - if ((Fala)) - if ((pom > RP + 0.3)) - // if(ep>rp+0.11)then - XP = XP - 20 * PR(pom, XP) * dt; - // else - // xp:=xp-16*(ep-(ep+0.01))/(0.1)*PR(ep,xp)*dt; - else + } + if( Fala ) { + if( pom > RP + 0.3 ) { + XP = XP - 20.0 * PR( pom, XP ) * dt; + } + else { Fala = false; + } + } - if ((LimPP > CP)) // podwyzszanie szybkie - CP = CP + 5 * 60 * Min0R(abs(LimPP - CP), 0.05) * PR(CP, LimPP) * dt; // zbiornik sterujacy; - else - CP = CP + 13 * Min0R(abs(LimPP - CP), 0.05) * PR(CP, LimPP) * dt; // zbiornik sterujacy + double LimPP = std::min( + LPP_RP( i_bcp ) + TP * 0.08 + RedAdj, + HP ); // pozycja + czasowy lub zasilanie + + // zbiornik sterujacy + if( LimPP > CP ) { + // podwyzszanie szybkie + CP += + 5.0 * 60.0 + * std::min( + std::abs( LimPP - CP ), + 0.05 ) + * PR( CP, LimPP ) + * dt; + } + else { + CP += + 13 + * std::min( + std::abs( LimPP - CP ), + 0.05 ) + * PR( CP, LimPP ) + * dt; + } LimPP = pom; // cp - dpPipe = Min0R(HP, LimPP + XP * xpM); + double const dpPipe = std::min(HP, LimPP + XP * xpM); - if (dpPipe > PP) - dpMainValve = -PFVa(HP, PP, ActFlowSpeed / LBDelay, dpPipe, 0.4); - else - dpMainValve = PFVd(PP, 0, ActFlowSpeed / LBDelay, dpPipe, 0.4); + double const ActFlowSpeed = BPT[ std::lround( i_bcp ) + 2 ][ 0 ]; - if (EQ(i_bcp, -1)) - { - if ((TP < 5)) - TP = TP + dt; // 5/10 - if ((TP < 1)) - TP = TP - 0.5 * dt; // 5/10 - // dpMainValve:=dpMainValve*2; - //+1*PF(dpPipe,pp,ActFlowSpeed/LBDelay)//coby - // nie przeszkadzal przy ladowaniu z zaworu obok + double dpMainValve = ( + dpPipe > PP ? + -PFVa( HP, PP, ActFlowSpeed / LBDelay, dpPipe, 0.4 ) : + PFVd( PP, 0, ActFlowSpeed / LBDelay, dpPipe, 0.4 ) ); + + if (EQ(i_bcp, -1)) { + + if( TP < 5 ) { TP += dt; } + if( TP < 1 ) { TP -= 0.5 * dt; } } - if (EQ(i_bcp, 0)) - { - if ((TP > 2)) - dpMainValve = dpMainValve * 1.5; //+0.5*PF(dpPipe,pp,ActFlowSpeed/LBDelay)//coby nie - // przeszkadzal przy ladowaniu z zaworu obok + if (EQ(i_bcp, 0)) { + + if( TP > 2 ) { + dpMainValve *= 1.5; + } } ep = dpPipe; - if ((EQ(i_bcp, 0) || (RP > ep))) - RP = RP + PF(RP, ep, 0.0007) * dt; // powolne wzrastanie, ale szybsze na jezdzie; - else - RP = RP + PF(RP, ep, 0.000093 / 2 * 2) * dt; // powolne wzrastanie i to bardzo - // jednak trzeba wydluzyc, bo - // obecnie zle dziala - if ((RP < ep) && - (RP < - BPT[lround(i_bcpno) + 2][1])) // jesli jestesmy ponizej cisnienia w sterujacym (2.9 bar) - RP = RP + PF(RP, CP, 0.005) * dt; // przypisz cisnienie w PG - wydluzanie napelniania o czas - // potrzebny do napelnienia PG + if( ( EQ( i_bcp, 0 ) + || ( RP > ep ) ) ) { + // powolne wzrastanie, ale szybsze na jezdzie; + RP += PF( RP, ep, 0.0007 ) * dt; + } + else { + // powolne wzrastanie i to bardzo + RP += PF( RP, ep, 0.000093 / 2 * 2 ) * dt; + } + // jednak trzeba wydluzyc, bo obecnie zle dziala + if( ( RP < ep ) + && ( RP < BPT[ std::lround( i_bcpno ) + 2 ][ 1 ] ) ) { + // jesli jestesmy ponizej cisnienia w sterujacym (2.9 bar) + // przypisz cisnienie w PG - wydluzanie napelniania o czas potrzebny do napelnienia PG + RP += PF( RP, CP, 0.005 ) * dt; + } - if ((EQ(i_bcp, i_bcpno)) || (EQ(i_bcp, -2))) - { - DP = PF(0, PP, ActFlowSpeed / LBDelay); + if( ( EQ( i_bcp, i_bcpno ) ) + || ( EQ( i_bcp, -2 ) ) ) { + + DP = PF( 0.0, PP, ActFlowSpeed / LBDelay ); dpMainValve = DP; Sounds[s_fv4a_e] = DP; - Sounds[s_fv4a_u] = 0; - Sounds[s_fv4a_b] = 0; - Sounds[s_fv4a_x] = 0; + Sounds[s_fv4a_u] = 0.0; + Sounds[s_fv4a_b] = 0.0; + Sounds[s_fv4a_x] = 0.0; } - else - { - if (dpMainValve > 0) - Sounds[s_fv4a_b] = dpMainValve; - else - Sounds[s_fv4a_u] = -dpMainValve; + else { + + if( dpMainValve > 0.0 ) { + Sounds[ s_fv4a_b ] = dpMainValve; + } + else { + Sounds[ s_fv4a_u ] = -dpMainValve; + } } return dpMainValve * dt; @@ -2345,29 +2499,27 @@ double TFV4aM::GetPos(int i) return pos_table[i]; } +double TFV4aM::GetCP() +{ + return TP; +} + double TFV4aM::LPP_RP(double pos) // cisnienie z zaokraglonej pozycji; { - int i_pos; + int const i_pos = 2 + std::floor( pos ); // zaokraglone w dol - i_pos = lround(pos - 0.5) + 2; // zaokraglone w dol - double i, j, k, l; - i = BPT[i_pos][1]; - j = BPT[i_pos + 1][1]; - k = pos + 2 - i_pos; - l = i + (j - i) * k; - double r = BPT[i_pos][1] + - (BPT[i_pos + 1][1] - BPT[i_pos][1]) * (pos + 2 - i_pos); // interpolacja liniowa - return r; + return + BPT[i_pos][1] + + (BPT[i_pos + 1][1] - BPT[i_pos][1]) * ((pos + 2) - i_pos); // interpolacja liniowa } bool TFV4aM::EQ(double pos, double i_pos) { return (pos <= i_pos + 0.5) && (pos > i_pos - 0.5); } -//---FV4a/M--- nowonapisany kran bez poprawki IC +//---MHZ_EN57--- manipulator hamulca zespolonego do EN57 -double TMHZ_EN57::GetPF(double i_bcp, double PP, double HP, double dt, double ep) -{ +double TMHZ_EN57::GetPF( double i_bcp, double PP, double HP, double dt, double ep ) { static int const LBDelay = 100; double LimPP; @@ -2376,13 +2528,11 @@ double TMHZ_EN57::GetPF(double i_bcp, double PP, double HP, double dt, double ep double ActFlowSpeed; double DP; double pom; - int i; - { - long i_end = 5; - for (i = 0; i < i_end; ++i) - Sounds[i] = 0; + for( int idx = 0; idx < 5; ++idx ) { + Sounds[ idx ] = 0; } + DP = 0; i_bcp = Max0R(Min0R(i_bcp, 9.999), -0.999); // na wszelki wypadek, zeby nie wyszlo poza zakres @@ -2507,6 +2657,119 @@ bool TMHZ_EN57::EQ(double pos, double i_pos) return (pos <= i_pos + 0.5) && (pos > i_pos - 0.5); } +//---MHZ_K5P--- manipulator hamulca zespolonego Knorr 5-ciopozycyjny + +double TMHZ_K5P::GetPF(double i_bcp, double PP, double HP, double dt, double ep) { + static int const LBDelay = 100; + + double LimPP; + double dpPipe; + double dpMainValve; + double ActFlowSpeed; + double DP; + double pom; + + for (int idx = 0; idx < 5; ++idx) { + Sounds[idx] = 0; + } + + DP = 0; + + i_bcp = Max0R(Min0R(i_bcp, 2.999), -0.999); // na wszelki wypadek, zeby nie wyszlo poza zakres + + if ((TP > 0)) + { + DP = 0.004; + TP = TP - DP * dt; + Sounds[s_fv4a_t] = DP; + } + else + { + TP = 0; + } + + if (EQ(i_bcp, 1)) //odcięcie - nie rób nic + LimPP = CP; + else if (i_bcp > 1) //hamowanie + LimPP = 3.4; + else //luzowanie + LimPP = 5.0; + pom = CP; + LimPP = Min0R(LimPP + TP + RedAdj, HP); // pozycja + czasowy lub zasilanie + ActFlowSpeed = 4; + + if ((LimPP > CP)) // podwyzszanie szybkie + CP = CP + 9 * Min0R(abs(LimPP - CP), 0.05) * PR(CP, LimPP) * dt; // zbiornik sterujacy; + else + CP = CP + 9 * Min0R(abs(LimPP - CP), 0.05) * PR(CP, LimPP) * dt; // zbiornik sterujacy + + LimPP = pom; // cp + dpPipe = Min0R(HP, LimPP); + + if (dpPipe > PP) + dpMainValve = -PFVa(HP, PP, ActFlowSpeed / LBDelay, dpPipe, 0.4); + else + dpMainValve = PFVd(PP, 0, ActFlowSpeed / LBDelay, dpPipe, 0.4); + + if (EQ(i_bcp, -1)) + { + if ((TP < 1)) + TP = TP + 0.03 * dt; + } + + if (EQ(i_bcp, 3)) + { + DP = PF(0, PP, 2 * ActFlowSpeed / LBDelay); + dpMainValve = DP; + Sounds[s_fv4a_e] = DP; + Sounds[s_fv4a_u] = 0; + Sounds[s_fv4a_b] = 0; + Sounds[s_fv4a_x] = 0; + } + else + { + if (dpMainValve > 0) + Sounds[s_fv4a_b] = dpMainValve; + else + Sounds[s_fv4a_u] = -dpMainValve; + } + + return dpMainValve * dt; +} + +void TMHZ_K5P::Init(double Press) +{ + CP = Press; +} + +void TMHZ_K5P::SetReductor(double nAdj) +{ + RedAdj = nAdj; +} + +double TMHZ_K5P::GetSound(int i) +{ + if (i > 4) + return 0; + else + return Sounds[i]; +} + +double TMHZ_K5P::GetPos(int i) +{ + return pos_table[i]; +} + +double TMHZ_K5P::GetCP() +{ + return RP; +} + +bool TMHZ_K5P::EQ(double pos, double i_pos) +{ + return (pos <= i_pos + 0.5) && (pos > i_pos - 0.5); +} + //---M394--- Matrosow double TM394::GetPF(double i_bcp, double PP, double HP, double dt, double ep) diff --git a/McZapkie/hamulce.h b/McZapkie/hamulce.h index 962b6a87..07134e18 100644 --- a/McZapkie/hamulce.h +++ b/McZapkie/hamulce.h @@ -35,7 +35,6 @@ Knorr/West EP - żeby był #pragma once #include "friction.h" // Pascal unit -#include "mctools.h" // Pascal unit static int const LocalBrakePosNo = 10; /*ilosc nastaw hamulca recznego lub pomocniczego*/ static int const MainBrakeMaxPos = 10; /*max. ilosc nastaw hamulca zasadniczego*/ @@ -45,7 +44,6 @@ static int const bdelay_G = 1; //G static int const bdelay_P = 2; //P static int const bdelay_R = 4; //R static int const bdelay_M = 8; //Mg -static int const bdelay_GR = 128; //G-R /*stan hamulca*/ @@ -137,10 +135,10 @@ static int const i_bcpno = 6; //klasa obejmujaca pojedyncze zbiorniki class TReservoir { - protected: - double Cap = 1.0; - double Vol = 0.0; - double dVol = 0.0; +protected: + double Cap{ 1.0 }; + double Vol{ 0.0 }; + double dVol{ 0.0 }; public: void CreateCap(double Capacity); @@ -185,7 +183,7 @@ class TBrake { bool DCV = false; //podwojny zawor zwrotny double ASBP = 0.0; //cisnienie hamulca pp - int BrakeStatus = 0; //flaga stanu + int BrakeStatus{ b_off }; //flaga stanu int SoundFlag = 0; public: @@ -206,6 +204,7 @@ class TBrake { void Releaser( int const state ); //odluzniacz virtual void SetEPS( double const nEPS ); //hamulec EP virtual void SetRM( double const RMR ) {}; //ustalenie przelozenia rapida + virtual void SetRV( double const RVR) {}; //ustalenie przelozenia rapida virtual void SetLP(double const TM, double const LM, double const TBP) {}; //parametry przystawki wazacej virtual void SetLBP(double const P) {}; //cisnienie z hamulca pomocniczego virtual void PLC(double const mass) {}; //wspolczynnik cisnienia przystawki wazacej @@ -213,7 +212,11 @@ class TBrake { int GetStatus(); //flaga statusu, moze sie przydac do odglosow void SetASBP( double const Press ); //ustalenie cisnienia pp virtual void ForceEmptiness(); + // removes specified amount of air from the reservoirs + virtual void ForceLeak( double const Amount ); int GetSoundFlag(); + int GetBrakeStatus() const { return BrakeStatus; } + void SetBrakeStatus( int const Status ) { BrakeStatus = Status; } virtual void SetED( double const EDstate ) {}; //stan hamulca ED do luzowania }; @@ -259,6 +262,7 @@ class TESt : public TBrake { void CheckReleaser(double dt); //odluzniacz double CVs(double BP); //napelniacz sterujacego double BVs(double BCP); //napelniacz pomocniczego + void ForceEmptiness() /*override*/; // wymuszenie bycia pustym inline TESt(double i_mbp, double i_bcr, double i_bcd, double i_brc, int i_bcn, int i_BD, int i_mat, int i_ba, int i_nbpa) : TBrake( i_mbp, i_bcr, i_bcd, i_brc, i_bcn, i_BD, i_mat, i_ba, i_nbpa) @@ -330,6 +334,7 @@ class TLSt : public TESt4R { protected: double LBP = 0.0; //cisnienie hamulca pomocniczego double RM = 0.0; //przelozenie rapida + double RV = 0.0; double EDFlag = 0.0; //luzowanie hamulca z powodu zalaczonego ED public: @@ -365,6 +370,7 @@ class TEStED : public TLSt { //zawor z EP09 - Est4 z oddzielnym przekladnikiem, double GetEDBCP()/*override*/; //cisnienie tylko z hamulca zasadniczego, uzywane do hamulca ED void PLC(double const mass); //wspolczynnik cisnienia przystawki wazacej void SetLP( double const TM, double const LM, double const TBP ); //parametry przystawki wazacej + void SetRV(double const RVR); //ustalenie predkosci przelaczenia rapida inline TEStED(double i_mbp, double i_bcr, double i_bcd, double i_brc, int i_bcn, int i_BD, int i_mat, int i_ba, int i_nbpa) : TLSt( i_mbp, i_bcr, i_bcd, i_brc, i_bcn, i_BD, i_mat, i_ba, i_nbpa) @@ -409,6 +415,7 @@ public: void CheckState( double const BCP, double &dV1 ); double CVs( double const BP ); double BVs( double const BCP ); + void ForceEmptiness() /*override*/; // wymuszenie bycia pustym inline TCV1(double i_mbp, double i_bcr, double i_bcd, double i_brc, int i_bcn, int i_BD, int i_mat, int i_ba, int i_nbpa) : TBrake( i_mbp, i_bcr, i_bcd, i_brc, i_bcn, i_BD, i_mat, i_ba, i_nbpa) @@ -481,6 +488,7 @@ class TKE : public TBrake { //Knorr Einheitsbauart — jeden do wszystkiego void PLC( double const mass ); //wspolczynnik cisnienia przystawki wazacej void SetLP( double const TM, double const LM, double const TBP ); //parametry przystawki wazacej void SetLBP( double const P ); //cisnienie z hamulca pomocniczego + void ForceEmptiness() /*override*/; // wymuszenie bycia pustym inline TKE(double i_mbp, double i_bcr, double i_bcd, double i_brc, int i_bcn, int i_BD, int i_mat, int i_ba, int i_nbpa) : TBrake( i_mbp, i_bcr, i_bcd, i_brc, i_bcn, i_BD, i_mat, i_ba, i_nbpa) @@ -500,7 +508,7 @@ class TDriverHandle { public: bool Time = false; bool TimeEP = false; - double Sounds[ 5 ]; //wielkosci przeplywow dla dzwiekow + double Sounds[ 5 ]; //wielkosci przeplywow dla dzwiekow virtual double GetPF(double i_bcp, double PP, double HP, double dt, double ep); virtual void Init(double Press); @@ -509,6 +517,8 @@ class TDriverHandle { virtual double GetSound(int i); virtual double GetPos(int i); virtual double GetEP(double pos); + + inline TDriverHandle() { memset( Sounds, 0, sizeof( Sounds ) ); } }; class TFV4a : public TDriverHandle { @@ -548,7 +558,7 @@ class TFV4aM : public TDriverHandle { void SetReductor(double nAdj)/*override*/; double GetSound(int i)/*override*/; double GetPos(int i)/*override*/; - + double GetCP(); inline TFV4aM() : TDriverHandle() {} @@ -581,6 +591,31 @@ class TMHZ_EN57 : public TDriverHandle { {} }; +class TMHZ_K5P : public TDriverHandle { + +private: + double CP = 0.0; //zbiornik sterujący + double TP = 0.0; //zbiornik czasowy + double RP = 0.0; //zbiornik redukcyjny + double RedAdj = 0.0; //dostosowanie reduktora cisnienia (krecenie kapturkiem) + bool Fala = false; + static double const pos_table[11]; //= { -2, 10, -1, 0, 0, 2, 9, 10, 0, 0, 0 }; + + bool EQ(double pos, double i_pos); + +public: + double GetPF(double i_bcp, double PP, double HP, double dt, double ep)/*override*/; + void Init(double Press)/*override*/; + void SetReductor(double nAdj)/*override*/; + double GetSound(int i)/*override*/; + double GetPos(int i)/*override*/; + double GetCP()/*override*/; + + inline TMHZ_K5P(void) : + TDriverHandle() + {} +}; + /* FBS2= class(TTDriverHandle) private CP, TP, RP: real; //zbiornik sterujący, czasowy, redukcyjny diff --git a/McZapkie/mctools.cpp b/McZapkie/mctools.cpp deleted file mode 100644 index 2c751394..00000000 --- a/McZapkie/mctools.cpp +++ /dev/null @@ -1,541 +0,0 @@ -/* -This Source Code Form is subject to the -terms of the Mozilla Public License, v. -2.0. If a copy of the MPL was not -distributed with this file, You can -obtain one at -http://mozilla.org/MPL/2.0/. -*/ -/* -MaSzyna EU07 - SPKS -Brakes. -Copyright (C) 2007-2014 Maciej Cierniak -*/ -#include "stdafx.h" -#include "mctools.h" -#include "Globals.h" - -/*================================================*/ - -int ConversionError = 0; -int LineCount = 0; -bool DebugModeFlag = false; -bool FreeFlyModeFlag = false; - -//std::string Ups(std::string s) -//{ -// int jatka; -// std::string swy; -// -// swy = ""; -// { -// long jatka_end = s.length() + 1; -// for (jatka = 0; jatka < jatka_end; jatka++) -// swy = swy + UpCase(s[jatka]); -// } -// return swy; -//} /*=Ups=*/ - -int Max0(int x1, int x2) -{ - if (x1 > x2) - return x1; - else - return x2; -} - -int Min0(int x1, int x2) -{ - if (x1 < x2) - return x1; - else - return x2; -} - -double Max0R(double x1, double x2) -{ - if (x1 > x2) - return x1; - else - return x2; -} - -double Min0R(double x1, double x2) -{ - if (x1 < x2) - return x1; - else - return x2; -} - -// shitty replacement for Borland timestamp function -// TODO: replace with something sensible -std::string Now() { - - std::time_t timenow = std::time( nullptr ); - std::tm tm = *std::localtime( &timenow ); - std::stringstream converter; - std::string output; - converter << std::put_time( &tm, "%c" ); - converter >> output; - return output; - -/* char buffer[ 256 ]; - sprintf( buffer, - "%d-%02d-%02d %02d:%02d:%02d.%03d", - st.wYear, - st.wMonth, - st.wDay, - st.wHour, - st.wMinute, - st.wSecond, - st.wMilliseconds ); -*/ -} - -bool TestFlag(int Flag, int Value) -{ - if ((Flag & Value) == Value) - return true; - else - return false; -} - -bool SetFlag(int &Flag, int Value) -{ - return iSetFlag(Flag, Value); -} - -bool iSetFlag(int &Flag, int Value) -{ - if (Value > 0) - { - if ((Flag & Value) == 0) - { - Flag |= Value; - return true; // true, gdy było wcześniej 0 i zostało ustawione - } - } - else if (Value < 0) - { - Value = abs(Value); - if ((Flag & Value) == Value) - { - Flag &= ~Value; // Value jest ujemne, czyli zerowanie flagi - return true; // true, gdy było wcześniej 1 i zostało wyzerowane - } - } - return false; -} - -bool UnSetFlag(int &Flag, int Value) -{ - Flag &= ~Value; - return true; -} - -inline double Random(double a, double b) -{ - std::uniform_real_distribution<> dis(a, b); - return dis(Global::random_engine); -} - -bool FuzzyLogic(double Test, double Threshold, double Probability) -{ - if ((Test > Threshold) && (!DebugModeFlag)) - return - (Random() < Probability * Threshold * 1.0 / Test) /*im wiekszy Test tym wieksza szansa*/; - else - return false; -} - -bool FuzzyLogicAI(double Test, double Threshold, double Probability) -{ - if ((Test > Threshold)) - return - (Random() < Probability * Threshold * 1.0 / Test) /*im wiekszy Test tym wieksza szansa*/; - else - return false; -} - -std::string ReadWord(std::ifstream &infile) -{ - std::string s = ""; - char c; - bool nextword = false; - - while ((!infile.eof()) && (!nextword)) - { - infile.get(c); - if (_spacesigns.find(c) != std::string::npos) - if (s != "") - nextword = true; - if (_spacesigns.find(c) == std::string::npos) - s += c; - } - return s; -} - -std::string TrimSpace(std::string &s) -{ - /*int ii; - - switch (Just) - { - case CutLeft: - { - ii = 0; - while ((ii < s.length()) && (s[ii + 1] == (char)" ")) - ++ii; - s = s.substr(ii + 1, s.length() - ii); - } - case CutRight: - { - ii = s.length(); - while ((ii > 0) && (s[ii] == (char)" ")) - --ii; - s = s.substr(0, ii); - } - case CutBoth: - { - s = TrimSpace(s, CutLeft); - s = TrimSpace(s, CutRight); - } - } - return s;*/ - - if (s.empty()) - return ""; - size_t first = s.find_first_not_of(' '); - if (first == std::string::npos) - return ""; - size_t last = s.find_last_not_of(' '); - return s.substr(first, (last - first + 1)); -} - -char* TrimAndReduceSpaces(const char* s) -{ // redukuje spacje pomiedzy znakami do jednej - char* tmp = nullptr; - if (s) - { - - tmp = _strdup(s); - char* from = tmp + strspn(tmp, " "); - char* to = tmp; - - do if ((*to = *from++) == ' ') - from += strspn(from, " "); - while (*to++); - - while (*--to == ' ') - *to = '\0'; - } - return tmp; -} - -std::string ExtractKeyWord(std::string InS, std::string KeyWord) -{ - std::string s; - InS = InS + " "; - std::size_t kwp = InS.find(KeyWord); - if (kwp != std::string::npos) - { - s = InS.substr(kwp, InS.length()); - //s = Copy(InS, kwp, length(InS)); - s = s.substr(0, s.find_first_of(" ")); - //s = Copy(s, 1, Pos(" ", s) - 1); - } - else - s = ""; - return s; -} - -std::string DUE(std::string s) /*Delete Before Equal sign*/ -{ - //DUE = Copy(s, Pos("=", s) + 1, length(s)); - return s.substr(s.find("=") + 1, s.length()); -} - -std::string DWE(std::string s) /*Delete After Equal sign*/ -{ - size_t ep = s.find("="); - if (ep != std::string::npos) - //DWE = Copy(s, 1, ep - 1); - return s.substr(0, ep); - else - return s; -} - -std::string ExchangeCharInString( std::string const &Source, char const &From, char const &To ) -{ - std::string replacement; replacement.reserve( Source.size() ); - std::for_each(Source.cbegin(), Source.cend(), [&](char const idx) { - if( idx != From ) { replacement += idx; } - else { - if( To != NULL ) { replacement += To; } } - } ); - - return replacement; -} - -std::vector &Split(const std::string &s, char delim, std::vector &elems) -{ // dzieli tekst na wektor tekstow - - std::stringstream ss(s); - std::string item; - while (std::getline(ss, item, delim)) - { - elems.push_back(item); - } - return elems; -} - -std::vector Split(const std::string &s, char delim) -{ // dzieli tekst na wektor tekstow - std::vector elems; - Split(s, delim, elems); - return elems; -} - -std::vector Split(const std::string &s) -{ // dzieli tekst na wektor tekstow po białych znakach - std::vector elems; - std::stringstream ss(s); - std::string item; - while (ss >> item) - { - elems.push_back(item); - } - return elems; -} - -std::string to_string(int _Val) -{ - std::ostringstream o; - o << _Val; - return o.str(); -}; - -std::string to_string(unsigned int _Val) -{ - std::ostringstream o; - o << _Val; - return o.str(); -}; - -std::string to_string(double _Val) -{ - std::ostringstream o; - o << _Val; - return o.str(); -}; - -std::string to_string(int _Val, int precision) -{ - std::ostringstream o; - o << std::fixed << std::setprecision(precision); - o << _Val; - return o.str(); -}; - -std::string to_string(double _Val, int precision) -{ - std::ostringstream o; - o << std::fixed << std::setprecision(precision); - o << _Val; - return o.str(); -}; - -std::string to_string(int _Val, int precision, int width) -{ - std::ostringstream o; - o.width(width); - o << std::fixed << std::setprecision(precision); - o << _Val; - return o.str(); -}; - -std::string to_string(double const Value, int const Precision, int const Width) -{ - std::ostringstream converter; - converter << std::setw( Width ) << std::fixed << std::setprecision(Precision) << Value; - return converter.str(); -}; - -std::string to_hex_str( int const Value, int const Width ) -{ - std::ostringstream converter; - converter << "0x" << std::uppercase << std::setfill( '0' ) << std::setw( Width ) << std::hex << Value; - return converter.str(); -}; - -int stol_def(const std::string &str, const int &DefaultValue) -{ - int result { DefaultValue }; - std::stringstream converter; - converter << str; - converter >> result; - return result; -/* - // this function was developed iteratively on Codereview.stackexchange - // with the assistance of @Corbin - std::size_t len = str.size(); - while (std::isspace(str[len - 1])) - len--; - if (len == 0) - return DefaultValue; - errno = 0; - char *s = new char[len + 1]; - std::strncpy(s, str.c_str(), len); - char *p; - int result = strtol(s, &p, 0); - delete[] s; - if( ( *p != '\0' ) || ( errno != 0 ) ) - { - return DefaultValue; - } - return result; -*/ -} - -std::string ToLower(std::string const &text) -{ - std::string lowercase( text ); - std::transform(text.begin(), text.end(), lowercase.begin(), ::tolower); - return lowercase; -} - -std::string ToUpper(std::string const &text) -{ - std::string uppercase( text ); - std::transform(text.begin(), text.end(), uppercase.begin(), ::toupper); - return uppercase; -} - -// replaces polish letters with basic ascii -void -win1250_to_ascii( std::string &Input ) { - - std::unordered_map charmap{ - { 165, 'A' }, { 198, 'C' }, { 202, 'E' }, { 163, 'L' }, { 209, 'N' }, { 211, 'O' }, { 140, 'S' }, { 143, 'Z' }, { 175, 'Z' }, - { 185, 'a' }, { 230, 'c' }, { 234, 'e' }, { 179, 'l' }, { 241, 'n' }, { 243, 'o' }, { 156, 's' }, { 159, 'z' }, { 191, 'z' } - }; - std::unordered_map::const_iterator lookup; - for( auto &input : Input ) { - if( ( lookup = charmap.find( input ) ) != charmap.end() ) - input = lookup->second; - } -} - -void ComputeArc(double X0, double Y0, double Xn, double Yn, double R, double L, double dL, - double &phi, double &Xout, double &Yout) -/*wylicza polozenie Xout Yout i orientacje phi punktu na elemencie dL luku*/ -{ - double dX; - double dY; - double Xc; - double Yc; - double gamma; - double alfa; - double AbsR; - - if ((R != 0) && (L != 0)) - { - AbsR = abs(R); - dX = Xn - X0; - dY = Yn - Y0; - if (dX != 0) - gamma = atan(dY * 1.0 / dX); - else if (dY > 0) - gamma = M_PI * 1.0 / 2; - else - gamma = 3 * M_PI * 1.0 / 2; - alfa = L * 1.0 / R; - phi = gamma - (alfa + M_PI * Round(R * 1.0 / AbsR)) * 1.0 / 2; - Xc = X0 - AbsR * cos(phi); - Yc = Y0 - AbsR * sin(phi); - phi = phi + alfa * dL * 1.0 / L; - Xout = AbsR * cos(phi) + Xc; - Yout = AbsR * sin(phi) + Yc; - } -} - -void ComputeALine(double X0, double Y0, double Xn, double Yn, double L, double R, double &Xout, - double &Yout) -{ - double dX; - double dY; - double gamma; - double alfa; - /* pX,pY : real;*/ - - alfa = 0; // ABu: bo nie bylo zainicjowane - dX = Xn - X0; - dY = Yn - Y0; - if (dX != 0) - gamma = atan(dY * 1.0 / dX); - else if (dY > 0) - gamma = M_PI * 1.0 / 2; - else - gamma = 3 * M_PI * 1.0 / 2; - if (R != 0) - alfa = L * 1.0 / R; - Xout = X0 + L * cos(alfa * 1.0 / 2 - gamma); - Yout = Y0 + L * sin(alfa * 1.0 / 2 - gamma); -} - -bool FileExists( std::string const &Filename ) { - - std::ifstream file( Filename ); - if( file.is_open() == false ) { return false; } - else { return true; } -} - -/* -//graficzne: - -double Xhor(double h) -{ - return h * Hstep + Xmin; -} - -double Yver(double v) -{ - return (Vsize - v) * Vstep + Ymin; -} - -long Horiz(double x) -{ - x = (x - Xmin) * 1.0 / Hstep; - if (x > -INT_MAX) - if (x < INT_MAX) - return Round(x); - else - return INT_MAX; - else - return -INT_MAX; -} - -long Vert(double Y) -{ - Y = (Y - Ymin) * 1.0 / Vstep; - if (Y > -INT_MAX) - if (Y < INT_MAX) - return Vsize - Round(Y); - else - return INT_MAX; - else - return -INT_MAX; -} -*/ - -// NOTE: this now does nothing. -void ClearPendingExceptions() -// resetuje błędy FPU, wymagane dla Trunc() -{ - ; /*?*/ /* ASM - FNCLEX - ASM END */ -} - -// END diff --git a/McZapkie/mctools.h b/McZapkie/mctools.h deleted file mode 100644 index 817f34ec..00000000 --- a/McZapkie/mctools.h +++ /dev/null @@ -1,178 +0,0 @@ -#pragma once - -/* -This Source Code Form is subject to the -terms of the Mozilla Public License, v. -2.0. If a copy of the MPL was not -distributed with this file, You can -obtain one at -http://mozilla.org/MPL/2.0/. -*/ - -/*rozne takie duperele do operacji na stringach w paszczalu, pewnie w delfi sa lepsze*/ -/*konwersja zmiennych na stringi, funkcje matematyczne, logiczne, lancuchowe, I/O etc*/ - -#include -#include -#include -#include -#include -#include - -/*Ra: te stałe nie są używane... - _FileName = ['a'..'z','A'..'Z',':','\','.','*','?','0'..'9','_','-']; - _RealNum = ['0'..'9','-','+','.','E','e']; - _Integer = ['0'..'9','-']; //Ra: to się gryzie z STLport w Builder 6 - _Plus_Int = ['0'..'9']; - _All = [' '..'ţ']; - _Delimiter= [',',';']+_EOL; - _Delimiter_Space=_Delimiter+[' ']; -*/ -static char _EOL[2] = { (char)13, (char)10 }; -static char _Spacesigns[4] = { (char)' ', (char)9, (char)13, (char)10 }; -static std::string _spacesigns = " " + (char)9 + (char)13 + (char)10; -static int const CutLeft = -1; -static int const CutRight = 1; -static int const CutBoth = 0; /*Cut_Space*/ - -extern int ConversionError; -extern int LineCount; -extern bool DebugModeFlag; -extern bool FreeFlyModeFlag; - - -typedef unsigned long/*?*//*set of: char */ TableChar; /*MCTUTIL*/ - -/*konwersje*/ - -/*funkcje matematyczne*/ -int Max0(int x1, int x2); -int Min0(int x1, int x2); - -double Max0R(double x1, double x2); -double Min0R(double x1, double x2); - -inline int Sign(int x) -{ - return x >= 0 ? 1 : -1; -} - -inline double Sign(double x) -{ - return x >= 0 ? 1.0 : -1.0; -} - -inline long Round(float f) -{ - return (long)(f + 0.5); - //return lround(f); -} - -extern double Random(double a, double b); - -inline double Random() -{ - return Random(0.0,1.0); -} - -inline double Random(double b) -{ - return Random(0.0, b); -} - -inline double BorlandTime() -{ - auto timesinceepoch = std::time( nullptr ); - return timesinceepoch / (24.0 * 60 * 60); -/* - // std alternative - auto timesinceepoch = std::chrono::system_clock::now().time_since_epoch(); - return std::chrono::duration_cast( timesinceepoch ).count() / (24.0 * 60 * 60); -*/ -} - -std::string Now(); - -/*funkcje logiczne*/ -extern bool TestFlag(int Flag, int Value); -extern bool SetFlag( int & Flag, int Value); -extern bool iSetFlag( int & Flag, int Value); -extern bool UnSetFlag(int &Flag, int Value); - -bool FuzzyLogic(double Test, double Threshold, double Probability); -/*jesli Test>Threshold to losowanie*/ -bool FuzzyLogicAI(double Test, double Threshold, double Probability); -/*to samo ale zawsze niezaleznie od DebugFlag*/ - -/*operacje na stringach*/ -std::string ReadWord( std::ifstream& infile); /*czyta slowo z wiersza pliku tekstowego*/ -//std::string Ups(std::string s); -//std::string TrimSpace(std::string &s); -//char* TrimAndReduceSpaces(const char* s); -//std::string ExtractKeyWord(std::string InS, std::string KeyWord); /*wyciaga slowo kluczowe i lancuch do pierwszej spacji*/ -std::string DUE(std::string s); /*Delete Until Equal sign*/ -std::string DWE(std::string s); /*Delete While Equal sign*/ -std::string ExchangeCharInString(std::string const &s, const char &aim, const char &target); // zamienia jeden znak na drugi -std::vector &Split(const std::string &s, char delim, std::vector &elems); -std::vector Split(const std::string &s, char delim); -//std::vector Split(const std::string &s); - -std::string to_string(int _Val); -std::string to_string(unsigned int _Val); -std::string to_string(int _Val, int precision); -std::string to_string(int _Val, int precision, int width); -std::string to_string(double _Val); -std::string to_string(double _Val, int precision); -std::string to_string(double _Val, int precision, int width); -std::string to_hex_str( int const _Val, int const width = 4 ); - -inline std::string to_string(bool _Val) -{ - return _Val == true ? "true" : "false"; -} - -int stol_def(const std::string & str, const int & DefaultValue); - -std::string ToLower(std::string const &text); -std::string ToUpper(std::string const &text); - -// replaces polish letters with basic ascii -void win1250_to_ascii( std::string &Input ); - -/*procedury, zmienne i funkcje graficzne*/ -void ComputeArc(double X0, double Y0, double Xn, double Yn, double R, double L, double dL, double & phi, double & Xout, double & Yout); -/*wylicza polozenie Xout Yout i orientacje phi punktu na elemencie dL luku*/ -void ComputeALine(double X0, double Y0, double Xn, double Yn, double L, double R, double & Xout, double & Yout); -/* -inline bool fileExists(const std::string &name) -{ - struct stat buffer; - return (stat(name.c_str(), &buffer) == 0); -}*/ -bool FileExists( std::string const &Filename ); -/* -extern double Xmin; -extern double Ymin; -extern double Xmax; -extern double Ymax; -extern double Xaspect; -extern double Yaspect; -extern double Hstep; -extern double Vstep; -extern int Vsize; -extern int Hsize; - - -// Converts horizontal screen coordinate into real X-coordinate. -double Xhor( double h ); - -// Converts vertical screen coordinate into real Y-coordinate. -double Yver( double v ); - -long Horiz(double x); - -long Vert(double Y); -*/ - -void ClearPendingExceptions(); - diff --git a/MdlMngr.cpp b/MdlMngr.cpp index f3663e10..3dea431c 100644 --- a/MdlMngr.cpp +++ b/MdlMngr.cpp @@ -16,64 +16,48 @@ http://mozilla.org/MPL/2.0/. #include "stdafx.h" #include "MdlMngr.h" +#include "model3d.h" #include "Globals.h" -#include "Logs.h" -#include "McZapkie/mctools.h" +#include "logs.h" +#include "utilities.h" -//#define SeekFiles std::string("*.t3d") +// wczytanie modelu do kontenerka +TModel3d * +TMdlContainer::LoadModel(std::string const &Name, bool const Dynamic) { -TModel3d * TMdlContainer::LoadModel(std::string const &NewName, bool dynamic) -{ // wczytanie modelu do kontenerka - SafeDelete(Model); - Name = NewName; - Model = new TModel3d(); - if (!Model->LoadFromFile(Name, dynamic)) // np. "models\\pkp/head1-y.t3d" - SafeDelete(Model); - return Model; -}; - -TMdlContainer *TModelsManager::Models; -int TModelsManager::Count; -int const MAX_MODELS = 1000; - -void TModelsManager::Init() -{ - Models = new TMdlContainer[MAX_MODELS]; - Count = 0; -} -/* - TModelsManager::TModelsManager() -{ -// Models= NULL; - Models= new TMdlContainer[MAX_MODELS]; - Count= 0; -}; - - TModelsManager::~TModelsManager() -{ - Free(); -}; - */ -void TModelsManager::Free() -{ - SafeDeleteArray(Models); -} - -TModel3d * TModelsManager::LoadModel(std::string const &Name, bool dynamic) -{ // wczytanie modelu do tablicy - TModel3d *mdl = NULL; - if (Count >= MAX_MODELS) - Error("FIXME: Too many models, program will now crash :)"); - else - { - mdl = Models[Count].LoadModel(Name, dynamic); - if (mdl) - Count++; // jeśli błąd wczytania modelu, to go nie wliczamy + Model = std::make_shared(); + if( true == Model->LoadFromFile( Name, Dynamic ) ) { + m_name = Name; + return Model.get(); } - return mdl; + else { + m_name.clear(); + Model = nullptr; + return nullptr; + } +}; + +TModelsManager::modelcontainer_sequence TModelsManager::m_models { 1, {} }; +TModelsManager::stringmodelcontainerindex_map TModelsManager::m_modelsmap; + +// wczytanie modelu do tablicy +TModel3d * +TModelsManager::LoadModel(std::string const &Name, bool dynamic) { + + m_models.emplace_back(); + auto model = m_models.back().LoadModel( Name, dynamic ); + if( model != nullptr ) { + m_modelsmap.emplace( Name, m_models.size() - 1 ); + } + else { + m_models.pop_back(); + m_modelsmap.emplace( Name, null_handle ); + } + return model; } -TModel3d * TModelsManager::GetModel(std::string const &Name, bool dynamic) +TModel3d * +TModelsManager::GetModel(std::string const &Name, bool const Dynamic) { // model może być we wpisie "node...model" albo "node...dynamic", a także być dodatkowym w dynamic // (kabina, wnętrze, ładunek) // dla "node...dynamic" mamy podaną ścieżkę w "\dynamic\" i musi być co najmniej 1 poziom, zwkle @@ -95,101 +79,76 @@ TModel3d * TModelsManager::GetModel(std::string const &Name, bool dynamic) // - wczytanie uproszczonego wnętrza, ścieżka dokładna, tekstury z katalogu modelu // - niebo animowane, ścieżka brana ze wpisu, tekstury nieokreślone // - wczytanie modelu animowanego - Init() - sprawdzić - std::string buf; - std::string buftp = Global::asCurrentTexturePath; // zapamiętanie aktualnej ścieżki do tekstur, - // bo będzie tyczmasowo zmieniana - /* - // Ra: niby tak jest lepiej, ale działa gorzej, więc przywrócone jest oryginalne - //nawet jeśli model będzie pobrany z tablicy, to trzeba ustalić ścieżkę dla tekstur - if (dynamic) //na razie tak, bo nie wiadomo, jaki może mieć wpływ na pozostałe modele - {//dla pojazdów podana jest zawsze pełna ścieżka do modelu - strcpy(buf,Name); - if (strchr(Name,'/')!=NULL) - {//pobieranie tekstur z katalogu, w którym jest model - Global::asCurrentTexturePath=Global::asCurrentTexturePath+AnsiString(Name); - Global::asCurrentTexturePath.Delete(Global::asCurrentTexturePath.Pos("/")+1,Global::asCurrentTexturePath.Length()); - } - } - else - {//dla modeli scenerii trzeba ustalić ścieżkę - if (strchr(Name,'\\')==NULL) - {//jeśli nie ma lewego ukośnika w ścieżce, a jest prawy, to zmienić ścieżkę dla tekstur na tę - z modelem - strcpy(buf,"models\\"); //Ra: było by lepiej katalog dodać w parserze - //strcpy(buf,"scenery\\"); //Ra: było by lepiej katalog dodać w parserze - strcat(buf,Name); - if (strchr(Name,'/')!=NULL) - {//jeszcze musi być prawy ukośnik - Global::asCurrentTexturePath=Global::asCurrentTexturePath+AnsiString(Name); - Global::asCurrentTexturePath.Delete(Global::asCurrentTexturePath.Pos("/")+1,Global::asCurrentTexturePath.Length()); - } - } - else - {//jeśli jest lewy ukośnik, to ścieżkę do tekstur zmienić tylko dla pojazdów - strcpy(buf,Name); - } - } - StrLower(buf); - for (int i=0;i +TModelsManager::find_in_databank( std::string const &Name ) { - NewModel= *GetNextModel(Name); + std::vector filenames { + Name, + szModelPath + Name }; - if (asReplacableTexture!=AnsiString("none")) - ReplacableTextureID= TTexturesManager::GetTextureID(asReplacableTexture.c_str()); + for( auto const &filename : filenames ) { + auto const lookup { m_modelsmap.find( filename ) }; + if( lookup != m_modelsmap.end() ) { + return { true, m_models[ lookup->second ].Model.get() }; + } + } - NewModel.ReplacableSkinID=ReplacableTextureID; + return { false, nullptr }; +} - return NewModel; -}; -*/ +// checks whether specified file exists. returns name of the located file, or empty string. +std::string +TModelsManager::find_on_disk( std::string const &Name ) { + + std::vector extensions { { ".e3d" }, { ".t3d" } }; + for( auto const &extension : extensions ) { + + auto lookup = ( + FileExists( Name + extension ) ? Name : + FileExists( szModelPath + Name + extension ) ? szModelPath + Name : + "" ); + if( false == lookup.empty() ) { + return lookup; + } + } + + return {}; +} //--------------------------------------------------------------------------- diff --git a/MdlMngr.h b/MdlMngr.h index bdd465cd..ef4f2535 100644 --- a/MdlMngr.h +++ b/MdlMngr.h @@ -8,38 +8,35 @@ http://mozilla.org/MPL/2.0/. */ #pragma once -#include "Model3d.h" -#include "usefull.h" +#include "classes.h" -class TMdlContainer -{ +class TMdlContainer { friend class TModelsManager; - TMdlContainer() - { - Model = NULL; - }; - ~TMdlContainer() - { - SafeDelete(Model); - }; - TModel3d * LoadModel(std::string const &NewName, bool dynamic); - TModel3d *Model; - std::string Name; +private: + TModel3d *LoadModel( std::string const &Name, bool const Dynamic ); + std::shared_ptr Model { nullptr }; + std::string m_name; }; -class TModelsManager -{ // klasa statyczna, nie ma obiektu - private: - static TMdlContainer *Models; - static int Count; - static TModel3d * LoadModel(std::string const &Name, bool dynamic); - - public: - // TModelsManager(); - // ~TModelsManager(); - static void Init(); - static void Free(); +// klasa statyczna, nie ma obiektu +class TModelsManager { +public: // McZapkie: dodalem sciezke, notabene Path!=Patch :) - static TModel3d * GetModel(std::string const &Name, bool dynamic = false); + static TModel3d *GetModel( std::string const &Name, bool dynamic = false ); + +private: +// types: + typedef std::deque modelcontainer_sequence; + typedef std::unordered_map stringmodelcontainerindex_map; +// members: + static modelcontainer_sequence m_models; + static stringmodelcontainerindex_map m_modelsmap; +// methods: + static TModel3d *LoadModel( std::string const &Name, bool const Dynamic ); + static std::pair find_in_databank( std::string const &Name ); + // checks whether specified file exists. returns name of the located file, or empty string. + static std::string find_on_disk( std::string const &Name ); + }; + //--------------------------------------------------------------------------- diff --git a/MemCell.cpp b/MemCell.cpp index 49db62c3..ca7fd120 100644 --- a/MemCell.cpp +++ b/MemCell.cpp @@ -14,132 +14,76 @@ http://mozilla.org/MPL/2.0/. */ #include "stdafx.h" -#include "MemCell.h" +#include "memcell.h" -#include "Globals.h" -#include "Logs.h" -#include "Usefull.h" -#include "Driver.h" -#include "Event.h" -#include "parser.h" +#include "simulation.h" +#include "driver.h" +#include "event.h" +#include "logs.h" //--------------------------------------------------------------------------- -TMemCell::TMemCell(vector3 *p) -{ - fValue1 = fValue2 = 0; -#ifdef EU07_USE_OLD_TMEMCELL_TEXT_ARRAY - szText = new char[256]; // musi być dla automatycznie tworzonych komórek dla odcinków izolowanych -#endif - vPosition = - p ? *p : vector3(0, 0, 0); // ustawienie współrzędnych, bo do TGroundNode nie ma dostępu - bCommand = false; // komenda wysłana - OnSent = NULL; -} -#ifdef EU07_USE_OLD_TMEMCELL_TEXT_ARRAY -TMemCell::~TMemCell() -{ - SafeDeleteArray(szText); -} -#endif -void TMemCell::Init() -{ -} -#ifdef EU07_USE_OLD_TMEMCELL_TEXT_ARRAY -void TMemCell::UpdateValues(char const *szNewText, double const fNewValue1, double const fNewValue2, int const CheckMask) -#else +TMemCell::TMemCell( scene::node_data const &Nodedata ) : basic_node( Nodedata ) {} + void TMemCell::UpdateValues( std::string const &szNewText, double const fNewValue1, double const fNewValue2, int const CheckMask ) -#endif { - if (CheckMask & update_memadd) + if (CheckMask & basic_event::flags::mode_add) { // dodawanie wartości - if( TestFlag( CheckMask, update_memstring ) ) -#ifdef EU07_USE_OLD_TMEMCELL_TEXT_ARRAY - strcat( szText, szNewText ); -#else + if( TestFlag( CheckMask, basic_event::flags::text ) ) szText += szNewText; -#endif - if (TestFlag(CheckMask, update_memval1)) + if (TestFlag(CheckMask, basic_event::flags::value_1)) fValue1 += fNewValue1; - if (TestFlag(CheckMask, update_memval2)) + if (TestFlag(CheckMask, basic_event::flags::value_2)) fValue2 += fNewValue2; } else { - if( TestFlag( CheckMask, update_memstring ) ) -#ifdef EU07_USE_OLD_TMEMCELL_TEXT_ARRAY - strcpy( szText, szNewText ); -#else + if( TestFlag( CheckMask, basic_event::flags::text ) ) szText = szNewText; -#endif - if (TestFlag(CheckMask, update_memval1)) + if (TestFlag(CheckMask, basic_event::flags::value_1)) fValue1 = fNewValue1; - if (TestFlag(CheckMask, update_memval2)) + if (TestFlag(CheckMask, basic_event::flags::value_2)) fValue2 = fNewValue2; } - if (TestFlag(CheckMask, update_memstring)) + if (TestFlag(CheckMask, basic_event::flags::text)) CommandCheck(); // jeśli zmieniony tekst, próbujemy rozpoznać komendę } TCommandType TMemCell::CommandCheck() { // rozpoznanie komendy -#ifdef EU07_USE_OLD_TMEMCELL_TEXT_ARRAY - if (strcmp(szText, "SetVelocity") == 0) // najpopularniejsze -#else if( szText == "SetVelocity" ) // najpopularniejsze -#endif { - eCommand = cm_SetVelocity; + eCommand = TCommandType::cm_SetVelocity; bCommand = false; // ta komenda nie jest wysyłana } -#ifdef EU07_USE_OLD_TMEMCELL_TEXT_ARRAY - else if( strcmp( szText, "ShuntVelocity" ) == 0 ) // w tarczach manewrowych -#else else if( szText == "ShuntVelocity" ) // w tarczach manewrowych -#endif { - eCommand = cm_ShuntVelocity; + eCommand = TCommandType::cm_ShuntVelocity; bCommand = false; // ta komenda nie jest wysyłana } -#ifdef EU07_USE_OLD_TMEMCELL_TEXT_ARRAY - else if( strcmp( szText, "Change_direction" ) == 0 ) // zdarza się -#else else if( szText == "Change_direction" ) // zdarza się -#endif { - eCommand = cm_ChangeDirection; + eCommand = TCommandType::cm_ChangeDirection; bCommand = true; // do wysłania } -#ifdef EU07_USE_OLD_TMEMCELL_TEXT_ARRAY - else if( strcmp( szText, "OutsideStation" ) == 0 ) // zdarza się -#else else if( szText == "OutsideStation" ) // zdarza się -#endif { - eCommand = cm_OutsideStation; + eCommand = TCommandType::cm_OutsideStation; bCommand = false; // tego nie powinno być w komórce } -#ifdef EU07_USE_OLD_TMEMCELL_TEXT_ARRAY - else if( strncmp( szText, "PassengerStopPoint:", 19 ) == 0 ) // porównanie początków -#else else if( szText.compare( 0, 19, "PassengerStopPoint:" ) == 0 ) // porównanie początków -#endif { - eCommand = cm_PassengerStopPoint; + eCommand = TCommandType::cm_PassengerStopPoint; bCommand = false; // tego nie powinno być w komórce } -#ifdef EU07_USE_OLD_TMEMCELL_TEXT_ARRAY - else if( strcmp( szText, "SetProximityVelocity" ) == 0 ) // nie powinno tego być -#else else if( szText == "SetProximityVelocity" ) // nie powinno tego być -#endif { - eCommand = cm_SetProximityVelocity; + eCommand = TCommandType::cm_SetProximityVelocity; bCommand = false; // ta komenda nie jest wysyłana } else { - eCommand = cm_Unknown; // ciąg nierozpoznany (nie jest komendą) + eCommand = TCommandType::cm_Unknown; // ciąg nierozpoznany (nie jest komendą) bCommand = true; // do wysłania } return eCommand; @@ -148,17 +92,12 @@ TCommandType TMemCell::CommandCheck() bool TMemCell::Load(cParser *parser) { std::string token; - parser->getTokens(1, false); // case sensitive -#ifdef EU07_USE_OLD_TMEMCELL_TEXT_ARRAY - *parser >> token; - SafeDeleteArray(szText); - szText = new char[256]; // musi być bufor do łączenia tekstów - strcpy(szText, token.c_str()); -#else - *parser >> szText; -#endif - parser->getTokens( 2, false ); + parser->getTokens( 6, false ); *parser + >> m_area.center.x + >> m_area.center.y + >> m_area.center.z + >> szText >> fValue1 >> fValue2; parser->getTokens(); @@ -173,41 +112,15 @@ bool TMemCell::Load(cParser *parser) return true; } -void TMemCell::PutCommand(TController *Mech, vector3 *Loc) +void TMemCell::PutCommand( TController *Mech, glm::dvec3 const *Loc ) const { // wysłanie zawartości komórki do AI if (Mech) Mech->PutCommand(szText, fValue1, fValue2, Loc); } -bool TMemCell::Compare(char const *szTestText, double const fTestValue1, double const fTestValue2, int const CheckMask) -{ // porównanie zawartości komórki pamięci z podanymi wartościami - if (TestFlag(CheckMask, conditional_memstring)) - { // porównać teksty - std::string - match( szTestText ); - auto range = match.find( '*' ); - if( range != std::string::npos ) { - // compare string parts - if( 0 != szText.compare( 0, range, match, 0, range ) ) { - return false; - } - } - else { - // compare full strings - if( szText != match ) { - return false; - } - } - } - // tekst zgodny, porównać resztę - return ((!TestFlag(CheckMask, conditional_memval1) || (fValue1 == fTestValue1)) && - (!TestFlag(CheckMask, conditional_memval2) || (fValue2 == fTestValue2))); -}; - -#ifndef EU07_USE_OLD_TMEMCELL_TEXT_ARRAY -bool TMemCell::Compare( std::string const &szTestText, double const fTestValue1, double const fTestValue2, int const CheckMask ) { +bool TMemCell::Compare( std::string const &szTestText, double const fTestValue1, double const fTestValue2, int const CheckMask ) const { // porównanie zawartości komórki pamięci z podanymi wartościami - if( TestFlag( CheckMask, conditional_memstring ) ) { + if( TestFlag( CheckMask, basic_event::flags::text ) ) { // porównać teksty auto range = szTestText.find( '*' ); if( range != std::string::npos ) { @@ -224,23 +137,17 @@ bool TMemCell::Compare( std::string const &szTestText, double const fTestValue1, } } // tekst zgodny, porównać resztę - return ( ( !TestFlag( CheckMask, conditional_memval1 ) || ( fValue1 == fTestValue1 ) ) && - ( !TestFlag( CheckMask, conditional_memval2 ) || ( fValue2 == fTestValue2 ) ) ); + return ( ( !TestFlag( CheckMask, basic_event::flags::value_1 ) || ( fValue1 == fTestValue1 ) ) + && ( !TestFlag( CheckMask, basic_event::flags::value_2 ) || ( fValue2 == fTestValue2 ) ) ); }; -#endif -bool TMemCell::Render() -{ - return true; -} - -bool TMemCell::IsVelocity() +bool TMemCell::IsVelocity() const { // sprawdzenie, czy event odczytu tej komórki ma być do skanowania, czy do kolejkowania - if (eCommand == cm_SetVelocity) + if (eCommand == TCommandType::cm_SetVelocity) return true; - if (eCommand == cm_ShuntVelocity) + if (eCommand == TCommandType::cm_ShuntVelocity) return true; - return (eCommand == cm_SetProximityVelocity); + return (eCommand == TCommandType::cm_SetProximityVelocity); }; void TMemCell::StopCommandSent() @@ -248,11 +155,80 @@ void TMemCell::StopCommandSent() if (!bCommand) return; bCommand = false; - if (OnSent) // jeśli jest event - Global::AddToQuery(OnSent, NULL); + if( OnSent ) { + // jeśli jest event + simulation::Events.AddToQuery( OnSent, nullptr ); + } }; -void TMemCell::AssignEvents(TEvent *e) +void TMemCell::AssignEvents(basic_event *e) { // powiązanie eventu OnSent = e; }; + +// serialize() subclass details, sends content of the subclass to provided stream +void +TMemCell::serialize_( std::ostream &Output ) const { + + // TODO: implement +} +// deserialize() subclass details, restores content of the subclass from provided stream +void +TMemCell::deserialize_( std::istream &Input ) { + + // TODO: implement +} + +// export() subclass details, sends basic content of the class in legacy (text) format to provided stream +void +TMemCell::export_as_text_( std::ostream &Output ) const { + // header + Output << "memcell "; + // location + Output + << location().x << ' ' + << location().y << ' ' + << location().z << ' ' + // cell data + << szText << ' ' + << fValue1 << ' ' + << fValue2 << ' ' + // associated track + << ( Track ? Track->name() : asTrackName.empty() ? "none" : asTrackName ) << ' ' + // footer + << "endmemcell" + << "\n"; +} + + + + +// legacy method, initializes traction after deserialization from scenario file +void +memory_table::InitCells() { + + for( auto *cell : m_items ) { + // Ra: eventy komórek pamięci, wykonywane po wysłaniu komendy do zatrzymanego pojazdu + cell->AssignEvents( simulation::Events.FindEvent( cell->name() + ":sent" ) ); + // bind specified path with the memory cell + if( false == cell->asTrackName.empty() ) { + cell->Track = simulation::Paths.find( cell->asTrackName ); + if( cell->Track == nullptr ) { + ErrorLog( "Bad memcell: track \"" + cell->asTrackName + "\" referenced in memcell \"" + cell->name() + "\" doesn't exist" ); + } + } + } +} + +// legacy method, sends content of all cells to the log +void +memory_table::log_all() { + + for( auto *cell : m_items ) { + + WriteLog( "Memcell \"" + cell->name() + "\": [" + + cell->Text() + "] [" + + to_string( cell->Value1(), 2 ) + "] [" + + to_string( cell->Value2(), 2 ) + "]" ); + } +} diff --git a/MemCell.h b/MemCell.h index 730a5bf1..a98d751c 100644 --- a/MemCell.h +++ b/MemCell.h @@ -7,81 +7,81 @@ obtain one at http://mozilla.org/MPL/2.0/. */ -#ifndef MemCellH -#define MemCellH +#pragma once #include "Classes.h" -#include "dumb3d.h" -using namespace Math3D; -using namespace std; +#include "scenenode.h" +#include "names.h" -class TMemCell -{ - private: - vector3 vPosition; -#ifdef EU07_USE_OLD_TMEMCELL_TEXT_ARRAY - char *szText; -#else - std::string szText; -#endif - double fValue1; - double fValue2; - TCommandType eCommand; - bool bCommand; // czy zawiera komendę dla zatrzymanego AI - TEvent *OnSent; // event dodawany do kolejki po wysłaniu komendy zatrzymującej skład - public: - string - asTrackName; // McZapkie-100302 - zeby nazwe toru na ktory jest Putcommand wysylane pamietac - TMemCell(vector3 *p); -#ifdef EU07_USE_OLD_TMEMCELL_TEXT_ARRAY - ~TMemCell(); -#endif - void Init(); -#ifdef EU07_USE_OLD_TMEMCELL_TEXT_ARRAY - void UpdateValues( char const *szNewText, double const fNewValue1, double const fNewValue2, int const CheckMask ); -#else - void UpdateValues( std::string const &szNewText, double const fNewValue1, double const fNewValue2, int const CheckMask ); -#endif - bool Load(cParser *parser); - void PutCommand(TController *Mech, vector3 *Loc); - bool Compare( char const *szTestText, double const fTestValue1, double const fTestValue2, int const CheckMask ); -#ifndef EU07_USE_OLD_TMEMCELL_TEXT_ARRAY - bool Compare( std::string const &szTestText, double const fTestValue1, double const fTestValue2, int const CheckMask ); -#endif - bool Render(); -#ifdef EU07_USE_OLD_TMEMCELL_TEXT_ARRAY - inline char * Text() - { - return szText; - }; -#else - inline std::string const &Text() { return szText; } -#endif - inline double Value1() - { - return fValue1; - }; - inline double Value2() - { - return fValue2; - }; - inline vector3 Position() - { - return vPosition; - }; - inline TCommandType Command() - { - return eCommand; - }; - inline bool StopCommand() - { - return bCommand; - }; +class TMemCell : public scene::basic_node { + +public: +// constructors + explicit TMemCell( scene::node_data const &Nodedata ); +// methods + void + UpdateValues( std::string const &szNewText, double const fNewValue1, double const fNewValue2, int const CheckMask ); + bool + Load(cParser *parser); + void + PutCommand( TController *Mech, glm::dvec3 const *Loc ) const; + bool + Compare( std::string const &szTestText, double const fTestValue1, double const fTestValue2, int const CheckMask ) const; + std::string const & + Text() const { + return szText; } + double + Value1() const { + return fValue1; }; + double + Value2() const { + return fValue2; }; + TCommandType + Command() const { + return eCommand; }; + bool + StopCommand() const { + return bCommand; }; void StopCommandSent(); TCommandType CommandCheck(); - bool IsVelocity(); - void AssignEvents(TEvent *e); + bool IsVelocity() const; + void AssignEvents(basic_event *e); +// members + std::string asTrackName; // McZapkie-100302 - zeby nazwe toru na ktory jest Putcommand wysylane pamietac + TTrack *Track { nullptr }; // resolved binding with the specified track + bool is_exportable { true }; // export helper; autogenerated cells don't need to be exported + +private: +// methods + // serialize() subclass details, sends content of the subclass to provided stream + void serialize_( std::ostream &Output ) const; + // deserialize() subclass details, restores content of the subclass from provided stream + void deserialize_( std::istream &Input ); + // export() subclass details, sends basic content of the class in legacy (text) format to provided stream + void export_as_text_( std::ostream &Output ) const; + +// members + // content + std::string szText; + double fValue1 { 0.0 }; + double fValue2 { 0.0 }; + // other + TCommandType eCommand { TCommandType::cm_Unknown }; + bool bCommand { false }; // czy zawiera komendę dla zatrzymanego AI + basic_event *OnSent { nullptr }; // event dodawany do kolejki po wysłaniu komendy zatrzymującej skład +}; + + + +class memory_table : public basic_table { + +public: + // legacy method, initializes traction after deserialization from scenario file + void + InitCells(); + // legacy method, sends content of all cells to the log + void + log_all(); }; //--------------------------------------------------------------------------- -#endif diff --git a/Model3d.cpp b/Model3d.cpp index 4071db89..ecf7ed53 100644 --- a/Model3d.cpp +++ b/Model3d.cpp @@ -7,8 +7,8 @@ obtain one at http://mozilla.org/MPL/2.0/. */ /* - MaSzyna EU07 locomotive simulator - Copyright (C) 2001-2004 Marcin Wozniak, Maciej Czapkiewicz and others +MaSzyna EU07 locomotive simulator +Copyright (C) 2001-2004 Marcin Wozniak, Maciej Czapkiewicz and others */ @@ -17,18 +17,20 @@ http://mozilla.org/MPL/2.0/. #include "Globals.h" #include "logs.h" -#include "mczapkie/mctools.h" -#include "Usefull.h" -#include "Texture.h" +#include "utilities.h" +#include "renderer.h" #include "Timer.h" +#include "simulation.h" +#include "simulationtime.h" #include "mtable.h" +#include "sn_utils.h" //--------------------------------------------------------------------------- using namespace Mtable; -double TSubModel::fSquareDist = 0; -int TSubModel::iInstance; // numer renderowanego egzemplarza obiektu -texture_manager::size_type *TSubModel::ReplacableSkinId = NULL; +float TSubModel::fSquareDist = 0.f; +std::uintptr_t TSubModel::iInstance; // numer renderowanego egzemplarza obiektu +texture_handle const *TSubModel::ReplacableSkinId = NULL; int TSubModel::iAlpha = 0x30300030; // maska do testowania flag tekstur wymiennych TModel3d *TSubModel::pRoot; // Ra: tymczasowo wskaźnik na model widoczny z submodelu std::string *TSubModel::pasText; @@ -41,218 +43,116 @@ std::string *TSubModel::pasText; // 0x3F3F003F - wszystkie wymienne tekstury używane w danym cyklu // Ale w TModel3d okerśla przezroczystość tekstur wymiennych! -int TSubModelInfo::iTotalTransforms = 0; // ilość transformów -int TSubModelInfo::iTotalNames = 0; // długość obszaru nazw -int TSubModelInfo::iTotalTextures = 0; // długość obszaru tekstur -int TSubModelInfo::iCurrent = 0; // aktualny obiekt -TSubModelInfo *TSubModelInfo::pTable = NULL; // tabele obiektów pomocniczych +TSubModel::~TSubModel() { -char *TStringPack::String(int n) -{ // zwraca wskaźnik do łańcucha o podanym numerze - if (index ? n < (index[1] >> 2) - 2 : false) - return data + 8 + index[n + 2]; // indeks upraszcza kwestię wyszukiwania - // jak nie ma indeksu, to trzeba szukać - int max = *((int *)(data + 4)); // długość obszaru łańcuchów - char *ptr = data + 8; // począek obszaru łańcuchów - for (int i = 0; i < n; ++i) - { // wyszukiwanie łańcuchów nie jest zbyt optymalne, ale nie musi być - while (*ptr) - ++ptr; // wyszukiwanie zera - ++ptr; // pominięcie zera - if (ptr > data + max) - return NULL; // zbyt wysoki numer - } - return ptr; -}; - -TSubModel::TSubModel() -{ - ZeroMemory(this, sizeof(TSubModel)); // istotne przy zapisywaniu wersji binarnej - FirstInit(); -}; - -void TSubModel::FirstInit() -{ - eType = TP_ROTATOR; - Vertices = NULL; - uiDisplayList = 0; - iNumVerts = -1; // do sprawdzenia - iVboPtr = -1; - fLight = -1.0; //świetcenie wyłączone - v_RotateAxis = float3(0, 0, 0); - v_TransVector = float3(0, 0, 0); - f_Angle = 0; - b_Anim = at_None; - b_aAnim = at_None; - fVisible = 0.0; // zawsze widoczne - iVisible = 1; - fMatrix = NULL; // to samo co iMatrix=0; - Next = NULL; - Child = NULL; - TextureID = 0; - // TexAlpha=false; - iFlags = 0x0200; // bit 9=1: submodel został utworzony a nie ustawiony na - // wczytany plik - // TexHash=false; - // Hits=NULL; - // CollisionPts=NULL; - // CollisionPtsCount=0; - Opacity = 1.0; // przy wczytywaniu modeli było dzielone przez 100... - bWire = false; - fWireSize = 0; - fNearAttenStart = 40; - fNearAttenEnd = 80; - bUseNearAtten = false; - iFarAttenDecay = 0; - fFarDecayRadius = 100; - fCosFalloffAngle = 0.5; // 120°? - fCosHotspotAngle = 0.3; // 145°? - fCosViewAngle = 0; - fSquareMaxDist = 10000 * 10000; // 10km - fSquareMinDist = 0; - iName = -1; // brak nazwy - iTexture = 0; // brak tekstury - // asName=""; - // asTexture=""; - pName = pTexture = NULL; - f4Ambient[0] = f4Ambient[1] = f4Ambient[2] = f4Ambient[3] = 1.0; //{1,1,1,1}; - f4Diffuse[0] = f4Diffuse[1] = f4Diffuse[2] = f4Diffuse[3] = 1.0; //{1,1,1,1}; - f4Specular[0] = f4Specular[1] = f4Specular[2] = 0.0; - f4Specular[3] = 1.0; //{0,0,0,1}; - f4Emision[0] = f4Emision[1] = f4Emision[2] = f4Emision[3] = 1.0; - smLetter = NULL; // używany tylko roboczo dla TP_TEXT, do przyspieszenia wyświetlania -}; - -TSubModel::~TSubModel() -{ - if (uiDisplayList) - glDeleteLists(uiDisplayList, 1); if (iFlags & 0x0200) - { // wczytany z pliku tekstowego musi sam posprzątać - // SafeDeleteArray(Indices); - SafeDelete(Next); - SafeDelete(Child); - delete fMatrix; // własny transform trzeba usunąć (zawsze jeden) - delete[] Vertices; - delete[] pTexture; - delete[] pName; - } - /* - else - {//wczytano z pliku binarnego (nie jest właścicielem tablic) - } - */ - delete[] smLetter; // używany tylko roboczo dla TP_TEXT, do przyspieszenia - // wyświetlania + { // wczytany z pliku tekstowego musi sam posprzątać + SafeDelete(Next); + SafeDelete(Child); + delete fMatrix; // własny transform trzeba usunąć (zawsze jeden) + } + delete[] smLetter; // używany tylko roboczo dla TP_TEXT, do przyspieszenia + // wyświetlania }; -void TSubModel::TextureNameSet(const char *n) +void TSubModel::Name_Material(std::string const &Name) { // ustawienie nazwy submodelu, o - // ile nie jest wczytany z E3D - if (iFlags & 0x0200) - { // tylko jeżeli submodel zosta utworzony przez new - delete[] pTexture; // usunięcie poprzedniej - int i = strlen(n); - if (i) - { // utworzenie nowej - pTexture = new char[i + 1]; - strcpy(pTexture, n); - } - else - pTexture = NULL; - } + // ile nie jest wczytany z E3D + if (iFlags & 0x0200) + { // tylko jeżeli submodel zosta utworzony przez new + m_materialname = Name; + } }; -void TSubModel::NameSet(const char *n) +void TSubModel::Name(std::string const &Name) { // ustawienie nazwy submodelu, o ile - // nie jest wczytany z E3D - if (iFlags & 0x0200) - { // tylko jeżeli submodel zosta utworzony przez new - delete[] pName; // usunięcie poprzedniej - int i = strlen(n); - if (i) - { // utworzenie nowej - pName = new char[i + 1]; - strcpy(pName, n); - } - else - pName = NULL; - } + // nie jest wczytany z E3D + if (iFlags & 0x0200) + pName = Name; }; -// int TSubModel::SeekFaceNormal(DWORD *Masks, int f,DWORD dwMask,vector3 -// *pt,GLVERTEX -// *Vertices) -int TSubModel::SeekFaceNormal(unsigned int *Masks, int f, unsigned int dwMask, float3 *pt, - float8 *Vertices) -{ // szukanie punktu stycznego - // do (pt), zwraca numer - // wierzchołka, a nie trójkąta - int iNumFaces = iNumVerts / 3; // bo maska powierzchni jest jedna na trójkąt - // GLVERTEX *p; //roboczy wskaźnik - float8 *p; // roboczy wskaźnik - for (int i = f; i < iNumFaces; ++i) // pętla po trójkątach, od trójkąta (f) - if (Masks[i] & dwMask) // jeśli wspólna maska powierzchni - { - p = Vertices + 3 * i; - if (p->Point == *pt) - return 3 * i; - if ((++p)->Point == *pt) - return 3 * i + 1; - if ((++p)->Point == *pt) - return 3 * i + 2; +// sets visibility level (alpha component) to specified value +void +TSubModel::SetVisibilityLevel( float const Level, bool const Includechildren, bool const Includesiblings ) { + + fVisible = Level; + if( true == Includesiblings ) { + auto sibling { this }; + while( ( sibling = sibling->Next ) != nullptr ) { + sibling->SetVisibilityLevel( Level, Includechildren, false ); // no need for all siblings to duplicate the work } - return -1; // nie znaleziono stycznego wierzchołka + } + if( ( true == Includechildren ) + && ( Child != nullptr ) ) { + Child->SetVisibilityLevel( Level, Includechildren, true ); // node's children include child's siblings and children + } } -float emm1[] = {1, 1, 1, 0}; -float emm2[] = {0, 0, 0, 1}; +// sets light level (alpha component of illumination color) to specified value +void +TSubModel::SetLightLevel( float const Level, bool const Includechildren, bool const Includesiblings ) { -inline double readIntAsDouble(cParser &parser, int base = 255) + f4Emision.a = Level; + if( true == Includesiblings ) { + auto sibling { this }; + while( ( sibling = sibling->Next ) != nullptr ) { + sibling->SetLightLevel( Level, Includechildren, false ); // no need for all siblings to duplicate the work + } + } + if( ( true == Includechildren ) + && ( Child != nullptr ) ) { + Child->SetLightLevel( Level, Includechildren, true ); // node's children include child's siblings and children + } +} + +int TSubModel::SeekFaceNormal(std::vector const &Masks, int const Startface, unsigned int const Mask, glm::vec3 const &Position, gfx::vertex_array const &Vertices) +{ // szukanie punktu stycznego do (pt), zwraca numer wierzchołka, a nie trójkąta + int facecount = iNumVerts / 3; // bo maska powierzchni jest jedna na trójkąt + for( int faceidx = Startface; faceidx < facecount; ++faceidx ) { + // pętla po trójkątach, od trójkąta (f) + if( Masks[ faceidx ] & Mask ) { + // jeśli wspólna maska powierzchni + for( int vertexidx = 0; vertexidx < 3; ++vertexidx ) { + if( Vertices[ 3 * faceidx + vertexidx ].position == Position ) { + return 3 * faceidx + vertexidx; + } + } + } + } + return -1; // nie znaleziono stycznego wierzchołka +} + +float emm1[] = { 1, 1, 1, 0 }; +float emm2[] = { 0, 0, 0, 1 }; + +inline void readColor(cParser &parser, glm::vec4 &color) { - int value = parser.getToken(false); - return (static_cast(value) / base); + int discard; + parser.getTokens(4, false); + parser + >> discard + >> color.r + >> color.g + >> color.b; + color /= 255.0f; }; -template inline void readColor(cParser &parser, ColorT *color) -{ - double discard; - parser.getTokens(4, false); - parser >> discard >> color[0] >> color[1] >> color[2]; -}; - -inline void readColor(cParser &parser, int &color) -{ - int r, g, b, discard; - parser.getTokens(4, false); - parser >> discard >> r >> g >> b; - color = r + (g << 8) + (b << 16); -}; -/* -inline void readMatrix(cParser& parser,matrix4x4& matrix) -{//Ra: wczytanie transforma - for (int x=0;x<=3;x++) //wiersze - for (int y=0;y<=3;y++) //kolumny - parser.getToken(matrix(x)[y]); -}; -*/ inline void readMatrix(cParser &parser, float4x4 &matrix) { // Ra: wczytanie transforma - parser.getTokens(16, false); - for (int x = 0; x <= 3; ++x) // wiersze - for (int y = 0; y <= 3; ++y) // kolumny - parser >> matrix(x)[y]; + parser.getTokens(16, false); + for (int x = 0; x <= 3; ++x) // wiersze + for (int y = 0; y <= 3; ++y) // kolumny + parser >> matrix(x)[y]; }; -int TSubModel::Load(cParser &parser, TModel3d *Model, int Pos, bool dynamic) +int TSubModel::Load( cParser &parser, TModel3d *Model, /*int Pos,*/ bool dynamic) { // Ra: VBO tworzone na poziomie modelu, a nie submodeli iNumVerts = 0; +/* iVboPtr = Pos; // pozycja w VBO - // TMaterialColorf Ambient,Diffuse,Specular; - // GLuint TextureID; - // char *extName; +*/ if (!parser.expectToken("type:")) - Error("Model type parse failure!"); + ErrorLog("Bad model: expected submodel type definition not found while loading model \"" + Model->NameGet() + "\"" ); { std::string type = parser.getToken(); if (type == "mesh") @@ -268,21 +168,24 @@ int TSubModel::Load(cParser &parser, TModel3d *Model, int Pos, bool dynamic) }; parser.ignoreToken(); std::string token; - // parser.getToken(token1); //ze zmianą na małe! parser.getTokens(1, false); // nazwa submodelu bez zmieny na małe parser >> token; - NameSet(token.c_str()); - if (dynamic) - { // dla pojazdu, blokujemy załączone submodele, które mogą być - // nieobsługiwane - if (token.find("_on") + 3 == token.length()) // jeśli nazwa kończy się na "_on" - iVisible = 0; // to domyślnie wyłączyć, żeby się nie nakładało z obiektem "_off" + Name(token); + if (dynamic) { + // dla pojazdu, blokujemy załączone submodele, które mogą być nieobsługiwane + if( ( token.size() >= 3 ) + && ( token.find( "_on" ) + 3 == token.length() ) ) { + // jeśli nazwa kończy się na "_on" to domyślnie wyłączyć, żeby się nie nakładało z obiektem "_off" + iVisible = 0; + } + } + else { + // dla pozostałych modeli blokujemy zapalone światła, które mogą być nieobsługiwane + if( token.compare( 0, 8, "Light_On" ) == 0 ) { + // jeśli nazwa zaczyna się od "Light_On" to domyślnie wyłączyć, żeby się nie nakładało z obiektem "Light_Off" + iVisible = 0; + } } - else // dla pozostałych modeli blokujemy zapalone światła, które mogą być - // nieobsługiwane - if (token.compare(0, 8, "Light_On") == 0) // jeśli nazwa zaczyna się od "Light_On" - iVisible = 0; // to domyślnie wyłączyć, żeby się nie nakładało z obiektem - // "Light_Off" if (parser.expectToken("anim:")) // Ra: ta informacja by się przydała! { // rodzaj animacji @@ -291,49 +194,54 @@ int TSubModel::Load(cParser &parser, TModel3d *Model, int Pos, bool dynamic) { iFlags |= 0x4000; // jak animacja, to trzeba przechowywać macierz zawsze if (type == "seconds_jump") - b_Anim = b_aAnim = at_SecondsJump; // sekundy z przeskokiem + b_Anim = b_aAnim = TAnimType::at_SecondsJump; // sekundy z przeskokiem else if (type == "minutes_jump") - b_Anim = b_aAnim = at_MinutesJump; // minuty z przeskokiem + b_Anim = b_aAnim = TAnimType::at_MinutesJump; // minuty z przeskokiem else if (type == "hours_jump") - b_Anim = b_aAnim = at_HoursJump; // godziny z przeskokiem + b_Anim = b_aAnim = TAnimType::at_HoursJump; // godziny z przeskokiem else if (type == "hours24_jump") - b_Anim = b_aAnim = at_Hours24Jump; // godziny z przeskokiem + b_Anim = b_aAnim = TAnimType::at_Hours24Jump; // godziny z przeskokiem else if (type == "seconds") - b_Anim = b_aAnim = at_Seconds; // minuty płynnie + b_Anim = b_aAnim = TAnimType::at_Seconds; // minuty płynnie else if (type == "minutes") - b_Anim = b_aAnim = at_Minutes; // minuty płynnie + b_Anim = b_aAnim = TAnimType::at_Minutes; // minuty płynnie else if (type == "hours") - b_Anim = b_aAnim = at_Hours; // godziny płynnie + b_Anim = b_aAnim = TAnimType::at_Hours; // godziny płynnie else if (type == "hours24") - b_Anim = b_aAnim = at_Hours24; // godziny płynnie + b_Anim = b_aAnim = TAnimType::at_Hours24; // godziny płynnie else if (type == "billboard") - b_Anim = b_aAnim = at_Billboard; // obrót w pionie do kamery + b_Anim = b_aAnim = TAnimType::at_Billboard; // obrót w pionie do kamery else if (type == "wind") - b_Anim = b_aAnim = at_Wind; // ruch pod wpływem wiatru + b_Anim = b_aAnim = TAnimType::at_Wind; // ruch pod wpływem wiatru else if (type == "sky") - b_Anim = b_aAnim = at_Sky; // aniamacja nieba + b_Anim = b_aAnim = TAnimType::at_Sky; // aniamacja nieba else if (type == "ik") - b_Anim = b_aAnim = at_IK; // IK: zadający + b_Anim = b_aAnim = TAnimType::at_IK; // IK: zadający else if (type == "ik11") - b_Anim = b_aAnim = at_IK11; // IK: kierunkowany + b_Anim = b_aAnim = TAnimType::at_IK11; // IK: kierunkowany else if (type == "ik21") - b_Anim = b_aAnim = at_IK21; // IK: kierunkowany + b_Anim = b_aAnim = TAnimType::at_IK21; // IK: kierunkowany else if (type == "ik22") - b_Anim = b_aAnim = at_IK22; // IK: kierunkowany + b_Anim = b_aAnim = TAnimType::at_IK22; // IK: kierunkowany else if (type == "digital") - b_Anim = b_aAnim = at_Digital; // licznik mechaniczny + b_Anim = b_aAnim = TAnimType::at_Digital; // licznik mechaniczny else if (type == "digiclk") - b_Anim = b_aAnim = at_DigiClk; // zegar cyfrowy + b_Anim = b_aAnim = TAnimType::at_DigiClk; // zegar cyfrowy else - b_Anim = b_aAnim = at_Undefined; // nieznana forma animacji + b_Anim = b_aAnim = TAnimType::at_Undefined; // nieznana forma animacji } } if (eType < TP_ROTATOR) readColor(parser, f4Ambient); // ignoruje token przed readColor(parser, f4Diffuse); - if (eType < TP_ROTATOR) - readColor(parser, f4Specular); - parser.ignoreTokens(1); // zignorowanie nazwy "SelfIllum:" + if( eType < TP_ROTATOR ) { + readColor( parser, f4Specular ); + if( pName == "cien" ) { + // crude workaround to kill specular on shadow geometry of legacy models + f4Specular = glm::vec4{ 0.0f, 0.0f, 0.0f, 1.0f }; + } + } + parser.ignoreToken(); // zignorowanie nazwy "SelfIllum:" { std::string light = parser.getToken(); if (light == "true") @@ -351,275 +259,341 @@ int TSubModel::Load(cParser &parser, TModel3d *Model, int Pos, bool dynamic) } std::string discard; parser.getTokens(13, false); - parser >> fNearAttenStart >> discard >> fNearAttenEnd >> discard >> bUseNearAtten >> - discard >> iFarAttenDecay >> discard >> fFarDecayRadius >> discard >> - fCosFalloffAngle // kąt liczony dla średnicy, a nie promienia + parser + >> fNearAttenStart + >> discard >> fNearAttenEnd + >> discard >> bUseNearAtten + >> discard >> iFarAttenDecay + >> discard >> fFarDecayRadius + >> discard >> fCosFalloffAngle // kąt liczony dla średnicy, a nie promienia >> discard >> fCosHotspotAngle; // kąt liczony dla średnicy, a nie promienia - fCosFalloffAngle = cos(DegToRad(0.5 * fCosFalloffAngle)); - fCosHotspotAngle = cos(DegToRad(0.5 * fCosHotspotAngle)); + // convert conve parameters if specified in degrees + if( fCosFalloffAngle > 1.0 ) { + fCosFalloffAngle = std::cos( DegToRad( 0.5f * fCosFalloffAngle ) ); + } + if( fCosHotspotAngle > 1.0 ) { + fCosHotspotAngle = std::cos( DegToRad( 0.5f * fCosHotspotAngle ) ); + } iNumVerts = 1; - iFlags |= 0x4010; // rysowane w cyklu nieprzezroczystych, macierz musi - // zostać bez zmiany +/* + iFlags |= 0x4010; // rysowane w cyklu nieprzezroczystych, macierz musi zostać bez zmiany +*/ + iFlags |= 0x4030; // drawn both in solid (light point) and transparent (light glare) phases } else if (eType < TP_ROTATOR) { std::string discard; - parser.getTokens(5, false); - parser >> discard >> bWire >> discard >> fWireSize >> discard; - Opacity = readIntAsDouble(parser, - 100.0f); // wymagane jest 0 dla szyb, 100 idzie w nieprzezroczyste - if (Opacity > 1.0) - Opacity *= 0.01; // w 2013 był błąd i aby go obejść, trzeba było wpisać 10000.0 - if ((Global::iConvertModels & 1) == 0) // dla zgodności wstecz - Opacity = 0.0; // wszystko idzie w przezroczyste albo zależnie od tekstury + parser.getTokens(6, false); + parser + >> discard >> bWire + >> discard >> fWireSize + >> discard >> Opacity; + // wymagane jest 0 dla szyb, 100 idzie w nieprzezroczyste + if( Opacity > 1.f ) { + Opacity = std::min( 1.f, Opacity * 0.01f ); + } + if (!parser.expectToken("map:")) Error("Model map parse failure!"); - std::string texture = parser.getToken(); - if (texture == "none") + std::string material = parser.getToken(); + if (material == "none") { // rysowanie podanym kolorem - TextureID = 0; + m_material = null_handle; iFlags |= 0x10; // rysowane w cyklu nieprzezroczystych } - else if (texture.find("replacableskin") != texture.npos) + else if (material.find("replacableskin") != material.npos) { // McZapkie-060702: zmienialne skory modelu - TextureID = -1; + m_material = -1; iFlags |= (Opacity < 1.0) ? 1 : 0x10; // zmienna tekstura 1 } - else if (texture == "-1") + else if (material == "-1") { - TextureID = -1; + m_material = -1; iFlags |= (Opacity < 1.0) ? 1 : 0x10; // zmienna tekstura 1 } - else if (texture == "-2") + else if (material == "-2") { - TextureID = -2; + m_material = -2; iFlags |= (Opacity < 1.0) ? 2 : 0x10; // zmienna tekstura 2 } - else if (texture == "-3") + else if (material == "-3") { - TextureID = -3; + m_material = -3; iFlags |= (Opacity < 1.0) ? 4 : 0x10; // zmienna tekstura 3 } - else if (texture == "-4") + else if (material == "-4") { - TextureID = -4; + m_material = -4; iFlags |= (Opacity < 1.0) ? 8 : 0x10; // zmienna tekstura 4 } - else - { // jeśli tylko nazwa pliku, to dawać bieżącą ścieżkę do tekstur - // asTexture=AnsiString(texture.c_str()); //zapamiętanie nazwy tekstury - TextureNameSet(texture.c_str()); - if (texture.find_first_of("/\\") == texture.npos) - texture.insert(0, Global::asCurrentTexturePath.c_str()); - TextureID = TextureManager.GetTextureId( texture, szTexturePath ); - // TexAlpha=TTexturesManager::GetAlpha(TextureID); - // iFlags|=TexAlpha?0x20:0x10; //0x10-nieprzezroczysta, 0x20-przezroczysta - if (Opacity < 1.0) // przezroczystość z tekstury brana tylko dla Opacity - // 0! - iFlags |= TextureManager.Texture(TextureID).has_alpha ? - 0x20 : - 0x10; // 0x10-nieprzezroczysta, 0x20-przezroczysta - else - iFlags |= 0x10; // normalnie nieprzezroczyste + else { + Name_Material(material); +/* + if( material.find_first_of( "/\\" ) == material.npos ) { + // jeśli tylko nazwa pliku, to dawać bieżącą ścieżkę do tekstur + material.insert( 0, Global.asCurrentTexturePath ); + } +*/ + m_material = GfxRenderer.Fetch_Material( material ); // renderowanie w cyklu przezroczystych tylko jeśli: // 1. Opacity=0 (przejściowo <1, czy tam <100) oraz // 2. tekstura ma przezroczystość + iFlags |= + ( ( ( Opacity < 1.0 ) + && ( ( m_material != null_handle ) + && ( GfxRenderer.Material( m_material ).has_alpha ) ) ) ? + 0x20 : + 0x10 ); // 0x10-nieprzezroczysta, 0x20-przezroczysta }; } else iFlags |= 0x10; - std::string discard; - parser.getTokens(5, false); - parser >> discard >> fSquareMaxDist >> discard >> fSquareMinDist >> discard; + // visibility range + std::string discard; + parser.getTokens(5, false); + parser >> discard >> fSquareMaxDist >> discard >> fSquareMinDist >> discard; - if (fSquareMaxDist >= 0.0) - { - fSquareMaxDist *= fSquareMaxDist; + if( fSquareMaxDist <= 0.0 ) { + // 15km to więcej, niż się obecnie wyświetla + fSquareMaxDist = 15000.0; } - else - { - fSquareMaxDist = 15000 * 15000; - } // 15km to więcej, niż się obecnie wyświetla - fSquareMinDist *= fSquareMinDist; - fMatrix = new float4x4(); - readMatrix(parser, *fMatrix); // wczytanie transform - if (!fMatrix->IdentityIs()) + fSquareMaxDist *= fSquareMaxDist; + fSquareMinDist *= fSquareMinDist; + + // transformation matrix + fMatrix = new float4x4(); + readMatrix(parser, *fMatrix); // wczytanie transform + if( !fMatrix->IdentityIs() ) { iFlags |= 0x8000; // transform niejedynkowy - trzeba go przechować - int iNumFaces; // ilość trójkątów - unsigned int *sg; // maski przynależności trójkątów do powierzchni - if (eType < TP_ROTATOR) - { // wczytywanie wierzchołków - parser.getTokens(2, false); - parser >> discard >> token; - // Ra 15-01: to wczytać jako tekst - jeśli pierwszy znak zawiera "*", to - // dalej będzie nazwa wcześniejszego submodelu, z którego należy wziąć - // wierzchołki - // zapewni to jakąś zgodność wstecz, bo zamiast liczby będzie ciąg, którego - // wartość powinna być uznana jako zerowa - // parser.getToken(iNumVerts); - if (token[0] == '*') - { // jeśli pierwszy znak jest gwiazdką, poszukać - // submodelu o nazwie bez tej gwiazdki i wziąć z - // niego wierzchołki - Error("Verticles reference not yet supported!"); + // check the scaling + auto const matrix = glm::make_mat4( fMatrix->readArray() ); + glm::vec3 const scale{ + glm::length( glm::vec3( glm::column( matrix, 0 ) ) ), + glm::length( glm::vec3( glm::column( matrix, 1 ) ) ), + glm::length( glm::vec3( glm::column( matrix, 2 ) ) ) }; + if( ( std::abs( scale.x - 1.0f ) > 0.01 ) + || ( std::abs( scale.y - 1.0f ) > 0.01 ) + || ( std::abs( scale.z - 1.0f ) > 0.01 ) ) { + ErrorLog( "Bad model: transformation matrix for sub-model \"" + pName + "\" imposes geometry scaling (factors: " + to_string( scale ) + ")", logtype::model ); + m_normalizenormals = ( + ( ( std::abs( scale.x - scale.y ) < 0.01f ) && ( std::abs( scale.y - scale.z ) < 0.01f ) ) ? + rescale : + normalize ); } - else - { // normalna lista wierzchołków - iNumVerts = atoi(token.c_str()); - if (iNumVerts % 3) - { - iNumVerts = 0; - Error("Mesh error, (iNumVertices=" + std::to_string(iNumVerts) + ")%3<>0"); - return 0; - } - // Vertices=new GLVERTEX[iNumVerts]; - if (iNumVerts) - { - Vertices = new float8[iNumVerts]; - iNumFaces = iNumVerts / 3; - sg = new unsigned int[iNumFaces]; // maski powierzchni: 0 oznacza brak - // użredniania wektorów normalnych - int *wsp = new int[iNumVerts]; // z którego wierzchołka kopiować wektor - // normalny - int maska = 0; - for (int i = 0; i < iNumVerts; i++) - { // Ra: z konwersją na układ scenerii - będzie wydajniejsze - // wyświetlanie - wsp[i] = -1; // wektory normalne nie są policzone dla tego wierzchołka - if ((i % 3) == 0) - { // jeśli będzie maska -1, to dalej będą - // wierzchołki z wektorami normalnymi, podanymi - // jawnie - maska = parser.getToken(false); // maska powierzchni trójkąta - sg[i / 3] = (maska == -1) ? 0 : maska; // dla maski -1 będzie 0, - // czyli nie ma wspólnych - // wektorów normalnych - } - parser.getTokens(3, false); - parser >> Vertices[i].Point.x >> Vertices[i].Point.y >> Vertices[i].Point.z; - if (maska == -1) - { // jeśli wektory normalne podane jawnie - parser.getTokens(3, false); - parser >> Vertices[i].Normal.x >> Vertices[i].Normal.y >> - Vertices[i].Normal.z; - wsp[i] = i; // wektory normalne "są już policzone" - } - parser.getTokens(2, false); - parser >> Vertices[i].tu >> Vertices[i].tv; - if (i % 3 == 2) // jeżeli wczytano 3 punkty - { - if (Vertices[i].Point == Vertices[i - 1].Point || - Vertices[i - 1].Point == Vertices[i - 2].Point || - Vertices[i - 2].Point == Vertices[i].Point) - { // jeżeli punkty się nakładają na siebie - --iNumFaces; // o jeden trójkąt mniej - iNumVerts -= 3; // czyli o 3 wierzchołki - i -= 3; // wczytanie kolejnego w to miejsce - WriteLog(std::string("Degenerated triangle ignored in: \"") + pName + - "\", verticle " + std::to_string(i)); + } + if (eType < TP_ROTATOR) + { // wczytywanie wierzchołków + parser.getTokens(2, false); + parser >> discard >> token; + // Ra 15-01: to wczytać jako tekst - jeśli pierwszy znak zawiera "*", to + // dalej będzie nazwa wcześniejszego submodelu, z którego należy wziąć + // wierzchołki + // zapewni to jakąś zgodność wstecz, bo zamiast liczby będzie ciąg, którego + // wartość powinna być uznana jako zerowa + // parser.getToken(iNumVerts); + if (token[0] == '*') + { // jeśli pierwszy znak jest gwiazdką, poszukać + // submodelu o nazwie bez tej gwiazdki i wziąć z + // niego wierzchołki + Error("Vertices reference not yet supported!"); + } + else + { // normalna lista wierzchołków + iNumVerts = std::atoi(token.c_str()); + if (iNumVerts % 3) + { + iNumVerts = 0; + Error("Mesh error, (iNumVertices=" + std::to_string(iNumVerts) + ")%3<>0"); + return 0; + } + // Vertices=new GLVERTEX[iNumVerts]; + if (iNumVerts) { +/* + Vertices = new basic_vertex[iNumVerts]; +*/ + Vertices.resize( iNumVerts ); + int facecount = iNumVerts / 3; +/* + unsigned int *sg; // maski przynależności trójkątów do powierzchni + sg = new unsigned int[iNumFaces]; // maski powierzchni: 0 oznacza brak użredniania wektorów normalnych + int *wsp = new int[iNumVerts]; // z którego wierzchołka kopiować wektor normalny +*/ + std::vector sg; sg.resize( facecount ); // maski przynależności trójkątów do powierzchni + std::vector wsp; wsp.resize( iNumVerts );// z którego wierzchołka kopiować wektor normalny + int maska = 0; + int rawvertexcount = 0; // used to keep track of vertex indices in source file + for (int i = 0; i < iNumVerts; ++i) { + ++rawvertexcount; + // Ra: z konwersją na układ scenerii - będzie wydajniejsze wyświetlanie + wsp[i] = -1; // wektory normalne nie są policzone dla tego wierzchołka + if ((i % 3) == 0) { + // jeśli będzie maska -1, to dalej będą wierzchołki z wektorami normalnymi, podanymi jawnie + maska = parser.getToken(false); // maska powierzchni trójkąta + // dla maski -1 będzie 0, czyli nie ma wspólnych wektorów normalnych + sg[i / 3] = ( + ( maska == -1 ) ? + 0 : + maska ); + } + parser.getTokens(3, false); + parser + >> Vertices[i].position.x + >> Vertices[i].position.y + >> Vertices[i].position.z; + if (maska == -1) + { // jeśli wektory normalne podane jawnie + parser.getTokens(3, false); + parser + >> Vertices[i].normal.x + >> Vertices[i].normal.y + >> Vertices[i].normal.z; + if( glm::length2( Vertices[ i ].normal ) > 0.0f ) { + glm::normalize( Vertices[ i ].normal ); } - if (i > 0) // jeśli pierwszy trójkąt będzie zdegenerowany, to - // zostanie usunięty i nie ma co sprawdzać - if (((Vertices[i].Point - Vertices[i - 1].Point).Length() > 1000.0) || - ((Vertices[i - 1].Point - Vertices[i - 2].Point).Length() > - 1000.0) || - ((Vertices[i - 2].Point - Vertices[i].Point).Length() > 1000.0)) - { // jeżeli są dalej niż 2km od siebie //Ra 15-01: - // obiekt wstawiany nie powinien być większy niż - // 300m (trójkąty terenu w E3D mogą mieć 1.5km) - --iNumFaces; // o jeden trójkąt mniej - iNumVerts -= 3; // czyli o 3 wierzchołki - i -= 3; // wczytanie kolejnego w to miejsce - WriteLog(std::string("Too large triangle ignored in: \"") + pName + - "\""); + else { + WriteLog( "Bad model: zero length normal vector specified in: \"" + pName + "\", vertex " + std::to_string(i), logtype::model ); + } + wsp[i] = i; // wektory normalne "są już policzone" + } + parser.getTokens(2, false); + parser + >> Vertices[i].texture.s + >> Vertices[i].texture.t; + if (i % 3 == 2) { + // jeżeli wczytano 3 punkty + if( true == degenerate( Vertices[ i ].position, Vertices[ i - 1 ].position, Vertices[ i - 2 ].position ) ) { + // jeżeli punkty się nakładają na siebie + --facecount; // o jeden trójkąt mniej + iNumVerts -= 3; // czyli o 3 wierzchołki + i -= 3; // wczytanie kolejnego w to miejsce + WriteLog("Bad model: degenerated triangle ignored in: \"" + pName + "\", vertices " + std::to_string(rawvertexcount-2) + "-" + std::to_string(rawvertexcount), logtype::model ); + } + if (i > 0) { + // jeśli pierwszy trójkąt będzie zdegenerowany, to zostanie usunięty i nie ma co sprawdzać + if ((glm::length(Vertices[i ].position - Vertices[i - 1].position) > 1000.0) + || (glm::length(Vertices[i - 1].position - Vertices[i - 2].position) > 1000.0) + || (glm::length(Vertices[i - 2].position - Vertices[i ].position) > 1000.0)) { + // jeżeli są dalej niż 2km od siebie //Ra 15-01: + // obiekt wstawiany nie powinien być większy niż 300m (trójkąty terenu w E3D mogą mieć 1.5km) + --facecount; // o jeden trójkąt mniej + iNumVerts -= 3; // czyli o 3 wierzchołki + i -= 3; // wczytanie kolejnego w to miejsce + WriteLog( "Bad model: too large triangle ignored in: \"" + pName + "\"", logtype::model ); + } + } + } + } +/* + glm::vec3 *n = new glm::vec3[iNumFaces]; // tablica wektorów normalnych dla trójkątów +*/ + std::vector facenormals; facenormals.reserve( facecount ); + for( int i = 0; i < facecount; ++i ) { + // pętla po trójkątach - będzie szybciej, jak wstępnie przeliczymy normalne trójkątów + auto facenormal = + glm::cross( + Vertices[ i * 3 ].position - Vertices[ i * 3 + 1 ].position, + Vertices[ i * 3 ].position - Vertices[ i * 3 + 2 ].position ); + facenormals.emplace_back( + glm::length2( facenormal ) > 0.0f ? + glm::normalize( facenormal ) : + glm::vec3() ); + } + glm::vec3 vertexnormal; // roboczy wektor normalny + for (int vertexidx = 0; vertexidx < iNumVerts; ++vertexidx) { + // pętla po wierzchołkach trójkątów + if( wsp[ vertexidx ] >= 0 ) { + // jeśli już był liczony wektor normalny z użyciem tego wierzchołka to wystarczy skopiować policzony wcześniej + Vertices[ vertexidx ].normal = Vertices[ wsp[ vertexidx ] ].normal; + } + else { + // inaczej musimy dopiero policzyć + auto const faceidx = vertexidx / 3; // numer trójkąta + vertexnormal = glm::vec3(); // liczenie zaczynamy od zera + auto adjacenvertextidx = vertexidx; // zaczynamy dodawanie wektorów normalnych od własnego + while (adjacenvertextidx >= 0) { + // sumowanie z wektorem normalnym sąsiada (włącznie ze sobą) + if( glm::dot( vertexnormal, facenormals[ adjacenvertextidx / 3 ] ) > -0.99f ) { + wsp[ adjacenvertextidx ] = vertexidx; // informacja, że w tym wierzchołku jest już policzony wektor normalny + vertexnormal += facenormals[ adjacenvertextidx / 3 ]; } - } - } - int i; // indeks dla trójkątów - float3 *n = new float3[iNumFaces]; // tablica wektorów normalnych dla trójkątów - for (i = 0; i < iNumFaces; i++) // pętla po trójkątach - będzie - // szybciej, jak wstępnie przeliczymy - // normalne trójkątów - n[i] = SafeNormalize( - CrossProduct(Vertices[i * 3].Point - Vertices[i * 3 + 1].Point, - Vertices[i * 3].Point - Vertices[i * 3 + 2].Point)); - int v; // indeks dla wierzchołków - int f; // numer trójkąta stycznego - float3 norm; // roboczy wektor normalny - for (v = 0; v < iNumVerts; v++) - { // pętla po wierzchołkach trójkątów - if (wsp[v] >= 0) // jeśli już był liczony wektor normalny z użyciem - // tego wierzchołka - Vertices[v].Normal = - Vertices[wsp[v]].Normal; // to wystarczy skopiować policzony wcześniej - else - { // inaczej musimy dopiero policzyć - i = v / 3; // numer trójkąta - norm = float3(0, 0, 0); // liczenie zaczynamy od zera - f = v; // zaczynamy dodawanie wektorów normalnych od własnego - while (f >= 0) - { // sumowanie z wektorem normalnym sąsiada (włącznie - // ze sobą) - wsp[f] = v; // informacja, że w tym wierzchołku jest już policzony - // wektor normalny - norm += n[f / 3]; - f = SeekFaceNormal(sg, f / 3 + 1, sg[i], &Vertices[v].Point, - Vertices); // i szukanie od kolejnego trójkąta + else { + ErrorLog( "Bad model: opposite normals in the same smoothing group, check sub-model \"" + pName + "\" for two-sided faces and/or scaling", logtype::model ); + } + // i szukanie od kolejnego trójkąta + adjacenvertextidx = SeekFaceNormal(sg, adjacenvertextidx / 3 + 1, sg[faceidx], Vertices[vertexidx].position, Vertices); } - // Ra 15-01: należało by jeszcze uwzględnić skalowanie wprowadzane - // przez transformy, aby normalne po przeskalowaniu były jednostkowe - Vertices[v].Normal = - SafeNormalize(norm); // przepisanie do wierzchołka trójkąta - } - } - delete[] wsp; - delete[] n; - delete[] sg; - } - else // gdy brak wierzchołków - { - eType = TP_ROTATOR; // submodel pomocniczy, ma tylko macierz przekształcenia - iVboPtr = iNumVerts = 0; // dla formalności - } - } // obsługa submodelu z własną listą wierzchołków + // Ra 15-01: należało by jeszcze uwzględnić skalowanie wprowadzane przez transformy, aby normalne po przeskalowaniu były jednostkowe + if( glm::length2( vertexnormal ) == 0.0f ) { + WriteLog( "Bad model: zero length normal vector generated for sub-model \"" + pName + "\"", logtype::model ); + } + Vertices[ vertexidx ].normal = ( + glm::length2( vertexnormal ) > 0.0f ? + glm::normalize( vertexnormal ) : + facenormals[ vertexidx / 3 ] ); // przepisanie do wierzchołka trójkąta + } + } + Vertices.resize( iNumVerts ); // in case we had some degenerate triangles along the way +/* + delete[] wsp; + delete[] n; + delete[] sg; +*/ + } + else // gdy brak wierzchołków + { + eType = TP_ROTATOR; // submodel pomocniczy, ma tylko macierz przekształcenia + /*iVboPtr =*/ iNumVerts = 0; // dla formalności + } + } // obsługa submodelu z własną listą wierzchołków + } + else if (eType == TP_STARS) + { // punkty świecące dookólnie - składnia jak + // dla smt_Mesh + std::string discard; + parser.getTokens(2, false); + parser >> discard >> iNumVerts; +/* + // Vertices=new GLVERTEX[iNumVerts]; + Vertices = new basic_vertex[iNumVerts]; +*/ + Vertices.resize( iNumVerts ); + int i; + unsigned int color; + for (i = 0; i < iNumVerts; ++i) + { + if (i % 3 == 0) + { + parser.ignoreToken(); // maska powierzchni trójkąta + } + parser.getTokens(5, false); + parser + >> Vertices[i].position.x + >> Vertices[i].position.y + >> Vertices[i].position.z + >> color // zakodowany kolor + >> discard; + Vertices[i].normal.x = ((color) & 0xff) / 255.0f; // R + Vertices[i].normal.y = ((color >> 8) & 0xff) / 255.0f; // G + Vertices[i].normal.z = ((color >> 16) & 0xff) / 255.0f; // B + } + } + else if( eType == TP_FREESPOTLIGHT ) { + // single light points only have single data point, duh + Vertices.emplace_back(); + iNumVerts = 1; } - else if (eType == TP_STARS) - { // punkty świecące dookólnie - składnia jak - // dla smt_Mesh - std::string discard; - parser.getTokens(2, false); - parser >> discard >> iNumVerts; - // Vertices=new GLVERTEX[iNumVerts]; - Vertices = new float8[iNumVerts]; - int i, j; - for (i = 0; i < iNumVerts; i++) - { - if (i % 3 == 0) - { - parser.ignoreToken(); // maska powierzchni trójkąta - } - parser.getTokens(5, false); - parser >> Vertices[i].Point.x >> Vertices[i].Point.y >> Vertices[i].Point.z >> - j // zakodowany kolor - >> discard; - Vertices[i].Normal.x = ((j)&0xFF) / 255.0; // R - Vertices[i].Normal.y = ((j >> 8) & 0xFF) / 255.0; // G - Vertices[i].Normal.z = ((j >> 16) & 0xFF) / 255.0; // B - } - } - // Visible=true; //się potem wyłączy w razie potrzeby - // iFlags|=0x0200; //wczytano z pliku tekstowego (jest właścicielem tablic) - if (iNumVerts < 1) - iFlags &= ~0x3F; // cykl renderowania uzależniony od potomnych - return iNumVerts; // do określenia wielkości VBO + // Visible=true; //się potem wyłączy w razie potrzeby + // iFlags|=0x0200; //wczytano z pliku tekstowego (jest właścicielem tablic) + if (iNumVerts < 1) + iFlags &= ~0x3F; // cykl renderowania uzależniony od potomnych + return iNumVerts; // do określenia wielkości VBO }; -int TSubModel::TriangleAdd(TModel3d *m, texture_manager::size_type tex, int tri) -{ // dodanie trójkątów do submodelu, używane - // przy tworzeniu E3D terenu +int TSubModel::TriangleAdd(TModel3d *m, material_handle tex, int tri) +{ // dodanie trójkątów do submodelu, używane przy tworzeniu E3D terenu TSubModel *s = this; - while (s ? (s->TextureID != tex) : false) + while (s ? (s->m_material != tex) : false) { // szukanie submodelu o danej teksturze if (s == this) s = Child; @@ -628,18 +602,16 @@ int TSubModel::TriangleAdd(TModel3d *m, texture_manager::size_type tex, int tri) } if (!s) { - if (TextureID <= 0) + if (m_material <= 0) s = this; // użycie głównego else { // dodanie nowego submodelu do listy potomnych s = new TSubModel(); m->AddTo(this, s); } - // s->asTexture=AnsiString(TTexturesManager::GetName(tex).c_str()); - s->TextureNameSet(TextureManager.Texture(tex).name.c_str()); - s->TextureID = tex; + s->Name_Material(GfxRenderer.Material(tex).name); + s->m_material = tex; s->eType = GL_TRIANGLES; - // iAnimOwner=0; //roboczy wskaźnik na wierzchołek } if (s->iNumVerts < 0) s->iNumVerts = tri; // bo na początku jest -1, czyli że nie wiadomo @@ -647,128 +619,39 @@ int TSubModel::TriangleAdd(TModel3d *m, texture_manager::size_type tex, int tri) s->iNumVerts += tri; // aktualizacja ilości wierzchołków return s->iNumVerts - tri; // zwraca pozycję tych trójkątów w submodelu }; +/* +basic_vertex *TSubModel::TrianglePtr(int tex, int pos, glm::vec3 const &Ambient, glm::vec3 const &Diffuse, glm::vec3 const &Specular ) +{ // zwraca wskaźnik do wypełnienia tabeli wierzchołków, używane przy tworzeniu E3D terenu -float8 *TSubModel::TrianglePtr(int tex, int pos, int *la, int *ld, int *ls) -{ // zwraca wskaźnik do wypełnienia tabeli wierzchołków, używane - // przy tworzeniu E3D terenu - TSubModel *s = this; - while (s ? s->TextureID != tex : false) - { // szukanie submodelu o danej teksturze - if (s == this) - s = Child; - else - s = s->Next; - } - if (!s) - return NULL; // coś nie tak poszło - if (!s->Vertices) - { // utworznie tabeli trójkątów - s->Vertices = new float8[s->iNumVerts]; - // iVboPtr=pos; //pozycja submodelu w tabeli wierzchołków - // pos+=iNumVerts; //rezerwacja miejsca w tabeli - s->iVboPtr = iInstance; // pozycja submodelu w tabeli wierzchołków - iInstance += s->iNumVerts; // pozycja dla następnego - } - s->ColorsSet(la, ld, ls); // ustawienie kolorów świateł - return s->Vertices + pos; // wskaźnik na wolne miejsce w tabeli wierzchołków -}; - -void TSubModel::DisplayLists() -{ // utworznie po jednej skompilowanej liście dla - // każdego submodelu - if (Global::bUseVBO) - return; // Ra: przy VBO to się nie przyda - // iFlags|=0x4000; //wyłączenie przeliczania wierzchołków, bo nie są zachowane - if (eType < TP_ROTATOR) - { - if (iNumVerts > 0) - { - uiDisplayList = glGenLists(1); - glNewList(uiDisplayList, GL_COMPILE); - glColor3fv(f4Diffuse); // McZapkie-240702: zamiast ub -#ifdef USE_VERTEX_ARRAYS - // ShaXbee-121209: przekazywanie wierzcholkow hurtem - glVertexPointer(3, GL_DOUBLE, sizeof(GLVERTEX), &Vertices[0].Point.x); - glNormalPointer(GL_DOUBLE, sizeof(GLVERTEX), &Vertices[0].Normal.x); - glTexCoordPointer(2, GL_FLOAT, sizeof(GLVERTEX), &Vertices[0].tu); - glDrawArrays(eType, 0, iNumVerts); -#else - glBegin(eType); - for (int i = 0; i < iNumVerts; i++) - { - /* - glNormal3dv(&Vertices[i].Normal.x); - glTexCoord2f(Vertices[i].tu,Vertices[i].tv); - glVertex3dv(&Vertices[i].Point.x); - */ - glNormal3fv(&Vertices[i].Normal.x); - glTexCoord2f(Vertices[i].tu, Vertices[i].tv); - glVertex3fv(&Vertices[i].Point.x); - }; - glEnd(); -#endif - glEndList(); - } - } - else if (eType == TP_FREESPOTLIGHT) - { - uiDisplayList = glGenLists(1); - glNewList(uiDisplayList, GL_COMPILE); - TextureManager.Bind(0); - // if (eType==smt_FreeSpotLight) - // { - // if (iFarAttenDecay==0) - // glColor3f(Diffuse[0],Diffuse[1],Diffuse[2]); - // } - // else - // TODO: poprawic zeby dzialalo - // glColor3f(f4Diffuse[0],f4Diffuse[1],f4Diffuse[2]); - glColorMaterial(GL_FRONT, GL_EMISSION); - glDisable(GL_LIGHTING); // Tolaris-030603: bo mu punkty swiecace sie blendowaly - glBegin(GL_POINTS); - glVertex3f(0, 0, 0); - glEnd(); - glEnable(GL_LIGHTING); - glColorMaterial(GL_FRONT, GL_AMBIENT_AND_DIFFUSE); - glMaterialfv(GL_FRONT, GL_EMISSION, emm2); - glEndList(); - } - else if (eType == TP_STARS) - { // punkty świecące dookólnie - uiDisplayList = glGenLists(1); - glNewList(uiDisplayList, GL_COMPILE); - TextureManager.Bind(0); // tekstury nie ma - glColorMaterial(GL_FRONT, GL_EMISSION); - glDisable(GL_LIGHTING); // Tolaris-030603: bo mu punkty swiecace sie blendowaly - glBegin(GL_POINTS); - for (int i = 0; i < iNumVerts; i++) - { - glColor3f(Vertices[i].Normal.x, Vertices[i].Normal.y, Vertices[i].Normal.z); - // glVertex3dv(&Vertices[i].Point.x); - glVertex3fv(&Vertices[i].Point.x); - }; - glEnd(); - glEnable(GL_LIGHTING); - glColorMaterial(GL_FRONT, GL_AMBIENT_AND_DIFFUSE); - glMaterialfv(GL_FRONT, GL_EMISSION, emm2); - glEndList(); - } - // SafeDeleteArray(Vertices); //przy VBO muszą zostać do załadowania całego - // modelu - if (Child) - Child->DisplayLists(); - if (Next) - Next->DisplayLists(); + TSubModel *s = this; + while (s ? s->TextureID != tex : false) + { // szukanie submodelu o danej teksturze + if (s == this) + s = Child; + else + s = s->Next; + } + if (!s) + return NULL; // coś nie tak poszło + if (!s->Vertices) + { // utworznie tabeli trójkątów + s->Vertices = new basic_vertex[s->iNumVerts]; + s->iVboPtr = iInstance; // pozycja submodelu w tabeli wierzchołków + iInstance += s->iNumVerts; // pozycja dla następnego + } + s->ColorsSet(Ambient, Diffuse, Specular); // ustawienie kolorów świateł + return s->Vertices + pos; // wskaźnik na wolne miejsce w tabeli wierzchołków }; +*/ void TSubModel::InitialRotate(bool doit) { // konwersja układu współrzędnych na zgodny ze scenerią if (iFlags & 0xC000) // jeśli jest animacja albo niejednostkowy transform { // niejednostkowy transform jest mnożony i wystarczy zabawy - if (doit) - { // obrót lewostronny - if (!fMatrix) // macierzy może nie być w dodanym "bananie" - { + if (doit) { + // obrót lewostronny + if (!fMatrix) { + // macierzy może nie być w dodanym "bananie" fMatrix = new float4x4(); // tworzy macierz o przypadkowej zawartości fMatrix->Identity(); // a zaczynamy obracanie od jednostkowej } @@ -777,47 +660,55 @@ void TSubModel::InitialRotate(bool doit) if (fMatrix->IdentityIs()) iFlags &= ~0x8000; // jednak jednostkowa po obróceniu } - if (Child) - Child->InitialRotate(false); // potomnych nie obracamy już, tylko - // ewentualnie optymalizujemy - else if (Global::iConvertModels & 2) // optymalizacja jest opcjonalna + if( Child ) { + // potomnych nie obracamy już, tylko ewentualnie optymalizujemy + Child->InitialRotate( false ); + } + else if (Global.iConvertModels & 2) { + // optymalizacja jest opcjonalna if ((iFlags & 0xC000) == 0x8000) // o ile nie ma animacji - { // jak nie ma potomnych, można wymnożyć przez transform i wyjedynkować - // go + { // jak nie ma potomnych, można wymnożyć przez transform i wyjedynkować go float4x4 *mat = GetMatrix(); // transform submodelu - if (Vertices) - { - for (int i = 0; i < iNumVerts; ++i) - Vertices[i].Point = (*mat) * Vertices[i].Point; - (*mat)(3)[0] = (*mat)(3)[1] = (*mat)(3)[2] = - 0.0; // zerujemy przesunięcie przed obracaniem normalnych - if (eType != TP_STARS) // gwiazdki mają kolory zamiast normalnych, to - // ich wtedy nie ruszamy - for (int i = 0; i < iNumVerts; ++i) - Vertices[i].Normal = SafeNormalize((*mat) * Vertices[i].Normal); + if( false == Vertices.empty() ) { + for( auto &vertex : Vertices ) { + vertex.position = (*mat) * vertex.position; + } + // zerujemy przesunięcie przed obracaniem normalnych + (*mat)(3)[0] = (*mat)(3)[1] = (*mat)(3)[2] = 0.0; + if( eType != TP_STARS ) { + // gwiazdki mają kolory zamiast normalnych, to ich wtedy nie ruszamy + for( auto &vertex : Vertices ) { + vertex.normal = ( + glm::length( vertex.normal ) > 0.0f ? + glm::normalize( ( *mat ) * vertex.normal ) : + glm::vec3() ); + } + } } mat->Identity(); // jedynkowanie transformu po przeliczeniu wierzchołków iFlags &= ~0x8000; // transform jedynkowy } + } } else // jak jest jednostkowy i nie ma animacji if (doit) { // jeśli jest jednostkowy transform, to przeliczamy // wierzchołki, a mnożenie podajemy dalej - double t; - if (Vertices) - for (int i = 0; i < iNumVerts; ++i) - { - Vertices[i].Point.x = -Vertices[i].Point.x; // zmiana znaku X - t = Vertices[i].Point.y; // zamiana Y i Z - Vertices[i].Point.y = Vertices[i].Point.z; - Vertices[i].Point.z = t; - // wektory normalne również trzeba przekształcić, bo się źle oświetlają - Vertices[i].Normal.x = -Vertices[i].Normal.x; // zmiana znaku X - t = Vertices[i].Normal.y; // zamiana Y i Z - Vertices[i].Normal.y = Vertices[i].Normal.z; - Vertices[i].Normal.z = t; + float swapcopy; + for( auto &vertex : Vertices ) { + vertex.position.x = -vertex.position.x; // zmiana znaku X + swapcopy = vertex.position.y; // zamiana Y i Z + vertex.position.y = vertex.position.z; + vertex.position.z = swapcopy; + // wektory normalne również trzeba przekształcić, bo się źle oświetlają + if( eType != TP_STARS ) { + // gwiazdki mają kolory zamiast normalnych, to // ich wtedy nie ruszamy + vertex.normal.x = -vertex.normal.x; // zmiana znaku X + swapcopy = vertex.normal.y; // zamiana Y i Z + vertex.normal.y = vertex.normal.z; + vertex.normal.z = swapcopy; } + } if (Child) Child->InitialRotate(doit); // potomne ewentualnie obrócimy } @@ -827,1588 +718,1128 @@ void TSubModel::InitialRotate(bool doit) void TSubModel::ChildAdd(TSubModel *SubModel) { // dodanie submodelu potemnego (uzależnionego) - // Ra: zmiana kolejności, żeby kolejne móc renderować po aktualnym (było - // przed) - if (SubModel) - SubModel->NextAdd(Child); // Ra: zmiana kolejności renderowania - Child = SubModel; + // Ra: zmiana kolejności, żeby kolejne móc renderować po aktualnym (było + // przed) + if (SubModel) + SubModel->NextAdd(Child); // Ra: zmiana kolejności renderowania + Child = SubModel; }; void TSubModel::NextAdd(TSubModel *SubModel) { // dodanie submodelu kolejnego (wspólny przodek) - if (Next) - Next->NextAdd(SubModel); - else - Next = SubModel; + if (Next) + Next->NextAdd(SubModel); + else + Next = SubModel; }; +int TSubModel::count_siblings() { + + auto siblingcount { 0 }; + auto *sibling { Next }; + while( sibling != nullptr ) { + ++siblingcount; + sibling = sibling->Next; + } + return siblingcount; +} + +int TSubModel::count_children() { + + return ( + Child == nullptr ? + 0 : + 1 + Child->count_siblings() ); +} + int TSubModel::FlagsCheck() { // analiza koniecznych zmian pomiędzy submodelami - // samo pomijanie glBindTexture() nie poprawi wydajności - // ale można sprawdzić, czy można w ogóle pominąć kod do tekstur (sprawdzanie - // replaceskin) - int i = 0; - if (Child) - { // Child jest renderowany po danym submodelu - if (Child->TextureID) // o ile ma teksturę - if (Child->TextureID != TextureID) // i jest ona inna niż rodzica - Child->iFlags |= 0x80; // to trzeba sprawdzać, jak z teksturami jest - i = Child->FlagsCheck(); - iFlags |= 0x00FF0000 & ((i << 16) | (i) | (i >> 8)); // potomny, rodzeństwo i dzieci - if (eType == TP_TEXT) - { // wyłączenie renderowania Next dla znaków - // wyświetlacza tekstowego - TSubModel *p = Child; - while (p) - { - p->iFlags &= 0xC0FFFFFF; - p = p->Next; - } - } - } - if (Next) - { // Next jest renderowany po danym submodelu (kolejność odwrócona - // po wczytaniu T3D) - if (TextureID) // o ile dany ma teksturę - if ((TextureID != Next->TextureID) || - (i & 0x00800000)) // a ma inną albo dzieci zmieniają - iFlags |= 0x80; // to dany submodel musi sobie ją ustawiać - i = Next->FlagsCheck(); - iFlags |= 0xFF000000 & ((i << 24) | (i << 8) | (i)); // następny, kolejne i ich dzieci - // tekstury nie ustawiamy tylko wtedy, gdy jest taka sama jak Next i jego - // dzieci nie zmieniają - } - return iFlags; + // samo pomijanie glBindTexture() nie poprawi wydajności + // ale można sprawdzić, czy można w ogóle pominąć kod do tekstur (sprawdzanie + // replaceskin) + int i = 0; + if (Child) + { // Child jest renderowany po danym submodelu + if (Child->m_material) // o ile ma teksturę + if (Child->m_material != m_material) // i jest ona inna niż rodzica + Child->iFlags |= 0x80; // to trzeba sprawdzać, jak z teksturami jest + i = Child->FlagsCheck(); + iFlags |= 0x00FF0000 & ((i << 16) | (i) | (i >> 8)); // potomny, rodzeństwo i dzieci + if (eType == TP_TEXT) + { // wyłączenie renderowania Next dla znaków + // wyświetlacza tekstowego + TSubModel *p = Child; + while (p) + { + p->iFlags &= 0xC0FFFFFF; + p = p->Next; + } + } + } + if (Next) + { // Next jest renderowany po danym submodelu (kolejność odwrócona + // po wczytaniu T3D) + if (m_material) // o ile dany ma teksturę + if ((m_material != Next->m_material) || + (i & 0x00800000)) // a ma inną albo dzieci zmieniają + iFlags |= 0x80; // to dany submodel musi sobie ją ustawiać + i = Next->FlagsCheck(); + iFlags |= 0xFF000000 & ((i << 24) | (i << 8) | (i)); // następny, kolejne i ich dzieci + // tekstury nie ustawiamy tylko wtedy, gdy jest taka sama jak Next i jego + // dzieci nie zmieniają + } + return iFlags; }; void TSubModel::SetRotate(float3 vNewRotateAxis, float fNewAngle) { // obrócenie submodelu wg podanej - // osi (np. wskazówki w kabinie) - v_RotateAxis = vNewRotateAxis; - f_Angle = fNewAngle; - if (fNewAngle != 0.0) - { - b_Anim = at_Rotate; - b_aAnim = at_Rotate; - } - iAnimOwner = iInstance; // zapamiętanie czyja jest animacja + // osi (np. wskazówki w kabinie) + v_RotateAxis = vNewRotateAxis; + f_Angle = fNewAngle; + if (fNewAngle != 0.0) + { + b_Anim = TAnimType::at_Rotate; + b_aAnim = TAnimType::at_Rotate; + } + iAnimOwner = iInstance; // zapamiętanie czyja jest animacja } void TSubModel::SetRotateXYZ(float3 vNewAngles) { // obrócenie submodelu o - // podane kąty wokół osi - // lokalnego układu - v_Angles = vNewAngles; - b_Anim = at_RotateXYZ; - b_aAnim = at_RotateXYZ; - iAnimOwner = iInstance; // zapamiętanie czyja jest animacja + // podane kąty wokół osi + // lokalnego układu + v_Angles = vNewAngles; + b_Anim = TAnimType::at_RotateXYZ; + b_aAnim = TAnimType::at_RotateXYZ; + iAnimOwner = iInstance; // zapamiętanie czyja jest animacja } -void TSubModel::SetRotateXYZ(vector3 vNewAngles) +void TSubModel::SetRotateXYZ( Math3D::vector3 vNewAngles) { // obrócenie submodelu o - // podane kąty wokół osi - // lokalnego układu - v_Angles.x = vNewAngles.x; - v_Angles.y = vNewAngles.y; - v_Angles.z = vNewAngles.z; - b_Anim = at_RotateXYZ; - b_aAnim = at_RotateXYZ; - iAnimOwner = iInstance; // zapamiętanie czyja jest animacja + // podane kąty wokół osi + // lokalnego układu + v_Angles.x = vNewAngles.x; + v_Angles.y = vNewAngles.y; + v_Angles.z = vNewAngles.z; + b_Anim = TAnimType::at_RotateXYZ; + b_aAnim = TAnimType::at_RotateXYZ; + iAnimOwner = iInstance; // zapamiętanie czyja jest animacja } void TSubModel::SetTranslate(float3 vNewTransVector) { // przesunięcie submodelu (np. w kabinie) - v_TransVector = vNewTransVector; - b_Anim = at_Translate; - b_aAnim = at_Translate; - iAnimOwner = iInstance; // zapamiętanie czyja jest animacja + v_TransVector = vNewTransVector; + b_Anim = TAnimType::at_Translate; + b_aAnim = TAnimType::at_Translate; + iAnimOwner = iInstance; // zapamiętanie czyja jest animacja } -void TSubModel::SetTranslate(vector3 vNewTransVector) +void TSubModel::SetTranslate( Math3D::vector3 vNewTransVector) { // przesunięcie submodelu (np. w kabinie) - v_TransVector.x = vNewTransVector.x; - v_TransVector.y = vNewTransVector.y; - v_TransVector.z = vNewTransVector.z; - b_Anim = at_Translate; - b_aAnim = at_Translate; - iAnimOwner = iInstance; // zapamiętanie czyja jest animacja + v_TransVector.x = vNewTransVector.x; + v_TransVector.y = vNewTransVector.y; + v_TransVector.z = vNewTransVector.z; + b_Anim = TAnimType::at_Translate; + b_aAnim = TAnimType::at_Translate; + iAnimOwner = iInstance; // zapamiętanie czyja jest animacja } void TSubModel::SetRotateIK1(float3 vNewAngles) { // obrócenie submodelu o - // podane kąty wokół osi - // lokalnego układu - v_Angles = vNewAngles; - iAnimOwner = iInstance; // zapamiętanie czyja jest animacja + // podane kąty wokół osi + // lokalnego układu + v_Angles = vNewAngles; + iAnimOwner = iInstance; // zapamiętanie czyja jest animacja } struct ToLower { - char operator()(char input) - { - return tolower(input); - } + char operator()(char input) + { + return tolower(input); + } }; TSubModel *TSubModel::GetFromName(std::string const &search, bool i) { - return GetFromName(search.c_str(), i); -}; - -TSubModel *TSubModel::GetFromName(char const *search, bool i) -{ - TSubModel *result; - // std::transform(search.begin(),search.end(),search.begin(),ToLower()); - // search=search.LowerCase(); - // AnsiString name=AnsiString(); - if (pName && search) - if ((i ? stricmp(pName, search) : strcmp(pName, search)) == 0) - return this; - else if (pName == search) - return this; // oba NULL - if (Next) - { - result = Next->GetFromName(search); - if (result) - return result; - } - if (Child) - { - result = Child->GetFromName(search); - if (result) - return result; - } - return NULL; + TSubModel *result; + // std::transform(search.begin(),search.end(),search.begin(),ToLower()); + // search=search.LowerCase(); + // AnsiString name=AnsiString(); + std::string search_lc = search; + if (i) + std::transform(search_lc.begin(), search_lc.end(), search_lc.begin(), ::tolower); + std::string pName_lc = pName; + if (i) + std::transform(pName_lc.begin(), pName_lc.end(), pName_lc.begin(), ::tolower); + if (pName.size() && search.size()) + if (pName_lc == search_lc) + return this; + if (Next) + { + result = Next->GetFromName(search); + if (result) + return result; + } + if (Child) + { + result = Child->GetFromName(search); + if (result) + return result; + } + return NULL; }; // WORD hbIndices[18]={3,0,1,5,4,2,1,0,4,1,5,3,2,3,5,2,4,0}; void TSubModel::RaAnimation(TAnimType a) { // wykonanie animacji niezależnie od renderowania - switch (a) - { // korekcja położenia, jeśli submodel jest animowany - case at_Translate: // Ra: było "true" - if (iAnimOwner != iInstance) - break; // cudza animacja - glTranslatef(v_TransVector.x, v_TransVector.y, v_TransVector.z); - break; - case at_Rotate: // Ra: było "true" - if (iAnimOwner != iInstance) - break; // cudza animacja - glRotatef(f_Angle, v_RotateAxis.x, v_RotateAxis.y, v_RotateAxis.z); - break; - case at_RotateXYZ: - if (iAnimOwner != iInstance) - break; // cudza animacja - glTranslatef(v_TransVector.x, v_TransVector.y, v_TransVector.z); - glRotatef(v_Angles.x, 1.0, 0.0, 0.0); - glRotatef(v_Angles.y, 0.0, 1.0, 0.0); - glRotatef(v_Angles.z, 0.0, 0.0, 1.0); - break; - case at_SecondsJump: // sekundy z przeskokiem - glRotatef(floor(GlobalTime->mr) * 6.0, 0.0, 1.0, 0.0); - break; - case at_MinutesJump: // minuty z przeskokiem - glRotatef(GlobalTime->mm * 6.0, 0.0, 1.0, 0.0); - break; - case at_HoursJump: // godziny skokowo 12h/360° - glRotatef(GlobalTime->hh * 30.0 * 0.5, 0.0, 1.0, 0.0); - break; - case at_Hours24Jump: // godziny skokowo 24h/360° - glRotatef(GlobalTime->hh * 15.0 * 0.25, 0.0, 1.0, 0.0); - break; - case at_Seconds: // sekundy płynnie - glRotatef(GlobalTime->mr * 6.0, 0.0, 1.0, 0.0); - break; - case at_Minutes: // minuty płynnie - glRotatef(GlobalTime->mm * 6.0 + GlobalTime->mr * 0.1, 0.0, 1.0, 0.0); - break; - case at_Hours: // godziny płynnie 12h/360° - // glRotatef(GlobalTime->hh*30.0+GlobalTime->mm*0.5+GlobalTime->mr/120.0,0.0,1.0,0.0); - glRotatef(2.0 * Global::fTimeAngleDeg, 0.0, 1.0, 0.0); - break; - case at_Hours24: // godziny płynnie 24h/360° - // glRotatef(GlobalTime->hh*15.0+GlobalTime->mm*0.25+GlobalTime->mr/240.0,0.0,1.0,0.0); - glRotatef(Global::fTimeAngleDeg, 0.0, 1.0, 0.0); - break; - case at_Billboard: // obrót w pionie do kamery - { - matrix4x4 mat; // potrzebujemy współrzędne przesunięcia środka układu - // współrzędnych submodelu - glGetDoublev(GL_MODELVIEW_MATRIX, mat.getArray()); // pobranie aktualnej matrycy - float3 gdzie = float3(mat[3][0], mat[3][1], - mat[3][2]); // początek układu współrzędnych submodelu względem kamery - glLoadIdentity(); // macierz jedynkowa - glTranslatef(gdzie.x, gdzie.y, gdzie.z); // początek układu zostaje bez - // zmian - glRotated(atan2(gdzie.x, gdzie.z) * 180.0 / M_PI, 0.0, 1.0, - 0.0); // jedynie obracamy w pionie o kąt + switch (a) + { // korekcja położenia, jeśli submodel jest animowany + case TAnimType::at_Translate: // Ra: było "true" + if (iAnimOwner != iInstance) + break; // cudza animacja + glTranslatef(v_TransVector.x, v_TransVector.y, v_TransVector.z); + break; + case TAnimType::at_Rotate: // Ra: było "true" + if (iAnimOwner != iInstance) + break; // cudza animacja + glRotatef(f_Angle, v_RotateAxis.x, v_RotateAxis.y, v_RotateAxis.z); + break; + case TAnimType::at_RotateXYZ: + if (iAnimOwner != iInstance) + break; // cudza animacja + glTranslatef(v_TransVector.x, v_TransVector.y, v_TransVector.z); + glRotatef(v_Angles.x, 1.0f, 0.0f, 0.0f); + glRotatef(v_Angles.y, 0.0f, 1.0f, 0.0f); + glRotatef(v_Angles.z, 0.0f, 0.0f, 1.0f); + break; + case TAnimType::at_SecondsJump: // sekundy z przeskokiem + glRotatef(simulation::Time.data().wSecond * 6.0, 0.0, 1.0, 0.0); + break; + case TAnimType::at_MinutesJump: // minuty z przeskokiem + glRotatef(simulation::Time.data().wMinute * 6.0, 0.0, 1.0, 0.0); + break; + case TAnimType::at_HoursJump: // godziny skokowo 12h/360° + glRotatef(simulation::Time.data().wHour * 30.0 * 0.5, 0.0, 1.0, 0.0); + break; + case TAnimType::at_Hours24Jump: // godziny skokowo 24h/360° + glRotatef(simulation::Time.data().wHour * 15.0 * 0.25, 0.0, 1.0, 0.0); + break; + case TAnimType::at_Seconds: // sekundy płynnie + glRotatef(simulation::Time.second() * 6.0, 0.0, 1.0, 0.0); + break; + case TAnimType::at_Minutes: // minuty płynnie + glRotatef(simulation::Time.data().wMinute * 6.0 + simulation::Time.second() * 0.1, 0.0, 1.0, 0.0); + break; + case TAnimType::at_Hours: // godziny płynnie 12h/360° + glRotatef(2.0 * Global.fTimeAngleDeg, 0.0, 1.0, 0.0); + break; + case TAnimType::at_Hours24: // godziny płynnie 24h/360° + glRotatef(Global.fTimeAngleDeg, 0.0, 1.0, 0.0); + break; + case TAnimType::at_Billboard: // obrót w pionie do kamery + { + Math3D::matrix4x4 mat; mat.OpenGL_Matrix( OpenGLMatrices.data_array( GL_MODELVIEW ) ); + float3 gdzie = float3(mat[3][0], mat[3][1], mat[3][2]); // początek układu współrzędnych submodelu względem kamery + glLoadIdentity(); // macierz jedynkowa + glTranslatef(gdzie.x, gdzie.y, gdzie.z); // początek układu zostaje bez + // zmian + glRotated(atan2(gdzie.x, gdzie.z) * 180.0 / M_PI, 0.0, 1.0, + 0.0); // jedynie obracamy w pionie o kąt + } + break; + case TAnimType::at_Wind: // ruch pod wpływem wiatru (wiatr będziemy liczyć potem...) + glRotated(1.5 * std::sin(M_PI * simulation::Time.second() / 6.0), 0.0, 1.0, 0.0); + break; + case TAnimType::at_Sky: // animacja nieba + glRotated(Global.fLatitudeDeg, 1.0, 0.0, 0.0); // ustawienie osi OY na północ + // glRotatef(Global.fTimeAngleDeg,0.0,1.0,0.0); //obrót dobowy osi OX + glRotated(-fmod(Global.fTimeAngleDeg, 360.0), 0.0, 1.0, 0.0); // obrót dobowy osi OX + break; + case TAnimType::at_IK11: // ostatni element animacji szkieletowej (podudzie, stopa) + glRotatef(v_Angles.z, 0.0f, 1.0f, 0.0f); // obrót względem osi pionowej (azymut) + glRotatef(v_Angles.x, 1.0f, 0.0f, 0.0f); // obrót względem poziomu (deklinacja) + break; + case TAnimType::at_DigiClk: // animacja zegara cyfrowego + { // ustawienie animacji w submodelach potomnych + TSubModel *sm = ChildGet(); + do { // pętla po submodelach potomnych i obracanie ich o kąt zależy od czasu + if( sm->pName.size() ) { + // musi mieć niepustą nazwę + if( ( sm->pName[ 0 ] >= '0' ) + && ( sm->pName[ 0 ] <= '5') ) { + // zegarek ma 6 cyfr maksymalnie + sm->SetRotate( + float3( 0, 1, 0 ), + -Global.fClockAngleDeg[ sm->pName[ 0 ] - '0' ] ); + } + } + sm = sm->NextGet(); + } while (sm); + } + break; + } + if (mAnimMatrix) // można by to dać np. do at_Translate + { + glMultMatrixf(mAnimMatrix->readArray()); + mAnimMatrix = NULL; // jak animator będzie potrzebował, to ustawi ponownie + } +}; + + //--------------------------------------------------------------------------- + +void TSubModel::serialize_geometry( std::ostream &Output ) const { + + if( Child ) { + Child->serialize_geometry( Output ); } - break; - case at_Wind: // ruch pod wpływem wiatru (wiatr będziemy liczyć potem...) - glRotated(1.5 * sin(M_PI * GlobalTime->mr / 6.0), 0.0, 1.0, 0.0); - break; - case at_Sky: // animacja nieba - glRotated(Global::fLatitudeDeg, 1.0, 0.0, 0.0); // ustawienie osi OY na północ - // glRotatef(Global::fTimeAngleDeg,0.0,1.0,0.0); //obrót dobowy osi OX - glRotated(-fmod(Global::fTimeAngleDeg, 360.0), 0.0, 1.0, 0.0); // obrót dobowy osi OX - break; - case at_IK11: // ostatni element animacji szkieletowej (podudzie, stopa) - glRotatef(v_Angles.z, 0.0, 1.0, 0.0); // obrót względem osi pionowej - // (azymut) - glRotatef(v_Angles.x, 1.0, 0.0, 0.0); // obrót względem poziomu (deklinacja) - break; - case at_DigiClk: // animacja zegara cyfrowego - { // ustawienie animacji w submodelach potomnych - TSubModel *sm = ChildGet(); - do - { // pętla po submodelach potomnych i obracanie ich o kąt zależy od czasu - if (sm->pName) - { // musi mieć niepustą nazwę - if ((sm->pName[0]) >= '0') - if ((sm->pName[0]) <= '5') // zegarek ma 6 cyfr maksymalnie - sm->SetRotate(float3(0, 1, 0), - -Global::fClockAngleDeg[(sm->pName[0]) - '0']); - } - sm = sm->NextGet(); - } while (sm); + if( m_geometry != null_handle ) { + for( auto const &vertex : GfxRenderer.Vertices( m_geometry ) ) { + vertex.serialize( Output ); + } } - break; - } - if (mAnimMatrix) // można by to dać np. do at_Translate - { - glMultMatrixf(mAnimMatrix->readArray()); - mAnimMatrix = NULL; // jak animator będzie potrzebował, to ustawi ponownie + if( Next ) { + Next->serialize_geometry( Output ); } }; -void TSubModel::RenderDL() -{ // główna procedura renderowania przez DL - if (iVisible && (fSquareDist >= fSquareMinDist) && (fSquareDist < fSquareMaxDist)) - { - if (iFlags & 0xC000) - { - glPushMatrix(); - if (fMatrix) - glMultMatrixf(fMatrix->readArray()); - if (b_Anim) - RaAnimation(b_Anim); - } - if (eType < TP_ROTATOR) - { // renderowanie obiektów OpenGL - if (iAlpha & iFlags & 0x1F) // rysuj gdy element nieprzezroczysty - { - if (TextureID < 0) // && (ReplacableSkinId!=0)) - { // zmienialne skóry - TextureManager.Bind(ReplacableSkinId[-TextureID]); - // TexAlpha=!(iAlpha&1); //zmiana tylko w przypadku wymienej tekstury - } - else - TextureManager.Bind(TextureID); // również 0 - if (Global::fLuminance < fLight) - { - glMaterialfv(GL_FRONT, GL_EMISSION, f4Diffuse); // zeby swiecilo na kolorowo - glCallList(uiDisplayList); // tylko dla siatki - glMaterialfv(GL_FRONT, GL_EMISSION, emm2); - } - else - glCallList(uiDisplayList); // tylko dla siatki - } - } - else if (eType == TP_FREESPOTLIGHT) - { // wersja DL - matrix4x4 mat; // macierz opisuje układ renderowania względem kamery - glGetDoublev(GL_MODELVIEW_MATRIX, mat.getArray()); - // kąt między kierunkiem światła a współrzędnymi kamery - vector3 gdzie = mat * vector3(0, 0, 0); // pozycja punktu świecącego względem kamery - fCosViewAngle = DotProduct(Normalize(mat * vector3(0, 0, 1) - gdzie), Normalize(gdzie)); - if (fCosViewAngle > fCosFalloffAngle) // kąt większy niż maksymalny stożek swiatła - { - double Distdimm = 1.0; - if (fCosViewAngle < - fCosHotspotAngle) // zmniejszona jasność między Hotspot a Falloff - if (fCosFalloffAngle < fCosHotspotAngle) - Distdimm = 1.0 - - (fCosHotspotAngle - fCosViewAngle) / - (fCosHotspotAngle - fCosFalloffAngle); - glColor3f(f4Diffuse[0] * Distdimm, f4Diffuse[1] * Distdimm, - f4Diffuse[2] * Distdimm); - /* TODO: poprawic to zeby dzialalo - if (iFarAttenDecay>0) - switch (iFarAttenDecay) - { - case 1: - Distdimm=fFarDecayRadius/(1+sqrt(fSquareDist)); - //dorobic od kata - break; - case 2: - Distdimm=fFarDecayRadius/(1+fSquareDist); - //dorobic od kata - break; - } - if (Distdimm>1) - Distdimm=1; - glColor3f(Diffuse[0]*Distdimm,Diffuse[1]*Distdimm,Diffuse[2]*Distdimm); - */ - // glPopMatrix(); - // return; - glCallList(uiDisplayList); // wyświetlenie warunkowe - } - } - else if (eType == TP_STARS) - { - // glDisable(GL_LIGHTING); //Tolaris-030603: bo mu punkty swiecace sie - // blendowaly - if (Global::fLuminance < fLight) - { - glMaterialfv(GL_FRONT, GL_EMISSION, f4Diffuse); // zeby swiecilo na kolorowo - glCallList(uiDisplayList); // narysuj naraz wszystkie punkty z DL - glMaterialfv(GL_FRONT, GL_EMISSION, emm2); - } - } - if (Child != NULL) - if (iAlpha & iFlags & 0x001F0000) - Child->RenderDL(); - if (iFlags & 0xC000) - glPopMatrix(); +void +TSubModel::create_geometry( std::size_t &Dataoffset, gfx::geometrybank_handle const &Bank ) { + + // data offset is used to determine data offset of each submodel into single shared geometry bank + // (the offsets are part of legacy system which we now need to work around for backward compatibility) + if( Child ) + Child->create_geometry( Dataoffset, Bank ); + + if( false == Vertices.empty() ) { + + tVboPtr = static_cast( Dataoffset ); + Dataoffset += Vertices.size(); + // conveniently all relevant custom node types use GL_POINTS, or we'd have to determine the type on individual basis + auto type = ( + eType < TP_ROTATOR ? + eType : + GL_POINTS ); + m_geometry = GfxRenderer.Insert( Vertices, Bank, type ); } - if (b_Anim < at_SecondsJump) - b_Anim = at_None; // wyłączenie animacji dla kolejnego użycia subm - if (Next) - if (iAlpha & iFlags & 0x1F000000) - Next->RenderDL(); // dalsze rekurencyjnie -}; // Render -void TSubModel::RenderAlphaDL() -{ // renderowanie przezroczystych przez DL - if (iVisible && (fSquareDist >= fSquareMinDist) && (fSquareDist < fSquareMaxDist)) - { - if (iFlags & 0xC000) - { - glPushMatrix(); - if (fMatrix) - glMultMatrixf(fMatrix->readArray()); - if (b_aAnim) - RaAnimation(b_aAnim); - } - if (eType < TP_ROTATOR) - { // renderowanie obiektów OpenGL - if (iAlpha & iFlags & 0x2F) // rysuj gdy element przezroczysty - { - if (TextureID < 0) // && (ReplacableSkinId!=0)) - { // zmienialne skóry - TextureManager.Bind(ReplacableSkinId[-TextureID]); - // TexAlpha=iAlpha&1; //zmiana tylko w przypadku wymienej tekstury - } - else - TextureManager.Bind(TextureID); // również 0 - if (Global::fLuminance < fLight) - { - glMaterialfv(GL_FRONT, GL_EMISSION, f4Diffuse); // zeby swiecilo na kolorowo - glCallList(uiDisplayList); // tylko dla siatki - glMaterialfv(GL_FRONT, GL_EMISSION, emm2); - } - else - glCallList(uiDisplayList); // tylko dla siatki + if( m_geometry != NULL ) { + // calculate bounding radius while we're at it + float squaredradius {}; + // if this happens to be root node it may already have non-squared radius of the largest child + // since we're comparing squared radii, we need to square it back for correct results + m_boundingradius *= m_boundingradius; + auto const submodeloffset { offset( std::numeric_limits::max() ) }; + for( auto const &vertex : GfxRenderer.Vertices( m_geometry ) ) { + squaredradius = glm::length2( submodeloffset + vertex.position ); + if( squaredradius > m_boundingradius ) { + m_boundingradius = squaredradius; } } - else if (eType == TP_FREESPOTLIGHT) - { - // dorobić aureolę! + if( m_boundingradius > 0.f ) { m_boundingradius = std::sqrt( m_boundingradius ); } + // adjust overall radius if needed + // NOTE: the method to access root submodel is... less than ideal + auto *root { this }; + while( root->Parent != nullptr ) { + root = root->Parent; } - if (Child != NULL) - if (eType == TP_TEXT) - { // tekst renderujemy w specjalny sposób, zamiast - // submodeli z łańcucha Child - int i, j = pasText->size(); - TSubModel *p; - char c; - if (!smLetter) - { // jeśli nie ma tablicy, to ją stworzyć; miejsce - // nieodpowiednie, ale tymczasowo - // może być - smLetter = new TSubModel *[256]; // tablica wskaźników submodeli dla - // wyświetlania tekstu - ZeroMemory(smLetter, 256 * sizeof(TSubModel *)); // wypełnianie zerami - p = Child; - while (p) - { - smLetter[*p->pName] = p; - p = p->Next; // kolejny znak - } - } - for (i = 1; i <= j; ++i) - { - p = smLetter[(*pasText)[i]]; // znak do wyświetlenia - if (p) - { // na razie tylko jako przezroczyste - p->RenderAlphaDL(); - if (p->fMatrix) - glMultMatrixf(p->fMatrix->readArray()); // przesuwanie widoku - } - } - } - else if (iAlpha & iFlags & 0x002F0000) - Child->RenderAlphaDL(); - if (iFlags & 0xC000) - glPopMatrix(); + root->m_boundingradius = std::max( + root->m_boundingradius, + m_boundingradius ); } - if (b_aAnim < at_SecondsJump) - b_aAnim = at_None; // wyłączenie animacji dla kolejnego użycia submodelu - if (Next != NULL) - if (iAlpha & iFlags & 0x2F000000) - Next->RenderAlphaDL(); -}; // RenderAlpha -void TSubModel::RenderVBO() -{ // główna procedura renderowania przez VBO - if (iVisible && (fSquareDist >= fSquareMinDist) && (fSquareDist < fSquareMaxDist)) - { - if (iFlags & 0xC000) - { - glPushMatrix(); - if (fMatrix) - glMultMatrixf(fMatrix->readArray()); - if (b_Anim) - RaAnimation(b_Anim); - } - if (eType < TP_ROTATOR) - { // renderowanie obiektów OpenGL - if (iAlpha & iFlags & 0x1F) // rysuj gdy element nieprzezroczysty - { - if (TextureID < 0) // && (ReplacableSkinId!=0)) - { // zmienialne skóry - TextureManager.Bind(ReplacableSkinId[-TextureID]); - // TexAlpha=!(iAlpha&1); //zmiana tylko w przypadku wymienej tekstury - } - else - TextureManager.Bind(TextureID); // również 0 - glColor3fv(f4Diffuse); // McZapkie-240702: zamiast ub - // glMaterialfv(GL_FRONT,GL_AMBIENT_AND_DIFFUSE,f4Diffuse); //to samo, - // co glColor - if (Global::fLuminance < fLight) - { - glMaterialfv(GL_FRONT, GL_EMISSION, f4Diffuse); // zeby swiecilo na kolorowo - glDrawArrays(eType, iVboPtr, - iNumVerts); // narysuj naraz wszystkie trójkąty z VBO - glMaterialfv(GL_FRONT, GL_EMISSION, emm2); - } - else - glDrawArrays(eType, iVboPtr, - iNumVerts); // narysuj naraz wszystkie trójkąty z VBO - } - } - else if (eType == TP_FREESPOTLIGHT) - { // wersja VBO - matrix4x4 mat; // macierz opisuje układ renderowania względem kamery - glGetDoublev(GL_MODELVIEW_MATRIX, mat.getArray()); - // kąt między kierunkiem światła a współrzędnymi kamery - vector3 gdzie = mat * vector3(0, 0, 0); // pozycja punktu świecącego względem kamery - fCosViewAngle = DotProduct(Normalize(mat * vector3(0, 0, 1) - gdzie), Normalize(gdzie)); - if (fCosViewAngle > fCosFalloffAngle) // kąt większy niż maksymalny stożek swiatła - { - double Distdimm = 1.0; - if (fCosViewAngle < - fCosHotspotAngle) // zmniejszona jasność między Hotspot a Falloff - if (fCosFalloffAngle < fCosHotspotAngle) - Distdimm = 1.0 - - (fCosHotspotAngle - fCosViewAngle) / - (fCosHotspotAngle - fCosFalloffAngle); + if( Next ) + Next->create_geometry( Dataoffset, Bank ); +} - /* TODO: poprawic to zeby dzialalo - - 2- Inverse (Applies inverse decay. The formula is luminance=R0/R, where - R0 is - the radial source of the light if no attenuation is - used, or the Near End - value of the light if Attenuation is used. R is the - radial distance of the - illuminated surface from R0.) - - 3- Inverse Square (Applies inverse-square decay. The formula for this is - (R0/R)^2. - This is actually the "real-world" decay of light, but - you might find it too dim - in the world of computer graphics.) - - .DecayRadius -- The distance over which the decay occurs. - - if (iFarAttenDecay>0) - switch (iFarAttenDecay) - { - case 1: - Distdimm=fFarDecayRadius/(1+sqrt(fSquareDist)); - //dorobic od kata - break; - case 2: - Distdimm=fFarDecayRadius/(1+fSquareDist); - //dorobic od kata - break; - } - if (Distdimm>1) - Distdimm=1; - - */ - TextureManager.Bind(0); // nie teksturować - // glColor3f(f4Diffuse[0],f4Diffuse[1],f4Diffuse[2]); - // glColorMaterial(GL_FRONT,GL_EMISSION); - float color[4] = {f4Diffuse[0] * Distdimm, f4Diffuse[1] * Distdimm, - f4Diffuse[2] * Distdimm, 0}; - // glColor3f(f4Diffuse[0]*Distdimm,f4Diffuse[1]*Distdimm,f4Diffuse[2]*Distdimm); - glColorMaterial(GL_FRONT, GL_EMISSION); - glDisable(GL_LIGHTING); // Tolaris-030603: bo mu punkty swiecace sie - // blendowaly - glColor3fv(color); // inaczej są białe - glMaterialfv(GL_FRONT, GL_EMISSION, color); - glDrawArrays(GL_POINTS, iVboPtr, iNumVerts); // narysuj wierzchołek z - // VBO - glEnable(GL_LIGHTING); - glColorMaterial(GL_FRONT, GL_AMBIENT_AND_DIFFUSE); // co ma ustawiać glColor - glMaterialfv(GL_FRONT, GL_EMISSION, emm2); // bez tego słupy się świecą - } - } - else if (eType == TP_STARS) - { - // glDisable(GL_LIGHTING); //Tolaris-030603: bo mu punkty swiecace sie - // blendowaly - if (Global::fLuminance < fLight) - { // Ra: pewnie można by to zrobić - // lepiej, bez powtarzania StartVBO() - pRoot->EndVBO(); // Ra: to też nie jest zbyt ładne - if (pRoot->StartColorVBO()) - { // wyświetlanie kolorowych punktów zamiast - // trójkątów - TextureManager.Bind(0); // tekstury nie ma - glColorMaterial(GL_FRONT, GL_EMISSION); - glDisable(GL_LIGHTING); // Tolaris-030603: bo mu punkty swiecace sie - // blendowaly - // glMaterialfv(GL_FRONT,GL_EMISSION,f4Diffuse); //zeby swiecilo na - // kolorowo - glDrawArrays(GL_POINTS, iVboPtr, - iNumVerts); // narysuj naraz wszystkie punkty z VBO - glEnable(GL_LIGHTING); - glColorMaterial(GL_FRONT, GL_AMBIENT_AND_DIFFUSE); - // glMaterialfv(GL_FRONT,GL_EMISSION,emm2); - pRoot->EndVBO(); - pRoot->StartVBO(); - } - } - } - /*Ra: tu coś jest bez sensu... - else - { - glBindTexture(GL_TEXTURE_2D, 0); - // if (eType==smt_FreeSpotLight) - // { - // if (iFarAttenDecay==0) - // glColor3f(Diffuse[0],Diffuse[1],Diffuse[2]); - // } - // else - //TODO: poprawic zeby dzialalo - glColor3f(f4Diffuse[0],f4Diffuse[1],f4Diffuse[2]); - glColorMaterial(GL_FRONT,GL_EMISSION); - glDisable(GL_LIGHTING); //Tolaris-030603: bo mu punkty - swiecace sie blendowaly - //glBegin(GL_POINTS); - glDrawArrays(GL_POINTS,iVboPtr,iNumVerts); //narysuj - wierzchołek z VBO - // glVertex3f(0,0,0); - //glEnd(); - glEnable(GL_LIGHTING); - glColorMaterial(GL_FRONT,GL_AMBIENT_AND_DIFFUSE); - glMaterialfv(GL_FRONT,GL_EMISSION,emm2); - //glEndList(); - } - */ - if (Child != NULL) - if (iAlpha & iFlags & 0x001F0000) - Child->RenderVBO(); - if (iFlags & 0xC000) - glPopMatrix(); - } - if (b_Anim < at_SecondsJump) - b_Anim = at_None; // wyłączenie animacji dla kolejnego użycia submodelu - if (Next) - if (iAlpha & iFlags & 0x1F000000) - Next->RenderVBO(); // dalsze rekurencyjnie -}; // RaRender - -void TSubModel::RenderAlphaVBO() -{ // renderowanie przezroczystych przez VBO - if (iVisible && (fSquareDist >= fSquareMinDist) && (fSquareDist < fSquareMaxDist)) - { - if (iFlags & 0xC000) - { - glPushMatrix(); // zapamiętanie matrycy - if (fMatrix) - glMultMatrixf(fMatrix->readArray()); - if (b_aAnim) - RaAnimation(b_aAnim); - } - glColor3fv(f4Diffuse); - if (eType < TP_ROTATOR) - { // renderowanie obiektów OpenGL - if (iAlpha & iFlags & 0x2F) // rysuj gdy element przezroczysty - { - if (TextureID < 0) // && (ReplacableSkinId!=0)) - { // zmienialne skory - TextureManager.Bind(ReplacableSkinId[-TextureID]); - // TexAlpha=iAlpha&1; //zmiana tylko w przypadku wymienej tekstury - } - else - TextureManager.Bind(TextureID); // również 0 - if (Global::fLuminance < fLight) - { - glMaterialfv(GL_FRONT, GL_EMISSION, f4Diffuse); // zeby swiecilo na kolorowo - glDrawArrays(eType, iVboPtr, - iNumVerts); // narysuj naraz wszystkie trójkąty z VBO - glMaterialfv(GL_FRONT, GL_EMISSION, emm2); - } - else - glDrawArrays(eType, iVboPtr, - iNumVerts); // narysuj naraz wszystkie trójkąty z VBO - } - } - else if (eType == TP_FREESPOTLIGHT) - { - // dorobić aureolę! - } - if (Child) - if (iAlpha & iFlags & 0x002F0000) - Child->RenderAlphaVBO(); - if (iFlags & 0xC000) - glPopMatrix(); - } - if (b_aAnim < at_SecondsJump) - b_aAnim = at_None; // wyłączenie animacji dla kolejnego użycia submodelu - if (Next) - if (iAlpha & iFlags & 0x2F000000) - Next->RenderAlphaVBO(); -}; // RaRenderAlpha - -//--------------------------------------------------------------------------- - -void TSubModel::RaArrayFill(CVertNormTex *Vert) -{ // wypełnianie tablic VBO - if (Child) - Child->RaArrayFill(Vert); - if ((eType < TP_ROTATOR) || (eType == TP_STARS)) - for (int i = 0; i < iNumVerts; ++i) - { - Vert[iVboPtr + i].x = Vertices[i].Point.x; - Vert[iVboPtr + i].y = Vertices[i].Point.y; - Vert[iVboPtr + i].z = Vertices[i].Point.z; - Vert[iVboPtr + i].nx = Vertices[i].Normal.x; - Vert[iVboPtr + i].ny = Vertices[i].Normal.y; - Vert[iVboPtr + i].nz = Vertices[i].Normal.z; - Vert[iVboPtr + i].u = Vertices[i].tu; - Vert[iVboPtr + i].v = Vertices[i].tv; - } - else if (eType == TP_FREESPOTLIGHT) - Vert[iVboPtr].x = Vert[iVboPtr].y = Vert[iVboPtr].z = 0.0; - if (Next) - Next->RaArrayFill(Vert); -}; - -void TSubModel::Info() -{ // zapisanie informacji o submodelu do obiektu - // pomocniczego - TSubModelInfo *info = TSubModelInfo::pTable + TSubModelInfo::iCurrent; - info->pSubModel = this; - if (fMatrix && (iFlags & 0x8000)) // ma matrycę i jest ona niejednostkowa - info->iTransform = info->iTotalTransforms++; - if (TextureID > 0) - { // jeśli ma teksturę niewymienną - for (int i = 0; i < info->iCurrent; ++i) - if (TextureID == info->pTable[i].pSubModel->TextureID) // porównanie z wcześniejszym - { - info->iTexture = info->pTable[i].iTexture; // taki jaki już był - break; // koniec sprawdzania - } - if (info->iTexture < 0) // jeśli nie znaleziono we wcześniejszych - { - info->iTexture = ++info->iTotalTextures; // przydzielenie numeru tekstury - // w pliku (od 1) - std::string t(pTexture); - // trim extension - size_t kropka = t.rfind('.'); - if (kropka != std::string::npos && - (t.substr(kropka) == ".tga" || t.substr(kropka) == ".dds")) - { - t.erase(t.rfind('.')); - } - if (t != std::string(pTexture)) - { // jeśli się zmieniło - // pName=new char[token.length()+1]; //nie ma sensu skracać tabeli - strcpy(pTexture, t.c_str()); - } - info->iTextureLen = t.size() + 1; // przygotowanie do zapisania, z zerem na końcu - } - } - else - info->iTexture = TextureID; // nie ma albo wymienna - // if (asName.Length()) - if (pName) - { - info->iName = info->iTotalNames++; // przydzielenie numeru nazwy w pliku (od 0) - info->iNameLen = strlen(pName) + 1; // z zerem na końcu - } - ++info->iCurrent; // przejście do kolejnego obiektu pomocniczego - if (Child) - { - info->iChild = info->iCurrent; - Child->Info(); - } - if (Next) - { - info->iNext = info->iCurrent; - Next->Info(); - } -}; - -void TSubModel::InfoSet(TSubModelInfo *info) -{ // ustawienie danych wg obiektu - // pomocniczego do zapisania w - // pliku - int ile = (char *)&uiDisplayList - (char *)&eType; // ilość bajtów pomiędzy tymi zmiennymi - ZeroMemory(this, sizeof(TSubModel)); // zerowaie całości - CopyMemory(this, info->pSubModel, ile); // skopiowanie pamięci 1:1 - iTexture = info->iTexture; // numer nazwy tekstury, a nie numer w OpenGL - TextureID = info->iTexture; // numer tekstury w OpenGL - iName = info->iName; // numer nazwy w obszarze nazw - iMatrix = info->iTransform; // numer macierzy - Next = (TSubModel *)info->iNext; // numer następnego - Child = (TSubModel *)info->iChild; // numer potomnego - iFlags &= ~0x200; // nie jest wczytany z tekstowego - // asTexture=asName=""; - pTexture = pName = NULL; -}; - -void TSubModel::BinInit(TSubModel *s, float4x4 *m, float8 *v, TStringPack *t, TStringPack *n, - bool dynamic) -{ // ustawienie wskaźników w submodelu - iVisible = 1; // tymczasowo używane - Child = ((int)Child > 0) ? s + (int)Child : NULL; // zerowy nie może być potomnym - Next = ((int)Next > 0) ? s + (int)Next : NULL; // zerowy nie może być następnym - fMatrix = ((iMatrix >= 0) && m) ? m + iMatrix : NULL; - // if (n&&(iName>=0)) asName=AnsiString(n->String(iName)); else asName=""; - if (n && (iName >= 0)) - { - pName = n->String(iName); - std::string name(pName); - if (false == name.empty()) - { // jeśli dany submodel jest zgaszonym światłem, to - // domyślnie go ukrywamy - if ((name.size() >= 8) && (name.substr(0, 8) == "Light_On")) - { // jeśli jest światłem numerowanym - iVisible = 0; // to domyślnie wyłączyć, żeby się nie nakładało z - } - // obiektem "Light_Off" - else if (dynamic) - { // inaczej wyłączało smugę w latarniach - if ((name.size() >= 3) && (name.substr(name.size() - 3, 3) == "_on")) - { // jeśli jest kontrolką w stanie zapalonym - iVisible = 0; // to domyślnie wyłączyć, żeby się nie nakładało z - } - } - // obiektem "_off" - } - } - else - pName = NULL; - if (iTexture > 0) - { // obsługa stałej tekstury - // TextureID=TTexturesManager::GetTextureID(t->String(TextureID)); - // asTexture=AnsiString(t->String(iTexture)); - pTexture = t->String(iTexture); - std::string tex = pTexture; - if (tex.find_last_of("/\\") == std::string::npos) - tex.insert(0, Global::asCurrentTexturePath); - TextureID = TextureManager.GetTextureId( tex, szTexturePath ); - // TexAlpha=TTexturesManager::GetAlpha(TextureID); //zmienna robocza - // ustawienie cyklu przezroczyste/nieprzezroczyste zależnie od własności - // stałej tekstury - // iFlags=(iFlags&~0x30)|(TTexturesManager::GetAlpha(TextureID)?0x20:0x10); - // //0x10-nieprzezroczysta, 0x20-przezroczysta - if (Opacity < 1.0) // przezroczystość z tekstury brana tylko dla Opacity 0! - iFlags |= TextureManager.Texture(TextureID).has_alpha ? - 0x20 : - 0x10; // 0x10-nieprzezroczysta, 0x20-przezroczysta - else - iFlags |= 0x10; // normalnie nieprzezroczyste - } - b_aAnim = b_Anim; // skopiowanie animacji do drugiego cyklu - iFlags &= ~0x0200; // wczytano z pliku binarnego (nie jest właścicielem - // tablic) - Vertices = v + iVboPtr; - // if (!iNumVerts) eType=-1; //tymczasowo zmiana typu, żeby się nie - // renderowało na siłę -}; -void TSubModel::AdjustDist() -{ // aktualizacja odległości faz LoD, zależna od - // rozdzielczości pionowej oraz multisamplingu - if (fSquareMaxDist > 0.0) - fSquareMaxDist *= Global::fDistanceFactor; - if (fSquareMinDist > 0.0) - fSquareMinDist *= Global::fDistanceFactor; - // if (fNearAttenStart>0.0) fNearAttenStart*=Global::fDistanceFactor; - // if (fNearAttenEnd>0.0) fNearAttenEnd*=Global::fDistanceFactor; - if (Child) - Child->AdjustDist(); - if (Next) - Next->AdjustDist(); -}; - -void TSubModel::ColorsSet(int *a, int *d, int *s) +void TSubModel::ColorsSet( glm::vec3 const &Ambient, glm::vec3 const &Diffuse, glm::vec3 const &Specular ) { // ustawienie kolorów dla modelu terenu + f4Ambient = glm::vec4( Ambient, 1.0f ); + f4Diffuse = glm::vec4( Diffuse, 1.0f ); + f4Specular = glm::vec4( Specular, 1.0f ); +/* int i; - if (a) - for (i = 0; i < 4; ++i) - f4Ambient[i] = a[i] / 255.0; - if (d) - for (i = 0; i < 4; ++i) - f4Diffuse[i] = d[i] / 255.0; - if (s) - for (i = 0; i < 4; ++i) - f4Specular[i] = s[i] / 255.0; + if (a) + for (i = 0; i < 4; ++i) + f4Ambient[i] = a[i] / 255.0; + if (d) + for (i = 0; i < 4; ++i) + f4Diffuse[i] = d[i] / 255.0; + if (s) + for (i = 0; i < 4; ++i) + f4Specular[i] = s[i] / 255.0; +*/ }; -void TSubModel::ParentMatrix(float4x4 *m) -{ // pobranie transformacji względem wstawienia modelu - // jeśli nie zostało wykonane Init() (tzn. zaraz po wczytaniu T3D), to - // dodatkowy obrót - // obrót T3D jest wymagany np. do policzenia wysokości pantografów - *m = float4x4(*fMatrix); // skopiowanie, bo będziemy mnożyć - // m(3)[1]=m[3][1]+0.054; //w górę o wysokość ślizgu (na razie tak) - TSubModel *sm = this; - while (sm->Parent) - { // przenieść tę funkcję do modelu - if (sm->Parent->GetMatrix()) - *m = *sm->Parent->GetMatrix() * *m; - sm = sm->Parent; + +void TSubModel::ParentMatrix( float4x4 *m ) const { // pobranie transformacji względem wstawienia modelu + // jeśli nie zostało wykonane Init() (tzn. zaraz po wczytaniu T3D), + // to dodatkowy obrót obrót T3D jest wymagany np. do policzenia wysokości pantografów + if( fMatrix != nullptr ) { + // skopiowanie, bo będziemy mnożyć + *m = float4x4( *fMatrix ); } - // dla ostatniego może być potrzebny dodatkowy obrót, jeśli wczytano z T3D, a - // nie obrócono jeszcze + else { + m->Identity(); + } + auto *sm = this; + while (sm->Parent) + { // przenieść tę funkcję do modelu + if (sm->Parent->GetMatrix()) + *m = *sm->Parent->GetMatrix() * *m; + sm = sm->Parent; + } + // dla ostatniego może być potrzebny dodatkowy obrót, jeśli wczytano z T3D, a + // nie obrócono jeszcze }; -float TSubModel::MaxY(const float4x4 &m) -{ // obliczenie maksymalnej wysokości, - // na początek ślizgu w pantografie - if (eType != 4) - return 0; // tylko dla trójkątów liczymy - if (iNumVerts < 1) - return 0; - if (!Vertices) - return 0; - float y, - my = m[0][1] * Vertices[0].Point.x + m[1][1] * Vertices[0].Point.y + - m[2][1] * Vertices[0].Point.z + m[3][1]; - for (int i = 1; i < iNumVerts; ++i) - { - y = m[0][1] * Vertices[i].Point.x + m[1][1] * Vertices[i].Point.y + - m[2][1] * Vertices[i].Point.z + m[3][1]; - if (my < y) - my = y; + +// obliczenie maksymalnej wysokości, na początek ślizgu w pantografie +float TSubModel::MaxY( float4x4 const &m ) { + // tylko dla trójkątów liczymy + if( eType != 4 ) { return 0; } + + auto maxy { 0.0f }; + // binary and text models invoke this function at different stages, either after or before geometry data was sent to the geometry manager + if( m_geometry != null_handle ) { + + for( auto const &vertex : GfxRenderer.Vertices( m_geometry ) ) { + maxy = std::max( + maxy, + m[ 0 ][ 1 ] * vertex.position.x + + m[ 1 ][ 1 ] * vertex.position.y + + m[ 2 ][ 1 ] * vertex.position.z + + m[ 3 ][ 1 ] ); + } } - return my; + else if( false == Vertices.empty() ) { + + for( auto const &vertex : Vertices ) { + maxy = std::max( + maxy, + m[ 0 ][ 1 ] * vertex.position.x + + m[ 1 ][ 1 ] * vertex.position.y + + m[ 2 ][ 1 ] * vertex.position.z + + m[ 3 ][ 1 ] ); + } + } + + return maxy; }; //--------------------------------------------------------------------------- TModel3d::TModel3d() { - // Materials=NULL; - // MaterialsCount=0; - Root = NULL; - iFlags = 0; - iSubModelsCount = 0; - iModel = NULL; // tylko jak wczytany model binarny - iNumVerts = 0; // nie ma jeszcze wierzchołków + Root = NULL; + iFlags = 0; + iSubModelsCount = 0; + iNumVerts = 0; // nie ma jeszcze wierzchołków }; -/* - TModel3d::TModel3d(char *FileName) -{ -// Root=NULL; -// Materials=NULL; -// MaterialsCount=0; - Root=NULL; - SubModelsCount=0; - iFlags=0; - LoadFromFile(FileName); -}; -*/ -TModel3d::~TModel3d() -{ - // SafeDeleteArray(Materials); - if (iFlags & 0x0200) - { // wczytany z pliku tekstowego, submodele sprzątają - // same - SafeDelete(Root); // submodele się usuną rekurencyjnie + +TModel3d::~TModel3d() { + + if (iFlags & 0x0200) { + // wczytany z pliku tekstowego, submodele sprzątają same + SafeDelete( Root ); + } + else { + // wczytano z pliku binarnego (jest właścicielem tablic) + SafeDeleteArray( Root ); // submodele się usuną rekurencyjnie } - else - { // wczytano z pliku binarnego (jest właścicielem tablic) - m_pVNT = NULL; // nie usuwać tego, bo wskazuje na iModel - Root = NULL; - delete[] iModel; // usuwamy cały wczytany plik i to wystarczy - } - // później się jeszcze usuwa obiekt z którego dziedziczymy tabelę VBO }; TSubModel *TModel3d::AddToNamed(const char *Name, TSubModel *SubModel) { - TSubModel *sm = Name ? GetFromName(Name) : NULL; - AddTo(sm, SubModel); // szukanie nadrzędnego - return sm; // zwracamy wskaźnik do nadrzędnego submodelu + TSubModel *sm = Name ? GetFromName(Name) : nullptr; + if( ( sm == nullptr ) + && ( Name != nullptr ) && ( std::strcmp( Name, "none" ) != 0 ) ) { + ErrorLog( "Bad model: parent for sub-model \"" + SubModel->pName +"\" doesn't exist or is located later in the model data", logtype::model ); + } + AddTo(sm, SubModel); // szukanie nadrzędnego + return sm; // zwracamy wskaźnik do nadrzędnego submodelu }; -void TModel3d::AddTo(TSubModel *tmp, TSubModel *SubModel) -{ // jedyny poprawny sposób dodawania - // submodeli, inaczej mogą zginąć - // przy zapisie E3D - if (tmp) - { // jeśli znaleziony, podłączamy mu jako potomny - tmp->ChildAdd(SubModel); - } - else - { // jeśli nie znaleziony, podczepiamy do łańcucha głównego - SubModel->NextAdd(Root); // Ra: zmiana kolejności renderowania wymusza zmianę tu - Root = SubModel; - } - ++iSubModelsCount; // teraz jest o 1 submodel więcej - iFlags |= 0x0200; // submodele są oddzielne +// jedyny poprawny sposób dodawania submodeli, inaczej mogą zginąć przy zapisie E3D +void TModel3d::AddTo(TSubModel *tmp, TSubModel *SubModel) { + if (tmp) { + // jeśli znaleziony, podłączamy mu jako potomny + tmp->ChildAdd(SubModel); + } + else + { // jeśli nie znaleziony, podczepiamy do łańcucha głównego + SubModel->NextAdd(Root); // Ra: zmiana kolejności renderowania wymusza zmianę tu + Root = SubModel; + } + ++iSubModelsCount; // teraz jest o 1 submodel więcej + iFlags |= 0x0200; // submodele są oddzielne }; -TSubModel *TModel3d::GetFromName(const char *sName) +TSubModel *TModel3d::GetFromName(std::string const &Name) const { // wyszukanie submodelu po nazwie - if (!sName) - return Root; // potrzebne do terenu z E3D - if (iFlags & 0x0200) // wczytany z pliku tekstowego, wyszukiwanie rekurencyjne - return Root ? Root->GetFromName(sName) : NULL; - else // wczytano z pliku binarnego, można wyszukać iteracyjnie - { - // for (int i=0;iGetFromName(sName) : NULL; - } + if (Name.empty()) + return Root; // potrzebne do terenu z E3D + if (iFlags & 0x0200) // wczytany z pliku tekstowego, wyszukiwanie rekurencyjne + return Root ? Root->GetFromName(Name) : nullptr; + else // wczytano z pliku binarnego, można wyszukać iteracyjnie + { + // for (int i=0;iGetFromName(Name) : nullptr; + } }; -/* -TMaterial* TModel3d::GetMaterialFromName(char *sName) -{ - AnsiString tmp=AnsiString(sName).Trim(); - for (int i=0; i 0) : false; // brak pliku albo problem z wczytaniem + if (false == result) + { + ErrorLog("Bad model: failed to load 3d model \"" + name + "\""); + } + return result; +}; + +// E3D serialization +// http://rainsted.com/pl/Format_binarny_modeli_-_E3D + + +//m7todo: wymyślić lepszą nazwę +template +size_t get_container_pos(L &list, T o) +{ + auto i = std::find(list.begin(), list.end(), o); + if (i == list.end()) + { + list.push_back(o); + return list.size() - 1; + } + else + { + return std::distance(list.begin(), i); + } +} + +//m7todo: za dużo argumentów, może przenieść do osobnej +//klasy serializera mającej własny stan, albo zrobić +//strukturę TModel3d::SerializerContext? +void TSubModel::serialize(std::ostream &s, + std::vector &models, + std::vector &names, + std::vector &textures, + std::vector &transforms) +{ + size_t end = (size_t)s.tellp() + 256; + + if (!Next) + sn_utils::ls_int32(s, -1); + else + sn_utils::ls_int32(s, (int32_t)get_container_pos(models, Next)); + if (!Child) + sn_utils::ls_int32(s, -1); + else + sn_utils::ls_int32(s, (int32_t)get_container_pos(models, Child)); + + sn_utils::ls_int32(s, eType); + if (pName.size() == 0) + sn_utils::ls_int32(s, -1); + else + sn_utils::ls_int32(s, (int32_t)get_container_pos(names, pName)); + sn_utils::ls_int32(s, (int)b_Anim); + + sn_utils::ls_int32(s, iFlags); + sn_utils::ls_int32(s, (int32_t)get_container_pos(transforms, *fMatrix)); + + sn_utils::ls_int32(s, iNumVerts); + sn_utils::ls_int32(s, tVboPtr); + + if (m_material <= 0) + sn_utils::ls_int32(s, m_material); + else + sn_utils::ls_int32(s, (int32_t)get_container_pos(textures, m_materialname)); + +// sn_utils::ls_float32(s, fVisible); + sn_utils::ls_float32(s, 1.f); + sn_utils::ls_float32(s, fLight); + + sn_utils::s_vec4(s, f4Ambient); + sn_utils::s_vec4(s, f4Diffuse); + sn_utils::s_vec4(s, f4Specular); + sn_utils::s_vec4(s, f4Emision); + + sn_utils::ls_float32(s, fWireSize); + sn_utils::ls_float32(s, fSquareMaxDist); + sn_utils::ls_float32(s, fSquareMinDist); + + sn_utils::ls_float32(s, fNearAttenStart); + sn_utils::ls_float32(s, fNearAttenEnd); + sn_utils::ls_uint32(s, bUseNearAtten ? 1 : 0); + + sn_utils::ls_int32(s, iFarAttenDecay); + sn_utils::ls_float32(s, fFarDecayRadius); + sn_utils::ls_float32(s, fCosFalloffAngle); + sn_utils::ls_float32(s, fCosHotspotAngle); + sn_utils::ls_float32(s, fCosViewAngle); + + size_t fill = end - s.tellp(); + for (size_t i = 0; i < fill; i++) + s.put(0); +} + +void TModel3d::SaveToBinFile(std::string const &FileName) +{ + WriteLog("saving e3d model.."); + + //m7todo: można by zoptymalizować robiąc unordered_map + //na wyszukiwanie numerów już dodanych stringów i osobno + //vector na wskaźniki do stringów w kolejności numeracji + //tylko czy potrzeba? + std::vector models; + models.push_back(Root); + std::vector names; + std::vector textures; + textures.push_back(""); + std::vector transforms; + + std::ofstream s(FileName, std::ios::binary); + + sn_utils::ls_uint32(s, MAKE_ID4('E', '3', 'D', '0')); + auto const e3d_spos = s.tellp(); + sn_utils::ls_uint32(s, 0); + + { + sn_utils::ls_uint32(s, MAKE_ID4('S', 'U', 'B', '0')); + auto const sub_spos = s.tellp(); + sn_utils::ls_uint32(s, 0); + for (size_t i = 0; i < models.size(); i++) + models[i]->serialize(s, models, names, textures, transforms); + auto const pos = s.tellp(); + s.seekp(sub_spos); + sn_utils::ls_uint32(s, (uint32_t)(4 + pos - sub_spos)); + s.seekp(pos); + } + + sn_utils::ls_uint32(s, MAKE_ID4('T', 'R', 'A', '0')); + sn_utils::ls_uint32(s, 8 + (uint32_t)transforms.size() * 64); + for (size_t i = 0; i < transforms.size(); i++) + transforms[i].serialize_float32(s); + + sn_utils::ls_uint32(s, MAKE_ID4('V', 'N', 'T', '0')); + sn_utils::ls_uint32(s, 8 + iNumVerts * 32); + Root->serialize_geometry( s ); + + if (textures.size()) + { + sn_utils::ls_uint32(s, MAKE_ID4('T', 'E', 'X', '0')); + auto const tex_spos = s.tellp(); + sn_utils::ls_uint32(s, 0); + for (size_t i = 0; i < textures.size(); i++) + sn_utils::s_str(s, textures[i]); + auto const pos = s.tellp(); + s.seekp(tex_spos); + sn_utils::ls_uint32(s, (uint32_t)(4 + pos - tex_spos)); + s.seekp(pos); + } + + if (names.size()) + { + sn_utils::ls_uint32(s, MAKE_ID4('N', 'A', 'M', '0')); + auto const nam_spos = s.tellp(); + sn_utils::ls_uint32(s, 0); + for (size_t i = 0; i < names.size(); i++) + sn_utils::s_str(s, names[i]); + auto const pos = s.tellp(); + s.seekp(nam_spos); + sn_utils::ls_uint32(s, (uint32_t)(4 + pos - nam_spos)); + s.seekp(pos); + } + + auto const end = s.tellp(); + s.seekp(e3d_spos); + sn_utils::ls_uint32(s, (uint32_t)(4 + end - e3d_spos)); + s.close(); + + WriteLog("..done."); +} + +void TSubModel::deserialize(std::istream &s) +{ + iNext = sn_utils::ld_int32(s); + iChild = sn_utils::ld_int32(s); + + eType = sn_utils::ld_int32(s); + iName = sn_utils::ld_int32(s); + + b_Anim = (TAnimType)sn_utils::ld_int32(s); + + iFlags = sn_utils::ld_int32(s); + iMatrix = sn_utils::ld_int32(s); + + iNumVerts = sn_utils::ld_int32(s); + tVboPtr = sn_utils::ld_int32(s); + iTexture = sn_utils::ld_int32(s); + +// fVisible = sn_utils::ld_float32(s); + auto discard = sn_utils::ld_float32(s); + fLight = sn_utils::ld_float32(s); + + f4Ambient = sn_utils::d_vec4(s); + f4Diffuse = sn_utils::d_vec4(s); + f4Specular = sn_utils::d_vec4(s); + f4Emision = sn_utils::d_vec4(s); + + fWireSize = sn_utils::ld_float32(s); + fSquareMaxDist = sn_utils::ld_float32(s); + fSquareMinDist = sn_utils::ld_float32(s); + + fNearAttenStart = sn_utils::ld_float32(s); + fNearAttenEnd = sn_utils::ld_float32(s); + bUseNearAtten = sn_utils::ld_uint32(s) != 0; + iFarAttenDecay = sn_utils::ld_int32(s); + fFarDecayRadius = sn_utils::ld_float32(s); + fCosFalloffAngle = sn_utils::ld_float32(s); + fCosHotspotAngle = sn_utils::ld_float32(s); + fCosViewAngle = sn_utils::ld_float32(s); +} + +void TModel3d::deserialize(std::istream &s, size_t size, bool dynamic) +{ + Root = nullptr; + if( m_geometrybank == null_handle ) { + m_geometrybank = GfxRenderer.Create_Bank(); + } + + std::streampos end = s.tellg() + (std::streampos)size; + + while (s.tellg() < end) + { + uint32_t type = sn_utils::ld_uint32(s); + uint32_t size = sn_utils::ld_uint32(s) - 8; + std::streampos end = s.tellg() + (std::streampos)size; + + if ((type & 0x00FFFFFF) == MAKE_ID4('S', 'U', 'B', 0)) + { + if (Root != nullptr) + throw std::runtime_error("e3d: duplicated SUB chunk"); + + size_t sm_size = 256 + 64 * (((type & 0xFF000000) >> 24) - '0'); + size_t sm_cnt = size / sm_size; + iSubModelsCount = (int)sm_cnt; + Root = new TSubModel[sm_cnt]; + size_t pos = s.tellg(); + for (size_t i = 0; i < sm_cnt; ++i) + { + s.seekg(pos + sm_size * i); + Root[i].deserialize(s); + } + } + else if (type == MAKE_ID4('V', 'N', 'T', '0')) + { +/* + if (m_pVNT != nullptr) + throw std::runtime_error("e3d: duplicated VNT chunk"); + + size_t vt_cnt = size / 32; + iNumVerts = (int)vt_cnt; + m_nVertexCount = (int)vt_cnt; + m_pVNT.resize( vt_cnt ); + for (size_t i = 0; i < vt_cnt; i++) + m_pVNT[i].deserialize(s); +*/ + // we rely on the SUB chunk coming before the vertex data, and on the overall vertex count matching the size of data in the chunk. + // geometry associated with chunks isn't stored in the same order as the chunks themselves, so we need to sort that out first + if( Root == nullptr ) + throw std::runtime_error( "e3d: VNT chunk encountered before SUB chunk" ); + std::vector< std::pair > submodeloffsets; // vertex data offset, submodel index + submodeloffsets.reserve( iSubModelsCount ); + for( int submodelindex = 0; submodelindex < iSubModelsCount; ++submodelindex ) { + auto const &submodel = Root[ submodelindex ]; + if( submodel.iNumVerts <= 0 ) { continue; } + submodeloffsets.emplace_back( submodel.tVboPtr, submodelindex ); + } + std::sort( + submodeloffsets.begin(), + submodeloffsets.end(), + []( std::pair const &Left, std::pair const &Right ) { + return (Left.first) < (Right.first); } ); + // once sorted we can grab geometry as it comes, and assign it to the chunks it belongs to + for( auto const &submodeloffset : submodeloffsets ) { + auto &submodel = Root[ submodeloffset.second ]; + gfx::vertex_array vertices; vertices.resize( submodel.iNumVerts ); + iNumVerts += submodel.iNumVerts; + for( auto &vertex : vertices ) { + vertex.deserialize( s ); + if( submodel.eType < TP_ROTATOR ) { + // normal vectors debug routine + auto normallength = glm::length2( vertex.normal ); + if( ( false == submodel.m_normalizenormals ) + && ( std::abs( normallength - 1.0f ) > 0.01f ) ) { + submodel.m_normalizenormals = TSubModel::normalize; // we don't know if uniform scaling would suffice + WriteLog( "Bad model: non-unit normal vector(s) encountered during sub-model geometry deserialization", logtype::model ); + } + } + } + // remap geometry type for custom type submodels + int type; + switch( submodel.eType ) { + case TP_FREESPOTLIGHT: + case TP_STARS: { + type = GL_POINTS; + break; } + default: { + type = submodel.eType; + break; + } + } + submodel.m_geometry = GfxRenderer.Insert( vertices, m_geometrybank, type ); + } + + } + else if (type == MAKE_ID4('T', 'R', 'A', '0')) + { + if( false == Matrices.empty() ) + throw std::runtime_error("e3d: duplicated TRA chunk"); + size_t t_cnt = size / 64; + + Matrices.resize(t_cnt); + for (size_t i = 0; i < t_cnt; ++i) + Matrices[i].deserialize_float32(s); + } + else if (type == MAKE_ID4('T', 'R', 'A', '1')) + { + if( false == Matrices.empty() ) + throw std::runtime_error("e3d: duplicated TRA chunk"); + size_t t_cnt = size / 128; + + Matrices.resize( t_cnt ); + for (size_t i = 0; i < t_cnt; ++i) + Matrices[i].deserialize_float64(s); + } + else if (type == MAKE_ID4('T', 'E', 'X', '0')) + { + if (Textures.size()) + throw std::runtime_error("e3d: duplicated TEX chunk"); + while (s.tellg() < end) + Textures.push_back(sn_utils::d_str(s)); + } + else if (type == MAKE_ID4('N', 'A', 'M', '0')) + { + if (Names.size()) + throw std::runtime_error("e3d: duplicated NAM chunk"); + while (s.tellg() < end) + Names.push_back(sn_utils::d_str(s)); + } + + s.seekg(end); + } + + if (!Root) + throw std::runtime_error("e3d: no submodels"); + + for (size_t i = 0; (int)i < iSubModelsCount; ++i) + { + Root[i].BinInit( Root, Matrices.data(), &Textures, &Names, dynamic ); + + if (Root[i].ChildGet()) + Root[i].ChildGet()->Parent = &Root[i]; + if (Root[i].NextGet()) + Root[i].NextGet()->Parent = Root[i].Parent; + } +} + +void TSubModel::BinInit(TSubModel *s, float4x4 *m, std::vector *t, std::vector *n, bool dynamic) +{ // ustawienie wskaźników w submodelu + //m7todo: brzydko + iVisible = 1; // tymczasowo używane + Child = (iChild > 0) ? s + iChild : nullptr; // zerowy nie może być potomnym + Next = (iNext > 0) ? s + iNext : nullptr; // zerowy nie może być następnym + fMatrix = ((iMatrix >= 0) && m) ? m + iMatrix : nullptr; + + if (n->size() && (iName >= 0)) + { + pName = n->at(iName); + if (!pName.empty()) + { // jeśli dany submodel jest zgaszonym światłem, to + // domyślnie go ukrywamy + if ((pName.size() >= 8) && (pName.substr(0, 8) == "Light_On")) + { // jeśli jest światłem numerowanym + iVisible = 0; // to domyślnie wyłączyć, żeby się nie nakładało z + } + // obiektem "Light_Off" + else if (dynamic) + { // inaczej wyłączało smugę w latarniach + if ((pName.size() >= 3) && (pName.substr(pName.size() - 3, 3) == "_on")) { + // jeśli jest kontrolką w stanie zapalonym to domyślnie wyłączyć, + // żeby się nie nakładało z obiektem "_off" + iVisible = 0; + } + } + // hack: reset specular light value for shadow submodels + if( pName == "cien" ) { + f4Specular = glm::vec4 { 0.0f, 0.0f, 0.0f, 1.0f }; + } + } + } + else + pName = ""; + if (iTexture > 0) + { // obsługa stałej tekstury + auto const materialindex = static_cast( iTexture ); + if( materialindex < t->size() ) { + m_materialname = t->at( materialindex ); +/* + if( m_materialname.find_last_of( "/\\" ) == std::string::npos ) { + m_materialname = Global.asCurrentTexturePath + m_materialname; + } +*/ + m_material = GfxRenderer.Fetch_Material( m_materialname ); + if( ( iFlags & 0x30 ) == 0 ) { + // texture-alpha based fallback if for some reason we don't have opacity flag set yet + iFlags |= ( + ( ( m_material != null_handle ) + && ( GfxRenderer.Material( m_material ).has_alpha ) ) ? + 0x20 : + 0x10 ); // 0x10-nieprzezroczysta, 0x20-przezroczysta + } + } + else { + ErrorLog( "Bad model: reference to nonexistent texture index in sub-model" + ( pName.empty() ? "" : " \"" + pName + "\"" ), logtype::model ); + m_material = null_handle; } } - bool const result = - Root ? (iSubModelsCount > 0) : false; // brak pliku albo problem z wczytaniem - if (false == result) - { - ErrorLog("Failed to load 3d model \"" + FileName + "\""); + else + m_material = iTexture; + + b_aAnim = b_Anim; // skopiowanie animacji do drugiego cyklu + + if( (eType == TP_FREESPOTLIGHT) && (iFlags & 0x10)) { + // we've added light glare which needs to be rendered during transparent phase, + // but models converted to e3d before addition won't have the render flag set correctly for this + // so as a workaround we're doing it here manually + iFlags |= 0x20; + } + // intercept and fix hotspot values if specified in degrees and not directly + if( fCosFalloffAngle > 1.0f ) { + fCosFalloffAngle = std::cos( DegToRad( 0.5f * fCosFalloffAngle ) ); + } + if( fCosHotspotAngle > 1.0f ) { + fCosHotspotAngle = std::cos( DegToRad( 0.5f * fCosHotspotAngle ) ); + } + // cap specular values for legacy models + f4Specular = glm::vec4{ + clamp( f4Specular.r, 0.0f, 1.0f ), + clamp( f4Specular.g, 0.0f, 1.0f ), + clamp( f4Specular.b, 0.0f, 1.0f ), + clamp( f4Specular.a, 0.0f, 1.0f ) }; + + iFlags &= ~0x0200; // wczytano z pliku binarnego (nie jest właścicielem tablic) + + if( fMatrix != nullptr ) { + auto const matrix = glm::make_mat4( fMatrix->readArray() ); + glm::vec3 const scale { + glm::length( glm::vec3( glm::column( matrix, 0 ) ) ), + glm::length( glm::vec3( glm::column( matrix, 1 ) ) ), + glm::length( glm::vec3( glm::column( matrix, 2 ) ) ) }; + if( ( std::abs( scale.x - 1.0f ) > 0.01 ) + || ( std::abs( scale.y - 1.0f ) > 0.01 ) + || ( std::abs( scale.z - 1.0f ) > 0.01 ) ) { + ErrorLog( "Bad model: transformation matrix for sub-model \"" + pName + "\" imposes geometry scaling (factors: " + to_string( scale ) + ")", logtype::model ); + m_normalizenormals = ( + ( ( std::abs( scale.x - scale.y ) < 0.01f ) && ( std::abs( scale.y - scale.z ) < 0.01f ) ) ? + rescale : + normalize ); + } } - return result; }; void TModel3d::LoadFromBinFile(std::string const &FileName, bool dynamic) { // wczytanie modelu z pliku binarnego - WriteLog("Loading - binary model: " + FileName); - int i = 0, j, k, ch, size; + WriteLog( "Loading binary format 3d model data from \"" + FileName + "\"...", logtype::model ); + + std::ifstream file(FileName, std::ios::binary); - /* TFileStream *fs = new TFileStream(AnsiString(FileName), fmOpenRead); - size = fs->Size >> 2; - iModel = new int[size]; // ten wskaźnik musi być w modelu, aby zwolnić pamięć - fs->Read(iModel, fs->Size); // wczytanie pliku - delete fs; -*/ { - std::ifstream file(FileName, std::ios::binary | std::ios::ate); - file.unsetf(std::ios::skipws); - size = file.tellg(); // ios::ate already positioned us at the end of the file - iModel = new int[size >> 2]; // ten wskaźnik musi być w modelu, aby zwolnić pamięć - file.seekg(0, std::ios::beg); // rewind the caret afterwards - file.read(reinterpret_cast(iModel), size); - } - float4x4 *m = NULL; // transformy - // zestaw kromek: - while ((i << 2) < size) // w pliku może być kilka modeli - { - ch = iModel[i]; // nazwa kromki - j = i + (iModel[i + 1] >> 2); // początek następnej kromki - if (ch == MAKE_ID4('E', '3', 'D', '0')) // główna: 'E3D0',len,pod-kromki - { // tylko tę kromkę znamy, może kiedyś jeszcze DOF się zrobi - i += 2; - while (i < j) - { // przetwarzanie kromek wewnętrznych - ch = iModel[i]; // nazwa kromki - k = (iModel[i + 1] >> 2); // długość aktualnej kromki - switch (ch) - { - case MAKE_ID4('M', 'D', 'L', - '0'): // zmienne modelu: 'E3D0',len,(informacje o modelu) - break; - case MAKE_ID4('V', 'N', 'T', - '0'): // wierzchołki: 'VNT0',len,(32 bajty na wierzchołek) - iNumVerts = (k - 2) >> 3; - m_nVertexCount = iNumVerts; - m_pVNT = (CVertNormTex *)(iModel + i + 2); - break; - case MAKE_ID4('S', 'U', 'B', '0'): // submodele: 'SUB0',len,(256 bajtów na submodel) - iSubModelsCount = (k - 2) / 64; - Root = - (TSubModel *)(iModel + i + 2); // numery na wskaźniki przetworzymy później - break; - case MAKE_ID4('S', 'U', 'B', '1'): // submodele: 'SUB1',len,(320 bajtów na submodel) - iSubModelsCount = (k - 2) / 80; - Root = - (TSubModel *)(iModel + i + 2); // numery na wskaźniki przetworzymy później - for (ch = 1; ch < iSubModelsCount; - ++ch) // trzeba przesunąć bliżej, bo 256 wystarczy - MoveMemory(((char *)Root) + 256 * ch, ((char *)Root) + 320 * ch, 256); - break; - case MAKE_ID4('T', 'R', 'A', '0'): // transformy: 'TRA0',len,(64 bajty na transform) - m = (float4x4 *)(iModel + i + 2); // tabela transformów - break; - case MAKE_ID4('T', 'R', 'A', - '1'): // transformy: 'TRA1',len,(128 bajtów na transform) - m = (float4x4 *)(iModel + i + 2); // tabela transformów - for (ch = 0; ch < ((k - 2) >> 1); ++ch) - *(((float *)m) + ch) = *(((double *)m) + ch); // przepisanie double do float - break; - case MAKE_ID4('I', 'D', 'X', - '1'): // indeksy 1B: 'IDX2',len,(po bajcie na numer wierzchołka) - break; - case MAKE_ID4('I', 'D', 'X', - '2'): // indeksy 2B: 'IDX2',len,(po 2 bajty na numer wierzchołka) - break; - case MAKE_ID4('I', 'D', 'X', - '4'): // indeksy 4B: 'IDX4',len,(po 4 bajty na numer wierzchołka) - break; - case MAKE_ID4('T', 'E', 'X', - '0'): // tekstury: 'TEX0',len,(łańcuchy zakończone zerem - pliki - // tekstur) - Textures.Init((char *)(iModel + i)); //łącznie z nagłówkiem - break; - case MAKE_ID4('T', 'I', 'X', '0'): // indeks nazw tekstur - Textures.InitIndex((int *)(iModel + i)); //łącznie z nagłówkiem - break; - case MAKE_ID4('N', 'A', 'M', - '0'): // nazwy: 'NAM0',len,(łańcuchy zakończone zerem - nazwy - // submodeli) - Names.Init((char *)(iModel + i)); //łącznie z nagłówkiem - break; - case MAKE_ID4('N', 'I', 'X', '0'): // indeks nazw submodeli - Names.InitIndex((int *)(iModel + i)); //łącznie z nagłówkiem - break; - } - i += k; // przejście do kolejnej kromki - } - } - i = j; - } - for (i = 0; i < iSubModelsCount; ++i) - { // aktualizacja wskaźników w submodelach - Root[i].BinInit(Root, m, (float8 *)m_pVNT, &Textures, &Names, dynamic); - if (Root[i].ChildGet()) - Root[i].ChildGet()->Parent = Root + i; // wpisanie wskaźnika nadrzędnego do potmnego - if (Root[i].NextGet()) - Root[i].NextGet()->Parent = - Root[i].Parent; // skopiowanie wskaźnika nadrzędnego do kolejnego - } - iFlags &= ~0x0200; - return; + uint32_t type = sn_utils::ld_uint32(file); + uint32_t size = sn_utils::ld_uint32(file) - 8; + + if (type != MAKE_ID4('E', '3', 'D', '0')) + throw std::runtime_error("e3d: unknown main chunk"); + + deserialize(file, size, dynamic); + file.close(); + + WriteLog( "Finished loading 3d model data from \"" + FileName + "\"", logtype::model ); }; void TModel3d::LoadFromTextFile(std::string const &FileName, bool dynamic) { // wczytanie submodelu z pliku tekstowego - WriteLog("Loading - text model: " + FileName); - iFlags |= 0x0200; // wczytano z pliku tekstowego (właścicielami tablic są submodle) - cParser parser(FileName, cParser::buffer_FILE); // Ra: tu powinno być "models\\"... - TSubModel *SubModel; - std::string token = parser.getToken(); - iNumVerts = 0; // w konstruktorze to jest - while (token != "" || parser.eof()) - { - std::string parent; - // parser.getToken(parent); - parser.getTokens(1, false); // nazwa submodelu nadrzędnego bez zmieny na małe - parser >> parent; - if (parent == "") + WriteLog( "Loading text format 3d model data from \"" + FileName + "\"...", logtype::model ); + iFlags |= 0x0200; // wczytano z pliku tekstowego (właścicielami tablic są submodle) + cParser parser(FileName, cParser::buffer_FILE); // Ra: tu powinno być "models\\"... + TSubModel *SubModel; + std::string token = parser.getToken(); + iNumVerts = 0; // w konstruktorze to jest + while (token != "" || parser.eof()) + { + std::string parent; + // parser.getToken(parent); + parser.getTokens(1, false); // nazwa submodelu nadrzędnego bez zmieny na małe + parser >> parent; + if( parent == "" ) { break; - SubModel = new TSubModel(); - iNumVerts += SubModel->Load(parser, this, iNumVerts, dynamic); - SubModel->Parent = AddToNamed( - parent.c_str(), SubModel); // będzie potrzebne do wyliczenia pozycji, np. pantografu - // iSubModelsCount++; - parser.getTokens(); - parser >> token; - } - // Ra: od wersji 334 przechylany jest cały model, a nie tylko pierwszy - // submodel - // ale bujanie kabiny nadal używa bananów :( od 393 przywrócone, ale z - // dodatkowym warunkiem - if (Global::iConvertModels & 4) - { // automatyczne banany czasem psuły przechylanie kabin... - if (dynamic && Root) - { - if (Root->NextGet()) // jeśli ma jakiekolwiek kolejne - { // dynamic musi mieć "banana", bo tylko pierwszy obiekt jest animowany, - // a następne nie - SubModel = new TSubModel(); // utworzenie pustego - SubModel->ChildAdd(Root); - Root = SubModel; - ++iSubModelsCount; - } - Root->WillBeAnimated(); // bo z tym jest dużo problemów } - } + SubModel = new TSubModel(); + iNumVerts += SubModel->Load(parser, this, /*iNumVerts,*/ dynamic); + + // będzie potrzebne do wyliczenia pozycji, np. pantografu + SubModel->Parent = AddToNamed(parent.c_str(), SubModel); + + parser.getTokens(); + parser >> token; + } + // Ra: od wersji 334 przechylany jest cały model, a nie tylko pierwszy submodel + // ale bujanie kabiny nadal używa bananów :( od 393 przywrócone, ale z dodatkowym warunkiem + if (Global.iConvertModels & 4) + { // automatyczne banany czasem psuły przechylanie kabin... + if (dynamic && Root) + { + if (Root->NextGet()) // jeśli ma jakiekolwiek kolejne + { // dynamic musi mieć "banana", bo tylko pierwszy obiekt jest animowany, a następne nie + SubModel = new TSubModel(); // utworzenie pustego + SubModel->ChildAdd(Root); + Root = SubModel; + ++iSubModelsCount; + } + Root->WillBeAnimated(); // bo z tym jest dużo problemów + } + } } void TModel3d::Init() { // obrócenie początkowe układu współrzędnych, dla - // pojazdów wykonywane po analizie animacji - if (iFlags & 0x8000) - return; // operacje zostały już wykonane - if (Root) - { - if (iFlags & 0x0200) // jeśli wczytano z pliku tekstowego - { // jest jakiś dziwny błąd, że obkręcany ma być tylko ostatni submodel - // głównego łańcucha - // TSubModel *p=Root; - // do - //{p->InitialRotate(true); //ostatniemu należy się konwersja układu - // współrzędnych - // p=p->NextGet(); - //} - // while (p->NextGet()) - // Root->InitialRotate(false); //a poprzednim tylko optymalizacja - Root->InitialRotate(true); // argumet określa, czy wykonać pierwotny obrót + // pojazdów wykonywane po analizie animacji + if (iFlags & 0x8000) + return; // operacje zostały już wykonane + if (Root) + { + if (iFlags & 0x0200) { + // jeśli wczytano z pliku tekstowego jest jakiś dziwny błąd, + // że obkręcany ma być tylko ostatni submodel głównego łańcucha + // argumet określa, czy wykonać pierwotny obrót + Root->InitialRotate(true); + } + iFlags |= Root->FlagsCheck() | 0x8000; // flagi całego modelu + if (iNumVerts) { + if( m_geometrybank == null_handle ) { + m_geometrybank = GfxRenderer.Create_Bank(); + } + std::size_t dataoffset = 0; + Root->create_geometry( dataoffset, m_geometrybank ); } - iFlags |= Root->FlagsCheck() | 0x8000; // flagi całego modelu - if (false == asBinary.empty()) // jeśli jest podana nazwa - { - if (Global::iConvertModels) // i włączony zapis - SaveToBinFile(asBinary.c_str()); // utworzy tablicę (m_pVNT) + if( ( Global.iConvertModels > 0 ) + && ( false == asBinary.empty() ) ) { + SaveToBinFile( asBinary ); asBinary = ""; // zablokowanie powtórnego zapisu } - if (iNumVerts) - { - if (Global::fDistanceFactor != - 1.0) // trochę zaoszczędzi czasu na modelach z wieloma submocelami - Root->AdjustDist(); // aktualizacja odległości faz LoD, zależnie od - // rozdzielczości pionowej oraz multisamplingu - if (Global::bUseVBO) - { - if (!m_pVNT) // jeśli nie ma jeszcze tablicy (wczytano z pliku - // tekstowego) - { // tworzenie tymczasowej tablicy z wierzchołkami całego modelu - MakeArray(iNumVerts); // tworzenie tablic dla VBO - Root->RaArrayFill(m_pVNT); // wypełnianie tablicy - BuildVBOs(); // tworzenie VBO i usuwanie tablicy z pamięci - } - else - BuildVBOs(false); // tworzenie VBO bez usuwania tablicy z pamięci - } - else - { // przygotowanie skompilowanych siatek dla DisplayLists - Root->DisplayLists(); // tworzenie skompilowanej listy dla submodelu - } - // if (Root->TextureID) //o ile ma teksturę - // Root->iFlags|=0x80; //konieczność ustawienia tekstury - } } }; -void TModel3d::SaveToBinFile(char const *FileName) -{ // zapis modelu binarnego - WriteLog("Saving E3D binary model."); - int i, zero = 0; - TSubModelInfo *info = new TSubModelInfo[iSubModelsCount]; - info->Reset(); - Root->Info(); // zebranie informacji o submodelach - int len; //łączna długość pliku - int sub; // ilość submodeli (w bajtach) - int tra; // wielkość obszaru transformów - int vnt; // wielkość obszaru wierzchołków - int tex = 0; // wielkość obszaru nazw tekstur - int nam = 0; // wielkość obszaru nazw submodeli - sub = 8 + sizeof(TSubModel) * iSubModelsCount; - tra = info->iTotalTransforms ? 8 + 64 * info->iTotalTransforms : 0; - vnt = 8 + 32 * iNumVerts; - for (i = 0; i < iSubModelsCount; ++i) - { - tex += info[i].iTextureLen; - nam += info[i].iNameLen; - } - if (tex) - tex += 9; // 8 na nagłówek i jeden ciąg pusty (tylko znacznik końca) - if (nam) - nam += 8; - len = 8 + sub + tra + vnt + tex + ((-tex) & 3) + nam + ((-nam) & 3); - TSubModel *roboczy = new TSubModel(); // bufor używany do zapisywania - // AnsiString *asN=&roboczy->asName,*asT=&roboczy->asTexture; - // roboczy->FirstInit(); //żeby delete nie usuwało czego nie powinno - /* TFileStream *fs = new TFileStream(AnsiString(FileName), fmCreate); -*/ { - std::ofstream file(FileName, std::ios::binary); - file.unsetf(std::ios::skipws); - file.write("E3D0", 4); // kromka główna - file.write(reinterpret_cast(&len), 4); - - file.write("SUB0", 4); // dane submodeli - file.write(reinterpret_cast(&sub), 4); - for (i = 0; i < iSubModelsCount; ++i) - { - roboczy->InfoSet(info + i); - file.write(reinterpret_cast(roboczy), - sizeof(TSubModel)); // zapis jednego submodelu - } - if (tra) - { // zapis transformów - file.write("TRA0", 4); // transformy - file.write(reinterpret_cast(&tra), 4); - for (i = 0; i < iSubModelsCount; ++i) - if (info[i].iTransform >= 0) - file.write(reinterpret_cast(info[i].pSubModel->GetMatrix()), 16 * 4); - } - { // zapis wierzchołków - MakeArray(iNumVerts); // tworzenie tablic dla VBO - Root->RaArrayFill(m_pVNT); // wypełnianie tablicy - file.write("VNT0", 4); // wierzchołki - file.write(reinterpret_cast(&vnt), 4); - file.write(reinterpret_cast(m_pVNT), 32 * iNumVerts); - } - if (tex) // może być jeden submodel ze zmienną teksturą i nazwy nie będzie - { // zapis nazw tekstur - file.write("TEX0", 4); // nazwy tekstur - i = (tex + 3) & ~3; // zaokrąglenie w górę - file.write(reinterpret_cast(&i), 4); - file.write(reinterpret_cast(&zero), - 1); // ciąg o numerze zero nie jest używany, ma tylko znacznik końca - for (i = 0; i < iSubModelsCount; ++i) - if (info[i].iTextureLen) - file.write(info[i].pSubModel->pTexture, info[i].iTextureLen); - if ((-tex) & 3) - file.write(reinterpret_cast(&zero), - ((-tex) & 3)); // wyrównanie do wielokrotności 4 bajtów - } - if (nam) // może być jeden anonimowy submodel w modelu - { // zapis nazw submodeli - file.write("NAM0", 4); // nazwy submodeli - i = (nam + 3) & ~3; // zaokrąglenie w górę - file.write(reinterpret_cast(&i), 4); - for (i = 0; i < iSubModelsCount; ++i) - if (info[i].iNameLen) - file.write(info[i].pSubModel->pName, info[i].iNameLen); - if ((-nam) & 3) - file.write(reinterpret_cast(&zero), - ((-nam) & 3)); // wyrównanie do wielokrotności 4 bajtów - } - } // file autocloses on getting out of scope - // roboczy->FirstInit(); //żeby delete nie usuwało czego nie powinno - // roboczy->iFlags=0; //żeby delete nie usuwało czego nie powinno - // roboczy->asName)=asN; - //&roboczy->asTexture=asT; - delete roboczy; - delete[] info; -}; - -void TModel3d::BreakHierarhy() -{ - Error("Not implemented yet :("); -}; - -/* -void TModel3d::Render(vector3 pPosition,double fAngle,GLuint -ReplacableSkinId,int iAlpha) -{ -// glColor3f(1.0f,1.0f,1.0f); -// glColor3f(0.0f,0.0f,0.0f); - glPushMatrix(); - - glTranslated(pPosition.x,pPosition.y,pPosition.z); - if (fAngle!=0) - glRotatef(fAngle,0,1,0); -/* - matrix4x4 Identity; - Identity.Identity(); - - matrix4x4 CurrentMatrix; - glGetdoublev(GL_MODELVIEW_MATRIX,CurrentMatrix.getArray()); - vector3 pos=vector3(0,0,0); - pos=CurrentMatrix*pos; - fSquareDist=SquareMagnitude(pos); - * / - fSquareDist=SquareMagnitude(pPosition-Global::GetCameraPosition()); - -#ifdef _DEBUG - if (Root) - Root->Render(ReplacableSkinId,iAlpha); -#else - Root->Render(ReplacableSkinId,iAlpha); -#endif - glPopMatrix(); -}; -*/ - -void TModel3d::Render(double fSquareDistance, texture_manager::size_type *ReplacableSkinId, int iAlpha) -{ - iAlpha ^= 0x0F0F000F; // odwrócenie flag tekstur, aby wyłapać nieprzezroczyste - if (iAlpha & iFlags & 0x1F1F001F) // czy w ogóle jest co robić w tym cyklu? - { - TSubModel::fSquareDist = fSquareDistance; // zmienna globalna! - Root->ReplacableSet(ReplacableSkinId, iAlpha); - Root->RenderDL(); - } -}; - -void TModel3d::RenderAlpha(double fSquareDistance, texture_manager::size_type *ReplacableSkinId, int iAlpha) -{ - if (iAlpha & iFlags & 0x2F2F002F) - { - TSubModel::fSquareDist = fSquareDistance; // zmienna globalna! - Root->ReplacableSet(ReplacableSkinId, iAlpha); - Root->RenderAlphaDL(); - } -}; - -/* -void TModel3d::RaRender(vector3 pPosition,double fAngle,GLuint -*ReplacableSkinId,int -iAlpha) -{ -// glColor3f(1.0f,1.0f,1.0f); -// glColor3f(0.0f,0.0f,0.0f); - glPushMatrix(); //zapamiętanie matrycy przekształcenia - glTranslated(pPosition.x,pPosition.y,pPosition.z); - if (fAngle!=0) - glRotatef(fAngle,0,1,0); -/* - matrix4x4 Identity; - Identity.Identity(); - - matrix4x4 CurrentMatrix; - glGetdoublev(GL_MODELVIEW_MATRIX,CurrentMatrix.getArray()); - vector3 pos=vector3(0,0,0); - pos=CurrentMatrix*pos; - fSquareDist=SquareMagnitude(pos); -*/ -/* - fSquareDist=SquareMagnitude(pPosition-Global::GetCameraPosition()); //zmienna -globalna! - if (StartVBO()) - {//odwrócenie flag, aby wyłapać nieprzezroczyste - Root->ReplacableSet(ReplacableSkinId,iAlpha^0x0F0F000F); - Root->RaRender(); - EndVBO(); - } - glPopMatrix(); //przywrócenie ustawień przekształcenia -}; -*/ - -void TModel3d::RaRender( double fSquareDistance, texture_manager::size_type *ReplacableSkinId, int iAlpha ) -{ // renderowanie specjalne, np. kabiny - iAlpha ^= 0x0F0F000F; // odwrócenie flag tekstur, aby wyłapać nieprzezroczyste - if (iAlpha & iFlags & 0x1F1F001F) // czy w ogóle jest co robić w tym cyklu? - { - TSubModel::fSquareDist = fSquareDistance; // zmienna globalna! - if (StartVBO()) - { // odwrócenie flag, aby wyłapać nieprzezroczyste - Root->ReplacableSet(ReplacableSkinId, iAlpha); - Root->pRoot = this; - Root->RenderVBO(); - EndVBO(); - } - } -}; - -void TModel3d::RaRenderAlpha(double fSquareDistance, texture_manager::size_type *ReplacableSkinId, int iAlpha) -{ // renderowanie specjalne, np. kabiny - if (iAlpha & iFlags & 0x2F2F002F) // czy w ogóle jest co robić w tym cyklu? - { - TSubModel::fSquareDist = fSquareDistance; // zmienna globalna! - if (StartVBO()) - { - Root->ReplacableSet(ReplacableSkinId, iAlpha); - Root->RenderAlphaVBO(); - EndVBO(); - } - } -}; - -/* -void TModel3d::RaRenderAlpha(vector3 pPosition,double fAngle,GLuint -*ReplacableSkinId,int -iAlpha) -{ - glPushMatrix(); - glTranslatef(pPosition.x,pPosition.y,pPosition.z); - if (fAngle!=0) - glRotatef(fAngle,0,1,0); - fSquareDist=SquareMagnitude(pPosition-Global::GetCameraPosition()); //zmienna -globalna! - if (StartVBO()) - {Root->ReplacableSet(ReplacableSkinId,iAlpha); - Root->RaRenderAlpha(); - EndVBO(); - } - glPopMatrix(); -}; -*/ - -//----------------------------------------------------------------------------- -// 2011-03-16 cztery nowe funkcje renderowania z możliwością pochylania obiektów -//----------------------------------------------------------------------------- - -void TModel3d::Render(vector3 *vPosition, vector3 *vAngle, texture_manager::size_type *ReplacableSkinId, int iAlpha) -{ // nieprzezroczyste, Display List - glPushMatrix(); - glTranslated(vPosition->x, vPosition->y, vPosition->z); - if (vAngle->y != 0.0) - glRotated(vAngle->y, 0.0, 1.0, 0.0); - if (vAngle->x != 0.0) - glRotated(vAngle->x, 1.0, 0.0, 0.0); - if (vAngle->z != 0.0) - glRotated(vAngle->z, 0.0, 0.0, 1.0); - TSubModel::fSquareDist = - SquareMagnitude(*vPosition - Global::GetCameraPosition()); // zmienna globalna! - // odwrócenie flag, aby wyłapać nieprzezroczyste - Root->ReplacableSet(ReplacableSkinId, iAlpha ^ 0x0F0F000F); - Root->RenderDL(); - glPopMatrix(); -}; -void TModel3d::RenderAlpha(vector3 *vPosition, vector3 *vAngle, texture_manager::size_type *ReplacableSkinId, - int iAlpha) -{ // przezroczyste, Display List - glPushMatrix(); - glTranslated(vPosition->x, vPosition->y, vPosition->z); - if (vAngle->y != 0.0) - glRotated(vAngle->y, 0.0, 1.0, 0.0); - if (vAngle->x != 0.0) - glRotated(vAngle->x, 1.0, 0.0, 0.0); - if (vAngle->z != 0.0) - glRotated(vAngle->z, 0.0, 0.0, 1.0); - TSubModel::fSquareDist = - SquareMagnitude(*vPosition - Global::GetCameraPosition()); // zmienna globalna! - Root->ReplacableSet(ReplacableSkinId, iAlpha); - Root->RenderAlphaDL(); - glPopMatrix(); -}; -void TModel3d::RaRender( vector3 *vPosition, vector3 *vAngle, texture_manager::size_type *ReplacableSkinId, int iAlpha ) -{ // nieprzezroczyste, VBO - glPushMatrix(); - glTranslated(vPosition->x, vPosition->y, vPosition->z); - if (vAngle->y != 0.0) - glRotated(vAngle->y, 0.0, 1.0, 0.0); - if (vAngle->x != 0.0) - glRotated(vAngle->x, 1.0, 0.0, 0.0); - if (vAngle->z != 0.0) - glRotated(vAngle->z, 0.0, 0.0, 1.0); - TSubModel::fSquareDist = - SquareMagnitude(*vPosition - Global::GetCameraPosition()); // zmienna globalna! - if (StartVBO()) - { // odwrócenie flag, aby wyłapać nieprzezroczyste - Root->ReplacableSet(ReplacableSkinId, iAlpha ^ 0x0F0F000F); - Root->RenderVBO(); - EndVBO(); - } - glPopMatrix(); -}; -void TModel3d::RaRenderAlpha(vector3 *vPosition, vector3 *vAngle, texture_manager::size_type *ReplacableSkinId, - int iAlpha) -{ // przezroczyste, VBO - glPushMatrix(); - glTranslated(vPosition->x, vPosition->y, vPosition->z); - if (vAngle->y != 0.0) - glRotated(vAngle->y, 0.0, 1.0, 0.0); - if (vAngle->x != 0.0) - glRotated(vAngle->x, 1.0, 0.0, 0.0); - if (vAngle->z != 0.0) - glRotated(vAngle->z, 0.0, 0.0, 1.0); - TSubModel::fSquareDist = - SquareMagnitude(*vPosition - Global::GetCameraPosition()); // zmienna globalna! - if (StartVBO()) - { - Root->ReplacableSet(ReplacableSkinId, iAlpha); - Root->RenderAlphaVBO(); - EndVBO(); - } - glPopMatrix(); -}; - //----------------------------------------------------------------------------- // 2012-02 funkcje do tworzenia terenu z E3D //----------------------------------------------------------------------------- -int TModel3d::TerrainCount() +int TModel3d::TerrainCount() const { // zliczanie kwadratów kilometrowych (główna - // linia po Next) do tworznia tablicy - int i = 0; - TSubModel *r = Root; - while (r) - { - r = r->NextGet(); - ++i; - } - return i; + // linia po Next) do tworznia tablicy + int i = 0; + TSubModel *r = Root; + while (r) + { + r = r->NextGet(); + ++i; + } + return i; }; TSubModel *TModel3d::TerrainSquare(int n) { // pobieranie wskaźnika do submodelu (n) - int i = 0; - TSubModel *r = Root; - while (i < n) - { - r = r->NextGet(); - ++i; - } - r->UnFlagNext(); // blokowanie wyświetlania po Next głównej listy - return r; -}; -void TModel3d::TerrainRenderVBO(int n) -{ // renderowanie terenu z VBO - glPushMatrix(); - // glTranslated(vPosition->x,vPosition->y,vPosition->z); - // if (vAngle->y!=0.0) glRotated(vAngle->y,0.0,1.0,0.0); - // if (vAngle->x!=0.0) glRotated(vAngle->x,1.0,0.0,0.0); - // if (vAngle->z!=0.0) glRotated(vAngle->z,0.0,0.0,1.0); - // TSubModel::fSquareDist=SquareMagnitude(*vPosition-Global::GetCameraPosition()); - // //zmienna globalna! - if (StartVBO()) - { // odwrócenie flag, aby wyłapać nieprzezroczyste - // Root->ReplacableSet(ReplacableSkinId,iAlpha^0x0F0F000F); - TSubModel *r = Root; - while (r) - { - if (r->iVisible == - n) // tylko jeśli ma być widoczny w danej ramce (problem dla 0==false) - r->RenderVBO(); // sub kolejne (Next) się nie wyrenderują - r = r->NextGet(); - } - EndVBO(); - } - glPopMatrix(); + int i = 0; + TSubModel *r = Root; + while (i < n) + { + r = r->NextGet(); + ++i; + } + r->UnFlagNext(); // blokowanie wyświetlania po Next głównej listy + return r; }; diff --git a/Model3d.h b/Model3d.h index 9f1cb3e0..68a82983 100644 --- a/Model3d.h +++ b/Model3d.h @@ -7,447 +7,255 @@ obtain one at http://mozilla.org/MPL/2.0/. */ -#ifndef Model3dH -#define Model3dH +#pragma once -#include "opengl/glew.h" -#include "Parser.h" +#include "classes.h" #include "dumb3d.h" #include "Float3d.h" -#include "VBO.h" -#include "Texture.h" +#include "openglgeometrybank.h" +#include "material.h" -using namespace Math3D; - -struct GLVERTEX -{ - vector3 Point; - vector3 Normal; - float tu, tv; -}; - -class TStringPack -{ - char *data; - //+0 - 4 bajty: typ kromki - //+4 - 4 bajty: długość łącznie z nagłówkiem - //+8 - obszar łańcuchów znakowych, każdy zakończony zerem - int *index; - //+0 - 4 bajty: typ kromki - //+4 - 4 bajty: długość łącznie z nagłówkiem - //+8 - tabela indeksów - public: - char *String(int n); - char *StringAt(int n) - { - return data + 9 + n; - }; - TStringPack() - { - data = NULL; - index = NULL; - }; - void Init(char *d) - { - data = d; - }; - void InitIndex(int *i) - { - index = i; - }; -}; - -class TMaterialColor -{ - public: - TMaterialColor(){}; - TMaterialColor(char V) - { - r = g = b = V; - }; - // TMaterialColor(double R, double G, double B) - TMaterialColor(char R, char G, char B) - { - r = R; - g = G; - b = B; - }; - - char r, g, b; -}; - -/* -struct TMaterial -{ - int ID; - AnsiString Name; -//McZapkie-240702: lepiej uzywac wartosci float do opisu koloru bo funkcje opengl chyba tego na ogol -uzywaja - float Ambient[4]; - float Diffuse[4]; - float Specular[4]; - float Transparency; - GLuint TextureID; -}; -*/ -/* -struct THitBoxContainer -{ - TPlane Planes[6]; - int Index; - inline void Reset() { Planes[0]= TPlane(vector3(0,0,0),0.0f); }; - inline bool Inside(vector3 Point) - { - bool Hit= true; - - if (Planes[0].Defined()) - for (int i=0; i<6; i++) - { - if (Planes[i].GetSide(Point)>0) - { - Hit= false; - break; - }; - - } - else return(false); - return(Hit); - }; -}; -*/ - -/* Ra: tego nie będziemy już używać, bo można wycisnąć więcej -typedef enum -{smt_Unknown, //nieznany - smt_Mesh, //siatka - smt_Point, - smt_FreeSpotLight, //punkt świetlny - smt_Text, //generator tekstu - smt_Stars //wiele punktów świetlnych -} TSubModelType; -*/ // Ra: specjalne typy submodeli, poza tym GL_TRIANGLES itp. const int TP_ROTATOR = 256; const int TP_FREESPOTLIGHT = 257; const int TP_STARS = 258; const int TP_TEXT = 259; -enum TAnimType // rodzaj animacji +enum class TAnimType // rodzaj animacji { - at_None, // brak - at_Rotate, // obrót względem wektora o kąt - at_RotateXYZ, // obrót względem osi o kąty - at_Translate, // przesunięcie - at_SecondsJump, // sekundy z przeskokiem - at_MinutesJump, // minuty z przeskokiem - at_HoursJump, // godziny z przeskokiem 12h/360° - at_Hours24Jump, // godziny z przeskokiem 24h/360° - at_Seconds, // sekundy płynnie - at_Minutes, // minuty płynnie - at_Hours, // godziny płynnie 12h/360° - at_Hours24, // godziny płynnie 24h/360° - at_Billboard, // obrót w pionie do kamery - at_Wind, // ruch pod wpływem wiatru - at_Sky, // animacja nieba - at_IK = 0x100, // odwrotna kinematyka - submodel sterujący (np. staw skokowy) - at_IK11 = 0x101, // odwrotna kinematyka - submodel nadrzędny do sterowango (np. stopa) - at_IK21 = 0x102, // odwrotna kinematyka - submodel nadrzędny do sterowango (np. podudzie) - at_IK22 = 0x103, // odwrotna kinematyka - submodel nadrzędny do nadrzędnego sterowango (np. udo) - at_Digital = 0x200, // dziesięciocyfrowy licznik mechaniczny (z cylindrami) - at_DigiClk = 0x201, // zegar cyfrowy jako licznik na dziesięciościanach - at_Undefined = 0x800000FF // animacja chwilowo nieokreślona + at_None, // brak + at_Rotate, // obrót względem wektora o kąt + at_RotateXYZ, // obrót względem osi o kąty + at_Translate, // przesunięcie + at_SecondsJump, // sekundy z przeskokiem + at_MinutesJump, // minuty z przeskokiem + at_HoursJump, // godziny z przeskokiem 12h/360° + at_Hours24Jump, // godziny z przeskokiem 24h/360° + at_Seconds, // sekundy płynnie + at_Minutes, // minuty płynnie + at_Hours, // godziny płynnie 12h/360° + at_Hours24, // godziny płynnie 24h/360° + at_Billboard, // obrót w pionie do kamery + at_Wind, // ruch pod wpływem wiatru + at_Sky, // animacja nieba + at_IK, // odwrotna kinematyka - submodel sterujący (np. staw skokowy) + at_IK11, // odwrotna kinematyka - submodel nadrzędny do sterowango (np. stopa) + at_IK21, // odwrotna kinematyka - submodel nadrzędny do sterowango (np. podudzie) + at_IK22, // odwrotna kinematyka - submodel nadrzędny do nadrzędnego sterowango (np. udo) + at_Digital, // dziesięciocyfrowy licznik mechaniczny (z cylindrami) + at_DigiClk, // zegar cyfrowy jako licznik na dziesięciościanach + at_Undefined // animacja chwilowo nieokreślona }; -class TModel3d; -class TSubModelInfo; +namespace scene { +class shape_node; +} class TSubModel { // klasa submodelu - pojedyncza siatka, punkt świetlny albo grupa punktów - // Ra: ta klasa ma mieć wielkość 256 bajtów, aby pokryła się z formatem binarnym - // Ra: nie przestawiać zmiennych, bo wczytują się z pliku binarnego! - private: - TSubModel *Next; - TSubModel *Child; - int eType; // Ra: modele binarne dają więcej możliwości niż mesh złożony z trójkątów - int iName; // numer łańcucha z nazwą submodelu, albo -1 gdy anonimowy - public: // chwilowo - TAnimType b_Anim; + //m7todo: zrobić normalną serializację - private: - int iFlags; // flagi informacyjne: - // bit 0: =1 faza rysowania zależy od wymiennej tekstury 0 - // bit 1: =1 faza rysowania zależy od wymiennej tekstury 1 - // bit 2: =1 faza rysowania zależy od wymiennej tekstury 2 - // bit 3: =1 faza rysowania zależy od wymiennej tekstury 3 - // bit 4: =1 rysowany w fazie nieprzezroczystych (stała tekstura albo brak) - // bit 5: =1 rysowany w fazie przezroczystych (stała tekstura) - // bit 7: =1 ta sama tekstura, co poprzedni albo nadrzędny - // bit 8: =1 wierzchołki wyświetlane z indeksów - // bit 9: =1 wczytano z pliku tekstowego (jest właścicielem tablic) - // bit 13: =1 wystarczy przesunięcie zamiast mnożenia macierzy (trzy jedynki) - // bit 14: =1 wymagane przechowanie macierzy (animacje) - // bit 15: =1 wymagane przechowanie macierzy (transform niejedynkowy) - union - { // transform, nie każdy submodel musi mieć - float4x4 *fMatrix; // pojedyncza precyzja wystarcza - // matrix4x4 *dMatrix; //do testu macierz podwójnej precyzji - int iMatrix; // w pliku binarnym jest numer matrycy - }; - int iNumVerts; // ilość wierzchołków (1 dla FreeSpotLight) - int iVboPtr; // początek na liście wierzchołków albo indeksów - int iTexture; // numer nazwy tekstury, -1 wymienna, 0 brak - float fVisible; // próg jasności światła do załączenia submodelu - float fLight; // próg jasności światła do zadziałania selfillum - float f4Ambient[4]; - float f4Diffuse[4]; // float ze względu na glMaterialfv() - float f4Specular[4]; - float f4Emision[4]; - float fWireSize; // nie używane, ale wczytywane - float fSquareMaxDist; - float fSquareMinDist; - // McZapkie-050702: parametry dla swiatla: - float fNearAttenStart; - float fNearAttenEnd; - bool bUseNearAtten; // te 3 zmienne okreslaja rysowanie aureoli wokol zrodla swiatla - int iFarAttenDecay; // ta zmienna okresla typ zaniku natezenia swiatla (0:brak, 1,2: potega 1/R) - float fFarDecayRadius; // normalizacja j.w. - float fCosFalloffAngle; // cosinus kąta stożka pod którym widać światło - float fCosHotspotAngle; // cosinus kąta stożka pod którym widać aureolę i zwiększone natężenie - // światła - float fCosViewAngle; // cos kata pod jakim sie teraz patrzy - // Ra: dalej są zmienne robocze, można je przestawiać z zachowaniem rozmiaru klasy - texture_manager::size_type TextureID; // numer tekstury, -1 wymienna, 0 brak - bool bWire; // nie używane, ale wczytywane - // short TexAlpha; //Ra: nie używane już - GLuint uiDisplayList; // roboczy numer listy wyświetlania - float Opacity; // nie używane, ale wczytywane - // ABu: te same zmienne, ale zdublowane dla Render i RenderAlpha, - // bo sie chrzanilo przemieszczanie obiektow. - // Ra: już się nie chrzani - float f_Angle; - float3 v_RotateAxis; - float3 v_Angles; + friend opengl_renderer; + friend TModel3d; // temporary workaround. TODO: clean up class content/hierarchy + friend TDynamicObject; // temporary etc + friend scene::shape_node; // temporary etc - public: // chwilowo - float3 v_TransVector; - float8 *Vertices; // roboczy wskaźnik - wczytanie T3D do VBO - int iAnimOwner; // roboczy numer egzemplarza, który ustawił animację - TAnimType b_aAnim; // kody animacji oddzielnie, bo zerowane - public: - float4x4 *mAnimMatrix; // macierz do animacji kwaternionowych (należy do AnimContainer) - char space[8]; // wolne miejsce na przyszłe zmienne (zmniejszyć w miarę potrzeby) - public: - TSubModel ** - smLetter; // wskaźnik na tablicę submdeli do generoania tekstu (docelowo zapisać do E3D) - TSubModel *Parent; // nadrzędny, np. do wymnażania macierzy - int iVisible; // roboczy stan widoczności - // AnsiString asTexture; //robocza nazwa tekstury do zapisania w pliku binarnym - // AnsiString asName; //robocza nazwa - char *pTexture; // robocza nazwa tekstury do zapisania w pliku binarnym - char *pName; // robocza nazwa - private: - // int SeekFaceNormal(DWORD *Masks, int f,DWORD dwMask,vector3 *pt,GLVERTEX - // *Vertices); - int SeekFaceNormal(unsigned int *Masks, int f, unsigned int dwMask, float3 *pt, float8 *Vertices); - void RaAnimation(TAnimType a); +public: + enum normalization { + none = 0, + rescale, + normalize + }; - public: - static int iInstance; // identyfikator egzemplarza, który aktualnie renderuje model - static texture_manager::size_type *ReplacableSkinId; - static int iAlpha; // maska bitowa dla danego przebiegu - static double fSquareDist; - static TModel3d *pRoot; - static std::string *pasText; // tekst dla wyświetlacza (!!!! do przemyślenia) - TSubModel(); - ~TSubModel(); - void FirstInit(); - int Load(cParser &Parser, TModel3d *Model, int Pos, bool dynamic); - void ChildAdd(TSubModel *SubModel); - void NextAdd(TSubModel *SubModel); - TSubModel * NextGet() - { - return Next; - }; - TSubModel * ChildGet() - { - return Child; - }; - int TriangleAdd(TModel3d *m, texture_manager::size_type tex, int tri); - float8 * TrianglePtr(int tex, int pos, int *la, int *ld, int *ls); - // float8* TrianglePtr(const char *tex,int tri); - // void SetRotate(vector3 vNewRotateAxis,float fNewAngle); - void SetRotate(float3 vNewRotateAxis, float fNewAngle); - void SetRotateXYZ(vector3 vNewAngles); - void SetRotateXYZ(float3 vNewAngles); - void SetTranslate(vector3 vNewTransVector); - void SetTranslate(float3 vNewTransVector); - void SetRotateIK1(float3 vNewAngles); - TSubModel * GetFromName(std::string const &search, bool i = true); - TSubModel * GetFromName(char const *search, bool i = true); - void RenderDL(); - void RenderAlphaDL(); - void RenderVBO(); - void RenderAlphaVBO(); - // inline matrix4x4* GetMatrix() {return dMatrix;}; - inline float4x4 * GetMatrix() - { - return fMatrix; - }; - // matrix4x4* GetTransform() {return Matrix;}; - inline void Hide() - { - iVisible = 0; - }; - void RaArrayFill(CVertNormTex *Vert); - // void Render(); - int FlagsCheck(); - void WillBeAnimated() - { - if (this) - iFlags |= 0x4000; - }; - void InitialRotate(bool doit); - void DisplayLists(); - void Info(); - void InfoSet(TSubModelInfo *info); - void BinInit(TSubModel *s, float4x4 *m, float8 *v, TStringPack *t, TStringPack *n = NULL, - bool dynamic = false); - void ReplacableSet(texture_manager::size_type *r, int a) - { - ReplacableSkinId = r; - iAlpha = a; - }; - void TextureNameSet(const char *n); - void NameSet(const char *n); - // Ra: funkcje do budowania terenu z E3D - int Flags() - { - return iFlags; - }; - void UnFlagNext() - { - iFlags &= 0x00FFFFFF; - }; - void ColorsSet(int *a, int *d, int *s); - inline float3 Translation1Get() - { - return fMatrix ? *(fMatrix->TranslationGet()) + v_TransVector : v_TransVector; - } - inline float3 Translation2Get() - { - return *(fMatrix->TranslationGet()) + Child->Translation1Get(); - } - int GetTextureId() - { - return TextureID; - } - void ParentMatrix(float4x4 *m); - float MaxY(const float4x4 &m); - void AdjustDist(); +private: + int iNext{ 0 }; + int iChild{ 0 }; + int eType{ TP_ROTATOR }; // Ra: modele binarne dają więcej możliwości niż mesh złożony z trójkątów + int iName{ -1 }; // numer łańcucha z nazwą submodelu, albo -1 gdy anonimowy +public: // chwilowo + TAnimType b_Anim{ TAnimType::at_None }; + +private: + int iFlags{ 0x0200 }; // bit 9=1: submodel został utworzony a nie ustawiony na wczytany plik + // flagi informacyjne: + // bit 0: =1 faza rysowania zależy od wymiennej tekstury 0 + // bit 1: =1 faza rysowania zależy od wymiennej tekstury 1 + // bit 2: =1 faza rysowania zależy od wymiennej tekstury 2 + // bit 3: =1 faza rysowania zależy od wymiennej tekstury 3 + // bit 4: =1 rysowany w fazie nieprzezroczystych (stała tekstura albo brak) + // bit 5: =1 rysowany w fazie przezroczystych (stała tekstura) + // bit 7: =1 ta sama tekstura, co poprzedni albo nadrzędny + // bit 8: =1 wierzchołki wyświetlane z indeksów + // bit 9: =1 wczytano z pliku tekstowego (jest właścicielem tablic) + // bit 13: =1 wystarczy przesunięcie zamiast mnożenia macierzy (trzy jedynki) + // bit 14: =1 wymagane przechowanie macierzy (animacje) + // bit 15: =1 wymagane przechowanie macierzy (transform niejedynkowy) + union + { // transform, nie każdy submodel musi mieć + float4x4 *fMatrix = nullptr; // pojedyncza precyzja wystarcza + int iMatrix; // w pliku binarnym jest numer matrycy + }; + int iNumVerts { -1 }; // ilość wierzchołków (1 dla FreeSpotLight) + int tVboPtr; // początek na liście wierzchołków albo indeksów + int iTexture { 0 }; // numer nazwy tekstury, -1 wymienna, 0 brak + float fLight { -1.0f }; // próg jasności światła do zadziałania selfillum + glm::vec4 + f4Ambient { 1.0f,1.0f,1.0f,1.0f }, + f4Diffuse { 1.0f,1.0f,1.0f,1.0f }, + f4Specular { 0.0f,0.0f,0.0f,1.0f }, + f4Emision { 1.0f,1.0f,1.0f,1.0f }; + normalization m_normalizenormals { normalization::none }; // indicates vectors need to be normalized due to scaling etc + float fWireSize { 0.0f }; // nie używane, ale wczytywane + float fSquareMaxDist { 10000.0f * 10000.0f }; + float fSquareMinDist { 0.0f }; + // McZapkie-050702: parametry dla swiatla: + float fNearAttenStart { 40.0f }; + float fNearAttenEnd { 80.0f }; + bool bUseNearAtten { false }; // te 3 zmienne okreslaja rysowanie aureoli wokol zrodla swiatla + int iFarAttenDecay { 0 }; // ta zmienna okresla typ zaniku natezenia swiatla (0:brak, 1,2: potega 1/R) + float fFarDecayRadius { 100.0f }; // normalizacja j.w. + float fCosFalloffAngle { 0.5f }; // cosinus kąta stożka pod którym widać światło + float fCosHotspotAngle { 0.3f }; // cosinus kąta stożka pod którym widać aureolę i zwiększone natężenie światła + float fCosViewAngle { 0.0f }; // cos kata pod jakim sie teraz patrzy + + TSubModel *Next { nullptr }; + TSubModel *Child { nullptr }; +public: // temporary access, clean this up during refactoring + gfx::geometry_handle m_geometry { 0, 0 }; // geometry of the submodel +private: + material_handle m_material { null_handle }; // numer tekstury, -1 wymienna, 0 brak + bool bWire { false }; // nie używane, ale wczytywane + float Opacity { 1.0f }; + float f_Angle { 0.0f }; + float3 v_RotateAxis { 0.0f, 0.0f, 0.0f }; + float3 v_Angles { 0.0f, 0.0f, 0.0f }; + +public: // chwilowo + float3 v_TransVector { 0.0f, 0.0f, 0.0f }; + gfx::vertex_array Vertices; + float m_boundingradius { 0 }; + std::uintptr_t iAnimOwner{ 0 }; // roboczy numer egzemplarza, który ustawił animację + TAnimType b_aAnim{ TAnimType::at_None }; // kody animacji oddzielnie, bo zerowane + float4x4 *mAnimMatrix{ nullptr }; // macierz do animacji kwaternionowych (należy do AnimContainer) + TSubModel **smLetter{ nullptr }; // wskaźnik na tablicę submdeli do generoania tekstu (docelowo zapisać do E3D) + TSubModel *Parent{ nullptr }; // nadrzędny, np. do wymnażania macierzy + int iVisible { 1 }; // roboczy stan widoczności + float fVisible { 1.f }; // visibility level + std::string m_materialname; // robocza nazwa tekstury do zapisania w pliku binarnym + std::string pName; // robocza nazwa +private: + int SeekFaceNormal( std::vector const &Masks, int const Startface, unsigned int const Mask, glm::vec3 const &Position, gfx::vertex_array const &Vertices ); + void RaAnimation(TAnimType a); + +public: + static size_t iInstance; // identyfikator egzemplarza, który aktualnie renderuje model + static material_handle const *ReplacableSkinId; + static int iAlpha; // maska bitowa dla danego przebiegu + static float fSquareDist; + static TModel3d *pRoot; + static std::string *pasText; // tekst dla wyświetlacza (!!!! do przemyślenia) + TSubModel() = default; + ~TSubModel(); + int Load(cParser &Parser, TModel3d *Model, /*int Pos,*/ bool dynamic); + void ChildAdd(TSubModel *SubModel); + void NextAdd(TSubModel *SubModel); + TSubModel * NextGet() { return Next; }; + TSubModel * ChildGet() { return Child; }; + int count_siblings(); + int count_children(); + int TriangleAdd(TModel3d *m, material_handle tex, int tri); + void SetRotate(float3 vNewRotateAxis, float fNewAngle); + void SetRotateXYZ( Math3D::vector3 vNewAngles); + void SetRotateXYZ(float3 vNewAngles); + void SetTranslate( Math3D::vector3 vNewTransVector); + void SetTranslate(float3 vNewTransVector); + void SetRotateIK1(float3 vNewAngles); + TSubModel * GetFromName( std::string const &search, bool i = true ); + inline float4x4 * GetMatrix() { return fMatrix; }; + inline float4x4 const * GetMatrix() const { return fMatrix; }; + // returns offset vector from root + glm::vec3 offset( float const Geometrytestoffsetthreshold = 0.f ) const; + inline void Hide() { iVisible = 0; }; + + void create_geometry( std::size_t &Dataoffset, gfx::geometrybank_handle const &Bank ); + int FlagsCheck(); + void WillBeAnimated() { + iFlags |= 0x4000; }; + void InitialRotate(bool doit); + void BinInit(TSubModel *s, float4x4 *m, std::vector *t, std::vector *n, bool dynamic); + static void ReplacableSet(material_handle const *r, int a) { + ReplacableSkinId = r; + iAlpha = a; }; + void Name_Material( std::string const &Name ); + void Name( std::string const &Name ); + // Ra: funkcje do budowania terenu z E3D + int Flags() const { return iFlags; }; + void UnFlagNext() { iFlags &= 0x00FFFFFF; }; + void ColorsSet( glm::vec3 const &Ambient, glm::vec3 const &Diffuse, glm::vec3 const &Specular ); + // sets visibility level (alpha component) to specified value + void SetVisibilityLevel( float const Level, bool const Includechildren = false, bool const Includesiblings = false ); + // sets light level (alpha component of illumination color) to specified value + void SetLightLevel( float const Level, bool const Includechildren = false, bool const Includesiblings = false ); + inline float3 Translation1Get() { + return fMatrix ? *(fMatrix->TranslationGet()) + v_TransVector : v_TransVector; } + inline float3 Translation2Get() { + return *(fMatrix->TranslationGet()) + Child->Translation1Get(); } + material_handle GetMaterial() const { + return m_material; } + void ParentMatrix(float4x4 *m) const; + float MaxY( float4x4 const &m ); + + void deserialize(std::istream&); + void serialize(std::ostream&, + std::vector&, + std::vector&, + std::vector&, + std::vector&); + void serialize_geometry( std::ostream &Output ) const; + // places contained geometry in provided ground node }; -class TSubModelInfo -{ // klasa z informacjami o submodelach, do tworzenia pliku binarnego - public: - TSubModel *pSubModel; // wskaźnik na submodel - int iTransform; // numer transformu (-1 gdy brak) - int iName; // numer nazwy - int iTexture; // numer tekstury - int iNameLen; // długość nazwy - int iTextureLen; // długość tekstury - int iNext, iChild; // numer następnego i potomnego - static int iTotalTransforms; // ilość transformów - static int iTotalNames; // ilość nazw - static int iTotalTextures; // ilość tekstur - static int iCurrent; // aktualny obiekt - static TSubModelInfo *pTable; // tabele obiektów pomocniczych - TSubModelInfo() - { - pSubModel = NULL; - iTransform = iName = iTexture = iNext = iChild = -1; // nie ma - iNameLen = iTextureLen = 0; - } - void Reset() - { - pTable = this; // ustawienie wskaźnika tabeli obiektów - iTotalTransforms = iTotalNames = iTotalTextures = iCurrent = 0; // zerowanie liczników - } - ~TSubModelInfo(){}; -}; - -class TModel3d : public CMesh +class TModel3d { - private: - // TMaterial *Materials; - // int MaterialsCount; //Ra: nie używane - // bool TractionPart; //Ra: nie używane - TSubModel *Root; // drzewo submodeli - int iFlags; // Ra: czy submodele mają przezroczyste tekstury - public: // Ra: tymczasowo + friend opengl_renderer; + +private: + TSubModel *Root; // drzewo submodeli + int iFlags; // Ra: czy submodele mają przezroczyste tekstury +public: // Ra: tymczasowo int iNumVerts; // ilość wierzchołków (gdy nie ma VBO, to m_nVertexCount=0) - private: - TStringPack Textures; // nazwy tekstur - TStringPack Names; // nazwy submodeli - int *iModel; // zawartość pliku binarnego - int iSubModelsCount; // Ra: używane do tworzenia binarnych - std::string asBinary; // nazwa pod którą zapisać model binarny - public: - inline TSubModel * GetSMRoot() - { - return (Root); - }; - // double Radius; //Ra: nie używane + gfx::geometrybank_handle m_geometrybank; + bool m_geometrycreated { false }; +private: + std::vector Textures; // nazwy tekstur + std::vector Names; // nazwy submodeli + std::vector Matrices; // submodel matrices + int iSubModelsCount; // Ra: używane do tworzenia binarnych + std::string asBinary; // nazwa pod którą zapisać model binarny + std::string m_filename; + +public: TModel3d(); - TModel3d(char *FileName); ~TModel3d(); - TSubModel * GetFromName(const char *sName); - // TMaterial* GetMaterialFromName(char *sName); - TSubModel * AddToNamed(const char *Name, TSubModel *SubModel); - void AddTo(TSubModel *tmp, TSubModel *SubModel); - void LoadFromTextFile(std::string const &FileName, bool dynamic); - void LoadFromBinFile(std::string const &FileName, bool dynamic); - bool LoadFromFile(std::string const &FileName, bool dynamic); - void SaveToBinFile(char const *FileName); - void BreakHierarhy(); - // renderowanie specjalne - void Render(double fSquareDistance, texture_manager::size_type *ReplacableSkinId = NULL, int iAlpha = 0x30300030); - void RenderAlpha(double fSquareDistance, texture_manager::size_type *ReplacableSkinId = NULL, - int iAlpha = 0x30300030); - void RaRender(double fSquareDistance, texture_manager::size_type *ReplacableSkinId = NULL, int iAlpha = 0x30300030); - void RaRenderAlpha(double fSquareDistance, texture_manager::size_type *ReplacableSkinId = NULL, - int iAlpha = 0x30300030); - // jeden kąt obrotu - void Render(vector3 pPosition, double fAngle = 0, texture_manager::size_type *ReplacableSkinId = NULL, - int iAlpha = 0x30300030); - void RenderAlpha(vector3 pPosition, double fAngle = 0, texture_manager::size_type *ReplacableSkinId = NULL, - int iAlpha = 0x30300030); - void RaRender(vector3 pPosition, double fAngle = 0, texture_manager::size_type *ReplacableSkinId = NULL, - int iAlpha = 0x30300030); - void RaRenderAlpha(vector3 pPosition, double fAngle = 0, texture_manager::size_type *ReplacableSkinId = NULL, - int iAlpha = 0x30300030); - // trzy kąty obrotu - void Render( vector3 *vPosition, vector3 *vAngle, texture_manager::size_type *ReplacableSkinId = NULL, - int iAlpha = 0x30300030); - void RenderAlpha( vector3 *vPosition, vector3 *vAngle, texture_manager::size_type *ReplacableSkinId = NULL, - int iAlpha = 0x30300030); - void RaRender( vector3 *vPosition, vector3 *vAngle, texture_manager::size_type *ReplacableSkinId = NULL, - int iAlpha = 0x30300030); - void RaRenderAlpha( vector3 *vPosition, vector3 *vAngle, texture_manager::size_type *ReplacableSkinId = NULL, - int iAlpha = 0x30300030); - // inline int GetSubModelsCount() { return (SubModelsCount); }; - int Flags() - { - return iFlags; - }; - void Init(); - char * NameGet() - { - return Root ? Root->pName : NULL; - }; - int TerrainCount(); - TSubModel * TerrainSquare(int n); - void TerrainRenderVBO(int n); + float bounding_radius() const { + return ( + Root ? + Root->m_boundingradius : + 0.f ); } + inline TSubModel * GetSMRoot() { return (Root); }; + TSubModel * GetFromName(std::string const &Name) const; + TSubModel * AddToNamed(const char *Name, TSubModel *SubModel); + void AddTo(TSubModel *tmp, TSubModel *SubModel); + void LoadFromTextFile(std::string const &FileName, bool dynamic); + void LoadFromBinFile(std::string const &FileName, bool dynamic); + bool LoadFromFile(std::string const &FileName, bool dynamic); + void SaveToBinFile(std::string const &FileName); + int Flags() const { return iFlags; }; + void Init(); + std::string NameGet() const { return m_filename; }; + int TerrainCount() const; + TSubModel * TerrainSquare(int n); + void deserialize(std::istream &s, size_t size, bool dynamic); }; //--------------------------------------------------------------------------- -#endif diff --git a/Names.cpp b/Names.cpp index 1f6bcd54..c9f26e8e 100644 --- a/Names.cpp +++ b/Names.cpp @@ -11,179 +11,3 @@ http://mozilla.org/MPL/2.0/. #include "Names.h" //--------------------------------------------------------------------------- - -/* -Moduł zarządzający plikami oraz wyszukiwaniem obiektów wg nazw. -1. Ma przydzielony z góry (EU07.INI) obszar pamięci (rzędu 16MB). -2. W przypadku przepełnienia dostępnej pamięci wystąpi błąd wczytywania. -3. Obszar ten będzie zużywany na rekordy obiektów oraz ciągi tekstowe z nazwami. -4. Rekordy będą sortowane w ramach typu (tekstury, dźwięki, modele, node, eventy). -5. Pierwszy etap wyszukiwania to 5 bitów z pierwszego bajtu i 3 z drugiego (256). -6. Dla plików istnieje możliwość wczytania ich w innym terminie. -7. Możliwość wczytania plików w oddzielnym watku (np. tekstur). - -Obsługiwane pliki: -1. Tekstury, można wczytywać później, rekord przechowuje numer podany przez kartę graficzną. -2. Dźwięki, można wczytać później. -3. Modele, można wczytać później o ile nie mają animacji eventami i nie dotyczą pojazdów. - -Obiekty sortowane wg nazw, można dodawać i usuwać komórki scenerii: -4. Tory, drogi, rzeki - wyszukiwanie w celu sprawdzenia zajetości. -5. Eventy - wyszukiwane przy zewnętrznym wywołaniu oraz podczas wczytywania. -6. Pojazdy - wyszukiwane w celu wysyłania komend. -7. Egzemplarze modeli animowanych - wyszukiwanie w celu połączenia z animacjami. - -*/ - -#ifdef EU07_USE_OLD_TNAMES_CLASS - -void ItemRecord::TreeAdd(ItemRecord *r, int c) -{ // dodanie rekordu do drzewa - ustalenie w której gałęzi - // zapisać w (iFlags) ile znaków jest zgodnych z nadrzędnym, żeby nie sprawdzać wszystkich od - // zera - if ((cName[c] && r->cName[c]) ? cName[c] == r->cName[c] : false) - TreeAdd(r, c + 1); // ustawić wg kolejnego znaku, chyba że zero - else if ((unsigned char)(cName[c]) < (unsigned char)(r->cName[c])) - { // zero jest najmniejsze - doczepiamy jako (rNext) - if (!rNext) - rNext = r; - else - rNext->TreeAdd(r, 0); // doczepić do tej gałęzi - } - else - { - if (!rPrev) - rPrev = r; - else - rPrev->TreeAdd(r, 0); // doczepić do tej gałęzi - } -}; - -void ItemRecord::ListGet(ItemRecord *r, int *&n) -{ // rekurencyjne wypełnianie posortowanej listy na podstawie drzewa - if (rPrev) - rPrev->ListGet(r, n); // dodanie wszystkich wcześniejszych - *n++ = this - r; // dodanie swojego indeksu do tabeli - if (rNext) - rNext->ListGet(r, n); // dodanie wszystkich późniejszych -}; - -void * ItemRecord::TreeFind(const char *n) -{ // wyszukanie ciągu (n) - ItemRecord *r = TreeFindRecord(n); - return r ? r->pData : NULL; -}; - -ItemRecord * ItemRecord::TreeFindRecord(const char *n) -{ // wyszukanie ciągu (n) - ItemRecord *r = this; //żeby nie robić rekurencji - int i = 0; - do - { - if (!n[i]) - if (!r->cName[i]) - return r; // znaleziony - if (n[i] == r->cName[i]) - ++i; // porównać kolejny znak - else if ((unsigned char)(n[i]) < (unsigned char)(r->cName[i])) - { - i = 0; // porównywać od nowa - r = r->rPrev; // wcześniejsza gałąź drzewa - } - else - { - i = 0; // porównywać od nowa - r = r->rNext; // późniejsza gałąź drzewa - } - } while (r); - return NULL; -}; - -TNames::TNames() -{ // tworzenie bufora - iSize = 16 * 1024 * 1024; // rozmiar bufora w bajtach - cBuffer = new char[iSize]; - ZeroMemory(cBuffer, iSize); // nie trzymać jakiś starych śmieci - rRecords = (ItemRecord *)cBuffer; - cLast = cBuffer + iSize; // bajt za buforem - iLast = -1; - ZeroMemory(rTypes, 20 * sizeof(ItemRecord *)); -}; - -TNames::~TNames() { - - delete[] cBuffer; -} - -int TNames::Add(int t, const char *n) -{ // dodanie obiektu typu (t) o nazwie (n) - int len = strlen(n) + 1; // ze znacznikiem końca - cLast -= len; // rezerwacja miejsca - memcpy(cLast, n, len); // przekopiowanie tekstu do bufora - // cLast[len-1]='\0'; - rRecords[++iLast].cName = cLast; // połączenie nazwy z rekordem - rRecords[iLast].iFlags = t; - if (!rTypes[t]) - rTypes[t] = rRecords + iLast; // korzeń drzewa, bo nie było wcześniej - else - rTypes[t]->TreeAdd(rRecords + iLast, 0); // doczepienie jako gałąź - // rTypes[t]=Sort(t); //sortowanie uruchamiać ręcznie - if ((iLast & 0x3F) == 0) // nie za często, bo sortowania zajmą więcej czasu niż wyszukiwania - Sort(t); // optymalizacja drzewa co jakiś czas - return iLast; -} -int TNames::Add(int t, const char *n, void *d) -{ - int i = Add(t, n); - rRecords[iLast].pData = d; - return i; -}; - -bool TNames::Update(int t, const char *n, void *d) -{ // dodanie jeśli nie ma, wymiana (d), gdy jest - ItemRecord *r = FindRecord(t, n); // najpierw sprawdzić, czy już jest - if (r) - { // przy zdublowaniu nazwy podmieniać w drzewku na późniejszy - r->pData = d; - return true; // duplikat - } - // Add(t,n,d); //nazwa unikalna - return false; // został dodany nowy -}; - -ItemRecord * TNames::TreeSet(int *n, int d, int u) -{ // rekurencyjne wypełnianie drzewa pozycjami od (d) do (u) - if (d == u) - { - rRecords[n[d]].rPrev = rRecords[n[d]].rNext = NULL; - return rRecords + n[d]; // tej gałęzi nie ma - } - else if (d > u) - return NULL; - int p = (u + d) >> 1; // połowa - rRecords[n[p]].rPrev = TreeSet(n, d, p - 1); // zapisanie wcześniejszych gałęzi - rRecords[n[p]].rNext = TreeSet(n, p + 1, u); // zapisanie późniejszych gałęzi - return rRecords + n[p]; -}; - -void TNames::Sort(int t) -{ // przebudowa drzewa typu (t), zwraca wierzchołek drzewa - if (iLast < 3) - return; // jak jest mało, to nie ma sensu sortować - if (rTypes[t]) // jeśli jest jakiś rekord danego typu - { - int *r = new int[iLast + 1]; // robocza tablica indeksów - numery posortowanych rekordów - int *q = r; // wskaźnik roboczy, przekazywany przez referencję - rTypes[t]->ListGet(rRecords, q); // drzewo jest już posortowane - zamienić je na listę - rTypes[t] = TreeSet(r, 0, (q - r) - 1); - delete[] r; - } - return; -}; - -ItemRecord * TNames::FindRecord(const int t, const char *n) -{ // poszukiwanie rekordu w celu np. zmiany wskaźnika - return rTypes[t] ? rTypes[t]->TreeFindRecord(n) : NULL; -}; - -#endif diff --git a/Names.h b/Names.h index d9220fb1..9c6652ab 100644 --- a/Names.h +++ b/Names.h @@ -1,4 +1,3 @@ -#pragma once /* This Source Code Form is subject to the terms of the Mozilla Public License, v. @@ -8,122 +7,61 @@ obtain one at http://mozilla.org/MPL/2.0/. */ +#pragma once + #include #include -#ifndef EU07_USE_OLD_TNAMES_CLASS - -template -class TNames { +template +class basic_table { public: -// types: - -// constructors: - TNames() = default; - -// destructor: - -// methods: - // dodanie obiektu z wskaźnikiem. updates data field if the object already exists. returns true for insertion, false for update +// destructor + ~basic_table() { + for( auto *item : m_items ) { + delete item; } } +// methods + // adds provided item to the collection. returns: true if there's no duplicate with the same name, false otherwise bool - Add( int const Type, std::string const &Name, _Pointer Data ) { - - auto lookup = find_map( Type ).emplace( Name, Data ); - if( lookup.second == false ) { - // record already exists, update it - lookup.first->second = Data; - return false; - } - else { - // new record inserted, bail out + insert( Type_ *Item ) { + m_items.emplace_back( Item ); + auto const itemname = Item->name(); + if( ( true == itemname.empty() ) || ( itemname == "none" ) ) { return true; } - } - // returns pointer associated with provided label, or nullptr if there's no match - _Pointer - Find( int const Type, std::string const &Name ) { + auto const itemhandle { m_items.size() - 1 }; + // add item name to the map + auto mapping = m_itemmap.emplace( itemname, itemhandle ); + if( true == mapping.second ) { + return true; + } + // cell with this name already exists; update mapping to point to the new one, for backward compatibility + mapping.first->second = itemhandle; + return false; } + // locates item with specified name. returns pointer to the item, or nullptr + Type_ * + find( std::string const &Name ) const { + auto lookup = m_itemmap.find( Name ); + return ( + lookup != m_itemmap.end() ? + m_items[ lookup->second ] : + nullptr ); } - auto const &map = find_map( Type ); - auto const lookup = map.find( Name ); - if( lookup != map.end() ) { return lookup->second; } - else { return nullptr; } - } +protected: +// types + using type_sequence = std::deque; + using index_map = std::unordered_map; +// members + type_sequence m_items; + index_map m_itemmap; -private: -// types: - typedef std::unordered_map pointer_map; - typedef std::unordered_map pointermap_map; +public: + // data access + type_sequence & + sequence() { + return m_items; } + type_sequence const & + sequence() const { + return m_items; } -// methods: - // returns database stored with specified type key; creates new database if needed. - pointer_map & - find_map( int const Type ) { - - return m_maps.emplace( Type, pointer_map() ).first->second; - } - -// members: - pointermap_map m_maps; // list of pointer maps of types specified so far }; - -#else - -//--------------------------------------------------------------------------- -class ItemRecord -{ // rekord opisujący obiekt; raz utworzony nie przemieszcza się - // rozmiar rekordu można zmienić w razie potrzeby - public: - char *cName; // wskaźnik do nazwy umieszczonej w buforze - int iFlags; // flagi bitowe - ItemRecord *rPrev, *rNext; // posortowane drzewo (przebudowywane w razie potrzeby) - union - { - void *pData; // wskaźnik do obiektu - int iData; // albo numer obiektu (tekstury) - unsigned int uData; - }; - // typedef - void ListGet(ItemRecord *r, int *&n); - void TreeAdd(ItemRecord *r, int c); - template inline TOut *DataGet() - { - return (TOut *)pData; - }; - template inline void DataSet(TOut *x) - { - pData = (void *)x; - }; - void * TreeFind(const char *n); - ItemRecord * TreeFindRecord(const char *n); -}; - -class TNames -{ - public: - int iSize; // rozmiar bufora - char *cBuffer; // bufor dla rekordów (na początku) i nazw (na końcu) - ItemRecord *rRecords; // rekordy na początku bufora - char *cLast; // ostatni użyty bajt na nazwy - ItemRecord *rTypes[20]; // rożne typy obiektów (początek drzewa) - int iLast; // ostatnio użyty rekord - public: - TNames(); - ~TNames(); - int Add(int t, const char *n); // dodanie obiektu typu (t) - int Add(int t, const char *n, void *d); // dodanie obiektu z wskaźnikiem - int Add(int t, const char *n, int d); // dodanie obiektu z numerem - bool Update(int t, const char *n, void *d); // dodanie jeśli nie ma, wymiana (d), gdy jest - void TreeSet(); - ItemRecord * TreeSet(int *n, int d, int u); - void Sort(int t); // przebudowa drzewa typu (t) - ItemRecord * Item(int n); // rekord o numerze (n) - inline void *Find(const int t, const char *n) - { - return rTypes[t] ? rTypes[t]->TreeFind(n) : NULL; - }; - ItemRecord * FindRecord(const int t, const char *n); - // template inline TOut* Find(const int t,const char *n) - //{return (TOut*)(rTypes[t]->TreeFind(n));}; -}; -#endif diff --git a/PyInt.cpp b/PyInt.cpp index b3cdb28a..95d44486 100644 --- a/PyInt.cpp +++ b/PyInt.cpp @@ -1,620 +1,319 @@ +/* +This Source Code Form is subject to the +terms of the Mozilla Public License, v. +2.0. If a copy of the MPL was not +distributed with this file, You can +obtain one at +http://mozilla.org/MPL/2.0/. +*/ + #include "stdafx.h" #include "PyInt.h" -#include "Train.h" + +#include "globals.h" +#include "application.h" +#include "renderer.h" #include "Logs.h" -//#include -//#include -//#include -TPythonInterpreter *TPythonInterpreter::_instance = NULL; +void render_task::run() { + // call the renderer + auto *output { PyObject_CallMethod( m_renderer, "render", "O", m_input ) }; + Py_DECREF( m_input ); -//#define _PY_INT_MORE_LOG + if( output != nullptr ) { + auto *outputwidth { PyObject_CallMethod( m_renderer, "get_width", nullptr ) }; + auto *outputheight { PyObject_CallMethod( m_renderer, "get_height", nullptr ) }; + // upload texture data + if( ( outputwidth != nullptr ) + && ( outputheight != nullptr ) ) { -TPythonInterpreter::TPythonInterpreter() -{ - WriteLog("Loading Python ..."); - Py_SetPythonHome("python"); - Py_Initialize(); - _main = PyImport_ImportModule("__main__"); - if (_main == NULL) - { - WriteLog("Cannot import Python module __main__"); + GfxRenderer.Bind_Material( m_target ); + // setup texture parameters + ::glTexParameteri( GL_TEXTURE_2D, GL_GENERATE_MIPMAP, GL_TRUE ); + ::glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR ); + ::glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR ); + if( GLEW_EXT_texture_filter_anisotropic ) { + // anisotropic filtering + ::glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_MAX_ANISOTROPY_EXT, Global.AnisotropicFiltering ); + } + ::glTexEnvf( GL_TEXTURE_FILTER_CONTROL, GL_TEXTURE_LOD_BIAS, -1.0 ); + // build texture + ::glTexImage2D( + GL_TEXTURE_2D, 0, + GL_RGBA8, + PyInt_AsLong( outputwidth ), PyInt_AsLong( outputheight ), 0, + GL_RGB, GL_UNSIGNED_BYTE, reinterpret_cast( PyString_AsString( output ) ) ); + } + Py_DECREF( outputheight ); + Py_DECREF( outputwidth ); + Py_DECREF( output ); } - _screenRendererPriority = THREAD_PRIORITY_NORMAL; // domyslny priorytet normalny - PyObject *cStringModule = PyImport_ImportModule("cStringIO"); - _stdErr = NULL; - if (cStringModule == NULL) - return; - PyObject *cStringClassName = PyObject_GetAttrString(cStringModule, "StringIO"); - if (cStringClassName == NULL) - return; - PyObject *cString = PyObject_CallObject(cStringClassName, NULL); - if (cString == NULL) - return; - if (PySys_SetObject("stderr", cString) != 0) - return; - _stdErr = cString; + // clean up after yourself + delete this; } -TPythonInterpreter *TPythonInterpreter::getInstance() -{ - if (!_instance) - { - _instance = new TPythonInterpreter(); +// initializes the module. returns true on success +auto python_taskqueue::init() -> bool { + +#ifdef _WIN32 + if (sizeof(void*) == 8) + Py_SetPythonHome("python64"); + else + Py_SetPythonHome("python"); +#elif __linux__ + if (sizeof(void*) == 8) + Py_SetPythonHome("linuxpython64"); + else + Py_SetPythonHome("linuxpython"); +#endif + Py_Initialize(); + PyEval_InitThreads(); + // save a pointer to the main PyThreadState object + m_mainthread = PyThreadState_Get(); + // do the setup work while we hold the lock + m_main = PyImport_ImportModule("__main__"); + if (m_main == nullptr) { + ErrorLog( "Python Interpreter: __main__ module is missing" ); + goto release_and_exit; } - return _instance; + + auto *stringiomodule { PyImport_ImportModule( "cStringIO" ) }; + auto *stringioclassname { ( + stringiomodule != nullptr ? + PyObject_GetAttrString( stringiomodule, "StringIO" ) : + nullptr ) }; + auto *stringioobject { ( + stringioclassname != nullptr ? + PyObject_CallObject( stringioclassname, nullptr ) : + nullptr ) }; + m_error = { ( + stringioobject == nullptr ? nullptr : + PySys_SetObject( "stderr", stringioobject ) != 0 ? nullptr : + stringioobject ) }; + + if( m_error == nullptr ) { goto release_and_exit; } + + if( false == run_file( "abstractscreenrenderer" ) ) { goto release_and_exit; } + + // release the lock + PyEval_ReleaseLock(); + + WriteLog( "Python Interpreter setup complete" ); + + // init workers + for( auto &worker : m_workers ) { + + auto *openglcontextwindow { Application.window( -1 ) }; + worker = + std::make_unique( + &python_taskqueue::run, this, + openglcontextwindow, std::ref( m_tasks ), std::ref( m_condition ), std::ref( m_exit ) ); + + if( worker == nullptr ) { return false; } + } + + return true; + +release_and_exit: + PyEval_ReleaseLock(); + return false; +} + +// shuts down the module +void python_taskqueue::exit() { + // let the workers know we're done with them + m_exit = true; + m_condition.notify_all(); + // let them free up their shit before we proceed + for( auto const &worker : m_workers ) { + worker->join(); + } + // get rid of the leftover tasks + // with the workers dead we don't have to worry about concurrent access anymore + for( auto *task : m_tasks.data ) { + delete task; + } + // take a bow + PyEval_AcquireLock(); + PyThreadState_Swap( m_mainthread ); + Py_Finalize(); +} + +// adds specified task along with provided collection of data to the work queue. returns true on success +auto python_taskqueue::insert( task_request const &Task ) -> bool { + + if( ( Task.renderer.empty() ) + || ( Task.input == nullptr ) + || ( Task.target == null_handle ) ) { return false; } + + auto *renderer { fetch_renderer( Task.renderer ) }; + if( renderer == nullptr ) { return false; } + // acquire a lock on the task queue and add a new task + { + std::lock_guard lock( m_tasks.mutex ); + m_tasks.data.emplace_back( new render_task( renderer, Task.input, Task.target ) ); + } + // potentially wake a worker to handle the new task + m_condition.notify_one(); + // all done + return true; +} + +// executes python script stored in specified file. returns true on success +auto python_taskqueue::run_file( std::string const &File, std::string const &Path ) -> bool { + + auto const lookup { FileExists( { Path + File, "python/local/" + File }, { ".py" } ) }; + if( lookup.first.empty() ) { return false; } + + std::ifstream inputfile { lookup.first + lookup.second }; + std::string input; + input.assign( std::istreambuf_iterator( inputfile ), std::istreambuf_iterator() ); + + if( PyRun_SimpleString( input.c_str() ) != 0 ) { + error(); + return false; + } + + return true; +} + +auto python_taskqueue::fetch_renderer( std::string const Renderer ) ->PyObject * { + + auto const lookup { m_renderers.find( Renderer ) }; + if( lookup != std::end( m_renderers ) ) { + return lookup->second; + } + // try to load specified renderer class + auto const path { substr_path( Renderer ) }; + auto const file { Renderer.substr( path.size() ) }; + PyObject *renderer { nullptr }; + PyObject *rendererarguments { nullptr }; + PyEval_AcquireLock(); + { + if( m_main == nullptr ) { + ErrorLog( "Python Renderer: __main__ module is missing" ); + goto cache_and_return; + } + + if( false == run_file( file, path ) ) { + goto cache_and_return; + } + auto *renderername{ PyObject_GetAttrString( m_main, file.c_str() ) }; + if( renderername == nullptr ) { + ErrorLog( "Python Renderer: class \"" + file + "\" not defined" ); + goto cache_and_return; + } + rendererarguments = Py_BuildValue( "(s)", path.c_str() ); + if( rendererarguments == nullptr ) { + ErrorLog( "Python Renderer: failed to create initialization arguments" ); + goto cache_and_return; + } + renderer = PyObject_CallObject( renderername, rendererarguments ); + + if( PyErr_Occurred() != nullptr ) { + error(); + renderer = nullptr; + } + +cache_and_return: + // clean up after yourself + if( rendererarguments != nullptr ) { + Py_DECREF( rendererarguments ); + } + } + PyEval_ReleaseLock(); + // cache the failures as well so we don't try again on subsequent requests + m_renderers.emplace( Renderer, renderer ); + return renderer; +} + +void python_taskqueue::run( GLFWwindow *Context, rendertask_sequence &Tasks, threading::condition_variable &Condition, std::atomic &Exit ) { + + glfwMakeContextCurrent( Context ); + // create a state object for this thread + PyEval_AcquireLock(); + auto *threadstate { PyThreadState_New( m_mainthread->interp ) }; + PyEval_ReleaseLock(); + + render_task *task { nullptr }; + + while( false == Exit.load() ) { + // regardless of the reason we woke up prime the spurious wakeup flag for the next time + Condition.spurious( true ); + // keep working as long as there's any scheduled tasks + do { + task = nullptr; + // acquire a lock on the task queue and potentially grab a task from it + { + std::lock_guard lock( Tasks.mutex ); + if( false == Tasks.data.empty() ) { + // fifo + task = Tasks.data.front(); + Tasks.data.pop_front(); + } + } + if( task != nullptr ) { + // swap in my thread state + PyEval_AcquireLock(); + PyThreadState_Swap( threadstate ); + // execute python code + task->run(); + error(); + // clear the thread state + PyThreadState_Swap( nullptr ); + PyEval_ReleaseLock(); + } + // TBD, TODO: add some idle time between tasks in case we're on a single thread cpu? + } while( task != nullptr ); + // if there's nothing left to do wait until there is + // but check every now and then on your own to minimize potential deadlock situations + Condition.wait_for( std::chrono::seconds( 5 ) ); + } + // clean up thread state data + PyEval_AcquireLock(); + PyThreadState_Swap( nullptr ); + PyThreadState_Clear( threadstate ); + PyThreadState_Delete( threadstate ); + PyEval_ReleaseLock(); } void -TPythonInterpreter::killInstance() { +python_taskqueue::error() { - delete _instance; -} + if( PyErr_Occurred() == nullptr ) { return; } -bool TPythonInterpreter::loadClassFile( std::string const &lookupPath, std::string const &className ) -{ - std::set::const_iterator it = _classes.find(className); - if (it == _classes.end()) - { - FILE *sourceFile = _getFile(lookupPath, className); - if (sourceFile != nullptr) - { - fseek(sourceFile, 0, SEEK_END); - long fsize = ftell(sourceFile); - char *buffer = (char *)calloc(fsize + 1, sizeof(char)); - fseek(sourceFile, 0, SEEK_SET); - long freaded = fread(buffer, sizeof(char), fsize, sourceFile); - buffer[freaded] = 0; // z jakiegos powodu czytamy troche mniej i trzczeba dodac konczace -// zero do bufora (mimo ze calloc teoretycznie powiniene zwrocic -// wyzerowana pamiec) -#ifdef _PY_INT_MORE_LOG - char buf[255]; - sprintf(buf, "readed %d / %d characters for %s", freaded, fsize, className); - WriteLog(buf); -#endif // _PY_INT_MORE_LOG - fclose(sourceFile); - if (PyRun_SimpleString(buffer) != 0) - { - handleError(); - return false; - } - _classes.insert( className ); -/* - char *classNameToRemember = (char *)calloc(strlen(className) + 1, sizeof(char)); - strcpy(classNameToRemember, className); - _classes.insert(classNameToRemember); -*/ - free(buffer); - return true; - } - return false; - } - return true; -} - -PyObject *TPythonInterpreter::newClass( std::string const &className ) -{ - return newClass(className, NULL); -} - -FILE *TPythonInterpreter::_getFile( std::string const &lookupPath, std::string const &className ) -{ - if( false == lookupPath.empty() ) { - std::string const sourcefilepath = lookupPath + className + ".py"; - FILE *file = fopen( sourcefilepath.c_str(), "r" ); -#ifdef _PY_INT_MORE_LOG - WriteLog( sourceFilePath ); -#endif // _PY_INT_MORE_LOG - if( nullptr != file ) { return file; } - } - std::string sourcefilepath = "python\\local\\" + className + ".py"; - FILE *file = fopen( sourcefilepath.c_str(), "r" ); -#ifdef _PY_INT_MORE_LOG - WriteLog( sourceFilePath ); -#endif // _PY_INT_MORE_LOG - return file; // either the file, or a nullptr on fail -/* - char *sourceFilePath; - if (lookupPath != NULL) - { - sourceFilePath = (char *)calloc(strlen(lookupPath) + strlen(className) + 4, sizeof(char)); - strcat(sourceFilePath, lookupPath); - strcat(sourceFilePath, className); - strcat(sourceFilePath, ".py"); - - FILE *file = fopen(sourceFilePath, "r"); -#ifdef _PY_INT_MORE_LOG - WriteLog(sourceFilePath); -#endif // _PY_INT_MORE_LOG - free(sourceFilePath); - if (file != NULL) - { - return file; - } - } - char *basePath = "python\\local\\"; - sourceFilePath = (char *)calloc(strlen(basePath) + strlen(className) + 4, sizeof(char)); - strcat(sourceFilePath, basePath); - strcat(sourceFilePath, className); - strcat(sourceFilePath, ".py"); - - FILE *file = fopen(sourceFilePath, "r"); -#ifdef _PY_INT_MORE_LOG - WriteLog(sourceFilePath); -#endif // _PY_INT_MORE_LOG - free(sourceFilePath); - if (file != NULL) - { - return file; - } - return NULL; -*/ -} - -void TPythonInterpreter::handleError() -{ -#ifdef _PY_INT_MORE_LOG - WriteLog("Python Error occured"); -#endif // _PY_INT_MORE_LOG - if (_stdErr != NULL) - { // std err pythona jest buforowane + if( m_error != nullptr ) { + // std err pythona jest buforowane PyErr_Print(); - PyObject *bufferContent = PyObject_CallMethod(_stdErr, "getvalue", NULL); - PyObject_CallMethod(_stdErr, "truncate", "i", 0); // czyscimy bufor na kolejne bledy - WriteLog(PyString_AsString(bufferContent)); + auto *errortext { PyObject_CallMethod( m_error, "getvalue", nullptr ) }; + ErrorLog( PyString_AsString( errortext ) ); + // czyscimy bufor na kolejne bledy + PyObject_CallMethod( m_error, "truncate", "i", 0 ); } - else - { // nie dziala buffor pythona - if (PyErr_Occurred() != NULL) - { - PyObject *ptype, *pvalue, *ptraceback; - PyErr_Fetch(&ptype, &pvalue, &ptraceback); - if (ptype == NULL) - { - WriteLog("Don't konw how to handle NULL exception"); - } - PyErr_NormalizeException(&ptype, &pvalue, &ptraceback); - if (ptype == NULL) - { - WriteLog("Don't konw how to handle NULL exception"); - } - PyObject *pStrType = PyObject_Str(ptype); - if (pStrType != NULL) - { - WriteLog(PyString_AsString(pStrType)); - } - WriteLog(PyString_AsString(pvalue)); - PyObject *pStrTraceback = PyObject_Str(ptraceback); - if (pStrTraceback != NULL) - { - WriteLog(PyString_AsString(pStrTraceback)); - } - else - { - WriteLog("Python Traceback cannot be shown"); - } + else { + // nie dziala buffor pythona + PyObject *type, *value, *traceback; + PyErr_Fetch( &type, &value, &traceback ); + if( type == nullptr ) { + ErrorLog( "Python Interpreter: don't know how to handle null exception" ); } - else - { -#ifdef _PY_INT_MORE_LOG - WriteLog("Called python error handler when no error occured!"); -#endif // _PY_INT_MORE_LOG + PyErr_NormalizeException( &type, &value, &traceback ); + if( type == nullptr ) { + ErrorLog( "Python Interpreter: don't know how to handle null exception" ); + } + auto *typetext { PyObject_Str( type ) }; + if( typetext != nullptr ) { + ErrorLog( PyString_AsString( typetext ) ); + } + if( value != nullptr ) { + ErrorLog( PyString_AsString( value ) ); + } + auto *tracebacktext { PyObject_Str( traceback ) }; + if( tracebacktext != nullptr ) { + WriteLog( PyString_AsString( tracebacktext ) ); + } + else { + WriteLog( "Python Interpreter: failed to retrieve the stack traceback" ); } } } -PyObject *TPythonInterpreter::newClass(std::string const &className, PyObject *argsTuple) -{ - if (_main == NULL) - { - WriteLog("main turned into null"); - return NULL; - } - PyObject *classNameObj = PyObject_GetAttrString(_main, className.c_str()); - if (classNameObj == NULL) - { -#ifdef _PY_INT_MORE_LOG - char buf[255]; - sprintf(buf, "Python class %s not defined!", className); - WriteLog(buf); -#endif // _PY_INT_MORE_LOG - return NULL; - } - PyObject *object = PyObject_CallObject(classNameObj, argsTuple); - - if (PyErr_Occurred() != NULL) - { - handleError(); - return NULL; - } - return object; -} - -void TPythonInterpreter::setScreenRendererPriority(const char *priority) -{ - if (strncmp(priority, "normal", 6) == 0) - { - _screenRendererPriority = THREAD_PRIORITY_NORMAL; -//#ifdef _PY_INT_MORE_LOG - WriteLog("Python screen renderer priority: Normal"); -//#endif // _PY_INT_MORE_LOG - } - else if (strncmp(priority, "lower", 5) == 0) - { - _screenRendererPriority = THREAD_PRIORITY_BELOW_NORMAL; -//#ifdef _PY_INT_MORE_LOG - WriteLog("Python screen renderer priority: Lower"); -//#endif // _PY_INT_MORE_LOG - } - else if (strncmp(priority, "lowest", 6) == 0) - { - _screenRendererPriority = THREAD_PRIORITY_LOWEST; -//#ifdef _PY_INT_MORE_LOG - WriteLog("Python screen renderer priority: Lowest"); -//#endif // _PY_INT_MORE_LOG - } - else if (strncmp(priority, "idle", 4) == 0) - { - _screenRendererPriority = THREAD_PRIORITY_IDLE; -//#ifdef _PY_INT_MORE_LOG - WriteLog("Python screen renderer priority: Idle"); -//#endif // _PY_INT_MORE_LOG - } -} - -TPythonScreenRenderer::TPythonScreenRenderer(int textureId, PyObject *renderer) -{ - _textureId = textureId; - _pyRenderer = renderer; -} - -void TPythonScreenRenderer::updateTexture() -{ - int width, height; - if (_pyWidth == NULL || _pyHeight == NULL) - { - WriteLog("Unknown python texture size!"); - return; - } - width = PyInt_AsLong(_pyWidth); - height = PyInt_AsLong(_pyHeight); - if (_pyTexture != NULL) - { - char *textureData = PyString_AsString(_pyTexture); - if (textureData != NULL) - { -#ifdef _PY_INT_MORE_LOG - char buff[255]; - sprintf(buff, "Sending texture id: %d w: %d h: %d", _textureId, width, height); - WriteLog(buff); -#endif // _PY_INT_MORE_LOG - glPixelStorei(GL_UNPACK_ALIGNMENT, 1); - glBindTexture(GL_TEXTURE_2D, _textureId); - // setup texture parameters - if( GLEW_VERSION_1_4 ) { - - glTexParameteri( GL_TEXTURE_2D, GL_GENERATE_MIPMAP, GL_TRUE ); - glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR ); - glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR ); - glTexEnvf( GL_TEXTURE_FILTER_CONTROL, GL_TEXTURE_LOD_BIAS, -1.0 ); - } - else { - - glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR ); - glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR ); - } - // build texture - glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, width, height, 0, GL_RGB, GL_UNSIGNED_BYTE, textureData); - -#ifdef _PY_INT_MORE_LOG - GLenum status = glGetError(); - switch (status) - { - case GL_INVALID_ENUM: - WriteLog("An unacceptable value is specified for an enumerated argument. The " - "offending function is ignored, having no side effect other than to set " - "the error flag."); - break; - case GL_INVALID_VALUE: - WriteLog("A numeric argument is out of range. The offending function is ignored, " - "having no side effect other than to set the error flag."); - break; - case GL_INVALID_OPERATION: - WriteLog("The specified operation is not allowed in the current state. The " - "offending function is ignored, having no side effect other than to set " - "the error flag."); - break; - case GL_NO_ERROR: - WriteLog("No error has been recorded. The value of this symbolic constant is " - "guaranteed to be zero."); - break; - case GL_STACK_OVERFLOW: - WriteLog("This function would cause a stack overflow. The offending function is " - "ignored, having no side effect other than to set the error flag."); - break; - case GL_STACK_UNDERFLOW: - WriteLog("This function would cause a stack underflow. The offending function is " - "ignored, having no side effect other than to set the error flag."); - break; - case GL_OUT_OF_MEMORY: - WriteLog("There is not enough memory left to execute the function. The state of " - "OpenGL is undefined, except for the state of the error flags, after this " - "error is recorded."); - break; - }; -#endif // _PY_INT_MORE_LOG - } - else - { - WriteLog("RAW python texture data is NULL!"); - } - } - else - { - WriteLog("Python texture object is NULL!"); - } -} - -void TPythonScreenRenderer::render(PyObject *trainState) -{ -#ifdef _PY_INT_MORE_LOG - WriteLog("Python rendering texture ..."); -#endif // _PY_INT_MORE_LOG - _pyTexture = PyObject_CallMethod(_pyRenderer, "render", "O", trainState); - - if (_pyTexture == NULL) - { - TPythonInterpreter::getInstance()->handleError(); - } - else - { - _pyWidth = PyObject_CallMethod(_pyRenderer, "get_width", NULL); - if (_pyWidth == NULL) - { - TPythonInterpreter::getInstance()->handleError(); - } - _pyHeight = PyObject_CallMethod(_pyRenderer, "get_height", NULL); - if (_pyHeight == NULL) - { - TPythonInterpreter::getInstance()->handleError(); - } - } -} - -TPythonScreenRenderer::~TPythonScreenRenderer() -{ -#ifdef _PY_INT_MORE_LOG - WriteLog("PythonScreenRenderer descturctor called"); -#endif // _PY_INT_MORE_LOG - if (_pyRenderer != NULL) - { - Py_CLEAR(_pyRenderer); - } - cleanup(); -#ifdef _PY_INT_MORE_LOG - WriteLog("PythonScreenRenderer desctructor finished"); -#endif // _PY_INT_MORE_LOG -} - -void TPythonScreenRenderer::cleanup() -{ - if (_pyTexture != NULL) - { - Py_CLEAR(_pyTexture); - _pyTexture = NULL; - } - if (_pyWidth != NULL) - { - Py_CLEAR(_pyWidth); - _pyWidth = NULL; - } - if (_pyHeight != NULL) - { - Py_CLEAR(_pyHeight); - _pyHeight = NULL; - } -} - -void TPythonScreens::reset(void *train) -{ - _terminationFlag = true; - if (_thread != NULL) - { -// WriteLog("Awaiting python thread to end"); - WaitForSingleObject(_thread, INFINITE); - _thread = NULL; - } - _terminationFlag = false; - _cleanupReadyFlag = false; - _renderReadyFlag = false; - for (std::vector::iterator i = _screens.begin(); i != _screens.end(); - ++i) - { - delete *i; - } -#ifdef _PY_INT_MORE_LOG - WriteLog("Clearing renderer vector"); -#endif // _PY_INT_MORE_LOG - _screens.clear(); - _train = train; -} - -void TPythonScreens::init(cParser &parser, TModel3d *model, std::string const &name, int const cab) -{ - std::string asSubModelName, asPyClassName; - parser.getTokens( 2, false ); - parser - >> asSubModelName - >> asPyClassName; - std::string subModelName = ToLower( asSubModelName ); - std::string pyClassName = ToLower( asPyClassName ); - TSubModel *subModel = model->GetFromName(subModelName.c_str()); - if (subModel == NULL) - { - WriteLog( "Python Screen: submodel " + subModelName + " not found - Ignoring screen" ); - return; // nie ma takiego sub modelu w danej kabinie pomijamy - } - int textureId = TextureManager.Texture(subModel->GetTextureId()).id; - if (textureId <= 0) - { - WriteLog( "Python Screen: invalid texture id " + std::to_string(textureId) + " - Ignoring screen" ); - return; // sub model nie posiada tekstury lub tekstura wymienna - nie obslugiwana - } - TPythonInterpreter *python = TPythonInterpreter::getInstance(); - python->loadClassFile(_lookupPath, pyClassName); - PyObject *args = Py_BuildValue("(ssi)", _lookupPath.c_str(), name.c_str(), cab); - if (args == NULL) - { - WriteLog("Python Screen: cannot create __init__ arguments"); - return; - } - PyObject *pyRenderer = python->newClass(pyClassName, args); - Py_CLEAR(args); - if (pyRenderer == NULL) - { - WriteLog( "Python Screen: null renderer for " + pyClassName + " - Ignoring screen" ); - return; // nie mozna utworzyc obiektu Pythonowego - } - TPythonScreenRenderer *renderer = new TPythonScreenRenderer(textureId, pyRenderer); - _screens.push_back(renderer); - WriteLog( "Created python screen " + pyClassName + " on submodel " + subModelName + " (" + std::to_string(textureId) + ")" ); -} - -void TPythonScreens::update() -{ - if (!_renderReadyFlag) - { - return; - } - _renderReadyFlag = false; - for (std::vector::iterator i = _screens.begin(); i != _screens.end(); - ++i) - { - (*i)->updateTexture(); - } - _cleanupReadyFlag = true; -} - -void TPythonScreens::setLookupPath(std::string const &path) -{ - _lookupPath = path; -} - -TPythonScreens::TPythonScreens() -{ - TPythonInterpreter::getInstance()->loadClassFile("", "abstractscreenrenderer"); - _terminationFlag = false; - _renderReadyFlag = false; - _cleanupReadyFlag = false; - _thread = NULL; -} - -TPythonScreens::~TPythonScreens() -{ -#ifdef _PY_INT_MORE_LOG - WriteLog("Called python sceeens destructor"); -#endif // _PY_INT_MORE_LOG - reset(NULL); -/* - if (_lookupPath != NULL) - { -#ifdef _PY_INT_MORE_LOG - WriteLog("Freeing lookup path"); -#endif // _PY_INT_MORE_LOG - free(_lookupPath); - } -*/ -} - -void TPythonScreens::run() -{ - while (1) - { - if (_terminationFlag) - { - return; - } - TTrain *train = (TTrain *)_train; - _trainState = train->GetTrainState(); - if (_terminationFlag) - { - _freeTrainState(); - return; - } - for (std::vector::iterator i = _screens.begin(); - i != _screens.end(); ++i) - { - (*i)->render(_trainState); - } - _freeTrainState(); - if (_terminationFlag) - { - _cleanup(); - return; - } - _renderReadyFlag = true; - while (!_cleanupReadyFlag && !_terminationFlag) - { - Sleep(100); - } - if (_terminationFlag) - { - return; - } - _cleanup(); - } -} - -void TPythonScreens::finish() -{ - _thread = NULL; -} - -DWORD WINAPI ScreenRendererThread(LPVOID lpParam) -{ - TPythonScreens *renderer = (TPythonScreens *)lpParam; - renderer->run(); - renderer->finish(); -#ifdef _PY_INT_MORE_LOG - WriteLog("Python Screen Renderer Thread Ends"); -#endif // _PY_INT_MORE_LOG - return true; -} - -void TPythonScreens::start() -{ - if (_screens.size() > 0) - { - _thread = CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)ScreenRendererThread, this, - CREATE_SUSPENDED, reinterpret_cast(&_threadId)); - if (_thread != NULL) - { - SetThreadPriority(_thread, - TPythonInterpreter::getInstance()->getScreenRendererPriotity()); - if (ResumeThread(_thread) != (DWORD)-1) - { - return; - } - } - WriteLog("Python Screen Renderer Thread Did Not Start"); - } -} - -void TPythonScreens::_cleanup() -{ - _cleanupReadyFlag = false; - for (std::vector::iterator i = _screens.begin(); i != _screens.end(); - ++i) - { - (*i)->cleanup(); - } -} - -void TPythonScreens::_freeTrainState() -{ - if (_trainState != NULL) - { - PyDict_Clear(_trainState); - Py_CLEAR(_trainState); - _trainState = NULL; - } -} diff --git a/PyInt.h b/PyInt.h index 93720d7c..1bf215b9 100644 --- a/PyInt.h +++ b/PyInt.h @@ -1,9 +1,13 @@ -#ifndef PyIntH -#define PyIntH +/* +This Source Code Form is subject to the +terms of the Mozilla Public License, v. +2.0. If a copy of the MPL was not +distributed with this file, You can +obtain one at +http://mozilla.org/MPL/2.0/. +*/ -#include -#include -#include +#pragma once #ifdef _DEBUG #undef _DEBUG // bez tego macra Py_DECREF powoduja problemy przy linkowaniu @@ -12,97 +16,70 @@ #else #include "Python.h" #endif -#include "parser.h" -#include "Model3d.h" +#include "Classes.h" #define PyGetFloat(param) PyFloat_FromDouble(param >= 0 ? param : -param) #define PyGetFloatS(param) PyFloat_FromDouble(param) #define PyGetInt(param) PyInt_FromLong(param) -#define PyGetFloatS(param) PyFloat_FromDouble(param) #define PyGetBool(param) param ? Py_True : Py_False #define PyGetString(param) PyString_FromString(param) -struct ltstr -{ - bool operator()(const char *s1, const char *s2) const - { - return strcmp(s1, s2) < 0; - } -}; +// TODO: extract common base and inherit specialization from it +class render_task { -class TPythonInterpreter -{ - protected: - TPythonInterpreter(); - ~TPythonInterpreter() {} - static TPythonInterpreter *_instance; - int _screenRendererPriority = 0; -// std::set _classes; - std::set _classes; - PyObject *_main; - PyObject *_stdErr; -// FILE *_getFile(const char *lookupPath, const char *className); - FILE *_getFile( std::string const &lookupPath, std::string const &className ); - - public: - static TPythonInterpreter *getInstance(); - static void killInstance(); -/* bool loadClassFile(const char *lookupPath, const char *className); - PyObject *newClass(const char *className); - PyObject *newClass(const char *className, PyObject *argsTuple); -*/ bool loadClassFile( std::string const &lookupPath, std::string const &className ); - PyObject *newClass( std::string const &className ); - PyObject *newClass( std::string const &className, PyObject *argsTuple ); - int getScreenRendererPriotity() - { - return _screenRendererPriority; - }; - void setScreenRendererPriority(const char *priority); - void handleError(); -}; - -class TPythonScreenRenderer -{ - protected: - PyObject *_pyRenderer; - PyObject *_pyTexture; - int _textureId; - PyObject *_pyWidth; - PyObject *_pyHeight; - - public: - TPythonScreenRenderer(int textureId, PyObject *renderer); - ~TPythonScreenRenderer(); - void render(PyObject *trainState); - void cleanup(); - void updateTexture(); -}; - -class TPythonScreens -{ - protected: - bool _cleanupReadyFlag; - bool _renderReadyFlag; - bool _terminationFlag; - void *_thread; - unsigned int _threadId; - std::vector _screens; - std::string _lookupPath; - void *_train; - void _cleanup(); - void _freeTrainState(); - PyObject *_trainState; - - public: - void reset(void *train); - void setLookupPath(std::string const &path); - void init(cParser &parser, TModel3d *model, std::string const &name, int const cab); - void update(); - TPythonScreens(); - ~TPythonScreens(); +public: +// constructors + render_task( PyObject *Renderer, PyObject *Input, material_handle Target ) : + m_renderer( Renderer ), m_input( Input ), m_target( Target ) + {} +// methods void run(); - void start(); - void finish(); + +private: +// members + PyObject *m_renderer {nullptr}; + PyObject *m_input { nullptr }; + material_handle m_target { null_handle }; }; -#endif // PyIntH +class python_taskqueue { + +public: +// types + struct task_request { + + std::string const &renderer; + PyObject *input; + material_handle target; + }; +// constructors + python_taskqueue() = default; +// methods + // initializes the module. returns true on success + auto init() -> bool; + // shuts down the module + void exit(); + // adds specified task along with provided collection of data to the work queue. returns true on success + auto insert( task_request const &Task ) -> bool; + // executes python script stored in specified file. returns true on success + auto run_file( std::string const &File, std::string const &Path = "" ) -> bool; + +private: +// types + static int const WORKERCOUNT { 1 }; + using worker_array = std::array, WORKERCOUNT >; + using rendertask_sequence = threading::lockable< std::deque >; +// methods + auto fetch_renderer( std::string const Renderer ) -> PyObject *; + void run( GLFWwindow *Context, rendertask_sequence &Tasks, threading::condition_variable &Condition, std::atomic &Exit ); + void error(); +// members + PyObject *m_main { nullptr }; + PyObject *m_error { nullptr }; + PyThreadState *m_mainthread{ nullptr }; + worker_array m_workers; + threading::condition_variable m_condition; // wakes up the workers + std::atomic m_exit { false }; // signals the workers to quit + std::unordered_map m_renderers; // cache of python classes + rendertask_sequence m_tasks; +}; diff --git a/ResourceManager.cpp b/ResourceManager.cpp index 412aa853..adbf4bf4 100644 --- a/ResourceManager.cpp +++ b/ResourceManager.cpp @@ -8,6 +8,8 @@ http://mozilla.org/MPL/2.0/. */ #include "stdafx.h" + +/* #include "ResourceManager.h" #include "Logs.h" @@ -18,7 +20,7 @@ double ResourceManager::_lastReport = 0.0f; void ResourceManager::Register(Resource *resource) { - _resources.push_back(resource); + _resources.emplace_back(resource); }; void ResourceManager::Unregister(Resource *resource) @@ -84,3 +86,4 @@ void ResourceManager::Sweep(double currentTime) _lastUpdate = currentTime; }; +*/ \ No newline at end of file diff --git a/ResourceManager.h b/ResourceManager.h index 93a73480..f75d8b43 100644 --- a/ResourceManager.h +++ b/ResourceManager.h @@ -7,55 +7,75 @@ obtain one at http://mozilla.org/MPL/2.0/. */ -#ifndef RESOURCEMANAGER_H -#define RESOURCEMANAGER_H 1 +#pragma once -#include -#include - -#pragma hdrstop - -class Resource -{ - - public: - virtual void Release() = 0; - double GetLastUsage() const - { - return _lastUsage; - } - - protected: - void SetLastUsage(double const lastUsage) - { - _lastUsage = lastUsage; - } - - private: - double _lastUsage = 0.0; +enum class resource_state { + none, + loading, + good, + failed }; -class ResourceManager -{ +using resource_timestamp = std::chrono::steady_clock::time_point; - public: - static void Register(Resource *resource); - static void Unregister(Resource *resource); +// takes containers providing access to specific element through operator[] +// with elements of std::pair +// the element should provide method release() freeing resources owned by the element +template +class garbage_collector { - static void Sweep(double currentTime); - static void SetExpiry(double expiry) - { - _expiry = expiry; - } +public: +// constructor: + garbage_collector( Container_ &Container, unsigned int const Secondstolive, std::size_t const Sweepsize, std::string const Resourcename = "resource" ) : + m_unusedresourcetimetolive{ std::chrono::seconds{ Secondstolive } }, + m_unusedresourcesweepsize{ Sweepsize }, + m_resourcename{ Resourcename }, + m_container{ Container } + {} - private: - typedef std::vector Resources; +// methods: + // performs resource sweep. returns: number of released resources + int + sweep() { + m_resourcetimestamp = std::chrono::steady_clock::now(); + // garbage collection sweep is limited to a number of records per call, to reduce impact on framerate + auto const sweeplastindex = + std::min( + m_resourcesweepindex + m_unusedresourcesweepsize, + m_container.size() ); + auto const blanktimestamp { std::chrono::steady_clock::time_point() }; + int releasecount{ 0 }; + for( auto resourceindex = m_resourcesweepindex; resourceindex < sweeplastindex; ++resourceindex ) { + if( ( m_container[ resourceindex ].second != blanktimestamp ) + && ( m_resourcetimestamp - m_container[ resourceindex ].second > m_unusedresourcetimetolive ) ) { - static double _expiry; - static double _lastUpdate; - static double _lastReport; + m_container[ resourceindex ].first->release(); + m_container[ resourceindex ].second = blanktimestamp; + ++releasecount; + } + } +/* + if( releasecount ) { + WriteLog( "Resource garbage sweep released " + std::to_string( releasecount ) + " " + ( releasecount == 1 ? m_resourcename : m_resourcename + "s" ) ); + } +*/ + m_resourcesweepindex = ( + m_resourcesweepindex + m_unusedresourcesweepsize >= m_container.size() ? + 0 : // if the next sweep chunk is beyond actual data, so start anew + m_resourcesweepindex + m_unusedresourcesweepsize ); + + return releasecount; } - static Resources _resources; + std::chrono::steady_clock::time_point + timestamp() const { + return m_resourcetimestamp; } + +private: +// members: + std::chrono::nanoseconds const m_unusedresourcetimetolive; + typename Container_::size_type const m_unusedresourcesweepsize; + std::string const m_resourcename; + Container_ &m_container; + typename Container_::size_type m_resourcesweepindex { 0 }; + std::chrono::steady_clock::time_point m_resourcetimestamp { std::chrono::steady_clock::now() }; }; - -#endif diff --git a/Segment.cpp b/Segment.cpp index daaf7356..92a3a9ca 100644 --- a/Segment.cpp +++ b/Segment.cpp @@ -9,39 +9,41 @@ http://mozilla.org/MPL/2.0/. #include "stdafx.h" #include "Segment.h" -#include "opengl/glew.h" #include "Globals.h" #include "Logs.h" -#include "Usefull.h" +#include "utilities.h" #include "Track.h" +#include "renderer.h" //--------------------------------------------------------------------------- -// 101206 Ra: trapezoidalne drogi -// 110806 Ra: odwrócone mapowanie wzdłuż - Point1 == 1.0 +void +segment_data::deserialize( cParser &Input, glm::dvec3 const &Offset ) { + + points[ segment_data::point::start ] = LoadPoint( Input ) + Offset; + Input.getTokens(); + Input >> rolls[ 0 ]; + points[ segment_data::point::control1 ] = LoadPoint( Input ); + points[ segment_data::point::control2 ] = LoadPoint( Input ); + points[ segment_data::point::end ] = LoadPoint( Input ) + Offset; + Input.getTokens( 2 ); + Input + >> rolls[ 1 ] + >> radius; +} -std::string Where(vector3 p) -{ // zamiana współrzędnych na tekst, używana w błędach - return std::to_string(p.x) + " " + std::to_string(p.y) + " " + std::to_string(p.z); -}; TSegment::TSegment(TTrack *owner) : - pOwner( owner ) -{ - fAngle[ 0 ] = 0.0; - fAngle[ 1 ] = 0.0; -}; + pOwner( owner ) +{} -TSegment::~TSegment() -{ - SafeDeleteArray(fTsBuffer); -}; - -bool TSegment::Init(vector3 NewPoint1, vector3 NewPoint2, double fNewStep, double fNewRoll1, - double fNewRoll2) +bool TSegment::Init(Math3D::vector3 NewPoint1, Math3D::vector3 NewPoint2, double fNewStep, double fNewRoll1, double fNewRoll2) { // wersja dla prostego - wyliczanie punktów kontrolnych - vector3 dir; + Math3D::vector3 dir; + + // NOTE: we're enforcing division also for straight track, to ensure dense enough mesh for per-vertex lighting +/* if (fNewRoll1 == fNewRoll2) { // faktyczny prosty dir = Normalize(NewPoint2 - NewPoint1); // wektor kierunku o długości 1 @@ -49,25 +51,27 @@ bool TSegment::Init(vector3 NewPoint1, vector3 NewPoint2, double fNewStep, doubl false); } else +*/ { // prosty ze zmienną przechyłką musi być segmentowany jak krzywe dir = (NewPoint2 - NewPoint1) / 3.0; // punkty kontrolne prostego są w 1/3 długości - return TSegment::Init(NewPoint1, NewPoint1 + dir, NewPoint2 - dir, NewPoint2, fNewStep, - fNewRoll1, fNewRoll2, true); + return TSegment::Init( + NewPoint1, NewPoint1 + dir, + NewPoint2 - dir, NewPoint2, + fNewStep, fNewRoll1, fNewRoll2, true); } }; -bool TSegment::Init(vector3 &NewPoint1, vector3 NewCPointOut, vector3 NewCPointIn, - vector3 &NewPoint2, double fNewStep, double fNewRoll1, double fNewRoll2, - bool bIsCurve) +bool TSegment::Init( Math3D::vector3 &NewPoint1, Math3D::vector3 NewCPointOut, Math3D::vector3 NewCPointIn, Math3D::vector3 &NewPoint2, double fNewStep, double fNewRoll1, double fNewRoll2, bool bIsCurve) { // wersja uniwersalna (dla krzywej i prostego) Point1 = NewPoint1; CPointOut = NewCPointOut; CPointIn = NewCPointIn; Point2 = NewPoint2; // poprawienie przechyłki - fRoll1 = DegToRad(fNewRoll1); // Ra: przeliczone jest bardziej przydatne do obliczeń - fRoll2 = DegToRad(fNewRoll2); - if (Global::bRollFix) + fRoll1 = glm::radians(fNewRoll1); // Ra: przeliczone jest bardziej przydatne do obliczeń + fRoll2 = glm::radians(fNewRoll2); + bCurve = bIsCurve; + if (Global.bRollFix) { // Ra: poprawianie przechyłki // Przechyłka powinna być na środku wewnętrznej szyny, a standardowo jest w osi // toru. Dlatego trzeba podnieść tor oraz odpowiednio podwyższyć podsypkę. @@ -78,25 +82,24 @@ bool TSegment::Init(vector3 &NewPoint1, vector3 NewCPointOut, vector3 NewCPointI // mieć moment wypoziomowania, ale musi on być również podniesiony. if (fRoll1 != 0.0) { // tylko jeśli jest przechyłka - double w1 = fabs(sin(fRoll1) * 0.75); // 0.5*w2+0.0325; //0.75m dla 1.435 + double w1 = std::abs(std::sin(fRoll1) * 0.75); // 0.5*w2+0.0325; //0.75m dla 1.435 Point1.y += w1; // modyfikacja musi być przed policzeniem dalszych parametrów if (bCurve) CPointOut.y += w1; // prosty ma wektory jednostkowe pOwner->MovedUp1(w1); // zwrócić trzeba informację o podwyższeniu podsypki } - if (fRoll2 != 0.0) + if (fRoll2 != 0.f) { - double w2 = fabs(sin(fRoll2) * 0.75); // 0.5*w2+0.0325; //0.75m dla 1.435 + double w2 = std::abs(std::sin(fRoll2) * 0.75); // 0.5*w2+0.0325; //0.75m dla 1.435 Point2.y += w2; // modyfikacja musi być przed policzeniem dalszych parametrów if (bCurve) CPointIn.y += w2; // prosty ma wektory jednostkowe // zwrócić trzeba informację o podwyższeniu podsypki } } + // kąt w planie, żeby nie liczyć wielokrotnie // Ra: ten kąt jeszcze do przemyślenia jest - fDirection = -atan2(Point2.x - Point1.x, - Point2.z - Point1.z); // kąt w planie, żeby nie liczyć wielokrotnie - bCurve = bIsCurve; + fDirection = -std::atan2(Point2.x - Point1.x, Point2.z - Point1.z); if (bCurve) { // przeliczenie współczynników wielomianu, będzie mniej mnożeń i można policzyć pochodne vC = 3.0 * (CPointOut - Point1); // t^1 @@ -104,50 +107,48 @@ bool TSegment::Init(vector3 &NewPoint1, vector3 NewCPointOut, vector3 NewCPointI vA = Point2 - Point1 - vC - vB; // t^3 fLength = ComputeLength(); } - else - fLength = (Point1 - Point2).Length(); + else { + fLength = ( Point1 - Point2 ).Length(); + } + if (fLength <= 0) { + + ErrorLog( "Bad track: zero length spline \"" + pOwner->name() + "\" (location: " + to_string( glm::dvec3{ Point1 } ) + ")" ); + fLength = 0.01; // crude workaround TODO: fix this properly + } + + fStoop = std::atan2((Point2.y - Point1.y), fLength); // pochylenie toru prostego, żeby nie liczyć wielokrotnie + fStep = fNewStep; - if (fLength <= 0) - { - ErrorLog("Bad geometry: Length <= 0 in TSegment::Init at " + Where(Point1)); - // MessageBox(0,"Length<=0","TSegment::Init",MB_OK); - return false; // zerowe nie mogą być + // NOTE: optionally replace this part with the commented version, after solving geometry issues with double switches + if( ( pOwner->eType == tt_Switch ) + && ( fStep * ( 3.0 * Global.SplineFidelity ) > fLength ) ) { + // NOTE: a workaround for too short switches (less than 3 segments) messing up animation/generation of blades + fStep = fLength / ( 3.0 * Global.SplineFidelity ); } - fStoop = atan2((Point2.y - Point1.y), - fLength); // pochylenie toru prostego, żeby nie liczyć wielokrotnie - SafeDeleteArray(fTsBuffer); - if ((bCurve) && (fStep > 0)) - { // Ra: prosty dostanie podział, jak ma różną przechyłkę na końcach - double s = 0; - int i = 0; - iSegCount = ceil(fLength / fStep); // potrzebne do VBO - // fStep=fLength/(double)(iSegCount-1); //wyrównanie podziału - fTsBuffer = new double[iSegCount + 1]; - fTsBuffer[0] = 0; /* TODO : fix fTsBuffer */ - while (s < fLength) - { - i++; - s += fStep; - if (s > fLength) - s = fLength; - fTsBuffer[i] = GetTFromS(s); - } - } - if (fLength > 500) - { // tor ma pojemność 40 pojazdów, więc nie może być za długi - ErrorLog("Bad geometry: Length > 500m at " + Where(Point1)); - // MessageBox(0,"Length>500","TSegment::Init",MB_OK); - return false; +// iSegCount = static_cast( std::ceil( fLength / fStep ) ); // potrzebne do VBO + iSegCount = ( + pOwner->eType == tt_Switch ? + 6 * Global.SplineFidelity : + static_cast( std::ceil( fLength / fStep ) ) ); // potrzebne do VBO + + fStep = fLength / iSegCount; // update step to equalize size of individual pieces + + fTsBuffer.resize( iSegCount + 1 ); + fTsBuffer[ 0 ] = 0.0; + for( int i = 1; i < iSegCount; ++i ) { + fTsBuffer[ i ] = GetTFromS( i * fStep ); } + fTsBuffer[ iSegCount ] = 1.0; + return true; } -vector3 TSegment::GetFirstDerivative(double fTime) +Math3D::vector3 TSegment::GetFirstDerivative(double const fTime) const { double fOmTime = 1.0 - fTime; double fPowTime = fTime; - vector3 kResult = fOmTime * (CPointOut - Point1); + Math3D::vector3 kResult = fOmTime * (CPointOut - Point1); // int iDegreeM1 = 3 - 1; @@ -161,7 +162,7 @@ vector3 TSegment::GetFirstDerivative(double fTime) return kResult; } -double TSegment::RombergIntegral(double fA, double fB) +double TSegment::RombergIntegral(double const fA, double const fB) const { double fH = fB - fA; @@ -193,21 +194,20 @@ double TSegment::RombergIntegral(double fA, double fB) return ms_apfRom[0][ms_iOrder - 1]; } -double TSegment::GetTFromS(double s) +double TSegment::GetTFromS(double const s) const { // initial guess for Newton's method double fTolerance = 0.001; double fRatio = s / RombergIntegral(0, 1); - double fOmRatio = 1.0 - fRatio; - double fTime = fOmRatio * 0 + fRatio * 1; - int iteration = 0; + double fTime = interpolate( 0.0, 1.0, fRatio ); + int iteration = 0; + double fDifference {}; // exposed for debug down the road do { - double fDifference = RombergIntegral(0, fTime) - s; - if( ( fDifference > 0 ? fDifference : -fDifference ) < fTolerance ) { + fDifference = RombergIntegral(0, fTime) - s; + if( std::abs( fDifference ) < fTolerance ) { return fTime; } - fTime -= fDifference / GetFirstDerivative(fTime).Length(); ++iteration; } @@ -216,46 +216,88 @@ double TSegment::GetTFromS(double s) // Newton's method failed. If this happens, increase iterations or // tolerance or integration accuracy. // return -1; //Ra: tu nigdy nie dojdzie - ErrorLog( "Bad geometry: Too many iterations at " + Where( Point1 ) ); + ErrorLog( "Bad track: shape estimation failed for spline \"" + pOwner->name() + "\" (location: " + to_string( glm::dvec3{ Point1 } ) + ")" ); // MessageBox(0,"Too many iterations","GetTFromS",MB_OK); return fTime; }; -vector3 TSegment::RaInterpolate(double t) +Math3D::vector3 TSegment::RaInterpolate(double const t) const { // wyliczenie XYZ na krzywej Beziera z użyciem współczynników return t * (t * (t * vA + vB) + vC) + Point1; // 9 mnożeń, 9 dodawań }; -vector3 TSegment::RaInterpolate0(double t) +Math3D::vector3 TSegment::RaInterpolate0(double const t) const { // wyliczenie XYZ na krzywej Beziera, na użytek liczenia długości nie jest dodawane Point1 return t * (t * (t * vA + vB) + vC); // 9 mnożeń, 6 dodawań }; -double TSegment::ComputeLength() // McZapkie-150503: dlugosc miedzy punktami krzywej +double TSegment::ComputeLength() const // McZapkie-150503: dlugosc miedzy punktami krzywej { // obliczenie długości krzywej Beziera za pomocą interpolacji odcinkami // Ra: zamienić na liczenie rekurencyjne średniej z cięciwy i łamanej po kontrolnych // Ra: koniec rekurencji jeśli po podziale suma długości nie różni się więcej niż 0.5mm od // poprzedniej // Ra: ewentualnie rozpoznać łuk okręgu płaskiego i liczyć ze wzoru na długość łuku double t, l = 0; - vector3 last = vector3(0, 0, 0); // długość liczona po przesunięciu odcinka do początku układu - vector3 tmp = Point2 - Point1; + Math3D::vector3 last = Math3D::vector3(0, 0, 0); // długość liczona po przesunięciu odcinka do początku układu + Math3D::vector3 tmp = Point2 - Point1; int m = 20.0 * tmp.Length(); // było zawsze do 10000, teraz jest liczone odcinkami po około 5cm for (int i = 1; i <= m; i++) { t = double(i) / double(m); // wyznaczenie parametru na krzywej z przedziału (0,1> // tmp=Interpolate(t,p1,cp1,cp2,p2); tmp = RaInterpolate0(t); // obliczenie punktu dla tego parametru - t = vector3(tmp - last).Length(); // obliczenie długości wektora + t = Math3D::vector3(tmp - last).Length(); // obliczenie długości wektora l += t; // zwiększenie wyliczanej długości last = tmp; } return (l); } +// finds point on segment closest to specified point in 3d space. returns: point on segment as value in range 0-1 +double +TSegment::find_nearest_point( glm::dvec3 const &Point ) const { + + if( ( false == bCurve ) || ( iSegCount == 1 ) ) { + // for straight track just treat it as a single segment + return + nearest_segment_point( + glm::dvec3{ FastGetPoint_0() }, + glm::dvec3{ FastGetPoint_1() }, + Point ); + } + else { + // for curves iterate through segment chunks, and find the one which gives us the least distance to the specified point + double distance = std::numeric_limits::max(); + double nearest; + // NOTE: we're reusing already created segment chunks, which are created based on splinefidelity setting + // this means depending on splinefidelity the results can be potentially slightly different + for( int segmentidx = 0; segmentidx < iSegCount; ++segmentidx ) { + + auto const segmentpoint = + clamp( + nearest_segment_point( + glm::dvec3{ FastGetPoint( fTsBuffer[ segmentidx ] ) }, + glm::dvec3{ FastGetPoint( fTsBuffer[ segmentidx + 1 ] ) }, + Point ) // point in range 0-1 on current segment + * ( fTsBuffer[ segmentidx + 1 ] - fTsBuffer[ segmentidx ] ) // segment length + + fTsBuffer[ segmentidx ], // segment offset + 0.0, 1.0 ); // we clamp the range in case there's some floating point math inaccuracies + + auto const segmentdistance = glm::length2( Point - glm::dvec3{ FastGetPoint( segmentpoint ) } ); + if( segmentdistance < distance ) { + + nearest = segmentpoint; + distance = segmentdistance; + } + } + // + return nearest; + } +} + const double fDirectionOffset = 0.1; // długość wektora do wyliczenia kierunku -vector3 TSegment::GetDirection(double fDistance) +Math3D::vector3 TSegment::GetDirection(double const fDistance) const { // takie toporne liczenie pochodnej dla podanego dystansu od Point1 double t1 = GetTFromS(fDistance - fDirectionOffset); if (t1 <= 0.0) @@ -266,7 +308,7 @@ vector3 TSegment::GetDirection(double fDistance) return (FastGetPoint(t2) - FastGetPoint(t1)); } -vector3 TSegment::FastGetDirection(double fDistance, double fOffset) +Math3D::vector3 TSegment::FastGetDirection(double fDistance, double fOffset) { // takie toporne liczenie pochodnej dla parametru 0.0÷1.0 double t1 = fDistance - fOffset; if (t1 <= 0.0) @@ -276,8 +318,8 @@ vector3 TSegment::FastGetDirection(double fDistance, double fOffset) return (Point2 - CPointIn); // wektor na końcu jest stały return (FastGetPoint(t2) - FastGetPoint(t1)); } - -vector3 TSegment::GetPoint(double fDistance) +/* +Math3D::vector3 TSegment::GetPoint(double const fDistance) const { // wyliczenie współrzędnych XYZ na torze w odległości (fDistance) od Point1 if (bCurve) { // można by wprowadzić uproszczony wzór dla okręgów płaskich @@ -285,364 +327,206 @@ vector3 TSegment::GetPoint(double fDistance) // return Interpolate(t,Point1,CPointOut,CPointIn,Point2); return RaInterpolate(t); } - else - { // wyliczenie dla odcinka prostego jest prostsze - double t = fDistance / fLength; // zerowych torów nie ma - return ((1.0 - t) * Point1 + (t)*Point2); + else { + // wyliczenie dla odcinka prostego jest prostsze + return + interpolate( + Point1, Point2, + clamp( + fDistance / fLength, + 0.0, 1.0 ) ); } }; +*/ +// ustalenie pozycji osi na torze, przechyłki, pochylenia i kierunku jazdy +void TSegment::RaPositionGet(double const fDistance, Math3D::vector3 &p, Math3D::vector3 &a) const { -void TSegment::RaPositionGet(double fDistance, vector3 &p, vector3 &a) -{ // ustalenie pozycji osi na torze, przechyłki, pochylenia i kierunku jazdy - if (bCurve) - { // można by wprowadzić uproszczony wzór dla okręgów płaskich - double t = GetTFromS(fDistance); // aproksymacja dystansu na krzywej Beziera na parametr (t) - p = RaInterpolate(t); - a.x = (1.0 - t) * fRoll1 + (t)*fRoll2; // przechyłka w danym miejscu (zmienia się liniowo) + if (bCurve) { + // można by wprowadzić uproszczony wzór dla okręgów płaskich + auto const t = GetTFromS(fDistance); // aproksymacja dystansu na krzywej Beziera na parametr (t) + p = FastGetPoint( t ); + // przechyłka w danym miejscu (zmienia się liniowo) + a.x = interpolate( fRoll1, fRoll2, t ); // pochodna jest 3*A*t^2+2*B*t+C - a.y = atan(t * (t * 3.0 * vA.y + vB.y + vB.y) + vC.y); // pochylenie krzywej (w pionie) - a.z = -atan2(t * (t * 3.0 * vA.x + vB.x + vB.x) + vC.x, - t * (t * 3.0 * vA.z + vB.z + vB.z) + vC.z); // kierunek krzywej w planie + auto const tangent = t * ( t * 3.0 * vA + vB + vB ) + vC; + // pochylenie krzywej (w pionie) + a.y = std::atan( tangent.y ); + // kierunek krzywej w planie + a.z = -std::atan2( tangent.x, tangent.z ); } - else - { // wyliczenie dla odcinka prostego jest prostsze - double t = fDistance / fLength; // zerowych torów nie ma - p = ((1.0 - t) * Point1 + (t)*Point2); - a.x = (1.0 - t) * fRoll1 + (t)*fRoll2; // przechyłka w danym miejscu (zmienia się liniowo) + else { + // wyliczenie dla odcinka prostego jest prostsze + auto const t = fDistance / fLength; // zerowych torów nie ma + p = FastGetPoint( t ); + // przechyłka w danym miejscu (zmienia się liniowo) + a.x = interpolate( fRoll1, fRoll2, t ); a.y = fStoop; // pochylenie toru prostego a.z = fDirection; // kierunek toru w planie } }; -vector3 TSegment::FastGetPoint(double t) +Math3D::vector3 TSegment::FastGetPoint(double const t) const { // return (bCurve?Interpolate(t,Point1,CPointOut,CPointIn,Point2):((1.0-t)*Point1+(t)*Point2)); - return (bCurve ? RaInterpolate(t) : ((1.0 - t) * Point1 + (t)*Point2)); + return ( + ( ( true == bCurve ) || ( iSegCount != 1 ) ) ? + RaInterpolate( t ) : + interpolate( Point1, Point2, t ) ); } -void TSegment::RenderLoft(const vector6 *ShapePoints, int iNumShapePoints, double fTextureLength, - int iSkip, int iQualityFactor, vector3 **p, bool bRender) +bool TSegment::RenderLoft( gfx::vertex_array &Output, Math3D::vector3 const &Origin, const gfx::vertex_array &ShapePoints, int iNumShapePoints, double fTextureLength, double Texturescale, int iSkip, int iEnd, float fOffsetX, glm::vec3 **p, bool bRender) { // generowanie trójkątów dla odcinka trajektorii ruchu // standardowo tworzy triangle_strip dla prostego albo ich zestaw dla łuku // po modyfikacji - dla ujemnego (iNumShapePoints) w dodatkowych polach tabeli // podany jest przekrój końcowy // podsypka toru jest robiona za pomocą 6 punktów, szyna 12, drogi i rzeki na 3+2+3 - if (iQualityFactor < 1) - iQualityFactor = 1; // co który segment ma być uwzględniony - vector3 pos1, pos2, dir, parallel1, parallel2, pt, norm; - double s, step, fOffset, tv1, tv2, t; - int i, j; - bool trapez = iNumShapePoints < 0; // sygnalizacja trapezowatości - iNumShapePoints = abs(iNumShapePoints); - if (bCurve) - { - double m1, jmm1, m2, jmm2; // pozycje względne na odcinku 0...1 (ale nie parametr Beziera) - tv1 = 1.0; // Ra: to by można było wyliczać dla odcinka, wyglądało by lepiej - step = fStep * iQualityFactor; - s = fStep * iSkip; // iSkip - ile odcinków z początku pominąć - i = iSkip; // domyślnie 0 - if (!fTsBuffer) - return; // prowizoryczne zabezpieczenie przed wysypem - ustalić faktyczną przyczynę - if (i > iSegCount) - return; // prowizoryczne zabezpieczenie przed wysypem - ustalić faktyczną przyczynę - t = fTsBuffer[i]; // tabela watości t dla segmentów - fOffset = 0.1 / fLength; // pierwsze 10cm - pos1 = FastGetPoint(t); // wektor początku segmentu - dir = FastGetDirection(t, fOffset); // wektor kierunku - // parallel1=Normalize(CrossProduct(dir,vector3(0,1,0))); //wektor poprzeczny - parallel1 = Normalize(vector3(-dir.z, 0.0, dir.x)); // wektor poprzeczny - m2 = s / fLength; - jmm2 = 1.0 - m2; - while (s < fLength) - { - // step=SquareMagnitude(Global::GetCameraPosition()+pos); - i += iQualityFactor; // kolejny punkt łamanej - s += step; // końcowa pozycja segmentu [m] - m1 = m2; - jmm1 = jmm2; // stara pozycja - m2 = s / fLength; - jmm2 = 1.0 - m2; // nowa pozycja - if (s > fLength - 0.5) // Ra: -0.5 żeby nie robiło cieniasa na końcu - { // gdy przekroczyliśmy koniec - stąd dziury w torach... - step -= (s - fLength); // jeszcze do wyliczenia mapowania potrzebny - s = fLength; - i = iSegCount; // 20/5 ma dawać 4 - m2 = 1.0; - jmm2 = 0.0; - } - while (tv1 < 0.0) - tv1 += 1.0; // przestawienie mapowania - tv2 = tv1 - step / fTextureLength; // mapowanie na końcu segmentu - t = fTsBuffer[i]; // szybsze od GetTFromS(s); - pos2 = FastGetPoint(t); - dir = FastGetDirection(t, fOffset); // nowy wektor kierunku - // parallel2=CrossProduct(dir,vector3(0,1,0)); //wektor poprzeczny - parallel2 = Normalize(vector3(-dir.z, 0.0, dir.x)); // wektor poprzeczny - glBegin(GL_TRIANGLE_STRIP); - if (trapez) - for (j = 0; j < iNumShapePoints; j++) - { - norm = (jmm1 * ShapePoints[j].n.x + m1 * ShapePoints[j + iNumShapePoints].n.x) * - parallel1; - norm.y += jmm1 * ShapePoints[j].n.y + m1 * ShapePoints[j + iNumShapePoints].n.y; - pt = parallel1 * - (jmm1 * ShapePoints[j].x + m1 * ShapePoints[j + iNumShapePoints].x) + - pos1; - pt.y += jmm1 * ShapePoints[j].y + m1 * ShapePoints[j + iNumShapePoints].y; - if (bRender) - { // skrzyżowania podczas łączenia siatek mogą nie renderować poboczy, ale - // potrzebować punktów - glNormal3f(norm.x, norm.y, norm.z); - glTexCoord2f( - jmm1 * ShapePoints[j].z + m1 * ShapePoints[j + iNumShapePoints].z, tv1); - glVertex3f(pt.x, pt.y, pt.z); // pt nie mamy gdzie zapamiętać? - } - if (p) // jeśli jest wskaźnik do tablicy - if (*p) - if (!j) // to dla pierwszego punktu - { - *(*p) = pt; - (*p)++; + + if( fTsBuffer.empty() ) + return false; // prowizoryczne zabezpieczenie przed wysypem - ustalić faktyczną przyczynę + + glm::vec3 pos1, pos2, dir, parallel1, parallel2, pt, norm; + float s, step, fOffset, tv1, tv2, t, fEnd; + bool const trapez = iNumShapePoints < 0; // sygnalizacja trapezowatości + iNumShapePoints = std::abs( iNumShapePoints ); + float const texturelength = fTextureLength * Texturescale; + float const texturescale = Texturescale; + + float m1, jmm1, m2, jmm2; // pozycje względne na odcinku 0...1 (ale nie parametr Beziera) + step = fStep; + tv1 = 1.0; // Ra: to by można było wyliczać dla odcinka, wyglądało by lepiej + s = fStep * iSkip; // iSkip - ile odcinków z początku pominąć + int i = iSkip; // domyślnie 0 + t = fTsBuffer[ i ]; // tabela wattości t dla segmentów + // BUG: length of spline can be 0, we should skip geometry generation for such cases + fOffset = 0.1 / fLength; // pierwsze 10cm + pos1 = glm::dvec3{ FastGetPoint( t ) - Origin }; // wektor początku segmentu + dir = glm::dvec3{ FastGetDirection( t, fOffset ) }; // wektor kierunku + parallel1 = glm::vec3{ -dir.z, 0.f, dir.x }; // wektor poprzeczny + if( glm::length2( parallel1 ) == 0.f ) { + // temporary workaround for malformed situations with control points placed above endpoints + parallel1 = glm::vec3{ glm::dvec3{ FastGetPoint_1() - FastGetPoint_0() } }; + } + parallel1 = glm::normalize( parallel1 ); + if( iEnd == 0 ) + iEnd = iSegCount; + fEnd = fLength * double( iEnd ) / double( iSegCount ); + m2 = s / fEnd; + jmm2 = 1.0 - m2; + + while( i < iEnd ) { + + ++i; // kolejny punkt łamanej + s += step; // końcowa pozycja segmentu [m] + m1 = m2; + jmm1 = jmm2; // stara pozycja + m2 = s / fEnd; + jmm2 = 1.0 - m2; // nowa pozycja + if( i == iEnd ) { // gdy przekroczyliśmy koniec - stąd dziury w torach... + step -= ( s - fEnd ); // jeszcze do wyliczenia mapowania potrzebny + s = fEnd; + m2 = 1.0; + jmm2 = 0.0; + } + + while( tv1 < 0.0 ) { + tv1 += 1.0; + } + tv2 = tv1 - step / texturelength; // mapowanie na końcu segmentu + + t = fTsBuffer[ i ]; // szybsze od GetTFromS(s); + pos2 = glm::dvec3{ FastGetPoint( t ) - Origin }; + dir = glm::dvec3{ FastGetDirection( t, fOffset ) }; // nowy wektor kierunku + parallel2 = glm::vec3{ -dir.z, 0.f, dir.x }; // wektor poprzeczny + if( glm::length2( parallel2 ) == 0.f ) { + // temporary workaround for malformed situations with control points placed above endpoints + parallel2 = glm::vec3{ glm::dvec3{ FastGetPoint_1() - FastGetPoint_0() } }; + } + parallel2 = glm::normalize( parallel2 ); + + if( trapez ) { + for( int j = 0; j < iNumShapePoints; ++j ) { + pt = parallel1 * ( jmm1 * ( ShapePoints[ j ].position.x - fOffsetX ) + m1 * ShapePoints[ j + iNumShapePoints ].position.x ) + pos1; + pt.y += jmm1 * ShapePoints[ j ].position.y + m1 * ShapePoints[ j + iNumShapePoints ].position.y; +// pt -= Origin; + norm = ( jmm1 * ShapePoints[ j ].normal.x + m1 * ShapePoints[ j + iNumShapePoints ].normal.x ) * parallel1; + norm.y += jmm1 * ShapePoints[ j ].normal.y + m1 * ShapePoints[ j + iNumShapePoints ].normal.y; + if( bRender ) { + // skrzyżowania podczas łączenia siatek mogą nie renderować poboczy, ale potrzebować punktów + Output.emplace_back( + pt, + glm::normalize( norm ), + glm::vec2 { ( jmm1 * ShapePoints[ j ].texture.x + m1 * ShapePoints[ j + iNumShapePoints ].texture.x ) / texturescale, tv1 } ); + } + if( p ) // jeśli jest wskaźnik do tablicy + if( *p ) + if( !j ) // to dla pierwszego punktu + { + *( *p ) = pt; + ( *p )++; + } // zapamiętanie brzegu jezdni + // dla trapezu drugi koniec ma inne współrzędne + pt = parallel2 * ( jmm2 * ( ShapePoints[ j ].position.x - fOffsetX ) + m2 * ShapePoints[ j + iNumShapePoints ].position.x ) + pos2; + pt.y += jmm2 * ShapePoints[ j ].position.y + m2 * ShapePoints[ j + iNumShapePoints ].position.y; +// pt -= Origin; + norm = ( jmm1 * ShapePoints[ j ].normal.x + m1 * ShapePoints[ j + iNumShapePoints ].normal.x ) * parallel2; + norm.y += jmm1 * ShapePoints[ j ].normal.y + m1 * ShapePoints[ j + iNumShapePoints ].normal.y; + if( bRender ) { + // skrzyżowania podczas łączenia siatek mogą nie renderować poboczy, ale potrzebować punktów + Output.emplace_back( + pt, + glm::normalize( norm ), + glm::vec2 { ( jmm2 * ShapePoints[ j ].texture.x + m2 * ShapePoints[ j + iNumShapePoints ].texture.x ) / texturescale, tv2 } ); + } + if( p ) // jeśli jest wskaźnik do tablicy + if( *p ) + if( !j ) // to dla pierwszego punktu + if( i == iSegCount ) { + *( *p ) = pt; + ( *p )++; } // zapamiętanie brzegu jezdni - // dla trapezu drugi koniec ma inne współrzędne - norm = (jmm1 * ShapePoints[j].n.x + m1 * ShapePoints[j + iNumShapePoints].n.x) * - parallel2; - norm.y += jmm1 * ShapePoints[j].n.y + m1 * ShapePoints[j + iNumShapePoints].n.y; - pt = parallel2 * - (jmm2 * ShapePoints[j].x + m2 * ShapePoints[j + iNumShapePoints].x) + - pos2; - pt.y += jmm2 * ShapePoints[j].y + m2 * ShapePoints[j + iNumShapePoints].y; - if (bRender) - { // skrzyżowania podczas łączenia siatek mogą nie renderować poboczy, ale - // potrzebować punktów - glNormal3f(norm.x, norm.y, norm.z); - glTexCoord2f( - jmm2 * ShapePoints[j].z + m2 * ShapePoints[j + iNumShapePoints].z, tv2); - glVertex3f(pt.x, pt.y, pt.z); - } - if (p) // jeśli jest wskaźnik do tablicy - if (*p) - if (!j) // to dla pierwszego punktu - if (i == iSegCount) - { - *(*p) = pt; - (*p)++; - } // zapamiętanie brzegu jezdni + } + } + else { + if( bRender ) { + for( int j = 0; j < iNumShapePoints; ++j ) { + //łuk z jednym profilem + pt = parallel1 * ( ShapePoints[ j ].position.x - fOffsetX ) + pos1; + pt.y += ShapePoints[ j ].position.y; +// pt -= Origin; + norm = ShapePoints[ j ].normal.x * parallel1; + norm.y += ShapePoints[ j ].normal.y; + + Output.emplace_back( + pt, + glm::normalize( norm ), + glm::vec2 { ShapePoints[ j ].texture.x / texturescale, tv1 } ); + + pt = parallel2 * ShapePoints[ j ].position.x + pos2; + pt.y += ShapePoints[ j ].position.y; +// pt -= Origin; + norm = ShapePoints[ j ].normal.x * parallel2; + norm.y += ShapePoints[ j ].normal.y; + + Output.emplace_back( + pt, + glm::normalize( norm ), + glm::vec2 { ShapePoints[ j ].texture.x / texturescale, tv2 } ); } - else - for (j = 0; j < iNumShapePoints; j++) - { //łuk z jednym profilem - norm = ShapePoints[j].n.x * parallel1; - norm.y += ShapePoints[j].n.y; - pt = parallel1 * ShapePoints[j].x + pos1; - pt.y += ShapePoints[j].y; - glNormal3f(norm.x, norm.y, norm.z); - glTexCoord2f(ShapePoints[j].z, tv1); - glVertex3f(pt.x, pt.y, pt.z); // punkt na początku odcinka - norm = ShapePoints[j].n.x * parallel2; - norm.y += ShapePoints[j].n.y; - pt = parallel2 * ShapePoints[j].x + pos2; - pt.y += ShapePoints[j].y; - glNormal3f(norm.x, norm.y, norm.z); - glTexCoord2f(ShapePoints[j].z, tv2); - glVertex3f(pt.x, pt.y, pt.z); // punkt na końcu odcinka - } - glEnd(); - pos1 = pos2; - parallel1 = parallel2; - tv1 = tv2; + } } + pos1 = pos2; + parallel1 = parallel2; + tv1 = tv2; } - else - { // gdy prosty, nie modyfikujemy wektora kierunkowego i poprzecznego - pos1 = FastGetPoint((fStep * iSkip) / fLength); - pos2 = FastGetPoint_1(); - dir = GetDirection(); - // parallel1=Normalize(CrossProduct(dir,vector3(0,1,0))); - parallel1 = Normalize(vector3(-dir.z, 0.0, dir.x)); // wektor poprzeczny - glBegin(GL_TRIANGLE_STRIP); - if (trapez) - for (j = 0; j < iNumShapePoints; j++) - { - norm = ShapePoints[j].n.x * parallel1; - norm.y += ShapePoints[j].n.y; - pt = parallel1 * ShapePoints[j].x + pos1; - pt.y += ShapePoints[j].y; - glNormal3f(norm.x, norm.y, norm.z); - glTexCoord2f(ShapePoints[j].z, 0); - glVertex3f(pt.x, pt.y, pt.z); - // dla trapezu drugi koniec ma inne współrzędne względne - norm = ShapePoints[j + iNumShapePoints].n.x * parallel1; - norm.y += ShapePoints[j + iNumShapePoints].n.y; - pt = parallel1 * ShapePoints[j + iNumShapePoints].x + pos2; // odsunięcie - pt.y += ShapePoints[j + iNumShapePoints].y; // wysokość - glNormal3f(norm.x, norm.y, norm.z); - glTexCoord2f(ShapePoints[j + iNumShapePoints].z, fLength / fTextureLength); - glVertex3f(pt.x, pt.y, pt.z); - } - else - for (j = 0; j < iNumShapePoints; j++) - { - norm = ShapePoints[j].n.x * parallel1; - norm.y += ShapePoints[j].n.y; - pt = parallel1 * ShapePoints[j].x + pos1; - pt.y += ShapePoints[j].y; - glNormal3f(norm.x, norm.y, norm.z); - glTexCoord2f(ShapePoints[j].z, 0); - glVertex3f(pt.x, pt.y, pt.z); - pt = parallel1 * ShapePoints[j].x + pos2; - pt.y += ShapePoints[j].y; - glNormal3f(norm.x, norm.y, norm.z); - glTexCoord2f(ShapePoints[j].z, fLength / fTextureLength); - glVertex3f(pt.x, pt.y, pt.z); - } - glEnd(); - } + return true; }; - -void TSegment::RenderSwitchRail(const vector6 *ShapePoints1, const vector6 *ShapePoints2, - int iNumShapePoints, double fTextureLength, int iSkip, - double fOffsetX) -{ // tworzenie siatki trójkątów dla iglicy - vector3 pos1, pos2, dir, parallel1, parallel2, pt; - double a1, a2, s, step, offset, tv1, tv2, t, t2, t2step, oldt2, sp, oldsp; - int i, j; - if (bCurve) - { // dla toru odchylonego - // t2= 0; - t2step = 1 / double(iSkip); // przesunięcie tekstury? - oldt2 = 1; - tv1 = 1.0; - step = fStep; // długść segmentu - s = 0; - i = 0; - t = fTsBuffer[i]; // wartość t krzywej Beziera dla początku - a1 = 0; - // step= fStep/fLength; - offset = 0.1 / fLength; // około 10cm w sensie parametru t - pos1 = FastGetPoint(t); // współrzędne dla parmatru t - // dir= GetDirection1(); - dir = FastGetDirection(t, offset); // wektor wzdłużny - // parallel1=Normalize(CrossProduct(dir,vector3(0,1,0))); //poprzeczny? - parallel1 = Normalize(vector3(-dir.z, 0.0, dir.x)); // wektor poprzeczny - - while (s < fLength && i < iSkip) - { - // step= SquareMagnitude(Global::GetCameraPosition()+pos); - // t2= oldt2+t2step; - i++; - s += step; - - if (s > fLength) - { - step -= (s - fLength); - s = fLength; - } - - while (tv1 < 0.0) - tv1 += 1.0; - tv2 = tv1 - step / fTextureLength; - - t = fTsBuffer[i]; - pos2 = FastGetPoint(t); - dir = FastGetDirection(t, offset); - // parallel2=Normalize(CrossProduct(dir,vector3(0,1,0))); - parallel2 = Normalize(vector3(-dir.z, 0.0, dir.x)); // wektor poprzeczny - - a2 = double(i) / (iSkip); - glBegin(GL_TRIANGLE_STRIP); - for (j = 0; j < iNumShapePoints; j++) - { // po dwa punkty trapezu - pt = parallel1 * - (ShapePoints1[j].x * a1 + (ShapePoints2[j].x - fOffsetX) * (1.0 - a1)) + - pos1; - pt.y += ShapePoints1[j].y * a1 + ShapePoints2[j].y * (1.0 - a1); - glNormal3f(0.0f, 1.0f, 0.0f); - glTexCoord2f(ShapePoints1[j].z * a1 + ShapePoints2[j].z * (1.0 - a1), tv1); - glVertex3f(pt.x, pt.y, pt.z); - - pt = parallel2 * - (ShapePoints1[j].x * a2 + (ShapePoints2[j].x - fOffsetX) * (1.0 - a2)) + - pos2; - pt.y += ShapePoints1[j].y * a2 + ShapePoints2[j].y * (1.0 - a2); - glNormal3f(0.0f, 1.0f, 0.0f); - glTexCoord2f(ShapePoints1[j].z * a2 + ShapePoints2[j].z * (1.0 - a2), tv2); - glVertex3f(pt.x, pt.y, pt.z); - } - glEnd(); - pos1 = pos2; - parallel1 = parallel2; - tv1 = tv2; - a1 = a2; - } - } - else - { // dla toru prostego - tv1 = 1.0; - s = 0; - i = 0; - // pos1= FastGetPoint( (5*iSkip)/fLength ); - pos1 = FastGetPoint_0(); - dir = GetDirection(); - // parallel1=CrossProduct(dir,vector3(0,1,0)); - parallel1 = Normalize(vector3(-dir.z, 0.0, dir.x)); // wektor poprzeczny - - step = 5; - a1 = 0; - - while (i < iSkip) - { - // step= SquareMagnitude(Global::GetCameraPosition()+pos); - i++; - s += step; - - if (s > fLength) - { - step -= (s - fLength); - s = fLength; - } - - while (tv1 < 0.0) - tv1 += 1.0; - - tv2 = tv1 - step / fTextureLength; - - t = s / fLength; - pos2 = FastGetPoint(t); - - a2 = double(i) / (iSkip); - glBegin(GL_TRIANGLE_STRIP); - for (j = 0; j < iNumShapePoints; j++) - { - pt = parallel1 * - (ShapePoints1[j].x * a1 + (ShapePoints2[j].x - fOffsetX) * (1.0 - a1)) + - pos1; - pt.y += ShapePoints1[j].y * a1 + ShapePoints2[j].y * (1.0 - a1); - glNormal3f(0.0f, 1.0f, 0.0f); - glTexCoord2f((ShapePoints1[j].z), tv1); - glVertex3f(pt.x, pt.y, pt.z); - - pt = parallel1 * - (ShapePoints1[j].x * a2 + (ShapePoints2[j].x - fOffsetX) * (1.0 - a2)) + - pos2; - pt.y += ShapePoints1[j].y * a2 + ShapePoints2[j].y * (1.0 - a2); - glNormal3f(0.0f, 1.0f, 0.0f); - glTexCoord2f(ShapePoints2[j].z, tv2); - glVertex3f(pt.x, pt.y, pt.z); - } - glEnd(); - pos1 = pos2; - tv1 = tv2; - a1 = a2; - } - } -}; - +/* +// NOTE: legacy leftover, potentially usable (but not really) void TSegment::Render() { - vector3 pt; - TextureManager.Bind(0); - int i; + Math3D::vector3 pt; + GfxRenderer.Bind_Material( null_handle ); + if (bCurve) { glColor3f(0, 0, 1.0f); @@ -685,301 +569,5 @@ void TSegment::Render() glEnd(); } } - -void TSegment::RaRenderLoft(CVertNormTex *&Vert, const vector6 *ShapePoints, int iNumShapePoints, - double fTextureLength, int iSkip, int iEnd, double fOffsetX) -{ // generowanie trójkątów dla odcinka trajektorii ruchu - // standardowo tworzy triangle_strip dla prostego albo ich zestaw dla łuku - // po modyfikacji - dla ujemnego (iNumShapePoints) w dodatkowych polach tabeli - // podany jest przekrój końcowy - // podsypka toru jest robiona za pomocą 6 punktów, szyna 12, drogi i rzeki na 3+2+3 - // na użytek VBO strip dla łuków jest tworzony wzdłuż - // dla skróconego odcinka (iEndnx = norm.x; // niekoniecznie tak - Vert->ny = norm.y; - Vert->nz = norm.z; - Vert->u = jmm1 * ShapePoints[j].z + m1 * ShapePoints[j + iNumShapePoints].z; - Vert->v = tv1; - Vert->x = pt.x; - Vert->y = pt.y; - Vert->z = pt.z; // punkt na początku odcinka - Vert++; - // dla trapezu drugi koniec ma inne współrzędne względne - norm = (jmm1 * ShapePoints[j].n.x + m1 * ShapePoints[j + iNumShapePoints].n.x) * - parallel2; - norm.y += jmm1 * ShapePoints[j].n.y + m1 * ShapePoints[j + iNumShapePoints].n.y; - pt = parallel2 * (jmm2 * (ShapePoints[j].x - fOffsetX) + - m2 * ShapePoints[j + iNumShapePoints].x) + - pos2; - pt.y += jmm2 * ShapePoints[j].y + m2 * ShapePoints[j + iNumShapePoints].y; - Vert->nx = norm.x; // niekoniecznie tak - Vert->ny = norm.y; - Vert->nz = norm.z; - Vert->u = jmm2 * ShapePoints[j].z + m2 * ShapePoints[j + iNumShapePoints].z; - Vert->v = tv2; - Vert->x = pt.x; - Vert->y = pt.y; - Vert->z = pt.z; // punkt na końcu odcinka - Vert++; - } - else - for (j = 0; j < iNumShapePoints; j++) - { // współrzędne początku - norm = ShapePoints[j].n.x * parallel1; - norm.y += ShapePoints[j].n.y; - pt = parallel1 * (ShapePoints[j].x - fOffsetX) + pos1; - pt.y += ShapePoints[j].y; - Vert->nx = norm.x; // niekoniecznie tak - Vert->ny = norm.y; - Vert->nz = norm.z; - Vert->u = ShapePoints[j].z; - Vert->v = tv1; - Vert->x = pt.x; - Vert->y = pt.y; - Vert->z = pt.z; // punkt na początku odcinka - Vert++; - norm = ShapePoints[j].n.x * parallel2; - norm.y += ShapePoints[j].n.y; - pt = parallel2 * ShapePoints[j].x + pos2; - pt.y += ShapePoints[j].y; - Vert->nx = norm.x; // niekoniecznie tak - Vert->ny = norm.y; - Vert->nz = norm.z; - Vert->u = ShapePoints[j].z; - Vert->v = tv2; - Vert->x = pt.x; - Vert->y = pt.y; - Vert->z = pt.z; // punkt na końcu odcinka - Vert++; - } - pos1 = pos2; - parallel1 = parallel2; - tv1 = tv2; - } - } - else - { // gdy prosty - pos1 = FastGetPoint((fStep * iSkip) / fLength); - pos2 = FastGetPoint_1(); - dir = GetDirection(); - // parallel1=Normalize(CrossProduct(dir,vector3(0,1,0))); - parallel1 = Normalize(vector3(-dir.z, 0.0, dir.x)); // wektor poprzeczny - if (trapez) - for (j = 0; j < iNumShapePoints; j++) - { - norm = ShapePoints[j].n.x * parallel1; - norm.y += ShapePoints[j].n.y; - pt = parallel1 * (ShapePoints[j].x - fOffsetX) + pos1; - pt.y += ShapePoints[j].y; - Vert->nx = norm.x; // niekoniecznie tak - Vert->ny = norm.y; - Vert->nz = norm.z; - Vert->u = ShapePoints[j].z; - Vert->v = 0; - Vert->x = pt.x; - Vert->y = pt.y; - Vert->z = pt.z; // punkt na początku odcinka - Vert++; - // dla trapezu drugi koniec ma inne współrzędne - norm = ShapePoints[j + iNumShapePoints].n.x * parallel1; - norm.y += ShapePoints[j + iNumShapePoints].n.y; - pt = parallel1 * (ShapePoints[j + iNumShapePoints].x - fOffsetX) + - pos2; // odsunięcie - pt.y += ShapePoints[j + iNumShapePoints].y; // wysokość - Vert->nx = norm.x; // niekoniecznie tak - Vert->ny = norm.y; - Vert->nz = norm.z; - Vert->u = ShapePoints[j + iNumShapePoints].z; - Vert->v = fLength / fTextureLength; - Vert->x = pt.x; - Vert->y = pt.y; - Vert->z = pt.z; // punkt na końcu odcinka - Vert++; - } - else - for (j = 0; j < iNumShapePoints; j++) - { - norm = ShapePoints[j].n.x * parallel1; - norm.y += ShapePoints[j].n.y; - pt = parallel1 * (ShapePoints[j].x - fOffsetX) + pos1; - pt.y += ShapePoints[j].y; - Vert->nx = norm.x; // niekoniecznie tak - Vert->ny = norm.y; - Vert->nz = norm.z; - Vert->u = ShapePoints[j].z; - Vert->v = 0; - Vert->x = pt.x; - Vert->y = pt.y; - Vert->z = pt.z; // punkt na początku odcinka - Vert++; - pt = parallel1 * (ShapePoints[j].x - fOffsetX) + pos2; - pt.y += ShapePoints[j].y; - Vert->nx = norm.x; // niekoniecznie tak - Vert->ny = norm.y; - Vert->nz = norm.z; - Vert->u = ShapePoints[j].z; - Vert->v = fLength / fTextureLength; - Vert->x = pt.x; - Vert->y = pt.y; - Vert->z = pt.z; // punkt na końcu odcinka - Vert++; - } - } -}; - -void TSegment::RaAnimate(CVertNormTex *&Vert, const vector6 *ShapePoints, int iNumShapePoints, - double fTextureLength, int iSkip, int iEnd, double fOffsetX) -{ // jak wyżej, tylko z pominięciem mapowania i braku trapezowania - vector3 pos1, pos2, dir, parallel1, parallel2, pt; - double s, step, fOffset, t, fEnd; - int i, j; - bool trapez = iNumShapePoints < 0; // sygnalizacja trapezowatości - iNumShapePoints = abs(iNumShapePoints); - if (bCurve) - { - double m1, jmm1, m2, jmm2; // pozycje względne na odcinku 0...1 (ale nie parametr Beziera) - step = fStep; - s = fStep * iSkip; // iSkip - ile odcinków z początku pominąć - i = iSkip; // domyślnie 0 - t = fTsBuffer[i]; // tabela wattości t dla segmentów - fOffset = 0.1 / fLength; // pierwsze 10cm - pos1 = FastGetPoint(t); // wektor początku segmentu - dir = FastGetDirection(t, fOffset); // wektor kierunku - // parallel1=Normalize(CrossProduct(dir,vector3(0,1,0))); //wektor prostopadły - parallel1 = Normalize(vector3(-dir.z, 0.0, dir.x)); // wektor poprzeczny - if (iEnd == 0) - iEnd = iSegCount; - fEnd = fLength * double(iEnd) / double(iSegCount); - m2 = s / fEnd; - jmm2 = 1.0 - m2; - while (i < iEnd) - { - ++i; // kolejny punkt łamanej - s += step; // końcowa pozycja segmentu [m] - m1 = m2; - jmm1 = jmm2; // stara pozycja - m2 = s / fEnd; - jmm2 = 1.0 - m2; // nowa pozycja - if (i == iEnd) - { // gdy przekroczyliśmy koniec - stąd dziury w torach... - step -= (s - fEnd); // jeszcze do wyliczenia mapowania potrzebny - s = fEnd; - // i=iEnd; //20/5 ma dawać 4 - m2 = 1.0; - jmm2 = 0.0; - } - t = fTsBuffer[i]; // szybsze od GetTFromS(s); - pos2 = FastGetPoint(t); - dir = FastGetDirection(t, fOffset); // nowy wektor kierunku - // parallel2=Normalize(CrossProduct(dir,vector3(0,1,0))); - parallel2 = Normalize(vector3(-dir.z, 0.0, dir.x)); // wektor poprzeczny - if (trapez) - for (j = 0; j < iNumShapePoints; j++) - { // współrzędne początku - pt = parallel1 * (jmm1 * (ShapePoints[j].x - fOffsetX) + - m1 * ShapePoints[j + iNumShapePoints].x) + - pos1; - pt.y += jmm1 * ShapePoints[j].y + m1 * ShapePoints[j + iNumShapePoints].y; - Vert->x = pt.x; - Vert->y = pt.y; - Vert->z = pt.z; // punkt na początku odcinka - Vert++; - // dla trapezu drugi koniec ma inne współrzędne - pt = parallel2 * (jmm2 * (ShapePoints[j].x - fOffsetX) + - m2 * ShapePoints[j + iNumShapePoints].x) + - pos2; - pt.y += jmm2 * ShapePoints[j].y + m2 * ShapePoints[j + iNumShapePoints].y; - Vert->x = pt.x; - Vert->y = pt.y; - Vert->z = pt.z; // punkt na końcu odcinka - Vert++; - } - pos1 = pos2; - parallel1 = parallel2; - } - } - else - { // gdy prosty - pos1 = FastGetPoint((fStep * iSkip) / fLength); - pos2 = FastGetPoint_1(); - dir = GetDirection(); - // parallel1=Normalize(CrossProduct(dir,vector3(0,1,0))); - parallel1 = Normalize(vector3(-dir.z, 0.0, dir.x)); // wektor poprzeczny - if (trapez) - for (j = 0; j < iNumShapePoints; j++) - { - pt = parallel1 * (ShapePoints[j].x - fOffsetX) + pos1; - pt.y += ShapePoints[j].y; - Vert->x = pt.x; - Vert->y = pt.y; - Vert->z = pt.z; // punkt na początku odcinka - Vert++; - pt = parallel1 * (ShapePoints[j + iNumShapePoints].x - fOffsetX) + - pos2; // odsunięcie - pt.y += ShapePoints[j + iNumShapePoints].y; // wysokość - Vert->x = pt.x; - Vert->y = pt.y; - Vert->z = pt.z; // punkt na końcu odcinka - Vert++; - } - } -}; +*/ //--------------------------------------------------------------------------- diff --git a/Segment.h b/Segment.h index 380744e1..2f5cd2f9 100644 --- a/Segment.h +++ b/Segment.h @@ -7,152 +7,128 @@ obtain one at http://mozilla.org/MPL/2.0/. */ -#ifndef SegmentH -#define SegmentH +#pragma once -#include "VBO.h" +#include "classes.h" #include "dumb3d.h" -#include "Classes.h" +#include "openglgeometrybank.h" +#include "utilities.h" -using namespace Math3D; - -// 110405 Ra: klasa punktów przekroju z normalnymi - -class vector6 : public vector3 -{ // punkt przekroju wraz z wektorem normalnym - public: - vector3 n; - vector6() - { - x = y = z = n.x = n.z = 0.0; - n.y = 1.0; - }; - vector6(double a, double b, double c, double d, double e, double f) - //{x=a; y=b; z=c; n.x=d; n.y=e; n.z=f;}; - { - x = a; - y = b; - z = c; - n.x = 0.0; - n.y = 1.0; - n.z = 0.0; - }; // Ra: bo na razie są z tym problemy - vector6(double a, double b, double c) - { - x = a; - y = b; - z = c; - n.x = 0.0; - n.y = 1.0; - n.z = 0.0; +struct segment_data { +// types + enum point { + start = 0, + control1, + control2, + end }; +// members + std::array points {}; + std::array rolls {}; + float radius {}; +// constructors + segment_data() = default; +// methods + void deserialize( cParser &Input, glm::dvec3 const &Offset ); }; class TSegment { // aproksymacja toru (zwrotnica ma dwa takie, jeden z nich jest aktywny) private: - vector3 Point1, CPointOut, CPointIn, Point2; - double fRoll1 = 0.0, - fRoll2 = 0.0; // przechyłka na końcach - double fLength = 0.0; // długość policzona - double *fTsBuffer = nullptr; // wartości parametru krzywej dla równych odcinków + Math3D::vector3 Point1, CPointOut, CPointIn, Point2; + float + fRoll1 { 0.f }, + fRoll2 { 0.f }; // przechyłka na końcach + double fLength { -1.0 }; // długość policzona + std::vector fTsBuffer; // wartości parametru krzywej dla równych odcinków double fStep = 0.0; int iSegCount = 0; // ilość odcinków do rysowania krzywej double fDirection = 0.0; // Ra: kąt prostego w planie; dla łuku kąt od Point1 double fStoop = 0.0; // Ra: kąt wzniesienia; dla łuku od Point1 - vector3 vA, vB, vC; // współczynniki wielomianów trzeciego stopnia vD==Point1 - // TSegment *pPrev; //odcinek od strony punktu 1 - w segmencie, żeby nie skakać na zwrotnicach - // TSegment *pNext; //odcinek od strony punktu 2 + Math3D::vector3 vA, vB, vC; // współczynniki wielomianów trzeciego stopnia vD==Point1 TTrack *pOwner = nullptr; // wskaźnik na właściciela - double fAngle[2]; // kąty zakończenia drogi na przejazdach - vector3 GetFirstDerivative(double fTime); - double RombergIntegral(double fA, double fB); - double GetTFromS(double s); - vector3 RaInterpolate(double t); - vector3 RaInterpolate0(double t); - // TSegment *segNeightbour[2]; //sąsiednie odcinki - musi być przeniesione z Track - // int iNeightbour[2]; //do którego końca doczepiony - public: + Math3D::vector3 + GetFirstDerivative(double const fTime) const; + double + RombergIntegral(double const fA, double const fB) const; + double + GetTFromS(double const s) const; + Math3D::vector3 + RaInterpolate(double const t) const; + Math3D::vector3 + RaInterpolate0(double const t) const; + +public: bool bCurve = false; - // int iShape; //Ra: flagi kształtu dadzą więcej możliwości optymalizacji - // (0-Bezier,1-prosty,2/3-łuk w lewo/prawo,6/7-przejściowa w lewo/prawo) + TSegment(TTrack *owner); - ~TSegment(); - bool Init(vector3 NewPoint1, vector3 NewPoint2, double fNewStep, double fNewRoll1 = 0, - double fNewRoll2 = 0); - bool Init(vector3 &NewPoint1, vector3 NewCPointOut, vector3 NewCPointIn, vector3 &NewPoint2, - double fNewStep, double fNewRoll1 = 0, double fNewRoll2 = 0, bool bIsCurve = true); - inline double ComputeLength(); // McZapkie-150503 - inline vector3 GetDirection1() - { - return bCurve ? CPointOut - Point1 : CPointOut; - }; - inline vector3 GetDirection2() - { - return bCurve ? CPointIn - Point2 : CPointIn; - }; - vector3 GetDirection(double fDistance); - vector3 GetDirection() - { - return CPointOut; - }; - vector3 FastGetDirection(double fDistance, double fOffset); - vector3 GetPoint(double fDistance); - void RaPositionGet(double fDistance, vector3 &p, vector3 &a); - vector3 FastGetPoint(double t); - inline vector3 FastGetPoint_0() - { - return Point1; - }; - inline vector3 FastGetPoint_1() - { - return Point2; - }; - inline double GetRoll(double s) - { - s /= fLength; - return ((1.0 - s) * fRoll1 + s * fRoll2); - } - void GetRolls(double &r1, double &r2) - { // pobranie przechyłek (do generowania trójkątów) - r1 = fRoll1; - r2 = fRoll2; - } - void RenderLoft(const vector6 *ShapePoints, int iNumShapePoints, double fTextureLength, - int iSkip = 0, int iQualityFactor = 1, vector3 **p = NULL, bool bRender = true); - void RenderSwitchRail(const vector6 *ShapePoints1, const vector6 *ShapePoints2, - int iNumShapePoints, double fTextureLength, int iSkip = 0, - double fOffsetX = 0.0f); - void Render(); - inline double GetLength() - { - return fLength; - }; - void MoveMe(vector3 pPosition) - { - Point1 += pPosition; - Point2 += pPosition; - if (bCurve) - { - CPointIn += pPosition; - CPointOut += pPosition; - } - } - int RaSegCount() - { - return fTsBuffer ? iSegCount : 1; - }; - void RaRenderLoft(CVertNormTex *&Vert, const vector6 *ShapePoints, int iNumShapePoints, - double fTextureLength, int iSkip = 0, int iEnd = 0, double fOffsetX = 0.0); - void RaAnimate(CVertNormTex *&Vert, const vector6 *ShapePoints, int iNumShapePoints, - double fTextureLength, int iSkip = 0, int iEnd = 0, double fOffsetX = 0.0); - void AngleSet(int i, double a) - { - fAngle[i] = a; - }; - void Rollment(double w1, double w2); // poprawianie przechyłki + bool + Init( Math3D::vector3 NewPoint1, Math3D::vector3 NewPoint2, double fNewStep, double fNewRoll1 = 0, double fNewRoll2 = 0); + bool + Init( Math3D::vector3 &NewPoint1, Math3D::vector3 NewCPointOut, Math3D::vector3 NewCPointIn, Math3D::vector3 &NewPoint2, double fNewStep, double fNewRoll1 = 0, double fNewRoll2 = 0, bool bIsCurve = true); + double + ComputeLength() const; // McZapkie-150503 + // finds point on segment closest to specified point in 3d space. returns: point on segment as value in range 0-1 + double + find_nearest_point( glm::dvec3 const &Point ) const; + inline + Math3D::vector3 + GetDirection1() const { + return bCurve ? CPointOut - Point1 : CPointOut; }; + inline + Math3D::vector3 + GetDirection2() const { + return bCurve ? CPointIn - Point2 : CPointIn; }; + Math3D::vector3 + GetDirection(double const fDistance) const; + inline + Math3D::vector3 + GetDirection() const { + return CPointOut; }; + Math3D::vector3 + FastGetDirection(double const fDistance, double const fOffset); +/* + Math3D::vector3 + GetPoint(double const fDistance) const; +*/ + void + RaPositionGet(double const fDistance, Math3D::vector3 &p, Math3D::vector3 &a) const; + Math3D::vector3 + FastGetPoint(double const t) const; + inline + Math3D::vector3 + FastGetPoint_0() const { + return Point1; }; + inline + Math3D::vector3 + FastGetPoint_1() const { + return Point2; }; + inline + float + GetRoll(double const Distance) const { + return interpolate( fRoll1, fRoll2, static_cast(Distance / fLength) ); } + inline + void + GetRolls(float &r1, float &r2) const { + // pobranie przechyłek (do generowania trójkątów) + r1 = fRoll1; + r2 = fRoll2; } + + bool + RenderLoft( gfx::vertex_array &Output, Math3D::vector3 const &Origin, gfx::vertex_array const &ShapePoints, int iNumShapePoints, double fTextureLength, double Texturescale = 1.0, int iSkip = 0, int iEnd = 0, float fOffsetX = 0.f, glm::vec3 **p = nullptr, bool bRender = true); +/* + void + Render(); +*/ + inline + double + GetLength() const { + return fLength; }; + inline + int + RaSegCount() const { + return ( fTsBuffer.empty() ? 1 : iSegCount ); }; }; //--------------------------------------------------------------------------- -#endif diff --git a/Spring.cpp b/Spring.cpp index 38104815..587be4f7 100644 --- a/Spring.cpp +++ b/Spring.cpp @@ -10,48 +10,31 @@ http://mozilla.org/MPL/2.0/. #include "stdafx.h" #include "Spring.h" -TSpring::TSpring() -{ - vForce1 = vForce2 = vector3(0, 0, 0); - Ks = 0; - Kd = 0; - restLen = 0; -} - -TSpring::~TSpring() -{ -} - -void TSpring::Init(double nrestLen, double nKs, double nKd) -{ +void TSpring::Init(double nKs, double nKd) { Ks = nKs; Kd = nKd; - restLen = nrestLen; } -Math3D::vector3 TSpring::ComputateForces(vector3 const &pPosition1, vector3 const &pPosition2) -{ +Math3D::vector3 TSpring::ComputateForces( Math3D::vector3 const &pPosition1, Math3D::vector3 const &pPosition2) { - double dist, Hterm, Dterm; - vector3 springForce, deltaV, deltaP; + Math3D::vector3 springForce; // p1 = &system[spring->p1]; // p2 = &system[spring->p2]; // VectorDifference(&p1->pos,&p2->pos,&deltaP); // Vector distance - deltaP = pPosition1 - pPosition2; - // dist = VectorLength(&deltaP); // Magnitude of - // deltaP - dist = deltaP.Length(); - if (dist != 0.0 ) { + auto deltaP = pPosition1 - pPosition2; + // dist = VectorLength(&deltaP); // Magnitude of deltaP + auto dist = deltaP.Length(); + if( dist > restLen ) { // Hterm = (dist - spring->restLen) * spring->Ks; // Ks * (dist - rest) - Hterm = ( dist - restLen ) * Ks; // Ks * (dist - rest) + auto Hterm = ( dist - restLen ) * Ks; // Ks * (dist - rest) // VectorDifference(&p1->v,&p2->v,&deltaV); // Delta Velocity Vector - deltaV = pPosition1 - pPosition2; + auto deltaV = pPosition1 - pPosition2; // Dterm = (DotProduct(&deltaV,&deltaP) * spring->Kd) / dist; // Damping Term - // Dterm = (DotProduct(deltaV,deltaP) * Kd) / dist; - Dterm = 0; + auto Dterm = (DotProduct(deltaV,deltaP) * Kd) / dist; + //Dterm = 0; // ScaleVector(&deltaP,1.0f / dist, &springForce); // Normalize Distance Vector // ScaleVector(&springForce,-(Hterm + Dterm),&springForce); // Calc Force @@ -60,14 +43,7 @@ Math3D::vector3 TSpring::ComputateForces(vector3 const &pPosition1, vector3 cons // VectorDifference(&p2->f,&springForce,&p2->f); // - Force on Particle 2 } - vForce1 = springForce; - vForce2 = springForce; - return springForce; } -void TSpring::Render() -{ -} - //--------------------------------------------------------------------------- diff --git a/Spring.h b/Spring.h index e716b8b9..30fd0a1b 100644 --- a/Spring.h +++ b/Spring.h @@ -10,8 +10,9 @@ http://mozilla.org/MPL/2.0/. #ifndef ParticlesH #define ParticlesH +#include "dumb3d.h" +/* #define STATIC_THRESHOLD 0.17f -// efine STATIC_THRESHOLD 0.03f const double m_Kd = 0.02f; // DAMPING FACTOR const double m_Kr = 0.8f; // 1.0 = SUPERBALL BOUNCE 0.0 = DEAD WEIGHT const double m_Ksh = 5.0f; // HOOK'S SPRING CONSTANT @@ -19,25 +20,20 @@ const double m_Ksd = 0.1f; // SPRING DAMPING CONSTANT const double m_Csf = 0.9f; // Default Static Friction const double m_Ckf = 0.7f; // Default Kinetic Friction +*/ +class TSpring { -#include "dumb3d.h" -using namespace Math3D; - -class TSpring -{ - public: - TSpring(); - ~TSpring(); +public: + TSpring() = default; // void Init(TParticnp1, TParticle *np2, double nKs= 0.5f, double nKd= 0.002f, // double nrestLen= -1.0f); - void Init(double nrestLen, double nKs = 0.5f, double nKd = 0.002f); - Math3D::vector3 ComputateForces(vector3 const &pPosition1, vector3 const &pPosition2); - void Render(); - vector3 vForce1, vForce2; - double restLen; // LENGTH OF SPRING AT REST - double Ks; // SPRING CONSTANT - double Kd; // SPRING DAMPING - private: + void Init(double nKs = 0.5f, double nKd = 0.002f); + Math3D::vector3 ComputateForces( Math3D::vector3 const &pPosition1, Math3D::vector3 const &pPosition2); +private: +// members + double restLen { 0.01 }; // LENGTH OF SPRING AT REST + double Ks { 0.0 }; // SPRING CONSTANT + double Kd { 0.0 }; // SPRING DAMPING }; //--------------------------------------------------------------------------- diff --git a/Texture.cpp b/Texture.cpp index fb9a4dd0..665a2598 100644 --- a/Texture.cpp +++ b/Texture.cpp @@ -14,24 +14,22 @@ http://mozilla.org/MPL/2.0/. */ #include "stdafx.h" -#include "Texture.h" +#include "texture.h" #include -#include -#include -#include "opengl/glew.h" +#include "GL/glew.h" -#include "Globals.h" +#include "utilities.h" +#include "globals.h" #include "logs.h" -#include "Usefull.h" -#include "TextureDDS.h" +#include "sn_utils.h" -texture_manager TextureManager; +#define EU07_DEFERRED_TEXTURE_UPLOAD texture_manager::texture_manager() { // since index 0 is used to indicate no texture, we put a blank entry in the first texture slot - m_textures.emplace_back( opengl_texture() ); + m_textures.emplace_back( new opengl_texture(), std::chrono::steady_clock::time_point() ); } // loads texture data from specified file @@ -41,7 +39,7 @@ opengl_texture::load() { if( name.size() < 3 ) { goto fail; } - WriteLog( "Loading texture data from \"" + name + "\"" ); + WriteLog( "Loading texture data from \"" + name + "\"", logtype::texture ); data_state = resource_state::loading; { @@ -57,12 +55,21 @@ opengl_texture::load() { // data state will be set by called loader, so we're all done here if( data_state == resource_state::good ) { + has_alpha = ( + data_components == GL_RGBA ? + true : + false ); + + size = data.size() / 1024; + return; } fail: data_state = resource_state::failed; - ErrorLog( "Failed to load texture \"" + name + "\"" ); + ErrorLog( "Bad texture: failed to load texture \"" + name + "\"" ); + // NOTE: temporary workaround for texture assignment errors + id = 0; return; } @@ -84,16 +91,16 @@ opengl_texture::load_BMP() { BITMAPINFO info; unsigned int infosize = header.bfOffBits - sizeof( BITMAPFILEHEADER ); if( infosize > sizeof( info ) ) { - WriteLog( "Warning - BMP header is larger than expected, possible format difference." ); + WriteLog( "Warning - BMP header is larger than expected, possible format difference.", logtype::texture ); } - file.read( (char *)&info, std::min( infosize, sizeof( info ) ) ); + file.read( (char *)&info, std::min( (size_t)infosize, sizeof( info ) ) ); data_width = info.bmiHeader.biWidth; data_height = info.bmiHeader.biHeight; if( info.bmiHeader.biCompression != BI_RGB ) { - ErrorLog( "Compressed BMP textures aren't supported." ); + ErrorLog( "Bad texture: compressed BMP textures aren't supported.", logtype::texture ); data_state = resource_state::failed; return; } @@ -124,6 +131,70 @@ opengl_texture::load_BMP() { return; } +DDCOLORKEY opengl_texture::deserialize_ddck(std::istream &s) +{ + DDCOLORKEY ddck; + + ddck.dwColorSpaceLowValue = sn_utils::ld_uint32(s); + ddck.dwColorSpaceHighValue = sn_utils::ld_uint32(s); + + return ddck; +} + +DDPIXELFORMAT opengl_texture::deserialize_ddpf(std::istream &s) +{ + DDPIXELFORMAT ddpf; + + ddpf.dwSize = sn_utils::ld_uint32(s); + ddpf.dwFlags = sn_utils::ld_uint32(s); + ddpf.dwFourCC = sn_utils::ld_uint32(s); + ddpf.dwRGBBitCount = sn_utils::ld_uint32(s); + ddpf.dwRBitMask = sn_utils::ld_uint32(s); + ddpf.dwGBitMask = sn_utils::ld_uint32(s); + ddpf.dwBBitMask = sn_utils::ld_uint32(s); + ddpf.dwRGBAlphaBitMask = sn_utils::ld_uint32(s); + + return ddpf; +} + +DDSCAPS2 opengl_texture::deserialize_ddscaps(std::istream &s) +{ + DDSCAPS2 ddsc; + + ddsc.dwCaps = sn_utils::ld_uint32(s); + ddsc.dwCaps2 = sn_utils::ld_uint32(s); + ddsc.dwCaps3 = sn_utils::ld_uint32(s); + ddsc.dwCaps4 = sn_utils::ld_uint32(s); + + return ddsc; +} + +DDSURFACEDESC2 opengl_texture::deserialize_ddsd(std::istream &s) +{ + DDSURFACEDESC2 ddsd; + + ddsd.dwSize = sn_utils::ld_uint32(s); + ddsd.dwFlags = sn_utils::ld_uint32(s); + ddsd.dwHeight = sn_utils::ld_uint32(s); + ddsd.dwWidth = sn_utils::ld_uint32(s); + ddsd.lPitch = sn_utils::ld_uint32(s); + ddsd.dwBackBufferCount = sn_utils::ld_uint32(s); + ddsd.dwMipMapCount = sn_utils::ld_uint32(s); + ddsd.dwAlphaBitDepth = sn_utils::ld_uint32(s); + ddsd.dwReserved = sn_utils::ld_uint32(s); + sn_utils::ld_uint32(s); + ddsd.lpSurface = nullptr; + ddsd.ddckCKDestOverlay = deserialize_ddck(s); + ddsd.ddckCKDestBlt = deserialize_ddck(s); + ddsd.ddckCKSrcOverlay = deserialize_ddck(s); + ddsd.ddckCKSrcBlt = deserialize_ddck(s); + ddsd.ddpfPixelFormat = deserialize_ddpf(s); + ddsd.ddsCaps = deserialize_ddscaps(s); + ddsd.dwTextureStage = sn_utils::ld_uint32(s); + + return ddsd; +} + void opengl_texture::load_DDS() { @@ -142,9 +213,8 @@ opengl_texture::load_DDS() { return; } - DDSURFACEDESC2 ddsd; - file.read((char *)&ddsd, sizeof(ddsd)); - filesize -= sizeof( ddsd ); + DDSURFACEDESC2 ddsd = deserialize_ddsd(file); + filesize -= 124; // // This .dds loader supports the loading of compressed formats DXT1, DXT3 @@ -180,12 +250,13 @@ opengl_texture::load_DDS() { int blockSize = ( data_format == GL_COMPRESSED_RGBA_S3TC_DXT1_EXT ? 8 : 16 ); int offset = 0; - while( ( data_width > Global::iMaxTextureSize ) || ( data_height > Global::iMaxTextureSize ) ) { + while( ( data_width > Global.iMaxTextureSize ) || ( data_height > Global.iMaxTextureSize ) ) { // pomijanie zbyt dużych mipmap, jeśli wymagane jest ograniczenie rozmiaru offset += ( ( data_width + 3 ) / 4 ) * ( ( data_height + 3 ) / 4 ) * blockSize; data_width /= 2; data_height /= 2; --data_mapcount; + WriteLog( "Texture size exceeds specified limits, skipping mipmap level" ); }; if( data_mapcount <= 0 ) { @@ -195,7 +266,7 @@ opengl_texture::load_DDS() { return; } - int datasize = filesize - offset; + size_t datasize = filesize - offset; /* // this approach loads only the first mipmap and relies on graphics card to fill the rest data_mapcount = 1; @@ -216,6 +287,12 @@ opengl_texture::load_DDS() { --mapcount; } */ + if( datasize == 0 ) { + // catch malformed .dds files + WriteLog( "Bad texture: file \"" + name + "\" is malformed and holds no texture data.", logtype::texture ); + data_state = resource_state::failed; + return; + } // reserve space and load texture data data.resize( datasize ); if( offset != 0 ) { @@ -253,7 +330,7 @@ opengl_texture::load_TEX() { hasalpha = true; } else { - ErrorLog( "Unrecognized TEX texture sub-format: " + std::string(head) ); + ErrorLog( "Bad texture: unrecognized TEX texture sub-format: " + std::string(head), logtype::texture ); data_state = resource_state::failed; return; }; @@ -349,7 +426,6 @@ opengl_texture::load_TGA() { else if( tgaheader[ 2 ] == 10 ) { // compressed TGA int currentpixel = 0; - int currentbyte = 0; unsigned char buffer[ 4 ] = { 255, 255, 255, 255 }; const int pixelcount = data_width * data_height; @@ -408,6 +484,22 @@ opengl_texture::load_TGA() { return; } + if( ( tgaheader[ 17 ] & 0x20 ) != 0 ) { + // normally origin is bottom-left + // if byte 17 bit 5 is set, it is top-left and needs flip + flip_vertical(); + } + + downsize( GL_BGRA ); + if( ( data_width > Global.iMaxTextureSize ) || ( data_height > Global.iMaxTextureSize ) ) { + // for non-square textures there's currently possibility the scaling routine will have to abort + // before it gets all work done + data_state = resource_state::failed; + return; + } + + // TODO: add horizontal/vertical data flip, based on the descriptor (18th) header byte + // fill remaining data info data_mapcount = 1; data_format = GL_BGRA; @@ -420,131 +512,166 @@ opengl_texture::load_TGA() { return; } -void +bool +opengl_texture::bind() { + + if( ( false == is_ready ) + && ( false == create() ) ) { + return false; + } + ::glBindTexture( GL_TEXTURE_2D, id ); + return true; +} + +bool opengl_texture::create() { if( data_state != resource_state::good ) { // don't bother until we have useful texture data - return; + return false; } - ::glGenTextures( 1, &id ); - ::glBindTexture( GL_TEXTURE_2D, id ); + // TODO: consider creating and storing low-res version of the texture if it's ever unloaded from the gfx card, + // as a placeholder until it can be loaded again + if( id == -1 ) { - // analyze specified texture traits - bool wraps{ true }; - bool wrapt{ true }; - for( auto const &trait : traits ) { + ::glGenTextures( 1, &id ); + ::glBindTexture( GL_TEXTURE_2D, id ); - switch( trait ) { + // analyze specified texture traits + bool wraps{ true }; + bool wrapt{ true }; + for( auto const &trait : traits ) { - case 's': { wraps = false; break; } - case 't': { wrapt = false; break; } + switch( trait ) { + + case 's': { wraps = false; break; } + case 't': { wrapt = false; break; } + } } - } - ::glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, ( wraps == true ? GL_REPEAT : GL_CLAMP_TO_EDGE ) ); - ::glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, ( wrapt == true ? GL_REPEAT : GL_CLAMP_TO_EDGE ) ); + ::glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, ( wraps == true ? GL_REPEAT : GL_CLAMP_TO_EDGE ) ); + ::glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, ( wrapt == true ? GL_REPEAT : GL_CLAMP_TO_EDGE ) ); - set_filtering(); + set_filtering(); - if( data_mapcount == 1 ) { - // fill missing mipmaps if needed - ::glTexParameteri( GL_TEXTURE_2D, GL_GENERATE_MIPMAP, GL_TRUE ); - } - // upload texture data - int dataoffset = 0, - datasize = 0, - datawidth = data_width, - dataheight = data_height; - for( int maplevel = 0; maplevel < data_mapcount; ++maplevel ) { + if( data_mapcount == 1 ) { + // fill missing mipmaps if needed + ::glTexParameteri( GL_TEXTURE_2D, GL_GENERATE_MIPMAP, GL_TRUE ); + } + // upload texture data + int dataoffset = 0, + datasize = 0, + datawidth = data_width, + dataheight = data_height; + for( int maplevel = 0; maplevel < data_mapcount; ++maplevel ) { - if( ( data_format == GL_COMPRESSED_RGBA_S3TC_DXT1_EXT ) - || ( data_format == GL_COMPRESSED_RGBA_S3TC_DXT3_EXT ) - || ( data_format == GL_COMPRESSED_RGBA_S3TC_DXT5_EXT ) ) { - // compressed dds formats - int const datablocksize = - ( data_format == GL_COMPRESSED_RGBA_S3TC_DXT1_EXT ? + if( ( data_format == GL_COMPRESSED_RGBA_S3TC_DXT1_EXT ) + || ( data_format == GL_COMPRESSED_RGBA_S3TC_DXT3_EXT ) + || ( data_format == GL_COMPRESSED_RGBA_S3TC_DXT5_EXT ) ) { + // compressed dds formats + int const datablocksize = + ( data_format == GL_COMPRESSED_RGBA_S3TC_DXT1_EXT ? 8 : 16 ); - datasize = ( ( std::max(datawidth, 4) + 3 ) / 4 ) * ( ( std::max(dataheight, 4) + 3 ) / 4 ) * datablocksize; + datasize = ( ( std::max( datawidth, 4 ) + 3 ) / 4 ) * ( ( std::max( dataheight, 4 ) + 3 ) / 4 ) * datablocksize; - ::glCompressedTexImage2D( - GL_TEXTURE_2D, maplevel, data_format, - datawidth, dataheight, 0, - datasize, (GLubyte *)&data[0] + dataoffset ); + ::glCompressedTexImage2D( + GL_TEXTURE_2D, maplevel, data_format, + datawidth, dataheight, 0, + datasize, (GLubyte *)&data[ dataoffset ] ); - dataoffset += datasize; - datawidth = std::max( datawidth / 2, 1 ); - dataheight = std::max( dataheight / 2, 1 ); + dataoffset += datasize; + datawidth = std::max( datawidth / 2, 1 ); + dataheight = std::max( dataheight / 2, 1 ); + } + else { + // uncompressed texture data. have the gfx card do the compression as it sees fit + ::glTexImage2D( + GL_TEXTURE_2D, 0, + ( Global.compress_tex ? + GL_COMPRESSED_RGBA : + GL_RGBA ), + data_width, data_height, 0, + data_format, GL_UNSIGNED_BYTE, (GLubyte *)&data[ 0 ] ); + } } - else{ - // uncompressed texture data - ::glTexImage2D( - GL_TEXTURE_2D, 0, GL_RGBA8, - data_width, data_height, 0, - data_format, GL_UNSIGNED_BYTE, (GLubyte *)&data[0] ); + + if( ( true == Global.ResourceMove ) + || ( false == Global.ResourceSweep ) ) { + // if garbage collection is disabled we don't expect having to upload the texture more than once + data = std::vector(); + data_state = resource_state::none; } + is_ready = true; } - is_ready = true; - has_alpha = ( - data_components == GL_RGBA ? - true : - false ); + return true; +} - data.resize( 0 ); // TBD, TODO: keep the texture data if we start doing some gpu data cleaning down the road - data_state = resource_state::none; +// releases resources allocated on the opengl end, storing local copy if requested +void +opengl_texture::release() { + + if( id == -1 ) { return; } + + if( true == Global.ResourceMove ) { + // if resource move is enabled we don't keep a cpu side copy after upload + // so need to re-acquire the data before release + // TBD, TODO: instead of vram-ram transfer fetch the data 'normally' from the disk using worker thread + ::glBindTexture( GL_TEXTURE_2D, id ); + GLint datasize {}; + GLint iscompressed {}; + ::glGetTexLevelParameteriv( GL_TEXTURE_2D, 0, GL_TEXTURE_COMPRESSED, &iscompressed ); + if( iscompressed == GL_TRUE ) { + // texture is compressed on the gpu side + // query texture details needed to perform the backup... + ::glGetTexLevelParameteriv( GL_TEXTURE_2D, 0, GL_TEXTURE_INTERNAL_FORMAT, &data_format ); + ::glGetTexLevelParameteriv( GL_TEXTURE_2D, 0, GL_TEXTURE_COMPRESSED_IMAGE_SIZE, &datasize ); + data.resize( datasize ); + // ...fetch the data... + ::glGetCompressedTexImage( GL_TEXTURE_2D, 0, &data[ 0 ] ); + } + else { + // for whatever reason texture didn't get compressed during upload + // fallback on plain rgba storage... + data_format = GL_RGBA; + data.resize( data_width * data_height * 4 ); + // ...fetch the data... + ::glGetTexImage( GL_TEXTURE_2D, 0, data_format, GL_UNSIGNED_BYTE, &data[ 0 ] ); + } + // ...and update texture object state + data_mapcount = 1; // we keep copy of only top mipmap level + data_state = resource_state::good; + } + // release opengl resources + ::glDeleteTextures( 1, &id ); + id = -1; + is_ready = false; + + return; } void -opengl_texture::set_filtering() { +opengl_texture::set_filtering() const { // default texture mode ::glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR ); ::glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR ); + if( GLEW_EXT_texture_filter_anisotropic ) { + // anisotropic filtering + ::glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_MAX_ANISOTROPY_EXT, Global.AnisotropicFiltering ); + } + bool sharpen{ false }; for( auto const &trait : traits ) { switch( trait ) { case '#': { sharpen = true; break; } -/* - // legacy filter modes. TODO, TBD: get rid of them? - // let's just turn them off and see if anyone notices. - case '4': { - // najbliższy z tekstury - glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST ); - break; - } - case '5': { - //średnia z tekstury - glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR ); - break; - } - case '6': { - // najbliższy z mipmapy - glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST_MIPMAP_NEAREST ); - break; - } - case '7': { - //średnia z mipmapy - glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_NEAREST ); - break; - } - case '8': { - // najbliższy z dwóch mipmap - glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST_MIPMAP_LINEAR ); - break; - } - case '9': { - //średnia z dwóch mipmap - glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR ); - break; - } -*/ + default: { break; } } } @@ -559,12 +686,70 @@ opengl_texture::set_filtering() { } void -texture_manager::Init() { +opengl_texture::downsize( GLuint const Format ) { + + while( ( data_width > Global.iMaxTextureSize ) || ( data_height > Global.iMaxTextureSize ) ) { + // scale down the base texture, if it's larger than allowed maximum + // NOTE: scaling is uniform along both axes, meaning non-square textures can drop below the maximum + // TODO: replace with proper scaling function once we have image middleware in place + if( ( data_width < 2 ) || ( data_height < 2 ) ) { + // can't go any smaller + break; + } + + WriteLog( "Texture size exceeds specified limits, downsampling data" ); + // trim potential odd texture sizes + data_width -= ( data_width % 2 ); + data_height -= ( data_height % 2 ); + switch( Format ) { + + case GL_RGB: { downsample< glm::tvec3 >( data_width, data_height, data.data() ); break; } + case GL_BGRA: + case GL_RGBA: { downsample< glm::tvec4 >( data_width, data_height, data.data() ); break; } + default: { break; } + } + data_width /= 2; + data_height /= 2; + data.resize( data.size() / 4 ); // not strictly needed, but, eh + }; +} + +void +opengl_texture::flip_vertical() { + + auto const swapsize { data_width * 4 }; + auto destination { data.begin() + ( data_height - 1 ) * swapsize }; + auto sampler { data.begin() }; + + for( auto row = 0; row < data_height / 2; ++row ) { + + std::swap_ranges( sampler, sampler + swapsize, destination ); + sampler += swapsize; + destination -= swapsize; + } +} + +void +texture_manager::assign_units( GLint const Helper, GLint const Shadows, GLint const Normals, GLint const Diffuse ) { + + m_units[ 0 ].unit = Helper; + m_units[ 1 ].unit = Shadows; + m_units[ 2 ].unit = Normals; + m_units[ 3 ].unit = Diffuse; +} + +void +texture_manager::unit( GLint const Textureunit ) { + + if( m_activeunit == Textureunit ) { return; } + + m_activeunit = Textureunit; + ::glActiveTexture( Textureunit ); } // ustalenie numeru tekstury, wczytanie jeśli jeszcze takiej nie było -texture_manager::size_type -texture_manager::GetTextureId( std::string Filename, std::string const &Dir, int const Filter, bool const Loadnow ) { +texture_handle +texture_manager::create( std::string Filename, bool const Loadnow ) { if( Filename.find( '|' ) != std::string::npos ) Filename.erase( Filename.find( '|' ) ); // po | może być nazwa kolejnej tekstury @@ -578,169 +763,197 @@ texture_manager::GetTextureId( std::string Filename, std::string const &Dir, int Filename.erase( traitpos ); } - if( Filename.rfind( '.' ) != std::string::npos ) - Filename.erase( Filename.rfind( '.' ) ); // trim extension if there's one - - for( char &c : Filename ) { - // change forward slashes to windows ones. NOTE: probably not strictly necessary, but eh - c = ( c == '/' ? '\\' : c ); + erase_extension( Filename ); + replace_slashes( Filename ); + if( Filename[ 0 ] == '/' ) { + // filename can potentially begin with a slash, and we don't need it + Filename.erase( 0, 1 ); } -/* - std::transform( - Filename.begin(), Filename.end(), - Filename.begin(), - []( char Char ){ return Char == '/' ? '\\' : Char; } ); -*/ - if( Filename.find( '\\' ) == std::string::npos ) { - // jeśli bieżaca ścieżka do tekstur nie została dodana to dodajemy domyślną - Filename = szTexturePath + Filename; - } - - std::vector extensions{ { ".dds" }, { ".tga" }, { ".bmp" }, { ".ext" } }; // try to locate requested texture in the databank - auto lookup = find_in_databank( Filename + Global::szDefaultExt ); + auto lookup { find_in_databank( Filename ) }; if( lookup != npos ) { - // start with the default extension... return lookup; } - else { - // ...then try recognized file extensions other than default - for( auto const &extension : extensions ) { - - if( extension == Global::szDefaultExt ) { - // we already tried this one - continue; - } - lookup = find_in_databank( Filename + extension ); - if( lookup != npos ) { - - return lookup; - } - } - } // if we don't have the texture in the databank, check if it's on disk - std::string filename = find_on_disk( Filename + Global::szDefaultExt ); - if( true == filename.empty() ) { - // if the default lookup fails, try other known extensions - for( auto const &extension : extensions ) { + auto const disklookup { find_on_disk( Filename ) }; - if( extension == Global::szDefaultExt ) { - // we already tried this one - continue; - } - filename = find_on_disk( Filename + extension ); - if( false == filename.empty() ) { - // we found something, don't bother with others - break; - } - } - } - - if( true == filename.empty() ) { + if( true == disklookup.first.empty() ) { // there's nothing matching in the databank nor on the disk, report failure + ErrorLog( "Bad file: failed do locate texture file \"" + Filename + "\"", logtype::file ); return npos; } - opengl_texture texture; - texture.name = filename; - if( ( Filter > 0 ) && ( Filter < 10 ) ) { - // temporary. TODO, TBD: check how it's used and possibly get rid of it - traits += std::to_string( ( Filter < 4 ? Filter + 4 : Filter ) ); - } - if( Filename.find('#') !=std::string::npos ) { + auto texture = new opengl_texture(); + texture->name = disklookup.first + disklookup.second; + if( Filename.find('#') != std::string::npos ) { // temporary code for legacy assets -- textures with names beginning with # are to be sharpened traits += '#'; } - texture.traits = traits; - auto const textureindex = m_textures.size(); - m_textures.emplace_back( texture ); - m_texturemappings.emplace( filename, textureindex ); + texture->traits = traits; + auto const textureindex = (texture_handle)m_textures.size(); + m_textures.emplace_back( texture, std::chrono::steady_clock::time_point() ); + m_texturemappings.emplace( disklookup.first, textureindex ); - WriteLog( "Created texture object for \"" + filename + "\"" ); + WriteLog( "Created texture object for \"" + disklookup.first + disklookup.second + "\"", logtype::texture ); if( true == Loadnow ) { - Texture( textureindex ).load(); - Texture( textureindex ).create(); + texture_manager::texture( textureindex ).load(); +#ifndef EU07_DEFERRED_TEXTURE_UPLOAD + texture_manager::texture( textureindex ).create(); + // texture creation binds a different texture, force a re-bind on next use + m_activetexture = -1; +#endif } return textureindex; }; void -texture_manager::Bind( texture_manager::size_type const Id ) { -/* - // NOTE: this optimization disabled for the time being, until the render code is reviewed - // having it active would lead to some terrain and spline chunks receiving wrong - // (the most recent?) texture, instead of the proper one. It'd also affect negatively - // light point rendering. - if( Id == m_activetexture ) { +texture_manager::bind( std::size_t const Unit, texture_handle const Texture ) { + + m_textures[ Texture ].second = m_garbagecollector.timestamp(); + if( m_units[ Unit ].unit == 0 ) { + // no texture unit, nothing to bind the texture to + return; + } + // even if we may skip texture binding make sure the relevant texture unit is activated + unit( m_units[ Unit ].unit ); + if( Texture == m_units[ Unit ].texture ) { // don't bind again what's already active return; } -*/ - // TODO: do binding in texture object, add support for other types - if( Id != 0 ) { - - auto const &texture = Texture( Id ); - if( true == texture.is_ready ) { - ::glBindTexture( GL_TEXTURE_2D, texture.id ); - m_activetexture = Id; - return; + // TBD, TODO: do binding in texture object, add support for other types than 2d + if( Texture != null_handle ) { +#ifndef EU07_DEFERRED_TEXTURE_UPLOAD + // NOTE: we could bind dedicated 'error' texture here if the id isn't valid + ::glBindTexture( GL_TEXTURE_2D, texture(Texture).id ); + m_units[ Unit ].texture = Texture; +#else + if( true == texture( Texture ).bind() ) { + m_units[ Unit ].texture = Texture; } + else { + // TODO: bind a special 'error' texture on failure + ::glBindTexture( GL_TEXTURE_2D, 0 ); + m_units[ Unit ].texture = 0; + } +#endif } - - ::glBindTexture( GL_TEXTURE_2D, 0 ); - m_activetexture = 0; - + else { + ::glBindTexture( GL_TEXTURE_2D, 0 ); + m_units[ Unit ].texture = 0; + } + // all done return; } -// checks whether specified texture is in the texture bank. returns texture id, or npos. -texture_manager::size_type -texture_manager::find_in_databank( std::string const &Texturename ) { - - auto lookup = m_texturemappings.find( Texturename ); - if( lookup != m_texturemappings.end() ) { - return lookup->second; - } - // jeszcze próba z dodatkową ścieżką - lookup = m_texturemappings.find( szTexturePath + Texturename ); - - return ( - lookup != m_texturemappings.end() ? - lookup->second : - npos ); -} - -// checks whether specified file exists. -std::string -texture_manager::find_on_disk( std::string const &Texturename ) { - - { - std::ifstream file( Texturename ); - if( true == file.is_open() ) { - // success - return Texturename; - } - } - // if we fail make a last ditch attempt in the default textures directory - { - std::ifstream file( szTexturePath + Texturename ); - if( true == file.is_open() ) { - // success - return szTexturePath + Texturename; - } - } - // no results either way, report failure - return ""; -} void -texture_manager::Free() -{ +texture_manager::delete_textures() { for( auto const &texture : m_textures ) { // usunięcie wszyskich tekstur (bez usuwania struktury) - ::glDeleteTextures( 1, &texture.id ); + if( ( texture.first->id > 0 ) + && ( texture.first->id != -1 ) ) { + ::glDeleteTextures( 1, &(texture.first->id) ); + } + delete texture.first; } } + +// performs a resource sweep +void +texture_manager::update() { + + if( m_garbagecollector.sweep() > 0 ) { + for( auto &unit : m_units ) { + unit.texture = -1; + } + } +} + +// debug performance string +std::string +texture_manager::info() const { + + // TODO: cache this data and update only during resource sweep + std::size_t totaltexturecount{ m_textures.size() - 1 }; + std::size_t totaltexturesize{ 0 }; +#ifdef EU07_DEFERRED_TEXTURE_UPLOAD + std::size_t readytexturecount{ 0 }; + std::size_t readytexturesize{ 0 }; +#endif + + for( auto const& texture : m_textures ) { + + totaltexturesize += texture.first->size; +#ifdef EU07_DEFERRED_TEXTURE_UPLOAD + + if( texture.first->is_ready ) { + + ++readytexturecount; + readytexturesize += texture.first->size; + } +#endif + } + + return + "; textures: " +#ifdef EU07_DEFERRED_TEXTURE_UPLOAD + + std::to_string( readytexturecount ) + + " (" + + to_string( readytexturesize / 1024.0f, 2 ) + " mb)" + + " in vram, " +#endif + + std::to_string( totaltexturecount ) + + " (" + + to_string( totaltexturesize / 1024.0f, 2 ) + " mb)" + + " total"; +} + +// checks whether specified texture is in the texture bank. returns texture id, or npos. +texture_handle +texture_manager::find_in_databank( std::string const &Texturename ) const { + + std::vector const filenames { + Global.asCurrentTexturePath + Texturename, + Texturename, + szTexturePath + Texturename }; + + for( auto const &filename : filenames ) { + auto const lookup { m_texturemappings.find( filename ) }; + if( lookup != m_texturemappings.end() ) { + return lookup->second; + } + } + // all lookups failed + return npos; +} + +// checks whether specified file exists. +std::pair +texture_manager::find_on_disk( std::string const &Texturename ) const { + + std::vector const filenames { + Global.asCurrentTexturePath + Texturename, + Texturename, + szTexturePath + Texturename }; + + auto lookup = + FileExists( + filenames, + { Global.szDefaultExt } ); + + if( false == lookup.first.empty() ) { + return lookup; + } + + // if the first attempt fails, try entire extension list + // NOTE: slightly wasteful as it means preferred extension is tested twice, but, eh + return ( + FileExists( + filenames, + { ".dds", ".tga", ".bmp", ".ext" } ) ); +} + +//--------------------------------------------------------------------------- diff --git a/Texture.h b/Texture.h index 5779c7cc..b57cd20d 100644 --- a/Texture.h +++ b/Texture.h @@ -9,43 +9,63 @@ http://mozilla.org/MPL/2.0/. #pragma once +#include +#include #include -#include "opengl/glew.h" - -enum class resource_state { - none, - loading, - good, - failed -}; +#include "GL/glew.h" +#include "ResourceManager.h" struct opengl_texture { + static DDSURFACEDESC2 deserialize_ddsd(std::istream&); + static DDCOLORKEY deserialize_ddck(std::istream&); + static DDPIXELFORMAT deserialize_ddpf(std::istream&); + static DDSCAPS2 deserialize_ddscaps(std::istream&); - // methods - void load(); - void create(); - // members - GLuint id{ (GLuint) -1 }; // associated GL resource +// constructors + opengl_texture() = default; +// methods + void + load(); + bool + bind(); + bool + create(); + // releases resources allocated on the opengl end, storing local copy if requested + void + release(); + inline + int + width() const { + return data_width; } + inline + int + height() const { + return data_height; } +// members + GLuint id{ (GLuint)-1 }; // associated GL resource bool has_alpha{ false }; // indicates the texture has alpha channel bool is_ready{ false }; // indicates the texture was processed and is ready for use std::string traits; // requested texture attributes: wrapping modes etc std::string name; // name of the texture source file + std::size_t size{ 0 }; // size of the texture data, in kb private: - // methods +// methods void load_BMP(); void load_DDS(); void load_TEX(); void load_TGA(); - void set_filtering(); + void set_filtering() const; + void downsize( GLuint const Format ); + void flip_vertical(); - // members - std::vector data; // texture data +// members + std::vector data; // texture data (stored GL-style, bottom-left origin) resource_state data_state{ resource_state::none }; // current state of texture data int data_width{ 0 }, data_height{ 0 }, data_mapcount{ 0 }; - GLuint data_format{ 0 }, + GLint data_format{ 0 }, data_components{ 0 }; /* std::atomic is_loaded{ false }; // indicates the texture data was loaded and can be processed @@ -53,49 +73,124 @@ private: */ }; +typedef int texture_handle; + class texture_manager { -private: - typedef std::vector opengltexture_array; - public: -// typedef opengltexture_array::size_type size_type; - typedef int size_type; - texture_manager(); - ~texture_manager() { Free(); } + ~texture_manager() { delete_textures(); } - size_type GetTextureId( std::string Filename, std::string const &Dir, int const Filter = -1, bool const Loadnow = true ); - void Bind( size_type const Id ); - opengl_texture &Texture( size_type const Id ) { return m_textures.at( Id ); } - void Init(); - void Free(); + void + assign_units( GLint const Helper, GLint const Shadows, GLint const Normals, GLint const Diffuse ); + // activates specified texture unit + void + unit( GLint const Textureunit ); + // creates texture object out of data stored in specified file + texture_handle + create( std::string Filename, bool const Loadnow = true ); + // binds specified texture to specified texture unit + void + bind( std::size_t const Unit, texture_handle const Texture ); + // provides direct access to specified texture object + opengl_texture & + texture( texture_handle const Texture ) const { return *(m_textures[ Texture ].first); } + // performs a resource sweep + void + update(); + // debug performance string + std::string + info() const; private: - typedef std::unordered_map index_map; -/* - opengltexture_array::size_type LoadFromFile(std::string name, int filter = -1); -*/ -/* - bool LoadBMP( std::string const &fileName); - bool LoadTEX( std::string fileName ); - bool LoadTGA( std::string fileName, int filter = -1 ); - bool LoadDDS( std::string fileName, int filter = -1 ); -*/ +// types: + typedef std::pair< + opengl_texture *, + resource_timestamp > texturetimepoint_pair; + + typedef std::vector< texturetimepoint_pair > texturetimepointpair_sequence; + + typedef std::unordered_map index_map; + + struct texture_unit { + GLint unit { 0 }; + texture_handle texture { null_handle }; // current (most recently bound) texture + }; + +// methods: // checks whether specified texture is in the texture bank. returns texture id, or npos. - size_type find_in_databank( std::string const &Texturename ); + texture_handle + find_in_databank( std::string const &Texturename ) const; // checks whether specified file exists. returns name of the located file, or empty string. - std::string find_on_disk( std::string const &Texturename ); -/* - void SetFiltering(int filter); - void SetFiltering(bool alpha, bool hash); - GLuint CreateTexture(GLubyte *buff, GLint bpp, int width, int height, bool bHasAlpha, - bool bHash, bool bDollar = true, int filter = -1); -*/ - static const size_type npos{ 0 }; // should be -1, but the rest of the code uses -1 for something else - opengltexture_array m_textures; + std::pair + find_on_disk( std::string const &Texturename ) const; + void + delete_textures(); + +// members: + texture_handle const npos { 0 }; // should be -1, but the rest of the code uses -1 for something else + texturetimepointpair_sequence m_textures; index_map m_texturemappings; - size_type m_activetexture{ 0 }; // last i.e. currently bound texture + garbage_collector m_garbagecollector { m_textures, 600, 60, "texture" }; + std::array m_units; + GLint m_activeunit { 0 }; }; -extern texture_manager TextureManager; \ No newline at end of file +// reduces provided data image to half of original size, using basic 2x2 average +template +void +downsample( std::size_t const Width, std::size_t const Height, char *Imagedata ) { + + Colortype_ *destination = reinterpret_cast( Imagedata ); + Colortype_ *sampler = reinterpret_cast( Imagedata ); + + Colortype_ accumulator, color; +/* + _Colortype color; + float component; +*/ + for( std::size_t row = 0; row < Height; row += 2, sampler += Width ) { // column movement advances us down another row + for( std::size_t column = 0; column < Width; column += 2, sampler += 2 ) { +/* + // straightforward, but won't work with byte data + auto color = ( + *sampler + + *( sampler + 1 ) + + *( sampler + Width ) + + *( sampler + Width + 1 ) ); + color /= 4; +*/ + // manual version of the above, but drops colour resolution to 6 bits + accumulator = *sampler; + accumulator /= 4; + color = accumulator; + accumulator = *(sampler + 1); + accumulator /= 4; + color += accumulator; + accumulator = *(sampler + Width); + accumulator /= 4; + color += accumulator; + accumulator = *(sampler + Width + 1); + accumulator /= 4; + color += accumulator; + + *destination++ = color; +/* + // "full" 8bit resolution + color = Colortype_(); component = 0; + for( int idx = 0; idx < sizeof( Colortype_ ); ++idx ) { + + component = ( + (*sampler)[idx] + + ( *( sampler + 1 ) )[idx] + + ( *( sampler + Width ) )[idx] + + ( *( sampler + Width + 1 ))[idx] ); + color[ idx ] = component /= 4; + } + *destination++ = color; +*/ + } + } +} + +//--------------------------------------------------------------------------- diff --git a/TextureDDS.cpp b/TextureDDS.cpp index 74df0b07..1d218422 100644 --- a/TextureDDS.cpp +++ b/TextureDDS.cpp @@ -196,7 +196,7 @@ void DecompressDXT3(DDS_IMAGE_DATA lImage, const GLubyte *lCompData, GLubyte *Da void DecompressDXT5(DDS_IMAGE_DATA lImage, const GLubyte *lCompData, GLubyte *Data) { - GLint x, y, z, i, j, k; + GLint x, y, i, j, k; GLuint Select; const GLubyte *Temp; //, r0, g0, b0, r1, g1, b1; Color8888 colours[4], *col; diff --git a/TextureDDS.h b/TextureDDS.h index 543e67d8..8645a115 100644 --- a/TextureDDS.h +++ b/TextureDDS.h @@ -10,7 +10,7 @@ http://mozilla.org/MPL/2.0/. #ifndef TEXTURE_DDS_H #define TEXTURE_DDS_H 1 -#include "opengl/glew.h" +#include "GL/glew.h" #pragma hdrstop diff --git a/Timer.cpp b/Timer.cpp index d6934f65..bfbdc456 100644 --- a/Timer.cpp +++ b/Timer.cpp @@ -11,16 +11,17 @@ http://mozilla.org/MPL/2.0/. #include "Timer.h" #include "Globals.h" -namespace Timer -{ +namespace Timer { + +subsystem_stopwatches subsystem; double DeltaTime, DeltaRenderTime; -double fFPS = 0.0f; -double fLastTime = 0.0f; -DWORD dwFrames = 0L; -double fSimulationTime = 0; -double fSoundTimer = 0; -double fSinceStart = 0; +double fFPS{ 0.0f }; +double fLastTime{ 0.0f }; +DWORD dwFrames{ 0 }; +double fSimulationTime{ 0.0 }; +double fSoundTimer{ 0.0 }; +double fSinceStart{ 0.0 }; double GetTime() { @@ -37,26 +38,11 @@ double GetDeltaRenderTime() return DeltaRenderTime; } -double GetfSinceStart() -{ - return fSinceStart; -} - void SetDeltaTime(double t) { DeltaTime = t; } -double GetSimulationTime() -{ - return fSimulationTime; -} - -void SetSimulationTime(double t) -{ - fSimulationTime = t; -} - bool GetSoundTimer() { // Ra: być może, by dźwięki nie modyfikowały się zbyt często, po 0.1s zeruje się ten licznik return (fSoundTimer == 0.0f); @@ -69,42 +55,33 @@ double GetFPS() void ResetTimers() { - // double CurrentTime= -#if _WIN32_WINNT >= _WIN32_WINNT_VISTA - ::GetTickCount64(); -#else - ::GetTickCount(); -#endif + UpdateTimers( Global.iPause != 0 ); DeltaTime = 0.1; - DeltaRenderTime = 0; - fSoundTimer = 0; + DeltaRenderTime = 0.0; + fSoundTimer = 0.0; }; LONGLONG fr, count, oldCount; -// LARGE_INTEGER fr,count; -void UpdateTimers(bool pause) -{ + +void UpdateTimers(bool pause) { + QueryPerformanceFrequency((LARGE_INTEGER *)&fr); QueryPerformanceCounter((LARGE_INTEGER *)&count); DeltaRenderTime = double(count - oldCount) / double(fr); if (!pause) { - DeltaTime = Global::fTimeSpeed * DeltaRenderTime; + DeltaTime = Global.fTimeSpeed * DeltaRenderTime; fSoundTimer += DeltaTime; if (fSoundTimer > 0.1) - fSoundTimer = 0; - /* - double CurrentTime= double(count)/double(fr);//GetTickCount(); - DeltaTime= (CurrentTime-OldTime); - OldTime= CurrentTime; - */ - if (DeltaTime > 1) - DeltaTime = 1; + fSoundTimer = 0.0; + + if (DeltaTime > 1.0) + DeltaTime = 1.0; } else - DeltaTime = 0; // wszystko stoi, bo czas nie płynie - oldCount = count; + DeltaTime = 0.0; // wszystko stoi, bo czas nie płynie + oldCount = count; // Keep track of the time lapse and frame count #if _WIN32_WINNT >= _WIN32_WINNT_VISTA double fTime = ::GetTickCount64() * 0.001f; // Get current time in seconds @@ -121,6 +98,7 @@ void UpdateTimers(bool pause) } fSimulationTime += DeltaTime; }; -}; + +}; // namespace timer //--------------------------------------------------------------------------- diff --git a/Timer.h b/Timer.h index b16d0d56..ffc15cb7 100644 --- a/Timer.h +++ b/Timer.h @@ -7,25 +7,17 @@ obtain one at http://mozilla.org/MPL/2.0/. */ -#ifndef TimerH -#define TimerH +#pragma once -namespace Timer -{ +namespace Timer { double GetTime(); double GetDeltaTime(); double GetDeltaRenderTime(); -double GetfSinceStart(); - void SetDeltaTime(double v); -double GetSimulationTime(); - -void SetSimulationTime(double v); - bool GetSoundTimer(); double GetFPS(); @@ -33,7 +25,43 @@ double GetFPS(); void ResetTimers(); void UpdateTimers(bool pause); + +class stopwatch { + +public: +// constructors + stopwatch() = default; +// methods + void + start() { + m_start = std::chrono::steady_clock::now(); } + void + stop() { + m_accumulator = 0.95f * m_accumulator + std::chrono::duration_cast( ( std::chrono::steady_clock::now() - m_start ) ).count() / 1000.f; } + float + average() const { + return m_accumulator / 20.f;} + +private: +// members + std::chrono::time_point m_start { std::chrono::steady_clock::now() }; + float m_accumulator { 1000.f / 30.f * 20.f }; // 20 last samples, initial 'neutral' rate of 30 fps +}; + +struct subsystem_stopwatches { + stopwatch gfx_total; + stopwatch gfx_color; + stopwatch gfx_shadows; + stopwatch gfx_reflections; + stopwatch gfx_swap; + stopwatch sim_total; + stopwatch sim_dynamics; + stopwatch sim_events; + stopwatch sim_ai; +}; + +extern subsystem_stopwatches subsystem; + }; //--------------------------------------------------------------------------- -#endif diff --git a/Track.cpp b/Track.cpp index d36b4016..ca006e48 100644 --- a/Track.cpp +++ b/Track.cpp @@ -13,36 +13,33 @@ http://mozilla.org/MPL/2.0/. */ #include "stdafx.h" -#include "Track.h" -#include "Globals.h" -#include "Logs.h" -#include "Usefull.h" -#include "Texture.h" -#include "Timer.h" -#include "Ground.h" -#include "parser.h" -#include "Mover.h" -#include "DynObj.h" -#include "AnimModel.h" -#include "MemCell.h" -#include "Event.h" +#include "track.h" + +#include "simulation.h" +#include "globals.h" +#include "event.h" +#include "messaging.h" +#include "dynobj.h" +#include "animmodel.h" +#include "track.h" +#include "timer.h" +#include "logs.h" +#include "renderer.h" // 101206 Ra: trapezoidalne drogi i tory // 110720 Ra: rozprucie zwrotnicy i odcinki izolowane -static const double fMaxOffset = 0.1; // double(0.1f)==0.100000001490116 +static float const fMaxOffset = 0.1f; // double(0.1f)==0.100000001490116 // const int NextMask[4]={0,1,0,1}; //tor następny dla stanów 0, 1, 2, 3 // const int PrevMask[4]={0,0,1,1}; //tor poprzedni dla stanów 0, 1, 2, 3 const int iLewo4[4] = {5, 3, 4, 6}; // segmenty (1..6) do skręcania w lewo const int iPrawo4[4] = {-4, -6, -3, -5}; // segmenty (1..6) do skręcania w prawo const int iProsto4[4] = {1, -1, 2, -2}; // segmenty (1..6) do jazdy prosto -const int iEnds4[13] = {3, 0, 2, 1, 2, 0, -1, - 1, 3, 2, 0, 3, 1}; // numer sąsiedniego toru na końcu segmentu "-1" +const int iEnds4[13] = {3, 0, 2, 1, 2, 0, -1, 1, 3, 2, 0, 3, 1}; // numer sąsiedniego toru na końcu segmentu "-1" const int iLewo3[4] = {1, 3, 2, 1}; // segmenty do skręcania w lewo const int iPrawo3[4] = {-2, -1, -3, -2}; // segmenty do skręcania w prawo const int iProsto3[4] = {1, -1, 2, 1}; // segmenty do jazdy prosto -const int iEnds3[13] = {3, 0, 2, 1, 2, 0, -1, - 1, 0, 2, 0, 3, 1}; // numer sąsiedniego toru na końcu segmentu "-1" +const int iEnds3[13] = {3, 0, 2, 1, 2, 0, -1, 1, 0, 2, 0, 3, 1}; // numer sąsiedniego toru na końcu segmentu "-1" TIsolated *TIsolated::pRoot = NULL; TSwitchExtension::TSwitchExtension(TTrack *owner, int const what) @@ -52,7 +49,7 @@ TSwitchExtension::TSwitchExtension(TTrack *owner, int const what) pPrevs[0] = nullptr; pPrevs[1] = nullptr; fOffset1 = fOffset = fDesiredOffset = -fOffsetDelay; // położenie zasadnicze - fOffset2 = 0.0; // w zasadniczym wewnętrzna iglica dolega + fOffset2 = 0.f; // w zasadniczym wewnętrzna iglica dolega Segments[0] = std::make_shared(owner); // z punktu 1 do 2 Segments[1] = std::make_shared(owner); // z punktu 3 do 4 (1=3 dla zwrotnic; odwrócony dla skrzyżowań, ewentualnie 1=4) Segments[2] = (what >= 3) ? @@ -71,32 +68,28 @@ TSwitchExtension::TSwitchExtension(TTrack *owner, int const what) TSwitchExtension::~TSwitchExtension() { // nie ma nic do usuwania } - +/* TIsolated::TIsolated() { // utworznie pustego TIsolated("none", NULL); }; - -TIsolated::TIsolated(const string &n, TIsolated *i) : - asName( n ), pNext( i ) +*/ +TIsolated::TIsolated(std::string const &n, TIsolated *i) : + asName( n ), pNext( i ) { // utworznie obwodu izolowanego. nothing to do here. }; -TIsolated::~TIsolated(){ - // usuwanie - /* - TIsolated *p=pRoot; - while (pRoot) - { - p=pRoot; - p->pNext=NULL; - delete p; - } - */ -}; +void TIsolated::DeleteAll() { -TIsolated * TIsolated::Find(const string &n) + while( pRoot ) { + auto *next = pRoot->Next(); + delete pRoot; + pRoot = next; + } +} + +TIsolated * TIsolated::Find(std::string const &n) { // znalezienie obiektu albo utworzenie nowego TIsolated *p = pRoot; while (p) @@ -109,6 +102,15 @@ TIsolated * TIsolated::Find(const string &n) return pRoot; }; +bool +TIsolated::AssignEvents() { + + evBusy = simulation::Events.FindEvent( asName + ":busy" ); + evFree = simulation::Events.FindEvent( asName + ":free" ); + + return ( evBusy != nullptr ) && ( evFree != nullptr ); +} + void TIsolated::Modify(int i, TDynamicObject *o) { // dodanie lub odjęcie osi if (iAxles) @@ -117,17 +119,12 @@ void TIsolated::Modify(int i, TDynamicObject *o) if (!iAxles) { // jeśli po zmianie nie ma żadnej osi na odcinku izolowanym if (evFree) - Global::AddToQuery(evFree, o); // dodanie zwolnienia do kolejki - if (Global::iMultiplayer) // jeśli multiplayer - Global::pGround->WyslijString(asName, 10); // wysłanie pakietu o zwolnieniu + simulation::Events.AddToQuery(evFree, o); // dodanie zwolnienia do kolejki + if (Global.iMultiplayer) // jeśli multiplayer + multiplayer::WyslijString(asName, 10); // wysłanie pakietu o zwolnieniu if (pMemCell) // w powiązanej komórce -#ifdef EU07_USE_OLD_TMEMCELL_TEXT_ARRAY - pMemCell->UpdateValues( NULL, 0, int( pMemCell->Value2() ) & ~0xFF, - update_memval2); //"zerujemy" ostatnią wartość -#else pMemCell->UpdateValues( "", 0, int( pMemCell->Value2() ) & ~0xFF, - update_memval2 ); //"zerujemy" ostatnią wartość -#endif + basic_event::flags::value_2 ); //"zerujemy" ostatnią wartość } } else @@ -136,48 +133,27 @@ void TIsolated::Modify(int i, TDynamicObject *o) if (iAxles) { if (evBusy) - Global::AddToQuery(evBusy, o); // dodanie zajętości do kolejki - if (Global::iMultiplayer) // jeśli multiplayer - Global::pGround->WyslijString(asName, 11); // wysłanie pakietu o zajęciu + simulation::Events.AddToQuery(evBusy, o); // dodanie zajętości do kolejki + if (Global.iMultiplayer) // jeśli multiplayer + multiplayer::WyslijString(asName, 11); // wysłanie pakietu o zajęciu if (pMemCell) // w powiązanej komórce -#ifdef EU07_USE_OLD_TMEMCELL_TEXT_ARRAY - pMemCell->UpdateValues( NULL, 0, int( pMemCell->Value2() ) | 1, - update_memval2); // zmieniamy ostatnią wartość na nieparzystą -#else - pMemCell->UpdateValues( "", 0, int( pMemCell->Value2() ) | 1, update_memval2 ); // zmieniamy ostatnią wartość na nieparzystą -#endif + pMemCell->UpdateValues( "", 0, int( pMemCell->Value2() ) | 1, basic_event::flags::value_2 ); // zmieniamy ostatnią wartość na nieparzystą } } + // pass the event to the parent + if( pParent != nullptr ) { + pParent->Modify( i, o ); + } }; // tworzenie nowego odcinka ruchu -TTrack::TTrack(TGroundNode *g) : - pMyNode( g ) // Ra: proteza, żeby tor znał swoją nazwę TODO: odziedziczyć TTrack z TGroundNode -{ -#ifdef EU07_USE_OLD_TTRACK_DYNAMICS_ARRAY - ::SecureZeroMemory( Dynamics, sizeof( Dynamics ) ); -#endif - fRadiusTable[ 0 ] = 0.0; - fRadiusTable[ 1 ] = 0.0; - nFouling[ 0 ] = nullptr; - nFouling[ 1 ] = nullptr; -} +TTrack::TTrack( scene::node_data const &Nodedata ) : basic_node( Nodedata ) {} TTrack::~TTrack() { // likwidacja odcinka if( eType == tt_Cross ) { delete SwitchExtension->vPoints; // skrzyżowanie może mieć punkty } - -/* if (eType == tt_Normal) - delete Segment; // dla zwrotnic nie usuwać tego (kopiowany) - else - { // usuwanie dodatkowych danych dla niezwykłych odcinków - if (eType == tt_Cross) - delete SwitchExtension->vPoints; // skrzyżowanie może mieć punkty - SafeDelete(SwitchExtension); - } -*/ } void TTrack::Init() @@ -189,8 +165,7 @@ void TTrack::Init() break; case tt_Cross: // tylko dla skrzyżowania dróg SwitchExtension = std::make_shared( this, 6 ); // 6 po³¹czeñ - SwitchExtension->vPoints = NULL; // brak tablicy punktów - SwitchExtension->iPoints = 0; + SwitchExtension->vPoints = nullptr; // brak tablicy punktów SwitchExtension->bPoints = false; // tablica punktów nie wypełniona SwitchExtension->iRoads = 4; // domyślnie 4 break; @@ -199,40 +174,46 @@ void TTrack::Init() break; case tt_Table: // oba potrzebne SwitchExtension = std::make_shared( this, 1 ); // kopia oryginalnego toru - Segment = make_shared(this); + Segment = std::make_shared(this); break; } } +bool +TTrack::sort_by_material( TTrack const *Left, TTrack const *Right ) { + + return ( ( Left->m_material1 < Right->m_material1 ) + && ( Left->m_material2 < Right->m_material2 ) ); +} + TTrack * TTrack::Create400m(int what, double dx) { // tworzenie toru do wstawiania taboru podczas konwersji na E3D - TGroundNode *tmp = new TGroundNode(TP_TRACK); // node - TTrack *trk = tmp->pTrack; - trk->bVisible = false; // nie potrzeba pokazywać, zresztą i tak nie ma tekstur + scene::node_data nodedata; + nodedata.name = "auto_400m"; // track isn't visible so only name is needed + auto *trk = new TTrack( nodedata ); + trk->m_visible = false; // nie potrzeba pokazywać, zresztą i tak nie ma tekstur trk->iCategoryFlag = what; // taki sam typ plus informacja, że dodatkowy trk->Init(); // utworzenie segmentu - trk->Segment->Init(vector3(-dx, 0, 0), vector3(-dx, 0, 400), 0, 0, 0); // prosty - tmp->pCenter = vector3(-dx, 0, 200); //środek, aby się mogło wyświetlić - TSubRect *r = Global::pGround->GetSubRect(tmp->pCenter.x, tmp->pCenter.z); - r->NodeAdd(tmp); // dodanie toru do segmentu - r->Sort(); //żeby wyświetlał tabor z dodanego toru - r->Release(); // usunięcie skompilowanych zasobów + trk->Segment->Init( Math3D::vector3( -dx, 0, 0 ), Math3D::vector3( -dx, 0, 400 ), 10.0, 0, 0 ); // prosty + trk->location( glm::dvec3{ -dx, 0, 200 } ); //środek, aby się mogło wyświetlić + simulation::Paths.insert( trk ); + simulation::Region->insert( trk ); return trk; }; TTrack * TTrack::NullCreate(int dir) { // tworzenie toru wykolejającego od strony (dir), albo pętli dla samochodów - TGroundNode *tmp = new TGroundNode(TP_TRACK), *tmp2 = NULL; // node - TTrack *trk = tmp->pTrack; // tor; UWAGA! obrotnica może generować duże ilości tego - // tmp->iType=TP_TRACK; - // TTrack* trk=new TTrack(tmp); //tor; UWAGA! obrotnica może generować duże ilości tego - // tmp->pTrack=trk; - trk->bVisible = false; // nie potrzeba pokazywać, zresztą i tak nie ma tekstur - // trk->iTrapezoid=1; //są przechyłki do uwzględniania w rysowaniu + TTrack + *trk { nullptr }, + *trk2 { nullptr }; + scene::node_data nodedata; + nodedata.name = "auto_null"; // track isn't visible so only name is needed + trk = new TTrack( nodedata ); + trk->m_visible = false; // nie potrzeba pokazywać, zresztą i tak nie ma tekstur trk->iCategoryFlag = (iCategoryFlag & 15) | 0x80; // taki sam typ plus informacja, że dodatkowy - double r1, r2; + float r1, r2; Segment->GetRolls(r1, r2); // pobranie przechyłek na początku toru - vector3 p1, cv1, cv2, p2; // będziem tworzyć trajektorię lotu + Math3D::vector3 p1, cv1, cv2, p2; // będziem tworzyć trajektorię lotu if (iCategoryFlag & 1) { // tylko dla kolei trk->iDamageFlag = 128; // wykolejenie @@ -243,25 +224,21 @@ TTrack * TTrack::NullCreate(int dir) case 0: p1 = Segment->FastGetPoint_0(); p2 = p1 - 450.0 * Normalize(Segment->GetDirection1()); - trk->Segment->Init(p1, p2, 5, -RadToDeg(r1), - 70.0); // bo prosty, kontrolne wyliczane przy zmiennej przechyłce + // bo prosty, kontrolne wyliczane przy zmiennej przechyłce + trk->Segment->Init(p1, p2, 5, -RadToDeg(r1), 70.0); ConnectPrevPrev(trk, 0); break; case 1: p1 = Segment->FastGetPoint_1(); p2 = p1 - 450.0 * Normalize(Segment->GetDirection2()); - trk->Segment->Init(p1, p2, 5, RadToDeg(r2), - 70.0); // bo prosty, kontrolne wyliczane przy zmiennej przechyłce + // bo prosty, kontrolne wyliczane przy zmiennej przechyłce + trk->Segment->Init(p1, p2, 5, RadToDeg(r2), 70.0); ConnectNextPrev(trk, 0); break; case 3: // na razie nie możliwe p1 = SwitchExtension->Segments[1]->FastGetPoint_1(); // koniec toru drugiego zwrotnicy - p2 = p1 - - 450.0 * - Normalize( - SwitchExtension->Segments[1]->GetDirection2()); // przedłużenie na wprost - trk->Segment->Init(p1, p2, 5, RadToDeg(r2), - 70.0); // bo prosty, kontrolne wyliczane przy zmiennej przechyłce + p2 = p1 - 450.0 * Normalize( SwitchExtension->Segments[1]->GetDirection2()); // przedłużenie na wprost + trk->Segment->Init(p1, p2, 5, RadToDeg(r2), 70.0); // bo prosty, kontrolne wyliczane przy zmiennej przechyłce ConnectNextPrev(trk, 0); // trk->ConnectPrevNext(trk,dir); SetConnections(1); // skopiowanie połączeń @@ -274,59 +251,52 @@ TTrack * TTrack::NullCreate(int dir) trk->fVelocity = 20.0; // zawracanie powoli trk->fRadius = 20.0; // promień, aby się dodawało do tabelki prędkości i liczyło narastająco trk->Init(); // utworzenie segmentu - tmp2 = new TGroundNode(TP_TRACK); // drugi odcinek do zapętlenia - TTrack *trk2 = tmp2->pTrack; + trk2 = new TTrack( nodedata ); trk2->iCategoryFlag = (iCategoryFlag & 15) | 0x80; // taki sam typ plus informacja, że dodatkowy - trk2->bVisible = false; + trk2->m_visible = false; trk2->fVelocity = 20.0; // zawracanie powoli - trk2->fRadius = 20.0; // promień, aby się dodawało do tabelki prędkości i liczyło - // narastająco + trk2->fRadius = 20.0; // promień, aby się dodawało do tabelki prędkości i liczyło narastająco trk2->Init(); // utworzenie segmentu + trk->m_name = m_name + ":loopstart"; + trk2->m_name = m_name + ":loopfinish"; switch (dir) { //łączenie z nowym torem case 0: p1 = Segment->FastGetPoint_0(); cv1 = -20.0 * Normalize(Segment->GetDirection1()); // pierwszy wektor kontrolny p2 = p1 + cv1 + cv1; // 40m - trk->Segment->Init(p1, p1 + cv1, p2 + vector3(-cv1.z, cv1.y, cv1.x), p2, 2, - -RadToDeg(r1), - 0.0); // bo prosty, kontrolne wyliczane przy zmiennej przechyłce + // bo prosty, kontrolne wyliczane przy zmiennej przechyłce + trk->Segment->Init(p1, p1 + cv1, p2 + Math3D::vector3(-cv1.z, cv1.y, cv1.x), p2, 2, -RadToDeg(r1), 0.0); ConnectPrevPrev(trk, 0); - trk2->Segment->Init(p1, p1 + cv1, p2 + vector3(cv1.z, cv1.y, -cv1.x), p2, 2, - -RadToDeg(r1), - 0.0); // bo prosty, kontrolne wyliczane przy zmiennej przechyłce + // bo prosty, kontrolne wyliczane przy zmiennej przechyłce + trk2->Segment->Init(p1, p1 + cv1, p2 + Math3D::vector3(cv1.z, cv1.y, -cv1.x), p2, 2, -RadToDeg(r1), 0.0); trk2->iPrevDirection = 0; // zwrotnie do tego samego odcinka break; case 1: p1 = Segment->FastGetPoint_1(); cv1 = -20.0 * Normalize(Segment->GetDirection2()); // pierwszy wektor kontrolny p2 = p1 + cv1 + cv1; - trk->Segment->Init(p1, p1 + cv1, p2 + vector3(-cv1.z, cv1.y, cv1.x), p2, 2, - RadToDeg(r2), - 0.0); // bo prosty, kontrolne wyliczane przy zmiennej przechyłce + // bo prosty, kontrolne wyliczane przy zmiennej przechyłce + trk->Segment->Init(p1, p1 + cv1, p2 + Math3D::vector3(-cv1.z, cv1.y, cv1.x), p2, 2, RadToDeg(r2), 0.0); ConnectNextPrev(trk, 0); - trk2->Segment->Init(p1, p1 + cv1, p2 + vector3(cv1.z, cv1.y, -cv1.x), p2, 2, - RadToDeg(r2), - 0.0); // bo prosty, kontrolne wyliczane przy zmiennej przechyłce + // bo prosty, kontrolne wyliczane przy zmiennej przechyłce + trk2->Segment->Init(p1, p1 + cv1, p2 + Math3D::vector3(cv1.z, cv1.y, -cv1.x), p2, 2, RadToDeg(r2), 0.0); trk2->iPrevDirection = 1; // zwrotnie do tego samego odcinka break; } trk2->trPrev = this; trk->ConnectNextNext(trk2, 1); // połączenie dwóch dodatkowych odcinków punktami 2 - tmp2->pCenter = (0.5 * (p1 + p2)); //środek, aby się mogło wyświetlić } // trzeba jeszcze dodać do odpowiedniego segmentu, aby się renderowały z niego pojazdy - tmp->pCenter = (0.5 * (p1 + p2)); //środek, aby się mogło wyświetlić - if (tmp2) - tmp2->pCenter = tmp->pCenter; // ten sam środek jest - // Ra: to poniżej to porażka, ale na razie się nie da inaczej - TSubRect *r = Global::pGround->GetSubRect(tmp->pCenter.x, tmp->pCenter.z); - r->NodeAdd(tmp); // dodanie toru do segmentu - if (tmp2) - r->NodeAdd(tmp2); // drugiego też - r->Sort(); //żeby wyświetlał tabor z dodanego toru - r->Release(); // usunięcie skompilowanych zasobów + trk->location( glm::dvec3{ 0.5 * ( p1 + p2 ) } ); //środek, aby się mogło wyświetlić + simulation::Paths.insert( trk ); + simulation::Region->insert( trk ); + if( trk2 ) { + trk2->location( trk->location() ); // ten sam środek jest + simulation::Paths.insert( trk2 ); + simulation::Region->insert( trk2 ); + } return trk; }; @@ -348,8 +318,8 @@ void TTrack::ConnectPrevNext(TTrack *pTrack, int typ) iPrevDirection = typ | 1; // 1:zwykły lub pierwszy zwrotnicy, 3:drugi zwrotnicy pTrack->trNext = this; pTrack->iNextDirection = 0; - if (bVisible) - if (pTrack->bVisible) + if (m_visible) + if (pTrack->m_visible) if (eType == tt_Normal) // jeśli łączone są dwa normalne if (pTrack->eType == tt_Normal) if ((fTrackWidth != @@ -368,8 +338,8 @@ void TTrack::ConnectNextPrev(TTrack *pTrack, int typ) iNextDirection = ((pTrack->eType == tt_Switch) ? 0 : (typ & 2)); pTrack->trPrev = this; pTrack->iPrevDirection = 1; - if (bVisible) - if (pTrack->bVisible) + if (m_visible) + if (pTrack->m_visible) if (eType == tt_Normal) // jeśli łączone są dwa normalne if (pTrack->eType == tt_Normal) if ((fTrackWidth != @@ -391,36 +361,16 @@ void TTrack::ConnectNextNext(TTrack *pTrack, int typ) } } -vector3 MakeCPoint(vector3 p, double d, double a1, double a2) -{ - vector3 cp = vector3(0, 0, 1); - cp.RotateX(DegToRad(a2)); - cp.RotateY(DegToRad(a1)); - cp = cp * d + p; - return cp; -} - -vector3 LoadPoint(cParser *parser) -{ // pobranie współrzędnych punktu - vector3 p; - std::string token; - parser->getTokens(3); - *parser >> p.x >> p.y >> p.z; - return p; -} - -void TTrack::Load(cParser *parser, vector3 pOrigin, std::string name) +void TTrack::Load(cParser *parser, glm::dvec3 const &pOrigin) { // pobranie obiektu trajektorii ruchu - vector3 pt, vec, p1, p2, cp1, cp2, p3, p4, cp3, cp4; // dodatkowe punkty potrzebne do skrzyżowań - double a1, a2, r1, r2, r3, r4, d1, d2, a; - string str; - bool bCurve; - int i; //,state; //Ra: teraz już nie ma początkowego stanu zwrotnicy we wpisie + Math3D::vector3 pt, vec, p1, p2, cp1, cp2, p3, p4, cp3, cp4; // dodatkowe punkty potrzebne do skrzyżowań + double a1, a2, r1, r2, r3, r4; + std::string str; + size_t i; //,state; //Ra: teraz już nie ma początkowego stanu zwrotnicy we wpisie std::string token; parser->getTokens(); - *parser >> token; - str = token; // typ toru + *parser >> str; // typ toru if (str == "normal") { @@ -464,25 +414,24 @@ void TTrack::Load(cParser *parser, vector3 pOrigin, std::string name) } else eType = tt_Unknown; - if (Global::iWriteLogEnabled & 4) + if (Global.iWriteLogEnabled & 4) WriteLog(str); parser->getTokens(4); - *parser >> fTrackLength >> fTrackWidth >> fFriction >> fSoundDistance; - // fTrackLength=Parser->GetNextSymbol().ToDouble(); //track length - // 100502 - // fTrackWidth=Parser->GetNextSymbol().ToDouble(); //track width - // fFriction=Parser->GetNextSymbol().ToDouble(); //friction coeff. - // fSoundDistance=Parser->GetNextSymbol().ToDouble(); //snd + float discard {}; + *parser + >> discard + >> fTrackWidth + >> fFriction + >> fSoundDistance; fTrackWidth2 = fTrackWidth; // rozstaw/szerokość w punkcie 2, na razie taka sama parser->getTokens(2); - *parser >> iQualityFlag >> iDamageFlag; - // iQualityFlag=Parser->GetNextSymbol().ToInt(); //McZapkie: qualityflag - // iDamageFlag=Parser->GetNextSymbol().ToInt(); //damage + *parser + >> iQualityFlag + >> iDamageFlag; if (iDamageFlag & 128) iAction |= 0x80; // flaga wykolejania z powodu uszkodzenia parser->getTokens(); - *parser >> token; - str = token; // environment + *parser >> str; // environment if (str == "flat") eEnvironment = e_flat; else if (str == "mountains" || str == "mountain") @@ -498,148 +447,237 @@ void TTrack::Load(cParser *parser, vector3 pOrigin, std::string name) else { eEnvironment = e_unknown; - Error("Unknown track environment: \"" + str + "\""); + Error( "Unknown track environment: \"" + str + "\"" ); } parser->getTokens(); *parser >> token; - bVisible = (token.compare("vis") == 0); // visible - if (bVisible) + m_visible = (token.compare("vis") == 0); // visible + if (m_visible) { parser->getTokens(); - *parser >> token; - str = token; // railtex - TextureID1 = (str == "none" ? 0 : TextureManager.GetTextureId( - str, szTexturePath, - (iCategoryFlag & 1) ? Global::iRailProFiltering : - Global::iBallastFiltering)); + *parser >> str; // railtex + m_material1 = ( + str == "none" ? + null_handle : + GfxRenderer.Fetch_Material( str ) ); parser->getTokens(); *parser >> fTexLength; // tex tile length if (fTexLength < 0.01) fTexLength = 4; // Ra: zabezpiecznie przed zawieszeniem parser->getTokens(); - *parser >> token; - str = token; // sub || railtex - TextureID2 = (str == "none" ? 0 : TextureManager.GetTextureId( - str, szTexturePath, - (eType == tt_Normal) ? Global::iBallastFiltering : - Global::iRailProFiltering)); + *parser >> str; // sub || railtex + m_material2 = ( + str == "none" ? + null_handle : + GfxRenderer.Fetch_Material( str ) ); parser->getTokens(3); - *parser >> fTexHeight1 >> fTexWidth >> fTexSlope; - // fTexHeight=Parser->GetNextSymbol().ToDouble(); //tex sub height - // fTexWidth=Parser->GetNextSymbol().ToDouble(); //tex sub width - // fTexSlope=Parser->GetNextSymbol().ToDouble(); //tex sub slope width + *parser + >> fTexHeight1 + >> fTexWidth + >> fTexSlope; + if (iCategoryFlag & 4) fTexHeight1 = -fTexHeight1; // rzeki mają wysokość odwrotnie niż drogi } - else if (Global::iWriteLogEnabled & 4) + else if (Global.iWriteLogEnabled & 4) WriteLog("unvis"); Init(); // ustawia SwitchExtension double segsize = 5.0; // długość odcinka segmentowania - switch (eType) - { // Ra: łuki segmentowane co 5m albo 314-kątem foremnym - case tt_Table: // obrotnica jest prawie jak zwykły tor + + // path data + // all subtypes contain at least one path + m_paths.emplace_back(); + m_paths.back().deserialize( *parser, pOrigin ); + switch( eType ) { + case tt_Switch: + case tt_Cross: + case tt_Tributary: { + // these subtypes contain additional path + m_paths.emplace_back(); + m_paths.back().deserialize( *parser, pOrigin ); + break; + } + default: { + break; + } + } + + switch (eType) { + // Ra: łuki segmentowane co 5m albo 314-kątem foremnym + case tt_Table: { + // obrotnica jest prawie jak zwykły tor iAction |= 2; // flaga zmiany położenia typu obrotnica - case tt_Normal: - p1 = LoadPoint(parser) + pOrigin; // pobranie współrzędnych P1 - parser->getTokens(); - *parser >> r1; // pobranie przechyłki w P1 - cp1 = LoadPoint(parser); // pobranie współrzędnych punktów kontrolnych - cp2 = LoadPoint(parser); - p2 = LoadPoint(parser) + pOrigin; // pobranie współrzędnych P2 - parser->getTokens(2); - *parser >> r2 >> fRadius; // pobranie przechyłki w P1 i promienia - fRadius = fabs(fRadius); // we wpisie może być ujemny + } + case tt_Normal: { + // pobranie współrzędnych P1 + auto const &path { m_paths[ 0 ] }; + p1 = path.points[ segment_data::point::start ]; + // pobranie współrzędnych punktów kontrolnych + cp1 = path.points[ segment_data::point::control1 ]; + cp2 = path.points[ segment_data::point::control2 ]; + // pobranie współrzędnych P2 + p2 = path.points[ segment_data::point::end ]; + r1 = path.rolls[ 0 ]; + r2 = path.rolls[ 1 ]; + fRadius = std::abs( path.radius ); // we wpisie może być ujemny + if (iCategoryFlag & 1) { // zero na główce szyny p1.y += 0.18; p2.y += 0.18; // na przechyłce doliczyć jeszcze pół przechyłki } - if (fRadius != 0) // gdy podany promień - segsize = Min0R(5.0, 0.2 + fabs(fRadius) * 0.02); // do 250m - 5, potem 1 co 50m - if ((((p1 + p1 + p2) / 3.0 - p1 - cp1).Length() < 0.02) || - (((p1 + p2 + p2) / 3.0 - p2 + cp1).Length() < 0.02)) - cp1 = cp2 = vector3(0, 0, 0); //"prostowanie" prostych z kontrolnymi, dokładność 2cm + if( ( ( ( p1 + p1 + p2 ) / 3.0 - p1 - cp1 ).Length() < 0.02 ) + || ( ( ( p1 + p2 + p2 ) / 3.0 - p2 + cp1 ).Length() < 0.02 ) ) { + // "prostowanie" prostych z kontrolnymi, dokładność 2cm + cp1 = cp2 = Math3D::vector3( 0, 0, 0 ); + } + + if( fRadius != 0 ) { + // gdy podany promień + segsize = + clamp( + std::abs( fRadius ) * ( 0.02 / Global.SplineFidelity ), + 2.0 / Global.SplineFidelity, + 10.0 / Global.SplineFidelity ); + } + else { + // HACK: crude check whether claimed straight is an actual straight piece + if( ( cp1 == Math3D::vector3() ) + && ( cp2 == Math3D::vector3() ) ) { + segsize = 10.0; // for straights, 10m per segment works good enough + } + else { + // HACK: divide roughly in 10 segments. + segsize = + clamp( + ( p1 - p2 ).Length() * 0.1, + 2.0 / Global.SplineFidelity, + 10.0 / Global.SplineFidelity ); + } + } + + if( ( cp1 == Math3D::vector3( 0, 0, 0 ) ) + && ( cp2 == Math3D::vector3( 0, 0, 0 ) ) ) { + // Ra: hm, czasem dla prostego są podane... + // gdy prosty, kontrolne wyliczane przy zmiennej przechyłce + Segment->Init( p1, p2, segsize, r1, r2 ); + } + else { + // gdy łuk (ustawia bCurve=true) + Segment->Init( p1, cp1 + p1, cp2 + p2, p2, segsize, r1, r2 ); + } - if ((cp1 == vector3(0, 0, 0)) && - (cp2 == vector3(0, 0, 0))) // Ra: hm, czasem dla prostego są podane... - Segment->Init(p1, p2, segsize, r1, - r2); // gdy prosty, kontrolne wyliczane przy zmiennej przechyłce - else - Segment->Init(p1, cp1 + p1, cp2 + p2, p2, segsize, r1, - r2); // gdy łuk (ustawia bCurve=true) if ((r1 != 0) || (r2 != 0)) iTrapezoid = 1; // są przechyłki do uwzględniania w rysowaniu + if (eType == tt_Table) // obrotnica ma doklejkę { // SwitchExtension=new TSwitchExtension(this,1); //dodatkowe zmienne dla obrotnicy SwitchExtension->Segments[0]->Init(p1, p2, segsize); // kopia oryginalnego toru } else if (iCategoryFlag & 2) - if (TextureID1 && fTexLength) + if (m_material1 && fTexLength) { // dla drogi trzeba ustalić proporcje boków nawierzchni float w, h; - TextureManager.Bind(TextureID1); + GfxRenderer.Bind_Material(m_material1); glGetTexLevelParameterfv(GL_TEXTURE_2D, 0, GL_TEXTURE_WIDTH, &w); glGetTexLevelParameterfv(GL_TEXTURE_2D, 0, GL_TEXTURE_HEIGHT, &h); if (h != 0.0) fTexRatio1 = w / h; // proporcja boków - TextureManager.Bind(TextureID2); + GfxRenderer.Bind_Material(m_material2); glGetTexLevelParameterfv(GL_TEXTURE_2D, 0, GL_TEXTURE_WIDTH, &w); glGetTexLevelParameterfv(GL_TEXTURE_2D, 0, GL_TEXTURE_HEIGHT, &h); if (h != 0.0) fTexRatio2 = w / h; // proporcja boków } break; - - case tt_Cross: // skrzyżowanie dróg - 4 punkty z wektorami kontrolnymi - segsize = 1.0; // specjalne segmentowanie ze względu na małe promienie + } + case tt_Cross: { + // skrzyżowanie dróg - 4 punkty z wektorami kontrolnymi +// segsize = 1.0; // specjalne segmentowanie ze względu na małe promienie + } case tt_Tributary: // dopływ - case tt_Switch: // zwrotnica + case tt_Switch: { // zwrotnica iAction |= 1; // flaga zmiany położenia typu zwrotnica lub skrzyżowanie dróg // problemy z animacją iglic powstaje, gdzy odcinek prosty ma zmienną przechyłkę // wtedy dzieli się na dodatkowe odcinki (po 0.2m, bo R=0) i animację diabli biorą // Ra: na razie nie podejmuję się przerabiania iglic // SwitchExtension=new TSwitchExtension(this,eType==tt_Cross?6:2); //zwrotnica ma doklejkę + auto const &path { m_paths[ 0 ] }; + p1 = path.points[ segment_data::point::start ]; + // pobranie współrzędnych punktów kontrolnych + cp1 = path.points[ segment_data::point::control1 ]; + cp2 = path.points[ segment_data::point::control2 ]; + // pobranie współrzędnych P2 + p2 = path.points[ segment_data::point::end ]; + r1 = path.rolls[ 0 ]; + r2 = path.rolls[ 1 ]; + fRadiusTable[0] = std::abs( path.radius ); // we wpisie może być ujemny - p1 = LoadPoint(parser) + pOrigin; // pobranie współrzędnych P1 - parser->getTokens(); - *parser >> r1; - cp1 = LoadPoint(parser); - cp2 = LoadPoint(parser); - p2 = LoadPoint(parser) + pOrigin; // pobranie współrzędnych P2 - parser->getTokens(2); - *parser >> r2 >> fRadiusTable[0]; - fRadiusTable[0] = fabs(fRadiusTable[0]); // we wpisie może być ujemny if (iCategoryFlag & 1) { // zero na główce szyny p1.y += 0.18; p2.y += 0.18; // na przechyłce doliczyć jeszcze pół przechyłki? } - if (fRadiusTable[0] > 0) - segsize = Min0R(5.0, 0.2 + fRadiusTable[0] * 0.02); - else if (eType != tt_Cross) // dla skrzyżowań muszą być podane kontrolne - { // jak promień zerowy, to przeliczamy punkty kontrolne - cp1 = (p1 + p1 + p2) / 3.0 - p1; // jak jest prosty, to się zoptymalizuje - cp2 = (p1 + p2 + p2) / 3.0 - p2; - segsize = 5.0; - } // ułomny prosty - if (!(cp1 == vector3(0, 0, 0)) && !(cp2 == vector3(0, 0, 0))) - SwitchExtension->Segments[0]->Init(p1, p1 + cp1, p2 + cp2, p2, segsize, r1, r2); - else - SwitchExtension->Segments[0]->Init(p1, p2, segsize, r1, r2); - p3 = LoadPoint(parser) + pOrigin; // pobranie współrzędnych P3 - parser->getTokens(); - *parser >> r3; - cp3 = LoadPoint(parser); - cp4 = LoadPoint(parser); - p4 = LoadPoint(parser) + pOrigin; // pobranie współrzędnych P4 - parser->getTokens(2); - *parser >> r4 >> fRadiusTable[1]; - fRadiusTable[1] = fabs(fRadiusTable[1]); // we wpisie może być ujemny + if( eType != tt_Cross ) { + // dla skrzyżowań muszą być podane kontrolne + if( ( ( ( p1 + p1 + p2 ) / 3.0 - p1 - cp1 ).Length() < 0.02 ) + || ( ( ( p1 + p2 + p2 ) / 3.0 - p2 + cp1 ).Length() < 0.02 ) ) { + // "prostowanie" prostych z kontrolnymi, dokładność 2cm + cp1 = cp2 = Math3D::vector3( 0, 0, 0 ); + } + } + + if( fRadiusTable[ 0 ] != 0 ) { + // gdy podany promień + segsize = + clamp( + std::abs( fRadiusTable[ 0 ] ) * ( 0.02 / Global.SplineFidelity ), + 2.0 / Global.SplineFidelity, + 10.0 / Global.SplineFidelity ); + } + else { + // HACK: crude check whether claimed straight is an actual straight piece + if( ( cp1 == Math3D::vector3() ) + && ( cp2 == Math3D::vector3() ) ) { + segsize = 10.0; // for straights, 10m per segment works good enough + } + else { + // HACK: divide roughly in 10 segments. + segsize = + clamp( + ( p1 - p2 ).Length() * 0.1, + 2.0 / Global.SplineFidelity, + 10.0 / Global.SplineFidelity ); + } + } + + if( ( cp1 == Math3D::vector3( 0, 0, 0 ) ) + && ( cp2 == Math3D::vector3( 0, 0, 0 ) ) ) { + // Ra: hm, czasem dla prostego są podane... + // gdy prosty, kontrolne wyliczane przy zmiennej przechyłce + SwitchExtension->Segments[ 0 ]->Init( p1, p2, segsize, r1, r2 ); + } + else { + // gdy łuk (ustawia bCurve=true) + SwitchExtension->Segments[ 0 ]->Init( p1, cp1 + p1, cp2 + p2, p2, segsize, r1, r2 ); + } + + auto const &path2 { m_paths[ 1 ] }; + p3 = path2.points[ segment_data::point::start ]; + // pobranie współrzędnych punktów kontrolnych + cp3 = path2.points[ segment_data::point::control1 ]; + cp4 = path2.points[ segment_data::point::control2 ]; + // pobranie współrzędnych P2 + p4 = path2.points[ segment_data::point::end ]; + r3 = path2.rolls[ 0 ]; + r4 = path2.rolls[ 1 ]; + fRadiusTable[1] = std::abs( path2.radius ); // we wpisie może być ujemny + if (iCategoryFlag & 1) { // zero na główce szyny p3.y += 0.18; @@ -647,53 +685,79 @@ void TTrack::Load(cParser *parser, vector3 pOrigin, std::string name) // na przechyłce doliczyć jeszcze pół przechyłki? } - if (fRadiusTable[1] > 0) - segsize = Min0R(5.0, 0.2 + fRadiusTable[1] * 0.02); - else if (eType != tt_Cross) // dla skrzyżowań muszą być podane kontrolne - { // jak promień zerowy, to przeliczamy punkty kontrolne - cp3 = (p3 + p3 + p4) / 3.0 - p3; // jak jest prosty, to się zoptymalizuje - cp4 = (p3 + p4 + p4) / 3.0 - p4; - segsize = 5.0; - } // ułomny prosty - - if (!(cp3 == vector3(0, 0, 0)) && !(cp4 == vector3(0, 0, 0))) - { // dla skrzyżowania dróg dać odwrotnie końce, żeby brzegi generować lewym - if (eType != tt_Cross) - SwitchExtension->Segments[1]->Init(p3, p3 + cp3, p4 + cp4, p4, segsize, r3, r4); - else - SwitchExtension->Segments[1]->Init(p4, p4 + cp4, p3 + cp3, p3, segsize, r4, - r3); // odwrócony + if( eType != tt_Cross ) { + // dla skrzyżowań muszą być podane kontrolne + if( ( ( ( p3 + p3 + p4 ) / 3.0 - p3 - cp3 ).Length() < 0.02 ) + || ( ( ( p3 + p4 + p4 ) / 3.0 - p4 + cp3 ).Length() < 0.02 ) ) { + // "prostowanie" prostych z kontrolnymi, dokładność 2cm + cp3 = cp4 = Math3D::vector3( 0, 0, 0 ); + } } - else - SwitchExtension->Segments[1]->Init(p3, p4, segsize, r3, r4); + + if( fRadiusTable[ 1 ] != 0 ) { + // gdy podany promień + segsize = + clamp( + std::abs( fRadiusTable[ 1 ] ) * ( 0.02 / Global.SplineFidelity ), + 2.0 / Global.SplineFidelity, + 10.0 / Global.SplineFidelity ); + } + else { + // HACK: crude check whether claimed straight is an actual straight piece + if( ( cp3 == Math3D::vector3() ) + && ( cp4 == Math3D::vector3() ) ) { + segsize = 10.0; // for straights, 10m per segment works good enough + } + else { + // HACK: divide roughly in 10 segments. + segsize = + clamp( + ( p3 - p4 ).Length() * 0.1, + 2.0 / Global.SplineFidelity, + 10.0 / Global.SplineFidelity ); + } + } + + if( ( cp3 == Math3D::vector3( 0, 0, 0 ) ) + && ( cp4 == Math3D::vector3( 0, 0, 0 ) ) ) { + // Ra: hm, czasem dla prostego są podane... + // gdy prosty, kontrolne wyliczane przy zmiennej przechyłce + SwitchExtension->Segments[ 1 ]->Init( p3, p4, segsize, r3, r4 ); + } + else { + if( eType != tt_Cross ) { + SwitchExtension->Segments[ 1 ]->Init( p3, p3 + cp3, p4 + cp4, p4, segsize, r3, r4 ); + } + else { + // dla skrzyżowania dróg dać odwrotnie końce, żeby brzegi generować lewym + SwitchExtension->Segments[ 1 ]->Init( p4, p4 + cp4, p3 + cp3, p3, segsize, r4, r3 ); // odwrócony + } + } + if (eType == tt_Cross) { // Ra 2014-07: dla skrzyżowań będą dodatkowe segmenty - SwitchExtension->Segments[2]->Init(p2, cp2 + p2, cp4 + p4, p4, segsize, r2, - r4); // z punktu 2 do 4 - if (LengthSquared3(p3 - p1) < - 0.01) // gdy mniej niż 10cm, to mamy skrzyżowanie trzech dróg + SwitchExtension->Segments[2]->Init(p2, cp2 + p2, cp4 + p4, p4, segsize, r2, r4); // z punktu 2 do 4 + if (LengthSquared3(p3 - p1) < 0.01) // gdy mniej niż 10cm, to mamy skrzyżowanie trzech dróg SwitchExtension->iRoads = 3; else // dla 4 dróg będą dodatkowe 3 segmenty { - SwitchExtension->Segments[3]->Init(p4, p4 + cp4, p1 + cp1, p1, segsize, r4, - r1); // z punktu 4 do 1 - SwitchExtension->Segments[4]->Init(p1, p1 + cp1, p3 + cp3, p3, segsize, r1, - r3); // z punktu 1 do 3 - SwitchExtension->Segments[5]->Init(p3, p3 + cp3, p2 + cp2, p2, segsize, r3, - r2); // z punktu 3 do 2 + SwitchExtension->Segments[3]->Init(p4, p4 + cp4, p1 + cp1, p1, segsize, r4, r1); // z punktu 4 do 1 + SwitchExtension->Segments[4]->Init(p1, p1 + cp1, p3 + cp3, p3, segsize, r1, r3); // z punktu 1 do 3 + SwitchExtension->Segments[5]->Init(p3, p3 + cp3, p2 + cp2, p2, segsize, r3, r2); // z punktu 3 do 2 } } Switch(0); // na stałe w położeniu 0 - nie ma początkowego stanu zwrotnicy we wpisie + if( eType == tt_Switch ) // Ra: zamienić później na iloczyn wektorowy { - vector3 v1, v2; + Math3D::vector3 v1, v2; double a1, a2; - v1 = SwitchExtension->Segments[0]->FastGetPoint_1() - - SwitchExtension->Segments[0]->FastGetPoint_0(); - v2 = SwitchExtension->Segments[1]->FastGetPoint_1() - - SwitchExtension->Segments[1]->FastGetPoint_0(); + v1 = SwitchExtension->Segments[0]->FastGetPoint_1() + - SwitchExtension->Segments[0]->FastGetPoint_0(); + v2 = SwitchExtension->Segments[1]->FastGetPoint_1() + - SwitchExtension->Segments[1]->FastGetPoint_0(); a1 = atan2(v1.x, v1.z); a2 = atan2(v2.x, v2.z); a2 = a2 - a1; @@ -704,7 +768,10 @@ void TTrack::Load(cParser *parser, vector3 pOrigin, std::string name) SwitchExtension->RightSwitch = a2 < 0; // lustrzany układ OXY... } break; + } } + + // optional attributes parser->getTokens(); *parser >> token; str = token; @@ -714,46 +781,46 @@ void TTrack::Load(cParser *parser, vector3 pOrigin, std::string name) { parser->getTokens(); *parser >> token; - asEvent0Name = token; + m_events0.emplace_back( token, nullptr ); } else if (str == "event1") { parser->getTokens(); *parser >> token; - asEvent1Name = token; + m_events1.emplace_back( token, nullptr ); } else if (str == "event2") { parser->getTokens(); *parser >> token; - asEvent2Name = token; + m_events2.emplace_back( token, nullptr ); } else if (str == "eventall0") { parser->getTokens(); *parser >> token; - asEventall0Name = token; + m_events0all.emplace_back( token, nullptr ); } else if (str == "eventall1") { parser->getTokens(); *parser >> token; - asEventall1Name = token; + m_events1all.emplace_back( token, nullptr ); } else if (str == "eventall2") { parser->getTokens(); *parser >> token; - asEventall2Name = token; + m_events2all.emplace_back( token, nullptr ); } else if (str == "velocity") { parser->getTokens(); *parser >> fVelocity; //*0.28; McZapkie-010602 if (SwitchExtension) // jeśli tor ruchomy - if (fabs(fVelocity) >= 1.0) //żeby zero nie ograniczało dożywotnio - SwitchExtension->fVelocity = fVelocity; // zapamiętanie głównego ograniczenia; a - // np. -40 ogranicza tylko na bok + if (std::abs(fVelocity) >= 1.0) //żeby zero nie ograniczało dożywotnio + // zapamiętanie głównego ograniczenia; a np. -40 ogranicza tylko na bok + SwitchExtension->fVelocity = static_cast(fVelocity); } else if (str == "isolated") { // obwód izolowany, do którego tor należy @@ -763,208 +830,117 @@ void TTrack::Load(cParser *parser, vector3 pOrigin, std::string name) } else if (str == "angle1") { // kąt ścięcia końca od strony 1 + // NOTE: not used/implemented parser->getTokens(); *parser >> a1; - Segment->AngleSet(0, a1); + //Segment->AngleSet(0, a1); } else if (str == "angle2") { // kąt ścięcia końca od strony 2 + // NOTE: not used/implemented parser->getTokens(); *parser >> a2; - Segment->AngleSet(1, a2); + //Segment->AngleSet(1, a2); } else if (str == "fouling1") { // wskazanie modelu ukresu w kierunku 1 + // NOTE: not used/implemented parser->getTokens(); *parser >> token; // nFouling[0]= } else if (str == "fouling2") { // wskazanie modelu ukresu w kierunku 2 + // NOTE: not used/implemented parser->getTokens(); *parser >> token; // nFouling[1]= } else if (str == "overhead") - { // informacja o stanie sieci: 0-jazda bezprądowa, >0-z opuszczonym i ograniczeniem - // prędkości + { // informacja o stanie sieci: 0-jazda bezprądowa, >0-z opuszczonym i ograniczeniem prędkości parser->getTokens(); *parser >> fOverhead; if (fOverhead > 0.0) iAction |= 0x40; // flaga opuszczenia pantografu (tor uwzględniany w skanowaniu jako // ograniczenie dla pantografujących) } - else if (str == "colides") - { // informacja o stanie sieci: 0-jazda bezprądowa, >0-z opuszczonym i ograniczeniem - // prędkości + else if( str == "vradius" ) { + // y-axis track radius + // NOTE: not used/implemented parser->getTokens(); - *parser >> token; - // trColides=; //tor kolizyjny, na którym trzeba sprawdzać pojazdy pod kątem zderzenia + *parser >> fVerticalRadius; + } + else if( str == "trackbed" ) { + // switch trackbed texture + auto const trackbedtexture { parser->getToken() }; + if( eType == tt_Switch ) { + SwitchExtension->m_material3 = GfxRenderer.Fetch_Material( trackbedtexture ); + } } else - ErrorLog("Unknown property: \"" + str + "\" in track \"" + name + "\""); + ErrorLog("Unknown property: \"" + str + "\" in track \"" + m_name + "\""); parser->getTokens(); *parser >> token; str = token; } // alternatywny zapis nazwy odcinka izolowanego - po znaku "@" w nazwie toru if (!pIsolated) - if ((i = name.find("@")) != string::npos) - if (i < name.length()) // nie może być puste + if ((i = m_name.find("@")) != std::string::npos) + if (i < m_name.length()) // nie może być puste { - pIsolated = TIsolated::Find(name.substr(i + 1, name.length())); - name = name.substr(0, i - 1); // usunięcie z nazwy + pIsolated = TIsolated::Find(m_name.substr(i + 1, m_name.length())); + m_name = m_name.substr(0, i - 1); // usunięcie z nazwy } + + // calculate path location + location( { ( + CurrentSegment()->FastGetPoint_0() + + CurrentSegment()->FastGetPoint( 0.5 ) + + CurrentSegment()->FastGetPoint_1() ) + / 3.0 } ); } -bool TTrack::AssignEvents(TEvent *NewEvent0, TEvent *NewEvent1, TEvent *NewEvent2) -{ - bool bError = false; - if (!evEvent0) - { - if (NewEvent0) - { - evEvent0 = NewEvent0; - asEvent0Name = ""; - iEvents |= 1; // sumaryczna informacja o eventach - } - else - { - if (!asEvent0Name.empty()) - { - ErrorLog("Bad track: Event0 \"" + asEvent0Name + - "\" does not exist"); - bError = true; +bool TTrack::AssignEvents() { + + bool lookupfail { false }; + + std::vector< std::pair< std::string, event_sequence * > > const eventsequences { + { "event0", &m_events0 }, { "eventall0", &m_events0all }, + { "event1", &m_events1 }, { "eventall1", &m_events1all }, + { "event2", &m_events2 }, { "eventall2", &m_events2all } }; + + for( auto &eventsequence : eventsequences ) { + for( auto &event : *( eventsequence.second ) ) { + event.second = simulation::Events.FindEvent( event.first ); + if( event.second != nullptr ) { + m_events = true; + } + else { + ErrorLog( "Bad track: \"" + m_name + "\" can't find assigned event \"" + event.first + "\"" ); + lookupfail = true; } } } - else - { - ErrorLog( - "Bad track: Event0 cannot be assigned to track, track already has one"); - bError = true; - } - if (!evEvent1) - { - if (NewEvent1) - { - evEvent1 = NewEvent1; - asEvent1Name = ""; - iEvents |= 2; // sumaryczna informacja o eventach - } - else if (!asEvent1Name.empty()) - { // Ra: tylko w logu informacja - ErrorLog("Bad track: Event1 \"" + asEvent1Name + - "\" does not exist"); - bError = true; + + auto const trackname { name() }; + + if( ( Global.iHiddenEvents & 1 ) + && ( false == trackname.empty() ) ) { + // jeśli podana jest nazwa torów, można szukać eventów skojarzonych przez nazwę + for( auto &eventsequence : eventsequences ) { + auto *event = simulation::Events.FindEvent( trackname + ':' + eventsequence.first ); + if( event != nullptr ) { + // HACK: auto-associated events come with empty lookup string, to avoid including them in the text format export + eventsequence.second->emplace_back( "", event ); + m_events = true; + } } } - else - { - ErrorLog( - "Bad track: Event1 cannot be assigned to track, track already has one"); - bError = true; - } - if (!evEvent2) - { - if (NewEvent2) - { - evEvent2 = NewEvent2; - asEvent2Name = ""; - iEvents |= 4; // sumaryczna informacja o eventach - } - else if (!asEvent2Name.empty()) - { // Ra: tylko w logu informacja - ErrorLog("Bad track: Event2 \"" + asEvent2Name + - "\" does not exist"); - bError = true; - } - } - else - { - ErrorLog( - "Bad track: Event2 cannot be assigned to track, track already has one"); - bError = true; - } - return !bError; + + return ( lookupfail == false ); } -bool TTrack::AssignallEvents(TEvent *NewEvent0, TEvent *NewEvent1, TEvent *NewEvent2) -{ - bool bError = false; - if (!evEventall0) - { - if (NewEvent0) - { - evEventall0 = NewEvent0; - asEventall0Name = ""; - iEvents |= 8; // sumaryczna informacja o eventach - } - else - { - if (!asEvent0Name.empty()) - { - Error("Eventall0 \"" + asEventall0Name + - "\" does not exist"); - bError = true; - } - } - } - else - { - Error("Eventall0 cannot be assigned to track, track already has one"); - bError = true; - } - if (!evEventall1) - { - if (NewEvent1) - { - evEventall1 = NewEvent1; - asEventall1Name = ""; - iEvents |= 16; // sumaryczna informacja o eventach - } - else - { - if (!asEvent0Name.empty()) - { // Ra: tylko w logu informacja - WriteLog("Eventall1 \"" + asEventall1Name + - "\" does not exist"); - bError = true; - } - } - } - else - { - Error("Eventall1 cannot be assigned to track, track already has one"); - bError = true; - } - if (!evEventall2) - { - if (NewEvent2) - { - evEventall2 = NewEvent2; - asEventall2Name = ""; - iEvents |= 32; // sumaryczna informacja o eventach - } - else - { - if (!asEvent0Name.empty()) - { // Ra: tylko w logu informacja - WriteLog("Eventall2 \"" + asEventall2Name + - "\" does not exist"); - bError = true; - } - } - } - else - { - Error("Eventall2 cannot be assigned to track, track already has one"); - bError = true; - } - return !bError; -} - -bool TTrack::AssignForcedEvents(TEvent *NewEventPlus, TEvent *NewEventMinus) +bool TTrack::AssignForcedEvents(basic_event *NewEventPlus, basic_event *NewEventMinus) { // ustawienie eventów sygnalizacji rozprucia if (SwitchExtension) { @@ -977,7 +953,26 @@ bool TTrack::AssignForcedEvents(TEvent *NewEventPlus, TEvent *NewEventMinus) return false; }; -string TTrack::IsolatedName() +void TTrack::QueueEvents( event_sequence const &Events, TDynamicObject const *Owner ) { + + for( auto const &event : Events ) { + if( event.second != nullptr ) { + simulation::Events.AddToQuery( event.second, Owner ); + } + } +} + +void TTrack::QueueEvents( event_sequence const &Events, TDynamicObject const *Owner, double const Delaylimit ) { + + for( auto const &event : Events ) { + if( ( event.second != nullptr ) + && ( event.second->m_delay <= Delaylimit) ) { + simulation::Events.AddToQuery( event.second, Owner ); + } + } +} + +std::string TTrack::IsolatedName() { // podaje nazwę odcinka izolowanego, jesli nie ma on jeszcze przypisanych zdarzeń if (pIsolated) if (!pIsolated->evBusy && !pIsolated->evFree) @@ -985,20 +980,7 @@ string TTrack::IsolatedName() return ""; }; -bool TTrack::IsolatedEventsAssign(TEvent *busy, TEvent *free) -{ // ustawia zdarzenia dla odcinka izolowanego - if (pIsolated) - { - if (busy) - pIsolated->evBusy = busy; - if (free) - pIsolated->evFree = free; - return true; - } - return false; -}; - -// ABu: przeniesione z Track.h i poprawione!!! +// ABu: przeniesione z Path.h i poprawione!!! bool TTrack::AddDynamicObject(TDynamicObject *Dynamic) { // dodanie pojazdu do trajektorii // Ra: tymczasowo wysyłanie informacji o zajętości konkretnego toru @@ -1008,34 +990,13 @@ bool TTrack::AddDynamicObject(TDynamicObject *Dynamic) Dynamic->MyTrack = NULL; // trzeba by to uzależnić od kierunku ruchu... return true; } -#ifdef EU07_USE_OLD_TTRACK_DYNAMICS_ARRAY - if (Global::iMultiplayer) // jeśli multiplayer - if (!iNumDynamics) // pierwszy zajmujący - if (pMyNode->asName != "none") - Global::pGround->WyslijString(pMyNode->asName, - 8); // przekazanie informacji o zajętości toru - if (iNumDynamics < iMaxNumDynamics) - { // jeśli jest miejsce, dajemy na koniec - Dynamics[iNumDynamics++] = Dynamic; - Dynamic->MyTrack = this; // ABu: na ktorym torze jesteśmy - if (Dynamic->iOverheadMask) // jeśli ma pantografy - Dynamic->OverheadTrack( - fOverhead); // przekazanie informacji o jeździe bezprądowej na tym odcinku toru - return true; - } - else - { - Error("Too many dynamics on track " + pMyNode->asName); - return false; - } -#else - if( Global::iMultiplayer ) { + if( Global.iMultiplayer ) { // jeśli multiplayer if( true == Dynamics.empty() ) { // pierwszy zajmujący - if( pMyNode->asName != "none" ) { + if( m_name != "none" ) { // przekazanie informacji o zajętości toru - Global::pGround->WyslijString( pMyNode->asName, 8 ); + multiplayer::WyslijString( m_name, 8 ); } } } @@ -1046,860 +1007,57 @@ bool TTrack::AddDynamicObject(TDynamicObject *Dynamic) Dynamic->OverheadTrack( fOverhead ); // przekazanie informacji o jeździe bezprądowej na tym odcinku toru } return true; -#endif -}; - -void TTrack::MoveMe(vector3 pPosition) -{ // to nie jest używane - if (SwitchExtension) - { - SwitchExtension->Segments[0]->MoveMe(1 * pPosition); - SwitchExtension->Segments[1]->MoveMe(1 * pPosition); - SwitchExtension->Segments[2]->MoveMe(3 * pPosition); // Ra: 3 razy? - SwitchExtension->Segments[3]->MoveMe(4 * pPosition); - } - else - { - Segment->MoveMe(pPosition); - }; - ResourceManager::Unregister(this); }; const int numPts = 4; const int nnumPts = 12; -/* -const vector6 szyna[nnumPts]= //szyna - vextor6(x,y,mapowanie tekstury,xn,yn,zn) -{pierwotna szyna, opracował youBy, zmiany w celu uzyskania symetrii - vector6( 0.111,-0.180,0.00, 1.000, 0.000,0.000), - vector6( 0.045,-0.155,0.15, 0.707, 0.707,0.000), - vector6( 0.045,-0.070,0.25, 0.707,-0.707,0.000), - vector6( 0.071,-0.040,0.35, 0.707,-0.707,0.000), //albo tu 0.073 - vector6( 0.072,-0.010,0.40, 0.707, 0.707,0.000), - vector6( 0.052,-0.000,0.45, 0.000, 1.000,0.000), - vector6( 0.020,-0.000,0.55, 0.000, 1.000,0.000), - vector6( 0.000,-0.010,0.60,-0.707, 0.707,0.000), - vector6( 0.001,-0.040,0.65,-0.707,-0.707,0.000), //albo tu -0.001 - vector6( 0.027,-0.070,0.75,-0.707,-0.707,0.000), //albo zostanie asymetryczna - vector6( 0.027,-0.155,0.85,-0.707, 0.707,0.000), - vector6(-0.039,-0.180,1.00,-1.000, 0.000,0.000) -}; -*/ -const vector6 szyna[nnumPts] = // szyna - vextor6(x,y,mapowanie tekstury,xn,yn,zn) - { // tę wersję opracował Tolein (bez pochylenia) - vector6(0.111, -0.180, 0.00, 1.000, 0.000, 0.000), - vector6(0.046, -0.150, 0.15, 0.707, 0.707, 0.000), - vector6(0.044, -0.050, 0.25, 0.707, -0.707, 0.000), - vector6(0.073, -0.038, 0.35, 0.707, -0.707, 0.000), - vector6(0.072, -0.010, 0.40, 0.707, 0.707, 0.000), - vector6(0.052, -0.000, 0.45, 0.000, 1.000, 0.000), - vector6(0.020, -0.000, 0.55, 0.000, 1.000, 0.000), - vector6(0.000, -0.010, 0.60, -0.707, 0.707, 0.000), - vector6(-0.001, -0.038, 0.65, -0.707, -0.707, 0.000), - vector6(0.028, -0.050, 0.75, -0.707, -0.707, 0.000), - vector6(0.026, -0.150, 0.85, -0.707, 0.707, 0.000), - vector6(-0.039, -0.180, 1.00, -1.000, 0.000, 0.000)}; -const vector6 iglica[nnumPts] = // iglica - vextor3(x,y,mapowanie tekstury) - { - vector6(0.010, -0.180, 0.00, 1.000, 0.000, 0.000), - vector6(0.010, -0.155, 0.15, 1.000, 0.000, 0.000), - vector6(0.010, -0.070, 0.25, 1.000, 0.000, 0.000), - vector6(0.010, -0.040, 0.35, 1.000, 0.000, 0.000), - vector6(0.010, -0.010, 0.40, 1.000, 0.000, 0.000), - vector6(0.010, -0.000, 0.45, 0.707, 0.707, 0.000), - vector6(0.000, -0.000, 0.55, 0.707, 0.707, 0.000), - vector6(0.000, -0.010, 0.60, -1.000, 0.000, 0.000), - vector6(0.000, -0.040, 0.65, -1.000, 0.000, 0.000), - vector6(0.000, -0.070, 0.75, -1.000, 0.000, 0.000), - vector6(0.000, -0.155, 0.85, -0.707, 0.707, 0.000), - vector6(-0.040, -0.180, 1.00, -1.000, 0.000, - 0.000) // 1mm więcej, żeby nie nachodziły tekstury? -}; +// szyna - vextor6(x,y,mapowanie tekstury,xn,yn,zn) +// tę wersję opracował Tolein (bez pochylenia) +// TODO: profile definitions in external files +gfx::basic_vertex const szyna[ nnumPts ] = { + {{ 0.111f, -0.180f, 0.f}, { 1.000f, 0.000f, 0.f}, {0.00f, 0.f}}, + {{ 0.046f, -0.150f, 0.f}, { 0.707f, 0.707f, 0.f}, {0.15f, 0.f}}, + {{ 0.044f, -0.050f, 0.f}, { 0.707f, -0.707f, 0.f}, {0.25f, 0.f}}, + {{ 0.073f, -0.038f, 0.f}, { 0.707f, -0.707f, 0.f}, {0.35f, 0.f}}, + {{ 0.072f, -0.010f, 0.f}, { 0.707f, 0.707f, 0.f}, {0.40f, 0.f}}, + {{ 0.052f, -0.000f, 0.f}, { 0.000f, 1.000f, 0.f}, {0.45f, 0.f}}, + {{ 0.020f, -0.000f, 0.f}, { 0.000f, 1.000f, 0.f}, {0.55f, 0.f}}, + {{ 0.000f, -0.010f, 0.f}, {-0.707f, 0.707f, 0.f}, {0.60f, 0.f}}, + {{-0.001f, -0.038f, 0.f}, {-0.707f, -0.707f, 0.f}, {0.65f, 0.f}}, + {{ 0.028f, -0.050f, 0.f}, {-0.707f, -0.707f, 0.f}, {0.75f, 0.f}}, + {{ 0.026f, -0.150f, 0.f}, {-0.707f, 0.707f, 0.f}, {0.85f, 0.f}}, + {{-0.039f, -0.180f, 0.f}, {-1.000f, 0.000f, 0.f}, {1.00f, 0.f}} }; -void TTrack::Compile(GLuint tex) -{ // generowanie treści dla Display Lists - model proceduralny - if (!tex) - { // jeśli nie podana tekstura, to każdy tor ma wlasne DL - if (DisplayListID) - Release(); // zwolnienie zasobów w celu ponownego utworzenia - if (Global::bManageNodes) - { - DisplayListID = glGenLists(1); // otwarcie nowej listy - glNewList(DisplayListID, GL_COMPILE); - }; - } - glColor3f(1.0f, 1.0f, 1.0f); // to tutaj potrzebne? - // Ra: nie zmieniamy oświetlenia przy kompilowaniu, ponieważ ono się zmienia w czasie! - // trochę podliczonych zmiennych, co się potem przydadzą - double fHTW = 0.5 * fabs(fTrackWidth); // połowa szerokości - double side = fabs(fTexWidth); // szerokść podsypki na zewnątrz szyny albo pobocza - double slop = fabs(fTexSlope); // szerokość pochylenia - double rozp = fHTW + side + slop; // brzeg zewnętrzny - double hypot1 = hypot(slop, fTexHeight1); // rozmiar pochylenia do liczenia normalnych - if (hypot1 == 0.0) - hypot1 = 1.0; - vector3 normal1 = vector3(fTexSlope / hypot1, fTexHeight1 / hypot1, 0.0); // wektor normalny - double fHTW2, side2, slop2, rozp2, fTexHeight2, hypot2; - vector3 normal2; - if (iTrapezoid & 2) // ten bit oznacza, że istnieje odpowiednie pNext - { // Ra: jest OK - fHTW2 = 0.5 * fabs(trNext->fTrackWidth); // połowa rozstawu/nawierzchni - side2 = fabs(trNext->fTexWidth); - slop2 = fabs(trNext->fTexSlope); - rozp2 = fHTW2 + side2 + slop2; // szerokość podstawy - fTexHeight2 = trNext->fTexHeight1; - hypot2 = hypot(slop2, fTexHeight2); - if (hypot2 == 0.0) - hypot2 = 1.0; - normal2 = vector3(trNext->fTexSlope / hypot2, fTexHeight2 / hypot2, 0.0); - } - else // gdy nie ma następnego albo jest nieodpowiednim końcem podpięty - { - fHTW2 = fHTW; - side2 = side; - slop2 = slop; - rozp2 = rozp; - fTexHeight2 = fTexHeight1; - hypot2 = hypot1; - normal2 = normal1; - } - double roll1, roll2; - switch (iCategoryFlag & 15) - { - case 1: // tor - { - Segment->GetRolls(roll1, roll2); - double sin1 = sin(roll1), cos1 = cos(roll1), sin2 = sin(roll2), cos2 = cos(roll2); - // zwykla szyna: //Ra: czemu główki są asymetryczne na wysokości 0.140? - vector6 rpts1[24], rpts2[24], rpts3[24], rpts4[24]; - int i; - for (i = 0; i < 12; ++i) - { - rpts1[i] = vector6((fHTW + szyna[i].x) * cos1 + szyna[i].y * sin1, - -(fHTW + szyna[i].x) * sin1 + szyna[i].y * cos1, szyna[i].z, - +szyna[i].n.x * cos1 + szyna[i].n.y * sin1, - -szyna[i].n.x * sin1 + szyna[i].n.y * cos1, 0.0); - rpts2[11 - i] = vector6((-fHTW - szyna[i].x) * cos1 + szyna[i].y * sin1, - -(-fHTW - szyna[i].x) * sin1 + szyna[i].y * cos1, szyna[i].z, - -szyna[i].n.x * cos1 + szyna[i].n.y * sin1, - +szyna[i].n.x * sin1 + szyna[i].n.y * cos1, 0.0); - } - if (iTrapezoid) // jak trapez albo przechyłki, to oddzielne punkty na końcu - for (i = 0; i < 12; ++i) - { - rpts1[12 + i] = vector6((fHTW2 + szyna[i].x) * cos2 + szyna[i].y * sin2, - -(fHTW2 + szyna[i].x) * sin2 + szyna[i].y * cos2, - szyna[i].z, +szyna[i].n.x * cos2 + szyna[i].n.y * sin2, - -szyna[i].n.x * sin2 + szyna[i].n.y * cos2, 0.0); - rpts2[23 - i] = vector6((-fHTW2 - szyna[i].x) * cos2 + szyna[i].y * sin2, - -(-fHTW2 - szyna[i].x) * sin2 + szyna[i].y * cos2, - szyna[i].z, -szyna[i].n.x * cos2 + szyna[i].n.y * sin2, - +szyna[i].n.x * sin2 + szyna[i].n.y * cos2, 0.0); - } - switch (eType) // dalej zależnie od typu - { - case tt_Table: // obrotnica jak zwykły tor, animacja wykonywana w RaAnimate(), tutaj tylko - // regeneracja siatek - case tt_Normal: - if (TextureID2) - if (tex ? TextureID2 == tex : true) // jeśli pasuje do grupy (tex) - { // podsypka z podkładami jest tylko dla zwykłego toru - vector6 - bpts1[8]; // punkty głównej płaszczyzny nie przydają się do robienia boków - if (fTexLength == - 4.0) // jeśli stare mapowanie na profil 0.2 0.5 1.1 (również 6-9-9/noil) - { // stare mapowanie z różną gęstością pikseli i oddzielnymi teksturami na każdy - // profil - if (iTrapezoid) // trapez albo przechyłki - { // podsypka z podkladami trapezowata - // ewentualnie poprawić mapowanie, żeby środek mapował się na - // 1.435/4.671 ((0.3464,0.6536) - // bo się tekstury podsypki rozjeżdżają po zmianie proporcji profilu - bpts1[0] = vector6(rozp, -fTexHeight1 - 0.18, 0.00, normal1.x, - -normal1.y, 0.0); // lewy brzeg - bpts1[1] = vector6((fHTW + side) * cos1, -(fHTW + side) * sin1 - 0.18, - 0.33, 0.0, 1.0, 0.0); // krawędź załamania - bpts1[2] = - vector6(-bpts1[1].x, +(fHTW + side) * sin1 - 0.18, 0.67, -normal1.x, - -normal1.y, 0.0); // prawy brzeg początku symetrycznie - bpts1[3] = vector6(-rozp, -fTexHeight1 - 0.18, 1.00, -normal1.x, - -normal1.y, 0.0); // prawy skos - // przekrój końcowy - bpts1[4] = vector6(rozp2, -fTexHeight2 - 0.18, 0.00, normal2.x, - -normal2.y, 0.0); // lewy brzeg - bpts1[5] = - vector6((fHTW2 + side2) * cos2, -(fHTW2 + side2) * sin2 - 0.18, - 0.33, 0.0, 1.0, 0.0); // krawędź załamania - bpts1[6] = vector6(-bpts1[5].x, +(fHTW2 + side2) * sin2 - 0.18, 0.67, - 0.0, 1.0, 0.0); // prawy brzeg początku symetrycznie - bpts1[7] = vector6(-rozp2, -fTexHeight2 - 0.18, 1.00, -normal2.x, - -normal2.y, 0.0); // prawy skos - } - else - { - bpts1[0] = vector6(rozp, -fTexHeight1 - 0.18, 0.0, +normal1.x, - -normal1.y, 0.0); // lewy brzeg - bpts1[1] = vector6(fHTW + side, -0.18, 0.33, +normal1.x, -normal1.y, - 0.0); // krawędź załamania - bpts1[2] = vector6(-fHTW - side, -0.18, 0.67, -normal1.x, -normal1.y, - 0.0); // druga - bpts1[3] = vector6(-rozp, -fTexHeight1 - 0.18, 1.0, -normal1.x, - -normal1.y, 0.0); // prawy skos - } - } - else - { // mapowanie proporcjonalne do powierzchni, rozmiar w poprzek określa - // fTexLength - double max = fTexRatio2 * fTexLength; // szerokość proporcjonalna do - // długości - double map11 = - max > 0.0 ? (fHTW + side) / max : 0.25; // załamanie od strony 1 - double map12 = - max > 0.0 ? (fHTW + side + hypot1) / max : 0.5; // brzeg od strony 1 - if (iTrapezoid) // trapez albo przechyłki - { // podsypka z podkladami trapezowata - double map21 = - max > 0.0 ? (fHTW2 + side2) / max : 0.25; // załamanie od strony 2 - double map22 = max > 0.0 ? (fHTW2 + side2 + hypot2) / max : - 0.5; // brzeg od strony 2 - // ewentualnie poprawić mapowanie, żeby środek mapował się na - // 1.435/4.671 ((0.3464,0.6536) - // bo się tekstury podsypki rozjeżdżają po zmianie proporcji profilu - bpts1[0] = vector6(rozp, -fTexHeight1 - 0.18, 0.5 - map12, normal1.x, - -normal1.y, 0.0); // lewy brzeg - bpts1[1] = vector6((fHTW + side) * cos1, -(fHTW + side) * sin1 - 0.18, - 0.5 - map11, 0.0, 1.0, 0.0); // krawędź załamania - bpts1[2] = - vector6(-bpts1[1].x, +(fHTW + side) * sin1 - 0.18, 0.5 + map11, 0.0, - 1.0, 0.0); // prawy brzeg początku symetrycznie - bpts1[3] = vector6(-rozp, -fTexHeight1 - 0.18, 0.5 + map12, -normal1.x, - -normal1.y, 0.0); // prawy skos - // przekrój końcowy - bpts1[4] = vector6(rozp2, -fTexHeight2 - 0.18, 0.5 - map22, normal2.x, - -normal2.y, 0.0); // lewy brzeg - bpts1[5] = - vector6((fHTW2 + side2) * cos2, -(fHTW2 + side2) * sin2 - 0.18, - 0.5 - map21, 0.0, 1.0, 0.0); // krawędź załamania - bpts1[6] = - vector6(-bpts1[5].x, +(fHTW2 + side2) * sin2 - 0.18, 0.5 + map21, - 0.0, 1.0, 0.0); // prawy brzeg początku symetrycznie - bpts1[7] = vector6(-rozp2, -fTexHeight2 - 0.18, 0.5 + map22, -normal2.x, - -normal2.y, 0.0); // prawy skos - } - else - { - bpts1[0] = vector6(rozp, -fTexHeight1 - 0.18, 0.5 - map12, +normal1.x, - -normal1.y, 0.0); // lewy brzeg - bpts1[1] = vector6(fHTW + side, -0.18, 0.5 - map11, +normal1.x, - -normal1.y, 0.0); // krawędź załamania - bpts1[2] = vector6(-fHTW - side, -0.18, 0.5 + map11, -normal1.x, - -normal1.y, 0.0); // druga - bpts1[3] = vector6(-rozp, -fTexHeight1 - 0.18, 0.5 + map12, -normal1.x, - -normal1.y, 0.0); // prawy skos - } - } - if (!tex) - TextureManager.Bind( TextureID2 ); - Segment->RenderLoft(bpts1, iTrapezoid ? -4 : 4, fTexLength); - } - if (TextureID1) - if (tex ? TextureID1 == tex : true) // jeśli pasuje do grupy (tex) - { // szyny - if (!tex) - TextureManager.Bind( TextureID1 ); - Segment->RenderLoft(rpts1, iTrapezoid ? -nnumPts : nnumPts, fTexLength); - Segment->RenderLoft(rpts2, iTrapezoid ? -nnumPts : nnumPts, fTexLength); - } - break; - case tt_Switch: // dla zwrotnicy dwa razy szyny - if (TextureID1) // zwrotnice nie są grupowane, aby prościej było je animować - { // iglice liczone tylko dla zwrotnic - // Ra: TODO: oddzielna animacja każdej iglicy, opór na docisku - vector6 rpts3[24], rpts4[24]; - for (i = 0; i < 12; ++i) - { - rpts3[i] = vector6((fHTW + iglica[i].x) * cos1 + iglica[i].y * sin1, - -(fHTW + iglica[i].x) * sin1 + iglica[i].y * cos1, - iglica[i].z, +iglica[i].n.x * cos1 + iglica[i].n.y * sin1, - -iglica[i].n.x * sin1 + iglica[i].n.y * cos1, 0.0); - rpts4[11 - i] = - vector6((-fHTW - iglica[i].x) * cos1 + iglica[i].y * sin1, - -(-fHTW - iglica[i].x) * sin1 + iglica[i].y * cos1, iglica[i].z, - -iglica[i].n.x * cos1 + iglica[i].n.y * sin1, - +iglica[i].n.x * sin1 + iglica[i].n.y * cos1, 0.0); - } - if (iTrapezoid) // trapez albo przechyłki, to oddzielne punkty na końcu - for (i = 0; i < 12; ++i) - { - rpts3[12 + i] = - vector6((fHTW2 + iglica[i].x) * cos2 + iglica[i].y * sin2, - -(fHTW2 + iglica[i].x) * sin2 + iglica[i].y * cos2, iglica[i].z, - +iglica[i].n.x * cos2 + iglica[i].n.y * sin2, - -iglica[i].n.x * sin2 + iglica[i].n.y * cos2, 0.0); - rpts4[23 - i] = - vector6((-fHTW2 - iglica[i].x) * cos2 + iglica[i].y * sin2, - -(-fHTW2 - iglica[i].x) * sin2 + iglica[i].y * cos2, - iglica[i].z, -iglica[i].n.x * cos2 + iglica[i].n.y * sin2, - +iglica[i].n.x * sin2 + iglica[i].n.y * cos2, 0.0); - } - // McZapkie-130302 - poprawione rysowanie szyn - if (SwitchExtension->RightSwitch) - { // zwrotnica prawa - TextureManager.Bind( TextureID1 ); - SwitchExtension->Segments[0]->RenderLoft(rpts1, nnumPts, fTexLength, - 2); // prawa szyna za iglicą - SwitchExtension->Segments[0]->RenderSwitchRail( - rpts1, rpts3, nnumPts, fTexLength, 2, - SwitchExtension->fOffset2); // prawa iglica - SwitchExtension->Segments[0]->RenderLoft( - rpts2, nnumPts, fTexLength); // lewa szyna normalnie cała - if (TextureID2 != TextureID1) // nie wiadomo, czy OpenGL to optymalizuje - TextureManager.Bind( TextureID2 ); - SwitchExtension->Segments[1]->RenderLoft( - rpts1, nnumPts, fTexLength); // prawa szyna normalna cała - SwitchExtension->Segments[1]->RenderLoft(rpts2, nnumPts, fTexLength, - 2); // lewa szyna za iglicą - SwitchExtension->Segments[1]->RenderSwitchRail( - rpts2, rpts4, nnumPts, fTexLength, 2, - -fMaxOffset + SwitchExtension->fOffset1); // lewa iglica - } - else - { // lewa kiedyś działała lepiej niż prawa - TextureManager.Bind( TextureID1 ); - SwitchExtension->Segments[0]->RenderLoft( - rpts1, nnumPts, fTexLength); // prawa szyna normalna cała - SwitchExtension->Segments[0]->RenderLoft(rpts2, nnumPts, fTexLength, - 2); // lewa szyna za iglicą - SwitchExtension->Segments[0]->RenderSwitchRail( - rpts2, rpts4, nnumPts, fTexLength, 2, - -SwitchExtension->fOffset2); // lewa iglica - if (TextureID2 != TextureID1) // nie wiadomo, czy OpenGL to optymalizuje - TextureManager.Bind( TextureID2 ); - SwitchExtension->Segments[1]->RenderLoft(rpts1, nnumPts, fTexLength, - 2); // prawa szyna za iglicą - SwitchExtension->Segments[1]->RenderSwitchRail( - rpts1, rpts3, nnumPts, fTexLength, 2, - fMaxOffset - SwitchExtension->fOffset1); // prawa iglica - SwitchExtension->Segments[1]->RenderLoft( - rpts2, nnumPts, fTexLength); // lewa szyna normalnie cała - } - } - break; - } - } // koniec obsługi torów - break; - case 2: // McZapkie-260302 - droga - rendering - // McZapkie:240702-zmieniony zakres widzialnosci - switch (eType) // dalej zależnie od typu - { - case tt_Normal: // drogi proste, bo skrzyżowania osobno - { - vector6 bpts1[4]; // punkty głównej płaszczyzny przydają się do robienia boków - if (TextureID1 || TextureID2) // punkty się przydadzą, nawet jeśli nawierzchni nie ma - { // double max=2.0*(fHTW>fHTW2?fHTW:fHTW2); //z szerszej strony jest 100% - double max = fTexRatio1 * fTexLength; // test: szerokość proporcjonalna do długości - double map1 = max > 0.0 ? fHTW / max : 0.5; // obcięcie tekstury od strony 1 - double map2 = max > 0.0 ? fHTW2 / max : 0.5; // obcięcie tekstury od strony 2 - if (iTrapezoid) // trapez albo przechyłki - { // nawierzchnia trapezowata - Segment->GetRolls(roll1, roll2); - bpts1[0] = vector6(fHTW * cos(roll1), -fHTW * sin(roll1), 0.5 - map1, - sin(roll1), cos(roll1), 0.0); // lewy brzeg początku - bpts1[1] = vector6(-bpts1[0].x, -bpts1[0].y, 0.5 + map1, -sin(roll1), - cos(roll1), 0.0); // prawy brzeg początku symetrycznie - bpts1[2] = vector6(fHTW2 * cos(roll2), -fHTW2 * sin(roll2), 0.5 - map2, - sin(roll2), cos(roll2), 0.0); // lewy brzeg końca - bpts1[3] = vector6(-bpts1[2].x, -bpts1[2].y, 0.5 + map2, -sin(roll2), - cos(roll2), 0.0); // prawy brzeg początku symetrycznie - } - else - { - bpts1[0] = vector6(fHTW, 0.0, 0.5 - map1, 0.0, 1.0, 0.0); - bpts1[1] = vector6(-fHTW, 0.0, 0.5 + map1, 0.0, 1.0, 0.0); - } - } - if (TextureID1) // jeśli podana była tekstura, generujemy trójkąty - if (tex ? TextureID1 == tex : true) // jeśli pasuje do grupy (tex) - { // tworzenie trójkątów nawierzchni szosy - if (!tex) - TextureManager.Bind( TextureID1 ); - Segment->RenderLoft(bpts1, iTrapezoid ? -2 : 2, fTexLength); - } - if (TextureID2) - if (tex ? TextureID2 == tex : true) // jeśli pasuje do grupy (tex) - { // pobocze drogi - poziome przy przechyłce (a może krawężnik i chodnik zrobić jak - // w Midtown Madness 2?) - if (!tex) - TextureManager.Bind( TextureID2 ); - vector6 rpts1[6], - rpts2[6]; // współrzędne przekroju i mapowania dla prawej i lewej strony - if (fTexHeight1 >= 0.0) - { // standardowo: od zewnątrz pochylenie, a od wewnątrz poziomo - rpts1[0] = vector6(rozp, -fTexHeight1, 0.0); // lewy brzeg podstawy - rpts1[1] = - vector6(bpts1[0].x + side, bpts1[0].y, 0.5); // lewa krawędź załamania - rpts1[2] = vector6(bpts1[0].x, bpts1[0].y, - 1.0); // lewy brzeg pobocza (mapowanie może być inne - rpts2[0] = vector6(bpts1[1].x, bpts1[1].y, 1.0); // prawy brzeg pobocza - rpts2[1] = - vector6(bpts1[1].x - side, bpts1[1].y, 0.5); // prawa krawędź załamania - rpts2[2] = vector6(-rozp, -fTexHeight1, 0.0); // prawy brzeg podstawy - if (iTrapezoid) // trapez albo przechyłki - { // pobocza do trapezowatej nawierzchni - dodatkowe punkty z drugiej strony - // odcinka - rpts1[3] = - vector6(rozp2, -fTexHeight2, 0.0); // lewy brzeg lewego pobocza - rpts1[4] = - vector6(bpts1[2].x + side2, bpts1[2].y, 0.5); // krawędź załamania - rpts1[5] = vector6(bpts1[2].x, bpts1[2].y, 1.0); // brzeg pobocza - rpts2[3] = vector6(bpts1[3].x, bpts1[3].y, 1.0); - rpts2[4] = vector6(bpts1[3].x - side2, bpts1[3].y, 0.5); - rpts2[5] = - vector6(-rozp2, -fTexHeight2, 0.0); // prawy brzeg prawego pobocza - } - } - else - { // wersja dla chodnika: skos 1:3.75, każdy chodnik innej szerokości - // mapowanie propocjonalne do szerokości chodnika - // krawężnik jest mapowany od 31/64 do 32/64 lewy i od 32/64 do 33/64 prawy - double d = - -fTexHeight1 / 3.75; // krawężnik o wysokości 150mm jest pochylony 40mm - double max = - fTexRatio2 * fTexLength; // test: szerokość proporcjonalna do długości - double map1l = max > 0.0 ? - side / max : - 0.484375; // obcięcie tekstury od lewej strony punktu 1 - double map1r = max > 0.0 ? - slop / max : - 0.484375; // obcięcie tekstury od prawej strony punktu 1 - rpts1[0] = vector6(bpts1[0].x + slop, bpts1[0].y - fTexHeight1, - 0.515625 + map1r); // prawy brzeg prawego chodnika - rpts1[1] = vector6(bpts1[0].x + d, bpts1[0].y - fTexHeight1, - 0.515625); // prawy krawężnik u góry - rpts1[2] = vector6(bpts1[0].x, bpts1[0].y, - 0.515625 - d / 2.56); // prawy krawężnik u dołu - rpts2[0] = vector6(bpts1[1].x, bpts1[1].y, - 0.484375 + d / 2.56); // lewy krawężnik u dołu - rpts2[1] = vector6(bpts1[1].x - d, bpts1[1].y - fTexHeight1, - 0.484375); // lewy krawężnik u góry - rpts2[2] = vector6(bpts1[1].x - side, bpts1[1].y - fTexHeight1, - 0.484375 - map1l); // lewy brzeg lewego chodnika - if (iTrapezoid) // trapez albo przechyłki - { // pobocza do trapezowatej nawierzchni - dodatkowe punkty z drugiej strony - // odcinka - slop2 = fabs((iTrapezoid & 2) ? slop2 : - slop); // szerokość chodnika po prawej - double map2l = - max > 0.0 ? side2 / max : - 0.484375; // obcięcie tekstury od lewej strony punktu 2 - double map2r = - max > 0.0 ? slop2 / max : - 0.484375; // obcięcie tekstury od prawej strony punktu 2 - rpts1[3] = vector6(bpts1[2].x + slop2, bpts1[2].y - fTexHeight2, - 0.515625 + map2r); // prawy brzeg prawego chodnika - rpts1[4] = vector6(bpts1[2].x + d, bpts1[2].y - fTexHeight2, - 0.515625); // prawy krawężnik u góry - rpts1[5] = vector6(bpts1[2].x, bpts1[2].y, - 0.515625 - d / 2.56); // prawy krawężnik u dołu - rpts2[3] = vector6(bpts1[3].x, bpts1[3].y, - 0.484375 + d / 2.56); // lewy krawężnik u dołu - rpts2[4] = vector6(bpts1[3].x - d, bpts1[3].y - fTexHeight2, - 0.484375); // lewy krawężnik u góry - rpts2[5] = vector6(bpts1[3].x - side2, bpts1[3].y - fTexHeight2, - 0.484375 - map2l); // lewy brzeg lewego chodnika - } - } - if (iTrapezoid) // trapez albo przechyłki - { // pobocza do trapezowatej nawierzchni - dodatkowe punkty z drugiej strony - // odcinka - if ((fTexHeight1 >= 0.0) ? true : (slop != 0.0)) - Segment->RenderLoft(rpts1, -3, fTexLength); // tylko jeśli jest z prawej - if ((fTexHeight1 >= 0.0) ? true : (side != 0.0)) - Segment->RenderLoft(rpts2, -3, fTexLength); // tylko jeśli jest z lewej - } - else - { // pobocza zwykłe, brak przechyłki - if ((fTexHeight1 >= 0.0) ? true : (slop != 0.0)) - Segment->RenderLoft(rpts1, 3, fTexLength); - if ((fTexHeight1 >= 0.0) ? true : (side != 0.0)) - Segment->RenderLoft(rpts2, 3, fTexLength); - } - } - break; - } - case tt_Cross: // skrzyżowanie dróg rysujemy inaczej - { // ustalenie współrzędnych środka - przecięcie Point1-Point2 z CV4-Point4 - double a[4]; // kąty osi ulic wchodzących - vector3 p[4]; // punkty się przydadzą do obliczeń - // na razie połowa odległości pomiędzy Point1 i Point2, potem się dopracuje - a[0] = a[1] = 0.5; // parametr do poszukiwania przecięcia łuków - // modyfikować a[0] i a[1] tak, aby trafić na przecięcie odcinka 34 - p[0] = SwitchExtension->Segments[0]->FastGetPoint( - a[0]); // współrzędne środka pierwszego odcinka - p[1] = SwitchExtension->Segments[1]->FastGetPoint(a[1]); //-//- drugiego - // p[2]=p[1]-p[0]; //jeśli różne od zera, przeliczyć a[0] i a[1] i wyznaczyć nowe punkty - vector3 oxz = p[0]; // punkt mapowania środka tekstury skrzyżowania - p[0] = SwitchExtension->Segments[0] - ->GetDirection1(); // Point1 - pobranie wektorów kontrolnych - p[1] = SwitchExtension->Segments[1]->GetDirection2(); // Point3 (bo zamienione) - p[2] = SwitchExtension->Segments[0]->GetDirection2(); // Point2 - p[3] = SwitchExtension->Segments[1]->GetDirection1(); // Point4 (bo zamienione) - a[0] = atan2(-p[0].x, p[0].z); // kąty stycznych osi dróg - a[1] = atan2(-p[1].x, p[1].z); - a[2] = atan2(-p[2].x, p[2].z); - a[3] = atan2(-p[3].x, p[3].z); - p[0] = SwitchExtension->Segments[0] - ->FastGetPoint_0(); // Point1 - pobranie współrzędnych końców - p[1] = SwitchExtension->Segments[1]->FastGetPoint_1(); // Point3 - p[2] = SwitchExtension->Segments[0]->FastGetPoint_1(); // Point2 - p[3] = SwitchExtension->Segments[1] - ->FastGetPoint_0(); // Point4 - przy trzech drogach pokrywa się z Point1 - // 2014-07: na początek rysować brzegi jak dla łuków - // punkty brzegu nawierzchni uzyskujemy podczas renderowania boków (bez sensu, ale - // najszybciej było zrobić) - int i, j; // ile punktów (może byc różna ilość punktów między drogami) - if (!SwitchExtension->vPoints) - { // jeśli tablica punktów nie jest jeszcze utworzona, zliczamy punkty i tworzymy ją - if (SwitchExtension->iRoads == 3) // mogą być tylko 3 drogi zamiast 4 - SwitchExtension->iPoints = 5 + SwitchExtension->Segments[0]->RaSegCount() + - SwitchExtension->Segments[1]->RaSegCount() + - SwitchExtension->Segments[2]->RaSegCount(); - else - SwitchExtension->iPoints = - 5 + SwitchExtension->Segments[2]->RaSegCount() + - SwitchExtension->Segments[3]->RaSegCount() + - SwitchExtension->Segments[4]->RaSegCount() + - SwitchExtension->Segments[5]->RaSegCount(); // mogą być tylko 3 drogi - SwitchExtension->vPoints = - new vector3[SwitchExtension->iPoints]; // tablica utworzona z zapasem, ale nie - // wypełniona współrzędnymi - } - vector3 *b = - SwitchExtension->bPoints ? - NULL : - SwitchExtension - ->vPoints; // zmienna robocza, NULL gdy tablica punktów już jest wypełniona - vector6 bpts1[4]; // punkty głównej płaszczyzny przydają się do robienia boków - if (TextureID1 || TextureID2) // punkty się przydadzą, nawet jeśli nawierzchni nie ma - { // double max=2.0*(fHTW>fHTW2?fHTW:fHTW2); //z szerszej strony jest 100% - double max = fTexRatio1 * fTexLength; // test: szerokość proporcjonalna do długości - double map1 = max > 0.0 ? fHTW / max : 0.5; // obcięcie tekstury od strony 1 - double map2 = max > 0.0 ? fHTW2 / max : 0.5; // obcięcie tekstury od strony 2 - // if (iTrapezoid) //trapez albo przechyłki - { // nawierzchnia trapezowata - Segment->GetRolls(roll1, roll2); - bpts1[0] = vector6(fHTW * cos(roll1), -fHTW * sin(roll1), 0.5 - map1, - sin(roll1), cos(roll1), 0.0); // lewy brzeg początku - bpts1[1] = vector6(-bpts1[0].x, -bpts1[0].y, 0.5 + map1, -sin(roll1), - cos(roll1), 0.0); // prawy brzeg początku symetrycznie - bpts1[2] = vector6(fHTW2 * cos(roll2), -fHTW2 * sin(roll2), 0.5 - map2, - sin(roll2), cos(roll2), 0.0); // lewy brzeg końca - bpts1[3] = vector6(-bpts1[2].x, -bpts1[2].y, 0.5 + map2, -sin(roll2), - cos(roll2), 0.0); // prawy brzeg początku symetrycznie - } - } - // najpierw renderowanie poboczy i zapamiętywanie punktów - // problem ze skrzyżowaniami jest taki, że teren chce się pogrupować wg tekstur, ale - // zaczyna od nawierzchni - // sama nawierzchnia nie wypełni tablicy punktów, bo potrzebne są pobocza - // ale pobocza renderują się później, więc nawierzchnia nie załapuje się na renderowanie - // w swoim czasie - // if (TextureID2) - // if (tex?TextureID2==tex:true) //jeśli pasuje do grupy (tex) - { // pobocze drogi - poziome przy przechyłce (a może krawężnik i chodnik zrobić jak w - // Midtown Madness 2?) - if (TextureID2) - if (!tex) - TextureManager.Bind( TextureID2 ); - vector6 rpts1[6], - rpts2[6]; // współrzędne przekroju i mapowania dla prawej i lewej strony - // Ra 2014-07: trzeba to przerobić na pętlę i pobierać profile (przynajmniej 2..4) z - // sąsiednich dróg - if (fTexHeight1 >= 0.0) - { // standardowo: od zewnątrz pochylenie, a od wewnątrz poziomo - rpts1[0] = vector6(rozp, -fTexHeight1, 0.0); // lewy brzeg podstawy - rpts1[1] = vector6(bpts1[0].x + side, bpts1[0].y, 0.5); // lewa krawędź - // załamania - rpts1[2] = vector6(bpts1[0].x, bpts1[0].y, - 1.0); // lewy brzeg pobocza (mapowanie może być inne - rpts2[0] = vector6(bpts1[1].x, bpts1[1].y, 1.0); // prawy brzeg pobocza - rpts2[1] = - vector6(bpts1[1].x - side, bpts1[1].y, 0.5); // prawa krawędź załamania - rpts2[2] = vector6(-rozp, -fTexHeight1, 0.0); // prawy brzeg podstawy - // if (iTrapezoid) //trapez albo przechyłki - { // pobocza do trapezowatej nawierzchni - dodatkowe punkty z drugiej strony - // odcinka - rpts1[3] = vector6(rozp2, -fTexHeight2, 0.0); // lewy brzeg lewego pobocza - rpts1[4] = vector6(bpts1[2].x + side2, bpts1[2].y, 0.5); // krawędź - // załamania - rpts1[5] = vector6(bpts1[2].x, bpts1[2].y, 1.0); // brzeg pobocza - rpts2[3] = vector6(bpts1[3].x, bpts1[3].y, 1.0); - rpts2[4] = vector6(bpts1[3].x - side2, bpts1[3].y, 0.5); - rpts2[5] = vector6(-rozp2, -fTexHeight2, 0.0); // prawy brzeg prawego - // pobocza - } - } - else - { // wersja dla chodnika: skos 1:3.75, każdy chodnik innej szerokości - // mapowanie propocjonalne do szerokości chodnika - // krawężnik jest mapowany od 31/64 do 32/64 lewy i od 32/64 do 33/64 prawy - double d = - -fTexHeight1 / 3.75; // krawężnik o wysokości 150mm jest pochylony 40mm - double max = - fTexRatio2 * fTexLength; // test: szerokość proporcjonalna do długości - double map1l = max > 0.0 ? - side / max : - 0.484375; // obcięcie tekstury od lewej strony punktu 1 - double map1r = max > 0.0 ? - slop / max : - 0.484375; // obcięcie tekstury od prawej strony punktu 1 - rpts1[0] = vector6(bpts1[0].x + slop, bpts1[0].y - fTexHeight1, - 0.515625 + map1r); // prawy brzeg prawego chodnika - rpts1[1] = vector6(bpts1[0].x + d, bpts1[0].y - fTexHeight1, - 0.515625); // prawy krawężnik u góry - rpts1[2] = vector6(bpts1[0].x, bpts1[0].y, - 0.515625 - d / 2.56); // prawy krawężnik u dołu - rpts2[0] = vector6(bpts1[1].x, bpts1[1].y, - 0.484375 + d / 2.56); // lewy krawężnik u dołu - rpts2[1] = vector6(bpts1[1].x - d, bpts1[1].y - fTexHeight1, - 0.484375); // lewy krawężnik u góry - rpts2[2] = vector6(bpts1[1].x - side, bpts1[1].y - fTexHeight1, - 0.484375 - map1l); // lewy brzeg lewego chodnika - // if (iTrapezoid) //trapez albo przechyłki - { // pobocza do trapezowatej nawierzchni - dodatkowe punkty z drugiej strony - // odcinka - slop2 = - fabs((iTrapezoid & 2) ? slop2 : slop); // szerokość chodnika po prawej - double map2l = max > 0.0 ? - side2 / max : - 0.484375; // obcięcie tekstury od lewej strony punktu 2 - double map2r = max > 0.0 ? - slop2 / max : - 0.484375; // obcięcie tekstury od prawej strony punktu 2 - rpts1[3] = vector6(bpts1[2].x + slop2, bpts1[2].y - fTexHeight2, - 0.515625 + map2r); // prawy brzeg prawego chodnika - rpts1[4] = vector6(bpts1[2].x + d, bpts1[2].y - fTexHeight2, - 0.515625); // prawy krawężnik u góry - rpts1[5] = vector6(bpts1[2].x, bpts1[2].y, - 0.515625 - d / 2.56); // prawy krawężnik u dołu - rpts2[3] = vector6(bpts1[3].x, bpts1[3].y, - 0.484375 + d / 2.56); // lewy krawężnik u dołu - rpts2[4] = vector6(bpts1[3].x - d, bpts1[3].y - fTexHeight2, - 0.484375); // lewy krawężnik u góry - rpts2[5] = vector6(bpts1[3].x - side2, bpts1[3].y - fTexHeight2, - 0.484375 - map2l); // lewy brzeg lewego chodnika - } - } - bool render = TextureID2 ? (tex ? TextureID2 == tex : true) : - false; // renderować nie trzeba, ale trzeba wyznaczyć - // punkty brzegowe nawierzchni - // if (iTrapezoid) //trapez albo przechyłki - if (SwitchExtension->iRoads == 4) - { // pobocza do trapezowatej nawierzchni - dodatkowe punkty z drugiej strony odcinka - if ((fTexHeight1 >= 0.0) ? true : (side != 0.0)) - SwitchExtension->Segments[2]->RenderLoft( - rpts2, -3, fTexLength, 0, 1, &b, render); // tylko jeśli jest z lewej - if ((fTexHeight1 >= 0.0) ? true : (side != 0.0)) - SwitchExtension->Segments[3]->RenderLoft( - rpts2, -3, fTexLength, 0, 1, &b, render); // tylko jeśli jest z lewej - if ((fTexHeight1 >= 0.0) ? true : (side != 0.0)) - SwitchExtension->Segments[4]->RenderLoft( - rpts2, -3, fTexLength, 0, 1, &b, render); // tylko jeśli jest z lewej - if ((fTexHeight1 >= 0.0) ? true : (side != 0.0)) - SwitchExtension->Segments[5]->RenderLoft( - rpts2, -3, fTexLength, 0, 1, &b, render); // tylko jeśli jest z lewej - } - else // to będzie ewentualnie dla prostego na skrzyżowaniu trzech dróg - { // punkt 3 pokrywa się z punktem 1, jak w zwrotnicy; połączenie 1->2 nie musi być - // prostoliniowe - if ((fTexHeight1 >= 0.0) ? true : (side != 0.0)) // OK - SwitchExtension->Segments[2]->RenderLoft(rpts2, -3, fTexLength, 0, 1, &b, - render); // z P2 do P4 - if ((fTexHeight1 >= 0.0) ? true : (side != 0.0)) // OK - SwitchExtension->Segments[1]->RenderLoft( - rpts2, -3, fTexLength, 0, 1, &b, render); // z P4 do P3=P1 (odwrócony) - if ((fTexHeight1 >= 0.0) ? true : (side != 0.0)) // OK - SwitchExtension->Segments[0]->RenderLoft(rpts2, -3, fTexLength, 0, 1, &b, - render); // z P1 do P2 - /* - if ((fTexHeight1>=0.0)?true:(slop!=0.0)) - Segment->RenderLoft(rpts1,3,fTexLength); - if ((fTexHeight1>=0.0)?true:(side!=0.0)) - Segment->RenderLoft(rpts2,3,fTexLength); - */ - } - } - // renderowanie nawierzchni na końcu - double sina0 = sin(a[0]), cosa0 = cos(a[0]); - double u, v; - if (!SwitchExtension->bPoints) // jeśli tablica nie wypełniona - if (b) // ale jest wskaźnik do tablicy - może nie być? - { // coś się gubi w obliczeniach na wskaźnikach - i = (int((void *)(b)) - int((void *)(SwitchExtension->vPoints))) / - sizeof(vector3); // ustalenie liczby punktów, bo mogło wyjść inaczej niż - // policzone z góry - if (i > 0) - { // jeśli zostało to właśnie utworzone - if (SwitchExtension->iPoints > i) // jeśli wyszło mniej niż było miejsca - SwitchExtension->iPoints = i; // domknięcie wachlarza - else - --SwitchExtension->iPoints; // jak tutaj wejdzie, to błąd jest - zrobić - // miejsce na powtórzenie pierwszego punktu - // na końcu - SwitchExtension->vPoints[SwitchExtension->iPoints++] = - SwitchExtension->vPoints[0]; - SwitchExtension->bPoints = true; // tablica punktów została wypełniona - } - } - if (TextureID1) // jeśli podana tekstura nawierzchni - if (tex ? TextureID1 == tex : true) // jeśli pasuje do grupy (tex) - { - if (!tex) - TextureManager.Bind( TextureID1 ); - glBegin(GL_TRIANGLE_FAN); // takie kółeczko będzie - glNormal3f(0, 1, 0); - glTexCoord2f(0.5, 0.5); //środek tekstury na środku skrzyżowania - glVertex3f(oxz.x, oxz.y, oxz.z); - for (i = SwitchExtension->iPoints - 1; i >= 0; --i) - // for (i=0;iiPoints;++i) - { - glNormal3f(0, 1, 0); - u = (SwitchExtension->vPoints[i].x - oxz.x) / - fTexLength; // mapowanie we współrzędnych scenerii - v = (SwitchExtension->vPoints[i].z - oxz.z) / (fTexRatio1 * fTexLength); - glTexCoord2f(cosa0 * u + sina0 * v + 0.5, -sina0 * u + cosa0 * v + 0.5); - glVertex3f(SwitchExtension->vPoints[i].x, SwitchExtension->vPoints[i].y, - SwitchExtension->vPoints[i].z); - } - glEnd(); - } - break; - } - } - break; - case 4: // McZapkie-260302 - rzeka- rendering - // Ra: rzeki na razie bez zmian, przechyłki na pewno nie mają - // Ra: przemyśleć wyrównanie u góry trawą do czworoboku - vector6 bpts1[numPts] = {vector6(fHTW, 0.0, 0.0), vector6(fHTW, 0.2, 0.33), - vector6(-fHTW, 0.0, 0.67), vector6(-fHTW, 0.0, 1.0)}; - // Ra: dziwnie ten kształt wygląda - if (TextureID1) - if (tex ? TextureID1 == tex : true) // jeśli pasuje do grupy (tex) - { - if (!tex) - TextureManager.Bind( TextureID1 ); - Segment->RenderLoft(bpts1, numPts, fTexLength); - } - if (TextureID2) - if (tex ? TextureID2 == tex : true) // jeśli pasuje do grupy (tex) - { // brzegi rzeki prawie jak pobocze derogi, tylko inny znak ma wysokość - // znak jest zmieniany przy wczytywaniu, więc tu musi byc minus fTexHeight - vector6 rpts1[3] = {vector6(rozp, -fTexHeight1, 0.0), - vector6(fHTW + side, 0.0, 0.5), vector6(fHTW, 0.0, 1.0)}; - vector6 rpts2[3] = {vector6(-fHTW, 0.0, 1.0), vector6(-fHTW - side, 0.0, 0.5), - vector6(-rozp, -fTexHeight1, 0.0)}; // Ra: po kiego 0.1? - if (!tex) - TextureManager.Bind( TextureID2 ); // brzeg rzeki - Segment->RenderLoft(rpts1, 3, fTexLength); - Segment->RenderLoft(rpts2, 3, fTexLength); - } - break; - } - if (!tex) - if (Global::bManageNodes) - glEndList(); -}; - -void TTrack::Release() -{ - if (DisplayListID) - glDeleteLists(DisplayListID, 1); - DisplayListID = 0; -}; - -void TTrack::Render() -{ - if (bVisible) // Ra: tory są renderowane sektorami i nie ma sensu każdorazowo liczyć odległości - { - if (!DisplayListID) - { - Compile(); - if (Global::bManageNodes) - ResourceManager::Register(this); - }; - SetLastUsage(Timer::GetSimulationTime()); - EnvironmentSet(); // oświetlenie nie może być skompilowane, bo może się zmieniać z czasem - glCallList(DisplayListID); - EnvironmentReset(); // ustawienie oświetlenia na zwykłe - if (InMovement()) - Release(); // zwrotnica w trakcie animacji do odrysowania - }; -//#ifdef _DEBUG -#if 0 - if (DebugModeFlag && ScannedFlag) //McZapkie-230702 - //if (iNumDynamics) //będzie kreska na zajętym torze - { - vector3 pos1,pos2,pos3; - glDisable(GL_DEPTH_TEST); - glDisable(GL_LIGHTING); - glColor3ub(255,0,0); - glBindTexture(GL_TEXTURE_2D,0); - glBegin(GL_LINE_STRIP); - pos1=Segment->FastGetPoint_0(); - pos2=Segment->FastGetPoint(0.5); - pos3=Segment->FastGetPoint_1(); - glVertex3f(pos1.x,pos1.y,pos1.z); - glVertex3f(pos2.x,pos2.y+10,pos2.z); - glVertex3f(pos3.x,pos3.y,pos3.z); - glEnd(); - glEnable(GL_LIGHTING); - glEnable(GL_DEPTH_TEST); - ScannedFlag=false; - } -#endif - // glLightfv(GL_LIGHT0,GL_AMBIENT,Global::ambientDayLight); - // glLightfv(GL_LIGHT0,GL_DIFFUSE,Global::diffuseDayLight); - // glLightfv(GL_LIGHT0,GL_SPECULAR,Global::specularDayLight); -}; +// iglica - vextor3(x,y,mapowanie tekstury) +// 1 mm więcej, żeby nie nachodziły tekstury? +// TODO: automatic generation from base profile TBD: reuse base profile? +gfx::basic_vertex const iglica[ nnumPts ] = { + {{ 0.010f, -0.180f, 0.f}, { 1.000f, 0.000f, 0.f}, {0.00f, 0.f}}, + {{ 0.010f, -0.155f, 0.f}, { 1.000f, 0.000f, 0.f}, {0.15f, 0.f}}, + {{ 0.010f, -0.070f, 0.f}, { 1.000f, 0.000f, 0.f}, {0.25f, 0.f}}, + {{ 0.010f, -0.040f, 0.f}, { 1.000f, 0.000f, 0.f}, {0.35f, 0.f}}, + {{ 0.010f, -0.010f, 0.f}, { 1.000f, 0.000f, 0.f}, {0.40f, 0.f}}, + {{ 0.010f, -0.000f, 0.f}, { 0.707f, 0.707f, 0.f}, {0.45f, 0.f}}, + {{ 0.000f, -0.000f, 0.f}, { 0.707f, 0.707f, 0.f}, {0.55f, 0.f}}, + {{ 0.000f, -0.010f, 0.f}, {-1.000f, 0.000f, 0.f}, {0.60f, 0.f}}, + {{ 0.000f, -0.040f, 0.f}, {-1.000f, 0.000f, 0.f}, {0.65f, 0.f}}, + {{ 0.000f, -0.070f, 0.f}, {-1.000f, 0.000f, 0.f}, {0.75f, 0.f}}, + {{ 0.000f, -0.155f, 0.f}, {-0.707f, 0.707f, 0.f}, {0.85f, 0.f}}, + {{-0.040f, -0.180f, 0.f}, {-1.000f, 0.000f, 0.f}, {1.00f, 0.f}} }; bool TTrack::CheckDynamicObject(TDynamicObject *Dynamic) { // sprawdzenie, czy pojazd jest przypisany do toru -#ifdef EU07_USE_OLD_TTRACK_DYNAMICS_ARRAY - for (int i = 0; i < iNumDynamics; i++) - if (Dynamic == Dynamics[i]) - return true; - return false; -#else for( auto dynamic : Dynamics ) { if( dynamic == Dynamic ) { return true; } } return false; -#endif }; bool TTrack::RemoveDynamicObject(TDynamicObject *Dynamic) { // usunięcie pojazdu z listy przypisanych do toru -#ifdef EU07_USE_OLD_TTRACK_DYNAMICS_ARRAY - for (int i = 0; i < iNumDynamics; i++) - { // sprawdzanie wszystkich po kolei - if (Dynamic == Dynamics[i]) - { // znaleziony, przepisanie następnych, żeby dziur nie było - --iNumDynamics; - for (i; i < iNumDynamics; i++) - Dynamics[i] = Dynamics[i + 1]; - if (Global::iMultiplayer) // jeśli multiplayer - if (!iNumDynamics) // jeśli już nie ma żadnego - if (pMyNode->asName != "none") - Global::pGround->WyslijString( - pMyNode->asName, 9); // przekazanie informacji o zwolnieniu toru - return true; - } - } - Error("Cannot remove dynamic from track"); - return false; -#else bool result = false; if( *Dynamics.begin() == Dynamic ) { // most likely the object getting removed is at the front... @@ -1924,19 +1082,18 @@ bool TTrack::RemoveDynamicObject(TDynamicObject *Dynamic) } } } - if( Global::iMultiplayer ) { + if( Global.iMultiplayer ) { // jeśli multiplayer if( true == Dynamics.empty() ) { // jeśli już nie ma żadnego - if( pMyNode->asName != "none" ) { + if( m_name != "none" ) { // przekazanie informacji o zwolnieniu toru - Global::pGround->WyslijString( pMyNode->asName, 9 ); + multiplayer::WyslijString( m_name, 9 ); } } } return result; -#endif } bool TTrack::InMovement() @@ -1951,8 +1108,10 @@ bool TTrack::InMovement() if (!SwitchExtension->CurrentIndex) return false; // 0=zablokowana się nie animuje // trzeba każdorazowo porównywać z kątem modelu - TAnimContainer *ac = - SwitchExtension->pModel ? SwitchExtension->pModel->GetContainer(NULL) : NULL; + TAnimContainer *ac = ( + SwitchExtension->pModel ? + SwitchExtension->pModel->GetContainer() : + nullptr ); return ac ? (ac->AngleGet() != SwitchExtension->fOffset) || !(ac->TransGet() == SwitchExtension->vTrans) : @@ -1962,287 +1121,151 @@ bool TTrack::InMovement() } return false; }; -void TTrack::RaAssign(TGroundNode *gn, TAnimContainer *ac){ - // Ra: wiązanie toru z modelem obrotnicy - // if (eType==tt_Table) SwitchExtension->pAnim=p; -}; -void TTrack::RaAssign(TGroundNode *gn, TAnimModel *am, TEvent *done, TEvent *joined) + +void TTrack::RaAssign( TAnimModel *am, basic_event *done, basic_event *joined ) { // Ra: wiązanie toru z modelem obrotnicy if (eType == tt_Table) { SwitchExtension->pModel = am; - SwitchExtension->pMyNode = gn; SwitchExtension->evMinus = done; // event zakończenia animacji (zadanie nowej przedłuża) SwitchExtension->evPlus = joined; // event potwierdzenia połączenia (gdy nie znajdzie, to się nie połączy) if (am) - if (am->GetContainer(NULL)) // może nie być? - am->GetContainer(NULL)->EventAssign(done); // zdarzenie zakończenia animacji + if (am->GetContainer()) // może nie być? + am->GetContainer()->EventAssign(done); // zdarzenie zakończenia animacji } }; -int TTrack::RaArrayPrepare() -{ // przygotowanie tablic do skopiowania do VBO (zliczanie wierzchołków) - if (bVisible) // o ile w ogóle widać - switch (iCategoryFlag & 15) - { - case 1: // tor - if (eType == tt_Switch) // dla zwrotnicy tylko szyny - return 48 * ((TextureID1 ? SwitchExtension->Segments[0]->RaSegCount() : 0) + - (TextureID2 ? SwitchExtension->Segments[1]->RaSegCount() : 0)); - else // dla toru podsypka plus szyny - return (Segment->RaSegCount()) * ((TextureID1 ? 48 : 0) + (TextureID2 ? 8 : 0)); - case 2: // droga - if (eType == tt_Cross) // tylko dla skrzyżowania dróg - { // specjalny sposób obliczania liczby wierzchołków w skrzyżowaniu - // int n=0; //wierzchołki wewnętrzne do generowania nawierzchni - // int b=0; //wierzchołki do generowania boków - if (fTexHeight1 >= 0) // jeśli fTexHeight1<0, to są chodniki i może któregoś nie być - { // normalne pobocze, na razie się składa z - return (Segment->RaSegCount()) * ((TextureID1 ? 4 : 0) + (TextureID2 ? 12 : 0)); - } - else - return (Segment->RaSegCount()) * - ((TextureID1 ? 4 : 0) + - (TextureID2 ? (fTexWidth != 0.0 ? 6 : 0) + (fTexSlope != 0.0 ? 6 : 0) : - 0)); - } - else // standardowo dla zwykłej drogi - if (fTexHeight1 >= 0) // jeśli fTexHeight1<0, to są chodniki i może któregoś nie być - return (Segment->RaSegCount()) * - ((TextureID1 ? 4 : 0) + (TextureID2 ? 12 : 0)); // może nie być poziomego! - else - return (Segment->RaSegCount()) * - ((TextureID1 ? 4 : 0) + - (TextureID2 ? (fTexWidth != 0.0 ? 6 : 0) + (fTexSlope != 0.0 ? 6 : 0) : 0)); - case 4: // rzeki do przemyślenia - return (Segment->RaSegCount()) * ((TextureID1 ? 4 : 0) + (TextureID2 ? 12 : 0)); - } - return 0; -}; +// wypełnianie tablic VBO +void TTrack::create_geometry( gfx::geometrybank_handle const &Bank ) { -void TTrack::RaArrayFill(CVertNormTex *Vert, const CVertNormTex *Start) -{ // wypełnianie tablic VBO - // Ra: trzeba rozdzielić szyny od podsypki, aby móc grupować wg tekstur - double fHTW = 0.5 * fabs(fTrackWidth); - double side = fabs(fTexWidth); // szerokść podsypki na zewnątrz szyny albo pobocza - double slop = fabs(fTexSlope); // brzeg zewnętrzny - double rozp = fHTW + side + slop; // brzeg zewnętrzny - double hypot1 = hypot(slop, fTexHeight1); // rozmiar pochylenia do liczenia normalnych - if (hypot1 == 0.0) - hypot1 = 1.0; - vector3 normal1 = vector3(fTexSlope / hypot1, fTexHeight1 / hypot1, 0.0); // wektor normalny - double fHTW2, side2, slop2, rozp2, fTexHeight2, hypot2; - vector3 normal2; - if (iTrapezoid & 2) // ten bit oznacza, że istnieje odpowiednie pNext - { // Ra: jest OK - fHTW2 = 0.5 * fabs(trNext->fTrackWidth); // połowa rozstawu/nawierzchni - side2 = fabs(trNext->fTexWidth); - slop2 = fabs(trNext->fTexSlope); // nie jest używane później - rozp2 = fHTW2 + side2 + slop2; - fTexHeight2 = trNext->fTexHeight1; - hypot2 = hypot(slop2, fTexHeight2); - if (hypot2 == 0.0) - hypot2 = 1.0; - normal2 = vector3(trNext->fTexSlope / hypot2, fTexHeight2 / hypot2, 0.0); - } - else // gdy nie ma następnego albo jest nieodpowiednim końcem podpięty - { - fHTW2 = fHTW; - side2 = side; - slop2 = slop; - rozp2 = rozp; - fTexHeight2 = fTexHeight1; - hypot2 = hypot1; - normal2 = normal1; - } - double roll1, roll2; switch (iCategoryFlag & 15) { case 1: // tor { - if (Segment) - Segment->GetRolls(roll1, roll2); - else - roll1 = roll2 = 0.0; // dla zwrotnic - double sin1 = sin(roll1), cos1 = cos(roll1), sin2 = sin(roll2), cos2 = cos(roll2); // zwykla szyna: //Ra: czemu główki są asymetryczne na wysokości 0.140? - vector6 rpts1[24], rpts2[24], rpts3[24], rpts4[24]; - int i; - for (i = 0; i < 12; ++i) - { - rpts1[i] = vector6((fHTW + szyna[i].x) * cos1 + szyna[i].y * sin1, - -(fHTW + szyna[i].x) * sin1 + szyna[i].y * cos1, szyna[i].z, - +szyna[i].n.x * cos1 + szyna[i].n.y * sin1, - -szyna[i].n.x * sin1 + szyna[i].n.y * cos1, 0.0); - rpts2[11 - i] = vector6((-fHTW - szyna[i].x) * cos1 + szyna[i].y * sin1, - -(-fHTW - szyna[i].x) * sin1 + szyna[i].y * cos1, szyna[i].z, - -szyna[i].n.x * cos1 + szyna[i].n.y * sin1, - +szyna[i].n.x * sin1 + szyna[i].n.y * cos1, 0.0); - } - if (iTrapezoid) // trapez albo przechyłki, to oddzielne punkty na końcu - for (i = 0; i < 12; ++i) - { - rpts1[12 + i] = vector6((fHTW2 + szyna[i].x) * cos2 + szyna[i].y * sin2, - -(fHTW2 + szyna[i].x) * sin2 + szyna[i].y * cos2, - szyna[i].z, +szyna[i].n.x * cos2 + szyna[i].n.y * sin2, - -szyna[i].n.x * sin2 + szyna[i].n.y * cos2, 0.0); - rpts2[23 - i] = vector6((-fHTW2 - szyna[i].x) * cos2 + szyna[i].y * sin2, - -(-fHTW2 - szyna[i].x) * sin2 + szyna[i].y * cos2, - szyna[i].z, -szyna[i].n.x * cos2 + szyna[i].n.y * sin2, - +szyna[i].n.x * sin2 + szyna[i].n.y * cos2, 0.0); - } + gfx::vertex_array rpts1, rpts2; + create_track_rail_profile( rpts1, rpts2 ); switch (eType) // dalej zależnie od typu { case tt_Table: // obrotnica jak zwykły tor, tylko animacja dochodzi - SwitchExtension->iLeftVBO = Vert - Start; // indeks toru obrotnicy case tt_Normal: - if (TextureID2) + if (m_material2) { // podsypka z podkładami jest tylko dla zwykłego toru - vector6 bpts1[8]; // punkty głównej płaszczyzny nie przydają się do robienia boków - if (fTexLength == 4.0) // jeśli stare mapowanie - { // stare mapowanie z różną gęstością pikseli i oddzielnymi teksturami na każdy - // profil - if (iTrapezoid) // trapez albo przechyłki - { // podsypka z podkladami trapezowata - // ewentualnie poprawić mapowanie, żeby środek mapował się na 1.435/4.671 - // ((0.3464,0.6536) - // bo się tekstury podsypki rozjeżdżają po zmianie proporcji profilu - bpts1[0] = vector6(rozp, -fTexHeight1 - 0.18, 0.00, -0.707, 0.707, - 0.0); // lewy brzeg - bpts1[1] = vector6((fHTW + side) * cos1, -(fHTW + side) * sin1 - 0.18, 0.33, - -0.707, 0.707, 0.0); // krawędź załamania - bpts1[2] = vector6(-bpts1[1].x, +(fHTW + side) * sin1 - 0.18, 0.67, 0.707, - 0.707, 0.0); // prawy brzeg początku symetrycznie - bpts1[3] = vector6(-rozp, -fTexHeight1 - 0.18, 1.00, 0.707, 0.707, - 0.0); // prawy skos - // końcowy przekrój - bpts1[4] = vector6(rozp2, -fTexHeight2 - 0.18, 0.00, -0.707, 0.707, - 0.0); // lewy brzeg - bpts1[5] = vector6((fHTW2 + side2) * cos2, -(fHTW2 + side2) * sin2 - 0.18, - 0.33, -0.707, 0.707, 0.0); // krawędź załamania - bpts1[6] = vector6(-bpts1[5].x, +(fHTW2 + side2) * sin2 - 0.18, 0.67, 0.707, - 0.707, 0.0); // prawy brzeg początku symetrycznie - bpts1[7] = vector6(-rozp2, -fTexHeight2 - 0.18, 1.00, 0.707, 0.707, - 0.0); // prawy skos - } - else - { - bpts1[0] = vector6(rozp, -fTexHeight1 - 0.18, 0.0, -0.707, 0.707, - 0.0); // lewy brzeg - bpts1[1] = vector6(fHTW + side, -0.18, 0.33, -0.707, 0.707, - 0.0); // krawędź załamania - bpts1[2] = vector6(-fHTW - side, -0.18, 0.67, 0.707, 0.707, 0.0); // druga - bpts1[3] = vector6(-rozp, -fTexHeight1 - 0.18, 1.0, 0.707, 0.707, - 0.0); // prawy skos - } + gfx::vertex_array bpts1; + create_track_bed_profile( bpts1, trPrev, trNext ); + auto const texturelength { texture_length( m_material2 ) }; + gfx::vertex_array vertices; + Segment->RenderLoft(vertices, m_origin, bpts1, iTrapezoid ? -5 : 5, texturelength); + if( ( Bank != 0 ) && ( true == Geometry2.empty() ) ) { + Geometry2.emplace_back( GfxRenderer.Insert( vertices, Bank, GL_TRIANGLE_STRIP ) ); } - else - { // mapowanie proporcjonalne do powierzchni, rozmiar w poprzek określa fTexLength - double max = fTexRatio2 * fTexLength; // szerokość proporcjonalna do długości - double map11 = max > 0.0 ? (fHTW + side) / max : 0.25; // załamanie od strony 1 - double map12 = - max > 0.0 ? (fHTW + side + hypot1) / max : 0.5; // brzeg od strony 1 - if (iTrapezoid) // trapez albo przechyłki - { // podsypka z podkladami trapezowata - double map21 = - max > 0.0 ? (fHTW2 + side2) / max : 0.25; // załamanie od strony 2 - double map22 = - max > 0.0 ? (fHTW2 + side2 + hypot2) / max : 0.5; // brzeg od strony 2 - // ewentualnie poprawić mapowanie, żeby środek mapował się na 1.435/4.671 - // ((0.3464,0.6536) - // bo się tekstury podsypki rozjeżdżają po zmianie proporcji profilu - bpts1[0] = vector6(rozp, -fTexHeight1 - 0.18, 0.5 - map12, normal1.x, - -normal1.y, 0.0); // lewy brzeg - bpts1[1] = vector6((fHTW + side) * cos1, -(fHTW + side) * sin1 - 0.18, - 0.5 - map11, 0.0, 1.0, 0.0); // krawędź załamania - bpts1[2] = vector6(-bpts1[1].x, +(fHTW + side) * sin1 - 0.18, 0.5 + map11, - 0.0, 1.0, 0.0); // prawy brzeg początku symetrycznie - bpts1[3] = vector6(-rozp, -fTexHeight1 - 0.18, 0.5 + map12, -normal1.x, - -normal1.y, 0.0); // prawy skos - // przekrój końcowy - bpts1[4] = vector6(rozp2, -fTexHeight2 - 0.18, 0.5 - map22, normal2.x, - -normal2.y, 0.0); // lewy brzeg - bpts1[5] = vector6((fHTW2 + side2) * cos2, -(fHTW2 + side2) * sin2 - 0.18, - 0.5 - map21, 0.0, 1.0, 0.0); // krawędź załamania - bpts1[6] = vector6(-bpts1[5].x, +(fHTW2 + side2) * sin2 - 0.18, 0.5 + map21, - 0.0, 1.0, 0.0); // prawy brzeg początku symetrycznie - bpts1[7] = vector6(-rozp2, -fTexHeight2 - 0.18, 0.5 + map22, -normal2.x, - -normal2.y, 0.0); // prawy skos - } - else - { - bpts1[0] = vector6(rozp, -fTexHeight1 - 0.18, 0.5 - map12, +normal1.x, - -normal1.y, 0.0); // lewy brzeg - bpts1[1] = vector6(fHTW + side, -0.18, 0.5 - map11, +normal1.x, -normal1.y, - 0.0); // krawędź załamania - bpts1[2] = vector6(-fHTW - side, -0.18, 0.5 + map11, -normal1.x, -normal1.y, - 0.0); // druga - bpts1[3] = vector6(-rozp, -fTexHeight1 - 0.18, 0.5 + map12, -normal1.x, - -normal1.y, 0.0); // prawy skos - } + if( ( Bank == 0 ) && ( false == Geometry2.empty() ) ) { + // special variant, replace existing data for a turntable track + GfxRenderer.Replace( vertices, Geometry2[ 0 ] ); } - Segment->RaRenderLoft(Vert, bpts1, iTrapezoid ? -4 : 4, fTexLength); } - if (TextureID1) + if (m_material1) { // szyny - generujemy dwie, najwyżej rysować się będzie jedną - Segment->RaRenderLoft(Vert, rpts1, iTrapezoid ? -nnumPts : nnumPts, fTexLength); - Segment->RaRenderLoft(Vert, rpts2, iTrapezoid ? -nnumPts : nnumPts, fTexLength); + auto const texturelength { texture_length( m_material1 ) }; + gfx::vertex_array vertices; + if( ( Bank != 0 ) && ( true == Geometry1.empty() ) ) { + Segment->RenderLoft( vertices, m_origin, rpts1, iTrapezoid ? -nnumPts : nnumPts, texturelength ); + Geometry1.emplace_back( GfxRenderer.Insert( vertices, Bank, GL_TRIANGLE_STRIP ) ); + vertices.clear(); // reuse the scratchpad + Segment->RenderLoft( vertices, m_origin, rpts2, iTrapezoid ? -nnumPts : nnumPts, texturelength ); + Geometry1.emplace_back( GfxRenderer.Insert( vertices, Bank, GL_TRIANGLE_STRIP ) ); + } + if( ( Bank == 0 ) && ( false == Geometry1.empty() ) ) { + // special variant, replace existing data for a turntable track + Segment->RenderLoft( vertices, m_origin, rpts1, iTrapezoid ? -nnumPts : nnumPts, texturelength ); + GfxRenderer.Replace( vertices, Geometry1[ 0 ] ); + vertices.clear(); // reuse the scratchpad + Segment->RenderLoft( vertices, m_origin, rpts2, iTrapezoid ? -nnumPts : nnumPts, texturelength ); + GfxRenderer.Replace( vertices, Geometry1[ 1 ] ); + } } break; case tt_Switch: // dla zwrotnicy dwa razy szyny - if (TextureID1) // Ra: !!!! tu jest do poprawienia - { // iglice liczone tylko dla zwrotnic - vector6 rpts3[24], rpts4[24]; - for (i = 0; i < 12; ++i) - { - rpts3[i] = - vector6(+(fHTW + iglica[i].x) * cos1 + iglica[i].y * sin1, - -(+fHTW + iglica[i].x) * sin1 + iglica[i].y * cos1, iglica[i].z); - rpts3[i + 12] = - vector6(+(fHTW2 + szyna[i].x) * cos2 + szyna[i].y * sin2, - -(+fHTW2 + szyna[i].x) * sin2 + iglica[i].y * cos2, szyna[i].z); - rpts4[11 - i] = - vector6((-fHTW - iglica[i].x) * cos1 + iglica[i].y * sin1, - -(-fHTW - iglica[i].x) * sin1 + iglica[i].y * cos1, iglica[i].z); - rpts4[23 - i] = - vector6((-fHTW2 - szyna[i].x) * cos2 + szyna[i].y * sin2, - -(-fHTW2 - szyna[i].x) * sin2 + iglica[i].y * cos2, szyna[i].z); - } + if( m_material1 || m_material2 ) { + // iglice liczone tylko dla zwrotnic + gfx::vertex_array rpts3, rpts4; + create_track_blade_profile( rpts3, rpts4 ); + // TODO, TBD: change all track geometry to triangles, to allow packing data in less, larger buffers + auto const bladelength { static_cast( std::ceil( SwitchExtension->Segments[ 0 ]->RaSegCount() * 0.65 ) ) }; if (SwitchExtension->RightSwitch) { // nowa wersja z SPKS, ale odwrotnie lewa/prawa - SwitchExtension->iLeftVBO = Vert - Start; // indeks lewej iglicy - SwitchExtension->Segments[0]->RaRenderLoft(Vert, rpts3, -nnumPts, fTexLength, 0, - 2, SwitchExtension->fOffset2); - SwitchExtension->Segments[0]->RaRenderLoft(Vert, rpts1, nnumPts, fTexLength, 2); - SwitchExtension->Segments[0]->RaRenderLoft(Vert, rpts2, nnumPts, fTexLength); - SwitchExtension->Segments[1]->RaRenderLoft(Vert, rpts1, nnumPts, fTexLength); - SwitchExtension->iRightVBO = Vert - Start; // indeks prawej iglicy - SwitchExtension->Segments[1]->RaRenderLoft(Vert, rpts4, -nnumPts, fTexLength, 0, - 2, -fMaxOffset + - SwitchExtension->fOffset1); - SwitchExtension->Segments[1]->RaRenderLoft(Vert, rpts2, nnumPts, fTexLength, 2); + gfx::vertex_array vertices; + if( m_material1 ) { + auto const texturelength { texture_length( m_material1 ) }; + // fixed parts + SwitchExtension->Segments[ 0 ]->RenderLoft( vertices, m_origin, rpts2, nnumPts, texturelength ); + Geometry1.emplace_back( GfxRenderer.Insert( vertices, Bank, GL_TRIANGLE_STRIP ) ); + vertices.clear(); + SwitchExtension->Segments[ 0 ]->RenderLoft( vertices, m_origin, rpts1, nnumPts, texturelength, 1.0, bladelength ); + Geometry1.emplace_back( GfxRenderer.Insert( vertices, Bank, GL_TRIANGLE_STRIP ) ); + vertices.clear(); + // left blade + SwitchExtension->Segments[ 0 ]->RenderLoft( vertices, m_origin, rpts3, -nnumPts, texturelength, 1.0, 0, bladelength, SwitchExtension->fOffset2 ); + Geometry1.emplace_back( GfxRenderer.Insert( vertices, Bank, GL_TRIANGLE_STRIP ) ); + vertices.clear(); + } + if( m_material2 ) { + auto const texturelength { texture_length( m_material2 ) }; + // fixed parts + SwitchExtension->Segments[ 1 ]->RenderLoft( vertices, m_origin, rpts1, nnumPts, texturelength ); + Geometry2.emplace_back( GfxRenderer.Insert( vertices, Bank, GL_TRIANGLE_STRIP ) ); + vertices.clear(); + SwitchExtension->Segments[ 1 ]->RenderLoft( vertices, m_origin, rpts2, nnumPts, texturelength, 1.0, bladelength ); + Geometry2.emplace_back( GfxRenderer.Insert( vertices, Bank, GL_TRIANGLE_STRIP ) ); + vertices.clear(); + // right blade + SwitchExtension->Segments[ 1 ]->RenderLoft( vertices, m_origin, rpts4, -nnumPts, texturelength, 1.0, 0, bladelength, -fMaxOffset + SwitchExtension->fOffset1 ); + Geometry2.emplace_back( GfxRenderer.Insert( vertices, Bank, GL_TRIANGLE_STRIP ) ); + vertices.clear(); + } } else { // lewa działa lepiej niż prawa - SwitchExtension->Segments[0]->RaRenderLoft( - Vert, rpts1, nnumPts, fTexLength); // lewa szyna normalna cała - SwitchExtension->iLeftVBO = Vert - Start; // indeks lewej iglicy - SwitchExtension->Segments[0]->RaRenderLoft( - Vert, rpts4, -nnumPts, fTexLength, 0, 2, - -SwitchExtension->fOffset2); // prawa iglica - SwitchExtension->Segments[0]->RaRenderLoft(Vert, rpts2, nnumPts, fTexLength, - 2); // prawa szyna za iglicą - SwitchExtension->iRightVBO = Vert - Start; // indeks prawej iglicy - SwitchExtension->Segments[1]->RaRenderLoft( - Vert, rpts3, -nnumPts, fTexLength, 0, 2, - fMaxOffset - SwitchExtension->fOffset1); // lewa iglica - SwitchExtension->Segments[1]->RaRenderLoft(Vert, rpts1, nnumPts, fTexLength, - 2); // lewa szyna za iglicą - SwitchExtension->Segments[1]->RaRenderLoft( - Vert, rpts2, nnumPts, fTexLength); // prawa szyna normalnie cała + gfx::vertex_array vertices; + if( m_material1 ) { + auto const texturelength { texture_length( m_material1 ) }; + // fixed parts + SwitchExtension->Segments[ 0 ]->RenderLoft( vertices, m_origin, rpts1, nnumPts, texturelength ); // lewa szyna normalna cała + Geometry1.emplace_back( GfxRenderer.Insert( vertices, Bank, GL_TRIANGLE_STRIP ) ); + vertices.clear(); + SwitchExtension->Segments[ 0 ]->RenderLoft( vertices, m_origin, rpts2, nnumPts, texturelength, 1.0, bladelength ); // prawa szyna za iglicą + Geometry1.emplace_back( GfxRenderer.Insert( vertices, Bank, GL_TRIANGLE_STRIP ) ); + vertices.clear(); + // right blade + SwitchExtension->Segments[ 0 ]->RenderLoft( vertices, m_origin, rpts4, -nnumPts, texturelength, 1.0, 0, bladelength, -SwitchExtension->fOffset2 ); + Geometry1.emplace_back( GfxRenderer.Insert( vertices, Bank, GL_TRIANGLE_STRIP ) ); + vertices.clear(); + } + if( m_material2 ) { + auto const texturelength { texture_length( m_material2 ) }; + // fixed parts + SwitchExtension->Segments[ 1 ]->RenderLoft( vertices, m_origin, rpts2, nnumPts, texturelength ); // prawa szyna normalnie cała + Geometry2.emplace_back( GfxRenderer.Insert( vertices, Bank, GL_TRIANGLE_STRIP ) ); + vertices.clear(); + SwitchExtension->Segments[ 1 ]->RenderLoft( vertices, m_origin, rpts1, nnumPts, texturelength, 1.0, bladelength ); // lewa szyna za iglicą + Geometry2.emplace_back( GfxRenderer.Insert( vertices, Bank, GL_TRIANGLE_STRIP ) ); + vertices.clear(); + // left blade + SwitchExtension->Segments[ 1 ]->RenderLoft( vertices, m_origin, rpts3, -nnumPts, texturelength, 1.0, 0, bladelength, fMaxOffset - SwitchExtension->fOffset1 ); + Geometry2.emplace_back( GfxRenderer.Insert( vertices, Bank, GL_TRIANGLE_STRIP ) ); + vertices.clear(); + } } } + // auto-generated switch trackbed + if( true == Global.CreateSwitchTrackbeds ) { + gfx::vertex_array vertices; + create_switch_trackbed( vertices ); + SwitchExtension->Geometry3 = GfxRenderer.Insert( vertices, Bank, GL_TRIANGLE_STRIP ); + vertices.clear(); + } + break; } } // koniec obsługi torów @@ -2252,426 +1275,273 @@ void TTrack::RaArrayFill(CVertNormTex *Vert, const CVertNormTex *Start) { case tt_Normal: // drogi proste, bo skrzyżowania osobno { - vector6 bpts1[4]; // punkty głównej płaszczyzny przydają się do robienia boków - if (TextureID1 || TextureID2) // punkty się przydadzą, nawet jeśli nawierzchni nie ma - { // double max=2.0*(fHTW>fHTW2?fHTW:fHTW2); //z szerszej strony jest 100% - double max = (iCategoryFlag & 4) ? - 0.0 : - fTexLength; // test: szerokość dróg proporcjonalna do długości - double map1 = max > 0.0 ? fHTW / max : 0.5; // obcięcie tekstury od strony 1 - double map2 = max > 0.0 ? fHTW2 / max : 0.5; // obcięcie tekstury od strony 2 - if (iTrapezoid) // trapez albo przechyłki - { // nawierzchnia trapezowata - Segment->GetRolls(roll1, roll2); - bpts1[0] = vector6(fHTW * cos(roll1), -fHTW * sin(roll1), - 0.5 - map1); // lewy brzeg początku - bpts1[1] = vector6(-bpts1[0].x, -bpts1[0].y, - 0.5 + map1); // prawy brzeg początku symetrycznie - bpts1[2] = vector6(fHTW2 * cos(roll2), -fHTW2 * sin(roll2), - 0.5 - map2); // lewy brzeg końca - bpts1[3] = vector6(-bpts1[2].x, -bpts1[2].y, - 0.5 + map2); // prawy brzeg początku symetrycznie - } - else - { - bpts1[0] = vector6(fHTW, 0.0, 0.5 - map1); // zawsze standardowe mapowanie - bpts1[1] = vector6(-fHTW, 0.0, 0.5 + map1); - } + gfx::vertex_array bpts1; // punkty głównej płaszczyzny przydają się do robienia boków + if (m_material1 || m_material2) { + // punkty się przydadzą, nawet jeśli nawierzchni nie ma + create_road_profile( bpts1 ); } - if (TextureID1) // jeśli podana była tekstura, generujemy trójkąty + if (m_material1) // jeśli podana była tekstura, generujemy trójkąty { // tworzenie trójkątów nawierzchni szosy - Segment->RaRenderLoft(Vert, bpts1, iTrapezoid ? -2 : 2, fTexLength); + auto const texturelength { texture_length( m_material1 ) }; + gfx::vertex_array vertices; + Segment->RenderLoft(vertices, m_origin, bpts1, iTrapezoid ? -2 : 2, texturelength); + Geometry1.emplace_back( GfxRenderer.Insert( vertices, Bank, GL_TRIANGLE_STRIP ) ); } - if (TextureID2) - { // pobocze drogi - poziome przy przechyłce (a może krawężnik i chodnik zrobić jak w - // Midtown Madness 2?) - vector6 rpts1[6], - rpts2[6]; // współrzędne przekroju i mapowania dla prawej i lewej strony - if (fTexHeight1 >= 0.0) - { // standardowo: od zewnątrz pochylenie, a od wewnątrz poziomo - rpts1[0] = vector6(rozp, -fTexHeight1, 0.0); // lewy brzeg podstawy - rpts1[1] = - vector6(bpts1[0].x + side, bpts1[0].y, 0.5), // lewa krawędź załamania - rpts1[2] = vector6(bpts1[0].x, bpts1[0].y, - 1.0); // lewy brzeg pobocza (mapowanie może być inne - rpts2[0] = vector6(bpts1[1].x, bpts1[1].y, 1.0); // prawy brzeg pobocza - rpts2[1] = - vector6(bpts1[1].x - side, bpts1[1].y, 0.5); // prawa krawędź załamania - rpts2[2] = vector6(-rozp, -fTexHeight1, 0.0); // prawy brzeg podstawy - if (iTrapezoid) // trapez albo przechyłki - { // pobocza do trapezowatej nawierzchni - dodatkowe punkty z drugiej strony - // odcinka - rpts1[3] = vector6(rozp2, -fTexHeight2, 0.0); // lewy brzeg lewego pobocza - rpts1[4] = vector6(bpts1[2].x + side2, bpts1[2].y, 0.5); // krawędź - // załamania - rpts1[5] = vector6(bpts1[2].x, bpts1[2].y, 1.0); // brzeg pobocza - rpts2[3] = vector6(bpts1[3].x, bpts1[3].y, 1.0); - rpts2[4] = vector6(bpts1[3].x - side2, bpts1[3].y, 0.5); - rpts2[5] = vector6(-rozp2, -fTexHeight2, 0.0); // prawy brzeg prawego - // pobocza - Segment->RaRenderLoft(Vert, rpts1, -3, fTexLength); - Segment->RaRenderLoft(Vert, rpts2, -3, fTexLength); + if (m_material2) + { // pobocze drogi - poziome przy przechyłce (a może krawężnik i chodnik zrobić jak w Midtown Madness 2?) + auto const side{ std::abs( fTexWidth ) }; // szerokść podsypki na zewnątrz szyny albo pobocza + auto const slop{ std::abs( fTexSlope ) }; // brzeg zewnętrzny + auto const texturelength { texture_length( m_material2 ) }; + gfx::vertex_array rpts1, rpts2; // współrzędne przekroju i mapowania dla prawej i lewej strony + create_road_side_profile( rpts1, rpts2, bpts1 ); + gfx::vertex_array vertices; + if( iTrapezoid ) // trapez albo przechyłki + { // pobocza do trapezowatej nawierzchni - dodatkowe punkty z drugiej strony + // odcinka + if( ( fTexHeight1 >= 0.0 ) || ( slop != 0.0 ) ) { + Segment->RenderLoft( vertices, m_origin, rpts1, -3, texturelength ); // tylko jeśli jest z prawej + Geometry2.emplace_back( GfxRenderer.Insert( vertices, Bank, GL_TRIANGLE_STRIP ) ); + vertices.clear(); } - else - { // pobocza zwykłe, brak przechyłki - Segment->RaRenderLoft(Vert, rpts1, 3, fTexLength); - Segment->RaRenderLoft(Vert, rpts2, 3, fTexLength); + if( ( fTexHeight1 >= 0.0 ) || ( side != 0.0 ) ) { + Segment->RenderLoft( vertices, m_origin, rpts2, -3, texturelength ); // tylko jeśli jest z lewej + Geometry2.emplace_back( GfxRenderer.Insert( vertices, Bank, GL_TRIANGLE_STRIP ) ); + vertices.clear(); } } - else - { // wersja dla chodnika: skos 1:3.75, każdy chodnik innej szerokości - // mapowanie propocjonalne do szerokości chodnika - // krawężnik jest mapowany od 31/64 do 32/64 lewy i od 32/64 do 33/64 prawy - double d = - -fTexHeight1 / 3.75; // krawężnik o wysokości 150mm jest pochylony 40mm - double max = - fTexRatio2 * fTexLength; // test: szerokość proporcjonalna do długości - double map1l = max > 0.0 ? - side / max : - 0.484375; // obcięcie tekstury od lewej strony punktu 1 - double map1r = max > 0.0 ? - slop / max : - 0.484375; // obcięcie tekstury od prawej strony punktu 1 - double h1r = (slop > d) ? -fTexHeight1 : 0; - double h1l = (side > d) ? -fTexHeight1 : 0; - rpts1[0] = vector6(bpts1[0].x + slop, bpts1[0].y + h1r, - 0.515625 + map1r); // prawy brzeg prawego chodnika - rpts1[1] = vector6(bpts1[0].x + d, bpts1[0].y + h1r, - 0.515625); // prawy krawężnik u góry - rpts1[2] = vector6(bpts1[0].x, bpts1[0].y, - 0.515625 - d / 2.56); // prawy krawężnik u dołu - rpts2[0] = vector6(bpts1[1].x, bpts1[1].y, - 0.484375 + d / 2.56); // lewy krawężnik u dołu - rpts2[1] = vector6(bpts1[1].x - d, bpts1[1].y + h1l, - 0.484375); // lewy krawężnik u góry - rpts2[2] = vector6(bpts1[1].x - side, bpts1[1].y + h1l, - 0.484375 - map1l); // lewy brzeg lewego chodnika - if (iTrapezoid) // trapez albo przechyłki - { // pobocza do trapezowatej nawierzchni - dodatkowe punkty z drugiej strony - // odcinka - slop2 = - fabs((iTrapezoid & 2) ? slop2 : slop); // szerokość chodnika po prawej - double map2l = max > 0.0 ? - side2 / max : - 0.484375; // obcięcie tekstury od lewej strony punktu 2 - double map2r = max > 0.0 ? - slop2 / max : - 0.484375; // obcięcie tekstury od prawej strony punktu 2 - double h2r = (slop2 > d) ? -fTexHeight2 : 0; - double h2l = (side2 > d) ? -fTexHeight2 : 0; - rpts1[3] = vector6(bpts1[2].x + slop2, bpts1[2].y + h2r, - 0.515625 + map2r); // prawy brzeg prawego chodnika - rpts1[4] = vector6(bpts1[2].x + d, bpts1[2].y + h2r, - 0.515625); // prawy krawężnik u góry - rpts1[5] = vector6(bpts1[2].x, bpts1[2].y, - 0.515625 - d / 2.56); // prawy krawężnik u dołu - rpts2[3] = vector6(bpts1[3].x, bpts1[3].y, - 0.484375 + d / 2.56); // lewy krawężnik u dołu - rpts2[4] = vector6(bpts1[3].x - d, bpts1[3].y + h2l, - 0.484375); // lewy krawężnik u góry - rpts2[5] = vector6(bpts1[3].x - side2, bpts1[3].y + h2l, - 0.484375 - map2l); // lewy brzeg lewego chodnika - if (slop != 0.0) - Segment->RaRenderLoft(Vert, rpts1, -3, fTexLength); - if (side != 0.0) - Segment->RaRenderLoft(Vert, rpts2, -3, fTexLength); + else { // pobocza zwykłe, brak przechyłki + if( ( fTexHeight1 >= 0.0 ) || ( slop != 0.0 ) ) { + Segment->RenderLoft( vertices, m_origin, rpts1, 3, texturelength ); + Geometry2.emplace_back( GfxRenderer.Insert( vertices, Bank, GL_TRIANGLE_STRIP ) ); + vertices.clear(); } - else - { // pobocza zwykłe, brak przechyłki - if (slop != 0.0) - Segment->RaRenderLoft(Vert, rpts1, 3, fTexLength); - if (side != 0.0) - Segment->RaRenderLoft(Vert, rpts2, 3, fTexLength); + if( ( fTexHeight1 >= 0.0 ) || ( side != 0.0 ) ) { + Segment->RenderLoft( vertices, m_origin, rpts2, 3, texturelength ); + Geometry2.emplace_back( GfxRenderer.Insert( vertices, Bank, GL_TRIANGLE_STRIP ) ); + vertices.clear(); } } } + break; } - } + case tt_Cross: // skrzyżowanie dróg rysujemy inaczej + { // ustalenie współrzędnych środka - przecięcie Point1-Point2 z CV4-Point4 + double a[4]; // kąty osi ulic wchodzących + Math3D::vector3 p[4]; // punkty się przydadzą do obliczeń + // na razie połowa odległości pomiędzy Point1 i Point2, potem się dopracuje + a[0] = a[1] = 0.5; // parametr do poszukiwania przecięcia łuków + // modyfikować a[0] i a[1] tak, aby trafić na przecięcie odcinka 34 + p[0] = SwitchExtension->Segments[0]->FastGetPoint(a[0]); // współrzędne środka pierwszego odcinka + p[1] = SwitchExtension->Segments[1]->FastGetPoint(a[1]); //-//- drugiego + // p[2]=p[1]-p[0]; //jeśli różne od zera, przeliczyć a[0] i a[1] i wyznaczyć nowe punkty + Math3D::vector3 oxz = p[0]; // punkt mapowania środka tekstury skrzyżowania + p[0] = SwitchExtension->Segments[0]->GetDirection1(); // Point1 - pobranie wektorów kontrolnych + p[1] = SwitchExtension->Segments[1]->GetDirection2(); // Point3 (bo zamienione) + p[2] = SwitchExtension->Segments[0]->GetDirection2(); // Point2 + p[3] = SwitchExtension->Segments[1]->GetDirection1(); // Point4 (bo zamienione) + a[0] = atan2(-p[0].x, p[0].z); // kąty stycznych osi dróg + a[1] = atan2(-p[1].x, p[1].z); + a[2] = atan2(-p[2].x, p[2].z); + a[3] = atan2(-p[3].x, p[3].z); + p[0] = SwitchExtension->Segments[0]->FastGetPoint_0(); // Point1 - pobranie współrzędnych końców + p[1] = SwitchExtension->Segments[1]->FastGetPoint_1(); // Point3 + p[2] = SwitchExtension->Segments[0]->FastGetPoint_1(); // Point2 + p[3] = SwitchExtension->Segments[1]->FastGetPoint_0(); // Point4 - przy trzech drogach pokrywa się z Point1 + // 2014-07: na początek rysować brzegi jak dla łuków + // punkty brzegu nawierzchni uzyskujemy podczas renderowania boków (bez sensu, ale najszybciej było zrobić) + int pointcount; + if( SwitchExtension->iRoads == 3 ) { + // mogą być tylko 3 drogi zamiast 4 + pointcount = + SwitchExtension->Segments[ 0 ]->RaSegCount() + + SwitchExtension->Segments[ 1 ]->RaSegCount() + + SwitchExtension->Segments[ 2 ]->RaSegCount(); + } + else { + pointcount = + SwitchExtension->Segments[ 2 ]->RaSegCount() + + SwitchExtension->Segments[ 3 ]->RaSegCount() + + SwitchExtension->Segments[ 4 ]->RaSegCount() + + SwitchExtension->Segments[ 5 ]->RaSegCount(); + } + if (!SwitchExtension->vPoints) + { // jeśli tablica punktów nie jest jeszcze utworzona, zliczamy punkty i tworzymy ją + // we'll need to add couple extra points for the complete fan we'll build + SwitchExtension->vPoints = new glm::vec3[pointcount + SwitchExtension->iRoads]; + } + glm::vec3 *b = + SwitchExtension->bPoints ? + nullptr : + SwitchExtension->vPoints; // zmienna robocza, NULL gdy tablica punktów już jest wypełniona + gfx::vertex_array bpts1; // punkty głównej płaszczyzny przydają się do robienia boków + if (m_material1 || m_material2) { // punkty się przydadzą, nawet jeśli nawierzchni nie ma + create_road_profile( bpts1, true ); + } + // najpierw renderowanie poboczy i zapamiętywanie punktów + // problem ze skrzyżowaniami jest taki, że teren chce się pogrupować wg tekstur, ale zaczyna od nawierzchni + // sama nawierzchnia nie wypełni tablicy punktów, bo potrzebne są pobocza + // ale pobocza renderują się później, więc nawierzchnia nie załapuje się na renderowanie w swoim czasie + if( m_material2 ) + { // pobocze drogi - poziome przy przechyłce (a może krawężnik i chodnik zrobić jak w Midtown Madness 2?) + gfx::vertex_array rpts1, rpts2; // współrzędne przekroju i mapowania dla prawej i lewej strony + create_road_side_profile( rpts1, rpts2, bpts1, true ); + // Ra 2014-07: trzeba to przerobić na pętlę i pobierać profile (przynajmniej 2..4) z sąsiednich dróg + bool render = ( m_material2 != 0 ); // renderować nie trzeba, ale trzeba wyznaczyć punkty brzegowe nawierzchni + auto const side{ std::abs( fTexWidth ) }; // szerokść podsypki na zewnątrz szyny albo pobocza + auto const texturelength{ texture_length( m_material2 ) }; + gfx::vertex_array vertices; + if (SwitchExtension->iRoads == 4) + { // pobocza do trapezowatej nawierzchni - dodatkowe punkty z drugiej strony odcinka + if( ( fTexHeight1 >= 0.0 ) || ( side != 0.0 ) ) { + SwitchExtension->Segments[ 2 ]->RenderLoft( vertices, m_origin, rpts2, -3, texturelength, 1.0, 0, 0, 0.0, &b, render ); + if( true == render ) { + Geometry2.emplace_back( GfxRenderer.Insert( vertices, Bank, GL_TRIANGLE_STRIP ) ); + vertices.clear(); + } + SwitchExtension->Segments[ 3 ]->RenderLoft( vertices, m_origin, rpts2, -3, texturelength, 1.0, 0, 0, 0.0, &b, render ); + if( true == render ) { + Geometry2.emplace_back( GfxRenderer.Insert( vertices, Bank, GL_TRIANGLE_STRIP ) ); + vertices.clear(); + } + SwitchExtension->Segments[ 4 ]->RenderLoft( vertices, m_origin, rpts2, -3, texturelength, 1.0, 0, 0, 0.0, &b, render ); + if( true == render ) { + Geometry2.emplace_back( GfxRenderer.Insert( vertices, Bank, GL_TRIANGLE_STRIP ) ); + vertices.clear(); + } + SwitchExtension->Segments[ 5 ]->RenderLoft( vertices, m_origin, rpts2, -3, texturelength, 1.0, 0, 0, 0.0, &b, render ); + if( true == render ) { + Geometry2.emplace_back( GfxRenderer.Insert( vertices, Bank, GL_TRIANGLE_STRIP ) ); + vertices.clear(); + } + } + } + else { + // punkt 3 pokrywa się z punktem 1, jak w zwrotnicy; połączenie 1->2 nie musi być prostoliniowe + if( ( fTexHeight1 >= 0.0 ) || ( side != 0.0 ) ) { + SwitchExtension->Segments[ 2 ]->RenderLoft( vertices, m_origin, rpts2, -3, texturelength, 1.0, 0, 0, 0.0, &b, render ); // z P2 do P4 + if( true == render ) { + Geometry2.emplace_back( GfxRenderer.Insert( vertices, Bank, GL_TRIANGLE_STRIP ) ); + vertices.clear(); + } + SwitchExtension->Segments[ 1 ]->RenderLoft( vertices, m_origin, rpts2, -3, texturelength, 1.0, 0, 0, 0.0, &b, render ); // z P4 do P3=P1 (odwrócony) + if( true == render ) { + Geometry2.emplace_back( GfxRenderer.Insert( vertices, Bank, GL_TRIANGLE_STRIP ) ); + vertices.clear(); + } + SwitchExtension->Segments[ 0 ]->RenderLoft( vertices, m_origin, rpts2, -3, texturelength, 1.0, 0, 0, 0.0, &b, render ); // z P1 do P2 + if( true == render ) { + Geometry2.emplace_back( GfxRenderer.Insert( vertices, Bank, GL_TRIANGLE_STRIP ) ); + vertices.clear(); + } + } + } + } + // renderowanie nawierzchni na końcu + double sina0 = sin(a[0]), cosa0 = cos(a[0]); + double u, v; + if( ( false == SwitchExtension->bPoints ) // jeśli tablica nie wypełniona + && ( b != nullptr ) ) { + SwitchExtension->bPoints = true; // tablica punktów została wypełniona + } + + if( m_material1 ) { + auto const texturelength { texture_length( m_material1 ) }; + gfx::vertex_array vertices; + // jeśli podana tekstura nawierzchni + // we start with a vertex in the middle... + vertices.emplace_back( + glm::vec3{ + oxz.x - m_origin.x, + oxz.y - m_origin.y, + oxz.z - m_origin.z }, + glm::vec3{ 0.0f, 1.0f, 0.0f }, + glm::vec2{ 0.5f, 0.5f } ); + // ...and add one extra vertex to close the fan... + u = ( SwitchExtension->vPoints[ 0 ].x - oxz.x + m_origin.x ) / texturelength; + v = ( SwitchExtension->vPoints[ 0 ].z - oxz.z + m_origin.z ) / ( fTexRatio1 * texturelength ); + vertices.emplace_back( + glm::vec3 { + SwitchExtension->vPoints[ 0 ].x, + SwitchExtension->vPoints[ 0 ].y, + SwitchExtension->vPoints[ 0 ].z }, + glm::vec3{ 0.0f, 1.0f, 0.0f }, + // mapowanie we współrzędnych scenerii + glm::vec2{ + cosa0 * u + sina0 * v + 0.5, + -sina0 * u + cosa0 * v + 0.5 } ); + // ...then draw the precalculated rest + for (int i = pointcount + SwitchExtension->iRoads - 1; i >= 0; --i) { + // mapowanie we współrzędnych scenerii + u = ( SwitchExtension->vPoints[ i ].x - oxz.x + m_origin.x ) / texturelength; + v = ( SwitchExtension->vPoints[ i ].z - oxz.z + m_origin.z ) / ( fTexRatio1 * texturelength ); + vertices.emplace_back( + glm::vec3 { + SwitchExtension->vPoints[ i ].x, + SwitchExtension->vPoints[ i ].y, + SwitchExtension->vPoints[ i ].z }, + glm::vec3{ 0.0f, 1.0f, 0.0f }, + // mapowanie we współrzędnych scenerii + glm::vec2{ + cosa0 * u + sina0 * v + 0.5, + -sina0 * u + cosa0 * v + 0.5 } ); + } + Geometry1.emplace_back( GfxRenderer.Insert( vertices, Bank, GL_TRIANGLE_FAN ) ); + } + break; + } // tt_cross + } // road break; case 4: // Ra: rzeki na razie jak drogi, przechyłki na pewno nie mają switch (eType) // dalej zależnie od typu { case tt_Normal: // drogi proste, bo skrzyżowania osobno { - vector6 bpts1[4]; // punkty głównej płaszczyzny przydają się do robienia boków - if (TextureID1 || TextureID2) // punkty się przydadzą, nawet jeśli nawierzchni nie ma - { // double max=2.0*(fHTW>fHTW2?fHTW:fHTW2); //z szerszej strony jest 100% - double max = (iCategoryFlag & 4) ? - 0.0 : - fTexLength; // test: szerokość dróg proporcjonalna do długości - double map1 = max > 0.0 ? fHTW / max : 0.5; // obcięcie tekstury od strony 1 - double map2 = max > 0.0 ? fHTW2 / max : 0.5; // obcięcie tekstury od strony 2 - if (iTrapezoid) // trapez albo przechyłki - { // nawierzchnia trapezowata - Segment->GetRolls(roll1, roll2); - bpts1[0] = vector6(fHTW * cos(roll1), -fHTW * sin(roll1), - 0.5 - map1); // lewy brzeg początku - bpts1[1] = vector6(-bpts1[0].x, -bpts1[0].y, - 0.5 + map1); // prawy brzeg początku symetrycznie - bpts1[2] = vector6(fHTW2 * cos(roll2), -fHTW2 * sin(roll2), - 0.5 - map2); // lewy brzeg końca - bpts1[3] = vector6(-bpts1[2].x, -bpts1[2].y, - 0.5 + map2); // prawy brzeg początku symetrycznie - } - else - { - bpts1[0] = vector6(fHTW, 0.0, 0.5 - map1); // zawsze standardowe mapowanie - bpts1[1] = vector6(-fHTW, 0.0, 0.5 + map1); - } + gfx::vertex_array bpts1; // punkty głównej płaszczyzny przydają się do robienia boków + if (m_material1 || m_material2) { // punkty się przydadzą, nawet jeśli nawierzchni nie ma + create_road_profile( bpts1 ); } - if (TextureID1) // jeśli podana była tekstura, generujemy trójkąty + if (m_material1) // jeśli podana była tekstura, generujemy trójkąty { // tworzenie trójkątów nawierzchni szosy - Segment->RaRenderLoft(Vert, bpts1, iTrapezoid ? -2 : 2, fTexLength); + gfx::vertex_array vertices; + Segment->RenderLoft(vertices, m_origin, bpts1, iTrapezoid ? -2 : 2, fTexLength); + Geometry1.emplace_back( GfxRenderer.Insert( vertices, Bank, GL_TRIANGLE_STRIP ) ); } - if (TextureID2) - { // pobocze drogi - poziome przy przechyłce (a może krawężnik i chodnik zrobić jak w - // Midtown Madness 2?) - vector6 rpts1[6], - rpts2[6]; // współrzędne przekroju i mapowania dla prawej i lewej strony - rpts1[0] = vector6(rozp, -fTexHeight1, 0.0); // lewy brzeg podstawy - rpts1[1] = vector6(bpts1[0].x + side, bpts1[0].y, 0.5), // lewa krawędź załamania - rpts1[2] = vector6(bpts1[0].x, bpts1[0].y, - 1.0); // lewy brzeg pobocza (mapowanie może być inne - rpts2[0] = vector6(bpts1[1].x, bpts1[1].y, 1.0); // prawy brzeg pobocza - rpts2[1] = vector6(bpts1[1].x - side, bpts1[1].y, 0.5); // prawa krawędź załamania - rpts2[2] = vector6(-rozp, -fTexHeight1, 0.0); // prawy brzeg podstawy + if (m_material2) + { // pobocze drogi - poziome przy przechyłce (a może krawężnik i chodnik zrobić jak w Midtown Madness 2?) + gfx::vertex_array rpts1, rpts2; // współrzędne przekroju i mapowania dla prawej i lewej strony + create_road_side_profile( rpts1, rpts2, bpts1 ); + gfx::vertex_array vertices; if (iTrapezoid) // trapez albo przechyłki { // pobocza do trapezowatej nawierzchni - dodatkowe punkty z drugiej strony odcinka - rpts1[3] = vector6(rozp2, -fTexHeight2, 0.0); // lewy brzeg lewego pobocza - rpts1[4] = vector6(bpts1[2].x + side2, bpts1[2].y, 0.5); // krawędź załamania - rpts1[5] = vector6(bpts1[2].x, bpts1[2].y, 1.0); // brzeg pobocza - rpts2[3] = vector6(bpts1[3].x, bpts1[3].y, 1.0); - rpts2[4] = vector6(bpts1[3].x - side2, bpts1[3].y, 0.5); - rpts2[5] = vector6(-rozp2, -fTexHeight2, 0.0); // prawy brzeg prawego pobocza - Segment->RaRenderLoft(Vert, rpts1, -3, fTexLength); - Segment->RaRenderLoft(Vert, rpts2, -3, fTexLength); + Segment->RenderLoft(vertices, m_origin, rpts1, -3, fTexLength); + Geometry2.emplace_back( GfxRenderer.Insert( vertices, Bank, GL_TRIANGLE_STRIP ) ); + vertices.clear(); + Segment->RenderLoft(vertices, m_origin, rpts2, -3, fTexLength); + Geometry2.emplace_back( GfxRenderer.Insert( vertices, Bank, GL_TRIANGLE_STRIP ) ); + vertices.clear(); } else { // pobocza zwykłe, brak przechyłki - Segment->RaRenderLoft(Vert, rpts1, 3, fTexLength); - Segment->RaRenderLoft(Vert, rpts2, 3, fTexLength); + Segment->RenderLoft(vertices, m_origin, rpts1, 3, fTexLength); + Geometry2.emplace_back( GfxRenderer.Insert( vertices, Bank, GL_TRIANGLE_STRIP ) ); + vertices.clear(); + Segment->RenderLoft(vertices, m_origin, rpts2, 3, fTexLength); + Geometry2.emplace_back( GfxRenderer.Insert( vertices, Bank, GL_TRIANGLE_STRIP ) ); + vertices.clear(); } } } } break; } -}; - -void TTrack::RaRenderVBO(int iPtr) -{ // renderowanie z użyciem VBO - // Ra 2014-07: trzeba wymienić GL_TRIANGLE_STRIP na GL_TRIANGLES i renderować trójkąty sektora - // dla kolejnych tekstur! - EnvironmentSet(); - int seg; - int i; - switch (iCategoryFlag & 15) - { - case 1: // tor - if (eType == tt_Switch) // dla zwrotnicy tylko szyny - { - if (TextureID1) - if ((seg = SwitchExtension->Segments[0]->RaSegCount()) > 0) - { - TextureManager.Bind( TextureID1 ); // szyny + - for (i = 0; i < seg; ++i) - glDrawArrays(GL_TRIANGLE_STRIP, iPtr + 24 * i, 24); - iPtr += 24 * seg; // pominięcie lewej szyny - for (i = 0; i < seg; ++i) - glDrawArrays(GL_TRIANGLE_STRIP, iPtr + 24 * i, 24); - iPtr += 24 * seg; // pominięcie prawej szyny - } - if (TextureID2) - if ((seg = SwitchExtension->Segments[1]->RaSegCount()) > 0) - { - TextureManager.Bind( TextureID2 ); // szyny - - for (i = 0; i < seg; ++i) - glDrawArrays(GL_TRIANGLE_STRIP, iPtr + 24 * i, 24); - iPtr += 24 * seg; // pominięcie lewej szyny - for (i = 0; i < seg; ++i) - glDrawArrays(GL_TRIANGLE_STRIP, iPtr + 24 * i, 24); - } - } - else // dla toru podsypka plus szyny - { - if ((seg = Segment->RaSegCount()) > 0) - { - if (TextureID2) - { - TextureManager.Bind( TextureID2 ); // podsypka - for (i = 0; i < seg; ++i) - glDrawArrays(GL_TRIANGLE_STRIP, iPtr + 8 * i, 8); - iPtr += 8 * seg; // pominięcie podsypki - } - if (TextureID1) - { - TextureManager.Bind( TextureID1 ); // szyny - for (i = 0; i < seg; ++i) - glDrawArrays(GL_TRIANGLE_STRIP, iPtr + 24 * i, 24); - iPtr += 24 * seg; // pominięcie lewej szyny - for (i = 0; i < seg; ++i) - glDrawArrays(GL_TRIANGLE_STRIP, iPtr + 24 * i, 24); - } - } - } - break; - case 2: // droga - if ((seg = Segment->RaSegCount()) > 0) - { - if (TextureID1) - { - TextureManager.Bind( TextureID1 ); // nawierzchnia - for (i = 0; i < seg; ++i) - { - glDrawArrays(GL_TRIANGLE_STRIP, iPtr, 4); - iPtr += 4; - } - } - if (TextureID2) - { - TextureManager.Bind( TextureID2 ); // pobocze - if (fTexHeight1 >= 0.0) - { // normalna droga z poboczem - for (i = 0; i < seg; ++i) - glDrawArrays(GL_TRIANGLE_STRIP, iPtr + 6 * i, 6); - iPtr += 6 * seg; // pominięcie lewego pobocza - for (i = 0; i < seg; ++i) - glDrawArrays(GL_TRIANGLE_STRIP, iPtr + 6 * i, 6); - } - else - { // z chodnikami o różnych szerokociach - if (fTexWidth != 0.0) - { - for (i = 0; i < seg; ++i) - glDrawArrays(GL_TRIANGLE_STRIP, iPtr + 6 * i, 6); - iPtr += 6 * seg; // pominięcie lewego pobocza - } - if (fTexSlope != 0.0) - for (i = 0; i < seg; ++i) - glDrawArrays(GL_TRIANGLE_STRIP, iPtr + 6 * i, 6); - } - } - } - break; - case 4: // rzeki - jeszcze do przemyślenia - if ((seg = Segment->RaSegCount()) > 0) - { - if (TextureID1) - { - TextureManager.Bind( TextureID1 ); // nawierzchnia - for (i = 0; i < seg; ++i) - { - glDrawArrays(GL_TRIANGLE_STRIP, iPtr, 4); - iPtr += 4; - } - } - if (TextureID2) - { - TextureManager.Bind( TextureID2 ); // pobocze - for (i = 0; i < seg; ++i) - glDrawArrays(GL_TRIANGLE_STRIP, iPtr + 6 * i, 6); - iPtr += 6 * seg; // pominięcie lewego pobocza - for (i = 0; i < seg; ++i) - glDrawArrays(GL_TRIANGLE_STRIP, iPtr + 6 * i, 6); - } - } - break; - } - EnvironmentReset(); -}; - -void TTrack::EnvironmentSet() -{ // ustawienie zmienionego światła - glColor3f(1.0f, 1.0f, 1.0f); // Ra: potrzebne to? - if (eEnvironment) - { // McZapkie-310702: zmiana oswietlenia w tunelu, wykopie - GLfloat ambientLight[4] = {0.5f, 0.5f, 0.5f, 1.0f}; - GLfloat diffuseLight[4] = {0.5f, 0.5f, 0.5f, 1.0f}; - GLfloat specularLight[4] = {0.5f, 0.5f, 0.5f, 1.0f}; - switch (eEnvironment) - { // modyfikacje oświetlenia zależnie od środowiska - case e_canyon: - for (int li = 0; li < 3; li++) - { - // ambientLight[li]= Global::ambientDayLight[li]*0.8; //0.7 - diffuseLight[li] = Global::diffuseDayLight[li] * 0.4; // 0.3 - specularLight[li] = Global::specularDayLight[li] * 0.5; // 0.4 - } - // glLightfv(GL_LIGHT0,GL_AMBIENT,ambientLight); - glLightfv(GL_LIGHT0, GL_DIFFUSE, diffuseLight); - glLightfv(GL_LIGHT0, GL_SPECULAR, specularLight); - break; - case e_tunnel: - for (int li = 0; li < 3; li++) - { - ambientLight[li] = Global::ambientDayLight[li] * 0.2; - diffuseLight[li] = Global::diffuseDayLight[li] * 0.1; - specularLight[li] = Global::specularDayLight[li] * 0.2; - } - glLightfv(GL_LIGHT0, GL_AMBIENT, ambientLight); - glLightfv(GL_LIGHT0, GL_DIFFUSE, diffuseLight); - glLightfv(GL_LIGHT0, GL_SPECULAR, specularLight); - break; - } - } -}; - -void TTrack::EnvironmentReset() -{ // przywrócenie domyślnego światła - switch (eEnvironment) - { // przywrócenie globalnych ustawień światła, o ile było zmienione - case e_canyon: // wykop - case e_tunnel: // tunel - glLightfv(GL_LIGHT0, GL_AMBIENT, Global::ambientDayLight); - glLightfv(GL_LIGHT0, GL_DIFFUSE, Global::diffuseDayLight); - glLightfv(GL_LIGHT0, GL_SPECULAR, Global::specularDayLight); - } -}; - -void TTrack::RenderDyn() -{ // renderowanie nieprzezroczystych fragmentów pojazdów -#ifdef EU07_USE_OLD_TTRACK_DYNAMICS_ARRAY - if (!iNumDynamics) - return; // po co kombinować, jeśli nie ma pojazdów? - // EnvironmentSet(); //Ra: pojazdy sobie same teraz liczą cienie - for (int i = 0; i < iNumDynamics; i++) - Dynamics[i]->Render(); // sam sprawdza, czy VBO; zmienia kontekst VBO! - // EnvironmentReset(); -#else - for( auto dynamic : Dynamics ) { - // sam sprawdza, czy VBO; zmienia kontekst VBO! - dynamic->Render(); - } -#endif -}; - -void TTrack::RenderDynAlpha() -{ // renderowanie przezroczystych fragmentów pojazdów -#ifdef EU07_USE_OLD_TTRACK_DYNAMICS_ARRAY - if (!iNumDynamics) - return; // po co kombinować, jeśli nie ma pojazdów? - // EnvironmentSet(); //Ra: pojazdy sobie same teraz liczą cienie - for (int i = 0; i < iNumDynamics; i++) - Dynamics[i]->RenderAlpha(); // sam sprawdza, czy VBO; zmienia kontekst VBO! - // EnvironmentReset(); -#else - for( auto dynamic : Dynamics ) { - // sam sprawdza, czy VBO; zmienia kontekst VBO! - dynamic->RenderAlpha(); - } -#endif + return; }; void TTrack::RenderDynSounds() { // odtwarzanie dźwięków pojazdów jest niezależne od ich wyświetlania -#ifdef EU07_USE_OLD_TTRACK_DYNAMICS_ARRAY - for( int i = 0; i < iNumDynamics; i++ ) - Dynamics[i]->RenderSounds(); -#else for( auto dynamic : Dynamics ) { dynamic->RenderSounds(); } -#endif }; //--------------------------------------------------------------------------- bool TTrack::SetConnections(int i) @@ -2699,14 +1569,14 @@ bool TTrack::SetConnections(int i) return false; } -bool TTrack::Switch(int i, double t, double d) +bool TTrack::Switch(int i, float const t, float const d) { // przełączenie torów z uruchomieniem animacji if (SwitchExtension) // tory przełączalne mają doklejkę if (eType == tt_Switch) { // przekładanie zwrotnicy jak zwykle - if (t > 0.0) // prędkość liniowa ruchu iglic + if (t > 0.f) // prędkość liniowa ruchu iglic SwitchExtension->fOffsetSpeed = t; // prędkość łatwiej zgrać z animacją modelu - if (d >= 0.0) // dodatkowy ruch drugiej iglicy (zamknięcie nastawnicze) + if (d >= 0.f) // dodatkowy ruch drugiej iglicy (zamknięcie nastawnicze) SwitchExtension->fOffsetDelay = d; i &= 1; // ograniczenie błędów !!!! SwitchExtension->fDesiredOffset = @@ -2718,21 +1588,25 @@ bool TTrack::Switch(int i, double t, double d) iNextDirection = SwitchExtension->iNextDirection[i]; iPrevDirection = SwitchExtension->iPrevDirection[i]; fRadius = fRadiusTable[i]; // McZapkie: wybor promienia toru - if (SwitchExtension->fVelocity <= - -2) //-1 oznacza maksymalną prędkość, a dalsze ujemne to ograniczenie na bok + if( SwitchExtension->fVelocity <= -2 ) { + //-1 oznacza maksymalną prędkość, a dalsze ujemne to ograniczenie na bok fVelocity = i ? -SwitchExtension->fVelocity : -1; + } + else { + fVelocity = SwitchExtension->fVelocity; + } if (SwitchExtension->pOwner ? SwitchExtension->pOwner->RaTrackAnimAdd(this) : true) // jeśli nie dodane do animacji { // nie ma się co bawić SwitchExtension->fOffset = SwitchExtension->fDesiredOffset; - RaAnimate(); // przeliczenie położenia iglic; czy zadziała na niewyświetlanym - // sektorze w VBO? + // przeliczenie położenia iglic; czy zadziała na niewyświetlanym sektorze w VBO? + RaAnimate(); } return true; } else if (eType == tt_Table) { // blokowanie (0, szukanie torów) lub odblokowanie (1, rozłączenie) obrotnicy - if (i) + if (i) // NOTE: this condition seems opposite to intention/comment? TODO: investigate this { // 0: rozłączenie sąsiednich torów od obrotnicy if (trPrev) // jeśli jest tor od Point1 obrotnicy if (iPrevDirection) // 0:dołączony Point1, 1:dołączony Point2 @@ -2749,25 +1623,30 @@ bool TTrack::Switch(int i, double t, double d) fVelocity = 0.0; // AI, nie ruszaj się! if (SwitchExtension->pOwner) SwitchExtension->pOwner->RaTrackAnimAdd(this); // dodanie do listy animacyjnej + // TODO: unregister path ends in the owner cell } else { // 1: ustalenie finalnego położenia (gdy nie było animacji) RaAnimate(); // ostatni etap animowania // zablokowanie pozycji i połączenie do sąsiednich torów - Global::pGround->TrackJoin(SwitchExtension->pMyNode); + // TODO: register new position of the path endpoints with the region + simulation::Region->TrackJoin( this ); if (trNext || trPrev) { fVelocity = 6.0; // jazda dozwolona - if (trPrev) - if (trPrev->fVelocity == - 0.0) // ustawienie 0 da możliwość zatrzymania AI na obrotnicy - trPrev->VelocitySet(6.0); // odblokowanie dołączonego toru do jazdy - if (trNext) - if (trNext->fVelocity == 0.0) - trNext->VelocitySet(6.0); - if (SwitchExtension->evPlus) // w starych sceneriach może nie być - Global::AddToQuery(SwitchExtension->evPlus, - NULL); // potwierdzenie wykonania (np. odpala WZ) + if( ( trPrev ) + && ( trPrev->fVelocity == 0.0 ) ) { + // ustawienie 0 da możliwość zatrzymania AI na obrotnicy + trPrev->VelocitySet( 6.0 ); // odblokowanie dołączonego toru do jazdy + } + if( ( trNext ) + && ( trNext->fVelocity == 0.0 ) ) { + trNext->VelocitySet( 6.0 ); + } + if( SwitchExtension->evPlus ) { // w starych sceneriach może nie być + // potwierdzenie wykonania (np. odpala WZ) + simulation::Events.AddToQuery( SwitchExtension->evPlus, nullptr ); + } } } SwitchExtension->CurrentIndex = i; // zapamiętanie stanu zablokowania @@ -2802,11 +1681,11 @@ bool TTrack::SwitchForced(int i, TDynamicObject *o) { case 0: if (SwitchExtension->evPlus) - Global::AddToQuery(SwitchExtension->evPlus, o); // dodanie do kolejki + simulation::Events.AddToQuery(SwitchExtension->evPlus, o); // dodanie do kolejki break; case 1: if (SwitchExtension->evMinus) - Global::AddToQuery(SwitchExtension->evMinus, o); // dodanie do kolejki + simulation::Events.AddToQuery(SwitchExtension->evMinus, o); // dodanie do kolejki break; } Switch(i); // jeśli się tu nie przełączy, to każdy pojazd powtórzy event rozrprucia @@ -2826,18 +1705,18 @@ int TTrack::CrossSegment(int from, int into) switch (into) { case 0: // stop - // WriteLog("Crossing from P"+AnsiString(from+1)+" into stop on "+pMyNode->asName); +// WriteLog( "Stopping in P" + to_string( from + 1 ) + " on " + name() ); break; case 1: // left - // WriteLog("Crossing from P"+AnsiString(from+1)+" to left on "+pMyNode->asName); +// WriteLog( "Turning left from P" + to_string( from + 1 ) + " on " + name() ); i = (SwitchExtension->iRoads == 4) ? iLewo4[from] : iLewo3[from]; break; case 2: // right - // WriteLog("Crossing from P"+AnsiString(from+1)+" to right on "+pMyNode->asName); +// WriteLog( "Turning right from P" + to_string( from + 1 ) + " on " + name() ); i = (SwitchExtension->iRoads == 4) ? iPrawo4[from] : iPrawo3[from]; break; case 3: // stright - // WriteLog("Crossing from P"+AnsiString(from+1)+" to straight on "+pMyNode->asName); +// WriteLog( "Going straight from P" + to_string( from + 1 ) + " on " + name() ); i = (SwitchExtension->iRoads == 4) ? iProsto4[from] : iProsto3[from]; break; } @@ -2875,21 +1754,21 @@ void TTrack::RaAnimListAdd(TTrack *t) TTrack * TTrack::RaAnimate() { // wykonanie rekurencyjne animacji, wywoływane przed wyświetleniem sektora // zwraca wskaźnik toru wymagającego dalszej animacji - if (SwitchExtension->pNextAnim) + if( SwitchExtension->pNextAnim ) SwitchExtension->pNextAnim = SwitchExtension->pNextAnim->RaAnimate(); bool m = true; // animacja trwa if (eType == tt_Switch) // dla zwrotnicy tylko szyny { - double v = SwitchExtension->fDesiredOffset - SwitchExtension->fOffset; // kierunek + auto const v = SwitchExtension->fDesiredOffset - SwitchExtension->fOffset; // kierunek SwitchExtension->fOffset += sign(v) * Timer::GetDeltaTime() * SwitchExtension->fOffsetSpeed; // Ra: trzeba dać to do klasy... SwitchExtension->fOffset1 = SwitchExtension->fOffset; SwitchExtension->fOffset2 = SwitchExtension->fOffset; - if (SwitchExtension->fOffset1 >= fMaxOffset) + if (SwitchExtension->fOffset1 > fMaxOffset) SwitchExtension->fOffset1 = fMaxOffset; // ograniczenie animacji zewnętrznej iglicy - if (SwitchExtension->fOffset2 <= 0.00) - SwitchExtension->fOffset2 = 0.0; // ograniczenie animacji wewnętrznej iglicy - if (v < 0) + if (SwitchExtension->fOffset2 < 0.f) + SwitchExtension->fOffset2 = 0.f; // ograniczenie animacji wewnętrznej iglicy + if (v < 0.f) { // jak na pierwszy z torów if (SwitchExtension->fOffset <= SwitchExtension->fDesiredOffset) { @@ -2905,90 +1784,61 @@ TTrack * TTrack::RaAnimate() m = false; // koniec animacji } } - if (Global::bUseVBO) - { // dla OpenGL 1.4 odświeży się cały sektor, w późniejszych poprawiamy fragment - if (true == GLEW_VERSION_1_5) // dla OpenGL 1.4 to się nie wykona poprawnie - if (TextureID1) // Ra: !!!! tu jest do poprawienia - { // iglice liczone tylko dla zwrotnic - vector6 rpts3[24], rpts4[24]; - double fHTW = 0.5 * fabs(fTrackWidth); - double fHTW2 = fHTW; // Ra: na razie niech tak będzie - double cos1 = 1.0, sin1 = 0.0, cos2 = 1.0, sin2 = 0.0; // Ra: ... - for (int i = 0; i < 12; ++i) - { - rpts3[i] = - vector6((fHTW + iglica[i].x) * cos1 + iglica[i].y * sin1, - -(fHTW + iglica[i].x) * sin1 + iglica[i].y * cos1, iglica[i].z); - rpts3[i + 12] = - vector6((fHTW2 + szyna[i].x) * cos2 + szyna[i].y * sin2, - -(fHTW2 + szyna[i].x) * sin2 + iglica[i].y * cos2, szyna[i].z); - rpts4[11 - i] = vector6((-fHTW - iglica[i].x) * cos1 + iglica[i].y * sin1, - -(-fHTW - iglica[i].x) * sin1 + iglica[i].y * cos1, - iglica[i].z); - rpts4[23 - i] = - vector6((-fHTW2 - szyna[i].x) * cos2 + szyna[i].y * sin2, - -(-fHTW2 - szyna[i].x) * sin2 + iglica[i].y * cos2, szyna[i].z); - } - CVertNormTex Vert[2 * 2 * 12]; // na razie 2 segmenty - CVertNormTex *v = Vert; // bo RaAnimate() modyfikuje wskaźnik - glGetBufferSubData( - GL_ARRAY_BUFFER, SwitchExtension->iLeftVBO * sizeof(CVertNormTex), - 2 * 2 * 12 * sizeof(CVertNormTex), &Vert); // pobranie fragmentu bufora VBO - if (SwitchExtension->RightSwitch) - { // nowa wersja z SPKS, ale odwrotnie lewa/prawa - SwitchExtension->Segments[0]->RaAnimate(v, rpts3, -nnumPts, fTexLength, 0, - 2, SwitchExtension->fOffset2); - glBufferSubData(GL_ARRAY_BUFFER, - SwitchExtension->iLeftVBO * sizeof(CVertNormTex), - 2 * 2 * 12 * sizeof(CVertNormTex), - &Vert); // wysłanie fragmentu bufora VBO - v = Vert; - glGetBufferSubData(GL_ARRAY_BUFFER, - SwitchExtension->iRightVBO * sizeof(CVertNormTex), - 2 * 2 * 12 * sizeof(CVertNormTex), - &Vert); // pobranie fragmentu bufora VBO - SwitchExtension->Segments[1]->RaAnimate(v, rpts4, -nnumPts, fTexLength, 0, - 2, -fMaxOffset + - SwitchExtension->fOffset1); - } - else - { // oryginalnie lewa działała lepiej niż prawa - SwitchExtension->Segments[0]->RaAnimate( - v, rpts4, -nnumPts, fTexLength, 0, 2, - -SwitchExtension->fOffset2); // prawa iglica - glBufferSubData(GL_ARRAY_BUFFER, - SwitchExtension->iLeftVBO * sizeof(CVertNormTex), - 2 * 2 * 12 * sizeof(CVertNormTex), - &Vert); // wysłanie fragmentu bufora VBO - v = Vert; - glGetBufferSubData(GL_ARRAY_BUFFER, - SwitchExtension->iRightVBO * sizeof(CVertNormTex), - 2 * 2 * 12 * sizeof(CVertNormTex), - &Vert); // pobranie fragmentu bufora VBO - SwitchExtension->Segments[1]->RaAnimate( - v, rpts3, -nnumPts, fTexLength, 0, 2, - fMaxOffset - SwitchExtension->fOffset1); // lewa iglica - } - glBufferSubData( - GL_ARRAY_BUFFER, SwitchExtension->iRightVBO * sizeof(CVertNormTex), - 2 * 2 * 12 * sizeof(CVertNormTex), &Vert); // wysłanie fragmentu bufora VBO + // skip the geometry update if no geometry for this track was generated yet + if( ( ( m_material1 != 0 ) + || ( m_material2 != 0 ) ) + && ( ( false == Geometry1.empty() ) + || ( false == Geometry2.empty() ) ) ) { + // iglice liczone tylko dla zwrotnic + gfx::vertex_array rpts3, rpts4; + create_track_blade_profile( rpts3, rpts4 ); + gfx::vertex_array vertices; + auto const bladelength { static_cast( std::ceil( SwitchExtension->Segments[ 0 ]->RaSegCount() * 0.65 ) ) }; + if (SwitchExtension->RightSwitch) + { // nowa wersja z SPKS, ale odwrotnie lewa/prawa + if( m_material1 ) { + auto const texturelength { texture_length( m_material1 ) }; + // left blade + SwitchExtension->Segments[ 0 ]->RenderLoft( vertices, m_origin, rpts3, -nnumPts, texturelength, 1.0, 0, bladelength, SwitchExtension->fOffset2 ); + GfxRenderer.Replace( vertices, Geometry1[ 2 ] ); + vertices.clear(); } + if( m_material2 ) { + auto const texturelength { texture_length( m_material2 ) }; + // right blade + SwitchExtension->Segments[ 1 ]->RenderLoft( vertices, m_origin, rpts4, -nnumPts, texturelength, 1.0, 0, bladelength, -fMaxOffset + SwitchExtension->fOffset1 ); + GfxRenderer.Replace( vertices, Geometry2[ 2 ] ); + vertices.clear(); + } + } + else { // lewa działa lepiej niż prawa + if( m_material1 ) { + auto const texturelength { texture_length( m_material1 ) }; + // right blade + SwitchExtension->Segments[ 0 ]->RenderLoft( vertices, m_origin, rpts4, -nnumPts, texturelength, 1.0, 0, bladelength, -SwitchExtension->fOffset2 ); + GfxRenderer.Replace( vertices, Geometry1[ 2 ] ); + vertices.clear(); + } + if( m_material2 ) { + auto const texturelength { texture_length( m_material2 ) }; + // left blade + SwitchExtension->Segments[ 1 ]->RenderLoft( vertices, m_origin, rpts3, -nnumPts, texturelength, 1.0, 0, bladelength, fMaxOffset - SwitchExtension->fOffset1 ); + GfxRenderer.Replace( vertices, Geometry2[ 2 ] ); + vertices.clear(); + } + } } - else // gdy Display List - Release(); // niszczenie skompilowanej listy, aby się wygenerowała nowa } - else if (eType == tt_Table) // dla obrotnicy - szyny i podsypka - { + else if (eType == tt_Table) { + // dla obrotnicy - szyny i podsypka if (SwitchExtension->pModel && SwitchExtension->CurrentIndex) // 0=zablokowana się nie animuje { // trzeba każdorazowo porównywać z kątem modelu - // SwitchExtension->fOffset1=SwitchExtension->pAnim?SwitchExtension->pAnim->AngleGet():0.0; // //pobranie kąta z modelu - TAnimContainer *ac = SwitchExtension->pModel ? - SwitchExtension->pModel->GetContainer(NULL) : - NULL; // pobranie głównego submodelu - // if (ac) ac->EventAssign(SwitchExtension->evMinus); //event zakończenia animacji, - // trochę bez sensu tutaj + TAnimContainer *ac = ( + SwitchExtension->pModel ? + SwitchExtension->pModel->GetContainer() : // pobranie głównego submodelu + nullptr ); if (ac) if ((ac->AngleGet() != SwitchExtension->fOffset) || !(ac->TransGet() == @@ -2997,44 +1847,20 @@ TTrack * TTrack::RaAnimate() double hlen = 0.5 * SwitchExtension->Segments[0]->GetLength(); // połowa // długości SwitchExtension->fOffset = ac->AngleGet(); // pobranie kąta z submodelu - double sina = -hlen * sin(DegToRad(SwitchExtension->fOffset)), - cosa = -hlen * cos(DegToRad(SwitchExtension->fOffset)); + double sina = -hlen * std::sin(glm::radians(SwitchExtension->fOffset)), + cosa = -hlen * std::cos(glm::radians(SwitchExtension->fOffset)); SwitchExtension->vTrans = ac->TransGet(); - vector3 middle = - SwitchExtension->pMyNode->pCenter + + auto middle = + location() + SwitchExtension->vTrans; // SwitchExtension->Segments[0]->FastGetPoint(0.5); - Segment->Init(middle + vector3(sina, 0.0, cosa), - middle - vector3(sina, 0.0, cosa), 5.0); // nowy odcinek -#ifdef EU07_USE_OLD_TTRACK_DYNAMICS_ARRAY - for( int i = 0; i < iNumDynamics; i++ ) - Dynamics[i]->Move(0.000001); // minimalny ruch, aby przeliczyć pozycję i -#else + Segment->Init(middle + Math3D::vector3(sina, 0.0, cosa), + middle - Math3D::vector3(sina, 0.0, cosa), 10.0); // nowy odcinek for( auto dynamic : Dynamics ) { // minimalny ruch, aby przeliczyć pozycję dynamic->Move( 0.000001 ); } -#endif - // kąty - if (Global::bUseVBO) - { // dla OpenGL 1.4 odświeży się cały sektor, w późniejszych poprawiamy fragment - // aktualizacja pojazdów na torze - if (true == GLEW_VERSION_1_5) // dla OpenGL 1.4 to się nie wykona poprawnie - { - int size = - RaArrayPrepare(); // wielkość tabeli potrzebna dla tej obrotnicy - CVertNormTex *Vert = new CVertNormTex[size]; // bufor roboczy - // CVertNormTex *v=Vert; //zmieniane przez - RaArrayFill(Vert, - Vert - - SwitchExtension - ->iLeftVBO); // iLeftVBO powinno zostać niezmienione - glBufferSubData( - GL_ARRAY_BUFFER, SwitchExtension->iLeftVBO * sizeof(CVertNormTex), - size * sizeof(CVertNormTex), Vert); // wysłanie fragmentu bufora VBO - } - } - else // gdy Display List - Release(); // niszczenie skompilowanej listy, aby się wygenerowała nowa + // NOTE: passing empty handle is a bit of a hack here. could be refactored into something more elegant + create_geometry( {} ); } // animacja trwa nadal } else @@ -3045,15 +1871,9 @@ TTrack * TTrack::RaAnimate() //--------------------------------------------------------------------------- void TTrack::RadioStop() { // przekazanie pojazdom rozkazu zatrzymania -#ifdef EU07_USE_OLD_TTRACK_DYNAMICS_ARRAY - for (int i = 0; i < iNumDynamics; i++) - Dynamics[i]->RadioStop(); -#else for( auto dynamic : Dynamics ) { dynamic->RadioStop(); } -#endif - }; double TTrack::WidthTotal() @@ -3074,7 +1894,7 @@ bool TTrack::IsGroupable() return true; }; -bool Equal(vector3 v1, vector3 *v2) +bool Equal( Math3D::vector3 v1, Math3D::vector3 *v2) { // sprawdzenie odległości punktów // Ra: powinno być do 100cm wzdłuż toru i ze 2cm w poprzek (na prostej może nie być długiego // kawałka) @@ -3089,7 +1909,7 @@ bool Equal(vector3 v1, vector3 *v2) // return (SquareMagnitude(v1-*v2)<0.00012); //0.011^2=0.00012 }; -int TTrack::TestPoint(vector3 *Point) +int TTrack::TestPoint( Math3D::vector3 *Point) { // sprawdzanie, czy tory można połączyć switch (eType) { @@ -3157,54 +1977,270 @@ int TTrack::TestPoint(vector3 *Point) return -1; }; -void TTrack::MovedUp1(double dh) +// retrieves list of the track's end points +std::vector +TTrack::endpoints() const { + + switch( eType ) { + case tt_Normal: + case tt_Table: { + return { + glm::dvec3{ Segment->FastGetPoint_0() }, + glm::dvec3{ Segment->FastGetPoint_1() } }; + } + case tt_Switch: + case tt_Cross: { + return { + glm::dvec3{ SwitchExtension->Segments[ 0 ]->FastGetPoint_0() }, + glm::dvec3{ SwitchExtension->Segments[ 0 ]->FastGetPoint_1() }, + glm::dvec3{ SwitchExtension->Segments[ 1 ]->FastGetPoint_0() }, + glm::dvec3{ SwitchExtension->Segments[ 1 ]->FastGetPoint_1() } }; + } + default: { + return{}; + } + } +} + +// radius() subclass details, calculates node's bounding radius +float +TTrack::radius_() { + + auto const points { endpoints() }; + auto radius { 0.f }; + for( auto &point : points ) { + radius = std::max( + radius, + static_cast( glm::length( m_area.center - point ) ) ); // extra margin to prevent driven vehicle from flicking + } + return radius; +} + +// serialize() subclass details, sends content of the subclass to provided stream +void +TTrack::serialize_( std::ostream &Output ) const { + + // TODO: implement +} +// deserialize() subclass details, restores content of the subclass from provided stream +void +TTrack::deserialize_( std::istream &Input ) { + + // TODO: implement +} + +// export() subclass details, sends basic content of the class in legacy (text) format to provided stream +void +TTrack::export_as_text_( std::ostream &Output ) const { + // header + Output << "track "; + // type + Output << ( + eType == tt_Normal ? ( + iCategoryFlag == 1 ? "normal" : + iCategoryFlag == 2 ? "road" : + iCategoryFlag == 4 ? "river" : + "none" ) : + eType == tt_Switch ? "switch" : + eType == tt_Cross ? "cross" : + eType == tt_Table ? "turn" : + eType == tt_Tributary ? "tributary" : + "none" ) + << ' '; + // basic attributes + Output + << Length() << ' ' + << fTrackWidth << ' ' + << fFriction << ' ' + << fSoundDistance << ' ' + << iQualityFlag << ' ' + << iDamageFlag << ' '; + // environment + Output << ( + eEnvironment == e_flat ? "flat" : + eEnvironment == e_bridge ? "bridge" : + eEnvironment == e_tunnel ? "tunnel" : + eEnvironment == e_bank ? "bank" : + eEnvironment == e_canyon ? "canyon" : + eEnvironment == e_mountains ? "mountains" : + "none" ) + << ' '; + // visibility + // NOTE: 'invis' would be less wrong than 'unvis', but potentially incompatible with old 3rd party tools + Output << ( m_visible ? "vis" : "unvis" ) << ' '; + if( m_visible ) { + // texture parameters are supplied only if the path is set as visible + auto texturefile { ( + m_material1 != null_handle ? + GfxRenderer.Material( m_material1 ).name : + "none" ) }; + if( texturefile.find( szTexturePath ) == 0 ) { + // don't include 'textures/' in the path + texturefile.erase( 0, std::string{ szTexturePath }.size() ); + } + Output + << texturefile << ' ' + << fTexLength << ' '; + + texturefile = ( + m_material2 != null_handle ? + GfxRenderer.Material( m_material2 ).name : + "none" ); + if( texturefile.find( szTexturePath ) == 0 ) { + // don't include 'textures/' in the path + texturefile.erase( 0, std::string{ szTexturePath }.size() ); + } + Output << texturefile << ' '; + + Output + << (fTexHeight1 - fTexHeightOffset ) * ( ( iCategoryFlag & 4 ) ? -1 : 1 ) << ' ' + << fTexWidth << ' ' + << fTexSlope << ' '; + } + // path data + for( auto const &path : m_paths ) { + Output + << path.points[ segment_data::point::start ].x << ' ' + << path.points[ segment_data::point::start ].y << ' ' + << path.points[ segment_data::point::start ].z << ' ' + << path.rolls[ 0 ] << ' ' + + << path.points[ segment_data::point::control1 ].x << ' ' + << path.points[ segment_data::point::control1 ].y << ' ' + << path.points[ segment_data::point::control1 ].z << ' ' + + << path.points[ segment_data::point::control2 ].x << ' ' + << path.points[ segment_data::point::control2 ].y << ' ' + << path.points[ segment_data::point::control2 ].z << ' ' + + << path.points[ segment_data::point::end ].x << ' ' + << path.points[ segment_data::point::end ].y << ' ' + << path.points[ segment_data::point::end ].z << ' ' + << path.rolls[ 1 ] << ' ' + + << path.radius << ' '; + } + // optional attributes + std::vector< std::pair< std::string, event_sequence const * > > const eventsequences { + { "event0", &m_events0 }, { "eventall0", &m_events0all }, + { "event1", &m_events1 }, { "eventall1", &m_events1all }, + { "event2", &m_events2 }, { "eventall2", &m_events2all } }; + + for( auto &eventsequence : eventsequences ) { + for( auto &event : *( eventsequence.second ) ) { + // NOTE: actual event name can be potentially different from its cached name, if it was renamed in the editor + // therefore on export we pull the name from the event itself, if the binding isn't broken + Output + << eventsequence.first << ' ' + << ( event.second != nullptr ? + event.second->m_name : + event.first ) + << ' '; + } + } + if( ( SwitchExtension ) + && ( SwitchExtension->fVelocity != -1.0 ) ) { + Output << "velocity " << SwitchExtension->fVelocity << ' '; + } + else { + if( fVelocity != -1.0 ) { + Output << "velocity " << fVelocity << ' '; + } + } + if( pIsolated ) { + Output << "isolated " << pIsolated->asName << ' '; + } + if( fOverhead != -1.0 ) { + Output << "overhead " << fOverhead << ' '; + } + if( fVerticalRadius != 0.f ) { + Output << "vradius " << fVerticalRadius << ' '; + } + // footer + Output + << "endtrack" + << "\n"; +} + +float +TTrack::texture_length( material_handle const Material ) { + + if( Material == null_handle ) { + return fTexLength; + } + auto const texturelength { GfxRenderer.Material( Material ).size.y }; + return ( + texturelength < 0.f ? + fTexLength : + texturelength ); +} + +void TTrack::MovedUp1(float const dh) { // poprawienie przechyłki wymaga wydłużenia podsypki fTexHeight1 += dh; + fTexHeightOffset += dh; }; -string TTrack::NameGet() -{ // ustalenie nazwy toru - if (this) - if (pMyNode) - return pMyNode->asName; - return "none"; -}; - -void TTrack::VelocitySet(float v) -{ // ustawienie prędkości z ograniczeniem do pierwotnej wartości (zapisanej w scenerii) - if (SwitchExtension ? SwitchExtension->fVelocity >= 0.0 : false) - { // zwrotnica może mieć odgórne ograniczenie, nieprzeskakiwalne eventem - if (v > SwitchExtension->fVelocity ? true : v < 0.0) - return void(fVelocity = - SwitchExtension->fVelocity); // maksymalnie tyle, ile było we wpisie +// ustawienie prędkości z ograniczeniem do pierwotnej wartości (zapisanej w scenerii) +void TTrack::VelocitySet(float v) { + // TBD, TODO: add a variable to preserve potential speed limit set by the track configuration on basic track pieces + if( ( SwitchExtension ) + && ( SwitchExtension->fVelocity != -1 ) ) { + // zwrotnica może mieć odgórne ograniczenie, nieprzeskakiwalne eventem + fVelocity = + min_speed( + v, + ( SwitchExtension->fVelocity > 0 ? + SwitchExtension->fVelocity : // positive limit applies to both switch tracks + ( SwitchExtension->CurrentIndex == 0 ? + -1 : // negative limit applies only to the diverging track + -SwitchExtension->fVelocity ) ) ); + } + else { + fVelocity = v; // nie ma ograniczenia } - fVelocity = v; // nie ma ograniczenia }; -float TTrack::VelocityGet() +double TTrack::VelocityGet() { // pobranie dozwolonej prędkości podczas skanowania - return ((iDamageFlag & 128) ? 0.0f : fVelocity); // tor uszkodzony = prędkość zerowa + return ((iDamageFlag & 128) ? 0.0 : fVelocity); // tor uszkodzony = prędkość zerowa }; void TTrack::ConnectionsLog() { // wypisanie informacji o połączeniach int i; - WriteLog("--> tt_Cross named " + pMyNode->asName); + WriteLog("--> tt_Cross named " + m_name); if (eType == tt_Cross) for (i = 0; i < 2; ++i) { if (SwitchExtension->pPrevs[i]) WriteLog("Point " + std::to_string(i + i + 1) + " -> track " + - SwitchExtension->pPrevs[i]->pMyNode->asName + ":" + + SwitchExtension->pPrevs[i]->m_name + ":" + std::to_string(int(SwitchExtension->iPrevDirection[i]))); if (SwitchExtension->pNexts[i]) WriteLog("Point " + std::to_string(i + i + 2) + " -> track " + - SwitchExtension->pNexts[i]->pMyNode->asName + ":" + + SwitchExtension->pNexts[i]->m_name + ":" + std::to_string(int(SwitchExtension->iNextDirection[i]))); } }; -TTrack * TTrack::Neightbour(int s, double &d) +bool +TTrack::DoubleSlip() const { + + // crude way to discern part of double slip switch: + // a switch with name ending in _a or _b or _c or _d + return ( + ( iCategoryFlag == 1 ) + && ( eType == tt_Switch ) + && ( m_name.size() > 2 ) + && ( m_name.back() >= 'a' ) + && ( m_name.back() <= 'd' ) + && ( ( m_name[ m_name.size() - 2 ] == '_' ) + || ( m_name.rfind( '_' ) != std::string::npos ) ) ); +} + + +TTrack * TTrack::Connected(int s, double &d) const { // zwraca wskaźnik na sąsiedni tor, w kierunku określonym znakiem (s), odwraca (d) w razie // niezgodności kierunku torów TTrack *t; // nie zmieniamy kierunku (d), jeśli nie ma toru dalej @@ -3253,3 +2289,969 @@ TTrack * TTrack::Neightbour(int s, double &d) } return NULL; }; + +// creates rail profile data for current track +void +TTrack::create_track_rail_profile( gfx::vertex_array &Right, gfx::vertex_array &Left ) { + + auto const fHTW { 0.5f * std::abs( fTrackWidth ) }; + + float + roll1{ 0.f }, + roll2{ 0.f }; + + if( Segment ) { + Segment->GetRolls( roll1, roll2 ); + } + + float const + sin1 { std::sin( roll1 ) }, + cos1 { std::cos( roll1 ) }, + sin2 { std::sin( roll2 ) }, + cos2 { std::cos( roll2 ) }; + + auto const pointcount { iTrapezoid == 0 ? 12 : 24 }; + Right.resize( pointcount ); + Left.resize( pointcount ); + + for( int i = 0; i < 12; ++i ) { + + Right[ i ] = { + // position + {( fHTW + szyna[ i ].position.x ) * cos1 + szyna[ i ].position.y * sin1, + -( fHTW + szyna[ i ].position.x ) * sin1 + szyna[ i ].position.y * cos1, + szyna[ i ].position.z}, + // normal + { szyna[ i ].normal.x * cos1 + szyna[ i ].normal.y * sin1, + -szyna[ i ].normal.x * sin1 + szyna[ i ].normal.y * cos1, + szyna[ i ].normal.z }, + // texture + { szyna[ i ].texture.x, + szyna[ i ].texture.y } }; + + Left[ 11 - i ] = { + // position + {(-fHTW - szyna[ i ].position.x ) * cos1 + szyna[ i ].position.y * sin1, + -(-fHTW - szyna[ i ].position.x ) * sin1 + szyna[ i ].position.y * cos1, + szyna[ i ].position.z}, + // normal + {-szyna[ i ].normal.x * cos1 + szyna[ i ].normal.y * sin1, + szyna[ i ].normal.x * sin1 + szyna[ i ].normal.y * cos1, + szyna[ i ].normal.z }, + // texture + { szyna[ i ].texture.x, + szyna[ i ].texture.y } }; + + if( iTrapezoid == 0 ) { continue; } + // trapez albo przechyłki, to oddzielne punkty na końcu + + Right[ 12 + i ] = { + // position + {( fHTW + szyna[ i ].position.x ) * cos2 + szyna[ i ].position.y * sin2, + -( fHTW + szyna[ i ].position.x ) * sin2 + szyna[ i ].position.y * cos2, + szyna[ i ].position.z}, + // normal + { szyna[ i ].normal.x * cos2 + szyna[ i ].normal.y * sin2, + -szyna[ i ].normal.x * sin2 + szyna[ i ].normal.y * cos2, + szyna[ i ].normal.z }, + // texture + { szyna[ i ].texture.x, + szyna[ i ].texture.y } }; + + Left[ 23 - i ] = { + // position + {(-fHTW - szyna[ i ].position.x ) * cos2 + szyna[ i ].position.y * sin2, + -(-fHTW - szyna[ i ].position.x ) * sin2 + szyna[ i ].position.y * cos2, + szyna[ i ].position.z}, + // normal + {-szyna[ i ].normal.x * cos2 + szyna[ i ].normal.y * sin2, + szyna[ i ].normal.x * sin2 + szyna[ i ].normal.y * cos2, + szyna[ i ].normal.z }, + // texture + { szyna[ i ].texture.x, + szyna[ i ].texture.y } }; + } +} + +// creates switch blades profile data for current track +void +TTrack::create_track_blade_profile( gfx::vertex_array &Right, gfx::vertex_array &Left ) { + + auto const fHTW { 0.5f * std::abs( fTrackWidth ) }; + float const fHTW2 { ( + ( iTrapezoid & 2 ) != 0 ? // ten bit oznacza, że istnieje odpowiednie pNext + 0.5f * std::fabs( trNext->fTrackWidth ) : // połowa rozstawu/nawierzchni + fHTW ) }; + + float + roll1 { 0.f }, + roll2 { 0.f }; + + if( Segment ) { + Segment->GetRolls( roll1, roll2 ); + } + + float const + sin1 { std::sin( roll1 ) }, + cos1 { std::cos( roll1 ) }, + sin2 { std::sin( roll2 ) }, + cos2 { std::cos( roll2 ) }; + + auto const pointcount { 24 }; + Right.resize( pointcount ); + Left.resize( pointcount ); + + glm::vec3 const flipxvalue { -1, 1, 1 }; + for( int i = 0; i < 12; ++i ) { + + Right[ i ] = { + {+( fHTW + iglica[ i ].position.x ) * cos1 + iglica[ i ].position.y * sin1, + -( fHTW + iglica[ i ].position.x ) * sin1 + iglica[ i ].position.y * cos1, + 0.f}, + {iglica[ i ].normal}, + {iglica[ i ].texture.x, 0.f} }; + Right[ i + 12 ] = { + {+( fHTW2 + szyna[ i ].position.x ) * cos2 + szyna[ i ].position.y * sin2, + -( fHTW2 + szyna[ i ].position.x ) * sin2 + iglica[ i ].position.y * cos2, + 0.f}, + {szyna[ i ].normal}, + {szyna[ i ].texture.x, 0.f} }; + Left[ 11 - i ] = { + { ( -fHTW - iglica[ i ].position.x ) * cos1 + iglica[ i ].position.y * sin1, + -( -fHTW - iglica[ i ].position.x ) * sin1 + iglica[ i ].position.y * cos1, + 0.f}, + {iglica[ i ].normal * flipxvalue}, + {iglica[ i ].texture.x, 0.f} }; + Left[ 23 - i ] = { + { ( -fHTW2 - szyna[ i ].position.x ) * cos2 + szyna[ i ].position.y * sin2, + -( -fHTW2 - szyna[ i ].position.x ) * sin2 + iglica[ i ].position.y * cos2, + 0.f}, + {szyna[ i ].normal * flipxvalue}, + {szyna[ i ].texture.x, 0.f} }; + } +} + +// creates trackbed profile data for current track +void +TTrack::create_track_bed_profile( gfx::vertex_array &Output, TTrack const *Previous, TTrack const *Next ) { + // geometry parameters + auto * profilesource = ( + eType != tt_Switch ? this : + Previous && Previous->eType != tt_Switch ? Previous : + Next && Next->eType != tt_Switch ? Next : + this ); + + auto const texheight1 { profilesource->fTexHeight1 }; + auto const texwidth { profilesource->fTexWidth }; + auto const texslope { profilesource->fTexSlope }; + + auto const fHTW { 0.5f * std::abs( fTrackWidth ) }; + auto const side { std::abs( texwidth ) }; // szerokść podsypki na zewnątrz szyny albo pobocza + auto const slop { std::abs( texslope ) }; // brzeg zewnętrzny + auto const rozp { fHTW + side + slop }; // brzeg zewnętrzny + + auto hypot1 { std::hypot( slop, texheight1 ) }; // rozmiar pochylenia do liczenia normalnych + if( hypot1 == 0.f ) + hypot1 = 1.f; + + glm::vec3 normal1 { texheight1 / hypot1, texslope / hypot1, 0.f }; // wektor normalny + if( glm::length( normal1 ) == 0.f ) { + // fix normal for vertical surfaces + normal1 = glm::vec3 { 1.f, 0.f, 0.f }; + } + + glm::vec3 normal2; + float fHTW2, side2, slop2, rozp2, fTexHeight2, hypot2; + if( ( Next != nullptr ) + && ( Next->eType != tt_Switch ) + && ( ( iTrapezoid & 2 ) // ten bit oznacza, że istnieje odpowiednie pNext + || ( eType == tt_Switch ) ) ) { + fHTW2 = 0.5f * std::abs(Next->fTrackWidth); // połowa rozstawu/nawierzchni + side2 = std::abs(Next->fTexWidth); + slop2 = std::abs(Next->fTexSlope); // nie jest używane później + rozp2 = fHTW2 + side2 + slop2; + fTexHeight2 = Next->fTexHeight1; + hypot2 = std::hypot(slop2, fTexHeight2); + if( hypot2 == 0.f ) + hypot2 = 1.f; + normal2 = { fTexHeight2 / hypot2, Next->fTexSlope / hypot2, 0.f }; + if( glm::length( normal2 ) == 0.f ) { + // fix normal for vertical surfaces + normal2 = glm::vec3 { 1.f, 0.f, 0.f }; + } + } + else { + // gdy nie ma następnego albo jest nieodpowiednim końcem podpięty + fHTW2 = fHTW; + side2 = side; + slop2 = slop; + rozp2 = rozp; + fTexHeight2 = texheight1; + hypot2 = hypot1; + normal2 = normal1; + } + + float + roll1{ 0.f }, + roll2{ 0.f }; + + if( Segment ) { + Segment->GetRolls( roll1, roll2 ); + } + + float const + sin1 { std::sin( roll1 ) }, + cos1 { std::cos( roll1 ) }, + sin2 { std::sin( roll2 ) }, + cos2 { std::cos( roll2 ) }; + + // profile + auto const transition { ( iTrapezoid != 0 ) || ( eType == tt_Switch ) }; + auto const pointcount { transition ? 10 : 5 }; + Output.resize( pointcount ); + // potentially retrieve texture length override from the assigned material + auto const texturelength { texture_length( copy_adjacent_trackbed_material() ) }; + auto const railheight { 0.18f }; + if( texturelength == 4.f ) { + // stare mapowanie z różną gęstością pikseli i oddzielnymi teksturami na każdy profil + auto const normalx = std::cos( glm::radians( 75.f ) ); + auto const normaly = std::sin( glm::radians( 75.f ) ); + if( transition ) { + // trapez albo przechyłki + // ewentualnie poprawić mapowanie, żeby środek mapował się na 1.435/4.671 ((0.3464,0.6536) + // bo się tekstury podsypki rozjeżdżają po zmianie proporcji profilu + Output[ 0 ] = { + {rozp, -texheight1 - railheight, 0.f}, + {normalx, normaly, 0.f}, + {0.00f, 0.f} }; // lewy brzeg + Output[ 1 ] = { + {( fHTW + side ) * cos1, -( fHTW + side ) * sin1 - railheight, 0.f}, + {normalx, normaly, 0.f}, + {0.33f, 0.f} }; // krawędź załamania + Output[ 2 ] = { + {0.f, -railheight + 0.01f, 0.f}, + {0.f, 1.f, 0.f}, + {0.5f, 0.f} }; // middle + Output[ 3 ] = { + {-Output[ 1 ].position.x, +( fHTW + side ) * sin1 - railheight, 0.f}, + {-normalx, normaly, 0.f}, + {0.67f, 0.f} }; // prawy brzeg początku symetrycznie + Output[ 4 ] = { + {-rozp, -texheight1 - railheight, 0.f}, + {-normalx, normaly, 0.f}, + {1.f, 0.f} }; // prawy skos + // końcowy przekrój + Output[ 5 ] = { + {rozp2, -fTexHeight2 - railheight, 0.f}, + {normalx, normaly, 0.f}, + {0.00f, 0.f} }; // lewy brzeg + Output[ 6 ] = { + {( fHTW2 + side2 ) * cos2, -( fHTW2 + side2 ) * sin2 - railheight, 0.f}, + {normalx, normaly, 0.f}, + {0.33f, 0.f} }; // krawędź załamania + Output[ 7 ] = { + {0.f, -railheight + 0.01f, 0.f}, + {0.f, 1.f, 0.f}, + {0.5f, 0.f} }; // middle + Output[ 8 ] = { + {-Output[ 6 ].position.x, +( fHTW2 + side2 ) * sin2 - railheight, 0.f}, + {-normalx, normaly, 0.f}, + {0.67f, 0.f} }; // prawy brzeg początku symetrycznie + Output[ 9 ] = { + {-rozp2, -fTexHeight2 - railheight, 0.f}, + {-normalx, normaly, 0.f}, + {1.00f, 0.f} }; // prawy skos + } + else { + Output[ 0 ] = { + {rozp, -texheight1 - railheight, 0.f}, + {normalx, normaly, 0.f}, + {0.00f, 0.f} }; // lewy brzeg + Output[ 1 ] = { + {fHTW + side, -railheight, 0.f}, + {normalx, normaly, 0.f}, + {0.33f, 0.f} }; // krawędź załamania + Output[ 2 ] = { + {0.f, -railheight + 0.01f, 0.f}, + {0.f, 1.f, 0.f}, + {0.5f, 0.f} }; // middle + Output[ 3 ] = { + {-fHTW - side, -railheight, 0.f}, + {-normalx, normaly, 0.f}, + {0.67f, 0.f} }; // druga + Output[ 4 ] = { + {-rozp, -texheight1 - railheight, 0.f}, + {-normalx, normaly, 0.f}, + {1.00f, 0.f} }; // prawy skos + } + } + else { + // mapowanie proporcjonalne do powierzchni, rozmiar w poprzek określa fTexLength + auto const max = fTexRatio2 * texturelength; // szerokość proporcjonalna do długości + auto const map11 = max > 0.f ? (fHTW + side) / max : 0.25f; // załamanie od strony 1 + auto const map12 = max > 0.f ? (fHTW + side + hypot1) / max : 0.5f; // brzeg od strony 1 + if (transition) { + // trapez albo przechyłki + auto const map21 = max > 0.f ? (fHTW2 + side2) / max : 0.25f; // załamanie od strony 2 + auto const map22 = max > 0.f ? (fHTW2 + side2 + hypot2) / max : 0.5f; // brzeg od strony 2 + // ewentualnie poprawić mapowanie, żeby środek mapował się na 1.435/4.671 + // ((0.3464,0.6536) + // bo się tekstury podsypki rozjeżdżają po zmianie proporcji profilu + Output[ 0 ] = { + {rozp, -texheight1 - railheight, 0.f}, + {normal1.x, normal1.y, 0.f}, + {0.5f - map12, 0.f} }; // lewy brzeg + Output[ 1 ] = { + {( fHTW + side ) * cos1, -( fHTW + side ) * sin1 - railheight, 0.f}, + {normal1.x, normal1.y, 0.f}, + {0.5f - map11 , 0.f} }; // krawędź załamania + Output[ 2 ] = { + {0.f, -railheight + 0.01f, 0.f}, + {0.f, 1.f, 0.f}, + {0.5f, 0.f} }; // middle + Output[ 3 ] = { + {-Output[ 1 ].position.x, +( fHTW + side ) * sin1 - railheight, 0.f}, + {-normal1.x, normal1.y, 0.f}, + {0.5 + map11, 0.f} }; // prawy brzeg początku symetrycznie + Output[ 4 ] = { + {-rozp, -texheight1 - railheight, 0.f}, + {-normal1.x, normal1.y, 0.f}, + {0.5f + map12, 0.f} }; // prawy skos + // przekrój końcowy + Output[ 5 ] = { + {rozp2, -fTexHeight2 - railheight, 0.f}, + {normal2.x, normal2.y, 0.f}, + {0.5f - map22, 0.f} }; // lewy brzeg + Output[ 6 ] = { + {( fHTW2 + side2 ) * cos2, -( fHTW2 + side2 ) * sin2 - railheight, 0.f}, + {normal2.x, normal2.y, 0.f}, + {0.5f - map21 , 0.f} }; // krawędź załamania + Output[ 7 ] = { + {0.f, -railheight + 0.01f, 0.f}, + {0.f, 1.f, 0.f}, + {0.5f, 0.f} }; // middle + Output[ 8 ] = { + {-Output[ 6 ].position.x, +( fHTW2 + side2 ) * sin2 - railheight, 0.f}, + {-normal2.x, normal2.y, 0.f}, + {0.5f + map21, 0.f} }; // prawy brzeg początku symetrycznie + Output[ 9 ] = { + {-rozp2, -fTexHeight2 - railheight, 0.f}, + {-normal2.x, normal2.y, 0.f}, + {0.5f + map22, 0.f} }; // prawy skos + } + else + { + Output[ 0 ] = { + {rozp, -texheight1 - railheight, 0.f}, + {+normal1.x, normal1.y, 0.f}, + {0.5f - map12, 0.f} }; // lewy brzeg + Output[ 1 ] = { + {fHTW + side, - railheight, 0.f}, + {+normal1.x, normal1.y, 0.f}, + {0.5f - map11, 0.f} }; // krawędź załamania + Output[ 2 ] = { + {0.f, -railheight + 0.01f, 0.f}, + {0.f, 1.f, 0.f}, + {0.5f, 0.f} }; // middle + Output[ 3 ] = { + {-fHTW - side, - railheight, 0.f}, + {-normal1.x, normal1.y, 0.f}, + {0.5f + map11, 0.f} }; // druga + Output[ 4 ] = { + {-rozp, -texheight1 - railheight, 0.f}, + {-normal1.x, normal1.y, 0.f}, + {0.5f + map12, 0.f} }; // prawy skos + } + } +} + +// creates road profile data for current path +void +TTrack::create_road_profile( gfx::vertex_array &Output, bool const Forcetransition ) { + + auto const fHTW { 0.5f * std::abs( fTrackWidth ) }; + float const fHTW2 { ( + ( iTrapezoid & 2 ) != 0 ? // ten bit oznacza, że istnieje odpowiednie pNext + 0.5f * std::fabs( trNext->fTrackWidth ) : // połowa rozstawu/nawierzchni + fHTW ) }; + + glm::vec3 const normalup { 0.f, 1.f, 0.f }; + + auto const texturelength { texture_length( m_material1 ) }; + auto const max = fTexRatio1 * texturelength; // test: szerokość proporcjonalna do długości + auto const map1 = max > 0.f ? fHTW / max : 0.5f; // obcięcie tekstury od strony 1 + auto const map2 = max > 0.f ? fHTW2 / max : 0.5f; // obcięcie tekstury od strony 2 + + auto const transition { ( true == Forcetransition ) || ( iTrapezoid != 0 ) }; + + auto const pointcount{ transition ? 4 : 2 }; + Output.resize( pointcount ); + + if( transition ) { + // trapez albo przechyłki + float + roll1 { 0.f }, + roll2 { 0.f }; + + if( Segment ) { + Segment->GetRolls( roll1, roll2 ); + } + + Output[ 0 ] = { + {fHTW * std::cos( roll1 ), -fHTW * std::sin( roll1 ), 0.f}, + normalup, + {0.5f - map1, 0.f} }; // lewy brzeg początku + Output[ 1 ] = { + {-Output[ 0 ].position.x, -Output[ 0 ].position.y, 0.f}, + normalup, + {0.5f + map1, 0.f} }; // prawy brzeg początku symetrycznie + Output[ 2 ] = { + {fHTW2 * std::cos( roll2 ), -fHTW2 * std::sin( roll2 ), 0.f}, + normalup, + {0.5f - map2, 0.f} }; // lewy brzeg końca + Output[ 3 ] = { + {-Output[ 2 ].position.x, -Output[ 2 ].position.y, 0.f}, + normalup, + {0.5f + map2, 0.f} }; // prawy brzeg początku symetrycznie + } + else { + Output[ 0 ] = { + {fHTW, 0.f, 0.f}, + normalup, + {0.5f - map1, 0.f} }; + Output[ 1 ] = { + {-fHTW, 0.f, 0.f}, + normalup, + {0.5f + map1, 0.f} }; + } +} + +void +TTrack::create_road_side_profile( gfx::vertex_array &Right, gfx::vertex_array &Left, gfx::vertex_array const &Road, bool const Forcetransition ) { + + auto const fHTW{ 0.5f * std::abs( fTrackWidth ) }; + auto const side{ std::abs( fTexWidth ) }; // szerokść podsypki na zewnątrz szyny albo pobocza + auto const slop{ std::abs( fTexSlope ) }; // brzeg zewnętrzny + auto const rozp{ fHTW + side + slop }; // brzeg zewnętrzny + + float fHTW2, side2, slop2, rozp2, fTexHeight2; + if( iTrapezoid & 2 ) { + // ten bit oznacza, że istnieje odpowiednie pNext + // Ra: jest OK + fHTW2 = 0.5f * std::fabs( trNext->fTrackWidth ); // połowa rozstawu/nawierzchni + side2 = std::fabs( trNext->fTexWidth ); + slop2 = std::fabs( trNext->fTexSlope ); // nie jest używane później + rozp2 = fHTW2 + side2 + slop2; + fTexHeight2 = trNext->fTexHeight1; + } + else { + // gdy nie ma następnego albo jest nieodpowiednim końcem podpięty + fHTW2 = fHTW; + side2 = side; + slop2 = slop; + rozp2 = rozp; + fTexHeight2 = fTexHeight1; + } + + glm::vec3 const normalup{ 0.f, 1.f, 0.f }; + + auto const texturelength{ texture_length( m_material2 ) }; + + auto const transition { ( true == Forcetransition ) || ( iTrapezoid != 0 ) }; + + auto const pointcount{ transition ? 6 : 3 }; + Right.resize( pointcount ); + Left.resize( pointcount ); + + + if( fTexHeight1 >= 0.f ) { // standardowo: od zewnątrz pochylenie, a od wewnątrz poziomo + Right[ 0 ] = { + {rozp, -fTexHeight1, 0.f}, + { 1.f, 0.f, 0.f }, + {0.f, 0.f} }; // lewy brzeg podstawy + Right[ 1 ] = { + {Road[ 0 ].position.x + side, Road[ 0 ].position.y, 0.f}, + normalup, + {0.5, 0.f} }; // lewa krawędź załamania + Right[ 2 ] = { + {Road[ 0 ].position.x, Road[ 0 ].position.y, 0.f}, + normalup, + {1.f, 0.f} }; // lewy brzeg pobocza (mapowanie może być inne + Left[ 0 ] = { + {Road[ 1 ].position.x, Road[ 1 ].position.y, 0.f}, + normalup, + {1.f, 0.f} }; // prawy brzeg pobocza + Left[ 1 ] = { + {Road[ 1 ].position.x - side, Road[ 1 ].position.y, 0.f}, + normalup, + {0.5f, 0.f} }; // prawa krawędź załamania + Left[ 2 ] = { + {-rozp, -fTexHeight1, 0.f}, + { -1.f, 0.f, 0.f }, + {0.f, 0.f} }; // prawy brzeg podstawy + if( transition ) { + // pobocza do trapezowatej nawierzchni - dodatkowe punkty z drugiej strony odcinka + Right[ 3 ] = { + {rozp2, -fTexHeight2, 0.f}, + { 1.f, 0.f, 0.f }, + {0.f, 0.f} }; // lewy brzeg lewego pobocza + Right[ 4 ] = { + {Road[ 2 ].position.x + side2, Road[ 2 ].position.y, 0.f}, + normalup, + {0.5f, 0.f} }; // krawędź załamania + Right[ 5 ] = { + {Road[ 2 ].position.x, Road[ 2 ].position.y, 0.f}, + normalup, + {1.f, 0.f} }; // brzeg pobocza + Left[ 3 ] = { + {Road[ 3 ].position.x, Road[ 3 ].position.y, 0.f}, + normalup, + {1.f, 0.f} }; + Left[ 4 ] = { + {Road[ 3 ].position.x - side2, Road[ 3 ].position.y, 0.f}, + normalup, + {0.5f, 0.f} }; + Left[ 5 ] = { + {-rozp2, -fTexHeight2, 0.f}, + { -1.f, 0.f, 0.f }, + {0.f, 0.f} }; // prawy brzeg prawego pobocza + } + } + else { // wersja dla chodnika: skos 1:3.75, każdy chodnik innej szerokości + // mapowanie propocjonalne do szerokości chodnika + // krawężnik jest mapowany od 31/64 do 32/64 lewy i od 32/64 do 33/64 prawy + auto const d = -fTexHeight1 / 3.75f; // krawężnik o wysokości 150mm jest pochylony 40mm + auto const max = fTexRatio2 * texturelength; // test: szerokość proporcjonalna do długości + auto const map1l = ( + max > 0.f ? + side / max : + 0.484375f ); // obcięcie tekstury od lewej strony punktu 1 + auto const map1r = ( + max > 0.f ? + slop / max : + 0.484375f ); // obcięcie tekstury od prawej strony punktu 1 + auto const h1r = ( + slop > d ? + -fTexHeight1 : + 0.f ); + auto const h1l = ( + side > d ? + -fTexHeight1 : + 0.f ); + + Right[ 0 ] = { + {Road[ 0 ].position.x + slop, Road[ 0 ].position.y + h1r, 0.f}, + normalup, + {0.515625f + map1r, 0.f} }; // prawy brzeg prawego chodnika + Right[ 1 ] = { + {Road[ 0 ].position.x + d, Road[ 0 ].position.y + h1r, 0.f}, + normalup, + {0.515625f, 0.f} }; // prawy krawężnik u góry + Right[ 2 ] = { + {Road[ 0 ].position.x, Road[ 0 ].position.y, 0.f}, + { -1.f, 0.f, 0.f }, + {0.515625f - d / 2.56f, 0.f} }; // prawy krawężnik u dołu + Left[ 0 ] = { + {Road[ 1 ].position.x, Road[ 1 ].position.y, 0.f}, + { 1.f, 0.f, 0.f }, + {0.484375f + d / 2.56f, 0.f} }; // lewy krawężnik u dołu + Left[ 1 ] = { + {Road[ 1 ].position.x - d, Road[ 1 ].position.y + h1l, 0.f}, + normalup, + {0.484375f, 0.f} }; // lewy krawężnik u góry + Left[ 2 ] = { + {Road[ 1 ].position.x - side, Road[ 1 ].position.y + h1l, 0.f}, + normalup, + {0.484375f - map1l, 0.f} }; // lewy brzeg lewego chodnika + + if( transition ) { + // pobocza do trapezowatej nawierzchni - dodatkowe punkty z drugiej strony odcinka + slop2 = ( + std::fabs( ( iTrapezoid & 2 ) ? + slop2 : + slop ) ); // szerokość chodnika po prawej + auto const map2l = ( + max > 0.f ? + side2 / max : + 0.484375f ); // obcięcie tekstury od lewej strony punktu 2 + auto const map2r = ( + max > 0.f ? + slop2 / max : + 0.484375f ); // obcięcie tekstury od prawej strony punktu 2 + auto const h2r = ( + slop2 > d ? + -fTexHeight2 : + 0.f ); + auto const h2l = ( + side2 > d ? + -fTexHeight2 : + 0.f ); + + Right[ 3 ] = { + {Road[ 2 ].position.x + slop2, Road[ 2 ].position.y + h2r, 0.f}, + normalup, + {0.515625f + map2r, 0.f} }; // prawy brzeg prawego chodnika + Right[ 4 ] = { + {Road[ 2 ].position.x + d, Road[ 2 ].position.y + h2r, 0.f}, + normalup, + {0.515625f, 0.f} }; // prawy krawężnik u góry + Right[ 5 ] = { + {Road[ 2 ].position.x, Road[ 2 ].position.y, 0.f}, + { -1.f, 0.f, 0.f }, + {0.515625f - d / 2.56f, 0.f} }; // prawy krawężnik u dołu + Left[ 3 ] = { + {Road[ 3 ].position.x, Road[ 3 ].position.y, 0.f}, + { 1.f, 0.f, 0.f }, + {0.484375f + d / 2.56f, 0.f} }; // lewy krawężnik u dołu + Left[ 4 ] = { + {Road[ 3 ].position.x - d, Road[ 3 ].position.y + h2l, 0.f}, + normalup, + {0.484375f, 0.f} }; // lewy krawężnik u góry + Left[ 5 ] = { + {Road[ 3 ].position.x - side2, Road[ 3 ].position.y + h2l, 0.f}, + normalup, + {0.484375f - map2l, 0.f} }; // lewy brzeg lewego chodnika + } + } +} + +void +TTrack::create_switch_trackbed( gfx::vertex_array &Output ) { + // try to get trackbed material from a regular track connected to the primary path + if( ( SwitchExtension->m_material3 == null_handle ) + && ( trPrev != nullptr ) + && ( trPrev->eType == tt_Normal ) ) { + SwitchExtension->m_material3 = trPrev->m_material2; + } + if( ( SwitchExtension->m_material3 == null_handle ) + && ( trNext != nullptr ) + && ( trNext->eType == tt_Normal ) ) { + SwitchExtension->m_material3 = trNext->m_material2; + } + // without material don't bother + if( SwitchExtension->m_material3 == null_handle ) { return; } + // generate trackbed for each path of the switch... + auto const texturelength { texture_length( SwitchExtension->m_material3 ) }; + gfx::vertex_array trackbedprofile; + gfx::vertex_array trackbedvertices1, trackbedvertices2; + // main trackbed + create_track_bed_profile( trackbedprofile, SwitchExtension->pPrevs[ 0 ], SwitchExtension->pNexts[ 0 ] ); + SwitchExtension->Segments[ 0 ]->RenderLoft( trackbedvertices1, m_origin, trackbedprofile, -5, texturelength ); + // side trackbed + create_track_bed_profile( trackbedprofile, SwitchExtension->pPrevs[ 1 ], SwitchExtension->pNexts[ 1 ] ); + SwitchExtension->Segments[ 1 ]->RenderLoft( trackbedvertices2, m_origin, trackbedprofile, -5, texturelength ); + // ...then combine them into a single geometry sequence + auto const segmentsize { 10 }; + auto const segmentcount { trackbedvertices1.size() / segmentsize }; + auto *sampler1 { trackbedvertices1.data() }; + auto *sampler2 { trackbedvertices2.data() }; + auto const isright { SwitchExtension->RightSwitch }; + auto const isleft { false == isright }; + auto const samplersoffset { isright ? 2 : 0 }; + auto const geometryoffset { 0.025f }; + for( int segment = 0; segment < segmentcount; ++segment ) { + // main trackbed + // lower outer edge to avoid z-fighting + if( isright ) { + ( sampler1 + samplersoffset + 0 )->position.y -= geometryoffset; + ( sampler1 + samplersoffset + 1 )->position.y -= geometryoffset; + } + if( isleft ) { + ( sampler1 + samplersoffset + 6 )->position.y -= geometryoffset; + ( sampler1 + samplersoffset + 7 )->position.y -= geometryoffset; + } + // copy the data + for( auto pointidx = 0; pointidx < segmentsize; ++pointidx ) { + Output.emplace_back( *( sampler1 + pointidx ) ); + } + // side trackbed + // lower outer edge to avoid z-fighting + if( isleft ) { + ( sampler2 - samplersoffset + 2 )->position.y -= geometryoffset; + ( sampler2 - samplersoffset + 3 )->position.y -= geometryoffset; + } + if( isright ) { + ( sampler2 - samplersoffset + 8 )->position.y -= geometryoffset; + ( sampler2 - samplersoffset + 9 )->position.y -= geometryoffset; + } + // copy the data + for( auto pointidx = 0; pointidx < segmentsize; ++pointidx ) { + Output.emplace_back( *( sampler2 + pointidx ) ); + } + // switch to next segment data + sampler1 += segmentsize; + sampler2 += segmentsize; + } +} + +material_handle +TTrack::copy_adjacent_trackbed_material( TTrack const *Exclude ) { + + if( iCategoryFlag != 1 ) { return null_handle; } // tracks only + + auto &material { eType == tt_Switch ? SwitchExtension->m_material3 : m_material2 }; + + if( material != null_handle ) { return material; } // already has material + + std::vector adjacents; + switch( eType ) { + case tt_Normal: { + // for regular tracks don't set the trackbed texture if we aren't sitting next to a part of a double slip +/* + auto const hasadjacentdoubleslip { + ( trPrev ? trPrev->DoubleSlip() : false ) + || ( trNext ? trNext->DoubleSlip() : false ) }; + + if( true == hasadjacentdoubleslip ) { + adjacents.emplace_back( trPrev ); + adjacents.emplace_back( trNext ); + } +*/ + auto const hasadjacentswitch { + ( trPrev && trPrev->eType == tt_Switch ) + || ( trNext && trNext->eType == tt_Switch ) }; + +// if( true == hasadjacentdoubleslip ) { + if( true == hasadjacentswitch ) { + adjacents.emplace_back( trPrev ); + adjacents.emplace_back( trNext ); + } + break; + } + case tt_Switch: { + // only check the neighbour on the joint side + adjacents.emplace_back( SwitchExtension->pPrevs[ 0 ] ); + break; + } + default: { + break; + } + } + + for( auto *adjacent : adjacents ) { + if( ( adjacent != nullptr ) && ( adjacent != Exclude ) ) { + material = adjacent->copy_adjacent_trackbed_material( this ); + if( material != null_handle ) { break; } // got what we wanted + } + } + + return material; +} + + + +path_table::~path_table() { + + TIsolated::DeleteAll(); +} + +// legacy method, initializes tracks after deserialization from scenario file +void +path_table::InitTracks() { + + int connection { -1 }; + TTrack *matchingtrack { nullptr }; + +#ifdef EU07_IGNORE_LEGACYPROCESSINGORDER + for( auto *track : m_items ) { +#else + // NOTE: legacy code peformed item operations last-to-first due to way the items were added to the list + // this had impact in situations like two possible connection candidates, where only the first one would be used + for( auto first = std::rbegin(m_items); first != std::rend(m_items); ++first ) { + auto *track = *first; +#endif + track->AssignEvents(); + + auto const trackname { track->name() }; + + switch (track->eType) { + // TODO: re-enable + case tt_Table: { + // obrotnicę też łączymy na starcie z innymi torami + // szukamy modelu o tej samej nazwie + auto *instance = simulation::Instances.find( trackname ); + // wiązanie toru z modelem obrotnicy + track->RaAssign( + instance, + simulation::Events.FindEvent( trackname + ":done" ), + simulation::Events.FindEvent( trackname + ":joined" ) ); + if( instance == nullptr ) { + // jak nie ma modelu to pewnie jest wykolejnica, a ta jest domyślnie zamknięta i wykoleja + break; + } + // no break on purpose: + // "jak coś pójdzie źle, to robimy z tego normalny tor" + } + case tt_Normal: { + // tylko proste są podłączane do rozjazdów, stąd dwa rozjazdy się nie połączą ze sobą + if( track->CurrentPrev() == nullptr ) { + // tylko jeśli jeszcze nie podłączony + std::tie( matchingtrack, connection ) = simulation::Region->find_path( track->CurrentSegment()->FastGetPoint_0(), track ); + switch( connection ) { + case -1: // Ra: pierwsza koncepcja zawijania samochodów i statków + // if ((Track->iCategoryFlag&1)==0) //jeśli nie jest torem szynowym + // Track->ConnectPrevPrev(Track,0); //łączenie końca odcinka do samego siebie + break; + case 0: + track->ConnectPrevPrev( matchingtrack, 0 ); + break; + case 1: + track->ConnectPrevNext( matchingtrack, 1 ); + break; + case 2: + track->ConnectPrevPrev( matchingtrack, 0 ); // do Point1 pierwszego + matchingtrack->SetConnections( 0 ); // zapamiętanie ustawień w Segmencie + break; + case 3: + track->ConnectPrevNext( matchingtrack, 1 ); // do Point2 pierwszego + matchingtrack->SetConnections( 0 ); // zapamiętanie ustawień w Segmencie + break; + case 4: + matchingtrack->Switch( 1 ); + track->ConnectPrevPrev( matchingtrack, 2 ); // do Point1 drugiego + matchingtrack->SetConnections( 1 ); // robi też Switch(0) + matchingtrack->Switch( 0 ); + break; + case 5: + matchingtrack->Switch( 1 ); + track->ConnectPrevNext( matchingtrack, 3 ); // do Point2 drugiego + matchingtrack->SetConnections( 1 ); // robi też Switch(0) + matchingtrack->Switch( 0 ); + break; + default: + break; + } + } + if( track->CurrentNext() == nullptr ) { + // tylko jeśli jeszcze nie podłączony + std::tie( matchingtrack, connection ) = simulation::Region->find_path( track->CurrentSegment()->FastGetPoint_1(), track ); + switch( connection ) { + case -1: // Ra: pierwsza koncepcja zawijania samochodów i statków + // if ((Track->iCategoryFlag&1)==0) //jeśli nie jest torem szynowym + // Track->ConnectNextNext(Track,1); //łączenie końca odcinka do samego siebie + break; + case 0: + track->ConnectNextPrev( matchingtrack, 0 ); + break; + case 1: + track->ConnectNextNext( matchingtrack, 1 ); + break; + case 2: + track->ConnectNextPrev( matchingtrack, 0 ); + matchingtrack->SetConnections( 0 ); // zapamiętanie ustawień w Segmencie + break; + case 3: + track->ConnectNextNext( matchingtrack, 1 ); + matchingtrack->SetConnections( 0 ); // zapamiętanie ustawień w Segmencie + break; + case 4: + matchingtrack->Switch( 1 ); + track->ConnectNextPrev( matchingtrack, 2 ); + matchingtrack->SetConnections( 1 ); // robi też Switch(0) + // tmp->Switch(0); + break; + case 5: + matchingtrack->Switch( 1 ); + track->ConnectNextNext( matchingtrack, 3 ); + matchingtrack->SetConnections( 1 ); // robi też Switch(0) + // tmp->Switch(0); + break; + default: + break; + } + } + if( Global.CreateSwitchTrackbeds ) { + // when autogenerating trackbeds, try to restore trackbeds for tracks neighbouring double slips + track->copy_adjacent_trackbed_material(); + } + break; + } + case tt_Switch: { + // dla rozjazdów szukamy eventów sygnalizacji rozprucia + track->AssignForcedEvents( + simulation::Events.FindEvent( trackname + ":forced+" ), + simulation::Events.FindEvent( trackname + ":forced-" ) ); + if( Global.CreateSwitchTrackbeds ) { + // when autogenerating trackbeds, try to restore trackbeds for tracks neighbouring double slips + track->copy_adjacent_trackbed_material(); + } + break; + } + default: { + break; + } + } // switch + + if( ( trackname[ 0 ] == '*' ) + && ( !track->CurrentPrev() && track->CurrentNext() ) ) { + // możliwy portal, jeśli nie podłączony od strony 1 + // ustawienie flagi portalu + track->iCategoryFlag |= 0x100; + } + } + + auto *isolated = TIsolated::Root(); + while( isolated ) { + + isolated->AssignEvents(); + + auto *memorycell = simulation::Memory.find( isolated->asName ); // czy jest komóka o odpowiedniej nazwie + if( memorycell == nullptr ) { + // utworzenie automatycznej komórki + // TODO: determine suitable location for this one, create and add world reference node + scene::node_data nodedata; + nodedata.name = isolated->asName; + memorycell = new TMemCell( nodedata ); // to nie musi mieć nazwy, nazwa w wyszukiwarce wystarczy + // NOTE: autogenerated cells aren't exported; they'll be autogenerated anew when exported file is loaded + memorycell->is_exportable = false; + simulation::Memory.insert( memorycell ); + } + // przypisanie powiązanej komórki + isolated->pMemCell = memorycell; + + isolated = isolated->Next(); + } +} + +// legacy method, sends list of occupied paths over network +void +path_table::TrackBusyList() const { + // wysłanie informacji o wszystkich zajętych odcinkach + for( auto const *path : m_items ) { + if( ( false == path->name().empty() ) // musi być nazwa + && ( false == path->Dynamics.empty() ) ) { + // zajęty + multiplayer::WyslijString( path->name(), 8 ); + } + } +} + +// legacy method, sends list of occupied path sections over network +void +path_table::IsolatedBusyList() const { + // wysłanie informacji o wszystkich odcinkach izolowanych + TIsolated *Current; + for( Current = TIsolated::Root(); Current; Current = Current->Next() ) { + + if( Current->Busy() ) { multiplayer::WyslijString( Current->asName, 11 ); } + else { multiplayer::WyslijString( Current->asName, 10 ); } + } + multiplayer::WyslijString( "none", 10 ); // informacja o końcu listy +} + +// legacy method, sends state of specified path section over network +void +path_table::IsolatedBusy( std::string const &Name ) const { + // wysłanie informacji o odcinku izolowanym (t) + // Ra 2014-06: do wyszukania użyć drzewka nazw + TIsolated *Current; + for( Current = TIsolated::Root(); Current; Current = Current->Next() ) { + if( Current->asName == Name ) { + if( Current->Busy() ) { multiplayer::WyslijString( Current->asName, 11 ); } + else { multiplayer::WyslijString( Current->asName, 10 ); } + // nie sprawdzaj dalszych + return; + } + } + multiplayer::WyslijString( Name, 10 ); // wolny (technically not found but, eh) +} diff --git a/Track.h b/Track.h index 0d3d9e5e..c2384802 100644 --- a/Track.h +++ b/Track.h @@ -10,25 +10,30 @@ http://mozilla.org/MPL/2.0/. #pragma once #include -#include "opengl/glew.h" -#include "ResourceManager.h" +#include +#include + +#include "classes.h" #include "Segment.h" -#include "Texture.h" +#include "material.h" +#include "scenenode.h" +#include "names.h" -class TEvent; +namespace scene { +class basic_cell; +} -typedef enum -{ +enum TTrackType { tt_Unknown, tt_Normal, tt_Switch, tt_Table, tt_Cross, tt_Tributary -} TTrackType; +}; // McZapkie-100502 -typedef enum -{ + +enum TEnvironmentType { e_unknown = -1, e_flat = 0, e_mountains, @@ -36,9 +41,10 @@ typedef enum e_tunnel, e_bridge, e_bank -} TEnvironmentType; +}; // Ra: opracować alternatywny system cieni/świateł z definiowaniem koloru oświetlenia w halach +class basic_event; class TTrack; class TGroundNode; class TSubRect; @@ -50,251 +56,282 @@ class TSwitchExtension TSwitchExtension(TTrack *owner, int const what); ~TSwitchExtension(); std::shared_ptr Segments[6]; // dwa tory od punktu 1, pozosta³e dwa od 2? Ra 140101: 6 po³¹czeñ dla skrzy¿owañ - // TTrack *trNear[4]; //tory do³¹czone do punktów 1, 2, 3 i 4 - // dotychczasowe [2]+[2] wskaŸniki zamieniæ na nowe [4] TTrack *pNexts[2]; // tory do³¹czone do punktów 2 i 4 TTrack *pPrevs[2]; // tory do³¹czone do punktów 1 i 3 int iNextDirection[2]; // to te¿ z [2]+[2] przerobiæ na [4] int iPrevDirection[2]; int CurrentIndex = 0; // dla zwrotnicy - double fOffset = 0.0, - fDesiredOffset = 0.0; // aktualne i docelowe położenie napędu iglic - double fOffsetSpeed = 0.1; // prędkość liniowa ruchu iglic - double fOffsetDelay = 0.05; // opóźnienie ruchu drugiej iglicy względem pierwszej // dodatkowy ruch drugiej iglicy po zablokowaniu pierwszej na opornicy + float + fOffset{ 0.f }, + fDesiredOffset{ 0.f }; // aktualne i docelowe położenie napędu iglic + float fOffsetSpeed = 0.1f; // prędkość liniowa ruchu iglic + float fOffsetDelay = 0.05f; // opóźnienie ruchu drugiej iglicy względem pierwszej // dodatkowy ruch drugiej iglicy po zablokowaniu pierwszej na opornicy union { struct { // zmienne potrzebne tylko dla zwrotnicy - double fOffset1, - fOffset2; // przesunięcia iglic - 0=na wprost + float fOffset1, + fOffset2; // przesunięcia iglic - 0=na wprost bool RightSwitch; // czy zwrotnica w prawo }; struct { // zmienne potrzebne tylko dla obrotnicy/przesuwnicy - TGroundNode *pMyNode; // dla obrotnicy do wtórnego podłączania torów - // TAnimContainer *pAnim; //animator modelu dla obrotnicy + // TAnimContainer *pAnim; //animator modelu dla obrotnicy TAnimModel *pModel; // na razie model }; struct { // zmienne dla skrzyżowania - vector3 *vPoints; // tablica wierzchołków nawierzchni, generowana przez pobocze - int iPoints; // liczba faktycznie użytych wierzchołków nawierzchni - bool bPoints; // czy utworzone? int iRoads; // ile dróg się spotyka? + glm::vec3 *vPoints; // tablica wierzchołków nawierzchni, generowana przez pobocze + bool bPoints; // czy utworzone? }; }; bool bMovement = false; // czy w trakcie animacji - int iLeftVBO = 0, - iRightVBO = 0; // indeksy iglic w VBO - TSubRect *pOwner = nullptr; // sektor, któremu trzeba zgłosić animację + scene::basic_cell *pOwner = nullptr; // TODO: convert this to observer pattern TTrack *pNextAnim = nullptr; // następny tor do animowania - TEvent *evPlus = nullptr, + basic_event *evPlus = nullptr, *evMinus = nullptr; // zdarzenia sygnalizacji rozprucia float fVelocity = -1.0; // maksymalne ograniczenie prędkości (ustawianej eventem) - vector3 vTrans; // docelowa translacja przesuwnicy - private: + Math3D::vector3 vTrans; // docelowa translacja przesuwnicy + material_handle m_material3 = 0; // texture of auto generated switch trackbed + gfx::geometry_handle Geometry3; // geometry of auto generated switch trackbed }; -#ifdef EU07_USE_OLD_TTRACK_DYNAMICS_ARRAY -const int iMaxNumDynamics = 40; // McZapkie-100303 -#endif - class TIsolated { // obiekt zbierający zajętości z kilku odcinków - int iAxles = 0; // ilość osi na odcinkach obsługiwanych przez obiekt - TIsolated *pNext = nullptr; // odcinki izolowane są trzymane w postaci listy jednikierunkowej - static TIsolated *pRoot; // początek listy - public: - std::string asName; // nazwa obiektu, baza do nazw eventów - TEvent *evBusy = nullptr; // zdarzenie wyzwalane po zajęciu grupy - TEvent *evFree = nullptr; // zdarzenie wyzwalane po całkowitym zwolnieniu zajętości grupy - TMemCell *pMemCell = nullptr; // automatyczna komórka pamięci, która współpracuje z odcinkiem izolowanym - TIsolated(); +public: + // constructors TIsolated(const std::string &n, TIsolated *i); - ~TIsolated(); - static TIsolated * Find( - const std::string &n); // znalezienie obiektu albo utworzenie nowego + // methods + static void DeleteAll(); + static TIsolated * Find(const std::string &n); // znalezienie obiektu albo utworzenie nowego + bool AssignEvents(); void Modify(int i, TDynamicObject *o); // dodanie lub odjęcie osi - bool Busy() - { - return (iAxles > 0); - }; - static TIsolated * Root() - { - return (pRoot); - }; - TIsolated * Next() - { - return (pNext); - }; + inline + bool + Busy() { + return (iAxles > 0); }; + inline + static TIsolated * + Root() { + return (pRoot); }; + inline + TIsolated * + Next() { + return (pNext); }; + inline + void + parent( TIsolated *Parent ) { + pParent = Parent; } + inline + TIsolated * + parent() const { + return pParent; } + // members + std::string asName; // nazwa obiektu, baza do nazw eventów + basic_event *evBusy { nullptr }; // zdarzenie wyzwalane po zajęciu grupy + basic_event *evFree { nullptr }; // zdarzenie wyzwalane po całkowitym zwolnieniu zajętości grupy + TMemCell *pMemCell { nullptr }; // automatyczna komórka pamięci, która współpracuje z odcinkiem izolowanym +private: + // members + int iAxles { 0 }; // ilość osi na odcinkach obsługiwanych przez obiekt + TIsolated *pNext { nullptr }; // odcinki izolowane są trzymane w postaci listy jednikierunkowej + TIsolated *pParent { nullptr }; // optional parent piece, receiving data from its children + static TIsolated *pRoot; // początek listy }; -class TTrack : public Resource -{ // trajektoria ruchu - opakowanie - private: +// trajektoria ruchu - opakowanie +class TTrack : public scene::basic_node { + + friend opengl_renderer; + // NOTE: temporary arrangement + friend itemproperties_panel; + +private: + TIsolated * pIsolated = nullptr; // obwód izolowany obsługujący zajęcia/zwolnienia grupy torów std::shared_ptr SwitchExtension; // dodatkowe dane do toru, który jest zwrotnicą std::shared_ptr Segment; - TTrack *trNext = nullptr; // odcinek od strony punktu 2 - to powinno być w segmencie - TTrack *trPrev = nullptr; // odcinek od strony punktu 1 + TTrack * trNext = nullptr; // odcinek od strony punktu 2 - to powinno być w segmencie + TTrack * trPrev = nullptr; // odcinek od strony punktu 1 + // McZapkie-070402: dodalem zmienne opisujace rozmiary tekstur - texture_manager::size_type TextureID1 = 0; // tekstura szyn albo nawierzchni - texture_manager::size_type TextureID2 = 0; // tekstura automatycznej podsypki albo pobocza - float fTexLength = 4.0; // długość powtarzania tekstury w metrach - float fTexRatio1 = 1.0; // proporcja boków tekstury nawierzchni (żeby zaoszczędzić na rozmiarach tekstur...) - float fTexRatio2 = 1.0; // proporcja boków tekstury chodnika (żeby zaoszczędzić na rozmiarach tekstur...) - float fTexHeight1 = 0.6; // wysokość brzegu względem trajektorii - float fTexWidth = 0.9; // szerokość boku - float fTexSlope = 0.9; - double fRadiusTable[ 2 ]; // dwa promienie, drugi dla zwrotnicy int iTrapezoid = 0; // 0-standard, 1-przechyłka, 2-trapez, 3-oba - GLuint DisplayListID = 0; - TIsolated *pIsolated = nullptr; // obwód izolowany obsługujący zajęcia/zwolnienia grupy torów - TGroundNode * - pMyNode = nullptr; // Ra: proteza, żeby tor znał swoją nazwę TODO: odziedziczyć TTrack z TGroundNode - public: -#ifdef EU07_USE_OLD_TTRACK_DYNAMICS_ARRAY - int iNumDynamics = 0; - TDynamicObject *Dynamics[iMaxNumDynamics]; -#else - typedef std::deque dynamics_sequence; + double fRadiusTable[ 2 ] = { 0.0, 0.0 }; // dwa promienie, drugi dla zwrotnicy + float fVerticalRadius { 0.f }; // y-axis track radius (currently not supported) + float fTexLength = 4.0f; // długość powtarzania tekstury w metrach + float fTexRatio1 = 1.0f; // proporcja boków tekstury nawierzchni (żeby zaoszczędzić na rozmiarach tekstur...) + float fTexRatio2 = 1.0f; // proporcja boków tekstury chodnika (żeby zaoszczędzić na rozmiarach tekstur...) + float fTexHeight1 = 0.6f; // wysokość brzegu względem trajektorii + float fTexHeightOffset = 0.f; // potential adjustment to account for the path roll + float fTexWidth = 0.9f; // szerokość boku + float fTexSlope = 0.9f; + + glm::dvec3 m_origin; + material_handle m_material1 = 0; // tekstura szyn albo nawierzchni + material_handle m_material2 = 0; // tekstura automatycznej podsypki albo pobocza + using geometryhandle_sequence = std::vector; + geometryhandle_sequence Geometry1; // geometry chunks textured with texture 1 + geometryhandle_sequence Geometry2; // geometry chunks textured with texture 2 + + std::vector m_paths; // source data for owned paths + +public: + using dynamics_sequence = std::deque; + using event_sequence = std::vector >; + dynamics_sequence Dynamics; -#endif - int iEvents = 0; // Ra: flaga informująca o obecności eventów - TEvent *evEventall0 = nullptr; // McZapkie-140302: wyzwalany gdy pojazd stoi - TEvent *evEventall1 = nullptr; - TEvent *evEventall2 = nullptr; - TEvent *evEvent0 = nullptr; // McZapkie-280503: wyzwalany tylko gdy headdriver - TEvent *evEvent1 = nullptr; - TEvent *evEvent2 = nullptr; - std::string asEventall0Name; // nazwy eventów - std::string asEventall1Name; - std::string asEventall2Name; - std::string asEvent0Name; - std::string asEvent1Name; - std::string asEvent2Name; + event_sequence + m_events0all, + m_events1all, + m_events2all, + m_events0, + m_events1, + m_events2; + bool m_events { false }; // Ra: flaga informująca o obecności eventów + int iNextDirection = 0; // 0:Point1, 1:Point2, 3:do odchylonego na zwrotnicy int iPrevDirection = 0; // domyślnie wirtualne odcinki dołączamy stroną od Point1 TTrackType eType = tt_Normal; // domyślnie zwykły int iCategoryFlag = 1; // 0x100 - usuwanie pojazów // 1-tor, 2-droga, 4-rzeka, 8-samolot? - float fTrackWidth = 1.435; // szerokość w punkcie 1 // rozstaw toru, szerokość nawierzchni - float fTrackWidth2 = 0.0; // szerokość w punkcie 2 (głównie drogi i rzeki) - float fFriction = 0.15; // współczynnik tarcia - float fSoundDistance = -1.0; + float fTrackWidth = 1.435f; // szerokość w punkcie 1 // rozstaw toru, szerokość nawierzchni + float fTrackWidth2 = 0.0f; // szerokość w punkcie 2 (głównie drogi i rzeki) + float fFriction = 0.15f; // współczynnik tarcia + float fSoundDistance = -1.0f; int iQualityFlag = 20; int iDamageFlag = 0; TEnvironmentType eEnvironment = e_flat; // dźwięk i oświetlenie - bool bVisible = true; // czy rysowany int iAction = 0; // czy modyfikowany eventami (specjalna obsługa przy skanowaniu) float fOverhead = -1.0; // można normalnie pobierać prąd (0 dla jazdy bezprądowej po danym odcinku, >0-z opuszczonym i ograniczeniem prędkości) - private: +private: double fVelocity = -1.0; // ograniczenie prędkości // prędkość dla AI (powyżej rośnie prawdopowobieństwo wykolejenia) - public: +public: // McZapkie-100502: - double fTrackLength = 100.0; // długość z wpisu, nigdzie nie używana +// double fTrackLength = 100.0; // długość z wpisu, nigdzie nie używana double fRadius = 0.0; // promień, dla zwrotnicy kopiowany z tabeli bool ScannedFlag = false; // McZapkie: do zaznaczania kolorem torów skanowanych przez AI - TTraction *hvOverhead = nullptr; // drut zasilający do szybkiego znalezienia (nie używany) - TGroundNode *nFouling[ 2 ]; // współrzędne ukresu albo oporu kozła - TTrack *trColides = nullptr; // tor kolizyjny, na którym trzeba sprawdzać pojazdy pod kątem zderzenia + TGroundNode *nFouling[ 2 ] = { nullptr, nullptr }; // współrzędne ukresu albo oporu kozła + + explicit TTrack( scene::node_data const &Nodedata ); + virtual ~TTrack(); - TTrack(TGroundNode *g); - ~TTrack(); void Init(); + static bool sort_by_material( TTrack const *Left, TTrack const *Right ); static TTrack * Create400m(int what, double dx); TTrack * NullCreate(int dir); - inline bool IsEmpty() - { -#ifdef EU07_USE_OLD_TTRACK_DYNAMICS_ARRAY - return (iNumDynamics <= 0); -#else - return Dynamics.empty(); -#endif - }; + inline bool IsEmpty() { + return Dynamics.empty(); }; void ConnectPrevPrev(TTrack *pNewPrev, int typ); void ConnectPrevNext(TTrack *pNewPrev, int typ); void ConnectNextPrev(TTrack *pNewNext, int typ); void ConnectNextNext(TTrack *pNewNext, int typ); - inline double Length() - { - return Segment->GetLength(); - }; - inline std::shared_ptr CurrentSegment() - { - return Segment; - }; - inline TTrack * CurrentNext() - { - return (trNext); - }; - inline TTrack * CurrentPrev() - { - return (trPrev); - }; - TTrack * Neightbour(int s, double &d); + material_handle copy_adjacent_trackbed_material( TTrack const *Exclude = nullptr ); + inline double Length() const { + return Segment->GetLength(); }; + inline std::shared_ptr CurrentSegment() const { + return Segment; }; + inline TTrack *CurrentNext() const { + return trNext; }; + inline TTrack *CurrentPrev() const { + return trPrev; }; + TTrack *Connected(int s, double &d) const; bool SetConnections(int i); - bool Switch(int i, double t = -1.0, double d = -1.0); + bool Switch(int i, float const t = -1.f, float const d = -1.f); bool SwitchForced(int i, TDynamicObject *o); int CrossSegment(int from, int into); - inline int GetSwitchState() - { - return (SwitchExtension ? SwitchExtension->CurrentIndex : -1); - }; - void Load(cParser *parser, vector3 pOrigin, std::string name); - bool AssignEvents(TEvent *NewEvent0, TEvent *NewEvent1, TEvent *NewEvent2); - bool AssignallEvents(TEvent *NewEvent0, TEvent *NewEvent1, TEvent *NewEvent2); - bool AssignForcedEvents(TEvent *NewEventPlus, TEvent *NewEventMinus); + inline int GetSwitchState() { + return ( + SwitchExtension ? + SwitchExtension->CurrentIndex : + -1); }; + // returns number of different routes possible to take from given point + // TODO: specify entry point, number of routes for switches can vary + inline + int + RouteCount() const { + return ( + SwitchExtension != nullptr ? + SwitchExtension->iRoads - 1 : + 1 ); } + void Load(cParser *parser, glm::dvec3 const &pOrigin); + bool AssignEvents(); + bool AssignForcedEvents(basic_event *NewEventPlus, basic_event *NewEventMinus); + void QueueEvents( event_sequence const &Events, TDynamicObject const *Owner ); + void QueueEvents( event_sequence const &Events, TDynamicObject const *Owner, double const Delaylimit ); bool CheckDynamicObject(TDynamicObject *Dynamic); bool AddDynamicObject(TDynamicObject *Dynamic); bool RemoveDynamicObject(TDynamicObject *Dynamic); - void MoveMe(vector3 pPosition); - void Release(); - void Compile(GLuint tex = 0); + // set origin point + void + origin( glm::dvec3 Origin ) { + m_origin = Origin; } + // retrieves list of the track's end points + std::vector + endpoints() const; - void Render(); // renderowanie z Display Lists - int RaArrayPrepare(); // zliczanie rozmiaru dla VBO sektroa - void RaArrayFill(CVertNormTex *Vert, const CVertNormTex *Start); // wypełnianie VBO - void RaRenderVBO(int iPtr); // renderowanie z VBO sektora - void RenderDyn(); // renderowanie nieprzezroczystych pojazdów (oba tryby) - void RenderDynAlpha(); // renderowanie przezroczystych pojazdów (oba tryby) - void RenderDynSounds(); // odtwarzanie dźwięków pojazdów jest niezależne od ich - // wyświetlania + void create_geometry( gfx::geometrybank_handle const &Bank ); // wypełnianie VBO + void RenderDynSounds(); // odtwarzanie dźwięków pojazdów jest niezależne od ich wyświetlania - void RaOwnerSet(TSubRect *o) - { - if (SwitchExtension) - SwitchExtension->pOwner = o; - }; + void RaOwnerSet( scene::basic_cell *o ) { + if( SwitchExtension ) { SwitchExtension->pOwner = o; } }; bool InMovement(); // czy w trakcie animacji? - void RaAssign(TGroundNode *gn, TAnimContainer *ac); - void RaAssign(TGroundNode *gn, TAnimModel *am, TEvent *done, TEvent *joined); + void RaAssign( TAnimModel *am, basic_event *done, basic_event *joined ); void RaAnimListAdd(TTrack *t); TTrack * RaAnimate(); void RadioStop(); - void AxleCounter(int i, TDynamicObject *o) - { + void AxleCounter(int i, TDynamicObject *o) { if (pIsolated) - pIsolated->Modify(i, o); - }; // dodanie lub odjęcie osi + pIsolated->Modify(i, o); }; // dodanie lub odjęcie osi std::string IsolatedName(); - bool IsolatedEventsAssign(TEvent *busy, TEvent *free); double WidthTotal(); - GLuint TextureGet(int i) - { - return i ? TextureID1 : TextureID2; - }; bool IsGroupable(); - int TestPoint(vector3 *Point); - void MovedUp1(double dh); - std::string NameGet(); + int TestPoint( Math3D::vector3 *Point); + void MovedUp1(float const dh); void VelocitySet(float v); - float VelocityGet(); + double VelocityGet(); void ConnectionsLog(); + bool DoubleSlip() const; - private: - void EnvironmentSet(); - void EnvironmentReset(); +private: + // radius() subclass details, calculates node's bounding radius + float radius_(); + // serialize() subclass details, sends content of the subclass to provided stream + void serialize_( std::ostream &Output ) const; + // deserialize() subclass details, restores content of the subclass from provided stream + void deserialize_( std::istream &Input ); + // export() subclass details, sends basic content of the class in legacy (text) format to provided stream + void export_as_text_( std::ostream &Output ) const; + // returns texture length for specified material + float texture_length( material_handle const Material ); + // creates profile for a part of current path + void create_switch_trackbed( gfx::vertex_array &Output ); + void create_track_rail_profile( gfx::vertex_array &Right, gfx::vertex_array &Left ); + void create_track_blade_profile( gfx::vertex_array &Right, gfx::vertex_array &Left ); + void create_track_bed_profile( gfx::vertex_array &Output, TTrack const *Previous, TTrack const *Next ); + void create_road_profile( gfx::vertex_array &Output, bool const Forcetransition = false ); + void create_road_side_profile( gfx::vertex_array &Right, gfx::vertex_array &Left, gfx::vertex_array const &Road, bool const Forcetransition = false ); +}; + + + +// collection of virtual tracks and roads present in the scene +class path_table : public basic_table { + +public: + ~path_table(); + // legacy method, initializes tracks after deserialization from scenario file + void + InitTracks(); + // legacy method, sends list of occupied paths over network + void + TrackBusyList() const; + // legacy method, sends list of occupied path sections over network + void + IsolatedBusyList() const; + // legacy method, sends state of specified path section over network + void + IsolatedBusy( std::string const &Name ) const; }; //--------------------------------------------------------------------------- diff --git a/Traction.cpp b/Traction.cpp index c9a2bdf2..5981f614 100644 --- a/Traction.cpp +++ b/Traction.cpp @@ -14,11 +14,12 @@ http://mozilla.org/MPL/2.0/. #include "stdafx.h" #include "Traction.h" + +#include "simulation.h" #include "Globals.h" +#include "tractionpower.h" #include "logs.h" -#include "mctools.h" -#include "TractionPower.h" -#include "Texture.h" +#include "renderer.h" //--------------------------------------------------------------------------- /* @@ -91,506 +92,315 @@ jawnie nazwę sekcji, ewentualnie nazwę zasilacza (zostanie zastąpiona wskazan sekcji z sąsiedniego przęsła). */ -TTraction::TTraction() -{ - hvNext[ 0 ] = nullptr; - hvNext[ 1 ] = nullptr; - psPower[ 0 ] = nullptr; - psPower[ 1 ] = nullptr; // na początku zasilanie nie podłączone - iNext[ 0 ] = 0; - iNext[ 1 ] = 0; - fResistance[ 0 ] = -1.0; - fResistance[ 1 ] = -1.0; // trzeba dopiero policzyć -} +TTraction::TTraction( scene::node_data const &Nodedata ) : basic_node( Nodedata ) {} -TTraction::~TTraction() -{ - if (!Global::bUseVBO) - glDeleteLists(uiDisplayList, 1); -} +void +TTraction::Load( cParser *parser, glm::dvec3 const &pOrigin ) { -void TTraction::Optimize() -{ - if (Global::bUseVBO) - return; - uiDisplayList = glGenLists(1); - glNewList(uiDisplayList, GL_COMPILE); - - TextureManager.Bind(0); - // glColor3ub(0,0,0); McZapkie: to do render - - // glPushMatrix(); - // glTranslatef(pPosition.x,pPosition.y,pPosition.z); - - if (Wires != 0) - { - // Dlugosc odcinka trakcji 'Winger - double ddp = hypot(pPoint2.x - pPoint1.x, pPoint2.z - pPoint1.z); - - if (Wires == 2) - WireOffset = 0; - // Przewoz jezdny 1 'Marcin - glBegin(GL_LINE_STRIP); - glVertex3f(pPoint1.x - (pPoint2.z / ddp - pPoint1.z / ddp) * WireOffset, pPoint1.y, - pPoint1.z - (-pPoint2.x / ddp + pPoint1.x / ddp) * WireOffset); - glVertex3f(pPoint2.x - (pPoint2.z / ddp - pPoint1.z / ddp) * WireOffset, pPoint2.y, - pPoint2.z - (-pPoint2.x / ddp + pPoint1.x / ddp) * WireOffset); - glEnd(); - // Nie wiem co 'Marcin - Math3D::vector3 pt1, pt2, pt3, pt4, v1, v2; - v1 = pPoint4 - pPoint3; - v2 = pPoint2 - pPoint1; - float step = 0; - if (iNumSections > 0) - step = 1.0f / (float)iNumSections; - float f = step; - float mid = 0.5; - float t; - - // Przewod nosny 'Marcin - if (Wires != 1) - { - glBegin(GL_LINE_STRIP); - glVertex3f(pPoint3.x, pPoint3.y, pPoint3.z); - for (int i = 0; i < iNumSections - 1; i++) - { - pt3 = pPoint3 + v1 * f; - t = (1 - fabs(f - mid) * 2); - if ((Wires < 4) || ((i != 0) && (i != iNumSections - 2))) - glVertex3f(pt3.x, pt3.y - sqrt(t) * fHeightDifference, pt3.z); - f += step; - } - glVertex3f(pPoint4.x, pPoint4.y, pPoint4.z); - glEnd(); - } - - // Drugi przewod jezdny 'Winger - if (Wires > 2) - { - glBegin(GL_LINE_STRIP); - glVertex3f(pPoint1.x + (pPoint2.z / ddp - pPoint1.z / ddp) * WireOffset, pPoint1.y, - pPoint1.z + (-pPoint2.x / ddp + pPoint1.x / ddp) * WireOffset); - glVertex3f(pPoint2.x + (pPoint2.z / ddp - pPoint1.z / ddp) * WireOffset, pPoint2.y, - pPoint2.z + (-pPoint2.x / ddp + pPoint1.x / ddp) * WireOffset); - glEnd(); - } - - f = step; - - if (Wires == 4) - { - glBegin(GL_LINE_STRIP); - glVertex3f(pPoint3.x, pPoint3.y - 0.65f * fHeightDifference, pPoint3.z); - for (int i = 0; i < iNumSections - 1; i++) - { - pt3 = pPoint3 + v1 * f; - t = (1 - fabs(f - mid) * 2); - glVertex3f( - pt3.x, - pt3.y - sqrt(t) * fHeightDifference - - ((i == 0) || (i == iNumSections - 2) ? 0.25f * fHeightDifference : +0.05), - pt3.z); - f += step; - } - glVertex3f(pPoint4.x, pPoint4.y - 0.65f * fHeightDifference, pPoint4.z); - glEnd(); - } - - f = step; - - // Przewody pionowe (wieszaki) 'Marcin, poprawki na 2 przewody jezdne 'Winger - if (Wires != 1) - { - glBegin(GL_LINES); - for (int i = 0; i < iNumSections - 1; i++) - { - float flo, flo1; - flo = (Wires == 4 ? 0.25f * fHeightDifference : 0); - flo1 = (Wires == 4 ? +0.05 : 0); - pt3 = pPoint3 + v1 * f; - pt4 = pPoint1 + v2 * f; - t = (1 - fabs(f - mid) * 2); - if ((i % 2) == 0) - { - glVertex3f(pt3.x, pt3.y - sqrt(t) * fHeightDifference - - ((i == 0) || (i == iNumSections - 2) ? flo : flo1), - pt3.z); - glVertex3f(pt4.x - (pPoint2.z / ddp - pPoint1.z / ddp) * WireOffset, pt4.y, - pt4.z - (-pPoint2.x / ddp + pPoint1.x / ddp) * WireOffset); - } - else - { - glVertex3f(pt3.x, pt3.y - sqrt(t) * fHeightDifference - - ((i == 0) || (i == iNumSections - 2) ? flo : flo1), - pt3.z); - glVertex3f(pt4.x + (pPoint2.z / ddp - pPoint1.z / ddp) * WireOffset, pt4.y, - pt4.z + (-pPoint2.x / ddp + pPoint1.x / ddp) * WireOffset); - } - if ((Wires == 4) && ((i == 1) || (i == iNumSections - 3))) - { - glVertex3f(pt3.x, pt3.y - sqrt(t) * fHeightDifference - 0.05, pt3.z); - glVertex3f(pt3.x, pt3.y - sqrt(t) * fHeightDifference, pt3.z); - } - // endif; - f += step; - } - glEnd(); - } - glEndList(); + parser->getTokens( 4 ); + *parser + >> asPowerSupplyName + >> NominalVoltage + >> MaxCurrent + >> fResistivity; + if( fResistivity == 0.01f ) { + // tyle jest w sceneriach [om/km] + // taka sensowniejsza wartość za http://www.ikolej.pl/fileadmin/user_upload/Seminaria_IK/13_05_07_Prezentacja_Kruczek.pdf + fResistivity = 0.075f; } -} -/* -void TTraction::InitCenter(vector3 Angles, vector3 pOrigin) -{ - pPosition= (pPoint2+pPoint1)*0.5f; - fSquaredRadius= SquareMagnitude((pPoint2-pPoint1)*0.5f); -} */ + fResistivity *= 0.001f; // teraz [om/m] + // Ra 2014-02: a tutaj damy symbol sieci i jej budowę, np.: + // SKB70-C, CuCd70-2C, KB95-2C, C95-C, C95-2C, YC95-2C, YpC95-2C, YC120-2C + // YpC120-2C, YzC120-2C, YwsC120-2C, YC150-C150, YC150-2C150, C150-C150 + // C120-2C, 2C120-2C, 2C120-2C-1, 2C120-2C-2, 2C120-2C-3, 2C120-2C-4 + auto const material = parser->getToken(); + // 1=miedziana, rysuje się na zielono albo czerwono + // 2=aluminiowa, rysuje się na czarno + if( material == "none" ) { Material = 0; } + else if( material == "al" ) { Material = 2; } + else { Material = 1; } + parser->getTokens( 2 ); + *parser + >> WireThickness + >> DamageFlag; + pPoint1 = LoadPoint( *parser ) + pOrigin; + pPoint2 = LoadPoint( *parser ) + pOrigin; + pPoint3 = LoadPoint( *parser ) + pOrigin; + pPoint4 = LoadPoint( *parser ) + pOrigin; + auto const minheight { parser->getToken() }; + fHeightDifference = ( pPoint3.y - pPoint1.y + pPoint4.y - pPoint2.y ) * 0.5 - minheight; + auto const segmentlength { parser->getToken() }; + iNumSections = ( + segmentlength ? + glm::length( ( pPoint1 - pPoint2 ) ) / segmentlength : + 0 ); + parser->getTokens( 2 ); + *parser + >> Wires + >> WireOffset; + m_visible = ( parser->getToken() == "vis" ); -void TTraction::RenderDL(float mgn) // McZapkie: mgn to odleglosc od obserwatora -{ - // McZapkie: ustalanie przezroczystosci i koloru linii: - if (Wires != 0 && !TestFlag(DamageFlag, 128)) // rysuj jesli sa druty i nie zerwana - { - // glDisable(GL_LIGHTING); //aby nie używało wektorów normalnych do kolorowania - glColor4f(0, 0, 0, 1); // jak nieznany kolor to czarne nieprzezroczyste - if (!Global::bSmoothTraction) - glDisable(GL_LINE_SMOOTH); // na liniach kiepsko wygląda - robi gradient - float linealpha = 5000 * WireThickness / (mgn + 1.0); //*WireThickness - if (linealpha > 1.2) - linealpha = 1.2; // zbyt grube nie są dobre - glLineWidth(linealpha); - if (linealpha > 1.0) - linealpha = 1.0; - // McZapkie-261102: kolor zalezy od materialu i zasniedzenia - float r, g, b; - switch (Material) - { // Ra: kolory podzieliłem przez 2, bo po zmianie ambient za jasne były - // trzeba uwzględnić kierunek świecenia Słońca - tylko ze Słońcem widać kolor - case 1: - if (TestFlag(DamageFlag, 1)) - { - r = 0.00000; - g = 0.32549; - b = 0.2882353; // zielona miedź - } - else - { - r = 0.35098; - g = 0.22549; - b = 0.1; // czerwona miedź - } - break; - case 2: - if (TestFlag(DamageFlag, 1)) - { - r = 0.10; - g = 0.10; - b = 0.10; // czarne Al - } - else - { - r = 0.25; - g = 0.25; - b = 0.25; // srebrne Al - } - break; - // tymczasowo pokazanie zasilanych odcinków - case 4: - r = 0.5; - g = 0.5; - b = 1.0; - break; // niebieskie z podłączonym zasilaniem - case 5: - r = 1.0; - g = 0.0; - b = 0.0; - break; // czerwone z podłączonym zasilaniem 1 - case 6: - r = 0.0; - g = 1.0; - b = 0.0; - break; // zielone z podłączonym zasilaniem 2 - case 7: - r = 1.0; - g = 1.0; - b = 0.0; - break; //żółte z podłączonym zasilaniem z obu stron - } - if (DebugModeFlag) - if (hvParallel) - { // jeśli z bieżnią wspólną, to dodatkowo przyciemniamy - r *= 0.6; - g *= 0.6; - b *= 0.6; - } - r *= Global::ambientDayLight[0]; // w zaleźności od koloru swiatła - g *= Global::ambientDayLight[1]; - b *= Global::ambientDayLight[2]; - if (linealpha > 1.0) - linealpha = 1.0; // trzeba ograniczyć do <=1 - glColor4f(r, g, b, linealpha); - if (!uiDisplayList) - Optimize(); // generowanie DL w miarę potrzeby - glCallList(uiDisplayList); - glLineWidth(1.0); - glEnable(GL_LINE_SMOOTH); - // glEnable(GL_LIGHTING); //bez tego się modele nie oświetlają + std::string token { parser->getToken() }; + if( token == "parallel" ) { + // jawne wskazanie innego przęsła, na które może przestawić się pantograf + parser->getTokens(); + *parser >> asParallel; } + while( ( false == token.empty() ) + && ( token != "endtraction" ) ) { + + token = parser->getToken(); + } + + Init(); // przeliczenie parametrów + + // calculate traction location + location( interpolate( pPoint2, pPoint1, 0.5 ) ); } -int TTraction::RaArrayPrepare() -{ // przygotowanie tablic do skopiowania do VBO (zliczanie wierzchołków) - // if (bVisible) //o ile w ogóle widać - switch (Wires) - { - case 1: - iLines = 2; - break; - case 2: - iLines = iNumSections ? 4 * (iNumSections)-2 + 2 : 4; - break; - case 3: - iLines = iNumSections ? 4 * (iNumSections)-2 + 4 : 6; - break; - case 4: - iLines = iNumSections ? 4 * (iNumSections)-2 + 6 : 8; - break; - default: - iLines = 0; - } - // else iLines=0; - return iLines; -}; +// retrieves list of the track's end points +std::vector +TTraction::endpoints() const { -void TTraction::RaArrayFill(CVertNormTex *Vert) -{ // wypełnianie tablic VBO - CVertNormTex *old = Vert; - double ddp = hypot(pPoint2.x - pPoint1.x, pPoint2.z - pPoint1.z); - if (Wires == 2) + return { pPoint1, pPoint2 }; +} + +std::size_t +TTraction::create_geometry( gfx::geometrybank_handle const &Bank ) { + if( m_geometry != null_handle ) { + return GfxRenderer.Vertices( m_geometry ).size() / 2; + } + + gfx::vertex_array vertices; + + double ddp = std::hypot( pPoint2.x - pPoint1.x, pPoint2.z - pPoint1.z ); + if( Wires == 2 ) WireOffset = 0; // jezdny - Vert->x = pPoint1.x - (pPoint2.z / ddp - pPoint1.z / ddp) * WireOffset; - Vert->y = pPoint1.y; - Vert->z = pPoint1.z - (-pPoint2.x / ddp + pPoint1.x / ddp) * WireOffset; - ++Vert; - Vert->x = pPoint2.x - (pPoint2.z / ddp - pPoint1.z / ddp) * WireOffset; - Vert->y = pPoint2.y; - Vert->z = pPoint2.z - (-pPoint2.x / ddp + pPoint1.x / ddp) * WireOffset; - ++Vert; + gfx::basic_vertex startvertex, endvertex; + startvertex.position = + glm::vec3( + pPoint1.x - ( pPoint2.z / ddp - pPoint1.z / ddp ) * WireOffset - m_origin.x, + pPoint1.y - m_origin.y, + pPoint1.z - ( -pPoint2.x / ddp + pPoint1.x / ddp ) * WireOffset - m_origin.z ); + endvertex.position = + glm::vec3( + pPoint2.x - ( pPoint2.z / ddp - pPoint1.z / ddp ) * WireOffset - m_origin.x, + pPoint2.y - m_origin.y, + pPoint2.z - ( -pPoint2.x / ddp + pPoint1.x / ddp ) * WireOffset - m_origin.z ); + vertices.emplace_back( startvertex ); + vertices.emplace_back( endvertex ); // Nie wiem co 'Marcin - Math3D::vector3 pt1, pt2, pt3, pt4, v1, v2; + glm::dvec3 pt1, pt2, pt3, pt4, v1, v2; v1 = pPoint4 - pPoint3; v2 = pPoint2 - pPoint1; float step = 0; - if (iNumSections > 0) + if( iNumSections > 0 ) step = 1.0f / (float)iNumSections; - float f = step; + double f = step; float mid = 0.5; float t; // Przewod nosny 'Marcin - if (Wires > 1) - { // lina nośna w kawałkach - Vert->x = pPoint3.x; - Vert->y = pPoint3.y; - Vert->z = pPoint3.z; - ++Vert; - for (int i = 0; i < iNumSections - 1; i++) - { + if( Wires > 1 ) { // lina nośna w kawałkach + startvertex.position = + glm::vec3( + pPoint3.x - m_origin.x, + pPoint3.y - m_origin.y, + pPoint3.z - m_origin.z ); + for( int i = 0; i < iNumSections - 1; ++i ) { pt3 = pPoint3 + v1 * f; - t = (1 - fabs(f - mid) * 2); - Vert->x = pt3.x; - Vert->y = pt3.y - sqrt(t) * fHeightDifference; - Vert->z = pt3.z; - ++Vert; - Vert->x = pt3.x; // drugi raz, bo nie jest line_strip - Vert->y = pt3.y - sqrt(t) * fHeightDifference; - Vert->z = pt3.z; - ++Vert; + t = ( 1 - std::fabs( f - mid ) * 2 ); + if( ( Wires < 4 ) + || ( ( i != 0 ) + && ( i != iNumSections - 2 ) ) ) { + endvertex.position = + glm::vec3( + pt3.x - m_origin.x, + pt3.y - std::sqrt( t ) * fHeightDifference - m_origin.y, + pt3.z - m_origin.z ); + vertices.emplace_back( startvertex ); + vertices.emplace_back( endvertex ); + startvertex = endvertex; + } f += step; } - Vert->x = pPoint4.x; - Vert->y = pPoint4.y; - Vert->z = pPoint4.z; - ++Vert; + endvertex.position = + glm::vec3( + pPoint4.x - m_origin.x, + pPoint4.y - m_origin.y, + pPoint4.z - m_origin.z ); + vertices.emplace_back( startvertex ); + vertices.emplace_back( endvertex ); } // Drugi przewod jezdny 'Winger - if (Wires == 3) - { - Vert->x = pPoint1.x + (pPoint2.z / ddp - pPoint1.z / ddp) * WireOffset; - Vert->y = pPoint1.y; - Vert->z = pPoint1.z + (-pPoint2.x / ddp + pPoint1.x / ddp) * WireOffset; - ++Vert; - Vert->x = pPoint2.x + (pPoint2.z / ddp - pPoint1.z / ddp) * WireOffset; - Vert->y = pPoint2.y; - Vert->z = pPoint2.z + (-pPoint2.x / ddp + pPoint1.x / ddp) * WireOffset; - ++Vert; + if( Wires > 2 ) { + startvertex.position = + glm::vec3( + pPoint1.x + ( pPoint2.z / ddp - pPoint1.z / ddp ) * WireOffset - m_origin.x, + pPoint1.y - m_origin.y, + pPoint1.z + ( -pPoint2.x / ddp + pPoint1.x / ddp ) * WireOffset - m_origin.z ); + endvertex.position = + glm::vec3( + pPoint2.x + ( pPoint2.z / ddp - pPoint1.z / ddp ) * WireOffset - m_origin.x, + pPoint2.y - m_origin.y, + pPoint2.z + ( -pPoint2.x / ddp + pPoint1.x / ddp ) * WireOffset - m_origin.z ); + vertices.emplace_back( startvertex ); + vertices.emplace_back( endvertex ); + } + + f = step; + + if( Wires == 4 ) { + startvertex.position = + glm::vec3( + pPoint3.x - m_origin.x, + pPoint3.y - 0.65f * fHeightDifference - m_origin.y, + pPoint3.z - m_origin.z ); + for( int i = 0; i < iNumSections - 1; ++i ) { + pt3 = pPoint3 + v1 * f; + t = ( 1 - std::fabs( f - mid ) * 2 ); + endvertex.position = + glm::vec3( + pt3.x - m_origin.x, + pt3.y - std::sqrt( t ) * fHeightDifference - ( + ( ( i == 0 ) + || ( i == iNumSections - 2 ) ) ? + 0.25f * fHeightDifference : + 0.05 ) + - m_origin.y, + pt3.z - m_origin.z ); + vertices.emplace_back( startvertex ); + vertices.emplace_back( endvertex ); + startvertex = endvertex; + f += step; + } + endvertex.position = + glm::vec3( + pPoint4.x - m_origin.x, + pPoint4.y - 0.65f * fHeightDifference - m_origin.y, + pPoint4.z - m_origin.z ); + vertices.emplace_back( startvertex ); + vertices.emplace_back( endvertex ); } f = step; + // Przewody pionowe (wieszaki) 'Marcin, poprawki na 2 przewody jezdne 'Winger - if (Wires > 1) - { - for (int i = 0; i < iNumSections - 1; i++) - { + if( Wires > 1 ) { + auto const flo { static_cast( Wires == 4 ? 0.25f * fHeightDifference : 0 ) }; + auto const flo1 { static_cast( Wires == 4 ? +0.05 : 0 ) }; + for( int i = 0; i < iNumSections - 1; ++i ) { pt3 = pPoint3 + v1 * f; pt4 = pPoint1 + v2 * f; - t = (1 - fabs(f - mid) * 2); - Vert->x = pt3.x; - Vert->y = pt3.y - sqrt(t) * fHeightDifference; - Vert->z = pt3.z; - ++Vert; - if ((i % 2) == 0) - { - Vert->x = pt4.x - (pPoint2.z / ddp - pPoint1.z / ddp) * WireOffset; - Vert->y = pt4.y; - Vert->z = pt4.z - (-pPoint2.x / ddp + pPoint1.x / ddp) * WireOffset; + t = ( 1 - std::fabs( f - mid ) * 2 ); + if( ( i % 2 ) == 0 ) { + startvertex.position = + glm::vec3( + pt3.x - m_origin.x, + pt3.y - std::sqrt( t ) * fHeightDifference - ( ( i == 0 ) || ( i == iNumSections - 2 ) ? flo : flo1 ) - m_origin.y, + pt3.z - m_origin.z ); + endvertex.position = + glm::vec3( + pt4.x - ( pPoint2.z / ddp - pPoint1.z / ddp ) * WireOffset - m_origin.x, + pt4.y - m_origin.y, + pt4.z - ( -pPoint2.x / ddp + pPoint1.x / ddp ) * WireOffset - m_origin.z ); + vertices.emplace_back( startvertex ); + vertices.emplace_back( endvertex ); } - else - { - Vert->x = pt4.x + (pPoint2.z / ddp - pPoint1.z / ddp) * WireOffset; - Vert->y = pt4.y; - Vert->z = pt4.z + (-pPoint2.x / ddp + pPoint1.x / ddp) * WireOffset; + else { + startvertex.position = + glm::vec3( + pt3.x - m_origin.x, + pt3.y - std::sqrt( t ) * fHeightDifference - ( ( i == 0 ) || ( i == iNumSections - 2 ) ? flo : flo1 ) - m_origin.y, + pt3.z - m_origin.z ); + endvertex.position = + glm::vec3( + pt4.x + ( pPoint2.z / ddp - pPoint1.z / ddp ) * WireOffset - m_origin.x, + pt4.y - m_origin.y, + pt4.z + ( -pPoint2.x / ddp + pPoint1.x / ddp ) * WireOffset - m_origin.z ); + vertices.emplace_back( startvertex ); + vertices.emplace_back( endvertex ); + } + if( ( ( Wires == 4 ) + && ( ( i == 1 ) + || ( i == iNumSections - 3 ) ) ) ) { + startvertex.position = + glm::vec3( + pt3.x - m_origin.x, + pt3.y - std::sqrt( t ) * fHeightDifference - 0.05 - m_origin.y, + pt3.z - m_origin.z ); + endvertex.position = + glm::vec3( + pt3.x - m_origin.x, + pt3.y - std::sqrt( t ) * fHeightDifference - m_origin.y, + pt3.z - m_origin.z ); + vertices.emplace_back( startvertex ); + vertices.emplace_back( endvertex ); } - ++Vert; f += step; } } - if ((Vert - old) != iLines) - WriteLog("!!! Wygenerowano punktów " + std::to_string(Vert - old) + ", powinno być " + - std::to_string(iLines)); -}; -void TTraction::RenderVBO(float mgn, int iPtr) -{ // renderowanie z użyciem VBO - if (Wires != 0 && !TestFlag(DamageFlag, 128)) // rysuj jesli sa druty i nie zerwana - { - TextureManager.Bind(0); - glDisable(GL_LIGHTING); // aby nie używało wektorów normalnych do kolorowania - glColor4f(0, 0, 0, 1); // jak nieznany kolor to czarne nieprzezroczyste - if (!Global::bSmoothTraction) - glDisable(GL_LINE_SMOOTH); // na liniach kiepsko wygląda - robi gradient - float linealpha = 5000 * WireThickness / (mgn + 1.0); //*WireThickness - if (linealpha > 1.2) - linealpha = 1.2; // zbyt grube nie są dobre - glLineWidth(linealpha); - // McZapkie-261102: kolor zalezy od materialu i zasniedzenia - float r, g, b; - switch (Material) - { // Ra: kolory podzieliłem przez 2, bo po zmianie ambient za jasne były - // trzeba uwzględnić kierunek świecenia Słońca - tylko ze Słońcem widać kolor - case 1: - if (TestFlag(DamageFlag, 1)) - { - r = 0.00000; - g = 0.32549; - b = 0.2882353; // zielona miedź - } - else - { - r = 0.35098; - g = 0.22549; - b = 0.1; // czerwona miedź - } - break; - case 2: - if (TestFlag(DamageFlag, 1)) - { - r = 0.10; - g = 0.10; - b = 0.10; // czarne Al - } - else - { - r = 0.25; - g = 0.25; - b = 0.25; // srebrne Al - } - break; - // tymczasowo pokazanie zasilanych odcinków - case 4: - r = 0.5; - g = 0.5; - b = 1.0; - break; // niebieskie z podłączonym zasilaniem - case 5: - r = 1.0; - g = 0.0; - b = 0.0; - break; // czerwone z podłączonym zasilaniem 1 - case 6: - r = 0.0; - g = 1.0; - b = 0.0; - break; // zielone z podłączonym zasilaniem 2 - case 7: - r = 1.0; - g = 1.0; - b = 0.0; - break; //żółte z podłączonym zasilaniem z obu stron - } - r = r * Global::ambientDayLight[0]; // w zaleznosci od koloru swiatla - g = g * Global::ambientDayLight[1]; - b = b * Global::ambientDayLight[2]; - if (linealpha > 1.0) - linealpha = 1.0; // trzeba ograniczyć do <=1 - glColor4f(r, g, b, linealpha); - glDrawArrays(GL_LINES, iPtr, iLines); - glLineWidth(1.0); - glEnable(GL_LINE_SMOOTH); - glEnable(GL_LIGHTING); // bez tego się modele nie oświetlają - } -}; + auto const elementcount = vertices.size() / 2; + m_geometry = GfxRenderer.Insert( vertices, Bank, GL_LINES ); -int TTraction::TestPoint(Math3D::vector3 *Point) + return elementcount; +} + +int TTraction::TestPoint(glm::dvec3 const &Point) { // sprawdzanie, czy przęsła można połączyć - if (!hvNext[0]) - if (pPoint1.Equal(Point)) - return 0; - if (!hvNext[1]) - if (pPoint2.Equal(Point)) - return 1; + if( ( hvNext[ 0 ] == nullptr ) + && ( glm::all( glm::epsilonEqual( Point, pPoint1, 0.025 ) ) ) ) { + return 0; + } + if( ( hvNext[ 1 ] == nullptr ) + && ( glm::all( glm::epsilonEqual( Point, pPoint2, 0.025 ) ) ) ) { + return 1; + } return -1; }; -void TTraction::Connect(int my, TTraction *with, int to) -{ //łączenie segmentu (with) od strony (my) do jego (to) - if (my) - { // do mojego Point2 - hvNext[1] = with; - iNext[1] = to; - } - else - { // do mojego Point1 - hvNext[0] = with; - iNext[0] = to; - } - if (to) - { // do jego Point2 - with->hvNext[1] = this; - with->iNext[1] = my; - } - else - { // do jego Point1 - with->hvNext[0] = this; - with->iNext[0] = my; - } - if (hvNext[0]) // jeśli z obu stron podłączony - if (hvNext[1]) - iLast = 0; // to nie jest ostatnim - if (with->hvNext[0]) // temu też, bo drugi raz łączenie się nie nie wykona - if (with->hvNext[1]) - with->iLast = 0; // to nie jest ostatnim -}; +//łączenie segmentu (with) od strony (my) do jego (to) +void +TTraction::Connect(int my, TTraction *with, int to) { -bool TTraction::WhereIs() -{ // ustalenie przedostatnich przęseł - if (iLast) - return (iLast == 1); // ma już ustaloną informację o położeniu - if (hvNext[0] ? hvNext[0]->iLast == 1 : false) // jeśli poprzedni jest ostatnim - iLast = 2; // jest przedostatnim - else if (hvNext[1] ? hvNext[1]->iLast == 1 : false) // jeśli następny jest ostatnim - iLast = 2; // jest przedostatnim - return (iLast == 1); // ostatnie będą dostawać zasilanie -}; + hvNext[ my ] = with; + iNext[ my ] = to; + + if( ( hvNext[ 0 ] != nullptr ) + && ( hvNext[ 1 ] != nullptr ) ) { + // jeśli z obu stron podłączony to nie jest ostatnim + iLast = 0; + } + + with->hvNext[ to ] = this; + with->iNext[ to ] = my; + + if( ( with->hvNext[ 0 ] != nullptr ) + && ( with->hvNext[ 1 ] != nullptr ) ) { + // temu też, bo drugi raz łączenie się nie nie wykona + with->iLast = 0; + } +} + +// ustalenie przedostatnich przęseł +bool TTraction::WhereIs() { + + if( iLast ) { + // ma już ustaloną informację o położeniu + return ( iLast & 1 ); + } + for( int endindex = 0; endindex < 2; ++endindex ) { + if( hvNext[ endindex ] == nullptr ) { + // no neighbour piece means this one is last + iLast |= 1; + } + else if( hvNext[ endindex ]->hvNext[ 1 - iNext[ endindex ] ] == nullptr ) { + // otherwise if that neighbour has no further connection on the opposite end then this piece is second-last + iLast |= 2; + } + } + return (iLast & 1); // ostatnie będą dostawać zasilanie +} void TTraction::Init() { // przeliczenie parametrów @@ -607,21 +417,24 @@ void TTraction::ResistanceCalc(int d, double r, TTractionPowerSource *ps) else ps = psPower[d ^ 1]; // zasilacz od przeciwnej strony niż idzie analiza d = iNext[d]; // kierunek - // double r; //sumaryczna rezystancja - if (DebugModeFlag) // tylko podczas testów - Material = 4; // pokazanie, że to przęsło ma podłączone zasilanie - while (t ? !t->psPower[d] : false) // jeśli jest jakiś kolejny i nie ma ustalonego zasilacza + PowerState = 4; + while( ( t != nullptr ) + && ( t->psPower[d] == nullptr ) ) // jeśli jest jakiś kolejny i nie ma ustalonego zasilacza { // ustawienie zasilacza i policzenie rezystancji zastępczej - if (DebugModeFlag) // tylko podczas testów - if (t->Material != 4) // przęsła zasilającego nie modyfikować - { - if (t->Material < 4) - t->Material = 4; // tymczasowo, aby zmieniła kolor - t->Material |= d ? 2 : 1; // kolor zależny od strony, z której jest zasilanie + if( t->PowerState != 4 ) { + // przęsła zasilającego nie modyfikować + if( t->psPowered != nullptr ) { + + t->PowerState = 4; } + else { + // kolor zależny od strony, z której jest zasilanie + t->PowerState |= d ? 2 : 1; + } + } t->psPower[d] = ps; // skopiowanie wskaźnika zasilacza od danej strony t->fResistance[d] = r; // wpisanie rezystancji w kierunku tego zasilacza - r += t->fResistivity * Length3(t->vParametric); // doliczenie oporu kolejnego odcinka + r += t->fResistivity * glm::length(t->vParametric); // doliczenie oporu kolejnego odcinka p = t; // zapamiętanie dotychczasowego t = p->hvNext[d ^ 1]; // podążanie w tę samą stronę d = p->iNext[d ^ 1]; @@ -630,8 +443,7 @@ void TTraction::ResistanceCalc(int d, double r, TTractionPowerSource *ps) } else { // podążanie w obu kierunkach, można by rekurencją, ale szkoda zasobów - r = 0.5 * fResistivity * - Length3(vParametric); // powiedzmy, że w zasilanym przęśle jest połowa + r = 0.5 * fResistivity * glm::length(vParametric); // powiedzmy, że w zasilanym przęśle jest połowa if (fResistance[0] == 0.0) ResistanceCalc(0, r); // do tyłu (w stronę Point1) if (fResistance[1] == 0.0) @@ -663,12 +475,19 @@ double TTraction::VoltageGet(double u, double i) // 1. zasilacz psPower[0] z rezystancją fResistance[0] oraz jego wewnętrzną // 2. zasilacz psPower[1] z rezystancją fResistance[1] oraz jego wewnętrzną // 3. zasilacz psPowered z jego wewnętrzną rezystancją dla przęseł zasilanych bezpośrednio - double res = (i != 0.0) ? (u / i) : 10000.0; - if (psPowered) - return psPowered->CurrentGet(res) * - res; // yB: dla zasilanego nie baw się w gwiazdy, tylko bierz bezpośrednio + double res = ( + (i != 0.0) ? + (u / i) : + 10000.0 ); + if( psPowered != nullptr ) { + // yB: dla zasilanego nie baw się w gwiazdy, tylko bierz bezpośrednio + return ( + ( res != 0.0 ) ? + psPowered->CurrentGet( res ) * res : + 0.0 ); + } double r0t, r1t, r0g, r1g; - double u0, u1, i0, i1; + double i0, i1; r0t = fResistance[0]; //średni pomysł, ale lepsze niż nic r1t = fResistance[1]; // bo nie uwzględnia spadków z innych pojazdów if (psPower[0] && psPower[1]) @@ -704,3 +523,425 @@ double TTraction::VoltageGet(double u, double i) return psPower[1]->CurrentGet(res + r1t) * res; return 0.0; // gdy nie podłączony wcale? }; + +glm::vec3 +TTraction::wire_color() const { + + glm::vec3 color; + if( false == DebugModeFlag ) { + switch( Material ) { // Ra: kolory podzieliłem przez 2, bo po zmianie ambient za jasne były + // trzeba uwzględnić kierunek świecenia Słońca - tylko ze Słońcem widać kolor + case 1: { + if( TestFlag( DamageFlag, 1 ) ) { + color.r = 0.00000f; + color.g = 0.32549f; + color.b = 0.2882353f; // zielona miedź + } + else { + color.r = 0.35098f; + color.g = 0.22549f; + color.b = 0.1f; // czerwona miedź + } + break; + } + case 2: { + if( TestFlag( DamageFlag, 1 ) ) { + color.r = 0.10f; + color.g = 0.10f; + color.b = 0.10f; // czarne Al + } + else { + color.r = 0.25f; + color.g = 0.25f; + color.b = 0.25f; // srebrne Al + } + break; + } + default: {break; } + } + // w zaleźności od koloru swiatła + color.r *= Global.DayLight.ambient[ 0 ]; + color.g *= Global.DayLight.ambient[ 1 ]; + color.b *= Global.DayLight.ambient[ 2 ]; + color *= 0.35f; + } + else { + // tymczasowo pokazanie zasilanych odcinków + switch( PowerState ) { + + case 1: { + // czerwone z podłączonym zasilaniem 1 +// color.r = 1.0f; +// color.g = 0.0f; +// color.b = 0.0f; + // cyan + color = glm::vec3 { 0.f, 174.f / 255.f, 239.f / 255.f }; + break; + } + case 2: { + // zielone z podłączonym zasilaniem 2 +// color.r = 0.0f; +// color.g = 1.0f; +// color.b = 0.0f; + // yellow + color = glm::vec3 { 240.f / 255.f, 228.f / 255.f, 0.f }; + break; + } + case 3: { + //żółte z podłączonym zasilaniem z obu stron +// color.r = 1.0f; +// color.g = 1.0f; +// color.b = 0.0f; + // green + color = glm::vec3 { 0.f, 239.f / 255.f, 118.f / 255.f }; + break; + } + case 4: { + // niebieskie z podłączonym zasilaniem +// color.r = 0.5f; +// color.g = 0.5f; +// color.b = 1.0f; + // white for powered, red for ends + color = ( + psPowered != nullptr ? + glm::vec3{ 239.f / 255.f, 239.f / 255.f, 239.f / 255.f } : + glm::vec3{ 239.f / 255.f, 128.f / 255.f, 128.f / 255.f } ); + break; + } + default: { break; } + } + if( hvParallel ) { // jeśli z bieżnią wspólną, to dodatkowo przyciemniamy + color.r *= 0.6f; + color.g *= 0.6f; + color.b *= 0.6f; + } +/* + switch( iTries ) { + case 0: { + color = glm::vec3{ 239.f / 255.f, 128.f / 255.f, 128.f / 255.f }; // red + break; + } + case 1: { + color = glm::vec3{ 240.f / 255.f, 228.f / 255.f, 0.f }; // yellow + break; + } + case 5: { + color = glm::vec3{ 0.f / 255.f, 239.f / 255.f, 118.f / 255.f }; // green + break; + } + default: { + color = glm::vec3{ 239.f / 255.f, 239.f / 255.f, 239.f / 255.f }; + break; + } + } +*/ +/* + switch( iLast ) { + case 0: { + color = glm::vec3{ 240.f / 255.f, 228.f / 255.f, 0.f }; // yellow + break; + } + case 1: { + color = glm::vec3{ 239.f / 255.f, 128.f / 255.f, 128.f / 255.f }; // red + break; + } + case 2: { + color = glm::vec3{ 0.f / 255.f, 239.f / 255.f, 118.f / 255.f }; // green + break; + } + default: { + color = glm::vec3{ 239.f / 255.f, 239.f / 255.f, 239.f / 255.f }; + break; + } + } +*/ + } + return color; +} + +// radius() subclass details, calculates node's bounding radius +float +TTraction::radius_() { + + auto const points { endpoints() }; + auto radius { 0.f }; + for( auto &point : points ) { + radius = std::max( + radius, + static_cast( glm::length( m_area.center - point ) ) ); + } + return radius; +} + +// serialize() subclass details, sends content of the subclass to provided stream +void +TTraction::serialize_( std::ostream &Output ) const { + + // TODO: implement +} +// deserialize() subclass details, restores content of the subclass from provided stream +void +TTraction::deserialize_( std::istream &Input ) { + + // TODO: implement +} + +// export() subclass details, sends basic content of the class in legacy (text) format to provided stream +void +TTraction::export_as_text_( std::ostream &Output ) const { + // header + Output << "traction "; + // basic attributes + Output + << asPowerSupplyName << ' ' + << NominalVoltage << ' ' + << MaxCurrent << ' ' + << ( fResistivity * 1000 ) << ' ' + << ( + Material == 2 ? "al" : + Material == 0 ? "none" : + "cu" ) << ' ' + << WireThickness << ' ' + << DamageFlag << ' '; + // path data + Output + << pPoint1.x << ' ' << pPoint1.y << ' ' << pPoint1.z << ' ' + << pPoint2.x << ' ' << pPoint2.y << ' ' << pPoint2.z << ' ' + << pPoint3.x << ' ' << pPoint3.y << ' ' << pPoint3.z << ' ' + << pPoint4.x << ' ' << pPoint4.y << ' ' << pPoint4.z << ' '; + // minimum height + Output << ( ( pPoint3.y - pPoint1.y + pPoint4.y - pPoint2.y ) * 0.5 - fHeightDifference ) << ' '; + // segment length + Output << static_cast( iNumSections ? glm::length( pPoint1 - pPoint2 ) / iNumSections : 0.0 ) << ' '; + // wire data + Output + << Wires << ' ' + << WireOffset << ' '; + // visibility + // NOTE: 'invis' would be less wrong than 'unvis', but potentially incompatible with old 3rd party tools + Output << ( m_visible ? "vis" : "unvis" ) << ' '; + // optional attributes + if( false == asParallel.empty() ) { + Output << "parallel " << asParallel << ' '; + } + // footer + Output + << "endtraction" + << "\n"; +} + + + +// legacy method, initializes traction after deserialization from scenario file +void +traction_table::InitTraction() { + + //łączenie drutów ze sobą oraz z torami i eventami +// TGroundNode *nCurrent, *nTemp; +// TTraction *tmp; // znalezione przęsło + + int connection { -1 }; + TTraction *matchingtraction { nullptr }; + + for( auto *traction : m_items ) { + // podłączenie do zasilacza, żeby można było sumować prąd kilku pojazdów + // a jednocześnie z jednego miejsca zmieniać napięcie eventem + // wykonywane najpierw, żeby można było logować podłączenie 2 zasilaczy do jednego drutu + // izolator zawieszony na przęśle jest ma być osobnym odcinkiem drutu o długości ok. 1m, + // podłączonym do zasilacza o nazwie "*" (gwiazka); "none" nie będzie odpowiednie + auto *powersource = simulation::Powergrid.find( traction->asPowerSupplyName ); + if( powersource ) { + // jak zasilacz znaleziony to podłączyć do przęsła + traction->PowerSet( powersource ); + } + else { + if( ( traction->asPowerSupplyName != "*" ) // gwiazdka dla przęsła z izolatorem + && ( traction->asPowerSupplyName != "none" ) ) { // dopuszczamy na razie brak podłączenia? + // logowanie błędu i utworzenie zasilacza o domyślnej zawartości + ErrorLog( "Bad scenario: traction piece connected to nonexistent power source \"" + traction->asPowerSupplyName + "\"" ); + scene::node_data nodedata; + nodedata.name = traction->asPowerSupplyName; + powersource = new TTractionPowerSource( nodedata ); + powersource->Init( traction->NominalVoltage, traction->MaxCurrent ); + simulation::Powergrid.insert( powersource ); + } + } + } + +#ifdef EU07_IGNORE_LEGACYPROCESSINGORDER + for( auto *traction : m_items ) { +#else + // NOTE: legacy code peformed item operations last-to-first due to way the items were added to the list + // this had impact in situations like two possible connection candidates, where only the first one would be used + for( auto first = std::rbegin(m_items); first != std::rend(m_items); ++first ) { + auto *traction = *first; +#endif + if( traction->hvNext[ 0 ] == nullptr ) { + // tylko jeśli jeszcze nie podłączony + std::tie( matchingtraction, connection ) = simulation::Region->find_traction( traction->pPoint1, traction ); + switch (connection) { + case 0: + case 1: { + traction->Connect( 0, matchingtraction, connection ); + break; + } + default: { + break; + } + } + if( traction->hvNext[ 0 ] ) { + // jeśli został podłączony + if( ( traction->psSection != nullptr ) + && ( matchingtraction->psSection != nullptr ) ) { + // tylko przęsło z izolatorem może nie mieć zasilania, bo ma 2, trzeba sprawdzać sąsiednie + if( traction->psSection != matchingtraction->psSection ) { + // połączone odcinki mają różne zasilacze + // to może być albo podłączenie podstacji lub kabiny sekcyjnej do sekcji, albo błąd + if( ( true == traction->psSection->bSection ) + && ( false == matchingtraction->psSection->bSection ) ) { + //(tmp->psSection) jest podstacją, a (Traction->psSection) nazwą sekcji + matchingtraction->PowerSet( traction->psSection ); // zastąpienie wskazaniem sekcji + } + else if( ( false == traction->psSection->bSection ) + && ( true == matchingtraction->psSection->bSection ) ) { + //(Traction->psSection) jest podstacją, a (tmp->psSection) nazwą sekcji + traction->PowerSet( matchingtraction->psSection ); // zastąpienie wskazaniem sekcji + } + else { + // jeśli obie to sekcje albo obie podstacje, to będzie błąd + ErrorLog( "Bad scenario: faulty traction power connection at location " + to_string( traction->pPoint1 ) ); + } + } + } + } + } + if( traction->hvNext[ 1 ] == nullptr ) { + // tylko jeśli jeszcze nie podłączony + std::tie( matchingtraction, connection ) = simulation::Region->find_traction( traction->pPoint2, traction ); + switch (connection) { + case 0: + case 1: { + traction->Connect( 1, matchingtraction, connection ); + break; + } + default: { + break; + } + } + if( traction->hvNext[ 1 ] ) { + // jeśli został podłączony + if( ( traction->psSection != nullptr ) + && ( matchingtraction->psSection != nullptr ) ) { + // tylko przęsło z izolatorem może nie mieć zasilania, bo ma 2, trzeba sprawdzać sąsiednie + if( traction->psSection != matchingtraction->psSection ) { + // to może być albo podłączenie podstacji lub kabiny sekcyjnej do sekcji, albo błąd + if( ( true == traction->psSection->bSection ) + && ( false == matchingtraction->psSection->bSection ) ) { + //(tmp->psSection) jest podstacją, a (Traction->psSection) nazwą sekcji + matchingtraction->PowerSet( traction->psSection ); // zastąpienie wskazaniem sekcji + } + else if( ( false == traction->psSection->bSection ) + && ( true == matchingtraction->psSection->bSection ) ) { + //(Traction->psSection) jest podstacją, a (tmp->psSection) nazwą sekcji + traction->PowerSet( matchingtraction->psSection ); // zastąpienie wskazaniem sekcji + } + else { + // jeśli obie to sekcje albo obie podstacje, to będzie błąd + ErrorLog( "Bad scenario: faulty traction power connection at location " + to_string( traction->pPoint2 ) ); + } + } + } + } + } + } + + auto endcount { 0 }; + for( auto *traction : m_items ) { + // operacje mające na celu wykrywanie bieżni wspólnych i łączenie przęseł naprążania + if( traction->WhereIs() ) { + // true for outer pieces of the traction section + traction->iTries = 5; // oznaczanie końcowych + ++endcount; + } + if (traction->fResistance[0] == 0.0) { + // obliczanie przęseł w segmencie z bezpośrednim zasilaniem + traction->ResistanceCalc(); + traction->iTries = 0; // nie potrzeba mu szukać zasilania + } + } + + std::vector ends; ends.reserve( endcount ); + for( auto *traction : m_items ) { + //łączenie bieżni wspólnych, w tym oznaczanie niepodanych jawnie + if( false == traction->asParallel.empty() ) { + // będzie wskaźnik na inne przęsło + if( ( traction->asParallel == "none" ) + || ( traction->asParallel == "*" ) ) { + // jeśli nieokreślone + traction->iLast |= 2; // jakby przedostatni - niech po prostu szuka (iLast już przeliczone) + } + else if( traction->hvParallel == nullptr ) { + // jeśli jeszcze nie został włączony w kółko + auto *nTemp = find( traction->asParallel ); + if( nTemp != nullptr ) { + // o ile zostanie znalezione przęsło o takiej nazwie + if( nTemp->hvParallel == nullptr ) { + // jeśli tamten jeszcze nie ma wskaźnika bieżni wspólnej + traction->hvParallel = nTemp; // wpisać siebie i dalej dać mu wskaźnik zwrotny + } + else { + // a jak ma, to albo dołączyć się do kółeczka + traction->hvParallel = nTemp->hvParallel; // przjąć dotychczasowy wskaźnik od niego + } + nTemp->hvParallel = traction; // i na koniec ustawienie wskaźnika zwrotnego + } + if( traction->hvParallel == nullptr ) { + ErrorLog( "Missed overhead: " + traction->asParallel ); // logowanie braku + } + } + } + if( traction->iTries == 5 ) { + // jeśli zaznaczony do podłączenia + // wypełnianie tabeli końców w celu szukania im połączeń + ends.emplace_back( traction ); + } + } + + bool connected; // nieefektywny przebieg kończy łączenie + do { + // ustalenie zastępczej rezystancji dla każdego przęsła + // flaga podłączonych przęseł końcowych: -1=puste wskaźniki, 0=coś zostało, 1=wykonano łączenie + connected = false; + for( auto &end : ends ) { + // załatwione będziemy zerować + if( end == nullptr ) { continue; } + // każdy przebieg to próba podłączenia końca segmentu naprężania do innego zasilanego przęsła + if( end->hvNext[ 0 ] != nullptr ) { + // jeśli końcowy ma ciąg dalszy od strony 0 (Point1), szukamy odcinka najbliższego do Point2 + std::tie( matchingtraction, connection ) = simulation::Region->find_traction( end->pPoint2, end, 0 ); + if( matchingtraction != nullptr ) { + // jak znalezione przęsło z zasilaniem, to podłączenie "równoległe" + end->ResistanceCalc( 0, matchingtraction->fResistance[ connection ], matchingtraction->psPower[ connection ] ); + // jak coś zostało podłączone, to może zasilanie gdzieś dodatkowo dotrze + connected = true; + end = nullptr; + } + } + else if( end->hvNext[ 1 ] != nullptr ) { + // jeśli końcowy ma ciąg dalszy od strony 1 (Point2), szukamy odcinka najbliższego do Point1 + std::tie( matchingtraction, connection ) = simulation::Region->find_traction( end->pPoint1, end, 1 ); + if( matchingtraction != nullptr ) { + // jak znalezione przęsło z zasilaniem, to podłączenie "równoległe" + end->ResistanceCalc( 1, matchingtraction->fResistance[ connection ], matchingtraction->psPower[ connection ] ); + // jak coś zostało podłączone, to może zasilanie gdzieś dodatkowo dotrze + connected = true; + end = nullptr; + } + } + else { + // gdy koniec jest samotny, to na razie nie zostanie podłączony (nie powinno takich być) + end = nullptr; + } + } + } while( true == connected ); +} diff --git a/Traction.h b/Traction.h index 75e72374..8a152127 100644 --- a/Traction.h +++ b/Traction.h @@ -10,73 +10,92 @@ http://mozilla.org/MPL/2.0/. #pragma once #include -#include "opengl/glew.h" -#include "VBO.h" -#include "dumb3d.h" + +#include "scenenode.h" +#include "Segment.h" +#include "material.h" +#include "names.h" class TTractionPowerSource; -class TTraction -{ // drut zasilający, dla wskaźników używać przedrostka "hv" - private: - // vector3 vUp,vFront,vLeft; - // matrix4x4 mMatrix; - // matryca do wyliczania pozycji drutu w zależności od [X,Y,kąt] w scenerii: - // - x: odległość w bok (czy odbierak się nie zsunął) - // - y: przyjmuje wartość <0,1>, jeśli pod drutem (wzdłuż) - // - z: wysokość bezwzględna drutu w danym miejsu +class TTraction : public scene::basic_node { + + friend opengl_renderer; + public: // na razie - TTractionPowerSource *psPower[2]; // najbliższe zasilacze z obu kierunków - TTractionPowerSource *psPowered = nullptr; // ustawione tylko dla bezpośrednio zasilanego przęsła - TTraction *hvNext[2]; //łączenie drutów w sieć - int iNext[2]; // do którego końca się łączy - int iLast = 1; //że niby ostatni drut // ustawiony bit 0, jeśli jest ostatnim drutem w sekcji; bit1 - przedostatni + TTractionPowerSource *psPower[ 2 ] { nullptr, nullptr }; // najbliższe zasilacze z obu kierunków + TTractionPowerSource *psPowered { nullptr }; // ustawione tylko dla bezpośrednio zasilanego przęsła + TTraction *hvNext[ 2 ] { nullptr, nullptr }; //łączenie drutów w sieć + int iNext[ 2 ] { 0, 0 }; // do którego końca się łączy + int iLast { 0 }; //że niby ostatni drut // ustawiony bit 0, jeśli jest ostatnim drutem w sekcji; bit1 - przedostatni public: - GLuint uiDisplayList = 0; - Math3D::vector3 pPoint1, pPoint2, pPoint3, pPoint4; - Math3D::vector3 vParametric; // współczynniki równania parametrycznego odcinka - double fHeightDifference = 0.0; //,fMiddleHeight; - // int iCategory,iMaterial,iDamageFlag; - // float fU,fR,fMaxI,fWireThickness; - int iNumSections = 0; - int iLines = 0; // ilosc linii dla VBO - float NominalVoltage = 0.0; - float MaxCurrent = 0.0; - float fResistivity = 0.0; //[om/m], przeliczone z [om/km] - DWORD Material = 0; // 1: Cu, 2: Al - float WireThickness = 0.0; - DWORD DamageFlag = 0; // 1: zasniedziale, 128: zerwana - int Wires = 2; - float WireOffset = 0.0; + glm::dvec3 pPoint1, pPoint2, pPoint3, pPoint4; + glm::dvec3 vParametric; // współczynniki równania parametrycznego odcinka + double fHeightDifference { 0.0 }; + int iNumSections { 0 }; + float NominalVoltage { 0.0f }; + float MaxCurrent { 0.0f }; + float fResistivity { 0.0f }; //[om/m], przeliczone z [om/km] + DWORD Material { 0 }; // 1: Cu, 2: Al + float WireThickness { 0.0f }; + DWORD DamageFlag { 0 }; // 1: zasniedziale, 128: zerwana + int Wires { 2 }; + float WireOffset { 0.0f }; std::string asPowerSupplyName; // McZapkie: nazwa podstacji trakcyjnej - TTractionPowerSource *psSection = nullptr; // zasilacz (opcjonalnie może to być pulpit sterujący EL2 w hali!) + TTractionPowerSource *psSection { nullptr }; // zasilacz (opcjonalnie może to być pulpit sterujący EL2 w hali!) std::string asParallel; // nazwa przęsła, z którym może być bieżnia wspólna - TTraction *hvParallel = nullptr; // jednokierunkowa i zapętlona lista przęseł ewentualnej bieżni wspólnej - float fResistance[2]; // rezystancja zastępcza do punktu zasilania (0: przęsło zasilane, <0: do policzenia) - int iTries = 0; - // bool bVisible; - // DWORD dwFlags; + TTraction *hvParallel { nullptr }; // jednokierunkowa i zapętlona lista przęseł ewentualnej bieżni wspólnej + float fResistance[ 2 ] { -1.0f, -1.0f }; // rezystancja zastępcza do punktu zasilania (0: przęsło zasilane, <0: do policzenia) + int iTries { 1 }; // 0 is used later down the road to mark directly powered pieces + int PowerState { 0 }; // type of incoming power, if any + // visualization data + glm::dvec3 m_origin; + gfx::geometry_handle m_geometry; - void Optimize(); + explicit TTraction( scene::node_data const &Nodedata ); - TTraction(); - ~TTraction(); - - // virtual void InitCenter(vector3 Angles, vector3 pOrigin); - // virtual bool Hit(double x, double z, vector3 &hitPoint, vector3 &hitDirection) - // { return TNode::Hit(x,z,hitPoint,hitDirection); }; - // virtual bool Move(double dx, double dy, double dz) { return false; }; - // virtual void SelectedRender(); - void RenderDL(float mgn); - int RaArrayPrepare(); - void RaArrayFill(CVertNormTex *Vert); - void RenderVBO(float mgn, int iPtr); - int TestPoint(Math3D::vector3 *Point); + void Load( cParser *parser, glm::dvec3 const &pOrigin ); + // set origin point + void + origin( glm::dvec3 Origin ) { + m_origin = Origin; } + // retrieves list of the track's end points + std::vector + endpoints() const; + // creates geometry data in specified geometry bank. returns: number of created elements, or NULL + // NOTE: deleting nodes doesn't currently release geometry data owned by the node. TODO: implement erasing individual geometry chunks and banks + std::size_t create_geometry( gfx::geometrybank_handle const &Bank ); + int TestPoint(glm::dvec3 const &Point); void Connect(int my, TTraction *with, int to); void Init(); bool WhereIs(); - void ResistanceCalc(int d = -1, double r = 0, TTractionPowerSource *ps = NULL); + void ResistanceCalc(int d = -1, double r = 0, TTractionPowerSource *ps = nullptr); void PowerSet(TTractionPowerSource *ps); double VoltageGet(double u, double i); + +private: +// methods + glm::vec3 wire_color() const; + // radius() subclass details, calculates node's bounding radius + float radius_(); + // serialize() subclass details, sends content of the subclass to provided stream + void serialize_( std::ostream &Output ) const; + // deserialize() subclass details, restores content of the subclass from provided stream + void deserialize_( std::istream &Input ); + // export() subclass details, sends basic content of the class in legacy (text) format to provided stream + void export_as_text_( std::ostream &Output ) const; + }; + + + +// collection of virtual tracks and roads present in the scene +class traction_table : public basic_table { + +public: + // legacy method, initializes traction after deserialization from scenario file + void + InitTraction(); +}; + //--------------------------------------------------------------------------- diff --git a/TractionPower.cpp b/TractionPower.cpp index ade5cc5b..48ff6d4a 100644 --- a/TractionPower.cpp +++ b/TractionPower.cpp @@ -15,19 +15,14 @@ http://mozilla.org/MPL/2.0/. #include "stdafx.h" #include "TractionPower.h" + +#include "parser.h" #include "Logs.h" -#include "Ground.h" //--------------------------------------------------------------------------- -TTractionPowerSource::TTractionPowerSource(TGroundNode const *node) : - gMyNode( node ) -{ - psNode[0] = nullptr; // sekcje zostaną podłączone do zasilaczy - psNode[1] = nullptr; -}; - -TTractionPowerSource::~TTractionPowerSource(){}; +TTractionPowerSource::TTractionPowerSource( scene::node_data const &Nodedata ) : basic_node( Nodedata ) {} +// legacy constructor void TTractionPowerSource::Init(double const u, double const i) { // ustawianie zasilacza przy braku w scenerii @@ -36,61 +31,62 @@ void TTractionPowerSource::Init(double const u, double const i) MaxOutputCurrent = i; }; -bool TTractionPowerSource::Load(cParser *parser) -{ - std::string token; - // AnsiString str; - // str= Parser->GetNextSymbol()LowerCase(); - // asName= str; - parser->getTokens(5); - *parser >> NominalVoltage >> VoltageFrequency >> InternalRes >> MaxOutputCurrent >> - FastFuseTimeOut; - parser->getTokens(); - *parser >> FastFuseRepetition; - parser->getTokens(); - *parser >> SlowFuseTimeOut; - parser->getTokens(); - *parser >> token; - if (token.compare("recuperation") == 0) - Recuperation = true; - else if (token.compare("section") == 0) // odłącznik sekcyjny - bSection = true; // nie jest źródłem zasilania, a jedynie informuje o prądzie odłączenia - // sekcji z obwodu - parser->getTokens(); - *parser >> token; - if (token.compare("end") != 0) - Error("tractionpowersource end statement missing"); - // if (!bSection) //odłącznik sekcji zasadniczo nie ma impedancji (0.01 jest OK) - if (InternalRes < 0.1) // coś mała ta rezystancja była... - InternalRes = 0.2; // tak około 0.2, wg - // http://www.ikolej.pl/fileadmin/user_upload/Seminaria_IK/13_05_07_Prezentacja_Kruczek.pdf - return true; -}; +bool TTractionPowerSource::Load(cParser *parser) { -bool TTractionPowerSource::Render() -{ + parser->getTokens( 10, false ); + *parser + >> m_area.center.x + >> m_area.center.y + >> m_area.center.z + >> NominalVoltage + >> VoltageFrequency + >> InternalRes + >> MaxOutputCurrent + >> FastFuseTimeOut + >> FastFuseRepetition + >> SlowFuseTimeOut; + + std::string token { parser->getToken() }; + if( token == "recuperation" ) { + Recuperation = true; + } + else if( token == "section" ) { + // odłącznik sekcyjny + // nie jest źródłem zasilania, a jedynie informuje o prądzie odłączenia sekcji z obwodu + bSection = true; + } + // skip rest of the section + while( ( false == token.empty() ) + && ( token != "end" ) ) { + + token = parser->getToken(); + } + + if( InternalRes < 0.1 ) { + // coś mała ta rezystancja była... + // tak około 0.2, wg + // http://www.ikolej.pl/fileadmin/user_upload/Seminaria_IK/13_05_07_Prezentacja_Kruczek.pdf + InternalRes = 0.2; + } return true; }; bool TTractionPowerSource::Update(double dt) { // powinno być wykonane raz na krok fizyki - // if (NominalVoltage * TotalPreviousAdmitance > - // MaxOutputCurrent * 0.00000005) // iloczyn napięcia i admitancji daje prąd - // ErrorLog("Power overload: \"" + gMyNode->asName + "\" with current " + AnsiString(NominalVoltage * TotalPreviousAdmitance) + "A"); - if (NominalVoltage * TotalPreviousAdmitance > - MaxOutputCurrent) // iloczyn napięcia i admitancji daje prąd - { + // iloczyn napięcia i admitancji daje prąd + if (NominalVoltage * TotalPreviousAdmitance > MaxOutputCurrent) { + FastFuse = true; FuseCounter += 1; - if (FuseCounter > FastFuseRepetition) - { + if (FuseCounter > FastFuseRepetition) { + SlowFuse = true; - ErrorLog("Power overload: \"" + gMyNode->asName + "\" disabled for " + - std::to_string(SlowFuseTimeOut) + "s"); + ErrorLog( "Power overload: \"" + m_name + "\" disabled for " + std::to_string( SlowFuseTimeOut ) + "s" ); } - else - ErrorLog("Power overload: \"" + gMyNode->asName + "\" disabled for " + - std::to_string(FastFuseTimeOut) + "s"); + else { + ErrorLog( "Power overload: \"" + m_name + "\" disabled for " + std::to_string( FastFuseTimeOut ) + "s" ); + } + FuseTimer = 0; } if (FastFuse || SlowFuse) @@ -145,4 +141,61 @@ void TTractionPowerSource::PowerSet(TTractionPowerSource *ps) // else ErrorLog("nie może być więcej punktów zasilania niż dwa"); }; +// serialize() subclass details, sends content of the subclass to provided stream +void +TTractionPowerSource::serialize_( std::ostream &Output ) const { + + // TODO: implement +} + +// deserialize() subclass details, restores content of the subclass from provided stream +void +TTractionPowerSource::deserialize_( std::istream &Input ) { + + // TODO: implement +} + +// export() subclass details, sends basic content of the class in legacy (text) format to provided stream +void +TTractionPowerSource::export_as_text_( std::ostream &Output ) const { + // header + Output << "tractionpowersource "; + // placement + Output + << location().x << ' ' + << location().y << ' ' + << location().z << ' '; + // basic attributes + Output + << NominalVoltage << ' ' + << VoltageFrequency << ' ' + << InternalRes << ' ' + << MaxOutputCurrent << ' ' + << FastFuseTimeOut << ' ' + << FastFuseRepetition << ' ' + << SlowFuseTimeOut << ' '; + // optional attributes + if( true == Recuperation ) { + Output << "recuperation "; + } + if( true == bSection ) { + Output << "section "; + } + // footer + Output + << "end" + << "\n"; +} + + + +// legacy method, calculates changes in simulation state over specified time +void +powergridsource_table::update( double const Deltatime ) { + + for( auto *powersource : m_items ) { + powersource->Update( Deltatime ); + } +} + //--------------------------------------------------------------------------- diff --git a/TractionPower.h b/TractionPower.h index d85330f7..33ab8983 100644 --- a/TractionPower.h +++ b/TractionPower.h @@ -7,15 +7,39 @@ obtain one at http://mozilla.org/MPL/2.0/. */ -#ifndef TractionPowerH -#define TractionPowerH -#include "parser.h" //Tolaris-010603 +#pragma once -class TGroundNode; +#include "classes.h" +#include "scenenode.h" +#include "names.h" -class TTractionPowerSource -{ - private: +class TTractionPowerSource : public scene::basic_node { + +public: +// constructor + TTractionPowerSource( scene::node_data const &Nodedata ); +// methods + void Init(double const u, double const i); + bool Load(cParser *parser); + bool Update(double dt); + double CurrentGet(double res); + void VoltageSet(double const v) { + NominalVoltage = v; }; + void PowerSet(TTractionPowerSource *ps); +// members + TTractionPowerSource *psNode[ 2 ] = { nullptr, nullptr }; // zasilanie na końcach dla sekcji + bool bSection = false; // czy jest sekcją + +private: +// methods + // serialize() subclass details, sends content of the subclass to provided stream + void serialize_( std::ostream &Output ) const; + // deserialize() subclass details, restores content of the subclass from provided stream + void deserialize_( std::istream &Input ); + // export() subclass details, sends basic content of the class in legacy (text) format to provided stream + void export_as_text_( std::ostream &Output ) const; + +// members double NominalVoltage = 0.0; double VoltageFrequency = 0.0; double InternalRes = 0.2; @@ -33,27 +57,18 @@ class TTractionPowerSource bool SlowFuse = false; double FuseTimer = 0.0; int FuseCounter = 0; - TGroundNode const *gMyNode = nullptr; // wskaźnik na węzeł rodzica - protected: - public: // zmienne publiczne - TTractionPowerSource *psNode[2]; // zasilanie na końcach dla sekcji - bool bSection = false; // czy jest sekcją - public: - // AnsiString asName; - TTractionPowerSource(TGroundNode const *node); - ~TTractionPowerSource(); - void Init(double const u, double const i); - bool Load(cParser *parser); - bool Render(); - bool Update(double dt); - double CurrentGet(double res); - void VoltageSet(double const v) - { - NominalVoltage = v; - }; - void PowerSet(TTractionPowerSource *ps); +}; + + + +// collection of generators for power grid present in the scene +class powergridsource_table : public basic_table { + +public: + // legacy method, calculates changes in simulation state over specified time + void + update( double const Deltatime ); }; //--------------------------------------------------------------------------- -#endif diff --git a/Train.cpp b/Train.cpp index e557dcbe..3bc3d315 100644 --- a/Train.cpp +++ b/Train.cpp @@ -13,57 +13,56 @@ http://mozilla.org/MPL/2.0/. */ #include "stdafx.h" - #include "Train.h" #include "Globals.h" +#include "simulation.h" +#include "simulationtime.h" +#include "camera.h" #include "Logs.h" #include "MdlMngr.h" +#include "model3d.h" +#include "dumb3d.h" #include "Timer.h" #include "Driver.h" +#include "dynobj.h" +#include "mtable.h" #include "Console.h" -#include "McZapkie\hamulce.h" -#include "McZapkie\MOVER.h" -//--------------------------------------------------------------------------- +#include "application.h" -using namespace Timer; +namespace input { + +extern user_command command; -TCab::TCab() -{ - CabPos1.x = -1.0; - CabPos1.y = 1.0; - CabPos1.z = 1.0; - CabPos2.x = 1.0; - CabPos2.y = 1.0; - CabPos2.z = -1.0; - bEnabled = false; - bOccupied = true; - dimm_r = dimm_g = dimm_b = 1; - intlit_r = intlit_g = intlit_b = 0; - intlitlow_r = intlitlow_g = intlitlow_b = 0; - iGaugesMax = 100; // 95 - trzeba pobierać to z pliku konfiguracyjnego - ggList = new TGauge[iGaugesMax]; - iGauges = 0; // na razie nie są dodane - iButtonsMax = 60; // 55 - trzeba pobierać to z pliku konfiguracyjnego - btList = new TButton[iButtonsMax]; - iButtons = 0; } -void TCab::Init(double Initx1, double Inity1, double Initz1, double Initx2, double Inity2, - double Initz2, bool InitEnabled, bool InitOccupied) -{ - CabPos1.x = Initx1; - CabPos1.y = Inity1; - CabPos1.z = Initz1; - CabPos2.x = Initx2; - CabPos2.y = Inity2; - CabPos2.z = Initz2; - bEnabled = InitEnabled; - bOccupied = InitOccupied; +void +control_mapper::insert( TGauge const &Gauge, std::string const &Label ) { + + auto const submodel = Gauge.SubModel; + if( submodel != nullptr ) { + m_controlnames.emplace( submodel, Label ); + } +} + +std::string +control_mapper::find( TSubModel const *Control ) const { + + auto const lookup = m_controlnames.find( Control ); + if( lookup != m_controlnames.end() ) { + return lookup->second; + } + else { + return ""; + } } void TCab::Load(cParser &Parser) { + // NOTE: clearing control tables here is bit of a crutch, imposed by current scheme of loading compartments anew on each cab change + ggList.clear(); + btList.clear(); + std::string token; Parser.getTokens(); Parser >> token; @@ -71,15 +70,15 @@ void TCab::Load(cParser &Parser) { Parser.getTokens( 9, false ); Parser - >> dimm_r - >> dimm_g - >> dimm_b - >> intlit_r - >> intlit_g - >> intlit_b - >> intlitlow_r - >> intlitlow_g - >> intlitlow_b; + >> dimm.r + >> dimm.g + >> dimm.b + >> intlit.r + >> intlit.g + >> intlit.b + >> intlitlow.r + >> intlitlow.g + >> intlitlow.b; Parser.getTokens(); Parser >> token; } CabPos1.x = std::stod( token ); @@ -95,14 +94,9 @@ void TCab::Load(cParser &Parser) bOccupied = true; } -TCab::~TCab() -{ - delete[] ggList; - delete[] btList; -}; - -TGauge *TCab::Gauge(int n) +TGauge &TCab::Gauge(int n) { // pobranie adresu obiektu aniomowanego ruchem +/* if (n < 0) { // rezerwacja wolnego ggList[iGauges].Clear(); @@ -111,9 +105,19 @@ TGauge *TCab::Gauge(int n) else if (n < iGauges) return ggList + n; return NULL; +*/ + if( n < 0 ) { + ggList.emplace_back(); + return ggList.back(); + } + else { + return ggList[ n ]; + } }; -TButton *TCab::Button(int n) + +TButton &TCab::Button(int n) { // pobranie adresu obiektu animowanego wyborem 1 z 2 +/* if (n < 0) { // rezerwacja wolnego return btList + iButtons++; @@ -121,10 +125,19 @@ TButton *TCab::Button(int n) else if (n < iButtons) return btList + n; return NULL; +*/ + if( n < 0 ) { + btList.emplace_back(); + return btList.back(); + } + else { + return btList[ n ]; + } }; void TCab::Update() { // odczyt parametrów i ustawienie animacji submodelom +/* int i; for (i = 0; i < iGauges; ++i) { // animacje izometryczne @@ -135,11 +148,215 @@ void TCab::Update() { // animacje dwustanowe btList[i].Update(); // odczyt parametru i wybór submodelu } +*/ + for( auto &gauge : ggList ) { + // animacje izometryczne + gauge.UpdateValue(); // odczyt parametru i przeliczenie na kąt + gauge.Update(); // ustawienie animacji + } + for( auto &button : btList ) { + // animacje dwustanowe + button.Update(); // odczyt parametru i wybór submodelu + } }; -TTrain::TTrain() -{ - ActiveUniversal4 = false; +// NOTE: we're currently using universal handlers and static handler map but it may be beneficial to have these implemented on individual class instance basis +// TBD, TODO: consider this approach if we ever want to have customized consist behaviour to received commands, based on the consist/vehicle type or whatever +TTrain::commandhandler_map const TTrain::m_commandhandlers = { + + { user_command::aidriverenable, &TTrain::OnCommand_aidriverenable }, + { user_command::aidriverdisable, &TTrain::OnCommand_aidriverdisable }, + { user_command::mastercontrollerincrease, &TTrain::OnCommand_mastercontrollerincrease }, + { user_command::mastercontrollerincreasefast, &TTrain::OnCommand_mastercontrollerincreasefast }, + { user_command::mastercontrollerdecrease, &TTrain::OnCommand_mastercontrollerdecrease }, + { user_command::mastercontrollerdecreasefast, &TTrain::OnCommand_mastercontrollerdecreasefast }, + { user_command::mastercontrollerset, &TTrain::OnCommand_mastercontrollerset }, + { user_command::secondcontrollerincrease, &TTrain::OnCommand_secondcontrollerincrease }, + { user_command::secondcontrollerincreasefast, &TTrain::OnCommand_secondcontrollerincreasefast }, + { user_command::secondcontrollerdecrease, &TTrain::OnCommand_secondcontrollerdecrease }, + { user_command::secondcontrollerdecreasefast, &TTrain::OnCommand_secondcontrollerdecreasefast }, + { user_command::secondcontrollerset, &TTrain::OnCommand_secondcontrollerset }, + { user_command::notchingrelaytoggle, &TTrain::OnCommand_notchingrelaytoggle }, + { user_command::mucurrentindicatorothersourceactivate, &TTrain::OnCommand_mucurrentindicatorothersourceactivate }, + { user_command::independentbrakeincrease, &TTrain::OnCommand_independentbrakeincrease }, + { user_command::independentbrakeincreasefast, &TTrain::OnCommand_independentbrakeincreasefast }, + { user_command::independentbrakedecrease, &TTrain::OnCommand_independentbrakedecrease }, + { user_command::independentbrakedecreasefast, &TTrain::OnCommand_independentbrakedecreasefast }, + { user_command::independentbrakeset, &TTrain::OnCommand_independentbrakeset }, + { user_command::independentbrakebailoff, &TTrain::OnCommand_independentbrakebailoff }, + { user_command::trainbrakeincrease, &TTrain::OnCommand_trainbrakeincrease }, + { user_command::trainbrakedecrease, &TTrain::OnCommand_trainbrakedecrease }, + { user_command::trainbrakeset, &TTrain::OnCommand_trainbrakeset }, + { user_command::trainbrakecharging, &TTrain::OnCommand_trainbrakecharging }, + { user_command::trainbrakerelease, &TTrain::OnCommand_trainbrakerelease }, + { user_command::trainbrakefirstservice, &TTrain::OnCommand_trainbrakefirstservice }, + { user_command::trainbrakeservice, &TTrain::OnCommand_trainbrakeservice }, + { user_command::trainbrakefullservice, &TTrain::OnCommand_trainbrakefullservice }, + { user_command::trainbrakehandleoff, &TTrain::OnCommand_trainbrakehandleoff }, + { user_command::trainbrakeemergency, &TTrain::OnCommand_trainbrakeemergency }, + { user_command::trainbrakebasepressureincrease, &TTrain::OnCommand_trainbrakebasepressureincrease }, + { user_command::trainbrakebasepressuredecrease, &TTrain::OnCommand_trainbrakebasepressuredecrease }, + { user_command::trainbrakebasepressurereset, &TTrain::OnCommand_trainbrakebasepressurereset }, + { user_command::trainbrakeoperationtoggle, &TTrain::OnCommand_trainbrakeoperationtoggle }, + { user_command::manualbrakeincrease, &TTrain::OnCommand_manualbrakeincrease }, + { user_command::manualbrakedecrease, &TTrain::OnCommand_manualbrakedecrease }, + { user_command::alarmchaintoggle, &TTrain::OnCommand_alarmchaintoggle }, + { user_command::wheelspinbrakeactivate, &TTrain::OnCommand_wheelspinbrakeactivate }, + { user_command::sandboxactivate, &TTrain::OnCommand_sandboxactivate }, + { user_command::epbrakecontroltoggle, &TTrain::OnCommand_epbrakecontroltoggle }, + { user_command::trainbrakeoperationmodeincrease, &TTrain::OnCommand_trainbrakeoperationmodeincrease }, + { user_command::trainbrakeoperationmodedecrease, &TTrain::OnCommand_trainbrakeoperationmodedecrease }, + { user_command::brakeactingspeedincrease, &TTrain::OnCommand_brakeactingspeedincrease }, + { user_command::brakeactingspeeddecrease, &TTrain::OnCommand_brakeactingspeeddecrease }, + { user_command::brakeactingspeedsetcargo, &TTrain::OnCommand_brakeactingspeedsetcargo }, + { user_command::brakeactingspeedsetpassenger, &TTrain::OnCommand_brakeactingspeedsetpassenger }, + { user_command::brakeactingspeedsetrapid, &TTrain::OnCommand_brakeactingspeedsetrapid }, + { user_command::brakeloadcompensationincrease, &TTrain::OnCommand_brakeloadcompensationincrease }, + { user_command::brakeloadcompensationdecrease, &TTrain::OnCommand_brakeloadcompensationdecrease }, + { user_command::mubrakingindicatortoggle, &TTrain::OnCommand_mubrakingindicatortoggle }, + { user_command::reverserincrease, &TTrain::OnCommand_reverserincrease }, + { user_command::reverserdecrease, &TTrain::OnCommand_reverserdecrease }, + { user_command::reverserforwardhigh, &TTrain::OnCommand_reverserforwardhigh }, + { user_command::reverserforward, &TTrain::OnCommand_reverserforward }, + { user_command::reverserneutral, &TTrain::OnCommand_reverserneutral }, + { user_command::reverserbackward, &TTrain::OnCommand_reverserbackward }, + { user_command::alerteracknowledge, &TTrain::OnCommand_alerteracknowledge }, + { user_command::batterytoggle, &TTrain::OnCommand_batterytoggle }, + { user_command::batteryenable, &TTrain::OnCommand_batteryenable }, + { user_command::batterydisable, &TTrain::OnCommand_batterydisable }, + { user_command::pantographcompressorvalvetoggle, &TTrain::OnCommand_pantographcompressorvalvetoggle }, + { user_command::pantographcompressoractivate, &TTrain::OnCommand_pantographcompressoractivate }, + { user_command::pantographtogglefront, &TTrain::OnCommand_pantographtogglefront }, + { user_command::pantographtogglerear, &TTrain::OnCommand_pantographtogglerear }, + { user_command::pantographraisefront, &TTrain::OnCommand_pantographraisefront }, + { user_command::pantographraiserear, &TTrain::OnCommand_pantographraiserear }, + { user_command::pantographlowerfront, &TTrain::OnCommand_pantographlowerfront }, + { user_command::pantographlowerrear, &TTrain::OnCommand_pantographlowerrear }, + { user_command::pantographlowerall, &TTrain::OnCommand_pantographlowerall }, + { user_command::linebreakertoggle, &TTrain::OnCommand_linebreakertoggle }, + { user_command::linebreakeropen, &TTrain::OnCommand_linebreakeropen }, + { user_command::linebreakerclose, &TTrain::OnCommand_linebreakerclose }, + { user_command::fuelpumptoggle, &TTrain::OnCommand_fuelpumptoggle }, + { user_command::fuelpumpenable, &TTrain::OnCommand_fuelpumpenable }, + { user_command::fuelpumpdisable, &TTrain::OnCommand_fuelpumpdisable }, + { user_command::oilpumptoggle, &TTrain::OnCommand_oilpumptoggle }, + { user_command::oilpumpenable, &TTrain::OnCommand_oilpumpenable }, + { user_command::oilpumpdisable, &TTrain::OnCommand_oilpumpdisable }, + { user_command::waterheaterbreakertoggle, &TTrain::OnCommand_waterheaterbreakertoggle }, + { user_command::waterheaterbreakerclose, &TTrain::OnCommand_waterheaterbreakerclose }, + { user_command::waterheaterbreakeropen, &TTrain::OnCommand_waterheaterbreakeropen }, + { user_command::waterheatertoggle, &TTrain::OnCommand_waterheatertoggle }, + { user_command::waterheaterenable, &TTrain::OnCommand_waterheaterenable }, + { user_command::waterheaterdisable, &TTrain::OnCommand_waterheaterdisable }, + { user_command::waterpumpbreakertoggle, &TTrain::OnCommand_waterpumpbreakertoggle }, + { user_command::waterpumpbreakerclose, &TTrain::OnCommand_waterpumpbreakerclose }, + { user_command::waterpumpbreakeropen, &TTrain::OnCommand_waterpumpbreakeropen }, + { user_command::waterpumptoggle, &TTrain::OnCommand_waterpumptoggle }, + { user_command::waterpumpenable, &TTrain::OnCommand_waterpumpenable }, + { user_command::waterpumpdisable, &TTrain::OnCommand_waterpumpdisable }, + { user_command::watercircuitslinktoggle, &TTrain::OnCommand_watercircuitslinktoggle }, + { user_command::watercircuitslinkenable, &TTrain::OnCommand_watercircuitslinkenable }, + { user_command::watercircuitslinkdisable, &TTrain::OnCommand_watercircuitslinkdisable }, + { user_command::convertertoggle, &TTrain::OnCommand_convertertoggle }, + { user_command::converterenable, &TTrain::OnCommand_converterenable }, + { user_command::converterdisable, &TTrain::OnCommand_converterdisable }, + { user_command::convertertogglelocal, &TTrain::OnCommand_convertertogglelocal }, + { user_command::converteroverloadrelayreset, &TTrain::OnCommand_converteroverloadrelayreset }, + { user_command::compressortoggle, &TTrain::OnCommand_compressortoggle }, + { user_command::compressorenable, &TTrain::OnCommand_compressorenable }, + { user_command::compressordisable, &TTrain::OnCommand_compressordisable }, + { user_command::compressortogglelocal, &TTrain::OnCommand_compressortogglelocal }, + { user_command::motorblowerstogglefront, &TTrain::OnCommand_motorblowerstogglefront }, + { user_command::motorblowerstogglerear, &TTrain::OnCommand_motorblowerstogglerear }, + { user_command::motorblowersdisableall, &TTrain::OnCommand_motorblowersdisableall }, + { user_command::motorconnectorsopen, &TTrain::OnCommand_motorconnectorsopen }, + { user_command::motorconnectorsclose, &TTrain::OnCommand_motorconnectorsclose }, + { user_command::motordisconnect, &TTrain::OnCommand_motordisconnect }, + { user_command::motoroverloadrelaythresholdtoggle, &TTrain::OnCommand_motoroverloadrelaythresholdtoggle }, + { user_command::motoroverloadrelaythresholdsetlow, &TTrain::OnCommand_motoroverloadrelaythresholdsetlow }, + { user_command::motoroverloadrelaythresholdsethigh, &TTrain::OnCommand_motoroverloadrelaythresholdsethigh }, + { user_command::motoroverloadrelayreset, &TTrain::OnCommand_motoroverloadrelayreset }, + { user_command::heatingtoggle, &TTrain::OnCommand_heatingtoggle }, + { user_command::heatingenable, &TTrain::OnCommand_heatingenable }, + { user_command::heatingdisable, &TTrain::OnCommand_heatingdisable }, + { user_command::lightspresetactivatenext, &TTrain::OnCommand_lightspresetactivatenext }, + { user_command::lightspresetactivateprevious, &TTrain::OnCommand_lightspresetactivateprevious }, + { user_command::headlighttoggleleft, &TTrain::OnCommand_headlighttoggleleft }, + { user_command::headlightenableleft, &TTrain::OnCommand_headlightenableleft }, + { user_command::headlightdisableleft, &TTrain::OnCommand_headlightdisableleft }, + { user_command::headlighttoggleright, &TTrain::OnCommand_headlighttoggleright }, + { user_command::headlightenableright, &TTrain::OnCommand_headlightenableright }, + { user_command::headlightdisableright, &TTrain::OnCommand_headlightdisableright }, + { user_command::headlighttoggleupper, &TTrain::OnCommand_headlighttoggleupper }, + { user_command::headlightenableupper, &TTrain::OnCommand_headlightenableupper }, + { user_command::headlightdisableupper, &TTrain::OnCommand_headlightdisableupper }, + { user_command::redmarkertoggleleft, &TTrain::OnCommand_redmarkertoggleleft }, + { user_command::redmarkerenableleft, &TTrain::OnCommand_redmarkerenableleft }, + { user_command::redmarkerdisableleft, &TTrain::OnCommand_redmarkerdisableleft }, + { user_command::redmarkertoggleright, &TTrain::OnCommand_redmarkertoggleright }, + { user_command::redmarkerenableright, &TTrain::OnCommand_redmarkerenableright }, + { user_command::redmarkerdisableright, &TTrain::OnCommand_redmarkerdisableright }, + { user_command::headlighttogglerearleft, &TTrain::OnCommand_headlighttogglerearleft }, + { user_command::headlighttogglerearright, &TTrain::OnCommand_headlighttogglerearright }, + { user_command::headlighttogglerearupper, &TTrain::OnCommand_headlighttogglerearupper }, + { user_command::redmarkertogglerearleft, &TTrain::OnCommand_redmarkertogglerearleft }, + { user_command::redmarkertogglerearright, &TTrain::OnCommand_redmarkertogglerearright }, + { user_command::redmarkerstoggle, &TTrain::OnCommand_redmarkerstoggle }, + { user_command::endsignalstoggle, &TTrain::OnCommand_endsignalstoggle }, + { user_command::headlightsdimtoggle, &TTrain::OnCommand_headlightsdimtoggle }, + { user_command::headlightsdimenable, &TTrain::OnCommand_headlightsdimenable }, + { user_command::headlightsdimdisable, &TTrain::OnCommand_headlightsdimdisable }, + { user_command::interiorlighttoggle, &TTrain::OnCommand_interiorlighttoggle }, + { user_command::interiorlightenable, &TTrain::OnCommand_interiorlightenable }, + { user_command::interiorlightdimdisable, &TTrain::OnCommand_interiorlightdisable }, + { user_command::interiorlightdimtoggle, &TTrain::OnCommand_interiorlightdimtoggle }, + { user_command::interiorlightdimenable, &TTrain::OnCommand_interiorlightdimenable }, + { user_command::interiorlightdimdisable, &TTrain::OnCommand_interiorlightdimdisable }, + { user_command::instrumentlighttoggle, &TTrain::OnCommand_instrumentlighttoggle }, + { user_command::instrumentlightenable, &TTrain::OnCommand_instrumentlightenable }, + { user_command::instrumentlightdisable, &TTrain::OnCommand_instrumentlightdisable }, + { user_command::dashboardlighttoggle, &TTrain::OnCommand_dashboardlighttoggle }, + { user_command::timetablelighttoggle, &TTrain::OnCommand_timetablelighttoggle }, + { user_command::doorlocktoggle, &TTrain::OnCommand_doorlocktoggle }, + { user_command::doortoggleleft, &TTrain::OnCommand_doortoggleleft }, + { user_command::doortoggleright, &TTrain::OnCommand_doortoggleright }, + { user_command::dooropenleft, &TTrain::OnCommand_dooropenleft }, + { user_command::dooropenright, &TTrain::OnCommand_dooropenright }, + { user_command::doorcloseleft, &TTrain::OnCommand_doorcloseleft }, + { user_command::doorcloseright, &TTrain::OnCommand_doorcloseright }, + { user_command::doorcloseall, &TTrain::OnCommand_doorcloseall }, + { user_command::carcouplingincrease, &TTrain::OnCommand_carcouplingincrease }, + { user_command::carcouplingdisconnect, &TTrain::OnCommand_carcouplingdisconnect }, + { user_command::departureannounce, &TTrain::OnCommand_departureannounce }, + { user_command::hornlowactivate, &TTrain::OnCommand_hornlowactivate }, + { user_command::hornhighactivate, &TTrain::OnCommand_hornhighactivate }, + { user_command::whistleactivate, &TTrain::OnCommand_whistleactivate }, + { user_command::radiotoggle, &TTrain::OnCommand_radiotoggle }, + { user_command::radiochannelincrease, &TTrain::OnCommand_radiochannelincrease }, + { user_command::radiochanneldecrease, &TTrain::OnCommand_radiochanneldecrease }, + { user_command::radiostopsend, &TTrain::OnCommand_radiostopsend }, + { user_command::radiostoptest, &TTrain::OnCommand_radiostoptest }, + { user_command::cabchangeforward, &TTrain::OnCommand_cabchangeforward }, + { user_command::cabchangebackward, &TTrain::OnCommand_cabchangebackward }, + { user_command::generictoggle0, &TTrain::OnCommand_generictoggle }, + { user_command::generictoggle1, &TTrain::OnCommand_generictoggle }, + { user_command::generictoggle2, &TTrain::OnCommand_generictoggle }, + { user_command::generictoggle3, &TTrain::OnCommand_generictoggle }, + { user_command::generictoggle4, &TTrain::OnCommand_generictoggle }, + { user_command::generictoggle5, &TTrain::OnCommand_generictoggle }, + { user_command::generictoggle6, &TTrain::OnCommand_generictoggle }, + { user_command::generictoggle7, &TTrain::OnCommand_generictoggle }, + { user_command::generictoggle8, &TTrain::OnCommand_generictoggle }, + { user_command::generictoggle9, &TTrain::OnCommand_generictoggle } +}; + +std::vector const TTrain::fPress_labels = { + + "ch1: ", "ch2: ", "ch3: ", "ch4: ", "ch5: ", "ch6: ", "ch7: ", "ch8: ", "ch9: ", "ch0: " +}; + +TTrain::TTrain() { + ShowNextCurrent = false; // McZapkie-240302 - przyda sie do tachometru fTachoVelocity = 0; @@ -147,44 +364,18 @@ TTrain::TTrain() fPPress = fNPress = 0; // asMessage=""; - fMechCroach = 0.25; - pMechShake = vector3(0, 0, 0); - vMechMovement = vector3(0, 0, 0); - pMechOffset = vector3(0, 0, 0); + pMechShake = Math3D::vector3(0, 0, 0); + vMechMovement = Math3D::vector3(0, 0, 0); + pMechOffset = Math3D::vector3(0, 0, 0); fBlinkTimer = 0; fHaslerTimer = 0; - keybrakecount = 0; DynamicSet(NULL); // ustawia wszystkie mv* iCabLightFlag = 0; // hunter-091012 bCabLight = false; bCabLightDim = false; //----- - pMechSittingPosition = vector3(0, 0, 0); // ABu: 180404 - LampkaUniversal3_st = false; // ABu: 030405 - dsbNastawnikJazdy = NULL; - dsbNastawnikBocz = NULL; - dsbRelay = NULL; - dsbPneumaticRelay = NULL; - dsbSwitch = NULL; - dsbPneumaticSwitch = NULL; - dsbReverserKey = NULL; // hunter-121211 - dsbCouplerAttach = NULL; - dsbCouplerDetach = NULL; - dsbDieselIgnition = NULL; - dsbDoorClose = NULL; - dsbDoorOpen = NULL; - dsbPantUp = NULL; - dsbPantDown = NULL; - dsbWejscie_na_bezoporow = NULL; - dsbWejscie_na_drugi_uklad = NULL; // hunter-081211: poprawka literowki - dsbHasler = NULL; - dsbBuzzer = NULL; - dsbSlipAlarm = NULL; // Bombardier 011010: alarm przy poslizgu dla 181/182 - dsbCouplerStretch = NULL; - dsbEN57_CouplerStretch = NULL; - dsbBufferClamp = NULL; - iRadioChannel = 0; + pMechSittingPosition = Math3D::vector3(0, 0, 0); // ABu: 180404 fTachoTimer = 0.0; // włączenie skoków wskazań prędkościomierza // @@ -209,42 +400,26 @@ TTrain::TTrain() fPress[ i ][ j ] = 0.0; } -TTrain::~TTrain() -{ - if (DynamicObject) - if (DynamicObject->Mechanik) - DynamicObject->Mechanik->TakeControl( - true); // likwidacja kabiny wymaga przejęcia przez AI -} - bool TTrain::Init(TDynamicObject *NewDynamicObject, bool e3d) { // powiązanie ręcznego sterowania kabiną z pojazdem - // Global::pUserDynamic=NewDynamicObject; //pojazd renderowany bez trzęsienia + if( NewDynamicObject->Mechanik == nullptr ) { + ErrorLog( "Bad config: can't take control of inactive vehicle \"" + NewDynamicObject->asName + "\"" ); + return false; + } + DynamicSet(NewDynamicObject); if (!e3d) if (DynamicObject->Mechanik == NULL) return false; - // if (DynamicObject->Mechanik->AIControllFlag==AIdriver) - // return false; + DynamicObject->MechInside = true; - /* iPozSzereg=28; - for (int i=1; iMainCtrlPosNo; i++) - { - if (mvControlled->RList[i].Bn>1) - { - iPozSzereg=i-1; - i=mvControlled->MainCtrlPosNo+1; - } - } - */ - MechSpring.Init(0.015, 250); - vMechVelocity = vector3(0, 0, 0); - pMechOffset = vector3(-0.4, 3.3, 5.5); - fMechCroach = 0.5; - fMechSpringX = 1; - fMechSpringY = 0.5; - fMechSpringZ = 0.5; + MechSpring.Init(125.0); + vMechVelocity = Math3D::vector3(0, 0, 0); + pMechOffset = Math3D::vector3( 0, 0, 0 ); + fMechSpringX = 0.2; + fMechSpringY = 0.2; + fMechSpringZ = 0.1; fMechMaxSpring = 0.15; fMechRoll = 0.05; fMechPitch = 0.1; @@ -254,25 +429,6 @@ bool TTrain::Init(TDynamicObject *NewDynamicObject, bool e3d) return false; } - // McZapkie: w razie wykolejenia - // dsbDerailment=TSoundsManager::GetFromName("derail.wav"); - // McZapkie: jazda luzem: - // dsbRunningNoise=TSoundsManager::GetFromName("runningnoise.wav"); - - // McZapkie? - dzwieki slyszalne tylko wewnatrz kabiny - generowane przez - // obiekt sterowany: - - // McZapkie-080302 sWentylatory.Init("wenton.wav","went.wav","wentoff.wav"); - // McZapkie-010302 - // sCompressor.Init("compressor-start.wav","compressor.wav","compressor-stop.wav"); - - // sHorn1.Init("horn1.wav",0.3); - // sHorn2.Init("horn2.wav",0.3); - - // sHorn1.Init("horn1-start.wav","horn1.wav","horn1-stop.wav"); - // sHorn2.Init("horn2-start.wav","horn2.wav","horn2-stop.wav"); - - // sConverter.Init("converter.wav",1.5); //NBMX obsluga przez AdvSound iCabn = 0; // Ra: taka proteza - przesłanie kierunku do członów connected if (mvControlled->ActiveDir > 0) @@ -289,2228 +445,4267 @@ bool TTrain::Init(TDynamicObject *NewDynamicObject, bool e3d) } PyObject *TTrain::GetTrainState() { - PyObject *dict = PyDict_New(); - if( dict == NULL ) { - return NULL; + + auto const *mover = DynamicObject->MoverParameters; + PyEval_AcquireLock(); + auto *dict = PyDict_New(); + PyEval_ReleaseLock(); + if( ( dict == nullptr ) + || ( mover == nullptr ) ) { + return nullptr; } - PyDict_SetItemString( dict, "direction", PyGetInt( DynamicObject->MoverParameters->ActiveDir ) ); - PyDict_SetItemString( dict, "cab", PyGetInt( DynamicObject->MoverParameters->ActiveCab ) ); - PyDict_SetItemString( dict, "slipping_wheels", - PyGetBool( DynamicObject->MoverParameters->SlippingWheels ) ); - PyDict_SetItemString( dict, "converter", - PyGetBool( DynamicObject->MoverParameters->ConverterFlag ) ); - PyDict_SetItemString( dict, "main_ctrl_actual_pos", - PyGetInt( DynamicObject->MoverParameters->MainCtrlActualPos ) ); - PyDict_SetItemString( dict, "scnd_ctrl_actual_pos", - PyGetInt( DynamicObject->MoverParameters->ScndCtrlActualPos ) ); - PyDict_SetItemString( dict, "fuse", PyGetBool( DynamicObject->MoverParameters->FuseFlag ) ); - PyDict_SetItemString( dict, "converter_overload", - PyGetBool( DynamicObject->MoverParameters->ConvOvldFlag ) ); - PyDict_SetItemString( dict, "voltage", PyGetFloat( DynamicObject->MoverParameters->Voltage ) ); - PyDict_SetItemString( dict, "velocity", PyGetFloat( DynamicObject->MoverParameters->Vel ) ); - PyDict_SetItemString( dict, "im", PyGetFloat( DynamicObject->MoverParameters->Im ) ); - PyDict_SetItemString( dict, "compress", - PyGetBool( DynamicObject->MoverParameters->CompressorFlag ) ); - PyDict_SetItemString( dict, "hours", PyGetInt( GlobalTime->hh ) ); - PyDict_SetItemString( dict, "minutes", PyGetInt( GlobalTime->mm ) ); - PyDict_SetItemString( dict, "seconds", PyGetInt( GlobalTime->mr ) ); - PyDict_SetItemString( dict, "velocity_desired", PyGetFloat( DynamicObject->Mechanik->VelDesired ) ); - char* TXTT[ 10 ] = { "fd", "fdt", "fdb", "pd", "pdt", "pdb", "itothv", "1", "2", "3" }; - char* TXTC[ 10 ] = { "fr", "frt", "frb", "pr", "prt", "prb", "im", "vm", "ihv", "uhv" }; - char* TXTP[ 3 ] = { "bc", "bp", "sp" }; - for( int j = 0; j<10; j++ ) - PyDict_SetItemString( dict, ( std::string( "eimp_t_" ) + std::string( TXTT[ j ] ) ).c_str(), PyGetFloatS( fEIMParams[ 0 ][ j ] ) ); - for( int i = 0; i<8; i++ ) { - for( int j = 0; j<10; j++ ) - PyDict_SetItemString( dict, ( std::string( "eimp_c" ) + std::to_string( i + 1 ) + std::string( "_" ) + std::string( TXTC[ j ] ) ).c_str(), PyGetFloatS( fEIMParams[ i + 1 ][ j ] ) ); - PyDict_SetItemString( dict, ( std::string( "eimp_c" ) + std::to_string( i + 1 ) + std::string( "_ms" ) ).c_str(), PyGetBool( bMains[ i ] ) ); - PyDict_SetItemString( dict, ( std::string( "eimp_c" ) + std::to_string( i + 1 ) + std::string( "_cv" ) ).c_str(), PyGetFloatS( fCntVol[ i ] ) ); - PyDict_SetItemString( dict, ( std::string( "eimp_u" ) + std::to_string( i + 1 ) + std::string( "_pf" ) ).c_str(), PyGetBool( bPants[ i ][ 0 ] ) ); - PyDict_SetItemString( dict, ( std::string( "eimp_u" ) + std::to_string( i + 1 ) + std::string( "_pr" ) ).c_str(), PyGetBool( bPants[ i ][ 1 ] ) ); - PyDict_SetItemString( dict, ( std::string( "eimp_c" ) + std::to_string( i + 1 ) + std::string( "_fuse" ) ).c_str(), PyGetBool( bFuse[ i ] ) ); - PyDict_SetItemString( dict, ( std::string( "eimp_c" ) + std::to_string( i + 1 ) + std::string( "_batt" ) ).c_str(), PyGetBool( bBatt[ i ] ) ); - PyDict_SetItemString( dict, ( std::string( "eimp_c" ) + std::to_string( i + 1 ) + std::string( "_conv" ) ).c_str(), PyGetBool( bConv[ i ] ) ); - PyDict_SetItemString( dict, ( std::string( "eimp_u" ) + std::to_string( i + 1 ) + std::string( "_comp_a" ) ).c_str(), PyGetBool( bComp[ i ][ 0 ] ) ); - PyDict_SetItemString( dict, ( std::string( "eimp_u" ) + std::to_string( i + 1 ) + std::string( "_comp_w" ) ).c_str(), PyGetBool( bComp[ i ][ 1 ] ) ); - PyDict_SetItemString( dict, ( std::string( "eimp_c" ) + std::to_string( i + 1 ) + std::string( "_heat" ) ).c_str(), PyGetBool( bHeat[ i ] ) ); - - } - for( int i = 0; i<20; i++ ) { - for( int j = 0; j<3; j++ ) - PyDict_SetItemString( dict, ( std::string( "eimp_pn" ) + std::to_string( i + 1 ) + std::string( "_" ) + std::string( TXTP[ j ] ) ).c_str(), - PyGetFloatS( fPress[ i ][ j ] ) ); - } - bool bEP, bPN; - bEP = ( mvControlled->LocHandle->GetCP()>0.2 ) || ( fEIMParams[ 0 ][ 2 ]>0.01 ); + PyDict_SetItemString( dict, "name", PyGetString( DynamicObject->asName.c_str() ) ); + PyDict_SetItemString( dict, "cab", PyGetInt( mover->ActiveCab ) ); + // basic systems state data + PyDict_SetItemString( dict, "battery", PyGetBool( mvControlled->Battery ) ); + PyDict_SetItemString( dict, "linebreaker", PyGetBool( mvControlled->Mains ) ); + PyDict_SetItemString( dict, "converter", PyGetBool( mover->ConverterFlag ) ); + PyDict_SetItemString( dict, "converter_overload", PyGetBool( mover->ConvOvldFlag ) ); + PyDict_SetItemString( dict, "compress", PyGetBool( mover->CompressorFlag ) ); + // reverser + PyDict_SetItemString( dict, "direction", PyGetInt( mover->ActiveDir ) ); + // throttle + PyDict_SetItemString( dict, "mainctrl_pos", PyGetInt( mover->MainCtrlPos ) ); + PyDict_SetItemString( dict, "main_ctrl_actual_pos", PyGetInt( mover->MainCtrlActualPos ) ); + PyDict_SetItemString( dict, "scndctrl_pos", PyGetInt( mover->ScndCtrlPos ) ); + PyDict_SetItemString( dict, "scnd_ctrl_actual_pos", PyGetInt( mover->ScndCtrlActualPos ) ); + // brakes + PyDict_SetItemString( dict, "manual_brake", PyGetBool( mvOccupied->ManualBrakePos > 0 ) ); + bool const bEP = ( mvControlled->LocHandle->GetCP() > 0.2 ) || ( fEIMParams[ 0 ][ 2 ] > 0.01 ); PyDict_SetItemString( dict, "dir_brake", PyGetBool( bEP ) ); + bool bPN; if( ( typeid( *mvControlled->Hamulec ) == typeid( TLSt ) ) || ( typeid( *mvControlled->Hamulec ) == typeid( TEStED ) ) ) { TBrake* temp_ham = mvControlled->Hamulec.get(); - // TLSt* temp_ham2 = temp_ham; - bPN = ( static_cast( temp_ham )->GetEDBCP()>0.2 ); + bPN = ( static_cast( temp_ham )->GetEDBCP() > 0.2 ); } else bPN = false; PyDict_SetItemString( dict, "indir_brake", PyGetBool( bPN ) ); - for( int i = 0; i<20; i++ ) { - PyDict_SetItemString( dict, ( std::string( "doors_" ) + std::to_string( i + 1 ) ).c_str(), PyGetFloatS( bDoors[ i ][ 0 ] ) ); - PyDict_SetItemString( dict, ( std::string( "doors_r_" ) + std::to_string( i + 1 ) ).c_str(), PyGetFloatS( bDoors[ i ][ 1 ] ) ); - PyDict_SetItemString( dict, ( std::string( "doors_l_" ) + std::to_string( i + 1 ) ).c_str(), PyGetFloatS( bDoors[ i ][ 2 ] ) ); - PyDict_SetItemString( dict, ( std::string( "doors_no_" ) + std::to_string( i + 1 ) ).c_str(), PyGetInt( iDoorNo[ i ] ) ); - PyDict_SetItemString( dict, ( std::string( "code_" ) + std::to_string( i + 1 ) ).c_str(), PyGetString( std::string( std::to_string( iUnits[ i ] ) + - cCode[ i ] ).c_str() ) ); - PyDict_SetItemString( dict, ( std::string( "car_name" ) + std::to_string( i + 1 ) ).c_str(), PyGetString( asCarName[ i ].c_str() ) ); + PyDict_SetItemString( dict, "brake_delay_flag", PyGetInt( mvControlled->BrakeDelayFlag )); + PyDict_SetItemString( dict, "brake_op_mode_flag", PyGetInt( mvControlled->BrakeOpModeFlag )); + // other controls + PyDict_SetItemString( dict, "ca", PyGetBool( TestFlag( mvOccupied->SecuritySystem.Status, s_aware ) ) ); + PyDict_SetItemString( dict, "shp", PyGetBool( TestFlag( mvOccupied->SecuritySystem.Status, s_active ) ) ); + PyDict_SetItemString( dict, "pantpress", PyGetFloat( mvControlled->PantPress ) ); + PyDict_SetItemString( dict, "universal3", PyGetBool( InstrumentLightActive ) ); + PyDict_SetItemString( dict, "radio_channel", PyGetInt( iRadioChannel ) ); + // movement data + PyDict_SetItemString( dict, "velocity", PyGetFloat( mover->Vel ) ); + PyDict_SetItemString( dict, "tractionforce", PyGetFloat( mover->Ft ) ); + PyDict_SetItemString( dict, "slipping_wheels", PyGetBool( mover->SlippingWheels ) ); + PyDict_SetItemString( dict, "sanding", PyGetBool( mover->SandDose ) ); + // electric current data + PyDict_SetItemString( dict, "traction_voltage", PyGetFloat( mover->RunningTraction.TractionVoltage ) ); + PyDict_SetItemString( dict, "voltage", PyGetFloat( mover->Voltage ) ); + PyDict_SetItemString( dict, "im", PyGetFloat( mover->Im ) ); + PyDict_SetItemString( dict, "fuse", PyGetBool( mover->FuseFlag ) ); + PyDict_SetItemString( dict, "epfuse", PyGetBool( mover->EpFuse ) ); + // induction motor state data + char const *TXTT[ 10 ] = { "fd", "fdt", "fdb", "pd", "pdt", "pdb", "itothv", "1", "2", "3" }; + char const *TXTC[ 10 ] = { "fr", "frt", "frb", "pr", "prt", "prb", "im", "vm", "ihv", "uhv" }; + char const *TXTP[ 3 ] = { "bc", "bp", "sp" }; + for( int j = 0; j < 10; ++j ) + PyDict_SetItemString( dict, ( std::string( "eimp_t_" ) + std::string( TXTT[ j ] ) ).c_str(), PyGetFloatS( fEIMParams[ 0 ][ j ] ) ); + for( int i = 0; i < 8; ++i ) { + for( int j = 0; j < 10; ++j ) + PyDict_SetItemString( dict, ( "eimp_c" + std::to_string( i + 1 ) + "_" + std::string( TXTC[ j ] ) ).c_str(), PyGetFloatS( fEIMParams[ i + 1 ][ j ] ) ); + + PyDict_SetItemString( dict, ( "eimp_c" + std::to_string( i + 1 ) + "_ms" ).c_str(), PyGetBool( bMains[ i ] ) ); + PyDict_SetItemString( dict, ( "eimp_c" + std::to_string( i + 1 ) + "_cv" ).c_str(), PyGetFloatS( fCntVol[ i ] ) ); + PyDict_SetItemString( dict, ( "eimp_u" + std::to_string( i + 1 ) + "_pf" ).c_str(), PyGetBool( bPants[ i ][ 0 ] ) ); + PyDict_SetItemString( dict, ( "eimp_u" + std::to_string( i + 1 ) + "_pr" ).c_str(), PyGetBool( bPants[ i ][ 1 ] ) ); + PyDict_SetItemString( dict, ( "eimp_c" + std::to_string( i + 1 ) + "_fuse" ).c_str(), PyGetBool( bFuse[ i ] ) ); + PyDict_SetItemString( dict, ( "eimp_c" + std::to_string( i + 1 ) + "_batt" ).c_str(), PyGetBool( bBatt[ i ] ) ); + PyDict_SetItemString( dict, ( "eimp_c" + std::to_string( i + 1 ) + "_conv" ).c_str(), PyGetBool( bConv[ i ] ) ); + PyDict_SetItemString( dict, ( "eimp_u" + std::to_string( i + 1 ) + "_comp_a" ).c_str(), PyGetBool( bComp[ i ][ 0 ] ) ); + PyDict_SetItemString( dict, ( "eimp_u" + std::to_string( i + 1 ) + "_comp_w" ).c_str(), PyGetBool( bComp[ i ][ 1 ] ) ); + PyDict_SetItemString( dict, ( "eimp_c" + std::to_string( i + 1 ) + "_heat" ).c_str(), PyGetBool( bHeat[ i ] ) ); + } + for( int i = 0; i < 20; ++i ) { + for( int j = 0; j < 3; ++j ) + PyDict_SetItemString( dict, ( "eimp_pn" + std::to_string( i + 1 ) + "_" + TXTP[ j ] ).c_str(), + PyGetFloatS( fPress[ i ][ j ] ) ); + } + // multi-unit state data PyDict_SetItemString( dict, "car_no", PyGetInt( iCarNo ) ); PyDict_SetItemString( dict, "power_no", PyGetInt( iPowerNo ) ); PyDict_SetItemString( dict, "unit_no", PyGetInt( iUnitNo ) ); - PyDict_SetItemString( dict, "universal3", PyGetBool( LampkaUniversal3_st ) ); - PyDict_SetItemString( dict, "ca", PyGetBool( TestFlag( mvOccupied->SecuritySystem.Status, s_aware ) ) ); - PyDict_SetItemString( dict, "shp", PyGetBool( TestFlag( mvOccupied->SecuritySystem.Status, s_active ) ) ); - PyDict_SetItemString( dict, "manual_brake", PyGetBool( mvOccupied->ManualBrakePos > 0 ) ); - PyDict_SetItemString( dict, "pantpress", PyGetFloat( mvControlled->PantPress ) ); - PyDict_SetItemString( dict, "trainnumber", PyGetString( DynamicObject->Mechanik->TrainName().c_str() ) ); - PyDict_SetItemString( dict, "velnext", PyGetFloat( DynamicObject->Mechanik->VelNext ) ); - PyDict_SetItemString( dict, "actualproximitydist", PyGetFloat( DynamicObject->Mechanik->ActualProximityDist ) ); - PyDict_SetItemString( dict, "velsignallast", PyGetFloat( DynamicObject->Mechanik->VelSignalLast ) ); - PyDict_SetItemString( dict, "vellimitlast", PyGetFloat( DynamicObject->Mechanik->VelLimitLast ) ); - PyDict_SetItemString( dict, "velroad", PyGetFloat( DynamicObject->Mechanik->VelRoad ) ); - PyDict_SetItemString( dict, "velsignalnext", PyGetFloat( DynamicObject->Mechanik->VelSignalNext ) ); - PyDict_SetItemString( dict, "battery", PyGetBool( mvControlled->Battery ) ); - PyDict_SetItemString( dict, "tractionforce", PyGetFloat( DynamicObject->MoverParameters->Ft ) ); + + for( int i = 0; i < 20; i++ ) { + PyDict_SetItemString( dict, ( "doors_" + std::to_string( i + 1 ) ).c_str(), PyGetBool( bDoors[ i ][ 0 ] ) ); + PyDict_SetItemString( dict, ( "doors_r_" + std::to_string( i + 1 ) ).c_str(), PyGetBool( bDoors[ i ][ 1 ] ) ); + PyDict_SetItemString( dict, ( "doors_l_" + std::to_string( i + 1 ) ).c_str(), PyGetBool( bDoors[ i ][ 2 ] ) ); + PyDict_SetItemString( dict, ( "doors_no_" + std::to_string( i + 1 ) ).c_str(), PyGetInt( iDoorNo[ i ] ) ); + PyDict_SetItemString( dict, ( "code_" + std::to_string( i + 1 ) ).c_str(), PyGetString( ( std::to_string( iUnits[ i ] ) + cCode[ i ] ).c_str() ) ); + PyDict_SetItemString( dict, ( "car_name" + std::to_string( i + 1 ) ).c_str(), PyGetString( asCarName[ i ].c_str() ) ); + PyDict_SetItemString( dict, ( "slip_" + std::to_string( i + 1 ) ).c_str(), PyGetBool( bSlip[ i ] ) ); + } + // ai state data + auto const *driver = DynamicObject->Mechanik; + + PyDict_SetItemString( dict, "velocity_desired", PyGetFloat( driver->VelDesired ) ); + PyDict_SetItemString( dict, "velroad", PyGetFloat( driver->VelRoad ) ); + PyDict_SetItemString( dict, "vellimitlast", PyGetFloat( driver->VelLimitLast ) ); + PyDict_SetItemString( dict, "velsignallast", PyGetFloat( driver->VelSignalLast ) ); + PyDict_SetItemString( dict, "velsignalnext", PyGetFloat( driver->VelSignalNext ) ); + PyDict_SetItemString( dict, "velnext", PyGetFloat( driver->VelNext ) ); + PyDict_SetItemString( dict, "actualproximitydist", PyGetFloat( driver->ActualProximityDist ) ); + // train data + PyDict_SetItemString( dict, "trainnumber", PyGetString( driver->TrainName().c_str() ) ); + PyDict_SetItemString( dict, "train_stationindex", PyGetInt( driver->StationIndex() ) ); + auto const stationcount { driver->StationCount() }; + PyDict_SetItemString( dict, "train_stationcount", PyGetInt( stationcount ) ); + if( stationcount > 0 ) { + // timetable stations data, if there's any + auto const *timetable { driver->TrainTimetable() }; + for( auto stationidx = 1; stationidx <= stationcount; ++stationidx ) { + auto const stationlabel { "train_station" + std::to_string( stationidx ) + "_" }; + auto const &timetableline { timetable->TimeTable[ stationidx ] }; + PyDict_SetItemString( dict, ( stationlabel + "name" ).c_str(), PyGetString( Bezogonkow( timetableline.StationName ).c_str() ) ); + PyDict_SetItemString( dict, ( stationlabel + "fclt" ).c_str(), PyGetString( Bezogonkow( timetableline.StationWare ).c_str() ) ); + PyDict_SetItemString( dict, ( stationlabel + "lctn" ).c_str(), PyGetFloat( timetableline.km ) ); + PyDict_SetItemString( dict, ( stationlabel + "vmax" ).c_str(), PyGetInt( timetableline.vmax ) ); + PyDict_SetItemString( dict, ( stationlabel + "ah" ).c_str(), PyGetInt( timetableline.Ah ) ); + PyDict_SetItemString( dict, ( stationlabel + "am" ).c_str(), PyGetInt( timetableline.Am ) ); + PyDict_SetItemString( dict, ( stationlabel + "dh" ).c_str(), PyGetInt( timetableline.Dh ) ); + PyDict_SetItemString( dict, ( stationlabel + "dm" ).c_str(), PyGetInt( timetableline.Dm ) ); + } + } + // world state data + PyDict_SetItemString( dict, "hours", PyGetInt( simulation::Time.data().wHour ) ); + PyDict_SetItemString( dict, "minutes", PyGetInt( simulation::Time.data().wMinute ) ); + PyDict_SetItemString( dict, "seconds", PyGetInt( simulation::Time.second() ) ); + PyDict_SetItemString( dict, "air_temperature", PyGetInt( Global.AirTemperature ) ); return dict; } -void TTrain::OnKeyDown(int cKey) -{ // naciśnięcie klawisza - bool isEztOer; - isEztOer = ((mvControlled->TrainType == dt_EZT) && (mvControlled->Battery == true) && - (mvControlled->EpFuse == true) && (mvOccupied->BrakeSubsystem == ss_ESt) && - (mvControlled->ActiveDir != 0)); // od yB - // isEztOer=(mvControlled->TrainType==dt_EZT)&&(mvControlled->Mains)&&(mvOccupied->BrakeSubsystem==ss_ESt)&&(mvControlled->ActiveDir!=0); - // isEztOer=((mvControlled->TrainType==dt_EZT)&&(mvControlled->Battery==true)&&(mvControlled->EpFuse==true)&&(mvOccupied->BrakeSubsystem==Oerlikon)&&(mvControlled->ActiveDir!=0)); +TTrain::state_t +TTrain::get_state() const { - if (GetAsyncKeyState(VK_SHIFT) < 0) - { // wciśnięty [Shift] - if (cKey == Global::Keys[k_IncMainCtrlFAST]) // McZapkie-200702: szybkie - // przelaczanie na poz. - // bezoporowa - { - if (mvControlled->IncMainCtrl(2)) - { - dsbNastawnikJazdy->SetCurrentPosition(0); - dsbNastawnikJazdy->Play(0, 0, 0); - } - } - else if (cKey == Global::Keys[k_DirectionBackward]) - { - if (mvOccupied->Radio == false) - if (GetAsyncKeyState(VK_CONTROL) >= 0) - { - dsbSwitch->SetVolume(DSBVOLUME_MAX); - dsbSwitch->Play(0, 0, 0); - mvOccupied->Radio = true; - } - } - else if (cKey == Global::Keys[k_DecMainCtrlFAST]) - if (mvControlled->DecMainCtrl(2)) - { - dsbNastawnikJazdy->SetCurrentPosition(0); - dsbNastawnikJazdy->Play(0, 0, 0); - } - else - ; - else if (cKey == Global::Keys[k_IncScndCtrlFAST]) - if (mvControlled->IncScndCtrl(2)) - { - if (dsbNastawnikBocz) // hunter-081211 - { - dsbNastawnikBocz->SetCurrentPosition(0); - dsbNastawnikBocz->Play(0, 0, 0); - } - else if (!dsbNastawnikBocz) - { - dsbNastawnikJazdy->SetCurrentPosition(0); - dsbNastawnikJazdy->Play(0, 0, 0); - } - } - else - ; - else if (cKey == Global::Keys[k_DecScndCtrlFAST]) - if (mvControlled->DecScndCtrl(2)) - { - if (dsbNastawnikBocz) // hunter-081211 - { - dsbNastawnikBocz->SetCurrentPosition(0); - dsbNastawnikBocz->Play(0, 0, 0); - } - else if (!dsbNastawnikBocz) - { - dsbNastawnikJazdy->SetCurrentPosition(0); - dsbNastawnikJazdy->Play(0, 0, 0); - } - } - else - ; - else if (cKey == Global::Keys[k_IncLocalBrakeLevelFAST]) - if (mvOccupied->IncLocalBrakeLevel(2)) - ; - else - ; - else if (cKey == Global::Keys[k_DecLocalBrakeLevelFAST]) - if (mvOccupied->DecLocalBrakeLevel(2)) - ; - else - ; - // McZapkie-240302 - wlaczanie glownego obwodu klawiszem M+shift - //----------- - // hunter-141211: wyl. szybki zalaczony przeniesiony do TTrain::Update() - /* if (cKey==Global::Keys[k_Main]) - { - ggMainOnButton.PutValue(1); - if (mvControlled->MainSwitch(true)) - { - if (mvControlled->EngineType==DieselEngine) - dsbDieselIgnition->Play(0,0,0); - else - dsbNastawnikJazdy->Play(0,0,0); - } - } - else */ - if (cKey == Global::Keys[k_Battery]) - { - // if - // (((mvControlled->TrainType==dt_EZT)||(mvControlled->EngineType==ElectricSeriesMotor)||(mvControlled->EngineType==DieselElectric))&&(!mvControlled->Battery)) - if (!mvControlled->Battery) - { // wyłącznik jest też w SN61, ewentualnie - // załączać prąd na stałe z poziomu FIZ - if (mvOccupied->BatterySwitch(true)) // bateria potrzebna np. do zapalenia świateł - { - dsbSwitch->Play(0, 0, 0); - if (ggBatteryButton.SubModel) - { - ggBatteryButton.PutValue(1); - } - if (mvOccupied->LightsPosNo > 0) - { - SetLights(); - } - if (TestFlag(mvOccupied->SecuritySystem.SystemType, - 2)) // Ra: znowu w kabinie jest coś, co być nie powinno! - { - SetFlag(mvOccupied->SecuritySystem.Status, s_active); - SetFlag(mvOccupied->SecuritySystem.Status, s_SHPalarm); - } - } - } - } - else if (cKey == Global::Keys[k_StLinOff]) - { - if (mvControlled->TrainType == dt_EZT) - { - if ((mvControlled->Signalling == false)) - { - dsbSwitch->Play(0, 0, 0); - mvControlled->Signalling = true; - } - } - } - else if (cKey == Global::Keys[k_Sand]) - { - if (mvControlled->TrainType == dt_EZT) - { - if (ggDoorSignallingButton.SubModel != NULL) - { - if (!mvControlled->DoorSignalling) - { - mvOccupied->DoorBlocked = true; - dsbSwitch->Play(0, 0, 0); - mvControlled->DoorSignalling = true; - } - } - } - else if (mvControlled->TrainType != dt_EZT) - { - if (ggSandButton.SubModel != NULL) - { - ggSandButton.PutValue(1); - // dsbPneumaticRelay->SetVolume(-80); - // dsbPneumaticRelay->Play(0, 0, 0); - } - } - } - if (cKey == Global::Keys[k_Main]) - { - if (fabs(ggMainOnButton.GetValue()) < 0.001) - if (dsbSwitch) - { - dsbSwitch->SetVolume(DSBVOLUME_MAX); - dsbSwitch->Play(0, 0, 0); - } - } - else if (cKey == Global::Keys[k_BrakeProfile]) // McZapkie-240302-B: - //----------- + return { + btLampkaSHP.GetValue(), + btLampkaCzuwaka.GetValue(), + btLampkaRadioStop.GetValue(), + btLampkaOpory.GetValue(), + btLampkaWylSzybki.GetValue(), + btLampkaNadmSil.GetValue(), + btLampkaStyczn.GetValue(), + btLampkaPoslizg.GetValue(), + btLampkaNadmPrzetw.GetValue(), + btLampkaPrzetwOff.GetValue(), + btLampkaNadmSpr.GetValue(), + btLampkaNadmWent.GetValue(), + btLampkaWysRozr.GetValue(), + btLampkaOgrzewanieSkladu.GetValue(), + btHaslerBrakes.GetValue(), + btHaslerCurrent.GetValue(), + ( TestFlag( mvOccupied->SecuritySystem.Status, s_CAalarm ) || TestFlag( mvOccupied->SecuritySystem.Status, s_SHPalarm ) ), + btLampkaHVoltageB.GetValue(), + fTachoVelocity, + static_cast( mvOccupied->Compressor ), + static_cast( mvOccupied->PipePress ), + static_cast( mvOccupied->BrakePress ), + fHVoltage, + { fHCurrent[ ( mvControlled->TrainType & dt_EZT ) ? 0 : 1 ], fHCurrent[ 2 ], fHCurrent[ 3 ] } + }; +} - // przelacznik opoznienia - // hamowania - { // yB://ABu: male poprawki, zeby bylo mozna ustawic dowolny wagon - int CouplNr = -2; - if (!FreeFlyModeFlag) - { - if (GetAsyncKeyState(VK_CONTROL) < 0) - if (mvOccupied->BrakeDelaySwitch(bdelay_R + bdelay_M)) - { - dsbPneumaticRelay->SetVolume(DSBVOLUME_MAX); - dsbPneumaticRelay->Play(0, 0, 0); - } - else - ; - else if (mvOccupied->BrakeDelaySwitch(bdelay_P)) - { - dsbPneumaticRelay->SetVolume(DSBVOLUME_MAX); - dsbPneumaticRelay->Play(0, 0, 0); - } - } - else - { - TDynamicObject *temp; - temp = (DynamicObject->ABuScanNearestObject(DynamicObject->GetTrack(), -1, 1500, - CouplNr)); - if (temp == NULL) - { - CouplNr = -2; - temp = (DynamicObject->ABuScanNearestObject(DynamicObject->GetTrack(), 1, 1500, - CouplNr)); - } - if (temp) - { - if (GetAsyncKeyState(VK_CONTROL) < 0) - if (temp->MoverParameters->BrakeDelaySwitch(bdelay_R + bdelay_M)) - { - dsbPneumaticRelay->SetVolume(DSBVOLUME_MAX); - dsbPneumaticRelay->Play(0, 0, 0); - } - else - ; - else if (temp->MoverParameters->BrakeDelaySwitch(bdelay_P)) - { - dsbPneumaticRelay->SetVolume(DSBVOLUME_MAX); - dsbPneumaticRelay->Play(0, 0, 0); - } - } - } - } - //----------- - // hunter-261211: przetwornica i sprzezarka przeniesione do - // TTrain::Update() - /* if (cKey==Global::Keys[k_Converter]) //NBMX 14-09-2003: -przetwornica wl - { -if ((mvControlled->PantFrontVolt) || (mvControlled->PantRearVolt) || -(mvControlled->EnginePowerSource.SourceType!=CurrentCollector) || -(!Global::bLiveTraction)) - if (mvControlled->ConverterSwitch(true)) - { - dsbSwitch->SetVolume(DSBVOLUME_MAX); - dsbSwitch->Play(0,0,0); - } - } - else - if (cKey==Global::Keys[k_Compressor]) //NBMX 14-09-2003: sprezarka wl - { - if ((mvControlled->ConverterFlag) || -(mvControlled->CompressorPower<2)) - if (mvControlled->CompressorSwitch(true)) - { - dsbSwitch->SetVolume(DSBVOLUME_MAX); - dsbSwitch->Play(0,0,0); - } - } - else */ +bool TTrain::is_eztoer() const { - else if (cKey == Global::Keys[k_Converter]) - { - if (ggConverterButton.GetValue() == 0) - { - dsbSwitch->SetVolume(DSBVOLUME_MAX); - dsbSwitch->Play(0, 0, 0); - } - } - else if ((cKey == Global::Keys[k_Compressor]) && - (mvControlled->CompressorPower < 2)) // hunter-091012: tak jest poprawnie - // if - // ((cKey==Global::Keys[k_Compressor])&&((mvControlled->EngineType==ElectricSeriesMotor)||(mvControlled->TrainType==dt_EZT))) - // //hunter-110212: poprawka dla EZT + return + ( ( mvControlled->TrainType == dt_EZT ) + && ( mvOccupied->BrakeSubsystem == TBrakeSubSystem::ss_ESt ) + && ( mvControlled->Battery == true ) + && ( mvControlled->EpFuse == true ) + && ( mvControlled->ActiveDir != 0 ) ); // od yB +} - { - if (ggCompressorButton.GetValue() == 0) - { - dsbSwitch->SetVolume(DSBVOLUME_MAX); - dsbSwitch->Play(0, 0, 0); - } - } - else if (cKey == Global::Keys[k_SmallCompressor]) // Winger 160404: mala - // sprezarka wl - { // Ra: dźwięk, gdy razem z [Shift] - if ((mvControlled->TrainType & dt_EZT) ? mvControlled == mvOccupied : - !mvOccupied->ActiveCab) // tylko w maszynowym - if (Console::Pressed(VK_CONTROL)) // z [Ctrl] - mvControlled->bPantKurek3 = true; // zbiornik pantografu połączony - // jest ze zbiornikiem głównym - // (pompowanie nie ma sensu) - else if (!mvControlled->PantCompFlag) // jeśli wyłączona - if (mvControlled->Battery) // jeszcze musi być załączona bateria - if (mvControlled->PantPress < 4.8) // piszą, że to tak nie działa - { - mvControlled->PantCompFlag = true; - dsbSwitch->SetVolume(DSBVOLUME_MAX); - dsbSwitch->Play(0, 0, 0); // dźwięk tylko po naciśnięciu klawisza - } - } - else if (cKey == VkKeyScan('q')) // ze Shiftem - włączenie AI - { // McZapkie-240302 - wlaczanie automatycznego pilota (zadziala tylko w - // trybie debugmode) - if (DynamicObject->Mechanik) - { - if (DebugModeFlag) - if (DynamicObject->Mechanik->AIControllFlag) //żeby nie trzeba było - // rozłączać dla - // zresetowania - DynamicObject->Mechanik->TakeControl(false); - DynamicObject->Mechanik->TakeControl(true); - } - } - else if (cKey == Global::Keys[k_MaxCurrent]) // McZapkie-160502: F - - // wysoki rozruch - { - if ((mvControlled->EngineType == DieselElectric) && (mvControlled->ShuntModeAllow) && - (mvControlled->MainCtrlPos == 0)) - { - mvControlled->ShuntMode = true; - } - if (mvControlled->CurrentSwitch(true)) - { - dsbSwitch->SetVolume(DSBVOLUME_MAX); - dsbSwitch->Play(0, 0, 0); - } - /* Ra: przeniesione do Mover.cpp - if (mvControlled->TrainType!=dt_EZT) //to powinno być w fizyce, a - nie w kabinie! - if (mvControlled->MinCurrentSwitch(true)) - { - dsbSwitch->SetVolume(DSBVOLUME_MAX); - dsbSwitch->Play(0,0,0); - } - */ - } - else if (cKey == Global::Keys[k_CurrentAutoRelay]) // McZapkie-241002: G - - // wlaczanie PSR - { - if (mvControlled->AutoRelaySwitch(true)) - { - dsbSwitch->SetVolume(DSBVOLUME_MAX); - dsbSwitch->Play(0, 0, 0); - } - } - else if (cKey == Global::Keys[k_FailedEngineCutOff]) // McZapkie-060103: E - // - wylaczanie - // sekcji silnikow - { - if (mvControlled->CutOffEngine()) - { - dsbSwitch->SetVolume(DSBVOLUME_MAX); - dsbSwitch->Play(0, 0, 0); - } - } - else if (cKey == Global::Keys[k_OpenLeft]) // NBMX 17-09-2003: otwieranie drzwi - { - if (mvOccupied->DoorOpenCtrl == 1) - if (mvOccupied->CabNo < 0 ? mvOccupied->DoorRight(true) : mvOccupied->DoorLeft(true)) - { - dsbSwitch->SetVolume(DSBVOLUME_MAX); - dsbSwitch->Play(0, 0, 0); - if (dsbDoorOpen) - { - dsbDoorOpen->SetCurrentPosition(0); - dsbDoorOpen->Play(0, 0, 0); - } - } - } - else if (cKey == Global::Keys[k_OpenRight]) // NBMX 17-09-2003: otwieranie drzwi - { - if (mvOccupied->DoorOpenCtrl == 1) - if (mvOccupied->CabNo < 0 ? mvOccupied->DoorLeft(true) : mvOccupied->DoorRight(true)) - { - dsbSwitch->SetVolume(DSBVOLUME_MAX); - dsbSwitch->Play(0, 0, 0); - if (dsbDoorOpen) - { - dsbDoorOpen->SetCurrentPosition(0); - dsbDoorOpen->Play(0, 0, 0); - } - } - } - //----------- - // hunter-131211: dzwiek dla przelacznika universala podniesionego - // hunter-091012: ubajerowanie swiatla w kabinie (wyrzucenie - // przyciemnienia pod Univ4) - else if (cKey == Global::Keys[k_Univ3]) - { - if (Console::Pressed(VK_CONTROL)) - { - if (bCabLight == false) //(ggCabLightButton.GetValue()==0) - { - dsbSwitch->SetVolume(DSBVOLUME_MAX); - dsbSwitch->Play(0, 0, 0); - } - } - else - { - if (ggUniversal3Button.GetValue() == 0) - { - dsbSwitch->SetVolume(DSBVOLUME_MAX); - dsbSwitch->Play(0, 0, 0); - } - /* - if (Console::Pressed(VK_CONTROL)) - {//z [Ctrl] zapalamy albo gasimy światełko w kabinie - if (iCabLightFlag<2) ++iCabLightFlag; //zapalenie - } - */ - } - } +// mover master controller to specified position +void TTrain::set_master_controller( double const Position ) { - //----------- - // hunter-091012: dzwiek dla przyciemnienia swiatelka w kabinie - else if (cKey == Global::Keys[k_Univ4]) - { - if (Console::Pressed(VK_CONTROL)) - { - if (bCabLightDim == false) //(ggCabLightDimButton.GetValue()==0) - { - dsbSwitch->SetVolume(DSBVOLUME_MAX); - dsbSwitch->Play(0, 0, 0); - } - } - } - - //----------- - else if (cKey == Global::Keys[k_PantFrontUp]) - { // Winger 160204: podn. - // przedn. pantografu - if (mvOccupied->ActiveCab == - 1) //||((mvOccupied->ActiveCab<1)&&((mvControlled->TrainType&(dt_ET40|dt_ET41|dt_ET42|dt_EZT))==0))) - { // przedni gdy w kabinie 1 lub (z wyjątkiem ET40, ET41, ET42 i EZT) gdy - // w kabinie -1 - mvControlled->PantFrontSP = false; - if (mvControlled->PantFront(true)) - if (mvControlled->PantFrontStart != 1) - { - dsbSwitch->SetVolume(DSBVOLUME_MAX); - dsbSwitch->Play(0, 0, 0); - } - } - else - // if - // ((mvOccupied->ActiveCab<1)&&(mvControlled->TrainType&(dt_ET40|dt_ET41|dt_ET42|dt_EZT))) - { // w kabinie -1 dla ET40, ET41, ET42 i EZT - mvControlled->PantRearSP = false; - if (mvControlled->PantRear(true)) - if (mvControlled->PantRearStart != 1) - { - dsbSwitch->SetVolume(DSBVOLUME_MAX); - dsbSwitch->Play(0, 0, 0); - } - } - } - else if (cKey == Global::Keys[k_PantRearUp]) - { // Winger 160204: podn. - // tyln. pantografu - // względem kierunku jazdy - if (mvOccupied->ActiveCab == - 1) //||((mvOccupied->ActiveCab<1)&&((mvControlled->TrainType&(dt_ET40|dt_ET41|dt_ET42|dt_EZT))==0))) - { // tylny gdy w kabinie 1 lub (z wyjątkiem ET40, ET41, ET42 i EZT) gdy w - // kabinie -1 - mvControlled->PantRearSP = false; - if (mvControlled->PantRear(true)) - if (mvControlled->PantRearStart != 1) - { - dsbSwitch->SetVolume(DSBVOLUME_MAX); - dsbSwitch->Play(0, 0, 0); - } - } - else - // if - // ((mvOccupied->ActiveCab<1)&&(mvControlled->TrainType&(dt_ET40|dt_ET41|dt_ET42|dt_EZT))) - { // przedni w kabinie -1 dla ET40, ET41, ET42 i EZT - mvControlled->PantFrontSP = false; - if (mvControlled->PantFront(true)) - if (mvControlled->PantFrontStart != 1) - { - dsbSwitch->SetVolume(DSBVOLUME_MAX); - dsbSwitch->Play(0, 0, 0); - } - } - } - else if (cKey == Global::Keys[k_Active]) // yB 300407: przelacznik rozrzadu - { // Ra 2014-06: uruchomiłem to, aby aktywować czuwak w zajmowanym członie, - // a wyłączyć w innych - // Ra 2014-03: aktywacja czuwaka przepięta na ustawienie kierunku w - // mvOccupied - // if (mvControlled->Battery) //jeśli bateria jest już załączona - // mvOccupied->BatterySwitch(true); //to w ten oto durny sposób aktywuje - // się CA/SHP - // if (mvControlled->CabActivisation()) - // { - // dsbSwitch->SetVolume(DSBVOLUME_MAX); - // dsbSwitch->Play(0,0,0); - // } - } - else if (cKey == Global::Keys[k_Heating]) // Winger 020304: ogrzewanie - // skladu - wlaczenie - { // Ra 2014-09: w trybie latania obsługa jest w World.cpp - if (!FreeFlyModeFlag) - { - if ((mvControlled->Heating == false) && - ((mvControlled->EngineType == ElectricSeriesMotor) && - (mvControlled->Mains == true) || - (mvControlled->ConverterFlag))) - { - mvControlled->Heating = true; - dsbSwitch->SetVolume(DSBVOLUME_MAX); - dsbSwitch->Play(0, 0, 0); - } - } - } - else if (cKey == Global::Keys[k_LeftSign]) // lewe swiatlo - włączenie - // ABu 060205: dzielo Wingera po malutkim liftingu: - { - if (false == (mvOccupied->LightsPosNo > 0)) - { - if ((GetAsyncKeyState(VK_CONTROL) < 0) && - (ggRearLeftLightButton.SubModel)) // hunter-230112 - z controlem zapala z tylu - { - //------------------------------ - if (mvOccupied->ActiveCab == 1) - { // kabina 1 - if (((DynamicObject->iLights[1]) & 3) == 0) - { - DynamicObject->iLights[1] |= 1; - dsbSwitch->SetVolume(DSBVOLUME_MAX); - dsbSwitch->Play(0, 0, 0); - ggRearLeftLightButton.PutValue(1); - } - if (((DynamicObject->iLights[1]) & 3) == 2) - { - DynamicObject->iLights[1] &= (255 - 2); - dsbSwitch->SetVolume(DSBVOLUME_MAX); - dsbSwitch->Play(0, 0, 0); - if (ggRearLeftEndLightButton.SubModel) - { - ggRearLeftEndLightButton.PutValue(0); - ggRearLeftLightButton.PutValue(0); - } - else - ggRearLeftLightButton.PutValue(0); - } - } - else - { // kabina -1 - if (((DynamicObject->iLights[0]) & 3) == 0) - { - DynamicObject->iLights[0] |= 1; - dsbSwitch->SetVolume(DSBVOLUME_MAX); - dsbSwitch->Play(0, 0, 0); - ggRearLeftLightButton.PutValue(1); - } - if (((DynamicObject->iLights[0]) & 3) == 2) - { - DynamicObject->iLights[0] &= (255 - 2); - dsbSwitch->SetVolume(DSBVOLUME_MAX); - dsbSwitch->Play(0, 0, 0); - if (ggRearLeftEndLightButton.SubModel) - { - ggRearLeftEndLightButton.PutValue(0); - ggRearLeftLightButton.PutValue(0); - } - else - ggRearLeftLightButton.PutValue(0); - } - } - //---------------------- - } - else - { - if (mvOccupied->ActiveCab == 1) - { // kabina 1 - if (((DynamicObject->iLights[0]) & 3) == 0) - { - DynamicObject->iLights[0] |= 1; - dsbSwitch->SetVolume(DSBVOLUME_MAX); - dsbSwitch->Play(0, 0, 0); - ggLeftLightButton.PutValue(1); - } - if (((DynamicObject->iLights[0]) & 3) == 2) - { - DynamicObject->iLights[0] &= (255 - 2); - dsbSwitch->SetVolume(DSBVOLUME_MAX); - dsbSwitch->Play(0, 0, 0); - if (ggLeftEndLightButton.SubModel) - { - ggLeftEndLightButton.PutValue(0); - ggLeftLightButton.PutValue(0); - } - else - ggLeftLightButton.PutValue(0); - } - } - else - { // kabina -1 - if (((DynamicObject->iLights[1]) & 3) == 0) - { - DynamicObject->iLights[1] |= 1; - dsbSwitch->SetVolume(DSBVOLUME_MAX); - dsbSwitch->Play(0, 0, 0); - ggLeftLightButton.PutValue(1); - } - if (((DynamicObject->iLights[1]) & 3) == 2) - { - DynamicObject->iLights[1] &= (255 - 2); - dsbSwitch->SetVolume(DSBVOLUME_MAX); - dsbSwitch->Play(0, 0, 0); - if (ggLeftEndLightButton.SubModel) - { - ggLeftEndLightButton.PutValue(0); - ggLeftLightButton.PutValue(0); - } - else - ggLeftLightButton.PutValue(0); - } - } - } //----------- - } - } - else if (cKey == Global::Keys[k_UpperSign]) // ABu 060205: światło górne - - // włączenie - { - if (mvOccupied->LightsPosNo > 0) //kręciolek od swiatel - { - if ((mvOccupied->LightsPos < mvOccupied->LightsPosNo) || (mvOccupied->LightsWrap)) - { - mvOccupied->LightsPos++; - if (mvOccupied->LightsPos > mvOccupied->LightsPosNo) - { - mvOccupied->LightsPos = 1; - } - dsbSwitch->SetVolume(DSBVOLUME_MAX); - dsbSwitch->Play(0, 0, 0); - SetLights(); - } - } - else if ((GetAsyncKeyState(VK_CONTROL) < 0) && - (ggRearUpperLightButton.SubModel)) // hunter-230112 - z controlem zapala z tylu - { - //------------------------------ - if ((mvOccupied->ActiveCab) == 1) - { // kabina 1 - if (((DynamicObject->iLights[1]) & 12) == 0) - { - DynamicObject->iLights[1] |= 4; - dsbSwitch->SetVolume(DSBVOLUME_MAX); - dsbSwitch->Play(0, 0, 0); - ggRearUpperLightButton.PutValue(1); - } - } - else - { // kabina -1 - if (((DynamicObject->iLights[0]) & 12) == 0) - { - DynamicObject->iLights[0] |= 4; - dsbSwitch->SetVolume(DSBVOLUME_MAX); - dsbSwitch->Play(0, 0, 0); - ggRearUpperLightButton.PutValue(1); - } - } - } //------------------------------ - else - { - if ((mvOccupied->ActiveCab) == 1) - { // kabina 1 - if (((DynamicObject->iLights[0]) & 12) == 0) - { - DynamicObject->iLights[0] |= 4; - dsbSwitch->SetVolume(DSBVOLUME_MAX); - dsbSwitch->Play(0, 0, 0); - ggUpperLightButton.PutValue(1); - } - } - else - { // kabina -1 - if (((DynamicObject->iLights[1]) & 12) == 0) - { - DynamicObject->iLights[1] |= 4; - dsbSwitch->SetVolume(DSBVOLUME_MAX); - dsbSwitch->Play(0, 0, 0); - ggUpperLightButton.PutValue(1); - } - } - } - } - else if (cKey == Global::Keys[k_RightSign]) // Winger 070304: swiatla - // tylne (koncowki) - - // wlaczenie - { - if (false == (mvOccupied->LightsPosNo > 0)) - { - if ((GetAsyncKeyState(VK_CONTROL) < 0) && - (ggRearRightLightButton.SubModel)) // hunter-230112 - z controlem zapala z tylu - { - //------------------------------ - if (mvOccupied->ActiveCab == 1) - { // kabina 1 - if (((DynamicObject->iLights[1]) & 48) == 0) - { - DynamicObject->iLights[1] |= 16; - dsbSwitch->SetVolume(DSBVOLUME_MAX); - dsbSwitch->Play(0, 0, 0); - ggRearRightLightButton.PutValue(1); - } - if (((DynamicObject->iLights[1]) & 48) == 32) - { - DynamicObject->iLights[1] &= (255 - 32); - dsbSwitch->SetVolume(DSBVOLUME_MAX); - dsbSwitch->Play(0, 0, 0); - if (ggRearRightEndLightButton.SubModel) - { - ggRearRightEndLightButton.PutValue(0); - ggRearRightLightButton.PutValue(0); - } - else - ggRearRightLightButton.PutValue(0); - } - } - else - { // kabina -1 - if (((DynamicObject->iLights[0]) & 48) == 0) - { - DynamicObject->iLights[0] |= 16; - dsbSwitch->SetVolume(DSBVOLUME_MAX); - dsbSwitch->Play(0, 0, 0); - ggRearRightLightButton.PutValue(1); - } - if (((DynamicObject->iLights[0]) & 48) == 32) - { - DynamicObject->iLights[0] &= (255 - 32); - dsbSwitch->SetVolume(DSBVOLUME_MAX); - dsbSwitch->Play(0, 0, 0); - if (ggRearRightEndLightButton.SubModel) - { - ggRearRightEndLightButton.PutValue(0); - ggRearRightLightButton.PutValue(0); - } - else - ggRearRightLightButton.PutValue(0); - } - } - } //------------------------------ - else - { - if (mvOccupied->ActiveCab == 1) - { // kabina 1 - if (((DynamicObject->iLights[0]) & 48) == 0) - { - DynamicObject->iLights[0] |= 16; - dsbSwitch->SetVolume(DSBVOLUME_MAX); - dsbSwitch->Play(0, 0, 0); - ggRightLightButton.PutValue(1); - } - if (((DynamicObject->iLights[0]) & 48) == 32) - { - DynamicObject->iLights[0] &= (255 - 32); - dsbSwitch->SetVolume(DSBVOLUME_MAX); - dsbSwitch->Play(0, 0, 0); - if (ggRightEndLightButton.SubModel) - { - ggRightEndLightButton.PutValue(0); - ggRightLightButton.PutValue(0); - } - else - ggRightLightButton.PutValue(0); - } - } - else - { // kabina -1 - if (((DynamicObject->iLights[1]) & 48) == 0) - { - DynamicObject->iLights[1] |= 16; - dsbSwitch->SetVolume(DSBVOLUME_MAX); - dsbSwitch->Play(0, 0, 0); - ggRightLightButton.PutValue(1); - } - if (((DynamicObject->iLights[1]) & 48) == 32) - { - DynamicObject->iLights[1] &= (255 - 32); - dsbSwitch->SetVolume(DSBVOLUME_MAX); - dsbSwitch->Play(0, 0, 0); - if (ggRightEndLightButton.SubModel) - { - ggRightEndLightButton.PutValue(0); - ggRightLightButton.PutValue(0); - } - else - ggRightLightButton.PutValue(0); - } - } - } - } - } + auto positionchange { + std::min( + Position, + ( mvControlled->CoupledCtrl ? + mvControlled->MainCtrlPosNo + mvControlled->ScndCtrlPosNo : + mvControlled->MainCtrlPosNo ) ) + - ( mvControlled->CoupledCtrl ? + mvControlled->MainCtrlPos + mvControlled->ScndCtrlPos : + mvControlled->MainCtrlPos ) }; + while( ( positionchange < 0 ) + && ( true == mvControlled->DecMainCtrl( 1 ) ) ) { + ++positionchange; } - else // McZapkie-240302 - klawisze bez shifta - { - if (cKey == Global::Keys[k_IncMainCtrl]) - { - if (mvControlled->IncMainCtrl(1)) - { - dsbNastawnikJazdy->SetCurrentPosition(0); - dsbNastawnikJazdy->Play(0, 0, 0); - } - } - else if (cKey == Global::Keys[k_DecMainCtrl]) - if (mvControlled->DecMainCtrl(1)) - { - dsbNastawnikJazdy->SetCurrentPosition(0); - dsbNastawnikJazdy->Play(0, 0, 0); - } - else - ; - else if (cKey == Global::Keys[k_IncScndCtrl]) - // if (MoverParameters->ScndCtrlPosScndCtrlPosNo) - // if - // (mvControlled->EnginePowerSource.SourceType==CurrentCollector) - if (mvControlled->ShuntMode) - { - mvControlled->AnPos += (GetDeltaTime() / 0.85f); - if (mvControlled->AnPos > 1) - mvControlled->AnPos = 1; - } - else if (mvControlled->IncScndCtrl(1)) - { - if (dsbNastawnikBocz) // hunter-081211 - { - dsbNastawnikBocz->SetCurrentPosition(0); - dsbNastawnikBocz->Play(0, 0, 0); - } - else if (!dsbNastawnikBocz) - { - dsbNastawnikJazdy->SetCurrentPosition(0); - dsbNastawnikJazdy->Play(0, 0, 0); - } - } - else - ; - else if (cKey == Global::Keys[k_DecScndCtrl]) - // if (mvControlled->EnginePowerSource.SourceType==CurrentCollector) - if (mvControlled->ShuntMode) - { - mvControlled->AnPos -= (GetDeltaTime() / 0.55f); - if (mvControlled->AnPos < 0) - mvControlled->AnPos = 0; - } - else + while( ( positionchange > 0 ) + && ( true == mvControlled->IncMainCtrl( 1 ) ) ) { + --positionchange; + } +} - if (mvControlled->DecScndCtrl(1)) - // if (MoverParameters->ScndCtrlPos>0) - { - if (dsbNastawnikBocz) // hunter-081211 - { - dsbNastawnikBocz->SetCurrentPosition(0); - dsbNastawnikBocz->Play(0, 0, 0); - } - else if (!dsbNastawnikBocz) - { - dsbNastawnikJazdy->SetCurrentPosition(0); - dsbNastawnikJazdy->Play(0, 0, 0); - } - } - else - ; - else if (cKey == Global::Keys[k_IncLocalBrakeLevel]) - { // Ra 2014-09: w - // trybie latania - // obsługa jest w - // World.cpp - if (!FreeFlyModeFlag) - { - if (GetAsyncKeyState(VK_CONTROL) < 0) - if ((mvOccupied->LocalBrake == ManualBrake) || (mvOccupied->MBrake == true)) - { - mvOccupied->IncManualBrakeLevel(1); - } - else - ; - else if (mvOccupied->LocalBrake != ManualBrake) - mvOccupied->IncLocalBrakeLevel(1); - } - } - else if (cKey == Global::Keys[k_DecLocalBrakeLevel]) - { // Ra 2014-06: wersja dla - // swobodnego latania - // przeniesiona do - // World.cpp - if (!FreeFlyModeFlag) - { - if (GetAsyncKeyState(VK_CONTROL) < 0) - if ((mvOccupied->LocalBrake == ManualBrake) || (mvOccupied->MBrake == true)) - mvOccupied->DecManualBrakeLevel(1); - else - ; - else // Ra 1014-06: AI potrafi zahamować pomocniczym mimo jego braku - - // odhamować jakoś trzeba - if ((mvOccupied->LocalBrake != ManualBrake) || mvOccupied->LocalBrakePos) - mvOccupied->DecLocalBrakeLevel(1); - } - } - else if ((cKey == Global::Keys[k_IncBrakeLevel]) && (mvOccupied->BrakeHandle != FV4a)) - // if (mvOccupied->IncBrakeLevel()) - if (mvOccupied->BrakeLevelAdd(Global::fBrakeStep)) // nieodpowiedni - // warunek; true, jeśli - // można dalej kręcić - { - keybrakecount = 0; - if ((isEztOer) && (mvOccupied->BrakeCtrlPos < 3)) - { // Ra: uzależnić dźwięk od zmiany stanu EP, nie od klawisza - dsbPneumaticSwitch->SetVolume(-10); - dsbPneumaticSwitch->Play(0, 0, 0); - } - } - else - ; - else if ((cKey == Global::Keys[k_DecBrakeLevel]) && (mvOccupied->BrakeHandle != FV4a)) - { - // nową wersję dostarczył ZiomalCl ("fixed looped sound in ezt when using - // NUM_9 key") - if ((mvOccupied->BrakeCtrlPos > -1) || (keybrakecount > 1)) - { +// moves train brake lever to specified position, potentially emits switch sound if conditions are met +void TTrain::set_train_brake( double const Position ) { - if ((isEztOer) && (mvControlled->Mains) && (mvOccupied->BrakeCtrlPos != -1)) - { // Ra: uzależnić dźwięk od zmiany stanu EP, nie od klawisza - dsbPneumaticSwitch->SetVolume(-10); - dsbPneumaticSwitch->Play(0, 0, 0); - } - // mvOccupied->DecBrakeLevel(); - mvOccupied->BrakeLevelAdd(-Global::fBrakeStep); - } - else - keybrakecount += 1; - // koniec wersji dostarczonej przez ZiomalCl - /* wersja poprzednia - ten pierwszy if ze średnikiem nie działał jak - warunek - if ((mvOccupied->BrakeCtrlPos>-1)|| (keybrakecount>1)) - { - if (mvOccupied->DecBrakeLevel()); - { - if ((isEztOer) && - (mvOccupied->BrakeCtrlPos<2)&&(keybrakecount<=1)) - { - dsbPneumaticSwitch->SetVolume(-10); - dsbPneumaticSwitch->Play(0,0,0); - } - } - } - else keybrakecount+=1; - */ - } - else if (cKey == Global::Keys[k_EmergencyBrake]) - { - // while (mvOccupied->IncBrakeLevel()); - mvOccupied->BrakeLevelSet(mvOccupied->Handle->GetPos(bh_EB)); - if (mvOccupied->BrakeCtrlPosNo <= 0.1) // hamulec bezpieczeństwa dla wagonów - mvOccupied->EmergencyBrakeFlag = true; - } - else if (cKey == Global::Keys[k_Brake3]) - { - if ((isEztOer) && ((mvOccupied->BrakeCtrlPos == 1) || (mvOccupied->BrakeCtrlPos == -1))) - { - dsbPneumaticSwitch->SetVolume(-10); - dsbPneumaticSwitch->Play(0, 0, 0); - } - // while (mvOccupied->BrakeCtrlPos>mvOccupied->BrakeCtrlPosNo-1 && - // mvOccupied->DecBrakeLevel()); - // while (mvOccupied->BrakeCtrlPosBrakeCtrlPosNo-1 && - // mvOccupied->IncBrakeLevel()); - mvOccupied->BrakeLevelSet(mvOccupied->BrakeCtrlPosNo - 1); - } - else if (cKey == Global::Keys[k_Brake2]) - { - if ((isEztOer) && ((mvOccupied->BrakeCtrlPos == 1) || (mvOccupied->BrakeCtrlPos == -1))) - { - dsbPneumaticSwitch->SetVolume(-10); - dsbPneumaticSwitch->Play(0, 0, 0); - } - // while (mvOccupied->BrakeCtrlPos>mvOccupied->BrakeCtrlPosNo/2 && - // mvOccupied->DecBrakeLevel()); - // while (mvOccupied->BrakeCtrlPosBrakeCtrlPosNo/2 && - // mvOccupied->IncBrakeLevel()); - mvOccupied->BrakeLevelSet(mvOccupied->BrakeCtrlPosNo / 2 + - (mvOccupied->BrakeHandle == FV4a ? 1 : 0)); - if (GetAsyncKeyState(VK_CONTROL) < 0) - mvOccupied->BrakeLevelSet( - mvOccupied->Handle->GetPos(bh_NP)); // yB: czy ten stos funkcji nie - // powinien być jako oddzielna - // funkcja movera? - } - else if (cKey == Global::Keys[k_Brake1]) - { - if ((isEztOer) && (mvOccupied->BrakeCtrlPos != 1)) - { - dsbPneumaticSwitch->SetVolume(-10); - dsbPneumaticSwitch->Play(0, 0, 0); - } - // while (mvOccupied->BrakeCtrlPos>1 && mvOccupied->DecBrakeLevel()); - // while (mvOccupied->BrakeCtrlPos<1 && mvOccupied->IncBrakeLevel()); - mvOccupied->BrakeLevelSet(1); - } - else if (cKey == Global::Keys[k_Brake0]) - { - if (Console::Pressed(VK_CONTROL)) - { - mvOccupied->BrakeCtrlPos2 = 0; // wyrownaj kapturek - } - else - { - if ((isEztOer) && - ((mvOccupied->BrakeCtrlPos == 1) || (mvOccupied->BrakeCtrlPos == -1))) - { - dsbPneumaticSwitch->SetVolume(-10); - dsbPneumaticSwitch->Play(0, 0, 0); - } - // while (mvOccupied->BrakeCtrlPos>0 && mvOccupied->DecBrakeLevel()); - // while (mvOccupied->BrakeCtrlPos<0 && mvOccupied->IncBrakeLevel()); - mvOccupied->BrakeLevelSet(0); - } - } - else if (cKey == Global::Keys[k_WaveBrake]) //[Num.] - { - if ((isEztOer) && (mvControlled->Mains) && (mvOccupied->BrakeCtrlPos != -1)) - { - dsbPneumaticSwitch->SetVolume(-10); - dsbPneumaticSwitch->Play(0, 0, 0); - } - // while (mvOccupied->BrakeCtrlPos>-1 && mvOccupied->DecBrakeLevel()); - // while (mvOccupied->BrakeCtrlPos<-1 && mvOccupied->IncBrakeLevel()); - mvOccupied->BrakeLevelSet(-1); - } - else if (cKey == Global::Keys[k_Czuwak]) - //--------------- - // hunter-131211: zbicie czuwaka przeniesione do TTrain::Update() - { // Ra: tu został tylko dźwięk - // dsbBuzzer->Stop(); - // if (mvOccupied->SecuritySystemReset()) - if (fabs(ggSecurityResetButton.GetValue()) < 0.001) - { - dsbSwitch->SetVolume(DSBVOLUME_MAX); - dsbSwitch->Play(0, 0, 0); - } - // ggSecurityResetButton.PutValue(1); - } - else if (cKey == Global::Keys[k_AntiSlipping]) - //--------------- - // hunter-221211: hamulec przeciwposlizgowy przeniesiony do - // TTrain::Update() - { - if (mvOccupied->BrakeSystem != ElectroPneumatic) - { - // if (mvControlled->AntiSlippingButton()) - if (fabs(ggAntiSlipButton.GetValue()) < 0.001) - { - // Dlaczego bylo '-50'??? - // dsbSwitch->SetVolume(-50); - dsbSwitch->SetVolume(DSBVOLUME_MAX); - dsbSwitch->Play(0, 0, 0); - } - // ggAntiSlipButton.PutValue(1); - } - } - else if (cKey == Global::Keys[k_Fuse]) - //--------------- - { - if (GetAsyncKeyState(VK_CONTROL) < 0) // z controlem - { - ggConverterFuseButton.PutValue(1); // hunter-261211 - if ((mvControlled->Mains == false) && (ggConverterButton.GetValue() == 0) && - (mvControlled->TrainType != dt_EZT)) - mvControlled->ConvOvldFlag = false; - } - else - { - ggFuseButton.PutValue(1); - mvControlled->FuseOn(); - } - } - else if (cKey == Global::Keys[k_DirectionForward]) - // McZapkie-240302 - zmiana kierunku: 'd' do przodu, 'r' do tylu - { - if (mvOccupied->DirectionForward()) - { - //------------ - // hunter-121211: dzwiek kierunkowego - if (dsbReverserKey) - { - dsbReverserKey->SetCurrentPosition(0); - dsbReverserKey->SetVolume(DSBVOLUME_MAX); - dsbReverserKey->Play(0, 0, 0); - } - else if (!dsbReverserKey) - if (dsbSwitch) - { - dsbSwitch->SetVolume(DSBVOLUME_MAX); - dsbSwitch->Play(0, 0, 0); - } - //------------ - if (mvOccupied->ActiveDir) // jeśli kierunek niezerowy - if (DynamicObject->Mechanik) // na wszelki wypadek - DynamicObject->Mechanik->CheckVehicles( - Change_direction); // aktualizacja skrajnych pojazdów w składzie - } - } - else if (cKey == Global::Keys[k_DirectionBackward]) // r - { - if (GetAsyncKeyState(VK_CONTROL) < 0) - { // wciśnięty [Ctrl] - if (mvOccupied->Radio == true) - { - dsbSwitch->SetVolume(DSBVOLUME_MAX); - dsbSwitch->Play(0, 0, 0); - mvOccupied->Radio = false; - } - } - else if (mvOccupied->DirectionBackward()) - { - //------------ - // hunter-121211: dzwiek kierunkowego - if (dsbReverserKey) - { - dsbReverserKey->SetCurrentPosition(0); - dsbReverserKey->SetVolume(DSBVOLUME_MAX); - dsbReverserKey->Play(0, 0, 0); - } - else if (!dsbReverserKey) - if (dsbSwitch) - { - dsbSwitch->SetVolume(DSBVOLUME_MAX); - dsbSwitch->Play(0, 0, 0); - } - //------------ - if (mvOccupied->ActiveDir) // jeśli kierunek niezerowy - if (DynamicObject->Mechanik) // na wszelki wypadek - DynamicObject->Mechanik->CheckVehicles( - Change_direction); // aktualizacja skrajnych pojazdów w składzie - } - } - else if (cKey == Global::Keys[k_Main]) - // McZapkie-240302 - wylaczanie glownego obwodu - //----------- - // hunter-141211: wyl. szybki wylaczony przeniesiony do TTrain::Update() - { - if (fabs(ggMainOffButton.GetValue()) < 0.001) - if (dsbSwitch) - { - dsbSwitch->SetVolume(DSBVOLUME_MAX); - dsbSwitch->Play(0, 0, 0); - } - } - else if (cKey == Global::Keys[k_Battery]) - { - // if ((mvControlled->TrainType==dt_EZT) || - // (mvControlled->EngineType==ElectricSeriesMotor)|| - // (mvControlled->EngineType==DieselElectric)) - if (mvOccupied->BatterySwitch(false)) - { // ewentualnie zablokować z FIZ, - // np. w samochodach się nie - // odłącza akumulatora - if (ggBatteryButton.SubModel) - { - ggBatteryButton.PutValue(0); - } - dsbSwitch->Play(0, 0, 0); - // mvOccupied->SecuritySystem.Status=0; - mvControlled->PantFront(false); - mvControlled->PantRear(false); - } - } + auto const originalbrakeposition { static_cast( 100.0 * mvOccupied->fBrakeCtrlPos ) }; - //----------- - // if (cKey==Global::Keys[k_Active]) //yB 300407: przelacznik - // rozrzadu - // { - // if (mvControlled->CabDeactivisation()) - // { - // dsbSwitch->SetVolume(DSBVOLUME_MAX); - // dsbSwitch->Play(0,0,0); - // } - // } - // else - if (cKey == Global::Keys[k_BrakeProfile]) - { // yB://ABu: male poprawki, zeby - // bylo mozna ustawic dowolny - // wagon - int CouplNr = -2; - if (!FreeFlyModeFlag) - { - if (GetAsyncKeyState(VK_CONTROL) < 0) - if (mvOccupied->BrakeDelaySwitch(bdelay_R)) - { - dsbPneumaticRelay->SetVolume(DSBVOLUME_MAX); - dsbPneumaticRelay->Play(0, 0, 0); - } - else - ; - else if (mvOccupied->BrakeDelaySwitch(bdelay_G)) - { - dsbPneumaticRelay->SetVolume(DSBVOLUME_MAX); - dsbPneumaticRelay->Play(0, 0, 0); - } - } - else - { - TDynamicObject *temp; - temp = (DynamicObject->ABuScanNearestObject(DynamicObject->GetTrack(), -1, 1500, - CouplNr)); - if (temp == NULL) - { - CouplNr = -2; - temp = (DynamicObject->ABuScanNearestObject(DynamicObject->GetTrack(), 1, 1500, - CouplNr)); - } - if (temp) - { - if (GetAsyncKeyState(VK_CONTROL) < 0) - if (temp->MoverParameters->BrakeDelaySwitch(bdelay_R)) - { - dsbPneumaticRelay->SetVolume(DSBVOLUME_MAX); - dsbPneumaticRelay->Play(0, 0, 0); - } - else - ; - else if (temp->MoverParameters->BrakeDelaySwitch(bdelay_G)) - { - dsbPneumaticRelay->SetVolume(DSBVOLUME_MAX); - dsbPneumaticRelay->Play(0, 0, 0); - } - } - } - } - else if (cKey == Global::Keys[k_Converter]) - //----------- - // hunter-261211: przetwornica i sprzezarka przeniesione do - // TTrain::Update() - { - if (ggConverterButton.GetValue() != 0) - { - dsbSwitch->SetVolume(DSBVOLUME_MAX); - dsbSwitch->Play(0, 0, 0); - } - } - // if - // ((cKey==Global::Keys[k_Compressor])&&((mvControlled->EngineType==ElectricSeriesMotor)||(mvControlled->TrainType==dt_EZT))) - // //hunter-110212: poprawka dla EZT - else if ((cKey == Global::Keys[k_Compressor]) && - (mvControlled->CompressorPower < 2)) // hunter-091012: tak jest poprawnie - { - if (ggCompressorButton.GetValue() != 0) - { - dsbSwitch->SetVolume(DSBVOLUME_MAX); - dsbSwitch->Play(0, 0, 0); - } - } - //----------- - else if (cKey == Global::Keys[k_Releaser]) // odluzniacz - { - if (!FreeFlyModeFlag) - { - if ((mvControlled->EngineType == ElectricSeriesMotor) || - (mvControlled->EngineType == DieselElectric) || - (mvControlled->EngineType == ElectricInductionMotor)) - if (mvControlled->TrainType != dt_EZT) - if (mvOccupied->BrakeCtrlPosNo > 0) - { - ggReleaserButton.PutValue(1); - mvOccupied->BrakeReleaser(1); - // if (mvOccupied->BrakeReleaser(1)) - // { - // dsbPneumaticRelay->SetVolume(-80); - // dsbPneumaticRelay->Play(0, 0, 0); - // } - } - } - } - else if (cKey == Global::Keys[k_SmallCompressor]) // Winger 160404: mala - // sprezarka wl - { // Ra: bez [Shift] też dać dźwięk - if ((mvControlled->TrainType & dt_EZT) ? mvControlled == mvOccupied : - !mvOccupied->ActiveCab) // tylko w maszynowym - if (Console::Pressed(VK_CONTROL)) // z [Ctrl] - mvControlled->bPantKurek3 = - false; // zbiornik pantografu połączony jest z małą sprężarką - // (pompowanie ma sens, ale potem trzeba przełączyć) - else if (!mvControlled->PantCompFlag) // jeśli wyłączona - if (mvControlled->Battery) // jeszcze musi być załączona bateria - if (mvControlled->PantPress < 4.8) // piszą, że to tak nie działa - { - mvControlled->PantCompFlag = true; - dsbSwitch->SetVolume(DSBVOLUME_MAX); - dsbSwitch->Play(0, 0, 0); // dźwięk tylko po naciśnięciu klawisza - } - } - // McZapkie-240302 - wylaczanie automatycznego pilota (w trybie ~debugmode - // mozna tylko raz) - else if (cKey == VkKeyScan('q')) // bez Shift - { - if (DynamicObject->Mechanik) - DynamicObject->Mechanik->TakeControl(false); - } - else if (cKey == Global::Keys[k_MaxCurrent]) // McZapkie-160502: f - niski rozruch - { - if ((mvControlled->EngineType == DieselElectric) && (mvControlled->ShuntModeAllow) && - (mvControlled->MainCtrlPos == 0)) - { - mvControlled->ShuntMode = false; - } - if (mvControlled->CurrentSwitch(false)) - { - dsbSwitch->SetVolume(DSBVOLUME_MAX); - dsbSwitch->Play(0, 0, 0); - } - /* Ra: przeniesione do Mover.cpp - if (mvControlled->TrainType!=dt_EZT) - if (mvControlled->MinCurrentSwitch(false)) - { - dsbSwitch->SetVolume(DSBVOLUME_MAX); - dsbSwitch->Play(0,0,0); - } - */ - } - else if (cKey == Global::Keys[k_CurrentAutoRelay]) // McZapkie-241002: g - - // wylaczanie PSR - { - if (mvControlled->AutoRelaySwitch(false)) - { - dsbSwitch->SetVolume(DSBVOLUME_MAX); - dsbSwitch->Play(0, 0, 0); - } - } + mvOccupied->BrakeLevelSet( Position ); - // hunter-201211: piasecznica poprawiona oraz przeniesiona do - // TTrain::Update() - else if (cKey == Global::Keys[k_Sand]) - { - /* - if (mvControlled->TrainType!=dt_EZT) - { - if (mvControlled->SandDoseOn()) - if (mvControlled->SandDose) - { - dsbPneumaticRelay->SetVolume(-30); - dsbPneumaticRelay->Play(0,0,0); - } - } - */ - if (mvControlled->TrainType == dt_EZT) - { - if (ggDoorSignallingButton.SubModel != NULL) - { - if (mvControlled->DoorSignalling) - { - mvOccupied->DoorBlocked = false; - dsbSwitch->Play(0, 0, 0); - mvControlled->DoorSignalling = false; - } - } - } - } - else if (cKey == Global::Keys[k_CabForward]) - { - if (!CabChange(1)) - if (TestFlag(DynamicObject->MoverParameters->Couplers[0].CouplingFlag, - ctrain_passenger)) - { // przejscie do nastepnego pojazdu - Global::changeDynObj = DynamicObject->PrevConnected; - Global::changeDynObj->MoverParameters->ActiveCab = - DynamicObject->PrevConnectedNo ? -1 : 1; - } - if (DynamicObject->MoverParameters->ActiveCab) - mvControlled->PantCompFlag = false; // wyjście z maszynowego wyłącza sprężarkę - } - else if (cKey == Global::Keys[k_CabBackward]) - { - if (!CabChange(-1)) - if (TestFlag(DynamicObject->MoverParameters->Couplers[1].CouplingFlag, - ctrain_passenger)) - { // przejscie do poprzedniego - Global::changeDynObj = DynamicObject->NextConnected; - Global::changeDynObj->MoverParameters->ActiveCab = - DynamicObject->NextConnectedNo ? -1 : 1; - } - if (DynamicObject->MoverParameters->ActiveCab) - mvControlled->PantCompFlag = - false; // wyjście z maszynowego wyłącza sprężarkę pomocniczą - } - else if (cKey == Global::Keys[k_Couple]) - { // ABu051104: male zmiany, zeby - // mozna bylo laczyc odlegle - // wagony - // da sie zoptymalizowac, ale nie ma na to czasu :( - if (iCabn > 0) - { - if (!FreeFlyModeFlag) // tryb 'kabinowy' - { /* - if (mvControlled->Couplers[iCabn-1].CouplingFlag==0) - { -if - (mvControlled->Attach(iCabn-1,mvControlled->Couplers[iCabn-1].Connected,ctrain_coupler)) - { - dsbCouplerAttach->SetVolume(DSBVOLUME_MAX); - dsbCouplerAttach->Play(0,0,0); - //ABu: aha, a guzik, nie dziala i nie bedzie, a przydalo by sie - cos takiego: - //DynamicObject->NextConnected=mvControlled->Couplers[iCabn-1].Connected; - //DynamicObject->PrevConnected=mvControlled->Couplers[iCabn-1].Connected; - } - } - else - if - (!TestFlag(mvControlled->Couplers[iCabn-1].CouplingFlag,ctrain_pneumatic)) - { - //ABu021104: zeby caly czas bylo widac sprzegi: -if - (mvControlled->Attach(iCabn-1,mvControlled->Couplers[iCabn-1].Connected,mvControlled->Couplers[iCabn-1].CouplingFlag+ctrain_pneumatic)) -//if - (mvControlled->Attach(iCabn-1,mvControlled->Couplers[iCabn-1].Connected,ctrain_pneumatic)) - { - rsHiss.Play(1,DSBPLAY_LOOPING,true,DynamicObject->GetPosition()); - } - }*/ - } - else - { // tryb freefly - int CouplNr = -1; // normalnie żaden ze sprzęgów - TDynamicObject *tmp; - tmp = DynamicObject->ABuScanNearestObject(DynamicObject->GetTrack(), 1, 1500, - CouplNr); - if (tmp == NULL) - tmp = DynamicObject->ABuScanNearestObject(DynamicObject->GetTrack(), -1, - 1500, CouplNr); - if (tmp && (CouplNr != -1)) - { - if (tmp->MoverParameters->Couplers[CouplNr].CouplingFlag == - 0) // najpierw hak - { - if ((tmp->MoverParameters->Couplers[CouplNr] - .Connected->Couplers[CouplNr] - .AllowedFlag & - tmp->MoverParameters->Couplers[CouplNr].AllowedFlag & - ctrain_coupler) == ctrain_coupler) - if (tmp->MoverParameters->Attach( - CouplNr, 2, - tmp->MoverParameters->Couplers[CouplNr].Connected, - ctrain_coupler)) - { - // tmp->MoverParameters->Couplers[CouplNr].Render=true; - // //podłączony sprzęg będzie widoczny - if (DynamicObject->Mechanik) // na wszelki wypadek - DynamicObject->Mechanik->CheckVehicles( - Connect); // aktualizacja flag kierunku w składzie - dsbCouplerAttach->SetVolume(DSBVOLUME_MAX); - dsbCouplerAttach->Play(0, 0, 0); - } - else - WriteLog("Mechanical coupling failed."); - } - else if (!TestFlag(tmp->MoverParameters->Couplers[CouplNr].CouplingFlag, - ctrain_pneumatic)) // pneumatyka - { - if ((tmp->MoverParameters->Couplers[CouplNr] - .Connected->Couplers[CouplNr] - .AllowedFlag & - tmp->MoverParameters->Couplers[CouplNr].AllowedFlag & - ctrain_pneumatic) == ctrain_pneumatic) - if (tmp->MoverParameters->Attach( - CouplNr, 2, - tmp->MoverParameters->Couplers[CouplNr].Connected, - tmp->MoverParameters->Couplers[CouplNr].CouplingFlag + - ctrain_pneumatic)) - { - rsHiss.Play(1, DSBPLAY_LOOPING, true, tmp->GetPosition()); - DynamicObject->SetPneumatic(CouplNr, - 1); // Ra: to mi się nie podoba !!!! - tmp->SetPneumatic(CouplNr, 1); - } - } - else if (!TestFlag(tmp->MoverParameters->Couplers[CouplNr].CouplingFlag, - ctrain_scndpneumatic)) // zasilajacy - { - if ((tmp->MoverParameters->Couplers[CouplNr] - .Connected->Couplers[CouplNr] - .AllowedFlag & - tmp->MoverParameters->Couplers[CouplNr].AllowedFlag & - ctrain_scndpneumatic) == ctrain_scndpneumatic) - if (tmp->MoverParameters->Attach( - CouplNr, 2, - tmp->MoverParameters->Couplers[CouplNr].Connected, - tmp->MoverParameters->Couplers[CouplNr].CouplingFlag + - ctrain_scndpneumatic)) - { - // rsHiss.Play(1,DSBPLAY_LOOPING,true,tmp->GetPosition()); - dsbCouplerDetach->SetVolume(DSBVOLUME_MAX); - dsbCouplerDetach->Play(0, 0, 0); - DynamicObject->SetPneumatic(CouplNr, - 0); // Ra: to mi się nie podoba !!!! - tmp->SetPneumatic(CouplNr, 0); - } - } - else if (!TestFlag(tmp->MoverParameters->Couplers[CouplNr].CouplingFlag, - ctrain_controll)) // ukrotnionko - { - if ((tmp->MoverParameters->Couplers[CouplNr] - .Connected->Couplers[CouplNr] - .AllowedFlag & - tmp->MoverParameters->Couplers[CouplNr].AllowedFlag & - ctrain_controll) == ctrain_controll) - if (tmp->MoverParameters->Attach( - CouplNr, 2, - tmp->MoverParameters->Couplers[CouplNr].Connected, - tmp->MoverParameters->Couplers[CouplNr].CouplingFlag + - ctrain_controll)) - { - dsbCouplerAttach->SetVolume(DSBVOLUME_MAX); - dsbCouplerAttach->Play(0, 0, 0); - } - } - else if (!TestFlag(tmp->MoverParameters->Couplers[CouplNr].CouplingFlag, - ctrain_passenger)) // mostek - { - if ((tmp->MoverParameters->Couplers[CouplNr] - .Connected->Couplers[CouplNr] - .AllowedFlag & - tmp->MoverParameters->Couplers[CouplNr].AllowedFlag & - ctrain_passenger) == ctrain_passenger) - if (tmp->MoverParameters->Attach( - CouplNr, 2, - tmp->MoverParameters->Couplers[CouplNr].Connected, - tmp->MoverParameters->Couplers[CouplNr].CouplingFlag + - ctrain_passenger)) - { - // rsHiss.Play(1,DSBPLAY_LOOPING,true,tmp->GetPosition()); - dsbCouplerDetach->SetVolume(DSBVOLUME_MAX); - dsbCouplerDetach->Play(0, 0, 0); - DynamicObject->SetPneumatic(CouplNr, 0); - tmp->SetPneumatic(CouplNr, 0); - } - } - } - } - } - } - else if (cKey == Global::Keys[k_DeCouple]) - { // ABu051104: male zmiany, - // zeby mozna bylo rozlaczac - // odlegle wagony - if (iCabn > 0) - { - if (!FreeFlyModeFlag) // tryb 'kabinowy' (pozwala również rozłączyć - // sprzęgi zablokowane) - { - if (DynamicObject->DettachStatus(iCabn - 1) < 0) // jeśli jest co odczepić - if (DynamicObject->Dettach(iCabn - 1)) // iCab==1:przód,iCab==2:tył - { - dsbCouplerDetach->SetVolume(DSBVOLUME_MAX); // w kabinie ten dźwięk? - dsbCouplerDetach->Play(0, 0, 0); - } - } - else - { // tryb freefly - int CouplNr = -1; - TDynamicObject *tmp; - tmp = DynamicObject->ABuScanNearestObject(DynamicObject->GetTrack(), 1, 1500, - CouplNr); - if (tmp == NULL) - tmp = DynamicObject->ABuScanNearestObject(DynamicObject->GetTrack(), -1, - 1500, CouplNr); - if (tmp && (CouplNr != -1)) - { - if ((tmp->MoverParameters->Couplers[CouplNr].CouplingFlag & ctrain_depot) == - 0) // jeżeli sprzęg niezablokowany - if (tmp->DettachStatus(CouplNr) < 0) // jeśli jest co odczepić i się da - if (!tmp->Dettach(CouplNr)) - { // dźwięk odczepiania - dsbCouplerDetach->SetVolume(DSBVOLUME_MAX); - dsbCouplerDetach->Play(0, 0, 0); - } - } - } - if (DynamicObject->Mechanik) // na wszelki wypadek - DynamicObject->Mechanik->CheckVehicles( - Disconnect); // aktualizacja skrajnych pojazdów w składzie - } - } - else if (cKey == Global::Keys[k_CloseLeft]) // NBMX 17-09-2003: zamykanie drzwi - { - if( mvOccupied->DoorCloseCtrl == 1 ) { - if( mvOccupied->CabNo < 0 ? mvOccupied->DoorRight( false ) : mvOccupied->DoorLeft( false ) ) { - dsbSwitch->SetVolume( DSBVOLUME_MAX ); - dsbSwitch->Play( 0, 0, 0 ); - if( dsbDoorClose ) { - dsbDoorClose->SetCurrentPosition( 0 ); - dsbDoorClose->Play( 0, 0, 0 ); - } - } - } - } - else if (cKey == Global::Keys[k_CloseRight]) // NBMX 17-09-2003: zamykanie drzwi - { - if( mvOccupied->DoorCloseCtrl == 1 ) { - if( mvOccupied->CabNo < 0 ? mvOccupied->DoorLeft( false ) : mvOccupied->DoorRight( false ) ) { - dsbSwitch->SetVolume( DSBVOLUME_MAX ); - dsbSwitch->Play( 0, 0, 0 ); - if( dsbDoorClose ) { - dsbDoorClose->SetCurrentPosition( 0 ); - dsbDoorClose->Play( 0, 0, 0 ); - } - } - } - } + if( static_cast( 100.0 * mvOccupied->fBrakeCtrlPos ) == originalbrakeposition ) { return; } - //----------- - // hunter-131211: dzwiek dla przelacznika universala - // hunter-091012: ubajerowanie swiatla w kabinie (wyrzucenie - // przyciemnienia pod Univ4) - else if (cKey == Global::Keys[k_Univ3]) - { - if (Console::Pressed(VK_CONTROL)) - { - if (bCabLight == true) //(ggCabLightButton.GetValue()!=0) - { - dsbSwitch->SetVolume(DSBVOLUME_MAX); - dsbSwitch->Play(0, 0, 0); - } - } - else - { - if (ggUniversal3Button.GetValue() != 0) - { - dsbSwitch->SetVolume(DSBVOLUME_MAX); - dsbSwitch->Play(0, 0, 0); - } - /* - if (Console::Pressed(VK_CONTROL)) - {//z [Ctrl] zapalamy albo gasimy światełko w kabinie - if (iCabLightFlag) --iCabLightFlag; //gaszenie - } */ - } - } + if( ( true == is_eztoer() ) + && ( false == ( + ( ( originalbrakeposition / 100 == 0 ) || ( originalbrakeposition / 100 >= 5 ) ) + && ( ( mvOccupied->BrakeCtrlPos == 0 ) || ( mvOccupied->BrakeCtrlPos >= 5 ) ) ) ) ) { + // sound feedback if the lever movement activates one of the switches + dsbPneumaticSwitch.play(); + } +} - //----------- - // hunter-091012: dzwiek dla przyciemnienia swiatelka w kabinie - else if (cKey == Global::Keys[k_Univ4]) - { - if (Console::Pressed(VK_CONTROL)) - { - if (bCabLightDim == true) //(ggCabLightDimButton.GetValue()!=0) - { - dsbSwitch->SetVolume(DSBVOLUME_MAX); - dsbSwitch->Play(0, 0, 0); - } - } - } - //----------- - else if (cKey == Global::Keys[k_PantFrontDown]) // Winger 160204: - // opuszczanie prz. patyka - { - if (mvOccupied->ActiveCab == - 1) //||((mvOccupied->ActiveCab<1)&&(mvControlled->TrainType!=dt_ET40)&&(mvControlled->TrainType!=dt_ET41)&&(mvControlled->TrainType!=dt_ET42)&&(mvControlled->TrainType!=dt_EZT))) - { - // if (!mvControlled->PantFrontUp) //jeśli był opuszczony - // if () //jeśli połamany - // //to powtórzone opuszczanie naprawia - if (mvControlled->PantFront(false)) - { - dsbSwitch->SetVolume(DSBVOLUME_MAX); - dsbSwitch->Play(0, 0, 0); - } - } - else - // if - // ((mvOccupied->ActiveCab<1)&&((mvControlled->TrainType==dt_ET40)||(mvControlled->TrainType==dt_ET41)||(mvControlled->TrainType==dt_ET42)||(mvControlled->TrainType==dt_EZT))) - { - if (mvControlled->PantRear(false)) - { - dsbSwitch->SetVolume(DSBVOLUME_MAX); - dsbSwitch->Play(0, 0, 0); - } - } - } - else if (cKey == Global::Keys[k_PantRearDown]) // Winger 160204: - // opuszczanie tyl. patyka - { - if (mvOccupied->ActiveCab == - 1) //||((mvOccupied->ActiveCab<1)&&(mvControlled->TrainType!=dt_ET40)&&(mvControlled->TrainType!=dt_ET41)&&(mvControlled->TrainType!=dt_ET42)&&(mvControlled->TrainType!=dt_EZT))) - { - if (mvControlled->PantSwitchType == "impulse") - ggPantFrontButtonOff.PutValue(1); - if (mvControlled->PantRear(false)) - { - dsbSwitch->SetVolume(DSBVOLUME_MAX); - dsbSwitch->Play(0, 0, 0); - } - } - else - // if - // ((mvOccupied->ActiveCab<1)&&((mvControlled->TrainType==dt_ET40)||(mvControlled->TrainType==dt_ET41)||(mvControlled->TrainType==dt_ET42)||(mvControlled->TrainType==dt_EZT))) - { - /* if (mvControlled->PantSwitchType=="impulse") - ggPantRearButtonOff.PutValue(1); */ - if (mvControlled->PantFront(false)) - { - dsbSwitch->SetVolume(DSBVOLUME_MAX); - dsbSwitch->Play(0, 0, 0); - } - } - } - else if (cKey == Global::Keys[k_Heating]) // Winger 020304: ogrzewanie - - // wylaczenie - { // Ra 2014-09: w trybie latania obsługa jest w World.cpp - if (!FreeFlyModeFlag) - { - if (mvControlled->Heating == true) - { - dsbSwitch->SetVolume(DSBVOLUME_MAX); - dsbSwitch->Play(0, 0, 0); - mvControlled->Heating = false; - } - } - } - else if (cKey == Global::Keys[k_LeftSign]) // ABu 060205: lewe swiatlo - - // wylaczenie - { - if (false == (mvOccupied->LightsPosNo > 0)) - { - if ((GetAsyncKeyState(VK_CONTROL) < 0) && - (ggRearLeftLightButton.SubModel)) // hunter-230112 - z controlem gasi z tylu - { - //------------------------------ - if (mvOccupied->ActiveCab == 1) - { // kabina 1 - if (((DynamicObject->iLights[1]) & 3) == 0) - { - DynamicObject->iLights[1] |= 2; - dsbSwitch->SetVolume(DSBVOLUME_MAX); - dsbSwitch->Play(0, 0, 0); - if (ggRearLeftEndLightButton.SubModel) - { - ggRearLeftEndLightButton.PutValue(1); - ggRearLeftLightButton.PutValue(0); - } - else - ggRearLeftLightButton.PutValue(-1); - } - if (((DynamicObject->iLights[1]) & 3) == 1) - { - DynamicObject->iLights[1] &= (255 - 1); - dsbSwitch->SetVolume(DSBVOLUME_MAX); - dsbSwitch->Play(0, 0, 0); - ggRearLeftLightButton.PutValue(0); - } - } - else - { // kabina -1 - if (((DynamicObject->iLights[0]) & 3) == 0) - { - DynamicObject->iLights[0] |= 2; - dsbSwitch->SetVolume(DSBVOLUME_MAX); - dsbSwitch->Play(0, 0, 0); - if (ggRearLeftEndLightButton.SubModel) - { - ggRearLeftEndLightButton.PutValue(1); - ggRearLeftLightButton.PutValue(0); - } - else - ggRearLeftLightButton.PutValue(-1); - } - if (((DynamicObject->iLights[1]) & 3) == 1) - { - DynamicObject->iLights[1] &= (255 - 1); - dsbSwitch->SetVolume(DSBVOLUME_MAX); - dsbSwitch->Play(0, 0, 0); - ggLeftLightButton.PutValue(0); - } - } - } //------------------------------ - else - { - if (mvOccupied->ActiveCab == 1) - { // kabina 1 - if (((DynamicObject->iLights[0]) & 3) == 0) - { - DynamicObject->iLights[0] |= 2; - dsbSwitch->SetVolume(DSBVOLUME_MAX); - dsbSwitch->Play(0, 0, 0); - if (ggLeftEndLightButton.SubModel) - { - ggLeftEndLightButton.PutValue(1); - ggLeftLightButton.PutValue(0); - } - else - ggLeftLightButton.PutValue(-1); - } - if (((DynamicObject->iLights[0]) & 3) == 1) - { - DynamicObject->iLights[0] &= (255 - 1); - dsbSwitch->SetVolume(DSBVOLUME_MAX); - dsbSwitch->Play(0, 0, 0); - ggLeftLightButton.PutValue(0); - } - } - else - { // kabina -1 - if (((DynamicObject->iLights[1]) & 3) == 0) - { - DynamicObject->iLights[1] |= 2; - dsbSwitch->SetVolume(DSBVOLUME_MAX); - dsbSwitch->Play(0, 0, 0); - if (ggLeftEndLightButton.SubModel) - { - ggLeftEndLightButton.PutValue(1); - ggLeftLightButton.PutValue(0); - } - else - ggLeftLightButton.PutValue(-1); - } - if (((DynamicObject->iLights[1]) & 3) == 1) - { - DynamicObject->iLights[1] &= (255 - 1); - dsbSwitch->SetVolume(DSBVOLUME_MAX); - dsbSwitch->Play(0, 0, 0); - ggLeftLightButton.PutValue(0); - } - } - } - } - } - else if (cKey == Global::Keys[k_UpperSign]) // ABu 060205: światło górne - - // wyłączenie - { - if (mvOccupied->LightsPosNo > 0) //kręciolek od swiatel - { - if ((mvOccupied->LightsPos > 1) || (mvOccupied->LightsWrap)) - { - mvOccupied->LightsPos--; - if (mvOccupied->LightsPos < 1) - { - mvOccupied->LightsPos = mvOccupied->LightsPosNo; - } - dsbSwitch->SetVolume(DSBVOLUME_MAX); - dsbSwitch->Play(0, 0, 0); - SetLights(); - } - } - else if ((GetAsyncKeyState(VK_CONTROL) < 0) && - (ggRearUpperLightButton.SubModel)) // hunter-230112 - z controlem gasi z tylu - { - //------------------------------ - if (mvOccupied->ActiveCab == 1) - { // kabina 1 - if (((DynamicObject->iLights[1]) & 12) == 4) - { - DynamicObject->iLights[1] &= (255 - 4); - dsbSwitch->SetVolume(DSBVOLUME_MAX); - dsbSwitch->Play(0, 0, 0); - ggRearUpperLightButton.PutValue(0); - } - } - else - { // kabina -1 - if (((DynamicObject->iLights[0]) & 12) == 4) - { - DynamicObject->iLights[0] &= (255 - 4); - dsbSwitch->SetVolume(DSBVOLUME_MAX); - dsbSwitch->Play(0, 0, 0); - ggRearUpperLightButton.PutValue(0); - } - } - } //------------------------------ - else - { - if (mvOccupied->ActiveCab == 1) - { // kabina 1 - if (((DynamicObject->iLights[0]) & 12) == 4) - { - DynamicObject->iLights[0] &= (255 - 4); - dsbSwitch->SetVolume(DSBVOLUME_MAX); - dsbSwitch->Play(0, 0, 0); - ggUpperLightButton.PutValue(0); - } - } - else - { // kabina -1 - if (((DynamicObject->iLights[1]) & 12) == 4) - { - DynamicObject->iLights[1] &= (255 - 4); - dsbSwitch->SetVolume(DSBVOLUME_MAX); - dsbSwitch->Play(0, 0, 0); - ggUpperLightButton.PutValue(0); - } - } - } - } - if (cKey == Global::Keys[k_RightSign]) // Winger 070304: swiatla tylne - // (koncowki) - wlaczenie - { - if (false == (mvOccupied->LightsPosNo > 0)) - { - if ((GetAsyncKeyState(VK_CONTROL) < 0) && - (ggRearRightLightButton.SubModel)) // hunter-230112 - z controlem gasi z tylu - { - //------------------------------ - if (mvOccupied->ActiveCab == 1) - { // kabina 1 (od strony 0) - if (((DynamicObject->iLights[1]) & 48) == 0) - { - DynamicObject->iLights[1] |= 32; - dsbSwitch->SetVolume(DSBVOLUME_MAX); - dsbSwitch->Play(0, 0, 0); - if (ggRearRightEndLightButton.SubModel) - { - ggRearRightEndLightButton.PutValue(1); - ggRearRightLightButton.PutValue(0); - } - else - ggRearRightLightButton.PutValue(-1); - } - if (((DynamicObject->iLights[1]) & 48) == 16) - { - DynamicObject->iLights[1] &= (255 - 16); - dsbSwitch->SetVolume(DSBVOLUME_MAX); - dsbSwitch->Play(0, 0, 0); - ggRearRightLightButton.PutValue(0); - } - } - else - { // kabina -1 - if (((DynamicObject->iLights[0]) & 48) == 0) - { - DynamicObject->iLights[0] |= 32; - dsbSwitch->SetVolume(DSBVOLUME_MAX); - dsbSwitch->Play(0, 0, 0); - if (ggRearRightEndLightButton.SubModel) - { - ggRearRightEndLightButton.PutValue(1); - ggRearRightLightButton.PutValue(0); - } - else - ggRearRightLightButton.PutValue(-1); - } - if (((DynamicObject->iLights[0]) & 48) == 16) - { - DynamicObject->iLights[0] &= (255 - 16); - dsbSwitch->SetVolume(DSBVOLUME_MAX); - dsbSwitch->Play(0, 0, 0); - ggRearRightLightButton.PutValue(0); - } - } - } //------------------------------ - else - { - if (mvOccupied->ActiveCab == 1) - { // kabina 0 - if (((DynamicObject->iLights[0]) & 48) == 0) - { - DynamicObject->iLights[0] |= 32; - dsbSwitch->SetVolume(DSBVOLUME_MAX); - dsbSwitch->Play(0, 0, 0); - if (ggRightEndLightButton.SubModel) - { - ggRightEndLightButton.PutValue(1); - ggRightLightButton.PutValue(0); - } - else - ggRightLightButton.PutValue(-1); - } - if (((DynamicObject->iLights[0]) & 48) == 16) - { - DynamicObject->iLights[0] &= (255 - 16); - dsbSwitch->SetVolume(DSBVOLUME_MAX); - dsbSwitch->Play(0, 0, 0); - ggRightLightButton.PutValue(0); - } - } - else - { // kabina -1 - if (((DynamicObject->iLights[1]) & 48) == 0) - { - DynamicObject->iLights[1] |= 32; - dsbSwitch->SetVolume(DSBVOLUME_MAX); - dsbSwitch->Play(0, 0, 0); - if (ggRightEndLightButton.SubModel) - { - ggRightEndLightButton.PutValue(1); - ggRightLightButton.PutValue(0); - } - else - ggRightLightButton.PutValue(-1); - } - if (((DynamicObject->iLights[1]) & 48) == 16) - { - DynamicObject->iLights[1] &= (255 - 16); - dsbSwitch->SetVolume(DSBVOLUME_MAX); - dsbSwitch->Play(0, 0, 0); - ggRightLightButton.PutValue(0); - } - } - } - } - } - else if (cKey == Global::Keys[k_StLinOff]) // Winger 110904: wylacznik st. - // liniowych - { - if ((mvControlled->TrainType != dt_EZT) && (mvControlled->TrainType != dt_EP05) && - (mvControlled->TrainType != dt_ET40)) - { - ggStLinOffButton.PutValue(1); // Ra: było Fuse... - dsbSwitch->SetVolume(DSBVOLUME_MAX); - dsbSwitch->Play(0, 0, 0); - if (mvControlled->MainCtrlPosNo > 0) - { - mvControlled->StLinFlag = - false; // yBARC - zmienione na przeciwne, bo true to zalaczone - dsbRelay->SetVolume(DSBVOLUME_MAX); - dsbRelay->Play(0, 0, 0); - } - } - if (mvControlled->TrainType == dt_EZT) - { - if (mvControlled->Signalling == true) - { - dsbSwitch->Play(0, 0, 0); - mvControlled->Signalling = false; - } - } - } - else - { - // McZapkie: poruszanie sie po kabinie, w updatemechpos zawarte sa wiezy +void TTrain::set_train_brake_speed( TDynamicObject *Vehicle, int const Speed ) { - // double dt=Timer::GetDeltaTime(); - if (mvOccupied->ActiveCab < 0) - fMechCroach = -0.5; - else - fMechCroach = 0.5; - // if (!GetAsyncKeyState(VK_SHIFT)<0) // bez shifta - if (!Console::Pressed(VK_CONTROL)) // gdy [Ctrl] zwolniony (dodatkowe widoki) - { - if (cKey == Global::Keys[k_MechLeft]) - { - vMechMovement.x += fMechCroach; - if (DynamicObject->Mechanik) - if (!FreeFlyModeFlag) //żeby nie mieszać obserwując z zewnątrz - DynamicObject->Mechanik->RouteSwitch( - 1); // na skrzyżowaniu skręci w lewo - } - else if (cKey == Global::Keys[k_MechRight]) - { - vMechMovement.x -= fMechCroach; - if (DynamicObject->Mechanik) - if (!FreeFlyModeFlag) //żeby nie mieszać obserwując z zewnątrz - DynamicObject->Mechanik->RouteSwitch( - 2); // na skrzyżowaniu skręci w prawo - } - else if (cKey == Global::Keys[k_MechBackward]) - { - vMechMovement.z -= fMechCroach; - // if (DynamicObject->Mechanik) - // if (!FreeFlyModeFlag) //żeby nie mieszać obserwując z zewnątrz - // DynamicObject->Mechanik->RouteSwitch(0); //na skrzyżowaniu stanie - // i poczeka - } - else if (cKey == Global::Keys[k_MechForward]) - { - vMechMovement.z += fMechCroach; - if (DynamicObject->Mechanik) - if (!FreeFlyModeFlag) //żeby nie mieszać obserwując z zewnątrz - DynamicObject->Mechanik->RouteSwitch( - 3); // na skrzyżowaniu pojedzie prosto - } - else if (cKey == Global::Keys[k_MechUp]) - pMechOffset.y += 0.2; // McZapkie-120302 - wstawanie - else if (cKey == Global::Keys[k_MechDown]) - pMechOffset.y -= 0.2; // McZapkie-120302 - siadanie + if( true == Vehicle->MoverParameters->BrakeDelaySwitch( Speed ) ) { + // visual feedback + // TODO: add setting indicator to vehicle class, for external lever/indicator + if( Vehicle == DynamicObject ) { + if( ggBrakeProfileCtrl.SubModel != nullptr ) { + ggBrakeProfileCtrl.UpdateValue( + ( ( mvOccupied->BrakeDelayFlag & bdelay_R ) != 0 ? + 2.0 : + mvOccupied->BrakeDelayFlag - 1 ), + dsbSwitch ); } - } - - // else - if (DebugModeFlag) - { // przesuwanie składu o 100m - TDynamicObject *d = DynamicObject; - if (cKey == VkKeyScan('[')) - { - while (d) - { - d->Move(100.0 * d->DirectionGet()); - d = d->Next(); // pozostałe też - } - d = DynamicObject->Prev(); - while (d) - { - d->Move(100.0 * d->DirectionGet()); - d = d->Prev(); // w drugą stronę też - } + if( ggBrakeProfileG.SubModel != nullptr ) { + ggBrakeProfileG.UpdateValue( + ( mvOccupied->BrakeDelayFlag == bdelay_G ? + 1.0 : + 0.0 ), + dsbSwitch ); } - else if (cKey == VkKeyScan(']')) - { - while (d) - { - d->Move(-100.0 * d->DirectionGet()); - d = d->Next(); // pozostałe też - } - d = DynamicObject->Prev(); - while (d) - { - d->Move(-100.0 * d->DirectionGet()); - d = d->Prev(); // w drugą stronę też - } + if( ggBrakeProfileR.SubModel != nullptr ) { + ggBrakeProfileR.UpdateValue( + ( ( mvOccupied->BrakeDelayFlag & bdelay_R ) != 0 ? + 1.0 : + 0.0 ), + dsbSwitch ); } } - if (cKey == VkKeyScan('-')) - { // zmniejszenie numeru kanału radiowego - if (iRadioChannel > 0) - --iRadioChannel; // 0=wyłączony - } - else if (cKey == VkKeyScan('=')) - { // zmniejszenie numeru kanału radiowego - if (iRadioChannel < 8) - ++iRadioChannel; // 0=wyłączony - } } } -void TTrain::OnKeyUp(int cKey) -{ // zwolnienie klawisza - if (GetAsyncKeyState(VK_SHIFT) < 0) - { // wciśnięty [Shift] - } - else - { - if (cKey == Global::Keys[k_StLinOff]) // Winger 110904: wylacznik st. liniowych - { // zwolnienie klawisza daje powrót przycisku do zwykłego stanu - if ((mvControlled->TrainType != dt_EZT) && (mvControlled->TrainType != dt_EP05) && - (mvControlled->TrainType != dt_ET40)) - ggStLinOffButton.PutValue(0); +void TTrain::set_paired_open_motor_connectors_button( bool const State ) { + + if( ( mvControlled->TrainType == dt_ET41 ) + || ( mvControlled->TrainType == dt_ET42 ) ) { + // crude implementation of the button affecting entire unit for multi-unit engines + // TODO: rework it into part of standard command propagation system + if( ( mvControlled->Couplers[ side::front ].Connected != nullptr ) + && ( true == TestFlag( mvControlled->Couplers[ side::front ].CouplingFlag, coupling::permanent ) ) ) { + mvControlled->Couplers[ side::front ].Connected->StLinSwitchOff = State; + } + if( ( mvControlled->Couplers[ side::rear ].Connected != nullptr ) + && ( true == TestFlag( mvControlled->Couplers[ side::rear ].CouplingFlag, coupling::permanent ) ) ) { + mvControlled->Couplers[ side::rear ].Connected->StLinSwitchOff = State; } } -}; +} +// locates nearest vehicle belonging to the consist +TDynamicObject * +TTrain::find_nearest_consist_vehicle() const { + + if( false == FreeFlyModeFlag ) { + return DynamicObject; + } + auto coupler { -2 }; // scan for vehicle, not any specific coupler + auto *vehicle{ DynamicObject->ABuScanNearestObject( DynamicObject->GetTrack(), 1, 1500, coupler ) }; + if( vehicle == nullptr ) + vehicle = DynamicObject->ABuScanNearestObject( DynamicObject->GetTrack(), -1, 1500, coupler ); + // TBD, TODO: perform owner test for the located vehicle + return vehicle; +} + + +// command handlers +void TTrain::OnCommand_aidriverenable( TTrain *Train, command_data const &Command ) { + + if( Command.action == GLFW_PRESS ) { + // on press + if( Train->DynamicObject->Mechanik == nullptr ) { return; } + + if( true == Train->DynamicObject->Mechanik->AIControllFlag ) { + //żeby nie trzeba było rozłączać dla zresetowania + Train->DynamicObject->Mechanik->TakeControl( false ); + } + Train->DynamicObject->Mechanik->TakeControl( true ); + } +} + +void TTrain::OnCommand_aidriverdisable( TTrain *Train, command_data const &Command ) { + + if( Command.action == GLFW_PRESS ) { + // on press + if( Train->DynamicObject->Mechanik ) + Train->DynamicObject->Mechanik->TakeControl( false ); + } +} + +void TTrain::OnCommand_mastercontrollerincrease( TTrain *Train, command_data const &Command ) { + + if( Command.action != GLFW_RELEASE ) { + // on press or hold + Train->mvControlled->IncMainCtrl( 1 ); + } +} + +void TTrain::OnCommand_mastercontrollerincreasefast( TTrain *Train, command_data const &Command ) { + + if( Command.action != GLFW_RELEASE ) { + // on press or hold + Train->mvControlled->IncMainCtrl( 2 ); + } +} + +void TTrain::OnCommand_mastercontrollerdecrease( TTrain *Train, command_data const &Command ) { + + if( Command.action != GLFW_RELEASE ) { + // on press or hold + Train->mvControlled->DecMainCtrl( 1 ); + } +} + +void TTrain::OnCommand_mastercontrollerdecreasefast( TTrain *Train, command_data const &Command ) { + + if( Command.action != GLFW_RELEASE ) { + // on press or hold + Train->mvControlled->DecMainCtrl( 2 ); + } +} + +void TTrain::OnCommand_mastercontrollerset( TTrain *Train, command_data const &Command ) { + + if( Command.action != GLFW_RELEASE ) { + // on press or hold + Train->set_master_controller( Command.param1 ); + } +} + +void TTrain::OnCommand_secondcontrollerincrease( TTrain *Train, command_data const &Command ) { + + if( Command.action != GLFW_RELEASE ) { + // on press or hold + if( ( Train->mvControlled->EngineType == TEngineType::DieselElectric ) + && ( true == Train->mvControlled->ShuntMode ) ) { + Train->mvControlled->AnPos = clamp( + Train->mvControlled->AnPos + 0.025, + 0.0, 1.0 ); + } + else { + Train->mvControlled->IncScndCtrl( 1 ); + } + } +} + +void TTrain::OnCommand_secondcontrollerincreasefast( TTrain *Train, command_data const &Command ) { + + if( Command.action != GLFW_RELEASE ) { + // on press or hold + if( ( Train->mvControlled->EngineType == TEngineType::DieselElectric ) + && ( true == Train->mvControlled->ShuntMode ) ) { + Train->mvControlled->AnPos = 1.0; + } + else { + Train->mvControlled->IncScndCtrl( 2 ); + } + } +} + +void TTrain::OnCommand_notchingrelaytoggle( TTrain *Train, command_data const &Command ) { + + if( Command.action == GLFW_PRESS ) { + // only reacting to press, so the switch doesn't flip back and forth if key is held down + if( false == Train->mvOccupied->AutoRelayFlag ) { + // turn on + Train->mvOccupied->AutoRelaySwitch( true ); + } + else { + //turn off + Train->mvOccupied->AutoRelaySwitch( false ); + } + } +} + +void TTrain::OnCommand_mucurrentindicatorothersourceactivate( TTrain *Train, command_data const &Command ) { + + if( Train->ggNextCurrentButton.SubModel == nullptr ) { + if( Command.action == GLFW_PRESS ) { + WriteLog( "Current Indicator Source switch is missing, or wasn't defined" ); + } + return; + } + + if( Command.action == GLFW_PRESS ) { + // turn on + Train->ShowNextCurrent = true; + // visual feedback + Train->ggNextCurrentButton.UpdateValue( 1.0, Train->dsbSwitch ); + } + else if( Command.action == GLFW_RELEASE ) { + //turn off + Train->ShowNextCurrent = false; + // visual feedback + Train->ggNextCurrentButton.UpdateValue( 0.0, Train->dsbSwitch ); + } +} + +void TTrain::OnCommand_secondcontrollerdecrease( TTrain *Train, command_data const &Command ) { + + if( Command.action != GLFW_RELEASE ) { + // on press or hold + if( ( Train->mvControlled->EngineType == TEngineType::DieselElectric ) + && ( true == Train->mvControlled->ShuntMode ) ) { + Train->mvControlled->AnPos = clamp( + Train->mvControlled->AnPos - 0.025, + 0.0, 1.0 ); + } + else { + Train->mvControlled->DecScndCtrl( 1 ); + } + } +} + +void TTrain::OnCommand_secondcontrollerdecreasefast( TTrain *Train, command_data const &Command ) { + + if( Command.action != GLFW_RELEASE ) { + // on press or hold + if( ( Train->mvControlled->EngineType == TEngineType::DieselElectric ) + && ( true == Train->mvControlled->ShuntMode ) ) { + Train->mvControlled->AnPos = 0.0; + } + else { + Train->mvControlled->DecScndCtrl( 2 ); + } + } +} + +void TTrain::OnCommand_secondcontrollerset( TTrain *Train, command_data const &Command ) { + + auto const targetposition { std::min( Command.param1, Train->mvControlled->ScndCtrlPosNo ) }; + while( ( targetposition < Train->mvControlled->ScndCtrlPos ) + && ( true == Train->mvControlled->DecScndCtrl( 1 ) ) ) { + // all work is done in the header + ; + } + while( ( targetposition > Train->mvControlled->ScndCtrlPos ) + && ( true == Train->mvControlled->IncScndCtrl( 1 ) ) ) { + // all work is done in the header + ; + } +} + +void TTrain::OnCommand_independentbrakeincrease( TTrain *Train, command_data const &Command ) { + + if( Command.action != GLFW_RELEASE ) { + + if( Train->mvOccupied->LocalBrake != TLocalBrake::ManualBrake ) { + Train->mvOccupied->IncLocalBrakeLevel( 1 ); + } + } +} + +void TTrain::OnCommand_independentbrakeincreasefast( TTrain *Train, command_data const &Command ) { + + if( Command.action != GLFW_RELEASE ) { + + if( Train->mvOccupied->LocalBrake != TLocalBrake::ManualBrake ) { + Train->mvOccupied->IncLocalBrakeLevel( LocalBrakePosNo ); + } + } +} + +void TTrain::OnCommand_independentbrakedecrease( TTrain *Train, command_data const &Command ) { + + if( Command.action != GLFW_RELEASE ) { + + if( ( Train->mvOccupied->LocalBrake != TLocalBrake::ManualBrake ) + // Ra 1014-06: AI potrafi zahamować pomocniczym mimo jego braku - odhamować jakoś trzeba + // TODO: sort AI out so it doesn't do things it doesn't have equipment for + || ( Train->mvOccupied->LocalBrakePosA > 0 ) ) { + Train->mvOccupied->DecLocalBrakeLevel( 1 ); + } + } +} + +void TTrain::OnCommand_independentbrakedecreasefast( TTrain *Train, command_data const &Command ) { + + if( Command.action != GLFW_RELEASE ) { + + if( ( Train->mvOccupied->LocalBrake != TLocalBrake::ManualBrake ) + // Ra 1014-06: AI potrafi zahamować pomocniczym mimo jego braku - odhamować jakoś trzeba + // TODO: sort AI out so it doesn't do things it doesn't have equipment for + || ( Train->mvOccupied->LocalBrakePosA > 0 ) ) { + Train->mvOccupied->DecLocalBrakeLevel( LocalBrakePosNo ); + } + } +} + +void TTrain::OnCommand_independentbrakeset( TTrain *Train, command_data const &Command ) { + + Train->mvControlled->LocalBrakePosA = ( + clamp( + Command.param1, + 0.0, 1.0 ) ); +/* + Train->mvControlled->LocalBrakePos = ( + std::round( + interpolate( + 0.0, + LocalBrakePosNo, + clamp( + Command.param1, + 0.0, 1.0 ) ) ) ); +*/ +} + +void TTrain::OnCommand_independentbrakebailoff( TTrain *Train, command_data const &Command ) { + + if( false == FreeFlyModeFlag ) { + // TODO: check if this set of conditions can be simplified. + // it'd be more flexible to have an attribute indicating whether bail off position is supported + if( ( Train->mvControlled->TrainType != dt_EZT ) + && ( ( Train->mvControlled->EngineType == TEngineType::ElectricSeriesMotor ) + || ( Train->mvControlled->EngineType == TEngineType::DieselElectric ) + || ( Train->mvControlled->EngineType == TEngineType::ElectricInductionMotor ) ) + && ( Train->mvOccupied->BrakeCtrlPosNo > 0 ) ) { + + if( Command.action == GLFW_PRESS ) { + // press or hold + // visual feedback + Train->ggReleaserButton.UpdateValue( 1.0, Train->dsbSwitch ); + + Train->mvOccupied->BrakeReleaser( 1 ); + } + else if( Command.action == GLFW_RELEASE ) { + // release + // visual feedback + Train->ggReleaserButton.UpdateValue( 0.0, Train->dsbSwitch ); + + Train->mvOccupied->BrakeReleaser( 0 ); + } + } + } + else { + // car brake handling, while in walk mode + auto *vehicle { Train->find_nearest_consist_vehicle() }; + if( vehicle != nullptr ) { + if( Command.action == GLFW_PRESS ) { + // press or hold + vehicle->MoverParameters->BrakeReleaser( 1 ); + } + else if( Command.action == GLFW_RELEASE ) { + // release + vehicle->MoverParameters->BrakeReleaser( 0 ); + } + } + } +} + +void TTrain::OnCommand_trainbrakeincrease( TTrain *Train, command_data const &Command ) { + + if( Command.action != GLFW_RELEASE ) { + + if( Train->mvOccupied->BrakeHandle == TBrakeHandle::FV4a ) { + Train->mvOccupied->BrakeLevelAdd( 0.1 /*15.0 * Command.time_delta*/ ); + } + else { + Train->set_train_brake( Train->mvOccupied->BrakeCtrlPos + Global.fBrakeStep ); + } + } +} + +void TTrain::OnCommand_trainbrakedecrease( TTrain *Train, command_data const &Command ) { + + if( Command.action != GLFW_RELEASE ) { + // press or hold + if( Train->mvOccupied->BrakeHandle == TBrakeHandle::FV4a ) { + Train->mvOccupied->BrakeLevelAdd( -0.1 /*-15.0 * Command.time_delta*/ ); + } + else { + Train->set_train_brake( Train->mvOccupied->BrakeCtrlPos - Global.fBrakeStep ); + } + } +} + +void TTrain::OnCommand_trainbrakeset( TTrain *Train, command_data const &Command ) { + + Train->mvOccupied->BrakeLevelSet( + interpolate( + Train->mvOccupied->Handle->GetPos( bh_MIN ), + Train->mvOccupied->Handle->GetPos( bh_MAX ), + clamp( + Command.param1, + 0.0, 1.0 ) ) ); +} + +void TTrain::OnCommand_trainbrakecharging( TTrain *Train, command_data const &Command ) { + + if( Command.action != GLFW_RELEASE ) { + // press or hold + Train->set_train_brake( -1 ); + } + else { + // release + if( ( Train->mvOccupied->BrakeCtrlPos == -1 ) + && ( Train->mvOccupied->BrakeHandle == TBrakeHandle::FVel6 ) + && ( Train->DynamicObject->Controller != AIdriver ) + && ( Global.iFeedbackMode < 3 ) ) { + // Odskakiwanie hamulce EP + Train->set_train_brake( 0 ); + } + } +} + +void TTrain::OnCommand_trainbrakerelease( TTrain *Train, command_data const &Command ) { + + if( Command.action == GLFW_PRESS ) { + + Train->set_train_brake( 0 ); + } +} + +void TTrain::OnCommand_trainbrakefirstservice( TTrain *Train, command_data const &Command ) { + + if( Command.action == GLFW_PRESS ) { + + Train->set_train_brake( 1 ); + } +} + +void TTrain::OnCommand_trainbrakeservice( TTrain *Train, command_data const &Command ) { + + if( Command.action == GLFW_PRESS ) { + + Train->set_train_brake( ( + Train->mvOccupied->BrakeCtrlPosNo / 2 + + ( Train->mvOccupied->BrakeHandle == TBrakeHandle::FV4a ? + 1 : + 0 ) ) ); + } +} + +void TTrain::OnCommand_trainbrakefullservice( TTrain *Train, command_data const &Command ) { + + if( Command.action == GLFW_PRESS ) { + + Train->set_train_brake( Train->mvOccupied->BrakeCtrlPosNo - 1 ); + } +} + +void TTrain::OnCommand_trainbrakehandleoff( TTrain *Train, command_data const &Command ) { + + if( Command.action == GLFW_PRESS ) { + + Train->set_train_brake( Train->mvOccupied->Handle->GetPos( bh_NP ) ); + } +} + +void TTrain::OnCommand_trainbrakeemergency( TTrain *Train, command_data const &Command ) { + + if( Command.action == GLFW_PRESS ) { + + Train->set_train_brake( Train->mvOccupied->Handle->GetPos( bh_EB ) ); +/* + if( Train->mvOccupied->BrakeCtrlPosNo <= 0.1 ) { + // hamulec bezpieczeństwa dla wagonów + Train->mvOccupied->RadioStopFlag = true; + } +*/ + } +} + +void TTrain::OnCommand_trainbrakebasepressureincrease( TTrain *Train, command_data const &Command ) { + + if( Command.action != GLFW_RELEASE ) { + + switch( Train->mvOccupied->BrakeHandle ) { + case TBrakeHandle::FV4a: { + Train->mvOccupied->BrakeCtrlPos2 = clamp( Train->mvOccupied->BrakeCtrlPos2 - 0.01, -1.5, 2.0 ); + break; + } + default: { + Train->mvOccupied->BrakeLevelAdd( 0.01 ); + break; + } + } + } +} + +void TTrain::OnCommand_trainbrakebasepressuredecrease( TTrain *Train, command_data const &Command ) { + + if( Command.action != GLFW_RELEASE ) { + + switch( Train->mvOccupied->BrakeHandle ) { + case TBrakeHandle::FV4a: { + Train->mvOccupied->BrakeCtrlPos2 = clamp( Train->mvOccupied->BrakeCtrlPos2 + 0.01, -1.5, 2.0 ); + break; + } + default: { + Train->mvOccupied->BrakeLevelAdd( -0.01 ); + break; + } + } + } +} + +void TTrain::OnCommand_trainbrakebasepressurereset( TTrain *Train, command_data const &Command ) { + + if( Command.action == GLFW_PRESS ) { + + Train->mvOccupied->BrakeCtrlPos2 = 0; + } +} + +void TTrain::OnCommand_trainbrakeoperationtoggle( TTrain *Train, command_data const &Command ) { + + if( Command.action == GLFW_PRESS ) { + + auto *vehicle { Train->find_nearest_consist_vehicle() }; + if( vehicle == nullptr ) { return; } + + vehicle->MoverParameters->Hamulec->SetBrakeStatus( vehicle->MoverParameters->Hamulec->GetBrakeStatus() ^ b_dmg ); + } +} + +void TTrain::OnCommand_manualbrakeincrease( TTrain *Train, command_data const &Command ) { + + if( Command.action != GLFW_RELEASE ) { + + auto *vehicle { Train->find_nearest_consist_vehicle() }; + if( vehicle == nullptr ) { return; } + + if( ( vehicle->MoverParameters->LocalBrake == TLocalBrake::ManualBrake ) + || ( vehicle->MoverParameters->MBrake == true ) ) { + + vehicle->MoverParameters->IncManualBrakeLevel( 1 ); + } + } +} + +void TTrain::OnCommand_manualbrakedecrease( TTrain *Train, command_data const &Command ) { + + if( Command.action != GLFW_RELEASE ) { + + auto *vehicle { Train->find_nearest_consist_vehicle() }; + if( vehicle == nullptr ) { return; } + + if( ( vehicle->MoverParameters->LocalBrake == TLocalBrake::ManualBrake ) + || ( vehicle->MoverParameters->MBrake == true ) ) { + + vehicle->MoverParameters->DecManualBrakeLevel( 1 ); + } + } +} + +void TTrain::OnCommand_alarmchaintoggle( TTrain *Train, command_data const &Command ) { + + if( Command.action == GLFW_PRESS ) { + + if( false == Train->mvOccupied->AlarmChainFlag ) { + // pull + Train->mvOccupied->AlarmChainSwitch( true ); + // visual feedback + Train->ggAlarmChain.UpdateValue( 1.0 ); + } + else { + // release + Train->mvOccupied->AlarmChainSwitch( false ); + // visual feedback + Train->ggAlarmChain.UpdateValue( 0.0 ); + } + } +} + +void TTrain::OnCommand_wheelspinbrakeactivate( TTrain *Train, command_data const &Command ) { + + // TODO: proper control deviced definition for the interiors, that doesn't hinge of presence of 3d submodels + if( Train->ggAntiSlipButton.SubModel == nullptr ) { + if( Command.action == GLFW_PRESS ) { + WriteLog( "Wheelspin Brake button is missing, or wasn't defined" ); + } + return; + } + + if( Train->mvOccupied->BrakeSystem != TBrakeSystem::ElectroPneumatic ) { + // standard behaviour + if( Command.action == GLFW_PRESS ) { + // visual feedback + Train->ggAntiSlipButton.UpdateValue( 1.0, Train->dsbSwitch ); + + // NOTE: system activation is (repeatedly) done in the train update routine + } + else if( Command.action == GLFW_RELEASE ) { + // visual feedback + Train->ggAntiSlipButton.UpdateValue( 0.0 ); + } + } + else { + // electro-pneumatic, custom case + if( Command.action == GLFW_PRESS ) { + // visual feedback + Train->ggAntiSlipButton.UpdateValue( 1.0, Train->dsbPneumaticSwitch ); + + if( ( Train->mvOccupied->BrakeHandle == TBrakeHandle::St113 ) + && ( Train->mvControlled->EpFuse == true ) ) { + Train->mvOccupied->SwitchEPBrake( 1 ); + } + } + else if( Command.action == GLFW_RELEASE ) { + // visual feedback + Train->ggAntiSlipButton.UpdateValue( 0.0 ); + + Train->mvOccupied->SwitchEPBrake( 0 ); + } + } +} + +void TTrain::OnCommand_sandboxactivate( TTrain *Train, command_data const &Command ) { + + // TODO: proper control deviced definition for the interiors, that doesn't hinge of presence of 3d submodels + if( Train->ggSandButton.SubModel == nullptr ) { + if( Command.action == GLFW_PRESS ) { + WriteLog( "Sandbox activation button is missing, or wasn't defined" ); + } + return; + } + + if( Command.action == GLFW_PRESS ) { + // visual feedback + Train->ggSandButton.UpdateValue( 1.0, Train->dsbSwitch ); + + Train->mvControlled->Sandbox( true ); + } + else if( Command.action == GLFW_RELEASE) { + // visual feedback + Train->ggSandButton.UpdateValue( 0.0 ); + + Train->mvControlled->Sandbox( false ); + } +} + +void TTrain::OnCommand_epbrakecontroltoggle( TTrain *Train, command_data const &Command ) { + + if( Command.action == GLFW_PRESS ) { + // only reacting to press, so the switch doesn't flip back and forth if key is held down + if( false == Train->mvOccupied->EpFuse ) { + // turn on + if( Train->mvOccupied->EpFuseSwitch( true ) ) { + // audio feedback + Train->dsbPneumaticSwitch.play(); + // visual feedback + // NOTE: there's no button for ep brake control switch + // TBD, TODO: add ep brake control switch? + } + } + else { + //turn off + if( Train->mvOccupied->EpFuseSwitch( false ) ) { + // audio feedback + Train->dsbPneumaticSwitch.play(); + // visual feedback + // NOTE: there's no button for ep brake control switch + // TBD, TODO: add ep brake control switch? + } + } + } +} + +void TTrain::OnCommand_trainbrakeoperationmodeincrease(TTrain *Train, command_data const &Command) { + + if (Command.action == GLFW_PRESS) { + // only reacting to press, so the switch doesn't flip back and forth if key is held down + if( ( ( Train->mvOccupied->BrakeOpModeFlag << 1 ) & Train->mvOccupied->BrakeOpModes ) != 0 ) { + // next mode + Train->mvOccupied->BrakeOpModeFlag <<= 1; + // audio feedback + Train->dsbPneumaticSwitch.play(); + // visual feedback + Train->ggBrakeOperationModeCtrl.UpdateValue( + Train->mvOccupied->BrakeOpModeFlag > 0 ? + std::log2( Train->mvOccupied->BrakeOpModeFlag ) : + 0 ); + } + } +} + +void TTrain::OnCommand_trainbrakeoperationmodedecrease(TTrain *Train, command_data const &Command) { + + if (Command.action == GLFW_PRESS) { + // only reacting to press, so the switch doesn't flip back and forth if key is held down + if( ( ( Train->mvOccupied->BrakeOpModeFlag >> 1 ) & Train->mvOccupied->BrakeOpModes ) != 0 ) { + // previous mode + Train->mvOccupied->BrakeOpModeFlag >>= 1; + // audio feedback + Train->dsbPneumaticSwitch.play(); + // visual feedback + Train->ggBrakeOperationModeCtrl.UpdateValue( + Train->mvOccupied->BrakeOpModeFlag > 0 ? + std::log2( Train->mvOccupied->BrakeOpModeFlag ) : + 0 ); + } + } +} + +void TTrain::OnCommand_brakeactingspeedincrease( TTrain *Train, command_data const &Command ) { + + if( Command.action == GLFW_PRESS ) { + + auto *vehicle { Train->find_nearest_consist_vehicle() }; + if( vehicle == nullptr ) { return; } + + if( ( vehicle->MoverParameters->BrakeDelayFlag & bdelay_M ) != 0 ) { + // can't speed it up any more than this + return; + } + auto const fasterbrakesetting = ( + vehicle->MoverParameters->BrakeDelayFlag < bdelay_R ? + vehicle->MoverParameters->BrakeDelayFlag << 1 : + vehicle->MoverParameters->BrakeDelayFlag | bdelay_M ); + + Train->set_train_brake_speed( vehicle, fasterbrakesetting ); + } +} + +void TTrain::OnCommand_brakeactingspeeddecrease( TTrain *Train, command_data const &Command ) { + + if( Command.action == GLFW_PRESS ) { + + auto *vehicle { Train->find_nearest_consist_vehicle() }; + if( vehicle == nullptr ) { return; } + + if( vehicle->MoverParameters->BrakeDelayFlag == bdelay_G ) { + // can't slow it down any more than this + return; + } + auto const slowerbrakesetting = ( + vehicle->MoverParameters->BrakeDelayFlag < bdelay_M ? + vehicle->MoverParameters->BrakeDelayFlag >> 1 : + vehicle->MoverParameters->BrakeDelayFlag ^ bdelay_M ); + + Train->set_train_brake_speed( vehicle, slowerbrakesetting ); + } +} + +void TTrain::OnCommand_brakeactingspeedsetcargo( TTrain *Train, command_data const &Command ) { + + if( Command.action == GLFW_PRESS ) { + + auto *vehicle { Train->find_nearest_consist_vehicle() }; + if( vehicle == nullptr ) { return; } + + Train->set_train_brake_speed( vehicle, bdelay_G ); + } +} + +void TTrain::OnCommand_brakeactingspeedsetpassenger( TTrain *Train, command_data const &Command ) { + + if( Command.action == GLFW_PRESS ) { + + auto *vehicle { Train->find_nearest_consist_vehicle() }; + if( vehicle == nullptr ) { return; } + + Train->set_train_brake_speed( vehicle, bdelay_P ); + } +} + +void TTrain::OnCommand_brakeactingspeedsetrapid( TTrain *Train, command_data const &Command ) { + + if( Command.action == GLFW_PRESS ) { + + auto *vehicle{ Train->find_nearest_consist_vehicle() }; + if( vehicle == nullptr ) { return; } + + Train->set_train_brake_speed( vehicle, bdelay_R ); + } +} + +void TTrain::OnCommand_brakeloadcompensationincrease( TTrain *Train, command_data const &Command ) { + + if( ( true == FreeFlyModeFlag ) + && ( Command.action == GLFW_PRESS ) ) { + auto *vehicle { Train->find_nearest_consist_vehicle() }; + if( vehicle != nullptr ) { + vehicle->MoverParameters->IncBrakeMult(); + } + } +} + +void TTrain::OnCommand_brakeloadcompensationdecrease( TTrain *Train, command_data const &Command ) { + + if( ( true == FreeFlyModeFlag ) + && ( Command.action == GLFW_PRESS ) ) { + auto *vehicle { Train->find_nearest_consist_vehicle() }; + if( vehicle != nullptr ) { + vehicle->MoverParameters->DecBrakeMult(); + } + } +} + +void TTrain::OnCommand_mubrakingindicatortoggle( TTrain *Train, command_data const &Command ) { + + if( Train->ggSignallingButton.SubModel == nullptr ) { + if( Command.action == GLFW_PRESS ) { + WriteLog( "Braking Indicator switch is missing, or wasn't defined" ); + } + return; + } + if( Train->mvControlled->TrainType != dt_EZT ) { + // + return; + } + + if( Command.action == GLFW_PRESS ) { + // only reacting to press, so the switch doesn't flip back and forth if key is held down + if( false == Train->mvControlled->Signalling) { + // turn on + Train->mvControlled->Signalling = true; + // visual feedback + Train->ggSignallingButton.UpdateValue( 1.0, Train->dsbSwitch ); + } + else { + //turn off + Train->mvControlled->Signalling = false; + // visual feedback + Train->ggSignallingButton.UpdateValue( 0.0, Train->dsbSwitch ); + } + } +} + +void TTrain::OnCommand_reverserincrease( TTrain *Train, command_data const &Command ) { + + if( Command.action == GLFW_PRESS ) { + + if( Train->mvOccupied->DirectionForward() ) { + // aktualizacja skrajnych pojazdów w składzie + if( ( Train->mvOccupied->ActiveDir ) + && ( Train->DynamicObject->Mechanik ) ) { + + Train->DynamicObject->Mechanik->CheckVehicles( Change_direction ); + } + } + } +} + +void TTrain::OnCommand_reverserdecrease( TTrain *Train, command_data const &Command ) { + + if( Command.action == GLFW_PRESS ) { + + if( Train->mvOccupied->DirectionBackward() ) { + // aktualizacja skrajnych pojazdów w składzie + if( ( Train->mvOccupied->ActiveDir ) + && ( Train->DynamicObject->Mechanik ) ) { + + Train->DynamicObject->Mechanik->CheckVehicles( Change_direction ); + } + } + } +} + +void TTrain::OnCommand_reverserforwardhigh( TTrain *Train, command_data const &Command ) { + + if( Command.action == GLFW_PRESS ) { + + OnCommand_reverserforward( Train, Command ); + OnCommand_reverserincrease( Train, Command ); + } +} + +void TTrain::OnCommand_reverserforward( TTrain *Train, command_data const &Command ) { + + if( Command.action == GLFW_PRESS ) { + // HACK: try to move the reverser one position back, in case it's set to "high forward" + OnCommand_reverserdecrease( Train, Command ); + + if( Train->mvOccupied->ActiveDir < 1 ) { + + while( ( Train->mvOccupied->ActiveDir < 1 ) + && ( true == Train->mvOccupied->DirectionForward() ) ) { + // all work is done in the header + } + // aktualizacja skrajnych pojazdów w składzie + if( ( Train->mvOccupied->ActiveDir == 1 ) + && ( Train->DynamicObject->Mechanik ) ) { + + Train->DynamicObject->Mechanik->CheckVehicles( Change_direction ); + } + } + } +} + +void TTrain::OnCommand_reverserneutral( TTrain *Train, command_data const &Command ) { + + if( Command.action == GLFW_PRESS ) { + + while( ( Train->mvOccupied->ActiveDir < 0 ) + && ( true == Train->mvOccupied->DirectionForward() ) ) { + // all work is done in the header + } + while( ( Train->mvOccupied->ActiveDir > 0 ) + && ( true == Train->mvOccupied->DirectionBackward() ) ) { + // all work is done in the header + } + } +} + +void TTrain::OnCommand_reverserbackward( TTrain *Train, command_data const &Command ) { + + if( Command.action == GLFW_PRESS ) { + + if( Train->mvOccupied->ActiveDir > -1 ) { + + while( ( Train->mvOccupied->ActiveDir > -1 ) + && ( true == Train->mvOccupied->DirectionBackward() ) ) { + // all work is done in the header + } + // aktualizacja skrajnych pojazdów w składzie + if( ( Train->mvOccupied->ActiveDir == -1 ) + && ( Train->DynamicObject->Mechanik ) ) { + + Train->DynamicObject->Mechanik->CheckVehicles( Change_direction ); + } + } + } +} + +void TTrain::OnCommand_alerteracknowledge( TTrain *Train, command_data const &Command ) { + + if( Command.action == GLFW_PRESS ) { + // visual feedback + Train->ggSecurityResetButton.UpdateValue( 1.0, Train->dsbSwitch ); + if( Train->CAflag == false ) { + Train->CAflag = true; + Train->mvOccupied->SecuritySystemReset(); + } + } + else if( Command.action == GLFW_RELEASE ) { + // visual feedback + Train->ggSecurityResetButton.UpdateValue( 0.0 ); + + Train->fCzuwakTestTimer = 0.0f; + if( TestFlag( Train->mvOccupied->SecuritySystem.Status, s_CAtest ) ) { + SetFlag( Train->mvOccupied->SecuritySystem.Status, -s_CAtest ); + Train->mvOccupied->s_CAtestebrake = false; + Train->mvOccupied->SecuritySystem.SystemBrakeCATestTimer = 0.0; + } + Train->CAflag = false; + } +} + +void TTrain::OnCommand_batterytoggle( TTrain *Train, command_data const &Command ) { + + if( Command.action == GLFW_PRESS ) { + // only reacting to press, so the switch doesn't flip back and forth if key is held down + if( false == Train->mvOccupied->Battery ) { + // turn on + OnCommand_batteryenable( Train, Command ); + } + else { + //turn off + OnCommand_batterydisable( Train, Command ); + } + } +} + +void TTrain::OnCommand_batteryenable( TTrain *Train, command_data const &Command ) { + + if( true == Train->mvOccupied->Battery ) { return; } // already on + + if( Command.action == GLFW_PRESS ) { + // ignore repeats + // wyłącznik jest też w SN61, ewentualnie załączać prąd na stałe z poziomu FIZ + if( Train->mvOccupied->BatterySwitch( true ) ) { + // bateria potrzebna np. do zapalenia świateł + if( Train->ggBatteryButton.SubModel ) { + Train->ggBatteryButton.UpdateValue( 1.0, Train->dsbSwitch ); + } + // side-effects + if( Train->mvOccupied->LightsPosNo > 0 ) { + Train->SetLights(); + } + if( TestFlag( Train->mvOccupied->SecuritySystem.SystemType, 2 ) ) { + // Ra: znowu w kabinie jest coś, co być nie powinno! + SetFlag( Train->mvOccupied->SecuritySystem.Status, s_active ); + SetFlag( Train->mvOccupied->SecuritySystem.Status, s_SHPalarm ); + } + } + } +} + +void TTrain::OnCommand_batterydisable( TTrain *Train, command_data const &Command ) { + + if( false == Train->mvOccupied->Battery ) { return; } // already off + + if( Command.action == GLFW_PRESS ) { + // ignore repeats + if( Train->mvOccupied->BatterySwitch( false ) ) { + // ewentualnie zablokować z FIZ, np. w samochodach się nie odłącza akumulatora + if( Train->ggBatteryButton.SubModel ) { + Train->ggBatteryButton.UpdateValue( 0.0, Train->dsbSwitch ); + } + // side-effects + if( false == Train->mvControlled->ConverterFlag ) { + // if there's no (low voltage) power source left, drop pantographs + Train->mvControlled->PantFront( false ); + Train->mvControlled->PantRear( false ); + } + } + } +} + +void TTrain::OnCommand_pantographtogglefront( TTrain *Train, command_data const &Command ) { + + if( Command.action == GLFW_PRESS ) { + // only reacting to press, so the switch doesn't flip back and forth if key is held down + if( false == Train->mvControlled->PantFrontUp ) { + // turn on... + OnCommand_pantographraisefront( Train, Command ); + } + else { + // ...or turn off + OnCommand_pantographlowerfront( Train, Command ); + } + } + else if( Command.action == GLFW_RELEASE ) { + // impulse switches return automatically to neutral position + // NOTE: this routine is used also by dedicated raise and lower commands + if( Train->mvOccupied->PantSwitchType == "impulse" ) { + if( Train->ggPantFrontButton.SubModel ) + Train->ggPantFrontButton.UpdateValue( 0.0, Train->dsbSwitch ); + // NOTE: currently we animate the selectable pantograph control based on standard key presses + // TODO: implement actual selection control, and refactor handling this control setup in a separate method + if( Train->ggPantSelectedButton.SubModel ) + Train->ggPantSelectedButton.UpdateValue( 0.0, Train->dsbSwitch ); + // also the switch off button, in cabs which have it + if( Train->ggPantFrontButtonOff.SubModel ) + Train->ggPantFrontButtonOff.UpdateValue( 0.0, Train->dsbSwitch ); + if( Train->ggPantSelectedDownButton.SubModel ) { + // NOTE: currently we animate the selectable pantograph control based on standard key presses + // TODO: implement actual selection control, and refactor handling this control setup in a separate method + Train->ggPantSelectedDownButton.UpdateValue( 0.0, Train->dsbSwitch ); + } + } + } +} + +void TTrain::OnCommand_pantographtogglerear( TTrain *Train, command_data const &Command ) { + + if( Command.action == GLFW_PRESS ) { + // only reacting to press, so the switch doesn't flip back and forth if key is held down + if( false == Train->mvControlled->PantRearUp ) { + // turn on... + OnCommand_pantographraiserear( Train, Command ); + } + else { + // ...or turn off + OnCommand_pantographlowerrear( Train, Command ); + } + } + else if( Command.action == GLFW_RELEASE ) { + // impulse switches return automatically to neutral position + // NOTE: this routine is used also by dedicated raise and lower commands + if( Train->mvOccupied->PantSwitchType == "impulse" ) { + if( Train->ggPantRearButton.SubModel ) + Train->ggPantRearButton.UpdateValue( 0.0, Train->dsbSwitch ); + // NOTE: currently we animate the selectable pantograph control based on standard key presses + // TODO: implement actual selection control, and refactor handling this control setup in a separate method + if( Train->ggPantSelectedButton.SubModel ) + Train->ggPantSelectedButton.UpdateValue( 0.0, Train->dsbSwitch ); + // also the switch off button, in cabs which have it + if( Train->ggPantRearButtonOff.SubModel ) + Train->ggPantRearButtonOff.UpdateValue( 0.0, Train->dsbSwitch ); + if( Train->ggPantSelectedDownButton.SubModel ) { + // NOTE: currently we animate the selectable pantograph control based on standard key presses + // TODO: implement actual selection control, and refactor handling this control setup in a separate method + Train->ggPantSelectedDownButton.UpdateValue( 0.0, Train->dsbSwitch ); + } + } + } +} + +void TTrain::OnCommand_pantographraisefront( TTrain *Train, command_data const &Command ) { + + if( Command.action == GLFW_PRESS ) { + // only reacting to press, so the switch doesn't flip back and forth if key is held down + // visual feedback + if( Train->ggPantFrontButton.SubModel ) + Train->ggPantFrontButton.UpdateValue( 1.0, Train->dsbSwitch ); + // NOTE: currently we animate the selectable pantograph control based on standard key presses + // TODO: implement actual selection control, and refactor handling this control setup in a separate method + if( Train->ggPantSelectedButton.SubModel ) + Train->ggPantSelectedButton.UpdateValue( 1.0, Train->dsbSwitch ); + // pantograph control can have two-button setup + if( Train->ggPantFrontButtonOff.SubModel ) + Train->ggPantFrontButtonOff.UpdateValue( 0.0, Train->dsbSwitch ); + // NOTE: currently we animate the selectable pantograph control based on standard key presses + // TODO: implement actual selection control, and refactor handling this control setup in a separate method + if( Train->ggPantSelectedDownButton.SubModel ) + Train->ggPantSelectedDownButton.UpdateValue( 0.0, Train->dsbSwitch ); + + if( true == Train->mvControlled->PantFrontUp ) { return; } // already up + + // TBD, TODO: impulse switch should only work when the power is on? + if( Train->mvControlled->PantFront( true ) ) { + Train->mvControlled->PantFrontSP = false; + } + } + else if( Command.action == GLFW_RELEASE ) { + // visual feedback + // NOTE: bit of a hax here, we're reusing button reset routine so we don't need a copy in every branch + OnCommand_pantographtogglefront( Train, Command ); + } +} + +void TTrain::OnCommand_pantographraiserear( TTrain *Train, command_data const &Command ) { + + if( Command.action == GLFW_PRESS ) { + // only reacting to press, so the switch doesn't flip back and forth if key is held down + // visual feedback + if( Train->ggPantRearButton.SubModel ) + Train->ggPantRearButton.UpdateValue( 1.0, Train->dsbSwitch ); + // NOTE: currently we animate the selectable pantograph control based on standard key presses + // TODO: implement actual selection control, and refactor handling this control setup in a separate method + if( Train->ggPantSelectedButton.SubModel ) + Train->ggPantSelectedButton.UpdateValue( 1.0, Train->dsbSwitch ); + // pantograph control can have two-button setup + if( Train->ggPantRearButtonOff.SubModel ) + Train->ggPantRearButtonOff.UpdateValue( 0.0, Train->dsbSwitch ); + // NOTE: currently we animate the selectable pantograph control based on standard key presses + // TODO: implement actual selection control, and refactor handling this control setup in a separate method + if( Train->ggPantSelectedDownButton.SubModel ) + Train->ggPantSelectedDownButton.UpdateValue( 0.0, Train->dsbSwitch ); + + if( true == Train->mvControlled->PantRearUp ) { return; } // already up + + // TBD, TODO: impulse switch should only work when the power is on? + if( Train->mvControlled->PantRear( true ) ) { + Train->mvControlled->PantRearSP = false; + } + } + else if( Command.action == GLFW_RELEASE ) { + // visual feedback + // NOTE: bit of a hax here, we're reusing button reset routine so we don't need a copy in every branch + OnCommand_pantographtogglerear( Train, Command ); + } +} + +void TTrain::OnCommand_pantographlowerfront( TTrain *Train, command_data const &Command ) { + + if( Command.action == GLFW_PRESS ) { + + if( Train->mvOccupied->PantSwitchType == "impulse" ) { + if( ( Train->ggPantFrontButtonOff.SubModel == nullptr ) + && ( Train->ggPantSelectedDownButton.SubModel == nullptr ) ) { + // with impulse buttons we expect a dedicated switch to lower the pantograph, and if the cabin lacks it + // then another control has to be used (like pantographlowerall) + // TODO: we should have a way to define presence of cab controls without having to bind these to 3d submodels + return; + } + } + + // visual feedback + if( Train->ggPantFrontButton.SubModel ) + Train->ggPantFrontButton.UpdateValue( 0.0, Train->dsbSwitch ); + // NOTE: currently we animate the selectable pantograph control based on standard key presses + // TODO: implement actual selection control, and refactor handling this control setup in a separate method + if( Train->ggPantSelectedButton.SubModel ) + Train->ggPantSelectedButton.UpdateValue( 0.0, Train->dsbSwitch ); + // pantograph control can have two-button setup + if( Train->ggPantFrontButtonOff.SubModel ) + Train->ggPantFrontButtonOff.UpdateValue( 1.0, Train->dsbSwitch ); + // NOTE: currently we animate the selectable pantograph control based on standard key presses + // TODO: implement actual selection control, and refactor handling this control setup in a separate method + if( Train->ggPantSelectedDownButton.SubModel ) + Train->ggPantSelectedDownButton.UpdateValue( 1.0, Train->dsbSwitch ); + + if( false == Train->mvControlled->PantFrontUp ) { return; } // already down + + // TBD, TODO: impulse switch should only work when the power is on? + if( Train->mvControlled->PantFront( false ) ) { + Train->mvControlled->PantFrontSP = false; + } + } + else if( Command.action == GLFW_RELEASE ) { + // visual feedback + // NOTE: bit of a hax here, we're reusing button reset routine so we don't need a copy in every branch + OnCommand_pantographtogglefront( Train, Command ); + } +} + +void TTrain::OnCommand_pantographlowerrear( TTrain *Train, command_data const &Command ) { + + if( Command.action == GLFW_PRESS ) { + + if( Train->mvOccupied->PantSwitchType == "impulse" ) { + if( ( Train->ggPantRearButtonOff.SubModel == nullptr ) + && ( Train->ggPantSelectedDownButton.SubModel == nullptr ) ) { + // with impulse buttons we expect a dedicated switch to lower the pantograph, and if the cabin lacks it + // then another control has to be used (like pantographlowerall) + // TODO: we should have a way to define presence of cab controls without having to bind these to 3d submodels + return; + } + } + + // visual feedback + if( Train->ggPantRearButton.SubModel ) + Train->ggPantRearButton.UpdateValue( 0.0, Train->dsbSwitch ); + // NOTE: currently we animate the selectable pantograph control based on standard key presses + // TODO: implement actual selection control, and refactor handling this control setup in a separate method + if( Train->ggPantSelectedButton.SubModel ) + Train->ggPantSelectedButton.UpdateValue( 0.0, Train->dsbSwitch ); + // pantograph control can have two-button setup + if( Train->ggPantRearButtonOff.SubModel ) + Train->ggPantRearButtonOff.UpdateValue( 1.0, Train->dsbSwitch ); + // NOTE: currently we animate the selectable pantograph control based on standard key presses + // TODO: implement actual selection control, and refactor handling this control setup in a separate method + if( Train->ggPantSelectedDownButton.SubModel ) + Train->ggPantSelectedDownButton.UpdateValue( 1.0, Train->dsbSwitch ); + + if( false == Train->mvControlled->PantRearUp ) { return; } // already down + + // TBD, TODO: impulse switch should only work when the power is on? + if( Train->mvControlled->PantRear( false ) ) { + Train->mvControlled->PantRearSP = false; + } + } + else if( Command.action == GLFW_RELEASE ) { + // visual feedback + // NOTE: bit of a hax here, we're reusing button reset routine so we don't need a copy in every branch + OnCommand_pantographtogglerear( Train, Command ); + } +} + +void TTrain::OnCommand_pantographlowerall( TTrain *Train, command_data const &Command ) { + + if( ( Train->ggPantAllDownButton.SubModel == nullptr ) + && ( Train->ggPantSelectedDownButton.SubModel == nullptr ) ) { + // TODO: expand definition of cab controls so we can know if the control is present without testing for presence of 3d switch + if( Command.action == GLFW_PRESS ) { + WriteLog( "Lower All Pantographs switch is missing, or wasn't defined" ); + } + return; + } + if( Command.action == GLFW_PRESS ) { + // press the button + // since we're just lowering all potential pantographs we don't need to test for state and effect + // front... + Train->mvControlled->PantFrontSP = false; + Train->mvControlled->PantFront( false ); + // ...and rear + Train->mvControlled->PantRearSP = false; + Train->mvControlled->PantRear( false ); + // visual feedback + if( Train->ggPantAllDownButton.SubModel ) + Train->ggPantAllDownButton.UpdateValue( 1.0, Train->dsbSwitch ); + if( Train->ggPantSelectedDownButton.SubModel ) { + Train->ggPantSelectedDownButton.UpdateValue( 1.0, Train->dsbSwitch ); + } + } + else if( Command.action == GLFW_RELEASE ) { + // release the button + // visual feedback + if( Train->ggPantAllDownButton.SubModel ) + Train->ggPantAllDownButton.UpdateValue( 0.0 ); + if( Train->ggPantSelectedDownButton.SubModel ) { + Train->ggPantSelectedDownButton.UpdateValue( 0.0 ); + } + } +} + +void TTrain::OnCommand_pantographcompressorvalvetoggle( TTrain *Train, command_data const &Command ) { + + if( ( Train->mvControlled->TrainType == dt_EZT ? + ( Train->mvControlled != Train->mvOccupied ) : + ( Train->mvOccupied->ActiveCab != 0 ) ) ) { + // tylko w maszynowym + return; + } + + if( Command.action == GLFW_PRESS ) { + // only react to press + if( Train->mvControlled->bPantKurek3 == false ) { + // connect pantographs with primary tank + Train->mvControlled->bPantKurek3 = true; + // visual feedback: + Train->ggPantCompressorValve.UpdateValue( 0.0 ); + } + else { + // connect pantograps with pantograph compressor + Train->mvControlled->bPantKurek3 = false; + // visual feedback: + Train->ggPantCompressorValve.UpdateValue( 1.0 ); + } + } +} + +void TTrain::OnCommand_pantographcompressoractivate( TTrain *Train, command_data const &Command ) { + + if( ( Train->mvControlled->TrainType == dt_EZT ? + ( Train->mvControlled != Train->mvOccupied ) : + ( Train->mvOccupied->ActiveCab != 0 ) ) ) { + // tylko w maszynowym + return; + } + + if( ( Train->mvControlled->PantPress > 4.8 ) + || ( false == Train->mvControlled->Battery ) ) { + // needs live power source and low enough pressure to work + return; + } + + if( Command.action != GLFW_RELEASE ) { + // press or hold to activate + Train->mvControlled->PantCompFlag = true; + // visual feedback: + Train->ggPantCompressorButton.UpdateValue( 1.0 ); + } + else { + // release to disable + Train->mvControlled->PantCompFlag = false; + // visual feedback: + Train->ggPantCompressorButton.UpdateValue( 0.0 ); + } +} + +void TTrain::OnCommand_linebreakertoggle( TTrain *Train, command_data const &Command ) { + + if( Command.action == GLFW_PRESS ) { + // press or hold... + if( Train->m_linebreakerstate == 0 ) { + // ...to close the circuit + // NOTE: bit of a dirty shortcut here + OnCommand_linebreakerclose( Train, Command ); + } + else if( Train->m_linebreakerstate == 1 ) { + // ...to open the circuit + OnCommand_linebreakeropen( Train, Command ); + } + } + else if( Command.action == GLFW_RELEASE ) { + // release... + if( ( Train->ggMainOnButton.SubModel != nullptr ) + || ( Train->mvControlled->TrainType == dt_EZT ) ) { + // only impulse switches react to release events; since we don't have switch type definition for the line breaker, + // we detect it from presence of relevant button, or presume such switch arrangement for EMUs + if( Train->m_linebreakerstate == 0 ) { + // ...after opening circuit, or holding for too short time to close it + OnCommand_linebreakeropen( Train, Command ); + } + else { + // ...after closing the circuit + // NOTE: bit of a dirty shortcut here + OnCommand_linebreakerclose( Train, Command ); + } + } + } +} + +void TTrain::OnCommand_linebreakeropen( TTrain *Train, command_data const &Command ) { + + if( Command.action == GLFW_PRESS ) { + // visual feedback + if( Train->ggMainOffButton.SubModel != nullptr ) { + // two separate switches to close and break the circuit + Train->ggMainOffButton.UpdateValue( 1.0, Train->dsbSwitch ); + } + else if( Train->ggMainButton.SubModel != nullptr ) { + // single two-state switch + // NOTE: we don't have switch type definition for the line breaker switch + // so for the time being we have hard coded "impulse" switches for all EMUs + // TODO: have proper switch type config for all switches, and put it in the cab switch descriptions, not in the .fiz + if( Train->mvControlled->TrainType == dt_EZT ) { + Train->ggMainButton.UpdateValue( 1.0, Train->dsbSwitch ); + } + else { + Train->ggMainButton.UpdateValue( 0.0, Train->dsbSwitch ); + } + } + else { + // fallback for cabs with no submodel + Train->ggMainButton.UpdateValue( 0.0, Train->dsbSwitch ); + } + // play sound immediately when the switch is hit, not after release + Train->fMainRelayTimer = 0.0f; + + if( Train->m_linebreakerstate == 0 ) { return; } // already in the desired state + // NOTE: we don't have switch type definition for the line breaker switch + // so for the time being we have hard coded "impulse" switches for all EMUs + // TODO: have proper switch type config for all switches, and put it in the cab switch descriptions, not in the .fiz + if( Train->mvControlled->TrainType == dt_EZT ) { + // a single impulse switch can't open the circuit, only close it + return; + } + + if( true == Train->mvControlled->MainSwitch( false ) ) { + Train->m_linebreakerstate = 0; + } + } + else if( Command.action == GLFW_RELEASE ) { + // visual feedback + // we don't exactly know which of the two buttons was used, so reset both + // for setup with two separate swiches + if( Train->ggMainOnButton.SubModel != nullptr ) { + Train->ggMainOnButton.UpdateValue( 0.0, Train->dsbSwitch ); + } + if( Train->ggMainOffButton.SubModel != nullptr ) { + Train->ggMainOffButton.UpdateValue( 0.0, Train->dsbSwitch ); + } + // and the two-state switch too, for good measure + if( Train->ggMainButton.SubModel != nullptr ) { + Train->ggMainButton.UpdateValue( 0.0, Train->dsbSwitch ); + } + } +} + +void TTrain::OnCommand_linebreakerclose( TTrain *Train, command_data const &Command ) { + + if( Command.action == GLFW_PRESS ) { + // visual feedback + if( Train->ggMainOnButton.SubModel != nullptr ) { + // two separate switches to close and break the circuit + Train->ggMainOnButton.UpdateValue( 1.0, Train->dsbSwitch ); + } + else if( Train->ggMainButton.SubModel != nullptr ) { + // single two-state switch + Train->ggMainButton.UpdateValue( 1.0, Train->dsbSwitch ); + } + else { + // fallback for cabs with no submodel + Train->ggMainButton.UpdateValue( 1.0, Train->dsbSwitch ); + } + + // the actual closing of the line breaker is handled in the train update routine + } + else if( Command.action == GLFW_RELEASE ) { + // visual feedback + if( Train->ggMainOnButton.SubModel != nullptr ) { + // setup with two separate switches + Train->ggMainOnButton.UpdateValue( 0.0, Train->dsbSwitch ); + } + // NOTE: we don't have switch type definition for the line breaker switch + // so for the time being we have hard coded "impulse" switches for all EMUs + // TODO: have proper switch type config for all switches, and put it in the cab switch descriptions, not in the .fiz + if( Train->mvControlled->TrainType == dt_EZT ) { + if( Train->ggMainButton.SubModel != nullptr ) { + Train->ggMainButton.UpdateValue( 0.0, Train->dsbSwitch ); + } + } + + if( Train->m_linebreakerstate == 1 ) { return; } // already in the desired state + + if( Train->m_linebreakerstate == 2 ) { + // we don't need to start the diesel twice, but the other types (with impulse switch setup) still need to be launched + if( ( Train->mvControlled->EngineType != TEngineType::DieselEngine ) + && ( Train->mvControlled->EngineType != TEngineType::DieselElectric ) ) { + // try to finalize state change of the line breaker, set the state based on the outcome + Train->m_linebreakerstate = ( + Train->mvControlled->MainSwitch( true ) ? + 1 : + 0 ); + } + } + // on button release reset the closing timer + Train->fMainRelayTimer = 0.0f; + } +} + +void TTrain::OnCommand_fuelpumptoggle( TTrain *Train, command_data const &Command ) { + + if( Command.action == GLFW_REPEAT ) { return; } + + if( Train->ggFuelPumpButton.type() == TGaugeType::push ) { + // impulse switch + // currently there's no off button so we always try to turn it on + OnCommand_fuelpumpenable( Train, Command ); + } + else { + // two-state switch + if( Command.action == GLFW_RELEASE ) { return; } + + if( false == Train->mvControlled->FuelPump.is_enabled ) { + // turn on + OnCommand_fuelpumpenable( Train, Command ); + } + else { + //turn off + OnCommand_fuelpumpdisable( Train, Command ); + } + } +} + +void TTrain::OnCommand_fuelpumpenable( TTrain *Train, command_data const &Command ) { + + if( Command.action == GLFW_REPEAT ) { return; } + + if( Train->ggFuelPumpButton.type() == TGaugeType::push ) { + // impulse switch + if( Command.action == GLFW_PRESS ) { + // visual feedback + Train->ggFuelPumpButton.UpdateValue( 1.0, Train->dsbSwitch ); + Train->mvControlled->FuelPumpSwitch( true ); + } + else if( Command.action == GLFW_RELEASE ) { + // visual feedback + Train->ggFuelPumpButton.UpdateValue( 0.0, Train->dsbSwitch ); + Train->mvControlled->FuelPumpSwitch( false ); + } + } + else { + // two-state switch, only cares about press events + if( Command.action == GLFW_PRESS ) { + // visual feedback + Train->ggFuelPumpButton.UpdateValue( 1.0, Train->dsbSwitch ); + Train->mvControlled->FuelPumpSwitch( true ); + Train->mvControlled->FuelPumpSwitchOff( false ); + } + } +} + +void TTrain::OnCommand_fuelpumpdisable( TTrain *Train, command_data const &Command ) { + + if( Command.action == GLFW_REPEAT ) { return; } + + if( Train->ggFuelPumpButton.type() == TGaugeType::push ) { + // impulse switch + // currently there's no disable return type switch + return; + } + else { + // two-state switch, only cares about press events + if( Command.action == GLFW_PRESS ) { + // visual feedback + Train->ggFuelPumpButton.UpdateValue( 0.0, Train->dsbSwitch ); + Train->mvControlled->FuelPumpSwitch( false ); + Train->mvControlled->FuelPumpSwitchOff( true ); + } + } +} + +void TTrain::OnCommand_oilpumptoggle( TTrain *Train, command_data const &Command ) { + + if( Command.action == GLFW_REPEAT ) { return; } + + if( Train->ggOilPumpButton.type() == TGaugeType::push ) { + // impulse switch + // currently there's no off button so we always try to turn it on + OnCommand_oilpumpenable( Train, Command ); + } + else { + // two-state switch + if( Command.action == GLFW_RELEASE ) { return; } + + if( false == Train->mvControlled->OilPump.is_enabled ) { + // turn on + OnCommand_oilpumpenable( Train, Command ); + } + else { + //turn off + OnCommand_oilpumpdisable( Train, Command ); + } + } +} + +void TTrain::OnCommand_oilpumpenable( TTrain *Train, command_data const &Command ) { + + if( Command.action == GLFW_REPEAT ) { return; } + + if( Train->ggOilPumpButton.type() == TGaugeType::push ) { + // impulse switch + if( Command.action == GLFW_PRESS ) { + // visual feedback + Train->ggOilPumpButton.UpdateValue( 1.0, Train->dsbSwitch ); + Train->mvControlled->OilPumpSwitch( true ); + } + else if( Command.action == GLFW_RELEASE ) { + // visual feedback + Train->ggOilPumpButton.UpdateValue( 0.0, Train->dsbSwitch ); + Train->mvControlled->OilPumpSwitch( false ); + } + } + else { + // two-state switch, only cares about press events + if( Command.action == GLFW_PRESS ) { + // visual feedback + Train->ggOilPumpButton.UpdateValue( 1.0, Train->dsbSwitch ); + Train->mvControlled->OilPumpSwitch( true ); + Train->mvControlled->OilPumpSwitchOff( false ); + } + } +} + +void TTrain::OnCommand_oilpumpdisable( TTrain *Train, command_data const &Command ) { + + if( Command.action == GLFW_REPEAT ) { return; } + + if( Train->ggOilPumpButton.type() == TGaugeType::push ) { + // impulse switch + // currently there's no disable return type switch + return; + } + else { + // two-state switch, only cares about press events + if( Command.action == GLFW_PRESS ) { + // visual feedback + Train->ggOilPumpButton.UpdateValue( 0.0, Train->dsbSwitch ); + Train->mvControlled->OilPumpSwitch( false ); + Train->mvControlled->OilPumpSwitchOff( true ); + } + } +} + +void TTrain::OnCommand_waterheaterbreakertoggle( TTrain *Train, command_data const &Command ) { + + if( Command.action == GLFW_PRESS ) { + // only reacting to press, so the switch doesn't flip back and forth if key is held down + if( false == Train->mvControlled->WaterHeater.breaker ) { + // turn on + OnCommand_waterheaterbreakerclose( Train, Command ); + } + else { + //turn off + OnCommand_waterheaterbreakeropen( Train, Command ); + } + } +} + +void TTrain::OnCommand_waterheaterbreakerclose( TTrain *Train, command_data const &Command ) { + + if( Command.action == GLFW_PRESS ) { + // visual feedback + Train->ggWaterHeaterBreakerButton.UpdateValue( 1.0, Train->dsbSwitch ); + + if( true == Train->mvControlled->WaterHeater.breaker ) { return; } // already enabled + + Train->mvControlled->WaterHeaterBreakerSwitch( true ); + } +} + +void TTrain::OnCommand_waterheaterbreakeropen( TTrain *Train, command_data const &Command ) { + + if( Command.action == GLFW_PRESS ) { + // visual feedback + Train->ggWaterHeaterBreakerButton.UpdateValue( 0.0, Train->dsbSwitch ); + + if( false == Train->mvControlled->WaterHeater.breaker ) { return; } // already enabled + + Train->mvControlled->WaterHeaterBreakerSwitch( false ); + } +} + +void TTrain::OnCommand_waterheatertoggle( TTrain *Train, command_data const &Command ) { + + if( Command.action == GLFW_PRESS ) { + // only reacting to press, so the switch doesn't flip back and forth if key is held down + if( false == Train->mvControlled->WaterHeater.is_enabled ) { + // turn on + OnCommand_waterheaterenable( Train, Command ); + } + else { + //turn off + OnCommand_waterheaterdisable( Train, Command ); + } + } +} + +void TTrain::OnCommand_waterheaterenable( TTrain *Train, command_data const &Command ) { + + if( Command.action == GLFW_PRESS ) { + // visual feedback + Train->ggWaterHeaterButton.UpdateValue( 1.0, Train->dsbSwitch ); + + if( true == Train->mvControlled->WaterHeater.is_enabled ) { return; } // already enabled + + Train->mvControlled->WaterHeaterSwitch( true ); + } +} + +void TTrain::OnCommand_waterheaterdisable( TTrain *Train, command_data const &Command ) { + + if( Command.action == GLFW_PRESS ) { + // visual feedback + Train->ggWaterHeaterButton.UpdateValue( 0.0, Train->dsbSwitch ); + + if( false == Train->mvControlled->WaterHeater.is_enabled ) { return; } // already disabled + + Train->mvControlled->WaterHeaterSwitch( false ); + } +} + +void TTrain::OnCommand_waterpumpbreakertoggle( TTrain *Train, command_data const &Command ) { + + if( Command.action == GLFW_PRESS ) { + // only reacting to press, so the switch doesn't flip back and forth if key is held down + if( false == Train->mvControlled->WaterPump.breaker ) { + // turn on + OnCommand_waterpumpbreakerclose( Train, Command ); + } + else { + //turn off + OnCommand_waterpumpbreakeropen( Train, Command ); + } + } +} + +void TTrain::OnCommand_waterpumpbreakerclose( TTrain *Train, command_data const &Command ) { + + if( Command.action == GLFW_PRESS ) { + // visual feedback + Train->ggWaterPumpBreakerButton.UpdateValue( 1.0, Train->dsbSwitch ); + + if( true == Train->mvControlled->WaterPump.breaker ) { return; } // already enabled + + Train->mvControlled->WaterPumpBreakerSwitch( true ); + } +} + +void TTrain::OnCommand_waterpumpbreakeropen( TTrain *Train, command_data const &Command ) { + + if( Command.action == GLFW_PRESS ) { + // visual feedback + Train->ggWaterPumpBreakerButton.UpdateValue( 0.0, Train->dsbSwitch ); + + if( false == Train->mvControlled->WaterPump.breaker ) { return; } // already enabled + + Train->mvControlled->WaterPumpBreakerSwitch( false ); + } +} + +void TTrain::OnCommand_waterpumptoggle( TTrain *Train, command_data const &Command ) { + + if( Command.action == GLFW_REPEAT ) { return; } + + if( Train->ggWaterPumpButton.type() == TGaugeType::push ) { + // impulse switch + // currently there's no off button so we always try to turn it on + OnCommand_waterpumpenable( Train, Command ); + } + else { + // two-state switch + if( Command.action == GLFW_RELEASE ) { return; } + + if( false == Train->mvControlled->WaterPump.is_enabled ) { + // turn on + OnCommand_waterpumpenable( Train, Command ); + } + else { + //turn off + OnCommand_waterpumpdisable( Train, Command ); + } + } +} + +void TTrain::OnCommand_waterpumpenable( TTrain *Train, command_data const &Command ) { + + if( Command.action == GLFW_REPEAT ) { return; } + + if( Train->ggWaterPumpButton.type() == TGaugeType::push ) { + // impulse switch + if( Command.action == GLFW_PRESS ) { + // visual feedback + Train->ggWaterPumpButton.UpdateValue( 1.0, Train->dsbSwitch ); + Train->mvControlled->WaterPumpSwitch( true ); + } + else if( Command.action == GLFW_RELEASE ) { + // visual feedback + Train->ggWaterPumpButton.UpdateValue( 0.0, Train->dsbSwitch ); + Train->mvControlled->WaterPumpSwitch( false ); + } + } + else { + // two-state switch, only cares about press events + if( Command.action == GLFW_PRESS ) { + // visual feedback + Train->ggWaterPumpButton.UpdateValue( 1.0, Train->dsbSwitch ); + Train->mvControlled->WaterPumpSwitch( true ); + Train->mvControlled->WaterPumpSwitchOff( false ); + } + } +} + +void TTrain::OnCommand_waterpumpdisable( TTrain *Train, command_data const &Command ) { + + if( Command.action == GLFW_REPEAT ) { return; } + + if( Train->ggWaterPumpButton.type() == TGaugeType::push ) { + // impulse switch + // currently there's no disable return type switch + return; + } + else { + // two-state switch, only cares about press events + if( Command.action == GLFW_PRESS ) { + // visual feedback + Train->ggWaterPumpButton.UpdateValue( 0.0, Train->dsbSwitch ); + Train->mvControlled->WaterPumpSwitch( false ); + Train->mvControlled->WaterPumpSwitchOff( true ); + } + } +} + +void TTrain::OnCommand_watercircuitslinktoggle( TTrain *Train, command_data const &Command ) { + + if( Command.action == GLFW_PRESS ) { + // only reacting to press, so the switch doesn't flip back and forth if key is held down + if( false == Train->mvControlled->WaterCircuitsLink ) { + // turn on + OnCommand_watercircuitslinkenable( Train, Command ); + } + else { + //turn off + OnCommand_watercircuitslinkdisable( Train, Command ); + } + } +} + +void TTrain::OnCommand_watercircuitslinkenable( TTrain *Train, command_data const &Command ) { + + if( Command.action == GLFW_PRESS ) { + // visual feedback + Train->ggWaterCircuitsLinkButton.UpdateValue( 1.0, Train->dsbSwitch ); + + if( true == Train->mvControlled->WaterCircuitsLink ) { return; } // already enabled + + Train->mvControlled->WaterCircuitsLinkSwitch( true ); + } +} + +void TTrain::OnCommand_watercircuitslinkdisable( TTrain *Train, command_data const &Command ) { + + if( Command.action == GLFW_PRESS ) { + // visual feedback + Train->ggWaterCircuitsLinkButton.UpdateValue( 0.0, Train->dsbSwitch ); + + if( false == Train->mvControlled->WaterCircuitsLink ) { return; } // already disabled + + Train->mvControlled->WaterCircuitsLinkSwitch( false ); + } +} + +void TTrain::OnCommand_convertertoggle( TTrain *Train, command_data const &Command ) { + + if( Command.action == GLFW_PRESS ) { + // only reacting to press, so the switch doesn't flip back and forth if key is held down + if( ( false == Train->mvControlled->ConverterAllow ) + && ( Train->ggConverterButton.GetValue() < 0.5 ) ) { + // turn on + OnCommand_converterenable( Train, Command ); + } + else { + //turn off + OnCommand_converterdisable( Train, Command ); + } + } + else if( Command.action == GLFW_RELEASE ) { + // on button release... + if( Train->mvOccupied->ConvSwitchType == "impulse" ) { + // ...return switches to start position if applicable + Train->ggConverterButton.UpdateValue( 0.0, Train->dsbSwitch ); + Train->ggConverterOffButton.UpdateValue( 0.0, Train->dsbSwitch ); + } + } +} + +void TTrain::OnCommand_converterenable( TTrain *Train, command_data const &Command ) { + + if( Train->mvControlled->ConverterStart == start_t::automatic ) { + // let the automatic thing do its automatic thing... + return; + } + + if( Command.action == GLFW_PRESS ) { + // visual feedback + Train->ggConverterButton.UpdateValue( 1.0, Train->dsbSwitch ); + + if( true == Train->mvControlled->ConverterAllow ) { return; } // already enabled + + // impulse type switch has no effect if there's no power + // NOTE: this is most likely setup wrong, but the whole thing is smoke and mirrors anyway + if( ( Train->mvOccupied->ConvSwitchType != "impulse" ) + || ( Train->mvControlled->Mains ) ) { + // won't start if the line breaker button is still held + if( true == Train->mvControlled->ConverterSwitch( true ) ) { + // side effects + // control the compressor, if it's paired with the converter + if( Train->mvControlled->CompressorPower == 2 ) { + // hunter-091012: tak jest poprawnie + Train->mvControlled->CompressorSwitch( true ); + } + } + } + } + else if( Command.action == GLFW_RELEASE ) { + // potentially reset impulse switch position, using shared code branch + OnCommand_convertertoggle( Train, Command ); + } +} + +void TTrain::OnCommand_converterdisable( TTrain *Train, command_data const &Command ) { + + if( Train->mvControlled->ConverterStart == start_t::automatic ) { + // let the automatic thing do its automatic thing... + return; + } + + if( Command.action == GLFW_PRESS ) { + // visual feedback + Train->ggConverterButton.UpdateValue( 0.0, Train->dsbSwitch ); + if( Train->ggConverterOffButton.SubModel != nullptr ) { + Train->ggConverterOffButton.UpdateValue( 1.0, Train->dsbSwitch ); + } + + if( false == Train->mvControlled->ConverterAllow ) { return; } // already disabled + + if( true == Train->mvControlled->ConverterSwitch( false ) ) { + // side effects + // control the compressor, if it's paired with the converter + if( Train->mvControlled->CompressorPower == 2 ) { + // hunter-091012: tak jest poprawnie + Train->mvControlled->CompressorSwitch( false ); + } + if( ( Train->mvControlled->TrainType == dt_EZT ) + && ( false == TestFlag( Train->mvControlled->EngDmgFlag, 4 ) ) ) { + Train->mvControlled->ConvOvldFlag = false; + } + // if there's no (low voltage) power source left, drop pantographs + if( false == Train->mvControlled->Battery ) { + Train->mvControlled->PantFront( false ); + Train->mvControlled->PantRear( false ); + } + } + } + else if( Command.action == GLFW_RELEASE ) { + // potentially reset impulse switch position, using shared code branch + OnCommand_convertertoggle( Train, Command ); + } +} + +void TTrain::OnCommand_convertertogglelocal( TTrain *Train, command_data const &Command ) { + + if( Train->mvOccupied->ConverterStart == start_t::automatic ) { + // let the automatic thing do its automatic thing... + return; + } + if( Train->ggConverterLocalButton.SubModel == nullptr ) { + return; + } + + if( Command.action == GLFW_PRESS ) { + // only reacting to press, so the switch doesn't flip back and forth if key is held down + if( ( false == Train->mvOccupied->ConverterAllowLocal ) + && ( Train->ggConverterLocalButton.GetValue() < 0.5 ) ) { + // turn on + // visual feedback + Train->ggConverterLocalButton.UpdateValue( 1.0, Train->dsbSwitch ); + // effect + Train->mvOccupied->ConverterAllowLocal = true; +/* + if( true == Train->mvControlled->ConverterSwitch( true, range::local ) ) { + // side effects + // control the compressor, if it's paired with the converter + if( Train->mvControlled->CompressorPower == 2 ) { + // hunter-091012: tak jest poprawnie + Train->mvControlled->CompressorSwitch( true, range::local ); + } + } +*/ + } + else { + //turn off + // visual feedback + Train->ggConverterLocalButton.UpdateValue( 0.0, Train->dsbSwitch ); + // effect + Train->mvOccupied->ConverterAllowLocal = false; +/* + if( true == Train->mvControlled->ConverterSwitch( false, range::local ) ) { + // side effects + // control the compressor, if it's paired with the converter + if( Train->mvControlled->CompressorPower == 2 ) { + // hunter-091012: tak jest poprawnie + Train->mvControlled->CompressorSwitch( false, range::local ); + } + // if there's no (low voltage) power source left, drop pantographs + if( false == Train->mvControlled->Battery ) { + Train->mvControlled->PantFront( false, range::local ); + Train->mvControlled->PantRear( false, range::local ); + } + } +*/ + } + } +} + +void TTrain::OnCommand_converteroverloadrelayreset( TTrain *Train, command_data const &Command ) { + + if( Train->ggConverterFuseButton.SubModel == nullptr ) { + if( Command.action == GLFW_PRESS ) { + WriteLog( "Converter Overload Relay Reset button is missing, or wasn't defined" ); + } +// return; + } + + if( Command.action == GLFW_PRESS ) { + // visual feedback + Train->ggConverterFuseButton.UpdateValue( 1.0, Train->dsbSwitch ); + + if( ( Train->mvControlled->Mains == false ) + && ( Train->ggConverterButton.GetValue() < 0.05 ) + && ( Train->mvControlled->TrainType != dt_EZT ) ) { + Train->mvControlled->ConvOvldFlag = false; + } + } + else if( Command.action == GLFW_RELEASE ) { + // visual feedback + Train->ggConverterFuseButton.UpdateValue( 0.0, Train->dsbSwitch ); + } +} + +void TTrain::OnCommand_compressortoggle( TTrain *Train, command_data const &Command ) { + + if( Command.action == GLFW_PRESS ) { + // only reacting to press, so the switch doesn't flip back and forth if key is held down + if( false == Train->mvControlled->CompressorAllow ) { + // turn on + OnCommand_compressorenable( Train, Command ); + } + else { + //turn off + OnCommand_compressordisable( Train, Command ); + } + } +/* + // disabled because we don't have yet support for compressor switch type definition + else if( Command.action == GLFW_RELEASE ) { + // on button release... + if( Train->mvOccupied->CompSwitchType == "impulse" ) { + // ...return switches to start position if applicable + Train->ggCompressorButton.UpdateValue( 0.0, Train->dsbSwitch ); + Train->ggCompressorOffButton.UpdateValue( 0.0, Train->dsbSwitch ); + } + } +*/ +} + +void TTrain::OnCommand_compressorenable( TTrain *Train, command_data const &Command ) { + + if( Train->mvControlled->CompressorPower >= 2 ) { + return; + } + + if( Command.action == GLFW_PRESS ) { + // visual feedback + Train->ggCompressorButton.UpdateValue( 1.0, Train->dsbSwitch ); + + if( true == Train->mvControlled->CompressorAllow ) { return; } // already enabled + + // impulse type switch has no effect if there's no power + // NOTE: this is most likely setup wrong, but the whole thing is smoke and mirrors anyway +// if( ( Train->mvOccupied->CompSwitchType != "impulse" ) +// || ( Train->mvControlled->Mains ) ) { + + Train->mvControlled->CompressorSwitch( true ); +// } + } + else if( Command.action == GLFW_RELEASE ) { + // potentially reset impulse switch position, using shared code branch + OnCommand_compressortoggle( Train, Command ); + } + +} + +void TTrain::OnCommand_compressordisable( TTrain *Train, command_data const &Command ) { + + if( Train->mvControlled->CompressorPower >= 2 ) { + return; + } + + if( Command.action == GLFW_PRESS ) { + // visual feedback + Train->ggCompressorButton.UpdateValue( 0.0, Train->dsbSwitch ); +/* + if( Train->ggCompressorOffButton.SubModel != nullptr ) { + Train->ggCompressorOffButton.UpdateValue( 1.0, Train->dsbSwitch ); + } +*/ + if( false == Train->mvControlled->CompressorAllow ) { return; } // already disabled + + Train->mvControlled->CompressorSwitch( false ); + } + else if( Command.action == GLFW_RELEASE ) { + // potentially reset impulse switch position, using shared code branch + OnCommand_compressortoggle( Train, Command ); + } +} + +void TTrain::OnCommand_compressortogglelocal( TTrain *Train, command_data const &Command ) { + + if( Train->mvOccupied->CompressorPower >= 2 ) { + return; + } + if( Train->ggCompressorLocalButton.SubModel == nullptr ) { + return; + } + + if( Command.action == GLFW_PRESS ) { + // only reacting to press, so the switch doesn't flip back and forth if key is held down + if( false == Train->mvOccupied->CompressorAllowLocal ) { + // turn on + // visual feedback + Train->ggCompressorLocalButton.UpdateValue( 1.0, Train->dsbSwitch ); + // effect + Train->mvOccupied->CompressorAllowLocal = true; + } + else { + // turn off + // visual feedback + Train->ggCompressorLocalButton.UpdateValue( 0.0, Train->dsbSwitch ); + // effect + Train->mvOccupied->CompressorAllowLocal = false; + } + } +} + +void TTrain::OnCommand_motorblowerstogglefront( TTrain *Train, command_data const &Command ) { + + if( Command.action == GLFW_REPEAT ) { return; } + + if( Train->ggMotorBlowersFrontButton.type() == TGaugeType::push ) { + // impulse switch + // currently there's no off button so we always try to turn it on + OnCommand_motorblowersenablefront( Train, Command ); + } + else { + // two-state switch + if( Command.action == GLFW_RELEASE ) { return; } + + if( false == Train->mvControlled->MotorBlowers[side::front].is_enabled ) { + // turn on + OnCommand_motorblowersenablefront( Train, Command ); + } + else { + //turn off + OnCommand_motorblowersdisablefront( Train, Command ); + } + } +} + +void TTrain::OnCommand_motorblowersenablefront( TTrain *Train, command_data const &Command ) { + + if( Command.action == GLFW_REPEAT ) { return; } + + if( Train->ggMotorBlowersFrontButton.type() == TGaugeType::push ) { + // impulse switch + if( Command.action == GLFW_PRESS ) { + // visual feedback + Train->ggMotorBlowersFrontButton.UpdateValue( 1.f, Train->dsbSwitch ); + Train->mvControlled->MotorBlowersSwitch( true, side::front ); + } + else if( Command.action == GLFW_RELEASE ) { + // visual feedback + Train->ggMotorBlowersFrontButton.UpdateValue( 0.f, Train->dsbSwitch ); + Train->mvControlled->MotorBlowersSwitch( false, side::front ); + } + } + else { + // two-state switch, only cares about press events + if( Command.action == GLFW_PRESS ) { + // visual feedback + Train->ggMotorBlowersFrontButton.UpdateValue( 1.f, Train->dsbSwitch ); + Train->mvControlled->MotorBlowersSwitch( true, side::front ); + Train->mvControlled->MotorBlowersSwitchOff( false, side::front ); + } + } +} + +void TTrain::OnCommand_motorblowersdisablefront( TTrain *Train, command_data const &Command ) { + + if( Command.action == GLFW_REPEAT ) { return; } + + if( Train->ggMotorBlowersFrontButton.type() == TGaugeType::push ) { + // impulse switch + // currently there's no disable return type switch + return; + } + else { + // two-state switch, only cares about press events + if( Command.action == GLFW_PRESS ) { + // visual feedback + Train->ggMotorBlowersFrontButton.UpdateValue( 0.f, Train->dsbSwitch ); + Train->mvControlled->MotorBlowersSwitch( false, side::front ); + Train->mvControlled->MotorBlowersSwitchOff( true, side::front ); + } + } +} + +void TTrain::OnCommand_motorblowerstogglerear( TTrain *Train, command_data const &Command ) { + + if( Command.action == GLFW_REPEAT ) { return; } + + if( Train->ggMotorBlowersRearButton.type() == TGaugeType::push ) { + // impulse switch + // currently there's no off button so we always try to turn it on + OnCommand_motorblowersenablerear( Train, Command ); + } + else { + // two-state switch + if( Command.action == GLFW_RELEASE ) { return; } + + if( false == Train->mvControlled->MotorBlowers[ side::rear ].is_enabled ) { + // turn on + OnCommand_motorblowersenablerear( Train, Command ); + } + else { + //turn off + OnCommand_motorblowersdisablerear( Train, Command ); + } + } +} + +void TTrain::OnCommand_motorblowersenablerear( TTrain *Train, command_data const &Command ) { + + if( Command.action == GLFW_REPEAT ) { return; } + + if( Train->ggMotorBlowersRearButton.type() == TGaugeType::push ) { + // impulse switch + if( Command.action == GLFW_PRESS ) { + // visual feedback + Train->ggMotorBlowersRearButton.UpdateValue( 1.f, Train->dsbSwitch ); + Train->mvControlled->MotorBlowersSwitch( true, side::rear ); + } + else if( Command.action == GLFW_RELEASE ) { + // visual feedback + Train->ggMotorBlowersRearButton.UpdateValue( 0.f, Train->dsbSwitch ); + Train->mvControlled->MotorBlowersSwitch( false, side::rear ); + } + } + else { + // two-state switch, only cares about press events + if( Command.action == GLFW_PRESS ) { + // visual feedback + Train->ggMotorBlowersRearButton.UpdateValue( 1.f, Train->dsbSwitch ); + Train->mvControlled->MotorBlowersSwitch( true, side::rear ); + Train->mvControlled->MotorBlowersSwitchOff( false, side::rear ); + } + } +} + +void TTrain::OnCommand_motorblowersdisablerear( TTrain *Train, command_data const &Command ) { + + if( Command.action == GLFW_REPEAT ) { return; } + + if( Train->ggMotorBlowersRearButton.type() == TGaugeType::push ) { + // impulse switch + // currently there's no disable return type switch + return; + } + else { + // two-state switch, only cares about press events + if( Command.action == GLFW_PRESS ) { + // visual feedback + Train->ggMotorBlowersRearButton.UpdateValue( 0.f, Train->dsbSwitch ); + Train->mvControlled->MotorBlowersSwitch( false, side::rear ); + Train->mvControlled->MotorBlowersSwitchOff( true, side::rear ); + } + } +} + +void TTrain::OnCommand_motorblowersdisableall( TTrain *Train, command_data const &Command ) { + + if( Command.action == GLFW_REPEAT ) { return; } + + if( Train->ggMotorBlowersAllOffButton.type() == TGaugeType::push ) { + // impulse switch + if( Command.action == GLFW_PRESS ) { + // visual feedback + Train->ggMotorBlowersAllOffButton.UpdateValue( 1.f, Train->dsbSwitch ); + Train->mvControlled->MotorBlowersSwitchOff( true, side::front ); + Train->mvControlled->MotorBlowersSwitchOff( true, side::rear ); + } + else if( Command.action == GLFW_RELEASE ) { + // visual feedback + Train->ggMotorBlowersAllOffButton.UpdateValue( 0.f, Train->dsbSwitch ); + Train->mvControlled->MotorBlowersSwitchOff( false, side::front ); + Train->mvControlled->MotorBlowersSwitchOff( false, side::rear ); + } + } + else { + // two-state switch, only cares about press events + // NOTE: generally this switch doesn't come in two-state form + if( Command.action == GLFW_PRESS ) { + if( Train->ggMotorBlowersAllOffButton.GetDesiredValue() < 0.5f ) { + // switch is off, activate + Train->mvControlled->MotorBlowersSwitchOff( true, side::front ); + Train->mvControlled->MotorBlowersSwitchOff( true, side::rear ); + // visual feedback + Train->ggMotorBlowersRearButton.UpdateValue( 1.f, Train->dsbSwitch ); + } + else { + // deactivate + Train->mvControlled->MotorBlowersSwitchOff( false, side::front ); + Train->mvControlled->MotorBlowersSwitchOff( false, side::rear ); + // visual feedback + Train->ggMotorBlowersRearButton.UpdateValue( 0.f, Train->dsbSwitch ); + } + } + } +} + +void TTrain::OnCommand_motorconnectorsopen( TTrain *Train, command_data const &Command ) { + + // TODO: don't rely on presense of 3d model to determine presence of the switch + if( Train->ggStLinOffButton.SubModel == nullptr ) { + if( Command.action == GLFW_PRESS ) { + WriteLog( "Open Motor Power Connectors button is missing, or wasn't defined" ); + } + return; + } + // HACK: because we don't have modeled actual circuits this is a simplification of the real mechanics + // namely, pressing the button will flip it in the entire unit, which isn't exactly physically possible + if( Command.action == GLFW_PRESS ) { + // button works while it's held down but we can ignore repeats + if( false == Train->mvControlled->StLinSwitchOff ) { + // open the connectors + // visual feedback + Train->ggStLinOffButton.UpdateValue( 1.0, Train->dsbSwitch ); + + Train->mvControlled->StLinSwitchOff = true; + Train->set_paired_open_motor_connectors_button( true ); + } + else { + // potentially close the connectors + OnCommand_motorconnectorsclose( Train, Command ); + } + } + else if( Command.action == GLFW_RELEASE ) { + // button released + if( Train->mvControlled->StLinSwitchType != "toggle" ) { + // default button type (impulse) ceases its work on button release + // visual feedback + Train->ggStLinOffButton.UpdateValue( 0.0, Train->dsbSwitch ); + + Train->mvControlled->StLinSwitchOff = false; + Train->set_paired_open_motor_connectors_button( false ); + } + } +} + +void TTrain::OnCommand_motorconnectorsclose( TTrain *Train, command_data const &Command ) { + + // TODO: don't rely on presense of 3d model to determine presence of the switch + if( Train->ggStLinOffButton.SubModel == nullptr ) { + if( Command.action == GLFW_PRESS ) { + WriteLog( "Open Motor Power Connectors button is missing, or wasn't defined" ); + } + return; + } + + if( Command.action == GLFW_PRESS ) { + if( Train->mvControlled->StLinSwitchType == "toggle" ) { + // default type of button (impulse) has only one effect on press, but the toggle type can toggle the state + // visual feedback + Train->ggStLinOffButton.UpdateValue( 0.0, Train->dsbSwitch ); + } + + if( false == Train->mvControlled->StLinSwitchOff ) { return; } // already closed + + Train->mvControlled->StLinSwitchOff = false; + Train->set_paired_open_motor_connectors_button( false ); + } +} + +void TTrain::OnCommand_motordisconnect( TTrain *Train, command_data const &Command ) { + + if( ( Train->mvControlled->TrainType == dt_EZT ? + ( Train->mvControlled != Train->mvOccupied ) : + ( Train->mvOccupied->ActiveCab != 0 ) ) ) { + // tylko w maszynowym + return; + } + + if( Command.action == GLFW_PRESS ) { + Train->mvControlled->CutOffEngine(); + } +} + +void TTrain::OnCommand_motoroverloadrelaythresholdtoggle( TTrain *Train, command_data const &Command ) { + + if( Command.action == GLFW_PRESS ) { + // only reacting to press, so the switch doesn't flip back and forth if key is held down + if( ( true == Train->mvControlled->ShuntModeAllow ? + ( false == Train->mvControlled->ShuntMode ) : + ( Train->mvControlled->Imax < Train->mvControlled->ImaxHi ) ) ) { + // turn on + OnCommand_motoroverloadrelaythresholdsethigh( Train, Command ); + } + else { + //turn off + OnCommand_motoroverloadrelaythresholdsetlow( Train, Command ); + } + } +} + +void TTrain::OnCommand_motoroverloadrelaythresholdsetlow( TTrain *Train, command_data const &Command ) { + + if( Command.action == GLFW_PRESS ) { + // only reacting to press, so the switch doesn't flip back and forth if key is held down + if( true == Train->mvControlled->CurrentSwitch( false ) ) { + // visual feedback + Train->ggMaxCurrentCtrl.UpdateValue( 0.0, Train->dsbSwitch ); + } + } +} + +void TTrain::OnCommand_motoroverloadrelaythresholdsethigh( TTrain *Train, command_data const &Command ) { + + if( Command.action == GLFW_PRESS ) { + // only reacting to press, so the switch doesn't flip back and forth if key is held down + if( true == Train->mvControlled->CurrentSwitch( true ) ) { + // visual feedback + Train->ggMaxCurrentCtrl.UpdateValue( 1.0, Train->dsbSwitch ); + } + } +} + +void TTrain::OnCommand_motoroverloadrelayreset( TTrain *Train, command_data const &Command ) { + + if( Train->ggFuseButton.SubModel == nullptr ) { + if( Command.action == GLFW_PRESS ) { + WriteLog( "Motor Overload Relay Reset button is missing, or wasn't defined" ); + } +// return; + } + + if( Command.action == GLFW_PRESS ) { + // visual feedback + Train->ggFuseButton.UpdateValue( 1.0, Train->dsbSwitch ); + + Train->mvControlled->FuseOn(); + } + else if( Command.action == GLFW_RELEASE ) { + // visual feedback + Train->ggFuseButton.UpdateValue( 0.0, Train->dsbSwitch ); + } +} + +void TTrain::OnCommand_lightspresetactivatenext( TTrain *Train, command_data const &Command ) { + + if( Train->mvOccupied->LightsPosNo == 0 ) { + // lights are controlled by preset selector + return; + } + if( Command.action != GLFW_PRESS ) { + // one change per key press + return; + } + + if( ( Train->mvOccupied->LightsPos < Train->mvOccupied->LightsPosNo ) + || ( true == Train->mvOccupied->LightsWrap ) ) { + // active light preset is stored as value in range 1-LigthPosNo + Train->mvOccupied->LightsPos = ( + Train->mvOccupied->LightsPos < Train->mvOccupied->LightsPosNo ? + Train->mvOccupied->LightsPos + 1 : + 1 ); // wrap mode + + Train->SetLights(); + // visual feedback + if( Train->ggLightsButton.SubModel != nullptr ) { + Train->ggLightsButton.UpdateValue( Train->mvOccupied->LightsPos - 1, Train->dsbSwitch ); + } + } +} + +void TTrain::OnCommand_lightspresetactivateprevious( TTrain *Train, command_data const &Command ) { + + if( Train->mvOccupied->LightsPosNo == 0 ) { + // lights are controlled by preset selector + return; + } + if( Command.action != GLFW_PRESS ) { + // one change per key press + return; + } + + if( ( Train->mvOccupied->LightsPos > 1 ) + || ( true == Train->mvOccupied->LightsWrap ) ) { + // active light preset is stored as value in range 1-LigthPosNo + Train->mvOccupied->LightsPos = ( + Train->mvOccupied->LightsPos > 1 ? + Train->mvOccupied->LightsPos - 1 : + Train->mvOccupied->LightsPosNo ); // wrap mode + + Train->SetLights(); + // visual feedback + if( Train->ggLightsButton.SubModel != nullptr ) { + Train->ggLightsButton.UpdateValue( Train->mvOccupied->LightsPos - 1, Train->dsbSwitch ); + } + } +} + +void TTrain::OnCommand_headlighttoggleleft( TTrain *Train, command_data const &Command ) { + + int const vehicleside = + ( Train->mvOccupied->ActiveCab == 1 ? + side::front : + side::rear ); + + if( Command.action == GLFW_PRESS ) { + // only reacting to press, so the switch doesn't flip back and forth if key is held down + if( ( Train->DynamicObject->iLights[ vehicleside ] & light::headlight_left ) == 0 ) { + // turn on + OnCommand_headlightenableleft( Train, Command ); + } + else { + //turn off + OnCommand_headlightdisableleft( Train, Command ); + } + } +} + +void TTrain::OnCommand_headlightenableleft( TTrain *Train, command_data const &Command ) { + + if( Train->mvOccupied->LightsPosNo > 0 ) { + // lights are controlled by preset selector + return; + } + + if( Command.action == GLFW_PRESS ) { + // only reacting to press, so the switch doesn't flip back and forth if key is held down + int const vehicleside = + ( Train->mvOccupied->ActiveCab == 1 ? + side::front : + side::rear ); + + if( ( Train->DynamicObject->iLights[ vehicleside ] & light::headlight_left ) != 0 ) { return; } // already enabled + + Train->DynamicObject->iLights[ vehicleside ] ^= light::headlight_left; + // visual feedback + Train->ggLeftLightButton.UpdateValue( 1.0, Train->dsbSwitch ); + // if the light is controlled by 3-way switch, disable marker light + if( Train->ggLeftEndLightButton.SubModel == nullptr ) { + Train->DynamicObject->iLights[ vehicleside ] &= ~light::redmarker_left; + } + } +} + +void TTrain::OnCommand_headlightdisableleft( TTrain *Train, command_data const &Command ) { + + if( Train->mvOccupied->LightsPosNo > 0 ) { + // lights are controlled by preset selector + return; + } + + if( Command.action == GLFW_PRESS ) { + // only reacting to press, so the switch doesn't flip back and forth if key is held down + int const vehicleside = + ( Train->mvOccupied->ActiveCab == 1 ? + side::front : + side::rear ); + + if( ( Train->DynamicObject->iLights[ vehicleside ] & light::headlight_left ) == 0 ) { return; } // already disabled + + Train->DynamicObject->iLights[ vehicleside ] ^= light::headlight_left; + // visual feedback + Train->ggLeftLightButton.UpdateValue( 0.0, Train->dsbSwitch ); + } +} + +void TTrain::OnCommand_headlighttoggleright( TTrain *Train, command_data const &Command ) { + + int const vehicleside = + ( Train->mvOccupied->ActiveCab == 1 ? + side::front : + side::rear ); + + if( Command.action == GLFW_PRESS ) { + // only reacting to press, so the switch doesn't flip back and forth if key is held down + if( ( Train->DynamicObject->iLights[ vehicleside ] & light::headlight_right ) == 0 ) { + // turn on + OnCommand_headlightenableright( Train, Command ); + } + else { + //turn off + OnCommand_headlightdisableright( Train, Command ); + } + } +} + +void TTrain::OnCommand_headlightenableright( TTrain *Train, command_data const &Command ) { + + if( Train->mvOccupied->LightsPosNo > 0 ) { + // lights are controlled by preset selector + return; + } + + if( Command.action == GLFW_PRESS ) { + // only reacting to press, so the switch doesn't flip back and forth if key is held down + int const vehicleside = + ( Train->mvOccupied->ActiveCab == 1 ? + side::front : + side::rear ); + + if( ( Train->DynamicObject->iLights[ vehicleside ] & light::headlight_right ) != 0 ) { return; } // already enabled + + Train->DynamicObject->iLights[ vehicleside ] ^= light::headlight_right; + // visual feedback + Train->ggRightLightButton.UpdateValue( 1.0, Train->dsbSwitch ); + // if the light is controlled by 3-way switch, disable marker light + if( Train->ggRightEndLightButton.SubModel == nullptr ) { + Train->DynamicObject->iLights[ vehicleside ] &= ~light::redmarker_right; + } + } +} + +void TTrain::OnCommand_headlightdisableright( TTrain *Train, command_data const &Command ) { + + if( Train->mvOccupied->LightsPosNo > 0 ) { + // lights are controlled by preset selector + return; + } + + if( Command.action == GLFW_PRESS ) { + // only reacting to press, so the switch doesn't flip back and forth if key is held down + int const vehicleside = + ( Train->mvOccupied->ActiveCab == 1 ? + side::front : + side::rear ); + + if( ( Train->DynamicObject->iLights[ vehicleside ] & light::headlight_right ) == 0 ) { return; } // already disabled + + Train->DynamicObject->iLights[ vehicleside ] ^= light::headlight_right; + // visual feedback + Train->ggRightLightButton.UpdateValue( 0.0, Train->dsbSwitch ); + } +} + +void TTrain::OnCommand_headlighttoggleupper( TTrain *Train, command_data const &Command ) { + + int const vehicleside = + ( Train->mvOccupied->ActiveCab == 1 ? + side::front : + side::rear ); + + if( Command.action == GLFW_PRESS ) { + // only reacting to press, so the switch doesn't flip back and forth if key is held down + if( ( Train->DynamicObject->iLights[ vehicleside ] & light::headlight_upper ) == 0 ) { + // turn on + OnCommand_headlightenableupper( Train, Command ); + } + else { + //turn off + OnCommand_headlightdisableupper( Train, Command ); + } + } +} + +void TTrain::OnCommand_headlightenableupper( TTrain *Train, command_data const &Command ) { + + if( Train->mvOccupied->LightsPosNo > 0 ) { + // lights are controlled by preset selector + return; + } + + if( Command.action == GLFW_PRESS ) { + // only reacting to press, so the switch doesn't flip back and forth if key is held down + int const vehicleside = + ( Train->mvOccupied->ActiveCab == 1 ? + side::front : + side::rear ); + + if( ( Train->DynamicObject->iLights[ vehicleside ] & light::headlight_upper ) != 0 ) { return; } // already enabled + + Train->DynamicObject->iLights[ vehicleside ] ^= light::headlight_upper; + // visual feedback + Train->ggUpperLightButton.UpdateValue( 1.0, Train->dsbSwitch ); + } +} + +void TTrain::OnCommand_headlightdisableupper( TTrain *Train, command_data const &Command ) { + + if( Train->mvOccupied->LightsPosNo > 0 ) { + // lights are controlled by preset selector + return; + } + + if( Command.action == GLFW_PRESS ) { + // only reacting to press, so the switch doesn't flip back and forth if key is held down + int const vehicleside = + ( Train->mvOccupied->ActiveCab == 1 ? + side::front : + side::rear ); + + if( ( Train->DynamicObject->iLights[ vehicleside ] & light::headlight_upper ) == 0 ) { return; } // already disabled + + Train->DynamicObject->iLights[ vehicleside ] ^= light::headlight_upper; + // visual feedback + Train->ggUpperLightButton.UpdateValue( 0.0, Train->dsbSwitch ); + } +} + +void TTrain::OnCommand_redmarkertoggleleft( TTrain *Train, command_data const &Command ) { + + if( Command.action == GLFW_PRESS ) { + // only reacting to press, so the switch doesn't flip back and forth if key is held down + int const vehicleside = + ( Train->mvOccupied->ActiveCab == 1 ? + side::front : + side::rear ); + + if( ( Train->DynamicObject->iLights[ vehicleside ] & light::redmarker_left ) == 0 ) { + // turn on + OnCommand_redmarkerenableleft( Train, Command ); + } + else { + //turn off + OnCommand_redmarkerdisableleft( Train, Command ); + } + } +} + +void TTrain::OnCommand_redmarkerenableleft( TTrain *Train, command_data const &Command ) { + + if( Train->mvOccupied->LightsPosNo > 0 ) { + // lights are controlled by preset selector + return; + } + + if( Command.action == GLFW_PRESS ) { + // only reacting to press, so the switch doesn't flip back and forth if key is held down + int const vehicleside = + ( Train->mvOccupied->ActiveCab == 1 ? + side::front : + side::rear ); + + if( ( Train->DynamicObject->iLights[ vehicleside ] & light::redmarker_left ) != 0 ) { return; } // already enabled + + Train->DynamicObject->iLights[ vehicleside ] ^= light::redmarker_left; + // visual feedback + if( Train->ggLeftEndLightButton.SubModel != nullptr ) { + Train->ggLeftEndLightButton.UpdateValue( 1.0, Train->dsbSwitch ); + } + else { + // we interpret lack of dedicated switch as a sign the light is controlled with 3-way switch + // this is crude, but for now will do + Train->ggLeftLightButton.UpdateValue( -1.0, Train->dsbSwitch ); + // if the light is controlled by 3-way switch, disable the headlight + Train->DynamicObject->iLights[ vehicleside ] &= ~light::headlight_left; + } + } +} + +void TTrain::OnCommand_redmarkerdisableleft( TTrain *Train, command_data const &Command ) { + + if( Train->mvOccupied->LightsPosNo > 0 ) { + // lights are controlled by preset selector + return; + } + + if( Command.action == GLFW_PRESS ) { + // only reacting to press, so the switch doesn't flip back and forth if key is held down + int const vehicleside = + ( Train->mvOccupied->ActiveCab == 1 ? + side::front : + side::rear ); + + if( ( Train->DynamicObject->iLights[ vehicleside ] & light::redmarker_left ) == 0 ) { return; } // already disabled + + Train->DynamicObject->iLights[ vehicleside ] ^= light::redmarker_left; + // visual feedback + if( Train->ggLeftEndLightButton.SubModel != nullptr ) { + Train->ggLeftEndLightButton.UpdateValue( 0.0, Train->dsbSwitch ); + } + else { + // we interpret lack of dedicated switch as a sign the light is controlled with 3-way switch + // this is crude, but for now will do + Train->ggLeftLightButton.UpdateValue( 0.0, Train->dsbSwitch ); + } + } +} + +void TTrain::OnCommand_redmarkertoggleright( TTrain *Train, command_data const &Command ) { + + if( Command.action == GLFW_PRESS ) { + // only reacting to press, so the switch doesn't flip back and forth if key is held down + int const vehicleside = + ( Train->mvOccupied->ActiveCab == 1 ? + side::front : + side::rear ); + + if( ( Train->DynamicObject->iLights[ vehicleside ] & light::redmarker_right ) == 0 ) { + // turn on + OnCommand_redmarkerenableright( Train, Command ); + } + else { + //turn off + OnCommand_redmarkerdisableright( Train, Command ); + } + } +} + +void TTrain::OnCommand_redmarkerenableright( TTrain *Train, command_data const &Command ) { + + if( Train->mvOccupied->LightsPosNo > 0 ) { + // lights are controlled by preset selector + return; + } + + if( Command.action == GLFW_PRESS ) { + // only reacting to press, so the switch doesn't flip back and forth if key is held down + int const vehicleside = + ( Train->mvOccupied->ActiveCab == 1 ? + side::front : + side::rear ); + + if( ( Train->DynamicObject->iLights[ vehicleside ] & light::redmarker_right ) != 0 ) { return; } // already enabled + + Train->DynamicObject->iLights[ vehicleside ] ^= light::redmarker_right; + // visual feedback + if( Train->ggRightEndLightButton.SubModel != nullptr ) { + Train->ggRightEndLightButton.UpdateValue( 1.0, Train->dsbSwitch ); + } + else { + // we interpret lack of dedicated switch as a sign the light is controlled with 3-way switch + // this is crude, but for now will do + Train->ggRightLightButton.UpdateValue( -1.0, Train->dsbSwitch ); + // if the light is controlled by 3-way switch, disable the headlight + Train->DynamicObject->iLights[ vehicleside ] &= ~light::headlight_right; + } + } +} + +void TTrain::OnCommand_redmarkerdisableright( TTrain *Train, command_data const &Command ) { + + if( Train->mvOccupied->LightsPosNo > 0 ) { + // lights are controlled by preset selector + return; + } + + if( Command.action == GLFW_PRESS ) { + // only reacting to press, so the switch doesn't flip back and forth if key is held down + int const vehicleside = + ( Train->mvOccupied->ActiveCab == 1 ? + side::front : + side::rear ); + + if( ( Train->DynamicObject->iLights[ vehicleside ] & light::redmarker_right ) == 0 ) { return; } // already disabled + + Train->DynamicObject->iLights[ vehicleside ] ^= light::redmarker_right; + // visual feedback + if( Train->ggRightEndLightButton.SubModel != nullptr ) { + Train->ggRightEndLightButton.UpdateValue( 0.0, Train->dsbSwitch ); + } + else { + // we interpret lack of dedicated switch as a sign the light is controlled with 3-way switch + // this is crude, but for now will do + Train->ggRightLightButton.UpdateValue( 0.0, Train->dsbSwitch ); + } + } +} + +void TTrain::OnCommand_headlighttogglerearleft( TTrain *Train, command_data const &Command ) { + + if( Train->mvOccupied->LightsPosNo > 0 ) { + // lights are controlled by preset selector + return; + } + + int const vehicleside = + ( Train->mvOccupied->ActiveCab == 1 ? + side::rear : + side::front ); + + if( Command.action == GLFW_PRESS ) { + // NOTE: we toggle the light on opposite side, as 'rear right' is 'front left' on the rear end etc + // only reacting to press, so the switch doesn't flip back and forth if key is held down + if( ( Train->DynamicObject->iLights[ vehicleside ] & light::headlight_right ) == 0 ) { + // turn on + Train->DynamicObject->iLights[ vehicleside ] ^= light::headlight_right; + // visual feedback + Train->ggRearLeftLightButton.UpdateValue( 1.0, Train->dsbSwitch ); + } + else { + //turn off + Train->DynamicObject->iLights[ vehicleside ] ^= light::headlight_right; + // visual feedback + Train->ggRearLeftLightButton.UpdateValue( 0.0, Train->dsbSwitch ); + } + } +} + +void TTrain::OnCommand_headlighttogglerearright( TTrain *Train, command_data const &Command ) { + + if( Train->mvOccupied->LightsPosNo > 0 ) { + // lights are controlled by preset selector + return; + } + + int const vehicleside = + ( Train->mvOccupied->ActiveCab == 1 ? + side::rear : + side::front ); + + if( Command.action == GLFW_PRESS ) { + // NOTE: we toggle the light on opposite side, as 'rear right' is 'front left' on the rear end etc + // only reacting to press, so the switch doesn't flip back and forth if key is held down + if( ( Train->DynamicObject->iLights[ vehicleside ] & light::headlight_left ) == 0 ) { + // turn on + Train->DynamicObject->iLights[ vehicleside ] ^= light::headlight_left; + // visual feedback + Train->ggRearRightLightButton.UpdateValue( 1.0, Train->dsbSwitch ); + } + else { + //turn off + Train->DynamicObject->iLights[ vehicleside ] ^= light::headlight_left; + // visual feedback + Train->ggRearRightLightButton.UpdateValue( 0.0, Train->dsbSwitch ); + } + } +} + +void TTrain::OnCommand_headlighttogglerearupper( TTrain *Train, command_data const &Command ) { + + if( Train->mvOccupied->LightsPosNo > 0 ) { + // lights are controlled by preset selector + return; + } + + int const vehicleside = + ( Train->mvOccupied->ActiveCab == 1 ? + side::rear : + side::front ); + + if( Command.action == GLFW_PRESS ) { + // only reacting to press, so the switch doesn't flip back and forth if key is held down + if( ( Train->DynamicObject->iLights[ vehicleside ] & light::headlight_upper ) == 0 ) { + // turn on + Train->DynamicObject->iLights[ vehicleside ] ^= light::headlight_upper; + // visual feedback + Train->ggRearUpperLightButton.UpdateValue( 1.0, Train->dsbSwitch ); + } + else { + //turn off + Train->DynamicObject->iLights[ vehicleside ] ^= light::headlight_upper; + // visual feedback + Train->ggRearUpperLightButton.UpdateValue( 0.0, Train->dsbSwitch ); + } + } +} + +void TTrain::OnCommand_redmarkertogglerearleft( TTrain *Train, command_data const &Command ) { + + if( Train->mvOccupied->LightsPosNo > 0 ) { + // lights are controlled by preset selector + return; + } + + int const vehicleside = + ( Train->mvOccupied->ActiveCab == 1 ? + side::rear : + side::front ); + + if( Command.action == GLFW_PRESS ) { + // NOTE: we toggle the light on opposite side, as 'rear right' is 'front left' on the rear end etc + // only reacting to press, so the switch doesn't flip back and forth if key is held down + if( ( Train->DynamicObject->iLights[ vehicleside ] & light::redmarker_right ) == 0 ) { + // turn on + Train->DynamicObject->iLights[ vehicleside ] ^= light::redmarker_right; + // visual feedback + Train->ggRearLeftEndLightButton.UpdateValue( 1.0, Train->dsbSwitch ); + } + else { + //turn off + Train->DynamicObject->iLights[ vehicleside ] ^= light::redmarker_right; + // visual feedback + Train->ggRearLeftEndLightButton.UpdateValue( 0.0, Train->dsbSwitch ); + } + } +} + +void TTrain::OnCommand_redmarkertogglerearright( TTrain *Train, command_data const &Command ) { + + if( Train->mvOccupied->LightsPosNo > 0 ) { + // lights are controlled by preset selector + return; + } + + int const vehicleside = + ( Train->mvOccupied->ActiveCab == 1 ? + side::rear : + side::front ); + + if( Command.action == GLFW_PRESS ) { + // NOTE: we toggle the light on opposite side, as 'rear right' is 'front left' on the rear end etc + // only reacting to press, so the switch doesn't flip back and forth if key is held down + if( ( Train->DynamicObject->iLights[ vehicleside ] & light::redmarker_left ) == 0 ) { + // turn on + Train->DynamicObject->iLights[ vehicleside ] ^= light::redmarker_left; + // visual feedback + Train->ggRearRightEndLightButton.UpdateValue( 1.0, Train->dsbSwitch ); + } + else { + //turn off + Train->DynamicObject->iLights[ vehicleside ] ^= light::redmarker_left; + // visual feedback + Train->ggRearRightEndLightButton.UpdateValue( 0.0, Train->dsbSwitch ); + } + } +} + +void TTrain::OnCommand_redmarkerstoggle( TTrain *Train, command_data const &Command ) { + + if( ( true == FreeFlyModeFlag ) + && ( Command.action == GLFW_PRESS ) ) { + + auto *vehicle { std::get( simulation::Region->find_vehicle( Global.pCamera.Pos, 10, false, true ) ) }; + + if( vehicle == nullptr ) { return; } + + int const CouplNr { + clamp( + vehicle->DirectionGet() + * ( LengthSquared3( vehicle->HeadPosition() - Global.pCamera.Pos ) > LengthSquared3( vehicle->RearPosition() - Global.pCamera.Pos ) ? + 1 : + -1 ), + 0, 1 ) }; // z [-1,1] zrobić [0,1] + + auto const lightset { light::redmarker_left | light::redmarker_right }; + + vehicle->iLights[ CouplNr ] = ( + false == TestFlag( vehicle->iLights[ CouplNr ], lightset ) ? + vehicle->iLights[ CouplNr ] |= lightset : // turn signals on + vehicle->iLights[ CouplNr ] ^= lightset ); // turn signals off + } +} + +void TTrain::OnCommand_endsignalstoggle( TTrain *Train, command_data const &Command ) { + + if( ( true == FreeFlyModeFlag ) + && ( Command.action == GLFW_PRESS ) ) { + + auto *vehicle { std::get( simulation::Region->find_vehicle( Global.pCamera.Pos, 10, false, true ) ) }; + + if( vehicle == nullptr ) { return; } + + int const CouplNr { + clamp( + vehicle->DirectionGet() + * ( LengthSquared3( vehicle->HeadPosition() - Global.pCamera.Pos ) > LengthSquared3( vehicle->RearPosition() - Global.pCamera.Pos ) ? + 1 : + -1 ), + 0, 1 ) }; // z [-1,1] zrobić [0,1] + + auto const lightset { light::rearendsignals }; + + vehicle->iLights[ CouplNr ] = ( + false == TestFlag( vehicle->iLights[ CouplNr ], lightset ) ? + vehicle->iLights[ CouplNr ] |= lightset : // turn signals on + vehicle->iLights[ CouplNr ] ^= lightset ); // turn signals off + } +} + +void TTrain::OnCommand_headlightsdimtoggle( TTrain *Train, command_data const &Command ) { + + if( Command.action == GLFW_PRESS ) { + // only reacting to press, so the switch doesn't flip back and forth if key is held down + if( false == Train->DynamicObject->DimHeadlights ) { + // turn on + OnCommand_headlightsdimenable( Train, Command ); + } + else { + //turn off + OnCommand_headlightsdimdisable( Train, Command ); + } + } +} + +void TTrain::OnCommand_headlightsdimenable( TTrain *Train, command_data const &Command ) { + + if( Command.action == GLFW_PRESS ) { + // only reacting to press, so the switch doesn't flip back and forth if key is held down + if( Train->ggDimHeadlightsButton.SubModel == nullptr ) { + // TODO: proper control deviced definition for the interiors, that doesn't hinge of presence of 3d submodels + WriteLog( "Dim Headlights switch is missing, or wasn't defined" ); + return; + } + // visual feedback + Train->ggDimHeadlightsButton.UpdateValue( 1.0, Train->dsbSwitch ); + + if( true == Train->DynamicObject->DimHeadlights ) { return; } // already enabled + + Train->DynamicObject->DimHeadlights = true; + } +} + +void TTrain::OnCommand_headlightsdimdisable( TTrain *Train, command_data const &Command ) { + + if( Command.action == GLFW_PRESS ) { + // only reacting to press, so the switch doesn't flip back and forth if key is held down + if( Train->ggDimHeadlightsButton.SubModel == nullptr ) { + // TODO: proper control deviced definition for the interiors, that doesn't hinge of presence of 3d submodels + WriteLog( "Dim Headlights switch is missing, or wasn't defined" ); + return; + } + // visual feedback + Train->ggDimHeadlightsButton.UpdateValue( 0.0, Train->dsbSwitch ); + + if( false == Train->DynamicObject->DimHeadlights ) { return; } // already enabled + + Train->DynamicObject->DimHeadlights = false; + } +} + +void TTrain::OnCommand_interiorlighttoggle( TTrain *Train, command_data const &Command ) { + + if( Command.action == GLFW_PRESS ) { + // only reacting to press, so the switch doesn't flip back and forth if key is held down + if( false == Train->bCabLight ) { + // turn on + OnCommand_interiorlightenable( Train, Command ); + } + else { + //turn off + OnCommand_interiorlightdisable( Train, Command ); + } + } +} + +void TTrain::OnCommand_interiorlightenable( TTrain *Train, command_data const &Command ) { + + if( Command.action == GLFW_PRESS ) { + // only reacting to press, so the switch doesn't flip back and forth if key is held down + if( Train->ggCabLightButton.SubModel == nullptr ) { + // TODO: proper control deviced definition for the interiors, that doesn't hinge of presence of 3d submodels + WriteLog( "Interior Light switch is missing, or wasn't defined" ); + return; + } + // visual feedback + Train->ggCabLightButton.UpdateValue( 1.0, Train->dsbSwitch ); + + if( true == Train->bCabLight ) { return; } // already enabled + + Train->bCabLight = true; + Train->btCabLight.Turn( true ); + } +} + +void TTrain::OnCommand_interiorlightdisable( TTrain *Train, command_data const &Command ) { + + if( Command.action == GLFW_PRESS ) { + // only reacting to press, so the switch doesn't flip back and forth if key is held down + if( Train->ggCabLightButton.SubModel == nullptr ) { + // TODO: proper control deviced definition for the interiors, that doesn't hinge of presence of 3d submodels + WriteLog( "Interior Light switch is missing, or wasn't defined" ); + return; + } + // visual feedback + Train->ggCabLightButton.UpdateValue( 0.0, Train->dsbSwitch ); + + if( false == Train->bCabLight ) { return; } // already disabled + + Train->bCabLight = false; + Train->btCabLight.Turn( false ); + } +} + +void TTrain::OnCommand_interiorlightdimtoggle( TTrain *Train, command_data const &Command ) { + + if( Command.action == GLFW_PRESS ) { + // only reacting to press, so the switch doesn't flip back and forth if key is held down + if( false == Train->bCabLightDim ) { + // turn on + OnCommand_interiorlightdimenable( Train, Command ); + } + else { + //turn off + OnCommand_interiorlightdimdisable( Train, Command ); + } + } +} + +void TTrain::OnCommand_interiorlightdimenable( TTrain *Train, command_data const &Command ) { + + if( Command.action == GLFW_PRESS ) { + // only reacting to press, so the switch doesn't flip back and forth if key is held down + if( Train->ggCabLightDimButton.SubModel == nullptr ) { + // TODO: proper control deviced definition for the interiors, that doesn't hinge of presence of 3d submodels + WriteLog( "Dim Interior Light switch is missing, or wasn't defined" ); + return; + } + // visual feedback + Train->ggCabLightDimButton.UpdateValue( 1.0, Train->dsbSwitch ); + + if( true == Train->bCabLightDim ) { return; } // already enabled + + Train->bCabLightDim = true; + } +} + +void TTrain::OnCommand_interiorlightdimdisable( TTrain *Train, command_data const &Command ) { + + if( Command.action == GLFW_PRESS ) { + // only reacting to press, so the switch doesn't flip back and forth if key is held down + if( Train->ggCabLightDimButton.SubModel == nullptr ) { + // TODO: proper control deviced definition for the interiors, that doesn't hinge of presence of 3d submodels + WriteLog( "Dim Interior Light switch is missing, or wasn't defined" ); + return; + } + // visual feedback + Train->ggCabLightDimButton.UpdateValue( 0.0, Train->dsbSwitch ); + + if( false == Train->bCabLightDim ) { return; } // already disabled + + Train->bCabLightDim = false; + } +} + +void TTrain::OnCommand_instrumentlighttoggle( TTrain *Train, command_data const &Command ) { + + if( Command.action == GLFW_PRESS ) { + // only reacting to press, so the switch doesn't flip back and forth if key is held down + if( false == Train->InstrumentLightActive ) { + // turn on + OnCommand_instrumentlightenable( Train, Command ); + } + else { + //turn off + OnCommand_instrumentlightdisable( Train, Command ); + } + } +} + +void TTrain::OnCommand_instrumentlightenable( TTrain *Train, command_data const &Command ) { + + if( Command.action == GLFW_PRESS ) { + // only reacting to press, so the switch doesn't flip back and forth if key is held down + if( Train->ggInstrumentLightButton.SubModel == nullptr ) { + // TODO: proper control deviced definition for the interiors, that doesn't hinge of presence of 3d submodels + WriteLog( "Instrument Light switch is missing, or wasn't defined" ); + return; + } + // visual feedback + Train->ggInstrumentLightButton.UpdateValue( 1.0, Train->dsbSwitch ); + + if( true == Train->InstrumentLightActive ) { return; } // already enabled + + Train->InstrumentLightActive = true; + } +} + +void TTrain::OnCommand_instrumentlightdisable( TTrain *Train, command_data const &Command ) { + + if( Command.action == GLFW_PRESS ) { + // only reacting to press, so the switch doesn't flip back and forth if key is held down + if( Train->ggInstrumentLightButton.SubModel == nullptr ) { + // TODO: proper control deviced definition for the interiors, that doesn't hinge of presence of 3d submodels + WriteLog( "Instrument Light switch is missing, or wasn't defined" ); + return; + } + // visual feedback + Train->ggInstrumentLightButton.UpdateValue( 0.0, Train->dsbSwitch ); + + if( false == Train->InstrumentLightActive ) { return; } // already disabled + + Train->InstrumentLightActive = false; + } +} + +void TTrain::OnCommand_dashboardlighttoggle( TTrain *Train, command_data const &Command ) { + // only reacting to press, so the switch doesn't flip back and forth if key is held down + if( Command.action != GLFW_PRESS ) { return; } + + if( Train->ggDashboardLightButton.SubModel == nullptr ) { + // TODO: proper control deviced definition for the interiors, that doesn't hinge of presence of 3d submodels + WriteLog( "Dashboard Light switch is missing, or wasn't defined" ); + return; + } + + if( false == Train->DashboardLightActive ) { + // turn on + Train->DashboardLightActive = true; + // visual feedback + Train->ggDashboardLightButton.UpdateValue( 1.0, Train->dsbSwitch ); + } + else { + //turn off + Train->DashboardLightActive = false; + // visual feedback + Train->ggDashboardLightButton.UpdateValue( 0.0, Train->dsbSwitch ); + } +} + +void TTrain::OnCommand_timetablelighttoggle( TTrain *Train, command_data const &Command ) { + // only reacting to press, so the switch doesn't flip back and forth if key is held down + if( Command.action != GLFW_PRESS ) { return; } + + if( Train->ggTimetableLightButton.SubModel == nullptr ) { + // TODO: proper control deviced definition for the interiors, that doesn't hinge of presence of 3d submodels + WriteLog( "Timetable Light switch is missing, or wasn't defined" ); + return; + } + + if( false == Train->TimetableLightActive ) { + // turn on + Train->TimetableLightActive = true; + // visual feedback + Train->ggTimetableLightButton.UpdateValue( 1.0, Train->dsbSwitch ); + } + else { + //turn off + Train->TimetableLightActive = false; + // visual feedback + Train->ggTimetableLightButton.UpdateValue( 0.0, Train->dsbSwitch ); + } +} + +void TTrain::OnCommand_heatingtoggle( TTrain *Train, command_data const &Command ) { + + if( Train->ggTrainHeatingButton.SubModel == nullptr ) { + if( Command.action == GLFW_PRESS ) { + WriteLog( "Train Heating switch is missing, or wasn't defined" ); + } + return; + } + + if( Command.action == GLFW_PRESS ) { + // only reacting to press, so the switch doesn't flip back and forth if key is held down + if( false == Train->mvControlled->Heating ) { + // turn on + OnCommand_heatingenable( Train, Command ); + } + else { + //turn off + OnCommand_heatingdisable( Train, Command ); + } + } +} + +void TTrain::OnCommand_heatingenable( TTrain *Train, command_data const &Command ) { + + if( Command.action == GLFW_PRESS ) { + // visual feedback + Train->ggTrainHeatingButton.UpdateValue( 1.0, Train->dsbSwitch ); + + if( true == Train->mvControlled->Heating ) { return; } // already enabled + + Train->mvControlled->Heating = true; + } +} + +void TTrain::OnCommand_heatingdisable( TTrain *Train, command_data const &Command ) { + + if( Command.action == GLFW_PRESS ) { + // visual feedback + Train->ggTrainHeatingButton.UpdateValue( 0.0, Train->dsbSwitch ); + + if( false == Train->mvControlled->Heating ) { return; } // already disabled + + Train->mvControlled->Heating = false; + } +} + +void TTrain::OnCommand_generictoggle( TTrain *Train, command_data const &Command ) { + + auto const itemindex = static_cast( Command.command ) - static_cast( user_command::generictoggle0 ); + auto &item = Train->ggUniversals[ itemindex ]; + + if( item.SubModel == nullptr ) { + if( Command.action == GLFW_PRESS ) { + WriteLog( "Train generic item " + std::to_string( itemindex ) + " is missing, or wasn't defined" ); + } + return; + } + + if( Command.action == GLFW_PRESS ) { + // only reacting to press, so the switch doesn't flip back and forth if key is held down + if( item.GetDesiredValue() < 0.5 ) { + // turn on + // visual feedback + item.UpdateValue( 1.0, Train->dsbSwitch ); + } + else { + // turn off + // visual feedback + item.UpdateValue( 0.0, Train->dsbSwitch ); + } + } +} + +void TTrain::OnCommand_doorlocktoggle( TTrain *Train, command_data const &Command ) { + + if( Train->ggDoorSignallingButton.SubModel == nullptr ) { + if( Command.action == GLFW_PRESS ) { + WriteLog( "Door Lock switch is missing, or wasn't defined" ); + } + return; + } + + if( Command.action == GLFW_PRESS ) { + // only reacting to press, so the sound can loop uninterrupted + if( false == Train->mvOccupied->DoorLockEnabled ) { + // turn on + // TODO: door lock command to send through consist + Train->mvOccupied->DoorLockEnabled = true; + // visual feedback + Train->ggDoorSignallingButton.UpdateValue( 1.0, Train->dsbSwitch ); + } + else { + // turn off + // TODO: door lock command to send through consist + Train->mvOccupied->DoorLockEnabled = false; + // visual feedback + Train->ggDoorSignallingButton.UpdateValue( 0.0, Train->dsbSwitch ); + } + } +} + +void TTrain::OnCommand_doortoggleleft( TTrain *Train, command_data const &Command ) { + + if( Command.action == GLFW_PRESS ) { + // NOTE: test how the door state check works with consists where the occupied vehicle doesn't have opening doors + if( false == ( + Train->mvOccupied->ActiveCab == 1 ? + Train->mvOccupied->DoorLeftOpened : + Train->mvOccupied->DoorRightOpened ) ) { + // open + OnCommand_dooropenleft( Train, Command ); + } + else { + // close + if( ( Train->ggDoorAllOffButton.SubModel != nullptr ) + && ( Train->ggDoorLeftOffButton.SubModel == nullptr ) ) { + // OnCommand_doorcloseall( Train, Command ); + // if two-button setup lacks dedicated closing button require the user to press appropriate button manually + return; + } + else { + OnCommand_doorcloseleft( Train, Command ); + } + } + } + else if( Command.action == GLFW_RELEASE ) { + + if( true == ( + Train->mvOccupied->ActiveCab == 1 ? + Train->mvOccupied->DoorLeftOpened : + Train->mvOccupied->DoorRightOpened ) ) { + // open + if( ( Train->mvOccupied->DoorClosureWarningAuto ) + && ( Train->mvOccupied->DepartureSignal ) ) { + // complete closing the doors + if( ( Train->ggDoorAllOffButton.SubModel != nullptr ) + && ( Train->ggDoorLeftOffButton.SubModel == nullptr ) ) { + // OnCommand_doorcloseall( Train, Command ); + // if two-button setup lacks dedicated closing button require the user to press appropriate button manually + return; + } + else { + OnCommand_doorcloseleft( Train, Command ); + } + } + else { + OnCommand_dooropenleft( Train, Command ); + } + } + else { + // close + if( ( Train->ggDoorAllOffButton.SubModel != nullptr ) + && ( Train->ggDoorLeftOffButton.SubModel == nullptr ) ) { + // OnCommand_doorcloseall( Train, Command ); + // if two-button setup lacks dedicated closing button require the user to press appropriate button manually + return; + } + else { + OnCommand_doorcloseleft( Train, Command ); + } + } + } +} + +void TTrain::OnCommand_dooropenleft( TTrain *Train, command_data const &Command ) { + + if( Command.action == GLFW_PRESS ) { + // NOTE: test how the door state check works with consists where the occupied vehicle doesn't have opening doors + if( Train->mvOccupied->DoorOpenCtrl != control_t::driver ) { + return; + } + if( Train->mvOccupied->ActiveCab == 1 ) { + Train->mvOccupied->DoorLeft( true ); + } + else { + // in the rear cab sides are reversed... + Train->mvOccupied->DoorRight( true ); + } + // visual feedback + if( Train->ggDoorLeftOnButton.SubModel != nullptr ) { + // two separate impulse switches + Train->ggDoorLeftOnButton.UpdateValue( 1.0, Train->dsbSwitch ); + } + else { + // single two-state switch + Train->ggDoorLeftButton.UpdateValue( 1.0, Train->dsbSwitch ); + } + } + else if( Command.action == GLFW_RELEASE ) { + // visual feedback + if( Train->ggDoorLeftOnButton.SubModel != nullptr ) { + // two separate impulse switches + Train->ggDoorLeftOnButton.UpdateValue( 0.0, Train->dsbSwitch ); + } + } +} + +void TTrain::OnCommand_doorcloseleft( TTrain *Train, command_data const &Command ) { + + if( Command.action == GLFW_PRESS ) { + + if( Train->mvOccupied->DoorCloseCtrl != control_t::driver ) { + return; + } + + if( Train->mvOccupied->DoorClosureWarningAuto ) { + // automatic departure signal delays actual door closing until the button is released + Train->mvOccupied->signal_departure( true ); + } + else { + // TODO: move door opening/closing to the update, so the switch animation doesn't hinge on door working + if( Train->mvOccupied->ActiveCab == 1 ) { + Train->mvOccupied->DoorLeft( false ); + } + else { + // in the rear cab sides are reversed... + Train->mvOccupied->DoorRight( false ); + } + } + // visual feedback + if( Train->ggDoorLeftOffButton.SubModel != nullptr ) { + // two separate switches to open and close the door + Train->ggDoorLeftOffButton.UpdateValue( 1.0, Train->dsbSwitch ); + } + else { + // single two-state switch + Train->ggDoorLeftButton.UpdateValue( 0.0, Train->dsbSwitch ); + } + } + else if( Command.action == GLFW_RELEASE ) { + + if( Train->mvOccupied->DoorClosureWarningAuto ) { + // automatic departure signal delays actual door closing until the button is released + Train->mvOccupied->signal_departure( false ); + // now we can actually close the door + if( Train->mvOccupied->ActiveCab == 1 ) { + Train->mvOccupied->DoorLeft( false ); + } + else { + // in the rear cab sides are reversed... + Train->mvOccupied->DoorRight( false ); + } + } + // visual feedback + // dedicated closing buttons are presumed to be impulse switches and return automatically to neutral position + if( Train->ggDoorLeftOffButton.SubModel ) + Train->ggDoorLeftOffButton.UpdateValue( 0.0, Train->dsbSwitch ); + } +} + +void TTrain::OnCommand_doortoggleright( TTrain *Train, command_data const &Command ) { + + if( Command.action == GLFW_PRESS ) { + // NOTE: test how the door state check works with consists where the occupied vehicle doesn't have opening doors + if( false == ( + Train->mvOccupied->ActiveCab == 1 ? + Train->mvOccupied->DoorRightOpened : + Train->mvOccupied->DoorLeftOpened ) ) { + // open + OnCommand_dooropenright( Train, Command ); + } + else { + // close + if( ( Train->ggDoorAllOffButton.SubModel != nullptr ) + && ( Train->ggDoorRightOffButton.SubModel == nullptr ) ) { + // OnCommand_doorcloseall( Train, Command ); + // if two-button setup lacks dedicated closing button require the user to press appropriate button manually + return; + } + else { + OnCommand_doorcloseright( Train, Command ); + } + } + } + else if( Command.action == GLFW_RELEASE ) { + + if( true == ( + Train->mvOccupied->ActiveCab == 1 ? + Train->mvOccupied->DoorRightOpened : + Train->mvOccupied->DoorLeftOpened ) ) { + // open + if( ( Train->mvOccupied->DoorClosureWarningAuto ) + && ( Train->mvOccupied->DepartureSignal ) ) { + // complete closing the doors + if( ( Train->ggDoorAllOffButton.SubModel != nullptr ) + && ( Train->ggDoorRightOffButton.SubModel == nullptr ) ) { + // OnCommand_doorcloseall( Train, Command ); + // if two-button setup lacks dedicated closing button require the user to press appropriate button manually + return; + } + else { + OnCommand_doorcloseright( Train, Command ); + } + } + else { + OnCommand_dooropenright( Train, Command ); + } + } + else { + // close + if( ( Train->ggDoorAllOffButton.SubModel != nullptr ) + && ( Train->ggDoorRightOffButton.SubModel == nullptr ) ) { + // OnCommand_doorcloseall( Train, Command ); + // if two-button setup lacks dedicated closing button require the user to press appropriate button manually + return; + } + else { + OnCommand_doorcloseright( Train, Command ); + } + } + } +} + +void TTrain::OnCommand_dooropenright( TTrain *Train, command_data const &Command ) { + + if( Command.action == GLFW_PRESS ) { + // NOTE: test how the door state check works with consists where the occupied vehicle doesn't have opening doors + if( Train->mvOccupied->DoorOpenCtrl != control_t::driver ) { + return; + } + if( Train->mvOccupied->ActiveCab == 1 ) { + Train->mvOccupied->DoorRight( true ); + } + else { + // in the rear cab sides are reversed... + Train->mvOccupied->DoorLeft( true ); + } + // visual feedback + if( Train->ggDoorRightOnButton.SubModel != nullptr ) { + // two separate impulse switches + Train->ggDoorRightOnButton.UpdateValue( 1.0, Train->dsbSwitch ); + } + else { + // single two-state switch + Train->ggDoorRightButton.UpdateValue( 1.0, Train->dsbSwitch ); + } + } + else if( Command.action == GLFW_RELEASE ) { + // visual feedback + if( Train->ggDoorRightOnButton.SubModel != nullptr ) { + // two separate impulse switches + Train->ggDoorRightOnButton.UpdateValue( 0.0, Train->dsbSwitch ); + } + } +} + +void TTrain::OnCommand_doorcloseright( TTrain *Train, command_data const &Command ) { + + if( Command.action == GLFW_PRESS ) { + + if( Train->mvOccupied->DoorCloseCtrl != control_t::driver ) { + return; + } + + if( Train->mvOccupied->DoorClosureWarningAuto ) { + // automatic departure signal delays actual door closing until the button is released + Train->mvOccupied->signal_departure( true ); + } + else { + // TODO: move door opening/closing to the update, so the switch animation doesn't hinge on door working + if( Train->mvOccupied->ActiveCab == 1 ) { + Train->mvOccupied->DoorRight( false ); + } + else { + // in the rear cab sides are reversed... + Train->mvOccupied->DoorLeft( false ); + } + } + // visual feedback + if( Train->ggDoorRightOffButton.SubModel != nullptr ) { + // two separate switches to open and close the door + Train->ggDoorRightOffButton.UpdateValue( 1.0, Train->dsbSwitch ); + } + else { + // single two-state switch + Train->ggDoorRightButton.UpdateValue( 0.0, Train->dsbSwitch ); + } + } + else if( Command.action == GLFW_RELEASE ) { + + if( Train->mvOccupied->DoorClosureWarningAuto ) { + // automatic departure signal delays actual door closing until the button is released + Train->mvOccupied->signal_departure( false ); + // now we can actually close the door + if( Train->mvOccupied->ActiveCab == 1 ) { + Train->mvOccupied->DoorRight( false ); + } + else { + // in the rear cab sides are reversed... + Train->mvOccupied->DoorLeft( false ); + } + } + // visual feedback + // dedicated closing buttons are presumed to be impulse switches and return automatically to neutral position + if( Train->ggDoorRightOffButton.SubModel ) + Train->ggDoorRightOffButton.UpdateValue( 0.0, Train->dsbSwitch ); + } +} + +void TTrain::OnCommand_doorcloseall( TTrain *Train, command_data const &Command ) { + + if( Train->ggDoorAllOffButton.SubModel == nullptr ) { + // TODO: expand definition of cab controls so we can know if the control is present without testing for presence of 3d switch + if( Command.action == GLFW_PRESS ) { + WriteLog( "Close All Doors switch is missing, or wasn't defined" ); + } + return; + } + + if( Command.action == GLFW_PRESS ) { + + if( Train->mvOccupied->DoorCloseCtrl != control_t::driver ) { + return; + } + + if( Train->mvOccupied->DoorClosureWarningAuto ) { + // automatic departure signal delays actual door closing until the button is released + Train->mvOccupied->signal_departure( true ); + } + else { + Train->mvOccupied->DoorRight( false ); + Train->mvOccupied->DoorLeft( false ); + } + // visual feedback + Train->ggDoorLeftButton.UpdateValue( 0.0, Train->dsbSwitch ); + Train->ggDoorRightButton.UpdateValue( 0.0, Train->dsbSwitch ); + if( Train->ggDoorAllOffButton.SubModel ) + Train->ggDoorAllOffButton.UpdateValue( 1.0, Train->dsbSwitch ); + } + else if( Command.action == GLFW_RELEASE ) { + // release the button + if( Train->mvOccupied->DoorClosureWarningAuto ) { + // automatic departure signal delays actual door closing until the button is released + Train->mvOccupied->signal_departure( false ); + // now we can actually close the door + Train->mvOccupied->DoorRight( false ); + Train->mvOccupied->DoorLeft( false ); + } + // visual feedback + if( Train->ggDoorAllOffButton.SubModel ) + Train->ggDoorAllOffButton.UpdateValue( 0.0 ); + } +} + +void TTrain::OnCommand_carcouplingincrease( TTrain *Train, command_data const &Command ) { + + if( ( true == FreeFlyModeFlag ) + && ( Command.action == GLFW_PRESS ) ) { + // tryb freefly, press only + auto coupler { -1 }; + auto *vehicle { Train->DynamicObject->ABuScanNearestObject( Train->DynamicObject->GetTrack(), 1, 1500, coupler ) }; + if( vehicle == nullptr ) + vehicle = Train->DynamicObject->ABuScanNearestObject( Train->DynamicObject->GetTrack(), -1, 1500, coupler ); + + if( ( coupler != -1 ) + && ( vehicle != nullptr ) ) { + + vehicle->couple( coupler ); + } + if( Train->DynamicObject->Mechanik ) { + // aktualizacja flag kierunku w składzie + Train->DynamicObject->Mechanik->CheckVehicles( Connect ); + } + } +} + +void TTrain::OnCommand_carcouplingdisconnect( TTrain *Train, command_data const &Command ) { + + if( ( true == FreeFlyModeFlag ) + && ( Command.action == GLFW_PRESS ) ) { + // tryb freefly, press only + auto coupler { -1 }; + auto *vehicle { Train->DynamicObject->ABuScanNearestObject( Train->DynamicObject->GetTrack(), 1, 1500, coupler ) }; + if( vehicle == nullptr ) + vehicle = Train->DynamicObject->ABuScanNearestObject( Train->DynamicObject->GetTrack(), -1, 1500, coupler ); + + if( ( coupler != -1 ) + && ( vehicle != nullptr ) ) { + + vehicle->uncouple( coupler ); + } + if( Train->DynamicObject->Mechanik ) { + // aktualizacja flag kierunku w składzie + Train->DynamicObject->Mechanik->CheckVehicles( Disconnect ); + } + } +} + +void TTrain::OnCommand_departureannounce( TTrain *Train, command_data const &Command ) { + + if( Train->ggDepartureSignalButton.SubModel == nullptr ) { + if( Command.action == GLFW_PRESS ) { + WriteLog( "Departure Signal button is missing, or wasn't defined" ); + } + return; + } + + if( Command.action == GLFW_PRESS ) { + // only reacting to press, so the sound can loop uninterrupted + if( false == Train->mvOccupied->DepartureSignal ) { + // turn on + Train->mvOccupied->signal_departure( true ); + // visual feedback + Train->ggDepartureSignalButton.UpdateValue( 1.0, Train->dsbSwitch ); + } + } + else if( Command.action == GLFW_RELEASE ) { + // turn off + Train->mvOccupied->signal_departure( false ); + // visual feedback + Train->ggDepartureSignalButton.UpdateValue( 0.0, Train->dsbSwitch ); + } +} + +void TTrain::OnCommand_hornlowactivate( TTrain *Train, command_data const &Command ) { + + if( ( Train->ggHornButton.SubModel == nullptr ) + && ( Train->ggHornLowButton.SubModel == nullptr ) ) { + if( Command.action == GLFW_PRESS ) { + WriteLog( "Horn button is missing, or wasn't defined" ); + } + return; + } + + if( Command.action == GLFW_PRESS ) { + // only need to react to press, sound will continue until stopped + if( false == TestFlag( Train->mvOccupied->WarningSignal, 1 ) ) { + // turn on + Train->mvOccupied->WarningSignal |= 1; +/* + if( true == TestFlag( Train->mvOccupied->WarningSignal, 2 ) ) { + // low and high horn are treated as mutually exclusive + Train->mvControlled->WarningSignal &= ~2; + } +*/ + // visual feedback + Train->ggHornButton.UpdateValue( -1.0 ); + Train->ggHornLowButton.UpdateValue( 1.0 ); + } + } + else if( Command.action == GLFW_RELEASE ) { + // turn off +/* + // NOTE: we turn off both low and high horn, due to unreliability of release event when shift key is involved + Train->mvOccupied->WarningSignal &= ~( 1 | 2 ); +*/ + Train->mvOccupied->WarningSignal &= ~1; + // visual feedback + Train->ggHornButton.UpdateValue( 0.0 ); + Train->ggHornLowButton.UpdateValue( 0.0 ); + } +} + +void TTrain::OnCommand_hornhighactivate( TTrain *Train, command_data const &Command ) { + + if( ( Train->ggHornButton.SubModel == nullptr ) + && ( Train->ggHornHighButton.SubModel == nullptr ) ) { + if( Command.action == GLFW_PRESS ) { + WriteLog( "Horn button is missing, or wasn't defined" ); + } + return; + } + + if( Command.action == GLFW_PRESS ) { + // only need to react to press, sound will continue until stopped + if( false == TestFlag( Train->mvOccupied->WarningSignal, 2 ) ) { + // turn on + Train->mvOccupied->WarningSignal |= 2; +/* + if( true == TestFlag( Train->mvOccupied->WarningSignal, 1 ) ) { + // low and high horn are treated as mutually exclusive + Train->mvControlled->WarningSignal &= ~1; + } +*/ + // visual feedback + Train->ggHornButton.UpdateValue( 1.0 ); + Train->ggHornHighButton.UpdateValue( 1.0 ); + } + } + else if( Command.action == GLFW_RELEASE ) { + // turn off +/* + // NOTE: we turn off both low and high horn, due to unreliability of release event when shift key is involved + Train->mvOccupied->WarningSignal &= ~( 1 | 2 ); +*/ + Train->mvOccupied->WarningSignal &= ~2; + // visual feedback + Train->ggHornButton.UpdateValue( 0.0 ); + Train->ggHornHighButton.UpdateValue( 0.0 ); + } +} + +void TTrain::OnCommand_whistleactivate( TTrain *Train, command_data const &Command ) { + + if( Train->ggWhistleButton.SubModel == nullptr ) { + if( Command.action == GLFW_PRESS ) { + WriteLog( "Whistle button is missing, or wasn't defined" ); + } + return; + } + + if( Command.action == GLFW_PRESS ) { + // only need to react to press, sound will continue until stopped + if( false == TestFlag( Train->mvOccupied->WarningSignal, 4 ) ) { + // turn on + Train->mvOccupied->WarningSignal |= 4; + // visual feedback + Train->ggWhistleButton.UpdateValue( 1.0 ); + } + } + else if( Command.action == GLFW_RELEASE ) { + // turn off + Train->mvOccupied->WarningSignal &= ~4; + // visual feedback + Train->ggWhistleButton.UpdateValue( 0.0 ); + } +} + +void TTrain::OnCommand_radiotoggle( TTrain *Train, command_data const &Command ) { + + if( Train->ggRadioButton.SubModel == nullptr ) { + if( Command.action == GLFW_PRESS ) { + WriteLog( "Radio switch is missing, or wasn't defined" ); + } +/* + // NOTE: we ignore the lack of 3d model to allow system reset after receiving radio-stop signal + return; +*/ + } + + if( Command.action == GLFW_PRESS ) { + // only reacting to press, so the sound can loop uninterrupted + if( false == Train->mvOccupied->Radio ) { + // turn on + Train->mvOccupied->Radio = true; + // visual feedback + Train->ggRadioButton.UpdateValue( 1.0, Train->dsbSwitch ); + } + else { + // turn off + Train->mvOccupied->Radio = false; + // visual feedback + Train->ggRadioButton.UpdateValue( 0.0, Train->dsbSwitch ); + } + } +} + +void TTrain::OnCommand_radiochannelincrease( TTrain *Train, command_data const &Command ) { + + if( Command.action == GLFW_PRESS ) { + Train->iRadioChannel = clamp( Train->iRadioChannel + 1, 1, 10 ); + // visual feedback + Train->ggRadioChannelSelector.UpdateValue( Train->iRadioChannel - 1 ); + Train->ggRadioChannelNext.UpdateValue( 1.0 ); + } + else if( Command.action == GLFW_RELEASE ) { + // visual feedback + Train->ggRadioChannelNext.UpdateValue( 0.0 ); + } +} + +void TTrain::OnCommand_radiochanneldecrease( TTrain *Train, command_data const &Command ) { + + if( Command.action == GLFW_PRESS ) { + Train->iRadioChannel = clamp( Train->iRadioChannel - 1, 1, 10 ); + // visual feedback + Train->ggRadioChannelSelector.UpdateValue( Train->iRadioChannel - 1 ); + Train->ggRadioChannelPrevious.UpdateValue( 1.0 ); + } + else if( Command.action == GLFW_RELEASE ) { + // visual feedback + Train->ggRadioChannelPrevious.UpdateValue( 0.0 ); + } +} + +void TTrain::OnCommand_radiostopsend( TTrain *Train, command_data const &Command ) { + + if( Command.action == GLFW_PRESS ) { + if( ( true == Train->mvOccupied->Radio ) + && ( Train->mvControlled->Battery || Train->mvControlled->ConverterFlag ) ) { + simulation::Region->RadioStop( Train->Dynamic()->GetPosition() ); + } + // visual feedback + Train->ggRadioStop.UpdateValue( 1.0 ); + } + else if( Command.action == GLFW_RELEASE ) { + // visual feedback + Train->ggRadioStop.UpdateValue( 0.0 ); + } +} + +void TTrain::OnCommand_radiostoptest( TTrain *Train, command_data const &Command ) { + + if( Command.action == GLFW_PRESS ) { + if( ( Train->RadioChannel() == 10 ) + && ( Train->mvControlled->Battery || Train->mvControlled->ConverterFlag ) ) { + Train->Dynamic()->RadioStop(); + } + // visual feedback + Train->ggRadioTest.UpdateValue( 1.0 ); + } + else if( Command.action == GLFW_RELEASE ) { + // visual feedback + Train->ggRadioTest.UpdateValue( 0.0 ); + } +} + +void TTrain::OnCommand_cabchangeforward( TTrain *Train, command_data const &Command ) { + + if( Command.action == GLFW_PRESS ) { + if( false == Train->CabChange( 1 ) ) { + if( TestFlag( Train->DynamicObject->MoverParameters->Couplers[ side::front ].CouplingFlag, coupling::gangway ) ) { + // przejscie do nastepnego pojazdu + Global.changeDynObj = Train->DynamicObject->PrevConnected; + Global.changeDynObj->MoverParameters->ActiveCab = ( + Train->DynamicObject->PrevConnectedNo ? + -1 : + 1 ); + } + } + } +} + +void TTrain::OnCommand_cabchangebackward( TTrain *Train, command_data const &Command ) { + + if( Command.action == GLFW_PRESS ) { + if( false == Train->CabChange( -1 ) ) { + if( TestFlag( Train->DynamicObject->MoverParameters->Couplers[ side::rear ].CouplingFlag, coupling::gangway ) ) { + // przejscie do nastepnego pojazdu + Global.changeDynObj = Train->DynamicObject->NextConnected; + Global.changeDynObj->MoverParameters->ActiveCab = ( + Train->DynamicObject->NextConnectedNo ? + -1 : + 1 ); + } + } + } +} + +// cab movement update, fixed step part void TTrain::UpdateMechPosition(double dt) { // Ra: mechanik powinien być // telepany niezależnie od pozycji @@ -2524,127 +4719,270 @@ void TTrain::UpdateMechPosition(double dt) // - na postoju horyzont prosto, kabina skosem // - przy szybkiej jeździe kabina prosto, horyzont pochylony - vector3 pNewMechPosition; Math3D::vector3 shake; // McZapkie: najpierw policzę pozycję w/m kabiny // ABu: rzucamy kabina tylko przy duzym FPS! // Mala histereza, zeby bez przerwy nie przelaczalo przy FPS~17 // Granice mozna ustalic doswiadczalnie. Ja proponuje 14:20 - double const iVel = std::min(DynamicObject->GetVelocity(), 150.0); + double const iVel = std::min( DynamicObject->GetVelocity(), 150.0 ); - if (!Global::iSlowMotion // musi być pełna prędkość - && (pMechOffset.y < 4.0)) // Ra 15-01: przy oglądaniu pantografu bujanie przeszkadza + if( ( false == Global.iSlowMotion ) // musi być pełna prędkość + && ( pMechOffset.y < 4.0 ) ) // Ra 15-01: przy oglądaniu pantografu bujanie przeszkadza { - if( iVel > 0.0 ) { - // acceleration-driven base shake - shake += 1.25 * MechSpring.ComputateForces( - vector3( - -mvControlled->AccN * dt * 5.0, // highlight side sway - mvControlled->AccV * dt, - -mvControlled->AccS * dt * 1.25 ), // accent acceleration/deceleration - pMechShake ); - - if( Random( iVel ) > 25.0 ) { - // extra shake at increased velocity - shake += MechSpring.ComputateForces( - vector3( - ( Random( iVel * 2 ) - iVel ) / ( ( iVel * 2 ) * 4 ) * fMechSpringX, - ( Random( iVel * 2 ) - iVel ) / ( ( iVel * 2 ) * 4 ) * fMechSpringY, - ( Random( iVel * 2 ) - iVel ) / ( ( iVel * 2 ) * 4 ) * fMechSpringZ ), - pMechShake ); -// * (( 200 - DynamicObject->MyTrack->iQualityFlag ) * 0.0075 ); // scale to 75-150% based on track quality + Math3D::vector3 shakevector; + if( ( mvOccupied->EngineType == TEngineType::DieselElectric ) + || ( mvOccupied->EngineType == TEngineType::DieselEngine ) ) { + if( std::abs( mvOccupied->enrot ) > 0.0 ) { + // engine vibration + shakevector.x += + ( std::sin( mvOccupied->eAngle * 4.0 ) * dt * EngineShake.scale ) + // fade in with rpm above threshold + * clamp( + ( mvOccupied->enrot - EngineShake.fadein_offset ) * EngineShake.fadein_factor, + 0.0, 1.0 ) + // fade out with rpm above threshold + * interpolate( + 1.0, 0.0, + clamp( + ( mvOccupied->enrot - EngineShake.fadeout_offset ) * EngineShake.fadeout_factor, + 0.0, 1.0 ) ); } -// shake *= 1.25; } - vMechVelocity -= (shake + vMechVelocity * 100) * (fMechSpringX + fMechSpringY + fMechSpringZ) / (200); -// shake *= 0.95 * dt; // shake damping + + if( ( HuntingShake.fadein_begin > 0.f ) + && ( true == mvOccupied->TruckHunting ) ) { + // hunting oscillation + HuntingAngle = clamp_circular( HuntingAngle + 4.0 * HuntingShake.frequency * dt * mvOccupied->Vel, 360.0 ); + auto const huntingamount = + interpolate( + 0.0, 1.0, + clamp( + ( mvOccupied->Vel - HuntingShake.fadein_begin ) / ( HuntingShake.fadein_end - HuntingShake.fadein_begin ), + 0.0, 1.0 ) ); + shakevector.x += + ( std::sin( glm::radians( HuntingAngle ) ) * dt * HuntingShake.scale ) + * huntingamount; + IsHunting = ( huntingamount > 0.025 ); + } + + if( iVel > 0.5 ) { + // acceleration-driven base shake + shakevector += Math3D::vector3( + -mvOccupied->AccN * dt * 5.0, // highlight side sway + -mvOccupied->AccVert * dt, + -mvOccupied->AccSVBased * dt * 1.25 ); // accent acceleration/deceleration + } + + shake += 1.25 * MechSpring.ComputateForces( shakevector, pMechShake ); + + if( Random( iVel ) > 25.0 ) { + // extra shake at increased velocity + shake += MechSpring.ComputateForces( + Math3D::vector3( + ( Random( iVel * 2 ) - iVel ) / ( ( iVel * 2 ) * 4 ) * fMechSpringX, + ( Random( iVel * 2 ) - iVel ) / ( ( iVel * 2 ) * 4 ) * fMechSpringY, + ( Random( iVel * 2 ) - iVel ) / ( ( iVel * 2 ) * 4 ) * fMechSpringZ ) + * 1.25, + pMechShake ); + // * (( 200 - DynamicObject->MyTrack->iQualityFlag ) * 0.0075 ); // scale to 75-150% based on track quality + } + shake *= 0.85; + + vMechVelocity -= ( shake + vMechVelocity * 100 ) * ( fMechSpringX + fMechSpringY + fMechSpringZ ) / ( 200 ); + // shake *= 0.95 * dt; // shake damping // McZapkie: pMechShake += vMechVelocity * dt; + if( ( pMechShake.y > fMechMaxSpring ) + || ( pMechShake.y < -fMechMaxSpring ) ) { + vMechVelocity.y = -vMechVelocity.y; + } // Ra 2015-01: dotychczasowe rzucanie pMechOffset += vMechMovement * dt; - if ((pMechShake.y > fMechMaxSpring) || (pMechShake.y < -fMechMaxSpring)) - vMechVelocity.y = -vMechVelocity.y; // ABu011104: 5*pMechShake.y, zeby ladnie pudlem rzucalo :) - pNewMechPosition = pMechOffset + vector3(1.5 * pMechShake.x, 2.0 * pMechShake.y, 1.5 * pMechShake.z); - vMechMovement = 0.5 * vMechMovement; + pMechPosition = pMechOffset + Math3D::vector3( 1.5 * pMechShake.x, 2.0 * pMechShake.y, 1.5 * pMechShake.z ); + +// pMechShake = interpolate( pMechShake, Math3D::vector3(), clamp( dt, 0.0, 1.0 ) ); } - else - { // hamowanie rzucania przy spadku FPS - pMechShake -= pMechShake * std::min(dt, 1.0); // po tym chyba potrafią zostać jakieś ułamki, które powodują zjazd + else { // hamowanie rzucania przy spadku FPS + pMechShake -= pMechShake * std::min( dt, 1.0 ); // po tym chyba potrafią zostać jakieś ułamki, które powodują zjazd pMechOffset += vMechMovement * dt; vMechVelocity.y = 0.5 * vMechVelocity.y; - pNewMechPosition = pMechOffset + vector3(pMechShake.x, 5 * pMechShake.y, pMechShake.z); - vMechMovement = 0.5 * vMechMovement; + pMechPosition = pMechOffset + Math3D::vector3( pMechShake.x, 5 * pMechShake.y, pMechShake.z ); } // numer kabiny (-1: kabina B) - if (DynamicObject->Mechanik) // może nie być? - if (DynamicObject->Mechanik->AIControllFlag) // jeśli prowadzi AI + if( DynamicObject->Mechanik ) // może nie być? + if( DynamicObject->Mechanik->AIControllFlag ) // jeśli prowadzi AI { // Ra: przesiadka, jeśli AI zmieniło kabinę (a człon?)... - if (iCabn != (DynamicObject->MoverParameters->ActiveCab == -1 ? - 2 : - DynamicObject->MoverParameters->ActiveCab)) - InitializeCab(DynamicObject->MoverParameters->ActiveCab, - DynamicObject->asBaseDir + DynamicObject->MoverParameters->TypeName + - ".mmd"); + if( iCabn != ( DynamicObject->MoverParameters->ActiveCab == -1 ? + 2 : + DynamicObject->MoverParameters->ActiveCab ) ) + InitializeCab( DynamicObject->MoverParameters->ActiveCab, + DynamicObject->asBaseDir + DynamicObject->MoverParameters->TypeName + + ".mmd" ); } - iCabn = (DynamicObject->MoverParameters->ActiveCab == -1 ? - 2 : - DynamicObject->MoverParameters->ActiveCab); - if (!DebugModeFlag) - { // sprawdzaj więzy //Ra: nie tu! - if (pNewMechPosition.x < Cabine[iCabn].CabPos1.x) - pNewMechPosition.x = Cabine[iCabn].CabPos1.x; - if (pNewMechPosition.x > Cabine[iCabn].CabPos2.x) - pNewMechPosition.x = Cabine[iCabn].CabPos2.x; - if (pNewMechPosition.z < Cabine[iCabn].CabPos1.z) - pNewMechPosition.z = Cabine[iCabn].CabPos1.z; - if (pNewMechPosition.z > Cabine[iCabn].CabPos2.z) - pNewMechPosition.z = Cabine[iCabn].CabPos2.z; - if (pNewMechPosition.y > Cabine[iCabn].CabPos1.y + 1.8) - pNewMechPosition.y = Cabine[iCabn].CabPos1.y + 1.8; - if (pNewMechPosition.y < Cabine[iCabn].CabPos1.y + 0.5) - pNewMechPosition.y = Cabine[iCabn].CabPos2.y + 0.5; + iCabn = ( DynamicObject->MoverParameters->ActiveCab == -1 ? + 2 : + DynamicObject->MoverParameters->ActiveCab ); + if( !DebugModeFlag ) { // sprawdzaj więzy //Ra: nie tu! - if (pMechOffset.x < Cabine[iCabn].CabPos1.x) - pMechOffset.x = Cabine[iCabn].CabPos1.x; - if (pMechOffset.x > Cabine[iCabn].CabPos2.x) - pMechOffset.x = Cabine[iCabn].CabPos2.x; - if (pMechOffset.z < Cabine[iCabn].CabPos1.z) - pMechOffset.z = Cabine[iCabn].CabPos1.z; - if (pMechOffset.z > Cabine[iCabn].CabPos2.z) - pMechOffset.z = Cabine[iCabn].CabPos2.z; - if (pMechOffset.y > Cabine[iCabn].CabPos1.y + 1.8) - pMechOffset.y = Cabine[iCabn].CabPos1.y + 1.8; - if (pMechOffset.y < Cabine[iCabn].CabPos1.y + 0.5) - pMechOffset.y = Cabine[iCabn].CabPos2.y + 0.5; + pMechPosition.x = clamp( pMechPosition.x, Cabine[ iCabn ].CabPos1.x, Cabine[ iCabn ].CabPos2.x ); + pMechPosition.y = clamp( pMechPosition.y, Cabine[ iCabn ].CabPos1.y + 0.5, Cabine[ iCabn ].CabPos2.y + 1.8 ); + pMechPosition.z = clamp( pMechPosition.z, Cabine[ iCabn ].CabPos1.z, Cabine[ iCabn ].CabPos2.z ); + + pMechOffset.x = clamp( pMechOffset.x, Cabine[ iCabn ].CabPos1.x, Cabine[ iCabn ].CabPos2.x ); + pMechOffset.y = clamp( pMechOffset.y, Cabine[ iCabn ].CabPos1.y + 0.5, Cabine[ iCabn ].CabPos2.y + 1.8 ); + pMechOffset.z = clamp( pMechOffset.z, Cabine[ iCabn ].CabPos1.z, Cabine[ iCabn ].CabPos2.z ); } - pMechPosition = DynamicObject->mMatrix * - pNewMechPosition; // położenie względem środka pojazdu w układzie scenerii - pMechPosition += DynamicObject->GetPosition(); }; +// returns position of the mechanic in the scene coordinates +Math3D::vector3 +TTrain::GetWorldMechPosition() { + + auto position = DynamicObject->mMatrix * pMechPosition; // położenie względem środka pojazdu w układzie scenerii + position += DynamicObject->GetPosition(); + return position; +} + bool TTrain::Update( double const Deltatime ) { - DWORD stat; - double dt = Deltatime; // Timer::GetDeltaTime(); + // train state verification + // line breaker: + if( m_linebreakerstate == 0 ) { + if( true == mvControlled->Mains ) { + // crude way to sync state of the linebreaker with ai-issued commands + m_linebreakerstate = 1; + } + } + if( m_linebreakerstate == 1 ) { + if( false == ( mvControlled->Mains || mvControlled->dizel_startup ) ) { + // crude way to catch cases where the main was knocked out + // because the state of the line breaker isn't changed to match, we need to do it here manually + m_linebreakerstate = 0; + } + } + + if( ( ggMainButton.GetDesiredValue() > 0.95 ) + || ( ggMainOnButton.GetDesiredValue() > 0.95 ) ) { + // keep track of period the line breaker button is held down, to determine when/if circuit closes + if( ( fHVoltage > 0.5 * mvControlled->EnginePowerSource.MaxVoltage ) + || ( ( mvControlled->EngineType != TEngineType::ElectricSeriesMotor ) + && ( mvControlled->EngineType != TEngineType::ElectricInductionMotor ) + && ( true == mvControlled->Battery ) ) ) { + // prevent the switch from working if there's no power + // TODO: consider whether it makes sense for diesel engines and such + fMainRelayTimer += Deltatime; + } + } + else { + // button isn't down, reset the timer + fMainRelayTimer = 0.0f; + } + if( ggMainOffButton.GetDesiredValue() > 0.95 ) { + // if the button disconnecting the line breaker is down prevent the timer from accumulating + fMainRelayTimer = 0.0f; + } + if( m_linebreakerstate == 0 ) { + if( fMainRelayTimer > mvControlled->InitialCtrlDelay ) { + // wlaczanie WSa z opoznieniem + // mark the line breaker as ready to close; for electric vehicles with impulse switch the setup is completed on button release + m_linebreakerstate = 2; + } + } + if( m_linebreakerstate == 2 ) { + // for diesels and/or vehicles with toggle switch setup we complete the engine start here + if( ( ggMainOnButton.SubModel == nullptr ) + || ( ( mvControlled->EngineType == TEngineType::DieselEngine ) + || ( mvControlled->EngineType == TEngineType::DieselElectric ) ) ) { + // try to finalize state change of the line breaker, set the state based on the outcome + m_linebreakerstate = ( + mvControlled->MainSwitch( true ) ? + 1 : + 0 ); + } + } + + // check for received user commands + // NOTE: this is a temporary arrangement, for the transition period from old command setup to the new one + // eventually commands are going to be retrieved directly by the vehicle, filtered through active control stand + // and ultimately executed, provided the stand allows it. + command_data commanddata; + // NOTE: currently we're only storing commands for local vehicle and there's no id system in place, + // so we're supplying 'default' vehicle id of 0 + while( simulation::Commands.pop( commanddata, static_cast( command_target::vehicle ) | 0 ) ) { + + auto lookup = m_commandhandlers.find( commanddata.command ); + if( lookup != m_commandhandlers.end() ) { + // debug data + if( commanddata.action != GLFW_RELEASE ) { + WriteLog( mvOccupied->Name + " received command: [" + simulation::Commands_descriptions[ static_cast( commanddata.command ) ].name + "]" ); + } + // pass the command to the assigned handler + lookup->second( this, commanddata ); + } + } + + // update driver's position + { + auto Vec = Global.pCamera.Velocity * -2.0;// -7.5 * Timer::GetDeltaRenderTime(); + Vec.y = -Vec.y; + if( mvOccupied->ActiveCab < 0 ) { + Vec *= -1.0f; + Vec.y = -Vec.y; + } + Vec.RotateY( Global.pCamera.Yaw ); + vMechMovement = Vec; + } + if (DynamicObject->mdKabina) - { // Ra: TODO: odczyty klawiatury/pulpitu nie - // powinny być uzależnione od istnienia modelu - // kabiny - tor = DynamicObject->GetTrack(); // McZapkie-180203 + { // Ra: TODO: odczyty klawiatury/pulpitu nie powinny być uzależnione od istnienia modelu kabiny + + if( ( DynamicObject->Mechanik != nullptr ) + && ( false == DynamicObject->Mechanik->AIControllFlag ) ) { + // nie blokujemy AI + if( ( mvOccupied->TrainType == dt_ET40 ) + || ( mvOccupied->TrainType == dt_EP05 ) ) { + // dla ET40 i EU05 automatyczne cofanie nastawnika - i tak nie będzie to działać dobrze... + // TODO: use deltatime to stabilize speed + if( false == ( + ( input::command == user_command::mastercontrollerset ) + || ( input::command == user_command::mastercontrollerincrease ) + || ( input::command == user_command::mastercontrollerdecrease ) ) ) { + if( mvOccupied->MainCtrlPos > mvOccupied->MainCtrlActualPos ) { + mvOccupied->DecMainCtrl( 1 ); + } + else if( mvOccupied->MainCtrlPos < mvOccupied->MainCtrlActualPos ) { + // Ra 15-01: a to nie miało być tylko cofanie? + mvOccupied->IncMainCtrl( 1 ); + } + } + } + + if( ( mvOccupied->BrakeHandle == TBrakeHandle::FVel6 ) + && ( mvOccupied->fBrakeCtrlPos < 0.0 ) + && ( Global.iFeedbackMode < 3 ) ) { + // Odskakiwanie hamulce EP + if( false == ( + ( input::command == user_command::trainbrakeset ) + || ( input::command == user_command::trainbrakedecrease ) + || ( input::command == user_command::trainbrakecharging ) ) ) { + set_train_brake( 0 ); + } + } + } + // McZapkie: predkosc wyswietlana na tachometrze brana jest z obrotow kol - float maxtacho = 3; - fTachoVelocity = Min0R(fabs(11.31 * mvControlled->WheelDiameter * mvControlled->nrot), - mvControlled->Vmax * 1.05); + auto const maxtacho { 3.0 }; + fTachoVelocity = static_cast( std::min( std::abs(11.31 * mvControlled->WheelDiameter * mvControlled->nrot), mvControlled->Vmax * 1.05) ); { // skacze osobna zmienna - float ff = floor(GlobalTime->mr); // skacze co sekunde - pol sekundy + float ff = simulation::Time.data().wSecond; // skacze co sekunde - pol sekundy // pomiar, pol sekundy ustawienie if (ff != fTachoTimer) // jesli w tej sekundzie nie zmienial { if (fTachoVelocity > 1) // jedzie - fTachoVelocityJump = fTachoVelocity + (2 - Random(3) + Random(3)) * 0.5; + fTachoVelocityJump = fTachoVelocity + (2.0 - Random(3) + Random(3)) * 0.5; else fTachoVelocityJump = 0; // stoi fTachoTimer = ff; // juz zmienil @@ -2652,40 +4990,17 @@ bool TTrain::Update( double const Deltatime ) } if (fTachoVelocity > 1) // McZapkie-270503: podkrecanie tachometru { - if (fTachoCount < maxtacho) - fTachoCount += dt * 3; // szybciej zacznij stukac + // szybciej zacznij stukac + fTachoCount = std::min( maxtacho, fTachoCount + Deltatime * 3 ); + } + else if( fTachoCount > 0 ) { + // schodz powoli - niektore haslery to ze 4 sekundy potrafia stukac + fTachoCount = std::max( 0.0, fTachoCount - Deltatime * 0.66 ); } - else if (fTachoCount > 0) - fTachoCount -= dt * 0.66; // schodz powoli - niektore haslery to ze 4 - // sekundy potrafia stukac - /* Ra: to by trzeba było przemyśleć, zmienione na szybko problemy robi - //McZapkie: predkosc wyswietlana na tachometrze brana jest z obrotow kol - double vel=fabs(11.31*mvControlled->WheelDiameter*mvControlled->nrot); - if (iSekunda!=floor(GlobalTime->mr)||(vel<1.0)) - {fTachoVelocity=vel; - if (fTachoVelocity>1.0) //McZapkie-270503: podkrecanie tachometru - { - if (fTachoCount0) - fTachoCount-=dt; - if (mvControlled->TrainType==dt_EZT) - //dla EZT wskazówka porusza się niestabilnie - if (fTachoVelocity>7.0) - {fTachoVelocity=floor(0.5+fTachoVelocity+random(5)-random(5)); - //*floor(0.2*fTachoVelocity); - if (fTachoVelocity<0.0) fTachoVelocity=0.0; - } - iSekunda=floor(GlobalTime->mr); - } - */ - // Ra 2014-09: napięcia i prądy muszą być ustalone najpierw, bo wysyłane są - // ewentualnie na - // PoKeys - if ((mvControlled->EngineType != DieselElectric) && (mvControlled->EngineType != ElectricInductionMotor)) // Ra 2014-09: czy taki rozdzia? ma sens? + // Ra 2014-09: napięcia i prądy muszą być ustalone najpierw, bo wysyłane są ewentualnie na PoKeys + if ((mvControlled->EngineType != TEngineType::DieselElectric) + && (mvControlled->EngineType != TEngineType::ElectricInductionMotor)) // Ra 2014-09: czy taki rozdzia? ma sens? fHVoltage = mvControlled->RunningTraction.TractionVoltage; // Winger czy to nie jest zle? // *mvControlled->Mains); else @@ -2744,21 +5059,22 @@ bool TTrain::Update( double const Deltatime ) bDoors[i][2] = (p->dDoorMoveL > 0.001); iDoorNo[i] = p->iAnimType[ANIM_DOORS]; iUnits[i] = iUnitNo; - cCode[i] = p->MoverParameters->TypeName[p->MoverParameters->TypeName.length()]; - asCarName[i] = p->GetName(); + cCode[i] = p->MoverParameters->TypeName[p->MoverParameters->TypeName.length() - 1]; + asCarName[i] = p->name(); bPants[iUnitNo - 1][0] = (bPants[iUnitNo - 1][0] || p->MoverParameters->PantFrontUp); bPants[iUnitNo - 1][1] = (bPants[iUnitNo - 1][1] || p->MoverParameters->PantRearUp); - bComp[iUnitNo - 1][0] = (bComp[iUnitNo - 1][0] || p->MoverParameters->CompressorAllow); + bComp[iUnitNo - 1][0] = (bComp[iUnitNo - 1][0] || p->MoverParameters->CompressorAllow || (p->MoverParameters->CompressorStart == start_t::automatic)); + bSlip[i] = p->MoverParameters->SlippingWheels; if (p->MoverParameters->CompressorSpeed > 0.00001) { bComp[iUnitNo - 1][1] = (bComp[iUnitNo - 1][1] || p->MoverParameters->CompressorFlag); } if ((in < 8) && (p->MoverParameters->eimc[eimc_p_Pmax] > 1)) { - fEIMParams[1 + in][0] = p->MoverParameters->eimv[eimv_Fr]; + fEIMParams[1 + in][0] = p->MoverParameters->eimv[eimv_Fmax]; fEIMParams[1 + in][1] = Max0R(fEIMParams[1 + in][0], 0); fEIMParams[1 + in][2] = -Min0R(fEIMParams[1 + in][0], 0); - fEIMParams[1 + in][3] = p->MoverParameters->eimv[eimv_Fr] / + fEIMParams[1 + in][3] = p->MoverParameters->eimv[eimv_Fmax] / Max0R(p->MoverParameters->eimv[eimv_Fful], 1); fEIMParams[1 + in][4] = Max0R(fEIMParams[1 + in][3], 0); fEIMParams[1 + in][5] = -Min0R(fEIMParams[1 + in][3], 0); @@ -2790,6 +5106,7 @@ bool TTrain::Update( double const Deltatime ) bDoors[i][0] = false; bDoors[i][1] = false; bDoors[i][2] = false; + bSlip[i] = false; iUnits[i] = 0; cCode[i] = 0; //'0'; asCarName[i] = ""; @@ -2823,36 +5140,25 @@ bool TTrain::Update( double const Deltatime ) fEIMParams[1 + i][8] = 0; fEIMParams[1 + i][9] = 0; } - - if (Global::iFeedbackMode == 4) - { // wykonywać tylko gdy wyprowadzone na pulpit - Console::ValueSet(0, - mvOccupied->Compressor); // Ra: sterowanie miernikiem: zbiornik główny - Console::ValueSet(1, - mvOccupied->PipePress); // Ra: sterowanie miernikiem: przewód główny - Console::ValueSet(2, mvOccupied->BrakePress); // Ra: sterowanie miernikiem: cylinder hamulcowy - Console::ValueSet(3, fHVoltage); // woltomierz wysokiego napięcia - Console::ValueSet(4, fHCurrent[2]); // Ra: sterowanie miernikiem: drugi amperomierz - Console::ValueSet(5, - fHCurrent[(mvControlled->TrainType & dt_EZT) ? 0 : 1]); // pierwszy amperomierz; dla - // EZT prąd całkowity - Console::ValueSet(6, fTachoVelocity); ////Ra: prędkość na pin 43 - wyjście - /// analogowe (to nie jest PWM); - /// skakanie zapewnia mechanika - /// napędu +#ifdef _WIN32 + if (Global.iFeedbackMode == 4) { + // wykonywać tylko gdy wyprowadzone na pulpit + // Ra: sterowanie miernikiem: zbiornik główny + Console::ValueSet(0, mvOccupied->Compressor); + // Ra: sterowanie miernikiem: przewód główny + Console::ValueSet(1, mvOccupied->PipePress); + // Ra: sterowanie miernikiem: cylinder hamulcowy + Console::ValueSet(2, mvOccupied->BrakePress); + // woltomierz wysokiego napięcia + Console::ValueSet(3, fHVoltage); + // Ra: sterowanie miernikiem: drugi amperomierz + Console::ValueSet(4, fHCurrent[2]); + // pierwszy amperomierz; dla EZT prąd całkowity + Console::ValueSet(5, fHCurrent[(mvControlled->TrainType & dt_EZT) ? 0 : 1]); + // Ra: prędkość na pin 43 - wyjście analogowe (to nie jest PWM); skakanie zapewnia mechanika napędu + Console::ValueSet(6, fTachoVelocity); } - - // hunter-080812: wyrzucanie szybkiego na elektrykach gdy nie ma napiecia - // przy dowolnym ustawieniu kierunkowego - // Ra: to już jest w T_MoverParameters::TractionForce(), ale zależy od - // kierunku - if (mvControlled->EngineType == ElectricSeriesMotor) - if (fabs(mvControlled->RunningTraction.TractionVoltage) < - 0.5 * - mvControlled->EnginePowerSource - .MaxVoltage) // minimalne napięcie pobierać z FIZ? - mvControlled->MainSwitch(false); - +#endif // hunter-091012: swiatlo if (bCabLight == true) { @@ -2869,9 +5175,9 @@ bool TTrain::Update( double const Deltatime ) // Ra 15-01: to musi stąd wylecieć - zależności nie mogą być w kabinie if (mvControlled->ConverterFlag == true) { - fConverterTimer += dt; + fConverterTimer += Deltatime; if ((mvControlled->CompressorFlag == true) && (mvControlled->CompressorPower == 1) && - ((mvControlled->EngineType == ElectricSeriesMotor) || + ((mvControlled->EngineType == TEngineType::ElectricSeriesMotor) || (mvControlled->TrainType == dt_EZT)) && (DynamicObject->Controller == Humandriver)) // hunter-110212: poprawka dla EZT { // hunter-091012: poprawka (zmiana warunku z CompressorPower /rozne od @@ -2880,354 +5186,18 @@ bool TTrain::Update( double const Deltatime ) { mvControlled->ConvOvldFlag = true; if (mvControlled->TrainType != dt_EZT) - mvControlled->MainSwitch(false); + mvControlled->MainSwitch( false, ( mvControlled->TrainType == dt_EZT ? range_t::unit : range_t::local ) ); + } + else if( fConverterTimer >= fConverterPrzekaznik ) { + // changed switch from always true to take into account state of the compressor switch + mvControlled->CompressorSwitch( mvControlled->CompressorAllow ); } - else if (fConverterTimer >= fConverterPrzekaznik) - mvControlled->CompressorSwitch(true); } } else fConverterTimer = 0; //------------------ - double vol = 0; - // int freq=1; - double dfreq; - - // McZapkie-280302 - syczenie - if ((mvOccupied->BrakeHandle == FV4a) || (mvOccupied->BrakeHandle == FVel6)) - { - if (rsHiss.AM != 0) // upuszczanie z PG - { - fPPress = (1 * fPPress + mvOccupied->Handle->GetSound(s_fv4a_b)) / (2); - if (fPPress > 0) - { - vol = 2 * rsHiss.AM * fPPress; - } - if (vol > 0.001) - { - rsHiss.Play(vol, DSBPLAY_LOOPING, true, DynamicObject->GetPosition()); - } - else - { - rsHiss.Stop(); - } - } - if (rsHissU.AM != 0) // upuszczanie z PG - { - fNPress = (1 * fNPress + mvOccupied->Handle->GetSound(s_fv4a_u)) / (2); - if (fNPress > 0) - { - vol = rsHissU.AM * fNPress; - } - if (vol > 0.001) - { - rsHissU.Play(vol, DSBPLAY_LOOPING, true, DynamicObject->GetPosition()); - } - else - { - rsHissU.Stop(); - } - } - if (rsHissE.AM != 0) // upuszczanie przy naglym - { - vol = mvOccupied->Handle->GetSound(s_fv4a_e) * rsHissE.AM; - if (vol > 0.001) - { - rsHissE.Play(vol, DSBPLAY_LOOPING, true, DynamicObject->GetPosition()); - } - else - { - rsHissE.Stop(); - } - } - if (rsHissX.AM != 0) // upuszczanie sterujacego fala - { - vol = mvOccupied->Handle->GetSound(s_fv4a_x) * rsHissX.AM; - if (vol > 0.001) - { - rsHissX.Play(vol, DSBPLAY_LOOPING, true, DynamicObject->GetPosition()); - } - else - { - rsHissX.Stop(); - } - } - if (rsHissT.AM != 0) // upuszczanie z czasowego - { - vol = mvOccupied->Handle->GetSound(s_fv4a_t) * rsHissT.AM; - if (vol > 0.001) - { - rsHissT.Play(vol, DSBPLAY_LOOPING, true, DynamicObject->GetPosition()); - } - else - { - rsHissT.Stop(); - } - } - - } // koniec FV4a - else // jesli nie FV4a - { - if (rsHiss.AM != 0) // upuszczanie z PG - { - fPPress = (4 * fPPress + Max0R(mvOccupied->dpLocalValve, mvOccupied->dpMainValve)) / - (4 + 1); - if (fPPress > 0) - { - vol = 2 * rsHiss.AM * fPPress * 0.01; - } - if (vol > 0.01) - { - rsHiss.Play(vol, DSBPLAY_LOOPING, true, DynamicObject->GetPosition()); - } - else - { - rsHiss.Stop(); - } - } - if (rsHissU.AM != 0) // napelnianie PG - { - fNPress = (4 * fNPress + Min0R(mvOccupied->dpLocalValve, mvOccupied->dpMainValve)) / - (4 + 1); - if (fNPress < 0) - { - vol = -2 * rsHissU.AM * fNPress * 0.004; - } - if (vol > 0.01) - { - rsHissU.Play(vol, DSBPLAY_LOOPING, true, DynamicObject->GetPosition()); - } - else - { - rsHissU.Stop(); - } - } - } // koniec nie FV4a - - // Winger-160404 - syczenie pomocniczego (luzowanie) - /* if (rsSBHiss.AM!=0) - { - fSPPress=(mvOccupied->LocalBrakeRatio())-(mvOccupied->LocalBrakePos); - if (fSPPress>0) - { - vol=2*rsSBHiss.AM*fSPPress; - } - if (vol>0.1) - { - rsSBHiss.Play(vol,DSBPLAY_LOOPING,true,DynamicObject->GetPosition()); - } - else - { - rsSBHiss.Stop(); - } - } - */ - // szum w czasie jazdy - vol = 0.0; - dfreq = 1.0; - if (rsRunningNoise.AM != 0) - { - if (DynamicObject->GetVelocity() != 0) - { - if (!TestFlag(mvOccupied->DamageFlag, - dtrain_wheelwear)) // McZpakie-221103: halas zalezny od kola - { - dfreq = rsRunningNoise.FM * mvOccupied->Vel + rsRunningNoise.FA; - vol = rsRunningNoise.AM * mvOccupied->Vel + rsRunningNoise.AA; - switch (tor->eEnvironment) - { - case e_tunnel: - { - vol *= 3; - dfreq *= 0.95; - } - break; - case e_canyon: - { - vol *= 1.1; - } - break; - case e_bridge: - { - vol *= 2; - dfreq *= 0.98; - } - break; - } - } - else // uszkodzone kolo (podkucie) - if (fabs(mvOccupied->nrot) > 0.01) - { - dfreq = rsRunningNoise.FM * mvOccupied->Vel + rsRunningNoise.FA; - vol = rsRunningNoise.AM * mvOccupied->Vel + rsRunningNoise.AA; - switch (tor->eEnvironment) - { - case e_tunnel: - { - vol *= 2; - } - break; - case e_canyon: - { - vol *= 1.1; - } - break; - case e_bridge: - { - vol *= 1.5; - } - break; - } - } - if (fabs(mvOccupied->nrot) > 0.01) - vol *= 1 + - mvOccupied->UnitBrakeForce / - (1 + mvOccupied->MaxBrakeForce); // hamulce wzmagaja halas - vol = vol * (20.0 + tor->iDamageFlag) / 21; - rsRunningNoise.AdjFreq(dfreq, 0); - rsRunningNoise.Play(vol, DSBPLAY_LOOPING, true, DynamicObject->GetPosition()); - } - else - rsRunningNoise.Stop(); - } - - if (rsBrake.AM != 0) - { - if ((!mvOccupied->SlippingWheels) && (mvOccupied->UnitBrakeForce > 10.0) && - (DynamicObject->GetVelocity() > 0.01)) - { - // vol=rsBrake.AA+rsBrake.AM*(DynamicObject->GetVelocity()*100+mvOccupied->UnitBrakeForce); - vol = - rsBrake.AM * sqrt((DynamicObject->GetVelocity() * mvOccupied->UnitBrakeForce)); - dfreq = rsBrake.FA + rsBrake.FM * DynamicObject->GetVelocity(); - rsBrake.AdjFreq(dfreq, 0); - rsBrake.Play(vol, DSBPLAY_LOOPING, true, DynamicObject->GetPosition()); - } - else - { - rsBrake.Stop(); - } - } - - if (rsEngageSlippery.AM != 0) - { - if /*((fabs(mvControlled->dizel_engagedeltaomega)>0.2) && */ ( - mvControlled->dizel_engage > 0.1) - { - if (fabs(mvControlled->dizel_engagedeltaomega) > 0.2) - { - dfreq = rsEngageSlippery.FA + - rsEngageSlippery.FM * fabs(mvControlled->dizel_engagedeltaomega); - vol = rsEngageSlippery.AA + rsEngageSlippery.AM * (mvControlled->dizel_engage); - } - else - { - dfreq = - 1; // rsEngageSlippery.FA+0.7*rsEngageSlippery.FM*(fabs(mvControlled->enrot)+mvControlled->nmax); - if (mvControlled->dizel_engage > 0.2) - vol = - rsEngageSlippery.AA + - 0.2 * rsEngageSlippery.AM * (mvControlled->enrot / mvControlled->nmax); - else - vol = 0; - } - rsEngageSlippery.AdjFreq(dfreq, 0); - rsEngageSlippery.Play(vol, DSBPLAY_LOOPING, true, DynamicObject->GetPosition()); - } - else - { - rsEngageSlippery.Stop(); - } - } - - if (FreeFlyModeFlag) - rsFadeSound.Stop(); // wyłącz to cholerne cykanie! - else - rsFadeSound.Play(1, DSBPLAY_LOOPING, true, DynamicObject->GetPosition()); - - // McZapkie! - to wazne - SoundFlag wystawiane jest przez moje moduly - // gdy zachodza pewne wydarzenia komentowane dzwiekiem. - // Mysle ze wystarczy sprawdzac a potem zerowac SoundFlag tutaj - // a nie w DynObject - gdyby cos poszlo zle to po co szarpac dzwiekiem co - // 10ms. - - if (TestFlag(mvOccupied->SoundFlag, sound_relay)) // przekaznik - gdy - // bezpiecznik, - // automatyczny rozruch - // itp - { - if (mvOccupied->EventFlag || TestFlag(mvOccupied->SoundFlag, sound_loud)) - { - mvOccupied->EventFlag = false; // Ra: w kabinie? - dsbRelay->SetVolume(DSBVOLUME_MAX); - } - else - { - dsbRelay->SetVolume(-40); - } - if (!TestFlag(mvOccupied->SoundFlag, sound_manyrelay)) - dsbRelay->Play(0, 0, 0); - else - { - if (TestFlag(mvOccupied->SoundFlag, sound_loud)) - dsbWejscie_na_bezoporow->Play(0, 0, 0); - else - dsbWejscie_na_drugi_uklad->Play(0, 0, 0); - } - } - - if (TestFlag(mvOccupied->SoundFlag, sound_bufferclamp)) // zderzaki uderzaja o siebie - { - if (TestFlag(mvOccupied->SoundFlag, sound_loud)) - dsbBufferClamp->SetVolume(DSBVOLUME_MAX); - else - dsbBufferClamp->SetVolume(-20); - dsbBufferClamp->Play(0, 0, 0); - } - if (dsbCouplerStretch) - if (TestFlag(mvOccupied->SoundFlag, sound_couplerstretch)) // sprzegi sie rozciagaja - { - if (TestFlag(mvOccupied->SoundFlag, sound_loud)) - dsbCouplerStretch->SetVolume(DSBVOLUME_MAX); - else - dsbCouplerStretch->SetVolume(-20); - dsbCouplerStretch->Play(0, 0, 0); - } - - if (mvOccupied->SoundFlag == 0) - if (mvOccupied->EventFlag) - if (TestFlag(mvOccupied->DamageFlag, dtrain_wheelwear)) - { // Ra: przenieść do DynObj! - if (rsRunningNoise.AM != 0) - { - rsRunningNoise.Stop(); - // float aa=rsRunningNoise.AA; - float am = rsRunningNoise.AM; - float fa = rsRunningNoise.FA; - float fm = rsRunningNoise.FM; - rsRunningNoise.Init("lomotpodkucia.wav", -1, 0, 0, 0, - true); // MC: zmiana szumu na lomot - if (rsRunningNoise.AM == 1) - rsRunningNoise.AM = am; - rsRunningNoise.AA = 0.7; - rsRunningNoise.FA = fa; - rsRunningNoise.FM = fm; - } - mvOccupied->EventFlag = false; - } - - mvOccupied->SoundFlag = 0; - /* - for (int b=0; b<2; b++) //MC: aby zerowac stukanie przekaznikow w - czlonie silnikowym - if (TestFlag(mvControlled->Couplers[b].CouplingFlag,ctrain_controll)) - if (mvControlled->Couplers[b].Connected.Power>0.01) - mvControlled->Couplers[b]->Connected->SoundFlag=0; - */ - - // McZapkie! - koniec obslugi dzwiekow z mover.pas - // youBy - prad w drugim czlonie: galaz lub calosc { TDynamicObject *tmp; @@ -3240,75 +5210,43 @@ bool TTrain::Update( double const Deltatime ) if ((TestFlag(mvControlled->Couplers[0].CouplingFlag, ctrain_controll)) && (mvOccupied->ActiveCab == -1)) tmp = DynamicObject->PrevConnected; - if (tmp) - if (tmp->MoverParameters->Power > 0) - { - if (ggI1B.SubModel) - { - ggI1B.UpdateValue(tmp->MoverParameters->ShowCurrent(1)); + if( tmp ) { + if( tmp->MoverParameters->Power > 0 ) { + if( ggI1B.SubModel ) { + ggI1B.UpdateValue( tmp->MoverParameters->ShowCurrent( 1 ) ); ggI1B.Update(); } - if (ggI2B.SubModel) - { - ggI2B.UpdateValue(tmp->MoverParameters->ShowCurrent(2)); + if( ggI2B.SubModel ) { + ggI2B.UpdateValue( tmp->MoverParameters->ShowCurrent( 2 ) ); ggI2B.Update(); } - if (ggI3B.SubModel) - { - ggI3B.UpdateValue(tmp->MoverParameters->ShowCurrent(3)); + if( ggI3B.SubModel ) { + ggI3B.UpdateValue( tmp->MoverParameters->ShowCurrent( 3 ) ); ggI3B.Update(); } - if (ggItotalB.SubModel) - { - ggItotalB.UpdateValue(tmp->MoverParameters->ShowCurrent(0)); + if( ggItotalB.SubModel ) { + ggItotalB.UpdateValue( tmp->MoverParameters->ShowCurrent( 0 ) ); ggItotalB.Update(); } + if( ggWater1TempB.SubModel ) { + ggWater1TempB.UpdateValue( tmp->MoverParameters->dizel_heat.temperatura1 ); + ggWater1TempB.Update(); + } + if( ggOilPressB.SubModel ) { + ggOilPressB.UpdateValue( tmp->MoverParameters->OilPump.pressure ); + ggOilPressB.Update(); + } } - } - /* - //McZapkie-240302 ggVelocity.UpdateValue(DynamicObject->GetVelocity()); - //fHaslerTimer+=dt; - //if (fHaslerTimer>fHaslerTime) - {//Ra: ryzykowne jest to, gdyż może się nie uaktualniać prędkość - //Ra: prędkość się powinna zaokrąglać tam gdzie się liczy - fTachoVelocity - if (ggVelocity.SubModel) - {//ZiomalCl: wskazanie Haslera w kabinie A ze zwloka czasowa oraz odpowiednia - tolerancja - //Nalezy sie zastanowic na przyszlosc nad rozroznieniem predkosciomierzy - (dokladnosc wskazan, zwloka czasowa wskazania, inne funkcje) - //ZiomalCl: W ezt typu stare EN57 wskazania haslera sa mniej dokladne - (linka) - //ggVelocity.UpdateValue(fTachoVelocity>2?fTachoVelocity+0.5-random(mvControlled->TrainType==dt_EZT?5:2)/2:0); - ggVelocity.UpdateValue(Min0R(fTachoVelocity,mvControlled->Vmax*1.05)); - //ograniczenie maksymalnego wskazania na analogowym - ggVelocity.Update(); - } - if (ggVelocityDgt.SubModel) - {//Ra 2014-07: prędkościomierz cyfrowy - ggVelocityDgt.UpdateValue(fTachoVelocity); - ggVelocityDgt.Update(); - } - if (ggVelocity_B.SubModel) - {//ZiomalCl: wskazanie Haslera w kabinie B ze zwloka czasowa oraz odpowiednia - tolerancja - //Nalezy sie zastanowic na przyszlosc nad rozroznieniem predkosciomierzy - (dokladnosc wskazan, zwloka czasowa wskazania, inne funkcje) - //Velocity_B.UpdateValue(fTachoVelocity>2?fTachoVelocity+0.5-random(mvControlled->TrainType==dt_EZT?5:2)/2:0); - ggVelocity_B.UpdateValue(fTachoVelocity); - ggVelocity_B.Update(); - } - //fHaslerTimer-=fHaslerTime; //1.2s (???) } - */ + } // McZapkie-300302: zegarek if (ggClockMInd.SubModel) { - ggClockSInd.UpdateValue(int(GlobalTime->mr)); + ggClockSInd.UpdateValue(simulation::Time.data().wSecond); ggClockSInd.Update(); - ggClockMInd.UpdateValue(GlobalTime->mm); + ggClockMInd.UpdateValue(simulation::Time.data().wMinute); ggClockMInd.Update(); - ggClockHInd.UpdateValue(GlobalTime->hh + GlobalTime->mm / 60.0); + ggClockHInd.UpdateValue(simulation::Time.data().wHour + simulation::Time.data().wMinute / 60.0); ggClockHInd.Update(); } @@ -3354,107 +5292,57 @@ bool TTrain::Update( double const Deltatime ) // Winger 140404 - woltomierz NN if (ggLVoltage.SubModel) { - if (mvControlled->Battery == true) - ggLVoltage.UpdateValue(mvControlled->BatteryVoltage); - else - ggLVoltage.UpdateValue(0); + // NOTE: since we don't have functional converter object, we're faking it here by simple check whether converter is on + // TODO: implement object-based circuits and power systems model so we can have this working more properly + ggLVoltage.UpdateValue( + std::max( + ( mvControlled->ConverterFlag ? + mvControlled->NominalBatteryVoltage : + 0.0 ), + ( mvControlled->Battery ? + mvControlled->BatteryVoltage : + 0.0 ) ) ); ggLVoltage.Update(); } - if (mvControlled->EngineType == DieselElectric) + if (mvControlled->EngineType == TEngineType::DieselElectric) { // ustawienie zmiennych dla silnika spalinowego fEngine[1] = mvControlled->ShowEngineRotation(1); fEngine[2] = mvControlled->ShowEngineRotation(2); - // if (ggEnrot1m.SubModel) - //{ - // ggEnrot1m.UpdateValue(mvControlled->ShowEngineRotation(1)); - // ggEnrot1m.Update(); - //} - // if (ggEnrot2m.SubModel) - //{ - // ggEnrot2m.UpdateValue(mvControlled->ShowEngineRotation(2)); - // ggEnrot2m.Update(); - //} } - else if (mvControlled->EngineType == DieselEngine) + else if (mvControlled->EngineType == TEngineType::DieselEngine) { // albo dla innego spalinowego fEngine[1] = mvControlled->ShowEngineRotation(1); fEngine[2] = mvControlled->ShowEngineRotation(2); fEngine[3] = mvControlled->ShowEngineRotation(3); - // if (ggEnrot1m.SubModel) - //{ - // ggEnrot1m.UpdateValue(mvControlled->ShowEngineRotation(1)); - // ggEnrot1m.Update(); - //} - // if (ggEnrot2m.SubModel) - //{ - // ggEnrot2m.UpdateValue(mvControlled->ShowEngineRotation(2)); - // ggEnrot2m.Update(); - //} - // if (ggEnrot3m.SubModel) - // if (mvControlled->Couplers[1].Connected) - // { - // ggEnrot3m.UpdateValue(mvControlled->ShowEngineRotation(3)); - // ggEnrot3m.Update(); - // } - // if (ggEngageRatio.SubModel) - //{ - // ggEngageRatio.UpdateValue(mvControlled->dizel_engage); - // ggEngageRatio.Update(); - //} if (ggMainGearStatus.SubModel) { if (mvControlled->Mains) - ggMainGearStatus.UpdateValue(1.1 - - fabs(mvControlled->dizel_automaticgearstatus)); + ggMainGearStatus.UpdateValue(1.1 - std::abs(mvControlled->dizel_automaticgearstatus)); else - ggMainGearStatus.UpdateValue(0); + ggMainGearStatus.UpdateValue(0.0); ggMainGearStatus.Update(); } if (ggIgnitionKey.SubModel) { - ggIgnitionKey.UpdateValue(mvControlled->dizel_enginestart); + ggIgnitionKey.UpdateValue(mvControlled->dizel_startup); ggIgnitionKey.Update(); } } - if (mvControlled->SlippingWheels) - { // Ra 2014-12: lokomotywy 181/182 - // dostają SlippingWheels po zahamowaniu - // powyżej 2.85 bara i buczały + if (mvControlled->SlippingWheels) { + // Ra 2014-12: lokomotywy 181/182 dostają SlippingWheels po zahamowaniu powyżej 2.85 bara i buczały double veldiff = (DynamicObject->GetVelocity() - fTachoVelocity) / mvControlled->Vmax; - if (veldiff < -0.01) // 1% Vmax rezerwy, żeby 181/182 nie buczały po - // zahamowaniu, ale to proteza - { - if (fabs(mvControlled->Im) > 10.0) - btLampkaPoslizg.TurnOn(); - rsSlippery.Play(-rsSlippery.AM * veldiff + rsSlippery.AA, DSBPLAY_LOOPING, true, - DynamicObject->GetPosition()); - if (mvControlled->TrainType == - dt_181) // alarm przy poslizgu dla 181/182 - BOMBARDIER - if (dsbSlipAlarm) - dsbSlipAlarm->Play(0, 0, DSBPLAY_LOOPING); - } - else - { - if ((mvOccupied->UnitBrakeForce > 100.0) && (DynamicObject->GetVelocity() > 1.0)) - { - rsSlippery.Play(rsSlippery.AM * veldiff + rsSlippery.AA, DSBPLAY_LOOPING, true, - DynamicObject->GetPosition()); - if (mvControlled->TrainType == dt_181) - if (dsbSlipAlarm) - dsbSlipAlarm->Stop(); + if( veldiff < -0.01 ) { + // 1% Vmax rezerwy, żeby 181/182 nie buczały po zahamowaniu, ale to proteza + if( std::abs( mvControlled->Im ) > 10.0 ) { + btLampkaPoslizg.Turn( true ); } } } - else - { - btLampkaPoslizg.TurnOff(); - rsSlippery.Stop(); - if (mvControlled->TrainType == dt_181) - if (dsbSlipAlarm) - dsbSlipAlarm->Stop(); + else { + btLampkaPoslizg.Turn( false ); } if ((mvControlled->Mains) || (mvControlled->TrainType == dt_EZT)) @@ -3463,129 +5351,247 @@ bool TTrain::Update( double const Deltatime ) } else { - btLampkaNadmSil.TurnOff(); + btLampkaNadmSil.Turn( false ); } - if (mvControlled->Mains) - { - btLampkaWylSzybki.TurnOn(); - btLampkaOpory.Turn(mvControlled->StLinFlag ? mvControlled->ResistorsFlagCheck() : - false); - btLampkaBezoporowa.Turn(mvControlled->ResistorsFlagCheck() || - (mvControlled->MainCtrlActualPos == 0)); // do EU04 - if ((mvControlled->Itot != 0) || (mvOccupied->BrakePress > 2) || - (mvOccupied->PipePress < 3.6)) - btLampkaStyczn.TurnOff(); // Ra: czy to jest udawanie działania - // styczników liniowych? - else if (mvOccupied->BrakePress < 1) - btLampkaStyczn.TurnOn(); // mozna prowadzic rozruch - if (((TestFlag(mvControlled->Couplers[1].CouplingFlag, ctrain_controll)) && - (mvControlled->CabNo == 1)) || - ((TestFlag(mvControlled->Couplers[0].CouplingFlag, ctrain_controll)) && - (mvControlled->CabNo == -1))) - btLampkaUkrotnienie.TurnOn(); + if (mvControlled->Battery || mvControlled->ConverterFlag) { + // alerter test + if( true == CAflag ) { + if( ggSecurityResetButton.GetDesiredValue() > 0.95 ) { + fCzuwakTestTimer += Deltatime; + } + if( fCzuwakTestTimer > 1.0 ) { + SetFlag( mvOccupied->SecuritySystem.Status, s_CAtest ); + } + } + // McZapkie-141102: SHP i czuwak, TODO: sygnalizacja kabinowa + if( mvOccupied->SecuritySystem.Status > 0 ) { + if( fBlinkTimer > fCzuwakBlink ) + fBlinkTimer = -fCzuwakBlink; + else + fBlinkTimer += Deltatime; + // hunter-091012: dodanie testu czuwaka + if( ( TestFlag( mvOccupied->SecuritySystem.Status, s_aware ) ) + || ( TestFlag( mvOccupied->SecuritySystem.Status, s_CAtest ) ) ) { + btLampkaCzuwaka.Turn( fBlinkTimer > 0 ); + } + else + btLampkaCzuwaka.Turn( false ); + + btLampkaSHP.Turn( TestFlag( mvOccupied->SecuritySystem.Status, s_active ) ); + } + else // wylaczone + { + btLampkaCzuwaka.Turn( false ); + btLampkaSHP.Turn( false ); + } + + btLampkaWylSzybki.Turn( + ( ( (m_linebreakerstate == 2) + || (true == mvControlled->Mains) ) ? + true : + false ) ); + // NOTE: 'off' variant uses the same test, but opposite resulting states + btLampkaWylSzybkiOff.Turn( + ( ( ( m_linebreakerstate == 2 ) + || ( true == mvControlled->Mains ) ) ? + false : + true ) ); + + btLampkaPrzetw.Turn( mvControlled->ConverterFlag ); + btLampkaPrzetwOff.Turn( false == mvControlled->ConverterFlag ); + btLampkaNadmPrzetw.Turn( mvControlled->ConvOvldFlag ); + + btLampkaOpory.Turn( + mvControlled->StLinFlag ? + mvControlled->ResistorsFlagCheck() : + false ); + + btLampkaBezoporowa.Turn( + ( true == mvControlled->ResistorsFlagCheck() ) + || ( mvControlled->MainCtrlActualPos == 0 ) ); // do EU04 + + if( mvControlled->StLinFlag ) { + btLampkaStyczn.Turn( false ); + } + else { + // mozna prowadzic rozruch + btLampkaStyczn.Turn( mvOccupied->BrakePress < 1.0 ); + } + if( ( ( TestFlag( mvControlled->Couplers[ side::rear ].CouplingFlag, coupling::control ) ) && ( mvControlled->CabNo == 1 ) ) + || ( ( TestFlag( mvControlled->Couplers[ side::front ].CouplingFlag, coupling::control ) ) && ( mvControlled->CabNo == -1 ) ) ) + btLampkaUkrotnienie.Turn( true ); else - btLampkaUkrotnienie.TurnOff(); + btLampkaUkrotnienie.Turn( false ); // if - // ((TestFlag(mvControlled->BrakeStatus,+b_Rused+b_Ractive)))//Lampka - // drugiego stopnia hamowania - btLampkaHamPosp.Turn((TestFlag(mvOccupied->BrakeStatus, 1))); // lampka drugiego stopnia - // hamowania //TODO: youBy - // wyciągnąć flagę wysokiego - // stopnia - - // hunter-111211: wylacznik cisnieniowy - Ra: tutaj? w kabinie? //yBARC - - // omujborzegrzesiuzniszczylesmicalydzien - // if (mvControlled->TrainType!=dt_EZT) - // if (((mvOccupied->BrakePress > 2) || ( mvOccupied->PipePress < - // 3.6 )) && ( mvControlled->MainCtrlPos != 0 )) - // mvControlled->StLinFlag=true; - //------- + // ((TestFlag(mvControlled->BrakeStatus,+b_Rused+b_Ractive)))//Lampka drugiego stopnia hamowania + btLampkaHamPosp.Turn((TestFlag(mvOccupied->Hamulec->GetBrakeStatus(), 1))); // lampka drugiego stopnia hamowania + //TODO: youBy wyciągnąć flagę wysokiego stopnia // hunter-121211: lampka zanikowo-pradowego wentylatorow: - btLampkaNadmWent.Turn((mvControlled->RventRot < 5.0) && - mvControlled->ResistorsFlagCheck()); + btLampkaNadmWent.Turn( ( mvControlled->RventRot < 5.0 ) && ( mvControlled->ResistorsFlagCheck() ) ); //------- - btLampkaWysRozr.Turn(mvControlled->Imax == mvControlled->ImaxHi); - if (((mvControlled->ScndCtrlActualPos > 0) || - ((mvControlled->RList[mvControlled->MainCtrlActualPos].ScndAct != 0) && - (mvControlled->RList[mvControlled->MainCtrlActualPos].ScndAct != 255))) && - (!mvControlled->DelayCtrlFlag)) - btLampkaBoczniki.TurnOn(); - else - btLampkaBoczniki.TurnOff(); + btLampkaWysRozr.Turn(!(mvControlled->Imax < mvControlled->ImaxHi)); - btLampkaNapNastHam.Turn(mvControlled->ActiveDir != - 0); // napiecie na nastawniku hamulcowym + if( ( false == mvControlled->DelayCtrlFlag ) + && ( ( mvControlled->ScndCtrlActualPos > 0 ) + || ( ( mvControlled->RList[ mvControlled->MainCtrlActualPos ].ScndAct != 0 ) + && ( mvControlled->RList[ mvControlled->MainCtrlActualPos ].ScndAct != 255 ) ) ) ) { + btLampkaBoczniki.Turn( true ); + } + else { + btLampkaBoczniki.Turn( false ); + } + + btLampkaNapNastHam.Turn(mvControlled->ActiveDir != 0); // napiecie na nastawniku hamulcowym btLampkaSprezarka.Turn(mvControlled->CompressorFlag); // mutopsitka dziala + btLampkaSprezarkaOff.Turn( false == mvControlled->CompressorFlag ); + btLampkaFuelPumpOff.Turn( false == mvControlled->FuelPump.is_active ); // boczniki unsigned char scp; // Ra: dopisałem "unsigned" // Ra: w SU45 boczniki wchodzą na MainCtrlPos, a nie na MainCtrlActualPos // - pokićkał ktoś? scp = mvControlled->RList[mvControlled->MainCtrlPos].ScndAct; scp = (scp == 255 ? 0 : scp); // Ra: whatta hella is this? - if ((mvControlled->ScndCtrlPos > 0) || (mvControlled->ScndInMain) && (scp > 0)) + if ((mvControlled->ScndCtrlPos > 0) || (mvControlled->ScndInMain != 0) && (scp > 0)) { // boczniki pojedynczo - btLampkaBocznik1.TurnOn(); + btLampkaBocznik1.Turn( true ); btLampkaBocznik2.Turn(mvControlled->ScndCtrlPos > 1); btLampkaBocznik3.Turn(mvControlled->ScndCtrlPos > 2); btLampkaBocznik4.Turn(mvControlled->ScndCtrlPos > 3); } else { // wyłączone wszystkie cztery - btLampkaBocznik1.TurnOff(); - btLampkaBocznik2.TurnOff(); - btLampkaBocznik3.TurnOff(); - btLampkaBocznik4.TurnOff(); + btLampkaBocznik1.Turn( false ); + btLampkaBocznik2.Turn( false ); + btLampkaBocznik3.Turn( false ); + btLampkaBocznik4.Turn( false ); } - /* - { //sprezarka w drugim wozie - bool comptemp=false; - if (DynamicObject->NextConnected) - if - (TestFlag(mvControlled->Couplers[1].CouplingFlag,ctrain_controll)) - comptemp=DynamicObject->NextConnected->MoverParameters->CompressorFlag; - if ((DynamicObject->PrevConnected) && (!comptemp)) - if - (TestFlag(mvControlled->Couplers[0].CouplingFlag,ctrain_controll)) - comptemp=DynamicObject->PrevConnected->MoverParameters->CompressorFlag; - btLampkaSprezarkaB.Turn(comptemp); - */ - } - else // wylaczone - { - btLampkaWylSzybki.TurnOff(); - btLampkaOpory.TurnOff(); - btLampkaStyczn.TurnOff(); - btLampkaUkrotnienie.TurnOff(); - btLampkaHamPosp.TurnOff(); - btLampkaBoczniki.TurnOff(); - btLampkaNapNastHam.TurnOff(); - btLampkaSprezarka.TurnOff(); - btLampkaBezoporowa.TurnOff(); - } - if (mvControlled->Signalling == true) - { - if ((mvOccupied->BrakePress >= 0.145f) && (mvControlled->Battery == true) && - (mvControlled->Signalling == true)) - { - btLampkaHamowanie1zes.TurnOn(); + if( mvControlled->Signalling == true ) { + if( mvOccupied->BrakePress >= 1.45f ) { + btLampkaHamowanie1zes.Turn( true ); + } + if( mvControlled->BrakePress < 0.75f ) { + btLampkaHamowanie1zes.Turn( false ); + } } - if (mvControlled->BrakePress < 0.075f) - { - btLampkaHamowanie1zes.TurnOff(); + else { + btLampkaHamowanie1zes.Turn( false ); } + + switch (mvControlled->TrainType) { + // zależnie od typu lokomotywy + case dt_EZT: { + btLampkaHamienie.Turn( ( mvControlled->BrakePress >= 0.2 ) && mvControlled->Signalling ); + break; + } + case dt_ET41: { + // odhamowanie drugiego członu + if( mvSecond ) { + // bo może komuś przyjść do głowy jeżdżenie jednym członem + btLampkaHamienie.Turn( mvSecond->BrakePress < 0.4 ); + } + break; + } + default: { + btLampkaHamienie.Turn( ( mvOccupied->BrakePress >= 0.1 ) || mvControlled->DynamicBrakeFlag ); + btLampkaBrakingOff.Turn( ( mvOccupied->BrakePress < 0.1 ) && ( false == mvControlled->DynamicBrakeFlag ) ); + break; + } + } + // KURS90 + btLampkaMaxSila.Turn(abs(mvControlled->Im) >= 350); + btLampkaPrzekrMaxSila.Turn(abs(mvControlled->Im) >= 450); + btLampkaRadio.Turn(mvOccupied->Radio); + btLampkaRadioStop.Turn( mvOccupied->Radio && mvOccupied->RadioStopFlag ); + btLampkaHamulecReczny.Turn(mvOccupied->ManualBrakePos > 0); + // NBMX wrzesien 2003 - drzwi oraz sygnał odjazdu + btLampkaDoorLeft.Turn(mvOccupied->DoorLeftOpened); + btLampkaDoorRight.Turn(mvOccupied->DoorRightOpened); + btLampkaBlokadaDrzwi.Turn(mvOccupied->DoorBlockedFlag()); + btLampkaDoorLockOff.Turn( false == mvOccupied->DoorLockEnabled ); + btLampkaDepartureSignal.Turn( mvControlled->DepartureSignal ); + btLampkaNapNastHam.Turn((mvControlled->ActiveDir != 0) && (mvOccupied->EpFuse)); // napiecie na nastawniku hamulcowym + btLampkaForward.Turn(mvControlled->ActiveDir > 0); // jazda do przodu + btLampkaBackward.Turn(mvControlled->ActiveDir < 0); // jazda do tyłu + btLampkaED.Turn(mvControlled->DynamicBrakeFlag); // hamulec ED + btLampkaBrakeProfileG.Turn( TestFlag( mvOccupied->BrakeDelayFlag, bdelay_G ) ); + btLampkaBrakeProfileP.Turn( TestFlag( mvOccupied->BrakeDelayFlag, bdelay_P ) ); + btLampkaBrakeProfileR.Turn( TestFlag( mvOccupied->BrakeDelayFlag, bdelay_R ) ); + // light indicators + // NOTE: sides are hardcoded to deal with setups where single cab is equipped with all indicators + btLampkaUpperLight.Turn( ( mvOccupied->iLights[ side::front ] & light::headlight_upper ) != 0 ); + btLampkaLeftLight.Turn( ( mvOccupied->iLights[ side::front ] & light::headlight_left ) != 0 ); + btLampkaRightLight.Turn( ( mvOccupied->iLights[ side::front ] & light::headlight_right ) != 0 ); + btLampkaLeftEndLight.Turn( ( mvOccupied->iLights[ side::front ] & light::redmarker_left ) != 0 ); + btLampkaRightEndLight.Turn( ( mvOccupied->iLights[ side::front ] & light::redmarker_right ) != 0 ); + btLampkaRearUpperLight.Turn( ( mvOccupied->iLights[ side::rear ] & light::headlight_upper ) != 0 ); + btLampkaRearLeftLight.Turn( ( mvOccupied->iLights[ side::rear ] & light::headlight_left ) != 0 ); + btLampkaRearRightLight.Turn( ( mvOccupied->iLights[ side::rear ] & light::headlight_right ) != 0 ); + btLampkaRearLeftEndLight.Turn( ( mvOccupied->iLights[ side::rear ] & light::redmarker_left ) != 0 ); + btLampkaRearRightEndLight.Turn( ( mvOccupied->iLights[ side::rear ] & light::redmarker_right ) != 0 ); + // others + btLampkaMalfunction.Turn( mvControlled->dizel_heat.PA ); + btLampkaMotorBlowers.Turn( ( mvControlled->MotorBlowers[ side::front ].is_active ) && ( mvControlled->MotorBlowers[ side::rear ].is_active ) ); } - else - { - btLampkaHamowanie1zes.TurnOff(); + else { + // wylaczone + btLampkaCzuwaka.Turn( false ); + btLampkaSHP.Turn( false ); + btLampkaWylSzybki.Turn( false ); + btLampkaWylSzybkiOff.Turn( false ); + btLampkaWysRozr.Turn( false ); + btLampkaOpory.Turn( false ); + btLampkaStyczn.Turn( false ); + btLampkaUkrotnienie.Turn( false ); + btLampkaHamPosp.Turn( false ); + btLampkaBoczniki.Turn( false ); + btLampkaNapNastHam.Turn( false ); + btLampkaPrzetw.Turn( false ); + btLampkaPrzetwOff.Turn( false ); + btLampkaNadmPrzetw.Turn( false ); + btLampkaSprezarka.Turn( false ); + btLampkaSprezarkaOff.Turn( false ); + btLampkaFuelPumpOff.Turn( false ); + btLampkaBezoporowa.Turn( false ); + btLampkaHamowanie1zes.Turn( false ); + btLampkaHamienie.Turn( false ); + btLampkaBrakingOff.Turn( false ); + btLampkaBrakeProfileG.Turn( false ); + btLampkaBrakeProfileP.Turn( false ); + btLampkaBrakeProfileR.Turn( false ); + btLampkaMaxSila.Turn( false ); + btLampkaPrzekrMaxSila.Turn( false ); + btLampkaRadio.Turn( false ); + btLampkaRadioStop.Turn( false ); + btLampkaHamulecReczny.Turn( false ); + btLampkaDoorLeft.Turn( false ); + btLampkaDoorRight.Turn( false ); + btLampkaBlokadaDrzwi.Turn( false ); + btLampkaDoorLockOff.Turn( false ); + btLampkaDepartureSignal.Turn( false ); + btLampkaNapNastHam.Turn( false ); + btLampkaForward.Turn( false ); + btLampkaBackward.Turn( false ); + btLampkaED.Turn( false ); + // light indicators + btLampkaUpperLight.Turn( false ); + btLampkaLeftLight.Turn( false ); + btLampkaRightLight.Turn( false ); + btLampkaLeftEndLight.Turn( false ); + btLampkaRightEndLight.Turn( false ); + btLampkaRearUpperLight.Turn( false ); + btLampkaRearLeftLight.Turn( false ); + btLampkaRearRightLight.Turn( false ); + btLampkaRearLeftEndLight.Turn( false ); + btLampkaRearRightEndLight.Turn( false ); + // others + btLampkaMalfunction.Turn( false ); + btLampkaMotorBlowers.Turn( false ); } - btLampkaBlokadaDrzwi.Turn(mvControlled->DoorSignalling ? - mvOccupied->DoorBlockedFlag() && mvControlled->Battery : - false); { // yB - wskazniki drugiego czlonu TDynamicObject *tmp; //=mvControlled->mvSecond; //Ra 2014-07: trzeba to @@ -3600,132 +5606,92 @@ bool TTrain::Update( double const Deltatime ) tmp = DynamicObject->PrevConnected; if (tmp) - if (tmp->MoverParameters->Mains) - { - btLampkaWylSzybkiB.TurnOn(); - btLampkaOporyB.Turn(tmp->MoverParameters->ResistorsFlagCheck()); + if ( mvControlled->Battery || mvControlled->ConverterFlag ) { + + auto const *mover { tmp->MoverParameters }; + + btLampkaWylSzybkiB.Turn( mover->Mains ); + btLampkaWylSzybkiBOff.Turn( false == mover->Mains ); + + btLampkaOporyB.Turn(mover->ResistorsFlagCheck()); btLampkaBezoporowaB.Turn( - tmp->MoverParameters->ResistorsFlagCheck() || - (tmp->MoverParameters->MainCtrlActualPos == 0)); // do EU04 - if ((tmp->MoverParameters->Itot != 0) || - (tmp->MoverParameters->BrakePress > 0.2) || - (tmp->MoverParameters->PipePress < 0.36)) - btLampkaStycznB.TurnOff(); // - else if (tmp->MoverParameters->BrakePress < 0.1) - btLampkaStycznB.TurnOn(); // mozna prowadzic rozruch + ( true == mover->ResistorsFlagCheck() ) + || ( mover->MainCtrlActualPos == 0 ) ); // do EU04 - //----------------- - // //hunter-271211: brak jazdy w drugim czlonie, gdy w - // pierwszym tez nie ma (i odwrotnie) - Ra: tutaj? w kabinie? - // if (tmp->MoverParameters->TrainType!=dt_EZT) - // if (((tmp->MoverParameters->BrakePress > 2) || ( - // tmp->MoverParameters->PipePress < 3.6 )) && ( - // tmp->MoverParameters->MainCtrlPos != 0 )) - // { - // tmp->MoverParameters->MainCtrlActualPos=0; //inaczej - // StLinFlag nie zmienia sie na false w drugim pojezdzie - // //tmp->MoverParameters->StLinFlag=true; - // mvControlled->StLinFlag=true; - // } - // if (mvControlled->StLinFlag==true) - // tmp->MoverParameters->MainCtrlActualPos=0; - // //tmp->MoverParameters->StLinFlag=true; - - //----------------- - // hunter-271211: sygnalizacja poslizgu w pierwszym pojezdzie, gdy - // wystapi w drugim - btLampkaPoslizg.Turn(tmp->MoverParameters->SlippingWheels); - //----------------- - - btLampkaSprezarkaB.Turn( - tmp->MoverParameters->CompressorFlag); // mutopsitka dziala - if ((tmp->MoverParameters->BrakePress >= 0.145f * 10) && - (mvControlled->Battery == true) && (mvControlled->Signalling == true)) - { - btLampkaHamowanie2zes.TurnOn(); + if( ( mover->StLinFlag ) + || ( mover->BrakePress > 2.0 ) + || ( mover->PipePress < 0.36 ) ) { + btLampkaStycznB.Turn( false ); } - if ((tmp->MoverParameters->BrakePress < 0.075f * 10) || - (mvControlled->Battery == false) || (mvControlled->Signalling == false)) - { - btLampkaHamowanie2zes.TurnOff(); + else if( mover->BrakePress < 1.0 ) { + btLampkaStycznB.Turn( true ); // mozna prowadzic rozruch + } + // hunter-271211: sygnalizacja poslizgu w pierwszym pojezdzie, gdy wystapi w drugim + btLampkaPoslizg.Turn(mover->SlippingWheels); + + btLampkaSprezarkaB.Turn( mover->CompressorFlag ); // mutopsitka dziala + btLampkaSprezarkaBOff.Turn( false == mover->CompressorFlag ); + if( mvControlled->Signalling == true ) { + if( mover->BrakePress >= 1.45f ) { + btLampkaHamowanie2zes.Turn( true ); + } + if( mover->BrakePress < 0.75f ) { + btLampkaHamowanie2zes.Turn( false ); + } + } + else { + btLampkaHamowanie2zes.Turn( false ); + } + btLampkaNadmPrzetwB.Turn( mover->ConvOvldFlag ); // nadmiarowy przetwornicy? + btLampkaPrzetwB.Turn( mover->ConverterFlag ); // zalaczenie przetwornicy + btLampkaPrzetwBOff.Turn( false == mover->ConverterFlag ); + btLampkaHVoltageB.Turn( mover->NoVoltRelay && mover->OvervoltageRelay ); + btLampkaMalfunctionB.Turn( mover->dizel_heat.PA ); + // motor fuse indicator turns on if the fuse was blown in any unit under control + if( mover->Mains ) { + btLampkaNadmSil.Turn( btLampkaNadmSil.GetValue() || mover->FuseFlagCheck() ); } - btLampkaNadmPrzetwB.Turn( - tmp->MoverParameters->ConvOvldFlag); // nadmiarowy przetwornicy? - btLampkaPrzetwB.Turn( - !tmp->MoverParameters->ConverterFlag); // zalaczenie przetwornicy } else // wylaczone { - btLampkaWylSzybkiB.TurnOff(); - btLampkaOporyB.TurnOff(); - btLampkaStycznB.TurnOff(); - btLampkaSprezarkaB.TurnOff(); - btLampkaBezoporowaB.TurnOff(); - btLampkaHamowanie2zes.TurnOff(); - btLampkaNadmPrzetwB.TurnOn(); - btLampkaPrzetwB.TurnOff(); + btLampkaWylSzybkiB.Turn( false ); + btLampkaWylSzybkiBOff.Turn( false ); + btLampkaOporyB.Turn( false ); + btLampkaStycznB.Turn( false ); + btLampkaSprezarkaB.Turn( false ); + btLampkaSprezarkaBOff.Turn( false ); + btLampkaBezoporowaB.Turn( false ); + btLampkaHamowanie2zes.Turn( false ); + btLampkaNadmPrzetwB.Turn( false ); + btLampkaPrzetwB.Turn( false ); + btLampkaPrzetwBOff.Turn( false ); + btLampkaHVoltageB.Turn( false ); + btLampkaMalfunctionB.Turn( false ); } - - // hunter-261211: jakis stary kod (i niezgodny z prawda), zahaszowalem - // if (tmp) - // if (tmp->MoverParameters->ConverterFlag==true) - // btLampkaNadmPrzetwB.TurnOff(); - // else - // btLampkaNadmPrzetwB.TurnOn(); - - } //**************************************************** */ - if (mvControlled->Battery) - { - switch (mvControlled->TrainType) - { // zależnie od typu lokomotywy - case dt_EZT: - btLampkaHamienie.Turn((mvControlled->BrakePress >= 0.2) && - mvControlled->Signalling); - break; - case dt_ET41: // odhamowanie drugiego członu - if (mvSecond) // bo może komuś przyjść do głowy jeżdżenie jednym członem - btLampkaHamienie.Turn(mvSecond->BrakePress < 0.4); - break; - default: - btLampkaHamienie.Turn((mvOccupied->BrakePress >= 0.1) || - mvControlled->DynamicBrakeFlag); - } - // KURS90 - btLampkaMaxSila.Turn(abs(mvControlled->Im) >= 350); - btLampkaPrzekrMaxSila.Turn(abs(mvControlled->Im) >= 450); - btLampkaRadio.Turn(mvOccupied->Radio); - btLampkaHamulecReczny.Turn(mvOccupied->ManualBrakePos > 0); - // NBMX wrzesien 2003 - drzwi oraz sygnał odjazdu - btLampkaDoorLeft.Turn(mvOccupied->DoorLeftOpened); - btLampkaDoorRight.Turn(mvOccupied->DoorRightOpened); - btLampkaNapNastHam.Turn((mvControlled->ActiveDir != 0) && - (mvOccupied->EpFuse)); // napiecie na nastawniku hamulcowym - btLampkaForward.Turn(mvControlled->ActiveDir > 0); // jazda do przodu - btLampkaBackward.Turn(mvControlled->ActiveDir < 0); // jazda do tyłu - btLampkaED.Turn(mvControlled->DynamicBrakeFlag); // hamulec ED - } - else - { // gdy bateria wyłączona - btLampkaHamienie.TurnOff(); - btLampkaMaxSila.TurnOff(); - btLampkaPrzekrMaxSila.TurnOff(); - btLampkaRadio.TurnOff(); - btLampkaHamulecReczny.TurnOff(); - btLampkaDoorLeft.TurnOff(); - btLampkaDoorRight.TurnOff(); - btLampkaNapNastHam.TurnOff(); - btLampkaForward.TurnOff(); - btLampkaBackward.TurnOff(); - btLampkaED.TurnOff(); } // McZapkie-080602: obroty (albo translacje) regulatorow - if (ggMainCtrl.SubModel) - { - if (mvControlled->CoupledCtrl) + if (ggMainCtrl.SubModel) { + +#ifdef _WIN32 + if( ( DynamicObject->Mechanik != nullptr ) + && ( false == DynamicObject->Mechanik->AIControllFlag ) // nie blokujemy AI + && ( Global.iFeedbackMode == 4 ) + && ( Global.fCalibrateIn[ 2 ][ 1 ] != 0.0 ) ) { + + set_master_controller( Console::AnalogCalibrateGet( 2 ) * mvOccupied->MainCtrlPosNo ); + } +#endif + + if( mvControlled->CoupledCtrl ) { ggMainCtrl.UpdateValue( - double(mvControlled->MainCtrlPos + mvControlled->ScndCtrlPos)); - else - ggMainCtrl.UpdateValue(double(mvControlled->MainCtrlPos)); + double( mvControlled->MainCtrlPos + mvControlled->ScndCtrlPos ), + dsbNastawnikJazdy ); + } + else { + ggMainCtrl.UpdateValue( + double( mvControlled->MainCtrlPos ), + dsbNastawnikJazdy ); + } ggMainCtrl.Update(); } if (ggMainCtrlAct.SubModel) @@ -3737,1216 +5703,127 @@ bool TTrain::Update( double const Deltatime ) ggMainCtrlAct.UpdateValue(double(mvControlled->MainCtrlActualPos)); ggMainCtrlAct.Update(); } - if (ggScndCtrl.SubModel) - { // Ra: od byte odejmowane boolean i konwertowane - // potem na double? + if (ggScndCtrl.SubModel) { + // Ra: od byte odejmowane boolean i konwertowane potem na double? ggScndCtrl.UpdateValue( - double(mvControlled->ScndCtrlPos - - ((mvControlled->TrainType == dt_ET42) && mvControlled->DynamicBrakeFlag))); + double( mvControlled->ScndCtrlPos + - ( ( mvControlled->TrainType == dt_ET42 ) && mvControlled->DynamicBrakeFlag ) ), + dsbNastawnikBocz ); ggScndCtrl.Update(); } - if (ggDirKey.SubModel) - { + if (ggDirKey.SubModel) { if (mvControlled->TrainType != dt_EZT) - ggDirKey.UpdateValue(double(mvControlled->ActiveDir)); + ggDirKey.UpdateValue( + double(mvControlled->ActiveDir), + dsbReverserKey); else - ggDirKey.UpdateValue(double(mvControlled->ActiveDir) + - double(mvControlled->Imin == mvControlled->IminHi)); + ggDirKey.UpdateValue( + double(mvControlled->ActiveDir) + double(mvControlled->Imin == mvControlled->IminHi), + dsbReverserKey); ggDirKey.Update(); } if (ggBrakeCtrl.SubModel) { +#ifdef _WIN32 if (DynamicObject->Mechanik ? (DynamicObject->Mechanik->AIControllFlag ? false : - (Global::iFeedbackMode == 4 || (Global::bMWDmasterEnable && Global::bMWDBreakEnable))) : + (Global.iFeedbackMode == 4 /*|| (Global.bMWDmasterEnable && Global.bMWDBreakEnable)*/)) : false) // nie blokujemy AI { // Ra: nie najlepsze miejsce, ale na początek gdzieś to dać trzeba // Firleju: dlatego kasujemy i zastepujemy funkcją w Console - if (((mvOccupied->BrakeHandle == FV4a) || - (mvOccupied->BrakeHandle == FVel6))) // może można usunąć ograniczenie do FV4a i FVel6? + if (mvOccupied->BrakeHandle == TBrakeHandle::FV4a) { double b = Console::AnalogCalibrateGet(0); - b = Global::CutValueToRange(-2.0, b, mvOccupied->BrakeCtrlPosNo); // przycięcie zmiennej do granic - + b = b * 8.0 - 2.0; + b = clamp( b, -2.0, mvOccupied->BrakeCtrlPosNo ); // przycięcie zmiennej do granic + ggBrakeCtrl.UpdateValue(b); // przesów bez zaokrąglenia + mvOccupied->BrakeLevelSet(b); + } + if (mvOccupied->BrakeHandle == TBrakeHandle::FVel6) // może można usunąć ograniczenie do FV4a i FVel6? + { + double b = Console::AnalogCalibrateGet(0); + b = b * 7.0 - 1.0; + b = clamp( b, -1.0, mvOccupied->BrakeCtrlPosNo ); // przycięcie zmiennej do granic ggBrakeCtrl.UpdateValue(b); // przesów bez zaokrąglenia mvOccupied->BrakeLevelSet(b); } // else //standardowa prodedura z kranem powiązanym z klawiaturą // ggBrakeCtrl.UpdateValue(double(mvOccupied->BrakeCtrlPos)); } +#endif // else //standardowa prodedura z kranem powiązanym z klawiaturą // ggBrakeCtrl.UpdateValue(double(mvOccupied->BrakeCtrlPos)); ggBrakeCtrl.UpdateValue(mvOccupied->fBrakeCtrlPos); ggBrakeCtrl.Update(); } - if (ggLocalBrake.SubModel) - { - if (DynamicObject->Mechanik ? - (DynamicObject->Mechanik->AIControllFlag ? false : (Global::iFeedbackMode == 4 || Global::bMWDmasterEnable)) : - false) // nie blokujemy AI - { // Ra: nie najlepsze miejsce, ale na początek gdzieś to dać trzeba - // Firleju: dlatego kasujemy i zastepujemy funkcją w Console - if ((mvOccupied->BrakeLocHandle == FD1)) - { - double b = Console::AnalogCalibrateGet(1); - b = Global::CutValueToRange(0.0, b, LocalBrakePosNo); // przycięcie zmiennej do granic - ggLocalBrake.UpdateValue(b); // przesów bez zaokrąglenia - mvOccupied->LocalBrakePos = - int(1.09 * b); // sposób zaokrąglania jest do ustalenia - } - else // standardowa prodedura z kranem powiązanym z klawiaturą - ggLocalBrake.UpdateValue(double(mvOccupied->LocalBrakePos)); + + if( ggLocalBrake.SubModel ) { +#ifdef _WIN32 + if( ( DynamicObject->Mechanik != nullptr ) + && ( false == DynamicObject->Mechanik->AIControllFlag ) // nie blokujemy AI + && ( mvOccupied->BrakeLocHandle == TBrakeHandle::FD1 ) + && ( ( Global.iFeedbackMode == 4 ) + /*|| ( Global.bMWDmasterEnable && Global.bMWDBreakEnable )*/ ) ) { + // Ra: nie najlepsze miejsce, ale na początek gdzieś to dać trzeba + // Firleju: dlatego kasujemy i zastepujemy funkcją w Console + auto const b = clamp( + Console::AnalogCalibrateGet( 1 ), + 0.0, + 1.0 ); + mvOccupied->LocalBrakePosA = b; + ggLocalBrake.UpdateValue( b * LocalBrakePosNo ); + } + else +#endif + { + // standardowa prodedura z kranem powiązanym z klawiaturą + ggLocalBrake.UpdateValue( mvOccupied->LocalBrakePosA * LocalBrakePosNo ); } - else // standardowa prodedura z kranem powiązanym z klawiaturą - ggLocalBrake.UpdateValue(double(mvOccupied->LocalBrakePos)); ggLocalBrake.Update(); } - if (ggManualBrake.SubModel != NULL) - { + if (ggManualBrake.SubModel != nullptr) { ggManualBrake.UpdateValue(double(mvOccupied->ManualBrakePos)); ggManualBrake.Update(); } - if (ggBrakeProfileCtrl.SubModel) - { - ggBrakeProfileCtrl.UpdateValue( - double(mvOccupied->BrakeDelayFlag == 4 ? 2 : mvOccupied->BrakeDelayFlag - 1)); - ggBrakeProfileCtrl.Update(); - } - if (ggBrakeProfileG.SubModel) - { - ggBrakeProfileG.UpdateValue(double(mvOccupied->BrakeDelayFlag == bdelay_G ? 1 : 0)); - ggBrakeProfileG.Update(); - } - if (ggBrakeProfileR.SubModel) - { - ggBrakeProfileR.UpdateValue(double(mvOccupied->BrakeDelayFlag == bdelay_R ? 1 : 0)); - ggBrakeProfileR.Update(); - } - - if (ggMaxCurrentCtrl.SubModel) - { - ggMaxCurrentCtrl.UpdateValue(double(mvControlled->Imax == mvControlled->ImaxHi)); - ggMaxCurrentCtrl.Update(); - } - + ggAlarmChain.Update(); + ggBrakeProfileCtrl.Update(); + ggBrakeProfileG.Update(); + ggBrakeProfileR.Update(); + ggBrakeOperationModeCtrl.Update(); + ggMaxCurrentCtrl.Update(); // NBMX wrzesien 2003 - drzwi - if (ggDoorLeftButton.SubModel) - { - ggDoorLeftButton.PutValue(mvOccupied->DoorLeftOpened ? 1 : 0); - ggDoorLeftButton.Update(); - } - if (ggDoorRightButton.SubModel) - { - ggDoorRightButton.PutValue(mvOccupied->DoorRightOpened ? 1 : 0); - ggDoorRightButton.Update(); - } - if (ggDepartureSignalButton.SubModel) - { - // ggDepartureSignalButton.UpdateValue(double()); - ggDepartureSignalButton.Update(); - } - + ggDoorLeftButton.Update(); + ggDoorRightButton.Update(); + ggDoorLeftOnButton.Update(); + ggDoorRightOnButton.Update(); + ggDoorLeftOffButton.Update(); + ggDoorRightOffButton.Update(); + ggDoorAllOffButton.Update(); + ggDoorSignallingButton.Update(); // NBMX dzwignia sprezarki - if (ggCompressorButton.SubModel) // hunter-261211: poprawka - ggCompressorButton.Update(); - if (ggMainButton.SubModel) - ggMainButton.Update(); - if (ggRadioButton.SubModel) - { - ggRadioButton.PutValue(mvOccupied->Radio ? 1 : 0); - ggRadioButton.Update(); - } - if (ggConverterButton.SubModel) - ggConverterButton.Update(); - if (ggConverterOffButton.SubModel) - ggConverterOffButton.Update(); - - if (((DynamicObject->iLights[0]) == 0) && ((DynamicObject->iLights[1]) == 0)) - { - ggRightLightButton.PutValue(0); - ggLeftLightButton.PutValue(0); - ggUpperLightButton.PutValue(0); - ggRightEndLightButton.PutValue(0); - ggLeftEndLightButton.PutValue(0); - } + ggCompressorButton.Update(); + ggCompressorLocalButton.Update(); //--------- - // hunter-101211: poprawka na zle obracajace sie przelaczniki - /* - if (((DynamicObject->iLights[0]&1)==1) - ||((DynamicObject->iLights[1]&1)==1)) - ggLeftLightButton.PutValue(1); - if (((DynamicObject->iLights[0]&16)==16) - ||((DynamicObject->iLights[1]&16)==16)) - ggRightLightButton.PutValue(1); - if (((DynamicObject->iLights[0]&4)==4) - ||((DynamicObject->iLights[1]&4)==4)) - ggUpperLightButton.PutValue(1); - - if (((DynamicObject->iLights[0]&2)==2) - ||((DynamicObject->iLights[1]&2)==2)) - if (ggLeftEndLightButton.SubModel) - { - ggLeftEndLightButton.PutValue(1); - ggLeftLightButton.PutValue(0); - } - else - ggLeftLightButton.PutValue(-1); - - if (((DynamicObject->iLights[0]&32)==32) - ||((DynamicObject->iLights[1]&32)==32)) - if (ggRightEndLightButton.SubModel) - { - ggRightEndLightButton.PutValue(1); - ggRightLightButton.PutValue(0); - } - else - ggRightLightButton.PutValue(-1); - */ - - //-------------- - // hunter-230112 - - // REFLEKTOR LEWY - // glowne oswietlenie - if ((DynamicObject->iLights[0] & 1) == 1) - if ((mvOccupied->ActiveCab) == 1) - ggLeftLightButton.PutValue(1); - else if ((mvOccupied->ActiveCab) == -1) - ggRearLeftLightButton.PutValue(1); - - if ((DynamicObject->iLights[1] & 1) == 1) - if ((mvOccupied->ActiveCab) == -1) - ggLeftLightButton.PutValue(1); - else if ((mvOccupied->ActiveCab) == 1) - ggRearLeftLightButton.PutValue(1); - - // końcówki - if ((DynamicObject->iLights[0] & 2) == 2) - if ((mvOccupied->ActiveCab) == 1) - { - if (ggLeftEndLightButton.SubModel) - { - ggLeftEndLightButton.PutValue(1); - ggLeftLightButton.PutValue(0); - } - else - ggLeftLightButton.PutValue(-1); - } - else if ((mvOccupied->ActiveCab) == -1) - { - if (ggRearLeftEndLightButton.SubModel) - { - ggRearLeftEndLightButton.PutValue(1); - ggRearLeftLightButton.PutValue(0); - } - else - ggRearLeftLightButton.PutValue(-1); - } - - if ((DynamicObject->iLights[1] & 2) == 2) - if ((mvOccupied->ActiveCab) == -1) - { - if (ggLeftEndLightButton.SubModel) - { - ggLeftEndLightButton.PutValue(1); - ggLeftLightButton.PutValue(0); - } - else - ggLeftLightButton.PutValue(-1); - } - else if ((mvOccupied->ActiveCab) == 1) - { - if (ggRearLeftEndLightButton.SubModel) - { - ggRearLeftEndLightButton.PutValue(1); - ggRearLeftLightButton.PutValue(0); - } - else - ggRearLeftLightButton.PutValue(-1); - } - //-------------- - // REFLEKTOR GORNY - if ((DynamicObject->iLights[0] & 4) == 4) - if ((mvOccupied->ActiveCab) == 1) - ggUpperLightButton.PutValue(1); - else if ((mvOccupied->ActiveCab) == -1) - ggRearUpperLightButton.PutValue(1); - - if ((DynamicObject->iLights[1] & 4) == 4) - if ((mvOccupied->ActiveCab) == -1) - ggUpperLightButton.PutValue(1); - else if ((mvOccupied->ActiveCab) == 1) - ggRearUpperLightButton.PutValue(1); - //-------------- - // REFLEKTOR PRAWY - // główne oświetlenie - if ((DynamicObject->iLights[0] & 16) == 16) - if ((mvOccupied->ActiveCab) == 1) - ggRightLightButton.PutValue(1); - else if ((mvOccupied->ActiveCab) == -1) - ggRearRightLightButton.PutValue(1); - - if ((DynamicObject->iLights[1] & 16) == 16) - if ((mvOccupied->ActiveCab) == -1) - ggRightLightButton.PutValue(1); - else if ((mvOccupied->ActiveCab) == 1) - ggRearRightLightButton.PutValue(1); - - // końcówki - if ((DynamicObject->iLights[0] & 32) == 32) - if ((mvOccupied->ActiveCab) == 1) - { - if (ggRightEndLightButton.SubModel) - { - ggRightEndLightButton.PutValue(1); - ggRightLightButton.PutValue(0); - } - else - ggRightLightButton.PutValue(-1); - } - else if ((mvOccupied->ActiveCab) == -1) - { - if (ggRearRightEndLightButton.SubModel) - { - ggRearRightEndLightButton.PutValue(1); - ggRearRightLightButton.PutValue(0); - } - else - ggRearRightLightButton.PutValue(-1); - } - - if ((DynamicObject->iLights[1] & 32) == 32) - if ((mvOccupied->ActiveCab) == -1) - { - if (ggRightEndLightButton.SubModel) - { - ggRightEndLightButton.PutValue(1); - ggRightLightButton.PutValue(0); - } - else - ggRightLightButton.PutValue(-1); - } - else if ((mvOccupied->ActiveCab) == 1) - { - if (ggRearRightEndLightButton.SubModel) - { - ggRearRightEndLightButton.PutValue(1); - ggRearRightLightButton.PutValue(0); - } - else - ggRearRightLightButton.PutValue(-1); - } - if (ggLightsButton.SubModel) - { - ggLightsButton.PutValue(mvOccupied->LightsPos - 1); - ggLightsButton.Update(); - } - - //--------- - // Winger 010304 - pantografy - if (ggPantFrontButton.SubModel) - { - if (mvControlled->PantFrontUp) - ggPantFrontButton.PutValue(1); - else - ggPantFrontButton.PutValue(0); - ggPantFrontButton.Update(); - } - if (ggPantRearButton.SubModel) - { - ggPantRearButton.PutValue(mvControlled->PantRearUp ? 1 : 0); - ggPantRearButton.Update(); - } - if (ggPantFrontButtonOff.SubModel) - { - ggPantFrontButtonOff.Update(); - } - // Winger 020304 - ogrzewanie - //---------- - // hunter-080812: poprawka na ogrzewanie w elektrykach - usuniete - // uzaleznienie od przetwornicy - if (ggTrainHeatingButton.SubModel) - { - if (mvControlled->Heating) - { - ggTrainHeatingButton.PutValue(1); - // if (mvControlled->ConverterFlag==true) - // btLampkaOgrzewanieSkladu.TurnOn(); - } - else - { - ggTrainHeatingButton.PutValue(0); - // btLampkaOgrzewanieSkladu.TurnOff(); - } - ggTrainHeatingButton.Update(); - } - if (ggSignallingButton.SubModel != NULL) - { - ggSignallingButton.PutValue(mvControlled->Signalling ? 1 : 0); - ggSignallingButton.Update(); - } - if (ggDoorSignallingButton.SubModel != NULL) - { - ggDoorSignallingButton.PutValue(mvControlled->DoorSignalling ? 1 : 0); - ggDoorSignallingButton.Update(); - } - // if (ggDistCounter.SubModel) - //{//Ra 2014-07: licznik kilometrów - // ggDistCounter.PutValue(mvControlled->DistCounter); - // ggDistCounter.Update(); - //} - if ((((mvControlled->EngineType == ElectricSeriesMotor) && (mvControlled->Mains == true) && - (mvControlled->ConvOvldFlag == false)) || - (mvControlled->ConverterFlag)) && - (mvControlled->Heating == true)) - btLampkaOgrzewanieSkladu.TurnOn(); + // hunter-080812: poprawka na ogrzewanie w elektrykach - usuniete uzaleznienie od przetwornicy + if( ( mvControlled->Heating == true ) + && ( mvControlled->Mains == true ) + && ( mvControlled->ConvOvldFlag == false ) ) + btLampkaOgrzewanieSkladu.Turn( true ); else - btLampkaOgrzewanieSkladu.TurnOff(); + btLampkaOgrzewanieSkladu.Turn( false ); //---------- - // hunter-261211: jakis stary kod (i niezgodny z prawda), - // zahaszowalem i poprawilem - // youBy-220913: ale przyda sie do lampki samej przetwornicy - btLampkaPrzetw.Turn(!mvControlled->ConverterFlag); - btLampkaNadmPrzetw.Turn(mvControlled->ConvOvldFlag); - //---------- - // McZapkie-141102: SHP i czuwak, TODO: sygnalizacja kabinowa - if (mvOccupied->SecuritySystem.Status > 0) - { - if (fBlinkTimer > fCzuwakBlink) - fBlinkTimer = -fCzuwakBlink; - else - fBlinkTimer += dt; - - // hunter-091012: dodanie testu czuwaka - if ((TestFlag(mvOccupied->SecuritySystem.Status, s_aware)) || - (TestFlag(mvOccupied->SecuritySystem.Status, s_CAtest))) - { - btLampkaCzuwaka.Turn(fBlinkTimer > 0); - } - else - btLampkaCzuwaka.TurnOff(); - btLampkaSHP.Turn(TestFlag(mvOccupied->SecuritySystem.Status, s_active)); - - // hunter-091012: rozdzielenie alarmow - // if (TestFlag(mvOccupied->SecuritySystem.Status,s_alarm)) - if (TestFlag(mvOccupied->SecuritySystem.Status, s_CAalarm) || - TestFlag(mvOccupied->SecuritySystem.Status, s_SHPalarm)) - { - if (dsbBuzzer) - { - dsbBuzzer->GetStatus(&stat); - if (!(stat & DSBSTATUS_PLAYING)) - { - dsbBuzzer->Play(0, 0, DSBPLAY_LOOPING); - Console::BitsSet(1 << 14); // ustawienie bitu 16 na PoKeys - } - } - } - else - { - if (dsbBuzzer) - { - dsbBuzzer->GetStatus(&stat); - if (stat & DSBSTATUS_PLAYING) - { - dsbBuzzer->Stop(); - Console::BitsClear(1 << 14); // ustawienie bitu 16 na PoKeys - } - } - } - } - else // wylaczone - { - btLampkaCzuwaka.TurnOff(); - btLampkaSHP.TurnOff(); - if (dsbBuzzer) - { - dsbBuzzer->GetStatus(&stat); - if (stat & DSBSTATUS_PLAYING) - { - dsbBuzzer->Stop(); - Console::BitsClear(1 << 14); // ustawienie bitu 16 na PoKeys - } - } - } - - //****************************************** - // przelaczniki - - if (Console::Pressed(Global::Keys[k_Horn])) - { - if (Console::Pressed(VK_SHIFT)) - { - SetFlag(mvOccupied->WarningSignal, 2); - mvOccupied->WarningSignal &= (255 - 1); - if (ggHornButton.SubModel) - ggHornButton.UpdateValue(1); - } - else - { - SetFlag(mvOccupied->WarningSignal, 1); - mvOccupied->WarningSignal &= (255 - 2); - if (ggHornButton.SubModel) - ggHornButton.UpdateValue(-1); - } - } - else - { - mvOccupied->WarningSignal = 0; - if (ggHornButton.SubModel) - ggHornButton.UpdateValue(0); - } - - if (Console::Pressed(Global::Keys[k_Horn2])) - if (Global::Keys[k_Horn2] != Global::Keys[k_Horn]) - { - SetFlag(mvOccupied->WarningSignal, 2); - } - - //---------------- - // hunter-141211: wyl. szybki zalaczony i wylaczony przeniesiony z - // OnKeyPress() - if (Console::Pressed(VK_SHIFT) && Console::Pressed(Global::Keys[k_Main])) - { - fMainRelayTimer += dt; - ggMainOnButton.PutValue(1); - if (mvControlled->Mains != true) // hunter-080812: poprawka - mvControlled->ConverterSwitch(false); - if (fMainRelayTimer > mvControlled->InitialCtrlDelay) // wlaczanie WSa z opoznieniem - if (mvControlled->MainSwitch(true)) - { - // if (mvControlled->MainCtrlPos!=0) //zabezpieczenie, by po - // wrzuceniu pozycji przed wlaczonym - // mvControlled->StLinFlag=true; //WSem nie wrzucilo na ta - // pozycje po jego zalaczeniu //yBARC - co to tutaj robi?! - if (mvControlled->EngineType == DieselEngine) - dsbDieselIgnition->Play(0, 0, 0); - } - } - else - { - if (ggConverterButton.GetValue() != - 0) // po puszczeniu przycisku od WSa odpalanie potwora - mvControlled->ConverterSwitch(true); - // hunter-091012: przeniesione z mover.pas, zeby dzwiek sie nie zapetlal, - // drugi warunek zeby nie odtwarzalo w nieskonczonosc i przeniesienie - // zerowania timera - if ((mvControlled->Mains != true) && (fMainRelayTimer > 0)) - { - dsbRelay->Play(0, 0, 0); - fMainRelayTimer = 0; - } - ggMainOnButton.UpdateValue(0); - } - //--- - - if (!Console::Pressed(VK_SHIFT) && Console::Pressed(Global::Keys[k_Main])) - { - ggMainOffButton.PutValue(1); - if (mvControlled->MainSwitch(false)) - dsbRelay->Play(0, 0, 0); - } - else - ggMainOffButton.UpdateValue(0); - - /* if (cKey==Global::Keys[k_Main]) //z shiftem - { - ggMainOnButton.PutValue(1); - if (mvControlled->MainSwitch(true)) - { - if (mvControlled->MainCtrlPos!=0) //hunter-131211: takie - zabezpieczenie - mvControlled->StLinFlag=true; - - if (mvControlled->EngineType==DieselEngine) - dsbDieselIgnition->Play(0,0,0); - else - dsbNastawnikJazdy->Play(0,0,0); - } - } - else */ - - /* if (cKey==Global::Keys[k_Main]) //bez shifta - { - ggMainOffButton.PutValue(1); - if (mvControlled->MainSwitch(false)) - { - dsbNastawnikJazdy->Play(0,0,0); - } - } - else */ - - //---------------- - // hunter-131211: czuwak przeniesiony z OnKeyPress - // hunter-091012: zrobiony test czuwaka - if (Console::Pressed(Global::Keys[k_Czuwak])) - { // czuwak testuje kierunek, ale podobno w - // EZT nie, więc może być w rozrządczym - fCzuwakTestTimer += dt; - ggSecurityResetButton.PutValue(1); - if (CAflag == false) - { - CAflag = true; - mvOccupied->SecuritySystemReset(); - } - else if (fCzuwakTestTimer > 1.0) - SetFlag(mvOccupied->SecuritySystem.Status, s_CAtest); - } - else - { - fCzuwakTestTimer = 0; - ggSecurityResetButton.UpdateValue(0); - if (TestFlag(mvOccupied->SecuritySystem.Status, - s_CAtest)) //&&(!TestFlag(mvControlled->SecuritySystem.Status,s_CAebrake))) - { - SetFlag(mvOccupied->SecuritySystem.Status, -s_CAtest); - mvOccupied->s_CAtestebrake = false; - mvOccupied->SecuritySystem.SystemBrakeCATestTimer = 0; - // if ((!TestFlag(mvOccupied->SecuritySystem.Status,s_SHPebrake)) - // ||(!TestFlag(mvOccupied->SecuritySystem.Status,s_CAebrake))) - // mvControlled->EmergencyBrakeFlag=false; //YB-HN - } - CAflag = false; - } - /* - if ( Console::Pressed(Global::Keys[k_Czuwak]) ) - { - ggSecurityResetButton.PutValue(1); - if ((mvOccupied->SecuritySystem.Status&s_aware)&& - (mvOccupied->SecuritySystem.Status&s_active)) - { - mvOccupied->SecuritySystem.SystemTimer=0; - mvOccupied->SecuritySystem.Status-=s_aware; - mvOccupied->SecuritySystem.VelocityAllowed=-1; - CAflag=1; - } - else if (CAflag!=1) - mvOccupied->SecuritySystemReset(); - } - else - { - ggSecurityResetButton.UpdateValue(0); - CAflag=0; - } - */ - - //----------------- - // hunter-201211: piasecznica przeniesiona z OnKeyPress, wlacza sie tylko, - // gdy trzymamy przycisk, a nie tak jak wczesniej (raz nacisnelo sie 's' - // i sypala caly czas) - /* - if (cKey==Global::Keys[k_Sand]) - { - if (mvControlled->SandDoseOn()) - if (mvControlled->SandDose) - { - dsbPneumaticRelay->SetVolume(-30); - dsbPneumaticRelay->Play(0,0,0); - } - } - */ - - if (Console::Pressed(Global::Keys[k_Sand])) - { - if (mvControlled->TrainType != dt_EZT && ggSandButton.SubModel != NULL) - { - // dsbPneumaticRelay->SetVolume(-30); - // dsbPneumaticRelay->Play(0,0,0); - ggSandButton.PutValue(1); - mvControlled->SandDose = true; - // mvControlled->SandDoseOn(true); - } - } - else - { - mvControlled->SandDose = false; - // mvControlled->SandDoseOn(false); - // dsbPneumaticRelay->SetVolume(-30); - // dsbPneumaticRelay->Play(0,0,0); - } - - //----------------- - // hunter-221211: hamowanie przy poslizgu - if (Console::Pressed(Global::Keys[k_AntiSlipping])) - { - if (mvControlled->BrakeSystem != ElectroPneumatic) - { - ggAntiSlipButton.PutValue(1); - mvControlled->AntiSlippingBrake(); - } - } - else - ggAntiSlipButton.UpdateValue(0); - //----------------- - // hunter-261211: przetwornica i sprezarka - if (Console::Pressed(VK_SHIFT) && - Console::Pressed(Global::Keys[k_Converter])) // NBMX 14-09-2003: przetwornica wl - { //(mvControlled->CompressorPower<2) - ggConverterButton.PutValue(1); - if ((mvControlled->PantFrontVolt != 0.0) || (mvControlled->PantRearVolt != 0.0) || - (mvControlled->EnginePowerSource.SourceType != - CurrentCollector) /*||(!Global::bLiveTraction)*/) - mvControlled->ConverterSwitch(true); - // if - // ((mvControlled->EngineType!=ElectricSeriesMotor)&&(mvControlled->TrainType!=dt_EZT)) - // //hunter-110212: poprawka dla EZT - if (mvControlled->CompressorPower == 2) // hunter-091012: tak jest poprawnie - mvControlled->CompressorSwitch(true); - } - else - { - if (mvControlled->ConvSwitchType == "impulse") - { - ggConverterButton.PutValue(0); - ggConverterOffButton.PutValue(0); - } - } - - // if ( - // Console::Pressed(VK_SHIFT)&&Console::Pressed(Global::Keys[k_Compressor])&&((mvControlled->EngineType==ElectricSeriesMotor)||(mvControlled->TrainType==dt_EZT)) - // ) //NBMX 14-09-2003: sprezarka wl - if (Console::Pressed(VK_SHIFT) && Console::Pressed(Global::Keys[k_Compressor]) && - (mvControlled->CompressorPower < 2)) // hunter-091012: tak jest poprawnie - { // hunter-110212: poprawka dla EZT - ggCompressorButton.PutValue(1); - mvControlled->CompressorSwitch(true); - } - - if (!Console::Pressed(VK_SHIFT) && - Console::Pressed(Global::Keys[k_Converter])) // NBMX 14-09-2003: przetwornica wl - { - ggConverterButton.PutValue(0); - ggConverterOffButton.PutValue(1); - mvControlled->ConverterSwitch(false); - if ((mvControlled->TrainType == dt_EZT) && (!TestFlag(mvControlled->EngDmgFlag, 4))) - mvControlled->ConvOvldFlag = false; - } - - // if ( - // !Console::Pressed(VK_SHIFT)&&Console::Pressed(Global::Keys[k_Compressor])&&((mvControlled->EngineType==ElectricSeriesMotor)||(mvControlled->TrainType==dt_EZT)) - // ) //NBMX 14-09-2003: sprezarka wl - if (!Console::Pressed(VK_SHIFT) && Console::Pressed(Global::Keys[k_Compressor]) && - (mvControlled->CompressorPower < 2)) // hunter-091012: tak jest poprawnie - { // hunter-110212: poprawka dla EZT - ggCompressorButton.PutValue(0); - mvControlled->CompressorSwitch(false); - } - - /* - bez szifta - if (cKey==Global::Keys[k_Converter]) //NBMX wyl przetwornicy - { - if (mvControlled->ConverterSwitch(false)) - { - dsbSwitch->SetVolume(DSBVOLUME_MAX); - dsbSwitch->Play(0,0,0);; - } - } - else - if (cKey==Global::Keys[k_Compressor]) //NBMX wyl sprezarka - { - if (mvControlled->CompressorSwitch(false)) - { - dsbSwitch->SetVolume(DSBVOLUME_MAX); - dsbSwitch->Play(0,0,0);; - } - } - else - */ - //----------------- - - if ((!FreeFlyModeFlag) && - (!(DynamicObject->Mechanik ? DynamicObject->Mechanik->AIControllFlag : false))) - { - if (Console::Pressed(Global::Keys[k_Releaser])) // yB: odluzniacz caly - // czas trzymany, warunki - // powinny byc takie same, - // jak przy naciskaniu. - // Wlasciwie stamtad mozna - // wyrzucic sprawdzanie - // nacisniecia. - { - if ((mvControlled->EngineType == ElectricSeriesMotor) || - (mvControlled->EngineType == DieselElectric)) - if (mvControlled->TrainType != dt_EZT) - if ((mvOccupied->BrakeCtrlPosNo > 0) && (mvControlled->ActiveDir != 0)) - { - ggReleaserButton.PutValue(1); - mvOccupied->BrakeReleaser(1); - } - } // releaser - else - mvOccupied->BrakeReleaser(0); - } // FFMF - - if (Console::Pressed(Global::Keys[k_Univ1])) - { - if (!DebugModeFlag) - { - if (ggUniversal1Button.SubModel) - if (Console::Pressed(VK_SHIFT)) - ggUniversal1Button.IncValue(dt / 2); - else - ggUniversal1Button.DecValue(dt / 2); - } - } - if (!Console::Pressed(Global::Keys[k_SmallCompressor])) - // Ra: przecieść to na zwolnienie klawisza - if (DynamicObject->Mechanik ? !DynamicObject->Mechanik->AIControllFlag : - false) // nie wyłączać, gdy AI - mvControlled->PantCompFlag = false; // wyłączona, gdy nie trzymamy klawisza - if (Console::Pressed(Global::Keys[k_Univ2])) - { - if (!DebugModeFlag) - { - if (ggUniversal2Button.SubModel) - if (Console::Pressed(VK_SHIFT)) - ggUniversal2Button.IncValue(dt / 2); - else - ggUniversal2Button.DecValue(dt / 2); - } - } - - // hunter-091012: zrobione z uwzglednieniem przelacznika swiatla - if (Console::Pressed(Global::Keys[k_Univ3])) - { - if (Console::Pressed(VK_SHIFT)) - { - if (Console::Pressed(VK_CONTROL)) - { - bCabLight = true; - if (ggCabLightButton.SubModel) - { - ggCabLightButton.PutValue(1); - btCabLight.TurnOn(); - } - } - else - { - if (ggUniversal3Button.SubModel) - { - ggUniversal3Button.PutValue(1); // hunter-131211: z UpdateValue na - // PutValue - by zachowywal sie jak - // pozostale przelaczniki - if (btLampkaUniversal3.Active()) - LampkaUniversal3_st = true; - } - } - } - else - { - if (Console::Pressed(VK_CONTROL)) - { - bCabLight = false; - if (ggCabLightButton.SubModel) - { - ggCabLightButton.PutValue(0); - btCabLight.TurnOff(); - } - } - else - { - if (ggUniversal3Button.SubModel) - { - ggUniversal3Button.PutValue(0); // hunter-131211: z UpdateValue na - // PutValue - by zachowywal sie jak - // pozostale przelaczniki - if (btLampkaUniversal3.Active()) - LampkaUniversal3_st = false; - } - } - } - } - - // hunter-091012: to w ogole jest bez sensu i tak namodzone ze nie wiadomo o - // co chodzi - zakomentowalem i zrobilem po swojemu - /* - if ( Console::Pressed(Global::Keys[k_Univ3]) ) - { - if (ggUniversal3Button.SubModel) - - - if (Console::Pressed(VK_CONTROL)) - {//z [Ctrl] zapalamy albo gasimy światełko w kabinie - //tutaj jest bez sensu, trzeba reagować na wciskanie klawisza! - if (Console::Pressed(VK_SHIFT)) - {//zapalenie - if (iCabLightFlag<2) ++iCabLightFlag; - } - else - {//gaszenie - if (iCabLightFlag) --iCabLightFlag; - } - - } - else - {//bez [Ctrl] przełączamy cośtem - if (Console::Pressed(VK_SHIFT)) - { - ggUniversal3Button.PutValue(1); //hunter-131211: z UpdateValue na - PutValue - by zachowywal sie jak pozostale przelaczniki - if (btLampkaUniversal3.Active()) - LampkaUniversal3_st=true; - } - else - { - ggUniversal3Button.PutValue(0); //hunter-131211: z UpdateValue na - PutValue - by zachowywal sie jak pozostale przelaczniki - if (btLampkaUniversal3.Active()) - LampkaUniversal3_st=false; - } - } - } */ - - // ABu030405 obsluga lampki uniwersalnej: - if (btLampkaUniversal3.Active()) // w ogóle jest - if (LampkaUniversal3_st) // załączona - switch (LampkaUniversal3_typ) - { - case 0: - btLampkaUniversal3.Turn(mvControlled->Battery); - break; - case 1: - btLampkaUniversal3.Turn(mvControlled->Mains); - break; - case 2: - btLampkaUniversal3.Turn(mvControlled->ConverterFlag); - break; - default: - btLampkaUniversal3.TurnOff(); - } - else - btLampkaUniversal3.TurnOff(); - - /* - if (Console::Pressed(Global::Keys[k_Univ4])) - { - if (ggUniversal4Button.SubModel) - if (Console::Pressed(VK_SHIFT)) - { - ActiveUniversal4=true; - //ggUniversal4Button.UpdateValue(1); - } - else - { - ActiveUniversal4=false; - //ggUniversal4Button.UpdateValue(0); - } - } - */ - - // hunter-091012: przepisanie univ4 i zrobione z uwzglednieniem przelacznika - // swiatla - if (Console::Pressed(Global::Keys[k_Univ4])) - { - if (Console::Pressed(VK_SHIFT)) - { - if (Console::Pressed(VK_CONTROL)) - { - bCabLightDim = true; - if (ggCabLightDimButton.SubModel) - { - ggCabLightDimButton.PutValue(1); - } - } - else - { - ActiveUniversal4 = true; - // ggUniversal4Button.UpdateValue(1); - } - } - else - { - if (Console::Pressed(VK_CONTROL)) - { - bCabLightDim = false; - if (ggCabLightDimButton.SubModel) - { - ggCabLightDimButton.PutValue(0); // hunter-131211: z UpdateValue na - // PutValue - by zachowywal sie jak - // pozostale przelaczniki - } - } - else - { - ActiveUniversal4 = false; - // ggUniversal4Button.UpdateValue(0); - } - } - } - // Odskakiwanie hamulce EP - if ((!Console::Pressed(Global::Keys[k_DecBrakeLevel])) && - (!Console::Pressed(Global::Keys[k_WaveBrake])) && (mvOccupied->BrakeCtrlPos == -1) && - (mvOccupied->BrakeHandle == FVel6) && (DynamicObject->Controller != AIdriver) && - (Global::iFeedbackMode != 4)) - { - // mvOccupied->BrakeCtrlPos=(mvOccupied->BrakeCtrlPos)+1; - // mvOccupied->IncBrakeLevel(); - mvOccupied->BrakeLevelSet(mvOccupied->BrakeCtrlPos + 1); - keybrakecount = 0; - if ((mvOccupied->TrainType == dt_EZT) && (mvControlled->Mains) && - (mvControlled->ActiveDir != 0)) - { - dsbPneumaticSwitch->SetVolume(-10); - dsbPneumaticSwitch->Play(0, 0, 0); - } - } - - // Ra: przeklejka z SPKS - płynne poruszanie hamulcem - // if - // ((mvOccupied->BrakeHandle==FV4a)&&(Console::Pressed(Global::Keys[k_IncBrakeLevel]))) - if ((Console::Pressed(Global::Keys[k_IncBrakeLevel]))) - { - if (Console::Pressed(VK_CONTROL)) - { - // mvOccupied->BrakeCtrlPos2-=dt/20.0; - // if (mvOccupied->BrakeCtrlPos2<-1.5) mvOccupied->BrakeCtrlPos2=-1.5; - } - else - { - // mvOccupied->BrakeCtrlPosR+=(mvOccupied->BrakeCtrlPosR>mvOccupied->BrakeCtrlPosNo?0:dt*2); - // mvOccupied->BrakeCtrlPos= floor(mvOccupied->BrakeCtrlPosR+0.499); - } - } - // if - // ((mvOccupied->BrakeHandle==FV4a)&&(Console::Pressed(Global::Keys[k_DecBrakeLevel]))) - if ((Console::Pressed(Global::Keys[k_DecBrakeLevel]))) - { - if (Console::Pressed(VK_CONTROL)) - { - // mvOccupied->BrakeCtrlPos2+=(mvOccupied->BrakeCtrlPos2>2?0:dt/20.0); - // if (mvOccupied->BrakeCtrlPos2<-3) mvOccupied->BrakeCtrlPos2=-3; - // mvOccupied->BrakeLevelAdd(mvOccupied->fBrakeCtrlPos<-1?0:dt*2); - } - else - { - // mvOccupied->BrakeCtrlPosR-=(mvOccupied->BrakeCtrlPosR<-1?0:dt*2); - // mvOccupied->BrakeCtrlPos= floor(mvOccupied->BrakeCtrlPosR+0.499); - // mvOccupied->BrakeLevelAdd(mvOccupied->fBrakeCtrlPos<-1?0:-dt*2); - } - } - - if ((mvOccupied->BrakeHandle == FV4a) && (Console::Pressed(Global::Keys[k_IncBrakeLevel]))) - { - if (Console::Pressed(VK_CONTROL)) - { - mvOccupied->BrakeCtrlPos2 -= dt / 20.0; - if (mvOccupied->BrakeCtrlPos2 < -1.5) - mvOccupied->BrakeCtrlPos2 = -1.5; - } - else - { - // mvOccupied->BrakeCtrlPosR+=(mvOccupied->BrakeCtrlPosR>mvOccupied->BrakeCtrlPosNo?0:dt*2); - mvOccupied->BrakeLevelAdd(dt * 2); - // mvOccupied->BrakeCtrlPos= - // floor(mvOccupied->BrakeCtrlPosR+0.499); - } - } - - if ((mvOccupied->BrakeHandle == FV4a) && (Console::Pressed(Global::Keys[k_DecBrakeLevel]))) - { - if (Console::Pressed(VK_CONTROL)) - { - mvOccupied->BrakeCtrlPos2 += (mvOccupied->BrakeCtrlPos2 > 2 ? 0 : dt / 20.0); - if (mvOccupied->BrakeCtrlPos2 < -3) - mvOccupied->BrakeCtrlPos2 = -3; - } - else - { - // mvOccupied->BrakeCtrlPosR-=(mvOccupied->BrakeCtrlPosR<-1?0:dt*2); - // mvOccupied->BrakeCtrlPos= - // floor(mvOccupied->BrakeCtrlPosR+0.499); - mvOccupied->BrakeLevelAdd(-dt * 2); - } - } - - // bool kEP; - // kEP=(mvOccupied->BrakeSubsystem==Knorr)||(mvOccupied->BrakeSubsystem==Hik)||(mvOccupied->BrakeSubsystem==Kk); - if ((mvOccupied->BrakeSystem == ElectroPneumatic) && ((mvOccupied->BrakeHandle == St113)) && - (mvControlled->EpFuse == true)) - if (Console::Pressed(Global::Keys[k_AntiSlipping])) // kEP - { - ggAntiSlipButton.UpdateValue(1); - if (mvOccupied->SwitchEPBrake(1)) - { - dsbPneumaticSwitch->SetVolume(-10); - dsbPneumaticSwitch->Play(0, 0, 0); - } - } - else - { - if (mvOccupied->SwitchEPBrake(0)) - { - dsbPneumaticSwitch->SetVolume(-10); - dsbPneumaticSwitch->Play(0, 0, 0); - } - } - - if (Console::Pressed(Global::Keys[k_DepartureSignal])) - { - ggDepartureSignalButton.PutValue(1); - btLampkaDepartureSignal.TurnOn(); - mvControlled->DepartureSignal = true; - } - else - { - btLampkaDepartureSignal.TurnOff(); - if (DynamicObject->Mechanik) // może nie być? - if (!DynamicObject->Mechanik->AIControllFlag) // tylko jeśli nie prowadzi AI - mvControlled->DepartureSignal = false; - } - - if (Console::Pressed(Global::Keys[k_Main])) //[] - { - if (Console::Pressed(VK_SHIFT)) - ggMainButton.PutValue(1); - else - ggMainButton.PutValue(0); - } - else - ggMainButton.PutValue(0); - - if (Console::Pressed(Global::Keys[k_CurrentNext])) - { - if (mvControlled->TrainType != dt_EZT) - { - if (ShowNextCurrent == false) - { - if (ggNextCurrentButton.SubModel) - { - ggNextCurrentButton.UpdateValue(1); - dsbSwitch->SetVolume(DSBVOLUME_MAX); - dsbSwitch->Play(0, 0, 0); - ShowNextCurrent = true; - } - } - } - else - { - if (Console::Pressed(VK_SHIFT)) - { - // if (Console::Pressed(k_CurrentNext)) - { // Ra: było pod VK_F3 - if ((mvOccupied->EpFuseSwitch(true))) - { - dsbPneumaticSwitch->SetVolume(-10); - dsbPneumaticSwitch->Play(0, 0, 0); - } - } - } - else - { - // if (Console::Pressed(k_CurrentNext)) - { // Ra: było pod VK_F3 - if (Console::Pressed(VK_CONTROL)) - { - if ((mvOccupied->EpFuseSwitch(false))) - { - dsbPneumaticSwitch->SetVolume(-10); - dsbPneumaticSwitch->Play(0, 0, 0); - } - } - } - } - } - } - else - { - if (ShowNextCurrent == true) - { - if (ggNextCurrentButton.SubModel) - { - ggNextCurrentButton.UpdateValue(0); - dsbSwitch->SetVolume(DSBVOLUME_MAX); - dsbSwitch->Play(0, 0, 0); - ShowNextCurrent = false; - } - } - } - - // Winger 010304 PantAllDownButton - if (Console::Pressed(Global::Keys[k_PantFrontUp])) - { - if (Console::Pressed(VK_SHIFT)) - ggPantFrontButton.PutValue(1); - else - ggPantAllDownButton.PutValue(1); - } - else if (mvControlled->PantSwitchType == "impulse") - { - ggPantFrontButton.PutValue(0); - ggPantAllDownButton.PutValue(0); - } - - if (Console::Pressed(Global::Keys[k_PantRearUp])) - { - if (Console::Pressed(VK_SHIFT)) - ggPantRearButton.PutValue(1); - else - ggPantFrontButtonOff.PutValue(1); - } - else if (mvControlled->PantSwitchType == "impulse") - { - ggPantRearButton.PutValue(0); - ggPantFrontButtonOff.PutValue(0); - } - - /* if ((mvControlled->Mains) && - (mvControlled->EngineType==ElectricSeriesMotor)) - { - //tu dac w przyszlosci zaleznosc od wlaczenia przetwornicy - if (mvControlled->ConverterFlag) //NBMX -obsluga przetwornicy - { - //glosnosc zalezna od nap. sieci - //-2000 do 0 - long tmpVol; - int trackVol; - trackVol=3550-2000; - if (mvControlled->RunningTraction.TractionVoltage<2000) - { - tmpVol=0; - } - else - { - tmpVol=mvControlled->RunningTraction.TractionVoltage-2000; - } - sConverter.Volume(-2000*(trackVol-tmpVol)/trackVol); - - if (!sConverter.Playing()) - sConverter.TurnOn(); - } - else //wyl przetwornicy - sConverter.TurnOff(); - } - else - { - if (sConverter.Playing()) - sConverter.TurnOff(); - } - sConverter.Update(); - */ - - // if (fabs(DynamicObject->GetVelocity())>0.5) - if (FreeFlyModeFlag ? false : fTachoCount > maxtacho) - { - dsbHasler->GetStatus(&stat); - if (!(stat & DSBSTATUS_PLAYING)) - dsbHasler->Play(0, 0, DSBPLAY_LOOPING); - } - else - { - if (FreeFlyModeFlag ? true : fTachoCount < 1) - { - dsbHasler->GetStatus(&stat); - if (stat & DSBSTATUS_PLAYING) - dsbHasler->Stop(); - } - } - - // koniec mieszania z dzwiekami + // lights + auto const lightpower { ( + InstrumentLightType == 0 ? mvControlled->Battery || mvControlled->ConverterFlag : + InstrumentLightType == 1 ? mvControlled->Mains : + InstrumentLightType == 2 ? mvControlled->ConverterFlag : + false ) }; + btInstrumentLight.Turn( InstrumentLightActive && lightpower ); + btDashboardLight.Turn( DashboardLightActive && lightpower ); + btTimetableLight.Turn( TimetableLightActive && lightpower ); // guziki: ggMainOffButton.Update(); @@ -4960,10 +5837,24 @@ bool TTrain::Update( double const Deltatime ) ggConverterFuseButton.Update(); ggStLinOffButton.Update(); ggRadioButton.Update(); + ggRadioChannelSelector.Update(); + ggRadioChannelPrevious.Update(); + ggRadioChannelNext.Update(); + ggRadioStop.Update(); + ggRadioTest.Update(); ggDepartureSignalButton.Update(); + ggPantFrontButton.Update(); ggPantRearButton.Update(); + ggPantSelectedButton.Update(); ggPantFrontButtonOff.Update(); + ggPantRearButtonOff.Update(); + ggPantSelectedDownButton.Update(); + ggPantAllDownButton.Update(); + ggPantCompressorButton.Update(); + ggPantCompressorValve.Update(); + + ggLightsButton.Update(); ggUpperLightButton.Update(); ggLeftLightButton.Update(); ggRightLightButton.Update(); @@ -4975,51 +5866,458 @@ bool TTrain::Update( double const Deltatime ) ggRearRightLightButton.Update(); ggRearLeftEndLightButton.Update(); ggRearRightEndLightButton.Update(); + ggDimHeadlightsButton.Update(); //------------ - ggPantAllDownButton.Update(); ggConverterButton.Update(); + ggConverterLocalButton.Update(); ggConverterOffButton.Update(); ggTrainHeatingButton.Update(); ggSignallingButton.Update(); ggNextCurrentButton.Update(); ggHornButton.Update(); - ggUniversal1Button.Update(); - ggUniversal2Button.Update(); - ggUniversal3Button.Update(); + ggHornLowButton.Update(); + ggHornHighButton.Update(); + ggWhistleButton.Update(); + for( auto &universal : ggUniversals ) { + universal.Update(); + } // hunter-091012 + ggInstrumentLightButton.Update(); + ggDashboardLightButton.Update(); + ggTimetableLightButton.Update(); ggCabLightButton.Update(); ggCabLightDimButton.Update(); ggBatteryButton.Update(); + + ggWaterPumpBreakerButton.Update(); + ggWaterPumpButton.Update(); + ggWaterHeaterBreakerButton.Update(); + ggWaterHeaterButton.Update(); + ggWaterCircuitsLinkButton.Update(); + ggFuelPumpButton.Update(); + ggOilPumpButton.Update(); + ggMotorBlowersFrontButton.Update(); + ggMotorBlowersRearButton.Update(); + ggMotorBlowersAllOffButton.Update(); //------ - if (ActiveUniversal4) - ggUniversal4Button.PermIncValue(dt); - - ggUniversal4Button.Update(); - ggMainOffButton.UpdateValue(0); - ggMainOnButton.UpdateValue(0); - ggSecurityResetButton.UpdateValue(0); - ggReleaserButton.UpdateValue(0); - ggSandButton.UpdateValue(0); - ggAntiSlipButton.UpdateValue(0); - ggDepartureSignalButton.UpdateValue(0); - ggFuseButton.UpdateValue(0); - ggConverterFuseButton.UpdateValue(0); - - pyScreens.update(); } // wyprowadzenie sygnałów dla haslera na PoKeys (zaznaczanie na taśmie) btHaslerBrakes.Turn(DynamicObject->MoverParameters->BrakePress > 0.4); // ciśnienie w cylindrach btHaslerCurrent.Turn(DynamicObject->MoverParameters->Im != 0.0); // prąd na silnikach - m_updated = true; + // calculate current level of interior illumination + // TODO: organize it along with rest of train update in a more sensible arrangement + switch( iCabLightFlag ) // Ra: uzeleżnic od napięcia w obwodzie sterowania + { // hunter-091012: uzaleznienie jasnosci od przetwornicy + case 0: { + //światło wewnętrzne zgaszone + DynamicObject->InteriorLightLevel = 0.0f; + break; + } + case 1: { + //światło wewnętrzne przygaszone (255 216 176) + auto const converteractive { ( + ( mvOccupied->ConverterFlag ) + || ( ( ( mvOccupied->Couplers[ side::front ].CouplingFlag & coupling::permanent ) != 0 ) && mvOccupied->Couplers[ side::front ].Connected->ConverterFlag ) + || ( ( ( mvOccupied->Couplers[ side::rear ].CouplingFlag & coupling::permanent ) != 0 ) && mvOccupied->Couplers[ side::rear ].Connected->ConverterFlag ) ) }; + + DynamicObject->InteriorLightLevel = ( + converteractive ? + 0.4f : + 0.2f ); + break; + } + case 2: { + //światło wewnętrzne zapalone (255 216 176) + auto const converteractive { ( + ( mvOccupied->ConverterFlag ) + || ( ( ( mvOccupied->Couplers[ side::front ].CouplingFlag & coupling::permanent ) != 0 ) && mvOccupied->Couplers[ side::front ].Connected->ConverterFlag ) + || ( ( ( mvOccupied->Couplers[ side::rear ].CouplingFlag & coupling::permanent ) != 0 ) && mvOccupied->Couplers[ side::rear ].Connected->ConverterFlag ) ) }; + + DynamicObject->InteriorLightLevel = ( + converteractive ? + 1.0f : + 0.5f ); + break; + } + } + + // anti slip system activation, maintained while the control button is down + if( mvOccupied->BrakeSystem != TBrakeSystem::ElectroPneumatic ) { + if( ggAntiSlipButton.GetDesiredValue() > 0.95 ) { + mvControlled->AntiSlippingBrake(); + } + } + + // NOTE: crude way to have the pantographs go back up if they're dropped due to insufficient pressure etc + // TODO: rework it into something more elegant, when redoing the whole consist/unit/cab etc arrangement + if( false == DynamicObject->Mechanik->AIControllFlag ) { + // don't mess with the ai driving, at least not while switches don't follow ai-set vehicle state + if( ( mvControlled->Battery ) + || ( mvControlled->ConverterFlag ) ) { + if( ggPantAllDownButton.GetDesiredValue() < 0.05 ) { + // the 'lower all' button overrides state of switches, while active itself + if( ( false == mvControlled->PantFrontUp ) + && ( ggPantFrontButton.GetDesiredValue() >= 0.95 ) ) { + mvControlled->PantFront( true ); + } + if( ( false == mvControlled->PantRearUp ) + && ( ggPantRearButton.GetDesiredValue() >= 0.95 ) ) { + mvControlled->PantRear( true ); + } + } + } + } +/* + // check whether we should raise the pantographs, based on volume in pantograph tank + // NOTE: disabled while switch state isn't preserved while moving between compartments + if( mvControlled->PantPress > ( + mvControlled->TrainType == dt_EZT ? + 2.4 : + 3.5 ) ) { + if( ( false == mvControlled->PantFrontUp ) + && ( ggPantFrontButton.GetValue() > 0.95 ) ) { + mvControlled->PantFront( true ); + } + if( ( false == mvControlled->PantRearUp ) + && ( ggPantRearButton.GetValue() > 0.95 ) ) { + mvControlled->PantRear( true ); + } + } +*/ + // screens + fScreenTimer += Deltatime; + if( ( fScreenTimer > Global.PythonScreenUpdateRate * 0.001f ) + && ( false == FreeFlyModeFlag ) ) { // don't bother if we're outside + fScreenTimer = 0.f; + for( auto const &screen : m_screens ) { + Application.request( { screen.first, GetTrainState(), screen.second } ); + } + } + // sounds + update_sounds( Deltatime ); + return true; //(DynamicObject->Update(dt)); } // koniec update +void +TTrain::update_sounds( double const Deltatime ) { + + if( Deltatime == 0.0 ) { return; } + + double volume { 0.0 }; + double const brakevolumescale { 0.5 }; + + // Winger-160404 - syczenie pomocniczego (luzowanie) + if( m_lastlocalbrakepressure != -1.f ) { + // calculate rate of pressure drop in local brake cylinder, once it's been initialized + auto const brakepressuredifference { mvOccupied->LocBrakePress - m_lastlocalbrakepressure }; + m_localbrakepressurechange = interpolate( m_localbrakepressurechange, 10 * ( brakepressuredifference / Deltatime ), 0.1f ); + } + m_lastlocalbrakepressure = mvOccupied->LocBrakePress; + // local brake, release + if( ( m_localbrakepressurechange < -0.05f ) + && ( mvOccupied->LocBrakePress > mvOccupied->BrakePress - 0.05 ) ) { + rsSBHiss + .gain( clamp( rsSBHiss.m_amplitudeoffset + rsSBHiss.m_amplitudefactor * -m_localbrakepressurechange * 0.05, 0.0, 1.5 ) ) + .play( sound_flags::exclusive | sound_flags::looping ); + } + else { + // don't stop the sound too abruptly + volume = std::max( 0.0, rsSBHiss.gain() - 0.1 * Deltatime ); + rsSBHiss.gain( volume ); + if( volume < 0.05 ) { + rsSBHiss.stop(); + } + } + // local brake, engage + if( m_localbrakepressurechange > 0.05f ) { + rsSBHissU + .gain( clamp( rsSBHissU.m_amplitudeoffset + rsSBHissU.m_amplitudefactor * m_localbrakepressurechange * 0.05, 0.0, 1.5 ) ) + .play( sound_flags::exclusive | sound_flags::looping ); + } + else { + // don't stop the sound too abruptly + volume = std::max( 0.0, rsSBHissU.gain() - 0.1 * Deltatime ); + rsSBHissU.gain( volume ); + if( volume < 0.05 ) { + rsSBHissU.stop(); + } + } + + // McZapkie-280302 - syczenie + // TODO: softer volume reduction than plain abrupt stop, perhaps as reusable wrapper? + if( ( mvOccupied->BrakeHandle == TBrakeHandle::FV4a ) + || ( mvOccupied->BrakeHandle == TBrakeHandle::FVel6 ) ) { + // upuszczanie z PG + fPPress = interpolate( fPPress, static_cast( mvOccupied->Handle->GetSound( s_fv4a_b ) ), 0.05f ); + volume = ( + fPPress > 0 ? + rsHiss.m_amplitudefactor * fPPress * 0.25 : + 0 ); + if( volume * brakevolumescale > 0.05 ) { + rsHiss + .gain( volume * brakevolumescale ) + .play( sound_flags::exclusive | sound_flags::looping ); + } + else { + rsHiss.stop(); + } + // napelnianie PG + fNPress = interpolate( fNPress, static_cast( mvOccupied->Handle->GetSound( s_fv4a_u ) ), 0.25f ); + volume = ( + fNPress > 0 ? + rsHissU.m_amplitudefactor * fNPress : + 0 ); + if( volume * brakevolumescale > 0.05 ) { + rsHissU + .gain( volume * brakevolumescale ) + .play( sound_flags::exclusive | sound_flags::looping ); + } + else { + rsHissU.stop(); + } + // upuszczanie przy naglym + volume = mvOccupied->Handle->GetSound( s_fv4a_e ) * rsHissE.m_amplitudefactor; + if( volume * brakevolumescale > 0.05 ) { + rsHissE + .gain( volume * brakevolumescale ) + .play( sound_flags::exclusive | sound_flags::looping ); + } + else { + rsHissE.stop(); + } + // upuszczanie sterujacego fala + volume = mvOccupied->Handle->GetSound( s_fv4a_x ) * rsHissX.m_amplitudefactor; + if( volume * brakevolumescale > 0.05 ) { + rsHissX + .gain( volume * brakevolumescale ) + .play( sound_flags::exclusive | sound_flags::looping ); + } + else { + rsHissX.stop(); + } + // upuszczanie z czasowego + volume = mvOccupied->Handle->GetSound( s_fv4a_t ) * rsHissT.m_amplitudefactor; + if( volume * brakevolumescale > 0.05 ) { + rsHissT + .gain( volume * brakevolumescale ) + .play( sound_flags::exclusive | sound_flags::looping ); + } + else { + rsHissT.stop(); + } + + } else { + // jesli nie FV4a + // upuszczanie z PG + fPPress = ( 4.0f * fPPress + std::max( mvOccupied->dpLocalValve, mvOccupied->dpMainValve ) ) / ( 4.0f + 1.0f ); + volume = ( + fPPress > 0.0f ? + 2.0 * rsHiss.m_amplitudefactor * fPPress : + 0.0 ); + if( volume > 0.05 ) { + rsHiss + .gain( volume ) + .play( sound_flags::exclusive | sound_flags::looping ); + } + else { + rsHiss.stop(); + } + // napelnianie PG + fNPress = ( 4.0f * fNPress + Min0R( mvOccupied->dpLocalValve, mvOccupied->dpMainValve ) ) / ( 4.0f + 1.0f ); + volume = ( + fNPress < 0.0f ? + -1.0 * rsHissU.m_amplitudefactor * fNPress : + 0.0 ); + if( volume > 0.01 ) { + rsHissU + .gain( volume ) + .play( sound_flags::exclusive | sound_flags::looping ); + } + else { + rsHissU.stop(); + } + } // koniec nie FV4a + + // ambient sound + // since it's typically ticking of the clock we can center it on tachometer or on middle of compartment bounding area + rsFadeSound.play( sound_flags::exclusive | sound_flags::looping ); + + if( mvControlled->TrainType == dt_181 ) { + // alarm przy poslizgu dla 181/182 - BOMBARDIER + if( ( mvControlled->SlippingWheels ) + && ( DynamicObject->GetVelocity() > 1.0 ) ) { + dsbSlipAlarm.play( sound_flags::exclusive | sound_flags::looping ); + } + else { + dsbSlipAlarm.stop(); + } + } + // szum w czasie jazdy + if( ( false == FreeFlyModeFlag ) + && ( false == Global.CabWindowOpen ) + && ( DynamicObject->GetVelocity() > 0.5 ) ) { + + update_sounds_runningnoise( rsRunningNoise ); + } + else { + // don't play the optional ending sound if the listener switches views + rsRunningNoise.stop( true == FreeFlyModeFlag ); + } + // hunting oscillation noise + if( ( false == FreeFlyModeFlag ) + && ( false == Global.CabWindowOpen ) + && ( DynamicObject->GetVelocity() > 0.5 ) + && ( IsHunting ) ) { + + update_sounds_runningnoise( rsHuntingNoise ); + // modify calculated sound volume by hunting amount + auto const huntingamount = + interpolate( + 0.0, 1.0, + clamp( + ( mvOccupied->Vel - HuntingShake.fadein_begin ) / ( HuntingShake.fadein_end - HuntingShake.fadein_begin ), + 0.0, 1.0 ) ); + + rsHuntingNoise.gain( rsHuntingNoise.gain() * huntingamount ); + } + else { + // don't play the optional ending sound if the listener switches views + rsHuntingNoise.stop( true == FreeFlyModeFlag ); + } + + // McZapkie-141102: SHP i czuwak, TODO: sygnalizacja kabinowa + if (mvOccupied->SecuritySystem.Status > 0) { + // hunter-091012: rozdzielenie alarmow + if( TestFlag( mvOccupied->SecuritySystem.Status, s_CAalarm ) + || TestFlag( mvOccupied->SecuritySystem.Status, s_SHPalarm ) ) { + + if( false == dsbBuzzer.is_playing() ) { + dsbBuzzer.play( sound_flags::looping ); + Console::BitsSet( 1 << 14 ); // ustawienie bitu 16 na PoKeys + } + } + else { + if( true == dsbBuzzer.is_playing() ) { + dsbBuzzer.stop(); + Console::BitsClear( 1 << 14 ); // ustawienie bitu 16 na PoKeys + } + } + } + else { + // wylaczone + if( true == dsbBuzzer.is_playing() ) { + dsbBuzzer.stop(); + Console::BitsClear( 1 << 14 ); // ustawienie bitu 16 na PoKeys + } + } + + update_sounds_radio(); + + if( fTachoCount >= 3.f ) { + auto const frequency { ( + true == dsbHasler.is_combined() ? + fTachoVelocity * 0.01 : + 1.0 ) }; + dsbHasler + .pitch( frequency ) + .play( sound_flags::exclusive | sound_flags::looping ); + } + else if( fTachoCount < 1.f ) { + dsbHasler.stop(); + } +} + +void TTrain::update_sounds_runningnoise( sound_source &Sound ) { + // frequency calculation + auto const normalizer { ( + true == Sound.is_combined() ? + mvOccupied->Vmax * 0.01f : + 1.f ) }; + auto const frequency { + Sound.m_frequencyoffset + + Sound.m_frequencyfactor * mvOccupied->Vel * normalizer }; + + // volume calculation + auto volume = + Sound.m_amplitudeoffset + + Sound.m_amplitudefactor * mvOccupied->Vel; + if( std::abs( mvOccupied->nrot ) > 0.01 ) { + // hamulce wzmagaja halas + auto const brakeforceratio { ( + clamp( + mvOccupied->UnitBrakeForce / std::max( 1.0, mvOccupied->BrakeForceR( 1.0, mvOccupied->Vel ) / ( mvOccupied->NAxles * std::max( 1, mvOccupied->NBpA ) ) ), + 0.0, 1.0 ) ) }; + + volume *= 1 + 0.125 * brakeforceratio; + } + // scale volume by track quality + // TODO: track quality and/or environment factors as separate subroutine + volume *= + interpolate( + 0.8, 1.2, + clamp( + DynamicObject->MyTrack->iQualityFlag / 20.0, + 0.0, 1.0 ) ); + // for single sample sounds muffle the playback at low speeds + if( false == Sound.is_combined() ) { + volume *= + interpolate( + 0.0, 1.0, + clamp( + mvOccupied->Vel / 40.0, + 0.0, 1.0 ) ); + } + + if( volume > 0.05 ) { + Sound + .pitch( frequency ) + .gain( volume ) + .play( sound_flags::exclusive | sound_flags::looping ); + } + else { + Sound.stop(); + } +} + +void TTrain::update_sounds_radio() { + + if( false == m_radiomessages.empty() ) { + // erase completed radio messages from the list + m_radiomessages.erase( + std::remove_if( + std::begin( m_radiomessages ), std::end( m_radiomessages ), + []( auto const &source ) { + return ( false == source.second->is_playing() ); } ), + std::end( m_radiomessages ) ); + } + // adjust audibility of remaining messages based on current radio conditions + auto const radioenabled { ( true == mvOccupied->Radio ) && ( mvControlled->Battery || mvControlled->ConverterFlag ) }; + for( auto &message : m_radiomessages ) { + auto const volume { + ( true == radioenabled ) + && ( message.first == iRadioChannel ) ? + 1.0 : + 0.0 }; + message.second->gain( volume ); + } + // radiostop + if( ( true == radioenabled ) + && ( true == mvOccupied->RadioStopFlag ) ) { + m_radiostop.play( sound_flags::exclusive | sound_flags::looping ); + } + else { + m_radiostop.stop(); + } +} + bool TTrain::CabChange(int iDirection) { // McZapkie-090902: zmiana kabiny 1->0->2 i z powrotem - if (DynamicObject->Mechanik ? DynamicObject->Mechanik->AIControllFlag : - true) // jeśli prowadzi AI albo jest w innym członie - { // jak AI prowadzi, to nie można mu mieszać + if( ( DynamicObject->Mechanik == nullptr ) + || ( true == DynamicObject->Mechanik->AIControllFlag ) ) { + // jeśli prowadzi AI albo jest w innym członie + // jak AI prowadzi, to nie można mu mieszać if (abs(DynamicObject->MoverParameters->ActiveCab + iDirection) > 1) return false; // ewentualna zmiana pojazdu DynamicObject->MoverParameters->ActiveCab = @@ -5033,14 +6331,12 @@ bool TTrain::CabChange(int iDirection) DynamicObject->asBaseDir + DynamicObject->MoverParameters->TypeName + ".mmd")) { // zmiana kabiny w ramach tego samego pojazdu - DynamicObject->MoverParameters - ->CabActivisation(); // załączenie rozrządu (wirtualne kabiny) + DynamicObject->MoverParameters->CabActivisation(); // załączenie rozrządu (wirtualne kabiny) + DynamicObject->Mechanik->CheckVehicles( Change_direction ); return true; // udało się zmienić kabinę } - DynamicObject->MoverParameters->CabActivisation(); // aktywizacja - // poprzedniej, bo - // jeszcze nie wiadomo, - // czy jakiś pojazd jest + // aktywizacja poprzedniej, bo jeszcze nie wiadomo, czy jakiś pojazd jest + DynamicObject->MoverParameters->CabActivisation(); } return false; // ewentualna zmiana pojazdu } @@ -5049,16 +6345,9 @@ bool TTrain::CabChange(int iDirection) // wczytywanie pliku z danymi multimedialnymi (dzwieki, kontrolki, kabiny) bool TTrain::LoadMMediaFile(std::string const &asFileName) { - double dSDist; cParser parser(asFileName, cParser::buffer_FILE); // NOTE: yaml-style comments are disabled until conflict in use of # is resolved // parser.addCommentStyle( "#", "\n" ); - //Wartości domyślne by nie wysypywało przy wybrakowanych mmd @240816 Stele - dsbPneumaticSwitch = TSoundsManager::GetFromName("silence1.wav", true); - dsbBufferClamp = TSoundsManager::GetFromName("en57_bufferclamp.wav", true); - dsbCouplerDetach = TSoundsManager::GetFromName("couplerdetach.wav", true); - dsbCouplerStretch = TSoundsManager::GetFromName("en57_couplerstretch.wav", true); - dsbCouplerAttach = TSoundsManager::GetFromName("couplerattach.wav", true); std::string token; do @@ -5070,7 +6359,6 @@ bool TTrain::LoadMMediaFile(std::string const &asFileName) if (token == "internaldata:") { - do { token = ""; @@ -5080,252 +6368,164 @@ bool TTrain::LoadMMediaFile(std::string const &asFileName) if (token == "ctrl:") { // nastawnik: - dsbNastawnikJazdy = - TSoundsManager::GetFromName(parser.getToken().c_str(), true); + dsbNastawnikJazdy.deserialize( parser, sound_type::single ); + dsbNastawnikJazdy.owner( DynamicObject ); } else if (token == "ctrlscnd:") { // hunter-081211: nastawnik bocznikowania - dsbNastawnikBocz = - TSoundsManager::GetFromName(parser.getToken().c_str(), true); + dsbNastawnikBocz.deserialize( parser, sound_type::single ); + dsbNastawnikBocz.owner( DynamicObject ); } else if (token == "reverserkey:") { // hunter-131211: dzwiek kierunkowego - dsbReverserKey = - TSoundsManager::GetFromName(parser.getToken().c_str(), true); + dsbReverserKey.deserialize( parser, sound_type::single ); + dsbReverserKey.owner( DynamicObject ); } else if (token == "buzzer:") { // bzyczek shp: - dsbBuzzer = - TSoundsManager::GetFromName(parser.getToken().c_str(), true); + dsbBuzzer.deserialize( parser, sound_type::single ); + dsbBuzzer.owner( DynamicObject ); + } + else if( token == "radiostop:" ) { + // radiostop + m_radiostop.deserialize( parser, sound_type::single ); + m_radiostop.owner( DynamicObject ); } else if (token == "slipalarm:") { // Bombardier 011010: alarm przy poslizgu: - dsbSlipAlarm = - TSoundsManager::GetFromName(parser.getToken().c_str(), true); + dsbSlipAlarm.deserialize( parser, sound_type::single ); + dsbSlipAlarm.owner( DynamicObject ); } else if (token == "tachoclock:") { // cykanie rejestratora: - dsbHasler = - TSoundsManager::GetFromName(parser.getToken().c_str(), true); + dsbHasler.deserialize( parser, sound_type::single ); + dsbHasler.owner( DynamicObject ); } else if (token == "switch:") { // przelaczniki: - dsbSwitch = - TSoundsManager::GetFromName(parser.getToken().c_str(), true); + dsbSwitch.deserialize( parser, sound_type::single ); + dsbSwitch.owner( DynamicObject ); } else if (token == "pneumaticswitch:") { // stycznik EP: - dsbPneumaticSwitch = - TSoundsManager::GetFromName(parser.getToken().c_str(), true); - } - else if (token == "wejscie_na_bezoporow:") - { - // hunter-111211: wydzielenie wejscia na bezoporowa i na drugi uklad do pliku - dsbWejscie_na_bezoporow = - TSoundsManager::GetFromName(parser.getToken().c_str(), true); - } - else if (token == "wejscie_na_drugi_uklad:") - { - - dsbWejscie_na_drugi_uklad = - TSoundsManager::GetFromName(parser.getToken().c_str(), true); - } - else if (token == "relay:") - { - // styczniki itp: - dsbRelay = - TSoundsManager::GetFromName(parser.getToken().c_str(), true); - if (!dsbWejscie_na_bezoporow) - { // hunter-111211: domyslne, gdy brak - dsbWejscie_na_bezoporow = - TSoundsManager::GetFromName("wejscie_na_bezoporow.wav", true); - } - if (!dsbWejscie_na_drugi_uklad) - { - dsbWejscie_na_drugi_uklad = - TSoundsManager::GetFromName("wescie_na_drugi_uklad.wav", true); - } - } - else if (token == "pneumaticrelay:") - { - // wylaczniki pneumatyczne: - dsbPneumaticRelay = - TSoundsManager::GetFromName(parser.getToken().c_str(), true); - } - else if (token == "couplerattach:") - { - // laczenie: - dsbCouplerAttach = - TSoundsManager::GetFromName(parser.getToken().c_str(), true); - } - else if (token == "couplerstretch:") - { - // laczenie: - dsbCouplerStretch = TSoundsManager::GetFromName( - parser.getToken().c_str(), - true); // McZapkie-090503: PROWIZORKA!!! "en57_couplerstretch.wav" - } - else if (token == "couplerdetach:") - { - // rozlaczanie: - dsbCouplerDetach = - TSoundsManager::GetFromName(parser.getToken().c_str(), true); - } - else if (token == "bufferclamp:") - { - // laczenie: - dsbBufferClamp = TSoundsManager::GetFromName( - parser.getToken().c_str(), - true); // McZapkie-090503: PROWIZORKA!!! "en57_bufferclamp.wav" - } - else if (token == "ignition:") - { - // odpalanie silnika - dsbDieselIgnition = - TSoundsManager::GetFromName(parser.getToken().c_str(), true); - } - else if (token == "brakesound:") - { - // hamowanie zwykle: - rsBrake.Init(parser.getToken(), -1, 0, 0, 0, true, true); - parser.getTokens(4, false); - parser >> rsBrake.AM >> rsBrake.AA >> rsBrake.FM >> rsBrake.FA; - rsBrake.AM /= (1 + mvOccupied->MaxBrakeForce * 1000); - rsBrake.FM /= (1 + mvOccupied->Vmax); - } - else if (token == "slipperysound:") - { - // sanie: - rsSlippery.Init(parser.getToken(), -1, 0, 0, 0, true); - parser.getTokens(2, false); - parser >> rsSlippery.AM >> rsSlippery.AA; - rsSlippery.FM = 0.0; - rsSlippery.FA = 1.0; - rsSlippery.AM /= (1 + mvOccupied->Vmax); + dsbPneumaticSwitch.deserialize( parser, sound_type::single ); + dsbPneumaticSwitch.owner( DynamicObject ); } else if (token == "airsound:") { // syk: - rsHiss.Init(parser.getToken(), -1, 0, 0, 0, true); - parser.getTokens(2, false); - parser >> rsHiss.AM >> rsHiss.AA; - rsHiss.FM = 0.0; - rsHiss.FA = 1.0; + rsHiss.deserialize( parser, sound_type::single, sound_parameters::amplitude ); + rsHiss.owner( DynamicObject ); + if( true == rsSBHiss.empty() ) { + // fallback for vehicles without defined local brake hiss sound + rsSBHiss = rsHiss; + } } else if (token == "airsound2:") { // syk: - rsHissU.Init(parser.getToken(), -1, 0, 0, 0, true); - parser.getTokens(2, false); - parser >> rsHissU.AM >> rsHissU.AA; - rsHissU.FM = 0.0; - rsHissU.FA = 1.0; + rsHissU.deserialize( parser, sound_type::single, sound_parameters::amplitude ); + rsHissU.owner( DynamicObject ); + if( true == rsSBHissU.empty() ) { + // fallback for vehicles without defined local brake hiss sound + rsSBHissU = rsHissU; + } } else if (token == "airsound3:") { // syk: - rsHissE.Init(parser.getToken(), -1, 0, 0, 0, true); - parser.getTokens(2, false); - parser >> rsHissE.AM >> rsHissE.AA; - rsHissE.FM = 0.0; - rsHissE.FA = 1.0; + rsHissE.deserialize( parser, sound_type::single, sound_parameters::amplitude ); + rsHissE.owner( DynamicObject ); } else if (token == "airsound4:") { // syk: - rsHissX.Init(parser.getToken(), -1, 0, 0, 0, true); - parser.getTokens(2, false); - parser >> rsHissX.AM >> rsHissX.AA; - rsHissX.FM = 0.0; - rsHissX.FA = 1.0; + rsHissX.deserialize( parser, sound_type::single, sound_parameters::amplitude ); + rsHissX.owner( DynamicObject ); } else if (token == "airsound5:") { // syk: - rsHissT.Init(parser.getToken(), -1, 0, 0, 0, true); - parser.getTokens(2, false); - parser >> rsHissT.AM >> rsHissT.AA; - rsHissT.FM = 0.0; - rsHissT.FA = 1.0; - } - else if (token == "fadesound:") - { - // syk: - rsFadeSound.Init(parser.getToken(), -1, 0, 0, 0, true); - rsFadeSound.AM = 1.0; - rsFadeSound.AA = 1.0; - rsFadeSound.FM = 1.0; - rsFadeSound.FA = 1.0; + rsHissT.deserialize( parser, sound_type::single, sound_parameters::amplitude ); + rsHissT.owner( DynamicObject ); } else if (token == "localbrakesound:") { // syk: - rsSBHiss.Init(parser.getToken(), -1, 0, 0, 0, true); - parser.getTokens(2, false); - parser >> rsSBHiss.AM >> rsSBHiss.AA; - rsSBHiss.FM = 0.0; - rsSBHiss.FA = 1.0; + rsSBHiss.deserialize( parser, sound_type::single, sound_parameters::amplitude ); + rsSBHiss.owner( DynamicObject ); } - else if (token == "runningnoise:") + else if( token == "localbrakesound2:" ) { + // syk: + rsSBHissU.deserialize( parser, sound_type::single, sound_parameters::amplitude ); + rsSBHissU.owner( DynamicObject ); + } + else if (token == "fadesound:") { + // ambient sound: + rsFadeSound.deserialize( parser, sound_type::single ); + rsFadeSound.owner( DynamicObject ); + } + else if( token == "runningnoise:" ) { // szum podczas jazdy: - rsRunningNoise.Init(parser.getToken(), -1, 0, 0, 0, true, true); - parser.getTokens(4, false); - parser >> rsRunningNoise.AM >> rsRunningNoise.AA >> rsRunningNoise.FM >> - rsRunningNoise.FA; - rsRunningNoise.AM /= (1 + mvOccupied->Vmax); - rsRunningNoise.FM /= (1 + mvOccupied->Vmax); + rsRunningNoise.deserialize( parser, sound_type::single, sound_parameters::amplitude | sound_parameters::frequency, mvOccupied->Vmax ); + rsRunningNoise.owner( DynamicObject ); + + rsRunningNoise.m_amplitudefactor /= ( 1 + mvOccupied->Vmax ); + rsRunningNoise.m_frequencyfactor /= ( 1 + mvOccupied->Vmax ); } - else if (token == "engageslippery:") - { - // tarcie tarcz sprzegla: - rsEngageSlippery.Init(parser.getToken(), -1, 0, 0, 0, true, true); - parser.getTokens(4, false); - parser >> rsEngageSlippery.AM >> rsEngageSlippery.AA >> rsEngageSlippery.FM >> - rsEngageSlippery.FA; - rsEngageSlippery.FM /= (1 + mvOccupied->nmax); + else if( token == "huntingnoise:" ) { + // hunting oscillation sound: + rsHuntingNoise.deserialize( parser, sound_type::single, sound_parameters::amplitude | sound_parameters::frequency, mvOccupied->Vmax ); + rsHuntingNoise.owner( DynamicObject ); + + rsHuntingNoise.m_amplitudefactor /= ( 1 + mvOccupied->Vmax ); + rsHuntingNoise.m_frequencyfactor /= ( 1 + mvOccupied->Vmax ); } else if (token == "mechspring:") { // parametry bujania kamery: double ks, kd; parser.getTokens(2, false); - parser >> ks >> kd; - MechSpring.Init(MechSpring.restLen, ks, kd); + parser + >> ks + >> kd; + MechSpring.Init(ks, kd); parser.getTokens(6, false); - parser >> fMechSpringX >> fMechSpringY >> fMechSpringZ >> fMechMaxSpring >> - fMechRoll >> fMechPitch; + parser + >> fMechSpringX + >> fMechSpringY + >> fMechSpringZ + >> fMechMaxSpring + >> fMechRoll + >> fMechPitch; } - else if (token == "pantographup:") - { - // podniesienie patyka: - dsbPantUp = - TSoundsManager::GetFromName(parser.getToken().c_str(), true); + else if( token == "enginespring:" ) { + parser.getTokens( 5, false ); + parser + >> EngineShake.scale + >> EngineShake.fadein_offset + >> EngineShake.fadein_factor + >> EngineShake.fadeout_offset + >> EngineShake.fadeout_factor; + // offsets values are provided as rpm for convenience + EngineShake.fadein_offset /= 60.f; + EngineShake.fadeout_offset /= 60.f; } - else if (token == "pantographdown:") - { - // podniesienie patyka: - dsbPantDown = - TSoundsManager::GetFromName(parser.getToken().c_str(), true); - } - else if (token == "doorclose:") - { - // zamkniecie drzwi: - dsbDoorClose = - TSoundsManager::GetFromName(parser.getToken().c_str(), true); - } - else if (token == "dooropen:") - { - // otwarcie drzwi: - dsbDoorOpen = - TSoundsManager::GetFromName(parser.getToken().c_str(), true); + else if( token == "huntingspring:" ) { + parser.getTokens( 4, false ); + parser + >> HuntingShake.scale + >> HuntingShake.frequency + >> HuntingShake.fadein_begin + >> HuntingShake.fadein_end; } } while (token != ""); @@ -5353,10 +6553,27 @@ bool TTrain::LoadMMediaFile(std::string const &asFileName) bool TTrain::InitializeCab(int NewCabNo, std::string const &asFileName) { - pyScreens.reset(this); - pyScreens.setLookupPath(DynamicObject->asBaseDir); + m_controlmapper.clear(); + // clear python screens + m_screens.clear(); + // reset sound positions and owner + auto const nullvector { glm::vec3() }; + std::vector sounds = { + &dsbReverserKey, &dsbNastawnikJazdy, &dsbNastawnikBocz, + &dsbSwitch, &dsbPneumaticSwitch, + &rsHiss, &rsHissU, &rsHissE, &rsHissX, &rsHissT, &rsSBHiss, &rsSBHissU, + &rsFadeSound, &rsRunningNoise, &rsHuntingNoise, + &dsbHasler, &dsbBuzzer, &dsbSlipAlarm, &m_radiosound, &m_radiostop + }; + for( auto sound : sounds ) { + sound->offset( nullvector ); + sound->owner( DynamicObject ); + } + // reset view angles + pMechViewAngle = { 0.0, 0.0 }; + Global.pCamera.Pitch = pMechViewAngle.x; + Global.pCamera.Yaw = pMechViewAngle.y; bool parse = false; - double dSDist; int cabindex = 0; DynamicObject->mdKabina = NULL; // likwidacja wskaźnika na dotychczasową kabinę switch (NewCabNo) @@ -5373,7 +6590,7 @@ bool TTrain::InitializeCab(int NewCabNo, std::string const &asFileName) } std::string cabstr("cab" + std::to_string(cabindex) + "definition:"); - std::shared_ptr parser = std::make_shared(asFileName, cParser::buffer_FILE); + cParser parser(asFileName, cParser::buffer_FILE); // NOTE: yaml-style comments are disabled until conflict in use of # is resolved // parser.addCommentStyle( "#", "\n" ); std::string token; @@ -5381,11 +6598,45 @@ bool TTrain::InitializeCab(int NewCabNo, std::string const &asFileName) { // szukanie kabiny token = ""; - parser->getTokens(); - *parser >> token; + parser.getTokens(); + parser >> token; +/* + if( token == "locations:" ) { + do { + token = ""; + parser.getTokens(); parser >> token; + if( token == "radio:" ) { + // point in 3d space, in format [ x, y, z ] + glm::vec3 radiolocation; + parser.getTokens( 3, false, "\n\r\t ,;[]" ); + parser + >> radiolocation.x + >> radiolocation.y + >> radiolocation.z; + radiolocation *= glm::vec3( NewCabNo, 1, NewCabNo ); + m_radiosound.offset( radiolocation ); + } + + else if( token == "alerter:" ) { + // point in 3d space, in format [ x, y, z ] + glm::vec3 alerterlocation; + parser.getTokens( 3, false, "\n\r\t ,;[]" ); + parser + >> alerterlocation.x + >> alerterlocation.y + >> alerterlocation.z; + alerterlocation *= glm::vec3( NewCabNo, 1, NewCabNo ); + dsbBuzzer.offset( alerterlocation ); + } + + } while( ( token != "" ) + && ( token != "endlocations" ) ); + + } // locations: +*/ } while ((token != "") && (token != cabstr)); - +/* if ((cabindex != 1) && (token != cabstr)) { // jeśli nie znaleziony wpis kabiny, próba szukania kabiny 1 @@ -5397,50 +6648,68 @@ bool TTrain::InitializeCab(int NewCabNo, std::string const &asFileName) do { token = ""; - parser->getTokens(); - *parser >> token; + parser.getTokens(); + parser >> token; } while ((token != "") && (token != cabstr)); } +*/ if (token == cabstr) { // jeśli znaleziony wpis kabiny - Cabine[cabindex].Load(*parser); - // NOTE: the next part is likely to break if sitpos doesn't follow pos - parser->getTokens(); - *parser >> token; + Cabine[cabindex].Load(parser); + // NOTE: the position and angle definitions depend on strict entry order + // TODO: refactor into more flexible arrangement + parser.getTokens(); + parser >> token; + if( token == std::string( "driver" + std::to_string( cabindex ) + "angle:" ) ) { + // camera view angle + parser.getTokens( 2, false ); + // angle is specified in degrees but internally stored in radians + glm::vec2 viewangle; + parser + >> viewangle.y // yaw first, then pitch + >> viewangle.x; + pMechViewAngle = glm::radians( viewangle ); + Global.pCamera.Pitch = pMechViewAngle.x; + Global.pCamera.Yaw = pMechViewAngle.y; + + parser.getTokens(); + parser >> token; + } if (token == std::string("driver" + std::to_string(cabindex) + "pos:")) { // pozycja poczatkowa maszynisty - parser->getTokens(3, false); - *parser >> pMechOffset.x >> pMechOffset.y >> pMechOffset.z; - pMechSittingPosition.x = pMechOffset.x; - pMechSittingPosition.y = pMechOffset.y; - pMechSittingPosition.z = pMechOffset.z; + parser.getTokens(3, false); + parser + >> pMechOffset.x + >> pMechOffset.y + >> pMechOffset.z; + pMechSittingPosition = pMechOffset; + + parser.getTokens(); + parser >> token; } // ABu: pozycja siedzaca mechanika - parser->getTokens(); - *parser >> token; if (token == std::string("driver" + std::to_string(cabindex) + "sitpos:")) { // ABu 180404 pozycja siedzaca maszynisty - parser->getTokens(3, false); - *parser >> pMechSittingPosition.x >> pMechSittingPosition.y >> pMechSittingPosition.z; - parse = true; + parser.getTokens(3, false); + parser + >> pMechSittingPosition.x + >> pMechSittingPosition.y + >> pMechSittingPosition.z; + + parser.getTokens(); + parser >> token; } // else parse=false; - do - { - // ABu: wstawione warunki, wczesniej tylko to: - // str=Parser->GetNextSymbol().LowerCase(); - if (parse == true) - { - + do { + if( parse == true ) { token = ""; - parser->getTokens(); - *parser >> token; + parser.getTokens(); + parser >> token; } - else - { + else { parse = true; } // inicjacja kabiny @@ -5451,18 +6720,21 @@ bool TTrain::InitializeCab(int NewCabNo, std::string const &asFileName) if (token == std::string("cab" + std::to_string(cabindex) + "model:")) { // model kabiny - parser->getTokens(); - *parser >> token; + parser.getTokens(); + parser >> token; if (token != "none") { - - Global::asCurrentTexturePath = - DynamicObject->asBaseDir; // bieżąca sciezka do tekstur to dynamic/... - TModel3d *kabina = - TModelsManager::GetModel(DynamicObject->asBaseDir + token, - true); // szukaj kabinę jako oddzielny model - Global::asCurrentTexturePath = - szTexturePath; // z powrotem defaultowa sciezka do tekstur + // bieżąca sciezka do tekstur to dynamic/... + Global.asCurrentTexturePath = DynamicObject->asBaseDir; + // szukaj kabinę jako oddzielny model + // name can contain leading slash, erase it to avoid creation of double slashes when the name is combined with current directory + replace_slashes( token ); + if( token[ 0 ] == '/' ) { + token.erase( 0, 1 ); + } + TModel3d *kabina = TModelsManager::GetModel(DynamicObject->asBaseDir + token, true); + // z powrotem defaultowa sciezka do tekstur + Global.asCurrentTexturePath = szTexturePath; // if (DynamicObject->mdKabina!=k) if (kabina != nullptr) { @@ -5473,14 +6745,11 @@ bool TTrain::InitializeCab(int NewCabNo, std::string const &asFileName) // else // break; //wyjście z pętli, bo model zostaje bez zmian } - else if (cabindex == 1) - { + else if (cabindex == 1) { // model tylko, gdy nie ma kabiny 1 - DynamicObject->mdKabina = - DynamicObject - ->mdModel; // McZapkie-170103: szukaj elementy kabiny w glownym modelu + // McZapkie-170103: szukaj elementy kabiny w glownym modelu + DynamicObject->mdKabina = DynamicObject->mdModel; } - ActiveUniversal4 = false; clear_cab_controls(); } if (nullptr == DynamicObject->mdKabina) @@ -5488,20 +6757,42 @@ bool TTrain::InitializeCab(int NewCabNo, std::string const &asFileName) // don't bother with other parts until the cab is initialised continue; } - else if (true == initialize_gauge(*parser, token, cabindex)) + else if (true == initialize_gauge(parser, token, cabindex)) { // matched the token, grab the next one continue; } - else if (true == initialize_button(*parser, token, cabindex)) + else if (true == initialize_button(parser, token, cabindex)) { // matched the token, grab the next one continue; } + // TODO: add "pydestination:" else if (token == "pyscreen:") { - pyScreens.init(*parser, DynamicObject->mdKabina, DynamicObject->GetName(), - NewCabNo); + std::string submodelname, renderername; + parser.getTokens( 2 ); + parser + >> submodelname + >> renderername; + + auto const *submodel { DynamicObject->mdKabina->GetFromName( submodelname ) }; + if( submodel == nullptr ) { + WriteLog( "Python Screen: submodel " + submodelname + " not found - Ignoring screen" ); + continue; + } + auto const material { submodel->GetMaterial() }; + if( material <= 0 ) { + // sub model nie posiada tekstury lub tekstura wymienna - nie obslugiwana + WriteLog( "Python Screen: invalid texture id " + std::to_string( material ) + " - Ignoring screen" ); + continue; + } + // record renderer and material binding for future update requests + m_screens.emplace_back( + ( substr_path(renderername).empty() ? // supply vehicle folder as path if none is provided + DynamicObject->asBaseDir + renderername : + renderername ), + material ); } // btLampkaUnknown.Init("unknown",mdKabina,false); } while (token != ""); @@ -5510,36 +6801,86 @@ bool TTrain::InitializeCab(int NewCabNo, std::string const &asFileName) { return false; } - pyScreens.start(); if (DynamicObject->mdKabina) { - DynamicObject->mdKabina->Init(); // obrócenie modelu oraz optymalizacja, - // również zapisanie binarnego + // configure placement of sound emitters which aren't bound with any device model, and weren't placed manually + // try first to bind sounds to location of possible devices + if( dsbReverserKey.offset() == nullvector ) { + dsbReverserKey.offset( ggDirKey.model_offset() ); + } + if( dsbNastawnikJazdy.offset() == nullvector ) { + dsbNastawnikJazdy.offset( ggMainCtrl.model_offset() ); + } + if( dsbNastawnikBocz.offset() == nullvector ) { + dsbNastawnikBocz.offset( ggScndCtrl.model_offset() ); + } + if( dsbBuzzer.offset() == nullvector ) { + dsbBuzzer.offset( btLampkaCzuwaka.model_offset() ); + } + // radio has two potential items which can provide the position + if( m_radiosound.offset() == nullvector ) { + m_radiosound.offset( btLampkaRadio.model_offset() ); + } + if( m_radiosound.offset() == nullvector ) { + m_radiosound.offset( ggRadioButton.model_offset() ); + } + if( m_radiostop.offset() == nullvector ) { + m_radiostop.offset( m_radiosound.offset() ); + } + auto const localbrakeoffset { ggLocalBrake.model_offset() }; + std::vector localbrakesounds = { + &rsSBHiss, &rsSBHissU + }; + for( auto sound : localbrakesounds ) { + if( sound->offset() == nullvector ) { + sound->offset( localbrakeoffset ); + } + } + // NOTE: if the local brake model can't be located the emitter will also be assigned location of main brake + auto const brakeoffset { ggBrakeCtrl.model_offset() }; + std::vector brakesounds = { + &rsHiss, &rsHissU, &rsHissE, &rsHissX, &rsHissT, &rsSBHiss, &rsSBHissU, + }; + for( auto sound : brakesounds ) { + if( sound->offset() == nullvector ) { + sound->offset( brakeoffset ); + } + } + // for whatever is left fallback on generic location, centre of the cab + auto const caboffset { glm::dvec3 { ( Cabine[ cabindex ].CabPos1 + Cabine[ cabindex ].CabPos2 ) * 0.5 } + glm::dvec3 { 0, 1, 0 } }; + for( auto sound : sounds ) { + if( sound->offset() == nullvector ) { + sound->offset( caboffset ); + } + } + + DynamicObject->mdKabina->Init(); // obrócenie modelu oraz optymalizacja, również zapisanie binarnego + set_cab_controls(); + return true; } return (token == "none"); } void TTrain::MechStop() -{ // likwidacja ruchu kamery w kabinie (po powrocie - // przez [F4]) - pMechPosition = vector3(0, 0, 0); - pMechShake = vector3(0, 0, 0); - vMechMovement = vector3(0, 0, 0); - vMechVelocity = vector3(0, 0, 0); // tu zostawały jakieś ułamki, powodujące uciekanie kamery +{ // likwidacja ruchu kamery w kabinie (po powrocie przez [F4]) + pMechPosition = Math3D::vector3(0, 0, 0); + pMechShake = Math3D::vector3(0, 0, 0); + vMechMovement = Math3D::vector3(0, 0, 0); + vMechVelocity = Math3D::vector3(0, 0, 0); // tu zostawały jakieś ułamki, powodujące uciekanie kamery }; -vector3 TTrain::MirrorPosition(bool lewe) +Math3D::vector3 TTrain::MirrorPosition(bool lewe) { // zwraca współrzędne widoku kamery z lusterka switch (iCabn) { case 1: // przednia (1) return DynamicObject->mMatrix * - vector3(lewe ? Cabine[iCabn].CabPos2.x : Cabine[iCabn].CabPos1.x, + Math3D::vector3(lewe ? Cabine[iCabn].CabPos2.x : Cabine[iCabn].CabPos1.x, 1.5 + Cabine[iCabn].CabPos1.y, Cabine[iCabn].CabPos2.z); case 2: // tylna (-1) return DynamicObject->mMatrix * - vector3(lewe ? Cabine[iCabn].CabPos1.x : Cabine[iCabn].CabPos2.x, + Math3D::vector3(lewe ? Cabine[iCabn].CabPos1.x : Cabine[iCabn].CabPos2.x, 1.5 + Cabine[iCabn].CabPos1.y, Cabine[iCabn].CabPos1.z); } return DynamicObject->GetPosition(); // współrzędne środka pojazdu @@ -5606,66 +6947,32 @@ void TTrain::DynamicSet(TDynamicObject *d) } }; -void TTrain::Silence() -{ // wyciszenie dźwięków przy wychodzeniu - if (dsbNastawnikJazdy) - dsbNastawnikJazdy->Stop(); - if (dsbNastawnikBocz) - dsbNastawnikBocz->Stop(); - if (dsbRelay) - dsbRelay->Stop(); - if (dsbPneumaticRelay) - dsbPneumaticRelay->Stop(); - if (dsbSwitch) - dsbSwitch->Stop(); - if (dsbPneumaticSwitch) - dsbPneumaticSwitch->Stop(); - if (dsbReverserKey) - dsbReverserKey->Stop(); - if (dsbCouplerAttach) - dsbCouplerAttach->Stop(); - if (dsbCouplerDetach) - dsbCouplerDetach->Stop(); - if (dsbDieselIgnition) - dsbDieselIgnition->Stop(); - if (dsbDoorClose) - dsbDoorClose->Stop(); - if (dsbDoorOpen) - dsbDoorOpen->Stop(); - if (dsbPantUp) - dsbPantUp->Stop(); - if (dsbPantDown) - dsbPantDown->Stop(); - if (dsbWejscie_na_bezoporow) - dsbWejscie_na_bezoporow->Stop(); - if (dsbWejscie_na_drugi_uklad) - dsbWejscie_na_drugi_uklad->Stop(); - rsBrake.Stop(); - rsSlippery.Stop(); - rsHiss.Stop(); - rsHissU.Stop(); - rsHissE.Stop(); - rsHissX.Stop(); - rsHissT.Stop(); - rsSBHiss.Stop(); - rsRunningNoise.Stop(); - rsEngageSlippery.Stop(); - rsFadeSound.Stop(); - if (dsbHasler) - dsbHasler->Stop(); // wyłączenie dźwięków opuszczanej kabiny - if (dsbBuzzer) - dsbBuzzer->Stop(); - if (dsbSlipAlarm) - dsbSlipAlarm->Stop(); // dźwięk alarmu przy poślizgu - // sConverter.Stop(); - // sSmallCompressor->Stop(); - if (dsbCouplerStretch) - dsbCouplerStretch->Stop(); - if (dsbEN57_CouplerStretch) - dsbEN57_CouplerStretch->Stop(); - if (dsbBufferClamp) - dsbBufferClamp->Stop(); -}; +void +TTrain::radio_message( sound_source *Message, int const Channel ) { + + auto const soundrange { Message->range() }; + if( ( soundrange > 0 ) + && ( glm::length2( Message->location() - glm::dvec3 { DynamicObject->GetPosition() } ) > ( soundrange * soundrange ) ) ) { + // skip message playback if the receiver is outside of the emitter's range + return; + } + // NOTE: we initiate playback of all sounds in range, in case the user switches on the radio or tunes to the right channel mid-play + m_radiomessages.emplace_back( + Channel, + std::make_shared( m_radiosound ) ); + // assign sound to the template and play it + auto &message = *( m_radiomessages.back().second.get() ); + auto const radioenabled { ( true == mvOccupied->Radio ) && ( mvControlled->Battery || mvControlled->ConverterFlag ) }; + auto const volume { + ( true == radioenabled ) + && ( Channel == iRadioChannel ) ? + 1.0 : + 0.0 }; + message + .copy_sounds( *Message ) + .gain( volume ) + .play(); +} void TTrain::SetLights() { @@ -5701,7 +7008,27 @@ void TTrain::SetLights() // clears state of all cabin controls void TTrain::clear_cab_controls() { + // indicators exposed to custom control devices + btLampkaSHP.Clear(0); + btLampkaCzuwaka.Clear(1); + btLampkaOpory.Clear(2); + btLampkaWylSzybki.Clear(3); + btLampkaNadmSil.Clear(4); + btLampkaStyczn.Clear(5); + btLampkaPoslizg.Clear(6); + btLampkaNadmPrzetw.Clear(((mvControlled->TrainType & dt_EZT) != 0) ? -1 : 7); // EN57 nie ma tej lampki + btLampkaPrzetwOff.Clear(((mvControlled->TrainType & dt_EZT) != 0) ? 7 : -1 ); // za to ma tę + btLampkaNadmSpr.Clear(8); + btLampkaNadmWent.Clear(9); + btLampkaWysRozr.Clear(((mvControlled->TrainType & dt_ET22) != 0) ? -1 : 10); // ET22 nie ma tej lampki + btLampkaOgrzewanieSkladu.Clear(11); + btHaslerBrakes.Clear(12); // ciśnienie w cylindrach do odbijania na haslerze + btHaslerCurrent.Clear(13); // prąd na silnikach do odbijania na haslerze + // Numer 14 jest używany dla buczka SHP w update_sounds() + // Jeśli ustawiamy nową wartość dla PoKeys wolna jest 15 + // other cab controls + // TODO: arrange in more readable manner, and eventually refactor ggMainCtrl.Clear(); ggMainCtrlAct.Clear(); ggScndCtrl.Clear(); @@ -5709,9 +7036,11 @@ void TTrain::clear_cab_controls() ggBrakeCtrl.Clear(); ggLocalBrake.Clear(); ggManualBrake.Clear(); + ggAlarmChain.Clear(); ggBrakeProfileCtrl.Clear(); ggBrakeProfileG.Clear(); ggBrakeProfileR.Clear(); + ggBrakeOperationModeCtrl.Clear(); ggMaxCurrentCtrl.Clear(); ggMainOffButton.Clear(); ggMainOnButton.Clear(); @@ -5720,75 +7049,106 @@ void TTrain::clear_cab_controls() ggSandButton.Clear(); ggAntiSlipButton.Clear(); ggHornButton.Clear(); + ggHornLowButton.Clear(); + ggHornHighButton.Clear(); + ggWhistleButton.Clear(); ggNextCurrentButton.Clear(); - ggUniversal1Button.Clear(); - ggUniversal2Button.Clear(); - ggUniversal3Button.Clear(); + for( auto &universal : ggUniversals ) { + universal.Clear(); + } + ggInstrumentLightButton.Clear(); + ggDashboardLightButton.Clear(); + ggTimetableLightButton.Clear(); // hunter-091012 ggCabLightButton.Clear(); ggCabLightDimButton.Clear(); + ggBatteryButton.Clear(); //------- - ggUniversal4Button.Clear(); ggFuseButton.Clear(); ggConverterFuseButton.Clear(); ggStLinOffButton.Clear(); + ggRadioButton.Clear(); + ggRadioChannelSelector.Clear(); + ggRadioChannelPrevious.Clear(); + ggRadioChannelNext.Clear(); + ggRadioStop.Clear(); + ggRadioTest.Clear(); ggDoorLeftButton.Clear(); ggDoorRightButton.Clear(); + ggDoorLeftOnButton.Clear(); + ggDoorRightOnButton.Clear(); + ggDoorLeftOffButton.Clear(); + ggDoorRightOffButton.Clear(); + ggDoorAllOffButton.Clear(); + ggTrainHeatingButton.Clear(); + ggSignallingButton.Clear(); + ggDoorSignallingButton.Clear(); ggDepartureSignalButton.Clear(); ggCompressorButton.Clear(); + ggCompressorLocalButton.Clear(); ggConverterButton.Clear(); + ggConverterOffButton.Clear(); + ggConverterLocalButton.Clear(); + ggMainButton.Clear(); ggPantFrontButton.Clear(); ggPantRearButton.Clear(); + ggPantSelectedButton.Clear(); ggPantFrontButtonOff.Clear(); + ggPantRearButtonOff.Clear(); + ggPantSelectedDownButton.Clear(); ggPantAllDownButton.Clear(); + ggPantCompressorButton.Clear(); + ggPantCompressorValve.Clear(); ggZbS.Clear(); ggI1B.Clear(); ggI2B.Clear(); ggI3B.Clear(); ggItotalB.Clear(); + ggOilPressB.Clear(); + ggWater1TempB.Clear(); ggClockSInd.Clear(); ggClockMInd.Clear(); ggClockHInd.Clear(); ggEngineVoltage.Clear(); ggLVoltage.Clear(); - // ggLVoltage.Output(0); //Ra: sterowanie miernikiem: niskie napięcie - // ggEnrot1m.Clear(); - // ggEnrot2m.Clear(); - // ggEnrot3m.Clear(); - // ggEngageRatio.Clear(); ggMainGearStatus.Clear(); ggIgnitionKey.Clear(); - // Jeśli ustawiamy nową wartość dla PoKeys wolna jest 15 - // Numer 14 jest używany dla buczka SHP w innym miejscu - btLampkaPoslizg.Clear(6); - btLampkaStyczn.Clear(5); - btLampkaNadmPrzetw.Clear((mvControlled->TrainType & (dt_EZT)) ? -1 : - 7); // EN57 nie ma tej lampki - btLampkaPrzetw.Clear((mvControlled->TrainType & (dt_EZT)) ? 7 : -1); // za to ma tę + + ggWaterPumpBreakerButton.Clear(); + ggWaterPumpButton.Clear(); + ggWaterHeaterBreakerButton.Clear(); + ggWaterHeaterButton.Clear(); + ggWaterCircuitsLinkButton.Clear(); + ggFuelPumpButton.Clear(); + ggOilPumpButton.Clear(); + ggMotorBlowersFrontButton.Clear(); + ggMotorBlowersRearButton.Clear(); + ggMotorBlowersAllOffButton.Clear(); + + btLampkaPrzetw.Clear(); + btLampkaPrzetwB.Clear(); + btLampkaPrzetwBOff.Clear(); btLampkaPrzekRozn.Clear(); btLampkaPrzekRoznPom.Clear(); - btLampkaNadmSil.Clear(4); btLampkaUkrotnienie.Clear(); btLampkaHamPosp.Clear(); - btLampkaWylSzybki.Clear(3); - btLampkaNadmWent.Clear(9); - btLampkaNadmSpr.Clear(8); - btLampkaOpory.Clear(2); - btLampkaWysRozr.Clear((mvControlled->TrainType & (dt_ET22)) ? -1 : - 10); // ET22 nie ma tej lampki + btLampkaWylSzybkiOff.Clear(); + btLampkaWylSzybkiB.Clear(); + btLampkaWylSzybkiBOff.Clear(); btLampkaBezoporowa.Clear(); btLampkaBezoporowaB.Clear(); btLampkaMaxSila.Clear(); btLampkaPrzekrMaxSila.Clear(); btLampkaRadio.Clear(); + btLampkaRadioStop.Clear(); btLampkaHamulecReczny.Clear(); btLampkaBlokadaDrzwi.Clear(); - btLampkaUniversal3.Clear(); + btLampkaDoorLockOff.Clear(); + btInstrumentLight.Clear(); + btDashboardLight.Clear(); + btTimetableLight.Clear(); btLampkaWentZaluzje.Clear(); - btLampkaOgrzewanieSkladu.Clear(11); - btLampkaSHP.Clear(0); - btLampkaCzuwaka.Clear(1); btLampkaDoorLeft.Clear(); btLampkaDoorRight.Clear(); btLampkaDepartureSignal.Clear(); @@ -5800,22 +7160,46 @@ void TTrain::clear_cab_controls() btLampkaBocznik4.Clear(); btLampkaRadiotelefon.Clear(); btLampkaHamienie.Clear(); + btLampkaBrakingOff.Clear(); + btLampkaED.Clear(); + btLampkaBrakeProfileG.Clear(); + btLampkaBrakeProfileP.Clear(); + btLampkaBrakeProfileR.Clear(); btLampkaSprezarka.Clear(); btLampkaSprezarkaB.Clear(); + btLampkaSprezarkaOff.Clear(); + btLampkaSprezarkaBOff.Clear(); + btLampkaFuelPumpOff.Clear(); btLampkaNapNastHam.Clear(); - btLampkaJazda.Clear(); + btLampkaOporyB.Clear(); btLampkaStycznB.Clear(); btLampkaHamowanie1zes.Clear(); btLampkaHamowanie2zes.Clear(); btLampkaNadmPrzetwB.Clear(); - btLampkaPrzetwB.Clear(); - btLampkaWylSzybkiB.Clear(); + btLampkaHVoltageB.Clear(); btLampkaForward.Clear(); btLampkaBackward.Clear(); + // light indicators + btLampkaUpperLight.Clear(); + btLampkaLeftLight.Clear(); + btLampkaRightLight.Clear(); + btLampkaLeftEndLight.Clear(); + btLampkaRightEndLight.Clear(); + btLampkaRearUpperLight.Clear(); + btLampkaRearLeftLight.Clear(); + btLampkaRearRightLight.Clear(); + btLampkaRearLeftEndLight.Clear(); + btLampkaRearRightEndLight.Clear(); btCabLight.Clear(); // hunter-171012 + // others + btLampkaMalfunction.Clear(); + btLampkaMalfunctionB.Clear(); + btLampkaMotorBlowers.Clear(); + ggLeftLightButton.Clear(); ggRightLightButton.Clear(); ggUpperLightButton.Clear(); + ggDimHeadlightsButton.Clear(); ggLeftEndLightButton.Clear(); ggRightEndLightButton.Clear(); ggLightsButton.Clear(); @@ -5825,234 +7209,408 @@ void TTrain::clear_cab_controls() ggRearUpperLightButton.Clear(); ggRearLeftEndLightButton.Clear(); ggRearRightEndLightButton.Clear(); - btHaslerBrakes.Clear(12); // ciśnienie w cylindrach do odbijania na haslerze - btHaslerCurrent.Clear(13); // prąd na silnikach do odbijania na haslerze } -// initializes a button matching provided label. returns: true if the label was found, false -// otherwise -// NOTE: this is temporary work-around for compiler else-if limit +// NOTE: we can get rid of this function once we have per-cab persistent state +void TTrain::set_cab_controls() { + // switches + // battery + if( true == mvOccupied->Battery ) { + ggBatteryButton.PutValue( 1.0 ); + } + // motor connectors + ggStLinOffButton.PutValue( + ( mvControlled->StLinSwitchOff ? + 1.0 : + 0.0 ) ); + // radio + if( true == mvOccupied->Radio ) { + ggRadioButton.PutValue( 1.0 ); + } + ggRadioChannelSelector.PutValue( iRadioChannel - 1 ); + // pantographs + if( mvOccupied->PantSwitchType != "impulse" ) { + if( ggPantFrontButton.SubModel ) { + ggPantFrontButton.PutValue( + ( mvControlled->PantFrontUp ? + 1.0 : + 0.0 ) ); + } + if( ggPantFrontButtonOff.SubModel ) { + ggPantFrontButtonOff.PutValue( + ( mvControlled->PantFrontUp ? + 0.0 : + 1.0 ) ); + } + // NOTE: currently we animate the selectable pantograph control for both pantographs + // TODO: implement actual selection control, and refactor handling this control setup in a separate method + if( ggPantSelectedButton.SubModel ) { + ggPantSelectedButton.PutValue( + ( mvControlled->PantFrontUp ? + 1.0 : + 0.0 ) ); + } + if( ggPantSelectedDownButton.SubModel ) { + ggPantSelectedDownButton.PutValue( + ( mvControlled->PantFrontUp ? + 0.0 : + 1.0 ) ); + } + } + if( mvOccupied->PantSwitchType != "impulse" ) { + if( ggPantRearButton.SubModel ) { + ggPantRearButton.PutValue( + ( mvControlled->PantRearUp ? + 1.0 : + 0.0 ) ); + } + if( ggPantRearButtonOff.SubModel ) { + ggPantRearButtonOff.PutValue( + ( mvControlled->PantRearUp ? + 0.0 : + 1.0 ) ); + } + // NOTE: currently we animate the selectable pantograph control for both pantographs + // TODO: implement actual selection control, and refactor handling this control setup in a separate method + if( ggPantSelectedButton.SubModel ) { + ggPantSelectedButton.PutValue( + ( mvControlled->PantRearUp ? + 1.0 : + 0.0 ) ); + } + if( ggPantSelectedDownButton.SubModel ) { + ggPantSelectedDownButton.PutValue( + ( mvControlled->PantRearUp ? + 0.0 : + 1.0 ) ); + } + } + // auxiliary compressor + ggPantCompressorValve.PutValue( + mvControlled->bPantKurek3 ? + 0.0 : // default setting is pantographs connected with primary tank + 1.0 ); + ggPantCompressorButton.PutValue( + mvControlled->PantCompFlag ? + 1.0 : + 0.0 ); + // converter + if( mvOccupied->ConvSwitchType != "impulse" ) { + ggConverterButton.PutValue( + mvControlled->ConverterAllow ? + 1.0 : + 0.0 ); + } + ggConverterLocalButton.PutValue( + mvControlled->ConverterAllowLocal ? + 1.0 : + 0.0 ); + // compressor + ggCompressorButton.PutValue( + mvControlled->CompressorAllow ? + 1.0 : + 0.0 ); + ggCompressorLocalButton.PutValue( + mvControlled->CompressorAllowLocal ? + 1.0 : + 0.0 ); + // motor overload relay threshold / shunt mode + ggMaxCurrentCtrl.PutValue( + ( true == mvControlled->ShuntModeAllow ? + ( true == mvControlled->ShuntMode ? + 1.0 : + 0.0 ) : + ( mvControlled->Imax == mvControlled->ImaxHi ? + 1.0 : + 0.0 ) ) ); + // lights + ggLightsButton.PutValue( mvOccupied->LightsPos - 1 ); + + int const vehicleside = + ( mvOccupied->ActiveCab == 1 ? + side::front : + side::rear ); + + if( ( DynamicObject->iLights[ vehicleside ] & light::headlight_left ) != 0 ) { + ggLeftLightButton.PutValue( 1.0 ); + } + if( ( DynamicObject->iLights[ vehicleside ] & light::headlight_right ) != 0 ) { + ggRightLightButton.PutValue( 1.0 ); + } + if( ( DynamicObject->iLights[ vehicleside ] & light::headlight_upper ) != 0 ) { + ggUpperLightButton.PutValue( 1.0 ); + } + if( ( DynamicObject->iLights[ vehicleside ] & light::redmarker_left ) != 0 ) { + if( ggLeftEndLightButton.SubModel != nullptr ) { + ggLeftEndLightButton.PutValue( 1.0 ); + } + else { + ggLeftLightButton.PutValue( -1.0 ); + } + } + if( ( DynamicObject->iLights[ vehicleside ] & light::redmarker_right ) != 0 ) { + if( ggRightEndLightButton.SubModel != nullptr ) { + ggRightEndLightButton.PutValue( 1.0 ); + } + else { + ggRightLightButton.PutValue( -1.0 ); + } + } + if( true == DynamicObject->DimHeadlights ) { + ggDimHeadlightsButton.PutValue( 1.0 ); + } + // cab lights + if( true == bCabLight ) { + ggCabLightButton.PutValue( 1.0 ); + } + if( true == bCabLightDim ) { + ggCabLightDimButton.PutValue( 1.0 ); + } + + ggInstrumentLightButton.PutValue( ( + InstrumentLightActive ? + 1.0 : + 0.0 ) ); + ggDashboardLightButton.PutValue( ( + DashboardLightActive ? + 1.0 : + 0.0 ) ); + ggTimetableLightButton.PutValue( ( + TimetableLightActive ? + 1.0 : + 0.0 ) ); + // doors + // NOTE: we're relying on the cab models to have switches reversed for the rear cab(?) + ggDoorLeftButton.PutValue( mvOccupied->DoorLeftOpened ? 1.0 : 0.0 ); + ggDoorRightButton.PutValue( mvOccupied->DoorRightOpened ? 1.0 : 0.0 ); + // door lock + ggDoorSignallingButton.PutValue( + mvOccupied->DoorLockEnabled ? + 1.0 : + 0.0 ); + // heating + if( true == mvControlled->Heating ) { + ggTrainHeatingButton.PutValue( 1.0 ); + } + // brake acting time + if( ggBrakeProfileCtrl.SubModel != nullptr ) { + ggBrakeProfileCtrl.PutValue( + ( ( mvOccupied->BrakeDelayFlag & bdelay_R ) != 0 ? + 2.0 : + mvOccupied->BrakeDelayFlag - 1 ) ); + } + if( ggBrakeProfileG.SubModel != nullptr ) { + ggBrakeProfileG.PutValue( + mvOccupied->BrakeDelayFlag == bdelay_G ? + 1.0 : + 0.0 ); + } + if( ggBrakeProfileR.SubModel != nullptr ) { + ggBrakeProfileR.PutValue( + ( mvOccupied->BrakeDelayFlag & bdelay_R ) != 0 ? + 1.0 : + 0.0 ); + } + if (ggBrakeOperationModeCtrl.SubModel != nullptr) { + ggBrakeOperationModeCtrl.PutValue( + (mvOccupied->BrakeOpModeFlag > 0 ? + log2(mvOccupied->BrakeOpModeFlag) : + 0)); + } + // alarm chain + ggAlarmChain.PutValue( + mvControlled->AlarmChainFlag ? + 1.0 : + 0.0 ); + // brake signalling + ggSignallingButton.PutValue( + mvControlled->Signalling ? + 1.0 : + 0.0 ); + // multiple-unit current indicator source + ggNextCurrentButton.PutValue( + ShowNextCurrent ? + 1.0 : + 0.0 ); + // water pump + ggWaterPumpBreakerButton.PutValue( + mvControlled->WaterPump.breaker ? + 1.0 : + 0.0 ); + if( ggWaterPumpButton.type() != TGaugeType::push ) { + ggWaterPumpButton.PutValue( + mvControlled->WaterPump.is_enabled ? + 1.0 : + 0.0 ); + } + // water heater + ggWaterHeaterBreakerButton.PutValue( + mvControlled->WaterHeater.breaker ? + 1.0 : + 0.0 ); + ggWaterHeaterButton.PutValue( + mvControlled->WaterHeater.is_enabled ? + 1.0 : + 0.0 ); + ggWaterCircuitsLinkButton.PutValue( + mvControlled->WaterCircuitsLink ? + 1.0 : + 0.0 ); + // fuel pump + if( ggFuelPumpButton.type() != TGaugeType::push ) { + ggFuelPumpButton.PutValue( + mvControlled->FuelPump.is_enabled ? + 1.0 : + 0.0 ); + } + // oil pump + if( ggOilPumpButton.type() != TGaugeType::push ) { + ggOilPumpButton.PutValue( + mvControlled->OilPump.is_enabled ? + 1.0 : + 0.0 ); + } + // traction motor fans + if( ggMotorBlowersFrontButton.type() != TGaugeType::push ) { + ggMotorBlowersFrontButton.PutValue( + mvControlled->MotorBlowers[side::front].is_enabled ? + 1.0 : + 0.0 ); + } + if( ggMotorBlowersRearButton.type() != TGaugeType::push ) { + ggMotorBlowersRearButton.PutValue( + mvControlled->MotorBlowers[side::rear].is_enabled ? + 1.0 : + 0.0 ); + } + if( ggMotorBlowersAllOffButton.type() != TGaugeType::push ) { + ggMotorBlowersAllOffButton.PutValue( + ( mvControlled->MotorBlowers[side::front].is_disabled + || mvControlled->MotorBlowers[ side::front ].is_disabled ) ? + 1.0 : + 0.0 ); + } + + // we reset all indicators, as they're set during the update pass + // TODO: when cleaning up break setting indicator state into a separate function, so we can reuse it +} + +// initializes a button matching provided label. returns: true if the label was found, false otherwise // TODO: refactor the cabin controls into some sensible structure -bool TTrain::initialize_button(cParser &Parser, std::string const &Label, int const Cabindex) -{ +bool TTrain::initialize_button(cParser &Parser, std::string const &Label, int const Cabindex) { - TButton *bt; // roboczy wskaźnik na obiekt animujący lampkę + std::unordered_map const lights = { + { "i-maxft:", btLampkaMaxSila }, + { "i-maxftt:", btLampkaPrzekrMaxSila }, + { "i-radio:", btLampkaRadio }, + { "i-radiostop:", btLampkaRadioStop }, + { "i-manual_brake:", btLampkaHamulecReczny }, + { "i-door_blocked:", btLampkaBlokadaDrzwi }, + { "i-door_blockedoff:", btLampkaDoorLockOff }, + { "i-slippery:", btLampkaPoslizg }, + { "i-contactors:", btLampkaStyczn }, + { "i-conv_ovld:", btLampkaNadmPrzetw }, + { "i-converter:", btLampkaPrzetw }, + { "i-converteroff:", btLampkaPrzetwOff }, + { "i-converterb:", btLampkaPrzetwB }, + { "i-converterboff:", btLampkaPrzetwBOff }, + { "i-diff_relay:", btLampkaPrzekRozn }, + { "i-diff_relay2:", btLampkaPrzekRoznPom }, + { "i-motor_ovld:", btLampkaNadmSil }, + { "i-train_controll:", btLampkaUkrotnienie }, + { "i-brake_delay_r:", btLampkaHamPosp }, + { "i-mainbreaker:", btLampkaWylSzybki }, + { "i-mainbreakerb:", btLampkaWylSzybkiB }, + { "i-mainbreakeroff:", btLampkaWylSzybkiOff }, + { "i-mainbreakerboff:", btLampkaWylSzybkiBOff }, + { "i-vent_ovld:", btLampkaNadmWent }, + { "i-comp_ovld:", btLampkaNadmSpr }, + { "i-resistors:", btLampkaOpory }, + { "i-no_resistors:", btLampkaBezoporowa }, + { "i-no_resistors_b:", btLampkaBezoporowaB }, + { "i-highcurrent:", btLampkaWysRozr }, + { "i-vent_trim:", btLampkaWentZaluzje }, + { "i-motorblowers:", btLampkaMotorBlowers }, + { "i-trainheating:", btLampkaOgrzewanieSkladu }, + { "i-security_aware:", btLampkaCzuwaka }, + { "i-security_cabsignal:", btLampkaSHP }, + { "i-door_left:", btLampkaDoorLeft }, + { "i-door_right:", btLampkaDoorRight }, + { "i-departure_signal:", btLampkaDepartureSignal }, + { "i-reserve:", btLampkaRezerwa }, + { "i-scnd:", btLampkaBoczniki }, + { "i-scnd1:", btLampkaBocznik1 }, + { "i-scnd2:", btLampkaBocznik2 }, + { "i-scnd3:", btLampkaBocznik3 }, + { "i-scnd4:", btLampkaBocznik4 }, + { "i-braking:", btLampkaHamienie }, + { "i-brakingoff:", btLampkaBrakingOff }, + { "i-dynamicbrake:", btLampkaED }, + { "i-brakeprofileg:", btLampkaBrakeProfileG }, + { "i-brakeprofilep:", btLampkaBrakeProfileP }, + { "i-brakeprofiler:", btLampkaBrakeProfileR }, + { "i-braking-ezt:", btLampkaHamowanie1zes }, + { "i-braking-ezt2:", btLampkaHamowanie2zes }, + { "i-compressor:", btLampkaSprezarka }, + { "i-compressorb:", btLampkaSprezarkaB }, + { "i-compressoroff:", btLampkaSprezarkaOff }, + { "i-compressorboff:", btLampkaSprezarkaBOff }, + { "i-fuelpumpoff:", btLampkaFuelPumpOff }, + { "i-voltbrake:", btLampkaNapNastHam }, + { "i-resistorsb:", btLampkaOporyB }, + { "i-contactorsb:", btLampkaStycznB }, + { "i-conv_ovldb:", btLampkaNadmPrzetwB }, + { "i-hvoltageb:", btLampkaHVoltageB }, + { "i-malfunction:", btLampkaMalfunction }, + { "i-malfunctionb:", btLampkaMalfunctionB }, + { "i-forward:", btLampkaForward }, + { "i-backward:", btLampkaBackward }, + { "i-upperlight:", btLampkaUpperLight }, + { "i-leftlight:", btLampkaLeftLight }, + { "i-rightlight:", btLampkaRightLight }, + { "i-leftend:", btLampkaLeftEndLight }, + { "i-rightend:", btLampkaRightEndLight }, + { "i-rearupperlight:", btLampkaRearUpperLight }, + { "i-rearleftlight:", btLampkaRearLeftLight }, + { "i-rearrightlight:", btLampkaRearRightLight }, + { "i-rearleftend:", btLampkaRearLeftEndLight }, + { "i-rearrightend:", btLampkaRearRightEndLight }, + { "i-dashboardlight:", btDashboardLight }, + { "i-timetablelight:", btTimetableLight }, + { "i-cablight:", btCabLight } + }; + auto lookup = lights.find( Label ); + if( lookup != lights.end() ) { + lookup->second.Load( Parser, DynamicObject, DynamicObject->mdKabina ); + } - // SEKCJA LAMPEK - if (Label == "i-maxft:") - { - btLampkaMaxSila.Load(Parser, DynamicObject->mdKabina); + else if( Label == "i-instrumentlight:" ) { + btInstrumentLight.Load( Parser, DynamicObject, DynamicObject->mdKabina, DynamicObject->mdModel ); + InstrumentLightType = 0; } - else if (Label == "i-maxftt:") - { - btLampkaPrzekrMaxSila.Load(Parser, DynamicObject->mdKabina); + else if( Label == "i-instrumentlight_M:" ) { + btInstrumentLight.Load( Parser, DynamicObject, DynamicObject->mdKabina, DynamicObject->mdModel ); + InstrumentLightType = 1; } - else if (Label == "i-radio:") - { - btLampkaRadio.Load(Parser, DynamicObject->mdKabina); - } - else if (Label == "i-manual_brake:") - { - btLampkaHamulecReczny.Load(Parser, DynamicObject->mdKabina); - } - else if (Label == "i-door_blocked:") - { - btLampkaBlokadaDrzwi.Load(Parser, DynamicObject->mdKabina); - } - else if (Label == "i-slippery:") - { - btLampkaPoslizg.Load(Parser, DynamicObject->mdKabina); - } - else if (Label == "i-contactors:") - { - btLampkaStyczn.Load(Parser, DynamicObject->mdKabina); - } - else if (Label == "i-conv_ovld:") - { - btLampkaNadmPrzetw.Load(Parser, DynamicObject->mdKabina); - } - else if (Label == "i-converter:") - { - btLampkaPrzetw.Load(Parser, DynamicObject->mdKabina); - } - else if (Label == "i-diff_relay:") - { - btLampkaPrzekRozn.Load(Parser, DynamicObject->mdKabina); - } - else if (Label == "i-diff_relay2:") - { - btLampkaPrzekRoznPom.Load(Parser, DynamicObject->mdKabina); - } - else if (Label == "i-motor_ovld:") - { - btLampkaNadmSil.Load(Parser, DynamicObject->mdKabina); - } - else if (Label == "i-train_controll:") - { - btLampkaUkrotnienie.Load(Parser, DynamicObject->mdKabina); - } - else if (Label == "i-brake_delay_r:") - { - btLampkaHamPosp.Load(Parser, DynamicObject->mdKabina); - } - else if (Label == "i-mainbreaker:") - { - btLampkaWylSzybki.Load(Parser, DynamicObject->mdKabina); - } - else if (Label == "i-vent_ovld:") - { - btLampkaNadmWent.Load(Parser, DynamicObject->mdKabina); - } - else if (Label == "i-comp_ovld:") - { - btLampkaNadmSpr.Load(Parser, DynamicObject->mdKabina); - } - else if (Label == "i-resistors:") - { - btLampkaOpory.Load(Parser, DynamicObject->mdKabina); - } - else if (Label == "i-no_resistors:") - { - btLampkaBezoporowa.Load(Parser, DynamicObject->mdKabina); - } - else if (Label == "i-no_resistors_b:") - { - btLampkaBezoporowaB.Load(Parser, DynamicObject->mdKabina); - } - else if (Label == "i-highcurrent:") - { - btLampkaWysRozr.Load(Parser, DynamicObject->mdKabina); - } - else if (Label == "i-universal3:") - { - btLampkaUniversal3.Load(Parser, DynamicObject->mdKabina, DynamicObject->mdModel); - LampkaUniversal3_typ = 0; - } - else if (Label == "i-universal3_M:") - { - btLampkaUniversal3.Load(Parser, DynamicObject->mdKabina, DynamicObject->mdModel); - LampkaUniversal3_typ = 1; - } - else if (Label == "i-universal3_C:") - { - btLampkaUniversal3.Load(Parser, DynamicObject->mdKabina, DynamicObject->mdModel); - LampkaUniversal3_typ = 2; - } - else if (Label == "i-vent_trim:") - { - btLampkaWentZaluzje.Load(Parser, DynamicObject->mdKabina); - } - else if (Label == "i-trainheating:") - { - btLampkaOgrzewanieSkladu.Load(Parser, DynamicObject->mdKabina); - } - else if (Label == "i-security_aware:") - { - btLampkaCzuwaka.Load(Parser, DynamicObject->mdKabina); - } - else if (Label == "i-security_cabsignal:") - { - btLampkaSHP.Load(Parser, DynamicObject->mdKabina); - } - else if (Label == "i-door_left:") - { - btLampkaDoorLeft.Load(Parser, DynamicObject->mdKabina); - } - else if (Label == "i-door_right:") - { - btLampkaDoorRight.Load(Parser, DynamicObject->mdKabina); - } - else if (Label == "i-departure_signal:") - { - btLampkaDepartureSignal.Load(Parser, DynamicObject->mdKabina); - } - else if (Label == "i-reserve:") - { - btLampkaRezerwa.Load(Parser, DynamicObject->mdKabina); - } - else if (Label == "i-scnd:") - { - btLampkaBoczniki.Load(Parser, DynamicObject->mdKabina); - } - else if (Label == "i-scnd1:") - { - btLampkaBocznik1.Load(Parser, DynamicObject->mdKabina); - } - else if (Label == "i-scnd2:") - { - btLampkaBocznik2.Load(Parser, DynamicObject->mdKabina); - } - else if (Label == "i-scnd3:") - { - btLampkaBocznik3.Load(Parser, DynamicObject->mdKabina); - } - else if (Label == "i-scnd4:") - { - btLampkaBocznik4.Load(Parser, DynamicObject->mdKabina); - } - else if (Label == "i-braking:") - { - btLampkaHamienie.Load(Parser, DynamicObject->mdKabina); - } - else if (Label == "i-braking-ezt:") - { - btLampkaHamowanie1zes.Load(Parser, DynamicObject->mdKabina); - } - else if (Label == "i-braking-ezt2:") - { - btLampkaHamowanie2zes.Load(Parser, DynamicObject->mdKabina); - } - else if (Label == "i-compressor:") - { - btLampkaSprezarka.Load(Parser, DynamicObject->mdKabina); - } - else if (Label == "i-compressorb:") - { - btLampkaSprezarkaB.Load(Parser, DynamicObject->mdKabina); - } - else if (Label == "i-voltbrake:") - { - btLampkaNapNastHam.Load(Parser, DynamicObject->mdKabina); - } - else if (Label == "i-mainbreakerb:") - { - btLampkaWylSzybkiB.Load(Parser, DynamicObject->mdKabina); - } - else if (Label == "i-resistorsb:") - { - btLampkaOporyB.Load(Parser, DynamicObject->mdKabina); - } - else if (Label == "i-contactorsb:") - { - btLampkaStycznB.Load(Parser, DynamicObject->mdKabina); - } - else if (Label == "i-conv_ovldb:") - { - btLampkaNadmPrzetwB.Load(Parser, DynamicObject->mdKabina); - } - else if (Label == "i-converterb:") - { - btLampkaPrzetwB.Load(Parser, DynamicObject->mdKabina); - } - else if (Label == "i-forward:") - { - btLampkaForward.Load(Parser, DynamicObject->mdKabina); - } - else if (Label == "i-backward:") - { - btLampkaBackward.Load(Parser, DynamicObject->mdKabina); - } - else if (Label == "i-cablight:") - { // hunter-171012 - btCabLight.Load(Parser, DynamicObject->mdKabina); + else if( Label == "i-instrumentlight_C:" ) { + btInstrumentLight.Load( Parser, DynamicObject, DynamicObject->mdKabina, DynamicObject->mdModel ); + InstrumentLightType = 2; } else if (Label == "i-doors:") { int i = Parser.getToken() - 1; - bt = Cabine[Cabindex].Button(-1); // pierwsza wolna lampka - bt->Load(Parser, DynamicObject->mdKabina); - bt->AssignBool(bDoors[0] + 3 * i); + auto &button = Cabine[Cabindex].Button(-1); // pierwsza wolna lampka + button.Load(Parser, DynamicObject, DynamicObject->mdKabina); + button.AssignBool(bDoors[0] + 3 * i); } +/* + else if( Label == "i-malfunction:" ) { + // generic malfunction indicator + auto &button = Cabine[ Cabindex ].Button( -1 ); // pierwsza wolna gałka + button.Load( Parser, DynamicObject, DynamicObject->mdKabina ); + button.AssignBool( &mvOccupied->dizel_heat.PA ); + } +*/ else { // failed to match the label @@ -6062,344 +7620,180 @@ bool TTrain::initialize_button(cParser &Parser, std::string const &Label, int co return true; } -// initializes a gauge matching provided label. returns: true if the label was found, false -// otherwise -// NOTE: this is temporary work-around for compiler else-if limit +// initializes a gauge matching provided label. returns: true if the label was found, false otherwise // TODO: refactor the cabin controls into some sensible structure -bool TTrain::initialize_gauge(cParser &Parser, std::string const &Label, int const Cabindex) -{ +bool TTrain::initialize_gauge(cParser &Parser, std::string const &Label, int const Cabindex) { - TGauge *gg; // roboczy wskaźnik na obiekt animujący gałkę - - /* sanity check - if( !DynamicObject->mdKabina ) { - WriteLog( "Cab not initialised!" ); - return false; - } - */ - // SEKCJA REGULATOROW - if (Label == "mainctrl:") - { - // nastawnik - ggMainCtrl.Load(Parser, DynamicObject->mdKabina); - } - else if (Label == "mainctrlact:") - { - // zabek pozycji aktualnej - ggMainCtrlAct.Load(Parser, DynamicObject->mdKabina); - } - else if (Label == "scndctrl:") - { - // bocznik - ggScndCtrl.Load(Parser, DynamicObject->mdKabina); - } - else if (Label == "dirkey:") - { - // klucz kierunku - ggDirKey.Load(Parser, DynamicObject->mdKabina); - } - else if (Label == "brakectrl:") - { - // hamulec zasadniczy - ggBrakeCtrl.Load(Parser, DynamicObject->mdKabina); - } - else if (Label == "localbrake:") - { - // hamulec pomocniczy - ggLocalBrake.Load(Parser, DynamicObject->mdKabina); - } - else if (Label == "manualbrake:") - { - // hamulec reczny - ggManualBrake.Load(Parser, DynamicObject->mdKabina); - } - // sekcja przelacznikow obrotowych - else if (Label == "brakeprofile_sw:") - { - // przelacznik tow/osob/posp - ggBrakeProfileCtrl.Load(Parser, DynamicObject->mdKabina); - } - else if (Label == "brakeprofileg_sw:") - { - // przelacznik tow/osob - ggBrakeProfileG.Load(Parser, DynamicObject->mdKabina); - } - else if (Label == "brakeprofiler_sw:") - { - // przelacznik osob/posp - ggBrakeProfileR.Load(Parser, DynamicObject->mdKabina); - } - else if (Label == "maxcurrent_sw:") - { - // przelacznik rozruchu - ggMaxCurrentCtrl.Load(Parser, DynamicObject->mdKabina); - } - // SEKCJA przyciskow sprezynujacych - else if (Label == "main_off_bt:") - { - // przycisk wylaczajacy (w EU07 wyl szybki czerwony) - ggMainOffButton.Load(Parser, DynamicObject->mdKabina); - } - else if (Label == "main_on_bt:") - { - // przycisk wlaczajacy (w EU07 wyl szybki zielony) - ggMainOnButton.Load(Parser, DynamicObject->mdKabina); - } - else if (Label == "security_reset_bt:") - { - // przycisk zbijajacy SHP/czuwak - ggSecurityResetButton.Load(Parser, DynamicObject->mdKabina); - } - else if (Label == "releaser_bt:") - { - // przycisk odluzniacza - ggReleaserButton.Load(Parser, DynamicObject->mdKabina); - } - else if (Label == "sand_bt:") - { - // przycisk piasecznicy - ggSandButton.Load(Parser, DynamicObject->mdKabina); - } - else if (Label == "antislip_bt:") - { - // przycisk antyposlizgowy - ggAntiSlipButton.Load(Parser, DynamicObject->mdKabina); - } - else if (Label == "horn_bt:") - { - // dzwignia syreny - ggHornButton.Load(Parser, DynamicObject->mdKabina); - } - else if (Label == "fuse_bt:") - { - // bezp. nadmiarowy - ggFuseButton.Load(Parser, DynamicObject->mdKabina); - } - else if (Label == "converterfuse_bt:") - { - // hunter-261211: - // odblokowanie przekaznika nadm. przetw. i ogrz. - ggConverterFuseButton.Load(Parser, DynamicObject->mdKabina); - } - else if (Label == "stlinoff_bt:") - { - // st. liniowe - ggStLinOffButton.Load(Parser, DynamicObject->mdKabina); - } - else if (Label == "door_left_sw:") - { - // drzwi lewe - ggDoorLeftButton.Load(Parser, DynamicObject->mdKabina); - } - else if (Label == "door_right_sw:") - { - // drzwi prawe - ggDoorRightButton.Load(Parser, DynamicObject->mdKabina); - } - else if (Label == "departure_signal_bt:") - { - // sygnal odjazdu - ggDepartureSignalButton.Load(Parser, DynamicObject->mdKabina); - } - else if (Label == "upperlight_sw:") - { - // swiatlo - ggUpperLightButton.Load(Parser, DynamicObject->mdKabina); - } - else if (Label == "leftlight_sw:") - { - // swiatlo - ggLeftLightButton.Load(Parser, DynamicObject->mdKabina); - } - else if (Label == "rightlight_sw:") - { - // swiatlo - ggRightLightButton.Load(Parser, DynamicObject->mdKabina); - } - else if (Label == "leftend_sw:") - { - // swiatlo - ggLeftEndLightButton.Load(Parser, DynamicObject->mdKabina); - } - else if (Label == "rightend_sw:") - { - // swiatlo - ggRightEndLightButton.Load(Parser, DynamicObject->mdKabina); - } - else if (Label == "lights_sw:") - { - // swiatla wszystkie - ggLightsButton.Load(Parser, DynamicObject->mdKabina); - } - //--------------------- - // hunter-230112: przelaczniki swiatel tylnich - else if (Label == "rearupperlight_sw:") - { - // swiatlo - ggRearUpperLightButton.Load(Parser, DynamicObject->mdKabina); - } - else if (Label == "rearleftlight_sw:") - { - // swiatlo - ggRearLeftLightButton.Load(Parser, DynamicObject->mdKabina); - } - else if (Label == "rearrightlight_sw:") - { - // swiatlo - ggRearRightLightButton.Load(Parser, DynamicObject->mdKabina); - } - else if (Label == "rearleftend_sw:") - { - // swiatlo - ggRearLeftEndLightButton.Load(Parser, DynamicObject->mdKabina); - } - else if (Label == "rearrightend_sw:") - { - // swiatlo - ggRearRightEndLightButton.Load(Parser, DynamicObject->mdKabina); - } - //------------------ - else if (Label == "compressor_sw:") - { - // sprezarka - ggCompressorButton.Load(Parser, DynamicObject->mdKabina); - } - else if (Label == "converter_sw:") - { - // przetwornica - ggConverterButton.Load(Parser, DynamicObject->mdKabina); - } - else if (Label == "converteroff_sw:") - { - // przetwornica wyl - ggConverterOffButton.Load(Parser, DynamicObject->mdKabina); - } - else if (Label == "main_sw:") - { - // wyl szybki (ezt) - ggMainButton.Load(Parser, DynamicObject->mdKabina); - } - else if (Label == "radio_sw:") - { - // radio - ggRadioButton.Load(Parser, DynamicObject->mdKabina); - } - else if (Label == "pantfront_sw:") - { - // patyk przedni - ggPantFrontButton.Load(Parser, DynamicObject->mdKabina); - } - else if (Label == "pantrear_sw:") - { - // patyk tylny - ggPantRearButton.Load(Parser, DynamicObject->mdKabina); - } - else if (Label == "pantfrontoff_sw:") - { - // patyk przedni w dol - ggPantFrontButtonOff.Load(Parser, DynamicObject->mdKabina); - } - else if (Label == "pantalloff_sw:") - { - // patyk przedni w dol - ggPantAllDownButton.Load(Parser, DynamicObject->mdKabina); - } - else if (Label == "trainheating_sw:") - { - // grzanie skladu - ggTrainHeatingButton.Load(Parser, DynamicObject->mdKabina); - } - else if (Label == "signalling_sw:") - { - // Sygnalizacja hamowania - ggSignallingButton.Load(Parser, DynamicObject->mdKabina); - } - else if (Label == "door_signalling_sw:") - { - // Sygnalizacja blokady drzwi - ggDoorSignallingButton.Load(Parser, DynamicObject->mdKabina); - } - else if (Label == "nextcurrent_sw:") - { - // prąd drugiego członu - ggNextCurrentButton.Load(Parser, DynamicObject->mdKabina); - } - else if (Label == "cablight_sw:") - { - // hunter-091012: swiatlo w kabinie - ggCabLightButton.Load(Parser, DynamicObject->mdKabina); - } - else if (Label == "cablightdim_sw:") - { - // hunter-091012: przyciemnienie swiatla w kabinie - ggCabLightDimButton.Load(Parser, DynamicObject->mdKabina); + std::unordered_map const gauges = { + { "mainctrl:", ggMainCtrl }, + { "scndctrl:", ggScndCtrl }, + { "dirkey:" , ggDirKey }, + { "brakectrl:", ggBrakeCtrl }, + { "localbrake:", ggLocalBrake }, + { "manualbrake:", ggManualBrake }, + { "alarmchain:", ggAlarmChain }, + { "brakeprofile_sw:", ggBrakeProfileCtrl }, + { "brakeprofileg_sw:", ggBrakeProfileG }, + { "brakeprofiler_sw:", ggBrakeProfileR }, + { "brakeopmode_sw:", ggBrakeOperationModeCtrl }, + { "maxcurrent_sw:", ggMaxCurrentCtrl }, + { "main_off_bt:", ggMainOffButton }, + { "main_on_bt:", ggMainOnButton }, + { "security_reset_bt:", ggSecurityResetButton }, + { "releaser_bt:", ggReleaserButton }, + { "sand_bt:", ggSandButton }, + { "antislip_bt:", ggAntiSlipButton }, + { "horn_bt:", ggHornButton }, + { "hornlow_bt:", ggHornLowButton }, + { "hornhigh_bt:", ggHornHighButton }, + { "whistle_bt:", ggWhistleButton }, + { "fuse_bt:", ggFuseButton }, + { "converterfuse_bt:", ggConverterFuseButton }, + { "stlinoff_bt:", ggStLinOffButton }, + { "door_left_sw:", ggDoorLeftButton }, + { "door_right_sw:", ggDoorRightButton }, + { "doorlefton_sw:", ggDoorLeftOnButton }, + { "doorrighton_sw:", ggDoorRightOnButton }, + { "doorleftoff_sw:", ggDoorLeftOffButton }, + { "doorrightoff_sw:", ggDoorRightOffButton }, + { "dooralloff_sw:", ggDoorAllOffButton }, + { "departure_signal_bt:", ggDepartureSignalButton }, + { "upperlight_sw:", ggUpperLightButton }, + { "leftlight_sw:", ggLeftLightButton }, + { "rightlight_sw:", ggRightLightButton }, + { "dimheadlights_sw:", ggDimHeadlightsButton }, + { "leftend_sw:", ggLeftEndLightButton }, + { "rightend_sw:", ggRightEndLightButton }, + { "lights_sw:", ggLightsButton }, + { "rearupperlight_sw:", ggRearUpperLightButton }, + { "rearleftlight_sw:", ggRearLeftLightButton }, + { "rearrightlight_sw:", ggRearRightLightButton }, + { "rearleftend_sw:", ggRearLeftEndLightButton }, + { "rearrightend_sw:", ggRearRightEndLightButton }, + { "compressor_sw:", ggCompressorButton }, + { "compressorlocal_sw:", ggCompressorLocalButton }, + { "converter_sw:", ggConverterButton }, + { "converterlocal_sw:", ggConverterLocalButton }, + { "converteroff_sw:", ggConverterOffButton }, + { "main_sw:", ggMainButton }, + { "waterpumpbreaker_sw:", ggWaterPumpBreakerButton }, + { "waterpump_sw:", ggWaterPumpButton }, + { "waterheaterbreaker_sw:", ggWaterHeaterBreakerButton }, + { "waterheater_sw:", ggWaterHeaterButton }, + { "water1tempb:", ggWater1TempB }, + { "watercircuitslink_sw:", ggWaterCircuitsLinkButton }, + { "fuelpump_sw:", ggFuelPumpButton }, + { "oilpump_sw:", ggOilPumpButton }, + { "oilpressb:", ggOilPressB }, + { "motorblowersfront_sw:", ggMotorBlowersFrontButton }, + { "motorblowersrear_sw:", ggMotorBlowersRearButton }, + { "motorblowersalloff_sw:", ggMotorBlowersAllOffButton }, + { "radio_sw:", ggRadioButton }, + { "radiochannel_sw:", ggRadioChannelSelector }, + { "radiochannelprev_sw:", ggRadioChannelPrevious }, + { "radiochannelnext_sw:", ggRadioChannelNext }, + { "radiostop_sw:", ggRadioStop }, + { "radiotest_sw:", ggRadioTest }, + { "pantfront_sw:", ggPantFrontButton }, + { "pantrear_sw:", ggPantRearButton }, + { "pantfrontoff_sw:", ggPantFrontButtonOff }, + { "pantrearoff_sw:", ggPantRearButtonOff }, + { "pantalloff_sw:", ggPantAllDownButton }, + { "pantselected_sw:", ggPantSelectedButton }, + { "pantselectedoff_sw:", ggPantSelectedDownButton }, + { "pantcompressor_sw:", ggPantCompressorButton }, + { "pantcompressorvalve_sw:", ggPantCompressorValve }, + { "trainheating_sw:", ggTrainHeatingButton }, + { "signalling_sw:", ggSignallingButton }, + { "door_signalling_sw:", ggDoorSignallingButton }, + { "nextcurrent_sw:", ggNextCurrentButton }, + { "instrumentlight_sw:", ggInstrumentLightButton }, + { "dashboardlight_sw:", ggDashboardLightButton }, + { "timetablelight_sw:", ggTimetableLightButton }, + { "cablight_sw:", ggCabLightButton }, + { "cablightdim_sw:", ggCabLightDimButton }, + { "battery_sw:", ggBatteryButton }, + { "universal0:", ggUniversals[ 0 ] }, + { "universal1:", ggUniversals[ 1 ] }, + { "universal2:", ggUniversals[ 2 ] }, + { "universal3:", ggUniversals[ 3 ] }, + { "universal4:", ggUniversals[ 4 ] }, + { "universal5:", ggUniversals[ 5 ] }, + { "universal6:", ggUniversals[ 6 ] }, + { "universal7:", ggUniversals[ 7 ] }, + { "universal8:", ggUniversals[ 8 ] }, + { "universal9:", ggUniversals[ 9 ] } + }; + auto lookup = gauges.find( Label ); + if( lookup != gauges.end() ) { + lookup->second.Load( Parser, DynamicObject, DynamicObject->mdKabina ); + m_controlmapper.insert( lookup->second, lookup->first ); } // ABu 090305: uniwersalne przyciski lub inne rzeczy - else if (Label == "universal1:") - { - ggUniversal1Button.Load(Parser, DynamicObject->mdKabina, DynamicObject->mdModel); - } - else if (Label == "universal2:") - { - ggUniversal2Button.Load(Parser, DynamicObject->mdKabina, DynamicObject->mdModel); - } - else if (Label == "universal3:") - { - ggUniversal3Button.Load(Parser, DynamicObject->mdKabina, DynamicObject->mdModel); - } - else if (Label == "universal4:") - { - ggUniversal4Button.Load(Parser, DynamicObject->mdKabina, DynamicObject->mdModel); + else if( Label == "mainctrlact:" ) { + ggMainCtrlAct.Load( Parser, DynamicObject, DynamicObject->mdKabina, DynamicObject->mdModel ); } // SEKCJA WSKAZNIKOW else if ((Label == "tachometer:") || (Label == "tachometerb:")) { // predkosciomierz wskaźnikowy z szarpaniem - gg = Cabine[Cabindex].Gauge(-1); // pierwsza wolna gałka - gg->Load(Parser, DynamicObject->mdKabina); - gg->AssignFloat(&fTachoVelocityJump); + auto &gauge = Cabine[Cabindex].Gauge(-1); // pierwsza wolna gałka + gauge.Load(Parser, DynamicObject, DynamicObject->mdKabina); + gauge.AssignFloat(&fTachoVelocityJump); + // bind tachometer sound location to the meter + if( dsbHasler.offset() == glm::vec3() ) { + dsbHasler.offset( gauge.model_offset() ); + } } else if (Label == "tachometern:") { // predkosciomierz wskaźnikowy bez szarpania - gg = Cabine[Cabindex].Gauge(-1); // pierwsza wolna gałka - gg->Load(Parser, DynamicObject->mdKabina); - gg->AssignFloat(&fTachoVelocity); + auto &gauge = Cabine[Cabindex].Gauge(-1); // pierwsza wolna gałka + gauge.Load(Parser, DynamicObject, DynamicObject->mdKabina); + gauge.AssignFloat(&fTachoVelocity); + // bind tachometer sound location to the meter + if( dsbHasler.offset() == glm::vec3() ) { + dsbHasler.offset( gauge.model_offset() ); + } } else if (Label == "tachometerd:") { // predkosciomierz cyfrowy - gg = Cabine[Cabindex].Gauge(-1); // pierwsza wolna gałka - gg->Load(Parser, DynamicObject->mdKabina); - gg->AssignFloat(&fTachoVelocity); + auto &gauge = Cabine[Cabindex].Gauge(-1); // pierwsza wolna gałka + gauge.Load(Parser, DynamicObject, DynamicObject->mdKabina); + gauge.AssignFloat(&fTachoVelocity); + // bind tachometer sound location to the meter + if( dsbHasler.offset() == glm::vec3() ) { + dsbHasler.offset( gauge.model_offset() ); + } } else if ((Label == "hvcurrent1:") || (Label == "hvcurrent1b:")) { // 1szy amperomierz - gg = Cabine[Cabindex].Gauge(-1); // pierwsza wolna gałka - gg->Load(Parser, DynamicObject->mdKabina); - gg->AssignFloat(fHCurrent + 1); + auto &gauge = Cabine[Cabindex].Gauge(-1); // pierwsza wolna gałka + gauge.Load(Parser, DynamicObject, DynamicObject->mdKabina); + gauge.AssignFloat(fHCurrent + 1); } else if ((Label == "hvcurrent2:") || (Label == "hvcurrent2b:")) { // 2gi amperomierz - gg = Cabine[Cabindex].Gauge(-1); // pierwsza wolna gałka - gg->Load(Parser, DynamicObject->mdKabina); - gg->AssignFloat(fHCurrent + 2); + auto &gauge = Cabine[Cabindex].Gauge(-1); // pierwsza wolna gałka + gauge.Load(Parser, DynamicObject, DynamicObject->mdKabina); + gauge.AssignFloat(fHCurrent + 2); } else if ((Label == "hvcurrent3:") || (Label == "hvcurrent3b:")) { // 3ci amperomierz - gg = Cabine[Cabindex].Gauge(-1); // pierwsza wolna gałska - gg->Load(Parser, DynamicObject->mdKabina); - gg->AssignFloat(fHCurrent + 3); + auto &gauge = Cabine[Cabindex].Gauge(-1); // pierwsza wolna gałska + gauge.Load(Parser, DynamicObject, DynamicObject->mdKabina); + gauge.AssignFloat(fHCurrent + 3); } else if ((Label == "hvcurrent:") || (Label == "hvcurrentb:")) { // amperomierz calkowitego pradu - gg = Cabine[Cabindex].Gauge(-1); // pierwsza wolna gałka - gg->Load(Parser, DynamicObject->mdKabina); - gg->AssignFloat(fHCurrent); + auto &gauge = Cabine[Cabindex].Gauge(-1); // pierwsza wolna gałka + gauge.Load(Parser, DynamicObject, DynamicObject->mdKabina); + gauge.AssignFloat(fHCurrent); } else if (Label == "eimscreen:") { @@ -6407,9 +7801,9 @@ bool TTrain::initialize_gauge(cParser &Parser, std::string const &Label, int con int i, j; Parser.getTokens(2, false); Parser >> i >> j; - gg = Cabine[Cabindex].Gauge(-1); // pierwsza wolna gałka - gg->Load(Parser, DynamicObject->mdKabina); - gg->AssignFloat(&fEIMParams[i][j]); + auto &gauge = Cabine[Cabindex].Gauge(-1); // pierwsza wolna gałka + gauge.Load(Parser, DynamicObject, DynamicObject->mdKabina); + gauge.AssignFloat(&fEIMParams[i][j]); } else if (Label == "brakes:") { @@ -6417,64 +7811,88 @@ bool TTrain::initialize_gauge(cParser &Parser, std::string const &Label, int con int i, j; Parser.getTokens(2, false); Parser >> i >> j; - gg = Cabine[Cabindex].Gauge(-1); // pierwsza wolna gałka - gg->Load(Parser, DynamicObject->mdKabina); - gg->AssignFloat(&fPress[i - 1][j]); + auto &gauge = Cabine[Cabindex].Gauge(-1); // pierwsza wolna gałka + gauge.Load(Parser, DynamicObject, DynamicObject->mdKabina); + gauge.AssignFloat(&fPress[i - 1][j]); } else if ((Label == "brakepress:") || (Label == "brakepressb:")) { // manometr cylindrow hamulcowych // Ra 2014-08: przeniesione do TCab - gg = Cabine[Cabindex].Gauge(-1); // pierwsza wolna gałka - gg->Load(Parser, DynamicObject->mdKabina, NULL, 0.1); - gg->AssignDouble(&mvOccupied->BrakePress); + auto &gauge = Cabine[Cabindex].Gauge(-1); // pierwsza wolna gałka + gauge.Load(Parser, DynamicObject, DynamicObject->mdKabina, nullptr, 0.1); + gauge.AssignDouble(&mvOccupied->BrakePress); } else if ((Label == "pipepress:") || (Label == "pipepressb:")) { // manometr przewodu hamulcowego - TGauge *gg = Cabine[Cabindex].Gauge(-1); // pierwsza wolna gałka - gg->Load(Parser, DynamicObject->mdKabina, NULL, 0.1); - gg->AssignDouble(&mvOccupied->PipePress); + auto &gauge = Cabine[Cabindex].Gauge(-1); // pierwsza wolna gałka + gauge.Load(Parser, DynamicObject, DynamicObject->mdKabina, nullptr, 0.1); + gauge.AssignDouble(&mvOccupied->PipePress); } else if (Label == "limpipepress:") { // manometr zbiornika sterujacego zaworu maszynisty - ggZbS.Load(Parser, DynamicObject->mdKabina, NULL, 0.1); + ggZbS.Load(Parser, DynamicObject, DynamicObject->mdKabina, nullptr, 0.1); } else if (Label == "cntrlpress:") { // manometr zbiornika kontrolnego/rorzďż˝du - gg = Cabine[Cabindex].Gauge(-1); // pierwsza wolna gałka - gg->Load(Parser, DynamicObject->mdKabina, NULL, 0.1); - gg->AssignDouble(&mvControlled->PantPress); + auto &gauge = Cabine[Cabindex].Gauge(-1); // pierwsza wolna gałka + gauge.Load(Parser, DynamicObject, DynamicObject->mdKabina, nullptr, 0.1); + gauge.AssignDouble(&mvControlled->PantPress); } else if ((Label == "compressor:") || (Label == "compressorb:")) { // manometr sprezarki/zbiornika glownego - gg = Cabine[Cabindex].Gauge(-1); // pierwsza wolna gałka - gg->Load(Parser, DynamicObject->mdKabina, NULL, 0.1); - gg->AssignDouble(&mvOccupied->Compressor); + auto &gauge = Cabine[Cabindex].Gauge(-1); // pierwsza wolna gałka + gauge.Load(Parser, DynamicObject, DynamicObject->mdKabina, nullptr, 0.1); + gauge.AssignDouble(&mvOccupied->Compressor); + } + else if( Label == "oilpress:" ) { + // oil pressure + auto &gauge = Cabine[ Cabindex ].Gauge( -1 ); // pierwsza wolna gałka + gauge.Load( Parser, DynamicObject, DynamicObject->mdKabina, nullptr ); + gauge.AssignFloat( &mvControlled->OilPump.pressure ); + } + else if( Label == "oiltemp:" ) { + // oil temperature + auto &gauge = Cabine[ Cabindex ].Gauge( -1 ); // pierwsza wolna gałka + gauge.Load( Parser, DynamicObject, DynamicObject->mdKabina, nullptr ); + gauge.AssignFloat( &mvControlled->dizel_heat.To ); + } + else if( Label == "water1temp:" ) { + // main circuit water temperature + auto &gauge = Cabine[ Cabindex ].Gauge( -1 ); // pierwsza wolna gałka + gauge.Load( Parser, DynamicObject, DynamicObject->mdKabina, nullptr ); + gauge.AssignFloat( &mvControlled->dizel_heat.temperatura1 ); + } + else if( Label == "water2temp:" ) { + // auxiliary circuit water temperature + auto &gauge = Cabine[ Cabindex ].Gauge( -1 ); // pierwsza wolna gałka + gauge.Load( Parser, DynamicObject, DynamicObject->mdKabina, nullptr ); + gauge.AssignFloat( &mvControlled->dizel_heat.temperatura2 ); } // yB - dla drugiej sekcji else if (Label == "hvbcurrent1:") { // 1szy amperomierz - ggI1B.Load(Parser, DynamicObject->mdKabina); + ggI1B.Load(Parser, DynamicObject, DynamicObject->mdKabina); } else if (Label == "hvbcurrent2:") { // 2gi amperomierz - ggI2B.Load(Parser, DynamicObject->mdKabina); + ggI2B.Load(Parser, DynamicObject, DynamicObject->mdKabina); } else if (Label == "hvbcurrent3:") { // 3ci amperomierz - ggI3B.Load(Parser, DynamicObject->mdKabina); + ggI3B.Load(Parser, DynamicObject, DynamicObject->mdKabina); } else if (Label == "hvbcurrent:") { // amperomierz calkowitego pradu - ggItotalB.Load(Parser, DynamicObject->mdKabina); + ggItotalB.Load(Parser, DynamicObject, DynamicObject->mdKabina); } //************************************************************* else if (Label == "clock:") @@ -6483,73 +7901,77 @@ bool TTrain::initialize_gauge(cParser &Parser, std::string const &Label, int con if (Parser.getToken() == "analog") { // McZapkie-300302: zegarek - ggClockSInd.Init(DynamicObject->mdKabina->GetFromName("ClockShand"), gt_Rotate, - 0.016666667, 0, 0); - ggClockMInd.Init(DynamicObject->mdKabina->GetFromName("ClockMhand"), gt_Rotate, - 0.016666667, 0, 0); - ggClockHInd.Init(DynamicObject->mdKabina->GetFromName("ClockHhand"), gt_Rotate, - 0.083333333, 0, 0); + ggClockSInd.Init(DynamicObject->mdKabina->GetFromName("ClockShand"), TGaugeAnimation::gt_Rotate, 1.0/60.0); + ggClockMInd.Init(DynamicObject->mdKabina->GetFromName("ClockMhand"), TGaugeAnimation::gt_Rotate, 1.0/60.0); + ggClockHInd.Init(DynamicObject->mdKabina->GetFromName("ClockHhand"), TGaugeAnimation::gt_Rotate, 1.0/12.0); } } else if (Label == "evoltage:") { // woltomierz napiecia silnikow - ggEngineVoltage.Load(Parser, DynamicObject->mdKabina); + ggEngineVoltage.Load(Parser, DynamicObject, DynamicObject->mdKabina); } else if (Label == "hvoltage:") { // woltomierz wysokiego napiecia - gg = Cabine[Cabindex].Gauge(-1); // pierwsza wolna gałka - gg->Load(Parser, DynamicObject->mdKabina); - gg->AssignFloat(&fHVoltage); + auto &gauge = Cabine[Cabindex].Gauge(-1); // pierwsza wolna gałka + gauge.Load(Parser, DynamicObject, DynamicObject->mdKabina); + gauge.AssignFloat(&fHVoltage); } else if (Label == "lvoltage:") { // woltomierz niskiego napiecia - ggLVoltage.Load(Parser, DynamicObject->mdKabina); + ggLVoltage.Load(Parser, DynamicObject, DynamicObject->mdKabina); } else if (Label == "enrot1m:") { // obrotomierz - gg = Cabine[Cabindex].Gauge(-1); // pierwsza wolna gałka - gg->Load(Parser, DynamicObject->mdKabina); - gg->AssignFloat(fEngine + 1); + auto &gauge = Cabine[Cabindex].Gauge(-1); // pierwsza wolna gałka + gauge.Load(Parser, DynamicObject, DynamicObject->mdKabina); + gauge.AssignFloat(fEngine + 1); } // ggEnrot1m.Load(Parser,DynamicObject->mdKabina); else if (Label == "enrot2m:") { // obrotomierz - gg = Cabine[Cabindex].Gauge(-1); // pierwsza wolna gałka - gg->Load(Parser, DynamicObject->mdKabina); - gg->AssignFloat(fEngine + 2); + auto &gauge = Cabine[Cabindex].Gauge(-1); // pierwsza wolna gałka + gauge.Load(Parser, DynamicObject, DynamicObject->mdKabina); + gauge.AssignFloat(fEngine + 2); } // ggEnrot2m.Load(Parser,DynamicObject->mdKabina); else if (Label == "enrot3m:") { // obrotomierz - gg = Cabine[Cabindex].Gauge(-1); // pierwsza wolna gałka - gg->Load(Parser, DynamicObject->mdKabina); - gg->AssignFloat(fEngine + 3); + auto &gauge = Cabine[Cabindex].Gauge(-1); // pierwsza wolna gałka + gauge.Load(Parser, DynamicObject, DynamicObject->mdKabina); + gauge.AssignFloat(fEngine + 3); } // ggEnrot3m.Load(Parser,DynamicObject->mdKabina); else if (Label == "engageratio:") { // np. ciśnienie sterownika sprzęgła - gg = Cabine[Cabindex].Gauge(-1); // pierwsza wolna gałka - gg->Load(Parser, DynamicObject->mdKabina); - gg->AssignDouble(&mvControlled->dizel_engage); + auto &gauge = Cabine[Cabindex].Gauge(-1); // pierwsza wolna gałka + gauge.Load(Parser, DynamicObject, DynamicObject->mdKabina); + gauge.AssignDouble(&mvControlled->dizel_engage); } // ggEngageRatio.Load(Parser,DynamicObject->mdKabina); else if (Label == "maingearstatus:") { // np. ciśnienie sterownika skrzyni biegów - ggMainGearStatus.Load(Parser, DynamicObject->mdKabina); + ggMainGearStatus.Load(Parser, DynamicObject, DynamicObject->mdKabina); } else if (Label == "ignitionkey:") { - ggIgnitionKey.Load(Parser, DynamicObject->mdKabina); + ggIgnitionKey.Load(Parser, DynamicObject, DynamicObject->mdKabina); } else if (Label == "distcounter:") { // Ra 2014-07: licznik kilometrów - gg = Cabine[Cabindex].Gauge(-1); // pierwsza wolna gałka - gg->Load(Parser, DynamicObject->mdKabina); - gg->AssignDouble(&mvControlled->DistCounter); + auto &gauge = Cabine[Cabindex].Gauge(-1); // pierwsza wolna gałka + gauge.Load(Parser, DynamicObject, DynamicObject->mdKabina); + gauge.AssignDouble(&mvControlled->DistCounter); + } + else if( Label == "shuntmodepower:" ) { + // shunt mode power slider + auto &gauge = Cabine[Cabindex].Gauge(-1); // pierwsza wolna gałka + gauge.Load(Parser, DynamicObject, DynamicObject->mdKabina); + gauge.AssignDouble(&mvControlled->AnPos); + m_controlmapper.insert( gauge, "shuntmodepower:" ); } else { diff --git a/Train.h b/Train.h index 2ca7ac82..de0888ab 100644 --- a/Train.h +++ b/Train.h @@ -7,121 +7,341 @@ obtain one at http://mozilla.org/MPL/2.0/. */ -#ifndef TrainH -#define TrainH +#pragma once -//#include "Track.h" -//#include "TrkFoll.h" -#include "Button.h" -#include "DynObj.h" -#include "Gauge.h" -#include "Model3d.h" -#include "Spring.h" -#include "mtable.h" - -#include "AdvSound.h" -#include "FadeSound.h" -#include "PyInt.h" -#include "RealSound.h" -#include "Sound.h" #include +#include "DynObj.h" +#include "Button.h" +#include "Gauge.h" +#include "Spring.h" +#include "sound.h" +#include "PyInt.h" +#include "command.h" // typedef enum {st_Off, st_Starting, st_On, st_ShuttingDown} T4State; const int maxcab = 2; -// const double fCzuwakTime= 90.0f; const double fCzuwakBlink = 0.15; -const float fConverterPrzekaznik = 1.5; // hunter-261211: do przekaznika nadmiarowego przetwornicy +const float fConverterPrzekaznik = 1.5f; // hunter-261211: do przekaznika nadmiarowego przetwornicy // 0.33f // const double fBuzzerTime= 5.0f; -const float fHaslerTime = 1.2; +const float fHaslerTime = 1.2f; -// const double fStycznTime= 0.5f; -// const double fDblClickTime= 0.2f; +class TCab { -class TCab -{ - public: - TCab(); - ~TCab(); - void Init(double Initx1, double Inity1, double Initz1, double Initx2, double Inity2, - double Initz2, bool InitEnabled, bool InitOccupied); +public: +// methods void Load(cParser &Parser); - vector3 CabPos1; - vector3 CabPos2; - bool bEnabled; - bool bOccupied; - double dimm_r, dimm_g, dimm_b; // McZapkie-120503: tlumienie swiatla - double intlit_r, intlit_g, intlit_b; // McZapkie-120503: oswietlenie kabiny - double intlitlow_r, intlitlow_g, - intlitlow_b; // McZapkie-120503: przyciemnione oswietlenie kabiny - private: - // bool bChangePossible; - TGauge *ggList; // Ra 2014-08: lista animacji macierzowych (gałek) w kabinie - int iGaugesMax, iGauges; // ile miejsca w tablicy i ile jest w użyciu - TButton *btList; // Ra 2014-08: lista animacji dwustanowych (lampek) w kabinie - int iButtonsMax, iButtons; // ile miejsca w tablicy i ile jest w użyciu - public: - TGauge *Gauge(int n = -1); // pobranie adresu obiektu - TButton *Button(int n = -1); // pobranie adresu obiektu void Update(); +// members + Math3D::vector3 CabPos1 { 0, 1, 1 }; + Math3D::vector3 CabPos2 { 0, 1, -1 }; + bool bEnabled { false }; + bool bOccupied { true }; + glm::vec3 dimm; // McZapkie-120503: tlumienie swiatla + glm::vec3 intlit; // McZapkie-120503: oswietlenie kabiny + glm::vec3 intlitlow; // McZapkie-120503: przyciemnione oswietlenie kabiny + TGauge &Gauge( int n = -1 ); // pobranie adresu obiektu + TButton &Button( int n = -1 ); // pobranie adresu obiektu + +private: +// members + std::vector ggList; + std::vector btList; +}; + +class control_mapper { + typedef std::unordered_map< TSubModel const *, std::string> submodelstring_map; + submodelstring_map m_controlnames; +public: + void + clear() { m_controlnames.clear(); } + void + insert( TGauge const &Gauge, std::string const &Label ); + std::string + find( TSubModel const *Control ) const; }; class TTrain { public: +// types + struct state_t { + std::uint8_t shp; + std::uint8_t alerter; + std::uint8_t radio_stop; + std::uint8_t motor_resistors; + std::uint8_t line_breaker; + std::uint8_t motor_overload; + std::uint8_t motor_connectors; + std::uint8_t wheelslip; + std::uint8_t converter_overload; + std::uint8_t converter_off; + std::uint8_t compressor_overload; + std::uint8_t ventilator_overload; + std::uint8_t motor_overload_threshold; + std::uint8_t train_heating; + std::uint8_t recorder_braking; + std::uint8_t recorder_power; + std::uint8_t alerter_sound; + std::uint8_t coupled_hv_voltage_relays; + float velocity; + float reservoir_pressure; + float pipe_pressure; + float brake_pressure; + float hv_voltage; + std::array hv_current; + }; + +// methods bool CabChange(int iDirection); - bool ActiveUniversal4; bool ShowNextCurrent; // pokaz przd w podlaczonej lokomotywie (ET41) bool InitializeCab(int NewCabNo, std::string const &asFileName); TTrain(); - ~TTrain(); - // bool Init(TTrack *Track); // McZapkie-010302 bool Init(TDynamicObject *NewDynamicObject, bool e3d = false); - void OnKeyDown(int cKey); - void OnKeyUp(int cKey); - // bool SHP() { fShpTimer= 0; }; - - inline vector3 GetDirection() - { - return DynamicObject->VectorFront(); - }; - inline vector3 GetUp() - { - return DynamicObject->VectorUp(); - }; + inline Math3D::vector3 GetDirection() { return DynamicObject->VectorFront(); }; + inline Math3D::vector3 GetUp() { return DynamicObject->VectorUp(); }; + inline std::string GetLabel( TSubModel const *Control ) const { return m_controlmapper.find( Control ); } void UpdateMechPosition(double dt); + Math3D::vector3 GetWorldMechPosition(); bool Update( double const Deltatime ); - bool m_updated = false; void MechStop(); void SetLights(); - // virtual bool RenderAlpha(); // McZapkie-310302: ladowanie parametrow z pliku bool LoadMMediaFile(std::string const &asFileName); PyObject *GetTrainState(); + state_t get_state() const; private: +// types + typedef void( *command_handler )( TTrain *Train, command_data const &Command ); + typedef std::unordered_map commandhandler_map; +// methods // clears state of all cabin controls void clear_cab_controls(); - // initializes a gauge matching provided label. returns: true if the label was found, false - // otherwise + // sets cabin controls based on current state of the vehicle + // NOTE: we can get rid of this function once we have per-cab persistent state + void set_cab_controls(); + // initializes a gauge matching provided label. returns: true if the label was found, false otherwise bool initialize_gauge(cParser &Parser, std::string const &Label, int const Cabindex); - // initializes a button matching provided label. returns: true if the label was found, false - // otherwise + // initializes a button matching provided label. returns: true if the label was found, false otherwise bool initialize_button(cParser &Parser, std::string const &Label, int const Cabindex); + // helper, returns true for EMU with oerlikon brake + bool is_eztoer() const; + // locates nearest vehicle belonging to the consist + TDynamicObject *find_nearest_consist_vehicle() const; + // mover master controller to specified position + void set_master_controller( double const Position ); + // moves train brake lever to specified position, potentially emits switch sound if conditions are met + void set_train_brake( double const Position ); + // sets specified brake acting speed for specified vehicle, potentially updating state of cab controls to match + void set_train_brake_speed( TDynamicObject *Vehicle, int const Speed ); + // sets the motor connector button in paired unit to specified state + void set_paired_open_motor_connectors_button( bool const State ); + // update function subroutines + void update_sounds( double const Deltatime ); + void update_sounds_runningnoise( sound_source &Sound ); + void update_sounds_radio(); - private: //żeby go nic z zewnątrz nie przestawiało - TDynamicObject *DynamicObject; // przestawia zmiana pojazdu [F5] - private: //żeby go nic z zewnątrz nie przestawiało - TMoverParameters *mvControlled; // człon, w którym sterujemy silnikiem - TMoverParameters *mvOccupied; // człon, w którym sterujemy hamulcem - TMoverParameters *mvSecond; // drugi człon (ET40, ET41, ET42, ukrotnienia) - TMoverParameters *mvThird; // trzeci człon (SN61) - public: // reszta może by?publiczna - // AnsiString asMessage; + // command handlers + // NOTE: we're currently using universal handlers and static handler map but it may be beneficial to have these implemented on individual class instance basis + // TBD, TODO: consider this approach if we ever want to have customized consist behaviour to received commands, based on the consist/vehicle type or whatever + static void OnCommand_aidriverenable( TTrain *Train, command_data const &Command ); + static void OnCommand_aidriverdisable( TTrain *Train, command_data const &Command ); + static void OnCommand_mastercontrollerincrease( TTrain *Train, command_data const &Command ); + static void OnCommand_mastercontrollerincreasefast( TTrain *Train, command_data const &Command ); + static void OnCommand_mastercontrollerdecrease( TTrain *Train, command_data const &Command ); + static void OnCommand_mastercontrollerdecreasefast( TTrain *Train, command_data const &Command ); + static void OnCommand_mastercontrollerset( TTrain *Train, command_data const &Command ); + static void OnCommand_secondcontrollerincrease( TTrain *Train, command_data const &Command ); + static void OnCommand_secondcontrollerincreasefast( TTrain *Train, command_data const &Command ); + static void OnCommand_secondcontrollerdecrease( TTrain *Train, command_data const &Command ); + static void OnCommand_secondcontrollerdecreasefast( TTrain *Train, command_data const &Command ); + static void OnCommand_secondcontrollerset( TTrain *Train, command_data const &Command ); + static void OnCommand_notchingrelaytoggle( TTrain *Train, command_data const &Command ); + static void OnCommand_mucurrentindicatorothersourceactivate( TTrain *Train, command_data const &Command ); + static void OnCommand_independentbrakeincrease( TTrain *Train, command_data const &Command ); + static void OnCommand_independentbrakeincreasefast( TTrain *Train, command_data const &Command ); + static void OnCommand_independentbrakedecrease( TTrain *Train, command_data const &Command ); + static void OnCommand_independentbrakedecreasefast( TTrain *Train, command_data const &Command ); + static void OnCommand_independentbrakeset( TTrain *Train, command_data const &Command ); + static void OnCommand_independentbrakebailoff( TTrain *Train, command_data const &Command ); + static void OnCommand_trainbrakeincrease( TTrain *Train, command_data const &Command ); + static void OnCommand_trainbrakedecrease( TTrain *Train, command_data const &Command ); + static void OnCommand_trainbrakeset( TTrain *Train, command_data const &Command ); + static void OnCommand_trainbrakecharging( TTrain *Train, command_data const &Command ); + static void OnCommand_trainbrakerelease( TTrain *Train, command_data const &Command ); + static void OnCommand_trainbrakefirstservice( TTrain *Train, command_data const &Command ); + static void OnCommand_trainbrakeservice( TTrain *Train, command_data const &Command ); + static void OnCommand_trainbrakefullservice( TTrain *Train, command_data const &Command ); + static void OnCommand_trainbrakehandleoff( TTrain *Train, command_data const &Command ); + static void OnCommand_trainbrakeemergency( TTrain *Train, command_data const &Command ); + static void OnCommand_trainbrakebasepressureincrease( TTrain *Train, command_data const &Command ); + static void OnCommand_trainbrakebasepressuredecrease( TTrain *Train, command_data const &Command ); + static void OnCommand_trainbrakebasepressurereset( TTrain *Train, command_data const &Command ); + static void OnCommand_trainbrakeoperationtoggle( TTrain *Train, command_data const &Command ); + static void OnCommand_manualbrakeincrease( TTrain *Train, command_data const &Command ); + static void OnCommand_manualbrakedecrease( TTrain *Train, command_data const &Command ); + static void OnCommand_alarmchaintoggle( TTrain *Train, command_data const &Command ); + static void OnCommand_wheelspinbrakeactivate( TTrain *Train, command_data const &Command ); + static void OnCommand_sandboxactivate( TTrain *Train, command_data const &Command ); + static void OnCommand_epbrakecontroltoggle( TTrain *Train, command_data const &Command ); + static void OnCommand_trainbrakeoperationmodeincrease(TTrain *Train, command_data const &Command); + static void OnCommand_trainbrakeoperationmodedecrease(TTrain *Train, command_data const &Command); + static void OnCommand_brakeactingspeedincrease( TTrain *Train, command_data const &Command ); + static void OnCommand_brakeactingspeeddecrease( TTrain *Train, command_data const &Command ); + static void OnCommand_brakeactingspeedsetcargo( TTrain *Train, command_data const &Command ); + static void OnCommand_brakeactingspeedsetpassenger( TTrain *Train, command_data const &Command ); + static void OnCommand_brakeactingspeedsetrapid( TTrain *Train, command_data const &Command ); + static void OnCommand_brakeloadcompensationincrease( TTrain *Train, command_data const &Command ); + static void OnCommand_brakeloadcompensationdecrease( TTrain *Train, command_data const &Command ); + static void OnCommand_mubrakingindicatortoggle( TTrain *Train, command_data const &Command ); + static void OnCommand_reverserincrease( TTrain *Train, command_data const &Command ); + static void OnCommand_reverserdecrease( TTrain *Train, command_data const &Command ); + static void OnCommand_reverserforwardhigh( TTrain *Train, command_data const &Command ); + static void OnCommand_reverserforward( TTrain *Train, command_data const &Command ); + static void OnCommand_reverserneutral( TTrain *Train, command_data const &Command ); + static void OnCommand_reverserbackward( TTrain *Train, command_data const &Command ); + static void OnCommand_alerteracknowledge( TTrain *Train, command_data const &Command ); + static void OnCommand_batterytoggle( TTrain *Train, command_data const &Command ); + static void OnCommand_batteryenable( TTrain *Train, command_data const &Command ); + static void OnCommand_batterydisable( TTrain *Train, command_data const &Command ); + static void OnCommand_pantographcompressorvalvetoggle( TTrain *Train, command_data const &Command ); + static void OnCommand_pantographcompressoractivate( TTrain *Train, command_data const &Command ); + static void OnCommand_pantographtogglefront( TTrain *Train, command_data const &Command ); + static void OnCommand_pantographtogglerear( TTrain *Train, command_data const &Command ); + static void OnCommand_pantographraisefront( TTrain *Train, command_data const &Command ); + static void OnCommand_pantographraiserear( TTrain *Train, command_data const &Command ); + static void OnCommand_pantographlowerfront( TTrain *Train, command_data const &Command ); + static void OnCommand_pantographlowerrear( TTrain *Train, command_data const &Command ); + static void OnCommand_pantographlowerall( TTrain *Train, command_data const &Command ); + static void OnCommand_linebreakertoggle( TTrain *Train, command_data const &Command ); + static void OnCommand_linebreakeropen( TTrain *Train, command_data const &Command ); + static void OnCommand_linebreakerclose( TTrain *Train, command_data const &Command ); + static void OnCommand_fuelpumptoggle( TTrain *Train, command_data const &Command ); + static void OnCommand_fuelpumpenable( TTrain *Train, command_data const &Command ); + static void OnCommand_fuelpumpdisable( TTrain *Train, command_data const &Command ); + static void OnCommand_oilpumptoggle( TTrain *Train, command_data const &Command ); + static void OnCommand_oilpumpenable( TTrain *Train, command_data const &Command ); + static void OnCommand_oilpumpdisable( TTrain *Train, command_data const &Command ); + static void OnCommand_waterheaterbreakertoggle( TTrain *Train, command_data const &Command ); + static void OnCommand_waterheaterbreakerclose( TTrain *Train, command_data const &Command ); + static void OnCommand_waterheaterbreakeropen( TTrain *Train, command_data const &Command ); + static void OnCommand_waterheatertoggle( TTrain *Train, command_data const &Command ); + static void OnCommand_waterheaterenable( TTrain *Train, command_data const &Command ); + static void OnCommand_waterheaterdisable( TTrain *Train, command_data const &Command ); + static void OnCommand_waterpumpbreakertoggle( TTrain *Train, command_data const &Command ); + static void OnCommand_waterpumpbreakerclose( TTrain *Train, command_data const &Command ); + static void OnCommand_waterpumpbreakeropen( TTrain *Train, command_data const &Command ); + static void OnCommand_waterpumptoggle( TTrain *Train, command_data const &Command ); + static void OnCommand_waterpumpenable( TTrain *Train, command_data const &Command ); + static void OnCommand_waterpumpdisable( TTrain *Train, command_data const &Command ); + static void OnCommand_watercircuitslinktoggle( TTrain *Train, command_data const &Command ); + static void OnCommand_watercircuitslinkenable( TTrain *Train, command_data const &Command ); + static void OnCommand_watercircuitslinkdisable( TTrain *Train, command_data const &Command ); + static void OnCommand_convertertoggle( TTrain *Train, command_data const &Command ); + static void OnCommand_converterenable( TTrain *Train, command_data const &Command ); + static void OnCommand_converterdisable( TTrain *Train, command_data const &Command ); + static void OnCommand_convertertogglelocal( TTrain *Train, command_data const &Command ); + static void OnCommand_converteroverloadrelayreset( TTrain *Train, command_data const &Command ); + static void OnCommand_compressortoggle( TTrain *Train, command_data const &Command ); + static void OnCommand_compressorenable( TTrain *Train, command_data const &Command ); + static void OnCommand_compressordisable( TTrain *Train, command_data const &Command ); + static void OnCommand_compressortogglelocal( TTrain *Train, command_data const &Command ); + static void OnCommand_motorblowerstogglefront( TTrain *Train, command_data const &Command ); + static void OnCommand_motorblowersenablefront( TTrain *Train, command_data const &Command ); + static void OnCommand_motorblowersdisablefront( TTrain *Train, command_data const &Command ); + static void OnCommand_motorblowerstogglerear( TTrain *Train, command_data const &Command ); + static void OnCommand_motorblowersenablerear( TTrain *Train, command_data const &Command ); + static void OnCommand_motorblowersdisablerear( TTrain *Train, command_data const &Command ); + static void OnCommand_motorblowersdisableall( TTrain *Train, command_data const &Command ); + static void OnCommand_motorconnectorsopen( TTrain *Train, command_data const &Command ); + static void OnCommand_motorconnectorsclose( TTrain *Train, command_data const &Command ); + static void OnCommand_motordisconnect( TTrain *Train, command_data const &Command ); + static void OnCommand_motoroverloadrelaythresholdtoggle( TTrain *Train, command_data const &Command ); + static void OnCommand_motoroverloadrelaythresholdsetlow( TTrain *Train, command_data const &Command ); + static void OnCommand_motoroverloadrelaythresholdsethigh( TTrain *Train, command_data const &Command ); + static void OnCommand_motoroverloadrelayreset( TTrain *Train, command_data const &Command ); + static void OnCommand_heatingtoggle( TTrain *Train, command_data const &Command ); + static void OnCommand_heatingenable( TTrain *Train, command_data const &Command ); + static void OnCommand_heatingdisable( TTrain *Train, command_data const &Command ); + static void OnCommand_lightspresetactivatenext( TTrain *Train, command_data const &Command ); + static void OnCommand_lightspresetactivateprevious( TTrain *Train, command_data const &Command ); + static void OnCommand_headlighttoggleleft( TTrain *Train, command_data const &Command ); + static void OnCommand_headlightenableleft( TTrain *Train, command_data const &Command ); + static void OnCommand_headlightdisableleft( TTrain *Train, command_data const &Command ); + static void OnCommand_headlighttoggleright( TTrain *Train, command_data const &Command ); + static void OnCommand_headlightenableright( TTrain *Train, command_data const &Command ); + static void OnCommand_headlightdisableright( TTrain *Train, command_data const &Command ); + static void OnCommand_headlighttoggleupper( TTrain *Train, command_data const &Command ); + static void OnCommand_headlightenableupper( TTrain *Train, command_data const &Command ); + static void OnCommand_headlightdisableupper( TTrain *Train, command_data const &Command ); + static void OnCommand_redmarkertoggleleft( TTrain *Train, command_data const &Command ); + static void OnCommand_redmarkerenableleft( TTrain *Train, command_data const &Command ); + static void OnCommand_redmarkerdisableleft( TTrain *Train, command_data const &Command ); + static void OnCommand_redmarkertoggleright( TTrain *Train, command_data const &Command ); + static void OnCommand_redmarkerenableright( TTrain *Train, command_data const &Command ); + static void OnCommand_redmarkerdisableright( TTrain *Train, command_data const &Command ); + static void OnCommand_headlighttogglerearleft( TTrain *Train, command_data const &Command ); + static void OnCommand_headlighttogglerearright( TTrain *Train, command_data const &Command ); + static void OnCommand_headlighttogglerearupper( TTrain *Train, command_data const &Command ); + static void OnCommand_redmarkertogglerearleft( TTrain *Train, command_data const &Command ); + static void OnCommand_redmarkertogglerearright( TTrain *Train, command_data const &Command ); + static void OnCommand_redmarkerstoggle( TTrain *Train, command_data const &Command ); + static void OnCommand_endsignalstoggle( TTrain *Train, command_data const &Command ); + static void OnCommand_headlightsdimtoggle( TTrain *Train, command_data const &Command ); + static void OnCommand_headlightsdimenable( TTrain *Train, command_data const &Command ); + static void OnCommand_headlightsdimdisable( TTrain *Train, command_data const &Command ); + static void OnCommand_interiorlighttoggle( TTrain *Train, command_data const &Command ); + static void OnCommand_interiorlightenable( TTrain *Train, command_data const &Command ); + static void OnCommand_interiorlightdisable( TTrain *Train, command_data const &Command ); + static void OnCommand_interiorlightdimtoggle( TTrain *Train, command_data const &Command ); + static void OnCommand_interiorlightdimenable( TTrain *Train, command_data const &Command ); + static void OnCommand_interiorlightdimdisable( TTrain *Train, command_data const &Command ); + static void OnCommand_instrumentlighttoggle( TTrain *Train, command_data const &Command ); + static void OnCommand_instrumentlightenable( TTrain *Train, command_data const &Command ); + static void OnCommand_instrumentlightdisable( TTrain *Train, command_data const &Command ); + static void OnCommand_dashboardlighttoggle( TTrain *Train, command_data const &Command ); + static void OnCommand_timetablelighttoggle( TTrain *Train, command_data const &Command ); + static void OnCommand_doorlocktoggle( TTrain *Train, command_data const &Command ); + static void OnCommand_doortoggleleft( TTrain *Train, command_data const &Command ); + static void OnCommand_doortoggleright( TTrain *Train, command_data const &Command ); + static void OnCommand_dooropenleft( TTrain *Train, command_data const &Command ); + static void OnCommand_dooropenright( TTrain *Train, command_data const &Command ); + static void OnCommand_doorcloseleft( TTrain *Train, command_data const &Command ); + static void OnCommand_doorcloseright( TTrain *Train, command_data const &Command ); + static void OnCommand_doorcloseall( TTrain *Train, command_data const &Command ); + static void OnCommand_carcouplingincrease( TTrain *Train, command_data const &Command ); + static void OnCommand_carcouplingdisconnect( TTrain *Train, command_data const &Command ); + static void OnCommand_departureannounce( TTrain *Train, command_data const &Command ); + static void OnCommand_hornlowactivate( TTrain *Train, command_data const &Command ); + static void OnCommand_hornhighactivate( TTrain *Train, command_data const &Command ); + static void OnCommand_whistleactivate( TTrain *Train, command_data const &Command ); + static void OnCommand_radiotoggle( TTrain *Train, command_data const &Command ); + static void OnCommand_radiochannelincrease( TTrain *Train, command_data const &Command ); + static void OnCommand_radiochanneldecrease( TTrain *Train, command_data const &Command ); + static void OnCommand_radiostopsend( TTrain *Train, command_data const &Command ); + static void OnCommand_radiostoptest( TTrain *Train, command_data const &Command ); + static void OnCommand_cabchangeforward( TTrain *Train, command_data const &Command ); + static void OnCommand_cabchangebackward( TTrain *Train, command_data const &Command ); + static void OnCommand_generictoggle( TTrain *Train, command_data const &Command ); + + +// members + TDynamicObject *DynamicObject { nullptr }; // przestawia zmiana pojazdu [F5] + TMoverParameters *mvControlled { nullptr }; // człon, w którym sterujemy silnikiem + TMoverParameters *mvOccupied { nullptr }; // człon, w którym sterujemy hamulcem + TMoverParameters *mvSecond { nullptr }; // drugi człon (ET40, ET41, ET42, ukrotnienia) + TMoverParameters *mvThird { nullptr }; // trzeci człon (SN61) + // helper variable, to prevent immediate switch between closing and opening line breaker circuit + int m_linebreakerstate { 0 }; // 0: open, 1: closed, 2: freshly closed (and yes this is awful way to go about it) + static const commandhandler_map m_commandhandlers; + control_mapper m_controlmapper; + +public: // reszta może by?publiczna // McZapkie: definicje wskaźników // Ra 2014-08: częsciowo przeniesione do tablicy w TCab @@ -129,12 +349,7 @@ class TTrain TGauge ggClockSInd; TGauge ggClockMInd; TGauge ggClockHInd; - // TGauge ggHVoltage; TGauge ggLVoltage; - // TGauge ggEnrot1m; - // TGauge ggEnrot2m; - // TGauge ggEnrot3m; - // TGauge ggEngageRatio; TGauge ggMainGearStatus; TGauge ggEngineVoltage; @@ -143,18 +358,23 @@ class TTrain TGauge ggI3B; TGauge ggItotalB; + TGauge ggOilPressB; // other unit oil pressure indicator + TGauge ggWater1TempB; + // McZapkie: definicje regulatorow TGauge ggMainCtrl; TGauge ggMainCtrlAct; TGauge ggScndCtrl; - TGauge ggScndCtrlButton; + TGauge ggScndCtrlButton; // NOTE: not used? TGauge ggDirKey; TGauge ggBrakeCtrl; TGauge ggLocalBrake; TGauge ggManualBrake; + TGauge ggAlarmChain; TGauge ggBrakeProfileCtrl; // nastawiacz GPR - przelacznik obrotowy TGauge ggBrakeProfileG; // nastawiacz GP - hebelek towarowy TGauge ggBrakeProfileR; // nastawiacz PR - hamowanie dwustopniowe + TGauge ggBrakeOperationModeCtrl; //przełącznik trybu pracy PS/PN/EP/MED TGauge ggMaxCurrentCtrl; @@ -166,16 +386,21 @@ class TTrain TGauge ggSandButton; // guzik piasecznicy TGauge ggAntiSlipButton; TGauge ggFuseButton; - TGauge ggConverterFuseButton; // hunter-261211: przycisk odblokowania - // nadmiarowego przetwornic i ogrzewania + TGauge ggConverterFuseButton; // hunter-261211: przycisk odblokowania nadmiarowego przetwornic i ogrzewania TGauge ggStLinOffButton; TGauge ggRadioButton; + TGauge ggRadioChannelSelector; + TGauge ggRadioChannelPrevious; + TGauge ggRadioChannelNext; + TGauge ggRadioTest; + TGauge ggRadioStop; TGauge ggUpperLightButton; TGauge ggLeftLightButton; TGauge ggRightLightButton; TGauge ggLeftEndLightButton; TGauge ggRightEndLightButton; TGauge ggLightsButton; // przelacznik reflektorow (wszystkich) + TGauge ggDimHeadlightsButton; // headlights dimming switch // hunter-230112: przelacznik swiatel tylnich TGauge ggRearUpperLightButton; @@ -187,18 +412,23 @@ class TTrain TGauge ggIgnitionKey; TGauge ggCompressorButton; + TGauge ggCompressorLocalButton; // controls only compressor of its own unit (et42-specific) TGauge ggConverterButton; + TGauge ggConverterLocalButton; // controls only converter of its own unit (et42-specific) TGauge ggConverterOffButton; // ABu 090305 - syrena i prad nastepnego czlonu TGauge ggHornButton; + TGauge ggHornLowButton; + TGauge ggHornHighButton; + TGauge ggWhistleButton; TGauge ggNextCurrentButton; - // ABu 090305 - uniwersalne przyciski - TGauge ggUniversal1Button; - TGauge ggUniversal2Button; - TGauge ggUniversal3Button; - TGauge ggUniversal4Button; + std::array ggUniversals; // NOTE: temporary arrangement until we have dynamically built control table + + TGauge ggInstrumentLightButton; + TGauge ggDashboardLightButton; + TGauge ggTimetableLightButton; TGauge ggCabLightButton; // hunter-091012: przelacznik oswietlania kabiny TGauge ggCabLightDimButton; // hunter-091012: przelacznik przyciemnienia TGauge ggBatteryButton; // Stele 161228 hebelek baterii @@ -207,53 +437,79 @@ class TTrain // NBMX wrzesien 2003 - obsluga drzwi TGauge ggDoorLeftButton; TGauge ggDoorRightButton; + TGauge ggDoorLeftOnButton; + TGauge ggDoorRightOnButton; + TGauge ggDoorLeftOffButton; + TGauge ggDoorRightOffButton; + TGauge ggDoorAllOffButton; TGauge ggDepartureSignalButton; // Winger 160204 - obsluga pantografow - ZROBIC TGauge ggPantFrontButton; TGauge ggPantRearButton; TGauge ggPantFrontButtonOff; // EZT + TGauge ggPantRearButtonOff; TGauge ggPantAllDownButton; + TGauge ggPantSelectedButton; + TGauge ggPantSelectedDownButton; + TGauge ggPantCompressorButton; + TGauge ggPantCompressorValve; // Winger 020304 - wlacznik ogrzewania TGauge ggTrainHeatingButton; TGauge ggSignallingButton; TGauge ggDoorSignallingButton; - // TModel3d *mdKabina; McZapkie-030303: to do dynobj - // TGauge ggDistCounter; //Ra 2014-07: licznik kilometrów - // TGauge ggVelocityDgt; //i od razu prędkościomierz + + TGauge ggWaterPumpBreakerButton; // water pump breaker switch + TGauge ggWaterPumpButton; // water pump switch + TGauge ggWaterHeaterBreakerButton; // water heater breaker switch + TGauge ggWaterHeaterButton; // water heater switch + TGauge ggWaterCircuitsLinkButton; + TGauge ggFuelPumpButton; // fuel pump switch + TGauge ggOilPumpButton; // fuel pump switch + TGauge ggMotorBlowersFrontButton; // front traction motor fan switch + TGauge ggMotorBlowersRearButton; // rear traction motor fan switch + TGauge ggMotorBlowersAllOffButton; // motor fans shutdown switch TButton btLampkaPoslizg; TButton btLampkaStyczn; TButton btLampkaNadmPrzetw; TButton btLampkaPrzetw; - TButton btLampkaPrzekRozn; - TButton btLampkaPrzekRoznPom; + TButton btLampkaPrzetwOff; + TButton btLampkaPrzekRozn; // TODO: implement + TButton btLampkaPrzekRoznPom; // TODO: implement TButton btLampkaNadmSil; TButton btLampkaWylSzybki; + TButton btLampkaWylSzybkiOff; TButton btLampkaNadmWent; - TButton btLampkaNadmSpr; + TButton btLampkaNadmSpr; // TODO: implement // yB: drugie lampki dla EP05 i ET42 TButton btLampkaOporyB; TButton btLampkaStycznB; TButton btLampkaWylSzybkiB; + TButton btLampkaWylSzybkiBOff; TButton btLampkaNadmPrzetwB; TButton btLampkaPrzetwB; + TButton btLampkaPrzetwBOff; + TButton btLampkaHVoltageB; // TODO: implement // KURS90 lampki jazdy bezoporowej dla EU04 TButton btLampkaBezoporowaB; TButton btLampkaBezoporowa; TButton btLampkaUkrotnienie; TButton btLampkaHamPosp; TButton btLampkaRadio; + TButton btLampkaRadioStop; TButton btLampkaHamowanie1zes; TButton btLampkaHamowanie2zes; - // TButton btLampkaUnknown; TButton btLampkaOpory; TButton btLampkaWysRozr; - TButton btLampkaUniversal3; - int LampkaUniversal3_typ; // ABu 030405 - swiecenie uzaleznione od: 0-nic, - // 1-obw.gl, 2-przetw. - bool LampkaUniversal3_st; - TButton btLampkaWentZaluzje; // ET22 + TButton btInstrumentLight; + TButton btDashboardLight; + TButton btTimetableLight; + int InstrumentLightType{ 0 }; // ABu 030405 - swiecenie uzaleznione od: 0-nic, 1-obw.gl, 2-przetw. + bool InstrumentLightActive{ false }; + bool DashboardLightActive{ false }; + bool TimetableLightActive{ false }; + TButton btLampkaWentZaluzje; // ET22 // TODO: implement TButton btLampkaOgrzewanieSkladu; TButton btLampkaSHP; TButton btLampkaCzuwaka; // McZapkie-141102 @@ -262,41 +518,61 @@ class TTrain TButton btLampkaNapNastHam; TButton btLampkaSprezarka; TButton btLampkaSprezarkaB; + TButton btLampkaSprezarkaOff; + TButton btLampkaSprezarkaBOff; + TButton btLampkaFuelPumpOff; TButton btLampkaBocznik1; TButton btLampkaBocznik2; TButton btLampkaBocznik3; TButton btLampkaBocznik4; - TButton btLampkaRadiotelefon; + TButton btLampkaRadiotelefon; // TODO: implement TButton btLampkaHamienie; + TButton btLampkaBrakingOff; TButton btLampkaED; // Stele 161228 hamowanie elektrodynamiczne - TButton btLampkaJazda; // Ra: nie używane + TButton btLampkaBrakeProfileG; // cargo train brake acting speed + TButton btLampkaBrakeProfileP; // passenger train brake acting speed + TButton btLampkaBrakeProfileR; // rapid brake acting speed // KURS90 TButton btLampkaBoczniki; TButton btLampkaMaxSila; TButton btLampkaPrzekrMaxSila; - // TButton bt; - // TButton btLampkaDoorLeft; TButton btLampkaDoorRight; TButton btLampkaDepartureSignal; TButton btLampkaBlokadaDrzwi; + TButton btLampkaDoorLockOff; TButton btLampkaHamulecReczny; TButton btLampkaForward; // Ra: lampki w przód i w ty?dla komputerowych kabin TButton btLampkaBackward; + // light indicators + TButton btLampkaUpperLight; + TButton btLampkaLeftLight; + TButton btLampkaRightLight; + TButton btLampkaLeftEndLight; + TButton btLampkaRightEndLight; + TButton btLampkaRearUpperLight; + TButton btLampkaRearLeftLight; + TButton btLampkaRearRightLight; + TButton btLampkaRearLeftEndLight; + TButton btLampkaRearRightEndLight; + // other + TButton btLampkaMalfunction; + TButton btLampkaMalfunctionB; + TButton btLampkaMotorBlowers; TButton btCabLight; // hunter-171012: lampa oswietlajaca kabine // Ra 2013-12: wirtualne "lampki" do odbijania na haslerze w PoKeys TButton btHaslerBrakes; // ciśnienie w cylindrach TButton btHaslerCurrent; // prąd na silnikach - +/* vector3 pPosition; - vector3 pMechOffset; // driverNpos - vector3 vMechMovement; - vector3 pMechPosition; - vector3 pMechShake; - vector3 vMechVelocity; +*/ + Math3D::vector3 pMechOffset; // driverNpos + Math3D::vector3 vMechMovement; + Math3D::vector3 pMechPosition; + Math3D::vector3 pMechShake; + Math3D::vector3 vMechVelocity; // McZapkie: do poruszania sie po kabinie - double fMechCroach; // McZapkie: opis kabiny - obszar poruszania sie mechanika oraz zajetosc TCab Cabine[maxcab + 1]; // przedzial maszynowy, kabina 1 (A), kabina 2 (B) int iCabn; @@ -307,101 +583,81 @@ class TTrain double fMechMaxSpring; double fMechRoll; double fMechPitch; + struct engineshake_config { + float scale { 2.f }; + float fadein_offset { 1.5f }; // 90 rpm + float fadein_factor { 0.3f }; + float fadeout_offset { 10.f }; // 600 rpm + float fadeout_factor { 0.5f }; + } EngineShake; + struct huntingshake_config { + float scale { 1.f }; + float frequency { 1.f }; + float fadein_begin { 0.f }; // effect start speed in km/h + float fadein_end { 0.f }; // full effect speed in km/h + } HuntingShake; + float HuntingAngle { 0.f }; // crude approximation of hunting oscillation; current angle of sine wave + bool IsHunting { false }; - PSound dsbNastawnikJazdy; - PSound dsbNastawnikBocz; // hunter-081211 - PSound dsbRelay; - PSound dsbPneumaticRelay; - PSound dsbSwitch; - PSound dsbPneumaticSwitch; - PSound dsbReverserKey; // hunter-121211 + sound_source dsbReverserKey { sound_placement::internal, EU07_SOUND_CABCONTROLSCUTOFFRANGE }; // hunter-121211 + sound_source dsbNastawnikJazdy { sound_placement::internal, EU07_SOUND_CABCONTROLSCUTOFFRANGE }; + sound_source dsbNastawnikBocz { sound_placement::internal, EU07_SOUND_CABCONTROLSCUTOFFRANGE }; // hunter-081211 + sound_source dsbSwitch { sound_placement::internal, EU07_SOUND_CABCONTROLSCUTOFFRANGE }; + sound_source dsbPneumaticSwitch { sound_placement::internal, EU07_SOUND_CABCONTROLSCUTOFFRANGE }; - PSound dsbCouplerAttach; // Ra: w kabinie???? - PSound dsbCouplerDetach; // Ra: w kabinie??? + sound_source rsHiss { sound_placement::internal, EU07_SOUND_CABCONTROLSCUTOFFRANGE }; // upuszczanie + sound_source rsHissU { sound_placement::internal, EU07_SOUND_CABCONTROLSCUTOFFRANGE }; // napelnianie + sound_source rsHissE { sound_placement::internal, EU07_SOUND_CABCONTROLSCUTOFFRANGE }; // nagle + sound_source rsHissX { sound_placement::internal, EU07_SOUND_CABCONTROLSCUTOFFRANGE }; // fala + sound_source rsHissT { sound_placement::internal, EU07_SOUND_CABCONTROLSCUTOFFRANGE }; // czasowy + sound_source rsSBHiss { sound_placement::internal, EU07_SOUND_CABCONTROLSCUTOFFRANGE }; // local + sound_source rsSBHissU { sound_placement::internal, EU07_SOUND_CABCONTROLSCUTOFFRANGE }; // local, engage brakes + float m_lastlocalbrakepressure { -1.f }; // helper, cached level of pressure in local brake cylinder + float m_localbrakepressurechange { 0.f }; // recent change of pressure in local brake cylinder - PSound dsbDieselIgnition; // Ra: w kabinie??? + sound_source rsFadeSound { sound_placement::internal, EU07_SOUND_CABCONTROLSCUTOFFRANGE }; + sound_source rsRunningNoise{ sound_placement::internal, EU07_SOUND_GLOBALRANGE }; + sound_source rsHuntingNoise{ sound_placement::internal, EU07_SOUND_GLOBALRANGE }; - PSound dsbDoorClose; // Ra: w kabinie??? - PSound dsbDoorOpen; // Ra: w kabinie??? + sound_source dsbHasler { sound_placement::internal, EU07_SOUND_CABCONTROLSCUTOFFRANGE }; + sound_source dsbBuzzer { sound_placement::internal, EU07_SOUND_CABCONTROLSCUTOFFRANGE }; + sound_source dsbSlipAlarm { sound_placement::internal, EU07_SOUND_CABCONTROLSCUTOFFRANGE }; // Bombardier 011010: alarm przy poslizgu dla 181/182 + sound_source m_radiosound { sound_placement::internal, 2 * EU07_SOUND_CABCONTROLSCUTOFFRANGE }; // cached template for radio messages + std::vector>> m_radiomessages; // list of currently played radio messages + sound_source m_radiostop { sound_placement::internal, EU07_SOUND_CABCONTROLSCUTOFFRANGE }; - // Winger 010304 - PSound dsbPantUp; - PSound dsbPantDown; - - PSound dsbWejscie_na_bezoporow; - PSound dsbWejscie_na_drugi_uklad; // hunter-081211: poprawka literowki - - // PSound dsbHiss1; - // PSound dsbHiss2; - - // McZapkie-280302 - TRealSound rsBrake; - TRealSound rsSlippery; - TRealSound rsHiss; // upuszczanie - TRealSound rsHissU; // napelnianie - TRealSound rsHissE; // nagle - TRealSound rsHissX; // fala - TRealSound rsHissT; // czasowy - TRealSound rsSBHiss; - TRealSound rsRunningNoise; - TRealSound rsEngageSlippery; - TRealSound rsFadeSound; - - PSound dsbHasler; - PSound dsbBuzzer; - PSound dsbSlipAlarm; // Bombardier 011010: alarm przy poslizgu dla 181/182 - // TFadeSound sConverter; //przetwornica - // TFadeSound sSmallCompressor; //przetwornica - - int iCabLightFlag; // McZapkie:120503: oswietlenie kabiny (0: wyl, 1: - // przyciemnione, 2: pelne) + int iCabLightFlag; // McZapkie:120503: oswietlenie kabiny (0: wyl, 1: przyciemnione, 2: pelne) bool bCabLight; // hunter-091012: czy swiatlo jest zapalone? bool bCabLightDim; // hunter-091012: czy przyciemnienie kabiny jest zapalone? - vector3 pMechSittingPosition; // ABu 180404 - vector3 MirrorPosition(bool lewe); + Math3D::vector3 pMechSittingPosition; // ABu 180404 + Math3D::vector3 MirrorPosition(bool lewe); + glm::vec2 pMechViewAngle { 0.0, 0.0 }; // camera pitch and yaw values, preserved while in external view - private: - // PSound dsbBuzzer; - PSound dsbCouplerStretch; - PSound dsbEN57_CouplerStretch; - PSound dsbBufferClamp; - // TSubModel *smCzuwakShpOn; - // TSubModel *smCzuwakOn; - // TSubModel *smShpOn; - // TSubModel *smCzuwakShpOff; - // double fCzuwakTimer; +private: double fBlinkTimer; float fHaslerTimer; float fConverterTimer; // hunter-261211: dla przekaznika float fMainRelayTimer; // hunter-141211: zalaczanie WSa z opoznieniem float fCzuwakTestTimer; // hunter-091012: do testu czuwaka - float fLightsTimer; // yB 150617: timer do swiatel + float fScreenTimer { 0.f }; - int CAflag; // hunter-131211: dla osobnego zbijania CA i SHP + bool CAflag { false }; // hunter-131211: dla osobnego zbijania CA i SHP - double fPoslizgTimer; - // double fShpTimer; - // double fDblClickTimer; - // ABu: Przeniesione do public. - Wiem, ze to nieladnie... - // bool CabChange(int iDirection); - // bool InitializeCab(int NewCabNo, AnsiString asFileName); - TTrack *tor; - int keybrakecount; // McZapkie-240302 - przyda sie do tachometru - float fTachoVelocity; - float fTachoVelocityJump; // ze skakaniem - float fTachoTimer; - float fTachoCount; - float fHVoltage; // napi?cie dla dynamicznych ga?ek - float fHCurrent[4]; // pr?dy: suma i amperomierze 1,2,3 - float fEngine[4]; // obroty te? trzeba pobra? - int iCarNo, iPowerNo, iUnitNo; // liczba pojazdow, czlonow napednych i jednostek spiętych ze - // sobą + float fTachoVelocity{ 0.0f }; + float fTachoVelocityJump{ 0.0f }; // ze skakaniem + float fTachoTimer{ 0.0f }; + float fTachoCount{ 0.0f }; + float fHVoltage{ 0.0f }; // napi?cie dla dynamicznych ga?ek + float fHCurrent[ 4 ] = { 0.0f, 0.0f, 0.0f, 0.0f }; // pr?dy: suma i amperomierze 1,2,3 + float fEngine[ 4 ] = { 0.0f, 0.0f, 0.0f, 0.0f }; // obroty te? trzeba pobra? + int iCarNo, iPowerNo, iUnitNo; // liczba pojazdow, czlonow napednych i jednostek spiętych ze sobą bool bDoors[20][3]; // drzwi dla wszystkich czlonow int iUnits[20]; // numer jednostki int iDoorNo[20]; // liczba drzwi char cCode[20]; // kod pojazdu + bool bSlip[20]; // poślizg kół pojazdu std::string asCarName[20]; // nazwa czlonu bool bMains[8]; // WSy float fCntVol[8]; // napiecie NN @@ -413,28 +669,23 @@ class TTrain bool bHeat[8]; // grzanie // McZapkie: do syczenia float fPPress, fNPress; - float fSPPress, fSNPress; - int iSekunda; // Ra: sekunda aktualizacji pr?dko?ci - int iRadioChannel; // numer aktualnego kana?u radiowego - TPythonScreens pyScreens; + int iRadioChannel { 1 }; // numer aktualnego kana?u radiowego + std::vector> m_screens; public: float fPress[20][3]; // cisnienia dla wszystkich czlonow + static std::vector const fPress_labels; float fEIMParams[9][10]; // parametry dla silnikow asynchronicznych - int RadioChannel() - { - return iRadioChannel; - }; - inline TDynamicObject *Dynamic() - { - return DynamicObject; - }; - inline TMoverParameters *Controlled() - { - return mvControlled; - }; + int RadioChannel() const { return iRadioChannel; }; + // plays provided sound from position of the radio + void radio_message( sound_source *Message, int const Channel ); + inline TDynamicObject *Dynamic() { return DynamicObject; }; + inline TDynamicObject const *Dynamic() const { return DynamicObject; }; + inline TMoverParameters *Controlled() { return mvControlled; }; + inline TMoverParameters const *Controlled() const { return mvControlled; }; + inline TMoverParameters *Occupied() { return mvOccupied; }; + inline TMoverParameters const *Occupied() const { return mvOccupied; }; void DynamicSet(TDynamicObject *d); - void Silence(); + }; //--------------------------------------------------------------------------- -#endif diff --git a/TrkFoll.cpp b/TrkFoll.cpp index 349fa859..0d828768 100644 --- a/TrkFoll.cpp +++ b/TrkFoll.cpp @@ -15,11 +15,12 @@ http://mozilla.org/MPL/2.0/. #include "stdafx.h" #include "TrkFoll.h" + +#include "simulation.h" #include "Globals.h" +#include "dynobj.h" +#include "driver.h" #include "Logs.h" -#include "Driver.h" -#include "DynObj.h" -#include "Event.h" TTrackFollower::~TTrackFollower() { @@ -71,19 +72,11 @@ TTrack * TTrackFollower::SetCurrentTrack(TTrack *pTrack, int end) } break; } - if (!pTrack) - { // gdy nie ma toru w kierunku jazdy - pTrack = pCurrentTrack->NullCreate( - end); // tworzenie toru wykolejącego na przedłużeniu pCurrentTrack + if (!pTrack) { + // gdy nie ma toru w kierunku jazdy tworzenie toru wykolejącego na przedłużeniu pCurrentTrack + pTrack = pCurrentTrack->NullCreate(end); if (!end) // jeśli dodana od strony zero, to zmiana kierunku fDirection = -fDirection; // wtórna zmiana - // if (pTrack->iCategoryFlag&2) - //{//jeśli samochód, zepsuć na miejscu - // Owner->MoverParameters->V=0; //zatrzymać - // Owner->MoverParameters->Power=0; //ukraść silnik - // Owner->MoverParameters->AccS=0; //wchłonąć moc - // Global::iPause|=1; //zapauzowanie symulacji - //} } else { // najpierw +1, później -1, aby odcinek izolowany wspólny dla tych torów nie wykrył zera @@ -102,72 +95,68 @@ bool TTrackFollower::Move(double fDistance, bool bPrimary) { // przesuwanie wózka po torach o odległość (fDistance), z wyzwoleniem eventów // bPrimary=true - jest pierwszą osią w pojeździe, czyli generuje eventy i przepisuje pojazd // Ra: zwraca false, jeśli pojazd ma być usunięty + auto const ismoving { ( std::abs( fDistance ) > 0.01 ) && ( Owner->GetVelocity() > 0.01 ) }; + int const eventfilter { ( + ( ( true == ismoving ) && ( Owner->ctOwner != nullptr ) ) ? + Owner->ctOwner->Direction() * ( Owner->ctOwner->Vehicle()->DirectionGet() == Owner->DirectionGet() ? 1 : -1 ) * ( fDirection > 0 ? 1 : -1 ) : + 0 ) }; fDistance *= fDirection; // dystans mnożnony przez kierunek double s; // roboczy dystans double dir; // zapamiętany kierunek do sprawdzenia, czy się zmienił bool bCanSkip; // czy przemieścić pojazd na inny tor while (true) // pętla wychodzi, gdy przesunięcie wyjdzie zerowe { // pętla przesuwająca wózek przez kolejne tory, aż do trafienia w jakiś - if (!pCurrentTrack) - return false; // nie ma toru, to nie ma przesuwania - if (pCurrentTrack->iEvents) // sumaryczna informacja o eventach - { // omijamy cały ten blok, gdy tor nie ma on żadnych eventów (większość nie ma) - if (fDistance < 0) - { - if (iSetFlag(iEventFlag, -1)) // zawsze zeruje flagę sprawdzenia, jak mechanik - // dosiądzie, to się nie wykona - if (Owner->Mechanik->Primary()) // tylko dla jednego członu - // if (TestFlag(iEventFlag,1)) //McZapkie-280503: wyzwalanie event tylko dla - // pojazdow z obsada - if (bPrimary && pCurrentTrack->evEvent1 && - (!pCurrentTrack->evEvent1->iQueued)) - Global::AddToQuery(pCurrentTrack->evEvent1, Owner); // dodanie do - // kolejki - // Owner->RaAxleEvent(pCurrentTrack->Event1); //Ra: dynamic zdecyduje, czy dodać do - // kolejki - // if (TestFlag(iEventallFlag,1)) - if (iSetFlag(iEventallFlag, - -1)) // McZapkie-280503: wyzwalanie eventall dla wszystkich pojazdow - if (bPrimary && pCurrentTrack->evEventall1 && - (!pCurrentTrack->evEventall1->iQueued)) - Global::AddToQuery(pCurrentTrack->evEventall1, Owner); // dodanie do kolejki - // Owner->RaAxleEvent(pCurrentTrack->Eventall1); //Ra: dynamic zdecyduje, czy dodać - // do kolejki + if( pCurrentTrack == nullptr ) { return false; } // nie ma toru, to nie ma przesuwania + // TODO: refactor following block as track method + if( pCurrentTrack->m_events ) { // sumaryczna informacja o eventach + // omijamy cały ten blok, gdy tor nie ma on żadnych eventów (większość nie ma) + if( false == ismoving ) { + //McZapkie-140602: wyzwalanie zdarzenia gdy pojazd stoi + if( ( Owner->Mechanik != nullptr ) + && ( Owner->Mechanik->Primary() ) ) { + // tylko dla jednego członu + pCurrentTrack->QueueEvents( pCurrentTrack->m_events0, Owner ); + } + pCurrentTrack->QueueEvents( pCurrentTrack->m_events0all, Owner ); } - else if (fDistance > 0) - { - if (iSetFlag(iEventFlag, -2)) // zawsze ustawia flagę sprawdzenia, jak mechanik - // dosiądzie, to się nie wykona - if (Owner->Mechanik->Primary()) // tylko dla jednego członu - // if (TestFlag(iEventFlag,2)) //sprawdzanie jest od razu w pierwszym - // warunku - if (bPrimary && pCurrentTrack->evEvent2 && - (!pCurrentTrack->evEvent2->iQueued)) - Global::AddToQuery(pCurrentTrack->evEvent2, Owner); - // Owner->RaAxleEvent(pCurrentTrack->Event2); //Ra: dynamic zdecyduje, czy dodać do - // kolejki - // if (TestFlag(iEventallFlag,2)) - if (iSetFlag(iEventallFlag, - -2)) // sprawdza i zeruje na przyszłość, true jeśli zmieni z 2 na 0 - if (bPrimary && pCurrentTrack->evEventall2 && - (!pCurrentTrack->evEventall2->iQueued)) - Global::AddToQuery(pCurrentTrack->evEventall2, Owner); - // Owner->RaAxleEvent(pCurrentTrack->Eventall2); //Ra: dynamic zdecyduje, czy dodać - // do kolejki + else if( (fDistance < 0) && ( eventfilter < 0 ) ) { + // event1, eventall1 + if( SetFlag( iEventFlag, -1 ) ) { + // zawsze zeruje flagę sprawdzenia, jak mechanik dosiądzie, to się nie wykona + if( ( Owner->Mechanik != nullptr ) + && ( Owner->Mechanik->Primary() ) ) { + // tylko dla jednego członu + // McZapkie-280503: wyzwalanie event tylko dla pojazdow z obsada + if( true == bPrimary ) { + pCurrentTrack->QueueEvents( pCurrentTrack->m_events1, Owner ); + } + } + } + if( SetFlag( iEventallFlag, -1 ) ) { + // McZapkie-280503: wyzwalanie eventall dla wszystkich pojazdow + if( true == bPrimary ) { + pCurrentTrack->QueueEvents( pCurrentTrack->m_events1all, Owner ); + } + } } - else // if (fDistance==0) //McZapkie-140602: wyzwalanie zdarzenia gdy pojazd stoi - { - if (Owner->Mechanik->Primary()) // tylko dla jednego członu - if (pCurrentTrack->evEvent0) - if (!pCurrentTrack->evEvent0->iQueued) - Global::AddToQuery(pCurrentTrack->evEvent0, Owner); - // Owner->RaAxleEvent(pCurrentTrack->Event0); //Ra: dynamic zdecyduje, czy dodać do - // kolejki - if (pCurrentTrack->evEventall0) - if (!pCurrentTrack->evEventall0->iQueued) - Global::AddToQuery(pCurrentTrack->evEventall0, Owner); - // Owner->RaAxleEvent(pCurrentTrack->Eventall0); //Ra: dynamic zdecyduje, czy dodać - // do kolejki + else if( ( fDistance > 0 ) && ( eventfilter > 0 ) ) { + // event2, eventall2 + if( SetFlag( iEventFlag, -2 ) ) { + // zawsze ustawia flagę sprawdzenia, jak mechanik dosiądzie, to się nie wykona + if( ( Owner->Mechanik != nullptr ) + && ( Owner->Mechanik->Primary() ) ) { + // tylko dla jednego członu + if( true == bPrimary ) { + pCurrentTrack->QueueEvents( pCurrentTrack->m_events2, Owner ); + } + } + } + if( SetFlag( iEventallFlag, -2 ) ) { + // sprawdza i zeruje na przyszłość, true jeśli zmieni z 2 na 0 + if( true == bPrimary ) { + pCurrentTrack->QueueEvents( pCurrentTrack->m_events2all, Owner ); + } + } } } if (!pCurrentSegment) // jeżeli nie ma powiązanego segmentu toru? @@ -191,18 +180,19 @@ bool TTrackFollower::Move(double fDistance, bool bPrimary) */ if (s < 0) { // jeśli przekroczenie toru od strony Point1 - bCanSkip = bPrimary ? pCurrentTrack->CheckDynamicObject(Owner) : false; - if (bCanSkip) // tylko główna oś przenosi pojazd do innego toru - Owner->MyTrack->RemoveDynamicObject( - Owner); // zdejmujemy pojazd z dotychczasowego toru + bCanSkip = ( bPrimary && pCurrentTrack->CheckDynamicObject( Owner ) ); + if( bCanSkip ) { + // tylko główna oś przenosi pojazd do innego toru + // zdejmujemy pojazd z dotychczasowego toru + Owner->MyTrack->RemoveDynamicObject( Owner ); + } dir = fDirection; if (pCurrentTrack->eType == tt_Cross) { - if (!SetCurrentTrack(pCurrentTrack->Neightbour(iSegment, fDirection), 0)) + if (!SetCurrentTrack(pCurrentTrack->Connected(iSegment, fDirection), 0)) return false; // wyjście z błędem } - else if (!SetCurrentTrack(pCurrentTrack->Neightbour(-1, fDirection), - 0)) // ustawia fDirection + else if (!SetCurrentTrack(pCurrentTrack->Connected(-1, fDirection), 0)) // ustawia fDirection return false; // wyjście z błędem if (dir == fDirection) //(pCurrentTrack->iPrevDirection) { // gdy kierunek bez zmiany (Point1->Point2) @@ -217,8 +207,7 @@ bool TTrackFollower::Move(double fDistance, bool bPrimary) if (bCanSkip) { // jak główna oś, to dodanie pojazdu do nowego toru pCurrentTrack->AddDynamicObject(Owner); - iEventFlag = - 3; // McZapkie-020602: umozliwienie uruchamiania event1,2 po zmianie toru + iEventFlag = 3; // McZapkie-020602: umozliwienie uruchamiania event1,2 po zmianie toru iEventallFlag = 3; // McZapkie-280503: jw, dla eventall1,2 if (!Owner->MyTrack) return false; @@ -227,19 +216,17 @@ bool TTrackFollower::Move(double fDistance, bool bPrimary) } else if (s > pCurrentSegment->GetLength()) { // jeśli przekroczenie toru od strony Point2 - bCanSkip = bPrimary ? pCurrentTrack->CheckDynamicObject(Owner) : false; + bCanSkip = ( bPrimary && pCurrentTrack->CheckDynamicObject( Owner ) ); if (bCanSkip) // tylko główna oś przenosi pojazd do innego toru - Owner->MyTrack->RemoveDynamicObject( - Owner); // zdejmujemy pojazd z dotychczasowego toru + Owner->MyTrack->RemoveDynamicObject(Owner); // zdejmujemy pojazd z dotychczasowego toru fDistance = s - pCurrentSegment->GetLength(); dir = fDirection; if (pCurrentTrack->eType == tt_Cross) { - if (!SetCurrentTrack(pCurrentTrack->Neightbour(iSegment, fDirection), 1)) + if (!SetCurrentTrack(pCurrentTrack->Connected(iSegment, fDirection), 1)) return false; // wyjście z błędem } - else if (!SetCurrentTrack(pCurrentTrack->Neightbour(1, fDirection), - 1)) // ustawia fDirection + else if (!SetCurrentTrack(pCurrentTrack->Connected(1, fDirection), 1)) // ustawia fDirection return false; // wyjście z błędem if (dir != fDirection) //(pCurrentTrack->iNextDirection) { // gdy zmiana kierunku toru (Point2->Point2) @@ -251,8 +238,7 @@ bool TTrackFollower::Move(double fDistance, bool bPrimary) if (bCanSkip) { // jak główna oś, to dodanie pojazdu do nowego toru pCurrentTrack->AddDynamicObject(Owner); - iEventFlag = - 3; // McZapkie-020602: umozliwienie uruchamiania event1,2 po zmianie toru + iEventFlag = 3; // McZapkie-020602: umozliwienie uruchamiania event1,2 po zmianie toru iEventallFlag = 3; if (!Owner->MyTrack) return false; @@ -263,21 +249,15 @@ bool TTrackFollower::Move(double fDistance, bool bPrimary) { // gdy zostaje na tym samym torze (przesuwanie już nie zmienia toru) if (bPrimary) { // tylko gdy początkowe ustawienie, dodajemy eventy stania do kolejki - if (Owner->MoverParameters->ActiveCab != 0) - // if (Owner->MoverParameters->CabNo!=0) - { - if (pCurrentTrack->evEvent1 && pCurrentTrack->evEvent1->fDelay <= -1.0f) - Global::AddToQuery(pCurrentTrack->evEvent1, Owner); - if (pCurrentTrack->evEvent2 && pCurrentTrack->evEvent2->fDelay <= -1.0f) - Global::AddToQuery(pCurrentTrack->evEvent2, Owner); + if (Owner->MoverParameters->ActiveCab != 0) { + + pCurrentTrack->QueueEvents( pCurrentTrack->m_events1, Owner, -1.0 ); + pCurrentTrack->QueueEvents( pCurrentTrack->m_events2, Owner, -1.0 ); } - if (pCurrentTrack->evEventall1 && pCurrentTrack->evEventall1->fDelay <= -1.0f) - Global::AddToQuery(pCurrentTrack->evEventall1, Owner); - if (pCurrentTrack->evEventall2 && pCurrentTrack->evEventall2->fDelay <= -1.0f) - Global::AddToQuery(pCurrentTrack->evEventall2, Owner); + pCurrentTrack->QueueEvents( pCurrentTrack->m_events1all, Owner, -1.0 ); + pCurrentTrack->QueueEvents( pCurrentTrack->m_events2all, Owner, -1.0 ); } fCurrentDistance = s; - // fDistance=0; return ComputatePosition(); // przeliczenie XYZ, true o ile nie wyjechał na NULL } } @@ -303,8 +283,8 @@ bool TTrackFollower::ComputatePosition() return false; } #if RENDER_CONE -#include "opengl/glew.h" -#include "opengl/glut.h" +#include "GL/glew.h" +#include "GL/glut.h" void TTrackFollower::Render(float fNr) { // funkcja rysująca stożek w miejscu osi glPushMatrix(); // matryca kamery diff --git a/TrkFoll.h b/TrkFoll.h index 5400e935..b15a38f7 100644 --- a/TrkFoll.h +++ b/TrkFoll.h @@ -10,52 +10,53 @@ http://mozilla.org/MPL/2.0/. #ifndef TrkFollH #define TrkFollH -#include "Track.h" -#include "McZapkie\MOVER.h" +#include "classes.h" +#include "segment.h" -class TTrackFollower -{ // oś poruszająca się po torze - private: - TTrack *pCurrentTrack = nullptr; // na którym torze siê znajduje - std::shared_ptr pCurrentSegment; // zwrotnice mog¹ mieæ dwa segmenty - double fCurrentDistance = 0.0; // przesuniêcie wzglêdem Point1 w stronê Point2 - double fDirection = 1.0; // ustawienie wzglêdem toru: -1.0 albo 1.0, mno¿one przez dystans // jest przodem do Point2 - bool ComputatePosition(); // przeliczenie pozycji na torze - TDynamicObject *Owner = nullptr; // pojazd posiadający - int iEventFlag = 0; // McZapkie-020602: informacja o tym czy wyzwalac zdarzenie: 0,1,2,3 - int iEventallFlag = 0; - int iSegment = 0; // który segment toru jest używany (żeby nie przeskakiwało po przestawieniu - // zwrotnicy pod taborem) - public: - double fOffsetH = 0.0; // Ra: odległość środka osi od osi toru (dla samochodów) - użyć do wężykowania - vector3 pPosition; // współrzędne XYZ w układzie scenerii - vector3 vAngles; // x:przechyłka, y:pochylenie, z:kierunek w planie (w radianach) +// oś poruszająca się po torze +class TTrackFollower { + +public: +// constructors TTrackFollower() = default; +// destructor ~TTrackFollower(); +// methods TTrack * SetCurrentTrack(TTrack *pTrack, int end); bool Move(double fDistance, bool bPrimary); - inline TTrack * GetTrack() - { - return pCurrentTrack; - }; - inline double GetRoll() - { - return vAngles.x; - }; // przechyłka policzona przy ustalaniu pozycji + inline TTrack * GetTrack() const { + return pCurrentTrack; }; + // przechyłka policzona przy ustalaniu pozycji + inline double GetRoll() { + return vAngles.x; }; //{return pCurrentSegment->GetRoll(fCurrentDistance)*fDirection;}; //zamiast liczyć można pobrać - inline double GetDirection() - { - return fDirection; - }; // zwrot na torze - inline double GetTranslation() - { - return fCurrentDistance; - }; // ABu-030403 + // zwrot na torze + inline double GetDirection() const { + return fDirection; }; + // ABu-030403 + inline double GetTranslation() const { + return fCurrentDistance; }; // inline double GetLength(vector3 p1, vector3 cp1, vector3 cp2, vector3 p2) //{ return pCurrentSegment->ComputeLength(p1,cp1,cp2,p2); }; // inline double GetRadius(double L, double d); //McZapkie-150503 bool Init(TTrack *pTrack, TDynamicObject *NewOwner, double fDir); void Render(float fNr); +// members + double fOffsetH = 0.0; // Ra: odległość środka osi od osi toru (dla samochodów) - użyć do wężykowania + Math3D::vector3 pPosition; // współrzędne XYZ w układzie scenerii + Math3D::vector3 vAngles; // x:przechyłka, y:pochylenie, z:kierunek w planie (w radianach) +private: +// methods + bool ComputatePosition(); // przeliczenie pozycji na torze +// members + TTrack *pCurrentTrack = nullptr; // na którym torze siê znajduje + std::shared_ptr pCurrentSegment; // zwrotnice mog¹ mieæ dwa segmenty + double fCurrentDistance = 0.0; // przesuniêcie wzglêdem Point1 w stronê Point2 + double fDirection = 1.0; // ustawienie wzglêdem toru: -1.0 albo 1.0, mno¿one przez dystans // jest przodem do Point2 + TDynamicObject *Owner = nullptr; // pojazd posiadający + int iEventFlag = 0; // McZapkie-020602: informacja o tym czy wyzwalac zdarzenie: 0,1,2,3 + int iEventallFlag = 0; + int iSegment = 0; // który segment toru jest używany (żeby nie przeskakiwało po przestawieniu zwrotnicy pod taborem) }; //--------------------------------------------------------------------------- #endif diff --git a/VBO.cpp b/VBO.cpp deleted file mode 100644 index 07e8dc01..00000000 --- a/VBO.cpp +++ /dev/null @@ -1,101 +0,0 @@ -/* -This Source Code Form is subject to the -terms of the Mozilla Public License, v. -2.0. If a copy of the MPL was not -distributed with this file, You can -obtain one at -http://mozilla.org/MPL/2.0/. -*/ - -#include "stdafx.h" -#include "VBO.h" -#include "opengl/glew.h" -#include "usefull.h" -//--------------------------------------------------------------------------- - -CMesh::CMesh() -{ // utworzenie pustego obiektu - m_pVNT = nullptr; - m_nVertexCount = -1; - m_nVBOVertices = 0; // nie zarezerwowane -}; - -CMesh::~CMesh() -{ // usuwanie obiektu - Clear(); // zwolnienie zasobów -}; - -void CMesh::MakeArray(int n) -{ // tworzenie tablic - m_nVertexCount = n; - m_pVNT = new CVertNormTex[m_nVertexCount]; // przydzielenie pamięci dla tablicy -}; - -void CMesh::BuildVBOs(bool del) -{ // tworzenie VBO i kasowanie już niepotrzebnych tablic - // pobierz numer VBO oraz ustaw go jako aktywny - glGenBuffers(1, &m_nVBOVertices); // pobierz numer - glBindBuffer(GL_ARRAY_BUFFER, m_nVBOVertices); // ustaw bufor jako aktualny - glBufferData(GL_ARRAY_BUFFER, m_nVertexCount * sizeof(CVertNormTex), m_pVNT, GL_STATIC_DRAW); - // WriteLog("Assigned VBO number "+AnsiString(m_nVBOVertices)+", vertices: - // "+AnsiString(m_nVertexCount)); - if (del) - SafeDeleteArray(m_pVNT); // wierzchołki już się nie przydadzą -}; - -void CMesh::Clear() -{ // niewirtualne zwolnienie zasobów przez sprzątacz albo destruktor - // inna nazwa, żeby nie mieszało się z funkcją wirtualną sprzątacza - if (m_nVBOVertices) // jeśli było coś rezerwowane - { - glDeleteBuffers(1, &m_nVBOVertices); // Free The Memory - // WriteLog("Released VBO number "+AnsiString(m_nVBOVertices)); - } - m_nVBOVertices = 0; - m_nVertexCount = -1; // do ponownego zliczenia - SafeDeleteArray(m_pVNT); // usuwanie tablic, gdy były użyte do Vertex Array -}; - -bool CMesh::StartVBO() -{ // początek rysowania elementów z VBO - if (m_nVertexCount <= 0) - return false; // nie ma nic do rysowania w ten sposób - glEnableClientState(GL_VERTEX_ARRAY); - glEnableClientState(GL_NORMAL_ARRAY); - glEnableClientState(GL_TEXTURE_COORD_ARRAY); - if (m_nVBOVertices) - { - glBindBuffer(GL_ARRAY_BUFFER_ARB, m_nVBOVertices); - glVertexPointer( 3, GL_FLOAT, sizeof(CVertNormTex), static_cast(nullptr) ); // pozycje - glNormalPointer( GL_FLOAT, sizeof( CVertNormTex ), static_cast( nullptr ) + 12 ); // normalne - glTexCoordPointer( 2, GL_FLOAT, sizeof( CVertNormTex ), static_cast( nullptr ) + 24 ); // wierzchołki - } - return true; // można rysować z VBO -}; - -bool CMesh::StartColorVBO() -{ // początek rysowania punktów świecących z VBO - if (m_nVertexCount <= 0) - return false; // nie ma nic do rysowania w ten sposób - glEnableClientState(GL_VERTEX_ARRAY); - glEnableClientState(GL_COLOR_ARRAY); - if (m_nVBOVertices) - { - glBindBuffer(GL_ARRAY_BUFFER, m_nVBOVertices); - glVertexPointer( 3, GL_FLOAT, sizeof( CVertNormTex ), static_cast( nullptr ) ); // pozycje - // glColorPointer(3,GL_UNSIGNED_BYTE,sizeof(CVertNormTex),((char*)NULL)+12); //kolory - glColorPointer( 3, GL_FLOAT, sizeof( CVertNormTex ), static_cast( nullptr ) + 12 ); // kolory - } - return true; // można rysować z VBO -}; - -void CMesh::EndVBO() -{ // koniec użycia VBO - glDisableClientState(GL_VERTEX_ARRAY); - glDisableClientState(GL_NORMAL_ARRAY); - glDisableClientState(GL_TEXTURE_COORD_ARRAY); - glDisableClientState(GL_COLOR_ARRAY); - // glBindBuffer(GL_ARRAY_BUFFER,0); //takie coś psuje, mimo iż polecali użyć - glBindBuffer(GL_ARRAY_BUFFER, 0); - glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0); // Ra: to na przyszłość -}; diff --git a/VBO.h b/VBO.h deleted file mode 100644 index 368563be..00000000 --- a/VBO.h +++ /dev/null @@ -1,42 +0,0 @@ -/* -This Source Code Form is subject to the -terms of the Mozilla Public License, v. -2.0. If a copy of the MPL was not -distributed with this file, You can -obtain one at -http://mozilla.org/MPL/2.0/. -*/ - -#ifndef VBOH -#define VBOH -//--------------------------------------------------------------------------- -class CVertNormTex -{ - public: - float x = 0.0; // X wierzchołka - float y = 0.0; // Y wierzchołka - float z = 0.0; // Z wierzchołka - float nx = 0.0; // X wektora normalnego - float ny = 0.0; // Y wektora normalnego - float nz = 0.0; // Z wektora normalnego - float u = 0.0; // U mapowania - float v = 0.0; // V mapowania -}; - -class CMesh -{ // wsparcie dla VBO - public: - int m_nVertexCount; // liczba wierzchołków - CVertNormTex *m_pVNT; - unsigned int m_nVBOVertices; // numer VBO z wierzchołkami - CMesh(); - ~CMesh(); - void MakeArray(int n); // tworzenie tablicy z elementami VNT - void BuildVBOs(bool del = true); // zamiana tablic na VBO - void Clear(); // zwolnienie zasobów - bool StartVBO(); - void EndVBO(); - bool StartColorVBO(); -}; - -#endif diff --git a/World.cpp b/World.cpp deleted file mode 100644 index c0188625..00000000 --- a/World.cpp +++ /dev/null @@ -1,2943 +0,0 @@ -/* -This Source Code Form is subject to the -terms of the Mozilla Public License, v. -2.0. If a copy of the MPL was not -distributed with this file, You can -obtain one at -http://mozilla.org/MPL/2.0/. -*/ -/* - MaSzyna EU07 locomotive simulator - Copyright (C) 2001-2004 Marcin Wozniak, Maciej Czapkiewicz and others - -*/ - -#include "stdafx.h" -#include "World.h" - -#include "opengl/glew.h" -#include "opengl/glut.h" - -#include "Globals.h" -#include "Logs.h" -#include "MdlMngr.h" -#include "Texture.h" -#include "Timer.h" -#include "mtable.h" -#include "Sound.h" -#include "Camera.h" -#include "ResourceManager.h" -#include "Event.h" -#include "Train.h" -#include "Driver.h" -#include "Console.h" - -#define TEXTURE_FILTER_CONTROL_EXT 0x8500 -#define TEXTURE_LOD_BIAS_EXT 0x8501 -//--------------------------------------------------------------------------- - -typedef void(APIENTRY *FglutBitmapCharacter)(void *font, int character); // typ funkcji -FglutBitmapCharacter glutBitmapCharacterDLL = NULL; // deklaracja zmiennej -HINSTANCE hinstGLUT32 = NULL; // wskaźnik do GLUT32.DLL -// GLUTAPI void APIENTRY glutBitmapCharacterDLL(void *font, int character); -TDynamicObject *Controlled = NULL; // pojazd, który prowadzimy - -const double fTimeMax = 1.00; //[s] maksymalny czas aktualizacji w jednek klatce - -TWorld::TWorld() -{ - // randomize(); - // Randomize(); - Train = NULL; - // Aspect=1; - for (int i = 0; i < 10; ++i) - KeyEvents[i] = NULL; // eventy wyzwalane klawiszami cyfrowymi - Global::iSlowMotion = 0; - // Global::changeDynObj=NULL; - OutText1 = ""; // teksty wyświetlane na ekranie - OutText2 = ""; - OutText3 = ""; - iCheckFPS = 0; // kiedy znów sprawdzić FPS, żeby wyłączać optymalizacji od razu do zera - pDynamicNearest = NULL; - fTimeBuffer = 0.0; // bufor czasu aktualizacji dla stałego kroku fizyki - fMaxDt = 0.01; //[s] początkowy krok czasowy fizyki - fTime50Hz = 0.0; // bufor czasu dla komunikacji z PoKeys -} - -TWorld::~TWorld() -{ - Global::bManageNodes = false; // Ra: wyłączenie wyrejestrowania, bo się sypie - TrainDelete(); - // Ground.Free(); //Ra: usunięcie obiektów przed usunięciem dźwięków - sypie się - TSoundsManager::Free(); - TModelsManager::Free(); - glDeleteLists(base, 96); - if (hinstGLUT32) - FreeLibrary(hinstGLUT32); -} - -void TWorld::TrainDelete(TDynamicObject *d) -{ // usunięcie pojazdu prowadzonego przez użytkownika - if (d) - if (Train) - if (Train->Dynamic() != d) - return; // nie tego usuwać - delete Train; // i nie ma czym sterować - Train = NULL; - Controlled = NULL; // tego też już nie ma - mvControlled = NULL; - Global::pUserDynamic = NULL; // tego też nie ma -}; - -GLvoid TWorld::glPrint(const char *txt) // custom GL "Print" routine -{ // wypisywanie tekstu 2D na ekranie - if (!txt) - return; - if (Global::bGlutFont) - { // tekst generowany przez GLUT - int i, len = strlen(txt); - for (i = 0; i < len; i++) - glutBitmapCharacterDLL(GLUT_BITMAP_8_BY_13, txt[i]); // funkcja linkowana dynamicznie - } - else - { // generowanie przez Display Lists - glPushAttrib(GL_LIST_BIT); // pushes the display list bits - glListBase(base - 32); // sets the base character to 32 - glCallLists(strlen(txt), GL_UNSIGNED_BYTE, txt); // draws the display list text - glPopAttrib(); // pops the display list bits - } -} - -/* Ra: do opracowania: wybor karty graficznej ~Intel gdy są dwie... -BOOL GetDisplayMonitorInfo(int nDeviceIndex, LPSTR lpszMonitorInfo) -{ - FARPROC EnumDisplayDevices; - HINSTANCE hInstUser32; - DISPLAY_DEVICE DispDev; - char szSaveDeviceName[33]; // 32 + 1 for the null-terminator - BOOL bRet = TRUE; - HRESULT hr; - - hInstUser32 = LoadLibrary("c:\\windows\User32.DLL"); - if (!hInstUser32) return FALSE; - - // Get the address of the EnumDisplayDevices function - EnumDisplayDevices = (FARPROC)GetProcAddress(hInstUser32,"EnumDisplayDevicesA"); - if (!EnumDisplayDevices) { - FreeLibrary(hInstUser32); - return FALSE; - } - - ZeroMemory(&DispDev, sizeof(DispDev)); - DispDev.cb = sizeof(DispDev); - - // After the first call to EnumDisplayDevices, - // DispDev.DeviceString is the adapter name - if (EnumDisplayDevices(NULL, nDeviceIndex, &DispDev, 0)) - { - hr = StringCchCopy(szSaveDeviceName, 33, DispDev.DeviceName); - if (FAILED(hr)) - { - // TODO: write error handler - } - - // After second call, DispDev.DeviceString is the - // monitor name for that device - EnumDisplayDevices(szSaveDeviceName, 0, &DispDev, 0); - - // In the following, lpszMonitorInfo must be 128 + 1 for - // the null-terminator. - hr = StringCchCopy(lpszMonitorInfo, 129, DispDev.DeviceString); - if (FAILED(hr)) - { - // TODO: write error handler - } - - } else { - bRet = FALSE; - } - - FreeLibrary(hInstUser32); - - return bRet; -} -*/ - -bool TWorld::Init(HWND NhWnd, HDC hDC) -{ - auto timestart = std::chrono::system_clock::now(); - Global::hWnd = NhWnd; // do WM_COPYDATA - Global::pCamera = &Camera; // Ra: wskaźnik potrzebny do likwidacji drgań - Global::detonatoryOK = true; - WriteLog("Starting MaSzyna rail vehicle simulator."); - WriteLog(Global::asVersion); - if( sizeof( TSubModel ) != 256 ) { - Error( "Wrong sizeof(TSubModel) is " + std::to_string(sizeof( TSubModel )) ); - return false; - } - WriteLog("Online documentation and additional files on http://eu07.pl"); - WriteLog("Authors: Marcin_EU, McZapkie, ABu, Winger, Tolaris, nbmx, OLO_EU, Bart, Quark-t, " - "ShaXbee, Oli_EU, youBy, KURS90, Ra, hunter, szociu, Stele, Q, firleju and others"); - WriteLog("Renderer:"); - WriteLog((char *)glGetString(GL_RENDERER)); - WriteLog("Vendor:"); - // Winger030405: sprawdzanie sterownikow - WriteLog((char *)glGetString(GL_VENDOR)); - std::string glver = ((char *)glGetString(GL_VERSION)); - WriteLog("OpenGL Version:"); - WriteLog(glver); - if ((glver == "1.5.1") || (glver == "1.5.2")) - { - Error("Niekompatybilna wersja openGL - dwuwymiarowy tekst nie bedzie wyswietlany!"); - WriteLog("WARNING! This OpenGL version is not fully compatible with simulator!"); - WriteLog("UWAGA! Ta wersja OpenGL nie jest w pelni kompatybilna z symulatorem!"); - Global::detonatoryOK = false; - } - else - Global::detonatoryOK = true; - // Ra: umieszczone w EU07.cpp jakoś nie chce działać - while( glver.rfind( '.' ) > glver.find( '.' ) ) { - glver = glver.substr( 0, glver.rfind( '.' ) - 1 ); // obcięcie od drugiej kropki - } - double ogl; - try - { - ogl = std::stod( glver ); - } - catch (...) - { - ogl = 0.0; - } - if (Global::fOpenGL > 0.0) // jeśli była wpisane maksymalna wersja w EU07.INI - { - if (ogl > 0.0) // zakładając, że się odczytało dobrze - if (ogl < Global::fOpenGL) // a karta oferuje niższą wersję niż wpisana - Global::fOpenGL = ogl; // to przyjąc to z karty - } - else if (false == GLEW_VERSION_1_3) // sprzętowa deompresja DDS zwykle wymaga 1.3 - Error("Missed OpenGL 1.3+ drivers!"); // błąd np. gdy wersja 1.1, a nie ma wpisu w EU07.INI -/* - Global::bOpenGL_1_5 = (Global::fOpenGL >= 1.5); // są fragmentaryczne animacje VBO -*/ - WriteLog("Supported extensions:"); - WriteLog((char *)glGetString(GL_EXTENSIONS)); - if (GLEW_ARB_vertex_buffer_object) // czy jest VBO w karcie graficznej - { - if( std::string( (char *)glGetString(GL_VENDOR) ).find("Intel") != std::string::npos ) // wymuszenie tylko dla kart Intel - { // karty Intel nie nadają się do grafiki 3D, ale robimy wyjątek, bo to w końcu symulator - Global::iMultisampling = - 0; // to robi problemy na "Intel(R) HD Graphics Family" - czarny ekran - if (Global::fOpenGL >= - 1.4) // 1.4 miało obsługę VBO, ale bez opcji modyfikacji fragmentu bufora - Global::bUseVBO = true; // VBO włączane tylko, jeśli jest obsługa oraz nie ustawiono - // niższego numeru - } - if (Global::bUseVBO) - WriteLog("Ra: The VBO is found and will be used."); - else - WriteLog("Ra: The VBO is found, but Display Lists are selected."); - } - else - { - WriteLog("Ra: No VBO found - Display Lists used. Graphics card too old?"); - Global::bUseVBO = false; // może być włączone parametrem w INI - } - if (Global::bDecompressDDS) // jeśli sprzętowa (domyślnie jest false) - WriteLog("DDS textures support at OpenGL level is disabled in INI file."); - else - { - Global::bDecompressDDS = - !(true == GLEW_EXT_texture_compression_s3tc); // czy obsługiwane? - if (Global::bDecompressDDS) // czy jest obsługa DDS w karcie graficznej - WriteLog("DDS textures are not supported."); - else // brak obsługi DDS - trzeba włączyć programową dekompresję - WriteLog("DDS textures are supported."); - } - if (Global::iMultisampling) - WriteLog("Used multisampling of " + std::to_string(Global::iMultisampling) + " samples."); - { // ograniczenie maksymalnego rozmiaru tekstur - parametr dla skalowania tekstur - GLint i; - glGetIntegerv(GL_MAX_TEXTURE_SIZE, &i); - if (i < Global::iMaxTextureSize) - Global::iMaxTextureSize = i; - WriteLog("Max texture size: " + std::to_string(Global::iMaxTextureSize)); - } - /*-----------------------Render Initialization----------------------*/ - if (Global::fOpenGL >= 1.2) // poniższe nie działa w 1.1 - glTexEnvf(TEXTURE_FILTER_CONTROL_EXT, TEXTURE_LOD_BIAS_EXT, -1); - GLfloat FogColor[] = {1.0f, 1.0f, 1.0f, 1.0f}; - glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix - glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); // Clear screen and depth buffer - glLoadIdentity(); - // WriteLog("glClearColor (FogColor[0], FogColor[1], FogColor[2], 0.0); "); - // glClearColor (1.0, 0.0, 0.0, 0.0); // Background Color - // glClearColor (FogColor[0], FogColor[1], FogColor[2], 0.0); - // Background // Color - glClearColor(Global::Background[0], Global::Background[1], Global::Background[2], 1.0); // Background Color - - WriteLog("glFogfv(GL_FOG_COLOR, FogColor);"); - glFogfv(GL_FOG_COLOR, FogColor); // Set Fog Color - - WriteLog("glClearDepth(1.0f); "); - glClearDepth(1.0f); // ZBuffer Value - - // glEnable(GL_NORMALIZE); - // glEnable(GL_RESCALE_NORMAL); - - // glEnable(GL_CULL_FACE); - WriteLog("glEnable(GL_TEXTURE_2D);"); - glEnable(GL_TEXTURE_2D); // Enable Texture Mapping - WriteLog("glShadeModel(GL_SMOOTH);"); - glShadeModel(GL_SMOOTH); // Enable Smooth Shading - WriteLog("glEnable(GL_DEPTH_TEST);"); - glEnable(GL_DEPTH_TEST); - - // McZapkie:261102-uruchomienie polprzezroczystosci (na razie linie) pod kierunkiem Marcina - // if (Global::bRenderAlpha) //Ra: wywalam tę flagę - { - WriteLog("glEnable(GL_BLEND);"); - glEnable(GL_BLEND); - WriteLog("glEnable(GL_ALPHA_TEST);"); - glEnable(GL_ALPHA_TEST); - WriteLog("glAlphaFunc(GL_GREATER,0.04);"); - glAlphaFunc(GL_GREATER, 0.04); - WriteLog("glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);"); - glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); - WriteLog("glDepthFunc(GL_LEQUAL);"); - glDepthFunc(GL_LEQUAL); - } - /* - else - { - WriteLog("glEnable(GL_ALPHA_TEST);"); - glEnable(GL_ALPHA_TEST); - WriteLog("glAlphaFunc(GL_GREATER,0.5);"); - glAlphaFunc(GL_GREATER,0.5); - WriteLog("glDepthFunc(GL_LEQUAL);"); - glDepthFunc(GL_LEQUAL); - WriteLog("glDisable(GL_BLEND);"); - glDisable(GL_BLEND); - } - */ - /* zakomentowanie to co bylo kiedys mieszane - WriteLog("glEnable(GL_ALPHA_TEST);"); - glEnable(GL_ALPHA_TEST);//glGetIntegerv() - WriteLog("glAlphaFunc(GL_GREATER,0.5);"); - // glAlphaFunc(GL_LESS,0.5); - glAlphaFunc(GL_GREATER,0.5); - // glBlendFunc(GL_SRC_ALPHA,GL_ONE); - WriteLog("glDepthFunc(GL_LEQUAL);"); - glDepthFunc(GL_LEQUAL);//EQUAL); - // The Type Of Depth Testing To Do - // glEnable(GL_BLEND); - // glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA); - */ - - WriteLog("glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST);"); - glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST); // Really Nice Perspective Calculations - - WriteLog("glPolygonMode(GL_FRONT, GL_FILL);"); - glPolygonMode(GL_FRONT, GL_FILL); - WriteLog("glFrontFace(GL_CCW);"); - glFrontFace(GL_CCW); // Counter clock-wise polygons face out - WriteLog("glEnable(GL_CULL_FACE); "); - glEnable(GL_CULL_FACE); // Cull back-facing triangles - WriteLog("glLineWidth(1.0f);"); - glLineWidth(1.0f); - // glLineWidth(2.0f); - WriteLog("glPointSize(2.0f);"); - glPointSize(2.0f); - - // ----------- LIGHTING SETUP ----------- - // Light values and coordinates - - vector3 lp = Normalize(vector3(-500, 500, 200)); - - Global::lightPos[0] = lp.x; - Global::lightPos[1] = lp.y; - Global::lightPos[2] = lp.z; - Global::lightPos[3] = 0.0f; - - // Ra: światła by sensowniej było ustawiać po wczytaniu scenerii - - // Ra: szczątkowe światło rozproszone - żeby było cokolwiek widać w ciemności - WriteLog("glLightModelfv(GL_LIGHT_MODEL_AMBIENT,darkLight);"); - glLightModelfv(GL_LIGHT_MODEL_AMBIENT, Global::darkLight); - - // Ra: światło 0 - główne światło zewnętrzne (Słońce, Księżyc) - WriteLog("glLightfv(GL_LIGHT0,GL_AMBIENT,ambientLight);"); - glLightfv(GL_LIGHT0, GL_AMBIENT, Global::ambientDayLight); - WriteLog("glLightfv(GL_LIGHT0,GL_DIFFUSE,diffuseLight);"); - glLightfv(GL_LIGHT0, GL_DIFFUSE, Global::diffuseDayLight); - WriteLog("glLightfv(GL_LIGHT0,GL_SPECULAR,specularLight);"); - glLightfv(GL_LIGHT0, GL_SPECULAR, Global::specularDayLight); - WriteLog("glLightfv(GL_LIGHT0,GL_POSITION,lightPos);"); - glLightfv(GL_LIGHT0, GL_POSITION, Global::lightPos); - WriteLog("glEnable(GL_LIGHT0);"); - glEnable(GL_LIGHT0); - - // glColor() ma zmieniać kolor wybrany w glColorMaterial() - WriteLog("glEnable(GL_COLOR_MATERIAL);"); - glEnable(GL_COLOR_MATERIAL); - - WriteLog("glColorMaterial(GL_FRONT, GL_AMBIENT_AND_DIFFUSE);"); - glColorMaterial(GL_FRONT, GL_AMBIENT_AND_DIFFUSE); - - // WriteLog("glMaterialfv( GL_FRONT, GL_AMBIENT, whiteLight );"); - // glMaterialfv( GL_FRONT, GL_AMBIENT, Global::whiteLight ); - - WriteLog("glMaterialfv( GL_FRONT, GL_AMBIENT_AND_DIFFUSE, whiteLight );"); - glMaterialfv(GL_FRONT, GL_AMBIENT_AND_DIFFUSE, Global::whiteLight); - - /* - WriteLog("glMaterialfv( GL_FRONT, GL_SPECULAR, noLight );"); - glMaterialfv( GL_FRONT, GL_SPECULAR, Global::noLight ); - */ - - WriteLog("glEnable(GL_LIGHTING);"); - glEnable(GL_LIGHTING); - - WriteLog("glFogi(GL_FOG_MODE, GL_LINEAR);"); - glFogi(GL_FOG_MODE, GL_LINEAR); // Fog Mode - WriteLog("glFogfv(GL_FOG_COLOR, FogColor);"); - glFogfv(GL_FOG_COLOR, FogColor); // Set Fog Color - // glFogf(GL_FOG_DENSITY, 0.594f); // How Dense Will The - //Fog - // Be - // glHint(GL_FOG_HINT, GL_NICEST); // Fog Hint Value - WriteLog("glFogf(GL_FOG_START, 1000.0f);"); - glFogf(GL_FOG_START, 10.0f); // Fog Start Depth - WriteLog("glFogf(GL_FOG_END, 2000.0f);"); - glFogf(GL_FOG_END, 200.0f); // Fog End Depth - WriteLog("glEnable(GL_FOG);"); - glEnable(GL_FOG); // Enables GL_FOG - - // Ra: ustawienia testowe - glHint(GL_LINE_SMOOTH_HINT, GL_NICEST); - glHint(GL_POLYGON_SMOOTH_HINT, GL_NICEST); - - /*--------------------Render Initialization End---------------------*/ - - WriteLog("Font init"); // początek inicjacji fontów 2D - if (Global::bGlutFont) // jeśli wybrano GLUT font, próbujemy zlinkować GLUT32.DLL - { - UINT mode = SetErrorMode(SEM_NOOPENFILEERRORBOX); // aby nie wrzeszczał, że znaleźć nie może - hinstGLUT32 = LoadLibrary(TEXT("GLUT32.DLL")); // get a handle to the DLL module - SetErrorMode(mode); - // If the handle is valid, try to get the function address. - if (hinstGLUT32) - glutBitmapCharacterDLL = - (FglutBitmapCharacter)GetProcAddress(hinstGLUT32, "glutBitmapCharacter"); - else - WriteLog("Missed GLUT32.DLL."); - if (glutBitmapCharacterDLL) - WriteLog("Used font from GLUT32.DLL."); - else - Global::bGlutFont = false; // nie udało się, trzeba spróbować na Display List - } - if (!Global::bGlutFont) - { // jeśli bezGLUTowy font - HFONT font; // Windows Font ID - base = glGenLists(96); // storage for 96 characters - font = CreateFont(-15, // height of font - 0, // width of font - 0, // angle of escapement - 0, // orientation angle - FW_BOLD, // font weight - FALSE, // italic - FALSE, // underline - FALSE, // strikeout - ANSI_CHARSET, // character set identifier - OUT_TT_PRECIS, // output precision - CLIP_DEFAULT_PRECIS, // clipping precision - ANTIALIASED_QUALITY, // output quality - FF_DONTCARE | DEFAULT_PITCH, // family and pitch - "Courier New"); // font name - SelectObject(hDC, font); // selects the font we want - wglUseFontBitmapsA(hDC, 32, 96, base); // builds 96 characters starting at character 32 - WriteLog("Display Lists font used."); //+AnsiString(glGetError()) - } - WriteLog("Font init OK"); //+AnsiString(glGetError()) - - Timer::ResetTimers(); - - hWnd = NhWnd; - glColor4f(1.0f, 3.0f, 3.0f, 0.0f); - // SwapBuffers(hDC); // Swap Buffers (Double Buffering) - // glClear(GL_COLOR_BUFFER_BIT); - // glFlush(); - - SetForegroundWindow(hWnd); - WriteLog("Sound Init"); - - glLoadIdentity(); - // glColor4f(0.3f,0.0f,0.0f,0.0f); - glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); - glTranslatef(0.0f, 0.0f, -0.50f); - // glRasterPos2f(-0.25f, -0.10f); - glDisable(GL_DEPTH_TEST); // Disables depth testing - glColor3f(3.0f, 3.0f, 3.0f); - - auto logo = TextureManager.GetTextureId( "logo", szTexturePath, 6 ); - TextureManager.Bind(logo); // Select our texture - - glBegin(GL_QUADS); // Drawing using triangles - glTexCoord2f(0.0f, 0.0f); - glVertex3f(-0.28f, -0.22f, 0.0f); // bottom left of the texture and quad - glTexCoord2f(1.0f, 0.0f); - glVertex3f(0.28f, -0.22f, 0.0f); // bottom right of the texture and quad - glTexCoord2f(1.0f, 1.0f); - glVertex3f(0.28f, 0.22f, 0.0f); // top right of the texture and quad - glTexCoord2f(0.0f, 1.0f); - glVertex3f(-0.28f, 0.22f, 0.0f); // top left of the texture and quad - glEnd(); - //~logo; Ra: to jest bez sensu zapis - glColor3f(0.0f, 0.0f, 100.0f); - if (Global::detonatoryOK) - { - glRasterPos2f(-0.25f, -0.09f); - glPrint("Uruchamianie / Initializing..."); - glRasterPos2f(-0.25f, -0.10f); - glPrint("Dzwiek / Sound..."); - } - SwapBuffers(hDC); // Swap Buffers (Double Buffering) - - glEnable(GL_LIGHTING); - /*-----------------------Sound Initialization-----------------------*/ - TSoundsManager::Init(hWnd); - // TSoundsManager::LoadSounds( "" ); - /*---------------------Sound Initialization End---------------------*/ - WriteLog("Sound Init OK"); - if (Global::detonatoryOK) - { - glRasterPos2f(-0.25f, -0.11f); - glPrint("OK."); - } - SwapBuffers(hDC); // Swap Buffers (Double Buffering) - - int i; - - Paused = true; - WriteLog("Textures init"); - if (Global::detonatoryOK) - { - glRasterPos2f(-0.25f, -0.12f); - glPrint("Tekstury / Textures..."); - } - SwapBuffers(hDC); // Swap Buffers (Double Buffering) -/* - TTexturesManager.Init(); -*/ - WriteLog("Textures init OK"); - if (Global::detonatoryOK) - { - glRasterPos2f(-0.25f, -0.13f); - glPrint("OK."); - } - SwapBuffers(hDC); // Swap Buffers (Double Buffering) - - WriteLog("Models init"); - if (Global::detonatoryOK) - { - glRasterPos2f(-0.25f, -0.14f); - glPrint("Modele / Models..."); - } - SwapBuffers(hDC); // Swap Buffers (Double Buffering) - // McZapkie: dodalem sciezke zeby mozna bylo definiowac skad brac modele ale to malo eleganckie - // TModelsManager::LoadModels(asModelsPatch); - TModelsManager::Init(); - WriteLog("Models init OK"); - if (Global::detonatoryOK) - { - glRasterPos2f(-0.25f, -0.15f); - glPrint("OK."); - } - SwapBuffers(hDC); // Swap Buffers (Double Buffering) - - WriteLog("Ground init"); - if (Global::detonatoryOK) - { - glRasterPos2f(-0.25f, -0.16f); - glPrint("Sceneria / Scenery (please wait)..."); - } - SwapBuffers(hDC); // Swap Buffers (Double Buffering) - - Ground.Init(Global::SceneryFile, hDC); - // Global::tSinceStart= 0; - Clouds.Init(); - WriteLog("Ground init OK"); - if (Global::detonatoryOK) - { - glRasterPos2f(-0.25f, -0.17f); - glPrint("OK."); - } - SwapBuffers(hDC); // Swap Buffers (Double Buffering) - - // TTrack *Track=Ground.FindGroundNode("train_start",TP_TRACK)->pTrack; - - // Camera.Init(vector3(2700,10,6500),0,M_PI,0); - // Camera.Init(vector3(00,40,000),0,M_PI,0); - // Camera.Init(vector3(1500,5,-4000),0,M_PI,0); - // McZapkie-130302 - coby nie przekompilowywac: - // Camera.Init(Global::pFreeCameraInit,0,M_PI,0); - Camera.Init(Global::pFreeCameraInit[0], Global::pFreeCameraInitAngle[0]); - - char buff[255] = "Player train init: "; - if (Global::detonatoryOK) - { - glRasterPos2f(-0.25f, -0.18f); - glPrint("Przygotowanie kabiny do sterowania..."); - } - SwapBuffers(hDC); // Swap Buffers (Double Buffering) - - strcat(buff, Global::asHumanCtrlVehicle.c_str()); - WriteLog(buff); - TGroundNode *nPlayerTrain = NULL; - if (Global::asHumanCtrlVehicle != "ghostview") - nPlayerTrain = Ground.DynamicFind(Global::asHumanCtrlVehicle); // szukanie w tych z obsadą - if (nPlayerTrain) - { - Train = new TTrain(); - if (Train->Init(nPlayerTrain->DynamicObject)) - { - Controlled = Train->Dynamic(); - mvControlled = Controlled->ControlledFind()->MoverParameters; - Global::pUserDynamic = Controlled; // renerowanie pojazdu względem kabiny - WriteLog("Player train init OK"); - if (Global::detonatoryOK) - { - glRasterPos2f(-0.25f, -0.19f); - glPrint("OK."); - } - FollowView(); - SwapBuffers(hDC); // Swap Buffers (Double Buffering) - } - else - { - Error("Player train init failed!"); - FreeFlyModeFlag = true; // Ra: automatycznie włączone latanie - if (Global::detonatoryOK) - { - glRasterPos2f(-0.25f, -0.20f); - glPrint("Blad inicjalizacji sterowanego pojazdu!"); - } - SwapBuffers(hDC); // Swap Buffers (Double Buffering) - Controlled = NULL; - mvControlled = NULL; - Camera.Type = tp_Free; - } - } - else - { - if (Global::asHumanCtrlVehicle != "ghostview") - { - Error("Player train not exist!"); - if (Global::detonatoryOK) - { - glRasterPos2f(-0.25f, -0.20f); - glPrint("Wybrany pojazd nie istnieje w scenerii!"); - } - } - FreeFlyModeFlag = true; // Ra: automatycznie włączone latanie - SwapBuffers(hDC); // swap buffers (double buffering) - Controlled = NULL; - mvControlled = NULL; - Camera.Type = tp_Free; - } - glEnable(GL_DEPTH_TEST); - // Ground.pTrain=Train; - // if (!Global::bMultiplayer) //na razie włączone - { // eventy aktywowane z klawiatury tylko dla jednego użytkownika - KeyEvents[0] = Ground.FindEvent("keyctrl00"); - KeyEvents[1] = Ground.FindEvent("keyctrl01"); - KeyEvents[2] = Ground.FindEvent("keyctrl02"); - KeyEvents[3] = Ground.FindEvent("keyctrl03"); - KeyEvents[4] = Ground.FindEvent("keyctrl04"); - KeyEvents[5] = Ground.FindEvent("keyctrl05"); - KeyEvents[6] = Ground.FindEvent("keyctrl06"); - KeyEvents[7] = Ground.FindEvent("keyctrl07"); - KeyEvents[8] = Ground.FindEvent("keyctrl08"); - KeyEvents[9] = Ground.FindEvent("keyctrl09"); - } - // glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); //{Texture blends with object - // background} - if (Global::bOldSmudge == true) - light = TextureManager.GetTextureId( "smuga.tga", szTexturePath ); - else - light = TextureManager.GetTextureId( "smuga2.tga", szTexturePath ); - // Camera.Reset(); - Timer::ResetTimers(); - WriteLog( "Load time: " + - std::to_string( std::chrono::duration_cast(( std::chrono::system_clock::now() - timestart )).count() ) - + " seconds"); - if (DebugModeFlag) // w Debugmode automatyczne włączenie AI - if (Train) - if (Train->Dynamic()->Mechanik) - Train->Dynamic()->Mechanik->TakeControl(true); - return true; -}; - -void TWorld::OnKeyDown(int cKey) -{ //(cKey) to kod klawisza, cyfrowe i literowe się zgadzają - // Ra 2014-09: tu by można dodać tabelę konwersji: 256 wirtualnych kodów w kontekście dwóch - // przełączników [Shift] i [Ctrl] - // na każdy kod wirtualny niech przypadają 4 bajty: 2 dla naciśnięcia i 2 dla zwolnienia - // powtórzone 256 razy da 1kB na każdy stan przełączników, łącznie będzie 4kB pierwszej tabeli - // przekodowania - if (!Global::iPause) - { // podczas pauzy klawisze nie działają - std::string info = "Key pressed: ["; - if (Console::Pressed(VK_SHIFT)) - info += "Shift]+["; - if (Console::Pressed(VK_CONTROL)) - info += "Ctrl]+["; - if (cKey > 192) // coś tam jeszcze ciekawego jest? - { - if (cKey < 255) // 255 to [Fn] w laptopach - WriteLog(info + (char)(cKey - 128) + "]"); - } - else if (cKey >= 186) - WriteLog(info + std::string(";=,-./~").substr(cKey - 186, 1) + "]"); - else if (cKey > 123) // coś tam jeszcze ciekawego jest? - WriteLog(info + std::to_string(cKey) + "]"); // numer klawisza - else if (cKey >= 112) // funkcyjne - WriteLog(info + "F" + std::to_string(cKey - 111) + "]"); - else if (cKey >= 96) - WriteLog(info + "Num" + std::string("0123456789*+?-./").substr(cKey - 96, 1) + "]"); - else if (((cKey >= '0') && (cKey <= '9')) || ((cKey >= 'A') && (cKey <= 'Z')) || - (cKey == ' ')) - WriteLog(info + (char)(cKey) + "]"); - else if (cKey == '-') - WriteLog(info + "Insert]"); - else if (cKey == '.') - WriteLog(info + "Delete]"); - else if (cKey == '$') - WriteLog(info + "Home]"); - else if (cKey == '#') - WriteLog(info + "End]"); - else if (cKey > 'Z') //żeby nie logować kursorów - WriteLog(info + std::to_string(cKey) + "]"); // numer klawisza - } - if ((cKey <= '9') ? (cKey >= '0') : false) // klawisze cyfrowe - { - int i = cKey - '0'; // numer klawisza - if (Console::Pressed(VK_SHIFT)) - { // z [Shift] uruchomienie eventu - if (!Global::iPause) // podczas pauzy klawisze nie działają - if (KeyEvents[i]) - Ground.AddToQuery(KeyEvents[i], NULL); - } - else // zapamiętywanie kamery może działać podczas pauzy - if (FreeFlyModeFlag) // w trybie latania można przeskakiwać do ustawionych kamer - if ((Global::iTextMode != VK_F12) && - (Global::iTextMode != VK_F3)) // ograniczamy użycie kamer - { - if ((!Global::pFreeCameraInit[i].x && !Global::pFreeCameraInit[i].y && - !Global::pFreeCameraInit[i].z)) - { // jeśli kamera jest w punkcie zerowym, zapamiętanie współrzędnych i kątów - Global::pFreeCameraInit[i] = Camera.Pos; - Global::pFreeCameraInitAngle[i].x = Camera.Pitch; - Global::pFreeCameraInitAngle[i].y = Camera.Yaw; - Global::pFreeCameraInitAngle[i].z = Camera.Roll; - // logowanie, żeby można było do scenerii przepisać - WriteLog( - "camera " + std::to_string( Global::pFreeCameraInit[i].x ) + " " + - std::to_string(Global::pFreeCameraInit[i].y ) + " " + - std::to_string(Global::pFreeCameraInit[i].z ) + " " + - std::to_string(RadToDeg(Global::pFreeCameraInitAngle[i].x)) + - " " + - std::to_string(RadToDeg(Global::pFreeCameraInitAngle[i].y)) + - " " + - std::to_string(RadToDeg(Global::pFreeCameraInitAngle[i].z)) + - " " + std::to_string(i) + " endcamera"); - } - else // również przeskakiwanie - { // Ra: to z tą kamerą (Camera.Pos i Global::pCameraPosition) jest trochę bez sensu - Global::SetCameraPosition( - Global::pFreeCameraInit[i]); // nowa pozycja dla generowania obiektów - Ground.Silence(Camera.Pos); // wyciszenie wszystkiego z poprzedniej pozycji - Camera.Init(Global::pFreeCameraInit[i], - Global::pFreeCameraInitAngle[i]); // przestawienie - } - } - // będzie jeszcze załączanie sprzęgów z [Ctrl] - } - else if ((cKey >= VK_F1) ? (cKey <= VK_F12) : false) - { - switch (cKey) - { - case VK_F1: // czas i relacja - case VK_F3: - case VK_F5: // przesiadka do innego pojazdu - case VK_F8: // FPS - case VK_F9: // wersja, typ wyświetlania, błędy OpenGL - case VK_F10: - if (Global::iTextMode == cKey) - Global::iTextMode = - (Global::iPause && (cKey != VK_F1) ? VK_F1 : - 0); // wyłączenie napisów, chyba że pauza - else - Global::iTextMode = cKey; - break; - case VK_F2: // parametry pojazdu - if (Global::iTextMode == cKey) // jeśli kolejne naciśnięcie - ++Global::iScreenMode[cKey - VK_F1]; // kolejny ekran - else - { // pierwsze naciśnięcie daje pierwszy (tzn. zerowy) ekran - Global::iTextMode = cKey; - Global::iScreenMode[cKey - VK_F1] = 0; - } - break; - case VK_F12: // coś tam jeszcze - if (Console::Pressed(VK_CONTROL) && Console::Pressed(VK_SHIFT)) - DebugModeFlag = !DebugModeFlag; // taka opcjonalna funkcja, może się czasem przydać - /* //Ra 2F1P: teraz włączanie i wyłączanie klawiszami cyfrowymi po użyciu [F12] - else if (Console::Pressed(VK_SHIFT)) - {//odpalenie logu w razie "W" - if ((Global::iWriteLogEnabled&2)==0) //nie było okienka - {//otwarcie okna - AllocConsole(); - SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),FOREGROUND_GREEN); - } - Global::iWriteLogEnabled|=3; - } */ - else - Global::iTextMode = cKey; - break; - case VK_F4: - InOutKey(); - break; - case VK_F6: - if (DebugModeFlag) - { // przyspieszenie symulacji do testowania scenerii... uwaga na FPS! - // Global::iViewMode=VK_F6; - if (Console::Pressed(VK_CONTROL)) - Global::fTimeSpeed = (Console::Pressed(VK_SHIFT) ? 10.0 : 5.0); - else - Global::fTimeSpeed = (Console::Pressed(VK_SHIFT) ? 2.0 : 1.0); - } - break; - } - // if (cKey!=VK_F4) - return; // nie są przekazywane do pojazdu wcale - } - if (Global::iTextMode == VK_F10) // wyświetlone napisy klawiszem F10 - { // i potwierdzenie - if( cKey == 'Y' ) { - // flaga wyjścia z programu - ::PostQuitMessage( 0 ); -// Global::iTextMode = -1; - } - return; // nie przekazujemy do pociągu - } - else if ((Global::iTextMode == VK_F12) ? (cKey >= '0') && (cKey <= '9') : false) - { // tryb konfiguracji debugmode (przestawianie kamery już wyłączone - if (!Console::Pressed(VK_SHIFT)) // bez [Shift] - { - if (cKey == '1') - Global::iWriteLogEnabled ^= 1; // włącz/wyłącz logowanie do pliku - else if (cKey == '2') - { // włącz/wyłącz okno konsoli - Global::iWriteLogEnabled ^= 2; - if ((Global::iWriteLogEnabled & 2) == 0) // nie było okienka - { // otwarcie okna - AllocConsole(); // jeśli konsola już jest, to zwróci błąd; uwalniać nie ma po - // co, bo się odłączy - SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_GREEN); - } - } - // else if (cKey=='3') Global::iWriteLogEnabled^=4; //wypisywanie nazw torów - } - } - else if (cKey == 3) //[Ctrl]+[Break] - { // hamowanie wszystkich pojazdów w okolicy - if (Controlled->MoverParameters->Radio) - Ground.RadioStop(Camera.Pos); - } - else if (!Global::iPause) //||(cKey==VK_F4)) //podczas pauzy sterownaie nie działa, F4 tak - if (Train) - if (Controlled) - if ((Controlled->Controller == Humandriver) ? true : DebugModeFlag || (cKey == 'Q')) - Train->OnKeyDown(cKey); // przekazanie klawisza do kabiny - if (FreeFlyModeFlag) // aby nie odluźniało wagonu za lokomotywą - { // operacje wykonywane na dowolnym pojeździe, przeniesione tu z kabiny - if (cKey == Global::Keys[k_Releaser]) // odluźniacz - { // działa globalnie, sprawdzić zasięg - TDynamicObject *temp = Global::DynamicNearest(); - if (temp) - { - if (GetAsyncKeyState(VK_CONTROL) < 0) // z ctrl odcinanie - { - temp->MoverParameters->BrakeStatus ^= 128; - } - else if (temp->MoverParameters->BrakeReleaser(1)) - { - // temp->sBrakeAcc-> - // dsbPneumaticRelay->SetVolume(DSBVOLUME_MAX); - // dsbPneumaticRelay->Play(0,0,0); //temp->Position()-Camera.Pos //??? - } - } - } - else if (cKey == Global::Keys[k_Heating]) // Ra: klawisz nie jest najszczęśliwszy - { // zmiana próżny/ładowny; Ra: zabrane z kabiny - TDynamicObject *temp = Global::DynamicNearest(); - if (temp) - { - if (Console::Pressed(VK_SHIFT) ? temp->MoverParameters->IncBrakeMult() : - temp->MoverParameters->DecBrakeMult()) - if (Train) - { // dźwięk oczywiście jest w kabinie - Train->dsbSwitch->SetVolume(DSBVOLUME_MAX); - Train->dsbSwitch->Play(0, 0, 0); - } - } - } - else if (cKey == Global::Keys[k_EndSign]) - { // Ra 2014-07: zabrane z kabiny - TDynamicObject *tmp = Global::CouplerNearest(); // domyślnie wyszukuje do 20m - if (tmp) - { - int CouplNr = (LengthSquared3(tmp->HeadPosition() - Camera.Pos) > - LengthSquared3(tmp->RearPosition() - Camera.Pos) ? - 1 : - -1) * - tmp->DirectionGet(); - if (CouplNr < 0) - CouplNr = 0; // z [-1,1] zrobić [0,1] - int mask, set = 0; // Ra: [Shift]+[Ctrl]+[T] odpala mi jakąś idiotyczną zmianę - // tapety pulpitu :/ - if (GetAsyncKeyState(VK_SHIFT) < 0) // z [Shift] zapalanie - set = mask = 64; // bez [Ctrl] założyć tabliczki - else if (GetAsyncKeyState(VK_CONTROL) < 0) - set = mask = 2 + 32; // z [Ctrl] zapalić światła czerwone - else - mask = 2 + 32 + 64; // wyłączanie ściąga wszystko - if (((tmp->iLights[CouplNr]) & mask) != set) - { - tmp->iLights[CouplNr] = (tmp->iLights[CouplNr] & ~mask) | set; - if (Train) - { // Ra: ten dźwięk z kabiny to przegięcie, ale na razie zostawiam - Train->dsbSwitch->SetVolume(DSBVOLUME_MAX); - Train->dsbSwitch->Play(0, 0, 0); - } - } - } - } - else if (cKey == Global::Keys[k_IncLocalBrakeLevel]) - { // zahamowanie dowolnego pojazdu - TDynamicObject *temp = Global::DynamicNearest(); - if (temp) - { - if (GetAsyncKeyState(VK_CONTROL) < 0) - if ((temp->MoverParameters->LocalBrake == ManualBrake) || - (temp->MoverParameters->MBrake == true)) - temp->MoverParameters->IncManualBrakeLevel(1); - else - ; - else if (temp->MoverParameters->LocalBrake != ManualBrake) - if (temp->MoverParameters->IncLocalBrakeLevelFAST()) - if (Train) - { // dźwięk oczywiście jest w kabinie - Train->dsbPneumaticRelay->SetVolume(-80); - Train->dsbPneumaticRelay->Play(0, 0, 0); - } - } - } - else if (cKey == Global::Keys[k_DecLocalBrakeLevel]) - { // odhamowanie dowolnego pojazdu - TDynamicObject *temp = Global::DynamicNearest(); - if (temp) - { - if (GetAsyncKeyState(VK_CONTROL) < 0) - if ((temp->MoverParameters->LocalBrake == ManualBrake) || - (temp->MoverParameters->MBrake == true)) - temp->MoverParameters->DecManualBrakeLevel(1); - else - ; - else if (temp->MoverParameters->LocalBrake != ManualBrake) - if (temp->MoverParameters->DecLocalBrakeLevelFAST()) - if (Train) - { // dźwięk oczywiście jest w kabinie - Train->dsbPneumaticRelay->SetVolume(-80); - Train->dsbPneumaticRelay->Play(0, 0, 0); - } - } - } - } - // switch (cKey) - //{case 'a': //ignorowanie repetycji - // case 'A': Global::iKeyLast=cKey; break; - // default: Global::iKeyLast=0; - //} -} - -void TWorld::OnKeyUp(int cKey) -{ // zwolnienie klawisza; (cKey) to kod klawisza, cyfrowe i literowe się zgadzają - if (!Global::iPause) // podczas pauzy sterownaie nie działa - if (Train) - if (Controlled) - if ((Controlled->Controller == Humandriver) ? true : DebugModeFlag || (cKey == 'Q')) - Train->OnKeyUp(cKey); // przekazanie zwolnienia klawisza do kabiny -}; - -void TWorld::OnMouseMove(double x, double y) -{ // McZapkie:060503-definicja obracania myszy - Camera.OnCursorMove(x * Global::fMouseXScale, -y * Global::fMouseYScale); -} - -void TWorld::InOutKey() -{ // przełączenie widoku z kabiny na zewnętrzny i odwrotnie - FreeFlyModeFlag = !FreeFlyModeFlag; // zmiana widoku - if (FreeFlyModeFlag) - { // jeżeli poza kabiną, przestawiamy w jej okolicę - OK - Global::pUserDynamic = NULL; // bez renderowania względem kamery - if (Train) - { // Train->Dynamic()->ABuSetModelShake(vector3(0,0,0)); - Train->Silence(); // wyłączenie dźwięków kabiny - Train->Dynamic()->bDisplayCab = false; - DistantView(); - } - } - else - { // jazda w kabinie - if (Train) - { - Global::pUserDynamic = Controlled; // renerowanie względem kamery - Train->Dynamic()->bDisplayCab = true; - Train->Dynamic()->ABuSetModelShake( - vector3(0, 0, 0)); // zerowanie przesunięcia przed powrotem? - // Camera.Stop(); //zatrzymanie ruchu - Train->MechStop(); - FollowView(); // na pozycję mecha - } - else - FreeFlyModeFlag = true; // nadal poza kabiną - } -}; - -void TWorld::DistantView() -{ // ustawienie widoku pojazdu z zewnątrz - if (Controlled) // jest pojazd do prowadzenia? - { // na prowadzony - Camera.Pos = - Controlled->GetPosition() + - (Controlled->MoverParameters->ActiveCab >= 0 ? 30 : -30) * Controlled->VectorFront() + - vector3(0, 5, 0); - Camera.LookAt = Controlled->GetPosition(); - Camera.RaLook(); // jednorazowe przestawienie kamery - } - else if (pDynamicNearest) // jeśli jest pojazd wykryty blisko - { // patrzenie na najbliższy pojazd - Camera.Pos = pDynamicNearest->GetPosition() + - (pDynamicNearest->MoverParameters->ActiveCab >= 0 ? 30 : -30) * - pDynamicNearest->VectorFront() + - vector3(0, 5, 0); - Camera.LookAt = pDynamicNearest->GetPosition(); - Camera.RaLook(); // jednorazowe przestawienie kamery - } -}; - -void TWorld::FollowView(bool wycisz) -{ // ustawienie śledzenia pojazdu - // ABu 180404 powrot mechanika na siedzenie albo w okolicę pojazdu - // if (Console::Pressed(VK_F4)) Global::iViewMode=VK_F4; - // Ra: na zewnątrz wychodzimy w Train.cpp - Camera.Reset(); // likwidacja obrotów - patrzy horyzontalnie na południe - if (Controlled) // jest pojazd do prowadzenia? - { - vector3 camStara = - Camera.Pos; // przestawianie kamery jest bez sensu: do przerobienia na potem - // Controlled->ABuSetModelShake(vector3(0,0,0)); - if (FreeFlyModeFlag) - { // jeżeli poza kabiną, przestawiamy w jej okolicę - OK - if (Train) - Train->Dynamic()->ABuSetModelShake( - vector3(0, 0, 0)); // wyłączenie trzęsienia na siłę? - // Camera.Pos=Train->pMechPosition+Normalize(Train->GetDirection())*20; - DistantView(); // przestawienie kamery - //żeby nie bylo numerów z 'fruwajacym' lokiem - konsekwencja bujania pudła - Global::SetCameraPosition( - Camera.Pos); // tu ustawić nową, bo od niej liczą się odległości - Ground.Silence(camStara); // wyciszenie dźwięków z poprzedniej pozycji - } - else if (Train) - { // korekcja ustawienia w kabinie - OK - vector3 camStara = - Camera.Pos; // przestawianie kamery jest bez sensu: do przerobienia na potem - // Ra: czy to tu jest potrzebne, bo przelicza się kawałek dalej? - Camera.Pos = Train->pMechPosition; // Train.GetPosition1(); - Camera.Roll = atan(Train->pMechShake.x * Train->fMechRoll); // hustanie kamery na boki - Camera.Pitch -= - atan(Train->vMechVelocity.z * Train->fMechPitch); // hustanie kamery przod tyl - if (Train->Dynamic()->MoverParameters->ActiveCab == 0) - Camera.LookAt = Train->pMechPosition + Train->GetDirection(); - else // patrz w strone wlasciwej kabiny - Camera.LookAt = - Train->pMechPosition + - Train->GetDirection() * Train->Dynamic()->MoverParameters->ActiveCab; - Train->pMechOffset.x = Train->pMechSittingPosition.x; - Train->pMechOffset.y = Train->pMechSittingPosition.y; - Train->pMechOffset.z = Train->pMechSittingPosition.z; - Global::SetCameraPosition( - Train->Dynamic() - ->GetPosition()); // tu ustawić nową, bo od niej liczą się odległości - if (wycisz) // trzymanie prawego w kabinie daje marny efekt - Ground.Silence(camStara); // wyciszenie dźwięków z poprzedniej pozycji - } - } - else - DistantView(); -}; - -bool TWorld::Update() -{ -#ifdef USE_SCENERY_MOVING - vector3 tmpvector = Global::GetCameraPosition(); - tmpvector = vector3(-int(tmpvector.x) + int(tmpvector.x) % 10000, - -int(tmpvector.y) + int(tmpvector.y) % 10000, - -int(tmpvector.z) + int(tmpvector.z) % 10000); - if (tmpvector.x || tmpvector.y || tmpvector.z) - { - WriteLog("Moving scenery"); - Ground.MoveGroundNode(tmpvector); - WriteLog("Scenery moved"); - }; -#endif - if (iCheckFPS) - --iCheckFPS; - else - { // jak doszło do zera, to sprawdzamy wydajność - if (Timer::GetFPS() < Global::fFpsMin) - { - Global::iSegmentsRendered -= - Random(10); // floor(0.5+Global::iSegmentsRendered/Global::fRadiusFactor); - if (Global::iSegmentsRendered < 10) // jeśli jest co zmniejszać - Global::iSegmentsRendered = 10; // 10=minimalny promień to 600m - } - else if (Timer::GetFPS() > Global::fFpsMax) // jeśli jest dużo FPS - if (Global::iSegmentsRendered < Global::iFpsRadiusMax) // jeśli jest co zwiększać - { - Global::iSegmentsRendered += - Random(5); // floor(0.5+Global::iSegmentsRendered*Global::fRadiusFactor); - if (Global::iSegmentsRendered > Global::iFpsRadiusMax) // 5.6km (22*22*M_PI) - Global::iSegmentsRendered = Global::iFpsRadiusMax; - } - if ((Timer::GetFPS() < 12) && (Global::iSlowMotion < 7)) - { - Global::iSlowMotion = (Global::iSlowMotion << 1) + 1; // zapalenie kolejnego bitu - if (Global::iSlowMotionMask & 1) - if (Global::iMultisampling) // a multisampling jest włączony - glDisable(GL_MULTISAMPLE); // wyłączenie multisamplingu powinno poprawić FPS - } - else if ((Timer::GetFPS() > 20) && Global::iSlowMotion) - { // FPS się zwiększył, można włączyć bajery - Global::iSlowMotion = (Global::iSlowMotion >> 1); // zgaszenie bitu - if (Global::iSlowMotion == 0) // jeśli jest pełna prędkość - if (Global::iMultisampling) // a multisampling jest włączony - glEnable(GL_MULTISAMPLE); - } - /* - if (!Global::bPause) - if (GetFPS()<=5) - {//zwiększenie kroku fizyki przy słabym FPS - if (fMaxDt<0.05) - {fMaxDt=0.05; //Ra: tak nie może być, bo są problemy na sprzęgach - WriteLog("Phisics step switched to 0.05s!"); - } - } - else if (GetFPS()>12) - if (fMaxDt>0.01) - {//powrót do podstawowego kroku fizyki - fMaxDt=0.01; - WriteLog("Phisics step switched to 0.01s!"); - } - */ - iCheckFPS = 0.25 * Timer::GetFPS(); // tak za 0.25 sekundy sprawdzić ponownie (jeszcze przycina?) - } - Timer::UpdateTimers(Global::iPause); - if (!Global::iPause) - { // jak pauza, to nie ma po co tego przeliczać - GlobalTime->UpdateMTableTime(Timer::GetDeltaTime()); // McZapkie-300302: czas rozkladowy - // Ra 2014-07: przeliczenie kąta czasu (do animacji zależnych od czasu) - Global::fTimeAngleDeg = - GlobalTime->hh * 15.0 + GlobalTime->mm * 0.25 + GlobalTime->mr / 240.0; - Global::fClockAngleDeg[0] = 36.0 * (int(GlobalTime->mr) % 10); // jednostki sekund - Global::fClockAngleDeg[1] = 36.0 * (int(GlobalTime->mr) / 10); // dziesiątki sekund - Global::fClockAngleDeg[2] = 36.0 * (GlobalTime->mm % 10); // jednostki minut - Global::fClockAngleDeg[3] = 36.0 * (GlobalTime->mm / 10); // dziesiątki minut - Global::fClockAngleDeg[4] = 36.0 * (GlobalTime->hh % 10); // jednostki godzin - Global::fClockAngleDeg[5] = 36.0 * (GlobalTime->hh / 10); // dziesiątki godzin - - Update_Lights(); - } // koniec działań niewykonywanych podczas pauzy - // poprzednie jakoś tam działało - double dt = Timer::GetDeltaRenderTime(); // nie uwzględnia pauzowania ani mnożenia czasu - fTime50Hz += - dt; // w pauzie też trzeba zliczać czas, bo przy dużym FPS będzie problem z odczytem ramek - if (fTime50Hz >= 0.2) - Console::Update(); // to i tak trzeba wywoływać - dt = Timer::GetDeltaTime(); // 0.0 gdy pauza - fTimeBuffer += dt; //[s] dodanie czasu od poprzedniej ramki - if (fTimeBuffer >= fMaxDt) // jest co najmniej jeden krok; normalnie 0.01s - { // Ra: czas dla fizyki jest skwantowany - fizykę lepiej przeliczać stałym krokiem - // tak można np. moc silników itp., ale ruch musi być przeliczany w każdej klatce, bo - // inaczej skacze - Global::tranTexts.Update(); // obiekt obsługujący stenogramy dźwięków na ekranie - Console::Update(); // obsługa cykli PoKeys (np. aktualizacja wyjść analogowych) - double iter = - ceil(fTimeBuffer / fMaxDt); // ile kroków się zmieściło od ostatniego sprawdzania? - int n = int(iter); // ile kroków jako int - fTimeBuffer -= iter * fMaxDt; // reszta czasu na potem (do bufora) - if (n > 20) - n = 20; // Ra: jeżeli FPS jest zatrważająco niski, to fizyka nie może zająć całkowicie -// procesora -#if 0 - Ground.UpdatePhys(fMaxDt,n); //Ra: teraz czas kroku jest (względnie) stały - if (DebugModeFlag) - if (Global::bActive) //nie przyspieszać, gdy jedzie w tle :) - if (GetAsyncKeyState(VK_ESCAPE)<0) - {//yB dodał przyspieszacz fizyki - Ground.UpdatePhys(fMaxDt,n); - Ground.UpdatePhys(fMaxDt,n); - Ground.UpdatePhys(fMaxDt,n); - Ground.UpdatePhys(fMaxDt,n); //w sumie 5 razy - } -#endif - } - // awaria PoKeys mogła włączyć pauzę - przekazać informację - if (Global::iMultiplayer) // dajemy znać do serwera o wykonaniu - if (iPause != Global::iPause) - { // przesłanie informacji o pauzie do programu nadzorującego - Ground.WyslijParam(5, 3); // ramka 5 z czasem i stanem zapauzowania - iPause = Global::iPause; - } - double iter; - int n = 1; - if (dt > fMaxDt) // normalnie 0.01s - { - iter = ceil(dt / fMaxDt); - n = iter; - dt = dt / iter; // Ra: fizykę lepiej by było przeliczać ze stałym krokiem - if (n > 20) - n = 20; // McZapkie-081103: przesuniecie granicy FPS z 10 na 5 - } - // else n=1; - // blablabla - // Ground.UpdatePhys(dt,n); //na razie tu //2014-12: yB przeniósł do Ground.Update() :( - Ground.Update(dt, n); // tu zrobić tylko coklatkową aktualizację przesunięć - if (DebugModeFlag) - if (Global::bActive) // nie przyspieszać, gdy jedzie w tle :) - if (GetAsyncKeyState(VK_ESCAPE) < 0) - { // yB dodał przyspieszacz fizyki - Ground.Update(dt, n); - Ground.Update(dt, n); - Ground.Update(dt, n); - Ground.Update(dt, n); // 5 razy - } - - dt = Timer::GetDeltaTime(); // czas niekwantowany - - Update_Camera( dt ); - - Ground.CheckQuery(); - - if( Train != nullptr ) { - TSubModel::iInstance = reinterpret_cast( Train->Dynamic() ); - Train->Update( dt ); - } - else { - TSubModel::iInstance = 0; - } - - // przy 0.25 smuga gaśnie o 6:37 w Quarku, a mogłaby już 5:40 - // Ra 2014-12: przy 0.15 się skarżyli, że nie widać smug => zmieniłem na 0.25 - // changed light activation threshold to 0.5, paired with strength reduction in daylight - if (Train) // jeśli nie usunięty - Global::bSmudge = - ( FreeFlyModeFlag ? - false : - ( Train->Dynamic()->fShade <= 0.0 ? - (Global::fLuminance <= 0.5) : - (Train->Dynamic()->fShade * Global::fLuminance <= 0.5) ) ); - - if (!Render()) - return false; - - return (true); -}; - -void -TWorld::Update_Camera( double const Deltatime ) { - - // Console::Update(); //tu jest zależne od FPS, co nie jest korzystne - if( Global::bActive ) { // obsługa ruchu kamery tylko gdy okno jest aktywne - if( Console::Pressed( VK_LBUTTON ) ) { - Camera.Reset(); // likwidacja obrotów - patrzy horyzontalnie na południe - // if (!FreeFlyModeFlag) //jeśli wewnątrz - patrzymy do tyłu - // Camera.LookAt=Train->pMechPosition-Normalize(Train->GetDirection())*10; - if( Controlled ? LengthSquared3( Controlled->GetPosition() - Camera.Pos ) < 2250000 : - false ) // gdy bliżej niż 1.5km - Camera.LookAt = Controlled->GetPosition(); - else { - TDynamicObject *d = - Ground.DynamicNearest( Camera.Pos, 300 ); // szukaj w promieniu 300m - if( !d ) - d = Ground.DynamicNearest( Camera.Pos, - 1000 ); // dalej szukanie, jesli bliżej nie ma - if( d && pDynamicNearest ) // jeśli jakiś jest znaleziony wcześniej - if( 100.0 * LengthSquared3( d->GetPosition() - Camera.Pos ) > - LengthSquared3( pDynamicNearest->GetPosition() - Camera.Pos ) ) - d = pDynamicNearest; // jeśli najbliższy nie jest 10 razy bliżej niż - // poprzedni najbliższy, zostaje poprzedni - if( d ) - pDynamicNearest = d; // zmiana na nowy, jeśli coś znaleziony niepusty - if( pDynamicNearest ) - Camera.LookAt = pDynamicNearest->GetPosition(); - } - if( FreeFlyModeFlag ) - Camera.RaLook(); // jednorazowe przestawienie kamery - } - else if( Console::Pressed( VK_RBUTTON ) ) //||Console::Pressed(VK_F4)) - FollowView( false ); // bez wyciszania dźwięków -/* - else if( Global::iTextMode == -1 ) { // tu mozna dodac dopisywanie do logu przebiegu lokomotywy - WriteLog( "Number of textures used: " + std::to_string( Global::iTextures ) ); - return false; - } -*/ - Camera.Update(); // uwzględnienie ruchu wywołanego klawiszami - } // koniec bloku pomijanego przy nieaktywnym oknie - - if( Camera.Type == tp_Follow ) { - if( Train ) { // jeśli jazda w kabinie, przeliczyć trzeba parametry kamery - Train->UpdateMechPosition( Deltatime / - Global::fTimeSpeed ); // ograniczyć telepanie po przyspieszeniu - vector3 tempangle; - double modelrotate; - tempangle = - Controlled->VectorFront() * ( Controlled->MoverParameters->ActiveCab == -1 ? -1 : 1 ); - modelrotate = atan2( -tempangle.x, tempangle.z ); - if( Console::Pressed( VK_CONTROL ) ? ( Console::Pressed( Global::Keys[ k_MechLeft ] ) || - Console::Pressed( Global::Keys[ k_MechRight ] ) ) : - false ) { // jeśli lusterko lewe albo prawe (bez rzucania na razie) - bool lr = Console::Pressed( Global::Keys[ k_MechLeft ] ); -#if 0 - Camera.Pos = Train->MirrorPosition( lr ); //robocza wartość - if( Controlled->MoverParameters->ActiveCab<0 ) lr = !lr; //w drugiej kabinie odwrotnie jest środek - Camera.LookAt = Controlled->GetPosition() + vector3( lr ? 2.0 : -2.0, Camera.Pos.y, 0 ); //trochę na zewnątrz, użyć szerokości pojazdu - //Camera.LookAt=Train->pMechPosition+Train->GetDirection()*Train->Dynamic()->MoverParameters->ActiveCab; - Camera.Pos += Controlled->GetPosition(); - //Camera.RaLook(); //jednorazowe przestawienie kamery - Camera.Yaw = 0; //odchylenie na bok od Camera.LookAt -#else - // Camera.Yaw powinno być wyzerowane, aby po powrocie patrzeć do przodu - Camera.Pos = - Controlled->GetPosition() + Train->MirrorPosition( lr ); // pozycja lusterka - Camera.Yaw = 0; // odchylenie na bok od Camera.LookAt - if( Train->Dynamic()->MoverParameters->ActiveCab == 0 ) - Camera.LookAt = Camera.Pos - Train->GetDirection(); // gdy w korytarzu - else if( Console::Pressed( VK_SHIFT ) ) { // patrzenie w bok przez szybę - Camera.LookAt = Camera.Pos - - ( lr ? -1 : 1 ) * Train->Dynamic()->VectorLeft() * - Train->Dynamic()->MoverParameters->ActiveCab; - Global::SetCameraRotation( -modelrotate ); - } - else { // patrzenie w kierunku osi pojazdu, z uwzględnieniem kabiny - jakby z lusterka, - // ale bez odbicia - Camera.LookAt = Camera.Pos - - Train->GetDirection() * - Train->Dynamic()->MoverParameters->ActiveCab; //-1 albo 1 - Global::SetCameraRotation( M_PI - - modelrotate ); // tu już trzeba uwzględnić lusterka - } -#endif - Camera.Roll = - atan( Train->pMechShake.x * Train->fMechRoll ); // hustanie kamery na boki - Camera.Pitch = - atan( Train->vMechVelocity.z * Train->fMechPitch ); // hustanie kamery przod tyl - Camera.vUp = Controlled->VectorUp(); - } - else { // patrzenie standardowe - Camera.Pos = Train->pMechPosition; // Train.GetPosition1(); - if( !Global::iPause ) { // podczas pauzy nie przeliczać kątów przypadkowymi wartościami - Camera.Roll = - atan( Train->pMechShake.x * Train->fMechRoll ); // hustanie kamery na boki - Camera.Pitch -= atan( Train->vMechVelocity.z * - Train->fMechPitch ); // hustanie kamery przod tyl //Ra: tu - // jest uciekanie kamery w górę!!! - } - // ABu011104: rzucanie pudlem - vector3 temp; - if( abs( Train->pMechShake.y ) < 0.25 ) - temp = vector3( 0, 0, 6 * Train->pMechShake.y ); - else if( ( Train->pMechShake.y ) > 0 ) - temp = vector3( 0, 0, 6 * 0.25 ); - else - temp = vector3( 0, 0, -6 * 0.25 ); - if( Controlled ) - Controlled->ABuSetModelShake( temp ); - // ABu: koniec rzucania - - if( Train->Dynamic()->MoverParameters->ActiveCab == 0 ) - Camera.LookAt = Train->pMechPosition + Train->GetDirection(); // gdy w korytarzu - else // patrzenie w kierunku osi pojazdu, z uwzględnieniem kabiny - Camera.LookAt = Train->pMechPosition + - Train->GetDirection() * - Train->Dynamic()->MoverParameters->ActiveCab; //-1 albo 1 - Camera.vUp = Train->GetUp(); - Global::SetCameraRotation( Camera.Yaw - - modelrotate ); // tu już trzeba uwzględnić lusterka - } - } - } - else { // kamera nieruchoma - Global::SetCameraRotation( Camera.Yaw - M_PI ); - } -} - -void TWorld::Update_Lights() { - - if( Global::fMoveLight < 0.0 ) { - return; - } - - // double a=Global::fTimeAngleDeg/180.0*M_PI-M_PI; //kąt godzinny w radianach - double a = fmod( Global::fTimeAngleDeg, 360.0 ) / 180.0 * M_PI - - M_PI; // kąt godzinny w radianach - //(a) jest traktowane jako czas miejscowy, nie uwzględniający stref czasowych ani czasu - // letniego - // aby wyznaczyć strefę czasową, trzeba uwzględnić południk miejscowy - // aby uwzględnić czas letni, trzeba sprawdzić dzień roku - double L = Global::fLatitudeDeg / 180.0 * M_PI; // szerokość geograficzna - double H = asin( cos( L ) * cos( Global::fSunDeclination ) * cos( a ) + - sin( L ) * sin( Global::fSunDeclination ) ); // kąt ponad horyzontem - // double A=asin(cos(d)*sin(M_PI-a)/cos(H)); - // Declination=((0.322003-22.971*cos(t)-0.357898*cos(2*t)-0.14398*cos(3*t)+3.94638*sin(t)+0.019334*sin(2*t)+0.05928*sin(3*t)))*Pi/180 - // Altitude=asin(sin(Declination)*sin(latitude)+cos(Declination)*cos(latitude)*cos((15*(time-12))*(Pi/180))); - // Azimuth=(acos((cos(latitude)*sin(Declination)-cos(Declination)*sin(latitude)*cos((15*(time-12))*(Pi/180)))/cos(Altitude))); - // double A=acos(cos(L)*sin(d)-cos(d)*sin(L)*cos(M_PI-a)/cos(H)); - // dAzimuth = atan2(-sin( dHourAngle ),tan( dDeclination )*dCos_Latitude - - // dSin_Latitude*dCos_HourAngle ); - double A = atan2( sin( a ), tan( Global::fSunDeclination ) * cos( L ) - sin( L ) * cos( a ) ); - vector3 lp = vector3( sin( A ), tan( H ), cos( A ) ); - lp = Normalize( lp ); // przeliczenie na wektor długości 1.0 - Global::lightPos[ 0 ] = (float)lp.x; - Global::lightPos[ 1 ] = (float)lp.y; - Global::lightPos[ 2 ] = (float)lp.z; - glLightfv( GL_LIGHT0, GL_POSITION, Global::lightPos ); // daylight position - if( H > 0 ) { // słońce ponad horyzontem - Global::ambientDayLight[ 0 ] = Global::ambientLight[ 0 ]; - Global::ambientDayLight[ 1 ] = Global::ambientLight[ 1 ]; - Global::ambientDayLight[ 2 ] = Global::ambientLight[ 2 ]; - if( H > 0.02 ) // ponad 1.146° zaczynają się cienie - { - Global::diffuseDayLight[ 0 ] = - Global::diffuseLight[ 0 ]; // od wschodu do zachodu maksimum ??? - Global::diffuseDayLight[ 1 ] = Global::diffuseLight[ 1 ]; - Global::diffuseDayLight[ 2 ] = Global::diffuseLight[ 2 ]; - Global::specularDayLight[ 0 ] = Global::specularLight[ 0 ]; // podobnie specular - Global::specularDayLight[ 1 ] = Global::specularLight[ 1 ]; - Global::specularDayLight[ 2 ] = Global::specularLight[ 2 ]; - } - else { - Global::diffuseDayLight[ 0 ] = - 50 * H * Global::diffuseLight[ 0 ]; // wschód albo zachód - Global::diffuseDayLight[ 1 ] = 50 * H * Global::diffuseLight[ 1 ]; - Global::diffuseDayLight[ 2 ] = 50 * H * Global::diffuseLight[ 2 ]; - Global::specularDayLight[ 0 ] = - 50 * H * Global::specularLight[ 0 ]; // podobnie specular - Global::specularDayLight[ 1 ] = 50 * H * Global::specularLight[ 1 ]; - Global::specularDayLight[ 2 ] = 50 * H * Global::specularLight[ 2 ]; - } - } - else { // słońce pod horyzontem - GLfloat lum = 3.1831 * ( H > -0.314159 ? 0.314159 + H : - 0.0 ); // po zachodzie ambient się ściemnia - Global::ambientDayLight[ 0 ] = lum * Global::ambientLight[ 0 ]; - Global::ambientDayLight[ 1 ] = lum * Global::ambientLight[ 1 ]; - Global::ambientDayLight[ 2 ] = lum * Global::ambientLight[ 2 ]; - Global::diffuseDayLight[ 0 ] = - Global::noLight[ 0 ]; // od zachodu do wschodu nie ma diffuse - Global::diffuseDayLight[ 1 ] = Global::noLight[ 1 ]; - Global::diffuseDayLight[ 2 ] = Global::noLight[ 2 ]; - Global::specularDayLight[ 0 ] = Global::noLight[ 0 ]; // ani specular - Global::specularDayLight[ 1 ] = Global::noLight[ 1 ]; - Global::specularDayLight[ 2 ] = Global::noLight[ 2 ]; - } - // Calculate sky colour according to time of day. - // GLfloat sin_t = sin(PI * time_of_day / 12.0); - // back_red = 0.3 * (1.0 - sin_t); - // back_green = 0.9 * sin_t; - // back_blue = sin_t + 0.4, 1.0; - // aktualizacja świateł - glLightfv( GL_LIGHT0, GL_AMBIENT, Global::ambientDayLight ); - glLightfv( GL_LIGHT0, GL_DIFFUSE, Global::diffuseDayLight ); - glLightfv( GL_LIGHT0, GL_SPECULAR, Global::specularDayLight ); - - Global::fLuminance = // to posłuży również do zapalania latarń - +0.150 * ( Global::diffuseDayLight[ 0 ] + Global::ambientDayLight[ 0 ] ) // R - + 0.295 * ( Global::diffuseDayLight[ 1 ] + Global::ambientDayLight[ 1 ] ) // G - + 0.055 * ( Global::diffuseDayLight[ 2 ] + Global::ambientDayLight[ 2 ] ); // B - - vector3 sky = vector3( Global::AtmoColor[ 0 ], Global::AtmoColor[ 1 ], Global::AtmoColor[ 2 ] ); - if( Global::fLuminance < 0.25 ) { // przyspieszenie zachodu/wschodu - sky *= 4.0 * Global::fLuminance; // nocny kolor nieba - GLfloat fog[ 3 ]; - fog[ 0 ] = Global::FogColor[ 0 ] * 4.0 * Global::fLuminance; - fog[ 1 ] = Global::FogColor[ 1 ] * 4.0 * Global::fLuminance; - fog[ 2 ] = Global::FogColor[ 2 ] * 4.0 * Global::fLuminance; - glFogfv( GL_FOG_COLOR, fog ); // nocny kolor mgły - } - else { - glFogfv( GL_FOG_COLOR, Global::FogColor ); // kolor mgły - } - glClearColor( sky.x, sky.y, sky.z, 0.0 ); // kolor nieba -} - -bool TWorld::Render() -{ - glColor3b(255, 255, 255); - // glColor3b(255, 0, 255); - glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); - glDepthFunc( GL_LEQUAL ); - glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix - glLoadIdentity(); - Camera.SetMatrix(); // ustawienie macierzy kamery względem początku scenerii - glLightfv(GL_LIGHT0, GL_POSITION, Global::lightPos); - - if (!Global::bWireFrame) - { // bez nieba w trybie rysowania linii - glDisable(GL_FOG); - Clouds.Render(); - glEnable(GL_FOG); - } - if (Global::bUseVBO) - { // renderowanie przez VBO - if (!Ground.RenderVBO(Camera.Pos)) - return false; - if (!Ground.RenderAlphaVBO(Camera.Pos)) - return false; - } - else - { // renderowanie przez Display List - if (!Ground.RenderDL(Camera.Pos)) - return false; - if (!Ground.RenderAlphaDL(Camera.Pos)) - return false; - } -/* - TSubModel::iInstance = (int)(Train ? Train->Dynamic() : 0); //żeby nie robić cudzych animacji - // if (Camera.Type==tp_Follow) - if (Train) - Train->Update(); -*/ - Render_Cab(); - Render_UI(); - -// glFlush(); - // Global::bReCompile=false; //Ra: już zrobiona rekompilacja - ResourceManager::Sweep( Timer::GetSimulationTime() ); - - return true; -}; - -// rendering kabiny gdy jest oddzielnym modelem i ma byc wyswietlana -void -TWorld::Render_Cab() { - - if( Train == nullptr ) { - - TSubModel::iInstance = 0; - return; - } - - TDynamicObject *dynamic = Train->Dynamic(); - TSubModel::iInstance = reinterpret_cast( dynamic ); - - if( ( true == FreeFlyModeFlag ) - || ( false == dynamic->bDisplayCab ) - || ( dynamic->mdKabina == dynamic->mdModel ) ) { - // ABu: Rendering kabiny jako ostatniej, zeby bylo widac przez szyby, tylko w widoku ze srodka - return; - } -/* - // ABu: Rendering kabiny jako ostatniej, zeby bylo widac przez szyby, tylko w widoku ze srodka - if( ( Train->Dynamic()->mdKabina != Train->Dynamic()->mdModel ) && - Train->Dynamic()->bDisplayCab && !FreeFlyModeFlag ) { -*/ - glPushMatrix(); - vector3 pos = dynamic->GetPosition(); // wszpółrzędne pojazdu z kabiną - // glTranslatef(pos.x,pos.y,pos.z); //przesunięcie o wektor (tak było i trzęsło) - // aby pozbyć się choć trochę trzęsienia, trzeba by nie przeliczać kabiny do punktu - // zerowego scenerii - glLoadIdentity(); // zacząć od macierzy jedynkowej - Camera.SetCabMatrix( pos ); // widok z kamery po przesunięciu - glMultMatrixd( dynamic->mMatrix.getArray() ); // ta macierz nie ma przesunięcia - - //*yB: moje smuuugi 1 - if( Global::bSmudge ) { // Ra: uwzględniłem zacienienie pojazdu przy zapalaniu smug - // 1. warunek na smugę wyznaczyc wcześniej - // 2. jeśli smuga włączona, nie renderować pojazdu użytkownika w DynObj - // 3. jeśli smuga właczona, wyrenderować pojazd użytkownia po dodaniu smugi do sceny - auto const &frontlights = Train->Controlled()->iLights[ 0 ]; - float frontlightstrength = 0.f + - ( ( frontlights & 1 ) ? 0.3f : 0.f ) + - ( ( frontlights & 4 ) ? 0.3f : 0.f ) + - ( ( frontlights & 16 ) ? 0.3f : 0.f ); - frontlightstrength = std::max( frontlightstrength - Global::fLuminance, 0.0 ); - auto const &rearlights = Train->Controlled()->iLights[ 1 ]; - float rearlightstrength = 0.f + - ( ( rearlights & 1 ) ? 0.3f : 0.f ) + - ( ( rearlights & 4 ) ? 0.3f : 0.f ) + - ( ( rearlights & 16 ) ? 0.3f : 0.f ); - rearlightstrength = std::max( rearlightstrength - Global::fLuminance, 0.0 ); - - if( ( Train->Controlled()->Battery ) // trochę na skróty z tą baterią - && ( ( frontlightstrength > 0.f ) - || ( rearlightstrength > 0.f ) ) ) { - - if( Global::bOldSmudge == true ) { - glBlendFunc( GL_SRC_ALPHA, GL_ONE ); - // glBlendFunc(GL_ONE_MINUS_DST_COLOR, GL_DST_COLOR); - // glBlendFunc(GL_SRC_ALPHA_SATURATE,GL_ONE); - glDisable( GL_DEPTH_TEST ); - glDisable( GL_LIGHTING ); - glDisable( GL_FOG ); - TextureManager.Bind( light ); // Select our texture - glBegin( GL_QUADS ); - float fSmudge = - dynamic->MoverParameters->DimHalf.y + 7; // gdzie zaczynać smugę - if( frontlightstrength > 0.f ) { // wystarczy jeden zapalony z przodu - glColor4f( 1.0f, 1.0f, 1.0f, 0.5f * frontlightstrength ); - glTexCoord2f( 0, 0 ); - glVertex3f( 15.0, 0.0, +fSmudge ); // rysowanie względem położenia modelu - glTexCoord2f( 1, 0 ); - glVertex3f( -15.0, 0.0, +fSmudge ); - glTexCoord2f( 1, 1 ); - glVertex3f( -15.0, 2.5, 250.0 ); - glTexCoord2f( 0, 1 ); - glVertex3f( 15.0, 2.5, 250.0 ); - } - if( rearlightstrength > 0.f ) { // wystarczy jeden zapalony z tyłu - glColor4f( 1.0f, 1.0f, 1.0f, 0.5f * rearlightstrength ); - glTexCoord2f( 0, 0 ); - glVertex3f( -15.0, 0.0, -fSmudge ); - glTexCoord2f( 1, 0 ); - glVertex3f( 15.0, 0.0, -fSmudge ); - glTexCoord2f( 1, 1 ); - glVertex3f( 15.0, 2.5, -250.0 ); - glTexCoord2f( 0, 1 ); - glVertex3f( -15.0, 2.5, -250.0 ); - } - glEnd(); - - glBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA ); - glEnable( GL_DEPTH_TEST ); - // glEnable(GL_LIGHTING); //i tak się włączy potem - glEnable( GL_FOG ); - } - else { - - glBlendFunc( GL_DST_COLOR, GL_ONE ); - glDepthFunc( GL_GEQUAL ); - glAlphaFunc( GL_GREATER, 0.004 ); - // glDisable(GL_DEPTH_TEST); - glDisable( GL_LIGHTING ); - glDisable( GL_FOG ); - //glColor4f(0.15f, 0.15f, 0.15f, 0.25f); - TextureManager.Bind( light ); // Select our texture - //float ddl = (0.15*Global::diffuseDayLight[0]+0.295*Global::diffuseDayLight[1]+0.055*Global::diffuseDayLight[2]); //0.24:0 - glBegin( GL_QUADS ); - float fSmudge = dynamic->MoverParameters->DimHalf.y + 7; // gdzie zaczynać smugę - if( frontlightstrength > 0.f ) { // wystarczy jeden zapalony z przodu - - for( int i = 15; i <= 35; i++ ) { - float z = i * i * i * 0.01f;//25/4; - //float C = (36 - i*0.5)*0.005*(1.5 - sqrt(ddl)); - float C = ( 36 - i*0.5 )*0.005*sqrt( ( 1 / sqrt( Global::fLuminance + 0.015 ) ) - 1 ) * frontlightstrength; - glColor4f( C, C, C, 0.35f );// *frontlightstrength ); - glTexCoord2f( 0, 0 ); glVertex3f( -10 / 2 - 2 * i / 4, 6.0 + 0.3*z, 13 + 1.7*z / 3 ); - glTexCoord2f( 1, 0 ); glVertex3f( 10 / 2 + 2 * i / 4, 6.0 + 0.3*z, 13 + 1.7*z / 3 ); - glTexCoord2f( 1, 1 ); glVertex3f( 10 / 2 + 2 * i / 4, -5.0 - 0.5*z, 13 + 1.7*z / 3 ); - glTexCoord2f( 0, 1 ); glVertex3f( -10 / 2 - 2 * i / 4, -5.0 - 0.5*z, 13 + 1.7*z / 3 ); - } - } - if( rearlightstrength > 0.f ) { // wystarczy jeden zapalony z tyłu - for( int i = 15; i <= 35; i++ ) { - float z = i * i * i * 0.01f;//25/4; - float C = ( 36 - i*0.5 )*0.005*sqrt( ( 1 / sqrt( Global::fLuminance + 0.015 ) ) - 1 ) * rearlightstrength; - glColor4f( C, C, C, 0.35f );// *rearlightstrength ); - glTexCoord2f( 0, 0 ); glVertex3f( 10 / 2 + 2 * i / 4, 6.0 + 0.3*z, -13 - 1.7*z / 3 ); - glTexCoord2f( 1, 0 ); glVertex3f( -10 / 2 - 2 * i / 4, 6.0 + 0.3*z, -13 - 1.7*z / 3 ); - glTexCoord2f( 1, 1 ); glVertex3f( -10 / 2 - 2 * i / 4, -5.0 - 0.5*z, -13 - 1.7*z / 3 ); - glTexCoord2f( 0, 1 ); glVertex3f( 10 / 2 + 2 * i / 4, -5.0 - 0.5*z, -13 - 1.7*z / 3 ); - } - } - glEnd(); - - glBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA ); - // glEnable(GL_DEPTH_TEST); - glAlphaFunc( GL_GREATER, 0.04 ); - glDepthFunc( GL_LEQUAL ); - glEnable( GL_LIGHTING ); //i tak się włączy potem - glEnable( GL_FOG ); - } - } - glEnable( GL_LIGHTING ); // po renderowaniu smugi jest to wyłączone - // Ra: pojazd użytkownika należało by renderować po smudze, aby go nie rozświetlała - Global::bSmudge = false; // aby model użytkownika się teraz wyrenderował - dynamic->Render(); - dynamic->RenderAlpha(); // przezroczyste fragmenty pojazdów na torach - } // yB: moje smuuugi 1 - koniec*/ - else - glEnable( GL_LIGHTING ); // po renderowaniu drutów może być to wyłączone - - if( dynamic->mdKabina ) // bo mogła zniknąć przy przechodzeniu do innego pojazdu - { // oswietlenie kabiny - GLfloat ambientCabLight[ 4 ] = { 0.5f, 0.5f, 0.5f, 1.0f }; - GLfloat diffuseCabLight[ 4 ] = { 0.5f, 0.5f, 0.5f, 1.0f }; - GLfloat specularCabLight[ 4 ] = { 0.5f, 0.5f, 0.5f, 1.0f }; - for( int li = 0; li < 3; li++ ) { // przyciemnienie standardowe - ambientCabLight[ li ] = Global::ambientDayLight[ li ] * 0.9; - diffuseCabLight[ li ] = Global::diffuseDayLight[ li ] * 0.5; - specularCabLight[ li ] = Global::specularDayLight[ li ] * 0.5; - } - switch( dynamic->MyTrack->eEnvironment ) { // wpływ świetła zewnętrznego - case e_canyon: - { - for( int li = 0; li < 3; li++ ) { - diffuseCabLight[ li ] *= 0.6; - specularCabLight[ li ] *= 0.7; - } - } - break; - case e_tunnel: - { - for( int li = 0; li < 3; li++ ) { - ambientCabLight[ li ] *= 0.3; - diffuseCabLight[ li ] *= 0.1; - specularCabLight[ li ] *= 0.2; - } - } - break; - } - switch( Train->iCabLightFlag ) // Ra: uzeleżnic od napięcia w obwodzie sterowania - { // hunter-091012: uzaleznienie jasnosci od przetwornicy - case 0: //światło wewnętrzne zgaszone - break; - case 1: //światło wewnętrzne przygaszone (255 216 176) - if( dynamic->MoverParameters->ConverterFlag == - true ) // jasnosc dla zalaczonej przetwornicy - { - ambientCabLight[ 0 ] = Max0R( 0.700, ambientCabLight[ 0 ] ) * 0.75; // R - ambientCabLight[ 1 ] = Max0R( 0.593, ambientCabLight[ 1 ] ) * 0.75; // G - ambientCabLight[ 2 ] = Max0R( 0.483, ambientCabLight[ 2 ] ) * 0.75; // B - - for( int i = 0; i < 3; i++ ) - if( ambientCabLight[ i ] <= ( Global::ambientDayLight[ i ] * 0.9 ) ) - ambientCabLight[ i ] = Global::ambientDayLight[ i ] * 0.9; - } - else { - ambientCabLight[ 0 ] = Max0R( 0.700, ambientCabLight[ 0 ] ) * 0.375; // R - ambientCabLight[ 1 ] = Max0R( 0.593, ambientCabLight[ 1 ] ) * 0.375; // G - ambientCabLight[ 2 ] = Max0R( 0.483, ambientCabLight[ 2 ] ) * 0.375; // B - - for( int i = 0; i < 3; i++ ) - if( ambientCabLight[ i ] <= ( Global::ambientDayLight[ i ] * 0.9 ) ) - ambientCabLight[ i ] = Global::ambientDayLight[ i ] * 0.9; - } - break; - case 2: //światło wewnętrzne zapalone (255 216 176) - if( dynamic->MoverParameters->ConverterFlag == - true ) // jasnosc dla zalaczonej przetwornicy - { - ambientCabLight[ 0 ] = Max0R( 1.000, ambientCabLight[ 0 ] ); // R - ambientCabLight[ 1 ] = Max0R( 0.847, ambientCabLight[ 1 ] ); // G - ambientCabLight[ 2 ] = Max0R( 0.690, ambientCabLight[ 2 ] ); // B - - for( int i = 0; i < 3; i++ ) - if( ambientCabLight[ i ] <= ( Global::ambientDayLight[ i ] * 0.9 ) ) - ambientCabLight[ i ] = Global::ambientDayLight[ i ] * 0.9; - } - else { - ambientCabLight[ 0 ] = Max0R( 1.000, ambientCabLight[ 0 ] ) * 0.5; // R - ambientCabLight[ 1 ] = Max0R( 0.847, ambientCabLight[ 1 ] ) * 0.5; // G - ambientCabLight[ 2 ] = Max0R( 0.690, ambientCabLight[ 2 ] ) * 0.5; // B - - for( int i = 0; i < 3; i++ ) - if( ambientCabLight[ i ] <= ( Global::ambientDayLight[ i ] * 0.9 ) ) - ambientCabLight[ i ] = Global::ambientDayLight[ i ] * 0.9; - } - break; - } - glLightfv( GL_LIGHT0, GL_AMBIENT, ambientCabLight ); - glLightfv( GL_LIGHT0, GL_DIFFUSE, diffuseCabLight ); - glLightfv( GL_LIGHT0, GL_SPECULAR, specularCabLight ); - if( Global::bUseVBO ) { // renderowanie z użyciem VBO - dynamic->mdKabina->RaRender( 0.0, dynamic->ReplacableSkinID, dynamic->iAlpha ); - dynamic->mdKabina->RaRenderAlpha( 0.0, dynamic->ReplacableSkinID, dynamic->iAlpha ); - } - else { // renderowanie z Display List - dynamic->mdKabina->Render( 0.0, dynamic->ReplacableSkinID, dynamic->iAlpha ); - dynamic->mdKabina->RenderAlpha( 0.0, dynamic->ReplacableSkinID, dynamic->iAlpha ); - } - // przywrócenie standardowych, bo zawsze są zmieniane - glLightfv( GL_LIGHT0, GL_AMBIENT, Global::ambientDayLight ); - glLightfv( GL_LIGHT0, GL_DIFFUSE, Global::diffuseDayLight ); - glLightfv( GL_LIGHT0, GL_SPECULAR, Global::specularDayLight ); - } - glPopMatrix(); -} - -void -TWorld::Render_UI() { - - if( DebugModeFlag && !Global::iTextMode ) { - OutText1 = " FPS: "; - OutText1 += to_string( Timer::GetFPS(), 2 ); - OutText1 += Global::iSlowMotion ? "s" : "n"; - - OutText1 += ( Timer::GetDeltaTime() >= 0.2 ) ? "!" : " "; - // if (GetDeltaTime()>=0.2) //Ra: to za bardzo miota tekstem! - // { - // OutText1+= " Slowing Down !!! "; - // } - } - /*if (Console::Pressed(VK_F5)) - {Global::slowmotion=true;}; - if (Console::Pressed(VK_F6)) - {Global::slowmotion=false;};*/ - - if( Global::iTextMode == VK_F8 ) { - Global::iViewMode = VK_F8; - OutText1 = " FPS: "; - OutText1 += to_string( Timer::GetFPS(), 2 ); - //OutText1 += sprintf(); - if( Global::iSlowMotion ) - OutText1 += " (slowmotion " + to_string( Global::iSlowMotion ) + ")"; - OutText1 += ", sectors: "; - OutText1 += to_string( Ground.iRendered ); - } - - // if (Console::Pressed(VK_F7)) - //{ - // OutText1=FloatToStrF(Controlled->MoverParameters->Couplers[0].CouplingFlag,ffFixed,2,0)+", - // "; - // OutText1+=FloatToStrF(Controlled->MoverParameters->Couplers[1].CouplingFlag,ffFixed,2,0); - //} - - /* - if (Console::Pressed(VK_F5)) - { - int line=2; - OutText1="Time: "+FloatToStrF(GlobalTime->hh,ffFixed,2,0)+":" - +FloatToStrF(GlobalTime->mm,ffFixed,2,0)+", "; - OutText1+="distance: "; - OutText1+="34.94"; - OutText2="Next station: "; - OutText2+=FloatToStrF(Controlled->TrainParams->TimeTable[line].km,ffFixed,2,2)+" km, "; - OutText2+=AnsiString(Controlled->TrainParams->TimeTable[line].StationName)+", "; - OutText2+=AnsiString(Controlled->TrainParams->TimeTable[line].StationWare); - OutText3="Arrival: "; - if(Controlled->TrainParams->TimeTable[line].Ah==-1) - { - OutText3+="--:--"; - } - else - { - OutText3+=FloatToStrF(Controlled->TrainParams->TimeTable[line].Ah,ffFixed,2,0)+":"; - OutText3+=FloatToStrF(Controlled->TrainParams->TimeTable[line].Am,ffFixed,2,0)+" "; - } - OutText3+=" Departure: "; - OutText3+=FloatToStrF(Controlled->TrainParams->TimeTable[line].Dh,ffFixed,2,0)+":"; - OutText3+=FloatToStrF(Controlled->TrainParams->TimeTable[line].Dm,ffFixed,2,0)+" "; - }; - // */ - /* - if (Console::Pressed(VK_F6)) - { - //GlobalTime->UpdateMTableTime(100); - //OutText1=FloatToStrF(SquareMagnitude(Global::pCameraPosition-Controlled->GetPosition()),ffFixed,10,0); - //OutText1=FloatToStrF(Global::TnijSzczegoly,ffFixed,7,0)+", "; - //OutText1+=FloatToStrF(dta,ffFixed,2,4)+", "; - OutText1+= FloatToStrF(GetFPS(),ffFixed,6,2); - OutText1+= FloatToStrF(Global::ABuDebug,ffFixed,6,15); - }; - */ - if( Global::changeDynObj ) { // ABu zmiana pojazdu - przejście do innego - // Ra: to nie może być tak robione, to zbytnia proteza jest - Train->Silence(); // wyłączenie dźwięków opuszczanej kabiny - if( Train->Dynamic()->Mechanik ) // AI może sobie samo pójść - if( !Train->Dynamic()->Mechanik->AIControllFlag ) // tylko jeśli ręcznie prowadzony - { // jeśli prowadzi AI, to mu nie robimy dywersji! - Train->Dynamic()->MoverParameters->CabDeactivisation(); - Train->Dynamic()->Controller = AIdriver; - // Train->Dynamic()->MoverParameters->SecuritySystem.Status=0; //rozwala CA w EZT - Train->Dynamic()->MoverParameters->ActiveCab = 0; - Train->Dynamic()->MoverParameters->BrakeLevelSet( - Train->Dynamic()->MoverParameters->Handle->GetPos( - bh_NP ) ); //rozwala sterowanie hamulcem GF 04-2016 - Train->Dynamic()->MechInside = false; - } - // int CabNr; - TDynamicObject *temp = Global::changeDynObj; - // CabNr=temp->MoverParameters->ActiveCab; - /* - if (Train->Dynamic()->MoverParameters->ActiveCab==-1) - { - temp=Train->Dynamic()->NextConnected; //pojazd od strony sprzęgu 1 - CabNr=(Train->Dynamic()->NextConnectedNo==0)?1:-1; - } - else - { - temp=Train->Dynamic()->PrevConnected; //pojazd od strony sprzęgu 0 - CabNr=(Train->Dynamic()->PrevConnectedNo==0)?1:-1; - } - */ - Train->Dynamic()->bDisplayCab = false; - Train->Dynamic()->ABuSetModelShake( vector3( 0, 0, 0 ) ); - /// Train->Dynamic()->MoverParameters->LimPipePress=-1; - /// Train->Dynamic()->MoverParameters->ActFlowSpeed=0; - /// Train->Dynamic()->Mechanik->CloseLog(); - /// SafeDelete(Train->Dynamic()->Mechanik); - - // Train->Dynamic()->mdKabina=NULL; - if( Train->Dynamic()->Mechanik ) // AI może sobie samo pójść - if( !Train->Dynamic()->Mechanik->AIControllFlag ) // tylko jeśli ręcznie prowadzony - Train->Dynamic()->Mechanik->MoveTo( temp ); // przsunięcie obiektu zarządzającego - // Train->DynamicObject=NULL; - Train->DynamicSet( temp ); - Controlled = temp; - mvControlled = Controlled->ControlledFind()->MoverParameters; - Global::asHumanCtrlVehicle = Train->Dynamic()->GetName(); - if( Train->Dynamic()->Mechanik ) // AI może sobie samo pójść - if( !Train->Dynamic()->Mechanik->AIControllFlag ) // tylko jeśli ręcznie prowadzony - { - Train->Dynamic()->MoverParameters->LimPipePress = - Controlled->MoverParameters->PipePress; - // Train->Dynamic()->MoverParameters->ActFlowSpeed=0; - // Train->Dynamic()->MoverParameters->SecuritySystem.Status=1; - // Train->Dynamic()->MoverParameters->ActiveCab=CabNr; - Train->Dynamic() - ->MoverParameters->CabActivisation(); // załączenie rozrządu (wirtualne kabiny) - Train->Dynamic()->Controller = Humandriver; - Train->Dynamic()->MechInside = true; - // Train->Dynamic()->Mechanik=new - // TController(l,r,Controlled->Controller,&Controlled->MoverParameters,&Controlled->TrainParams,Aggressive); - // Train->InitializeCab(CabNr,Train->Dynamic()->asBaseDir+Train->Dynamic()->MoverParameters->TypeName+".mmd"); - } - Train->InitializeCab( Train->Dynamic()->MoverParameters->CabNo, - Train->Dynamic()->asBaseDir + - Train->Dynamic()->MoverParameters->TypeName + ".mmd" ); - if( !FreeFlyModeFlag ) { - Global::pUserDynamic = Controlled; // renerowanie względem kamery - Train->Dynamic()->bDisplayCab = true; - Train->Dynamic()->ABuSetModelShake( - vector3( 0, 0, 0 ) ); // zerowanie przesunięcia przed powrotem? - Train->MechStop(); - FollowView(); // na pozycję mecha - } - Global::changeDynObj = NULL; - } - - glDepthFunc( GL_ALWAYS ); - glDisable( GL_LIGHTING ); - if( Controlled ) - SetWindowText( hWnd, Controlled->MoverParameters->Name.c_str() ); - else - SetWindowText( hWnd, Global::SceneryFile.c_str() ); // nazwa scenerii - TextureManager.Bind( 0 ); - glColor4f( 1.0f, 0.0f, 0.0f, 1.0f ); - glLoadIdentity(); - glTranslatef( 0.0f, 0.0f, -0.50f ); - - if( Global::iTextMode == VK_F1 ) { // tekst pokazywany po wciśnięciu [F1] - // Global::iViewMode=VK_F1; - glColor3f( 1.0f, 1.0f, 1.0f ); // a, damy białym - OutText1 = - "Time: " - + to_string( (int)GlobalTime->hh ) + ":" - + ( GlobalTime->mm < 10 ? "0" : "" ) + to_string( GlobalTime->mm ) + ":" - + ( GlobalTime->mr < 10 ? "0" : "" ) + to_string( std::floor( GlobalTime->mr ) ); - if( Global::iPause ) - OutText1 += " - paused"; - if( Controlled ) - if( Controlled->Mechanik ) { - OutText2 = Controlled->Mechanik->Relation(); - if( !OutText2.empty() ) // jeśli jest podana relacja, to dodajemy punkt następnego - // zatrzymania - OutText2 = - Global::Bezogonkow( OutText2 + ": -> " + Controlled->Mechanik->NextStop(), - true ); // dopisanie punktu zatrzymania - } - // double CtrlPos=mvControlled->MainCtrlPos; - // double CtrlPosNo=mvControlled->MainCtrlPosNo; - // OutText2="defrot="+FloatToStrF(1+0.4*(CtrlPos/CtrlPosNo),ffFixed,2,5); - OutText3 = ""; // Pomoc w sterowaniu - [F9]"; - // OutText3=AnsiString(Global::pCameraRotationDeg); //kąt kamery względem północy - } - else if( Global::iTextMode == VK_F12 ) { // opcje włączenia i wyłączenia logowania - OutText1 = "[0] Debugmode " + std::string( DebugModeFlag ? "(on)" : "(off)" ); - OutText2 = "[1] log.txt " + std::string( ( Global::iWriteLogEnabled & 1 ) ? "(on)" : "(off)" ); - OutText3 = "[2] Console " + std::string( ( Global::iWriteLogEnabled & 2 ) ? "(on)" : "(off)" ); - } - else if( Global::iTextMode == VK_F2 ) { // ABu: info dla najblizszego pojazdu! - TDynamicObject *tmp = FreeFlyModeFlag ? Ground.DynamicNearest( Camera.Pos ) : - Controlled; // w trybie latania lokalizujemy wg mapy - if( tmp ) { - if( Global::iScreenMode[ Global::iTextMode - VK_F1 ] == 0 ) { // jeśli domyślny ekran po pierwszym naciśnięciu - OutText3 = ""; - OutText1 = "Vehicle name: " + tmp->MoverParameters->Name; - // yB OutText1+="; d: "+FloatToStrF(tmp->ABuGetDirection(),ffFixed,2,0); - // OutText1=FloatToStrF(tmp->MoverParameters->Couplers[0].CouplingFlag,ffFixed,3,2)+", - // "; - // OutText1+=FloatToStrF(tmp->MoverParameters->Couplers[1].CouplingFlag,ffFixed,3,2); - if( tmp->Mechanik ) // jeśli jest prowadzący - { // ostatnia komenda dla AI - OutText1 += ", command: " + tmp->Mechanik->OrderCurrent(); - } - else if( tmp->ctOwner ) - OutText1 += ", owned by " + tmp->ctOwner->OwnerName(); - if( !tmp->MoverParameters->CommandLast.empty() ) - OutText1 += ", put: " + tmp->MoverParameters->CommandLast; - // OutText1+="; Cab="+AnsiString(tmp->MoverParameters->CabNo); - OutText2 = "Damage status: " + - tmp->MoverParameters->EngineDescription( 0 ); //+" Engine status: "; - OutText2 += "; Brake delay: "; - if( ( tmp->MoverParameters->BrakeDelayFlag & bdelay_G ) == bdelay_G ) - OutText2 += "G"; - if( ( tmp->MoverParameters->BrakeDelayFlag & bdelay_P ) == bdelay_P ) - OutText2 += "P"; - if( ( tmp->MoverParameters->BrakeDelayFlag & bdelay_R ) == bdelay_R ) - OutText2 += "R"; - if( ( tmp->MoverParameters->BrakeDelayFlag & bdelay_M ) == bdelay_M ) - OutText2 += "+Mg"; - OutText2 += ", BTP:" + - to_string( tmp->MoverParameters->LoadFlag, 0 ); - // if ((tmp->MoverParameters->EnginePowerSource.SourceType==CurrentCollector) || - // (tmp->MoverParameters->TrainType==dt_EZT)) - { - OutText2 += "; pant. " + - to_string( tmp->MoverParameters->PantPress, 2 ); - OutText2 += ( tmp->MoverParameters->bPantKurek3 ? "MoverParameters->u,ffFixed,3,3); - // OutText2+=AnsiString(", - // N:")+FloatToStrF(tmp->MoverParameters->Ntotal,ffFixed,4,0); - OutText2 += ", MED:" + - to_string( tmp->MoverParameters->LocalBrakePosA, 2 ); - OutText2 += "+" + - to_string( tmp->MoverParameters->AnPos, 2 ); - OutText2 += ", Ft:" + - to_string( tmp->MoverParameters->Ft * 0.001f, 0 ); - OutText2 += ", HV0:" + - to_string( tmp->MoverParameters->HVCouplers[ 0 ][ 1 ], 0 ); - OutText2 += "@" + - to_string( tmp->MoverParameters->HVCouplers[ 0 ][ 0 ], 0 ); - OutText2 += "+HV1:" + - to_string( tmp->MoverParameters->HVCouplers[ 1 ][ 1 ], 0 ); - OutText2 += "@" + - to_string( tmp->MoverParameters->HVCouplers[ 1 ][ 0 ], 0 ); - OutText2 += " TC:" + - to_string( tmp->MoverParameters->TotalCurrent, 0 ); - // OutText3= AnsiString("BP: - // ")+FloatToStrF(tmp->MoverParameters->BrakePress,ffFixed,5,2)+AnsiString(", - // "); - // OutText3+= AnsiString("PP: - // ")+FloatToStrF(tmp->MoverParameters->PipePress,ffFixed,5,2)+AnsiString(", - // "); - // OutText3+= AnsiString("BVP: - // ")+FloatToStrF(tmp->MoverParameters->Volume,ffFixed,5,3)+AnsiString(", - // "); - // OutText3+= - // FloatToStrF(tmp->MoverParameters->CntrlPipePress,ffFixed,5,3)+AnsiString(", - // "); - // OutText3+= - // FloatToStrF(tmp->MoverParameters->Hamulec->GetCRP(),ffFixed,5,3)+AnsiString(", - // "); - // OutText3+= - // FloatToStrF(tmp->MoverParameters->BrakeStatus,ffFixed,5,0)+AnsiString(", - // "); - // OutText3+= AnsiString("HP: - // ")+FloatToStrF(tmp->MoverParameters->ScndPipePress,ffFixed,5,2)+AnsiString(". - // "); - // OutText2+= - // FloatToStrF(tmp->MoverParameters->CompressorPower,ffFixed,5,0)+AnsiString(", - // "); - // yB if(tmp->MoverParameters->BrakeSubsystem==Knorr) OutText2+=" Knorr"; - // yB if(tmp->MoverParameters->BrakeSubsystem==Oerlikon) OutText2+=" Oerlikon"; - // yB if(tmp->MoverParameters->BrakeSubsystem==Hik) OutText2+=" Hik"; - // yB if(tmp->MoverParameters->BrakeSubsystem==WeLu) OutText2+=" Łestinghałs"; - // OutText2= " GetFirst: - // "+AnsiString(tmp->GetFirstDynamic(1)->MoverParameters->Name)+" Damage - // status="+tmp->MoverParameters->EngineDescription(0)+" Engine status: "; - // OutText2+= " GetLast: - // "+AnsiString(tmp->GetLastDynamic(1)->MoverParameters->Name)+" Damage - // status="+tmp->MoverParameters->EngineDescription(0)+" Engine status: "; - OutText3 = ( "BP: " ) + - to_string( tmp->MoverParameters->BrakePress, 2 ) + - ( ", " ); - OutText3 += to_string( tmp->MoverParameters->BrakeStatus, 0 ) + - ( ", " ); - OutText3 += ( "PP: " ) + - to_string( tmp->MoverParameters->PipePress, 2 ) + - ( "/" ); - OutText3 += to_string( tmp->MoverParameters->ScndPipePress, 2 ) + - ( "/" ); - OutText3 += to_string( tmp->MoverParameters->EqvtPipePress, 2 ) + - ( ", " ); - OutText3 += ( "BVP: " ) + - to_string( tmp->MoverParameters->Volume, 3 ) + - ( ", " ); - OutText3 += to_string( tmp->MoverParameters->CntrlPipePress, 3 ) + - ( ", " ); - OutText3 += to_string( tmp->MoverParameters->Hamulec->GetCRP(), 3 ) + - ( ", " ); - OutText3 += to_string( tmp->MoverParameters->BrakeStatus, 0 ) + - ( ", " ); - // OutText3+=AnsiString("BVP: - // ")+FloatToStrF(tmp->MoverParameters->BrakeVP(),ffFixed,5,2)+AnsiString(", - // "); - - // OutText3+=FloatToStrF(tmp->MoverParameters->CntrlPipePress,ffFixed,5,2)+AnsiString(", - // "); - // OutText3+=FloatToStrF(tmp->MoverParameters->HighPipePress,ffFixed,5,2)+AnsiString(", - // "); - // OutText3+=FloatToStrF(tmp->MoverParameters->LowPipePress,ffFixed,5,2)+AnsiString(", - // "); - - if( tmp->MoverParameters->ManualBrakePos > 0 ) - OutText3 += ( "manual brake active. " ); - else if( tmp->MoverParameters->LocalBrakePos > 0 ) - OutText3 += ( "local brake active. " ); - else - OutText3 += ( "local brake inactive. " ); - /* - //OutText3+=AnsiString("LSwTim: - ")+FloatToStrF(tmp->MoverParameters->LastSwitchingTime,ffFixed,5,2); - //OutText3+=AnsiString(" Physic: - ")+FloatToStrF(tmp->MoverParameters->PhysicActivation,ffFixed,5,2); - //OutText3+=AnsiString(" ESF: - ")+FloatToStrF(tmp->MoverParameters->EndSignalsFlag,ffFixed,5,0); - OutText3+=AnsiString(" dPAngF: ")+FloatToStrF(tmp->dPantAngleF,ffFixed,5,0); - OutText3+=AnsiString(" dPAngFT: - ")+FloatToStrF(-(tmp->PantTraction1*28.9-136.938),ffFixed,5,0); - if (tmp->lastcabf==1) - { - OutText3+=AnsiString(" pcabc1: - ")+FloatToStrF(tmp->MoverParameters->PantFrontUp,ffFixed,5,0); - OutText3+=AnsiString(" pcabc2: - ")+FloatToStrF(tmp->MoverParameters->PantRearUp,ffFixed,5,0); - } - if (tmp->lastcabf==-1) - { - OutText3+=AnsiString(" pcabc1: - ")+FloatToStrF(tmp->MoverParameters->PantRearUp,ffFixed,5,0); - OutText3+=AnsiString(" pcabc2: - ")+FloatToStrF(tmp->MoverParameters->PantFrontUp,ffFixed,5,0); - } - */ - OutText4 = ""; - if( tmp->Mechanik ) { // o ile jest ktoś w środku - // OutText4=tmp->Mechanik->StopReasonText(); - // if (!OutText4.IsEmpty()) OutText4+="; "; //aby ładniejszy odstęp był - // if (Controlled->Mechanik && (Controlled->Mechanik->AIControllFlag==AIdriver)) - std::string flags = "bwaccmlshhhoibsgvdp; "; // flagi AI (definicja w Driver.h) - for( int i = 0, j = 1; i < 19; ++i, j <<= 1 ) - if( tmp->Mechanik->DrivigFlags() & j ) // jak bit ustawiony - flags[ i + 1 ] = std::toupper( flags[ i + 1 ] ); // ^= 0x20; // to zmiana na wielką literę - OutText4 = flags; - OutText4 += - ( "Driver: Vd=" ) + - to_string( tmp->Mechanik->VelDesired, 0 ) + ( " ad=" ) + - to_string( tmp->Mechanik->AccDesired, 2 ) + ( " Pd=" ) + - to_string( tmp->Mechanik->ActualProximityDist, 0 ) + - ( " Vn=" ) + to_string( tmp->Mechanik->VelNext, 0 ) + - ( " VSm=" ) + to_string( tmp->Mechanik->VelSignalLast, 0 ) + - ( " VLm=" ) + to_string( tmp->Mechanik->VelLimitLast, 0 ) + - ( " VRd=" ) + to_string( tmp->Mechanik->VelRoad, 0 ); - if( tmp->Mechanik->VelNext == 0.0 ) - if( tmp->Mechanik->eSignNext ) { // jeśli ma zapamiętany event semafora - // if (!OutText4.IsEmpty()) OutText4+=", "; //aby ładniejszy odstęp był - OutText4 += " (" + - Global::Bezogonkow( tmp->Mechanik->eSignNext->asName ) + - ")"; // nazwa eventu semafora - } - } - if( !OutText4.empty() ) - OutText4 += "; "; // aby ładniejszy odstęp był - // informacja o sprzęgach nawet bez mechanika - OutText4 += - "C0=" + ( tmp->PrevConnected ? - tmp->PrevConnected->GetName() + ":" + - to_string( tmp->MoverParameters->Couplers[ 0 ].CouplingFlag ) : - std::string( "NULL" ) ); - OutText4 += - " C1=" + ( tmp->NextConnected ? - tmp->NextConnected->GetName() + ":" + - to_string( tmp->MoverParameters->Couplers[ 1 ].CouplingFlag ) : - std::string( "NULL" ) ); - if( Console::Pressed( VK_F2 ) ) { - WriteLog( OutText1 ); - WriteLog( OutText2 ); - WriteLog( OutText3 ); - WriteLog( OutText4 ); - } - } // koniec treści podstawowego ekranu FK_V2 - else { // ekran drugi, czyli tabelka skanowania AI - if( tmp->Mechanik ) //żeby była tabelka, musi być AI - { // tabelka jest na użytek testujących scenerie, więc nie musi być "ładna" - glColor3f( 1.0f, 1.0f, 1.0f ); // a, damy zielony. GF: jednak biały - // glTranslatef(0.0f,0.0f,-0.50f); - glRasterPos2f( -0.25f, 0.20f ); - // OutText1="Scan distance: "+AnsiString(tmp->Mechanik->scanmax)+", back: - // "+AnsiString(tmp->Mechanik->scanback); - OutText1 = "Time: " + to_string( (int)GlobalTime->hh ) + ":"; - int i = GlobalTime->mm; // bo inaczej potrafi zrobić "hh:010" - if( i < 10 ) - OutText1 += "0"; - OutText1 += to_string( i ); // minuty - OutText1 += ":"; - i = floor( GlobalTime->mr ); // bo inaczej potrafi zrobić "hh:mm:010" - if( i < 10 ) - OutText1 += "0"; - OutText1 += to_string( i ); - OutText1 += - ( ". Vel: " ) + to_string( tmp->GetVelocity(), 1 ); - OutText1 += ". Scan table:"; - glPrint( Global::Bezogonkow( OutText1 ).c_str() ); - i = -1; - while( ( OutText1 = tmp->Mechanik->TableText( ++i ) ) != "" ) { // wyświetlenie pozycji z tabelki - glRasterPos2f( -0.25f, 0.19f - 0.01f * i ); - glPrint( Global::Bezogonkow( OutText1 ).c_str() ); - } - // podsumowanie sensu tabelki - OutText4 = - ( "Driver: Vd=" ) + - to_string( tmp->Mechanik->VelDesired, 0 ) + ( " ad=" ) + - to_string( tmp->Mechanik->AccDesired, 2 ) + ( " Pd=" ) + - to_string( tmp->Mechanik->ActualProximityDist, 0 ) + - ( " Vn=" ) + to_string( tmp->Mechanik->VelNext, 0 ) + - ( "\n VSm=" ) + to_string( tmp->Mechanik->VelSignalLast, 0 ) + - ( " VLm=" ) + to_string( tmp->Mechanik->VelLimitLast, 0 ) + - ( " VRd=" ) + to_string( tmp->Mechanik->VelRoad, 0 ) + - ( " VSig=" ) + to_string( tmp->Mechanik->VelSignal, 0 ); - if( tmp->Mechanik->VelNext == 0.0 ) - if( tmp->Mechanik->eSignNext ) { // jeśli ma zapamiętany event semafora - // if (!OutText4.IsEmpty()) OutText4+=", "; //aby ładniejszy odstęp był - OutText4 += " (" + - Global::Bezogonkow( tmp->Mechanik->eSignNext->asName ) + - ")"; // nazwa eventu semafora - } - glRasterPos2f( -0.25f, 0.19f - 0.01f * i ); - glPrint( Global::Bezogonkow( OutText4 ).c_str() ); - } - } // koniec ekanu skanowania - } // koniec obsługi, gdy mamy wskaźnik do pojazdu - else { // wyświetlenie współrzędnych w scenerii oraz kąta kamery, gdy nie mamy wskaźnika - OutText1 = "Camera position: " + to_string( Camera.Pos.x, 2 ) + " " + - to_string( Camera.Pos.y, 2 ) + " " + - to_string( Camera.Pos.z, 2 ); - OutText1 += ", azimuth: " + - to_string( 180.0 - RadToDeg( Camera.Yaw ), 0 ); // ma być azymut, czyli 0 na północy i rośnie na wschód - OutText1 += - " " + - std::string( "S SEE NEN NWW SW" ) - .substr( 1 + 2 * floor( fmod( 8 + ( Camera.Yaw + 0.5 * M_PI_4 ) / M_PI_4, 8 ) ), 2 ); - } - // OutText3= AnsiString(" Online documentation (PL, ENG, DE, soon CZ): - // http://www.eu07.pl"); - // OutText3="enrot="+FloatToStrF(Controlled->MoverParameters->enrot,ffFixed,6,2); - // OutText3="; n="+FloatToStrF(Controlled->MoverParameters->n,ffFixed,6,2); - } // koniec treści podstawowego ekranu FK_V2 - else if( Global::iTextMode == VK_F5 ) { // przesiadka do innego pojazdu - if( FreeFlyModeFlag ) // jeśli tryb latania - { - TDynamicObject *tmp = Ground.DynamicNearest( Camera.Pos, 50, true ); //łapiemy z obsadą - if( tmp ) - if( tmp != Controlled ) { - if( Controlled ) // jeśli mielismy pojazd - if( Controlled->Mechanik ) // na skutek jakiegoś błędu może czasem zniknąć - Controlled->Mechanik->TakeControl( true ); // oddajemy dotychczasowy AI - if( DebugModeFlag ? true : tmp->MoverParameters->Vel <= 5.0 ) { - Controlled = tmp; // przejmujemy nowy - mvControlled = Controlled->ControlledFind()->MoverParameters; - if( Train ) - Train->Silence(); // wyciszenie dźwięków opuszczanego pojazdu - else - Train = new TTrain(); // jeśli niczym jeszcze nie jeździlismy - if( Train->Init( Controlled ) ) { // przejmujemy sterowanie - if( !DebugModeFlag ) // w DebugMode nadal prowadzi AI - Controlled->Mechanik->TakeControl( false ); - } - else - SafeDelete( Train ); // i nie ma czym sterować - // Global::pUserDynamic=Controlled; //renerowanie pojazdu względem kabiny - // Global::iTextMode=VK_F4; - if( Train ) - InOutKey(); // do kabiny - } - } - Global::iTextMode = 0; // tryb neutralny - } - /* - - OutText1=OutText2=OutText3=OutText4=""; - AnsiString flag[10]={"vmax", "tory", "smfr", "pjzd", "mnwr", "pstk", "brak", "brak", - "brak", "brak"}; - if(tmp) - if(tmp->Mechanik) - { - for(int i=0;i<15;i++) - { - int tmppar=floor(tmp->Mechanik->ProximityTable[i].Vel); - OutText2+=(tmppar<1000?(tmppar<100?((tmppar<10)&&(tmppar>=0)?" ":" "):" - "):"")+IntToStr(tmppar)+" "; - tmppar=floor(tmp->Mechanik->ProximityTable[i].Dist); - OutText3+=(tmppar<1000?(tmppar<100?((tmppar<10)&&(tmppar>=0)?" ":" "):" - "):"")+IntToStr(tmppar)+" "; - OutText1+=flag[tmp->Mechanik->ProximityTable[i].Flag]+" "; - } - for(int i=0;i<6;i++) - { - int tmppar=floor(tmp->Mechanik->ReducedTable[i]); - OutText4+=flag[i]+":"+(tmppar<1000?(tmppar<100?((tmppar<10)&&(tmppar>=0)?" ":" - "):" "):"")+IntToStr(tmppar)+" "; - } - } - */ - } - else if( Global::iTextMode == VK_F10 ) { // tu mozna dodac dopisywanie do logu przebiegu lokomotywy - // Global::iViewMode=VK_F10; - // return false; - OutText1 = ( "To quit press [Y] key." ); - OutText3 = ( "Aby zakonczyc program, przycisnij klawisz [Y]." ); - } - else if( Controlled && DebugModeFlag && !Global::iTextMode ) { - OutText1 += ( "; vel " ) + to_string( Controlled->GetVelocity(), 2 ); - OutText1 += ( "; pos " ) + to_string( Controlled->GetPosition().x, 2 ); - OutText1 += ( " ; " ) + to_string( Controlled->GetPosition().y, 2 ); - OutText1 += ( " ; " ) + to_string( Controlled->GetPosition().z, 2 ); - OutText1 += ( "; dist=" ) + to_string( Controlled->MoverParameters->DistCounter, 4 ); - - // double a= acos( DotProduct(Normalize(Controlled->GetDirection()),vWorldFront)); - // OutText+= AnsiString("; angle ")+FloatToStrF(a/M_PI*180,ffFixed,6,2); - OutText1 += - ( "; d_omega " ) + to_string( Controlled->MoverParameters->dizel_engagedeltaomega, 3 ); - OutText2 = ( "HamZ=" ) + to_string( Controlled->MoverParameters->fBrakeCtrlPos, 1 ); - OutText2 += ( "; HamP=" ) + to_string( mvControlled->LocalBrakePos ); - OutText2 += ( "/" ) + to_string( Controlled->MoverParameters->LocalBrakePosA, 2 ); - // mvControlled->MainCtrlPos; - // if (mvControlled->MainCtrlPos<0) - // OutText2+= AnsiString("; nastawnik 0"); - // if (mvControlled->MainCtrlPos>iPozSzereg) - OutText2 += ( "; NasJ=" ) + to_string( mvControlled->MainCtrlPos ); - // else - // OutText2+= AnsiString("; nastawnik S") + mvControlled->MainCtrlPos; - OutText2 += ( "(" ) + to_string( mvControlled->MainCtrlActualPos ); - - OutText2 += ( "); NasB=" ) + to_string( mvControlled->ScndCtrlPos ); - OutText2 += ( "(" ) + to_string( mvControlled->ScndCtrlActualPos ); - if( mvControlled->TrainType == dt_EZT ) - OutText2 += ( "); I=" ) + to_string( int( mvControlled->ShowCurrent( 0 ) ) ); - else - OutText2 += ( "); I=" ) + to_string( int( mvControlled->Im ) ); - // OutText2+=AnsiString("; - // I2=")+FloatToStrF(Controlled->NextConnected->MoverParameters->Im,ffFixed,6,2); - OutText2 += ( "; U=" ) + - to_string( int( mvControlled->RunningTraction.TractionVoltage + 0.5 ) ); - // OutText2+=AnsiString("; rvent=")+FloatToStrF(mvControlled->RventRot,ffFixed,6,2); - OutText2 += ( "; R=" ) + - to_string( Controlled->MoverParameters->RunningShape.R, 1 ); - OutText2 += ( " An=" ) + to_string( Controlled->MoverParameters->AccN, 2 ); // przyspieszenie poprzeczne - if( tprev != int( GlobalTime->mr ) ) { - tprev = GlobalTime->mr; - Acc = ( Controlled->MoverParameters->Vel - VelPrev ) / 3.6; - VelPrev = Controlled->MoverParameters->Vel; - } - OutText2 += ( "; As=" ) + to_string( Acc/*Controlled->MoverParameters->AccS*/, 2 ); // przyspieszenie wzdłużne - // OutText2+=AnsiString("; P=")+FloatToStrF(mvControlled->EnginePower,ffFixed,6,1); - OutText3 += ( "cyl.ham. " ) + - to_string( Controlled->MoverParameters->BrakePress, 2 ); - OutText3 += ( "; prz.gl. " ) + - to_string( Controlled->MoverParameters->PipePress, 2 ); - OutText3 += ( "; zb.gl. " ) + - to_string( Controlled->MoverParameters->CompressedVolume, 2 ); - // youBy - drugi wezyk - OutText3 += ( "; p.zas. " ) + - to_string( Controlled->MoverParameters->ScndPipePress, 2 ); - - if( Controlled->MoverParameters->EngineType == ElectricInductionMotor ) { - // glTranslatef(0.0f,0.0f,-0.50f); - glColor3f( 1.0f, 1.0f, 1.0f ); // a, damy białym - for( int i = 0; i <= 20; i++ ) { - glRasterPos2f( -0.25f, 0.16f - 0.01f * i ); - if( Controlled->MoverParameters->eimc[ i ] < 10 ) - OutText4 = to_string( Controlled->MoverParameters->eimc[ i ], 3 ); - else - OutText4 = to_string( Controlled->MoverParameters->eimc[ i ], 3 ); - glPrint( OutText4.c_str() ); - } - for( int i = 0; i <= 20; i++ ) { - glRasterPos2f( -0.2f, 0.16f - 0.01f * i ); - if( Controlled->MoverParameters->eimv[ i ] < 10 ) - OutText4 = to_string( Controlled->MoverParameters->eimv[ i ], 3 ); - else - OutText4 = to_string( Controlled->MoverParameters->eimv[ i ], 3 ); - glPrint( OutText4.c_str() ); - } - for( int i = 0; i <= 10; i++ ) { - glRasterPos2f( -0.15f, 0.16f - 0.01f * i ); - OutText4 = to_string( Train->fPress[ i ][ 0 ], 3 ); - glPrint( OutText4.c_str() ); - } - for( int i = 0; i <= 8; i++ ) { - glRasterPos2f( -0.15f, 0.04f - 0.01f * i ); - OutText4 = to_string( Controlled->MED[ 0 ][ i ], 3 ); - glPrint( OutText4.c_str() ); - } - for( int i = 0; i <= 8; i++ ) { - for( int j = 0; j <= 9; j++ ) { - glRasterPos2f( 0.05f + 0.03f * i, 0.16f - 0.01f * j ); - OutText4 = to_string( Train->fEIMParams[ i ][ j ], 2 ); - glPrint( OutText4.c_str() ); - } - } - OutText4 = ""; - // glTranslatef(0.0f,0.0f,+0.50f); - glColor3f( 1.0f, 0.0f, 0.0f ); // a, damy czerwonym - } - - // ABu: testy sprzegow-> (potem przeniesc te zmienne z public do protected!) - // OutText3+=AnsiString("; EnginePwr=")+FloatToStrF(mvControlled->EnginePower,ffFixed,1,5); - // OutText3+=AnsiString("; nn=")+FloatToStrF(Controlled->NextConnectedNo,ffFixed,1,0); - // OutText3+=AnsiString("; PR=")+FloatToStrF(Controlled->dPantAngleR,ffFixed,3,0); - // OutText3+=AnsiString("; PF=")+FloatToStrF(Controlled->dPantAngleF,ffFixed,3,0); - // if(Controlled->bDisplayCab==true) - // OutText3+=AnsiString("; Wysw. kab");//+Controlled->mdKabina->GetSMRoot()->Name; - // else - // OutText3+=AnsiString("; test:")+AnsiString(Controlled->MoverParameters->TrainType[1]); - - // OutText3+=FloatToStrF(Train->Dynamic()->MoverParameters->EndSignalsFlag,ffFixed,3,0);; - - // OutText3+=FloatToStrF(Train->Dynamic()->MoverParameters->EndSignalsFlag&byte(((((1+Train->Dynamic()->MoverParameters->CabNo)/2)*30)+2)),ffFixed,3,0);; - - // OutText3+=AnsiString("; - // Ftmax=")+FloatToStrF(Controlled->MoverParameters->Ftmax,ffFixed,3,0); - // OutText3+=AnsiString("; - // FTotal=")+FloatToStrF(Controlled->MoverParameters->FTotal/1000.0f,ffFixed,3,2); - // OutText3+=AnsiString("; - // FTrain=")+FloatToStrF(Controlled->MoverParameters->FTrain/1000.0f,ffFixed,3,2); - // Controlled->mdModel->GetSMRoot()->SetTranslate(vector3(0,1,0)); - - // McZapkie: warto wiedziec w jakim stanie sa przelaczniki - if( mvControlled->ConvOvldFlag ) - OutText3 += " C! "; - else if( mvControlled->FuseFlag ) - OutText3 += " F! "; - else if( !mvControlled->Mains ) - OutText3 += " () "; - else - switch( mvControlled->ActiveDir * ( mvControlled->Imin == mvControlled->IminLo ? 1 : 2 ) ) { - case 2: - { - OutText3 += " >> "; - break; - } - case 1: - { - OutText3 += " -> "; - break; - } - case 0: - { - OutText3 += " -- "; - break; - } - case -1: - { - OutText3 += " <- "; - break; - } - case -2: - { - OutText3 += " << "; - break; - } - } - // OutText3+=AnsiString("; dpLocal - // ")+FloatToStrF(Controlled->MoverParameters->dpLocalValve,ffFixed,10,8); - // OutText3+=AnsiString("; dpMain - // ")+FloatToStrF(Controlled->MoverParameters->dpMainValve,ffFixed,10,8); - // McZapkie: predkosc szlakowa - if( Controlled->MoverParameters->RunningTrack.Velmax == -1 ) { - OutText3 += ( " Vtrack=Vmax" ); - } - else { - OutText3 += - ( " Vtrack " ) + - to_string( Controlled->MoverParameters->RunningTrack.Velmax, 2 ); - } - // WriteLog(Controlled->MoverParameters->TrainType.c_str()); - if( ( mvControlled->EnginePowerSource.SourceType == CurrentCollector ) || - ( mvControlled->TrainType == dt_EZT ) ) { - OutText3 += - ( "; pant. " ) + to_string( mvControlled->PantPress, 2 ); - OutText3 += ( mvControlled->bPantKurek3 ? "=ZG" : "|ZG" ); - } - // McZapkie: komenda i jej parametry - if( Controlled->MoverParameters->CommandIn.Command != ( "" ) ) - OutText4 = ( "C:" ) + - ( Controlled->MoverParameters->CommandIn.Command ) + - ( " V1=" ) + - to_string( Controlled->MoverParameters->CommandIn.Value1, 0 ) + - ( " V2=" ) + - to_string( Controlled->MoverParameters->CommandIn.Value2, 0 ); - if( Controlled->Mechanik && ( Controlled->Mechanik->AIControllFlag == AIdriver ) ) - OutText4 += - ( "AI: Vd=" ) + - to_string( Controlled->Mechanik->VelDesired, 0 ) + ( " ad=" ) + - to_string( Controlled->Mechanik->AccDesired, 2 ) + ( " Pd=" ) + - to_string( Controlled->Mechanik->ActualProximityDist, 0 ) + - ( " Vn=" ) + to_string( Controlled->Mechanik->VelNext, 0 ); - } - - // ABu 150205: prosty help, zeby sie na forum nikt nie pytal, jak ma ruszyc :) - - if( Global::detonatoryOK ) { - // if (Console::Pressed(VK_F9)) ShowHints(); //to nie działa prawidłowo - prosili wyłączyć - if( Global::iTextMode == VK_F9 ) { // informacja o wersji, sposobie wyświetlania i błędach OpenGL - // Global::iViewMode=VK_F9; - OutText1 = Global::asVersion; // informacja o wersji - OutText2 = std::string( "Rendering mode: " ) + ( Global::bUseVBO ? "VBO" : "Display Lists" ); - if( Global::iMultiplayer ) - OutText2 += ". Multiplayer is active"; - OutText2 += "."; - GLenum err = glGetError(); - if( err != GL_NO_ERROR ) { - OutText3 = "OpenGL error " + to_string( err ) + ": " + - Global::Bezogonkow( ( (char *)gluErrorString( err ) ) ); - } - } - if( Global::iTextMode == VK_F3 ) { // wyświetlenie rozkładu jazdy, na razie jakkolwiek - TDynamicObject *tmp = FreeFlyModeFlag ? - Ground.DynamicNearest( Camera.Pos ) : - Controlled; // w trybie latania lokalizujemy wg mapy - Mtable::TTrainParameters *tt = NULL; - if( tmp ) - if( tmp->Mechanik ) { - tt = tmp->Mechanik->Timetable(); - if( tt ) // musi być rozkład - { // wyświetlanie rozkładu - glColor3f( 1.0f, 1.0f, 1.0f ); // a, damy białym - // glTranslatef(0.0f,0.0f,-0.50f); - glRasterPos2f( -0.25f, 0.20f ); - OutText1 = tmp->Mechanik->Relation() + " (" + - tmp->Mechanik->Timetable()->TrainName + ")"; - glPrint( Global::Bezogonkow( OutText1, true ).c_str() ); - glRasterPos2f( -0.25f, 0.19f ); - // glPrint("|============================|=======|=======|=====|"); - // glPrint("| Posterunek | Przyj.| Odjazd| Vmax|"); - // glPrint("|============================|=======|=======|=====|"); - glPrint( "|----------------------------|-------|-------|-----|" ); - TMTableLine *t; - for( int i = tmp->Mechanik->iStationStart; i <= tt->StationCount; ++i ) { // wyświetlenie pozycji z rozkładu - t = tt->TimeTable + i; // linijka rozkładu - OutText1 = ( t->StationName + - " " ).substr( 0, 26 ); - OutText2 = ( t->Ah >= 0 ) ? - to_string( int( 100 + t->Ah ) ).substr( 1, 2 ) + ":" + - to_string( int( 100 + t->Am ) ).substr( 1, 2 ) : - std::string( " " ); - OutText3 = ( t->Dh >= 0 ) ? - to_string( int( 100 + t->Dh ) ).substr( 1, 2 ) + ":" + - to_string( int( 100 + t->Dm ) ).substr( 1, 2 ) : - std::string( " " ); - OutText4 = " " + to_string( t->vmax, 0 ); - OutText4 = OutText4.substr( OutText4.length() - 3, - 3 ); // z wyrównaniem do prawej - // if (AnsiString(t->StationWare).Pos("@")) - OutText1 = "| " + OutText1 + " | " + OutText2 + " | " + OutText3 + - " | " + OutText4 + " | " + t->StationWare; - glRasterPos2f( -0.25f, - 0.18f - 0.02f * ( i - tmp->Mechanik->iStationStart ) ); - if( ( tmp->Mechanik->iStationStart < tt->StationIndex ) ? - ( i < tt->StationIndex ) : - false ) { // czas minął i odjazd był, to nazwa stacji będzie na zielono - glColor3f( 0.0f, 1.0f, 0.0f ); // zielone - glRasterPos2f( - -0.25f, - 0.18f - 0.02f * ( i - tmp->Mechanik->iStationStart ) ); // dopiero - // ustawienie - // pozycji - // ustala - // kolor, - // dziwne... - glPrint( Global::Bezogonkow( OutText1, true ).c_str() ); - glColor3f( 1.0f, 1.0f, 1.0f ); // a reszta białym - } - else // normalne wyświetlanie, bez zmiany kolorów - glPrint( Global::Bezogonkow( OutText1, true ).c_str() ); - glRasterPos2f( -0.25f, - 0.17f - 0.02f * ( i - tmp->Mechanik->iStationStart ) ); - glPrint( "|----------------------------|-------|-------|-----|" ); - } - } - } - OutText1 = OutText2 = OutText3 = OutText4 = ""; - } - else if( OutText1 != "" ) { // ABu: i od razu czyszczenie tego, co bylo napisane - // glTranslatef(0.0f,0.0f,-0.50f); - glRasterPos2f( -0.25f, 0.20f ); - glPrint( OutText1.c_str() ); - OutText1 = ""; - if( OutText2 != "" ) { - glRasterPos2f( -0.25f, 0.19f ); - glPrint( OutText2.c_str() ); - OutText2 = ""; - } - if( OutText3 != "" ) { - glRasterPos2f( -0.25f, 0.18f ); - glPrint( OutText3.c_str() ); - OutText3 = ""; - if( OutText4 != "" ) { - glRasterPos2f( -0.25f, 0.17f ); - glPrint( OutText4.c_str() ); - OutText4 = ""; - } - } - } - // if ((Global::iTextMode!=VK_F3)) - { // stenogramy dźwięków (ukryć, gdy tabelka skanowania lub rozkład?) -/* - glColor3f( 1.0f, 1.0f, 0.0f ); //żółte - for( int i = 0; i < 5; ++i ) { // kilka linijek - if( Global::asTranscript[ i ].empty() ) - break; // dalej nie trzeba - else { - glRasterPos2f( -0.20f, -0.05f - 0.01f * i ); - glPrint( Global::Bezogonkow( Global::asTranscript[ i ] ).c_str() ); - } - } -*/ - int i = 0; - for( auto const &transcript : Global::tranTexts.aLines ) { - - if( Global::fTimeAngleDeg >= transcript.fShow ) { - - cParser parser( transcript.asText ); - while( true == parser.getTokens(1, false, "|") ) { - - std::string transcriptline; parser >> transcriptline; - ::glColor3f( 1.0f, 1.0f, 0.0f ); //żółte - ::glRasterPos2f( -0.20f, -0.05f - 0.01f * i ); - glPrint( transcriptline.c_str() ); - ++i; - } - } - } - } - } - // if (Global::iViewMode!=Global::iTextMode) - //{//Ra: taka maksymalna prowizorka na razie - // WriteLog("Pressed function key F"+AnsiString(Global::iViewMode-111)); - // Global::iTextMode=Global::iViewMode; - //} - glEnable( GL_LIGHTING ); -} - -//--------------------------------------------------------------------------- -void TWorld::OnCommandGet(DaneRozkaz *pRozkaz) -{ // odebranie komunikatu z serwera - if (pRozkaz->iSygn == 'EU07') - switch (pRozkaz->iComm) - { - case 0: // odesłanie identyfikatora wersji - CommLog( Now() + " " + std::to_string(pRozkaz->iComm) + " version" + " rcvd"); - Ground.WyslijString(Global::asVersion, 0); // przedsatwienie się - break; - case 1: // odesłanie identyfikatora wersji - CommLog( Now() + " " + std::to_string(pRozkaz->iComm) + " scenery" + " rcvd"); - Ground.WyslijString(Global::SceneryFile, 1); // nazwa scenerii - break; - case 2: // event - CommLog( Now() + " " + std::to_string(pRozkaz->iComm) + " " + - std::string(pRozkaz->cString + 1, (unsigned)(pRozkaz->cString[0])) + " rcvd"); - if (Global::iMultiplayer) - { // WriteLog("Komunikat: "+AnsiString(pRozkaz->Name1)); - TEvent *e = Ground.FindEvent( - std::string(pRozkaz->cString + 1, (unsigned)(pRozkaz->cString[0]))); - if (e) - if ((e->Type == tp_Multiple) || (e->Type == tp_Lights) || - bool(e->evJoined)) // tylko jawne albo niejawne Multiple - Ground.AddToQuery(e, NULL); // drugi parametr to dynamic wywołujący - tu - // brak - } - break; - case 3: // rozkaz dla AI - if (Global::iMultiplayer) - { - int i = - int(pRozkaz->cString[8]); // długość pierwszego łańcucha (z przodu dwa floaty) - CommLog( - to_string(BorlandTime()) + " " + to_string(pRozkaz->iComm) + " " + - std::string(pRozkaz->cString + 11 + i, (unsigned)(pRozkaz->cString[10 + i])) + - " rcvd"); - TGroundNode *t = Ground.DynamicFind( - std::string(pRozkaz->cString + 11 + i, - (unsigned)pRozkaz->cString[10 + i])); // nazwa pojazdu jest druga - if (t) - if (t->DynamicObject->Mechanik) - { - t->DynamicObject->Mechanik->PutCommand(std::string(pRozkaz->cString + 9, i), - pRozkaz->fPar[0], pRozkaz->fPar[1], - NULL, stopExt); // floaty są z przodu - WriteLog("AI command: " + std::string(pRozkaz->cString + 9, i)); - } - } - break; - case 4: // badanie zajętości toru - { - CommLog(to_string(BorlandTime()) + " " + to_string(pRozkaz->iComm) + " " + - std::string(pRozkaz->cString + 1, (unsigned)(pRozkaz->cString[0])) + " rcvd"); - TGroundNode *t = Ground.FindGroundNode( - std::string(pRozkaz->cString + 1, (unsigned)(pRozkaz->cString[0])), TP_TRACK); - if (t) - if (t->pTrack->IsEmpty()) - Ground.WyslijWolny(t->asName); - } - break; - case 5: // ustawienie parametrów - { - CommLog(to_string(BorlandTime()) + " " + to_string(pRozkaz->iComm) + " params " + - to_string(*pRozkaz->iPar) + " rcvd"); - if (*pRozkaz->iPar == 0) // sprawdzenie czasu - if (*pRozkaz->iPar & 1) // ustawienie czasu - { - double t = pRozkaz->fPar[1]; - GlobalTime->dd = floor(t); // niby nie powinno być dnia, ale... - if (Global::fMoveLight >= 0) - Global::fMoveLight = t; // trzeba by deklinację Słońca przeliczyć - GlobalTime->hh = floor(24 * t) - 24.0 * GlobalTime->dd; - GlobalTime->mm = - floor(60 * 24 * t) - 60.0 * (24.0 * GlobalTime->dd + GlobalTime->hh); - GlobalTime->mr = - floor(60 * 60 * 24 * t) - - 60.0 * (60.0 * (24.0 * GlobalTime->dd + GlobalTime->hh) + GlobalTime->mm); - } - if (*pRozkaz->iPar & 2) - { // ustawienie flag zapauzowania - Global::iPause = pRozkaz->fPar[2]; // zakładamy, że wysyłający wie, co robi - } - } - break; - case 6: // pobranie parametrów ruchu pojazdu - if (Global::iMultiplayer) - { // Ra 2014-12: to ma działać również dla pojazdów bez obsady - CommLog(to_string(BorlandTime()) + " " + to_string(pRozkaz->iComm) + " " + - std::string(pRozkaz->cString + 1, (unsigned)(pRozkaz->cString[0])) + - " rcvd"); - if (pRozkaz->cString[0]) // jeśli długość nazwy jest niezerowa - { // szukamy pierwszego pojazdu o takiej nazwie i odsyłamy parametry ramką #7 - TGroundNode *t; - if (pRozkaz->cString[1] == '*') - t = Ground.DynamicFind( - Global::asHumanCtrlVehicle); // nazwa pojazdu użytkownika - else - t = Ground.DynamicFindAny(std::string( - pRozkaz->cString + 1, (unsigned)pRozkaz->cString[0])); // nazwa pojazdu - if (t) - Ground.WyslijNamiary(t); // wysłanie informacji o pojeździe - } - else - { // dla pustego wysyłamy ramki 6 z nazwami pojazdów AI (jeśli potrzebne wszystkie, - // to rozpoznać np. "*") - Ground.DynamicList(); - } - } - break; - case 8: // ponowne wysłanie informacji o zajętych odcinkach toru - CommLog(to_string(BorlandTime()) + " " + to_string(pRozkaz->iComm) + " all busy track" + " rcvd"); - Ground.TrackBusyList(); - break; - case 9: // ponowne wysłanie informacji o zajętych odcinkach izolowanych - CommLog(to_string(BorlandTime()) + " " + to_string(pRozkaz->iComm) + " all busy isolated" + " rcvd"); - Ground.IsolatedBusyList(); - break; - case 10: // badanie zajętości jednego odcinka izolowanego - CommLog(to_string(BorlandTime()) + " " + to_string(pRozkaz->iComm) + " " + - std::string(pRozkaz->cString + 1, (unsigned)(pRozkaz->cString[0])) + " rcvd"); - Ground.IsolatedBusy(std::string(pRozkaz->cString + 1, (unsigned)(pRozkaz->cString[0]))); - break; - case 11: // ustawienie parametrów ruchu pojazdu - // Ground.IsolatedBusy(AnsiString(pRozkaz->cString+1,(unsigned)(pRozkaz->cString[0]))); - break; - case 12: // skrocona ramka parametrow pojazdow AI (wszystkich!!) - CommLog(to_string(BorlandTime()) + " " + to_string(pRozkaz->iComm) + " obsadzone" + " rcvd"); - Ground.WyslijObsadzone(); - // Ground.IsolatedBusy(AnsiString(pRozkaz->cString+1,(unsigned)(pRozkaz->cString[0]))); - break; - case 13: // ramka uszkodzenia i innych stanow pojazdu, np. wylaczenie CA, wlaczenie recznego itd. - // WriteLog("Przyszlo 13!"); - // WriteLog(pRozkaz->cString); - CommLog(to_string(BorlandTime()) + " " + to_string(pRozkaz->iComm) + " " + - std::string(pRozkaz->cString + 1, (unsigned)(pRozkaz->cString[0])) + - " rcvd"); - if (pRozkaz->cString[1]) // jeśli długość nazwy jest niezerowa - { // szukamy pierwszego pojazdu o takiej nazwie i odsyłamy parametry ramką #13 - TGroundNode *t; - if (pRozkaz->cString[2] == '*') - t = Ground.DynamicFind( - Global::asHumanCtrlVehicle); // nazwa pojazdu użytkownika - else - t = Ground.DynamicFindAny( - std::string(pRozkaz->cString + 2, - (unsigned)pRozkaz->cString[1])); // nazwa pojazdu - if (t) - { - TDynamicObject *d = t->DynamicObject; - while (d) - { - d->Damage(pRozkaz->cString[0]); - d = d->Next(); // pozostałe też - } - d = t->DynamicObject->Prev(); - while (d) - { - d->Damage(pRozkaz->cString[0]); - d = d->Prev(); // w drugą stronę też - } - Ground.WyslijUszkodzenia(t->asName, t->DynamicObject->MoverParameters->EngDmgFlag); // zwrot informacji o pojeździe - } - } - // Ground.IsolatedBusy(AnsiString(pRozkaz->cString+1,(unsigned)(pRozkaz->cString[0]))); - break; - } -}; - -//--------------------------------------------------------------------------- -void TWorld::ModifyTGA(const std::string &dir) -{ // rekurencyjna modyfikacje plików TGA -/* TODO: implement version without Borland stuff - TSearchRec sr; - if (FindFirst(dir + "*.*", faDirectory | faArchive, sr) == 0) - { - do - { - if (sr.Name[1] != '.') - if ((sr.Attr & faDirectory)) // jeśli katalog, to rekurencja - ModifyTGA(dir + sr.Name + "/"); - else if (sr.Name.LowerCase().SubString(sr.Name.Length() - 3, 4) == ".tga") - TTexturesManager::GetTextureID(NULL, NULL, AnsiString(dir + sr.Name).c_str()); - } while (FindNext(sr) == 0); - FindClose(sr); - } -*/ -}; -//--------------------------------------------------------------------------- -std::string last; // zmienne używane w rekurencji -double shift = 0; -void TWorld::CreateE3D(std::string const &dir, bool dyn) -{ // rekurencyjna generowanie plików E3D - -/* TODO: remove Borland file access stuff - TTrack *trk; - double at; - TSearchRec sr; - if (FindFirst(dir + "*.*", faDirectory | faArchive, sr) == 0) - { - do - { - if (sr.Name[1] != '.') - if ((sr.Attr & faDirectory)) // jeśli katalog, to rekurencja - CreateE3D(dir + sr.Name + "\\", dyn); - else if (dyn) - { - if (sr.Name.LowerCase().SubString(sr.Name.Length() - 3, 4) == ".mmd") - { - // konwersja pojazdów będzie ułomna, bo nie poustawiają się animacje na - // submodelach określonych w MMD - // TModelsManager::GetModel(AnsiString(dir+sr.Name).c_str(),true); - if (last != dir) - { // utworzenie toru dla danego pojazdu - last = dir; - trk = TTrack::Create400m(1, shift); - shift += 10.0; // następny tor będzie deczko dalej, aby nie zabić FPS - at = 400.0; - // if (shift>1000) break; //bezpiecznik - } - TGroundNode *tmp = new TGroundNode(); - tmp->DynamicObject = new TDynamicObject(); - // Global::asCurrentTexturePath=dir; //pojazdy mają tekstury we własnych - // katalogach - at -= tmp->DynamicObject->Init( - "", string((dir.SubString(9, dir.Length() - 9)).c_str()), "none", - string(sr.Name.SubString(1, sr.Name.Length() - 4).c_str()), trk, at, "nobody", 0.0, - "none", 0.0, "", false, ""); - // po wczytaniu CHK zrobić pętlę po ładunkach, aby każdy z nich skonwertować - AnsiString loads, load; - loads = AnsiString(tmp->DynamicObject->MoverParameters->LoadAccepted.c_str()); // typy ładunków - if (!loads.IsEmpty()) - { - loads += ","; // przecinek na końcu - int i = loads.Pos(","); - while (i > 1) - { // wypadało by sprawdzić, czy T3D ładunku jest - load = loads.SubString(1, i - 1); - if (FileExists(dir + load + ".t3d")) // o ile jest plik ładunku, bo - // inaczej nie ma to sensu - if (!FileExists( - dir + load + - ".e3d")) // a nie ma jeszcze odpowiednika binarnego - at -= tmp->DynamicObject->Init( - "", dir.SubString(9, dir.Length() - 9).c_str(), "none", - sr.Name.SubString(1, sr.Name.Length() - 4).c_str(), trk, at, - "nobody", 0.0, "none", 1.0, load.c_str(), false, ""); - loads.Delete(1, i); // usunięcie z następującym przecinkiem - i = loads.Pos(","); - } - } - if (tmp->DynamicObject->iCabs) - { // jeśli ma jakąkolwiek kabinę - delete Train; - Train = new TTrain(); - if (tmp->DynamicObject->iCabs & 1) - { - tmp->DynamicObject->MoverParameters->ActiveCab = 1; - Train->Init(tmp->DynamicObject, true); - } - if (tmp->DynamicObject->iCabs & 4) - { - tmp->DynamicObject->MoverParameters->ActiveCab = -1; - Train->Init(tmp->DynamicObject, true); - } - if (tmp->DynamicObject->iCabs & 2) - { - tmp->DynamicObject->MoverParameters->ActiveCab = 0; - Train->Init(tmp->DynamicObject, true); - } - } - Global::asCurrentTexturePath = - (szTexturePath); // z powrotem defaultowa sciezka do tekstur - } - } - else if (sr.Name.LowerCase().SubString(sr.Name.Length() - 3, 4) == ".t3d") - { // z modelami jest prościej - Global::asCurrentTexturePath = dir.c_str(); - TModelsManager::GetModel(AnsiString(dir + sr.Name).c_str(), false); - } - } while (FindNext(sr) == 0); - FindClose(sr); - } -*/ -}; -//--------------------------------------------------------------------------- -void TWorld::CabChange(TDynamicObject *old, TDynamicObject *now) -{ // ewentualna zmiana kabiny użytkownikowi - if (Train) - if (Train->Dynamic() == old) - Global::changeDynObj = now; // uruchomienie protezy -}; -//--------------------------------------------------------------------------- diff --git a/World.h b/World.h deleted file mode 100644 index f710a515..00000000 --- a/World.h +++ /dev/null @@ -1,72 +0,0 @@ -/* -This Source Code Form is subject to the -terms of the Mozilla Public License, v. -2.0. If a copy of the MPL was not -distributed with this file, You can -obtain one at -http://mozilla.org/MPL/2.0/. -*/ - -#pragma once - -#include -#include "Camera.h" -#include "Ground.h" -#include "sky.h" -#include "mczapkie/mover.h" - -class TWorld -{ - void InOutKey(); - void FollowView(bool wycisz = true); - void DistantView(); - - public: - bool Init(HWND NhWnd, HDC hDC); - HWND hWnd; - GLvoid glPrint(const char *fmt); - void OnKeyDown(int cKey); - void OnKeyUp(int cKey); - // void UpdateWindow(); - void OnMouseMove(double x, double y); - void OnCommandGet(DaneRozkaz *pRozkaz); - bool Update(); - void TrainDelete(TDynamicObject *d = NULL); - TWorld(); - ~TWorld(); - // double Aspect; - private: - std::string OutText1; // teksty na ekranie - std::string OutText2; - std::string OutText3; - std::string OutText4; - void Update_Lights(); - void Update_Camera( const double Deltatime ); - bool Render(); - void Render_Cab(); - void Render_UI(); - TCamera Camera; - TGround Ground; - TTrain *Train; - TDynamicObject *pDynamicNearest; - bool Paused; - GLuint base; // numer DL dla znaków w napisach - texture_manager::size_type light; // numer tekstury dla smugi - TSky Clouds; - TEvent *KeyEvents[10]; // eventy wyzwalane z klawiaury - TMoverParameters *mvControlled; // wskaźnik na człon silnikowy, do wyświetlania jego parametrów - int iCheckFPS; // kiedy znów sprawdzić FPS, żeby wyłączać optymalizacji od razu do zera - double fTime50Hz; // bufor czasu dla komunikacji z PoKeys - double fTimeBuffer; // bufor czasu aktualizacji dla stałego kroku fizyki - double fMaxDt; //[s] krok czasowy fizyki (0.01 dla normalnych warunków) - int iPause; // wykrywanie zmian w zapauzowaniu - double VelPrev; // poprzednia prędkość - int tprev; // poprzedni czas - double Acc; // przyspieszenie styczne - public: - void ModifyTGA(std::string const &dir = ""); - void CreateE3D(std::string const &dir = "", bool dyn = false); - void CabChange(TDynamicObject *old, TDynamicObject *now); -}; -//--------------------------------------------------------------------------- - diff --git a/application.cpp b/application.cpp new file mode 100644 index 00000000..d35fb33e --- /dev/null +++ b/application.cpp @@ -0,0 +1,525 @@ +/* +This Source Code Form is subject to the +terms of the Mozilla Public License, v. +2.0. If a copy of the MPL was not +distributed with this file, You can +obtain one at +http://mozilla.org/MPL/2.0/. +*/ + +#include "stdafx.h" +#include "application.h" +#include "scenarioloadermode.h" +#include "drivermode.h" +#include "editormode.h" + +#include "globals.h" +#include "simulation.h" +#include "train.h" +#include "sceneeditor.h" +#include "renderer.h" +#include "uilayer.h" +#include "translation.h" +#include "logs.h" + +#ifdef EU07_BUILD_STATIC +#pragma comment( lib, "glfw3.lib" ) +#pragma comment( lib, "glew32s.lib" ) +#else +#ifdef _WIN32 +#pragma comment( lib, "glfw3dll.lib" ) +#else +#pragma comment( lib, "glfw3.lib" ) +#endif +#pragma comment( lib, "glew32.lib" ) +#endif // build_static +#pragma comment( lib, "opengl32.lib" ) +#pragma comment( lib, "glu32.lib" ) +#pragma comment( lib, "openal32.lib") +#pragma comment( lib, "setupapi.lib" ) +#pragma comment( lib, "python27.lib" ) +#pragma comment( lib, "libserialport-0.lib" ) +#pragma comment (lib, "dbghelp.lib") +#pragma comment (lib, "version.lib") + +eu07_application Application; + +ui_layer uilayerstaticinitializer; + +#ifdef _WIN32 +extern "C" +{ + GLFWAPI HWND glfwGetWin32Window( GLFWwindow* window ); +} + +LONG CALLBACK unhandled_handler( ::EXCEPTION_POINTERS* e ); +LRESULT APIENTRY WndProc( HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam ); +extern HWND Hwnd; +extern WNDPROC BaseWindowProc; +#endif + +// user input callbacks + +void focus_callback( GLFWwindow *window, int focus ) { + if( Global.bInactivePause ) // jeśli ma być pauzowanie okna w tle + if( focus ) + Global.iPause &= ~4; // odpauzowanie, gdy jest na pierwszym planie + else + Global.iPause |= 4; // włączenie pauzy, gdy nieaktywy +} + +void window_resize_callback( GLFWwindow *window, int w, int h ) { + // NOTE: we have two variables which basically do the same thing as we don't have dynamic fullscreen toggle + // TBD, TODO: merge them? + Global.iWindowWidth = w; + Global.iWindowHeight = h; + Global.fDistanceFactor = std::max( 0.5f, h / 768.0f ); // not sure if this is really something we want to use + glViewport( 0, 0, w, h ); +} + +void cursor_pos_callback( GLFWwindow *window, double x, double y ) { + + Application.on_cursor_pos( x, y ); +} + +void mouse_button_callback( GLFWwindow* window, int button, int action, int mods ) { + + Application.on_mouse_button( button, action, mods ); +} + +void scroll_callback( GLFWwindow* window, double xoffset, double yoffset ) { + + Application.on_scroll( xoffset, yoffset ); +} + +void key_callback( GLFWwindow *window, int key, int scancode, int action, int mods ) { + + Application.on_key( key, scancode, action, mods ); +} + +// public: + +int +eu07_application::init( int Argc, char *Argv[] ) { + + int result { 0 }; + + init_debug(); + init_files(); + if( ( result = init_settings( Argc, Argv ) ) != 0 ) { + return result; + } + if( ( result = init_locale() ) != 0 ) { + return result; + } + + WriteLog( "Starting MaSzyna rail vehicle simulator (release: " + Global.asVersion + ")" ); + WriteLog( "For online documentation and additional files refer to: http://eu07.pl" ); + WriteLog( "Authors: Marcin_EU, McZapkie, ABu, Winger, Tolaris, nbmx, OLO_EU, Bart, Quark-t, " + "ShaXbee, Oli_EU, youBy, KURS90, Ra, hunter, szociu, Stele, Q, firleju and others\n" ); + + if( ( result = init_glfw() ) != 0 ) { + return result; + } + init_callbacks(); + if( ( result = init_gfx() ) != 0 ) { + return result; + } + if( ( result = init_audio() ) != 0 ) { + return result; + } + m_taskqueue.init(); + if( ( result = init_modes() ) != 0 ) { + return result; + } + + return result; +} + +int +eu07_application::run() { + + // main application loop + while( ( false == glfwWindowShouldClose( m_windows.front() ) ) + && ( false == m_modestack.empty() ) + && ( true == m_modes[ m_modestack.top() ]->update() ) + && ( true == GfxRenderer.Render() ) ) { + glfwPollEvents(); + m_modes[ m_modestack.top() ]->on_event_poll(); + } + + return 0; +} + +bool +eu07_application::request( python_taskqueue::task_request const &Task ) { + + return m_taskqueue.insert( Task ); +} + +void +eu07_application::exit() { + + SafeDelete( simulation::Train ); + SafeDelete( simulation::Region ); + + ui_layer::shutdown(); + + for( auto *window : m_windows ) { + glfwDestroyWindow( window ); + } + glfwTerminate(); + m_taskqueue.exit(); +} + +void +eu07_application::render_ui() { + + if( m_modestack.empty() ) { return; } + + m_modes[ m_modestack.top() ]->render_ui(); +} + +bool +eu07_application::pop_mode() { + + if( m_modestack.empty() ) { return false; } + + m_modes[ m_modestack.top() ]->exit(); + m_modestack.pop(); + return true; +} + +bool +eu07_application::push_mode( eu07_application::mode const Mode ) { + + if( Mode >= mode::count_ ) { return false; } + + m_modes[ Mode ]->enter(); + m_modestack.push( Mode ); + + return true; +} + +void +eu07_application::set_title( std::string const &Title ) { + + glfwSetWindowTitle( m_windows.front(), Title.c_str() ); +} + +void +eu07_application::set_progress( float const Progress, float const Subtaskprogress ) { + + if( m_modestack.empty() ) { return; } + + m_modes[ m_modestack.top() ]->set_progress( Progress, Subtaskprogress ); +} + +void +eu07_application::set_cursor( int const Mode ) { + + ui_layer::set_cursor( Mode ); +} + +void +eu07_application::set_cursor_pos( double const Horizontal, double const Vertical ) { + + glfwSetCursorPos( m_windows.front(), Horizontal, Vertical ); +} + +void +eu07_application::get_cursor_pos( double &Horizontal, double &Vertical ) const { + + glfwGetCursorPos( m_windows.front(), &Horizontal, &Vertical ); +} + +void +eu07_application::on_key( int const Key, int const Scancode, int const Action, int const Mods ) { + + if( m_modestack.empty() ) { return; } + + m_modes[ m_modestack.top() ]->on_key( Key, Scancode, Action, Mods ); +} + +void +eu07_application::on_cursor_pos( double const Horizontal, double const Vertical ) { + + if( m_modestack.empty() ) { return; } + + m_modes[ m_modestack.top() ]->on_cursor_pos( Horizontal, Vertical ); +} + +void +eu07_application::on_mouse_button( int const Button, int const Action, int const Mods ) { + + if( m_modestack.empty() ) { return; } + + m_modes[ m_modestack.top() ]->on_mouse_button( Button, Action, Mods ); +} + +void +eu07_application::on_scroll( double const Xoffset, double const Yoffset ) { + + if( m_modestack.empty() ) { return; } + + m_modes[ m_modestack.top() ]->on_scroll( Xoffset, Yoffset ); +} + +GLFWwindow * +eu07_application::window( int const Windowindex ) { + + if( Windowindex >= 0 ) { + return ( + Windowindex < m_windows.size() ? + m_windows[ Windowindex ] : + nullptr ); + } + // for index -1 create a new child window + glfwWindowHint( GLFW_VISIBLE, GL_FALSE ); + auto *childwindow = glfwCreateWindow( 1, 1, "eu07helper", nullptr, m_windows.front() ); + if( childwindow != nullptr ) { + m_windows.emplace_back( childwindow ); + } + return childwindow; +} + +// private: + +void +eu07_application::init_debug() { + +#if defined(_MSC_VER) && defined (_DEBUG) + // memory leaks + _CrtSetDbgFlag( _CrtSetDbgFlag( _CRTDBG_REPORT_FLAG ) | _CRTDBG_LEAK_CHECK_DF ); + // floating point operation errors + auto state { _clearfp() }; + state = _control87( 0, 0 ); + // this will turn on FPE for #IND and zerodiv + state = _control87( state & ~( _EM_ZERODIVIDE | _EM_INVALID ), _MCW_EM ); +#endif +#ifdef _WIN32 + ::SetUnhandledExceptionFilter( unhandled_handler ); +#endif +} + +void +eu07_application::init_files() { + +#ifdef _WIN32 + DeleteFile( "log.txt" ); + DeleteFile( "errors.txt" ); + _mkdir( "logs" ); +#endif +} + +int +eu07_application::init_settings( int Argc, char *Argv[] ) { + + Global.LoadIniFile( "eu07.ini" ); + if( ( Global.iWriteLogEnabled & 2 ) != 0 ) { + // show output console if requested + AllocConsole(); + } +/* + std::string executable( argv[ 0 ] ); auto const pathend = executable.rfind( '\\' ); + Global.ExecutableName = + ( pathend != std::string::npos ? + executable.substr( executable.rfind( '\\' ) + 1 ) : + executable ); +*/ +#ifdef _WIN32 + // retrieve product version from the file's version data table + { + auto const fileversionsize { ::GetFileVersionInfoSize( Argv[ 0 ], NULL ) }; + std::vectorfileversiondata; fileversiondata.resize( fileversionsize ); + if( ::GetFileVersionInfo( Argv[ 0 ], 0, fileversionsize, fileversiondata.data() ) ) { + + struct lang_codepage { + WORD language; + WORD codepage; + } *langcodepage; + UINT datasize; + + ::VerQueryValue( + fileversiondata.data(), + TEXT( "\\VarFileInfo\\Translation" ), + (LPVOID*)&langcodepage, + &datasize ); + + std::string subblock; subblock.resize( 50 ); + ::StringCchPrintf( + &subblock[0], subblock.size(), + TEXT( "\\StringFileInfo\\%04x%04x\\ProductVersion" ), + langcodepage->language, + langcodepage->codepage ); + + VOID *stringdata; + if( ::VerQueryValue( + fileversiondata.data(), + subblock.data(), + &stringdata, + &datasize ) ) { + + Global.asVersion = std::string( reinterpret_cast(stringdata) ); + } + } + } +#endif + // process command line arguments + for( int i = 1; i < Argc; ++i ) { + + std::string token { Argv[ i ] }; + + if( token == "-s" ) { + if( i + 1 < Argc ) { + Global.SceneryFile = ToLower( Argv[ ++i ] ); + } + } + else if( token == "-v" ) { + if( i + 1 < Argc ) { + Global.asHumanCtrlVehicle = ToLower( Argv[ ++i ] ); + } + } + else { + std::cout + << "usage: " << std::string( Argv[ 0 ] ) + << " [-s sceneryfilepath]" + << " [-v vehiclename]" + << std::endl; + return -1; + } + } + + return 0; +} + +int +eu07_application::init_locale() { + + locale::init(); + + return 0; +} + +int +eu07_application::init_glfw() { + + if( glfwInit() == GLFW_FALSE ) { + ErrorLog( "Bad init: failed to initialize glfw" ); + return -1; + } + // match requested video mode to current to allow for + // fullwindow creation when resolution is the same + auto *monitor { glfwGetPrimaryMonitor() }; + auto const *vmode { glfwGetVideoMode( monitor ) }; + + glfwWindowHint( GLFW_RED_BITS, vmode->redBits ); + glfwWindowHint( GLFW_GREEN_BITS, vmode->greenBits ); + glfwWindowHint( GLFW_BLUE_BITS, vmode->blueBits ); + glfwWindowHint( GLFW_REFRESH_RATE, vmode->refreshRate ); + + glfwWindowHint( GLFW_AUTO_ICONIFY, GLFW_FALSE ); + if( Global.iMultisampling > 0 ) { + glfwWindowHint( GLFW_SAMPLES, 1 << Global.iMultisampling ); + } + + if( Global.bFullScreen ) { + // match screen dimensions with selected monitor, for 'borderless window' in fullscreen mode + Global.iWindowWidth = vmode->width; + Global.iWindowHeight = vmode->height; + } + + auto *window { + glfwCreateWindow( + Global.iWindowWidth, + Global.iWindowHeight, + Global.AppName.c_str(), + ( Global.bFullScreen ? + monitor : + nullptr ), + nullptr ) }; + + if( window == nullptr ) { + ErrorLog( "Bad init: failed to create glfw window" ); + return -1; + } + + glfwMakeContextCurrent( window ); + glfwSwapInterval( Global.VSync ? 1 : 0 ); //vsync + +#ifdef _WIN32 +// setup wrapper for base glfw window proc, to handle copydata messages + Hwnd = glfwGetWin32Window( window ); + BaseWindowProc = ( WNDPROC )::SetWindowLongPtr( Hwnd, GWLP_WNDPROC, (LONG_PTR)WndProc ); + // switch off the topmost flag + ::SetWindowPos( Hwnd, HWND_NOTOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE ); +#endif + m_windows.emplace_back( window ); + + return 0; +} + +void +eu07_application::init_callbacks() { + + auto *window { m_windows.front() }; + glfwSetFramebufferSizeCallback( window, window_resize_callback ); + glfwSetCursorPosCallback( window, cursor_pos_callback ); + glfwSetMouseButtonCallback( window, mouse_button_callback ); + glfwSetKeyCallback( window, key_callback ); + glfwSetScrollCallback( window, scroll_callback ); + glfwSetWindowFocusCallback( window, focus_callback ); + { + int width, height; + glfwGetFramebufferSize( window, &width, &height ); + window_resize_callback( window, width, height ); + } +} + +int +eu07_application::init_gfx() { + + if( glewInit() != GLEW_OK ) { + ErrorLog( "Bad init: failed to initialize glew" ); + return -1; + } + + if( ( false == GfxRenderer.Init( m_windows.front() ) ) + || ( false == ui_layer::init( m_windows.front() ) ) ) { + return -1; + } + + return 0; +} + +int +eu07_application::init_audio() { + + if( Global.bSoundEnabled ) { + Global.bSoundEnabled &= audio::renderer.init(); + } + // NOTE: lack of audio isn't deemed a failure serious enough to throw in the towel + return 0; +} + +int +eu07_application::init_modes() { + + // NOTE: we could delay creation/initialization until transition to specific mode is requested, + // but doing it in one go at the start saves us some error checking headache down the road + + // create all application behaviour modes + m_modes[ mode::scenarioloader ] = std::make_shared(); + m_modes[ mode::driver ] = std::make_shared(); + m_modes[ mode::editor ] = std::make_shared(); + // initialize the mode objects + for( auto &mode : m_modes ) { + if( false == mode->init() ) { + return -1; + } + } + // activate the default mode + push_mode( mode::scenarioloader ); + + return 0; +} diff --git a/application.h b/application.h new file mode 100644 index 00000000..7aceda31 --- /dev/null +++ b/application.h @@ -0,0 +1,88 @@ +/* +This Source Code Form is subject to the +terms of the Mozilla Public License, v. +2.0. If a copy of the MPL was not +distributed with this file, You can +obtain one at +http://mozilla.org/MPL/2.0/. +*/ + +#pragma once + +#include "applicationmode.h" +#include "pyint.h" + +class eu07_application { + +public: +// types + enum mode { +// launcher = 0, + scenarioloader, + driver, + editor, + count_ + }; +// constructors + eu07_application() = default; +// methods + int + init( int Argc, char *Argv[] ); + int + run(); + bool + request( python_taskqueue::task_request const &Task ); + void + exit(); + void + render_ui(); + // switches application to specified mode + bool + pop_mode(); + bool + push_mode( eu07_application::mode const Mode ); + void + set_title( std::string const &Title ); + void + set_progress( float const Progress = 0.f, float const Subtaskprogress = 0.f ); + void + set_cursor( int const Mode ); + void + set_cursor_pos( double const Horizontal, double const Vertical ); + void + get_cursor_pos( double &Horizontal, double &Vertical ) const; + // input handlers + void + on_key( int const Key, int const Scancode, int const Action, int const Mods ); + void + on_cursor_pos( double const Horizontal, double const Vertical ); + void + on_mouse_button( int const Button, int const Action, int const Mods ); + void + on_scroll( double const Xoffset, double const Yoffset ); + // gives access to specified window, creates a new window if index == -1 + GLFWwindow * + window( int const Windowindex = 0 ); + +private: +// types + using modeptr_array = std::array, static_cast( mode::count_ )>; + using mode_stack = std::stack; +// methods + void init_debug(); + void init_files(); + int init_settings( int Argc, char *Argv[] ); + int init_locale(); + int init_glfw(); + void init_callbacks(); + int init_gfx(); + int init_audio(); + int init_modes(); +// members + modeptr_array m_modes { nullptr }; // collection of available application behaviour modes + mode_stack m_modestack; // current behaviour mode + python_taskqueue m_taskqueue; + std::vector m_windows; +}; + +extern eu07_application Application; diff --git a/applicationmode.h b/applicationmode.h new file mode 100644 index 00000000..0bc0eaa0 --- /dev/null +++ b/applicationmode.h @@ -0,0 +1,70 @@ +/* +This Source Code Form is subject to the +terms of the Mozilla Public License, v. +2.0. If a copy of the MPL was not +distributed with this file, You can +obtain one at +http://mozilla.org/MPL/2.0/. +*/ + +#pragma once + +#include "uilayer.h" + +// component implementing specific mode of application behaviour +// base interface +class application_mode { + +public: +// destructor + virtual + ~application_mode() = default; +// methods; + // initializes internal data structures of the mode. returns: true on success, false otherwise + virtual + bool + init() = 0; + // mode-specific update of simulation data. returns: false on error, true otherwise + virtual + bool + update() = 0; + // draws node-specific user interface + inline + void + render_ui() { + if( m_userinterface != nullptr ) { + m_userinterface->render(); } } + inline + void + set_progress( float const Progress = 0.f, float const Subtaskprogress = 0.f ) { + if( m_userinterface != nullptr ) { + m_userinterface->set_progress( Progress, Subtaskprogress ); } } + // maintenance method, called when the mode is activated + virtual + void + enter() = 0; + // maintenance method, called when the mode is deactivated + virtual + void + exit() = 0; + // input handlers + virtual + void + on_key( int const Key, int const Scancode, int const Action, int const Mods ) = 0; + virtual + void + on_cursor_pos( double const X, double const Y ) = 0; + virtual + void + on_mouse_button( int const Button, int const Action, int const Mods ) = 0; + virtual + void + on_scroll( double const Xoffset, double const Yoffset ) = 0; + virtual + void + on_event_poll() = 0; + +protected: +// members + std::shared_ptr m_userinterface; +}; diff --git a/audio.cpp b/audio.cpp new file mode 100644 index 00000000..2ee32d26 --- /dev/null +++ b/audio.cpp @@ -0,0 +1,245 @@ +/* +This Source Code Form is subject to the +terms of the Mozilla Public License, v. +2.0. If a copy of the MPL was not +distributed with this file, You can +obtain one at +http://mozilla.org/MPL/2.0/. +*/ + +#include "stdafx.h" + +#include "audio.h" +#include "globals.h" +#include "utilities.h" +#include "logs.h" +#include "resourcemanager.h" + +#define STB_VORBIS_HEADER_ONLY +#include "stb_vorbis.c" +#define DR_WAV_IMPLEMENTATION +#include "dr_wav.h" +#define DR_FLAC_IMPLEMENTATION +#include "dr_flac.h" + +namespace audio { + +openal_buffer::openal_buffer( std::string const &Filename ) : + name( Filename ) { + + ::alGenBuffers( 1, &id ); + // fetch audio data + if( Filename.substr( Filename.rfind( '.' ) ) == ".wav" ) { + // .wav audio data file + auto *file { drwav_open_file( Filename.c_str() ) }; + if( file != nullptr ) { + rate = file->sampleRate; + auto const samplecount{ static_cast( file->totalSampleCount ) }; + data.resize( samplecount ); + drwav_read_s16( + file, + samplecount, + &data[ 0 ] ); + if( file->channels > 1 ) { + narrow_to_mono( file->channels ); + data.resize( samplecount / file->channels ); + } + } + else { + ErrorLog( "Bad file: failed do load audio file \"" + Filename + "\"", logtype::file ); + } + // we're done with the disk data + drwav_close( file ); + } + else if( Filename.substr( Filename.rfind( '.' ) ) == ".flac" ) { + // .flac audio data file + auto *file { drflac_open_file( Filename.c_str() ) }; + if( file != nullptr ) { + rate = file->sampleRate; + auto const samplecount{ static_cast( file->totalSampleCount ) }; + data.resize( samplecount ); + drflac_read_s16( + file, + samplecount, + &data[ 0 ] ); + if( file->channels > 1 ) { + narrow_to_mono( file->channels ); + data.resize( samplecount / file->channels ); + } + } + else { + ErrorLog( "Bad file: failed do load audio file \"" + Filename + "\"", logtype::file ); + } + // we're done with the disk data + drflac_close( file ); + } + else if( Filename.substr( Filename.rfind( '.' ) ) == ".ogg" ) { + // vorbis .ogg audio data file + // TBD, TODO: customized vorbis_decode to avoid unnecessary shuffling around of the decoded data + int channels, samplerate; + std::int16_t *filedata { nullptr }; + auto const samplecount{ stb_vorbis_decode_filename( Filename.c_str(), &channels, &samplerate, &filedata ) }; + if( samplecount > 0 ) { + rate = samplerate; + data.resize( samplecount ); + std::copy( filedata, filedata + samplecount, std::begin( data ) ); + free( filedata ); + if( channels > 1 ) { + narrow_to_mono( channels ); + data.resize( samplecount / channels ); + } + } + else { + ErrorLog( "Bad file: failed do load audio file \"" + Filename + "\"", logtype::file ); + } + } + + if( false == data.empty() ) { + // send the data to openal side + ::alBufferData( id, AL_FORMAT_MONO16, data.data(), data.size() * sizeof( std::int16_t ), rate ); + // and get rid of the source, we shouldn't need it anymore + // TBD, TODO: delay data fetching and transfers until the buffer is actually used? + std::vector().swap( data ); + } + fetch_caption(); +} + +// mix specified number of interleaved multi-channel data, down to mono +void +openal_buffer::narrow_to_mono( std::uint16_t const Channelcount ) { + + std::size_t monodataindex { 0 }; + std::int32_t accumulator { 0 }; + auto channelcount { Channelcount }; + + for( auto const channeldata : data ) { + + accumulator += channeldata; + if( --channelcount == 0 ) { + + data[ monodataindex++ ] = accumulator / Channelcount; + accumulator = 0; + channelcount = Channelcount; + } + } +} + +// retrieves sound caption in currently set language +void +openal_buffer::fetch_caption() { + + std::string captionfilename { name }; + captionfilename.erase( captionfilename.rfind( '.' ) ); // obcięcie rozszerzenia + captionfilename += "-" + Global.asLang + ".txt"; // już może być w różnych językach + if( true == FileExists( captionfilename ) ) { + // wczytanie + std::ifstream inputfile( captionfilename ); + caption.assign( std::istreambuf_iterator( inputfile ), std::istreambuf_iterator() ); + } +} + + + +buffer_manager::~buffer_manager() { + + for( auto &buffer : m_buffers ) { + if( buffer.id != null_resource ) { + ::alDeleteBuffers( 1, &( buffer.id ) ); + } + } +} + +// creates buffer object out of data stored in specified file. returns: handle to the buffer or null_handle if creation failed +audio::buffer_handle +buffer_manager::create( std::string const &Filename ) { + + auto filename { ToLower( Filename ) }; + + erase_extension( filename ); + replace_slashes( filename ); + + audio::buffer_handle lookup { null_handle }; + std::string filelookup; + if( false == Global.asCurrentDynamicPath.empty() ) { + // try dynamic-specific sounds first + lookup = find_buffer( Global.asCurrentDynamicPath + filename ); + if( lookup != null_handle ) { + return lookup; + } + filelookup = find_file( Global.asCurrentDynamicPath + filename ); + if( false == filelookup.empty() ) { + return emplace( filelookup ); + } + } + if( filename.find( '/' ) != std::string::npos ) { + // if the filename includes path, try to use it directly + lookup = find_buffer( filename ); + if( lookup != null_handle ) { + return lookup; + } + filelookup = find_file( filename ); + if( false == filelookup.empty() ) { + return emplace( filelookup ); + } + } + // if dynamic-specific and/or direct lookups find nothing, try the default sound folder + lookup = find_buffer( szSoundPath + filename ); + if( lookup != null_handle ) { + return lookup; + } + filelookup = find_file( szSoundPath + filename ); + if( false == filelookup.empty() ) { + return emplace( filelookup ); + } + // if we still didn't find anything, give up + ErrorLog( "Bad file: failed do locate audio file \"" + Filename + "\"", logtype::file ); + return null_handle; +} + +// provides direct access to a specified buffer +audio::openal_buffer const & +buffer_manager::buffer( audio::buffer_handle const Buffer ) const { + + return m_buffers[ Buffer ]; +} + +// places in the bank a buffer containing data stored in specified file. returns: handle to the buffer +audio::buffer_handle +buffer_manager::emplace( std::string Filename ) { + + buffer_handle const handle { m_buffers.size() }; + m_buffers.emplace_back( Filename ); + + // NOTE: we store mapping without file type extension, to simplify lookups + erase_extension( Filename ); + m_buffermappings.emplace( + Filename, + handle ); + + return handle; +} + +audio::buffer_handle +buffer_manager::find_buffer( std::string const &Buffername ) const { + + auto const lookup = m_buffermappings.find( Buffername ); + if( lookup != std::end( m_buffermappings ) ) + return lookup->second; + else + return null_handle; +} + +std::string +buffer_manager::find_file( std::string const &Filename ) const { + + auto const lookup { + FileExists( + { Filename }, + { ".ogg", ".flac", ".wav" } ) }; + + return lookup.first + lookup.second; +} + +} // audio + +//--------------------------------------------------------------------------- diff --git a/audio.h b/audio.h new file mode 100644 index 00000000..f9642600 --- /dev/null +++ b/audio.h @@ -0,0 +1,83 @@ +/* +This Source Code Form is subject to the +terms of the Mozilla Public License, v. +2.0. If a copy of the MPL was not +distributed with this file, You can +obtain one at +http://mozilla.org/MPL/2.0/. +*/ + +#pragma once + +#include "al.h" +#include "alc.h" + +namespace audio { + +ALuint const null_resource{ ~( ALuint { 0 } ) }; + +// wrapper for audio sample +struct openal_buffer { +// members + ALuint id { null_resource }; // associated AL resource + unsigned int rate {}; // sample rate of the data + std::string name; + std::string caption; +// constructors + openal_buffer() = default; + explicit openal_buffer( std::string const &Filename ); +// methods + // retrieves sound caption in currently set language + void + fetch_caption(); + +private: +// methods + // mix specified number of interleaved multi-channel data, down to mono + void + narrow_to_mono( std::uint16_t const Channelcount ); +// members + std::vector data; // audio data +}; + +using buffer_handle = std::size_t; + + +// +class buffer_manager { + +public: +// constructors + buffer_manager() { m_buffers.emplace_back( openal_buffer() ); } // empty bindings for null buffer +// destructor + ~buffer_manager(); +// methods + // creates buffer object out of data stored in specified file. returns: handle to the buffer or null_handle if creation failed + buffer_handle + create( std::string const &Filename ); + // provides direct access to a specified buffer + audio::openal_buffer const & + buffer( audio::buffer_handle const Buffer ) const; + +private: +// types + using buffer_sequence = std::vector; + using index_map = std::unordered_map; +// methods + // places in the bank a buffer containing data stored in specified file. returns: handle to the buffer + buffer_handle + emplace( std::string Filename ); + // checks whether specified buffer is in the buffer bank. returns: buffer handle, or null_handle. + buffer_handle + find_buffer( std::string const &Buffername ) const; + // checks whether specified file exists. returns: name of the located file, or empty string. + std::string + find_file( std::string const &Filename ) const; +// members + buffer_sequence m_buffers; + index_map m_buffermappings; +}; + +} // audio + +//--------------------------------------------------------------------------- diff --git a/audiorenderer.cpp b/audiorenderer.cpp new file mode 100644 index 00000000..c02379fb --- /dev/null +++ b/audiorenderer.cpp @@ -0,0 +1,449 @@ +/* +This Source Code Form is subject to the +terms of the Mozilla Public License, v. +2.0. If a copy of the MPL was not +distributed with this file, You can +obtain one at +http://mozilla.org/MPL/2.0/. +*/ + +#include "stdafx.h" +#include "audiorenderer.h" + +#include "sound.h" +#include "globals.h" +#include "camera.h" +#include "logs.h" +#include "utilities.h" + +namespace audio { + +openal_renderer renderer; + +float const EU07_SOUND_CUTOFFRANGE { 3000.f }; // 2750 m = max expected emitter spawn range, plus safety margin +float const EU07_SOUND_VELOCITYLIMIT { 250 / 3.6f }; // 343 m/sec ~= speed of sound; arbitrary limit of 250 km/h + +// potentially clamps length of provided vector to 343 meters +// TBD: make a generic method for utilities out of this +glm::vec3 +limit_velocity( glm::vec3 const &Velocity ) { + + auto const ratio { glm::length( Velocity ) / EU07_SOUND_VELOCITYLIMIT }; + + return ( + ratio > 1.f ? + Velocity / ratio : + Velocity ); +} + +// starts playback of queued buffers +void +openal_source::play() { + + if( id == audio::null_resource ) { return; } // no implementation-side source to match, no point + + ::alGetError(); // pop the error stack + ::alSourcePlay( id ); + + ALint state; + ::alGetSourcei( id, AL_SOURCE_STATE, &state ); + is_playing = ( state == AL_PLAYING ); +/* + is_playing = ( + ::alGetError() == AL_NO_ERROR ? + true : + false ); +*/ +} + +// stops the playback +void +openal_source::stop() { + + if( id == audio::null_resource ) { return; } // no implementation-side source to match, no point + + loop( false ); + // NOTE: workaround for potential edge cases where ::alSourceStop() doesn't set source which wasn't yet started to AL_STOPPED + int state; + ::alGetSourcei( id, AL_SOURCE_STATE, &state ); + if( state == AL_INITIAL ) { + play(); + } + ::alSourceStop( id ); + is_playing = false; +} + +// updates state of the source +void +openal_source::update( double const Deltatime, glm::vec3 const &Listenervelocity ) { + + update_deltatime = Deltatime; // cached for time-based processing of data from the controller + if( sound_range < 0.0 ) { + sound_velocity = Listenervelocity; // cached for doppler shift calculation + } + + if( id != audio::null_resource ) { + + sound_change = false; + ::alGetSourcei( id, AL_BUFFERS_PROCESSED, &sound_index ); + // for multipart sounds trim away processed sources until only one remains, the last one may be set to looping by the controller + // TBD, TODO: instead of change flag move processed buffer ids to separate queue, for accurate tracking of longer buffer sequences + ALuint bufferid; + while( ( sound_index > 0 ) + && ( sounds.size() > 1 ) ) { + ::alSourceUnqueueBuffers( id, 1, &bufferid ); + sounds.erase( std::begin( sounds ) ); + --sound_index; + sound_change = true; + } + + int state; + ::alGetSourcei( id, AL_SOURCE_STATE, &state ); + is_playing = ( state == AL_PLAYING ); + } + + // request instructions from the controller + controller->update( *this ); +} + +// configures state of the source to match the provided set of properties +void +openal_source::sync_with( sound_properties const &State ) { + + if( id == audio::null_resource ) { + // no implementation-side source to match, return sync error so the controller can clean up on its end + sync = sync_state::bad_resource; + return; + } + // velocity + if( ( update_deltatime > 0.0 ) + && ( sound_range >= 0 ) + && ( properties.location != glm::dvec3() ) ) { + // after sound position was initialized we can start velocity calculations + sound_velocity = limit_velocity( ( State.location - properties.location ) / update_deltatime ); + } + // NOTE: velocity at this point can be either listener velocity for global sounds, actual sound velocity, or 0 if sound position is yet unknown + ::alSourcefv( id, AL_VELOCITY, glm::value_ptr( sound_velocity ) ); + // location + properties.location = State.location; + sound_distance = properties.location - glm::dvec3 { Global.pCamera.Pos }; + if( sound_range > 0 ) { + // range cutoff check + auto const cutoffrange = ( + is_multipart ? + EU07_SOUND_CUTOFFRANGE : // we keep multi-part sounds around longer, to minimize restarts as the sounds get out and back in range + sound_range * 7.5f ); + if( glm::length2( sound_distance ) > std::min( ( cutoffrange * cutoffrange ), ( EU07_SOUND_CUTOFFRANGE * EU07_SOUND_CUTOFFRANGE ) ) ) { + stop(); + sync = sync_state::bad_distance; // flag sync failure for the controller + return; + } + } + if( sound_range >= 0 ) { + ::alSourcefv( id, AL_POSITION, glm::value_ptr( sound_distance ) ); + } + else { + // sounds with 'unlimited' range are positioned on top of the listener + ::alSourcefv( id, AL_POSITION, glm::value_ptr( glm::vec3() ) ); + } + // gain + if( ( State.soundproofing_stamp != properties.soundproofing_stamp ) + || ( State.gain != properties.gain ) ) { + // gain value has changed + properties.gain = State.gain; + properties.soundproofing = State.soundproofing; + properties.soundproofing_stamp = State.soundproofing_stamp; + + ::alSourcef( id, AL_GAIN, properties.gain * properties.soundproofing ); + } + if( sound_range > 0 ) { + auto const rangesquared { sound_range * sound_range }; + auto const distancesquared { glm::length2( sound_distance ) }; + if( ( distancesquared > rangesquared ) + || ( false == is_in_range ) ) { + // if the emitter is outside of its nominal hearing range or was outside of it during last check + // adjust the volume to a suitable fraction of nominal value + auto const fadedistance { sound_range * 0.75 }; + auto const rangefactor { + interpolate( + 1.f, 0.f, + clamp( + ( distancesquared - rangesquared ) / ( fadedistance * fadedistance ), + 0.f, 1.f ) ) }; + ::alSourcef( id, AL_GAIN, properties.gain * properties.soundproofing * rangefactor ); + } + is_in_range = ( distancesquared <= rangesquared ); + } + // pitch + if( State.pitch != properties.pitch ) { + // pitch value has changed + properties.pitch = State.pitch; + + ::alSourcef( id, AL_PITCH, clamp( properties.pitch * pitch_variation, 0.1f, 10.f ) ); + } + sync = sync_state::good; +} + +// sets max audible distance for sounds emitted by the source +void +openal_source::range( float const Range ) { + + // NOTE: we cache actual specified range, as we'll be giving 'unlimited' range special treatment + sound_range = Range; + + if( id == audio::null_resource ) { return; } // no implementation-side source to match, no point + + auto const range { ( + Range >= 0 ? + Range : + 5 ) }; // range of -1 means sound of unlimited range, positioned at the listener + ::alSourcef( id, AL_REFERENCE_DISTANCE, range * ( 1.f / 16.f ) ); + ::alSourcef( id, AL_ROLLOFF_FACTOR, 1.75f ); +} + +// sets modifier applied to the pitch of sounds emitted by the source +void +openal_source::pitch( float const Pitch ) { + + pitch_variation = Pitch; + // invalidate current pitch value to enforce change of next syns + properties.pitch = -1.f; +} + +// toggles looping of the sound emitted by the source +void +openal_source::loop( bool const State ) { + + if( id == audio::null_resource ) { return; } // no implementation-side source to match, no point + if( is_looping == State ) { return; } + + is_looping = State; + ::alSourcei( + id, + AL_LOOPING, + ( State ? + AL_TRUE : + AL_FALSE ) ); +} + +// releases bound buffers and resets state of the class variables +// NOTE: doesn't release allocated implementation-side source +void +openal_source::clear() { + + if( id != audio::null_resource ) { + // unqueue bound buffers: + // ensure no buffer is in use... + stop(); + // ...prepare space for returned ids of unqueued buffers (not that we need that info)... + std::vector bufferids; + bufferids.resize( sounds.size() ); + // ...release the buffers... + ::alSourceUnqueueBuffers( id, bufferids.size(), bufferids.data() ); + } + // ...and reset reset the properties, except for the id of the allocated source + // NOTE: not strictly necessary since except for the id the source data typically get discarded in next step + auto const sourceid { id }; + *this = openal_source(); + id = sourceid; +} + + + +openal_renderer::~openal_renderer() { + + ::alcMakeContextCurrent( nullptr ); + + if( m_context != nullptr ) { ::alcDestroyContext( m_context ); } + if( m_device != nullptr ) { ::alcCloseDevice( m_device ); } +} + +audio::buffer_handle +openal_renderer::fetch_buffer( std::string const &Filename ) { + + return m_buffers.create( Filename ); +} + +// provides direct access to a specified buffer +audio::openal_buffer const & +openal_renderer::buffer( audio::buffer_handle const Buffer ) const { + + return m_buffers.buffer( Buffer ); +} + +// initializes the service +bool +openal_renderer::init() { + + if( true == m_ready ) { + // already initialized and enabled + return true; + } + if( false == init_caps() ) { + // basic initialization failed + return false; + } + ::alDistanceModel( AL_INVERSE_DISTANCE_CLAMPED ); + // all done + m_ready = true; + return true; +} + +// removes from the queue all sounds controlled by the specified sound emitter +void +openal_renderer::erase( sound_source const *Controller ) { + + auto source { std::begin( m_sources ) }; + while( source != std::end( m_sources ) ) { + if( source->controller == Controller ) { + // if the controller is the one specified, kill it + source->clear(); + if( source->id != audio::null_resource ) { + // keep around functional sources, but no point in doing it with the above-the-limit ones + m_sourcespares.push( source->id ); + } + source = m_sources.erase( source ); + } + else { + // otherwise proceed through the list normally + ++source; + } + } +} + +// updates state of all active emitters +void +openal_renderer::update( double const Deltatime ) { + + // update listener + // gain + ::alListenerf( AL_GAIN, clamp( Global.AudioVolume, 0.f, 2.f ) * ( Global.iPause == 0 ? 1.f : 0.15f ) ); + // orientation + glm::dmat4 cameramatrix; + Global.pCamera.SetMatrix( cameramatrix ); + auto rotationmatrix { glm::mat3{ cameramatrix } }; + glm::vec3 const orientation[] = { + glm::vec3{ 0, 0,-1 } * rotationmatrix , + glm::vec3{ 0, 1, 0 } * rotationmatrix }; + ::alListenerfv( AL_ORIENTATION, reinterpret_cast( orientation ) ); + // velocity + if( Deltatime > 0 ) { + glm::dvec3 const listenerposition { Global.pCamera.Pos }; + glm::dvec3 const listenermovement { listenerposition - m_listenerposition }; + m_listenerposition = listenerposition; + m_listenervelocity = ( + glm::length( listenermovement ) < 1000.0 ? // large jumps are typically camera changes + limit_velocity( listenermovement / Deltatime ) : + glm::vec3() ); + ::alListenerfv( AL_VELOCITY, reinterpret_cast( glm::value_ptr( m_listenervelocity ) ) ); + } + + // update active emitters + auto source { std::begin( m_sources ) }; + while( source != std::end( m_sources ) ) { + // update each source + source->update( Deltatime, m_listenervelocity ); + // if after the update the source isn't playing, put it away on the spare stack, it's done + if( false == source->is_playing ) { + source->clear(); + if( source->id != audio::null_resource ) { + // keep around functional sources, but no point in doing it with the above-the-limit ones + m_sourcespares.push( source->id ); + } + source = m_sources.erase( source ); + } + else { + // otherwise proceed through the list normally + ++source; + } + } +} + +// returns an instance of implementation-side part of the sound emitter +audio::openal_source +openal_renderer::fetch_source() { + + audio::openal_source newsource; + if( false == m_sourcespares.empty() ) { + // reuse (a copy of) already allocated source + newsource.id = m_sourcespares.top(); + m_sourcespares.pop(); + } + if( newsource.id == audio::null_resource ) { + // if there's no source to reuse, try to generate a new one + ::alGenSources( 1, &( newsource.id ) ); + } + if( newsource.id == audio::null_resource ) { + // if we still don't have a working source, see if we can sacrifice an already active one + // under presumption it's more important to play new sounds than keep the old ones going + // TBD, TODO: for better results we could use range and/or position for the new sound + // to better weight whether the new sound is really more important + auto leastimportantsource { std::end( m_sources ) }; + auto leastimportantweight { std::numeric_limits::max() }; + + for( auto source { std::begin( m_sources ) }; source != std::cend( m_sources ); ++source ) { + + if( ( source->id == audio::null_resource ) + || ( true == source->is_multipart ) + || ( false == source->is_playing ) ) { + + continue; + } + auto const sourceweight { ( + source->sound_range > 0 ? + ( source->sound_range * source->sound_range ) / ( glm::length2( source->sound_distance ) + 1 ) : + std::numeric_limits::max() ) }; + if( sourceweight < leastimportantweight ) { + leastimportantsource = source; + leastimportantweight = sourceweight; + } + } + if( ( leastimportantsource != std::end( m_sources ) ) + && ( leastimportantweight < 1.f ) ) { + // only accept the candidate if it's outside of its nominal hearing range + leastimportantsource->stop(); + // HACK: dt of 0 is a roundabout way to notify the controller its emitter has stopped + leastimportantsource->update( 0, m_listenervelocity ); + leastimportantsource->clear(); + // we should be now free to grab the id and get rid of the remains + newsource.id = leastimportantsource->id; + m_sources.erase( leastimportantsource ); + } + } + + return newsource; +} + +bool +openal_renderer::init_caps() { + + // NOTE: default value of audio renderer variable is empty string, meaning argument of NULL i.e. 'preferred' device + m_device = ::alcOpenDevice( Global.AudioRenderer.c_str() ); + if( m_device == nullptr ) { + ErrorLog( "Failed to obtain audio device" ); + return false; + } + + ALCint versionmajor, versionminor; + ::alcGetIntegerv( m_device, ALC_MAJOR_VERSION, 1, &versionmajor ); + ::alcGetIntegerv( m_device, ALC_MINOR_VERSION, 1, &versionminor ); + auto const oalversion { std::to_string( versionmajor ) + "." + std::to_string( versionminor ) }; + + WriteLog( + "Audio Renderer: " + std::string { (char *)::alcGetString( m_device, ALC_DEVICE_SPECIFIER ) } + + " OpenAL Version: " + oalversion ); + + WriteLog( "Supported extensions: " + std::string{ (char *)::alcGetString( m_device, ALC_EXTENSIONS ) } ); + + m_context = ::alcCreateContext( m_device, nullptr ); + if( m_context == nullptr ) { + ErrorLog( "Failed to create audio context" ); + return false; + } + + return ( ::alcMakeContextCurrent( m_context ) == AL_TRUE ); +} + +} // audio + +//--------------------------------------------------------------------------- diff --git a/audiorenderer.h b/audiorenderer.h new file mode 100644 index 00000000..dbe95758 --- /dev/null +++ b/audiorenderer.h @@ -0,0 +1,206 @@ +/* +This Source Code Form is subject to the +terms of the Mozilla Public License, v. +2.0. If a copy of the MPL was not +distributed with this file, You can +obtain one at +http://mozilla.org/MPL/2.0/. +*/ + +#pragma once + +#include "audio.h" +#include "resourcemanager.h" +#include "uitranscripts.h" + +class opengl_renderer; +class sound_source; + +using uint32_sequence = std::vector; + +// sound emitter state sync item +struct sound_properties { + glm::dvec3 location; + float gain { 1.f }; + float soundproofing { 1.f }; + std::uintptr_t soundproofing_stamp { ~( std::uintptr_t{ 0 } ) }; + float pitch { 1.f }; +}; + +enum class sync_state { + good, + bad_distance, + bad_resource +}; + +namespace audio { + +// implementation part of the sound emitter +// TODO: generic interface base, for implementations other than openAL +struct openal_source { + + friend class openal_renderer; + +// types + using buffer_sequence = std::vector; + +// members + ALuint id { audio::null_resource }; // associated AL resource + sound_source *controller { nullptr }; // source controller + uint32_sequence sounds; // +// buffer_sequence buffers; // sequence of samples the source will emit + int sound_index { 0 }; // currently queued sample from the buffer sequence + bool sound_change { false }; // indicates currently queued sample has changed + bool is_playing { false }; + bool is_looping { false }; + sound_properties properties; + sync_state sync { sync_state::good }; +// constructors + openal_source() = default; +// methods + template + openal_source & + bind( sound_source *Controller, uint32_sequence Sounds, Iterator_ First, Iterator_ Last ); + // starts playback of queued buffers + void + play(); + // updates state of the source + void + update( double const Deltatime, glm::vec3 const &Listenervelocity ); + // configures state of the source to match the provided set of properties + void + sync_with( sound_properties const &State ); + // stops the playback + void + stop(); + // toggles looping of the sound emitted by the source + void + loop( bool const State ); + // sets max audible distance for sounds emitted by the source + void + range( float const Range ); + // sets modifier applied to the pitch of sounds emitted by the source + void + pitch( float const Pitch ); + // releases bound buffers and resets state of the class variables + // NOTE: doesn't release allocated implementation-side source + void + clear(); + +private: +// members + double update_deltatime; // time delta of most current update + float pitch_variation { 1.f }; // emitter-specific variation of the base pitch + float sound_range { 50.f }; // cached audible range of the emitted samples + glm::vec3 sound_distance; // cached distance between sound and the listener + glm::vec3 sound_velocity; // sound movement vector + bool is_in_range { false }; // helper, indicates the source was recently within audible range + bool is_multipart { false }; // multi-part sounds are kept alive at longer ranges +}; + + + +class openal_renderer { + + friend opengl_renderer; + +public: +// constructors + openal_renderer() = default; +// destructor + ~openal_renderer(); +// methods + // buffer methods + // returns handle to a buffer containing audio data from specified file + audio::buffer_handle + fetch_buffer( std::string const &Filename ); + // provides direct access to a specified buffer + audio::openal_buffer const & + buffer( audio::buffer_handle const Buffer ) const; + // core methods + // initializes the service + bool + init(); + // schedules playback of provided range of samples, under control of the specified sound emitter + template + void + insert( Iterator_ First, Iterator_ Last, sound_source *Controller, uint32_sequence Sounds ) { + m_sources.emplace_back( fetch_source().bind( Controller, Sounds, First, Last ) ); } + // removes from the queue all sounds controlled by the specified sound emitter + void + erase( sound_source const *Controller ); + // updates state of all active emitters + void + update( double const Deltatime ); + +private: +// types + using source_list = std::list; + using source_sequence = std::stack; +// methods + bool + init_caps(); + // returns an instance of implementation-side part of the sound emitter + audio::openal_source + fetch_source(); +// members + ALCdevice * m_device { nullptr }; + ALCcontext * m_context { nullptr }; + bool m_ready { false }; // renderer is initialized and functional + glm::dvec3 m_listenerposition; + glm::vec3 m_listenervelocity; + + buffer_manager m_buffers; + // TBD: list of sources as vector, sorted by distance, for openal implementations with limited number of active sources? + source_list m_sources; + source_sequence m_sourcespares; // already created and currently unused sound sources +}; + +extern openal_renderer renderer; + + + +template +openal_source & +openal_source::bind( sound_source *Controller, uint32_sequence Sounds, Iterator_ First, Iterator_ Last ) { + + controller = Controller; + sounds = Sounds; + // look up and queue assigned buffers + std::vector buffers; + std::for_each( + First, Last, + [&]( audio::buffer_handle const &bufferhandle ) { + auto const &buffer { audio::renderer.buffer( bufferhandle ) }; + buffers.emplace_back( buffer.id ); + if( false == buffer.caption.empty() ) { + ui::Transcripts.Add( buffer.caption ); } } ); + + if( id != audio::null_resource ) { + ::alSourceQueueBuffers( id, static_cast( buffers.size() ), buffers.data() ); + ::alSourceRewind( id ); + } + is_multipart = ( buffers.size() > 1 ); + + return *this; +} + + + +inline +float +amplitude_to_db( float const Amplitude ) { + + return 20.f * std::log10( Amplitude ); +} + +inline +float +db_to_amplitude( float const Decibels ) { + + return std::pow( 10.f, Decibels / 20.f ); +} + +} // audio + +//--------------------------------------------------------------------------- diff --git a/color.h b/color.h new file mode 100644 index 00000000..1ec63e80 --- /dev/null +++ b/color.h @@ -0,0 +1,124 @@ +#pragma once + +namespace colors { + +glm::vec4 const none{ 0.f, 0.f, 0.f, 1.f }; +glm::vec4 const white{ 1.f, 1.f, 1.f, 1.f }; +glm::vec4 const shadow{ 0.65f, 0.65f, 0.65f, 1.f }; + +inline +glm::vec3 +XYZtoRGB( glm::vec3 const &XYZ ) { + + // M^-1 for Adobe RGB from http://www.brucelindbloom.com/Eqn_RGB_XYZ_Matrix.html + float const mi[ 3 ][ 3 ] = { 2.041369f, -0.969266f, 0.0134474f, -0.5649464f, 1.8760108f, -0.1183897f, -0.3446944f, 0.041556f, 1.0154096f }; + // m^-1 for sRGB: +// float const mi[ 3 ][ 3 ] = { 3.240479f, -0.969256f, 0.055648f, -1.53715f, 1.875991f, -0.204043f, -0.49853f, 0.041556f, 1.057311f }; + + return glm::vec3{ + XYZ.x*mi[ 0 ][ 0 ] + XYZ.y*mi[ 1 ][ 0 ] + XYZ.z*mi[ 2 ][ 0 ], + XYZ.x*mi[ 0 ][ 1 ] + XYZ.y*mi[ 1 ][ 1 ] + XYZ.z*mi[ 2 ][ 1 ], + XYZ.x*mi[ 0 ][ 2 ] + XYZ.y*mi[ 1 ][ 2 ] + XYZ.z*mi[ 2 ][ 2 ] }; +} + +inline +glm::vec3 +RGBtoHSV( glm::vec3 const &RGB ) { + + glm::vec3 hsv; + + float const max = std::max( std::max( RGB.r, RGB.g ), RGB.b ); + float const min = std::min( std::min( RGB.r, RGB.g ), RGB.b ); + float const delta = max - min; + + hsv.z = max; // v + if( delta < 0.00001 ) { + hsv.y = 0; + hsv.x = 0; // undefined, maybe nan? + return hsv; + } + if( max > 0.0 ) { // NOTE: if Max is == 0, this divide would cause a crash + hsv.y = ( delta / max ); // s + } + else { + // if max is 0, then r = g = b = 0 + // s = 0, v is undefined + hsv.y = 0.0; + hsv.x = NAN; // its now undefined + return hsv; + } + if( RGB.r >= max ) // > is bogus, just keeps compilor happy + hsv.x = ( RGB.g - RGB.b ) / delta; // between yellow & magenta + else + if( RGB.g >= max ) + hsv.x = 2.f + ( RGB.g - RGB.r ) / delta; // between cyan & yellow + else + hsv.x = 4.f + ( RGB.r - RGB.g ) / delta; // between magenta & cyan + + hsv.x *= 60.0; // degrees + + if( hsv.x < 0.0 ) + hsv.x += 360.0; + + return hsv; +} + +inline +glm::vec3 +HSVtoRGB( glm::vec3 const &HSV ) { + + glm::vec3 rgb; + + if( HSV.y <= 0.0 ) { // < is bogus, just shuts up warnings + rgb.r = HSV.z; + rgb.g = HSV.z; + rgb.b = HSV.z; + return rgb; + } + float hh = HSV.x; + if( hh >= 360.0 ) hh = 0.0; + hh /= 60.0; + int const i = (int)hh; + float const ff = hh - i; + float const p = HSV.z * ( 1.f - HSV.y ); + float const q = HSV.z * ( 1.f - ( HSV.y * ff ) ); + float const t = HSV.z * ( 1.f - ( HSV.y * ( 1.f - ff ) ) ); + + switch( i ) { + case 0: + rgb.r = HSV.z; + rgb.g = t; + rgb.b = p; + break; + case 1: + rgb.r = q; + rgb.g = HSV.z; + rgb.b = p; + break; + case 2: + rgb.r = p; + rgb.g = HSV.z; + rgb.b = t; + break; + + case 3: + rgb.r = p; + rgb.g = q; + rgb.b = HSV.z; + break; + case 4: + rgb.r = t; + rgb.g = p; + rgb.b = HSV.z; + break; + case 5: + default: + rgb.r = HSV.z; + rgb.g = p; + rgb.b = q; + break; + } + return rgb; +} + +} // namespace colors diff --git a/combustionengine.cpp b/combustionengine.cpp new file mode 100644 index 00000000..d751f06d --- /dev/null +++ b/combustionengine.cpp @@ -0,0 +1,13 @@ +/* +This Source Code Form is subject to the +terms of the Mozilla Public License, v. +2.0. If a copy of the MPL was not +distributed with this file, You can +obtain one at +http://mozilla.org/MPL/2.0/. +*/ + +#include "stdafx.h" +#include "combustionengine.h" + +//--------------------------------------------------------------------------- diff --git a/combustionengine.h b/combustionengine.h new file mode 100644 index 00000000..07a378bd --- /dev/null +++ b/combustionengine.h @@ -0,0 +1,20 @@ +/* +This Source Code Form is subject to the +terms of the Mozilla Public License, v. +2.0. If a copy of the MPL was not +distributed with this file, You can +obtain one at +http://mozilla.org/MPL/2.0/. +*/ + +#pragma once + +// basic approximation of a fuel pump +// TODO: fuel consumption, optional automatic engine start after activation +struct fuel_pump { + + bool is_enabled { false }; // device is allowed/requested to operate + bool is_active { false }; // device is working +}; + +//--------------------------------------------------------------------------- diff --git a/command.cpp b/command.cpp new file mode 100644 index 00000000..6edade69 --- /dev/null +++ b/command.cpp @@ -0,0 +1,308 @@ +/* +This Source Code Form is subject to the +terms of the Mozilla Public License, v. +2.0. If a copy of the MPL was not +distributed with this file, You can +obtain one at +http://mozilla.org/MPL/2.0/. +*/ + +#include "stdafx.h" +#include "command.h" + +#include "globals.h" +#include "logs.h" +#include "timer.h" +#include "utilities.h" + +namespace simulation { + +command_queue Commands; +commanddescription_sequence Commands_descriptions = { + + { "aidriverenable", command_target::vehicle }, + { "aidriverdisable", command_target::vehicle }, + { "mastercontrollerincrease", command_target::vehicle }, + { "mastercontrollerincreasefast", command_target::vehicle }, + { "mastercontrollerdecrease", command_target::vehicle }, + { "mastercontrollerdecreasefast", command_target::vehicle }, + { "mastercontrollerset", command_target::vehicle }, + { "secondcontrollerincrease", command_target::vehicle }, + { "secondcontrollerincreasefast", command_target::vehicle }, + { "secondcontrollerdecrease", command_target::vehicle }, + { "secondcontrollerdecreasefast", command_target::vehicle }, + { "secondcontrollerset", command_target::vehicle }, + { "mucurrentindicatorothersourceactivate", command_target::vehicle }, + { "independentbrakeincrease", command_target::vehicle }, + { "independentbrakeincreasefast", command_target::vehicle }, + { "independentbrakedecrease", command_target::vehicle }, + { "independentbrakedecreasefast", command_target::vehicle }, + { "independentbrakeset", command_target::vehicle }, + { "independentbrakebailoff", command_target::vehicle }, + { "trainbrakeincrease", command_target::vehicle }, + { "trainbrakedecrease", command_target::vehicle }, + { "trainbrakeset", command_target::vehicle }, + { "trainbrakecharging", command_target::vehicle }, + { "trainbrakerelease", command_target::vehicle }, + { "trainbrakefirstservice", command_target::vehicle }, + { "trainbrakeservice", command_target::vehicle }, + { "trainbrakefullservice", command_target::vehicle }, + { "trainbrakehandleoff", command_target::vehicle }, + { "trainbrakeemergency", command_target::vehicle }, + { "trainbrakebasepressureincrease", command_target::vehicle }, + { "trainbrakebasepressuredecrease", command_target::vehicle }, + { "trainbrakebasepressurereset", command_target::vehicle }, + { "trainbrakeoperationtoggle", command_target::vehicle }, + { "manualbrakeincrease", command_target::vehicle }, + { "manualbrakedecrease", command_target::vehicle }, + { "alarmchaintoggle", command_target::vehicle }, + { "wheelspinbrakeactivate", command_target::vehicle }, + { "sandboxactivate", command_target::vehicle }, + { "reverserincrease", command_target::vehicle }, + { "reverserdecrease", command_target::vehicle }, + { "reverserforwardhigh", command_target::vehicle }, + { "reverserforward", command_target::vehicle }, + { "reverserneutral", command_target::vehicle }, + { "reverserbackward", command_target::vehicle }, + { "waterpumpbreakertoggle", command_target::vehicle }, + { "waterpumpbreakerclose", command_target::vehicle }, + { "waterpumpbreakeropen", command_target::vehicle }, + { "waterpumptoggle", command_target::vehicle }, + { "waterpumpenable", command_target::vehicle }, + { "waterpumpdisable", command_target::vehicle }, + { "waterheaterbreakertoggle", command_target::vehicle }, + { "waterheaterbreakerclose", command_target::vehicle }, + { "waterheaterbreakeropen", command_target::vehicle }, + { "waterheatertoggle", command_target::vehicle }, + { "waterheaterenable", command_target::vehicle }, + { "waterheaterdisable", command_target::vehicle }, + { "watercircuitslinktoggle", command_target::vehicle }, + { "watercircuitslinkenable", command_target::vehicle }, + { "watercircuitslinkdisable", command_target::vehicle }, + { "fuelpumptoggle", command_target::vehicle }, + { "fuelpumpenable", command_target::vehicle }, + { "fuelpumpdisable", command_target::vehicle }, + { "oilpumptoggle", command_target::vehicle }, + { "oilpumpenable", command_target::vehicle }, + { "oilpumpdisable", command_target::vehicle }, + { "linebreakertoggle", command_target::vehicle }, + { "linebreakeropen", command_target::vehicle }, + { "linebreakerclose", command_target::vehicle }, + { "convertertoggle", command_target::vehicle }, + { "converterenable", command_target::vehicle }, + { "converterdisable", command_target::vehicle }, + { "convertertogglelocal", command_target::vehicle }, + { "converteroverloadrelayreset", command_target::vehicle }, + { "compressortoggle", command_target::vehicle }, + { "compressorenable", command_target::vehicle }, + { "compressordisable", command_target::vehicle }, + { "compressortogglelocal", command_target::vehicle }, + { "motoroverloadrelaythresholdtoggle", command_target::vehicle }, + { "motoroverloadrelaythresholdsetlow", command_target::vehicle }, + { "motoroverloadrelaythresholdsethigh", command_target::vehicle }, + { "motoroverloadrelayreset", command_target::vehicle }, + { "notchingrelaytoggle", command_target::vehicle }, + { "epbrakecontroltoggle", command_target::vehicle }, + { "trainbrakeoperationmodeincrease", command_target::vehicle }, + { "trainbrakeoperationmodedecrease", command_target::vehicle }, + { "brakeactingspeedincrease", command_target::vehicle }, + { "brakeactingspeeddecrease", command_target::vehicle }, + { "brakeactingspeedsetcargo", command_target::vehicle }, + { "brakeactingspeedsetpassenger", command_target::vehicle }, + { "brakeactingspeedsetrapid", command_target::vehicle }, + { "brakeloadcompensationincrease", command_target::vehicle }, + { "brakeloadcompensationdecrease", command_target::vehicle }, + { "mubrakingindicatortoggle", command_target::vehicle }, + { "alerteracknowledge", command_target::vehicle }, + { "hornlowactivate", command_target::vehicle }, + { "hornhighactivate", command_target::vehicle }, + { "whistleactivate", command_target::vehicle }, + { "radiotoggle", command_target::vehicle }, + { "radiochannelincrease", command_target::vehicle }, + { "radiochanneldecrease", command_target::vehicle }, + { "radiostopsend", command_target::vehicle }, + { "radiostoptest", command_target::vehicle }, + // TBD, TODO: make cab change controls entity-centric + { "cabchangeforward", command_target::vehicle }, + { "cabchangebackward", command_target::vehicle }, + + { "viewturn", command_target::entity }, + { "movehorizontal", command_target::entity }, + { "movehorizontalfast", command_target::entity }, + { "movevertical", command_target::entity }, + { "moveverticalfast", command_target::entity }, + { "moveleft", command_target::entity }, + { "moveright", command_target::entity }, + { "moveforward", command_target::entity }, + { "moveback", command_target::entity }, + { "moveup", command_target::entity }, + { "movedown", command_target::entity }, + // TBD, TODO: make coupling controls entity-centric + { "carcouplingincrease", command_target::vehicle }, + { "carcouplingdisconnect", command_target::vehicle }, + { "doortoggleleft", command_target::vehicle }, + { "doortoggleright", command_target::vehicle }, + { "dooropenleft", command_target::vehicle }, + { "dooropenright", command_target::vehicle }, + { "doorcloseleft", command_target::vehicle }, + { "doorcloseright", command_target::vehicle }, + { "doorcloseall", command_target::vehicle }, + { "departureannounce", command_target::vehicle }, + { "doorlocktoggle", command_target::vehicle }, + { "pantographcompressorvalvetoggle", command_target::vehicle }, + { "pantographcompressoractivate", command_target::vehicle }, + { "pantographtogglefront", command_target::vehicle }, + { "pantographtogglerear", command_target::vehicle }, + { "pantographraisefront", command_target::vehicle }, + { "pantographraiserear", command_target::vehicle }, + { "pantographlowerfront", command_target::vehicle }, + { "pantographlowerrear", command_target::vehicle }, + { "pantographlowerall", command_target::vehicle }, + { "heatingtoggle", command_target::vehicle }, + { "heatingenable", command_target::vehicle }, + { "heatingdisable", command_target::vehicle }, + { "lightspresetactivatenext", command_target::vehicle }, + { "lightspresetactivateprevious", command_target::vehicle }, + { "headlighttoggleleft", command_target::vehicle }, + { "headlightenableleft", command_target::vehicle }, + { "headlightdisableleft", command_target::vehicle }, + { "headlighttoggleright", command_target::vehicle }, + { "headlightenableright", command_target::vehicle }, + { "headlightdisableright", command_target::vehicle }, + { "headlighttoggleupper", command_target::vehicle }, + { "headlightenableupper", command_target::vehicle }, + { "headlightdisableupper", command_target::vehicle }, + { "redmarkertoggleleft", command_target::vehicle }, + { "redmarkerenableleft", command_target::vehicle }, + { "redmarkerdisableleft", command_target::vehicle }, + { "redmarkertoggleright", command_target::vehicle }, + { "redmarkerenableright", command_target::vehicle }, + { "redmarkerdisableright", command_target::vehicle }, + { "headlighttogglerearleft", command_target::vehicle }, + { "headlighttogglerearright", command_target::vehicle }, + { "headlighttogglerearupper", command_target::vehicle }, + { "redmarkertogglerearleft", command_target::vehicle }, + { "redmarkertogglerearright", command_target::vehicle }, + { "redmarkerstoggle", command_target::vehicle }, + { "endsignalstoggle", command_target::vehicle }, + { "headlightsdimtoggle", command_target::vehicle }, + { "headlightsdimenable", command_target::vehicle }, + { "headlightsdimdisable", command_target::vehicle }, + { "motorconnectorsopen", command_target::vehicle }, + { "motorconnectorsclose", command_target::vehicle }, + { "motordisconnect", command_target::vehicle }, + { "interiorlighttoggle", command_target::vehicle }, + { "interiorlightenable", command_target::vehicle }, + { "interiorlightdisable", command_target::vehicle }, + { "interiorlightdimtoggle", command_target::vehicle }, + { "interiorlightdimenable", command_target::vehicle }, + { "interiorlightdimdisable", command_target::vehicle }, + { "instrumentlighttoggle", command_target::vehicle }, + { "instrumentlightenable", command_target::vehicle }, + { "instrumentlightdisable", command_target::vehicle }, + { "dashboardlighttoggle", command_target::vehicle }, + { "timetablelighttoggle", command_target::vehicle }, + { "generictoggle0", command_target::vehicle }, + { "generictoggle1", command_target::vehicle }, + { "generictoggle2", command_target::vehicle }, + { "generictoggle3", command_target::vehicle }, + { "generictoggle4", command_target::vehicle }, + { "generictoggle5", command_target::vehicle }, + { "generictoggle6", command_target::vehicle }, + { "generictoggle7", command_target::vehicle }, + { "generictoggle8", command_target::vehicle }, + { "generictoggle9", command_target::vehicle }, + { "batterytoggle", command_target::vehicle }, + { "batteryenable", command_target::vehicle }, + { "batterydisable", command_target::vehicle }, + { "motorblowerstogglefront", command_target::vehicle }, + { "motorblowerstogglerear", command_target::vehicle }, + { "motorblowersdisableall", command_target::vehicle } + +}; + +} // simulation + +// posts specified command for specified recipient +void +command_queue::push( command_data const &Command, std::size_t const Recipient ) { + + auto lookup = m_commands.emplace( Recipient, commanddata_sequence() ); + // recipient stack was either located or created, so we can add to it quite safely + lookup.first->second.emplace( Command ); +} + +// retrieves oldest posted command for specified recipient, if any. returns: true on retrieval, false if there's nothing to retrieve +bool +command_queue::pop( command_data &Command, std::size_t const Recipient ) { + + auto lookup = m_commands.find( Recipient ); + if( lookup == m_commands.end() ) { + // no command stack for this recipient, so no commands + return false; + } + auto &commands = lookup->second; + if( true == commands.empty() ) { + + return false; + } + // we have command stack with command(s) on it, retrieve and pop the first one + Command = commands.front(); + commands.pop(); + + return true; +} + +void +command_relay::post( user_command const Command, double const Param1, double const Param2, int const Action, std::uint16_t const Recipient ) const { + + auto const &command = simulation::Commands_descriptions[ static_cast( Command ) ]; + if( ( command.target == command_target::vehicle ) + && ( true == FreeFlyModeFlag ) + && ( ( false == DebugModeFlag ) + && ( true == Global.RealisticControlMode ) ) ) { + // in realistic control mode don't pass vehicle commands if the user isn't in one, unless we're in debug mode + return; + } + + simulation::Commands.push( + command_data{ + Command, + Action, + Param1, + Param2, + Timer::GetDeltaTime() }, + static_cast( command.target ) | Recipient ); +/* +#ifdef _DEBUG + if( Action != GLFW_RELEASE ) { + // key was pressed or is still held + if( false == command.name.empty() ) { + if( false == ( + ( Command == user_command::moveleft ) + || ( Command == user_command::moveleftfast ) + || ( Command == user_command::moveright ) + || ( Command == user_command::moverightfast ) + || ( Command == user_command::moveforward ) + || ( Command == user_command::moveforwardfast ) + || ( Command == user_command::moveback ) + || ( Command == user_command::movebackfast ) + || ( Command == user_command::moveup ) + || ( Command == user_command::moveupfast ) + || ( Command == user_command::movedown ) + || ( Command == user_command::movedownfast ) + || ( Command == user_command::movevector ) + || ( Command == user_command::viewturn ) ) ) { + WriteLog( "Command issued: " + command.name ); + } + } + } + else { + // key was released (but we don't log this) + WriteLog( "Key released: " + command.name ); + } +#endif +*/ +} + +//--------------------------------------------------------------------------- diff --git a/command.h b/command.h new file mode 100644 index 00000000..5f34b6fd --- /dev/null +++ b/command.h @@ -0,0 +1,302 @@ +/* +This Source Code Form is subject to the +terms of the Mozilla Public License, v. +2.0. If a copy of the MPL was not +distributed with this file, You can +obtain one at +http://mozilla.org/MPL/2.0/. +*/ + +#pragma once + +#include +#include + +enum class user_command { + + aidriverenable, + aidriverdisable, + mastercontrollerincrease, + mastercontrollerincreasefast, + mastercontrollerdecrease, + mastercontrollerdecreasefast, + mastercontrollerset, + secondcontrollerincrease, + secondcontrollerincreasefast, + secondcontrollerdecrease, + secondcontrollerdecreasefast, + secondcontrollerset, + mucurrentindicatorothersourceactivate, + independentbrakeincrease, + independentbrakeincreasefast, + independentbrakedecrease, + independentbrakedecreasefast, + independentbrakeset, + independentbrakebailoff, + trainbrakeincrease, + trainbrakedecrease, + trainbrakeset, + trainbrakecharging, + trainbrakerelease, + trainbrakefirstservice, + trainbrakeservice, + trainbrakefullservice, + trainbrakehandleoff, + trainbrakeemergency, + trainbrakebasepressureincrease, + trainbrakebasepressuredecrease, + trainbrakebasepressurereset, + trainbrakeoperationtoggle, + manualbrakeincrease, + manualbrakedecrease, + alarmchaintoggle, + wheelspinbrakeactivate, + sandboxactivate, + reverserincrease, + reverserdecrease, + reverserforwardhigh, + reverserforward, + reverserneutral, + reverserbackward, + waterpumpbreakertoggle, + waterpumpbreakerclose, + waterpumpbreakeropen, + waterpumptoggle, + waterpumpenable, + waterpumpdisable, + waterheaterbreakertoggle, + waterheaterbreakerclose, + waterheaterbreakeropen, + waterheatertoggle, + waterheaterenable, + waterheaterdisable, + watercircuitslinktoggle, + watercircuitslinkenable, + watercircuitslinkdisable, + fuelpumptoggle, + fuelpumpenable, + fuelpumpdisable, + oilpumptoggle, + oilpumpenable, + oilpumpdisable, + linebreakertoggle, + linebreakeropen, + linebreakerclose, + convertertoggle, + converterenable, + converterdisable, + convertertogglelocal, + converteroverloadrelayreset, + compressortoggle, + compressorenable, + compressordisable, + compressortogglelocal, + motoroverloadrelaythresholdtoggle, + motoroverloadrelaythresholdsetlow, + motoroverloadrelaythresholdsethigh, + motoroverloadrelayreset, + notchingrelaytoggle, + epbrakecontroltoggle, + trainbrakeoperationmodeincrease, + trainbrakeoperationmodedecrease, + brakeactingspeedincrease, + brakeactingspeeddecrease, + brakeactingspeedsetcargo, + brakeactingspeedsetpassenger, + brakeactingspeedsetrapid, + brakeloadcompensationincrease, + brakeloadcompensationdecrease, + mubrakingindicatortoggle, + alerteracknowledge, + hornlowactivate, + hornhighactivate, + whistleactivate, + radiotoggle, + radiochannelincrease, + radiochanneldecrease, + radiostopsend, + radiostoptest, + cabchangeforward, + cabchangebackward, + + viewturn, + movehorizontal, + movehorizontalfast, + movevertical, + moveverticalfast, + moveleft, + moveright, + moveforward, + moveback, + moveup, + movedown, + + carcouplingincrease, + carcouplingdisconnect, + doortoggleleft, + doortoggleright, + dooropenleft, + dooropenright, + doorcloseleft, + doorcloseright, + doorcloseall, + departureannounce, + doorlocktoggle, + pantographcompressorvalvetoggle, + pantographcompressoractivate, + pantographtogglefront, + pantographtogglerear, + pantographraisefront, + pantographraiserear, + pantographlowerfront, + pantographlowerrear, + pantographlowerall, + heatingtoggle, + heatingenable, + heatingdisable, + lightspresetactivatenext, + lightspresetactivateprevious, + headlighttoggleleft, + headlightenableleft, + headlightdisableleft, + headlighttoggleright, + headlightenableright, + headlightdisableright, + headlighttoggleupper, + headlightenableupper, + headlightdisableupper, + redmarkertoggleleft, + redmarkerenableleft, + redmarkerdisableleft, + redmarkertoggleright, + redmarkerenableright, + redmarkerdisableright, + headlighttogglerearleft, + headlighttogglerearright, + headlighttogglerearupper, + redmarkertogglerearleft, + redmarkertogglerearright, + redmarkerstoggle, + endsignalstoggle, + headlightsdimtoggle, + headlightsdimenable, + headlightsdimdisable, + motorconnectorsopen, + motorconnectorsclose, + motordisconnect, + interiorlighttoggle, + interiorlightenable, + interiorlightdisable, + interiorlightdimtoggle, + interiorlightdimenable, + interiorlightdimdisable, + instrumentlighttoggle, + instrumentlightenable, + instrumentlightdisable, + dashboardlighttoggle, + timetablelighttoggle, + generictoggle0, + generictoggle1, + generictoggle2, + generictoggle3, + generictoggle4, + generictoggle5, + generictoggle6, + generictoggle7, + generictoggle8, + generictoggle9, + batterytoggle, + batteryenable, + batterydisable, + motorblowerstogglefront, + motorblowerstogglerear, + motorblowersdisableall, + + none = -1 +}; + +enum class command_target { + + userinterface, + simulation, +/* + // NOTE: there's no need for consist- and unit-specific commands at this point, but it's a possibility. + // since command targets are mutually exclusive these don't reduce ranges for individual vehicles etc + consist = 0x4000, + unit = 0x8000, +*/ + // values are combined with object id. 0xffff objects of each type should be quite enough ("for everyone") + vehicle = 0x10000, + signal = 0x20000, + entity = 0x40000 +}; + +struct command_description { + + std::string name; + command_target target; +}; + +struct command_data { + + user_command command; + int action; // press, repeat or release + double param1; + double param2; + double time_delta; +}; + +// command_queues: collects and holds commands from input sources, for processing by their intended recipients +// NOTE: this won't scale well. +// TODO: turn it into a dispatcher and build individual command sequences into the items, where they can be examined without lookups + +class command_queue { + +public: +// methods + // posts specified command for specified recipient + void + push( command_data const &Command, std::size_t const Recipient ); + // retrieves oldest posted command for specified recipient, if any. returns: true on retrieval, false if there's nothing to retrieve + bool + pop( command_data &Command, std::size_t const Recipient ); + +private: +// types + typedef std::queue commanddata_sequence; + typedef std::unordered_map commanddatasequence_map; +// members + commanddatasequence_map m_commands; + +}; + +// NOTE: simulation should be a (light) wrapper rather than namespace so we could potentially instance it, +// but realistically it's not like we're going to run more than one simulation at a time +namespace simulation { + +typedef std::vector commanddescription_sequence; + +extern command_queue Commands; +// TODO: add name to command map, and wrap these two into helper object +extern commanddescription_sequence Commands_descriptions; + +} + +// command_relay: composite class component, passes specified command to appropriate command stack + +class command_relay { + +public: +// constructors +// methods + // posts specified command for the specified recipient + // TODO: replace uint16_t with recipient handle, based on item id + void + post( user_command const Command, double const Param1, double const Param2, + int const Action, std::uint16_t const Recipient ) const; +private: +// types +// members +}; + +//--------------------------------------------------------------------------- diff --git a/driverkeyboardinput.cpp b/driverkeyboardinput.cpp new file mode 100644 index 00000000..ae8aab93 --- /dev/null +++ b/driverkeyboardinput.cpp @@ -0,0 +1,227 @@ +/* +This Source Code Form is subject to the +terms of the Mozilla Public License, v. +2.0. If a copy of the MPL was not +distributed with this file, You can +obtain one at +http://mozilla.org/MPL/2.0/. +*/ + +#include "stdafx.h" +#include "driverkeyboardinput.h" + +bool +driverkeyboard_input::init() { + + default_bindings(); + recall_bindings(); + bind(); + m_bindingsetups.clear(); + + return true; +} + +void +driverkeyboard_input::default_bindings() { + + m_bindingsetups = { + { user_command::aidriverenable, GLFW_KEY_Q | keymodifier::shift }, + { user_command::aidriverdisable, GLFW_KEY_Q }, + { user_command::mastercontrollerincrease, GLFW_KEY_KP_ADD }, + { user_command::mastercontrollerincreasefast, GLFW_KEY_KP_ADD | keymodifier::shift }, + { user_command::mastercontrollerdecrease, GLFW_KEY_KP_SUBTRACT }, + { user_command::mastercontrollerdecreasefast, GLFW_KEY_KP_SUBTRACT | keymodifier::shift }, + // mastercontrollerset, + { user_command::secondcontrollerincrease, GLFW_KEY_KP_DIVIDE }, + { user_command::secondcontrollerincreasefast, GLFW_KEY_KP_DIVIDE | keymodifier::shift }, + { user_command::secondcontrollerdecrease, GLFW_KEY_KP_MULTIPLY }, + { user_command::secondcontrollerdecreasefast, GLFW_KEY_KP_MULTIPLY | keymodifier::shift }, + // secondcontrollerset, + { user_command::mucurrentindicatorothersourceactivate, GLFW_KEY_Z | keymodifier::shift }, + { user_command::independentbrakeincrease, GLFW_KEY_KP_1 }, + { user_command::independentbrakeincreasefast, GLFW_KEY_KP_1 | keymodifier::shift }, + { user_command::independentbrakedecrease, GLFW_KEY_KP_7 }, + { user_command::independentbrakedecreasefast, GLFW_KEY_KP_7 | keymodifier::shift }, + // independentbrakeset, + { user_command::independentbrakebailoff, GLFW_KEY_KP_4 }, + { user_command::trainbrakeincrease, GLFW_KEY_KP_3 }, + { user_command::trainbrakedecrease, GLFW_KEY_KP_9 }, + // trainbrakeset, + { user_command::trainbrakecharging, GLFW_KEY_KP_DECIMAL }, + { user_command::trainbrakerelease, GLFW_KEY_KP_6 }, + { user_command::trainbrakefirstservice, GLFW_KEY_KP_8 }, + { user_command::trainbrakeservice, GLFW_KEY_KP_5 }, + { user_command::trainbrakefullservice, GLFW_KEY_KP_2 }, + { user_command::trainbrakehandleoff, GLFW_KEY_KP_5 | keymodifier::control }, + { user_command::trainbrakeemergency, GLFW_KEY_KP_0 }, + { user_command::trainbrakebasepressureincrease, GLFW_KEY_KP_3 | keymodifier::control }, + { user_command::trainbrakebasepressuredecrease, GLFW_KEY_KP_9 | keymodifier::control }, + { user_command::trainbrakebasepressurereset, GLFW_KEY_KP_6 | keymodifier::control }, + { user_command::trainbrakeoperationtoggle, GLFW_KEY_KP_4 | keymodifier::control }, + { user_command::manualbrakeincrease, GLFW_KEY_KP_1 | keymodifier::control }, + { user_command::manualbrakedecrease, GLFW_KEY_KP_7 | keymodifier::control }, + { user_command::alarmchaintoggle, GLFW_KEY_B | keymodifier::shift | keymodifier::control }, + { user_command::wheelspinbrakeactivate, GLFW_KEY_KP_ENTER }, + { user_command::sandboxactivate, GLFW_KEY_S | keymodifier::shift }, + { user_command::reverserincrease, GLFW_KEY_D }, + { user_command::reverserdecrease, GLFW_KEY_R }, + // reverserforwardhigh, + // reverserforward, + // reverserneutral, + // reverserbackward, + { user_command::waterpumpbreakertoggle, GLFW_KEY_W | keymodifier::control }, + // waterpumpbreakerclose, + // waterpumpbreakeropen, + { user_command::waterpumptoggle, GLFW_KEY_W }, + // waterpumpenable, + // waterpumpdisable, + { user_command::waterheaterbreakertoggle, GLFW_KEY_W | keymodifier::control | keymodifier::shift }, + // waterheaterbreakerclose, + // waterheaterbreakeropen, + { user_command::waterheatertoggle, GLFW_KEY_W | keymodifier::shift }, + // waterheaterenable, + // waterheaterdisable, + { user_command::watercircuitslinktoggle, GLFW_KEY_H | keymodifier::shift }, + // watercircuitslinkenable, + // watercircuitslinkdisable, + { user_command::fuelpumptoggle, GLFW_KEY_F }, + // fuelpumpenable, + // fuelpumpdisable, + { user_command::oilpumptoggle, GLFW_KEY_F | keymodifier::shift }, + // oilpumpenable, + // oilpumpdisable, + { user_command::linebreakertoggle, GLFW_KEY_M }, + // linebreakeropen, + // linebreakerclose, + { user_command::convertertoggle, GLFW_KEY_X }, + // converterenable, + // converterdisable, + { user_command::convertertogglelocal, GLFW_KEY_X | keymodifier::shift }, + { user_command::converteroverloadrelayreset, GLFW_KEY_N | keymodifier::control }, + { user_command::compressortoggle, GLFW_KEY_C }, + // compressorenable, + // compressordisable, + { user_command::compressortogglelocal, GLFW_KEY_C | keymodifier::shift }, + { user_command::motoroverloadrelaythresholdtoggle, GLFW_KEY_F | keymodifier::control }, + // motoroverloadrelaythresholdsetlow, + // motoroverloadrelaythresholdsethigh, + { user_command::motoroverloadrelayreset, GLFW_KEY_N }, + { user_command::notchingrelaytoggle, GLFW_KEY_G }, + { user_command::epbrakecontroltoggle, GLFW_KEY_Z | keymodifier::control }, + { user_command::trainbrakeoperationmodeincrease, GLFW_KEY_KP_2 | keymodifier::control }, + { user_command::trainbrakeoperationmodedecrease, GLFW_KEY_KP_8 | keymodifier::control }, + { user_command::brakeactingspeedincrease, GLFW_KEY_B | keymodifier::shift }, + { user_command::brakeactingspeeddecrease, GLFW_KEY_B }, + // brakeactingspeedsetcargo, + // brakeactingspeedsetpassenger, + // brakeactingspeedsetrapid, + { user_command::brakeloadcompensationincrease, GLFW_KEY_H | keymodifier::shift | keymodifier::control }, + { user_command::brakeloadcompensationdecrease, GLFW_KEY_H | keymodifier::control }, + { user_command::mubrakingindicatortoggle, GLFW_KEY_L | keymodifier::shift }, + { user_command::alerteracknowledge, GLFW_KEY_SPACE }, + { user_command::hornlowactivate, GLFW_KEY_A }, + { user_command::hornhighactivate, GLFW_KEY_S }, + { user_command::whistleactivate, GLFW_KEY_Z }, + { user_command::radiotoggle, GLFW_KEY_R | keymodifier::control }, + { user_command::radiochannelincrease, GLFW_KEY_R | keymodifier::shift }, + { user_command::radiochanneldecrease, GLFW_KEY_R }, + { user_command::radiostopsend, GLFW_KEY_PAUSE | keymodifier::shift | keymodifier::control }, + { user_command::radiostoptest, GLFW_KEY_R | keymodifier::shift | keymodifier::control }, + { user_command::cabchangeforward, GLFW_KEY_HOME }, + { user_command::cabchangebackward, GLFW_KEY_END }, + // viewturn, + // movehorizontal, + // movehorizontalfast, + // movevertical, + // moveverticalfast, + { user_command::moveleft, GLFW_KEY_LEFT }, + { user_command::moveright, GLFW_KEY_RIGHT }, + { user_command::moveforward, GLFW_KEY_UP }, + { user_command::moveback, GLFW_KEY_DOWN }, + { user_command::moveup, GLFW_KEY_PAGE_UP }, + { user_command::movedown, GLFW_KEY_PAGE_DOWN }, + { user_command::carcouplingincrease, GLFW_KEY_INSERT }, + { user_command::carcouplingdisconnect, GLFW_KEY_DELETE }, + { user_command::doortoggleleft, GLFW_KEY_COMMA }, + { user_command::doortoggleright, GLFW_KEY_PERIOD }, + // dooropenleft, + // dooropenright, + // doorcloseleft, + // doorcloseright, + { user_command::doorcloseall, GLFW_KEY_SLASH | keymodifier::control }, + { user_command::departureannounce, GLFW_KEY_SLASH }, + { user_command::doorlocktoggle, GLFW_KEY_S | keymodifier::control }, + { user_command::pantographcompressorvalvetoggle, GLFW_KEY_V | keymodifier::control }, + { user_command::pantographcompressoractivate, GLFW_KEY_V | keymodifier::shift }, + { user_command::pantographtogglefront, GLFW_KEY_P }, + { user_command::pantographtogglerear, GLFW_KEY_O }, + // pantographraisefront, + // pantographraiserear, + // pantographlowerfront, + // pantographlowerrear, + { user_command::pantographlowerall, GLFW_KEY_P | keymodifier::control }, + { user_command::heatingtoggle, GLFW_KEY_H }, + // heatingenable, + // heatingdisable, + { user_command::lightspresetactivatenext, GLFW_KEY_T | keymodifier::shift }, + { user_command::lightspresetactivateprevious, GLFW_KEY_T }, + { user_command::headlighttoggleleft, GLFW_KEY_Y }, + // headlightenableleft, + // headlightdisableleft, + { user_command::headlighttoggleright, GLFW_KEY_I }, + // headlightenableright, + // headlightdisableright, + { user_command::headlighttoggleupper, GLFW_KEY_U }, + // headlightenableupper, + // headlightdisableupper, + { user_command::redmarkertoggleleft, GLFW_KEY_Y | keymodifier::shift }, + // redmarkerenableleft, + // redmarkerdisableleft, + { user_command::redmarkertoggleright, GLFW_KEY_I | keymodifier::shift }, + // redmarkerenableright, + // redmarkerdisableright, + { user_command::headlighttogglerearleft, GLFW_KEY_Y | keymodifier::control }, + { user_command::headlighttogglerearright, GLFW_KEY_I | keymodifier::control }, + { user_command::headlighttogglerearupper, GLFW_KEY_U | keymodifier::control }, + { user_command::redmarkertogglerearleft, GLFW_KEY_Y | keymodifier::control | keymodifier::shift }, + { user_command::redmarkertogglerearright, GLFW_KEY_I | keymodifier::control | keymodifier::shift }, + { user_command::redmarkerstoggle, GLFW_KEY_E | keymodifier::shift }, + { user_command::endsignalstoggle, GLFW_KEY_E }, + { user_command::headlightsdimtoggle, GLFW_KEY_L | keymodifier::control }, + // headlightsdimenable, + // headlightsdimdisable, + { user_command::motorconnectorsopen, GLFW_KEY_L }, + // motorconnectorsclose, + { user_command::motordisconnect, GLFW_KEY_E | keymodifier::control }, + { user_command::interiorlighttoggle, GLFW_KEY_APOSTROPHE }, + // interiorlightenable, + // interiorlightdisable, + { user_command::interiorlightdimtoggle, GLFW_KEY_APOSTROPHE | keymodifier::control }, + // interiorlightdimenable, + // interiorlightdimdisable, + { user_command::instrumentlighttoggle, GLFW_KEY_SEMICOLON }, + // instrumentlightenable, + // instrumentlightdisable, + // dashboardlighttoggle, + // timetablelighttoggle, + { user_command::generictoggle0, GLFW_KEY_0 }, + { user_command::generictoggle1, GLFW_KEY_1 }, + { user_command::generictoggle2, GLFW_KEY_2 }, + { user_command::generictoggle3, GLFW_KEY_3 }, + { user_command::generictoggle4, GLFW_KEY_4 }, + { user_command::generictoggle5, GLFW_KEY_5 }, + { user_command::generictoggle6, GLFW_KEY_6 }, + { user_command::generictoggle7, GLFW_KEY_7 }, + { user_command::generictoggle8, GLFW_KEY_8 }, + { user_command::generictoggle9, GLFW_KEY_9 }, + { user_command::batterytoggle, GLFW_KEY_J }, + // batteryenable, + // batterydisable, + { user_command::motorblowerstogglefront, GLFW_KEY_N | keymodifier::shift }, + { user_command::motorblowerstogglerear, GLFW_KEY_M | keymodifier::shift }, + { user_command::motorblowersdisableall, GLFW_KEY_M | keymodifier::control } + + }; +} + +//--------------------------------------------------------------------------- diff --git a/driverkeyboardinput.h b/driverkeyboardinput.h new file mode 100644 index 00000000..c18871df --- /dev/null +++ b/driverkeyboardinput.h @@ -0,0 +1,27 @@ +/* +This Source Code Form is subject to the +terms of the Mozilla Public License, v. +2.0. If a copy of the MPL was not +distributed with this file, You can +obtain one at +http://mozilla.org/MPL/2.0/. +*/ + +#pragma once + +#include "keyboardinput.h" + +class driverkeyboard_input : public keyboard_input { + +public: +// methods + bool + init() override; + +protected: +// methods + void + default_bindings(); +}; + +//--------------------------------------------------------------------------- diff --git a/drivermode.cpp b/drivermode.cpp new file mode 100644 index 00000000..cc5d8ce1 --- /dev/null +++ b/drivermode.cpp @@ -0,0 +1,986 @@ +/* +This Source Code Form is subject to the +terms of the Mozilla Public License, v. +2.0. If a copy of the MPL was not +distributed with this file, You can +obtain one at +http://mozilla.org/MPL/2.0/. +*/ + +#include "stdafx.h" +#include "drivermode.h" +#include "driveruilayer.h" + +#include "globals.h" +#include "application.h" +#include "simulation.h" +#include "simulationtime.h" +#include "simulationenvironment.h" +#include "lightarray.h" +#include "train.h" +#include "driver.h" +#include "dynobj.h" +#include "model3d.h" +#include "event.h" +#include "messaging.h" +#include "timer.h" +#include "renderer.h" +#include "utilities.h" +#include "logs.h" + +namespace input { + +user_command command; // currently issued control command, if any + +} + +void +driver_mode::drivermode_input::poll() { + + keyboard.poll(); + if( true == Global.InputMouse ) { + mouse.poll(); + } + if( true == Global.InputGamepad ) { + gamepad.poll(); + } + if( uart != nullptr ) { + uart->poll(); + } + // TBD, TODO: wrap current command in object, include other input sources? + input::command = ( + mouse.command() != user_command::none ? + mouse.command() : + keyboard.command() ); +} + +bool +driver_mode::drivermode_input::init() { + + // initialize input devices + auto result = ( + keyboard.init() + && mouse.init() ); + if( true == Global.InputGamepad ) { + gamepad.init(); + } + if( true == Global.uart_conf.enable ) { + uart = std::make_unique(); + uart->init(); + } +#ifdef _WIN32 + Console::On(); // włączenie konsoli +#endif + + return result; +} + +driver_mode::driver_mode() { + + m_userinterface = std::make_shared(); +} + +// initializes internal data structures of the mode. returns: true on success, false otherwise +bool +driver_mode::init() { + + return m_input.init(); +} + +// mode-specific update of simulation data. returns: false on error, true otherwise +bool +driver_mode::update() { + + Timer::UpdateTimers(Global.iPause != 0); + Timer::subsystem.sim_total.start(); + + double const deltatime = Timer::GetDeltaTime(); // 0.0 gdy pauza + + if( Global.iPause == 0 ) { + // jak pauza, to nie ma po co tego przeliczać + simulation::Time.update( deltatime ); + } + simulation::State.update_clocks(); + simulation::Environment.update(); + + // fixed step, simulation time based updates +// m_primaryupdateaccumulator += dt; // unused for the time being + m_secondaryupdateaccumulator += deltatime; +/* + // NOTE: until we have no physics state interpolation during render, we need to rely on the old code, + // as doing fixed step calculations but flexible step render results in ugly mini jitter + // core routines (physics) + int updatecount = 0; + while( ( m_primaryupdateaccumulator >= m_primaryupdaterate ) + &&( updatecount < 20 ) ) { + // no more than 20 updates per single pass, to keep physics from hogging up all run time + Ground.Update( m_primaryupdaterate, 1 ); + ++updatecount; + m_primaryupdateaccumulator -= m_primaryupdaterate; + } +*/ + int updatecount = 1; + if( deltatime > m_primaryupdaterate ) // normalnie 0.01s + { +/* + // NOTE: experimentally disabled physics update cap + auto const iterations = std::ceil(dt / m_primaryupdaterate); + updatecount = std::min( 20, static_cast( iterations ) ); +*/ + updatecount = std::ceil( deltatime / m_primaryupdaterate ); +/* + // NOTE: changing dt wrecks things further down the code. re-acquire proper value later or cleanup here + dt = dt / iterations; // Ra: fizykę lepiej by było przeliczać ze stałym krokiem +*/ + } + auto const stepdeltatime { deltatime / updatecount }; + // NOTE: updates are limited to 20, but dt is distributed over potentially many more iterations + // this means at count > 20 simulation and render are going to desync. is that right? + // NOTE: experimentally changing this to prevent the desync. + // TODO: test what happens if we hit more than 20 * 0.01 sec slices, i.e. less than 5 fps + Timer::subsystem.sim_dynamics.start(); + if( true == Global.FullPhysics ) { + // mixed calculation mode, steps calculated in ~0.05s chunks + while( updatecount >= 5 ) { + simulation::State.update( stepdeltatime, 5 ); + updatecount -= 5; + } + if( updatecount ) { + simulation::State.update( stepdeltatime, updatecount ); + } + } + else { + // simplified calculation mode; faster but can lead to errors + simulation::State.update( stepdeltatime, updatecount ); + } + Timer::subsystem.sim_dynamics.stop(); + + // secondary fixed step simulation time routines + while( m_secondaryupdateaccumulator >= m_secondaryupdaterate ) { + + // awaria PoKeys mogła włączyć pauzę - przekazać informację + if( Global.iMultiplayer ) // dajemy znać do serwera o wykonaniu + if( iPause != Global.iPause ) { // przesłanie informacji o pauzie do programu nadzorującego + multiplayer::WyslijParam( 5, 3 ); // ramka 5 z czasem i stanem zapauzowania + iPause = Global.iPause; + } + + // fixed step part of the camera update + if( ( simulation::Train != nullptr ) + && ( Camera.Type == TCameraType::tp_Follow ) + && ( false == DebugCameraFlag ) ) { + // jeśli jazda w kabinie, przeliczyć trzeba parametry kamery + simulation::Train->UpdateMechPosition( m_secondaryupdaterate ); + } + + m_secondaryupdateaccumulator -= m_secondaryupdaterate; // these should be inexpensive enough we have no cap + } + + // variable step simulation time routines + + if( ( simulation::Train == nullptr ) && ( false == FreeFlyModeFlag ) ) { + // intercept cases when the driven train got removed after entering portal + InOutKey(); + } + + if( Global.changeDynObj ) { + // ABu zmiana pojazdu - przejście do innego + ChangeDynamic(); + } + + if( simulation::Train != nullptr ) { + TSubModel::iInstance = reinterpret_cast( simulation::Train->Dynamic() ); + simulation::Train->Update( deltatime ); + } + else { + TSubModel::iInstance = 0; + } + + simulation::Events.update(); + simulation::Region->update_events(); + simulation::Lights.update(); + + // render time routines follow: + + auto const deltarealtime = Timer::GetDeltaRenderTime(); // nie uwzględnia pauzowania ani mnożenia czasu + + // fixed step render time routines + + fTime50Hz += deltarealtime; // w pauzie też trzeba zliczać czas, bo przy dużym FPS będzie problem z odczytem ramek + while( fTime50Hz >= 1.0 / 50.0 ) { + Console::Update(); // to i tak trzeba wywoływać + ui::Transcripts.Update(); // obiekt obsługujący stenogramy dźwięków na ekranie + m_userinterface->update(); + // decelerate camera + Camera.Velocity *= 0.65; + if( std::abs( Camera.Velocity.x ) < 0.01 ) { Camera.Velocity.x = 0.0; } + if( std::abs( Camera.Velocity.y ) < 0.01 ) { Camera.Velocity.y = 0.0; } + if( std::abs( Camera.Velocity.z ) < 0.01 ) { Camera.Velocity.z = 0.0; } + // decelerate debug camera too + DebugCamera.Velocity *= 0.65; + if( std::abs( DebugCamera.Velocity.x ) < 0.01 ) { DebugCamera.Velocity.x = 0.0; } + if( std::abs( DebugCamera.Velocity.y ) < 0.01 ) { DebugCamera.Velocity.y = 0.0; } + if( std::abs( DebugCamera.Velocity.z ) < 0.01 ) { DebugCamera.Velocity.z = 0.0; } + + fTime50Hz -= 1.0 / 50.0; + } + + // variable step render time routines + + update_camera( deltarealtime ); + + simulation::Environment.update_precipitation(); // has to be launched after camera step to work properly + + Timer::subsystem.sim_total.stop(); + + simulation::Region->update_sounds(); + audio::renderer.update( deltarealtime ); + + GfxRenderer.Update( deltarealtime ); + + simulation::is_ready = true; + + return true; +} + +// maintenance method, called when the mode is activated +void +driver_mode::enter() { + + Camera.Init(Global.FreeCameraInit[0], Global.FreeCameraInitAngle[0], ( FreeFlyModeFlag ? TCameraType::tp_Free : TCameraType::tp_Follow ) ); + Global.pCamera = Camera; + Global.pDebugCamera = DebugCamera; + + TDynamicObject *nPlayerTrain { ( + ( Global.asHumanCtrlVehicle != "ghostview" ) ? + simulation::Vehicles.find( Global.asHumanCtrlVehicle ) : + nullptr ) }; + + if (nPlayerTrain) + { + WriteLog( "Initializing player train, \"" + Global.asHumanCtrlVehicle + "\"" ); + + if( simulation::Train == nullptr ) { + simulation::Train = new TTrain(); + } + if( simulation::Train->Init( nPlayerTrain ) ) + { + WriteLog("Player train initialization OK"); + + Application.set_title( Global.AppName + " (" + simulation::Train->Controlled()->Name + " @ " + Global.SceneryFile + ")" ); + + FollowView(); + } + else + { + Error("Bad init: player train initialization failed"); + FreeFlyModeFlag = true; // Ra: automatycznie włączone latanie + SafeDelete( simulation::Train ); + Camera.Type = TCameraType::tp_Free; + } + } + else + { + if (Global.asHumanCtrlVehicle != "ghostview") + { + Error("Bad scenario: failed to locate player train, \"" + Global.asHumanCtrlVehicle + "\"" ); + } + FreeFlyModeFlag = true; // Ra: automatycznie włączone latanie + Camera.Type = TCameraType::tp_Free; + DebugCamera = Camera; + } + + // if (!Global.bMultiplayer) //na razie włączone + { // eventy aktywowane z klawiatury tylko dla jednego użytkownika + KeyEvents[ 0 ] = simulation::Events.FindEvent( "keyctrl00" ); + KeyEvents[ 1 ] = simulation::Events.FindEvent( "keyctrl01" ); + KeyEvents[ 2 ] = simulation::Events.FindEvent( "keyctrl02" ); + KeyEvents[ 3 ] = simulation::Events.FindEvent( "keyctrl03" ); + KeyEvents[ 4 ] = simulation::Events.FindEvent( "keyctrl04" ); + KeyEvents[ 5 ] = simulation::Events.FindEvent( "keyctrl05" ); + KeyEvents[ 6 ] = simulation::Events.FindEvent( "keyctrl06" ); + KeyEvents[ 7 ] = simulation::Events.FindEvent( "keyctrl07" ); + KeyEvents[ 8 ] = simulation::Events.FindEvent( "keyctrl08" ); + KeyEvents[ 9 ] = simulation::Events.FindEvent( "keyctrl09" ); + } + + Timer::ResetTimers(); + + set_picking( Global.ControlPicking ); +} + +// maintenance method, called when the mode is deactivated +void +driver_mode::exit() { + +} + +void +driver_mode::on_key( int const Key, int const Scancode, int const Action, int const Mods ) { + + Global.shiftState = ( Mods & GLFW_MOD_SHIFT ) ? true : false; + Global.ctrlState = ( Mods & GLFW_MOD_CONTROL ) ? true : false; + Global.altState = ( Mods & GLFW_MOD_ALT ) ? true : false; + + // give the ui first shot at the input processing... + if( true == m_userinterface->on_key( Key, Action ) ) { return; } + // ...if the input is left untouched, pass it on + if( true == m_input.keyboard.key( Key, Action ) ) { return; } + + if( ( true == Global.InputMouse ) + && ( ( Key == GLFW_KEY_LEFT_ALT ) + || ( Key == GLFW_KEY_RIGHT_ALT ) ) ) { + // if the alt key was pressed toggle control picking mode and set matching cursor behaviour + if( Action == GLFW_PRESS ) { + // toggle picking mode + set_picking( !Global.ControlPicking ); + } + } + + if( Action != GLFW_RELEASE ) { + + OnKeyDown( Key ); + +#ifdef CAN_I_HAS_LIBPNG + switch( key ) { + case GLFW_KEY_PRINT_SCREEN: { + make_screenshot(); + break; + } + default: { break; } + } +#endif + } +} + +void +driver_mode::on_cursor_pos( double const Horizontal, double const Vertical ) { + + // give the ui first shot at the input processing... + if( true == m_userinterface->on_cursor_pos( Horizontal, Vertical ) ) { return; } + + if( false == Global.ControlPicking ) { + // in regular view mode keep cursor on screen + Application.set_cursor_pos( 0, 0 ); + } + // give the potential event recipient a shot at it, in the virtual z order + m_input.mouse.move( Horizontal, Vertical ); +} + +void +driver_mode::on_mouse_button( int const Button, int const Action, int const Mods ) { + + // give the ui first shot at the input processing... + if( true == m_userinterface->on_mouse_button( Button, Action ) ) { return; } + + // give the potential event recipient a shot at it, in the virtual z order + m_input.mouse.button( Button, Action ); +} + +void +driver_mode::on_scroll( double const Xoffset, double const Yoffset ) { + + m_input.mouse.scroll( Xoffset, Yoffset ); +} + +void +driver_mode::on_event_poll() { + + m_input.poll(); +} + +void +driver_mode::update_camera( double const Deltatime ) { + + auto *controlled = ( + simulation::Train ? + simulation::Train->Dynamic() : + nullptr ); + + if( false == Global.ControlPicking ) { + if( m_input.mouse.button( GLFW_MOUSE_BUTTON_LEFT ) == GLFW_PRESS ) { + Camera.Reset(); // likwidacja obrotów - patrzy horyzontalnie na południe + if( controlled && LengthSquared3( controlled->GetPosition() - Camera.Pos ) < ( 1500 * 1500 ) ) { + // gdy bliżej niż 1.5km + Camera.LookAt = controlled->GetPosition(); + } + else { + TDynamicObject *d = std::get( simulation::Region->find_vehicle( Global.pCamera.Pos, 300, false, false ) ); + if( !d ) + d = std::get( simulation::Region->find_vehicle( Global.pCamera.Pos, 1000, false, false ) ); // dalej szukanie, jesli bliżej nie ma + + if( d && pDynamicNearest ) { + // jeśli jakiś jest znaleziony wcześniej + if( 100.0 * LengthSquared3( d->GetPosition() - Camera.Pos ) > LengthSquared3( pDynamicNearest->GetPosition() - Camera.Pos ) ) { + d = pDynamicNearest; // jeśli najbliższy nie jest 10 razy bliżej niż + } + } + // poprzedni najbliższy, zostaje poprzedni + if( d ) + pDynamicNearest = d; // zmiana na nowy, jeśli coś znaleziony niepusty + if( pDynamicNearest ) + Camera.LookAt = pDynamicNearest->GetPosition(); + } + if( FreeFlyModeFlag ) + Camera.RaLook(); // jednorazowe przestawienie kamery + } + else if( m_input.mouse.button( GLFW_MOUSE_BUTTON_RIGHT ) == GLFW_PRESS ) { + FollowView( false ); // bez wyciszania dźwięków + } + } + + if( m_input.mouse.button( GLFW_MOUSE_BUTTON_MIDDLE ) == GLFW_PRESS ) { + // middle mouse button controls zoom. + Global.ZoomFactor = std::min( 4.5f, Global.ZoomFactor + 15.0f * static_cast( Deltatime ) ); + } + else if( m_input.mouse.button( GLFW_MOUSE_BUTTON_MIDDLE ) != GLFW_PRESS ) { + // reset zoom level if the button is no longer held down. + // NOTE: yes, this is terrible way to go about it. it'll do for now. + Global.ZoomFactor = std::max( 1.0f, Global.ZoomFactor - 15.0f * static_cast( Deltatime ) ); + } + + if( DebugCameraFlag ) { DebugCamera.Update(); } + else { Camera.Update(); } // uwzględnienie ruchu wywołanego klawiszami + + if( ( false == FreeFlyModeFlag ) + && ( false == Global.CabWindowOpen ) + && ( simulation::Train != nullptr ) ) { + // cache cab camera view angles in case of view type switch + simulation::Train->pMechViewAngle = { Camera.Pitch, Camera.Yaw }; + } + + // reset window state, it'll be set again if applicable in a check below + Global.CabWindowOpen = false; + + if( ( simulation::Train != nullptr ) + && ( Camera.Type == TCameraType::tp_Follow ) + && ( false == DebugCameraFlag ) ) { + // jeśli jazda w kabinie, przeliczyć trzeba parametry kamery +/* + auto tempangle = controlled->VectorFront() * ( controlled->MoverParameters->ActiveCab == -1 ? -1 : 1 ); + double modelrotate = atan2( -tempangle.x, tempangle.z ); +*/ + if( ( true == Global.ctrlState ) + && ( ( m_input.keyboard.key( GLFW_KEY_LEFT ) != GLFW_RELEASE ) + || ( m_input.keyboard.key( GLFW_KEY_RIGHT ) != GLFW_RELEASE ) ) ) { + // jeśli lusterko lewe albo prawe (bez rzucania na razie) + Global.CabWindowOpen = true; + + auto const lr { m_input.keyboard.key( GLFW_KEY_LEFT ) != GLFW_RELEASE }; + // Camera.Yaw powinno być wyzerowane, aby po powrocie patrzeć do przodu + Camera.Pos = controlled->GetPosition() + simulation::Train->MirrorPosition( lr ); // pozycja lusterka + Camera.Yaw = 0; // odchylenie na bok od Camera.LookAt + if( simulation::Train->Occupied()->ActiveCab == 0 ) + Camera.LookAt = Camera.Pos - simulation::Train->GetDirection(); // gdy w korytarzu + else if( Global.shiftState ) { + // patrzenie w bok przez szybę + Camera.LookAt = Camera.Pos - ( lr ? -1 : 1 ) * controlled->VectorLeft() * simulation::Train->Occupied()->ActiveCab; + } + else { // patrzenie w kierunku osi pojazdu, z uwzględnieniem kabiny - jakby z lusterka, + // ale bez odbicia + Camera.LookAt = Camera.Pos - simulation::Train->GetDirection() * simulation::Train->Occupied()->ActiveCab; //-1 albo 1 + } + Camera.Roll = std::atan( simulation::Train->pMechShake.x * simulation::Train->fMechRoll ); // hustanie kamery na boki + Camera.Pitch = 0.5 * std::atan( simulation::Train->vMechVelocity.z * simulation::Train->fMechPitch ); // hustanie kamery przod tyl + Camera.vUp = controlled->VectorUp(); + } + else { + // patrzenie standardowe + // potentially restore view angle after returning from external view + // TODO: mirror view toggle as separate method + Camera.Pitch = simulation::Train->pMechViewAngle.x; + Camera.Yaw = simulation::Train->pMechViewAngle.y; + + Camera.Pos = simulation::Train->GetWorldMechPosition(); // Train.GetPosition1(); + if( !Global.iPause ) { + // podczas pauzy nie przeliczać kątów przypadkowymi wartościami + // hustanie kamery na boki + Camera.Roll = atan( simulation::Train->vMechVelocity.x * simulation::Train->fMechRoll ); + // hustanie kamery przod tyl + // Ra: tu jest uciekanie kamery w górę!!! + Camera.Pitch -= 0.5 * atan( simulation::Train->vMechVelocity.z * simulation::Train->fMechPitch ); + } +/* + // ABu011104: rzucanie pudlem + vector3 temp; + if( abs( Train->pMechShake.y ) < 0.25 ) + temp = vector3( 0, 0, 6 * Train->pMechShake.y ); + else if( ( Train->pMechShake.y ) > 0 ) + temp = vector3( 0, 0, 6 * 0.25 ); + else + temp = vector3( 0, 0, -6 * 0.25 ); + if( Controlled ) + Controlled->ABuSetModelShake( temp ); + // ABu: koniec rzucania +*/ + if( simulation::Train->Occupied()->ActiveCab == 0 ) + Camera.LookAt = simulation::Train->GetWorldMechPosition() + simulation::Train->GetDirection() * 5.0; // gdy w korytarzu + else // patrzenie w kierunku osi pojazdu, z uwzględnieniem kabiny + Camera.LookAt = simulation::Train->GetWorldMechPosition() + simulation::Train->GetDirection() * 5.0 * simulation::Train->Occupied()->ActiveCab; //-1 albo 1 + Camera.vUp = simulation::Train->GetUp(); + } + } + // all done, update camera position to the new value + Global.pCamera = Camera; +} + +void +driver_mode::OnKeyDown(int cKey) { + // dump keypress info in the log + // podczas pauzy klawisze nie działają + std::string keyinfo; + auto keyname = glfwGetKeyName( cKey, 0 ); + if( keyname != nullptr ) { + keyinfo += std::string( keyname ); + } + else { + switch( cKey ) { + + case GLFW_KEY_SPACE: { keyinfo += "Space"; break; } + case GLFW_KEY_ENTER: { keyinfo += "Enter"; break; } + case GLFW_KEY_ESCAPE: { keyinfo += "Esc"; break; } + case GLFW_KEY_TAB: { keyinfo += "Tab"; break; } + case GLFW_KEY_INSERT: { keyinfo += "Insert"; break; } + case GLFW_KEY_DELETE: { keyinfo += "Delete"; break; } + case GLFW_KEY_HOME: { keyinfo += "Home"; break; } + case GLFW_KEY_END: { keyinfo += "End"; break; } + case GLFW_KEY_F1: { keyinfo += "F1"; break; } + case GLFW_KEY_F2: { keyinfo += "F2"; break; } + case GLFW_KEY_F3: { keyinfo += "F3"; break; } + case GLFW_KEY_F4: { keyinfo += "F4"; break; } + case GLFW_KEY_F5: { keyinfo += "F5"; break; } + case GLFW_KEY_F6: { keyinfo += "F6"; break; } + case GLFW_KEY_F7: { keyinfo += "F7"; break; } + case GLFW_KEY_F8: { keyinfo += "F8"; break; } + case GLFW_KEY_F9: { keyinfo += "F9"; break; } + case GLFW_KEY_F10: { keyinfo += "F10"; break; } + case GLFW_KEY_F11: { keyinfo += "F11"; break; } + case GLFW_KEY_F12: { keyinfo += "F12"; break; } + case GLFW_KEY_PAUSE: { keyinfo += "Pause"; break; } + } + } + if( keyinfo.empty() == false ) { + + std::string keymodifiers; + if( Global.shiftState ) + keymodifiers += "[Shift]+"; + if( Global.ctrlState ) + keymodifiers += "[Ctrl]+"; + + WriteLog( "Key pressed: " + keymodifiers + "[" + keyinfo + "]" ); + } + + // actual key processing + // TODO: redo the input system + if( ( cKey >= GLFW_KEY_0 ) && ( cKey <= GLFW_KEY_9 ) ) { + // klawisze cyfrowe + int i = cKey - GLFW_KEY_0; // numer klawisza + if (Global.shiftState) { + // z [Shift] uruchomienie eventu + if( ( false == Global.iPause ) // podczas pauzy klawisze nie działają + && ( KeyEvents[ i ] != nullptr ) ) { + simulation::Events.AddToQuery( KeyEvents[ i ], NULL ); + } + } + else if( Global.ctrlState ) { + // zapamiętywanie kamery może działać podczas pauzy + if( FreeFlyModeFlag ) { + // w trybie latania można przeskakiwać do ustawionych kamer + if( ( Global.FreeCameraInit[ i ].x == 0.0 ) + && ( Global.FreeCameraInit[ i ].y == 0.0 ) + && ( Global.FreeCameraInit[ i ].z == 0.0 ) ) { + // jeśli kamera jest w punkcie zerowym, zapamiętanie współrzędnych i kątów + Global.FreeCameraInit[ i ] = Camera.Pos; + Global.FreeCameraInitAngle[ i ].x = Camera.Pitch; + Global.FreeCameraInitAngle[ i ].y = Camera.Yaw; + Global.FreeCameraInitAngle[ i ].z = Camera.Roll; + // logowanie, żeby można było do scenerii przepisać + WriteLog( + "camera " + std::to_string( Global.FreeCameraInit[ i ].x ) + " " + + std::to_string( Global.FreeCameraInit[ i ].y ) + " " + + std::to_string( Global.FreeCameraInit[ i ].z ) + " " + + std::to_string( RadToDeg( Global.FreeCameraInitAngle[ i ].x ) ) + " " + + std::to_string( RadToDeg( Global.FreeCameraInitAngle[ i ].y ) ) + " " + + std::to_string( RadToDeg( Global.FreeCameraInitAngle[ i ].z ) ) + " " + + std::to_string( i ) + " endcamera" ); + } + else // również przeskakiwanie + { // Ra: to z tą kamerą (Camera.Pos i Global.pCameraPosition) jest trochę bez sensu + Global.pCamera.Pos = Global.FreeCameraInit[ i ]; // nowa pozycja dla generowania obiektów + Camera.Init( Global.FreeCameraInit[ i ], Global.FreeCameraInitAngle[ i ], TCameraType::tp_Free ); // przestawienie + } + } + } + return; + } + + switch (cKey) { + + case GLFW_KEY_F1: { + + if( DebugModeFlag ) { + // additional simulation clock jump keys in debug mode + if( Global.ctrlState ) { + // ctrl-f1 + simulation::Time.update( 20.0 * 60.0 ); + } + else if( Global.shiftState ) { + // shift-f1 + simulation::Time.update( 5.0 * 60.0 ); + } + } + break; + } + + case GLFW_KEY_F4: { + + InOutKey( !Global.shiftState ); // distant view with Shift, short distance step out otherwise + break; + } + case GLFW_KEY_F5: { + // przesiadka do innego pojazdu + if( false == FreeFlyModeFlag ) { + // only available in free fly mode + break; + } + + TDynamicObject *tmp = std::get( simulation::Region->find_vehicle( Global.pCamera.Pos, 50, true, false ) ); + + if( tmp != nullptr ) { + + if( simulation::Train ) {// jeśli mielismy pojazd + if( simulation::Train->Dynamic()->Mechanik ) { // na skutek jakiegoś błędu może czasem zniknąć + simulation::Train->Dynamic()->Mechanik->TakeControl( true ); // oddajemy dotychczasowy AI + } + } + + if( ( true == DebugModeFlag ) + || ( tmp->MoverParameters->Vel <= 5.0 ) ) { + // works always in debug mode, or for stopped/slow moving vehicles otherwise + if( simulation::Train == nullptr ) { + simulation::Train = new TTrain(); // jeśli niczym jeszcze nie jeździlismy + } + if( simulation::Train->Init( tmp ) ) { // przejmujemy sterowanie + simulation::Train->Dynamic()->Mechanik->TakeControl( false ); + } + else { + SafeDelete( simulation::Train ); // i nie ma czym sterować + } + if( simulation::Train ) { + InOutKey(); // do kabiny + } + } + } + break; + } + case GLFW_KEY_F6: { + // przyspieszenie symulacji do testowania scenerii... uwaga na FPS! + if( DebugModeFlag ) { + + if( Global.ctrlState ) { Global.fTimeSpeed = ( Global.shiftState ? 60.0 : 20.0 ); } + else { Global.fTimeSpeed = ( Global.shiftState ? 5.0 : 1.0 ); } + } + break; + } + case GLFW_KEY_F7: { + // debug mode functions + if( DebugModeFlag ) { + + if( Global.ctrlState + && Global.shiftState ) { + // shift + ctrl + f7 toggles between debug and regular camera + DebugCameraFlag = !DebugCameraFlag; + } + else if( Global.ctrlState ) { + // ctrl + f7 toggles static daylight + simulation::Environment.toggle_daylight(); + break; + } + else if( Global.shiftState ) { + // shift + f7 is currently unused + } + else { + // f7: wireframe toggle + // TODO: pass this to renderer instead of making direct calls + Global.bWireFrame = !Global.bWireFrame; + if( true == Global.bWireFrame ) { + glPolygonMode( GL_FRONT_AND_BACK, GL_LINE ); + } + else { + glPolygonMode( GL_FRONT_AND_BACK, GL_FILL ); + } + } + } + break; + } + case GLFW_KEY_F11: { + // editor mode + if( ( false == Global.ctrlState ) + && ( false == Global.shiftState ) ) { + Application.push_mode( eu07_application::mode::editor ); + } + break; + } + case GLFW_KEY_F12: { + // quick debug mode toggle + if( Global.ctrlState + && Global.shiftState ) { + DebugModeFlag = !DebugModeFlag; + } + break; + } + + case GLFW_KEY_LEFT_BRACKET: + case GLFW_KEY_RIGHT_BRACKET: + case GLFW_KEY_TAB: { + // consist movement in debug mode + if( ( true == DebugModeFlag ) + && ( false == Global.shiftState ) + && ( true == Global.ctrlState ) + && ( simulation::Train != nullptr ) + && ( simulation::Train->Dynamic()->Controller == Humandriver ) ) { + + if( DebugModeFlag ) { + // przesuwanie składu o 100m + auto *vehicle { simulation::Train->Dynamic() }; + TDynamicObject *d = vehicle; + if( cKey == GLFW_KEY_LEFT_BRACKET ) { + while( d ) { + d->Move( 100.0 * d->DirectionGet() ); + d = d->Next(); // pozostałe też + } + d = vehicle->Prev(); + while( d ) { + d->Move( 100.0 * d->DirectionGet() ); + d = d->Prev(); // w drugą stronę też + } + } + else if( cKey == GLFW_KEY_RIGHT_BRACKET ) { + while( d ) { + d->Move( -100.0 * d->DirectionGet() ); + d = d->Next(); // pozostałe też + } + d = vehicle->Prev(); + while( d ) { + d->Move( -100.0 * d->DirectionGet() ); + d = d->Prev(); // w drugą stronę też + } + } + else if( cKey == GLFW_KEY_TAB ) { + while( d ) { + d->MoverParameters->V += d->DirectionGet()*2.78; + d = d->Next(); // pozostałe też + } + d = vehicle->Prev(); + while( d ) { + d->MoverParameters->V += d->DirectionGet()*2.78; + d = d->Prev(); // w drugą stronę też + } + } + } + } + break; + } + + default: { + break; + } + } + + return; // nie są przekazywane do pojazdu wcale +} + +// places camera outside the controlled vehicle, or nearest if nothing is under control +// depending on provided switch the view is placed right outside, or at medium distance +void +driver_mode::DistantView( bool const Near ) { + + TDynamicObject const *vehicle = { ( + ( simulation::Train != nullptr ) ? + simulation::Train->Dynamic() : + pDynamicNearest ) }; + + if( vehicle == nullptr ) { return; } + + auto const cab = + ( vehicle->MoverParameters->ActiveCab == 0 ? + 1 : + vehicle->MoverParameters->ActiveCab ); + auto const left = vehicle->VectorLeft() * cab; + + if( true == Near ) { + + Camera.Pos = + Math3D::vector3( Camera.Pos.x, vehicle->GetPosition().y, Camera.Pos.z ) + + left * vehicle->GetWidth() + + Math3D::vector3( 1.25 * left.x, 1.6, 1.25 * left.z ); + } + else { + + Camera.Pos = + vehicle->GetPosition() + + vehicle->VectorFront() * vehicle->MoverParameters->ActiveCab * 50.0 + + Math3D::vector3( -10.0 * left.x, 1.6, -10.0 * left.z ); + } + + Camera.LookAt = vehicle->GetPosition(); + Camera.RaLook(); // jednorazowe przestawienie kamery +} + +// ustawienie śledzenia pojazdu +void +driver_mode::FollowView(bool wycisz) { + + Camera.Reset(); // likwidacja obrotów - patrzy horyzontalnie na południe + + auto *train { simulation::Train }; + + if (train != nullptr ) // jest pojazd do prowadzenia? + { + if (FreeFlyModeFlag) + { // jeżeli poza kabiną, przestawiamy w jej okolicę - OK + // wyłączenie trzęsienia na siłę? + train->Dynamic()->ABuSetModelShake( {} ); + + DistantView(); // przestawienie kamery + } + else { + Camera.Pos = train->pMechPosition; + // potentially restore cached camera angles + Camera.Pitch = train->pMechViewAngle.x; + Camera.Yaw = train->pMechViewAngle.y; + + Camera.Roll = std::atan(train->pMechShake.x * train->fMechRoll); // hustanie kamery na boki + Camera.Pitch -= 0.5 * std::atan(train->vMechVelocity.z * train->fMechPitch); // hustanie kamery przod tyl + + if( train->Occupied()->ActiveCab == 0 ) { + Camera.LookAt = + train->pMechPosition + + train->GetDirection() * 5.0; + } + else { + // patrz w strone wlasciwej kabiny + Camera.LookAt = + train->pMechPosition + + train->GetDirection() * 5.0 * train->Occupied()->ActiveCab; + } + train->pMechOffset = train->pMechSittingPosition; + } + } + else + DistantView(); +} + +void +driver_mode::ChangeDynamic() { + + auto *train { simulation::Train }; + if( train == nullptr ) { return; } + + auto *vehicle { train->Dynamic() }; + auto *occupied { train->Occupied() }; + auto *driver { vehicle->Mechanik }; + // Ra: to nie może być tak robione, to zbytnia proteza jest + if( driver ) { + // AI może sobie samo pójść + if( false == driver->AIControllFlag ) { + // tylko jeśli ręcznie prowadzony + // jeśli prowadzi AI, to mu nie robimy dywersji! + occupied->CabDeactivisation(); + occupied->ActiveCab = 0; + occupied->BrakeLevelSet( occupied->Handle->GetPos( bh_NP ) ); //rozwala sterowanie hamulcem GF 04-2016 + vehicle->MechInside = false; + vehicle->Controller = AIdriver; + } + } + TDynamicObject *temp = Global.changeDynObj; + vehicle->bDisplayCab = false; + vehicle->ABuSetModelShake( {} ); + + if( driver ) // AI może sobie samo pójść + if( false == driver->AIControllFlag ) { + // tylko jeśli ręcznie prowadzony + // przsunięcie obiektu zarządzającego + driver->MoveTo( temp ); + } + + train->DynamicSet( temp ); + // update helpers + train = simulation::Train; + vehicle = train->Dynamic(); + occupied = train->Occupied(); + driver = vehicle->Mechanik; + Global.asHumanCtrlVehicle = vehicle->name(); + if( driver ) // AI może sobie samo pójść + if( false == driver->AIControllFlag ) // tylko jeśli ręcznie prowadzony + { + occupied->LimPipePress = occupied->PipePress; + occupied->CabActivisation(); // załączenie rozrządu (wirtualne kabiny) + vehicle->MechInside = true; + vehicle->Controller = Humandriver; + } + train->InitializeCab( + occupied->CabNo, + vehicle->asBaseDir + occupied->TypeName + ".mmd" ); + if( false == FreeFlyModeFlag ) { + vehicle->bDisplayCab = true; + vehicle->ABuSetModelShake( {} ); // zerowanie przesunięcia przed powrotem? + train->MechStop(); + FollowView(); // na pozycję mecha + } + Global.changeDynObj = nullptr; +} + +void +driver_mode::InOutKey( bool const Near ) +{ // przełączenie widoku z kabiny na zewnętrzny i odwrotnie + FreeFlyModeFlag = !FreeFlyModeFlag; // zmiana widoku + + auto *train { simulation::Train }; + + if (FreeFlyModeFlag) { + // jeżeli poza kabiną, przestawiamy w jej okolicę - OK + if (train) { + // cache current cab position so there's no need to set it all over again after each out-in switch + train->pMechSittingPosition = train->pMechOffset; + + train->Dynamic()->bDisplayCab = false; + DistantView( Near ); + } + DebugCamera = Camera; + } + else + { // jazda w kabinie + if (train) + { + train->Dynamic()->bDisplayCab = true; + // zerowanie przesunięcia przed powrotem? + train->Dynamic()->ABuSetModelShake( { 0, 0, 0 } ); + train->MechStop(); + FollowView(); // na pozycję mecha + train->UpdateMechPosition( m_secondaryupdaterate ); + } + else + FreeFlyModeFlag = true; // nadal poza kabiną + } + // update window title to reflect the situation + Application.set_title( Global.AppName + " (" + ( train != nullptr ? train->Occupied()->Name : "" ) + " @ " + Global.SceneryFile + ")" ); +} + +void +driver_mode::set_picking( bool const Picking ) { + + if( Picking ) { + // enter picking mode + Application.set_cursor_pos( m_input.mouse_pickmodepos.x, m_input.mouse_pickmodepos.y ); + Application.set_cursor( GLFW_CURSOR_NORMAL ); + } + else { + // switch off + Application.get_cursor_pos( m_input.mouse_pickmodepos.x, m_input.mouse_pickmodepos.y ); + Application.set_cursor( GLFW_CURSOR_DISABLED ); + Application.set_cursor_pos( 0, 0 ); + } + // actually toggle the mode + Global.ControlPicking = Picking; +} diff --git a/drivermode.h b/drivermode.h new file mode 100644 index 00000000..cd616a41 --- /dev/null +++ b/drivermode.h @@ -0,0 +1,90 @@ +/* +This Source Code Form is subject to the +terms of the Mozilla Public License, v. +2.0. If a copy of the MPL was not +distributed with this file, You can +obtain one at +http://mozilla.org/MPL/2.0/. +*/ + +#pragma once + +#include "applicationmode.h" + +#include "driverkeyboardinput.h" +#include "drivermouseinput.h" +#include "gamepadinput.h" +#include "uart.h" +#include "console.h" +#include "camera.h" +#include "classes.h" + +class driver_mode : public application_mode { + +public: +// constructors + driver_mode(); + +// methods + // initializes internal data structures of the mode. returns: true on success, false otherwise + bool + init() override; + // mode-specific update of simulation data. returns: false on error, true otherwise + bool + update() override; + // maintenance method, called when the mode is activated + void + enter() override; + // maintenance method, called when the mode is deactivated + void + exit() override; + // input handlers + void + on_key( int const Key, int const Scancode, int const Action, int const Mods ) override; + void + on_cursor_pos( double const Horizontal, double const Vertical ) override; + void + on_mouse_button( int const Button, int const Action, int const Mods ) override; + void + on_scroll( double const Xoffset, double const Yoffset ) override; + void + on_event_poll() override; + +private: +// types + struct drivermode_input { + + gamepad_input gamepad; + drivermouse_input mouse; + glm::dvec2 mouse_pickmodepos; // stores last mouse position in control picking mode + driverkeyboard_input keyboard; + Console console; + std::unique_ptr uart; + + bool init(); + void poll(); + }; + +// methods + void update_camera( const double Deltatime ); + // handles vehicle change flag + void OnKeyDown( int cKey ); + void ChangeDynamic(); + void InOutKey( bool const Near = true ); + void FollowView( bool wycisz = true ); + void DistantView( bool const Near = false ); + void set_picking( bool const Picking ); + +// members + drivermode_input m_input; + std::array KeyEvents { nullptr }; // eventy wyzwalane z klawiaury + TCamera Camera; + TCamera DebugCamera; + TDynamicObject *pDynamicNearest { nullptr }; // vehicle nearest to the active camera. TODO: move to camera + double fTime50Hz { 0.0 }; // bufor czasu dla komunikacji z PoKeys + double const m_primaryupdaterate { 1.0 / 100.0 }; + double const m_secondaryupdaterate { 1.0 / 50.0 }; + double m_primaryupdateaccumulator { m_secondaryupdaterate }; // keeps track of elapsed simulation time, for core fixed step routines + double m_secondaryupdateaccumulator { m_secondaryupdaterate }; // keeps track of elapsed simulation time, for less important fixed step routines + int iPause { 0 }; // wykrywanie zmian w zapauzowaniu +}; diff --git a/drivermouseinput.cpp b/drivermouseinput.cpp new file mode 100644 index 00000000..0a34c2f2 --- /dev/null +++ b/drivermouseinput.cpp @@ -0,0 +1,755 @@ +/* +This Source Code Form is subject to the +terms of the Mozilla Public License, v. +2.0. If a copy of the MPL was not +distributed with this file, You can +obtain one at +http://mozilla.org/MPL/2.0/. +*/ + +#include "stdafx.h" +#include "drivermouseinput.h" + +#include "application.h" +#include "utilities.h" +#include "globals.h" +#include "timer.h" +#include "simulation.h" +#include "train.h" +#include "animmodel.h" +#include "renderer.h" +#include "uilayer.h" +#include "logs.h" + +void +mouse_slider::bind( user_command const &Command ) { + + m_command = Command; + + auto const *train { simulation::Train }; + TMoverParameters const *vehicle { nullptr }; + switch( m_command ) { + case user_command::mastercontrollerset: + case user_command::secondcontrollerset: { + vehicle = ( train ? train->Controlled() : nullptr ); + break; + } + case user_command::trainbrakeset: + case user_command::independentbrakeset: { + vehicle = ( train ? train->Occupied() : nullptr ); + break; + } + default: { + break; + } + } + if( vehicle == nullptr ) { return; } + + // calculate initial value and accepted range + switch( m_command ) { + case user_command::mastercontrollerset: { + m_valuerange = ( + vehicle->CoupledCtrl ? + vehicle->MainCtrlPosNo + vehicle->ScndCtrlPosNo : + vehicle->MainCtrlPosNo ); + m_value = ( + vehicle->CoupledCtrl ? + vehicle->MainCtrlPos + vehicle->ScndCtrlPos : + vehicle->MainCtrlPos ); + m_analogue = false; + break; + } + case user_command::secondcontrollerset: { + m_valuerange = vehicle->ScndCtrlPosNo; + m_value = vehicle->ScndCtrlPos; + m_analogue = false; + break; + } + case user_command::trainbrakeset: { + m_valuerange = 1.0; + m_value = ( vehicle->fBrakeCtrlPos - vehicle->Handle->GetPos( bh_MIN ) ) / ( vehicle->Handle->GetPos( bh_MAX ) - vehicle->Handle->GetPos( bh_MIN ) ); + m_analogue = true; + break; + } + case user_command::independentbrakeset: { + m_valuerange = 1.0; + m_value = vehicle->LocalBrakePosA; + m_analogue = true; + break; + } + default: { + m_valuerange = 1; + break; + } + } + // hide the cursor and place it in accordance with current slider value + Application.get_cursor_pos( m_cursorposition.x, m_cursorposition.y ); + Application.set_cursor( GLFW_CURSOR_DISABLED ); + + auto const controlsize { Global.iWindowHeight * 0.75 }; + auto const controledge { Global.iWindowHeight * 0.5 + controlsize * 0.5 }; + auto const stepsize { controlsize / m_valuerange }; + + Application.set_cursor_pos( + Global.iWindowWidth * 0.5, + ( m_analogue ? + controledge - ( 1.0 - m_value ) * controlsize : + controledge - m_value * stepsize - 0.5 * stepsize ) ); +} + +void +mouse_slider::release() { + + m_command = user_command::none; + Application.set_cursor_pos( m_cursorposition.x, m_cursorposition.y ); + Application.set_cursor( GLFW_CURSOR_NORMAL ); +} + +void +mouse_slider::on_move( double const Mousex, double const Mousey ) { + + auto const controlsize { Global.iWindowHeight * 0.75 }; + auto const controledge { Global.iWindowHeight * 0.5 + controlsize * 0.5 }; + auto const stepsize { controlsize / m_valuerange }; + + auto mousey = clamp( Mousey, controledge - controlsize, controledge ); + m_value = ( + m_analogue ? + 1.0 - ( ( controledge - mousey ) / controlsize ) : + std::floor( ( controledge - mousey ) / stepsize ) ); +} + + + +bool +drivermouse_input::init() { + +#ifdef _WIN32 + DWORD systemkeyboardspeed; + ::SystemParametersInfo( SPI_GETKEYBOARDSPEED, 0, &systemkeyboardspeed, 0 ); + m_updaterate = interpolate( 0.5, 0.04, systemkeyboardspeed / 31.0 ); + DWORD systemkeyboarddelay; + ::SystemParametersInfo( SPI_GETKEYBOARDDELAY, 0, &systemkeyboarddelay, 0 ); + m_updatedelay = interpolate( 0.25, 1.0, systemkeyboarddelay / 3.0 ); +#endif + + default_bindings(); + recall_bindings(); + + return true; +} + +bool +drivermouse_input::recall_bindings() { + + cParser bindingparser( "eu07_input-mouse.ini", cParser::buffer_FILE ); + if( false == bindingparser.ok() ) { + return false; + } + + // build helper translation tables + std::unordered_map nametocommandmap; + std::size_t commandid = 0; + for( auto const &description : simulation::Commands_descriptions ) { + nametocommandmap.emplace( + description.name, + static_cast( commandid ) ); + ++commandid; + } + + // NOTE: to simplify things we expect one entry per line, and whole entry in one line + while( true == bindingparser.getTokens( 1, true, "\n" ) ) { + + std::string bindingentry; + bindingparser >> bindingentry; + cParser entryparser( bindingentry ); + + if( true == entryparser.getTokens( 1, true, "\n\r\t " ) ) { + + std::string bindingpoint {}; + entryparser >> bindingpoint; + + std::vector< std::reference_wrapper > bindingtargets; + + if( bindingpoint == "wheel" ) { + bindingtargets.emplace_back( std::ref( m_wheelbindings.up ) ); + bindingtargets.emplace_back( std::ref( m_wheelbindings.down ) ); + } + // TODO: binding targets for mouse buttons + + for( auto &bindingtarget : bindingtargets ) { + // grab command(s) associated with the input pin + auto const bindingcommandname{ entryparser.getToken() }; + if( true == bindingcommandname.empty() ) { + // no tokens left, may as well complain then call it a day + WriteLog( "Mouse binding for " + bindingpoint + " didn't specify associated command(s)" ); + break; + } + auto const commandlookup = nametocommandmap.find( bindingcommandname ); + if( commandlookup == nametocommandmap.end() ) { + WriteLog( "Mouse binding for " + bindingpoint + " specified unknown command, \"" + bindingcommandname + "\"" ); + } + else { + bindingtarget.get() = commandlookup->second; + } + } + } + } + + return true; +} + +void +drivermouse_input::move( double Mousex, double Mousey ) { + + if( false == Global.ControlPicking ) { + // default control mode + m_relay.post( + user_command::viewturn, + Mousex, + Mousey, + GLFW_PRESS, + // as we haven't yet implemented either item id system or multiplayer, the 'local' controlled vehicle and entity have temporary ids of 0 + // TODO: pass correct entity id once the missing systems are in place + 0 ); + } + else { + // control picking mode + if( m_slider.command() != user_command::none ) { + m_slider.on_move( Mousex, Mousey ); + m_relay.post( + m_slider.command(), + m_slider.value(), + 0, + GLFW_PRESS, + // TODO: pass correct entity id once the missing systems are in place + 0 ); + } + + if( false == m_pickmodepanning ) { + // even if the view panning isn't active we capture the cursor position in case it does get activated + m_cursorposition.x = Mousex; + m_cursorposition.y = Mousey; + return; + } + glm::dvec2 cursorposition { Mousex, Mousey }; + auto const viewoffset = cursorposition - m_cursorposition; + m_relay.post( + user_command::viewturn, + viewoffset.x, + viewoffset.y, + GLFW_PRESS, + // as we haven't yet implemented either item id system or multiplayer, the 'local' controlled vehicle and entity have temporary ids of 0 + // TODO: pass correct entity id once the missing systems are in place + 0 ); + m_cursorposition = cursorposition; + } +} + +void +drivermouse_input::scroll( double const Xoffset, double const Yoffset ) { + + if( Global.ctrlState ) { + // ctrl + scroll wheel adjusts fov + Global.FieldOfView = clamp( static_cast( Global.FieldOfView - Yoffset * 20.0 / Timer::subsystem.gfx_total.average() ), 15.0f, 75.0f ); + } + else { + // scroll adjusts master controller + // TODO: allow configurable scroll commands + auto command { + adjust_command( + ( Yoffset > 0.0 ) ? + m_wheelbindings.up : + m_wheelbindings.down ) }; + + m_relay.post( + command, + 0, + 0, + GLFW_PRESS, + // TODO: pass correct entity id once the missing systems are in place + 0 ); + } +} + +void +drivermouse_input::button( int const Button, int const Action ) { + + // store key state + if( Button >= 0 ) { + m_buttons[ Button ] = Action; + } + + if( false == Global.ControlPicking ) { return; } + + if( true == FreeFlyModeFlag ) { + // freefly mode + // left mouse button launches on_click event associated with to the node + if( Button == GLFW_MOUSE_BUTTON_LEFT ) { + if( Action == GLFW_PRESS ) { + auto const *node { GfxRenderer.Update_Pick_Node() }; + if( ( node == nullptr ) + || ( typeid( *node ) != typeid( TAnimModel ) ) ) { + return; + } + simulation::Region->on_click( static_cast( node ) ); + } + } + // right button controls panning + if( Button == GLFW_MOUSE_BUTTON_RIGHT ) { + m_pickmodepanning = ( Action == GLFW_PRESS ); + } + } + else { + // cab controls mode + user_command &mousecommand = ( + Button == GLFW_MOUSE_BUTTON_LEFT ? + m_mousecommandleft : + m_mousecommandright + ); + + if( Action == GLFW_RELEASE ) { + if( mousecommand != user_command::none ) { + // NOTE: basic keyboard controls don't have any parameters + // as we haven't yet implemented either item id system or multiplayer, the 'local' controlled vehicle and entity have temporary ids of 0 + // TODO: pass correct entity id once the missing systems are in place + m_relay.post( mousecommand, 0, 0, Action, 0 ); + mousecommand = user_command::none; + } + else { + if( Button == GLFW_MOUSE_BUTTON_LEFT ) { + if( m_slider.command() != user_command::none ) { + m_slider.release(); + } + } + // if it's the right mouse button that got released and we had no command active, we were potentially in view panning mode; stop it + if( Button == GLFW_MOUSE_BUTTON_RIGHT ) { + m_pickmodepanning = false; + } + } + // if we were in varying command repeat rate, we can stop that now. done without any conditions, to catch some unforeseen edge cases + m_varyingpollrate = false; + } + else { + // if not release then it's press + auto const lookup = m_buttonbindings.find( simulation::Train->GetLabel( GfxRenderer.Update_Pick_Control() ) ); + if( lookup != m_buttonbindings.end() ) { + // if the recognized element under the cursor has a command associated with the pressed button, notify the recipient + mousecommand = ( + Button == GLFW_MOUSE_BUTTON_LEFT ? + lookup->second.left : + lookup->second.right + ); + if( mousecommand == user_command::none ) { return; } + // check manually for commands which have 'fast' variants launched with shift modifier + if( Global.shiftState ) { + switch( mousecommand ) { + case user_command::mastercontrollerincrease: { mousecommand = user_command::mastercontrollerincreasefast; break; } + case user_command::mastercontrollerdecrease: { mousecommand = user_command::mastercontrollerdecreasefast; break; } + case user_command::secondcontrollerincrease: { mousecommand = user_command::secondcontrollerincreasefast; break; } + case user_command::secondcontrollerdecrease: { mousecommand = user_command::secondcontrollerdecreasefast; break; } + case user_command::independentbrakeincrease: { mousecommand = user_command::independentbrakeincreasefast; break; } + case user_command::independentbrakedecrease: { mousecommand = user_command::independentbrakedecreasefast; break; } + default: { break; } + } + } + + switch( mousecommand ) { + case user_command::mastercontrollerincrease: + case user_command::mastercontrollerdecrease: + case user_command::secondcontrollerincrease: + case user_command::secondcontrollerdecrease: + case user_command::trainbrakeincrease: + case user_command::trainbrakedecrease: + case user_command::independentbrakeincrease: + case user_command::independentbrakedecrease: { + // these commands trigger varying repeat rate mode, + // which scales the rate based on the distance of the cursor from its point when the command was first issued + m_varyingpollrateorigin = m_cursorposition; + m_varyingpollrate = true; + break; + } + case user_command::mastercontrollerset: + case user_command::secondcontrollerset: + case user_command::trainbrakeset: + case user_command::independentbrakeset: { + m_slider.bind( mousecommand ); + mousecommand = user_command::none; + return; + } + default: { + break; + } + } + // NOTE: basic keyboard controls don't have any parameters + // NOTE: as we haven't yet implemented either item id system or multiplayer, the 'local' controlled vehicle and entity have temporary ids of 0 + // TODO: pass correct entity id once the missing systems are in place + m_relay.post( mousecommand, 0, 0, Action, 0 ); + m_updateaccumulator = -0.25; // prevent potential command repeat right after issuing one + } + else { + // if we don't have any recognized element under the cursor and the right button was pressed, enter view panning mode + if( Button == GLFW_MOUSE_BUTTON_RIGHT ) { + m_pickmodepanning = true; + } + } + } + } +} + +int +drivermouse_input::button( int const Button ) const { + + return m_buttons[ Button ]; +} + +void +drivermouse_input::poll() { + + m_updateaccumulator += Timer::GetDeltaRenderTime(); + + auto updaterate { m_updaterate }; + if( m_varyingpollrate ) { + updaterate /= std::max( 0.15, 2.0 * glm::length( m_cursorposition - m_varyingpollrateorigin ) / std::max( 1, Global.iWindowHeight ) ); + } + + while( m_updateaccumulator > updaterate ) { + + if( m_mousecommandleft != user_command::none ) { + // NOTE: basic keyboard controls don't have any parameters + // as we haven't yet implemented either item id system or multiplayer, the 'local' controlled vehicle and entity have temporary ids of 0 + // TODO: pass correct entity id once the missing systems are in place + m_relay.post( m_mousecommandleft, 0, 0, GLFW_REPEAT, 0 ); + } + if( m_mousecommandright != user_command::none ) { + // NOTE: basic keyboard controls don't have any parameters + // as we haven't yet implemented either item id system or multiplayer, the 'local' controlled vehicle and entity have temporary ids of 0 + // TODO: pass correct entity id once the missing systems are in place + m_relay.post( m_mousecommandright, 0, 0, GLFW_REPEAT, 0 ); + } + m_updateaccumulator -= updaterate; + } +} + +user_command +drivermouse_input::command() const { + + return ( + m_slider.command() != user_command::none ? m_slider.command() : + m_mousecommandleft != user_command::none ? m_mousecommandleft : + m_mousecommandright ); +} + +void +drivermouse_input::default_bindings() { + + m_buttonbindings = { + { "mainctrl:", { + user_command::mastercontrollerset, + user_command::none } }, + { "scndctrl:", { + user_command::secondcontrollerset, + user_command::none } }, + { "shuntmodepower:", { + user_command::secondcontrollerincrease, + user_command::secondcontrollerdecrease } }, + { "dirkey:", { + user_command::reverserincrease, + user_command::reverserdecrease } }, + { "brakectrl:", { + user_command::trainbrakeset, + user_command::none } }, + { "localbrake:", { + user_command::independentbrakeset, + user_command::none } }, + { "manualbrake:", { + user_command::manualbrakeincrease, + user_command::manualbrakedecrease } }, + { "alarmchain:", { + user_command::alarmchaintoggle, + user_command::none } }, + { "brakeprofile_sw:", { + user_command::brakeactingspeedincrease, + user_command::brakeactingspeeddecrease } }, + // TODO: dedicated methods for braking speed switches + { "brakeprofileg_sw:", { + user_command::brakeactingspeedsetcargo, + user_command::brakeactingspeedsetpassenger } }, + { "brakeprofiler_sw:", { + user_command::brakeactingspeedsetrapid, + user_command::brakeactingspeedsetpassenger } }, + { "maxcurrent_sw:", { + user_command::motoroverloadrelaythresholdtoggle, + user_command::none } }, + { "waterpumpbreaker_sw:", { + user_command::waterpumpbreakertoggle, + user_command::none } }, + { "waterpump_sw:", { + user_command::waterpumptoggle, + user_command::none } }, + { "waterheaterbreaker_sw:", { + user_command::waterheaterbreakertoggle, + user_command::none } }, + { "waterheater_sw:", { + user_command::waterheatertoggle, + user_command::none } }, + { "fuelpump_sw:", { + user_command::fuelpumptoggle, + user_command::none } }, + { "oilpump_sw:", { + user_command::oilpumptoggle, + user_command::none } }, + { "motorblowersfront_sw:", { + user_command::motorblowerstogglefront, + user_command::none } }, + { "motorblowersrear_sw:", { + user_command::motorblowerstogglerear, + user_command::none } }, + { "motorblowersalloff_sw:", { + user_command::motorblowersdisableall, + user_command::none } }, + { "main_off_bt:", { + user_command::linebreakeropen, + user_command::none } }, + { "main_on_bt:",{ + user_command::linebreakerclose, + user_command::none } }, + { "security_reset_bt:", { + user_command::alerteracknowledge, + user_command::none } }, + { "releaser_bt:", { + user_command::independentbrakebailoff, + user_command::none } }, + { "sand_bt:", { + user_command::sandboxactivate, + user_command::none } }, + { "antislip_bt:", { + user_command::wheelspinbrakeactivate, + user_command::none } }, + { "horn_bt:", { + user_command::hornhighactivate, + user_command::hornlowactivate } }, + { "hornlow_bt:", { + user_command::hornlowactivate, + user_command::none } }, + { "hornhigh_bt:", { + user_command::hornhighactivate, + user_command::none } }, + { "whistle_bt:", { + user_command::whistleactivate, + user_command::none } }, + { "fuse_bt:", { + user_command::motoroverloadrelayreset, + user_command::none } }, + { "converterfuse_bt:", { + user_command::converteroverloadrelayreset, + user_command::none } }, + { "stlinoff_bt:", { + user_command::motorconnectorsopen, + user_command::none } }, + { "door_left_sw:", { + user_command::doortoggleleft, + user_command::none } }, + { "door_right_sw:", { + user_command::doortoggleright, + user_command::none } }, + { "doorlefton_sw:", { + user_command::dooropenleft, + user_command::none } }, + { "doorrighton_sw:", { + user_command::dooropenright, + user_command::none } }, + { "doorleftoff_sw:", { + user_command::doorcloseleft, + user_command::none } }, + { "doorrightoff_sw:", { + user_command::doorcloseright, + user_command::none } }, + { "dooralloff_sw:", { + user_command::doorcloseall, + user_command::none } }, + { "departure_signal_bt:", { + user_command::departureannounce, + user_command::none } }, + { "upperlight_sw:", { + user_command::headlighttoggleupper, + user_command::none } }, + { "leftlight_sw:", { + user_command::headlighttoggleleft, + user_command::none } }, + { "rightlight_sw:", { + user_command::headlighttoggleright, + user_command::none } }, + { "dimheadlights_sw:", { + user_command::headlightsdimtoggle, + user_command::none } }, + { "leftend_sw:", { + user_command::redmarkertoggleleft, + user_command::none } }, + { "rightend_sw:", { + user_command::redmarkertoggleright, + user_command::none } }, + { "lights_sw:", { + user_command::lightspresetactivatenext, + user_command::lightspresetactivateprevious } }, + { "rearupperlight_sw:", { + user_command::headlighttogglerearupper, + user_command::none } }, + { "rearleftlight_sw:", { + user_command::headlighttogglerearleft, + user_command::none } }, + { "rearrightlight_sw:", { + user_command::headlighttogglerearright, + user_command::none } }, + { "rearleftend_sw:", { + user_command::redmarkertogglerearleft, + user_command::none } }, + { "rearrightend_sw:", { + user_command::redmarkertogglerearright, + user_command::none } }, + { "compressor_sw:", { + user_command::compressortoggle, + user_command::none } }, + { "compressorlocal_sw:", { + user_command::compressortogglelocal, + user_command::none } }, + { "converter_sw:", { + user_command::convertertoggle, + user_command::none } }, + { "converterlocal_sw:", { + user_command::convertertogglelocal, + user_command::none } }, + { "converteroff_sw:", { + user_command::convertertoggle, + user_command::none } }, // TODO: dedicated converter shutdown command + { "main_sw:", { + user_command::linebreakertoggle, + user_command::none } }, + { "radio_sw:", { + user_command::radiotoggle, + user_command::none } }, + { "radiochannel_sw:", { + user_command::radiochannelincrease, + user_command::radiochanneldecrease } }, + { "radiochannelprev_sw:", { + user_command::radiochanneldecrease, + user_command::none } }, + { "radiochannelnext_sw:", { + user_command::radiochannelincrease, + user_command::none } }, + { "radiostop_sw:", { + user_command::radiostopsend, + user_command::none } }, + { "radiotest_sw:", { + user_command::radiostoptest, + user_command::none } }, + { "pantfront_sw:", { + user_command::pantographtogglefront, + user_command::none } }, + { "pantrear_sw:", { + user_command::pantographtogglerear, + user_command::none } }, + { "pantfrontoff_sw:", { + user_command::pantographlowerfront, + user_command::none } }, // TODO: dedicated lower pantograph commands + { "pantrearoff_sw:", { + user_command::pantographlowerrear, + user_command::none } }, // TODO: dedicated lower pantograph commands + { "pantalloff_sw:", { + user_command::pantographlowerall, + user_command::none } }, + { "pantselected_sw:", { + user_command::none, + user_command::none } }, // TODO: selected pantograph(s) operation command + { "pantselectedoff_sw:", { + user_command::none, + user_command::none } }, // TODO: lower selected pantograp(s) command + { "pantcompressor_sw:", { + user_command::pantographcompressoractivate, + user_command::none } }, + { "pantcompressorvalve_sw:", { + user_command::pantographcompressorvalvetoggle, + user_command::none } }, + { "trainheating_sw:", { + user_command::heatingtoggle, + user_command::none } }, + { "signalling_sw:", { + user_command::mubrakingindicatortoggle, + user_command::none } }, + { "door_signalling_sw:", { + user_command::doorlocktoggle, + user_command::none } }, + { "nextcurrent_sw:", { + user_command::mucurrentindicatorothersourceactivate, + user_command::none } }, + { "instrumentlight_sw:", { + user_command::instrumentlighttoggle, + user_command::none } }, + { "dashboardlight_sw:", { + user_command::dashboardlighttoggle, + user_command::none } }, + { "timetablelight_sw:", { + user_command::timetablelighttoggle, + user_command::none } }, + { "cablight_sw:", { + user_command::interiorlighttoggle, + user_command::none } }, + { "cablightdim_sw:", { + user_command::interiorlightdimtoggle, + user_command::none } }, + { "battery_sw:", { + user_command::batterytoggle, + user_command::none } }, + { "universal0:", { + user_command::generictoggle0, + user_command::none } }, + { "universal1:", { + user_command::generictoggle1, + user_command::none } }, + { "universal2:", { + user_command::generictoggle2, + user_command::none } }, + { "universal3:", { + user_command::generictoggle3, + user_command::none } }, + { "universal4:", { + user_command::generictoggle4, + user_command::none } }, + { "universal5:", { + user_command::generictoggle5, + user_command::none } }, + { "universal6:", { + user_command::generictoggle6, + user_command::none } }, + { "universal7:", { + user_command::generictoggle7, + user_command::none } }, + { "universal8:", { + user_command::generictoggle8, + user_command::none } }, + { "universal9:", { + user_command::generictoggle9, + user_command::none } } + }; +} + +user_command +drivermouse_input::adjust_command( user_command Command ) { + + if( ( true == Global.shiftState ) + && ( Command != user_command::none ) ) { + switch( Command ) { + case user_command::mastercontrollerincrease: { Command = user_command::mastercontrollerincreasefast; break; } + case user_command::mastercontrollerdecrease: { Command = user_command::mastercontrollerdecreasefast; break; } + case user_command::secondcontrollerincrease: { Command = user_command::secondcontrollerincreasefast; break; } + case user_command::secondcontrollerdecrease: { Command = user_command::secondcontrollerdecreasefast; break; } + case user_command::independentbrakeincrease: { Command = user_command::independentbrakeincreasefast; break; } + case user_command::independentbrakedecrease: { Command = user_command::independentbrakedecreasefast; break; } + default: { break; } + } + } + + return Command; +} + +//--------------------------------------------------------------------------- diff --git a/drivermouseinput.h b/drivermouseinput.h new file mode 100644 index 00000000..b8b40a4e --- /dev/null +++ b/drivermouseinput.h @@ -0,0 +1,109 @@ +/* +This Source Code Form is subject to the +terms of the Mozilla Public License, v. +2.0. If a copy of the MPL was not +distributed with this file, You can +obtain one at +http://mozilla.org/MPL/2.0/. +*/ + +#pragma once + +#include +#include "command.h" + +// virtual slider; value determined by position of the mouse +class mouse_slider { + +public: +// constructors + mouse_slider() = default; +// methods + void + bind( user_command const &Command ); + void + release(); + void + on_move( double const Mousex, double const Mousey ); + inline + user_command + command() const { + return m_command; } + double + value() const { + return m_value; } + +private: +// members + user_command m_command { user_command::none }; + double m_value { 0.0 }; + double m_valuerange { 0.0 }; + bool m_analogue { false }; + glm::dvec2 m_cursorposition { 0.0 }; +}; + +class drivermouse_input { + +public: +// constructors + drivermouse_input() = default; + +// methods + bool + init(); + bool + recall_bindings(); + void + button( int const Button, int const Action ); + int + button( int const Button ) const; + void + move( double const Horizontal, double const Vertical ); + void + scroll( double const Xoffset, double const Yoffset ); + void + poll(); + user_command + command() const; + +private: +// types + struct button_bindings { + + user_command left; + user_command right; + }; + + struct wheel_bindings { + + user_command up; + user_command down; + }; + + typedef std::unordered_map buttonbindings_map; + +// methods + void + default_bindings(); + // potentially replaces supplied command with a more relevant one + user_command + adjust_command( user_command Command ); + +// members + command_relay m_relay; + mouse_slider m_slider; // virtual control, when active translates intercepted mouse position to a value + buttonbindings_map m_buttonbindings; + wheel_bindings m_wheelbindings { user_command::mastercontrollerincrease, user_command::mastercontrollerdecrease }; // commands bound to the scroll wheel + user_command m_mousecommandleft { user_command::none }; // last if any command issued with left mouse button + user_command m_mousecommandright { user_command::none }; // last if any command issued with right mouse button + double m_updaterate { 0.075 }; + double m_updatedelay { 0.25 }; + double m_updateaccumulator { 0.0 }; + bool m_pickmodepanning { false }; // indicates mouse is in view panning mode + glm::dvec2 m_cursorposition; // stored last cursor position, used for panning + bool m_varyingpollrate { false }; // indicates rate of command repeats is affected by the cursor position + glm::dvec2 m_varyingpollrateorigin; // helper, cursor position when the command was initiated + std::array m_buttons; +}; + +//--------------------------------------------------------------------------- diff --git a/driveruilayer.cpp b/driveruilayer.cpp new file mode 100644 index 00000000..8433d709 --- /dev/null +++ b/driveruilayer.cpp @@ -0,0 +1,218 @@ +/* +This Source Code Form is subject to the +terms of the Mozilla Public License, v. +2.0. If a copy of the MPL was not +distributed with this file, You can +obtain one at +http://mozilla.org/MPL/2.0/. +*/ + +#include "stdafx.h" +#include "driveruilayer.h" + +#include "globals.h" +#include "application.h" +#include "translation.h" +#include "simulation.h" +#include "train.h" +#include "animmodel.h" +#include "renderer.h" + +driver_ui::driver_ui() { + + clear_panels(); + // bind the panels with ui object. maybe not the best place for this but, eh + push_back( &m_aidpanel ); + push_back( &m_timetablepanel ); + push_back( &m_debugpanel ); + push_back( &m_transcriptspanel ); + + m_aidpanel.title = locale::strings[ locale::string::driver_aid_header ]; + + m_timetablepanel.title = locale::strings[ locale::string::driver_timetable_header ]; + m_timetablepanel.size_min = { 435, 110 }; + m_timetablepanel.size_max = { 435, Global.iWindowHeight * 0.95 }; + + m_transcriptspanel.title = locale::strings[ locale::string::driver_transcripts_header ]; + m_transcriptspanel.size_min = { 435, 85 }; + m_transcriptspanel.size_max = { Global.iWindowWidth * 0.95, Global.iWindowHeight * 0.95 }; +} + +// potentially processes provided input key. returns: true if key was processed, false otherwise +bool +driver_ui::on_key( int const Key, int const Action ) { + // TODO: pass the input first through an active ui element if there's any + // if the ui element shows no interest or we don't have one, try to interpret the input yourself: + + if( Key == GLFW_KEY_ESCAPE ) { + // toggle pause + if( Action != GLFW_PRESS ) { return true; } // recognized, but ignored + + if( Global.iPause & 1 ) { + // jeśli pauza startowa + // odpauzowanie, gdy po wczytaniu miało nie startować + Global.iPause ^= 1; + } + else if( ( Global.iMultiplayer & 2 ) == 0 ) { + // w multiplayerze pauza nie ma sensu + Global.iPause ^= 2; // zmiana stanu zapauzowania + } + return true; + } + + // if the pause is on ignore block other input + if( m_paused ) { return true; } + + switch( Key ) { + + case GLFW_KEY_F1: + case GLFW_KEY_F2: + case GLFW_KEY_F10: + case GLFW_KEY_F12: { // ui mode selectors + + if( ( true == Global.ctrlState ) + || ( true == Global.shiftState ) ) { + // only react to keys without modifiers + return false; + } + + if( Action != GLFW_PRESS ) { return true; } // recognized, but ignored + } + + default: { // everything else + break; + } + } + + switch (Key) { + + case GLFW_KEY_F1: { + // basic consist info + auto state = ( + ( m_aidpanel.is_open == false ) ? 0 : + ( m_aidpanel.is_expanded == false ) ? 1 : + 2 ); + state = clamp_circular( ++state, 3 ); + + m_aidpanel.is_open = ( state > 0 ); + m_aidpanel.is_expanded = ( state > 1 ); + + return true; + } + + case GLFW_KEY_F2: { + // timetable + auto state = ( + ( m_timetablepanel.is_open == false ) ? 0 : + ( m_timetablepanel.is_expanded == false ) ? 1 : + 2 ); + state = clamp_circular( ++state, 3 ); + + m_timetablepanel.is_open = ( state > 0 ); + m_timetablepanel.is_expanded = ( state > 1 ); + + return true; + } + + case GLFW_KEY_F12: { + // debug panel + m_debugpanel.is_open = !m_debugpanel.is_open; + return true; + } + + default: { + break; + } + } + + return false; +} + +// potentially processes provided mouse movement. returns: true if the input was processed, false otherwise +bool +driver_ui::on_cursor_pos( double const Horizontal, double const Vertical ) { + // intercept mouse movement when the pause window is on + return m_paused; +} + +// potentially processes provided mouse button. returns: true if the input was processed, false otherwise +bool +driver_ui::on_mouse_button( int const Button, int const Action ) { + // intercept mouse movement when the pause window is on + return m_paused; +} + +// updates state of UI elements +void +driver_ui::update() { + + auto const pausemask { 1 | 2 }; + auto ispaused { ( false == DebugModeFlag ) && ( ( Global.iPause & pausemask ) != 0 ) }; + if( ( ispaused != m_paused ) + && ( false == Global.ControlPicking ) ) { + set_cursor( ispaused ); + } + m_paused = ispaused; + + set_tooltip( "" ); + + auto const *train { simulation::Train }; + + if( ( train != nullptr ) && ( false == FreeFlyModeFlag ) ) { + if( false == DebugModeFlag ) { + // in regular mode show control functions, for defined controls + set_tooltip( locale::label_cab_control( train->GetLabel( GfxRenderer.Pick_Control() ) ) ); + } + else { + // in debug mode show names of submodels, to help with cab setup and/or debugging + auto const cabcontrol = GfxRenderer.Pick_Control(); + set_tooltip( ( cabcontrol ? cabcontrol->pName : "" ) ); + } + } + if( ( true == Global.ControlPicking ) && ( true == FreeFlyModeFlag ) && ( true == DebugModeFlag ) ) { + auto const scenerynode = GfxRenderer.Pick_Node(); + set_tooltip( + ( scenerynode ? + scenerynode->name() : + "" ) ); + } + + ui_layer::update(); +} + +void +driver_ui::set_cursor( bool const Visible ) { + + if( Visible ) { + Application.set_cursor( GLFW_CURSOR_NORMAL ); + Application.set_cursor_pos( Global.iWindowWidth / 2, Global.iWindowHeight / 2 ); + } + else { + Application.set_cursor( GLFW_CURSOR_DISABLED ); + Application.set_cursor_pos( 0, 0 ); + } +} + +// render() subclass details +void +driver_ui::render_() { + + if( m_paused ) { + // pause/quit modal + auto const popupheader { locale::strings[ locale::string::driver_pause_header ].c_str() }; + ImGui::OpenPopup( popupheader ); + if( ImGui::BeginPopupModal( popupheader, nullptr, ImGuiWindowFlags_AlwaysAutoResize ) ) { + auto const popupwidth{ locale::strings[ locale::string::driver_pause_header ].size() * 7 }; + if( ImGui::Button( locale::strings[ locale::string::driver_pause_resume ].c_str(), ImVec2( popupwidth, 0 ) ) ) { + ImGui::CloseCurrentPopup(); + auto const pausemask { 1 | 2 }; + Global.iPause &= ~pausemask; + } + if( ImGui::Button( locale::strings[ locale::string::driver_pause_quit ].c_str(), ImVec2( popupwidth, 0 ) ) ) { + ImGui::CloseCurrentPopup(); + glfwSetWindowShouldClose( m_window, 1 ); + } + ImGui::EndPopup(); + } + } +} diff --git a/driveruilayer.h b/driveruilayer.h new file mode 100644 index 00000000..28a6d94b --- /dev/null +++ b/driveruilayer.h @@ -0,0 +1,49 @@ +/* +This Source Code Form is subject to the +terms of the Mozilla Public License, v. +2.0. If a copy of the MPL was not +distributed with this file, You can +obtain one at +http://mozilla.org/MPL/2.0/. +*/ + +#pragma once + +#include "uilayer.h" +#include "driveruipanels.h" + +class driver_ui : public ui_layer { + +public: +// constructors + driver_ui(); +// methods + // potentially processes provided input key. returns: true if the input was processed, false otherwise + bool + on_key( int const Key, int const Action ) override; + // potentially processes provided mouse movement. returns: true if the input was processed, false otherwise + bool + on_cursor_pos( double const Horizontal, double const Vertical ) override; + // potentially processes provided mouse button. returns: true if the input was processed, false otherwise + bool + on_mouse_button( int const Button, int const Action ) override; + // updates state of UI elements + void + update() override; + +private: +// methods + // sets visibility of the cursor + void + set_cursor( bool const Visible ); + // render() subclass details + void + render_() override; +// members + drivingaid_panel m_aidpanel { "Driving Aid", true }; + timetable_panel m_timetablepanel { "Timetable", false }; + debug_panel m_debugpanel { "Debug Data", false }; + transcripts_panel m_transcriptspanel { "Transcripts", true }; // voice transcripts + bool m_paused { false }; + +}; diff --git a/driveruipanels.cpp b/driveruipanels.cpp new file mode 100644 index 00000000..71572dc1 --- /dev/null +++ b/driveruipanels.cpp @@ -0,0 +1,954 @@ +/* +This Source Code Form is subject to the +terms of the Mozilla Public License, v. +2.0. If a copy of the MPL was not +distributed with this file, You can +obtain one at +http://mozilla.org/MPL/2.0/. +*/ + +#include "stdafx.h" +#include "driveruipanels.h" + +#include "globals.h" +#include "translation.h" +#include "simulation.h" +#include "simulationtime.h" +#include "timer.h" +#include "event.h" +#include "camera.h" +#include "mtable.h" +#include "train.h" +#include "driver.h" +#include "animmodel.h" +#include "dynobj.h" +#include "model3d.h" +#include "renderer.h" +#include "utilities.h" +#include "logs.h" + +#undef snprintf // defined by train.h->pyint.h->python + +void +drivingaid_panel::update() { + + if( false == is_open ) { return; } + + text_lines.clear(); + + auto const *train { simulation::Train }; + auto const *controlled { ( train ? train->Dynamic() : nullptr ) }; + + if( ( controlled == nullptr ) + || ( controlled->Mechanik == nullptr ) ) { return; } + + auto const *mover = controlled->MoverParameters; + auto const *driver = controlled->Mechanik; + + { // throttle, velocity, speed limits and grade + std::string expandedtext; + if( is_expanded ) { + // grade + std::string gradetext; + auto const reverser { ( mover->ActiveDir > 0 ? 1 : -1 ) }; + auto const grade { controlled->VectorFront().y * 100 * ( controlled->DirectionGet() == reverser ? 1 : -1 ) * reverser }; + if( std::abs( grade ) >= 0.25 ) { + std::snprintf( + m_buffer.data(), m_buffer.size(), + locale::strings[ locale::string::driver_aid_grade ].c_str(), + grade ); + gradetext = m_buffer.data(); + } + // next speed limit + auto const speedlimit { static_cast( std::floor( driver->VelDesired ) ) }; + auto const nextspeedlimit { static_cast( std::floor( driver->VelNext ) ) }; + std::string nextspeedlimittext; + if( nextspeedlimit != speedlimit ) { + std::snprintf( + m_buffer.data(), m_buffer.size(), + locale::strings[ locale::string::driver_aid_nextlimit ].c_str(), + nextspeedlimit, + driver->ActualProximityDist * 0.001 ); + nextspeedlimittext = m_buffer.data(); + } + // current speed and limit + std::snprintf( + m_buffer.data(), m_buffer.size(), + locale::strings[ locale::string::driver_aid_speedlimit ].c_str(), + static_cast( std::floor( mover->Vel ) ), + speedlimit, + nextspeedlimittext.c_str(), + gradetext.c_str() ); + expandedtext = m_buffer.data(); + } + // base data and optional bits put together + std::snprintf( + m_buffer.data(), m_buffer.size(), + locale::strings[ locale::string::driver_aid_throttle ].c_str(), + driver->Controlling()->MainCtrlPos, + driver->Controlling()->ScndCtrlPos, + ( mover->ActiveDir > 0 ? 'D' : mover->ActiveDir < 0 ? 'R' : 'N' ), + expandedtext.c_str()); + + text_lines.emplace_back( m_buffer.data(), Global.UITextColor ); + } + + { // brakes, air pressure + std::string expandedtext; + if( is_expanded ) { + std::snprintf ( + m_buffer.data(), m_buffer.size(), + locale::strings[ locale::string::driver_aid_pressures ].c_str(), + mover->BrakePress * 100, + mover->PipePress * 100 ); + expandedtext = m_buffer.data(); + } + std::snprintf( + m_buffer.data(), m_buffer.size(), + locale::strings[ locale::string::driver_aid_brakes ].c_str(), + mover->fBrakeCtrlPos, + mover->LocalBrakePosA * LocalBrakePosNo, + ( mover->SlippingWheels ? '!' : ' ' ), + expandedtext.c_str() ); + + text_lines.emplace_back( m_buffer.data(), Global.UITextColor ); + } + + { // alerter, hints + std::string expandedtext; + if( is_expanded ) { + auto const stoptime { static_cast( -1.0 * controlled->Mechanik->fStopTime ) }; + if( stoptime > 0 ) { + std::snprintf( + m_buffer.data(), m_buffer.size(), + locale::strings[ locale::string::driver_aid_loadinginprogress ].c_str(), + stoptime ); + expandedtext = m_buffer.data(); + } + else { + auto const trackblockdistance{ std::abs( controlled->Mechanik->TrackBlock() ) }; + if( trackblockdistance <= 75.0 ) { + std::snprintf( + m_buffer.data(), m_buffer.size(), + locale::strings[ locale::string::driver_aid_vehicleahead ].c_str(), + trackblockdistance ); + expandedtext = m_buffer.data(); + } + } + } + std::string textline = + ( true == TestFlag( mover->SecuritySystem.Status, s_aware ) ? + locale::strings[ locale::string::driver_aid_alerter ] : + " " ); + textline += + ( true == TestFlag( mover->SecuritySystem.Status, s_active ) ? + locale::strings[ locale::string::driver_aid_shp ] : + " " ); + + text_lines.emplace_back( textline + " " + expandedtext, Global.UITextColor ); + } + + auto const sizex = ( is_expanded ? 735 : 135 ); + size = { sizex, 85 }; +} + +void +timetable_panel::update() { + + if( false == is_open ) { return; } + + text_lines.clear(); + + auto const *train { simulation::Train }; + auto const *controlled { ( train ? train->Dynamic() : nullptr ) }; + auto const &camera { Global.pCamera }; + auto const &time { simulation::Time.data() }; + + { // current time + std::snprintf( + m_buffer.data(), m_buffer.size(), + locale::strings[ locale::string::driver_timetable_time ].c_str(), + time.wHour, + time.wMinute, + time.wSecond ); + + text_lines.emplace_back( m_buffer.data(), Global.UITextColor ); + } + + auto *vehicle { + ( FreeFlyModeFlag ? + std::get( simulation::Region->find_vehicle( camera.Pos, 20, false, false ) ) : + controlled ) }; // w trybie latania lokalizujemy wg mapy + + if( vehicle == nullptr ) { return; } + // if the nearest located vehicle doesn't have a direct driver, try to query its owner + auto const *owner = ( + ( ( vehicle->Mechanik != nullptr ) && ( vehicle->Mechanik->Primary() ) ) ? + vehicle->Mechanik : + vehicle->ctOwner ); + if( owner == nullptr ) { return; } + + auto const *table = owner->TrainTimetable(); + if( table == nullptr ) { return; } + + { // destination + auto textline = Bezogonkow( owner->Relation(), true ); + if( false == textline.empty() ) { + textline += " (" + Bezogonkow( owner->TrainName(), true ) + ")"; + } + + text_lines.emplace_back( textline, Global.UITextColor ); + } + + { // next station + auto const nextstation = Bezogonkow( owner->NextStop(), true ); + if( false == nextstation.empty() ) { + // jeśli jest podana relacja, to dodajemy punkt następnego zatrzymania + auto textline = " -> " + nextstation; + + text_lines.emplace_back( textline, Global.UITextColor ); + } + } + + if( is_expanded ) { + + text_lines.emplace_back( "", Global.UITextColor ); + + if( 0 == table->StationCount ) { + // only bother if there's stations to list + text_lines.emplace_back( locale::strings[ locale::string::driver_timetable_notimetable ], Global.UITextColor ); + } + else { + auto const readycolor { glm::vec4( 84.0f / 255.0f, 164.0f / 255.0f, 132.0f / 255.0f, 1.f ) }; + // header + text_lines.emplace_back( "+-----+------------------------------------+-------+-----+", Global.UITextColor ); + + TMTableLine const *tableline; + for( int i = owner->iStationStart; i <= table->StationCount; ++i ) { + // wyświetlenie pozycji z rozkładu + tableline = table->TimeTable + i; // linijka rozkładu + + std::string vmax = + " " + + to_string( tableline->vmax, 0 ); + vmax = vmax.substr( vmax.size() - 3, 3 ); // z wyrównaniem do prawej + std::string const station = ( + Bezogonkow( tableline->StationName, true ) + + " " ) + .substr( 0, 34 ); + std::string const location = ( + ( tableline->km > 0.0 ? + to_string( tableline->km, 2 ) : + "" ) + + " " ) + .substr( 0, 34 - tableline->StationWare.size() ); + std::string const arrival = ( + tableline->Ah >= 0 ? + to_string( int( 100 + tableline->Ah ) ).substr( 1, 2 ) + ":" + to_string( int( 100 + tableline->Am ) ).substr( 1, 2 ) : + " | " ); + std::string const departure = ( + tableline->Dh >= 0 ? + to_string( int( 100 + tableline->Dh ) ).substr( 1, 2 ) + ":" + to_string( int( 100 + tableline->Dm ) ).substr( 1, 2 ) : + " | " ); + auto const candeparture = ( + ( owner->iStationStart < table->StationIndex ) + && ( i < table->StationIndex ) + && ( ( tableline->Ah < 0 ) // pass-through, always valid + || ( time.wHour * 60 + time.wMinute >= tableline->Dh * 60 + tableline->Dm ) ) ); + auto traveltime = + " " + + ( i < 2 ? "" : + tableline->Ah >= 0 ? to_string( CompareTime( table->TimeTable[ i - 1 ].Dh, table->TimeTable[ i - 1 ].Dm, tableline->Ah, tableline->Am ), 0 ) : + to_string( std::max( 0.0, CompareTime( table->TimeTable[ i - 1 ].Dh, table->TimeTable[ i - 1 ].Dm, tableline->Dh, tableline->Dm ) - 0.5 ), 0 ) ); + traveltime = traveltime.substr( traveltime.size() - 3, 3 ); // z wyrównaniem do prawej + + text_lines.emplace_back( + ( "| " + vmax + " | " + station + " | " + arrival + " | " + traveltime + " |" ), + ( candeparture ? + readycolor :// czas minął i odjazd był, to nazwa stacji będzie na zielono + Global.UITextColor ) ); + text_lines.emplace_back( + ( "| | " + location + tableline->StationWare + " | " + departure + " | |" ), + ( candeparture ? + readycolor :// czas minął i odjazd był, to nazwa stacji będzie na zielono + Global.UITextColor ) ); + // divider/footer + text_lines.emplace_back( "+-----+------------------------------------+-------+-----+", Global.UITextColor ); + } + } + } // is_expanded +} + +void +debug_panel::update() { + + if( false == is_open ) { return; } + + // input item bindings + m_input.train = simulation::Train; + m_input.controlled = ( m_input.train ? m_input.train->Dynamic() : nullptr ); + m_input.camera = &( Global.pCamera ); + m_input.vehicle = + ( FreeFlyModeFlag ? + std::get( simulation::Region->find_vehicle( m_input.camera->Pos, 20, false, false ) ) : + m_input.controlled ); // w trybie latania lokalizujemy wg mapy + m_input.mover = + ( m_input.vehicle != nullptr ? + m_input.vehicle->MoverParameters : + nullptr ); + m_input.mechanik = ( + m_input.vehicle != nullptr ? + m_input.vehicle->Mechanik : + nullptr ); + + // header section + text_lines.clear(); + + auto textline = "Version " + Global.asVersion; + + text_lines.emplace_back( textline, Global.UITextColor ); + + // sub-sections + m_vehiclelines.clear(); + m_enginelines.clear(); + m_ailines.clear(); + m_scantablelines.clear(); + m_scenariolines.clear(); + m_eventqueuelines.clear(); + m_cameralines.clear(); + m_rendererlines.clear(); + + update_section_vehicle( m_vehiclelines ); + update_section_engine( m_enginelines ); + update_section_ai( m_ailines ); + update_section_scantable( m_scantablelines ); + update_section_scenario( m_scenariolines ); + update_section_eventqueue( m_eventqueuelines ); + update_section_camera( m_cameralines ); + update_section_renderer( m_rendererlines ); +} + +void +debug_panel::render() { + + if( false == is_open ) { return; } + + auto flags = + ImGuiWindowFlags_NoFocusOnAppearing + | ImGuiWindowFlags_NoCollapse + | ( size.x > 0 ? ImGuiWindowFlags_NoResize : 0 ); + + if( size.x > 0 ) { + ImGui::SetNextWindowSize( ImVec2( size.x, size.y ) ); + } + if( size_min.x > 0 ) { + ImGui::SetNextWindowSizeConstraints( ImVec2( size_min.x, size_min.y ), ImVec2( size_max.x, size_max.y ) ); + } + if( true == ImGui::Begin( name.c_str(), &is_open, flags ) ) { + // header section + for( auto const &line : text_lines ) { + ImGui::TextColored( ImVec4( line.color.r, line.color.g, line.color.b, line.color.a ), line.data.c_str() ); + } + // sections + ImGui::Separator(); + render_section( "Vehicle", m_vehiclelines ); + render_section( "Vehicle Engine", m_enginelines ); + render_section( "Vehicle AI", m_ailines ); + render_section( "Vehicle Scan Table", m_scantablelines ); + render_section( "Scenario", m_scenariolines ); + if( true == render_section( "Scenario Event Queue", m_eventqueuelines ) ) { + // event queue filter + ImGui::Checkbox( "By This Vehicle Only", &m_eventqueueactivevehicleonly ); + } + render_section( "Camera", m_cameralines ); + render_section( "Gfx Renderer", m_rendererlines ); + // toggles + ImGui::Separator(); + ImGui::Checkbox( "Debug Mode", &DebugModeFlag ); + } + ImGui::End(); +} + +void +debug_panel::update_section_vehicle( std::vector &Output ) { + + if( m_input.vehicle == nullptr ) { return; } + if( m_input.mover == nullptr ) { return; } + + auto const &vehicle { *m_input.vehicle }; + auto const &mover { *m_input.mover }; + + auto const isowned { ( vehicle.Mechanik == nullptr ) && ( vehicle.ctOwner != nullptr ) }; + auto const isplayervehicle { ( m_input.train != nullptr ) && ( m_input.train->Dynamic() == m_input.vehicle ) }; + auto const isdieselenginepowered { ( mover.EngineType == TEngineType::DieselElectric ) || ( mover.EngineType == TEngineType::DieselEngine ) }; + auto const isdieselinshuntmode { mover.ShuntMode && mover.EngineType == TEngineType::DieselElectric }; + + std::snprintf( + m_buffer.data(), m_buffer.size(), + locale::strings[ locale::string::debug_vehicle_nameloadstatuscouplers ].c_str(), + mover.Name.c_str(), + std::string( isowned ? locale::strings[ locale::string::debug_vehicle_owned ].c_str() + vehicle.ctOwner->OwnerName() : "" ).c_str(), + mover.LoadAmount, + mover.LoadType.name.c_str(), + mover.EngineDescription( 0 ).c_str(), + // TODO: put wheel flat reporting in the enginedescription() + std::string( mover.WheelFlat > 0.01 ? " Flat: " + to_string( mover.WheelFlat, 1 ) + " mm" : "" ).c_str(), + update_vehicle_coupler( side::front ).c_str(), + update_vehicle_coupler( side::rear ).c_str() ); + + Output.emplace_back( std::string{ m_buffer.data() }, Global.UITextColor ); + + std::snprintf( + m_buffer.data(), m_buffer.size(), + locale::strings[ locale::string::debug_vehicle_devicespower ].c_str(), + // devices + ( mover.Battery ? 'B' : '.' ), + ( mover.Mains ? 'M' : '.' ), + ( mover.FuseFlag ? '!' : '.' ), + ( mover.PantRearUp ? ( mover.PantRearVolt > 0.0 ? 'O' : 'o' ) : '.' ), + ( mover.PantFrontUp ? ( mover.PantFrontVolt > 0.0 ? 'P' : 'p' ) : '.' ), + ( mover.PantPressLockActive ? '!' : ( mover.PantPressSwitchActive ? '*' : '.' ) ), + ( mover.WaterPump.is_active ? 'W' : ( false == mover.WaterPump.breaker ? '-' : ( mover.WaterPump.is_enabled ? 'w' : '.' ) ) ), + ( true == mover.WaterHeater.is_damaged ? '!' : ( mover.WaterHeater.is_active ? 'H' : ( false == mover.WaterHeater.breaker ? '-' : ( mover.WaterHeater.is_enabled ? 'h' : '.' ) ) ) ), + ( mover.FuelPump.is_active ? 'F' : ( mover.FuelPump.is_enabled ? 'f' : '.' ) ), + ( mover.OilPump.is_active ? 'O' : ( mover.OilPump.is_enabled ? 'o' : '.' ) ), + ( false == mover.ConverterAllowLocal ? '-' : ( mover.ConverterAllow ? ( mover.ConverterFlag ? 'X' : 'x' ) : '.' ) ), + ( mover.ConvOvldFlag ? '!' : '.' ), + ( mover.CompressorFlag ? 'C' : ( false == mover.CompressorAllowLocal ? '-' : ( ( mover.CompressorAllow || mover.CompressorStart == start_t::automatic ) ? 'c' : '.' ) ) ), + ( mover.CompressorGovernorLock ? '!' : '.' ), + std::string( isplayervehicle ? locale::strings[ locale::string::debug_vehicle_radio ] + ( mover.Radio ? std::to_string( m_input.train->RadioChannel() ) : "-" ) : "" ).c_str(), + std::string( isdieselenginepowered ? locale::strings[ locale::string::debug_vehicle_oilpressure ] + to_string( mover.OilPump.pressure, 2 ) : "" ).c_str(), + // power transfers + mover.Couplers[ side::front ].power_high.voltage, + mover.Couplers[ side::front ].power_high.current, + std::string( mover.Couplers[ side::front ].power_high.local ? "" : "-" ).c_str(), + std::string( vehicle.DirectionGet() ? ":<<:" : ":>>:" ).c_str(), + std::string( mover.Couplers[ side::rear ].power_high.local ? "" : "-" ).c_str(), + mover.Couplers[ side::rear ].power_high.voltage, + mover.Couplers[ side::rear ].power_high.current ); + + Output.emplace_back( m_buffer.data(), Global.UITextColor ); + + std::snprintf( + m_buffer.data(), m_buffer.size(), + locale::strings[ locale::string::debug_vehicle_controllersenginerevolutions ].c_str(), + // controllers + mover.MainCtrlPos, + mover.MainCtrlActualPos, + std::string( isdieselinshuntmode ? to_string( mover.AnPos, 2 ) + locale::strings[ locale::string::debug_vehicle_shuntmode ] : std::to_string( mover.ScndCtrlPos ) + "(" + std::to_string( mover.ScndCtrlActualPos ) + ")" ).c_str(), + // engine + mover.EnginePower, + std::abs( mover.TrainType == dt_EZT ? mover.ShowCurrent( 0 ) : mover.Im ), + // revolutions + std::abs( mover.enrot ) * 60, + std::abs( mover.nrot ) * mover.Transmision.Ratio * 60, + mover.RventRot * 60, + mover.MotorBlowers[side::front].revolutions, + mover.MotorBlowers[side::rear].revolutions, + mover.dizel_heat.rpmw, + mover.dizel_heat.rpmw2 ); + + std::string textline { m_buffer.data() }; + + if( isdieselenginepowered ) { + std::snprintf( + m_buffer.data(), m_buffer.size(), + locale::strings[ locale::string::debug_vehicle_temperatures ].c_str(), + mover.dizel_heat.Ts, + mover.dizel_heat.To, + mover.dizel_heat.temperatura1, + ( mover.WaterCircuitsLink ? '-' : '|' ), + mover.dizel_heat.temperatura2 ); + textline += m_buffer.data(); + } + + Output.emplace_back( textline, Global.UITextColor ); + + std::snprintf( + m_buffer.data(), m_buffer.size(), + locale::strings[ locale::string::debug_vehicle_brakespressures ].c_str(), + // brakes + mover.fBrakeCtrlPos, + mover.LocalBrakePosA, + update_vehicle_brake().c_str(), + mover.LoadFlag, + // cylinders + mover.BrakePress, + mover.LocBrakePress, + mover.Hamulec->GetBrakeStatus(), + // pipes + mover.PipePress, + mover.BrakeCtrlPos2, + mover.ScndPipePress, + mover.CntrlPipePress, + // tanks + mover.Volume, + mover.Compressor, + mover.Hamulec->GetCRP() ); + + textline = m_buffer.data(); + + if( mover.EnginePowerSource.SourceType == TPowerSource::CurrentCollector ) { + std::snprintf( + m_buffer.data(), m_buffer.size(), + locale::strings[ locale::string::debug_vehicle_pantograph ].c_str(), + mover.PantPress, + ( mover.bPantKurek3 ? '-' : '|' ) ); + textline += m_buffer.data(); + } + + Output.emplace_back( textline, Global.UITextColor ); + + if( tprev != simulation::Time.data().wSecond ) { + tprev = simulation::Time.data().wSecond; + Acc = ( mover.Vel - VelPrev ) / 3.6; + VelPrev = mover.Vel; + } + + std::snprintf( + m_buffer.data(), m_buffer.size(), + locale::strings[ locale::string::debug_vehicle_forcesaccelerationvelocityposition ].c_str(), + // forces + mover.Ft * 0.001f * ( mover.ActiveCab ? mover.ActiveCab : vehicle.ctOwner ? vehicle.ctOwner->Controlling()->ActiveCab : 1 ) + 0.001f, + mover.Fb * 0.001f, + mover.Adhesive( mover.RunningTrack.friction ), + ( mover.SlippingWheels ? " (!)" : "" ), + // acceleration + Acc, + mover.AccN + 0.001f, + std::string( std::abs( mover.RunningShape.R ) > 10000.0 ? "~0" : to_string( mover.RunningShape.R, 0 ) ).c_str(), + // velocity + vehicle.GetVelocity(), + mover.DistCounter, + // position + vehicle.GetPosition().x, + vehicle.GetPosition().y, + vehicle.GetPosition().z ); + + Output.emplace_back( m_buffer.data(), Global.UITextColor ); +/* + textline = " TC:" + to_string( mover.TotalCurrent, 0 ); +*/ +/* + if( mover.ManualBrakePos > 0 ) { + + textline += "; manual brake on"; + } +*/ +/* + // McZapkie: warto wiedziec w jakim stanie sa przelaczniki + switch( + mover.ActiveDir * + ( mover.Imin == mover.IminLo ? + 1 : + 2 ) ) { + case 2: { textline += " >> "; break; } + case 1: { textline += " -> "; break; } + case 0: { textline += " -- "; break; } + case -1: { textline += " <- "; break; } + case -2: { textline += " << "; break; } + } + + // McZapkie: komenda i jej parametry + if( mover.CommandIn.Command != ( "" ) ) { + textline = + "C:" + mover.CommandIn.Command + + " V1=" + to_string( mover.CommandIn.Value1, 0 ) + + " V2=" + to_string( mover.CommandIn.Value2, 0 ); + } +*/ +} + +std::string +debug_panel::update_vehicle_coupler( int const Side ) { + // NOTE: mover and vehicle are guaranteed to be valid by the caller + std::string couplerstatus { locale::strings[ locale::string::debug_vehicle_none ] }; + + auto const *connected { ( + Side == side::front ? + m_input.vehicle->PrevConnected : + m_input.vehicle->NextConnected ) }; + + if( connected == nullptr ) { return couplerstatus; } + + auto const &mover { *( m_input.mover ) }; + + std::snprintf( + m_buffer.data(), m_buffer.size(), + "%s [%d]%s", + connected->name().c_str(), + mover.Couplers[ Side ].CouplingFlag, + std::string( mover.Couplers[ Side ].CouplingFlag == 0 ? " (" + to_string( mover.Couplers[ Side ].CoupleDist, 1 ) + " m)" : "" ).c_str() ); + + return { m_buffer.data() }; +} + +std::string +debug_panel::update_vehicle_brake() const { + // NOTE: mover is guaranteed to be valid by the caller + auto const &mover { *( m_input.mover ) }; + + std::string brakedelay; + + std::vector> delays { + { bdelay_G, "G" }, + { bdelay_P, "P" }, + { bdelay_R, "R" }, + { bdelay_M, "+Mg" } }; + + for( auto const &delay : delays ) { + if( ( mover.BrakeDelayFlag & delay.first ) == delay.first ) { + brakedelay += delay.second; + } + } + + return brakedelay; +} + +void +debug_panel::update_section_engine( std::vector &Output ) { + + if( m_input.train == nullptr ) { return; } + if( m_input.vehicle == nullptr ) { return; } + if( m_input.mover == nullptr ) { return; } + + auto const &train { *m_input.train }; + auto const &vehicle{ *m_input.vehicle }; + auto const &mover{ *m_input.mover }; + + // engine data + // induction motor data + if( mover.EngineType == TEngineType::ElectricInductionMotor ) { + + Output.emplace_back( " eimc: eimv: press:", Global.UITextColor ); + for( int i = 0; i <= 20; ++i ) { + + std::string parameters = + mover.eimc_labels[ i ] + to_string( mover.eimc[ i ], 2, 9 ) + + " | " + + mover.eimv_labels[ i ] + to_string( mover.eimv[ i ], 2, 9 ); + + if( i < 10 ) { + parameters += " | " + train.fPress_labels[ i ] + to_string( train.fPress[ i ][ 0 ], 2, 9 ); + } + else if( i == 12 ) { + parameters += " med:"; + } + else if( i >= 13 ) { + parameters += " | " + vehicle.MED_labels[ i - 13 ] + to_string( vehicle.MED[ 0 ][ i - 13 ], 2, 9 ); + } + + Output.emplace_back( parameters, Global.UITextColor ); + } + } + if( mover.EngineType == TEngineType::DieselEngine ) { + + std::string parameterstext = "param value"; + std::vector< std::pair > const paramvalues { + { "efill: ", mover.dizel_fill }, + { "etorq: ", mover.dizel_Torque }, + { "creal: ", mover.dizel_engage }, + { "cdesi: ", mover.dizel_engagestate }, + { "cdelt: ", mover.dizel_engagedeltaomega }, + { "gears: ", mover.dizel_automaticgearstatus} }; + for( auto const ¶meter : paramvalues ) { + parameterstext += "\n" + parameter.first + to_string( parameter.second, 2, 9 ); + } + Output.emplace_back( parameterstext, Global.UITextColor ); + + parameterstext = "hydro value"; + std::vector< std::pair > const hydrovalues { + { "hTCnI: ", mover.hydro_TC_nIn }, + { "hTCnO: ", mover.hydro_TC_nOut }, + { "hTCTM: ", mover.hydro_TC_TMRatio }, + { "hTCTI: ", mover.hydro_TC_TorqueIn }, + { "hTCTO: ", mover.hydro_TC_TorqueOut }, + { "hTCfl: ", mover.hydro_TC_Fill }, + { "hTCLR: ", mover.hydro_TC_LockupRate } }; + for( auto const ¶meter : hydrovalues ) { + parameterstext += "\n" + parameter.first + to_string( parameter.second, 2, 9 ); + } + Output.emplace_back( parameterstext, Global.UITextColor ); + } +} + +void +debug_panel::update_section_ai( std::vector &Output ) { + + if( m_input.mover == nullptr ) { return; } + if( m_input.mechanik == nullptr ) { return; } + + auto const &mover{ *m_input.mover }; + auto const &mechanik{ *m_input.mechanik }; + + // biezaca komenda dla AI + auto textline = "Current order: " + mechanik.OrderCurrent(); + + Output.emplace_back( textline, Global.UITextColor ); + + if( ( mechanik.VelNext == 0.0 ) + && ( mechanik.eSignNext ) ) { + // jeśli ma zapamiętany event semafora, nazwa eventu semafora + Output.emplace_back( "Current signal: " + Bezogonkow( mechanik.eSignNext->m_name ), Global.UITextColor ); + } + + // distances + textline = + "Distances:\n proximity: " + to_string( mechanik.ActualProximityDist, 0 ) + + ", braking: " + to_string( mechanik.fBrakeDist, 0 ); + + Output.emplace_back( textline, Global.UITextColor ); + + // velocity factors + textline = + "Velocity:\n desired: " + to_string( mechanik.VelDesired, 0 ) + + ", next: " + to_string( mechanik.VelNext, 0 ); + + std::vector< std::pair< double, std::string > > const restrictions{ + { mechanik.VelSignalLast, "signal" }, + { mechanik.VelLimitLast, "limit" }, + { mechanik.VelRoad, "road" }, + { mechanik.VelRestricted, "restricted" }, + { mover.RunningTrack.Velmax, "track" } }; + + std::string restrictionstext; + for( auto const &restriction : restrictions ) { + if( restriction.first < 0.0 ) { continue; } + if( false == restrictionstext.empty() ) { + restrictionstext += ", "; + } + restrictionstext += + to_string( restriction.first, 0 ) + + " (" + restriction.second + ")"; + } + + if( false == restrictionstext.empty() ) { + textline += "\n restrictions: " + restrictionstext; + } + + Output.emplace_back( textline, Global.UITextColor ); + + // acceleration + textline = + "Acceleration:\n desired: " + to_string( mechanik.AccDesired, 2 ) + + ", corrected: " + to_string( mechanik.AccDesired * mechanik.BrakeAccFactor(), 2 ) + + "\n current: " + to_string( mechanik.AbsAccS_pub + 0.001f, 2 ) + + ", slope: " + to_string( mechanik.fAccGravity + 0.001f, 2 ) + " (" + ( mechanik.fAccGravity > 0.01 ? "\\" : ( mechanik.fAccGravity < -0.01 ? "/" : "-" ) ) + ")" + + "\n brake threshold: " + to_string( mechanik.fAccThreshold, 2 ) + + ", delays: " + to_string( mechanik.fBrake_a0[ 0 ], 2 ) + + "+" + to_string( mechanik.fBrake_a1[ 0 ], 2 ); + + Output.emplace_back( textline, Global.UITextColor ); + + // brakes + textline = + "Brakes:\n consist: " + to_string( mechanik.fReady, 2 ) + " or less"; + + Output.emplace_back( textline, Global.UITextColor ); + + // ai driving flags + std::vector const drivingflagnames { + "StopCloser", "StopPoint", "Active", "Press", "Connect", "Primary", "Late", "StopHere", + "StartHorn", "StartHornNow", "StartHornDone", "Oerlikons", "IncSpeed", "TrackEnd", "SwitchFound", "GuardSignal", + "Visibility", "DoorOpened", "PushPull", "SemaphorFound", "StopPointFound" /*"SemaphorWasElapsed", "TrainInsideStation", "SpeedLimitFound"*/ }; + + textline = "Driving flags:"; + for( int idx = 0, flagbit = 1; idx < drivingflagnames.size(); ++idx, flagbit <<= 1 ) { + if( mechanik.DrivigFlags() & flagbit ) { + textline += "\n " + drivingflagnames[ idx ]; + } + } + + Output.emplace_back( textline, Global.UITextColor ); +} + +void +debug_panel::update_section_scantable( std::vector &Output ) { + + if( m_input.mechanik == nullptr ) { return; } + + Output.emplace_back( "Flags: Dist: Vel: Name:", Global.UITextColor ); + + auto const &mechanik{ *m_input.mechanik }; + + std::size_t i = 0; std::size_t const speedtablesize = clamp( static_cast( mechanik.TableSize() ) - 1, 0, 30 ); + do { + auto const scanline = mechanik.TableText( i ); + if( scanline.empty() ) { break; } + Output.emplace_back( Bezogonkow( scanline ), Global.UITextColor ); + ++i; + } while( i < speedtablesize ); + if( Output.size() == 1 ) { + Output.front().data = "(no points of interest)"; + } +} + +void +debug_panel::update_section_scenario( std::vector &Output ) { + + auto textline = + "vehicles: " + to_string( Timer::subsystem.sim_dynamics.average(), 2 ) + " msec" + + " update total: " + to_string( Timer::subsystem.sim_total.average(), 2 ) + " msec"; + + Output.emplace_back( textline, Global.UITextColor ); + // current luminance level + textline = "Cloud cover: " + to_string( Global.Overcast, 3 ); + textline += "\nLight level: " + to_string( Global.fLuminance, 3 ); + if( Global.FakeLight ) { textline += "(*)"; } + textline += "\nAir temperature: " + to_string( Global.AirTemperature, 1 ) + " deg C"; + + Output.emplace_back( textline, Global.UITextColor ); +} + +void +debug_panel::update_section_eventqueue( std::vector &Output ) { + + std::string textline; + + // current event queue + auto const time { Timer::GetTime() }; + auto const *event { simulation::Events.begin() }; + + Output.emplace_back( "Delay: Event:", Global.UITextColor ); + + while( ( event != nullptr ) + && ( Output.size() < 30 ) ) { + + if( ( false == event->m_ignored ) + && ( false == event->m_passive ) + && ( ( false == m_eventqueueactivevehicleonly ) + || ( event->m_activator == m_input.vehicle ) ) ) { + + auto const delay { " " + to_string( std::max( 0.0, event->m_launchtime - time ), 1 ) }; + textline = delay.substr( delay.length() - 6 ) + + " " + event->m_name + + ( event->m_activator ? " (by: " + event->m_activator->asName + ")" : "" ) + + ( event->m_sibling ? " (joint event)" : "" ); + + Output.emplace_back( textline, Global.UITextColor ); + } + event = event->m_next; + } + if( Output.size() == 1 ) { + Output.front().data = "(no queued events)"; + } +} + +void +debug_panel::update_section_camera( std::vector &Output ) { + + if( m_input.camera == nullptr ) { return; } + + auto const &camera{ *m_input.camera }; + + // camera data + auto textline = + "Position: [" + + to_string( camera.Pos.x, 2 ) + ", " + + to_string( camera.Pos.y, 2 ) + ", " + + to_string( camera.Pos.z, 2 ) + "]"; + + Output.emplace_back( textline, Global.UITextColor ); + + textline = + "Azimuth: " + + to_string( 180.0 - glm::degrees( camera.Yaw ), 0 ) // ma być azymut, czyli 0 na północy i rośnie na wschód + + " " + + std::string( "S SEE NEN NWW SW" ) + .substr( 0 + 2 * floor( fmod( 8 + ( camera.Yaw + 0.5 * M_PI_4 ) / M_PI_4, 8 ) ), 2 ); + + Output.emplace_back( textline, Global.UITextColor ); +} + +void +debug_panel::update_section_renderer( std::vector &Output ) { + + // gfx renderer data + auto textline = + "FoV: " + to_string( Global.FieldOfView / Global.ZoomFactor, 1 ) + + ", Draw range x " + to_string( Global.fDistanceFactor, 1 ) +// + "; sectors: " + std::to_string( GfxRenderer.m_drawcount ) +// + ", FPS: " + to_string( Timer::GetFPS(), 2 ); + + ", FPS: " + std::to_string( static_cast(std::round(GfxRenderer.Framerate())) ); + if( Global.iSlowMotion ) { + textline += " (slowmotion " + to_string( Global.iSlowMotion ) + ")"; + } + + Output.emplace_back( textline, Global.UITextColor ); + + textline = + std::string( "Rendering mode: " ) + + ( Global.bUseVBO ? + "VBO" : + "Display Lists" ) + + " "; + if( false == Global.LastGLError.empty() ) { + textline += + "Last openGL error: " + + Global.LastGLError; + } + + Output.emplace_back( textline, Global.UITextColor ); + + // renderer stats + Output.emplace_back( GfxRenderer.info_times(), Global.UITextColor ); + Output.emplace_back( GfxRenderer.info_stats(), Global.UITextColor ); +} + +bool +debug_panel::render_section( std::string const &Header, std::vector const &Lines ) { + + if( true == Lines.empty() ) { return false; } + if( false == ImGui::CollapsingHeader( Header.c_str() ) ) { return false; } + + for( auto const &line : Lines ) { + ImGui::TextColored( ImVec4( line.color.r, line.color.g, line.color.b, line.color.a ), line.data.c_str() ); + } + return true; +} + +void +transcripts_panel::update() { + + if( false == is_open ) { return; } + + text_lines.clear(); + + for( auto const &transcript : ui::Transcripts.aLines ) { + if( Global.fTimeAngleDeg >= transcript.fShow ) { + // NOTE: legacy transcript lines use | as new line mark + text_lines.emplace_back( ExchangeCharInString( transcript.asText, '|', ' ' ), colors::white ); + } + } +} + +void +transcripts_panel::render() { + + if( false == is_open ) { return; } + if( true == text_lines.empty() ) { return; } + + auto flags = + ImGuiWindowFlags_NoFocusOnAppearing + | ImGuiWindowFlags_NoCollapse + | ( size.x > 0 ? ImGuiWindowFlags_NoResize : 0 ); + + if( size.x > 0 ) { + ImGui::SetNextWindowSize( ImVec2( size.x, size.y ) ); + } + if( size_min.x > 0 ) { + ImGui::SetNextWindowSizeConstraints( ImVec2( size_min.x, size_min.y ), ImVec2( size_max.x, size_max.y ) ); + } + auto const panelname { ( + title.empty() ? + name : + title ) + + "###" + name }; + if( true == ImGui::Begin( panelname.c_str(), &is_open, flags ) ) { + // header section + for( auto const &line : text_lines ) { + ImGui::TextWrapped( line.data.c_str() ); + } + } + ImGui::End(); +} diff --git a/driveruipanels.h b/driveruipanels.h new file mode 100644 index 00000000..505565be --- /dev/null +++ b/driveruipanels.h @@ -0,0 +1,106 @@ +/* +This Source Code Form is subject to the +terms of the Mozilla Public License, v. +2.0. If a copy of the MPL was not +distributed with this file, You can +obtain one at +http://mozilla.org/MPL/2.0/. +*/ + +#pragma once + +#include "uilayer.h" +#include "classes.h" + +class drivingaid_panel : public ui_panel { + +public: + drivingaid_panel( std::string const &Name, bool const Isopen ) + : ui_panel( Name, Isopen ) + {} + + void update() override; + + bool is_expanded { false }; + +private: +// members + std::array m_buffer; +}; + +class timetable_panel : public ui_panel { + +public: + timetable_panel( std::string const &Name, bool const Isopen ) + : ui_panel( Name, Isopen ) {} + + void update() override; + + bool is_expanded{ false }; + +private: + // members + std::array m_buffer; +}; + +class debug_panel : public ui_panel { + +public: + debug_panel( std::string const &Name, bool const Isopen ) + : ui_panel( Name, Isopen ) {} + + void update() override; + void render() override; + +private: +// types + struct input_data { + TTrain const *train; + TDynamicObject const *controlled; + TCamera const *camera; + TDynamicObject const *vehicle; + TMoverParameters const *mover; + TController const *mechanik; + }; +// methods + // generate and send section data to provided output + void update_section_vehicle( std::vector &Output ); + void update_section_engine( std::vector &Output ); + void update_section_ai( std::vector &Output ); + void update_section_scantable( std::vector &Output ); + void update_section_scenario( std::vector &Output ); + void update_section_eventqueue( std::vector &Output ); + void update_section_camera( std::vector &Output ); + void update_section_renderer( std::vector &Output ); + // section update helpers + std::string update_vehicle_coupler( int const Side ); + std::string update_vehicle_brake() const; + // renders provided lines, under specified collapsing header + bool render_section( std::string const &Header, std::vector const &Lines ); +// members + std::array m_buffer; + input_data m_input; + std::vector + m_vehiclelines, + m_enginelines, + m_ailines, + m_scantablelines, + m_cameralines, + m_scenariolines, + m_eventqueuelines, + m_rendererlines; + int tprev { 0 }; // poprzedni czas + double VelPrev { 0.0 }; // poprzednia prędkość + double Acc { 0.0 }; // przyspieszenie styczne + bool m_eventqueueactivevehicleonly { false }; +}; + +class transcripts_panel : public ui_panel { + +public: + transcripts_panel( std::string const &Name, bool const Isopen ) + : ui_panel( Name, Isopen ) {} + + void update() override; + void render() override; +}; diff --git a/dumb3d.h b/dumb3d.h index 0ed4f67f..8a39af53 100644 --- a/dumb3d.h +++ b/dumb3d.h @@ -64,15 +64,17 @@ class vector3 public: vector3(void) : x(0.0), y(0.0), z(0.0) - { - } - vector3(scalar_t a, scalar_t b, scalar_t c) - { - x = a; - y = b; - z = c; - } - + {} + vector3( scalar_t X, scalar_t Y, scalar_t Z ) : + x( X ), y( Y ), z( Z ) + {} + template + vector3( glm::tvec3 const &Vector ) : + x( Vector.x ), y( Vector.y ), z( Vector.z ) + {} + template + operator glm::tvec3() const { + return glm::tvec3{ x, y, z }; } // The int parameter is the number of elements to copy from initArray (3 or 4) // explicit vector3(scalar_t* initArray, int arraySize = 3) // { for (int i = 0;ix) > 0.02) @@ -131,21 +128,22 @@ class matrix4x4 public: matrix4x4(void) { - ::SecureZeroMemory( e, sizeof( e ) ); + memset( e, 0, sizeof( e ) ); } // When defining matrices in C arrays, it is easiest to define them with // the column increasing fastest. However, some APIs (OpenGL in particular) do this // backwards, hence the "constructor" from C matrices, or from OpenGL matrices. // Note that matrices are stored internally in OpenGL format. - void C_Matrix(scalar_t *initArray) + void C_Matrix(scalar_t const *initArray) { int i = 0; for (int y = 0; y < 4; ++y) for (int x = 0; x < 4; ++x) (*this)(x)[y] = initArray[i++]; } - void OpenGL_Matrix(scalar_t *initArray) + template + void OpenGL_Matrix(Type_ const *initArray) { int i = 0; for (int x = 0; x < 4; ++x) @@ -165,7 +163,7 @@ class matrix4x4 } // Low-level access to the array. - const scalar_t *readArray(void) + const scalar_t *readArray(void) const { return e; } @@ -415,6 +413,11 @@ inline vector3 CrossProduct(const vector3 &v1, const vector3 &v2) return vector3(v1.y * v2.z - v1.z * v2.y, v2.x * v1.z - v2.z * v1.x, v1.x * v2.y - v1.y * v2.x); } +inline vector3 Interpolate( vector3 const &First, vector3 const &Second, float const Factor ) { + + return ( First * ( 1.0f - Factor ) ) + ( Second * Factor ); +} + inline vector3 operator*(const matrix4x4 &m, const vector3 &v) { return vector3(v.x * m[0][0] + v.y * m[1][0] + v.z * m[2][0] + m[3][0], @@ -430,11 +433,16 @@ void inline vector3::Normalize() z *= il; } -double inline vector3::Length() +double inline vector3::Length() const { return SQRT_FUNCTION(x * x + y * y + z * z); } +double inline vector3::LengthSquared() const { + + return ( x * x + y * y + z * z ); +} + inline bool operator==(const matrix4x4 &m1, const matrix4x4 &m2) { for (int x = 0; x < 4; ++x) diff --git a/editorkeyboardinput.cpp b/editorkeyboardinput.cpp new file mode 100644 index 00000000..0e88137a --- /dev/null +++ b/editorkeyboardinput.cpp @@ -0,0 +1,38 @@ +/* +This Source Code Form is subject to the +terms of the Mozilla Public License, v. +2.0. If a copy of the MPL was not +distributed with this file, You can +obtain one at +http://mozilla.org/MPL/2.0/. +*/ + +#include "stdafx.h" +#include "editorkeyboardinput.h" + +bool +editorkeyboard_input::init() { + + default_bindings(); + // TODO: re-enable after mode-specific binding import is in place + // return recall_bindings(); + bind(); + m_bindingsetups.clear(); + + return true; +} + +void +editorkeyboard_input::default_bindings() { + + m_bindingsetups = { + { user_command::moveleft, GLFW_KEY_LEFT }, + { user_command::moveright, GLFW_KEY_RIGHT }, + { user_command::moveforward, GLFW_KEY_UP }, + { user_command::moveback, GLFW_KEY_DOWN }, + { user_command::moveup, GLFW_KEY_PAGE_UP }, + { user_command::movedown, GLFW_KEY_PAGE_DOWN }, + }; +} + +//--------------------------------------------------------------------------- diff --git a/editorkeyboardinput.h b/editorkeyboardinput.h new file mode 100644 index 00000000..138ba99d --- /dev/null +++ b/editorkeyboardinput.h @@ -0,0 +1,27 @@ +/* +This Source Code Form is subject to the +terms of the Mozilla Public License, v. +2.0. If a copy of the MPL was not +distributed with this file, You can +obtain one at +http://mozilla.org/MPL/2.0/. +*/ + +#pragma once + +#include "keyboardinput.h" + +class editorkeyboard_input : public keyboard_input { + +public: +// methods + bool + init() override; + +protected: +// methods + void + default_bindings() override; +}; + +//--------------------------------------------------------------------------- diff --git a/editormode.cpp b/editormode.cpp new file mode 100644 index 00000000..cd376707 --- /dev/null +++ b/editormode.cpp @@ -0,0 +1,276 @@ +/* +This Source Code Form is subject to the +terms of the Mozilla Public License, v. +2.0. If a copy of the MPL was not +distributed with this file, You can +obtain one at +http://mozilla.org/MPL/2.0/. +*/ + +#include "stdafx.h" +#include "editormode.h" +#include "editoruilayer.h" + +#include "application.h" +#include "globals.h" +#include "simulation.h" +#include "simulationtime.h" +#include "simulationenvironment.h" +#include "timer.h" +#include "console.h" +#include "renderer.h" + +bool +editor_mode::editormode_input::init() { + + return ( + mouse.init() + && keyboard.init() ); +} + +void +editor_mode::editormode_input::poll() { + + keyboard.poll(); +} + +editor_mode::editor_mode() { + + m_userinterface = std::make_shared(); +} + +// initializes internal data structures of the mode. returns: true on success, false otherwise +bool +editor_mode::init() { + + Camera.Init( { 0, 15, 0 }, { glm::radians( -30.0 ), glm::radians( 180.0 ), 0 }, TCameraType::tp_Free ); + + return m_input.init(); +} + +// mode-specific update of simulation data. returns: false on error, true otherwise +bool +editor_mode::update() { + + Timer::UpdateTimers( true ); + + simulation::State.update_clocks(); + simulation::Environment.update(); + + // render time routines follow: + auto const deltarealtime = Timer::GetDeltaRenderTime(); // nie uwzględnia pauzowania ani mnożenia czasu + + // fixed step render time routines: + fTime50Hz += deltarealtime; // w pauzie też trzeba zliczać czas, bo przy dużym FPS będzie problem z odczytem ramek + while( fTime50Hz >= 1.0 / 50.0 ) { + Console::Update(); // to i tak trzeba wywoływać + m_userinterface->update(); + // decelerate camera + Camera.Velocity *= 0.65; + if( std::abs( Camera.Velocity.x ) < 0.01 ) { Camera.Velocity.x = 0.0; } + if( std::abs( Camera.Velocity.y ) < 0.01 ) { Camera.Velocity.y = 0.0; } + if( std::abs( Camera.Velocity.z ) < 0.01 ) { Camera.Velocity.z = 0.0; } + + fTime50Hz -= 1.0 / 50.0; + } + + // variable step render time routines: + update_camera( deltarealtime ); + + simulation::Region->update_sounds(); + audio::renderer.update( deltarealtime ); + + GfxRenderer.Update( deltarealtime ); + + simulation::is_ready = true; + + return true; +} + +void +editor_mode::update_camera( double const Deltatime ) { + + // uwzględnienie ruchu wywołanego klawiszami + Camera.Update(); + // reset window state, it'll be set again if applicable in a check below + Global.CabWindowOpen = false; + // all done, update camera position to the new value + Global.pCamera = Camera; +} + +// maintenance method, called when the mode is activated +void +editor_mode::enter() { + + m_statebackup = { Global.pCamera, FreeFlyModeFlag, Global.ControlPicking }; + + Global.pCamera = Camera; + FreeFlyModeFlag = true; + Global.ControlPicking = true; + EditorModeFlag = true; + + Application.set_cursor( GLFW_CURSOR_NORMAL ); +} + +// maintenance method, called when the mode is deactivated +void +editor_mode::exit() { + + EditorModeFlag = false; + Global.ControlPicking = m_statebackup.picking; + FreeFlyModeFlag = m_statebackup.freefly; + Global.pCamera = m_statebackup.camera; + + Application.set_cursor( + ( Global.ControlPicking ? + GLFW_CURSOR_NORMAL : + GLFW_CURSOR_DISABLED ) ); + + if( false == Global.ControlPicking ) { + Application.set_cursor_pos( 0, 0 ); + } +} + +void +editor_mode::on_key( int const Key, int const Scancode, int const Action, int const Mods ) { + + Global.shiftState = ( Mods & GLFW_MOD_SHIFT ) ? true : false; + Global.ctrlState = ( Mods & GLFW_MOD_CONTROL ) ? true : false; + Global.altState = ( Mods & GLFW_MOD_ALT ) ? true : false; + + // give the ui first shot at the input processing... + if( true == m_userinterface->on_key( Key, Action ) ) { return; } + // ...if the input is left untouched, pass it on + if( true == m_input.keyboard.key( Key, Action ) ) { return; } + + if( Action == GLFW_RELEASE ) { return; } + + // legacy hardcoded keyboard commands + // TODO: replace with current command system, move to input object(s) + switch( Key ) { + + case GLFW_KEY_F11: { + + if( Action != GLFW_PRESS ) { break; } + // mode switch + // TODO: unsaved changes warning + if( ( false == Global.ctrlState ) + && ( false == Global.shiftState ) ) { + Application.pop_mode(); + } + // scenery export + if( Global.ctrlState + && Global.shiftState ) { + simulation::State.export_as_text( Global.SceneryFile ); + } + break; + } + + case GLFW_KEY_F12: { + // quick debug mode toggle + if( Global.ctrlState + && Global.shiftState ) { + DebugModeFlag = !DebugModeFlag; + } + break; + } + + default: { + break; + } + } +} + +void +editor_mode::on_cursor_pos( double const Horizontal, double const Vertical ) { + + auto const mousemove { glm::dvec2{ Horizontal, Vertical } - m_input.mouse.position() }; + m_input.mouse.position( Horizontal, Vertical ); + + if( m_input.mouse.button( GLFW_MOUSE_BUTTON_LEFT ) == GLFW_RELEASE ) { return; } + if( m_node == nullptr ) { return; } + + if( m_takesnapshot ) { + // take a snapshot of selected node(s) + // TODO: implement this + m_takesnapshot = false; + } + + if( mode_translation() ) { + // move selected node + if( mode_translation_vertical() ) { + auto const translation { mousemove.y * -0.01f }; + m_editor.translate( m_node, translation ); + } + else { + auto const mouseworldposition { Camera.Pos + GfxRenderer.Mouse_Position() }; + m_editor.translate( m_node, mouseworldposition, mode_snap() ); + } + } + else { + // rotate selected node + auto const rotation { glm::vec3 { mousemove.y, mousemove.x, 0 } * 0.25f }; + auto const quantization { ( + mode_snap() ? + 15.f : // TODO: put quantization value in a variable + 0.f ) }; + m_editor.rotate( m_node, rotation, quantization ); + } + +} + +void +editor_mode::on_mouse_button( int const Button, int const Action, int const Mods ) { + + if( Button == GLFW_MOUSE_BUTTON_LEFT ) { + + if( Action == GLFW_PRESS ) { + // left button press + m_node = GfxRenderer.Update_Pick_Node(); + if( m_node ) { + Application.set_cursor( GLFW_CURSOR_DISABLED ); + } + dynamic_cast( m_userinterface.get() )->set_node( m_node ); + } + else { + // left button release + if( m_node ) { + Application.set_cursor( GLFW_CURSOR_NORMAL ); + } + // prime history stack for another snapshot + m_takesnapshot = true; + } + } + + m_input.mouse.button( Button, Action ); +} + +void +editor_mode::on_event_poll() { + + m_input.poll(); +} + +bool +editor_mode::mode_translation() const { + + return ( false == Global.altState ); +} + +bool +editor_mode::mode_translation_vertical() const { + + return ( true == Global.shiftState ); +} + +bool +editor_mode::mode_rotation() const { + + return ( true == Global.altState ); +} + +bool +editor_mode::mode_snap() const { + + return ( true == Global.ctrlState ); +} diff --git a/editormode.h b/editormode.h new file mode 100644 index 00000000..2a996caa --- /dev/null +++ b/editormode.h @@ -0,0 +1,86 @@ +/* +This Source Code Form is subject to the +terms of the Mozilla Public License, v. +2.0. If a copy of the MPL was not +distributed with this file, You can +obtain one at +http://mozilla.org/MPL/2.0/. +*/ + +#pragma once + +#include "applicationmode.h" +#include "editormouseinput.h" +#include "editorkeyboardinput.h" +#include "camera.h" +#include "sceneeditor.h" +#include "scenenode.h" + +class editor_mode : public application_mode { + +public: +// constructors + editor_mode(); +// methods + // initializes internal data structures of the mode. returns: true on success, false otherwise + bool + init() override; + // mode-specific update of simulation data. returns: false on error, true otherwise + bool + update() override; + // maintenance method, called when the mode is activated + void + enter() override; + // maintenance method, called when the mode is deactivated + void + exit() override; + // input handlers + void + on_key( int const Key, int const Scancode, int const Action, int const Mods ) override; + void + on_cursor_pos( double const Horizontal, double const Vertical ) override; + void + on_mouse_button( int const Button, int const Action, int const Mods ) override; + void + on_scroll( double const Xoffset, double const Yoffset ) override { ; } + void + on_event_poll() override; + +private: +// types + struct editormode_input { + + editormouse_input mouse; + editorkeyboard_input keyboard; + + bool init(); + void poll(); + }; + + struct state_backup { + + TCamera camera; + bool freefly; + bool picking; + }; +// methods + void + update_camera( double const Deltatime ); + bool + mode_translation() const; + bool + mode_translation_vertical() const; + bool + mode_rotation() const; + bool + mode_snap() const; +// members + editormode_input m_input; + TCamera Camera; + double fTime50Hz { 0.0 }; // bufor czasu dla komunikacji z PoKeys + scene::basic_editor m_editor; + scene::basic_node *m_node; // currently selected scene node + bool m_takesnapshot { true }; // helper, hints whether snapshot of selected node(s) should be taken before modification + state_backup m_statebackup; // helper, cached variables to be restored on mode exit + +}; diff --git a/editormouseinput.cpp b/editormouseinput.cpp new file mode 100644 index 00000000..a8a01ad2 --- /dev/null +++ b/editormouseinput.cpp @@ -0,0 +1,55 @@ +/* +This Source Code Form is subject to the +terms of the Mozilla Public License, v. +2.0. If a copy of the MPL was not +distributed with this file, You can +obtain one at +http://mozilla.org/MPL/2.0/. +*/ + +#include "stdafx.h" +#include "editormouseinput.h" + +bool +editormouse_input::init() { + + return true; +} + +void +editormouse_input::position( double Horizontal, double Vertical ) { + + if( false == m_pickmodepanning ) { + // even if the view panning isn't active we capture the cursor position in case it does get activated + m_cursorposition.x = Horizontal; + m_cursorposition.y = Vertical; + return; + } + glm::dvec2 cursorposition { Horizontal, Vertical }; + auto const viewoffset = cursorposition - m_cursorposition; + m_relay.post( + user_command::viewturn, + viewoffset.x, + viewoffset.y, + GLFW_PRESS, + // as we haven't yet implemented either item id system or multiplayer, the 'local' controlled vehicle and entity have temporary ids of 0 + // TODO: pass correct entity id once the missing systems are in place + 0 ); + m_cursorposition = cursorposition; +} + +void +editormouse_input::button( int const Button, int const Action ) { + + // store key state + if( Button >= 0 ) { + m_buttons[ Button ] = Action; + } + + // right button controls panning + if( Button == GLFW_MOUSE_BUTTON_RIGHT ) { + m_pickmodepanning = ( Action == GLFW_PRESS ); + } +} + +//--------------------------------------------------------------------------- diff --git a/editormouseinput.h b/editormouseinput.h new file mode 100644 index 00000000..3f33af2c --- /dev/null +++ b/editormouseinput.h @@ -0,0 +1,44 @@ +/* +This Source Code Form is subject to the +terms of the Mozilla Public License, v. +2.0. If a copy of the MPL was not +distributed with this file, You can +obtain one at +http://mozilla.org/MPL/2.0/. +*/ + +#pragma once + +#include "command.h" + +class editormouse_input { + +public: +// constructors + editormouse_input() = default; + +// methods + bool + init(); + void + position( double const Horizontal, double const Vertical ); + inline + glm::dvec2 + position() const { + return m_cursorposition; } + void + button( int const Button, int const Action ); + inline + int + button( int const Button ) const { + return m_buttons[ Button ]; } + +private: +// members + command_relay m_relay; + bool m_pickmodepanning { false }; // indicates mouse is in view panning mode + glm::dvec2 m_cursorposition { 0.0 }; // stored last cursor position, used for panning + std::array m_buttons { GLFW_RELEASE }; +}; + +//--------------------------------------------------------------------------- diff --git a/editoruilayer.cpp b/editoruilayer.cpp new file mode 100644 index 00000000..2513b07b --- /dev/null +++ b/editoruilayer.cpp @@ -0,0 +1,54 @@ +/* +This Source Code Form is subject to the +terms of the Mozilla Public License, v. +2.0. If a copy of the MPL was not +distributed with this file, You can +obtain one at +http://mozilla.org/MPL/2.0/. +*/ + +#include "stdafx.h" +#include "editoruilayer.h" + +#include "globals.h" +#include "renderer.h" + +editor_ui::editor_ui() { + + clear_panels(); + // bind the panels with ui object. maybe not the best place for this but, eh + push_back( &m_itempropertiespanel ); +} + +// potentially processes provided input key. returns: true if key was processed, false otherwise +bool +editor_ui::on_key( int const Key, int const Action ) { + + return false; +} + +// updates state of UI elements +void +editor_ui::update() { + + set_tooltip( "" ); + + if( ( true == Global.ControlPicking ) + && ( true == DebugModeFlag ) ) { + + auto const scenerynode = GfxRenderer.Pick_Node(); + set_tooltip( + ( scenerynode ? + scenerynode->name() : + "" ) ); + } + + ui_layer::update(); + m_itempropertiespanel.update( m_node ); +} + +void +editor_ui::set_node( scene::basic_node * Node ) { + + m_node = Node; +} diff --git a/editoruilayer.h b/editoruilayer.h new file mode 100644 index 00000000..95b06169 --- /dev/null +++ b/editoruilayer.h @@ -0,0 +1,40 @@ +/* +This Source Code Form is subject to the +terms of the Mozilla Public License, v. +2.0. If a copy of the MPL was not +distributed with this file, You can +obtain one at +http://mozilla.org/MPL/2.0/. +*/ + +#pragma once + +#include "uilayer.h" +#include "editoruipanels.h" + +namespace scene { + +class basic_node; + +} + +class editor_ui : public ui_layer { + +public: +// constructors + editor_ui(); +// methods + // potentially processes provided input key. returns: true if the input was processed, false otherwise + bool + on_key( int const Key, int const Action ) override; + // updates state of UI elements + void + update() override; + void + set_node( scene::basic_node * Node ); + +private: +// members + itemproperties_panel m_itempropertiespanel { "Node Properties", true }; + scene::basic_node * m_node { nullptr }; // currently bound scene node, if any +}; diff --git a/editoruipanels.cpp b/editoruipanels.cpp new file mode 100644 index 00000000..18d0a6df --- /dev/null +++ b/editoruipanels.cpp @@ -0,0 +1,201 @@ +/* +This Source Code Form is subject to the +terms of the Mozilla Public License, v. +2.0. If a copy of the MPL was not +distributed with this file, You can +obtain one at +http://mozilla.org/MPL/2.0/. +*/ + +#include "stdafx.h" +#include "editoruipanels.h" + +#include "globals.h" +#include "camera.h" +#include "animmodel.h" +#include "track.h" +#include "event.h" +#include "renderer.h" +#include "utilities.h" + +void +itemproperties_panel::update( scene::basic_node const *Node ) { + + if( false == is_open ) { return; } + + text_lines.clear(); + std::string textline; + + // scenario inspector + auto const *node { Node }; + auto const &camera { Global.pCamera }; + + if( node == nullptr ) { + auto const mouseposition { camera.Pos + GfxRenderer.Mouse_Position() }; + textline = "mouse location: [" + to_string( mouseposition.x, 2 ) + ", " + to_string( mouseposition.y, 2 ) + ", " + to_string( mouseposition.z, 2 ) + "]"; + text_lines.emplace_back( textline, Global.UITextColor ); + return; + } + + textline = + "node name: " + node->name() + + "\nlocation: [" + to_string( node->location().x, 2 ) + ", " + to_string( node->location().y, 2 ) + ", " + to_string( node->location().z, 2 ) + "]" + + " (distance: " + to_string( glm::length( glm::dvec3{ node->location().x, 0.0, node->location().z } -glm::dvec3{ camera.Pos.x, 0.0, camera.Pos.z } ), 1 ) + " m)"; + text_lines.emplace_back( textline, Global.UITextColor ); + + // subclass-specific data + // TBD, TODO: specialized data dump method in each node subclass, or data imports in the panel for provided subclass pointer? + if( typeid( *node ) == typeid( TAnimModel ) ) { + + auto const *subnode = static_cast( node ); + + textline = "angle: " + to_string( clamp_circular( subnode->vAngle.y, 360.f ), 2 ) + " deg"; + textline += "; lights: "; + if( subnode->iNumLights > 0 ) { + textline += '['; + for( int lightidx = 0; lightidx < subnode->iNumLights; ++lightidx ) { + textline += to_string( subnode->lsLights[ lightidx ] ); + if( lightidx < subnode->iNumLights - 1 ) { + textline += ", "; + } + } + textline += ']'; + } + else { + textline += "none"; + } + text_lines.emplace_back( textline, Global.UITextColor ); + + // 3d shape + auto modelfile { ( + ( subnode->pModel != nullptr ) ? + subnode->pModel->NameGet() : + "none" ) }; + if( modelfile.find( szModelPath ) == 0 ) { + // don't include 'models/' in the path + modelfile.erase( 0, std::string{ szModelPath }.size() ); + } + // texture + auto texturefile { ( + ( subnode->Material()->replacable_skins[ 1 ] != null_handle ) ? + GfxRenderer.Material( subnode->Material()->replacable_skins[ 1 ] ).name : + "none" ) }; + if( texturefile.find( szTexturePath ) == 0 ) { + // don't include 'textures/' in the path + texturefile.erase( 0, std::string{ szTexturePath }.size() ); + } + text_lines.emplace_back( "mesh: " + modelfile, Global.UITextColor ); + text_lines.emplace_back( "skin: " + texturefile, Global.UITextColor ); + } + else if( typeid( *node ) == typeid( TTrack ) ) { + + auto const *subnode = static_cast( node ); + // basic attributes + textline = + "isolated: " + ( ( subnode->pIsolated != nullptr ) ? subnode->pIsolated->asName : "none" ) + + "\nvelocity: " + to_string( subnode->SwitchExtension ? subnode->SwitchExtension->fVelocity : subnode->fVelocity ) + + "\nwidth: " + to_string( subnode->fTrackWidth ) + " m" + + "\nfriction: " + to_string( subnode->fFriction, 2 ) + + "\nquality: " + to_string( subnode->iQualityFlag ); + text_lines.emplace_back( textline, Global.UITextColor ); + // textures + auto texturefile { ( + ( subnode->m_material1 != null_handle ) ? + GfxRenderer.Material( subnode->m_material1 ).name : + "none" ) }; + if( texturefile.find( szTexturePath ) == 0 ) { + texturefile.erase( 0, std::string{ szTexturePath }.size() ); + } + auto texturefile2{ ( + ( subnode->m_material2 != null_handle ) ? + GfxRenderer.Material( subnode->m_material2 ).name : + "none" ) }; + if( texturefile2.find( szTexturePath ) == 0 ) { + texturefile2.erase( 0, std::string{ szTexturePath }.size() ); + } + textline = "skins:\n " + texturefile + "\n " + texturefile2; + text_lines.emplace_back( textline, Global.UITextColor ); + // paths + textline = "paths: "; + for( auto const &path : subnode->m_paths ) { + textline += + "\n [" + + to_string( path.points[ segment_data::point::start ].x, 3 ) + ", " + + to_string( path.points[ segment_data::point::start ].y, 3 ) + ", " + + to_string( path.points[ segment_data::point::start ].z, 3 ) + "]->" + + "[" + + to_string( path.points[ segment_data::point::end ].x, 3 ) + ", " + + to_string( path.points[ segment_data::point::end ].y, 3 ) + ", " + + to_string( path.points[ segment_data::point::end ].z, 3 ) + "] "; + } + text_lines.emplace_back( textline, Global.UITextColor ); + // events + textline.clear(); + + std::vector< std::pair< std::string, TTrack::event_sequence const * > > const eventsequences { + { "ev0", &subnode->m_events0 }, { "ev0all", &subnode->m_events0all }, + { "ev1", &subnode->m_events1 }, { "ev1all", &subnode->m_events1all }, + { "ev2", &subnode->m_events2 }, { "ev2all", &subnode->m_events2all } }; + + for( auto const &eventsequence : eventsequences ) { + + if( eventsequence.second->empty() ) { continue; } + + textline += ( textline.empty() ? "" : "\n" ) + eventsequence.first + ": ["; + for( auto const &event : *( eventsequence.second ) ) { + if( textline.back() != '[' ) { + textline += ", "; + } + textline += ( + event.second != nullptr ? + event.second->m_name : + event.first + " (missing)" ); + } + textline += "] "; + } + text_lines.emplace_back( textline, Global.UITextColor ); + } + else if( typeid( *node ) == typeid( TMemCell ) ) { + + auto const *subnode = static_cast( node ); + + textline = + "data: [" + subnode->Text() + "]" + + " [" + to_string( subnode->Value1(), 2 ) + "]" + + " [" + to_string( subnode->Value2(), 2 ) + "]"; + text_lines.emplace_back( textline, Global.UITextColor ); + textline = "track: " + ( subnode->asTrackName.empty() ? "none" : subnode->asTrackName ); + text_lines.emplace_back( textline, Global.UITextColor ); + } +} + +void +itemproperties_panel::render() { + + if( false == is_open ) { return; } + if( true == text_lines.empty() ) { return; } + + auto flags = + ImGuiWindowFlags_NoFocusOnAppearing + | ImGuiWindowFlags_NoCollapse + | ( size.x > 0 ? ImGuiWindowFlags_NoResize : 0 ); + + if( size.x > 0 ) { + ImGui::SetNextWindowSize( ImVec2( size.x, size.y ) ); + } + if( size_min.x > 0 ) { + ImGui::SetNextWindowSizeConstraints( ImVec2( size_min.x, size_min.y ), ImVec2( size_max.x, size_max.y ) ); + } + auto const panelname { ( + title.empty() ? + name : + title ) + + "###" + name }; + if( true == ImGui::Begin( panelname.c_str(), nullptr, flags ) ) { + // header section + for( auto const &line : text_lines ) { + ImGui::TextColored( ImVec4( line.color.r, line.color.g, line.color.b, line.color.a ), line.data.c_str() ); + } + } + ImGui::End(); +} diff --git a/editoruipanels.h b/editoruipanels.h new file mode 100644 index 00000000..7664d4be --- /dev/null +++ b/editoruipanels.h @@ -0,0 +1,24 @@ +/* +This Source Code Form is subject to the +terms of the Mozilla Public License, v. +2.0. If a copy of the MPL was not +distributed with this file, You can +obtain one at +http://mozilla.org/MPL/2.0/. +*/ + +#pragma once + +#include "uilayer.h" +#include "classes.h" + +class itemproperties_panel : public ui_panel { + +public: + itemproperties_panel( std::string const &Name, bool const Isopen ) + : ui_panel( Name, Isopen ) + {} + + void update( scene::basic_node const *Node ); + void render() override; +}; diff --git a/eu07.rc b/eu07.rc new file mode 100644 index 00000000..8e594be8 --- /dev/null +++ b/eu07.rc @@ -0,0 +1 @@ +IDI_ICON1 ICON "eu07.ico" \ No newline at end of file diff --git a/frustum.cpp b/frustum.cpp new file mode 100644 index 00000000..a92f395f --- /dev/null +++ b/frustum.cpp @@ -0,0 +1,184 @@ +/* +This Source Code Form is subject to the +terms of the Mozilla Public License, v. +2.0. If a copy of the MPL was not +distributed with this file, You can +obtain one at +http://mozilla.org/MPL/2.0/. +*/ + +#include "stdafx.h" +#include "frustum.h" + +void +cFrustum::calculate() { + + auto const &projection = OpenGLMatrices.data( GL_PROJECTION ); + auto const &modelview = OpenGLMatrices.data( GL_MODELVIEW ); + + calculate( projection, modelview ); +} + +void +cFrustum::calculate( glm::mat4 const &Projection, glm::mat4 const &Modelview ) { + + float const *proj = glm::value_ptr( Projection ); + float const *modl = glm::value_ptr( Modelview ); + float clip[ 16 ]; + + // multiply the matrices to retrieve clipping planes + clip[ 0 ] = modl[ 0 ] * proj[ 0 ] + modl[ 1 ] * proj[ 4 ] + modl[ 2 ] * proj[ 8 ] + modl[ 3 ] * proj[ 12 ]; + clip[ 1 ] = modl[ 0 ] * proj[ 1 ] + modl[ 1 ] * proj[ 5 ] + modl[ 2 ] * proj[ 9 ] + modl[ 3 ] * proj[ 13 ]; + clip[ 2 ] = modl[ 0 ] * proj[ 2 ] + modl[ 1 ] * proj[ 6 ] + modl[ 2 ] * proj[ 10 ] + modl[ 3 ] * proj[ 14 ]; + clip[ 3 ] = modl[ 0 ] * proj[ 3 ] + modl[ 1 ] * proj[ 7 ] + modl[ 2 ] * proj[ 11 ] + modl[ 3 ] * proj[ 15 ]; + + clip[ 4 ] = modl[ 4 ] * proj[ 0 ] + modl[ 5 ] * proj[ 4 ] + modl[ 6 ] * proj[ 8 ] + modl[ 7 ] * proj[ 12 ]; + clip[ 5 ] = modl[ 4 ] * proj[ 1 ] + modl[ 5 ] * proj[ 5 ] + modl[ 6 ] * proj[ 9 ] + modl[ 7 ] * proj[ 13 ]; + clip[ 6 ] = modl[ 4 ] * proj[ 2 ] + modl[ 5 ] * proj[ 6 ] + modl[ 6 ] * proj[ 10 ] + modl[ 7 ] * proj[ 14 ]; + clip[ 7 ] = modl[ 4 ] * proj[ 3 ] + modl[ 5 ] * proj[ 7 ] + modl[ 6 ] * proj[ 11 ] + modl[ 7 ] * proj[ 15 ]; + + clip[ 8 ] = modl[ 8 ] * proj[ 0 ] + modl[ 9 ] * proj[ 4 ] + modl[ 10 ] * proj[ 8 ] + modl[ 11 ] * proj[ 12 ]; + clip[ 9 ] = modl[ 8 ] * proj[ 1 ] + modl[ 9 ] * proj[ 5 ] + modl[ 10 ] * proj[ 9 ] + modl[ 11 ] * proj[ 13 ]; + clip[ 10 ] = modl[ 8 ] * proj[ 2 ] + modl[ 9 ] * proj[ 6 ] + modl[ 10 ] * proj[ 10 ] + modl[ 11 ] * proj[ 14 ]; + clip[ 11 ] = modl[ 8 ] * proj[ 3 ] + modl[ 9 ] * proj[ 7 ] + modl[ 10 ] * proj[ 11 ] + modl[ 11 ] * proj[ 15 ]; + + clip[ 12 ] = modl[ 12 ] * proj[ 0 ] + modl[ 13 ] * proj[ 4 ] + modl[ 14 ] * proj[ 8 ] + modl[ 15 ] * proj[ 12 ]; + clip[ 13 ] = modl[ 12 ] * proj[ 1 ] + modl[ 13 ] * proj[ 5 ] + modl[ 14 ] * proj[ 9 ] + modl[ 15 ] * proj[ 13 ]; + clip[ 14 ] = modl[ 12 ] * proj[ 2 ] + modl[ 13 ] * proj[ 6 ] + modl[ 14 ] * proj[ 10 ] + modl[ 15 ] * proj[ 14 ]; + clip[ 15 ] = modl[ 12 ] * proj[ 3 ] + modl[ 13 ] * proj[ 7 ] + modl[ 14 ] * proj[ 11 ] + modl[ 15 ] * proj[ 15 ]; + + // get the sides of the frustum. + m_frustum[ side_RIGHT ][ plane_A ] = clip[ 3 ] - clip[ 0 ]; + m_frustum[ side_RIGHT ][ plane_B ] = clip[ 7 ] - clip[ 4 ]; + m_frustum[ side_RIGHT ][ plane_C ] = clip[ 11 ] - clip[ 8 ]; + m_frustum[ side_RIGHT ][ plane_D ] = clip[ 15 ] - clip[ 12 ]; + normalize_plane( side_RIGHT ); + + m_frustum[ side_LEFT ][ plane_A ] = clip[ 3 ] + clip[ 0 ]; + m_frustum[ side_LEFT ][ plane_B ] = clip[ 7 ] + clip[ 4 ]; + m_frustum[ side_LEFT ][ plane_C ] = clip[ 11 ] + clip[ 8 ]; + m_frustum[ side_LEFT ][ plane_D ] = clip[ 15 ] + clip[ 12 ]; + normalize_plane( side_LEFT ); + + m_frustum[ side_BOTTOM ][ plane_A ] = clip[ 3 ] + clip[ 1 ]; + m_frustum[ side_BOTTOM ][ plane_B ] = clip[ 7 ] + clip[ 5 ]; + m_frustum[ side_BOTTOM ][ plane_C ] = clip[ 11 ] + clip[ 9 ]; + m_frustum[ side_BOTTOM ][ plane_D ] = clip[ 15 ] + clip[ 13 ]; + normalize_plane( side_BOTTOM ); + + m_frustum[ side_TOP ][ plane_A ] = clip[ 3 ] - clip[ 1 ]; + m_frustum[ side_TOP ][ plane_B ] = clip[ 7 ] - clip[ 5 ]; + m_frustum[ side_TOP ][ plane_C ] = clip[ 11 ] - clip[ 9 ]; + m_frustum[ side_TOP ][ plane_D ] = clip[ 15 ] - clip[ 13 ]; + normalize_plane( side_TOP ); + + m_frustum[ side_BACK ][ plane_A ] = clip[ 3 ] - clip[ 2 ]; + m_frustum[ side_BACK ][ plane_B ] = clip[ 7 ] - clip[ 6 ]; + m_frustum[ side_BACK ][ plane_C ] = clip[ 11 ] - clip[ 10 ]; + m_frustum[ side_BACK ][ plane_D ] = clip[ 15 ] - clip[ 14 ]; + normalize_plane( side_BACK ); + + m_frustum[ side_FRONT ][ plane_A ] = clip[ 3 ] + clip[ 2 ]; + m_frustum[ side_FRONT ][ plane_B ] = clip[ 7 ] + clip[ 6 ]; + m_frustum[ side_FRONT ][ plane_C ] = clip[ 11 ] + clip[ 10 ]; + m_frustum[ side_FRONT ][ plane_D ] = clip[ 15 ] + clip[ 14 ]; + normalize_plane( side_FRONT ); +} + +bool +cFrustum::point_inside( float const X, float const Y, float const Z ) const { + + // cycle through the sides of the frustum, checking if the point is behind them + for( int idx = 0; idx < 6; ++idx ) { + if( m_frustum[ idx ][ plane_A ] * X + + m_frustum[ idx ][ plane_B ] * Y + + m_frustum[ idx ][ plane_C ] * Z + + m_frustum[ idx ][ plane_D ] <= 0 ) + return false; + } + + // the point is in front of each frustum plane, i.e. inside of the frustum + return true; +} + +float +cFrustum::sphere_inside( float const X, float const Y, float const Z, float const Radius ) const { + + float distance; + // go through all the sides of the frustum. bail out as soon as possible + for( int idx = 0; idx < 6; ++idx ) { + distance = + m_frustum[ idx ][ plane_A ] * X + + m_frustum[ idx ][ plane_B ] * Y + + m_frustum[ idx ][ plane_C ] * Z + + m_frustum[ idx ][ plane_D ]; + if( distance <= -Radius ) + return 0.0f; + } + return distance + Radius; +} + +bool +cFrustum::cube_inside( float const X, float const Y, float const Z, float const Size ) const { + + for( int idx = 0; idx < 6; ++idx ) { + if( m_frustum[ idx ][ plane_A ] * ( X - Size ) + + m_frustum[ idx ][ plane_B ] * ( Y - Size ) + + m_frustum[ idx ][ plane_C ] * ( Z - Size ) + + m_frustum[ idx ][ plane_D ] > 0 ) + continue; + if( m_frustum[ idx ][ plane_A ] * ( X + Size ) + + m_frustum[ idx ][ plane_B ] * ( Y - Size ) + + m_frustum[ idx ][ plane_C ] * ( Z - Size ) + + m_frustum[ idx ][ plane_D ] > 0 ) + continue; + if( m_frustum[ idx ][ plane_A ] * ( X - Size ) + + m_frustum[ idx ][ plane_B ] * ( Y + Size ) + + m_frustum[ idx ][ plane_C ] * ( Z - Size ) + + m_frustum[ idx ][ plane_D ] > 0 ) + continue; + if( m_frustum[ idx ][ plane_A ] * ( X + Size ) + + m_frustum[ idx ][ plane_B ] * ( Y + Size ) + + m_frustum[ idx ][ plane_C ] * ( Z - Size ) + + m_frustum[ idx ][ plane_D ] > 0 ) + continue; + if( m_frustum[ idx ][ plane_A ] * ( X - Size ) + + m_frustum[ idx ][ plane_B ] * ( Y - Size ) + + m_frustum[ idx ][ plane_C ] * ( Z + Size ) + + m_frustum[ idx ][ plane_D ] > 0 ) + continue; + if( m_frustum[ idx ][ plane_A ] * ( X + Size ) + + m_frustum[ idx ][ plane_B ] * ( Y - Size ) + + m_frustum[ idx ][ plane_C ] * ( Z + Size ) + + m_frustum[ idx ][ plane_D ] > 0 ) + continue; + if( m_frustum[ idx ][ plane_A ] * ( X - Size ) + + m_frustum[ idx ][ plane_B ] * ( Y + Size ) + + m_frustum[ idx ][ plane_C ] * ( Z + Size ) + + m_frustum[ idx ][ plane_D ] > 0 ) + continue; + if( m_frustum[ idx ][ plane_A ] * ( X + Size ) + + m_frustum[ idx ][ plane_B ] * ( Y + Size ) + + m_frustum[ idx ][ plane_C ] * ( Z + Size ) + + m_frustum[ idx ][ plane_D ] > 0 ) + continue; + + return false; + } + + return true; +} + +void cFrustum::normalize_plane( cFrustum::side const Side ) { + + float magnitude = + std::sqrt( + m_frustum[ Side ][ plane_A ] * m_frustum[ Side ][ plane_A ] + + m_frustum[ Side ][ plane_B ] * m_frustum[ Side ][ plane_B ] + + m_frustum[ Side ][ plane_C ] * m_frustum[ Side ][ plane_C ] ); + + m_frustum[ Side ][ plane_A ] /= magnitude; + m_frustum[ Side ][ plane_B ] /= magnitude; + m_frustum[ Side ][ plane_C ] /= magnitude; + m_frustum[ Side ][ plane_D ] /= magnitude; +} diff --git a/frustum.h b/frustum.h new file mode 100644 index 00000000..87d2b7fe --- /dev/null +++ b/frustum.h @@ -0,0 +1,87 @@ +/* +This Source Code Form is subject to the +terms of the Mozilla Public License, v. +2.0. If a copy of the MPL was not +distributed with this file, You can +obtain one at +http://mozilla.org/MPL/2.0/. +*/ + +#pragma once + +#include "float3d.h" +#include "dumb3d.h" + +std::vector const ndcfrustumshapepoints { + { -1, -1, -1, 1 },{ 1, -1, -1, 1 },{ 1, 1, -1, 1 },{ -1, 1, -1, 1 }, // z-near + { -1, -1, 1, 1 },{ 1, -1, 1, 1 },{ 1, 1, 1, 1 },{ -1, 1, 1, 1 } }; // z-far + +std::vector const frustumshapepoinstorder { 0, 1, 1, 2, 2, 3, 3, 0, 4, 5, 5, 6, 6, 7, 7, 4, 0, 4, 1, 5, 2, 6, 3, 7 }; + +// generic frustum class. used to determine if objects are inside current view area + +class cFrustum { + +public: +// constructors: + cFrustum() = default; +// methods: + // update the frustum to match current view orientation + void + calculate(); + void + calculate(glm::mat4 const &Projection, glm::mat4 const &Modelview); + // returns true if specified point is inside of the frustum + inline + bool + point_inside( glm::vec3 const &Point ) const { return point_inside( Point.x, Point.y, Point.z ); } + inline + bool + point_inside( float3 const &Point ) const { return point_inside( Point.x, Point.y, Point.z ); } + inline + bool + point_inside( Math3D::vector3 const &Point ) const { return point_inside( static_cast( Point.x ), static_cast( Point.y ), static_cast( Point.z ) ); } + bool + point_inside( float const X, float const Y, float const Z ) const; + // tests if the sphere is in frustum, returns the distance between origin and sphere centre + inline + float + sphere_inside( glm::dvec3 const &Center, float const Radius ) const { return sphere_inside( static_cast( Center.x ), static_cast( Center.y ), static_cast( Center.z ), Radius ); } + inline + float + sphere_inside( glm::vec3 const &Center, float const Radius ) const { return sphere_inside( Center.x, Center.y, Center.z, Radius ); } + inline + float + sphere_inside( float3 const &Center, float const Radius ) const { return sphere_inside( Center.x, Center.y, Center.z, Radius ); } + inline + float + sphere_inside( Math3D::vector3 const &Center, float const Radius ) const { return sphere_inside( static_cast( Center.x ), static_cast( Center.y ), static_cast( Center.z ), Radius ); } + float + sphere_inside( float const X, float const Y, float const Z, float const Radius ) const; + // returns true if specified cube is inside of the frustum. Size = half of the length + inline + bool + cube_inside( glm::vec3 const &Center, float const Size ) const { return cube_inside( Center.x, Center.y, Center.z, Size ); } + inline + bool + cube_inside( float3 const &Center, float const Size ) const { return cube_inside( Center.x, Center.y, Center.z, Size ); } + inline + bool + cube_inside( Math3D::vector3 const &Center, float const Size ) const { return cube_inside( static_cast( Center.x ), static_cast( Center.y ), static_cast( Center.z ), Size ); } + bool + cube_inside( float const X, float const Y, float const Z, float const Size ) const; + +private: +// types: + // planes of the frustum + enum side { side_RIGHT = 0, side_LEFT = 1, side_BOTTOM = 2, side_TOP = 3, side_BACK = 4, side_FRONT = 5 }; + // parameters of the frustum plane: A, B, C define plane normal, D defines distance from origin + enum plane { plane_A = 0, plane_B = 1, plane_C = 2, plane_D = 3 }; + +// methods: + void + normalize_plane( cFrustum::side const Side ); // normalizes a plane (A side) from the frustum + +// members: + float m_frustum[6][4]; // holds the A B C and D values (normal & distance) for each side of the frustum. +}; diff --git a/gamepadinput.cpp b/gamepadinput.cpp new file mode 100644 index 00000000..95039614 --- /dev/null +++ b/gamepadinput.cpp @@ -0,0 +1,315 @@ +/* +This Source Code Form is subject to the +terms of the Mozilla Public License, v. +2.0. If a copy of the MPL was not +distributed with this file, You can +obtain one at +http://mozilla.org/MPL/2.0/. +*/ + +#include "stdafx.h" +#include "gamepadinput.h" +#include "logs.h" +#include "timer.h" +#include "utilities.h" + +glm::vec2 circle_to_square( glm::vec2 const &Point, int const Roundness = 0 ) { + + // Determine the theta angle + auto angle = std::atan2( Point.x, Point.y ) + M_PI; + + glm::vec2 squared; + // Scale according to which wall we're clamping to + // X+ wall + if( angle <= M_PI_4 || angle > 7 * M_PI_4 ) + squared = Point * (float)( 1.0 / std::cos( angle ) ); + // Y+ wall + else if( angle > M_PI_4 && angle <= 3 * M_PI_4 ) + squared = Point * (float)( 1.0 / std::sin( angle ) ); + // X- wall + else if( angle > 3 * M_PI_4 && angle <= 5 * M_PI_4 ) + squared = Point * (float)( -1.0 / std::cos( angle ) ); + // Y- wall + else if( angle > 5 * M_PI_4 && angle <= 7 * M_PI_4 ) + squared = Point * (float)( -1.0 / std::sin( angle ) ); + + // Early-out for a perfect square output + if( Roundness == 0 ) + return squared; + + // Find the inner-roundness scaling factor and LERP + auto const length = glm::length( Point ); + auto const factor = std::pow( length, Roundness ); + return interpolate( Point, squared, factor ); +} + +gamepad_input::gamepad_input() { + + m_modecommands = { + + { user_command::mastercontrollerincrease, user_command::mastercontrollerdecrease }, + { user_command::trainbrakedecrease, user_command::trainbrakeincrease }, + { user_command::secondcontrollerincrease, user_command::secondcontrollerdecrease }, + { user_command::independentbrakedecrease, user_command::independentbrakeincrease } + }; +} + +bool +gamepad_input::init() { + + // NOTE: we're only checking for joystick_1 and rely for it to stay connected throughout. + // not exactly flexible, but for quick hack it'll do + auto const name = glfwGetJoystickName( GLFW_JOYSTICK_1 ); + if( name != nullptr ) { + WriteLog( "Connected gamepad: " + std::string( name ) ); + m_deviceid = GLFW_JOYSTICK_1; + } + else { + // no joystick, + WriteLog( "No gamepad detected" ); + m_axes.clear(); + m_buttons.clear(); + return false; + } + + int count; + + glfwGetJoystickAxes( m_deviceid, &count ); + m_axes.resize( count ); + + glfwGetJoystickButtons( m_deviceid, &count ); + m_buttons.resize( count ); + + return true; +} + +// checks state of the controls and sends issued commands +void +gamepad_input::poll() { + + if( m_deviceid == -1 ) { + // if there's no gamepad we can skip the rest + return; + } + + int count; std::size_t idx = 0; + // poll button state + auto const buttons = glfwGetJoystickButtons( m_deviceid, &count ); + if( count ) { // safety check in case joystick gets pulled out + for( auto &button : m_buttons ) { + + if( button != buttons[ idx ] ) { + // button pressed or released, both are important + on_button( + static_cast( idx ), + ( buttons[ idx ] == 1 ? + GLFW_PRESS : + GLFW_RELEASE ) ); + } + else { + // otherwise we only pass info about button being held down + if( button == 1 ) { + + on_button( + static_cast( idx ), + GLFW_REPEAT ); + } + } + button = buttons[ idx ]; + ++idx; + } + } + + // poll axes state + idx = 0; + glm::vec2 leftstick, rightstick, triggers; + auto const axes = glfwGetJoystickAxes( m_deviceid, &count ); + if( count ) { + // safety check in case joystick gets pulled out + if( count >= 2 ) { + leftstick = glm::vec2( + ( std::abs( axes[ gamepad_axes::leftstick_x ] ) > m_deadzone ? + axes[ gamepad_axes::leftstick_x ] : + 0.0f ), + ( std::abs( axes[ gamepad_axes::leftstick_y ] ) > m_deadzone ? + axes[ gamepad_axes::leftstick_y ] : + 0.0f ) ); + } + if( count >= 4 ) { + rightstick = glm::vec2( + ( std::abs( axes[ gamepad_axes::rightstick_x ] ) > m_deadzone ? + axes[ gamepad_axes::rightstick_x ] : + 0.0f ), + ( std::abs( axes[ gamepad_axes::rightstick_y ] ) > m_deadzone ? + axes[ gamepad_axes::rightstick_y ] : + 0.0f ) ); + } + if( count >= 6 ) { + triggers = glm::vec2( + ( axes[ gamepad_axes::lefttrigger ] > m_deadzone ? + axes[ gamepad_axes::lefttrigger ] : + 0.0f ), + ( axes[ gamepad_axes::righttrigger ] > m_deadzone ? + axes[ gamepad_axes::righttrigger ] : + 0.0f ) ); + } + } + process_axes( leftstick, rightstick, triggers ); +} + +void +gamepad_input::on_button( gamepad_button const Button, int const Action ) { + + switch( Button ) { + // NOTE: this is rigid coupling, down the road we should support more flexible binding of functions with buttons + case gamepad_button::a: + case gamepad_button::b: + case gamepad_button::x: + case gamepad_button::y: { + + if( Action == GLFW_RELEASE ) { + // TODO: send GLFW_RELEASE for whatever command could be issued by the mode active until now + // if the button was released the stick switches to control the movement + m_mode = control_mode::entity; + // zero the stick and the accumulator so the input won't bleed between modes + m_leftstick = glm::vec2(); + m_modeaccumulator = 0.0f; + } + else { + // otherwise set control mode to match pressed button + m_mode = static_cast( Button ); + } + break; + } + default: { + break; + } + } +} + +void +gamepad_input::process_axes( glm::vec2 Leftstick, glm::vec2 const &Rightstick, glm::vec2 const &Triggers ) { + + // right stick, look around + if( ( Rightstick.x != 0.0f ) || ( Rightstick.y != 0.0f ) ) { + // TODO: make toggles for the axis flip + auto const deltatime = Timer::GetDeltaRenderTime() * 60.0; + double const turnx = Rightstick.x * 10.0 * deltatime; + double const turny = -Rightstick.y * 10.0 * deltatime; + m_relay.post( + user_command::viewturn, + turnx, + turny, + GLFW_PRESS, + // as we haven't yet implemented either item id system or multiplayer, the 'local' controlled vehicle and entity have temporary ids of 0 + // TODO: pass correct entity id once the missing systems are in place + 0 ); + } + + // left stick, either movement or controls, depending on currently active mode + if( m_mode == control_mode::entity ) { + + if( ( Leftstick.x != 0.0 || Leftstick.y != 0.0 ) + || ( m_leftstick.x != 0.0 || m_leftstick.y != 0.0 ) ) { + m_relay.post( + user_command::movehorizontal, + Leftstick.x, + Leftstick.y, + GLFW_PRESS, + 0 ); + } + } + else { + // vehicle control modes + process_mode( Leftstick.y, 0 ); + } + + m_rightstick = Rightstick; + m_leftstick = Leftstick; + m_triggers = Triggers; +} + +void +gamepad_input::process_mode( float const Value, std::uint16_t const Recipient ) { + + // TODO: separate multiplier for each mode, to allow different, customizable sensitivity for each control + auto const deltatime = Timer::GetDeltaTime() * 15.0; + auto const &lookup = m_modecommands.at( static_cast( m_mode ) ); + + if( Value >= 0.0f ) { + if( m_modeaccumulator < 0.0f ) { + // reset accumulator if we're going in the other direction i.e. issuing opposite control + // this also means we should indicate the previous command no longer applies + // (normally it's handled when the stick enters dead zone, but it's possible there's no actual dead zone) + m_relay.post( + lookup.second, + 0, 0, + GLFW_RELEASE, + Recipient ); + m_modeaccumulator = 0.0f; + } + if( Value > m_deadzone ) { + m_modeaccumulator += ( Value - m_deadzone ) / ( 1.0 - m_deadzone ) * deltatime; + // we're making sure there's always a positive charge left in the accumulator, + // to more reliably decect when the stick goes from active to dead zone, below + while( m_modeaccumulator > 1.0f ) { + // send commands if the accumulator(s) was filled + m_relay.post( + lookup.first, + 0, 0, + GLFW_PRESS, + Recipient ); + m_modeaccumulator -= 1.0f; + } + } + else { + // if the accumulator isn't empty it's an indicator the stick moved from active to neutral zone + // indicate it with proper RELEASE command + m_relay.post( + lookup.first, + 0, 0, + GLFW_RELEASE, + Recipient ); + m_modeaccumulator = 0.0f; + } + } + else { + if( m_modeaccumulator > 0.0f ) { + // reset accumulator if we're going in the other direction i.e. issuing opposite control + // this also means we should indicate the previous command no longer applies + // (normally it's handled when the stick enters dead zone, but it's possible there's no actual dead zone) + m_relay.post( + lookup.first, + 0, 0, + GLFW_RELEASE, + Recipient ); + m_modeaccumulator = 0.0f; + } + if( Value < m_deadzone ) { + m_modeaccumulator += ( Value + m_deadzone ) / ( 1.0 - m_deadzone ) * deltatime; + // we're making sure there's always a negative charge left in the accumulator, + // to more reliably decect when the stick goes from active to dead zone, below + while( m_modeaccumulator < -1.0f ) { + // send commands if the accumulator(s) was filled + m_relay.post( + lookup.second, + 0, 0, + GLFW_PRESS, + Recipient ); + m_modeaccumulator += 1.0f; + } + } + else { + // if the accumulator isn't empty it's an indicator the stick moved from active to neutral zone + // indicate it with proper RELEASE command + m_relay.post( + lookup.second, + 0, 0, + GLFW_RELEASE, + Recipient ); + m_modeaccumulator = 0.0f; + } + } +} + +//--------------------------------------------------------------------------- diff --git a/gamepadinput.h b/gamepadinput.h new file mode 100644 index 00000000..80cfce8b --- /dev/null +++ b/gamepadinput.h @@ -0,0 +1,84 @@ +/* +This Source Code Form is subject to the +terms of the Mozilla Public License, v. +2.0. If a copy of the MPL was not +distributed with this file, You can +obtain one at +http://mozilla.org/MPL/2.0/. +*/ + +#pragma once + +#include +#include "command.h" + +class gamepad_input { + +public: +// constructors + gamepad_input(); + +// methods + // checks state of the controls and sends issued commands + bool + init(); + void + poll(); + +private: +// types + enum gamepad_button { + a, + b, + x, + y, + left_shoulder, + right_shoulder, + back, + start, + left_sticker, + right_sticker, + dpad_up, + dpad_right, + dpad_down, + dpad_left + }; + enum gamepad_axes { + leftstick_x, + leftstick_y, + rightstick_x, + rightstick_y, + lefttrigger, + righttrigger + }; + enum class control_mode { + entity = -1, + vehicle_mastercontroller, + vehicle_trainbrake, + vehicle_secondarycontroller, + vehicle_independentbrake + }; + typedef std::vector float_sequence; + typedef std::vector char_sequence; + typedef std::vector< std::pair< user_command, user_command > > commandpair_sequence; + +// methods + void on_button( gamepad_button const Button, int const Action ); + void process_axes( glm::vec2 Leftstick, glm::vec2 const &Rightstick, glm::vec2 const &Triggers ); + void process_mode( float const Value, std::uint16_t const Recipient ); + +// members + command_relay m_relay; + float_sequence m_axes; + char_sequence m_buttons; + int m_deviceid{ -1 }; + control_mode m_mode{ control_mode::entity }; + commandpair_sequence m_modecommands; // sets of commands issued depending on the active control mode + float m_deadzone{ 0.15f }; // TODO: allow to configure this + glm::vec2 m_leftstick; + glm::vec2 m_rightstick; + glm::vec2 m_triggers; + double m_modeaccumulator{ 0.0 }; // used to throttle command input rate for vehicle controls +}; + +//--------------------------------------------------------------------------- diff --git a/geometry.h b/geometry.h index 5cdd2ec3..85f0e586 100644 --- a/geometry.h +++ b/geometry.h @@ -9,7 +9,7 @@ http://mozilla.org/MPL/2.0/. #ifndef GeometryH #define GeometryH -#include "opengl/glew.h" +#include "GL/glew.h" #include "dumb3d.h" using namespace Math3D; //--------------------------------------------------------------------------- diff --git a/keyboardinput.cpp b/keyboardinput.cpp new file mode 100644 index 00000000..1e05bed8 --- /dev/null +++ b/keyboardinput.cpp @@ -0,0 +1,277 @@ +/* +This Source Code Form is subject to the +terms of the Mozilla Public License, v. +2.0. If a copy of the MPL was not +distributed with this file, You can +obtain one at +http://mozilla.org/MPL/2.0/. +*/ + +#include "stdafx.h" +#include "keyboardinput.h" +#include "globals.h" +#include "logs.h" +#include "parser.h" + +namespace input { + +std::array keys { GLFW_RELEASE }; +bool key_alt; +bool key_ctrl; +bool key_shift; + +} + +bool +keyboard_input::recall_bindings() { + + cParser bindingparser( "eu07_input-keyboard.ini", cParser::buffer_FILE ); + if( false == bindingparser.ok() ) { + return false; + } + + // build helper translation tables + std::unordered_map nametocommandmap; + std::size_t commandid = 0; + for( auto const &description : simulation::Commands_descriptions ) { + nametocommandmap.emplace( + description.name, + static_cast( commandid ) ); + ++commandid; + } + std::unordered_map nametokeymap = { + { "0", GLFW_KEY_0 }, { "1", GLFW_KEY_1 }, { "2", GLFW_KEY_2 }, { "3", GLFW_KEY_3 }, { "4", GLFW_KEY_4 }, + { "5", GLFW_KEY_5 }, { "6", GLFW_KEY_6 }, { "7", GLFW_KEY_7 }, { "8", GLFW_KEY_8 }, { "9", GLFW_KEY_9 }, + { "-", GLFW_KEY_MINUS }, { "=", GLFW_KEY_EQUAL }, + { "a", GLFW_KEY_A }, { "b", GLFW_KEY_B }, { "c", GLFW_KEY_C }, { "d", GLFW_KEY_D }, { "e", GLFW_KEY_E }, + { "f", GLFW_KEY_F }, { "g", GLFW_KEY_G }, { "h", GLFW_KEY_H }, { "i", GLFW_KEY_I }, { "j", GLFW_KEY_J }, + { "k", GLFW_KEY_K }, { "l", GLFW_KEY_L }, { "m", GLFW_KEY_M }, { "n", GLFW_KEY_N }, { "o", GLFW_KEY_O }, + { "p", GLFW_KEY_P }, { "q", GLFW_KEY_Q }, { "r", GLFW_KEY_R }, { "s", GLFW_KEY_S }, { "t", GLFW_KEY_T }, + { "u", GLFW_KEY_U }, { "v", GLFW_KEY_V }, { "w", GLFW_KEY_W }, { "x", GLFW_KEY_X }, { "y", GLFW_KEY_Y }, { "z", GLFW_KEY_Z }, + { "-", GLFW_KEY_MINUS }, { "=", GLFW_KEY_EQUAL }, { "backspace", GLFW_KEY_BACKSPACE }, + { "[", GLFW_KEY_LEFT_BRACKET }, { "]", GLFW_KEY_RIGHT_BRACKET }, { "\\", GLFW_KEY_BACKSLASH }, + { ";", GLFW_KEY_SEMICOLON }, { "'", GLFW_KEY_APOSTROPHE }, { "enter", GLFW_KEY_ENTER }, + { ",", GLFW_KEY_COMMA }, { ".", GLFW_KEY_PERIOD }, { "/", GLFW_KEY_SLASH }, + { "space", GLFW_KEY_SPACE }, + { "pause", GLFW_KEY_PAUSE }, { "insert", GLFW_KEY_INSERT }, { "delete", GLFW_KEY_DELETE }, { "home", GLFW_KEY_HOME }, { "end", GLFW_KEY_END }, + // numpad block + { "num_/", GLFW_KEY_KP_DIVIDE }, { "num_*", GLFW_KEY_KP_MULTIPLY }, { "num_-", GLFW_KEY_KP_SUBTRACT }, + { "num_7", GLFW_KEY_KP_7 }, { "num_8", GLFW_KEY_KP_8 }, { "num_9", GLFW_KEY_KP_9 }, { "num_+", GLFW_KEY_KP_ADD }, + { "num_4", GLFW_KEY_KP_4 }, { "num_5", GLFW_KEY_KP_5 }, { "num_6", GLFW_KEY_KP_6 }, + { "num_1", GLFW_KEY_KP_1 }, { "num_2", GLFW_KEY_KP_2 }, { "num_3", GLFW_KEY_KP_3 }, { "num_enter", GLFW_KEY_KP_ENTER }, + { "num_0", GLFW_KEY_KP_0 }, { "num_.", GLFW_KEY_KP_DECIMAL } + }; + + // NOTE: to simplify things we expect one entry per line, and whole entry in one line + while( true == bindingparser.getTokens( 1, true, "\n" ) ) { + + std::string bindingentry; + bindingparser >> bindingentry; + cParser entryparser( bindingentry ); + if( true == entryparser.getTokens( 1, true, "\n\r\t " ) ) { + + std::string commandname; + entryparser >> commandname; + + auto const lookup = nametocommandmap.find( commandname ); + if( lookup == nametocommandmap.end() ) { + + WriteLog( "Keyboard binding defined for unknown command, \"" + commandname + "\"" ); + } + else { + int binding{ 0 }; + while( entryparser.getTokens( 1, true, "\n\r\t " ) ) { + + std::string bindingkeyname; + entryparser >> bindingkeyname; + + if( bindingkeyname == "shift" ) { binding |= keymodifier::shift; } + else if( bindingkeyname == "ctrl" ) { binding |= keymodifier::control; } + else if( bindingkeyname == "none" ) { binding = 0; } + else { + // regular key, convert it to glfw key code + auto const keylookup = nametokeymap.find( bindingkeyname ); + if( keylookup == nametokeymap.end() ) { + + WriteLog( "Keyboard binding included unrecognized key, \"" + bindingkeyname + "\"" ); + } + else { + // replace any existing binding, preserve modifiers + // (protection from cases where there's more than one key listed in the entry) + binding = keylookup->second | ( binding & 0xffff0000 ); + } + } + + if( ( binding & 0xffff ) != 0 ) { + m_bindingsetups.emplace_back( binding_setup{ lookup->second, binding } ); + } + } + } + } + } + + return true; +} + +bool +keyboard_input::key( int const Key, int const Action ) { + + bool modifier( false ); + + if( ( Key == GLFW_KEY_LEFT_SHIFT ) || ( Key == GLFW_KEY_RIGHT_SHIFT ) ) { + // update internal state, but don't bother passing these + input::key_shift = + ( Action == GLFW_RELEASE ? + false : + true ); + modifier = true; + // whenever shift key is used it may affect currently pressed movement keys, so check and update these + } + if( ( Key == GLFW_KEY_LEFT_CONTROL ) || ( Key == GLFW_KEY_RIGHT_CONTROL ) ) { + // update internal state, but don't bother passing these + input::key_ctrl = + ( Action == GLFW_RELEASE ? + false : + true ); + modifier = true; + } + if( ( Key == GLFW_KEY_LEFT_ALT ) || ( Key == GLFW_KEY_RIGHT_ALT ) ) { + // update internal state, but don't bother passing these + input::key_alt = + ( Action == GLFW_RELEASE ? + false : + true ); + } + + if( Key == -1 ) { return false; } + + // store key state + input::keys[ Key ] = Action; + + if( true == is_movement_key( Key ) ) { + // if the received key was one of movement keys, it's been handled and we don't need to bother further + return true; + } + + // include active modifiers for currently pressed key, except if the key is a modifier itself + auto const key = + Key + | ( modifier ? 0 : ( input::key_shift ? keymodifier::shift : 0 ) ) + | ( modifier ? 0 : ( input::key_ctrl ? keymodifier::control : 0 ) ); + + auto const lookup = m_bindings.find( key ); + if( lookup == m_bindings.end() ) { + // no binding for this key + return false; + } + // NOTE: basic keyboard controls don't have any parameters + // as we haven't yet implemented either item id system or multiplayer, the 'local' controlled vehicle and entity have temporary ids of 0 + // TODO: pass correct entity id once the missing systems are in place + m_relay.post( lookup->second, 0, 0, Action, 0 ); + m_command = ( + Action == GLFW_RELEASE ? + user_command::none : + lookup->second ); + + return true; +} + +int +keyboard_input::key( int const Key ) const { + + return input::keys[ Key ]; +} + +void +keyboard_input::bind() { + + for( auto const &bindingsetup : m_bindingsetups ) { + + m_bindings[ bindingsetup.binding ] = bindingsetup.command; + } + // cache movement key bindings + m_bindingscache.forward = binding( user_command::moveforward ); + m_bindingscache.back = binding( user_command::moveback ); + m_bindingscache.left = binding( user_command::moveleft ); + m_bindingscache.right = binding( user_command::moveright ); + m_bindingscache.up = binding( user_command::moveup ); + m_bindingscache.down = binding( user_command::movedown ); +} + +int +keyboard_input::binding( user_command const Command ) const { + + for( auto const &binding : m_bindings ) { + if( binding.second == Command ) { + return binding.first; + } + } + return -1; +} + +bool +keyboard_input::is_movement_key( int const Key ) const { + + bool const ismovementkey = + ( ( Key == m_bindingscache.forward ) + || ( Key == m_bindingscache.back ) + || ( Key == m_bindingscache.left ) + || ( Key == m_bindingscache.right ) + || ( Key == m_bindingscache.up ) + || ( Key == m_bindingscache.down ) ); + + return ismovementkey; +} + +void +keyboard_input::poll() { + + glm::vec2 const movementhorizontal { + // x-axis + ( Global.shiftState ? 1.f : 0.5f ) * + ( input::keys[ m_bindingscache.left ] != GLFW_RELEASE ? -1.f : + input::keys[ m_bindingscache.right ] != GLFW_RELEASE ? 1.f : + 0.f ), + // z-axis + ( Global.shiftState ? 1.f : 0.5f ) * + ( input::keys[ m_bindingscache.forward ] != GLFW_RELEASE ? 1.f : + input::keys[ m_bindingscache.back ] != GLFW_RELEASE ? -1.f : + 0.f ) }; + + if( ( movementhorizontal.x != 0.f || movementhorizontal.y != 0.f ) + || ( m_movementhorizontal.x != 0.f || m_movementhorizontal.y != 0.f ) ) { + m_relay.post( + ( true == Global.ctrlState ? + user_command::movehorizontalfast : + user_command::movehorizontal ), + movementhorizontal.x, + movementhorizontal.y, + GLFW_PRESS, + 0 ); + } + + m_movementhorizontal = movementhorizontal; + + float const movementvertical { + // y-axis + ( Global.shiftState ? 1.f : 0.5f ) * + ( input::keys[ m_bindingscache.up ] != GLFW_RELEASE ? 1.f : + input::keys[ m_bindingscache.down ] != GLFW_RELEASE ? -1.f : + 0.f ) }; + + if( ( movementvertical != 0.f ) + || ( m_movementvertical != 0.f ) ) { + m_relay.post( + ( true == Global.ctrlState ? + user_command::moveverticalfast : + user_command::movevertical ), + movementvertical, + 0, + GLFW_PRESS, + 0 ); + } + + m_movementvertical = movementvertical; +} + +//--------------------------------------------------------------------------- diff --git a/keyboardinput.h b/keyboardinput.h new file mode 100644 index 00000000..aa64ed9e --- /dev/null +++ b/keyboardinput.h @@ -0,0 +1,106 @@ +/* +This Source Code Form is subject to the +terms of the Mozilla Public License, v. +2.0. If a copy of the MPL was not +distributed with this file, You can +obtain one at +http://mozilla.org/MPL/2.0/. +*/ + +#pragma once + +#include +#include +#include "command.h" + +namespace input { + +extern std::array keys; +extern bool key_alt; +extern bool key_ctrl; +extern bool key_shift; + +} + +class keyboard_input { + +public: +// constructors + keyboard_input() = default; + +// destructor + virtual ~keyboard_input() = default; + +// methods + virtual + bool + init() { return true; } + bool + key( int const Key, int const Action ); + int + key( int const Key ) const; + void + poll(); + inline + user_command const + command() const { + return m_command; } + +protected: +// types + enum keymodifier : int { + + shift = 0x10000, + control = 0x20000 + }; + + struct binding_setup { + + user_command command; + int binding; + }; + + using bindingsetup_sequence = std::vector; + +// methods + virtual + void + default_bindings() = 0; + bool + recall_bindings(); + void + bind(); + +// members + bindingsetup_sequence m_bindingsetups; + +private: +// types + using usercommand_map = std::unordered_map; + + struct bindings_cache { + + int forward { -1 }; + int back { -1 }; + int left { -1 }; + int right { -1 }; + int up { -1 }; + int down { -1 }; + }; + +// methods + int + binding( user_command const Command ) const; + bool + is_movement_key( int const Key ) const; + +// members + user_command m_command { user_command::none }; // last, if any, issued command + usercommand_map m_bindings; + command_relay m_relay; + bindings_cache m_bindingscache; + glm::vec2 m_movementhorizontal { 0.f }; + float m_movementvertical { 0.f }; +}; + +//--------------------------------------------------------------------------- diff --git a/light.cpp b/light.cpp new file mode 100644 index 00000000..c17195c7 --- /dev/null +++ b/light.cpp @@ -0,0 +1,11 @@ +/* +This Source Code Form is subject to the +terms of the Mozilla Public License, v. +2.0. If a copy of the MPL was not +distributed with this file, You can +obtain one at +http://mozilla.org/MPL/2.0/. +*/ + +#include "stdafx.h" +#include "light.h" diff --git a/light.h b/light.h new file mode 100644 index 00000000..f3d68e5f --- /dev/null +++ b/light.h @@ -0,0 +1,23 @@ +/* +This Source Code Form is subject to the +terms of the Mozilla Public License, v. +2.0. If a copy of the MPL was not +distributed with this file, You can +obtain one at +http://mozilla.org/MPL/2.0/. +*/ + +#pragma once + +#include "color.h" + +// a simple light source, either omni- or directional +struct basic_light { + + glm::vec4 ambient { colors::none }; + glm::vec4 diffuse { colors::white }; + glm::vec4 specular { colors::white }; + glm::vec3 position; + glm::vec3 direction; + bool is_directional { true }; +}; diff --git a/lightarray.cpp b/lightarray.cpp new file mode 100644 index 00000000..1c82284b --- /dev/null +++ b/lightarray.cpp @@ -0,0 +1,86 @@ +/* +This Source Code Form is subject to the +terms of the Mozilla Public License, v. +2.0. If a copy of the MPL was not +distributed with this file, You can +obtain one at +http://mozilla.org/MPL/2.0/. +*/ + +/* + MaSzyna EU07 locomotive simulator + Copyright (C) 2001-2004 Marcin Wozniak and others + +*/ + +#include "stdafx.h" +#include "lightarray.h" + +#include "dynobj.h" + +void +light_array::insert( TDynamicObject const *Owner ) { + + // we're only storing lights for locos, which have two sets of lights, front and rear + // for a more generic role this function would have to be tweaked to add vehicle type-specific light combinations + data.emplace_back( Owner, side::front ); + data.emplace_back( Owner, side::rear ); +} + +void +light_array::remove( TDynamicObject const *Owner ) { + + data.erase( + std::remove_if( + data.begin(), + data.end(), + [=]( light_record const &light ){ return light.owner == Owner; } ), + data.end() ); +} + +// updates records in the collection +void +light_array::update() { + + for( auto &light : data ) { + // update light parameters to match current data of the owner + if( light.index == side::front ) { + // front light set + light.position = light.owner->GetPosition() + ( light.owner->VectorFront() * light.owner->GetLength() * 0.4 ); + light.direction = glm::make_vec3( light.owner->VectorFront().getArray() ); + } + else { + // rear light set + light.position = light.owner->GetPosition() - ( light.owner->VectorFront() * light.owner->GetLength() * 0.4 ); + light.direction = glm::make_vec3( light.owner->VectorFront().getArray() ); + light.direction.x = -light.direction.x; + light.direction.z = -light.direction.z; + } + // determine intensity of this light set + if( ( true == light.owner->MoverParameters->Battery ) + || ( true == light.owner->MoverParameters->ConverterFlag ) ) { + // with power on, the intensity depends on the state of activated switches + // first we cross-check the list of enabled lights with the lights installed in the vehicle... + auto const lights { light.owner->iLights[ light.index ] & light.owner->LightList( static_cast( light.index ) ) }; + // ...then check their individual state + light.count = 0 + + ( ( lights & light::headlight_left ) ? 1 : 0 ) + + ( ( lights & light::headlight_right ) ? 1 : 0 ) + + ( ( lights & light::headlight_upper ) ? 1 : 0 ); + + if( light.count > 0 ) { + light.intensity = std::max( 0.0f, std::log( (float)light.count + 1.0f ) ); + light.intensity *= ( light.owner->DimHeadlights ? 0.6f : 1.0f ); + // TBD, TODO: intensity can be affected further by other factors + } + else { + light.intensity = 0.0f; + } + } + else { + // with battery off the lights are off + light.intensity = 0.0f; + light.count = 0; + } + } +} diff --git a/lightarray.h b/lightarray.h new file mode 100644 index 00000000..700a34cd --- /dev/null +++ b/lightarray.h @@ -0,0 +1,42 @@ +#pragma once + +#include "classes.h" + +// collection of virtual light sources present in the scene +// used by the renderer to determine most suitable placement for actual light sources during render +struct light_array { + +public: +// types + struct light_record { + + light_record( TDynamicObject const *Owner, int const Lightindex) : + owner(Owner), index(Lightindex) + {}; + + TDynamicObject const *owner; // the object in world which 'carries' the light + int index{ -1 }; // 0: front lights, 1: rear lights + glm::dvec3 position; // position of the light in 3d scene + glm::vec3 direction; // direction of the light in 3d scene + glm::vec3 color{ 255.0f / 255.0f, 241.0f / 255.0f, 224.0f / 255.0f }; // color of the light, default is halogen light + float intensity{ 0.0f }; // (combined) intensity of the light(s) + int count{ 0 }; // number (or pattern) of active light(s) + }; + +// methods + // adds records for lights of specified owner to the collection + void + insert( TDynamicObject const *Owner ); + // removes records for lights of specified owner from the collection + void + remove( TDynamicObject const *Owner ); + // updates records in the collection + void + update(); + +// types + typedef std::vector lightrecord_array; + +// members + lightrecord_array data; +}; diff --git a/maszyna.rc b/maszyna.rc index ac76d2e1..ec21daa0 100644 Binary files a/maszyna.rc and b/maszyna.rc differ diff --git a/maszyna.vcxproj b/maszyna.vcxproj deleted file mode 100644 index 1cf2b810..00000000 --- a/maszyna.vcxproj +++ /dev/null @@ -1,387 +0,0 @@ - - - - - Debug - Win32 - - - Debug - x64 - - - Release - Win32 - - - Release - x64 - - - - {8E0232E5-1C67-442F-9E04-45ED2DDFC960} - Win32Proj - - - - Application - true - v140_xp - - - Application - true - v140_xp - - - Application - false - v140_xp - - - Application - false - v140_xp - - - - - - - - - - - - - - - - - - - eu07-$(PlatformShortName) - $(SolutionDir)tmp\$(PlatformShortName)-$(Configuration)\$(ProjectName)\ - $(SolutionDir)bin\ - - - eu07-$(PlatformShortName) - $(SolutionDir)bin\ - $(SolutionDir)tmp\$(PlatformShortName)-$(Configuration)\$(ProjectName)\ - - - false - $(SolutionDir)bin\ - $(SolutionDir)tmp\$(PlatformShortName)-$(Configuration)\$(ProjectName)\ - eu07-$(PlatformShortName) - - - eu07-$(PlatformShortName) - false - $(SolutionDir)bin\ - $(SolutionDir)tmp\$(PlatformShortName)-$(Configuration)\$(ProjectName)\ - - - - WIN32;_DEBUG;_WINDOWS;%(PreprocessorDefinitions) - Level3 - ProgramDatabase - $(SolutionDir);$(SolutionDir)console;$(SolutionDir)mczapkie;$(SolutionDir)ref/glew/include;$(SolutionDir)ref/glfw/include;$(SolutionDir)ref/glm;$(SolutionDir)ref/openal/include;$(SolutionDir)ref/dr_libs/include;$(SolutionDir)ref/imgui;$(SolutionDir)ref/imgui/examples;$(SolutionDir)ref/python/include;$(SolutionDir)ref/libserialport/include;%(AdditionalIncludeDirectories) - Use - true - false - true - true - - - true - $(DXSKD_DIR)lib/$(PlatformShortName);$(SolutionDir)ref/glew/lib/msvc-$(MSBuildToolsVersion)/$(PlatformShortName);$(SolutionDir)ref/glfw/lib/msvc-$(MSBuildToolsVersion)/$(PlatformShortName);$(SolutionDir)ref/openal/lib/$(PlatformShortName);$(SolutionDir)ref/python/lib/$(PlatformShortName);$(SolutionDir)ref/libserialport/lib/$(PlatformShortName);%(AdditionalLibraryDirectories) - Windows - - - true - - - - - - - WIN32;_DEBUG;_WINDOWS;%(PreprocessorDefinitions) - Level3 - ProgramDatabase - $(SolutionDir);$(SolutionDir)console;$(SolutionDir)mczapkie;$(SolutionDir)ref/glew/include;$(SolutionDir)ref/glfw/include;$(SolutionDir)ref/glm;$(SolutionDir)ref/openal/include;$(SolutionDir)ref/dr_libs/include;$(SolutionDir)ref/imgui;$(SolutionDir)ref/imgui/examples;$(SolutionDir)ref/python/include;$(SolutionDir)ref/libserialport/include;%(AdditionalIncludeDirectories) - Use - true - false - true - - - true - $(DXSKD_DIR)lib/$(PlatformShortName);$(SolutionDir)ref/glew/lib/msvc-$(MSBuildToolsVersion)/$(PlatformShortName);$(SolutionDir)ref/glfw/lib/msvc-$(MSBuildToolsVersion)/$(PlatformShortName);$(SolutionDir)ref/openal/lib/$(PlatformShortName);$(SolutionDir)ref/python/lib/$(PlatformShortName);$(SolutionDir)ref/libserialport/lib/$(PlatformShortName);%(AdditionalLibraryDirectories) - Windows - - - - - - - WIN32;NDEBUG;_WINDOWS;%(PreprocessorDefinitions) - MultiThreaded - Level3 - ProgramDatabase - $(SolutionDir);$(SolutionDir)console;$(SolutionDir)mczapkie;$(SolutionDir)ref/glew/include;$(SolutionDir)ref/glfw/include;$(SolutionDir)ref/glm;$(SolutionDir)ref/openal/include;$(SolutionDir)ref/dr_libs/include;$(SolutionDir)ref/imgui;$(SolutionDir)ref/imgui/examples;$(SolutionDir)ref/python/include;$(SolutionDir)ref/libserialport/include;%(AdditionalIncludeDirectories) - Use - true - true - true - - - true - true - true - $(DXSKD_DIR)lib/$(PlatformShortName);$(SolutionDir)ref/glew/lib/msvc-$(MSBuildToolsVersion)/$(PlatformShortName);$(SolutionDir)ref/glfw/lib/msvc-$(MSBuildToolsVersion)/$(PlatformShortName);$(SolutionDir)ref/openal/lib/$(PlatformShortName);$(SolutionDir)ref/python/lib/$(PlatformShortName);$(SolutionDir)ref/libserialport/lib/$(PlatformShortName);%(AdditionalLibraryDirectories) - Windows - libcmt.lib - true - UseLinkTimeCodeGeneration - - - - - WIN32;NDEBUG;_WINDOWS;%(PreprocessorDefinitions) - MultiThreaded - Level3 - ProgramDatabase - $(SolutionDir);$(SolutionDir)console;$(SolutionDir)mczapkie;$(SolutionDir)ref/glew/include;$(SolutionDir)ref/glfw/include;$(SolutionDir)ref/glm;$(SolutionDir)ref/openal/include;$(SolutionDir)ref/dr_libs/include;$(SolutionDir)ref/imgui;$(SolutionDir)ref/imgui/examples;$(SolutionDir)ref/python/include;$(SolutionDir)ref/libserialport/include;%(AdditionalIncludeDirectories) - Use - true - true - true - true - - - true - true - true - $(DXSKD_DIR)lib/$(PlatformShortName);$(SolutionDir)ref/glew/lib/msvc-$(MSBuildToolsVersion)/$(PlatformShortName);$(SolutionDir)ref/glfw/lib/msvc-$(MSBuildToolsVersion)/$(PlatformShortName);$(SolutionDir)ref/openal/lib/$(PlatformShortName);$(SolutionDir)ref/python/lib/$(PlatformShortName);$(SolutionDir)ref/libserialport/lib/$(PlatformShortName);%(AdditionalLibraryDirectories) - Windows - libcmt.lib - UseLinkTimeCodeGeneration - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - NotUsing - NotUsing - NotUsing - NotUsing - - - Create - Create - Create - Create - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - TARGETMACHINEX86;%(PreprocessorDefinitions) - TARGETMACHINEX86;%(PreprocessorDefinitions) - - - - - - - - - \ No newline at end of file diff --git a/material.cpp b/material.cpp new file mode 100644 index 00000000..d8402acf --- /dev/null +++ b/material.cpp @@ -0,0 +1,193 @@ +/* +This Source Code Form is subject to the +terms of the Mozilla Public License, v. +2.0. If a copy of the MPL was not +distributed with this file, You can +obtain one at +http://mozilla.org/MPL/2.0/. +*/ + +#include "stdafx.h" + +#include "material.h" +#include "renderer.h" +#include "utilities.h" +#include "sn_utils.h" +#include "globals.h" + +bool +opengl_material::deserialize( cParser &Input, bool const Loadnow ) { + + bool result { false }; + while( true == deserialize_mapping( Input, 0, Loadnow ) ) { + result = true; // once would suffice but, eh + } + + has_alpha = ( + texture1 != null_handle ? + GfxRenderer.Texture( texture1 ).has_alpha : + false ); + + return result; +} + +// imports member data pair from the config file +bool +opengl_material::deserialize_mapping( cParser &Input, int const Priority, bool const Loadnow ) { + // NOTE: comma can be part of legacy file names, so we don't treat it as a separator here + std::string const key { Input.getToken( true, "\n\r\t ;[]" ) }; + // key can be an actual key or block end + if( ( true == key.empty() ) || ( key == "}" ) ) { return false; } + + if( Priority != -1 ) { + // regular attribute processing mode + if( key == Global.Weather ) { + // weather textures override generic (pri 0) and seasonal (pri 1) textures + // seasonal weather textures (pri 1+2=3) override generic weather (pri 2) textures + // skip the opening bracket + auto const value { Input.getToken( true, "\n\r\t ;" ) }; + while( true == deserialize_mapping( Input, Priority + 2, Loadnow ) ) { + ; // all work is done in the header + } + } + else if( key == Global.Season ) { + // seasonal textures override generic textures + // skip the opening bracket + auto const value { Input.getToken( true, "\n\r\t ;" ) }; + while( true == deserialize_mapping( Input, Priority + 1, Loadnow ) ) { + ; // all work is done in the header + } + } + else if( ( key == "texture1:" ) + || ( key == "texture_diffuse:" ) ) { + if( ( texture1 == null_handle ) + || ( Priority > priority1 ) ) { + texture1 = GfxRenderer.Fetch_Texture( deserialize_random_set( Input ), Loadnow ); + priority1 = Priority; + } + } + else if( ( key == "texture2:" ) + || ( key == "texture_normalmap:" ) ) { + if( ( texture2 == null_handle ) + || ( Priority > priority2 ) ) { + texture2 = GfxRenderer.Fetch_Texture( deserialize_random_set( Input ), Loadnow ); + priority2 = Priority; + } + } + else if( key == "size:" ) { + Input.getTokens( 2 ); + Input + >> size.x + >> size.y; + } + else { + auto const value { Input.getToken( true, "\n\r\t ;" ) }; + if( value == "{" ) { + // unrecognized or ignored token, but comes with attribute block and potential further nesting + // go through it and discard the content + while( true == deserialize_mapping( Input, -1, Loadnow ) ) { + ; // all work is done in the header + } + } + } + } + else { + // discard mode; ignores all retrieved tokens + auto const value { Input.getToken( true, "\n\r\t ;" ) }; + if( value == "{" ) { + // ignored tokens can come with their own blocks, ignore these recursively + // go through it and discard the content + while( true == deserialize_mapping( Input, -1, Loadnow ) ) { + ; // all work is done in the header + } + } + } + + return true; // return value marks a key: value pair was extracted, nothing about whether it's recognized +} + + +// create material object from data stored in specified file. +// NOTE: the deferred load parameter is passed to textures defined by material, the material itself is always loaded immediately +material_handle +material_manager::create( std::string const &Filename, bool const Loadnow ) { + + auto filename { Filename }; + + if( filename.find( '|' ) != std::string::npos ) + filename.erase( filename.find( '|' ) ); // po | może być nazwa kolejnej tekstury + + erase_extension( filename ); + replace_slashes( filename ); + if( filename[ 0 ] == '/' ) { + // filename can potentially begin with a slash, and we don't need it + filename.erase( 0, 1 ); + } + + // try to locate requested material in the databank + auto const databanklookup { find_in_databank( filename ) }; + if( databanklookup != null_handle ) { + return databanklookup; + } + // if this fails, try to look for it on disk + opengl_material material; + auto const disklookup { find_on_disk( filename ) }; + if( false == disklookup.first.empty() ) { + cParser materialparser( disklookup.first + disklookup.second, cParser::buffer_FILE ); + if( false == material.deserialize( materialparser, Loadnow ) ) { + // deserialization failed but the .mat file does exist, so we give up at this point + return null_handle; + } + material.name = disklookup.first; + } + else { + // if there's no .mat file, this could be legacy method of referring just to diffuse texture directly, make a material out of it in such case + material.texture1 = GfxRenderer.Fetch_Texture( Filename, Loadnow ); + if( material.texture1 == null_handle ) { + // if there's also no texture, give up + return null_handle; + } + // use texture path and name to tell the newly created materials apart + filename = GfxRenderer.Texture( material.texture1 ).name; + erase_extension( filename ); + material.name = filename; + material.has_alpha = GfxRenderer.Texture( material.texture1 ).has_alpha; + } + + material_handle handle = m_materials.size(); + m_materials.emplace_back( material ); + m_materialmappings.emplace( material.name, handle ); + return handle; +}; + +// checks whether specified material is in the material bank. returns handle to the material, or a null handle +material_handle +material_manager::find_in_databank( std::string const &Materialname ) const { + + std::vector const filenames { + Global.asCurrentTexturePath + Materialname, + Materialname, + szTexturePath + Materialname }; + + for( auto const &filename : filenames ) { + auto const lookup { m_materialmappings.find( filename ) }; + if( lookup != m_materialmappings.end() ) { + return lookup->second; + } + } + // all lookups failed + return null_handle; +} + +// checks whether specified file exists. +// NOTE: technically could be static, but we might want to switch from global texture path to instance-specific at some point +std::pair +material_manager::find_on_disk( std::string const &Materialname ) const { + + return ( + FileExists( + { Global.asCurrentTexturePath + Materialname, Materialname, szTexturePath + Materialname }, + { ".mat" } ) ); +} + +//--------------------------------------------------------------------------- diff --git a/material.h b/material.h new file mode 100644 index 00000000..104990de --- /dev/null +++ b/material.h @@ -0,0 +1,77 @@ +/* +This Source Code Form is subject to the +terms of the Mozilla Public License, v. +2.0. If a copy of the MPL was not +distributed with this file, You can +obtain one at +http://mozilla.org/MPL/2.0/. +*/ + +#pragma once + +#include "classes.h" +#include "texture.h" + +typedef int material_handle; + +// a collection of parameters for the rendering setup. +// for modern opengl this translates to set of attributes for the active shaders, +// for legacy opengl this is basically just texture(s) assigned to geometry +struct opengl_material { + + texture_handle texture1 { null_handle }; // primary texture, typically diffuse+apha + texture_handle texture2 { null_handle }; // secondary texture, typically normal+reflection + + bool has_alpha { false }; // alpha state, calculated from presence of alpha in texture1 + std::string name; + glm::vec2 size { -1.f, -1.f }; // 'physical' size of bound texture, in meters + +// constructors + opengl_material() = default; + +// methods + bool + deserialize( cParser &Input, bool const Loadnow ); + +private: +// methods + // imports member data pair from the config file, overriding existing parameter values of lower priority + bool + deserialize_mapping( cParser &Input, int const Priority, bool const Loadnow ); + // extracts name of the sound file from provided data stream + std::string + deserialize_filename( cParser &Input ); + +// members + int priority1 { -1 }; // priority of last loaded primary texture + int priority2 { -1 }; // priority of last loaded secondary texture +}; + +class material_manager { + +public: + material_manager() { m_materials.emplace_back( opengl_material() ); } // empty bindings for null material + + material_handle + create( std::string const &Filename, bool const Loadnow ); + opengl_material const & + material( material_handle const Material ) const { return m_materials[ Material ]; } + +private: +// types + typedef std::vector material_sequence; + typedef std::unordered_map index_map; +// methods: + // checks whether specified texture is in the texture bank. returns texture id, or npos. + material_handle + find_in_databank( std::string const &Materialname ) const; + // checks whether specified file exists. returns name of the located file, or empty string. + std::pair + find_on_disk( std::string const &Materialname ) const; +// members: + material_sequence m_materials; + index_map m_materialmappings; + +}; + +//--------------------------------------------------------------------------- diff --git a/messaging.cpp b/messaging.cpp new file mode 100644 index 00000000..f1826507 --- /dev/null +++ b/messaging.cpp @@ -0,0 +1,424 @@ +/* +This Source Code Form is subject to the +terms of the Mozilla Public License, v. +2.0. If a copy of the MPL was not +distributed with this file, You can +obtain one at +http://mozilla.org/MPL/2.0/. +*/ + +#include "stdafx.h" +#include "messaging.h" + +#include "globals.h" +#include "application.h" +#include "simulation.h" +#include "simulationtime.h" +#include "event.h" +#include "dynobj.h" +#include "driver.h" +#include "mtable.h" +#include "logs.h" + +#ifdef _WIN32 +extern "C" +{ + GLFWAPI HWND glfwGetWin32Window( GLFWwindow* window ); //m7todo: potrzebne do directsound +} +#endif + +namespace multiplayer { + +std::uint32_t const EU07_MESSAGEHEADER { MAKE_ID4( 'E','U','0','7' ) }; + +void +Navigate(std::string const &ClassName, UINT Msg, WPARAM wParam, LPARAM lParam) { +#ifdef _WIN32 + // wysłanie komunikatu do sterującego + HWND h = FindWindow(ClassName.c_str(), 0); // można by to zapamiętać + if (h == 0) + h = FindWindow(0, ClassName.c_str()); // można by to zapamiętać + SendMessage(h, Msg, wParam, lParam); +#endif +} + +void +OnCommandGet(multiplayer::DaneRozkaz *pRozkaz) +{ // odebranie komunikatu z serwera + if (pRozkaz->iSygn == EU07_MESSAGEHEADER ) + switch (pRozkaz->iComm) + { + case 0: // odesłanie identyfikatora wersji + CommLog( Now() + " " + std::to_string(pRozkaz->iComm) + " version" + " rcvd"); + WyslijString(Global.asVersion, 0); // przedsatwienie się + break; + case 1: // odesłanie identyfikatora wersji + CommLog( Now() + " " + std::to_string(pRozkaz->iComm) + " scenery" + " rcvd"); + WyslijString(Global.SceneryFile, 1); // nazwa scenerii + break; + case 2: { + // event + CommLog( Now() + " " + std::to_string( pRozkaz->iComm ) + " " + + std::string( pRozkaz->cString + 1, (unsigned)( pRozkaz->cString[ 0 ] ) ) + " rcvd" ); + + if( Global.iMultiplayer ) { + auto *event = simulation::Events.FindEvent( std::string( pRozkaz->cString + 1, (unsigned)( pRozkaz->cString[ 0 ] ) ) ); + if( event != nullptr ) { + if( ( typeid( *event ) == typeid( multi_event ) ) + || ( typeid( *event ) == typeid( lights_event ) ) + || ( event->m_sibling != 0 ) ) { + // tylko jawne albo niejawne Multiple + simulation::Events.AddToQuery( event, nullptr ); // drugi parametr to dynamic wywołujący - tu brak + } + } + } + break; + } + case 3: // rozkaz dla AI + if (Global.iMultiplayer) + { + int i = int(pRozkaz->cString[8]); // długość pierwszego łańcucha (z przodu dwa floaty) + CommLog( + Now() + " " + to_string(pRozkaz->iComm) + " " + + std::string(pRozkaz->cString + 11 + i, (unsigned)(pRozkaz->cString[10 + i])) + + " rcvd"); + // nazwa pojazdu jest druga + auto *vehicle = simulation::Vehicles.find( { pRozkaz->cString + 11 + i, (unsigned)pRozkaz->cString[ 10 + i ] } ); + if( ( vehicle != nullptr ) + && ( vehicle->Mechanik != nullptr ) ) { + vehicle->Mechanik->PutCommand( + { pRozkaz->cString + 9, static_cast(i) }, + pRozkaz->fPar[0], pRozkaz->fPar[1], + nullptr, + stopExt ); // floaty są z przodu + WriteLog("AI command: " + std::string(pRozkaz->cString + 9, i)); + } + } + break; + case 4: // badanie zajętości toru + { + CommLog(Now() + " " + to_string(pRozkaz->iComm) + " " + + std::string(pRozkaz->cString + 1, (unsigned)(pRozkaz->cString[0])) + " rcvd"); + + auto *track = simulation::Paths.find( std::string( pRozkaz->cString + 1, (unsigned)( pRozkaz->cString[ 0 ] ) ) ); + if( ( track != nullptr ) + && ( track->IsEmpty() ) ) { + WyslijWolny( track->name() ); + } + } + break; + case 5: // ustawienie parametrów + { + CommLog(Now() + " " + to_string(pRozkaz->iComm) + " params " + to_string(*pRozkaz->iPar) + " rcvd"); + if (*pRozkaz->iPar == 0) // sprawdzenie czasu + if (*pRozkaz->iPar & 1) // ustawienie czasu + { + double t = pRozkaz->fPar[1]; + simulation::Time.data().wDay = std::floor(t); // niby nie powinno być dnia, ale... + if (Global.fMoveLight >= 0) + Global.fMoveLight = t; // trzeba by deklinację Słońca przeliczyć + simulation::Time.data().wHour = std::floor(24 * t) - 24.0 * simulation::Time.data().wDay; + simulation::Time.data().wMinute = std::floor(60 * 24 * t) - 60.0 * (24.0 * simulation::Time.data().wDay + simulation::Time.data().wHour); + simulation::Time.data().wSecond = std::floor( 60 * 60 * 24 * t ) - 60.0 * ( 60.0 * ( 24.0 * simulation::Time.data().wDay + simulation::Time.data().wHour ) + simulation::Time.data().wMinute ); + } + if (*pRozkaz->iPar & 2) + { // ustawienie flag zapauzowania + Global.iPause = pRozkaz->fPar[2]; // zakładamy, że wysyłający wie, co robi + } + } + break; + case 6: // pobranie parametrów ruchu pojazdu + if (Global.iMultiplayer) { + // Ra 2014-12: to ma działać również dla pojazdów bez obsady + CommLog( + Now() + " " + + to_string( pRozkaz->iComm ) + " " + + std::string{ pRozkaz->cString + 1, (unsigned)( pRozkaz->cString[ 0 ] ) } + + " rcvd" ); + if (pRozkaz->cString[0]) { + // jeśli długość nazwy jest niezerowa szukamy pierwszego pojazdu o takiej nazwie i odsyłamy parametry ramką #7 + auto *vehicle = ( + pRozkaz->cString[ 1 ] == '*' ? + simulation::Vehicles.find( Global.asHumanCtrlVehicle ) : + simulation::Vehicles.find( std::string{ pRozkaz->cString + 1, (unsigned)pRozkaz->cString[ 0 ] } ) ); + if( vehicle != nullptr ) { + WyslijNamiary( vehicle ); // wysłanie informacji o pojeździe + } + } + else { + // dla pustego wysyłamy ramki 6 z nazwami pojazdów AI (jeśli potrzebne wszystkie, to rozpoznać np. "*") + simulation::Vehicles.DynamicList(); + } + } + break; + case 8: // ponowne wysłanie informacji o zajętych odcinkach toru + CommLog(Now() + " " + to_string(pRozkaz->iComm) + " all busy track" + " rcvd"); + simulation::Paths.TrackBusyList(); + break; + case 9: // ponowne wysłanie informacji o zajętych odcinkach izolowanych + CommLog(Now() + " " + to_string(pRozkaz->iComm) + " all busy isolated" + " rcvd"); + simulation::Paths.IsolatedBusyList(); + break; + case 10: // badanie zajętości jednego odcinka izolowanego + CommLog(Now() + " " + to_string(pRozkaz->iComm) + " " + + std::string(pRozkaz->cString + 1, (unsigned)(pRozkaz->cString[0])) + " rcvd"); + simulation::Paths.IsolatedBusy( std::string( pRozkaz->cString + 1, (unsigned)( pRozkaz->cString[ 0 ] ) ) ); + break; + case 11: // ustawienie parametrów ruchu pojazdu + // Ground.IsolatedBusy(AnsiString(pRozkaz->cString+1,(unsigned)(pRozkaz->cString[0]))); + break; + case 12: // skrocona ramka parametrow pojazdow AI (wszystkich!!) + CommLog(Now() + " " + to_string(pRozkaz->iComm) + " obsadzone" + " rcvd"); + WyslijObsadzone(); + // Ground.IsolatedBusy(AnsiString(pRozkaz->cString+1,(unsigned)(pRozkaz->cString[0]))); + break; + case 13: // ramka uszkodzenia i innych stanow pojazdu, np. wylaczenie CA, wlaczenie recznego itd. + CommLog(Now() + " " + to_string(pRozkaz->iComm) + " " + + std::string(pRozkaz->cString + 1, (unsigned)(pRozkaz->cString[0])) + + " rcvd"); + if( pRozkaz->cString[ 1 ] ) // jeśli długość nazwy jest niezerowa + { // szukamy pierwszego pojazdu o takiej nazwie i odsyłamy parametry ramką #13 + auto *lookup = ( + pRozkaz->cString[ 2 ] == '*' ? + simulation::Vehicles.find( Global.asHumanCtrlVehicle ) : // nazwa pojazdu użytkownika + simulation::Vehicles.find( std::string( pRozkaz->cString + 2, (unsigned)pRozkaz->cString[ 1 ] ) ) ); // nazwa pojazdu + if( lookup == nullptr ) { break; } // nothing found, nothing to do + auto *d { lookup }; + while( d != nullptr ) { + d->Damage( pRozkaz->cString[ 0 ] ); + d = d->Next(); // pozostałe też + } + d = lookup->Prev(); + while( d != nullptr ) { + d->Damage( pRozkaz->cString[ 0 ] ); + d = d->Prev(); // w drugą stronę też + } + WyslijUszkodzenia( lookup->asName, lookup->MoverParameters->EngDmgFlag ); // zwrot informacji o pojeździe + } + break; + default: + break; + } +} + +void +WyslijEvent(const std::string &e, const std::string &d) +{ // Ra: jeszcze do wyczyszczenia +#ifdef _WIN32 + DaneRozkaz r; + r.iSygn = EU07_MESSAGEHEADER; + r.iComm = 2; // 2 - event + size_t i = e.length(), j = d.length(); + r.cString[0] = char(i); + strcpy(r.cString + 1, e.c_str()); // zakończony zerem + r.cString[i + 2] = char(j); // licznik po zerze kończącym + strcpy(r.cString + 3 + i, d.c_str()); // zakończony zerem + COPYDATASTRUCT cData; + cData.dwData = EU07_MESSAGEHEADER; // sygnatura + cData.cbData = (DWORD)(12 + i + j); // 8+dwa liczniki i dwa zera kończące + cData.lpData = &r; + Navigate( "TEU07SRK", WM_COPYDATA, (WPARAM)glfwGetWin32Window( Application.window() ), (LPARAM)&cData ); + CommLog( Now() + " " + std::to_string(r.iComm) + " " + e + " sent" ); +#endif +} + +void +WyslijUszkodzenia(const std::string &t, char fl) +{ // wysłanie informacji w postaci pojedynczego tekstu +#ifdef _WIN32 + DaneRozkaz r; + r.iSygn = EU07_MESSAGEHEADER; + r.iComm = 13; // numer komunikatu + size_t i = t.length(); + r.cString[0] = char(fl); + r.cString[1] = char(i); + strcpy(r.cString + 2, t.c_str()); // z zerem kończącym + COPYDATASTRUCT cData; + cData.dwData = EU07_MESSAGEHEADER; // sygnatura + cData.cbData = (DWORD)(11 + i); // 8+licznik i zero kończące + cData.lpData = &r; + Navigate( "TEU07SRK", WM_COPYDATA, (WPARAM)glfwGetWin32Window( Application.window() ), (LPARAM)&cData ); + CommLog( Now() + " " + std::to_string(r.iComm) + " " + t + " sent"); +#endif +} + +void +WyslijString(const std::string &t, int n) +{ // wysłanie informacji w postaci pojedynczego tekstu +#ifdef _WIN32 + DaneRozkaz r; + r.iSygn = EU07_MESSAGEHEADER; + r.iComm = n; // numer komunikatu + size_t i = t.length(); + r.cString[0] = char(i); + strcpy(r.cString + 1, t.c_str()); // z zerem kończącym + COPYDATASTRUCT cData; + cData.dwData = EU07_MESSAGEHEADER; // sygnatura + cData.cbData = (DWORD)(10 + i); // 8+licznik i zero kończące + cData.lpData = &r; + Navigate( "TEU07SRK", WM_COPYDATA, (WPARAM)glfwGetWin32Window( Application.window() ), (LPARAM)&cData ); + CommLog( Now() + " " + std::to_string(r.iComm) + " " + t + " sent"); +#endif +} + +void +WyslijWolny(const std::string &t) +{ // Ra: jeszcze do wyczyszczenia + WyslijString(t, 4); // tor wolny +} + +void +WyslijNamiary(TDynamicObject const *Vehicle) +{ // wysłanie informacji o pojeździe - (float), długość ramki będzie zwiększana w miarę potrzeby +#ifdef _WIN32 + // WriteLog("Wysylam pojazd"); + DaneRozkaz r; + r.iSygn = EU07_MESSAGEHEADER; + r.iComm = 7; // 7 - dane pojazdu + int i = 32; + size_t j = Vehicle->asName.length(); + r.iPar[0] = i; // ilość danych liczbowych + r.fPar[1] = Global.fTimeAngleDeg / 360.0; // aktualny czas (1.0=doba) + r.fPar[2] = Vehicle->MoverParameters->Loc.X; // pozycja X + r.fPar[3] = Vehicle->MoverParameters->Loc.Y; // pozycja Y + r.fPar[4] = Vehicle->MoverParameters->Loc.Z; // pozycja Z + r.fPar[5] = Vehicle->MoverParameters->V; // prędkość ruchu X + r.fPar[6] = Vehicle->MoverParameters->nrot * M_PI * + Vehicle->MoverParameters->WheelDiameter; // prędkość obrotowa kóŁ + r.fPar[7] = 0; // prędkość ruchu Z + r.fPar[8] = Vehicle->MoverParameters->AccS; // przyspieszenie X + r.fPar[9] = Vehicle->MoverParameters->AccN; // przyspieszenie Y //na razie nie + r.fPar[10] = Vehicle->MoverParameters->AccVert; // przyspieszenie Z + r.fPar[11] = Vehicle->MoverParameters->DistCounter; // przejechana odległość w km + r.fPar[12] = Vehicle->MoverParameters->PipePress; // ciśnienie w PG + r.fPar[13] = Vehicle->MoverParameters->ScndPipePress; // ciśnienie w PZ + r.fPar[14] = Vehicle->MoverParameters->BrakePress; // ciśnienie w CH + r.fPar[15] = Vehicle->MoverParameters->Compressor; // ciśnienie w ZG + r.fPar[16] = Vehicle->MoverParameters->Itot; // Prąd całkowity + r.iPar[17] = Vehicle->MoverParameters->MainCtrlPos; // Pozycja NJ + r.iPar[18] = Vehicle->MoverParameters->ScndCtrlPos; // Pozycja NB + r.iPar[19] = Vehicle->MoverParameters->MainCtrlActualPos; // Pozycja jezdna + r.iPar[20] = Vehicle->MoverParameters->ScndCtrlActualPos; // Pozycja bocznikowania + r.iPar[21] = Vehicle->MoverParameters->ScndCtrlActualPos; // Pozycja bocznikowania + r.iPar[22] = Vehicle->MoverParameters->ResistorsFlag * 1 + + Vehicle->MoverParameters->ConverterFlag * 2 + + +Vehicle->MoverParameters->CompressorFlag * 4 + + Vehicle->MoverParameters->Mains * 8 + + +Vehicle->MoverParameters->DoorLeftOpened * 16 + + Vehicle->MoverParameters->DoorRightOpened * 32 + + +Vehicle->MoverParameters->FuseFlag * 64 + + Vehicle->MoverParameters->DepartureSignal * 128; + // WriteLog("Zapisalem stare"); + // WriteLog("Mam patykow "+IntToStr(t->DynamicObject->iAnimType[ANIM_PANTS])); + for (int p = 0; p < 4; p++) + { + // WriteLog("Probuje pant "+IntToStr(p)); + if (p < Vehicle->iAnimType[ANIM_PANTS]) + { + r.fPar[23 + p] = Vehicle->pants[p].fParamPants->PantWys; // stan pantografów 4 + // WriteLog("Zapisalem pant "+IntToStr(p)); + } + else + { + r.fPar[23 + p] = -2; + // WriteLog("Nie mam pant "+IntToStr(p)); + } + } + // WriteLog("Zapisalem pantografy"); + for (int p = 0; p < 3; p++) + r.fPar[27 + p] = + Vehicle->MoverParameters->ShowCurrent(p + 1); // amperomierze kolejnych grup + // WriteLog("zapisalem prady"); + r.iPar[30] = Vehicle->MoverParameters->WarningSignal; // trabienie + r.fPar[31] = Vehicle->MoverParameters->RunningTraction.TractionVoltage; // napiecie WN + // WriteLog("Parametry gotowe"); + i <<= 2; // ilość bajtów + r.cString[i] = char(j); // na końcu nazwa, żeby jakoś zidentyfikować + strcpy(r.cString + i + 1, Vehicle->asName.c_str()); // zakończony zerem + COPYDATASTRUCT cData; + cData.dwData = EU07_MESSAGEHEADER; // sygnatura + cData.cbData = (DWORD)(10 + i + j); // 8+licznik i zero kończące + cData.lpData = &r; + // WriteLog("Ramka gotowa"); + Navigate( "TEU07SRK", WM_COPYDATA, (WPARAM)glfwGetWin32Window( Application.window() ), (LPARAM)&cData ); + // WriteLog("Ramka poszla!"); + CommLog( Now() + " " + std::to_string(r.iComm) + " " + Vehicle->asName + " sent"); +#endif +} + +void +WyslijObsadzone() +{ // wysłanie informacji o pojeździe +#ifdef _WIN32 + DaneRozkaz2 r; + r.iSygn = EU07_MESSAGEHEADER; + r.iComm = 12; // kod 12 + for (int i=0; i<1984; ++i) r.cString[i] = 0; + + // TODO: clean this up, we shouldn't be relying on direct list access + auto &vehiclelist = simulation::Vehicles.sequence(); + + int i = 0; + for( auto *vehicle : vehiclelist ) { + if( vehicle->Mechanik ) { + strcpy( r.cString + 64 * i, vehicle->asName.c_str() ); + r.fPar[ 16 * i + 4 ] = vehicle->GetPosition().x; + r.fPar[ 16 * i + 5 ] = vehicle->GetPosition().y; + r.fPar[ 16 * i + 6 ] = vehicle->GetPosition().z; + r.iPar[ 16 * i + 7 ] = static_cast( vehicle->Mechanik->GetAction() ); + strcpy( r.cString + 64 * i + 32, vehicle->GetTrack()->IsolatedName().c_str() ); + strcpy( r.cString + 64 * i + 48, vehicle->Mechanik->TrainName().c_str() ); + i++; + if( i > 30 ) break; + } + } + while (i <= 30) + { + strcpy(r.cString + 64 * i, "none"); + r.fPar[16 * i + 4] = 1; + r.fPar[16 * i + 5] = 2; + r.fPar[16 * i + 6] = 3; + r.iPar[16 * i + 7] = 0; + strcpy(r.cString + 64 * i + 32, "none"); + strcpy(r.cString + 64 * i + 48, "none"); + i++; + } + + COPYDATASTRUCT cData; + cData.dwData = EU07_MESSAGEHEADER; // sygnatura + cData.cbData = 8 + 1984; // 8+licznik i zero kończące + cData.lpData = &r; + // WriteLog("Ramka gotowa"); + Navigate( "TEU07SRK", WM_COPYDATA, (WPARAM)glfwGetWin32Window( Application.window() ), (LPARAM)&cData ); + CommLog( Now() + " " + std::to_string(r.iComm) + " obsadzone" + " sent"); +#endif +} + +void +WyslijParam(int nr, int fl) +{ // wysłanie parametrów symulacji w ramce (nr) z flagami (fl) +#ifdef _WIN32 + DaneRozkaz r; + r.iSygn = EU07_MESSAGEHEADER; + r.iComm = nr; // zwykle 5 + r.iPar[0] = fl; // flagi istotności kolejnych parametrów + int i = 0; // domyślnie brak danych + switch (nr) + { // można tym przesyłać różne zestawy parametrów + case 5: // czas i pauza + r.fPar[1] = Global.fTimeAngleDeg / 360.0; // aktualny czas (1.0=doba) + r.iPar[2] = Global.iPause; // stan zapauzowania + i = 8; // dwa parametry po 4 bajty każdy + break; + } + COPYDATASTRUCT cData; + cData.dwData = EU07_MESSAGEHEADER; // sygnatura + cData.cbData = 12 + i; // 12+rozmiar danych + cData.lpData = &r; + Navigate( "TEU07SRK", WM_COPYDATA, (WPARAM)glfwGetWin32Window( Application.window() ), (LPARAM)&cData ); +#endif +} + +} // multiplayer + +//--------------------------------------------------------------------------- diff --git a/messaging.h b/messaging.h new file mode 100644 index 00000000..46624bfe --- /dev/null +++ b/messaging.h @@ -0,0 +1,52 @@ +/* +This Source Code Form is subject to the +terms of the Mozilla Public License, v. +2.0. If a copy of the MPL was not +distributed with this file, You can +obtain one at +http://mozilla.org/MPL/2.0/. +*/ + +#pragma once + +#include + +class TDynamicObject; + +namespace multiplayer { + +struct DaneRozkaz { // struktura komunikacji z EU07.EXE + int iSygn; // sygnatura 'EU07' + int iComm; // rozkaz/status (kod ramki) + union { + float fPar[ 62 ]; + int iPar[ 62 ]; + char cString[ 248 ]; // upakowane stringi + }; +}; + +struct DaneRozkaz2 { // struktura komunikacji z EU07.EXE + int iSygn; // sygnatura 'EU07' + int iComm; // rozkaz/status (kod ramki) + union { + float fPar[ 496 ]; + int iPar[ 496 ]; + char cString[ 1984 ]; // upakowane stringi + }; +}; + +void Navigate( std::string const &ClassName, UINT Msg, WPARAM wParam, LPARAM lParam ); + +void OnCommandGet( multiplayer::DaneRozkaz *pRozkaz ); + +void WyslijEvent( const std::string &e, const std::string &d ); +void WyslijString( const std::string &t, int n ); +void WyslijWolny( const std::string &t ); +void WyslijNamiary( TDynamicObject const *Vehicle ); +void WyslijParam( int nr, int fl ); +void WyslijUszkodzenia( const std::string &t, char fl ); +void WyslijObsadzone(); // -> skladanie wielu pojazdow + +} // multiplayer + +//--------------------------------------------------------------------------- diff --git a/moon.cpp b/moon.cpp new file mode 100644 index 00000000..e28a13e7 --- /dev/null +++ b/moon.cpp @@ -0,0 +1,322 @@ + +#include "stdafx.h" +#include "moon.h" +#include "globals.h" +#include "mtable.h" +#include "utilities.h" +#include "simulationtime.h" + +////////////////////////////////////////////////////////////////////////////////////////// +// cSun -- class responsible for dynamic calculation of position and intensity of the Sun, + +cMoon::cMoon() { + + setLocation( 19.00f, 52.00f ); // default location roughly in centre of Poland + m_observer.press = 1013.0; // surface pressure, millibars + m_observer.temp = 15.0; // ambient dry-bulb temperature, degrees C +} + +cMoon::~cMoon() { gluDeleteQuadric( moonsphere ); } + +void +cMoon::init() { + + m_observer.timezone = -1.0 * simulation::Time.zone_bias(); + // NOTE: we're calculating phase just once, because it's unlikely simulation will last a few days, + // plus a sudden texture change would be pretty jarring + phase(); + + moonsphere = gluNewQuadric(); + gluQuadricNormals( moonsphere, GLU_SMOOTH ); +} + +void +cMoon::update() { + + m_observer.temp = Global.AirTemperature; + + move(); + glm::vec3 position( 0.f, 0.f, -1.f ); + position = glm::rotateX( position, glm::radians( static_cast( m_body.elevref ) ) ); + position = glm::rotateY( position, glm::radians( static_cast( -m_body.hrang ) ) ); + + m_position = glm::normalize( position ); +} + +void +cMoon::render() { + + ::glColor4f( 225.f / 255.f, 225.f / 255.f, 255.f / 255.f, 1.f ); + // debug line to locate the moon easier + auto const position { m_position * 2000.f }; + ::glBegin( GL_LINES ); + ::glVertex3fv( glm::value_ptr( position ) ); + ::glVertex3f( position.x, 0.f, position.z ); + ::glEnd(); + ::glPushMatrix(); + ::glTranslatef( position.x, position.y, position.z ); + ::gluSphere( moonsphere, /* (float)( Global.iWindowHeight / Global.FieldOfView ) * 0.5 * */ ( m_body.distance / 60.2666 ) * 9.037461, 12, 12 ); + ::glPopMatrix(); +} + +glm::vec3 +cMoon::getDirection() { + + return m_position; +} + +float +cMoon::getAngle() const { + + return (float)m_body.elevref; +} + +float cMoon::getIntensity() { + + irradiance(); + // NOTE: we don't have irradiance model for the moon so we cheat here + // calculating intensity of the sun instead, and returning 15% of the value, + // which roughly matches how much sunlight is reflected by the moon + // We alter the intensity further based on current phase of the moon + auto const phasefactor = 1.0f - std::abs( m_phase - 29.53f * 0.5f ) / ( 29.53f * 0.5f ); + return static_cast( ( m_body.etr/ 1399.0 ) * phasefactor * 0.15 ); // arbitrary scaling factor taken from etrn value +} + +void cMoon::setLocation( float const Longitude, float const Latitude ) { + + // convert fraction from geographical base of 6o minutes + m_observer.longitude = (int)Longitude + (Longitude - (int)(Longitude)) * 100.0 / 60.0; + m_observer.latitude = (int)Latitude + (Latitude - (int)(Latitude)) * 100.0 / 60.0 ; +} + +// sets current time, overriding one acquired from the system clock +void cMoon::setTime( int const Hour, int const Minute, int const Second ) { + + m_observer.hour = clamp( Hour, -1, 23 ); + m_observer.minute = clamp( Minute, -1, 59 ); + m_observer.second = clamp( Second, -1, 59 ); +} + +void cMoon::setTemperature( float const Temperature ) { + + m_observer.temp = Temperature; +} + +void cMoon::setPressure( float const Pressure ) { + + m_observer.press = Pressure; +} + +void cMoon::move() { + + static double radtodeg = 57.295779513; // converts from radians to degrees + static double degtorad = 0.0174532925; // converts from degrees to radians + + SYSTEMTIME localtime = simulation::Time.data(); // time for the calculation + + if( m_observer.hour >= 0 ) { localtime.wHour = m_observer.hour; } + if( m_observer.minute >= 0 ) { localtime.wMinute = m_observer.minute; } + if( m_observer.second >= 0 ) { localtime.wSecond = m_observer.second; } + + double localut = + localtime.wHour + + localtime.wMinute / 60.0 // too low resolution, noticeable skips + + localtime.wSecond / 3600.0; // good enough in normal circumstances +/* + + localtime.wMilliseconds / 3600000.0; // for really smooth movement +*/ + double daynumber + = 367 * localtime.wYear + - 7 * ( localtime.wYear + ( localtime.wMonth + 9 ) / 12 ) / 4 + + 275 * localtime.wMonth / 9 + + localtime.wDay + - 730530 + + ( localut / 24.0 ); + + // Universal Coordinated (Greenwich standard) time + m_observer.utime = localut - m_observer.timezone; + + // obliquity of the ecliptic + m_body.oblecl = clamp_circular( 23.4393 - 3.563e-7 * daynumber ); + // moon parameters + double longascnode = clamp_circular( 125.1228 - 0.0529538083 * daynumber ); // N, degrees + double const inclination = 5.1454; // i, degrees + double const mndistance = 60.2666; // a, in earth radii + // argument of perigee + double const perigeearg = clamp_circular( 318.0634 + 0.1643573223 * daynumber ); // w, degrees + // mean anomaly + m_body.mnanom = clamp_circular( 115.3654 + 13.0649929509 * daynumber ); // M, degrees + // eccentricity + double const e = 0.054900; + // eccentric anomaly + double E0 = m_body.mnanom + radtodeg * e * std::sin( degtorad * m_body.mnanom ) * ( 1.0 + e * std::cos( degtorad * m_body.mnanom ) ); + double E1 = E0 - ( E0 - radtodeg * e * std::sin( degtorad * E0 ) - m_body.mnanom ) / ( 1.0 - e * std::cos( degtorad * E0 ) ); + while( std::abs( E0 - E1 ) > 0.005 ) { // arbitrary precision tolerance threshold + E0 = E1; + E1 = E0 - ( E0 - radtodeg * e * std::sin( degtorad * E0 ) - m_body.mnanom ) / ( 1.0 - e * std::cos( degtorad * E0 ) ); + } + double const E = E1; + // lunar orbit plane rectangular coordinates + double const xv = mndistance * ( std::cos( degtorad * E ) - e ); + double const yv = mndistance * std::sin( degtorad * E ) * std::sqrt( 1.0 - e*e ); + // distance + m_body.distance = std::sqrt( xv*xv + yv*yv ); // r + // true anomaly + m_body.tranom = clamp_circular( radtodeg * std::atan2( yv, xv ) ); // v + // ecliptic rectangular coordinates + double const vpluswinrad = degtorad * ( m_body.tranom + perigeearg ); + double const xeclip = m_body.distance * ( std::cos( degtorad * longascnode ) * std::cos( vpluswinrad ) - std::sin( degtorad * longascnode ) * std::sin( vpluswinrad ) * std::cos( degtorad * inclination ) ); + double const yeclip = m_body.distance * ( std::sin( degtorad * longascnode ) * std::cos( vpluswinrad ) + std::cos( degtorad * longascnode ) * std::sin( vpluswinrad ) * std::cos( degtorad * inclination ) ); + double const zeclip = m_body.distance * std::sin( vpluswinrad ) * std::sin( degtorad * inclination ); + // ecliptic coordinates + double ecliplat = radtodeg * std::atan2( zeclip, std::sqrt( xeclip*xeclip + yeclip*yeclip ) ); + m_body.eclong = clamp_circular( radtodeg * std::atan2( yeclip, xeclip ) ); + // distance + m_body.distance = std::sqrt( xeclip*xeclip + yeclip*yeclip + zeclip*zeclip ); + // perturbations + // NOTE: perturbation calculation can be safely disabled if we don't mind error of 1-2 degrees + // Sun's mean anomaly: Ms (already computed) + double const sunmnanom = clamp_circular( 356.0470 + 0.9856002585 * daynumber ); // M + // Sun's mean longitude: Ls (already computed) + double const sunphlong = clamp_circular( 282.9404 + 4.70935e-5 * daynumber ); + double const sunmnlong = clamp_circular( sunphlong + sunmnanom ); // L = w + M + // Moon's mean anomaly: Mm (already computed) + // Moon's mean longitude: Lm = N + w + M (for the Moon) + m_body.mnlong = clamp_circular( longascnode + perigeearg + m_body.mnanom ); + // Moon's mean elongation: D = Lm - Ls + double const mnelong = clamp_circular( m_body.mnlong - sunmnlong ); + // Moon's argument of latitude: F = Lm - N + double const arglat = clamp_circular( m_body.mnlong - longascnode ); + // longitude perturbations + double const pertevection = -1.274 * std::sin( degtorad * ( m_body.mnanom - 2.0 * mnelong ) ); // Evection + double const pertvariation = +0.658 * std::sin( degtorad * ( 2.0 * mnelong ) ); // Variation + double const pertyearlyeqt = -0.186 * std::sin( degtorad * sunmnanom ); // Yearly equation + // latitude perturbations + double const pertlat = -0.173 * std::sin( degtorad * ( arglat - 2.0 * mnelong ) ); + + m_body.eclong += pertevection + pertvariation + pertyearlyeqt; + ecliplat += pertlat; + // declination + m_body.declin = radtodeg * std::asin( std::sin (m_body.oblecl * degtorad) * std::sin(m_body.eclong * degtorad) ); + + // right ascension + double top = std::cos( degtorad * m_body.oblecl ) * std::sin( degtorad * m_body.eclong ); + double bottom = std::cos( degtorad * m_body.eclong ); + m_body.rascen = clamp_circular( radtodeg * std::atan2( top, bottom ) ); + + // Greenwich mean sidereal time + m_observer.gmst = 6.697375 + 0.0657098242 * daynumber + m_observer.utime; + + m_observer.gmst -= 24.0 * (int)( m_observer.gmst / 24.0 ); + if( m_observer.gmst < 0.0 ) m_observer.gmst += 24.0; + + // local mean sidereal time + m_observer.lmst = m_observer.gmst * 15.0 + m_observer.longitude; + + m_observer.lmst -= 360.0 * (int)( m_observer.lmst / 360.0 ); + if( m_observer.lmst < 0.0 ) m_observer.lmst += 360.0; + + // hour angle + m_body.hrang = m_observer.lmst - m_body.rascen; + + if( m_body.hrang < -180.0 ) m_body.hrang += 360.0; // (force it between -180 and 180 degrees) + else if( m_body.hrang > 180.0 ) m_body.hrang -= 360.0; + + double cz; // cosine of the solar zenith angle + + double tdatcd = std::cos( degtorad * m_body.declin ); + double tdatch = std::cos( degtorad * m_body.hrang ); + double tdatcl = std::cos( degtorad * m_observer.latitude ); + double tdatsd = std::sin( degtorad * m_body.declin ); + double tdatsl = std::sin( degtorad * m_observer.latitude ); + + cz = tdatsd * tdatsl + tdatcd * tdatcl * tdatch; + + // (watch out for the roundoff errors) + if( fabs (cz) > 1.0 ) { cz >= 0.0 ? cz = 1.0 : cz = -1.0; } + + m_body.zenetr = std::acos( cz ) * radtodeg; + m_body.elevetr = 90.0 - m_body.zenetr; + refract(); +} + +void cMoon::refract() { + + static double degtorad = 0.0174532925; // converts from degrees to radians + + double prestemp; // temporary pressure/temperature correction + double refcor; // temporary refraction correction + double tanelev; // tangent of the solar elevation angle + + // if the sun is near zenith, the algorithm bombs; refraction near 0. + if( m_body.elevetr > 85.0 ) + refcor = 0.0; + else { + + tanelev = tan( degtorad * m_body.elevetr ); + if( m_body.elevetr >= 5.0 ) + refcor = 58.1 / tanelev + - 0.07 / pow( tanelev, 3 ) + + 0.000086 / pow( tanelev, 5 ); + else if( m_body.elevetr >= -0.575 ) + refcor = 1735.0 + + m_body.elevetr * ( -518.2 + m_body.elevetr * + ( 103.4 + m_body.elevetr * ( -12.79 + m_body.elevetr * 0.711 ) ) ); + else + refcor = -20.774 / tanelev; + + prestemp = ( m_observer.press * 283.0 ) / ( 1013.0 * ( 273.0 + m_observer.temp ) ); + refcor *= prestemp / 3600.0; + } + + // refracted solar elevation angle + m_body.elevref = m_body.elevetr + refcor; + + // refracted solar zenith angle + m_body.zenref = 90.0 - m_body.elevref; +} + +void cMoon::irradiance() { + + static double radtodeg = 57.295779513; // converts from radians to degrees + static double degtorad = 0.0174532925; // converts from degrees to radians + + m_body.dayang = ( simulation::Time.year_day() - 1 ) * 360.0 / 365.0; + double sd = sin( degtorad * m_body.dayang ); // sine of the day angle + double cd = cos( degtorad * m_body.dayang ); // cosine of the day angle or delination + m_body.erv = 1.000110 + 0.034221*cd + 0.001280*sd; + double d2 = 2.0 * m_body.dayang; + double c2 = cos( degtorad * d2 ); + double s2 = sin( degtorad * d2 ); + m_body.erv += 0.000719*c2 + 0.000077*s2; + + double solcon = 1367.0; // Solar constant, 1367 W/sq m + + m_body.coszen = cos( degtorad * m_body.zenref ); + if( m_body.coszen > 0.0 ) { + m_body.etrn = solcon * m_body.erv; + m_body.etr = m_body.etrn * m_body.coszen; + } + else { + m_body.etrn = 0.0; + m_body.etr = 0.0; + } +} + +void +cMoon::phase() { + + // calculate moon's age in days from new moon + float ip = normalize( ( simulation::Time.julian_day() - 2451550.1f ) / 29.530588853f ); + m_phase = ip * 29.53f; +} + +// normalize values to range 0...1 +float +cMoon::normalize( const float Value ) const { + + float value = Value - floor( Value ); + if( value < 0.f ) { ++value; } + + return value; +} diff --git a/moon.h b/moon.h new file mode 100644 index 00000000..eb59a1a7 --- /dev/null +++ b/moon.h @@ -0,0 +1,103 @@ +#pragma once + +#include "windows.h" +#include "GL/glew.h" +#include "GL/wglew.h" + + +// TODO: sun and moon share code as celestial bodies, we could make a base class out of it + +class cMoon { + +public: +// types: + +// methods: + void init(); + void update(); + void render(); + // returns vector pointing at the sun + glm::vec3 getDirection(); + // returns current elevation above horizon + float getAngle() const; + // returns current intensity of the sun + float getIntensity(); + // returns current phase of the moon + float getPhase() const { return m_phase; } + // sets current time, overriding one acquired from the system clock + void setTime( int const Hour, int const Minute, int const Second ); + // sets current geographic location + void setLocation( float const Longitude, float const Latitude ); + // sets ambient temperature in degrees C. + void setTemperature( float const Temperature ); + // sets surface pressure in milibars + void setPressure( float const Pressure ); + +// constructors: + cMoon(); + +// deconstructor: + ~cMoon(); + +// members: + +protected: +// types: + +// methods: + // calculates sun position on the sky given specified time and location + void move(); + // calculates position adjustment due to refraction + void refract(); + // calculates light intensity at current moment + void irradiance(); + void phase(); + // helper, normalize values to range 0...1 + float normalize( const float Value ) const; + +// members: + GLUquadricObj *moonsphere; // temporary handler for moon positioning test + + struct celestialbody { // main planet parameters + + double dayang; // day angle (daynum*360/year-length) degrees + double phlong; // longitude of perihelion + double mnlong; // mean longitude, degrees + double mnanom; // mean anomaly, degrees + double tranom; // true anomaly, degrees + double eclong; // ecliptic longitude, degrees. + double oblecl; // obliquity of ecliptic. + double declin; // declination--zenith angle of solar noon at equator, degrees NORTH. + double rascen; // right ascension, degrees + double hrang; // hour angle--hour of sun from solar noon, degrees WEST + double zenetr; // solar zenith angle, no atmospheric correction (= ETR) + double zenref; // solar zenith angle, deg. from zenith, refracted + double coszen; // cosine of refraction corrected solar zenith angle + double elevetr; // solar elevation, no atmospheric correction (= ETR) + double elevref; // solar elevation angle, deg. from horizon, refracted. + double distance; // distance from earth in AUs + double erv; // earth radius vector (multiplied to solar constant) + double etr; // extraterrestrial (top-of-atmosphere) W/sq m global horizontal solar irradiance + double etrn; // extraterrestrial (top-of-atmosphere) W/sq m direct normal solar irradiance + }; + + struct observer { // weather, time and position data in observer's location + + double latitude; // latitude, degrees north (south negative) + double longitude; // longitude, degrees east (west negative) + int hour{ -1 }; // current time, used for calculation of utime. if set to -1, time for + int minute{ -1 };// calculation will be obtained from the local clock + int second{ -1 }; + double utime; // universal (Greenwich) standard time + double timezone; // time zone, east (west negative). USA: Mountain = -7, Central = -6, etc. + double gmst; // Greenwich mean sidereal time, hours + double lmst; // local mean sidereal time, degrees + double temp; // ambient dry-bulb temperature, degrees C, used for refraction correction + double press; // surface pressure, millibars, used for refraction correction and ampress + }; + + celestialbody m_body; + observer m_observer; + glm::vec3 m_position; + float m_phase; +}; diff --git a/mtable.cpp b/mtable.cpp index 877271b8..81cfd90b 100644 --- a/mtable.cpp +++ b/mtable.cpp @@ -1,7 +1,3 @@ -/** @file - @brief -*/ - /* This Source Code Form is subject to the terms of the Mozilla Public License, v. @@ -13,30 +9,10 @@ http://mozilla.org/MPL/2.0/. #include "stdafx.h" #include "mtable.h" -#include "mczapkie/mctools.h" -// using namespace Mtable; -std::shared_ptr Mtable::GlobalTime; - -double CompareTime(double t1h, double t1m, double t2h, double t2m) /*roznica czasu w minutach*/ -// zwraca różnicę czasu -// jeśli pierwsza jest aktualna, a druga rozkładowa, to ujemna oznacza opóżnienie -// na dłuższą metę trzeba uwzględnić datę, jakby opóżnienia miały przekraczać 12h (towarowych) -{ - double t; - - if ((t2h < 0)) - return 0; - else - { - t = (t2h - t1h) * 60 + t2m - t1m; // jeśli t2=00:05, a t1=23:50, to różnica wyjdzie ujemna - if ((t < -720)) // jeśli różnica przekracza 12h na minus - t = t + 1440; // to dodanie doby minut;else - if ((t > 720)) // jeśli przekracza 12h na plus - t = t - 1440; // to odjęcie doby minut - return t; - } -} +#include "globals.h" +#include "simulationtime.h" +#include "utilities.h" double TTrainParameters::CheckTrainLatency() { @@ -57,7 +33,7 @@ double TTrainParameters::WatchMTable(double DistCounter) return dist; } -std::string TTrainParameters::NextStop() +std::string TTrainParameters::NextStop() const { // pobranie nazwy następnego miejsca zatrzymania if (StationIndex <= StationCount) return NextStationName; // nazwa następnego przystanku; @@ -65,7 +41,7 @@ std::string TTrainParameters::NextStop() return "[End of route]"; //że niby koniec } -bool TTrainParameters::IsStop() +bool TTrainParameters::IsStop() const { // zapytanie, czy zatrzymywać na następnym punkcie rozkładu if ((StationIndex < StationCount)) return TimeTable[StationIndex].Ah >= 0; //-1 to brak postoju @@ -73,7 +49,12 @@ bool TTrainParameters::IsStop() return true; // na ostatnim się zatrzymać zawsze } -bool TTrainParameters::UpdateMTable(double hh, double mm, std::string NewName) +bool TTrainParameters::UpdateMTable( scenario_time const &Time, std::string const &NewName ) { + + return UpdateMTable( Time.data().wHour, Time.data().wMinute, NewName ); +} + +bool TTrainParameters::UpdateMTable(double hh, double mm, std::string const &NewName) /*odfajkowanie dojechania do stacji (NewName) i przeliczenie opóźnienia*/ { bool OK; @@ -82,8 +63,7 @@ bool TTrainParameters::UpdateMTable(double hh, double mm, std::string NewName) { if (NewName == NextStationName) // jeśli dojechane do następnego { // Ra: wywołanie może być powtarzane, jak stoi na W4 - if (TimeTable[StationIndex + 1].km - TimeTable[StationIndex].km < - 0) // to jest bez sensu + if (TimeTable[StationIndex + 1].km - TimeTable[StationIndex].km < 0) // to jest bez sensu Direction = -1; else Direction = 1; // prowizorka bo moze byc zmiana kilometrazu @@ -91,21 +71,42 @@ bool TTrainParameters::UpdateMTable(double hh, double mm, std::string NewName) LastStationLatency = CompareTime(hh, mm, TimeTable[StationIndex].Dh, TimeTable[StationIndex].Dm); // inc(StationIndex); //przejście do następnej pozycji StationIndex<=StationCount - if (StationIndex < - StationCount) // Ra: "<", bo dodaje 1 przy przejściu do następnej stacji - { // jeśli nie ostatnia stacja + // Ra: "<", bo dodaje 1 przy przejściu do następnej stacji + if (StationIndex < StationCount) { + // jeśli nie ostatnia stacja NextStationName = TimeTable[StationIndex + 1].StationName; // zapamiętanie nazwy - TTVmax = TimeTable[StationIndex + 1] - .vmax; // Ra: nowa prędkość rozkładowa na kolejnym odcinku + // Ra: nowa prędkość rozkładowa na kolejnym odcinku + TTVmax = TimeTable[StationIndex + 1].vmax; + } + else { + // gdy ostatnia stacja, nie ma następnej stacji + NextStationName = ""; } - else // gdy ostatnia stacja - NextStationName = ""; // nie ma następnej stacji OK = true; } } return OK; /*czy jest nastepna stacja*/ } +bool Mtable::TTrainParameters::RewindTimeTable(std::string actualStationName) { + + if( actualStationName.compare( 0, 19, "PassengerStopPoint:" ) == 0 ) { + actualStationName = ToLower( actualStationName.substr( 19 ) ); + } + for( auto i = 1; i <= StationCount; ++i ) { + // przechodzimy po całej tabelce i sprawdzamy nazwy stacji (bez pierwszej) + if (ToLower(TimeTable[i].StationName) == actualStationName) { + // nazwa stacji zgodna więc ustawiamy na poprzednią, żeby w następnym kroku poprawnie obsłużyć + StationIndex = i; + NextStationName = TimeTable[ i ].StationName; + TTVmax = TimeTable[ i ].vmax; + return true; // znaleźliśmy więc kończymy + } + } + // failed to find a match + return false; +} + void TTrainParameters::StationIndexInc() { // przejście do następnej pozycji StationIndex<=StationCount ++StationIndex; @@ -128,7 +129,7 @@ bool TTrainParameters::IsTimeToGo(double hh, double mm) return false; // dalej nie jechać } -std::string TTrainParameters::ShowRelation() +std::string TTrainParameters::ShowRelation() const /*zwraca informację o relacji*/ { // if (Relation1=TimeTable[1].StationName) and (Relation2=TimeTable[StationCount].StationName) @@ -138,13 +139,13 @@ std::string TTrainParameters::ShowRelation() return ""; } -TTrainParameters::TTrainParameters(std::string NewTrainName) +TTrainParameters::TTrainParameters(std::string const &NewTrainName) /*wstępne ustawienie parametrów rozkładu jazdy*/ { NewName(NewTrainName); } -void TTrainParameters::NewName(std::string NewTrainName) +void TTrainParameters::NewName(std::string const &NewTrainName) /*wstępne ustawienie parametrów rozkładu jazdy*/ { TrainName = NewTrainName; @@ -157,18 +158,7 @@ void TTrainParameters::NewName(std::string NewTrainName) Relation2 = ""; for (int i = 0; i < MaxTTableSize + 1; ++i) { - TMTableLine *t = &TimeTable[i]; - t->km = 0; - t->vmax = -1; - t->StationName = "nowhere"; - t->StationWare = ""; - t->TrackNo = 1; - t->Ah = -1; - t->Am = -1; - t->Dh = -1; - t->Dm = -1; - t->tm = 0; - t->WaitTime = 0; + TimeTable[ i ] = TMTableLine(); } TTVmax = 100; /*wykasowac*/ BrakeRatio = 0; @@ -202,8 +192,6 @@ bool TTrainParameters::LoadTTfile(std::string scnpath, int iPlus, double vmax) std::ifstream fin; bool EndTable; double vActual; - int i; - int time; // do zwiększania czasu int ConversionError = 0; EndTable = false; @@ -368,15 +356,12 @@ bool TTrainParameters::LoadTTfile(std::string scnpath, int iPlus, double vmax) { if (s.find(hrsd) != std::string::npos) { - record->Ah = atoi( - s.substr(0, s.find(hrsd)).c_str()); // godzina przyjazdu - record->Am = atoi(s.substr(s.find(hrsd) + 1, s.length()) - .c_str()); // minuta przyjazdu + record->Ah = atoi( s.substr(0, s.find(hrsd)).c_str()); // godzina przyjazdu + record->Am = atoi(s.substr(s.find(hrsd) + 1, s.length()).c_str()); // minuta przyjazdu } else { - record->Ah = TimeTable[StationCount - 1] - .Ah; // godzina z poprzedniej pozycji + record->Ah = TimeTable[StationCount - 1].Ah; // godzina z poprzedniej pozycji record->Am = atoi(s.c_str()); // bo tylko minuty podane } } @@ -421,29 +406,20 @@ bool TTrainParameters::LoadTTfile(std::string scnpath, int iPlus, double vmax) { if (s.find(hrsd) != std::string::npos) { - record->Dh = - atoi(s.substr(0, s.find(hrsd)).c_str()); // godzina odjazdu - record->Dm = atoi(s.substr(s.find(hrsd) + 1, s.length()) - .c_str()); // minuta odjazdu + record->Dh = atoi(s.substr(0, s.find(hrsd)).c_str()); // godzina odjazdu + record->Dm = atoi(s.substr(s.find(hrsd) + 1, s.length()).c_str()); // minuta odjazdu } else { - record->Dh = TimeTable[StationCount - 1] - .Dh; // godzina z poprzedniej pozycji + record->Dh = TimeTable[StationCount - 1].Dh; // godzina z poprzedniej pozycji record->Dm = atoi(s.c_str()); // bo tylko minuty podane } } else { - record->Dh = record->Ah; // odjazd o tej samej, co przyjazd (dla - // ostatniego też) - record->Dm = record->Am; // bo są używane do wyliczenia opóźnienia - // po dojechaniu + record->Dh = record->Ah; // odjazd o tej samej, co przyjazd (dla ostatniego też) + record->Dm = record->Am; // bo są używane do wyliczenia opóźnienia po dojechaniu } - if ((record->Ah >= 0)) - record->WaitTime = (int)(CompareTime(record->Ah, record->Am, - record->Dh, record->Dm) + - 0.1); do { fin >> s; @@ -494,55 +470,56 @@ bool TTrainParameters::LoadTTfile(std::string scnpath, int iPlus, double vmax) // NextStationName:=TimeTable[1].StationName; /* TTVmax:=TimeTable[1].vmax; */ } - if ((iPlus != 0)) // jeżeli jest przesunięcie rozkładu + auto const timeoffset { static_cast( Global.ScenarioTimeOffset * 60 ) + iPlus }; + if( timeoffset != 0 ) // jeżeli jest przesunięcie rozkładu { long i_end = StationCount + 1; - for (i = 1; i < i_end; ++i) // bez with, bo ciężko się przenosi na C++ + int adjustedtime; // do zwiększania czasu + for (auto i = 1; i < i_end; ++i) // bez with, bo ciężko się przenosi na C++ { if ((TimeTable[i].Ah >= 0)) { - time = iPlus + TimeTable[i].Ah * 60 + TimeTable[i].Am; // nowe minuty - TimeTable[i].Am = time % 60; - TimeTable[i].Ah = (time /*div*/ / 60) % 60; + adjustedtime = clamp_circular( TimeTable[i].Ah * 60 + TimeTable[i].Am + timeoffset, 24 * 60 ); // nowe minuty + TimeTable[i].Am = adjustedtime % 60; + TimeTable[i].Ah = (adjustedtime / 60) % 24; } if ((TimeTable[i].Dh >= 0)) { - time = iPlus + TimeTable[i].Dh * 60 + TimeTable[i].Dm; // nowe minuty - TimeTable[i].Dm = time % 60; - TimeTable[i].Dh = (time /*div*/ / 60) % 60; + adjustedtime = clamp_circular( TimeTable[i].Dh * 60 + TimeTable[i].Dm + timeoffset, 24 * 60 ); // nowe minuty + TimeTable[i].Dm = adjustedtime % 60; + TimeTable[i].Dh = (adjustedtime / 60) % 24; } } } - return !(bool)ConversionError; + return ConversionError == 0; } void TMTableTime::UpdateMTableTime(double deltaT) // dodanie czasu (deltaT) w sekundach, z przeliczeniem godziny { - mr = mr + deltaT; // dodawanie sekund - while (mr > 60.0) // przeliczenie sekund do właściwego przedziału + mr += deltaT; // dodawanie sekund + while (mr >= 60.0) // przeliczenie sekund do właściwego przedziału { - mr = mr - 60.0; + mr -= 60.0; ++mm; } while (mm > 59) // przeliczenie minut do właściwego przedziału { - mm = mm - 60; + mm -= 60; ++hh; } while (hh > 23) // przeliczenie godzin do właściwego przedziału { - hh = hh - 24; + hh -= 24; ++dd; // zwiększenie numeru dnia } - GameTime = GameTime + deltaT; } bool TTrainParameters::DirectionChange() // sprawdzenie, czy po zatrzymaniu wykonać kolejne komendy { if ((StationIndex > 0) && (StationIndex < StationCount)) // dla ostatniej stacji nie - if (TimeTable[StationIndex].StationWare.find("@") != std::string::npos) + if (TimeTable[StationIndex].StationWare.find('@') != std::string::npos) return true; return false; } diff --git a/mtable.h b/mtable.h index 3bc10f3f..f079790c 100644 --- a/mtable.h +++ b/mtable.h @@ -11,6 +11,8 @@ http://mozilla.org/MPL/2.0/. #include +#include "classes.h" + namespace Mtable { @@ -34,15 +36,14 @@ struct TMTableLine int Dh; int Dm; // godz. i min. odjazdu double tm; // czas jazdy do tej stacji w min. (z kolumny) - int WaitTime; // czas postoju (liczony plus 6 sekund) TMTableLine() { km = 0; vmax = -1; StationName = "nowhere", StationWare = ""; TrackNo = 1; - Ah, Am, Dh, Dm = -1; - WaitTime, tm = 0; + Ah = Am = Dh = Dm = -1; + tm = 0; } }; @@ -68,14 +69,16 @@ class TTrainParameters int Direction; /*kierunek jazdy w/g kilometrazu*/ double CheckTrainLatency(); /*todo: str hh:mm to int i z powrotem*/ - std::string ShowRelation(); + std::string ShowRelation() const; double WatchMTable(double DistCounter); - std::string NextStop(); - bool IsStop(); + std::string NextStop() const; + bool IsStop() const; bool IsTimeToGo(double hh, double mm); - bool UpdateMTable(double hh, double mm, std::string NewName); - TTrainParameters(std::string NewTrainName); - void NewName(std::string NewTrainName); + bool UpdateMTable(double hh, double mm, std::string const &NewName); + bool UpdateMTable( scenario_time const &Time, std::string const &NewName ); + bool RewindTimeTable( std::string actualStationName ); + TTrainParameters( std::string const &NewTrainName ); + void NewName(std::string const &NewTrainName); void UpdateVelocity(int StationCount, double vActual); bool LoadTTfile(std::string scnpath, int iPlus, double vmax); bool DirectionChange(); @@ -86,29 +89,19 @@ class TMTableTime { public: - double GameTime = 0.0; int dd = 0; int hh = 0; int mm = 0; - int srh = 0; - int srm = 0; /*wschod slonca*/ - int ssh = 0; - int ssm = 0; /*zachod slonca*/ double mr = 0.0; void UpdateMTableTime(double deltaT); - TMTableTime(int InitH, int InitM, int InitSRH, int InitSRM, int InitSSH, int InitSSM) : - hh( InitH ), - mm( InitM ), - srh( InitSRH ), - srm( InitSRM ), - ssh( InitSSH ), - ssm( InitSSM ) + TMTableTime(int InitH, int InitM ) : + hh( InitH ), + mm( InitM ) {} TMTableTime() = default; }; -extern std::shared_ptr GlobalTime; } #if !defined(NO_IMPLICIT_NAMESPACE_USE) diff --git a/AdvSound.cpp b/old/AdvSound.cpp similarity index 92% rename from AdvSound.cpp rename to old/AdvSound.cpp index 63149449..94870c95 100644 --- a/AdvSound.cpp +++ b/old/AdvSound.cpp @@ -19,12 +19,7 @@ TAdvancedSound::~TAdvancedSound() // SoundShut.Stop(); } -void TAdvancedSound::Free() -{ -} - -void TAdvancedSound::Init( std::string const &NameOn, std::string const &Name, std::string const &NameOff, double DistanceAttenuation, - vector3 const &pPosition) +void TAdvancedSound::Init( std::string const &NameOn, std::string const &Name, std::string const &NameOff, double DistanceAttenuation, Math3D::vector3 const &pPosition) { SoundStart.Init(NameOn, DistanceAttenuation, pPosition.x, pPosition.y, pPosition.z, true); SoundCommencing.Init(Name, DistanceAttenuation, pPosition.x, pPosition.y, pPosition.z, true); @@ -47,7 +42,7 @@ void TAdvancedSound::Init( std::string const &NameOn, std::string const &Name, s SoundShut.FA = 0.0; } -void TAdvancedSound::Load(cParser &Parser, vector3 const &pPosition) +void TAdvancedSound::Load(cParser &Parser, Math3D::vector3 const &pPosition) { std::string nameon, name, nameoff; double attenuation; @@ -62,7 +57,7 @@ void TAdvancedSound::Load(cParser &Parser, vector3 const &pPosition) Init( nameon, name, nameoff, attenuation, pPosition ); } -void TAdvancedSound::TurnOn(bool ListenerInside, vector3 NewPosition) +void TAdvancedSound::TurnOn(bool ListenerInside, Math3D::vector3 NewPosition) { // hunter-311211: nie trzeba czekac na ponowne odtworzenie dzwieku, az sie wylaczy if ((State == ss_Off || State == ss_ShuttingDown) && (SoundStart.AM > 0)) @@ -76,7 +71,7 @@ void TAdvancedSound::TurnOn(bool ListenerInside, vector3 NewPosition) } } -void TAdvancedSound::TurnOff(bool ListenerInside, vector3 NewPosition) +void TAdvancedSound::TurnOff(bool ListenerInside, Math3D::vector3 NewPosition) { if ((State == ss_Commencing || State == ss_Starting) && (SoundShut.AM > 0)) { @@ -90,7 +85,7 @@ void TAdvancedSound::TurnOff(bool ListenerInside, vector3 NewPosition) } } -void TAdvancedSound::Update(bool ListenerInside, vector3 NewPosition) +void TAdvancedSound::Update(bool ListenerInside, Math3D::vector3 NewPosition) { if ((State == ss_Commencing) && (SoundCommencing.AM > 0)) { @@ -126,8 +121,12 @@ void TAdvancedSound::Update(bool ListenerInside, vector3 NewPosition) } } -void TAdvancedSound::UpdateAF(double A, double F, bool ListenerInside, vector3 NewPosition) +void TAdvancedSound::UpdateAF(double A, double F, bool ListenerInside, Math3D::vector3 NewPosition) { // update, ale z amplituda i czestotliwoscia + if( State == ss_Off ) { + return; + } + if ((State == ss_Commencing) && (SoundCommencing.AM > 0)) { SoundShut.Stop(); // hunter-311211 diff --git a/AdvSound.h b/old/AdvSound.h similarity index 67% rename from AdvSound.h rename to old/AdvSound.h index 1049e750..f5c4de40 100644 --- a/AdvSound.h +++ b/old/AdvSound.h @@ -13,13 +13,13 @@ http://mozilla.org/MPL/2.0/. #include "RealSound.h" #include "parser.h" -typedef enum -{ +enum TSoundState { + ss_Off, ss_Starting, ss_Commencing, ss_ShuttingDown -} TSoundState; +}; class TAdvancedSound { // klasa dźwięków mających początek, dowolnie długi środek oraz zakończenie (np. Rp1) @@ -36,13 +36,12 @@ class TAdvancedSound public: TAdvancedSound() = default; ~TAdvancedSound(); - void Init( std::string const &NameOn, std::string const &Name, std::string const &NameOff, double DistanceAttenuation, vector3 const &pPosition); - void Load(cParser &Parser, vector3 const &pPosition); - void TurnOn(bool ListenerInside, vector3 NewPosition); - void TurnOff(bool ListenerInside, vector3 NewPosition); - void Free(); - void Update(bool ListenerInside, vector3 NewPosition); - void UpdateAF(double A, double F, bool ListenerInside, vector3 NewPosition); + void Init( std::string const &NameOn, std::string const &Name, std::string const &NameOff, double DistanceAttenuation, Math3D::vector3 const &pPosition); + void Load(cParser &Parser, Math3D::vector3 const &pPosition); + void TurnOn(bool ListenerInside, Math3D::vector3 NewPosition); + void TurnOff(bool ListenerInside, Math3D::vector3 NewPosition); + void Update(bool ListenerInside, Math3D::vector3 NewPosition); + void UpdateAF(double A, double F, bool ListenerInside, Math3D::vector3 NewPosition); void CopyIfEmpty(TAdvancedSound &s); }; diff --git a/Classes.cpp b/old/Classes.cpp similarity index 100% rename from Classes.cpp rename to old/Classes.cpp diff --git a/Data.h b/old/Data.h similarity index 100% rename from Data.h rename to old/Data.h diff --git a/FadeSound.cpp b/old/FadeSound.cpp similarity index 96% rename from FadeSound.cpp rename to old/FadeSound.cpp index c45d0176..fff7273f 100644 --- a/FadeSound.cpp +++ b/old/FadeSound.cpp @@ -25,7 +25,7 @@ void TFadeSound::Free() { } -void TFadeSound::Init(char *Name, float fNewFade) +void TFadeSound::Init(std::string const &Name, float fNewFade) { Sound = TSoundsManager::GetFromName(Name, false); if (Sound) diff --git a/FadeSound.h b/old/FadeSound.h similarity index 88% rename from FadeSound.h rename to old/FadeSound.h index 4c93054c..97c45eb0 100644 --- a/FadeSound.h +++ b/old/FadeSound.h @@ -21,10 +21,10 @@ class TFadeSound fTime = 0.0f; TSoundState State = ss_Off; - public: - TFadeSound(); +public: + TFadeSound() = default; ~TFadeSound(); - void Init(char *Name, float fNewFade); + void Init(std::string const &Name, float fNewFade); void TurnOn(); void TurnOff(); bool Playing() diff --git a/Forth.cpp b/old/Forth.cpp similarity index 100% rename from Forth.cpp rename to old/Forth.cpp diff --git a/Forth.h b/old/Forth.h similarity index 100% rename from Forth.h rename to old/Forth.h diff --git a/Geom.cpp b/old/Geom.cpp similarity index 99% rename from Geom.cpp rename to old/Geom.cpp index 9b2d7b02..6f43ea7f 100644 --- a/Geom.cpp +++ b/old/Geom.cpp @@ -11,7 +11,7 @@ http://mozilla.org/MPL/2.0/. #include "classes.hpp" #include #include -#include "opengl/glut.h" +#include "GL/glut.h" #pragma hdrstop #include "Texture.h" diff --git a/Geom.h b/old/Geom.h similarity index 100% rename from Geom.h rename to old/Geom.h diff --git a/old/Ground.cpp b/old/Ground.cpp new file mode 100644 index 00000000..b457259f --- /dev/null +++ b/old/Ground.cpp @@ -0,0 +1,4015 @@ +/* +This Source Code Form is subject to the +terms of the Mozilla Public License, v. +2.0. If a copy of the MPL was not +distributed with this file, You can +obtain one at +http://mozilla.org/MPL/2.0/. +*/ + +/* + MaSzyna EU07 locomotive simulator + Copyright (C) 2001-2004 Marcin Wozniak and others + +*/ + +#include "stdafx.h" +#include "Ground.h" + +#include "Globals.h" +#include "messaging.h" +#include "Logs.h" +#include "usefull.h" +#include "Timer.h" +#include "Event.h" +#include "EvLaunch.h" +#include "TractionPower.h" +#include "Traction.h" +#include "Track.h" +#include "RealSound.h" +#include "AnimModel.h" +#include "MemCell.h" +#include "mtable.h" +#include "DynObj.h" +#include "Data.h" +#include "parser.h" //Tolaris-010603 +#include "Driver.h" +#include "uilayer.h" + +//--------------------------------------------------------------------------- + +extern "C" +{ + GLFWAPI HWND glfwGetWin32Window( GLFWwindow* window ); //m7todo: potrzebne do directsound +} + +bool bCondition; // McZapkie: do testowania warunku na event multiple + +//--------------------------------------------------------------------------- +// Obiekt renderujący siatkę jest sztucznie tworzonym obiektem pomocniczym, +// grupującym siatki obiektów dla danej tekstury. Obiektami składowymi mogą +// byc trójkąty terenu, szyny, podsypki, a także proste modele np. słupy. +// Obiekty składowe dodane są do listy TSubRect::nMeshed z listą zrobioną na +// TGroundNode::nNext3, gdzie są posortowane wg tekstury. Obiekty renderujące +// są wpisane na listę TSubRect::nRootMesh (TGroundNode::nNext2) oraz na +// odpowiednie listy renderowania, gdzie zastępują obiekty składowe (nNext3). +// Problematyczne są tory/drogi/rzeki, gdzie używane sa 2 tekstury. Dlatego +// tory są zdublowane jako TP_TRACK oraz TP_DUMMYTRACK. Jeśli tekstura jest +// tylko jedna (np. zwrotnice), nie jest używany TP_DUMMYTRACK. +//--------------------------------------------------------------------------- +TGroundNode::TGroundNode() +{ // nowy obiekt terenu - pusty + iType = GL_POINTS; + nNext = nNext2 = NULL; + iCount = 0; // wierzchołków w trójkącie + // iNumPts=0; //punktów w linii + m_material = 0; + iFlags = 0; // tryb przezroczystości nie zbadany + Pointer = NULL; // zerowanie wskaźnika kontekstowego + bVisible = false; // czy widoczny + fSquareRadius = 10000 * 10000; + fSquareMinRadius = 0; + asName = ""; + fLineThickness=1.0; //mm dla linii + nNext3 = NULL; // nie wyświetla innych +} + +TGroundNode::~TGroundNode() +{ + // if (iFlags&0x200) //czy obiekt został utworzony? + switch (iType) + { + case TP_MEMCELL: + SafeDelete(MemCell); + break; + case TP_EVLAUNCH: + SafeDelete(EvLaunch); + break; + case TP_TRACTION: + SafeDelete(hvTraction); + break; + case TP_TRACTIONPOWERSOURCE: + SafeDelete(psTractionPowerSource); + break; + case TP_TRACK: + SafeDelete(pTrack); + break; + case TP_DYNAMIC: + SafeDelete(DynamicObject); + break; + case TP_MODEL: + if (iFlags & 0x200) // czy model został utworzony? + delete Model; + Model = NULL; + break; + case TP_SOUND: + SafeDelete(tsStaticSound); + break; + case TP_TERRAIN: + { // pierwsze nNode zawiera model E3D, reszta to trójkąty + delete[] nNode; // usunięcie tablicy i pierwszego elementu + } + case TP_SUBMODEL: // dla formalności, nie wymaga usuwania + break; + case GL_LINES: + case GL_LINE_STRIP: + case GL_LINE_LOOP: + case GL_TRIANGLE_STRIP: + case GL_TRIANGLE_FAN: + case GL_TRIANGLES: + SafeDelete( Piece ); + break; + default: + break; + } +} +/* +void TGroundNode::Init(int n) +{ // utworzenie tablicy wierzchołków + bVisible = false; + iNumVerts = n; + Vertices = new TGroundVertex[iNumVerts]; +} +*/ +TGroundNode::TGroundNode( TGroundNodeType t ) : + TGroundNode() { + // utworzenie obiektu + iType = t; + switch (iType) { + // zależnie od typu + case GL_TRIANGLES: { + Piece = new piece_node; + break; + } + case TP_TRACK: { + pTrack = new TTrack( asName ); + break; + } + default: { + break; + } + } +} + +// obliczenie wektorów normalnych +void TGroundNode::InitNormals() { + + glm::dvec3 v1, v2; + glm::vec3 n1; + glm::vec2 t1; + + for( auto i = 0; i < iNumVerts; i += 3 ) { + + v1 = Piece->vertices[ i + 0 ].position - Piece->vertices[ i + 1 ].position; + v2 = Piece->vertices[ i + 1 ].position - Piece->vertices[ i + 2 ].position; + n1 = glm::normalize( glm::cross( v1, v2 ) ); + if( Piece->vertices[ i + 0 ].normal == glm::vec3() ) + Piece->vertices[ i + 0 ].normal = ( n1 ); + if( Piece->vertices[ i + 1 ].normal == glm::vec3() ) + Piece->vertices[ i + 1 ].normal = ( n1 ); + if( Piece->vertices[ i + 2 ].normal == glm::vec3() ) + Piece->vertices[ i + 2 ].normal = ( n1 ); + t1 = glm::vec2( + std::floor( Piece->vertices[ i + 0 ].texture.s ), + std::floor( Piece->vertices[ i + 0 ].texture.t ) ); + Piece->vertices[ i + 1 ].texture -= t1; + Piece->vertices[ i + 2 ].texture -= t1; + Piece->vertices[ i + 0 ].texture -= t1; + } +} + +void TGroundNode::RenderHidden() +{ // renderowanie obiektów niewidocznych + double mgn = SquareMagnitude(pCenter - Global::pCameraPosition); + switch (iType) + { + case TP_SOUND: // McZapkie - dzwiek zapetlony w zaleznosci od odleglosci + if ((tsStaticSound->GetStatus() & DSBSTATUS_PLAYING) == DSBPLAY_LOOPING) + { + tsStaticSound->Play(1, DSBPLAY_LOOPING, true, tsStaticSound->vSoundPosition); + tsStaticSound->AdjFreq(1.0, Timer::GetDeltaTime()); + } + return; + case TP_EVLAUNCH: + if (EvLaunch->check_conditions()) + if ((EvLaunch->dRadius < 0) || (mgn < EvLaunch->dRadius)) + { + WriteLog("Eventlauncher " + asName); + if (Global::shiftState && (EvLaunch->Event2)) + Global::AddToQuery(EvLaunch->Event2, NULL); + else if (EvLaunch->Event1) + Global::AddToQuery(EvLaunch->Event1, NULL); + } + return; + } +}; + +//------------------------------------------------------------------------------ +//------------------ Podstawowy pojemnik terenu - sektor ----------------------- +//------------------------------------------------------------------------------ +TSubRect::~TSubRect() +{ + // TODO: usunąć obiekty z listy (nRootMesh), bo są one tworzone dla sektora + delete[] tTracks; +} + +void TSubRect::NodeAdd(TGroundNode *Node) +{ // przyczepienie obiektu do sektora, wstępna kwalifikacja na listy renderowania + if (!this) + return; // zabezpiecznie przed obiektami przekraczającymi obszar roboczy + // Ra: sortowanie obiektów na listy renderowania: + // nRenderHidden - lista obiektów niewidocznych, "renderowanych" również z tyłu + // nRenderRect - lista grup renderowanych z sektora + // nRenderRectAlpha - lista grup renderowanych z sektora z przezroczystością + // nRender - lista grup renderowanych z własnych VBO albo DL + // nRenderAlpha - lista grup renderowanych z własnych VBO albo DL z przezroczystością + // nRenderWires - lista grup renderowanych z własnych VBO albo DL - druty i linie + + Node->m_rootposition = m_area.center; + + // since ground rectangle can be empty, we're doing lazy initialization of the geometry bank, when something may actually use it + // NOTE: this method is called for both subcell and cell, but subcells get first created and passed the handle from their parent + // thus, this effectively only gets executed for the 'parent' ground cells. Not the most elegant, but for now it'll do + if( m_geometrybank == null_handle ) { + m_geometrybank = GfxRenderer.Create_Bank(); + } + + switch (Node->iType) + { + case TP_SOUND: // te obiekty są sprawdzanie niezależnie od kierunku patrzenia + case TP_EVLAUNCH: + Node->nNext3 = nRenderHidden; + nRenderHidden = Node; // do listy koniecznych + break; + case TP_TRACK: // TODO: tory z cieniem (tunel, canyon) też dać bez łączenia? + ++iTracks; // jeden tor więcej +#ifdef EU07_USE_OLD_GROUNDCODE + Node->pTrack->RaOwnerSet(this); // do którego sektora ma zgłaszać animację +#endif + // NOTE: track merge/sort temporarily disabled to simplify unification of render code + // TODO: refactor sorting as universal part of drawing process in the renderer + Node->nNext3 = nRenderRect; + nRenderRect = Node; + break; + case GL_TRIANGLE_STRIP: + case GL_TRIANGLE_FAN: + case GL_TRIANGLES: + if (Node->iFlags & 0x20) { + // do przezroczystych z sektora + Node->nNext3 = nRenderRectAlpha; + nRenderRectAlpha = Node; + } + else { + // do nieprzezroczystych z sektora + Node->nNext3 = nRenderRect; + nRenderRect = Node; + } + break; + case TP_TRACTION: + case GL_LINES: + case GL_LINE_STRIP: + case GL_LINE_LOOP: // te renderowane na końcu, żeby nie łapały koloru nieba + Node->nNext3 = nRenderWires; + nRenderWires = Node; // lista drutów + break; + case TP_MODEL: // modele zawsze wyświetlane z własnego VBO + // jeśli model jest prosty, można próbować zrobić wspólną siatkę (słupy) + if ((Node->iFlags & 0x20200020) == 0) // czy brak przezroczystości? + { + Node->nNext3 = nRender; + nRender = Node; + } // do nieprzezroczystych + else if ((Node->iFlags & 0x10100010) == 0) // czy brak nieprzezroczystości? + { + Node->nNext3 = nRenderAlpha; + nRenderAlpha = Node; + } // do przezroczystych + else // jak i take i takie, to będzie dwa razy renderowane... + { + Node->nNext3 = nRenderMixed; + nRenderMixed = Node; + } // do mieszanych + break; +#ifdef EU07_SCENERY_EDITOR + case TP_MEMCELL: { + m_memcells.emplace_back( Node ); + break; + } +#endif + case TP_TRACTIONPOWERSOURCE: // a te w ogóle pomijamy +/* + // case TP_ISOLATED: //lista torów w obwodzie izolowanym - na razie ignorowana + break; +*/ + case TP_DYNAMIC: + return; // tych nie dopisujemy wcale + } + // dopisanie do ogólnej listy + Node->nNext2 = nRootNode; + nRootNode = Node; + // licznik obiektów + ++iNodeCount; +} + +// przygotowanie sektora do renderowania +void TSubRect::Sort() { + + SafeDeleteArray( tTracks ); + + if( iTracks > 0 ) { + tTracks = new TTrack *[ iTracks ]; // tworzenie tabeli torów do renderowania pojazdów + int i = 0; + for( TGroundNode *node = nRootNode; node != nullptr; node = node->nNext2 ) { + // kolejne obiekty z sektora + if( node->iType == TP_TRACK ) { + tTracks[ i++ ] = node->pTrack; + } + } + } + // NOTE: actual sort procedure temporarily removed as part of render code unification +} + +TTrack * TSubRect::FindTrack(vector3 *Point, int &iConnection, TTrack *Exclude) +{ // szukanie toru, którego koniec jest najbliższy (*Point) + for( int i = 0; i < iTracks; ++i ) { + if( tTracks[ i ] != Exclude ) // można użyć tabelę torów, bo jest mniejsza + { + iConnection = tTracks[ i ]->TestPoint( Point ); + if( iConnection >= 0 ) + return tTracks[ i ]; // szukanie TGroundNode nie jest potrzebne + } + } + return NULL; +}; + +#ifdef EU07_USE_OLD_GROUNDCODE +bool TSubRect::RaTrackAnimAdd(TTrack *t) +{ // aktywacja animacji torów w VBO (zwrotnica, obrotnica) + if( false == m_geometrycreated ) { + // nie ma animacji, gdy nie widać + return true; + } + if (tTrackAnim) + tTrackAnim->RaAnimListAdd(t); + else + tTrackAnim = t; + return false; // będzie animowane... +} + +// wykonanie animacji +void TSubRect::RaAnimate( unsigned int const Framestamp ) { + + if( ( tTrackAnim == nullptr ) + || ( Framestamp == m_framestamp ) ) { + // nie ma nic do animowania + return; + } + tTrackAnim = tTrackAnim->RaAnimate(); // przeliczenie animacji kolejnego + + m_framestamp = Framestamp; +}; +#endif + +TTraction * TSubRect::FindTraction(glm::dvec3 const &Point, int &iConnection, TTraction *Exclude) +{ // szukanie przęsła w sektorze, którego koniec jest najbliższy (*Point) + TGroundNode *Current; + for (Current = nRenderWires; Current; Current = Current->nNext3) + if ((Current->iType == TP_TRACTION) && (Current->hvTraction != Exclude)) + { + iConnection = Current->hvTraction->TestPoint(Point); + if (iConnection >= 0) + return Current->hvTraction; + } + return NULL; +}; + +// utworzenie siatek VBO dla wszystkich node w sektorze +void TSubRect::LoadNodes() { + + if( true == m_geometrycreated ) { + // obiekty były już sprawdzone + return; + } + else { + // mark it done for future checks + m_geometrycreated = true; + } + + auto *node { nRootNode }; + while( node != nullptr ) { + switch (node->iType) { + case GL_TRIANGLES: + case GL_LINES: { + vertex_array vertices; + for( auto const &vertex : node->Piece->vertices ) { + vertices.emplace_back( + vertex.position - node->m_rootposition, + vertex.normal, + vertex.texture ); + } + node->Piece->geometry = GfxRenderer.Insert( vertices, m_geometrybank, node->iType ); + node->Piece->vertices.swap( std::vector() ); // hipster shrink_to_fit + // TODO: get rid of the vertex counters, they're obsolete at this point + if( node->iType == GL_LINES ) { node->iNumVerts = 0; } + else { node->iNumPts = 0; } + break; + } + case TP_TRACK: + if( node->pTrack->visible() ) { // bo tory zabezpieczające są niewidoczne +#ifdef EU07_USE_OLD_GROUNDCODE + node->pTrack->create_geometry( m_geometrybank, node->m_rootposition ); +#else + node->pTrack->create_geometry( m_geometrybank ); +#endif + } + break; + case TP_TRACTION: +#ifdef EU07_USE_OLD_GROUNDCODE + node->hvTraction->create_geometry( m_geometrybank, node->m_rootposition ); +#else + node->hvTraction->create_geometry( m_geometrybank ); +#endif + break; + default: { break; } + } + node = node->nNext2; // następny z sektora + } +} +#ifdef EU07_USE_OLD_GROUNDCODE +void TSubRect::RenderSounds() +{ // aktualizacja dźwięków w pojazdach sektora (sektor może nie być wyświetlany) + for (int j = 0; j < iTracks; ++j) + tTracks[j]->RenderDynSounds(); // dźwięki pojazdów idą niezależnie od wyświetlania +}; +#endif +//--------------------------------------------------------------------------- +//------------------ Kwadrat kilometrowy ------------------------------------ +//--------------------------------------------------------------------------- +TGroundRect::~TGroundRect() +{ + SafeDeleteArray(pSubRects); +}; + +void +TGroundRect::Init() { + // since ground rectangle can be empty, we're doing lazy initialization of the geometry bank, when something may actually use it + if( m_geometrybank == null_handle ) { + m_geometrybank = GfxRenderer.Create_Bank(); + } + + pSubRects = new TSubRect[ iNumSubRects * iNumSubRects ]; + auto const subrectsize = 1000.0 / iNumSubRects; + for( int column = 0; column < iNumSubRects; ++column ) { + for( int row = 0; row < iNumSubRects; ++row ) { + auto subcell = FastGetSubRect( column, row ); + auto &area = subcell->m_area; + area.center = + m_area.center + - glm::dvec3( 500.0, 0.0, 500.0 ) // 'upper left' corner of rectangle + + glm::dvec3( subrectsize * 0.5, 0.0, subrectsize * 0.5 ) // center of sub-rectangle + + glm::dvec3( subrectsize * column, 0.0, subrectsize * row ); + area.radius = subrectsize * M_SQRT2; + // all subcells share the same geometry bank with their parent, to reduce buffer switching during render + subcell->m_geometrybank = m_geometrybank; + } + } +}; + +// dodanie obiektu do sektora na etapie rozdzielania na sektory +void +TGroundRect::NodeAdd( TGroundNode *Node ) { + + // override visibility ranges, to ensure the content is drawn from far enough + Node->fSquareRadius = 50000.0 * 50000.0; + Node->fSquareMinRadius = 0.0; + + // if the cell already has a node with matching material settings, we can just add the new geometry to it + if( ( Node->iType == GL_TRIANGLES ) ) { + // cell node only receives opaque geometry, so we can skip transparency test + auto matchingnode { nRenderRect }; + while( ( matchingnode != nullptr ) + && ( false == mergeable( *Node, *matchingnode ) ) ) { + // search will get us either a matching node, or a nullptr + matchingnode = matchingnode->nNext3; + } + if( matchingnode != nullptr ) { + // a valid match, so dump the content into it + // updating centre points isn't strictly necessary since render is based off the cell's middle, but, eh + matchingnode->pCenter = + interpolate( + matchingnode->pCenter, Node->pCenter, + static_cast( Node->iNumVerts ) / ( Node->iNumVerts + matchingnode->iNumVerts ) ); + matchingnode->iNumVerts += Node->iNumVerts; + matchingnode->Piece->vertices.insert( + std::end( matchingnode->Piece->vertices ), + std::begin( Node->Piece->vertices ), std::end( Node->Piece->vertices ) ); + // clear content of the node we're copying. a minor memory saving at best, but still a saving + std::vector().swap( Node->Piece->vertices ); + Node->iNumVerts = 0; + // since we've put the data in existing node we can skip adding the new one... + return; + // ...for others, they'll go through the regular procedure, along with other non-mergeable types + } + } + + return TSubRect::NodeAdd( Node ); +} + +// compares two provided nodes, returns true if their content can be merged +bool +TGroundRect::mergeable( TGroundNode const &Left, TGroundNode const &Right ) const { + // since view ranges and transparency type for all nodes put through this method are guaranteed to be equal, + // we can skip their tests and only do the material check. + // TODO, TBD: material as dedicated type, and refactor this method into a simple equality test + return ( ( Left.m_material == Right.m_material ) + && ( Left.Ambient == Right.Ambient ) + && ( Left.Diffuse == Right.Diffuse ) + && ( Left.Specular == Right.Specular ) ); +} + +//--------------------------------------------------------------------------- + +BYTE TempConnectionType[ 200 ]; // Ra: sprzêgi w sk³adzie; ujemne, gdy odwrotnie + +TGround::TGround() +{ +#ifdef EU07_USE_OLD_GROUNDCODE + Global::pGround = this; +#endif + for( int i = 0; i < TP_LAST; ++i ) { + nRootOfType[ i ] = nullptr; // zerowanie tablic wyszukiwania + } + ::SecureZeroMemory( TempConnectionType, sizeof( TempConnectionType ) ); + // set bounding area information for ground rectangles + float const rectsize = 1000.0f; + glm::vec3 const worldcenter; + for( int column = 0; column < iNumRects; ++column ) { + for( int row = 0; row < iNumRects; ++row ) { + auto &area = Rects[ column ][ row ].m_area; + // NOTE: in current implementation triangles can stick out to ~200m from the area, so we add extra padding + area.radius = ( rectsize * 0.5f * M_SQRT2 ) + 200.0f; + area.center = + worldcenter + - glm::vec3( (iNumRects / 2) * rectsize, 0.0f, (iNumRects / 2) * rectsize ) // 'upper left' corner of the world + + glm::vec3( rectsize * 0.5f, 0.0f, rectsize * 0.5f ) // center of the rectangle + + glm::vec3( rectsize * column, 0.0f, rectsize * row ); + } + } +} + +TGround::~TGround() +{ + Free(); +} + +void TGround::Free() +{ +#ifdef EU07_USE_OLD_GROUNDCODE + TEvent *tmp; + for (TEvent *Current = RootEvent; Current;) + { + tmp = Current; + Current = Current->evNext2; + delete tmp; + } +#endif + TGroundNode *tmpn; + for (int i = 0; i < TP_LAST; ++i) + { + for (TGroundNode *Current = nRootOfType[i]; Current;) + { + tmpn = Current; + Current = Current->nNext; + delete tmpn; + } + nRootOfType[i] = NULL; + } + for (TGroundNode *Current = nRootDynamic; Current;) + { + tmpn = Current; + Current = Current->nNext; + delete tmpn; + } + // RootNode=NULL; + nRootDynamic = NULL; +} +#ifdef EU07_USE_OLD_GROUNDCODE +TGroundNode * TGround::DynamicFindAny(std::string const &Name) +{ // wyszukanie pojazdu o podanej nazwie, szukanie po wszystkich (użyć drzewa!) + for (TGroundNode *Current = nRootDynamic; Current; Current = Current->nNext) + if ((Current->asName == Name)) + return Current; + return NULL; +}; + +TGroundNode * TGround::DynamicFind(std::string const &Name) +{ // wyszukanie pojazdu z obsadą o podanej nazwie (użyć drzewa!) + for (TGroundNode *Current = nRootDynamic; Current; Current = Current->nNext) + if (Current->DynamicObject->Mechanik) + if ((Current->asName == Name)) + return Current; + return NULL; +}; + +void +TGround::DynamicList(bool all) +{ // odesłanie nazw pojazdów dostępnych na scenerii (nazwy, szczególnie wagonów, mogą się + // powtarzać!) + for (TGroundNode *Current = nRootDynamic; Current; Current = Current->nNext) + if (all || Current->DynamicObject->Mechanik) + multiplayer::WyslijString(Current->asName, 6); // same nazwy pojazdów + multiplayer::WyslijString("none", 6); // informacja o końcu listy +}; + +// wyszukiwanie obiektu o podanej nazwie i konkretnym typie +TGroundNode * +TGround::FindGroundNode(std::string const &asNameToFind, TGroundNodeType const iNodeType) { + + if( ( iNodeType == TP_TRACK ) + || ( iNodeType == TP_MEMCELL ) + || ( iNodeType == TP_MODEL ) ) { + // wyszukiwanie w drzewie binarnym + return m_nodemap.Find( iNodeType, asNameToFind ); + } + // standardowe wyszukiwanie liniowe + for( TGroundNode *Current = nRootOfType[ iNodeType ]; Current != nullptr; Current = Current->nNext ) { + if( Current->asName == asNameToFind ) { + return Current; + } + } + return nullptr; +} +#endif +TGroundRect * +TGround::GetRect( double x, double z ) { + + auto const column = GetColFromX( x ) / iNumSubRects; + auto const row = GetRowFromZ( z ) / iNumSubRects; + + if( ( column >= 0 ) && ( column < iNumRects ) + && ( row >= 0 ) && ( row < iNumRects ) ) { + return &Rects[ column ][ row ]; + } + else { + return nullptr; + } +}; +#ifdef EU07_USE_OLD_GROUNDCODE +// convert tp_terrain model to a series of triangle nodes +void +TGround::convert_terrain( TGroundNode const *Terrain ) { + + TSubModel *submodel { nullptr }; + for( auto cellindex = 1; cellindex < Terrain->iCount; ++cellindex ) { + // go through all submodels for individual terrain cells... + submodel = Terrain->nNode[ cellindex ].smTerrain; + convert_terrain( submodel ); + // if there's more than one group of triangles in the cell they're held as children of the primary submodel + submodel = submodel->ChildGet(); + while( submodel != nullptr ) { + convert_terrain( submodel ); + submodel = submodel->NextGet(); + } + } +} + +void +TGround::convert_terrain( TSubModel const *Submodel ) { + + auto groundnode = new TGroundNode( GL_TRIANGLES ); + Submodel->convert( *groundnode ); + + if( groundnode->iNumVerts > 0 ) { + // jeśli nie jest pojazdem ostatni dodany dołączamy na końcu nowego + groundnode->nNext = nRootOfType[ groundnode->iType ]; + // ustawienie nowego na początku listy + nRootOfType[ groundnode->iType ] = groundnode; + } + else { + delete groundnode; + } +} +#endif +double fTrainSetVel = 0; +double fTrainSetDir = 0; +double fTrainSetDist = 0; // odległość składu od punktu 1 w stronę punktu 2 +std::string asTrainSetTrack = ""; +int iTrainSetConnection = 0; +bool bTrainSet = false; +std::string asTrainName = ""; +int iTrainSetWehicleNumber = 0; +TGroundNode *nTrainSetNode = NULL; // poprzedni pojazd do łączenia +TGroundNode *nTrainSetDriver = NULL; // pojazd, któremu zostanie wysłany rozkład + +#ifdef EU07_USE_OLD_GROUNDCODE +void TGround::RaTriangleDivider(TGroundNode *node) +{ // tworzy dodatkowe trójkąty i zmiejsza podany + // to jest wywoływane przy wczytywaniu trójkątów + // dodatkowe trójkąty są dodawane do głównej listy trójkątów + // podział trójkątów na sektory i kwadraty jest dokonywany później w FirstInit + if (node->iType != GL_TRIANGLES) + return; // tylko pojedyncze trójkąty + if (node->iNumVerts != 3) + return; // tylko gdy jeden trójkąt + double x0 = 1000.0 * std::floor(0.001 * node->pCenter.x) - 200.0; + double x1 = x0 + 1400.0; + double z0 = 1000.0 * std::floor(0.001 * node->pCenter.z) - 200.0; + double z1 = z0 + 1400.0; + if ((node->Piece->vertices[0].position.x >= x0) && (node->Piece->vertices[0].position.x <= x1) && + (node->Piece->vertices[0].position.z >= z0) && (node->Piece->vertices[0].position.z <= z1) && + (node->Piece->vertices[1].position.x >= x0) && (node->Piece->vertices[1].position.x <= x1) && + (node->Piece->vertices[1].position.z >= z0) && (node->Piece->vertices[1].position.z <= z1) && + (node->Piece->vertices[2].position.x >= x0) && (node->Piece->vertices[2].position.x <= x1) && + (node->Piece->vertices[2].position.z >= z0) && (node->Piece->vertices[2].position.z <= z1)) + return; // trójkąt wystający mniej niż 200m z kw. kilometrowego jest do przyjęcia + // Ra: przerobić na dzielenie na 2 trójkąty, podział w przecięciu z siatką kilometrową + // Ra: i z rekurencją będzie dzielić trzy trójkąty, jeśli będzie taka potrzeba + int divide = -1; // bok do podzielenia: 0=AB, 1=BC, 2=CA; +4=podział po OZ; +8 na x1/z1 + double min = 0, mul; // jeśli przechodzi przez oś, iloczyn będzie ujemny + x0 += 200.0; + x1 -= 200.0; // przestawienie na siatkę + z0 += 200.0; + z1 -= 200.0; + mul = (node->Piece->vertices[0].position.x - x0) * (node->Piece->vertices[1].position.x - x0); // AB na wschodzie + if (mul < min) + min = mul, divide = 0; + mul = (node->Piece->vertices[1].position.x - x0) * (node->Piece->vertices[2].position.x - x0); // BC na wschodzie + if (mul < min) + min = mul, divide = 1; + mul = (node->Piece->vertices[2].position.x - x0) * (node->Piece->vertices[0].position.x - x0); // CA na wschodzie + if (mul < min) + min = mul, divide = 2; + mul = (node->Piece->vertices[0].position.x - x1) * (node->Piece->vertices[1].position.x - x1); // AB na zachodzie + if (mul < min) + min = mul, divide = 8; + mul = (node->Piece->vertices[1].position.x - x1) * (node->Piece->vertices[2].position.x - x1); // BC na zachodzie + if (mul < min) + min = mul, divide = 9; + mul = (node->Piece->vertices[2].position.x - x1) * (node->Piece->vertices[0].position.x - x1); // CA na zachodzie + if (mul < min) + min = mul, divide = 10; + mul = (node->Piece->vertices[0].position.z - z0) * (node->Piece->vertices[1].position.z - z0); // AB na południu + if (mul < min) + min = mul, divide = 4; + mul = (node->Piece->vertices[1].position.z - z0) * (node->Piece->vertices[2].position.z - z0); // BC na południu + if (mul < min) + min = mul, divide = 5; + mul = (node->Piece->vertices[2].position.z - z0) * (node->Piece->vertices[0].position.z - z0); // CA na południu + if (mul < min) + min = mul, divide = 6; + mul = (node->Piece->vertices[0].position.z - z1) * (node->Piece->vertices[1].position.z - z1); // AB na północy + if (mul < min) + min = mul, divide = 12; + mul = (node->Piece->vertices[1].position.z - z1) * (node->Piece->vertices[2].position.z - z1); // BC na północy + if (mul < min) + min = mul, divide = 13; + mul = (node->Piece->vertices[2].position.z - z1) * (node->Piece->vertices[0].position.z - z1); // CA na północy + if (mul < min) + divide = 14; + // tworzymy jeden dodatkowy trójkąt, dzieląc jeden bok na przecięciu siatki kilometrowej + TGroundNode *ntri; // wskaźnik na nowy trójkąt + ntri = new TGroundNode(GL_TRIANGLES); // a ten jest nowy + // kopiowanie parametrów, przydałby się konstruktor kopiujący + ntri->m_material = node->m_material; + ntri->iFlags = node->iFlags; + ntri->Ambient = node->Ambient; + ntri->Diffuse = node->Diffuse; + ntri->Specular = node->Specular; + ntri->asName = node->asName; + ntri->fSquareRadius = node->fSquareRadius; + ntri->fSquareMinRadius = node->fSquareMinRadius; + ntri->bVisible = node->bVisible; // a są jakieś niewidoczne? + ntri->nNext = nRootOfType[GL_TRIANGLES]; + nRootOfType[GL_TRIANGLES] = ntri; // dopisanie z przodu do listy + ntri->iNumVerts = 3; + ntri->Piece->vertices.resize( 3 ); + switch (divide & 3) + { // podzielenie jednego z boków, powstaje wierzchołek D + case 0: // podział AB (0-1) -> ADC i DBC + ntri->Piece->vertices[2] = node->Piece->vertices[2]; // wierzchołek C jest wspólny + ntri->Piece->vertices[1] = node->Piece->vertices[1]; // wierzchołek B przechodzi do nowego + // node->Vertices[1].HalfSet(node->Vertices[0],node->Vertices[1]); //na razie D tak + if (divide & 4) + node->Piece->vertices[1].SetByZ(node->Piece->vertices[0], node->Piece->vertices[1], (divide & 8) ? z1 : z0); + else + node->Piece->vertices[1].SetByX(node->Piece->vertices[0], node->Piece->vertices[1], (divide & 8) ? x1 : x0); + ntri->Piece->vertices[0] = node->Piece->vertices[1]; // wierzchołek D jest wspólny + break; + case 1: // podział BC (1-2) -> ABD i ADC + ntri->Piece->vertices[0] = node->Piece->vertices[0]; // wierzchołek A jest wspólny + ntri->Piece->vertices[2] = node->Piece->vertices[2]; // wierzchołek C przechodzi do nowego + // node->Vertices[2].HalfSet(node->Vertices[1],node->Vertices[2]); //na razie D tak + if (divide & 4) + node->Piece->vertices[2].SetByZ(node->Piece->vertices[1], node->Piece->vertices[2], (divide & 8) ? z1 : z0); + else + node->Piece->vertices[2].SetByX(node->Piece->vertices[1], node->Piece->vertices[2], (divide & 8) ? x1 : x0); + ntri->Piece->vertices[1] = node->Piece->vertices[2]; // wierzchołek D jest wspólny + break; + case 2: // podział CA (2-0) -> ABD i DBC + ntri->Piece->vertices[1] = node->Piece->vertices[1]; // wierzchołek B jest wspólny + ntri->Piece->vertices[2] = node->Piece->vertices[2]; // wierzchołek C przechodzi do nowego + // node->Vertices[2].HalfSet(node->Vertices[2],node->Vertices[0]); //na razie D tak + if (divide & 4) + node->Piece->vertices[2].SetByZ(node->Piece->vertices[2], node->Piece->vertices[0], (divide & 8) ? z1 : z0); + else + node->Piece->vertices[2].SetByX(node->Piece->vertices[2], node->Piece->vertices[0], (divide & 8) ? x1 : x0); + ntri->Piece->vertices[0] = node->Piece->vertices[2]; // wierzchołek D jest wspólny + break; + } + // przeliczenie środków ciężkości obu + node->pCenter = ( node->Piece->vertices[ 0 ].position + node->Piece->vertices[ 1 ].position + node->Piece->vertices[ 2 ].position ) / 3.0; + ntri->pCenter = ( ntri->Piece->vertices[ 0 ].position + ntri->Piece->vertices[ 1 ].position + ntri->Piece->vertices[ 2 ].position ) / 3.0; + RaTriangleDivider(node); // rekurencja, bo nawet na TD raz nie wystarczy + RaTriangleDivider(ntri); +}; +#endif +TGroundNode * TGround::AddGroundNode(cParser *parser) +{ // wczytanie wpisu typu "node" + std::string str, str1, str2, str3, str4, Skin, DriverType, asNodeName; + double tf, r, rmin, tf1, tf3; + int int1; + size_t int2; + bool bError = false; + vector3 pt, front, up, left, pos, tv; + matrix4x4 mat2, mat1, mat; + TGroundNode *tmp1; + TTrack *Track; + std::string token; + parser->getTokens(4); + *parser + >> r + >> rmin + >> asNodeName + >> str; + TGroundNode *tmp = new TGroundNode(); + tmp->asName = (asNodeName == "none" ? "" : asNodeName); + if (r >= 0) + tmp->fSquareRadius = r * r; + tmp->fSquareMinRadius = rmin * rmin; + if (str == "triangles") + tmp->iType = GL_TRIANGLES; + else if (str == "triangle_strip") + tmp->iType = GL_TRIANGLE_STRIP; + else if (str == "triangle_fan") + tmp->iType = GL_TRIANGLE_FAN; + else if (str == "lines") + tmp->iType = GL_LINES; + else if (str == "line_strip") + tmp->iType = GL_LINE_STRIP; + else if (str == "line_loop") + tmp->iType = GL_LINE_LOOP; + else if (str == "model") + tmp->iType = TP_MODEL; + // else if (str=="terrain") tmp->iType=TP_TERRAIN; //tymczasowo do odwołania + else if (str == "dynamic") + tmp->iType = TP_DYNAMIC; + else if (str == "sound") + tmp->iType = TP_SOUND; + else if (str == "track") + tmp->iType = TP_TRACK; + else if (str == "memcell") + tmp->iType = TP_MEMCELL; + else if (str == "eventlauncher") + tmp->iType = TP_EVLAUNCH; + else if (str == "traction") + tmp->iType = TP_TRACTION; + else if (str == "tractionpowersource") + tmp->iType = TP_TRACTIONPOWERSOURCE; + // else if (str=="isolated") tmp->iType=TP_ISOLATED; + else + bError = true; + // WriteLog("-> node "+str+" "+tmp->asName); + if (bError) + { + Error("Scene parse error near " + str); + for (int i = 0; i < 60; ++i) + { // Ra: skopiowanie dalszej części do logu - taka prowizorka, lepsza niż nic + parser->getTokens(); // pobranie linijki tekstu nie działa + *parser >> token; + WriteLog(token); + } + // if (tmp==RootNode) RootNode=NULL; + delete tmp; + return NULL; + } + glm::dvec3 center; + std::vector importedvertices; + + switch (tmp->iType) + { +#ifdef EU07_USE_OLD_GROUNDCODE + case TP_TRACTION: + tmp->hvTraction = new TTraction( tmp->asName ); + parser->getTokens(); + *parser >> token; + tmp->hvTraction->asPowerSupplyName = token; // nazwa zasilacza + parser->getTokens(3); + *parser + >> tmp->hvTraction->NominalVoltage + >> tmp->hvTraction->MaxCurrent + >> tmp->hvTraction->fResistivity; + if (tmp->hvTraction->fResistivity == 0.01f) // tyle jest w sceneriach [om/km] + tmp->hvTraction->fResistivity = 0.075f; // taka sensowniejsza wartość za + // http://www.ikolej.pl/fileadmin/user_upload/Seminaria_IK/13_05_07_Prezentacja_Kruczek.pdf + tmp->hvTraction->fResistivity *= 0.001f; // teraz [om/m] + parser->getTokens(); + *parser >> token; + // Ra 2014-02: a tutaj damy symbol sieci i jej budowę, np.: + // SKB70-C, CuCd70-2C, KB95-2C, C95-C, C95-2C, YC95-2C, YpC95-2C, YC120-2C + // YpC120-2C, YzC120-2C, YwsC120-2C, YC150-C150, YC150-2C150, C150-C150 + // C120-2C, 2C120-2C, 2C120-2C-1, 2C120-2C-2, 2C120-2C-3, 2C120-2C-4 + if (token.compare("none") == 0) + tmp->hvTraction->Material = 0; + else if (token.compare("al") == 0) + tmp->hvTraction->Material = 2; // 1=aluminiowa, rysuje się na czarno + else + tmp->hvTraction->Material = 1; // 1=miedziana, rysuje się na zielono albo czerwono + parser->getTokens(); + *parser >> tmp->hvTraction->WireThickness; + parser->getTokens(); + *parser >> tmp->hvTraction->DamageFlag; + parser->getTokens(3); + *parser + >> tmp->hvTraction->pPoint1.x + >> tmp->hvTraction->pPoint1.y + >> tmp->hvTraction->pPoint1.z; + tmp->hvTraction->pPoint1 += glm::dvec3{ pOrigin }; + parser->getTokens(3); + *parser + >> tmp->hvTraction->pPoint2.x + >> tmp->hvTraction->pPoint2.y + >> tmp->hvTraction->pPoint2.z; + tmp->hvTraction->pPoint2 += glm::dvec3{ pOrigin }; + parser->getTokens(3); + *parser + >> tmp->hvTraction->pPoint3.x + >> tmp->hvTraction->pPoint3.y + >> tmp->hvTraction->pPoint3.z; + tmp->hvTraction->pPoint3 += glm::dvec3{ pOrigin }; + parser->getTokens(3); + *parser + >> tmp->hvTraction->pPoint4.x + >> tmp->hvTraction->pPoint4.y + >> tmp->hvTraction->pPoint4.z; + tmp->hvTraction->pPoint4 += glm::dvec3{ pOrigin }; + parser->getTokens(); + *parser >> tf1; + tmp->hvTraction->fHeightDifference = + (tmp->hvTraction->pPoint3.y - tmp->hvTraction->pPoint1.y + tmp->hvTraction->pPoint4.y - tmp->hvTraction->pPoint2.y) * 0.5f - tf1; + parser->getTokens(); + *parser >> tf1; + if (tf1 > 0) + tmp->hvTraction->iNumSections = + glm::length((tmp->hvTraction->pPoint1 - tmp->hvTraction->pPoint2)) / tf1; + else + tmp->hvTraction->iNumSections = 0; + parser->getTokens(); + *parser >> tmp->hvTraction->Wires; + parser->getTokens(); + *parser >> tmp->hvTraction->WireOffset; + parser->getTokens(); + *parser >> token; + tmp->bVisible = (token.compare("vis") == 0); + parser->getTokens(); + *parser >> token; + if (token.compare("parallel") == 0) + { // jawne wskazanie innego przęsła, na które może przestawić się pantograf + parser->getTokens(); + *parser >> token; // wypadało by to zapamiętać... + tmp->hvTraction->asParallel = token; + parser->getTokens(); + *parser >> token; // a tu już powinien być koniec + } + if (token.compare("endtraction") != 0) + Error("ENDTRACTION delimiter missing! " + str2 + " found instead."); + tmp->hvTraction->Init(); // przeliczenie parametrów + tmp->pCenter = interpolate( tmp->hvTraction->pPoint2, tmp->hvTraction->pPoint1, 0.5 ); + break; + case TP_TRACTIONPOWERSOURCE: + parser->getTokens(3); + *parser + >> tmp->pCenter.x + >> tmp->pCenter.y + >> tmp->pCenter.z; + tmp->pCenter += pOrigin; + tmp->psTractionPowerSource = new TTractionPowerSource( tmp->asName ); + tmp->psTractionPowerSource->Load(parser); + break; + case TP_MEMCELL: + parser->getTokens(3); + *parser + >> tmp->pCenter.x + >> tmp->pCenter.y + >> tmp->pCenter.z; + tmp->pCenter.RotateY(aRotate.y / 180.0 * M_PI); // Ra 2014-11: uwzględnienie rotacji + tmp->pCenter += pOrigin; + tmp->MemCell = new TMemCell(&tmp->pCenter); + tmp->MemCell->Load(parser); + if (!tmp->asName.empty()) // jest pusta gdy "none" + { // dodanie do wyszukiwarki + if( false == m_nodemap.Add( TP_MEMCELL, tmp->asName, tmp ) ) { + // przy zdublowaniu wskaźnik zostanie podmieniony w drzewku na późniejszy (zgodność wsteczna) + ErrorLog( "Duplicated memcell: " + tmp->asName ); // to zgłaszać duplikat + } + } + break; + case TP_EVLAUNCH: + parser->getTokens(3); + *parser + >> tmp->pCenter.x + >> tmp->pCenter.y + >> tmp->pCenter.z; + tmp->pCenter.RotateY(aRotate.y / 180.0 * M_PI); // Ra 2014-11: uwzględnienie rotacji + tmp->pCenter += pOrigin; + tmp->EvLaunch = new TEventLauncher(); + tmp->EvLaunch->Load(parser); + break; + case TP_TRACK: + tmp->pTrack = new TTrack( tmp->asName ); + if (Global::iWriteLogEnabled & 4) + if (!tmp->asName.empty()) + WriteLog(tmp->asName); + tmp->pTrack->Load(parser, pOrigin); // w nazwie może być nazwa odcinka izolowanego + if (!tmp->asName.empty()) // jest pusta gdy "none" + { // dodanie do wyszukiwarki + if( false == m_nodemap.Add( TP_TRACK, tmp->asName, tmp ) ) { + // przy zdublowaniu wskaźnik zostanie podmieniony w drzewku na późniejszy (zgodność wsteczna) + ErrorLog( "Duplicated track: " + tmp->asName ); // to zgłaszać duplikat + } + } + tmp->pCenter = ( + tmp->pTrack->CurrentSegment()->FastGetPoint_0() + + tmp->pTrack->CurrentSegment()->FastGetPoint( 0.5 ) + + tmp->pTrack->CurrentSegment()->FastGetPoint_1() ) + / 3.0; + break; + case TP_SOUND: + parser->getTokens(3); + *parser + >> tmp->pCenter.x + >> tmp->pCenter.y + >> tmp->pCenter.z; + tmp->pCenter.RotateY(aRotate.y / 180.0 * M_PI); // Ra 2014-11: uwzględnienie rotacji + tmp->pCenter += pOrigin; + parser->getTokens(); + *parser >> token; + str = token; + //str = AnsiString(token.c_str()); + tmp->tsStaticSound = new TTextSound(str, sqrt(tmp->fSquareRadius), tmp->pCenter.x, tmp->pCenter.y, tmp->pCenter.z, false, false, rmin); + if (rmin < 0.0) + rmin = 0.0; // przywrócenie poprawnej wartości, jeśli służyła do wyłączenia efektu Dopplera + parser->getTokens(); + *parser >> token; + break; + case TP_DYNAMIC: + tmp->DynamicObject = new TDynamicObject(); + // tmp->DynamicObject->Load(Parser); + parser->getTokens(3); + *parser + >> str1 // katalog + >> Skin // tekstura wymienna + >> str3; // McZapkie-131102: model w MMD + if (bTrainSet) + { // jeśli pojazd jest umieszczony w składzie + str = asTrainSetTrack; + parser->getTokens(3); + *parser + >> tf1 // Ra: -1 oznacza odwrotne wstawienie, normalnie w składzie 0 + >> DriverType // McZapkie:010303 - w przyszlosci rozne konfiguracje mechanik/pomocnik itp + >> str4; + tf3 = fTrainSetVel; // prędkość + int2 = str4.find("."); // yB: wykorzystuje tutaj zmienna, ktora potem bedzie ladunkiem + if (int2 != std::string::npos) // yB: jesli znalazl kropke, to ja przetwarza jako parametry + { + size_t dlugosc = str4.length(); + int1 = atoi(str4.substr(0, int2).c_str()); // niech sprzegiem bedzie do kropki cos + str4 = str4.substr(int2 + 1, dlugosc - int2); + } + else + { + int1 = atoi(str4.c_str()); + str4 = ""; + } + int2 = 0; // zeruje po wykorzystaniu + if (int1 < 0) + int1 = (-int1) | + ctrain_depot; // sprzęg zablokowany (pojazdy nierozłączalne przy manewrach) + if (tf1 != -1.0) + if (std::fabs(tf1) > 0.5) // maksymalna odległość między sprzęgami - do przemyślenia + int1 = 0; // likwidacja sprzęgu, jeśli odległość zbyt duża - to powinno być + // uwzględniane w fizyce sprzęgów... + TempConnectionType[iTrainSetWehicleNumber] = int1; // wartość dodatnia + } + else + { // pojazd wstawiony luzem + fTrainSetDist = 0; // zerowanie dodatkowego przesunięcia + asTrainName = ""; // puste oznacza jazdę pojedynczego bez rozkładu, "none" jest dla + // składu (trainset) + parser->getTokens(4); + *parser + >> str // track + >> tf1 // Ra: -1 oznacza odwrotne wstawienie + >> DriverType // McZapkie:010303: obsada + >> tf3; // prędkość, niektórzy wpisują tu "3" jako sprzęg, żeby nie było tabliczki + iTrainSetWehicleNumber = 0; + TempConnectionType[iTrainSetWehicleNumber] = 3; // likwidacja tabliczki na końcu? + } + parser->getTokens(); + *parser >> int2; // ilość ładunku + if (int2 > 0) + { // jeżeli ładunku jest więcej niż 0, to rozpoznajemy jego typ + parser->getTokens(); + *parser >> str2; // LoadType + if (str2 == "enddynamic") // idiotoodporność: ładunek bez podanego typu + { + str2 = ""; + int2 = 0; // ilość bez typu się nie liczy jako ładunek + } + } + else + str2 = ""; // brak ladunku + + tmp1 = FindGroundNode(str, TP_TRACK); // poszukiwanie toru + if (tmp1 ? tmp1->pTrack != NULL : false) + { // jeśli tor znaleziony + Track = tmp1->pTrack; + if (!iTrainSetWehicleNumber) // jeśli pierwszy pojazd + if (Track->evEvent0) // jeśli tor ma Event0 + if (fabs(fTrainSetVel) <= 1.0) // a skład stoi + if (fTrainSetDist >= 0.0) // ale może nie sięgać na owy tor + if (fTrainSetDist < 8.0) // i raczej nie sięga + fTrainSetDist = + 8.0; // przesuwamy około pół EU07 dla wstecznej zgodności + + auto const length = + tmp->DynamicObject->Init( + asNodeName, str1, Skin, str3, Track, + ( tf1 == -1.0 ? + fTrainSetDist : + fTrainSetDist - tf1 ), + DriverType, tf3, asTrainName, int2, str2, (tf1 == -1.0), str4); + if (length != 0.0) // zero oznacza błąd + { + // przesunięcie dla kolejnego, minus bo idziemy w stronę punktu 1 + fTrainSetDist -= length; + tmp->pCenter = tmp->DynamicObject->GetPosition(); + // automatically establish permanent connections for couplers which specify them in their definitions + if( TempConnectionType[ iTrainSetWehicleNumber ] ) { + if( tmp->DynamicObject->MoverParameters->Couplers[ ( tf1 == -1.0 ? 0 : 1 ) ].AllowedFlag & coupling::permanent ) { + TempConnectionType[ iTrainSetWehicleNumber ] |= coupling::permanent; + } + } + iTrainSetWehicleNumber++; + } + else + { // LastNode=NULL; + delete tmp; + tmp = NULL; // nie może być tu return, bo trzeba pominąć jeszcze enddynamic + } + } + else + { // gdy tor nie znaleziony + ErrorLog("Missed track: dynamic placed on \"" + tmp->DynamicObject->asTrack + "\""); + delete tmp; + tmp = NULL; // nie może być tu return, bo trzeba pominąć jeszcze enddynamic + } + parser->getTokens(); + *parser >> token; + if (token.compare("destination") == 0) + { // dokąd wagon ma jechać, uwzględniane przy manewrach + parser->getTokens(); + *parser >> token; + if (tmp) + tmp->DynamicObject->asDestination = token; + *parser >> token; + } + if (token.compare("enddynamic") != 0) + Error("enddynamic statement missing"); +/* + if( tmp->DynamicObject->MoverParameters->LightPowerSource.SourceType != TPowerSource::NotDefined ) { + // if the vehicle has defined light source, it can (potentially) emit light, so add it to the light array +*/ + if( ( tmp != nullptr ) + && ( tmp->DynamicObject->MoverParameters->CategoryFlag == 1 ) // trains only + && ( ( tmp->DynamicObject->MoverParameters->SecuritySystem.SystemType != 0 ) + || ( tmp->DynamicObject->MoverParameters->SandCapacity > 0.0 ) ) ) { + // we check for presence of security system or sand load, as a way to determine whether the vehicle is a controllable engine + // NOTE: this isn't 100% precise, e.g. middle EZT module comes with security system, while it has no lights, and some engines + // don't have security systems fitted + simulation::Lights.insert( tmp->DynamicObject ); + } + + break; + case TP_MODEL: { + if( rmin < 0 ) { + // legacy leftover: special case, terrain provided as 3d model + tmp->iType = TP_TERRAIN; + tmp->fSquareMinRadius = 0; // to w ogóle potrzebne? + // we ignore center and rotation for terrain; they should be set to 0 anyway + parser->getTokens( 4 ); + + tmp->iFlags = 0x200; // flaga usuwania + tmp->Model = new TAnimModel(); + if( false == tmp->Model->Load( parser, true ) ) { + delete tmp; + tmp = nullptr; + break; + } + tmp->iFlags |= tmp->Model->Flags(); // ustalenie, czy przezroczysty + tmp->pCenter = Math3D::vector3(); // enforce placement in the world center + // jeśli model jest terenem, trzeba utworzyć dodatkowe obiekty + tmp->iCount = tmp->Model->TerrainCount() + 1; // zliczenie submodeli + Global::pTerrainCompact = tmp->Model; + tmp->nNode = new TGroundNode[ tmp->iCount ]; // sztuczne node dla kwadratów + tmp->nNode[ 0 ].iType = TP_MODEL; // pierwszy zawiera model (dla delete) + tmp->nNode[ 0 ].Model = Global::pTerrainCompact; + tmp->nNode[ 0 ].iFlags = 0x200; // nie wyświetlany, ale usuwany + for( auto i = 1; i < tmp->iCount; ++i ) { // a reszta to submodele + tmp->nNode[ i ].iType = TP_SUBMODEL; + tmp->nNode[ i ].smTerrain = Global::pTerrainCompact->TerrainSquare( i - 1 ); + tmp->nNode[ i ].iFlags = 0x10; // nieprzezroczyste; nie usuwany + tmp->nNode[ i ].bVisible = true; + tmp->nNode[ i ].pCenter = tmp->pCenter; // nie przesuwamy w inne miejsce + } + } + else { + // regular 3d model + parser->getTokens( 3 ); + *parser + >> tmp->pCenter.x + >> tmp->pCenter.y + >> tmp->pCenter.z; + parser->getTokens(); + *parser >> tf1; + // OlO_EU&KAKISH-030103: obracanie punktow zaczepien w modelu + tmp->pCenter.RotateY( glm::radians( aRotate.y ) ); + // McZapkie-260402: model tez ma wspolrzedne wzgledne + tmp->pCenter += pOrigin; + + tmp->iFlags = 0x200; // flaga usuwania + tmp->Model = new TAnimModel(); + tmp->Model->RaAnglesSet( glm::vec3{ aRotate.x, tf1 + aRotate.y, aRotate.z } ); // dostosowanie do pochylania linii + if( false == tmp->Model->Load( parser, false ) ) { + // model nie wczytał się - ignorowanie node + delete tmp; + tmp = nullptr; // nie może być tu return + break; // nie może być tu return? + } + tmp->iFlags |= tmp->Model->Flags(); // ustalenie, czy przezroczysty + if( false == tmp->asName.empty() ) { // jest pusta gdy "none" + // dodanie do wyszukiwarki + if( false == m_nodemap.Add( TP_MODEL, tmp->asName, tmp ) ) { + // przy zdublowaniu wskaźnik zostanie podmieniony w drzewku na późniejszy (zgodność wsteczna) + ErrorLog( "Duplicated model: " + tmp->asName ); // to zgłaszać duplikat + } + } + } + break; + } + // case TP_GEOMETRY : + case GL_TRIANGLES: + case GL_TRIANGLE_STRIP: + case GL_TRIANGLE_FAN: { + + parser->getTokens(); + *parser >> token; + // McZapkie-050702: opcjonalne wczytywanie parametrow materialu (ambient,diffuse,specular) + if( token.compare( "material" ) == 0 ) { + parser->getTokens(); + *parser >> token; + while( token.compare( "endmaterial" ) != 0 ) { + if( token.compare( "ambient:" ) == 0 ) { + parser->getTokens( 3 ); + *parser + >> tmp->Ambient.r + >> tmp->Ambient.g + >> tmp->Ambient.b; + tmp->Ambient /= 255.0f; + } + else if( token.compare( "diffuse:" ) == 0 ) { // Ra: coś jest nie tak, bo w jednej linijce nie działa + parser->getTokens( 3 ); + *parser + >> tmp->Diffuse.r + >> tmp->Diffuse.g + >> tmp->Diffuse.b; + tmp->Diffuse /= 255.0f; + } + else if( token.compare( "specular:" ) == 0 ) { + parser->getTokens( 3 ); + *parser + >> tmp->Specular.r + >> tmp->Specular.g + >> tmp->Specular.b; + tmp->Specular /= 255.0f; + } + else + Error( "Scene material failure!" ); + parser->getTokens(); + *parser >> token; + } + } + if( token.compare( "endmaterial" ) == 0 ) { + parser->getTokens(); + *parser >> token; + } + str = token; + tmp->m_material = GfxRenderer.Fetch_Material( str ); + auto const texturehandle = ( + tmp->m_material != null_handle ? + GfxRenderer.Material( tmp->m_material ).texture1 : + null_handle ); + auto const &texture = ( + texturehandle ? + GfxRenderer.Texture( texturehandle ) : + opengl_texture() ); // dirty workaround for lack of better api + bool const clamps = ( + texturehandle ? + texture.traits.find( 's' ) != std::string::npos : + false ); + bool const clampt = ( + texturehandle ? + texture.traits.find( 't' ) != std::string::npos : + false ); + + tmp->iFlags |= 200; // z usuwaniem + // remainder of legacy 'problend' system -- geometry assigned a texture with '@' in its name is treated as translucent, opaque otherwise + if( texturehandle != null_handle ) { + tmp->iFlags |= ( + ( ( texture.name.find( '@' ) != std::string::npos ) + && ( true == texture.has_alpha ) ) ? + 0x20 : + 0x10 ); + } + else { + tmp->iFlags |= 0x10; + } + + TGroundVertex vertex, vertex1, vertex2; + std::size_t vertexcount{ 0 }; + do { + parser->getTokens( 8, false ); + *parser + >> vertex.position.x + >> vertex.position.y + >> vertex.position.z + >> vertex.normal.x + >> vertex.normal.y + >> vertex.normal.z + >> vertex.texture.s + >> vertex.texture.t; + vertex.position = glm::rotateZ( vertex.position, glm::radians( aRotate.z ) ); + vertex.position = glm::rotateX( vertex.position, glm::radians( aRotate.x ) ); + vertex.position = glm::rotateY( vertex.position, glm::radians( aRotate.y ) ); + vertex.normal = glm::rotateZ( vertex.normal, glm::radians( aRotate.z ) ); + vertex.normal = glm::rotateX( vertex.normal, glm::radians( aRotate.x ) ); + vertex.normal = glm::rotateY( vertex.normal, glm::radians( aRotate.y ) ); + vertex.position += glm::dvec3{ pOrigin }; + if( true == clamps ) { vertex.texture.s = clamp( vertex.texture.s, 0.001f, 0.999f ); } + if( true == clampt ) { vertex.texture.t = clamp( vertex.texture.t, 0.001f, 0.999f ); } + // convert all data to gl_triangles to allow data merge for matching nodes + switch( tmp->iType ) { + case GL_TRIANGLES: { + if( vertexcount == 0 ) { vertex1 = vertex; } + else if( vertexcount == 1 ) { vertex2 = vertex; } + else if( vertexcount >= 2 ) { + if( false == degenerate( vertex1.position, vertex2.position, vertex.position ) ) { + importedvertices.emplace_back( vertex1 ); + importedvertices.emplace_back( vertex2 ); + importedvertices.emplace_back( vertex ); + } + else { + ErrorLog( + "Bad geometry: degenerate triangle encountered" + + ( tmp->asName != "" ? " in node \"" + tmp->asName + "\"" : "" ) + + " (vertices: " + to_string( vertex1.position ) + " + " + to_string( vertex2.position ) + " + " + to_string( vertex.position ) + ")" ); + } + } + ++vertexcount; + if( vertexcount > 2 ) { vertexcount = 0; } // start new triangle if needed + break; + } + case GL_TRIANGLE_FAN: { + if( vertexcount == 0 ) { vertex1 = vertex; } + else if( vertexcount == 1 ) { vertex2 = vertex; } + else if( vertexcount >= 2 ) { + if( false == degenerate( vertex1.position, vertex2.position, vertex.position ) ) { + importedvertices.emplace_back( vertex1 ); + importedvertices.emplace_back( vertex2 ); + importedvertices.emplace_back( vertex ); + vertex2 = vertex; + } + else { + ErrorLog( + "Bad geometry: degenerate triangle encountered" + + ( tmp->asName != "" ? " in node \"" + tmp->asName + "\"" : "" ) + + " (vertices: " + to_string( vertex1.position ) + " + " + to_string( vertex2.position ) + " + " + to_string( vertex.position ) + ")" ); + } + } + ++vertexcount; + break; + } + case GL_TRIANGLE_STRIP: { + if( vertexcount == 0 ) { vertex1 = vertex; } + else if( vertexcount == 1 ) { vertex2 = vertex; } + else if( vertexcount >= 2 ) { + if( false == degenerate( vertex1.position, vertex2.position, vertex.position ) ) { + // swap order every other triangle, to maintain consistent winding + if( vertexcount % 2 == 0 ) { + importedvertices.emplace_back( vertex1 ); + importedvertices.emplace_back( vertex2 ); + } + else { + importedvertices.emplace_back( vertex2 ); + importedvertices.emplace_back( vertex1 ); + } + importedvertices.emplace_back( vertex ); + + vertex1 = vertex2; + vertex2 = vertex; + } + else { + ErrorLog( + "Bad geometry: degenerate triangle encountered" + + ( tmp->asName != "" ? " in node \"" + tmp->asName + "\"" : "" ) + + " (vertices: " + to_string( vertex1.position ) + " + " + to_string( vertex2.position ) + " + " + to_string( vertex.position ) + ")" ); + } + } + ++vertexcount; + break; + } + default: { break; } + } + parser->getTokens(); + *parser >> token; + + } while( token.compare( "endtri" ) != 0 ); + + tmp->iType = GL_TRIANGLES; + tmp->Piece = new piece_node(); + tmp->iNumVerts = importedvertices.size(); + + if( tmp->iNumVerts > 0 ) { + + tmp->Piece->vertices.swap( importedvertices ); + + for( auto const &vertex : tmp->Piece->vertices ) { + tmp->pCenter += vertex.position; + } + tmp->pCenter /= tmp->iNumVerts; + + r = 0; + for( auto const &vertex : tmp->Piece->vertices ) { + tf = glm::length2( vertex.position - glm::dvec3{ tmp->pCenter } ); + if( tf > r ) + r = tf; + } + tmp->fSquareRadius += r; + RaTriangleDivider( tmp ); // Ra: dzielenie trójkątów jest teraz całkiem wydajne + } // koniec wczytywania trójkątów + break; + } + case GL_LINES: + case GL_LINE_STRIP: + case GL_LINE_LOOP: { + parser->getTokens( 4 ); + *parser + >> tmp->Diffuse.r + >> tmp->Diffuse.g + >> tmp->Diffuse.b + >> tmp->fLineThickness; + tmp->Diffuse /= 255.0f; + tmp->fLineThickness = std::min( 30.0, tmp->fLineThickness ); // 30 pix equals rougly width of a signal pole viewed from ~1m away + + TGroundVertex vertex, vertex0, vertex1; + std::size_t vertexcount{ 0 }; + + parser->getTokens(); + *parser >> token; + do { + vertex.position.x = std::atof( token.c_str() ); + parser->getTokens( 2 ); + *parser + >> vertex.position.y + >> vertex.position.z; + vertex.position = glm::rotateZ( vertex.position, glm::radians( aRotate.z ) ); + vertex.position = glm::rotateX( vertex.position, glm::radians( aRotate.x ) ); + vertex.position = glm::rotateY( vertex.position, glm::radians( aRotate.y ) ); + + vertex.position += glm::dvec3{ pOrigin }; + // convert all data to gl_lines to allow data merge for matching nodes + switch( tmp->iType ) { + case GL_LINES: { + importedvertices.emplace_back( vertex ); + break; + } + case GL_LINE_STRIP: { + if( vertexcount > 0 ) { + importedvertices.emplace_back( vertex1 ); + importedvertices.emplace_back( vertex ); + } + vertex1 = vertex; + ++vertexcount; + break; + } + case GL_LINE_LOOP: { + if( vertexcount == 0 ) { + vertex0 = vertex; + vertex1 = vertex; + } + else { + importedvertices.emplace_back( vertex1 ); + importedvertices.emplace_back( vertex ); + } + vertex1 = vertex; + ++vertexcount; + break; + } + default: { break; } + } + parser->getTokens(); + *parser >> token; + } while( token.compare( "endline" ) != 0 ); + // add closing line for the loop + if( ( tmp->iType == GL_LINE_LOOP ) + && ( vertexcount > 2 ) ) { + importedvertices.emplace_back( vertex1 ); + importedvertices.emplace_back( vertex0 ); + } + if( importedvertices.size() % 2 != 0 ) { + ErrorLog( "Lines node specified odd number of vertices, encountered in file \"" + parser->Name() + "\" (line " + std::to_string( parser->Line() - 1 ) + ")" ); + importedvertices.pop_back(); + } + tmp->iType = GL_LINES; + tmp->Piece = new piece_node(); + tmp->iNumPts = importedvertices.size(); + + if( false == importedvertices.empty() ) { + + tmp->Piece->vertices.swap( importedvertices ); + + glm::dvec3 minpoint( std::numeric_limits::max(), 0.0, std::numeric_limits::max() ); + glm::dvec3 maxpoint( std::numeric_limits::lowest(), 0.0, std::numeric_limits::lowest() ); + for( auto const &vertex : tmp->Piece->vertices ) { + tmp->pCenter += vertex.position; + minpoint.x = std::min( minpoint.x, vertex.position.x ); + minpoint.z = std::min( minpoint.z, vertex.position.z ); + maxpoint.x = std::max( maxpoint.x, vertex.position.x ); + maxpoint.z = std::max( maxpoint.z, vertex.position.z ); + } + tmp->pCenter /= tmp->iNumPts; + tmp->m_radius = static_cast( glm::distance( maxpoint, minpoint ) * 0.5 ); + } + break; + } +#endif + default: { + break; + } + } + return tmp; +} + +TSubRect * TGround::FastGetSubRect(int iCol, int iRow) +{ + int br, bc, sr, sc; + br = iRow / iNumSubRects; + bc = iCol / iNumSubRects; + sr = iRow - br * iNumSubRects; + sc = iCol - bc * iNumSubRects; + if ((br < 0) || (bc < 0) || (br >= iNumRects) || (bc >= iNumRects)) + return NULL; + return (Rects[bc][br].FastGetSubRect(sc, sr)); +} + +TSubRect * TGround::GetSubRect(int iCol, int iRow) +{ // znalezienie małego kwadratu mapy + int br, bc, sr, sc; + br = iRow / iNumSubRects; // współrzędne kwadratu kilometrowego + bc = iCol / iNumSubRects; + sr = iRow - br * iNumSubRects; // współrzędne wzglęne małego kwadratu + sc = iCol - bc * iNumSubRects; + if ((br < 0) || (bc < 0) || (br >= iNumRects) || (bc >= iNumRects)) + return NULL; // jeśli poza mapą + return (Rects[bc][br].SafeGetSubRect(sc, sr)); // pobranie małego kwadratu +} + +#ifdef EU07_USE_OLD_GROUNDCODE +TEvent * TGround::FindEvent(const std::string &asEventName) +{ + if( asEventName.empty() ) { return nullptr; } + + auto const lookup = m_eventmap.find( asEventName ); + return ( + lookup != m_eventmap.end() ? + lookup->second : + nullptr ); +} + +void TGround::FirstInit() +{ // ustalanie zależności na scenerii przed wczytaniem pojazdów + if (bInitDone) + return; // Ra: żeby nie robiło się dwa razy + bInitDone = true; + WriteLog("InitNormals"); + for (int type = 0; type < TP_LAST; ++type) { + for (TGroundNode *Current = nRootOfType[type]; Current != nullptr; Current = Current->nNext) { + + if( type == GL_TRIANGLES ) { Current->InitNormals(); } + + if (Current->iType != TP_DYNAMIC) + { // pojazdów w ogóle nie dotyczy dodawanie do mapy + if( ( type == TP_EVLAUNCH ) + && ( true == Current->EvLaunch->IsGlobal() ) ) { + // dodanie do globalnego obiektu + srGlobal.NodeAdd( Current ); + } +#ifdef EU07_USE_OLD_TERRAINCODE + else if (type == TP_TERRAIN) { + // specjalne przetwarzanie terenu wczytanego z pliku E3D + TGroundRect *gr; + for (int j = 1; j < Current->iCount; ++j) { + // od 1 do końca są zestawy trójkątów + std::string xxxzzz = Current->nNode[j].smTerrain->pName; // pobranie nazwy + gr = GetRect( + ( std::stoi( xxxzzz.substr( 0, 3 )) - 500 ) * 1000, + ( std::stoi( xxxzzz.substr( 3, 3 )) - 500 ) * 1000 ); + gr->nTerrain = Current->nNode + j; // zapamiętanie + } + } +#endif + else { + TSubRect *targetcell { nullptr }; + // test whether we can add the node to a ground cell, or a subcell + if( ( Current->iType != GL_TRIANGLES ) + || ( Current->iFlags & 0x20 ) + || ( Current->fSquareMinRadius != 0.0 ) + || ( Current->fSquareRadius <= 90000.0 ) ) { + // add to sub-rectangle + targetcell = GetSubRect( Current->pCenter.x, Current->pCenter.z ); + } + else { + // dodajemy do kwadratu kilometrowego + targetcell = GetRect( Current->pCenter.x, Current->pCenter.z ); + } + if( targetcell != nullptr ) { + targetcell->NodeAdd( Current ); + } + else { + ErrorLog( "Scenery node" + ( + Current->asName == "" ? + "" : + " \"" + Current->asName + "\"" ) + + " placed in location outside of map bounds (location: " + to_string( glm::dvec3{ Current->pCenter } ) + ")" ); + } + } + } + } + } + for (std::size_t i = 0; i < iNumRects; ++i) + for (std::size_t j = 0; j < iNumRects; ++j) + Rects[i][j].Optimize(); // optymalizacja obiektów w sektorach + + WriteLog("InitNormals OK"); + + InitTracks(); //łączenie odcinków ze sobą i przyklejanie eventów + WriteLog("InitTracks OK"); + InitTraction(); //łączenie drutów ze sobą + WriteLog("InitTraction OK"); + InitEvents(); + WriteLog( "InitEvents OK" ); + InitLaunchers(); + WriteLog("InitLaunchers OK"); + WriteLog("FirstInit is done"); +}; + +bool TGround::Init(std::string File) +{ // główne wczytywanie scenerii + if (ToLower(File).substr(0, 7) == "scenery") + File = File.erase(0, 8); // Ra: usunięcie niepotrzebnych znaków - zgodność wstecz z 2003 + WriteLog("Loading scenery from " + File); + Global::pGround = this; + // pTrain=NULL; + pOrigin = aRotate = vector3(0, 0, 0); // zerowanie przesunięcia i obrotu + std::string str; + // int size; + std::string subpath = Global::asCurrentSceneryPath; // "scenery/"; + cParser parser(File, cParser::buffer_FILE, subpath, Global::bLoadTraction); + std::string token; + + std::stack OriginStack; // stos zagnieżdżenia origin + + TGroundNode *LastNode = nullptr; // do użycia w trainset + token = ""; + parser.getTokens(); + parser >> token; + std::size_t processed = 0; + + while (token != "") //(!Parser->EndOfFile) + { + ++processed; + if( processed % 1000 == 0 ) + { + glfwPollEvents(); + UILayer.set_progress( parser.getProgress(), parser.getFullProgress() ); + GfxRenderer.Render(); + } + str = token; + if (str == "node") { + // rozpoznanie węzła + LastNode = AddGroundNode(&parser); + if (LastNode) { + // jeżeli przetworzony poprawnie + switch( LastNode->iType ) { + // validate the new node + case GL_TRIANGLES: { + if( true == LastNode->Piece->vertices.empty() ) { + SafeDelete( LastNode ); + } + break; + } + case TP_TRACTION: { + if( false == Global::bLoadTraction ) { + // usuwamy druty, jeśli wyłączone + SafeDelete( LastNode ); + } + break; + } +#ifndef EU07_SCENERY_EDITOR + case TP_TERRAIN: { + // convert legacy terrain model to a series of triangle nodes, to take advantage of camera-centric render and geometry merging + // NOTE: this leaves us with a large model we don't use loaded and taking space. it'll sort of solve itself when the binary scenery file is in place + convert_terrain( LastNode ); + SafeDelete( LastNode ); + Global::pTerrainCompact = nullptr; + } +#endif + default: { + break; + } + } + + if( LastNode ) { + // dopiero na koniec dopisujemy do tablic + if( LastNode->iType != TP_DYNAMIC ) { + // jeśli nie jest pojazdem ostatni dodany dołączamy na końcu nowego + LastNode->nNext = nRootOfType[ LastNode->iType ]; + // ustawienie nowego na początku listy + nRootOfType[ LastNode->iType ] = LastNode; + } + else { // jeśli jest pojazdem + if( ( LastNode->DynamicObject->Mechanik != nullptr ) + && ( LastNode->DynamicObject->Mechanik->Primary() ) ) { + // jeśli jest głównym (pasażer nie jest) + nTrainSetDriver = LastNode; // pojazd, któremu zostanie wysłany rozkład + } + LastNode->nNext = nRootDynamic; + nRootDynamic = LastNode; // dopisanie z przodu do listy + + if( nTrainSetNode != nullptr ) { + // jeżeli istnieje wcześniejszy TP_DYNAMIC + nTrainSetNode->DynamicObject->AttachPrev( + LastNode->DynamicObject, + TempConnectionType[ iTrainSetWehicleNumber - 2 ] ); + } + nTrainSetNode = LastNode; // ostatnio wczytany + + if( TempConnectionType[ iTrainSetWehicleNumber - 1 ] == 0 ) // jeśli sprzęg jest zerowy, to wysłać rozkład do składu + { // powinien też tu wchodzić, gdy pojazd bez trainset + if( nTrainSetDriver ) // pojazd, któremu zostanie wysłany rozkład + { // wysłanie komendy "Timetable" ustawia odpowiedni tryb jazdy + nTrainSetDriver->DynamicObject->Mechanik->DirectionInitial(); + nTrainSetDriver->DynamicObject->Mechanik->PutCommand( + "Timetable:" + asTrainName, + fTrainSetVel, 0, + nullptr ); + nTrainSetDriver = nullptr; // a przy "endtrainset" już wtedy nie potrzeba + } + } + } + } + } + else + { + ErrorLog("Bad node: node parsing error, encountered in file \"" + parser.Name() + "\" (line " + std::to_string( parser.Line() - 1 ) + ")"); + // break; + } + } + else if (str == "trainset") + { + iTrainSetWehicleNumber = 0; + nTrainSetNode = NULL; + nTrainSetDriver = NULL; // pojazd, któremu zostanie wysłany rozkład + bTrainSet = true; + parser.getTokens(); + parser >> token; + asTrainName = token; // McZapkie: rodzaj+nazwa pociagu w SRJP + parser.getTokens(); + parser >> token; + asTrainSetTrack = token; //ścieżka startowa + parser.getTokens(2); + parser >> fTrainSetDist >> fTrainSetVel; // przesunięcie i prędkość + } + else if (str == "endtrainset") + { // McZapkie-110103: sygnaly konca pociagu ale tylko dla pociagow rozkladowych + if (nTrainSetNode) // trainset bez dynamic się sypał + { // powinien też tu wchodzić, gdy pojazd bez trainset + if (nTrainSetDriver) // pojazd, któremu zostanie wysłany rozkład + { // wysłanie komendy "Timetable" ustawia odpowiedni tryb jazdy + nTrainSetDriver->DynamicObject->Mechanik->DirectionInitial(); + nTrainSetDriver->DynamicObject->Mechanik->PutCommand("Timetable:" + asTrainName, fTrainSetVel, 0, NULL); + } + } + if( LastNode ) { + // ostatni wczytany obiekt + if( LastNode->iType == TP_DYNAMIC ) { + // o ile jest pojazdem (na ogół jest, ale kto wie...) + if( ( iTrainSetWehicleNumber > 0 ) + && ( TempConnectionType[ iTrainSetWehicleNumber - 1 ] == 0 ) ) { + // jeśli ostatni pojazd ma sprzęg 0 to założymy mu końcówki blaszane + // (jak AI się odpali, to sobie poprawi) + LastNode->DynamicObject->RaLightsSet( -1, 2 + 32 + 64 ); + } + } + } + bTrainSet = false; + fTrainSetVel = 0; + nTrainSetNode = nTrainSetDriver = nullptr; + iTrainSetWehicleNumber = 0; + } + else if (str == "event") + { + TEvent *tmp = new TEvent(); + tmp->Load(&parser, pOrigin); + if (tmp->Type == tp_Unknown) + delete tmp; + else + { // najpierw sprawdzamy, czy nie ma, a potem dopisujemy + TEvent *found = FindEvent(tmp->asName); + if (found) + { // jeśli znaleziony duplikat + auto const size = tmp->asName.size(); + if( tmp->asName[0] == '#' ) // zawsze jeden znak co najmniej jest + { + delete tmp; + tmp = nullptr; + } // utylizacja duplikatu z krzyżykiem + else if( ( size > 8 ) + && ( tmp->asName.substr( 0, 9 ) == "lineinfo:" )) + // tymczasowo wyjątki + { + delete tmp; + tmp = nullptr; + } // tymczasowa utylizacja duplikatów W5 + else if( ( size > 8 ) + && ( tmp->asName.substr( size - 8 ) == "_warning")) + // tymczasowo wyjątki + { + delete tmp; + tmp = nullptr; + } // tymczasowa utylizacja duplikatu z trąbieniem + else if( ( size > 4 ) + && ( tmp->asName.substr( size - 4 ) == "_shp" )) + // nie podlegają logowaniu + { + delete tmp; + tmp = NULL; + } // tymczasowa utylizacja duplikatu SHP + if (tmp) // jeśli nie został zutylizowany + if (Global::bJoinEvents) + found->Append(tmp); // doczepka (taki wirtualny multiple bez warunków) + else + { + ErrorLog("Duplicated event: " + tmp->asName); + found->Append(tmp); // doczepka (taki wirtualny multiple bez warunków) + found->m_ignored = true; // dezaktywacja pierwotnego - taka proteza na + // wsteczną zgodność + // SafeDelete(tmp); //bezlitośnie usuwamy wszelkie duplikaty, żeby nie + // zaśmiecać drzewka + } + } + if ( nullptr != tmp ) + { // jeśli nie duplikat + tmp->evNext2 = RootEvent; // lista wszystkich eventów (m.in. do InitEvents) + RootEvent = tmp; + if (!found) + { // jeśli nazwa wystąpiła, to do kolejki i wyszukiwarki dodawany jest tylko pierwszy + if( ( RootEvent->m_ignored == false ) + && ( RootEvent->asName.find( "onstart" ) != std::string::npos ) ) { + // event uruchamiany automatycznie po starcie + AddToQuery( RootEvent, NULL ); // dodanie do kolejki + } + m_eventmap.emplace( tmp->asName, tmp ); // dodanie do wyszukiwarki + } + } + } + } + else if (str == "rotate") + { + // parser.getTokens(3); + // parser >> aRotate.x >> aRotate.y >> aRotate.z; //Ra: to potrafi dawać błędne rezultaty // ??? how so TODO: investigate + parser.getTokens(); + parser >> aRotate.x; + parser.getTokens(); + parser >> aRotate.y; + parser.getTokens(); + parser >> aRotate.z; + } + else if (str == "origin") + { + Math3D::vector3 offset; + parser.getTokens(3); + parser + >> offset.x + >> offset.y + >> offset.z; + // sumowanie całkowitego przesunięcia + OriginStack.emplace( + offset + ( + OriginStack.empty() ? + Math3D::vector3() : + OriginStack.top() ) ); + pOrigin = OriginStack.top(); + } + else if (str == "endorigin") + { + if( true == OriginStack.empty() ) { + // report error here + } + else { + OriginStack.pop(); + } + pOrigin = ( OriginStack.empty() ? + Math3D::vector3() : + OriginStack.top() ); + } + else if (str == "atmo") // TODO: uporzadkowac gdzie maja byc parametry mgly! + { // Ra: ustawienie parametrów OpenGL przeniesione do FirstInit + WriteLog("Scenery atmo definition"); + parser.getTokens(3); +/* + // disabled, no longer used + parser + >> Global::AtmoColor[0] + >> Global::AtmoColor[1] + >> Global::AtmoColor[2]; +*/ + parser.getTokens(2); + parser + >> Global::fFogStart + >> Global::fFogEnd; + if (Global::fFogEnd > 0.0) + { // ostatnie 3 parametry są opcjonalne + parser.getTokens(3); + parser + >> Global::FogColor[0] + >> Global::FogColor[1] + >> Global::FogColor[2]; + } + parser.getTokens(); + parser >> token; + if( token != "endatmo" ) { + // optional overcast parameter + // NOTE: parameter system needs some decent replacement, but not worth the effort if we're moving to built-in editor + Global::Overcast = clamp( std::stof( token ), 0.0f, 1.0f ); + } + while (token.compare("endatmo") != 0) + { // a kolejne parametry są pomijane + parser.getTokens(); + parser >> token; + } + } + else if (str == "time") + { + WriteLog("Scenery time definition"); + parser.getTokens(); + parser >> token; + + cParser timeparser( token ); + timeparser.getTokens( 2, false, ":" ); + auto &time = simulation::Time.data(); + timeparser + >> time.wHour + >> time.wMinute; + + // NOTE: we ignore old sunrise and sunset definitions, as they're now calculated dynamically + + while (token.compare("endtime") != 0) + { + parser.getTokens(); + parser >> token; + } + } + else if (str == "light") + { // Ra: ustawianie światła przeniesione do FirstInit + WriteLog("Scenery light definition"); + parser.getTokens(3, false); + parser + >> Global::DayLight.direction.x + >> Global::DayLight.direction.y + >> Global::DayLight.direction.z;; + Global::DayLight.direction = glm::normalize( Global::DayLight.direction ); + parser.getTokens(9, false); + + do { + parser.getTokens(); + parser >> token; + } while (token.compare("endlight") != 0); + } + else if (str == "camera") + { + vector3 xyz, abc; + xyz = abc = vector3(0, 0, 0); // wartości domyślne, bo nie wszystie muszą być + int i = -1, into = -1; // do której definicji kamery wstawić + WriteLog("Scenery camera definition"); + do + { // opcjonalna siódma liczba określa numer kamery, a kiedyś były tylko 3 + parser.getTokens(); + parser >> token; + switch (++i) + { // kiedyś camera miało tylko 3 współrzędne + case 0: + xyz.x = atof(token.c_str()); + break; + case 1: + xyz.y = atof(token.c_str()); + break; + case 2: + xyz.z = atof(token.c_str()); + break; + case 3: + abc.x = atof(token.c_str()); + break; + case 4: + abc.y = atof(token.c_str()); + break; + case 5: + abc.z = atof(token.c_str()); + break; + case 6: + into = atoi(token.c_str()); // takie sobie, bo można wpisać -1 + } + } while (token.compare("endcamera") != 0); + if (into < 0) + into = ++Global::iCameraLast; + if ((into >= 0) && (into < 10)) + { // przepisanie do odpowiedniego miejsca w tabelce + Global::FreeCameraInit[ into ] = xyz; + Global::FreeCameraInitAngle[ into ] = + Math3D::vector3( + DegToRad( abc.x ), + DegToRad( abc.y ), + DegToRad( abc.z ) ); + Global::iCameraLast = into; // numer ostatniej + } + } + else if (str == "sky") + { // youBy - niebo z pliku + WriteLog("Scenery sky definition"); + parser.getTokens(); + parser >> token; + std::string SkyTemp = token; + if (Global::asSky == "1") + Global::asSky = SkyTemp; + do + { // pożarcie dodatkowych parametrów + parser.getTokens(); + parser >> token; + } while (token.compare("endsky") != 0); + WriteLog(Global::asSky.c_str()); + } + else if (str == "firstinit") + FirstInit(); + else if (str == "description") + { + do + { + parser.getTokens(); + parser >> token; + } while (token.compare("enddescription") != 0); + } + else if (str == "test") + { // wypisywanie treści po przetworzeniu + WriteLog("---> Parser test:"); + do + { + parser.getTokens(); + parser >> token; + WriteLog(token.c_str()); + } while (token.compare("endtest") != 0); + WriteLog("---> End of parser test."); + } + else if (str == "config") + { // możliwość przedefiniowania parametrów w scenerii + Global::ConfigParse(parser); // parsowanie dodatkowych ustawień + } + else if (str != "") { + // pomijanie od nierozpoznanej komendy do jej zakończenia + if ((token.length() > 2) && (atof(token.c_str()) == 0.0)) { + // jeśli nie liczba, to spróbować pominąć komendę + WriteLog( "Unrecognized command: \"" + str + "\" encountered in file \"" + parser.Name() + "\" (line " + std::to_string( parser.Line() - 1 ) + ")" ); + str = "end" + str; + do + { + parser.getTokens(); + token = ""; + parser >> token; + } while ((token != "") && (token.compare(str.c_str()) != 0)); + } + else { + // jak liczba to na pewno błąd + ErrorLog( "Unrecognized command: \"" + str + "\" encountered in file \"" + parser.Name() + "\" (line " + std::to_string( parser.Line() - 1 ) + ")" ); + } + } + + token = ""; + parser.getTokens(); + parser >> token; + } + + if (!bInitDone) + FirstInit(); // jeśli nie było w scenerii + + if (Global::pTerrainCompact) + TerrainWrite(); // Ra: teraz można zapisać teren w jednym pliku + Global::iPause &= ~0x10; // koniec pauzy wczytywania + return true; +} + +bool TGround::InitEvents() +{ //łączenie eventów z pozostałymi obiektami + TGroundNode *tmp, *trk; + std::string cellastext; + int i; + for (TEvent *Current = RootEvent; Current; Current = Current->evNext2) + { + switch (Current->Type) + { + case tp_AddValues: // sumowanie wartości + case tp_UpdateValues: // zmiana wartości + tmp = FindGroundNode(Current->asNodeName, TP_MEMCELL); // nazwa komórki powiązanej z eventem + if (tmp) + { // McZapkie-100302 + if (Current->iFlags & (conditional_trackoccupied | conditional_trackfree)) + { // jeśli chodzi o zajetosc toru (tor może być inny, niż wpisany w komórce) + trk = FindGroundNode(Current->asNodeName, TP_TRACK); // nazwa toru ta sama, co nazwa komórki + if (trk) + Current->Params[9].asTrack = trk->pTrack; + if (!Current->Params[9].asTrack) + ErrorLog("Bad event: track \"" + Current->asNodeName + "\" referenced in event \"" + Current->asName + "\" doesn't exist"); + } + Current->Params[4].nGroundNode = tmp; + Current->Params[5].asMemCell = tmp->MemCell; // komórka do aktualizacji + if (Current->iFlags & (conditional_memcompare)) + Current->Params[9].asMemCell = tmp->MemCell; // komórka do badania warunku + if (!tmp->MemCell->asTrackName + .empty()) // tor powiązany z komórką powiązaną z eventem + { // tu potrzebujemy wskaźnik do komórki w (tmp) + trk = FindGroundNode(tmp->MemCell->asTrackName, TP_TRACK); + if (trk) + Current->Params[6].asTrack = trk->pTrack; + else + ErrorLog("Bad memcell: track \"" + tmp->MemCell->asTrackName + "\" referenced in memcell \"" + tmp->asName + "\" doesn't exist"); + } + else + Current->Params[6].asTrack = NULL; + } + else + { // nie ma komórki, to nie będzie działał poprawnie + Current->m_ignored = true; // deaktywacja + ErrorLog("Bad event: event \"" + Current->asName + "\" cannot find memcell \"" + Current->asNodeName + "\""); + } + break; + case tp_LogValues: // skojarzenie z memcell + if (Current->asNodeName.empty()) + { // brak skojarzenia daje logowanie wszystkich + Current->Params[9].asMemCell = NULL; + break; + } + case tp_GetValues: + case tp_WhoIs: + tmp = FindGroundNode(Current->asNodeName, TP_MEMCELL); + if (tmp) + { + Current->Params[8].nGroundNode = tmp; + Current->Params[9].asMemCell = tmp->MemCell; + if (Current->Type == tp_GetValues) // jeśli odczyt komórki + if (tmp->MemCell->IsVelocity()) // a komórka zawiera komendę SetVelocity albo + // ShuntVelocity + Current->bEnabled = false; // to event nie będzie dodawany do kolejki + } + else + { // nie ma komórki, to nie będzie działał poprawnie + Current->m_ignored = true; // deaktywacja + ErrorLog("Bad event: event \"" + Current->asName + "\" cannot find memcell \"" + Current->asNodeName + "\""); + } + break; + case tp_CopyValues: // skopiowanie komórki do innej + tmp = FindGroundNode(Current->asNodeName, TP_MEMCELL); // komórka docelowa + if (tmp) + { + Current->Params[4].nGroundNode = tmp; + Current->Params[5].asMemCell = tmp->MemCell; // komórka docelowa + if (!tmp->MemCell->asTrackName + .empty()) // tor powiązany z komórką powiązaną z eventem + { // tu potrzebujemy wskaźnik do komórki w (tmp) + trk = FindGroundNode(tmp->MemCell->asTrackName, TP_TRACK); + if (trk) + Current->Params[6].asTrack = trk->pTrack; + else + ErrorLog("Bad memcell: track \"" + tmp->MemCell->asTrackName + "\" referenced in memcell \"" + tmp->asName + "\" doesn't exists"); + } + else + Current->Params[6].asTrack = NULL; + } + else + ErrorLog("Bad event: copyvalues event \"" + Current->asName + "\" cannot find memcell \"" + Current->asNodeName + "\""); + cellastext = Current->Params[ 9 ].asText; + SafeDeleteArray(Current->Params[9].asText); // usunięcie nazwy komórki + tmp = FindGroundNode( cellastext, TP_MEMCELL); // komórka źódłowa + if (tmp != nullptr ) { + Current->Params[8].nGroundNode = tmp; + Current->Params[9].asMemCell = tmp->MemCell; // komórka źródłowa + } + else + ErrorLog("Bad event: copyvalues event \"" + Current->asName + "\" cannot find memcell \"" + cellastext + "\""); + break; + case tp_Animation: // animacja modelu + tmp = FindGroundNode(Current->asNodeName, TP_MODEL); // egzemplarza modelu do animowania + if (tmp) + { + cellastext = Current->Params[9].asText; // skopiowanie nazwy submodelu do bufora roboczego + SafeDeleteArray(Current->Params[9].asText); // usunięcie nazwy submodelu + if (Current->Params[0].asInt == 4) + Current->Params[9].asModel = tmp->Model; // model dla całomodelowych animacji + else + { // standardowo przypisanie submodelu + Current->Params[9].asAnimContainer = tmp->Model->GetContainer(cellastext); // submodel + if (Current->Params[9].asAnimContainer) + { + Current->Params[9].asAnimContainer->WillBeAnimated(); // oflagowanie + // animacji + if (!Current->Params[9] + .asAnimContainer->Event()) // nie szukać, gdy znaleziony + Current->Params[9].asAnimContainer->EventAssign( + FindEvent(Current->asNodeName + "." + cellastext + ":done")); + } + } + } + else + ErrorLog("Bad event: animation event \"" + Current->asName + "\" cannot find model \"" + Current->asNodeName + "\""); + Current->asNodeName = ""; + break; + case tp_Lights: // zmiana świeteł modelu + tmp = FindGroundNode(Current->asNodeName, TP_MODEL); + if (tmp) + Current->Params[9].asModel = tmp->Model; + else + ErrorLog("Bad event: lights event \"" + Current->asName + "\" cannot find model \"" + Current->asNodeName + "\""); + Current->asNodeName = ""; + break; + case tp_Visible: // ukrycie albo przywrócenie obiektu + tmp = FindGroundNode(Current->asNodeName, TP_MODEL); // najpierw model + if (!tmp) + tmp = FindGroundNode(Current->asNodeName, TP_TRACK); // albo tory? + if (!tmp) + tmp = FindGroundNode(Current->asNodeName, TP_TRACTION); // może druty? + if (tmp) + Current->Params[9].nGroundNode = tmp; + else + ErrorLog("Bad event: visibility event \"" + Current->asName + "\" cannot find item \"" + Current->asNodeName + "\""); + Current->asNodeName = ""; + break; + case tp_Switch: // przełożenie zwrotnicy albo zmiana stanu obrotnicy + tmp = FindGroundNode(Current->asNodeName, TP_TRACK); + if (tmp) + { // dowiązanie toru + if (!tmp->pTrack->iAction) // jeśli nie jest zwrotnicą ani obrotnicą + tmp->pTrack->iAction |= 0x100; // to będzie się zmieniał stan uszkodzenia + Current->Params[9].asTrack = tmp->pTrack; + if (!Current->Params[0].asInt) // jeśli przełącza do stanu 0 + if (Current->Params[2].asdouble >= + 0.0) // jeśli jest zdefiniowany dodatkowy ruch iglic + Current->Params[9].asTrack->Switch( + 0, Current->Params[1].asdouble, + Current->Params[2].asdouble); // przesłanie parametrów + } + else + ErrorLog("Bad event: switch event \"" + Current->asName + "\" cannot find track \"" + Current->asNodeName + "\""); + Current->asNodeName = ""; + break; + case tp_Sound: // odtworzenie dźwięku + tmp = FindGroundNode(Current->asNodeName, TP_SOUND); + if (tmp) + Current->Params[9].tsTextSound = tmp->tsStaticSound; + else + ErrorLog("Bad event: sound event \"" + Current->asName + "\" cannot find static sound \"" + Current->asNodeName + "\""); + Current->asNodeName = ""; + break; + case tp_TrackVel: // ustawienie prędkości na torze + if (!Current->asNodeName.empty()) + { + tmp = FindGroundNode(Current->asNodeName, TP_TRACK); + if (tmp) + { + tmp->pTrack->iAction |= + 0x200; // flaga zmiany prędkości toru jest istotna dla skanowania + Current->Params[9].asTrack = tmp->pTrack; + } + else + ErrorLog("Bad event: track velocity event \"" + Current->asName + "\" cannot find track \"" + Current->asNodeName + "\""); + } + Current->asNodeName = ""; + break; + case tp_DynVel: // komunikacja z pojazdem o konkretnej nazwie + if (Current->asNodeName == "activator") + Current->Params[9].asDynamic = NULL; + else + { + tmp = FindGroundNode(Current->asNodeName, TP_DYNAMIC); + if (tmp) + Current->Params[9].asDynamic = tmp->DynamicObject; + else + Error("Bad event: vehicle velocity event \"" + Current->asName + "\" cannot find vehicle \"" + Current->asNodeName + "\""); + } + Current->asNodeName = ""; + break; + case tp_Multiple: + if (Current->Params[9].asText != NULL) + { // przepisanie nazwy do bufora + cellastext = Current->Params[ 9 ].asText; + SafeDeleteArray(Current->Params[9].asText); + Current->Params[9].asPointer = NULL; // zerowanie wskaźnika, aby wykryć brak obeiktu + } + else + cellastext = ""; + if (Current->iFlags & (conditional_trackoccupied | conditional_trackfree)) + { // jeśli chodzi o zajetosc toru + tmp = FindGroundNode(cellastext, TP_TRACK); + if (tmp) + Current->Params[9].asTrack = tmp->pTrack; + if (!Current->Params[9].asTrack) + { + ErrorLog( "Bad event: multi-event \"" + Current->asName + "\" cannot find track \"" + cellastext + "\"" ); + Current->iFlags &= ~(conditional_trackoccupied | conditional_trackfree); // zerowanie flag + } + } + else if (Current->iFlags & (conditional_memstring | conditional_memval1 | conditional_memval2)) + { // jeśli chodzi o komorke pamieciową + tmp = FindGroundNode(cellastext, TP_MEMCELL); + if (tmp) + Current->Params[9].asMemCell = tmp->MemCell; + if (!Current->Params[9].asMemCell) + { + ErrorLog( "Bad event: multi-event \"" + Current->asName + "\" cannot find memory cell \"" + cellastext + "\"" ); + Current->iFlags &= ~(conditional_memstring | conditional_memval1 | conditional_memval2); + } + } + for (i = 0; i < 8; ++i) + { + if (Current->Params[i].asText != NULL) + { + cellastext = Current->Params[ i ].asText; + SafeDeleteArray(Current->Params[i].asText); + Current->Params[i].asEvent = FindEvent(cellastext); + if( !Current->Params[ i ].asEvent ) { + // Ra: tylko w logu informacja o braku + if( ( Current->Params[ i ].asText == NULL ) + || ( std::string( Current->Params[ i ].asText ).substr( 0, 5 ) != "none_" ) ) { + ErrorLog( "Bad event: multi-event \"" + Current->asName + "\" cannot find event \"" + cellastext + "\"" ); + } + } + } + } + break; + case tp_Voltage: // zmiana napięcia w zasilaczu (TractionPowerSource) + if (!Current->asNodeName.empty()) + { + tmp = FindGroundNode(Current->asNodeName, TP_TRACTIONPOWERSOURCE); // podłączenie zasilacza + if (tmp) + Current->Params[9].psPower = tmp->psTractionPowerSource; + else + ErrorLog("Bad event: voltage event \"" + Current->asName + "\" cannot find power source \"" + Current->asNodeName + "\""); + } + Current->asNodeName = ""; + break; + case tp_Message: // wyświetlenie komunikatu + break; + } + if (Current->fDelay < 0) + AddToQuery(Current, NULL); + } + for (TGroundNode *Current = nRootOfType[TP_MEMCELL]; Current; Current = Current->nNext) + { // Ra: eventy komórek pamięci, wykonywane po wysłaniu komendy do zatrzymanego pojazdu + Current->MemCell->AssignEvents(FindEvent(Current->asName + ":sent")); + } + return true; +} + +void TGround::InitTracks() +{ //łączenie torów ze sobą i z eventami + TGroundNode *Current, *Model; + TTrack *tmp; // znaleziony tor + TTrack *Track; + int iConnection; + + for (Current = nRootOfType[TP_TRACK]; Current; Current = Current->nNext) { + Track = Current->pTrack; + // assign track events + Track->AssignEvents( + FindEvent( Track->asEvent0Name ), + FindEvent( Track->asEvent1Name ), + FindEvent( Track->asEvent2Name ) ); + Track->AssignallEvents( + FindEvent( Track->asEventall0Name ), + FindEvent( Track->asEventall1Name ), + FindEvent( Track->asEventall2Name ) ); + if( ( Global::iHiddenEvents & 1 ) + && ( false == Current->asName.empty() ) ) { + // jeśli podana jest nazwa torów, można szukać eventów skojarzonych przez nazwę + Track->AssignEvents( + FindEvent( Current->asName + ":event0" ), + FindEvent( Current->asName + ":event1" ), + FindEvent( Current->asName + ":event2" ) ); + Track->AssignallEvents( + FindEvent( Current->asName + ":eventall0" ), + FindEvent( Current->asName + ":eventall1" ), + FindEvent( Current->asName + ":eventall2" ) ); + } + switch (Track->eType) + { + case tt_Table: // obrotnicę też łączymy na starcie z innymi torami + Model = FindGroundNode(Current->asName, TP_MODEL); // szukamy modelu o tej samej nazwie + // if (tmp) //mamy model, trzeba zapamiętać wskaźnik do jego animacji + { // jak coś pójdzie źle, to robimy z tego normalny tor + // Track->ModelAssign(tmp->Model->GetContainer(NULL)); //wiązanie toru z modelem + // obrotnicy +#ifdef EU07_USE_OLD_GROUNDCODE + Track->RaAssign( + Current, Model ? Model->Model : NULL, FindEvent( Current->asName + ":done" ), + FindEvent( Current->asName + ":joined" ) ); // wiązanie toru z modelem obrotnicy +#else + Track->RaAssign( + Current, Model ? Model->Model : NULL, simulation::Events.FindEvent(Current->asName + ":done"), + simulation::Events.FindEvent(Current->asName + ":joined")); // wiązanie toru z modelem obrotnicy +#endif + // break; //jednak połączę z sąsiednim, jak ma się wysypywać null track + } + if (!Model) // jak nie ma modelu + break; // to pewnie jest wykolejnica, a ta jest domyślnie zamknięta i wykoleja + case tt_Normal: // tylko proste są podłączane do rozjazdów, stąd dwa rozjazdy się nie + // połączą ze sobą + if (Track->CurrentPrev() == NULL) // tylko jeśli jeszcze nie podłączony + { + tmp = FindTrack(Track->CurrentSegment()->FastGetPoint_0(), iConnection, Current); + switch (iConnection) + { + case -1: // Ra: pierwsza koncepcja zawijania samochodów i statków + // if ((Track->iCategoryFlag&1)==0) //jeśli nie jest torem szynowym + // Track->ConnectPrevPrev(Track,0); //łączenie końca odcinka do samego siebie + break; + case 0: + Track->ConnectPrevPrev(tmp, 0); + break; + case 1: + Track->ConnectPrevNext(tmp, 1); + break; + case 2: + Track->ConnectPrevPrev(tmp, 0); // do Point1 pierwszego + tmp->SetConnections(0); // zapamiętanie ustawień w Segmencie + break; + case 3: + Track->ConnectPrevNext(tmp, 1); // do Point2 pierwszego + tmp->SetConnections(0); // zapamiętanie ustawień w Segmencie + break; + case 4: + tmp->Switch(1); + Track->ConnectPrevPrev(tmp, 2); // do Point1 drugiego + tmp->SetConnections(1); // robi też Switch(0) + tmp->Switch(0); + break; + case 5: + tmp->Switch(1); + Track->ConnectPrevNext(tmp, 3); // do Point2 drugiego + tmp->SetConnections(1); // robi też Switch(0) + tmp->Switch(0); + break; + } + } + if (Track->CurrentNext() == NULL) // tylko jeśli jeszcze nie podłączony + { + tmp = FindTrack(Track->CurrentSegment()->FastGetPoint_1(), iConnection, Current); + switch (iConnection) + { + case -1: // Ra: pierwsza koncepcja zawijania samochodów i statków + // if ((Track->iCategoryFlag&1)==0) //jeśli nie jest torem szynowym + // Track->ConnectNextNext(Track,1); //łączenie końca odcinka do samego siebie + break; + case 0: + Track->ConnectNextPrev(tmp, 0); + break; + case 1: + Track->ConnectNextNext(tmp, 1); + break; + case 2: + Track->ConnectNextPrev(tmp, 0); + tmp->SetConnections(0); // zapamiętanie ustawień w Segmencie + break; + case 3: + Track->ConnectNextNext(tmp, 1); + tmp->SetConnections(0); // zapamiętanie ustawień w Segmencie + break; + case 4: + tmp->Switch(1); + Track->ConnectNextPrev(tmp, 2); + tmp->SetConnections(1); // robi też Switch(0) + // tmp->Switch(0); + break; + case 5: + tmp->Switch(1); + Track->ConnectNextNext(tmp, 3); + tmp->SetConnections(1); // robi też Switch(0) + // tmp->Switch(0); + break; + } + } + break; + case tt_Switch: // dla rozjazdów szukamy eventów sygnalizacji rozprucia + Track->AssignForcedEvents( + FindEvent( Current->asName + ":forced+" ), + FindEvent( Current->asName + ":forced-" ) ); + break; + } + std::string const name = Track->IsolatedName(); // pobranie nazwy odcinka izolowanego + if( !name.empty() ) // jeśli została zwrócona nazwa + Track->IsolatedEventsAssign( + FindEvent( name + ":busy" ), + FindEvent( name + ":free" ) ); + // możliwy portal, jeśli nie podłączony od striny 1 + if (Current->asName.substr(0, 1) == "*") + if (!Track->CurrentPrev() && Track->CurrentNext()) + Track->iCategoryFlag |= 0x100; // ustawienie flagi portalu + } + // WriteLog("Total "+AnsiString(tracks)+", far "+AnsiString(tracksfar)); + TIsolated *p = TIsolated::Root(); + while (p) + { // jeśli się znajdzie, to podać wskaźnik + Current = FindGroundNode(p->asName, TP_MEMCELL); // czy jest komóka o odpowiedniej nazwie + if (Current) + p->pMemCell = Current->MemCell; // przypisanie powiązanej komórki + else + { // utworzenie automatycznej komórki + Current = new TGroundNode(); // to nie musi mieć nazwy, nazwa w wyszukiwarce wystarczy + // Current->asName=p->asName; //mazwa identyczna, jak nazwa odcinka izolowanego + Current->MemCell = new TMemCell(NULL); // nowa komórka + m_nodemap.Add( TP_MEMCELL, p->asName, Current ); + Current->nNext = + nRootOfType[TP_MEMCELL]; // to nie powinno tutaj być, bo robi się śmietnik + nRootOfType[TP_MEMCELL] = Current; + p->pMemCell = Current->MemCell; // wskaźnik komóki przekazany do odcinka izolowanego + } + p = p->Next(); + } +} + +void TGround::InitTraction() +{ //łączenie drutów ze sobą oraz z torami i eventami + TGroundNode *nCurrent, *nTemp; + TTraction *tmp; // znalezione przęsło + TTraction *Traction; + int iConnection; + std::string name; + for (nCurrent = nRootOfType[TP_TRACTION]; nCurrent; nCurrent = nCurrent->nNext) + { // podłączenie do zasilacza, żeby można było sumować prąd kilku pojazdów + // a jednocześnie z jednego miejsca zmieniać napięcie eventem + // wykonywane najpierw, żeby można było logować podłączenie 2 zasilaczy do jednego drutu + // izolator zawieszony na przęśle jest ma być osobnym odcinkiem drutu o długości ok. 1m, + // podłączonym do zasilacza o nazwie "*" (gwiazka); "none" nie będzie odpowiednie + Traction = nCurrent->hvTraction; + nTemp = FindGroundNode(Traction->asPowerSupplyName, TP_TRACTIONPOWERSOURCE); + if (nTemp) // jak zasilacz znaleziony + Traction->PowerSet(nTemp->psTractionPowerSource); // to podłączyć do przęsła + else if (Traction->asPowerSupplyName != "*") // gwiazdka dla przęsła z izolatorem + if (Traction->asPowerSupplyName != "none") // dopuszczamy na razie brak podłączenia? + { // logowanie błędu i utworzenie zasilacza o domyślnej zawartości + ErrorLog("Missed TractionPowerSource: " + Traction->asPowerSupplyName); + nTemp = new TGroundNode(); + nTemp->iType = TP_TRACTIONPOWERSOURCE; + nTemp->asName = Traction->asPowerSupplyName; + nTemp->psTractionPowerSource = new TTractionPowerSource(nTemp->asName); + nTemp->psTractionPowerSource->Init(Traction->NominalVoltage, Traction->MaxCurrent); + nTemp->nNext = nRootOfType[nTemp->iType]; // ostatni dodany dołączamy na końcu + // nowego + nRootOfType[nTemp->iType] = nTemp; // ustawienie nowego na początku listy + } + } + for (nCurrent = nRootOfType[TP_TRACTION]; nCurrent; nCurrent = nCurrent->nNext) + { + Traction = nCurrent->hvTraction; + if (!Traction->hvNext[0]) // tylko jeśli jeszcze nie podłączony + { + tmp = FindTraction(Traction->pPoint1, iConnection, nCurrent); + switch (iConnection) + { + case 0: + Traction->Connect(0, tmp, 0); + break; + case 1: + Traction->Connect(0, tmp, 1); + break; + } + if (Traction->hvNext[0]) // jeśli został podłączony + if (Traction->psSection && tmp->psSection) // tylko przęsło z izolatorem może nie + // mieć zasilania, bo ma 2, trzeba + // sprawdzać sąsiednie + if (Traction->psSection != + tmp->psSection) // połączone odcinki mają różne zasilacze + { // to może być albo podłączenie podstacji lub kabiny sekcyjnej do sekcji, albo + // błąd + if (Traction->psSection->bSection && !tmp->psSection->bSection) + { //(tmp->psSection) jest podstacją, a (Traction->psSection) nazwą sekcji + tmp->PowerSet(Traction->psSection); // zastąpienie wskazaniem sekcji + } + else if (!Traction->psSection->bSection && tmp->psSection->bSection) + { //(Traction->psSection) jest podstacją, a (tmp->psSection) nazwą sekcji + Traction->PowerSet(tmp->psSection); // zastąpienie wskazaniem sekcji + } + else // jeśli obie to sekcje albo obie podstacje, to będzie błąd + ErrorLog("Bad power: at " + + to_string(Traction->pPoint1.x, 2, 6) + " " + + to_string(Traction->pPoint1.y, 2, 6) + " " + + to_string(Traction->pPoint1.z, 2, 6)); + } + } + if (!Traction->hvNext[1]) // tylko jeśli jeszcze nie podłączony + { + tmp = FindTraction(Traction->pPoint2, iConnection, nCurrent); + switch (iConnection) + { + case 0: + Traction->Connect(1, tmp, 0); + break; + case 1: + Traction->Connect(1, tmp, 1); + break; + } + if (Traction->hvNext[1]) // jeśli został podłączony + if (Traction->psSection && tmp->psSection) // tylko przęsło z izolatorem może nie + // mieć zasilania, bo ma 2, trzeba + // sprawdzać sąsiednie + if (Traction->psSection != tmp->psSection) + { // to może być albo podłączenie podstacji lub kabiny sekcyjnej do sekcji, albo + // błąd + if (Traction->psSection->bSection && !tmp->psSection->bSection) + { //(tmp->psSection) jest podstacją, a (Traction->psSection) nazwą sekcji + tmp->PowerSet(Traction->psSection); // zastąpienie wskazaniem sekcji + } + else if (!Traction->psSection->bSection && tmp->psSection->bSection) + { //(Traction->psSection) jest podstacją, a (tmp->psSection) nazwą sekcji + Traction->PowerSet(tmp->psSection); // zastąpienie wskazaniem sekcji + } + else // jeśli obie to sekcje albo obie podstacje, to będzie błąd + ErrorLog("Bad power: at " + + to_string(Traction->pPoint2.x, 2, 6) + " " + + to_string(Traction->pPoint2.y, 2, 6) + " " + + to_string(Traction->pPoint2.z, 2, 6)); + } + } + } + iConnection = 0; // teraz będzie licznikiem końców + for (nCurrent = nRootOfType[TP_TRACTION]; nCurrent; nCurrent = nCurrent->nNext) + { // operacje mające na celu wykrywanie bieżni wspólnych i łączenie przęseł naprążania + if (nCurrent->hvTraction->WhereIs()) // oznakowanie przedostatnich przęseł + { // poszukiwanie bieżni wspólnej dla przedostatnich przęseł, również w celu połączenia + // zasilania + // to się nie sprawdza, bo połączyć się mogą dwa niezasilane odcinki jako najbliższe + // sobie + // nCurrent->hvTraction->hvParallel=TractionNearestFind(nCurrent->pCenter,0,nCurrent); + // //szukanie najbliższego przęsła + // trzeba by zliczać końce, a potem wpisać je do tablicy, aby sukcesywnie podłączać do + // zasilaczy + nCurrent->hvTraction->iTries = 5; // oznaczanie końcowych + ++iConnection; + } + if (nCurrent->hvTraction->fResistance[0] == 0.0) + { + nCurrent->hvTraction + ->ResistanceCalc(); // obliczanie przęseł w segmencie z bezpośrednim zasilaniem + // ErrorLog("Section "+nCurrent->hvTraction->asPowerSupplyName+" connected"); //jako + // niby błąd będzie bardziej widoczne + nCurrent->hvTraction->iTries = 0; // nie potrzeba mu szukać zasilania + } + // if (!Traction->hvParallel) //jeszcze utworzyć pętle z bieżni wspólnych + } + int zg = 0; // zgodność kierunku przęseł, tymczasowo iterator do tabeli końców + TGroundNode **nEnds = new TGroundNode *[iConnection]; // końców jest ok. 10 razy mniej niż + // wszystkich przęseł (Quark: 216) + for (nCurrent = nRootOfType[TP_TRACTION]; nCurrent; nCurrent = nCurrent->nNext) + { //łączenie bieżni wspólnych, w tym oznaczanie niepodanych jawnie + Traction = nCurrent->hvTraction; + if (!Traction->asParallel.empty()) // będzie wskaźnik na inne przęsło + if ((Traction->asParallel == "none") || + (Traction->asParallel == "*")) // jeśli nieokreślone + Traction->iLast = + 2; // jakby przedostatni - niech po prostu szuka (iLast już przeliczone) + else if (!Traction->hvParallel) // jeśli jeszcze nie został włączony w kółko + { + nTemp = FindGroundNode(Traction->asParallel, TP_TRACTION); + if (nTemp) + { // o ile zostanie znalezione przęsło o takiej nazwie + if (!nTemp->hvTraction + ->hvParallel) // jeśli tamten jeszcze nie ma wskaźnika bieżni wspólnej + Traction->hvParallel = + nTemp->hvTraction; // wpisać siebie i dalej dać mu wskaźnik zwrotny + else // a jak ma, to albo dołączyć się do kółeczka + Traction->hvParallel = + nTemp->hvTraction->hvParallel; // przjąć dotychczasowy wskaźnik od niego + nTemp->hvTraction->hvParallel = + Traction; // i na koniec ustawienie wskaźnika zwrotnego + } + if (!Traction->hvParallel) + ErrorLog("Missed overhead: " + Traction->asParallel); // logowanie braku + } + if (Traction->iTries == 5) // jeśli zaznaczony do podłączenia + // if (!nCurrent->hvTraction->psPower[0]||!nCurrent->hvTraction->psPower[1]) + if (zg < iConnection) // zabezpieczenie + nEnds[zg++] = nCurrent; // wypełnianie tabeli końców w celu szukania im połączeń + } + while (zg < iConnection) + nEnds[zg++] = NULL; // zapełnienie do końca tablicy, jeśli by jakieś końce wypadły + zg = 1; // nieefektywny przebieg kończy łączenie + while (zg) + { // ustalenie zastępczej rezystancji dla każdego przęsła + zg = 0; // flaga podłączonych przęseł końcowych: -1=puste wskaźniki, 0=coś zostało, + // 1=wykonano łączenie + for (int i = 0; i < iConnection; ++i) + if (nEnds[i]) // załatwione będziemy zerować + { // każdy przebieg to próba podłączenia końca segmentu naprężania do innego zasilanego + // przęsła + if (nEnds[i]->hvTraction->hvNext[0]) + { // jeśli końcowy ma ciąg dalszy od strony 0 (Point1), szukamy odcinka najbliższego + // do Point2 + if (TractionNearestFind(nEnds[i]->hvTraction->pPoint2, 0, + nEnds[i])) // poszukiwanie przęsła + { + nEnds[i] = NULL; + zg = 1; // jak coś zostało podłączone, to może zasilanie gdzieś dodatkowo + // dotrze + } + } + else if (nEnds[i]->hvTraction->hvNext[1]) + { // jeśli końcowy ma ciąg dalszy od strony 1 (Point2), szukamy odcinka najbliższego + // do Point1 + if (TractionNearestFind(nEnds[i]->hvTraction->pPoint1, 1, + nEnds[i])) // poszukiwanie przęsła + { + nEnds[i] = NULL; + zg = 1; // jak coś zostało podłączone, to może zasilanie gdzieś dodatkowo + // dotrze + } + } + else + { // gdy koniec jest samotny, to na razie nie zostanie podłączony (nie powinno + // takich być) + nEnds[i] = NULL; + } + } + } + delete[] nEnds; // nie potrzebne już +}; + +void TGround::TrackJoin(TGroundNode *Current) +{ // wyszukiwanie sąsiednich torów do podłączenia (wydzielone na użytek obrotnicy) + TTrack *Track = Current->pTrack; + TTrack *tmp; + int iConnection; + if (!Track->CurrentPrev()) + { + tmp = FindTrack(Track->CurrentSegment()->FastGetPoint_0(), iConnection, Current); // Current do pominięcia + switch (iConnection) + { + case 0: + Track->ConnectPrevPrev(tmp, 0); + break; + case 1: + Track->ConnectPrevNext(tmp, 1); + break; + } + } + if (!Track->CurrentNext()) + { + tmp = FindTrack(Track->CurrentSegment()->FastGetPoint_1(), iConnection, Current); + switch (iConnection) + { + case 0: + Track->ConnectNextPrev(tmp, 0); + break; + case 1: + Track->ConnectNextNext(tmp, 1); + break; + } + } +} + +// McZapkie-070602: wyzwalacze zdarzen +bool TGround::InitLaunchers() +{ + TGroundNode *Current, *tmp; + TEventLauncher *EventLauncher; + + for (Current = nRootOfType[TP_EVLAUNCH]; Current; Current = Current->nNext) + { + EventLauncher = Current->EvLaunch; + if (EventLauncher->iCheckMask != 0) + if (EventLauncher->asMemCellName != "none") + { // jeśli jest powiązana komórka pamięci + tmp = FindGroundNode(EventLauncher->asMemCellName, TP_MEMCELL); + if (tmp) + EventLauncher->MemCell = tmp->MemCell; // jeśli znaleziona, dopisać + else + MessageBox(0, "Cannot find Memory Cell for Event Launcher", "Error", MB_OK); + } + else + EventLauncher->MemCell = nullptr; + EventLauncher->Event1 = ( EventLauncher->asEvent1Name != "none") ? + FindEvent(EventLauncher->asEvent1Name) : + nullptr; + EventLauncher->Event2 = ( EventLauncher->asEvent2Name != "none") ? + FindEvent(EventLauncher->asEvent2Name) : + nullptr; + } + return true; +} + +TTrack * TGround::FindTrack(vector3 Point, int &iConnection, TGroundNode *Exclude) +{ // wyszukiwanie innego toru kończącego się w (Point) + TTrack *tmp; + iConnection = -1; + TSubRect *sr; + // najpierw szukamy w okolicznych segmentach + int c = GetColFromX(Point.x); + int r = GetRowFromZ(Point.z); + if ((sr = FastGetSubRect(c, r)) != NULL) // 75% torów jest w tym samym sektorze + if ((tmp = sr->FindTrack(&Point, iConnection, Exclude->pTrack)) != NULL) + return tmp; + int i, x, y; + for (i = 1; i < 9; + ++i) // sektory w kolejności odległości, 4 jest tu wystarczające, 9 na wszelki wypadek + { // niemal wszystkie podłączone tory znajdują się w sąsiednich 8 sektorach + x = SectorOrder[i].x; + y = SectorOrder[i].y; + if ((sr = FastGetSubRect(c + y, r + x)) != NULL) + if ((tmp = sr->FindTrack(&Point, iConnection, Exclude->pTrack)) != NULL) + return tmp; + if (x) + if ((sr = FastGetSubRect(c + y, r - x)) != NULL) + if ((tmp = sr->FindTrack(&Point, iConnection, Exclude->pTrack)) != NULL) + return tmp; + if (y) + if ((sr = FastGetSubRect(c - y, r + x)) != NULL) + if ((tmp = sr->FindTrack(&Point, iConnection, Exclude->pTrack)) != NULL) + return tmp; + if ((sr = FastGetSubRect(c - y, r - x)) != NULL) + if ((tmp = sr->FindTrack(&Point, iConnection, Exclude->pTrack)) != NULL) + return tmp; + } + return NULL; +} + +TTraction * TGround::FindTraction(glm::dvec3 const &Point, int &iConnection, TGroundNode *Exclude) +{ // wyszukiwanie innego przęsła kończącego się w (Point) + TTraction *tmp; + iConnection = -1; + TSubRect *sr; + // najpierw szukamy w okolicznych segmentach + int c = GetColFromX(Point.x); + int r = GetRowFromZ(Point.z); + if ((sr = FastGetSubRect(c, r)) != NULL) // większość będzie w tym samym sektorze + if ((tmp = sr->FindTraction(Point, iConnection, Exclude->hvTraction)) != NULL) + return tmp; + int i, x, y; + for (i = 1; i < 9; + ++i) // sektory w kolejności odległości, 4 jest tu wystarczające, 9 na wszelki wypadek + { // wszystkie przęsła powinny zostać znajdować się w sąsiednich 8 sektorach + x = SectorOrder[i].x; + y = SectorOrder[i].y; + if ((sr = FastGetSubRect(c + y, r + x)) != NULL) + if ((tmp = sr->FindTraction(Point, iConnection, Exclude->hvTraction)) != NULL) + return tmp; + if (x & y) + { + if ((sr = FastGetSubRect(c + y, r - x)) != NULL) + if ((tmp = sr->FindTraction(Point, iConnection, Exclude->hvTraction)) != NULL) + return tmp; + if ((sr = FastGetSubRect(c - y, r + x)) != NULL) + if ((tmp = sr->FindTraction(Point, iConnection, Exclude->hvTraction)) != NULL) + return tmp; + } + if ((sr = FastGetSubRect(c - y, r - x)) != NULL) + if ((tmp = sr->FindTraction(Point, iConnection, Exclude->hvTraction)) != NULL) + return tmp; + } + return NULL; +}; + +TTraction * TGround::TractionNearestFind(glm::dvec3 &p, int dir, TGroundNode *n) +{ // wyszukanie najbliższego do (p) przęsła o tej samej nazwie sekcji (ale innego niż podłączone) + // oraz zasilanego z kierunku (dir) + TGroundNode *nCurrent, *nBest = NULL; + int i, j, k, zg; + double d, dist = 200.0 * 200.0; //[m] odległość graniczna + // najpierw szukamy w okolicznych segmentach + int c = GetColFromX(n->pCenter.x); + int r = GetRowFromZ(n->pCenter.z); + TSubRect *sr; + for (i = -1; i <= 1; ++i) // przeglądamy 9 najbliższych sektorów + for (j = -1; j <= 1; ++j) // + if ((sr = FastGetSubRect(c + i, r + j)) != NULL) // o ile w ogóle sektor jest + for (nCurrent = sr->nRenderWires; nCurrent; nCurrent = nCurrent->nNext3) + if (nCurrent->iType == TP_TRACTION) + if (nCurrent->hvTraction->psSection == n->hvTraction->psSection) // jeśli ta sama sekcja + if (nCurrent != n) // ale nie jest tym samym + if (nCurrent->hvTraction != n->hvTraction->hvNext[0]) // ale nie jest bezpośrednio podłączonym + if (nCurrent->hvTraction != n->hvTraction->hvNext[1]) + if (nCurrent->hvTraction->psPower + [k = (glm::dot( + n->hvTraction->vParametric, + nCurrent->hvTraction->vParametric) >= 0 ? + dir ^ 1 : + dir)]) // ma zasilanie z odpowiedniej strony + if (nCurrent->hvTraction->fResistance[k] >= 0.0) { // żeby się nie propagowały jakieś ujemne + // znaleziony kandydat do połączenia + d = glm::length2( p - glm::dvec3{ nCurrent->pCenter } ); // kwadrat odległości środków + if (dist > d) { + // zapamiętanie nowego najbliższego + dist = d; // nowy rekord odległości + nBest = nCurrent; + zg = k; // z którego końca brać wskaźnik zasilacza + } + } + if (nBest) { + // jak znalezione przęsło z zasilaniem, to podłączenie "równoległe" + n->hvTraction->ResistanceCalc(dir, nBest->hvTraction->fResistance[zg], nBest->hvTraction->psPower[zg]); + } + return (nBest ? nBest->hvTraction : nullptr); +}; + +bool TGround::AddToQuery(TEvent *Event, TDynamicObject *Node) +{ + if( ( false == Event->m_ignored ) && ( true == Event->bEnabled ) ) { + // jeśli może być dodany do kolejki (nie używany w skanowaniu) + if( !Event->iQueued ) // jeśli nie dodany jeszcze do kolejki + { // kolejka eventów jest posortowana względem (fStartTime) + Event->Activator = Node; + if( ( Event->Type == tp_AddValues ) + && ( Event->fDelay == 0.0 ) ) { + // eventy AddValues trzeba wykonywać natychmiastowo, inaczej kolejka może zgubić jakieś dodawanie + // Ra: kopiowanie wykonania tu jest bez sensu, lepiej by było wydzielić funkcję + // wykonującą eventy i ją wywołać + if( EventConditon( Event ) ) { // teraz mogą być warunki do tych eventów + Event->Params[ 5 ].asMemCell->UpdateValues( + Event->Params[ 0 ].asText, Event->Params[ 1 ].asdouble, + Event->Params[ 2 ].asdouble, Event->iFlags ); + if( Event->Params[ 6 ].asTrack ) { // McZapkie-100302 - updatevalues oprocz zmiany wartosci robi putcommand dla + // wszystkich 'dynamic' na danym torze + for( auto dynamic : Event->Params[ 6 ].asTrack->Dynamics ) { + Event->Params[ 5 ].asMemCell->PutCommand( + dynamic->Mechanik, + &Event->Params[ 4 ].nGroundNode->pCenter ); + } + //if (DebugModeFlag) + WriteLog( + "EVENT EXECUTED" + ( Node ? ( " by " + Node->asName ) : "" ) + ": AddValues & Track command ( " + + std::string( Event->Params[ 0 ].asText ) + " " + + std::to_string( Event->Params[ 1 ].asdouble ) + " " + + std::to_string( Event->Params[ 2 ].asdouble ) + " )" ); + } + //else if (DebugModeFlag) + WriteLog( + "EVENT EXECUTED" + ( Node ? ( " by " + Node->asName ) : "" ) + ": AddValues ( " + + std::string( Event->Params[ 0 ].asText ) + " " + + std::to_string( Event->Params[ 1 ].asdouble ) + " " + + std::to_string( Event->Params[ 2 ].asdouble ) + " )" ); + } + // jeśli jest kolejny o takiej samej nazwie, to idzie do kolejki (and if there's no joint event it'll be set to null and processing will end here) + do { + Event = Event->evJoined; + // NOTE: we could've received a new event from joint event above, so we need to check conditions just in case and discard the bad events + // TODO: refactor this arrangement, it's hardly optimal + } while( ( Event != nullptr ) + && ( ( false == Event->bEnabled ) + || ( Event->iQueued > 0 ) ) ); + } + if( Event != nullptr ) { + // standardowe dodanie do kolejki + ++Event->iQueued; // zabezpieczenie przed podwójnym dodaniem do kolejki + WriteLog( "EVENT ADDED TO QUEUE" + ( Node ? ( " by " + Node->asName ) : "" ) + ": " + Event->asName ); + Event->fStartTime = std::abs( Event->fDelay ) + Timer::GetTime(); // czas od uruchomienia scenerii + if( Event->fRandomDelay > 0.0 ) { + // doliczenie losowego czasu opóźnienia + Event->fStartTime += Event->fRandomDelay * Random( 10000 ) * 0.0001; + } + if( QueryRootEvent != nullptr ) { + TEvent::AddToQuery( Event, QueryRootEvent ); + } + else { + QueryRootEvent = Event; + QueryRootEvent->evNext = nullptr; + } + } + } + } + return true; +} + +// sprawdzenie spelnienia warunków dla eventu +bool TGround::EventConditon(TEvent *e){ + + if (e->iFlags <= update_only) + return true; // bezwarunkowo + + if (e->iFlags & conditional_trackoccupied) + return (!e->Params[9].asTrack->IsEmpty()); + else if (e->iFlags & conditional_trackfree) + return (e->Params[9].asTrack->IsEmpty()); + else if (e->iFlags & conditional_propability) + { + double rprobability = Random(); + WriteLog("Random integer: " + std::to_string(rprobability) + " / " + std::to_string(e->Params[10].asdouble)); + return (e->Params[10].asdouble > rprobability); + } + else if( e->iFlags & conditional_memcompare ) { + // porównanie wartości + if( nullptr == e->Params[9].asMemCell ) { + + ErrorLog( "Event " + e->asName + " trying conditional_memcompare with nonexistent memcell" ); + return true; // though this is technically error, we report success to maintain backward compatibility + } + auto const comparisonresult = + tmpEvent->Params[ 9 ].asMemCell->Compare( + ( e->Params[ 10 ].asText != nullptr ? + e->Params[ 10 ].asText : + "" ), + e->Params[ 11 ].asdouble, + e->Params[ 12 ].asdouble, + e->iFlags ); + + std::string comparisonlog = "Type: MemCompare - "; + + comparisonlog += + "[" + e->Params[ 9 ].asMemCell->Text() + "]" + + " [" + to_string( e->Params[ 9 ].asMemCell->Value1(), 2 ) + "]" + + " [" + to_string( tmpEvent->Params[ 9 ].asMemCell->Value2(), 2 ) + "]"; + + comparisonlog += ( + true == comparisonresult ? + " == " : + " != " ); + + comparisonlog += ( + TestFlag( e->iFlags, conditional_memstring ) ? + "[" + std::string( tmpEvent->Params[ 10 ].asText ) + "]" : + "[*]" ); + comparisonlog += ( + TestFlag( tmpEvent->iFlags, conditional_memval1 ) ? + " [" + to_string( tmpEvent->Params[ 11 ].asdouble, 2 ) + "]" : + " [*]" ); + comparisonlog += ( + TestFlag( tmpEvent->iFlags, conditional_memval2 ) ? + " [" + to_string( tmpEvent->Params[ 12 ].asdouble, 2 ) + "]" : + " [*]" ); + + WriteLog( comparisonlog ); + return comparisonresult; + } + // unrecognized request + return false; +}; + +bool TGround::CheckQuery() +{ // sprawdzenie kolejki eventów oraz wykonanie tych, którym czas minął + TLocation loc; + int i; + while( ( QueryRootEvent != nullptr ) + && ( QueryRootEvent->fStartTime < Timer::GetTime() ) ) + { // eventy są posortowana wg czasu wykonania + tmpEvent = QueryRootEvent; // wyjęcie eventu z kolejki + if (QueryRootEvent->evJoined) // jeśli jest kolejny o takiej samej nazwie + { // to teraz on będzie następny do wykonania + QueryRootEvent = QueryRootEvent->evJoined; // następny będzie ten doczepiony + QueryRootEvent->evNext = tmpEvent->evNext; // pamiętając o następnym z kolejki + QueryRootEvent->fStartTime = tmpEvent->fStartTime; // czas musi być ten sam, bo nie jest aktualizowany + QueryRootEvent->Activator = tmpEvent->Activator; // pojazd aktywujący + QueryRootEvent->iQueued = 1; + // w sumie można by go dodać normalnie do kolejki, ale trzeba te połączone posortować wg czasu wykonania + } + else // a jak nazwa jest unikalna, to kolejka idzie dalej + QueryRootEvent = QueryRootEvent->evNext; // NULL w skrajnym przypadku + if( ( false == tmpEvent->m_ignored ) && ( true == tmpEvent->bEnabled ) ) { + // w zasadzie te wyłączone są skanowane i nie powinny się nigdy w kolejce znaleźć + --tmpEvent->iQueued; // teraz moze być ponownie dodany do kolejki + WriteLog( "EVENT LAUNCHED" + ( tmpEvent->Activator ? ( " by " + tmpEvent->Activator->asName ) : "" ) + ": " + tmpEvent->asName ); + switch (tmpEvent->Type) + { + case tp_CopyValues: // skopiowanie wartości z innej komórki + tmpEvent->Params[5].asMemCell->UpdateValues( + tmpEvent->Params[9].asMemCell->Text(), + tmpEvent->Params[9].asMemCell->Value1(), + tmpEvent->Params[9].asMemCell->Value2(), + tmpEvent->iFlags // flagi określają, co ma być skopiowane + ); + // break; //żeby się wysłało do torów i nie było potrzeby na AddValues * 0 0 + case tp_AddValues: // różni się jedną flagą od UpdateValues + case tp_UpdateValues: + if (EventConditon(tmpEvent)) + { // teraz mogą być warunki do tych eventów + if (tmpEvent->Type != tp_CopyValues) // dla CopyValues zrobiło się wcześniej + tmpEvent->Params[5].asMemCell->UpdateValues( + tmpEvent->Params[0].asText, + tmpEvent->Params[1].asdouble, + tmpEvent->Params[2].asdouble, + tmpEvent->iFlags); + if (tmpEvent->Params[6].asTrack) + { // McZapkie-100302 - updatevalues oprocz zmiany wartosci robi putcommand dla + // wszystkich 'dynamic' na danym torze + for( auto dynamic : tmpEvent->Params[ 6 ].asTrack->Dynamics ) { + tmpEvent->Params[ 5 ].asMemCell->PutCommand( + dynamic->Mechanik, + &tmpEvent->Params[ 4 ].nGroundNode->pCenter ); + } + //if (DebugModeFlag) + WriteLog("Type: UpdateValues & Track command - [" + + tmpEvent->Params[5].asMemCell->Text() + "] [" + + to_string( tmpEvent->Params[ 5 ].asMemCell->Value1(), 2 ) + "] [" + + to_string( tmpEvent->Params[ 5 ].asMemCell->Value2(), 2 ) + "]" ); + } + else //if (DebugModeFlag) + WriteLog("Type: UpdateValues - [" + + tmpEvent->Params[5].asMemCell->Text() + "] [" + + to_string( tmpEvent->Params[ 5 ].asMemCell->Value1(), 2 ) + "] [" + + to_string( tmpEvent->Params[ 5 ].asMemCell->Value2(), 2 ) + "]" ); + } + break; + case tp_GetValues: + if (tmpEvent->Activator) + { + // loc.X= -tmpEvent->Params[8].nGroundNode->pCenter.x; + // loc.Y= tmpEvent->Params[8].nGroundNode->pCenter.z; + // loc.Z= tmpEvent->Params[8].nGroundNode->pCenter.y; + if (Global::iMultiplayer) // potwierdzenie wykonania dla serwera (odczyt + // semafora już tak nie działa) + multiplayer::WyslijEvent(tmpEvent->asName, tmpEvent->Activator->name()); + // tmpEvent->Params[9].asMemCell->PutCommand(tmpEvent->Activator->Mechanik,loc); + tmpEvent->Params[9].asMemCell->PutCommand( + tmpEvent->Activator->Mechanik, &tmpEvent->Params[8].nGroundNode->pCenter); + } + WriteLog("Type: GetValues"); + break; + case tp_PutValues: + if (tmpEvent->Activator) { + // zamiana, bo fizyka ma inaczej niż sceneria + loc.X = -tmpEvent->Params[3].asdouble; + loc.Y = tmpEvent->Params[5].asdouble; + loc.Z = tmpEvent->Params[4].asdouble; + if (tmpEvent->Activator->Mechanik) // przekazanie rozkazu do AI + tmpEvent->Activator->Mechanik->PutCommand( + tmpEvent->Params[0].asText, tmpEvent->Params[1].asdouble, + tmpEvent->Params[2].asdouble, loc); + else { + // przekazanie do pojazdu + tmpEvent->Activator->MoverParameters->PutCommand( + tmpEvent->Params[0].asText, tmpEvent->Params[1].asdouble, + tmpEvent->Params[2].asdouble, loc); + } + WriteLog("Type: PutValues - [" + + std::string(tmpEvent->Params[0].asText) + "] [" + + to_string( tmpEvent->Params[ 1 ].asdouble, 2 ) + "] [" + + to_string( tmpEvent->Params[ 2 ].asdouble, 2 ) + "]" ); + } + break; + case tp_Lights: + if (tmpEvent->Params[9].asModel) + for (i = 0; i < iMaxNumLights; i++) + if (tmpEvent->Params[i].asdouble >= 0) //-1 zostawia bez zmiany + tmpEvent->Params[9].asModel->LightSet( + i, tmpEvent->Params[i].asdouble); // teraz też ułamek + break; + case tp_Visible: + if (tmpEvent->Params[9].nGroundNode) + tmpEvent->Params[9].nGroundNode->bVisible = (tmpEvent->Params[i].asInt > 0); + break; + case tp_Velocity: + Error("Not implemented yet :("); + break; + case tp_Exit: + MessageBox(0, tmpEvent->asNodeName.c_str(), " THE END ", MB_OK); + Global::iTextMode = -1; // wyłączenie takie samo jak sekwencja F10 -> Y + return false; + case tp_Sound: + switch (tmpEvent->Params[0].asInt) + { // trzy możliwe przypadki: + case 0: + tmpEvent->Params[9].tsTextSound->Stop(); + break; + case 1: + tmpEvent->Params[9].tsTextSound->Play( + 1, 0, true, tmpEvent->Params[9].tsTextSound->vSoundPosition); + break; + case -1: + tmpEvent->Params[9].tsTextSound->Play( + 1, DSBPLAY_LOOPING, true, tmpEvent->Params[9].tsTextSound->vSoundPosition); + break; + } + break; + case tp_Disable: + Error("Not implemented yet :("); + break; + case tp_Animation: // Marcin: dorobic translacje - Ra: dorobiłem ;-) + if (tmpEvent->Params[0].asInt == 1) + tmpEvent->Params[9].asAnimContainer->SetRotateAnim( + vector3(tmpEvent->Params[1].asdouble, tmpEvent->Params[2].asdouble, + tmpEvent->Params[3].asdouble), + tmpEvent->Params[4].asdouble); + else if (tmpEvent->Params[0].asInt == 2) + tmpEvent->Params[9].asAnimContainer->SetTranslateAnim( + vector3(tmpEvent->Params[1].asdouble, tmpEvent->Params[2].asdouble, + tmpEvent->Params[3].asdouble), + tmpEvent->Params[4].asdouble); + else if (tmpEvent->Params[0].asInt == 4) + tmpEvent->Params[9].asModel->AnimationVND( + tmpEvent->Params[8].asPointer, + tmpEvent->Params[1].asdouble, // tu mogą być dodatkowe parametry, np. od-do + tmpEvent->Params[2].asdouble, tmpEvent->Params[3].asdouble, + tmpEvent->Params[4].asdouble); + break; + case tp_Switch: + if (tmpEvent->Params[9].asTrack) + tmpEvent->Params[9].asTrack->Switch(tmpEvent->Params[0].asInt, + tmpEvent->Params[1].asdouble, + tmpEvent->Params[2].asdouble); + if (Global::iMultiplayer) // dajemy znać do serwera o przełożeniu + multiplayer::WyslijEvent(tmpEvent->asName, ""); // wysłanie nazwy eventu przełączajacego + // Ra: bardziej by się przydała nazwa toru, ale nie ma do niej stąd dostępu + break; + case tp_TrackVel: + if (tmpEvent->Params[9].asTrack) + { // prędkość na zwrotnicy może być ograniczona z góry we wpisie, większej się nie + // ustawi eventem + WriteLog("Type: TrackVel"); + tmpEvent->Params[9].asTrack->VelocitySet(tmpEvent->Params[0].asdouble); + if (DebugModeFlag) // wyświetlana jest ta faktycznie ustawiona + WriteLog(" - velocity: ", tmpEvent->Params[9].asTrack->VelocityGet()); + } + break; + case tp_DynVel: + Error("Event \"DynVel\" is obsolete"); + break; + case tp_Multiple: + { + bCondition = EventConditon(tmpEvent); + if (bCondition || (tmpEvent->iFlags & + conditional_anyelse)) // warunek spelniony albo było użyte else + { + WriteLog("Type: Multi-event"); + for (i = 0; i < 8; ++i) { + // dodawane do kolejki w kolejności zapisania + if( tmpEvent->Params[ i ].asEvent ) { + if( bCondition != ( ( ( tmpEvent->iFlags & ( conditional_else << i ) ) != 0 ) ) ) { + if( tmpEvent->Params[ i ].asEvent != tmpEvent ) + AddToQuery( tmpEvent->Params[ i ].asEvent, tmpEvent->Activator ); // normalnie dodać + else { + // jeśli ma być rekurencja to musi mieć sensowny okres powtarzania + if( tmpEvent->fDelay >= 5.0 ) { + AddToQuery( tmpEvent, tmpEvent->Activator ); + } + } + } + } + } + if (Global::iMultiplayer) // dajemy znać do serwera o wykonaniu + if ((tmpEvent->iFlags & conditional_anyelse) == + 0) // jednoznaczne tylko, gdy nie było else + { + if (tmpEvent->Activator) + multiplayer::WyslijEvent(tmpEvent->asName, tmpEvent->Activator->name()); + else + multiplayer::WyslijEvent(tmpEvent->asName, ""); + } + } + } + break; + case tp_WhoIs: { + // pobranie nazwy pociągu do komórki pamięci + if (tmpEvent->iFlags & update_load) { + // jeśli pytanie o ładunek + if( tmpEvent->iFlags & update_memadd ) { + // jeśli typ pojazdu + // TODO: define and recognize individual request types + auto const owner = ( + ( ( tmpEvent->Activator->Mechanik != nullptr ) && ( tmpEvent->Activator->Mechanik->Primary() ) ) ? + tmpEvent->Activator->Mechanik : + tmpEvent->Activator->ctOwner ); + auto const consistbrakelevel = ( + owner != nullptr ? + owner->fReady : + -1.0 ); + auto const collisiondistance = ( + owner != nullptr ? + owner->TrackBlock() : + -1.0 ); + + tmpEvent->Params[ 9 ].asMemCell->UpdateValues( + tmpEvent->Activator->MoverParameters->TypeName, // typ pojazdu + consistbrakelevel, + collisiondistance, + tmpEvent->iFlags & ( update_memstring | update_memval1 | update_memval2 ) ); + + WriteLog( + "Type: WhoIs (" + to_string( tmpEvent->iFlags ) + ") - " + + "[name: " + tmpEvent->Activator->MoverParameters->TypeName + "], " + + "[consist brake level: " + to_string( consistbrakelevel, 2 ) + "], " + + "[obstacle distance: " + to_string( collisiondistance, 2 ) + " m]" ); + } + else { + // jeśli parametry ładunku + tmpEvent->Params[ 9 ].asMemCell->UpdateValues( + tmpEvent->Activator->MoverParameters->LoadType, // nazwa ładunku + tmpEvent->Activator->MoverParameters->Load, // aktualna ilość + tmpEvent->Activator->MoverParameters->MaxLoad, // maksymalna ilość + tmpEvent->iFlags & ( update_memstring | update_memval1 | update_memval2 ) ); + + WriteLog( + "Type: WhoIs (" + to_string( tmpEvent->iFlags ) + ") - " + + "[load type: " + tmpEvent->Activator->MoverParameters->LoadType + "], " + + "[current load: " + to_string( tmpEvent->Activator->MoverParameters->Load, 2 ) + "], " + + "[max load: " + to_string( tmpEvent->Activator->MoverParameters->MaxLoad, 2 ) + "]" ); + } + } + else if (tmpEvent->iFlags & update_memadd) + { // jeśli miejsce docelowe pojazdu + tmpEvent->Params[ 9 ].asMemCell->UpdateValues( + tmpEvent->Activator->asDestination, // adres docelowy + tmpEvent->Activator->DirectionGet(), // kierunek pojazdu względem czoła składu (1=zgodny,-1=przeciwny) + tmpEvent->Activator->MoverParameters->Power, // moc pojazdu silnikowego: 0 dla wagonu + tmpEvent->iFlags & (update_memstring | update_memval1 | update_memval2)); + + WriteLog( + "Type: WhoIs (" + to_string( tmpEvent->iFlags ) + ") - " + + "[destination: " + tmpEvent->Activator->asDestination + "], " + + "[direction: " + to_string( tmpEvent->Activator->DirectionGet() ) + "], " + + "[engine power: " + to_string( tmpEvent->Activator->MoverParameters->Power, 2 ) + "]" ); + } + else if (tmpEvent->Activator->Mechanik) + if (tmpEvent->Activator->Mechanik->Primary()) + { // tylko jeśli ktoś tam siedzi - nie powinno dotyczyć pasażera! + tmpEvent->Params[ 9 ].asMemCell->UpdateValues( + tmpEvent->Activator->Mechanik->TrainName(), + tmpEvent->Activator->Mechanik->StationCount() - tmpEvent->Activator->Mechanik->StationIndex(), // ile przystanków do końca + tmpEvent->Activator->Mechanik->IsStop() ? 1 : + 0, // 1, gdy ma tu zatrzymanie + tmpEvent->iFlags); + WriteLog("Train detected: " + tmpEvent->Activator->Mechanik->TrainName()); + } + break; + } + case tp_LogValues: // zapisanie zawartości komórki pamięci do logu + if (tmpEvent->Params[9].asMemCell) // jeśli była podana nazwa komórki + WriteLog("Memcell \"" + tmpEvent->asNodeName + "\": " + + tmpEvent->Params[9].asMemCell->Text() + " " + + std::to_string(tmpEvent->Params[9].asMemCell->Value1()) + " " + + std::to_string(tmpEvent->Params[9].asMemCell->Value2())); + else // lista wszystkich + for (TGroundNode *Current = nRootOfType[TP_MEMCELL]; Current; + Current = Current->nNext) + WriteLog("Memcell \"" + Current->asName + "\": " + + Current->MemCell->Text() + " " + std::to_string(Current->MemCell->Value1()) + " " + + std::to_string(Current->MemCell->Value2())); + break; + case tp_Voltage: // zmiana napięcia w zasilaczu (TractionPowerSource) + if (tmpEvent->Params[9].psPower) + { // na razie takie chamskie ustawienie napięcia zasilania + WriteLog("Type: Voltage"); + tmpEvent->Params[9].psPower->VoltageSet(tmpEvent->Params[0].asdouble); + } + case tp_Friction: // zmiana tarcia na scenerii + { // na razie takie chamskie ustawienie napięcia zasilania + WriteLog("Type: Friction"); + Global::fFriction = (tmpEvent->Params[0].asdouble); + } + break; + case tp_Message: // wyświetlenie komunikatu + break; + } // switch (tmpEvent->Type) + } // if (tmpEvent->bEnabled) + } // while + return true; +} + +void TGround::UpdatePhys(double dt, int iter) +{ // aktualizacja fizyki stałym krokiem: dt=krok czasu [s], dt*iter=czas od ostatnich przeliczeń + for (TGroundNode *Current = nRootOfType[TP_TRACTIONPOWERSOURCE]; Current; + Current = Current->nNext) + Current->psTractionPowerSource->Update(dt * iter); // zerowanie sumy prądów +}; + +bool TGround::Update(double dt, int iter) +{ // aktualizacja animacji krokiem FPS: dt=krok czasu [s], dt*iter=czas od ostatnich przeliczeń + if (dt == 0.0) + { // jeśli załączona jest pauza, to tylko obsłużyć ruch w kabinie trzeba + return true; + } + // Ra: w zasadzie to trzeba by utworzyć oddzielną listę taboru do liczenia fizyki + // na którą by się zapisywały wszystkie pojazdy będące w ruchu + // pojazdy stojące nie potrzebują aktualizacji, chyba że np. ktoś im zmieni nastawę hamulca + // oddzielną listę można by zrobić na pojazdy z napędem, najlepiej posortowaną wg typu napędu + if (iter > 1) // ABu: ponizsze wykonujemy tylko jesli wiecej niz jedna iteracja + { // pierwsza iteracja i wyznaczenie stalych: + for (TGroundNode *Current = nRootDynamic; Current; Current = Current->nNext) + { // + Current->DynamicObject->MoverParameters->ComputeConstans(); + Current->DynamicObject->CoupleDist(); + Current->DynamicObject->UpdateForce(dt, dt, false); + } + for (TGroundNode *Current = nRootDynamic; Current; Current = Current->nNext) + Current->DynamicObject->FastUpdate(dt); + // pozostale iteracje + for (int i = 1; i < (iter - 1); ++i) // jeśli iter==5, to wykona się 3 razy + { + for (TGroundNode *Current = nRootDynamic; Current; Current = Current->nNext) + Current->DynamicObject->UpdateForce(dt, dt, false); + for (TGroundNode *Current = nRootDynamic; Current; Current = Current->nNext) + Current->DynamicObject->FastUpdate(dt); + } + // ABu 200205: a to robimy tylko raz, bo nie potrzeba więcej + // Winger 180204 - pantografy + double dt1 = dt * iter; // całkowity czas + UpdatePhys(dt1, 1); + TAnimModel::AnimUpdate(dt1); // wykonanie zakolejkowanych animacji + for (TGroundNode *Current = nRootDynamic; Current; Current = Current->nNext) + { // Ra: zmienić warunek na sprawdzanie pantografów w jednej zmiennej: czy pantografy i czy + // podniesione + if (Current->DynamicObject->MoverParameters->EnginePowerSource.SourceType == + CurrentCollector) + GetTraction(Current->DynamicObject); // poszukiwanie drutu dla pantografów + Current->DynamicObject->UpdateForce(dt, dt1, true); //,true); + } + for (TGroundNode *Current = nRootDynamic; Current; Current = Current->nNext) + Current->DynamicObject->Update(dt, dt1); // Ra 2015-01: tylko tu przelicza sieć + // trakcyjną + } + else + { // jezeli jest tylko jedna iteracja + UpdatePhys(dt, 1); + TAnimModel::AnimUpdate(dt); // wykonanie zakolejkowanych animacji + for (TGroundNode *Current = nRootDynamic; Current; Current = Current->nNext) + { + if (Current->DynamicObject->MoverParameters->EnginePowerSource.SourceType == + CurrentCollector) + GetTraction(Current->DynamicObject); + Current->DynamicObject->MoverParameters->ComputeConstans(); + Current->DynamicObject->CoupleDist(); + Current->DynamicObject->UpdateForce(dt, dt, true); //,true); + } + for (TGroundNode *Current = nRootDynamic; Current; Current = Current->nNext) + Current->DynamicObject->Update(dt, dt); // Ra 2015-01: tylko tu przelicza sieć trakcyjną + } + if (TDynamicObject::bDynamicRemove) + { // jeśli jest coś do usunięcia z listy, to trzeba na końcu + for (TGroundNode *Current = nRootDynamic; Current; Current = Current->nNext) + if ( false == Current->DynamicObject->bEnabled) + { + DynamicRemove(Current->DynamicObject); // usunięcie tego i podłączonych + Current = nRootDynamic; // sprawdzanie listy od początku + } + TDynamicObject::bDynamicRemove = false; // na razie koniec + } + return true; +}; + +void +TGround::Update_Hidden() { + + // rednerowanie globalnych (nie za często?) + for( TGroundNode *node = srGlobal.nRenderHidden; node; node = node->nNext3 ) { + node->RenderHidden(); + } + + // render events and sounds from sectors near enough to the viewer + auto const range = 2750.0; // audible range of 100 db sound + int const camerax = static_cast( std::floor( Global::pCameraPosition.x / 1000.0 ) + iNumRects / 2 ); + int const cameraz = static_cast( std::floor( Global::pCameraPosition.z / 1000.0 ) + iNumRects / 2 ); + int const segmentcount = 2 * static_cast( std::ceil( range / 1000.0 ) ); + int const originx = std::max( 0, camerax - segmentcount / 2 ); + int const originz = std::max( 0, cameraz - segmentcount / 2 ); + + for( int column = originx; column <= originx + segmentcount; ++column ) { + for( int row = originz; row <= originz + segmentcount; ++row ) { + + auto &cell = Rects[ column ][ row ]; + + for( int subcellcolumn = 0; subcellcolumn < iNumSubRects; ++subcellcolumn ) { + for( int subcellrow = 0; subcellrow < iNumSubRects; ++subcellrow ) { + auto subcell = cell.FastGetSubRect( subcellcolumn, subcellrow ); + if( subcell == nullptr ) { continue; } + // renderowanie obiektów aktywnych a niewidocznych + for( auto node = subcell->nRenderHidden; node; node = node->nNext3 ) { + node->RenderHidden(); + } + // jeszcze dźwięki pojazdów by się przydały, również niewidocznych + // TODO: move to sound renderer + subcell->RenderSounds(); + } + } + } + } +} + +// Winger 170204 - szukanie trakcji nad pantografami +bool TGround::GetTraction(TDynamicObject *model) +{ // aktualizacja drutu zasilającego dla każdego pantografu, żeby odczytać napięcie + // jeśli pojazd się nie porusza, to nie ma sensu przeliczać tego więcej niż raz + double fRaParam; // parametr równania parametrycznego odcinka drutu + double fVertical; // odległość w pionie; musi być w zasięgu ruchu "pionowego" pantografu + double fHorizontal; // odległość w bok; powinna być mniejsza niż pół szerokości pantografu + glm::dvec3 vLeft, vUp, vFront, dwys; + glm::dvec3 pant0; + glm::dvec3 vParam; // współczynniki równania parametrycznego drutu + glm::dvec3 vStyk; // punkt przebicia drutu przez płaszczyznę ruchu pantografu + glm::dvec3 vGdzie; // wektor położenia drutu względem pojazdu + vFront = glm::make_vec3(model->VectorFront().getArray()); // wektor normalny dla płaszczyzny ruchu pantografu + vUp = glm::make_vec3(model->VectorUp().getArray()); // wektor pionu pudła (pochylony od pionu na przechyłce) + vLeft = glm::make_vec3(model->VectorLeft().getArray()); // wektor odległości w bok (odchylony od poziomu na przechyłce) + auto const position = model->GetPosition(); // współrzędne środka pojazdu + dwys = glm::dvec3( position.x, position.y, position.z ); + TAnimPant *p; // wskaźnik do obiektu danych pantografu + for (int k = 0; k < model->iAnimType[ANIM_PANTS]; ++k) + { // pętla po pantografach + p = model->pants[k].fParamPants; + if (k ? model->MoverParameters->PantRearUp : model->MoverParameters->PantFrontUp) + { // jeśli pantograf podniesiony + pant0 = dwys + (vLeft * p->vPos.z) + (vUp * p->vPos.y) + (vFront * p->vPos.x); + if (p->hvPowerWire) + { // jeżeli znamy drut z poprzedniego przebiegu + int n = 30; //żeby się nie zapętlił + while (p->hvPowerWire) + { // powtarzane aż do znalezienia odpowiedniego odcinka na liście dwukierunkowej + // obliczamy wyraz wolny równania płaszczyzny (to miejsce nie jest odpowienie) + vParam = p->hvPowerWire->vParametric; // współczynniki równania parametrycznego + fRaParam = -glm::dot(pant0, vFront); + // podstawiamy równanie parametryczne drutu do równania płaszczyzny pantografu + // vFront.x*(t1x+t*vParam.x)+vFront.y*(t1y+t*vParam.y)+vFront.z*(t1z+t*vParam.z)+fRaDist=0; + fRaParam = -(glm::dot(p->hvPowerWire->pPoint1, vFront) + fRaParam) / + glm::dot(vParam, vFront); + if (fRaParam < + -0.001) // histereza rzędu 7cm na 70m typowego przęsła daje 1 promil + p->hvPowerWire = p->hvPowerWire->hvNext[0]; + else if (fRaParam > 1.001) + p->hvPowerWire = p->hvPowerWire->hvNext[1]; + else if (p->hvPowerWire->iLast & 3) + { // dla ostatniego i przedostatniego przęsła wymuszamy szukanie innego + p->hvPowerWire = NULL; // nie to, że nie ma, ale trzeba sprawdzić inne + // p->fHorizontal=fHorizontal; //zapamiętanie położenia drutu + break; + } + else if (p->hvPowerWire->hvParallel) + { // jeśli przęsło tworzy bieżnię wspólną, to trzeba sprawdzić pozostałe + p->hvPowerWire = NULL; // nie to, że nie ma, ale trzeba sprawdzić inne + // p->fHorizontal=fHorizontal; //zapamiętanie położenia drutu + break; // tymczasowo dla bieżni wspólnych poszukiwanie po całości + } + else + { // jeśli t jest w przedziale, wyznaczyć odległość wzdłuż wektorów vUp i vLeft + vStyk = p->hvPowerWire->pPoint1 + fRaParam * vParam; // punkt styku + // płaszczyzny z drutem + // (dla generatora łuku + // el.) + vGdzie = vStyk - pant0; // wektor + // odległość w pionie musi być w zasięgu ruchu "pionowego" pantografu + fVertical = glm::dot( + vGdzie, vUp); // musi się mieścić w przedziale ruchu pantografu + // odległość w bok powinna być mniejsza niż pół szerokości pantografu + fHorizontal = std::fabs(glm::dot(vGdzie, vLeft)) - + p->fWidth; // to się musi mieścić w przedziale zależnym od + // szerokości pantografu + // jeśli w pionie albo w bok jest za daleko, to dany drut jest nieużyteczny + if (fHorizontal > 0) // 0.635 dla AKP-1 AKP-4E + { // drut wyszedł poza zakres roboczy, ale jeszcze jest nabieżnik - + // pantograf się unosi bez utraty prądu + if (fHorizontal > p->fWidthExtra) // czy wyszedł za nabieżnik + { + p->hvPowerWire = NULL; // dotychczasowy drut nie liczy się + // p->fHorizontal=fHorizontal; //zapamiętanie położenia drutu + } + else + { // problem jest, gdy nowy drut jest wyżej, wtedy pantograf odłącza się + // od starego, a na podniesienie do nowego potrzebuje czasu + p->PantTraction = + fVertical + + 0.15 * fHorizontal / p->fWidthExtra; // na razie liniowo na + // nabieżniku, dokładność + // poprawi się później + // p->fHorizontal=fHorizontal; //zapamiętanie położenia drutu + } + } + else + { // po wyselekcjonowaniu drutu, przypisać go do toru, żeby nie trzeba było + // szukać + // dla 3 końcowych przęseł sprawdzić wszystkie dostępne przęsła + // bo mogą być umieszczone równolegle nad torem - połączyć w pierścień + // najlepiej, jakby odcinki równoległe były oznaczone we wpisach + // WriteLog("Drut: "+AnsiString(fHorizontal)+" "+AnsiString(fVertical)); + p->PantTraction = fVertical; + // p->fHorizontal=fHorizontal; //zapamiętanie położenia drutu + break; // koniec pętli, aktualny drut pasuje + } + } + if (--n <= 0) // coś za długo to szukanie trwa + p->hvPowerWire = NULL; + } + } + if (!p->hvPowerWire) // else nie, bo mógł zostać wyrzucony + { // poszukiwanie po okolicznych sektorach + int c = GetColFromX(dwys.x) + 1; + int r = GetRowFromZ(dwys.z) + 1; + TSubRect *tmp; + TGroundNode *node; + p->PantTraction = 5.0; // taka za duża wartość + for (int j = r - 2; j <= r; j++) + for (int i = c - 2; i <= c; i++) + { // poszukiwanie po najbliższych sektorach niewiele da przy większym + // zagęszczeniu + tmp = FastGetSubRect(i, j); + if (tmp) + { // dany sektor może nie mieć nic w środku + for (node = tmp->nRenderWires; node; + node = node->nNext3) // następny z grupy + if (node->iType == TP_TRACTION) // w grupie tej są druty oraz inne linie + { + // współczynniki równania parametrycznego + vParam = node->hvTraction->vParametric; + fRaParam = -glm::dot(pant0, vFront); + auto const paramfrontdot = glm::dot( vParam, vFront ); + fRaParam = + -( glm::dot( node->hvTraction->pPoint1, vFront ) + fRaParam ) + / ( paramfrontdot != 0.0 ? paramfrontdot : 0.001 ); // div0 trap + if ((fRaParam >= -0.001) ? (fRaParam <= 1.001) : false) + { // jeśli tylko jest w przedziale, wyznaczyć odległość wzdłuż wektorów vUp i vLeft + // punkt styku płaszczyzny z drutem (dla generatora łuku el.) + vStyk = node->hvTraction->pPoint1 + fRaParam * vParam; + // wektor musi się mieścić w przedziale ruchu pantografu + vGdzie = vStyk - pant0; + fVertical = glm::dot( vGdzie, vUp); + if (fVertical >= 0.0) // jeśli ponad pantografem (bo może + // łapać druty spod wiaduktu) + if (Global::bEnableTraction ? + fVertical < p->PantWys - 0.15 : + false) { + // jeśli drut jest niżej niż 15cm pod ślizgiem + // przełączamy w tryb połamania, o ile jedzie; + // (bEnableTraction) aby dało się jeździć na + // koślawych + // sceneriach + fHorizontal = std::fabs(glm::dot(vGdzie, vLeft)) - + p->fWidth; // i do tego jeszcze + // wejdzie pod ślizg + if (fHorizontal <= 0.0) // 0.635 dla AKP-1 AKP-4E + { + p->PantWys = + -1.0; // ujemna liczba oznacza połamanie + p->hvPowerWire = NULL; // bo inaczej się zasila + // w nieskończoność z + // połamanego + // p->fHorizontal=fHorizontal; //zapamiętanie + // położenia drutu + if (model->MoverParameters->EnginePowerSource + .CollectorParameters.CollectorsNo > + 0) // liczba pantografów + --model->MoverParameters->EnginePowerSource + .CollectorParameters + .CollectorsNo; // teraz będzie + // mniejsza + if (DebugModeFlag) + ErrorLog( + "Pant. break: at " + + to_string(pant0.x, 2, 7) + + " " + + to_string(pant0.y, 2, 7) + + " " + + to_string(pant0.z, 2, 7)); + } + } + else if (fVertical < p->PantTraction) // ale niżej, niż + // poprzednio + // znaleziony + { + fHorizontal = + std::fabs(glm::dot(vGdzie, vLeft)) - p->fWidth; + if (fHorizontal <= 0.0) // 0.635 dla AKP-1 AKP-4E + { // to się musi mieścić w przedziale zaleznym od + // szerokości pantografu + p->hvPowerWire = + node->hvTraction; // jakiś znaleziony + p->PantTraction = + fVertical; // zapamiętanie nowej wysokości + // p->fHorizontal=fHorizontal; //zapamiętanie + // położenia drutu + } + else if (fHorizontal < + p->fWidthExtra) // czy zmieścił się w + // zakresie nabieżnika? + { // problem jest, gdy nowy drut jest wyżej, wtedy + // pantograf odłącza się od starego, a na + // podniesienie do nowego potrzebuje czasu + fVertical += + 0.15 * fHorizontal / + p->fWidthExtra; // korekta wysokości o + // nabieżnik - drut nad + // nabieżnikiem jest + // geometrycznie jakby nieco + // wyżej + if (fVertical < + p->PantTraction) // gdy po korekcie jest + // niżej, niż poprzednio + // znaleziony + { // gdyby to wystarczyło, to możemy go uznać + p->hvPowerWire = + node->hvTraction; // może być + p->PantTraction = + fVertical; // na razie liniowo na + // nabieżniku, dokładność + // poprawi się później + // p->fHorizontal=fHorizontal; + // //zapamiętanie położenia drutu + } + } + } + } // warunek na parametr drutu <0;1> + } // pętla po drutach + } // sektor istnieje + } // pętla po sektorach + } // koniec poszukiwania w sektorach + if (!p->hvPowerWire) // jeśli drut nie znaleziony + if (!Global::bLiveTraction) // ale można oszukiwać + model->pants[k].fParamPants->PantTraction = 1.4; // to dajemy coś tam dla picu + } // koniec obsługi podniesionego + else + p->hvPowerWire = NULL; // pantograf opuszczony + } + + return true; +}; + +//--------------------------------------------------------------------------- +//--------------------------------------------------------------------------- +//--------------------------------------------------------------------------- +void TGround::RadioStop(vector3 pPosition) +{ // zatrzymanie pociągów w okolicy + TGroundNode *node; + TSubRect *tmp; + int c = GetColFromX(pPosition.x); + int r = GetRowFromZ(pPosition.z); + int i, j; + int n = 2 * iNumSubRects; // przeglądanie czołgowe okolicznych torów w kwadracie 4km×4km + for (j = r - n; j <= r + n; j++) + for (i = c - n; i <= c + n; i++) + if ((tmp = FastGetSubRect(i, j)) != NULL) + for (node = tmp->nRootNode; node != NULL; node = node->nNext2) + if (node->iType == TP_TRACK) + node->pTrack->RadioStop(); // przekazanie do każdego toru w każdym segmencie +}; + +TDynamicObject * TGround::DynamicNearest(vector3 pPosition, double distance, bool mech) +{ // wyszukanie pojazdu najbliższego względem (pPosition) + TGroundNode *node; + TSubRect *tmp; + TDynamicObject *dyn = NULL; + int c = GetColFromX(pPosition.x); + int r = GetRowFromZ(pPosition.z); + int i, j; + double sqm = distance * distance, sqd; // maksymalny promien poszukiwań do kwadratu + for (j = r - 1; j <= r + 1; j++) // plus dwa zewnętrzne sektory, łącznie 9 + for (i = c - 1; i <= c + 1; i++) + if ((tmp = FastGetSubRect(i, j)) != NULL) + for (node = tmp->nRootNode; node; node = node->nNext2) // następny z sektora + if (node->iType == TP_TRACK) // Ra: przebudować na użycie tabeli torów? + for( auto dynamic : node->pTrack->Dynamics ) { + if( mech ? ( dynamic->Mechanik != nullptr ) : true ) { + // czy ma mieć obsadę + if( ( sqd = SquareMagnitude( dynamic->GetPosition() - pPosition ) ) < sqm ) { + sqm = sqd; // nowa odległość + dyn = dynamic; // nowy lider + } + } + } + return dyn; +}; + +TDynamicObject * TGround::CouplerNearest(vector3 pPosition, double distance, bool mech) +{ // wyszukanie pojazdu, którego sprzęg jest najbliżej względem (pPosition) + TGroundNode *node; + TSubRect *tmp; + TDynamicObject *dyn = NULL; + int c = GetColFromX(pPosition.x); + int r = GetRowFromZ(pPosition.z); + int i, j; + double sqm = distance * distance, sqd; // maksymalny promien poszukiwań do kwadratu + for (j = r - 1; j <= r + 1; j++) // plus dwa zewnętrzne sektory, łącznie 9 + for (i = c - 1; i <= c + 1; i++) + if ((tmp = FastGetSubRect(i, j)) != NULL) + for (node = tmp->nRootNode; node; node = node->nNext2) // następny z sektora + if (node->iType == TP_TRACK) // Ra: przebudować na użycie tabeli torów? + for( auto dynamic : node->pTrack->Dynamics ) { + if( mech ? ( dynamic->Mechanik != nullptr ) : true ) { + // czy ma mieć obsadę + if( ( sqd = SquareMagnitude( dynamic->HeadPosition() - pPosition ) ) < sqm ) { + sqm = sqd; // nowa odległość + dyn = dynamic; // nowy lider + } + if( ( sqd = SquareMagnitude( dynamic->RearPosition() - pPosition ) ) < sqm ) { + sqm = sqd; // nowa odległość + dyn = dynamic; // nowy lider + } + } + } + return dyn; +}; +#endif +//--------------------------------------------------------------------------- +void TGround::DynamicRemove(TDynamicObject *dyn) +{ // Ra: usunięcie pojazdów ze scenerii (gdy dojadą na koniec i nie sa potrzebne) + TDynamicObject *d = dyn->Prev(); + if (d) // jeśli coś jest z przodu + DynamicRemove(d); // zaczynamy od tego z przodu + else + { // jeśli mamy już tego na początku + TGroundNode **n, *node; + d = dyn; // od pierwszego + while (d) + { + if (d->MyTrack) + d->MyTrack->RemoveDynamicObject(d); // usunięcie z toru o ile nie usunięty + n = &nRootDynamic; // lista pojazdów od początku + // node=NULL; //nie znalezione + while (*n ? (*n)->DynamicObject != d : false) + { // usuwanie z listy pojazdów + n = &((*n)->nNext); // sprawdzenie kolejnego pojazdu na liście + } + if ((*n)->DynamicObject == d) + { // jeśli znaleziony + node = (*n); // zapamiętanie węzła, aby go usunąć + (*n) = node->nNext; // pominięcie na liście + Global::TrainDelete(d); + // remove potential entries in the light array + simulation::Lights.remove( d ); + d = d->Next(); // przejście do kolejnego pojazdu, póki jeszcze jest + delete node; // usuwanie fizyczne z pamięci + } + else + d = NULL; // coś nie tak! + } + } +}; + +//--------------------------------------------------------------------------- + +void TGround::TerrainRead(std::string const &f){ + // Ra: wczytanie trójkątów terenu z pliku E3D +}; + +//--------------------------------------------------------------------------- + +void TGround::TerrainWrite() +{ // Ra: zapisywanie trójkątów terenu do pliku E3D + // TODO: re-implement +/* + if (Global::pTerrainCompact->TerrainLoaded()) + return; // jeśli zostało wczytane, to nie ma co dalej robić + if (Global::asTerrainModel.empty()) + return; + // Trójkąty są zapisywane kwadratami kilometrowymi. + // Kwadrat 500500 jest na środku (od 0.0 do 1000.0 na OX oraz OZ). + // Ewentualnie w numerowaniu kwadratów uwzględnic wpis //$g. + // Trójkąty są grupowane w submodele wg tekstury. + // Triangle_strip oraz triangle_fan są rozpisywane na pojedyncze trójkąty, + // chyba że dla danej tekstury wychodzi tylko jeden submodel. + TModel3d *m = new TModel3d(); // wirtualny model roboczy z oddzielnymi submodelami + TSubModel *sk; // wskaźnik roboczy na submodel kwadratu + // Zliczamy kwadraty z trójkątami, ilość tekstur oraz wierzchołków. + // Ilość kwadratów i ilość tekstur określi ilość submodeli. + // int sub=0; //całkowita ilość submodeli + // int ver=0; //całkowita ilość wierzchołków + int i, j, k; // indeksy w pętli + TGroundNode *Current; + basic_vertex *ver; // trójkąty + TSubModel::iInstance = 0; // pozycja w tabeli wierzchołków liczona narastająco + for (i = 0; i < iNumRects; ++i) // pętla po wszystkich kwadratach kilometrowych + for (j = 0; j < iNumRects; ++j) + if (Rects[i][j].iNodeCount) + { // o ile są jakieś trójkąty w środku + sk = new TSubModel(); // nowy submodel dla kawadratu + // numer kwadratu XXXZZZ, przy czym X jest ujemne - XXX rośnie na wschód, ZZZ rośnie + // na północ + sk->NameSet( std::to_string(1000 * (500 + i - iNumRects / 2) + (500 + j - iNumRects / 2)).c_str() ); // nazwa=numer kwadratu + m->AddTo(NULL, sk); // dodanie submodelu dla kwadratu + for (Current = Rects[i][j].nRootNode; Current; Current = Current->nNext2) + if (Current->TextureID) + switch (Current->iType) + { // pętla po trójkątach - zliczanie wierzchołków, dodaje submodel dla + // każdej tekstury + case GL_TRIANGLES: + Current->iVboPtr = sk->TriangleAdd( + m, Current->TextureID, + Current->iNumVerts); // zwiększenie ilości trójkątów w submodelu + m->iNumVerts += + Current->iNumVerts; // zwiększenie całkowitej ilości wierzchołków + break; + case GL_TRIANGLE_STRIP: // na razie nie, bo trzeba przerabiać na pojedyncze trójkąty + break; + case GL_TRIANGLE_FAN: // na razie nie, bo trzeba przerabiać na pojedyncze trójkąty + break; + } + for (Current = Rects[i][j].nRootNode; Current; Current = Current->nNext2) + if (Current->TextureID) + switch (Current->iType) + { // pętla po trójkątach - dopisywanie wierzchołków + case GL_TRIANGLES: + // //wskaźnik na początek + ver = sk->TrianglePtr(Current->TextureID, Current->iVboPtr, + Current->Ambient, Current->Diffuse, + Current->Specular); // wskaźnik na początek + Current->iVboPtr = -1; // bo to było tymczasowo używane + for (k = 0; k < Current->iNumVerts; ++k) + { // przepisanie współrzędnych + ver[ k ].position = Current->Vertices[ k ].position; + ver[ k ].normal = Current->Vertices[ k ].normal; + ver[ k ].texture = Current->Vertices[ k ].texture; + } + break; + case GL_TRIANGLE_STRIP: // na razie nie, bo trzeba przerabiać na pojedyncze trójkąty + break; + case GL_TRIANGLE_FAN: // na razie nie, bo trzeba przerabiać na pojedyncze trójkąty + break; + } + } + m->SaveToBinFile(strdup(("models\\" + Global::asTerrainModel).c_str())); +*/ +}; + +//--------------------------------------------------------------------------- +#ifdef EU07_USE_OLD_GROUNDCODE +void TGround::TrackBusyList() +{ // wysłanie informacji o wszystkich zajętych odcinkach + TGroundNode *Current; + for (Current = nRootOfType[TP_TRACK]; Current; Current = Current->nNext) + if (!Current->asName.empty()) // musi być nazwa + if( false == Current->pTrack->Dynamics.empty() ) + multiplayer::WyslijString(Current->asName, 8); // zajęty +}; +//--------------------------------------------------------------------------- + +void TGround::IsolatedBusyList() +{ // wysłanie informacji o wszystkich odcinkach izolowanych + TIsolated *Current; + for (Current = TIsolated::Root(); Current; Current = Current->Next()) + if (Current->Busy()) // sprawdź zajętość + multiplayer::WyslijString(Current->asName, 11); // zajęty + else + multiplayer::WyslijString(Current->asName, 10); // wolny + multiplayer::WyslijString("none", 10); // informacja o końcu listy +}; +//--------------------------------------------------------------------------- + +void TGround::IsolatedBusy(const std::string t) +{ // wysłanie informacji o odcinku izolowanym (t) + // Ra 2014-06: do wyszukania użyć drzewka nazw + TIsolated *Current; + for (Current = TIsolated::Root(); Current; Current = Current->Next()) + if (Current->asName == t) // wyszukiwanie odcinka o nazwie (t) + if (Current->Busy()) // sprawdź zajetość + { + multiplayer::WyslijString(Current->asName, 11); // zajęty + return; // nie sprawdzaj dalszych + } + multiplayer::WyslijString(t, 10); // wolny +}; +//--------------------------------------------------------------------------- + +void TGround::Silence(vector3 gdzie) +{ // wyciszenie wszystkiego w sektorach przed przeniesieniem kamery z (gdzie) + TGroundNode *node; + int n = 2 * iNumSubRects; //(2*==2km) promień wyświetlanej mapy w sektorach + int c = GetColFromX(gdzie.x); // sektory wg dotychczasowej pozycji kamery + int r = GetRowFromZ(gdzie.z); + TSubRect *tmp; + int i, j; + // renderowanie czołgowe dla obiektów aktywnych a niewidocznych + for (j = r - n; j <= r + n; j++) + for (i = c - n; i <= c + n; i++) + if ((tmp = FastGetSubRect(i, j)) != NULL) + { // tylko dźwięki interesują + for (node = tmp->nRenderHidden; node; node = node->nNext3) + node->RenderHidden(); + tmp->RenderSounds(); // dźwięki pojazdów by się przydało wyłączyć + } +}; +#endif +//--------------------------------------------------------------------------- diff --git a/old/Ground.h b/old/Ground.h new file mode 100644 index 00000000..8eba653b --- /dev/null +++ b/old/Ground.h @@ -0,0 +1,315 @@ +/* +This Source Code Form is subject to the +terms of the Mozilla Public License, v. +2.0. If a copy of the MPL was not +distributed with this file, You can +obtain one at +http://mozilla.org/MPL/2.0/. +*/ + +#pragma once + +#include + +#include "Classes.h" +#include "material.h" +#include "dumb3d.h" +#include "Names.h" +#include "lightarray.h" +#include "simulation.h" + +typedef int TGroundNodeType; +// Ra: zmniejszone liczby, aby zrobić tabelkę i zoptymalizować wyszukiwanie +const int TP_MODEL = 10; +/* +const int TP_MESH = 11; // Ra: specjalny obiekt grupujący siatki dla tekstury +const int TP_DUMMYTRACK = 12; // Ra: zdublowanie obiektu toru dla rozdzielenia tekstur +*/ +const int TP_TERRAIN = 13; // Ra: specjalny model dla terenu +const int TP_DYNAMIC = 14; +const int TP_SOUND = 15; +const int TP_TRACK = 16; +/* +const int TP_GEOMETRY=17; +*/ +const int TP_MEMCELL = 18; +const int TP_EVLAUNCH = 19; // MC +const int TP_TRACTION = 20; +const int TP_TRACTIONPOWERSOURCE = 21; // MC +/* +const int TP_ISOLATED=22; //Ra +*/ +const int TP_SUBMODEL = 22; // Ra: submodele terenu +const int TP_LAST = 25; // rozmiar tablicy + +struct TGroundVertex +{ + glm::dvec3 position; + glm::vec3 normal; + glm::vec2 texture; + + void HalfSet(const TGroundVertex &v1, const TGroundVertex &v2) + { // wyliczenie współrzędnych i mapowania punktu na środku odcinka v1<->v2 + interpolate_( v1, v2, 0.5 ); + } + void SetByX(const TGroundVertex &v1, const TGroundVertex &v2, double x) + { // wyliczenie współrzędnych i mapowania punktu na odcinku v1<->v2 + interpolate_( v1, v2, ( x - v1.position.x ) / ( v2.position.x - v1.position.x ) ); + } + void SetByZ(const TGroundVertex &v1, const TGroundVertex &v2, double z) + { // wyliczenie współrzędnych i mapowania punktu na odcinku v1<->v2 + interpolate_( v1, v2, ( z - v1.position.z ) / ( v2.position.z - v1.position.z ) ); + } + void interpolate_( const TGroundVertex &v1, const TGroundVertex &v2, double factor ) { + position = interpolate( v1.position, v2.position, factor ); + normal = interpolate( v1.normal, v2.normal, static_cast( factor ) ); + texture = interpolate( v1.texture, v2.texture, static_cast( factor ) ); + } +}; + +// ground node holding single, unique piece of 3d geometry. TBD, TODO: unify this with basic 3d model node +struct piece_node { + std::vector vertices; + geometry_handle geometry { 0, 0 }; // geometry prepared for drawing +}; + +// obiekt scenerii +class TGroundNode { + + friend class opengl_renderer; + +public: + TGroundNode *nNext; // lista wszystkich w scenerii, ostatni na początku + TGroundNode *nNext2; // lista obiektów w sektorze + TGroundNode *nNext3; // lista obiektów renderowanych we wspólnym cyklu + std::string asName; // nazwa (nie zawsze ma znaczenie) + TGroundNodeType iType; // typ obiektu + union + { // Ra: wskażniki zależne od typu - zrobić klasy dziedziczone zamiast + void *Pointer; // do przypisywania NULL + TSubModel *smTerrain; // modele terenu (kwadratow kilometrowych) + TAnimModel *Model; // model z animacjami + TDynamicObject *DynamicObject; // pojazd + piece_node *Piece; // non-instanced piece of geometry + TTrack *pTrack; // trajektoria ruchu + TMemCell *MemCell; // komórka pamięci + TEventLauncher *EvLaunch; // wyzwalacz zdarzeń + TTraction *hvTraction; // drut zasilający + TTractionPowerSource *psTractionPowerSource; // zasilanie drutu (zaniedbane w sceneriach) + TTextSound *tsStaticSound; // dźwięk przestrzenny + TGroundNode *nNode; // obiekt renderujący grupowo ma tu wskaźnik na listę obiektów + }; + Math3D::vector3 pCenter; // współrzędne środka do przydzielenia sektora + float m_radius { 0.0f }; // bounding radius of geometry stored in the node. TODO: reuse bounding_area struct for radius and center + glm::dvec3 m_rootposition; // position of the ground (sub)rectangle holding the node, in the 3d world + // visualization-related data + // TODO: wrap these in a struct, when cleaning objects up + double fSquareMinRadius; // kwadrat widoczności od + double fSquareRadius; // kwadrat widoczności do + union + { + int iNumVerts; // dla trójkątów + int iNumPts; // dla linii + int iCount; // dla terenu + }; + int iFlags; // tryb przezroczystości: 0x10-nieprz.,0x20-przezroczysty,0x30-mieszany + material_handle m_material; // główna (jedna) tekstura obiektu + glm::vec3 + Ambient{ 0.2f }, + Diffuse{ 1.0f }, + Specular{ 0.0f }; // oświetlenie + double fLineThickness; // McZapkie-120702: grubosc linii + bool bVisible; + + TGroundNode(); + TGroundNode(TGroundNodeType t); + ~TGroundNode(); + + void InitNormals(); + void RenderHidden(); // obsługa dźwięków i wyzwalaczy zdarzeń +}; + +class TSubRect : public CMesh +{ // sektor składowy kwadratu kilometrowego + public: + scene::bounding_area m_area; + unsigned int m_framestamp { 0 }; // id of last rendered gfx frame + int iTracks = 0; // ilość torów w (tTracks) + TTrack **tTracks = nullptr; // tory do renderowania pojazdów + protected: + TTrack *tTrackAnim = nullptr; // obiekty do przeliczenia animacji + public: + TGroundNode *nRootNode = nullptr; // wszystkie obiekty w sektorze, z wyjątkiem renderujących i pojazdów (nNext2) + TGroundNode *nRenderHidden = nullptr; // lista obiektów niewidocznych, "renderowanych" również z tyłu (nNext3) + TGroundNode *nRenderRect = nullptr; // z poziomu sektora - nieprzezroczyste (nNext3) + TGroundNode *nRenderRectAlpha = nullptr; // z poziomu sektora - przezroczyste (nNext3) + TGroundNode *nRenderWires = nullptr; // z poziomu sektora - druty i inne linie (nNext3) + TGroundNode *nRender = nullptr; // indywidualnie - nieprzezroczyste (nNext3) + TGroundNode *nRenderMixed = nullptr; // indywidualnie - nieprzezroczyste i przezroczyste (nNext3) + TGroundNode *nRenderAlpha = nullptr; // indywidualnie - przezroczyste (nNext3) +#ifdef EU07_SCENERY_EDITOR + std::deque< TGroundNode* > m_memcells; // collection of memcells present in the sector +#endif + int iNodeCount = 0; // licznik obiektów, do pomijania pustych sektorów + public: + void LoadNodes(); // utworzenie VBO sektora + public: + virtual ~TSubRect(); + virtual void NodeAdd(TGroundNode *Node); // dodanie obiektu do sektora na etapie rozdzielania na sektory + void Sort(); // optymalizacja obiektów w sektorze (sortowanie wg tekstur) + TTrack * FindTrack(vector3 *Point, int &iConnection, TTrack *Exclude); + TTraction * FindTraction(glm::dvec3 const &Point, int &iConnection, TTraction *Exclude); +#ifdef EU07_USE_OLD_GROUNDCODE + bool RaTrackAnimAdd(TTrack *t); // zgłoszenie toru do animacji + void RaAnimate( unsigned int const Framestamp ); // przeliczenie animacji torów + void RenderSounds(); // dźwięki pojazdów z niewidocznych sektorów +#endif +}; + +// Ra: trzeba sprawdzić wydajność siatki +const int iNumSubRects = 5; // na ile dzielimy kilometr +const int iNumRects = 500; +const int iTotalNumSubRects = iNumRects * iNumSubRects; +const double fHalfTotalNumSubRects = iTotalNumSubRects / 2.0; +const double fSubRectSize = 1000.0 / iNumSubRects; +const double fRectSize = fSubRectSize * iNumSubRects; + +class TGroundRect : public TSubRect +{ // kwadrat kilometrowy + // obiekty o niewielkiej ilości wierzchołków będą renderowane stąd + // Ra: 2012-02 doszły submodele terenu + friend class opengl_renderer; + +private: + TSubRect *pSubRects { nullptr }; + + void Init(); + +public: + virtual ~TGroundRect(); + // pobranie wskaźnika do małego kwadratu, utworzenie jeśli trzeba + inline + TSubRect * SafeGetSubRect(int iCol, int iRow) { + if( !pSubRects ) { + // utworzenie małych kwadratów + Init(); + } + return pSubRects + iRow * iNumSubRects + iCol; // zwrócenie właściwego + }; + // pobranie wskaźnika do małego kwadratu, bez tworzenia jeśli nie ma + inline + TSubRect *FastGetSubRect(int iCol, int iRow) const { + return ( + pSubRects ? + pSubRects + iRow * iNumSubRects + iCol : + nullptr); }; + void NodeAdd( TGroundNode *Node ); // dodanie obiektu do sektora na etapie rozdzielania na sektory + // compares two provided nodes, returns true if their content can be merged + bool mergeable( TGroundNode const &Left, TGroundNode const &Right ) const; + // optymalizacja obiektów w sektorach + inline + void Optimize() { + if( pSubRects ) { + for( int i = iNumSubRects * iNumSubRects - 1; i >= 0; --i ) { + // optymalizacja obiektów w sektorach + pSubRects[ i ].Sort(); } } }; + + TGroundNode *nTerrain { nullptr }; // model terenu z E3D - użyć nRootMesh? +}; + +class TGround +{ + friend class opengl_renderer; + + TGroundRect Rects[ iNumRects ][ iNumRects ]; // mapa kwadratów kilometrowych + TSubRect srGlobal; // zawiera obiekty globalne (na razie wyzwalacze czasowe) + TGroundNode *nRootDynamic = nullptr; // lista pojazdów + TGroundNode *nRootOfType[ TP_LAST ]; // tablica grupująca obiekty, przyspiesza szukanie +#ifdef EU07_USE_OLD_GROUNDCODE + TEvent *RootEvent = nullptr; // lista zdarzeń + TEvent *QueryRootEvent = nullptr, + *tmpEvent = nullptr; + typedef std::unordered_map event_map; + event_map m_eventmap; + TNames m_nodemap; +#endif + vector3 pOrigin; + vector3 aRotate; + bool bInitDone = false; + + private: // metody prywatne +#ifdef EU07_USE_OLD_GROUNDCODE + bool EventConditon(TEvent *e); +#endif + + public: + + TGround(); + ~TGround(); + void Free(); +#ifdef EU07_USE_OLD_GROUNDCODE + bool Init( std::string File ); + void FirstInit(); + void InitTracks(); + void InitTraction(); + bool InitEvents(); + bool InitLaunchers(); + TTrack * FindTrack(vector3 Point, int &iConnection, TGroundNode *Exclude); + TTraction * FindTraction(glm::dvec3 const &Point, int &iConnection, TGroundNode *Exclude); + TTraction * TractionNearestFind(glm::dvec3 &p, int dir, TGroundNode *n); +#endif + TGroundNode * AddGroundNode(cParser *parser); +#ifdef EU07_USE_OLD_GROUNDCODE + void UpdatePhys(double dt, int iter); // aktualizacja fizyki stałym krokiem + bool Update(double dt, int iter); // aktualizacja przesunięć zgodna z FPS + void Update_Hidden(); // updates invisible elements of the scene + bool GetTraction(TDynamicObject *model); + bool AddToQuery( TEvent *Event, TDynamicObject *Node ); + bool CheckQuery(); + TGroundNode * DynamicFindAny(std::string const &Name); + TGroundNode * DynamicFind(std::string const &Name); + TGroundNode * FindGroundNode(std::string const &asNameToFind, TGroundNodeType const iNodeType); +#endif + TGroundRect * GetRect( double x, double z ); + TSubRect * GetSubRect( int iCol, int iRow ); + inline + TSubRect * GetSubRect(double x, double z) { + return GetSubRect(GetColFromX(x), GetRowFromZ(z)); }; + TSubRect * FastGetSubRect( int iCol, int iRow ); + inline + TSubRect * FastGetSubRect( double x, double z ) { + return FastGetSubRect( GetColFromX( x ), GetRowFromZ( z ) ); }; + inline + int GetRowFromZ(double z) { + return (int)(z / fSubRectSize + fHalfTotalNumSubRects); }; + inline + int GetColFromX(double x) { + return (int)(x / fSubRectSize + fHalfTotalNumSubRects); }; +#ifdef EU07_USE_OLD_GROUNDCODE + TEvent * FindEvent(const std::string &asEventName); + void TrackJoin(TGroundNode *Current); +private: + // convert tp_terrain model to a series of triangle nodes + void convert_terrain( TGroundNode const *Terrain ); + void convert_terrain( TSubModel const *Submodel ); + void RaTriangleDivider(TGroundNode *node); +#endif +public: +#ifdef EU07_USE_OLD_GROUNDCODE + void DynamicList( bool all = false ); + void TrackBusyList(); + void IsolatedBusyList(); + void IsolatedBusy( const std::string t ); + void RadioStop(vector3 pPosition); + TDynamicObject * DynamicNearest(vector3 pPosition, double distance = 20.0, bool mech = false); + TDynamicObject * CouplerNearest(vector3 pPosition, double distance = 20.0, bool mech = false); +#endif + void DynamicRemove(TDynamicObject *dyn); + void TerrainRead(std::string const &f); + void TerrainWrite(); +#ifdef EU07_USE_OLD_GROUNDCODE + void Silence(vector3 gdzie); +#endif +}; + +//--------------------------------------------------------------------------- diff --git a/old/MWD.cpp b/old/MWD.cpp new file mode 100644 index 00000000..9ea5adcb --- /dev/null +++ b/old/MWD.cpp @@ -0,0 +1,763 @@ +/* +This Source Code Form is subject to the +terms of the Mozilla Public License, v. +2.0. If a copy of the MPL was not +distributed with this file, You can +obtain one at +http://mozilla.org/MPL/2.0/. +*/ + +/* + Program obsługi portu COM i innych na potrzeby sterownika MWDevice + (oraz innych wykorzystujących komunikację przez port COM) + dla Symulatora Pojazdów Szynowych MaSzyna + author: Maciej Witek 2016 + Autor nie ponosi odpowiedzialności za niewłaciwe używanie lub działanie programu! +*/ +#include "stdafx.h" +#include "MWD.h" +#include "Globals.h" +#include "Logs.h" +#include "World.h" + +#include + +HANDLE hComm; + +TMWDComm::TMWDComm() // konstruktor +{ + MWDTime = 0; + bSHPstate = false; + bPrzejazdSHP = false; + bKabina1 = true; // pasuje wyciągnąć dane na temat kabiny + bKabina2 = false; // i ustawiać te dwa parametry! + bHamowanie = false; + bCzuwak = false; + + bRysik1H = false; + bRysik1L = false; + bRysik2H = false; + bRysik2L = false; + + bocznik = 0; + nastawnik = 0; + kierunek = 0; + bnkMask = 0; + + int i = 6; + + while (i) + { + i--; + lastStateData[i] = 0; + maskData[i] = 0; + maskSwitch[i] = 0; + bitSwitch[i] = 0; + } + + i = 0; + while (i 0) + return 1; + else + return 0; +} + +bool TMWDComm::ReadData() // odbieranie danych + odczyta danych analogowych i zapis do zmiennych +{ + DWORD bytes_read; + ReadFile(hComm, &ReadDataBuff[0], BYTETOREAD, &bytes_read, NULL); + if (Global.bMWDdebugEnable && Global.iMWDDebugMode == 128) WriteLog("Data receive. Checking data..."); + if (Global.bMWDBreakEnable) + { + uiAnalog[0] = (ReadDataBuff[9] << 8) + ReadDataBuff[8]; + uiAnalog[1] = (ReadDataBuff[11] << 8) + ReadDataBuff[10]; + uiAnalog[2] = (ReadDataBuff[13] << 8) + ReadDataBuff[12]; + uiAnalog[3] = (ReadDataBuff[15] << 8) + ReadDataBuff[14]; + if (Global.bMWDdebugEnable && (Global.iMWDDebugMode & 1)) + { + WriteLog("Main Break = " + to_string(uiAnalog[0])); + WriteLog("Locomotiv Break = " + to_string(uiAnalog[1])); + } + if (Global.bMWDdebugEnable && (Global.iMWDDebugMode & 2)) + { + WriteLog("Analog input 1 = " + to_string(uiAnalog[2])); + WriteLog("Analog imput 2 = " + to_string(uiAnalog[3])); + } + } + if (Global.bMWDInputEnable) CheckData(); + return TRUE; +} + +bool TMWDComm::SendData() // wysyłanie danych +{ + DWORD bytes_write; + + WriteFile(hComm, &WriteDataBuff[0], BYTETOWRITE, &bytes_write, NULL); + + return TRUE; +} + +bool TMWDComm::Run() // wywoływanie obsługi MWD + generacja większego opóźnienia +{ + if (GetMWDState()) + { + MWDTime++; + if (!(MWDTime % Global.iMWDdivider)) + { + MWDTime = 0; + if (Global.bMWDdebugEnable && Global.iMWDDebugMode == 128) WriteLog("Sending data..."); + SendData(); + if (Global.bMWDdebugEnable && Global.iMWDDebugMode == 128) WriteLog(" complet!\nReceiving data..."); + ReadData(); + if (Global.bMWDdebugEnable && Global.iMWDDebugMode == 128) WriteLog(" complet!"); + return 1; + } + } + else + { + WriteLog("Port COM: connection ERROR!"); + Close(); + // może spróbować się połączyć znowu? + return 0; + } + return 1; +} + +void TMWDComm::CheckData() // sprawdzanie wejść cyfrowych i odpowiednie sterowanie maszyną +{ + int i = 0; + while (i < 6) + { + maskData[i] = ReadDataBuff[i] ^ lastStateData[i]; + lastStateData[i] = ReadDataBuff[i]; + i++; + } + /* + Rozpiska portów! + Port0: 0 NC odblok. przek. sprężarki i wentyl. oporów + 1 M wyłącznik wył. szybkiego + 2 Shift+M impuls załączający wył. szybki + 3 N odblok. przekaźników nadmiarowych + i różnicowego obwodu głównegoMMm + 4 NC rezerwa + 5 Ctrl+N odblok. przek. nadmiarowych + przetwornicy, ogrzewania pociągu i różnicowych obw. pomocniczych + 6 L wył. styczników liniowych + 7 SPACE kasowanie czuwaka + + Port1: 0 NC + 1 (Shift) X przetwornica + 2 (Shift) C sprężarka + 3 S piasecznice + 4 (Shift) H ogrzewanie składu + 5 przel. hamowania Shift+B + pspbpwy Ctrl+B pospieszny B towarowy + 6 przel. hamowania + 7 (Shift) F rozruch w/n + + Port2: 0 (Shift) P pantograf przedni + 1 (Shift) O pantograf tylni + 2 ENTER przyhamowanie przy poślizgu + 3 () przyciemnienie świateł + 4 () przyciemnienie świateł + 5 NUM6 odluźniacz + 6 a syrena lok W + 7 A syrena lok N + + Port3: 0 Shift+J bateria + 1 + 2 + 3 + 4 + 5 + 6 + 7 + */ + + /* po przełączeniu bistabilnego najpierw wciskamy klawisz i przy następnym + wejściu w pętlę MWD puszczamy bo inaczej nie działa + */ + + // wciskanie przycisków klawiatury + /*PORT0*/ + if (maskData[0] & 0x02) if (lastStateData[0] & 0x02) + KeyBoard('M', 1); // wyłączenie wyłącznika szybkiego + else KeyBoard('M', 0); // monostabilny + if (maskData[0] & 0x04) if (lastStateData[0] & 0x04) // impuls załączający wyłącznik szybki + { + KeyBoard(0x10, 1); // monostabilny + KeyBoard('M', 1); + } + else + { + KeyBoard('M', 0); + KeyBoard(0x10, 0); + } + if (maskData[0] & 0x08) if (lastStateData[0] & 0x08) + KeyBoard('N', 1); // odblok nadmiarowego silników trakcyjnych + else KeyBoard('N', 0); // monostabilny + if (maskData[0] & 0x20) if (lastStateData[0] & 0x20) + { // odblok nadmiarowego przetwornicy, ogrzewania poc. + KeyBoard(0x11, 1); // różnicowego obwodów pomocniczych + KeyBoard('N', 1); // monostabilny + } + else + { + KeyBoard('N', 0); + KeyBoard(0x11, 0); + } + if (maskData[0] & 0x40) if (lastStateData[0] & 0x40) KeyBoard('L', 1); // wył. styczników liniowych + else KeyBoard('L', 0); // monostabilny + if (maskData[0] & 0x80) if (lastStateData[0] & 0x80) KeyBoard(0x20, 1); // kasowanie czuwaka/SHP + else KeyBoard(0x20, 0); // kasowanie czuwaka/SHP + + /*PORT1*/ + + // puszczanie przycisku bistabilnego klawiatury + if (maskSwitch[1] & 0x02) + { + if (bitSwitch[1] & 0x02) + { + KeyBoard('X', 0); + KeyBoard(0x10, 0); + } + else KeyBoard('X', 0); + maskSwitch[1] &= ~0x02; + } + if (maskSwitch[1] & 0x04) { + if (bitSwitch[1] & 0x04) { + KeyBoard('C', 0); + KeyBoard(0x10, 0); + } + else KeyBoard('C', 0); + maskSwitch[1] &= ~0x04; + } + if (maskSwitch[1] & 0x10) { + if (bitSwitch[1] & 0x10) { + KeyBoard('H', 0); + KeyBoard(0x10, 0); + } + else KeyBoard('H', 0); + maskSwitch[1] &= ~0x10; + } + if (maskSwitch[1] & 0x20 || maskSwitch[1] & 0x40) { + if (maskSwitch[1] & 0x20) KeyBoard(0x10, 0); + if (maskSwitch[1] & 0x40) KeyBoard(0x11, 0); + KeyBoard('B', 0); + maskSwitch[1] &= ~0x60; + } + if (maskSwitch[1] & 0x80) { + if (bitSwitch[1] & 0x80) { + KeyBoard('F', 0); + KeyBoard(0x10, 0); + } + else KeyBoard('F', 0); + maskSwitch[1] &= ~0x80; + } + + // przetwornica + if (maskData[1] & 0x02) if (lastStateData[1] & 0x02) + { + KeyBoard(0x10, 1); // bistabilny + KeyBoard('X', 1); + maskSwitch[1] |= 0x02; + bitSwitch[1] |= 0x02; + } + else + { + maskSwitch[1] |= 0x02; + bitSwitch[1] &= ~0x02; + KeyBoard('X', 1); + } + // sprężarka + if (maskData[1] & 0x04) if (lastStateData[1] & 0x04) + { + KeyBoard(0x10, 1); // bistabilny + KeyBoard('C', 1); + maskSwitch[1] |= 0x04; + bitSwitch[1] |= 0x04; + } + else + { + maskSwitch[1] |= 0x04; + bitSwitch[1] &= ~0x04; + KeyBoard('C', 1); + } + // piasecznica + if (maskData[1] & 0x08) if (lastStateData[1] & 0x08) + KeyBoard('S', 1); + else + KeyBoard('S', 0); // monostabilny + // ogrzewanie składu + if (maskData[1] & 0x10) if (lastStateData[1] & 0x10) + { + KeyBoard(0x11, 1); // bistabilny + KeyBoard('H', 1); + maskSwitch[1] |= 0x10; + bitSwitch[1] |= 0x10; + } + else + { + maskSwitch[1] |= 0x10; + bitSwitch[1] &= ~0x10; + KeyBoard('H', 1); + } + // przełącznik hamowania + if (maskData[1] & 0x20 || maskData[1] & 0x40) + { + if (lastStateData[1] & 0x20) + { // Shift+B + KeyBoard(0x10, 1); + maskSwitch[1] |= 0x20; + } + else if (lastStateData[1] & 0x40) + { // Ctrl+B + KeyBoard(0x11, 1); + maskSwitch[1] |= 0x40; + } + KeyBoard('B', 1); + } + // rozruch wysoki/niski + if (maskData[1] & 0x80) if (lastStateData[1] & 0x80) + { + KeyBoard(0x10, 1); // bistabilny + KeyBoard('F', 1); + maskSwitch[1] |= 0x80; + bitSwitch[1] |= 0x80; + } + else + { + maskSwitch[1] |= 0x80; + bitSwitch[1] &= ~0x80; + KeyBoard('F', 1); + } + + + //PORT2 + if (maskSwitch[2] & 0x01) + { + if (bitSwitch[2] & 0x01) + { + KeyBoard('P', 0); + KeyBoard(0x10, 0); + } + else KeyBoard('P', 0); + maskSwitch[2] &= ~0x01; + } + if (maskSwitch[2] & 0x02) + { + if (bitSwitch[2] & 0x02) + { + KeyBoard('O', 0); + KeyBoard(0x10, 0); + } + else KeyBoard('O', 0); + maskSwitch[2] &= ~0x02; + } + + // pantograf przedni + if (maskData[2] & 0x01) if (lastStateData[2] & 0x01) + { + KeyBoard(0x10, 1); // bistabilny + KeyBoard('P', 1); + maskSwitch[2] |= 0x01; + bitSwitch[2] |= 0x01; + } + else + { + maskSwitch[2] |= 0x01; + bitSwitch[2] &= ~0x01; + KeyBoard('P', 1); + } + // pantograf tylni + if (maskData[2] & 0x02) if (lastStateData[2] & 0x02) + { + KeyBoard(0x10, 1); // bistabilny + KeyBoard('O', 1); + maskSwitch[2] |= 0x02; + bitSwitch[2] |= 0x02; + } + else + { + maskSwitch[2] |= 0x02; + bitSwitch[2] &= ~0x02; + KeyBoard('O', 1); + } + // przyhamowanie przy poślizgu + if (maskData[2] & 0x04) if (lastStateData[2] & 0x04) { + KeyBoard(0x10, 1); // monostabilny + KeyBoard(0x0D, 1); + } + else + { + KeyBoard(0x0D, 0); + KeyBoard(0x10, 0); + } + /*if(maskData[2] & 0x08) if (lastStateData[2] & 0x08){ // przyciemnienie świateł + KeyBoard(' ',0); // bistabilny + KeyBoard(0x10,1); + KeyBoard(' ',1); + }else{ + KeyBoard(' ',0); + KeyBoard(0x10,0); + KeyBoard(' ',1); + } + if(maskData[2] & 0x10) if (lastStateData[2] & 0x10) { // przyciemnienie świateł + KeyBoard(' ',0); // bistabilny + KeyBoard(0x11,1); + KeyBoard(' ',1); + }else{ + KeyBoard(' ',0); + KeyBoard(0x11,0); + KeyBoard(' ',1); + }*/ + // odluźniacz + if (maskData[2] & 0x20) if (lastStateData[2] & 0x20) + KeyBoard(0x66, 1); + else + KeyBoard(0x66, 0); // monostabilny + // syrena wysoka + if (maskData[2] & 0x40) if (lastStateData[2] & 0x40) + { + KeyBoard(0x10, 1); // monostabilny + KeyBoard('A', 1); + } + else + { + KeyBoard('A', 0); + KeyBoard(0x10, 0); + } + if (maskData[2] & 0x80) if (lastStateData[2] & 0x80) + KeyBoard('A', 1); // syrena niska + else + KeyBoard('A', 0); // monostabilny + + + //PORT3 + + if (maskSwitch[3] & 0x01) + { + if (bitSwitch[3] & 0x01) + { + KeyBoard('J', 0); + KeyBoard(0x10, 0); + } + else KeyBoard('J', 0); + maskSwitch[3] &= ~0x01; + } + if (maskSwitch[3] & 0x02) + { + if (bitSwitch[3] & 0x02) + { + KeyBoard('Y', 0); + KeyBoard(0x10, 0); + } + else KeyBoard('Y', 0); + maskSwitch[3] &= ~0x02; + } + if (maskSwitch[3] & 0x04) + { + if (bitSwitch[3] & 0x04) + { + KeyBoard('U', 0); + KeyBoard(0x10, 0); + } + else KeyBoard('U', 0); + maskSwitch[3] &= ~0x04; + } + if (maskSwitch[3] & 0x08) + { + if (bitSwitch[3] & 0x08) + { + KeyBoard('I', 0); + KeyBoard(0x10, 0); + } + else KeyBoard('I', 0); + maskSwitch[3] &= ~0x08; + } + + + // bateria + if (maskData[3] & 0x01) if (lastStateData[3] & 0x01) + { + KeyBoard(0x10, 1); // bistabilny + KeyBoard('J', 1); + maskSwitch[3] |= 0x01; + bitSwitch[3] |= 0x01; + } + else + { + maskSwitch[3] |= 0x01; + bitSwitch[3] &= ~0x01; + KeyBoard('J', 1); + } + //Światło lewe + if (maskData[3] & 0x02) if (lastStateData[3] & 0x02) + { + KeyBoard(0x10, 1); // bistabilny + KeyBoard('Y', 1); + maskSwitch[3] |= 0x02; + bitSwitch[3] |= 0x02; + }else + { + maskSwitch[3] |= 0x02; + bitSwitch[3] &= ~0x02; + KeyBoard('Y', 1); + } + //światło górne + if (maskData[3] & 0x04) if (lastStateData[3] & 0x04) + { + KeyBoard(0x10, 1); // bistabilny + KeyBoard('U', 1); + maskSwitch[3] |= 0x04; + bitSwitch[3] |= 0x04; + } + else + { + maskSwitch[3] |= 0x04; + bitSwitch[3] &= ~0x04; + KeyBoard('U', 1); + } + //światło prawe + if (maskData[3] & 0x08) if (lastStateData[3] & 0x08) + { + KeyBoard(0x10, 1); // bistabilny + KeyBoard('I', 1); + maskSwitch[3] |= 0x08; + bitSwitch[3] |= 0x08; + } + else + { + maskSwitch[3] |= 0x08; + bitSwitch[3] &= ~0x08; + KeyBoard('I', 1); + } + + + + /* NASTAWNIK, BOCZNIK i KIERUNEK */ + + if (bnkMask & 1) + { // puszczanie klawiszy + KeyBoard(0x6B, 0); + bnkMask &= ~1; + } + if (bnkMask & 2) + { + KeyBoard(0x6D, 0); + bnkMask &= ~2; + } + if (bnkMask & 4) + { + KeyBoard(0x6F, 0); + bnkMask &= ~4; + } + if (bnkMask & 8) + { + KeyBoard(0x6A, 0); + bnkMask &= ~8; + } + + if (nastawnik < ReadDataBuff[6]) + { + bnkMask |= 1; + nastawnik++; + KeyBoard(0x6B, 1); // wciśnij + i dodaj 1 do nastawnika + } + if (nastawnik > ReadDataBuff[6]) + { + bnkMask |= 2; + nastawnik--; + KeyBoard(0x6D, 1); // wciśnij - i odejmij 1 do nastawnika + } + if (bocznik < ReadDataBuff[7]) + { + bnkMask |= 4; + bocznik++; + KeyBoard(0x6F, 1); // wciśnij / i dodaj 1 do bocznika + } + if (bocznik > ReadDataBuff[7]) + { + bnkMask |= 8; + bocznik--; + KeyBoard(0x6A, 1); // wciśnij * i odejmij 1 do bocznika + } + + /* Obsługa HASLERA */ + if (ReadDataBuff[0] & 0x80) + bCzuwak = true; + + if (bKabina1) + { // logika rysika 1 + bRysik1H = true; + bRysik1L = false; + if (bPrzejazdSHP) + bRysik1H = false; + } + else if (bKabina2) + { + bRysik1L = true; + bRysik1H = false; + if (bPrzejazdSHP) + bRysik1L = false; + } + else + { + bRysik1H = false; + bRysik1L = false; + } + + if (bHamowanie) + { // logika rysika 2 + bRysik2H = false; + bRysik2L = true; + } + else + { + if (bCzuwak) + bRysik2H = true; + else + bRysik2H = false; + bRysik2L = false; + } + bCzuwak = false; + if (bRysik1H) + WriteDataBuff[6] |= 1 << 0; + else + WriteDataBuff[6] &= ~(1 << 0); + if (bRysik1L) + WriteDataBuff[6] |= 1 << 1; + else + WriteDataBuff[6] &= ~(1 << 1); + if (bRysik2H) + WriteDataBuff[6] |= 1 << 2; + else + WriteDataBuff[6] &= ~(1 << 2); + if (bRysik2L) + WriteDataBuff[6] |= 1 << 3; + else + WriteDataBuff[6] &= ~(1 << 3); +} + +void TMWDComm::KeyBoard(int key, bool s) // emulacja klawiatury +{ + INPUT ip; + // Set up a generic keyboard event. + ip.type = INPUT_KEYBOARD; + ip.ki.wScan = 0; // hardware scan code for key + ip.ki.time = 0; + ip.ki.dwExtraInfo = 0; + + ip.ki.wVk = key; // virtual-key code for the "a" key + + if (s) + { // Press the "A" key + ip.ki.dwFlags = 0; // 0 for key press + SendInput(1, &ip, sizeof(INPUT)); + } + else + { + ip.ki.dwFlags = KEYEVENTF_KEYUP; // KEYEVENTF_KEYUP for key release + SendInput(1, &ip, sizeof(INPUT)); + } + + // return 1; +} diff --git a/Console/MWD.h b/old/MWD.h similarity index 100% rename from Console/MWD.h rename to old/MWD.h diff --git a/McZapkie/Mover.hpp b/old/Mover.hpp similarity index 100% rename from McZapkie/Mover.hpp rename to old/Mover.hpp diff --git a/McZapkie/Oerlikon_ESt.hpp b/old/Oerlikon_ESt.hpp similarity index 100% rename from McZapkie/Oerlikon_ESt.hpp rename to old/Oerlikon_ESt.hpp diff --git a/McZapkie/Oerlikon_ESt.pas b/old/Oerlikon_ESt.pas similarity index 100% rename from McZapkie/Oerlikon_ESt.pas rename to old/Oerlikon_ESt.pas diff --git a/QueryParserComp.hpp b/old/QueryParserComp.hpp similarity index 100% rename from QueryParserComp.hpp rename to old/QueryParserComp.hpp diff --git a/QueryParserComp.pas b/old/QueryParserComp.pas similarity index 100% rename from QueryParserComp.pas rename to old/QueryParserComp.pas diff --git a/RealSound.cpp b/old/RealSound.cpp similarity index 76% rename from RealSound.cpp rename to old/RealSound.cpp index 17cd51f3..f16ffe05 100644 --- a/RealSound.cpp +++ b/old/RealSound.cpp @@ -19,9 +19,9 @@ http://mozilla.org/MPL/2.0/. //#include "math.h" #include "Timer.h" #include "mczapkie/mctools.h" +#include "usefull.h" -TRealSound::TRealSound(std::string const &SoundName, double SoundAttenuation, double X, double Y, double Z, bool Dynamic, - bool freqmod, double rmin) +TRealSound::TRealSound(std::string const &SoundName, double SoundAttenuation, double X, double Y, double Z, bool Dynamic, bool freqmod, double rmin) { Init(SoundName, SoundAttenuation, X, Y, Z, Dynamic, freqmod, rmin); } @@ -31,15 +31,10 @@ TRealSound::~TRealSound() // if (this) if (pSound) pSound->Stop(); } -void TRealSound::Free() -{ -} - -void TRealSound::Init(std::string const &SoundName, double DistanceAttenuation, double X, double Y, double Z, - bool Dynamic, bool freqmod, double rmin) +void TRealSound::Init(std::string const &SoundName, double DistanceAttenuation, double X, double Y, double Z, bool Dynamic, bool freqmod, double rmin) { // Nazwa=SoundName; //to tak raczej nie zadziała, (SoundName) jest tymczasowe - pSound = TSoundsManager::GetFromName(SoundName.c_str(), Dynamic, &fFrequency); + pSound = TSoundsManager::GetFromName(SoundName, Dynamic, &fFrequency); if (pSound) { if (freqmod) @@ -47,8 +42,7 @@ void TRealSound::Init(std::string const &SoundName, double DistanceAttenuation, { // dla modulowanych nie może być zmiany mnożnika, bo częstotliwość w nagłówku byłą // ignorowana, a mogła być inna niż 22050 fFrequency = 22050.0; - ErrorLog("Bad sound: " + std::string(SoundName) + - ", as modulated, should have 22.05kHz in header"); + ErrorLog("Bad sound: " + SoundName + ", as modulated, should have 22.05kHz in header"); } AM = 1.0; pSound->SetVolume(DSBVOLUME_MIN); @@ -56,7 +50,7 @@ void TRealSound::Init(std::string const &SoundName, double DistanceAttenuation, else { // nie ma dźwięku, to jest wysyp AM = 0; - ErrorLog("Missed sound: " + std::string(SoundName)); + ErrorLog("Missed sound: " + SoundName); } if (DistanceAttenuation > 0.0) { @@ -71,7 +65,7 @@ void TRealSound::Init(std::string const &SoundName, double DistanceAttenuation, dSoundAtt = -1; }; -double TRealSound::ListenerDistance(vector3 ListenerPosition) +double TRealSound::ListenerDistance( Math3D::vector3 ListenerPosition) { if (dSoundAtt == -1) { @@ -83,7 +77,7 @@ double TRealSound::ListenerDistance(vector3 ListenerPosition) } } -void TRealSound::Play(double Volume, int Looping, bool ListenerInside, vector3 NewPosition) +void TRealSound::Play(double Volume, int Looping, bool ListenerInside, Math3D::vector3 NewPosition) { if (!pSound) return; @@ -155,11 +149,6 @@ void TRealSound::Play(double Volume, int Looping, bool ListenerInside, vector3 N } }; -void TRealSound::Start(){ - // włączenie dźwięku - -}; - void TRealSound::Stop() { DWORD stat; @@ -176,8 +165,8 @@ void TRealSound::Stop() void TRealSound::AdjFreq(double Freq, double dt) // McZapkie TODO: dorobic tu efekt Dopplera // Freq moze byc liczba dodatnia mniejsza od 1 lub wieksza od 1 { - float df, Vlist, Vsrc; - if ((Global::bSoundEnabled) && (AM != 0)) + float df, Vlist; + if ((Global::bSoundEnabled) && (AM != 0) && (pSound != nullptr)) { if (dt > 0) // efekt Dopplera @@ -190,9 +179,7 @@ void TRealSound::AdjFreq(double Freq, double dt) // McZapkie TODO: dorobic tu ef if (Timer::GetSoundTimer()) { df = fFrequency * df; // TODO - brac czestotliwosc probkowania z wav - pSound->SetFrequency((df < DSBFREQUENCY_MIN ? - DSBFREQUENCY_MIN : - (df > DSBFREQUENCY_MAX ? DSBFREQUENCY_MAX : df))); + pSound->SetFrequency( clamp( df, static_cast(DSBFREQUENCY_MIN), static_cast(DSBFREQUENCY_MAX) ) ); } } } @@ -233,21 +220,18 @@ void TRealSound::ResetPosition() pSound->SetCurrentPosition(0); } -TTextSound::TTextSound(std::string const &SoundName, double SoundAttenuation, double X, double Y, double Z, - bool Dynamic, bool freqmod, double rmin) - : TRealSound(SoundName, SoundAttenuation, X, Y, Z, Dynamic, freqmod, rmin) +TTextSound::TTextSound(std::string const &SoundName, double SoundAttenuation, double X, double Y, double Z, bool Dynamic, bool freqmod, double rmin) : + TRealSound(SoundName, SoundAttenuation, X, Y, Z, Dynamic, freqmod, rmin) { Init(SoundName, SoundAttenuation, X, Y, Z, Dynamic, freqmod, rmin); } -void TTextSound::Init(std::string const &SoundName, double SoundAttenuation, double X, double Y, double Z, - bool Dynamic, bool freqmod, double rmin) +void TTextSound::Init(std::string const &SoundName, double SoundAttenuation, double X, double Y, double Z, bool Dynamic, bool freqmod, double rmin) { // dodatkowo doczytuje plik tekstowy - //TRealSound::Init(SoundName, SoundAttenuation, X, Y, Z, Dynamic, freqmod, rmin); fTime = GetWaveTime(); std::string txt(SoundName); txt.erase( txt.rfind( '.' ) ); // obcięcie rozszerzenia - for (int i = txt.length(); i > 0; --i) + for (size_t i = txt.length(); i > 0; --i) if (txt[i] == '/') txt[i] = '\\'; // bo nie rozumi txt += "-" + Global::asLang + ".txt"; // już może być w różnych językach @@ -255,40 +239,18 @@ void TTextSound::Init(std::string const &SoundName, double SoundAttenuation, dou txt = "sounds\\" + txt; //ścieżka może nie być podana if (FileExists(txt)) { // wczytanie -/* TFileStream *ts = new TFileStream(txt, fmOpenRead); - asText = AnsiString::StringOfChar(' ', ts->Size); - ts->Read(asText.c_str(), ts->Size); - delete ts; -*/ std::ifstream inputfile( txt ); + std::ifstream inputfile( txt ); asText.assign( std::istreambuf_iterator( inputfile ), std::istreambuf_iterator() ); } }; -void TTextSound::Play(double Volume, int Looping, bool ListenerInside, vector3 NewPosition) +void TTextSound::Play(double Volume, int Looping, bool ListenerInside, Math3D::vector3 NewPosition) { if (false == asText.empty()) { // jeśli ma powiązany tekst DWORD stat; pSound->GetStatus(&stat); - if (!(stat & DSBSTATUS_PLAYING)) // jeśli nie jest aktualnie odgrywany - { -/* - std::string t( asText ); - size_t i; - do - { // na razie zrobione jakkolwiek, docelowo przenieść teksty do tablicy nazw - i = t.find('\r'); // znak nowej linii - if( i == std::string::npos ) { - Global::tranTexts.Add( t, fTime, true ); - } - else - { - Global::tranTexts.Add(t.substr(0, i), fTime, true); - t.erase(0, i + 1); - while (t.empty() ? false : (unsigned char)(t[1]) < 33) - t.erase(0, 1); - } - } while (i != std::string::npos); -*/ + if (!(stat & DSBSTATUS_PLAYING)) { + // jeśli nie jest aktualnie odgrywany Global::tranTexts.Add( asText, fTime, true ); } } diff --git a/RealSound.h b/old/RealSound.h similarity index 53% rename from RealSound.h rename to old/RealSound.h index e2312051..c72d76a0 100644 --- a/RealSound.h +++ b/old/RealSound.h @@ -7,24 +7,25 @@ obtain one at http://mozilla.org/MPL/2.0/. */ -#ifndef RealSoundH -#define RealSoundH +#pragma once #include -#include "Sound.h" -#include "Geometry.h" -class TRealSound -{ - protected: +#include "Sound.h" +#include "dumb3d.h" +#include "names.h" + +class TRealSound { + +protected: PSound pSound = nullptr; -// char *Nazwa; // dla celow odwszawiania NOTE: currently not used anywhere - double fDistance = 0.0, - fPreviousDistance = 0.0; // dla liczenia Dopplera + double fDistance = 0.0; + double fPreviousDistance = 0.0; // dla liczenia Dopplera float fFrequency = 22050.0; // częstotliwość samplowania pliku int iDoppler = 0; // Ra 2014-07: możliwość wyłączenia efektu Dopplera np. dla śpiewu ptaków - public: - vector3 vSoundPosition; // polozenie zrodla dzwieku +public: + std::string m_name; + Math3D::vector3 vSoundPosition; // polozenie zrodla dzwieku double dSoundAtt = -1.0; // odleglosc polowicznego zaniku dzwieku double AM = 0.0; // mnoznik amplitudy double AA = 0.0; // offset amplitudy @@ -32,36 +33,43 @@ class TRealSound double FA = 0.0; // offset czestotliwosci bool bLoopPlay = false; // czy zapętlony dźwięk jest odtwarzany TRealSound() = default; - TRealSound( std::string const &SoundName, double SoundAttenuation, double X, double Y, double Z, bool Dynamic, - bool freqmod = false, double rmin = 0.0); + TRealSound( std::string const &SoundName, double SoundAttenuation, double X, double Y, double Z, bool Dynamic, bool freqmod = false, double rmin = 0.0 ); ~TRealSound(); - void Free(); - void Init(std::string const &SoundName, double SoundAttenuation, double X, double Y, double Z, bool Dynamic, - bool freqmod = false, double rmin = 0.0); - double ListenerDistance(vector3 ListenerPosition); - void Play(double Volume, int Looping, bool ListenerInside, vector3 NewPosition); - void Start(); + void Init( std::string const &SoundName, double SoundAttenuation, double X, double Y, double Z, bool Dynamic, bool freqmod = false, double rmin = 0.0 ); + double ListenerDistance( Math3D::vector3 ListenerPosition); + void Play(double Volume, int Looping, bool ListenerInside, Math3D::vector3 NewPosition); void Stop(); void AdjFreq(double Freq, double dt); void SetPan(int Pan); double GetWaveTime(); // McZapkie TODO: dorobic dla roznych bps int GetStatus(); void ResetPosition(); - // void FreqReset(float f=22050.0) {fFrequency=f;}; + bool Empty() { return ( pSound == nullptr ); } + void + name( std::string Name ) { + m_name = Name; } + std::string const & + name() const { + return m_name; } + glm::dvec3 + location() const { + return vSoundPosition; }; }; -class TTextSound : public TRealSound -{ // dźwięk ze stenogramem + + +class TTextSound : public TRealSound { + // dźwięk ze stenogramem std::string asText; float fTime; // czas trwania - public: - TTextSound(std::string const &SoundName, double SoundAttenuation, double X, double Y, double Z, - bool Dynamic, bool freqmod = false, double rmin = 0.0); - void Init(std::string const &SoundName, double SoundAttenuation, double X, double Y, double Z, - bool Dynamic, bool freqmod = false, double rmin = 0.0); - void Play(double Volume, int Looping, bool ListenerInside, vector3 NewPosition); +public: + TTextSound(std::string const &SoundName, double SoundAttenuation, double X, double Y, double Z, bool Dynamic, bool freqmod = false, double rmin = 0.0); + void Init(std::string const &SoundName, double SoundAttenuation, double X, double Y, double Z, bool Dynamic, bool freqmod = false, double rmin = 0.0); + void Play(double Volume, int Looping, bool ListenerInside, Math3D::vector3 NewPosition); }; + + class TSynthSound { // klasa generująca sygnał odjazdu (Rp12, Rp13), potem rozbudować o pracę manewrowego... int iIndex[44]; // indeksy początkowe, gdy mamy kilka wariantów dźwięków składowych @@ -73,10 +81,16 @@ class TSynthSound // 41 - "tysiące" // 42 - indeksy początkowe dla "odjazd" // 43 - indeksy początkowe dla "gotów" - PSound *sSound; // posortowana tablica dźwięków, rozmiar zależny od liczby znalezionych plików + PSound sSound; // posortowana tablica dźwięków, rozmiar zależny od liczby znalezionych plików // a może zamiast wielu plików/dźwięków zrobić jeden połączony plik i posługiwać się czasem // od..do? }; + + +// collection of generators for power grid present in the scene +class sound_table : public basic_table { + +}; + //--------------------------------------------------------------------------- -#endif diff --git a/Sound.cpp b/old/Sound.cpp similarity index 53% rename from Sound.cpp rename to old/Sound.cpp index 101a3fdf..9c026893 100644 --- a/Sound.cpp +++ b/old/Sound.cpp @@ -8,14 +8,13 @@ http://mozilla.org/MPL/2.0/. */ #include "stdafx.h" -#define STRICT #include "Sound.h" #include "Globals.h" #include "Logs.h" #include "Usefull.h" #include "mczapkie/mctools.h" #include "WavRead.h" -//#define SAFE_DELETE(p) { if(p) { delete (p); (p)=NULL; } } + #define SAFE_RELEASE(p) \ { \ if (p) \ @@ -25,43 +24,31 @@ http://mozilla.org/MPL/2.0/. } \ } -char Directory[] = "sounds\\"; - LPDIRECTSOUND TSoundsManager::pDS; LPDIRECTSOUNDNOTIFY TSoundsManager::pDSNotify; int TSoundsManager::Count = 0; TSoundContainer *TSoundsManager::First = NULL; -TSoundContainer::TSoundContainer(LPDIRECTSOUND pDS, const char *Directory, const char *strFileName, - int NConcurrent) +TSoundContainer::TSoundContainer(LPDIRECTSOUND pDS, std::string const &Directory, std::string const &Filename, int NConcurrent) { // wczytanie pliku dźwiękowego int hr = 111; - DSBuffer = NULL; // na początek, gdyby uruchomić dźwięków się nie udało - + DSBuffer = nullptr; // na początek, gdyby uruchomić dźwięków się nie udało Concurrent = NConcurrent; - Oldest = 0; - // strcpy(Name, strFileName); - - strcpy(Name, Directory); - strcat(Name, strFileName); - - CWaveSoundRead *pWaveSoundRead; + m_name = Directory + Filename; // Create a new wave file class - pWaveSoundRead = new CWaveSoundRead(); + std::shared_ptr pWaveSoundRead = std::make_shared(); // Load the wave file - if (FAILED(pWaveSoundRead->Open(Name))) - if (FAILED(pWaveSoundRead->Open(strdup(strFileName)))) - { - // SetFileUI( hDlg, TEXT("Bad wave file.") ); - ErrorLog( "Missed sound: " + std::string( strFileName ) ); - return; - } + if( ( FAILED( pWaveSoundRead->Open( m_name ) ) ) + && ( FAILED( pWaveSoundRead->Open( Filename ) ) ) ) { + ErrorLog( "Missed sound: " + Filename ); + return; + } - strcpy(Name, ToLower(strFileName).c_str()); + m_name = ToLower( Filename ); // Set up the direct sound buffer, and only request the flags needed // since each requires some overhead and limits if the buffer can @@ -134,27 +121,10 @@ TSoundContainer::TSoundContainer(LPDIRECTSOUND pDS, const char *Directory, const // We dont need the wav file data buffer anymore, so delete it delete[] pbWavData; - delete pWaveSoundRead; - DSBuffers.push(DSBuffer); - - /* - for (int i=1; iDuplicateSoundBuffer(pDSBuffer[0],&(pDSBuffer[i])))) - { - Concurrent= i; - break; - }; - - - };*/ }; TSoundContainer::~TSoundContainer() { - // for (int i=Concurrent-1; i>=0; i--) - // SAFE_RELEASE( pDSBuffer[i] ); - // free(pDSBuffer); while (!DSBuffers.empty()) { SAFE_RELEASE(DSBuffers.top()); @@ -186,85 +156,51 @@ void TSoundsManager::Free() SAFE_RELEASE(pDS); }; -TSoundContainer * TSoundsManager::LoadFromFile(const char *Dir, const char *Name, int Concurrent) +TSoundContainer * TSoundsManager::LoadFromFile( std::string const &Dir, std::string const &Filename, int Concurrent) { - TSoundContainer *Tmp = First; - First = new TSoundContainer(pDS, Dir, Name, Concurrent); - First->Next = Tmp; + TSoundContainer *tmp = First; + First = new TSoundContainer(pDS, Dir, Filename, Concurrent); + First->Next = tmp; Count++; return First; // albo NULL, jak nie wyjdzie (na razie zawsze wychodzi) }; -void TSoundsManager::LoadSounds(char *Directory) -{ // wczytanie wszystkich plików z katalogu - mało elastyczne - WIN32_FIND_DATA FindFileData; - HANDLE handle = FindFirstFile("sounds\\*.wav", &FindFileData); - if (handle != INVALID_HANDLE_VALUE) - do - { - LoadFromFile(Directory, FindFileData.cFileName, 1); - } while (FindNextFile(handle, &FindFileData)); - FindClose(handle); -}; - -LPDIRECTSOUNDBUFFER TSoundsManager::GetFromName(const char *Name, bool Dynamic, float *fSamplingRate) +LPDIRECTSOUNDBUFFER TSoundsManager::GetFromName(std::string const &Name, bool Dynamic, float *fSamplingRate) { // wyszukanie dźwięku w pamięci albo wczytanie z pliku + std::string name{ ToLower(Name) }; std::string file; if (Dynamic) { // próba wczytania z katalogu pojazdu - file = Global::asCurrentDynamicPath + Name; + file = Global::asCurrentDynamicPath + name; if (FileExists(file)) - Name = file.c_str(); // nowa nazwa + name = file; // nowa nazwa else Dynamic = false; // wczytanie z "sounds/" } TSoundContainer *Next = First; - DWORD dwStatus; for (int i = 0; i < Count; i++) { - if (strcmp(Name, Next->Name) == 0) - { + if( name == Next->m_name ) { + if (fSamplingRate) *fSamplingRate = Next->fSamplingRate; // częstotliwość return (Next->GetUnique(pDS)); - // DSBuffers. - /* - Next->pDSBuffer[Next->Oldest]->Stop(); - Next->pDSBuffer[Next->Oldest]->SetCurrentPosition(0); - if (Next->OldestConcurrent-1) - { - Next->Oldest++; - return (Next->pDSBuffer[Next->Oldest-1]); - } - else - { - Next->Oldest= 0; - return (Next->pDSBuffer[Next->Concurrent-1]); - }; - - /* for (int j=0; jConcurrent; j++) - { - - Next->pDSBuffer[j]->GetStatus(&dwStatus); - if ((dwStatus & DSBSTATUS_PLAYING) != DSBSTATUS_PLAYING) - return (Next->pDSBuffer[j]); - } */ } else Next = Next->Next; }; if (Dynamic) // wczytanie z katalogu pojazdu - Next = LoadFromFile("", Name, 1); + Next = LoadFromFile("", name, 1); else - Next = LoadFromFile(Directory, Name, 1); + Next = LoadFromFile(szSoundPath, name, 1); if (Next) { // if (fSamplingRate) *fSamplingRate = Next->fSamplingRate; // częstotliwość return Next->GetUnique(pDS); } - ErrorLog("Missed sound: " + std::string(Name) ); - return (NULL); + ErrorLog("Missed sound: " + Name ); + return (nullptr); }; void TSoundsManager::RestoreAll() @@ -277,11 +213,6 @@ void TSoundsManager::RestoreAll() for (int i = 0; i < Count; i++) { - - if (FAILED(hr = Next->DSBuffer->GetStatus(&dwStatus))) - ; - // return hr; - if (dwStatus & DSBSTATUS_BUFFERLOST) { // Since the app could have just been activated, then @@ -293,7 +224,7 @@ void TSoundsManager::RestoreAll() hr = Next->DSBuffer->Restore(); if (hr == DSERR_BUFFERLOST) Sleep(10); - } while ((hr = Next->DSBuffer->Restore()) != NULL); + } while ((hr = Next->DSBuffer->Restore()) != 0); // char *Name= Next->Name; // int cc= Next->Concurrent; @@ -306,76 +237,21 @@ void TSoundsManager::RestoreAll() }; }; -// void TSoundsManager::Init(char *Name, int Concurrent) -// TSoundsManager::TSoundsManager(HWND hWnd) -// void TSoundsManager::Init(HWND hWnd, char *NDirectory) +bool TSoundsManager::Init(HWND hWnd) { -void TSoundsManager::Init(HWND hWnd) -{ - - First = NULL; + First = nullptr; Count = 0; - pDS = NULL; - pDSNotify = NULL; - - HRESULT hr; //=222; - LPDIRECTSOUNDBUFFER pDSBPrimary = NULL; - - // strcpy(Directory, NDirectory); + pDS = nullptr; + pDSNotify = nullptr; // Create IDirectSound using the primary sound device - hr = DirectSoundCreate(NULL, &pDS, NULL); - if (hr != DS_OK) - { + auto hr = ::DirectSoundCreate(NULL, &pDS, NULL); + if (hr != DS_OK) { - if (hr == DSERR_ALLOCATED) - return; - if (hr == DSERR_INVALIDPARAM) - return; - if (hr == DSERR_NOAGGREGATION) - return; - if (hr == DSERR_NODRIVER) - return; - if (hr == DSERR_OUTOFMEMORY) - return; - - // hr=0; + return false; }; - // return ; - // Set coop level to DSSCL_PRIORITY - // if( FAILED( hr = pDS->SetCooperativeLevel( hWnd, DSSCL_PRIORITY ) ) ); - // return ; - pDS->SetCooperativeLevel(hWnd, DSSCL_PRIORITY); + pDS->SetCooperativeLevel(hWnd, DSSCL_NORMAL); - // Get the primary buffer - DSBUFFERDESC dsbd; - ZeroMemory(&dsbd, sizeof(DSBUFFERDESC)); - dsbd.dwSize = sizeof(DSBUFFERDESC); - dsbd.dwFlags = DSBCAPS_PRIMARYBUFFER; - if (!Global::bInactivePause) // jeśli przełączony w tło ma nadal działać - dsbd.dwFlags |= DSBCAPS_GLOBALFOCUS; // to dźwięki mają być również słyszalne - dsbd.dwBufferBytes = 0; - dsbd.lpwfxFormat = NULL; - - if (FAILED(hr = pDS->CreateSoundBuffer(&dsbd, &pDSBPrimary, NULL))) - return; - - // Set primary buffer format to 22kHz and 16-bit output. - WAVEFORMATEX wfx; - ZeroMemory(&wfx, sizeof(WAVEFORMATEX)); - wfx.wFormatTag = WAVE_FORMAT_PCM; - wfx.nChannels = 2; - wfx.nSamplesPerSec = 44100; - wfx.wBitsPerSample = 16; - wfx.nBlockAlign = wfx.wBitsPerSample / 8 * wfx.nChannels; - wfx.nAvgBytesPerSec = wfx.nSamplesPerSec * wfx.nBlockAlign; - - if (FAILED(hr = pDSBPrimary->SetFormat(&wfx))) - return; - - SAFE_RELEASE(pDSBPrimary); + return true; }; - -//--------------------------------------------------------------------------- -#pragma package(smart_init) diff --git a/Sound.h b/old/Sound.h similarity index 50% rename from Sound.h rename to old/Sound.h index e003ef8d..393d7dad 100644 --- a/Sound.h +++ b/old/Sound.h @@ -7,56 +7,44 @@ obtain one at http://mozilla.org/MPL/2.0/. */ -#ifndef SoundH -#define SoundH +#pragma once #include #include typedef LPDIRECTSOUNDBUFFER PSound; -// inline Playing(PSound Sound) -//{ - -//} - class TSoundContainer { - public: +public: int Concurrent; int Oldest; - char Name[80]; + std::string m_name; LPDIRECTSOUNDBUFFER DSBuffer; float fSamplingRate; // częstotliwość odczytana z pliku int iBitsPerSample; // ile bitów na próbkę TSoundContainer *Next; std::stack DSBuffers; - LPDIRECTSOUNDBUFFER GetUnique(LPDIRECTSOUND pDS); - TSoundContainer(LPDIRECTSOUND pDS, const char *Directory, const char *strFileName, int NConcurrent); + + TSoundContainer(LPDIRECTSOUND pDS, std::string const &Directory, std::string const &Filename, int NConcurrent); ~TSoundContainer(); + LPDIRECTSOUNDBUFFER GetUnique( LPDIRECTSOUND pDS ); }; class TSoundsManager { - private: +private: static LPDIRECTSOUND pDS; static LPDIRECTSOUNDNOTIFY pDSNotify; - // static char Directory[80]; - static int Count; static TSoundContainer *First; - static TSoundContainer * LoadFromFile(const char *Dir, const char *Name, int Concurrent); + static int Count; - public: - // TSoundsManager(HWND hWnd); - // static void Init(HWND hWnd, char *NDirectory); - static void Init(HWND hWnd); + static TSoundContainer * LoadFromFile( std::string const &Directory, std::string const &FileName, int Concurrent); + +public: ~TSoundsManager(); + static bool Init( HWND hWnd ); static void Free(); - static void Init(char *Name, int Concurrent); - static void LoadSounds(char *Directory); - static LPDIRECTSOUNDBUFFER GetFromName(const char *Name, bool Dynamic, float *fSamplingRate = NULL); + static LPDIRECTSOUNDBUFFER GetFromName( std::string const &Name, bool Dynamic, float *fSamplingRate = NULL ); static void RestoreAll(); }; - -//--------------------------------------------------------------------------- -#endif diff --git a/McZapkie/Unit1.pas b/old/Unit1.pas similarity index 100% rename from McZapkie/Unit1.pas rename to old/Unit1.pas diff --git a/old/VBO.cpp b/old/VBO.cpp new file mode 100644 index 00000000..be4ea20a --- /dev/null +++ b/old/VBO.cpp @@ -0,0 +1,11 @@ +/* +This Source Code Form is subject to the +terms of the Mozilla Public License, v. +2.0. If a copy of the MPL was not +distributed with this file, You can +obtain one at +http://mozilla.org/MPL/2.0/. +*/ + +#include "stdafx.h" +#include "VBO.h" diff --git a/old/VBO.h b/old/VBO.h new file mode 100644 index 00000000..99a3fac7 --- /dev/null +++ b/old/VBO.h @@ -0,0 +1,19 @@ +/* +This Source Code Form is subject to the +terms of the Mozilla Public License, v. +2.0. If a copy of the MPL was not +distributed with this file, You can +obtain one at +http://mozilla.org/MPL/2.0/. +*/ + +#pragma once + +#include "openglgeometrybank.h" + +class CMesh +{ + public: + geometrybank_handle m_geometrybank; + bool m_geometrycreated { false }; +}; diff --git a/old/World.cpp b/old/World.cpp new file mode 100644 index 00000000..7c5ce712 --- /dev/null +++ b/old/World.cpp @@ -0,0 +1,1379 @@ +/* +This Source Code Form is subject to the +terms of the Mozilla Public License, v. +2.0. If a copy of the MPL was not +distributed with this file, You can +obtain one at +http://mozilla.org/MPL/2.0/. +*/ +/* + MaSzyna EU07 locomotive simulator + Copyright (C) 2001-2004 Marcin Wozniak, Maciej Czapkiewicz and others + +*/ + +#include "stdafx.h" +#include "World.h" + +#include "Globals.h" +#include "application.h" +#include "simulation.h" +#include "simulationtime.h" +#include "Logs.h" +#include "MdlMngr.h" +#include "renderer.h" +#include "Timer.h" +#include "mtable.h" +#include "Sound.h" +#include "ResourceManager.h" +#include "Event.h" +#include "Train.h" +#include "Driver.h" +#include "Console.h" +#include "color.h" +#include "uilayer.h" + +//--------------------------------------------------------------------------- + +TWorld World; + +extern "C" +{ + GLFWAPI HWND glfwGetWin32Window( GLFWwindow* window ); //m7todo: potrzebne do directsound +} + +TWorld::TWorld() +{ + Train = NULL; + for (int i = 0; i < 10; ++i) + KeyEvents[i] = NULL; // eventy wyzwalane klawiszami cyfrowymi + Global.iSlowMotion = 0; + fTimeBuffer = 0.0; // bufor czasu aktualizacji dla stałego kroku fizyki + fMaxDt = 0.01; //[s] początkowy krok czasowy fizyki + fTime50Hz = 0.0; // bufor czasu dla komunikacji z PoKeys +} + +TWorld::~TWorld() +{ + TrainDelete(); +} + +void TWorld::TrainDelete(TDynamicObject *d) +{ // usunięcie pojazdu prowadzonego przez użytkownika + if (d) + if (Train) + if (Train->Dynamic() != d) + return; // nie tego usuwać +/* + if( ( Train->Dynamic() ) + && ( Train->Dynamic()->Mechanik ) ) { + // likwidacja kabiny wymaga przejęcia przez AI + Train->Dynamic()->Mechanik->TakeControl( true ); + } +*/ + SafeDelete( Train ); // i nie ma czym sterować + Controlled = NULL; // tego też już nie ma + mvControlled = NULL; +}; + +bool TWorld::Init( GLFWwindow *Window ) { + + auto timestart = std::chrono::system_clock::now(); + + window = Window; + Global.pCamera = &Camera; // Ra: wskaźnik potrzebny do likwidacji drgań + + WriteLog( "\nStarting MaSzyna rail vehicle simulator (release: " + Global.asVersion + ")" ); + WriteLog( "For online documentation and additional files refer to: http://eu07.pl"); + WriteLog( "Authors: Marcin_EU, McZapkie, ABu, Winger, Tolaris, nbmx, OLO_EU, Bart, Quark-t, " + "ShaXbee, Oli_EU, youBy, KURS90, Ra, hunter, szociu, Stele, Q, firleju and others\n" ); + + UILayer.set_background( "logo" ); + glfwSetWindowTitle( window, ( Global.AppName + " (" + Global.SceneryFile + ")" ).c_str() ); // nazwa scenerii + UILayer.set_progress(0.01); + UILayer.set_progress( "Loading scenery / Wczytywanie scenerii" ); + GfxRenderer.Render(); + + WriteLog( "World setup..." ); + if( false == simulation::State.deserialize( Global.SceneryFile ) ) { return false; } + + simulation::Time.init(); + + Environment.init(); + Camera.Init(Global.FreeCameraInit[0], Global.FreeCameraInitAngle[0]); + + UILayer.set_progress( "Preparing train / Przygotowanie kabiny" ); + WriteLog( "Player train init: " + Global.asHumanCtrlVehicle ); + + TDynamicObject *nPlayerTrain; + if( Global.asHumanCtrlVehicle != "ghostview" ) + nPlayerTrain = simulation::Vehicles.find( Global.asHumanCtrlVehicle ); + if (nPlayerTrain) + { + Train = new TTrain(); + if( Train->Init( nPlayerTrain ) ) + { + Controlled = Train->Dynamic(); + mvControlled = Controlled->ControlledFind()->MoverParameters; + WriteLog("Player train init OK"); + + glfwSetWindowTitle( window, ( Global.AppName + " (" + Controlled->MoverParameters->Name + " @ " + Global.SceneryFile + ")" ).c_str() ); + + FollowView(); + } + else + { + Error("Player train init failed!"); + FreeFlyModeFlag = true; // Ra: automatycznie włączone latanie + Controlled = NULL; + mvControlled = NULL; + SafeDelete( Train ); + Camera.Type = TCameraType::tp_Free; + } + } + else + { + if (Global.asHumanCtrlVehicle != "ghostview") + { + Error("Player train doesn't exist!"); + } + FreeFlyModeFlag = true; // Ra: automatycznie włączone latanie + glfwSwapBuffers( window ); + Controlled = NULL; + mvControlled = NULL; + Camera.Type = TCameraType::tp_Free; + DebugCamera = Camera; + Global.DebugCameraPosition = DebugCamera.Pos; + } + + // if (!Global.bMultiplayer) //na razie włączone + { // eventy aktywowane z klawiatury tylko dla jednego użytkownika + KeyEvents[ 0 ] = simulation::Events.FindEvent( "keyctrl00" ); + KeyEvents[ 1 ] = simulation::Events.FindEvent( "keyctrl01" ); + KeyEvents[ 2 ] = simulation::Events.FindEvent( "keyctrl02" ); + KeyEvents[ 3 ] = simulation::Events.FindEvent( "keyctrl03" ); + KeyEvents[ 4 ] = simulation::Events.FindEvent( "keyctrl04" ); + KeyEvents[ 5 ] = simulation::Events.FindEvent( "keyctrl05" ); + KeyEvents[ 6 ] = simulation::Events.FindEvent( "keyctrl06" ); + KeyEvents[ 7 ] = simulation::Events.FindEvent( "keyctrl07" ); + KeyEvents[ 8 ] = simulation::Events.FindEvent( "keyctrl08" ); + KeyEvents[ 9 ] = simulation::Events.FindEvent( "keyctrl09" ); + } + + WriteLog( "Load time: " + + std::to_string( std::chrono::duration_cast(( std::chrono::system_clock::now() - timestart )).count() ) + + " seconds"); + + UILayer.set_progress(); + UILayer.set_progress( "" ); + UILayer.set_background( "" ); + + Timer::ResetTimers(); + + return true; +}; + +void TWorld::OnKeyDown(int cKey) { + // dump keypress info in the log + // podczas pauzy klawisze nie działają + std::string keyinfo; + auto keyname = glfwGetKeyName( cKey, 0 ); + if( keyname != nullptr ) { + keyinfo += std::string( keyname ); + } + else { + switch( cKey ) { + + case GLFW_KEY_SPACE: { keyinfo += "Space"; break; } + case GLFW_KEY_ENTER: { keyinfo += "Enter"; break; } + case GLFW_KEY_ESCAPE: { keyinfo += "Esc"; break; } + case GLFW_KEY_TAB: { keyinfo += "Tab"; break; } + case GLFW_KEY_INSERT: { keyinfo += "Insert"; break; } + case GLFW_KEY_DELETE: { keyinfo += "Delete"; break; } + case GLFW_KEY_HOME: { keyinfo += "Home"; break; } + case GLFW_KEY_END: { keyinfo += "End"; break; } + case GLFW_KEY_F1: { keyinfo += "F1"; break; } + case GLFW_KEY_F2: { keyinfo += "F2"; break; } + case GLFW_KEY_F3: { keyinfo += "F3"; break; } + case GLFW_KEY_F4: { keyinfo += "F4"; break; } + case GLFW_KEY_F5: { keyinfo += "F5"; break; } + case GLFW_KEY_F6: { keyinfo += "F6"; break; } + case GLFW_KEY_F7: { keyinfo += "F7"; break; } + case GLFW_KEY_F8: { keyinfo += "F8"; break; } + case GLFW_KEY_F9: { keyinfo += "F9"; break; } + case GLFW_KEY_F10: { keyinfo += "F10"; break; } + case GLFW_KEY_F11: { keyinfo += "F11"; break; } + case GLFW_KEY_F12: { keyinfo += "F12"; break; } + case GLFW_KEY_PAUSE: { keyinfo += "Pause"; break; } + } + } + if( keyinfo.empty() == false ) { + + std::string keymodifiers; + if( Global.shiftState ) + keymodifiers += "[Shift]+"; + if( Global.ctrlState ) + keymodifiers += "[Ctrl]+"; + + WriteLog( "Key pressed: " + keymodifiers + "[" + keyinfo + "]" ); + } + + // actual key processing + // TODO: redo the input system + if( ( cKey >= GLFW_KEY_0 ) && ( cKey <= GLFW_KEY_9 ) ) // klawisze cyfrowe + { + int i = cKey - GLFW_KEY_0; // numer klawisza + if (Global.shiftState) { + // z [Shift] uruchomienie eventu + if( ( false == Global.iPause ) // podczas pauzy klawisze nie działają + && ( KeyEvents[ i ] != nullptr ) ) { + simulation::Events.AddToQuery( KeyEvents[ i ], NULL ); + } + } + else // zapamiętywanie kamery może działać podczas pauzy + if (FreeFlyModeFlag) // w trybie latania można przeskakiwać do ustawionych kamer + if( ( Global.iTextMode != GLFW_KEY_F12 ) && + ( Global.iTextMode != GLFW_KEY_F3 ) ) // ograniczamy użycie kamer + { + if ((!Global.FreeCameraInit[i].x) + && (!Global.FreeCameraInit[i].y) + && (!Global.FreeCameraInit[i].z)) + { // jeśli kamera jest w punkcie zerowym, zapamiętanie współrzędnych i kątów + Global.FreeCameraInit[i] = Camera.Pos; + Global.FreeCameraInitAngle[i].x = Camera.Pitch; + Global.FreeCameraInitAngle[i].y = Camera.Yaw; + Global.FreeCameraInitAngle[i].z = Camera.Roll; + // logowanie, żeby można było do scenerii przepisać + WriteLog( + "camera " + std::to_string( Global.FreeCameraInit[i].x ) + " " + + std::to_string(Global.FreeCameraInit[i].y ) + " " + + std::to_string(Global.FreeCameraInit[i].z ) + " " + + std::to_string(RadToDeg(Global.FreeCameraInitAngle[i].x)) + " " + + std::to_string(RadToDeg(Global.FreeCameraInitAngle[i].y)) + " " + + std::to_string(RadToDeg(Global.FreeCameraInitAngle[i].z)) + " " + + std::to_string(i) + " endcamera"); + } + else // również przeskakiwanie + { // Ra: to z tą kamerą (Camera.Pos i Global.pCameraPosition) jest trochę bez sensu + Global.pCameraPosition = Global.FreeCameraInit[i]; // nowa pozycja dla generowania obiektów + Camera.Init(Global.FreeCameraInit[i], + Global.FreeCameraInitAngle[i]); // przestawienie + } + } + // będzie jeszcze załączanie sprzęgów z [Ctrl] + } + else if( ( cKey >= GLFW_KEY_F1 ) && ( cKey <= GLFW_KEY_F12 ) ) + { + switch (cKey) { + + case GLFW_KEY_F1: { + + if( DebugModeFlag ) { + // additional simulation clock jump keys in debug mode + if( Global.ctrlState ) { + // ctrl-f1 + simulation::Time.update( 20.0 * 60.0 ); + } + else if( Global.shiftState ) { + // shift-f1 + simulation::Time.update( 5.0 * 60.0 ); + } + } + break; + } + + case GLFW_KEY_F4: { + + InOutKey( !Global.shiftState ); // distant view with Shift, short distance step out otherwise + break; + } + case GLFW_KEY_F5: { + // przesiadka do innego pojazdu + if( false == FreeFlyModeFlag ) { + // only available in free fly mode + break; + } + + TDynamicObject *tmp = std::get( simulation::Region->find_vehicle( Global.pCameraPosition, 50, true, false ) ); + + if( ( tmp != nullptr ) + && ( tmp != Controlled ) ) { + + if( Controlled ) // jeśli mielismy pojazd + if( Controlled->Mechanik ) // na skutek jakiegoś błędu może czasem zniknąć + Controlled->Mechanik->TakeControl( true ); // oddajemy dotychczasowy AI + + if( DebugModeFlag + || (tmp->MoverParameters->Vel <= 5.0) ) { + // works always in debug mode, or for stopped/slow moving vehicles otherwise + Controlled = tmp; // przejmujemy nowy + mvControlled = Controlled->ControlledFind()->MoverParameters; + if( Train == nullptr ) + Train = new TTrain(); // jeśli niczym jeszcze nie jeździlismy + if( Train->Init( Controlled ) ) { // przejmujemy sterowanie + if( !DebugModeFlag ) { + // w DebugMode nadal prowadzi AI + Controlled->Mechanik->TakeControl( false ); + } + } + else { + SafeDelete( Train ); // i nie ma czym sterować + } + if( Train ) { + InOutKey(); // do kabiny + } + } + } + break; + } + case GLFW_KEY_F6: { + // przyspieszenie symulacji do testowania scenerii... uwaga na FPS! + if( DebugModeFlag ) { + + if( Global.ctrlState ) { Global.fTimeSpeed = ( Global.shiftState ? 60.0 : 20.0 ); } + else { Global.fTimeSpeed = ( Global.shiftState ? 5.0 : 1.0 ); } + } + break; + } + case GLFW_KEY_F7: { + // debug mode functions + if( DebugModeFlag ) { + + if( Global.ctrlState + && Global.shiftState ) { + // shift + ctrl + f7 toggles between debug and regular camera + DebugCameraFlag = !DebugCameraFlag; + } + else if( Global.ctrlState ) { + // ctrl + f7 toggles static daylight + ToggleDaylight(); + break; + } + else if( Global.shiftState ) { + // shift + f7 is currently unused + } + else { + // f7: wireframe toggle + // TODO: pass this to renderer instead of making direct calls + Global.bWireFrame = !Global.bWireFrame; + if( true == Global.bWireFrame ) { + glPolygonMode( GL_FRONT_AND_BACK, GL_LINE ); + } + else { + glPolygonMode( GL_FRONT_AND_BACK, GL_FILL ); + } + } + } + break; + } + case GLFW_KEY_F11: { + // scenery export + if( Global.ctrlState + && Global.shiftState ) { + simulation::State.export_as_text( Global.SceneryFile ); + } + break; + } + case GLFW_KEY_F12: { + // quick debug mode toggle + if( Global.ctrlState + && Global.shiftState ) { + DebugModeFlag = !DebugModeFlag; + } + break; + } + + default: { + break; + } + } + // if (cKey!=VK_F4) + return; // nie są przekazywane do pojazdu wcale + } + + if ((Global.iTextMode == GLFW_KEY_F12) ? (cKey >= '0') && (cKey <= '9') : false) + { // tryb konfiguracji debugmode (przestawianie kamery już wyłączone + if (!Global.shiftState) // bez [Shift] + { + if (cKey == GLFW_KEY_1) + Global.iWriteLogEnabled ^= 1; // włącz/wyłącz logowanie do pliku + else if (cKey == GLFW_KEY_2) + { // włącz/wyłącz okno konsoli + Global.iWriteLogEnabled ^= 2; + if ((Global.iWriteLogEnabled & 2) == 0) // nie było okienka + { // otwarcie okna + AllocConsole(); // jeśli konsola już jest, to zwróci błąd; uwalniać nie ma po + // co, bo się odłączy + SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_GREEN); + } + } + // else if (cKey=='3') Global.iWriteLogEnabled^=4; //wypisywanie nazw torów + } + } + else if( cKey == GLFW_KEY_ESCAPE ) { + // toggle pause + if( Global.iPause & 1 ) // jeśli pauza startowa + Global.iPause &= ~1; // odpauzowanie, gdy po wczytaniu miało nie startować + else if( !( Global.iMultiplayer & 2 ) ) // w multiplayerze pauza nie ma sensu + Global.iPause ^= 2; // zmiana stanu zapauzowania + if( Global.iPause ) {// jak pauza + Global.iTextMode = GLFW_KEY_F1; // to wyświetlić zegar i informację + } + } + else { + + if( ( true == DebugModeFlag ) + && ( false == Global.shiftState ) + && ( true == Global.ctrlState ) + && ( Controlled != nullptr ) + && ( Controlled->Controller == Humandriver ) ) { + + if( DebugModeFlag ) { + // przesuwanie składu o 100m + TDynamicObject *d = Controlled; + if( cKey == GLFW_KEY_LEFT_BRACKET ) { + while( d ) { + d->Move( 100.0 * d->DirectionGet() ); + d = d->Next(); // pozostałe też + } + d = Controlled->Prev(); + while( d ) { + d->Move( 100.0 * d->DirectionGet() ); + d = d->Prev(); // w drugą stronę też + } + } + else if( cKey == GLFW_KEY_RIGHT_BRACKET ) { + while( d ) { + d->Move( -100.0 * d->DirectionGet() ); + d = d->Next(); // pozostałe też + } + d = Controlled->Prev(); + while( d ) { + d->Move( -100.0 * d->DirectionGet() ); + d = d->Prev(); // w drugą stronę też + } + } + else if( cKey == GLFW_KEY_TAB ) { + while( d ) { + d->MoverParameters->V += d->DirectionGet()*2.78; + d = d->Next(); // pozostałe też + } + d = Controlled->Prev(); + while( d ) { + d->MoverParameters->V += d->DirectionGet()*2.78; + d = d->Prev(); // w drugą stronę też + } + } + } + } + } +} + +void TWorld::InOutKey( bool const Near ) +{ // przełączenie widoku z kabiny na zewnętrzny i odwrotnie + FreeFlyModeFlag = !FreeFlyModeFlag; // zmiana widoku + if (FreeFlyModeFlag) { + // jeżeli poza kabiną, przestawiamy w jej okolicę - OK + if (Train) { + // cache current cab position so there's no need to set it all over again after each out-in switch + Train->pMechSittingPosition = Train->pMechOffset; + + Train->Dynamic()->bDisplayCab = false; + DistantView( Near ); + } + DebugCamera = Camera; + Global.DebugCameraPosition = DebugCamera.Pos; + } + else + { // jazda w kabinie + if (Train) + { + Train->Dynamic()->bDisplayCab = true; + // zerowanie przesunięcia przed powrotem? + Train->Dynamic()->ABuSetModelShake( { 0, 0, 0 } ); + Train->MechStop(); + FollowView(); // na pozycję mecha + } + else + FreeFlyModeFlag = true; // nadal poza kabiną + } + // update window title to reflect the situation + glfwSetWindowTitle( + window, + ( Global.AppName + + " (" + + ( Controlled != nullptr ? + Controlled->MoverParameters->Name : + "" ) + + " @ " + + Global.SceneryFile + + ")" ).c_str() ); +}; + +// places camera outside the controlled vehicle, or nearest if nothing is under control +// depending on provided switch the view is placed right outside, or at medium distance +void TWorld::DistantView( bool const Near ) +{ // ustawienie widoku pojazdu z zewnątrz + + TDynamicObject const *vehicle{ nullptr }; + if( nullptr != Controlled ) { vehicle = Controlled; } + else if( nullptr != pDynamicNearest ) { vehicle = pDynamicNearest; } + else { return; } + + auto const cab = + ( vehicle->MoverParameters->ActiveCab == 0 ? + 1 : + vehicle->MoverParameters->ActiveCab ); + auto const left = vehicle->VectorLeft() * cab; + + if( true == Near ) { + + Camera.Pos = + Math3D::vector3( Camera.Pos.x, vehicle->GetPosition().y, Camera.Pos.z ) + + left * vehicle->GetWidth() + + Math3D::vector3( 1.25 * left.x, 1.6, 1.25 * left.z ); + } + else { + + Camera.Pos = + vehicle->GetPosition() + + vehicle->VectorFront() * vehicle->MoverParameters->ActiveCab * 50.0 + + Math3D::vector3( -10.0 * left.x, 1.6, -10.0 * left.z ); + } + + Camera.LookAt = vehicle->GetPosition(); + Camera.RaLook(); // jednorazowe przestawienie kamery +}; + +// ustawienie śledzenia pojazdu +void TWorld::FollowView(bool wycisz) { + + Camera.Reset(); // likwidacja obrotów - patrzy horyzontalnie na południe + + if (Controlled) // jest pojazd do prowadzenia? + { + if (FreeFlyModeFlag) + { // jeżeli poza kabiną, przestawiamy w jej okolicę - OK + if( Train ) { + // wyłączenie trzęsienia na siłę? + Train->Dynamic()->ABuSetModelShake( {} ); + } + + DistantView(); // przestawienie kamery + //żeby nie bylo numerów z 'fruwajacym' lokiem - konsekwencja bujania pudła + // tu ustawić nową, bo od niej liczą się odległości + Global.pCameraPosition = Camera.Pos; + } + else if (Train) { + Camera.Pos = Train->pMechPosition; + // potentially restore cached camera angles + Camera.Pitch = Train->pMechViewAngle.x; + Camera.Yaw = Train->pMechViewAngle.y; + + Camera.Roll = std::atan(Train->pMechShake.x * Train->fMechRoll); // hustanie kamery na boki + Camera.Pitch -= 0.5 * std::atan(Train->vMechVelocity.z * Train->fMechPitch); // hustanie kamery przod tyl + + if( Train->Dynamic()->MoverParameters->ActiveCab == 0 ) { + Camera.LookAt = + Train->pMechPosition + + Train->GetDirection() * 5.0; + } + else { + // patrz w strone wlasciwej kabiny + Camera.LookAt = + Train->pMechPosition + + Train->GetDirection() * 5.0 * Train->Dynamic()->MoverParameters->ActiveCab; + } + Train->pMechOffset = Train->pMechSittingPosition; + } + } + else + DistantView(); +}; + +bool TWorld::Update() { + + Timer::UpdateTimers(Global.iPause != 0); + Timer::subsystem.sim_total.start(); + + if( (Global.iPause == 0) + || (m_init == false) ) { + // jak pauza, to nie ma po co tego przeliczać + simulation::Time.update( Timer::GetDeltaTime() ); + // Ra 2014-07: przeliczenie kąta czasu (do animacji zależnych od czasu) + auto const &time = simulation::Time.data(); + Global.fTimeAngleDeg = time.wHour * 15.0 + time.wMinute * 0.25 + ( ( time.wSecond + 0.001 * time.wMilliseconds ) / 240.0 ); + Global.fClockAngleDeg[ 0 ] = 36.0 * ( time.wSecond % 10 ); // jednostki sekund + Global.fClockAngleDeg[ 1 ] = 36.0 * ( time.wSecond / 10 ); // dziesiątki sekund + Global.fClockAngleDeg[ 2 ] = 36.0 * ( time.wMinute % 10 ); // jednostki minut + Global.fClockAngleDeg[ 3 ] = 36.0 * ( time.wMinute / 10 ); // dziesiątki minut + Global.fClockAngleDeg[ 4 ] = 36.0 * ( time.wHour % 10 ); // jednostki godzin + Global.fClockAngleDeg[ 5 ] = 36.0 * ( time.wHour / 10 ); // dziesiątki godzin + + Update_Environment(); + } // koniec działań niewykonywanych podczas pauzy + + // fixed step, simulation time based updates + + double dt = Timer::GetDeltaTime(); // 0.0 gdy pauza +/* + fTimeBuffer += dt; //[s] dodanie czasu od poprzedniej ramki +*/ +// m_primaryupdateaccumulator += dt; // unused for the time being + m_secondaryupdateaccumulator += dt; +/* + if (fTimeBuffer >= fMaxDt) // jest co najmniej jeden krok; normalnie 0.01s + { // Ra: czas dla fizyki jest skwantowany - fizykę lepiej przeliczać stałym krokiem + // tak można np. moc silników itp., ale ruch musi być przeliczany w każdej klatce, bo + // inaczej skacze + Global.tranTexts.Update(); // obiekt obsługujący stenogramy dźwięków na ekranie + Console::Update(); // obsługa cykli PoKeys (np. aktualizacja wyjść analogowych) + double iter = + ceil(fTimeBuffer / fMaxDt); // ile kroków się zmieściło od ostatniego sprawdzania? + int n = int(iter); // ile kroków jako int + fTimeBuffer -= iter * fMaxDt; // reszta czasu na potem (do bufora) + if (n > 20) + n = 20; // Ra: jeżeli FPS jest zatrważająco niski, to fizyka nie może zająć całkowicie procesora + } +*/ +/* + // NOTE: until we have no physics state interpolation during render, we need to rely on the old code, + // as doing fixed step calculations but flexible step render results in ugly mini jitter + // core routines (physics) + int updatecount = 0; + while( ( m_primaryupdateaccumulator >= m_primaryupdaterate ) + &&( updatecount < 20 ) ) { + // no more than 20 updates per single pass, to keep physics from hogging up all run time + Ground.Update( m_primaryupdaterate, 1 ); + ++updatecount; + m_primaryupdateaccumulator -= m_primaryupdaterate; + } +*/ + int updatecount = 1; + if( dt > m_primaryupdaterate ) // normalnie 0.01s + { +/* + // NOTE: experimentally disabled physics update cap + auto const iterations = std::ceil(dt / m_primaryupdaterate); + updatecount = std::min( 20, static_cast( iterations ) ); +*/ + updatecount = std::ceil( dt / m_primaryupdaterate ); +/* + // NOTE: changing dt wrecks things further down the code. re-acquire proper value later or cleanup here + dt = dt / iterations; // Ra: fizykę lepiej by było przeliczać ze stałym krokiem +*/ + } + auto const stepdeltatime { dt / updatecount }; + // NOTE: updates are limited to 20, but dt is distributed over potentially many more iterations + // this means at count > 20 simulation and render are going to desync. is that right? + // NOTE: experimentally changing this to prevent the desync. + // TODO: test what happens if we hit more than 20 * 0.01 sec slices, i.e. less than 5 fps + Timer::subsystem.sim_dynamics.start(); + if( true == Global.FullPhysics ) { + // mixed calculation mode, steps calculated in ~0.05s chunks + while( updatecount >= 5 ) { + simulation::State.update( stepdeltatime, 5 ); + updatecount -= 5; + } + if( updatecount ) { + simulation::State.update( stepdeltatime, updatecount ); + } + } + else { + // simplified calculation mode; faster but can lead to errors + simulation::State.update( stepdeltatime, updatecount ); + } + Timer::subsystem.sim_dynamics.stop(); + + // secondary fixed step simulation time routines + while( m_secondaryupdateaccumulator >= m_secondaryupdaterate ) { + + ui::Transcripts.Update(); // obiekt obsługujący stenogramy dźwięków na ekranie + + // awaria PoKeys mogła włączyć pauzę - przekazać informację + if( Global.iMultiplayer ) // dajemy znać do serwera o wykonaniu + if( iPause != Global.iPause ) { // przesłanie informacji o pauzie do programu nadzorującego + multiplayer::WyslijParam( 5, 3 ); // ramka 5 z czasem i stanem zapauzowania + iPause = Global.iPause; + } + + // fixed step part of the camera update + if( ( Train != nullptr ) + && ( Camera.Type == TCameraType::tp_Follow ) + && ( false == DebugCameraFlag ) ) { + // jeśli jazda w kabinie, przeliczyć trzeba parametry kamery + Train->UpdateMechPosition( m_secondaryupdaterate ); + } + + m_secondaryupdateaccumulator -= m_secondaryupdaterate; // these should be inexpensive enough we have no cap + } + + // variable step simulation time routines + + if( Global.changeDynObj ) { + // ABu zmiana pojazdu - przejście do innego + ChangeDynamic(); + } + + if( Train != nullptr ) { + TSubModel::iInstance = reinterpret_cast( Train->Dynamic() ); + Train->Update( dt ); + } + else { + TSubModel::iInstance = 0; + } + + simulation::Events.update(); + simulation::Region->update_events(); + simulation::Lights.update(); + + // render time routines follow: + + dt = Timer::GetDeltaRenderTime(); // nie uwzględnia pauzowania ani mnożenia czasu + + // fixed step render time routines + + fTime50Hz += dt; // w pauzie też trzeba zliczać czas, bo przy dużym FPS będzie problem z odczytem ramek + while( fTime50Hz >= 1.0 / 50.0 ) { + Console::Update(); // to i tak trzeba wywoływać + UILayer.update(); + // decelerate camera + Camera.Velocity *= 0.65; + if( std::abs( Camera.Velocity.x ) < 0.01 ) { Camera.Velocity.x = 0.0; } + if( std::abs( Camera.Velocity.y ) < 0.01 ) { Camera.Velocity.y = 0.0; } + if( std::abs( Camera.Velocity.z ) < 0.01 ) { Camera.Velocity.z = 0.0; } + // decelerate debug camera too + DebugCamera.Velocity *= 0.65; + if( std::abs( DebugCamera.Velocity.x ) < 0.01 ) { DebugCamera.Velocity.x = 0.0; } + if( std::abs( DebugCamera.Velocity.y ) < 0.01 ) { DebugCamera.Velocity.y = 0.0; } + if( std::abs( DebugCamera.Velocity.z ) < 0.01 ) { DebugCamera.Velocity.z = 0.0; } + + fTime50Hz -= 1.0 / 50.0; + } + + // variable step render time routines + + Update_Camera( dt ); + + Timer::subsystem.sim_total.stop(); + + simulation::Region->update_sounds(); + audio::renderer.update( dt ); + + GfxRenderer.Update( dt ); + + m_init = true; + + return true; +}; + +void +TWorld::Update_Camera( double const Deltatime ) { + + if( false == Global.ControlPicking ) { + if( glfwGetMouseButton( window, GLFW_MOUSE_BUTTON_LEFT ) == GLFW_PRESS ) { + Camera.Reset(); // likwidacja obrotów - patrzy horyzontalnie na południe + if( Controlled && LengthSquared3( Controlled->GetPosition() - Camera.Pos ) < ( 1500 * 1500 ) ) { + // gdy bliżej niż 1.5km + Camera.LookAt = Controlled->GetPosition(); + } + else { + TDynamicObject *d = std::get( simulation::Region->find_vehicle( Global.pCameraPosition, 300, false, false ) ); + if( !d ) + d = std::get( simulation::Region->find_vehicle( Global.pCameraPosition, 1000, false, false ) ); // dalej szukanie, jesli bliżej nie ma + + if( d && pDynamicNearest ) { + // jeśli jakiś jest znaleziony wcześniej + if( 100.0 * LengthSquared3( d->GetPosition() - Camera.Pos ) > LengthSquared3( pDynamicNearest->GetPosition() - Camera.Pos ) ) { + d = pDynamicNearest; // jeśli najbliższy nie jest 10 razy bliżej niż + } + } + // poprzedni najbliższy, zostaje poprzedni + if( d ) + pDynamicNearest = d; // zmiana na nowy, jeśli coś znaleziony niepusty + if( pDynamicNearest ) + Camera.LookAt = pDynamicNearest->GetPosition(); + } + if( FreeFlyModeFlag ) + Camera.RaLook(); // jednorazowe przestawienie kamery + } + else if( glfwGetMouseButton( window, GLFW_MOUSE_BUTTON_RIGHT ) == GLFW_PRESS ) { + FollowView( false ); // bez wyciszania dźwięków + } + else if( glfwGetMouseButton( window, GLFW_MOUSE_BUTTON_MIDDLE ) == GLFW_PRESS ) { + // middle mouse button controls zoom. + Global.ZoomFactor = std::min( 4.5f, Global.ZoomFactor + 15.0f * static_cast( Deltatime ) ); + } + else if( glfwGetMouseButton( window, GLFW_MOUSE_BUTTON_MIDDLE ) != GLFW_PRESS ) { + // reset zoom level if the button is no longer held down. + // NOTE: yes, this is terrible way to go about it. it'll do for now. + Global.ZoomFactor = std::max( 1.0f, Global.ZoomFactor - 15.0f * static_cast( Deltatime ) ); + } + } + + if( DebugCameraFlag ) { DebugCamera.Update(); } + else { Camera.Update(); } // uwzględnienie ruchu wywołanego klawiszami + + if( ( false == FreeFlyModeFlag ) + && ( false == Global.CabWindowOpen ) + && ( Train != nullptr ) ) { + // cache cab camera view angles in case of view type switch + Train->pMechViewAngle = { Camera.Pitch, Camera.Yaw }; + } + + // reset window state, it'll be set again if applicable in a check below + Global.CabWindowOpen = false; + + if( ( Train != nullptr ) + && ( Camera.Type == TCameraType::tp_Follow ) + && ( false == DebugCameraFlag ) ) { + // jeśli jazda w kabinie, przeliczyć trzeba parametry kamery + auto tempangle = Controlled->VectorFront() * ( Controlled->MoverParameters->ActiveCab == -1 ? -1 : 1 ); +// double modelrotate = atan2( -tempangle.x, tempangle.z ); + + if( ( true == Global.ctrlState ) + && ( ( glfwGetKey( Application.window(), GLFW_KEY_LEFT ) == GLFW_TRUE ) + || ( glfwGetKey( Application.window(), GLFW_KEY_RIGHT ) == GLFW_TRUE ) ) ) { + // jeśli lusterko lewe albo prawe (bez rzucania na razie) + Global.CabWindowOpen = true; + + auto const lr { glfwGetKey( Application.window(), GLFW_KEY_LEFT ) == GLFW_TRUE }; + // Camera.Yaw powinno być wyzerowane, aby po powrocie patrzeć do przodu + Camera.Pos = Controlled->GetPosition() + Train->MirrorPosition( lr ); // pozycja lusterka + Camera.Yaw = 0; // odchylenie na bok od Camera.LookAt + if( Train->Dynamic()->MoverParameters->ActiveCab == 0 ) + Camera.LookAt = Camera.Pos - Train->GetDirection(); // gdy w korytarzu + else if( Global.shiftState ) { + // patrzenie w bok przez szybę + Camera.LookAt = Camera.Pos - ( lr ? -1 : 1 ) * Train->Dynamic()->VectorLeft() * Train->Dynamic()->MoverParameters->ActiveCab; + } + else { // patrzenie w kierunku osi pojazdu, z uwzględnieniem kabiny - jakby z lusterka, + // ale bez odbicia + Camera.LookAt = Camera.Pos - Train->GetDirection() * Train->Dynamic()->MoverParameters->ActiveCab; //-1 albo 1 + } + Camera.Roll = std::atan( Train->pMechShake.x * Train->fMechRoll ); // hustanie kamery na boki + Camera.Pitch = 0.5 * std::atan( Train->vMechVelocity.z * Train->fMechPitch ); // hustanie kamery przod tyl + Camera.vUp = Controlled->VectorUp(); + } + else { + // patrzenie standardowe + // potentially restore view angle after returning from external view + // TODO: mirror view toggle as separate method + Camera.Pitch = Train->pMechViewAngle.x; + Camera.Yaw = Train->pMechViewAngle.y; + + Camera.Pos = Train->GetWorldMechPosition(); // Train.GetPosition1(); + if( !Global.iPause ) { + // podczas pauzy nie przeliczać kątów przypadkowymi wartościami + // hustanie kamery na boki + Camera.Roll = atan( Train->vMechVelocity.x * Train->fMechRoll ); + // hustanie kamery przod tyl + // Ra: tu jest uciekanie kamery w górę!!! + Camera.Pitch -= 0.5 * atan( Train->vMechVelocity.z * Train->fMechPitch ); + } +/* + // ABu011104: rzucanie pudlem + vector3 temp; + if( abs( Train->pMechShake.y ) < 0.25 ) + temp = vector3( 0, 0, 6 * Train->pMechShake.y ); + else if( ( Train->pMechShake.y ) > 0 ) + temp = vector3( 0, 0, 6 * 0.25 ); + else + temp = vector3( 0, 0, -6 * 0.25 ); + if( Controlled ) + Controlled->ABuSetModelShake( temp ); + // ABu: koniec rzucania +*/ + if( Train->Dynamic()->MoverParameters->ActiveCab == 0 ) + Camera.LookAt = Train->GetWorldMechPosition() + Train->GetDirection() * 5.0; // gdy w korytarzu + else // patrzenie w kierunku osi pojazdu, z uwzględnieniem kabiny + Camera.LookAt = Train->GetWorldMechPosition() + Train->GetDirection() * 5.0 * Train->Dynamic()->MoverParameters->ActiveCab; //-1 albo 1 + Camera.vUp = Train->GetUp(); + } + } + else { + // kamera nieruchoma + } + // all done, update camera position to the new value + Global.pCameraPosition = Camera.Pos; + Global.DebugCameraPosition = DebugCamera.Pos; +} + +void TWorld::Update_Environment() { + + Environment.update(); +} + +//--------------------------------------------------------------------------- +void TWorld::OnCommandGet(multiplayer::DaneRozkaz *pRozkaz) +{ // odebranie komunikatu z serwera + if (pRozkaz->iSygn == MAKE_ID4('E','U','0','7') ) + switch (pRozkaz->iComm) + { + case 0: // odesłanie identyfikatora wersji + CommLog( Now() + " " + std::to_string(pRozkaz->iComm) + " version" + " rcvd"); + multiplayer::WyslijString(Global.asVersion, 0); // przedsatwienie się + break; + case 1: // odesłanie identyfikatora wersji + CommLog( Now() + " " + std::to_string(pRozkaz->iComm) + " scenery" + " rcvd"); + multiplayer::WyslijString(Global.SceneryFile, 1); // nazwa scenerii + break; + case 2: { + // event + CommLog( Now() + " " + std::to_string( pRozkaz->iComm ) + " " + + std::string( pRozkaz->cString + 1, (unsigned)( pRozkaz->cString[ 0 ] ) ) + " rcvd" ); + + if( Global.iMultiplayer ) { + auto *event = simulation::Events.FindEvent( std::string( pRozkaz->cString + 1, (unsigned)( pRozkaz->cString[ 0 ] ) ) ); + if( event != nullptr ) { + if( ( event->Type == tp_Multiple ) + || ( event->Type == tp_Lights ) + || ( event->evJoined != 0 ) ) { + // tylko jawne albo niejawne Multiple + simulation::Events.AddToQuery( event, nullptr ); // drugi parametr to dynamic wywołujący - tu brak + } + } + } + break; + } + case 3: // rozkaz dla AI + if (Global.iMultiplayer) + { + int i = int(pRozkaz->cString[8]); // długość pierwszego łańcucha (z przodu dwa floaty) + CommLog( + Now() + " " + to_string(pRozkaz->iComm) + " " + + std::string(pRozkaz->cString + 11 + i, (unsigned)(pRozkaz->cString[10 + i])) + + " rcvd"); + // nazwa pojazdu jest druga + auto *vehicle = simulation::Vehicles.find( { pRozkaz->cString + 11 + i, (unsigned)pRozkaz->cString[ 10 + i ] } ); + if( ( vehicle != nullptr ) + && ( vehicle->Mechanik != nullptr ) ) { + vehicle->Mechanik->PutCommand( + { pRozkaz->cString + 9, static_cast(i) }, + pRozkaz->fPar[0], pRozkaz->fPar[1], + nullptr, + stopExt ); // floaty są z przodu + WriteLog("AI command: " + std::string(pRozkaz->cString + 9, i)); + } + } + break; + case 4: // badanie zajętości toru + { + CommLog(Now() + " " + to_string(pRozkaz->iComm) + " " + + std::string(pRozkaz->cString + 1, (unsigned)(pRozkaz->cString[0])) + " rcvd"); + + auto *track = simulation::Paths.find( std::string( pRozkaz->cString + 1, (unsigned)( pRozkaz->cString[ 0 ] ) ) ); + if( ( track != nullptr ) + && ( track->IsEmpty() ) ) { + multiplayer::WyslijWolny( track->name() ); + } + } + break; + case 5: // ustawienie parametrów + { + CommLog(Now() + " " + to_string(pRozkaz->iComm) + " params " + to_string(*pRozkaz->iPar) + " rcvd"); + if (*pRozkaz->iPar == 0) // sprawdzenie czasu + if (*pRozkaz->iPar & 1) // ustawienie czasu + { + double t = pRozkaz->fPar[1]; + simulation::Time.data().wDay = std::floor(t); // niby nie powinno być dnia, ale... + if (Global.fMoveLight >= 0) + Global.fMoveLight = t; // trzeba by deklinację Słońca przeliczyć + simulation::Time.data().wHour = std::floor(24 * t) - 24.0 * simulation::Time.data().wDay; + simulation::Time.data().wMinute = std::floor(60 * 24 * t) - 60.0 * (24.0 * simulation::Time.data().wDay + simulation::Time.data().wHour); + simulation::Time.data().wSecond = std::floor( 60 * 60 * 24 * t ) - 60.0 * ( 60.0 * ( 24.0 * simulation::Time.data().wDay + simulation::Time.data().wHour ) + simulation::Time.data().wMinute ); + } + if (*pRozkaz->iPar & 2) + { // ustawienie flag zapauzowania + Global.iPause = pRozkaz->fPar[2]; // zakładamy, że wysyłający wie, co robi + } + } + break; + case 6: // pobranie parametrów ruchu pojazdu + if (Global.iMultiplayer) { + // Ra 2014-12: to ma działać również dla pojazdów bez obsady + CommLog( + Now() + " " + + to_string( pRozkaz->iComm ) + " " + + std::string{ pRozkaz->cString + 1, (unsigned)( pRozkaz->cString[ 0 ] ) } + + " rcvd" ); + if (pRozkaz->cString[0]) { + // jeśli długość nazwy jest niezerowa szukamy pierwszego pojazdu o takiej nazwie i odsyłamy parametry ramką #7 + auto *vehicle = ( + pRozkaz->cString[ 1 ] == '*' ? + simulation::Vehicles.find( Global.asHumanCtrlVehicle ) : + simulation::Vehicles.find( std::string{ pRozkaz->cString + 1, (unsigned)pRozkaz->cString[ 0 ] } ) ); + if( vehicle != nullptr ) { + multiplayer::WyslijNamiary( vehicle ); // wysłanie informacji o pojeździe + } + } + else { + // dla pustego wysyłamy ramki 6 z nazwami pojazdów AI (jeśli potrzebne wszystkie, to rozpoznać np. "*") + simulation::Vehicles.DynamicList(); + } + } + break; + case 8: // ponowne wysłanie informacji o zajętych odcinkach toru + CommLog(Now() + " " + to_string(pRozkaz->iComm) + " all busy track" + " rcvd"); + simulation::Paths.TrackBusyList(); + break; + case 9: // ponowne wysłanie informacji o zajętych odcinkach izolowanych + CommLog(Now() + " " + to_string(pRozkaz->iComm) + " all busy isolated" + " rcvd"); + simulation::Paths.IsolatedBusyList(); + break; + case 10: // badanie zajętości jednego odcinka izolowanego + CommLog(Now() + " " + to_string(pRozkaz->iComm) + " " + + std::string(pRozkaz->cString + 1, (unsigned)(pRozkaz->cString[0])) + " rcvd"); + simulation::Paths.IsolatedBusy( std::string( pRozkaz->cString + 1, (unsigned)( pRozkaz->cString[ 0 ] ) ) ); + break; + case 11: // ustawienie parametrów ruchu pojazdu + // Ground.IsolatedBusy(AnsiString(pRozkaz->cString+1,(unsigned)(pRozkaz->cString[0]))); + break; + case 12: // skrocona ramka parametrow pojazdow AI (wszystkich!!) + CommLog(Now() + " " + to_string(pRozkaz->iComm) + " obsadzone" + " rcvd"); + multiplayer::WyslijObsadzone(); + // Ground.IsolatedBusy(AnsiString(pRozkaz->cString+1,(unsigned)(pRozkaz->cString[0]))); + break; + case 13: // ramka uszkodzenia i innych stanow pojazdu, np. wylaczenie CA, wlaczenie recznego itd. + CommLog(Now() + " " + to_string(pRozkaz->iComm) + " " + + std::string(pRozkaz->cString + 1, (unsigned)(pRozkaz->cString[0])) + + " rcvd"); + if( pRozkaz->cString[ 1 ] ) // jeśli długość nazwy jest niezerowa + { // szukamy pierwszego pojazdu o takiej nazwie i odsyłamy parametry ramką #13 + auto *lookup = ( + pRozkaz->cString[ 2 ] == '*' ? + simulation::Vehicles.find( Global.asHumanCtrlVehicle ) : // nazwa pojazdu użytkownika + simulation::Vehicles.find( std::string( pRozkaz->cString + 2, (unsigned)pRozkaz->cString[ 1 ] ) ) ); // nazwa pojazdu + if( lookup == nullptr ) { break; } // nothing found, nothing to do + auto *d { lookup }; + while( d != nullptr ) { + d->Damage( pRozkaz->cString[ 0 ] ); + d = d->Next(); // pozostałe też + } + d = lookup->Prev(); + while( d != nullptr ) { + d->Damage( pRozkaz->cString[ 0 ] ); + d = d->Prev(); // w drugą stronę też + } + multiplayer::WyslijUszkodzenia( lookup->asName, lookup->MoverParameters->EngDmgFlag ); // zwrot informacji o pojeździe + } + break; + default: + break; + } +}; + +//--------------------------------------------------------------------------- + +void TWorld::CreateE3D(std::string const &Path, bool Dynamic) +{ // rekurencyjna generowanie plików E3D + + std::string last; // zmienne używane w rekurencji + TTrack *trk{ nullptr }; + double at{ 0.0 }; + double shift{ 0.0 }; + +#ifdef _WIN32 + + std::string searchpattern( "*.*" ); + + ::WIN32_FIND_DATA filedata; + ::HANDLE search = ::FindFirstFile( ( Path + searchpattern ).c_str(), &filedata ); + + if( search == INVALID_HANDLE_VALUE ) { return; } // if nothing to do, bail out + + do { + + std::string filename = filedata.cFileName; + + if( filedata.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY ) { + // launch recursive search for sub-directories... + if( filename == "." ) { continue; } + if( filename == ".." ) { continue; } + CreateE3D( Path + filename + "/", Dynamic ); + } + else { + // process the file + if( filename.size() < 4 ) { continue; } + std::string const filetype = ToLower( filename.substr( filename.size() - 4, 4 ) ); + if( filetype == ".mmd" ) { + if( false == Dynamic ) { continue; } + + // konwersja pojazdów będzie ułomna, bo nie poustawiają się animacje na submodelach określonych w MMD + if( last != Path ) { // utworzenie toru dla danego pojazdu + last = Path; + trk = TTrack::Create400m( 1, shift ); + shift += 10.0; // następny tor będzie deczko dalej, aby nie zabić FPS + at = 400.0; + } + auto *dynamic = new TDynamicObject(); + + at -= dynamic->Init( + "", + Path.substr( 8, Path.size() - 9 ), // skip leading "dynamic/" and trailing slash + "none", + filename.substr( 0, filename.size() - 4 ), + trk, + at, + "nobody", 0.0, "none", 0.0, "", false, "" ); + + // po wczytaniu CHK zrobić pętlę po ładunkach, aby każdy z nich skonwertować + cParser loadparser( dynamic->MoverParameters->LoadAccepted ); // typy ładunków + std::string loadname; + loadparser.getTokens( 1, true, "," ); loadparser >> loadname; + while( loadname != "" ) { + + if( ( true == FileExists( Path + loadname + ".t3d" ) ) + && ( false == FileExists( Path + loadname + ".e3d" ) ) ) { + // a nie ma jeszcze odpowiednika binarnego + at -= dynamic->Init( + "", + Path.substr( 8, Path.size() - 9 ), // skip leading "dynamic/" and trailing slash + "none", + filename.substr( 0, filename.size() - 4 ), + trk, + at, + "nobody", 0.0, "none", 1.0, loadname, false, "" ); + } + + loadname = ""; + loadparser.getTokens( 1, true, "," ); loadparser >> loadname; + } + + if( dynamic->iCabs ) { // jeśli ma jakąkolwiek kabinę + delete Train; + Train = new TTrain(); + if( dynamic->iCabs & 0x1 ) { + dynamic->MoverParameters->ActiveCab = 1; + Train->Init( dynamic, true ); + } + if( dynamic->iCabs & 0x4 ) { + dynamic->MoverParameters->ActiveCab = -1; + Train->Init( dynamic, true ); + } + if( dynamic->iCabs & 0x2 ) { + dynamic->MoverParameters->ActiveCab = 0; + Train->Init( dynamic, true ); + } + } + // z powrotem defaultowa sciezka do tekstur + Global.asCurrentTexturePath = ( szTexturePath ); + } + else if( filetype == ".t3d" ) { + // z modelami jest prościej + Global.asCurrentTexturePath = Path; + TModelsManager::GetModel( Path + filename, false ); + } + } + + } while( ::FindNextFile( search, &filedata ) ); + + // all done, clean up + ::FindClose( search ); + +#endif +}; + +//--------------------------------------------------------------------------- +// passes specified sound to all vehicles within range as a radio message broadcasted on specified channel +void +TWorld::radio_message( sound_source *Message, int const Channel ) { + + if( Train != nullptr ) { + Train->radio_message( Message, Channel ); + } +} + +void TWorld::CabChange(TDynamicObject *old, TDynamicObject *now) +{ // ewentualna zmiana kabiny użytkownikowi + if (Train) + if (Train->Dynamic() == old) + Global.changeDynObj = now; // uruchomienie protezy +}; + +void TWorld::ChangeDynamic() { + + // Ra: to nie może być tak robione, to zbytnia proteza jest + if( Train->Dynamic()->Mechanik ) { + // AI może sobie samo pójść + if( false == Train->Dynamic()->Mechanik->AIControllFlag ) { + // tylko jeśli ręcznie prowadzony + // jeśli prowadzi AI, to mu nie robimy dywersji! + Train->Dynamic()->MoverParameters->CabDeactivisation(); + Train->Dynamic()->Controller = AIdriver; + Train->Dynamic()->MoverParameters->ActiveCab = 0; + Train->Dynamic()->MoverParameters->BrakeLevelSet( Train->Dynamic()->MoverParameters->Handle->GetPos( bh_NP ) ); //rozwala sterowanie hamulcem GF 04-2016 + Train->Dynamic()->MechInside = false; + } + } + TDynamicObject *temp = Global.changeDynObj; + Train->Dynamic()->bDisplayCab = false; + Train->Dynamic()->ABuSetModelShake( {} ); + + if( Train->Dynamic()->Mechanik ) // AI może sobie samo pójść + if( false == Train->Dynamic()->Mechanik->AIControllFlag ) { + // tylko jeśli ręcznie prowadzony + // przsunięcie obiektu zarządzającego + Train->Dynamic()->Mechanik->MoveTo( temp ); + } + + Train->DynamicSet( temp ); + Controlled = temp; + mvControlled = Controlled->ControlledFind()->MoverParameters; + Global.asHumanCtrlVehicle = Train->Dynamic()->name(); + if( Train->Dynamic()->Mechanik ) // AI może sobie samo pójść + if( !Train->Dynamic()->Mechanik->AIControllFlag ) // tylko jeśli ręcznie prowadzony + { + Train->Dynamic()->MoverParameters->LimPipePress = Controlled->MoverParameters->PipePress; + Train->Dynamic()->MoverParameters->CabActivisation(); // załączenie rozrządu (wirtualne kabiny) + Train->Dynamic()->Controller = Humandriver; + Train->Dynamic()->MechInside = true; + } + Train->InitializeCab( + Train->Dynamic()->MoverParameters->CabNo, + Train->Dynamic()->asBaseDir + Train->Dynamic()->MoverParameters->TypeName + ".mmd" ); + if( !FreeFlyModeFlag ) { + Train->Dynamic()->bDisplayCab = true; + Train->Dynamic()->ABuSetModelShake( {} ); // zerowanie przesunięcia przed powrotem? + Train->MechStop(); + FollowView(); // na pozycję mecha + } + Global.changeDynObj = NULL; +} + +void +TWorld::ToggleDaylight() { + + Global.FakeLight = !Global.FakeLight; + + if( Global.FakeLight ) { + // for fake daylight enter fixed hour + Environment.time( 10, 30, 0 ); + } + else { + // local clock based calculation + Environment.time(); + } +} + +// calculates current season of the year based on set simulation date +void +TWorld::compute_season( int const Yearday ) const { + + using dayseasonpair = std::pair; + + std::vector seasonsequence { + { 65, "winter:" }, + { 158, "spring:" }, + { 252, "summer:" }, + { 341, "autumn:" }, + { 366, "winter:" } }; + auto const lookup = + std::lower_bound( + std::begin( seasonsequence ), std::end( seasonsequence ), + clamp( Yearday, 1, seasonsequence.back().first ), + []( dayseasonpair const &Left, const int Right ) { + return Left.first < Right; } ); + + Global.Season = lookup->second; + // season can affect the weather so if it changes, re-calculate weather as well + compute_weather(); +} + +// calculates current weather +void +TWorld::compute_weather() const { + + Global.Weather = ( + Global.Overcast < 0.25 ? "clear:" : + Global.Overcast < 1.0 ? "cloudy:" : + ( Global.Season != "winter:" ? + "rain:" : + "snow:" ) ); +} + +void +world_environment::init() { + + m_sun.init(); + m_moon.init(); + m_stars.init(); + m_clouds.Init(); +} + +void +world_environment::update() { + // move celestial bodies... + m_sun.update(); + m_moon.update(); + // ...determine source of key light and adjust global state accordingly... + // diffuse (sun) intensity goes down after twilight, and reaches minimum 18 degrees below horizon + float twilightfactor = clamp( -m_sun.getAngle(), 0.0f, 18.0f ) / 18.0f; + // NOTE: sun light receives extra padding to prevent moon from kicking in too soon + auto const sunlightlevel = m_sun.getIntensity() + 0.05f * ( 1.f - twilightfactor ); + auto const moonlightlevel = m_moon.getIntensity() * 0.65f; // scaled down by arbitrary factor, it's pretty bright otherwise + float keylightintensity; + glm::vec3 keylightcolor; + if( moonlightlevel > sunlightlevel ) { + // rare situations when the moon is brighter than the sun, typically at night + Global.SunAngle = m_moon.getAngle(); + Global.DayLight.position = m_moon.getDirection(); + Global.DayLight.direction = -1.0f * m_moon.getDirection(); + keylightintensity = moonlightlevel; + // if the moon is up, it overrides the twilight + twilightfactor = 0.0f; + keylightcolor = glm::vec3( 255.0f / 255.0f, 242.0f / 255.0f, 202.0f / 255.0f ); + } + else { + // regular situation with sun as the key light + Global.SunAngle = m_sun.getAngle(); + Global.DayLight.position = m_sun.getDirection(); + Global.DayLight.direction = -1.0f * m_sun.getDirection(); + keylightintensity = sunlightlevel; + // include 'golden hour' effect in twilight lighting + float const duskfactor = 1.0f - clamp( Global.SunAngle, 0.0f, 18.0f ) / 18.0f; + keylightcolor = interpolate( + glm::vec3( 255.0f / 255.0f, 242.0f / 255.0f, 231.0f / 255.0f ), + glm::vec3( 235.0f / 255.0f, 140.0f / 255.0f, 36.0f / 255.0f ), + duskfactor ); + } + // ...update skydome to match the current sun position as well... + m_skydome.SetOvercastFactor( Global.Overcast ); + m_skydome.Update( m_sun.getDirection() ); + // ...retrieve current sky colour and brightness... + auto const skydomecolour = m_skydome.GetAverageColor(); + auto const skydomehsv = colors::RGBtoHSV( skydomecolour ); + // sun strength is reduced by overcast level + keylightintensity *= ( 1.0f - std::min( 1.f, Global.Overcast ) * 0.65f ); + + // intensity combines intensity of the sun and the light reflected by the sky dome + // it'd be more technically correct to have just the intensity of the sun here, + // but whether it'd _look_ better is something to be tested + auto const intensity = std::min( 1.15f * ( 0.05f + keylightintensity + skydomehsv.z ), 1.25f ); + // the impact of sun component is reduced proportionally to overcast level, as overcast increases role of ambient light + auto const diffuselevel = interpolate( keylightintensity, intensity * ( 1.0f - twilightfactor ), 1.0f - std::min( 1.f, Global.Overcast ) * 0.75f ); + // ...update light colours and intensity. + keylightcolor = keylightcolor * diffuselevel; + Global.DayLight.diffuse = glm::vec4( keylightcolor, Global.DayLight.diffuse.a ); + Global.DayLight.specular = glm::vec4( keylightcolor * 0.85f, diffuselevel ); + + // tonal impact of skydome color is inversely proportional to how high the sun is above the horizon + // (this is pure conjecture, aimed more to 'look right' than be accurate) + float const ambienttone = clamp( 1.0f - ( Global.SunAngle / 90.0f ), 0.0f, 1.0f ); + Global.DayLight.ambient[ 0 ] = interpolate( skydomehsv.z, skydomecolour.r, ambienttone ); + Global.DayLight.ambient[ 1 ] = interpolate( skydomehsv.z, skydomecolour.g, ambienttone ); + Global.DayLight.ambient[ 2 ] = interpolate( skydomehsv.z, skydomecolour.b, ambienttone ); + + Global.fLuminance = intensity; + + // update the fog. setting it to match the average colour of the sky dome is cheap + // but quite effective way to make the distant items blend with background better + // NOTE: base brightness calculation provides scaled up value, so we bring it back to 'real' one here + Global.FogColor = m_skydome.GetAverageHorizonColor(); +} + +void +world_environment::time( int const Hour, int const Minute, int const Second ) { + + m_sun.setTime( Hour, Minute, Second ); +} diff --git a/old/World.h b/old/World.h new file mode 100644 index 00000000..c0131762 --- /dev/null +++ b/old/World.h @@ -0,0 +1,113 @@ +/* +This Source Code Form is subject to the +terms of the Mozilla Public License, v. +2.0. If a copy of the MPL was not +distributed with this file, You can +obtain one at +http://mozilla.org/MPL/2.0/. +*/ + +#pragma once + +#include +#include + +#include "classes.h" +#include "Camera.h" +#include "sky.h" +#include "sun.h" +#include "moon.h" +#include "stars.h" +#include "skydome.h" +#include "messaging.h" + +// wrapper for environment elements -- sky, sun, stars, clouds etc +class world_environment { + + friend opengl_renderer; + +public: + void init(); + void update(); + void time( int const Hour = -1, int const Minute = -1, int const Second = -1 ); + +private: + CSkyDome m_skydome; + cStars m_stars; + cSun m_sun; + cMoon m_moon; + TSky m_clouds; +}; + +class TWorld +{ + // NOTE: direct access is a shortcut, but world etc needs some restructuring regardless + friend opengl_renderer; + +public: +// types + +// constructors +TWorld(); + +// destructor +~TWorld(); + +// methods + void CreateE3D( std::string const &dir = "", bool dyn = false ); + bool Init( GLFWwindow *w ); + bool InitPerformed() { return m_init; } + bool Update(); + void OnKeyDown( int cKey ); + void OnCommandGet( multiplayer::DaneRozkaz *pRozkaz ); + // passes specified sound to all vehicles within range as a radio message broadcasted on specified channel + void radio_message( sound_source *Message, int const Channel ); + void CabChange( TDynamicObject *old, TDynamicObject *now ); + void TrainDelete(TDynamicObject *d = NULL); + TTrain const * + train() const { return Train; } + TDynamicObject const * + controlled() const { return Controlled; } + // switches between static and dynamic daylight calculation + void ToggleDaylight(); + // calculates current season of the year based on set simulation date + void compute_season( int const Yearday ) const; + // calculates current weather + void compute_weather() const; + +// members + +private: + void Update_Environment(); + void Update_Camera( const double Deltatime ); + // handles vehicle change flag + void ChangeDynamic(); + void InOutKey( bool const Near = true ); + void FollowView( bool wycisz = true ); + void DistantView( bool const Near = false ); + + TCamera Camera; + TCamera DebugCamera; + world_environment Environment; + TTrain *Train; + TDynamicObject *Controlled { nullptr }; // pojazd, który prowadzimy + TDynamicObject *pDynamicNearest { nullptr }; + bool Paused { true }; + TEvent *KeyEvents[10]; // eventy wyzwalane z klawiaury + TMoverParameters *mvControlled; // wskaźnik na człon silnikowy, do wyświetlania jego parametrów + double fTime50Hz; // bufor czasu dla komunikacji z PoKeys + double fTimeBuffer; // bufor czasu aktualizacji dla stałego kroku fizyki + double fMaxDt; //[s] krok czasowy fizyki (0.01 dla normalnych warunków) + double const m_primaryupdaterate { 1.0 / 100.0 }; + double const m_secondaryupdaterate { 1.0 / 50.0 }; + double m_primaryupdateaccumulator { m_secondaryupdaterate }; // keeps track of elapsed simulation time, for core fixed step routines + double m_secondaryupdateaccumulator { m_secondaryupdaterate }; // keeps track of elapsed simulation time, for less important fixed step routines + int iPause; // wykrywanie zmian w zapauzowaniu + bool m_init { false }; // indicates whether initial update of the world was performed + GLFWwindow *window; +}; + +extern TWorld World; + +//--------------------------------------------------------------------------- + diff --git a/McZapkie/_Mover.hpp b/old/_Mover.hpp similarity index 100% rename from McZapkie/_Mover.hpp rename to old/_Mover.hpp diff --git a/McZapkie/_mover.pas b/old/_mover.pas similarity index 100% rename from McZapkie/_mover.pas rename to old/_mover.pas diff --git a/McZapkie/friction.hpp b/old/friction.hpp similarity index 100% rename from McZapkie/friction.hpp rename to old/friction.hpp diff --git a/McZapkie/friction.pas b/old/friction.pas similarity index 100% rename from McZapkie/friction.pas rename to old/friction.pas diff --git a/McZapkie/hamulce.hpp b/old/hamulce.hpp similarity index 100% rename from McZapkie/hamulce.hpp rename to old/hamulce.hpp diff --git a/McZapkie/hamulce.pas b/old/hamulce.pas similarity index 100% rename from McZapkie/hamulce.pas rename to old/hamulce.pas diff --git a/McZapkie/klasy_ham.pas b/old/klasy_ham.pas similarity index 100% rename from McZapkie/klasy_ham.pas rename to old/klasy_ham.pas diff --git a/old/mctools.cpp b/old/mctools.cpp new file mode 100644 index 00000000..e653d75a --- /dev/null +++ b/old/mctools.cpp @@ -0,0 +1,322 @@ +/* +This Source Code Form is subject to the +terms of the Mozilla Public License, v. +2.0. If a copy of the MPL was not +distributed with this file, You can +obtain one at +http://mozilla.org/MPL/2.0/. +*/ +/* +MaSzyna EU07 - SPKS +Brakes. +Copyright (C) 2007-2014 Maciej Cierniak +*/ +#include "stdafx.h" +#include "mctools.h" + +#include +#include +#ifndef WIN32 +#include +#endif + +#ifdef WIN32 +#define stat _stat +#endif + +#include "Globals.h" + +/*================================================*/ + +bool DebugModeFlag = false; +bool FreeFlyModeFlag = false; +bool EditorModeFlag = true; +bool DebugCameraFlag = false; + +double Max0R(double x1, double x2) +{ + if (x1 > x2) + return x1; + else + return x2; +} + +double Min0R(double x1, double x2) +{ + if (x1 < x2) + return x1; + else + return x2; +} + +// shitty replacement for Borland timestamp function +// TODO: replace with something sensible +std::string Now() { + + std::time_t timenow = std::time( nullptr ); + std::tm tm = *std::localtime( &timenow ); + std::stringstream converter; + converter << std::put_time( &tm, "%c" ); + return converter.str(); +} + +bool SetFlag( int &Flag, int const Value ) { + + if( Value > 0 ) { + if( false == TestFlag( Flag, Value ) ) { + Flag |= Value; + return true; // true, gdy było wcześniej 0 i zostało ustawione + } + } + else if( Value < 0 ) { + // Value jest ujemne, czyli zerowanie flagi + return ClearFlag( Flag, -Value ); + } + return false; +} + +bool ClearFlag( int &Flag, int const Value ) { + + if( true == TestFlag( Flag, Value ) ) { + Flag &= ~Value; + return true; + } + else { + return false; + } +} + +inline double Random(double a, double b) +{ + std::uniform_real_distribution<> dis(a, b); + return dis(Global.random_engine); +} + +bool FuzzyLogic(double Test, double Threshold, double Probability) +{ + if ((Test > Threshold) && (!DebugModeFlag)) + return + (Random() < Probability * Threshold * 1.0 / Test) /*im wiekszy Test tym wieksza szansa*/; + else + return false; +} + +bool FuzzyLogicAI(double Test, double Threshold, double Probability) +{ + if ((Test > Threshold)) + return + (Random() < Probability * Threshold * 1.0 / Test) /*im wiekszy Test tym wieksza szansa*/; + else + return false; +} + +std::string DUE(std::string s) /*Delete Before Equal sign*/ +{ + //DUE = Copy(s, Pos("=", s) + 1, length(s)); + return s.substr(s.find("=") + 1, s.length()); +} + +std::string DWE(std::string s) /*Delete After Equal sign*/ +{ + size_t ep = s.find("="); + if (ep != std::string::npos) + //DWE = Copy(s, 1, ep - 1); + return s.substr(0, ep); + else + return s; +} + +std::string ExchangeCharInString( std::string const &Source, char const From, char const To ) +{ + std::string replacement; replacement.reserve( Source.size() ); + std::for_each( + std::begin( Source ), std::end( Source ), + [&](char const idx) { + if( idx != From ) { replacement += idx; } + else { replacement += To; } } ); + + return replacement; +} + +std::vector &Split(const std::string &s, char delim, std::vector &elems) +{ // dzieli tekst na wektor tekstow + + std::stringstream ss(s); + std::string item; + while (std::getline(ss, item, delim)) + { + elems.push_back(item); + } + return elems; +} + +std::vector Split(const std::string &s, char delim) +{ // dzieli tekst na wektor tekstow + std::vector elems; + Split(s, delim, elems); + return elems; +} + +std::vector Split(const std::string &s) +{ // dzieli tekst na wektor tekstow po białych znakach + std::vector elems; + std::stringstream ss(s); + std::string item; + while (ss >> item) + { + elems.push_back(item); + } + return elems; +} + +std::string to_string(int _Val) +{ + std::ostringstream o; + o << _Val; + return o.str(); +}; + +std::string to_string(unsigned int _Val) +{ + std::ostringstream o; + o << _Val; + return o.str(); +}; + +std::string to_string(double _Val) +{ + std::ostringstream o; + o << _Val; + return o.str(); +}; + +std::string to_string(int _Val, int precision) +{ + std::ostringstream o; + o << std::fixed << std::setprecision(precision); + o << _Val; + return o.str(); +}; + +std::string to_string(double _Val, int precision) +{ + std::ostringstream o; + o << std::fixed << std::setprecision(precision); + o << _Val; + return o.str(); +}; + +std::string to_string(int _Val, int precision, int width) +{ + std::ostringstream o; + o.width(width); + o << std::fixed << std::setprecision(precision); + o << _Val; + return o.str(); +}; + +std::string to_string(double const Value, int const Precision, int const Width) +{ + std::ostringstream converter; + converter << std::setw( Width ) << std::fixed << std::setprecision(Precision) << Value; + return converter.str(); +}; + +std::string to_hex_str( int const Value, int const Width ) +{ + std::ostringstream converter; + converter << "0x" << std::uppercase << std::setfill( '0' ) << std::setw( Width ) << std::hex << Value; + return converter.str(); +}; + +int stol_def(const std::string &str, const int &DefaultValue) { + + int result { DefaultValue }; + std::stringstream converter; + converter << str; + converter >> result; + return result; +} + +std::string ToLower(std::string const &text) +{ + std::string lowercase( text ); + std::transform(text.begin(), text.end(), lowercase.begin(), ::tolower); + return lowercase; +} + +std::string ToUpper(std::string const &text) +{ + std::string uppercase( text ); + std::transform(text.begin(), text.end(), uppercase.begin(), ::toupper); + return uppercase; +} + +// replaces polish letters with basic ascii +void +win1250_to_ascii( std::string &Input ) { + + std::unordered_map charmap{ + { 165, 'A' }, { 198, 'C' }, { 202, 'E' }, { 163, 'L' }, { 209, 'N' }, { 211, 'O' }, { 140, 'S' }, { 143, 'Z' }, { 175, 'Z' }, + { 185, 'a' }, { 230, 'c' }, { 234, 'e' }, { 179, 'l' }, { 241, 'n' }, { 243, 'o' }, { 156, 's' }, { 159, 'z' }, { 191, 'z' } + }; + std::unordered_map::const_iterator lookup; + for( auto &input : Input ) { + if( ( lookup = charmap.find( input ) ) != charmap.end() ) + input = lookup->second; + } +} + +// Ra: tymczasowe rozwiązanie kwestii zagranicznych (czeskich) napisów +char bezogonkowo[] = "E?,?\"_++?%Sstzz" + " ^^L$A|S^CS<--RZo±,l'uP.,as>L\"lz" + "RAAAALCCCEEEEIIDDNNOOOOxRUUUUYTB" + "raaaalccceeeeiiddnnoooo-ruuuuyt?"; + +std::string Bezogonkow(std::string str, bool _) +{ // wycięcie liter z ogonkami, bo OpenGL nie umie wyświetlić + for (unsigned int i = 1; i < str.length(); ++i) + if (str[i] & 0x80) + str[i] = bezogonkowo[str[i] & 0x7F]; + else if (str[i] < ' ') // znaki sterujące nie są obsługiwane + str[i] = ' '; + else if (_) + if (str[i] == '_') // nazwy stacji nie mogą zawierać spacji + str[i] = ' '; // więc trzeba wyświetlać inaczej + return str; +}; + +template <> +bool +extract_value( bool &Variable, std::string const &Key, std::string const &Input, std::string const &Default ) { + + auto value = extract_value( Key, Input ); + if( false == value.empty() ) { + // set the specified variable to retrieved value + Variable = ( ToLower( value ) == "yes" ); + return true; // located the variable + } + else { + // set the variable to provided default value + if( false == Default.empty() ) { + Variable = ( ToLower( Default ) == "yes" ); + } + return false; // couldn't locate the variable in provided input + } +} + +bool +FileExists( std::string const &Filename ) { + + std::ifstream file( Filename ); + return( true == file.is_open() ); +} + +// returns time of last modification for specified file +std::time_t +last_modified( std::string const &Filename ) { + + struct stat filestat; + if( ::stat( Filename.c_str(), &filestat ) == 0 ) { return filestat.st_mtime; } + else { return 0; } +} diff --git a/old/mctools.h b/old/mctools.h new file mode 100644 index 00000000..819791e2 --- /dev/null +++ b/old/mctools.h @@ -0,0 +1,166 @@ +#pragma once + +/* +This Source Code Form is subject to the +terms of the Mozilla Public License, v. +2.0. If a copy of the MPL was not +distributed with this file, You can +obtain one at +http://mozilla.org/MPL/2.0/. +*/ + +/*rozne takie duperele do operacji na stringach w paszczalu, pewnie w delfi sa lepsze*/ +/*konwersja zmiennych na stringi, funkcje matematyczne, logiczne, lancuchowe, I/O etc*/ + +#include +#include +#include +#include +#include + +extern bool DebugModeFlag; +extern bool FreeFlyModeFlag; +extern bool EditorModeFlag; +extern bool DebugCameraFlag; + +/*funkcje matematyczne*/ +double Max0R(double x1, double x2); +double Min0R(double x1, double x2); + +inline double Sign(double x) +{ + return x >= 0 ? 1.0 : -1.0; +} + +inline long Round(double const f) +{ + return (long)(f + 0.5); + //return lround(f); +} + +double Random(double a, double b); + +inline double Random() +{ + return Random(0.0,1.0); +} + +inline double Random(double b) +{ + return Random(0.0, b); +} + +inline double BorlandTime() +{ + auto timesinceepoch = std::time( nullptr ); + return timesinceepoch / (24.0 * 60 * 60); +/* + // std alternative + auto timesinceepoch = std::chrono::system_clock::now().time_since_epoch(); + return std::chrono::duration_cast( timesinceepoch ).count() / (24.0 * 60 * 60); +*/ +} + +std::string Now(); + +/*funkcje logiczne*/ +inline bool TestFlag( int const Flag, int const Value ) { return ( ( Flag & Value ) == Value ); } +bool SetFlag( int &Flag, int const Value); +bool ClearFlag(int &Flag, int const Value); + +bool FuzzyLogic(double Test, double Threshold, double Probability); +/*jesli Test>Threshold to losowanie*/ +bool FuzzyLogicAI(double Test, double Threshold, double Probability); +/*to samo ale zawsze niezaleznie od DebugFlag*/ + +/*operacje na stringach*/ +std::string DUE(std::string s); /*Delete Until Equal sign*/ +std::string DWE(std::string s); /*Delete While Equal sign*/ +std::string ExchangeCharInString( std::string const &Source, char const From, char const To ); // zamienia jeden znak na drugi +std::vector &Split(const std::string &s, char delim, std::vector &elems); +std::vector Split(const std::string &s, char delim); +//std::vector Split(const std::string &s); + +std::string to_string(int _Val); +std::string to_string(unsigned int _Val); +std::string to_string(int _Val, int precision); +std::string to_string(int _Val, int precision, int width); +std::string to_string(double _Val); +std::string to_string(double _Val, int precision); +std::string to_string(double _Val, int precision, int width); +std::string to_hex_str( int const _Val, int const width = 4 ); + +inline std::string to_string(bool _Val) { + + return _Val == true ? "true" : "false"; +} + +template +std::string to_string( glm::tvec3 const &Value ) { + return to_string( Value.x, 2 ) + ", " + to_string( Value.y, 2 ) + ", " + to_string( Value.z, 2 ); +} + +template +std::string to_string( glm::tvec4 const &Value, int const Width = 2 ) { + return to_string( Value.x, Width ) + ", " + to_string( Value.y, Width ) + ", " + to_string( Value.z, Width ) + ", " + to_string( Value.w, Width ); +} + +int stol_def(const std::string & str, const int & DefaultValue); + +std::string ToLower(std::string const &text); +std::string ToUpper(std::string const &text); + +// replaces polish letters with basic ascii +void win1250_to_ascii( std::string &Input ); +// TODO: unify with win1250_to_ascii() +std::string Bezogonkow( std::string str, bool _ = false ); + +inline +std::string +extract_value( std::string const &Key, std::string const &Input ) { + // NOTE, HACK: the leading space allows to uniformly look for " variable=" substring + std::string const input { " " + Input }; + std::string value; + auto lookup = input.find( " " + Key + "=" ); + if( lookup != std::string::npos ) { + value = input.substr( input.find_first_not_of( ' ', lookup + Key.size() + 2 ) ); + lookup = value.find( ' ' ); + if( lookup != std::string::npos ) { + // trim everything past the value + value.erase( lookup ); + } + } + return value; +} + +template +bool +extract_value( Type_ &Variable, std::string const &Key, std::string const &Input, std::string const &Default ) { + + auto value = extract_value( Key, Input ); + if( false == value.empty() ) { + // set the specified variable to retrieved value + std::stringstream converter; + converter << value; + converter >> Variable; + return true; // located the variable + } + else { + // set the variable to provided default value + if( false == Default.empty() ) { + std::stringstream converter; + converter << Default; + converter >> Variable; + } + return false; // couldn't locate the variable in provided input + } +} + +template <> +bool +extract_value( bool &Variable, std::string const &Key, std::string const &Input, std::string const &Default ); + +bool FileExists( std::string const &Filename ); + +// returns time of last modification for specified file +std::time_t last_modified( std::string const &Filename ); \ No newline at end of file diff --git a/McZapkie/mctools.hpp b/old/mctools.hpp similarity index 100% rename from McZapkie/mctools.hpp rename to old/mctools.hpp diff --git a/McZapkie/mctools.pas b/old/mctools.pas similarity index 100% rename from McZapkie/mctools.pas rename to old/mctools.pas diff --git a/McZapkie/mtable.hpp b/old/mtable.hpp similarity index 100% rename from McZapkie/mtable.hpp rename to old/mtable.hpp diff --git a/McZapkie/mtable.pas b/old/mtable.pas similarity index 100% rename from McZapkie/mtable.pas rename to old/mtable.pas diff --git a/McZapkie/unit2.pas b/old/unit2.pas similarity index 100% rename from McZapkie/unit2.pas rename to old/unit2.pas diff --git a/wavread.cpp b/old/wavread.cpp similarity index 89% rename from wavread.cpp rename to old/wavread.cpp index d55dd9be..7b7e9698 100644 --- a/wavread.cpp +++ b/old/wavread.cpp @@ -17,26 +17,7 @@ http://mozilla.org/MPL/2.0/. //----------------------------------------------------------------------------- #include "stdafx.h" #include "WavRead.h" - -//----------------------------------------------------------------------------- -// Defines, constants, and global variables -//----------------------------------------------------------------------------- -#define SAFE_DELETE(p) \ - { \ - if (p) \ - { \ - delete (p); \ - (p) = NULL; \ - } \ - } -#define SAFE_RELEASE(p) \ - { \ - if (p) \ - { \ - (p)->Release(); \ - (p) = NULL; \ - } \ - } +#include "usefull.h" //----------------------------------------------------------------------------- // Name: ReadMMIO() @@ -122,13 +103,13 @@ HRESULT ReadMMIO(HMMIO hmmioIn, MMCKINFO *pckInRIFF, WAVEFORMATEX **ppwfxInfo) // so the data can be easily read with WaveReadFile. Returns 0 if // successful, the error code if not. //----------------------------------------------------------------------------- -HRESULT WaveOpenFile(CHAR *strFileName, HMMIO *phmmioIn, WAVEFORMATEX **ppwfxInfo, +HRESULT WaveOpenFile( std::string const &Filename, HMMIO *phmmioIn, WAVEFORMATEX **ppwfxInfo, MMCKINFO *pckInRIFF) { HRESULT hr; HMMIO hmmioIn = NULL; - if (NULL == (hmmioIn = mmioOpen(strFileName, NULL, MMIO_ALLOCBUF | MMIO_READ))) + if (NULL == (hmmioIn = mmioOpen(const_cast(Filename.c_str()), NULL, MMIO_ALLOCBUF | MMIO_READ))) return E_FAIL; if (FAILED(hr = ReadMMIO(hmmioIn, pckInRIFF, ppwfxInfo))) @@ -228,20 +209,20 @@ CWaveSoundRead::CWaveSoundRead() CWaveSoundRead::~CWaveSoundRead() { Close(); - SAFE_DELETE(m_pwfx); + SafeDelete(m_pwfx); } //----------------------------------------------------------------------------- // Name: Open() // Desc: Opens a wave file for reading //----------------------------------------------------------------------------- -HRESULT CWaveSoundRead::Open(CHAR *strFilename) +HRESULT CWaveSoundRead::Open(std::string const &Filename) { - SAFE_DELETE(m_pwfx); + SafeDelete(m_pwfx); HRESULT hr; - if (FAILED(hr = WaveOpenFile(strFilename, &m_hmmioIn, &m_pwfx, &m_ckInRiff))) + if (FAILED(hr = WaveOpenFile(Filename, &m_hmmioIn, &m_pwfx, &m_ckInRiff))) return hr; if (FAILED(hr = Reset())) @@ -276,6 +257,8 @@ HRESULT CWaveSoundRead::Read(UINT nSizeToRead, BYTE *pbData, UINT *pnSizeRead) //----------------------------------------------------------------------------- HRESULT CWaveSoundRead::Close() { - mmioClose(m_hmmioIn, 0); + if( m_hmmioIn != NULL ) { + mmioClose( m_hmmioIn, 0 ); + } return S_OK; } diff --git a/wavread.h b/old/wavread.h similarity index 85% rename from wavread.h rename to old/wavread.h index 68ce040e..f0bc4357 100644 --- a/wavread.h +++ b/old/wavread.h @@ -15,12 +15,12 @@ http://mozilla.org/MPL/2.0/. // // Copyright (c) 1999 Microsoft Corp. All rights reserved. //----------------------------------------------------------------------------- -#ifndef WAVE_READ_H -#define WAVE_READ_H +#pragma once #include +#include -HRESULT WaveOpenFile(CHAR *strFileName, HMMIO *phmmioIn, WAVEFORMATEX **ppwfxInfo, +HRESULT WaveOpenFile(std::string const &Filename, HMMIO *phmmioIn, WAVEFORMATEX **ppwfxInfo, MMCKINFO *pckInRIFF); HRESULT WaveStartDataRead(HMMIO *phmmioIn, MMCKINFO *pckIn, MMCKINFO *pckInRIFF); HRESULT WaveReadFile(HMMIO hmmioIn, UINT cbRead, BYTE *pbDest, MMCKINFO *pckIn, UINT *cbActualRead); @@ -33,7 +33,7 @@ class CWaveSoundRead { public: WAVEFORMATEX *m_pwfx; // Pointer to WAVEFORMATEX structure - HMMIO m_hmmioIn; // MM I/O handle for the WAVE + HMMIO m_hmmioIn{ NULL }; // MM I/O handle for the WAVE MMCKINFO m_ckIn; // Multimedia RIFF chunk MMCKINFO m_ckInRiff; // Use in opening a WAVE file @@ -41,10 +41,8 @@ class CWaveSoundRead CWaveSoundRead(); ~CWaveSoundRead(); - HRESULT Open(CHAR *strFilename); + HRESULT Open(std::string const &Filename); HRESULT Reset(); HRESULT Read(UINT nSizeToRead, BYTE *pbData, UINT *pnSizeRead); HRESULT Close(); }; - -#endif WAVE_READ_H diff --git a/opengl/ARB_Multisample.cpp b/opengl/ARB_Multisample.cpp deleted file mode 100644 index 0c58a540..00000000 --- a/opengl/ARB_Multisample.cpp +++ /dev/null @@ -1,120 +0,0 @@ -/*======================================================================================== - - Name: ARB_multisample.cpp - Author: Colt "MainRoach" McAnlis - Date: 4/29/04 - Desc: This file contains the context to load a WGL extension from a string - As well as collect the sample format available based upon the graphics card. - -========================================================================================*/ - -#include "stdafx.h" -#include "arb_multisample.h" -#include "glew.h" -#include "wglew.h" - -// Declairations We'll Use -#define WGL_SAMPLE_BUFFERS_ARB 0x2041 -#define WGL_SAMPLES_ARB 0x2042 - -bool arbMultisampleSupported = false; -int arbMultisampleFormat = 0; - -// WGLisExtensionSupported: This Is A Form Of The Extension For WGL -bool WGLisExtensionSupported(const char *extension) -{ - const size_t extlen = strlen(extension); - const char *supported = NULL; - - // Try To Use wglGetExtensionStringARB On Current DC, If Possible - PROC wglGetExtString = wglGetProcAddress("wglGetExtensionsStringARB"); - - if (wglGetExtString) - supported = ((char*(__stdcall*)(HDC))wglGetExtString)(wglGetCurrentDC()); - - // If That Failed, Try Standard Opengl Extensions String - if (supported == NULL) - supported = (char*)glGetString(GL_EXTENSIONS); - - // If That Failed Too, Must Be No Extensions Supported - if (supported == NULL) - return false; - - // Begin Examination At Start Of String, Increment By 1 On False Match - for (const char* p = supported; ; p++) - { - // Advance p Up To The Next Possible Match - p = strstr(p, extension); - - if (p == NULL) - return false; // No Match - - // Make Sure That Match Is At The Start Of The String Or That - // The Previous Char Is A Space, Or Else We Could Accidentally - // Match "wglFunkywglExtension" With "wglExtension" - - // Also, Make Sure That The Following Character Is Space Or NULL - // Or Else "wglExtensionTwo" Might Match "wglExtension" - if ((p==supported || p[-1]==' ') && (p[extlen]=='\0' || p[extlen]==' ')) - return true; // Match - } -} - -int InitMultisample(HINSTANCE hInstance,HWND hWnd,PIXELFORMATDESCRIPTOR pfd,int mode) -{//used to query the multisample frequencies - arbMultisampleSupported=false; - //see if the string exists in WGL! - if (!WGLisExtensionSupported("WGL_ARB_multisample")) - return 0; - //get our pixel format - PFNWGLCHOOSEPIXELFORMATARBPROC wglChoosePixelFormatARB=(PFNWGLCHOOSEPIXELFORMATARBPROC)wglGetProcAddress("wglChoosePixelFormatARB"); - if (!wglChoosePixelFormatARB) - return 0; - //get our current device context - HDC hDC=GetDC(hWnd); - int pixelFormat; - int valid; - UINT numFormats; - float fAttributes[]={0,0}; - // These attributes are the bits we want to test for in our sample - // everything is pretty standard, the only one we want to - // really focus on is the SAMPLE BUFFERS ARB and WGL SAMPLES - // these two are going to do the main testing for whether or not - // we support multisampling on this hardware. - int iAttributes[]= - { - WGL_DRAW_TO_WINDOW_ARB,GL_TRUE, - WGL_SUPPORT_OPENGL_ARB,GL_TRUE, - WGL_ACCELERATION_ARB,WGL_FULL_ACCELERATION_ARB, - WGL_COLOR_BITS_ARB,24, - WGL_ALPHA_BITS_ARB,8, - WGL_DEPTH_BITS_ARB,16, - WGL_STENCIL_BITS_ARB,0, - WGL_DOUBLE_BUFFER_ARB,GL_TRUE, - WGL_SAMPLE_BUFFERS_ARB,GL_TRUE, - WGL_SAMPLES_ARB,mode, - 0,0 - }; -/* - //first we check to see if we can get a pixel format for 4 samples - valid=wglChoosePixelFormatARB(hDC,iAttributes,fAttributes,1,&pixelFormat,&numFormats); - if (valid&&(numFormats>=1)) - {//if we returned true, and our format count is greater than 1 - arbMultisampleSupported=true; - arbMultisampleFormat=pixelFormat; - return arbMultisampleSupported; - } -*/ - while (iAttributes[19]>1) - {//our pixel format with (mode) samples failed, test for less samples - valid=wglChoosePixelFormatARB(hDC,iAttributes,fAttributes,1,&pixelFormat,&numFormats); - if (valid&&(numFormats>=1)) - {//if we returned true, and our format count is greater than 1 - arbMultisampleSupported=true; - arbMultisampleFormat=pixelFormat; - return iAttributes[19]; //return number of samples - } - iAttributes[19]>>=1; - } - return 0; -} diff --git a/opengl/ARB_Multisample.h b/opengl/ARB_Multisample.h deleted file mode 100644 index a688e851..00000000 --- a/opengl/ARB_Multisample.h +++ /dev/null @@ -1,25 +0,0 @@ -/*==================================== - Name: ARB_multisample.h - Author: Colt "MainRoach" McAnlis - Date: 4/29/04 - Desc: - This file contains our external items - -====================================*/ - -#ifndef __ARB_MULTISAMPLE_H__ -#define __ARB_MULTISAMPLE_H__ - -#include - -//Globals -extern bool arbMultisampleSupported; -extern int arbMultisampleFormat; - -//If you don't want multisampling, set this to 0 -#define CHECK_FOR_MULTISAMPLE 1 - -//to check for our sampling -int InitMultisample(HINSTANCE hInstance,HWND hWnd,PIXELFORMATDESCRIPTOR pfd,int mode=4); - -#endif diff --git a/opengl/GLUT.H b/opengl/GLUT.H deleted file mode 100644 index 525e5511..00000000 --- a/opengl/GLUT.H +++ /dev/null @@ -1,711 +0,0 @@ -#ifndef __glut_h__ -#define __glut_h__ - -/* Copyright (c) Mark J. Kilgard, 1994, 1995, 1996, 1998. */ - -/* This program is freely distributable without licensing fees and is - provided without guarantee or warrantee expressed or implied. This - program is -not- in the public domain. */ - -#if defined(_WIN32) - -/* GLUT 3.7 now tries to avoid including - to avoid name space pollution, but Win32's - needs APIENTRY and WINGDIAPI defined properly. */ -# if 0 - /* This would put tons of macros and crap in our clean name space. */ -# define WIN32_LEAN_AND_MEAN -# include -# else - /* XXX This is from Win32's */ -# ifndef APIENTRY -# define GLUT_APIENTRY_DEFINED -# if (_MSC_VER >= 800) || defined(_STDCALL_SUPPORTED) || defined(__BORLANDC__) -# define APIENTRY __stdcall -# else -# define APIENTRY -# endif -# endif - /* XXX This is from Win32's */ -# ifndef CALLBACK -# if (defined(_M_MRX000) || defined(_M_IX86) || defined(_M_ALPHA) || defined(_M_PPC)) && !defined(MIDL_PASS) -# define CALLBACK __stdcall -# else -# define CALLBACK -# endif -# endif - /* XXX This is from Win32's and */ -# ifndef WINGDIAPI -# define GLUT_WINGDIAPI_DEFINED -# define WINGDIAPI __declspec(dllimport) -# endif - /* XXX This is from Win32's */ -# ifndef _WCHAR_T_DEFINED -typedef unsigned short wchar_t; -# define _WCHAR_T_DEFINED -# endif -# endif - -#define GLUT_BUILDING_LIB /* disable automatic library usage for GLUT */ -/* To disable automatic library usage for GLUT, define GLUT_NO_LIB_PRAGMA - in your compile preprocessor options. */ -# if !defined(GLUT_BUILDING_LIB) && !defined(GLUT_NO_LIB_PRAGMA) -# pragma comment (lib, "winmm.lib") /* link with Windows MultiMedia lib */ -/* To enable automatic SGI OpenGL for Windows library usage for GLUT, - define GLUT_USE_SGI_OPENGL in your compile preprocessor options. */ -# ifdef GLUT_USE_SGI_OPENGL -# pragma comment (lib, "opengl.lib") /* link with SGI OpenGL for Windows lib */ -# pragma comment (lib, "glu.lib") /* link with SGI OpenGL Utility lib */ -# pragma comment (lib, "glut.lib") /* link with Win32 GLUT for SGI OpenGL lib */ -# else -# pragma comment (lib, "opengl32.lib") /* link with Microsoft OpenGL lib */ -# pragma comment (lib, "glu32.lib") /* link with Microsoft OpenGL Utility lib */ -# pragma comment (lib, "glut32.lib") /* link with Win32 GLUT lib */ -# endif -# endif - -/* To disable supression of annoying warnings about floats being promoted - to doubles, define GLUT_NO_WARNING_DISABLE in your compile preprocessor - options. */ -# ifndef GLUT_NO_WARNING_DISABLE -# pragma warning (disable:4244) /* Disable bogus VC++ 4.2 conversion warnings. */ -# pragma warning (disable:4305) /* VC++ 5.0 version of above warning. */ -# endif - -/* Win32 has an annoying issue where there are multiple C run-time - libraries (CRTs). If the executable is linked with a different CRT - from the GLUT DLL, the GLUT DLL will not share the same CRT static - data seen by the executable. In particular, atexit callbacks registered - in the executable will not be called if GLUT calls its (different) - exit routine). GLUT is typically built with the - "/MD" option (the CRT with multithreading DLL support), but the Visual - C++ linker default is "/ML" (the single threaded CRT). - - One workaround to this issue is requiring users to always link with - the same CRT as GLUT is compiled with. That requires users supply a - non-standard option. GLUT 3.7 has its own built-in workaround where - the executable's "exit" function pointer is covertly passed to GLUT. - GLUT then calls the executable's exit function pointer to ensure that - any "atexit" calls registered by the application are called if GLUT - needs to exit. - - Note that the __glut*WithExit routines should NEVER be called directly. - To avoid the atexit workaround, #define GLUT_DISABLE_ATEXIT_HACK. */ - -/* XXX This is from Win32's */ -# if !defined(_MSC_VER) && !defined(__cdecl) - /* Define __cdecl for non-Microsoft compilers. */ -# define __cdecl -# define GLUT_DEFINED___CDECL -# endif -# ifndef _CRTIMP -# ifdef _NTSDK - /* Definition compatible with NT SDK */ -# define _CRTIMP -# else - /* Current definition */ -# ifdef _DLL -# define _CRTIMP __declspec(dllimport) -# else -# define _CRTIMP -# endif -# endif -# define GLUT_DEFINED__CRTIMP -# endif - -/* GLUT API entry point declarations for Win32. */ -# ifdef GLUT_BUILDING_LIB -# define GLUTAPI __declspec(dllexport) -# else -# ifdef _DLL -# define GLUTAPI __declspec(dllimport) -# else -# define GLUTAPI extern -# endif -# endif - -/* GLUT callback calling convention for Win32. */ -# define GLUTCALLBACK __cdecl - -#endif /* _WIN32 */ - -#include -#include - -#ifdef __cplusplus -extern "C" { -#endif - -#if defined(_WIN32) -# ifndef GLUT_BUILDING_LIB -//extern _CRTIMP void __cdecl exit(int); -# endif -#else -/* non-Win32 case. */ -/* Define APIENTRY and CALLBACK to nothing if we aren't on Win32. */ -# define APIENTRY -# define GLUT_APIENTRY_DEFINED -# define CALLBACK -/* Define GLUTAPI and GLUTCALLBACK as below if we aren't on Win32. */ -# define GLUTAPI extern -# define GLUTCALLBACK -/* Prototype exit for the non-Win32 case (see above). */ -extern void exit(int); -#endif - -/** - GLUT API revision history: - - GLUT_API_VERSION is updated to reflect incompatible GLUT - API changes (interface changes, semantic changes, deletions, - or additions). - - GLUT_API_VERSION=1 First public release of GLUT. 11/29/94 - - GLUT_API_VERSION=2 Added support for OpenGL/GLX multisampling, - extension. Supports new input devices like tablet, dial and button - box, and Spaceball. Easy to query OpenGL extensions. - - GLUT_API_VERSION=3 glutMenuStatus added. - - GLUT_API_VERSION=4 glutInitDisplayString, glutWarpPointer, - glutBitmapLength, glutStrokeLength, glutWindowStatusFunc, dynamic - video resize subAPI, glutPostWindowRedisplay, glutKeyboardUpFunc, - glutSpecialUpFunc, glutIgnoreKeyRepeat, glutSetKeyRepeat, - glutJoystickFunc, glutForceJoystickFunc (NOT FINALIZED!). -**/ -#ifndef GLUT_API_VERSION /* allow this to be overriden */ -#define GLUT_API_VERSION 3 -#endif - -/** - GLUT implementation revision history: - - GLUT_XLIB_IMPLEMENTATION is updated to reflect both GLUT - API revisions and implementation revisions (ie, bug fixes). - - GLUT_XLIB_IMPLEMENTATION=1 mjk's first public release of - GLUT Xlib-based implementation. 11/29/94 - - GLUT_XLIB_IMPLEMENTATION=2 mjk's second public release of - GLUT Xlib-based implementation providing GLUT version 2 - interfaces. - - GLUT_XLIB_IMPLEMENTATION=3 mjk's GLUT 2.2 images. 4/17/95 - - GLUT_XLIB_IMPLEMENTATION=4 mjk's GLUT 2.3 images. 6/?/95 - - GLUT_XLIB_IMPLEMENTATION=5 mjk's GLUT 3.0 images. 10/?/95 - - GLUT_XLIB_IMPLEMENTATION=7 mjk's GLUT 3.1+ with glutWarpPoitner. 7/24/96 - - GLUT_XLIB_IMPLEMENTATION=8 mjk's GLUT 3.1+ with glutWarpPoitner - and video resize. 1/3/97 - - GLUT_XLIB_IMPLEMENTATION=9 mjk's GLUT 3.4 release with early GLUT 4 routines. - - GLUT_XLIB_IMPLEMENTATION=11 Mesa 2.5's GLUT 3.6 release. - - GLUT_XLIB_IMPLEMENTATION=12 mjk's GLUT 3.6 release with early GLUT 4 routines + signal handling. - - GLUT_XLIB_IMPLEMENTATION=13 mjk's GLUT 3.7 beta with GameGLUT support. - - GLUT_XLIB_IMPLEMENTATION=14 mjk's GLUT 3.7 beta with f90gl friend interface. - - GLUT_XLIB_IMPLEMENTATION=15 mjk's GLUT 3.7 beta sync'ed with Mesa -**/ -#ifndef GLUT_XLIB_IMPLEMENTATION /* Allow this to be overriden. */ -#define GLUT_XLIB_IMPLEMENTATION 15 -#endif - -/* Display mode bit masks. */ -#define GLUT_RGB 0 -#define GLUT_RGBA GLUT_RGB -#define GLUT_INDEX 1 -#define GLUT_SINGLE 0 -#define GLUT_DOUBLE 2 -#define GLUT_ACCUM 4 -#define GLUT_ALPHA 8 -#define GLUT_DEPTH 16 -#define GLUT_STENCIL 32 -#if (GLUT_API_VERSION >= 2) -#define GLUT_MULTISAMPLE 128 -#define GLUT_STEREO 256 -#endif -#if (GLUT_API_VERSION >= 3) -#define GLUT_LUMINANCE 512 -#endif - -/* Mouse buttons. */ -#define GLUT_LEFT_BUTTON 0 -#define GLUT_MIDDLE_BUTTON 1 -#define GLUT_RIGHT_BUTTON 2 - -/* Mouse button state. */ -#define GLUT_DOWN 0 -#define GLUT_UP 1 - -#if (GLUT_API_VERSION >= 2) -/* function keys */ -#define GLUT_KEY_F1 1 -#define GLUT_KEY_F2 2 -#define GLUT_KEY_F3 3 -#define GLUT_KEY_F4 4 -#define GLUT_KEY_F5 5 -#define GLUT_KEY_F6 6 -#define GLUT_KEY_F7 7 -#define GLUT_KEY_F8 8 -#define GLUT_KEY_F9 9 -#define GLUT_KEY_F10 10 -#define GLUT_KEY_F11 11 -#define GLUT_KEY_F12 12 -/* directional keys */ -#define GLUT_KEY_LEFT 100 -#define GLUT_KEY_UP 101 -#define GLUT_KEY_RIGHT 102 -#define GLUT_KEY_DOWN 103 -#define GLUT_KEY_PAGE_UP 104 -#define GLUT_KEY_PAGE_DOWN 105 -#define GLUT_KEY_HOME 106 -#define GLUT_KEY_END 107 -#define GLUT_KEY_INSERT 108 -#endif - -/* Entry/exit state. */ -#define GLUT_LEFT 0 -#define GLUT_ENTERED 1 - -/* Menu usage state. */ -#define GLUT_MENU_NOT_IN_USE 0 -#define GLUT_MENU_IN_USE 1 - -/* Visibility state. */ -#define GLUT_NOT_VISIBLE 0 -#define GLUT_VISIBLE 1 - -/* Window status state. */ -#define GLUT_HIDDEN 0 -#define GLUT_FULLY_RETAINED 1 -#define GLUT_PARTIALLY_RETAINED 2 -#define GLUT_FULLY_COVERED 3 - -/* Color index component selection values. */ -#define GLUT_RED 0 -#define GLUT_GREEN 1 -#define GLUT_BLUE 2 - -#if defined(_WIN32) -/* Stroke font constants (use these in GLUT program). */ -#define GLUT_STROKE_ROMAN ((void*)0) -#define GLUT_STROKE_MONO_ROMAN ((void*)1) - -/* Bitmap font constants (use these in GLUT program). */ -#define GLUT_BITMAP_9_BY_15 ((void*)2) -#define GLUT_BITMAP_8_BY_13 ((void*)3) -#define GLUT_BITMAP_TIMES_ROMAN_10 ((void*)4) -#define GLUT_BITMAP_TIMES_ROMAN_24 ((void*)5) -#if (GLUT_API_VERSION >= 3) -#define GLUT_BITMAP_HELVETICA_10 ((void*)6) -#define GLUT_BITMAP_HELVETICA_12 ((void*)7) -#define GLUT_BITMAP_HELVETICA_18 ((void*)8) -#endif -#else -/* Stroke font opaque addresses (use constants instead in source code). */ -GLUTAPI void *glutStrokeRoman; -GLUTAPI void *glutStrokeMonoRoman; - -/* Stroke font constants (use these in GLUT program). */ -#define GLUT_STROKE_ROMAN (&glutStrokeRoman) -#define GLUT_STROKE_MONO_ROMAN (&glutStrokeMonoRoman) - -/* Bitmap font opaque addresses (use constants instead in source code). */ -GLUTAPI void *glutBitmap9By15; -GLUTAPI void *glutBitmap8By13; -GLUTAPI void *glutBitmapTimesRoman10; -GLUTAPI void *glutBitmapTimesRoman24; -GLUTAPI void *glutBitmapHelvetica10; -GLUTAPI void *glutBitmapHelvetica12; -GLUTAPI void *glutBitmapHelvetica18; - -/* Bitmap font constants (use these in GLUT program). */ -#define GLUT_BITMAP_9_BY_15 (&glutBitmap9By15) -#define GLUT_BITMAP_8_BY_13 (&glutBitmap8By13) -#define GLUT_BITMAP_TIMES_ROMAN_10 (&glutBitmapTimesRoman10) -#define GLUT_BITMAP_TIMES_ROMAN_24 (&glutBitmapTimesRoman24) -#if (GLUT_API_VERSION >= 3) -#define GLUT_BITMAP_HELVETICA_10 (&glutBitmapHelvetica10) -#define GLUT_BITMAP_HELVETICA_12 (&glutBitmapHelvetica12) -#define GLUT_BITMAP_HELVETICA_18 (&glutBitmapHelvetica18) -#endif -#endif - -/* glutGet parameters. */ -#define GLUT_WINDOW_X ((GLenum) 100) -#define GLUT_WINDOW_Y ((GLenum) 101) -#define GLUT_WINDOW_WIDTH ((GLenum) 102) -#define GLUT_WINDOW_HEIGHT ((GLenum) 103) -#define GLUT_WINDOW_BUFFER_SIZE ((GLenum) 104) -#define GLUT_WINDOW_STENCIL_SIZE ((GLenum) 105) -#define GLUT_WINDOW_DEPTH_SIZE ((GLenum) 106) -#define GLUT_WINDOW_RED_SIZE ((GLenum) 107) -#define GLUT_WINDOW_GREEN_SIZE ((GLenum) 108) -#define GLUT_WINDOW_BLUE_SIZE ((GLenum) 109) -#define GLUT_WINDOW_ALPHA_SIZE ((GLenum) 110) -#define GLUT_WINDOW_ACCUM_RED_SIZE ((GLenum) 111) -#define GLUT_WINDOW_ACCUM_GREEN_SIZE ((GLenum) 112) -#define GLUT_WINDOW_ACCUM_BLUE_SIZE ((GLenum) 113) -#define GLUT_WINDOW_ACCUM_ALPHA_SIZE ((GLenum) 114) -#define GLUT_WINDOW_DOUBLEBUFFER ((GLenum) 115) -#define GLUT_WINDOW_RGBA ((GLenum) 116) -#define GLUT_WINDOW_PARENT ((GLenum) 117) -#define GLUT_WINDOW_NUM_CHILDREN ((GLenum) 118) -#define GLUT_WINDOW_COLORMAP_SIZE ((GLenum) 119) -#if (GLUT_API_VERSION >= 2) -#define GLUT_WINDOW_NUM_SAMPLES ((GLenum) 120) -#define GLUT_WINDOW_STEREO ((GLenum) 121) -#endif -#if (GLUT_API_VERSION >= 3) -#define GLUT_WINDOW_CURSOR ((GLenum) 122) -#endif -#define GLUT_SCREEN_WIDTH ((GLenum) 200) -#define GLUT_SCREEN_HEIGHT ((GLenum) 201) -#define GLUT_SCREEN_WIDTH_MM ((GLenum) 202) -#define GLUT_SCREEN_HEIGHT_MM ((GLenum) 203) -#define GLUT_MENU_NUM_ITEMS ((GLenum) 300) -#define GLUT_DISPLAY_MODE_POSSIBLE ((GLenum) 400) -#define GLUT_INIT_WINDOW_X ((GLenum) 500) -#define GLUT_INIT_WINDOW_Y ((GLenum) 501) -#define GLUT_INIT_WINDOW_WIDTH ((GLenum) 502) -#define GLUT_INIT_WINDOW_HEIGHT ((GLenum) 503) -#define GLUT_INIT_DISPLAY_MODE ((GLenum) 504) -#if (GLUT_API_VERSION >= 2) -#define GLUT_ELAPSED_TIME ((GLenum) 700) -#endif -#if (GLUT_API_VERSION >= 4 || GLUT_XLIB_IMPLEMENTATION >= 13) -#define GLUT_WINDOW_FORMAT_ID ((GLenum) 123) -#endif - -#if (GLUT_API_VERSION >= 2) -/* glutDeviceGet parameters. */ -#define GLUT_HAS_KEYBOARD ((GLenum) 600) -#define GLUT_HAS_MOUSE ((GLenum) 601) -#define GLUT_HAS_SPACEBALL ((GLenum) 602) -#define GLUT_HAS_DIAL_AND_BUTTON_BOX ((GLenum) 603) -#define GLUT_HAS_TABLET ((GLenum) 604) -#define GLUT_NUM_MOUSE_BUTTONS ((GLenum) 605) -#define GLUT_NUM_SPACEBALL_BUTTONS ((GLenum) 606) -#define GLUT_NUM_BUTTON_BOX_BUTTONS ((GLenum) 607) -#define GLUT_NUM_DIALS ((GLenum) 608) -#define GLUT_NUM_TABLET_BUTTONS ((GLenum) 609) -#endif -#if (GLUT_API_VERSION >= 4 || GLUT_XLIB_IMPLEMENTATION >= 13) -#define GLUT_DEVICE_IGNORE_KEY_REPEAT ((GLenum) 610) -#define GLUT_DEVICE_KEY_REPEAT ((GLenum) 611) -#define GLUT_HAS_JOYSTICK ((GLenum) 612) -#define GLUT_OWNS_JOYSTICK ((GLenum) 613) -#define GLUT_JOYSTICK_BUTTONS ((GLenum) 614) -#define GLUT_JOYSTICK_AXES ((GLenum) 615) -#define GLUT_JOYSTICK_POLL_RATE ((GLenum) 616) -#endif - -#if (GLUT_API_VERSION >= 3) -/* glutLayerGet parameters. */ -#define GLUT_OVERLAY_POSSIBLE ((GLenum) 800) -#define GLUT_LAYER_IN_USE ((GLenum) 801) -#define GLUT_HAS_OVERLAY ((GLenum) 802) -#define GLUT_TRANSPARENT_INDEX ((GLenum) 803) -#define GLUT_NORMAL_DAMAGED ((GLenum) 804) -#define GLUT_OVERLAY_DAMAGED ((GLenum) 805) - -#if (GLUT_API_VERSION >= 4 || GLUT_XLIB_IMPLEMENTATION >= 9) -/* glutVideoResizeGet parameters. */ -#define GLUT_VIDEO_RESIZE_POSSIBLE ((GLenum) 900) -#define GLUT_VIDEO_RESIZE_IN_USE ((GLenum) 901) -#define GLUT_VIDEO_RESIZE_X_DELTA ((GLenum) 902) -#define GLUT_VIDEO_RESIZE_Y_DELTA ((GLenum) 903) -#define GLUT_VIDEO_RESIZE_WIDTH_DELTA ((GLenum) 904) -#define GLUT_VIDEO_RESIZE_HEIGHT_DELTA ((GLenum) 905) -#define GLUT_VIDEO_RESIZE_X ((GLenum) 906) -#define GLUT_VIDEO_RESIZE_Y ((GLenum) 907) -#define GLUT_VIDEO_RESIZE_WIDTH ((GLenum) 908) -#define GLUT_VIDEO_RESIZE_HEIGHT ((GLenum) 909) -#endif - -/* glutUseLayer parameters. */ -#define GLUT_NORMAL ((GLenum) 0) -#define GLUT_OVERLAY ((GLenum) 1) - -/* glutGetModifiers return mask. */ -#define GLUT_ACTIVE_SHIFT 1 -#define GLUT_ACTIVE_CTRL 2 -#define GLUT_ACTIVE_ALT 4 - -/* glutSetCursor parameters. */ -/* Basic arrows. */ -#define GLUT_CURSOR_RIGHT_ARROW 0 -#define GLUT_CURSOR_LEFT_ARROW 1 -/* Symbolic cursor shapes. */ -#define GLUT_CURSOR_INFO 2 -#define GLUT_CURSOR_DESTROY 3 -#define GLUT_CURSOR_HELP 4 -#define GLUT_CURSOR_CYCLE 5 -#define GLUT_CURSOR_SPRAY 6 -#define GLUT_CURSOR_WAIT 7 -#define GLUT_CURSOR_TEXT 8 -#define GLUT_CURSOR_CROSSHAIR 9 -/* Directional cursors. */ -#define GLUT_CURSOR_UP_DOWN 10 -#define GLUT_CURSOR_LEFT_RIGHT 11 -/* Sizing cursors. */ -#define GLUT_CURSOR_TOP_SIDE 12 -#define GLUT_CURSOR_BOTTOM_SIDE 13 -#define GLUT_CURSOR_LEFT_SIDE 14 -#define GLUT_CURSOR_RIGHT_SIDE 15 -#define GLUT_CURSOR_TOP_LEFT_CORNER 16 -#define GLUT_CURSOR_TOP_RIGHT_CORNER 17 -#define GLUT_CURSOR_BOTTOM_RIGHT_CORNER 18 -#define GLUT_CURSOR_BOTTOM_LEFT_CORNER 19 -/* Inherit from parent window. */ -#define GLUT_CURSOR_INHERIT 100 -/* Blank cursor. */ -#define GLUT_CURSOR_NONE 101 -/* Fullscreen crosshair (if available). */ -#define GLUT_CURSOR_FULL_CROSSHAIR 102 -#endif - -/* GLUT initialization sub-API. */ -GLUTAPI void APIENTRY glutInit(int *argcp, char **argv); -#if defined(_WIN32) && !defined(GLUT_DISABLE_ATEXIT_HACK) -GLUTAPI void APIENTRY __glutInitWithExit(int *argcp, char **argv, void (__cdecl *exitfunc)(int)); -#ifndef GLUT_BUILDING_LIB -static void APIENTRY glutInit_ATEXIT_HACK(int *argcp, char **argv) { __glutInitWithExit(argcp, argv, exit); } -#define glutInit glutInit_ATEXIT_HACK -#endif -#endif -GLUTAPI void APIENTRY glutInitDisplayMode(unsigned int mode); -#if (GLUT_API_VERSION >= 4 || GLUT_XLIB_IMPLEMENTATION >= 9) -GLUTAPI void APIENTRY glutInitDisplayString(const char *string); -#endif -GLUTAPI void APIENTRY glutInitWindowPosition(int x, int y); -GLUTAPI void APIENTRY glutInitWindowSize(int width, int height); -GLUTAPI void APIENTRY glutMainLoop(void); - -/* GLUT window sub-API. */ -GLUTAPI int APIENTRY glutCreateWindow(const char *title); -#if defined(_WIN32) && !defined(GLUT_DISABLE_ATEXIT_HACK) -GLUTAPI int APIENTRY __glutCreateWindowWithExit(const char *title, void (__cdecl *exitfunc)(int)); -#ifndef GLUT_BUILDING_LIB -static int APIENTRY glutCreateWindow_ATEXIT_HACK(const char *title) { return __glutCreateWindowWithExit(title, exit); } -#define glutCreateWindow glutCreateWindow_ATEXIT_HACK -#endif -#endif -GLUTAPI int APIENTRY glutCreateSubWindow(int win, int x, int y, int width, int height); -GLUTAPI void APIENTRY glutDestroyWindow(int win); -GLUTAPI void APIENTRY glutPostRedisplay(void); -#if (GLUT_API_VERSION >= 4 || GLUT_XLIB_IMPLEMENTATION >= 11) -GLUTAPI void APIENTRY glutPostWindowRedisplay(int win); -#endif -GLUTAPI void APIENTRY glutSwapBuffers(void); -GLUTAPI int APIENTRY glutGetWindow(void); -GLUTAPI void APIENTRY glutSetWindow(int win); -GLUTAPI void APIENTRY glutSetWindowTitle(const char *title); -GLUTAPI void APIENTRY glutSetIconTitle(const char *title); -GLUTAPI void APIENTRY glutPositionWindow(int x, int y); -GLUTAPI void APIENTRY glutReshapeWindow(int width, int height); -GLUTAPI void APIENTRY glutPopWindow(void); -GLUTAPI void APIENTRY glutPushWindow(void); -GLUTAPI void APIENTRY glutIconifyWindow(void); -GLUTAPI void APIENTRY glutShowWindow(void); -GLUTAPI void APIENTRY glutHideWindow(void); -#if (GLUT_API_VERSION >= 3) -GLUTAPI void APIENTRY glutFullScreen(void); -GLUTAPI void APIENTRY glutSetCursor(int cursor); -#if (GLUT_API_VERSION >= 4 || GLUT_XLIB_IMPLEMENTATION >= 9) -GLUTAPI void APIENTRY glutWarpPointer(int x, int y); -#endif - -/* GLUT overlay sub-API. */ -GLUTAPI void APIENTRY glutEstablishOverlay(void); -GLUTAPI void APIENTRY glutRemoveOverlay(void); -GLUTAPI void APIENTRY glutUseLayer(GLenum layer); -GLUTAPI void APIENTRY glutPostOverlayRedisplay(void); -#if (GLUT_API_VERSION >= 4 || GLUT_XLIB_IMPLEMENTATION >= 11) -GLUTAPI void APIENTRY glutPostWindowOverlayRedisplay(int win); -#endif -GLUTAPI void APIENTRY glutShowOverlay(void); -GLUTAPI void APIENTRY glutHideOverlay(void); -#endif - -/* GLUT menu sub-API. */ -GLUTAPI int APIENTRY glutCreateMenu(void (GLUTCALLBACK *func)(int)); -#if defined(_WIN32) && !defined(GLUT_DISABLE_ATEXIT_HACK) -GLUTAPI int APIENTRY __glutCreateMenuWithExit(void (GLUTCALLBACK *func)(int), void (__cdecl *exitfunc)(int)); -#ifndef GLUT_BUILDING_LIB -static int APIENTRY glutCreateMenu_ATEXIT_HACK(void (GLUTCALLBACK *func)(int)) { return __glutCreateMenuWithExit(func, exit); } -#define glutCreateMenu glutCreateMenu_ATEXIT_HACK -#endif -#endif -GLUTAPI void APIENTRY glutDestroyMenu(int menu); -GLUTAPI int APIENTRY glutGetMenu(void); -GLUTAPI void APIENTRY glutSetMenu(int menu); -GLUTAPI void APIENTRY glutAddMenuEntry(const char *label, int value); -GLUTAPI void APIENTRY glutAddSubMenu(const char *label, int submenu); -GLUTAPI void APIENTRY glutChangeToMenuEntry(int item, const char *label, int value); -GLUTAPI void APIENTRY glutChangeToSubMenu(int item, const char *label, int submenu); -GLUTAPI void APIENTRY glutRemoveMenuItem(int item); -GLUTAPI void APIENTRY glutAttachMenu(int button); -GLUTAPI void APIENTRY glutDetachMenu(int button); - -/* GLUT window callback sub-API. */ -GLUTAPI void APIENTRY glutDisplayFunc(void (GLUTCALLBACK *func)(void)); -GLUTAPI void APIENTRY glutReshapeFunc(void (GLUTCALLBACK *func)(int width, int height)); -GLUTAPI void APIENTRY glutKeyboardFunc(void (GLUTCALLBACK *func)(unsigned char key, int x, int y)); -GLUTAPI void APIENTRY glutMouseFunc(void (GLUTCALLBACK *func)(int button, int state, int x, int y)); -GLUTAPI void APIENTRY glutMotionFunc(void (GLUTCALLBACK *func)(int x, int y)); -GLUTAPI void APIENTRY glutPassiveMotionFunc(void (GLUTCALLBACK *func)(int x, int y)); -GLUTAPI void APIENTRY glutEntryFunc(void (GLUTCALLBACK *func)(int state)); -GLUTAPI void APIENTRY glutVisibilityFunc(void (GLUTCALLBACK *func)(int state)); -GLUTAPI void APIENTRY glutIdleFunc(void (GLUTCALLBACK *func)(void)); -GLUTAPI void APIENTRY glutTimerFunc(unsigned int millis, void (GLUTCALLBACK *func)(int value), int value); -GLUTAPI void APIENTRY glutMenuStateFunc(void (GLUTCALLBACK *func)(int state)); -#if (GLUT_API_VERSION >= 2) -GLUTAPI void APIENTRY glutSpecialFunc(void (GLUTCALLBACK *func)(int key, int x, int y)); -GLUTAPI void APIENTRY glutSpaceballMotionFunc(void (GLUTCALLBACK *func)(int x, int y, int z)); -GLUTAPI void APIENTRY glutSpaceballRotateFunc(void (GLUTCALLBACK *func)(int x, int y, int z)); -GLUTAPI void APIENTRY glutSpaceballButtonFunc(void (GLUTCALLBACK *func)(int button, int state)); -GLUTAPI void APIENTRY glutButtonBoxFunc(void (GLUTCALLBACK *func)(int button, int state)); -GLUTAPI void APIENTRY glutDialsFunc(void (GLUTCALLBACK *func)(int dial, int value)); -GLUTAPI void APIENTRY glutTabletMotionFunc(void (GLUTCALLBACK *func)(int x, int y)); -GLUTAPI void APIENTRY glutTabletButtonFunc(void (GLUTCALLBACK *func)(int button, int state, int x, int y)); -#if (GLUT_API_VERSION >= 3) -GLUTAPI void APIENTRY glutMenuStatusFunc(void (GLUTCALLBACK *func)(int status, int x, int y)); -GLUTAPI void APIENTRY glutOverlayDisplayFunc(void (GLUTCALLBACK *func)(void)); -#if (GLUT_API_VERSION >= 4 || GLUT_XLIB_IMPLEMENTATION >= 9) -GLUTAPI void APIENTRY glutWindowStatusFunc(void (GLUTCALLBACK *func)(int state)); -#endif -#if (GLUT_API_VERSION >= 4 || GLUT_XLIB_IMPLEMENTATION >= 13) -GLUTAPI void APIENTRY glutKeyboardUpFunc(void (GLUTCALLBACK *func)(unsigned char key, int x, int y)); -GLUTAPI void APIENTRY glutSpecialUpFunc(void (GLUTCALLBACK *func)(int key, int x, int y)); -GLUTAPI void APIENTRY glutJoystickFunc(void (GLUTCALLBACK *func)(unsigned int buttonMask, int x, int y, int z), int pollInterval); -#endif -#endif -#endif - -/* GLUT color index sub-API. */ -GLUTAPI void APIENTRY glutSetColor(int, GLfloat red, GLfloat green, GLfloat blue); -GLUTAPI GLfloat APIENTRY glutGetColor(int ndx, int component); -GLUTAPI void APIENTRY glutCopyColormap(int win); - -/* GLUT state retrieval sub-API. */ -GLUTAPI int APIENTRY glutGet(GLenum type); -GLUTAPI int APIENTRY glutDeviceGet(GLenum type); -#if (GLUT_API_VERSION >= 2) -/* GLUT extension support sub-API */ -GLUTAPI int APIENTRY glutExtensionSupported(const char *name); -#endif -#if (GLUT_API_VERSION >= 3) -GLUTAPI int APIENTRY glutGetModifiers(void); -GLUTAPI int APIENTRY glutLayerGet(GLenum type); -#endif - -/* GLUT font sub-API */ -GLUTAPI void APIENTRY glutBitmapCharacter(void *font, int character); -GLUTAPI int APIENTRY glutBitmapWidth(void *font, int character); -GLUTAPI void APIENTRY glutStrokeCharacter(void *font, int character); -GLUTAPI int APIENTRY glutStrokeWidth(void *font, int character); -#if (GLUT_API_VERSION >= 4 || GLUT_XLIB_IMPLEMENTATION >= 9) -GLUTAPI int APIENTRY glutBitmapLength(void *font, const unsigned char *string); -GLUTAPI int APIENTRY glutStrokeLength(void *font, const unsigned char *string); -#endif - -/* GLUT pre-built models sub-API */ -GLUTAPI void APIENTRY glutWireSphere(GLdouble radius, GLint slices, GLint stacks); -GLUTAPI void APIENTRY glutSolidSphere(GLdouble radius, GLint slices, GLint stacks); -GLUTAPI void APIENTRY glutWireCone(GLdouble base, GLdouble height, GLint slices, GLint stacks); -GLUTAPI void APIENTRY glutSolidCone(GLdouble base, GLdouble height, GLint slices, GLint stacks); -GLUTAPI void APIENTRY glutWireCube(GLdouble size); -GLUTAPI void APIENTRY glutSolidCube(GLdouble size); -GLUTAPI void APIENTRY glutWireTorus(GLdouble innerRadius, GLdouble outerRadius, GLint sides, GLint rings); -GLUTAPI void APIENTRY glutSolidTorus(GLdouble innerRadius, GLdouble outerRadius, GLint sides, GLint rings); -GLUTAPI void APIENTRY glutWireDodecahedron(void); -GLUTAPI void APIENTRY glutSolidDodecahedron(void); -GLUTAPI void APIENTRY glutWireTeapot(GLdouble size); -GLUTAPI void APIENTRY glutSolidTeapot(GLdouble size); -GLUTAPI void APIENTRY glutWireOctahedron(void); -GLUTAPI void APIENTRY glutSolidOctahedron(void); -GLUTAPI void APIENTRY glutWireTetrahedron(void); -GLUTAPI void APIENTRY glutSolidTetrahedron(void); -GLUTAPI void APIENTRY glutWireIcosahedron(void); -GLUTAPI void APIENTRY glutSolidIcosahedron(void); - -#if (GLUT_API_VERSION >= 4 || GLUT_XLIB_IMPLEMENTATION >= 9) -/* GLUT video resize sub-API. */ -GLUTAPI int APIENTRY glutVideoResizeGet(GLenum param); -GLUTAPI void APIENTRY glutSetupVideoResizing(void); -GLUTAPI void APIENTRY glutStopVideoResizing(void); -GLUTAPI void APIENTRY glutVideoResize(int x, int y, int width, int height); -GLUTAPI void APIENTRY glutVideoPan(int x, int y, int width, int height); - -/* GLUT debugging sub-API. */ -GLUTAPI void APIENTRY glutReportErrors(void); -#endif - -#if (GLUT_API_VERSION >= 4 || GLUT_XLIB_IMPLEMENTATION >= 13) -/* GLUT device control sub-API. */ -/* glutSetKeyRepeat modes. */ -#define GLUT_KEY_REPEAT_OFF 0 -#define GLUT_KEY_REPEAT_ON 1 -#define GLUT_KEY_REPEAT_DEFAULT 2 - -/* Joystick button masks. */ -#define GLUT_JOYSTICK_BUTTON_A 1 -#define GLUT_JOYSTICK_BUTTON_B 2 -#define GLUT_JOYSTICK_BUTTON_C 4 -#define GLUT_JOYSTICK_BUTTON_D 8 - -GLUTAPI void APIENTRY glutIgnoreKeyRepeat(int ignore); -GLUTAPI void APIENTRY glutSetKeyRepeat(int repeatMode); -GLUTAPI void APIENTRY glutForceJoystickFunc(void); - -/* GLUT game mode sub-API. */ -/* glutGameModeGet. */ -#define GLUT_GAME_MODE_ACTIVE ((GLenum) 0) -#define GLUT_GAME_MODE_POSSIBLE ((GLenum) 1) -#define GLUT_GAME_MODE_WIDTH ((GLenum) 2) -#define GLUT_GAME_MODE_HEIGHT ((GLenum) 3) -#define GLUT_GAME_MODE_PIXEL_DEPTH ((GLenum) 4) -#define GLUT_GAME_MODE_REFRESH_RATE ((GLenum) 5) -#define GLUT_GAME_MODE_DISPLAY_CHANGED ((GLenum) 6) - -GLUTAPI void APIENTRY glutGameModeString(const char *string); -GLUTAPI int APIENTRY glutEnterGameMode(void); -GLUTAPI void APIENTRY glutLeaveGameMode(void); -GLUTAPI int APIENTRY glutGameModeGet(GLenum mode); -#endif - -#ifdef __cplusplus -} - -#endif - -#ifdef GLUT_APIENTRY_DEFINED -# undef GLUT_APIENTRY_DEFINED -# undef APIENTRY -#endif - -#ifdef GLUT_WINGDIAPI_DEFINED -# undef GLUT_WINGDIAPI_DEFINED -# undef WINGDIAPI -#endif - -#ifdef GLUT_DEFINED___CDECL -# undef GLUT_DEFINED___CDECL -# undef __cdecl -#endif - -#ifdef GLUT_DEFINED__CRTIMP -# undef GLUT_DEFINED__CRTIMP -# undef _CRTIMP -#endif - -#endif /* __glut_h__ */ diff --git a/opengl/glew.c b/opengl/glew.c deleted file mode 100644 index 539c61f4..00000000 --- a/opengl/glew.c +++ /dev/null @@ -1,12180 +0,0 @@ -/* -** The OpenGL Extension Wrangler Library -** Copyright (C) 2002-2008, Milan Ikits -** Copyright (C) 2002-2008, Marcelo E. Magallon -** Copyright (C) 2002, Lev Povalahev -** All rights reserved. -** -** Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are met: -** -** * Redistributions of source code must retain the above copyright notice, -** this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright notice, -** this list of conditions and the following disclaimer in the documentation -** and/or other materials provided with the distribution. -** * The name of the author may be used to endorse or promote products -** derived from this software without specific prior written permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -** AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -** IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -** ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE -** LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -** CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -** SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -** INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -** CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -** ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF -** THE POSSIBILITY OF SUCH DAMAGE. -*/ - -#include "OPENGL/glew.h" -#if defined(_WIN32) -# include "OPENGL/wglew.h" -#elif !defined(__APPLE__) || defined(GLEW_APPLE_GLX) -# include "OPENGL/glxew.h" -#endif - -/* - * Define glewGetContext and related helper macros. - */ -#ifdef GLEW_MX -# define glewGetContext() ctx -# ifdef _WIN32 -# define GLEW_CONTEXT_ARG_DEF_INIT GLEWContext* ctx -# define GLEW_CONTEXT_ARG_VAR_INIT ctx -# define wglewGetContext() ctx -# define WGLEW_CONTEXT_ARG_DEF_INIT WGLEWContext* ctx -# define WGLEW_CONTEXT_ARG_DEF_LIST WGLEWContext* ctx -# else /* _WIN32 */ -# define GLEW_CONTEXT_ARG_DEF_INIT void -# define GLEW_CONTEXT_ARG_VAR_INIT -# define glxewGetContext() ctx -# define GLXEW_CONTEXT_ARG_DEF_INIT void -# define GLXEW_CONTEXT_ARG_DEF_LIST GLXEWContext* ctx -# endif /* _WIN32 */ -# define GLEW_CONTEXT_ARG_DEF_LIST GLEWContext* ctx -#else /* GLEW_MX */ -# define GLEW_CONTEXT_ARG_DEF_INIT void -# define GLEW_CONTEXT_ARG_VAR_INIT -# define GLEW_CONTEXT_ARG_DEF_LIST void -# define WGLEW_CONTEXT_ARG_DEF_INIT void -# define WGLEW_CONTEXT_ARG_DEF_LIST void -# define GLXEW_CONTEXT_ARG_DEF_INIT void -# define GLXEW_CONTEXT_ARG_DEF_LIST void -#endif /* GLEW_MX */ - -#if defined(__APPLE__) -#include -#include -#include - -void* NSGLGetProcAddress (const GLubyte *name) -{ - static const struct mach_header* image = NULL; - NSSymbol symbol; - char* symbolName; - if (NULL == image) - { - image = NSAddImage("/System/Library/Frameworks/OpenGL.framework/Versions/Current/OpenGL", NSADDIMAGE_OPTION_RETURN_ON_ERROR); - } - /* prepend a '_' for the Unix C symbol mangling convention */ - symbolName = malloc(strlen((const char*)name) + 2); - strcpy(symbolName+1, (const char*)name); - symbolName[0] = '_'; - symbol = NULL; - /* if (NSIsSymbolNameDefined(symbolName)) - symbol = NSLookupAndBindSymbol(symbolName); */ - symbol = image ? NSLookupSymbolInImage(image, symbolName, NSLOOKUPSYMBOLINIMAGE_OPTION_BIND | NSLOOKUPSYMBOLINIMAGE_OPTION_RETURN_ON_ERROR) : NULL; - free(symbolName); - return symbol ? NSAddressOfSymbol(symbol) : NULL; -} -#endif /* __APPLE__ */ - -#if defined(__sgi) || defined (__sun) -#include -#include -#include - -void* dlGetProcAddress (const GLubyte* name) -{ - static void* h = NULL; - static void* gpa; - - if (h == NULL) - { - if ((h = dlopen(NULL, RTLD_LAZY | RTLD_LOCAL)) == NULL) return NULL; - gpa = dlsym(h, "glXGetProcAddress"); - } - - if (gpa != NULL) - return ((void*(*)(const GLubyte*))gpa)(name); - else - return dlsym(h, (const char*)name); -} -#endif /* __sgi || __sun */ - -/* - * Define glewGetProcAddress. - */ -#if defined(_WIN32) -# define glewGetProcAddress(name) wglGetProcAddress((LPCSTR)name) -#else -# if defined(__APPLE__) -# define glewGetProcAddress(name) NSGLGetProcAddress(name) -# else -# if defined(__sgi) || defined(__sun) -# define glewGetProcAddress(name) dlGetProcAddress(name) -# else /* __linux */ -# define glewGetProcAddress(name) (*glXGetProcAddressARB)(name) -# endif -# endif -#endif - -/* - * Define GLboolean const cast. - */ -#define CONST_CAST(x) (*(GLboolean*)&x) - -/* - * GLEW, just like OpenGL or GLU, does not rely on the standard C library. - * These functions implement the functionality required in this file. - */ -static GLuint _glewStrLen (const GLubyte* s) -{ - GLuint i=0; - if (s == NULL) return 0; - while (s[i] != '\0') i++; - return i; -} - -static GLuint _glewStrCLen (const GLubyte* s, GLubyte c) -{ - GLuint i=0; - if (s == NULL) return 0; - while (s[i] != '\0' && s[i] != c) i++; - return (s[i] == '\0' || s[i] == c) ? i : 0; -} - -static GLboolean _glewStrSame (const GLubyte* a, const GLubyte* b, GLuint n) -{ - GLuint i=0; - if(a == NULL || b == NULL) - return (a == NULL && b == NULL && n == 0) ? GL_TRUE : GL_FALSE; - while (i < n && a[i] != '\0' && b[i] != '\0' && a[i] == b[i]) i++; - return i == n ? GL_TRUE : GL_FALSE; -} - -static GLboolean _glewStrSame1 (GLubyte** a, GLuint* na, const GLubyte* b, GLuint nb) -{ - while (*na > 0 && (**a == ' ' || **a == '\n' || **a == '\r' || **a == '\t')) - { - (*a)++; - (*na)--; - } - if(*na >= nb) - { - GLuint i=0; - while (i < nb && (*a)+i != NULL && b+i != NULL && (*a)[i] == b[i]) i++; - if(i == nb) - { - *a = *a + nb; - *na = *na - nb; - return GL_TRUE; - } - } - return GL_FALSE; -} - -static GLboolean _glewStrSame2 (GLubyte** a, GLuint* na, const GLubyte* b, GLuint nb) -{ - if(*na >= nb) - { - GLuint i=0; - while (i < nb && (*a)+i != NULL && b+i != NULL && (*a)[i] == b[i]) i++; - if(i == nb) - { - *a = *a + nb; - *na = *na - nb; - return GL_TRUE; - } - } - return GL_FALSE; -} - -static GLboolean _glewStrSame3 (GLubyte** a, GLuint* na, const GLubyte* b, GLuint nb) -{ - if(*na >= nb) - { - GLuint i=0; - while (i < nb && (*a)+i != NULL && b+i != NULL && (*a)[i] == b[i]) i++; - if (i == nb && (*na == nb || (*a)[i] == ' ' || (*a)[i] == '\n' || (*a)[i] == '\r' || (*a)[i] == '\t')) - { - *a = *a + nb; - *na = *na - nb; - return GL_TRUE; - } - } - return GL_FALSE; -} - -#if !defined(_WIN32) || !defined(GLEW_MX) - -PFNGLCOPYTEXSUBIMAGE3DPROC __glewCopyTexSubImage3D = NULL; -PFNGLDRAWRANGEELEMENTSPROC __glewDrawRangeElements = NULL; -PFNGLTEXIMAGE3DPROC __glewTexImage3D = NULL; -PFNGLTEXSUBIMAGE3DPROC __glewTexSubImage3D = NULL; - -PFNGLACTIVETEXTUREPROC __glewActiveTexture = NULL; -PFNGLCLIENTACTIVETEXTUREPROC __glewClientActiveTexture = NULL; -PFNGLCOMPRESSEDTEXIMAGE1DPROC __glewCompressedTexImage1D = NULL; -PFNGLCOMPRESSEDTEXIMAGE2DPROC __glewCompressedTexImage2D = NULL; -PFNGLCOMPRESSEDTEXIMAGE3DPROC __glewCompressedTexImage3D = NULL; -PFNGLCOMPRESSEDTEXSUBIMAGE1DPROC __glewCompressedTexSubImage1D = NULL; -PFNGLCOMPRESSEDTEXSUBIMAGE2DPROC __glewCompressedTexSubImage2D = NULL; -PFNGLCOMPRESSEDTEXSUBIMAGE3DPROC __glewCompressedTexSubImage3D = NULL; -PFNGLGETCOMPRESSEDTEXIMAGEPROC __glewGetCompressedTexImage = NULL; -PFNGLLOADTRANSPOSEMATRIXDPROC __glewLoadTransposeMatrixd = NULL; -PFNGLLOADTRANSPOSEMATRIXFPROC __glewLoadTransposeMatrixf = NULL; -PFNGLMULTTRANSPOSEMATRIXDPROC __glewMultTransposeMatrixd = NULL; -PFNGLMULTTRANSPOSEMATRIXFPROC __glewMultTransposeMatrixf = NULL; -PFNGLMULTITEXCOORD1DPROC __glewMultiTexCoord1d = NULL; -PFNGLMULTITEXCOORD1DVPROC __glewMultiTexCoord1dv = NULL; -PFNGLMULTITEXCOORD1FPROC __glewMultiTexCoord1f = NULL; -PFNGLMULTITEXCOORD1FVPROC __glewMultiTexCoord1fv = NULL; -PFNGLMULTITEXCOORD1IPROC __glewMultiTexCoord1i = NULL; -PFNGLMULTITEXCOORD1IVPROC __glewMultiTexCoord1iv = NULL; -PFNGLMULTITEXCOORD1SPROC __glewMultiTexCoord1s = NULL; -PFNGLMULTITEXCOORD1SVPROC __glewMultiTexCoord1sv = NULL; -PFNGLMULTITEXCOORD2DPROC __glewMultiTexCoord2d = NULL; -PFNGLMULTITEXCOORD2DVPROC __glewMultiTexCoord2dv = NULL; -PFNGLMULTITEXCOORD2FPROC __glewMultiTexCoord2f = NULL; -PFNGLMULTITEXCOORD2FVPROC __glewMultiTexCoord2fv = NULL; -PFNGLMULTITEXCOORD2IPROC __glewMultiTexCoord2i = NULL; -PFNGLMULTITEXCOORD2IVPROC __glewMultiTexCoord2iv = NULL; -PFNGLMULTITEXCOORD2SPROC __glewMultiTexCoord2s = NULL; -PFNGLMULTITEXCOORD2SVPROC __glewMultiTexCoord2sv = NULL; -PFNGLMULTITEXCOORD3DPROC __glewMultiTexCoord3d = NULL; -PFNGLMULTITEXCOORD3DVPROC __glewMultiTexCoord3dv = NULL; -PFNGLMULTITEXCOORD3FPROC __glewMultiTexCoord3f = NULL; -PFNGLMULTITEXCOORD3FVPROC __glewMultiTexCoord3fv = NULL; -PFNGLMULTITEXCOORD3IPROC __glewMultiTexCoord3i = NULL; -PFNGLMULTITEXCOORD3IVPROC __glewMultiTexCoord3iv = NULL; -PFNGLMULTITEXCOORD3SPROC __glewMultiTexCoord3s = NULL; -PFNGLMULTITEXCOORD3SVPROC __glewMultiTexCoord3sv = NULL; -PFNGLMULTITEXCOORD4DPROC __glewMultiTexCoord4d = NULL; -PFNGLMULTITEXCOORD4DVPROC __glewMultiTexCoord4dv = NULL; -PFNGLMULTITEXCOORD4FPROC __glewMultiTexCoord4f = NULL; -PFNGLMULTITEXCOORD4FVPROC __glewMultiTexCoord4fv = NULL; -PFNGLMULTITEXCOORD4IPROC __glewMultiTexCoord4i = NULL; -PFNGLMULTITEXCOORD4IVPROC __glewMultiTexCoord4iv = NULL; -PFNGLMULTITEXCOORD4SPROC __glewMultiTexCoord4s = NULL; -PFNGLMULTITEXCOORD4SVPROC __glewMultiTexCoord4sv = NULL; -PFNGLSAMPLECOVERAGEPROC __glewSampleCoverage = NULL; - -PFNGLBLENDCOLORPROC __glewBlendColor = NULL; -PFNGLBLENDEQUATIONPROC __glewBlendEquation = NULL; -PFNGLBLENDFUNCSEPARATEPROC __glewBlendFuncSeparate = NULL; -PFNGLFOGCOORDPOINTERPROC __glewFogCoordPointer = NULL; -PFNGLFOGCOORDDPROC __glewFogCoordd = NULL; -PFNGLFOGCOORDDVPROC __glewFogCoorddv = NULL; -PFNGLFOGCOORDFPROC __glewFogCoordf = NULL; -PFNGLFOGCOORDFVPROC __glewFogCoordfv = NULL; -PFNGLMULTIDRAWARRAYSPROC __glewMultiDrawArrays = NULL; -PFNGLMULTIDRAWELEMENTSPROC __glewMultiDrawElements = NULL; -PFNGLPOINTPARAMETERFPROC __glewPointParameterf = NULL; -PFNGLPOINTPARAMETERFVPROC __glewPointParameterfv = NULL; -PFNGLPOINTPARAMETERIPROC __glewPointParameteri = NULL; -PFNGLPOINTPARAMETERIVPROC __glewPointParameteriv = NULL; -PFNGLSECONDARYCOLOR3BPROC __glewSecondaryColor3b = NULL; -PFNGLSECONDARYCOLOR3BVPROC __glewSecondaryColor3bv = NULL; -PFNGLSECONDARYCOLOR3DPROC __glewSecondaryColor3d = NULL; -PFNGLSECONDARYCOLOR3DVPROC __glewSecondaryColor3dv = NULL; -PFNGLSECONDARYCOLOR3FPROC __glewSecondaryColor3f = NULL; -PFNGLSECONDARYCOLOR3FVPROC __glewSecondaryColor3fv = NULL; -PFNGLSECONDARYCOLOR3IPROC __glewSecondaryColor3i = NULL; -PFNGLSECONDARYCOLOR3IVPROC __glewSecondaryColor3iv = NULL; -PFNGLSECONDARYCOLOR3SPROC __glewSecondaryColor3s = NULL; -PFNGLSECONDARYCOLOR3SVPROC __glewSecondaryColor3sv = NULL; -PFNGLSECONDARYCOLOR3UBPROC __glewSecondaryColor3ub = NULL; -PFNGLSECONDARYCOLOR3UBVPROC __glewSecondaryColor3ubv = NULL; -PFNGLSECONDARYCOLOR3UIPROC __glewSecondaryColor3ui = NULL; -PFNGLSECONDARYCOLOR3UIVPROC __glewSecondaryColor3uiv = NULL; -PFNGLSECONDARYCOLOR3USPROC __glewSecondaryColor3us = NULL; -PFNGLSECONDARYCOLOR3USVPROC __glewSecondaryColor3usv = NULL; -PFNGLSECONDARYCOLORPOINTERPROC __glewSecondaryColorPointer = NULL; -PFNGLWINDOWPOS2DPROC __glewWindowPos2d = NULL; -PFNGLWINDOWPOS2DVPROC __glewWindowPos2dv = NULL; -PFNGLWINDOWPOS2FPROC __glewWindowPos2f = NULL; -PFNGLWINDOWPOS2FVPROC __glewWindowPos2fv = NULL; -PFNGLWINDOWPOS2IPROC __glewWindowPos2i = NULL; -PFNGLWINDOWPOS2IVPROC __glewWindowPos2iv = NULL; -PFNGLWINDOWPOS2SPROC __glewWindowPos2s = NULL; -PFNGLWINDOWPOS2SVPROC __glewWindowPos2sv = NULL; -PFNGLWINDOWPOS3DPROC __glewWindowPos3d = NULL; -PFNGLWINDOWPOS3DVPROC __glewWindowPos3dv = NULL; -PFNGLWINDOWPOS3FPROC __glewWindowPos3f = NULL; -PFNGLWINDOWPOS3FVPROC __glewWindowPos3fv = NULL; -PFNGLWINDOWPOS3IPROC __glewWindowPos3i = NULL; -PFNGLWINDOWPOS3IVPROC __glewWindowPos3iv = NULL; -PFNGLWINDOWPOS3SPROC __glewWindowPos3s = NULL; -PFNGLWINDOWPOS3SVPROC __glewWindowPos3sv = NULL; - -PFNGLBEGINQUERYPROC __glewBeginQuery = NULL; -PFNGLBINDBUFFERPROC __glewBindBuffer = NULL; -PFNGLBUFFERDATAPROC __glewBufferData = NULL; -PFNGLBUFFERSUBDATAPROC __glewBufferSubData = NULL; -PFNGLDELETEBUFFERSPROC __glewDeleteBuffers = NULL; -PFNGLDELETEQUERIESPROC __glewDeleteQueries = NULL; -PFNGLENDQUERYPROC __glewEndQuery = NULL; -PFNGLGENBUFFERSPROC __glewGenBuffers = NULL; -PFNGLGENQUERIESPROC __glewGenQueries = NULL; -PFNGLGETBUFFERPARAMETERIVPROC __glewGetBufferParameteriv = NULL; -PFNGLGETBUFFERPOINTERVPROC __glewGetBufferPointerv = NULL; -PFNGLGETBUFFERSUBDATAPROC __glewGetBufferSubData = NULL; -PFNGLGETQUERYOBJECTIVPROC __glewGetQueryObjectiv = NULL; -PFNGLGETQUERYOBJECTUIVPROC __glewGetQueryObjectuiv = NULL; -PFNGLGETQUERYIVPROC __glewGetQueryiv = NULL; -PFNGLISBUFFERPROC __glewIsBuffer = NULL; -PFNGLISQUERYPROC __glewIsQuery = NULL; -PFNGLMAPBUFFERPROC __glewMapBuffer = NULL; -PFNGLUNMAPBUFFERPROC __glewUnmapBuffer = NULL; - -PFNGLATTACHSHADERPROC __glewAttachShader = NULL; -PFNGLBINDATTRIBLOCATIONPROC __glewBindAttribLocation = NULL; -PFNGLBLENDEQUATIONSEPARATEPROC __glewBlendEquationSeparate = NULL; -PFNGLCOMPILESHADERPROC __glewCompileShader = NULL; -PFNGLCREATEPROGRAMPROC __glewCreateProgram = NULL; -PFNGLCREATESHADERPROC __glewCreateShader = NULL; -PFNGLDELETEPROGRAMPROC __glewDeleteProgram = NULL; -PFNGLDELETESHADERPROC __glewDeleteShader = NULL; -PFNGLDETACHSHADERPROC __glewDetachShader = NULL; -PFNGLDISABLEVERTEXATTRIBARRAYPROC __glewDisableVertexAttribArray = NULL; -PFNGLDRAWBUFFERSPROC __glewDrawBuffers = NULL; -PFNGLENABLEVERTEXATTRIBARRAYPROC __glewEnableVertexAttribArray = NULL; -PFNGLGETACTIVEATTRIBPROC __glewGetActiveAttrib = NULL; -PFNGLGETACTIVEUNIFORMPROC __glewGetActiveUniform = NULL; -PFNGLGETATTACHEDSHADERSPROC __glewGetAttachedShaders = NULL; -PFNGLGETATTRIBLOCATIONPROC __glewGetAttribLocation = NULL; -PFNGLGETPROGRAMINFOLOGPROC __glewGetProgramInfoLog = NULL; -PFNGLGETPROGRAMIVPROC __glewGetProgramiv = NULL; -PFNGLGETSHADERINFOLOGPROC __glewGetShaderInfoLog = NULL; -PFNGLGETSHADERSOURCEPROC __glewGetShaderSource = NULL; -PFNGLGETSHADERIVPROC __glewGetShaderiv = NULL; -PFNGLGETUNIFORMLOCATIONPROC __glewGetUniformLocation = NULL; -PFNGLGETUNIFORMFVPROC __glewGetUniformfv = NULL; -PFNGLGETUNIFORMIVPROC __glewGetUniformiv = NULL; -PFNGLGETVERTEXATTRIBPOINTERVPROC __glewGetVertexAttribPointerv = NULL; -PFNGLGETVERTEXATTRIBDVPROC __glewGetVertexAttribdv = NULL; -PFNGLGETVERTEXATTRIBFVPROC __glewGetVertexAttribfv = NULL; -PFNGLGETVERTEXATTRIBIVPROC __glewGetVertexAttribiv = NULL; -PFNGLISPROGRAMPROC __glewIsProgram = NULL; -PFNGLISSHADERPROC __glewIsShader = NULL; -PFNGLLINKPROGRAMPROC __glewLinkProgram = NULL; -PFNGLSHADERSOURCEPROC __glewShaderSource = NULL; -PFNGLSTENCILFUNCSEPARATEPROC __glewStencilFuncSeparate = NULL; -PFNGLSTENCILMASKSEPARATEPROC __glewStencilMaskSeparate = NULL; -PFNGLSTENCILOPSEPARATEPROC __glewStencilOpSeparate = NULL; -PFNGLUNIFORM1FPROC __glewUniform1f = NULL; -PFNGLUNIFORM1FVPROC __glewUniform1fv = NULL; -PFNGLUNIFORM1IPROC __glewUniform1i = NULL; -PFNGLUNIFORM1IVPROC __glewUniform1iv = NULL; -PFNGLUNIFORM2FPROC __glewUniform2f = NULL; -PFNGLUNIFORM2FVPROC __glewUniform2fv = NULL; -PFNGLUNIFORM2IPROC __glewUniform2i = NULL; -PFNGLUNIFORM2IVPROC __glewUniform2iv = NULL; -PFNGLUNIFORM3FPROC __glewUniform3f = NULL; -PFNGLUNIFORM3FVPROC __glewUniform3fv = NULL; -PFNGLUNIFORM3IPROC __glewUniform3i = NULL; -PFNGLUNIFORM3IVPROC __glewUniform3iv = NULL; -PFNGLUNIFORM4FPROC __glewUniform4f = NULL; -PFNGLUNIFORM4FVPROC __glewUniform4fv = NULL; -PFNGLUNIFORM4IPROC __glewUniform4i = NULL; -PFNGLUNIFORM4IVPROC __glewUniform4iv = NULL; -PFNGLUNIFORMMATRIX2FVPROC __glewUniformMatrix2fv = NULL; -PFNGLUNIFORMMATRIX3FVPROC __glewUniformMatrix3fv = NULL; -PFNGLUNIFORMMATRIX4FVPROC __glewUniformMatrix4fv = NULL; -PFNGLUSEPROGRAMPROC __glewUseProgram = NULL; -PFNGLVALIDATEPROGRAMPROC __glewValidateProgram = NULL; -PFNGLVERTEXATTRIB1DPROC __glewVertexAttrib1d = NULL; -PFNGLVERTEXATTRIB1DVPROC __glewVertexAttrib1dv = NULL; -PFNGLVERTEXATTRIB1FPROC __glewVertexAttrib1f = NULL; -PFNGLVERTEXATTRIB1FVPROC __glewVertexAttrib1fv = NULL; -PFNGLVERTEXATTRIB1SPROC __glewVertexAttrib1s = NULL; -PFNGLVERTEXATTRIB1SVPROC __glewVertexAttrib1sv = NULL; -PFNGLVERTEXATTRIB2DPROC __glewVertexAttrib2d = NULL; -PFNGLVERTEXATTRIB2DVPROC __glewVertexAttrib2dv = NULL; -PFNGLVERTEXATTRIB2FPROC __glewVertexAttrib2f = NULL; -PFNGLVERTEXATTRIB2FVPROC __glewVertexAttrib2fv = NULL; -PFNGLVERTEXATTRIB2SPROC __glewVertexAttrib2s = NULL; -PFNGLVERTEXATTRIB2SVPROC __glewVertexAttrib2sv = NULL; -PFNGLVERTEXATTRIB3DPROC __glewVertexAttrib3d = NULL; -PFNGLVERTEXATTRIB3DVPROC __glewVertexAttrib3dv = NULL; -PFNGLVERTEXATTRIB3FPROC __glewVertexAttrib3f = NULL; -PFNGLVERTEXATTRIB3FVPROC __glewVertexAttrib3fv = NULL; -PFNGLVERTEXATTRIB3SPROC __glewVertexAttrib3s = NULL; -PFNGLVERTEXATTRIB3SVPROC __glewVertexAttrib3sv = NULL; -PFNGLVERTEXATTRIB4NBVPROC __glewVertexAttrib4Nbv = NULL; -PFNGLVERTEXATTRIB4NIVPROC __glewVertexAttrib4Niv = NULL; -PFNGLVERTEXATTRIB4NSVPROC __glewVertexAttrib4Nsv = NULL; -PFNGLVERTEXATTRIB4NUBPROC __glewVertexAttrib4Nub = NULL; -PFNGLVERTEXATTRIB4NUBVPROC __glewVertexAttrib4Nubv = NULL; -PFNGLVERTEXATTRIB4NUIVPROC __glewVertexAttrib4Nuiv = NULL; -PFNGLVERTEXATTRIB4NUSVPROC __glewVertexAttrib4Nusv = NULL; -PFNGLVERTEXATTRIB4BVPROC __glewVertexAttrib4bv = NULL; -PFNGLVERTEXATTRIB4DPROC __glewVertexAttrib4d = NULL; -PFNGLVERTEXATTRIB4DVPROC __glewVertexAttrib4dv = NULL; -PFNGLVERTEXATTRIB4FPROC __glewVertexAttrib4f = NULL; -PFNGLVERTEXATTRIB4FVPROC __glewVertexAttrib4fv = NULL; -PFNGLVERTEXATTRIB4IVPROC __glewVertexAttrib4iv = NULL; -PFNGLVERTEXATTRIB4SPROC __glewVertexAttrib4s = NULL; -PFNGLVERTEXATTRIB4SVPROC __glewVertexAttrib4sv = NULL; -PFNGLVERTEXATTRIB4UBVPROC __glewVertexAttrib4ubv = NULL; -PFNGLVERTEXATTRIB4UIVPROC __glewVertexAttrib4uiv = NULL; -PFNGLVERTEXATTRIB4USVPROC __glewVertexAttrib4usv = NULL; -PFNGLVERTEXATTRIBPOINTERPROC __glewVertexAttribPointer = NULL; - -PFNGLUNIFORMMATRIX2X3FVPROC __glewUniformMatrix2x3fv = NULL; -PFNGLUNIFORMMATRIX2X4FVPROC __glewUniformMatrix2x4fv = NULL; -PFNGLUNIFORMMATRIX3X2FVPROC __glewUniformMatrix3x2fv = NULL; -PFNGLUNIFORMMATRIX3X4FVPROC __glewUniformMatrix3x4fv = NULL; -PFNGLUNIFORMMATRIX4X2FVPROC __glewUniformMatrix4x2fv = NULL; -PFNGLUNIFORMMATRIX4X3FVPROC __glewUniformMatrix4x3fv = NULL; - -PFNGLBEGINCONDITIONALRENDERPROC __glewBeginConditionalRender = NULL; -PFNGLBEGINTRANSFORMFEEDBACKPROC __glewBeginTransformFeedback = NULL; -PFNGLBINDBUFFERBASEPROC __glewBindBufferBase = NULL; -PFNGLBINDBUFFERRANGEPROC __glewBindBufferRange = NULL; -PFNGLBINDFRAGDATALOCATIONPROC __glewBindFragDataLocation = NULL; -PFNGLCLAMPCOLORPROC __glewClampColor = NULL; -PFNGLCLEARBUFFERFIPROC __glewClearBufferfi = NULL; -PFNGLCLEARBUFFERFVPROC __glewClearBufferfv = NULL; -PFNGLCLEARBUFFERIVPROC __glewClearBufferiv = NULL; -PFNGLCLEARBUFFERUIVPROC __glewClearBufferuiv = NULL; -PFNGLCOLORMASKIPROC __glewColorMaski = NULL; -PFNGLDISABLEIPROC __glewDisablei = NULL; -PFNGLENABLEIPROC __glewEnablei = NULL; -PFNGLENDCONDITIONALRENDERPROC __glewEndConditionalRender = NULL; -PFNGLENDTRANSFORMFEEDBACKPROC __glewEndTransformFeedback = NULL; -PFNGLGETBOOLEANI_VPROC __glewGetBooleani_v = NULL; -PFNGLGETFRAGDATALOCATIONPROC __glewGetFragDataLocation = NULL; -PFNGLGETINTEGERI_VPROC __glewGetIntegeri_v = NULL; -PFNGLGETSTRINGIPROC __glewGetStringi = NULL; -PFNGLGETTEXPARAMETERIIVPROC __glewGetTexParameterIiv = NULL; -PFNGLGETTEXPARAMETERIUIVPROC __glewGetTexParameterIuiv = NULL; -PFNGLGETTRANSFORMFEEDBACKVARYINGPROC __glewGetTransformFeedbackVarying = NULL; -PFNGLGETUNIFORMUIVPROC __glewGetUniformuiv = NULL; -PFNGLGETVERTEXATTRIBIIVPROC __glewGetVertexAttribIiv = NULL; -PFNGLGETVERTEXATTRIBIUIVPROC __glewGetVertexAttribIuiv = NULL; -PFNGLISENABLEDIPROC __glewIsEnabledi = NULL; -PFNGLTEXPARAMETERIIVPROC __glewTexParameterIiv = NULL; -PFNGLTEXPARAMETERIUIVPROC __glewTexParameterIuiv = NULL; -PFNGLTRANSFORMFEEDBACKVARYINGSPROC __glewTransformFeedbackVaryings = NULL; -PFNGLUNIFORM1UIPROC __glewUniform1ui = NULL; -PFNGLUNIFORM1UIVPROC __glewUniform1uiv = NULL; -PFNGLUNIFORM2UIPROC __glewUniform2ui = NULL; -PFNGLUNIFORM2UIVPROC __glewUniform2uiv = NULL; -PFNGLUNIFORM3UIPROC __glewUniform3ui = NULL; -PFNGLUNIFORM3UIVPROC __glewUniform3uiv = NULL; -PFNGLUNIFORM4UIPROC __glewUniform4ui = NULL; -PFNGLUNIFORM4UIVPROC __glewUniform4uiv = NULL; -PFNGLVERTEXATTRIBI1IPROC __glewVertexAttribI1i = NULL; -PFNGLVERTEXATTRIBI1IVPROC __glewVertexAttribI1iv = NULL; -PFNGLVERTEXATTRIBI1UIPROC __glewVertexAttribI1ui = NULL; -PFNGLVERTEXATTRIBI1UIVPROC __glewVertexAttribI1uiv = NULL; -PFNGLVERTEXATTRIBI2IPROC __glewVertexAttribI2i = NULL; -PFNGLVERTEXATTRIBI2IVPROC __glewVertexAttribI2iv = NULL; -PFNGLVERTEXATTRIBI2UIPROC __glewVertexAttribI2ui = NULL; -PFNGLVERTEXATTRIBI2UIVPROC __glewVertexAttribI2uiv = NULL; -PFNGLVERTEXATTRIBI3IPROC __glewVertexAttribI3i = NULL; -PFNGLVERTEXATTRIBI3IVPROC __glewVertexAttribI3iv = NULL; -PFNGLVERTEXATTRIBI3UIPROC __glewVertexAttribI3ui = NULL; -PFNGLVERTEXATTRIBI3UIVPROC __glewVertexAttribI3uiv = NULL; -PFNGLVERTEXATTRIBI4BVPROC __glewVertexAttribI4bv = NULL; -PFNGLVERTEXATTRIBI4IPROC __glewVertexAttribI4i = NULL; -PFNGLVERTEXATTRIBI4IVPROC __glewVertexAttribI4iv = NULL; -PFNGLVERTEXATTRIBI4SVPROC __glewVertexAttribI4sv = NULL; -PFNGLVERTEXATTRIBI4UBVPROC __glewVertexAttribI4ubv = NULL; -PFNGLVERTEXATTRIBI4UIPROC __glewVertexAttribI4ui = NULL; -PFNGLVERTEXATTRIBI4UIVPROC __glewVertexAttribI4uiv = NULL; -PFNGLVERTEXATTRIBI4USVPROC __glewVertexAttribI4usv = NULL; -PFNGLVERTEXATTRIBIPOINTERPROC __glewVertexAttribIPointer = NULL; - -PFNGLTBUFFERMASK3DFXPROC __glewTbufferMask3DFX = NULL; - -PFNGLDRAWELEMENTARRAYAPPLEPROC __glewDrawElementArrayAPPLE = NULL; -PFNGLDRAWRANGEELEMENTARRAYAPPLEPROC __glewDrawRangeElementArrayAPPLE = NULL; -PFNGLELEMENTPOINTERAPPLEPROC __glewElementPointerAPPLE = NULL; -PFNGLMULTIDRAWELEMENTARRAYAPPLEPROC __glewMultiDrawElementArrayAPPLE = NULL; -PFNGLMULTIDRAWRANGEELEMENTARRAYAPPLEPROC __glewMultiDrawRangeElementArrayAPPLE = NULL; - -PFNGLDELETEFENCESAPPLEPROC __glewDeleteFencesAPPLE = NULL; -PFNGLFINISHFENCEAPPLEPROC __glewFinishFenceAPPLE = NULL; -PFNGLFINISHOBJECTAPPLEPROC __glewFinishObjectAPPLE = NULL; -PFNGLGENFENCESAPPLEPROC __glewGenFencesAPPLE = NULL; -PFNGLISFENCEAPPLEPROC __glewIsFenceAPPLE = NULL; -PFNGLSETFENCEAPPLEPROC __glewSetFenceAPPLE = NULL; -PFNGLTESTFENCEAPPLEPROC __glewTestFenceAPPLE = NULL; -PFNGLTESTOBJECTAPPLEPROC __glewTestObjectAPPLE = NULL; - -PFNGLBUFFERPARAMETERIAPPLEPROC __glewBufferParameteriAPPLE = NULL; -PFNGLFLUSHMAPPEDBUFFERRANGEAPPLEPROC __glewFlushMappedBufferRangeAPPLE = NULL; - -PFNGLGETTEXPARAMETERPOINTERVAPPLEPROC __glewGetTexParameterPointervAPPLE = NULL; -PFNGLTEXTURERANGEAPPLEPROC __glewTextureRangeAPPLE = NULL; - -PFNGLBINDVERTEXARRAYAPPLEPROC __glewBindVertexArrayAPPLE = NULL; -PFNGLDELETEVERTEXARRAYSAPPLEPROC __glewDeleteVertexArraysAPPLE = NULL; -PFNGLGENVERTEXARRAYSAPPLEPROC __glewGenVertexArraysAPPLE = NULL; -PFNGLISVERTEXARRAYAPPLEPROC __glewIsVertexArrayAPPLE = NULL; - -PFNGLFLUSHVERTEXARRAYRANGEAPPLEPROC __glewFlushVertexArrayRangeAPPLE = NULL; -PFNGLVERTEXARRAYPARAMETERIAPPLEPROC __glewVertexArrayParameteriAPPLE = NULL; -PFNGLVERTEXARRAYRANGEAPPLEPROC __glewVertexArrayRangeAPPLE = NULL; - -PFNGLCLAMPCOLORARBPROC __glewClampColorARB = NULL; - -PFNGLDRAWBUFFERSARBPROC __glewDrawBuffersARB = NULL; - -PFNGLDRAWARRAYSINSTANCEDARBPROC __glewDrawArraysInstancedARB = NULL; -PFNGLDRAWELEMENTSINSTANCEDARBPROC __glewDrawElementsInstancedARB = NULL; - -PFNGLBINDFRAMEBUFFERPROC __glewBindFramebuffer = NULL; -PFNGLBINDRENDERBUFFERPROC __glewBindRenderbuffer = NULL; -PFNGLBLITFRAMEBUFFERPROC __glewBlitFramebuffer = NULL; -PFNGLCHECKFRAMEBUFFERSTATUSPROC __glewCheckFramebufferStatus = NULL; -PFNGLDELETEFRAMEBUFFERSPROC __glewDeleteFramebuffers = NULL; -PFNGLDELETERENDERBUFFERSPROC __glewDeleteRenderbuffers = NULL; -PFNGLFRAMEBUFFERRENDERBUFFERPROC __glewFramebufferRenderbuffer = NULL; -PFNGLFRAMEBUFFERTEXTURLAYERPROC __glewFramebufferTexturLayer = NULL; -PFNGLFRAMEBUFFERTEXTURE1DPROC __glewFramebufferTexture1D = NULL; -PFNGLFRAMEBUFFERTEXTURE2DPROC __glewFramebufferTexture2D = NULL; -PFNGLFRAMEBUFFERTEXTURE3DPROC __glewFramebufferTexture3D = NULL; -PFNGLGENFRAMEBUFFERSPROC __glewGenFramebuffers = NULL; -PFNGLGENRENDERBUFFERSPROC __glewGenRenderbuffers = NULL; -PFNGLGENERATEMIPMAPPROC __glewGenerateMipmap = NULL; -PFNGLGETFRAMEBUFFERATTACHMENTPARAMETERIVPROC __glewGetFramebufferAttachmentParameteriv = NULL; -PFNGLGETRENDERBUFFERPARAMETERIVPROC __glewGetRenderbufferParameteriv = NULL; -PFNGLISFRAMEBUFFERPROC __glewIsFramebuffer = NULL; -PFNGLISRENDERBUFFERPROC __glewIsRenderbuffer = NULL; -PFNGLRENDERBUFFERSTORAGEPROC __glewRenderbufferStorage = NULL; -PFNGLRENDERBUFFERSTORAGEMULTISAMPLEPROC __glewRenderbufferStorageMultisample = NULL; - -PFNGLFRAMEBUFFERTEXTUREARBPROC __glewFramebufferTextureARB = NULL; -PFNGLFRAMEBUFFERTEXTUREFACEARBPROC __glewFramebufferTextureFaceARB = NULL; -PFNGLFRAMEBUFFERTEXTURELAYERARBPROC __glewFramebufferTextureLayerARB = NULL; -PFNGLPROGRAMPARAMETERIARBPROC __glewProgramParameteriARB = NULL; - -PFNGLCOLORSUBTABLEPROC __glewColorSubTable = NULL; -PFNGLCOLORTABLEPROC __glewColorTable = NULL; -PFNGLCOLORTABLEPARAMETERFVPROC __glewColorTableParameterfv = NULL; -PFNGLCOLORTABLEPARAMETERIVPROC __glewColorTableParameteriv = NULL; -PFNGLCONVOLUTIONFILTER1DPROC __glewConvolutionFilter1D = NULL; -PFNGLCONVOLUTIONFILTER2DPROC __glewConvolutionFilter2D = NULL; -PFNGLCONVOLUTIONPARAMETERFPROC __glewConvolutionParameterf = NULL; -PFNGLCONVOLUTIONPARAMETERFVPROC __glewConvolutionParameterfv = NULL; -PFNGLCONVOLUTIONPARAMETERIPROC __glewConvolutionParameteri = NULL; -PFNGLCONVOLUTIONPARAMETERIVPROC __glewConvolutionParameteriv = NULL; -PFNGLCOPYCOLORSUBTABLEPROC __glewCopyColorSubTable = NULL; -PFNGLCOPYCOLORTABLEPROC __glewCopyColorTable = NULL; -PFNGLCOPYCONVOLUTIONFILTER1DPROC __glewCopyConvolutionFilter1D = NULL; -PFNGLCOPYCONVOLUTIONFILTER2DPROC __glewCopyConvolutionFilter2D = NULL; -PFNGLGETCOLORTABLEPROC __glewGetColorTable = NULL; -PFNGLGETCOLORTABLEPARAMETERFVPROC __glewGetColorTableParameterfv = NULL; -PFNGLGETCOLORTABLEPARAMETERIVPROC __glewGetColorTableParameteriv = NULL; -PFNGLGETCONVOLUTIONFILTERPROC __glewGetConvolutionFilter = NULL; -PFNGLGETCONVOLUTIONPARAMETERFVPROC __glewGetConvolutionParameterfv = NULL; -PFNGLGETCONVOLUTIONPARAMETERIVPROC __glewGetConvolutionParameteriv = NULL; -PFNGLGETHISTOGRAMPROC __glewGetHistogram = NULL; -PFNGLGETHISTOGRAMPARAMETERFVPROC __glewGetHistogramParameterfv = NULL; -PFNGLGETHISTOGRAMPARAMETERIVPROC __glewGetHistogramParameteriv = NULL; -PFNGLGETMINMAXPROC __glewGetMinmax = NULL; -PFNGLGETMINMAXPARAMETERFVPROC __glewGetMinmaxParameterfv = NULL; -PFNGLGETMINMAXPARAMETERIVPROC __glewGetMinmaxParameteriv = NULL; -PFNGLGETSEPARABLEFILTERPROC __glewGetSeparableFilter = NULL; -PFNGLHISTOGRAMPROC __glewHistogram = NULL; -PFNGLMINMAXPROC __glewMinmax = NULL; -PFNGLRESETHISTOGRAMPROC __glewResetHistogram = NULL; -PFNGLRESETMINMAXPROC __glewResetMinmax = NULL; -PFNGLSEPARABLEFILTER2DPROC __glewSeparableFilter2D = NULL; - -PFNGLVERTEXATTRIBDIVISORARBPROC __glewVertexAttribDivisorARB = NULL; - -PFNGLFLUSHMAPPEDBUFFERRANGEPROC __glewFlushMappedBufferRange = NULL; -PFNGLMAPBUFFERRANGEPROC __glewMapBufferRange = NULL; - -PFNGLCURRENTPALETTEMATRIXARBPROC __glewCurrentPaletteMatrixARB = NULL; -PFNGLMATRIXINDEXPOINTERARBPROC __glewMatrixIndexPointerARB = NULL; -PFNGLMATRIXINDEXUBVARBPROC __glewMatrixIndexubvARB = NULL; -PFNGLMATRIXINDEXUIVARBPROC __glewMatrixIndexuivARB = NULL; -PFNGLMATRIXINDEXUSVARBPROC __glewMatrixIndexusvARB = NULL; - -PFNGLSAMPLECOVERAGEARBPROC __glewSampleCoverageARB = NULL; - -PFNGLACTIVETEXTUREARBPROC __glewActiveTextureARB = NULL; -PFNGLCLIENTACTIVETEXTUREARBPROC __glewClientActiveTextureARB = NULL; -PFNGLMULTITEXCOORD1DARBPROC __glewMultiTexCoord1dARB = NULL; -PFNGLMULTITEXCOORD1DVARBPROC __glewMultiTexCoord1dvARB = NULL; -PFNGLMULTITEXCOORD1FARBPROC __glewMultiTexCoord1fARB = NULL; -PFNGLMULTITEXCOORD1FVARBPROC __glewMultiTexCoord1fvARB = NULL; -PFNGLMULTITEXCOORD1IARBPROC __glewMultiTexCoord1iARB = NULL; -PFNGLMULTITEXCOORD1IVARBPROC __glewMultiTexCoord1ivARB = NULL; -PFNGLMULTITEXCOORD1SARBPROC __glewMultiTexCoord1sARB = NULL; -PFNGLMULTITEXCOORD1SVARBPROC __glewMultiTexCoord1svARB = NULL; -PFNGLMULTITEXCOORD2DARBPROC __glewMultiTexCoord2dARB = NULL; -PFNGLMULTITEXCOORD2DVARBPROC __glewMultiTexCoord2dvARB = NULL; -PFNGLMULTITEXCOORD2FARBPROC __glewMultiTexCoord2fARB = NULL; -PFNGLMULTITEXCOORD2FVARBPROC __glewMultiTexCoord2fvARB = NULL; -PFNGLMULTITEXCOORD2IARBPROC __glewMultiTexCoord2iARB = NULL; -PFNGLMULTITEXCOORD2IVARBPROC __glewMultiTexCoord2ivARB = NULL; -PFNGLMULTITEXCOORD2SARBPROC __glewMultiTexCoord2sARB = NULL; -PFNGLMULTITEXCOORD2SVARBPROC __glewMultiTexCoord2svARB = NULL; -PFNGLMULTITEXCOORD3DARBPROC __glewMultiTexCoord3dARB = NULL; -PFNGLMULTITEXCOORD3DVARBPROC __glewMultiTexCoord3dvARB = NULL; -PFNGLMULTITEXCOORD3FARBPROC __glewMultiTexCoord3fARB = NULL; -PFNGLMULTITEXCOORD3FVARBPROC __glewMultiTexCoord3fvARB = NULL; -PFNGLMULTITEXCOORD3IARBPROC __glewMultiTexCoord3iARB = NULL; -PFNGLMULTITEXCOORD3IVARBPROC __glewMultiTexCoord3ivARB = NULL; -PFNGLMULTITEXCOORD3SARBPROC __glewMultiTexCoord3sARB = NULL; -PFNGLMULTITEXCOORD3SVARBPROC __glewMultiTexCoord3svARB = NULL; -PFNGLMULTITEXCOORD4DARBPROC __glewMultiTexCoord4dARB = NULL; -PFNGLMULTITEXCOORD4DVARBPROC __glewMultiTexCoord4dvARB = NULL; -PFNGLMULTITEXCOORD4FARBPROC __glewMultiTexCoord4fARB = NULL; -PFNGLMULTITEXCOORD4FVARBPROC __glewMultiTexCoord4fvARB = NULL; -PFNGLMULTITEXCOORD4IARBPROC __glewMultiTexCoord4iARB = NULL; -PFNGLMULTITEXCOORD4IVARBPROC __glewMultiTexCoord4ivARB = NULL; -PFNGLMULTITEXCOORD4SARBPROC __glewMultiTexCoord4sARB = NULL; -PFNGLMULTITEXCOORD4SVARBPROC __glewMultiTexCoord4svARB = NULL; - -PFNGLBEGINQUERYARBPROC __glewBeginQueryARB = NULL; -PFNGLDELETEQUERIESARBPROC __glewDeleteQueriesARB = NULL; -PFNGLENDQUERYARBPROC __glewEndQueryARB = NULL; -PFNGLGENQUERIESARBPROC __glewGenQueriesARB = NULL; -PFNGLGETQUERYOBJECTIVARBPROC __glewGetQueryObjectivARB = NULL; -PFNGLGETQUERYOBJECTUIVARBPROC __glewGetQueryObjectuivARB = NULL; -PFNGLGETQUERYIVARBPROC __glewGetQueryivARB = NULL; -PFNGLISQUERYARBPROC __glewIsQueryARB = NULL; - -PFNGLPOINTPARAMETERFARBPROC __glewPointParameterfARB = NULL; -PFNGLPOINTPARAMETERFVARBPROC __glewPointParameterfvARB = NULL; - -PFNGLATTACHOBJECTARBPROC __glewAttachObjectARB = NULL; -PFNGLCOMPILESHADERARBPROC __glewCompileShaderARB = NULL; -PFNGLCREATEPROGRAMOBJECTARBPROC __glewCreateProgramObjectARB = NULL; -PFNGLCREATESHADEROBJECTARBPROC __glewCreateShaderObjectARB = NULL; -PFNGLDELETEOBJECTARBPROC __glewDeleteObjectARB = NULL; -PFNGLDETACHOBJECTARBPROC __glewDetachObjectARB = NULL; -PFNGLGETACTIVEUNIFORMARBPROC __glewGetActiveUniformARB = NULL; -PFNGLGETATTACHEDOBJECTSARBPROC __glewGetAttachedObjectsARB = NULL; -PFNGLGETHANDLEARBPROC __glewGetHandleARB = NULL; -PFNGLGETINFOLOGARBPROC __glewGetInfoLogARB = NULL; -PFNGLGETOBJECTPARAMETERFVARBPROC __glewGetObjectParameterfvARB = NULL; -PFNGLGETOBJECTPARAMETERIVARBPROC __glewGetObjectParameterivARB = NULL; -PFNGLGETSHADERSOURCEARBPROC __glewGetShaderSourceARB = NULL; -PFNGLGETUNIFORMLOCATIONARBPROC __glewGetUniformLocationARB = NULL; -PFNGLGETUNIFORMFVARBPROC __glewGetUniformfvARB = NULL; -PFNGLGETUNIFORMIVARBPROC __glewGetUniformivARB = NULL; -PFNGLLINKPROGRAMARBPROC __glewLinkProgramARB = NULL; -PFNGLSHADERSOURCEARBPROC __glewShaderSourceARB = NULL; -PFNGLUNIFORM1FARBPROC __glewUniform1fARB = NULL; -PFNGLUNIFORM1FVARBPROC __glewUniform1fvARB = NULL; -PFNGLUNIFORM1IARBPROC __glewUniform1iARB = NULL; -PFNGLUNIFORM1IVARBPROC __glewUniform1ivARB = NULL; -PFNGLUNIFORM2FARBPROC __glewUniform2fARB = NULL; -PFNGLUNIFORM2FVARBPROC __glewUniform2fvARB = NULL; -PFNGLUNIFORM2IARBPROC __glewUniform2iARB = NULL; -PFNGLUNIFORM2IVARBPROC __glewUniform2ivARB = NULL; -PFNGLUNIFORM3FARBPROC __glewUniform3fARB = NULL; -PFNGLUNIFORM3FVARBPROC __glewUniform3fvARB = NULL; -PFNGLUNIFORM3IARBPROC __glewUniform3iARB = NULL; -PFNGLUNIFORM3IVARBPROC __glewUniform3ivARB = NULL; -PFNGLUNIFORM4FARBPROC __glewUniform4fARB = NULL; -PFNGLUNIFORM4FVARBPROC __glewUniform4fvARB = NULL; -PFNGLUNIFORM4IARBPROC __glewUniform4iARB = NULL; -PFNGLUNIFORM4IVARBPROC __glewUniform4ivARB = NULL; -PFNGLUNIFORMMATRIX2FVARBPROC __glewUniformMatrix2fvARB = NULL; -PFNGLUNIFORMMATRIX3FVARBPROC __glewUniformMatrix3fvARB = NULL; -PFNGLUNIFORMMATRIX4FVARBPROC __glewUniformMatrix4fvARB = NULL; -PFNGLUSEPROGRAMOBJECTARBPROC __glewUseProgramObjectARB = NULL; -PFNGLVALIDATEPROGRAMARBPROC __glewValidateProgramARB = NULL; - -PFNGLTEXBUFFERARBPROC __glewTexBufferARB = NULL; - -PFNGLCOMPRESSEDTEXIMAGE1DARBPROC __glewCompressedTexImage1DARB = NULL; -PFNGLCOMPRESSEDTEXIMAGE2DARBPROC __glewCompressedTexImage2DARB = NULL; -PFNGLCOMPRESSEDTEXIMAGE3DARBPROC __glewCompressedTexImage3DARB = NULL; -PFNGLCOMPRESSEDTEXSUBIMAGE1DARBPROC __glewCompressedTexSubImage1DARB = NULL; -PFNGLCOMPRESSEDTEXSUBIMAGE2DARBPROC __glewCompressedTexSubImage2DARB = NULL; -PFNGLCOMPRESSEDTEXSUBIMAGE3DARBPROC __glewCompressedTexSubImage3DARB = NULL; -PFNGLGETCOMPRESSEDTEXIMAGEARBPROC __glewGetCompressedTexImageARB = NULL; - -PFNGLLOADTRANSPOSEMATRIXDARBPROC __glewLoadTransposeMatrixdARB = NULL; -PFNGLLOADTRANSPOSEMATRIXFARBPROC __glewLoadTransposeMatrixfARB = NULL; -PFNGLMULTTRANSPOSEMATRIXDARBPROC __glewMultTransposeMatrixdARB = NULL; -PFNGLMULTTRANSPOSEMATRIXFARBPROC __glewMultTransposeMatrixfARB = NULL; - -PFNGLBINDVERTEXARRAYPROC __glewBindVertexArray = NULL; -PFNGLDELETEVERTEXARRAYSPROC __glewDeleteVertexArrays = NULL; -PFNGLGENVERTEXARRAYSPROC __glewGenVertexArrays = NULL; -PFNGLISVERTEXARRAYPROC __glewIsVertexArray = NULL; - -PFNGLVERTEXBLENDARBPROC __glewVertexBlendARB = NULL; -PFNGLWEIGHTPOINTERARBPROC __glewWeightPointerARB = NULL; -PFNGLWEIGHTBVARBPROC __glewWeightbvARB = NULL; -PFNGLWEIGHTDVARBPROC __glewWeightdvARB = NULL; -PFNGLWEIGHTFVARBPROC __glewWeightfvARB = NULL; -PFNGLWEIGHTIVARBPROC __glewWeightivARB = NULL; -PFNGLWEIGHTSVARBPROC __glewWeightsvARB = NULL; -PFNGLWEIGHTUBVARBPROC __glewWeightubvARB = NULL; -PFNGLWEIGHTUIVARBPROC __glewWeightuivARB = NULL; -PFNGLWEIGHTUSVARBPROC __glewWeightusvARB = NULL; - -PFNGLBINDBUFFERARBPROC __glewBindBufferARB = NULL; -PFNGLBUFFERDATAARBPROC __glewBufferDataARB = NULL; -PFNGLBUFFERSUBDATAARBPROC __glewBufferSubDataARB = NULL; -PFNGLDELETEBUFFERSARBPROC __glewDeleteBuffersARB = NULL; -PFNGLGENBUFFERSARBPROC __glewGenBuffersARB = NULL; -PFNGLGETBUFFERPARAMETERIVARBPROC __glewGetBufferParameterivARB = NULL; -PFNGLGETBUFFERPOINTERVARBPROC __glewGetBufferPointervARB = NULL; -PFNGLGETBUFFERSUBDATAARBPROC __glewGetBufferSubDataARB = NULL; -PFNGLISBUFFERARBPROC __glewIsBufferARB = NULL; -PFNGLMAPBUFFERARBPROC __glewMapBufferARB = NULL; -PFNGLUNMAPBUFFERARBPROC __glewUnmapBufferARB = NULL; - -PFNGLBINDPROGRAMARBPROC __glewBindProgramARB = NULL; -PFNGLDELETEPROGRAMSARBPROC __glewDeleteProgramsARB = NULL; -PFNGLDISABLEVERTEXATTRIBARRAYARBPROC __glewDisableVertexAttribArrayARB = NULL; -PFNGLENABLEVERTEXATTRIBARRAYARBPROC __glewEnableVertexAttribArrayARB = NULL; -PFNGLGENPROGRAMSARBPROC __glewGenProgramsARB = NULL; -PFNGLGETPROGRAMENVPARAMETERDVARBPROC __glewGetProgramEnvParameterdvARB = NULL; -PFNGLGETPROGRAMENVPARAMETERFVARBPROC __glewGetProgramEnvParameterfvARB = NULL; -PFNGLGETPROGRAMLOCALPARAMETERDVARBPROC __glewGetProgramLocalParameterdvARB = NULL; -PFNGLGETPROGRAMLOCALPARAMETERFVARBPROC __glewGetProgramLocalParameterfvARB = NULL; -PFNGLGETPROGRAMSTRINGARBPROC __glewGetProgramStringARB = NULL; -PFNGLGETPROGRAMIVARBPROC __glewGetProgramivARB = NULL; -PFNGLGETVERTEXATTRIBPOINTERVARBPROC __glewGetVertexAttribPointervARB = NULL; -PFNGLGETVERTEXATTRIBDVARBPROC __glewGetVertexAttribdvARB = NULL; -PFNGLGETVERTEXATTRIBFVARBPROC __glewGetVertexAttribfvARB = NULL; -PFNGLGETVERTEXATTRIBIVARBPROC __glewGetVertexAttribivARB = NULL; -PFNGLISPROGRAMARBPROC __glewIsProgramARB = NULL; -PFNGLPROGRAMENVPARAMETER4DARBPROC __glewProgramEnvParameter4dARB = NULL; -PFNGLPROGRAMENVPARAMETER4DVARBPROC __glewProgramEnvParameter4dvARB = NULL; -PFNGLPROGRAMENVPARAMETER4FARBPROC __glewProgramEnvParameter4fARB = NULL; -PFNGLPROGRAMENVPARAMETER4FVARBPROC __glewProgramEnvParameter4fvARB = NULL; -PFNGLPROGRAMLOCALPARAMETER4DARBPROC __glewProgramLocalParameter4dARB = NULL; -PFNGLPROGRAMLOCALPARAMETER4DVARBPROC __glewProgramLocalParameter4dvARB = NULL; -PFNGLPROGRAMLOCALPARAMETER4FARBPROC __glewProgramLocalParameter4fARB = NULL; -PFNGLPROGRAMLOCALPARAMETER4FVARBPROC __glewProgramLocalParameter4fvARB = NULL; -PFNGLPROGRAMSTRINGARBPROC __glewProgramStringARB = NULL; -PFNGLVERTEXATTRIB1DARBPROC __glewVertexAttrib1dARB = NULL; -PFNGLVERTEXATTRIB1DVARBPROC __glewVertexAttrib1dvARB = NULL; -PFNGLVERTEXATTRIB1FARBPROC __glewVertexAttrib1fARB = NULL; -PFNGLVERTEXATTRIB1FVARBPROC __glewVertexAttrib1fvARB = NULL; -PFNGLVERTEXATTRIB1SARBPROC __glewVertexAttrib1sARB = NULL; -PFNGLVERTEXATTRIB1SVARBPROC __glewVertexAttrib1svARB = NULL; -PFNGLVERTEXATTRIB2DARBPROC __glewVertexAttrib2dARB = NULL; -PFNGLVERTEXATTRIB2DVARBPROC __glewVertexAttrib2dvARB = NULL; -PFNGLVERTEXATTRIB2FARBPROC __glewVertexAttrib2fARB = NULL; -PFNGLVERTEXATTRIB2FVARBPROC __glewVertexAttrib2fvARB = NULL; -PFNGLVERTEXATTRIB2SARBPROC __glewVertexAttrib2sARB = NULL; -PFNGLVERTEXATTRIB2SVARBPROC __glewVertexAttrib2svARB = NULL; -PFNGLVERTEXATTRIB3DARBPROC __glewVertexAttrib3dARB = NULL; -PFNGLVERTEXATTRIB3DVARBPROC __glewVertexAttrib3dvARB = NULL; -PFNGLVERTEXATTRIB3FARBPROC __glewVertexAttrib3fARB = NULL; -PFNGLVERTEXATTRIB3FVARBPROC __glewVertexAttrib3fvARB = NULL; -PFNGLVERTEXATTRIB3SARBPROC __glewVertexAttrib3sARB = NULL; -PFNGLVERTEXATTRIB3SVARBPROC __glewVertexAttrib3svARB = NULL; -PFNGLVERTEXATTRIB4NBVARBPROC __glewVertexAttrib4NbvARB = NULL; -PFNGLVERTEXATTRIB4NIVARBPROC __glewVertexAttrib4NivARB = NULL; -PFNGLVERTEXATTRIB4NSVARBPROC __glewVertexAttrib4NsvARB = NULL; -PFNGLVERTEXATTRIB4NUBARBPROC __glewVertexAttrib4NubARB = NULL; -PFNGLVERTEXATTRIB4NUBVARBPROC __glewVertexAttrib4NubvARB = NULL; -PFNGLVERTEXATTRIB4NUIVARBPROC __glewVertexAttrib4NuivARB = NULL; -PFNGLVERTEXATTRIB4NUSVARBPROC __glewVertexAttrib4NusvARB = NULL; -PFNGLVERTEXATTRIB4BVARBPROC __glewVertexAttrib4bvARB = NULL; -PFNGLVERTEXATTRIB4DARBPROC __glewVertexAttrib4dARB = NULL; -PFNGLVERTEXATTRIB4DVARBPROC __glewVertexAttrib4dvARB = NULL; -PFNGLVERTEXATTRIB4FARBPROC __glewVertexAttrib4fARB = NULL; -PFNGLVERTEXATTRIB4FVARBPROC __glewVertexAttrib4fvARB = NULL; -PFNGLVERTEXATTRIB4IVARBPROC __glewVertexAttrib4ivARB = NULL; -PFNGLVERTEXATTRIB4SARBPROC __glewVertexAttrib4sARB = NULL; -PFNGLVERTEXATTRIB4SVARBPROC __glewVertexAttrib4svARB = NULL; -PFNGLVERTEXATTRIB4UBVARBPROC __glewVertexAttrib4ubvARB = NULL; -PFNGLVERTEXATTRIB4UIVARBPROC __glewVertexAttrib4uivARB = NULL; -PFNGLVERTEXATTRIB4USVARBPROC __glewVertexAttrib4usvARB = NULL; -PFNGLVERTEXATTRIBPOINTERARBPROC __glewVertexAttribPointerARB = NULL; - -PFNGLBINDATTRIBLOCATIONARBPROC __glewBindAttribLocationARB = NULL; -PFNGLGETACTIVEATTRIBARBPROC __glewGetActiveAttribARB = NULL; -PFNGLGETATTRIBLOCATIONARBPROC __glewGetAttribLocationARB = NULL; - -PFNGLWINDOWPOS2DARBPROC __glewWindowPos2dARB = NULL; -PFNGLWINDOWPOS2DVARBPROC __glewWindowPos2dvARB = NULL; -PFNGLWINDOWPOS2FARBPROC __glewWindowPos2fARB = NULL; -PFNGLWINDOWPOS2FVARBPROC __glewWindowPos2fvARB = NULL; -PFNGLWINDOWPOS2IARBPROC __glewWindowPos2iARB = NULL; -PFNGLWINDOWPOS2IVARBPROC __glewWindowPos2ivARB = NULL; -PFNGLWINDOWPOS2SARBPROC __glewWindowPos2sARB = NULL; -PFNGLWINDOWPOS2SVARBPROC __glewWindowPos2svARB = NULL; -PFNGLWINDOWPOS3DARBPROC __glewWindowPos3dARB = NULL; -PFNGLWINDOWPOS3DVARBPROC __glewWindowPos3dvARB = NULL; -PFNGLWINDOWPOS3FARBPROC __glewWindowPos3fARB = NULL; -PFNGLWINDOWPOS3FVARBPROC __glewWindowPos3fvARB = NULL; -PFNGLWINDOWPOS3IARBPROC __glewWindowPos3iARB = NULL; -PFNGLWINDOWPOS3IVARBPROC __glewWindowPos3ivARB = NULL; -PFNGLWINDOWPOS3SARBPROC __glewWindowPos3sARB = NULL; -PFNGLWINDOWPOS3SVARBPROC __glewWindowPos3svARB = NULL; - -PFNGLDRAWBUFFERSATIPROC __glewDrawBuffersATI = NULL; - -PFNGLDRAWELEMENTARRAYATIPROC __glewDrawElementArrayATI = NULL; -PFNGLDRAWRANGEELEMENTARRAYATIPROC __glewDrawRangeElementArrayATI = NULL; -PFNGLELEMENTPOINTERATIPROC __glewElementPointerATI = NULL; - -PFNGLGETTEXBUMPPARAMETERFVATIPROC __glewGetTexBumpParameterfvATI = NULL; -PFNGLGETTEXBUMPPARAMETERIVATIPROC __glewGetTexBumpParameterivATI = NULL; -PFNGLTEXBUMPPARAMETERFVATIPROC __glewTexBumpParameterfvATI = NULL; -PFNGLTEXBUMPPARAMETERIVATIPROC __glewTexBumpParameterivATI = NULL; - -PFNGLALPHAFRAGMENTOP1ATIPROC __glewAlphaFragmentOp1ATI = NULL; -PFNGLALPHAFRAGMENTOP2ATIPROC __glewAlphaFragmentOp2ATI = NULL; -PFNGLALPHAFRAGMENTOP3ATIPROC __glewAlphaFragmentOp3ATI = NULL; -PFNGLBEGINFRAGMENTSHADERATIPROC __glewBeginFragmentShaderATI = NULL; -PFNGLBINDFRAGMENTSHADERATIPROC __glewBindFragmentShaderATI = NULL; -PFNGLCOLORFRAGMENTOP1ATIPROC __glewColorFragmentOp1ATI = NULL; -PFNGLCOLORFRAGMENTOP2ATIPROC __glewColorFragmentOp2ATI = NULL; -PFNGLCOLORFRAGMENTOP3ATIPROC __glewColorFragmentOp3ATI = NULL; -PFNGLDELETEFRAGMENTSHADERATIPROC __glewDeleteFragmentShaderATI = NULL; -PFNGLENDFRAGMENTSHADERATIPROC __glewEndFragmentShaderATI = NULL; -PFNGLGENFRAGMENTSHADERSATIPROC __glewGenFragmentShadersATI = NULL; -PFNGLPASSTEXCOORDATIPROC __glewPassTexCoordATI = NULL; -PFNGLSAMPLEMAPATIPROC __glewSampleMapATI = NULL; -PFNGLSETFRAGMENTSHADERCONSTANTATIPROC __glewSetFragmentShaderConstantATI = NULL; - -PFNGLMAPOBJECTBUFFERATIPROC __glewMapObjectBufferATI = NULL; -PFNGLUNMAPOBJECTBUFFERATIPROC __glewUnmapObjectBufferATI = NULL; - -PFNGLPNTRIANGLESFATIPROC __glPNTrianglewesfATI = NULL; -PFNGLPNTRIANGLESIATIPROC __glPNTrianglewesiATI = NULL; - -PFNGLSTENCILFUNCSEPARATEATIPROC __glewStencilFuncSeparateATI = NULL; -PFNGLSTENCILOPSEPARATEATIPROC __glewStencilOpSeparateATI = NULL; - -PFNGLARRAYOBJECTATIPROC __glewArrayObjectATI = NULL; -PFNGLFREEOBJECTBUFFERATIPROC __glewFreeObjectBufferATI = NULL; -PFNGLGETARRAYOBJECTFVATIPROC __glewGetArrayObjectfvATI = NULL; -PFNGLGETARRAYOBJECTIVATIPROC __glewGetArrayObjectivATI = NULL; -PFNGLGETOBJECTBUFFERFVATIPROC __glewGetObjectBufferfvATI = NULL; -PFNGLGETOBJECTBUFFERIVATIPROC __glewGetObjectBufferivATI = NULL; -PFNGLGETVARIANTARRAYOBJECTFVATIPROC __glewGetVariantArrayObjectfvATI = NULL; -PFNGLGETVARIANTARRAYOBJECTIVATIPROC __glewGetVariantArrayObjectivATI = NULL; -PFNGLISOBJECTBUFFERATIPROC __glewIsObjectBufferATI = NULL; -PFNGLNEWOBJECTBUFFERATIPROC __glewNewObjectBufferATI = NULL; -PFNGLUPDATEOBJECTBUFFERATIPROC __glewUpdateObjectBufferATI = NULL; -PFNGLVARIANTARRAYOBJECTATIPROC __glewVariantArrayObjectATI = NULL; - -PFNGLGETVERTEXATTRIBARRAYOBJECTFVATIPROC __glewGetVertexAttribArrayObjectfvATI = NULL; -PFNGLGETVERTEXATTRIBARRAYOBJECTIVATIPROC __glewGetVertexAttribArrayObjectivATI = NULL; -PFNGLVERTEXATTRIBARRAYOBJECTATIPROC __glewVertexAttribArrayObjectATI = NULL; - -PFNGLCLIENTACTIVEVERTEXSTREAMATIPROC __glewClientActiveVertexStreamATI = NULL; -PFNGLNORMALSTREAM3BATIPROC __glewNormalStream3bATI = NULL; -PFNGLNORMALSTREAM3BVATIPROC __glewNormalStream3bvATI = NULL; -PFNGLNORMALSTREAM3DATIPROC __glewNormalStream3dATI = NULL; -PFNGLNORMALSTREAM3DVATIPROC __glewNormalStream3dvATI = NULL; -PFNGLNORMALSTREAM3FATIPROC __glewNormalStream3fATI = NULL; -PFNGLNORMALSTREAM3FVATIPROC __glewNormalStream3fvATI = NULL; -PFNGLNORMALSTREAM3IATIPROC __glewNormalStream3iATI = NULL; -PFNGLNORMALSTREAM3IVATIPROC __glewNormalStream3ivATI = NULL; -PFNGLNORMALSTREAM3SATIPROC __glewNormalStream3sATI = NULL; -PFNGLNORMALSTREAM3SVATIPROC __glewNormalStream3svATI = NULL; -PFNGLVERTEXBLENDENVFATIPROC __glewVertexBlendEnvfATI = NULL; -PFNGLVERTEXBLENDENVIATIPROC __glewVertexBlendEnviATI = NULL; -PFNGLVERTEXSTREAM2DATIPROC __glewVertexStream2dATI = NULL; -PFNGLVERTEXSTREAM2DVATIPROC __glewVertexStream2dvATI = NULL; -PFNGLVERTEXSTREAM2FATIPROC __glewVertexStream2fATI = NULL; -PFNGLVERTEXSTREAM2FVATIPROC __glewVertexStream2fvATI = NULL; -PFNGLVERTEXSTREAM2IATIPROC __glewVertexStream2iATI = NULL; -PFNGLVERTEXSTREAM2IVATIPROC __glewVertexStream2ivATI = NULL; -PFNGLVERTEXSTREAM2SATIPROC __glewVertexStream2sATI = NULL; -PFNGLVERTEXSTREAM2SVATIPROC __glewVertexStream2svATI = NULL; -PFNGLVERTEXSTREAM3DATIPROC __glewVertexStream3dATI = NULL; -PFNGLVERTEXSTREAM3DVATIPROC __glewVertexStream3dvATI = NULL; -PFNGLVERTEXSTREAM3FATIPROC __glewVertexStream3fATI = NULL; -PFNGLVERTEXSTREAM3FVATIPROC __glewVertexStream3fvATI = NULL; -PFNGLVERTEXSTREAM3IATIPROC __glewVertexStream3iATI = NULL; -PFNGLVERTEXSTREAM3IVATIPROC __glewVertexStream3ivATI = NULL; -PFNGLVERTEXSTREAM3SATIPROC __glewVertexStream3sATI = NULL; -PFNGLVERTEXSTREAM3SVATIPROC __glewVertexStream3svATI = NULL; -PFNGLVERTEXSTREAM4DATIPROC __glewVertexStream4dATI = NULL; -PFNGLVERTEXSTREAM4DVATIPROC __glewVertexStream4dvATI = NULL; -PFNGLVERTEXSTREAM4FATIPROC __glewVertexStream4fATI = NULL; -PFNGLVERTEXSTREAM4FVATIPROC __glewVertexStream4fvATI = NULL; -PFNGLVERTEXSTREAM4IATIPROC __glewVertexStream4iATI = NULL; -PFNGLVERTEXSTREAM4IVATIPROC __glewVertexStream4ivATI = NULL; -PFNGLVERTEXSTREAM4SATIPROC __glewVertexStream4sATI = NULL; -PFNGLVERTEXSTREAM4SVATIPROC __glewVertexStream4svATI = NULL; - -PFNGLGETUNIFORMBUFFERSIZEEXTPROC __glewGetUniformBufferSizeEXT = NULL; -PFNGLGETUNIFORMOFFSETEXTPROC __glewGetUniformOffsetEXT = NULL; -PFNGLUNIFORMBUFFEREXTPROC __glewUniformBufferEXT = NULL; - -PFNGLBLENDCOLOREXTPROC __glewBlendColorEXT = NULL; - -PFNGLBLENDEQUATIONSEPARATEEXTPROC __glewBlendEquationSeparateEXT = NULL; - -PFNGLBLENDFUNCSEPARATEEXTPROC __glewBlendFuncSeparateEXT = NULL; - -PFNGLBLENDEQUATIONEXTPROC __glewBlendEquationEXT = NULL; - -PFNGLCOLORSUBTABLEEXTPROC __glewColorSubTableEXT = NULL; -PFNGLCOPYCOLORSUBTABLEEXTPROC __glewCopyColorSubTableEXT = NULL; - -PFNGLLOCKARRAYSEXTPROC __glewLockArraysEXT = NULL; -PFNGLUNLOCKARRAYSEXTPROC __glewUnlockArraysEXT = NULL; - -PFNGLCONVOLUTIONFILTER1DEXTPROC __glewConvolutionFilter1DEXT = NULL; -PFNGLCONVOLUTIONFILTER2DEXTPROC __glewConvolutionFilter2DEXT = NULL; -PFNGLCONVOLUTIONPARAMETERFEXTPROC __glewConvolutionParameterfEXT = NULL; -PFNGLCONVOLUTIONPARAMETERFVEXTPROC __glewConvolutionParameterfvEXT = NULL; -PFNGLCONVOLUTIONPARAMETERIEXTPROC __glewConvolutionParameteriEXT = NULL; -PFNGLCONVOLUTIONPARAMETERIVEXTPROC __glewConvolutionParameterivEXT = NULL; -PFNGLCOPYCONVOLUTIONFILTER1DEXTPROC __glewCopyConvolutionFilter1DEXT = NULL; -PFNGLCOPYCONVOLUTIONFILTER2DEXTPROC __glewCopyConvolutionFilter2DEXT = NULL; -PFNGLGETCONVOLUTIONFILTEREXTPROC __glewGetConvolutionFilterEXT = NULL; -PFNGLGETCONVOLUTIONPARAMETERFVEXTPROC __glewGetConvolutionParameterfvEXT = NULL; -PFNGLGETCONVOLUTIONPARAMETERIVEXTPROC __glewGetConvolutionParameterivEXT = NULL; -PFNGLGETSEPARABLEFILTEREXTPROC __glewGetSeparableFilterEXT = NULL; -PFNGLSEPARABLEFILTER2DEXTPROC __glewSeparableFilter2DEXT = NULL; - -PFNGLBINORMALPOINTEREXTPROC __glewBinormalPointerEXT = NULL; -PFNGLTANGENTPOINTEREXTPROC __glewTangentPointerEXT = NULL; - -PFNGLCOPYTEXIMAGE1DEXTPROC __glewCopyTexImage1DEXT = NULL; -PFNGLCOPYTEXIMAGE2DEXTPROC __glewCopyTexImage2DEXT = NULL; -PFNGLCOPYTEXSUBIMAGE1DEXTPROC __glewCopyTexSubImage1DEXT = NULL; -PFNGLCOPYTEXSUBIMAGE2DEXTPROC __glewCopyTexSubImage2DEXT = NULL; -PFNGLCOPYTEXSUBIMAGE3DEXTPROC __glewCopyTexSubImage3DEXT = NULL; - -PFNGLCULLPARAMETERDVEXTPROC __glewCullParameterdvEXT = NULL; -PFNGLCULLPARAMETERFVEXTPROC __glewCullParameterfvEXT = NULL; - -PFNGLDEPTHBOUNDSEXTPROC __glewDepthBoundsEXT = NULL; - -PFNGLBINDMULTITEXTUREEXTPROC __glewBindMultiTextureEXT = NULL; -PFNGLCHECKNAMEDFRAMEBUFFERSTATUSEXTPROC __glewCheckNamedFramebufferStatusEXT = NULL; -PFNGLCLIENTATTRIBDEFAULTEXTPROC __glewClientAttribDefaultEXT = NULL; -PFNGLCOMPRESSEDMULTITEXIMAGE1DEXTPROC __glewCompressedMultiTexImage1DEXT = NULL; -PFNGLCOMPRESSEDMULTITEXIMAGE2DEXTPROC __glewCompressedMultiTexImage2DEXT = NULL; -PFNGLCOMPRESSEDMULTITEXIMAGE3DEXTPROC __glewCompressedMultiTexImage3DEXT = NULL; -PFNGLCOMPRESSEDMULTITEXSUBIMAGE1DEXTPROC __glewCompressedMultiTexSubImage1DEXT = NULL; -PFNGLCOMPRESSEDMULTITEXSUBIMAGE2DEXTPROC __glewCompressedMultiTexSubImage2DEXT = NULL; -PFNGLCOMPRESSEDMULTITEXSUBIMAGE3DEXTPROC __glewCompressedMultiTexSubImage3DEXT = NULL; -PFNGLCOMPRESSEDTEXTUREIMAGE1DEXTPROC __glewCompressedTextureImage1DEXT = NULL; -PFNGLCOMPRESSEDTEXTUREIMAGE2DEXTPROC __glewCompressedTextureImage2DEXT = NULL; -PFNGLCOMPRESSEDTEXTUREIMAGE3DEXTPROC __glewCompressedTextureImage3DEXT = NULL; -PFNGLCOMPRESSEDTEXTURESUBIMAGE1DEXTPROC __glewCompressedTextureSubImage1DEXT = NULL; -PFNGLCOMPRESSEDTEXTURESUBIMAGE2DEXTPROC __glewCompressedTextureSubImage2DEXT = NULL; -PFNGLCOMPRESSEDTEXTURESUBIMAGE3DEXTPROC __glewCompressedTextureSubImage3DEXT = NULL; -PFNGLCOPYMULTITEXIMAGE1DEXTPROC __glewCopyMultiTexImage1DEXT = NULL; -PFNGLCOPYMULTITEXIMAGE2DEXTPROC __glewCopyMultiTexImage2DEXT = NULL; -PFNGLCOPYMULTITEXSUBIMAGE1DEXTPROC __glewCopyMultiTexSubImage1DEXT = NULL; -PFNGLCOPYMULTITEXSUBIMAGE2DEXTPROC __glewCopyMultiTexSubImage2DEXT = NULL; -PFNGLCOPYMULTITEXSUBIMAGE3DEXTPROC __glewCopyMultiTexSubImage3DEXT = NULL; -PFNGLCOPYTEXTUREIMAGE1DEXTPROC __glewCopyTextureImage1DEXT = NULL; -PFNGLCOPYTEXTUREIMAGE2DEXTPROC __glewCopyTextureImage2DEXT = NULL; -PFNGLCOPYTEXTURESUBIMAGE1DEXTPROC __glewCopyTextureSubImage1DEXT = NULL; -PFNGLCOPYTEXTURESUBIMAGE2DEXTPROC __glewCopyTextureSubImage2DEXT = NULL; -PFNGLCOPYTEXTURESUBIMAGE3DEXTPROC __glewCopyTextureSubImage3DEXT = NULL; -PFNGLDISABLECLIENTSTATEINDEXEDEXTPROC __glewDisableClientStateIndexedEXT = NULL; -PFNGLENABLECLIENTSTATEINDEXEDEXTPROC __glewEnableClientStateIndexedEXT = NULL; -PFNGLFRAMEBUFFERDRAWBUFFEREXTPROC __glewFramebufferDrawBufferEXT = NULL; -PFNGLFRAMEBUFFERDRAWBUFFERSEXTPROC __glewFramebufferDrawBuffersEXT = NULL; -PFNGLFRAMEBUFFERREADBUFFEREXTPROC __glewFramebufferReadBufferEXT = NULL; -PFNGLGENERATEMULTITEXMIPMAPEXTPROC __glewGenerateMultiTexMipmapEXT = NULL; -PFNGLGENERATETEXTUREMIPMAPEXTPROC __glewGenerateTextureMipmapEXT = NULL; -PFNGLGETCOMPRESSEDMULTITEXIMAGEEXTPROC __glewGetCompressedMultiTexImageEXT = NULL; -PFNGLGETCOMPRESSEDTEXTUREIMAGEEXTPROC __glewGetCompressedTextureImageEXT = NULL; -PFNGLGETDOUBLEINDEXEDVEXTPROC __glewGetDoubleIndexedvEXT = NULL; -PFNGLGETFLOATINDEXEDVEXTPROC __glewGetFloatIndexedvEXT = NULL; -PFNGLGETFRAMEBUFFERPARAMETERIVEXTPROC __glewGetFramebufferParameterivEXT = NULL; -PFNGLGETMULTITEXENVFVEXTPROC __glewGetMultiTexEnvfvEXT = NULL; -PFNGLGETMULTITEXENVIVEXTPROC __glewGetMultiTexEnvivEXT = NULL; -PFNGLGETMULTITEXGENDVEXTPROC __glewGetMultiTexGendvEXT = NULL; -PFNGLGETMULTITEXGENFVEXTPROC __glewGetMultiTexGenfvEXT = NULL; -PFNGLGETMULTITEXGENIVEXTPROC __glewGetMultiTexGenivEXT = NULL; -PFNGLGETMULTITEXIMAGEEXTPROC __glewGetMultiTexImageEXT = NULL; -PFNGLGETMULTITEXLEVELPARAMETERFVEXTPROC __glewGetMultiTexLevelParameterfvEXT = NULL; -PFNGLGETMULTITEXLEVELPARAMETERIVEXTPROC __glewGetMultiTexLevelParameterivEXT = NULL; -PFNGLGETMULTITEXPARAMETERIIVEXTPROC __glewGetMultiTexParameterIivEXT = NULL; -PFNGLGETMULTITEXPARAMETERIUIVEXTPROC __glewGetMultiTexParameterIuivEXT = NULL; -PFNGLGETMULTITEXPARAMETERFVEXTPROC __glewGetMultiTexParameterfvEXT = NULL; -PFNGLGETMULTITEXPARAMETERIVEXTPROC __glewGetMultiTexParameterivEXT = NULL; -PFNGLGETNAMEDBUFFERPARAMETERIVEXTPROC __glewGetNamedBufferParameterivEXT = NULL; -PFNGLGETNAMEDBUFFERPOINTERVEXTPROC __glewGetNamedBufferPointervEXT = NULL; -PFNGLGETNAMEDBUFFERSUBDATAEXTPROC __glewGetNamedBufferSubDataEXT = NULL; -PFNGLGETNAMEDFRAMEBUFFERATTACHMENTPARAMETERIVEXTPROC __glewGetNamedFramebufferAttachmentParameterivEXT = NULL; -PFNGLGETNAMEDPROGRAMLOCALPARAMETERIIVEXTPROC __glewGetNamedProgramLocalParameterIivEXT = NULL; -PFNGLGETNAMEDPROGRAMLOCALPARAMETERIUIVEXTPROC __glewGetNamedProgramLocalParameterIuivEXT = NULL; -PFNGLGETNAMEDPROGRAMLOCALPARAMETERDVEXTPROC __glewGetNamedProgramLocalParameterdvEXT = NULL; -PFNGLGETNAMEDPROGRAMLOCALPARAMETERFVEXTPROC __glewGetNamedProgramLocalParameterfvEXT = NULL; -PFNGLGETNAMEDPROGRAMSTRINGEXTPROC __glewGetNamedProgramStringEXT = NULL; -PFNGLGETNAMEDPROGRAMIVEXTPROC __glewGetNamedProgramivEXT = NULL; -PFNGLGETNAMEDRENDERBUFFERPARAMETERIVEXTPROC __glewGetNamedRenderbufferParameterivEXT = NULL; -PFNGLGETPOINTERINDEXEDVEXTPROC __glewGetPointerIndexedvEXT = NULL; -PFNGLGETTEXTUREIMAGEEXTPROC __glewGetTextureImageEXT = NULL; -PFNGLGETTEXTURELEVELPARAMETERFVEXTPROC __glewGetTextureLevelParameterfvEXT = NULL; -PFNGLGETTEXTURELEVELPARAMETERIVEXTPROC __glewGetTextureLevelParameterivEXT = NULL; -PFNGLGETTEXTUREPARAMETERIIVEXTPROC __glewGetTextureParameterIivEXT = NULL; -PFNGLGETTEXTUREPARAMETERIUIVEXTPROC __glewGetTextureParameterIuivEXT = NULL; -PFNGLGETTEXTUREPARAMETERFVEXTPROC __glewGetTextureParameterfvEXT = NULL; -PFNGLGETTEXTUREPARAMETERIVEXTPROC __glewGetTextureParameterivEXT = NULL; -PFNGLMAPNAMEDBUFFEREXTPROC __glewMapNamedBufferEXT = NULL; -PFNGLMATRIXFRUSTUMEXTPROC __glewMatrixFrustumEXT = NULL; -PFNGLMATRIXLOADIDENTITYEXTPROC __glewMatrixLoadIdentityEXT = NULL; -PFNGLMATRIXLOADTRANSPOSEDEXTPROC __glewMatrixLoadTransposedEXT = NULL; -PFNGLMATRIXLOADTRANSPOSEFEXTPROC __glewMatrixLoadTransposefEXT = NULL; -PFNGLMATRIXLOADDEXTPROC __glewMatrixLoaddEXT = NULL; -PFNGLMATRIXLOADFEXTPROC __glewMatrixLoadfEXT = NULL; -PFNGLMATRIXMULTTRANSPOSEDEXTPROC __glewMatrixMultTransposedEXT = NULL; -PFNGLMATRIXMULTTRANSPOSEFEXTPROC __glewMatrixMultTransposefEXT = NULL; -PFNGLMATRIXMULTDEXTPROC __glewMatrixMultdEXT = NULL; -PFNGLMATRIXMULTFEXTPROC __glewMatrixMultfEXT = NULL; -PFNGLMATRIXORTHOEXTPROC __glewMatrixOrthoEXT = NULL; -PFNGLMATRIXPOPEXTPROC __glewMatrixPopEXT = NULL; -PFNGLMATRIXPUSHEXTPROC __glewMatrixPushEXT = NULL; -PFNGLMATRIXROTATEDEXTPROC __glewMatrixRotatedEXT = NULL; -PFNGLMATRIXROTATEFEXTPROC __glewMatrixRotatefEXT = NULL; -PFNGLMATRIXSCALEDEXTPROC __glewMatrixScaledEXT = NULL; -PFNGLMATRIXSCALEFEXTPROC __glewMatrixScalefEXT = NULL; -PFNGLMATRIXTRANSLATEDEXTPROC __glewMatrixTranslatedEXT = NULL; -PFNGLMATRIXTRANSLATEFEXTPROC __glewMatrixTranslatefEXT = NULL; -PFNGLMULTITEXBUFFEREXTPROC __glewMultiTexBufferEXT = NULL; -PFNGLMULTITEXCOORDPOINTEREXTPROC __glewMultiTexCoordPointerEXT = NULL; -PFNGLMULTITEXENVFEXTPROC __glewMultiTexEnvfEXT = NULL; -PFNGLMULTITEXENVFVEXTPROC __glewMultiTexEnvfvEXT = NULL; -PFNGLMULTITEXENVIEXTPROC __glewMultiTexEnviEXT = NULL; -PFNGLMULTITEXENVIVEXTPROC __glewMultiTexEnvivEXT = NULL; -PFNGLMULTITEXGENDEXTPROC __glewMultiTexGendEXT = NULL; -PFNGLMULTITEXGENDVEXTPROC __glewMultiTexGendvEXT = NULL; -PFNGLMULTITEXGENFEXTPROC __glewMultiTexGenfEXT = NULL; -PFNGLMULTITEXGENFVEXTPROC __glewMultiTexGenfvEXT = NULL; -PFNGLMULTITEXGENIEXTPROC __glewMultiTexGeniEXT = NULL; -PFNGLMULTITEXGENIVEXTPROC __glewMultiTexGenivEXT = NULL; -PFNGLMULTITEXIMAGE1DEXTPROC __glewMultiTexImage1DEXT = NULL; -PFNGLMULTITEXIMAGE2DEXTPROC __glewMultiTexImage2DEXT = NULL; -PFNGLMULTITEXIMAGE3DEXTPROC __glewMultiTexImage3DEXT = NULL; -PFNGLMULTITEXPARAMETERIIVEXTPROC __glewMultiTexParameterIivEXT = NULL; -PFNGLMULTITEXPARAMETERIUIVEXTPROC __glewMultiTexParameterIuivEXT = NULL; -PFNGLMULTITEXPARAMETERFEXTPROC __glewMultiTexParameterfEXT = NULL; -PFNGLMULTITEXPARAMETERFVEXTPROC __glewMultiTexParameterfvEXT = NULL; -PFNGLMULTITEXPARAMETERIEXTPROC __glewMultiTexParameteriEXT = NULL; -PFNGLMULTITEXPARAMETERIVEXTPROC __glewMultiTexParameterivEXT = NULL; -PFNGLMULTITEXRENDERBUFFEREXTPROC __glewMultiTexRenderbufferEXT = NULL; -PFNGLMULTITEXSUBIMAGE1DEXTPROC __glewMultiTexSubImage1DEXT = NULL; -PFNGLMULTITEXSUBIMAGE2DEXTPROC __glewMultiTexSubImage2DEXT = NULL; -PFNGLMULTITEXSUBIMAGE3DEXTPROC __glewMultiTexSubImage3DEXT = NULL; -PFNGLNAMEDBUFFERDATAEXTPROC __glewNamedBufferDataEXT = NULL; -PFNGLNAMEDBUFFERSUBDATAEXTPROC __glewNamedBufferSubDataEXT = NULL; -PFNGLNAMEDFRAMEBUFFERRENDERBUFFEREXTPROC __glewNamedFramebufferRenderbufferEXT = NULL; -PFNGLNAMEDFRAMEBUFFERTEXTURE1DEXTPROC __glewNamedFramebufferTexture1DEXT = NULL; -PFNGLNAMEDFRAMEBUFFERTEXTURE2DEXTPROC __glewNamedFramebufferTexture2DEXT = NULL; -PFNGLNAMEDFRAMEBUFFERTEXTURE3DEXTPROC __glewNamedFramebufferTexture3DEXT = NULL; -PFNGLNAMEDFRAMEBUFFERTEXTUREEXTPROC __glewNamedFramebufferTextureEXT = NULL; -PFNGLNAMEDFRAMEBUFFERTEXTUREFACEEXTPROC __glewNamedFramebufferTextureFaceEXT = NULL; -PFNGLNAMEDFRAMEBUFFERTEXTURELAYEREXTPROC __glewNamedFramebufferTextureLayerEXT = NULL; -PFNGLNAMEDPROGRAMLOCALPARAMETER4DEXTPROC __glewNamedProgramLocalParameter4dEXT = NULL; -PFNGLNAMEDPROGRAMLOCALPARAMETER4DVEXTPROC __glewNamedProgramLocalParameter4dvEXT = NULL; -PFNGLNAMEDPROGRAMLOCALPARAMETER4FEXTPROC __glewNamedProgramLocalParameter4fEXT = NULL; -PFNGLNAMEDPROGRAMLOCALPARAMETER4FVEXTPROC __glewNamedProgramLocalParameter4fvEXT = NULL; -PFNGLNAMEDPROGRAMLOCALPARAMETERI4IEXTPROC __glewNamedProgramLocalParameterI4iEXT = NULL; -PFNGLNAMEDPROGRAMLOCALPARAMETERI4IVEXTPROC __glewNamedProgramLocalParameterI4ivEXT = NULL; -PFNGLNAMEDPROGRAMLOCALPARAMETERI4UIEXTPROC __glewNamedProgramLocalParameterI4uiEXT = NULL; -PFNGLNAMEDPROGRAMLOCALPARAMETERI4UIVEXTPROC __glewNamedProgramLocalParameterI4uivEXT = NULL; -PFNGLNAMEDPROGRAMLOCALPARAMETERS4FVEXTPROC __glewNamedProgramLocalParameters4fvEXT = NULL; -PFNGLNAMEDPROGRAMLOCALPARAMETERSI4IVEXTPROC __glewNamedProgramLocalParametersI4ivEXT = NULL; -PFNGLNAMEDPROGRAMLOCALPARAMETERSI4UIVEXTPROC __glewNamedProgramLocalParametersI4uivEXT = NULL; -PFNGLNAMEDPROGRAMSTRINGEXTPROC __glewNamedProgramStringEXT = NULL; -PFNGLNAMEDRENDERBUFFERSTORAGEEXTPROC __glewNamedRenderbufferStorageEXT = NULL; -PFNGLNAMEDRENDERBUFFERSTORAGEMULTISAMPLECOVERAGEEXTPROC __glewNamedRenderbufferStorageMultisampleCoverageEXT = NULL; -PFNGLNAMEDRENDERBUFFERSTORAGEMULTISAMPLEEXTPROC __glewNamedRenderbufferStorageMultisampleEXT = NULL; -PFNGLPROGRAMUNIFORM1FEXTPROC __glewProgramUniform1fEXT = NULL; -PFNGLPROGRAMUNIFORM1FVEXTPROC __glewProgramUniform1fvEXT = NULL; -PFNGLPROGRAMUNIFORM1IEXTPROC __glewProgramUniform1iEXT = NULL; -PFNGLPROGRAMUNIFORM1IVEXTPROC __glewProgramUniform1ivEXT = NULL; -PFNGLPROGRAMUNIFORM1UIEXTPROC __glewProgramUniform1uiEXT = NULL; -PFNGLPROGRAMUNIFORM1UIVEXTPROC __glewProgramUniform1uivEXT = NULL; -PFNGLPROGRAMUNIFORM2FEXTPROC __glewProgramUniform2fEXT = NULL; -PFNGLPROGRAMUNIFORM2FVEXTPROC __glewProgramUniform2fvEXT = NULL; -PFNGLPROGRAMUNIFORM2IEXTPROC __glewProgramUniform2iEXT = NULL; -PFNGLPROGRAMUNIFORM2IVEXTPROC __glewProgramUniform2ivEXT = NULL; -PFNGLPROGRAMUNIFORM2UIEXTPROC __glewProgramUniform2uiEXT = NULL; -PFNGLPROGRAMUNIFORM2UIVEXTPROC __glewProgramUniform2uivEXT = NULL; -PFNGLPROGRAMUNIFORM3FEXTPROC __glewProgramUniform3fEXT = NULL; -PFNGLPROGRAMUNIFORM3FVEXTPROC __glewProgramUniform3fvEXT = NULL; -PFNGLPROGRAMUNIFORM3IEXTPROC __glewProgramUniform3iEXT = NULL; -PFNGLPROGRAMUNIFORM3IVEXTPROC __glewProgramUniform3ivEXT = NULL; -PFNGLPROGRAMUNIFORM3UIEXTPROC __glewProgramUniform3uiEXT = NULL; -PFNGLPROGRAMUNIFORM3UIVEXTPROC __glewProgramUniform3uivEXT = NULL; -PFNGLPROGRAMUNIFORM4FEXTPROC __glewProgramUniform4fEXT = NULL; -PFNGLPROGRAMUNIFORM4FVEXTPROC __glewProgramUniform4fvEXT = NULL; -PFNGLPROGRAMUNIFORM4IEXTPROC __glewProgramUniform4iEXT = NULL; -PFNGLPROGRAMUNIFORM4IVEXTPROC __glewProgramUniform4ivEXT = NULL; -PFNGLPROGRAMUNIFORM4UIEXTPROC __glewProgramUniform4uiEXT = NULL; -PFNGLPROGRAMUNIFORM4UIVEXTPROC __glewProgramUniform4uivEXT = NULL; -PFNGLPROGRAMUNIFORMMATRIX2FVEXTPROC __glewProgramUniformMatrix2fvEXT = NULL; -PFNGLPROGRAMUNIFORMMATRIX2X3FVEXTPROC __glewProgramUniformMatrix2x3fvEXT = NULL; -PFNGLPROGRAMUNIFORMMATRIX2X4FVEXTPROC __glewProgramUniformMatrix2x4fvEXT = NULL; -PFNGLPROGRAMUNIFORMMATRIX3FVEXTPROC __glewProgramUniformMatrix3fvEXT = NULL; -PFNGLPROGRAMUNIFORMMATRIX3X2FVEXTPROC __glewProgramUniformMatrix3x2fvEXT = NULL; -PFNGLPROGRAMUNIFORMMATRIX3X4FVEXTPROC __glewProgramUniformMatrix3x4fvEXT = NULL; -PFNGLPROGRAMUNIFORMMATRIX4FVEXTPROC __glewProgramUniformMatrix4fvEXT = NULL; -PFNGLPROGRAMUNIFORMMATRIX4X2FVEXTPROC __glewProgramUniformMatrix4x2fvEXT = NULL; -PFNGLPROGRAMUNIFORMMATRIX4X3FVEXTPROC __glewProgramUniformMatrix4x3fvEXT = NULL; -PFNGLPUSHCLIENTATTRIBDEFAULTEXTPROC __glewPushClientAttribDefaultEXT = NULL; -PFNGLTEXTUREBUFFEREXTPROC __glewTextureBufferEXT = NULL; -PFNGLTEXTUREIMAGE1DEXTPROC __glewTextureImage1DEXT = NULL; -PFNGLTEXTUREIMAGE2DEXTPROC __glewTextureImage2DEXT = NULL; -PFNGLTEXTUREIMAGE3DEXTPROC __glewTextureImage3DEXT = NULL; -PFNGLTEXTUREPARAMETERIIVEXTPROC __glewTextureParameterIivEXT = NULL; -PFNGLTEXTUREPARAMETERIUIVEXTPROC __glewTextureParameterIuivEXT = NULL; -PFNGLTEXTUREPARAMETERFEXTPROC __glewTextureParameterfEXT = NULL; -PFNGLTEXTUREPARAMETERFVEXTPROC __glewTextureParameterfvEXT = NULL; -PFNGLTEXTUREPARAMETERIEXTPROC __glewTextureParameteriEXT = NULL; -PFNGLTEXTUREPARAMETERIVEXTPROC __glewTextureParameterivEXT = NULL; -PFNGLTEXTURERENDERBUFFEREXTPROC __glewTextureRenderbufferEXT = NULL; -PFNGLTEXTURESUBIMAGE1DEXTPROC __glewTextureSubImage1DEXT = NULL; -PFNGLTEXTURESUBIMAGE2DEXTPROC __glewTextureSubImage2DEXT = NULL; -PFNGLTEXTURESUBIMAGE3DEXTPROC __glewTextureSubImage3DEXT = NULL; -PFNGLUNMAPNAMEDBUFFEREXTPROC __glewUnmapNamedBufferEXT = NULL; - -PFNGLCOLORMASKINDEXEDEXTPROC __glewColorMaskIndexedEXT = NULL; -PFNGLDISABLEINDEXEDEXTPROC __glewDisableIndexedEXT = NULL; -PFNGLENABLEINDEXEDEXTPROC __glewEnableIndexedEXT = NULL; -PFNGLGETBOOLEANINDEXEDVEXTPROC __glewGetBooleanIndexedvEXT = NULL; -PFNGLGETINTEGERINDEXEDVEXTPROC __glewGetIntegerIndexedvEXT = NULL; -PFNGLISENABLEDINDEXEDEXTPROC __glewIsEnabledIndexedEXT = NULL; - -PFNGLDRAWARRAYSINSTANCEDEXTPROC __glewDrawArraysInstancedEXT = NULL; -PFNGLDRAWELEMENTSINSTANCEDEXTPROC __glewDrawElementsInstancedEXT = NULL; - -PFNGLDRAWRANGEELEMENTSEXTPROC __glewDrawRangeElementsEXT = NULL; - -PFNGLFOGCOORDPOINTEREXTPROC __glewFogCoordPointerEXT = NULL; -PFNGLFOGCOORDDEXTPROC __glewFogCoorddEXT = NULL; -PFNGLFOGCOORDDVEXTPROC __glewFogCoorddvEXT = NULL; -PFNGLFOGCOORDFEXTPROC __glewFogCoordfEXT = NULL; -PFNGLFOGCOORDFVEXTPROC __glewFogCoordfvEXT = NULL; - -PFNGLFRAGMENTCOLORMATERIALEXTPROC __glewFragmentColorMaterialEXT = NULL; -PFNGLFRAGMENTLIGHTMODELFEXTPROC __glewFragmentLightModelfEXT = NULL; -PFNGLFRAGMENTLIGHTMODELFVEXTPROC __glewFragmentLightModelfvEXT = NULL; -PFNGLFRAGMENTLIGHTMODELIEXTPROC __glewFragmentLightModeliEXT = NULL; -PFNGLFRAGMENTLIGHTMODELIVEXTPROC __glewFragmentLightModelivEXT = NULL; -PFNGLFRAGMENTLIGHTFEXTPROC __glewFragmentLightfEXT = NULL; -PFNGLFRAGMENTLIGHTFVEXTPROC __glewFragmentLightfvEXT = NULL; -PFNGLFRAGMENTLIGHTIEXTPROC __glewFragmentLightiEXT = NULL; -PFNGLFRAGMENTLIGHTIVEXTPROC __glewFragmentLightivEXT = NULL; -PFNGLFRAGMENTMATERIALFEXTPROC __glewFragmentMaterialfEXT = NULL; -PFNGLFRAGMENTMATERIALFVEXTPROC __glewFragmentMaterialfvEXT = NULL; -PFNGLFRAGMENTMATERIALIEXTPROC __glewFragmentMaterialiEXT = NULL; -PFNGLFRAGMENTMATERIALIVEXTPROC __glewFragmentMaterialivEXT = NULL; -PFNGLGETFRAGMENTLIGHTFVEXTPROC __glewGetFragmentLightfvEXT = NULL; -PFNGLGETFRAGMENTLIGHTIVEXTPROC __glewGetFragmentLightivEXT = NULL; -PFNGLGETFRAGMENTMATERIALFVEXTPROC __glewGetFragmentMaterialfvEXT = NULL; -PFNGLGETFRAGMENTMATERIALIVEXTPROC __glewGetFragmentMaterialivEXT = NULL; -PFNGLLIGHTENVIEXTPROC __glewLightEnviEXT = NULL; - -PFNGLBLITFRAMEBUFFEREXTPROC __glewBlitFramebufferEXT = NULL; - -PFNGLRENDERBUFFERSTORAGEMULTISAMPLEEXTPROC __glewRenderbufferStorageMultisampleEXT = NULL; - -PFNGLBINDFRAMEBUFFEREXTPROC __glewBindFramebufferEXT = NULL; -PFNGLBINDRENDERBUFFEREXTPROC __glewBindRenderbufferEXT = NULL; -PFNGLCHECKFRAMEBUFFERSTATUSEXTPROC __glewCheckFramebufferStatusEXT = NULL; -PFNGLDELETEFRAMEBUFFERSEXTPROC __glewDeleteFramebuffersEXT = NULL; -PFNGLDELETERENDERBUFFERSEXTPROC __glewDeleteRenderbuffersEXT = NULL; -PFNGLFRAMEBUFFERRENDERBUFFEREXTPROC __glewFramebufferRenderbufferEXT = NULL; -PFNGLFRAMEBUFFERTEXTURE1DEXTPROC __glewFramebufferTexture1DEXT = NULL; -PFNGLFRAMEBUFFERTEXTURE2DEXTPROC __glewFramebufferTexture2DEXT = NULL; -PFNGLFRAMEBUFFERTEXTURE3DEXTPROC __glewFramebufferTexture3DEXT = NULL; -PFNGLGENFRAMEBUFFERSEXTPROC __glewGenFramebuffersEXT = NULL; -PFNGLGENRENDERBUFFERSEXTPROC __glewGenRenderbuffersEXT = NULL; -PFNGLGENERATEMIPMAPEXTPROC __glewGenerateMipmapEXT = NULL; -PFNGLGETFRAMEBUFFERATTACHMENTPARAMETERIVEXTPROC __glewGetFramebufferAttachmentParameterivEXT = NULL; -PFNGLGETRENDERBUFFERPARAMETERIVEXTPROC __glewGetRenderbufferParameterivEXT = NULL; -PFNGLISFRAMEBUFFEREXTPROC __glewIsFramebufferEXT = NULL; -PFNGLISRENDERBUFFEREXTPROC __glewIsRenderbufferEXT = NULL; -PFNGLRENDERBUFFERSTORAGEEXTPROC __glewRenderbufferStorageEXT = NULL; - -PFNGLFRAMEBUFFERTEXTUREEXTPROC __glewFramebufferTextureEXT = NULL; -PFNGLFRAMEBUFFERTEXTUREFACEEXTPROC __glewFramebufferTextureFaceEXT = NULL; -PFNGLFRAMEBUFFERTEXTURELAYEREXTPROC __glewFramebufferTextureLayerEXT = NULL; -PFNGLPROGRAMPARAMETERIEXTPROC __glewProgramParameteriEXT = NULL; - -PFNGLPROGRAMENVPARAMETERS4FVEXTPROC __glewProgramEnvParameters4fvEXT = NULL; -PFNGLPROGRAMLOCALPARAMETERS4FVEXTPROC __glewProgramLocalParameters4fvEXT = NULL; - -PFNGLBINDFRAGDATALOCATIONEXTPROC __glewBindFragDataLocationEXT = NULL; -PFNGLGETFRAGDATALOCATIONEXTPROC __glewGetFragDataLocationEXT = NULL; -PFNGLGETUNIFORMUIVEXTPROC __glewGetUniformuivEXT = NULL; -PFNGLGETVERTEXATTRIBIIVEXTPROC __glewGetVertexAttribIivEXT = NULL; -PFNGLGETVERTEXATTRIBIUIVEXTPROC __glewGetVertexAttribIuivEXT = NULL; -PFNGLUNIFORM1UIEXTPROC __glewUniform1uiEXT = NULL; -PFNGLUNIFORM1UIVEXTPROC __glewUniform1uivEXT = NULL; -PFNGLUNIFORM2UIEXTPROC __glewUniform2uiEXT = NULL; -PFNGLUNIFORM2UIVEXTPROC __glewUniform2uivEXT = NULL; -PFNGLUNIFORM3UIEXTPROC __glewUniform3uiEXT = NULL; -PFNGLUNIFORM3UIVEXTPROC __glewUniform3uivEXT = NULL; -PFNGLUNIFORM4UIEXTPROC __glewUniform4uiEXT = NULL; -PFNGLUNIFORM4UIVEXTPROC __glewUniform4uivEXT = NULL; -PFNGLVERTEXATTRIBI1IEXTPROC __glewVertexAttribI1iEXT = NULL; -PFNGLVERTEXATTRIBI1IVEXTPROC __glewVertexAttribI1ivEXT = NULL; -PFNGLVERTEXATTRIBI1UIEXTPROC __glewVertexAttribI1uiEXT = NULL; -PFNGLVERTEXATTRIBI1UIVEXTPROC __glewVertexAttribI1uivEXT = NULL; -PFNGLVERTEXATTRIBI2IEXTPROC __glewVertexAttribI2iEXT = NULL; -PFNGLVERTEXATTRIBI2IVEXTPROC __glewVertexAttribI2ivEXT = NULL; -PFNGLVERTEXATTRIBI2UIEXTPROC __glewVertexAttribI2uiEXT = NULL; -PFNGLVERTEXATTRIBI2UIVEXTPROC __glewVertexAttribI2uivEXT = NULL; -PFNGLVERTEXATTRIBI3IEXTPROC __glewVertexAttribI3iEXT = NULL; -PFNGLVERTEXATTRIBI3IVEXTPROC __glewVertexAttribI3ivEXT = NULL; -PFNGLVERTEXATTRIBI3UIEXTPROC __glewVertexAttribI3uiEXT = NULL; -PFNGLVERTEXATTRIBI3UIVEXTPROC __glewVertexAttribI3uivEXT = NULL; -PFNGLVERTEXATTRIBI4BVEXTPROC __glewVertexAttribI4bvEXT = NULL; -PFNGLVERTEXATTRIBI4IEXTPROC __glewVertexAttribI4iEXT = NULL; -PFNGLVERTEXATTRIBI4IVEXTPROC __glewVertexAttribI4ivEXT = NULL; -PFNGLVERTEXATTRIBI4SVEXTPROC __glewVertexAttribI4svEXT = NULL; -PFNGLVERTEXATTRIBI4UBVEXTPROC __glewVertexAttribI4ubvEXT = NULL; -PFNGLVERTEXATTRIBI4UIEXTPROC __glewVertexAttribI4uiEXT = NULL; -PFNGLVERTEXATTRIBI4UIVEXTPROC __glewVertexAttribI4uivEXT = NULL; -PFNGLVERTEXATTRIBI4USVEXTPROC __glewVertexAttribI4usvEXT = NULL; -PFNGLVERTEXATTRIBIPOINTEREXTPROC __glewVertexAttribIPointerEXT = NULL; - -PFNGLGETHISTOGRAMEXTPROC __glewGetHistogramEXT = NULL; -PFNGLGETHISTOGRAMPARAMETERFVEXTPROC __glewGetHistogramParameterfvEXT = NULL; -PFNGLGETHISTOGRAMPARAMETERIVEXTPROC __glewGetHistogramParameterivEXT = NULL; -PFNGLGETMINMAXEXTPROC __glewGetMinmaxEXT = NULL; -PFNGLGETMINMAXPARAMETERFVEXTPROC __glewGetMinmaxParameterfvEXT = NULL; -PFNGLGETMINMAXPARAMETERIVEXTPROC __glewGetMinmaxParameterivEXT = NULL; -PFNGLHISTOGRAMEXTPROC __glewHistogramEXT = NULL; -PFNGLMINMAXEXTPROC __glewMinmaxEXT = NULL; -PFNGLRESETHISTOGRAMEXTPROC __glewResetHistogramEXT = NULL; -PFNGLRESETMINMAXEXTPROC __glewResetMinmaxEXT = NULL; - -PFNGLINDEXFUNCEXTPROC __glewIndexFuncEXT = NULL; - -PFNGLINDEXMATERIALEXTPROC __glewIndexMaterialEXT = NULL; - -PFNGLAPPLYTEXTUREEXTPROC __glewApplyTextureEXT = NULL; -PFNGLTEXTURELIGHTEXTPROC __glewTextureLightEXT = NULL; -PFNGLTEXTUREMATERIALEXTPROC __glewTextureMaterialEXT = NULL; - -PFNGLMULTIDRAWARRAYSEXTPROC __glewMultiDrawArraysEXT = NULL; -PFNGLMULTIDRAWELEMENTSEXTPROC __glewMultiDrawElementsEXT = NULL; - -PFNGLSAMPLEMASKEXTPROC __glewSampleMaskEXT = NULL; -PFNGLSAMPLEPATTERNEXTPROC __glewSamplePatternEXT = NULL; - -PFNGLCOLORTABLEEXTPROC __glewColorTableEXT = NULL; -PFNGLGETCOLORTABLEEXTPROC __glewGetColorTableEXT = NULL; -PFNGLGETCOLORTABLEPARAMETERFVEXTPROC __glewGetColorTableParameterfvEXT = NULL; -PFNGLGETCOLORTABLEPARAMETERIVEXTPROC __glewGetColorTableParameterivEXT = NULL; - -PFNGLGETPIXELTRANSFORMPARAMETERFVEXTPROC __glewGetPixelTransformParameterfvEXT = NULL; -PFNGLGETPIXELTRANSFORMPARAMETERIVEXTPROC __glewGetPixelTransformParameterivEXT = NULL; -PFNGLPIXELTRANSFORMPARAMETERFEXTPROC __glewPixelTransformParameterfEXT = NULL; -PFNGLPIXELTRANSFORMPARAMETERFVEXTPROC __glewPixelTransformParameterfvEXT = NULL; -PFNGLPIXELTRANSFORMPARAMETERIEXTPROC __glewPixelTransformParameteriEXT = NULL; -PFNGLPIXELTRANSFORMPARAMETERIVEXTPROC __glewPixelTransformParameterivEXT = NULL; - -PFNGLPOINTPARAMETERFEXTPROC __glewPointParameterfEXT = NULL; -PFNGLPOINTPARAMETERFVEXTPROC __glewPointParameterfvEXT = NULL; - -PFNGLPOLYGONOFFSETEXTPROC __glewPolygonOffsetEXT = NULL; - -PFNGLBEGINSCENEEXTPROC __glewBeginSceneEXT = NULL; -PFNGLENDSCENEEXTPROC __glewEndSceneEXT = NULL; - -PFNGLSECONDARYCOLOR3BEXTPROC __glewSecondaryColor3bEXT = NULL; -PFNGLSECONDARYCOLOR3BVEXTPROC __glewSecondaryColor3bvEXT = NULL; -PFNGLSECONDARYCOLOR3DEXTPROC __glewSecondaryColor3dEXT = NULL; -PFNGLSECONDARYCOLOR3DVEXTPROC __glewSecondaryColor3dvEXT = NULL; -PFNGLSECONDARYCOLOR3FEXTPROC __glewSecondaryColor3fEXT = NULL; -PFNGLSECONDARYCOLOR3FVEXTPROC __glewSecondaryColor3fvEXT = NULL; -PFNGLSECONDARYCOLOR3IEXTPROC __glewSecondaryColor3iEXT = NULL; -PFNGLSECONDARYCOLOR3IVEXTPROC __glewSecondaryColor3ivEXT = NULL; -PFNGLSECONDARYCOLOR3SEXTPROC __glewSecondaryColor3sEXT = NULL; -PFNGLSECONDARYCOLOR3SVEXTPROC __glewSecondaryColor3svEXT = NULL; -PFNGLSECONDARYCOLOR3UBEXTPROC __glewSecondaryColor3ubEXT = NULL; -PFNGLSECONDARYCOLOR3UBVEXTPROC __glewSecondaryColor3ubvEXT = NULL; -PFNGLSECONDARYCOLOR3UIEXTPROC __glewSecondaryColor3uiEXT = NULL; -PFNGLSECONDARYCOLOR3UIVEXTPROC __glewSecondaryColor3uivEXT = NULL; -PFNGLSECONDARYCOLOR3USEXTPROC __glewSecondaryColor3usEXT = NULL; -PFNGLSECONDARYCOLOR3USVEXTPROC __glewSecondaryColor3usvEXT = NULL; -PFNGLSECONDARYCOLORPOINTEREXTPROC __glewSecondaryColorPointerEXT = NULL; - -PFNGLACTIVESTENCILFACEEXTPROC __glewActiveStencilFaceEXT = NULL; - -PFNGLTEXSUBIMAGE1DEXTPROC __glewTexSubImage1DEXT = NULL; -PFNGLTEXSUBIMAGE2DEXTPROC __glewTexSubImage2DEXT = NULL; -PFNGLTEXSUBIMAGE3DEXTPROC __glewTexSubImage3DEXT = NULL; - -PFNGLTEXIMAGE3DEXTPROC __glewTexImage3DEXT = NULL; - -PFNGLTEXBUFFEREXTPROC __glewTexBufferEXT = NULL; - -PFNGLCLEARCOLORIIEXTPROC __glewClearColorIiEXT = NULL; -PFNGLCLEARCOLORIUIEXTPROC __glewClearColorIuiEXT = NULL; -PFNGLGETTEXPARAMETERIIVEXTPROC __glewGetTexParameterIivEXT = NULL; -PFNGLGETTEXPARAMETERIUIVEXTPROC __glewGetTexParameterIuivEXT = NULL; -PFNGLTEXPARAMETERIIVEXTPROC __glewTexParameterIivEXT = NULL; -PFNGLTEXPARAMETERIUIVEXTPROC __glewTexParameterIuivEXT = NULL; - -PFNGLARETEXTURESRESIDENTEXTPROC __glewAreTexturesResidentEXT = NULL; -PFNGLBINDTEXTUREEXTPROC __glewBindTextureEXT = NULL; -PFNGLDELETETEXTURESEXTPROC __glewDeleteTexturesEXT = NULL; -PFNGLGENTEXTURESEXTPROC __glewGenTexturesEXT = NULL; -PFNGLISTEXTUREEXTPROC __glewIsTextureEXT = NULL; -PFNGLPRIORITIZETEXTURESEXTPROC __glewPrioritizeTexturesEXT = NULL; - -PFNGLTEXTURENORMALEXTPROC __glewTextureNormalEXT = NULL; - -//PFNGLGETQUERYOBJECTI64VEXTPROC __glewGetQueryObjecti64vEXT = NULL; -//PFNGLGETQUERYOBJECTUI64VEXTPROC __glewGetQueryObjectui64vEXT = NULL; - -PFNGLBEGINTRANSFORMFEEDBACKEXTPROC __glewBeginTransformFeedbackEXT = NULL; -PFNGLBINDBUFFERBASEEXTPROC __glewBindBufferBaseEXT = NULL; -PFNGLBINDBUFFEROFFSETEXTPROC __glewBindBufferOffsetEXT = NULL; -PFNGLBINDBUFFERRANGEEXTPROC __glewBindBufferRangeEXT = NULL; -PFNGLENDTRANSFORMFEEDBACKEXTPROC __glewEndTransformFeedbackEXT = NULL; -PFNGLGETTRANSFORMFEEDBACKVARYINGEXTPROC __glewGetTransformFeedbackVaryingEXT = NULL; -PFNGLTRANSFORMFEEDBACKVARYINGSEXTPROC __glewTransformFeedbackVaryingsEXT = NULL; - -PFNGLARRAYELEMENTEXTPROC __glewArrayElementEXT = NULL; -PFNGLCOLORPOINTEREXTPROC __glewColorPointerEXT = NULL; -PFNGLDRAWARRAYSEXTPROC __glewDrawArraysEXT = NULL; -PFNGLEDGEFLAGPOINTEREXTPROC __glewEdgeFlagPointerEXT = NULL; -PFNGLGETPOINTERVEXTPROC __glewGetPointervEXT = NULL; -PFNGLINDEXPOINTEREXTPROC __glewIndexPointerEXT = NULL; -PFNGLNORMALPOINTEREXTPROC __glewNormalPointerEXT = NULL; -PFNGLTEXCOORDPOINTEREXTPROC __glewTexCoordPointerEXT = NULL; -PFNGLVERTEXPOINTEREXTPROC __glewVertexPointerEXT = NULL; - -PFNGLBEGINVERTEXSHADEREXTPROC __glewBeginVertexShaderEXT = NULL; -PFNGLBINDLIGHTPARAMETEREXTPROC __glewBindLightParameterEXT = NULL; -PFNGLBINDMATERIALPARAMETEREXTPROC __glewBindMaterialParameterEXT = NULL; -PFNGLBINDPARAMETEREXTPROC __glewBindParameterEXT = NULL; -PFNGLBINDTEXGENPARAMETEREXTPROC __glewBindTexGenParameterEXT = NULL; -PFNGLBINDTEXTUREUNITPARAMETEREXTPROC __glewBindTextureUnitParameterEXT = NULL; -PFNGLBINDVERTEXSHADEREXTPROC __glewBindVertexShaderEXT = NULL; -PFNGLDELETEVERTEXSHADEREXTPROC __glewDeleteVertexShaderEXT = NULL; -PFNGLDISABLEVARIANTCLIENTSTATEEXTPROC __glewDisableVariantClientStateEXT = NULL; -PFNGLENABLEVARIANTCLIENTSTATEEXTPROC __glewEnableVariantClientStateEXT = NULL; -PFNGLENDVERTEXSHADEREXTPROC __glewEndVertexShaderEXT = NULL; -PFNGLEXTRACTCOMPONENTEXTPROC __glewExtractComponentEXT = NULL; -PFNGLGENSYMBOLSEXTPROC __glewGenSymbolsEXT = NULL; -PFNGLGENVERTEXSHADERSEXTPROC __glewGenVertexShadersEXT = NULL; -PFNGLGETINVARIANTBOOLEANVEXTPROC __glewGetInvariantBooleanvEXT = NULL; -PFNGLGETINVARIANTFLOATVEXTPROC __glewGetInvariantFloatvEXT = NULL; -PFNGLGETINVARIANTINTEGERVEXTPROC __glewGetInvariantIntegervEXT = NULL; -PFNGLGETLOCALCONSTANTBOOLEANVEXTPROC __glewGetLocalConstantBooleanvEXT = NULL; -PFNGLGETLOCALCONSTANTFLOATVEXTPROC __glewGetLocalConstantFloatvEXT = NULL; -PFNGLGETLOCALCONSTANTINTEGERVEXTPROC __glewGetLocalConstantIntegervEXT = NULL; -PFNGLGETVARIANTBOOLEANVEXTPROC __glewGetVariantBooleanvEXT = NULL; -PFNGLGETVARIANTFLOATVEXTPROC __glewGetVariantFloatvEXT = NULL; -PFNGLGETVARIANTINTEGERVEXTPROC __glewGetVariantIntegervEXT = NULL; -PFNGLGETVARIANTPOINTERVEXTPROC __glewGetVariantPointervEXT = NULL; -PFNGLINSERTCOMPONENTEXTPROC __glewInsertComponentEXT = NULL; -PFNGLISVARIANTENABLEDEXTPROC __glewIsVariantEnabledEXT = NULL; -PFNGLSETINVARIANTEXTPROC __glewSetInvariantEXT = NULL; -PFNGLSETLOCALCONSTANTEXTPROC __glewSetLocalConstantEXT = NULL; -PFNGLSHADEROP1EXTPROC __glewShaderOp1EXT = NULL; -PFNGLSHADEROP2EXTPROC __glewShaderOp2EXT = NULL; -PFNGLSHADEROP3EXTPROC __glewShaderOp3EXT = NULL; -PFNGLSWIZZLEEXTPROC __glewSwizzleEXT = NULL; -PFNGLVARIANTPOINTEREXTPROC __glewVariantPointerEXT = NULL; -PFNGLVARIANTBVEXTPROC __glewVariantbvEXT = NULL; -PFNGLVARIANTDVEXTPROC __glewVariantdvEXT = NULL; -PFNGLVARIANTFVEXTPROC __glewVariantfvEXT = NULL; -PFNGLVARIANTIVEXTPROC __glewVariantivEXT = NULL; -PFNGLVARIANTSVEXTPROC __glewVariantsvEXT = NULL; -PFNGLVARIANTUBVEXTPROC __glewVariantubvEXT = NULL; -PFNGLVARIANTUIVEXTPROC __glewVariantuivEXT = NULL; -PFNGLVARIANTUSVEXTPROC __glewVariantusvEXT = NULL; -PFNGLWRITEMASKEXTPROC __glewWriteMaskEXT = NULL; - -PFNGLVERTEXWEIGHTPOINTEREXTPROC __glewVertexWeightPointerEXT = NULL; -PFNGLVERTEXWEIGHTFEXTPROC __glewVertexWeightfEXT = NULL; -PFNGLVERTEXWEIGHTFVEXTPROC __glewVertexWeightfvEXT = NULL; - -PFNGLFRAMETERMINATORGREMEDYPROC __glewFrameTerminatorGREMEDY = NULL; - -PFNGLSTRINGMARKERGREMEDYPROC __glewStringMarkerGREMEDY = NULL; - -PFNGLGETIMAGETRANSFORMPARAMETERFVHPPROC __glewGetImageTransformParameterfvHP = NULL; -PFNGLGETIMAGETRANSFORMPARAMETERIVHPPROC __glewGetImageTransformParameterivHP = NULL; -PFNGLIMAGETRANSFORMPARAMETERFHPPROC __glewImageTransformParameterfHP = NULL; -PFNGLIMAGETRANSFORMPARAMETERFVHPPROC __glewImageTransformParameterfvHP = NULL; -PFNGLIMAGETRANSFORMPARAMETERIHPPROC __glewImageTransformParameteriHP = NULL; -PFNGLIMAGETRANSFORMPARAMETERIVHPPROC __glewImageTransformParameterivHP = NULL; - -PFNGLMULTIMODEDRAWARRAYSIBMPROC __glewMultiModeDrawArraysIBM = NULL; -PFNGLMULTIMODEDRAWELEMENTSIBMPROC __glewMultiModeDrawElementsIBM = NULL; - -PFNGLCOLORPOINTERLISTIBMPROC __glewColorPointerListIBM = NULL; -PFNGLEDGEFLAGPOINTERLISTIBMPROC __glewEdgeFlagPointerListIBM = NULL; -PFNGLFOGCOORDPOINTERLISTIBMPROC __glewFogCoordPointerListIBM = NULL; -PFNGLINDEXPOINTERLISTIBMPROC __glewIndexPointerListIBM = NULL; -PFNGLNORMALPOINTERLISTIBMPROC __glewNormalPointerListIBM = NULL; -PFNGLSECONDARYCOLORPOINTERLISTIBMPROC __glewSecondaryColorPointerListIBM = NULL; -PFNGLTEXCOORDPOINTERLISTIBMPROC __glewTexCoordPointerListIBM = NULL; -PFNGLVERTEXPOINTERLISTIBMPROC __glewVertexPointerListIBM = NULL; - -PFNGLCOLORPOINTERVINTELPROC __glewColorPointervINTEL = NULL; -PFNGLNORMALPOINTERVINTELPROC __glewNormalPointervINTEL = NULL; -PFNGLTEXCOORDPOINTERVINTELPROC __glewTexCoordPointervINTEL = NULL; -PFNGLVERTEXPOINTERVINTELPROC __glewVertexPointervINTEL = NULL; - -PFNGLTEXSCISSORFUNCINTELPROC __glewTexScissorFuncINTEL = NULL; -PFNGLTEXSCISSORINTELPROC __glewTexScissorINTEL = NULL; - -PFNGLBUFFERREGIONENABLEDEXTPROC __glewBufferRegionEnabledEXT = NULL; -PFNGLDELETEBUFFERREGIONEXTPROC __glewDeleteBufferRegionEXT = NULL; -PFNGLDRAWBUFFERREGIONEXTPROC __glewDrawBufferRegionEXT = NULL; -PFNGLNEWBUFFERREGIONEXTPROC __glewNewBufferRegionEXT = NULL; -PFNGLREADBUFFERREGIONEXTPROC __glewReadBufferRegionEXT = NULL; - -PFNGLRESIZEBUFFERSMESAPROC __glewResizeBuffersMESA = NULL; - -PFNGLWINDOWPOS2DMESAPROC __glewWindowPos2dMESA = NULL; -PFNGLWINDOWPOS2DVMESAPROC __glewWindowPos2dvMESA = NULL; -PFNGLWINDOWPOS2FMESAPROC __glewWindowPos2fMESA = NULL; -PFNGLWINDOWPOS2FVMESAPROC __glewWindowPos2fvMESA = NULL; -PFNGLWINDOWPOS2IMESAPROC __glewWindowPos2iMESA = NULL; -PFNGLWINDOWPOS2IVMESAPROC __glewWindowPos2ivMESA = NULL; -PFNGLWINDOWPOS2SMESAPROC __glewWindowPos2sMESA = NULL; -PFNGLWINDOWPOS2SVMESAPROC __glewWindowPos2svMESA = NULL; -PFNGLWINDOWPOS3DMESAPROC __glewWindowPos3dMESA = NULL; -PFNGLWINDOWPOS3DVMESAPROC __glewWindowPos3dvMESA = NULL; -PFNGLWINDOWPOS3FMESAPROC __glewWindowPos3fMESA = NULL; -PFNGLWINDOWPOS3FVMESAPROC __glewWindowPos3fvMESA = NULL; -PFNGLWINDOWPOS3IMESAPROC __glewWindowPos3iMESA = NULL; -PFNGLWINDOWPOS3IVMESAPROC __glewWindowPos3ivMESA = NULL; -PFNGLWINDOWPOS3SMESAPROC __glewWindowPos3sMESA = NULL; -PFNGLWINDOWPOS3SVMESAPROC __glewWindowPos3svMESA = NULL; -PFNGLWINDOWPOS4DMESAPROC __glewWindowPos4dMESA = NULL; -PFNGLWINDOWPOS4DVMESAPROC __glewWindowPos4dvMESA = NULL; -PFNGLWINDOWPOS4FMESAPROC __glewWindowPos4fMESA = NULL; -PFNGLWINDOWPOS4FVMESAPROC __glewWindowPos4fvMESA = NULL; -PFNGLWINDOWPOS4IMESAPROC __glewWindowPos4iMESA = NULL; -PFNGLWINDOWPOS4IVMESAPROC __glewWindowPos4ivMESA = NULL; -PFNGLWINDOWPOS4SMESAPROC __glewWindowPos4sMESA = NULL; -PFNGLWINDOWPOS4SVMESAPROC __glewWindowPos4svMESA = NULL; - -PFNGLBEGINCONDITIONALRENDERNVPROC __glewBeginConditionalRenderNV = NULL; -PFNGLENDCONDITIONALRENDERNVPROC __glewEndConditionalRenderNV = NULL; - -PFNGLCLEARDEPTHDNVPROC __glewClearDepthdNV = NULL; -PFNGLDEPTHBOUNDSDNVPROC __glewDepthBoundsdNV = NULL; -PFNGLDEPTHRANGEDNVPROC __glewDepthRangedNV = NULL; - -PFNGLEVALMAPSNVPROC __glewEvalMapsNV = NULL; -PFNGLGETMAPATTRIBPARAMETERFVNVPROC __glewGetMapAttribParameterfvNV = NULL; -PFNGLGETMAPATTRIBPARAMETERIVNVPROC __glewGetMapAttribParameterivNV = NULL; -PFNGLGETMAPCONTROLPOINTSNVPROC __glewGetMapControlPointsNV = NULL; -PFNGLGETMAPPARAMETERFVNVPROC __glewGetMapParameterfvNV = NULL; -PFNGLGETMAPPARAMETERIVNVPROC __glewGetMapParameterivNV = NULL; -PFNGLMAPCONTROLPOINTSNVPROC __glewMapControlPointsNV = NULL; -PFNGLMAPPARAMETERFVNVPROC __glewMapParameterfvNV = NULL; -PFNGLMAPPARAMETERIVNVPROC __glewMapParameterivNV = NULL; - -PFNGLGETMULTISAMPLEFVNVPROC __glewGetMultisamplefvNV = NULL; -PFNGLSAMPLEMASKINDEXEDNVPROC __glewSampleMaskIndexedNV = NULL; -PFNGLTEXRENDERBUFFERNVPROC __glewTexRenderbufferNV = NULL; - -PFNGLDELETEFENCESNVPROC __glewDeleteFencesNV = NULL; -PFNGLFINISHFENCENVPROC __glewFinishFenceNV = NULL; -PFNGLGENFENCESNVPROC __glewGenFencesNV = NULL; -PFNGLGETFENCEIVNVPROC __glewGetFenceivNV = NULL; -PFNGLISFENCENVPROC __glewIsFenceNV = NULL; -PFNGLSETFENCENVPROC __glewSetFenceNV = NULL; -PFNGLTESTFENCENVPROC __glewTestFenceNV = NULL; - -PFNGLGETPROGRAMNAMEDPARAMETERDVNVPROC __glewGetProgramNamedParameterdvNV = NULL; -PFNGLGETPROGRAMNAMEDPARAMETERFVNVPROC __glewGetProgramNamedParameterfvNV = NULL; -PFNGLPROGRAMNAMEDPARAMETER4DNVPROC __glewProgramNamedParameter4dNV = NULL; -PFNGLPROGRAMNAMEDPARAMETER4DVNVPROC __glewProgramNamedParameter4dvNV = NULL; -PFNGLPROGRAMNAMEDPARAMETER4FNVPROC __glewProgramNamedParameter4fNV = NULL; -PFNGLPROGRAMNAMEDPARAMETER4FVNVPROC __glewProgramNamedParameter4fvNV = NULL; - -PFNGLRENDERBUFFERSTORAGEMULTISAMPLECOVERAGENVPROC __glewRenderbufferStorageMultisampleCoverageNV = NULL; - -PFNGLPROGRAMVERTEXLIMITNVPROC __glewProgramVertexLimitNV = NULL; - -PFNGLPROGRAMENVPARAMETERI4INVPROC __glewProgramEnvParameterI4iNV = NULL; -PFNGLPROGRAMENVPARAMETERI4IVNVPROC __glewProgramEnvParameterI4ivNV = NULL; -PFNGLPROGRAMENVPARAMETERI4UINVPROC __glewProgramEnvParameterI4uiNV = NULL; -PFNGLPROGRAMENVPARAMETERI4UIVNVPROC __glewProgramEnvParameterI4uivNV = NULL; -PFNGLPROGRAMENVPARAMETERSI4IVNVPROC __glewProgramEnvParametersI4ivNV = NULL; -PFNGLPROGRAMENVPARAMETERSI4UIVNVPROC __glewProgramEnvParametersI4uivNV = NULL; -PFNGLPROGRAMLOCALPARAMETERI4INVPROC __glewProgramLocalParameterI4iNV = NULL; -PFNGLPROGRAMLOCALPARAMETERI4IVNVPROC __glewProgramLocalParameterI4ivNV = NULL; -PFNGLPROGRAMLOCALPARAMETERI4UINVPROC __glewProgramLocalParameterI4uiNV = NULL; -PFNGLPROGRAMLOCALPARAMETERI4UIVNVPROC __glewProgramLocalParameterI4uivNV = NULL; -PFNGLPROGRAMLOCALPARAMETERSI4IVNVPROC __glewProgramLocalParametersI4ivNV = NULL; -PFNGLPROGRAMLOCALPARAMETERSI4UIVNVPROC __glewProgramLocalParametersI4uivNV = NULL; - -PFNGLCOLOR3HNVPROC __glewColor3hNV = NULL; -PFNGLCOLOR3HVNVPROC __glewColor3hvNV = NULL; -PFNGLCOLOR4HNVPROC __glewColor4hNV = NULL; -PFNGLCOLOR4HVNVPROC __glewColor4hvNV = NULL; -PFNGLFOGCOORDHNVPROC __glewFogCoordhNV = NULL; -PFNGLFOGCOORDHVNVPROC __glewFogCoordhvNV = NULL; -PFNGLMULTITEXCOORD1HNVPROC __glewMultiTexCoord1hNV = NULL; -PFNGLMULTITEXCOORD1HVNVPROC __glewMultiTexCoord1hvNV = NULL; -PFNGLMULTITEXCOORD2HNVPROC __glewMultiTexCoord2hNV = NULL; -PFNGLMULTITEXCOORD2HVNVPROC __glewMultiTexCoord2hvNV = NULL; -PFNGLMULTITEXCOORD3HNVPROC __glewMultiTexCoord3hNV = NULL; -PFNGLMULTITEXCOORD3HVNVPROC __glewMultiTexCoord3hvNV = NULL; -PFNGLMULTITEXCOORD4HNVPROC __glewMultiTexCoord4hNV = NULL; -PFNGLMULTITEXCOORD4HVNVPROC __glewMultiTexCoord4hvNV = NULL; -PFNGLNORMAL3HNVPROC __glewNormal3hNV = NULL; -PFNGLNORMAL3HVNVPROC __glewNormal3hvNV = NULL; -PFNGLSECONDARYCOLOR3HNVPROC __glewSecondaryColor3hNV = NULL; -PFNGLSECONDARYCOLOR3HVNVPROC __glewSecondaryColor3hvNV = NULL; -PFNGLTEXCOORD1HNVPROC __glewTexCoord1hNV = NULL; -PFNGLTEXCOORD1HVNVPROC __glewTexCoord1hvNV = NULL; -PFNGLTEXCOORD2HNVPROC __glewTexCoord2hNV = NULL; -PFNGLTEXCOORD2HVNVPROC __glewTexCoord2hvNV = NULL; -PFNGLTEXCOORD3HNVPROC __glewTexCoord3hNV = NULL; -PFNGLTEXCOORD3HVNVPROC __glewTexCoord3hvNV = NULL; -PFNGLTEXCOORD4HNVPROC __glewTexCoord4hNV = NULL; -PFNGLTEXCOORD4HVNVPROC __glewTexCoord4hvNV = NULL; -PFNGLVERTEX2HNVPROC __glewVertex2hNV = NULL; -PFNGLVERTEX2HVNVPROC __glewVertex2hvNV = NULL; -PFNGLVERTEX3HNVPROC __glewVertex3hNV = NULL; -PFNGLVERTEX3HVNVPROC __glewVertex3hvNV = NULL; -PFNGLVERTEX4HNVPROC __glewVertex4hNV = NULL; -PFNGLVERTEX4HVNVPROC __glewVertex4hvNV = NULL; -PFNGLVERTEXATTRIB1HNVPROC __glewVertexAttrib1hNV = NULL; -PFNGLVERTEXATTRIB1HVNVPROC __glewVertexAttrib1hvNV = NULL; -PFNGLVERTEXATTRIB2HNVPROC __glewVertexAttrib2hNV = NULL; -PFNGLVERTEXATTRIB2HVNVPROC __glewVertexAttrib2hvNV = NULL; -PFNGLVERTEXATTRIB3HNVPROC __glewVertexAttrib3hNV = NULL; -PFNGLVERTEXATTRIB3HVNVPROC __glewVertexAttrib3hvNV = NULL; -PFNGLVERTEXATTRIB4HNVPROC __glewVertexAttrib4hNV = NULL; -PFNGLVERTEXATTRIB4HVNVPROC __glewVertexAttrib4hvNV = NULL; -PFNGLVERTEXATTRIBS1HVNVPROC __glewVertexAttribs1hvNV = NULL; -PFNGLVERTEXATTRIBS2HVNVPROC __glewVertexAttribs2hvNV = NULL; -PFNGLVERTEXATTRIBS3HVNVPROC __glewVertexAttribs3hvNV = NULL; -PFNGLVERTEXATTRIBS4HVNVPROC __glewVertexAttribs4hvNV = NULL; -PFNGLVERTEXWEIGHTHNVPROC __glewVertexWeighthNV = NULL; -PFNGLVERTEXWEIGHTHVNVPROC __glewVertexWeighthvNV = NULL; - -PFNGLBEGINOCCLUSIONQUERYNVPROC __glewBeginOcclusionQueryNV = NULL; -PFNGLDELETEOCCLUSIONQUERIESNVPROC __glewDeleteOcclusionQueriesNV = NULL; -PFNGLENDOCCLUSIONQUERYNVPROC __glewEndOcclusionQueryNV = NULL; -PFNGLGENOCCLUSIONQUERIESNVPROC __glewGenOcclusionQueriesNV = NULL; -PFNGLGETOCCLUSIONQUERYIVNVPROC __glewGetOcclusionQueryivNV = NULL; -PFNGLGETOCCLUSIONQUERYUIVNVPROC __glewGetOcclusionQueryuivNV = NULL; -PFNGLISOCCLUSIONQUERYNVPROC __glewIsOcclusionQueryNV = NULL; - -PFNGLPROGRAMBUFFERPARAMETERSIIVNVPROC __glewProgramBufferParametersIivNV = NULL; -PFNGLPROGRAMBUFFERPARAMETERSIUIVNVPROC __glewProgramBufferParametersIuivNV = NULL; -PFNGLPROGRAMBUFFERPARAMETERSFVNVPROC __glewProgramBufferParametersfvNV = NULL; - -PFNGLFLUSHPIXELDATARANGENVPROC __glewFlushPixelDataRangeNV = NULL; -PFNGLPIXELDATARANGENVPROC __glewPixelDataRangeNV = NULL; - -PFNGLPOINTPARAMETERINVPROC __glewPointParameteriNV = NULL; -PFNGLPOINTPARAMETERIVNVPROC __glewPointParameterivNV = NULL; - -//PFNGLGETVIDEOI64VNVPROC __glewGetVideoi64vNV = NULL; -PFNGLGETVIDEOIVNVPROC __glewGetVideoivNV = NULL; -//PFNGLGETVIDEOUI64VNVPROC __glewGetVideoui64vNV = NULL; -PFNGLGETVIDEOUIVNVPROC __glewGetVideouivNV = NULL; -//PFNGLPRESENTFRAMEDUALFILLNVPROC __glewPresentFrameDualFillNV = NULL; -//PFNGLPRESENTFRAMEKEYEDNVPROC __glewPresentFrameKeyedNV = NULL; -PFNGLVIDEOPARAMETERIVNVPROC __glewVideoParameterivNV = NULL; - -PFNGLPRIMITIVERESTARTINDEXNVPROC __glewPrimitiveRestartIndexNV = NULL; -PFNGLPRIMITIVERESTARTNVPROC __glewPrimitiveRestartNV = NULL; - -PFNGLCOMBINERINPUTNVPROC __glewCombinerInputNV = NULL; -PFNGLCOMBINEROUTPUTNVPROC __glewCombinerOutputNV = NULL; -PFNGLCOMBINERPARAMETERFNVPROC __glewCombinerParameterfNV = NULL; -PFNGLCOMBINERPARAMETERFVNVPROC __glewCombinerParameterfvNV = NULL; -PFNGLCOMBINERPARAMETERINVPROC __glewCombinerParameteriNV = NULL; -PFNGLCOMBINERPARAMETERIVNVPROC __glewCombinerParameterivNV = NULL; -PFNGLFINALCOMBINERINPUTNVPROC __glewFinalCombinerInputNV = NULL; -PFNGLGETCOMBINERINPUTPARAMETERFVNVPROC __glewGetCombinerInputParameterfvNV = NULL; -PFNGLGETCOMBINERINPUTPARAMETERIVNVPROC __glewGetCombinerInputParameterivNV = NULL; -PFNGLGETCOMBINEROUTPUTPARAMETERFVNVPROC __glewGetCombinerOutputParameterfvNV = NULL; -PFNGLGETCOMBINEROUTPUTPARAMETERIVNVPROC __glewGetCombinerOutputParameterivNV = NULL; -PFNGLGETFINALCOMBINERINPUTPARAMETERFVNVPROC __glewGetFinalCombinerInputParameterfvNV = NULL; -PFNGLGETFINALCOMBINERINPUTPARAMETERIVNVPROC __glewGetFinalCombinerInputParameterivNV = NULL; - -PFNGLCOMBINERSTAGEPARAMETERFVNVPROC __glewCombinerStageParameterfvNV = NULL; -PFNGLGETCOMBINERSTAGEPARAMETERFVNVPROC __glewGetCombinerStageParameterfvNV = NULL; - -PFNGLACTIVEVARYINGNVPROC __glewActiveVaryingNV = NULL; -PFNGLBEGINTRANSFORMFEEDBACKNVPROC __glewBeginTransformFeedbackNV = NULL; -PFNGLBINDBUFFERBASENVPROC __glewBindBufferBaseNV = NULL; -PFNGLBINDBUFFEROFFSETNVPROC __glewBindBufferOffsetNV = NULL; -PFNGLBINDBUFFERRANGENVPROC __glewBindBufferRangeNV = NULL; -PFNGLENDTRANSFORMFEEDBACKNVPROC __glewEndTransformFeedbackNV = NULL; -PFNGLGETACTIVEVARYINGNVPROC __glewGetActiveVaryingNV = NULL; -PFNGLGETTRANSFORMFEEDBACKVARYINGNVPROC __glewGetTransformFeedbackVaryingNV = NULL; -PFNGLGETVARYINGLOCATIONNVPROC __glewGetVaryingLocationNV = NULL; -PFNGLTRANSFORMFEEDBACKATTRIBSNVPROC __glewTransformFeedbackAttribsNV = NULL; -PFNGLTRANSFORMFEEDBACKVARYINGSNVPROC __glewTransformFeedbackVaryingsNV = NULL; - -PFNGLFLUSHVERTEXARRAYRANGENVPROC __glewFlushVertexArrayRangeNV = NULL; -PFNGLVERTEXARRAYRANGENVPROC __glewVertexArrayRangeNV = NULL; - -PFNGLAREPROGRAMSRESIDENTNVPROC __glewAreProgramsResidentNV = NULL; -PFNGLBINDPROGRAMNVPROC __glewBindProgramNV = NULL; -PFNGLDELETEPROGRAMSNVPROC __glewDeleteProgramsNV = NULL; -PFNGLEXECUTEPROGRAMNVPROC __glewExecuteProgramNV = NULL; -PFNGLGENPROGRAMSNVPROC __glewGenProgramsNV = NULL; -PFNGLGETPROGRAMPARAMETERDVNVPROC __glewGetProgramParameterdvNV = NULL; -PFNGLGETPROGRAMPARAMETERFVNVPROC __glewGetProgramParameterfvNV = NULL; -PFNGLGETPROGRAMSTRINGNVPROC __glewGetProgramStringNV = NULL; -PFNGLGETPROGRAMIVNVPROC __glewGetProgramivNV = NULL; -PFNGLGETTRACKMATRIXIVNVPROC __glewGetTrackMatrixivNV = NULL; -PFNGLGETVERTEXATTRIBPOINTERVNVPROC __glewGetVertexAttribPointervNV = NULL; -PFNGLGETVERTEXATTRIBDVNVPROC __glewGetVertexAttribdvNV = NULL; -PFNGLGETVERTEXATTRIBFVNVPROC __glewGetVertexAttribfvNV = NULL; -PFNGLGETVERTEXATTRIBIVNVPROC __glewGetVertexAttribivNV = NULL; -PFNGLISPROGRAMNVPROC __glewIsProgramNV = NULL; -PFNGLLOADPROGRAMNVPROC __glewLoadProgramNV = NULL; -PFNGLPROGRAMPARAMETER4DNVPROC __glewProgramParameter4dNV = NULL; -PFNGLPROGRAMPARAMETER4DVNVPROC __glewProgramParameter4dvNV = NULL; -PFNGLPROGRAMPARAMETER4FNVPROC __glewProgramParameter4fNV = NULL; -PFNGLPROGRAMPARAMETER4FVNVPROC __glewProgramParameter4fvNV = NULL; -PFNGLPROGRAMPARAMETERS4DVNVPROC __glewProgramParameters4dvNV = NULL; -PFNGLPROGRAMPARAMETERS4FVNVPROC __glewProgramParameters4fvNV = NULL; -PFNGLREQUESTRESIDENTPROGRAMSNVPROC __glewRequestResidentProgramsNV = NULL; -PFNGLTRACKMATRIXNVPROC __glewTrackMatrixNV = NULL; -PFNGLVERTEXATTRIB1DNVPROC __glewVertexAttrib1dNV = NULL; -PFNGLVERTEXATTRIB1DVNVPROC __glewVertexAttrib1dvNV = NULL; -PFNGLVERTEXATTRIB1FNVPROC __glewVertexAttrib1fNV = NULL; -PFNGLVERTEXATTRIB1FVNVPROC __glewVertexAttrib1fvNV = NULL; -PFNGLVERTEXATTRIB1SNVPROC __glewVertexAttrib1sNV = NULL; -PFNGLVERTEXATTRIB1SVNVPROC __glewVertexAttrib1svNV = NULL; -PFNGLVERTEXATTRIB2DNVPROC __glewVertexAttrib2dNV = NULL; -PFNGLVERTEXATTRIB2DVNVPROC __glewVertexAttrib2dvNV = NULL; -PFNGLVERTEXATTRIB2FNVPROC __glewVertexAttrib2fNV = NULL; -PFNGLVERTEXATTRIB2FVNVPROC __glewVertexAttrib2fvNV = NULL; -PFNGLVERTEXATTRIB2SNVPROC __glewVertexAttrib2sNV = NULL; -PFNGLVERTEXATTRIB2SVNVPROC __glewVertexAttrib2svNV = NULL; -PFNGLVERTEXATTRIB3DNVPROC __glewVertexAttrib3dNV = NULL; -PFNGLVERTEXATTRIB3DVNVPROC __glewVertexAttrib3dvNV = NULL; -PFNGLVERTEXATTRIB3FNVPROC __glewVertexAttrib3fNV = NULL; -PFNGLVERTEXATTRIB3FVNVPROC __glewVertexAttrib3fvNV = NULL; -PFNGLVERTEXATTRIB3SNVPROC __glewVertexAttrib3sNV = NULL; -PFNGLVERTEXATTRIB3SVNVPROC __glewVertexAttrib3svNV = NULL; -PFNGLVERTEXATTRIB4DNVPROC __glewVertexAttrib4dNV = NULL; -PFNGLVERTEXATTRIB4DVNVPROC __glewVertexAttrib4dvNV = NULL; -PFNGLVERTEXATTRIB4FNVPROC __glewVertexAttrib4fNV = NULL; -PFNGLVERTEXATTRIB4FVNVPROC __glewVertexAttrib4fvNV = NULL; -PFNGLVERTEXATTRIB4SNVPROC __glewVertexAttrib4sNV = NULL; -PFNGLVERTEXATTRIB4SVNVPROC __glewVertexAttrib4svNV = NULL; -PFNGLVERTEXATTRIB4UBNVPROC __glewVertexAttrib4ubNV = NULL; -PFNGLVERTEXATTRIB4UBVNVPROC __glewVertexAttrib4ubvNV = NULL; -PFNGLVERTEXATTRIBPOINTERNVPROC __glewVertexAttribPointerNV = NULL; -PFNGLVERTEXATTRIBS1DVNVPROC __glewVertexAttribs1dvNV = NULL; -PFNGLVERTEXATTRIBS1FVNVPROC __glewVertexAttribs1fvNV = NULL; -PFNGLVERTEXATTRIBS1SVNVPROC __glewVertexAttribs1svNV = NULL; -PFNGLVERTEXATTRIBS2DVNVPROC __glewVertexAttribs2dvNV = NULL; -PFNGLVERTEXATTRIBS2FVNVPROC __glewVertexAttribs2fvNV = NULL; -PFNGLVERTEXATTRIBS2SVNVPROC __glewVertexAttribs2svNV = NULL; -PFNGLVERTEXATTRIBS3DVNVPROC __glewVertexAttribs3dvNV = NULL; -PFNGLVERTEXATTRIBS3FVNVPROC __glewVertexAttribs3fvNV = NULL; -PFNGLVERTEXATTRIBS3SVNVPROC __glewVertexAttribs3svNV = NULL; -PFNGLVERTEXATTRIBS4DVNVPROC __glewVertexAttribs4dvNV = NULL; -PFNGLVERTEXATTRIBS4FVNVPROC __glewVertexAttribs4fvNV = NULL; -PFNGLVERTEXATTRIBS4SVNVPROC __glewVertexAttribs4svNV = NULL; -PFNGLVERTEXATTRIBS4UBVNVPROC __glewVertexAttribs4ubvNV = NULL; - -PFNGLCLEARDEPTHFOESPROC __glewClearDepthfOES = NULL; -PFNGLCLIPPLANEFOESPROC __glewClipPlanefOES = NULL; -PFNGLDEPTHRANGEFOESPROC __glewDepthRangefOES = NULL; -PFNGLFRUSTUMFOESPROC __glewFrustumfOES = NULL; -PFNGLGETCLIPPLANEFOESPROC __glewGetClipPlanefOES = NULL; -PFNGLORTHOFOESPROC __glewOrthofOES = NULL; - -PFNGLDETAILTEXFUNCSGISPROC __glewDetailTexFuncSGIS = NULL; -PFNGLGETDETAILTEXFUNCSGISPROC __glewGetDetailTexFuncSGIS = NULL; - -PFNGLFOGFUNCSGISPROC __glewFogFuncSGIS = NULL; -PFNGLGETFOGFUNCSGISPROC __glewGetFogFuncSGIS = NULL; - -PFNGLSAMPLEMASKSGISPROC __glewSampleMaskSGIS = NULL; -PFNGLSAMPLEPATTERNSGISPROC __glewSamplePatternSGIS = NULL; - -PFNGLGETSHARPENTEXFUNCSGISPROC __glewGetSharpenTexFuncSGIS = NULL; -PFNGLSHARPENTEXFUNCSGISPROC __glewSharpenTexFuncSGIS = NULL; - -PFNGLTEXIMAGE4DSGISPROC __glewTexImage4DSGIS = NULL; -PFNGLTEXSUBIMAGE4DSGISPROC __glewTexSubImage4DSGIS = NULL; - -PFNGLGETTEXFILTERFUNCSGISPROC __glewGetTexFilterFuncSGIS = NULL; -PFNGLTEXFILTERFUNCSGISPROC __glewTexFilterFuncSGIS = NULL; - -PFNGLASYNCMARKERSGIXPROC __glewAsyncMarkerSGIX = NULL; -PFNGLDELETEASYNCMARKERSSGIXPROC __glewDeleteAsyncMarkersSGIX = NULL; -PFNGLFINISHASYNCSGIXPROC __glewFinishAsyncSGIX = NULL; -PFNGLGENASYNCMARKERSSGIXPROC __glewGenAsyncMarkersSGIX = NULL; -PFNGLISASYNCMARKERSGIXPROC __glewIsAsyncMarkerSGIX = NULL; -PFNGLPOLLASYNCSGIXPROC __glewPollAsyncSGIX = NULL; - -PFNGLFLUSHRASTERSGIXPROC __glewFlushRasterSGIX = NULL; - -PFNGLTEXTUREFOGSGIXPROC __glewTextureFogSGIX = NULL; - -PFNGLFRAGMENTCOLORMATERIALSGIXPROC __glewFragmentColorMaterialSGIX = NULL; -PFNGLFRAGMENTLIGHTMODELFSGIXPROC __glewFragmentLightModelfSGIX = NULL; -PFNGLFRAGMENTLIGHTMODELFVSGIXPROC __glewFragmentLightModelfvSGIX = NULL; -PFNGLFRAGMENTLIGHTMODELISGIXPROC __glewFragmentLightModeliSGIX = NULL; -PFNGLFRAGMENTLIGHTMODELIVSGIXPROC __glewFragmentLightModelivSGIX = NULL; -PFNGLFRAGMENTLIGHTFSGIXPROC __glewFragmentLightfSGIX = NULL; -PFNGLFRAGMENTLIGHTFVSGIXPROC __glewFragmentLightfvSGIX = NULL; -PFNGLFRAGMENTLIGHTISGIXPROC __glewFragmentLightiSGIX = NULL; -PFNGLFRAGMENTLIGHTIVSGIXPROC __glewFragmentLightivSGIX = NULL; -PFNGLFRAGMENTMATERIALFSGIXPROC __glewFragmentMaterialfSGIX = NULL; -PFNGLFRAGMENTMATERIALFVSGIXPROC __glewFragmentMaterialfvSGIX = NULL; -PFNGLFRAGMENTMATERIALISGIXPROC __glewFragmentMaterialiSGIX = NULL; -PFNGLFRAGMENTMATERIALIVSGIXPROC __glewFragmentMaterialivSGIX = NULL; -PFNGLGETFRAGMENTLIGHTFVSGIXPROC __glewGetFragmentLightfvSGIX = NULL; -PFNGLGETFRAGMENTLIGHTIVSGIXPROC __glewGetFragmentLightivSGIX = NULL; -PFNGLGETFRAGMENTMATERIALFVSGIXPROC __glewGetFragmentMaterialfvSGIX = NULL; -PFNGLGETFRAGMENTMATERIALIVSGIXPROC __glewGetFragmentMaterialivSGIX = NULL; - -PFNGLFRAMEZOOMSGIXPROC __glewFrameZoomSGIX = NULL; - -PFNGLPIXELTEXGENSGIXPROC __glewPixelTexGenSGIX = NULL; - -PFNGLREFERENCEPLANESGIXPROC __glewReferencePlaneSGIX = NULL; - -PFNGLSPRITEPARAMETERFSGIXPROC __glewSpriteParameterfSGIX = NULL; -PFNGLSPRITEPARAMETERFVSGIXPROC __glewSpriteParameterfvSGIX = NULL; -PFNGLSPRITEPARAMETERISGIXPROC __glewSpriteParameteriSGIX = NULL; -PFNGLSPRITEPARAMETERIVSGIXPROC __glewSpriteParameterivSGIX = NULL; - -PFNGLTAGSAMPLEBUFFERSGIXPROC __glewTagSampleBufferSGIX = NULL; - -PFNGLCOLORTABLEPARAMETERFVSGIPROC __glewColorTableParameterfvSGI = NULL; -PFNGLCOLORTABLEPARAMETERIVSGIPROC __glewColorTableParameterivSGI = NULL; -PFNGLCOLORTABLESGIPROC __glewColorTableSGI = NULL; -PFNGLCOPYCOLORTABLESGIPROC __glewCopyColorTableSGI = NULL; -PFNGLGETCOLORTABLEPARAMETERFVSGIPROC __glewGetColorTableParameterfvSGI = NULL; -PFNGLGETCOLORTABLEPARAMETERIVSGIPROC __glewGetColorTableParameterivSGI = NULL; -PFNGLGETCOLORTABLESGIPROC __glewGetColorTableSGI = NULL; - -PFNGLFINISHTEXTURESUNXPROC __glewFinishTextureSUNX = NULL; - -PFNGLGLOBALALPHAFACTORBSUNPROC __glewGlobalAlphaFactorbSUN = NULL; -PFNGLGLOBALALPHAFACTORDSUNPROC __glewGlobalAlphaFactordSUN = NULL; -PFNGLGLOBALALPHAFACTORFSUNPROC __glewGlobalAlphaFactorfSUN = NULL; -PFNGLGLOBALALPHAFACTORISUNPROC __glewGlobalAlphaFactoriSUN = NULL; -PFNGLGLOBALALPHAFACTORSSUNPROC __glewGlobalAlphaFactorsSUN = NULL; -PFNGLGLOBALALPHAFACTORUBSUNPROC __glewGlobalAlphaFactorubSUN = NULL; -PFNGLGLOBALALPHAFACTORUISUNPROC __glewGlobalAlphaFactoruiSUN = NULL; -PFNGLGLOBALALPHAFACTORUSSUNPROC __glewGlobalAlphaFactorusSUN = NULL; - -PFNGLREADVIDEOPIXELSSUNPROC __glewReadVideoPixelsSUN = NULL; - -PFNGLREPLACEMENTCODEPOINTERSUNPROC __glewReplacementCodePointerSUN = NULL; -PFNGLREPLACEMENTCODEUBSUNPROC __glewReplacementCodeubSUN = NULL; -PFNGLREPLACEMENTCODEUBVSUNPROC __glewReplacementCodeubvSUN = NULL; -PFNGLREPLACEMENTCODEUISUNPROC __glewReplacementCodeuiSUN = NULL; -PFNGLREPLACEMENTCODEUIVSUNPROC __glewReplacementCodeuivSUN = NULL; -PFNGLREPLACEMENTCODEUSSUNPROC __glewReplacementCodeusSUN = NULL; -PFNGLREPLACEMENTCODEUSVSUNPROC __glewReplacementCodeusvSUN = NULL; - -PFNGLCOLOR3FVERTEX3FSUNPROC __glewColor3fVertex3fSUN = NULL; -PFNGLCOLOR3FVERTEX3FVSUNPROC __glewColor3fVertex3fvSUN = NULL; -PFNGLCOLOR4FNORMAL3FVERTEX3FSUNPROC __glewColor4fNormal3fVertex3fSUN = NULL; -PFNGLCOLOR4FNORMAL3FVERTEX3FVSUNPROC __glewColor4fNormal3fVertex3fvSUN = NULL; -PFNGLCOLOR4UBVERTEX2FSUNPROC __glewColor4ubVertex2fSUN = NULL; -PFNGLCOLOR4UBVERTEX2FVSUNPROC __glewColor4ubVertex2fvSUN = NULL; -PFNGLCOLOR4UBVERTEX3FSUNPROC __glewColor4ubVertex3fSUN = NULL; -PFNGLCOLOR4UBVERTEX3FVSUNPROC __glewColor4ubVertex3fvSUN = NULL; -PFNGLNORMAL3FVERTEX3FSUNPROC __glewNormal3fVertex3fSUN = NULL; -PFNGLNORMAL3FVERTEX3FVSUNPROC __glewNormal3fVertex3fvSUN = NULL; -PFNGLREPLACEMENTCODEUICOLOR3FVERTEX3FSUNPROC __glewReplacementCodeuiColor3fVertex3fSUN = NULL; -PFNGLREPLACEMENTCODEUICOLOR3FVERTEX3FVSUNPROC __glewReplacementCodeuiColor3fVertex3fvSUN = NULL; -PFNGLREPLACEMENTCODEUICOLOR4FNORMAL3FVERTEX3FSUNPROC __glewReplacementCodeuiColor4fNormal3fVertex3fSUN = NULL; -PFNGLREPLACEMENTCODEUICOLOR4FNORMAL3FVERTEX3FVSUNPROC __glewReplacementCodeuiColor4fNormal3fVertex3fvSUN = NULL; -PFNGLREPLACEMENTCODEUICOLOR4UBVERTEX3FSUNPROC __glewReplacementCodeuiColor4ubVertex3fSUN = NULL; -PFNGLREPLACEMENTCODEUICOLOR4UBVERTEX3FVSUNPROC __glewReplacementCodeuiColor4ubVertex3fvSUN = NULL; -PFNGLREPLACEMENTCODEUINORMAL3FVERTEX3FSUNPROC __glewReplacementCodeuiNormal3fVertex3fSUN = NULL; -PFNGLREPLACEMENTCODEUINORMAL3FVERTEX3FVSUNPROC __glewReplacementCodeuiNormal3fVertex3fvSUN = NULL; -PFNGLREPLACEMENTCODEUITEXCOORD2FCOLOR4FNORMAL3FVERTEX3FSUNPROC __glewReplacementCodeuiTexCoord2fColor4fNormal3fVertex3fSUN = NULL; -PFNGLREPLACEMENTCODEUITEXCOORD2FCOLOR4FNORMAL3FVERTEX3FVSUNPROC __glewReplacementCodeuiTexCoord2fColor4fNormal3fVertex3fvSUN = NULL; -PFNGLREPLACEMENTCODEUITEXCOORD2FNORMAL3FVERTEX3FSUNPROC __glewReplacementCodeuiTexCoord2fNormal3fVertex3fSUN = NULL; -PFNGLREPLACEMENTCODEUITEXCOORD2FNORMAL3FVERTEX3FVSUNPROC __glewReplacementCodeuiTexCoord2fNormal3fVertex3fvSUN = NULL; -PFNGLREPLACEMENTCODEUITEXCOORD2FVERTEX3FSUNPROC __glewReplacementCodeuiTexCoord2fVertex3fSUN = NULL; -PFNGLREPLACEMENTCODEUITEXCOORD2FVERTEX3FVSUNPROC __glewReplacementCodeuiTexCoord2fVertex3fvSUN = NULL; -PFNGLREPLACEMENTCODEUIVERTEX3FSUNPROC __glewReplacementCodeuiVertex3fSUN = NULL; -PFNGLREPLACEMENTCODEUIVERTEX3FVSUNPROC __glewReplacementCodeuiVertex3fvSUN = NULL; -PFNGLTEXCOORD2FCOLOR3FVERTEX3FSUNPROC __glewTexCoord2fColor3fVertex3fSUN = NULL; -PFNGLTEXCOORD2FCOLOR3FVERTEX3FVSUNPROC __glewTexCoord2fColor3fVertex3fvSUN = NULL; -PFNGLTEXCOORD2FCOLOR4FNORMAL3FVERTEX3FSUNPROC __glewTexCoord2fColor4fNormal3fVertex3fSUN = NULL; -PFNGLTEXCOORD2FCOLOR4FNORMAL3FVERTEX3FVSUNPROC __glewTexCoord2fColor4fNormal3fVertex3fvSUN = NULL; -PFNGLTEXCOORD2FCOLOR4UBVERTEX3FSUNPROC __glewTexCoord2fColor4ubVertex3fSUN = NULL; -PFNGLTEXCOORD2FCOLOR4UBVERTEX3FVSUNPROC __glewTexCoord2fColor4ubVertex3fvSUN = NULL; -PFNGLTEXCOORD2FNORMAL3FVERTEX3FSUNPROC __glewTexCoord2fNormal3fVertex3fSUN = NULL; -PFNGLTEXCOORD2FNORMAL3FVERTEX3FVSUNPROC __glewTexCoord2fNormal3fVertex3fvSUN = NULL; -PFNGLTEXCOORD2FVERTEX3FSUNPROC __glewTexCoord2fVertex3fSUN = NULL; -PFNGLTEXCOORD2FVERTEX3FVSUNPROC __glewTexCoord2fVertex3fvSUN = NULL; -PFNGLTEXCOORD4FCOLOR4FNORMAL3FVERTEX4FSUNPROC __glewTexCoord4fColor4fNormal3fVertex4fSUN = NULL; -PFNGLTEXCOORD4FCOLOR4FNORMAL3FVERTEX4FVSUNPROC __glewTexCoord4fColor4fNormal3fVertex4fvSUN = NULL; -PFNGLTEXCOORD4FVERTEX4FSUNPROC __glewTexCoord4fVertex4fSUN = NULL; -PFNGLTEXCOORD4FVERTEX4FVSUNPROC __glewTexCoord4fVertex4fvSUN = NULL; - -PFNGLADDSWAPHINTRECTWINPROC __glewAddSwapHintRectWIN = NULL; - -#endif /* !WIN32 || !GLEW_MX */ - -#if !defined(GLEW_MX) - -GLboolean __GLEW_VERSION_1_1 = GL_FALSE; -GLboolean __GLEW_VERSION_1_2 = GL_FALSE; -GLboolean __GLEW_VERSION_1_3 = GL_FALSE; -GLboolean __GLEW_VERSION_1_4 = GL_FALSE; -GLboolean __GLEW_VERSION_1_5 = GL_FALSE; -GLboolean __GLEW_VERSION_2_0 = GL_FALSE; -GLboolean __GLEW_VERSION_2_1 = GL_FALSE; -GLboolean __GLEW_VERSION_3_0 = GL_FALSE; -GLboolean __GLEW_3DFX_multisample = GL_FALSE; -GLboolean __GLEW_3DFX_tbuffer = GL_FALSE; -GLboolean __GLEW_3DFX_texture_compression_FXT1 = GL_FALSE; -GLboolean __GLEW_APPLE_client_storage = GL_FALSE; -GLboolean __GLEW_APPLE_element_array = GL_FALSE; -GLboolean __GLEW_APPLE_fence = GL_FALSE; -GLboolean __GLEW_APPLE_float_pixels = GL_FALSE; -GLboolean __GLEW_APPLE_flush_buffer_range = GL_FALSE; -GLboolean __GLEW_APPLE_pixel_buffer = GL_FALSE; -GLboolean __GLEW_APPLE_specular_vector = GL_FALSE; -GLboolean __GLEW_APPLE_texture_range = GL_FALSE; -GLboolean __GLEW_APPLE_transform_hint = GL_FALSE; -GLboolean __GLEW_APPLE_vertex_array_object = GL_FALSE; -GLboolean __GLEW_APPLE_vertex_array_range = GL_FALSE; -GLboolean __GLEW_APPLE_ycbcr_422 = GL_FALSE; -GLboolean __GLEW_ARB_color_buffer_float = GL_FALSE; -GLboolean __GLEW_ARB_depth_buffer_float = GL_FALSE; -GLboolean __GLEW_ARB_depth_texture = GL_FALSE; -GLboolean __GLEW_ARB_draw_buffers = GL_FALSE; -GLboolean __GLEW_ARB_draw_instanced = GL_FALSE; -GLboolean __GLEW_ARB_fragment_program = GL_FALSE; -GLboolean __GLEW_ARB_fragment_program_shadow = GL_FALSE; -GLboolean __GLEW_ARB_fragment_shader = GL_FALSE; -GLboolean __GLEW_ARB_framebuffer_object = GL_FALSE; -GLboolean __GLEW_ARB_framebuffer_sRGB = GL_FALSE; -GLboolean __GLEW_ARB_geometry_shader4 = GL_FALSE; -GLboolean __GLEW_ARB_half_float_pixel = GL_FALSE; -GLboolean __GLEW_ARB_half_float_vertex = GL_FALSE; -GLboolean __GLEW_ARB_imaging = GL_FALSE; -GLboolean __GLEW_ARB_instanced_arrays = GL_FALSE; -GLboolean __GLEW_ARB_map_buffer_range = GL_FALSE; -GLboolean __GLEW_ARB_matrix_palette = GL_FALSE; -GLboolean __GLEW_ARB_multisample = GL_FALSE; -GLboolean __GLEW_ARB_multitexture = GL_FALSE; -GLboolean __GLEW_ARB_occlusion_query = GL_FALSE; -GLboolean __GLEW_ARB_pixel_buffer_object = GL_FALSE; -GLboolean __GLEW_ARB_point_parameters = GL_FALSE; -GLboolean __GLEW_ARB_point_sprite = GL_FALSE; -GLboolean __GLEW_ARB_shader_objects = GL_FALSE; -GLboolean __GLEW_ARB_shading_language_100 = GL_FALSE; -GLboolean __GLEW_ARB_shadow = GL_FALSE; -GLboolean __GLEW_ARB_shadow_ambient = GL_FALSE; -GLboolean __GLEW_ARB_texture_border_clamp = GL_FALSE; -GLboolean __GLEW_ARB_texture_buffer_object = GL_FALSE; -GLboolean __GLEW_ARB_texture_compression = GL_FALSE; -GLboolean __GLEW_ARB_texture_compression_rgtc = GL_FALSE; -GLboolean __GLEW_ARB_texture_cube_map = GL_FALSE; -GLboolean __GLEW_ARB_texture_env_add = GL_FALSE; -GLboolean __GLEW_ARB_texture_env_combine = GL_FALSE; -GLboolean __GLEW_ARB_texture_env_crossbar = GL_FALSE; -GLboolean __GLEW_ARB_texture_env_dot3 = GL_FALSE; -GLboolean __GLEW_ARB_texture_float = GL_FALSE; -GLboolean __GLEW_ARB_texture_mirrored_repeat = GL_FALSE; -GLboolean __GLEW_ARB_texture_non_power_of_two = GL_FALSE; -GLboolean __GLEW_ARB_texture_rectangle = GL_FALSE; -GLboolean __GLEW_ARB_texture_rg = GL_FALSE; -GLboolean __GLEW_ARB_transpose_matrix = GL_FALSE; -GLboolean __GLEW_ARB_vertex_array_object = GL_FALSE; -GLboolean __GLEW_ARB_vertex_blend = GL_FALSE; -GLboolean __GLEW_ARB_vertex_buffer_object = GL_FALSE; -GLboolean __GLEW_ARB_vertex_program = GL_FALSE; -GLboolean __GLEW_ARB_vertex_shader = GL_FALSE; -GLboolean __GLEW_ARB_window_pos = GL_FALSE; -GLboolean __GLEW_ATIX_point_sprites = GL_FALSE; -GLboolean __GLEW_ATIX_texture_env_combine3 = GL_FALSE; -GLboolean __GLEW_ATIX_texture_env_route = GL_FALSE; -GLboolean __GLEW_ATIX_vertex_shader_output_point_size = GL_FALSE; -GLboolean __GLEW_ATI_draw_buffers = GL_FALSE; -GLboolean __GLEW_ATI_element_array = GL_FALSE; -GLboolean __GLEW_ATI_envmap_bumpmap = GL_FALSE; -GLboolean __GLEW_ATI_fragment_shader = GL_FALSE; -GLboolean __GLEW_ATI_map_object_buffer = GL_FALSE; -GLboolean __GLEW_ATI_pn_triangles = GL_FALSE; -GLboolean __GLEW_ATI_separate_stencil = GL_FALSE; -GLboolean __GLEW_ATI_shader_texture_lod = GL_FALSE; -GLboolean __GLEW_ATI_text_fragment_shader = GL_FALSE; -GLboolean __GLEW_ATI_texture_compression_3dc = GL_FALSE; -GLboolean __GLEW_ATI_texture_env_combine3 = GL_FALSE; -GLboolean __GLEW_ATI_texture_float = GL_FALSE; -GLboolean __GLEW_ATI_texture_mirror_once = GL_FALSE; -GLboolean __GLEW_ATI_vertex_array_object = GL_FALSE; -GLboolean __GLEW_ATI_vertex_attrib_array_object = GL_FALSE; -GLboolean __GLEW_ATI_vertex_streams = GL_FALSE; -GLboolean __GLEW_EXT_422_pixels = GL_FALSE; -GLboolean __GLEW_EXT_Cg_shader = GL_FALSE; -GLboolean __GLEW_EXT_abgr = GL_FALSE; -GLboolean __GLEW_EXT_bgra = GL_FALSE; -GLboolean __GLEW_EXT_bindable_uniform = GL_FALSE; -GLboolean __GLEW_EXT_blend_color = GL_FALSE; -GLboolean __GLEW_EXT_blend_equation_separate = GL_FALSE; -GLboolean __GLEW_EXT_blend_func_separate = GL_FALSE; -GLboolean __GLEW_EXT_blend_logic_op = GL_FALSE; -GLboolean __GLEW_EXT_blend_minmax = GL_FALSE; -GLboolean __GLEW_EXT_blend_subtract = GL_FALSE; -GLboolean __GLEW_EXT_clip_volume_hint = GL_FALSE; -GLboolean __GLEW_EXT_cmyka = GL_FALSE; -GLboolean __GLEW_EXT_color_subtable = GL_FALSE; -GLboolean __GLEW_EXT_compiled_vertex_array = GL_FALSE; -GLboolean __GLEW_EXT_convolution = GL_FALSE; -GLboolean __GLEW_EXT_coordinate_frame = GL_FALSE; -GLboolean __GLEW_EXT_copy_texture = GL_FALSE; -GLboolean __GLEW_EXT_cull_vertex = GL_FALSE; -GLboolean __GLEW_EXT_depth_bounds_test = GL_FALSE; -GLboolean __GLEW_EXT_direct_state_access = GL_FALSE; -GLboolean __GLEW_EXT_draw_buffers2 = GL_FALSE; -GLboolean __GLEW_EXT_draw_instanced = GL_FALSE; -GLboolean __GLEW_EXT_draw_range_elements = GL_FALSE; -GLboolean __GLEW_EXT_fog_coord = GL_FALSE; -GLboolean __GLEW_EXT_fragment_lighting = GL_FALSE; -GLboolean __GLEW_EXT_framebuffer_blit = GL_FALSE; -GLboolean __GLEW_EXT_framebuffer_multisample = GL_FALSE; -GLboolean __GLEW_EXT_framebuffer_object = GL_FALSE; -GLboolean __GLEW_EXT_framebuffer_sRGB = GL_FALSE; -GLboolean __GLEW_EXT_geometry_shader4 = GL_FALSE; -GLboolean __GLEW_EXT_gpu_program_parameters = GL_FALSE; -GLboolean __GLEW_EXT_gpu_shader4 = GL_FALSE; -GLboolean __GLEW_EXT_histogram = GL_FALSE; -GLboolean __GLEW_EXT_index_array_formats = GL_FALSE; -GLboolean __GLEW_EXT_index_func = GL_FALSE; -GLboolean __GLEW_EXT_index_material = GL_FALSE; -GLboolean __GLEW_EXT_index_texture = GL_FALSE; -GLboolean __GLEW_EXT_light_texture = GL_FALSE; -GLboolean __GLEW_EXT_misc_attribute = GL_FALSE; -GLboolean __GLEW_EXT_multi_draw_arrays = GL_FALSE; -GLboolean __GLEW_EXT_multisample = GL_FALSE; -GLboolean __GLEW_EXT_packed_depth_stencil = GL_FALSE; -GLboolean __GLEW_EXT_packed_float = GL_FALSE; -GLboolean __GLEW_EXT_packed_pixels = GL_FALSE; -GLboolean __GLEW_EXT_paletted_texture = GL_FALSE; -GLboolean __GLEW_EXT_pixel_buffer_object = GL_FALSE; -GLboolean __GLEW_EXT_pixel_transform = GL_FALSE; -GLboolean __GLEW_EXT_pixel_transform_color_table = GL_FALSE; -GLboolean __GLEW_EXT_point_parameters = GL_FALSE; -GLboolean __GLEW_EXT_polygon_offset = GL_FALSE; -GLboolean __GLEW_EXT_rescale_normal = GL_FALSE; -GLboolean __GLEW_EXT_scene_marker = GL_FALSE; -GLboolean __GLEW_EXT_secondary_color = GL_FALSE; -GLboolean __GLEW_EXT_separate_specular_color = GL_FALSE; -GLboolean __GLEW_EXT_shadow_funcs = GL_FALSE; -GLboolean __GLEW_EXT_shared_texture_palette = GL_FALSE; -GLboolean __GLEW_EXT_stencil_clear_tag = GL_FALSE; -GLboolean __GLEW_EXT_stencil_two_side = GL_FALSE; -GLboolean __GLEW_EXT_stencil_wrap = GL_FALSE; -GLboolean __GLEW_EXT_subtexture = GL_FALSE; -GLboolean __GLEW_EXT_texture = GL_FALSE; -GLboolean __GLEW_EXT_texture3D = GL_FALSE; -GLboolean __GLEW_EXT_texture_array = GL_FALSE; -GLboolean __GLEW_EXT_texture_buffer_object = GL_FALSE; -GLboolean __GLEW_EXT_texture_compression_dxt1 = GL_FALSE; -GLboolean __GLEW_EXT_texture_compression_latc = GL_FALSE; -GLboolean __GLEW_EXT_texture_compression_rgtc = GL_FALSE; -GLboolean __GLEW_EXT_texture_compression_s3tc = GL_FALSE; -GLboolean __GLEW_EXT_texture_cube_map = GL_FALSE; -GLboolean __GLEW_EXT_texture_edge_clamp = GL_FALSE; -GLboolean __GLEW_EXT_texture_env = GL_FALSE; -GLboolean __GLEW_EXT_texture_env_add = GL_FALSE; -GLboolean __GLEW_EXT_texture_env_combine = GL_FALSE; -GLboolean __GLEW_EXT_texture_env_dot3 = GL_FALSE; -GLboolean __GLEW_EXT_texture_filter_anisotropic = GL_FALSE; -GLboolean __GLEW_EXT_texture_integer = GL_FALSE; -GLboolean __GLEW_EXT_texture_lod_bias = GL_FALSE; -GLboolean __GLEW_EXT_texture_mirror_clamp = GL_FALSE; -GLboolean __GLEW_EXT_texture_object = GL_FALSE; -GLboolean __GLEW_EXT_texture_perturb_normal = GL_FALSE; -GLboolean __GLEW_EXT_texture_rectangle = GL_FALSE; -GLboolean __GLEW_EXT_texture_sRGB = GL_FALSE; -GLboolean __GLEW_EXT_texture_shared_exponent = GL_FALSE; -GLboolean __GLEW_EXT_texture_swizzle = GL_FALSE; -GLboolean __GLEW_EXT_timer_query = GL_FALSE; -GLboolean __GLEW_EXT_transform_feedback = GL_FALSE; -GLboolean __GLEW_EXT_vertex_array = GL_FALSE; -GLboolean __GLEW_EXT_vertex_array_bgra = GL_FALSE; -GLboolean __GLEW_EXT_vertex_shader = GL_FALSE; -GLboolean __GLEW_EXT_vertex_weighting = GL_FALSE; -GLboolean __GLEW_GREMEDY_frame_terminator = GL_FALSE; -GLboolean __GLEW_GREMEDY_string_marker = GL_FALSE; -GLboolean __GLEW_HP_convolution_border_modes = GL_FALSE; -GLboolean __GLEW_HP_image_transform = GL_FALSE; -GLboolean __GLEW_HP_occlusion_test = GL_FALSE; -GLboolean __GLEW_HP_texture_lighting = GL_FALSE; -GLboolean __GLEW_IBM_cull_vertex = GL_FALSE; -GLboolean __GLEW_IBM_multimode_draw_arrays = GL_FALSE; -GLboolean __GLEW_IBM_rasterpos_clip = GL_FALSE; -GLboolean __GLEW_IBM_static_data = GL_FALSE; -GLboolean __GLEW_IBM_texture_mirrored_repeat = GL_FALSE; -GLboolean __GLEW_IBM_vertex_array_lists = GL_FALSE; -GLboolean __GLEW_INGR_color_clamp = GL_FALSE; -GLboolean __GLEW_INGR_interlace_read = GL_FALSE; -GLboolean __GLEW_INTEL_parallel_arrays = GL_FALSE; -GLboolean __GLEW_INTEL_texture_scissor = GL_FALSE; -GLboolean __GLEW_KTX_buffer_region = GL_FALSE; -GLboolean __GLEW_MESAX_texture_stack = GL_FALSE; -GLboolean __GLEW_MESA_pack_invert = GL_FALSE; -GLboolean __GLEW_MESA_resize_buffers = GL_FALSE; -GLboolean __GLEW_MESA_window_pos = GL_FALSE; -GLboolean __GLEW_MESA_ycbcr_texture = GL_FALSE; -GLboolean __GLEW_NV_blend_square = GL_FALSE; -GLboolean __GLEW_NV_conditional_render = GL_FALSE; -GLboolean __GLEW_NV_copy_depth_to_color = GL_FALSE; -GLboolean __GLEW_NV_depth_buffer_float = GL_FALSE; -GLboolean __GLEW_NV_depth_clamp = GL_FALSE; -GLboolean __GLEW_NV_depth_range_unclamped = GL_FALSE; -GLboolean __GLEW_NV_evaluators = GL_FALSE; -GLboolean __GLEW_NV_explicit_multisample = GL_FALSE; -GLboolean __GLEW_NV_fence = GL_FALSE; -GLboolean __GLEW_NV_float_buffer = GL_FALSE; -GLboolean __GLEW_NV_fog_distance = GL_FALSE; -GLboolean __GLEW_NV_fragment_program = GL_FALSE; -GLboolean __GLEW_NV_fragment_program2 = GL_FALSE; -GLboolean __GLEW_NV_fragment_program4 = GL_FALSE; -GLboolean __GLEW_NV_fragment_program_option = GL_FALSE; -GLboolean __GLEW_NV_framebuffer_multisample_coverage = GL_FALSE; -GLboolean __GLEW_NV_geometry_program4 = GL_FALSE; -GLboolean __GLEW_NV_geometry_shader4 = GL_FALSE; -GLboolean __GLEW_NV_gpu_program4 = GL_FALSE; -GLboolean __GLEW_NV_half_float = GL_FALSE; -GLboolean __GLEW_NV_light_max_exponent = GL_FALSE; -GLboolean __GLEW_NV_multisample_filter_hint = GL_FALSE; -GLboolean __GLEW_NV_occlusion_query = GL_FALSE; -GLboolean __GLEW_NV_packed_depth_stencil = GL_FALSE; -GLboolean __GLEW_NV_parameter_buffer_object = GL_FALSE; -GLboolean __GLEW_NV_pixel_data_range = GL_FALSE; -GLboolean __GLEW_NV_point_sprite = GL_FALSE; -GLboolean __GLEW_NV_present_video = GL_FALSE; -GLboolean __GLEW_NV_primitive_restart = GL_FALSE; -GLboolean __GLEW_NV_register_combiners = GL_FALSE; -GLboolean __GLEW_NV_register_combiners2 = GL_FALSE; -GLboolean __GLEW_NV_texgen_emboss = GL_FALSE; -GLboolean __GLEW_NV_texgen_reflection = GL_FALSE; -GLboolean __GLEW_NV_texture_compression_vtc = GL_FALSE; -GLboolean __GLEW_NV_texture_env_combine4 = GL_FALSE; -GLboolean __GLEW_NV_texture_expand_normal = GL_FALSE; -GLboolean __GLEW_NV_texture_rectangle = GL_FALSE; -GLboolean __GLEW_NV_texture_shader = GL_FALSE; -GLboolean __GLEW_NV_texture_shader2 = GL_FALSE; -GLboolean __GLEW_NV_texture_shader3 = GL_FALSE; -GLboolean __GLEW_NV_transform_feedback = GL_FALSE; -GLboolean __GLEW_NV_vertex_array_range = GL_FALSE; -GLboolean __GLEW_NV_vertex_array_range2 = GL_FALSE; -GLboolean __GLEW_NV_vertex_program = GL_FALSE; -GLboolean __GLEW_NV_vertex_program1_1 = GL_FALSE; -GLboolean __GLEW_NV_vertex_program2 = GL_FALSE; -GLboolean __GLEW_NV_vertex_program2_option = GL_FALSE; -GLboolean __GLEW_NV_vertex_program3 = GL_FALSE; -GLboolean __GLEW_NV_vertex_program4 = GL_FALSE; -GLboolean __GLEW_OES_byte_coordinates = GL_FALSE; -GLboolean __GLEW_OES_compressed_paletted_texture = GL_FALSE; -GLboolean __GLEW_OES_read_format = GL_FALSE; -GLboolean __GLEW_OES_single_precision = GL_FALSE; -GLboolean __GLEW_OML_interlace = GL_FALSE; -GLboolean __GLEW_OML_resample = GL_FALSE; -GLboolean __GLEW_OML_subsample = GL_FALSE; -GLboolean __GLEW_PGI_misc_hints = GL_FALSE; -GLboolean __GLEW_PGI_vertex_hints = GL_FALSE; -GLboolean __GLEW_REND_screen_coordinates = GL_FALSE; -GLboolean __GLEW_S3_s3tc = GL_FALSE; -GLboolean __GLEW_SGIS_color_range = GL_FALSE; -GLboolean __GLEW_SGIS_detail_texture = GL_FALSE; -GLboolean __GLEW_SGIS_fog_function = GL_FALSE; -GLboolean __GLEW_SGIS_generate_mipmap = GL_FALSE; -GLboolean __GLEW_SGIS_multisample = GL_FALSE; -GLboolean __GLEW_SGIS_pixel_texture = GL_FALSE; -GLboolean __GLEW_SGIS_point_line_texgen = GL_FALSE; -GLboolean __GLEW_SGIS_sharpen_texture = GL_FALSE; -GLboolean __GLEW_SGIS_texture4D = GL_FALSE; -GLboolean __GLEW_SGIS_texture_border_clamp = GL_FALSE; -GLboolean __GLEW_SGIS_texture_edge_clamp = GL_FALSE; -GLboolean __GLEW_SGIS_texture_filter4 = GL_FALSE; -GLboolean __GLEW_SGIS_texture_lod = GL_FALSE; -GLboolean __GLEW_SGIS_texture_select = GL_FALSE; -GLboolean __GLEW_SGIX_async = GL_FALSE; -GLboolean __GLEW_SGIX_async_histogram = GL_FALSE; -GLboolean __GLEW_SGIX_async_pixel = GL_FALSE; -GLboolean __GLEW_SGIX_blend_alpha_minmax = GL_FALSE; -GLboolean __GLEW_SGIX_clipmap = GL_FALSE; -GLboolean __GLEW_SGIX_convolution_accuracy = GL_FALSE; -GLboolean __GLEW_SGIX_depth_texture = GL_FALSE; -GLboolean __GLEW_SGIX_flush_raster = GL_FALSE; -GLboolean __GLEW_SGIX_fog_offset = GL_FALSE; -GLboolean __GLEW_SGIX_fog_texture = GL_FALSE; -GLboolean __GLEW_SGIX_fragment_specular_lighting = GL_FALSE; -GLboolean __GLEW_SGIX_framezoom = GL_FALSE; -GLboolean __GLEW_SGIX_interlace = GL_FALSE; -GLboolean __GLEW_SGIX_ir_instrument1 = GL_FALSE; -GLboolean __GLEW_SGIX_list_priority = GL_FALSE; -GLboolean __GLEW_SGIX_pixel_texture = GL_FALSE; -GLboolean __GLEW_SGIX_pixel_texture_bits = GL_FALSE; -GLboolean __GLEW_SGIX_reference_plane = GL_FALSE; -GLboolean __GLEW_SGIX_resample = GL_FALSE; -GLboolean __GLEW_SGIX_shadow = GL_FALSE; -GLboolean __GLEW_SGIX_shadow_ambient = GL_FALSE; -GLboolean __GLEW_SGIX_sprite = GL_FALSE; -GLboolean __GLEW_SGIX_tag_sample_buffer = GL_FALSE; -GLboolean __GLEW_SGIX_texture_add_env = GL_FALSE; -GLboolean __GLEW_SGIX_texture_coordinate_clamp = GL_FALSE; -GLboolean __GLEW_SGIX_texture_lod_bias = GL_FALSE; -GLboolean __GLEW_SGIX_texture_multi_buffer = GL_FALSE; -GLboolean __GLEW_SGIX_texture_range = GL_FALSE; -GLboolean __GLEW_SGIX_texture_scale_bias = GL_FALSE; -GLboolean __GLEW_SGIX_vertex_preclip = GL_FALSE; -GLboolean __GLEW_SGIX_vertex_preclip_hint = GL_FALSE; -GLboolean __GLEW_SGIX_ycrcb = GL_FALSE; -GLboolean __GLEW_SGI_color_matrix = GL_FALSE; -GLboolean __GLEW_SGI_color_table = GL_FALSE; -GLboolean __GLEW_SGI_texture_color_table = GL_FALSE; -GLboolean __GLEW_SUNX_constant_data = GL_FALSE; -GLboolean __GLEW_SUN_convolution_border_modes = GL_FALSE; -GLboolean __GLEW_SUN_global_alpha = GL_FALSE; -GLboolean __GLEW_SUN_mesh_array = GL_FALSE; -GLboolean __GLEW_SUN_read_video_pixels = GL_FALSE; -GLboolean __GLEW_SUN_slice_accum = GL_FALSE; -GLboolean __GLEW_SUN_triangle_list = GL_FALSE; -GLboolean __GLEW_SUN_vertex = GL_FALSE; -GLboolean __GLEW_WIN_phong_shading = GL_FALSE; -GLboolean __GLEW_WIN_specular_fog = GL_FALSE; -GLboolean __GLEW_WIN_swap_hint = GL_FALSE; - -#endif /* !GLEW_MX */ - -#ifdef GL_VERSION_1_2 - -static GLboolean _glewInit_GL_VERSION_1_2 (GLEW_CONTEXT_ARG_DEF_INIT) -{ - GLboolean r = GL_FALSE; - - r = ((glCopyTexSubImage3D = (PFNGLCOPYTEXSUBIMAGE3DPROC)glewGetProcAddress((const GLubyte*)"glCopyTexSubImage3D")) == NULL) || r; - r = ((glDrawRangeElements = (PFNGLDRAWRANGEELEMENTSPROC)glewGetProcAddress((const GLubyte*)"glDrawRangeElements")) == NULL) || r; - r = ((glTexImage3D = (PFNGLTEXIMAGE3DPROC)glewGetProcAddress((const GLubyte*)"glTexImage3D")) == NULL) || r; - r = ((glTexSubImage3D = (PFNGLTEXSUBIMAGE3DPROC)glewGetProcAddress((const GLubyte*)"glTexSubImage3D")) == NULL) || r; - - return r; -} - -#endif /* GL_VERSION_1_2 */ - -#ifdef GL_VERSION_1_3 - -static GLboolean _glewInit_GL_VERSION_1_3 (GLEW_CONTEXT_ARG_DEF_INIT) -{ - GLboolean r = GL_FALSE; - - r = ((glActiveTexture = (PFNGLACTIVETEXTUREPROC)glewGetProcAddress((const GLubyte*)"glActiveTexture")) == NULL) || r; - r = ((glClientActiveTexture = (PFNGLCLIENTACTIVETEXTUREPROC)glewGetProcAddress((const GLubyte*)"glClientActiveTexture")) == NULL) || r; - r = ((glCompressedTexImage1D = (PFNGLCOMPRESSEDTEXIMAGE1DPROC)glewGetProcAddress((const GLubyte*)"glCompressedTexImage1D")) == NULL) || r; - r = ((glCompressedTexImage2D = (PFNGLCOMPRESSEDTEXIMAGE2DPROC)glewGetProcAddress((const GLubyte*)"glCompressedTexImage2D")) == NULL) || r; - r = ((glCompressedTexImage3D = (PFNGLCOMPRESSEDTEXIMAGE3DPROC)glewGetProcAddress((const GLubyte*)"glCompressedTexImage3D")) == NULL) || r; - r = ((glCompressedTexSubImage1D = (PFNGLCOMPRESSEDTEXSUBIMAGE1DPROC)glewGetProcAddress((const GLubyte*)"glCompressedTexSubImage1D")) == NULL) || r; - r = ((glCompressedTexSubImage2D = (PFNGLCOMPRESSEDTEXSUBIMAGE2DPROC)glewGetProcAddress((const GLubyte*)"glCompressedTexSubImage2D")) == NULL) || r; - r = ((glCompressedTexSubImage3D = (PFNGLCOMPRESSEDTEXSUBIMAGE3DPROC)glewGetProcAddress((const GLubyte*)"glCompressedTexSubImage3D")) == NULL) || r; - r = ((glGetCompressedTexImage = (PFNGLGETCOMPRESSEDTEXIMAGEPROC)glewGetProcAddress((const GLubyte*)"glGetCompressedTexImage")) == NULL) || r; - r = ((glLoadTransposeMatrixd = (PFNGLLOADTRANSPOSEMATRIXDPROC)glewGetProcAddress((const GLubyte*)"glLoadTransposeMatrixd")) == NULL) || r; - r = ((glLoadTransposeMatrixf = (PFNGLLOADTRANSPOSEMATRIXFPROC)glewGetProcAddress((const GLubyte*)"glLoadTransposeMatrixf")) == NULL) || r; - r = ((glMultTransposeMatrixd = (PFNGLMULTTRANSPOSEMATRIXDPROC)glewGetProcAddress((const GLubyte*)"glMultTransposeMatrixd")) == NULL) || r; - r = ((glMultTransposeMatrixf = (PFNGLMULTTRANSPOSEMATRIXFPROC)glewGetProcAddress((const GLubyte*)"glMultTransposeMatrixf")) == NULL) || r; - r = ((glMultiTexCoord1d = (PFNGLMULTITEXCOORD1DPROC)glewGetProcAddress((const GLubyte*)"glMultiTexCoord1d")) == NULL) || r; - r = ((glMultiTexCoord1dv = (PFNGLMULTITEXCOORD1DVPROC)glewGetProcAddress((const GLubyte*)"glMultiTexCoord1dv")) == NULL) || r; - r = ((glMultiTexCoord1f = (PFNGLMULTITEXCOORD1FPROC)glewGetProcAddress((const GLubyte*)"glMultiTexCoord1f")) == NULL) || r; - r = ((glMultiTexCoord1fv = (PFNGLMULTITEXCOORD1FVPROC)glewGetProcAddress((const GLubyte*)"glMultiTexCoord1fv")) == NULL) || r; - r = ((glMultiTexCoord1i = (PFNGLMULTITEXCOORD1IPROC)glewGetProcAddress((const GLubyte*)"glMultiTexCoord1i")) == NULL) || r; - r = ((glMultiTexCoord1iv = (PFNGLMULTITEXCOORD1IVPROC)glewGetProcAddress((const GLubyte*)"glMultiTexCoord1iv")) == NULL) || r; - r = ((glMultiTexCoord1s = (PFNGLMULTITEXCOORD1SPROC)glewGetProcAddress((const GLubyte*)"glMultiTexCoord1s")) == NULL) || r; - r = ((glMultiTexCoord1sv = (PFNGLMULTITEXCOORD1SVPROC)glewGetProcAddress((const GLubyte*)"glMultiTexCoord1sv")) == NULL) || r; - r = ((glMultiTexCoord2d = (PFNGLMULTITEXCOORD2DPROC)glewGetProcAddress((const GLubyte*)"glMultiTexCoord2d")) == NULL) || r; - r = ((glMultiTexCoord2dv = (PFNGLMULTITEXCOORD2DVPROC)glewGetProcAddress((const GLubyte*)"glMultiTexCoord2dv")) == NULL) || r; - r = ((glMultiTexCoord2f = (PFNGLMULTITEXCOORD2FPROC)glewGetProcAddress((const GLubyte*)"glMultiTexCoord2f")) == NULL) || r; - r = ((glMultiTexCoord2fv = (PFNGLMULTITEXCOORD2FVPROC)glewGetProcAddress((const GLubyte*)"glMultiTexCoord2fv")) == NULL) || r; - r = ((glMultiTexCoord2i = (PFNGLMULTITEXCOORD2IPROC)glewGetProcAddress((const GLubyte*)"glMultiTexCoord2i")) == NULL) || r; - r = ((glMultiTexCoord2iv = (PFNGLMULTITEXCOORD2IVPROC)glewGetProcAddress((const GLubyte*)"glMultiTexCoord2iv")) == NULL) || r; - r = ((glMultiTexCoord2s = (PFNGLMULTITEXCOORD2SPROC)glewGetProcAddress((const GLubyte*)"glMultiTexCoord2s")) == NULL) || r; - r = ((glMultiTexCoord2sv = (PFNGLMULTITEXCOORD2SVPROC)glewGetProcAddress((const GLubyte*)"glMultiTexCoord2sv")) == NULL) || r; - r = ((glMultiTexCoord3d = (PFNGLMULTITEXCOORD3DPROC)glewGetProcAddress((const GLubyte*)"glMultiTexCoord3d")) == NULL) || r; - r = ((glMultiTexCoord3dv = (PFNGLMULTITEXCOORD3DVPROC)glewGetProcAddress((const GLubyte*)"glMultiTexCoord3dv")) == NULL) || r; - r = ((glMultiTexCoord3f = (PFNGLMULTITEXCOORD3FPROC)glewGetProcAddress((const GLubyte*)"glMultiTexCoord3f")) == NULL) || r; - r = ((glMultiTexCoord3fv = (PFNGLMULTITEXCOORD3FVPROC)glewGetProcAddress((const GLubyte*)"glMultiTexCoord3fv")) == NULL) || r; - r = ((glMultiTexCoord3i = (PFNGLMULTITEXCOORD3IPROC)glewGetProcAddress((const GLubyte*)"glMultiTexCoord3i")) == NULL) || r; - r = ((glMultiTexCoord3iv = (PFNGLMULTITEXCOORD3IVPROC)glewGetProcAddress((const GLubyte*)"glMultiTexCoord3iv")) == NULL) || r; - r = ((glMultiTexCoord3s = (PFNGLMULTITEXCOORD3SPROC)glewGetProcAddress((const GLubyte*)"glMultiTexCoord3s")) == NULL) || r; - r = ((glMultiTexCoord3sv = (PFNGLMULTITEXCOORD3SVPROC)glewGetProcAddress((const GLubyte*)"glMultiTexCoord3sv")) == NULL) || r; - r = ((glMultiTexCoord4d = (PFNGLMULTITEXCOORD4DPROC)glewGetProcAddress((const GLubyte*)"glMultiTexCoord4d")) == NULL) || r; - r = ((glMultiTexCoord4dv = (PFNGLMULTITEXCOORD4DVPROC)glewGetProcAddress((const GLubyte*)"glMultiTexCoord4dv")) == NULL) || r; - r = ((glMultiTexCoord4f = (PFNGLMULTITEXCOORD4FPROC)glewGetProcAddress((const GLubyte*)"glMultiTexCoord4f")) == NULL) || r; - r = ((glMultiTexCoord4fv = (PFNGLMULTITEXCOORD4FVPROC)glewGetProcAddress((const GLubyte*)"glMultiTexCoord4fv")) == NULL) || r; - r = ((glMultiTexCoord4i = (PFNGLMULTITEXCOORD4IPROC)glewGetProcAddress((const GLubyte*)"glMultiTexCoord4i")) == NULL) || r; - r = ((glMultiTexCoord4iv = (PFNGLMULTITEXCOORD4IVPROC)glewGetProcAddress((const GLubyte*)"glMultiTexCoord4iv")) == NULL) || r; - r = ((glMultiTexCoord4s = (PFNGLMULTITEXCOORD4SPROC)glewGetProcAddress((const GLubyte*)"glMultiTexCoord4s")) == NULL) || r; - r = ((glMultiTexCoord4sv = (PFNGLMULTITEXCOORD4SVPROC)glewGetProcAddress((const GLubyte*)"glMultiTexCoord4sv")) == NULL) || r; - r = ((glSampleCoverage = (PFNGLSAMPLECOVERAGEPROC)glewGetProcAddress((const GLubyte*)"glSampleCoverage")) == NULL) || r; - - return r; -} - -#endif /* GL_VERSION_1_3 */ - -#ifdef GL_VERSION_1_4 - -static GLboolean _glewInit_GL_VERSION_1_4 (GLEW_CONTEXT_ARG_DEF_INIT) -{ - GLboolean r = GL_FALSE; - - r = ((glBlendColor = (PFNGLBLENDCOLORPROC)glewGetProcAddress((const GLubyte*)"glBlendColor")) == NULL) || r; - r = ((glBlendEquation = (PFNGLBLENDEQUATIONPROC)glewGetProcAddress((const GLubyte*)"glBlendEquation")) == NULL) || r; - r = ((glBlendFuncSeparate = (PFNGLBLENDFUNCSEPARATEPROC)glewGetProcAddress((const GLubyte*)"glBlendFuncSeparate")) == NULL) || r; - r = ((glFogCoordPointer = (PFNGLFOGCOORDPOINTERPROC)glewGetProcAddress((const GLubyte*)"glFogCoordPointer")) == NULL) || r; - r = ((glFogCoordd = (PFNGLFOGCOORDDPROC)glewGetProcAddress((const GLubyte*)"glFogCoordd")) == NULL) || r; - r = ((glFogCoorddv = (PFNGLFOGCOORDDVPROC)glewGetProcAddress((const GLubyte*)"glFogCoorddv")) == NULL) || r; - r = ((glFogCoordf = (PFNGLFOGCOORDFPROC)glewGetProcAddress((const GLubyte*)"glFogCoordf")) == NULL) || r; - r = ((glFogCoordfv = (PFNGLFOGCOORDFVPROC)glewGetProcAddress((const GLubyte*)"glFogCoordfv")) == NULL) || r; - r = ((glMultiDrawArrays = (PFNGLMULTIDRAWARRAYSPROC)glewGetProcAddress((const GLubyte*)"glMultiDrawArrays")) == NULL) || r; - r = ((glMultiDrawElements = (PFNGLMULTIDRAWELEMENTSPROC)glewGetProcAddress((const GLubyte*)"glMultiDrawElements")) == NULL) || r; - r = ((glPointParameterf = (PFNGLPOINTPARAMETERFPROC)glewGetProcAddress((const GLubyte*)"glPointParameterf")) == NULL) || r; - r = ((glPointParameterfv = (PFNGLPOINTPARAMETERFVPROC)glewGetProcAddress((const GLubyte*)"glPointParameterfv")) == NULL) || r; - r = ((glPointParameteri = (PFNGLPOINTPARAMETERIPROC)glewGetProcAddress((const GLubyte*)"glPointParameteri")) == NULL) || r; - r = ((glPointParameteriv = (PFNGLPOINTPARAMETERIVPROC)glewGetProcAddress((const GLubyte*)"glPointParameteriv")) == NULL) || r; - r = ((glSecondaryColor3b = (PFNGLSECONDARYCOLOR3BPROC)glewGetProcAddress((const GLubyte*)"glSecondaryColor3b")) == NULL) || r; - r = ((glSecondaryColor3bv = (PFNGLSECONDARYCOLOR3BVPROC)glewGetProcAddress((const GLubyte*)"glSecondaryColor3bv")) == NULL) || r; - r = ((glSecondaryColor3d = (PFNGLSECONDARYCOLOR3DPROC)glewGetProcAddress((const GLubyte*)"glSecondaryColor3d")) == NULL) || r; - r = ((glSecondaryColor3dv = (PFNGLSECONDARYCOLOR3DVPROC)glewGetProcAddress((const GLubyte*)"glSecondaryColor3dv")) == NULL) || r; - r = ((glSecondaryColor3f = (PFNGLSECONDARYCOLOR3FPROC)glewGetProcAddress((const GLubyte*)"glSecondaryColor3f")) == NULL) || r; - r = ((glSecondaryColor3fv = (PFNGLSECONDARYCOLOR3FVPROC)glewGetProcAddress((const GLubyte*)"glSecondaryColor3fv")) == NULL) || r; - r = ((glSecondaryColor3i = (PFNGLSECONDARYCOLOR3IPROC)glewGetProcAddress((const GLubyte*)"glSecondaryColor3i")) == NULL) || r; - r = ((glSecondaryColor3iv = (PFNGLSECONDARYCOLOR3IVPROC)glewGetProcAddress((const GLubyte*)"glSecondaryColor3iv")) == NULL) || r; - r = ((glSecondaryColor3s = (PFNGLSECONDARYCOLOR3SPROC)glewGetProcAddress((const GLubyte*)"glSecondaryColor3s")) == NULL) || r; - r = ((glSecondaryColor3sv = (PFNGLSECONDARYCOLOR3SVPROC)glewGetProcAddress((const GLubyte*)"glSecondaryColor3sv")) == NULL) || r; - r = ((glSecondaryColor3ub = (PFNGLSECONDARYCOLOR3UBPROC)glewGetProcAddress((const GLubyte*)"glSecondaryColor3ub")) == NULL) || r; - r = ((glSecondaryColor3ubv = (PFNGLSECONDARYCOLOR3UBVPROC)glewGetProcAddress((const GLubyte*)"glSecondaryColor3ubv")) == NULL) || r; - r = ((glSecondaryColor3ui = (PFNGLSECONDARYCOLOR3UIPROC)glewGetProcAddress((const GLubyte*)"glSecondaryColor3ui")) == NULL) || r; - r = ((glSecondaryColor3uiv = (PFNGLSECONDARYCOLOR3UIVPROC)glewGetProcAddress((const GLubyte*)"glSecondaryColor3uiv")) == NULL) || r; - r = ((glSecondaryColor3us = (PFNGLSECONDARYCOLOR3USPROC)glewGetProcAddress((const GLubyte*)"glSecondaryColor3us")) == NULL) || r; - r = ((glSecondaryColor3usv = (PFNGLSECONDARYCOLOR3USVPROC)glewGetProcAddress((const GLubyte*)"glSecondaryColor3usv")) == NULL) || r; - r = ((glSecondaryColorPointer = (PFNGLSECONDARYCOLORPOINTERPROC)glewGetProcAddress((const GLubyte*)"glSecondaryColorPointer")) == NULL) || r; - r = ((glWindowPos2d = (PFNGLWINDOWPOS2DPROC)glewGetProcAddress((const GLubyte*)"glWindowPos2d")) == NULL) || r; - r = ((glWindowPos2dv = (PFNGLWINDOWPOS2DVPROC)glewGetProcAddress((const GLubyte*)"glWindowPos2dv")) == NULL) || r; - r = ((glWindowPos2f = (PFNGLWINDOWPOS2FPROC)glewGetProcAddress((const GLubyte*)"glWindowPos2f")) == NULL) || r; - r = ((glWindowPos2fv = (PFNGLWINDOWPOS2FVPROC)glewGetProcAddress((const GLubyte*)"glWindowPos2fv")) == NULL) || r; - r = ((glWindowPos2i = (PFNGLWINDOWPOS2IPROC)glewGetProcAddress((const GLubyte*)"glWindowPos2i")) == NULL) || r; - r = ((glWindowPos2iv = (PFNGLWINDOWPOS2IVPROC)glewGetProcAddress((const GLubyte*)"glWindowPos2iv")) == NULL) || r; - r = ((glWindowPos2s = (PFNGLWINDOWPOS2SPROC)glewGetProcAddress((const GLubyte*)"glWindowPos2s")) == NULL) || r; - r = ((glWindowPos2sv = (PFNGLWINDOWPOS2SVPROC)glewGetProcAddress((const GLubyte*)"glWindowPos2sv")) == NULL) || r; - r = ((glWindowPos3d = (PFNGLWINDOWPOS3DPROC)glewGetProcAddress((const GLubyte*)"glWindowPos3d")) == NULL) || r; - r = ((glWindowPos3dv = (PFNGLWINDOWPOS3DVPROC)glewGetProcAddress((const GLubyte*)"glWindowPos3dv")) == NULL) || r; - r = ((glWindowPos3f = (PFNGLWINDOWPOS3FPROC)glewGetProcAddress((const GLubyte*)"glWindowPos3f")) == NULL) || r; - r = ((glWindowPos3fv = (PFNGLWINDOWPOS3FVPROC)glewGetProcAddress((const GLubyte*)"glWindowPos3fv")) == NULL) || r; - r = ((glWindowPos3i = (PFNGLWINDOWPOS3IPROC)glewGetProcAddress((const GLubyte*)"glWindowPos3i")) == NULL) || r; - r = ((glWindowPos3iv = (PFNGLWINDOWPOS3IVPROC)glewGetProcAddress((const GLubyte*)"glWindowPos3iv")) == NULL) || r; - r = ((glWindowPos3s = (PFNGLWINDOWPOS3SPROC)glewGetProcAddress((const GLubyte*)"glWindowPos3s")) == NULL) || r; - r = ((glWindowPos3sv = (PFNGLWINDOWPOS3SVPROC)glewGetProcAddress((const GLubyte*)"glWindowPos3sv")) == NULL) || r; - - return r; -} - -#endif /* GL_VERSION_1_4 */ - -#ifdef GL_VERSION_1_5 - -static GLboolean _glewInit_GL_VERSION_1_5 (GLEW_CONTEXT_ARG_DEF_INIT) -{ - GLboolean r = GL_FALSE; - - r = ((glBeginQuery = (PFNGLBEGINQUERYPROC)glewGetProcAddress((const GLubyte*)"glBeginQuery")) == NULL) || r; - r = ((glBindBuffer = (PFNGLBINDBUFFERPROC)glewGetProcAddress((const GLubyte*)"glBindBuffer")) == NULL) || r; - r = ((glBufferData = (PFNGLBUFFERDATAPROC)glewGetProcAddress((const GLubyte*)"glBufferData")) == NULL) || r; - r = ((glBufferSubData = (PFNGLBUFFERSUBDATAPROC)glewGetProcAddress((const GLubyte*)"glBufferSubData")) == NULL) || r; - r = ((glDeleteBuffers = (PFNGLDELETEBUFFERSPROC)glewGetProcAddress((const GLubyte*)"glDeleteBuffers")) == NULL) || r; - r = ((glDeleteQueries = (PFNGLDELETEQUERIESPROC)glewGetProcAddress((const GLubyte*)"glDeleteQueries")) == NULL) || r; - r = ((glEndQuery = (PFNGLENDQUERYPROC)glewGetProcAddress((const GLubyte*)"glEndQuery")) == NULL) || r; - r = ((glGenBuffers = (PFNGLGENBUFFERSPROC)glewGetProcAddress((const GLubyte*)"glGenBuffers")) == NULL) || r; - r = ((glGenQueries = (PFNGLGENQUERIESPROC)glewGetProcAddress((const GLubyte*)"glGenQueries")) == NULL) || r; - r = ((glGetBufferParameteriv = (PFNGLGETBUFFERPARAMETERIVPROC)glewGetProcAddress((const GLubyte*)"glGetBufferParameteriv")) == NULL) || r; - r = ((glGetBufferPointerv = (PFNGLGETBUFFERPOINTERVPROC)glewGetProcAddress((const GLubyte*)"glGetBufferPointerv")) == NULL) || r; - r = ((glGetBufferSubData = (PFNGLGETBUFFERSUBDATAPROC)glewGetProcAddress((const GLubyte*)"glGetBufferSubData")) == NULL) || r; - r = ((glGetQueryObjectiv = (PFNGLGETQUERYOBJECTIVPROC)glewGetProcAddress((const GLubyte*)"glGetQueryObjectiv")) == NULL) || r; - r = ((glGetQueryObjectuiv = (PFNGLGETQUERYOBJECTUIVPROC)glewGetProcAddress((const GLubyte*)"glGetQueryObjectuiv")) == NULL) || r; - r = ((glGetQueryiv = (PFNGLGETQUERYIVPROC)glewGetProcAddress((const GLubyte*)"glGetQueryiv")) == NULL) || r; - r = ((glIsBuffer = (PFNGLISBUFFERPROC)glewGetProcAddress((const GLubyte*)"glIsBuffer")) == NULL) || r; - r = ((glIsQuery = (PFNGLISQUERYPROC)glewGetProcAddress((const GLubyte*)"glIsQuery")) == NULL) || r; - r = ((glMapBuffer = (PFNGLMAPBUFFERPROC)glewGetProcAddress((const GLubyte*)"glMapBuffer")) == NULL) || r; - r = ((glUnmapBuffer = (PFNGLUNMAPBUFFERPROC)glewGetProcAddress((const GLubyte*)"glUnmapBuffer")) == NULL) || r; - - return r; -} - -#endif /* GL_VERSION_1_5 */ - -#ifdef GL_VERSION_2_0 - -static GLboolean _glewInit_GL_VERSION_2_0 (GLEW_CONTEXT_ARG_DEF_INIT) -{ - GLboolean r = GL_FALSE; - - r = ((glAttachShader = (PFNGLATTACHSHADERPROC)glewGetProcAddress((const GLubyte*)"glAttachShader")) == NULL) || r; - r = ((glBindAttribLocation = (PFNGLBINDATTRIBLOCATIONPROC)glewGetProcAddress((const GLubyte*)"glBindAttribLocation")) == NULL) || r; - r = ((glBlendEquationSeparate = (PFNGLBLENDEQUATIONSEPARATEPROC)glewGetProcAddress((const GLubyte*)"glBlendEquationSeparate")) == NULL) || r; - r = ((glCompileShader = (PFNGLCOMPILESHADERPROC)glewGetProcAddress((const GLubyte*)"glCompileShader")) == NULL) || r; - r = ((glCreateProgram = (PFNGLCREATEPROGRAMPROC)glewGetProcAddress((const GLubyte*)"glCreateProgram")) == NULL) || r; - r = ((glCreateShader = (PFNGLCREATESHADERPROC)glewGetProcAddress((const GLubyte*)"glCreateShader")) == NULL) || r; - r = ((glDeleteProgram = (PFNGLDELETEPROGRAMPROC)glewGetProcAddress((const GLubyte*)"glDeleteProgram")) == NULL) || r; - r = ((glDeleteShader = (PFNGLDELETESHADERPROC)glewGetProcAddress((const GLubyte*)"glDeleteShader")) == NULL) || r; - r = ((glDetachShader = (PFNGLDETACHSHADERPROC)glewGetProcAddress((const GLubyte*)"glDetachShader")) == NULL) || r; - r = ((glDisableVertexAttribArray = (PFNGLDISABLEVERTEXATTRIBARRAYPROC)glewGetProcAddress((const GLubyte*)"glDisableVertexAttribArray")) == NULL) || r; - r = ((glDrawBuffers = (PFNGLDRAWBUFFERSPROC)glewGetProcAddress((const GLubyte*)"glDrawBuffers")) == NULL) || r; - r = ((glEnableVertexAttribArray = (PFNGLENABLEVERTEXATTRIBARRAYPROC)glewGetProcAddress((const GLubyte*)"glEnableVertexAttribArray")) == NULL) || r; - r = ((glGetActiveAttrib = (PFNGLGETACTIVEATTRIBPROC)glewGetProcAddress((const GLubyte*)"glGetActiveAttrib")) == NULL) || r; - r = ((glGetActiveUniform = (PFNGLGETACTIVEUNIFORMPROC)glewGetProcAddress((const GLubyte*)"glGetActiveUniform")) == NULL) || r; - r = ((glGetAttachedShaders = (PFNGLGETATTACHEDSHADERSPROC)glewGetProcAddress((const GLubyte*)"glGetAttachedShaders")) == NULL) || r; - r = ((glGetAttribLocation = (PFNGLGETATTRIBLOCATIONPROC)glewGetProcAddress((const GLubyte*)"glGetAttribLocation")) == NULL) || r; - r = ((glGetProgramInfoLog = (PFNGLGETPROGRAMINFOLOGPROC)glewGetProcAddress((const GLubyte*)"glGetProgramInfoLog")) == NULL) || r; - r = ((glGetProgramiv = (PFNGLGETPROGRAMIVPROC)glewGetProcAddress((const GLubyte*)"glGetProgramiv")) == NULL) || r; - r = ((glGetShaderInfoLog = (PFNGLGETSHADERINFOLOGPROC)glewGetProcAddress((const GLubyte*)"glGetShaderInfoLog")) == NULL) || r; - r = ((glGetShaderSource = (PFNGLGETSHADERSOURCEPROC)glewGetProcAddress((const GLubyte*)"glGetShaderSource")) == NULL) || r; - r = ((glGetShaderiv = (PFNGLGETSHADERIVPROC)glewGetProcAddress((const GLubyte*)"glGetShaderiv")) == NULL) || r; - r = ((glGetUniformLocation = (PFNGLGETUNIFORMLOCATIONPROC)glewGetProcAddress((const GLubyte*)"glGetUniformLocation")) == NULL) || r; - r = ((glGetUniformfv = (PFNGLGETUNIFORMFVPROC)glewGetProcAddress((const GLubyte*)"glGetUniformfv")) == NULL) || r; - r = ((glGetUniformiv = (PFNGLGETUNIFORMIVPROC)glewGetProcAddress((const GLubyte*)"glGetUniformiv")) == NULL) || r; - r = ((glGetVertexAttribPointerv = (PFNGLGETVERTEXATTRIBPOINTERVPROC)glewGetProcAddress((const GLubyte*)"glGetVertexAttribPointerv")) == NULL) || r; - r = ((glGetVertexAttribdv = (PFNGLGETVERTEXATTRIBDVPROC)glewGetProcAddress((const GLubyte*)"glGetVertexAttribdv")) == NULL) || r; - r = ((glGetVertexAttribfv = (PFNGLGETVERTEXATTRIBFVPROC)glewGetProcAddress((const GLubyte*)"glGetVertexAttribfv")) == NULL) || r; - r = ((glGetVertexAttribiv = (PFNGLGETVERTEXATTRIBIVPROC)glewGetProcAddress((const GLubyte*)"glGetVertexAttribiv")) == NULL) || r; - r = ((glIsProgram = (PFNGLISPROGRAMPROC)glewGetProcAddress((const GLubyte*)"glIsProgram")) == NULL) || r; - r = ((glIsShader = (PFNGLISSHADERPROC)glewGetProcAddress((const GLubyte*)"glIsShader")) == NULL) || r; - r = ((glLinkProgram = (PFNGLLINKPROGRAMPROC)glewGetProcAddress((const GLubyte*)"glLinkProgram")) == NULL) || r; - r = ((glShaderSource = (PFNGLSHADERSOURCEPROC)glewGetProcAddress((const GLubyte*)"glShaderSource")) == NULL) || r; - r = ((glStencilFuncSeparate = (PFNGLSTENCILFUNCSEPARATEPROC)glewGetProcAddress((const GLubyte*)"glStencilFuncSeparate")) == NULL) || r; - r = ((glStencilMaskSeparate = (PFNGLSTENCILMASKSEPARATEPROC)glewGetProcAddress((const GLubyte*)"glStencilMaskSeparate")) == NULL) || r; - r = ((glStencilOpSeparate = (PFNGLSTENCILOPSEPARATEPROC)glewGetProcAddress((const GLubyte*)"glStencilOpSeparate")) == NULL) || r; - r = ((glUniform1f = (PFNGLUNIFORM1FPROC)glewGetProcAddress((const GLubyte*)"glUniform1f")) == NULL) || r; - r = ((glUniform1fv = (PFNGLUNIFORM1FVPROC)glewGetProcAddress((const GLubyte*)"glUniform1fv")) == NULL) || r; - r = ((glUniform1i = (PFNGLUNIFORM1IPROC)glewGetProcAddress((const GLubyte*)"glUniform1i")) == NULL) || r; - r = ((glUniform1iv = (PFNGLUNIFORM1IVPROC)glewGetProcAddress((const GLubyte*)"glUniform1iv")) == NULL) || r; - r = ((glUniform2f = (PFNGLUNIFORM2FPROC)glewGetProcAddress((const GLubyte*)"glUniform2f")) == NULL) || r; - r = ((glUniform2fv = (PFNGLUNIFORM2FVPROC)glewGetProcAddress((const GLubyte*)"glUniform2fv")) == NULL) || r; - r = ((glUniform2i = (PFNGLUNIFORM2IPROC)glewGetProcAddress((const GLubyte*)"glUniform2i")) == NULL) || r; - r = ((glUniform2iv = (PFNGLUNIFORM2IVPROC)glewGetProcAddress((const GLubyte*)"glUniform2iv")) == NULL) || r; - r = ((glUniform3f = (PFNGLUNIFORM3FPROC)glewGetProcAddress((const GLubyte*)"glUniform3f")) == NULL) || r; - r = ((glUniform3fv = (PFNGLUNIFORM3FVPROC)glewGetProcAddress((const GLubyte*)"glUniform3fv")) == NULL) || r; - r = ((glUniform3i = (PFNGLUNIFORM3IPROC)glewGetProcAddress((const GLubyte*)"glUniform3i")) == NULL) || r; - r = ((glUniform3iv = (PFNGLUNIFORM3IVPROC)glewGetProcAddress((const GLubyte*)"glUniform3iv")) == NULL) || r; - r = ((glUniform4f = (PFNGLUNIFORM4FPROC)glewGetProcAddress((const GLubyte*)"glUniform4f")) == NULL) || r; - r = ((glUniform4fv = (PFNGLUNIFORM4FVPROC)glewGetProcAddress((const GLubyte*)"glUniform4fv")) == NULL) || r; - r = ((glUniform4i = (PFNGLUNIFORM4IPROC)glewGetProcAddress((const GLubyte*)"glUniform4i")) == NULL) || r; - r = ((glUniform4iv = (PFNGLUNIFORM4IVPROC)glewGetProcAddress((const GLubyte*)"glUniform4iv")) == NULL) || r; - r = ((glUniformMatrix2fv = (PFNGLUNIFORMMATRIX2FVPROC)glewGetProcAddress((const GLubyte*)"glUniformMatrix2fv")) == NULL) || r; - r = ((glUniformMatrix3fv = (PFNGLUNIFORMMATRIX3FVPROC)glewGetProcAddress((const GLubyte*)"glUniformMatrix3fv")) == NULL) || r; - r = ((glUniformMatrix4fv = (PFNGLUNIFORMMATRIX4FVPROC)glewGetProcAddress((const GLubyte*)"glUniformMatrix4fv")) == NULL) || r; - r = ((glUseProgram = (PFNGLUSEPROGRAMPROC)glewGetProcAddress((const GLubyte*)"glUseProgram")) == NULL) || r; - r = ((glValidateProgram = (PFNGLVALIDATEPROGRAMPROC)glewGetProcAddress((const GLubyte*)"glValidateProgram")) == NULL) || r; - r = ((glVertexAttrib1d = (PFNGLVERTEXATTRIB1DPROC)glewGetProcAddress((const GLubyte*)"glVertexAttrib1d")) == NULL) || r; - r = ((glVertexAttrib1dv = (PFNGLVERTEXATTRIB1DVPROC)glewGetProcAddress((const GLubyte*)"glVertexAttrib1dv")) == NULL) || r; - r = ((glVertexAttrib1f = (PFNGLVERTEXATTRIB1FPROC)glewGetProcAddress((const GLubyte*)"glVertexAttrib1f")) == NULL) || r; - r = ((glVertexAttrib1fv = (PFNGLVERTEXATTRIB1FVPROC)glewGetProcAddress((const GLubyte*)"glVertexAttrib1fv")) == NULL) || r; - r = ((glVertexAttrib1s = (PFNGLVERTEXATTRIB1SPROC)glewGetProcAddress((const GLubyte*)"glVertexAttrib1s")) == NULL) || r; - r = ((glVertexAttrib1sv = (PFNGLVERTEXATTRIB1SVPROC)glewGetProcAddress((const GLubyte*)"glVertexAttrib1sv")) == NULL) || r; - r = ((glVertexAttrib2d = (PFNGLVERTEXATTRIB2DPROC)glewGetProcAddress((const GLubyte*)"glVertexAttrib2d")) == NULL) || r; - r = ((glVertexAttrib2dv = (PFNGLVERTEXATTRIB2DVPROC)glewGetProcAddress((const GLubyte*)"glVertexAttrib2dv")) == NULL) || r; - r = ((glVertexAttrib2f = (PFNGLVERTEXATTRIB2FPROC)glewGetProcAddress((const GLubyte*)"glVertexAttrib2f")) == NULL) || r; - r = ((glVertexAttrib2fv = (PFNGLVERTEXATTRIB2FVPROC)glewGetProcAddress((const GLubyte*)"glVertexAttrib2fv")) == NULL) || r; - r = ((glVertexAttrib2s = (PFNGLVERTEXATTRIB2SPROC)glewGetProcAddress((const GLubyte*)"glVertexAttrib2s")) == NULL) || r; - r = ((glVertexAttrib2sv = (PFNGLVERTEXATTRIB2SVPROC)glewGetProcAddress((const GLubyte*)"glVertexAttrib2sv")) == NULL) || r; - r = ((glVertexAttrib3d = (PFNGLVERTEXATTRIB3DPROC)glewGetProcAddress((const GLubyte*)"glVertexAttrib3d")) == NULL) || r; - r = ((glVertexAttrib3dv = (PFNGLVERTEXATTRIB3DVPROC)glewGetProcAddress((const GLubyte*)"glVertexAttrib3dv")) == NULL) || r; - r = ((glVertexAttrib3f = (PFNGLVERTEXATTRIB3FPROC)glewGetProcAddress((const GLubyte*)"glVertexAttrib3f")) == NULL) || r; - r = ((glVertexAttrib3fv = (PFNGLVERTEXATTRIB3FVPROC)glewGetProcAddress((const GLubyte*)"glVertexAttrib3fv")) == NULL) || r; - r = ((glVertexAttrib3s = (PFNGLVERTEXATTRIB3SPROC)glewGetProcAddress((const GLubyte*)"glVertexAttrib3s")) == NULL) || r; - r = ((glVertexAttrib3sv = (PFNGLVERTEXATTRIB3SVPROC)glewGetProcAddress((const GLubyte*)"glVertexAttrib3sv")) == NULL) || r; - r = ((glVertexAttrib4Nbv = (PFNGLVERTEXATTRIB4NBVPROC)glewGetProcAddress((const GLubyte*)"glVertexAttrib4Nbv")) == NULL) || r; - r = ((glVertexAttrib4Niv = (PFNGLVERTEXATTRIB4NIVPROC)glewGetProcAddress((const GLubyte*)"glVertexAttrib4Niv")) == NULL) || r; - r = ((glVertexAttrib4Nsv = (PFNGLVERTEXATTRIB4NSVPROC)glewGetProcAddress((const GLubyte*)"glVertexAttrib4Nsv")) == NULL) || r; - r = ((glVertexAttrib4Nub = (PFNGLVERTEXATTRIB4NUBPROC)glewGetProcAddress((const GLubyte*)"glVertexAttrib4Nub")) == NULL) || r; - r = ((glVertexAttrib4Nubv = (PFNGLVERTEXATTRIB4NUBVPROC)glewGetProcAddress((const GLubyte*)"glVertexAttrib4Nubv")) == NULL) || r; - r = ((glVertexAttrib4Nuiv = (PFNGLVERTEXATTRIB4NUIVPROC)glewGetProcAddress((const GLubyte*)"glVertexAttrib4Nuiv")) == NULL) || r; - r = ((glVertexAttrib4Nusv = (PFNGLVERTEXATTRIB4NUSVPROC)glewGetProcAddress((const GLubyte*)"glVertexAttrib4Nusv")) == NULL) || r; - r = ((glVertexAttrib4bv = (PFNGLVERTEXATTRIB4BVPROC)glewGetProcAddress((const GLubyte*)"glVertexAttrib4bv")) == NULL) || r; - r = ((glVertexAttrib4d = (PFNGLVERTEXATTRIB4DPROC)glewGetProcAddress((const GLubyte*)"glVertexAttrib4d")) == NULL) || r; - r = ((glVertexAttrib4dv = (PFNGLVERTEXATTRIB4DVPROC)glewGetProcAddress((const GLubyte*)"glVertexAttrib4dv")) == NULL) || r; - r = ((glVertexAttrib4f = (PFNGLVERTEXATTRIB4FPROC)glewGetProcAddress((const GLubyte*)"glVertexAttrib4f")) == NULL) || r; - r = ((glVertexAttrib4fv = (PFNGLVERTEXATTRIB4FVPROC)glewGetProcAddress((const GLubyte*)"glVertexAttrib4fv")) == NULL) || r; - r = ((glVertexAttrib4iv = (PFNGLVERTEXATTRIB4IVPROC)glewGetProcAddress((const GLubyte*)"glVertexAttrib4iv")) == NULL) || r; - r = ((glVertexAttrib4s = (PFNGLVERTEXATTRIB4SPROC)glewGetProcAddress((const GLubyte*)"glVertexAttrib4s")) == NULL) || r; - r = ((glVertexAttrib4sv = (PFNGLVERTEXATTRIB4SVPROC)glewGetProcAddress((const GLubyte*)"glVertexAttrib4sv")) == NULL) || r; - r = ((glVertexAttrib4ubv = (PFNGLVERTEXATTRIB4UBVPROC)glewGetProcAddress((const GLubyte*)"glVertexAttrib4ubv")) == NULL) || r; - r = ((glVertexAttrib4uiv = (PFNGLVERTEXATTRIB4UIVPROC)glewGetProcAddress((const GLubyte*)"glVertexAttrib4uiv")) == NULL) || r; - r = ((glVertexAttrib4usv = (PFNGLVERTEXATTRIB4USVPROC)glewGetProcAddress((const GLubyte*)"glVertexAttrib4usv")) == NULL) || r; - r = ((glVertexAttribPointer = (PFNGLVERTEXATTRIBPOINTERPROC)glewGetProcAddress((const GLubyte*)"glVertexAttribPointer")) == NULL) || r; - - return r; -} - -#endif /* GL_VERSION_2_0 */ - -#ifdef GL_VERSION_2_1 - -static GLboolean _glewInit_GL_VERSION_2_1 (GLEW_CONTEXT_ARG_DEF_INIT) -{ - GLboolean r = GL_FALSE; - - r = ((glUniformMatrix2x3fv = (PFNGLUNIFORMMATRIX2X3FVPROC)glewGetProcAddress((const GLubyte*)"glUniformMatrix2x3fv")) == NULL) || r; - r = ((glUniformMatrix2x4fv = (PFNGLUNIFORMMATRIX2X4FVPROC)glewGetProcAddress((const GLubyte*)"glUniformMatrix2x4fv")) == NULL) || r; - r = ((glUniformMatrix3x2fv = (PFNGLUNIFORMMATRIX3X2FVPROC)glewGetProcAddress((const GLubyte*)"glUniformMatrix3x2fv")) == NULL) || r; - r = ((glUniformMatrix3x4fv = (PFNGLUNIFORMMATRIX3X4FVPROC)glewGetProcAddress((const GLubyte*)"glUniformMatrix3x4fv")) == NULL) || r; - r = ((glUniformMatrix4x2fv = (PFNGLUNIFORMMATRIX4X2FVPROC)glewGetProcAddress((const GLubyte*)"glUniformMatrix4x2fv")) == NULL) || r; - r = ((glUniformMatrix4x3fv = (PFNGLUNIFORMMATRIX4X3FVPROC)glewGetProcAddress((const GLubyte*)"glUniformMatrix4x3fv")) == NULL) || r; - - return r; -} - -#endif /* GL_VERSION_2_1 */ - -#ifdef GL_VERSION_3_0 - -static GLboolean _glewInit_GL_VERSION_3_0 (GLEW_CONTEXT_ARG_DEF_INIT) -{ - GLboolean r = GL_FALSE; - - r = ((glBeginConditionalRender = (PFNGLBEGINCONDITIONALRENDERPROC)glewGetProcAddress((const GLubyte*)"glBeginConditionalRender")) == NULL) || r; - r = ((glBeginTransformFeedback = (PFNGLBEGINTRANSFORMFEEDBACKPROC)glewGetProcAddress((const GLubyte*)"glBeginTransformFeedback")) == NULL) || r; - r = ((glBindBufferBase = (PFNGLBINDBUFFERBASEPROC)glewGetProcAddress((const GLubyte*)"glBindBufferBase")) == NULL) || r; - r = ((glBindBufferRange = (PFNGLBINDBUFFERRANGEPROC)glewGetProcAddress((const GLubyte*)"glBindBufferRange")) == NULL) || r; - r = ((glBindFragDataLocation = (PFNGLBINDFRAGDATALOCATIONPROC)glewGetProcAddress((const GLubyte*)"glBindFragDataLocation")) == NULL) || r; - r = ((glClampColor = (PFNGLCLAMPCOLORPROC)glewGetProcAddress((const GLubyte*)"glClampColor")) == NULL) || r; - r = ((glClearBufferfi = (PFNGLCLEARBUFFERFIPROC)glewGetProcAddress((const GLubyte*)"glClearBufferfi")) == NULL) || r; - r = ((glClearBufferfv = (PFNGLCLEARBUFFERFVPROC)glewGetProcAddress((const GLubyte*)"glClearBufferfv")) == NULL) || r; - r = ((glClearBufferiv = (PFNGLCLEARBUFFERIVPROC)glewGetProcAddress((const GLubyte*)"glClearBufferiv")) == NULL) || r; - r = ((glClearBufferuiv = (PFNGLCLEARBUFFERUIVPROC)glewGetProcAddress((const GLubyte*)"glClearBufferuiv")) == NULL) || r; - r = ((glColorMaski = (PFNGLCOLORMASKIPROC)glewGetProcAddress((const GLubyte*)"glColorMaski")) == NULL) || r; - r = ((glDisablei = (PFNGLDISABLEIPROC)glewGetProcAddress((const GLubyte*)"glDisablei")) == NULL) || r; - r = ((glEnablei = (PFNGLENABLEIPROC)glewGetProcAddress((const GLubyte*)"glEnablei")) == NULL) || r; - r = ((glEndConditionalRender = (PFNGLENDCONDITIONALRENDERPROC)glewGetProcAddress((const GLubyte*)"glEndConditionalRender")) == NULL) || r; - r = ((glEndTransformFeedback = (PFNGLENDTRANSFORMFEEDBACKPROC)glewGetProcAddress((const GLubyte*)"glEndTransformFeedback")) == NULL) || r; - r = ((glGetBooleani_v = (PFNGLGETBOOLEANI_VPROC)glewGetProcAddress((const GLubyte*)"glGetBooleani_v")) == NULL) || r; - r = ((glGetFragDataLocation = (PFNGLGETFRAGDATALOCATIONPROC)glewGetProcAddress((const GLubyte*)"glGetFragDataLocation")) == NULL) || r; - r = ((glGetIntegeri_v = (PFNGLGETINTEGERI_VPROC)glewGetProcAddress((const GLubyte*)"glGetIntegeri_v")) == NULL) || r; - r = ((glGetStringi = (PFNGLGETSTRINGIPROC)glewGetProcAddress((const GLubyte*)"glGetStringi")) == NULL) || r; - r = ((glGetTexParameterIiv = (PFNGLGETTEXPARAMETERIIVPROC)glewGetProcAddress((const GLubyte*)"glGetTexParameterIiv")) == NULL) || r; - r = ((glGetTexParameterIuiv = (PFNGLGETTEXPARAMETERIUIVPROC)glewGetProcAddress((const GLubyte*)"glGetTexParameterIuiv")) == NULL) || r; - r = ((glGetTransformFeedbackVarying = (PFNGLGETTRANSFORMFEEDBACKVARYINGPROC)glewGetProcAddress((const GLubyte*)"glGetTransformFeedbackVarying")) == NULL) || r; - r = ((glGetUniformuiv = (PFNGLGETUNIFORMUIVPROC)glewGetProcAddress((const GLubyte*)"glGetUniformuiv")) == NULL) || r; - r = ((glGetVertexAttribIiv = (PFNGLGETVERTEXATTRIBIIVPROC)glewGetProcAddress((const GLubyte*)"glGetVertexAttribIiv")) == NULL) || r; - r = ((glGetVertexAttribIuiv = (PFNGLGETVERTEXATTRIBIUIVPROC)glewGetProcAddress((const GLubyte*)"glGetVertexAttribIuiv")) == NULL) || r; - r = ((glIsEnabledi = (PFNGLISENABLEDIPROC)glewGetProcAddress((const GLubyte*)"glIsEnabledi")) == NULL) || r; - r = ((glTexParameterIiv = (PFNGLTEXPARAMETERIIVPROC)glewGetProcAddress((const GLubyte*)"glTexParameterIiv")) == NULL) || r; - r = ((glTexParameterIuiv = (PFNGLTEXPARAMETERIUIVPROC)glewGetProcAddress((const GLubyte*)"glTexParameterIuiv")) == NULL) || r; - r = ((glTransformFeedbackVaryings = (PFNGLTRANSFORMFEEDBACKVARYINGSPROC)glewGetProcAddress((const GLubyte*)"glTransformFeedbackVaryings")) == NULL) || r; - r = ((glUniform1ui = (PFNGLUNIFORM1UIPROC)glewGetProcAddress((const GLubyte*)"glUniform1ui")) == NULL) || r; - r = ((glUniform1uiv = (PFNGLUNIFORM1UIVPROC)glewGetProcAddress((const GLubyte*)"glUniform1uiv")) == NULL) || r; - r = ((glUniform2ui = (PFNGLUNIFORM2UIPROC)glewGetProcAddress((const GLubyte*)"glUniform2ui")) == NULL) || r; - r = ((glUniform2uiv = (PFNGLUNIFORM2UIVPROC)glewGetProcAddress((const GLubyte*)"glUniform2uiv")) == NULL) || r; - r = ((glUniform3ui = (PFNGLUNIFORM3UIPROC)glewGetProcAddress((const GLubyte*)"glUniform3ui")) == NULL) || r; - r = ((glUniform3uiv = (PFNGLUNIFORM3UIVPROC)glewGetProcAddress((const GLubyte*)"glUniform3uiv")) == NULL) || r; - r = ((glUniform4ui = (PFNGLUNIFORM4UIPROC)glewGetProcAddress((const GLubyte*)"glUniform4ui")) == NULL) || r; - r = ((glUniform4uiv = (PFNGLUNIFORM4UIVPROC)glewGetProcAddress((const GLubyte*)"glUniform4uiv")) == NULL) || r; - r = ((glVertexAttribI1i = (PFNGLVERTEXATTRIBI1IPROC)glewGetProcAddress((const GLubyte*)"glVertexAttribI1i")) == NULL) || r; - r = ((glVertexAttribI1iv = (PFNGLVERTEXATTRIBI1IVPROC)glewGetProcAddress((const GLubyte*)"glVertexAttribI1iv")) == NULL) || r; - r = ((glVertexAttribI1ui = (PFNGLVERTEXATTRIBI1UIPROC)glewGetProcAddress((const GLubyte*)"glVertexAttribI1ui")) == NULL) || r; - r = ((glVertexAttribI1uiv = (PFNGLVERTEXATTRIBI1UIVPROC)glewGetProcAddress((const GLubyte*)"glVertexAttribI1uiv")) == NULL) || r; - r = ((glVertexAttribI2i = (PFNGLVERTEXATTRIBI2IPROC)glewGetProcAddress((const GLubyte*)"glVertexAttribI2i")) == NULL) || r; - r = ((glVertexAttribI2iv = (PFNGLVERTEXATTRIBI2IVPROC)glewGetProcAddress((const GLubyte*)"glVertexAttribI2iv")) == NULL) || r; - r = ((glVertexAttribI2ui = (PFNGLVERTEXATTRIBI2UIPROC)glewGetProcAddress((const GLubyte*)"glVertexAttribI2ui")) == NULL) || r; - r = ((glVertexAttribI2uiv = (PFNGLVERTEXATTRIBI2UIVPROC)glewGetProcAddress((const GLubyte*)"glVertexAttribI2uiv")) == NULL) || r; - r = ((glVertexAttribI3i = (PFNGLVERTEXATTRIBI3IPROC)glewGetProcAddress((const GLubyte*)"glVertexAttribI3i")) == NULL) || r; - r = ((glVertexAttribI3iv = (PFNGLVERTEXATTRIBI3IVPROC)glewGetProcAddress((const GLubyte*)"glVertexAttribI3iv")) == NULL) || r; - r = ((glVertexAttribI3ui = (PFNGLVERTEXATTRIBI3UIPROC)glewGetProcAddress((const GLubyte*)"glVertexAttribI3ui")) == NULL) || r; - r = ((glVertexAttribI3uiv = (PFNGLVERTEXATTRIBI3UIVPROC)glewGetProcAddress((const GLubyte*)"glVertexAttribI3uiv")) == NULL) || r; - r = ((glVertexAttribI4bv = (PFNGLVERTEXATTRIBI4BVPROC)glewGetProcAddress((const GLubyte*)"glVertexAttribI4bv")) == NULL) || r; - r = ((glVertexAttribI4i = (PFNGLVERTEXATTRIBI4IPROC)glewGetProcAddress((const GLubyte*)"glVertexAttribI4i")) == NULL) || r; - r = ((glVertexAttribI4iv = (PFNGLVERTEXATTRIBI4IVPROC)glewGetProcAddress((const GLubyte*)"glVertexAttribI4iv")) == NULL) || r; - r = ((glVertexAttribI4sv = (PFNGLVERTEXATTRIBI4SVPROC)glewGetProcAddress((const GLubyte*)"glVertexAttribI4sv")) == NULL) || r; - r = ((glVertexAttribI4ubv = (PFNGLVERTEXATTRIBI4UBVPROC)glewGetProcAddress((const GLubyte*)"glVertexAttribI4ubv")) == NULL) || r; - r = ((glVertexAttribI4ui = (PFNGLVERTEXATTRIBI4UIPROC)glewGetProcAddress((const GLubyte*)"glVertexAttribI4ui")) == NULL) || r; - r = ((glVertexAttribI4uiv = (PFNGLVERTEXATTRIBI4UIVPROC)glewGetProcAddress((const GLubyte*)"glVertexAttribI4uiv")) == NULL) || r; - r = ((glVertexAttribI4usv = (PFNGLVERTEXATTRIBI4USVPROC)glewGetProcAddress((const GLubyte*)"glVertexAttribI4usv")) == NULL) || r; - r = ((glVertexAttribIPointer = (PFNGLVERTEXATTRIBIPOINTERPROC)glewGetProcAddress((const GLubyte*)"glVertexAttribIPointer")) == NULL) || r; - - return r; -} - -#endif /* GL_VERSION_3_0 */ - -#ifdef GL_3DFX_multisample - -#endif /* GL_3DFX_multisample */ - -#ifdef GL_3DFX_tbuffer - -static GLboolean _glewInit_GL_3DFX_tbuffer (GLEW_CONTEXT_ARG_DEF_INIT) -{ - GLboolean r = GL_FALSE; - - r = ((glTbufferMask3DFX = (PFNGLTBUFFERMASK3DFXPROC)glewGetProcAddress((const GLubyte*)"glTbufferMask3DFX")) == NULL) || r; - - return r; -} - -#endif /* GL_3DFX_tbuffer */ - -#ifdef GL_3DFX_texture_compression_FXT1 - -#endif /* GL_3DFX_texture_compression_FXT1 */ - -#ifdef GL_APPLE_client_storage - -#endif /* GL_APPLE_client_storage */ - -#ifdef GL_APPLE_element_array - -static GLboolean _glewInit_GL_APPLE_element_array (GLEW_CONTEXT_ARG_DEF_INIT) -{ - GLboolean r = GL_FALSE; - - r = ((glDrawElementArrayAPPLE = (PFNGLDRAWELEMENTARRAYAPPLEPROC)glewGetProcAddress((const GLubyte*)"glDrawElementArrayAPPLE")) == NULL) || r; - r = ((glDrawRangeElementArrayAPPLE = (PFNGLDRAWRANGEELEMENTARRAYAPPLEPROC)glewGetProcAddress((const GLubyte*)"glDrawRangeElementArrayAPPLE")) == NULL) || r; - r = ((glElementPointerAPPLE = (PFNGLELEMENTPOINTERAPPLEPROC)glewGetProcAddress((const GLubyte*)"glElementPointerAPPLE")) == NULL) || r; - r = ((glMultiDrawElementArrayAPPLE = (PFNGLMULTIDRAWELEMENTARRAYAPPLEPROC)glewGetProcAddress((const GLubyte*)"glMultiDrawElementArrayAPPLE")) == NULL) || r; - r = ((glMultiDrawRangeElementArrayAPPLE = (PFNGLMULTIDRAWRANGEELEMENTARRAYAPPLEPROC)glewGetProcAddress((const GLubyte*)"glMultiDrawRangeElementArrayAPPLE")) == NULL) || r; - - return r; -} - -#endif /* GL_APPLE_element_array */ - -#ifdef GL_APPLE_fence - -static GLboolean _glewInit_GL_APPLE_fence (GLEW_CONTEXT_ARG_DEF_INIT) -{ - GLboolean r = GL_FALSE; - - r = ((glDeleteFencesAPPLE = (PFNGLDELETEFENCESAPPLEPROC)glewGetProcAddress((const GLubyte*)"glDeleteFencesAPPLE")) == NULL) || r; - r = ((glFinishFenceAPPLE = (PFNGLFINISHFENCEAPPLEPROC)glewGetProcAddress((const GLubyte*)"glFinishFenceAPPLE")) == NULL) || r; - r = ((glFinishObjectAPPLE = (PFNGLFINISHOBJECTAPPLEPROC)glewGetProcAddress((const GLubyte*)"glFinishObjectAPPLE")) == NULL) || r; - r = ((glGenFencesAPPLE = (PFNGLGENFENCESAPPLEPROC)glewGetProcAddress((const GLubyte*)"glGenFencesAPPLE")) == NULL) || r; - r = ((glIsFenceAPPLE = (PFNGLISFENCEAPPLEPROC)glewGetProcAddress((const GLubyte*)"glIsFenceAPPLE")) == NULL) || r; - r = ((glSetFenceAPPLE = (PFNGLSETFENCEAPPLEPROC)glewGetProcAddress((const GLubyte*)"glSetFenceAPPLE")) == NULL) || r; - r = ((glTestFenceAPPLE = (PFNGLTESTFENCEAPPLEPROC)glewGetProcAddress((const GLubyte*)"glTestFenceAPPLE")) == NULL) || r; - r = ((glTestObjectAPPLE = (PFNGLTESTOBJECTAPPLEPROC)glewGetProcAddress((const GLubyte*)"glTestObjectAPPLE")) == NULL) || r; - - return r; -} - -#endif /* GL_APPLE_fence */ - -#ifdef GL_APPLE_float_pixels - -#endif /* GL_APPLE_float_pixels */ - -#ifdef GL_APPLE_flush_buffer_range - -static GLboolean _glewInit_GL_APPLE_flush_buffer_range (GLEW_CONTEXT_ARG_DEF_INIT) -{ - GLboolean r = GL_FALSE; - - r = ((glBufferParameteriAPPLE = (PFNGLBUFFERPARAMETERIAPPLEPROC)glewGetProcAddress((const GLubyte*)"glBufferParameteriAPPLE")) == NULL) || r; - r = ((glFlushMappedBufferRangeAPPLE = (PFNGLFLUSHMAPPEDBUFFERRANGEAPPLEPROC)glewGetProcAddress((const GLubyte*)"glFlushMappedBufferRangeAPPLE")) == NULL) || r; - - return r; -} - -#endif /* GL_APPLE_flush_buffer_range */ - -#ifdef GL_APPLE_pixel_buffer - -#endif /* GL_APPLE_pixel_buffer */ - -#ifdef GL_APPLE_specular_vector - -#endif /* GL_APPLE_specular_vector */ - -#ifdef GL_APPLE_texture_range - -static GLboolean _glewInit_GL_APPLE_texture_range (GLEW_CONTEXT_ARG_DEF_INIT) -{ - GLboolean r = GL_FALSE; - - r = ((glGetTexParameterPointervAPPLE = (PFNGLGETTEXPARAMETERPOINTERVAPPLEPROC)glewGetProcAddress((const GLubyte*)"glGetTexParameterPointervAPPLE")) == NULL) || r; - r = ((glTextureRangeAPPLE = (PFNGLTEXTURERANGEAPPLEPROC)glewGetProcAddress((const GLubyte*)"glTextureRangeAPPLE")) == NULL) || r; - - return r; -} - -#endif /* GL_APPLE_texture_range */ - -#ifdef GL_APPLE_transform_hint - -#endif /* GL_APPLE_transform_hint */ - -#ifdef GL_APPLE_vertex_array_object - -static GLboolean _glewInit_GL_APPLE_vertex_array_object (GLEW_CONTEXT_ARG_DEF_INIT) -{ - GLboolean r = GL_FALSE; - - r = ((glBindVertexArrayAPPLE = (PFNGLBINDVERTEXARRAYAPPLEPROC)glewGetProcAddress((const GLubyte*)"glBindVertexArrayAPPLE")) == NULL) || r; - r = ((glDeleteVertexArraysAPPLE = (PFNGLDELETEVERTEXARRAYSAPPLEPROC)glewGetProcAddress((const GLubyte*)"glDeleteVertexArraysAPPLE")) == NULL) || r; - r = ((glGenVertexArraysAPPLE = (PFNGLGENVERTEXARRAYSAPPLEPROC)glewGetProcAddress((const GLubyte*)"glGenVertexArraysAPPLE")) == NULL) || r; - r = ((glIsVertexArrayAPPLE = (PFNGLISVERTEXARRAYAPPLEPROC)glewGetProcAddress((const GLubyte*)"glIsVertexArrayAPPLE")) == NULL) || r; - - return r; -} - -#endif /* GL_APPLE_vertex_array_object */ - -#ifdef GL_APPLE_vertex_array_range - -static GLboolean _glewInit_GL_APPLE_vertex_array_range (GLEW_CONTEXT_ARG_DEF_INIT) -{ - GLboolean r = GL_FALSE; - - r = ((glFlushVertexArrayRangeAPPLE = (PFNGLFLUSHVERTEXARRAYRANGEAPPLEPROC)glewGetProcAddress((const GLubyte*)"glFlushVertexArrayRangeAPPLE")) == NULL) || r; - r = ((glVertexArrayParameteriAPPLE = (PFNGLVERTEXARRAYPARAMETERIAPPLEPROC)glewGetProcAddress((const GLubyte*)"glVertexArrayParameteriAPPLE")) == NULL) || r; - r = ((glVertexArrayRangeAPPLE = (PFNGLVERTEXARRAYRANGEAPPLEPROC)glewGetProcAddress((const GLubyte*)"glVertexArrayRangeAPPLE")) == NULL) || r; - - return r; -} - -#endif /* GL_APPLE_vertex_array_range */ - -#ifdef GL_APPLE_ycbcr_422 - -#endif /* GL_APPLE_ycbcr_422 */ - -#ifdef GL_ARB_color_buffer_float - -static GLboolean _glewInit_GL_ARB_color_buffer_float (GLEW_CONTEXT_ARG_DEF_INIT) -{ - GLboolean r = GL_FALSE; - - r = ((glClampColorARB = (PFNGLCLAMPCOLORARBPROC)glewGetProcAddress((const GLubyte*)"glClampColorARB")) == NULL) || r; - - return r; -} - -#endif /* GL_ARB_color_buffer_float */ - -#ifdef GL_ARB_depth_buffer_float - -#endif /* GL_ARB_depth_buffer_float */ - -#ifdef GL_ARB_depth_texture - -#endif /* GL_ARB_depth_texture */ - -#ifdef GL_ARB_draw_buffers - -static GLboolean _glewInit_GL_ARB_draw_buffers (GLEW_CONTEXT_ARG_DEF_INIT) -{ - GLboolean r = GL_FALSE; - - r = ((glDrawBuffersARB = (PFNGLDRAWBUFFERSARBPROC)glewGetProcAddress((const GLubyte*)"glDrawBuffersARB")) == NULL) || r; - - return r; -} - -#endif /* GL_ARB_draw_buffers */ - -#ifdef GL_ARB_draw_instanced - -static GLboolean _glewInit_GL_ARB_draw_instanced (GLEW_CONTEXT_ARG_DEF_INIT) -{ - GLboolean r = GL_FALSE; - - r = ((glDrawArraysInstancedARB = (PFNGLDRAWARRAYSINSTANCEDARBPROC)glewGetProcAddress((const GLubyte*)"glDrawArraysInstancedARB")) == NULL) || r; - r = ((glDrawElementsInstancedARB = (PFNGLDRAWELEMENTSINSTANCEDARBPROC)glewGetProcAddress((const GLubyte*)"glDrawElementsInstancedARB")) == NULL) || r; - - return r; -} - -#endif /* GL_ARB_draw_instanced */ - -#ifdef GL_ARB_fragment_program - -#endif /* GL_ARB_fragment_program */ - -#ifdef GL_ARB_fragment_program_shadow - -#endif /* GL_ARB_fragment_program_shadow */ - -#ifdef GL_ARB_fragment_shader - -#endif /* GL_ARB_fragment_shader */ - -#ifdef GL_ARB_framebuffer_object - -static GLboolean _glewInit_GL_ARB_framebuffer_object (GLEW_CONTEXT_ARG_DEF_INIT) -{ - GLboolean r = GL_FALSE; - - r = ((glBindFramebuffer = (PFNGLBINDFRAMEBUFFERPROC)glewGetProcAddress((const GLubyte*)"glBindFramebuffer")) == NULL) || r; - r = ((glBindRenderbuffer = (PFNGLBINDRENDERBUFFERPROC)glewGetProcAddress((const GLubyte*)"glBindRenderbuffer")) == NULL) || r; - r = ((glBlitFramebuffer = (PFNGLBLITFRAMEBUFFERPROC)glewGetProcAddress((const GLubyte*)"glBlitFramebuffer")) == NULL) || r; - r = ((glCheckFramebufferStatus = (PFNGLCHECKFRAMEBUFFERSTATUSPROC)glewGetProcAddress((const GLubyte*)"glCheckFramebufferStatus")) == NULL) || r; - r = ((glDeleteFramebuffers = (PFNGLDELETEFRAMEBUFFERSPROC)glewGetProcAddress((const GLubyte*)"glDeleteFramebuffers")) == NULL) || r; - r = ((glDeleteRenderbuffers = (PFNGLDELETERENDERBUFFERSPROC)glewGetProcAddress((const GLubyte*)"glDeleteRenderbuffers")) == NULL) || r; - r = ((glFramebufferRenderbuffer = (PFNGLFRAMEBUFFERRENDERBUFFERPROC)glewGetProcAddress((const GLubyte*)"glFramebufferRenderbuffer")) == NULL) || r; - r = ((glFramebufferTexturLayer = (PFNGLFRAMEBUFFERTEXTURLAYERPROC)glewGetProcAddress((const GLubyte*)"glFramebufferTexturLayer")) == NULL) || r; - r = ((glFramebufferTexture1D = (PFNGLFRAMEBUFFERTEXTURE1DPROC)glewGetProcAddress((const GLubyte*)"glFramebufferTexture1D")) == NULL) || r; - r = ((glFramebufferTexture2D = (PFNGLFRAMEBUFFERTEXTURE2DPROC)glewGetProcAddress((const GLubyte*)"glFramebufferTexture2D")) == NULL) || r; - r = ((glFramebufferTexture3D = (PFNGLFRAMEBUFFERTEXTURE3DPROC)glewGetProcAddress((const GLubyte*)"glFramebufferTexture3D")) == NULL) || r; - r = ((glGenFramebuffers = (PFNGLGENFRAMEBUFFERSPROC)glewGetProcAddress((const GLubyte*)"glGenFramebuffers")) == NULL) || r; - r = ((glGenRenderbuffers = (PFNGLGENRENDERBUFFERSPROC)glewGetProcAddress((const GLubyte*)"glGenRenderbuffers")) == NULL) || r; - r = ((glGenerateMipmap = (PFNGLGENERATEMIPMAPPROC)glewGetProcAddress((const GLubyte*)"glGenerateMipmap")) == NULL) || r; - r = ((glGetFramebufferAttachmentParameteriv = (PFNGLGETFRAMEBUFFERATTACHMENTPARAMETERIVPROC)glewGetProcAddress((const GLubyte*)"glGetFramebufferAttachmentParameteriv")) == NULL) || r; - r = ((glGetRenderbufferParameteriv = (PFNGLGETRENDERBUFFERPARAMETERIVPROC)glewGetProcAddress((const GLubyte*)"glGetRenderbufferParameteriv")) == NULL) || r; - r = ((glIsFramebuffer = (PFNGLISFRAMEBUFFERPROC)glewGetProcAddress((const GLubyte*)"glIsFramebuffer")) == NULL) || r; - r = ((glIsRenderbuffer = (PFNGLISRENDERBUFFERPROC)glewGetProcAddress((const GLubyte*)"glIsRenderbuffer")) == NULL) || r; - r = ((glRenderbufferStorage = (PFNGLRENDERBUFFERSTORAGEPROC)glewGetProcAddress((const GLubyte*)"glRenderbufferStorage")) == NULL) || r; - r = ((glRenderbufferStorageMultisample = (PFNGLRENDERBUFFERSTORAGEMULTISAMPLEPROC)glewGetProcAddress((const GLubyte*)"glRenderbufferStorageMultisample")) == NULL) || r; - - return r; -} - -#endif /* GL_ARB_framebuffer_object */ - -#ifdef GL_ARB_framebuffer_sRGB - -#endif /* GL_ARB_framebuffer_sRGB */ - -#ifdef GL_ARB_geometry_shader4 - -static GLboolean _glewInit_GL_ARB_geometry_shader4 (GLEW_CONTEXT_ARG_DEF_INIT) -{ - GLboolean r = GL_FALSE; - - r = ((glFramebufferTextureARB = (PFNGLFRAMEBUFFERTEXTUREARBPROC)glewGetProcAddress((const GLubyte*)"glFramebufferTextureARB")) == NULL) || r; - r = ((glFramebufferTextureFaceARB = (PFNGLFRAMEBUFFERTEXTUREFACEARBPROC)glewGetProcAddress((const GLubyte*)"glFramebufferTextureFaceARB")) == NULL) || r; - r = ((glFramebufferTextureLayerARB = (PFNGLFRAMEBUFFERTEXTURELAYERARBPROC)glewGetProcAddress((const GLubyte*)"glFramebufferTextureLayerARB")) == NULL) || r; - r = ((glProgramParameteriARB = (PFNGLPROGRAMPARAMETERIARBPROC)glewGetProcAddress((const GLubyte*)"glProgramParameteriARB")) == NULL) || r; - - return r; -} - -#endif /* GL_ARB_geometry_shader4 */ - -#ifdef GL_ARB_half_float_pixel - -#endif /* GL_ARB_half_float_pixel */ - -#ifdef GL_ARB_half_float_vertex - -#endif /* GL_ARB_half_float_vertex */ - -#ifdef GL_ARB_imaging - -static GLboolean _glewInit_GL_ARB_imaging (GLEW_CONTEXT_ARG_DEF_INIT) -{ - GLboolean r = GL_FALSE; - - r = ((glBlendEquation = (PFNGLBLENDEQUATIONPROC)glewGetProcAddress((const GLubyte*)"glBlendEquation")) == NULL) || r; - r = ((glColorSubTable = (PFNGLCOLORSUBTABLEPROC)glewGetProcAddress((const GLubyte*)"glColorSubTable")) == NULL) || r; - r = ((glColorTable = (PFNGLCOLORTABLEPROC)glewGetProcAddress((const GLubyte*)"glColorTable")) == NULL) || r; - r = ((glColorTableParameterfv = (PFNGLCOLORTABLEPARAMETERFVPROC)glewGetProcAddress((const GLubyte*)"glColorTableParameterfv")) == NULL) || r; - r = ((glColorTableParameteriv = (PFNGLCOLORTABLEPARAMETERIVPROC)glewGetProcAddress((const GLubyte*)"glColorTableParameteriv")) == NULL) || r; - r = ((glConvolutionFilter1D = (PFNGLCONVOLUTIONFILTER1DPROC)glewGetProcAddress((const GLubyte*)"glConvolutionFilter1D")) == NULL) || r; - r = ((glConvolutionFilter2D = (PFNGLCONVOLUTIONFILTER2DPROC)glewGetProcAddress((const GLubyte*)"glConvolutionFilter2D")) == NULL) || r; - r = ((glConvolutionParameterf = (PFNGLCONVOLUTIONPARAMETERFPROC)glewGetProcAddress((const GLubyte*)"glConvolutionParameterf")) == NULL) || r; - r = ((glConvolutionParameterfv = (PFNGLCONVOLUTIONPARAMETERFVPROC)glewGetProcAddress((const GLubyte*)"glConvolutionParameterfv")) == NULL) || r; - r = ((glConvolutionParameteri = (PFNGLCONVOLUTIONPARAMETERIPROC)glewGetProcAddress((const GLubyte*)"glConvolutionParameteri")) == NULL) || r; - r = ((glConvolutionParameteriv = (PFNGLCONVOLUTIONPARAMETERIVPROC)glewGetProcAddress((const GLubyte*)"glConvolutionParameteriv")) == NULL) || r; - r = ((glCopyColorSubTable = (PFNGLCOPYCOLORSUBTABLEPROC)glewGetProcAddress((const GLubyte*)"glCopyColorSubTable")) == NULL) || r; - r = ((glCopyColorTable = (PFNGLCOPYCOLORTABLEPROC)glewGetProcAddress((const GLubyte*)"glCopyColorTable")) == NULL) || r; - r = ((glCopyConvolutionFilter1D = (PFNGLCOPYCONVOLUTIONFILTER1DPROC)glewGetProcAddress((const GLubyte*)"glCopyConvolutionFilter1D")) == NULL) || r; - r = ((glCopyConvolutionFilter2D = (PFNGLCOPYCONVOLUTIONFILTER2DPROC)glewGetProcAddress((const GLubyte*)"glCopyConvolutionFilter2D")) == NULL) || r; - r = ((glGetColorTable = (PFNGLGETCOLORTABLEPROC)glewGetProcAddress((const GLubyte*)"glGetColorTable")) == NULL) || r; - r = ((glGetColorTableParameterfv = (PFNGLGETCOLORTABLEPARAMETERFVPROC)glewGetProcAddress((const GLubyte*)"glGetColorTableParameterfv")) == NULL) || r; - r = ((glGetColorTableParameteriv = (PFNGLGETCOLORTABLEPARAMETERIVPROC)glewGetProcAddress((const GLubyte*)"glGetColorTableParameteriv")) == NULL) || r; - r = ((glGetConvolutionFilter = (PFNGLGETCONVOLUTIONFILTERPROC)glewGetProcAddress((const GLubyte*)"glGetConvolutionFilter")) == NULL) || r; - r = ((glGetConvolutionParameterfv = (PFNGLGETCONVOLUTIONPARAMETERFVPROC)glewGetProcAddress((const GLubyte*)"glGetConvolutionParameterfv")) == NULL) || r; - r = ((glGetConvolutionParameteriv = (PFNGLGETCONVOLUTIONPARAMETERIVPROC)glewGetProcAddress((const GLubyte*)"glGetConvolutionParameteriv")) == NULL) || r; - r = ((glGetHistogram = (PFNGLGETHISTOGRAMPROC)glewGetProcAddress((const GLubyte*)"glGetHistogram")) == NULL) || r; - r = ((glGetHistogramParameterfv = (PFNGLGETHISTOGRAMPARAMETERFVPROC)glewGetProcAddress((const GLubyte*)"glGetHistogramParameterfv")) == NULL) || r; - r = ((glGetHistogramParameteriv = (PFNGLGETHISTOGRAMPARAMETERIVPROC)glewGetProcAddress((const GLubyte*)"glGetHistogramParameteriv")) == NULL) || r; - r = ((glGetMinmax = (PFNGLGETMINMAXPROC)glewGetProcAddress((const GLubyte*)"glGetMinmax")) == NULL) || r; - r = ((glGetMinmaxParameterfv = (PFNGLGETMINMAXPARAMETERFVPROC)glewGetProcAddress((const GLubyte*)"glGetMinmaxParameterfv")) == NULL) || r; - r = ((glGetMinmaxParameteriv = (PFNGLGETMINMAXPARAMETERIVPROC)glewGetProcAddress((const GLubyte*)"glGetMinmaxParameteriv")) == NULL) || r; - r = ((glGetSeparableFilter = (PFNGLGETSEPARABLEFILTERPROC)glewGetProcAddress((const GLubyte*)"glGetSeparableFilter")) == NULL) || r; - r = ((glHistogram = (PFNGLHISTOGRAMPROC)glewGetProcAddress((const GLubyte*)"glHistogram")) == NULL) || r; - r = ((glMinmax = (PFNGLMINMAXPROC)glewGetProcAddress((const GLubyte*)"glMinmax")) == NULL) || r; - r = ((glResetHistogram = (PFNGLRESETHISTOGRAMPROC)glewGetProcAddress((const GLubyte*)"glResetHistogram")) == NULL) || r; - r = ((glResetMinmax = (PFNGLRESETMINMAXPROC)glewGetProcAddress((const GLubyte*)"glResetMinmax")) == NULL) || r; - r = ((glSeparableFilter2D = (PFNGLSEPARABLEFILTER2DPROC)glewGetProcAddress((const GLubyte*)"glSeparableFilter2D")) == NULL) || r; - - return r; -} - -#endif /* GL_ARB_imaging */ - -#ifdef GL_ARB_instanced_arrays - -static GLboolean _glewInit_GL_ARB_instanced_arrays (GLEW_CONTEXT_ARG_DEF_INIT) -{ - GLboolean r = GL_FALSE; - - r = ((glVertexAttribDivisorARB = (PFNGLVERTEXATTRIBDIVISORARBPROC)glewGetProcAddress((const GLubyte*)"glVertexAttribDivisorARB")) == NULL) || r; - - return r; -} - -#endif /* GL_ARB_instanced_arrays */ - -#ifdef GL_ARB_map_buffer_range - -static GLboolean _glewInit_GL_ARB_map_buffer_range (GLEW_CONTEXT_ARG_DEF_INIT) -{ - GLboolean r = GL_FALSE; - - r = ((glFlushMappedBufferRange = (PFNGLFLUSHMAPPEDBUFFERRANGEPROC)glewGetProcAddress((const GLubyte*)"glFlushMappedBufferRange")) == NULL) || r; - r = ((glMapBufferRange = (PFNGLMAPBUFFERRANGEPROC)glewGetProcAddress((const GLubyte*)"glMapBufferRange")) == NULL) || r; - - return r; -} - -#endif /* GL_ARB_map_buffer_range */ - -#ifdef GL_ARB_matrix_palette - -static GLboolean _glewInit_GL_ARB_matrix_palette (GLEW_CONTEXT_ARG_DEF_INIT) -{ - GLboolean r = GL_FALSE; - - r = ((glCurrentPaletteMatrixARB = (PFNGLCURRENTPALETTEMATRIXARBPROC)glewGetProcAddress((const GLubyte*)"glCurrentPaletteMatrixARB")) == NULL) || r; - r = ((glMatrixIndexPointerARB = (PFNGLMATRIXINDEXPOINTERARBPROC)glewGetProcAddress((const GLubyte*)"glMatrixIndexPointerARB")) == NULL) || r; - r = ((glMatrixIndexubvARB = (PFNGLMATRIXINDEXUBVARBPROC)glewGetProcAddress((const GLubyte*)"glMatrixIndexubvARB")) == NULL) || r; - r = ((glMatrixIndexuivARB = (PFNGLMATRIXINDEXUIVARBPROC)glewGetProcAddress((const GLubyte*)"glMatrixIndexuivARB")) == NULL) || r; - r = ((glMatrixIndexusvARB = (PFNGLMATRIXINDEXUSVARBPROC)glewGetProcAddress((const GLubyte*)"glMatrixIndexusvARB")) == NULL) || r; - - return r; -} - -#endif /* GL_ARB_matrix_palette */ - -#ifdef GL_ARB_multisample - -static GLboolean _glewInit_GL_ARB_multisample (GLEW_CONTEXT_ARG_DEF_INIT) -{ - GLboolean r = GL_FALSE; - - r = ((glSampleCoverageARB = (PFNGLSAMPLECOVERAGEARBPROC)glewGetProcAddress((const GLubyte*)"glSampleCoverageARB")) == NULL) || r; - - return r; -} - -#endif /* GL_ARB_multisample */ - -#ifdef GL_ARB_multitexture - -static GLboolean _glewInit_GL_ARB_multitexture (GLEW_CONTEXT_ARG_DEF_INIT) -{ - GLboolean r = GL_FALSE; - - r = ((glActiveTextureARB = (PFNGLACTIVETEXTUREARBPROC)glewGetProcAddress((const GLubyte*)"glActiveTextureARB")) == NULL) || r; - r = ((glClientActiveTextureARB = (PFNGLCLIENTACTIVETEXTUREARBPROC)glewGetProcAddress((const GLubyte*)"glClientActiveTextureARB")) == NULL) || r; - r = ((glMultiTexCoord1dARB = (PFNGLMULTITEXCOORD1DARBPROC)glewGetProcAddress((const GLubyte*)"glMultiTexCoord1dARB")) == NULL) || r; - r = ((glMultiTexCoord1dvARB = (PFNGLMULTITEXCOORD1DVARBPROC)glewGetProcAddress((const GLubyte*)"glMultiTexCoord1dvARB")) == NULL) || r; - r = ((glMultiTexCoord1fARB = (PFNGLMULTITEXCOORD1FARBPROC)glewGetProcAddress((const GLubyte*)"glMultiTexCoord1fARB")) == NULL) || r; - r = ((glMultiTexCoord1fvARB = (PFNGLMULTITEXCOORD1FVARBPROC)glewGetProcAddress((const GLubyte*)"glMultiTexCoord1fvARB")) == NULL) || r; - r = ((glMultiTexCoord1iARB = (PFNGLMULTITEXCOORD1IARBPROC)glewGetProcAddress((const GLubyte*)"glMultiTexCoord1iARB")) == NULL) || r; - r = ((glMultiTexCoord1ivARB = (PFNGLMULTITEXCOORD1IVARBPROC)glewGetProcAddress((const GLubyte*)"glMultiTexCoord1ivARB")) == NULL) || r; - r = ((glMultiTexCoord1sARB = (PFNGLMULTITEXCOORD1SARBPROC)glewGetProcAddress((const GLubyte*)"glMultiTexCoord1sARB")) == NULL) || r; - r = ((glMultiTexCoord1svARB = (PFNGLMULTITEXCOORD1SVARBPROC)glewGetProcAddress((const GLubyte*)"glMultiTexCoord1svARB")) == NULL) || r; - r = ((glMultiTexCoord2dARB = (PFNGLMULTITEXCOORD2DARBPROC)glewGetProcAddress((const GLubyte*)"glMultiTexCoord2dARB")) == NULL) || r; - r = ((glMultiTexCoord2dvARB = (PFNGLMULTITEXCOORD2DVARBPROC)glewGetProcAddress((const GLubyte*)"glMultiTexCoord2dvARB")) == NULL) || r; - r = ((glMultiTexCoord2fARB = (PFNGLMULTITEXCOORD2FARBPROC)glewGetProcAddress((const GLubyte*)"glMultiTexCoord2fARB")) == NULL) || r; - r = ((glMultiTexCoord2fvARB = (PFNGLMULTITEXCOORD2FVARBPROC)glewGetProcAddress((const GLubyte*)"glMultiTexCoord2fvARB")) == NULL) || r; - r = ((glMultiTexCoord2iARB = (PFNGLMULTITEXCOORD2IARBPROC)glewGetProcAddress((const GLubyte*)"glMultiTexCoord2iARB")) == NULL) || r; - r = ((glMultiTexCoord2ivARB = (PFNGLMULTITEXCOORD2IVARBPROC)glewGetProcAddress((const GLubyte*)"glMultiTexCoord2ivARB")) == NULL) || r; - r = ((glMultiTexCoord2sARB = (PFNGLMULTITEXCOORD2SARBPROC)glewGetProcAddress((const GLubyte*)"glMultiTexCoord2sARB")) == NULL) || r; - r = ((glMultiTexCoord2svARB = (PFNGLMULTITEXCOORD2SVARBPROC)glewGetProcAddress((const GLubyte*)"glMultiTexCoord2svARB")) == NULL) || r; - r = ((glMultiTexCoord3dARB = (PFNGLMULTITEXCOORD3DARBPROC)glewGetProcAddress((const GLubyte*)"glMultiTexCoord3dARB")) == NULL) || r; - r = ((glMultiTexCoord3dvARB = (PFNGLMULTITEXCOORD3DVARBPROC)glewGetProcAddress((const GLubyte*)"glMultiTexCoord3dvARB")) == NULL) || r; - r = ((glMultiTexCoord3fARB = (PFNGLMULTITEXCOORD3FARBPROC)glewGetProcAddress((const GLubyte*)"glMultiTexCoord3fARB")) == NULL) || r; - r = ((glMultiTexCoord3fvARB = (PFNGLMULTITEXCOORD3FVARBPROC)glewGetProcAddress((const GLubyte*)"glMultiTexCoord3fvARB")) == NULL) || r; - r = ((glMultiTexCoord3iARB = (PFNGLMULTITEXCOORD3IARBPROC)glewGetProcAddress((const GLubyte*)"glMultiTexCoord3iARB")) == NULL) || r; - r = ((glMultiTexCoord3ivARB = (PFNGLMULTITEXCOORD3IVARBPROC)glewGetProcAddress((const GLubyte*)"glMultiTexCoord3ivARB")) == NULL) || r; - r = ((glMultiTexCoord3sARB = (PFNGLMULTITEXCOORD3SARBPROC)glewGetProcAddress((const GLubyte*)"glMultiTexCoord3sARB")) == NULL) || r; - r = ((glMultiTexCoord3svARB = (PFNGLMULTITEXCOORD3SVARBPROC)glewGetProcAddress((const GLubyte*)"glMultiTexCoord3svARB")) == NULL) || r; - r = ((glMultiTexCoord4dARB = (PFNGLMULTITEXCOORD4DARBPROC)glewGetProcAddress((const GLubyte*)"glMultiTexCoord4dARB")) == NULL) || r; - r = ((glMultiTexCoord4dvARB = (PFNGLMULTITEXCOORD4DVARBPROC)glewGetProcAddress((const GLubyte*)"glMultiTexCoord4dvARB")) == NULL) || r; - r = ((glMultiTexCoord4fARB = (PFNGLMULTITEXCOORD4FARBPROC)glewGetProcAddress((const GLubyte*)"glMultiTexCoord4fARB")) == NULL) || r; - r = ((glMultiTexCoord4fvARB = (PFNGLMULTITEXCOORD4FVARBPROC)glewGetProcAddress((const GLubyte*)"glMultiTexCoord4fvARB")) == NULL) || r; - r = ((glMultiTexCoord4iARB = (PFNGLMULTITEXCOORD4IARBPROC)glewGetProcAddress((const GLubyte*)"glMultiTexCoord4iARB")) == NULL) || r; - r = ((glMultiTexCoord4ivARB = (PFNGLMULTITEXCOORD4IVARBPROC)glewGetProcAddress((const GLubyte*)"glMultiTexCoord4ivARB")) == NULL) || r; - r = ((glMultiTexCoord4sARB = (PFNGLMULTITEXCOORD4SARBPROC)glewGetProcAddress((const GLubyte*)"glMultiTexCoord4sARB")) == NULL) || r; - r = ((glMultiTexCoord4svARB = (PFNGLMULTITEXCOORD4SVARBPROC)glewGetProcAddress((const GLubyte*)"glMultiTexCoord4svARB")) == NULL) || r; - - return r; -} - -#endif /* GL_ARB_multitexture */ - -#ifdef GL_ARB_occlusion_query - -static GLboolean _glewInit_GL_ARB_occlusion_query (GLEW_CONTEXT_ARG_DEF_INIT) -{ - GLboolean r = GL_FALSE; - - r = ((glBeginQueryARB = (PFNGLBEGINQUERYARBPROC)glewGetProcAddress((const GLubyte*)"glBeginQueryARB")) == NULL) || r; - r = ((glDeleteQueriesARB = (PFNGLDELETEQUERIESARBPROC)glewGetProcAddress((const GLubyte*)"glDeleteQueriesARB")) == NULL) || r; - r = ((glEndQueryARB = (PFNGLENDQUERYARBPROC)glewGetProcAddress((const GLubyte*)"glEndQueryARB")) == NULL) || r; - r = ((glGenQueriesARB = (PFNGLGENQUERIESARBPROC)glewGetProcAddress((const GLubyte*)"glGenQueriesARB")) == NULL) || r; - r = ((glGetQueryObjectivARB = (PFNGLGETQUERYOBJECTIVARBPROC)glewGetProcAddress((const GLubyte*)"glGetQueryObjectivARB")) == NULL) || r; - r = ((glGetQueryObjectuivARB = (PFNGLGETQUERYOBJECTUIVARBPROC)glewGetProcAddress((const GLubyte*)"glGetQueryObjectuivARB")) == NULL) || r; - r = ((glGetQueryivARB = (PFNGLGETQUERYIVARBPROC)glewGetProcAddress((const GLubyte*)"glGetQueryivARB")) == NULL) || r; - r = ((glIsQueryARB = (PFNGLISQUERYARBPROC)glewGetProcAddress((const GLubyte*)"glIsQueryARB")) == NULL) || r; - - return r; -} - -#endif /* GL_ARB_occlusion_query */ - -#ifdef GL_ARB_pixel_buffer_object - -#endif /* GL_ARB_pixel_buffer_object */ - -#ifdef GL_ARB_point_parameters - -static GLboolean _glewInit_GL_ARB_point_parameters (GLEW_CONTEXT_ARG_DEF_INIT) -{ - GLboolean r = GL_FALSE; - - r = ((glPointParameterfARB = (PFNGLPOINTPARAMETERFARBPROC)glewGetProcAddress((const GLubyte*)"glPointParameterfARB")) == NULL) || r; - r = ((glPointParameterfvARB = (PFNGLPOINTPARAMETERFVARBPROC)glewGetProcAddress((const GLubyte*)"glPointParameterfvARB")) == NULL) || r; - - return r; -} - -#endif /* GL_ARB_point_parameters */ - -#ifdef GL_ARB_point_sprite - -#endif /* GL_ARB_point_sprite */ - -#ifdef GL_ARB_shader_objects - -static GLboolean _glewInit_GL_ARB_shader_objects (GLEW_CONTEXT_ARG_DEF_INIT) -{ - GLboolean r = GL_FALSE; - - r = ((glAttachObjectARB = (PFNGLATTACHOBJECTARBPROC)glewGetProcAddress((const GLubyte*)"glAttachObjectARB")) == NULL) || r; - r = ((glCompileShaderARB = (PFNGLCOMPILESHADERARBPROC)glewGetProcAddress((const GLubyte*)"glCompileShaderARB")) == NULL) || r; - r = ((glCreateProgramObjectARB = (PFNGLCREATEPROGRAMOBJECTARBPROC)glewGetProcAddress((const GLubyte*)"glCreateProgramObjectARB")) == NULL) || r; - r = ((glCreateShaderObjectARB = (PFNGLCREATESHADEROBJECTARBPROC)glewGetProcAddress((const GLubyte*)"glCreateShaderObjectARB")) == NULL) || r; - r = ((glDeleteObjectARB = (PFNGLDELETEOBJECTARBPROC)glewGetProcAddress((const GLubyte*)"glDeleteObjectARB")) == NULL) || r; - r = ((glDetachObjectARB = (PFNGLDETACHOBJECTARBPROC)glewGetProcAddress((const GLubyte*)"glDetachObjectARB")) == NULL) || r; - r = ((glGetActiveUniformARB = (PFNGLGETACTIVEUNIFORMARBPROC)glewGetProcAddress((const GLubyte*)"glGetActiveUniformARB")) == NULL) || r; - r = ((glGetAttachedObjectsARB = (PFNGLGETATTACHEDOBJECTSARBPROC)glewGetProcAddress((const GLubyte*)"glGetAttachedObjectsARB")) == NULL) || r; - r = ((glGetHandleARB = (PFNGLGETHANDLEARBPROC)glewGetProcAddress((const GLubyte*)"glGetHandleARB")) == NULL) || r; - r = ((glGetInfoLogARB = (PFNGLGETINFOLOGARBPROC)glewGetProcAddress((const GLubyte*)"glGetInfoLogARB")) == NULL) || r; - r = ((glGetObjectParameterfvARB = (PFNGLGETOBJECTPARAMETERFVARBPROC)glewGetProcAddress((const GLubyte*)"glGetObjectParameterfvARB")) == NULL) || r; - r = ((glGetObjectParameterivARB = (PFNGLGETOBJECTPARAMETERIVARBPROC)glewGetProcAddress((const GLubyte*)"glGetObjectParameterivARB")) == NULL) || r; - r = ((glGetShaderSourceARB = (PFNGLGETSHADERSOURCEARBPROC)glewGetProcAddress((const GLubyte*)"glGetShaderSourceARB")) == NULL) || r; - r = ((glGetUniformLocationARB = (PFNGLGETUNIFORMLOCATIONARBPROC)glewGetProcAddress((const GLubyte*)"glGetUniformLocationARB")) == NULL) || r; - r = ((glGetUniformfvARB = (PFNGLGETUNIFORMFVARBPROC)glewGetProcAddress((const GLubyte*)"glGetUniformfvARB")) == NULL) || r; - r = ((glGetUniformivARB = (PFNGLGETUNIFORMIVARBPROC)glewGetProcAddress((const GLubyte*)"glGetUniformivARB")) == NULL) || r; - r = ((glLinkProgramARB = (PFNGLLINKPROGRAMARBPROC)glewGetProcAddress((const GLubyte*)"glLinkProgramARB")) == NULL) || r; - r = ((glShaderSourceARB = (PFNGLSHADERSOURCEARBPROC)glewGetProcAddress((const GLubyte*)"glShaderSourceARB")) == NULL) || r; - r = ((glUniform1fARB = (PFNGLUNIFORM1FARBPROC)glewGetProcAddress((const GLubyte*)"glUniform1fARB")) == NULL) || r; - r = ((glUniform1fvARB = (PFNGLUNIFORM1FVARBPROC)glewGetProcAddress((const GLubyte*)"glUniform1fvARB")) == NULL) || r; - r = ((glUniform1iARB = (PFNGLUNIFORM1IARBPROC)glewGetProcAddress((const GLubyte*)"glUniform1iARB")) == NULL) || r; - r = ((glUniform1ivARB = (PFNGLUNIFORM1IVARBPROC)glewGetProcAddress((const GLubyte*)"glUniform1ivARB")) == NULL) || r; - r = ((glUniform2fARB = (PFNGLUNIFORM2FARBPROC)glewGetProcAddress((const GLubyte*)"glUniform2fARB")) == NULL) || r; - r = ((glUniform2fvARB = (PFNGLUNIFORM2FVARBPROC)glewGetProcAddress((const GLubyte*)"glUniform2fvARB")) == NULL) || r; - r = ((glUniform2iARB = (PFNGLUNIFORM2IARBPROC)glewGetProcAddress((const GLubyte*)"glUniform2iARB")) == NULL) || r; - r = ((glUniform2ivARB = (PFNGLUNIFORM2IVARBPROC)glewGetProcAddress((const GLubyte*)"glUniform2ivARB")) == NULL) || r; - r = ((glUniform3fARB = (PFNGLUNIFORM3FARBPROC)glewGetProcAddress((const GLubyte*)"glUniform3fARB")) == NULL) || r; - r = ((glUniform3fvARB = (PFNGLUNIFORM3FVARBPROC)glewGetProcAddress((const GLubyte*)"glUniform3fvARB")) == NULL) || r; - r = ((glUniform3iARB = (PFNGLUNIFORM3IARBPROC)glewGetProcAddress((const GLubyte*)"glUniform3iARB")) == NULL) || r; - r = ((glUniform3ivARB = (PFNGLUNIFORM3IVARBPROC)glewGetProcAddress((const GLubyte*)"glUniform3ivARB")) == NULL) || r; - r = ((glUniform4fARB = (PFNGLUNIFORM4FARBPROC)glewGetProcAddress((const GLubyte*)"glUniform4fARB")) == NULL) || r; - r = ((glUniform4fvARB = (PFNGLUNIFORM4FVARBPROC)glewGetProcAddress((const GLubyte*)"glUniform4fvARB")) == NULL) || r; - r = ((glUniform4iARB = (PFNGLUNIFORM4IARBPROC)glewGetProcAddress((const GLubyte*)"glUniform4iARB")) == NULL) || r; - r = ((glUniform4ivARB = (PFNGLUNIFORM4IVARBPROC)glewGetProcAddress((const GLubyte*)"glUniform4ivARB")) == NULL) || r; - r = ((glUniformMatrix2fvARB = (PFNGLUNIFORMMATRIX2FVARBPROC)glewGetProcAddress((const GLubyte*)"glUniformMatrix2fvARB")) == NULL) || r; - r = ((glUniformMatrix3fvARB = (PFNGLUNIFORMMATRIX3FVARBPROC)glewGetProcAddress((const GLubyte*)"glUniformMatrix3fvARB")) == NULL) || r; - r = ((glUniformMatrix4fvARB = (PFNGLUNIFORMMATRIX4FVARBPROC)glewGetProcAddress((const GLubyte*)"glUniformMatrix4fvARB")) == NULL) || r; - r = ((glUseProgramObjectARB = (PFNGLUSEPROGRAMOBJECTARBPROC)glewGetProcAddress((const GLubyte*)"glUseProgramObjectARB")) == NULL) || r; - r = ((glValidateProgramARB = (PFNGLVALIDATEPROGRAMARBPROC)glewGetProcAddress((const GLubyte*)"glValidateProgramARB")) == NULL) || r; - - return r; -} - -#endif /* GL_ARB_shader_objects */ - -#ifdef GL_ARB_shading_language_100 - -#endif /* GL_ARB_shading_language_100 */ - -#ifdef GL_ARB_shadow - -#endif /* GL_ARB_shadow */ - -#ifdef GL_ARB_shadow_ambient - -#endif /* GL_ARB_shadow_ambient */ - -#ifdef GL_ARB_texture_border_clamp - -#endif /* GL_ARB_texture_border_clamp */ - -#ifdef GL_ARB_texture_buffer_object - -static GLboolean _glewInit_GL_ARB_texture_buffer_object (GLEW_CONTEXT_ARG_DEF_INIT) -{ - GLboolean r = GL_FALSE; - - r = ((glTexBufferARB = (PFNGLTEXBUFFERARBPROC)glewGetProcAddress((const GLubyte*)"glTexBufferARB")) == NULL) || r; - - return r; -} - -#endif /* GL_ARB_texture_buffer_object */ - -#ifdef GL_ARB_texture_compression - -static GLboolean _glewInit_GL_ARB_texture_compression (GLEW_CONTEXT_ARG_DEF_INIT) -{ - GLboolean r = GL_FALSE; - - r = ((glCompressedTexImage1DARB = (PFNGLCOMPRESSEDTEXIMAGE1DARBPROC)glewGetProcAddress((const GLubyte*)"glCompressedTexImage1DARB")) == NULL) || r; - r = ((glCompressedTexImage2DARB = (PFNGLCOMPRESSEDTEXIMAGE2DARBPROC)glewGetProcAddress((const GLubyte*)"glCompressedTexImage2DARB")) == NULL) || r; - r = ((glCompressedTexImage3DARB = (PFNGLCOMPRESSEDTEXIMAGE3DARBPROC)glewGetProcAddress((const GLubyte*)"glCompressedTexImage3DARB")) == NULL) || r; - r = ((glCompressedTexSubImage1DARB = (PFNGLCOMPRESSEDTEXSUBIMAGE1DARBPROC)glewGetProcAddress((const GLubyte*)"glCompressedTexSubImage1DARB")) == NULL) || r; - r = ((glCompressedTexSubImage2DARB = (PFNGLCOMPRESSEDTEXSUBIMAGE2DARBPROC)glewGetProcAddress((const GLubyte*)"glCompressedTexSubImage2DARB")) == NULL) || r; - r = ((glCompressedTexSubImage3DARB = (PFNGLCOMPRESSEDTEXSUBIMAGE3DARBPROC)glewGetProcAddress((const GLubyte*)"glCompressedTexSubImage3DARB")) == NULL) || r; - r = ((glGetCompressedTexImageARB = (PFNGLGETCOMPRESSEDTEXIMAGEARBPROC)glewGetProcAddress((const GLubyte*)"glGetCompressedTexImageARB")) == NULL) || r; - - return r; -} - -#endif /* GL_ARB_texture_compression */ - -#ifdef GL_ARB_texture_compression_rgtc - -#endif /* GL_ARB_texture_compression_rgtc */ - -#ifdef GL_ARB_texture_cube_map - -#endif /* GL_ARB_texture_cube_map */ - -#ifdef GL_ARB_texture_env_add - -#endif /* GL_ARB_texture_env_add */ - -#ifdef GL_ARB_texture_env_combine - -#endif /* GL_ARB_texture_env_combine */ - -#ifdef GL_ARB_texture_env_crossbar - -#endif /* GL_ARB_texture_env_crossbar */ - -#ifdef GL_ARB_texture_env_dot3 - -#endif /* GL_ARB_texture_env_dot3 */ - -#ifdef GL_ARB_texture_float - -#endif /* GL_ARB_texture_float */ - -#ifdef GL_ARB_texture_mirrored_repeat - -#endif /* GL_ARB_texture_mirrored_repeat */ - -#ifdef GL_ARB_texture_non_power_of_two - -#endif /* GL_ARB_texture_non_power_of_two */ - -#ifdef GL_ARB_texture_rectangle - -#endif /* GL_ARB_texture_rectangle */ - -#ifdef GL_ARB_texture_rg - -#endif /* GL_ARB_texture_rg */ - -#ifdef GL_ARB_transpose_matrix - -static GLboolean _glewInit_GL_ARB_transpose_matrix (GLEW_CONTEXT_ARG_DEF_INIT) -{ - GLboolean r = GL_FALSE; - - r = ((glLoadTransposeMatrixdARB = (PFNGLLOADTRANSPOSEMATRIXDARBPROC)glewGetProcAddress((const GLubyte*)"glLoadTransposeMatrixdARB")) == NULL) || r; - r = ((glLoadTransposeMatrixfARB = (PFNGLLOADTRANSPOSEMATRIXFARBPROC)glewGetProcAddress((const GLubyte*)"glLoadTransposeMatrixfARB")) == NULL) || r; - r = ((glMultTransposeMatrixdARB = (PFNGLMULTTRANSPOSEMATRIXDARBPROC)glewGetProcAddress((const GLubyte*)"glMultTransposeMatrixdARB")) == NULL) || r; - r = ((glMultTransposeMatrixfARB = (PFNGLMULTTRANSPOSEMATRIXFARBPROC)glewGetProcAddress((const GLubyte*)"glMultTransposeMatrixfARB")) == NULL) || r; - - return r; -} - -#endif /* GL_ARB_transpose_matrix */ - -#ifdef GL_ARB_vertex_array_object - -static GLboolean _glewInit_GL_ARB_vertex_array_object (GLEW_CONTEXT_ARG_DEF_INIT) -{ - GLboolean r = GL_FALSE; - - r = ((glBindVertexArray = (PFNGLBINDVERTEXARRAYPROC)glewGetProcAddress((const GLubyte*)"glBindVertexArray")) == NULL) || r; - r = ((glDeleteVertexArrays = (PFNGLDELETEVERTEXARRAYSPROC)glewGetProcAddress((const GLubyte*)"glDeleteVertexArrays")) == NULL) || r; - r = ((glGenVertexArrays = (PFNGLGENVERTEXARRAYSPROC)glewGetProcAddress((const GLubyte*)"glGenVertexArrays")) == NULL) || r; - r = ((glIsVertexArray = (PFNGLISVERTEXARRAYPROC)glewGetProcAddress((const GLubyte*)"glIsVertexArray")) == NULL) || r; - - return r; -} - -#endif /* GL_ARB_vertex_array_object */ - -#ifdef GL_ARB_vertex_blend - -static GLboolean _glewInit_GL_ARB_vertex_blend (GLEW_CONTEXT_ARG_DEF_INIT) -{ - GLboolean r = GL_FALSE; - - r = ((glVertexBlendARB = (PFNGLVERTEXBLENDARBPROC)glewGetProcAddress((const GLubyte*)"glVertexBlendARB")) == NULL) || r; - r = ((glWeightPointerARB = (PFNGLWEIGHTPOINTERARBPROC)glewGetProcAddress((const GLubyte*)"glWeightPointerARB")) == NULL) || r; - r = ((glWeightbvARB = (PFNGLWEIGHTBVARBPROC)glewGetProcAddress((const GLubyte*)"glWeightbvARB")) == NULL) || r; - r = ((glWeightdvARB = (PFNGLWEIGHTDVARBPROC)glewGetProcAddress((const GLubyte*)"glWeightdvARB")) == NULL) || r; - r = ((glWeightfvARB = (PFNGLWEIGHTFVARBPROC)glewGetProcAddress((const GLubyte*)"glWeightfvARB")) == NULL) || r; - r = ((glWeightivARB = (PFNGLWEIGHTIVARBPROC)glewGetProcAddress((const GLubyte*)"glWeightivARB")) == NULL) || r; - r = ((glWeightsvARB = (PFNGLWEIGHTSVARBPROC)glewGetProcAddress((const GLubyte*)"glWeightsvARB")) == NULL) || r; - r = ((glWeightubvARB = (PFNGLWEIGHTUBVARBPROC)glewGetProcAddress((const GLubyte*)"glWeightubvARB")) == NULL) || r; - r = ((glWeightuivARB = (PFNGLWEIGHTUIVARBPROC)glewGetProcAddress((const GLubyte*)"glWeightuivARB")) == NULL) || r; - r = ((glWeightusvARB = (PFNGLWEIGHTUSVARBPROC)glewGetProcAddress((const GLubyte*)"glWeightusvARB")) == NULL) || r; - - return r; -} - -#endif /* GL_ARB_vertex_blend */ - -#ifdef GL_ARB_vertex_buffer_object - -static GLboolean _glewInit_GL_ARB_vertex_buffer_object (GLEW_CONTEXT_ARG_DEF_INIT) -{ - GLboolean r = GL_FALSE; - - r = ((glBindBufferARB = (PFNGLBINDBUFFERARBPROC)glewGetProcAddress((const GLubyte*)"glBindBufferARB")) == NULL) || r; - r = ((glBufferDataARB = (PFNGLBUFFERDATAARBPROC)glewGetProcAddress((const GLubyte*)"glBufferDataARB")) == NULL) || r; - r = ((glBufferSubDataARB = (PFNGLBUFFERSUBDATAARBPROC)glewGetProcAddress((const GLubyte*)"glBufferSubDataARB")) == NULL) || r; - r = ((glDeleteBuffersARB = (PFNGLDELETEBUFFERSARBPROC)glewGetProcAddress((const GLubyte*)"glDeleteBuffersARB")) == NULL) || r; - r = ((glGenBuffersARB = (PFNGLGENBUFFERSARBPROC)glewGetProcAddress((const GLubyte*)"glGenBuffersARB")) == NULL) || r; - r = ((glGetBufferParameterivARB = (PFNGLGETBUFFERPARAMETERIVARBPROC)glewGetProcAddress((const GLubyte*)"glGetBufferParameterivARB")) == NULL) || r; - r = ((glGetBufferPointervARB = (PFNGLGETBUFFERPOINTERVARBPROC)glewGetProcAddress((const GLubyte*)"glGetBufferPointervARB")) == NULL) || r; - r = ((glGetBufferSubDataARB = (PFNGLGETBUFFERSUBDATAARBPROC)glewGetProcAddress((const GLubyte*)"glGetBufferSubDataARB")) == NULL) || r; - r = ((glIsBufferARB = (PFNGLISBUFFERARBPROC)glewGetProcAddress((const GLubyte*)"glIsBufferARB")) == NULL) || r; - r = ((glMapBufferARB = (PFNGLMAPBUFFERARBPROC)glewGetProcAddress((const GLubyte*)"glMapBufferARB")) == NULL) || r; - r = ((glUnmapBufferARB = (PFNGLUNMAPBUFFERARBPROC)glewGetProcAddress((const GLubyte*)"glUnmapBufferARB")) == NULL) || r; - - return r; -} - -#endif /* GL_ARB_vertex_buffer_object */ - -#ifdef GL_ARB_vertex_program - -static GLboolean _glewInit_GL_ARB_vertex_program (GLEW_CONTEXT_ARG_DEF_INIT) -{ - GLboolean r = GL_FALSE; - - r = ((glBindProgramARB = (PFNGLBINDPROGRAMARBPROC)glewGetProcAddress((const GLubyte*)"glBindProgramARB")) == NULL) || r; - r = ((glDeleteProgramsARB = (PFNGLDELETEPROGRAMSARBPROC)glewGetProcAddress((const GLubyte*)"glDeleteProgramsARB")) == NULL) || r; - r = ((glDisableVertexAttribArrayARB = (PFNGLDISABLEVERTEXATTRIBARRAYARBPROC)glewGetProcAddress((const GLubyte*)"glDisableVertexAttribArrayARB")) == NULL) || r; - r = ((glEnableVertexAttribArrayARB = (PFNGLENABLEVERTEXATTRIBARRAYARBPROC)glewGetProcAddress((const GLubyte*)"glEnableVertexAttribArrayARB")) == NULL) || r; - r = ((glGenProgramsARB = (PFNGLGENPROGRAMSARBPROC)glewGetProcAddress((const GLubyte*)"glGenProgramsARB")) == NULL) || r; - r = ((glGetProgramEnvParameterdvARB = (PFNGLGETPROGRAMENVPARAMETERDVARBPROC)glewGetProcAddress((const GLubyte*)"glGetProgramEnvParameterdvARB")) == NULL) || r; - r = ((glGetProgramEnvParameterfvARB = (PFNGLGETPROGRAMENVPARAMETERFVARBPROC)glewGetProcAddress((const GLubyte*)"glGetProgramEnvParameterfvARB")) == NULL) || r; - r = ((glGetProgramLocalParameterdvARB = (PFNGLGETPROGRAMLOCALPARAMETERDVARBPROC)glewGetProcAddress((const GLubyte*)"glGetProgramLocalParameterdvARB")) == NULL) || r; - r = ((glGetProgramLocalParameterfvARB = (PFNGLGETPROGRAMLOCALPARAMETERFVARBPROC)glewGetProcAddress((const GLubyte*)"glGetProgramLocalParameterfvARB")) == NULL) || r; - r = ((glGetProgramStringARB = (PFNGLGETPROGRAMSTRINGARBPROC)glewGetProcAddress((const GLubyte*)"glGetProgramStringARB")) == NULL) || r; - r = ((glGetProgramivARB = (PFNGLGETPROGRAMIVARBPROC)glewGetProcAddress((const GLubyte*)"glGetProgramivARB")) == NULL) || r; - r = ((glGetVertexAttribPointervARB = (PFNGLGETVERTEXATTRIBPOINTERVARBPROC)glewGetProcAddress((const GLubyte*)"glGetVertexAttribPointervARB")) == NULL) || r; - r = ((glGetVertexAttribdvARB = (PFNGLGETVERTEXATTRIBDVARBPROC)glewGetProcAddress((const GLubyte*)"glGetVertexAttribdvARB")) == NULL) || r; - r = ((glGetVertexAttribfvARB = (PFNGLGETVERTEXATTRIBFVARBPROC)glewGetProcAddress((const GLubyte*)"glGetVertexAttribfvARB")) == NULL) || r; - r = ((glGetVertexAttribivARB = (PFNGLGETVERTEXATTRIBIVARBPROC)glewGetProcAddress((const GLubyte*)"glGetVertexAttribivARB")) == NULL) || r; - r = ((glIsProgramARB = (PFNGLISPROGRAMARBPROC)glewGetProcAddress((const GLubyte*)"glIsProgramARB")) == NULL) || r; - r = ((glProgramEnvParameter4dARB = (PFNGLPROGRAMENVPARAMETER4DARBPROC)glewGetProcAddress((const GLubyte*)"glProgramEnvParameter4dARB")) == NULL) || r; - r = ((glProgramEnvParameter4dvARB = (PFNGLPROGRAMENVPARAMETER4DVARBPROC)glewGetProcAddress((const GLubyte*)"glProgramEnvParameter4dvARB")) == NULL) || r; - r = ((glProgramEnvParameter4fARB = (PFNGLPROGRAMENVPARAMETER4FARBPROC)glewGetProcAddress((const GLubyte*)"glProgramEnvParameter4fARB")) == NULL) || r; - r = ((glProgramEnvParameter4fvARB = (PFNGLPROGRAMENVPARAMETER4FVARBPROC)glewGetProcAddress((const GLubyte*)"glProgramEnvParameter4fvARB")) == NULL) || r; - r = ((glProgramLocalParameter4dARB = (PFNGLPROGRAMLOCALPARAMETER4DARBPROC)glewGetProcAddress((const GLubyte*)"glProgramLocalParameter4dARB")) == NULL) || r; - r = ((glProgramLocalParameter4dvARB = (PFNGLPROGRAMLOCALPARAMETER4DVARBPROC)glewGetProcAddress((const GLubyte*)"glProgramLocalParameter4dvARB")) == NULL) || r; - r = ((glProgramLocalParameter4fARB = (PFNGLPROGRAMLOCALPARAMETER4FARBPROC)glewGetProcAddress((const GLubyte*)"glProgramLocalParameter4fARB")) == NULL) || r; - r = ((glProgramLocalParameter4fvARB = (PFNGLPROGRAMLOCALPARAMETER4FVARBPROC)glewGetProcAddress((const GLubyte*)"glProgramLocalParameter4fvARB")) == NULL) || r; - r = ((glProgramStringARB = (PFNGLPROGRAMSTRINGARBPROC)glewGetProcAddress((const GLubyte*)"glProgramStringARB")) == NULL) || r; - r = ((glVertexAttrib1dARB = (PFNGLVERTEXATTRIB1DARBPROC)glewGetProcAddress((const GLubyte*)"glVertexAttrib1dARB")) == NULL) || r; - r = ((glVertexAttrib1dvARB = (PFNGLVERTEXATTRIB1DVARBPROC)glewGetProcAddress((const GLubyte*)"glVertexAttrib1dvARB")) == NULL) || r; - r = ((glVertexAttrib1fARB = (PFNGLVERTEXATTRIB1FARBPROC)glewGetProcAddress((const GLubyte*)"glVertexAttrib1fARB")) == NULL) || r; - r = ((glVertexAttrib1fvARB = (PFNGLVERTEXATTRIB1FVARBPROC)glewGetProcAddress((const GLubyte*)"glVertexAttrib1fvARB")) == NULL) || r; - r = ((glVertexAttrib1sARB = (PFNGLVERTEXATTRIB1SARBPROC)glewGetProcAddress((const GLubyte*)"glVertexAttrib1sARB")) == NULL) || r; - r = ((glVertexAttrib1svARB = (PFNGLVERTEXATTRIB1SVARBPROC)glewGetProcAddress((const GLubyte*)"glVertexAttrib1svARB")) == NULL) || r; - r = ((glVertexAttrib2dARB = (PFNGLVERTEXATTRIB2DARBPROC)glewGetProcAddress((const GLubyte*)"glVertexAttrib2dARB")) == NULL) || r; - r = ((glVertexAttrib2dvARB = (PFNGLVERTEXATTRIB2DVARBPROC)glewGetProcAddress((const GLubyte*)"glVertexAttrib2dvARB")) == NULL) || r; - r = ((glVertexAttrib2fARB = (PFNGLVERTEXATTRIB2FARBPROC)glewGetProcAddress((const GLubyte*)"glVertexAttrib2fARB")) == NULL) || r; - r = ((glVertexAttrib2fvARB = (PFNGLVERTEXATTRIB2FVARBPROC)glewGetProcAddress((const GLubyte*)"glVertexAttrib2fvARB")) == NULL) || r; - r = ((glVertexAttrib2sARB = (PFNGLVERTEXATTRIB2SARBPROC)glewGetProcAddress((const GLubyte*)"glVertexAttrib2sARB")) == NULL) || r; - r = ((glVertexAttrib2svARB = (PFNGLVERTEXATTRIB2SVARBPROC)glewGetProcAddress((const GLubyte*)"glVertexAttrib2svARB")) == NULL) || r; - r = ((glVertexAttrib3dARB = (PFNGLVERTEXATTRIB3DARBPROC)glewGetProcAddress((const GLubyte*)"glVertexAttrib3dARB")) == NULL) || r; - r = ((glVertexAttrib3dvARB = (PFNGLVERTEXATTRIB3DVARBPROC)glewGetProcAddress((const GLubyte*)"glVertexAttrib3dvARB")) == NULL) || r; - r = ((glVertexAttrib3fARB = (PFNGLVERTEXATTRIB3FARBPROC)glewGetProcAddress((const GLubyte*)"glVertexAttrib3fARB")) == NULL) || r; - r = ((glVertexAttrib3fvARB = (PFNGLVERTEXATTRIB3FVARBPROC)glewGetProcAddress((const GLubyte*)"glVertexAttrib3fvARB")) == NULL) || r; - r = ((glVertexAttrib3sARB = (PFNGLVERTEXATTRIB3SARBPROC)glewGetProcAddress((const GLubyte*)"glVertexAttrib3sARB")) == NULL) || r; - r = ((glVertexAttrib3svARB = (PFNGLVERTEXATTRIB3SVARBPROC)glewGetProcAddress((const GLubyte*)"glVertexAttrib3svARB")) == NULL) || r; - r = ((glVertexAttrib4NbvARB = (PFNGLVERTEXATTRIB4NBVARBPROC)glewGetProcAddress((const GLubyte*)"glVertexAttrib4NbvARB")) == NULL) || r; - r = ((glVertexAttrib4NivARB = (PFNGLVERTEXATTRIB4NIVARBPROC)glewGetProcAddress((const GLubyte*)"glVertexAttrib4NivARB")) == NULL) || r; - r = ((glVertexAttrib4NsvARB = (PFNGLVERTEXATTRIB4NSVARBPROC)glewGetProcAddress((const GLubyte*)"glVertexAttrib4NsvARB")) == NULL) || r; - r = ((glVertexAttrib4NubARB = (PFNGLVERTEXATTRIB4NUBARBPROC)glewGetProcAddress((const GLubyte*)"glVertexAttrib4NubARB")) == NULL) || r; - r = ((glVertexAttrib4NubvARB = (PFNGLVERTEXATTRIB4NUBVARBPROC)glewGetProcAddress((const GLubyte*)"glVertexAttrib4NubvARB")) == NULL) || r; - r = ((glVertexAttrib4NuivARB = (PFNGLVERTEXATTRIB4NUIVARBPROC)glewGetProcAddress((const GLubyte*)"glVertexAttrib4NuivARB")) == NULL) || r; - r = ((glVertexAttrib4NusvARB = (PFNGLVERTEXATTRIB4NUSVARBPROC)glewGetProcAddress((const GLubyte*)"glVertexAttrib4NusvARB")) == NULL) || r; - r = ((glVertexAttrib4bvARB = (PFNGLVERTEXATTRIB4BVARBPROC)glewGetProcAddress((const GLubyte*)"glVertexAttrib4bvARB")) == NULL) || r; - r = ((glVertexAttrib4dARB = (PFNGLVERTEXATTRIB4DARBPROC)glewGetProcAddress((const GLubyte*)"glVertexAttrib4dARB")) == NULL) || r; - r = ((glVertexAttrib4dvARB = (PFNGLVERTEXATTRIB4DVARBPROC)glewGetProcAddress((const GLubyte*)"glVertexAttrib4dvARB")) == NULL) || r; - r = ((glVertexAttrib4fARB = (PFNGLVERTEXATTRIB4FARBPROC)glewGetProcAddress((const GLubyte*)"glVertexAttrib4fARB")) == NULL) || r; - r = ((glVertexAttrib4fvARB = (PFNGLVERTEXATTRIB4FVARBPROC)glewGetProcAddress((const GLubyte*)"glVertexAttrib4fvARB")) == NULL) || r; - r = ((glVertexAttrib4ivARB = (PFNGLVERTEXATTRIB4IVARBPROC)glewGetProcAddress((const GLubyte*)"glVertexAttrib4ivARB")) == NULL) || r; - r = ((glVertexAttrib4sARB = (PFNGLVERTEXATTRIB4SARBPROC)glewGetProcAddress((const GLubyte*)"glVertexAttrib4sARB")) == NULL) || r; - r = ((glVertexAttrib4svARB = (PFNGLVERTEXATTRIB4SVARBPROC)glewGetProcAddress((const GLubyte*)"glVertexAttrib4svARB")) == NULL) || r; - r = ((glVertexAttrib4ubvARB = (PFNGLVERTEXATTRIB4UBVARBPROC)glewGetProcAddress((const GLubyte*)"glVertexAttrib4ubvARB")) == NULL) || r; - r = ((glVertexAttrib4uivARB = (PFNGLVERTEXATTRIB4UIVARBPROC)glewGetProcAddress((const GLubyte*)"glVertexAttrib4uivARB")) == NULL) || r; - r = ((glVertexAttrib4usvARB = (PFNGLVERTEXATTRIB4USVARBPROC)glewGetProcAddress((const GLubyte*)"glVertexAttrib4usvARB")) == NULL) || r; - r = ((glVertexAttribPointerARB = (PFNGLVERTEXATTRIBPOINTERARBPROC)glewGetProcAddress((const GLubyte*)"glVertexAttribPointerARB")) == NULL) || r; - - return r; -} - -#endif /* GL_ARB_vertex_program */ - -#ifdef GL_ARB_vertex_shader - -static GLboolean _glewInit_GL_ARB_vertex_shader (GLEW_CONTEXT_ARG_DEF_INIT) -{ - GLboolean r = GL_FALSE; - - r = ((glBindAttribLocationARB = (PFNGLBINDATTRIBLOCATIONARBPROC)glewGetProcAddress((const GLubyte*)"glBindAttribLocationARB")) == NULL) || r; - r = ((glGetActiveAttribARB = (PFNGLGETACTIVEATTRIBARBPROC)glewGetProcAddress((const GLubyte*)"glGetActiveAttribARB")) == NULL) || r; - r = ((glGetAttribLocationARB = (PFNGLGETATTRIBLOCATIONARBPROC)glewGetProcAddress((const GLubyte*)"glGetAttribLocationARB")) == NULL) || r; - - return r; -} - -#endif /* GL_ARB_vertex_shader */ - -#ifdef GL_ARB_window_pos - -static GLboolean _glewInit_GL_ARB_window_pos (GLEW_CONTEXT_ARG_DEF_INIT) -{ - GLboolean r = GL_FALSE; - - r = ((glWindowPos2dARB = (PFNGLWINDOWPOS2DARBPROC)glewGetProcAddress((const GLubyte*)"glWindowPos2dARB")) == NULL) || r; - r = ((glWindowPos2dvARB = (PFNGLWINDOWPOS2DVARBPROC)glewGetProcAddress((const GLubyte*)"glWindowPos2dvARB")) == NULL) || r; - r = ((glWindowPos2fARB = (PFNGLWINDOWPOS2FARBPROC)glewGetProcAddress((const GLubyte*)"glWindowPos2fARB")) == NULL) || r; - r = ((glWindowPos2fvARB = (PFNGLWINDOWPOS2FVARBPROC)glewGetProcAddress((const GLubyte*)"glWindowPos2fvARB")) == NULL) || r; - r = ((glWindowPos2iARB = (PFNGLWINDOWPOS2IARBPROC)glewGetProcAddress((const GLubyte*)"glWindowPos2iARB")) == NULL) || r; - r = ((glWindowPos2ivARB = (PFNGLWINDOWPOS2IVARBPROC)glewGetProcAddress((const GLubyte*)"glWindowPos2ivARB")) == NULL) || r; - r = ((glWindowPos2sARB = (PFNGLWINDOWPOS2SARBPROC)glewGetProcAddress((const GLubyte*)"glWindowPos2sARB")) == NULL) || r; - r = ((glWindowPos2svARB = (PFNGLWINDOWPOS2SVARBPROC)glewGetProcAddress((const GLubyte*)"glWindowPos2svARB")) == NULL) || r; - r = ((glWindowPos3dARB = (PFNGLWINDOWPOS3DARBPROC)glewGetProcAddress((const GLubyte*)"glWindowPos3dARB")) == NULL) || r; - r = ((glWindowPos3dvARB = (PFNGLWINDOWPOS3DVARBPROC)glewGetProcAddress((const GLubyte*)"glWindowPos3dvARB")) == NULL) || r; - r = ((glWindowPos3fARB = (PFNGLWINDOWPOS3FARBPROC)glewGetProcAddress((const GLubyte*)"glWindowPos3fARB")) == NULL) || r; - r = ((glWindowPos3fvARB = (PFNGLWINDOWPOS3FVARBPROC)glewGetProcAddress((const GLubyte*)"glWindowPos3fvARB")) == NULL) || r; - r = ((glWindowPos3iARB = (PFNGLWINDOWPOS3IARBPROC)glewGetProcAddress((const GLubyte*)"glWindowPos3iARB")) == NULL) || r; - r = ((glWindowPos3ivARB = (PFNGLWINDOWPOS3IVARBPROC)glewGetProcAddress((const GLubyte*)"glWindowPos3ivARB")) == NULL) || r; - r = ((glWindowPos3sARB = (PFNGLWINDOWPOS3SARBPROC)glewGetProcAddress((const GLubyte*)"glWindowPos3sARB")) == NULL) || r; - r = ((glWindowPos3svARB = (PFNGLWINDOWPOS3SVARBPROC)glewGetProcAddress((const GLubyte*)"glWindowPos3svARB")) == NULL) || r; - - return r; -} - -#endif /* GL_ARB_window_pos */ - -#ifdef GL_ATIX_point_sprites - -#endif /* GL_ATIX_point_sprites */ - -#ifdef GL_ATIX_texture_env_combine3 - -#endif /* GL_ATIX_texture_env_combine3 */ - -#ifdef GL_ATIX_texture_env_route - -#endif /* GL_ATIX_texture_env_route */ - -#ifdef GL_ATIX_vertex_shader_output_point_size - -#endif /* GL_ATIX_vertex_shader_output_point_size */ - -#ifdef GL_ATI_draw_buffers - -static GLboolean _glewInit_GL_ATI_draw_buffers (GLEW_CONTEXT_ARG_DEF_INIT) -{ - GLboolean r = GL_FALSE; - - r = ((glDrawBuffersATI = (PFNGLDRAWBUFFERSATIPROC)glewGetProcAddress((const GLubyte*)"glDrawBuffersATI")) == NULL) || r; - - return r; -} - -#endif /* GL_ATI_draw_buffers */ - -#ifdef GL_ATI_element_array - -static GLboolean _glewInit_GL_ATI_element_array (GLEW_CONTEXT_ARG_DEF_INIT) -{ - GLboolean r = GL_FALSE; - - r = ((glDrawElementArrayATI = (PFNGLDRAWELEMENTARRAYATIPROC)glewGetProcAddress((const GLubyte*)"glDrawElementArrayATI")) == NULL) || r; - r = ((glDrawRangeElementArrayATI = (PFNGLDRAWRANGEELEMENTARRAYATIPROC)glewGetProcAddress((const GLubyte*)"glDrawRangeElementArrayATI")) == NULL) || r; - r = ((glElementPointerATI = (PFNGLELEMENTPOINTERATIPROC)glewGetProcAddress((const GLubyte*)"glElementPointerATI")) == NULL) || r; - - return r; -} - -#endif /* GL_ATI_element_array */ - -#ifdef GL_ATI_envmap_bumpmap - -static GLboolean _glewInit_GL_ATI_envmap_bumpmap (GLEW_CONTEXT_ARG_DEF_INIT) -{ - GLboolean r = GL_FALSE; - - r = ((glGetTexBumpParameterfvATI = (PFNGLGETTEXBUMPPARAMETERFVATIPROC)glewGetProcAddress((const GLubyte*)"glGetTexBumpParameterfvATI")) == NULL) || r; - r = ((glGetTexBumpParameterivATI = (PFNGLGETTEXBUMPPARAMETERIVATIPROC)glewGetProcAddress((const GLubyte*)"glGetTexBumpParameterivATI")) == NULL) || r; - r = ((glTexBumpParameterfvATI = (PFNGLTEXBUMPPARAMETERFVATIPROC)glewGetProcAddress((const GLubyte*)"glTexBumpParameterfvATI")) == NULL) || r; - r = ((glTexBumpParameterivATI = (PFNGLTEXBUMPPARAMETERIVATIPROC)glewGetProcAddress((const GLubyte*)"glTexBumpParameterivATI")) == NULL) || r; - - return r; -} - -#endif /* GL_ATI_envmap_bumpmap */ - -#ifdef GL_ATI_fragment_shader - -static GLboolean _glewInit_GL_ATI_fragment_shader (GLEW_CONTEXT_ARG_DEF_INIT) -{ - GLboolean r = GL_FALSE; - - r = ((glAlphaFragmentOp1ATI = (PFNGLALPHAFRAGMENTOP1ATIPROC)glewGetProcAddress((const GLubyte*)"glAlphaFragmentOp1ATI")) == NULL) || r; - r = ((glAlphaFragmentOp2ATI = (PFNGLALPHAFRAGMENTOP2ATIPROC)glewGetProcAddress((const GLubyte*)"glAlphaFragmentOp2ATI")) == NULL) || r; - r = ((glAlphaFragmentOp3ATI = (PFNGLALPHAFRAGMENTOP3ATIPROC)glewGetProcAddress((const GLubyte*)"glAlphaFragmentOp3ATI")) == NULL) || r; - r = ((glBeginFragmentShaderATI = (PFNGLBEGINFRAGMENTSHADERATIPROC)glewGetProcAddress((const GLubyte*)"glBeginFragmentShaderATI")) == NULL) || r; - r = ((glBindFragmentShaderATI = (PFNGLBINDFRAGMENTSHADERATIPROC)glewGetProcAddress((const GLubyte*)"glBindFragmentShaderATI")) == NULL) || r; - r = ((glColorFragmentOp1ATI = (PFNGLCOLORFRAGMENTOP1ATIPROC)glewGetProcAddress((const GLubyte*)"glColorFragmentOp1ATI")) == NULL) || r; - r = ((glColorFragmentOp2ATI = (PFNGLCOLORFRAGMENTOP2ATIPROC)glewGetProcAddress((const GLubyte*)"glColorFragmentOp2ATI")) == NULL) || r; - r = ((glColorFragmentOp3ATI = (PFNGLCOLORFRAGMENTOP3ATIPROC)glewGetProcAddress((const GLubyte*)"glColorFragmentOp3ATI")) == NULL) || r; - r = ((glDeleteFragmentShaderATI = (PFNGLDELETEFRAGMENTSHADERATIPROC)glewGetProcAddress((const GLubyte*)"glDeleteFragmentShaderATI")) == NULL) || r; - r = ((glEndFragmentShaderATI = (PFNGLENDFRAGMENTSHADERATIPROC)glewGetProcAddress((const GLubyte*)"glEndFragmentShaderATI")) == NULL) || r; - r = ((glGenFragmentShadersATI = (PFNGLGENFRAGMENTSHADERSATIPROC)glewGetProcAddress((const GLubyte*)"glGenFragmentShadersATI")) == NULL) || r; - r = ((glPassTexCoordATI = (PFNGLPASSTEXCOORDATIPROC)glewGetProcAddress((const GLubyte*)"glPassTexCoordATI")) == NULL) || r; - r = ((glSampleMapATI = (PFNGLSAMPLEMAPATIPROC)glewGetProcAddress((const GLubyte*)"glSampleMapATI")) == NULL) || r; - r = ((glSetFragmentShaderConstantATI = (PFNGLSETFRAGMENTSHADERCONSTANTATIPROC)glewGetProcAddress((const GLubyte*)"glSetFragmentShaderConstantATI")) == NULL) || r; - - return r; -} - -#endif /* GL_ATI_fragment_shader */ - -#ifdef GL_ATI_map_object_buffer - -static GLboolean _glewInit_GL_ATI_map_object_buffer (GLEW_CONTEXT_ARG_DEF_INIT) -{ - GLboolean r = GL_FALSE; - - r = ((glMapObjectBufferATI = (PFNGLMAPOBJECTBUFFERATIPROC)glewGetProcAddress((const GLubyte*)"glMapObjectBufferATI")) == NULL) || r; - r = ((glUnmapObjectBufferATI = (PFNGLUNMAPOBJECTBUFFERATIPROC)glewGetProcAddress((const GLubyte*)"glUnmapObjectBufferATI")) == NULL) || r; - - return r; -} - -#endif /* GL_ATI_map_object_buffer */ - -#ifdef GL_ATI_pn_triangles - -static GLboolean _glewInit_GL_ATI_pn_triangles (GLEW_CONTEXT_ARG_DEF_INIT) -{ - GLboolean r = GL_FALSE; - - r = ((glPNTrianglesfATI = (PFNGLPNTRIANGLESFATIPROC)glewGetProcAddress((const GLubyte*)"glPNTrianglesfATI")) == NULL) || r; - r = ((glPNTrianglesiATI = (PFNGLPNTRIANGLESIATIPROC)glewGetProcAddress((const GLubyte*)"glPNTrianglesiATI")) == NULL) || r; - - return r; -} - -#endif /* GL_ATI_pn_triangles */ - -#ifdef GL_ATI_separate_stencil - -static GLboolean _glewInit_GL_ATI_separate_stencil (GLEW_CONTEXT_ARG_DEF_INIT) -{ - GLboolean r = GL_FALSE; - - r = ((glStencilFuncSeparateATI = (PFNGLSTENCILFUNCSEPARATEATIPROC)glewGetProcAddress((const GLubyte*)"glStencilFuncSeparateATI")) == NULL) || r; - r = ((glStencilOpSeparateATI = (PFNGLSTENCILOPSEPARATEATIPROC)glewGetProcAddress((const GLubyte*)"glStencilOpSeparateATI")) == NULL) || r; - - return r; -} - -#endif /* GL_ATI_separate_stencil */ - -#ifdef GL_ATI_shader_texture_lod - -#endif /* GL_ATI_shader_texture_lod */ - -#ifdef GL_ATI_text_fragment_shader - -#endif /* GL_ATI_text_fragment_shader */ - -#ifdef GL_ATI_texture_compression_3dc - -#endif /* GL_ATI_texture_compression_3dc */ - -#ifdef GL_ATI_texture_env_combine3 - -#endif /* GL_ATI_texture_env_combine3 */ - -#ifdef GL_ATI_texture_float - -#endif /* GL_ATI_texture_float */ - -#ifdef GL_ATI_texture_mirror_once - -#endif /* GL_ATI_texture_mirror_once */ - -#ifdef GL_ATI_vertex_array_object - -static GLboolean _glewInit_GL_ATI_vertex_array_object (GLEW_CONTEXT_ARG_DEF_INIT) -{ - GLboolean r = GL_FALSE; - - r = ((glArrayObjectATI = (PFNGLARRAYOBJECTATIPROC)glewGetProcAddress((const GLubyte*)"glArrayObjectATI")) == NULL) || r; - r = ((glFreeObjectBufferATI = (PFNGLFREEOBJECTBUFFERATIPROC)glewGetProcAddress((const GLubyte*)"glFreeObjectBufferATI")) == NULL) || r; - r = ((glGetArrayObjectfvATI = (PFNGLGETARRAYOBJECTFVATIPROC)glewGetProcAddress((const GLubyte*)"glGetArrayObjectfvATI")) == NULL) || r; - r = ((glGetArrayObjectivATI = (PFNGLGETARRAYOBJECTIVATIPROC)glewGetProcAddress((const GLubyte*)"glGetArrayObjectivATI")) == NULL) || r; - r = ((glGetObjectBufferfvATI = (PFNGLGETOBJECTBUFFERFVATIPROC)glewGetProcAddress((const GLubyte*)"glGetObjectBufferfvATI")) == NULL) || r; - r = ((glGetObjectBufferivATI = (PFNGLGETOBJECTBUFFERIVATIPROC)glewGetProcAddress((const GLubyte*)"glGetObjectBufferivATI")) == NULL) || r; - r = ((glGetVariantArrayObjectfvATI = (PFNGLGETVARIANTARRAYOBJECTFVATIPROC)glewGetProcAddress((const GLubyte*)"glGetVariantArrayObjectfvATI")) == NULL) || r; - r = ((glGetVariantArrayObjectivATI = (PFNGLGETVARIANTARRAYOBJECTIVATIPROC)glewGetProcAddress((const GLubyte*)"glGetVariantArrayObjectivATI")) == NULL) || r; - r = ((glIsObjectBufferATI = (PFNGLISOBJECTBUFFERATIPROC)glewGetProcAddress((const GLubyte*)"glIsObjectBufferATI")) == NULL) || r; - r = ((glNewObjectBufferATI = (PFNGLNEWOBJECTBUFFERATIPROC)glewGetProcAddress((const GLubyte*)"glNewObjectBufferATI")) == NULL) || r; - r = ((glUpdateObjectBufferATI = (PFNGLUPDATEOBJECTBUFFERATIPROC)glewGetProcAddress((const GLubyte*)"glUpdateObjectBufferATI")) == NULL) || r; - r = ((glVariantArrayObjectATI = (PFNGLVARIANTARRAYOBJECTATIPROC)glewGetProcAddress((const GLubyte*)"glVariantArrayObjectATI")) == NULL) || r; - - return r; -} - -#endif /* GL_ATI_vertex_array_object */ - -#ifdef GL_ATI_vertex_attrib_array_object - -static GLboolean _glewInit_GL_ATI_vertex_attrib_array_object (GLEW_CONTEXT_ARG_DEF_INIT) -{ - GLboolean r = GL_FALSE; - - r = ((glGetVertexAttribArrayObjectfvATI = (PFNGLGETVERTEXATTRIBARRAYOBJECTFVATIPROC)glewGetProcAddress((const GLubyte*)"glGetVertexAttribArrayObjectfvATI")) == NULL) || r; - r = ((glGetVertexAttribArrayObjectivATI = (PFNGLGETVERTEXATTRIBARRAYOBJECTIVATIPROC)glewGetProcAddress((const GLubyte*)"glGetVertexAttribArrayObjectivATI")) == NULL) || r; - r = ((glVertexAttribArrayObjectATI = (PFNGLVERTEXATTRIBARRAYOBJECTATIPROC)glewGetProcAddress((const GLubyte*)"glVertexAttribArrayObjectATI")) == NULL) || r; - - return r; -} - -#endif /* GL_ATI_vertex_attrib_array_object */ - -#ifdef GL_ATI_vertex_streams - -static GLboolean _glewInit_GL_ATI_vertex_streams (GLEW_CONTEXT_ARG_DEF_INIT) -{ - GLboolean r = GL_FALSE; - - r = ((glClientActiveVertexStreamATI = (PFNGLCLIENTACTIVEVERTEXSTREAMATIPROC)glewGetProcAddress((const GLubyte*)"glClientActiveVertexStreamATI")) == NULL) || r; - r = ((glNormalStream3bATI = (PFNGLNORMALSTREAM3BATIPROC)glewGetProcAddress((const GLubyte*)"glNormalStream3bATI")) == NULL) || r; - r = ((glNormalStream3bvATI = (PFNGLNORMALSTREAM3BVATIPROC)glewGetProcAddress((const GLubyte*)"glNormalStream3bvATI")) == NULL) || r; - r = ((glNormalStream3dATI = (PFNGLNORMALSTREAM3DATIPROC)glewGetProcAddress((const GLubyte*)"glNormalStream3dATI")) == NULL) || r; - r = ((glNormalStream3dvATI = (PFNGLNORMALSTREAM3DVATIPROC)glewGetProcAddress((const GLubyte*)"glNormalStream3dvATI")) == NULL) || r; - r = ((glNormalStream3fATI = (PFNGLNORMALSTREAM3FATIPROC)glewGetProcAddress((const GLubyte*)"glNormalStream3fATI")) == NULL) || r; - r = ((glNormalStream3fvATI = (PFNGLNORMALSTREAM3FVATIPROC)glewGetProcAddress((const GLubyte*)"glNormalStream3fvATI")) == NULL) || r; - r = ((glNormalStream3iATI = (PFNGLNORMALSTREAM3IATIPROC)glewGetProcAddress((const GLubyte*)"glNormalStream3iATI")) == NULL) || r; - r = ((glNormalStream3ivATI = (PFNGLNORMALSTREAM3IVATIPROC)glewGetProcAddress((const GLubyte*)"glNormalStream3ivATI")) == NULL) || r; - r = ((glNormalStream3sATI = (PFNGLNORMALSTREAM3SATIPROC)glewGetProcAddress((const GLubyte*)"glNormalStream3sATI")) == NULL) || r; - r = ((glNormalStream3svATI = (PFNGLNORMALSTREAM3SVATIPROC)glewGetProcAddress((const GLubyte*)"glNormalStream3svATI")) == NULL) || r; - r = ((glVertexBlendEnvfATI = (PFNGLVERTEXBLENDENVFATIPROC)glewGetProcAddress((const GLubyte*)"glVertexBlendEnvfATI")) == NULL) || r; - r = ((glVertexBlendEnviATI = (PFNGLVERTEXBLENDENVIATIPROC)glewGetProcAddress((const GLubyte*)"glVertexBlendEnviATI")) == NULL) || r; - r = ((glVertexStream2dATI = (PFNGLVERTEXSTREAM2DATIPROC)glewGetProcAddress((const GLubyte*)"glVertexStream2dATI")) == NULL) || r; - r = ((glVertexStream2dvATI = (PFNGLVERTEXSTREAM2DVATIPROC)glewGetProcAddress((const GLubyte*)"glVertexStream2dvATI")) == NULL) || r; - r = ((glVertexStream2fATI = (PFNGLVERTEXSTREAM2FATIPROC)glewGetProcAddress((const GLubyte*)"glVertexStream2fATI")) == NULL) || r; - r = ((glVertexStream2fvATI = (PFNGLVERTEXSTREAM2FVATIPROC)glewGetProcAddress((const GLubyte*)"glVertexStream2fvATI")) == NULL) || r; - r = ((glVertexStream2iATI = (PFNGLVERTEXSTREAM2IATIPROC)glewGetProcAddress((const GLubyte*)"glVertexStream2iATI")) == NULL) || r; - r = ((glVertexStream2ivATI = (PFNGLVERTEXSTREAM2IVATIPROC)glewGetProcAddress((const GLubyte*)"glVertexStream2ivATI")) == NULL) || r; - r = ((glVertexStream2sATI = (PFNGLVERTEXSTREAM2SATIPROC)glewGetProcAddress((const GLubyte*)"glVertexStream2sATI")) == NULL) || r; - r = ((glVertexStream2svATI = (PFNGLVERTEXSTREAM2SVATIPROC)glewGetProcAddress((const GLubyte*)"glVertexStream2svATI")) == NULL) || r; - r = ((glVertexStream3dATI = (PFNGLVERTEXSTREAM3DATIPROC)glewGetProcAddress((const GLubyte*)"glVertexStream3dATI")) == NULL) || r; - r = ((glVertexStream3dvATI = (PFNGLVERTEXSTREAM3DVATIPROC)glewGetProcAddress((const GLubyte*)"glVertexStream3dvATI")) == NULL) || r; - r = ((glVertexStream3fATI = (PFNGLVERTEXSTREAM3FATIPROC)glewGetProcAddress((const GLubyte*)"glVertexStream3fATI")) == NULL) || r; - r = ((glVertexStream3fvATI = (PFNGLVERTEXSTREAM3FVATIPROC)glewGetProcAddress((const GLubyte*)"glVertexStream3fvATI")) == NULL) || r; - r = ((glVertexStream3iATI = (PFNGLVERTEXSTREAM3IATIPROC)glewGetProcAddress((const GLubyte*)"glVertexStream3iATI")) == NULL) || r; - r = ((glVertexStream3ivATI = (PFNGLVERTEXSTREAM3IVATIPROC)glewGetProcAddress((const GLubyte*)"glVertexStream3ivATI")) == NULL) || r; - r = ((glVertexStream3sATI = (PFNGLVERTEXSTREAM3SATIPROC)glewGetProcAddress((const GLubyte*)"glVertexStream3sATI")) == NULL) || r; - r = ((glVertexStream3svATI = (PFNGLVERTEXSTREAM3SVATIPROC)glewGetProcAddress((const GLubyte*)"glVertexStream3svATI")) == NULL) || r; - r = ((glVertexStream4dATI = (PFNGLVERTEXSTREAM4DATIPROC)glewGetProcAddress((const GLubyte*)"glVertexStream4dATI")) == NULL) || r; - r = ((glVertexStream4dvATI = (PFNGLVERTEXSTREAM4DVATIPROC)glewGetProcAddress((const GLubyte*)"glVertexStream4dvATI")) == NULL) || r; - r = ((glVertexStream4fATI = (PFNGLVERTEXSTREAM4FATIPROC)glewGetProcAddress((const GLubyte*)"glVertexStream4fATI")) == NULL) || r; - r = ((glVertexStream4fvATI = (PFNGLVERTEXSTREAM4FVATIPROC)glewGetProcAddress((const GLubyte*)"glVertexStream4fvATI")) == NULL) || r; - r = ((glVertexStream4iATI = (PFNGLVERTEXSTREAM4IATIPROC)glewGetProcAddress((const GLubyte*)"glVertexStream4iATI")) == NULL) || r; - r = ((glVertexStream4ivATI = (PFNGLVERTEXSTREAM4IVATIPROC)glewGetProcAddress((const GLubyte*)"glVertexStream4ivATI")) == NULL) || r; - r = ((glVertexStream4sATI = (PFNGLVERTEXSTREAM4SATIPROC)glewGetProcAddress((const GLubyte*)"glVertexStream4sATI")) == NULL) || r; - r = ((glVertexStream4svATI = (PFNGLVERTEXSTREAM4SVATIPROC)glewGetProcAddress((const GLubyte*)"glVertexStream4svATI")) == NULL) || r; - - return r; -} - -#endif /* GL_ATI_vertex_streams */ - -#ifdef GL_EXT_422_pixels - -#endif /* GL_EXT_422_pixels */ - -#ifdef GL_EXT_Cg_shader - -#endif /* GL_EXT_Cg_shader */ - -#ifdef GL_EXT_abgr - -#endif /* GL_EXT_abgr */ - -#ifdef GL_EXT_bgra - -#endif /* GL_EXT_bgra */ - -#ifdef GL_EXT_bindable_uniform - -static GLboolean _glewInit_GL_EXT_bindable_uniform (GLEW_CONTEXT_ARG_DEF_INIT) -{ - GLboolean r = GL_FALSE; - - r = ((glGetUniformBufferSizeEXT = (PFNGLGETUNIFORMBUFFERSIZEEXTPROC)glewGetProcAddress((const GLubyte*)"glGetUniformBufferSizeEXT")) == NULL) || r; - r = ((glGetUniformOffsetEXT = (PFNGLGETUNIFORMOFFSETEXTPROC)glewGetProcAddress((const GLubyte*)"glGetUniformOffsetEXT")) == NULL) || r; - r = ((glUniformBufferEXT = (PFNGLUNIFORMBUFFEREXTPROC)glewGetProcAddress((const GLubyte*)"glUniformBufferEXT")) == NULL) || r; - - return r; -} - -#endif /* GL_EXT_bindable_uniform */ - -#ifdef GL_EXT_blend_color - -static GLboolean _glewInit_GL_EXT_blend_color (GLEW_CONTEXT_ARG_DEF_INIT) -{ - GLboolean r = GL_FALSE; - - r = ((glBlendColorEXT = (PFNGLBLENDCOLOREXTPROC)glewGetProcAddress((const GLubyte*)"glBlendColorEXT")) == NULL) || r; - - return r; -} - -#endif /* GL_EXT_blend_color */ - -#ifdef GL_EXT_blend_equation_separate - -static GLboolean _glewInit_GL_EXT_blend_equation_separate (GLEW_CONTEXT_ARG_DEF_INIT) -{ - GLboolean r = GL_FALSE; - - r = ((glBlendEquationSeparateEXT = (PFNGLBLENDEQUATIONSEPARATEEXTPROC)glewGetProcAddress((const GLubyte*)"glBlendEquationSeparateEXT")) == NULL) || r; - - return r; -} - -#endif /* GL_EXT_blend_equation_separate */ - -#ifdef GL_EXT_blend_func_separate - -static GLboolean _glewInit_GL_EXT_blend_func_separate (GLEW_CONTEXT_ARG_DEF_INIT) -{ - GLboolean r = GL_FALSE; - - r = ((glBlendFuncSeparateEXT = (PFNGLBLENDFUNCSEPARATEEXTPROC)glewGetProcAddress((const GLubyte*)"glBlendFuncSeparateEXT")) == NULL) || r; - - return r; -} - -#endif /* GL_EXT_blend_func_separate */ - -#ifdef GL_EXT_blend_logic_op - -#endif /* GL_EXT_blend_logic_op */ - -#ifdef GL_EXT_blend_minmax - -static GLboolean _glewInit_GL_EXT_blend_minmax (GLEW_CONTEXT_ARG_DEF_INIT) -{ - GLboolean r = GL_FALSE; - - r = ((glBlendEquationEXT = (PFNGLBLENDEQUATIONEXTPROC)glewGetProcAddress((const GLubyte*)"glBlendEquationEXT")) == NULL) || r; - - return r; -} - -#endif /* GL_EXT_blend_minmax */ - -#ifdef GL_EXT_blend_subtract - -#endif /* GL_EXT_blend_subtract */ - -#ifdef GL_EXT_clip_volume_hint - -#endif /* GL_EXT_clip_volume_hint */ - -#ifdef GL_EXT_cmyka - -#endif /* GL_EXT_cmyka */ - -#ifdef GL_EXT_color_subtable - -static GLboolean _glewInit_GL_EXT_color_subtable (GLEW_CONTEXT_ARG_DEF_INIT) -{ - GLboolean r = GL_FALSE; - - r = ((glColorSubTableEXT = (PFNGLCOLORSUBTABLEEXTPROC)glewGetProcAddress((const GLubyte*)"glColorSubTableEXT")) == NULL) || r; - r = ((glCopyColorSubTableEXT = (PFNGLCOPYCOLORSUBTABLEEXTPROC)glewGetProcAddress((const GLubyte*)"glCopyColorSubTableEXT")) == NULL) || r; - - return r; -} - -#endif /* GL_EXT_color_subtable */ - -#ifdef GL_EXT_compiled_vertex_array - -static GLboolean _glewInit_GL_EXT_compiled_vertex_array (GLEW_CONTEXT_ARG_DEF_INIT) -{ - GLboolean r = GL_FALSE; - - r = ((glLockArraysEXT = (PFNGLLOCKARRAYSEXTPROC)glewGetProcAddress((const GLubyte*)"glLockArraysEXT")) == NULL) || r; - r = ((glUnlockArraysEXT = (PFNGLUNLOCKARRAYSEXTPROC)glewGetProcAddress((const GLubyte*)"glUnlockArraysEXT")) == NULL) || r; - - return r; -} - -#endif /* GL_EXT_compiled_vertex_array */ - -#ifdef GL_EXT_convolution - -static GLboolean _glewInit_GL_EXT_convolution (GLEW_CONTEXT_ARG_DEF_INIT) -{ - GLboolean r = GL_FALSE; - - r = ((glConvolutionFilter1DEXT = (PFNGLCONVOLUTIONFILTER1DEXTPROC)glewGetProcAddress((const GLubyte*)"glConvolutionFilter1DEXT")) == NULL) || r; - r = ((glConvolutionFilter2DEXT = (PFNGLCONVOLUTIONFILTER2DEXTPROC)glewGetProcAddress((const GLubyte*)"glConvolutionFilter2DEXT")) == NULL) || r; - r = ((glConvolutionParameterfEXT = (PFNGLCONVOLUTIONPARAMETERFEXTPROC)glewGetProcAddress((const GLubyte*)"glConvolutionParameterfEXT")) == NULL) || r; - r = ((glConvolutionParameterfvEXT = (PFNGLCONVOLUTIONPARAMETERFVEXTPROC)glewGetProcAddress((const GLubyte*)"glConvolutionParameterfvEXT")) == NULL) || r; - r = ((glConvolutionParameteriEXT = (PFNGLCONVOLUTIONPARAMETERIEXTPROC)glewGetProcAddress((const GLubyte*)"glConvolutionParameteriEXT")) == NULL) || r; - r = ((glConvolutionParameterivEXT = (PFNGLCONVOLUTIONPARAMETERIVEXTPROC)glewGetProcAddress((const GLubyte*)"glConvolutionParameterivEXT")) == NULL) || r; - r = ((glCopyConvolutionFilter1DEXT = (PFNGLCOPYCONVOLUTIONFILTER1DEXTPROC)glewGetProcAddress((const GLubyte*)"glCopyConvolutionFilter1DEXT")) == NULL) || r; - r = ((glCopyConvolutionFilter2DEXT = (PFNGLCOPYCONVOLUTIONFILTER2DEXTPROC)glewGetProcAddress((const GLubyte*)"glCopyConvolutionFilter2DEXT")) == NULL) || r; - r = ((glGetConvolutionFilterEXT = (PFNGLGETCONVOLUTIONFILTEREXTPROC)glewGetProcAddress((const GLubyte*)"glGetConvolutionFilterEXT")) == NULL) || r; - r = ((glGetConvolutionParameterfvEXT = (PFNGLGETCONVOLUTIONPARAMETERFVEXTPROC)glewGetProcAddress((const GLubyte*)"glGetConvolutionParameterfvEXT")) == NULL) || r; - r = ((glGetConvolutionParameterivEXT = (PFNGLGETCONVOLUTIONPARAMETERIVEXTPROC)glewGetProcAddress((const GLubyte*)"glGetConvolutionParameterivEXT")) == NULL) || r; - r = ((glGetSeparableFilterEXT = (PFNGLGETSEPARABLEFILTEREXTPROC)glewGetProcAddress((const GLubyte*)"glGetSeparableFilterEXT")) == NULL) || r; - r = ((glSeparableFilter2DEXT = (PFNGLSEPARABLEFILTER2DEXTPROC)glewGetProcAddress((const GLubyte*)"glSeparableFilter2DEXT")) == NULL) || r; - - return r; -} - -#endif /* GL_EXT_convolution */ - -#ifdef GL_EXT_coordinate_frame - -static GLboolean _glewInit_GL_EXT_coordinate_frame (GLEW_CONTEXT_ARG_DEF_INIT) -{ - GLboolean r = GL_FALSE; - - r = ((glBinormalPointerEXT = (PFNGLBINORMALPOINTEREXTPROC)glewGetProcAddress((const GLubyte*)"glBinormalPointerEXT")) == NULL) || r; - r = ((glTangentPointerEXT = (PFNGLTANGENTPOINTEREXTPROC)glewGetProcAddress((const GLubyte*)"glTangentPointerEXT")) == NULL) || r; - - return r; -} - -#endif /* GL_EXT_coordinate_frame */ - -#ifdef GL_EXT_copy_texture - -static GLboolean _glewInit_GL_EXT_copy_texture (GLEW_CONTEXT_ARG_DEF_INIT) -{ - GLboolean r = GL_FALSE; - - r = ((glCopyTexImage1DEXT = (PFNGLCOPYTEXIMAGE1DEXTPROC)glewGetProcAddress((const GLubyte*)"glCopyTexImage1DEXT")) == NULL) || r; - r = ((glCopyTexImage2DEXT = (PFNGLCOPYTEXIMAGE2DEXTPROC)glewGetProcAddress((const GLubyte*)"glCopyTexImage2DEXT")) == NULL) || r; - r = ((glCopyTexSubImage1DEXT = (PFNGLCOPYTEXSUBIMAGE1DEXTPROC)glewGetProcAddress((const GLubyte*)"glCopyTexSubImage1DEXT")) == NULL) || r; - r = ((glCopyTexSubImage2DEXT = (PFNGLCOPYTEXSUBIMAGE2DEXTPROC)glewGetProcAddress((const GLubyte*)"glCopyTexSubImage2DEXT")) == NULL) || r; - r = ((glCopyTexSubImage3DEXT = (PFNGLCOPYTEXSUBIMAGE3DEXTPROC)glewGetProcAddress((const GLubyte*)"glCopyTexSubImage3DEXT")) == NULL) || r; - - return r; -} - -#endif /* GL_EXT_copy_texture */ - -#ifdef GL_EXT_cull_vertex - -static GLboolean _glewInit_GL_EXT_cull_vertex (GLEW_CONTEXT_ARG_DEF_INIT) -{ - GLboolean r = GL_FALSE; - - r = ((glCullParameterdvEXT = (PFNGLCULLPARAMETERDVEXTPROC)glewGetProcAddress((const GLubyte*)"glCullParameterdvEXT")) == NULL) || r; - r = ((glCullParameterfvEXT = (PFNGLCULLPARAMETERFVEXTPROC)glewGetProcAddress((const GLubyte*)"glCullParameterfvEXT")) == NULL) || r; - - return r; -} - -#endif /* GL_EXT_cull_vertex */ - -#ifdef GL_EXT_depth_bounds_test - -static GLboolean _glewInit_GL_EXT_depth_bounds_test (GLEW_CONTEXT_ARG_DEF_INIT) -{ - GLboolean r = GL_FALSE; - - r = ((glDepthBoundsEXT = (PFNGLDEPTHBOUNDSEXTPROC)glewGetProcAddress((const GLubyte*)"glDepthBoundsEXT")) == NULL) || r; - - return r; -} - -#endif /* GL_EXT_depth_bounds_test */ - -#ifdef GL_EXT_direct_state_access - -static GLboolean _glewInit_GL_EXT_direct_state_access (GLEW_CONTEXT_ARG_DEF_INIT) -{ - GLboolean r = GL_FALSE; - - r = ((glBindMultiTextureEXT = (PFNGLBINDMULTITEXTUREEXTPROC)glewGetProcAddress((const GLubyte*)"glBindMultiTextureEXT")) == NULL) || r; - r = ((glCheckNamedFramebufferStatusEXT = (PFNGLCHECKNAMEDFRAMEBUFFERSTATUSEXTPROC)glewGetProcAddress((const GLubyte*)"glCheckNamedFramebufferStatusEXT")) == NULL) || r; - r = ((glClientAttribDefaultEXT = (PFNGLCLIENTATTRIBDEFAULTEXTPROC)glewGetProcAddress((const GLubyte*)"glClientAttribDefaultEXT")) == NULL) || r; - r = ((glCompressedMultiTexImage1DEXT = (PFNGLCOMPRESSEDMULTITEXIMAGE1DEXTPROC)glewGetProcAddress((const GLubyte*)"glCompressedMultiTexImage1DEXT")) == NULL) || r; - r = ((glCompressedMultiTexImage2DEXT = (PFNGLCOMPRESSEDMULTITEXIMAGE2DEXTPROC)glewGetProcAddress((const GLubyte*)"glCompressedMultiTexImage2DEXT")) == NULL) || r; - r = ((glCompressedMultiTexImage3DEXT = (PFNGLCOMPRESSEDMULTITEXIMAGE3DEXTPROC)glewGetProcAddress((const GLubyte*)"glCompressedMultiTexImage3DEXT")) == NULL) || r; - r = ((glCompressedMultiTexSubImage1DEXT = (PFNGLCOMPRESSEDMULTITEXSUBIMAGE1DEXTPROC)glewGetProcAddress((const GLubyte*)"glCompressedMultiTexSubImage1DEXT")) == NULL) || r; - r = ((glCompressedMultiTexSubImage2DEXT = (PFNGLCOMPRESSEDMULTITEXSUBIMAGE2DEXTPROC)glewGetProcAddress((const GLubyte*)"glCompressedMultiTexSubImage2DEXT")) == NULL) || r; - r = ((glCompressedMultiTexSubImage3DEXT = (PFNGLCOMPRESSEDMULTITEXSUBIMAGE3DEXTPROC)glewGetProcAddress((const GLubyte*)"glCompressedMultiTexSubImage3DEXT")) == NULL) || r; - r = ((glCompressedTextureImage1DEXT = (PFNGLCOMPRESSEDTEXTUREIMAGE1DEXTPROC)glewGetProcAddress((const GLubyte*)"glCompressedTextureImage1DEXT")) == NULL) || r; - r = ((glCompressedTextureImage2DEXT = (PFNGLCOMPRESSEDTEXTUREIMAGE2DEXTPROC)glewGetProcAddress((const GLubyte*)"glCompressedTextureImage2DEXT")) == NULL) || r; - r = ((glCompressedTextureImage3DEXT = (PFNGLCOMPRESSEDTEXTUREIMAGE3DEXTPROC)glewGetProcAddress((const GLubyte*)"glCompressedTextureImage3DEXT")) == NULL) || r; - r = ((glCompressedTextureSubImage1DEXT = (PFNGLCOMPRESSEDTEXTURESUBIMAGE1DEXTPROC)glewGetProcAddress((const GLubyte*)"glCompressedTextureSubImage1DEXT")) == NULL) || r; - r = ((glCompressedTextureSubImage2DEXT = (PFNGLCOMPRESSEDTEXTURESUBIMAGE2DEXTPROC)glewGetProcAddress((const GLubyte*)"glCompressedTextureSubImage2DEXT")) == NULL) || r; - r = ((glCompressedTextureSubImage3DEXT = (PFNGLCOMPRESSEDTEXTURESUBIMAGE3DEXTPROC)glewGetProcAddress((const GLubyte*)"glCompressedTextureSubImage3DEXT")) == NULL) || r; - r = ((glCopyMultiTexImage1DEXT = (PFNGLCOPYMULTITEXIMAGE1DEXTPROC)glewGetProcAddress((const GLubyte*)"glCopyMultiTexImage1DEXT")) == NULL) || r; - r = ((glCopyMultiTexImage2DEXT = (PFNGLCOPYMULTITEXIMAGE2DEXTPROC)glewGetProcAddress((const GLubyte*)"glCopyMultiTexImage2DEXT")) == NULL) || r; - r = ((glCopyMultiTexSubImage1DEXT = (PFNGLCOPYMULTITEXSUBIMAGE1DEXTPROC)glewGetProcAddress((const GLubyte*)"glCopyMultiTexSubImage1DEXT")) == NULL) || r; - r = ((glCopyMultiTexSubImage2DEXT = (PFNGLCOPYMULTITEXSUBIMAGE2DEXTPROC)glewGetProcAddress((const GLubyte*)"glCopyMultiTexSubImage2DEXT")) == NULL) || r; - r = ((glCopyMultiTexSubImage3DEXT = (PFNGLCOPYMULTITEXSUBIMAGE3DEXTPROC)glewGetProcAddress((const GLubyte*)"glCopyMultiTexSubImage3DEXT")) == NULL) || r; - r = ((glCopyTextureImage1DEXT = (PFNGLCOPYTEXTUREIMAGE1DEXTPROC)glewGetProcAddress((const GLubyte*)"glCopyTextureImage1DEXT")) == NULL) || r; - r = ((glCopyTextureImage2DEXT = (PFNGLCOPYTEXTUREIMAGE2DEXTPROC)glewGetProcAddress((const GLubyte*)"glCopyTextureImage2DEXT")) == NULL) || r; - r = ((glCopyTextureSubImage1DEXT = (PFNGLCOPYTEXTURESUBIMAGE1DEXTPROC)glewGetProcAddress((const GLubyte*)"glCopyTextureSubImage1DEXT")) == NULL) || r; - r = ((glCopyTextureSubImage2DEXT = (PFNGLCOPYTEXTURESUBIMAGE2DEXTPROC)glewGetProcAddress((const GLubyte*)"glCopyTextureSubImage2DEXT")) == NULL) || r; - r = ((glCopyTextureSubImage3DEXT = (PFNGLCOPYTEXTURESUBIMAGE3DEXTPROC)glewGetProcAddress((const GLubyte*)"glCopyTextureSubImage3DEXT")) == NULL) || r; - r = ((glDisableClientStateIndexedEXT = (PFNGLDISABLECLIENTSTATEINDEXEDEXTPROC)glewGetProcAddress((const GLubyte*)"glDisableClientStateIndexedEXT")) == NULL) || r; - r = ((glEnableClientStateIndexedEXT = (PFNGLENABLECLIENTSTATEINDEXEDEXTPROC)glewGetProcAddress((const GLubyte*)"glEnableClientStateIndexedEXT")) == NULL) || r; - r = ((glFramebufferDrawBufferEXT = (PFNGLFRAMEBUFFERDRAWBUFFEREXTPROC)glewGetProcAddress((const GLubyte*)"glFramebufferDrawBufferEXT")) == NULL) || r; - r = ((glFramebufferDrawBuffersEXT = (PFNGLFRAMEBUFFERDRAWBUFFERSEXTPROC)glewGetProcAddress((const GLubyte*)"glFramebufferDrawBuffersEXT")) == NULL) || r; - r = ((glFramebufferReadBufferEXT = (PFNGLFRAMEBUFFERREADBUFFEREXTPROC)glewGetProcAddress((const GLubyte*)"glFramebufferReadBufferEXT")) == NULL) || r; - r = ((glGenerateMultiTexMipmapEXT = (PFNGLGENERATEMULTITEXMIPMAPEXTPROC)glewGetProcAddress((const GLubyte*)"glGenerateMultiTexMipmapEXT")) == NULL) || r; - r = ((glGenerateTextureMipmapEXT = (PFNGLGENERATETEXTUREMIPMAPEXTPROC)glewGetProcAddress((const GLubyte*)"glGenerateTextureMipmapEXT")) == NULL) || r; - r = ((glGetCompressedMultiTexImageEXT = (PFNGLGETCOMPRESSEDMULTITEXIMAGEEXTPROC)glewGetProcAddress((const GLubyte*)"glGetCompressedMultiTexImageEXT")) == NULL) || r; - r = ((glGetCompressedTextureImageEXT = (PFNGLGETCOMPRESSEDTEXTUREIMAGEEXTPROC)glewGetProcAddress((const GLubyte*)"glGetCompressedTextureImageEXT")) == NULL) || r; - r = ((glGetDoubleIndexedvEXT = (PFNGLGETDOUBLEINDEXEDVEXTPROC)glewGetProcAddress((const GLubyte*)"glGetDoubleIndexedvEXT")) == NULL) || r; - r = ((glGetFloatIndexedvEXT = (PFNGLGETFLOATINDEXEDVEXTPROC)glewGetProcAddress((const GLubyte*)"glGetFloatIndexedvEXT")) == NULL) || r; - r = ((glGetFramebufferParameterivEXT = (PFNGLGETFRAMEBUFFERPARAMETERIVEXTPROC)glewGetProcAddress((const GLubyte*)"glGetFramebufferParameterivEXT")) == NULL) || r; - r = ((glGetMultiTexEnvfvEXT = (PFNGLGETMULTITEXENVFVEXTPROC)glewGetProcAddress((const GLubyte*)"glGetMultiTexEnvfvEXT")) == NULL) || r; - r = ((glGetMultiTexEnvivEXT = (PFNGLGETMULTITEXENVIVEXTPROC)glewGetProcAddress((const GLubyte*)"glGetMultiTexEnvivEXT")) == NULL) || r; - r = ((glGetMultiTexGendvEXT = (PFNGLGETMULTITEXGENDVEXTPROC)glewGetProcAddress((const GLubyte*)"glGetMultiTexGendvEXT")) == NULL) || r; - r = ((glGetMultiTexGenfvEXT = (PFNGLGETMULTITEXGENFVEXTPROC)glewGetProcAddress((const GLubyte*)"glGetMultiTexGenfvEXT")) == NULL) || r; - r = ((glGetMultiTexGenivEXT = (PFNGLGETMULTITEXGENIVEXTPROC)glewGetProcAddress((const GLubyte*)"glGetMultiTexGenivEXT")) == NULL) || r; - r = ((glGetMultiTexImageEXT = (PFNGLGETMULTITEXIMAGEEXTPROC)glewGetProcAddress((const GLubyte*)"glGetMultiTexImageEXT")) == NULL) || r; - r = ((glGetMultiTexLevelParameterfvEXT = (PFNGLGETMULTITEXLEVELPARAMETERFVEXTPROC)glewGetProcAddress((const GLubyte*)"glGetMultiTexLevelParameterfvEXT")) == NULL) || r; - r = ((glGetMultiTexLevelParameterivEXT = (PFNGLGETMULTITEXLEVELPARAMETERIVEXTPROC)glewGetProcAddress((const GLubyte*)"glGetMultiTexLevelParameterivEXT")) == NULL) || r; - r = ((glGetMultiTexParameterIivEXT = (PFNGLGETMULTITEXPARAMETERIIVEXTPROC)glewGetProcAddress((const GLubyte*)"glGetMultiTexParameterIivEXT")) == NULL) || r; - r = ((glGetMultiTexParameterIuivEXT = (PFNGLGETMULTITEXPARAMETERIUIVEXTPROC)glewGetProcAddress((const GLubyte*)"glGetMultiTexParameterIuivEXT")) == NULL) || r; - r = ((glGetMultiTexParameterfvEXT = (PFNGLGETMULTITEXPARAMETERFVEXTPROC)glewGetProcAddress((const GLubyte*)"glGetMultiTexParameterfvEXT")) == NULL) || r; - r = ((glGetMultiTexParameterivEXT = (PFNGLGETMULTITEXPARAMETERIVEXTPROC)glewGetProcAddress((const GLubyte*)"glGetMultiTexParameterivEXT")) == NULL) || r; - r = ((glGetNamedBufferParameterivEXT = (PFNGLGETNAMEDBUFFERPARAMETERIVEXTPROC)glewGetProcAddress((const GLubyte*)"glGetNamedBufferParameterivEXT")) == NULL) || r; - r = ((glGetNamedBufferPointervEXT = (PFNGLGETNAMEDBUFFERPOINTERVEXTPROC)glewGetProcAddress((const GLubyte*)"glGetNamedBufferPointervEXT")) == NULL) || r; - r = ((glGetNamedBufferSubDataEXT = (PFNGLGETNAMEDBUFFERSUBDATAEXTPROC)glewGetProcAddress((const GLubyte*)"glGetNamedBufferSubDataEXT")) == NULL) || r; - r = ((glGetNamedFramebufferAttachmentParameterivEXT = (PFNGLGETNAMEDFRAMEBUFFERATTACHMENTPARAMETERIVEXTPROC)glewGetProcAddress((const GLubyte*)"glGetNamedFramebufferAttachmentParameterivEXT")) == NULL) || r; - r = ((glGetNamedProgramLocalParameterIivEXT = (PFNGLGETNAMEDPROGRAMLOCALPARAMETERIIVEXTPROC)glewGetProcAddress((const GLubyte*)"glGetNamedProgramLocalParameterIivEXT")) == NULL) || r; - r = ((glGetNamedProgramLocalParameterIuivEXT = (PFNGLGETNAMEDPROGRAMLOCALPARAMETERIUIVEXTPROC)glewGetProcAddress((const GLubyte*)"glGetNamedProgramLocalParameterIuivEXT")) == NULL) || r; - r = ((glGetNamedProgramLocalParameterdvEXT = (PFNGLGETNAMEDPROGRAMLOCALPARAMETERDVEXTPROC)glewGetProcAddress((const GLubyte*)"glGetNamedProgramLocalParameterdvEXT")) == NULL) || r; - r = ((glGetNamedProgramLocalParameterfvEXT = (PFNGLGETNAMEDPROGRAMLOCALPARAMETERFVEXTPROC)glewGetProcAddress((const GLubyte*)"glGetNamedProgramLocalParameterfvEXT")) == NULL) || r; - r = ((glGetNamedProgramStringEXT = (PFNGLGETNAMEDPROGRAMSTRINGEXTPROC)glewGetProcAddress((const GLubyte*)"glGetNamedProgramStringEXT")) == NULL) || r; - r = ((glGetNamedProgramivEXT = (PFNGLGETNAMEDPROGRAMIVEXTPROC)glewGetProcAddress((const GLubyte*)"glGetNamedProgramivEXT")) == NULL) || r; - r = ((glGetNamedRenderbufferParameterivEXT = (PFNGLGETNAMEDRENDERBUFFERPARAMETERIVEXTPROC)glewGetProcAddress((const GLubyte*)"glGetNamedRenderbufferParameterivEXT")) == NULL) || r; - r = ((glGetPointerIndexedvEXT = (PFNGLGETPOINTERINDEXEDVEXTPROC)glewGetProcAddress((const GLubyte*)"glGetPointerIndexedvEXT")) == NULL) || r; - r = ((glGetTextureImageEXT = (PFNGLGETTEXTUREIMAGEEXTPROC)glewGetProcAddress((const GLubyte*)"glGetTextureImageEXT")) == NULL) || r; - r = ((glGetTextureLevelParameterfvEXT = (PFNGLGETTEXTURELEVELPARAMETERFVEXTPROC)glewGetProcAddress((const GLubyte*)"glGetTextureLevelParameterfvEXT")) == NULL) || r; - r = ((glGetTextureLevelParameterivEXT = (PFNGLGETTEXTURELEVELPARAMETERIVEXTPROC)glewGetProcAddress((const GLubyte*)"glGetTextureLevelParameterivEXT")) == NULL) || r; - r = ((glGetTextureParameterIivEXT = (PFNGLGETTEXTUREPARAMETERIIVEXTPROC)glewGetProcAddress((const GLubyte*)"glGetTextureParameterIivEXT")) == NULL) || r; - r = ((glGetTextureParameterIuivEXT = (PFNGLGETTEXTUREPARAMETERIUIVEXTPROC)glewGetProcAddress((const GLubyte*)"glGetTextureParameterIuivEXT")) == NULL) || r; - r = ((glGetTextureParameterfvEXT = (PFNGLGETTEXTUREPARAMETERFVEXTPROC)glewGetProcAddress((const GLubyte*)"glGetTextureParameterfvEXT")) == NULL) || r; - r = ((glGetTextureParameterivEXT = (PFNGLGETTEXTUREPARAMETERIVEXTPROC)glewGetProcAddress((const GLubyte*)"glGetTextureParameterivEXT")) == NULL) || r; - r = ((glMapNamedBufferEXT = (PFNGLMAPNAMEDBUFFEREXTPROC)glewGetProcAddress((const GLubyte*)"glMapNamedBufferEXT")) == NULL) || r; - r = ((glMatrixFrustumEXT = (PFNGLMATRIXFRUSTUMEXTPROC)glewGetProcAddress((const GLubyte*)"glMatrixFrustumEXT")) == NULL) || r; - r = ((glMatrixLoadIdentityEXT = (PFNGLMATRIXLOADIDENTITYEXTPROC)glewGetProcAddress((const GLubyte*)"glMatrixLoadIdentityEXT")) == NULL) || r; - r = ((glMatrixLoadTransposedEXT = (PFNGLMATRIXLOADTRANSPOSEDEXTPROC)glewGetProcAddress((const GLubyte*)"glMatrixLoadTransposedEXT")) == NULL) || r; - r = ((glMatrixLoadTransposefEXT = (PFNGLMATRIXLOADTRANSPOSEFEXTPROC)glewGetProcAddress((const GLubyte*)"glMatrixLoadTransposefEXT")) == NULL) || r; - r = ((glMatrixLoaddEXT = (PFNGLMATRIXLOADDEXTPROC)glewGetProcAddress((const GLubyte*)"glMatrixLoaddEXT")) == NULL) || r; - r = ((glMatrixLoadfEXT = (PFNGLMATRIXLOADFEXTPROC)glewGetProcAddress((const GLubyte*)"glMatrixLoadfEXT")) == NULL) || r; - r = ((glMatrixMultTransposedEXT = (PFNGLMATRIXMULTTRANSPOSEDEXTPROC)glewGetProcAddress((const GLubyte*)"glMatrixMultTransposedEXT")) == NULL) || r; - r = ((glMatrixMultTransposefEXT = (PFNGLMATRIXMULTTRANSPOSEFEXTPROC)glewGetProcAddress((const GLubyte*)"glMatrixMultTransposefEXT")) == NULL) || r; - r = ((glMatrixMultdEXT = (PFNGLMATRIXMULTDEXTPROC)glewGetProcAddress((const GLubyte*)"glMatrixMultdEXT")) == NULL) || r; - r = ((glMatrixMultfEXT = (PFNGLMATRIXMULTFEXTPROC)glewGetProcAddress((const GLubyte*)"glMatrixMultfEXT")) == NULL) || r; - r = ((glMatrixOrthoEXT = (PFNGLMATRIXORTHOEXTPROC)glewGetProcAddress((const GLubyte*)"glMatrixOrthoEXT")) == NULL) || r; - r = ((glMatrixPopEXT = (PFNGLMATRIXPOPEXTPROC)glewGetProcAddress((const GLubyte*)"glMatrixPopEXT")) == NULL) || r; - r = ((glMatrixPushEXT = (PFNGLMATRIXPUSHEXTPROC)glewGetProcAddress((const GLubyte*)"glMatrixPushEXT")) == NULL) || r; - r = ((glMatrixRotatedEXT = (PFNGLMATRIXROTATEDEXTPROC)glewGetProcAddress((const GLubyte*)"glMatrixRotatedEXT")) == NULL) || r; - r = ((glMatrixRotatefEXT = (PFNGLMATRIXROTATEFEXTPROC)glewGetProcAddress((const GLubyte*)"glMatrixRotatefEXT")) == NULL) || r; - r = ((glMatrixScaledEXT = (PFNGLMATRIXSCALEDEXTPROC)glewGetProcAddress((const GLubyte*)"glMatrixScaledEXT")) == NULL) || r; - r = ((glMatrixScalefEXT = (PFNGLMATRIXSCALEFEXTPROC)glewGetProcAddress((const GLubyte*)"glMatrixScalefEXT")) == NULL) || r; - r = ((glMatrixTranslatedEXT = (PFNGLMATRIXTRANSLATEDEXTPROC)glewGetProcAddress((const GLubyte*)"glMatrixTranslatedEXT")) == NULL) || r; - r = ((glMatrixTranslatefEXT = (PFNGLMATRIXTRANSLATEFEXTPROC)glewGetProcAddress((const GLubyte*)"glMatrixTranslatefEXT")) == NULL) || r; - r = ((glMultiTexBufferEXT = (PFNGLMULTITEXBUFFEREXTPROC)glewGetProcAddress((const GLubyte*)"glMultiTexBufferEXT")) == NULL) || r; - r = ((glMultiTexCoordPointerEXT = (PFNGLMULTITEXCOORDPOINTEREXTPROC)glewGetProcAddress((const GLubyte*)"glMultiTexCoordPointerEXT")) == NULL) || r; - r = ((glMultiTexEnvfEXT = (PFNGLMULTITEXENVFEXTPROC)glewGetProcAddress((const GLubyte*)"glMultiTexEnvfEXT")) == NULL) || r; - r = ((glMultiTexEnvfvEXT = (PFNGLMULTITEXENVFVEXTPROC)glewGetProcAddress((const GLubyte*)"glMultiTexEnvfvEXT")) == NULL) || r; - r = ((glMultiTexEnviEXT = (PFNGLMULTITEXENVIEXTPROC)glewGetProcAddress((const GLubyte*)"glMultiTexEnviEXT")) == NULL) || r; - r = ((glMultiTexEnvivEXT = (PFNGLMULTITEXENVIVEXTPROC)glewGetProcAddress((const GLubyte*)"glMultiTexEnvivEXT")) == NULL) || r; - r = ((glMultiTexGendEXT = (PFNGLMULTITEXGENDEXTPROC)glewGetProcAddress((const GLubyte*)"glMultiTexGendEXT")) == NULL) || r; - r = ((glMultiTexGendvEXT = (PFNGLMULTITEXGENDVEXTPROC)glewGetProcAddress((const GLubyte*)"glMultiTexGendvEXT")) == NULL) || r; - r = ((glMultiTexGenfEXT = (PFNGLMULTITEXGENFEXTPROC)glewGetProcAddress((const GLubyte*)"glMultiTexGenfEXT")) == NULL) || r; - r = ((glMultiTexGenfvEXT = (PFNGLMULTITEXGENFVEXTPROC)glewGetProcAddress((const GLubyte*)"glMultiTexGenfvEXT")) == NULL) || r; - r = ((glMultiTexGeniEXT = (PFNGLMULTITEXGENIEXTPROC)glewGetProcAddress((const GLubyte*)"glMultiTexGeniEXT")) == NULL) || r; - r = ((glMultiTexGenivEXT = (PFNGLMULTITEXGENIVEXTPROC)glewGetProcAddress((const GLubyte*)"glMultiTexGenivEXT")) == NULL) || r; - r = ((glMultiTexImage1DEXT = (PFNGLMULTITEXIMAGE1DEXTPROC)glewGetProcAddress((const GLubyte*)"glMultiTexImage1DEXT")) == NULL) || r; - r = ((glMultiTexImage2DEXT = (PFNGLMULTITEXIMAGE2DEXTPROC)glewGetProcAddress((const GLubyte*)"glMultiTexImage2DEXT")) == NULL) || r; - r = ((glMultiTexImage3DEXT = (PFNGLMULTITEXIMAGE3DEXTPROC)glewGetProcAddress((const GLubyte*)"glMultiTexImage3DEXT")) == NULL) || r; - r = ((glMultiTexParameterIivEXT = (PFNGLMULTITEXPARAMETERIIVEXTPROC)glewGetProcAddress((const GLubyte*)"glMultiTexParameterIivEXT")) == NULL) || r; - r = ((glMultiTexParameterIuivEXT = (PFNGLMULTITEXPARAMETERIUIVEXTPROC)glewGetProcAddress((const GLubyte*)"glMultiTexParameterIuivEXT")) == NULL) || r; - r = ((glMultiTexParameterfEXT = (PFNGLMULTITEXPARAMETERFEXTPROC)glewGetProcAddress((const GLubyte*)"glMultiTexParameterfEXT")) == NULL) || r; - r = ((glMultiTexParameterfvEXT = (PFNGLMULTITEXPARAMETERFVEXTPROC)glewGetProcAddress((const GLubyte*)"glMultiTexParameterfvEXT")) == NULL) || r; - r = ((glMultiTexParameteriEXT = (PFNGLMULTITEXPARAMETERIEXTPROC)glewGetProcAddress((const GLubyte*)"glMultiTexParameteriEXT")) == NULL) || r; - r = ((glMultiTexParameterivEXT = (PFNGLMULTITEXPARAMETERIVEXTPROC)glewGetProcAddress((const GLubyte*)"glMultiTexParameterivEXT")) == NULL) || r; - r = ((glMultiTexRenderbufferEXT = (PFNGLMULTITEXRENDERBUFFEREXTPROC)glewGetProcAddress((const GLubyte*)"glMultiTexRenderbufferEXT")) == NULL) || r; - r = ((glMultiTexSubImage1DEXT = (PFNGLMULTITEXSUBIMAGE1DEXTPROC)glewGetProcAddress((const GLubyte*)"glMultiTexSubImage1DEXT")) == NULL) || r; - r = ((glMultiTexSubImage2DEXT = (PFNGLMULTITEXSUBIMAGE2DEXTPROC)glewGetProcAddress((const GLubyte*)"glMultiTexSubImage2DEXT")) == NULL) || r; - r = ((glMultiTexSubImage3DEXT = (PFNGLMULTITEXSUBIMAGE3DEXTPROC)glewGetProcAddress((const GLubyte*)"glMultiTexSubImage3DEXT")) == NULL) || r; - r = ((glNamedBufferDataEXT = (PFNGLNAMEDBUFFERDATAEXTPROC)glewGetProcAddress((const GLubyte*)"glNamedBufferDataEXT")) == NULL) || r; - r = ((glNamedBufferSubDataEXT = (PFNGLNAMEDBUFFERSUBDATAEXTPROC)glewGetProcAddress((const GLubyte*)"glNamedBufferSubDataEXT")) == NULL) || r; - r = ((glNamedFramebufferRenderbufferEXT = (PFNGLNAMEDFRAMEBUFFERRENDERBUFFEREXTPROC)glewGetProcAddress((const GLubyte*)"glNamedFramebufferRenderbufferEXT")) == NULL) || r; - r = ((glNamedFramebufferTexture1DEXT = (PFNGLNAMEDFRAMEBUFFERTEXTURE1DEXTPROC)glewGetProcAddress((const GLubyte*)"glNamedFramebufferTexture1DEXT")) == NULL) || r; - r = ((glNamedFramebufferTexture2DEXT = (PFNGLNAMEDFRAMEBUFFERTEXTURE2DEXTPROC)glewGetProcAddress((const GLubyte*)"glNamedFramebufferTexture2DEXT")) == NULL) || r; - r = ((glNamedFramebufferTexture3DEXT = (PFNGLNAMEDFRAMEBUFFERTEXTURE3DEXTPROC)glewGetProcAddress((const GLubyte*)"glNamedFramebufferTexture3DEXT")) == NULL) || r; - r = ((glNamedFramebufferTextureEXT = (PFNGLNAMEDFRAMEBUFFERTEXTUREEXTPROC)glewGetProcAddress((const GLubyte*)"glNamedFramebufferTextureEXT")) == NULL) || r; - r = ((glNamedFramebufferTextureFaceEXT = (PFNGLNAMEDFRAMEBUFFERTEXTUREFACEEXTPROC)glewGetProcAddress((const GLubyte*)"glNamedFramebufferTextureFaceEXT")) == NULL) || r; - r = ((glNamedFramebufferTextureLayerEXT = (PFNGLNAMEDFRAMEBUFFERTEXTURELAYEREXTPROC)glewGetProcAddress((const GLubyte*)"glNamedFramebufferTextureLayerEXT")) == NULL) || r; - r = ((glNamedProgramLocalParameter4dEXT = (PFNGLNAMEDPROGRAMLOCALPARAMETER4DEXTPROC)glewGetProcAddress((const GLubyte*)"glNamedProgramLocalParameter4dEXT")) == NULL) || r; - r = ((glNamedProgramLocalParameter4dvEXT = (PFNGLNAMEDPROGRAMLOCALPARAMETER4DVEXTPROC)glewGetProcAddress((const GLubyte*)"glNamedProgramLocalParameter4dvEXT")) == NULL) || r; - r = ((glNamedProgramLocalParameter4fEXT = (PFNGLNAMEDPROGRAMLOCALPARAMETER4FEXTPROC)glewGetProcAddress((const GLubyte*)"glNamedProgramLocalParameter4fEXT")) == NULL) || r; - r = ((glNamedProgramLocalParameter4fvEXT = (PFNGLNAMEDPROGRAMLOCALPARAMETER4FVEXTPROC)glewGetProcAddress((const GLubyte*)"glNamedProgramLocalParameter4fvEXT")) == NULL) || r; - r = ((glNamedProgramLocalParameterI4iEXT = (PFNGLNAMEDPROGRAMLOCALPARAMETERI4IEXTPROC)glewGetProcAddress((const GLubyte*)"glNamedProgramLocalParameterI4iEXT")) == NULL) || r; - r = ((glNamedProgramLocalParameterI4ivEXT = (PFNGLNAMEDPROGRAMLOCALPARAMETERI4IVEXTPROC)glewGetProcAddress((const GLubyte*)"glNamedProgramLocalParameterI4ivEXT")) == NULL) || r; - r = ((glNamedProgramLocalParameterI4uiEXT = (PFNGLNAMEDPROGRAMLOCALPARAMETERI4UIEXTPROC)glewGetProcAddress((const GLubyte*)"glNamedProgramLocalParameterI4uiEXT")) == NULL) || r; - r = ((glNamedProgramLocalParameterI4uivEXT = (PFNGLNAMEDPROGRAMLOCALPARAMETERI4UIVEXTPROC)glewGetProcAddress((const GLubyte*)"glNamedProgramLocalParameterI4uivEXT")) == NULL) || r; - r = ((glNamedProgramLocalParameters4fvEXT = (PFNGLNAMEDPROGRAMLOCALPARAMETERS4FVEXTPROC)glewGetProcAddress((const GLubyte*)"glNamedProgramLocalParameters4fvEXT")) == NULL) || r; - r = ((glNamedProgramLocalParametersI4ivEXT = (PFNGLNAMEDPROGRAMLOCALPARAMETERSI4IVEXTPROC)glewGetProcAddress((const GLubyte*)"glNamedProgramLocalParametersI4ivEXT")) == NULL) || r; - r = ((glNamedProgramLocalParametersI4uivEXT = (PFNGLNAMEDPROGRAMLOCALPARAMETERSI4UIVEXTPROC)glewGetProcAddress((const GLubyte*)"glNamedProgramLocalParametersI4uivEXT")) == NULL) || r; - r = ((glNamedProgramStringEXT = (PFNGLNAMEDPROGRAMSTRINGEXTPROC)glewGetProcAddress((const GLubyte*)"glNamedProgramStringEXT")) == NULL) || r; - r = ((glNamedRenderbufferStorageEXT = (PFNGLNAMEDRENDERBUFFERSTORAGEEXTPROC)glewGetProcAddress((const GLubyte*)"glNamedRenderbufferStorageEXT")) == NULL) || r; - r = ((glNamedRenderbufferStorageMultisampleCoverageEXT = (PFNGLNAMEDRENDERBUFFERSTORAGEMULTISAMPLECOVERAGEEXTPROC)glewGetProcAddress((const GLubyte*)"glNamedRenderbufferStorageMultisampleCoverageEXT")) == NULL) || r; - r = ((glNamedRenderbufferStorageMultisampleEXT = (PFNGLNAMEDRENDERBUFFERSTORAGEMULTISAMPLEEXTPROC)glewGetProcAddress((const GLubyte*)"glNamedRenderbufferStorageMultisampleEXT")) == NULL) || r; - r = ((glProgramUniform1fEXT = (PFNGLPROGRAMUNIFORM1FEXTPROC)glewGetProcAddress((const GLubyte*)"glProgramUniform1fEXT")) == NULL) || r; - r = ((glProgramUniform1fvEXT = (PFNGLPROGRAMUNIFORM1FVEXTPROC)glewGetProcAddress((const GLubyte*)"glProgramUniform1fvEXT")) == NULL) || r; - r = ((glProgramUniform1iEXT = (PFNGLPROGRAMUNIFORM1IEXTPROC)glewGetProcAddress((const GLubyte*)"glProgramUniform1iEXT")) == NULL) || r; - r = ((glProgramUniform1ivEXT = (PFNGLPROGRAMUNIFORM1IVEXTPROC)glewGetProcAddress((const GLubyte*)"glProgramUniform1ivEXT")) == NULL) || r; - r = ((glProgramUniform1uiEXT = (PFNGLPROGRAMUNIFORM1UIEXTPROC)glewGetProcAddress((const GLubyte*)"glProgramUniform1uiEXT")) == NULL) || r; - r = ((glProgramUniform1uivEXT = (PFNGLPROGRAMUNIFORM1UIVEXTPROC)glewGetProcAddress((const GLubyte*)"glProgramUniform1uivEXT")) == NULL) || r; - r = ((glProgramUniform2fEXT = (PFNGLPROGRAMUNIFORM2FEXTPROC)glewGetProcAddress((const GLubyte*)"glProgramUniform2fEXT")) == NULL) || r; - r = ((glProgramUniform2fvEXT = (PFNGLPROGRAMUNIFORM2FVEXTPROC)glewGetProcAddress((const GLubyte*)"glProgramUniform2fvEXT")) == NULL) || r; - r = ((glProgramUniform2iEXT = (PFNGLPROGRAMUNIFORM2IEXTPROC)glewGetProcAddress((const GLubyte*)"glProgramUniform2iEXT")) == NULL) || r; - r = ((glProgramUniform2ivEXT = (PFNGLPROGRAMUNIFORM2IVEXTPROC)glewGetProcAddress((const GLubyte*)"glProgramUniform2ivEXT")) == NULL) || r; - r = ((glProgramUniform2uiEXT = (PFNGLPROGRAMUNIFORM2UIEXTPROC)glewGetProcAddress((const GLubyte*)"glProgramUniform2uiEXT")) == NULL) || r; - r = ((glProgramUniform2uivEXT = (PFNGLPROGRAMUNIFORM2UIVEXTPROC)glewGetProcAddress((const GLubyte*)"glProgramUniform2uivEXT")) == NULL) || r; - r = ((glProgramUniform3fEXT = (PFNGLPROGRAMUNIFORM3FEXTPROC)glewGetProcAddress((const GLubyte*)"glProgramUniform3fEXT")) == NULL) || r; - r = ((glProgramUniform3fvEXT = (PFNGLPROGRAMUNIFORM3FVEXTPROC)glewGetProcAddress((const GLubyte*)"glProgramUniform3fvEXT")) == NULL) || r; - r = ((glProgramUniform3iEXT = (PFNGLPROGRAMUNIFORM3IEXTPROC)glewGetProcAddress((const GLubyte*)"glProgramUniform3iEXT")) == NULL) || r; - r = ((glProgramUniform3ivEXT = (PFNGLPROGRAMUNIFORM3IVEXTPROC)glewGetProcAddress((const GLubyte*)"glProgramUniform3ivEXT")) == NULL) || r; - r = ((glProgramUniform3uiEXT = (PFNGLPROGRAMUNIFORM3UIEXTPROC)glewGetProcAddress((const GLubyte*)"glProgramUniform3uiEXT")) == NULL) || r; - r = ((glProgramUniform3uivEXT = (PFNGLPROGRAMUNIFORM3UIVEXTPROC)glewGetProcAddress((const GLubyte*)"glProgramUniform3uivEXT")) == NULL) || r; - r = ((glProgramUniform4fEXT = (PFNGLPROGRAMUNIFORM4FEXTPROC)glewGetProcAddress((const GLubyte*)"glProgramUniform4fEXT")) == NULL) || r; - r = ((glProgramUniform4fvEXT = (PFNGLPROGRAMUNIFORM4FVEXTPROC)glewGetProcAddress((const GLubyte*)"glProgramUniform4fvEXT")) == NULL) || r; - r = ((glProgramUniform4iEXT = (PFNGLPROGRAMUNIFORM4IEXTPROC)glewGetProcAddress((const GLubyte*)"glProgramUniform4iEXT")) == NULL) || r; - r = ((glProgramUniform4ivEXT = (PFNGLPROGRAMUNIFORM4IVEXTPROC)glewGetProcAddress((const GLubyte*)"glProgramUniform4ivEXT")) == NULL) || r; - r = ((glProgramUniform4uiEXT = (PFNGLPROGRAMUNIFORM4UIEXTPROC)glewGetProcAddress((const GLubyte*)"glProgramUniform4uiEXT")) == NULL) || r; - r = ((glProgramUniform4uivEXT = (PFNGLPROGRAMUNIFORM4UIVEXTPROC)glewGetProcAddress((const GLubyte*)"glProgramUniform4uivEXT")) == NULL) || r; - r = ((glProgramUniformMatrix2fvEXT = (PFNGLPROGRAMUNIFORMMATRIX2FVEXTPROC)glewGetProcAddress((const GLubyte*)"glProgramUniformMatrix2fvEXT")) == NULL) || r; - r = ((glProgramUniformMatrix2x3fvEXT = (PFNGLPROGRAMUNIFORMMATRIX2X3FVEXTPROC)glewGetProcAddress((const GLubyte*)"glProgramUniformMatrix2x3fvEXT")) == NULL) || r; - r = ((glProgramUniformMatrix2x4fvEXT = (PFNGLPROGRAMUNIFORMMATRIX2X4FVEXTPROC)glewGetProcAddress((const GLubyte*)"glProgramUniformMatrix2x4fvEXT")) == NULL) || r; - r = ((glProgramUniformMatrix3fvEXT = (PFNGLPROGRAMUNIFORMMATRIX3FVEXTPROC)glewGetProcAddress((const GLubyte*)"glProgramUniformMatrix3fvEXT")) == NULL) || r; - r = ((glProgramUniformMatrix3x2fvEXT = (PFNGLPROGRAMUNIFORMMATRIX3X2FVEXTPROC)glewGetProcAddress((const GLubyte*)"glProgramUniformMatrix3x2fvEXT")) == NULL) || r; - r = ((glProgramUniformMatrix3x4fvEXT = (PFNGLPROGRAMUNIFORMMATRIX3X4FVEXTPROC)glewGetProcAddress((const GLubyte*)"glProgramUniformMatrix3x4fvEXT")) == NULL) || r; - r = ((glProgramUniformMatrix4fvEXT = (PFNGLPROGRAMUNIFORMMATRIX4FVEXTPROC)glewGetProcAddress((const GLubyte*)"glProgramUniformMatrix4fvEXT")) == NULL) || r; - r = ((glProgramUniformMatrix4x2fvEXT = (PFNGLPROGRAMUNIFORMMATRIX4X2FVEXTPROC)glewGetProcAddress((const GLubyte*)"glProgramUniformMatrix4x2fvEXT")) == NULL) || r; - r = ((glProgramUniformMatrix4x3fvEXT = (PFNGLPROGRAMUNIFORMMATRIX4X3FVEXTPROC)glewGetProcAddress((const GLubyte*)"glProgramUniformMatrix4x3fvEXT")) == NULL) || r; - r = ((glPushClientAttribDefaultEXT = (PFNGLPUSHCLIENTATTRIBDEFAULTEXTPROC)glewGetProcAddress((const GLubyte*)"glPushClientAttribDefaultEXT")) == NULL) || r; - r = ((glTextureBufferEXT = (PFNGLTEXTUREBUFFEREXTPROC)glewGetProcAddress((const GLubyte*)"glTextureBufferEXT")) == NULL) || r; - r = ((glTextureImage1DEXT = (PFNGLTEXTUREIMAGE1DEXTPROC)glewGetProcAddress((const GLubyte*)"glTextureImage1DEXT")) == NULL) || r; - r = ((glTextureImage2DEXT = (PFNGLTEXTUREIMAGE2DEXTPROC)glewGetProcAddress((const GLubyte*)"glTextureImage2DEXT")) == NULL) || r; - r = ((glTextureImage3DEXT = (PFNGLTEXTUREIMAGE3DEXTPROC)glewGetProcAddress((const GLubyte*)"glTextureImage3DEXT")) == NULL) || r; - r = ((glTextureParameterIivEXT = (PFNGLTEXTUREPARAMETERIIVEXTPROC)glewGetProcAddress((const GLubyte*)"glTextureParameterIivEXT")) == NULL) || r; - r = ((glTextureParameterIuivEXT = (PFNGLTEXTUREPARAMETERIUIVEXTPROC)glewGetProcAddress((const GLubyte*)"glTextureParameterIuivEXT")) == NULL) || r; - r = ((glTextureParameterfEXT = (PFNGLTEXTUREPARAMETERFEXTPROC)glewGetProcAddress((const GLubyte*)"glTextureParameterfEXT")) == NULL) || r; - r = ((glTextureParameterfvEXT = (PFNGLTEXTUREPARAMETERFVEXTPROC)glewGetProcAddress((const GLubyte*)"glTextureParameterfvEXT")) == NULL) || r; - r = ((glTextureParameteriEXT = (PFNGLTEXTUREPARAMETERIEXTPROC)glewGetProcAddress((const GLubyte*)"glTextureParameteriEXT")) == NULL) || r; - r = ((glTextureParameterivEXT = (PFNGLTEXTUREPARAMETERIVEXTPROC)glewGetProcAddress((const GLubyte*)"glTextureParameterivEXT")) == NULL) || r; - r = ((glTextureRenderbufferEXT = (PFNGLTEXTURERENDERBUFFEREXTPROC)glewGetProcAddress((const GLubyte*)"glTextureRenderbufferEXT")) == NULL) || r; - r = ((glTextureSubImage1DEXT = (PFNGLTEXTURESUBIMAGE1DEXTPROC)glewGetProcAddress((const GLubyte*)"glTextureSubImage1DEXT")) == NULL) || r; - r = ((glTextureSubImage2DEXT = (PFNGLTEXTURESUBIMAGE2DEXTPROC)glewGetProcAddress((const GLubyte*)"glTextureSubImage2DEXT")) == NULL) || r; - r = ((glTextureSubImage3DEXT = (PFNGLTEXTURESUBIMAGE3DEXTPROC)glewGetProcAddress((const GLubyte*)"glTextureSubImage3DEXT")) == NULL) || r; - r = ((glUnmapNamedBufferEXT = (PFNGLUNMAPNAMEDBUFFEREXTPROC)glewGetProcAddress((const GLubyte*)"glUnmapNamedBufferEXT")) == NULL) || r; - - return r; -} - -#endif /* GL_EXT_direct_state_access */ - -#ifdef GL_EXT_draw_buffers2 - -static GLboolean _glewInit_GL_EXT_draw_buffers2 (GLEW_CONTEXT_ARG_DEF_INIT) -{ - GLboolean r = GL_FALSE; - - r = ((glColorMaskIndexedEXT = (PFNGLCOLORMASKINDEXEDEXTPROC)glewGetProcAddress((const GLubyte*)"glColorMaskIndexedEXT")) == NULL) || r; - r = ((glDisableIndexedEXT = (PFNGLDISABLEINDEXEDEXTPROC)glewGetProcAddress((const GLubyte*)"glDisableIndexedEXT")) == NULL) || r; - r = ((glEnableIndexedEXT = (PFNGLENABLEINDEXEDEXTPROC)glewGetProcAddress((const GLubyte*)"glEnableIndexedEXT")) == NULL) || r; - r = ((glGetBooleanIndexedvEXT = (PFNGLGETBOOLEANINDEXEDVEXTPROC)glewGetProcAddress((const GLubyte*)"glGetBooleanIndexedvEXT")) == NULL) || r; - r = ((glGetIntegerIndexedvEXT = (PFNGLGETINTEGERINDEXEDVEXTPROC)glewGetProcAddress((const GLubyte*)"glGetIntegerIndexedvEXT")) == NULL) || r; - r = ((glIsEnabledIndexedEXT = (PFNGLISENABLEDINDEXEDEXTPROC)glewGetProcAddress((const GLubyte*)"glIsEnabledIndexedEXT")) == NULL) || r; - - return r; -} - -#endif /* GL_EXT_draw_buffers2 */ - -#ifdef GL_EXT_draw_instanced - -static GLboolean _glewInit_GL_EXT_draw_instanced (GLEW_CONTEXT_ARG_DEF_INIT) -{ - GLboolean r = GL_FALSE; - - r = ((glDrawArraysInstancedEXT = (PFNGLDRAWARRAYSINSTANCEDEXTPROC)glewGetProcAddress((const GLubyte*)"glDrawArraysInstancedEXT")) == NULL) || r; - r = ((glDrawElementsInstancedEXT = (PFNGLDRAWELEMENTSINSTANCEDEXTPROC)glewGetProcAddress((const GLubyte*)"glDrawElementsInstancedEXT")) == NULL) || r; - - return r; -} - -#endif /* GL_EXT_draw_instanced */ - -#ifdef GL_EXT_draw_range_elements - -static GLboolean _glewInit_GL_EXT_draw_range_elements (GLEW_CONTEXT_ARG_DEF_INIT) -{ - GLboolean r = GL_FALSE; - - r = ((glDrawRangeElementsEXT = (PFNGLDRAWRANGEELEMENTSEXTPROC)glewGetProcAddress((const GLubyte*)"glDrawRangeElementsEXT")) == NULL) || r; - - return r; -} - -#endif /* GL_EXT_draw_range_elements */ - -#ifdef GL_EXT_fog_coord - -static GLboolean _glewInit_GL_EXT_fog_coord (GLEW_CONTEXT_ARG_DEF_INIT) -{ - GLboolean r = GL_FALSE; - - r = ((glFogCoordPointerEXT = (PFNGLFOGCOORDPOINTEREXTPROC)glewGetProcAddress((const GLubyte*)"glFogCoordPointerEXT")) == NULL) || r; - r = ((glFogCoorddEXT = (PFNGLFOGCOORDDEXTPROC)glewGetProcAddress((const GLubyte*)"glFogCoorddEXT")) == NULL) || r; - r = ((glFogCoorddvEXT = (PFNGLFOGCOORDDVEXTPROC)glewGetProcAddress((const GLubyte*)"glFogCoorddvEXT")) == NULL) || r; - r = ((glFogCoordfEXT = (PFNGLFOGCOORDFEXTPROC)glewGetProcAddress((const GLubyte*)"glFogCoordfEXT")) == NULL) || r; - r = ((glFogCoordfvEXT = (PFNGLFOGCOORDFVEXTPROC)glewGetProcAddress((const GLubyte*)"glFogCoordfvEXT")) == NULL) || r; - - return r; -} - -#endif /* GL_EXT_fog_coord */ - -#ifdef GL_EXT_fragment_lighting - -static GLboolean _glewInit_GL_EXT_fragment_lighting (GLEW_CONTEXT_ARG_DEF_INIT) -{ - GLboolean r = GL_FALSE; - - r = ((glFragmentColorMaterialEXT = (PFNGLFRAGMENTCOLORMATERIALEXTPROC)glewGetProcAddress((const GLubyte*)"glFragmentColorMaterialEXT")) == NULL) || r; - r = ((glFragmentLightModelfEXT = (PFNGLFRAGMENTLIGHTMODELFEXTPROC)glewGetProcAddress((const GLubyte*)"glFragmentLightModelfEXT")) == NULL) || r; - r = ((glFragmentLightModelfvEXT = (PFNGLFRAGMENTLIGHTMODELFVEXTPROC)glewGetProcAddress((const GLubyte*)"glFragmentLightModelfvEXT")) == NULL) || r; - r = ((glFragmentLightModeliEXT = (PFNGLFRAGMENTLIGHTMODELIEXTPROC)glewGetProcAddress((const GLubyte*)"glFragmentLightModeliEXT")) == NULL) || r; - r = ((glFragmentLightModelivEXT = (PFNGLFRAGMENTLIGHTMODELIVEXTPROC)glewGetProcAddress((const GLubyte*)"glFragmentLightModelivEXT")) == NULL) || r; - r = ((glFragmentLightfEXT = (PFNGLFRAGMENTLIGHTFEXTPROC)glewGetProcAddress((const GLubyte*)"glFragmentLightfEXT")) == NULL) || r; - r = ((glFragmentLightfvEXT = (PFNGLFRAGMENTLIGHTFVEXTPROC)glewGetProcAddress((const GLubyte*)"glFragmentLightfvEXT")) == NULL) || r; - r = ((glFragmentLightiEXT = (PFNGLFRAGMENTLIGHTIEXTPROC)glewGetProcAddress((const GLubyte*)"glFragmentLightiEXT")) == NULL) || r; - r = ((glFragmentLightivEXT = (PFNGLFRAGMENTLIGHTIVEXTPROC)glewGetProcAddress((const GLubyte*)"glFragmentLightivEXT")) == NULL) || r; - r = ((glFragmentMaterialfEXT = (PFNGLFRAGMENTMATERIALFEXTPROC)glewGetProcAddress((const GLubyte*)"glFragmentMaterialfEXT")) == NULL) || r; - r = ((glFragmentMaterialfvEXT = (PFNGLFRAGMENTMATERIALFVEXTPROC)glewGetProcAddress((const GLubyte*)"glFragmentMaterialfvEXT")) == NULL) || r; - r = ((glFragmentMaterialiEXT = (PFNGLFRAGMENTMATERIALIEXTPROC)glewGetProcAddress((const GLubyte*)"glFragmentMaterialiEXT")) == NULL) || r; - r = ((glFragmentMaterialivEXT = (PFNGLFRAGMENTMATERIALIVEXTPROC)glewGetProcAddress((const GLubyte*)"glFragmentMaterialivEXT")) == NULL) || r; - r = ((glGetFragmentLightfvEXT = (PFNGLGETFRAGMENTLIGHTFVEXTPROC)glewGetProcAddress((const GLubyte*)"glGetFragmentLightfvEXT")) == NULL) || r; - r = ((glGetFragmentLightivEXT = (PFNGLGETFRAGMENTLIGHTIVEXTPROC)glewGetProcAddress((const GLubyte*)"glGetFragmentLightivEXT")) == NULL) || r; - r = ((glGetFragmentMaterialfvEXT = (PFNGLGETFRAGMENTMATERIALFVEXTPROC)glewGetProcAddress((const GLubyte*)"glGetFragmentMaterialfvEXT")) == NULL) || r; - r = ((glGetFragmentMaterialivEXT = (PFNGLGETFRAGMENTMATERIALIVEXTPROC)glewGetProcAddress((const GLubyte*)"glGetFragmentMaterialivEXT")) == NULL) || r; - r = ((glLightEnviEXT = (PFNGLLIGHTENVIEXTPROC)glewGetProcAddress((const GLubyte*)"glLightEnviEXT")) == NULL) || r; - - return r; -} - -#endif /* GL_EXT_fragment_lighting */ - -#ifdef GL_EXT_framebuffer_blit - -static GLboolean _glewInit_GL_EXT_framebuffer_blit (GLEW_CONTEXT_ARG_DEF_INIT) -{ - GLboolean r = GL_FALSE; - - r = ((glBlitFramebufferEXT = (PFNGLBLITFRAMEBUFFEREXTPROC)glewGetProcAddress((const GLubyte*)"glBlitFramebufferEXT")) == NULL) || r; - - return r; -} - -#endif /* GL_EXT_framebuffer_blit */ - -#ifdef GL_EXT_framebuffer_multisample - -static GLboolean _glewInit_GL_EXT_framebuffer_multisample (GLEW_CONTEXT_ARG_DEF_INIT) -{ - GLboolean r = GL_FALSE; - - r = ((glRenderbufferStorageMultisampleEXT = (PFNGLRENDERBUFFERSTORAGEMULTISAMPLEEXTPROC)glewGetProcAddress((const GLubyte*)"glRenderbufferStorageMultisampleEXT")) == NULL) || r; - - return r; -} - -#endif /* GL_EXT_framebuffer_multisample */ - -#ifdef GL_EXT_framebuffer_object - -static GLboolean _glewInit_GL_EXT_framebuffer_object (GLEW_CONTEXT_ARG_DEF_INIT) -{ - GLboolean r = GL_FALSE; - - r = ((glBindFramebufferEXT = (PFNGLBINDFRAMEBUFFEREXTPROC)glewGetProcAddress((const GLubyte*)"glBindFramebufferEXT")) == NULL) || r; - r = ((glBindRenderbufferEXT = (PFNGLBINDRENDERBUFFEREXTPROC)glewGetProcAddress((const GLubyte*)"glBindRenderbufferEXT")) == NULL) || r; - r = ((glCheckFramebufferStatusEXT = (PFNGLCHECKFRAMEBUFFERSTATUSEXTPROC)glewGetProcAddress((const GLubyte*)"glCheckFramebufferStatusEXT")) == NULL) || r; - r = ((glDeleteFramebuffersEXT = (PFNGLDELETEFRAMEBUFFERSEXTPROC)glewGetProcAddress((const GLubyte*)"glDeleteFramebuffersEXT")) == NULL) || r; - r = ((glDeleteRenderbuffersEXT = (PFNGLDELETERENDERBUFFERSEXTPROC)glewGetProcAddress((const GLubyte*)"glDeleteRenderbuffersEXT")) == NULL) || r; - r = ((glFramebufferRenderbufferEXT = (PFNGLFRAMEBUFFERRENDERBUFFEREXTPROC)glewGetProcAddress((const GLubyte*)"glFramebufferRenderbufferEXT")) == NULL) || r; - r = ((glFramebufferTexture1DEXT = (PFNGLFRAMEBUFFERTEXTURE1DEXTPROC)glewGetProcAddress((const GLubyte*)"glFramebufferTexture1DEXT")) == NULL) || r; - r = ((glFramebufferTexture2DEXT = (PFNGLFRAMEBUFFERTEXTURE2DEXTPROC)glewGetProcAddress((const GLubyte*)"glFramebufferTexture2DEXT")) == NULL) || r; - r = ((glFramebufferTexture3DEXT = (PFNGLFRAMEBUFFERTEXTURE3DEXTPROC)glewGetProcAddress((const GLubyte*)"glFramebufferTexture3DEXT")) == NULL) || r; - r = ((glGenFramebuffersEXT = (PFNGLGENFRAMEBUFFERSEXTPROC)glewGetProcAddress((const GLubyte*)"glGenFramebuffersEXT")) == NULL) || r; - r = ((glGenRenderbuffersEXT = (PFNGLGENRENDERBUFFERSEXTPROC)glewGetProcAddress((const GLubyte*)"glGenRenderbuffersEXT")) == NULL) || r; - r = ((glGenerateMipmapEXT = (PFNGLGENERATEMIPMAPEXTPROC)glewGetProcAddress((const GLubyte*)"glGenerateMipmapEXT")) == NULL) || r; - r = ((glGetFramebufferAttachmentParameterivEXT = (PFNGLGETFRAMEBUFFERATTACHMENTPARAMETERIVEXTPROC)glewGetProcAddress((const GLubyte*)"glGetFramebufferAttachmentParameterivEXT")) == NULL) || r; - r = ((glGetRenderbufferParameterivEXT = (PFNGLGETRENDERBUFFERPARAMETERIVEXTPROC)glewGetProcAddress((const GLubyte*)"glGetRenderbufferParameterivEXT")) == NULL) || r; - r = ((glIsFramebufferEXT = (PFNGLISFRAMEBUFFEREXTPROC)glewGetProcAddress((const GLubyte*)"glIsFramebufferEXT")) == NULL) || r; - r = ((glIsRenderbufferEXT = (PFNGLISRENDERBUFFEREXTPROC)glewGetProcAddress((const GLubyte*)"glIsRenderbufferEXT")) == NULL) || r; - r = ((glRenderbufferStorageEXT = (PFNGLRENDERBUFFERSTORAGEEXTPROC)glewGetProcAddress((const GLubyte*)"glRenderbufferStorageEXT")) == NULL) || r; - - return r; -} - -#endif /* GL_EXT_framebuffer_object */ - -#ifdef GL_EXT_framebuffer_sRGB - -#endif /* GL_EXT_framebuffer_sRGB */ - -#ifdef GL_EXT_geometry_shader4 - -static GLboolean _glewInit_GL_EXT_geometry_shader4 (GLEW_CONTEXT_ARG_DEF_INIT) -{ - GLboolean r = GL_FALSE; - - r = ((glFramebufferTextureEXT = (PFNGLFRAMEBUFFERTEXTUREEXTPROC)glewGetProcAddress((const GLubyte*)"glFramebufferTextureEXT")) == NULL) || r; - r = ((glFramebufferTextureFaceEXT = (PFNGLFRAMEBUFFERTEXTUREFACEEXTPROC)glewGetProcAddress((const GLubyte*)"glFramebufferTextureFaceEXT")) == NULL) || r; - r = ((glFramebufferTextureLayerEXT = (PFNGLFRAMEBUFFERTEXTURELAYEREXTPROC)glewGetProcAddress((const GLubyte*)"glFramebufferTextureLayerEXT")) == NULL) || r; - r = ((glProgramParameteriEXT = (PFNGLPROGRAMPARAMETERIEXTPROC)glewGetProcAddress((const GLubyte*)"glProgramParameteriEXT")) == NULL) || r; - - return r; -} - -#endif /* GL_EXT_geometry_shader4 */ - -#ifdef GL_EXT_gpu_program_parameters - -static GLboolean _glewInit_GL_EXT_gpu_program_parameters (GLEW_CONTEXT_ARG_DEF_INIT) -{ - GLboolean r = GL_FALSE; - - r = ((glProgramEnvParameters4fvEXT = (PFNGLPROGRAMENVPARAMETERS4FVEXTPROC)glewGetProcAddress((const GLubyte*)"glProgramEnvParameters4fvEXT")) == NULL) || r; - r = ((glProgramLocalParameters4fvEXT = (PFNGLPROGRAMLOCALPARAMETERS4FVEXTPROC)glewGetProcAddress((const GLubyte*)"glProgramLocalParameters4fvEXT")) == NULL) || r; - - return r; -} - -#endif /* GL_EXT_gpu_program_parameters */ - -#ifdef GL_EXT_gpu_shader4 - -static GLboolean _glewInit_GL_EXT_gpu_shader4 (GLEW_CONTEXT_ARG_DEF_INIT) -{ - GLboolean r = GL_FALSE; - - r = ((glBindFragDataLocationEXT = (PFNGLBINDFRAGDATALOCATIONEXTPROC)glewGetProcAddress((const GLubyte*)"glBindFragDataLocationEXT")) == NULL) || r; - r = ((glGetFragDataLocationEXT = (PFNGLGETFRAGDATALOCATIONEXTPROC)glewGetProcAddress((const GLubyte*)"glGetFragDataLocationEXT")) == NULL) || r; - r = ((glGetUniformuivEXT = (PFNGLGETUNIFORMUIVEXTPROC)glewGetProcAddress((const GLubyte*)"glGetUniformuivEXT")) == NULL) || r; - r = ((glGetVertexAttribIivEXT = (PFNGLGETVERTEXATTRIBIIVEXTPROC)glewGetProcAddress((const GLubyte*)"glGetVertexAttribIivEXT")) == NULL) || r; - r = ((glGetVertexAttribIuivEXT = (PFNGLGETVERTEXATTRIBIUIVEXTPROC)glewGetProcAddress((const GLubyte*)"glGetVertexAttribIuivEXT")) == NULL) || r; - r = ((glUniform1uiEXT = (PFNGLUNIFORM1UIEXTPROC)glewGetProcAddress((const GLubyte*)"glUniform1uiEXT")) == NULL) || r; - r = ((glUniform1uivEXT = (PFNGLUNIFORM1UIVEXTPROC)glewGetProcAddress((const GLubyte*)"glUniform1uivEXT")) == NULL) || r; - r = ((glUniform2uiEXT = (PFNGLUNIFORM2UIEXTPROC)glewGetProcAddress((const GLubyte*)"glUniform2uiEXT")) == NULL) || r; - r = ((glUniform2uivEXT = (PFNGLUNIFORM2UIVEXTPROC)glewGetProcAddress((const GLubyte*)"glUniform2uivEXT")) == NULL) || r; - r = ((glUniform3uiEXT = (PFNGLUNIFORM3UIEXTPROC)glewGetProcAddress((const GLubyte*)"glUniform3uiEXT")) == NULL) || r; - r = ((glUniform3uivEXT = (PFNGLUNIFORM3UIVEXTPROC)glewGetProcAddress((const GLubyte*)"glUniform3uivEXT")) == NULL) || r; - r = ((glUniform4uiEXT = (PFNGLUNIFORM4UIEXTPROC)glewGetProcAddress((const GLubyte*)"glUniform4uiEXT")) == NULL) || r; - r = ((glUniform4uivEXT = (PFNGLUNIFORM4UIVEXTPROC)glewGetProcAddress((const GLubyte*)"glUniform4uivEXT")) == NULL) || r; - r = ((glVertexAttribI1iEXT = (PFNGLVERTEXATTRIBI1IEXTPROC)glewGetProcAddress((const GLubyte*)"glVertexAttribI1iEXT")) == NULL) || r; - r = ((glVertexAttribI1ivEXT = (PFNGLVERTEXATTRIBI1IVEXTPROC)glewGetProcAddress((const GLubyte*)"glVertexAttribI1ivEXT")) == NULL) || r; - r = ((glVertexAttribI1uiEXT = (PFNGLVERTEXATTRIBI1UIEXTPROC)glewGetProcAddress((const GLubyte*)"glVertexAttribI1uiEXT")) == NULL) || r; - r = ((glVertexAttribI1uivEXT = (PFNGLVERTEXATTRIBI1UIVEXTPROC)glewGetProcAddress((const GLubyte*)"glVertexAttribI1uivEXT")) == NULL) || r; - r = ((glVertexAttribI2iEXT = (PFNGLVERTEXATTRIBI2IEXTPROC)glewGetProcAddress((const GLubyte*)"glVertexAttribI2iEXT")) == NULL) || r; - r = ((glVertexAttribI2ivEXT = (PFNGLVERTEXATTRIBI2IVEXTPROC)glewGetProcAddress((const GLubyte*)"glVertexAttribI2ivEXT")) == NULL) || r; - r = ((glVertexAttribI2uiEXT = (PFNGLVERTEXATTRIBI2UIEXTPROC)glewGetProcAddress((const GLubyte*)"glVertexAttribI2uiEXT")) == NULL) || r; - r = ((glVertexAttribI2uivEXT = (PFNGLVERTEXATTRIBI2UIVEXTPROC)glewGetProcAddress((const GLubyte*)"glVertexAttribI2uivEXT")) == NULL) || r; - r = ((glVertexAttribI3iEXT = (PFNGLVERTEXATTRIBI3IEXTPROC)glewGetProcAddress((const GLubyte*)"glVertexAttribI3iEXT")) == NULL) || r; - r = ((glVertexAttribI3ivEXT = (PFNGLVERTEXATTRIBI3IVEXTPROC)glewGetProcAddress((const GLubyte*)"glVertexAttribI3ivEXT")) == NULL) || r; - r = ((glVertexAttribI3uiEXT = (PFNGLVERTEXATTRIBI3UIEXTPROC)glewGetProcAddress((const GLubyte*)"glVertexAttribI3uiEXT")) == NULL) || r; - r = ((glVertexAttribI3uivEXT = (PFNGLVERTEXATTRIBI3UIVEXTPROC)glewGetProcAddress((const GLubyte*)"glVertexAttribI3uivEXT")) == NULL) || r; - r = ((glVertexAttribI4bvEXT = (PFNGLVERTEXATTRIBI4BVEXTPROC)glewGetProcAddress((const GLubyte*)"glVertexAttribI4bvEXT")) == NULL) || r; - r = ((glVertexAttribI4iEXT = (PFNGLVERTEXATTRIBI4IEXTPROC)glewGetProcAddress((const GLubyte*)"glVertexAttribI4iEXT")) == NULL) || r; - r = ((glVertexAttribI4ivEXT = (PFNGLVERTEXATTRIBI4IVEXTPROC)glewGetProcAddress((const GLubyte*)"glVertexAttribI4ivEXT")) == NULL) || r; - r = ((glVertexAttribI4svEXT = (PFNGLVERTEXATTRIBI4SVEXTPROC)glewGetProcAddress((const GLubyte*)"glVertexAttribI4svEXT")) == NULL) || r; - r = ((glVertexAttribI4ubvEXT = (PFNGLVERTEXATTRIBI4UBVEXTPROC)glewGetProcAddress((const GLubyte*)"glVertexAttribI4ubvEXT")) == NULL) || r; - r = ((glVertexAttribI4uiEXT = (PFNGLVERTEXATTRIBI4UIEXTPROC)glewGetProcAddress((const GLubyte*)"glVertexAttribI4uiEXT")) == NULL) || r; - r = ((glVertexAttribI4uivEXT = (PFNGLVERTEXATTRIBI4UIVEXTPROC)glewGetProcAddress((const GLubyte*)"glVertexAttribI4uivEXT")) == NULL) || r; - r = ((glVertexAttribI4usvEXT = (PFNGLVERTEXATTRIBI4USVEXTPROC)glewGetProcAddress((const GLubyte*)"glVertexAttribI4usvEXT")) == NULL) || r; - r = ((glVertexAttribIPointerEXT = (PFNGLVERTEXATTRIBIPOINTEREXTPROC)glewGetProcAddress((const GLubyte*)"glVertexAttribIPointerEXT")) == NULL) || r; - - return r; -} - -#endif /* GL_EXT_gpu_shader4 */ - -#ifdef GL_EXT_histogram - -static GLboolean _glewInit_GL_EXT_histogram (GLEW_CONTEXT_ARG_DEF_INIT) -{ - GLboolean r = GL_FALSE; - - r = ((glGetHistogramEXT = (PFNGLGETHISTOGRAMEXTPROC)glewGetProcAddress((const GLubyte*)"glGetHistogramEXT")) == NULL) || r; - r = ((glGetHistogramParameterfvEXT = (PFNGLGETHISTOGRAMPARAMETERFVEXTPROC)glewGetProcAddress((const GLubyte*)"glGetHistogramParameterfvEXT")) == NULL) || r; - r = ((glGetHistogramParameterivEXT = (PFNGLGETHISTOGRAMPARAMETERIVEXTPROC)glewGetProcAddress((const GLubyte*)"glGetHistogramParameterivEXT")) == NULL) || r; - r = ((glGetMinmaxEXT = (PFNGLGETMINMAXEXTPROC)glewGetProcAddress((const GLubyte*)"glGetMinmaxEXT")) == NULL) || r; - r = ((glGetMinmaxParameterfvEXT = (PFNGLGETMINMAXPARAMETERFVEXTPROC)glewGetProcAddress((const GLubyte*)"glGetMinmaxParameterfvEXT")) == NULL) || r; - r = ((glGetMinmaxParameterivEXT = (PFNGLGETMINMAXPARAMETERIVEXTPROC)glewGetProcAddress((const GLubyte*)"glGetMinmaxParameterivEXT")) == NULL) || r; - r = ((glHistogramEXT = (PFNGLHISTOGRAMEXTPROC)glewGetProcAddress((const GLubyte*)"glHistogramEXT")) == NULL) || r; - r = ((glMinmaxEXT = (PFNGLMINMAXEXTPROC)glewGetProcAddress((const GLubyte*)"glMinmaxEXT")) == NULL) || r; - r = ((glResetHistogramEXT = (PFNGLRESETHISTOGRAMEXTPROC)glewGetProcAddress((const GLubyte*)"glResetHistogramEXT")) == NULL) || r; - r = ((glResetMinmaxEXT = (PFNGLRESETMINMAXEXTPROC)glewGetProcAddress((const GLubyte*)"glResetMinmaxEXT")) == NULL) || r; - - return r; -} - -#endif /* GL_EXT_histogram */ - -#ifdef GL_EXT_index_array_formats - -#endif /* GL_EXT_index_array_formats */ - -#ifdef GL_EXT_index_func - -static GLboolean _glewInit_GL_EXT_index_func (GLEW_CONTEXT_ARG_DEF_INIT) -{ - GLboolean r = GL_FALSE; - - r = ((glIndexFuncEXT = (PFNGLINDEXFUNCEXTPROC)glewGetProcAddress((const GLubyte*)"glIndexFuncEXT")) == NULL) || r; - - return r; -} - -#endif /* GL_EXT_index_func */ - -#ifdef GL_EXT_index_material - -static GLboolean _glewInit_GL_EXT_index_material (GLEW_CONTEXT_ARG_DEF_INIT) -{ - GLboolean r = GL_FALSE; - - r = ((glIndexMaterialEXT = (PFNGLINDEXMATERIALEXTPROC)glewGetProcAddress((const GLubyte*)"glIndexMaterialEXT")) == NULL) || r; - - return r; -} - -#endif /* GL_EXT_index_material */ - -#ifdef GL_EXT_index_texture - -#endif /* GL_EXT_index_texture */ - -#ifdef GL_EXT_light_texture - -static GLboolean _glewInit_GL_EXT_light_texture (GLEW_CONTEXT_ARG_DEF_INIT) -{ - GLboolean r = GL_FALSE; - - r = ((glApplyTextureEXT = (PFNGLAPPLYTEXTUREEXTPROC)glewGetProcAddress((const GLubyte*)"glApplyTextureEXT")) == NULL) || r; - r = ((glTextureLightEXT = (PFNGLTEXTURELIGHTEXTPROC)glewGetProcAddress((const GLubyte*)"glTextureLightEXT")) == NULL) || r; - r = ((glTextureMaterialEXT = (PFNGLTEXTUREMATERIALEXTPROC)glewGetProcAddress((const GLubyte*)"glTextureMaterialEXT")) == NULL) || r; - - return r; -} - -#endif /* GL_EXT_light_texture */ - -#ifdef GL_EXT_misc_attribute - -#endif /* GL_EXT_misc_attribute */ - -#ifdef GL_EXT_multi_draw_arrays - -static GLboolean _glewInit_GL_EXT_multi_draw_arrays (GLEW_CONTEXT_ARG_DEF_INIT) -{ - GLboolean r = GL_FALSE; - - r = ((glMultiDrawArraysEXT = (PFNGLMULTIDRAWARRAYSEXTPROC)glewGetProcAddress((const GLubyte*)"glMultiDrawArraysEXT")) == NULL) || r; - r = ((glMultiDrawElementsEXT = (PFNGLMULTIDRAWELEMENTSEXTPROC)glewGetProcAddress((const GLubyte*)"glMultiDrawElementsEXT")) == NULL) || r; - - return r; -} - -#endif /* GL_EXT_multi_draw_arrays */ - -#ifdef GL_EXT_multisample - -static GLboolean _glewInit_GL_EXT_multisample (GLEW_CONTEXT_ARG_DEF_INIT) -{ - GLboolean r = GL_FALSE; - - r = ((glSampleMaskEXT = (PFNGLSAMPLEMASKEXTPROC)glewGetProcAddress((const GLubyte*)"glSampleMaskEXT")) == NULL) || r; - r = ((glSamplePatternEXT = (PFNGLSAMPLEPATTERNEXTPROC)glewGetProcAddress((const GLubyte*)"glSamplePatternEXT")) == NULL) || r; - - return r; -} - -#endif /* GL_EXT_multisample */ - -#ifdef GL_EXT_packed_depth_stencil - -#endif /* GL_EXT_packed_depth_stencil */ - -#ifdef GL_EXT_packed_float - -#endif /* GL_EXT_packed_float */ - -#ifdef GL_EXT_packed_pixels - -#endif /* GL_EXT_packed_pixels */ - -#ifdef GL_EXT_paletted_texture - -static GLboolean _glewInit_GL_EXT_paletted_texture (GLEW_CONTEXT_ARG_DEF_INIT) -{ - GLboolean r = GL_FALSE; - - r = ((glColorTableEXT = (PFNGLCOLORTABLEEXTPROC)glewGetProcAddress((const GLubyte*)"glColorTableEXT")) == NULL) || r; - r = ((glGetColorTableEXT = (PFNGLGETCOLORTABLEEXTPROC)glewGetProcAddress((const GLubyte*)"glGetColorTableEXT")) == NULL) || r; - r = ((glGetColorTableParameterfvEXT = (PFNGLGETCOLORTABLEPARAMETERFVEXTPROC)glewGetProcAddress((const GLubyte*)"glGetColorTableParameterfvEXT")) == NULL) || r; - r = ((glGetColorTableParameterivEXT = (PFNGLGETCOLORTABLEPARAMETERIVEXTPROC)glewGetProcAddress((const GLubyte*)"glGetColorTableParameterivEXT")) == NULL) || r; - - return r; -} - -#endif /* GL_EXT_paletted_texture */ - -#ifdef GL_EXT_pixel_buffer_object - -#endif /* GL_EXT_pixel_buffer_object */ - -#ifdef GL_EXT_pixel_transform - -static GLboolean _glewInit_GL_EXT_pixel_transform (GLEW_CONTEXT_ARG_DEF_INIT) -{ - GLboolean r = GL_FALSE; - - r = ((glGetPixelTransformParameterfvEXT = (PFNGLGETPIXELTRANSFORMPARAMETERFVEXTPROC)glewGetProcAddress((const GLubyte*)"glGetPixelTransformParameterfvEXT")) == NULL) || r; - r = ((glGetPixelTransformParameterivEXT = (PFNGLGETPIXELTRANSFORMPARAMETERIVEXTPROC)glewGetProcAddress((const GLubyte*)"glGetPixelTransformParameterivEXT")) == NULL) || r; - r = ((glPixelTransformParameterfEXT = (PFNGLPIXELTRANSFORMPARAMETERFEXTPROC)glewGetProcAddress((const GLubyte*)"glPixelTransformParameterfEXT")) == NULL) || r; - r = ((glPixelTransformParameterfvEXT = (PFNGLPIXELTRANSFORMPARAMETERFVEXTPROC)glewGetProcAddress((const GLubyte*)"glPixelTransformParameterfvEXT")) == NULL) || r; - r = ((glPixelTransformParameteriEXT = (PFNGLPIXELTRANSFORMPARAMETERIEXTPROC)glewGetProcAddress((const GLubyte*)"glPixelTransformParameteriEXT")) == NULL) || r; - r = ((glPixelTransformParameterivEXT = (PFNGLPIXELTRANSFORMPARAMETERIVEXTPROC)glewGetProcAddress((const GLubyte*)"glPixelTransformParameterivEXT")) == NULL) || r; - - return r; -} - -#endif /* GL_EXT_pixel_transform */ - -#ifdef GL_EXT_pixel_transform_color_table - -#endif /* GL_EXT_pixel_transform_color_table */ - -#ifdef GL_EXT_point_parameters - -static GLboolean _glewInit_GL_EXT_point_parameters (GLEW_CONTEXT_ARG_DEF_INIT) -{ - GLboolean r = GL_FALSE; - - r = ((glPointParameterfEXT = (PFNGLPOINTPARAMETERFEXTPROC)glewGetProcAddress((const GLubyte*)"glPointParameterfEXT")) == NULL) || r; - r = ((glPointParameterfvEXT = (PFNGLPOINTPARAMETERFVEXTPROC)glewGetProcAddress((const GLubyte*)"glPointParameterfvEXT")) == NULL) || r; - - return r; -} - -#endif /* GL_EXT_point_parameters */ - -#ifdef GL_EXT_polygon_offset - -static GLboolean _glewInit_GL_EXT_polygon_offset (GLEW_CONTEXT_ARG_DEF_INIT) -{ - GLboolean r = GL_FALSE; - - r = ((glPolygonOffsetEXT = (PFNGLPOLYGONOFFSETEXTPROC)glewGetProcAddress((const GLubyte*)"glPolygonOffsetEXT")) == NULL) || r; - - return r; -} - -#endif /* GL_EXT_polygon_offset */ - -#ifdef GL_EXT_rescale_normal - -#endif /* GL_EXT_rescale_normal */ - -#ifdef GL_EXT_scene_marker - -static GLboolean _glewInit_GL_EXT_scene_marker (GLEW_CONTEXT_ARG_DEF_INIT) -{ - GLboolean r = GL_FALSE; - - r = ((glBeginSceneEXT = (PFNGLBEGINSCENEEXTPROC)glewGetProcAddress((const GLubyte*)"glBeginSceneEXT")) == NULL) || r; - r = ((glEndSceneEXT = (PFNGLENDSCENEEXTPROC)glewGetProcAddress((const GLubyte*)"glEndSceneEXT")) == NULL) || r; - - return r; -} - -#endif /* GL_EXT_scene_marker */ - -#ifdef GL_EXT_secondary_color - -static GLboolean _glewInit_GL_EXT_secondary_color (GLEW_CONTEXT_ARG_DEF_INIT) -{ - GLboolean r = GL_FALSE; - - r = ((glSecondaryColor3bEXT = (PFNGLSECONDARYCOLOR3BEXTPROC)glewGetProcAddress((const GLubyte*)"glSecondaryColor3bEXT")) == NULL) || r; - r = ((glSecondaryColor3bvEXT = (PFNGLSECONDARYCOLOR3BVEXTPROC)glewGetProcAddress((const GLubyte*)"glSecondaryColor3bvEXT")) == NULL) || r; - r = ((glSecondaryColor3dEXT = (PFNGLSECONDARYCOLOR3DEXTPROC)glewGetProcAddress((const GLubyte*)"glSecondaryColor3dEXT")) == NULL) || r; - r = ((glSecondaryColor3dvEXT = (PFNGLSECONDARYCOLOR3DVEXTPROC)glewGetProcAddress((const GLubyte*)"glSecondaryColor3dvEXT")) == NULL) || r; - r = ((glSecondaryColor3fEXT = (PFNGLSECONDARYCOLOR3FEXTPROC)glewGetProcAddress((const GLubyte*)"glSecondaryColor3fEXT")) == NULL) || r; - r = ((glSecondaryColor3fvEXT = (PFNGLSECONDARYCOLOR3FVEXTPROC)glewGetProcAddress((const GLubyte*)"glSecondaryColor3fvEXT")) == NULL) || r; - r = ((glSecondaryColor3iEXT = (PFNGLSECONDARYCOLOR3IEXTPROC)glewGetProcAddress((const GLubyte*)"glSecondaryColor3iEXT")) == NULL) || r; - r = ((glSecondaryColor3ivEXT = (PFNGLSECONDARYCOLOR3IVEXTPROC)glewGetProcAddress((const GLubyte*)"glSecondaryColor3ivEXT")) == NULL) || r; - r = ((glSecondaryColor3sEXT = (PFNGLSECONDARYCOLOR3SEXTPROC)glewGetProcAddress((const GLubyte*)"glSecondaryColor3sEXT")) == NULL) || r; - r = ((glSecondaryColor3svEXT = (PFNGLSECONDARYCOLOR3SVEXTPROC)glewGetProcAddress((const GLubyte*)"glSecondaryColor3svEXT")) == NULL) || r; - r = ((glSecondaryColor3ubEXT = (PFNGLSECONDARYCOLOR3UBEXTPROC)glewGetProcAddress((const GLubyte*)"glSecondaryColor3ubEXT")) == NULL) || r; - r = ((glSecondaryColor3ubvEXT = (PFNGLSECONDARYCOLOR3UBVEXTPROC)glewGetProcAddress((const GLubyte*)"glSecondaryColor3ubvEXT")) == NULL) || r; - r = ((glSecondaryColor3uiEXT = (PFNGLSECONDARYCOLOR3UIEXTPROC)glewGetProcAddress((const GLubyte*)"glSecondaryColor3uiEXT")) == NULL) || r; - r = ((glSecondaryColor3uivEXT = (PFNGLSECONDARYCOLOR3UIVEXTPROC)glewGetProcAddress((const GLubyte*)"glSecondaryColor3uivEXT")) == NULL) || r; - r = ((glSecondaryColor3usEXT = (PFNGLSECONDARYCOLOR3USEXTPROC)glewGetProcAddress((const GLubyte*)"glSecondaryColor3usEXT")) == NULL) || r; - r = ((glSecondaryColor3usvEXT = (PFNGLSECONDARYCOLOR3USVEXTPROC)glewGetProcAddress((const GLubyte*)"glSecondaryColor3usvEXT")) == NULL) || r; - r = ((glSecondaryColorPointerEXT = (PFNGLSECONDARYCOLORPOINTEREXTPROC)glewGetProcAddress((const GLubyte*)"glSecondaryColorPointerEXT")) == NULL) || r; - - return r; -} - -#endif /* GL_EXT_secondary_color */ - -#ifdef GL_EXT_separate_specular_color - -#endif /* GL_EXT_separate_specular_color */ - -#ifdef GL_EXT_shadow_funcs - -#endif /* GL_EXT_shadow_funcs */ - -#ifdef GL_EXT_shared_texture_palette - -#endif /* GL_EXT_shared_texture_palette */ - -#ifdef GL_EXT_stencil_clear_tag - -#endif /* GL_EXT_stencil_clear_tag */ - -#ifdef GL_EXT_stencil_two_side - -static GLboolean _glewInit_GL_EXT_stencil_two_side (GLEW_CONTEXT_ARG_DEF_INIT) -{ - GLboolean r = GL_FALSE; - - r = ((glActiveStencilFaceEXT = (PFNGLACTIVESTENCILFACEEXTPROC)glewGetProcAddress((const GLubyte*)"glActiveStencilFaceEXT")) == NULL) || r; - - return r; -} - -#endif /* GL_EXT_stencil_two_side */ - -#ifdef GL_EXT_stencil_wrap - -#endif /* GL_EXT_stencil_wrap */ - -#ifdef GL_EXT_subtexture - -static GLboolean _glewInit_GL_EXT_subtexture (GLEW_CONTEXT_ARG_DEF_INIT) -{ - GLboolean r = GL_FALSE; - - r = ((glTexSubImage1DEXT = (PFNGLTEXSUBIMAGE1DEXTPROC)glewGetProcAddress((const GLubyte*)"glTexSubImage1DEXT")) == NULL) || r; - r = ((glTexSubImage2DEXT = (PFNGLTEXSUBIMAGE2DEXTPROC)glewGetProcAddress((const GLubyte*)"glTexSubImage2DEXT")) == NULL) || r; - r = ((glTexSubImage3DEXT = (PFNGLTEXSUBIMAGE3DEXTPROC)glewGetProcAddress((const GLubyte*)"glTexSubImage3DEXT")) == NULL) || r; - - return r; -} - -#endif /* GL_EXT_subtexture */ - -#ifdef GL_EXT_texture - -#endif /* GL_EXT_texture */ - -#ifdef GL_EXT_texture3D - -static GLboolean _glewInit_GL_EXT_texture3D (GLEW_CONTEXT_ARG_DEF_INIT) -{ - GLboolean r = GL_FALSE; - - r = ((glTexImage3DEXT = (PFNGLTEXIMAGE3DEXTPROC)glewGetProcAddress((const GLubyte*)"glTexImage3DEXT")) == NULL) || r; - - return r; -} - -#endif /* GL_EXT_texture3D */ - -#ifdef GL_EXT_texture_array - -#endif /* GL_EXT_texture_array */ - -#ifdef GL_EXT_texture_buffer_object - -static GLboolean _glewInit_GL_EXT_texture_buffer_object (GLEW_CONTEXT_ARG_DEF_INIT) -{ - GLboolean r = GL_FALSE; - - r = ((glTexBufferEXT = (PFNGLTEXBUFFEREXTPROC)glewGetProcAddress((const GLubyte*)"glTexBufferEXT")) == NULL) || r; - - return r; -} - -#endif /* GL_EXT_texture_buffer_object */ - -#ifdef GL_EXT_texture_compression_dxt1 - -#endif /* GL_EXT_texture_compression_dxt1 */ - -#ifdef GL_EXT_texture_compression_latc - -#endif /* GL_EXT_texture_compression_latc */ - -#ifdef GL_EXT_texture_compression_rgtc - -#endif /* GL_EXT_texture_compression_rgtc */ - -#ifdef GL_EXT_texture_compression_s3tc - -#endif /* GL_EXT_texture_compression_s3tc */ - -#ifdef GL_EXT_texture_cube_map - -#endif /* GL_EXT_texture_cube_map */ - -#ifdef GL_EXT_texture_edge_clamp - -#endif /* GL_EXT_texture_edge_clamp */ - -#ifdef GL_EXT_texture_env - -#endif /* GL_EXT_texture_env */ - -#ifdef GL_EXT_texture_env_add - -#endif /* GL_EXT_texture_env_add */ - -#ifdef GL_EXT_texture_env_combine - -#endif /* GL_EXT_texture_env_combine */ - -#ifdef GL_EXT_texture_env_dot3 - -#endif /* GL_EXT_texture_env_dot3 */ - -#ifdef GL_EXT_texture_filter_anisotropic - -#endif /* GL_EXT_texture_filter_anisotropic */ - -#ifdef GL_EXT_texture_integer - -static GLboolean _glewInit_GL_EXT_texture_integer (GLEW_CONTEXT_ARG_DEF_INIT) -{ - GLboolean r = GL_FALSE; - - r = ((glClearColorIiEXT = (PFNGLCLEARCOLORIIEXTPROC)glewGetProcAddress((const GLubyte*)"glClearColorIiEXT")) == NULL) || r; - r = ((glClearColorIuiEXT = (PFNGLCLEARCOLORIUIEXTPROC)glewGetProcAddress((const GLubyte*)"glClearColorIuiEXT")) == NULL) || r; - r = ((glGetTexParameterIivEXT = (PFNGLGETTEXPARAMETERIIVEXTPROC)glewGetProcAddress((const GLubyte*)"glGetTexParameterIivEXT")) == NULL) || r; - r = ((glGetTexParameterIuivEXT = (PFNGLGETTEXPARAMETERIUIVEXTPROC)glewGetProcAddress((const GLubyte*)"glGetTexParameterIuivEXT")) == NULL) || r; - r = ((glTexParameterIivEXT = (PFNGLTEXPARAMETERIIVEXTPROC)glewGetProcAddress((const GLubyte*)"glTexParameterIivEXT")) == NULL) || r; - r = ((glTexParameterIuivEXT = (PFNGLTEXPARAMETERIUIVEXTPROC)glewGetProcAddress((const GLubyte*)"glTexParameterIuivEXT")) == NULL) || r; - - return r; -} - -#endif /* GL_EXT_texture_integer */ - -#ifdef GL_EXT_texture_lod_bias - -#endif /* GL_EXT_texture_lod_bias */ - -#ifdef GL_EXT_texture_mirror_clamp - -#endif /* GL_EXT_texture_mirror_clamp */ - -#ifdef GL_EXT_texture_object - -static GLboolean _glewInit_GL_EXT_texture_object (GLEW_CONTEXT_ARG_DEF_INIT) -{ - GLboolean r = GL_FALSE; - - r = ((glAreTexturesResidentEXT = (PFNGLARETEXTURESRESIDENTEXTPROC)glewGetProcAddress((const GLubyte*)"glAreTexturesResidentEXT")) == NULL) || r; - r = ((glBindTextureEXT = (PFNGLBINDTEXTUREEXTPROC)glewGetProcAddress((const GLubyte*)"glBindTextureEXT")) == NULL) || r; - r = ((glDeleteTexturesEXT = (PFNGLDELETETEXTURESEXTPROC)glewGetProcAddress((const GLubyte*)"glDeleteTexturesEXT")) == NULL) || r; - r = ((glGenTexturesEXT = (PFNGLGENTEXTURESEXTPROC)glewGetProcAddress((const GLubyte*)"glGenTexturesEXT")) == NULL) || r; - r = ((glIsTextureEXT = (PFNGLISTEXTUREEXTPROC)glewGetProcAddress((const GLubyte*)"glIsTextureEXT")) == NULL) || r; - r = ((glPrioritizeTexturesEXT = (PFNGLPRIORITIZETEXTURESEXTPROC)glewGetProcAddress((const GLubyte*)"glPrioritizeTexturesEXT")) == NULL) || r; - - return r; -} - -#endif /* GL_EXT_texture_object */ - -#ifdef GL_EXT_texture_perturb_normal - -static GLboolean _glewInit_GL_EXT_texture_perturb_normal (GLEW_CONTEXT_ARG_DEF_INIT) -{ - GLboolean r = GL_FALSE; - - r = ((glTextureNormalEXT = (PFNGLTEXTURENORMALEXTPROC)glewGetProcAddress((const GLubyte*)"glTextureNormalEXT")) == NULL) || r; - - return r; -} - -#endif /* GL_EXT_texture_perturb_normal */ - -#ifdef GL_EXT_texture_rectangle - -#endif /* GL_EXT_texture_rectangle */ - -#ifdef GL_EXT_texture_sRGB - -#endif /* GL_EXT_texture_sRGB */ - -#ifdef GL_EXT_texture_shared_exponent - -#endif /* GL_EXT_texture_shared_exponent */ - -#ifdef GL_EXT_texture_swizzle - -#endif /* GL_EXT_texture_swizzle */ - -#ifdef GL_EXT_timer_query - -static GLboolean _glewInit_GL_EXT_timer_query (GLEW_CONTEXT_ARG_DEF_INIT) -{ - GLboolean r = GL_FALSE; - -// r = ((glGetQueryObjecti64vEXT = (PFNGLGETQUERYOBJECTI64VEXTPROC)glewGetProcAddress((const GLubyte*)"glGetQueryObjecti64vEXT")) == NULL) || r; -// r = ((glGetQueryObjectui64vEXT = (PFNGLGETQUERYOBJECTUI64VEXTPROC)glewGetProcAddress((const GLubyte*)"glGetQueryObjectui64vEXT")) == NULL) || r; - - return r; -} - -#endif /* GL_EXT_timer_query */ - -#ifdef GL_EXT_transform_feedback - -static GLboolean _glewInit_GL_EXT_transform_feedback (GLEW_CONTEXT_ARG_DEF_INIT) -{ - GLboolean r = GL_FALSE; - - r = ((glBeginTransformFeedbackEXT = (PFNGLBEGINTRANSFORMFEEDBACKEXTPROC)glewGetProcAddress((const GLubyte*)"glBeginTransformFeedbackEXT")) == NULL) || r; - r = ((glBindBufferBaseEXT = (PFNGLBINDBUFFERBASEEXTPROC)glewGetProcAddress((const GLubyte*)"glBindBufferBaseEXT")) == NULL) || r; - r = ((glBindBufferOffsetEXT = (PFNGLBINDBUFFEROFFSETEXTPROC)glewGetProcAddress((const GLubyte*)"glBindBufferOffsetEXT")) == NULL) || r; - r = ((glBindBufferRangeEXT = (PFNGLBINDBUFFERRANGEEXTPROC)glewGetProcAddress((const GLubyte*)"glBindBufferRangeEXT")) == NULL) || r; - r = ((glEndTransformFeedbackEXT = (PFNGLENDTRANSFORMFEEDBACKEXTPROC)glewGetProcAddress((const GLubyte*)"glEndTransformFeedbackEXT")) == NULL) || r; - r = ((glGetTransformFeedbackVaryingEXT = (PFNGLGETTRANSFORMFEEDBACKVARYINGEXTPROC)glewGetProcAddress((const GLubyte*)"glGetTransformFeedbackVaryingEXT")) == NULL) || r; - r = ((glTransformFeedbackVaryingsEXT = (PFNGLTRANSFORMFEEDBACKVARYINGSEXTPROC)glewGetProcAddress((const GLubyte*)"glTransformFeedbackVaryingsEXT")) == NULL) || r; - - return r; -} - -#endif /* GL_EXT_transform_feedback */ - -#ifdef GL_EXT_vertex_array - -static GLboolean _glewInit_GL_EXT_vertex_array (GLEW_CONTEXT_ARG_DEF_INIT) -{ - GLboolean r = GL_FALSE; - - r = ((glArrayElementEXT = (PFNGLARRAYELEMENTEXTPROC)glewGetProcAddress((const GLubyte*)"glArrayElementEXT")) == NULL) || r; - r = ((glColorPointerEXT = (PFNGLCOLORPOINTEREXTPROC)glewGetProcAddress((const GLubyte*)"glColorPointerEXT")) == NULL) || r; - r = ((glDrawArraysEXT = (PFNGLDRAWARRAYSEXTPROC)glewGetProcAddress((const GLubyte*)"glDrawArraysEXT")) == NULL) || r; - r = ((glEdgeFlagPointerEXT = (PFNGLEDGEFLAGPOINTEREXTPROC)glewGetProcAddress((const GLubyte*)"glEdgeFlagPointerEXT")) == NULL) || r; - r = ((glGetPointervEXT = (PFNGLGETPOINTERVEXTPROC)glewGetProcAddress((const GLubyte*)"glGetPointervEXT")) == NULL) || r; - r = ((glIndexPointerEXT = (PFNGLINDEXPOINTEREXTPROC)glewGetProcAddress((const GLubyte*)"glIndexPointerEXT")) == NULL) || r; - r = ((glNormalPointerEXT = (PFNGLNORMALPOINTEREXTPROC)glewGetProcAddress((const GLubyte*)"glNormalPointerEXT")) == NULL) || r; - r = ((glTexCoordPointerEXT = (PFNGLTEXCOORDPOINTEREXTPROC)glewGetProcAddress((const GLubyte*)"glTexCoordPointerEXT")) == NULL) || r; - r = ((glVertexPointerEXT = (PFNGLVERTEXPOINTEREXTPROC)glewGetProcAddress((const GLubyte*)"glVertexPointerEXT")) == NULL) || r; - - return r; -} - -#endif /* GL_EXT_vertex_array */ - -#ifdef GL_EXT_vertex_array_bgra - -#endif /* GL_EXT_vertex_array_bgra */ - -#ifdef GL_EXT_vertex_shader - -static GLboolean _glewInit_GL_EXT_vertex_shader (GLEW_CONTEXT_ARG_DEF_INIT) -{ - GLboolean r = GL_FALSE; - - r = ((glBeginVertexShaderEXT = (PFNGLBEGINVERTEXSHADEREXTPROC)glewGetProcAddress((const GLubyte*)"glBeginVertexShaderEXT")) == NULL) || r; - r = ((glBindLightParameterEXT = (PFNGLBINDLIGHTPARAMETEREXTPROC)glewGetProcAddress((const GLubyte*)"glBindLightParameterEXT")) == NULL) || r; - r = ((glBindMaterialParameterEXT = (PFNGLBINDMATERIALPARAMETEREXTPROC)glewGetProcAddress((const GLubyte*)"glBindMaterialParameterEXT")) == NULL) || r; - r = ((glBindParameterEXT = (PFNGLBINDPARAMETEREXTPROC)glewGetProcAddress((const GLubyte*)"glBindParameterEXT")) == NULL) || r; - r = ((glBindTexGenParameterEXT = (PFNGLBINDTEXGENPARAMETEREXTPROC)glewGetProcAddress((const GLubyte*)"glBindTexGenParameterEXT")) == NULL) || r; - r = ((glBindTextureUnitParameterEXT = (PFNGLBINDTEXTUREUNITPARAMETEREXTPROC)glewGetProcAddress((const GLubyte*)"glBindTextureUnitParameterEXT")) == NULL) || r; - r = ((glBindVertexShaderEXT = (PFNGLBINDVERTEXSHADEREXTPROC)glewGetProcAddress((const GLubyte*)"glBindVertexShaderEXT")) == NULL) || r; - r = ((glDeleteVertexShaderEXT = (PFNGLDELETEVERTEXSHADEREXTPROC)glewGetProcAddress((const GLubyte*)"glDeleteVertexShaderEXT")) == NULL) || r; - r = ((glDisableVariantClientStateEXT = (PFNGLDISABLEVARIANTCLIENTSTATEEXTPROC)glewGetProcAddress((const GLubyte*)"glDisableVariantClientStateEXT")) == NULL) || r; - r = ((glEnableVariantClientStateEXT = (PFNGLENABLEVARIANTCLIENTSTATEEXTPROC)glewGetProcAddress((const GLubyte*)"glEnableVariantClientStateEXT")) == NULL) || r; - r = ((glEndVertexShaderEXT = (PFNGLENDVERTEXSHADEREXTPROC)glewGetProcAddress((const GLubyte*)"glEndVertexShaderEXT")) == NULL) || r; - r = ((glExtractComponentEXT = (PFNGLEXTRACTCOMPONENTEXTPROC)glewGetProcAddress((const GLubyte*)"glExtractComponentEXT")) == NULL) || r; - r = ((glGenSymbolsEXT = (PFNGLGENSYMBOLSEXTPROC)glewGetProcAddress((const GLubyte*)"glGenSymbolsEXT")) == NULL) || r; - r = ((glGenVertexShadersEXT = (PFNGLGENVERTEXSHADERSEXTPROC)glewGetProcAddress((const GLubyte*)"glGenVertexShadersEXT")) == NULL) || r; - r = ((glGetInvariantBooleanvEXT = (PFNGLGETINVARIANTBOOLEANVEXTPROC)glewGetProcAddress((const GLubyte*)"glGetInvariantBooleanvEXT")) == NULL) || r; - r = ((glGetInvariantFloatvEXT = (PFNGLGETINVARIANTFLOATVEXTPROC)glewGetProcAddress((const GLubyte*)"glGetInvariantFloatvEXT")) == NULL) || r; - r = ((glGetInvariantIntegervEXT = (PFNGLGETINVARIANTINTEGERVEXTPROC)glewGetProcAddress((const GLubyte*)"glGetInvariantIntegervEXT")) == NULL) || r; - r = ((glGetLocalConstantBooleanvEXT = (PFNGLGETLOCALCONSTANTBOOLEANVEXTPROC)glewGetProcAddress((const GLubyte*)"glGetLocalConstantBooleanvEXT")) == NULL) || r; - r = ((glGetLocalConstantFloatvEXT = (PFNGLGETLOCALCONSTANTFLOATVEXTPROC)glewGetProcAddress((const GLubyte*)"glGetLocalConstantFloatvEXT")) == NULL) || r; - r = ((glGetLocalConstantIntegervEXT = (PFNGLGETLOCALCONSTANTINTEGERVEXTPROC)glewGetProcAddress((const GLubyte*)"glGetLocalConstantIntegervEXT")) == NULL) || r; - r = ((glGetVariantBooleanvEXT = (PFNGLGETVARIANTBOOLEANVEXTPROC)glewGetProcAddress((const GLubyte*)"glGetVariantBooleanvEXT")) == NULL) || r; - r = ((glGetVariantFloatvEXT = (PFNGLGETVARIANTFLOATVEXTPROC)glewGetProcAddress((const GLubyte*)"glGetVariantFloatvEXT")) == NULL) || r; - r = ((glGetVariantIntegervEXT = (PFNGLGETVARIANTINTEGERVEXTPROC)glewGetProcAddress((const GLubyte*)"glGetVariantIntegervEXT")) == NULL) || r; - r = ((glGetVariantPointervEXT = (PFNGLGETVARIANTPOINTERVEXTPROC)glewGetProcAddress((const GLubyte*)"glGetVariantPointervEXT")) == NULL) || r; - r = ((glInsertComponentEXT = (PFNGLINSERTCOMPONENTEXTPROC)glewGetProcAddress((const GLubyte*)"glInsertComponentEXT")) == NULL) || r; - r = ((glIsVariantEnabledEXT = (PFNGLISVARIANTENABLEDEXTPROC)glewGetProcAddress((const GLubyte*)"glIsVariantEnabledEXT")) == NULL) || r; - r = ((glSetInvariantEXT = (PFNGLSETINVARIANTEXTPROC)glewGetProcAddress((const GLubyte*)"glSetInvariantEXT")) == NULL) || r; - r = ((glSetLocalConstantEXT = (PFNGLSETLOCALCONSTANTEXTPROC)glewGetProcAddress((const GLubyte*)"glSetLocalConstantEXT")) == NULL) || r; - r = ((glShaderOp1EXT = (PFNGLSHADEROP1EXTPROC)glewGetProcAddress((const GLubyte*)"glShaderOp1EXT")) == NULL) || r; - r = ((glShaderOp2EXT = (PFNGLSHADEROP2EXTPROC)glewGetProcAddress((const GLubyte*)"glShaderOp2EXT")) == NULL) || r; - r = ((glShaderOp3EXT = (PFNGLSHADEROP3EXTPROC)glewGetProcAddress((const GLubyte*)"glShaderOp3EXT")) == NULL) || r; - r = ((glSwizzleEXT = (PFNGLSWIZZLEEXTPROC)glewGetProcAddress((const GLubyte*)"glSwizzleEXT")) == NULL) || r; - r = ((glVariantPointerEXT = (PFNGLVARIANTPOINTEREXTPROC)glewGetProcAddress((const GLubyte*)"glVariantPointerEXT")) == NULL) || r; - r = ((glVariantbvEXT = (PFNGLVARIANTBVEXTPROC)glewGetProcAddress((const GLubyte*)"glVariantbvEXT")) == NULL) || r; - r = ((glVariantdvEXT = (PFNGLVARIANTDVEXTPROC)glewGetProcAddress((const GLubyte*)"glVariantdvEXT")) == NULL) || r; - r = ((glVariantfvEXT = (PFNGLVARIANTFVEXTPROC)glewGetProcAddress((const GLubyte*)"glVariantfvEXT")) == NULL) || r; - r = ((glVariantivEXT = (PFNGLVARIANTIVEXTPROC)glewGetProcAddress((const GLubyte*)"glVariantivEXT")) == NULL) || r; - r = ((glVariantsvEXT = (PFNGLVARIANTSVEXTPROC)glewGetProcAddress((const GLubyte*)"glVariantsvEXT")) == NULL) || r; - r = ((glVariantubvEXT = (PFNGLVARIANTUBVEXTPROC)glewGetProcAddress((const GLubyte*)"glVariantubvEXT")) == NULL) || r; - r = ((glVariantuivEXT = (PFNGLVARIANTUIVEXTPROC)glewGetProcAddress((const GLubyte*)"glVariantuivEXT")) == NULL) || r; - r = ((glVariantusvEXT = (PFNGLVARIANTUSVEXTPROC)glewGetProcAddress((const GLubyte*)"glVariantusvEXT")) == NULL) || r; - r = ((glWriteMaskEXT = (PFNGLWRITEMASKEXTPROC)glewGetProcAddress((const GLubyte*)"glWriteMaskEXT")) == NULL) || r; - - return r; -} - -#endif /* GL_EXT_vertex_shader */ - -#ifdef GL_EXT_vertex_weighting - -static GLboolean _glewInit_GL_EXT_vertex_weighting (GLEW_CONTEXT_ARG_DEF_INIT) -{ - GLboolean r = GL_FALSE; - - r = ((glVertexWeightPointerEXT = (PFNGLVERTEXWEIGHTPOINTEREXTPROC)glewGetProcAddress((const GLubyte*)"glVertexWeightPointerEXT")) == NULL) || r; - r = ((glVertexWeightfEXT = (PFNGLVERTEXWEIGHTFEXTPROC)glewGetProcAddress((const GLubyte*)"glVertexWeightfEXT")) == NULL) || r; - r = ((glVertexWeightfvEXT = (PFNGLVERTEXWEIGHTFVEXTPROC)glewGetProcAddress((const GLubyte*)"glVertexWeightfvEXT")) == NULL) || r; - - return r; -} - -#endif /* GL_EXT_vertex_weighting */ - -#ifdef GL_GREMEDY_frame_terminator - -static GLboolean _glewInit_GL_GREMEDY_frame_terminator (GLEW_CONTEXT_ARG_DEF_INIT) -{ - GLboolean r = GL_FALSE; - - r = ((glFrameTerminatorGREMEDY = (PFNGLFRAMETERMINATORGREMEDYPROC)glewGetProcAddress((const GLubyte*)"glFrameTerminatorGREMEDY")) == NULL) || r; - - return r; -} - -#endif /* GL_GREMEDY_frame_terminator */ - -#ifdef GL_GREMEDY_string_marker - -static GLboolean _glewInit_GL_GREMEDY_string_marker (GLEW_CONTEXT_ARG_DEF_INIT) -{ - GLboolean r = GL_FALSE; - - r = ((glStringMarkerGREMEDY = (PFNGLSTRINGMARKERGREMEDYPROC)glewGetProcAddress((const GLubyte*)"glStringMarkerGREMEDY")) == NULL) || r; - - return r; -} - -#endif /* GL_GREMEDY_string_marker */ - -#ifdef GL_HP_convolution_border_modes - -#endif /* GL_HP_convolution_border_modes */ - -#ifdef GL_HP_image_transform - -static GLboolean _glewInit_GL_HP_image_transform (GLEW_CONTEXT_ARG_DEF_INIT) -{ - GLboolean r = GL_FALSE; - - r = ((glGetImageTransformParameterfvHP = (PFNGLGETIMAGETRANSFORMPARAMETERFVHPPROC)glewGetProcAddress((const GLubyte*)"glGetImageTransformParameterfvHP")) == NULL) || r; - r = ((glGetImageTransformParameterivHP = (PFNGLGETIMAGETRANSFORMPARAMETERIVHPPROC)glewGetProcAddress((const GLubyte*)"glGetImageTransformParameterivHP")) == NULL) || r; - r = ((glImageTransformParameterfHP = (PFNGLIMAGETRANSFORMPARAMETERFHPPROC)glewGetProcAddress((const GLubyte*)"glImageTransformParameterfHP")) == NULL) || r; - r = ((glImageTransformParameterfvHP = (PFNGLIMAGETRANSFORMPARAMETERFVHPPROC)glewGetProcAddress((const GLubyte*)"glImageTransformParameterfvHP")) == NULL) || r; - r = ((glImageTransformParameteriHP = (PFNGLIMAGETRANSFORMPARAMETERIHPPROC)glewGetProcAddress((const GLubyte*)"glImageTransformParameteriHP")) == NULL) || r; - r = ((glImageTransformParameterivHP = (PFNGLIMAGETRANSFORMPARAMETERIVHPPROC)glewGetProcAddress((const GLubyte*)"glImageTransformParameterivHP")) == NULL) || r; - - return r; -} - -#endif /* GL_HP_image_transform */ - -#ifdef GL_HP_occlusion_test - -#endif /* GL_HP_occlusion_test */ - -#ifdef GL_HP_texture_lighting - -#endif /* GL_HP_texture_lighting */ - -#ifdef GL_IBM_cull_vertex - -#endif /* GL_IBM_cull_vertex */ - -#ifdef GL_IBM_multimode_draw_arrays - -static GLboolean _glewInit_GL_IBM_multimode_draw_arrays (GLEW_CONTEXT_ARG_DEF_INIT) -{ - GLboolean r = GL_FALSE; - - r = ((glMultiModeDrawArraysIBM = (PFNGLMULTIMODEDRAWARRAYSIBMPROC)glewGetProcAddress((const GLubyte*)"glMultiModeDrawArraysIBM")) == NULL) || r; - r = ((glMultiModeDrawElementsIBM = (PFNGLMULTIMODEDRAWELEMENTSIBMPROC)glewGetProcAddress((const GLubyte*)"glMultiModeDrawElementsIBM")) == NULL) || r; - - return r; -} - -#endif /* GL_IBM_multimode_draw_arrays */ - -#ifdef GL_IBM_rasterpos_clip - -#endif /* GL_IBM_rasterpos_clip */ - -#ifdef GL_IBM_static_data - -#endif /* GL_IBM_static_data */ - -#ifdef GL_IBM_texture_mirrored_repeat - -#endif /* GL_IBM_texture_mirrored_repeat */ - -#ifdef GL_IBM_vertex_array_lists - -static GLboolean _glewInit_GL_IBM_vertex_array_lists (GLEW_CONTEXT_ARG_DEF_INIT) -{ - GLboolean r = GL_FALSE; - - r = ((glColorPointerListIBM = (PFNGLCOLORPOINTERLISTIBMPROC)glewGetProcAddress((const GLubyte*)"glColorPointerListIBM")) == NULL) || r; - r = ((glEdgeFlagPointerListIBM = (PFNGLEDGEFLAGPOINTERLISTIBMPROC)glewGetProcAddress((const GLubyte*)"glEdgeFlagPointerListIBM")) == NULL) || r; - r = ((glFogCoordPointerListIBM = (PFNGLFOGCOORDPOINTERLISTIBMPROC)glewGetProcAddress((const GLubyte*)"glFogCoordPointerListIBM")) == NULL) || r; - r = ((glIndexPointerListIBM = (PFNGLINDEXPOINTERLISTIBMPROC)glewGetProcAddress((const GLubyte*)"glIndexPointerListIBM")) == NULL) || r; - r = ((glNormalPointerListIBM = (PFNGLNORMALPOINTERLISTIBMPROC)glewGetProcAddress((const GLubyte*)"glNormalPointerListIBM")) == NULL) || r; - r = ((glSecondaryColorPointerListIBM = (PFNGLSECONDARYCOLORPOINTERLISTIBMPROC)glewGetProcAddress((const GLubyte*)"glSecondaryColorPointerListIBM")) == NULL) || r; - r = ((glTexCoordPointerListIBM = (PFNGLTEXCOORDPOINTERLISTIBMPROC)glewGetProcAddress((const GLubyte*)"glTexCoordPointerListIBM")) == NULL) || r; - r = ((glVertexPointerListIBM = (PFNGLVERTEXPOINTERLISTIBMPROC)glewGetProcAddress((const GLubyte*)"glVertexPointerListIBM")) == NULL) || r; - - return r; -} - -#endif /* GL_IBM_vertex_array_lists */ - -#ifdef GL_INGR_color_clamp - -#endif /* GL_INGR_color_clamp */ - -#ifdef GL_INGR_interlace_read - -#endif /* GL_INGR_interlace_read */ - -#ifdef GL_INTEL_parallel_arrays - -static GLboolean _glewInit_GL_INTEL_parallel_arrays (GLEW_CONTEXT_ARG_DEF_INIT) -{ - GLboolean r = GL_FALSE; - - r = ((glColorPointervINTEL = (PFNGLCOLORPOINTERVINTELPROC)glewGetProcAddress((const GLubyte*)"glColorPointervINTEL")) == NULL) || r; - r = ((glNormalPointervINTEL = (PFNGLNORMALPOINTERVINTELPROC)glewGetProcAddress((const GLubyte*)"glNormalPointervINTEL")) == NULL) || r; - r = ((glTexCoordPointervINTEL = (PFNGLTEXCOORDPOINTERVINTELPROC)glewGetProcAddress((const GLubyte*)"glTexCoordPointervINTEL")) == NULL) || r; - r = ((glVertexPointervINTEL = (PFNGLVERTEXPOINTERVINTELPROC)glewGetProcAddress((const GLubyte*)"glVertexPointervINTEL")) == NULL) || r; - - return r; -} - -#endif /* GL_INTEL_parallel_arrays */ - -#ifdef GL_INTEL_texture_scissor - -static GLboolean _glewInit_GL_INTEL_texture_scissor (GLEW_CONTEXT_ARG_DEF_INIT) -{ - GLboolean r = GL_FALSE; - - r = ((glTexScissorFuncINTEL = (PFNGLTEXSCISSORFUNCINTELPROC)glewGetProcAddress((const GLubyte*)"glTexScissorFuncINTEL")) == NULL) || r; - r = ((glTexScissorINTEL = (PFNGLTEXSCISSORINTELPROC)glewGetProcAddress((const GLubyte*)"glTexScissorINTEL")) == NULL) || r; - - return r; -} - -#endif /* GL_INTEL_texture_scissor */ - -#ifdef GL_KTX_buffer_region - -static GLboolean _glewInit_GL_KTX_buffer_region (GLEW_CONTEXT_ARG_DEF_INIT) -{ - GLboolean r = GL_FALSE; - - r = ((glBufferRegionEnabledEXT = (PFNGLBUFFERREGIONENABLEDEXTPROC)glewGetProcAddress((const GLubyte*)"glBufferRegionEnabledEXT")) == NULL) || r; - r = ((glDeleteBufferRegionEXT = (PFNGLDELETEBUFFERREGIONEXTPROC)glewGetProcAddress((const GLubyte*)"glDeleteBufferRegionEXT")) == NULL) || r; - r = ((glDrawBufferRegionEXT = (PFNGLDRAWBUFFERREGIONEXTPROC)glewGetProcAddress((const GLubyte*)"glDrawBufferRegionEXT")) == NULL) || r; - r = ((glNewBufferRegionEXT = (PFNGLNEWBUFFERREGIONEXTPROC)glewGetProcAddress((const GLubyte*)"glNewBufferRegionEXT")) == NULL) || r; - r = ((glReadBufferRegionEXT = (PFNGLREADBUFFERREGIONEXTPROC)glewGetProcAddress((const GLubyte*)"glReadBufferRegionEXT")) == NULL) || r; - - return r; -} - -#endif /* GL_KTX_buffer_region */ - -#ifdef GL_MESAX_texture_stack - -#endif /* GL_MESAX_texture_stack */ - -#ifdef GL_MESA_pack_invert - -#endif /* GL_MESA_pack_invert */ - -#ifdef GL_MESA_resize_buffers - -static GLboolean _glewInit_GL_MESA_resize_buffers (GLEW_CONTEXT_ARG_DEF_INIT) -{ - GLboolean r = GL_FALSE; - - r = ((glResizeBuffersMESA = (PFNGLRESIZEBUFFERSMESAPROC)glewGetProcAddress((const GLubyte*)"glResizeBuffersMESA")) == NULL) || r; - - return r; -} - -#endif /* GL_MESA_resize_buffers */ - -#ifdef GL_MESA_window_pos - -static GLboolean _glewInit_GL_MESA_window_pos (GLEW_CONTEXT_ARG_DEF_INIT) -{ - GLboolean r = GL_FALSE; - - r = ((glWindowPos2dMESA = (PFNGLWINDOWPOS2DMESAPROC)glewGetProcAddress((const GLubyte*)"glWindowPos2dMESA")) == NULL) || r; - r = ((glWindowPos2dvMESA = (PFNGLWINDOWPOS2DVMESAPROC)glewGetProcAddress((const GLubyte*)"glWindowPos2dvMESA")) == NULL) || r; - r = ((glWindowPos2fMESA = (PFNGLWINDOWPOS2FMESAPROC)glewGetProcAddress((const GLubyte*)"glWindowPos2fMESA")) == NULL) || r; - r = ((glWindowPos2fvMESA = (PFNGLWINDOWPOS2FVMESAPROC)glewGetProcAddress((const GLubyte*)"glWindowPos2fvMESA")) == NULL) || r; - r = ((glWindowPos2iMESA = (PFNGLWINDOWPOS2IMESAPROC)glewGetProcAddress((const GLubyte*)"glWindowPos2iMESA")) == NULL) || r; - r = ((glWindowPos2ivMESA = (PFNGLWINDOWPOS2IVMESAPROC)glewGetProcAddress((const GLubyte*)"glWindowPos2ivMESA")) == NULL) || r; - r = ((glWindowPos2sMESA = (PFNGLWINDOWPOS2SMESAPROC)glewGetProcAddress((const GLubyte*)"glWindowPos2sMESA")) == NULL) || r; - r = ((glWindowPos2svMESA = (PFNGLWINDOWPOS2SVMESAPROC)glewGetProcAddress((const GLubyte*)"glWindowPos2svMESA")) == NULL) || r; - r = ((glWindowPos3dMESA = (PFNGLWINDOWPOS3DMESAPROC)glewGetProcAddress((const GLubyte*)"glWindowPos3dMESA")) == NULL) || r; - r = ((glWindowPos3dvMESA = (PFNGLWINDOWPOS3DVMESAPROC)glewGetProcAddress((const GLubyte*)"glWindowPos3dvMESA")) == NULL) || r; - r = ((glWindowPos3fMESA = (PFNGLWINDOWPOS3FMESAPROC)glewGetProcAddress((const GLubyte*)"glWindowPos3fMESA")) == NULL) || r; - r = ((glWindowPos3fvMESA = (PFNGLWINDOWPOS3FVMESAPROC)glewGetProcAddress((const GLubyte*)"glWindowPos3fvMESA")) == NULL) || r; - r = ((glWindowPos3iMESA = (PFNGLWINDOWPOS3IMESAPROC)glewGetProcAddress((const GLubyte*)"glWindowPos3iMESA")) == NULL) || r; - r = ((glWindowPos3ivMESA = (PFNGLWINDOWPOS3IVMESAPROC)glewGetProcAddress((const GLubyte*)"glWindowPos3ivMESA")) == NULL) || r; - r = ((glWindowPos3sMESA = (PFNGLWINDOWPOS3SMESAPROC)glewGetProcAddress((const GLubyte*)"glWindowPos3sMESA")) == NULL) || r; - r = ((glWindowPos3svMESA = (PFNGLWINDOWPOS3SVMESAPROC)glewGetProcAddress((const GLubyte*)"glWindowPos3svMESA")) == NULL) || r; - r = ((glWindowPos4dMESA = (PFNGLWINDOWPOS4DMESAPROC)glewGetProcAddress((const GLubyte*)"glWindowPos4dMESA")) == NULL) || r; - r = ((glWindowPos4dvMESA = (PFNGLWINDOWPOS4DVMESAPROC)glewGetProcAddress((const GLubyte*)"glWindowPos4dvMESA")) == NULL) || r; - r = ((glWindowPos4fMESA = (PFNGLWINDOWPOS4FMESAPROC)glewGetProcAddress((const GLubyte*)"glWindowPos4fMESA")) == NULL) || r; - r = ((glWindowPos4fvMESA = (PFNGLWINDOWPOS4FVMESAPROC)glewGetProcAddress((const GLubyte*)"glWindowPos4fvMESA")) == NULL) || r; - r = ((glWindowPos4iMESA = (PFNGLWINDOWPOS4IMESAPROC)glewGetProcAddress((const GLubyte*)"glWindowPos4iMESA")) == NULL) || r; - r = ((glWindowPos4ivMESA = (PFNGLWINDOWPOS4IVMESAPROC)glewGetProcAddress((const GLubyte*)"glWindowPos4ivMESA")) == NULL) || r; - r = ((glWindowPos4sMESA = (PFNGLWINDOWPOS4SMESAPROC)glewGetProcAddress((const GLubyte*)"glWindowPos4sMESA")) == NULL) || r; - r = ((glWindowPos4svMESA = (PFNGLWINDOWPOS4SVMESAPROC)glewGetProcAddress((const GLubyte*)"glWindowPos4svMESA")) == NULL) || r; - - return r; -} - -#endif /* GL_MESA_window_pos */ - -#ifdef GL_MESA_ycbcr_texture - -#endif /* GL_MESA_ycbcr_texture */ - -#ifdef GL_NV_blend_square - -#endif /* GL_NV_blend_square */ - -#ifdef GL_NV_conditional_render - -static GLboolean _glewInit_GL_NV_conditional_render (GLEW_CONTEXT_ARG_DEF_INIT) -{ - GLboolean r = GL_FALSE; - - r = ((glBeginConditionalRenderNV = (PFNGLBEGINCONDITIONALRENDERNVPROC)glewGetProcAddress((const GLubyte*)"glBeginConditionalRenderNV")) == NULL) || r; - r = ((glEndConditionalRenderNV = (PFNGLENDCONDITIONALRENDERNVPROC)glewGetProcAddress((const GLubyte*)"glEndConditionalRenderNV")) == NULL) || r; - - return r; -} - -#endif /* GL_NV_conditional_render */ - -#ifdef GL_NV_copy_depth_to_color - -#endif /* GL_NV_copy_depth_to_color */ - -#ifdef GL_NV_depth_buffer_float - -static GLboolean _glewInit_GL_NV_depth_buffer_float (GLEW_CONTEXT_ARG_DEF_INIT) -{ - GLboolean r = GL_FALSE; - - r = ((glClearDepthdNV = (PFNGLCLEARDEPTHDNVPROC)glewGetProcAddress((const GLubyte*)"glClearDepthdNV")) == NULL) || r; - r = ((glDepthBoundsdNV = (PFNGLDEPTHBOUNDSDNVPROC)glewGetProcAddress((const GLubyte*)"glDepthBoundsdNV")) == NULL) || r; - r = ((glDepthRangedNV = (PFNGLDEPTHRANGEDNVPROC)glewGetProcAddress((const GLubyte*)"glDepthRangedNV")) == NULL) || r; - - return r; -} - -#endif /* GL_NV_depth_buffer_float */ - -#ifdef GL_NV_depth_clamp - -#endif /* GL_NV_depth_clamp */ - -#ifdef GL_NV_depth_range_unclamped - -#endif /* GL_NV_depth_range_unclamped */ - -#ifdef GL_NV_evaluators - -static GLboolean _glewInit_GL_NV_evaluators (GLEW_CONTEXT_ARG_DEF_INIT) -{ - GLboolean r = GL_FALSE; - - r = ((glEvalMapsNV = (PFNGLEVALMAPSNVPROC)glewGetProcAddress((const GLubyte*)"glEvalMapsNV")) == NULL) || r; - r = ((glGetMapAttribParameterfvNV = (PFNGLGETMAPATTRIBPARAMETERFVNVPROC)glewGetProcAddress((const GLubyte*)"glGetMapAttribParameterfvNV")) == NULL) || r; - r = ((glGetMapAttribParameterivNV = (PFNGLGETMAPATTRIBPARAMETERIVNVPROC)glewGetProcAddress((const GLubyte*)"glGetMapAttribParameterivNV")) == NULL) || r; - r = ((glGetMapControlPointsNV = (PFNGLGETMAPCONTROLPOINTSNVPROC)glewGetProcAddress((const GLubyte*)"glGetMapControlPointsNV")) == NULL) || r; - r = ((glGetMapParameterfvNV = (PFNGLGETMAPPARAMETERFVNVPROC)glewGetProcAddress((const GLubyte*)"glGetMapParameterfvNV")) == NULL) || r; - r = ((glGetMapParameterivNV = (PFNGLGETMAPPARAMETERIVNVPROC)glewGetProcAddress((const GLubyte*)"glGetMapParameterivNV")) == NULL) || r; - r = ((glMapControlPointsNV = (PFNGLMAPCONTROLPOINTSNVPROC)glewGetProcAddress((const GLubyte*)"glMapControlPointsNV")) == NULL) || r; - r = ((glMapParameterfvNV = (PFNGLMAPPARAMETERFVNVPROC)glewGetProcAddress((const GLubyte*)"glMapParameterfvNV")) == NULL) || r; - r = ((glMapParameterivNV = (PFNGLMAPPARAMETERIVNVPROC)glewGetProcAddress((const GLubyte*)"glMapParameterivNV")) == NULL) || r; - - return r; -} - -#endif /* GL_NV_evaluators */ - -#ifdef GL_NV_explicit_multisample - -static GLboolean _glewInit_GL_NV_explicit_multisample (GLEW_CONTEXT_ARG_DEF_INIT) -{ - GLboolean r = GL_FALSE; - - r = ((glGetMultisamplefvNV = (PFNGLGETMULTISAMPLEFVNVPROC)glewGetProcAddress((const GLubyte*)"glGetMultisamplefvNV")) == NULL) || r; - r = ((glSampleMaskIndexedNV = (PFNGLSAMPLEMASKINDEXEDNVPROC)glewGetProcAddress((const GLubyte*)"glSampleMaskIndexedNV")) == NULL) || r; - r = ((glTexRenderbufferNV = (PFNGLTEXRENDERBUFFERNVPROC)glewGetProcAddress((const GLubyte*)"glTexRenderbufferNV")) == NULL) || r; - - return r; -} - -#endif /* GL_NV_explicit_multisample */ - -#ifdef GL_NV_fence - -static GLboolean _glewInit_GL_NV_fence (GLEW_CONTEXT_ARG_DEF_INIT) -{ - GLboolean r = GL_FALSE; - - r = ((glDeleteFencesNV = (PFNGLDELETEFENCESNVPROC)glewGetProcAddress((const GLubyte*)"glDeleteFencesNV")) == NULL) || r; - r = ((glFinishFenceNV = (PFNGLFINISHFENCENVPROC)glewGetProcAddress((const GLubyte*)"glFinishFenceNV")) == NULL) || r; - r = ((glGenFencesNV = (PFNGLGENFENCESNVPROC)glewGetProcAddress((const GLubyte*)"glGenFencesNV")) == NULL) || r; - r = ((glGetFenceivNV = (PFNGLGETFENCEIVNVPROC)glewGetProcAddress((const GLubyte*)"glGetFenceivNV")) == NULL) || r; - r = ((glIsFenceNV = (PFNGLISFENCENVPROC)glewGetProcAddress((const GLubyte*)"glIsFenceNV")) == NULL) || r; - r = ((glSetFenceNV = (PFNGLSETFENCENVPROC)glewGetProcAddress((const GLubyte*)"glSetFenceNV")) == NULL) || r; - r = ((glTestFenceNV = (PFNGLTESTFENCENVPROC)glewGetProcAddress((const GLubyte*)"glTestFenceNV")) == NULL) || r; - - return r; -} - -#endif /* GL_NV_fence */ - -#ifdef GL_NV_float_buffer - -#endif /* GL_NV_float_buffer */ - -#ifdef GL_NV_fog_distance - -#endif /* GL_NV_fog_distance */ - -#ifdef GL_NV_fragment_program - -static GLboolean _glewInit_GL_NV_fragment_program (GLEW_CONTEXT_ARG_DEF_INIT) -{ - GLboolean r = GL_FALSE; - - r = ((glGetProgramNamedParameterdvNV = (PFNGLGETPROGRAMNAMEDPARAMETERDVNVPROC)glewGetProcAddress((const GLubyte*)"glGetProgramNamedParameterdvNV")) == NULL) || r; - r = ((glGetProgramNamedParameterfvNV = (PFNGLGETPROGRAMNAMEDPARAMETERFVNVPROC)glewGetProcAddress((const GLubyte*)"glGetProgramNamedParameterfvNV")) == NULL) || r; - r = ((glProgramNamedParameter4dNV = (PFNGLPROGRAMNAMEDPARAMETER4DNVPROC)glewGetProcAddress((const GLubyte*)"glProgramNamedParameter4dNV")) == NULL) || r; - r = ((glProgramNamedParameter4dvNV = (PFNGLPROGRAMNAMEDPARAMETER4DVNVPROC)glewGetProcAddress((const GLubyte*)"glProgramNamedParameter4dvNV")) == NULL) || r; - r = ((glProgramNamedParameter4fNV = (PFNGLPROGRAMNAMEDPARAMETER4FNVPROC)glewGetProcAddress((const GLubyte*)"glProgramNamedParameter4fNV")) == NULL) || r; - r = ((glProgramNamedParameter4fvNV = (PFNGLPROGRAMNAMEDPARAMETER4FVNVPROC)glewGetProcAddress((const GLubyte*)"glProgramNamedParameter4fvNV")) == NULL) || r; - - return r; -} - -#endif /* GL_NV_fragment_program */ - -#ifdef GL_NV_fragment_program2 - -#endif /* GL_NV_fragment_program2 */ - -#ifdef GL_NV_fragment_program4 - -#endif /* GL_NV_fragment_program4 */ - -#ifdef GL_NV_fragment_program_option - -#endif /* GL_NV_fragment_program_option */ - -#ifdef GL_NV_framebuffer_multisample_coverage - -static GLboolean _glewInit_GL_NV_framebuffer_multisample_coverage (GLEW_CONTEXT_ARG_DEF_INIT) -{ - GLboolean r = GL_FALSE; - - r = ((glRenderbufferStorageMultisampleCoverageNV = (PFNGLRENDERBUFFERSTORAGEMULTISAMPLECOVERAGENVPROC)glewGetProcAddress((const GLubyte*)"glRenderbufferStorageMultisampleCoverageNV")) == NULL) || r; - - return r; -} - -#endif /* GL_NV_framebuffer_multisample_coverage */ - -#ifdef GL_NV_geometry_program4 - -static GLboolean _glewInit_GL_NV_geometry_program4 (GLEW_CONTEXT_ARG_DEF_INIT) -{ - GLboolean r = GL_FALSE; - - r = ((glProgramVertexLimitNV = (PFNGLPROGRAMVERTEXLIMITNVPROC)glewGetProcAddress((const GLubyte*)"glProgramVertexLimitNV")) == NULL) || r; - - return r; -} - -#endif /* GL_NV_geometry_program4 */ - -#ifdef GL_NV_geometry_shader4 - -#endif /* GL_NV_geometry_shader4 */ - -#ifdef GL_NV_gpu_program4 - -static GLboolean _glewInit_GL_NV_gpu_program4 (GLEW_CONTEXT_ARG_DEF_INIT) -{ - GLboolean r = GL_FALSE; - - r = ((glProgramEnvParameterI4iNV = (PFNGLPROGRAMENVPARAMETERI4INVPROC)glewGetProcAddress((const GLubyte*)"glProgramEnvParameterI4iNV")) == NULL) || r; - r = ((glProgramEnvParameterI4ivNV = (PFNGLPROGRAMENVPARAMETERI4IVNVPROC)glewGetProcAddress((const GLubyte*)"glProgramEnvParameterI4ivNV")) == NULL) || r; - r = ((glProgramEnvParameterI4uiNV = (PFNGLPROGRAMENVPARAMETERI4UINVPROC)glewGetProcAddress((const GLubyte*)"glProgramEnvParameterI4uiNV")) == NULL) || r; - r = ((glProgramEnvParameterI4uivNV = (PFNGLPROGRAMENVPARAMETERI4UIVNVPROC)glewGetProcAddress((const GLubyte*)"glProgramEnvParameterI4uivNV")) == NULL) || r; - r = ((glProgramEnvParametersI4ivNV = (PFNGLPROGRAMENVPARAMETERSI4IVNVPROC)glewGetProcAddress((const GLubyte*)"glProgramEnvParametersI4ivNV")) == NULL) || r; - r = ((glProgramEnvParametersI4uivNV = (PFNGLPROGRAMENVPARAMETERSI4UIVNVPROC)glewGetProcAddress((const GLubyte*)"glProgramEnvParametersI4uivNV")) == NULL) || r; - r = ((glProgramLocalParameterI4iNV = (PFNGLPROGRAMLOCALPARAMETERI4INVPROC)glewGetProcAddress((const GLubyte*)"glProgramLocalParameterI4iNV")) == NULL) || r; - r = ((glProgramLocalParameterI4ivNV = (PFNGLPROGRAMLOCALPARAMETERI4IVNVPROC)glewGetProcAddress((const GLubyte*)"glProgramLocalParameterI4ivNV")) == NULL) || r; - r = ((glProgramLocalParameterI4uiNV = (PFNGLPROGRAMLOCALPARAMETERI4UINVPROC)glewGetProcAddress((const GLubyte*)"glProgramLocalParameterI4uiNV")) == NULL) || r; - r = ((glProgramLocalParameterI4uivNV = (PFNGLPROGRAMLOCALPARAMETERI4UIVNVPROC)glewGetProcAddress((const GLubyte*)"glProgramLocalParameterI4uivNV")) == NULL) || r; - r = ((glProgramLocalParametersI4ivNV = (PFNGLPROGRAMLOCALPARAMETERSI4IVNVPROC)glewGetProcAddress((const GLubyte*)"glProgramLocalParametersI4ivNV")) == NULL) || r; - r = ((glProgramLocalParametersI4uivNV = (PFNGLPROGRAMLOCALPARAMETERSI4UIVNVPROC)glewGetProcAddress((const GLubyte*)"glProgramLocalParametersI4uivNV")) == NULL) || r; - - return r; -} - -#endif /* GL_NV_gpu_program4 */ - -#ifdef GL_NV_half_float - -static GLboolean _glewInit_GL_NV_half_float (GLEW_CONTEXT_ARG_DEF_INIT) -{ - GLboolean r = GL_FALSE; - - r = ((glColor3hNV = (PFNGLCOLOR3HNVPROC)glewGetProcAddress((const GLubyte*)"glColor3hNV")) == NULL) || r; - r = ((glColor3hvNV = (PFNGLCOLOR3HVNVPROC)glewGetProcAddress((const GLubyte*)"glColor3hvNV")) == NULL) || r; - r = ((glColor4hNV = (PFNGLCOLOR4HNVPROC)glewGetProcAddress((const GLubyte*)"glColor4hNV")) == NULL) || r; - r = ((glColor4hvNV = (PFNGLCOLOR4HVNVPROC)glewGetProcAddress((const GLubyte*)"glColor4hvNV")) == NULL) || r; - r = ((glFogCoordhNV = (PFNGLFOGCOORDHNVPROC)glewGetProcAddress((const GLubyte*)"glFogCoordhNV")) == NULL) || r; - r = ((glFogCoordhvNV = (PFNGLFOGCOORDHVNVPROC)glewGetProcAddress((const GLubyte*)"glFogCoordhvNV")) == NULL) || r; - r = ((glMultiTexCoord1hNV = (PFNGLMULTITEXCOORD1HNVPROC)glewGetProcAddress((const GLubyte*)"glMultiTexCoord1hNV")) == NULL) || r; - r = ((glMultiTexCoord1hvNV = (PFNGLMULTITEXCOORD1HVNVPROC)glewGetProcAddress((const GLubyte*)"glMultiTexCoord1hvNV")) == NULL) || r; - r = ((glMultiTexCoord2hNV = (PFNGLMULTITEXCOORD2HNVPROC)glewGetProcAddress((const GLubyte*)"glMultiTexCoord2hNV")) == NULL) || r; - r = ((glMultiTexCoord2hvNV = (PFNGLMULTITEXCOORD2HVNVPROC)glewGetProcAddress((const GLubyte*)"glMultiTexCoord2hvNV")) == NULL) || r; - r = ((glMultiTexCoord3hNV = (PFNGLMULTITEXCOORD3HNVPROC)glewGetProcAddress((const GLubyte*)"glMultiTexCoord3hNV")) == NULL) || r; - r = ((glMultiTexCoord3hvNV = (PFNGLMULTITEXCOORD3HVNVPROC)glewGetProcAddress((const GLubyte*)"glMultiTexCoord3hvNV")) == NULL) || r; - r = ((glMultiTexCoord4hNV = (PFNGLMULTITEXCOORD4HNVPROC)glewGetProcAddress((const GLubyte*)"glMultiTexCoord4hNV")) == NULL) || r; - r = ((glMultiTexCoord4hvNV = (PFNGLMULTITEXCOORD4HVNVPROC)glewGetProcAddress((const GLubyte*)"glMultiTexCoord4hvNV")) == NULL) || r; - r = ((glNormal3hNV = (PFNGLNORMAL3HNVPROC)glewGetProcAddress((const GLubyte*)"glNormal3hNV")) == NULL) || r; - r = ((glNormal3hvNV = (PFNGLNORMAL3HVNVPROC)glewGetProcAddress((const GLubyte*)"glNormal3hvNV")) == NULL) || r; - r = ((glSecondaryColor3hNV = (PFNGLSECONDARYCOLOR3HNVPROC)glewGetProcAddress((const GLubyte*)"glSecondaryColor3hNV")) == NULL) || r; - r = ((glSecondaryColor3hvNV = (PFNGLSECONDARYCOLOR3HVNVPROC)glewGetProcAddress((const GLubyte*)"glSecondaryColor3hvNV")) == NULL) || r; - r = ((glTexCoord1hNV = (PFNGLTEXCOORD1HNVPROC)glewGetProcAddress((const GLubyte*)"glTexCoord1hNV")) == NULL) || r; - r = ((glTexCoord1hvNV = (PFNGLTEXCOORD1HVNVPROC)glewGetProcAddress((const GLubyte*)"glTexCoord1hvNV")) == NULL) || r; - r = ((glTexCoord2hNV = (PFNGLTEXCOORD2HNVPROC)glewGetProcAddress((const GLubyte*)"glTexCoord2hNV")) == NULL) || r; - r = ((glTexCoord2hvNV = (PFNGLTEXCOORD2HVNVPROC)glewGetProcAddress((const GLubyte*)"glTexCoord2hvNV")) == NULL) || r; - r = ((glTexCoord3hNV = (PFNGLTEXCOORD3HNVPROC)glewGetProcAddress((const GLubyte*)"glTexCoord3hNV")) == NULL) || r; - r = ((glTexCoord3hvNV = (PFNGLTEXCOORD3HVNVPROC)glewGetProcAddress((const GLubyte*)"glTexCoord3hvNV")) == NULL) || r; - r = ((glTexCoord4hNV = (PFNGLTEXCOORD4HNVPROC)glewGetProcAddress((const GLubyte*)"glTexCoord4hNV")) == NULL) || r; - r = ((glTexCoord4hvNV = (PFNGLTEXCOORD4HVNVPROC)glewGetProcAddress((const GLubyte*)"glTexCoord4hvNV")) == NULL) || r; - r = ((glVertex2hNV = (PFNGLVERTEX2HNVPROC)glewGetProcAddress((const GLubyte*)"glVertex2hNV")) == NULL) || r; - r = ((glVertex2hvNV = (PFNGLVERTEX2HVNVPROC)glewGetProcAddress((const GLubyte*)"glVertex2hvNV")) == NULL) || r; - r = ((glVertex3hNV = (PFNGLVERTEX3HNVPROC)glewGetProcAddress((const GLubyte*)"glVertex3hNV")) == NULL) || r; - r = ((glVertex3hvNV = (PFNGLVERTEX3HVNVPROC)glewGetProcAddress((const GLubyte*)"glVertex3hvNV")) == NULL) || r; - r = ((glVertex4hNV = (PFNGLVERTEX4HNVPROC)glewGetProcAddress((const GLubyte*)"glVertex4hNV")) == NULL) || r; - r = ((glVertex4hvNV = (PFNGLVERTEX4HVNVPROC)glewGetProcAddress((const GLubyte*)"glVertex4hvNV")) == NULL) || r; - r = ((glVertexAttrib1hNV = (PFNGLVERTEXATTRIB1HNVPROC)glewGetProcAddress((const GLubyte*)"glVertexAttrib1hNV")) == NULL) || r; - r = ((glVertexAttrib1hvNV = (PFNGLVERTEXATTRIB1HVNVPROC)glewGetProcAddress((const GLubyte*)"glVertexAttrib1hvNV")) == NULL) || r; - r = ((glVertexAttrib2hNV = (PFNGLVERTEXATTRIB2HNVPROC)glewGetProcAddress((const GLubyte*)"glVertexAttrib2hNV")) == NULL) || r; - r = ((glVertexAttrib2hvNV = (PFNGLVERTEXATTRIB2HVNVPROC)glewGetProcAddress((const GLubyte*)"glVertexAttrib2hvNV")) == NULL) || r; - r = ((glVertexAttrib3hNV = (PFNGLVERTEXATTRIB3HNVPROC)glewGetProcAddress((const GLubyte*)"glVertexAttrib3hNV")) == NULL) || r; - r = ((glVertexAttrib3hvNV = (PFNGLVERTEXATTRIB3HVNVPROC)glewGetProcAddress((const GLubyte*)"glVertexAttrib3hvNV")) == NULL) || r; - r = ((glVertexAttrib4hNV = (PFNGLVERTEXATTRIB4HNVPROC)glewGetProcAddress((const GLubyte*)"glVertexAttrib4hNV")) == NULL) || r; - r = ((glVertexAttrib4hvNV = (PFNGLVERTEXATTRIB4HVNVPROC)glewGetProcAddress((const GLubyte*)"glVertexAttrib4hvNV")) == NULL) || r; - r = ((glVertexAttribs1hvNV = (PFNGLVERTEXATTRIBS1HVNVPROC)glewGetProcAddress((const GLubyte*)"glVertexAttribs1hvNV")) == NULL) || r; - r = ((glVertexAttribs2hvNV = (PFNGLVERTEXATTRIBS2HVNVPROC)glewGetProcAddress((const GLubyte*)"glVertexAttribs2hvNV")) == NULL) || r; - r = ((glVertexAttribs3hvNV = (PFNGLVERTEXATTRIBS3HVNVPROC)glewGetProcAddress((const GLubyte*)"glVertexAttribs3hvNV")) == NULL) || r; - r = ((glVertexAttribs4hvNV = (PFNGLVERTEXATTRIBS4HVNVPROC)glewGetProcAddress((const GLubyte*)"glVertexAttribs4hvNV")) == NULL) || r; - r = ((glVertexWeighthNV = (PFNGLVERTEXWEIGHTHNVPROC)glewGetProcAddress((const GLubyte*)"glVertexWeighthNV")) == NULL) || r; - r = ((glVertexWeighthvNV = (PFNGLVERTEXWEIGHTHVNVPROC)glewGetProcAddress((const GLubyte*)"glVertexWeighthvNV")) == NULL) || r; - - return r; -} - -#endif /* GL_NV_half_float */ - -#ifdef GL_NV_light_max_exponent - -#endif /* GL_NV_light_max_exponent */ - -#ifdef GL_NV_multisample_filter_hint - -#endif /* GL_NV_multisample_filter_hint */ - -#ifdef GL_NV_occlusion_query - -static GLboolean _glewInit_GL_NV_occlusion_query (GLEW_CONTEXT_ARG_DEF_INIT) -{ - GLboolean r = GL_FALSE; - - r = ((glBeginOcclusionQueryNV = (PFNGLBEGINOCCLUSIONQUERYNVPROC)glewGetProcAddress((const GLubyte*)"glBeginOcclusionQueryNV")) == NULL) || r; - r = ((glDeleteOcclusionQueriesNV = (PFNGLDELETEOCCLUSIONQUERIESNVPROC)glewGetProcAddress((const GLubyte*)"glDeleteOcclusionQueriesNV")) == NULL) || r; - r = ((glEndOcclusionQueryNV = (PFNGLENDOCCLUSIONQUERYNVPROC)glewGetProcAddress((const GLubyte*)"glEndOcclusionQueryNV")) == NULL) || r; - r = ((glGenOcclusionQueriesNV = (PFNGLGENOCCLUSIONQUERIESNVPROC)glewGetProcAddress((const GLubyte*)"glGenOcclusionQueriesNV")) == NULL) || r; - r = ((glGetOcclusionQueryivNV = (PFNGLGETOCCLUSIONQUERYIVNVPROC)glewGetProcAddress((const GLubyte*)"glGetOcclusionQueryivNV")) == NULL) || r; - r = ((glGetOcclusionQueryuivNV = (PFNGLGETOCCLUSIONQUERYUIVNVPROC)glewGetProcAddress((const GLubyte*)"glGetOcclusionQueryuivNV")) == NULL) || r; - r = ((glIsOcclusionQueryNV = (PFNGLISOCCLUSIONQUERYNVPROC)glewGetProcAddress((const GLubyte*)"glIsOcclusionQueryNV")) == NULL) || r; - - return r; -} - -#endif /* GL_NV_occlusion_query */ - -#ifdef GL_NV_packed_depth_stencil - -#endif /* GL_NV_packed_depth_stencil */ - -#ifdef GL_NV_parameter_buffer_object - -static GLboolean _glewInit_GL_NV_parameter_buffer_object (GLEW_CONTEXT_ARG_DEF_INIT) -{ - GLboolean r = GL_FALSE; - - r = ((glProgramBufferParametersIivNV = (PFNGLPROGRAMBUFFERPARAMETERSIIVNVPROC)glewGetProcAddress((const GLubyte*)"glProgramBufferParametersIivNV")) == NULL) || r; - r = ((glProgramBufferParametersIuivNV = (PFNGLPROGRAMBUFFERPARAMETERSIUIVNVPROC)glewGetProcAddress((const GLubyte*)"glProgramBufferParametersIuivNV")) == NULL) || r; - r = ((glProgramBufferParametersfvNV = (PFNGLPROGRAMBUFFERPARAMETERSFVNVPROC)glewGetProcAddress((const GLubyte*)"glProgramBufferParametersfvNV")) == NULL) || r; - - return r; -} - -#endif /* GL_NV_parameter_buffer_object */ - -#ifdef GL_NV_pixel_data_range - -static GLboolean _glewInit_GL_NV_pixel_data_range (GLEW_CONTEXT_ARG_DEF_INIT) -{ - GLboolean r = GL_FALSE; - - r = ((glFlushPixelDataRangeNV = (PFNGLFLUSHPIXELDATARANGENVPROC)glewGetProcAddress((const GLubyte*)"glFlushPixelDataRangeNV")) == NULL) || r; - r = ((glPixelDataRangeNV = (PFNGLPIXELDATARANGENVPROC)glewGetProcAddress((const GLubyte*)"glPixelDataRangeNV")) == NULL) || r; - - return r; -} - -#endif /* GL_NV_pixel_data_range */ - -#ifdef GL_NV_point_sprite - -static GLboolean _glewInit_GL_NV_point_sprite (GLEW_CONTEXT_ARG_DEF_INIT) -{ - GLboolean r = GL_FALSE; - - r = ((glPointParameteriNV = (PFNGLPOINTPARAMETERINVPROC)glewGetProcAddress((const GLubyte*)"glPointParameteriNV")) == NULL) || r; - r = ((glPointParameterivNV = (PFNGLPOINTPARAMETERIVNVPROC)glewGetProcAddress((const GLubyte*)"glPointParameterivNV")) == NULL) || r; - - return r; -} - -#endif /* GL_NV_point_sprite */ - -#ifdef GL_NV_present_video - -static GLboolean _glewInit_GL_NV_present_video (GLEW_CONTEXT_ARG_DEF_INIT) -{ - GLboolean r = GL_FALSE; - -// r = ((glGetVideoi64vNV = (PFNGLGETVIDEOI64VNVPROC)glewGetProcAddress((const GLubyte*)"glGetVideoi64vNV")) == NULL) || r; - r = ((glGetVideoivNV = (PFNGLGETVIDEOIVNVPROC)glewGetProcAddress((const GLubyte*)"glGetVideoivNV")) == NULL) || r; -// r = ((glGetVideoui64vNV = (PFNGLGETVIDEOUI64VNVPROC)glewGetProcAddress((const GLubyte*)"glGetVideoui64vNV")) == NULL) || r; - r = ((glGetVideouivNV = (PFNGLGETVIDEOUIVNVPROC)glewGetProcAddress((const GLubyte*)"glGetVideouivNV")) == NULL) || r; -// r = ((glPresentFrameDualFillNV = (PFNGLPRESENTFRAMEDUALFILLNVPROC)glewGetProcAddress((const GLubyte*)"glPresentFrameDualFillNV")) == NULL) || r; -// r = ((glPresentFrameKeyedNV = (PFNGLPRESENTFRAMEKEYEDNVPROC)glewGetProcAddress((const GLubyte*)"glPresentFrameKeyedNV")) == NULL) || r; - r = ((glVideoParameterivNV = (PFNGLVIDEOPARAMETERIVNVPROC)glewGetProcAddress((const GLubyte*)"glVideoParameterivNV")) == NULL) || r; - - return r; -} - -#endif /* GL_NV_present_video */ - -#ifdef GL_NV_primitive_restart - -static GLboolean _glewInit_GL_NV_primitive_restart (GLEW_CONTEXT_ARG_DEF_INIT) -{ - GLboolean r = GL_FALSE; - - r = ((glPrimitiveRestartIndexNV = (PFNGLPRIMITIVERESTARTINDEXNVPROC)glewGetProcAddress((const GLubyte*)"glPrimitiveRestartIndexNV")) == NULL) || r; - r = ((glPrimitiveRestartNV = (PFNGLPRIMITIVERESTARTNVPROC)glewGetProcAddress((const GLubyte*)"glPrimitiveRestartNV")) == NULL) || r; - - return r; -} - -#endif /* GL_NV_primitive_restart */ - -#ifdef GL_NV_register_combiners - -static GLboolean _glewInit_GL_NV_register_combiners (GLEW_CONTEXT_ARG_DEF_INIT) -{ - GLboolean r = GL_FALSE; - - r = ((glCombinerInputNV = (PFNGLCOMBINERINPUTNVPROC)glewGetProcAddress((const GLubyte*)"glCombinerInputNV")) == NULL) || r; - r = ((glCombinerOutputNV = (PFNGLCOMBINEROUTPUTNVPROC)glewGetProcAddress((const GLubyte*)"glCombinerOutputNV")) == NULL) || r; - r = ((glCombinerParameterfNV = (PFNGLCOMBINERPARAMETERFNVPROC)glewGetProcAddress((const GLubyte*)"glCombinerParameterfNV")) == NULL) || r; - r = ((glCombinerParameterfvNV = (PFNGLCOMBINERPARAMETERFVNVPROC)glewGetProcAddress((const GLubyte*)"glCombinerParameterfvNV")) == NULL) || r; - r = ((glCombinerParameteriNV = (PFNGLCOMBINERPARAMETERINVPROC)glewGetProcAddress((const GLubyte*)"glCombinerParameteriNV")) == NULL) || r; - r = ((glCombinerParameterivNV = (PFNGLCOMBINERPARAMETERIVNVPROC)glewGetProcAddress((const GLubyte*)"glCombinerParameterivNV")) == NULL) || r; - r = ((glFinalCombinerInputNV = (PFNGLFINALCOMBINERINPUTNVPROC)glewGetProcAddress((const GLubyte*)"glFinalCombinerInputNV")) == NULL) || r; - r = ((glGetCombinerInputParameterfvNV = (PFNGLGETCOMBINERINPUTPARAMETERFVNVPROC)glewGetProcAddress((const GLubyte*)"glGetCombinerInputParameterfvNV")) == NULL) || r; - r = ((glGetCombinerInputParameterivNV = (PFNGLGETCOMBINERINPUTPARAMETERIVNVPROC)glewGetProcAddress((const GLubyte*)"glGetCombinerInputParameterivNV")) == NULL) || r; - r = ((glGetCombinerOutputParameterfvNV = (PFNGLGETCOMBINEROUTPUTPARAMETERFVNVPROC)glewGetProcAddress((const GLubyte*)"glGetCombinerOutputParameterfvNV")) == NULL) || r; - r = ((glGetCombinerOutputParameterivNV = (PFNGLGETCOMBINEROUTPUTPARAMETERIVNVPROC)glewGetProcAddress((const GLubyte*)"glGetCombinerOutputParameterivNV")) == NULL) || r; - r = ((glGetFinalCombinerInputParameterfvNV = (PFNGLGETFINALCOMBINERINPUTPARAMETERFVNVPROC)glewGetProcAddress((const GLubyte*)"glGetFinalCombinerInputParameterfvNV")) == NULL) || r; - r = ((glGetFinalCombinerInputParameterivNV = (PFNGLGETFINALCOMBINERINPUTPARAMETERIVNVPROC)glewGetProcAddress((const GLubyte*)"glGetFinalCombinerInputParameterivNV")) == NULL) || r; - - return r; -} - -#endif /* GL_NV_register_combiners */ - -#ifdef GL_NV_register_combiners2 - -static GLboolean _glewInit_GL_NV_register_combiners2 (GLEW_CONTEXT_ARG_DEF_INIT) -{ - GLboolean r = GL_FALSE; - - r = ((glCombinerStageParameterfvNV = (PFNGLCOMBINERSTAGEPARAMETERFVNVPROC)glewGetProcAddress((const GLubyte*)"glCombinerStageParameterfvNV")) == NULL) || r; - r = ((glGetCombinerStageParameterfvNV = (PFNGLGETCOMBINERSTAGEPARAMETERFVNVPROC)glewGetProcAddress((const GLubyte*)"glGetCombinerStageParameterfvNV")) == NULL) || r; - - return r; -} - -#endif /* GL_NV_register_combiners2 */ - -#ifdef GL_NV_texgen_emboss - -#endif /* GL_NV_texgen_emboss */ - -#ifdef GL_NV_texgen_reflection - -#endif /* GL_NV_texgen_reflection */ - -#ifdef GL_NV_texture_compression_vtc - -#endif /* GL_NV_texture_compression_vtc */ - -#ifdef GL_NV_texture_env_combine4 - -#endif /* GL_NV_texture_env_combine4 */ - -#ifdef GL_NV_texture_expand_normal - -#endif /* GL_NV_texture_expand_normal */ - -#ifdef GL_NV_texture_rectangle - -#endif /* GL_NV_texture_rectangle */ - -#ifdef GL_NV_texture_shader - -#endif /* GL_NV_texture_shader */ - -#ifdef GL_NV_texture_shader2 - -#endif /* GL_NV_texture_shader2 */ - -#ifdef GL_NV_texture_shader3 - -#endif /* GL_NV_texture_shader3 */ - -#ifdef GL_NV_transform_feedback - -static GLboolean _glewInit_GL_NV_transform_feedback (GLEW_CONTEXT_ARG_DEF_INIT) -{ - GLboolean r = GL_FALSE; - - r = ((glActiveVaryingNV = (PFNGLACTIVEVARYINGNVPROC)glewGetProcAddress((const GLubyte*)"glActiveVaryingNV")) == NULL) || r; - r = ((glBeginTransformFeedbackNV = (PFNGLBEGINTRANSFORMFEEDBACKNVPROC)glewGetProcAddress((const GLubyte*)"glBeginTransformFeedbackNV")) == NULL) || r; - r = ((glBindBufferBaseNV = (PFNGLBINDBUFFERBASENVPROC)glewGetProcAddress((const GLubyte*)"glBindBufferBaseNV")) == NULL) || r; - r = ((glBindBufferOffsetNV = (PFNGLBINDBUFFEROFFSETNVPROC)glewGetProcAddress((const GLubyte*)"glBindBufferOffsetNV")) == NULL) || r; - r = ((glBindBufferRangeNV = (PFNGLBINDBUFFERRANGENVPROC)glewGetProcAddress((const GLubyte*)"glBindBufferRangeNV")) == NULL) || r; - r = ((glEndTransformFeedbackNV = (PFNGLENDTRANSFORMFEEDBACKNVPROC)glewGetProcAddress((const GLubyte*)"glEndTransformFeedbackNV")) == NULL) || r; - r = ((glGetActiveVaryingNV = (PFNGLGETACTIVEVARYINGNVPROC)glewGetProcAddress((const GLubyte*)"glGetActiveVaryingNV")) == NULL) || r; - r = ((glGetTransformFeedbackVaryingNV = (PFNGLGETTRANSFORMFEEDBACKVARYINGNVPROC)glewGetProcAddress((const GLubyte*)"glGetTransformFeedbackVaryingNV")) == NULL) || r; - r = ((glGetVaryingLocationNV = (PFNGLGETVARYINGLOCATIONNVPROC)glewGetProcAddress((const GLubyte*)"glGetVaryingLocationNV")) == NULL) || r; - r = ((glTransformFeedbackAttribsNV = (PFNGLTRANSFORMFEEDBACKATTRIBSNVPROC)glewGetProcAddress((const GLubyte*)"glTransformFeedbackAttribsNV")) == NULL) || r; - r = ((glTransformFeedbackVaryingsNV = (PFNGLTRANSFORMFEEDBACKVARYINGSNVPROC)glewGetProcAddress((const GLubyte*)"glTransformFeedbackVaryingsNV")) == NULL) || r; - - return r; -} - -#endif /* GL_NV_transform_feedback */ - -#ifdef GL_NV_vertex_array_range - -static GLboolean _glewInit_GL_NV_vertex_array_range (GLEW_CONTEXT_ARG_DEF_INIT) -{ - GLboolean r = GL_FALSE; - - r = ((glFlushVertexArrayRangeNV = (PFNGLFLUSHVERTEXARRAYRANGENVPROC)glewGetProcAddress((const GLubyte*)"glFlushVertexArrayRangeNV")) == NULL) || r; - r = ((glVertexArrayRangeNV = (PFNGLVERTEXARRAYRANGENVPROC)glewGetProcAddress((const GLubyte*)"glVertexArrayRangeNV")) == NULL) || r; - - return r; -} - -#endif /* GL_NV_vertex_array_range */ - -#ifdef GL_NV_vertex_array_range2 - -#endif /* GL_NV_vertex_array_range2 */ - -#ifdef GL_NV_vertex_program - -static GLboolean _glewInit_GL_NV_vertex_program (GLEW_CONTEXT_ARG_DEF_INIT) -{ - GLboolean r = GL_FALSE; - - r = ((glAreProgramsResidentNV = (PFNGLAREPROGRAMSRESIDENTNVPROC)glewGetProcAddress((const GLubyte*)"glAreProgramsResidentNV")) == NULL) || r; - r = ((glBindProgramNV = (PFNGLBINDPROGRAMNVPROC)glewGetProcAddress((const GLubyte*)"glBindProgramNV")) == NULL) || r; - r = ((glDeleteProgramsNV = (PFNGLDELETEPROGRAMSNVPROC)glewGetProcAddress((const GLubyte*)"glDeleteProgramsNV")) == NULL) || r; - r = ((glExecuteProgramNV = (PFNGLEXECUTEPROGRAMNVPROC)glewGetProcAddress((const GLubyte*)"glExecuteProgramNV")) == NULL) || r; - r = ((glGenProgramsNV = (PFNGLGENPROGRAMSNVPROC)glewGetProcAddress((const GLubyte*)"glGenProgramsNV")) == NULL) || r; - r = ((glGetProgramParameterdvNV = (PFNGLGETPROGRAMPARAMETERDVNVPROC)glewGetProcAddress((const GLubyte*)"glGetProgramParameterdvNV")) == NULL) || r; - r = ((glGetProgramParameterfvNV = (PFNGLGETPROGRAMPARAMETERFVNVPROC)glewGetProcAddress((const GLubyte*)"glGetProgramParameterfvNV")) == NULL) || r; - r = ((glGetProgramStringNV = (PFNGLGETPROGRAMSTRINGNVPROC)glewGetProcAddress((const GLubyte*)"glGetProgramStringNV")) == NULL) || r; - r = ((glGetProgramivNV = (PFNGLGETPROGRAMIVNVPROC)glewGetProcAddress((const GLubyte*)"glGetProgramivNV")) == NULL) || r; - r = ((glGetTrackMatrixivNV = (PFNGLGETTRACKMATRIXIVNVPROC)glewGetProcAddress((const GLubyte*)"glGetTrackMatrixivNV")) == NULL) || r; - r = ((glGetVertexAttribPointervNV = (PFNGLGETVERTEXATTRIBPOINTERVNVPROC)glewGetProcAddress((const GLubyte*)"glGetVertexAttribPointervNV")) == NULL) || r; - r = ((glGetVertexAttribdvNV = (PFNGLGETVERTEXATTRIBDVNVPROC)glewGetProcAddress((const GLubyte*)"glGetVertexAttribdvNV")) == NULL) || r; - r = ((glGetVertexAttribfvNV = (PFNGLGETVERTEXATTRIBFVNVPROC)glewGetProcAddress((const GLubyte*)"glGetVertexAttribfvNV")) == NULL) || r; - r = ((glGetVertexAttribivNV = (PFNGLGETVERTEXATTRIBIVNVPROC)glewGetProcAddress((const GLubyte*)"glGetVertexAttribivNV")) == NULL) || r; - r = ((glIsProgramNV = (PFNGLISPROGRAMNVPROC)glewGetProcAddress((const GLubyte*)"glIsProgramNV")) == NULL) || r; - r = ((glLoadProgramNV = (PFNGLLOADPROGRAMNVPROC)glewGetProcAddress((const GLubyte*)"glLoadProgramNV")) == NULL) || r; - r = ((glProgramParameter4dNV = (PFNGLPROGRAMPARAMETER4DNVPROC)glewGetProcAddress((const GLubyte*)"glProgramParameter4dNV")) == NULL) || r; - r = ((glProgramParameter4dvNV = (PFNGLPROGRAMPARAMETER4DVNVPROC)glewGetProcAddress((const GLubyte*)"glProgramParameter4dvNV")) == NULL) || r; - r = ((glProgramParameter4fNV = (PFNGLPROGRAMPARAMETER4FNVPROC)glewGetProcAddress((const GLubyte*)"glProgramParameter4fNV")) == NULL) || r; - r = ((glProgramParameter4fvNV = (PFNGLPROGRAMPARAMETER4FVNVPROC)glewGetProcAddress((const GLubyte*)"glProgramParameter4fvNV")) == NULL) || r; - r = ((glProgramParameters4dvNV = (PFNGLPROGRAMPARAMETERS4DVNVPROC)glewGetProcAddress((const GLubyte*)"glProgramParameters4dvNV")) == NULL) || r; - r = ((glProgramParameters4fvNV = (PFNGLPROGRAMPARAMETERS4FVNVPROC)glewGetProcAddress((const GLubyte*)"glProgramParameters4fvNV")) == NULL) || r; - r = ((glRequestResidentProgramsNV = (PFNGLREQUESTRESIDENTPROGRAMSNVPROC)glewGetProcAddress((const GLubyte*)"glRequestResidentProgramsNV")) == NULL) || r; - r = ((glTrackMatrixNV = (PFNGLTRACKMATRIXNVPROC)glewGetProcAddress((const GLubyte*)"glTrackMatrixNV")) == NULL) || r; - r = ((glVertexAttrib1dNV = (PFNGLVERTEXATTRIB1DNVPROC)glewGetProcAddress((const GLubyte*)"glVertexAttrib1dNV")) == NULL) || r; - r = ((glVertexAttrib1dvNV = (PFNGLVERTEXATTRIB1DVNVPROC)glewGetProcAddress((const GLubyte*)"glVertexAttrib1dvNV")) == NULL) || r; - r = ((glVertexAttrib1fNV = (PFNGLVERTEXATTRIB1FNVPROC)glewGetProcAddress((const GLubyte*)"glVertexAttrib1fNV")) == NULL) || r; - r = ((glVertexAttrib1fvNV = (PFNGLVERTEXATTRIB1FVNVPROC)glewGetProcAddress((const GLubyte*)"glVertexAttrib1fvNV")) == NULL) || r; - r = ((glVertexAttrib1sNV = (PFNGLVERTEXATTRIB1SNVPROC)glewGetProcAddress((const GLubyte*)"glVertexAttrib1sNV")) == NULL) || r; - r = ((glVertexAttrib1svNV = (PFNGLVERTEXATTRIB1SVNVPROC)glewGetProcAddress((const GLubyte*)"glVertexAttrib1svNV")) == NULL) || r; - r = ((glVertexAttrib2dNV = (PFNGLVERTEXATTRIB2DNVPROC)glewGetProcAddress((const GLubyte*)"glVertexAttrib2dNV")) == NULL) || r; - r = ((glVertexAttrib2dvNV = (PFNGLVERTEXATTRIB2DVNVPROC)glewGetProcAddress((const GLubyte*)"glVertexAttrib2dvNV")) == NULL) || r; - r = ((glVertexAttrib2fNV = (PFNGLVERTEXATTRIB2FNVPROC)glewGetProcAddress((const GLubyte*)"glVertexAttrib2fNV")) == NULL) || r; - r = ((glVertexAttrib2fvNV = (PFNGLVERTEXATTRIB2FVNVPROC)glewGetProcAddress((const GLubyte*)"glVertexAttrib2fvNV")) == NULL) || r; - r = ((glVertexAttrib2sNV = (PFNGLVERTEXATTRIB2SNVPROC)glewGetProcAddress((const GLubyte*)"glVertexAttrib2sNV")) == NULL) || r; - r = ((glVertexAttrib2svNV = (PFNGLVERTEXATTRIB2SVNVPROC)glewGetProcAddress((const GLubyte*)"glVertexAttrib2svNV")) == NULL) || r; - r = ((glVertexAttrib3dNV = (PFNGLVERTEXATTRIB3DNVPROC)glewGetProcAddress((const GLubyte*)"glVertexAttrib3dNV")) == NULL) || r; - r = ((glVertexAttrib3dvNV = (PFNGLVERTEXATTRIB3DVNVPROC)glewGetProcAddress((const GLubyte*)"glVertexAttrib3dvNV")) == NULL) || r; - r = ((glVertexAttrib3fNV = (PFNGLVERTEXATTRIB3FNVPROC)glewGetProcAddress((const GLubyte*)"glVertexAttrib3fNV")) == NULL) || r; - r = ((glVertexAttrib3fvNV = (PFNGLVERTEXATTRIB3FVNVPROC)glewGetProcAddress((const GLubyte*)"glVertexAttrib3fvNV")) == NULL) || r; - r = ((glVertexAttrib3sNV = (PFNGLVERTEXATTRIB3SNVPROC)glewGetProcAddress((const GLubyte*)"glVertexAttrib3sNV")) == NULL) || r; - r = ((glVertexAttrib3svNV = (PFNGLVERTEXATTRIB3SVNVPROC)glewGetProcAddress((const GLubyte*)"glVertexAttrib3svNV")) == NULL) || r; - r = ((glVertexAttrib4dNV = (PFNGLVERTEXATTRIB4DNVPROC)glewGetProcAddress((const GLubyte*)"glVertexAttrib4dNV")) == NULL) || r; - r = ((glVertexAttrib4dvNV = (PFNGLVERTEXATTRIB4DVNVPROC)glewGetProcAddress((const GLubyte*)"glVertexAttrib4dvNV")) == NULL) || r; - r = ((glVertexAttrib4fNV = (PFNGLVERTEXATTRIB4FNVPROC)glewGetProcAddress((const GLubyte*)"glVertexAttrib4fNV")) == NULL) || r; - r = ((glVertexAttrib4fvNV = (PFNGLVERTEXATTRIB4FVNVPROC)glewGetProcAddress((const GLubyte*)"glVertexAttrib4fvNV")) == NULL) || r; - r = ((glVertexAttrib4sNV = (PFNGLVERTEXATTRIB4SNVPROC)glewGetProcAddress((const GLubyte*)"glVertexAttrib4sNV")) == NULL) || r; - r = ((glVertexAttrib4svNV = (PFNGLVERTEXATTRIB4SVNVPROC)glewGetProcAddress((const GLubyte*)"glVertexAttrib4svNV")) == NULL) || r; - r = ((glVertexAttrib4ubNV = (PFNGLVERTEXATTRIB4UBNVPROC)glewGetProcAddress((const GLubyte*)"glVertexAttrib4ubNV")) == NULL) || r; - r = ((glVertexAttrib4ubvNV = (PFNGLVERTEXATTRIB4UBVNVPROC)glewGetProcAddress((const GLubyte*)"glVertexAttrib4ubvNV")) == NULL) || r; - r = ((glVertexAttribPointerNV = (PFNGLVERTEXATTRIBPOINTERNVPROC)glewGetProcAddress((const GLubyte*)"glVertexAttribPointerNV")) == NULL) || r; - r = ((glVertexAttribs1dvNV = (PFNGLVERTEXATTRIBS1DVNVPROC)glewGetProcAddress((const GLubyte*)"glVertexAttribs1dvNV")) == NULL) || r; - r = ((glVertexAttribs1fvNV = (PFNGLVERTEXATTRIBS1FVNVPROC)glewGetProcAddress((const GLubyte*)"glVertexAttribs1fvNV")) == NULL) || r; - r = ((glVertexAttribs1svNV = (PFNGLVERTEXATTRIBS1SVNVPROC)glewGetProcAddress((const GLubyte*)"glVertexAttribs1svNV")) == NULL) || r; - r = ((glVertexAttribs2dvNV = (PFNGLVERTEXATTRIBS2DVNVPROC)glewGetProcAddress((const GLubyte*)"glVertexAttribs2dvNV")) == NULL) || r; - r = ((glVertexAttribs2fvNV = (PFNGLVERTEXATTRIBS2FVNVPROC)glewGetProcAddress((const GLubyte*)"glVertexAttribs2fvNV")) == NULL) || r; - r = ((glVertexAttribs2svNV = (PFNGLVERTEXATTRIBS2SVNVPROC)glewGetProcAddress((const GLubyte*)"glVertexAttribs2svNV")) == NULL) || r; - r = ((glVertexAttribs3dvNV = (PFNGLVERTEXATTRIBS3DVNVPROC)glewGetProcAddress((const GLubyte*)"glVertexAttribs3dvNV")) == NULL) || r; - r = ((glVertexAttribs3fvNV = (PFNGLVERTEXATTRIBS3FVNVPROC)glewGetProcAddress((const GLubyte*)"glVertexAttribs3fvNV")) == NULL) || r; - r = ((glVertexAttribs3svNV = (PFNGLVERTEXATTRIBS3SVNVPROC)glewGetProcAddress((const GLubyte*)"glVertexAttribs3svNV")) == NULL) || r; - r = ((glVertexAttribs4dvNV = (PFNGLVERTEXATTRIBS4DVNVPROC)glewGetProcAddress((const GLubyte*)"glVertexAttribs4dvNV")) == NULL) || r; - r = ((glVertexAttribs4fvNV = (PFNGLVERTEXATTRIBS4FVNVPROC)glewGetProcAddress((const GLubyte*)"glVertexAttribs4fvNV")) == NULL) || r; - r = ((glVertexAttribs4svNV = (PFNGLVERTEXATTRIBS4SVNVPROC)glewGetProcAddress((const GLubyte*)"glVertexAttribs4svNV")) == NULL) || r; - r = ((glVertexAttribs4ubvNV = (PFNGLVERTEXATTRIBS4UBVNVPROC)glewGetProcAddress((const GLubyte*)"glVertexAttribs4ubvNV")) == NULL) || r; - - return r; -} - -#endif /* GL_NV_vertex_program */ - -#ifdef GL_NV_vertex_program1_1 - -#endif /* GL_NV_vertex_program1_1 */ - -#ifdef GL_NV_vertex_program2 - -#endif /* GL_NV_vertex_program2 */ - -#ifdef GL_NV_vertex_program2_option - -#endif /* GL_NV_vertex_program2_option */ - -#ifdef GL_NV_vertex_program3 - -#endif /* GL_NV_vertex_program3 */ - -#ifdef GL_NV_vertex_program4 - -#endif /* GL_NV_vertex_program4 */ - -#ifdef GL_OES_byte_coordinates - -#endif /* GL_OES_byte_coordinates */ - -#ifdef GL_OES_compressed_paletted_texture - -#endif /* GL_OES_compressed_paletted_texture */ - -#ifdef GL_OES_read_format - -#endif /* GL_OES_read_format */ - -#ifdef GL_OES_single_precision - -static GLboolean _glewInit_GL_OES_single_precision (GLEW_CONTEXT_ARG_DEF_INIT) -{ - GLboolean r = GL_FALSE; - - r = ((glClearDepthfOES = (PFNGLCLEARDEPTHFOESPROC)glewGetProcAddress((const GLubyte*)"glClearDepthfOES")) == NULL) || r; - r = ((glClipPlanefOES = (PFNGLCLIPPLANEFOESPROC)glewGetProcAddress((const GLubyte*)"glClipPlanefOES")) == NULL) || r; - r = ((glDepthRangefOES = (PFNGLDEPTHRANGEFOESPROC)glewGetProcAddress((const GLubyte*)"glDepthRangefOES")) == NULL) || r; - r = ((glFrustumfOES = (PFNGLFRUSTUMFOESPROC)glewGetProcAddress((const GLubyte*)"glFrustumfOES")) == NULL) || r; - r = ((glGetClipPlanefOES = (PFNGLGETCLIPPLANEFOESPROC)glewGetProcAddress((const GLubyte*)"glGetClipPlanefOES")) == NULL) || r; - r = ((glOrthofOES = (PFNGLORTHOFOESPROC)glewGetProcAddress((const GLubyte*)"glOrthofOES")) == NULL) || r; - - return r; -} - -#endif /* GL_OES_single_precision */ - -#ifdef GL_OML_interlace - -#endif /* GL_OML_interlace */ - -#ifdef GL_OML_resample - -#endif /* GL_OML_resample */ - -#ifdef GL_OML_subsample - -#endif /* GL_OML_subsample */ - -#ifdef GL_PGI_misc_hints - -#endif /* GL_PGI_misc_hints */ - -#ifdef GL_PGI_vertex_hints - -#endif /* GL_PGI_vertex_hints */ - -#ifdef GL_REND_screen_coordinates - -#endif /* GL_REND_screen_coordinates */ - -#ifdef GL_S3_s3tc - -#endif /* GL_S3_s3tc */ - -#ifdef GL_SGIS_color_range - -#endif /* GL_SGIS_color_range */ - -#ifdef GL_SGIS_detail_texture - -static GLboolean _glewInit_GL_SGIS_detail_texture (GLEW_CONTEXT_ARG_DEF_INIT) -{ - GLboolean r = GL_FALSE; - - r = ((glDetailTexFuncSGIS = (PFNGLDETAILTEXFUNCSGISPROC)glewGetProcAddress((const GLubyte*)"glDetailTexFuncSGIS")) == NULL) || r; - r = ((glGetDetailTexFuncSGIS = (PFNGLGETDETAILTEXFUNCSGISPROC)glewGetProcAddress((const GLubyte*)"glGetDetailTexFuncSGIS")) == NULL) || r; - - return r; -} - -#endif /* GL_SGIS_detail_texture */ - -#ifdef GL_SGIS_fog_function - -static GLboolean _glewInit_GL_SGIS_fog_function (GLEW_CONTEXT_ARG_DEF_INIT) -{ - GLboolean r = GL_FALSE; - - r = ((glFogFuncSGIS = (PFNGLFOGFUNCSGISPROC)glewGetProcAddress((const GLubyte*)"glFogFuncSGIS")) == NULL) || r; - r = ((glGetFogFuncSGIS = (PFNGLGETFOGFUNCSGISPROC)glewGetProcAddress((const GLubyte*)"glGetFogFuncSGIS")) == NULL) || r; - - return r; -} - -#endif /* GL_SGIS_fog_function */ - -#ifdef GL_SGIS_generate_mipmap - -#endif /* GL_SGIS_generate_mipmap */ - -#ifdef GL_SGIS_multisample - -static GLboolean _glewInit_GL_SGIS_multisample (GLEW_CONTEXT_ARG_DEF_INIT) -{ - GLboolean r = GL_FALSE; - - r = ((glSampleMaskSGIS = (PFNGLSAMPLEMASKSGISPROC)glewGetProcAddress((const GLubyte*)"glSampleMaskSGIS")) == NULL) || r; - r = ((glSamplePatternSGIS = (PFNGLSAMPLEPATTERNSGISPROC)glewGetProcAddress((const GLubyte*)"glSamplePatternSGIS")) == NULL) || r; - - return r; -} - -#endif /* GL_SGIS_multisample */ - -#ifdef GL_SGIS_pixel_texture - -#endif /* GL_SGIS_pixel_texture */ - -#ifdef GL_SGIS_point_line_texgen - -#endif /* GL_SGIS_point_line_texgen */ - -#ifdef GL_SGIS_sharpen_texture - -static GLboolean _glewInit_GL_SGIS_sharpen_texture (GLEW_CONTEXT_ARG_DEF_INIT) -{ - GLboolean r = GL_FALSE; - - r = ((glGetSharpenTexFuncSGIS = (PFNGLGETSHARPENTEXFUNCSGISPROC)glewGetProcAddress((const GLubyte*)"glGetSharpenTexFuncSGIS")) == NULL) || r; - r = ((glSharpenTexFuncSGIS = (PFNGLSHARPENTEXFUNCSGISPROC)glewGetProcAddress((const GLubyte*)"glSharpenTexFuncSGIS")) == NULL) || r; - - return r; -} - -#endif /* GL_SGIS_sharpen_texture */ - -#ifdef GL_SGIS_texture4D - -static GLboolean _glewInit_GL_SGIS_texture4D (GLEW_CONTEXT_ARG_DEF_INIT) -{ - GLboolean r = GL_FALSE; - - r = ((glTexImage4DSGIS = (PFNGLTEXIMAGE4DSGISPROC)glewGetProcAddress((const GLubyte*)"glTexImage4DSGIS")) == NULL) || r; - r = ((glTexSubImage4DSGIS = (PFNGLTEXSUBIMAGE4DSGISPROC)glewGetProcAddress((const GLubyte*)"glTexSubImage4DSGIS")) == NULL) || r; - - return r; -} - -#endif /* GL_SGIS_texture4D */ - -#ifdef GL_SGIS_texture_border_clamp - -#endif /* GL_SGIS_texture_border_clamp */ - -#ifdef GL_SGIS_texture_edge_clamp - -#endif /* GL_SGIS_texture_edge_clamp */ - -#ifdef GL_SGIS_texture_filter4 - -static GLboolean _glewInit_GL_SGIS_texture_filter4 (GLEW_CONTEXT_ARG_DEF_INIT) -{ - GLboolean r = GL_FALSE; - - r = ((glGetTexFilterFuncSGIS = (PFNGLGETTEXFILTERFUNCSGISPROC)glewGetProcAddress((const GLubyte*)"glGetTexFilterFuncSGIS")) == NULL) || r; - r = ((glTexFilterFuncSGIS = (PFNGLTEXFILTERFUNCSGISPROC)glewGetProcAddress((const GLubyte*)"glTexFilterFuncSGIS")) == NULL) || r; - - return r; -} - -#endif /* GL_SGIS_texture_filter4 */ - -#ifdef GL_SGIS_texture_lod - -#endif /* GL_SGIS_texture_lod */ - -#ifdef GL_SGIS_texture_select - -#endif /* GL_SGIS_texture_select */ - -#ifdef GL_SGIX_async - -static GLboolean _glewInit_GL_SGIX_async (GLEW_CONTEXT_ARG_DEF_INIT) -{ - GLboolean r = GL_FALSE; - - r = ((glAsyncMarkerSGIX = (PFNGLASYNCMARKERSGIXPROC)glewGetProcAddress((const GLubyte*)"glAsyncMarkerSGIX")) == NULL) || r; - r = ((glDeleteAsyncMarkersSGIX = (PFNGLDELETEASYNCMARKERSSGIXPROC)glewGetProcAddress((const GLubyte*)"glDeleteAsyncMarkersSGIX")) == NULL) || r; - r = ((glFinishAsyncSGIX = (PFNGLFINISHASYNCSGIXPROC)glewGetProcAddress((const GLubyte*)"glFinishAsyncSGIX")) == NULL) || r; - r = ((glGenAsyncMarkersSGIX = (PFNGLGENASYNCMARKERSSGIXPROC)glewGetProcAddress((const GLubyte*)"glGenAsyncMarkersSGIX")) == NULL) || r; - r = ((glIsAsyncMarkerSGIX = (PFNGLISASYNCMARKERSGIXPROC)glewGetProcAddress((const GLubyte*)"glIsAsyncMarkerSGIX")) == NULL) || r; - r = ((glPollAsyncSGIX = (PFNGLPOLLASYNCSGIXPROC)glewGetProcAddress((const GLubyte*)"glPollAsyncSGIX")) == NULL) || r; - - return r; -} - -#endif /* GL_SGIX_async */ - -#ifdef GL_SGIX_async_histogram - -#endif /* GL_SGIX_async_histogram */ - -#ifdef GL_SGIX_async_pixel - -#endif /* GL_SGIX_async_pixel */ - -#ifdef GL_SGIX_blend_alpha_minmax - -#endif /* GL_SGIX_blend_alpha_minmax */ - -#ifdef GL_SGIX_clipmap - -#endif /* GL_SGIX_clipmap */ - -#ifdef GL_SGIX_convolution_accuracy - -#endif /* GL_SGIX_convolution_accuracy */ - -#ifdef GL_SGIX_depth_texture - -#endif /* GL_SGIX_depth_texture */ - -#ifdef GL_SGIX_flush_raster - -static GLboolean _glewInit_GL_SGIX_flush_raster (GLEW_CONTEXT_ARG_DEF_INIT) -{ - GLboolean r = GL_FALSE; - - r = ((glFlushRasterSGIX = (PFNGLFLUSHRASTERSGIXPROC)glewGetProcAddress((const GLubyte*)"glFlushRasterSGIX")) == NULL) || r; - - return r; -} - -#endif /* GL_SGIX_flush_raster */ - -#ifdef GL_SGIX_fog_offset - -#endif /* GL_SGIX_fog_offset */ - -#ifdef GL_SGIX_fog_texture - -static GLboolean _glewInit_GL_SGIX_fog_texture (GLEW_CONTEXT_ARG_DEF_INIT) -{ - GLboolean r = GL_FALSE; - - r = ((glTextureFogSGIX = (PFNGLTEXTUREFOGSGIXPROC)glewGetProcAddress((const GLubyte*)"glTextureFogSGIX")) == NULL) || r; - - return r; -} - -#endif /* GL_SGIX_fog_texture */ - -#ifdef GL_SGIX_fragment_specular_lighting - -static GLboolean _glewInit_GL_SGIX_fragment_specular_lighting (GLEW_CONTEXT_ARG_DEF_INIT) -{ - GLboolean r = GL_FALSE; - - r = ((glFragmentColorMaterialSGIX = (PFNGLFRAGMENTCOLORMATERIALSGIXPROC)glewGetProcAddress((const GLubyte*)"glFragmentColorMaterialSGIX")) == NULL) || r; - r = ((glFragmentLightModelfSGIX = (PFNGLFRAGMENTLIGHTMODELFSGIXPROC)glewGetProcAddress((const GLubyte*)"glFragmentLightModelfSGIX")) == NULL) || r; - r = ((glFragmentLightModelfvSGIX = (PFNGLFRAGMENTLIGHTMODELFVSGIXPROC)glewGetProcAddress((const GLubyte*)"glFragmentLightModelfvSGIX")) == NULL) || r; - r = ((glFragmentLightModeliSGIX = (PFNGLFRAGMENTLIGHTMODELISGIXPROC)glewGetProcAddress((const GLubyte*)"glFragmentLightModeliSGIX")) == NULL) || r; - r = ((glFragmentLightModelivSGIX = (PFNGLFRAGMENTLIGHTMODELIVSGIXPROC)glewGetProcAddress((const GLubyte*)"glFragmentLightModelivSGIX")) == NULL) || r; - r = ((glFragmentLightfSGIX = (PFNGLFRAGMENTLIGHTFSGIXPROC)glewGetProcAddress((const GLubyte*)"glFragmentLightfSGIX")) == NULL) || r; - r = ((glFragmentLightfvSGIX = (PFNGLFRAGMENTLIGHTFVSGIXPROC)glewGetProcAddress((const GLubyte*)"glFragmentLightfvSGIX")) == NULL) || r; - r = ((glFragmentLightiSGIX = (PFNGLFRAGMENTLIGHTISGIXPROC)glewGetProcAddress((const GLubyte*)"glFragmentLightiSGIX")) == NULL) || r; - r = ((glFragmentLightivSGIX = (PFNGLFRAGMENTLIGHTIVSGIXPROC)glewGetProcAddress((const GLubyte*)"glFragmentLightivSGIX")) == NULL) || r; - r = ((glFragmentMaterialfSGIX = (PFNGLFRAGMENTMATERIALFSGIXPROC)glewGetProcAddress((const GLubyte*)"glFragmentMaterialfSGIX")) == NULL) || r; - r = ((glFragmentMaterialfvSGIX = (PFNGLFRAGMENTMATERIALFVSGIXPROC)glewGetProcAddress((const GLubyte*)"glFragmentMaterialfvSGIX")) == NULL) || r; - r = ((glFragmentMaterialiSGIX = (PFNGLFRAGMENTMATERIALISGIXPROC)glewGetProcAddress((const GLubyte*)"glFragmentMaterialiSGIX")) == NULL) || r; - r = ((glFragmentMaterialivSGIX = (PFNGLFRAGMENTMATERIALIVSGIXPROC)glewGetProcAddress((const GLubyte*)"glFragmentMaterialivSGIX")) == NULL) || r; - r = ((glGetFragmentLightfvSGIX = (PFNGLGETFRAGMENTLIGHTFVSGIXPROC)glewGetProcAddress((const GLubyte*)"glGetFragmentLightfvSGIX")) == NULL) || r; - r = ((glGetFragmentLightivSGIX = (PFNGLGETFRAGMENTLIGHTIVSGIXPROC)glewGetProcAddress((const GLubyte*)"glGetFragmentLightivSGIX")) == NULL) || r; - r = ((glGetFragmentMaterialfvSGIX = (PFNGLGETFRAGMENTMATERIALFVSGIXPROC)glewGetProcAddress((const GLubyte*)"glGetFragmentMaterialfvSGIX")) == NULL) || r; - r = ((glGetFragmentMaterialivSGIX = (PFNGLGETFRAGMENTMATERIALIVSGIXPROC)glewGetProcAddress((const GLubyte*)"glGetFragmentMaterialivSGIX")) == NULL) || r; - - return r; -} - -#endif /* GL_SGIX_fragment_specular_lighting */ - -#ifdef GL_SGIX_framezoom - -static GLboolean _glewInit_GL_SGIX_framezoom (GLEW_CONTEXT_ARG_DEF_INIT) -{ - GLboolean r = GL_FALSE; - - r = ((glFrameZoomSGIX = (PFNGLFRAMEZOOMSGIXPROC)glewGetProcAddress((const GLubyte*)"glFrameZoomSGIX")) == NULL) || r; - - return r; -} - -#endif /* GL_SGIX_framezoom */ - -#ifdef GL_SGIX_interlace - -#endif /* GL_SGIX_interlace */ - -#ifdef GL_SGIX_ir_instrument1 - -#endif /* GL_SGIX_ir_instrument1 */ - -#ifdef GL_SGIX_list_priority - -#endif /* GL_SGIX_list_priority */ - -#ifdef GL_SGIX_pixel_texture - -static GLboolean _glewInit_GL_SGIX_pixel_texture (GLEW_CONTEXT_ARG_DEF_INIT) -{ - GLboolean r = GL_FALSE; - - r = ((glPixelTexGenSGIX = (PFNGLPIXELTEXGENSGIXPROC)glewGetProcAddress((const GLubyte*)"glPixelTexGenSGIX")) == NULL) || r; - - return r; -} - -#endif /* GL_SGIX_pixel_texture */ - -#ifdef GL_SGIX_pixel_texture_bits - -#endif /* GL_SGIX_pixel_texture_bits */ - -#ifdef GL_SGIX_reference_plane - -static GLboolean _glewInit_GL_SGIX_reference_plane (GLEW_CONTEXT_ARG_DEF_INIT) -{ - GLboolean r = GL_FALSE; - - r = ((glReferencePlaneSGIX = (PFNGLREFERENCEPLANESGIXPROC)glewGetProcAddress((const GLubyte*)"glReferencePlaneSGIX")) == NULL) || r; - - return r; -} - -#endif /* GL_SGIX_reference_plane */ - -#ifdef GL_SGIX_resample - -#endif /* GL_SGIX_resample */ - -#ifdef GL_SGIX_shadow - -#endif /* GL_SGIX_shadow */ - -#ifdef GL_SGIX_shadow_ambient - -#endif /* GL_SGIX_shadow_ambient */ - -#ifdef GL_SGIX_sprite - -static GLboolean _glewInit_GL_SGIX_sprite (GLEW_CONTEXT_ARG_DEF_INIT) -{ - GLboolean r = GL_FALSE; - - r = ((glSpriteParameterfSGIX = (PFNGLSPRITEPARAMETERFSGIXPROC)glewGetProcAddress((const GLubyte*)"glSpriteParameterfSGIX")) == NULL) || r; - r = ((glSpriteParameterfvSGIX = (PFNGLSPRITEPARAMETERFVSGIXPROC)glewGetProcAddress((const GLubyte*)"glSpriteParameterfvSGIX")) == NULL) || r; - r = ((glSpriteParameteriSGIX = (PFNGLSPRITEPARAMETERISGIXPROC)glewGetProcAddress((const GLubyte*)"glSpriteParameteriSGIX")) == NULL) || r; - r = ((glSpriteParameterivSGIX = (PFNGLSPRITEPARAMETERIVSGIXPROC)glewGetProcAddress((const GLubyte*)"glSpriteParameterivSGIX")) == NULL) || r; - - return r; -} - -#endif /* GL_SGIX_sprite */ - -#ifdef GL_SGIX_tag_sample_buffer - -static GLboolean _glewInit_GL_SGIX_tag_sample_buffer (GLEW_CONTEXT_ARG_DEF_INIT) -{ - GLboolean r = GL_FALSE; - - r = ((glTagSampleBufferSGIX = (PFNGLTAGSAMPLEBUFFERSGIXPROC)glewGetProcAddress((const GLubyte*)"glTagSampleBufferSGIX")) == NULL) || r; - - return r; -} - -#endif /* GL_SGIX_tag_sample_buffer */ - -#ifdef GL_SGIX_texture_add_env - -#endif /* GL_SGIX_texture_add_env */ - -#ifdef GL_SGIX_texture_coordinate_clamp - -#endif /* GL_SGIX_texture_coordinate_clamp */ - -#ifdef GL_SGIX_texture_lod_bias - -#endif /* GL_SGIX_texture_lod_bias */ - -#ifdef GL_SGIX_texture_multi_buffer - -#endif /* GL_SGIX_texture_multi_buffer */ - -#ifdef GL_SGIX_texture_range - -#endif /* GL_SGIX_texture_range */ - -#ifdef GL_SGIX_texture_scale_bias - -#endif /* GL_SGIX_texture_scale_bias */ - -#ifdef GL_SGIX_vertex_preclip - -#endif /* GL_SGIX_vertex_preclip */ - -#ifdef GL_SGIX_vertex_preclip_hint - -#endif /* GL_SGIX_vertex_preclip_hint */ - -#ifdef GL_SGIX_ycrcb - -#endif /* GL_SGIX_ycrcb */ - -#ifdef GL_SGI_color_matrix - -#endif /* GL_SGI_color_matrix */ - -#ifdef GL_SGI_color_table - -static GLboolean _glewInit_GL_SGI_color_table (GLEW_CONTEXT_ARG_DEF_INIT) -{ - GLboolean r = GL_FALSE; - - r = ((glColorTableParameterfvSGI = (PFNGLCOLORTABLEPARAMETERFVSGIPROC)glewGetProcAddress((const GLubyte*)"glColorTableParameterfvSGI")) == NULL) || r; - r = ((glColorTableParameterivSGI = (PFNGLCOLORTABLEPARAMETERIVSGIPROC)glewGetProcAddress((const GLubyte*)"glColorTableParameterivSGI")) == NULL) || r; - r = ((glColorTableSGI = (PFNGLCOLORTABLESGIPROC)glewGetProcAddress((const GLubyte*)"glColorTableSGI")) == NULL) || r; - r = ((glCopyColorTableSGI = (PFNGLCOPYCOLORTABLESGIPROC)glewGetProcAddress((const GLubyte*)"glCopyColorTableSGI")) == NULL) || r; - r = ((glGetColorTableParameterfvSGI = (PFNGLGETCOLORTABLEPARAMETERFVSGIPROC)glewGetProcAddress((const GLubyte*)"glGetColorTableParameterfvSGI")) == NULL) || r; - r = ((glGetColorTableParameterivSGI = (PFNGLGETCOLORTABLEPARAMETERIVSGIPROC)glewGetProcAddress((const GLubyte*)"glGetColorTableParameterivSGI")) == NULL) || r; - r = ((glGetColorTableSGI = (PFNGLGETCOLORTABLESGIPROC)glewGetProcAddress((const GLubyte*)"glGetColorTableSGI")) == NULL) || r; - - return r; -} - -#endif /* GL_SGI_color_table */ - -#ifdef GL_SGI_texture_color_table - -#endif /* GL_SGI_texture_color_table */ - -#ifdef GL_SUNX_constant_data - -static GLboolean _glewInit_GL_SUNX_constant_data (GLEW_CONTEXT_ARG_DEF_INIT) -{ - GLboolean r = GL_FALSE; - - r = ((glFinishTextureSUNX = (PFNGLFINISHTEXTURESUNXPROC)glewGetProcAddress((const GLubyte*)"glFinishTextureSUNX")) == NULL) || r; - - return r; -} - -#endif /* GL_SUNX_constant_data */ - -#ifdef GL_SUN_convolution_border_modes - -#endif /* GL_SUN_convolution_border_modes */ - -#ifdef GL_SUN_global_alpha - -static GLboolean _glewInit_GL_SUN_global_alpha (GLEW_CONTEXT_ARG_DEF_INIT) -{ - GLboolean r = GL_FALSE; - - r = ((glGlobalAlphaFactorbSUN = (PFNGLGLOBALALPHAFACTORBSUNPROC)glewGetProcAddress((const GLubyte*)"glGlobalAlphaFactorbSUN")) == NULL) || r; - r = ((glGlobalAlphaFactordSUN = (PFNGLGLOBALALPHAFACTORDSUNPROC)glewGetProcAddress((const GLubyte*)"glGlobalAlphaFactordSUN")) == NULL) || r; - r = ((glGlobalAlphaFactorfSUN = (PFNGLGLOBALALPHAFACTORFSUNPROC)glewGetProcAddress((const GLubyte*)"glGlobalAlphaFactorfSUN")) == NULL) || r; - r = ((glGlobalAlphaFactoriSUN = (PFNGLGLOBALALPHAFACTORISUNPROC)glewGetProcAddress((const GLubyte*)"glGlobalAlphaFactoriSUN")) == NULL) || r; - r = ((glGlobalAlphaFactorsSUN = (PFNGLGLOBALALPHAFACTORSSUNPROC)glewGetProcAddress((const GLubyte*)"glGlobalAlphaFactorsSUN")) == NULL) || r; - r = ((glGlobalAlphaFactorubSUN = (PFNGLGLOBALALPHAFACTORUBSUNPROC)glewGetProcAddress((const GLubyte*)"glGlobalAlphaFactorubSUN")) == NULL) || r; - r = ((glGlobalAlphaFactoruiSUN = (PFNGLGLOBALALPHAFACTORUISUNPROC)glewGetProcAddress((const GLubyte*)"glGlobalAlphaFactoruiSUN")) == NULL) || r; - r = ((glGlobalAlphaFactorusSUN = (PFNGLGLOBALALPHAFACTORUSSUNPROC)glewGetProcAddress((const GLubyte*)"glGlobalAlphaFactorusSUN")) == NULL) || r; - - return r; -} - -#endif /* GL_SUN_global_alpha */ - -#ifdef GL_SUN_mesh_array - -#endif /* GL_SUN_mesh_array */ - -#ifdef GL_SUN_read_video_pixels - -static GLboolean _glewInit_GL_SUN_read_video_pixels (GLEW_CONTEXT_ARG_DEF_INIT) -{ - GLboolean r = GL_FALSE; - - r = ((glReadVideoPixelsSUN = (PFNGLREADVIDEOPIXELSSUNPROC)glewGetProcAddress((const GLubyte*)"glReadVideoPixelsSUN")) == NULL) || r; - - return r; -} - -#endif /* GL_SUN_read_video_pixels */ - -#ifdef GL_SUN_slice_accum - -#endif /* GL_SUN_slice_accum */ - -#ifdef GL_SUN_triangle_list - -static GLboolean _glewInit_GL_SUN_triangle_list (GLEW_CONTEXT_ARG_DEF_INIT) -{ - GLboolean r = GL_FALSE; - - r = ((glReplacementCodePointerSUN = (PFNGLREPLACEMENTCODEPOINTERSUNPROC)glewGetProcAddress((const GLubyte*)"glReplacementCodePointerSUN")) == NULL) || r; - r = ((glReplacementCodeubSUN = (PFNGLREPLACEMENTCODEUBSUNPROC)glewGetProcAddress((const GLubyte*)"glReplacementCodeubSUN")) == NULL) || r; - r = ((glReplacementCodeubvSUN = (PFNGLREPLACEMENTCODEUBVSUNPROC)glewGetProcAddress((const GLubyte*)"glReplacementCodeubvSUN")) == NULL) || r; - r = ((glReplacementCodeuiSUN = (PFNGLREPLACEMENTCODEUISUNPROC)glewGetProcAddress((const GLubyte*)"glReplacementCodeuiSUN")) == NULL) || r; - r = ((glReplacementCodeuivSUN = (PFNGLREPLACEMENTCODEUIVSUNPROC)glewGetProcAddress((const GLubyte*)"glReplacementCodeuivSUN")) == NULL) || r; - r = ((glReplacementCodeusSUN = (PFNGLREPLACEMENTCODEUSSUNPROC)glewGetProcAddress((const GLubyte*)"glReplacementCodeusSUN")) == NULL) || r; - r = ((glReplacementCodeusvSUN = (PFNGLREPLACEMENTCODEUSVSUNPROC)glewGetProcAddress((const GLubyte*)"glReplacementCodeusvSUN")) == NULL) || r; - - return r; -} - -#endif /* GL_SUN_triangle_list */ - -#ifdef GL_SUN_vertex - -static GLboolean _glewInit_GL_SUN_vertex (GLEW_CONTEXT_ARG_DEF_INIT) -{ - GLboolean r = GL_FALSE; - - r = ((glColor3fVertex3fSUN = (PFNGLCOLOR3FVERTEX3FSUNPROC)glewGetProcAddress((const GLubyte*)"glColor3fVertex3fSUN")) == NULL) || r; - r = ((glColor3fVertex3fvSUN = (PFNGLCOLOR3FVERTEX3FVSUNPROC)glewGetProcAddress((const GLubyte*)"glColor3fVertex3fvSUN")) == NULL) || r; - r = ((glColor4fNormal3fVertex3fSUN = (PFNGLCOLOR4FNORMAL3FVERTEX3FSUNPROC)glewGetProcAddress((const GLubyte*)"glColor4fNormal3fVertex3fSUN")) == NULL) || r; - r = ((glColor4fNormal3fVertex3fvSUN = (PFNGLCOLOR4FNORMAL3FVERTEX3FVSUNPROC)glewGetProcAddress((const GLubyte*)"glColor4fNormal3fVertex3fvSUN")) == NULL) || r; - r = ((glColor4ubVertex2fSUN = (PFNGLCOLOR4UBVERTEX2FSUNPROC)glewGetProcAddress((const GLubyte*)"glColor4ubVertex2fSUN")) == NULL) || r; - r = ((glColor4ubVertex2fvSUN = (PFNGLCOLOR4UBVERTEX2FVSUNPROC)glewGetProcAddress((const GLubyte*)"glColor4ubVertex2fvSUN")) == NULL) || r; - r = ((glColor4ubVertex3fSUN = (PFNGLCOLOR4UBVERTEX3FSUNPROC)glewGetProcAddress((const GLubyte*)"glColor4ubVertex3fSUN")) == NULL) || r; - r = ((glColor4ubVertex3fvSUN = (PFNGLCOLOR4UBVERTEX3FVSUNPROC)glewGetProcAddress((const GLubyte*)"glColor4ubVertex3fvSUN")) == NULL) || r; - r = ((glNormal3fVertex3fSUN = (PFNGLNORMAL3FVERTEX3FSUNPROC)glewGetProcAddress((const GLubyte*)"glNormal3fVertex3fSUN")) == NULL) || r; - r = ((glNormal3fVertex3fvSUN = (PFNGLNORMAL3FVERTEX3FVSUNPROC)glewGetProcAddress((const GLubyte*)"glNormal3fVertex3fvSUN")) == NULL) || r; - r = ((glReplacementCodeuiColor3fVertex3fSUN = (PFNGLREPLACEMENTCODEUICOLOR3FVERTEX3FSUNPROC)glewGetProcAddress((const GLubyte*)"glReplacementCodeuiColor3fVertex3fSUN")) == NULL) || r; - r = ((glReplacementCodeuiColor3fVertex3fvSUN = (PFNGLREPLACEMENTCODEUICOLOR3FVERTEX3FVSUNPROC)glewGetProcAddress((const GLubyte*)"glReplacementCodeuiColor3fVertex3fvSUN")) == NULL) || r; - r = ((glReplacementCodeuiColor4fNormal3fVertex3fSUN = (PFNGLREPLACEMENTCODEUICOLOR4FNORMAL3FVERTEX3FSUNPROC)glewGetProcAddress((const GLubyte*)"glReplacementCodeuiColor4fNormal3fVertex3fSUN")) == NULL) || r; - r = ((glReplacementCodeuiColor4fNormal3fVertex3fvSUN = (PFNGLREPLACEMENTCODEUICOLOR4FNORMAL3FVERTEX3FVSUNPROC)glewGetProcAddress((const GLubyte*)"glReplacementCodeuiColor4fNormal3fVertex3fvSUN")) == NULL) || r; - r = ((glReplacementCodeuiColor4ubVertex3fSUN = (PFNGLREPLACEMENTCODEUICOLOR4UBVERTEX3FSUNPROC)glewGetProcAddress((const GLubyte*)"glReplacementCodeuiColor4ubVertex3fSUN")) == NULL) || r; - r = ((glReplacementCodeuiColor4ubVertex3fvSUN = (PFNGLREPLACEMENTCODEUICOLOR4UBVERTEX3FVSUNPROC)glewGetProcAddress((const GLubyte*)"glReplacementCodeuiColor4ubVertex3fvSUN")) == NULL) || r; - r = ((glReplacementCodeuiNormal3fVertex3fSUN = (PFNGLREPLACEMENTCODEUINORMAL3FVERTEX3FSUNPROC)glewGetProcAddress((const GLubyte*)"glReplacementCodeuiNormal3fVertex3fSUN")) == NULL) || r; - r = ((glReplacementCodeuiNormal3fVertex3fvSUN = (PFNGLREPLACEMENTCODEUINORMAL3FVERTEX3FVSUNPROC)glewGetProcAddress((const GLubyte*)"glReplacementCodeuiNormal3fVertex3fvSUN")) == NULL) || r; - r = ((glReplacementCodeuiTexCoord2fColor4fNormal3fVertex3fSUN = (PFNGLREPLACEMENTCODEUITEXCOORD2FCOLOR4FNORMAL3FVERTEX3FSUNPROC)glewGetProcAddress((const GLubyte*)"glReplacementCodeuiTexCoord2fColor4fNormal3fVertex3fSUN")) == NULL) || r; - r = ((glReplacementCodeuiTexCoord2fColor4fNormal3fVertex3fvSUN = (PFNGLREPLACEMENTCODEUITEXCOORD2FCOLOR4FNORMAL3FVERTEX3FVSUNPROC)glewGetProcAddress((const GLubyte*)"glReplacementCodeuiTexCoord2fColor4fNormal3fVertex3fvSUN")) == NULL) || r; - r = ((glReplacementCodeuiTexCoord2fNormal3fVertex3fSUN = (PFNGLREPLACEMENTCODEUITEXCOORD2FNORMAL3FVERTEX3FSUNPROC)glewGetProcAddress((const GLubyte*)"glReplacementCodeuiTexCoord2fNormal3fVertex3fSUN")) == NULL) || r; - r = ((glReplacementCodeuiTexCoord2fNormal3fVertex3fvSUN = (PFNGLREPLACEMENTCODEUITEXCOORD2FNORMAL3FVERTEX3FVSUNPROC)glewGetProcAddress((const GLubyte*)"glReplacementCodeuiTexCoord2fNormal3fVertex3fvSUN")) == NULL) || r; - r = ((glReplacementCodeuiTexCoord2fVertex3fSUN = (PFNGLREPLACEMENTCODEUITEXCOORD2FVERTEX3FSUNPROC)glewGetProcAddress((const GLubyte*)"glReplacementCodeuiTexCoord2fVertex3fSUN")) == NULL) || r; - r = ((glReplacementCodeuiTexCoord2fVertex3fvSUN = (PFNGLREPLACEMENTCODEUITEXCOORD2FVERTEX3FVSUNPROC)glewGetProcAddress((const GLubyte*)"glReplacementCodeuiTexCoord2fVertex3fvSUN")) == NULL) || r; - r = ((glReplacementCodeuiVertex3fSUN = (PFNGLREPLACEMENTCODEUIVERTEX3FSUNPROC)glewGetProcAddress((const GLubyte*)"glReplacementCodeuiVertex3fSUN")) == NULL) || r; - r = ((glReplacementCodeuiVertex3fvSUN = (PFNGLREPLACEMENTCODEUIVERTEX3FVSUNPROC)glewGetProcAddress((const GLubyte*)"glReplacementCodeuiVertex3fvSUN")) == NULL) || r; - r = ((glTexCoord2fColor3fVertex3fSUN = (PFNGLTEXCOORD2FCOLOR3FVERTEX3FSUNPROC)glewGetProcAddress((const GLubyte*)"glTexCoord2fColor3fVertex3fSUN")) == NULL) || r; - r = ((glTexCoord2fColor3fVertex3fvSUN = (PFNGLTEXCOORD2FCOLOR3FVERTEX3FVSUNPROC)glewGetProcAddress((const GLubyte*)"glTexCoord2fColor3fVertex3fvSUN")) == NULL) || r; - r = ((glTexCoord2fColor4fNormal3fVertex3fSUN = (PFNGLTEXCOORD2FCOLOR4FNORMAL3FVERTEX3FSUNPROC)glewGetProcAddress((const GLubyte*)"glTexCoord2fColor4fNormal3fVertex3fSUN")) == NULL) || r; - r = ((glTexCoord2fColor4fNormal3fVertex3fvSUN = (PFNGLTEXCOORD2FCOLOR4FNORMAL3FVERTEX3FVSUNPROC)glewGetProcAddress((const GLubyte*)"glTexCoord2fColor4fNormal3fVertex3fvSUN")) == NULL) || r; - r = ((glTexCoord2fColor4ubVertex3fSUN = (PFNGLTEXCOORD2FCOLOR4UBVERTEX3FSUNPROC)glewGetProcAddress((const GLubyte*)"glTexCoord2fColor4ubVertex3fSUN")) == NULL) || r; - r = ((glTexCoord2fColor4ubVertex3fvSUN = (PFNGLTEXCOORD2FCOLOR4UBVERTEX3FVSUNPROC)glewGetProcAddress((const GLubyte*)"glTexCoord2fColor4ubVertex3fvSUN")) == NULL) || r; - r = ((glTexCoord2fNormal3fVertex3fSUN = (PFNGLTEXCOORD2FNORMAL3FVERTEX3FSUNPROC)glewGetProcAddress((const GLubyte*)"glTexCoord2fNormal3fVertex3fSUN")) == NULL) || r; - r = ((glTexCoord2fNormal3fVertex3fvSUN = (PFNGLTEXCOORD2FNORMAL3FVERTEX3FVSUNPROC)glewGetProcAddress((const GLubyte*)"glTexCoord2fNormal3fVertex3fvSUN")) == NULL) || r; - r = ((glTexCoord2fVertex3fSUN = (PFNGLTEXCOORD2FVERTEX3FSUNPROC)glewGetProcAddress((const GLubyte*)"glTexCoord2fVertex3fSUN")) == NULL) || r; - r = ((glTexCoord2fVertex3fvSUN = (PFNGLTEXCOORD2FVERTEX3FVSUNPROC)glewGetProcAddress((const GLubyte*)"glTexCoord2fVertex3fvSUN")) == NULL) || r; - r = ((glTexCoord4fColor4fNormal3fVertex4fSUN = (PFNGLTEXCOORD4FCOLOR4FNORMAL3FVERTEX4FSUNPROC)glewGetProcAddress((const GLubyte*)"glTexCoord4fColor4fNormal3fVertex4fSUN")) == NULL) || r; - r = ((glTexCoord4fColor4fNormal3fVertex4fvSUN = (PFNGLTEXCOORD4FCOLOR4FNORMAL3FVERTEX4FVSUNPROC)glewGetProcAddress((const GLubyte*)"glTexCoord4fColor4fNormal3fVertex4fvSUN")) == NULL) || r; - r = ((glTexCoord4fVertex4fSUN = (PFNGLTEXCOORD4FVERTEX4FSUNPROC)glewGetProcAddress((const GLubyte*)"glTexCoord4fVertex4fSUN")) == NULL) || r; - r = ((glTexCoord4fVertex4fvSUN = (PFNGLTEXCOORD4FVERTEX4FVSUNPROC)glewGetProcAddress((const GLubyte*)"glTexCoord4fVertex4fvSUN")) == NULL) || r; - - return r; -} - -#endif /* GL_SUN_vertex */ - -#ifdef GL_WIN_phong_shading - -#endif /* GL_WIN_phong_shading */ - -#ifdef GL_WIN_specular_fog - -#endif /* GL_WIN_specular_fog */ - -#ifdef GL_WIN_swap_hint - -static GLboolean _glewInit_GL_WIN_swap_hint (GLEW_CONTEXT_ARG_DEF_INIT) -{ - GLboolean r = GL_FALSE; - - r = ((glAddSwapHintRectWIN = (PFNGLADDSWAPHINTRECTWINPROC)glewGetProcAddress((const GLubyte*)"glAddSwapHintRectWIN")) == NULL) || r; - - return r; -} - -#endif /* GL_WIN_swap_hint */ - -/* ------------------------------------------------------------------------- */ - -/* - * Search for name in the extensions string. Use of strstr() - * is not sufficient because extension names can be prefixes of - * other extension names. Could use strtok() but the constant - * string returned by glGetString might be in read-only memory. - */ -GLboolean glewGetExtension (const char* name) -{ - GLubyte* p; - GLubyte* end; - GLuint len = _glewStrLen((const GLubyte*)name); - p = (GLubyte*)glGetString(GL_EXTENSIONS); - if (0 == p) return GL_FALSE; - end = p + _glewStrLen(p); - while (p < end) - { - GLuint n = _glewStrCLen(p, ' '); - if (len == n && _glewStrSame((const GLubyte*)name, p, n)) return GL_TRUE; - p += n+1; - } - return GL_FALSE; -} - -/* ------------------------------------------------------------------------- */ - -#ifndef GLEW_MX -static -#endif -GLenum glewContextInit (GLEW_CONTEXT_ARG_DEF_LIST) -{ - const GLubyte* s; - GLuint dot, major, minor; - /* query opengl version */ - s = glGetString(GL_VERSION); - dot = _glewStrCLen(s, '.'); - major = dot-1; - minor = dot+1; - if (dot == 0 || s[minor] == '\0') - return GLEW_ERROR_NO_GL_VERSION; - if (s[major] == '1' && s[minor] == '0') - { - return GLEW_ERROR_GL_VERSION_10_ONLY; - } - else - { - CONST_CAST(GLEW_VERSION_1_1) = GL_TRUE; - if (s[major] >= '2') - { - CONST_CAST(GLEW_VERSION_1_2) = GL_TRUE; - CONST_CAST(GLEW_VERSION_1_3) = GL_TRUE; - CONST_CAST(GLEW_VERSION_1_4) = GL_TRUE; - CONST_CAST(GLEW_VERSION_1_5) = GL_TRUE; - CONST_CAST(GLEW_VERSION_2_0) = GL_TRUE; - if (s[minor] >= '1') - { - CONST_CAST(GLEW_VERSION_2_1) = GL_TRUE; - } - } - else - { - if (s[minor] >= '5') - { - CONST_CAST(GLEW_VERSION_1_2) = GL_TRUE; - CONST_CAST(GLEW_VERSION_1_3) = GL_TRUE; - CONST_CAST(GLEW_VERSION_1_4) = GL_TRUE; - CONST_CAST(GLEW_VERSION_1_5) = GL_TRUE; - CONST_CAST(GLEW_VERSION_2_0) = GL_FALSE; - CONST_CAST(GLEW_VERSION_2_1) = GL_FALSE; - } - if (s[minor] == '4') - { - CONST_CAST(GLEW_VERSION_1_2) = GL_TRUE; - CONST_CAST(GLEW_VERSION_1_3) = GL_TRUE; - CONST_CAST(GLEW_VERSION_1_4) = GL_TRUE; - CONST_CAST(GLEW_VERSION_1_5) = GL_FALSE; - CONST_CAST(GLEW_VERSION_2_0) = GL_FALSE; - CONST_CAST(GLEW_VERSION_2_1) = GL_FALSE; - } - if (s[minor] == '3') - { - CONST_CAST(GLEW_VERSION_1_2) = GL_TRUE; - CONST_CAST(GLEW_VERSION_1_3) = GL_TRUE; - CONST_CAST(GLEW_VERSION_1_4) = GL_FALSE; - CONST_CAST(GLEW_VERSION_1_5) = GL_FALSE; - CONST_CAST(GLEW_VERSION_2_0) = GL_FALSE; - CONST_CAST(GLEW_VERSION_2_1) = GL_FALSE; - } - if (s[minor] == '2') - { - CONST_CAST(GLEW_VERSION_1_2) = GL_TRUE; - CONST_CAST(GLEW_VERSION_1_3) = GL_FALSE; - CONST_CAST(GLEW_VERSION_1_4) = GL_FALSE; - CONST_CAST(GLEW_VERSION_1_5) = GL_FALSE; - CONST_CAST(GLEW_VERSION_2_0) = GL_FALSE; - CONST_CAST(GLEW_VERSION_2_1) = GL_FALSE; - } - if (s[minor] < '2') - { - CONST_CAST(GLEW_VERSION_1_2) = GL_FALSE; - CONST_CAST(GLEW_VERSION_1_3) = GL_FALSE; - CONST_CAST(GLEW_VERSION_1_4) = GL_FALSE; - CONST_CAST(GLEW_VERSION_1_5) = GL_FALSE; - CONST_CAST(GLEW_VERSION_2_0) = GL_FALSE; - CONST_CAST(GLEW_VERSION_2_1) = GL_FALSE; - } - } - } - /* initialize extensions */ -#ifdef GL_VERSION_1_2 - if (glewExperimental || GLEW_VERSION_1_2) CONST_CAST(GLEW_VERSION_1_2) = !_glewInit_GL_VERSION_1_2(GLEW_CONTEXT_ARG_VAR_INIT); -#endif /* GL_VERSION_1_2 */ -#ifdef GL_VERSION_1_3 - if (glewExperimental || GLEW_VERSION_1_3) CONST_CAST(GLEW_VERSION_1_3) = !_glewInit_GL_VERSION_1_3(GLEW_CONTEXT_ARG_VAR_INIT); -#endif /* GL_VERSION_1_3 */ -#ifdef GL_VERSION_1_4 - if (glewExperimental || GLEW_VERSION_1_4) CONST_CAST(GLEW_VERSION_1_4) = !_glewInit_GL_VERSION_1_4(GLEW_CONTEXT_ARG_VAR_INIT); -#endif /* GL_VERSION_1_4 */ -#ifdef GL_VERSION_1_5 - if (glewExperimental || GLEW_VERSION_1_5) CONST_CAST(GLEW_VERSION_1_5) = !_glewInit_GL_VERSION_1_5(GLEW_CONTEXT_ARG_VAR_INIT); -#endif /* GL_VERSION_1_5 */ -#ifdef GL_VERSION_2_0 - if (glewExperimental || GLEW_VERSION_2_0) CONST_CAST(GLEW_VERSION_2_0) = !_glewInit_GL_VERSION_2_0(GLEW_CONTEXT_ARG_VAR_INIT); -#endif /* GL_VERSION_2_0 */ -#ifdef GL_VERSION_2_1 - if (glewExperimental || GLEW_VERSION_2_1) CONST_CAST(GLEW_VERSION_2_1) = !_glewInit_GL_VERSION_2_1(GLEW_CONTEXT_ARG_VAR_INIT); -#endif /* GL_VERSION_2_1 */ -#ifdef GL_VERSION_3_0 - if (glewExperimental || GLEW_VERSION_3_0) CONST_CAST(GLEW_VERSION_3_0) = !_glewInit_GL_VERSION_3_0(GLEW_CONTEXT_ARG_VAR_INIT); -#endif /* GL_VERSION_3_0 */ -#ifdef GL_3DFX_multisample - CONST_CAST(GLEW_3DFX_multisample) = glewGetExtension("GL_3DFX_multisample"); -#endif /* GL_3DFX_multisample */ -#ifdef GL_3DFX_tbuffer - CONST_CAST(GLEW_3DFX_tbuffer) = glewGetExtension("GL_3DFX_tbuffer"); - if (glewExperimental || GLEW_3DFX_tbuffer) CONST_CAST(GLEW_3DFX_tbuffer) = !_glewInit_GL_3DFX_tbuffer(GLEW_CONTEXT_ARG_VAR_INIT); -#endif /* GL_3DFX_tbuffer */ -#ifdef GL_3DFX_texture_compression_FXT1 - CONST_CAST(GLEW_3DFX_texture_compression_FXT1) = glewGetExtension("GL_3DFX_texture_compression_FXT1"); -#endif /* GL_3DFX_texture_compression_FXT1 */ -#ifdef GL_APPLE_client_storage - CONST_CAST(GLEW_APPLE_client_storage) = glewGetExtension("GL_APPLE_client_storage"); -#endif /* GL_APPLE_client_storage */ -#ifdef GL_APPLE_element_array - CONST_CAST(GLEW_APPLE_element_array) = glewGetExtension("GL_APPLE_element_array"); - if (glewExperimental || GLEW_APPLE_element_array) CONST_CAST(GLEW_APPLE_element_array) = !_glewInit_GL_APPLE_element_array(GLEW_CONTEXT_ARG_VAR_INIT); -#endif /* GL_APPLE_element_array */ -#ifdef GL_APPLE_fence - CONST_CAST(GLEW_APPLE_fence) = glewGetExtension("GL_APPLE_fence"); - if (glewExperimental || GLEW_APPLE_fence) CONST_CAST(GLEW_APPLE_fence) = !_glewInit_GL_APPLE_fence(GLEW_CONTEXT_ARG_VAR_INIT); -#endif /* GL_APPLE_fence */ -#ifdef GL_APPLE_float_pixels - CONST_CAST(GLEW_APPLE_float_pixels) = glewGetExtension("GL_APPLE_float_pixels"); -#endif /* GL_APPLE_float_pixels */ -#ifdef GL_APPLE_flush_buffer_range - CONST_CAST(GLEW_APPLE_flush_buffer_range) = glewGetExtension("GL_APPLE_flush_buffer_range"); - if (glewExperimental || GLEW_APPLE_flush_buffer_range) CONST_CAST(GLEW_APPLE_flush_buffer_range) = !_glewInit_GL_APPLE_flush_buffer_range(GLEW_CONTEXT_ARG_VAR_INIT); -#endif /* GL_APPLE_flush_buffer_range */ -#ifdef GL_APPLE_pixel_buffer - CONST_CAST(GLEW_APPLE_pixel_buffer) = glewGetExtension("GL_APPLE_pixel_buffer"); -#endif /* GL_APPLE_pixel_buffer */ -#ifdef GL_APPLE_specular_vector - CONST_CAST(GLEW_APPLE_specular_vector) = glewGetExtension("GL_APPLE_specular_vector"); -#endif /* GL_APPLE_specular_vector */ -#ifdef GL_APPLE_texture_range - CONST_CAST(GLEW_APPLE_texture_range) = glewGetExtension("GL_APPLE_texture_range"); - if (glewExperimental || GLEW_APPLE_texture_range) CONST_CAST(GLEW_APPLE_texture_range) = !_glewInit_GL_APPLE_texture_range(GLEW_CONTEXT_ARG_VAR_INIT); -#endif /* GL_APPLE_texture_range */ -#ifdef GL_APPLE_transform_hint - CONST_CAST(GLEW_APPLE_transform_hint) = glewGetExtension("GL_APPLE_transform_hint"); -#endif /* GL_APPLE_transform_hint */ -#ifdef GL_APPLE_vertex_array_object - CONST_CAST(GLEW_APPLE_vertex_array_object) = glewGetExtension("GL_APPLE_vertex_array_object"); - if (glewExperimental || GLEW_APPLE_vertex_array_object) CONST_CAST(GLEW_APPLE_vertex_array_object) = !_glewInit_GL_APPLE_vertex_array_object(GLEW_CONTEXT_ARG_VAR_INIT); -#endif /* GL_APPLE_vertex_array_object */ -#ifdef GL_APPLE_vertex_array_range - CONST_CAST(GLEW_APPLE_vertex_array_range) = glewGetExtension("GL_APPLE_vertex_array_range"); - if (glewExperimental || GLEW_APPLE_vertex_array_range) CONST_CAST(GLEW_APPLE_vertex_array_range) = !_glewInit_GL_APPLE_vertex_array_range(GLEW_CONTEXT_ARG_VAR_INIT); -#endif /* GL_APPLE_vertex_array_range */ -#ifdef GL_APPLE_ycbcr_422 - CONST_CAST(GLEW_APPLE_ycbcr_422) = glewGetExtension("GL_APPLE_ycbcr_422"); -#endif /* GL_APPLE_ycbcr_422 */ -#ifdef GL_ARB_color_buffer_float - CONST_CAST(GLEW_ARB_color_buffer_float) = glewGetExtension("GL_ARB_color_buffer_float"); - if (glewExperimental || GLEW_ARB_color_buffer_float) CONST_CAST(GLEW_ARB_color_buffer_float) = !_glewInit_GL_ARB_color_buffer_float(GLEW_CONTEXT_ARG_VAR_INIT); -#endif /* GL_ARB_color_buffer_float */ -#ifdef GL_ARB_depth_buffer_float - CONST_CAST(GLEW_ARB_depth_buffer_float) = glewGetExtension("GL_ARB_depth_buffer_float"); -#endif /* GL_ARB_depth_buffer_float */ -#ifdef GL_ARB_depth_texture - CONST_CAST(GLEW_ARB_depth_texture) = glewGetExtension("GL_ARB_depth_texture"); -#endif /* GL_ARB_depth_texture */ -#ifdef GL_ARB_draw_buffers - CONST_CAST(GLEW_ARB_draw_buffers) = glewGetExtension("GL_ARB_draw_buffers"); - if (glewExperimental || GLEW_ARB_draw_buffers) CONST_CAST(GLEW_ARB_draw_buffers) = !_glewInit_GL_ARB_draw_buffers(GLEW_CONTEXT_ARG_VAR_INIT); -#endif /* GL_ARB_draw_buffers */ -#ifdef GL_ARB_draw_instanced - CONST_CAST(GLEW_ARB_draw_instanced) = glewGetExtension("GL_ARB_draw_instanced"); - if (glewExperimental || GLEW_ARB_draw_instanced) CONST_CAST(GLEW_ARB_draw_instanced) = !_glewInit_GL_ARB_draw_instanced(GLEW_CONTEXT_ARG_VAR_INIT); -#endif /* GL_ARB_draw_instanced */ -#ifdef GL_ARB_fragment_program - CONST_CAST(GLEW_ARB_fragment_program) = glewGetExtension("GL_ARB_fragment_program"); -#endif /* GL_ARB_fragment_program */ -#ifdef GL_ARB_fragment_program_shadow - CONST_CAST(GLEW_ARB_fragment_program_shadow) = glewGetExtension("GL_ARB_fragment_program_shadow"); -#endif /* GL_ARB_fragment_program_shadow */ -#ifdef GL_ARB_fragment_shader - CONST_CAST(GLEW_ARB_fragment_shader) = glewGetExtension("GL_ARB_fragment_shader"); -#endif /* GL_ARB_fragment_shader */ -#ifdef GL_ARB_framebuffer_object - CONST_CAST(GLEW_ARB_framebuffer_object) = glewGetExtension("GL_ARB_framebuffer_object"); - if (glewExperimental || GLEW_ARB_framebuffer_object) CONST_CAST(GLEW_ARB_framebuffer_object) = !_glewInit_GL_ARB_framebuffer_object(GLEW_CONTEXT_ARG_VAR_INIT); -#endif /* GL_ARB_framebuffer_object */ -#ifdef GL_ARB_framebuffer_sRGB - CONST_CAST(GLEW_ARB_framebuffer_sRGB) = glewGetExtension("GL_ARB_framebuffer_sRGB"); -#endif /* GL_ARB_framebuffer_sRGB */ -#ifdef GL_ARB_geometry_shader4 - CONST_CAST(GLEW_ARB_geometry_shader4) = glewGetExtension("GL_ARB_geometry_shader4"); - if (glewExperimental || GLEW_ARB_geometry_shader4) CONST_CAST(GLEW_ARB_geometry_shader4) = !_glewInit_GL_ARB_geometry_shader4(GLEW_CONTEXT_ARG_VAR_INIT); -#endif /* GL_ARB_geometry_shader4 */ -#ifdef GL_ARB_half_float_pixel - CONST_CAST(GLEW_ARB_half_float_pixel) = glewGetExtension("GL_ARB_half_float_pixel"); -#endif /* GL_ARB_half_float_pixel */ -#ifdef GL_ARB_half_float_vertex - CONST_CAST(GLEW_ARB_half_float_vertex) = glewGetExtension("GL_ARB_half_float_vertex"); -#endif /* GL_ARB_half_float_vertex */ -#ifdef GL_ARB_imaging - CONST_CAST(GLEW_ARB_imaging) = glewGetExtension("GL_ARB_imaging"); - if (glewExperimental || GLEW_ARB_imaging) CONST_CAST(GLEW_ARB_imaging) = !_glewInit_GL_ARB_imaging(GLEW_CONTEXT_ARG_VAR_INIT); -#endif /* GL_ARB_imaging */ -#ifdef GL_ARB_instanced_arrays - CONST_CAST(GLEW_ARB_instanced_arrays) = glewGetExtension("GL_ARB_instanced_arrays"); - if (glewExperimental || GLEW_ARB_instanced_arrays) CONST_CAST(GLEW_ARB_instanced_arrays) = !_glewInit_GL_ARB_instanced_arrays(GLEW_CONTEXT_ARG_VAR_INIT); -#endif /* GL_ARB_instanced_arrays */ -#ifdef GL_ARB_map_buffer_range - CONST_CAST(GLEW_ARB_map_buffer_range) = glewGetExtension("GL_ARB_map_buffer_range"); - if (glewExperimental || GLEW_ARB_map_buffer_range) CONST_CAST(GLEW_ARB_map_buffer_range) = !_glewInit_GL_ARB_map_buffer_range(GLEW_CONTEXT_ARG_VAR_INIT); -#endif /* GL_ARB_map_buffer_range */ -#ifdef GL_ARB_matrix_palette - CONST_CAST(GLEW_ARB_matrix_palette) = glewGetExtension("GL_ARB_matrix_palette"); - if (glewExperimental || GLEW_ARB_matrix_palette) CONST_CAST(GLEW_ARB_matrix_palette) = !_glewInit_GL_ARB_matrix_palette(GLEW_CONTEXT_ARG_VAR_INIT); -#endif /* GL_ARB_matrix_palette */ -#ifdef GL_ARB_multisample - CONST_CAST(GLEW_ARB_multisample) = glewGetExtension("GL_ARB_multisample"); - if (glewExperimental || GLEW_ARB_multisample) CONST_CAST(GLEW_ARB_multisample) = !_glewInit_GL_ARB_multisample(GLEW_CONTEXT_ARG_VAR_INIT); -#endif /* GL_ARB_multisample */ -#ifdef GL_ARB_multitexture - CONST_CAST(GLEW_ARB_multitexture) = glewGetExtension("GL_ARB_multitexture"); - if (glewExperimental || GLEW_ARB_multitexture) CONST_CAST(GLEW_ARB_multitexture) = !_glewInit_GL_ARB_multitexture(GLEW_CONTEXT_ARG_VAR_INIT); -#endif /* GL_ARB_multitexture */ -#ifdef GL_ARB_occlusion_query - CONST_CAST(GLEW_ARB_occlusion_query) = glewGetExtension("GL_ARB_occlusion_query"); - if (glewExperimental || GLEW_ARB_occlusion_query) CONST_CAST(GLEW_ARB_occlusion_query) = !_glewInit_GL_ARB_occlusion_query(GLEW_CONTEXT_ARG_VAR_INIT); -#endif /* GL_ARB_occlusion_query */ -#ifdef GL_ARB_pixel_buffer_object - CONST_CAST(GLEW_ARB_pixel_buffer_object) = glewGetExtension("GL_ARB_pixel_buffer_object"); -#endif /* GL_ARB_pixel_buffer_object */ -#ifdef GL_ARB_point_parameters - CONST_CAST(GLEW_ARB_point_parameters) = glewGetExtension("GL_ARB_point_parameters"); - if (glewExperimental || GLEW_ARB_point_parameters) CONST_CAST(GLEW_ARB_point_parameters) = !_glewInit_GL_ARB_point_parameters(GLEW_CONTEXT_ARG_VAR_INIT); -#endif /* GL_ARB_point_parameters */ -#ifdef GL_ARB_point_sprite - CONST_CAST(GLEW_ARB_point_sprite) = glewGetExtension("GL_ARB_point_sprite"); -#endif /* GL_ARB_point_sprite */ -#ifdef GL_ARB_shader_objects - CONST_CAST(GLEW_ARB_shader_objects) = glewGetExtension("GL_ARB_shader_objects"); - if (glewExperimental || GLEW_ARB_shader_objects) CONST_CAST(GLEW_ARB_shader_objects) = !_glewInit_GL_ARB_shader_objects(GLEW_CONTEXT_ARG_VAR_INIT); -#endif /* GL_ARB_shader_objects */ -#ifdef GL_ARB_shading_language_100 - CONST_CAST(GLEW_ARB_shading_language_100) = glewGetExtension("GL_ARB_shading_language_100"); -#endif /* GL_ARB_shading_language_100 */ -#ifdef GL_ARB_shadow - CONST_CAST(GLEW_ARB_shadow) = glewGetExtension("GL_ARB_shadow"); -#endif /* GL_ARB_shadow */ -#ifdef GL_ARB_shadow_ambient - CONST_CAST(GLEW_ARB_shadow_ambient) = glewGetExtension("GL_ARB_shadow_ambient"); -#endif /* GL_ARB_shadow_ambient */ -#ifdef GL_ARB_texture_border_clamp - CONST_CAST(GLEW_ARB_texture_border_clamp) = glewGetExtension("GL_ARB_texture_border_clamp"); -#endif /* GL_ARB_texture_border_clamp */ -#ifdef GL_ARB_texture_buffer_object - CONST_CAST(GLEW_ARB_texture_buffer_object) = glewGetExtension("GL_ARB_texture_buffer_object"); - if (glewExperimental || GLEW_ARB_texture_buffer_object) CONST_CAST(GLEW_ARB_texture_buffer_object) = !_glewInit_GL_ARB_texture_buffer_object(GLEW_CONTEXT_ARG_VAR_INIT); -#endif /* GL_ARB_texture_buffer_object */ -#ifdef GL_ARB_texture_compression - CONST_CAST(GLEW_ARB_texture_compression) = glewGetExtension("GL_ARB_texture_compression"); - if (glewExperimental || GLEW_ARB_texture_compression) CONST_CAST(GLEW_ARB_texture_compression) = !_glewInit_GL_ARB_texture_compression(GLEW_CONTEXT_ARG_VAR_INIT); -#endif /* GL_ARB_texture_compression */ -#ifdef GL_ARB_texture_compression_rgtc - CONST_CAST(GLEW_ARB_texture_compression_rgtc) = glewGetExtension("GL_ARB_texture_compression_rgtc"); -#endif /* GL_ARB_texture_compression_rgtc */ -#ifdef GL_ARB_texture_cube_map - CONST_CAST(GLEW_ARB_texture_cube_map) = glewGetExtension("GL_ARB_texture_cube_map"); -#endif /* GL_ARB_texture_cube_map */ -#ifdef GL_ARB_texture_env_add - CONST_CAST(GLEW_ARB_texture_env_add) = glewGetExtension("GL_ARB_texture_env_add"); -#endif /* GL_ARB_texture_env_add */ -#ifdef GL_ARB_texture_env_combine - CONST_CAST(GLEW_ARB_texture_env_combine) = glewGetExtension("GL_ARB_texture_env_combine"); -#endif /* GL_ARB_texture_env_combine */ -#ifdef GL_ARB_texture_env_crossbar - CONST_CAST(GLEW_ARB_texture_env_crossbar) = glewGetExtension("GL_ARB_texture_env_crossbar"); -#endif /* GL_ARB_texture_env_crossbar */ -#ifdef GL_ARB_texture_env_dot3 - CONST_CAST(GLEW_ARB_texture_env_dot3) = glewGetExtension("GL_ARB_texture_env_dot3"); -#endif /* GL_ARB_texture_env_dot3 */ -#ifdef GL_ARB_texture_float - CONST_CAST(GLEW_ARB_texture_float) = glewGetExtension("GL_ARB_texture_float"); -#endif /* GL_ARB_texture_float */ -#ifdef GL_ARB_texture_mirrored_repeat - CONST_CAST(GLEW_ARB_texture_mirrored_repeat) = glewGetExtension("GL_ARB_texture_mirrored_repeat"); -#endif /* GL_ARB_texture_mirrored_repeat */ -#ifdef GL_ARB_texture_non_power_of_two - CONST_CAST(GLEW_ARB_texture_non_power_of_two) = glewGetExtension("GL_ARB_texture_non_power_of_two"); -#endif /* GL_ARB_texture_non_power_of_two */ -#ifdef GL_ARB_texture_rectangle - CONST_CAST(GLEW_ARB_texture_rectangle) = glewGetExtension("GL_ARB_texture_rectangle"); -#endif /* GL_ARB_texture_rectangle */ -#ifdef GL_ARB_texture_rg - CONST_CAST(GLEW_ARB_texture_rg) = glewGetExtension("GL_ARB_texture_rg"); -#endif /* GL_ARB_texture_rg */ -#ifdef GL_ARB_transpose_matrix - CONST_CAST(GLEW_ARB_transpose_matrix) = glewGetExtension("GL_ARB_transpose_matrix"); - if (glewExperimental || GLEW_ARB_transpose_matrix) CONST_CAST(GLEW_ARB_transpose_matrix) = !_glewInit_GL_ARB_transpose_matrix(GLEW_CONTEXT_ARG_VAR_INIT); -#endif /* GL_ARB_transpose_matrix */ -#ifdef GL_ARB_vertex_array_object - CONST_CAST(GLEW_ARB_vertex_array_object) = glewGetExtension("GL_ARB_vertex_array_object"); - if (glewExperimental || GLEW_ARB_vertex_array_object) CONST_CAST(GLEW_ARB_vertex_array_object) = !_glewInit_GL_ARB_vertex_array_object(GLEW_CONTEXT_ARG_VAR_INIT); -#endif /* GL_ARB_vertex_array_object */ -#ifdef GL_ARB_vertex_blend - CONST_CAST(GLEW_ARB_vertex_blend) = glewGetExtension("GL_ARB_vertex_blend"); - if (glewExperimental || GLEW_ARB_vertex_blend) CONST_CAST(GLEW_ARB_vertex_blend) = !_glewInit_GL_ARB_vertex_blend(GLEW_CONTEXT_ARG_VAR_INIT); -#endif /* GL_ARB_vertex_blend */ -#ifdef GL_ARB_vertex_buffer_object - CONST_CAST(GLEW_ARB_vertex_buffer_object) = glewGetExtension("GL_ARB_vertex_buffer_object"); - if (glewExperimental || GLEW_ARB_vertex_buffer_object) CONST_CAST(GLEW_ARB_vertex_buffer_object) = !_glewInit_GL_ARB_vertex_buffer_object(GLEW_CONTEXT_ARG_VAR_INIT); -#endif /* GL_ARB_vertex_buffer_object */ -#ifdef GL_ARB_vertex_program - CONST_CAST(GLEW_ARB_vertex_program) = glewGetExtension("GL_ARB_vertex_program"); - if (glewExperimental || GLEW_ARB_vertex_program) CONST_CAST(GLEW_ARB_vertex_program) = !_glewInit_GL_ARB_vertex_program(GLEW_CONTEXT_ARG_VAR_INIT); -#endif /* GL_ARB_vertex_program */ -#ifdef GL_ARB_vertex_shader - CONST_CAST(GLEW_ARB_vertex_shader) = glewGetExtension("GL_ARB_vertex_shader"); - if (glewExperimental || GLEW_ARB_vertex_shader) CONST_CAST(GLEW_ARB_vertex_shader) = !_glewInit_GL_ARB_vertex_shader(GLEW_CONTEXT_ARG_VAR_INIT); -#endif /* GL_ARB_vertex_shader */ -#ifdef GL_ARB_window_pos - CONST_CAST(GLEW_ARB_window_pos) = glewGetExtension("GL_ARB_window_pos"); - if (glewExperimental || GLEW_ARB_window_pos) CONST_CAST(GLEW_ARB_window_pos) = !_glewInit_GL_ARB_window_pos(GLEW_CONTEXT_ARG_VAR_INIT); -#endif /* GL_ARB_window_pos */ -#ifdef GL_ATIX_point_sprites - CONST_CAST(GLEW_ATIX_point_sprites) = glewGetExtension("GL_ATIX_point_sprites"); -#endif /* GL_ATIX_point_sprites */ -#ifdef GL_ATIX_texture_env_combine3 - CONST_CAST(GLEW_ATIX_texture_env_combine3) = glewGetExtension("GL_ATIX_texture_env_combine3"); -#endif /* GL_ATIX_texture_env_combine3 */ -#ifdef GL_ATIX_texture_env_route - CONST_CAST(GLEW_ATIX_texture_env_route) = glewGetExtension("GL_ATIX_texture_env_route"); -#endif /* GL_ATIX_texture_env_route */ -#ifdef GL_ATIX_vertex_shader_output_point_size - CONST_CAST(GLEW_ATIX_vertex_shader_output_point_size) = glewGetExtension("GL_ATIX_vertex_shader_output_point_size"); -#endif /* GL_ATIX_vertex_shader_output_point_size */ -#ifdef GL_ATI_draw_buffers - CONST_CAST(GLEW_ATI_draw_buffers) = glewGetExtension("GL_ATI_draw_buffers"); - if (glewExperimental || GLEW_ATI_draw_buffers) CONST_CAST(GLEW_ATI_draw_buffers) = !_glewInit_GL_ATI_draw_buffers(GLEW_CONTEXT_ARG_VAR_INIT); -#endif /* GL_ATI_draw_buffers */ -#ifdef GL_ATI_element_array - CONST_CAST(GLEW_ATI_element_array) = glewGetExtension("GL_ATI_element_array"); - if (glewExperimental || GLEW_ATI_element_array) CONST_CAST(GLEW_ATI_element_array) = !_glewInit_GL_ATI_element_array(GLEW_CONTEXT_ARG_VAR_INIT); -#endif /* GL_ATI_element_array */ -#ifdef GL_ATI_envmap_bumpmap - CONST_CAST(GLEW_ATI_envmap_bumpmap) = glewGetExtension("GL_ATI_envmap_bumpmap"); - if (glewExperimental || GLEW_ATI_envmap_bumpmap) CONST_CAST(GLEW_ATI_envmap_bumpmap) = !_glewInit_GL_ATI_envmap_bumpmap(GLEW_CONTEXT_ARG_VAR_INIT); -#endif /* GL_ATI_envmap_bumpmap */ -#ifdef GL_ATI_fragment_shader - CONST_CAST(GLEW_ATI_fragment_shader) = glewGetExtension("GL_ATI_fragment_shader"); - if (glewExperimental || GLEW_ATI_fragment_shader) CONST_CAST(GLEW_ATI_fragment_shader) = !_glewInit_GL_ATI_fragment_shader(GLEW_CONTEXT_ARG_VAR_INIT); -#endif /* GL_ATI_fragment_shader */ -#ifdef GL_ATI_map_object_buffer - CONST_CAST(GLEW_ATI_map_object_buffer) = glewGetExtension("GL_ATI_map_object_buffer"); - if (glewExperimental || GLEW_ATI_map_object_buffer) CONST_CAST(GLEW_ATI_map_object_buffer) = !_glewInit_GL_ATI_map_object_buffer(GLEW_CONTEXT_ARG_VAR_INIT); -#endif /* GL_ATI_map_object_buffer */ -#ifdef GL_ATI_pn_triangles - CONST_CAST(GLEW_ATI_pn_triangles) = glewGetExtension("GL_ATI_pn_triangles"); - if (glewExperimental || GLEW_ATI_pn_triangles) CONST_CAST(GLEW_ATI_pn_triangles) = !_glewInit_GL_ATI_pn_triangles(GLEW_CONTEXT_ARG_VAR_INIT); -#endif /* GL_ATI_pn_triangles */ -#ifdef GL_ATI_separate_stencil - CONST_CAST(GLEW_ATI_separate_stencil) = glewGetExtension("GL_ATI_separate_stencil"); - if (glewExperimental || GLEW_ATI_separate_stencil) CONST_CAST(GLEW_ATI_separate_stencil) = !_glewInit_GL_ATI_separate_stencil(GLEW_CONTEXT_ARG_VAR_INIT); -#endif /* GL_ATI_separate_stencil */ -#ifdef GL_ATI_shader_texture_lod - CONST_CAST(GLEW_ATI_shader_texture_lod) = glewGetExtension("GL_ATI_shader_texture_lod"); -#endif /* GL_ATI_shader_texture_lod */ -#ifdef GL_ATI_text_fragment_shader - CONST_CAST(GLEW_ATI_text_fragment_shader) = glewGetExtension("GL_ATI_text_fragment_shader"); -#endif /* GL_ATI_text_fragment_shader */ -#ifdef GL_ATI_texture_compression_3dc - CONST_CAST(GLEW_ATI_texture_compression_3dc) = glewGetExtension("GL_ATI_texture_compression_3dc"); -#endif /* GL_ATI_texture_compression_3dc */ -#ifdef GL_ATI_texture_env_combine3 - CONST_CAST(GLEW_ATI_texture_env_combine3) = glewGetExtension("GL_ATI_texture_env_combine3"); -#endif /* GL_ATI_texture_env_combine3 */ -#ifdef GL_ATI_texture_float - CONST_CAST(GLEW_ATI_texture_float) = glewGetExtension("GL_ATI_texture_float"); -#endif /* GL_ATI_texture_float */ -#ifdef GL_ATI_texture_mirror_once - CONST_CAST(GLEW_ATI_texture_mirror_once) = glewGetExtension("GL_ATI_texture_mirror_once"); -#endif /* GL_ATI_texture_mirror_once */ -#ifdef GL_ATI_vertex_array_object - CONST_CAST(GLEW_ATI_vertex_array_object) = glewGetExtension("GL_ATI_vertex_array_object"); - if (glewExperimental || GLEW_ATI_vertex_array_object) CONST_CAST(GLEW_ATI_vertex_array_object) = !_glewInit_GL_ATI_vertex_array_object(GLEW_CONTEXT_ARG_VAR_INIT); -#endif /* GL_ATI_vertex_array_object */ -#ifdef GL_ATI_vertex_attrib_array_object - CONST_CAST(GLEW_ATI_vertex_attrib_array_object) = glewGetExtension("GL_ATI_vertex_attrib_array_object"); - if (glewExperimental || GLEW_ATI_vertex_attrib_array_object) CONST_CAST(GLEW_ATI_vertex_attrib_array_object) = !_glewInit_GL_ATI_vertex_attrib_array_object(GLEW_CONTEXT_ARG_VAR_INIT); -#endif /* GL_ATI_vertex_attrib_array_object */ -#ifdef GL_ATI_vertex_streams - CONST_CAST(GLEW_ATI_vertex_streams) = glewGetExtension("GL_ATI_vertex_streams"); - if (glewExperimental || GLEW_ATI_vertex_streams) CONST_CAST(GLEW_ATI_vertex_streams) = !_glewInit_GL_ATI_vertex_streams(GLEW_CONTEXT_ARG_VAR_INIT); -#endif /* GL_ATI_vertex_streams */ -#ifdef GL_EXT_422_pixels - CONST_CAST(GLEW_EXT_422_pixels) = glewGetExtension("GL_EXT_422_pixels"); -#endif /* GL_EXT_422_pixels */ -#ifdef GL_EXT_Cg_shader - CONST_CAST(GLEW_EXT_Cg_shader) = glewGetExtension("GL_EXT_Cg_shader"); -#endif /* GL_EXT_Cg_shader */ -#ifdef GL_EXT_abgr - CONST_CAST(GLEW_EXT_abgr) = glewGetExtension("GL_EXT_abgr"); -#endif /* GL_EXT_abgr */ -#ifdef GL_EXT_bgra - CONST_CAST(GLEW_EXT_bgra) = glewGetExtension("GL_EXT_bgra"); -#endif /* GL_EXT_bgra */ -#ifdef GL_EXT_bindable_uniform - CONST_CAST(GLEW_EXT_bindable_uniform) = glewGetExtension("GL_EXT_bindable_uniform"); - if (glewExperimental || GLEW_EXT_bindable_uniform) CONST_CAST(GLEW_EXT_bindable_uniform) = !_glewInit_GL_EXT_bindable_uniform(GLEW_CONTEXT_ARG_VAR_INIT); -#endif /* GL_EXT_bindable_uniform */ -#ifdef GL_EXT_blend_color - CONST_CAST(GLEW_EXT_blend_color) = glewGetExtension("GL_EXT_blend_color"); - if (glewExperimental || GLEW_EXT_blend_color) CONST_CAST(GLEW_EXT_blend_color) = !_glewInit_GL_EXT_blend_color(GLEW_CONTEXT_ARG_VAR_INIT); -#endif /* GL_EXT_blend_color */ -#ifdef GL_EXT_blend_equation_separate - CONST_CAST(GLEW_EXT_blend_equation_separate) = glewGetExtension("GL_EXT_blend_equation_separate"); - if (glewExperimental || GLEW_EXT_blend_equation_separate) CONST_CAST(GLEW_EXT_blend_equation_separate) = !_glewInit_GL_EXT_blend_equation_separate(GLEW_CONTEXT_ARG_VAR_INIT); -#endif /* GL_EXT_blend_equation_separate */ -#ifdef GL_EXT_blend_func_separate - CONST_CAST(GLEW_EXT_blend_func_separate) = glewGetExtension("GL_EXT_blend_func_separate"); - if (glewExperimental || GLEW_EXT_blend_func_separate) CONST_CAST(GLEW_EXT_blend_func_separate) = !_glewInit_GL_EXT_blend_func_separate(GLEW_CONTEXT_ARG_VAR_INIT); -#endif /* GL_EXT_blend_func_separate */ -#ifdef GL_EXT_blend_logic_op - CONST_CAST(GLEW_EXT_blend_logic_op) = glewGetExtension("GL_EXT_blend_logic_op"); -#endif /* GL_EXT_blend_logic_op */ -#ifdef GL_EXT_blend_minmax - CONST_CAST(GLEW_EXT_blend_minmax) = glewGetExtension("GL_EXT_blend_minmax"); - if (glewExperimental || GLEW_EXT_blend_minmax) CONST_CAST(GLEW_EXT_blend_minmax) = !_glewInit_GL_EXT_blend_minmax(GLEW_CONTEXT_ARG_VAR_INIT); -#endif /* GL_EXT_blend_minmax */ -#ifdef GL_EXT_blend_subtract - CONST_CAST(GLEW_EXT_blend_subtract) = glewGetExtension("GL_EXT_blend_subtract"); -#endif /* GL_EXT_blend_subtract */ -#ifdef GL_EXT_clip_volume_hint - CONST_CAST(GLEW_EXT_clip_volume_hint) = glewGetExtension("GL_EXT_clip_volume_hint"); -#endif /* GL_EXT_clip_volume_hint */ -#ifdef GL_EXT_cmyka - CONST_CAST(GLEW_EXT_cmyka) = glewGetExtension("GL_EXT_cmyka"); -#endif /* GL_EXT_cmyka */ -#ifdef GL_EXT_color_subtable - CONST_CAST(GLEW_EXT_color_subtable) = glewGetExtension("GL_EXT_color_subtable"); - if (glewExperimental || GLEW_EXT_color_subtable) CONST_CAST(GLEW_EXT_color_subtable) = !_glewInit_GL_EXT_color_subtable(GLEW_CONTEXT_ARG_VAR_INIT); -#endif /* GL_EXT_color_subtable */ -#ifdef GL_EXT_compiled_vertex_array - CONST_CAST(GLEW_EXT_compiled_vertex_array) = glewGetExtension("GL_EXT_compiled_vertex_array"); - if (glewExperimental || GLEW_EXT_compiled_vertex_array) CONST_CAST(GLEW_EXT_compiled_vertex_array) = !_glewInit_GL_EXT_compiled_vertex_array(GLEW_CONTEXT_ARG_VAR_INIT); -#endif /* GL_EXT_compiled_vertex_array */ -#ifdef GL_EXT_convolution - CONST_CAST(GLEW_EXT_convolution) = glewGetExtension("GL_EXT_convolution"); - if (glewExperimental || GLEW_EXT_convolution) CONST_CAST(GLEW_EXT_convolution) = !_glewInit_GL_EXT_convolution(GLEW_CONTEXT_ARG_VAR_INIT); -#endif /* GL_EXT_convolution */ -#ifdef GL_EXT_coordinate_frame - CONST_CAST(GLEW_EXT_coordinate_frame) = glewGetExtension("GL_EXT_coordinate_frame"); - if (glewExperimental || GLEW_EXT_coordinate_frame) CONST_CAST(GLEW_EXT_coordinate_frame) = !_glewInit_GL_EXT_coordinate_frame(GLEW_CONTEXT_ARG_VAR_INIT); -#endif /* GL_EXT_coordinate_frame */ -#ifdef GL_EXT_copy_texture - CONST_CAST(GLEW_EXT_copy_texture) = glewGetExtension("GL_EXT_copy_texture"); - if (glewExperimental || GLEW_EXT_copy_texture) CONST_CAST(GLEW_EXT_copy_texture) = !_glewInit_GL_EXT_copy_texture(GLEW_CONTEXT_ARG_VAR_INIT); -#endif /* GL_EXT_copy_texture */ -#ifdef GL_EXT_cull_vertex - CONST_CAST(GLEW_EXT_cull_vertex) = glewGetExtension("GL_EXT_cull_vertex"); - if (glewExperimental || GLEW_EXT_cull_vertex) CONST_CAST(GLEW_EXT_cull_vertex) = !_glewInit_GL_EXT_cull_vertex(GLEW_CONTEXT_ARG_VAR_INIT); -#endif /* GL_EXT_cull_vertex */ -#ifdef GL_EXT_depth_bounds_test - CONST_CAST(GLEW_EXT_depth_bounds_test) = glewGetExtension("GL_EXT_depth_bounds_test"); - if (glewExperimental || GLEW_EXT_depth_bounds_test) CONST_CAST(GLEW_EXT_depth_bounds_test) = !_glewInit_GL_EXT_depth_bounds_test(GLEW_CONTEXT_ARG_VAR_INIT); -#endif /* GL_EXT_depth_bounds_test */ -#ifdef GL_EXT_direct_state_access - CONST_CAST(GLEW_EXT_direct_state_access) = glewGetExtension("GL_EXT_direct_state_access"); - if (glewExperimental || GLEW_EXT_direct_state_access) CONST_CAST(GLEW_EXT_direct_state_access) = !_glewInit_GL_EXT_direct_state_access(GLEW_CONTEXT_ARG_VAR_INIT); -#endif /* GL_EXT_direct_state_access */ -#ifdef GL_EXT_draw_buffers2 - CONST_CAST(GLEW_EXT_draw_buffers2) = glewGetExtension("GL_EXT_draw_buffers2"); - if (glewExperimental || GLEW_EXT_draw_buffers2) CONST_CAST(GLEW_EXT_draw_buffers2) = !_glewInit_GL_EXT_draw_buffers2(GLEW_CONTEXT_ARG_VAR_INIT); -#endif /* GL_EXT_draw_buffers2 */ -#ifdef GL_EXT_draw_instanced - CONST_CAST(GLEW_EXT_draw_instanced) = glewGetExtension("GL_EXT_draw_instanced"); - if (glewExperimental || GLEW_EXT_draw_instanced) CONST_CAST(GLEW_EXT_draw_instanced) = !_glewInit_GL_EXT_draw_instanced(GLEW_CONTEXT_ARG_VAR_INIT); -#endif /* GL_EXT_draw_instanced */ -#ifdef GL_EXT_draw_range_elements - CONST_CAST(GLEW_EXT_draw_range_elements) = glewGetExtension("GL_EXT_draw_range_elements"); - if (glewExperimental || GLEW_EXT_draw_range_elements) CONST_CAST(GLEW_EXT_draw_range_elements) = !_glewInit_GL_EXT_draw_range_elements(GLEW_CONTEXT_ARG_VAR_INIT); -#endif /* GL_EXT_draw_range_elements */ -#ifdef GL_EXT_fog_coord - CONST_CAST(GLEW_EXT_fog_coord) = glewGetExtension("GL_EXT_fog_coord"); - if (glewExperimental || GLEW_EXT_fog_coord) CONST_CAST(GLEW_EXT_fog_coord) = !_glewInit_GL_EXT_fog_coord(GLEW_CONTEXT_ARG_VAR_INIT); -#endif /* GL_EXT_fog_coord */ -#ifdef GL_EXT_fragment_lighting - CONST_CAST(GLEW_EXT_fragment_lighting) = glewGetExtension("GL_EXT_fragment_lighting"); - if (glewExperimental || GLEW_EXT_fragment_lighting) CONST_CAST(GLEW_EXT_fragment_lighting) = !_glewInit_GL_EXT_fragment_lighting(GLEW_CONTEXT_ARG_VAR_INIT); -#endif /* GL_EXT_fragment_lighting */ -#ifdef GL_EXT_framebuffer_blit - CONST_CAST(GLEW_EXT_framebuffer_blit) = glewGetExtension("GL_EXT_framebuffer_blit"); - if (glewExperimental || GLEW_EXT_framebuffer_blit) CONST_CAST(GLEW_EXT_framebuffer_blit) = !_glewInit_GL_EXT_framebuffer_blit(GLEW_CONTEXT_ARG_VAR_INIT); -#endif /* GL_EXT_framebuffer_blit */ -#ifdef GL_EXT_framebuffer_multisample - CONST_CAST(GLEW_EXT_framebuffer_multisample) = glewGetExtension("GL_EXT_framebuffer_multisample"); - if (glewExperimental || GLEW_EXT_framebuffer_multisample) CONST_CAST(GLEW_EXT_framebuffer_multisample) = !_glewInit_GL_EXT_framebuffer_multisample(GLEW_CONTEXT_ARG_VAR_INIT); -#endif /* GL_EXT_framebuffer_multisample */ -#ifdef GL_EXT_framebuffer_object - CONST_CAST(GLEW_EXT_framebuffer_object) = glewGetExtension("GL_EXT_framebuffer_object"); - if (glewExperimental || GLEW_EXT_framebuffer_object) CONST_CAST(GLEW_EXT_framebuffer_object) = !_glewInit_GL_EXT_framebuffer_object(GLEW_CONTEXT_ARG_VAR_INIT); -#endif /* GL_EXT_framebuffer_object */ -#ifdef GL_EXT_framebuffer_sRGB - CONST_CAST(GLEW_EXT_framebuffer_sRGB) = glewGetExtension("GL_EXT_framebuffer_sRGB"); -#endif /* GL_EXT_framebuffer_sRGB */ -#ifdef GL_EXT_geometry_shader4 - CONST_CAST(GLEW_EXT_geometry_shader4) = glewGetExtension("GL_EXT_geometry_shader4"); - if (glewExperimental || GLEW_EXT_geometry_shader4) CONST_CAST(GLEW_EXT_geometry_shader4) = !_glewInit_GL_EXT_geometry_shader4(GLEW_CONTEXT_ARG_VAR_INIT); -#endif /* GL_EXT_geometry_shader4 */ -#ifdef GL_EXT_gpu_program_parameters - CONST_CAST(GLEW_EXT_gpu_program_parameters) = glewGetExtension("GL_EXT_gpu_program_parameters"); - if (glewExperimental || GLEW_EXT_gpu_program_parameters) CONST_CAST(GLEW_EXT_gpu_program_parameters) = !_glewInit_GL_EXT_gpu_program_parameters(GLEW_CONTEXT_ARG_VAR_INIT); -#endif /* GL_EXT_gpu_program_parameters */ -#ifdef GL_EXT_gpu_shader4 - CONST_CAST(GLEW_EXT_gpu_shader4) = glewGetExtension("GL_EXT_gpu_shader4"); - if (glewExperimental || GLEW_EXT_gpu_shader4) CONST_CAST(GLEW_EXT_gpu_shader4) = !_glewInit_GL_EXT_gpu_shader4(GLEW_CONTEXT_ARG_VAR_INIT); -#endif /* GL_EXT_gpu_shader4 */ -#ifdef GL_EXT_histogram - CONST_CAST(GLEW_EXT_histogram) = glewGetExtension("GL_EXT_histogram"); - if (glewExperimental || GLEW_EXT_histogram) CONST_CAST(GLEW_EXT_histogram) = !_glewInit_GL_EXT_histogram(GLEW_CONTEXT_ARG_VAR_INIT); -#endif /* GL_EXT_histogram */ -#ifdef GL_EXT_index_array_formats - CONST_CAST(GLEW_EXT_index_array_formats) = glewGetExtension("GL_EXT_index_array_formats"); -#endif /* GL_EXT_index_array_formats */ -#ifdef GL_EXT_index_func - CONST_CAST(GLEW_EXT_index_func) = glewGetExtension("GL_EXT_index_func"); - if (glewExperimental || GLEW_EXT_index_func) CONST_CAST(GLEW_EXT_index_func) = !_glewInit_GL_EXT_index_func(GLEW_CONTEXT_ARG_VAR_INIT); -#endif /* GL_EXT_index_func */ -#ifdef GL_EXT_index_material - CONST_CAST(GLEW_EXT_index_material) = glewGetExtension("GL_EXT_index_material"); - if (glewExperimental || GLEW_EXT_index_material) CONST_CAST(GLEW_EXT_index_material) = !_glewInit_GL_EXT_index_material(GLEW_CONTEXT_ARG_VAR_INIT); -#endif /* GL_EXT_index_material */ -#ifdef GL_EXT_index_texture - CONST_CAST(GLEW_EXT_index_texture) = glewGetExtension("GL_EXT_index_texture"); -#endif /* GL_EXT_index_texture */ -#ifdef GL_EXT_light_texture - CONST_CAST(GLEW_EXT_light_texture) = glewGetExtension("GL_EXT_light_texture"); - if (glewExperimental || GLEW_EXT_light_texture) CONST_CAST(GLEW_EXT_light_texture) = !_glewInit_GL_EXT_light_texture(GLEW_CONTEXT_ARG_VAR_INIT); -#endif /* GL_EXT_light_texture */ -#ifdef GL_EXT_misc_attribute - CONST_CAST(GLEW_EXT_misc_attribute) = glewGetExtension("GL_EXT_misc_attribute"); -#endif /* GL_EXT_misc_attribute */ -#ifdef GL_EXT_multi_draw_arrays - CONST_CAST(GLEW_EXT_multi_draw_arrays) = glewGetExtension("GL_EXT_multi_draw_arrays"); - if (glewExperimental || GLEW_EXT_multi_draw_arrays) CONST_CAST(GLEW_EXT_multi_draw_arrays) = !_glewInit_GL_EXT_multi_draw_arrays(GLEW_CONTEXT_ARG_VAR_INIT); -#endif /* GL_EXT_multi_draw_arrays */ -#ifdef GL_EXT_multisample - CONST_CAST(GLEW_EXT_multisample) = glewGetExtension("GL_EXT_multisample"); - if (glewExperimental || GLEW_EXT_multisample) CONST_CAST(GLEW_EXT_multisample) = !_glewInit_GL_EXT_multisample(GLEW_CONTEXT_ARG_VAR_INIT); -#endif /* GL_EXT_multisample */ -#ifdef GL_EXT_packed_depth_stencil - CONST_CAST(GLEW_EXT_packed_depth_stencil) = glewGetExtension("GL_EXT_packed_depth_stencil"); -#endif /* GL_EXT_packed_depth_stencil */ -#ifdef GL_EXT_packed_float - CONST_CAST(GLEW_EXT_packed_float) = glewGetExtension("GL_EXT_packed_float"); -#endif /* GL_EXT_packed_float */ -#ifdef GL_EXT_packed_pixels - CONST_CAST(GLEW_EXT_packed_pixels) = glewGetExtension("GL_EXT_packed_pixels"); -#endif /* GL_EXT_packed_pixels */ -#ifdef GL_EXT_paletted_texture - CONST_CAST(GLEW_EXT_paletted_texture) = glewGetExtension("GL_EXT_paletted_texture"); - if (glewExperimental || GLEW_EXT_paletted_texture) CONST_CAST(GLEW_EXT_paletted_texture) = !_glewInit_GL_EXT_paletted_texture(GLEW_CONTEXT_ARG_VAR_INIT); -#endif /* GL_EXT_paletted_texture */ -#ifdef GL_EXT_pixel_buffer_object - CONST_CAST(GLEW_EXT_pixel_buffer_object) = glewGetExtension("GL_EXT_pixel_buffer_object"); -#endif /* GL_EXT_pixel_buffer_object */ -#ifdef GL_EXT_pixel_transform - CONST_CAST(GLEW_EXT_pixel_transform) = glewGetExtension("GL_EXT_pixel_transform"); - if (glewExperimental || GLEW_EXT_pixel_transform) CONST_CAST(GLEW_EXT_pixel_transform) = !_glewInit_GL_EXT_pixel_transform(GLEW_CONTEXT_ARG_VAR_INIT); -#endif /* GL_EXT_pixel_transform */ -#ifdef GL_EXT_pixel_transform_color_table - CONST_CAST(GLEW_EXT_pixel_transform_color_table) = glewGetExtension("GL_EXT_pixel_transform_color_table"); -#endif /* GL_EXT_pixel_transform_color_table */ -#ifdef GL_EXT_point_parameters - CONST_CAST(GLEW_EXT_point_parameters) = glewGetExtension("GL_EXT_point_parameters"); - if (glewExperimental || GLEW_EXT_point_parameters) CONST_CAST(GLEW_EXT_point_parameters) = !_glewInit_GL_EXT_point_parameters(GLEW_CONTEXT_ARG_VAR_INIT); -#endif /* GL_EXT_point_parameters */ -#ifdef GL_EXT_polygon_offset - CONST_CAST(GLEW_EXT_polygon_offset) = glewGetExtension("GL_EXT_polygon_offset"); - if (glewExperimental || GLEW_EXT_polygon_offset) CONST_CAST(GLEW_EXT_polygon_offset) = !_glewInit_GL_EXT_polygon_offset(GLEW_CONTEXT_ARG_VAR_INIT); -#endif /* GL_EXT_polygon_offset */ -#ifdef GL_EXT_rescale_normal - CONST_CAST(GLEW_EXT_rescale_normal) = glewGetExtension("GL_EXT_rescale_normal"); -#endif /* GL_EXT_rescale_normal */ -#ifdef GL_EXT_scene_marker - CONST_CAST(GLEW_EXT_scene_marker) = glewGetExtension("GL_EXT_scene_marker"); - if (glewExperimental || GLEW_EXT_scene_marker) CONST_CAST(GLEW_EXT_scene_marker) = !_glewInit_GL_EXT_scene_marker(GLEW_CONTEXT_ARG_VAR_INIT); -#endif /* GL_EXT_scene_marker */ -#ifdef GL_EXT_secondary_color - CONST_CAST(GLEW_EXT_secondary_color) = glewGetExtension("GL_EXT_secondary_color"); - if (glewExperimental || GLEW_EXT_secondary_color) CONST_CAST(GLEW_EXT_secondary_color) = !_glewInit_GL_EXT_secondary_color(GLEW_CONTEXT_ARG_VAR_INIT); -#endif /* GL_EXT_secondary_color */ -#ifdef GL_EXT_separate_specular_color - CONST_CAST(GLEW_EXT_separate_specular_color) = glewGetExtension("GL_EXT_separate_specular_color"); -#endif /* GL_EXT_separate_specular_color */ -#ifdef GL_EXT_shadow_funcs - CONST_CAST(GLEW_EXT_shadow_funcs) = glewGetExtension("GL_EXT_shadow_funcs"); -#endif /* GL_EXT_shadow_funcs */ -#ifdef GL_EXT_shared_texture_palette - CONST_CAST(GLEW_EXT_shared_texture_palette) = glewGetExtension("GL_EXT_shared_texture_palette"); -#endif /* GL_EXT_shared_texture_palette */ -#ifdef GL_EXT_stencil_clear_tag - CONST_CAST(GLEW_EXT_stencil_clear_tag) = glewGetExtension("GL_EXT_stencil_clear_tag"); -#endif /* GL_EXT_stencil_clear_tag */ -#ifdef GL_EXT_stencil_two_side - CONST_CAST(GLEW_EXT_stencil_two_side) = glewGetExtension("GL_EXT_stencil_two_side"); - if (glewExperimental || GLEW_EXT_stencil_two_side) CONST_CAST(GLEW_EXT_stencil_two_side) = !_glewInit_GL_EXT_stencil_two_side(GLEW_CONTEXT_ARG_VAR_INIT); -#endif /* GL_EXT_stencil_two_side */ -#ifdef GL_EXT_stencil_wrap - CONST_CAST(GLEW_EXT_stencil_wrap) = glewGetExtension("GL_EXT_stencil_wrap"); -#endif /* GL_EXT_stencil_wrap */ -#ifdef GL_EXT_subtexture - CONST_CAST(GLEW_EXT_subtexture) = glewGetExtension("GL_EXT_subtexture"); - if (glewExperimental || GLEW_EXT_subtexture) CONST_CAST(GLEW_EXT_subtexture) = !_glewInit_GL_EXT_subtexture(GLEW_CONTEXT_ARG_VAR_INIT); -#endif /* GL_EXT_subtexture */ -#ifdef GL_EXT_texture - CONST_CAST(GLEW_EXT_texture) = glewGetExtension("GL_EXT_texture"); -#endif /* GL_EXT_texture */ -#ifdef GL_EXT_texture3D - CONST_CAST(GLEW_EXT_texture3D) = glewGetExtension("GL_EXT_texture3D"); - if (glewExperimental || GLEW_EXT_texture3D) CONST_CAST(GLEW_EXT_texture3D) = !_glewInit_GL_EXT_texture3D(GLEW_CONTEXT_ARG_VAR_INIT); -#endif /* GL_EXT_texture3D */ -#ifdef GL_EXT_texture_array - CONST_CAST(GLEW_EXT_texture_array) = glewGetExtension("GL_EXT_texture_array"); -#endif /* GL_EXT_texture_array */ -#ifdef GL_EXT_texture_buffer_object - CONST_CAST(GLEW_EXT_texture_buffer_object) = glewGetExtension("GL_EXT_texture_buffer_object"); - if (glewExperimental || GLEW_EXT_texture_buffer_object) CONST_CAST(GLEW_EXT_texture_buffer_object) = !_glewInit_GL_EXT_texture_buffer_object(GLEW_CONTEXT_ARG_VAR_INIT); -#endif /* GL_EXT_texture_buffer_object */ -#ifdef GL_EXT_texture_compression_dxt1 - CONST_CAST(GLEW_EXT_texture_compression_dxt1) = glewGetExtension("GL_EXT_texture_compression_dxt1"); -#endif /* GL_EXT_texture_compression_dxt1 */ -#ifdef GL_EXT_texture_compression_latc - CONST_CAST(GLEW_EXT_texture_compression_latc) = glewGetExtension("GL_EXT_texture_compression_latc"); -#endif /* GL_EXT_texture_compression_latc */ -#ifdef GL_EXT_texture_compression_rgtc - CONST_CAST(GLEW_EXT_texture_compression_rgtc) = glewGetExtension("GL_EXT_texture_compression_rgtc"); -#endif /* GL_EXT_texture_compression_rgtc */ -#ifdef GL_EXT_texture_compression_s3tc - CONST_CAST(GLEW_EXT_texture_compression_s3tc) = glewGetExtension("GL_EXT_texture_compression_s3tc"); -#endif /* GL_EXT_texture_compression_s3tc */ -#ifdef GL_EXT_texture_cube_map - CONST_CAST(GLEW_EXT_texture_cube_map) = glewGetExtension("GL_EXT_texture_cube_map"); -#endif /* GL_EXT_texture_cube_map */ -#ifdef GL_EXT_texture_edge_clamp - CONST_CAST(GLEW_EXT_texture_edge_clamp) = glewGetExtension("GL_EXT_texture_edge_clamp"); -#endif /* GL_EXT_texture_edge_clamp */ -#ifdef GL_EXT_texture_env - CONST_CAST(GLEW_EXT_texture_env) = glewGetExtension("GL_EXT_texture_env"); -#endif /* GL_EXT_texture_env */ -#ifdef GL_EXT_texture_env_add - CONST_CAST(GLEW_EXT_texture_env_add) = glewGetExtension("GL_EXT_texture_env_add"); -#endif /* GL_EXT_texture_env_add */ -#ifdef GL_EXT_texture_env_combine - CONST_CAST(GLEW_EXT_texture_env_combine) = glewGetExtension("GL_EXT_texture_env_combine"); -#endif /* GL_EXT_texture_env_combine */ -#ifdef GL_EXT_texture_env_dot3 - CONST_CAST(GLEW_EXT_texture_env_dot3) = glewGetExtension("GL_EXT_texture_env_dot3"); -#endif /* GL_EXT_texture_env_dot3 */ -#ifdef GL_EXT_texture_filter_anisotropic - CONST_CAST(GLEW_EXT_texture_filter_anisotropic) = glewGetExtension("GL_EXT_texture_filter_anisotropic"); -#endif /* GL_EXT_texture_filter_anisotropic */ -#ifdef GL_EXT_texture_integer - CONST_CAST(GLEW_EXT_texture_integer) = glewGetExtension("GL_EXT_texture_integer"); - if (glewExperimental || GLEW_EXT_texture_integer) CONST_CAST(GLEW_EXT_texture_integer) = !_glewInit_GL_EXT_texture_integer(GLEW_CONTEXT_ARG_VAR_INIT); -#endif /* GL_EXT_texture_integer */ -#ifdef GL_EXT_texture_lod_bias - CONST_CAST(GLEW_EXT_texture_lod_bias) = glewGetExtension("GL_EXT_texture_lod_bias"); -#endif /* GL_EXT_texture_lod_bias */ -#ifdef GL_EXT_texture_mirror_clamp - CONST_CAST(GLEW_EXT_texture_mirror_clamp) = glewGetExtension("GL_EXT_texture_mirror_clamp"); -#endif /* GL_EXT_texture_mirror_clamp */ -#ifdef GL_EXT_texture_object - CONST_CAST(GLEW_EXT_texture_object) = glewGetExtension("GL_EXT_texture_object"); - if (glewExperimental || GLEW_EXT_texture_object) CONST_CAST(GLEW_EXT_texture_object) = !_glewInit_GL_EXT_texture_object(GLEW_CONTEXT_ARG_VAR_INIT); -#endif /* GL_EXT_texture_object */ -#ifdef GL_EXT_texture_perturb_normal - CONST_CAST(GLEW_EXT_texture_perturb_normal) = glewGetExtension("GL_EXT_texture_perturb_normal"); - if (glewExperimental || GLEW_EXT_texture_perturb_normal) CONST_CAST(GLEW_EXT_texture_perturb_normal) = !_glewInit_GL_EXT_texture_perturb_normal(GLEW_CONTEXT_ARG_VAR_INIT); -#endif /* GL_EXT_texture_perturb_normal */ -#ifdef GL_EXT_texture_rectangle - CONST_CAST(GLEW_EXT_texture_rectangle) = glewGetExtension("GL_EXT_texture_rectangle"); -#endif /* GL_EXT_texture_rectangle */ -#ifdef GL_EXT_texture_sRGB - CONST_CAST(GLEW_EXT_texture_sRGB) = glewGetExtension("GL_EXT_texture_sRGB"); -#endif /* GL_EXT_texture_sRGB */ -#ifdef GL_EXT_texture_shared_exponent - CONST_CAST(GLEW_EXT_texture_shared_exponent) = glewGetExtension("GL_EXT_texture_shared_exponent"); -#endif /* GL_EXT_texture_shared_exponent */ -#ifdef GL_EXT_texture_swizzle - CONST_CAST(GLEW_EXT_texture_swizzle) = glewGetExtension("GL_EXT_texture_swizzle"); -#endif /* GL_EXT_texture_swizzle */ -#ifdef GL_EXT_timer_query - CONST_CAST(GLEW_EXT_timer_query) = glewGetExtension("GL_EXT_timer_query"); - if (glewExperimental || GLEW_EXT_timer_query) CONST_CAST(GLEW_EXT_timer_query) = !_glewInit_GL_EXT_timer_query(GLEW_CONTEXT_ARG_VAR_INIT); -#endif /* GL_EXT_timer_query */ -#ifdef GL_EXT_transform_feedback - CONST_CAST(GLEW_EXT_transform_feedback) = glewGetExtension("GL_EXT_transform_feedback"); - if (glewExperimental || GLEW_EXT_transform_feedback) CONST_CAST(GLEW_EXT_transform_feedback) = !_glewInit_GL_EXT_transform_feedback(GLEW_CONTEXT_ARG_VAR_INIT); -#endif /* GL_EXT_transform_feedback */ -#ifdef GL_EXT_vertex_array - CONST_CAST(GLEW_EXT_vertex_array) = glewGetExtension("GL_EXT_vertex_array"); - if (glewExperimental || GLEW_EXT_vertex_array) CONST_CAST(GLEW_EXT_vertex_array) = !_glewInit_GL_EXT_vertex_array(GLEW_CONTEXT_ARG_VAR_INIT); -#endif /* GL_EXT_vertex_array */ -#ifdef GL_EXT_vertex_array_bgra - CONST_CAST(GLEW_EXT_vertex_array_bgra) = glewGetExtension("GL_EXT_vertex_array_bgra"); -#endif /* GL_EXT_vertex_array_bgra */ -#ifdef GL_EXT_vertex_shader - CONST_CAST(GLEW_EXT_vertex_shader) = glewGetExtension("GL_EXT_vertex_shader"); - if (glewExperimental || GLEW_EXT_vertex_shader) CONST_CAST(GLEW_EXT_vertex_shader) = !_glewInit_GL_EXT_vertex_shader(GLEW_CONTEXT_ARG_VAR_INIT); -#endif /* GL_EXT_vertex_shader */ -#ifdef GL_EXT_vertex_weighting - CONST_CAST(GLEW_EXT_vertex_weighting) = glewGetExtension("GL_EXT_vertex_weighting"); - if (glewExperimental || GLEW_EXT_vertex_weighting) CONST_CAST(GLEW_EXT_vertex_weighting) = !_glewInit_GL_EXT_vertex_weighting(GLEW_CONTEXT_ARG_VAR_INIT); -#endif /* GL_EXT_vertex_weighting */ -#ifdef GL_GREMEDY_frame_terminator - CONST_CAST(GLEW_GREMEDY_frame_terminator) = glewGetExtension("GL_GREMEDY_frame_terminator"); - if (glewExperimental || GLEW_GREMEDY_frame_terminator) CONST_CAST(GLEW_GREMEDY_frame_terminator) = !_glewInit_GL_GREMEDY_frame_terminator(GLEW_CONTEXT_ARG_VAR_INIT); -#endif /* GL_GREMEDY_frame_terminator */ -#ifdef GL_GREMEDY_string_marker - CONST_CAST(GLEW_GREMEDY_string_marker) = glewGetExtension("GL_GREMEDY_string_marker"); - if (glewExperimental || GLEW_GREMEDY_string_marker) CONST_CAST(GLEW_GREMEDY_string_marker) = !_glewInit_GL_GREMEDY_string_marker(GLEW_CONTEXT_ARG_VAR_INIT); -#endif /* GL_GREMEDY_string_marker */ -#ifdef GL_HP_convolution_border_modes - CONST_CAST(GLEW_HP_convolution_border_modes) = glewGetExtension("GL_HP_convolution_border_modes"); -#endif /* GL_HP_convolution_border_modes */ -#ifdef GL_HP_image_transform - CONST_CAST(GLEW_HP_image_transform) = glewGetExtension("GL_HP_image_transform"); - if (glewExperimental || GLEW_HP_image_transform) CONST_CAST(GLEW_HP_image_transform) = !_glewInit_GL_HP_image_transform(GLEW_CONTEXT_ARG_VAR_INIT); -#endif /* GL_HP_image_transform */ -#ifdef GL_HP_occlusion_test - CONST_CAST(GLEW_HP_occlusion_test) = glewGetExtension("GL_HP_occlusion_test"); -#endif /* GL_HP_occlusion_test */ -#ifdef GL_HP_texture_lighting - CONST_CAST(GLEW_HP_texture_lighting) = glewGetExtension("GL_HP_texture_lighting"); -#endif /* GL_HP_texture_lighting */ -#ifdef GL_IBM_cull_vertex - CONST_CAST(GLEW_IBM_cull_vertex) = glewGetExtension("GL_IBM_cull_vertex"); -#endif /* GL_IBM_cull_vertex */ -#ifdef GL_IBM_multimode_draw_arrays - CONST_CAST(GLEW_IBM_multimode_draw_arrays) = glewGetExtension("GL_IBM_multimode_draw_arrays"); - if (glewExperimental || GLEW_IBM_multimode_draw_arrays) CONST_CAST(GLEW_IBM_multimode_draw_arrays) = !_glewInit_GL_IBM_multimode_draw_arrays(GLEW_CONTEXT_ARG_VAR_INIT); -#endif /* GL_IBM_multimode_draw_arrays */ -#ifdef GL_IBM_rasterpos_clip - CONST_CAST(GLEW_IBM_rasterpos_clip) = glewGetExtension("GL_IBM_rasterpos_clip"); -#endif /* GL_IBM_rasterpos_clip */ -#ifdef GL_IBM_static_data - CONST_CAST(GLEW_IBM_static_data) = glewGetExtension("GL_IBM_static_data"); -#endif /* GL_IBM_static_data */ -#ifdef GL_IBM_texture_mirrored_repeat - CONST_CAST(GLEW_IBM_texture_mirrored_repeat) = glewGetExtension("GL_IBM_texture_mirrored_repeat"); -#endif /* GL_IBM_texture_mirrored_repeat */ -#ifdef GL_IBM_vertex_array_lists - CONST_CAST(GLEW_IBM_vertex_array_lists) = glewGetExtension("GL_IBM_vertex_array_lists"); - if (glewExperimental || GLEW_IBM_vertex_array_lists) CONST_CAST(GLEW_IBM_vertex_array_lists) = !_glewInit_GL_IBM_vertex_array_lists(GLEW_CONTEXT_ARG_VAR_INIT); -#endif /* GL_IBM_vertex_array_lists */ -#ifdef GL_INGR_color_clamp - CONST_CAST(GLEW_INGR_color_clamp) = glewGetExtension("GL_INGR_color_clamp"); -#endif /* GL_INGR_color_clamp */ -#ifdef GL_INGR_interlace_read - CONST_CAST(GLEW_INGR_interlace_read) = glewGetExtension("GL_INGR_interlace_read"); -#endif /* GL_INGR_interlace_read */ -#ifdef GL_INTEL_parallel_arrays - CONST_CAST(GLEW_INTEL_parallel_arrays) = glewGetExtension("GL_INTEL_parallel_arrays"); - if (glewExperimental || GLEW_INTEL_parallel_arrays) CONST_CAST(GLEW_INTEL_parallel_arrays) = !_glewInit_GL_INTEL_parallel_arrays(GLEW_CONTEXT_ARG_VAR_INIT); -#endif /* GL_INTEL_parallel_arrays */ -#ifdef GL_INTEL_texture_scissor - CONST_CAST(GLEW_INTEL_texture_scissor) = glewGetExtension("GL_INTEL_texture_scissor"); - if (glewExperimental || GLEW_INTEL_texture_scissor) CONST_CAST(GLEW_INTEL_texture_scissor) = !_glewInit_GL_INTEL_texture_scissor(GLEW_CONTEXT_ARG_VAR_INIT); -#endif /* GL_INTEL_texture_scissor */ -#ifdef GL_KTX_buffer_region - CONST_CAST(GLEW_KTX_buffer_region) = glewGetExtension("GL_KTX_buffer_region"); - if (glewExperimental || GLEW_KTX_buffer_region) CONST_CAST(GLEW_KTX_buffer_region) = !_glewInit_GL_KTX_buffer_region(GLEW_CONTEXT_ARG_VAR_INIT); -#endif /* GL_KTX_buffer_region */ -#ifdef GL_MESAX_texture_stack - CONST_CAST(GLEW_MESAX_texture_stack) = glewGetExtension("GL_MESAX_texture_stack"); -#endif /* GL_MESAX_texture_stack */ -#ifdef GL_MESA_pack_invert - CONST_CAST(GLEW_MESA_pack_invert) = glewGetExtension("GL_MESA_pack_invert"); -#endif /* GL_MESA_pack_invert */ -#ifdef GL_MESA_resize_buffers - CONST_CAST(GLEW_MESA_resize_buffers) = glewGetExtension("GL_MESA_resize_buffers"); - if (glewExperimental || GLEW_MESA_resize_buffers) CONST_CAST(GLEW_MESA_resize_buffers) = !_glewInit_GL_MESA_resize_buffers(GLEW_CONTEXT_ARG_VAR_INIT); -#endif /* GL_MESA_resize_buffers */ -#ifdef GL_MESA_window_pos - CONST_CAST(GLEW_MESA_window_pos) = glewGetExtension("GL_MESA_window_pos"); - if (glewExperimental || GLEW_MESA_window_pos) CONST_CAST(GLEW_MESA_window_pos) = !_glewInit_GL_MESA_window_pos(GLEW_CONTEXT_ARG_VAR_INIT); -#endif /* GL_MESA_window_pos */ -#ifdef GL_MESA_ycbcr_texture - CONST_CAST(GLEW_MESA_ycbcr_texture) = glewGetExtension("GL_MESA_ycbcr_texture"); -#endif /* GL_MESA_ycbcr_texture */ -#ifdef GL_NV_blend_square - CONST_CAST(GLEW_NV_blend_square) = glewGetExtension("GL_NV_blend_square"); -#endif /* GL_NV_blend_square */ -#ifdef GL_NV_conditional_render - CONST_CAST(GLEW_NV_conditional_render) = glewGetExtension("GL_NV_conditional_render"); - if (glewExperimental || GLEW_NV_conditional_render) CONST_CAST(GLEW_NV_conditional_render) = !_glewInit_GL_NV_conditional_render(GLEW_CONTEXT_ARG_VAR_INIT); -#endif /* GL_NV_conditional_render */ -#ifdef GL_NV_copy_depth_to_color - CONST_CAST(GLEW_NV_copy_depth_to_color) = glewGetExtension("GL_NV_copy_depth_to_color"); -#endif /* GL_NV_copy_depth_to_color */ -#ifdef GL_NV_depth_buffer_float - CONST_CAST(GLEW_NV_depth_buffer_float) = glewGetExtension("GL_NV_depth_buffer_float"); - if (glewExperimental || GLEW_NV_depth_buffer_float) CONST_CAST(GLEW_NV_depth_buffer_float) = !_glewInit_GL_NV_depth_buffer_float(GLEW_CONTEXT_ARG_VAR_INIT); -#endif /* GL_NV_depth_buffer_float */ -#ifdef GL_NV_depth_clamp - CONST_CAST(GLEW_NV_depth_clamp) = glewGetExtension("GL_NV_depth_clamp"); -#endif /* GL_NV_depth_clamp */ -#ifdef GL_NV_depth_range_unclamped - CONST_CAST(GLEW_NV_depth_range_unclamped) = glewGetExtension("GL_NV_depth_range_unclamped"); -#endif /* GL_NV_depth_range_unclamped */ -#ifdef GL_NV_evaluators - CONST_CAST(GLEW_NV_evaluators) = glewGetExtension("GL_NV_evaluators"); - if (glewExperimental || GLEW_NV_evaluators) CONST_CAST(GLEW_NV_evaluators) = !_glewInit_GL_NV_evaluators(GLEW_CONTEXT_ARG_VAR_INIT); -#endif /* GL_NV_evaluators */ -#ifdef GL_NV_explicit_multisample - CONST_CAST(GLEW_NV_explicit_multisample) = glewGetExtension("GL_NV_explicit_multisample"); - if (glewExperimental || GLEW_NV_explicit_multisample) CONST_CAST(GLEW_NV_explicit_multisample) = !_glewInit_GL_NV_explicit_multisample(GLEW_CONTEXT_ARG_VAR_INIT); -#endif /* GL_NV_explicit_multisample */ -#ifdef GL_NV_fence - CONST_CAST(GLEW_NV_fence) = glewGetExtension("GL_NV_fence"); - if (glewExperimental || GLEW_NV_fence) CONST_CAST(GLEW_NV_fence) = !_glewInit_GL_NV_fence(GLEW_CONTEXT_ARG_VAR_INIT); -#endif /* GL_NV_fence */ -#ifdef GL_NV_float_buffer - CONST_CAST(GLEW_NV_float_buffer) = glewGetExtension("GL_NV_float_buffer"); -#endif /* GL_NV_float_buffer */ -#ifdef GL_NV_fog_distance - CONST_CAST(GLEW_NV_fog_distance) = glewGetExtension("GL_NV_fog_distance"); -#endif /* GL_NV_fog_distance */ -#ifdef GL_NV_fragment_program - CONST_CAST(GLEW_NV_fragment_program) = glewGetExtension("GL_NV_fragment_program"); - if (glewExperimental || GLEW_NV_fragment_program) CONST_CAST(GLEW_NV_fragment_program) = !_glewInit_GL_NV_fragment_program(GLEW_CONTEXT_ARG_VAR_INIT); -#endif /* GL_NV_fragment_program */ -#ifdef GL_NV_fragment_program2 - CONST_CAST(GLEW_NV_fragment_program2) = glewGetExtension("GL_NV_fragment_program2"); -#endif /* GL_NV_fragment_program2 */ -#ifdef GL_NV_fragment_program4 - CONST_CAST(GLEW_NV_fragment_program4) = glewGetExtension("GL_NV_fragment_program4"); -#endif /* GL_NV_fragment_program4 */ -#ifdef GL_NV_fragment_program_option - CONST_CAST(GLEW_NV_fragment_program_option) = glewGetExtension("GL_NV_fragment_program_option"); -#endif /* GL_NV_fragment_program_option */ -#ifdef GL_NV_framebuffer_multisample_coverage - CONST_CAST(GLEW_NV_framebuffer_multisample_coverage) = glewGetExtension("GL_NV_framebuffer_multisample_coverage"); - if (glewExperimental || GLEW_NV_framebuffer_multisample_coverage) CONST_CAST(GLEW_NV_framebuffer_multisample_coverage) = !_glewInit_GL_NV_framebuffer_multisample_coverage(GLEW_CONTEXT_ARG_VAR_INIT); -#endif /* GL_NV_framebuffer_multisample_coverage */ -#ifdef GL_NV_geometry_program4 - CONST_CAST(GLEW_NV_geometry_program4) = glewGetExtension("GL_NV_geometry_program4"); - if (glewExperimental || GLEW_NV_geometry_program4) CONST_CAST(GLEW_NV_geometry_program4) = !_glewInit_GL_NV_geometry_program4(GLEW_CONTEXT_ARG_VAR_INIT); -#endif /* GL_NV_geometry_program4 */ -#ifdef GL_NV_geometry_shader4 - CONST_CAST(GLEW_NV_geometry_shader4) = glewGetExtension("GL_NV_geometry_shader4"); -#endif /* GL_NV_geometry_shader4 */ -#ifdef GL_NV_gpu_program4 - CONST_CAST(GLEW_NV_gpu_program4) = glewGetExtension("GL_NV_gpu_program4"); - if (glewExperimental || GLEW_NV_gpu_program4) CONST_CAST(GLEW_NV_gpu_program4) = !_glewInit_GL_NV_gpu_program4(GLEW_CONTEXT_ARG_VAR_INIT); -#endif /* GL_NV_gpu_program4 */ -#ifdef GL_NV_half_float - CONST_CAST(GLEW_NV_half_float) = glewGetExtension("GL_NV_half_float"); - if (glewExperimental || GLEW_NV_half_float) CONST_CAST(GLEW_NV_half_float) = !_glewInit_GL_NV_half_float(GLEW_CONTEXT_ARG_VAR_INIT); -#endif /* GL_NV_half_float */ -#ifdef GL_NV_light_max_exponent - CONST_CAST(GLEW_NV_light_max_exponent) = glewGetExtension("GL_NV_light_max_exponent"); -#endif /* GL_NV_light_max_exponent */ -#ifdef GL_NV_multisample_filter_hint - CONST_CAST(GLEW_NV_multisample_filter_hint) = glewGetExtension("GL_NV_multisample_filter_hint"); -#endif /* GL_NV_multisample_filter_hint */ -#ifdef GL_NV_occlusion_query - CONST_CAST(GLEW_NV_occlusion_query) = glewGetExtension("GL_NV_occlusion_query"); - if (glewExperimental || GLEW_NV_occlusion_query) CONST_CAST(GLEW_NV_occlusion_query) = !_glewInit_GL_NV_occlusion_query(GLEW_CONTEXT_ARG_VAR_INIT); -#endif /* GL_NV_occlusion_query */ -#ifdef GL_NV_packed_depth_stencil - CONST_CAST(GLEW_NV_packed_depth_stencil) = glewGetExtension("GL_NV_packed_depth_stencil"); -#endif /* GL_NV_packed_depth_stencil */ -#ifdef GL_NV_parameter_buffer_object - CONST_CAST(GLEW_NV_parameter_buffer_object) = glewGetExtension("GL_NV_parameter_buffer_object"); - if (glewExperimental || GLEW_NV_parameter_buffer_object) CONST_CAST(GLEW_NV_parameter_buffer_object) = !_glewInit_GL_NV_parameter_buffer_object(GLEW_CONTEXT_ARG_VAR_INIT); -#endif /* GL_NV_parameter_buffer_object */ -#ifdef GL_NV_pixel_data_range - CONST_CAST(GLEW_NV_pixel_data_range) = glewGetExtension("GL_NV_pixel_data_range"); - if (glewExperimental || GLEW_NV_pixel_data_range) CONST_CAST(GLEW_NV_pixel_data_range) = !_glewInit_GL_NV_pixel_data_range(GLEW_CONTEXT_ARG_VAR_INIT); -#endif /* GL_NV_pixel_data_range */ -#ifdef GL_NV_point_sprite - CONST_CAST(GLEW_NV_point_sprite) = glewGetExtension("GL_NV_point_sprite"); - if (glewExperimental || GLEW_NV_point_sprite) CONST_CAST(GLEW_NV_point_sprite) = !_glewInit_GL_NV_point_sprite(GLEW_CONTEXT_ARG_VAR_INIT); -#endif /* GL_NV_point_sprite */ -#ifdef GL_NV_present_video - CONST_CAST(GLEW_NV_present_video) = glewGetExtension("GL_NV_present_video"); - if (glewExperimental || GLEW_NV_present_video) CONST_CAST(GLEW_NV_present_video) = !_glewInit_GL_NV_present_video(GLEW_CONTEXT_ARG_VAR_INIT); -#endif /* GL_NV_present_video */ -#ifdef GL_NV_primitive_restart - CONST_CAST(GLEW_NV_primitive_restart) = glewGetExtension("GL_NV_primitive_restart"); - if (glewExperimental || GLEW_NV_primitive_restart) CONST_CAST(GLEW_NV_primitive_restart) = !_glewInit_GL_NV_primitive_restart(GLEW_CONTEXT_ARG_VAR_INIT); -#endif /* GL_NV_primitive_restart */ -#ifdef GL_NV_register_combiners - CONST_CAST(GLEW_NV_register_combiners) = glewGetExtension("GL_NV_register_combiners"); - if (glewExperimental || GLEW_NV_register_combiners) CONST_CAST(GLEW_NV_register_combiners) = !_glewInit_GL_NV_register_combiners(GLEW_CONTEXT_ARG_VAR_INIT); -#endif /* GL_NV_register_combiners */ -#ifdef GL_NV_register_combiners2 - CONST_CAST(GLEW_NV_register_combiners2) = glewGetExtension("GL_NV_register_combiners2"); - if (glewExperimental || GLEW_NV_register_combiners2) CONST_CAST(GLEW_NV_register_combiners2) = !_glewInit_GL_NV_register_combiners2(GLEW_CONTEXT_ARG_VAR_INIT); -#endif /* GL_NV_register_combiners2 */ -#ifdef GL_NV_texgen_emboss - CONST_CAST(GLEW_NV_texgen_emboss) = glewGetExtension("GL_NV_texgen_emboss"); -#endif /* GL_NV_texgen_emboss */ -#ifdef GL_NV_texgen_reflection - CONST_CAST(GLEW_NV_texgen_reflection) = glewGetExtension("GL_NV_texgen_reflection"); -#endif /* GL_NV_texgen_reflection */ -#ifdef GL_NV_texture_compression_vtc - CONST_CAST(GLEW_NV_texture_compression_vtc) = glewGetExtension("GL_NV_texture_compression_vtc"); -#endif /* GL_NV_texture_compression_vtc */ -#ifdef GL_NV_texture_env_combine4 - CONST_CAST(GLEW_NV_texture_env_combine4) = glewGetExtension("GL_NV_texture_env_combine4"); -#endif /* GL_NV_texture_env_combine4 */ -#ifdef GL_NV_texture_expand_normal - CONST_CAST(GLEW_NV_texture_expand_normal) = glewGetExtension("GL_NV_texture_expand_normal"); -#endif /* GL_NV_texture_expand_normal */ -#ifdef GL_NV_texture_rectangle - CONST_CAST(GLEW_NV_texture_rectangle) = glewGetExtension("GL_NV_texture_rectangle"); -#endif /* GL_NV_texture_rectangle */ -#ifdef GL_NV_texture_shader - CONST_CAST(GLEW_NV_texture_shader) = glewGetExtension("GL_NV_texture_shader"); -#endif /* GL_NV_texture_shader */ -#ifdef GL_NV_texture_shader2 - CONST_CAST(GLEW_NV_texture_shader2) = glewGetExtension("GL_NV_texture_shader2"); -#endif /* GL_NV_texture_shader2 */ -#ifdef GL_NV_texture_shader3 - CONST_CAST(GLEW_NV_texture_shader3) = glewGetExtension("GL_NV_texture_shader3"); -#endif /* GL_NV_texture_shader3 */ -#ifdef GL_NV_transform_feedback - CONST_CAST(GLEW_NV_transform_feedback) = glewGetExtension("GL_NV_transform_feedback"); - if (glewExperimental || GLEW_NV_transform_feedback) CONST_CAST(GLEW_NV_transform_feedback) = !_glewInit_GL_NV_transform_feedback(GLEW_CONTEXT_ARG_VAR_INIT); -#endif /* GL_NV_transform_feedback */ -#ifdef GL_NV_vertex_array_range - CONST_CAST(GLEW_NV_vertex_array_range) = glewGetExtension("GL_NV_vertex_array_range"); - if (glewExperimental || GLEW_NV_vertex_array_range) CONST_CAST(GLEW_NV_vertex_array_range) = !_glewInit_GL_NV_vertex_array_range(GLEW_CONTEXT_ARG_VAR_INIT); -#endif /* GL_NV_vertex_array_range */ -#ifdef GL_NV_vertex_array_range2 - CONST_CAST(GLEW_NV_vertex_array_range2) = glewGetExtension("GL_NV_vertex_array_range2"); -#endif /* GL_NV_vertex_array_range2 */ -#ifdef GL_NV_vertex_program - CONST_CAST(GLEW_NV_vertex_program) = glewGetExtension("GL_NV_vertex_program"); - if (glewExperimental || GLEW_NV_vertex_program) CONST_CAST(GLEW_NV_vertex_program) = !_glewInit_GL_NV_vertex_program(GLEW_CONTEXT_ARG_VAR_INIT); -#endif /* GL_NV_vertex_program */ -#ifdef GL_NV_vertex_program1_1 - CONST_CAST(GLEW_NV_vertex_program1_1) = glewGetExtension("GL_NV_vertex_program1_1"); -#endif /* GL_NV_vertex_program1_1 */ -#ifdef GL_NV_vertex_program2 - CONST_CAST(GLEW_NV_vertex_program2) = glewGetExtension("GL_NV_vertex_program2"); -#endif /* GL_NV_vertex_program2 */ -#ifdef GL_NV_vertex_program2_option - CONST_CAST(GLEW_NV_vertex_program2_option) = glewGetExtension("GL_NV_vertex_program2_option"); -#endif /* GL_NV_vertex_program2_option */ -#ifdef GL_NV_vertex_program3 - CONST_CAST(GLEW_NV_vertex_program3) = glewGetExtension("GL_NV_vertex_program3"); -#endif /* GL_NV_vertex_program3 */ -#ifdef GL_NV_vertex_program4 - CONST_CAST(GLEW_NV_vertex_program4) = glewGetExtension("GL_NV_vertex_program4"); -#endif /* GL_NV_vertex_program4 */ -#ifdef GL_OES_byte_coordinates - CONST_CAST(GLEW_OES_byte_coordinates) = glewGetExtension("GL_OES_byte_coordinates"); -#endif /* GL_OES_byte_coordinates */ -#ifdef GL_OES_compressed_paletted_texture - CONST_CAST(GLEW_OES_compressed_paletted_texture) = glewGetExtension("GL_OES_compressed_paletted_texture"); -#endif /* GL_OES_compressed_paletted_texture */ -#ifdef GL_OES_read_format - CONST_CAST(GLEW_OES_read_format) = glewGetExtension("GL_OES_read_format"); -#endif /* GL_OES_read_format */ -#ifdef GL_OES_single_precision - CONST_CAST(GLEW_OES_single_precision) = glewGetExtension("GL_OES_single_precision"); - if (glewExperimental || GLEW_OES_single_precision) CONST_CAST(GLEW_OES_single_precision) = !_glewInit_GL_OES_single_precision(GLEW_CONTEXT_ARG_VAR_INIT); -#endif /* GL_OES_single_precision */ -#ifdef GL_OML_interlace - CONST_CAST(GLEW_OML_interlace) = glewGetExtension("GL_OML_interlace"); -#endif /* GL_OML_interlace */ -#ifdef GL_OML_resample - CONST_CAST(GLEW_OML_resample) = glewGetExtension("GL_OML_resample"); -#endif /* GL_OML_resample */ -#ifdef GL_OML_subsample - CONST_CAST(GLEW_OML_subsample) = glewGetExtension("GL_OML_subsample"); -#endif /* GL_OML_subsample */ -#ifdef GL_PGI_misc_hints - CONST_CAST(GLEW_PGI_misc_hints) = glewGetExtension("GL_PGI_misc_hints"); -#endif /* GL_PGI_misc_hints */ -#ifdef GL_PGI_vertex_hints - CONST_CAST(GLEW_PGI_vertex_hints) = glewGetExtension("GL_PGI_vertex_hints"); -#endif /* GL_PGI_vertex_hints */ -#ifdef GL_REND_screen_coordinates - CONST_CAST(GLEW_REND_screen_coordinates) = glewGetExtension("GL_REND_screen_coordinates"); -#endif /* GL_REND_screen_coordinates */ -#ifdef GL_S3_s3tc - CONST_CAST(GLEW_S3_s3tc) = glewGetExtension("GL_S3_s3tc"); -#endif /* GL_S3_s3tc */ -#ifdef GL_SGIS_color_range - CONST_CAST(GLEW_SGIS_color_range) = glewGetExtension("GL_SGIS_color_range"); -#endif /* GL_SGIS_color_range */ -#ifdef GL_SGIS_detail_texture - CONST_CAST(GLEW_SGIS_detail_texture) = glewGetExtension("GL_SGIS_detail_texture"); - if (glewExperimental || GLEW_SGIS_detail_texture) CONST_CAST(GLEW_SGIS_detail_texture) = !_glewInit_GL_SGIS_detail_texture(GLEW_CONTEXT_ARG_VAR_INIT); -#endif /* GL_SGIS_detail_texture */ -#ifdef GL_SGIS_fog_function - CONST_CAST(GLEW_SGIS_fog_function) = glewGetExtension("GL_SGIS_fog_function"); - if (glewExperimental || GLEW_SGIS_fog_function) CONST_CAST(GLEW_SGIS_fog_function) = !_glewInit_GL_SGIS_fog_function(GLEW_CONTEXT_ARG_VAR_INIT); -#endif /* GL_SGIS_fog_function */ -#ifdef GL_SGIS_generate_mipmap - CONST_CAST(GLEW_SGIS_generate_mipmap) = glewGetExtension("GL_SGIS_generate_mipmap"); -#endif /* GL_SGIS_generate_mipmap */ -#ifdef GL_SGIS_multisample - CONST_CAST(GLEW_SGIS_multisample) = glewGetExtension("GL_SGIS_multisample"); - if (glewExperimental || GLEW_SGIS_multisample) CONST_CAST(GLEW_SGIS_multisample) = !_glewInit_GL_SGIS_multisample(GLEW_CONTEXT_ARG_VAR_INIT); -#endif /* GL_SGIS_multisample */ -#ifdef GL_SGIS_pixel_texture - CONST_CAST(GLEW_SGIS_pixel_texture) = glewGetExtension("GL_SGIS_pixel_texture"); -#endif /* GL_SGIS_pixel_texture */ -#ifdef GL_SGIS_point_line_texgen - CONST_CAST(GLEW_SGIS_point_line_texgen) = glewGetExtension("GL_SGIS_point_line_texgen"); -#endif /* GL_SGIS_point_line_texgen */ -#ifdef GL_SGIS_sharpen_texture - CONST_CAST(GLEW_SGIS_sharpen_texture) = glewGetExtension("GL_SGIS_sharpen_texture"); - if (glewExperimental || GLEW_SGIS_sharpen_texture) CONST_CAST(GLEW_SGIS_sharpen_texture) = !_glewInit_GL_SGIS_sharpen_texture(GLEW_CONTEXT_ARG_VAR_INIT); -#endif /* GL_SGIS_sharpen_texture */ -#ifdef GL_SGIS_texture4D - CONST_CAST(GLEW_SGIS_texture4D) = glewGetExtension("GL_SGIS_texture4D"); - if (glewExperimental || GLEW_SGIS_texture4D) CONST_CAST(GLEW_SGIS_texture4D) = !_glewInit_GL_SGIS_texture4D(GLEW_CONTEXT_ARG_VAR_INIT); -#endif /* GL_SGIS_texture4D */ -#ifdef GL_SGIS_texture_border_clamp - CONST_CAST(GLEW_SGIS_texture_border_clamp) = glewGetExtension("GL_SGIS_texture_border_clamp"); -#endif /* GL_SGIS_texture_border_clamp */ -#ifdef GL_SGIS_texture_edge_clamp - CONST_CAST(GLEW_SGIS_texture_edge_clamp) = glewGetExtension("GL_SGIS_texture_edge_clamp"); -#endif /* GL_SGIS_texture_edge_clamp */ -#ifdef GL_SGIS_texture_filter4 - CONST_CAST(GLEW_SGIS_texture_filter4) = glewGetExtension("GL_SGIS_texture_filter4"); - if (glewExperimental || GLEW_SGIS_texture_filter4) CONST_CAST(GLEW_SGIS_texture_filter4) = !_glewInit_GL_SGIS_texture_filter4(GLEW_CONTEXT_ARG_VAR_INIT); -#endif /* GL_SGIS_texture_filter4 */ -#ifdef GL_SGIS_texture_lod - CONST_CAST(GLEW_SGIS_texture_lod) = glewGetExtension("GL_SGIS_texture_lod"); -#endif /* GL_SGIS_texture_lod */ -#ifdef GL_SGIS_texture_select - CONST_CAST(GLEW_SGIS_texture_select) = glewGetExtension("GL_SGIS_texture_select"); -#endif /* GL_SGIS_texture_select */ -#ifdef GL_SGIX_async - CONST_CAST(GLEW_SGIX_async) = glewGetExtension("GL_SGIX_async"); - if (glewExperimental || GLEW_SGIX_async) CONST_CAST(GLEW_SGIX_async) = !_glewInit_GL_SGIX_async(GLEW_CONTEXT_ARG_VAR_INIT); -#endif /* GL_SGIX_async */ -#ifdef GL_SGIX_async_histogram - CONST_CAST(GLEW_SGIX_async_histogram) = glewGetExtension("GL_SGIX_async_histogram"); -#endif /* GL_SGIX_async_histogram */ -#ifdef GL_SGIX_async_pixel - CONST_CAST(GLEW_SGIX_async_pixel) = glewGetExtension("GL_SGIX_async_pixel"); -#endif /* GL_SGIX_async_pixel */ -#ifdef GL_SGIX_blend_alpha_minmax - CONST_CAST(GLEW_SGIX_blend_alpha_minmax) = glewGetExtension("GL_SGIX_blend_alpha_minmax"); -#endif /* GL_SGIX_blend_alpha_minmax */ -#ifdef GL_SGIX_clipmap - CONST_CAST(GLEW_SGIX_clipmap) = glewGetExtension("GL_SGIX_clipmap"); -#endif /* GL_SGIX_clipmap */ -#ifdef GL_SGIX_convolution_accuracy - CONST_CAST(GLEW_SGIX_convolution_accuracy) = glewGetExtension("GL_SGIX_convolution_accuracy"); -#endif /* GL_SGIX_convolution_accuracy */ -#ifdef GL_SGIX_depth_texture - CONST_CAST(GLEW_SGIX_depth_texture) = glewGetExtension("GL_SGIX_depth_texture"); -#endif /* GL_SGIX_depth_texture */ -#ifdef GL_SGIX_flush_raster - CONST_CAST(GLEW_SGIX_flush_raster) = glewGetExtension("GL_SGIX_flush_raster"); - if (glewExperimental || GLEW_SGIX_flush_raster) CONST_CAST(GLEW_SGIX_flush_raster) = !_glewInit_GL_SGIX_flush_raster(GLEW_CONTEXT_ARG_VAR_INIT); -#endif /* GL_SGIX_flush_raster */ -#ifdef GL_SGIX_fog_offset - CONST_CAST(GLEW_SGIX_fog_offset) = glewGetExtension("GL_SGIX_fog_offset"); -#endif /* GL_SGIX_fog_offset */ -#ifdef GL_SGIX_fog_texture - CONST_CAST(GLEW_SGIX_fog_texture) = glewGetExtension("GL_SGIX_fog_texture"); - if (glewExperimental || GLEW_SGIX_fog_texture) CONST_CAST(GLEW_SGIX_fog_texture) = !_glewInit_GL_SGIX_fog_texture(GLEW_CONTEXT_ARG_VAR_INIT); -#endif /* GL_SGIX_fog_texture */ -#ifdef GL_SGIX_fragment_specular_lighting - CONST_CAST(GLEW_SGIX_fragment_specular_lighting) = glewGetExtension("GL_SGIX_fragment_specular_lighting"); - if (glewExperimental || GLEW_SGIX_fragment_specular_lighting) CONST_CAST(GLEW_SGIX_fragment_specular_lighting) = !_glewInit_GL_SGIX_fragment_specular_lighting(GLEW_CONTEXT_ARG_VAR_INIT); -#endif /* GL_SGIX_fragment_specular_lighting */ -#ifdef GL_SGIX_framezoom - CONST_CAST(GLEW_SGIX_framezoom) = glewGetExtension("GL_SGIX_framezoom"); - if (glewExperimental || GLEW_SGIX_framezoom) CONST_CAST(GLEW_SGIX_framezoom) = !_glewInit_GL_SGIX_framezoom(GLEW_CONTEXT_ARG_VAR_INIT); -#endif /* GL_SGIX_framezoom */ -#ifdef GL_SGIX_interlace - CONST_CAST(GLEW_SGIX_interlace) = glewGetExtension("GL_SGIX_interlace"); -#endif /* GL_SGIX_interlace */ -#ifdef GL_SGIX_ir_instrument1 - CONST_CAST(GLEW_SGIX_ir_instrument1) = glewGetExtension("GL_SGIX_ir_instrument1"); -#endif /* GL_SGIX_ir_instrument1 */ -#ifdef GL_SGIX_list_priority - CONST_CAST(GLEW_SGIX_list_priority) = glewGetExtension("GL_SGIX_list_priority"); -#endif /* GL_SGIX_list_priority */ -#ifdef GL_SGIX_pixel_texture - CONST_CAST(GLEW_SGIX_pixel_texture) = glewGetExtension("GL_SGIX_pixel_texture"); - if (glewExperimental || GLEW_SGIX_pixel_texture) CONST_CAST(GLEW_SGIX_pixel_texture) = !_glewInit_GL_SGIX_pixel_texture(GLEW_CONTEXT_ARG_VAR_INIT); -#endif /* GL_SGIX_pixel_texture */ -#ifdef GL_SGIX_pixel_texture_bits - CONST_CAST(GLEW_SGIX_pixel_texture_bits) = glewGetExtension("GL_SGIX_pixel_texture_bits"); -#endif /* GL_SGIX_pixel_texture_bits */ -#ifdef GL_SGIX_reference_plane - CONST_CAST(GLEW_SGIX_reference_plane) = glewGetExtension("GL_SGIX_reference_plane"); - if (glewExperimental || GLEW_SGIX_reference_plane) CONST_CAST(GLEW_SGIX_reference_plane) = !_glewInit_GL_SGIX_reference_plane(GLEW_CONTEXT_ARG_VAR_INIT); -#endif /* GL_SGIX_reference_plane */ -#ifdef GL_SGIX_resample - CONST_CAST(GLEW_SGIX_resample) = glewGetExtension("GL_SGIX_resample"); -#endif /* GL_SGIX_resample */ -#ifdef GL_SGIX_shadow - CONST_CAST(GLEW_SGIX_shadow) = glewGetExtension("GL_SGIX_shadow"); -#endif /* GL_SGIX_shadow */ -#ifdef GL_SGIX_shadow_ambient - CONST_CAST(GLEW_SGIX_shadow_ambient) = glewGetExtension("GL_SGIX_shadow_ambient"); -#endif /* GL_SGIX_shadow_ambient */ -#ifdef GL_SGIX_sprite - CONST_CAST(GLEW_SGIX_sprite) = glewGetExtension("GL_SGIX_sprite"); - if (glewExperimental || GLEW_SGIX_sprite) CONST_CAST(GLEW_SGIX_sprite) = !_glewInit_GL_SGIX_sprite(GLEW_CONTEXT_ARG_VAR_INIT); -#endif /* GL_SGIX_sprite */ -#ifdef GL_SGIX_tag_sample_buffer - CONST_CAST(GLEW_SGIX_tag_sample_buffer) = glewGetExtension("GL_SGIX_tag_sample_buffer"); - if (glewExperimental || GLEW_SGIX_tag_sample_buffer) CONST_CAST(GLEW_SGIX_tag_sample_buffer) = !_glewInit_GL_SGIX_tag_sample_buffer(GLEW_CONTEXT_ARG_VAR_INIT); -#endif /* GL_SGIX_tag_sample_buffer */ -#ifdef GL_SGIX_texture_add_env - CONST_CAST(GLEW_SGIX_texture_add_env) = glewGetExtension("GL_SGIX_texture_add_env"); -#endif /* GL_SGIX_texture_add_env */ -#ifdef GL_SGIX_texture_coordinate_clamp - CONST_CAST(GLEW_SGIX_texture_coordinate_clamp) = glewGetExtension("GL_SGIX_texture_coordinate_clamp"); -#endif /* GL_SGIX_texture_coordinate_clamp */ -#ifdef GL_SGIX_texture_lod_bias - CONST_CAST(GLEW_SGIX_texture_lod_bias) = glewGetExtension("GL_SGIX_texture_lod_bias"); -#endif /* GL_SGIX_texture_lod_bias */ -#ifdef GL_SGIX_texture_multi_buffer - CONST_CAST(GLEW_SGIX_texture_multi_buffer) = glewGetExtension("GL_SGIX_texture_multi_buffer"); -#endif /* GL_SGIX_texture_multi_buffer */ -#ifdef GL_SGIX_texture_range - CONST_CAST(GLEW_SGIX_texture_range) = glewGetExtension("GL_SGIX_texture_range"); -#endif /* GL_SGIX_texture_range */ -#ifdef GL_SGIX_texture_scale_bias - CONST_CAST(GLEW_SGIX_texture_scale_bias) = glewGetExtension("GL_SGIX_texture_scale_bias"); -#endif /* GL_SGIX_texture_scale_bias */ -#ifdef GL_SGIX_vertex_preclip - CONST_CAST(GLEW_SGIX_vertex_preclip) = glewGetExtension("GL_SGIX_vertex_preclip"); -#endif /* GL_SGIX_vertex_preclip */ -#ifdef GL_SGIX_vertex_preclip_hint - CONST_CAST(GLEW_SGIX_vertex_preclip_hint) = glewGetExtension("GL_SGIX_vertex_preclip_hint"); -#endif /* GL_SGIX_vertex_preclip_hint */ -#ifdef GL_SGIX_ycrcb - CONST_CAST(GLEW_SGIX_ycrcb) = glewGetExtension("GL_SGIX_ycrcb"); -#endif /* GL_SGIX_ycrcb */ -#ifdef GL_SGI_color_matrix - CONST_CAST(GLEW_SGI_color_matrix) = glewGetExtension("GL_SGI_color_matrix"); -#endif /* GL_SGI_color_matrix */ -#ifdef GL_SGI_color_table - CONST_CAST(GLEW_SGI_color_table) = glewGetExtension("GL_SGI_color_table"); - if (glewExperimental || GLEW_SGI_color_table) CONST_CAST(GLEW_SGI_color_table) = !_glewInit_GL_SGI_color_table(GLEW_CONTEXT_ARG_VAR_INIT); -#endif /* GL_SGI_color_table */ -#ifdef GL_SGI_texture_color_table - CONST_CAST(GLEW_SGI_texture_color_table) = glewGetExtension("GL_SGI_texture_color_table"); -#endif /* GL_SGI_texture_color_table */ -#ifdef GL_SUNX_constant_data - CONST_CAST(GLEW_SUNX_constant_data) = glewGetExtension("GL_SUNX_constant_data"); - if (glewExperimental || GLEW_SUNX_constant_data) CONST_CAST(GLEW_SUNX_constant_data) = !_glewInit_GL_SUNX_constant_data(GLEW_CONTEXT_ARG_VAR_INIT); -#endif /* GL_SUNX_constant_data */ -#ifdef GL_SUN_convolution_border_modes - CONST_CAST(GLEW_SUN_convolution_border_modes) = glewGetExtension("GL_SUN_convolution_border_modes"); -#endif /* GL_SUN_convolution_border_modes */ -#ifdef GL_SUN_global_alpha - CONST_CAST(GLEW_SUN_global_alpha) = glewGetExtension("GL_SUN_global_alpha"); - if (glewExperimental || GLEW_SUN_global_alpha) CONST_CAST(GLEW_SUN_global_alpha) = !_glewInit_GL_SUN_global_alpha(GLEW_CONTEXT_ARG_VAR_INIT); -#endif /* GL_SUN_global_alpha */ -#ifdef GL_SUN_mesh_array - CONST_CAST(GLEW_SUN_mesh_array) = glewGetExtension("GL_SUN_mesh_array"); -#endif /* GL_SUN_mesh_array */ -#ifdef GL_SUN_read_video_pixels - CONST_CAST(GLEW_SUN_read_video_pixels) = glewGetExtension("GL_SUN_read_video_pixels"); - if (glewExperimental || GLEW_SUN_read_video_pixels) CONST_CAST(GLEW_SUN_read_video_pixels) = !_glewInit_GL_SUN_read_video_pixels(GLEW_CONTEXT_ARG_VAR_INIT); -#endif /* GL_SUN_read_video_pixels */ -#ifdef GL_SUN_slice_accum - CONST_CAST(GLEW_SUN_slice_accum) = glewGetExtension("GL_SUN_slice_accum"); -#endif /* GL_SUN_slice_accum */ -#ifdef GL_SUN_triangle_list - CONST_CAST(GLEW_SUN_triangle_list) = glewGetExtension("GL_SUN_triangle_list"); - if (glewExperimental || GLEW_SUN_triangle_list) CONST_CAST(GLEW_SUN_triangle_list) = !_glewInit_GL_SUN_triangle_list(GLEW_CONTEXT_ARG_VAR_INIT); -#endif /* GL_SUN_triangle_list */ -#ifdef GL_SUN_vertex - CONST_CAST(GLEW_SUN_vertex) = glewGetExtension("GL_SUN_vertex"); - if (glewExperimental || GLEW_SUN_vertex) CONST_CAST(GLEW_SUN_vertex) = !_glewInit_GL_SUN_vertex(GLEW_CONTEXT_ARG_VAR_INIT); -#endif /* GL_SUN_vertex */ -#ifdef GL_WIN_phong_shading - CONST_CAST(GLEW_WIN_phong_shading) = glewGetExtension("GL_WIN_phong_shading"); -#endif /* GL_WIN_phong_shading */ -#ifdef GL_WIN_specular_fog - CONST_CAST(GLEW_WIN_specular_fog) = glewGetExtension("GL_WIN_specular_fog"); -#endif /* GL_WIN_specular_fog */ -#ifdef GL_WIN_swap_hint - CONST_CAST(GLEW_WIN_swap_hint) = glewGetExtension("GL_WIN_swap_hint"); - if (glewExperimental || GLEW_WIN_swap_hint) CONST_CAST(GLEW_WIN_swap_hint) = !_glewInit_GL_WIN_swap_hint(GLEW_CONTEXT_ARG_VAR_INIT); -#endif /* GL_WIN_swap_hint */ - - return GLEW_OK; -} - - -#if defined(_WIN32) - -#if !defined(GLEW_MX) - -PFNWGLSETSTEREOEMITTERSTATE3DLPROC __wglewSetStereoEmitterState3DL = NULL; - -PFNWGLCREATEBUFFERREGIONARBPROC __wglewCreateBufferRegionARB = NULL; -PFNWGLDELETEBUFFERREGIONARBPROC __wglewDeleteBufferRegionARB = NULL; -PFNWGLRESTOREBUFFERREGIONARBPROC __wglewRestoreBufferRegionARB = NULL; -PFNWGLSAVEBUFFERREGIONARBPROC __wglewSaveBufferRegionARB = NULL; - -PFNWGLCREATECONTEXTATTRIBSARBPROC __wglewCreateContextAttribsARB = NULL; - -PFNWGLGETEXTENSIONSSTRINGARBPROC __wglewGetExtensionsStringARB = NULL; - -PFNWGLGETCURRENTREADDCARBPROC __wglewGetCurrentReadDCARB = NULL; -PFNWGLMAKECONTEXTCURRENTARBPROC __wglewMakeContextCurrentARB = NULL; - -PFNWGLCREATEPBUFFERARBPROC __wglewCreatePbufferARB = NULL; -PFNWGLDESTROYPBUFFERARBPROC __wglewDestroyPbufferARB = NULL; -PFNWGLGETPBUFFERDCARBPROC __wglewGetPbufferDCARB = NULL; -PFNWGLQUERYPBUFFERARBPROC __wglewQueryPbufferARB = NULL; -PFNWGLRELEASEPBUFFERDCARBPROC __wglewReleasePbufferDCARB = NULL; - -PFNWGLCHOOSEPIXELFORMATARBPROC __wglewChoosePixelFormatARB = NULL; -PFNWGLGETPIXELFORMATATTRIBFVARBPROC __wglewGetPixelFormatAttribfvARB = NULL; -PFNWGLGETPIXELFORMATATTRIBIVARBPROC __wglewGetPixelFormatAttribivARB = NULL; - -PFNWGLBINDTEXIMAGEARBPROC __wglewBindTexImageARB = NULL; -PFNWGLRELEASETEXIMAGEARBPROC __wglewReleaseTexImageARB = NULL; -PFNWGLSETPBUFFERATTRIBARBPROC __wglewSetPbufferAttribARB = NULL; - -PFNWGLBINDDISPLAYCOLORTABLEEXTPROC __wglewBindDisplayColorTableEXT = NULL; -PFNWGLCREATEDISPLAYCOLORTABLEEXTPROC __wglewCreateDisplayColorTableEXT = NULL; -PFNWGLDESTROYDISPLAYCOLORTABLEEXTPROC __wglewDestroyDisplayColorTableEXT = NULL; -PFNWGLLOADDISPLAYCOLORTABLEEXTPROC __wglewLoadDisplayColorTableEXT = NULL; - -PFNWGLGETEXTENSIONSSTRINGEXTPROC __wglewGetExtensionsStringEXT = NULL; - -PFNWGLGETCURRENTREADDCEXTPROC __wglewGetCurrentReadDCEXT = NULL; -PFNWGLMAKECONTEXTCURRENTEXTPROC __wglewMakeContextCurrentEXT = NULL; - -PFNWGLCREATEPBUFFEREXTPROC __wglewCreatePbufferEXT = NULL; -PFNWGLDESTROYPBUFFEREXTPROC __wglewDestroyPbufferEXT = NULL; -PFNWGLGETPBUFFERDCEXTPROC __wglewGetPbufferDCEXT = NULL; -PFNWGLQUERYPBUFFEREXTPROC __wglewQueryPbufferEXT = NULL; -PFNWGLRELEASEPBUFFERDCEXTPROC __wglewReleasePbufferDCEXT = NULL; - -PFNWGLCHOOSEPIXELFORMATEXTPROC __wglewChoosePixelFormatEXT = NULL; -PFNWGLGETPIXELFORMATATTRIBFVEXTPROC __wglewGetPixelFormatAttribfvEXT = NULL; -PFNWGLGETPIXELFORMATATTRIBIVEXTPROC __wglewGetPixelFormatAttribivEXT = NULL; - -PFNWGLGETSWAPINTERVALEXTPROC __wglewGetSwapIntervalEXT = NULL; -PFNWGLSWAPINTERVALEXTPROC __wglewSwapIntervalEXT = NULL; - -PFNWGLGETDIGITALVIDEOPARAMETERSI3DPROC __wglewGetDigitalVideoParametersI3D = NULL; -PFNWGLSETDIGITALVIDEOPARAMETERSI3DPROC __wglewSetDigitalVideoParametersI3D = NULL; - -PFNWGLGETGAMMATABLEI3DPROC __wglewGetGammaTableI3D = NULL; -PFNWGLGETGAMMATABLEPARAMETERSI3DPROC __wglewGetGammaTableParametersI3D = NULL; -PFNWGLSETGAMMATABLEI3DPROC __wglewSetGammaTableI3D = NULL; -PFNWGLSETGAMMATABLEPARAMETERSI3DPROC __wglewSetGammaTableParametersI3D = NULL; - -PFNWGLDISABLEGENLOCKI3DPROC __wglewDisableGenlockI3D = NULL; -PFNWGLENABLEGENLOCKI3DPROC __wglewEnableGenlockI3D = NULL; -PFNWGLGENLOCKSAMPLERATEI3DPROC __wglewGenlockSampleRateI3D = NULL; -PFNWGLGENLOCKSOURCEDELAYI3DPROC __wglewGenlockSourceDelayI3D = NULL; -PFNWGLGENLOCKSOURCEEDGEI3DPROC __wglewGenlockSourceEdgeI3D = NULL; -PFNWGLGENLOCKSOURCEI3DPROC __wglewGenlockSourceI3D = NULL; -PFNWGLGETGENLOCKSAMPLERATEI3DPROC __wglewGetGenlockSampleRateI3D = NULL; -PFNWGLGETGENLOCKSOURCEDELAYI3DPROC __wglewGetGenlockSourceDelayI3D = NULL; -PFNWGLGETGENLOCKSOURCEEDGEI3DPROC __wglewGetGenlockSourceEdgeI3D = NULL; -PFNWGLGETGENLOCKSOURCEI3DPROC __wglewGetGenlockSourceI3D = NULL; -PFNWGLISENABLEDGENLOCKI3DPROC __wglewIsEnabledGenlockI3D = NULL; -PFNWGLQUERYGENLOCKMAXSOURCEDELAYI3DPROC __wglewQueryGenlockMaxSourceDelayI3D = NULL; - -PFNWGLASSOCIATEIMAGEBUFFEREVENTSI3DPROC __wglewAssociateImageBufferEventsI3D = NULL; -PFNWGLCREATEIMAGEBUFFERI3DPROC __wglewCreateImageBufferI3D = NULL; -PFNWGLDESTROYIMAGEBUFFERI3DPROC __wglewDestroyImageBufferI3D = NULL; -PFNWGLRELEASEIMAGEBUFFEREVENTSI3DPROC __wglewReleaseImageBufferEventsI3D = NULL; - -PFNWGLDISABLEFRAMELOCKI3DPROC __wglewDisableFrameLockI3D = NULL; -PFNWGLENABLEFRAMELOCKI3DPROC __wglewEnableFrameLockI3D = NULL; -PFNWGLISENABLEDFRAMELOCKI3DPROC __wglewIsEnabledFrameLockI3D = NULL; -PFNWGLQUERYFRAMELOCKMASTERI3DPROC __wglewQueryFrameLockMasterI3D = NULL; - -PFNWGLBEGINFRAMETRACKINGI3DPROC __wglewBeginFrameTrackingI3D = NULL; -PFNWGLENDFRAMETRACKINGI3DPROC __wglewEndFrameTrackingI3D = NULL; -PFNWGLGETFRAMEUSAGEI3DPROC __wglewGetFrameUsageI3D = NULL; -PFNWGLQUERYFRAMETRACKINGI3DPROC __wglewQueryFrameTrackingI3D = NULL; - -PFNWGLCREATEAFFINITYDCNVPROC __wglewCreateAffinityDCNV = NULL; -PFNWGLDELETEDCNVPROC __wglewDeleteDCNV = NULL; -PFNWGLENUMGPUDEVICESNVPROC __wglewEnumGpuDevicesNV = NULL; -PFNWGLENUMGPUSFROMAFFINITYDCNVPROC __wglewEnumGpusFromAffinityDCNV = NULL; -PFNWGLENUMGPUSNVPROC __wglewEnumGpusNV = NULL; - -PFNWGLBINDVIDEODEVICENVPROC __wglewBindVideoDeviceNV = NULL; -PFNWGLENUMERATEVIDEODEVICESNVPROC __wglewEnumerateVideoDevicesNV = NULL; -PFNWGLQUERYCURRENTCONTEXTNVPROC __wglewQueryCurrentContextNV = NULL; - -PFNWGLBINDSWAPBARRIERNVPROC __wglewBindSwapBarrierNV = NULL; -PFNWGLJOINSWAPGROUPNVPROC __wglewJoinSwapGroupNV = NULL; -PFNWGLQUERYFRAMECOUNTNVPROC __wglewQueryFrameCountNV = NULL; -PFNWGLQUERYMAXSWAPGROUPSNVPROC __wglewQueryMaxSwapGroupsNV = NULL; -PFNWGLQUERYSWAPGROUPNVPROC __wglewQuerySwapGroupNV = NULL; -PFNWGLRESETFRAMECOUNTNVPROC __wglewResetFrameCountNV = NULL; - -PFNWGLALLOCATEMEMORYNVPROC __wglewAllocateMemoryNV = NULL; -PFNWGLFREEMEMORYNVPROC __wglewFreeMemoryNV = NULL; - -PFNWGLBINDVIDEOIMAGENVPROC __wglewBindVideoImageNV = NULL; -PFNWGLGETVIDEODEVICENVPROC __wglewGetVideoDeviceNV = NULL; -PFNWGLGETVIDEOINFONVPROC __wglewGetVideoInfoNV = NULL; -PFNWGLRELEASEVIDEODEVICENVPROC __wglewReleaseVideoDeviceNV = NULL; -PFNWGLRELEASEVIDEOIMAGENVPROC __wglewReleaseVideoImageNV = NULL; -PFNWGLSENDPBUFFERTOVIDEONVPROC __wglewSendPbufferToVideoNV = NULL; - -PFNWGLGETMSCRATEOMLPROC __wglewGetMscRateOML = NULL; -PFNWGLGETSYNCVALUESOMLPROC __wglewGetSyncValuesOML = NULL; -PFNWGLSWAPBUFFERSMSCOMLPROC __wglewSwapBuffersMscOML = NULL; -PFNWGLSWAPLAYERBUFFERSMSCOMLPROC __wglewSwapLayerBuffersMscOML = NULL; -PFNWGLWAITFORMSCOMLPROC __wglewWaitForMscOML = NULL; -PFNWGLWAITFORSBCOMLPROC __wglewWaitForSbcOML = NULL; -GLboolean __WGLEW_3DFX_multisample = GL_FALSE; -GLboolean __WGLEW_3DL_stereo_control = GL_FALSE; -GLboolean __WGLEW_ARB_buffer_region = GL_FALSE; -GLboolean __WGLEW_ARB_create_context = GL_FALSE; -GLboolean __WGLEW_ARB_extensions_string = GL_FALSE; -GLboolean __WGLEW_ARB_framebuffer_sRGB = GL_FALSE; -GLboolean __WGLEW_ARB_make_current_read = GL_FALSE; -GLboolean __WGLEW_ARB_multisample = GL_FALSE; -GLboolean __WGLEW_ARB_pbuffer = GL_FALSE; -GLboolean __WGLEW_ARB_pixel_format = GL_FALSE; -GLboolean __WGLEW_ARB_pixel_format_float = GL_FALSE; -GLboolean __WGLEW_ARB_render_texture = GL_FALSE; -GLboolean __WGLEW_ATI_pixel_format_float = GL_FALSE; -GLboolean __WGLEW_ATI_render_texture_rectangle = GL_FALSE; -GLboolean __WGLEW_EXT_depth_float = GL_FALSE; -GLboolean __WGLEW_EXT_display_color_table = GL_FALSE; -GLboolean __WGLEW_EXT_extensions_string = GL_FALSE; -GLboolean __WGLEW_EXT_framebuffer_sRGB = GL_FALSE; -GLboolean __WGLEW_EXT_make_current_read = GL_FALSE; -GLboolean __WGLEW_EXT_multisample = GL_FALSE; -GLboolean __WGLEW_EXT_pbuffer = GL_FALSE; -GLboolean __WGLEW_EXT_pixel_format = GL_FALSE; -GLboolean __WGLEW_EXT_pixel_format_packed_float = GL_FALSE; -GLboolean __WGLEW_EXT_swap_control = GL_FALSE; -GLboolean __WGLEW_I3D_digital_video_control = GL_FALSE; -GLboolean __WGLEW_I3D_gamma = GL_FALSE; -GLboolean __WGLEW_I3D_genlock = GL_FALSE; -GLboolean __WGLEW_I3D_image_buffer = GL_FALSE; -GLboolean __WGLEW_I3D_swap_frame_lock = GL_FALSE; -GLboolean __WGLEW_I3D_swap_frame_usage = GL_FALSE; -GLboolean __WGLEW_NV_float_buffer = GL_FALSE; -GLboolean __WGLEW_NV_gpu_affinity = GL_FALSE; -GLboolean __WGLEW_NV_present_video = GL_FALSE; -GLboolean __WGLEW_NV_render_depth_texture = GL_FALSE; -GLboolean __WGLEW_NV_render_texture_rectangle = GL_FALSE; -GLboolean __WGLEW_NV_swap_group = GL_FALSE; -GLboolean __WGLEW_NV_vertex_array_range = GL_FALSE; -GLboolean __WGLEW_NV_video_output = GL_FALSE; -GLboolean __WGLEW_OML_sync_control = GL_FALSE; - -#endif /* !GLEW_MX */ - -#ifdef WGL_3DFX_multisample - -#endif /* WGL_3DFX_multisample */ - -#ifdef WGL_3DL_stereo_control - -static GLboolean _glewInit_WGL_3DL_stereo_control (WGLEW_CONTEXT_ARG_DEF_INIT) -{ - GLboolean r = GL_FALSE; - - r = ((wglSetStereoEmitterState3DL = (PFNWGLSETSTEREOEMITTERSTATE3DLPROC)glewGetProcAddress((const GLubyte*)"wglSetStereoEmitterState3DL")) == NULL) || r; - - return r; -} - -#endif /* WGL_3DL_stereo_control */ - -#ifdef WGL_ARB_buffer_region - -static GLboolean _glewInit_WGL_ARB_buffer_region (WGLEW_CONTEXT_ARG_DEF_INIT) -{ - GLboolean r = GL_FALSE; - - r = ((wglCreateBufferRegionARB = (PFNWGLCREATEBUFFERREGIONARBPROC)glewGetProcAddress((const GLubyte*)"wglCreateBufferRegionARB")) == NULL) || r; - r = ((wglDeleteBufferRegionARB = (PFNWGLDELETEBUFFERREGIONARBPROC)glewGetProcAddress((const GLubyte*)"wglDeleteBufferRegionARB")) == NULL) || r; - r = ((wglRestoreBufferRegionARB = (PFNWGLRESTOREBUFFERREGIONARBPROC)glewGetProcAddress((const GLubyte*)"wglRestoreBufferRegionARB")) == NULL) || r; - r = ((wglSaveBufferRegionARB = (PFNWGLSAVEBUFFERREGIONARBPROC)glewGetProcAddress((const GLubyte*)"wglSaveBufferRegionARB")) == NULL) || r; - - return r; -} - -#endif /* WGL_ARB_buffer_region */ - -#ifdef WGL_ARB_create_context - -static GLboolean _glewInit_WGL_ARB_create_context (WGLEW_CONTEXT_ARG_DEF_INIT) -{ - GLboolean r = GL_FALSE; - - r = ((wglCreateContextAttribsARB = (PFNWGLCREATECONTEXTATTRIBSARBPROC)glewGetProcAddress((const GLubyte*)"wglCreateContextAttribsARB")) == NULL) || r; - - return r; -} - -#endif /* WGL_ARB_create_context */ - -#ifdef WGL_ARB_extensions_string - -static GLboolean _glewInit_WGL_ARB_extensions_string (WGLEW_CONTEXT_ARG_DEF_INIT) -{ - GLboolean r = GL_FALSE; - - r = ((wglGetExtensionsStringARB = (PFNWGLGETEXTENSIONSSTRINGARBPROC)glewGetProcAddress((const GLubyte*)"wglGetExtensionsStringARB")) == NULL) || r; - - return r; -} - -#endif /* WGL_ARB_extensions_string */ - -#ifdef WGL_ARB_framebuffer_sRGB - -#endif /* WGL_ARB_framebuffer_sRGB */ - -#ifdef WGL_ARB_make_current_read - -static GLboolean _glewInit_WGL_ARB_make_current_read (WGLEW_CONTEXT_ARG_DEF_INIT) -{ - GLboolean r = GL_FALSE; - - r = ((wglGetCurrentReadDCARB = (PFNWGLGETCURRENTREADDCARBPROC)glewGetProcAddress((const GLubyte*)"wglGetCurrentReadDCARB")) == NULL) || r; - r = ((wglMakeContextCurrentARB = (PFNWGLMAKECONTEXTCURRENTARBPROC)glewGetProcAddress((const GLubyte*)"wglMakeContextCurrentARB")) == NULL) || r; - - return r; -} - -#endif /* WGL_ARB_make_current_read */ - -#ifdef WGL_ARB_multisample - -#endif /* WGL_ARB_multisample */ - -#ifdef WGL_ARB_pbuffer - -static GLboolean _glewInit_WGL_ARB_pbuffer (WGLEW_CONTEXT_ARG_DEF_INIT) -{ - GLboolean r = GL_FALSE; - - r = ((wglCreatePbufferARB = (PFNWGLCREATEPBUFFERARBPROC)glewGetProcAddress((const GLubyte*)"wglCreatePbufferARB")) == NULL) || r; - r = ((wglDestroyPbufferARB = (PFNWGLDESTROYPBUFFERARBPROC)glewGetProcAddress((const GLubyte*)"wglDestroyPbufferARB")) == NULL) || r; - r = ((wglGetPbufferDCARB = (PFNWGLGETPBUFFERDCARBPROC)glewGetProcAddress((const GLubyte*)"wglGetPbufferDCARB")) == NULL) || r; - r = ((wglQueryPbufferARB = (PFNWGLQUERYPBUFFERARBPROC)glewGetProcAddress((const GLubyte*)"wglQueryPbufferARB")) == NULL) || r; - r = ((wglReleasePbufferDCARB = (PFNWGLRELEASEPBUFFERDCARBPROC)glewGetProcAddress((const GLubyte*)"wglReleasePbufferDCARB")) == NULL) || r; - - return r; -} - -#endif /* WGL_ARB_pbuffer */ - -#ifdef WGL_ARB_pixel_format - -static GLboolean _glewInit_WGL_ARB_pixel_format (WGLEW_CONTEXT_ARG_DEF_INIT) -{ - GLboolean r = GL_FALSE; - - r = ((wglChoosePixelFormatARB = (PFNWGLCHOOSEPIXELFORMATARBPROC)glewGetProcAddress((const GLubyte*)"wglChoosePixelFormatARB")) == NULL) || r; - r = ((wglGetPixelFormatAttribfvARB = (PFNWGLGETPIXELFORMATATTRIBFVARBPROC)glewGetProcAddress((const GLubyte*)"wglGetPixelFormatAttribfvARB")) == NULL) || r; - r = ((wglGetPixelFormatAttribivARB = (PFNWGLGETPIXELFORMATATTRIBIVARBPROC)glewGetProcAddress((const GLubyte*)"wglGetPixelFormatAttribivARB")) == NULL) || r; - - return r; -} - -#endif /* WGL_ARB_pixel_format */ - -#ifdef WGL_ARB_pixel_format_float - -#endif /* WGL_ARB_pixel_format_float */ - -#ifdef WGL_ARB_render_texture - -static GLboolean _glewInit_WGL_ARB_render_texture (WGLEW_CONTEXT_ARG_DEF_INIT) -{ - GLboolean r = GL_FALSE; - - r = ((wglBindTexImageARB = (PFNWGLBINDTEXIMAGEARBPROC)glewGetProcAddress((const GLubyte*)"wglBindTexImageARB")) == NULL) || r; - r = ((wglReleaseTexImageARB = (PFNWGLRELEASETEXIMAGEARBPROC)glewGetProcAddress((const GLubyte*)"wglReleaseTexImageARB")) == NULL) || r; - r = ((wglSetPbufferAttribARB = (PFNWGLSETPBUFFERATTRIBARBPROC)glewGetProcAddress((const GLubyte*)"wglSetPbufferAttribARB")) == NULL) || r; - - return r; -} - -#endif /* WGL_ARB_render_texture */ - -#ifdef WGL_ATI_pixel_format_float - -#endif /* WGL_ATI_pixel_format_float */ - -#ifdef WGL_ATI_render_texture_rectangle - -#endif /* WGL_ATI_render_texture_rectangle */ - -#ifdef WGL_EXT_depth_float - -#endif /* WGL_EXT_depth_float */ - -#ifdef WGL_EXT_display_color_table - -static GLboolean _glewInit_WGL_EXT_display_color_table (WGLEW_CONTEXT_ARG_DEF_INIT) -{ - GLboolean r = GL_FALSE; - - r = ((wglBindDisplayColorTableEXT = (PFNWGLBINDDISPLAYCOLORTABLEEXTPROC)glewGetProcAddress((const GLubyte*)"wglBindDisplayColorTableEXT")) == NULL) || r; - r = ((wglCreateDisplayColorTableEXT = (PFNWGLCREATEDISPLAYCOLORTABLEEXTPROC)glewGetProcAddress((const GLubyte*)"wglCreateDisplayColorTableEXT")) == NULL) || r; - r = ((wglDestroyDisplayColorTableEXT = (PFNWGLDESTROYDISPLAYCOLORTABLEEXTPROC)glewGetProcAddress((const GLubyte*)"wglDestroyDisplayColorTableEXT")) == NULL) || r; - r = ((wglLoadDisplayColorTableEXT = (PFNWGLLOADDISPLAYCOLORTABLEEXTPROC)glewGetProcAddress((const GLubyte*)"wglLoadDisplayColorTableEXT")) == NULL) || r; - - return r; -} - -#endif /* WGL_EXT_display_color_table */ - -#ifdef WGL_EXT_extensions_string - -static GLboolean _glewInit_WGL_EXT_extensions_string (WGLEW_CONTEXT_ARG_DEF_INIT) -{ - GLboolean r = GL_FALSE; - - r = ((wglGetExtensionsStringEXT = (PFNWGLGETEXTENSIONSSTRINGEXTPROC)glewGetProcAddress((const GLubyte*)"wglGetExtensionsStringEXT")) == NULL) || r; - - return r; -} - -#endif /* WGL_EXT_extensions_string */ - -#ifdef WGL_EXT_framebuffer_sRGB - -#endif /* WGL_EXT_framebuffer_sRGB */ - -#ifdef WGL_EXT_make_current_read - -static GLboolean _glewInit_WGL_EXT_make_current_read (WGLEW_CONTEXT_ARG_DEF_INIT) -{ - GLboolean r = GL_FALSE; - - r = ((wglGetCurrentReadDCEXT = (PFNWGLGETCURRENTREADDCEXTPROC)glewGetProcAddress((const GLubyte*)"wglGetCurrentReadDCEXT")) == NULL) || r; - r = ((wglMakeContextCurrentEXT = (PFNWGLMAKECONTEXTCURRENTEXTPROC)glewGetProcAddress((const GLubyte*)"wglMakeContextCurrentEXT")) == NULL) || r; - - return r; -} - -#endif /* WGL_EXT_make_current_read */ - -#ifdef WGL_EXT_multisample - -#endif /* WGL_EXT_multisample */ - -#ifdef WGL_EXT_pbuffer - -static GLboolean _glewInit_WGL_EXT_pbuffer (WGLEW_CONTEXT_ARG_DEF_INIT) -{ - GLboolean r = GL_FALSE; - - r = ((wglCreatePbufferEXT = (PFNWGLCREATEPBUFFEREXTPROC)glewGetProcAddress((const GLubyte*)"wglCreatePbufferEXT")) == NULL) || r; - r = ((wglDestroyPbufferEXT = (PFNWGLDESTROYPBUFFEREXTPROC)glewGetProcAddress((const GLubyte*)"wglDestroyPbufferEXT")) == NULL) || r; - r = ((wglGetPbufferDCEXT = (PFNWGLGETPBUFFERDCEXTPROC)glewGetProcAddress((const GLubyte*)"wglGetPbufferDCEXT")) == NULL) || r; - r = ((wglQueryPbufferEXT = (PFNWGLQUERYPBUFFEREXTPROC)glewGetProcAddress((const GLubyte*)"wglQueryPbufferEXT")) == NULL) || r; - r = ((wglReleasePbufferDCEXT = (PFNWGLRELEASEPBUFFERDCEXTPROC)glewGetProcAddress((const GLubyte*)"wglReleasePbufferDCEXT")) == NULL) || r; - - return r; -} - -#endif /* WGL_EXT_pbuffer */ - -#ifdef WGL_EXT_pixel_format - -static GLboolean _glewInit_WGL_EXT_pixel_format (WGLEW_CONTEXT_ARG_DEF_INIT) -{ - GLboolean r = GL_FALSE; - - r = ((wglChoosePixelFormatEXT = (PFNWGLCHOOSEPIXELFORMATEXTPROC)glewGetProcAddress((const GLubyte*)"wglChoosePixelFormatEXT")) == NULL) || r; - r = ((wglGetPixelFormatAttribfvEXT = (PFNWGLGETPIXELFORMATATTRIBFVEXTPROC)glewGetProcAddress((const GLubyte*)"wglGetPixelFormatAttribfvEXT")) == NULL) || r; - r = ((wglGetPixelFormatAttribivEXT = (PFNWGLGETPIXELFORMATATTRIBIVEXTPROC)glewGetProcAddress((const GLubyte*)"wglGetPixelFormatAttribivEXT")) == NULL) || r; - - return r; -} - -#endif /* WGL_EXT_pixel_format */ - -#ifdef WGL_EXT_pixel_format_packed_float - -#endif /* WGL_EXT_pixel_format_packed_float */ - -#ifdef WGL_EXT_swap_control - -static GLboolean _glewInit_WGL_EXT_swap_control (WGLEW_CONTEXT_ARG_DEF_INIT) -{ - GLboolean r = GL_FALSE; - - r = ((wglGetSwapIntervalEXT = (PFNWGLGETSWAPINTERVALEXTPROC)glewGetProcAddress((const GLubyte*)"wglGetSwapIntervalEXT")) == NULL) || r; - r = ((wglSwapIntervalEXT = (PFNWGLSWAPINTERVALEXTPROC)glewGetProcAddress((const GLubyte*)"wglSwapIntervalEXT")) == NULL) || r; - - return r; -} - -#endif /* WGL_EXT_swap_control */ - -#ifdef WGL_I3D_digital_video_control - -static GLboolean _glewInit_WGL_I3D_digital_video_control (WGLEW_CONTEXT_ARG_DEF_INIT) -{ - GLboolean r = GL_FALSE; - - r = ((wglGetDigitalVideoParametersI3D = (PFNWGLGETDIGITALVIDEOPARAMETERSI3DPROC)glewGetProcAddress((const GLubyte*)"wglGetDigitalVideoParametersI3D")) == NULL) || r; - r = ((wglSetDigitalVideoParametersI3D = (PFNWGLSETDIGITALVIDEOPARAMETERSI3DPROC)glewGetProcAddress((const GLubyte*)"wglSetDigitalVideoParametersI3D")) == NULL) || r; - - return r; -} - -#endif /* WGL_I3D_digital_video_control */ - -#ifdef WGL_I3D_gamma - -static GLboolean _glewInit_WGL_I3D_gamma (WGLEW_CONTEXT_ARG_DEF_INIT) -{ - GLboolean r = GL_FALSE; - - r = ((wglGetGammaTableI3D = (PFNWGLGETGAMMATABLEI3DPROC)glewGetProcAddress((const GLubyte*)"wglGetGammaTableI3D")) == NULL) || r; - r = ((wglGetGammaTableParametersI3D = (PFNWGLGETGAMMATABLEPARAMETERSI3DPROC)glewGetProcAddress((const GLubyte*)"wglGetGammaTableParametersI3D")) == NULL) || r; - r = ((wglSetGammaTableI3D = (PFNWGLSETGAMMATABLEI3DPROC)glewGetProcAddress((const GLubyte*)"wglSetGammaTableI3D")) == NULL) || r; - r = ((wglSetGammaTableParametersI3D = (PFNWGLSETGAMMATABLEPARAMETERSI3DPROC)glewGetProcAddress((const GLubyte*)"wglSetGammaTableParametersI3D")) == NULL) || r; - - return r; -} - -#endif /* WGL_I3D_gamma */ - -#ifdef WGL_I3D_genlock - -static GLboolean _glewInit_WGL_I3D_genlock (WGLEW_CONTEXT_ARG_DEF_INIT) -{ - GLboolean r = GL_FALSE; - - r = ((wglDisableGenlockI3D = (PFNWGLDISABLEGENLOCKI3DPROC)glewGetProcAddress((const GLubyte*)"wglDisableGenlockI3D")) == NULL) || r; - r = ((wglEnableGenlockI3D = (PFNWGLENABLEGENLOCKI3DPROC)glewGetProcAddress((const GLubyte*)"wglEnableGenlockI3D")) == NULL) || r; - r = ((wglGenlockSampleRateI3D = (PFNWGLGENLOCKSAMPLERATEI3DPROC)glewGetProcAddress((const GLubyte*)"wglGenlockSampleRateI3D")) == NULL) || r; - r = ((wglGenlockSourceDelayI3D = (PFNWGLGENLOCKSOURCEDELAYI3DPROC)glewGetProcAddress((const GLubyte*)"wglGenlockSourceDelayI3D")) == NULL) || r; - r = ((wglGenlockSourceEdgeI3D = (PFNWGLGENLOCKSOURCEEDGEI3DPROC)glewGetProcAddress((const GLubyte*)"wglGenlockSourceEdgeI3D")) == NULL) || r; - r = ((wglGenlockSourceI3D = (PFNWGLGENLOCKSOURCEI3DPROC)glewGetProcAddress((const GLubyte*)"wglGenlockSourceI3D")) == NULL) || r; - r = ((wglGetGenlockSampleRateI3D = (PFNWGLGETGENLOCKSAMPLERATEI3DPROC)glewGetProcAddress((const GLubyte*)"wglGetGenlockSampleRateI3D")) == NULL) || r; - r = ((wglGetGenlockSourceDelayI3D = (PFNWGLGETGENLOCKSOURCEDELAYI3DPROC)glewGetProcAddress((const GLubyte*)"wglGetGenlockSourceDelayI3D")) == NULL) || r; - r = ((wglGetGenlockSourceEdgeI3D = (PFNWGLGETGENLOCKSOURCEEDGEI3DPROC)glewGetProcAddress((const GLubyte*)"wglGetGenlockSourceEdgeI3D")) == NULL) || r; - r = ((wglGetGenlockSourceI3D = (PFNWGLGETGENLOCKSOURCEI3DPROC)glewGetProcAddress((const GLubyte*)"wglGetGenlockSourceI3D")) == NULL) || r; - r = ((wglIsEnabledGenlockI3D = (PFNWGLISENABLEDGENLOCKI3DPROC)glewGetProcAddress((const GLubyte*)"wglIsEnabledGenlockI3D")) == NULL) || r; - r = ((wglQueryGenlockMaxSourceDelayI3D = (PFNWGLQUERYGENLOCKMAXSOURCEDELAYI3DPROC)glewGetProcAddress((const GLubyte*)"wglQueryGenlockMaxSourceDelayI3D")) == NULL) || r; - - return r; -} - -#endif /* WGL_I3D_genlock */ - -#ifdef WGL_I3D_image_buffer - -static GLboolean _glewInit_WGL_I3D_image_buffer (WGLEW_CONTEXT_ARG_DEF_INIT) -{ - GLboolean r = GL_FALSE; - - r = ((wglAssociateImageBufferEventsI3D = (PFNWGLASSOCIATEIMAGEBUFFEREVENTSI3DPROC)glewGetProcAddress((const GLubyte*)"wglAssociateImageBufferEventsI3D")) == NULL) || r; - r = ((wglCreateImageBufferI3D = (PFNWGLCREATEIMAGEBUFFERI3DPROC)glewGetProcAddress((const GLubyte*)"wglCreateImageBufferI3D")) == NULL) || r; - r = ((wglDestroyImageBufferI3D = (PFNWGLDESTROYIMAGEBUFFERI3DPROC)glewGetProcAddress((const GLubyte*)"wglDestroyImageBufferI3D")) == NULL) || r; - r = ((wglReleaseImageBufferEventsI3D = (PFNWGLRELEASEIMAGEBUFFEREVENTSI3DPROC)glewGetProcAddress((const GLubyte*)"wglReleaseImageBufferEventsI3D")) == NULL) || r; - - return r; -} - -#endif /* WGL_I3D_image_buffer */ - -#ifdef WGL_I3D_swap_frame_lock - -static GLboolean _glewInit_WGL_I3D_swap_frame_lock (WGLEW_CONTEXT_ARG_DEF_INIT) -{ - GLboolean r = GL_FALSE; - - r = ((wglDisableFrameLockI3D = (PFNWGLDISABLEFRAMELOCKI3DPROC)glewGetProcAddress((const GLubyte*)"wglDisableFrameLockI3D")) == NULL) || r; - r = ((wglEnableFrameLockI3D = (PFNWGLENABLEFRAMELOCKI3DPROC)glewGetProcAddress((const GLubyte*)"wglEnableFrameLockI3D")) == NULL) || r; - r = ((wglIsEnabledFrameLockI3D = (PFNWGLISENABLEDFRAMELOCKI3DPROC)glewGetProcAddress((const GLubyte*)"wglIsEnabledFrameLockI3D")) == NULL) || r; - r = ((wglQueryFrameLockMasterI3D = (PFNWGLQUERYFRAMELOCKMASTERI3DPROC)glewGetProcAddress((const GLubyte*)"wglQueryFrameLockMasterI3D")) == NULL) || r; - - return r; -} - -#endif /* WGL_I3D_swap_frame_lock */ - -#ifdef WGL_I3D_swap_frame_usage - -static GLboolean _glewInit_WGL_I3D_swap_frame_usage (WGLEW_CONTEXT_ARG_DEF_INIT) -{ - GLboolean r = GL_FALSE; - - r = ((wglBeginFrameTrackingI3D = (PFNWGLBEGINFRAMETRACKINGI3DPROC)glewGetProcAddress((const GLubyte*)"wglBeginFrameTrackingI3D")) == NULL) || r; - r = ((wglEndFrameTrackingI3D = (PFNWGLENDFRAMETRACKINGI3DPROC)glewGetProcAddress((const GLubyte*)"wglEndFrameTrackingI3D")) == NULL) || r; - r = ((wglGetFrameUsageI3D = (PFNWGLGETFRAMEUSAGEI3DPROC)glewGetProcAddress((const GLubyte*)"wglGetFrameUsageI3D")) == NULL) || r; - r = ((wglQueryFrameTrackingI3D = (PFNWGLQUERYFRAMETRACKINGI3DPROC)glewGetProcAddress((const GLubyte*)"wglQueryFrameTrackingI3D")) == NULL) || r; - - return r; -} - -#endif /* WGL_I3D_swap_frame_usage */ - -#ifdef WGL_NV_float_buffer - -#endif /* WGL_NV_float_buffer */ - -#ifdef WGL_NV_gpu_affinity - -static GLboolean _glewInit_WGL_NV_gpu_affinity (WGLEW_CONTEXT_ARG_DEF_INIT) -{ - GLboolean r = GL_FALSE; - - r = ((wglCreateAffinityDCNV = (PFNWGLCREATEAFFINITYDCNVPROC)glewGetProcAddress((const GLubyte*)"wglCreateAffinityDCNV")) == NULL) || r; - r = ((wglDeleteDCNV = (PFNWGLDELETEDCNVPROC)glewGetProcAddress((const GLubyte*)"wglDeleteDCNV")) == NULL) || r; - r = ((wglEnumGpuDevicesNV = (PFNWGLENUMGPUDEVICESNVPROC)glewGetProcAddress((const GLubyte*)"wglEnumGpuDevicesNV")) == NULL) || r; - r = ((wglEnumGpusFromAffinityDCNV = (PFNWGLENUMGPUSFROMAFFINITYDCNVPROC)glewGetProcAddress((const GLubyte*)"wglEnumGpusFromAffinityDCNV")) == NULL) || r; - r = ((wglEnumGpusNV = (PFNWGLENUMGPUSNVPROC)glewGetProcAddress((const GLubyte*)"wglEnumGpusNV")) == NULL) || r; - - return r; -} - -#endif /* WGL_NV_gpu_affinity */ - -#ifdef WGL_NV_present_video - -static GLboolean _glewInit_WGL_NV_present_video (WGLEW_CONTEXT_ARG_DEF_INIT) -{ - GLboolean r = GL_FALSE; - - r = ((wglBindVideoDeviceNV = (PFNWGLBINDVIDEODEVICENVPROC)glewGetProcAddress((const GLubyte*)"wglBindVideoDeviceNV")) == NULL) || r; - r = ((wglEnumerateVideoDevicesNV = (PFNWGLENUMERATEVIDEODEVICESNVPROC)glewGetProcAddress((const GLubyte*)"wglEnumerateVideoDevicesNV")) == NULL) || r; - r = ((wglQueryCurrentContextNV = (PFNWGLQUERYCURRENTCONTEXTNVPROC)glewGetProcAddress((const GLubyte*)"wglQueryCurrentContextNV")) == NULL) || r; - - return r; -} - -#endif /* WGL_NV_present_video */ - -#ifdef WGL_NV_render_depth_texture - -#endif /* WGL_NV_render_depth_texture */ - -#ifdef WGL_NV_render_texture_rectangle - -#endif /* WGL_NV_render_texture_rectangle */ - -#ifdef WGL_NV_swap_group - -static GLboolean _glewInit_WGL_NV_swap_group (WGLEW_CONTEXT_ARG_DEF_INIT) -{ - GLboolean r = GL_FALSE; - - r = ((wglBindSwapBarrierNV = (PFNWGLBINDSWAPBARRIERNVPROC)glewGetProcAddress((const GLubyte*)"wglBindSwapBarrierNV")) == NULL) || r; - r = ((wglJoinSwapGroupNV = (PFNWGLJOINSWAPGROUPNVPROC)glewGetProcAddress((const GLubyte*)"wglJoinSwapGroupNV")) == NULL) || r; - r = ((wglQueryFrameCountNV = (PFNWGLQUERYFRAMECOUNTNVPROC)glewGetProcAddress((const GLubyte*)"wglQueryFrameCountNV")) == NULL) || r; - r = ((wglQueryMaxSwapGroupsNV = (PFNWGLQUERYMAXSWAPGROUPSNVPROC)glewGetProcAddress((const GLubyte*)"wglQueryMaxSwapGroupsNV")) == NULL) || r; - r = ((wglQuerySwapGroupNV = (PFNWGLQUERYSWAPGROUPNVPROC)glewGetProcAddress((const GLubyte*)"wglQuerySwapGroupNV")) == NULL) || r; - r = ((wglResetFrameCountNV = (PFNWGLRESETFRAMECOUNTNVPROC)glewGetProcAddress((const GLubyte*)"wglResetFrameCountNV")) == NULL) || r; - - return r; -} - -#endif /* WGL_NV_swap_group */ - -#ifdef WGL_NV_vertex_array_range - -static GLboolean _glewInit_WGL_NV_vertex_array_range (WGLEW_CONTEXT_ARG_DEF_INIT) -{ - GLboolean r = GL_FALSE; - - r = ((wglAllocateMemoryNV = (PFNWGLALLOCATEMEMORYNVPROC)glewGetProcAddress((const GLubyte*)"wglAllocateMemoryNV")) == NULL) || r; - r = ((wglFreeMemoryNV = (PFNWGLFREEMEMORYNVPROC)glewGetProcAddress((const GLubyte*)"wglFreeMemoryNV")) == NULL) || r; - - return r; -} - -#endif /* WGL_NV_vertex_array_range */ - -#ifdef WGL_NV_video_output - -static GLboolean _glewInit_WGL_NV_video_output (WGLEW_CONTEXT_ARG_DEF_INIT) -{ - GLboolean r = GL_FALSE; - - r = ((wglBindVideoImageNV = (PFNWGLBINDVIDEOIMAGENVPROC)glewGetProcAddress((const GLubyte*)"wglBindVideoImageNV")) == NULL) || r; - r = ((wglGetVideoDeviceNV = (PFNWGLGETVIDEODEVICENVPROC)glewGetProcAddress((const GLubyte*)"wglGetVideoDeviceNV")) == NULL) || r; - r = ((wglGetVideoInfoNV = (PFNWGLGETVIDEOINFONVPROC)glewGetProcAddress((const GLubyte*)"wglGetVideoInfoNV")) == NULL) || r; - r = ((wglReleaseVideoDeviceNV = (PFNWGLRELEASEVIDEODEVICENVPROC)glewGetProcAddress((const GLubyte*)"wglReleaseVideoDeviceNV")) == NULL) || r; - r = ((wglReleaseVideoImageNV = (PFNWGLRELEASEVIDEOIMAGENVPROC)glewGetProcAddress((const GLubyte*)"wglReleaseVideoImageNV")) == NULL) || r; - r = ((wglSendPbufferToVideoNV = (PFNWGLSENDPBUFFERTOVIDEONVPROC)glewGetProcAddress((const GLubyte*)"wglSendPbufferToVideoNV")) == NULL) || r; - - return r; -} - -#endif /* WGL_NV_video_output */ - -#ifdef WGL_OML_sync_control - -static GLboolean _glewInit_WGL_OML_sync_control (WGLEW_CONTEXT_ARG_DEF_INIT) -{ - GLboolean r = GL_FALSE; - - r = ((wglGetMscRateOML = (PFNWGLGETMSCRATEOMLPROC)glewGetProcAddress((const GLubyte*)"wglGetMscRateOML")) == NULL) || r; - r = ((wglGetSyncValuesOML = (PFNWGLGETSYNCVALUESOMLPROC)glewGetProcAddress((const GLubyte*)"wglGetSyncValuesOML")) == NULL) || r; - r = ((wglSwapBuffersMscOML = (PFNWGLSWAPBUFFERSMSCOMLPROC)glewGetProcAddress((const GLubyte*)"wglSwapBuffersMscOML")) == NULL) || r; - r = ((wglSwapLayerBuffersMscOML = (PFNWGLSWAPLAYERBUFFERSMSCOMLPROC)glewGetProcAddress((const GLubyte*)"wglSwapLayerBuffersMscOML")) == NULL) || r; - r = ((wglWaitForMscOML = (PFNWGLWAITFORMSCOMLPROC)glewGetProcAddress((const GLubyte*)"wglWaitForMscOML")) == NULL) || r; - r = ((wglWaitForSbcOML = (PFNWGLWAITFORSBCOMLPROC)glewGetProcAddress((const GLubyte*)"wglWaitForSbcOML")) == NULL) || r; - - return r; -} - -#endif /* WGL_OML_sync_control */ - -/* ------------------------------------------------------------------------- */ - -static PFNWGLGETEXTENSIONSSTRINGARBPROC _wglewGetExtensionsStringARB = NULL; -static PFNWGLGETEXTENSIONSSTRINGEXTPROC _wglewGetExtensionsStringEXT = NULL; - -GLboolean wglewGetExtension (const char* name) -{ - GLubyte* p; - GLubyte* end; - GLuint len = _glewStrLen((const GLubyte*)name); - if (_wglewGetExtensionsStringARB == NULL) - if (_wglewGetExtensionsStringEXT == NULL) - return GL_FALSE; - else - p = (GLubyte*)_wglewGetExtensionsStringEXT(); - else - p = (GLubyte*)_wglewGetExtensionsStringARB(wglGetCurrentDC()); - if (0 == p) return GL_FALSE; - end = p + _glewStrLen(p); - while (p < end) - { - GLuint n = _glewStrCLen(p, ' '); - if (len == n && _glewStrSame((const GLubyte*)name, p, n)) return GL_TRUE; - p += n+1; - } - return GL_FALSE; -} - -GLenum wglewContextInit (WGLEW_CONTEXT_ARG_DEF_LIST) -{ - GLboolean crippled; - /* find wgl extension string query functions */ - _wglewGetExtensionsStringARB = (PFNWGLGETEXTENSIONSSTRINGARBPROC)glewGetProcAddress((const GLubyte*)"wglGetExtensionsStringARB"); - _wglewGetExtensionsStringEXT = (PFNWGLGETEXTENSIONSSTRINGEXTPROC)glewGetProcAddress((const GLubyte*)"wglGetExtensionsStringEXT"); - /* initialize extensions */ - crippled = _wglewGetExtensionsStringARB == NULL && _wglewGetExtensionsStringEXT == NULL; -#ifdef WGL_3DFX_multisample - CONST_CAST(WGLEW_3DFX_multisample) = wglewGetExtension("WGL_3DFX_multisample"); -#endif /* WGL_3DFX_multisample */ -#ifdef WGL_3DL_stereo_control - CONST_CAST(WGLEW_3DL_stereo_control) = wglewGetExtension("WGL_3DL_stereo_control"); - if (glewExperimental || WGLEW_3DL_stereo_control|| crippled) CONST_CAST(WGLEW_3DL_stereo_control)= !_glewInit_WGL_3DL_stereo_control(GLEW_CONTEXT_ARG_VAR_INIT); -#endif /* WGL_3DL_stereo_control */ -#ifdef WGL_ARB_buffer_region - CONST_CAST(WGLEW_ARB_buffer_region) = wglewGetExtension("WGL_ARB_buffer_region"); - if (glewExperimental || WGLEW_ARB_buffer_region|| crippled) CONST_CAST(WGLEW_ARB_buffer_region)= !_glewInit_WGL_ARB_buffer_region(GLEW_CONTEXT_ARG_VAR_INIT); -#endif /* WGL_ARB_buffer_region */ -#ifdef WGL_ARB_create_context - CONST_CAST(WGLEW_ARB_create_context) = wglewGetExtension("WGL_ARB_create_context"); - if (glewExperimental || WGLEW_ARB_create_context|| crippled) CONST_CAST(WGLEW_ARB_create_context)= !_glewInit_WGL_ARB_create_context(GLEW_CONTEXT_ARG_VAR_INIT); -#endif /* WGL_ARB_create_context */ -#ifdef WGL_ARB_extensions_string - CONST_CAST(WGLEW_ARB_extensions_string) = wglewGetExtension("WGL_ARB_extensions_string"); - if (glewExperimental || WGLEW_ARB_extensions_string|| crippled) CONST_CAST(WGLEW_ARB_extensions_string)= !_glewInit_WGL_ARB_extensions_string(GLEW_CONTEXT_ARG_VAR_INIT); -#endif /* WGL_ARB_extensions_string */ -#ifdef WGL_ARB_framebuffer_sRGB - CONST_CAST(WGLEW_ARB_framebuffer_sRGB) = wglewGetExtension("WGL_ARB_framebuffer_sRGB"); -#endif /* WGL_ARB_framebuffer_sRGB */ -#ifdef WGL_ARB_make_current_read - CONST_CAST(WGLEW_ARB_make_current_read) = wglewGetExtension("WGL_ARB_make_current_read"); - if (glewExperimental || WGLEW_ARB_make_current_read|| crippled) CONST_CAST(WGLEW_ARB_make_current_read)= !_glewInit_WGL_ARB_make_current_read(GLEW_CONTEXT_ARG_VAR_INIT); -#endif /* WGL_ARB_make_current_read */ -#ifdef WGL_ARB_multisample - CONST_CAST(WGLEW_ARB_multisample) = wglewGetExtension("WGL_ARB_multisample"); -#endif /* WGL_ARB_multisample */ -#ifdef WGL_ARB_pbuffer - CONST_CAST(WGLEW_ARB_pbuffer) = wglewGetExtension("WGL_ARB_pbuffer"); - if (glewExperimental || WGLEW_ARB_pbuffer|| crippled) CONST_CAST(WGLEW_ARB_pbuffer)= !_glewInit_WGL_ARB_pbuffer(GLEW_CONTEXT_ARG_VAR_INIT); -#endif /* WGL_ARB_pbuffer */ -#ifdef WGL_ARB_pixel_format - CONST_CAST(WGLEW_ARB_pixel_format) = wglewGetExtension("WGL_ARB_pixel_format"); - if (glewExperimental || WGLEW_ARB_pixel_format|| crippled) CONST_CAST(WGLEW_ARB_pixel_format)= !_glewInit_WGL_ARB_pixel_format(GLEW_CONTEXT_ARG_VAR_INIT); -#endif /* WGL_ARB_pixel_format */ -#ifdef WGL_ARB_pixel_format_float - CONST_CAST(WGLEW_ARB_pixel_format_float) = wglewGetExtension("WGL_ARB_pixel_format_float"); -#endif /* WGL_ARB_pixel_format_float */ -#ifdef WGL_ARB_render_texture - CONST_CAST(WGLEW_ARB_render_texture) = wglewGetExtension("WGL_ARB_render_texture"); - if (glewExperimental || WGLEW_ARB_render_texture|| crippled) CONST_CAST(WGLEW_ARB_render_texture)= !_glewInit_WGL_ARB_render_texture(GLEW_CONTEXT_ARG_VAR_INIT); -#endif /* WGL_ARB_render_texture */ -#ifdef WGL_ATI_pixel_format_float - CONST_CAST(WGLEW_ATI_pixel_format_float) = wglewGetExtension("WGL_ATI_pixel_format_float"); -#endif /* WGL_ATI_pixel_format_float */ -#ifdef WGL_ATI_render_texture_rectangle - CONST_CAST(WGLEW_ATI_render_texture_rectangle) = wglewGetExtension("WGL_ATI_render_texture_rectangle"); -#endif /* WGL_ATI_render_texture_rectangle */ -#ifdef WGL_EXT_depth_float - CONST_CAST(WGLEW_EXT_depth_float) = wglewGetExtension("WGL_EXT_depth_float"); -#endif /* WGL_EXT_depth_float */ -#ifdef WGL_EXT_display_color_table - CONST_CAST(WGLEW_EXT_display_color_table) = wglewGetExtension("WGL_EXT_display_color_table"); - if (glewExperimental || WGLEW_EXT_display_color_table|| crippled) CONST_CAST(WGLEW_EXT_display_color_table)= !_glewInit_WGL_EXT_display_color_table(GLEW_CONTEXT_ARG_VAR_INIT); -#endif /* WGL_EXT_display_color_table */ -#ifdef WGL_EXT_extensions_string - CONST_CAST(WGLEW_EXT_extensions_string) = wglewGetExtension("WGL_EXT_extensions_string"); - if (glewExperimental || WGLEW_EXT_extensions_string|| crippled) CONST_CAST(WGLEW_EXT_extensions_string)= !_glewInit_WGL_EXT_extensions_string(GLEW_CONTEXT_ARG_VAR_INIT); -#endif /* WGL_EXT_extensions_string */ -#ifdef WGL_EXT_framebuffer_sRGB - CONST_CAST(WGLEW_EXT_framebuffer_sRGB) = wglewGetExtension("WGL_EXT_framebuffer_sRGB"); -#endif /* WGL_EXT_framebuffer_sRGB */ -#ifdef WGL_EXT_make_current_read - CONST_CAST(WGLEW_EXT_make_current_read) = wglewGetExtension("WGL_EXT_make_current_read"); - if (glewExperimental || WGLEW_EXT_make_current_read|| crippled) CONST_CAST(WGLEW_EXT_make_current_read)= !_glewInit_WGL_EXT_make_current_read(GLEW_CONTEXT_ARG_VAR_INIT); -#endif /* WGL_EXT_make_current_read */ -#ifdef WGL_EXT_multisample - CONST_CAST(WGLEW_EXT_multisample) = wglewGetExtension("WGL_EXT_multisample"); -#endif /* WGL_EXT_multisample */ -#ifdef WGL_EXT_pbuffer - CONST_CAST(WGLEW_EXT_pbuffer) = wglewGetExtension("WGL_EXT_pbuffer"); - if (glewExperimental || WGLEW_EXT_pbuffer|| crippled) CONST_CAST(WGLEW_EXT_pbuffer)= !_glewInit_WGL_EXT_pbuffer(GLEW_CONTEXT_ARG_VAR_INIT); -#endif /* WGL_EXT_pbuffer */ -#ifdef WGL_EXT_pixel_format - CONST_CAST(WGLEW_EXT_pixel_format) = wglewGetExtension("WGL_EXT_pixel_format"); - if (glewExperimental || WGLEW_EXT_pixel_format|| crippled) CONST_CAST(WGLEW_EXT_pixel_format)= !_glewInit_WGL_EXT_pixel_format(GLEW_CONTEXT_ARG_VAR_INIT); -#endif /* WGL_EXT_pixel_format */ -#ifdef WGL_EXT_pixel_format_packed_float - CONST_CAST(WGLEW_EXT_pixel_format_packed_float) = wglewGetExtension("WGL_EXT_pixel_format_packed_float"); -#endif /* WGL_EXT_pixel_format_packed_float */ -#ifdef WGL_EXT_swap_control - CONST_CAST(WGLEW_EXT_swap_control) = wglewGetExtension("WGL_EXT_swap_control"); - if (glewExperimental || WGLEW_EXT_swap_control|| crippled) CONST_CAST(WGLEW_EXT_swap_control)= !_glewInit_WGL_EXT_swap_control(GLEW_CONTEXT_ARG_VAR_INIT); -#endif /* WGL_EXT_swap_control */ -#ifdef WGL_I3D_digital_video_control - CONST_CAST(WGLEW_I3D_digital_video_control) = wglewGetExtension("WGL_I3D_digital_video_control"); - if (glewExperimental || WGLEW_I3D_digital_video_control|| crippled) CONST_CAST(WGLEW_I3D_digital_video_control)= !_glewInit_WGL_I3D_digital_video_control(GLEW_CONTEXT_ARG_VAR_INIT); -#endif /* WGL_I3D_digital_video_control */ -#ifdef WGL_I3D_gamma - CONST_CAST(WGLEW_I3D_gamma) = wglewGetExtension("WGL_I3D_gamma"); - if (glewExperimental || WGLEW_I3D_gamma|| crippled) CONST_CAST(WGLEW_I3D_gamma)= !_glewInit_WGL_I3D_gamma(GLEW_CONTEXT_ARG_VAR_INIT); -#endif /* WGL_I3D_gamma */ -#ifdef WGL_I3D_genlock - CONST_CAST(WGLEW_I3D_genlock) = wglewGetExtension("WGL_I3D_genlock"); - if (glewExperimental || WGLEW_I3D_genlock|| crippled) CONST_CAST(WGLEW_I3D_genlock)= !_glewInit_WGL_I3D_genlock(GLEW_CONTEXT_ARG_VAR_INIT); -#endif /* WGL_I3D_genlock */ -#ifdef WGL_I3D_image_buffer - CONST_CAST(WGLEW_I3D_image_buffer) = wglewGetExtension("WGL_I3D_image_buffer"); - if (glewExperimental || WGLEW_I3D_image_buffer|| crippled) CONST_CAST(WGLEW_I3D_image_buffer)= !_glewInit_WGL_I3D_image_buffer(GLEW_CONTEXT_ARG_VAR_INIT); -#endif /* WGL_I3D_image_buffer */ -#ifdef WGL_I3D_swap_frame_lock - CONST_CAST(WGLEW_I3D_swap_frame_lock) = wglewGetExtension("WGL_I3D_swap_frame_lock"); - if (glewExperimental || WGLEW_I3D_swap_frame_lock|| crippled) CONST_CAST(WGLEW_I3D_swap_frame_lock)= !_glewInit_WGL_I3D_swap_frame_lock(GLEW_CONTEXT_ARG_VAR_INIT); -#endif /* WGL_I3D_swap_frame_lock */ -#ifdef WGL_I3D_swap_frame_usage - CONST_CAST(WGLEW_I3D_swap_frame_usage) = wglewGetExtension("WGL_I3D_swap_frame_usage"); - if (glewExperimental || WGLEW_I3D_swap_frame_usage|| crippled) CONST_CAST(WGLEW_I3D_swap_frame_usage)= !_glewInit_WGL_I3D_swap_frame_usage(GLEW_CONTEXT_ARG_VAR_INIT); -#endif /* WGL_I3D_swap_frame_usage */ -#ifdef WGL_NV_float_buffer - CONST_CAST(WGLEW_NV_float_buffer) = wglewGetExtension("WGL_NV_float_buffer"); -#endif /* WGL_NV_float_buffer */ -#ifdef WGL_NV_gpu_affinity - CONST_CAST(WGLEW_NV_gpu_affinity) = wglewGetExtension("WGL_NV_gpu_affinity"); - if (glewExperimental || WGLEW_NV_gpu_affinity|| crippled) CONST_CAST(WGLEW_NV_gpu_affinity)= !_glewInit_WGL_NV_gpu_affinity(GLEW_CONTEXT_ARG_VAR_INIT); -#endif /* WGL_NV_gpu_affinity */ -#ifdef WGL_NV_present_video - CONST_CAST(WGLEW_NV_present_video) = wglewGetExtension("WGL_NV_present_video"); - if (glewExperimental || WGLEW_NV_present_video|| crippled) CONST_CAST(WGLEW_NV_present_video)= !_glewInit_WGL_NV_present_video(GLEW_CONTEXT_ARG_VAR_INIT); -#endif /* WGL_NV_present_video */ -#ifdef WGL_NV_render_depth_texture - CONST_CAST(WGLEW_NV_render_depth_texture) = wglewGetExtension("WGL_NV_render_depth_texture"); -#endif /* WGL_NV_render_depth_texture */ -#ifdef WGL_NV_render_texture_rectangle - CONST_CAST(WGLEW_NV_render_texture_rectangle) = wglewGetExtension("WGL_NV_render_texture_rectangle"); -#endif /* WGL_NV_render_texture_rectangle */ -#ifdef WGL_NV_swap_group - CONST_CAST(WGLEW_NV_swap_group) = wglewGetExtension("WGL_NV_swap_group"); - if (glewExperimental || WGLEW_NV_swap_group|| crippled) CONST_CAST(WGLEW_NV_swap_group)= !_glewInit_WGL_NV_swap_group(GLEW_CONTEXT_ARG_VAR_INIT); -#endif /* WGL_NV_swap_group */ -#ifdef WGL_NV_vertex_array_range - CONST_CAST(WGLEW_NV_vertex_array_range) = wglewGetExtension("WGL_NV_vertex_array_range"); - if (glewExperimental || WGLEW_NV_vertex_array_range|| crippled) CONST_CAST(WGLEW_NV_vertex_array_range)= !_glewInit_WGL_NV_vertex_array_range(GLEW_CONTEXT_ARG_VAR_INIT); -#endif /* WGL_NV_vertex_array_range */ -#ifdef WGL_NV_video_output - CONST_CAST(WGLEW_NV_video_output) = wglewGetExtension("WGL_NV_video_output"); - if (glewExperimental || WGLEW_NV_video_output|| crippled) CONST_CAST(WGLEW_NV_video_output)= !_glewInit_WGL_NV_video_output(GLEW_CONTEXT_ARG_VAR_INIT); -#endif /* WGL_NV_video_output */ -#ifdef WGL_OML_sync_control - CONST_CAST(WGLEW_OML_sync_control) = wglewGetExtension("WGL_OML_sync_control"); - if (glewExperimental || WGLEW_OML_sync_control|| crippled) CONST_CAST(WGLEW_OML_sync_control)= !_glewInit_WGL_OML_sync_control(GLEW_CONTEXT_ARG_VAR_INIT); -#endif /* WGL_OML_sync_control */ - - return GLEW_OK; -} - -#elif !defined(__APPLE__) || defined(GLEW_APPLE_GLX) - -PFNGLXGETCURRENTDISPLAYPROC __glewXGetCurrentDisplay = NULL; - -PFNGLXCHOOSEFBCONFIGPROC __glewXChooseFBConfig = NULL; -PFNGLXCREATENEWCONTEXTPROC __glewXCreateNewContext = NULL; -PFNGLXCREATEPBUFFERPROC __glewXCreatePbuffer = NULL; -PFNGLXCREATEPIXMAPPROC __glewXCreatePixmap = NULL; -PFNGLXCREATEWINDOWPROC __glewXCreateWindow = NULL; -PFNGLXDESTROYPBUFFERPROC __glewXDestroyPbuffer = NULL; -PFNGLXDESTROYPIXMAPPROC __glewXDestroyPixmap = NULL; -PFNGLXDESTROYWINDOWPROC __glewXDestroyWindow = NULL; -PFNGLXGETCURRENTREADDRAWABLEPROC __glewXGetCurrentReadDrawable = NULL; -PFNGLXGETFBCONFIGATTRIBPROC __glewXGetFBConfigAttrib = NULL; -PFNGLXGETFBCONFIGSPROC __glewXGetFBConfigs = NULL; -PFNGLXGETSELECTEDEVENTPROC __glewXGetSelectedEvent = NULL; -PFNGLXGETVISUALFROMFBCONFIGPROC __glewXGetVisualFromFBConfig = NULL; -PFNGLXMAKECONTEXTCURRENTPROC __glewXMakeContextCurrent = NULL; -PFNGLXQUERYCONTEXTPROC __glewXQueryContext = NULL; -PFNGLXQUERYDRAWABLEPROC __glewXQueryDrawable = NULL; -PFNGLXSELECTEVENTPROC __glewXSelectEvent = NULL; - -PFNGLXCREATECONTEXTATTRIBSARBPROC __glewXCreateContextAttribsARB = NULL; - -PFNGLXBINDTEXIMAGEATIPROC __glewXBindTexImageATI = NULL; -PFNGLXDRAWABLEATTRIBATIPROC __glewXDrawableAttribATI = NULL; -PFNGLXRELEASETEXIMAGEATIPROC __glewXReleaseTexImageATI = NULL; - -PFNGLXFREECONTEXTEXTPROC __glewXFreeContextEXT = NULL; -PFNGLXGETCONTEXTIDEXTPROC __glewXGetContextIDEXT = NULL; -PFNGLXIMPORTCONTEXTEXTPROC __glewXImportContextEXT = NULL; -PFNGLXQUERYCONTEXTINFOEXTPROC __glewXQueryContextInfoEXT = NULL; - -PFNGLXBINDTEXIMAGEEXTPROC __glewXBindTexImageEXT = NULL; -PFNGLXRELEASETEXIMAGEEXTPROC __glewXReleaseTexImageEXT = NULL; - -PFNGLXGETAGPOFFSETMESAPROC __glewXGetAGPOffsetMESA = NULL; - -PFNGLXCOPYSUBBUFFERMESAPROC __glewXCopySubBufferMESA = NULL; - -PFNGLXCREATEGLXPIXMAPMESAPROC __glewXCreateGLXPixmapMESA = NULL; - -PFNGLXRELEASEBUFFERSMESAPROC __glewXReleaseBuffersMESA = NULL; - -PFNGLXSET3DFXMODEMESAPROC __glewXSet3DfxModeMESA = NULL; - -PFNGLXBINDVIDEODEVICENVPROC __glewXBindVideoDeviceNV = NULL; -PFNGLXENUMERATEVIDEODEVICESNVPROC __glewXEnumerateVideoDevicesNV = NULL; - -PFNGLXBINDSWAPBARRIERNVPROC __glewXBindSwapBarrierNV = NULL; -PFNGLXJOINSWAPGROUPNVPROC __glewXJoinSwapGroupNV = NULL; -PFNGLXQUERYFRAMECOUNTNVPROC __glewXQueryFrameCountNV = NULL; -PFNGLXQUERYMAXSWAPGROUPSNVPROC __glewXQueryMaxSwapGroupsNV = NULL; -PFNGLXQUERYSWAPGROUPNVPROC __glewXQuerySwapGroupNV = NULL; -PFNGLXRESETFRAMECOUNTNVPROC __glewXResetFrameCountNV = NULL; - -PFNGLXALLOCATEMEMORYNVPROC __glewXAllocateMemoryNV = NULL; -PFNGLXFREEMEMORYNVPROC __glewXFreeMemoryNV = NULL; - -PFNGLXBINDVIDEOIMAGENVPROC __glewXBindVideoImageNV = NULL; -PFNGLXGETVIDEODEVICENVPROC __glewXGetVideoDeviceNV = NULL; -PFNGLXGETVIDEOINFONVPROC __glewXGetVideoInfoNV = NULL; -PFNGLXRELEASEVIDEODEVICENVPROC __glewXReleaseVideoDeviceNV = NULL; -PFNGLXRELEASEVIDEOIMAGENVPROC __glewXReleaseVideoImageNV = NULL; -PFNGLXSENDPBUFFERTOVIDEONVPROC __glewXSendPbufferToVideoNV = NULL; - -#ifdef GLX_OML_sync_control -PFNGLXGETMSCRATEOMLPROC __glewXGetMscRateOML = NULL; -PFNGLXGETSYNCVALUESOMLPROC __glewXGetSyncValuesOML = NULL; -PFNGLXSWAPBUFFERSMSCOMLPROC __glewXSwapBuffersMscOML = NULL; -PFNGLXWAITFORMSCOMLPROC __glewXWaitForMscOML = NULL; -PFNGLXWAITFORSBCOMLPROC __glewXWaitForSbcOML = NULL; -#endif - -PFNGLXCHOOSEFBCONFIGSGIXPROC __glewXChooseFBConfigSGIX = NULL; -PFNGLXCREATECONTEXTWITHCONFIGSGIXPROC __glewXCreateContextWithConfigSGIX = NULL; -PFNGLXCREATEGLXPIXMAPWITHCONFIGSGIXPROC __glewXCreateGLXPixmapWithConfigSGIX = NULL; -PFNGLXGETFBCONFIGATTRIBSGIXPROC __glewXGetFBConfigAttribSGIX = NULL; -PFNGLXGETFBCONFIGFROMVISUALSGIXPROC __glewXGetFBConfigFromVisualSGIX = NULL; -PFNGLXGETVISUALFROMFBCONFIGSGIXPROC __glewXGetVisualFromFBConfigSGIX = NULL; - -PFNGLXBINDHYPERPIPESGIXPROC __glewXBindHyperpipeSGIX = NULL; -PFNGLXDESTROYHYPERPIPECONFIGSGIXPROC __glewXDestroyHyperpipeConfigSGIX = NULL; -PFNGLXHYPERPIPEATTRIBSGIXPROC __glewXHyperpipeAttribSGIX = NULL; -PFNGLXHYPERPIPECONFIGSGIXPROC __glewXHyperpipeConfigSGIX = NULL; -PFNGLXQUERYHYPERPIPEATTRIBSGIXPROC __glewXQueryHyperpipeAttribSGIX = NULL; -PFNGLXQUERYHYPERPIPEBESTATTRIBSGIXPROC __glewXQueryHyperpipeBestAttribSGIX = NULL; -PFNGLXQUERYHYPERPIPECONFIGSGIXPROC __glewXQueryHyperpipeConfigSGIX = NULL; -PFNGLXQUERYHYPERPIPENETWORKSGIXPROC __glewXQueryHyperpipeNetworkSGIX = NULL; - -PFNGLXCREATEGLXPBUFFERSGIXPROC __glewXCreateGLXPbufferSGIX = NULL; -PFNGLXDESTROYGLXPBUFFERSGIXPROC __glewXDestroyGLXPbufferSGIX = NULL; -PFNGLXGETSELECTEDEVENTSGIXPROC __glewXGetSelectedEventSGIX = NULL; -PFNGLXQUERYGLXPBUFFERSGIXPROC __glewXQueryGLXPbufferSGIX = NULL; -PFNGLXSELECTEVENTSGIXPROC __glewXSelectEventSGIX = NULL; - -PFNGLXBINDSWAPBARRIERSGIXPROC __glewXBindSwapBarrierSGIX = NULL; -PFNGLXQUERYMAXSWAPBARRIERSSGIXPROC __glewXQueryMaxSwapBarriersSGIX = NULL; - -PFNGLXJOINSWAPGROUPSGIXPROC __glewXJoinSwapGroupSGIX = NULL; - -PFNGLXBINDCHANNELTOWINDOWSGIXPROC __glewXBindChannelToWindowSGIX = NULL; -PFNGLXCHANNELRECTSGIXPROC __glewXChannelRectSGIX = NULL; -PFNGLXCHANNELRECTSYNCSGIXPROC __glewXChannelRectSyncSGIX = NULL; -PFNGLXQUERYCHANNELDELTASSGIXPROC __glewXQueryChannelDeltasSGIX = NULL; -PFNGLXQUERYCHANNELRECTSGIXPROC __glewXQueryChannelRectSGIX = NULL; - -PFNGLXCUSHIONSGIPROC __glewXCushionSGI = NULL; - -PFNGLXGETCURRENTREADDRAWABLESGIPROC __glewXGetCurrentReadDrawableSGI = NULL; -PFNGLXMAKECURRENTREADSGIPROC __glewXMakeCurrentReadSGI = NULL; - -PFNGLXSWAPINTERVALSGIPROC __glewXSwapIntervalSGI = NULL; - -PFNGLXGETVIDEOSYNCSGIPROC __glewXGetVideoSyncSGI = NULL; -PFNGLXWAITVIDEOSYNCSGIPROC __glewXWaitVideoSyncSGI = NULL; - -PFNGLXGETTRANSPARENTINDEXSUNPROC __glewXGetTransparentIndexSUN = NULL; - -PFNGLXGETVIDEORESIZESUNPROC __glewXGetVideoResizeSUN = NULL; -PFNGLXVIDEORESIZESUNPROC __glewXVideoResizeSUN = NULL; - -#if !defined(GLEW_MX) - -GLboolean __GLXEW_VERSION_1_0 = GL_FALSE; -GLboolean __GLXEW_VERSION_1_1 = GL_FALSE; -GLboolean __GLXEW_VERSION_1_2 = GL_FALSE; -GLboolean __GLXEW_VERSION_1_3 = GL_FALSE; -GLboolean __GLXEW_VERSION_1_4 = GL_FALSE; -GLboolean __GLXEW_3DFX_multisample = GL_FALSE; -GLboolean __GLXEW_ARB_create_context = GL_FALSE; -GLboolean __GLXEW_ARB_fbconfig_float = GL_FALSE; -GLboolean __GLXEW_ARB_framebuffer_sRGB = GL_FALSE; -GLboolean __GLXEW_ARB_get_proc_address = GL_FALSE; -GLboolean __GLXEW_ARB_multisample = GL_FALSE; -GLboolean __GLXEW_ATI_pixel_format_float = GL_FALSE; -GLboolean __GLXEW_ATI_render_texture = GL_FALSE; -GLboolean __GLXEW_EXT_fbconfig_packed_float = GL_FALSE; -GLboolean __GLXEW_EXT_framebuffer_sRGB = GL_FALSE; -GLboolean __GLXEW_EXT_import_context = GL_FALSE; -GLboolean __GLXEW_EXT_scene_marker = GL_FALSE; -GLboolean __GLXEW_EXT_texture_from_pixmap = GL_FALSE; -GLboolean __GLXEW_EXT_visual_info = GL_FALSE; -GLboolean __GLXEW_EXT_visual_rating = GL_FALSE; -GLboolean __GLXEW_MESA_agp_offset = GL_FALSE; -GLboolean __GLXEW_MESA_copy_sub_buffer = GL_FALSE; -GLboolean __GLXEW_MESA_pixmap_colormap = GL_FALSE; -GLboolean __GLXEW_MESA_release_buffers = GL_FALSE; -GLboolean __GLXEW_MESA_set_3dfx_mode = GL_FALSE; -GLboolean __GLXEW_NV_float_buffer = GL_FALSE; -GLboolean __GLXEW_NV_present_video = GL_FALSE; -GLboolean __GLXEW_NV_swap_group = GL_FALSE; -GLboolean __GLXEW_NV_vertex_array_range = GL_FALSE; -GLboolean __GLXEW_NV_video_output = GL_FALSE; -GLboolean __GLXEW_OML_swap_method = GL_FALSE; -#ifdef GLX_OML_sync_control -GLboolean __GLXEW_OML_sync_control = GL_FALSE; -#endif -GLboolean __GLXEW_SGIS_blended_overlay = GL_FALSE; -GLboolean __GLXEW_SGIS_color_range = GL_FALSE; -GLboolean __GLXEW_SGIS_multisample = GL_FALSE; -GLboolean __GLXEW_SGIS_shared_multisample = GL_FALSE; -GLboolean __GLXEW_SGIX_fbconfig = GL_FALSE; -GLboolean __GLXEW_SGIX_hyperpipe = GL_FALSE; -GLboolean __GLXEW_SGIX_pbuffer = GL_FALSE; -GLboolean __GLXEW_SGIX_swap_barrier = GL_FALSE; -GLboolean __GLXEW_SGIX_swap_group = GL_FALSE; -GLboolean __GLXEW_SGIX_video_resize = GL_FALSE; -GLboolean __GLXEW_SGIX_visual_select_group = GL_FALSE; -GLboolean __GLXEW_SGI_cushion = GL_FALSE; -GLboolean __GLXEW_SGI_make_current_read = GL_FALSE; -GLboolean __GLXEW_SGI_swap_control = GL_FALSE; -GLboolean __GLXEW_SGI_video_sync = GL_FALSE; -GLboolean __GLXEW_SUN_get_transparent_index = GL_FALSE; -GLboolean __GLXEW_SUN_video_resize = GL_FALSE; - -#endif /* !GLEW_MX */ - -#ifdef GLX_VERSION_1_2 - -static GLboolean _glewInit_GLX_VERSION_1_2 (GLXEW_CONTEXT_ARG_DEF_INIT) -{ - GLboolean r = GL_FALSE; - - r = ((glXGetCurrentDisplay = (PFNGLXGETCURRENTDISPLAYPROC)glewGetProcAddress((const GLubyte*)"glXGetCurrentDisplay")) == NULL) || r; - - return r; -} - -#endif /* GLX_VERSION_1_2 */ - -#ifdef GLX_VERSION_1_3 - -static GLboolean _glewInit_GLX_VERSION_1_3 (GLXEW_CONTEXT_ARG_DEF_INIT) -{ - GLboolean r = GL_FALSE; - - r = ((glXChooseFBConfig = (PFNGLXCHOOSEFBCONFIGPROC)glewGetProcAddress((const GLubyte*)"glXChooseFBConfig")) == NULL) || r; - r = ((glXCreateNewContext = (PFNGLXCREATENEWCONTEXTPROC)glewGetProcAddress((const GLubyte*)"glXCreateNewContext")) == NULL) || r; - r = ((glXCreatePbuffer = (PFNGLXCREATEPBUFFERPROC)glewGetProcAddress((const GLubyte*)"glXCreatePbuffer")) == NULL) || r; - r = ((glXCreatePixmap = (PFNGLXCREATEPIXMAPPROC)glewGetProcAddress((const GLubyte*)"glXCreatePixmap")) == NULL) || r; - r = ((glXCreateWindow = (PFNGLXCREATEWINDOWPROC)glewGetProcAddress((const GLubyte*)"glXCreateWindow")) == NULL) || r; - r = ((glXDestroyPbuffer = (PFNGLXDESTROYPBUFFERPROC)glewGetProcAddress((const GLubyte*)"glXDestroyPbuffer")) == NULL) || r; - r = ((glXDestroyPixmap = (PFNGLXDESTROYPIXMAPPROC)glewGetProcAddress((const GLubyte*)"glXDestroyPixmap")) == NULL) || r; - r = ((glXDestroyWindow = (PFNGLXDESTROYWINDOWPROC)glewGetProcAddress((const GLubyte*)"glXDestroyWindow")) == NULL) || r; - r = ((glXGetCurrentReadDrawable = (PFNGLXGETCURRENTREADDRAWABLEPROC)glewGetProcAddress((const GLubyte*)"glXGetCurrentReadDrawable")) == NULL) || r; - r = ((glXGetFBConfigAttrib = (PFNGLXGETFBCONFIGATTRIBPROC)glewGetProcAddress((const GLubyte*)"glXGetFBConfigAttrib")) == NULL) || r; - r = ((glXGetFBConfigs = (PFNGLXGETFBCONFIGSPROC)glewGetProcAddress((const GLubyte*)"glXGetFBConfigs")) == NULL) || r; - r = ((glXGetSelectedEvent = (PFNGLXGETSELECTEDEVENTPROC)glewGetProcAddress((const GLubyte*)"glXGetSelectedEvent")) == NULL) || r; - r = ((glXGetVisualFromFBConfig = (PFNGLXGETVISUALFROMFBCONFIGPROC)glewGetProcAddress((const GLubyte*)"glXGetVisualFromFBConfig")) == NULL) || r; - r = ((glXMakeContextCurrent = (PFNGLXMAKECONTEXTCURRENTPROC)glewGetProcAddress((const GLubyte*)"glXMakeContextCurrent")) == NULL) || r; - r = ((glXQueryContext = (PFNGLXQUERYCONTEXTPROC)glewGetProcAddress((const GLubyte*)"glXQueryContext")) == NULL) || r; - r = ((glXQueryDrawable = (PFNGLXQUERYDRAWABLEPROC)glewGetProcAddress((const GLubyte*)"glXQueryDrawable")) == NULL) || r; - r = ((glXSelectEvent = (PFNGLXSELECTEVENTPROC)glewGetProcAddress((const GLubyte*)"glXSelectEvent")) == NULL) || r; - - return r; -} - -#endif /* GLX_VERSION_1_3 */ - -#ifdef GLX_VERSION_1_4 - -#endif /* GLX_VERSION_1_4 */ - -#ifdef GLX_3DFX_multisample - -#endif /* GLX_3DFX_multisample */ - -#ifdef GLX_ARB_create_context - -static GLboolean _glewInit_GLX_ARB_create_context (GLXEW_CONTEXT_ARG_DEF_INIT) -{ - GLboolean r = GL_FALSE; - - r = ((glXCreateContextAttribsARB = (PFNGLXCREATECONTEXTATTRIBSARBPROC)glewGetProcAddress((const GLubyte*)"glXCreateContextAttribsARB")) == NULL) || r; - - return r; -} - -#endif /* GLX_ARB_create_context */ - -#ifdef GLX_ARB_fbconfig_float - -#endif /* GLX_ARB_fbconfig_float */ - -#ifdef GLX_ARB_framebuffer_sRGB - -#endif /* GLX_ARB_framebuffer_sRGB */ - -#ifdef GLX_ARB_get_proc_address - -#endif /* GLX_ARB_get_proc_address */ - -#ifdef GLX_ARB_multisample - -#endif /* GLX_ARB_multisample */ - -#ifdef GLX_ATI_pixel_format_float - -#endif /* GLX_ATI_pixel_format_float */ - -#ifdef GLX_ATI_render_texture - -static GLboolean _glewInit_GLX_ATI_render_texture (GLXEW_CONTEXT_ARG_DEF_INIT) -{ - GLboolean r = GL_FALSE; - - r = ((glXBindTexImageATI = (PFNGLXBINDTEXIMAGEATIPROC)glewGetProcAddress((const GLubyte*)"glXBindTexImageATI")) == NULL) || r; - r = ((glXDrawableAttribATI = (PFNGLXDRAWABLEATTRIBATIPROC)glewGetProcAddress((const GLubyte*)"glXDrawableAttribATI")) == NULL) || r; - r = ((glXReleaseTexImageATI = (PFNGLXRELEASETEXIMAGEATIPROC)glewGetProcAddress((const GLubyte*)"glXReleaseTexImageATI")) == NULL) || r; - - return r; -} - -#endif /* GLX_ATI_render_texture */ - -#ifdef GLX_EXT_fbconfig_packed_float - -#endif /* GLX_EXT_fbconfig_packed_float */ - -#ifdef GLX_EXT_framebuffer_sRGB - -#endif /* GLX_EXT_framebuffer_sRGB */ - -#ifdef GLX_EXT_import_context - -static GLboolean _glewInit_GLX_EXT_import_context (GLXEW_CONTEXT_ARG_DEF_INIT) -{ - GLboolean r = GL_FALSE; - - r = ((glXFreeContextEXT = (PFNGLXFREECONTEXTEXTPROC)glewGetProcAddress((const GLubyte*)"glXFreeContextEXT")) == NULL) || r; - r = ((glXGetContextIDEXT = (PFNGLXGETCONTEXTIDEXTPROC)glewGetProcAddress((const GLubyte*)"glXGetContextIDEXT")) == NULL) || r; - r = ((glXImportContextEXT = (PFNGLXIMPORTCONTEXTEXTPROC)glewGetProcAddress((const GLubyte*)"glXImportContextEXT")) == NULL) || r; - r = ((glXQueryContextInfoEXT = (PFNGLXQUERYCONTEXTINFOEXTPROC)glewGetProcAddress((const GLubyte*)"glXQueryContextInfoEXT")) == NULL) || r; - - return r; -} - -#endif /* GLX_EXT_import_context */ - -#ifdef GLX_EXT_scene_marker - -#endif /* GLX_EXT_scene_marker */ - -#ifdef GLX_EXT_texture_from_pixmap - -static GLboolean _glewInit_GLX_EXT_texture_from_pixmap (GLXEW_CONTEXT_ARG_DEF_INIT) -{ - GLboolean r = GL_FALSE; - - r = ((glXBindTexImageEXT = (PFNGLXBINDTEXIMAGEEXTPROC)glewGetProcAddress((const GLubyte*)"glXBindTexImageEXT")) == NULL) || r; - r = ((glXReleaseTexImageEXT = (PFNGLXRELEASETEXIMAGEEXTPROC)glewGetProcAddress((const GLubyte*)"glXReleaseTexImageEXT")) == NULL) || r; - - return r; -} - -#endif /* GLX_EXT_texture_from_pixmap */ - -#ifdef GLX_EXT_visual_info - -#endif /* GLX_EXT_visual_info */ - -#ifdef GLX_EXT_visual_rating - -#endif /* GLX_EXT_visual_rating */ - -#ifdef GLX_MESA_agp_offset - -static GLboolean _glewInit_GLX_MESA_agp_offset (GLXEW_CONTEXT_ARG_DEF_INIT) -{ - GLboolean r = GL_FALSE; - - r = ((glXGetAGPOffsetMESA = (PFNGLXGETAGPOFFSETMESAPROC)glewGetProcAddress((const GLubyte*)"glXGetAGPOffsetMESA")) == NULL) || r; - - return r; -} - -#endif /* GLX_MESA_agp_offset */ - -#ifdef GLX_MESA_copy_sub_buffer - -static GLboolean _glewInit_GLX_MESA_copy_sub_buffer (GLXEW_CONTEXT_ARG_DEF_INIT) -{ - GLboolean r = GL_FALSE; - - r = ((glXCopySubBufferMESA = (PFNGLXCOPYSUBBUFFERMESAPROC)glewGetProcAddress((const GLubyte*)"glXCopySubBufferMESA")) == NULL) || r; - - return r; -} - -#endif /* GLX_MESA_copy_sub_buffer */ - -#ifdef GLX_MESA_pixmap_colormap - -static GLboolean _glewInit_GLX_MESA_pixmap_colormap (GLXEW_CONTEXT_ARG_DEF_INIT) -{ - GLboolean r = GL_FALSE; - - r = ((glXCreateGLXPixmapMESA = (PFNGLXCREATEGLXPIXMAPMESAPROC)glewGetProcAddress((const GLubyte*)"glXCreateGLXPixmapMESA")) == NULL) || r; - - return r; -} - -#endif /* GLX_MESA_pixmap_colormap */ - -#ifdef GLX_MESA_release_buffers - -static GLboolean _glewInit_GLX_MESA_release_buffers (GLXEW_CONTEXT_ARG_DEF_INIT) -{ - GLboolean r = GL_FALSE; - - r = ((glXReleaseBuffersMESA = (PFNGLXRELEASEBUFFERSMESAPROC)glewGetProcAddress((const GLubyte*)"glXReleaseBuffersMESA")) == NULL) || r; - - return r; -} - -#endif /* GLX_MESA_release_buffers */ - -#ifdef GLX_MESA_set_3dfx_mode - -static GLboolean _glewInit_GLX_MESA_set_3dfx_mode (GLXEW_CONTEXT_ARG_DEF_INIT) -{ - GLboolean r = GL_FALSE; - - r = ((glXSet3DfxModeMESA = (PFNGLXSET3DFXMODEMESAPROC)glewGetProcAddress((const GLubyte*)"glXSet3DfxModeMESA")) == NULL) || r; - - return r; -} - -#endif /* GLX_MESA_set_3dfx_mode */ - -#ifdef GLX_NV_float_buffer - -#endif /* GLX_NV_float_buffer */ - -#ifdef GLX_NV_present_video - -static GLboolean _glewInit_GLX_NV_present_video (GLXEW_CONTEXT_ARG_DEF_INIT) -{ - GLboolean r = GL_FALSE; - - r = ((glXBindVideoDeviceNV = (PFNGLXBINDVIDEODEVICENVPROC)glewGetProcAddress((const GLubyte*)"glXBindVideoDeviceNV")) == NULL) || r; - r = ((glXEnumerateVideoDevicesNV = (PFNGLXENUMERATEVIDEODEVICESNVPROC)glewGetProcAddress((const GLubyte*)"glXEnumerateVideoDevicesNV")) == NULL) || r; - - return r; -} - -#endif /* GLX_NV_present_video */ - -#ifdef GLX_NV_swap_group - -static GLboolean _glewInit_GLX_NV_swap_group (GLXEW_CONTEXT_ARG_DEF_INIT) -{ - GLboolean r = GL_FALSE; - - r = ((glXBindSwapBarrierNV = (PFNGLXBINDSWAPBARRIERNVPROC)glewGetProcAddress((const GLubyte*)"glXBindSwapBarrierNV")) == NULL) || r; - r = ((glXJoinSwapGroupNV = (PFNGLXJOINSWAPGROUPNVPROC)glewGetProcAddress((const GLubyte*)"glXJoinSwapGroupNV")) == NULL) || r; - r = ((glXQueryFrameCountNV = (PFNGLXQUERYFRAMECOUNTNVPROC)glewGetProcAddress((const GLubyte*)"glXQueryFrameCountNV")) == NULL) || r; - r = ((glXQueryMaxSwapGroupsNV = (PFNGLXQUERYMAXSWAPGROUPSNVPROC)glewGetProcAddress((const GLubyte*)"glXQueryMaxSwapGroupsNV")) == NULL) || r; - r = ((glXQuerySwapGroupNV = (PFNGLXQUERYSWAPGROUPNVPROC)glewGetProcAddress((const GLubyte*)"glXQuerySwapGroupNV")) == NULL) || r; - r = ((glXResetFrameCountNV = (PFNGLXRESETFRAMECOUNTNVPROC)glewGetProcAddress((const GLubyte*)"glXResetFrameCountNV")) == NULL) || r; - - return r; -} - -#endif /* GLX_NV_swap_group */ - -#ifdef GLX_NV_vertex_array_range - -static GLboolean _glewInit_GLX_NV_vertex_array_range (GLXEW_CONTEXT_ARG_DEF_INIT) -{ - GLboolean r = GL_FALSE; - - r = ((glXAllocateMemoryNV = (PFNGLXALLOCATEMEMORYNVPROC)glewGetProcAddress((const GLubyte*)"glXAllocateMemoryNV")) == NULL) || r; - r = ((glXFreeMemoryNV = (PFNGLXFREEMEMORYNVPROC)glewGetProcAddress((const GLubyte*)"glXFreeMemoryNV")) == NULL) || r; - - return r; -} - -#endif /* GLX_NV_vertex_array_range */ - -#ifdef GLX_NV_video_output - -static GLboolean _glewInit_GLX_NV_video_output (GLXEW_CONTEXT_ARG_DEF_INIT) -{ - GLboolean r = GL_FALSE; - - r = ((glXBindVideoImageNV = (PFNGLXBINDVIDEOIMAGENVPROC)glewGetProcAddress((const GLubyte*)"glXBindVideoImageNV")) == NULL) || r; - r = ((glXGetVideoDeviceNV = (PFNGLXGETVIDEODEVICENVPROC)glewGetProcAddress((const GLubyte*)"glXGetVideoDeviceNV")) == NULL) || r; - r = ((glXGetVideoInfoNV = (PFNGLXGETVIDEOINFONVPROC)glewGetProcAddress((const GLubyte*)"glXGetVideoInfoNV")) == NULL) || r; - r = ((glXReleaseVideoDeviceNV = (PFNGLXRELEASEVIDEODEVICENVPROC)glewGetProcAddress((const GLubyte*)"glXReleaseVideoDeviceNV")) == NULL) || r; - r = ((glXReleaseVideoImageNV = (PFNGLXRELEASEVIDEOIMAGENVPROC)glewGetProcAddress((const GLubyte*)"glXReleaseVideoImageNV")) == NULL) || r; - r = ((glXSendPbufferToVideoNV = (PFNGLXSENDPBUFFERTOVIDEONVPROC)glewGetProcAddress((const GLubyte*)"glXSendPbufferToVideoNV")) == NULL) || r; - - return r; -} - -#endif /* GLX_NV_video_output */ - -#ifdef GLX_OML_swap_method - -#endif /* GLX_OML_swap_method */ - -#if defined(GLX_OML_sync_control) && defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L) -#include - -static GLboolean _glewInit_GLX_OML_sync_control (GLXEW_CONTEXT_ARG_DEF_INIT) -{ - GLboolean r = GL_FALSE; - - r = ((glXGetMscRateOML = (PFNGLXGETMSCRATEOMLPROC)glewGetProcAddress((const GLubyte*)"glXGetMscRateOML")) == NULL) || r; - r = ((glXGetSyncValuesOML = (PFNGLXGETSYNCVALUESOMLPROC)glewGetProcAddress((const GLubyte*)"glXGetSyncValuesOML")) == NULL) || r; - r = ((glXSwapBuffersMscOML = (PFNGLXSWAPBUFFERSMSCOMLPROC)glewGetProcAddress((const GLubyte*)"glXSwapBuffersMscOML")) == NULL) || r; - r = ((glXWaitForMscOML = (PFNGLXWAITFORMSCOMLPROC)glewGetProcAddress((const GLubyte*)"glXWaitForMscOML")) == NULL) || r; - r = ((glXWaitForSbcOML = (PFNGLXWAITFORSBCOMLPROC)glewGetProcAddress((const GLubyte*)"glXWaitForSbcOML")) == NULL) || r; - - return r; -} - -#endif /* GLX_OML_sync_control */ - -#ifdef GLX_SGIS_blended_overlay - -#endif /* GLX_SGIS_blended_overlay */ - -#ifdef GLX_SGIS_color_range - -#endif /* GLX_SGIS_color_range */ - -#ifdef GLX_SGIS_multisample - -#endif /* GLX_SGIS_multisample */ - -#ifdef GLX_SGIS_shared_multisample - -#endif /* GLX_SGIS_shared_multisample */ - -#ifdef GLX_SGIX_fbconfig - -static GLboolean _glewInit_GLX_SGIX_fbconfig (GLXEW_CONTEXT_ARG_DEF_INIT) -{ - GLboolean r = GL_FALSE; - - r = ((glXChooseFBConfigSGIX = (PFNGLXCHOOSEFBCONFIGSGIXPROC)glewGetProcAddress((const GLubyte*)"glXChooseFBConfigSGIX")) == NULL) || r; - r = ((glXCreateContextWithConfigSGIX = (PFNGLXCREATECONTEXTWITHCONFIGSGIXPROC)glewGetProcAddress((const GLubyte*)"glXCreateContextWithConfigSGIX")) == NULL) || r; - r = ((glXCreateGLXPixmapWithConfigSGIX = (PFNGLXCREATEGLXPIXMAPWITHCONFIGSGIXPROC)glewGetProcAddress((const GLubyte*)"glXCreateGLXPixmapWithConfigSGIX")) == NULL) || r; - r = ((glXGetFBConfigAttribSGIX = (PFNGLXGETFBCONFIGATTRIBSGIXPROC)glewGetProcAddress((const GLubyte*)"glXGetFBConfigAttribSGIX")) == NULL) || r; - r = ((glXGetFBConfigFromVisualSGIX = (PFNGLXGETFBCONFIGFROMVISUALSGIXPROC)glewGetProcAddress((const GLubyte*)"glXGetFBConfigFromVisualSGIX")) == NULL) || r; - r = ((glXGetVisualFromFBConfigSGIX = (PFNGLXGETVISUALFROMFBCONFIGSGIXPROC)glewGetProcAddress((const GLubyte*)"glXGetVisualFromFBConfigSGIX")) == NULL) || r; - - return r; -} - -#endif /* GLX_SGIX_fbconfig */ - -#ifdef GLX_SGIX_hyperpipe - -static GLboolean _glewInit_GLX_SGIX_hyperpipe (GLXEW_CONTEXT_ARG_DEF_INIT) -{ - GLboolean r = GL_FALSE; - - r = ((glXBindHyperpipeSGIX = (PFNGLXBINDHYPERPIPESGIXPROC)glewGetProcAddress((const GLubyte*)"glXBindHyperpipeSGIX")) == NULL) || r; - r = ((glXDestroyHyperpipeConfigSGIX = (PFNGLXDESTROYHYPERPIPECONFIGSGIXPROC)glewGetProcAddress((const GLubyte*)"glXDestroyHyperpipeConfigSGIX")) == NULL) || r; - r = ((glXHyperpipeAttribSGIX = (PFNGLXHYPERPIPEATTRIBSGIXPROC)glewGetProcAddress((const GLubyte*)"glXHyperpipeAttribSGIX")) == NULL) || r; - r = ((glXHyperpipeConfigSGIX = (PFNGLXHYPERPIPECONFIGSGIXPROC)glewGetProcAddress((const GLubyte*)"glXHyperpipeConfigSGIX")) == NULL) || r; - r = ((glXQueryHyperpipeAttribSGIX = (PFNGLXQUERYHYPERPIPEATTRIBSGIXPROC)glewGetProcAddress((const GLubyte*)"glXQueryHyperpipeAttribSGIX")) == NULL) || r; - r = ((glXQueryHyperpipeBestAttribSGIX = (PFNGLXQUERYHYPERPIPEBESTATTRIBSGIXPROC)glewGetProcAddress((const GLubyte*)"glXQueryHyperpipeBestAttribSGIX")) == NULL) || r; - r = ((glXQueryHyperpipeConfigSGIX = (PFNGLXQUERYHYPERPIPECONFIGSGIXPROC)glewGetProcAddress((const GLubyte*)"glXQueryHyperpipeConfigSGIX")) == NULL) || r; - r = ((glXQueryHyperpipeNetworkSGIX = (PFNGLXQUERYHYPERPIPENETWORKSGIXPROC)glewGetProcAddress((const GLubyte*)"glXQueryHyperpipeNetworkSGIX")) == NULL) || r; - - return r; -} - -#endif /* GLX_SGIX_hyperpipe */ - -#ifdef GLX_SGIX_pbuffer - -static GLboolean _glewInit_GLX_SGIX_pbuffer (GLXEW_CONTEXT_ARG_DEF_INIT) -{ - GLboolean r = GL_FALSE; - - r = ((glXCreateGLXPbufferSGIX = (PFNGLXCREATEGLXPBUFFERSGIXPROC)glewGetProcAddress((const GLubyte*)"glXCreateGLXPbufferSGIX")) == NULL) || r; - r = ((glXDestroyGLXPbufferSGIX = (PFNGLXDESTROYGLXPBUFFERSGIXPROC)glewGetProcAddress((const GLubyte*)"glXDestroyGLXPbufferSGIX")) == NULL) || r; - r = ((glXGetSelectedEventSGIX = (PFNGLXGETSELECTEDEVENTSGIXPROC)glewGetProcAddress((const GLubyte*)"glXGetSelectedEventSGIX")) == NULL) || r; - r = ((glXQueryGLXPbufferSGIX = (PFNGLXQUERYGLXPBUFFERSGIXPROC)glewGetProcAddress((const GLubyte*)"glXQueryGLXPbufferSGIX")) == NULL) || r; - r = ((glXSelectEventSGIX = (PFNGLXSELECTEVENTSGIXPROC)glewGetProcAddress((const GLubyte*)"glXSelectEventSGIX")) == NULL) || r; - - return r; -} - -#endif /* GLX_SGIX_pbuffer */ - -#ifdef GLX_SGIX_swap_barrier - -static GLboolean _glewInit_GLX_SGIX_swap_barrier (GLXEW_CONTEXT_ARG_DEF_INIT) -{ - GLboolean r = GL_FALSE; - - r = ((glXBindSwapBarrierSGIX = (PFNGLXBINDSWAPBARRIERSGIXPROC)glewGetProcAddress((const GLubyte*)"glXBindSwapBarrierSGIX")) == NULL) || r; - r = ((glXQueryMaxSwapBarriersSGIX = (PFNGLXQUERYMAXSWAPBARRIERSSGIXPROC)glewGetProcAddress((const GLubyte*)"glXQueryMaxSwapBarriersSGIX")) == NULL) || r; - - return r; -} - -#endif /* GLX_SGIX_swap_barrier */ - -#ifdef GLX_SGIX_swap_group - -static GLboolean _glewInit_GLX_SGIX_swap_group (GLXEW_CONTEXT_ARG_DEF_INIT) -{ - GLboolean r = GL_FALSE; - - r = ((glXJoinSwapGroupSGIX = (PFNGLXJOINSWAPGROUPSGIXPROC)glewGetProcAddress((const GLubyte*)"glXJoinSwapGroupSGIX")) == NULL) || r; - - return r; -} - -#endif /* GLX_SGIX_swap_group */ - -#ifdef GLX_SGIX_video_resize - -static GLboolean _glewInit_GLX_SGIX_video_resize (GLXEW_CONTEXT_ARG_DEF_INIT) -{ - GLboolean r = GL_FALSE; - - r = ((glXBindChannelToWindowSGIX = (PFNGLXBINDCHANNELTOWINDOWSGIXPROC)glewGetProcAddress((const GLubyte*)"glXBindChannelToWindowSGIX")) == NULL) || r; - r = ((glXChannelRectSGIX = (PFNGLXCHANNELRECTSGIXPROC)glewGetProcAddress((const GLubyte*)"glXChannelRectSGIX")) == NULL) || r; - r = ((glXChannelRectSyncSGIX = (PFNGLXCHANNELRECTSYNCSGIXPROC)glewGetProcAddress((const GLubyte*)"glXChannelRectSyncSGIX")) == NULL) || r; - r = ((glXQueryChannelDeltasSGIX = (PFNGLXQUERYCHANNELDELTASSGIXPROC)glewGetProcAddress((const GLubyte*)"glXQueryChannelDeltasSGIX")) == NULL) || r; - r = ((glXQueryChannelRectSGIX = (PFNGLXQUERYCHANNELRECTSGIXPROC)glewGetProcAddress((const GLubyte*)"glXQueryChannelRectSGIX")) == NULL) || r; - - return r; -} - -#endif /* GLX_SGIX_video_resize */ - -#ifdef GLX_SGIX_visual_select_group - -#endif /* GLX_SGIX_visual_select_group */ - -#ifdef GLX_SGI_cushion - -static GLboolean _glewInit_GLX_SGI_cushion (GLXEW_CONTEXT_ARG_DEF_INIT) -{ - GLboolean r = GL_FALSE; - - r = ((glXCushionSGI = (PFNGLXCUSHIONSGIPROC)glewGetProcAddress((const GLubyte*)"glXCushionSGI")) == NULL) || r; - - return r; -} - -#endif /* GLX_SGI_cushion */ - -#ifdef GLX_SGI_make_current_read - -static GLboolean _glewInit_GLX_SGI_make_current_read (GLXEW_CONTEXT_ARG_DEF_INIT) -{ - GLboolean r = GL_FALSE; - - r = ((glXGetCurrentReadDrawableSGI = (PFNGLXGETCURRENTREADDRAWABLESGIPROC)glewGetProcAddress((const GLubyte*)"glXGetCurrentReadDrawableSGI")) == NULL) || r; - r = ((glXMakeCurrentReadSGI = (PFNGLXMAKECURRENTREADSGIPROC)glewGetProcAddress((const GLubyte*)"glXMakeCurrentReadSGI")) == NULL) || r; - - return r; -} - -#endif /* GLX_SGI_make_current_read */ - -#ifdef GLX_SGI_swap_control - -static GLboolean _glewInit_GLX_SGI_swap_control (GLXEW_CONTEXT_ARG_DEF_INIT) -{ - GLboolean r = GL_FALSE; - - r = ((glXSwapIntervalSGI = (PFNGLXSWAPINTERVALSGIPROC)glewGetProcAddress((const GLubyte*)"glXSwapIntervalSGI")) == NULL) || r; - - return r; -} - -#endif /* GLX_SGI_swap_control */ - -#ifdef GLX_SGI_video_sync - -static GLboolean _glewInit_GLX_SGI_video_sync (GLXEW_CONTEXT_ARG_DEF_INIT) -{ - GLboolean r = GL_FALSE; - - r = ((glXGetVideoSyncSGI = (PFNGLXGETVIDEOSYNCSGIPROC)glewGetProcAddress((const GLubyte*)"glXGetVideoSyncSGI")) == NULL) || r; - r = ((glXWaitVideoSyncSGI = (PFNGLXWAITVIDEOSYNCSGIPROC)glewGetProcAddress((const GLubyte*)"glXWaitVideoSyncSGI")) == NULL) || r; - - return r; -} - -#endif /* GLX_SGI_video_sync */ - -#ifdef GLX_SUN_get_transparent_index - -static GLboolean _glewInit_GLX_SUN_get_transparent_index (GLXEW_CONTEXT_ARG_DEF_INIT) -{ - GLboolean r = GL_FALSE; - - r = ((glXGetTransparentIndexSUN = (PFNGLXGETTRANSPARENTINDEXSUNPROC)glewGetProcAddress((const GLubyte*)"glXGetTransparentIndexSUN")) == NULL) || r; - - return r; -} - -#endif /* GLX_SUN_get_transparent_index */ - -#ifdef GLX_SUN_video_resize - -static GLboolean _glewInit_GLX_SUN_video_resize (GLXEW_CONTEXT_ARG_DEF_INIT) -{ - GLboolean r = GL_FALSE; - - r = ((glXGetVideoResizeSUN = (PFNGLXGETVIDEORESIZESUNPROC)glewGetProcAddress((const GLubyte*)"glXGetVideoResizeSUN")) == NULL) || r; - r = ((glXVideoResizeSUN = (PFNGLXVIDEORESIZESUNPROC)glewGetProcAddress((const GLubyte*)"glXVideoResizeSUN")) == NULL) || r; - - return r; -} - -#endif /* GLX_SUN_video_resize */ - -/* ------------------------------------------------------------------------ */ - -GLboolean glxewGetExtension (const char* name) -{ - GLubyte* p; - GLubyte* end; - GLuint len = _glewStrLen((const GLubyte*)name); -/* if (glXQueryExtensionsString == NULL || glXGetCurrentDisplay == NULL) return GL_FALSE; */ -/* p = (GLubyte*)glXQueryExtensionsString(glXGetCurrentDisplay(), DefaultScreen(glXGetCurrentDisplay())); */ - if (glXGetClientString == NULL || glXGetCurrentDisplay == NULL) return GL_FALSE; - p = (GLubyte*)glXGetClientString(glXGetCurrentDisplay(), GLX_EXTENSIONS); - if (0 == p) return GL_FALSE; - end = p + _glewStrLen(p); - while (p < end) - { - GLuint n = _glewStrCLen(p, ' '); - if (len == n && _glewStrSame((const GLubyte*)name, p, n)) return GL_TRUE; - p += n+1; - } - return GL_FALSE; -} - -GLenum glxewContextInit (GLXEW_CONTEXT_ARG_DEF_LIST) -{ - int major, minor; - /* initialize core GLX 1.2 */ - if (_glewInit_GLX_VERSION_1_2(GLEW_CONTEXT_ARG_VAR_INIT)) return GLEW_ERROR_GLX_VERSION_11_ONLY; - /* initialize flags */ - CONST_CAST(GLXEW_VERSION_1_0) = GL_TRUE; - CONST_CAST(GLXEW_VERSION_1_1) = GL_TRUE; - CONST_CAST(GLXEW_VERSION_1_2) = GL_TRUE; - CONST_CAST(GLXEW_VERSION_1_3) = GL_TRUE; - CONST_CAST(GLXEW_VERSION_1_4) = GL_TRUE; - /* query GLX version */ - glXQueryVersion(glXGetCurrentDisplay(), &major, &minor); - if (major == 1 && minor <= 3) - { - switch (minor) - { - case 3: - CONST_CAST(GLXEW_VERSION_1_4) = GL_FALSE; - break; - case 2: - CONST_CAST(GLXEW_VERSION_1_4) = GL_FALSE; - CONST_CAST(GLXEW_VERSION_1_3) = GL_FALSE; - break; - default: - return GLEW_ERROR_GLX_VERSION_11_ONLY; - break; - } - } - /* initialize extensions */ -#ifdef GLX_VERSION_1_3 - if (glewExperimental || GLXEW_VERSION_1_3) CONST_CAST(GLXEW_VERSION_1_3) = !_glewInit_GLX_VERSION_1_3(GLEW_CONTEXT_ARG_VAR_INIT); -#endif /* GLX_VERSION_1_3 */ -#ifdef GLX_3DFX_multisample - CONST_CAST(GLXEW_3DFX_multisample) = glxewGetExtension("GLX_3DFX_multisample"); -#endif /* GLX_3DFX_multisample */ -#ifdef GLX_ARB_create_context - CONST_CAST(GLXEW_ARB_create_context) = glxewGetExtension("GLX_ARB_create_context"); - if (glewExperimental || GLXEW_ARB_create_context) CONST_CAST(GLXEW_ARB_create_context) = !_glewInit_GLX_ARB_create_context(GLEW_CONTEXT_ARG_VAR_INIT); -#endif /* GLX_ARB_create_context */ -#ifdef GLX_ARB_fbconfig_float - CONST_CAST(GLXEW_ARB_fbconfig_float) = glxewGetExtension("GLX_ARB_fbconfig_float"); -#endif /* GLX_ARB_fbconfig_float */ -#ifdef GLX_ARB_framebuffer_sRGB - CONST_CAST(GLXEW_ARB_framebuffer_sRGB) = glxewGetExtension("GLX_ARB_framebuffer_sRGB"); -#endif /* GLX_ARB_framebuffer_sRGB */ -#ifdef GLX_ARB_get_proc_address - CONST_CAST(GLXEW_ARB_get_proc_address) = glxewGetExtension("GLX_ARB_get_proc_address"); -#endif /* GLX_ARB_get_proc_address */ -#ifdef GLX_ARB_multisample - CONST_CAST(GLXEW_ARB_multisample) = glxewGetExtension("GLX_ARB_multisample"); -#endif /* GLX_ARB_multisample */ -#ifdef GLX_ATI_pixel_format_float - CONST_CAST(GLXEW_ATI_pixel_format_float) = glxewGetExtension("GLX_ATI_pixel_format_float"); -#endif /* GLX_ATI_pixel_format_float */ -#ifdef GLX_ATI_render_texture - CONST_CAST(GLXEW_ATI_render_texture) = glxewGetExtension("GLX_ATI_render_texture"); - if (glewExperimental || GLXEW_ATI_render_texture) CONST_CAST(GLXEW_ATI_render_texture) = !_glewInit_GLX_ATI_render_texture(GLEW_CONTEXT_ARG_VAR_INIT); -#endif /* GLX_ATI_render_texture */ -#ifdef GLX_EXT_fbconfig_packed_float - CONST_CAST(GLXEW_EXT_fbconfig_packed_float) = glxewGetExtension("GLX_EXT_fbconfig_packed_float"); -#endif /* GLX_EXT_fbconfig_packed_float */ -#ifdef GLX_EXT_framebuffer_sRGB - CONST_CAST(GLXEW_EXT_framebuffer_sRGB) = glxewGetExtension("GLX_EXT_framebuffer_sRGB"); -#endif /* GLX_EXT_framebuffer_sRGB */ -#ifdef GLX_EXT_import_context - CONST_CAST(GLXEW_EXT_import_context) = glxewGetExtension("GLX_EXT_import_context"); - if (glewExperimental || GLXEW_EXT_import_context) CONST_CAST(GLXEW_EXT_import_context) = !_glewInit_GLX_EXT_import_context(GLEW_CONTEXT_ARG_VAR_INIT); -#endif /* GLX_EXT_import_context */ -#ifdef GLX_EXT_scene_marker - CONST_CAST(GLXEW_EXT_scene_marker) = glxewGetExtension("GLX_EXT_scene_marker"); -#endif /* GLX_EXT_scene_marker */ -#ifdef GLX_EXT_texture_from_pixmap - CONST_CAST(GLXEW_EXT_texture_from_pixmap) = glxewGetExtension("GLX_EXT_texture_from_pixmap"); - if (glewExperimental || GLXEW_EXT_texture_from_pixmap) CONST_CAST(GLXEW_EXT_texture_from_pixmap) = !_glewInit_GLX_EXT_texture_from_pixmap(GLEW_CONTEXT_ARG_VAR_INIT); -#endif /* GLX_EXT_texture_from_pixmap */ -#ifdef GLX_EXT_visual_info - CONST_CAST(GLXEW_EXT_visual_info) = glxewGetExtension("GLX_EXT_visual_info"); -#endif /* GLX_EXT_visual_info */ -#ifdef GLX_EXT_visual_rating - CONST_CAST(GLXEW_EXT_visual_rating) = glxewGetExtension("GLX_EXT_visual_rating"); -#endif /* GLX_EXT_visual_rating */ -#ifdef GLX_MESA_agp_offset - CONST_CAST(GLXEW_MESA_agp_offset) = glxewGetExtension("GLX_MESA_agp_offset"); - if (glewExperimental || GLXEW_MESA_agp_offset) CONST_CAST(GLXEW_MESA_agp_offset) = !_glewInit_GLX_MESA_agp_offset(GLEW_CONTEXT_ARG_VAR_INIT); -#endif /* GLX_MESA_agp_offset */ -#ifdef GLX_MESA_copy_sub_buffer - CONST_CAST(GLXEW_MESA_copy_sub_buffer) = glxewGetExtension("GLX_MESA_copy_sub_buffer"); - if (glewExperimental || GLXEW_MESA_copy_sub_buffer) CONST_CAST(GLXEW_MESA_copy_sub_buffer) = !_glewInit_GLX_MESA_copy_sub_buffer(GLEW_CONTEXT_ARG_VAR_INIT); -#endif /* GLX_MESA_copy_sub_buffer */ -#ifdef GLX_MESA_pixmap_colormap - CONST_CAST(GLXEW_MESA_pixmap_colormap) = glxewGetExtension("GLX_MESA_pixmap_colormap"); - if (glewExperimental || GLXEW_MESA_pixmap_colormap) CONST_CAST(GLXEW_MESA_pixmap_colormap) = !_glewInit_GLX_MESA_pixmap_colormap(GLEW_CONTEXT_ARG_VAR_INIT); -#endif /* GLX_MESA_pixmap_colormap */ -#ifdef GLX_MESA_release_buffers - CONST_CAST(GLXEW_MESA_release_buffers) = glxewGetExtension("GLX_MESA_release_buffers"); - if (glewExperimental || GLXEW_MESA_release_buffers) CONST_CAST(GLXEW_MESA_release_buffers) = !_glewInit_GLX_MESA_release_buffers(GLEW_CONTEXT_ARG_VAR_INIT); -#endif /* GLX_MESA_release_buffers */ -#ifdef GLX_MESA_set_3dfx_mode - CONST_CAST(GLXEW_MESA_set_3dfx_mode) = glxewGetExtension("GLX_MESA_set_3dfx_mode"); - if (glewExperimental || GLXEW_MESA_set_3dfx_mode) CONST_CAST(GLXEW_MESA_set_3dfx_mode) = !_glewInit_GLX_MESA_set_3dfx_mode(GLEW_CONTEXT_ARG_VAR_INIT); -#endif /* GLX_MESA_set_3dfx_mode */ -#ifdef GLX_NV_float_buffer - CONST_CAST(GLXEW_NV_float_buffer) = glxewGetExtension("GLX_NV_float_buffer"); -#endif /* GLX_NV_float_buffer */ -#ifdef GLX_NV_present_video - CONST_CAST(GLXEW_NV_present_video) = glxewGetExtension("GLX_NV_present_video"); - if (glewExperimental || GLXEW_NV_present_video) CONST_CAST(GLXEW_NV_present_video) = !_glewInit_GLX_NV_present_video(GLEW_CONTEXT_ARG_VAR_INIT); -#endif /* GLX_NV_present_video */ -#ifdef GLX_NV_swap_group - CONST_CAST(GLXEW_NV_swap_group) = glxewGetExtension("GLX_NV_swap_group"); - if (glewExperimental || GLXEW_NV_swap_group) CONST_CAST(GLXEW_NV_swap_group) = !_glewInit_GLX_NV_swap_group(GLEW_CONTEXT_ARG_VAR_INIT); -#endif /* GLX_NV_swap_group */ -#ifdef GLX_NV_vertex_array_range - CONST_CAST(GLXEW_NV_vertex_array_range) = glxewGetExtension("GLX_NV_vertex_array_range"); - if (glewExperimental || GLXEW_NV_vertex_array_range) CONST_CAST(GLXEW_NV_vertex_array_range) = !_glewInit_GLX_NV_vertex_array_range(GLEW_CONTEXT_ARG_VAR_INIT); -#endif /* GLX_NV_vertex_array_range */ -#ifdef GLX_NV_video_output - CONST_CAST(GLXEW_NV_video_output) = glxewGetExtension("GLX_NV_video_output"); - if (glewExperimental || GLXEW_NV_video_output) CONST_CAST(GLXEW_NV_video_output) = !_glewInit_GLX_NV_video_output(GLEW_CONTEXT_ARG_VAR_INIT); -#endif /* GLX_NV_video_output */ -#ifdef GLX_OML_swap_method - CONST_CAST(GLXEW_OML_swap_method) = glxewGetExtension("GLX_OML_swap_method"); -#endif /* GLX_OML_swap_method */ -#if defined(GLX_OML_sync_control) && defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L) -#include - CONST_CAST(GLXEW_OML_sync_control) = glxewGetExtension("GLX_OML_sync_control"); - if (glewExperimental || GLXEW_OML_sync_control) CONST_CAST(GLXEW_OML_sync_control) = !_glewInit_GLX_OML_sync_control(GLEW_CONTEXT_ARG_VAR_INIT); -#endif /* GLX_OML_sync_control */ -#ifdef GLX_SGIS_blended_overlay - CONST_CAST(GLXEW_SGIS_blended_overlay) = glxewGetExtension("GLX_SGIS_blended_overlay"); -#endif /* GLX_SGIS_blended_overlay */ -#ifdef GLX_SGIS_color_range - CONST_CAST(GLXEW_SGIS_color_range) = glxewGetExtension("GLX_SGIS_color_range"); -#endif /* GLX_SGIS_color_range */ -#ifdef GLX_SGIS_multisample - CONST_CAST(GLXEW_SGIS_multisample) = glxewGetExtension("GLX_SGIS_multisample"); -#endif /* GLX_SGIS_multisample */ -#ifdef GLX_SGIS_shared_multisample - CONST_CAST(GLXEW_SGIS_shared_multisample) = glxewGetExtension("GLX_SGIS_shared_multisample"); -#endif /* GLX_SGIS_shared_multisample */ -#ifdef GLX_SGIX_fbconfig - CONST_CAST(GLXEW_SGIX_fbconfig) = glxewGetExtension("GLX_SGIX_fbconfig"); - if (glewExperimental || GLXEW_SGIX_fbconfig) CONST_CAST(GLXEW_SGIX_fbconfig) = !_glewInit_GLX_SGIX_fbconfig(GLEW_CONTEXT_ARG_VAR_INIT); -#endif /* GLX_SGIX_fbconfig */ -#ifdef GLX_SGIX_hyperpipe - CONST_CAST(GLXEW_SGIX_hyperpipe) = glxewGetExtension("GLX_SGIX_hyperpipe"); - if (glewExperimental || GLXEW_SGIX_hyperpipe) CONST_CAST(GLXEW_SGIX_hyperpipe) = !_glewInit_GLX_SGIX_hyperpipe(GLEW_CONTEXT_ARG_VAR_INIT); -#endif /* GLX_SGIX_hyperpipe */ -#ifdef GLX_SGIX_pbuffer - CONST_CAST(GLXEW_SGIX_pbuffer) = glxewGetExtension("GLX_SGIX_pbuffer"); - if (glewExperimental || GLXEW_SGIX_pbuffer) CONST_CAST(GLXEW_SGIX_pbuffer) = !_glewInit_GLX_SGIX_pbuffer(GLEW_CONTEXT_ARG_VAR_INIT); -#endif /* GLX_SGIX_pbuffer */ -#ifdef GLX_SGIX_swap_barrier - CONST_CAST(GLXEW_SGIX_swap_barrier) = glxewGetExtension("GLX_SGIX_swap_barrier"); - if (glewExperimental || GLXEW_SGIX_swap_barrier) CONST_CAST(GLXEW_SGIX_swap_barrier) = !_glewInit_GLX_SGIX_swap_barrier(GLEW_CONTEXT_ARG_VAR_INIT); -#endif /* GLX_SGIX_swap_barrier */ -#ifdef GLX_SGIX_swap_group - CONST_CAST(GLXEW_SGIX_swap_group) = glxewGetExtension("GLX_SGIX_swap_group"); - if (glewExperimental || GLXEW_SGIX_swap_group) CONST_CAST(GLXEW_SGIX_swap_group) = !_glewInit_GLX_SGIX_swap_group(GLEW_CONTEXT_ARG_VAR_INIT); -#endif /* GLX_SGIX_swap_group */ -#ifdef GLX_SGIX_video_resize - CONST_CAST(GLXEW_SGIX_video_resize) = glxewGetExtension("GLX_SGIX_video_resize"); - if (glewExperimental || GLXEW_SGIX_video_resize) CONST_CAST(GLXEW_SGIX_video_resize) = !_glewInit_GLX_SGIX_video_resize(GLEW_CONTEXT_ARG_VAR_INIT); -#endif /* GLX_SGIX_video_resize */ -#ifdef GLX_SGIX_visual_select_group - CONST_CAST(GLXEW_SGIX_visual_select_group) = glxewGetExtension("GLX_SGIX_visual_select_group"); -#endif /* GLX_SGIX_visual_select_group */ -#ifdef GLX_SGI_cushion - CONST_CAST(GLXEW_SGI_cushion) = glxewGetExtension("GLX_SGI_cushion"); - if (glewExperimental || GLXEW_SGI_cushion) CONST_CAST(GLXEW_SGI_cushion) = !_glewInit_GLX_SGI_cushion(GLEW_CONTEXT_ARG_VAR_INIT); -#endif /* GLX_SGI_cushion */ -#ifdef GLX_SGI_make_current_read - CONST_CAST(GLXEW_SGI_make_current_read) = glxewGetExtension("GLX_SGI_make_current_read"); - if (glewExperimental || GLXEW_SGI_make_current_read) CONST_CAST(GLXEW_SGI_make_current_read) = !_glewInit_GLX_SGI_make_current_read(GLEW_CONTEXT_ARG_VAR_INIT); -#endif /* GLX_SGI_make_current_read */ -#ifdef GLX_SGI_swap_control - CONST_CAST(GLXEW_SGI_swap_control) = glxewGetExtension("GLX_SGI_swap_control"); - if (glewExperimental || GLXEW_SGI_swap_control) CONST_CAST(GLXEW_SGI_swap_control) = !_glewInit_GLX_SGI_swap_control(GLEW_CONTEXT_ARG_VAR_INIT); -#endif /* GLX_SGI_swap_control */ -#ifdef GLX_SGI_video_sync - CONST_CAST(GLXEW_SGI_video_sync) = glxewGetExtension("GLX_SGI_video_sync"); - if (glewExperimental || GLXEW_SGI_video_sync) CONST_CAST(GLXEW_SGI_video_sync) = !_glewInit_GLX_SGI_video_sync(GLEW_CONTEXT_ARG_VAR_INIT); -#endif /* GLX_SGI_video_sync */ -#ifdef GLX_SUN_get_transparent_index - CONST_CAST(GLXEW_SUN_get_transparent_index) = glxewGetExtension("GLX_SUN_get_transparent_index"); - if (glewExperimental || GLXEW_SUN_get_transparent_index) CONST_CAST(GLXEW_SUN_get_transparent_index) = !_glewInit_GLX_SUN_get_transparent_index(GLEW_CONTEXT_ARG_VAR_INIT); -#endif /* GLX_SUN_get_transparent_index */ -#ifdef GLX_SUN_video_resize - CONST_CAST(GLXEW_SUN_video_resize) = glxewGetExtension("GLX_SUN_video_resize"); - if (glewExperimental || GLXEW_SUN_video_resize) CONST_CAST(GLXEW_SUN_video_resize) = !_glewInit_GLX_SUN_video_resize(GLEW_CONTEXT_ARG_VAR_INIT); -#endif /* GLX_SUN_video_resize */ - - return GLEW_OK; -} - -#endif /* !__APPLE__ || GLEW_APPLE_GLX */ - -/* ------------------------------------------------------------------------ */ - -const GLubyte* glewGetErrorString (GLenum error) -{ - static const GLubyte* _glewErrorString[] = - { - (const GLubyte*)"No error", - (const GLubyte*)"Missing GL version", - (const GLubyte*)"GL 1.1 and up are not supported", - (const GLubyte*)"GLX 1.2 and up are not supported", - (const GLubyte*)"Unknown error" - }; - const int max_error = sizeof(_glewErrorString)/sizeof(*_glewErrorString) - 1; - return _glewErrorString[(int)error > max_error ? max_error : (int)error]; -} - -const GLubyte* glewGetString (GLenum name) -{ - static const GLubyte* _glewString[] = - { - (const GLubyte*)NULL, - (const GLubyte*)"1.5.1", - (const GLubyte*)"1", - (const GLubyte*)"5", - (const GLubyte*)"1" - }; - const int max_string = sizeof(_glewString)/sizeof(*_glewString) - 1; - return _glewString[(int)name > max_string ? 0 : (int)name]; -} - -/* ------------------------------------------------------------------------ */ - -GLboolean glewExperimental = GL_FALSE; - -#if !defined(GLEW_MX) - -#if defined(_WIN32) -extern GLenum wglewContextInit (void); -#elif !defined(__APPLE__) || defined(GLEW_APPLE_GLX) /* _UNIX */ -extern GLenum glxewContextInit (void); -#endif /* _WIN32 */ - -GLenum glewInit () -{ - GLenum r; - if ( (r = glewContextInit())!=NULL ) return r; -#if defined(_WIN32) - return wglewContextInit(); -#elif !defined(__APPLE__) || defined(GLEW_APPLE_GLX) /* _UNIX */ - return glxewContextInit(); -#else - return r; -#endif /* _WIN32 */ -} - -#endif /* !GLEW_MX */ -#ifdef GLEW_MX -GLboolean glewContextIsSupported (GLEWContext* ctx, const char* name) -#else -GLboolean glewIsSupported (const char* name) -#endif -{ - GLubyte* pos = (GLubyte*)name; - GLuint len = _glewStrLen(pos); - GLboolean ret = GL_TRUE; - while (ret && len > 0) - { - if (_glewStrSame1(&pos, &len, (const GLubyte*)"GL_", 3)) - { - if (_glewStrSame2(&pos, &len, (const GLubyte*)"VERSION_", 8)) - { -#ifdef GL_VERSION_1_2 - if (_glewStrSame3(&pos, &len, (const GLubyte*)"1_2", 3)) - { - ret = GLEW_VERSION_1_2; - continue; - } -#endif -#ifdef GL_VERSION_1_3 - if (_glewStrSame3(&pos, &len, (const GLubyte*)"1_3", 3)) - { - ret = GLEW_VERSION_1_3; - continue; - } -#endif -#ifdef GL_VERSION_1_4 - if (_glewStrSame3(&pos, &len, (const GLubyte*)"1_4", 3)) - { - ret = GLEW_VERSION_1_4; - continue; - } -#endif -#ifdef GL_VERSION_1_5 - if (_glewStrSame3(&pos, &len, (const GLubyte*)"1_5", 3)) - { - ret = GLEW_VERSION_1_5; - continue; - } -#endif -#ifdef GL_VERSION_2_0 - if (_glewStrSame3(&pos, &len, (const GLubyte*)"2_0", 3)) - { - ret = GLEW_VERSION_2_0; - continue; - } -#endif -#ifdef GL_VERSION_2_1 - if (_glewStrSame3(&pos, &len, (const GLubyte*)"2_1", 3)) - { - ret = GLEW_VERSION_2_1; - continue; - } -#endif -#ifdef GL_VERSION_3_0 - if (_glewStrSame3(&pos, &len, (const GLubyte*)"3_0", 3)) - { - ret = GLEW_VERSION_3_0; - continue; - } -#endif - } - if (_glewStrSame2(&pos, &len, (const GLubyte*)"3DFX_", 5)) - { -#ifdef GL_3DFX_multisample - if (_glewStrSame3(&pos, &len, (const GLubyte*)"multisample", 11)) - { - ret = GLEW_3DFX_multisample; - continue; - } -#endif -#ifdef GL_3DFX_tbuffer - if (_glewStrSame3(&pos, &len, (const GLubyte*)"tbuffer", 7)) - { - ret = GLEW_3DFX_tbuffer; - continue; - } -#endif -#ifdef GL_3DFX_texture_compression_FXT1 - if (_glewStrSame3(&pos, &len, (const GLubyte*)"texture_compression_FXT1", 24)) - { - ret = GLEW_3DFX_texture_compression_FXT1; - continue; - } -#endif - } - if (_glewStrSame2(&pos, &len, (const GLubyte*)"APPLE_", 6)) - { -#ifdef GL_APPLE_client_storage - if (_glewStrSame3(&pos, &len, (const GLubyte*)"client_storage", 14)) - { - ret = GLEW_APPLE_client_storage; - continue; - } -#endif -#ifdef GL_APPLE_element_array - if (_glewStrSame3(&pos, &len, (const GLubyte*)"element_array", 13)) - { - ret = GLEW_APPLE_element_array; - continue; - } -#endif -#ifdef GL_APPLE_fence - if (_glewStrSame3(&pos, &len, (const GLubyte*)"fence", 5)) - { - ret = GLEW_APPLE_fence; - continue; - } -#endif -#ifdef GL_APPLE_float_pixels - if (_glewStrSame3(&pos, &len, (const GLubyte*)"float_pixels", 12)) - { - ret = GLEW_APPLE_float_pixels; - continue; - } -#endif -#ifdef GL_APPLE_flush_buffer_range - if (_glewStrSame3(&pos, &len, (const GLubyte*)"flush_buffer_range", 18)) - { - ret = GLEW_APPLE_flush_buffer_range; - continue; - } -#endif -#ifdef GL_APPLE_pixel_buffer - if (_glewStrSame3(&pos, &len, (const GLubyte*)"pixel_buffer", 12)) - { - ret = GLEW_APPLE_pixel_buffer; - continue; - } -#endif -#ifdef GL_APPLE_specular_vector - if (_glewStrSame3(&pos, &len, (const GLubyte*)"specular_vector", 15)) - { - ret = GLEW_APPLE_specular_vector; - continue; - } -#endif -#ifdef GL_APPLE_texture_range - if (_glewStrSame3(&pos, &len, (const GLubyte*)"texture_range", 13)) - { - ret = GLEW_APPLE_texture_range; - continue; - } -#endif -#ifdef GL_APPLE_transform_hint - if (_glewStrSame3(&pos, &len, (const GLubyte*)"transform_hint", 14)) - { - ret = GLEW_APPLE_transform_hint; - continue; - } -#endif -#ifdef GL_APPLE_vertex_array_object - if (_glewStrSame3(&pos, &len, (const GLubyte*)"vertex_array_object", 19)) - { - ret = GLEW_APPLE_vertex_array_object; - continue; - } -#endif -#ifdef GL_APPLE_vertex_array_range - if (_glewStrSame3(&pos, &len, (const GLubyte*)"vertex_array_range", 18)) - { - ret = GLEW_APPLE_vertex_array_range; - continue; - } -#endif -#ifdef GL_APPLE_ycbcr_422 - if (_glewStrSame3(&pos, &len, (const GLubyte*)"ycbcr_422", 9)) - { - ret = GLEW_APPLE_ycbcr_422; - continue; - } -#endif - } - if (_glewStrSame2(&pos, &len, (const GLubyte*)"ARB_", 4)) - { -#ifdef GL_ARB_color_buffer_float - if (_glewStrSame3(&pos, &len, (const GLubyte*)"color_buffer_float", 18)) - { - ret = GLEW_ARB_color_buffer_float; - continue; - } -#endif -#ifdef GL_ARB_depth_buffer_float - if (_glewStrSame3(&pos, &len, (const GLubyte*)"depth_buffer_float", 18)) - { - ret = GLEW_ARB_depth_buffer_float; - continue; - } -#endif -#ifdef GL_ARB_depth_texture - if (_glewStrSame3(&pos, &len, (const GLubyte*)"depth_texture", 13)) - { - ret = GLEW_ARB_depth_texture; - continue; - } -#endif -#ifdef GL_ARB_draw_buffers - if (_glewStrSame3(&pos, &len, (const GLubyte*)"draw_buffers", 12)) - { - ret = GLEW_ARB_draw_buffers; - continue; - } -#endif -#ifdef GL_ARB_draw_instanced - if (_glewStrSame3(&pos, &len, (const GLubyte*)"draw_instanced", 14)) - { - ret = GLEW_ARB_draw_instanced; - continue; - } -#endif -#ifdef GL_ARB_fragment_program - if (_glewStrSame3(&pos, &len, (const GLubyte*)"fragment_program", 16)) - { - ret = GLEW_ARB_fragment_program; - continue; - } -#endif -#ifdef GL_ARB_fragment_program_shadow - if (_glewStrSame3(&pos, &len, (const GLubyte*)"fragment_program_shadow", 23)) - { - ret = GLEW_ARB_fragment_program_shadow; - continue; - } -#endif -#ifdef GL_ARB_fragment_shader - if (_glewStrSame3(&pos, &len, (const GLubyte*)"fragment_shader", 15)) - { - ret = GLEW_ARB_fragment_shader; - continue; - } -#endif -#ifdef GL_ARB_framebuffer_object - if (_glewStrSame3(&pos, &len, (const GLubyte*)"framebuffer_object", 18)) - { - ret = GLEW_ARB_framebuffer_object; - continue; - } -#endif -#ifdef GL_ARB_framebuffer_sRGB - if (_glewStrSame3(&pos, &len, (const GLubyte*)"framebuffer_sRGB", 16)) - { - ret = GLEW_ARB_framebuffer_sRGB; - continue; - } -#endif -#ifdef GL_ARB_geometry_shader4 - if (_glewStrSame3(&pos, &len, (const GLubyte*)"geometry_shader4", 16)) - { - ret = GLEW_ARB_geometry_shader4; - continue; - } -#endif -#ifdef GL_ARB_half_float_pixel - if (_glewStrSame3(&pos, &len, (const GLubyte*)"half_float_pixel", 16)) - { - ret = GLEW_ARB_half_float_pixel; - continue; - } -#endif -#ifdef GL_ARB_half_float_vertex - if (_glewStrSame3(&pos, &len, (const GLubyte*)"half_float_vertex", 17)) - { - ret = GLEW_ARB_half_float_vertex; - continue; - } -#endif -#ifdef GL_ARB_imaging - if (_glewStrSame3(&pos, &len, (const GLubyte*)"imaging", 7)) - { - ret = GLEW_ARB_imaging; - continue; - } -#endif -#ifdef GL_ARB_instanced_arrays - if (_glewStrSame3(&pos, &len, (const GLubyte*)"instanced_arrays", 16)) - { - ret = GLEW_ARB_instanced_arrays; - continue; - } -#endif -#ifdef GL_ARB_map_buffer_range - if (_glewStrSame3(&pos, &len, (const GLubyte*)"map_buffer_range", 16)) - { - ret = GLEW_ARB_map_buffer_range; - continue; - } -#endif -#ifdef GL_ARB_matrix_palette - if (_glewStrSame3(&pos, &len, (const GLubyte*)"matrix_palette", 14)) - { - ret = GLEW_ARB_matrix_palette; - continue; - } -#endif -#ifdef GL_ARB_multisample - if (_glewStrSame3(&pos, &len, (const GLubyte*)"multisample", 11)) - { - ret = GLEW_ARB_multisample; - continue; - } -#endif -#ifdef GL_ARB_multitexture - if (_glewStrSame3(&pos, &len, (const GLubyte*)"multitexture", 12)) - { - ret = GLEW_ARB_multitexture; - continue; - } -#endif -#ifdef GL_ARB_occlusion_query - if (_glewStrSame3(&pos, &len, (const GLubyte*)"occlusion_query", 15)) - { - ret = GLEW_ARB_occlusion_query; - continue; - } -#endif -#ifdef GL_ARB_pixel_buffer_object - if (_glewStrSame3(&pos, &len, (const GLubyte*)"pixel_buffer_object", 19)) - { - ret = GLEW_ARB_pixel_buffer_object; - continue; - } -#endif -#ifdef GL_ARB_point_parameters - if (_glewStrSame3(&pos, &len, (const GLubyte*)"point_parameters", 16)) - { - ret = GLEW_ARB_point_parameters; - continue; - } -#endif -#ifdef GL_ARB_point_sprite - if (_glewStrSame3(&pos, &len, (const GLubyte*)"point_sprite", 12)) - { - ret = GLEW_ARB_point_sprite; - continue; - } -#endif -#ifdef GL_ARB_shader_objects - if (_glewStrSame3(&pos, &len, (const GLubyte*)"shader_objects", 14)) - { - ret = GLEW_ARB_shader_objects; - continue; - } -#endif -#ifdef GL_ARB_shading_language_100 - if (_glewStrSame3(&pos, &len, (const GLubyte*)"shading_language_100", 20)) - { - ret = GLEW_ARB_shading_language_100; - continue; - } -#endif -#ifdef GL_ARB_shadow - if (_glewStrSame3(&pos, &len, (const GLubyte*)"shadow", 6)) - { - ret = GLEW_ARB_shadow; - continue; - } -#endif -#ifdef GL_ARB_shadow_ambient - if (_glewStrSame3(&pos, &len, (const GLubyte*)"shadow_ambient", 14)) - { - ret = GLEW_ARB_shadow_ambient; - continue; - } -#endif -#ifdef GL_ARB_texture_border_clamp - if (_glewStrSame3(&pos, &len, (const GLubyte*)"texture_border_clamp", 20)) - { - ret = GLEW_ARB_texture_border_clamp; - continue; - } -#endif -#ifdef GL_ARB_texture_buffer_object - if (_glewStrSame3(&pos, &len, (const GLubyte*)"texture_buffer_object", 21)) - { - ret = GLEW_ARB_texture_buffer_object; - continue; - } -#endif -#ifdef GL_ARB_texture_compression - if (_glewStrSame3(&pos, &len, (const GLubyte*)"texture_compression", 19)) - { - ret = GLEW_ARB_texture_compression; - continue; - } -#endif -#ifdef GL_ARB_texture_compression_rgtc - if (_glewStrSame3(&pos, &len, (const GLubyte*)"texture_compression_rgtc", 24)) - { - ret = GLEW_ARB_texture_compression_rgtc; - continue; - } -#endif -#ifdef GL_ARB_texture_cube_map - if (_glewStrSame3(&pos, &len, (const GLubyte*)"texture_cube_map", 16)) - { - ret = GLEW_ARB_texture_cube_map; - continue; - } -#endif -#ifdef GL_ARB_texture_env_add - if (_glewStrSame3(&pos, &len, (const GLubyte*)"texture_env_add", 15)) - { - ret = GLEW_ARB_texture_env_add; - continue; - } -#endif -#ifdef GL_ARB_texture_env_combine - if (_glewStrSame3(&pos, &len, (const GLubyte*)"texture_env_combine", 19)) - { - ret = GLEW_ARB_texture_env_combine; - continue; - } -#endif -#ifdef GL_ARB_texture_env_crossbar - if (_glewStrSame3(&pos, &len, (const GLubyte*)"texture_env_crossbar", 20)) - { - ret = GLEW_ARB_texture_env_crossbar; - continue; - } -#endif -#ifdef GL_ARB_texture_env_dot3 - if (_glewStrSame3(&pos, &len, (const GLubyte*)"texture_env_dot3", 16)) - { - ret = GLEW_ARB_texture_env_dot3; - continue; - } -#endif -#ifdef GL_ARB_texture_float - if (_glewStrSame3(&pos, &len, (const GLubyte*)"texture_float", 13)) - { - ret = GLEW_ARB_texture_float; - continue; - } -#endif -#ifdef GL_ARB_texture_mirrored_repeat - if (_glewStrSame3(&pos, &len, (const GLubyte*)"texture_mirrored_repeat", 23)) - { - ret = GLEW_ARB_texture_mirrored_repeat; - continue; - } -#endif -#ifdef GL_ARB_texture_non_power_of_two - if (_glewStrSame3(&pos, &len, (const GLubyte*)"texture_non_power_of_two", 24)) - { - ret = GLEW_ARB_texture_non_power_of_two; - continue; - } -#endif -#ifdef GL_ARB_texture_rectangle - if (_glewStrSame3(&pos, &len, (const GLubyte*)"texture_rectangle", 17)) - { - ret = GLEW_ARB_texture_rectangle; - continue; - } -#endif -#ifdef GL_ARB_texture_rg - if (_glewStrSame3(&pos, &len, (const GLubyte*)"texture_rg", 10)) - { - ret = GLEW_ARB_texture_rg; - continue; - } -#endif -#ifdef GL_ARB_transpose_matrix - if (_glewStrSame3(&pos, &len, (const GLubyte*)"transpose_matrix", 16)) - { - ret = GLEW_ARB_transpose_matrix; - continue; - } -#endif -#ifdef GL_ARB_vertex_array_object - if (_glewStrSame3(&pos, &len, (const GLubyte*)"vertex_array_object", 19)) - { - ret = GLEW_ARB_vertex_array_object; - continue; - } -#endif -#ifdef GL_ARB_vertex_blend - if (_glewStrSame3(&pos, &len, (const GLubyte*)"vertex_blend", 12)) - { - ret = GLEW_ARB_vertex_blend; - continue; - } -#endif -#ifdef GL_ARB_vertex_buffer_object - if (_glewStrSame3(&pos, &len, (const GLubyte*)"vertex_buffer_object", 20)) - { - ret = GLEW_ARB_vertex_buffer_object; - continue; - } -#endif -#ifdef GL_ARB_vertex_program - if (_glewStrSame3(&pos, &len, (const GLubyte*)"vertex_program", 14)) - { - ret = GLEW_ARB_vertex_program; - continue; - } -#endif -#ifdef GL_ARB_vertex_shader - if (_glewStrSame3(&pos, &len, (const GLubyte*)"vertex_shader", 13)) - { - ret = GLEW_ARB_vertex_shader; - continue; - } -#endif -#ifdef GL_ARB_window_pos - if (_glewStrSame3(&pos, &len, (const GLubyte*)"window_pos", 10)) - { - ret = GLEW_ARB_window_pos; - continue; - } -#endif - } - if (_glewStrSame2(&pos, &len, (const GLubyte*)"ATIX_", 5)) - { -#ifdef GL_ATIX_point_sprites - if (_glewStrSame3(&pos, &len, (const GLubyte*)"point_sprites", 13)) - { - ret = GLEW_ATIX_point_sprites; - continue; - } -#endif -#ifdef GL_ATIX_texture_env_combine3 - if (_glewStrSame3(&pos, &len, (const GLubyte*)"texture_env_combine3", 20)) - { - ret = GLEW_ATIX_texture_env_combine3; - continue; - } -#endif -#ifdef GL_ATIX_texture_env_route - if (_glewStrSame3(&pos, &len, (const GLubyte*)"texture_env_route", 17)) - { - ret = GLEW_ATIX_texture_env_route; - continue; - } -#endif -#ifdef GL_ATIX_vertex_shader_output_point_size - if (_glewStrSame3(&pos, &len, (const GLubyte*)"vertex_shader_output_point_size", 31)) - { - ret = GLEW_ATIX_vertex_shader_output_point_size; - continue; - } -#endif - } - if (_glewStrSame2(&pos, &len, (const GLubyte*)"ATI_", 4)) - { -#ifdef GL_ATI_draw_buffers - if (_glewStrSame3(&pos, &len, (const GLubyte*)"draw_buffers", 12)) - { - ret = GLEW_ATI_draw_buffers; - continue; - } -#endif -#ifdef GL_ATI_element_array - if (_glewStrSame3(&pos, &len, (const GLubyte*)"element_array", 13)) - { - ret = GLEW_ATI_element_array; - continue; - } -#endif -#ifdef GL_ATI_envmap_bumpmap - if (_glewStrSame3(&pos, &len, (const GLubyte*)"envmap_bumpmap", 14)) - { - ret = GLEW_ATI_envmap_bumpmap; - continue; - } -#endif -#ifdef GL_ATI_fragment_shader - if (_glewStrSame3(&pos, &len, (const GLubyte*)"fragment_shader", 15)) - { - ret = GLEW_ATI_fragment_shader; - continue; - } -#endif -#ifdef GL_ATI_map_object_buffer - if (_glewStrSame3(&pos, &len, (const GLubyte*)"map_object_buffer", 17)) - { - ret = GLEW_ATI_map_object_buffer; - continue; - } -#endif -#ifdef GL_ATI_pn_triangles - if (_glewStrSame3(&pos, &len, (const GLubyte*)"pn_triangles", 12)) - { - ret = GLEW_ATI_pn_triangles; - continue; - } -#endif -#ifdef GL_ATI_separate_stencil - if (_glewStrSame3(&pos, &len, (const GLubyte*)"separate_stencil", 16)) - { - ret = GLEW_ATI_separate_stencil; - continue; - } -#endif -#ifdef GL_ATI_shader_texture_lod - if (_glewStrSame3(&pos, &len, (const GLubyte*)"shader_texture_lod", 18)) - { - ret = GLEW_ATI_shader_texture_lod; - continue; - } -#endif -#ifdef GL_ATI_text_fragment_shader - if (_glewStrSame3(&pos, &len, (const GLubyte*)"text_fragment_shader", 20)) - { - ret = GLEW_ATI_text_fragment_shader; - continue; - } -#endif -#ifdef GL_ATI_texture_compression_3dc - if (_glewStrSame3(&pos, &len, (const GLubyte*)"texture_compression_3dc", 23)) - { - ret = GLEW_ATI_texture_compression_3dc; - continue; - } -#endif -#ifdef GL_ATI_texture_env_combine3 - if (_glewStrSame3(&pos, &len, (const GLubyte*)"texture_env_combine3", 20)) - { - ret = GLEW_ATI_texture_env_combine3; - continue; - } -#endif -#ifdef GL_ATI_texture_float - if (_glewStrSame3(&pos, &len, (const GLubyte*)"texture_float", 13)) - { - ret = GLEW_ATI_texture_float; - continue; - } -#endif -#ifdef GL_ATI_texture_mirror_once - if (_glewStrSame3(&pos, &len, (const GLubyte*)"texture_mirror_once", 19)) - { - ret = GLEW_ATI_texture_mirror_once; - continue; - } -#endif -#ifdef GL_ATI_vertex_array_object - if (_glewStrSame3(&pos, &len, (const GLubyte*)"vertex_array_object", 19)) - { - ret = GLEW_ATI_vertex_array_object; - continue; - } -#endif -#ifdef GL_ATI_vertex_attrib_array_object - if (_glewStrSame3(&pos, &len, (const GLubyte*)"vertex_attrib_array_object", 26)) - { - ret = GLEW_ATI_vertex_attrib_array_object; - continue; - } -#endif -#ifdef GL_ATI_vertex_streams - if (_glewStrSame3(&pos, &len, (const GLubyte*)"vertex_streams", 14)) - { - ret = GLEW_ATI_vertex_streams; - continue; - } -#endif - } - if (_glewStrSame2(&pos, &len, (const GLubyte*)"EXT_", 4)) - { -#ifdef GL_EXT_422_pixels - if (_glewStrSame3(&pos, &len, (const GLubyte*)"422_pixels", 10)) - { - ret = GLEW_EXT_422_pixels; - continue; - } -#endif -#ifdef GL_EXT_Cg_shader - if (_glewStrSame3(&pos, &len, (const GLubyte*)"Cg_shader", 9)) - { - ret = GLEW_EXT_Cg_shader; - continue; - } -#endif -#ifdef GL_EXT_abgr - if (_glewStrSame3(&pos, &len, (const GLubyte*)"abgr", 4)) - { - ret = GLEW_EXT_abgr; - continue; - } -#endif -#ifdef GL_EXT_bgra - if (_glewStrSame3(&pos, &len, (const GLubyte*)"bgra", 4)) - { - ret = GLEW_EXT_bgra; - continue; - } -#endif -#ifdef GL_EXT_bindable_uniform - if (_glewStrSame3(&pos, &len, (const GLubyte*)"bindable_uniform", 16)) - { - ret = GLEW_EXT_bindable_uniform; - continue; - } -#endif -#ifdef GL_EXT_blend_color - if (_glewStrSame3(&pos, &len, (const GLubyte*)"blend_color", 11)) - { - ret = GLEW_EXT_blend_color; - continue; - } -#endif -#ifdef GL_EXT_blend_equation_separate - if (_glewStrSame3(&pos, &len, (const GLubyte*)"blend_equation_separate", 23)) - { - ret = GLEW_EXT_blend_equation_separate; - continue; - } -#endif -#ifdef GL_EXT_blend_func_separate - if (_glewStrSame3(&pos, &len, (const GLubyte*)"blend_func_separate", 19)) - { - ret = GLEW_EXT_blend_func_separate; - continue; - } -#endif -#ifdef GL_EXT_blend_logic_op - if (_glewStrSame3(&pos, &len, (const GLubyte*)"blend_logic_op", 14)) - { - ret = GLEW_EXT_blend_logic_op; - continue; - } -#endif -#ifdef GL_EXT_blend_minmax - if (_glewStrSame3(&pos, &len, (const GLubyte*)"blend_minmax", 12)) - { - ret = GLEW_EXT_blend_minmax; - continue; - } -#endif -#ifdef GL_EXT_blend_subtract - if (_glewStrSame3(&pos, &len, (const GLubyte*)"blend_subtract", 14)) - { - ret = GLEW_EXT_blend_subtract; - continue; - } -#endif -#ifdef GL_EXT_clip_volume_hint - if (_glewStrSame3(&pos, &len, (const GLubyte*)"clip_volume_hint", 16)) - { - ret = GLEW_EXT_clip_volume_hint; - continue; - } -#endif -#ifdef GL_EXT_cmyka - if (_glewStrSame3(&pos, &len, (const GLubyte*)"cmyka", 5)) - { - ret = GLEW_EXT_cmyka; - continue; - } -#endif -#ifdef GL_EXT_color_subtable - if (_glewStrSame3(&pos, &len, (const GLubyte*)"color_subtable", 14)) - { - ret = GLEW_EXT_color_subtable; - continue; - } -#endif -#ifdef GL_EXT_compiled_vertex_array - if (_glewStrSame3(&pos, &len, (const GLubyte*)"compiled_vertex_array", 21)) - { - ret = GLEW_EXT_compiled_vertex_array; - continue; - } -#endif -#ifdef GL_EXT_convolution - if (_glewStrSame3(&pos, &len, (const GLubyte*)"convolution", 11)) - { - ret = GLEW_EXT_convolution; - continue; - } -#endif -#ifdef GL_EXT_coordinate_frame - if (_glewStrSame3(&pos, &len, (const GLubyte*)"coordinate_frame", 16)) - { - ret = GLEW_EXT_coordinate_frame; - continue; - } -#endif -#ifdef GL_EXT_copy_texture - if (_glewStrSame3(&pos, &len, (const GLubyte*)"copy_texture", 12)) - { - ret = GLEW_EXT_copy_texture; - continue; - } -#endif -#ifdef GL_EXT_cull_vertex - if (_glewStrSame3(&pos, &len, (const GLubyte*)"cull_vertex", 11)) - { - ret = GLEW_EXT_cull_vertex; - continue; - } -#endif -#ifdef GL_EXT_depth_bounds_test - if (_glewStrSame3(&pos, &len, (const GLubyte*)"depth_bounds_test", 17)) - { - ret = GLEW_EXT_depth_bounds_test; - continue; - } -#endif -#ifdef GL_EXT_direct_state_access - if (_glewStrSame3(&pos, &len, (const GLubyte*)"direct_state_access", 19)) - { - ret = GLEW_EXT_direct_state_access; - continue; - } -#endif -#ifdef GL_EXT_draw_buffers2 - if (_glewStrSame3(&pos, &len, (const GLubyte*)"draw_buffers2", 13)) - { - ret = GLEW_EXT_draw_buffers2; - continue; - } -#endif -#ifdef GL_EXT_draw_instanced - if (_glewStrSame3(&pos, &len, (const GLubyte*)"draw_instanced", 14)) - { - ret = GLEW_EXT_draw_instanced; - continue; - } -#endif -#ifdef GL_EXT_draw_range_elements - if (_glewStrSame3(&pos, &len, (const GLubyte*)"draw_range_elements", 19)) - { - ret = GLEW_EXT_draw_range_elements; - continue; - } -#endif -#ifdef GL_EXT_fog_coord - if (_glewStrSame3(&pos, &len, (const GLubyte*)"fog_coord", 9)) - { - ret = GLEW_EXT_fog_coord; - continue; - } -#endif -#ifdef GL_EXT_fragment_lighting - if (_glewStrSame3(&pos, &len, (const GLubyte*)"fragment_lighting", 17)) - { - ret = GLEW_EXT_fragment_lighting; - continue; - } -#endif -#ifdef GL_EXT_framebuffer_blit - if (_glewStrSame3(&pos, &len, (const GLubyte*)"framebuffer_blit", 16)) - { - ret = GLEW_EXT_framebuffer_blit; - continue; - } -#endif -#ifdef GL_EXT_framebuffer_multisample - if (_glewStrSame3(&pos, &len, (const GLubyte*)"framebuffer_multisample", 23)) - { - ret = GLEW_EXT_framebuffer_multisample; - continue; - } -#endif -#ifdef GL_EXT_framebuffer_object - if (_glewStrSame3(&pos, &len, (const GLubyte*)"framebuffer_object", 18)) - { - ret = GLEW_EXT_framebuffer_object; - continue; - } -#endif -#ifdef GL_EXT_framebuffer_sRGB - if (_glewStrSame3(&pos, &len, (const GLubyte*)"framebuffer_sRGB", 16)) - { - ret = GLEW_EXT_framebuffer_sRGB; - continue; - } -#endif -#ifdef GL_EXT_geometry_shader4 - if (_glewStrSame3(&pos, &len, (const GLubyte*)"geometry_shader4", 16)) - { - ret = GLEW_EXT_geometry_shader4; - continue; - } -#endif -#ifdef GL_EXT_gpu_program_parameters - if (_glewStrSame3(&pos, &len, (const GLubyte*)"gpu_program_parameters", 22)) - { - ret = GLEW_EXT_gpu_program_parameters; - continue; - } -#endif -#ifdef GL_EXT_gpu_shader4 - if (_glewStrSame3(&pos, &len, (const GLubyte*)"gpu_shader4", 11)) - { - ret = GLEW_EXT_gpu_shader4; - continue; - } -#endif -#ifdef GL_EXT_histogram - if (_glewStrSame3(&pos, &len, (const GLubyte*)"histogram", 9)) - { - ret = GLEW_EXT_histogram; - continue; - } -#endif -#ifdef GL_EXT_index_array_formats - if (_glewStrSame3(&pos, &len, (const GLubyte*)"index_array_formats", 19)) - { - ret = GLEW_EXT_index_array_formats; - continue; - } -#endif -#ifdef GL_EXT_index_func - if (_glewStrSame3(&pos, &len, (const GLubyte*)"index_func", 10)) - { - ret = GLEW_EXT_index_func; - continue; - } -#endif -#ifdef GL_EXT_index_material - if (_glewStrSame3(&pos, &len, (const GLubyte*)"index_material", 14)) - { - ret = GLEW_EXT_index_material; - continue; - } -#endif -#ifdef GL_EXT_index_texture - if (_glewStrSame3(&pos, &len, (const GLubyte*)"index_texture", 13)) - { - ret = GLEW_EXT_index_texture; - continue; - } -#endif -#ifdef GL_EXT_light_texture - if (_glewStrSame3(&pos, &len, (const GLubyte*)"light_texture", 13)) - { - ret = GLEW_EXT_light_texture; - continue; - } -#endif -#ifdef GL_EXT_misc_attribute - if (_glewStrSame3(&pos, &len, (const GLubyte*)"misc_attribute", 14)) - { - ret = GLEW_EXT_misc_attribute; - continue; - } -#endif -#ifdef GL_EXT_multi_draw_arrays - if (_glewStrSame3(&pos, &len, (const GLubyte*)"multi_draw_arrays", 17)) - { - ret = GLEW_EXT_multi_draw_arrays; - continue; - } -#endif -#ifdef GL_EXT_multisample - if (_glewStrSame3(&pos, &len, (const GLubyte*)"multisample", 11)) - { - ret = GLEW_EXT_multisample; - continue; - } -#endif -#ifdef GL_EXT_packed_depth_stencil - if (_glewStrSame3(&pos, &len, (const GLubyte*)"packed_depth_stencil", 20)) - { - ret = GLEW_EXT_packed_depth_stencil; - continue; - } -#endif -#ifdef GL_EXT_packed_float - if (_glewStrSame3(&pos, &len, (const GLubyte*)"packed_float", 12)) - { - ret = GLEW_EXT_packed_float; - continue; - } -#endif -#ifdef GL_EXT_packed_pixels - if (_glewStrSame3(&pos, &len, (const GLubyte*)"packed_pixels", 13)) - { - ret = GLEW_EXT_packed_pixels; - continue; - } -#endif -#ifdef GL_EXT_paletted_texture - if (_glewStrSame3(&pos, &len, (const GLubyte*)"paletted_texture", 16)) - { - ret = GLEW_EXT_paletted_texture; - continue; - } -#endif -#ifdef GL_EXT_pixel_buffer_object - if (_glewStrSame3(&pos, &len, (const GLubyte*)"pixel_buffer_object", 19)) - { - ret = GLEW_EXT_pixel_buffer_object; - continue; - } -#endif -#ifdef GL_EXT_pixel_transform - if (_glewStrSame3(&pos, &len, (const GLubyte*)"pixel_transform", 15)) - { - ret = GLEW_EXT_pixel_transform; - continue; - } -#endif -#ifdef GL_EXT_pixel_transform_color_table - if (_glewStrSame3(&pos, &len, (const GLubyte*)"pixel_transform_color_table", 27)) - { - ret = GLEW_EXT_pixel_transform_color_table; - continue; - } -#endif -#ifdef GL_EXT_point_parameters - if (_glewStrSame3(&pos, &len, (const GLubyte*)"point_parameters", 16)) - { - ret = GLEW_EXT_point_parameters; - continue; - } -#endif -#ifdef GL_EXT_polygon_offset - if (_glewStrSame3(&pos, &len, (const GLubyte*)"polygon_offset", 14)) - { - ret = GLEW_EXT_polygon_offset; - continue; - } -#endif -#ifdef GL_EXT_rescale_normal - if (_glewStrSame3(&pos, &len, (const GLubyte*)"rescale_normal", 14)) - { - ret = GLEW_EXT_rescale_normal; - continue; - } -#endif -#ifdef GL_EXT_scene_marker - if (_glewStrSame3(&pos, &len, (const GLubyte*)"scene_marker", 12)) - { - ret = GLEW_EXT_scene_marker; - continue; - } -#endif -#ifdef GL_EXT_secondary_color - if (_glewStrSame3(&pos, &len, (const GLubyte*)"secondary_color", 15)) - { - ret = GLEW_EXT_secondary_color; - continue; - } -#endif -#ifdef GL_EXT_separate_specular_color - if (_glewStrSame3(&pos, &len, (const GLubyte*)"separate_specular_color", 23)) - { - ret = GLEW_EXT_separate_specular_color; - continue; - } -#endif -#ifdef GL_EXT_shadow_funcs - if (_glewStrSame3(&pos, &len, (const GLubyte*)"shadow_funcs", 12)) - { - ret = GLEW_EXT_shadow_funcs; - continue; - } -#endif -#ifdef GL_EXT_shared_texture_palette - if (_glewStrSame3(&pos, &len, (const GLubyte*)"shared_texture_palette", 22)) - { - ret = GLEW_EXT_shared_texture_palette; - continue; - } -#endif -#ifdef GL_EXT_stencil_clear_tag - if (_glewStrSame3(&pos, &len, (const GLubyte*)"stencil_clear_tag", 17)) - { - ret = GLEW_EXT_stencil_clear_tag; - continue; - } -#endif -#ifdef GL_EXT_stencil_two_side - if (_glewStrSame3(&pos, &len, (const GLubyte*)"stencil_two_side", 16)) - { - ret = GLEW_EXT_stencil_two_side; - continue; - } -#endif -#ifdef GL_EXT_stencil_wrap - if (_glewStrSame3(&pos, &len, (const GLubyte*)"stencil_wrap", 12)) - { - ret = GLEW_EXT_stencil_wrap; - continue; - } -#endif -#ifdef GL_EXT_subtexture - if (_glewStrSame3(&pos, &len, (const GLubyte*)"subtexture", 10)) - { - ret = GLEW_EXT_subtexture; - continue; - } -#endif -#ifdef GL_EXT_texture - if (_glewStrSame3(&pos, &len, (const GLubyte*)"texture", 7)) - { - ret = GLEW_EXT_texture; - continue; - } -#endif -#ifdef GL_EXT_texture3D - if (_glewStrSame3(&pos, &len, (const GLubyte*)"texture3D", 9)) - { - ret = GLEW_EXT_texture3D; - continue; - } -#endif -#ifdef GL_EXT_texture_array - if (_glewStrSame3(&pos, &len, (const GLubyte*)"texture_array", 13)) - { - ret = GLEW_EXT_texture_array; - continue; - } -#endif -#ifdef GL_EXT_texture_buffer_object - if (_glewStrSame3(&pos, &len, (const GLubyte*)"texture_buffer_object", 21)) - { - ret = GLEW_EXT_texture_buffer_object; - continue; - } -#endif -#ifdef GL_EXT_texture_compression_dxt1 - if (_glewStrSame3(&pos, &len, (const GLubyte*)"texture_compression_dxt1", 24)) - { - ret = GLEW_EXT_texture_compression_dxt1; - continue; - } -#endif -#ifdef GL_EXT_texture_compression_latc - if (_glewStrSame3(&pos, &len, (const GLubyte*)"texture_compression_latc", 24)) - { - ret = GLEW_EXT_texture_compression_latc; - continue; - } -#endif -#ifdef GL_EXT_texture_compression_rgtc - if (_glewStrSame3(&pos, &len, (const GLubyte*)"texture_compression_rgtc", 24)) - { - ret = GLEW_EXT_texture_compression_rgtc; - continue; - } -#endif -#ifdef GL_EXT_texture_compression_s3tc - if (_glewStrSame3(&pos, &len, (const GLubyte*)"texture_compression_s3tc", 24)) - { - ret = GLEW_EXT_texture_compression_s3tc; - continue; - } -#endif -#ifdef GL_EXT_texture_cube_map - if (_glewStrSame3(&pos, &len, (const GLubyte*)"texture_cube_map", 16)) - { - ret = GLEW_EXT_texture_cube_map; - continue; - } -#endif -#ifdef GL_EXT_texture_edge_clamp - if (_glewStrSame3(&pos, &len, (const GLubyte*)"texture_edge_clamp", 18)) - { - ret = GLEW_EXT_texture_edge_clamp; - continue; - } -#endif -#ifdef GL_EXT_texture_env - if (_glewStrSame3(&pos, &len, (const GLubyte*)"texture_env", 11)) - { - ret = GLEW_EXT_texture_env; - continue; - } -#endif -#ifdef GL_EXT_texture_env_add - if (_glewStrSame3(&pos, &len, (const GLubyte*)"texture_env_add", 15)) - { - ret = GLEW_EXT_texture_env_add; - continue; - } -#endif -#ifdef GL_EXT_texture_env_combine - if (_glewStrSame3(&pos, &len, (const GLubyte*)"texture_env_combine", 19)) - { - ret = GLEW_EXT_texture_env_combine; - continue; - } -#endif -#ifdef GL_EXT_texture_env_dot3 - if (_glewStrSame3(&pos, &len, (const GLubyte*)"texture_env_dot3", 16)) - { - ret = GLEW_EXT_texture_env_dot3; - continue; - } -#endif -#ifdef GL_EXT_texture_filter_anisotropic - if (_glewStrSame3(&pos, &len, (const GLubyte*)"texture_filter_anisotropic", 26)) - { - ret = GLEW_EXT_texture_filter_anisotropic; - continue; - } -#endif -#ifdef GL_EXT_texture_integer - if (_glewStrSame3(&pos, &len, (const GLubyte*)"texture_integer", 15)) - { - ret = GLEW_EXT_texture_integer; - continue; - } -#endif -#ifdef GL_EXT_texture_lod_bias - if (_glewStrSame3(&pos, &len, (const GLubyte*)"texture_lod_bias", 16)) - { - ret = GLEW_EXT_texture_lod_bias; - continue; - } -#endif -#ifdef GL_EXT_texture_mirror_clamp - if (_glewStrSame3(&pos, &len, (const GLubyte*)"texture_mirror_clamp", 20)) - { - ret = GLEW_EXT_texture_mirror_clamp; - continue; - } -#endif -#ifdef GL_EXT_texture_object - if (_glewStrSame3(&pos, &len, (const GLubyte*)"texture_object", 14)) - { - ret = GLEW_EXT_texture_object; - continue; - } -#endif -#ifdef GL_EXT_texture_perturb_normal - if (_glewStrSame3(&pos, &len, (const GLubyte*)"texture_perturb_normal", 22)) - { - ret = GLEW_EXT_texture_perturb_normal; - continue; - } -#endif -#ifdef GL_EXT_texture_rectangle - if (_glewStrSame3(&pos, &len, (const GLubyte*)"texture_rectangle", 17)) - { - ret = GLEW_EXT_texture_rectangle; - continue; - } -#endif -#ifdef GL_EXT_texture_sRGB - if (_glewStrSame3(&pos, &len, (const GLubyte*)"texture_sRGB", 12)) - { - ret = GLEW_EXT_texture_sRGB; - continue; - } -#endif -#ifdef GL_EXT_texture_shared_exponent - if (_glewStrSame3(&pos, &len, (const GLubyte*)"texture_shared_exponent", 23)) - { - ret = GLEW_EXT_texture_shared_exponent; - continue; - } -#endif -#ifdef GL_EXT_texture_swizzle - if (_glewStrSame3(&pos, &len, (const GLubyte*)"texture_swizzle", 15)) - { - ret = GLEW_EXT_texture_swizzle; - continue; - } -#endif -#ifdef GL_EXT_timer_query - if (_glewStrSame3(&pos, &len, (const GLubyte*)"timer_query", 11)) - { - ret = GLEW_EXT_timer_query; - continue; - } -#endif -#ifdef GL_EXT_transform_feedback - if (_glewStrSame3(&pos, &len, (const GLubyte*)"transform_feedback", 18)) - { - ret = GLEW_EXT_transform_feedback; - continue; - } -#endif -#ifdef GL_EXT_vertex_array - if (_glewStrSame3(&pos, &len, (const GLubyte*)"vertex_array", 12)) - { - ret = GLEW_EXT_vertex_array; - continue; - } -#endif -#ifdef GL_EXT_vertex_array_bgra - if (_glewStrSame3(&pos, &len, (const GLubyte*)"vertex_array_bgra", 17)) - { - ret = GLEW_EXT_vertex_array_bgra; - continue; - } -#endif -#ifdef GL_EXT_vertex_shader - if (_glewStrSame3(&pos, &len, (const GLubyte*)"vertex_shader", 13)) - { - ret = GLEW_EXT_vertex_shader; - continue; - } -#endif -#ifdef GL_EXT_vertex_weighting - if (_glewStrSame3(&pos, &len, (const GLubyte*)"vertex_weighting", 16)) - { - ret = GLEW_EXT_vertex_weighting; - continue; - } -#endif - } - if (_glewStrSame2(&pos, &len, (const GLubyte*)"GREMEDY_", 8)) - { -#ifdef GL_GREMEDY_frame_terminator - if (_glewStrSame3(&pos, &len, (const GLubyte*)"frame_terminator", 16)) - { - ret = GLEW_GREMEDY_frame_terminator; - continue; - } -#endif -#ifdef GL_GREMEDY_string_marker - if (_glewStrSame3(&pos, &len, (const GLubyte*)"string_marker", 13)) - { - ret = GLEW_GREMEDY_string_marker; - continue; - } -#endif - } - if (_glewStrSame2(&pos, &len, (const GLubyte*)"HP_", 3)) - { -#ifdef GL_HP_convolution_border_modes - if (_glewStrSame3(&pos, &len, (const GLubyte*)"convolution_border_modes", 24)) - { - ret = GLEW_HP_convolution_border_modes; - continue; - } -#endif -#ifdef GL_HP_image_transform - if (_glewStrSame3(&pos, &len, (const GLubyte*)"image_transform", 15)) - { - ret = GLEW_HP_image_transform; - continue; - } -#endif -#ifdef GL_HP_occlusion_test - if (_glewStrSame3(&pos, &len, (const GLubyte*)"occlusion_test", 14)) - { - ret = GLEW_HP_occlusion_test; - continue; - } -#endif -#ifdef GL_HP_texture_lighting - if (_glewStrSame3(&pos, &len, (const GLubyte*)"texture_lighting", 16)) - { - ret = GLEW_HP_texture_lighting; - continue; - } -#endif - } - if (_glewStrSame2(&pos, &len, (const GLubyte*)"IBM_", 4)) - { -#ifdef GL_IBM_cull_vertex - if (_glewStrSame3(&pos, &len, (const GLubyte*)"cull_vertex", 11)) - { - ret = GLEW_IBM_cull_vertex; - continue; - } -#endif -#ifdef GL_IBM_multimode_draw_arrays - if (_glewStrSame3(&pos, &len, (const GLubyte*)"multimode_draw_arrays", 21)) - { - ret = GLEW_IBM_multimode_draw_arrays; - continue; - } -#endif -#ifdef GL_IBM_rasterpos_clip - if (_glewStrSame3(&pos, &len, (const GLubyte*)"rasterpos_clip", 14)) - { - ret = GLEW_IBM_rasterpos_clip; - continue; - } -#endif -#ifdef GL_IBM_static_data - if (_glewStrSame3(&pos, &len, (const GLubyte*)"static_data", 11)) - { - ret = GLEW_IBM_static_data; - continue; - } -#endif -#ifdef GL_IBM_texture_mirrored_repeat - if (_glewStrSame3(&pos, &len, (const GLubyte*)"texture_mirrored_repeat", 23)) - { - ret = GLEW_IBM_texture_mirrored_repeat; - continue; - } -#endif -#ifdef GL_IBM_vertex_array_lists - if (_glewStrSame3(&pos, &len, (const GLubyte*)"vertex_array_lists", 18)) - { - ret = GLEW_IBM_vertex_array_lists; - continue; - } -#endif - } - if (_glewStrSame2(&pos, &len, (const GLubyte*)"INGR_", 5)) - { -#ifdef GL_INGR_color_clamp - if (_glewStrSame3(&pos, &len, (const GLubyte*)"color_clamp", 11)) - { - ret = GLEW_INGR_color_clamp; - continue; - } -#endif -#ifdef GL_INGR_interlace_read - if (_glewStrSame3(&pos, &len, (const GLubyte*)"interlace_read", 14)) - { - ret = GLEW_INGR_interlace_read; - continue; - } -#endif - } - if (_glewStrSame2(&pos, &len, (const GLubyte*)"INTEL_", 6)) - { -#ifdef GL_INTEL_parallel_arrays - if (_glewStrSame3(&pos, &len, (const GLubyte*)"parallel_arrays", 15)) - { - ret = GLEW_INTEL_parallel_arrays; - continue; - } -#endif -#ifdef GL_INTEL_texture_scissor - if (_glewStrSame3(&pos, &len, (const GLubyte*)"texture_scissor", 15)) - { - ret = GLEW_INTEL_texture_scissor; - continue; - } -#endif - } - if (_glewStrSame2(&pos, &len, (const GLubyte*)"KTX_", 4)) - { -#ifdef GL_KTX_buffer_region - if (_glewStrSame3(&pos, &len, (const GLubyte*)"buffer_region", 13)) - { - ret = GLEW_KTX_buffer_region; - continue; - } -#endif - } - if (_glewStrSame2(&pos, &len, (const GLubyte*)"MESAX_", 6)) - { -#ifdef GL_MESAX_texture_stack - if (_glewStrSame3(&pos, &len, (const GLubyte*)"texture_stack", 13)) - { - ret = GLEW_MESAX_texture_stack; - continue; - } -#endif - } - if (_glewStrSame2(&pos, &len, (const GLubyte*)"MESA_", 5)) - { -#ifdef GL_MESA_pack_invert - if (_glewStrSame3(&pos, &len, (const GLubyte*)"pack_invert", 11)) - { - ret = GLEW_MESA_pack_invert; - continue; - } -#endif -#ifdef GL_MESA_resize_buffers - if (_glewStrSame3(&pos, &len, (const GLubyte*)"resize_buffers", 14)) - { - ret = GLEW_MESA_resize_buffers; - continue; - } -#endif -#ifdef GL_MESA_window_pos - if (_glewStrSame3(&pos, &len, (const GLubyte*)"window_pos", 10)) - { - ret = GLEW_MESA_window_pos; - continue; - } -#endif -#ifdef GL_MESA_ycbcr_texture - if (_glewStrSame3(&pos, &len, (const GLubyte*)"ycbcr_texture", 13)) - { - ret = GLEW_MESA_ycbcr_texture; - continue; - } -#endif - } - if (_glewStrSame2(&pos, &len, (const GLubyte*)"NV_", 3)) - { -#ifdef GL_NV_blend_square - if (_glewStrSame3(&pos, &len, (const GLubyte*)"blend_square", 12)) - { - ret = GLEW_NV_blend_square; - continue; - } -#endif -#ifdef GL_NV_conditional_render - if (_glewStrSame3(&pos, &len, (const GLubyte*)"conditional_render", 18)) - { - ret = GLEW_NV_conditional_render; - continue; - } -#endif -#ifdef GL_NV_copy_depth_to_color - if (_glewStrSame3(&pos, &len, (const GLubyte*)"copy_depth_to_color", 19)) - { - ret = GLEW_NV_copy_depth_to_color; - continue; - } -#endif -#ifdef GL_NV_depth_buffer_float - if (_glewStrSame3(&pos, &len, (const GLubyte*)"depth_buffer_float", 18)) - { - ret = GLEW_NV_depth_buffer_float; - continue; - } -#endif -#ifdef GL_NV_depth_clamp - if (_glewStrSame3(&pos, &len, (const GLubyte*)"depth_clamp", 11)) - { - ret = GLEW_NV_depth_clamp; - continue; - } -#endif -#ifdef GL_NV_depth_range_unclamped - if (_glewStrSame3(&pos, &len, (const GLubyte*)"depth_range_unclamped", 21)) - { - ret = GLEW_NV_depth_range_unclamped; - continue; - } -#endif -#ifdef GL_NV_evaluators - if (_glewStrSame3(&pos, &len, (const GLubyte*)"evaluators", 10)) - { - ret = GLEW_NV_evaluators; - continue; - } -#endif -#ifdef GL_NV_explicit_multisample - if (_glewStrSame3(&pos, &len, (const GLubyte*)"explicit_multisample", 20)) - { - ret = GLEW_NV_explicit_multisample; - continue; - } -#endif -#ifdef GL_NV_fence - if (_glewStrSame3(&pos, &len, (const GLubyte*)"fence", 5)) - { - ret = GLEW_NV_fence; - continue; - } -#endif -#ifdef GL_NV_float_buffer - if (_glewStrSame3(&pos, &len, (const GLubyte*)"float_buffer", 12)) - { - ret = GLEW_NV_float_buffer; - continue; - } -#endif -#ifdef GL_NV_fog_distance - if (_glewStrSame3(&pos, &len, (const GLubyte*)"fog_distance", 12)) - { - ret = GLEW_NV_fog_distance; - continue; - } -#endif -#ifdef GL_NV_fragment_program - if (_glewStrSame3(&pos, &len, (const GLubyte*)"fragment_program", 16)) - { - ret = GLEW_NV_fragment_program; - continue; - } -#endif -#ifdef GL_NV_fragment_program2 - if (_glewStrSame3(&pos, &len, (const GLubyte*)"fragment_program2", 17)) - { - ret = GLEW_NV_fragment_program2; - continue; - } -#endif -#ifdef GL_NV_fragment_program4 - if (_glewStrSame3(&pos, &len, (const GLubyte*)"fragment_program4", 17)) - { - ret = GLEW_NV_fragment_program4; - continue; - } -#endif -#ifdef GL_NV_fragment_program_option - if (_glewStrSame3(&pos, &len, (const GLubyte*)"fragment_program_option", 23)) - { - ret = GLEW_NV_fragment_program_option; - continue; - } -#endif -#ifdef GL_NV_framebuffer_multisample_coverage - if (_glewStrSame3(&pos, &len, (const GLubyte*)"framebuffer_multisample_coverage", 32)) - { - ret = GLEW_NV_framebuffer_multisample_coverage; - continue; - } -#endif -#ifdef GL_NV_geometry_program4 - if (_glewStrSame3(&pos, &len, (const GLubyte*)"geometry_program4", 17)) - { - ret = GLEW_NV_geometry_program4; - continue; - } -#endif -#ifdef GL_NV_geometry_shader4 - if (_glewStrSame3(&pos, &len, (const GLubyte*)"geometry_shader4", 16)) - { - ret = GLEW_NV_geometry_shader4; - continue; - } -#endif -#ifdef GL_NV_gpu_program4 - if (_glewStrSame3(&pos, &len, (const GLubyte*)"gpu_program4", 12)) - { - ret = GLEW_NV_gpu_program4; - continue; - } -#endif -#ifdef GL_NV_half_float - if (_glewStrSame3(&pos, &len, (const GLubyte*)"half_float", 10)) - { - ret = GLEW_NV_half_float; - continue; - } -#endif -#ifdef GL_NV_light_max_exponent - if (_glewStrSame3(&pos, &len, (const GLubyte*)"light_max_exponent", 18)) - { - ret = GLEW_NV_light_max_exponent; - continue; - } -#endif -#ifdef GL_NV_multisample_filter_hint - if (_glewStrSame3(&pos, &len, (const GLubyte*)"multisample_filter_hint", 23)) - { - ret = GLEW_NV_multisample_filter_hint; - continue; - } -#endif -#ifdef GL_NV_occlusion_query - if (_glewStrSame3(&pos, &len, (const GLubyte*)"occlusion_query", 15)) - { - ret = GLEW_NV_occlusion_query; - continue; - } -#endif -#ifdef GL_NV_packed_depth_stencil - if (_glewStrSame3(&pos, &len, (const GLubyte*)"packed_depth_stencil", 20)) - { - ret = GLEW_NV_packed_depth_stencil; - continue; - } -#endif -#ifdef GL_NV_parameter_buffer_object - if (_glewStrSame3(&pos, &len, (const GLubyte*)"parameter_buffer_object", 23)) - { - ret = GLEW_NV_parameter_buffer_object; - continue; - } -#endif -#ifdef GL_NV_pixel_data_range - if (_glewStrSame3(&pos, &len, (const GLubyte*)"pixel_data_range", 16)) - { - ret = GLEW_NV_pixel_data_range; - continue; - } -#endif -#ifdef GL_NV_point_sprite - if (_glewStrSame3(&pos, &len, (const GLubyte*)"point_sprite", 12)) - { - ret = GLEW_NV_point_sprite; - continue; - } -#endif -#ifdef GL_NV_present_video - if (_glewStrSame3(&pos, &len, (const GLubyte*)"present_video", 13)) - { - ret = GLEW_NV_present_video; - continue; - } -#endif -#ifdef GL_NV_primitive_restart - if (_glewStrSame3(&pos, &len, (const GLubyte*)"primitive_restart", 17)) - { - ret = GLEW_NV_primitive_restart; - continue; - } -#endif -#ifdef GL_NV_register_combiners - if (_glewStrSame3(&pos, &len, (const GLubyte*)"register_combiners", 18)) - { - ret = GLEW_NV_register_combiners; - continue; - } -#endif -#ifdef GL_NV_register_combiners2 - if (_glewStrSame3(&pos, &len, (const GLubyte*)"register_combiners2", 19)) - { - ret = GLEW_NV_register_combiners2; - continue; - } -#endif -#ifdef GL_NV_texgen_emboss - if (_glewStrSame3(&pos, &len, (const GLubyte*)"texgen_emboss", 13)) - { - ret = GLEW_NV_texgen_emboss; - continue; - } -#endif -#ifdef GL_NV_texgen_reflection - if (_glewStrSame3(&pos, &len, (const GLubyte*)"texgen_reflection", 17)) - { - ret = GLEW_NV_texgen_reflection; - continue; - } -#endif -#ifdef GL_NV_texture_compression_vtc - if (_glewStrSame3(&pos, &len, (const GLubyte*)"texture_compression_vtc", 23)) - { - ret = GLEW_NV_texture_compression_vtc; - continue; - } -#endif -#ifdef GL_NV_texture_env_combine4 - if (_glewStrSame3(&pos, &len, (const GLubyte*)"texture_env_combine4", 20)) - { - ret = GLEW_NV_texture_env_combine4; - continue; - } -#endif -#ifdef GL_NV_texture_expand_normal - if (_glewStrSame3(&pos, &len, (const GLubyte*)"texture_expand_normal", 21)) - { - ret = GLEW_NV_texture_expand_normal; - continue; - } -#endif -#ifdef GL_NV_texture_rectangle - if (_glewStrSame3(&pos, &len, (const GLubyte*)"texture_rectangle", 17)) - { - ret = GLEW_NV_texture_rectangle; - continue; - } -#endif -#ifdef GL_NV_texture_shader - if (_glewStrSame3(&pos, &len, (const GLubyte*)"texture_shader", 14)) - { - ret = GLEW_NV_texture_shader; - continue; - } -#endif -#ifdef GL_NV_texture_shader2 - if (_glewStrSame3(&pos, &len, (const GLubyte*)"texture_shader2", 15)) - { - ret = GLEW_NV_texture_shader2; - continue; - } -#endif -#ifdef GL_NV_texture_shader3 - if (_glewStrSame3(&pos, &len, (const GLubyte*)"texture_shader3", 15)) - { - ret = GLEW_NV_texture_shader3; - continue; - } -#endif -#ifdef GL_NV_transform_feedback - if (_glewStrSame3(&pos, &len, (const GLubyte*)"transform_feedback", 18)) - { - ret = GLEW_NV_transform_feedback; - continue; - } -#endif -#ifdef GL_NV_vertex_array_range - if (_glewStrSame3(&pos, &len, (const GLubyte*)"vertex_array_range", 18)) - { - ret = GLEW_NV_vertex_array_range; - continue; - } -#endif -#ifdef GL_NV_vertex_array_range2 - if (_glewStrSame3(&pos, &len, (const GLubyte*)"vertex_array_range2", 19)) - { - ret = GLEW_NV_vertex_array_range2; - continue; - } -#endif -#ifdef GL_NV_vertex_program - if (_glewStrSame3(&pos, &len, (const GLubyte*)"vertex_program", 14)) - { - ret = GLEW_NV_vertex_program; - continue; - } -#endif -#ifdef GL_NV_vertex_program1_1 - if (_glewStrSame3(&pos, &len, (const GLubyte*)"vertex_program1_1", 17)) - { - ret = GLEW_NV_vertex_program1_1; - continue; - } -#endif -#ifdef GL_NV_vertex_program2 - if (_glewStrSame3(&pos, &len, (const GLubyte*)"vertex_program2", 15)) - { - ret = GLEW_NV_vertex_program2; - continue; - } -#endif -#ifdef GL_NV_vertex_program2_option - if (_glewStrSame3(&pos, &len, (const GLubyte*)"vertex_program2_option", 22)) - { - ret = GLEW_NV_vertex_program2_option; - continue; - } -#endif -#ifdef GL_NV_vertex_program3 - if (_glewStrSame3(&pos, &len, (const GLubyte*)"vertex_program3", 15)) - { - ret = GLEW_NV_vertex_program3; - continue; - } -#endif -#ifdef GL_NV_vertex_program4 - if (_glewStrSame3(&pos, &len, (const GLubyte*)"vertex_program4", 15)) - { - ret = GLEW_NV_vertex_program4; - continue; - } -#endif - } - if (_glewStrSame2(&pos, &len, (const GLubyte*)"OES_", 4)) - { -#ifdef GL_OES_byte_coordinates - if (_glewStrSame3(&pos, &len, (const GLubyte*)"byte_coordinates", 16)) - { - ret = GLEW_OES_byte_coordinates; - continue; - } -#endif -#ifdef GL_OES_compressed_paletted_texture - if (_glewStrSame3(&pos, &len, (const GLubyte*)"compressed_paletted_texture", 27)) - { - ret = GLEW_OES_compressed_paletted_texture; - continue; - } -#endif -#ifdef GL_OES_read_format - if (_glewStrSame3(&pos, &len, (const GLubyte*)"read_format", 11)) - { - ret = GLEW_OES_read_format; - continue; - } -#endif -#ifdef GL_OES_single_precision - if (_glewStrSame3(&pos, &len, (const GLubyte*)"single_precision", 16)) - { - ret = GLEW_OES_single_precision; - continue; - } -#endif - } - if (_glewStrSame2(&pos, &len, (const GLubyte*)"OML_", 4)) - { -#ifdef GL_OML_interlace - if (_glewStrSame3(&pos, &len, (const GLubyte*)"interlace", 9)) - { - ret = GLEW_OML_interlace; - continue; - } -#endif -#ifdef GL_OML_resample - if (_glewStrSame3(&pos, &len, (const GLubyte*)"resample", 8)) - { - ret = GLEW_OML_resample; - continue; - } -#endif -#ifdef GL_OML_subsample - if (_glewStrSame3(&pos, &len, (const GLubyte*)"subsample", 9)) - { - ret = GLEW_OML_subsample; - continue; - } -#endif - } - if (_glewStrSame2(&pos, &len, (const GLubyte*)"PGI_", 4)) - { -#ifdef GL_PGI_misc_hints - if (_glewStrSame3(&pos, &len, (const GLubyte*)"misc_hints", 10)) - { - ret = GLEW_PGI_misc_hints; - continue; - } -#endif -#ifdef GL_PGI_vertex_hints - if (_glewStrSame3(&pos, &len, (const GLubyte*)"vertex_hints", 12)) - { - ret = GLEW_PGI_vertex_hints; - continue; - } -#endif - } - if (_glewStrSame2(&pos, &len, (const GLubyte*)"REND_", 5)) - { -#ifdef GL_REND_screen_coordinates - if (_glewStrSame3(&pos, &len, (const GLubyte*)"screen_coordinates", 18)) - { - ret = GLEW_REND_screen_coordinates; - continue; - } -#endif - } - if (_glewStrSame2(&pos, &len, (const GLubyte*)"S3_", 3)) - { -#ifdef GL_S3_s3tc - if (_glewStrSame3(&pos, &len, (const GLubyte*)"s3tc", 4)) - { - ret = GLEW_S3_s3tc; - continue; - } -#endif - } - if (_glewStrSame2(&pos, &len, (const GLubyte*)"SGIS_", 5)) - { -#ifdef GL_SGIS_color_range - if (_glewStrSame3(&pos, &len, (const GLubyte*)"color_range", 11)) - { - ret = GLEW_SGIS_color_range; - continue; - } -#endif -#ifdef GL_SGIS_detail_texture - if (_glewStrSame3(&pos, &len, (const GLubyte*)"detail_texture", 14)) - { - ret = GLEW_SGIS_detail_texture; - continue; - } -#endif -#ifdef GL_SGIS_fog_function - if (_glewStrSame3(&pos, &len, (const GLubyte*)"fog_function", 12)) - { - ret = GLEW_SGIS_fog_function; - continue; - } -#endif -#ifdef GL_SGIS_generate_mipmap - if (_glewStrSame3(&pos, &len, (const GLubyte*)"generate_mipmap", 15)) - { - ret = GLEW_SGIS_generate_mipmap; - continue; - } -#endif -#ifdef GL_SGIS_multisample - if (_glewStrSame3(&pos, &len, (const GLubyte*)"multisample", 11)) - { - ret = GLEW_SGIS_multisample; - continue; - } -#endif -#ifdef GL_SGIS_pixel_texture - if (_glewStrSame3(&pos, &len, (const GLubyte*)"pixel_texture", 13)) - { - ret = GLEW_SGIS_pixel_texture; - continue; - } -#endif -#ifdef GL_SGIS_point_line_texgen - if (_glewStrSame3(&pos, &len, (const GLubyte*)"point_line_texgen", 17)) - { - ret = GLEW_SGIS_point_line_texgen; - continue; - } -#endif -#ifdef GL_SGIS_sharpen_texture - if (_glewStrSame3(&pos, &len, (const GLubyte*)"sharpen_texture", 15)) - { - ret = GLEW_SGIS_sharpen_texture; - continue; - } -#endif -#ifdef GL_SGIS_texture4D - if (_glewStrSame3(&pos, &len, (const GLubyte*)"texture4D", 9)) - { - ret = GLEW_SGIS_texture4D; - continue; - } -#endif -#ifdef GL_SGIS_texture_border_clamp - if (_glewStrSame3(&pos, &len, (const GLubyte*)"texture_border_clamp", 20)) - { - ret = GLEW_SGIS_texture_border_clamp; - continue; - } -#endif -#ifdef GL_SGIS_texture_edge_clamp - if (_glewStrSame3(&pos, &len, (const GLubyte*)"texture_edge_clamp", 18)) - { - ret = GLEW_SGIS_texture_edge_clamp; - continue; - } -#endif -#ifdef GL_SGIS_texture_filter4 - if (_glewStrSame3(&pos, &len, (const GLubyte*)"texture_filter4", 15)) - { - ret = GLEW_SGIS_texture_filter4; - continue; - } -#endif -#ifdef GL_SGIS_texture_lod - if (_glewStrSame3(&pos, &len, (const GLubyte*)"texture_lod", 11)) - { - ret = GLEW_SGIS_texture_lod; - continue; - } -#endif -#ifdef GL_SGIS_texture_select - if (_glewStrSame3(&pos, &len, (const GLubyte*)"texture_select", 14)) - { - ret = GLEW_SGIS_texture_select; - continue; - } -#endif - } - if (_glewStrSame2(&pos, &len, (const GLubyte*)"SGIX_", 5)) - { -#ifdef GL_SGIX_async - if (_glewStrSame3(&pos, &len, (const GLubyte*)"async", 5)) - { - ret = GLEW_SGIX_async; - continue; - } -#endif -#ifdef GL_SGIX_async_histogram - if (_glewStrSame3(&pos, &len, (const GLubyte*)"async_histogram", 15)) - { - ret = GLEW_SGIX_async_histogram; - continue; - } -#endif -#ifdef GL_SGIX_async_pixel - if (_glewStrSame3(&pos, &len, (const GLubyte*)"async_pixel", 11)) - { - ret = GLEW_SGIX_async_pixel; - continue; - } -#endif -#ifdef GL_SGIX_blend_alpha_minmax - if (_glewStrSame3(&pos, &len, (const GLubyte*)"blend_alpha_minmax", 18)) - { - ret = GLEW_SGIX_blend_alpha_minmax; - continue; - } -#endif -#ifdef GL_SGIX_clipmap - if (_glewStrSame3(&pos, &len, (const GLubyte*)"clipmap", 7)) - { - ret = GLEW_SGIX_clipmap; - continue; - } -#endif -#ifdef GL_SGIX_convolution_accuracy - if (_glewStrSame3(&pos, &len, (const GLubyte*)"convolution_accuracy", 20)) - { - ret = GLEW_SGIX_convolution_accuracy; - continue; - } -#endif -#ifdef GL_SGIX_depth_texture - if (_glewStrSame3(&pos, &len, (const GLubyte*)"depth_texture", 13)) - { - ret = GLEW_SGIX_depth_texture; - continue; - } -#endif -#ifdef GL_SGIX_flush_raster - if (_glewStrSame3(&pos, &len, (const GLubyte*)"flush_raster", 12)) - { - ret = GLEW_SGIX_flush_raster; - continue; - } -#endif -#ifdef GL_SGIX_fog_offset - if (_glewStrSame3(&pos, &len, (const GLubyte*)"fog_offset", 10)) - { - ret = GLEW_SGIX_fog_offset; - continue; - } -#endif -#ifdef GL_SGIX_fog_texture - if (_glewStrSame3(&pos, &len, (const GLubyte*)"fog_texture", 11)) - { - ret = GLEW_SGIX_fog_texture; - continue; - } -#endif -#ifdef GL_SGIX_fragment_specular_lighting - if (_glewStrSame3(&pos, &len, (const GLubyte*)"fragment_specular_lighting", 26)) - { - ret = GLEW_SGIX_fragment_specular_lighting; - continue; - } -#endif -#ifdef GL_SGIX_framezoom - if (_glewStrSame3(&pos, &len, (const GLubyte*)"framezoom", 9)) - { - ret = GLEW_SGIX_framezoom; - continue; - } -#endif -#ifdef GL_SGIX_interlace - if (_glewStrSame3(&pos, &len, (const GLubyte*)"interlace", 9)) - { - ret = GLEW_SGIX_interlace; - continue; - } -#endif -#ifdef GL_SGIX_ir_instrument1 - if (_glewStrSame3(&pos, &len, (const GLubyte*)"ir_instrument1", 14)) - { - ret = GLEW_SGIX_ir_instrument1; - continue; - } -#endif -#ifdef GL_SGIX_list_priority - if (_glewStrSame3(&pos, &len, (const GLubyte*)"list_priority", 13)) - { - ret = GLEW_SGIX_list_priority; - continue; - } -#endif -#ifdef GL_SGIX_pixel_texture - if (_glewStrSame3(&pos, &len, (const GLubyte*)"pixel_texture", 13)) - { - ret = GLEW_SGIX_pixel_texture; - continue; - } -#endif -#ifdef GL_SGIX_pixel_texture_bits - if (_glewStrSame3(&pos, &len, (const GLubyte*)"pixel_texture_bits", 18)) - { - ret = GLEW_SGIX_pixel_texture_bits; - continue; - } -#endif -#ifdef GL_SGIX_reference_plane - if (_glewStrSame3(&pos, &len, (const GLubyte*)"reference_plane", 15)) - { - ret = GLEW_SGIX_reference_plane; - continue; - } -#endif -#ifdef GL_SGIX_resample - if (_glewStrSame3(&pos, &len, (const GLubyte*)"resample", 8)) - { - ret = GLEW_SGIX_resample; - continue; - } -#endif -#ifdef GL_SGIX_shadow - if (_glewStrSame3(&pos, &len, (const GLubyte*)"shadow", 6)) - { - ret = GLEW_SGIX_shadow; - continue; - } -#endif -#ifdef GL_SGIX_shadow_ambient - if (_glewStrSame3(&pos, &len, (const GLubyte*)"shadow_ambient", 14)) - { - ret = GLEW_SGIX_shadow_ambient; - continue; - } -#endif -#ifdef GL_SGIX_sprite - if (_glewStrSame3(&pos, &len, (const GLubyte*)"sprite", 6)) - { - ret = GLEW_SGIX_sprite; - continue; - } -#endif -#ifdef GL_SGIX_tag_sample_buffer - if (_glewStrSame3(&pos, &len, (const GLubyte*)"tag_sample_buffer", 17)) - { - ret = GLEW_SGIX_tag_sample_buffer; - continue; - } -#endif -#ifdef GL_SGIX_texture_add_env - if (_glewStrSame3(&pos, &len, (const GLubyte*)"texture_add_env", 15)) - { - ret = GLEW_SGIX_texture_add_env; - continue; - } -#endif -#ifdef GL_SGIX_texture_coordinate_clamp - if (_glewStrSame3(&pos, &len, (const GLubyte*)"texture_coordinate_clamp", 24)) - { - ret = GLEW_SGIX_texture_coordinate_clamp; - continue; - } -#endif -#ifdef GL_SGIX_texture_lod_bias - if (_glewStrSame3(&pos, &len, (const GLubyte*)"texture_lod_bias", 16)) - { - ret = GLEW_SGIX_texture_lod_bias; - continue; - } -#endif -#ifdef GL_SGIX_texture_multi_buffer - if (_glewStrSame3(&pos, &len, (const GLubyte*)"texture_multi_buffer", 20)) - { - ret = GLEW_SGIX_texture_multi_buffer; - continue; - } -#endif -#ifdef GL_SGIX_texture_range - if (_glewStrSame3(&pos, &len, (const GLubyte*)"texture_range", 13)) - { - ret = GLEW_SGIX_texture_range; - continue; - } -#endif -#ifdef GL_SGIX_texture_scale_bias - if (_glewStrSame3(&pos, &len, (const GLubyte*)"texture_scale_bias", 18)) - { - ret = GLEW_SGIX_texture_scale_bias; - continue; - } -#endif -#ifdef GL_SGIX_vertex_preclip - if (_glewStrSame3(&pos, &len, (const GLubyte*)"vertex_preclip", 14)) - { - ret = GLEW_SGIX_vertex_preclip; - continue; - } -#endif -#ifdef GL_SGIX_vertex_preclip_hint - if (_glewStrSame3(&pos, &len, (const GLubyte*)"vertex_preclip_hint", 19)) - { - ret = GLEW_SGIX_vertex_preclip_hint; - continue; - } -#endif -#ifdef GL_SGIX_ycrcb - if (_glewStrSame3(&pos, &len, (const GLubyte*)"ycrcb", 5)) - { - ret = GLEW_SGIX_ycrcb; - continue; - } -#endif - } - if (_glewStrSame2(&pos, &len, (const GLubyte*)"SGI_", 4)) - { -#ifdef GL_SGI_color_matrix - if (_glewStrSame3(&pos, &len, (const GLubyte*)"color_matrix", 12)) - { - ret = GLEW_SGI_color_matrix; - continue; - } -#endif -#ifdef GL_SGI_color_table - if (_glewStrSame3(&pos, &len, (const GLubyte*)"color_table", 11)) - { - ret = GLEW_SGI_color_table; - continue; - } -#endif -#ifdef GL_SGI_texture_color_table - if (_glewStrSame3(&pos, &len, (const GLubyte*)"texture_color_table", 19)) - { - ret = GLEW_SGI_texture_color_table; - continue; - } -#endif - } - if (_glewStrSame2(&pos, &len, (const GLubyte*)"SUNX_", 5)) - { -#ifdef GL_SUNX_constant_data - if (_glewStrSame3(&pos, &len, (const GLubyte*)"constant_data", 13)) - { - ret = GLEW_SUNX_constant_data; - continue; - } -#endif - } - if (_glewStrSame2(&pos, &len, (const GLubyte*)"SUN_", 4)) - { -#ifdef GL_SUN_convolution_border_modes - if (_glewStrSame3(&pos, &len, (const GLubyte*)"convolution_border_modes", 24)) - { - ret = GLEW_SUN_convolution_border_modes; - continue; - } -#endif -#ifdef GL_SUN_global_alpha - if (_glewStrSame3(&pos, &len, (const GLubyte*)"global_alpha", 12)) - { - ret = GLEW_SUN_global_alpha; - continue; - } -#endif -#ifdef GL_SUN_mesh_array - if (_glewStrSame3(&pos, &len, (const GLubyte*)"mesh_array", 10)) - { - ret = GLEW_SUN_mesh_array; - continue; - } -#endif -#ifdef GL_SUN_read_video_pixels - if (_glewStrSame3(&pos, &len, (const GLubyte*)"read_video_pixels", 17)) - { - ret = GLEW_SUN_read_video_pixels; - continue; - } -#endif -#ifdef GL_SUN_slice_accum - if (_glewStrSame3(&pos, &len, (const GLubyte*)"slice_accum", 11)) - { - ret = GLEW_SUN_slice_accum; - continue; - } -#endif -#ifdef GL_SUN_triangle_list - if (_glewStrSame3(&pos, &len, (const GLubyte*)"triangle_list", 13)) - { - ret = GLEW_SUN_triangle_list; - continue; - } -#endif -#ifdef GL_SUN_vertex - if (_glewStrSame3(&pos, &len, (const GLubyte*)"vertex", 6)) - { - ret = GLEW_SUN_vertex; - continue; - } -#endif - } - if (_glewStrSame2(&pos, &len, (const GLubyte*)"WIN_", 4)) - { -#ifdef GL_WIN_phong_shading - if (_glewStrSame3(&pos, &len, (const GLubyte*)"phong_shading", 13)) - { - ret = GLEW_WIN_phong_shading; - continue; - } -#endif -#ifdef GL_WIN_specular_fog - if (_glewStrSame3(&pos, &len, (const GLubyte*)"specular_fog", 12)) - { - ret = GLEW_WIN_specular_fog; - continue; - } -#endif -#ifdef GL_WIN_swap_hint - if (_glewStrSame3(&pos, &len, (const GLubyte*)"swap_hint", 9)) - { - ret = GLEW_WIN_swap_hint; - continue; - } -#endif - } - } - ret = (len == 0); - } - return ret; -} - -#if defined(_WIN32) - -#if defined(GLEW_MX) -GLboolean wglewContextIsSupported (WGLEWContext* ctx, const char* name) -#else -GLboolean wglewIsSupported (const char* name) -#endif -{ - GLubyte* pos = (GLubyte*)name; - GLuint len = _glewStrLen(pos); - GLboolean ret = GL_TRUE; - while (ret && len > 0) - { - if (_glewStrSame1(&pos, &len, (const GLubyte*)"WGL_", 4)) - { - if (_glewStrSame2(&pos, &len, (const GLubyte*)"3DFX_", 5)) - { -#ifdef WGL_3DFX_multisample - if (_glewStrSame3(&pos, &len, (const GLubyte*)"multisample", 11)) - { - ret = WGLEW_3DFX_multisample; - continue; - } -#endif - } - if (_glewStrSame2(&pos, &len, (const GLubyte*)"3DL_", 4)) - { -#ifdef WGL_3DL_stereo_control - if (_glewStrSame3(&pos, &len, (const GLubyte*)"stereo_control", 14)) - { - ret = WGLEW_3DL_stereo_control; - continue; - } -#endif - } - if (_glewStrSame2(&pos, &len, (const GLubyte*)"ARB_", 4)) - { -#ifdef WGL_ARB_buffer_region - if (_glewStrSame3(&pos, &len, (const GLubyte*)"buffer_region", 13)) - { - ret = WGLEW_ARB_buffer_region; - continue; - } -#endif -#ifdef WGL_ARB_create_context - if (_glewStrSame3(&pos, &len, (const GLubyte*)"create_context", 14)) - { - ret = WGLEW_ARB_create_context; - continue; - } -#endif -#ifdef WGL_ARB_extensions_string - if (_glewStrSame3(&pos, &len, (const GLubyte*)"extensions_string", 17)) - { - ret = WGLEW_ARB_extensions_string; - continue; - } -#endif -#ifdef WGL_ARB_framebuffer_sRGB - if (_glewStrSame3(&pos, &len, (const GLubyte*)"framebuffer_sRGB", 16)) - { - ret = WGLEW_ARB_framebuffer_sRGB; - continue; - } -#endif -#ifdef WGL_ARB_make_current_read - if (_glewStrSame3(&pos, &len, (const GLubyte*)"make_current_read", 17)) - { - ret = WGLEW_ARB_make_current_read; - continue; - } -#endif -#ifdef WGL_ARB_multisample - if (_glewStrSame3(&pos, &len, (const GLubyte*)"multisample", 11)) - { - ret = WGLEW_ARB_multisample; - continue; - } -#endif -#ifdef WGL_ARB_pbuffer - if (_glewStrSame3(&pos, &len, (const GLubyte*)"pbuffer", 7)) - { - ret = WGLEW_ARB_pbuffer; - continue; - } -#endif -#ifdef WGL_ARB_pixel_format - if (_glewStrSame3(&pos, &len, (const GLubyte*)"pixel_format", 12)) - { - ret = WGLEW_ARB_pixel_format; - continue; - } -#endif -#ifdef WGL_ARB_pixel_format_float - if (_glewStrSame3(&pos, &len, (const GLubyte*)"pixel_format_float", 18)) - { - ret = WGLEW_ARB_pixel_format_float; - continue; - } -#endif -#ifdef WGL_ARB_render_texture - if (_glewStrSame3(&pos, &len, (const GLubyte*)"render_texture", 14)) - { - ret = WGLEW_ARB_render_texture; - continue; - } -#endif - } - if (_glewStrSame2(&pos, &len, (const GLubyte*)"ATI_", 4)) - { -#ifdef WGL_ATI_pixel_format_float - if (_glewStrSame3(&pos, &len, (const GLubyte*)"pixel_format_float", 18)) - { - ret = WGLEW_ATI_pixel_format_float; - continue; - } -#endif -#ifdef WGL_ATI_render_texture_rectangle - if (_glewStrSame3(&pos, &len, (const GLubyte*)"render_texture_rectangle", 24)) - { - ret = WGLEW_ATI_render_texture_rectangle; - continue; - } -#endif - } - if (_glewStrSame2(&pos, &len, (const GLubyte*)"EXT_", 4)) - { -#ifdef WGL_EXT_depth_float - if (_glewStrSame3(&pos, &len, (const GLubyte*)"depth_float", 11)) - { - ret = WGLEW_EXT_depth_float; - continue; - } -#endif -#ifdef WGL_EXT_display_color_table - if (_glewStrSame3(&pos, &len, (const GLubyte*)"display_color_table", 19)) - { - ret = WGLEW_EXT_display_color_table; - continue; - } -#endif -#ifdef WGL_EXT_extensions_string - if (_glewStrSame3(&pos, &len, (const GLubyte*)"extensions_string", 17)) - { - ret = WGLEW_EXT_extensions_string; - continue; - } -#endif -#ifdef WGL_EXT_framebuffer_sRGB - if (_glewStrSame3(&pos, &len, (const GLubyte*)"framebuffer_sRGB", 16)) - { - ret = WGLEW_EXT_framebuffer_sRGB; - continue; - } -#endif -#ifdef WGL_EXT_make_current_read - if (_glewStrSame3(&pos, &len, (const GLubyte*)"make_current_read", 17)) - { - ret = WGLEW_EXT_make_current_read; - continue; - } -#endif -#ifdef WGL_EXT_multisample - if (_glewStrSame3(&pos, &len, (const GLubyte*)"multisample", 11)) - { - ret = WGLEW_EXT_multisample; - continue; - } -#endif -#ifdef WGL_EXT_pbuffer - if (_glewStrSame3(&pos, &len, (const GLubyte*)"pbuffer", 7)) - { - ret = WGLEW_EXT_pbuffer; - continue; - } -#endif -#ifdef WGL_EXT_pixel_format - if (_glewStrSame3(&pos, &len, (const GLubyte*)"pixel_format", 12)) - { - ret = WGLEW_EXT_pixel_format; - continue; - } -#endif -#ifdef WGL_EXT_pixel_format_packed_float - if (_glewStrSame3(&pos, &len, (const GLubyte*)"pixel_format_packed_float", 25)) - { - ret = WGLEW_EXT_pixel_format_packed_float; - continue; - } -#endif -#ifdef WGL_EXT_swap_control - if (_glewStrSame3(&pos, &len, (const GLubyte*)"swap_control", 12)) - { - ret = WGLEW_EXT_swap_control; - continue; - } -#endif - } - if (_glewStrSame2(&pos, &len, (const GLubyte*)"I3D_", 4)) - { -#ifdef WGL_I3D_digital_video_control - if (_glewStrSame3(&pos, &len, (const GLubyte*)"digital_video_control", 21)) - { - ret = WGLEW_I3D_digital_video_control; - continue; - } -#endif -#ifdef WGL_I3D_gamma - if (_glewStrSame3(&pos, &len, (const GLubyte*)"gamma", 5)) - { - ret = WGLEW_I3D_gamma; - continue; - } -#endif -#ifdef WGL_I3D_genlock - if (_glewStrSame3(&pos, &len, (const GLubyte*)"genlock", 7)) - { - ret = WGLEW_I3D_genlock; - continue; - } -#endif -#ifdef WGL_I3D_image_buffer - if (_glewStrSame3(&pos, &len, (const GLubyte*)"image_buffer", 12)) - { - ret = WGLEW_I3D_image_buffer; - continue; - } -#endif -#ifdef WGL_I3D_swap_frame_lock - if (_glewStrSame3(&pos, &len, (const GLubyte*)"swap_frame_lock", 15)) - { - ret = WGLEW_I3D_swap_frame_lock; - continue; - } -#endif -#ifdef WGL_I3D_swap_frame_usage - if (_glewStrSame3(&pos, &len, (const GLubyte*)"swap_frame_usage", 16)) - { - ret = WGLEW_I3D_swap_frame_usage; - continue; - } -#endif - } - if (_glewStrSame2(&pos, &len, (const GLubyte*)"NV_", 3)) - { -#ifdef WGL_NV_float_buffer - if (_glewStrSame3(&pos, &len, (const GLubyte*)"float_buffer", 12)) - { - ret = WGLEW_NV_float_buffer; - continue; - } -#endif -#ifdef WGL_NV_gpu_affinity - if (_glewStrSame3(&pos, &len, (const GLubyte*)"gpu_affinity", 12)) - { - ret = WGLEW_NV_gpu_affinity; - continue; - } -#endif -#ifdef WGL_NV_present_video - if (_glewStrSame3(&pos, &len, (const GLubyte*)"present_video", 13)) - { - ret = WGLEW_NV_present_video; - continue; - } -#endif -#ifdef WGL_NV_render_depth_texture - if (_glewStrSame3(&pos, &len, (const GLubyte*)"render_depth_texture", 20)) - { - ret = WGLEW_NV_render_depth_texture; - continue; - } -#endif -#ifdef WGL_NV_render_texture_rectangle - if (_glewStrSame3(&pos, &len, (const GLubyte*)"render_texture_rectangle", 24)) - { - ret = WGLEW_NV_render_texture_rectangle; - continue; - } -#endif -#ifdef WGL_NV_swap_group - if (_glewStrSame3(&pos, &len, (const GLubyte*)"swap_group", 10)) - { - ret = WGLEW_NV_swap_group; - continue; - } -#endif -#ifdef WGL_NV_vertex_array_range - if (_glewStrSame3(&pos, &len, (const GLubyte*)"vertex_array_range", 18)) - { - ret = WGLEW_NV_vertex_array_range; - continue; - } -#endif -#ifdef WGL_NV_video_output - if (_glewStrSame3(&pos, &len, (const GLubyte*)"video_output", 12)) - { - ret = WGLEW_NV_video_output; - continue; - } -#endif - } - if (_glewStrSame2(&pos, &len, (const GLubyte*)"OML_", 4)) - { -#ifdef WGL_OML_sync_control - if (_glewStrSame3(&pos, &len, (const GLubyte*)"sync_control", 12)) - { - ret = WGLEW_OML_sync_control; - continue; - } -#endif - } - } - ret = (len == 0); - } - return ret; -} - -#elif !defined(__APPLE__) || defined(GLEW_APPLE_GLX) - -#if defined(GLEW_MX) -GLboolean glxewContextIsSupported (GLXEWContext* ctx, const char* name) -#else -GLboolean glxewIsSupported (const char* name) -#endif -{ - GLubyte* pos = (GLubyte*)name; - GLuint len = _glewStrLen(pos); - GLboolean ret = GL_TRUE; - while (ret && len > 0) - { - if(_glewStrSame1(&pos, &len, (const GLubyte*)"GLX_", 4)) - { - if (_glewStrSame2(&pos, &len, (const GLubyte*)"VERSION_", 8)) - { -#ifdef GLX_VERSION_1_2 - if (_glewStrSame3(&pos, &len, (const GLubyte*)"1_2", 3)) - { - ret = GLXEW_VERSION_1_2; - continue; - } -#endif -#ifdef GLX_VERSION_1_3 - if (_glewStrSame3(&pos, &len, (const GLubyte*)"1_3", 3)) - { - ret = GLXEW_VERSION_1_3; - continue; - } -#endif -#ifdef GLX_VERSION_1_4 - if (_glewStrSame3(&pos, &len, (const GLubyte*)"1_4", 3)) - { - ret = GLXEW_VERSION_1_4; - continue; - } -#endif - } - if (_glewStrSame2(&pos, &len, (const GLubyte*)"3DFX_", 5)) - { -#ifdef GLX_3DFX_multisample - if (_glewStrSame3(&pos, &len, (const GLubyte*)"multisample", 11)) - { - ret = GLXEW_3DFX_multisample; - continue; - } -#endif - } - if (_glewStrSame2(&pos, &len, (const GLubyte*)"ARB_", 4)) - { -#ifdef GLX_ARB_create_context - if (_glewStrSame3(&pos, &len, (const GLubyte*)"create_context", 14)) - { - ret = GLXEW_ARB_create_context; - continue; - } -#endif -#ifdef GLX_ARB_fbconfig_float - if (_glewStrSame3(&pos, &len, (const GLubyte*)"fbconfig_float", 14)) - { - ret = GLXEW_ARB_fbconfig_float; - continue; - } -#endif -#ifdef GLX_ARB_framebuffer_sRGB - if (_glewStrSame3(&pos, &len, (const GLubyte*)"framebuffer_sRGB", 16)) - { - ret = GLXEW_ARB_framebuffer_sRGB; - continue; - } -#endif -#ifdef GLX_ARB_get_proc_address - if (_glewStrSame3(&pos, &len, (const GLubyte*)"get_proc_address", 16)) - { - ret = GLXEW_ARB_get_proc_address; - continue; - } -#endif -#ifdef GLX_ARB_multisample - if (_glewStrSame3(&pos, &len, (const GLubyte*)"multisample", 11)) - { - ret = GLXEW_ARB_multisample; - continue; - } -#endif - } - if (_glewStrSame2(&pos, &len, (const GLubyte*)"ATI_", 4)) - { -#ifdef GLX_ATI_pixel_format_float - if (_glewStrSame3(&pos, &len, (const GLubyte*)"pixel_format_float", 18)) - { - ret = GLXEW_ATI_pixel_format_float; - continue; - } -#endif -#ifdef GLX_ATI_render_texture - if (_glewStrSame3(&pos, &len, (const GLubyte*)"render_texture", 14)) - { - ret = GLXEW_ATI_render_texture; - continue; - } -#endif - } - if (_glewStrSame2(&pos, &len, (const GLubyte*)"EXT_", 4)) - { -#ifdef GLX_EXT_fbconfig_packed_float - if (_glewStrSame3(&pos, &len, (const GLubyte*)"fbconfig_packed_float", 21)) - { - ret = GLXEW_EXT_fbconfig_packed_float; - continue; - } -#endif -#ifdef GLX_EXT_framebuffer_sRGB - if (_glewStrSame3(&pos, &len, (const GLubyte*)"framebuffer_sRGB", 16)) - { - ret = GLXEW_EXT_framebuffer_sRGB; - continue; - } -#endif -#ifdef GLX_EXT_import_context - if (_glewStrSame3(&pos, &len, (const GLubyte*)"import_context", 14)) - { - ret = GLXEW_EXT_import_context; - continue; - } -#endif -#ifdef GLX_EXT_scene_marker - if (_glewStrSame3(&pos, &len, (const GLubyte*)"scene_marker", 12)) - { - ret = GLXEW_EXT_scene_marker; - continue; - } -#endif -#ifdef GLX_EXT_texture_from_pixmap - if (_glewStrSame3(&pos, &len, (const GLubyte*)"texture_from_pixmap", 19)) - { - ret = GLXEW_EXT_texture_from_pixmap; - continue; - } -#endif -#ifdef GLX_EXT_visual_info - if (_glewStrSame3(&pos, &len, (const GLubyte*)"visual_info", 11)) - { - ret = GLXEW_EXT_visual_info; - continue; - } -#endif -#ifdef GLX_EXT_visual_rating - if (_glewStrSame3(&pos, &len, (const GLubyte*)"visual_rating", 13)) - { - ret = GLXEW_EXT_visual_rating; - continue; - } -#endif - } - if (_glewStrSame2(&pos, &len, (const GLubyte*)"MESA_", 5)) - { -#ifdef GLX_MESA_agp_offset - if (_glewStrSame3(&pos, &len, (const GLubyte*)"agp_offset", 10)) - { - ret = GLXEW_MESA_agp_offset; - continue; - } -#endif -#ifdef GLX_MESA_copy_sub_buffer - if (_glewStrSame3(&pos, &len, (const GLubyte*)"copy_sub_buffer", 15)) - { - ret = GLXEW_MESA_copy_sub_buffer; - continue; - } -#endif -#ifdef GLX_MESA_pixmap_colormap - if (_glewStrSame3(&pos, &len, (const GLubyte*)"pixmap_colormap", 15)) - { - ret = GLXEW_MESA_pixmap_colormap; - continue; - } -#endif -#ifdef GLX_MESA_release_buffers - if (_glewStrSame3(&pos, &len, (const GLubyte*)"release_buffers", 15)) - { - ret = GLXEW_MESA_release_buffers; - continue; - } -#endif -#ifdef GLX_MESA_set_3dfx_mode - if (_glewStrSame3(&pos, &len, (const GLubyte*)"set_3dfx_mode", 13)) - { - ret = GLXEW_MESA_set_3dfx_mode; - continue; - } -#endif - } - if (_glewStrSame2(&pos, &len, (const GLubyte*)"NV_", 3)) - { -#ifdef GLX_NV_float_buffer - if (_glewStrSame3(&pos, &len, (const GLubyte*)"float_buffer", 12)) - { - ret = GLXEW_NV_float_buffer; - continue; - } -#endif -#ifdef GLX_NV_present_video - if (_glewStrSame3(&pos, &len, (const GLubyte*)"present_video", 13)) - { - ret = GLXEW_NV_present_video; - continue; - } -#endif -#ifdef GLX_NV_swap_group - if (_glewStrSame3(&pos, &len, (const GLubyte*)"swap_group", 10)) - { - ret = GLXEW_NV_swap_group; - continue; - } -#endif -#ifdef GLX_NV_vertex_array_range - if (_glewStrSame3(&pos, &len, (const GLubyte*)"vertex_array_range", 18)) - { - ret = GLXEW_NV_vertex_array_range; - continue; - } -#endif -#ifdef GLX_NV_video_output - if (_glewStrSame3(&pos, &len, (const GLubyte*)"video_output", 12)) - { - ret = GLXEW_NV_video_output; - continue; - } -#endif - } - if (_glewStrSame2(&pos, &len, (const GLubyte*)"OML_", 4)) - { -#ifdef GLX_OML_swap_method - if (_glewStrSame3(&pos, &len, (const GLubyte*)"swap_method", 11)) - { - ret = GLXEW_OML_swap_method; - continue; - } -#endif -#if defined(GLX_OML_sync_control) && defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L) -#include - if (_glewStrSame3(&pos, &len, (const GLubyte*)"sync_control", 12)) - { - ret = GLXEW_OML_sync_control; - continue; - } -#endif - } - if (_glewStrSame2(&pos, &len, (const GLubyte*)"SGIS_", 5)) - { -#ifdef GLX_SGIS_blended_overlay - if (_glewStrSame3(&pos, &len, (const GLubyte*)"blended_overlay", 15)) - { - ret = GLXEW_SGIS_blended_overlay; - continue; - } -#endif -#ifdef GLX_SGIS_color_range - if (_glewStrSame3(&pos, &len, (const GLubyte*)"color_range", 11)) - { - ret = GLXEW_SGIS_color_range; - continue; - } -#endif -#ifdef GLX_SGIS_multisample - if (_glewStrSame3(&pos, &len, (const GLubyte*)"multisample", 11)) - { - ret = GLXEW_SGIS_multisample; - continue; - } -#endif -#ifdef GLX_SGIS_shared_multisample - if (_glewStrSame3(&pos, &len, (const GLubyte*)"shared_multisample", 18)) - { - ret = GLXEW_SGIS_shared_multisample; - continue; - } -#endif - } - if (_glewStrSame2(&pos, &len, (const GLubyte*)"SGIX_", 5)) - { -#ifdef GLX_SGIX_fbconfig - if (_glewStrSame3(&pos, &len, (const GLubyte*)"fbconfig", 8)) - { - ret = GLXEW_SGIX_fbconfig; - continue; - } -#endif -#ifdef GLX_SGIX_hyperpipe - if (_glewStrSame3(&pos, &len, (const GLubyte*)"hyperpipe", 9)) - { - ret = GLXEW_SGIX_hyperpipe; - continue; - } -#endif -#ifdef GLX_SGIX_pbuffer - if (_glewStrSame3(&pos, &len, (const GLubyte*)"pbuffer", 7)) - { - ret = GLXEW_SGIX_pbuffer; - continue; - } -#endif -#ifdef GLX_SGIX_swap_barrier - if (_glewStrSame3(&pos, &len, (const GLubyte*)"swap_barrier", 12)) - { - ret = GLXEW_SGIX_swap_barrier; - continue; - } -#endif -#ifdef GLX_SGIX_swap_group - if (_glewStrSame3(&pos, &len, (const GLubyte*)"swap_group", 10)) - { - ret = GLXEW_SGIX_swap_group; - continue; - } -#endif -#ifdef GLX_SGIX_video_resize - if (_glewStrSame3(&pos, &len, (const GLubyte*)"video_resize", 12)) - { - ret = GLXEW_SGIX_video_resize; - continue; - } -#endif -#ifdef GLX_SGIX_visual_select_group - if (_glewStrSame3(&pos, &len, (const GLubyte*)"visual_select_group", 19)) - { - ret = GLXEW_SGIX_visual_select_group; - continue; - } -#endif - } - if (_glewStrSame2(&pos, &len, (const GLubyte*)"SGI_", 4)) - { -#ifdef GLX_SGI_cushion - if (_glewStrSame3(&pos, &len, (const GLubyte*)"cushion", 7)) - { - ret = GLXEW_SGI_cushion; - continue; - } -#endif -#ifdef GLX_SGI_make_current_read - if (_glewStrSame3(&pos, &len, (const GLubyte*)"make_current_read", 17)) - { - ret = GLXEW_SGI_make_current_read; - continue; - } -#endif -#ifdef GLX_SGI_swap_control - if (_glewStrSame3(&pos, &len, (const GLubyte*)"swap_control", 12)) - { - ret = GLXEW_SGI_swap_control; - continue; - } -#endif -#ifdef GLX_SGI_video_sync - if (_glewStrSame3(&pos, &len, (const GLubyte*)"video_sync", 10)) - { - ret = GLXEW_SGI_video_sync; - continue; - } -#endif - } - if (_glewStrSame2(&pos, &len, (const GLubyte*)"SUN_", 4)) - { -#ifdef GLX_SUN_get_transparent_index - if (_glewStrSame3(&pos, &len, (const GLubyte*)"get_transparent_index", 21)) - { - ret = GLXEW_SUN_get_transparent_index; - continue; - } -#endif -#ifdef GLX_SUN_video_resize - if (_glewStrSame3(&pos, &len, (const GLubyte*)"video_resize", 12)) - { - ret = GLXEW_SUN_video_resize; - continue; - } -#endif - } - } - ret = (len == 0); - } - return ret; -} - -#endif /* _WIN32 */ diff --git a/opengl/glew.h b/opengl/glew.h deleted file mode 100644 index fae0c216..00000000 --- a/opengl/glew.h +++ /dev/null @@ -1,20113 +0,0 @@ -/* -** The OpenGL Extension Wrangler Library -** Copyright (C) 2008-2015, Nigel Stewart -** Copyright (C) 2002-2008, Milan Ikits -** Copyright (C) 2002-2008, Marcelo E. Magallon -** Copyright (C) 2002, Lev Povalahev -** All rights reserved. -** -** Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are met: -** -** * Redistributions of source code must retain the above copyright notice, -** this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright notice, -** this list of conditions and the following disclaimer in the documentation -** and/or other materials provided with the distribution. -** * The name of the author may be used to endorse or promote products -** derived from this software without specific prior written permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -** AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -** IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -** ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE -** LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -** CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -** SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -** INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -** CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -** ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF -** THE POSSIBILITY OF SUCH DAMAGE. -*/ - -/* - * Mesa 3-D graphics library - * Version: 7.0 - * - * Copyright (C) 1999-2007 Brian Paul All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -/* -** Copyright (c) 2007 The Khronos Group Inc. -** -** Permission is hereby granted, free of charge, to any person obtaining a -** copy of this software and/or associated documentation files (the -** "Materials"), to deal in the Materials without restriction, including -** without limitation the rights to use, copy, modify, merge, publish, -** distribute, sublicense, and/or sell copies of the Materials, and to -** permit persons to whom the Materials are furnished to do so, subject to -** the following conditions: -** -** The above copyright notice and this permission notice shall be included -** in all copies or substantial portions of the Materials. -** -** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. -** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY -** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, -** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE -** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS. -*/ - -#ifndef __glew_h__ -#define __glew_h__ -#define __GLEW_H__ - -#if defined(__gl_h_) || defined(__GL_H__) || defined(_GL_H) || defined(__X_GL_H) -#error gl.h included before glew.h -#endif -#if defined(__gl2_h_) -#error gl2.h included before glew.h -#endif -#if defined(__gltypes_h_) -#error gltypes.h included before glew.h -#endif -#if defined(__REGAL_H__) -#error Regal.h included before glew.h -#endif -#if defined(__glext_h_) || defined(__GLEXT_H_) -#error glext.h included before glew.h -#endif -#if defined(__gl_ATI_h_) -#error glATI.h included before glew.h -#endif - -#define __gl_h_ -#define __gl2_h_ -#define __GL_H__ -#define _GL_H -#define __gltypes_h_ -#define __REGAL_H__ -#define __X_GL_H -#define __glext_h_ -#define __GLEXT_H_ -#define __gl_ATI_h_ - -#if defined(_WIN32) - -/* - * GLEW does not include to avoid name space pollution. - * GL needs GLAPI and GLAPIENTRY, GLU needs APIENTRY, CALLBACK, and wchar_t - * defined properly. - */ -/* and */ -#ifdef APIENTRY -# ifndef GLAPIENTRY -# define GLAPIENTRY APIENTRY -# endif -# ifndef GLEWAPIENTRY -# define GLEWAPIENTRY APIENTRY -# endif -#else -#define GLEW_APIENTRY_DEFINED -# if defined(__MINGW32__) || defined(__CYGWIN__) || (_MSC_VER >= 800) || defined(_STDCALL_SUPPORTED) || defined(__BORLANDC__) -# define APIENTRY __stdcall -# ifndef GLAPIENTRY -# define GLAPIENTRY __stdcall -# endif -# ifndef GLEWAPIENTRY -# define GLEWAPIENTRY __stdcall -# endif -# else -# define APIENTRY -# endif -#endif -#ifndef GLAPI -# if defined(__MINGW32__) || defined(__CYGWIN__) -# define GLAPI extern -# endif -#endif -/* */ -#ifndef CALLBACK -#define GLEW_CALLBACK_DEFINED -# if defined(__MINGW32__) || defined(__CYGWIN__) -# define CALLBACK __attribute__ ((__stdcall__)) -# elif (defined(_M_MRX000) || defined(_M_IX86) || defined(_M_ALPHA) || defined(_M_PPC)) && !defined(MIDL_PASS) -# define CALLBACK __stdcall -# else -# define CALLBACK -# endif -#endif -/* and */ -#ifndef WINGDIAPI -#define GLEW_WINGDIAPI_DEFINED -#define WINGDIAPI __declspec(dllimport) -#endif -/* */ -#if (defined(_MSC_VER) || defined(__BORLANDC__)) && !defined(_WCHAR_T_DEFINED) -typedef unsigned short wchar_t; -# define _WCHAR_T_DEFINED -#endif -/* */ -#if !defined(_W64) -# if !defined(__midl) && (defined(_X86_) || defined(_M_IX86)) && defined(_MSC_VER) && _MSC_VER >= 1300 -# define _W64 __w64 -# else -# define _W64 -# endif -#endif -#if !defined(_PTRDIFF_T_DEFINED) && !defined(_PTRDIFF_T_) && !defined(__MINGW64__) -# ifdef _WIN64 -typedef __int64 ptrdiff_t; -# else -typedef _W64 int ptrdiff_t; -# endif -# define _PTRDIFF_T_DEFINED -# define _PTRDIFF_T_ -#endif - -#ifndef GLAPI -# if defined(__MINGW32__) || defined(__CYGWIN__) -# define GLAPI extern -# else -# define GLAPI WINGDIAPI -# endif -#endif - -/* - * GLEW_STATIC is defined for static library. - * GLEW_BUILD is defined for building the DLL library. - */ - -#ifdef GLEW_STATIC -# define GLEWAPI extern -#else -# ifdef GLEW_BUILD -# define GLEWAPI extern __declspec(dllexport) -# else -# define GLEWAPI extern __declspec(dllimport) -# endif -#endif - -#else /* _UNIX */ - -/* - * Needed for ptrdiff_t in turn needed by VBO. This is defined by ISO - * C. On my system, this amounts to _3 lines_ of included code, all of - * them pretty much harmless. If you know of a way of detecting 32 vs - * 64 _targets_ at compile time you are free to replace this with - * something that's portable. For now, _this_ is the portable solution. - * (mem, 2004-01-04) - */ - -#include - -/* SGI MIPSPro doesn't like stdint.h in C++ mode */ -/* ID: 3376260 Solaris 9 has inttypes.h, but not stdint.h */ - -#if (defined(__sgi) || defined(__sun)) && !defined(__GNUC__) -#include -#else -#include -#endif - -#define GLEW_APIENTRY_DEFINED -#define APIENTRY - -/* - * GLEW_STATIC is defined for static library. - */ - -#ifdef GLEW_STATIC -# define GLEWAPI extern -#else -# if defined(__GNUC__) && __GNUC__>=4 -# define GLEWAPI extern __attribute__ ((visibility("default"))) -# elif defined(__SUNPRO_C) || defined(__SUNPRO_CC) -# define GLEWAPI extern __global -# else -# define GLEWAPI extern -# endif -#endif - -/* */ -#ifndef GLAPI -#define GLAPI extern -#endif - -#endif /* _WIN32 */ - -#ifndef GLAPIENTRY -#define GLAPIENTRY -#endif - -#ifndef GLEWAPIENTRY -#define GLEWAPIENTRY -#endif - -#define GLEW_VAR_EXPORT GLEWAPI -#define GLEW_FUN_EXPORT GLEWAPI - -#ifdef __cplusplus -extern "C" { -#endif - -/* ----------------------------- GL_VERSION_1_1 ---------------------------- */ - -#ifndef GL_VERSION_1_1 -#define GL_VERSION_1_1 1 - -typedef unsigned int GLenum; -typedef unsigned int GLbitfield; -typedef unsigned int GLuint; -typedef int GLint; -typedef int GLsizei; -typedef unsigned char GLboolean; -typedef signed char GLbyte; -typedef short GLshort; -typedef unsigned char GLubyte; -typedef unsigned short GLushort; -typedef unsigned long GLulong; -typedef float GLfloat; -typedef float GLclampf; -typedef double GLdouble; -typedef double GLclampd; -typedef void GLvoid; -#if defined(_MSC_VER) && _MSC_VER < 1400 -typedef __int64 GLint64EXT; -typedef unsigned __int64 GLuint64EXT; -#elif defined(_MSC_VER) || defined(__BORLANDC__) -typedef signed long long GLint64EXT; -typedef unsigned long long GLuint64EXT; -#else -# if defined(__MINGW32__) || defined(__CYGWIN__) -#include -# endif -typedef int64_t GLint64EXT; -typedef uint64_t GLuint64EXT; -#endif -typedef GLint64EXT GLint64; -typedef GLuint64EXT GLuint64; -typedef struct __GLsync *GLsync; - -typedef char GLchar; - -#define GL_ZERO 0 -#define GL_FALSE 0 -#define GL_LOGIC_OP 0x0BF1 -#define GL_NONE 0 -#define GL_TEXTURE_COMPONENTS 0x1003 -#define GL_NO_ERROR 0 -#define GL_POINTS 0x0000 -#define GL_CURRENT_BIT 0x00000001 -#define GL_TRUE 1 -#define GL_ONE 1 -#define GL_CLIENT_PIXEL_STORE_BIT 0x00000001 -#define GL_LINES 0x0001 -#define GL_LINE_LOOP 0x0002 -#define GL_POINT_BIT 0x00000002 -#define GL_CLIENT_VERTEX_ARRAY_BIT 0x00000002 -#define GL_LINE_STRIP 0x0003 -#define GL_LINE_BIT 0x00000004 -#define GL_TRIANGLES 0x0004 -#define GL_TRIANGLE_STRIP 0x0005 -#define GL_TRIANGLE_FAN 0x0006 -#define GL_QUADS 0x0007 -#define GL_QUAD_STRIP 0x0008 -#define GL_POLYGON_BIT 0x00000008 -#define GL_POLYGON 0x0009 -#define GL_POLYGON_STIPPLE_BIT 0x00000010 -#define GL_PIXEL_MODE_BIT 0x00000020 -#define GL_LIGHTING_BIT 0x00000040 -#define GL_FOG_BIT 0x00000080 -#define GL_DEPTH_BUFFER_BIT 0x00000100 -#define GL_ACCUM 0x0100 -#define GL_LOAD 0x0101 -#define GL_RETURN 0x0102 -#define GL_MULT 0x0103 -#define GL_ADD 0x0104 -#define GL_NEVER 0x0200 -#define GL_ACCUM_BUFFER_BIT 0x00000200 -#define GL_LESS 0x0201 -#define GL_EQUAL 0x0202 -#define GL_LEQUAL 0x0203 -#define GL_GREATER 0x0204 -#define GL_NOTEQUAL 0x0205 -#define GL_GEQUAL 0x0206 -#define GL_ALWAYS 0x0207 -#define GL_SRC_COLOR 0x0300 -#define GL_ONE_MINUS_SRC_COLOR 0x0301 -#define GL_SRC_ALPHA 0x0302 -#define GL_ONE_MINUS_SRC_ALPHA 0x0303 -#define GL_DST_ALPHA 0x0304 -#define GL_ONE_MINUS_DST_ALPHA 0x0305 -#define GL_DST_COLOR 0x0306 -#define GL_ONE_MINUS_DST_COLOR 0x0307 -#define GL_SRC_ALPHA_SATURATE 0x0308 -#define GL_STENCIL_BUFFER_BIT 0x00000400 -#define GL_FRONT_LEFT 0x0400 -#define GL_FRONT_RIGHT 0x0401 -#define GL_BACK_LEFT 0x0402 -#define GL_BACK_RIGHT 0x0403 -#define GL_FRONT 0x0404 -#define GL_BACK 0x0405 -#define GL_LEFT 0x0406 -#define GL_RIGHT 0x0407 -#define GL_FRONT_AND_BACK 0x0408 -#define GL_AUX0 0x0409 -#define GL_AUX1 0x040A -#define GL_AUX2 0x040B -#define GL_AUX3 0x040C -#define GL_INVALID_ENUM 0x0500 -#define GL_INVALID_VALUE 0x0501 -#define GL_INVALID_OPERATION 0x0502 -#define GL_STACK_OVERFLOW 0x0503 -#define GL_STACK_UNDERFLOW 0x0504 -#define GL_OUT_OF_MEMORY 0x0505 -#define GL_2D 0x0600 -#define GL_3D 0x0601 -#define GL_3D_COLOR 0x0602 -#define GL_3D_COLOR_TEXTURE 0x0603 -#define GL_4D_COLOR_TEXTURE 0x0604 -#define GL_PASS_THROUGH_TOKEN 0x0700 -#define GL_POINT_TOKEN 0x0701 -#define GL_LINE_TOKEN 0x0702 -#define GL_POLYGON_TOKEN 0x0703 -#define GL_BITMAP_TOKEN 0x0704 -#define GL_DRAW_PIXEL_TOKEN 0x0705 -#define GL_COPY_PIXEL_TOKEN 0x0706 -#define GL_LINE_RESET_TOKEN 0x0707 -#define GL_EXP 0x0800 -#define GL_VIEWPORT_BIT 0x00000800 -#define GL_EXP2 0x0801 -#define GL_CW 0x0900 -#define GL_CCW 0x0901 -#define GL_COEFF 0x0A00 -#define GL_ORDER 0x0A01 -#define GL_DOMAIN 0x0A02 -#define GL_CURRENT_COLOR 0x0B00 -#define GL_CURRENT_INDEX 0x0B01 -#define GL_CURRENT_NORMAL 0x0B02 -#define GL_CURRENT_TEXTURE_COORDS 0x0B03 -#define GL_CURRENT_RASTER_COLOR 0x0B04 -#define GL_CURRENT_RASTER_INDEX 0x0B05 -#define GL_CURRENT_RASTER_TEXTURE_COORDS 0x0B06 -#define GL_CURRENT_RASTER_POSITION 0x0B07 -#define GL_CURRENT_RASTER_POSITION_VALID 0x0B08 -#define GL_CURRENT_RASTER_DISTANCE 0x0B09 -#define GL_POINT_SMOOTH 0x0B10 -#define GL_POINT_SIZE 0x0B11 -#define GL_POINT_SIZE_RANGE 0x0B12 -#define GL_POINT_SIZE_GRANULARITY 0x0B13 -#define GL_LINE_SMOOTH 0x0B20 -#define GL_LINE_WIDTH 0x0B21 -#define GL_LINE_WIDTH_RANGE 0x0B22 -#define GL_LINE_WIDTH_GRANULARITY 0x0B23 -#define GL_LINE_STIPPLE 0x0B24 -#define GL_LINE_STIPPLE_PATTERN 0x0B25 -#define GL_LINE_STIPPLE_REPEAT 0x0B26 -#define GL_LIST_MODE 0x0B30 -#define GL_MAX_LIST_NESTING 0x0B31 -#define GL_LIST_BASE 0x0B32 -#define GL_LIST_INDEX 0x0B33 -#define GL_POLYGON_MODE 0x0B40 -#define GL_POLYGON_SMOOTH 0x0B41 -#define GL_POLYGON_STIPPLE 0x0B42 -#define GL_EDGE_FLAG 0x0B43 -#define GL_CULL_FACE 0x0B44 -#define GL_CULL_FACE_MODE 0x0B45 -#define GL_FRONT_FACE 0x0B46 -#define GL_LIGHTING 0x0B50 -#define GL_LIGHT_MODEL_LOCAL_VIEWER 0x0B51 -#define GL_LIGHT_MODEL_TWO_SIDE 0x0B52 -#define GL_LIGHT_MODEL_AMBIENT 0x0B53 -#define GL_SHADE_MODEL 0x0B54 -#define GL_COLOR_MATERIAL_FACE 0x0B55 -#define GL_COLOR_MATERIAL_PARAMETER 0x0B56 -#define GL_COLOR_MATERIAL 0x0B57 -#define GL_FOG 0x0B60 -#define GL_FOG_INDEX 0x0B61 -#define GL_FOG_DENSITY 0x0B62 -#define GL_FOG_START 0x0B63 -#define GL_FOG_END 0x0B64 -#define GL_FOG_MODE 0x0B65 -#define GL_FOG_COLOR 0x0B66 -#define GL_DEPTH_RANGE 0x0B70 -#define GL_DEPTH_TEST 0x0B71 -#define GL_DEPTH_WRITEMASK 0x0B72 -#define GL_DEPTH_CLEAR_VALUE 0x0B73 -#define GL_DEPTH_FUNC 0x0B74 -#define GL_ACCUM_CLEAR_VALUE 0x0B80 -#define GL_STENCIL_TEST 0x0B90 -#define GL_STENCIL_CLEAR_VALUE 0x0B91 -#define GL_STENCIL_FUNC 0x0B92 -#define GL_STENCIL_VALUE_MASK 0x0B93 -#define GL_STENCIL_FAIL 0x0B94 -#define GL_STENCIL_PASS_DEPTH_FAIL 0x0B95 -#define GL_STENCIL_PASS_DEPTH_PASS 0x0B96 -#define GL_STENCIL_REF 0x0B97 -#define GL_STENCIL_WRITEMASK 0x0B98 -#define GL_MATRIX_MODE 0x0BA0 -#define GL_NORMALIZE 0x0BA1 -#define GL_VIEWPORT 0x0BA2 -#define GL_MODELVIEW_STACK_DEPTH 0x0BA3 -#define GL_PROJECTION_STACK_DEPTH 0x0BA4 -#define GL_TEXTURE_STACK_DEPTH 0x0BA5 -#define GL_MODELVIEW_MATRIX 0x0BA6 -#define GL_PROJECTION_MATRIX 0x0BA7 -#define GL_TEXTURE_MATRIX 0x0BA8 -#define GL_ATTRIB_STACK_DEPTH 0x0BB0 -#define GL_CLIENT_ATTRIB_STACK_DEPTH 0x0BB1 -#define GL_ALPHA_TEST 0x0BC0 -#define GL_ALPHA_TEST_FUNC 0x0BC1 -#define GL_ALPHA_TEST_REF 0x0BC2 -#define GL_DITHER 0x0BD0 -#define GL_BLEND_DST 0x0BE0 -#define GL_BLEND_SRC 0x0BE1 -#define GL_BLEND 0x0BE2 -#define GL_LOGIC_OP_MODE 0x0BF0 -#define GL_INDEX_LOGIC_OP 0x0BF1 -#define GL_COLOR_LOGIC_OP 0x0BF2 -#define GL_AUX_BUFFERS 0x0C00 -#define GL_DRAW_BUFFER 0x0C01 -#define GL_READ_BUFFER 0x0C02 -#define GL_SCISSOR_BOX 0x0C10 -#define GL_SCISSOR_TEST 0x0C11 -#define GL_INDEX_CLEAR_VALUE 0x0C20 -#define GL_INDEX_WRITEMASK 0x0C21 -#define GL_COLOR_CLEAR_VALUE 0x0C22 -#define GL_COLOR_WRITEMASK 0x0C23 -#define GL_INDEX_MODE 0x0C30 -#define GL_RGBA_MODE 0x0C31 -#define GL_DOUBLEBUFFER 0x0C32 -#define GL_STEREO 0x0C33 -#define GL_RENDER_MODE 0x0C40 -#define GL_PERSPECTIVE_CORRECTION_HINT 0x0C50 -#define GL_POINT_SMOOTH_HINT 0x0C51 -#define GL_LINE_SMOOTH_HINT 0x0C52 -#define GL_POLYGON_SMOOTH_HINT 0x0C53 -#define GL_FOG_HINT 0x0C54 -#define GL_TEXTURE_GEN_S 0x0C60 -#define GL_TEXTURE_GEN_T 0x0C61 -#define GL_TEXTURE_GEN_R 0x0C62 -#define GL_TEXTURE_GEN_Q 0x0C63 -#define GL_PIXEL_MAP_I_TO_I 0x0C70 -#define GL_PIXEL_MAP_S_TO_S 0x0C71 -#define GL_PIXEL_MAP_I_TO_R 0x0C72 -#define GL_PIXEL_MAP_I_TO_G 0x0C73 -#define GL_PIXEL_MAP_I_TO_B 0x0C74 -#define GL_PIXEL_MAP_I_TO_A 0x0C75 -#define GL_PIXEL_MAP_R_TO_R 0x0C76 -#define GL_PIXEL_MAP_G_TO_G 0x0C77 -#define GL_PIXEL_MAP_B_TO_B 0x0C78 -#define GL_PIXEL_MAP_A_TO_A 0x0C79 -#define GL_PIXEL_MAP_I_TO_I_SIZE 0x0CB0 -#define GL_PIXEL_MAP_S_TO_S_SIZE 0x0CB1 -#define GL_PIXEL_MAP_I_TO_R_SIZE 0x0CB2 -#define GL_PIXEL_MAP_I_TO_G_SIZE 0x0CB3 -#define GL_PIXEL_MAP_I_TO_B_SIZE 0x0CB4 -#define GL_PIXEL_MAP_I_TO_A_SIZE 0x0CB5 -#define GL_PIXEL_MAP_R_TO_R_SIZE 0x0CB6 -#define GL_PIXEL_MAP_G_TO_G_SIZE 0x0CB7 -#define GL_PIXEL_MAP_B_TO_B_SIZE 0x0CB8 -#define GL_PIXEL_MAP_A_TO_A_SIZE 0x0CB9 -#define GL_UNPACK_SWAP_BYTES 0x0CF0 -#define GL_UNPACK_LSB_FIRST 0x0CF1 -#define GL_UNPACK_ROW_LENGTH 0x0CF2 -#define GL_UNPACK_SKIP_ROWS 0x0CF3 -#define GL_UNPACK_SKIP_PIXELS 0x0CF4 -#define GL_UNPACK_ALIGNMENT 0x0CF5 -#define GL_PACK_SWAP_BYTES 0x0D00 -#define GL_PACK_LSB_FIRST 0x0D01 -#define GL_PACK_ROW_LENGTH 0x0D02 -#define GL_PACK_SKIP_ROWS 0x0D03 -#define GL_PACK_SKIP_PIXELS 0x0D04 -#define GL_PACK_ALIGNMENT 0x0D05 -#define GL_MAP_COLOR 0x0D10 -#define GL_MAP_STENCIL 0x0D11 -#define GL_INDEX_SHIFT 0x0D12 -#define GL_INDEX_OFFSET 0x0D13 -#define GL_RED_SCALE 0x0D14 -#define GL_RED_BIAS 0x0D15 -#define GL_ZOOM_X 0x0D16 -#define GL_ZOOM_Y 0x0D17 -#define GL_GREEN_SCALE 0x0D18 -#define GL_GREEN_BIAS 0x0D19 -#define GL_BLUE_SCALE 0x0D1A -#define GL_BLUE_BIAS 0x0D1B -#define GL_ALPHA_SCALE 0x0D1C -#define GL_ALPHA_BIAS 0x0D1D -#define GL_DEPTH_SCALE 0x0D1E -#define GL_DEPTH_BIAS 0x0D1F -#define GL_MAX_EVAL_ORDER 0x0D30 -#define GL_MAX_LIGHTS 0x0D31 -#define GL_MAX_CLIP_PLANES 0x0D32 -#define GL_MAX_TEXTURE_SIZE 0x0D33 -#define GL_MAX_PIXEL_MAP_TABLE 0x0D34 -#define GL_MAX_ATTRIB_STACK_DEPTH 0x0D35 -#define GL_MAX_MODELVIEW_STACK_DEPTH 0x0D36 -#define GL_MAX_NAME_STACK_DEPTH 0x0D37 -#define GL_MAX_PROJECTION_STACK_DEPTH 0x0D38 -#define GL_MAX_TEXTURE_STACK_DEPTH 0x0D39 -#define GL_MAX_VIEWPORT_DIMS 0x0D3A -#define GL_MAX_CLIENT_ATTRIB_STACK_DEPTH 0x0D3B -#define GL_SUBPIXEL_BITS 0x0D50 -#define GL_INDEX_BITS 0x0D51 -#define GL_RED_BITS 0x0D52 -#define GL_GREEN_BITS 0x0D53 -#define GL_BLUE_BITS 0x0D54 -#define GL_ALPHA_BITS 0x0D55 -#define GL_DEPTH_BITS 0x0D56 -#define GL_STENCIL_BITS 0x0D57 -#define GL_ACCUM_RED_BITS 0x0D58 -#define GL_ACCUM_GREEN_BITS 0x0D59 -#define GL_ACCUM_BLUE_BITS 0x0D5A -#define GL_ACCUM_ALPHA_BITS 0x0D5B -#define GL_NAME_STACK_DEPTH 0x0D70 -#define GL_AUTO_NORMAL 0x0D80 -#define GL_MAP1_COLOR_4 0x0D90 -#define GL_MAP1_INDEX 0x0D91 -#define GL_MAP1_NORMAL 0x0D92 -#define GL_MAP1_TEXTURE_COORD_1 0x0D93 -#define GL_MAP1_TEXTURE_COORD_2 0x0D94 -#define GL_MAP1_TEXTURE_COORD_3 0x0D95 -#define GL_MAP1_TEXTURE_COORD_4 0x0D96 -#define GL_MAP1_VERTEX_3 0x0D97 -#define GL_MAP1_VERTEX_4 0x0D98 -#define GL_MAP2_COLOR_4 0x0DB0 -#define GL_MAP2_INDEX 0x0DB1 -#define GL_MAP2_NORMAL 0x0DB2 -#define GL_MAP2_TEXTURE_COORD_1 0x0DB3 -#define GL_MAP2_TEXTURE_COORD_2 0x0DB4 -#define GL_MAP2_TEXTURE_COORD_3 0x0DB5 -#define GL_MAP2_TEXTURE_COORD_4 0x0DB6 -#define GL_MAP2_VERTEX_3 0x0DB7 -#define GL_MAP2_VERTEX_4 0x0DB8 -#define GL_MAP1_GRID_DOMAIN 0x0DD0 -#define GL_MAP1_GRID_SEGMENTS 0x0DD1 -#define GL_MAP2_GRID_DOMAIN 0x0DD2 -#define GL_MAP2_GRID_SEGMENTS 0x0DD3 -#define GL_TEXTURE_1D 0x0DE0 -#define GL_TEXTURE_2D 0x0DE1 -#define GL_FEEDBACK_BUFFER_POINTER 0x0DF0 -#define GL_FEEDBACK_BUFFER_SIZE 0x0DF1 -#define GL_FEEDBACK_BUFFER_TYPE 0x0DF2 -#define GL_SELECTION_BUFFER_POINTER 0x0DF3 -#define GL_SELECTION_BUFFER_SIZE 0x0DF4 -#define GL_TEXTURE_WIDTH 0x1000 -#define GL_TRANSFORM_BIT 0x00001000 -#define GL_TEXTURE_HEIGHT 0x1001 -#define GL_TEXTURE_INTERNAL_FORMAT 0x1003 -#define GL_TEXTURE_BORDER_COLOR 0x1004 -#define GL_TEXTURE_BORDER 0x1005 -#define GL_DONT_CARE 0x1100 -#define GL_FASTEST 0x1101 -#define GL_NICEST 0x1102 -#define GL_AMBIENT 0x1200 -#define GL_DIFFUSE 0x1201 -#define GL_SPECULAR 0x1202 -#define GL_POSITION 0x1203 -#define GL_SPOT_DIRECTION 0x1204 -#define GL_SPOT_EXPONENT 0x1205 -#define GL_SPOT_CUTOFF 0x1206 -#define GL_CONSTANT_ATTENUATION 0x1207 -#define GL_LINEAR_ATTENUATION 0x1208 -#define GL_QUADRATIC_ATTENUATION 0x1209 -#define GL_COMPILE 0x1300 -#define GL_COMPILE_AND_EXECUTE 0x1301 -#define GL_BYTE 0x1400 -#define GL_UNSIGNED_BYTE 0x1401 -#define GL_SHORT 0x1402 -#define GL_UNSIGNED_SHORT 0x1403 -#define GL_INT 0x1404 -#define GL_UNSIGNED_INT 0x1405 -#define GL_FLOAT 0x1406 -#define GL_2_BYTES 0x1407 -#define GL_3_BYTES 0x1408 -#define GL_4_BYTES 0x1409 -#define GL_DOUBLE 0x140A -#define GL_CLEAR 0x1500 -#define GL_AND 0x1501 -#define GL_AND_REVERSE 0x1502 -#define GL_COPY 0x1503 -#define GL_AND_INVERTED 0x1504 -#define GL_NOOP 0x1505 -#define GL_XOR 0x1506 -#define GL_OR 0x1507 -#define GL_NOR 0x1508 -#define GL_EQUIV 0x1509 -#define GL_INVERT 0x150A -#define GL_OR_REVERSE 0x150B -#define GL_COPY_INVERTED 0x150C -#define GL_OR_INVERTED 0x150D -#define GL_NAND 0x150E -#define GL_SET 0x150F -#define GL_EMISSION 0x1600 -#define GL_SHININESS 0x1601 -#define GL_AMBIENT_AND_DIFFUSE 0x1602 -#define GL_COLOR_INDEXES 0x1603 -#define GL_MODELVIEW 0x1700 -#define GL_PROJECTION 0x1701 -#define GL_TEXTURE 0x1702 -#define GL_COLOR 0x1800 -#define GL_DEPTH 0x1801 -#define GL_STENCIL 0x1802 -#define GL_COLOR_INDEX 0x1900 -#define GL_STENCIL_INDEX 0x1901 -#define GL_DEPTH_COMPONENT 0x1902 -#define GL_RED 0x1903 -#define GL_GREEN 0x1904 -#define GL_BLUE 0x1905 -#define GL_ALPHA 0x1906 -#define GL_RGB 0x1907 -#define GL_RGBA 0x1908 -#define GL_LUMINANCE 0x1909 -#define GL_LUMINANCE_ALPHA 0x190A -#define GL_BITMAP 0x1A00 -#define GL_POINT 0x1B00 -#define GL_LINE 0x1B01 -#define GL_FILL 0x1B02 -#define GL_RENDER 0x1C00 -#define GL_FEEDBACK 0x1C01 -#define GL_SELECT 0x1C02 -#define GL_FLAT 0x1D00 -#define GL_SMOOTH 0x1D01 -#define GL_KEEP 0x1E00 -#define GL_REPLACE 0x1E01 -#define GL_INCR 0x1E02 -#define GL_DECR 0x1E03 -#define GL_VENDOR 0x1F00 -#define GL_RENDERER 0x1F01 -#define GL_VERSION 0x1F02 -#define GL_EXTENSIONS 0x1F03 -#define GL_S 0x2000 -#define GL_ENABLE_BIT 0x00002000 -#define GL_T 0x2001 -#define GL_R 0x2002 -#define GL_Q 0x2003 -#define GL_MODULATE 0x2100 -#define GL_DECAL 0x2101 -#define GL_TEXTURE_ENV_MODE 0x2200 -#define GL_TEXTURE_ENV_COLOR 0x2201 -#define GL_TEXTURE_ENV 0x2300 -#define GL_EYE_LINEAR 0x2400 -#define GL_OBJECT_LINEAR 0x2401 -#define GL_SPHERE_MAP 0x2402 -#define GL_TEXTURE_GEN_MODE 0x2500 -#define GL_OBJECT_PLANE 0x2501 -#define GL_EYE_PLANE 0x2502 -#define GL_NEAREST 0x2600 -#define GL_LINEAR 0x2601 -#define GL_NEAREST_MIPMAP_NEAREST 0x2700 -#define GL_LINEAR_MIPMAP_NEAREST 0x2701 -#define GL_NEAREST_MIPMAP_LINEAR 0x2702 -#define GL_LINEAR_MIPMAP_LINEAR 0x2703 -#define GL_TEXTURE_MAG_FILTER 0x2800 -#define GL_TEXTURE_MIN_FILTER 0x2801 -#define GL_TEXTURE_WRAP_S 0x2802 -#define GL_TEXTURE_WRAP_T 0x2803 -#define GL_CLAMP 0x2900 -#define GL_REPEAT 0x2901 -#define GL_POLYGON_OFFSET_UNITS 0x2A00 -#define GL_POLYGON_OFFSET_POINT 0x2A01 -#define GL_POLYGON_OFFSET_LINE 0x2A02 -#define GL_R3_G3_B2 0x2A10 -#define GL_V2F 0x2A20 -#define GL_V3F 0x2A21 -#define GL_C4UB_V2F 0x2A22 -#define GL_C4UB_V3F 0x2A23 -#define GL_C3F_V3F 0x2A24 -#define GL_N3F_V3F 0x2A25 -#define GL_C4F_N3F_V3F 0x2A26 -#define GL_T2F_V3F 0x2A27 -#define GL_T4F_V4F 0x2A28 -#define GL_T2F_C4UB_V3F 0x2A29 -#define GL_T2F_C3F_V3F 0x2A2A -#define GL_T2F_N3F_V3F 0x2A2B -#define GL_T2F_C4F_N3F_V3F 0x2A2C -#define GL_T4F_C4F_N3F_V4F 0x2A2D -#define GL_CLIP_PLANE0 0x3000 -#define GL_CLIP_PLANE1 0x3001 -#define GL_CLIP_PLANE2 0x3002 -#define GL_CLIP_PLANE3 0x3003 -#define GL_CLIP_PLANE4 0x3004 -#define GL_CLIP_PLANE5 0x3005 -#define GL_LIGHT0 0x4000 -#define GL_COLOR_BUFFER_BIT 0x00004000 -#define GL_LIGHT1 0x4001 -#define GL_LIGHT2 0x4002 -#define GL_LIGHT3 0x4003 -#define GL_LIGHT4 0x4004 -#define GL_LIGHT5 0x4005 -#define GL_LIGHT6 0x4006 -#define GL_LIGHT7 0x4007 -#define GL_HINT_BIT 0x00008000 -#define GL_POLYGON_OFFSET_FILL 0x8037 -#define GL_POLYGON_OFFSET_FACTOR 0x8038 -#define GL_ALPHA4 0x803B -#define GL_ALPHA8 0x803C -#define GL_ALPHA12 0x803D -#define GL_ALPHA16 0x803E -#define GL_LUMINANCE4 0x803F -#define GL_LUMINANCE8 0x8040 -#define GL_LUMINANCE12 0x8041 -#define GL_LUMINANCE16 0x8042 -#define GL_LUMINANCE4_ALPHA4 0x8043 -#define GL_LUMINANCE6_ALPHA2 0x8044 -#define GL_LUMINANCE8_ALPHA8 0x8045 -#define GL_LUMINANCE12_ALPHA4 0x8046 -#define GL_LUMINANCE12_ALPHA12 0x8047 -#define GL_LUMINANCE16_ALPHA16 0x8048 -#define GL_INTENSITY 0x8049 -#define GL_INTENSITY4 0x804A -#define GL_INTENSITY8 0x804B -#define GL_INTENSITY12 0x804C -#define GL_INTENSITY16 0x804D -#define GL_RGB4 0x804F -#define GL_RGB5 0x8050 -#define GL_RGB8 0x8051 -#define GL_RGB10 0x8052 -#define GL_RGB12 0x8053 -#define GL_RGB16 0x8054 -#define GL_RGBA2 0x8055 -#define GL_RGBA4 0x8056 -#define GL_RGB5_A1 0x8057 -#define GL_RGBA8 0x8058 -#define GL_RGB10_A2 0x8059 -#define GL_RGBA12 0x805A -#define GL_RGBA16 0x805B -#define GL_TEXTURE_RED_SIZE 0x805C -#define GL_TEXTURE_GREEN_SIZE 0x805D -#define GL_TEXTURE_BLUE_SIZE 0x805E -#define GL_TEXTURE_ALPHA_SIZE 0x805F -#define GL_TEXTURE_LUMINANCE_SIZE 0x8060 -#define GL_TEXTURE_INTENSITY_SIZE 0x8061 -#define GL_PROXY_TEXTURE_1D 0x8063 -#define GL_PROXY_TEXTURE_2D 0x8064 -#define GL_TEXTURE_PRIORITY 0x8066 -#define GL_TEXTURE_RESIDENT 0x8067 -#define GL_TEXTURE_BINDING_1D 0x8068 -#define GL_TEXTURE_BINDING_2D 0x8069 -#define GL_VERTEX_ARRAY 0x8074 -#define GL_NORMAL_ARRAY 0x8075 -#define GL_COLOR_ARRAY 0x8076 -#define GL_INDEX_ARRAY 0x8077 -#define GL_TEXTURE_COORD_ARRAY 0x8078 -#define GL_EDGE_FLAG_ARRAY 0x8079 -#define GL_VERTEX_ARRAY_SIZE 0x807A -#define GL_VERTEX_ARRAY_TYPE 0x807B -#define GL_VERTEX_ARRAY_STRIDE 0x807C -#define GL_NORMAL_ARRAY_TYPE 0x807E -#define GL_NORMAL_ARRAY_STRIDE 0x807F -#define GL_COLOR_ARRAY_SIZE 0x8081 -#define GL_COLOR_ARRAY_TYPE 0x8082 -#define GL_COLOR_ARRAY_STRIDE 0x8083 -#define GL_INDEX_ARRAY_TYPE 0x8085 -#define GL_INDEX_ARRAY_STRIDE 0x8086 -#define GL_TEXTURE_COORD_ARRAY_SIZE 0x8088 -#define GL_TEXTURE_COORD_ARRAY_TYPE 0x8089 -#define GL_TEXTURE_COORD_ARRAY_STRIDE 0x808A -#define GL_EDGE_FLAG_ARRAY_STRIDE 0x808C -#define GL_VERTEX_ARRAY_POINTER 0x808E -#define GL_NORMAL_ARRAY_POINTER 0x808F -#define GL_COLOR_ARRAY_POINTER 0x8090 -#define GL_INDEX_ARRAY_POINTER 0x8091 -#define GL_TEXTURE_COORD_ARRAY_POINTER 0x8092 -#define GL_EDGE_FLAG_ARRAY_POINTER 0x8093 -#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_EVAL_BIT 0x00010000 -#define GL_LIST_BIT 0x00020000 -#define GL_TEXTURE_BIT 0x00040000 -#define GL_SCISSOR_BIT 0x00080000 -#define GL_ALL_ATTRIB_BITS 0x000fffff -#define GL_CLIENT_ALL_ATTRIB_BITS 0xffffffff - -GLAPI void GLAPIENTRY glAccum (GLenum op, GLfloat value); -GLAPI void GLAPIENTRY glAlphaFunc (GLenum func, GLclampf ref); -GLAPI GLboolean GLAPIENTRY glAreTexturesResident (GLsizei n, const GLuint *textures, GLboolean *residences); -GLAPI void GLAPIENTRY glArrayElement (GLint i); -GLAPI void GLAPIENTRY glBegin (GLenum mode); -GLAPI void GLAPIENTRY glBindTexture (GLenum target, GLuint texture); -GLAPI void GLAPIENTRY glBitmap (GLsizei width, GLsizei height, GLfloat xorig, GLfloat yorig, GLfloat xmove, GLfloat ymove, const GLubyte *bitmap); -GLAPI void GLAPIENTRY glBlendFunc (GLenum sfactor, GLenum dfactor); -GLAPI void GLAPIENTRY glCallList (GLuint list); -GLAPI void GLAPIENTRY glCallLists (GLsizei n, GLenum type, const void *lists); -GLAPI void GLAPIENTRY glClear (GLbitfield mask); -GLAPI void GLAPIENTRY glClearAccum (GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha); -GLAPI void GLAPIENTRY glClearColor (GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha); -GLAPI void GLAPIENTRY glClearDepth (GLclampd depth); -GLAPI void GLAPIENTRY glClearIndex (GLfloat c); -GLAPI void GLAPIENTRY glClearStencil (GLint s); -GLAPI void GLAPIENTRY glClipPlane (GLenum plane, const GLdouble *equation); -GLAPI void GLAPIENTRY glColor3b (GLbyte red, GLbyte green, GLbyte blue); -GLAPI void GLAPIENTRY glColor3bv (const GLbyte *v); -GLAPI void GLAPIENTRY glColor3d (GLdouble red, GLdouble green, GLdouble blue); -GLAPI void GLAPIENTRY glColor3dv (const GLdouble *v); -GLAPI void GLAPIENTRY glColor3f (GLfloat red, GLfloat green, GLfloat blue); -GLAPI void GLAPIENTRY glColor3fv (const GLfloat *v); -GLAPI void GLAPIENTRY glColor3i (GLint red, GLint green, GLint blue); -GLAPI void GLAPIENTRY glColor3iv (const GLint *v); -GLAPI void GLAPIENTRY glColor3s (GLshort red, GLshort green, GLshort blue); -GLAPI void GLAPIENTRY glColor3sv (const GLshort *v); -GLAPI void GLAPIENTRY glColor3ub (GLubyte red, GLubyte green, GLubyte blue); -GLAPI void GLAPIENTRY glColor3ubv (const GLubyte *v); -GLAPI void GLAPIENTRY glColor3ui (GLuint red, GLuint green, GLuint blue); -GLAPI void GLAPIENTRY glColor3uiv (const GLuint *v); -GLAPI void GLAPIENTRY glColor3us (GLushort red, GLushort green, GLushort blue); -GLAPI void GLAPIENTRY glColor3usv (const GLushort *v); -GLAPI void GLAPIENTRY glColor4b (GLbyte red, GLbyte green, GLbyte blue, GLbyte alpha); -GLAPI void GLAPIENTRY glColor4bv (const GLbyte *v); -GLAPI void GLAPIENTRY glColor4d (GLdouble red, GLdouble green, GLdouble blue, GLdouble alpha); -GLAPI void GLAPIENTRY glColor4dv (const GLdouble *v); -GLAPI void GLAPIENTRY glColor4f (GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha); -GLAPI void GLAPIENTRY glColor4fv (const GLfloat *v); -GLAPI void GLAPIENTRY glColor4i (GLint red, GLint green, GLint blue, GLint alpha); -GLAPI void GLAPIENTRY glColor4iv (const GLint *v); -GLAPI void GLAPIENTRY glColor4s (GLshort red, GLshort green, GLshort blue, GLshort alpha); -GLAPI void GLAPIENTRY glColor4sv (const GLshort *v); -GLAPI void GLAPIENTRY glColor4ub (GLubyte red, GLubyte green, GLubyte blue, GLubyte alpha); -GLAPI void GLAPIENTRY glColor4ubv (const GLubyte *v); -GLAPI void GLAPIENTRY glColor4ui (GLuint red, GLuint green, GLuint blue, GLuint alpha); -GLAPI void GLAPIENTRY glColor4uiv (const GLuint *v); -GLAPI void GLAPIENTRY glColor4us (GLushort red, GLushort green, GLushort blue, GLushort alpha); -GLAPI void GLAPIENTRY glColor4usv (const GLushort *v); -GLAPI void GLAPIENTRY glColorMask (GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha); -GLAPI void GLAPIENTRY glColorMaterial (GLenum face, GLenum mode); -GLAPI void GLAPIENTRY glColorPointer (GLint size, GLenum type, GLsizei stride, const void *pointer); -GLAPI void GLAPIENTRY glCopyPixels (GLint x, GLint y, GLsizei width, GLsizei height, GLenum type); -GLAPI void GLAPIENTRY glCopyTexImage1D (GLenum target, GLint level, GLenum internalFormat, GLint x, GLint y, GLsizei width, GLint border); -GLAPI void GLAPIENTRY glCopyTexImage2D (GLenum target, GLint level, GLenum internalFormat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border); -GLAPI void GLAPIENTRY glCopyTexSubImage1D (GLenum target, GLint level, GLint xoffset, GLint x, GLint y, GLsizei width); -GLAPI void GLAPIENTRY glCopyTexSubImage2D (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height); -GLAPI void GLAPIENTRY glCullFace (GLenum mode); -GLAPI void GLAPIENTRY glDeleteLists (GLuint list, GLsizei range); -GLAPI void GLAPIENTRY glDeleteTextures (GLsizei n, const GLuint *textures); -GLAPI void GLAPIENTRY glDepthFunc (GLenum func); -GLAPI void GLAPIENTRY glDepthMask (GLboolean flag); -GLAPI void GLAPIENTRY glDepthRange (GLclampd zNear, GLclampd zFar); -GLAPI void GLAPIENTRY glDisable (GLenum cap); -GLAPI void GLAPIENTRY glDisableClientState (GLenum array); -GLAPI void GLAPIENTRY glDrawArrays (GLenum mode, GLint first, GLsizei count); -GLAPI void GLAPIENTRY glDrawBuffer (GLenum mode); -GLAPI void GLAPIENTRY glDrawElements (GLenum mode, GLsizei count, GLenum type, const void *indices); -GLAPI void GLAPIENTRY glDrawPixels (GLsizei width, GLsizei height, GLenum format, GLenum type, const void *pixels); -GLAPI void GLAPIENTRY glEdgeFlag (GLboolean flag); -GLAPI void GLAPIENTRY glEdgeFlagPointer (GLsizei stride, const void *pointer); -GLAPI void GLAPIENTRY glEdgeFlagv (const GLboolean *flag); -GLAPI void GLAPIENTRY glEnable (GLenum cap); -GLAPI void GLAPIENTRY glEnableClientState (GLenum array); -GLAPI void GLAPIENTRY glEnd (void); -GLAPI void GLAPIENTRY glEndList (void); -GLAPI void GLAPIENTRY glEvalCoord1d (GLdouble u); -GLAPI void GLAPIENTRY glEvalCoord1dv (const GLdouble *u); -GLAPI void GLAPIENTRY glEvalCoord1f (GLfloat u); -GLAPI void GLAPIENTRY glEvalCoord1fv (const GLfloat *u); -GLAPI void GLAPIENTRY glEvalCoord2d (GLdouble u, GLdouble v); -GLAPI void GLAPIENTRY glEvalCoord2dv (const GLdouble *u); -GLAPI void GLAPIENTRY glEvalCoord2f (GLfloat u, GLfloat v); -GLAPI void GLAPIENTRY glEvalCoord2fv (const GLfloat *u); -GLAPI void GLAPIENTRY glEvalMesh1 (GLenum mode, GLint i1, GLint i2); -GLAPI void GLAPIENTRY glEvalMesh2 (GLenum mode, GLint i1, GLint i2, GLint j1, GLint j2); -GLAPI void GLAPIENTRY glEvalPoint1 (GLint i); -GLAPI void GLAPIENTRY glEvalPoint2 (GLint i, GLint j); -GLAPI void GLAPIENTRY glFeedbackBuffer (GLsizei size, GLenum type, GLfloat *buffer); -GLAPI void GLAPIENTRY glFinish (void); -GLAPI void GLAPIENTRY glFlush (void); -GLAPI void GLAPIENTRY glFogf (GLenum pname, GLfloat param); -GLAPI void GLAPIENTRY glFogfv (GLenum pname, const GLfloat *params); -GLAPI void GLAPIENTRY glFogi (GLenum pname, GLint param); -GLAPI void GLAPIENTRY glFogiv (GLenum pname, const GLint *params); -GLAPI void GLAPIENTRY glFrontFace (GLenum mode); -GLAPI void GLAPIENTRY glFrustum (GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble zNear, GLdouble zFar); -GLAPI GLuint GLAPIENTRY glGenLists (GLsizei range); -GLAPI void GLAPIENTRY glGenTextures (GLsizei n, GLuint *textures); -GLAPI void GLAPIENTRY glGetBooleanv (GLenum pname, GLboolean *params); -GLAPI void GLAPIENTRY glGetClipPlane (GLenum plane, GLdouble *equation); -GLAPI void GLAPIENTRY glGetDoublev (GLenum pname, GLdouble *params); -GLAPI GLenum GLAPIENTRY glGetError (void); -GLAPI void GLAPIENTRY glGetFloatv (GLenum pname, GLfloat *params); -GLAPI void GLAPIENTRY glGetIntegerv (GLenum pname, GLint *params); -GLAPI void GLAPIENTRY glGetLightfv (GLenum light, GLenum pname, GLfloat *params); -GLAPI void GLAPIENTRY glGetLightiv (GLenum light, GLenum pname, GLint *params); -GLAPI void GLAPIENTRY glGetMapdv (GLenum target, GLenum query, GLdouble *v); -GLAPI void GLAPIENTRY glGetMapfv (GLenum target, GLenum query, GLfloat *v); -GLAPI void GLAPIENTRY glGetMapiv (GLenum target, GLenum query, GLint *v); -GLAPI void GLAPIENTRY glGetMaterialfv (GLenum face, GLenum pname, GLfloat *params); -GLAPI void GLAPIENTRY glGetMaterialiv (GLenum face, GLenum pname, GLint *params); -GLAPI void GLAPIENTRY glGetPixelMapfv (GLenum map, GLfloat *values); -GLAPI void GLAPIENTRY glGetPixelMapuiv (GLenum map, GLuint *values); -GLAPI void GLAPIENTRY glGetPixelMapusv (GLenum map, GLushort *values); -GLAPI void GLAPIENTRY glGetPointerv (GLenum pname, void* *params); -GLAPI void GLAPIENTRY glGetPolygonStipple (GLubyte *mask); -GLAPI const GLubyte * GLAPIENTRY glGetString (GLenum name); -GLAPI void GLAPIENTRY glGetTexEnvfv (GLenum target, GLenum pname, GLfloat *params); -GLAPI void GLAPIENTRY glGetTexEnviv (GLenum target, GLenum pname, GLint *params); -GLAPI void GLAPIENTRY glGetTexGendv (GLenum coord, GLenum pname, GLdouble *params); -GLAPI void GLAPIENTRY glGetTexGenfv (GLenum coord, GLenum pname, GLfloat *params); -GLAPI void GLAPIENTRY glGetTexGeniv (GLenum coord, GLenum pname, GLint *params); -GLAPI void GLAPIENTRY glGetTexImage (GLenum target, GLint level, GLenum format, GLenum type, void *pixels); -GLAPI void GLAPIENTRY glGetTexLevelParameterfv (GLenum target, GLint level, GLenum pname, GLfloat *params); -GLAPI void GLAPIENTRY glGetTexLevelParameteriv (GLenum target, GLint level, GLenum pname, GLint *params); -GLAPI void GLAPIENTRY glGetTexParameterfv (GLenum target, GLenum pname, GLfloat *params); -GLAPI void GLAPIENTRY glGetTexParameteriv (GLenum target, GLenum pname, GLint *params); -GLAPI void GLAPIENTRY glHint (GLenum target, GLenum mode); -GLAPI void GLAPIENTRY glIndexMask (GLuint mask); -GLAPI void GLAPIENTRY glIndexPointer (GLenum type, GLsizei stride, const void *pointer); -GLAPI void GLAPIENTRY glIndexd (GLdouble c); -GLAPI void GLAPIENTRY glIndexdv (const GLdouble *c); -GLAPI void GLAPIENTRY glIndexf (GLfloat c); -GLAPI void GLAPIENTRY glIndexfv (const GLfloat *c); -GLAPI void GLAPIENTRY glIndexi (GLint c); -GLAPI void GLAPIENTRY glIndexiv (const GLint *c); -GLAPI void GLAPIENTRY glIndexs (GLshort c); -GLAPI void GLAPIENTRY glIndexsv (const GLshort *c); -GLAPI void GLAPIENTRY glIndexub (GLubyte c); -GLAPI void GLAPIENTRY glIndexubv (const GLubyte *c); -GLAPI void GLAPIENTRY glInitNames (void); -GLAPI void GLAPIENTRY glInterleavedArrays (GLenum format, GLsizei stride, const void *pointer); -GLAPI GLboolean GLAPIENTRY glIsEnabled (GLenum cap); -GLAPI GLboolean GLAPIENTRY glIsList (GLuint list); -GLAPI GLboolean GLAPIENTRY glIsTexture (GLuint texture); -GLAPI void GLAPIENTRY glLightModelf (GLenum pname, GLfloat param); -GLAPI void GLAPIENTRY glLightModelfv (GLenum pname, const GLfloat *params); -GLAPI void GLAPIENTRY glLightModeli (GLenum pname, GLint param); -GLAPI void GLAPIENTRY glLightModeliv (GLenum pname, const GLint *params); -GLAPI void GLAPIENTRY glLightf (GLenum light, GLenum pname, GLfloat param); -GLAPI void GLAPIENTRY glLightfv (GLenum light, GLenum pname, const GLfloat *params); -GLAPI void GLAPIENTRY glLighti (GLenum light, GLenum pname, GLint param); -GLAPI void GLAPIENTRY glLightiv (GLenum light, GLenum pname, const GLint *params); -GLAPI void GLAPIENTRY glLineStipple (GLint factor, GLushort pattern); -GLAPI void GLAPIENTRY glLineWidth (GLfloat width); -GLAPI void GLAPIENTRY glListBase (GLuint base); -GLAPI void GLAPIENTRY glLoadIdentity (void); -GLAPI void GLAPIENTRY glLoadMatrixd (const GLdouble *m); -GLAPI void GLAPIENTRY glLoadMatrixf (const GLfloat *m); -GLAPI void GLAPIENTRY glLoadName (GLuint name); -GLAPI void GLAPIENTRY glLogicOp (GLenum opcode); -GLAPI void GLAPIENTRY glMap1d (GLenum target, GLdouble u1, GLdouble u2, GLint stride, GLint order, const GLdouble *points); -GLAPI void GLAPIENTRY glMap1f (GLenum target, GLfloat u1, GLfloat u2, GLint stride, GLint order, const GLfloat *points); -GLAPI void GLAPIENTRY glMap2d (GLenum target, GLdouble u1, GLdouble u2, GLint ustride, GLint uorder, GLdouble v1, GLdouble v2, GLint vstride, GLint vorder, const GLdouble *points); -GLAPI void GLAPIENTRY glMap2f (GLenum target, GLfloat u1, GLfloat u2, GLint ustride, GLint uorder, GLfloat v1, GLfloat v2, GLint vstride, GLint vorder, const GLfloat *points); -GLAPI void GLAPIENTRY glMapGrid1d (GLint un, GLdouble u1, GLdouble u2); -GLAPI void GLAPIENTRY glMapGrid1f (GLint un, GLfloat u1, GLfloat u2); -GLAPI void GLAPIENTRY glMapGrid2d (GLint un, GLdouble u1, GLdouble u2, GLint vn, GLdouble v1, GLdouble v2); -GLAPI void GLAPIENTRY glMapGrid2f (GLint un, GLfloat u1, GLfloat u2, GLint vn, GLfloat v1, GLfloat v2); -GLAPI void GLAPIENTRY glMaterialf (GLenum face, GLenum pname, GLfloat param); -GLAPI void GLAPIENTRY glMaterialfv (GLenum face, GLenum pname, const GLfloat *params); -GLAPI void GLAPIENTRY glMateriali (GLenum face, GLenum pname, GLint param); -GLAPI void GLAPIENTRY glMaterialiv (GLenum face, GLenum pname, const GLint *params); -GLAPI void GLAPIENTRY glMatrixMode (GLenum mode); -GLAPI void GLAPIENTRY glMultMatrixd (const GLdouble *m); -GLAPI void GLAPIENTRY glMultMatrixf (const GLfloat *m); -GLAPI void GLAPIENTRY glNewList (GLuint list, GLenum mode); -GLAPI void GLAPIENTRY glNormal3b (GLbyte nx, GLbyte ny, GLbyte nz); -GLAPI void GLAPIENTRY glNormal3bv (const GLbyte *v); -GLAPI void GLAPIENTRY glNormal3d (GLdouble nx, GLdouble ny, GLdouble nz); -GLAPI void GLAPIENTRY glNormal3dv (const GLdouble *v); -GLAPI void GLAPIENTRY glNormal3f (GLfloat nx, GLfloat ny, GLfloat nz); -GLAPI void GLAPIENTRY glNormal3fv (const GLfloat *v); -GLAPI void GLAPIENTRY glNormal3i (GLint nx, GLint ny, GLint nz); -GLAPI void GLAPIENTRY glNormal3iv (const GLint *v); -GLAPI void GLAPIENTRY glNormal3s (GLshort nx, GLshort ny, GLshort nz); -GLAPI void GLAPIENTRY glNormal3sv (const GLshort *v); -GLAPI void GLAPIENTRY glNormalPointer (GLenum type, GLsizei stride, const void *pointer); -GLAPI void GLAPIENTRY glOrtho (GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble zNear, GLdouble zFar); -GLAPI void GLAPIENTRY glPassThrough (GLfloat token); -GLAPI void GLAPIENTRY glPixelMapfv (GLenum map, GLsizei mapsize, const GLfloat *values); -GLAPI void GLAPIENTRY glPixelMapuiv (GLenum map, GLsizei mapsize, const GLuint *values); -GLAPI void GLAPIENTRY glPixelMapusv (GLenum map, GLsizei mapsize, const GLushort *values); -GLAPI void GLAPIENTRY glPixelStoref (GLenum pname, GLfloat param); -GLAPI void GLAPIENTRY glPixelStorei (GLenum pname, GLint param); -GLAPI void GLAPIENTRY glPixelTransferf (GLenum pname, GLfloat param); -GLAPI void GLAPIENTRY glPixelTransferi (GLenum pname, GLint param); -GLAPI void GLAPIENTRY glPixelZoom (GLfloat xfactor, GLfloat yfactor); -GLAPI void GLAPIENTRY glPointSize (GLfloat size); -GLAPI void GLAPIENTRY glPolygonMode (GLenum face, GLenum mode); -GLAPI void GLAPIENTRY glPolygonOffset (GLfloat factor, GLfloat units); -GLAPI void GLAPIENTRY glPolygonStipple (const GLubyte *mask); -GLAPI void GLAPIENTRY glPopAttrib (void); -GLAPI void GLAPIENTRY glPopClientAttrib (void); -GLAPI void GLAPIENTRY glPopMatrix (void); -GLAPI void GLAPIENTRY glPopName (void); -GLAPI void GLAPIENTRY glPrioritizeTextures (GLsizei n, const GLuint *textures, const GLclampf *priorities); -GLAPI void GLAPIENTRY glPushAttrib (GLbitfield mask); -GLAPI void GLAPIENTRY glPushClientAttrib (GLbitfield mask); -GLAPI void GLAPIENTRY glPushMatrix (void); -GLAPI void GLAPIENTRY glPushName (GLuint name); -GLAPI void GLAPIENTRY glRasterPos2d (GLdouble x, GLdouble y); -GLAPI void GLAPIENTRY glRasterPos2dv (const GLdouble *v); -GLAPI void GLAPIENTRY glRasterPos2f (GLfloat x, GLfloat y); -GLAPI void GLAPIENTRY glRasterPos2fv (const GLfloat *v); -GLAPI void GLAPIENTRY glRasterPos2i (GLint x, GLint y); -GLAPI void GLAPIENTRY glRasterPos2iv (const GLint *v); -GLAPI void GLAPIENTRY glRasterPos2s (GLshort x, GLshort y); -GLAPI void GLAPIENTRY glRasterPos2sv (const GLshort *v); -GLAPI void GLAPIENTRY glRasterPos3d (GLdouble x, GLdouble y, GLdouble z); -GLAPI void GLAPIENTRY glRasterPos3dv (const GLdouble *v); -GLAPI void GLAPIENTRY glRasterPos3f (GLfloat x, GLfloat y, GLfloat z); -GLAPI void GLAPIENTRY glRasterPos3fv (const GLfloat *v); -GLAPI void GLAPIENTRY glRasterPos3i (GLint x, GLint y, GLint z); -GLAPI void GLAPIENTRY glRasterPos3iv (const GLint *v); -GLAPI void GLAPIENTRY glRasterPos3s (GLshort x, GLshort y, GLshort z); -GLAPI void GLAPIENTRY glRasterPos3sv (const GLshort *v); -GLAPI void GLAPIENTRY glRasterPos4d (GLdouble x, GLdouble y, GLdouble z, GLdouble w); -GLAPI void GLAPIENTRY glRasterPos4dv (const GLdouble *v); -GLAPI void GLAPIENTRY glRasterPos4f (GLfloat x, GLfloat y, GLfloat z, GLfloat w); -GLAPI void GLAPIENTRY glRasterPos4fv (const GLfloat *v); -GLAPI void GLAPIENTRY glRasterPos4i (GLint x, GLint y, GLint z, GLint w); -GLAPI void GLAPIENTRY glRasterPos4iv (const GLint *v); -GLAPI void GLAPIENTRY glRasterPos4s (GLshort x, GLshort y, GLshort z, GLshort w); -GLAPI void GLAPIENTRY glRasterPos4sv (const GLshort *v); -GLAPI void GLAPIENTRY glReadBuffer (GLenum mode); -GLAPI void GLAPIENTRY glReadPixels (GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, void *pixels); -GLAPI void GLAPIENTRY glRectd (GLdouble x1, GLdouble y1, GLdouble x2, GLdouble y2); -GLAPI void GLAPIENTRY glRectdv (const GLdouble *v1, const GLdouble *v2); -GLAPI void GLAPIENTRY glRectf (GLfloat x1, GLfloat y1, GLfloat x2, GLfloat y2); -GLAPI void GLAPIENTRY glRectfv (const GLfloat *v1, const GLfloat *v2); -GLAPI void GLAPIENTRY glRecti (GLint x1, GLint y1, GLint x2, GLint y2); -GLAPI void GLAPIENTRY glRectiv (const GLint *v1, const GLint *v2); -GLAPI void GLAPIENTRY glRects (GLshort x1, GLshort y1, GLshort x2, GLshort y2); -GLAPI void GLAPIENTRY glRectsv (const GLshort *v1, const GLshort *v2); -GLAPI GLint GLAPIENTRY glRenderMode (GLenum mode); -GLAPI void GLAPIENTRY glRotated (GLdouble angle, GLdouble x, GLdouble y, GLdouble z); -GLAPI void GLAPIENTRY glRotatef (GLfloat angle, GLfloat x, GLfloat y, GLfloat z); -GLAPI void GLAPIENTRY glScaled (GLdouble x, GLdouble y, GLdouble z); -GLAPI void GLAPIENTRY glScalef (GLfloat x, GLfloat y, GLfloat z); -GLAPI void GLAPIENTRY glScissor (GLint x, GLint y, GLsizei width, GLsizei height); -GLAPI void GLAPIENTRY glSelectBuffer (GLsizei size, GLuint *buffer); -GLAPI void GLAPIENTRY glShadeModel (GLenum mode); -GLAPI void GLAPIENTRY glStencilFunc (GLenum func, GLint ref, GLuint mask); -GLAPI void GLAPIENTRY glStencilMask (GLuint mask); -GLAPI void GLAPIENTRY glStencilOp (GLenum fail, GLenum zfail, GLenum zpass); -GLAPI void GLAPIENTRY glTexCoord1d (GLdouble s); -GLAPI void GLAPIENTRY glTexCoord1dv (const GLdouble *v); -GLAPI void GLAPIENTRY glTexCoord1f (GLfloat s); -GLAPI void GLAPIENTRY glTexCoord1fv (const GLfloat *v); -GLAPI void GLAPIENTRY glTexCoord1i (GLint s); -GLAPI void GLAPIENTRY glTexCoord1iv (const GLint *v); -GLAPI void GLAPIENTRY glTexCoord1s (GLshort s); -GLAPI void GLAPIENTRY glTexCoord1sv (const GLshort *v); -GLAPI void GLAPIENTRY glTexCoord2d (GLdouble s, GLdouble t); -GLAPI void GLAPIENTRY glTexCoord2dv (const GLdouble *v); -GLAPI void GLAPIENTRY glTexCoord2f (GLfloat s, GLfloat t); -GLAPI void GLAPIENTRY glTexCoord2fv (const GLfloat *v); -GLAPI void GLAPIENTRY glTexCoord2i (GLint s, GLint t); -GLAPI void GLAPIENTRY glTexCoord2iv (const GLint *v); -GLAPI void GLAPIENTRY glTexCoord2s (GLshort s, GLshort t); -GLAPI void GLAPIENTRY glTexCoord2sv (const GLshort *v); -GLAPI void GLAPIENTRY glTexCoord3d (GLdouble s, GLdouble t, GLdouble r); -GLAPI void GLAPIENTRY glTexCoord3dv (const GLdouble *v); -GLAPI void GLAPIENTRY glTexCoord3f (GLfloat s, GLfloat t, GLfloat r); -GLAPI void GLAPIENTRY glTexCoord3fv (const GLfloat *v); -GLAPI void GLAPIENTRY glTexCoord3i (GLint s, GLint t, GLint r); -GLAPI void GLAPIENTRY glTexCoord3iv (const GLint *v); -GLAPI void GLAPIENTRY glTexCoord3s (GLshort s, GLshort t, GLshort r); -GLAPI void GLAPIENTRY glTexCoord3sv (const GLshort *v); -GLAPI void GLAPIENTRY glTexCoord4d (GLdouble s, GLdouble t, GLdouble r, GLdouble q); -GLAPI void GLAPIENTRY glTexCoord4dv (const GLdouble *v); -GLAPI void GLAPIENTRY glTexCoord4f (GLfloat s, GLfloat t, GLfloat r, GLfloat q); -GLAPI void GLAPIENTRY glTexCoord4fv (const GLfloat *v); -GLAPI void GLAPIENTRY glTexCoord4i (GLint s, GLint t, GLint r, GLint q); -GLAPI void GLAPIENTRY glTexCoord4iv (const GLint *v); -GLAPI void GLAPIENTRY glTexCoord4s (GLshort s, GLshort t, GLshort r, GLshort q); -GLAPI void GLAPIENTRY glTexCoord4sv (const GLshort *v); -GLAPI void GLAPIENTRY glTexCoordPointer (GLint size, GLenum type, GLsizei stride, const void *pointer); -GLAPI void GLAPIENTRY glTexEnvf (GLenum target, GLenum pname, GLfloat param); -GLAPI void GLAPIENTRY glTexEnvfv (GLenum target, GLenum pname, const GLfloat *params); -GLAPI void GLAPIENTRY glTexEnvi (GLenum target, GLenum pname, GLint param); -GLAPI void GLAPIENTRY glTexEnviv (GLenum target, GLenum pname, const GLint *params); -GLAPI void GLAPIENTRY glTexGend (GLenum coord, GLenum pname, GLdouble param); -GLAPI void GLAPIENTRY glTexGendv (GLenum coord, GLenum pname, const GLdouble *params); -GLAPI void GLAPIENTRY glTexGenf (GLenum coord, GLenum pname, GLfloat param); -GLAPI void GLAPIENTRY glTexGenfv (GLenum coord, GLenum pname, const GLfloat *params); -GLAPI void GLAPIENTRY glTexGeni (GLenum coord, GLenum pname, GLint param); -GLAPI void GLAPIENTRY glTexGeniv (GLenum coord, GLenum pname, const GLint *params); -GLAPI void GLAPIENTRY glTexImage1D (GLenum target, GLint level, GLint internalformat, GLsizei width, GLint border, GLenum format, GLenum type, const void *pixels); -GLAPI void GLAPIENTRY glTexImage2D (GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const void *pixels); -GLAPI void GLAPIENTRY glTexParameterf (GLenum target, GLenum pname, GLfloat param); -GLAPI void GLAPIENTRY glTexParameterfv (GLenum target, GLenum pname, const GLfloat *params); -GLAPI void GLAPIENTRY glTexParameteri (GLenum target, GLenum pname, GLint param); -GLAPI void GLAPIENTRY glTexParameteriv (GLenum target, GLenum pname, const GLint *params); -GLAPI void GLAPIENTRY glTexSubImage1D (GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLenum type, const void *pixels); -GLAPI void GLAPIENTRY glTexSubImage2D (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const void *pixels); -GLAPI void GLAPIENTRY glTranslated (GLdouble x, GLdouble y, GLdouble z); -GLAPI void GLAPIENTRY glTranslatef (GLfloat x, GLfloat y, GLfloat z); -GLAPI void GLAPIENTRY glVertex2d (GLdouble x, GLdouble y); -GLAPI void GLAPIENTRY glVertex2dv (const GLdouble *v); -GLAPI void GLAPIENTRY glVertex2f (GLfloat x, GLfloat y); -GLAPI void GLAPIENTRY glVertex2fv (const GLfloat *v); -GLAPI void GLAPIENTRY glVertex2i (GLint x, GLint y); -GLAPI void GLAPIENTRY glVertex2iv (const GLint *v); -GLAPI void GLAPIENTRY glVertex2s (GLshort x, GLshort y); -GLAPI void GLAPIENTRY glVertex2sv (const GLshort *v); -GLAPI void GLAPIENTRY glVertex3d (GLdouble x, GLdouble y, GLdouble z); -GLAPI void GLAPIENTRY glVertex3dv (const GLdouble *v); -GLAPI void GLAPIENTRY glVertex3f (GLfloat x, GLfloat y, GLfloat z); -GLAPI void GLAPIENTRY glVertex3fv (const GLfloat *v); -GLAPI void GLAPIENTRY glVertex3i (GLint x, GLint y, GLint z); -GLAPI void GLAPIENTRY glVertex3iv (const GLint *v); -GLAPI void GLAPIENTRY glVertex3s (GLshort x, GLshort y, GLshort z); -GLAPI void GLAPIENTRY glVertex3sv (const GLshort *v); -GLAPI void GLAPIENTRY glVertex4d (GLdouble x, GLdouble y, GLdouble z, GLdouble w); -GLAPI void GLAPIENTRY glVertex4dv (const GLdouble *v); -GLAPI void GLAPIENTRY glVertex4f (GLfloat x, GLfloat y, GLfloat z, GLfloat w); -GLAPI void GLAPIENTRY glVertex4fv (const GLfloat *v); -GLAPI void GLAPIENTRY glVertex4i (GLint x, GLint y, GLint z, GLint w); -GLAPI void GLAPIENTRY glVertex4iv (const GLint *v); -GLAPI void GLAPIENTRY glVertex4s (GLshort x, GLshort y, GLshort z, GLshort w); -GLAPI void GLAPIENTRY glVertex4sv (const GLshort *v); -GLAPI void GLAPIENTRY glVertexPointer (GLint size, GLenum type, GLsizei stride, const void *pointer); -GLAPI void GLAPIENTRY glViewport (GLint x, GLint y, GLsizei width, GLsizei height); - -#define GLEW_VERSION_1_1 GLEW_GET_VAR(__GLEW_VERSION_1_1) - -#endif /* GL_VERSION_1_1 */ - -/* ---------------------------------- GLU ---------------------------------- */ - -#ifndef GLEW_NO_GLU -# ifdef __APPLE__ -# include -# if defined(__IPHONE_OS_VERSION_MIN_REQUIRED) -# define GLEW_NO_GLU -# endif -# endif -#endif - -#ifndef GLEW_NO_GLU -/* this is where we can safely include GLU */ -# if defined(__APPLE__) && defined(__MACH__) -# include -# else -# include -# endif -#endif - -/* ----------------------------- GL_VERSION_1_2 ---------------------------- */ - -#ifndef GL_VERSION_1_2 -#define GL_VERSION_1_2 1 - -#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_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_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_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_ALIASED_POINT_SIZE_RANGE 0x846D -#define GL_ALIASED_LINE_WIDTH_RANGE 0x846E - -typedef void (GLAPIENTRY * PFNGLCOPYTEXSUBIMAGE3DPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height); -typedef void (GLAPIENTRY * PFNGLDRAWRANGEELEMENTSPROC) (GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const void *indices); -typedef void (GLAPIENTRY * PFNGLTEXIMAGE3DPROC) (GLenum target, GLint level, GLint internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const void *pixels); -typedef void (GLAPIENTRY * PFNGLTEXSUBIMAGE3DPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const void *pixels); - -#define glCopyTexSubImage3D GLEW_GET_FUN(__glewCopyTexSubImage3D) -#define glDrawRangeElements GLEW_GET_FUN(__glewDrawRangeElements) -#define glTexImage3D GLEW_GET_FUN(__glewTexImage3D) -#define glTexSubImage3D GLEW_GET_FUN(__glewTexSubImage3D) - -#define GLEW_VERSION_1_2 GLEW_GET_VAR(__GLEW_VERSION_1_2) - -#endif /* GL_VERSION_1_2 */ - -/* ---------------------------- GL_VERSION_1_2_1 --------------------------- */ - -#ifndef GL_VERSION_1_2_1 -#define GL_VERSION_1_2_1 1 - -#define GLEW_VERSION_1_2_1 GLEW_GET_VAR(__GLEW_VERSION_1_2_1) - -#endif /* GL_VERSION_1_2_1 */ - -/* ----------------------------- GL_VERSION_1_3 ---------------------------- */ - -#ifndef GL_VERSION_1_3 -#define GL_VERSION_1_3 1 - -#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_CLAMP_TO_BORDER 0x812D -#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_SUBTRACT 0x84E7 -#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_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_COMBINE 0x8570 -#define GL_COMBINE_RGB 0x8571 -#define GL_COMBINE_ALPHA 0x8572 -#define GL_RGB_SCALE 0x8573 -#define GL_ADD_SIGNED 0x8574 -#define GL_INTERPOLATE 0x8575 -#define GL_CONSTANT 0x8576 -#define GL_PRIMARY_COLOR 0x8577 -#define GL_PREVIOUS 0x8578 -#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_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_DOT3_RGB 0x86AE -#define GL_DOT3_RGBA 0x86AF -#define GL_MULTISAMPLE_BIT 0x20000000 - -typedef void (GLAPIENTRY * PFNGLACTIVETEXTUREPROC) (GLenum texture); -typedef void (GLAPIENTRY * PFNGLCLIENTACTIVETEXTUREPROC) (GLenum texture); -typedef void (GLAPIENTRY * PFNGLCOMPRESSEDTEXIMAGE1DPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLsizei imageSize, const void *data); -typedef void (GLAPIENTRY * PFNGLCOMPRESSEDTEXIMAGE2DPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const void *data); -typedef void (GLAPIENTRY * PFNGLCOMPRESSEDTEXIMAGE3DPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const void *data); -typedef void (GLAPIENTRY * PFNGLCOMPRESSEDTEXSUBIMAGE1DPROC) (GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLsizei imageSize, const void *data); -typedef void (GLAPIENTRY * PFNGLCOMPRESSEDTEXSUBIMAGE2DPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const void *data); -typedef void (GLAPIENTRY * PFNGLCOMPRESSEDTEXSUBIMAGE3DPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const void *data); -typedef void (GLAPIENTRY * PFNGLGETCOMPRESSEDTEXIMAGEPROC) (GLenum target, GLint lod, void *img); -typedef void (GLAPIENTRY * PFNGLLOADTRANSPOSEMATRIXDPROC) (const GLdouble m[16]); -typedef void (GLAPIENTRY * PFNGLLOADTRANSPOSEMATRIXFPROC) (const GLfloat m[16]); -typedef void (GLAPIENTRY * PFNGLMULTTRANSPOSEMATRIXDPROC) (const GLdouble m[16]); -typedef void (GLAPIENTRY * PFNGLMULTTRANSPOSEMATRIXFPROC) (const GLfloat m[16]); -typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD1DPROC) (GLenum target, GLdouble s); -typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD1DVPROC) (GLenum target, const GLdouble *v); -typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD1FPROC) (GLenum target, GLfloat s); -typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD1FVPROC) (GLenum target, const GLfloat *v); -typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD1IPROC) (GLenum target, GLint s); -typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD1IVPROC) (GLenum target, const GLint *v); -typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD1SPROC) (GLenum target, GLshort s); -typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD1SVPROC) (GLenum target, const GLshort *v); -typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD2DPROC) (GLenum target, GLdouble s, GLdouble t); -typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD2DVPROC) (GLenum target, const GLdouble *v); -typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD2FPROC) (GLenum target, GLfloat s, GLfloat t); -typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD2FVPROC) (GLenum target, const GLfloat *v); -typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD2IPROC) (GLenum target, GLint s, GLint t); -typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD2IVPROC) (GLenum target, const GLint *v); -typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD2SPROC) (GLenum target, GLshort s, GLshort t); -typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD2SVPROC) (GLenum target, const GLshort *v); -typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD3DPROC) (GLenum target, GLdouble s, GLdouble t, GLdouble r); -typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD3DVPROC) (GLenum target, const GLdouble *v); -typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD3FPROC) (GLenum target, GLfloat s, GLfloat t, GLfloat r); -typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD3FVPROC) (GLenum target, const GLfloat *v); -typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD3IPROC) (GLenum target, GLint s, GLint t, GLint r); -typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD3IVPROC) (GLenum target, const GLint *v); -typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD3SPROC) (GLenum target, GLshort s, GLshort t, GLshort r); -typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD3SVPROC) (GLenum target, const GLshort *v); -typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD4DPROC) (GLenum target, GLdouble s, GLdouble t, GLdouble r, GLdouble q); -typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD4DVPROC) (GLenum target, const GLdouble *v); -typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD4FPROC) (GLenum target, GLfloat s, GLfloat t, GLfloat r, GLfloat q); -typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD4FVPROC) (GLenum target, const GLfloat *v); -typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD4IPROC) (GLenum target, GLint s, GLint t, GLint r, GLint q); -typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD4IVPROC) (GLenum target, const GLint *v); -typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD4SPROC) (GLenum target, GLshort s, GLshort t, GLshort r, GLshort q); -typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD4SVPROC) (GLenum target, const GLshort *v); -typedef void (GLAPIENTRY * PFNGLSAMPLECOVERAGEPROC) (GLclampf value, GLboolean invert); - -#define glActiveTexture GLEW_GET_FUN(__glewActiveTexture) -#define glClientActiveTexture GLEW_GET_FUN(__glewClientActiveTexture) -#define glCompressedTexImage1D GLEW_GET_FUN(__glewCompressedTexImage1D) -#define glCompressedTexImage2D GLEW_GET_FUN(__glewCompressedTexImage2D) -#define glCompressedTexImage3D GLEW_GET_FUN(__glewCompressedTexImage3D) -#define glCompressedTexSubImage1D GLEW_GET_FUN(__glewCompressedTexSubImage1D) -#define glCompressedTexSubImage2D GLEW_GET_FUN(__glewCompressedTexSubImage2D) -#define glCompressedTexSubImage3D GLEW_GET_FUN(__glewCompressedTexSubImage3D) -#define glGetCompressedTexImage GLEW_GET_FUN(__glewGetCompressedTexImage) -#define glLoadTransposeMatrixd GLEW_GET_FUN(__glewLoadTransposeMatrixd) -#define glLoadTransposeMatrixf GLEW_GET_FUN(__glewLoadTransposeMatrixf) -#define glMultTransposeMatrixd GLEW_GET_FUN(__glewMultTransposeMatrixd) -#define glMultTransposeMatrixf GLEW_GET_FUN(__glewMultTransposeMatrixf) -#define glMultiTexCoord1d GLEW_GET_FUN(__glewMultiTexCoord1d) -#define glMultiTexCoord1dv GLEW_GET_FUN(__glewMultiTexCoord1dv) -#define glMultiTexCoord1f GLEW_GET_FUN(__glewMultiTexCoord1f) -#define glMultiTexCoord1fv GLEW_GET_FUN(__glewMultiTexCoord1fv) -#define glMultiTexCoord1i GLEW_GET_FUN(__glewMultiTexCoord1i) -#define glMultiTexCoord1iv GLEW_GET_FUN(__glewMultiTexCoord1iv) -#define glMultiTexCoord1s GLEW_GET_FUN(__glewMultiTexCoord1s) -#define glMultiTexCoord1sv GLEW_GET_FUN(__glewMultiTexCoord1sv) -#define glMultiTexCoord2d GLEW_GET_FUN(__glewMultiTexCoord2d) -#define glMultiTexCoord2dv GLEW_GET_FUN(__glewMultiTexCoord2dv) -#define glMultiTexCoord2f GLEW_GET_FUN(__glewMultiTexCoord2f) -#define glMultiTexCoord2fv GLEW_GET_FUN(__glewMultiTexCoord2fv) -#define glMultiTexCoord2i GLEW_GET_FUN(__glewMultiTexCoord2i) -#define glMultiTexCoord2iv GLEW_GET_FUN(__glewMultiTexCoord2iv) -#define glMultiTexCoord2s GLEW_GET_FUN(__glewMultiTexCoord2s) -#define glMultiTexCoord2sv GLEW_GET_FUN(__glewMultiTexCoord2sv) -#define glMultiTexCoord3d GLEW_GET_FUN(__glewMultiTexCoord3d) -#define glMultiTexCoord3dv GLEW_GET_FUN(__glewMultiTexCoord3dv) -#define glMultiTexCoord3f GLEW_GET_FUN(__glewMultiTexCoord3f) -#define glMultiTexCoord3fv GLEW_GET_FUN(__glewMultiTexCoord3fv) -#define glMultiTexCoord3i GLEW_GET_FUN(__glewMultiTexCoord3i) -#define glMultiTexCoord3iv GLEW_GET_FUN(__glewMultiTexCoord3iv) -#define glMultiTexCoord3s GLEW_GET_FUN(__glewMultiTexCoord3s) -#define glMultiTexCoord3sv GLEW_GET_FUN(__glewMultiTexCoord3sv) -#define glMultiTexCoord4d GLEW_GET_FUN(__glewMultiTexCoord4d) -#define glMultiTexCoord4dv GLEW_GET_FUN(__glewMultiTexCoord4dv) -#define glMultiTexCoord4f GLEW_GET_FUN(__glewMultiTexCoord4f) -#define glMultiTexCoord4fv GLEW_GET_FUN(__glewMultiTexCoord4fv) -#define glMultiTexCoord4i GLEW_GET_FUN(__glewMultiTexCoord4i) -#define glMultiTexCoord4iv GLEW_GET_FUN(__glewMultiTexCoord4iv) -#define glMultiTexCoord4s GLEW_GET_FUN(__glewMultiTexCoord4s) -#define glMultiTexCoord4sv GLEW_GET_FUN(__glewMultiTexCoord4sv) -#define glSampleCoverage GLEW_GET_FUN(__glewSampleCoverage) - -#define GLEW_VERSION_1_3 GLEW_GET_VAR(__GLEW_VERSION_1_3) - -#endif /* GL_VERSION_1_3 */ - -/* ----------------------------- GL_VERSION_1_4 ---------------------------- */ - -#ifndef GL_VERSION_1_4 -#define GL_VERSION_1_4 1 - -#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 - -typedef void (GLAPIENTRY * PFNGLBLENDCOLORPROC) (GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha); -typedef void (GLAPIENTRY * PFNGLBLENDEQUATIONPROC) (GLenum mode); -typedef void (GLAPIENTRY * PFNGLBLENDFUNCSEPARATEPROC) (GLenum sfactorRGB, GLenum dfactorRGB, GLenum sfactorAlpha, GLenum dfactorAlpha); -typedef void (GLAPIENTRY * PFNGLFOGCOORDPOINTERPROC) (GLenum type, GLsizei stride, const void *pointer); -typedef void (GLAPIENTRY * PFNGLFOGCOORDDPROC) (GLdouble coord); -typedef void (GLAPIENTRY * PFNGLFOGCOORDDVPROC) (const GLdouble *coord); -typedef void (GLAPIENTRY * PFNGLFOGCOORDFPROC) (GLfloat coord); -typedef void (GLAPIENTRY * PFNGLFOGCOORDFVPROC) (const GLfloat *coord); -typedef void (GLAPIENTRY * PFNGLMULTIDRAWARRAYSPROC) (GLenum mode, const GLint *first, const GLsizei *count, GLsizei drawcount); -typedef void (GLAPIENTRY * PFNGLMULTIDRAWELEMENTSPROC) (GLenum mode, const GLsizei *count, GLenum type, const void *const* indices, GLsizei drawcount); -typedef void (GLAPIENTRY * PFNGLPOINTPARAMETERFPROC) (GLenum pname, GLfloat param); -typedef void (GLAPIENTRY * PFNGLPOINTPARAMETERFVPROC) (GLenum pname, const GLfloat *params); -typedef void (GLAPIENTRY * PFNGLPOINTPARAMETERIPROC) (GLenum pname, GLint param); -typedef void (GLAPIENTRY * PFNGLPOINTPARAMETERIVPROC) (GLenum pname, const GLint *params); -typedef void (GLAPIENTRY * PFNGLSECONDARYCOLOR3BPROC) (GLbyte red, GLbyte green, GLbyte blue); -typedef void (GLAPIENTRY * PFNGLSECONDARYCOLOR3BVPROC) (const GLbyte *v); -typedef void (GLAPIENTRY * PFNGLSECONDARYCOLOR3DPROC) (GLdouble red, GLdouble green, GLdouble blue); -typedef void (GLAPIENTRY * PFNGLSECONDARYCOLOR3DVPROC) (const GLdouble *v); -typedef void (GLAPIENTRY * PFNGLSECONDARYCOLOR3FPROC) (GLfloat red, GLfloat green, GLfloat blue); -typedef void (GLAPIENTRY * PFNGLSECONDARYCOLOR3FVPROC) (const GLfloat *v); -typedef void (GLAPIENTRY * PFNGLSECONDARYCOLOR3IPROC) (GLint red, GLint green, GLint blue); -typedef void (GLAPIENTRY * PFNGLSECONDARYCOLOR3IVPROC) (const GLint *v); -typedef void (GLAPIENTRY * PFNGLSECONDARYCOLOR3SPROC) (GLshort red, GLshort green, GLshort blue); -typedef void (GLAPIENTRY * PFNGLSECONDARYCOLOR3SVPROC) (const GLshort *v); -typedef void (GLAPIENTRY * PFNGLSECONDARYCOLOR3UBPROC) (GLubyte red, GLubyte green, GLubyte blue); -typedef void (GLAPIENTRY * PFNGLSECONDARYCOLOR3UBVPROC) (const GLubyte *v); -typedef void (GLAPIENTRY * PFNGLSECONDARYCOLOR3UIPROC) (GLuint red, GLuint green, GLuint blue); -typedef void (GLAPIENTRY * PFNGLSECONDARYCOLOR3UIVPROC) (const GLuint *v); -typedef void (GLAPIENTRY * PFNGLSECONDARYCOLOR3USPROC) (GLushort red, GLushort green, GLushort blue); -typedef void (GLAPIENTRY * PFNGLSECONDARYCOLOR3USVPROC) (const GLushort *v); -typedef void (GLAPIENTRY * PFNGLSECONDARYCOLORPOINTERPROC) (GLint size, GLenum type, GLsizei stride, const void *pointer); -typedef void (GLAPIENTRY * PFNGLWINDOWPOS2DPROC) (GLdouble x, GLdouble y); -typedef void (GLAPIENTRY * PFNGLWINDOWPOS2DVPROC) (const GLdouble *p); -typedef void (GLAPIENTRY * PFNGLWINDOWPOS2FPROC) (GLfloat x, GLfloat y); -typedef void (GLAPIENTRY * PFNGLWINDOWPOS2FVPROC) (const GLfloat *p); -typedef void (GLAPIENTRY * PFNGLWINDOWPOS2IPROC) (GLint x, GLint y); -typedef void (GLAPIENTRY * PFNGLWINDOWPOS2IVPROC) (const GLint *p); -typedef void (GLAPIENTRY * PFNGLWINDOWPOS2SPROC) (GLshort x, GLshort y); -typedef void (GLAPIENTRY * PFNGLWINDOWPOS2SVPROC) (const GLshort *p); -typedef void (GLAPIENTRY * PFNGLWINDOWPOS3DPROC) (GLdouble x, GLdouble y, GLdouble z); -typedef void (GLAPIENTRY * PFNGLWINDOWPOS3DVPROC) (const GLdouble *p); -typedef void (GLAPIENTRY * PFNGLWINDOWPOS3FPROC) (GLfloat x, GLfloat y, GLfloat z); -typedef void (GLAPIENTRY * PFNGLWINDOWPOS3FVPROC) (const GLfloat *p); -typedef void (GLAPIENTRY * PFNGLWINDOWPOS3IPROC) (GLint x, GLint y, GLint z); -typedef void (GLAPIENTRY * PFNGLWINDOWPOS3IVPROC) (const GLint *p); -typedef void (GLAPIENTRY * PFNGLWINDOWPOS3SPROC) (GLshort x, GLshort y, GLshort z); -typedef void (GLAPIENTRY * PFNGLWINDOWPOS3SVPROC) (const GLshort *p); - -#define glBlendColor GLEW_GET_FUN(__glewBlendColor) -#define glBlendEquation GLEW_GET_FUN(__glewBlendEquation) -#define glBlendFuncSeparate GLEW_GET_FUN(__glewBlendFuncSeparate) -#define glFogCoordPointer GLEW_GET_FUN(__glewFogCoordPointer) -#define glFogCoordd GLEW_GET_FUN(__glewFogCoordd) -#define glFogCoorddv GLEW_GET_FUN(__glewFogCoorddv) -#define glFogCoordf GLEW_GET_FUN(__glewFogCoordf) -#define glFogCoordfv GLEW_GET_FUN(__glewFogCoordfv) -#define glMultiDrawArrays GLEW_GET_FUN(__glewMultiDrawArrays) -#define glMultiDrawElements GLEW_GET_FUN(__glewMultiDrawElements) -#define glPointParameterf GLEW_GET_FUN(__glewPointParameterf) -#define glPointParameterfv GLEW_GET_FUN(__glewPointParameterfv) -#define glPointParameteri GLEW_GET_FUN(__glewPointParameteri) -#define glPointParameteriv GLEW_GET_FUN(__glewPointParameteriv) -#define glSecondaryColor3b GLEW_GET_FUN(__glewSecondaryColor3b) -#define glSecondaryColor3bv GLEW_GET_FUN(__glewSecondaryColor3bv) -#define glSecondaryColor3d GLEW_GET_FUN(__glewSecondaryColor3d) -#define glSecondaryColor3dv GLEW_GET_FUN(__glewSecondaryColor3dv) -#define glSecondaryColor3f GLEW_GET_FUN(__glewSecondaryColor3f) -#define glSecondaryColor3fv GLEW_GET_FUN(__glewSecondaryColor3fv) -#define glSecondaryColor3i GLEW_GET_FUN(__glewSecondaryColor3i) -#define glSecondaryColor3iv GLEW_GET_FUN(__glewSecondaryColor3iv) -#define glSecondaryColor3s GLEW_GET_FUN(__glewSecondaryColor3s) -#define glSecondaryColor3sv GLEW_GET_FUN(__glewSecondaryColor3sv) -#define glSecondaryColor3ub GLEW_GET_FUN(__glewSecondaryColor3ub) -#define glSecondaryColor3ubv GLEW_GET_FUN(__glewSecondaryColor3ubv) -#define glSecondaryColor3ui GLEW_GET_FUN(__glewSecondaryColor3ui) -#define glSecondaryColor3uiv GLEW_GET_FUN(__glewSecondaryColor3uiv) -#define glSecondaryColor3us GLEW_GET_FUN(__glewSecondaryColor3us) -#define glSecondaryColor3usv GLEW_GET_FUN(__glewSecondaryColor3usv) -#define glSecondaryColorPointer GLEW_GET_FUN(__glewSecondaryColorPointer) -#define glWindowPos2d GLEW_GET_FUN(__glewWindowPos2d) -#define glWindowPos2dv GLEW_GET_FUN(__glewWindowPos2dv) -#define glWindowPos2f GLEW_GET_FUN(__glewWindowPos2f) -#define glWindowPos2fv GLEW_GET_FUN(__glewWindowPos2fv) -#define glWindowPos2i GLEW_GET_FUN(__glewWindowPos2i) -#define glWindowPos2iv GLEW_GET_FUN(__glewWindowPos2iv) -#define glWindowPos2s GLEW_GET_FUN(__glewWindowPos2s) -#define glWindowPos2sv GLEW_GET_FUN(__glewWindowPos2sv) -#define glWindowPos3d GLEW_GET_FUN(__glewWindowPos3d) -#define glWindowPos3dv GLEW_GET_FUN(__glewWindowPos3dv) -#define glWindowPos3f GLEW_GET_FUN(__glewWindowPos3f) -#define glWindowPos3fv GLEW_GET_FUN(__glewWindowPos3fv) -#define glWindowPos3i GLEW_GET_FUN(__glewWindowPos3i) -#define glWindowPos3iv GLEW_GET_FUN(__glewWindowPos3iv) -#define glWindowPos3s GLEW_GET_FUN(__glewWindowPos3s) -#define glWindowPos3sv GLEW_GET_FUN(__glewWindowPos3sv) - -#define GLEW_VERSION_1_4 GLEW_GET_VAR(__GLEW_VERSION_1_4) - -#endif /* GL_VERSION_1_4 */ - -/* ----------------------------- GL_VERSION_1_5 ---------------------------- */ - -#ifndef GL_VERSION_1_5 -#define GL_VERSION_1_5 1 - -#define GL_CURRENT_FOG_COORD GL_CURRENT_FOG_COORDINATE -#define GL_FOG_COORD GL_FOG_COORDINATE -#define GL_FOG_COORD_ARRAY GL_FOG_COORDINATE_ARRAY -#define GL_FOG_COORD_ARRAY_BUFFER_BINDING GL_FOG_COORDINATE_ARRAY_BUFFER_BINDING -#define GL_FOG_COORD_ARRAY_POINTER GL_FOG_COORDINATE_ARRAY_POINTER -#define GL_FOG_COORD_ARRAY_STRIDE GL_FOG_COORDINATE_ARRAY_STRIDE -#define GL_FOG_COORD_ARRAY_TYPE GL_FOG_COORDINATE_ARRAY_TYPE -#define GL_FOG_COORD_SRC GL_FOG_COORDINATE_SOURCE -#define GL_SRC0_ALPHA GL_SOURCE0_ALPHA -#define GL_SRC0_RGB GL_SOURCE0_RGB -#define GL_SRC1_ALPHA GL_SOURCE1_ALPHA -#define GL_SRC1_RGB GL_SOURCE1_RGB -#define GL_SRC2_ALPHA GL_SOURCE2_ALPHA -#define GL_SRC2_RGB GL_SOURCE2_RGB -#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 - -typedef ptrdiff_t GLintptr; -typedef ptrdiff_t GLsizeiptr; - -typedef void (GLAPIENTRY * PFNGLBEGINQUERYPROC) (GLenum target, GLuint id); -typedef void (GLAPIENTRY * PFNGLBINDBUFFERPROC) (GLenum target, GLuint buffer); -typedef void (GLAPIENTRY * PFNGLBUFFERDATAPROC) (GLenum target, GLsizeiptr size, const void* data, GLenum usage); -typedef void (GLAPIENTRY * PFNGLBUFFERSUBDATAPROC) (GLenum target, GLintptr offset, GLsizeiptr size, const void* data); -typedef void (GLAPIENTRY * PFNGLDELETEBUFFERSPROC) (GLsizei n, const GLuint* buffers); -typedef void (GLAPIENTRY * PFNGLDELETEQUERIESPROC) (GLsizei n, const GLuint* ids); -typedef void (GLAPIENTRY * PFNGLENDQUERYPROC) (GLenum target); -typedef void (GLAPIENTRY * PFNGLGENBUFFERSPROC) (GLsizei n, GLuint* buffers); -typedef void (GLAPIENTRY * PFNGLGENQUERIESPROC) (GLsizei n, GLuint* ids); -typedef void (GLAPIENTRY * PFNGLGETBUFFERPARAMETERIVPROC) (GLenum target, GLenum pname, GLint* params); -typedef void (GLAPIENTRY * PFNGLGETBUFFERPOINTERVPROC) (GLenum target, GLenum pname, void** params); -typedef void (GLAPIENTRY * PFNGLGETBUFFERSUBDATAPROC) (GLenum target, GLintptr offset, GLsizeiptr size, void* data); -typedef void (GLAPIENTRY * PFNGLGETQUERYOBJECTIVPROC) (GLuint id, GLenum pname, GLint* params); -typedef void (GLAPIENTRY * PFNGLGETQUERYOBJECTUIVPROC) (GLuint id, GLenum pname, GLuint* params); -typedef void (GLAPIENTRY * PFNGLGETQUERYIVPROC) (GLenum target, GLenum pname, GLint* params); -typedef GLboolean (GLAPIENTRY * PFNGLISBUFFERPROC) (GLuint buffer); -typedef GLboolean (GLAPIENTRY * PFNGLISQUERYPROC) (GLuint id); -typedef void* (GLAPIENTRY * PFNGLMAPBUFFERPROC) (GLenum target, GLenum access); -typedef GLboolean (GLAPIENTRY * PFNGLUNMAPBUFFERPROC) (GLenum target); - -#define glBeginQuery GLEW_GET_FUN(__glewBeginQuery) -#define glBindBuffer GLEW_GET_FUN(__glewBindBuffer) -#define glBufferData GLEW_GET_FUN(__glewBufferData) -#define glBufferSubData GLEW_GET_FUN(__glewBufferSubData) -#define glDeleteBuffers GLEW_GET_FUN(__glewDeleteBuffers) -#define glDeleteQueries GLEW_GET_FUN(__glewDeleteQueries) -#define glEndQuery GLEW_GET_FUN(__glewEndQuery) -#define glGenBuffers GLEW_GET_FUN(__glewGenBuffers) -#define glGenQueries GLEW_GET_FUN(__glewGenQueries) -#define glGetBufferParameteriv GLEW_GET_FUN(__glewGetBufferParameteriv) -#define glGetBufferPointerv GLEW_GET_FUN(__glewGetBufferPointerv) -#define glGetBufferSubData GLEW_GET_FUN(__glewGetBufferSubData) -#define glGetQueryObjectiv GLEW_GET_FUN(__glewGetQueryObjectiv) -#define glGetQueryObjectuiv GLEW_GET_FUN(__glewGetQueryObjectuiv) -#define glGetQueryiv GLEW_GET_FUN(__glewGetQueryiv) -#define glIsBuffer GLEW_GET_FUN(__glewIsBuffer) -#define glIsQuery GLEW_GET_FUN(__glewIsQuery) -#define glMapBuffer GLEW_GET_FUN(__glewMapBuffer) -#define glUnmapBuffer GLEW_GET_FUN(__glewUnmapBuffer) - -#define GLEW_VERSION_1_5 GLEW_GET_VAR(__GLEW_VERSION_1_5) - -#endif /* GL_VERSION_1_5 */ - -/* ----------------------------- GL_VERSION_2_0 ---------------------------- */ - -#ifndef GL_VERSION_2_0 -#define GL_VERSION_2_0 1 - -#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 - -typedef void (GLAPIENTRY * PFNGLATTACHSHADERPROC) (GLuint program, GLuint shader); -typedef void (GLAPIENTRY * PFNGLBINDATTRIBLOCATIONPROC) (GLuint program, GLuint index, const GLchar* name); -typedef void (GLAPIENTRY * PFNGLBLENDEQUATIONSEPARATEPROC) (GLenum modeRGB, GLenum modeAlpha); -typedef void (GLAPIENTRY * PFNGLCOMPILESHADERPROC) (GLuint shader); -typedef GLuint (GLAPIENTRY * PFNGLCREATEPROGRAMPROC) (void); -typedef GLuint (GLAPIENTRY * PFNGLCREATESHADERPROC) (GLenum type); -typedef void (GLAPIENTRY * PFNGLDELETEPROGRAMPROC) (GLuint program); -typedef void (GLAPIENTRY * PFNGLDELETESHADERPROC) (GLuint shader); -typedef void (GLAPIENTRY * PFNGLDETACHSHADERPROC) (GLuint program, GLuint shader); -typedef void (GLAPIENTRY * PFNGLDISABLEVERTEXATTRIBARRAYPROC) (GLuint index); -typedef void (GLAPIENTRY * PFNGLDRAWBUFFERSPROC) (GLsizei n, const GLenum* bufs); -typedef void (GLAPIENTRY * PFNGLENABLEVERTEXATTRIBARRAYPROC) (GLuint index); -typedef void (GLAPIENTRY * PFNGLGETACTIVEATTRIBPROC) (GLuint program, GLuint index, GLsizei maxLength, GLsizei* length, GLint* size, GLenum* type, GLchar* name); -typedef void (GLAPIENTRY * PFNGLGETACTIVEUNIFORMPROC) (GLuint program, GLuint index, GLsizei maxLength, GLsizei* length, GLint* size, GLenum* type, GLchar* name); -typedef void (GLAPIENTRY * PFNGLGETATTACHEDSHADERSPROC) (GLuint program, GLsizei maxCount, GLsizei* count, GLuint* shaders); -typedef GLint (GLAPIENTRY * PFNGLGETATTRIBLOCATIONPROC) (GLuint program, const GLchar* name); -typedef void (GLAPIENTRY * PFNGLGETPROGRAMINFOLOGPROC) (GLuint program, GLsizei bufSize, GLsizei* length, GLchar* infoLog); -typedef void (GLAPIENTRY * PFNGLGETPROGRAMIVPROC) (GLuint program, GLenum pname, GLint* param); -typedef void (GLAPIENTRY * PFNGLGETSHADERINFOLOGPROC) (GLuint shader, GLsizei bufSize, GLsizei* length, GLchar* infoLog); -typedef void (GLAPIENTRY * PFNGLGETSHADERSOURCEPROC) (GLuint obj, GLsizei maxLength, GLsizei* length, GLchar* source); -typedef void (GLAPIENTRY * PFNGLGETSHADERIVPROC) (GLuint shader, GLenum pname, GLint* param); -typedef GLint (GLAPIENTRY * PFNGLGETUNIFORMLOCATIONPROC) (GLuint program, const GLchar* name); -typedef void (GLAPIENTRY * PFNGLGETUNIFORMFVPROC) (GLuint program, GLint location, GLfloat* params); -typedef void (GLAPIENTRY * PFNGLGETUNIFORMIVPROC) (GLuint program, GLint location, GLint* params); -typedef void (GLAPIENTRY * PFNGLGETVERTEXATTRIBPOINTERVPROC) (GLuint index, GLenum pname, void** pointer); -typedef void (GLAPIENTRY * PFNGLGETVERTEXATTRIBDVPROC) (GLuint index, GLenum pname, GLdouble* params); -typedef void (GLAPIENTRY * PFNGLGETVERTEXATTRIBFVPROC) (GLuint index, GLenum pname, GLfloat* params); -typedef void (GLAPIENTRY * PFNGLGETVERTEXATTRIBIVPROC) (GLuint index, GLenum pname, GLint* params); -typedef GLboolean (GLAPIENTRY * PFNGLISPROGRAMPROC) (GLuint program); -typedef GLboolean (GLAPIENTRY * PFNGLISSHADERPROC) (GLuint shader); -typedef void (GLAPIENTRY * PFNGLLINKPROGRAMPROC) (GLuint program); -typedef void (GLAPIENTRY * PFNGLSHADERSOURCEPROC) (GLuint shader, GLsizei count, const GLchar *const* string, const GLint* length); -typedef void (GLAPIENTRY * PFNGLSTENCILFUNCSEPARATEPROC) (GLenum frontfunc, GLenum backfunc, GLint ref, GLuint mask); -typedef void (GLAPIENTRY * PFNGLSTENCILMASKSEPARATEPROC) (GLenum face, GLuint mask); -typedef void (GLAPIENTRY * PFNGLSTENCILOPSEPARATEPROC) (GLenum face, GLenum sfail, GLenum dpfail, GLenum dppass); -typedef void (GLAPIENTRY * PFNGLUNIFORM1FPROC) (GLint location, GLfloat v0); -typedef void (GLAPIENTRY * PFNGLUNIFORM1FVPROC) (GLint location, GLsizei count, const GLfloat* value); -typedef void (GLAPIENTRY * PFNGLUNIFORM1IPROC) (GLint location, GLint v0); -typedef void (GLAPIENTRY * PFNGLUNIFORM1IVPROC) (GLint location, GLsizei count, const GLint* value); -typedef void (GLAPIENTRY * PFNGLUNIFORM2FPROC) (GLint location, GLfloat v0, GLfloat v1); -typedef void (GLAPIENTRY * PFNGLUNIFORM2FVPROC) (GLint location, GLsizei count, const GLfloat* value); -typedef void (GLAPIENTRY * PFNGLUNIFORM2IPROC) (GLint location, GLint v0, GLint v1); -typedef void (GLAPIENTRY * PFNGLUNIFORM2IVPROC) (GLint location, GLsizei count, const GLint* value); -typedef void (GLAPIENTRY * PFNGLUNIFORM3FPROC) (GLint location, GLfloat v0, GLfloat v1, GLfloat v2); -typedef void (GLAPIENTRY * PFNGLUNIFORM3FVPROC) (GLint location, GLsizei count, const GLfloat* value); -typedef void (GLAPIENTRY * PFNGLUNIFORM3IPROC) (GLint location, GLint v0, GLint v1, GLint v2); -typedef void (GLAPIENTRY * PFNGLUNIFORM3IVPROC) (GLint location, GLsizei count, const GLint* value); -typedef void (GLAPIENTRY * PFNGLUNIFORM4FPROC) (GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3); -typedef void (GLAPIENTRY * PFNGLUNIFORM4FVPROC) (GLint location, GLsizei count, const GLfloat* value); -typedef void (GLAPIENTRY * PFNGLUNIFORM4IPROC) (GLint location, GLint v0, GLint v1, GLint v2, GLint v3); -typedef void (GLAPIENTRY * PFNGLUNIFORM4IVPROC) (GLint location, GLsizei count, const GLint* value); -typedef void (GLAPIENTRY * PFNGLUNIFORMMATRIX2FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat* value); -typedef void (GLAPIENTRY * PFNGLUNIFORMMATRIX3FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat* value); -typedef void (GLAPIENTRY * PFNGLUNIFORMMATRIX4FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat* value); -typedef void (GLAPIENTRY * PFNGLUSEPROGRAMPROC) (GLuint program); -typedef void (GLAPIENTRY * PFNGLVALIDATEPROGRAMPROC) (GLuint program); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB1DPROC) (GLuint index, GLdouble x); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB1DVPROC) (GLuint index, const GLdouble* v); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB1FPROC) (GLuint index, GLfloat x); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB1FVPROC) (GLuint index, const GLfloat* v); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB1SPROC) (GLuint index, GLshort x); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB1SVPROC) (GLuint index, const GLshort* v); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB2DPROC) (GLuint index, GLdouble x, GLdouble y); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB2DVPROC) (GLuint index, const GLdouble* v); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB2FPROC) (GLuint index, GLfloat x, GLfloat y); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB2FVPROC) (GLuint index, const GLfloat* v); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB2SPROC) (GLuint index, GLshort x, GLshort y); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB2SVPROC) (GLuint index, const GLshort* v); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB3DPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB3DVPROC) (GLuint index, const GLdouble* v); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB3FPROC) (GLuint index, GLfloat x, GLfloat y, GLfloat z); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB3FVPROC) (GLuint index, const GLfloat* v); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB3SPROC) (GLuint index, GLshort x, GLshort y, GLshort z); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB3SVPROC) (GLuint index, const GLshort* v); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4NBVPROC) (GLuint index, const GLbyte* v); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4NIVPROC) (GLuint index, const GLint* v); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4NSVPROC) (GLuint index, const GLshort* v); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4NUBPROC) (GLuint index, GLubyte x, GLubyte y, GLubyte z, GLubyte w); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4NUBVPROC) (GLuint index, const GLubyte* v); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4NUIVPROC) (GLuint index, const GLuint* v); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4NUSVPROC) (GLuint index, const GLushort* v); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4BVPROC) (GLuint index, const GLbyte* v); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4DPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4DVPROC) (GLuint index, const GLdouble* v); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4FPROC) (GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4FVPROC) (GLuint index, const GLfloat* v); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4IVPROC) (GLuint index, const GLint* v); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4SPROC) (GLuint index, GLshort x, GLshort y, GLshort z, GLshort w); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4SVPROC) (GLuint index, const GLshort* v); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4UBVPROC) (GLuint index, const GLubyte* v); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4UIVPROC) (GLuint index, const GLuint* v); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4USVPROC) (GLuint index, const GLushort* v); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBPOINTERPROC) (GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const void* pointer); - -#define glAttachShader GLEW_GET_FUN(__glewAttachShader) -#define glBindAttribLocation GLEW_GET_FUN(__glewBindAttribLocation) -#define glBlendEquationSeparate GLEW_GET_FUN(__glewBlendEquationSeparate) -#define glCompileShader GLEW_GET_FUN(__glewCompileShader) -#define glCreateProgram GLEW_GET_FUN(__glewCreateProgram) -#define glCreateShader GLEW_GET_FUN(__glewCreateShader) -#define glDeleteProgram GLEW_GET_FUN(__glewDeleteProgram) -#define glDeleteShader GLEW_GET_FUN(__glewDeleteShader) -#define glDetachShader GLEW_GET_FUN(__glewDetachShader) -#define glDisableVertexAttribArray GLEW_GET_FUN(__glewDisableVertexAttribArray) -#define glDrawBuffers GLEW_GET_FUN(__glewDrawBuffers) -#define glEnableVertexAttribArray GLEW_GET_FUN(__glewEnableVertexAttribArray) -#define glGetActiveAttrib GLEW_GET_FUN(__glewGetActiveAttrib) -#define glGetActiveUniform GLEW_GET_FUN(__glewGetActiveUniform) -#define glGetAttachedShaders GLEW_GET_FUN(__glewGetAttachedShaders) -#define glGetAttribLocation GLEW_GET_FUN(__glewGetAttribLocation) -#define glGetProgramInfoLog GLEW_GET_FUN(__glewGetProgramInfoLog) -#define glGetProgramiv GLEW_GET_FUN(__glewGetProgramiv) -#define glGetShaderInfoLog GLEW_GET_FUN(__glewGetShaderInfoLog) -#define glGetShaderSource GLEW_GET_FUN(__glewGetShaderSource) -#define glGetShaderiv GLEW_GET_FUN(__glewGetShaderiv) -#define glGetUniformLocation GLEW_GET_FUN(__glewGetUniformLocation) -#define glGetUniformfv GLEW_GET_FUN(__glewGetUniformfv) -#define glGetUniformiv GLEW_GET_FUN(__glewGetUniformiv) -#define glGetVertexAttribPointerv GLEW_GET_FUN(__glewGetVertexAttribPointerv) -#define glGetVertexAttribdv GLEW_GET_FUN(__glewGetVertexAttribdv) -#define glGetVertexAttribfv GLEW_GET_FUN(__glewGetVertexAttribfv) -#define glGetVertexAttribiv GLEW_GET_FUN(__glewGetVertexAttribiv) -#define glIsProgram GLEW_GET_FUN(__glewIsProgram) -#define glIsShader GLEW_GET_FUN(__glewIsShader) -#define glLinkProgram GLEW_GET_FUN(__glewLinkProgram) -#define glShaderSource GLEW_GET_FUN(__glewShaderSource) -#define glStencilFuncSeparate GLEW_GET_FUN(__glewStencilFuncSeparate) -#define glStencilMaskSeparate GLEW_GET_FUN(__glewStencilMaskSeparate) -#define glStencilOpSeparate GLEW_GET_FUN(__glewStencilOpSeparate) -#define glUniform1f GLEW_GET_FUN(__glewUniform1f) -#define glUniform1fv GLEW_GET_FUN(__glewUniform1fv) -#define glUniform1i GLEW_GET_FUN(__glewUniform1i) -#define glUniform1iv GLEW_GET_FUN(__glewUniform1iv) -#define glUniform2f GLEW_GET_FUN(__glewUniform2f) -#define glUniform2fv GLEW_GET_FUN(__glewUniform2fv) -#define glUniform2i GLEW_GET_FUN(__glewUniform2i) -#define glUniform2iv GLEW_GET_FUN(__glewUniform2iv) -#define glUniform3f GLEW_GET_FUN(__glewUniform3f) -#define glUniform3fv GLEW_GET_FUN(__glewUniform3fv) -#define glUniform3i GLEW_GET_FUN(__glewUniform3i) -#define glUniform3iv GLEW_GET_FUN(__glewUniform3iv) -#define glUniform4f GLEW_GET_FUN(__glewUniform4f) -#define glUniform4fv GLEW_GET_FUN(__glewUniform4fv) -#define glUniform4i GLEW_GET_FUN(__glewUniform4i) -#define glUniform4iv GLEW_GET_FUN(__glewUniform4iv) -#define glUniformMatrix2fv GLEW_GET_FUN(__glewUniformMatrix2fv) -#define glUniformMatrix3fv GLEW_GET_FUN(__glewUniformMatrix3fv) -#define glUniformMatrix4fv GLEW_GET_FUN(__glewUniformMatrix4fv) -#define glUseProgram GLEW_GET_FUN(__glewUseProgram) -#define glValidateProgram GLEW_GET_FUN(__glewValidateProgram) -#define glVertexAttrib1d GLEW_GET_FUN(__glewVertexAttrib1d) -#define glVertexAttrib1dv GLEW_GET_FUN(__glewVertexAttrib1dv) -#define glVertexAttrib1f GLEW_GET_FUN(__glewVertexAttrib1f) -#define glVertexAttrib1fv GLEW_GET_FUN(__glewVertexAttrib1fv) -#define glVertexAttrib1s GLEW_GET_FUN(__glewVertexAttrib1s) -#define glVertexAttrib1sv GLEW_GET_FUN(__glewVertexAttrib1sv) -#define glVertexAttrib2d GLEW_GET_FUN(__glewVertexAttrib2d) -#define glVertexAttrib2dv GLEW_GET_FUN(__glewVertexAttrib2dv) -#define glVertexAttrib2f GLEW_GET_FUN(__glewVertexAttrib2f) -#define glVertexAttrib2fv GLEW_GET_FUN(__glewVertexAttrib2fv) -#define glVertexAttrib2s GLEW_GET_FUN(__glewVertexAttrib2s) -#define glVertexAttrib2sv GLEW_GET_FUN(__glewVertexAttrib2sv) -#define glVertexAttrib3d GLEW_GET_FUN(__glewVertexAttrib3d) -#define glVertexAttrib3dv GLEW_GET_FUN(__glewVertexAttrib3dv) -#define glVertexAttrib3f GLEW_GET_FUN(__glewVertexAttrib3f) -#define glVertexAttrib3fv GLEW_GET_FUN(__glewVertexAttrib3fv) -#define glVertexAttrib3s GLEW_GET_FUN(__glewVertexAttrib3s) -#define glVertexAttrib3sv GLEW_GET_FUN(__glewVertexAttrib3sv) -#define glVertexAttrib4Nbv GLEW_GET_FUN(__glewVertexAttrib4Nbv) -#define glVertexAttrib4Niv GLEW_GET_FUN(__glewVertexAttrib4Niv) -#define glVertexAttrib4Nsv GLEW_GET_FUN(__glewVertexAttrib4Nsv) -#define glVertexAttrib4Nub GLEW_GET_FUN(__glewVertexAttrib4Nub) -#define glVertexAttrib4Nubv GLEW_GET_FUN(__glewVertexAttrib4Nubv) -#define glVertexAttrib4Nuiv GLEW_GET_FUN(__glewVertexAttrib4Nuiv) -#define glVertexAttrib4Nusv GLEW_GET_FUN(__glewVertexAttrib4Nusv) -#define glVertexAttrib4bv GLEW_GET_FUN(__glewVertexAttrib4bv) -#define glVertexAttrib4d GLEW_GET_FUN(__glewVertexAttrib4d) -#define glVertexAttrib4dv GLEW_GET_FUN(__glewVertexAttrib4dv) -#define glVertexAttrib4f GLEW_GET_FUN(__glewVertexAttrib4f) -#define glVertexAttrib4fv GLEW_GET_FUN(__glewVertexAttrib4fv) -#define glVertexAttrib4iv GLEW_GET_FUN(__glewVertexAttrib4iv) -#define glVertexAttrib4s GLEW_GET_FUN(__glewVertexAttrib4s) -#define glVertexAttrib4sv GLEW_GET_FUN(__glewVertexAttrib4sv) -#define glVertexAttrib4ubv GLEW_GET_FUN(__glewVertexAttrib4ubv) -#define glVertexAttrib4uiv GLEW_GET_FUN(__glewVertexAttrib4uiv) -#define glVertexAttrib4usv GLEW_GET_FUN(__glewVertexAttrib4usv) -#define glVertexAttribPointer GLEW_GET_FUN(__glewVertexAttribPointer) - -#define GLEW_VERSION_2_0 GLEW_GET_VAR(__GLEW_VERSION_2_0) - -#endif /* GL_VERSION_2_0 */ - -/* ----------------------------- GL_VERSION_2_1 ---------------------------- */ - -#ifndef GL_VERSION_2_1 -#define GL_VERSION_2_1 1 - -#define GL_CURRENT_RASTER_SECONDARY_COLOR 0x845F -#define GL_PIXEL_PACK_BUFFER 0x88EB -#define GL_PIXEL_UNPACK_BUFFER 0x88EC -#define GL_PIXEL_PACK_BUFFER_BINDING 0x88ED -#define GL_PIXEL_UNPACK_BUFFER_BINDING 0x88EF -#define GL_FLOAT_MAT2x3 0x8B65 -#define GL_FLOAT_MAT2x4 0x8B66 -#define GL_FLOAT_MAT3x2 0x8B67 -#define GL_FLOAT_MAT3x4 0x8B68 -#define GL_FLOAT_MAT4x2 0x8B69 -#define GL_FLOAT_MAT4x3 0x8B6A -#define GL_SRGB 0x8C40 -#define GL_SRGB8 0x8C41 -#define GL_SRGB_ALPHA 0x8C42 -#define GL_SRGB8_ALPHA8 0x8C43 -#define GL_SLUMINANCE_ALPHA 0x8C44 -#define GL_SLUMINANCE8_ALPHA8 0x8C45 -#define GL_SLUMINANCE 0x8C46 -#define GL_SLUMINANCE8 0x8C47 -#define GL_COMPRESSED_SRGB 0x8C48 -#define GL_COMPRESSED_SRGB_ALPHA 0x8C49 -#define GL_COMPRESSED_SLUMINANCE 0x8C4A -#define GL_COMPRESSED_SLUMINANCE_ALPHA 0x8C4B - -typedef void (GLAPIENTRY * PFNGLUNIFORMMATRIX2X3FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -typedef void (GLAPIENTRY * PFNGLUNIFORMMATRIX2X4FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -typedef void (GLAPIENTRY * PFNGLUNIFORMMATRIX3X2FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -typedef void (GLAPIENTRY * PFNGLUNIFORMMATRIX3X4FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -typedef void (GLAPIENTRY * PFNGLUNIFORMMATRIX4X2FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -typedef void (GLAPIENTRY * PFNGLUNIFORMMATRIX4X3FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); - -#define glUniformMatrix2x3fv GLEW_GET_FUN(__glewUniformMatrix2x3fv) -#define glUniformMatrix2x4fv GLEW_GET_FUN(__glewUniformMatrix2x4fv) -#define glUniformMatrix3x2fv GLEW_GET_FUN(__glewUniformMatrix3x2fv) -#define glUniformMatrix3x4fv GLEW_GET_FUN(__glewUniformMatrix3x4fv) -#define glUniformMatrix4x2fv GLEW_GET_FUN(__glewUniformMatrix4x2fv) -#define glUniformMatrix4x3fv GLEW_GET_FUN(__glewUniformMatrix4x3fv) - -#define GLEW_VERSION_2_1 GLEW_GET_VAR(__GLEW_VERSION_2_1) - -#endif /* GL_VERSION_2_1 */ - -/* ----------------------------- GL_VERSION_3_0 ---------------------------- */ - -#ifndef GL_VERSION_3_0 -#define GL_VERSION_3_0 1 - -#define GL_CLIP_DISTANCE0 GL_CLIP_PLANE0 -#define GL_CLIP_DISTANCE1 GL_CLIP_PLANE1 -#define GL_CLIP_DISTANCE2 GL_CLIP_PLANE2 -#define GL_CLIP_DISTANCE3 GL_CLIP_PLANE3 -#define GL_CLIP_DISTANCE4 GL_CLIP_PLANE4 -#define GL_CLIP_DISTANCE5 GL_CLIP_PLANE5 -#define GL_COMPARE_REF_TO_TEXTURE GL_COMPARE_R_TO_TEXTURE_ARB -#define GL_MAX_CLIP_DISTANCES GL_MAX_CLIP_PLANES -#define GL_MAX_VARYING_COMPONENTS GL_MAX_VARYING_FLOATS -#define GL_CONTEXT_FLAG_FORWARD_COMPATIBLE_BIT 0x0001 -#define GL_MAJOR_VERSION 0x821B -#define GL_MINOR_VERSION 0x821C -#define GL_NUM_EXTENSIONS 0x821D -#define GL_CONTEXT_FLAGS 0x821E -#define GL_DEPTH_BUFFER 0x8223 -#define GL_STENCIL_BUFFER 0x8224 -#define GL_RGBA32F 0x8814 -#define GL_RGB32F 0x8815 -#define GL_RGBA16F 0x881A -#define GL_RGB16F 0x881B -#define GL_VERTEX_ATTRIB_ARRAY_INTEGER 0x88FD -#define GL_MAX_ARRAY_TEXTURE_LAYERS 0x88FF -#define GL_MIN_PROGRAM_TEXEL_OFFSET 0x8904 -#define GL_MAX_PROGRAM_TEXEL_OFFSET 0x8905 -#define GL_CLAMP_VERTEX_COLOR 0x891A -#define GL_CLAMP_FRAGMENT_COLOR 0x891B -#define GL_CLAMP_READ_COLOR 0x891C -#define GL_FIXED_ONLY 0x891D -#define GL_TEXTURE_RED_TYPE 0x8C10 -#define GL_TEXTURE_GREEN_TYPE 0x8C11 -#define GL_TEXTURE_BLUE_TYPE 0x8C12 -#define GL_TEXTURE_ALPHA_TYPE 0x8C13 -#define GL_TEXTURE_LUMINANCE_TYPE 0x8C14 -#define GL_TEXTURE_INTENSITY_TYPE 0x8C15 -#define GL_TEXTURE_DEPTH_TYPE 0x8C16 -#define GL_TEXTURE_1D_ARRAY 0x8C18 -#define GL_PROXY_TEXTURE_1D_ARRAY 0x8C19 -#define GL_TEXTURE_2D_ARRAY 0x8C1A -#define GL_PROXY_TEXTURE_2D_ARRAY 0x8C1B -#define GL_TEXTURE_BINDING_1D_ARRAY 0x8C1C -#define GL_TEXTURE_BINDING_2D_ARRAY 0x8C1D -#define GL_R11F_G11F_B10F 0x8C3A -#define GL_UNSIGNED_INT_10F_11F_11F_REV 0x8C3B -#define GL_RGB9_E5 0x8C3D -#define GL_UNSIGNED_INT_5_9_9_9_REV 0x8C3E -#define GL_TEXTURE_SHARED_SIZE 0x8C3F -#define GL_TRANSFORM_FEEDBACK_VARYING_MAX_LENGTH 0x8C76 -#define GL_TRANSFORM_FEEDBACK_BUFFER_MODE 0x8C7F -#define GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS 0x8C80 -#define GL_TRANSFORM_FEEDBACK_VARYINGS 0x8C83 -#define GL_TRANSFORM_FEEDBACK_BUFFER_START 0x8C84 -#define GL_TRANSFORM_FEEDBACK_BUFFER_SIZE 0x8C85 -#define GL_PRIMITIVES_GENERATED 0x8C87 -#define GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN 0x8C88 -#define GL_RASTERIZER_DISCARD 0x8C89 -#define GL_MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS 0x8C8A -#define GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS 0x8C8B -#define GL_INTERLEAVED_ATTRIBS 0x8C8C -#define GL_SEPARATE_ATTRIBS 0x8C8D -#define GL_TRANSFORM_FEEDBACK_BUFFER 0x8C8E -#define GL_TRANSFORM_FEEDBACK_BUFFER_BINDING 0x8C8F -#define GL_RGBA32UI 0x8D70 -#define GL_RGB32UI 0x8D71 -#define GL_RGBA16UI 0x8D76 -#define GL_RGB16UI 0x8D77 -#define GL_RGBA8UI 0x8D7C -#define GL_RGB8UI 0x8D7D -#define GL_RGBA32I 0x8D82 -#define GL_RGB32I 0x8D83 -#define GL_RGBA16I 0x8D88 -#define GL_RGB16I 0x8D89 -#define GL_RGBA8I 0x8D8E -#define GL_RGB8I 0x8D8F -#define GL_RED_INTEGER 0x8D94 -#define GL_GREEN_INTEGER 0x8D95 -#define GL_BLUE_INTEGER 0x8D96 -#define GL_ALPHA_INTEGER 0x8D97 -#define GL_RGB_INTEGER 0x8D98 -#define GL_RGBA_INTEGER 0x8D99 -#define GL_BGR_INTEGER 0x8D9A -#define GL_BGRA_INTEGER 0x8D9B -#define GL_SAMPLER_1D_ARRAY 0x8DC0 -#define GL_SAMPLER_2D_ARRAY 0x8DC1 -#define GL_SAMPLER_1D_ARRAY_SHADOW 0x8DC3 -#define GL_SAMPLER_2D_ARRAY_SHADOW 0x8DC4 -#define GL_SAMPLER_CUBE_SHADOW 0x8DC5 -#define GL_UNSIGNED_INT_VEC2 0x8DC6 -#define GL_UNSIGNED_INT_VEC3 0x8DC7 -#define GL_UNSIGNED_INT_VEC4 0x8DC8 -#define GL_INT_SAMPLER_1D 0x8DC9 -#define GL_INT_SAMPLER_2D 0x8DCA -#define GL_INT_SAMPLER_3D 0x8DCB -#define GL_INT_SAMPLER_CUBE 0x8DCC -#define GL_INT_SAMPLER_1D_ARRAY 0x8DCE -#define GL_INT_SAMPLER_2D_ARRAY 0x8DCF -#define GL_UNSIGNED_INT_SAMPLER_1D 0x8DD1 -#define GL_UNSIGNED_INT_SAMPLER_2D 0x8DD2 -#define GL_UNSIGNED_INT_SAMPLER_3D 0x8DD3 -#define GL_UNSIGNED_INT_SAMPLER_CUBE 0x8DD4 -#define GL_UNSIGNED_INT_SAMPLER_1D_ARRAY 0x8DD6 -#define GL_UNSIGNED_INT_SAMPLER_2D_ARRAY 0x8DD7 -#define GL_QUERY_WAIT 0x8E13 -#define GL_QUERY_NO_WAIT 0x8E14 -#define GL_QUERY_BY_REGION_WAIT 0x8E15 -#define GL_QUERY_BY_REGION_NO_WAIT 0x8E16 - -typedef void (GLAPIENTRY * PFNGLBEGINCONDITIONALRENDERPROC) (GLuint id, GLenum mode); -typedef void (GLAPIENTRY * PFNGLBEGINTRANSFORMFEEDBACKPROC) (GLenum primitiveMode); -typedef void (GLAPIENTRY * PFNGLBINDFRAGDATALOCATIONPROC) (GLuint program, GLuint colorNumber, const GLchar* name); -typedef void (GLAPIENTRY * PFNGLCLAMPCOLORPROC) (GLenum target, GLenum clamp); -typedef void (GLAPIENTRY * PFNGLCLEARBUFFERFIPROC) (GLenum buffer, GLint drawBuffer, GLfloat depth, GLint stencil); -typedef void (GLAPIENTRY * PFNGLCLEARBUFFERFVPROC) (GLenum buffer, GLint drawBuffer, const GLfloat* value); -typedef void (GLAPIENTRY * PFNGLCLEARBUFFERIVPROC) (GLenum buffer, GLint drawBuffer, const GLint* value); -typedef void (GLAPIENTRY * PFNGLCLEARBUFFERUIVPROC) (GLenum buffer, GLint drawBuffer, const GLuint* value); -typedef void (GLAPIENTRY * PFNGLCOLORMASKIPROC) (GLuint buf, GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha); -typedef void (GLAPIENTRY * PFNGLDISABLEIPROC) (GLenum cap, GLuint index); -typedef void (GLAPIENTRY * PFNGLENABLEIPROC) (GLenum cap, GLuint index); -typedef void (GLAPIENTRY * PFNGLENDCONDITIONALRENDERPROC) (void); -typedef void (GLAPIENTRY * PFNGLENDTRANSFORMFEEDBACKPROC) (void); -typedef void (GLAPIENTRY * PFNGLGETBOOLEANI_VPROC) (GLenum pname, GLuint index, GLboolean* data); -typedef GLint (GLAPIENTRY * PFNGLGETFRAGDATALOCATIONPROC) (GLuint program, const GLchar* name); -typedef const GLubyte* (GLAPIENTRY * PFNGLGETSTRINGIPROC) (GLenum name, GLuint index); -typedef void (GLAPIENTRY * PFNGLGETTEXPARAMETERIIVPROC) (GLenum target, GLenum pname, GLint* params); -typedef void (GLAPIENTRY * PFNGLGETTEXPARAMETERIUIVPROC) (GLenum target, GLenum pname, GLuint* params); -typedef void (GLAPIENTRY * PFNGLGETTRANSFORMFEEDBACKVARYINGPROC) (GLuint program, GLuint index, GLsizei bufSize, GLsizei * length, GLsizei * size, GLenum * type, GLchar * name); -typedef void (GLAPIENTRY * PFNGLGETUNIFORMUIVPROC) (GLuint program, GLint location, GLuint* params); -typedef void (GLAPIENTRY * PFNGLGETVERTEXATTRIBIIVPROC) (GLuint index, GLenum pname, GLint* params); -typedef void (GLAPIENTRY * PFNGLGETVERTEXATTRIBIUIVPROC) (GLuint index, GLenum pname, GLuint* params); -typedef GLboolean (GLAPIENTRY * PFNGLISENABLEDIPROC) (GLenum cap, GLuint index); -typedef void (GLAPIENTRY * PFNGLTEXPARAMETERIIVPROC) (GLenum target, GLenum pname, const GLint* params); -typedef void (GLAPIENTRY * PFNGLTEXPARAMETERIUIVPROC) (GLenum target, GLenum pname, const GLuint* params); -typedef void (GLAPIENTRY * PFNGLTRANSFORMFEEDBACKVARYINGSPROC) (GLuint program, GLsizei count, const GLchar *const* varyings, GLenum bufferMode); -typedef void (GLAPIENTRY * PFNGLUNIFORM1UIPROC) (GLint location, GLuint v0); -typedef void (GLAPIENTRY * PFNGLUNIFORM1UIVPROC) (GLint location, GLsizei count, const GLuint* value); -typedef void (GLAPIENTRY * PFNGLUNIFORM2UIPROC) (GLint location, GLuint v0, GLuint v1); -typedef void (GLAPIENTRY * PFNGLUNIFORM2UIVPROC) (GLint location, GLsizei count, const GLuint* value); -typedef void (GLAPIENTRY * PFNGLUNIFORM3UIPROC) (GLint location, GLuint v0, GLuint v1, GLuint v2); -typedef void (GLAPIENTRY * PFNGLUNIFORM3UIVPROC) (GLint location, GLsizei count, const GLuint* value); -typedef void (GLAPIENTRY * PFNGLUNIFORM4UIPROC) (GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3); -typedef void (GLAPIENTRY * PFNGLUNIFORM4UIVPROC) (GLint location, GLsizei count, const GLuint* value); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBI1IPROC) (GLuint index, GLint v0); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBI1IVPROC) (GLuint index, const GLint* v0); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBI1UIPROC) (GLuint index, GLuint v0); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBI1UIVPROC) (GLuint index, const GLuint* v0); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBI2IPROC) (GLuint index, GLint v0, GLint v1); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBI2IVPROC) (GLuint index, const GLint* v0); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBI2UIPROC) (GLuint index, GLuint v0, GLuint v1); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBI2UIVPROC) (GLuint index, const GLuint* v0); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBI3IPROC) (GLuint index, GLint v0, GLint v1, GLint v2); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBI3IVPROC) (GLuint index, const GLint* v0); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBI3UIPROC) (GLuint index, GLuint v0, GLuint v1, GLuint v2); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBI3UIVPROC) (GLuint index, const GLuint* v0); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBI4BVPROC) (GLuint index, const GLbyte* v0); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBI4IPROC) (GLuint index, GLint v0, GLint v1, GLint v2, GLint v3); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBI4IVPROC) (GLuint index, const GLint* v0); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBI4SVPROC) (GLuint index, const GLshort* v0); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBI4UBVPROC) (GLuint index, const GLubyte* v0); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBI4UIPROC) (GLuint index, GLuint v0, GLuint v1, GLuint v2, GLuint v3); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBI4UIVPROC) (GLuint index, const GLuint* v0); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBI4USVPROC) (GLuint index, const GLushort* v0); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBIPOINTERPROC) (GLuint index, GLint size, GLenum type, GLsizei stride, const void*pointer); - -#define glBeginConditionalRender GLEW_GET_FUN(__glewBeginConditionalRender) -#define glBeginTransformFeedback GLEW_GET_FUN(__glewBeginTransformFeedback) -#define glBindFragDataLocation GLEW_GET_FUN(__glewBindFragDataLocation) -#define glClampColor GLEW_GET_FUN(__glewClampColor) -#define glClearBufferfi GLEW_GET_FUN(__glewClearBufferfi) -#define glClearBufferfv GLEW_GET_FUN(__glewClearBufferfv) -#define glClearBufferiv GLEW_GET_FUN(__glewClearBufferiv) -#define glClearBufferuiv GLEW_GET_FUN(__glewClearBufferuiv) -#define glColorMaski GLEW_GET_FUN(__glewColorMaski) -#define glDisablei GLEW_GET_FUN(__glewDisablei) -#define glEnablei GLEW_GET_FUN(__glewEnablei) -#define glEndConditionalRender GLEW_GET_FUN(__glewEndConditionalRender) -#define glEndTransformFeedback GLEW_GET_FUN(__glewEndTransformFeedback) -#define glGetBooleani_v GLEW_GET_FUN(__glewGetBooleani_v) -#define glGetFragDataLocation GLEW_GET_FUN(__glewGetFragDataLocation) -#define glGetStringi GLEW_GET_FUN(__glewGetStringi) -#define glGetTexParameterIiv GLEW_GET_FUN(__glewGetTexParameterIiv) -#define glGetTexParameterIuiv GLEW_GET_FUN(__glewGetTexParameterIuiv) -#define glGetTransformFeedbackVarying GLEW_GET_FUN(__glewGetTransformFeedbackVarying) -#define glGetUniformuiv GLEW_GET_FUN(__glewGetUniformuiv) -#define glGetVertexAttribIiv GLEW_GET_FUN(__glewGetVertexAttribIiv) -#define glGetVertexAttribIuiv GLEW_GET_FUN(__glewGetVertexAttribIuiv) -#define glIsEnabledi GLEW_GET_FUN(__glewIsEnabledi) -#define glTexParameterIiv GLEW_GET_FUN(__glewTexParameterIiv) -#define glTexParameterIuiv GLEW_GET_FUN(__glewTexParameterIuiv) -#define glTransformFeedbackVaryings GLEW_GET_FUN(__glewTransformFeedbackVaryings) -#define glUniform1ui GLEW_GET_FUN(__glewUniform1ui) -#define glUniform1uiv GLEW_GET_FUN(__glewUniform1uiv) -#define glUniform2ui GLEW_GET_FUN(__glewUniform2ui) -#define glUniform2uiv GLEW_GET_FUN(__glewUniform2uiv) -#define glUniform3ui GLEW_GET_FUN(__glewUniform3ui) -#define glUniform3uiv GLEW_GET_FUN(__glewUniform3uiv) -#define glUniform4ui GLEW_GET_FUN(__glewUniform4ui) -#define glUniform4uiv GLEW_GET_FUN(__glewUniform4uiv) -#define glVertexAttribI1i GLEW_GET_FUN(__glewVertexAttribI1i) -#define glVertexAttribI1iv GLEW_GET_FUN(__glewVertexAttribI1iv) -#define glVertexAttribI1ui GLEW_GET_FUN(__glewVertexAttribI1ui) -#define glVertexAttribI1uiv GLEW_GET_FUN(__glewVertexAttribI1uiv) -#define glVertexAttribI2i GLEW_GET_FUN(__glewVertexAttribI2i) -#define glVertexAttribI2iv GLEW_GET_FUN(__glewVertexAttribI2iv) -#define glVertexAttribI2ui GLEW_GET_FUN(__glewVertexAttribI2ui) -#define glVertexAttribI2uiv GLEW_GET_FUN(__glewVertexAttribI2uiv) -#define glVertexAttribI3i GLEW_GET_FUN(__glewVertexAttribI3i) -#define glVertexAttribI3iv GLEW_GET_FUN(__glewVertexAttribI3iv) -#define glVertexAttribI3ui GLEW_GET_FUN(__glewVertexAttribI3ui) -#define glVertexAttribI3uiv GLEW_GET_FUN(__glewVertexAttribI3uiv) -#define glVertexAttribI4bv GLEW_GET_FUN(__glewVertexAttribI4bv) -#define glVertexAttribI4i GLEW_GET_FUN(__glewVertexAttribI4i) -#define glVertexAttribI4iv GLEW_GET_FUN(__glewVertexAttribI4iv) -#define glVertexAttribI4sv GLEW_GET_FUN(__glewVertexAttribI4sv) -#define glVertexAttribI4ubv GLEW_GET_FUN(__glewVertexAttribI4ubv) -#define glVertexAttribI4ui GLEW_GET_FUN(__glewVertexAttribI4ui) -#define glVertexAttribI4uiv GLEW_GET_FUN(__glewVertexAttribI4uiv) -#define glVertexAttribI4usv GLEW_GET_FUN(__glewVertexAttribI4usv) -#define glVertexAttribIPointer GLEW_GET_FUN(__glewVertexAttribIPointer) - -#define GLEW_VERSION_3_0 GLEW_GET_VAR(__GLEW_VERSION_3_0) - -#endif /* GL_VERSION_3_0 */ - -/* ----------------------------- GL_VERSION_3_1 ---------------------------- */ - -#ifndef GL_VERSION_3_1 -#define GL_VERSION_3_1 1 - -#define GL_TEXTURE_RECTANGLE 0x84F5 -#define GL_TEXTURE_BINDING_RECTANGLE 0x84F6 -#define GL_PROXY_TEXTURE_RECTANGLE 0x84F7 -#define GL_MAX_RECTANGLE_TEXTURE_SIZE 0x84F8 -#define GL_SAMPLER_2D_RECT 0x8B63 -#define GL_SAMPLER_2D_RECT_SHADOW 0x8B64 -#define GL_TEXTURE_BUFFER 0x8C2A -#define GL_MAX_TEXTURE_BUFFER_SIZE 0x8C2B -#define GL_TEXTURE_BINDING_BUFFER 0x8C2C -#define GL_TEXTURE_BUFFER_DATA_STORE_BINDING 0x8C2D -#define GL_TEXTURE_BUFFER_FORMAT 0x8C2E -#define GL_SAMPLER_BUFFER 0x8DC2 -#define GL_INT_SAMPLER_2D_RECT 0x8DCD -#define GL_INT_SAMPLER_BUFFER 0x8DD0 -#define GL_UNSIGNED_INT_SAMPLER_2D_RECT 0x8DD5 -#define GL_UNSIGNED_INT_SAMPLER_BUFFER 0x8DD8 -#define GL_RED_SNORM 0x8F90 -#define GL_RG_SNORM 0x8F91 -#define GL_RGB_SNORM 0x8F92 -#define GL_RGBA_SNORM 0x8F93 -#define GL_R8_SNORM 0x8F94 -#define GL_RG8_SNORM 0x8F95 -#define GL_RGB8_SNORM 0x8F96 -#define GL_RGBA8_SNORM 0x8F97 -#define GL_R16_SNORM 0x8F98 -#define GL_RG16_SNORM 0x8F99 -#define GL_RGB16_SNORM 0x8F9A -#define GL_RGBA16_SNORM 0x8F9B -#define GL_SIGNED_NORMALIZED 0x8F9C -#define GL_PRIMITIVE_RESTART 0x8F9D -#define GL_PRIMITIVE_RESTART_INDEX 0x8F9E -#define GL_BUFFER_ACCESS_FLAGS 0x911F -#define GL_BUFFER_MAP_LENGTH 0x9120 -#define GL_BUFFER_MAP_OFFSET 0x9121 - -typedef void (GLAPIENTRY * PFNGLDRAWARRAYSINSTANCEDPROC) (GLenum mode, GLint first, GLsizei count, GLsizei primcount); -typedef void (GLAPIENTRY * PFNGLDRAWELEMENTSINSTANCEDPROC) (GLenum mode, GLsizei count, GLenum type, const void* indices, GLsizei primcount); -typedef void (GLAPIENTRY * PFNGLPRIMITIVERESTARTINDEXPROC) (GLuint buffer); -typedef void (GLAPIENTRY * PFNGLTEXBUFFERPROC) (GLenum target, GLenum internalFormat, GLuint buffer); - -#define glDrawArraysInstanced GLEW_GET_FUN(__glewDrawArraysInstanced) -#define glDrawElementsInstanced GLEW_GET_FUN(__glewDrawElementsInstanced) -#define glPrimitiveRestartIndex GLEW_GET_FUN(__glewPrimitiveRestartIndex) -#define glTexBuffer GLEW_GET_FUN(__glewTexBuffer) - -#define GLEW_VERSION_3_1 GLEW_GET_VAR(__GLEW_VERSION_3_1) - -#endif /* GL_VERSION_3_1 */ - -/* ----------------------------- GL_VERSION_3_2 ---------------------------- */ - -#ifndef GL_VERSION_3_2 -#define GL_VERSION_3_2 1 - -#define GL_CONTEXT_CORE_PROFILE_BIT 0x00000001 -#define GL_CONTEXT_COMPATIBILITY_PROFILE_BIT 0x00000002 -#define GL_LINES_ADJACENCY 0x000A -#define GL_LINE_STRIP_ADJACENCY 0x000B -#define GL_TRIANGLES_ADJACENCY 0x000C -#define GL_TRIANGLE_STRIP_ADJACENCY 0x000D -#define GL_PROGRAM_POINT_SIZE 0x8642 -#define GL_GEOMETRY_VERTICES_OUT 0x8916 -#define GL_GEOMETRY_INPUT_TYPE 0x8917 -#define GL_GEOMETRY_OUTPUT_TYPE 0x8918 -#define GL_MAX_GEOMETRY_TEXTURE_IMAGE_UNITS 0x8C29 -#define GL_FRAMEBUFFER_ATTACHMENT_LAYERED 0x8DA7 -#define GL_FRAMEBUFFER_INCOMPLETE_LAYER_TARGETS 0x8DA8 -#define GL_GEOMETRY_SHADER 0x8DD9 -#define GL_MAX_GEOMETRY_UNIFORM_COMPONENTS 0x8DDF -#define GL_MAX_GEOMETRY_OUTPUT_VERTICES 0x8DE0 -#define GL_MAX_GEOMETRY_TOTAL_OUTPUT_COMPONENTS 0x8DE1 -#define GL_MAX_VERTEX_OUTPUT_COMPONENTS 0x9122 -#define GL_MAX_GEOMETRY_INPUT_COMPONENTS 0x9123 -#define GL_MAX_GEOMETRY_OUTPUT_COMPONENTS 0x9124 -#define GL_MAX_FRAGMENT_INPUT_COMPONENTS 0x9125 -#define GL_CONTEXT_PROFILE_MASK 0x9126 - -typedef void (GLAPIENTRY * PFNGLFRAMEBUFFERTEXTUREPROC) (GLenum target, GLenum attachment, GLuint texture, GLint level); -typedef void (GLAPIENTRY * PFNGLGETBUFFERPARAMETERI64VPROC) (GLenum target, GLenum value, GLint64 * data); -typedef void (GLAPIENTRY * PFNGLGETINTEGER64I_VPROC) (GLenum pname, GLuint index, GLint64 * data); - -#define glFramebufferTexture GLEW_GET_FUN(__glewFramebufferTexture) -#define glGetBufferParameteri64v GLEW_GET_FUN(__glewGetBufferParameteri64v) -#define glGetInteger64i_v GLEW_GET_FUN(__glewGetInteger64i_v) - -#define GLEW_VERSION_3_2 GLEW_GET_VAR(__GLEW_VERSION_3_2) - -#endif /* GL_VERSION_3_2 */ - -/* ----------------------------- GL_VERSION_3_3 ---------------------------- */ - -#ifndef GL_VERSION_3_3 -#define GL_VERSION_3_3 1 - -#define GL_VERTEX_ATTRIB_ARRAY_DIVISOR 0x88FE -#define GL_RGB10_A2UI 0x906F - -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBDIVISORPROC) (GLuint index, GLuint divisor); - -#define glVertexAttribDivisor GLEW_GET_FUN(__glewVertexAttribDivisor) - -#define GLEW_VERSION_3_3 GLEW_GET_VAR(__GLEW_VERSION_3_3) - -#endif /* GL_VERSION_3_3 */ - -/* ----------------------------- GL_VERSION_4_0 ---------------------------- */ - -#ifndef GL_VERSION_4_0 -#define GL_VERSION_4_0 1 - -#define GL_SAMPLE_SHADING 0x8C36 -#define GL_MIN_SAMPLE_SHADING_VALUE 0x8C37 -#define GL_MIN_PROGRAM_TEXTURE_GATHER_OFFSET 0x8E5E -#define GL_MAX_PROGRAM_TEXTURE_GATHER_OFFSET 0x8E5F -#define GL_MAX_PROGRAM_TEXTURE_GATHER_COMPONENTS 0x8F9F -#define GL_TEXTURE_CUBE_MAP_ARRAY 0x9009 -#define GL_TEXTURE_BINDING_CUBE_MAP_ARRAY 0x900A -#define GL_PROXY_TEXTURE_CUBE_MAP_ARRAY 0x900B -#define GL_SAMPLER_CUBE_MAP_ARRAY 0x900C -#define GL_SAMPLER_CUBE_MAP_ARRAY_SHADOW 0x900D -#define GL_INT_SAMPLER_CUBE_MAP_ARRAY 0x900E -#define GL_UNSIGNED_INT_SAMPLER_CUBE_MAP_ARRAY 0x900F - -typedef void (GLAPIENTRY * PFNGLBLENDEQUATIONSEPARATEIPROC) (GLuint buf, GLenum modeRGB, GLenum modeAlpha); -typedef void (GLAPIENTRY * PFNGLBLENDEQUATIONIPROC) (GLuint buf, GLenum mode); -typedef void (GLAPIENTRY * PFNGLBLENDFUNCSEPARATEIPROC) (GLuint buf, GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha); -typedef void (GLAPIENTRY * PFNGLBLENDFUNCIPROC) (GLuint buf, GLenum src, GLenum dst); -typedef void (GLAPIENTRY * PFNGLMINSAMPLESHADINGPROC) (GLclampf value); - -#define glBlendEquationSeparatei GLEW_GET_FUN(__glewBlendEquationSeparatei) -#define glBlendEquationi GLEW_GET_FUN(__glewBlendEquationi) -#define glBlendFuncSeparatei GLEW_GET_FUN(__glewBlendFuncSeparatei) -#define glBlendFunci GLEW_GET_FUN(__glewBlendFunci) -#define glMinSampleShading GLEW_GET_FUN(__glewMinSampleShading) - -#define GLEW_VERSION_4_0 GLEW_GET_VAR(__GLEW_VERSION_4_0) - -#endif /* GL_VERSION_4_0 */ - -/* ----------------------------- GL_VERSION_4_1 ---------------------------- */ - -#ifndef GL_VERSION_4_1 -#define GL_VERSION_4_1 1 - -#define GLEW_VERSION_4_1 GLEW_GET_VAR(__GLEW_VERSION_4_1) - -#endif /* GL_VERSION_4_1 */ - -/* ----------------------------- GL_VERSION_4_2 ---------------------------- */ - -#ifndef GL_VERSION_4_2 -#define GL_VERSION_4_2 1 - -#define GL_TRANSFORM_FEEDBACK_PAUSED 0x8E23 -#define GL_TRANSFORM_FEEDBACK_ACTIVE 0x8E24 -#define GL_COMPRESSED_RGBA_BPTC_UNORM 0x8E8C -#define GL_COMPRESSED_SRGB_ALPHA_BPTC_UNORM 0x8E8D -#define GL_COMPRESSED_RGB_BPTC_SIGNED_FLOAT 0x8E8E -#define GL_COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT 0x8E8F -#define GL_COPY_READ_BUFFER_BINDING 0x8F36 -#define GL_COPY_WRITE_BUFFER_BINDING 0x8F37 - -#define GLEW_VERSION_4_2 GLEW_GET_VAR(__GLEW_VERSION_4_2) - -#endif /* GL_VERSION_4_2 */ - -/* ----------------------------- GL_VERSION_4_3 ---------------------------- */ - -#ifndef GL_VERSION_4_3 -#define GL_VERSION_4_3 1 - -#define GL_NUM_SHADING_LANGUAGE_VERSIONS 0x82E9 -#define GL_VERTEX_ATTRIB_ARRAY_LONG 0x874E - -#define GLEW_VERSION_4_3 GLEW_GET_VAR(__GLEW_VERSION_4_3) - -#endif /* GL_VERSION_4_3 */ - -/* ----------------------------- GL_VERSION_4_4 ---------------------------- */ - -#ifndef GL_VERSION_4_4 -#define GL_VERSION_4_4 1 - -#define GL_PRIMITIVE_RESTART_FOR_PATCHES_SUPPORTED 0x8221 -#define GL_MAX_VERTEX_ATTRIB_STRIDE 0x82E5 -#define GL_TEXTURE_BUFFER_BINDING 0x8C2A - -#define GLEW_VERSION_4_4 GLEW_GET_VAR(__GLEW_VERSION_4_4) - -#endif /* GL_VERSION_4_4 */ - -/* ----------------------------- GL_VERSION_4_5 ---------------------------- */ - -#ifndef GL_VERSION_4_5 -#define GL_VERSION_4_5 1 - -#define GL_CONTEXT_FLAG_ROBUST_ACCESS_BIT 0x00000004 - -typedef GLenum (GLAPIENTRY * PFNGLGETGRAPHICSRESETSTATUSPROC) (void); -typedef void (GLAPIENTRY * PFNGLGETNCOMPRESSEDTEXIMAGEPROC) (GLenum target, GLint lod, GLsizei bufSize, GLvoid *pixels); -typedef void (GLAPIENTRY * PFNGLGETNTEXIMAGEPROC) (GLenum tex, GLint level, GLenum format, GLenum type, GLsizei bufSize, GLvoid *pixels); -typedef void (GLAPIENTRY * PFNGLGETNUNIFORMDVPROC) (GLuint program, GLint location, GLsizei bufSize, GLdouble *params); - -#define glGetGraphicsResetStatus GLEW_GET_FUN(__glewGetGraphicsResetStatus) -#define glGetnCompressedTexImage GLEW_GET_FUN(__glewGetnCompressedTexImage) -#define glGetnTexImage GLEW_GET_FUN(__glewGetnTexImage) -#define glGetnUniformdv GLEW_GET_FUN(__glewGetnUniformdv) - -#define GLEW_VERSION_4_5 GLEW_GET_VAR(__GLEW_VERSION_4_5) - -#endif /* GL_VERSION_4_5 */ - -/* -------------------------- GL_3DFX_multisample -------------------------- */ - -#ifndef GL_3DFX_multisample -#define GL_3DFX_multisample 1 - -#define GL_MULTISAMPLE_3DFX 0x86B2 -#define GL_SAMPLE_BUFFERS_3DFX 0x86B3 -#define GL_SAMPLES_3DFX 0x86B4 -#define GL_MULTISAMPLE_BIT_3DFX 0x20000000 - -#define GLEW_3DFX_multisample GLEW_GET_VAR(__GLEW_3DFX_multisample) - -#endif /* GL_3DFX_multisample */ - -/* ---------------------------- GL_3DFX_tbuffer ---------------------------- */ - -#ifndef GL_3DFX_tbuffer -#define GL_3DFX_tbuffer 1 - -typedef void (GLAPIENTRY * PFNGLTBUFFERMASK3DFXPROC) (GLuint mask); - -#define glTbufferMask3DFX GLEW_GET_FUN(__glewTbufferMask3DFX) - -#define GLEW_3DFX_tbuffer GLEW_GET_VAR(__GLEW_3DFX_tbuffer) - -#endif /* GL_3DFX_tbuffer */ - -/* -------------------- GL_3DFX_texture_compression_FXT1 ------------------- */ - -#ifndef GL_3DFX_texture_compression_FXT1 -#define GL_3DFX_texture_compression_FXT1 1 - -#define GL_COMPRESSED_RGB_FXT1_3DFX 0x86B0 -#define GL_COMPRESSED_RGBA_FXT1_3DFX 0x86B1 - -#define GLEW_3DFX_texture_compression_FXT1 GLEW_GET_VAR(__GLEW_3DFX_texture_compression_FXT1) - -#endif /* GL_3DFX_texture_compression_FXT1 */ - -/* ----------------------- GL_AMD_blend_minmax_factor ---------------------- */ - -#ifndef GL_AMD_blend_minmax_factor -#define GL_AMD_blend_minmax_factor 1 - -#define GL_FACTOR_MIN_AMD 0x901C -#define GL_FACTOR_MAX_AMD 0x901D - -#define GLEW_AMD_blend_minmax_factor GLEW_GET_VAR(__GLEW_AMD_blend_minmax_factor) - -#endif /* GL_AMD_blend_minmax_factor */ - -/* ----------------------- GL_AMD_conservative_depth ----------------------- */ - -#ifndef GL_AMD_conservative_depth -#define GL_AMD_conservative_depth 1 - -#define GLEW_AMD_conservative_depth GLEW_GET_VAR(__GLEW_AMD_conservative_depth) - -#endif /* GL_AMD_conservative_depth */ - -/* -------------------------- GL_AMD_debug_output -------------------------- */ - -#ifndef GL_AMD_debug_output -#define GL_AMD_debug_output 1 - -#define GL_MAX_DEBUG_MESSAGE_LENGTH_AMD 0x9143 -#define GL_MAX_DEBUG_LOGGED_MESSAGES_AMD 0x9144 -#define GL_DEBUG_LOGGED_MESSAGES_AMD 0x9145 -#define GL_DEBUG_SEVERITY_HIGH_AMD 0x9146 -#define GL_DEBUG_SEVERITY_MEDIUM_AMD 0x9147 -#define GL_DEBUG_SEVERITY_LOW_AMD 0x9148 -#define GL_DEBUG_CATEGORY_API_ERROR_AMD 0x9149 -#define GL_DEBUG_CATEGORY_WINDOW_SYSTEM_AMD 0x914A -#define GL_DEBUG_CATEGORY_DEPRECATION_AMD 0x914B -#define GL_DEBUG_CATEGORY_UNDEFINED_BEHAVIOR_AMD 0x914C -#define GL_DEBUG_CATEGORY_PERFORMANCE_AMD 0x914D -#define GL_DEBUG_CATEGORY_SHADER_COMPILER_AMD 0x914E -#define GL_DEBUG_CATEGORY_APPLICATION_AMD 0x914F -#define GL_DEBUG_CATEGORY_OTHER_AMD 0x9150 - -typedef void (GLAPIENTRY *GLDEBUGPROCAMD)(GLuint id, GLenum category, GLenum severity, GLsizei length, const GLchar* message, void* userParam); - -typedef void (GLAPIENTRY * PFNGLDEBUGMESSAGECALLBACKAMDPROC) (GLDEBUGPROCAMD callback, void *userParam); -typedef void (GLAPIENTRY * PFNGLDEBUGMESSAGEENABLEAMDPROC) (GLenum category, GLenum severity, GLsizei count, const GLuint* ids, GLboolean enabled); -typedef void (GLAPIENTRY * PFNGLDEBUGMESSAGEINSERTAMDPROC) (GLenum category, GLenum severity, GLuint id, GLsizei length, const GLchar* buf); -typedef GLuint (GLAPIENTRY * PFNGLGETDEBUGMESSAGELOGAMDPROC) (GLuint count, GLsizei bufsize, GLenum* categories, GLuint* severities, GLuint* ids, GLsizei* lengths, GLchar* message); - -#define glDebugMessageCallbackAMD GLEW_GET_FUN(__glewDebugMessageCallbackAMD) -#define glDebugMessageEnableAMD GLEW_GET_FUN(__glewDebugMessageEnableAMD) -#define glDebugMessageInsertAMD GLEW_GET_FUN(__glewDebugMessageInsertAMD) -#define glGetDebugMessageLogAMD GLEW_GET_FUN(__glewGetDebugMessageLogAMD) - -#define GLEW_AMD_debug_output GLEW_GET_VAR(__GLEW_AMD_debug_output) - -#endif /* GL_AMD_debug_output */ - -/* ---------------------- GL_AMD_depth_clamp_separate ---------------------- */ - -#ifndef GL_AMD_depth_clamp_separate -#define GL_AMD_depth_clamp_separate 1 - -#define GL_DEPTH_CLAMP_NEAR_AMD 0x901E -#define GL_DEPTH_CLAMP_FAR_AMD 0x901F - -#define GLEW_AMD_depth_clamp_separate GLEW_GET_VAR(__GLEW_AMD_depth_clamp_separate) - -#endif /* GL_AMD_depth_clamp_separate */ - -/* ----------------------- GL_AMD_draw_buffers_blend ----------------------- */ - -#ifndef GL_AMD_draw_buffers_blend -#define GL_AMD_draw_buffers_blend 1 - -typedef void (GLAPIENTRY * PFNGLBLENDEQUATIONINDEXEDAMDPROC) (GLuint buf, GLenum mode); -typedef void (GLAPIENTRY * PFNGLBLENDEQUATIONSEPARATEINDEXEDAMDPROC) (GLuint buf, GLenum modeRGB, GLenum modeAlpha); -typedef void (GLAPIENTRY * PFNGLBLENDFUNCINDEXEDAMDPROC) (GLuint buf, GLenum src, GLenum dst); -typedef void (GLAPIENTRY * PFNGLBLENDFUNCSEPARATEINDEXEDAMDPROC) (GLuint buf, GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha); - -#define glBlendEquationIndexedAMD GLEW_GET_FUN(__glewBlendEquationIndexedAMD) -#define glBlendEquationSeparateIndexedAMD GLEW_GET_FUN(__glewBlendEquationSeparateIndexedAMD) -#define glBlendFuncIndexedAMD GLEW_GET_FUN(__glewBlendFuncIndexedAMD) -#define glBlendFuncSeparateIndexedAMD GLEW_GET_FUN(__glewBlendFuncSeparateIndexedAMD) - -#define GLEW_AMD_draw_buffers_blend GLEW_GET_VAR(__GLEW_AMD_draw_buffers_blend) - -#endif /* GL_AMD_draw_buffers_blend */ - -/* --------------------------- GL_AMD_gcn_shader --------------------------- */ - -#ifndef GL_AMD_gcn_shader -#define GL_AMD_gcn_shader 1 - -#define GLEW_AMD_gcn_shader GLEW_GET_VAR(__GLEW_AMD_gcn_shader) - -#endif /* GL_AMD_gcn_shader */ - -/* ------------------------ GL_AMD_gpu_shader_int64 ------------------------ */ - -#ifndef GL_AMD_gpu_shader_int64 -#define GL_AMD_gpu_shader_int64 1 - -#define GLEW_AMD_gpu_shader_int64 GLEW_GET_VAR(__GLEW_AMD_gpu_shader_int64) - -#endif /* GL_AMD_gpu_shader_int64 */ - -/* ---------------------- GL_AMD_interleaved_elements ---------------------- */ - -#ifndef GL_AMD_interleaved_elements -#define GL_AMD_interleaved_elements 1 - -#define GL_RED 0x1903 -#define GL_GREEN 0x1904 -#define GL_BLUE 0x1905 -#define GL_ALPHA 0x1906 -#define GL_RG8UI 0x8238 -#define GL_RG16UI 0x823A -#define GL_RGBA8UI 0x8D7C -#define GL_VERTEX_ELEMENT_SWIZZLE_AMD 0x91A4 -#define GL_VERTEX_ID_SWIZZLE_AMD 0x91A5 - -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBPARAMETERIAMDPROC) (GLuint index, GLenum pname, GLint param); - -#define glVertexAttribParameteriAMD GLEW_GET_FUN(__glewVertexAttribParameteriAMD) - -#define GLEW_AMD_interleaved_elements GLEW_GET_VAR(__GLEW_AMD_interleaved_elements) - -#endif /* GL_AMD_interleaved_elements */ - -/* ----------------------- GL_AMD_multi_draw_indirect ---------------------- */ - -#ifndef GL_AMD_multi_draw_indirect -#define GL_AMD_multi_draw_indirect 1 - -typedef void (GLAPIENTRY * PFNGLMULTIDRAWARRAYSINDIRECTAMDPROC) (GLenum mode, const void *indirect, GLsizei primcount, GLsizei stride); -typedef void (GLAPIENTRY * PFNGLMULTIDRAWELEMENTSINDIRECTAMDPROC) (GLenum mode, GLenum type, const void *indirect, GLsizei primcount, GLsizei stride); - -#define glMultiDrawArraysIndirectAMD GLEW_GET_FUN(__glewMultiDrawArraysIndirectAMD) -#define glMultiDrawElementsIndirectAMD GLEW_GET_FUN(__glewMultiDrawElementsIndirectAMD) - -#define GLEW_AMD_multi_draw_indirect GLEW_GET_VAR(__GLEW_AMD_multi_draw_indirect) - -#endif /* GL_AMD_multi_draw_indirect */ - -/* ------------------------- GL_AMD_name_gen_delete ------------------------ */ - -#ifndef GL_AMD_name_gen_delete -#define GL_AMD_name_gen_delete 1 - -#define GL_DATA_BUFFER_AMD 0x9151 -#define GL_PERFORMANCE_MONITOR_AMD 0x9152 -#define GL_QUERY_OBJECT_AMD 0x9153 -#define GL_VERTEX_ARRAY_OBJECT_AMD 0x9154 -#define GL_SAMPLER_OBJECT_AMD 0x9155 - -typedef void (GLAPIENTRY * PFNGLDELETENAMESAMDPROC) (GLenum identifier, GLuint num, const GLuint* names); -typedef void (GLAPIENTRY * PFNGLGENNAMESAMDPROC) (GLenum identifier, GLuint num, GLuint* names); -typedef GLboolean (GLAPIENTRY * PFNGLISNAMEAMDPROC) (GLenum identifier, GLuint name); - -#define glDeleteNamesAMD GLEW_GET_FUN(__glewDeleteNamesAMD) -#define glGenNamesAMD GLEW_GET_FUN(__glewGenNamesAMD) -#define glIsNameAMD GLEW_GET_FUN(__glewIsNameAMD) - -#define GLEW_AMD_name_gen_delete GLEW_GET_VAR(__GLEW_AMD_name_gen_delete) - -#endif /* GL_AMD_name_gen_delete */ - -/* ---------------------- GL_AMD_occlusion_query_event --------------------- */ - -#ifndef GL_AMD_occlusion_query_event -#define GL_AMD_occlusion_query_event 1 - -#define GL_QUERY_DEPTH_PASS_EVENT_BIT_AMD 0x00000001 -#define GL_QUERY_DEPTH_FAIL_EVENT_BIT_AMD 0x00000002 -#define GL_QUERY_STENCIL_FAIL_EVENT_BIT_AMD 0x00000004 -#define GL_QUERY_DEPTH_BOUNDS_FAIL_EVENT_BIT_AMD 0x00000008 -#define GL_OCCLUSION_QUERY_EVENT_MASK_AMD 0x874F -#define GL_QUERY_ALL_EVENT_BITS_AMD 0xFFFFFFFF - -typedef void (GLAPIENTRY * PFNGLQUERYOBJECTPARAMETERUIAMDPROC) (GLenum target, GLuint id, GLenum pname, GLuint param); - -#define glQueryObjectParameteruiAMD GLEW_GET_FUN(__glewQueryObjectParameteruiAMD) - -#define GLEW_AMD_occlusion_query_event GLEW_GET_VAR(__GLEW_AMD_occlusion_query_event) - -#endif /* GL_AMD_occlusion_query_event */ - -/* ----------------------- GL_AMD_performance_monitor ---------------------- */ - -#ifndef GL_AMD_performance_monitor -#define GL_AMD_performance_monitor 1 - -#define GL_COUNTER_TYPE_AMD 0x8BC0 -#define GL_COUNTER_RANGE_AMD 0x8BC1 -#define GL_UNSIGNED_INT64_AMD 0x8BC2 -#define GL_PERCENTAGE_AMD 0x8BC3 -#define GL_PERFMON_RESULT_AVAILABLE_AMD 0x8BC4 -#define GL_PERFMON_RESULT_SIZE_AMD 0x8BC5 -#define GL_PERFMON_RESULT_AMD 0x8BC6 - -typedef void (GLAPIENTRY * PFNGLBEGINPERFMONITORAMDPROC) (GLuint monitor); -typedef void (GLAPIENTRY * PFNGLDELETEPERFMONITORSAMDPROC) (GLsizei n, GLuint* monitors); -typedef void (GLAPIENTRY * PFNGLENDPERFMONITORAMDPROC) (GLuint monitor); -typedef void (GLAPIENTRY * PFNGLGENPERFMONITORSAMDPROC) (GLsizei n, GLuint* monitors); -typedef void (GLAPIENTRY * PFNGLGETPERFMONITORCOUNTERDATAAMDPROC) (GLuint monitor, GLenum pname, GLsizei dataSize, GLuint* data, GLint *bytesWritten); -typedef void (GLAPIENTRY * PFNGLGETPERFMONITORCOUNTERINFOAMDPROC) (GLuint group, GLuint counter, GLenum pname, void *data); -typedef void (GLAPIENTRY * PFNGLGETPERFMONITORCOUNTERSTRINGAMDPROC) (GLuint group, GLuint counter, GLsizei bufSize, GLsizei* length, GLchar *counterString); -typedef void (GLAPIENTRY * PFNGLGETPERFMONITORCOUNTERSAMDPROC) (GLuint group, GLint* numCounters, GLint *maxActiveCounters, GLsizei countersSize, GLuint *counters); -typedef void (GLAPIENTRY * PFNGLGETPERFMONITORGROUPSTRINGAMDPROC) (GLuint group, GLsizei bufSize, GLsizei* length, GLchar *groupString); -typedef void (GLAPIENTRY * PFNGLGETPERFMONITORGROUPSAMDPROC) (GLint* numGroups, GLsizei groupsSize, GLuint *groups); -typedef void (GLAPIENTRY * PFNGLSELECTPERFMONITORCOUNTERSAMDPROC) (GLuint monitor, GLboolean enable, GLuint group, GLint numCounters, GLuint* counterList); - -#define glBeginPerfMonitorAMD GLEW_GET_FUN(__glewBeginPerfMonitorAMD) -#define glDeletePerfMonitorsAMD GLEW_GET_FUN(__glewDeletePerfMonitorsAMD) -#define glEndPerfMonitorAMD GLEW_GET_FUN(__glewEndPerfMonitorAMD) -#define glGenPerfMonitorsAMD GLEW_GET_FUN(__glewGenPerfMonitorsAMD) -#define glGetPerfMonitorCounterDataAMD GLEW_GET_FUN(__glewGetPerfMonitorCounterDataAMD) -#define glGetPerfMonitorCounterInfoAMD GLEW_GET_FUN(__glewGetPerfMonitorCounterInfoAMD) -#define glGetPerfMonitorCounterStringAMD GLEW_GET_FUN(__glewGetPerfMonitorCounterStringAMD) -#define glGetPerfMonitorCountersAMD GLEW_GET_FUN(__glewGetPerfMonitorCountersAMD) -#define glGetPerfMonitorGroupStringAMD GLEW_GET_FUN(__glewGetPerfMonitorGroupStringAMD) -#define glGetPerfMonitorGroupsAMD GLEW_GET_FUN(__glewGetPerfMonitorGroupsAMD) -#define glSelectPerfMonitorCountersAMD GLEW_GET_FUN(__glewSelectPerfMonitorCountersAMD) - -#define GLEW_AMD_performance_monitor GLEW_GET_VAR(__GLEW_AMD_performance_monitor) - -#endif /* GL_AMD_performance_monitor */ - -/* -------------------------- GL_AMD_pinned_memory ------------------------- */ - -#ifndef GL_AMD_pinned_memory -#define GL_AMD_pinned_memory 1 - -#define GL_EXTERNAL_VIRTUAL_MEMORY_BUFFER_AMD 0x9160 - -#define GLEW_AMD_pinned_memory GLEW_GET_VAR(__GLEW_AMD_pinned_memory) - -#endif /* GL_AMD_pinned_memory */ - -/* ----------------------- GL_AMD_query_buffer_object ---------------------- */ - -#ifndef GL_AMD_query_buffer_object -#define GL_AMD_query_buffer_object 1 - -#define GL_QUERY_BUFFER_AMD 0x9192 -#define GL_QUERY_BUFFER_BINDING_AMD 0x9193 -#define GL_QUERY_RESULT_NO_WAIT_AMD 0x9194 - -#define GLEW_AMD_query_buffer_object GLEW_GET_VAR(__GLEW_AMD_query_buffer_object) - -#endif /* GL_AMD_query_buffer_object */ - -/* ------------------------ GL_AMD_sample_positions ------------------------ */ - -#ifndef GL_AMD_sample_positions -#define GL_AMD_sample_positions 1 - -#define GL_SUBSAMPLE_DISTANCE_AMD 0x883F - -typedef void (GLAPIENTRY * PFNGLSETMULTISAMPLEFVAMDPROC) (GLenum pname, GLuint index, const GLfloat* val); - -#define glSetMultisamplefvAMD GLEW_GET_FUN(__glewSetMultisamplefvAMD) - -#define GLEW_AMD_sample_positions GLEW_GET_VAR(__GLEW_AMD_sample_positions) - -#endif /* GL_AMD_sample_positions */ - -/* ------------------ GL_AMD_seamless_cubemap_per_texture ------------------ */ - -#ifndef GL_AMD_seamless_cubemap_per_texture -#define GL_AMD_seamless_cubemap_per_texture 1 - -#define GL_TEXTURE_CUBE_MAP_SEAMLESS_ARB 0x884F - -#define GLEW_AMD_seamless_cubemap_per_texture GLEW_GET_VAR(__GLEW_AMD_seamless_cubemap_per_texture) - -#endif /* GL_AMD_seamless_cubemap_per_texture */ - -/* -------------------- GL_AMD_shader_atomic_counter_ops ------------------- */ - -#ifndef GL_AMD_shader_atomic_counter_ops -#define GL_AMD_shader_atomic_counter_ops 1 - -#define GLEW_AMD_shader_atomic_counter_ops GLEW_GET_VAR(__GLEW_AMD_shader_atomic_counter_ops) - -#endif /* GL_AMD_shader_atomic_counter_ops */ - -/* ---------------- GL_AMD_shader_explicit_vertex_parameter ---------------- */ - -#ifndef GL_AMD_shader_explicit_vertex_parameter -#define GL_AMD_shader_explicit_vertex_parameter 1 - -#define GLEW_AMD_shader_explicit_vertex_parameter GLEW_GET_VAR(__GLEW_AMD_shader_explicit_vertex_parameter) - -#endif /* GL_AMD_shader_explicit_vertex_parameter */ - -/* ---------------------- GL_AMD_shader_stencil_export --------------------- */ - -#ifndef GL_AMD_shader_stencil_export -#define GL_AMD_shader_stencil_export 1 - -#define GLEW_AMD_shader_stencil_export GLEW_GET_VAR(__GLEW_AMD_shader_stencil_export) - -#endif /* GL_AMD_shader_stencil_export */ - -/* ------------------- GL_AMD_shader_stencil_value_export ------------------ */ - -#ifndef GL_AMD_shader_stencil_value_export -#define GL_AMD_shader_stencil_value_export 1 - -#define GLEW_AMD_shader_stencil_value_export GLEW_GET_VAR(__GLEW_AMD_shader_stencil_value_export) - -#endif /* GL_AMD_shader_stencil_value_export */ - -/* ---------------------- GL_AMD_shader_trinary_minmax --------------------- */ - -#ifndef GL_AMD_shader_trinary_minmax -#define GL_AMD_shader_trinary_minmax 1 - -#define GLEW_AMD_shader_trinary_minmax GLEW_GET_VAR(__GLEW_AMD_shader_trinary_minmax) - -#endif /* GL_AMD_shader_trinary_minmax */ - -/* ------------------------- GL_AMD_sparse_texture ------------------------- */ - -#ifndef GL_AMD_sparse_texture -#define GL_AMD_sparse_texture 1 - -#define GL_TEXTURE_STORAGE_SPARSE_BIT_AMD 0x00000001 -#define GL_VIRTUAL_PAGE_SIZE_X_AMD 0x9195 -#define GL_VIRTUAL_PAGE_SIZE_Y_AMD 0x9196 -#define GL_VIRTUAL_PAGE_SIZE_Z_AMD 0x9197 -#define GL_MAX_SPARSE_TEXTURE_SIZE_AMD 0x9198 -#define GL_MAX_SPARSE_3D_TEXTURE_SIZE_AMD 0x9199 -#define GL_MAX_SPARSE_ARRAY_TEXTURE_LAYERS 0x919A -#define GL_MIN_SPARSE_LEVEL_AMD 0x919B -#define GL_MIN_LOD_WARNING_AMD 0x919C - -typedef void (GLAPIENTRY * PFNGLTEXSTORAGESPARSEAMDPROC) (GLenum target, GLenum internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLsizei layers, GLbitfield flags); -typedef void (GLAPIENTRY * PFNGLTEXTURESTORAGESPARSEAMDPROC) (GLuint texture, GLenum target, GLenum internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLsizei layers, GLbitfield flags); - -#define glTexStorageSparseAMD GLEW_GET_FUN(__glewTexStorageSparseAMD) -#define glTextureStorageSparseAMD GLEW_GET_FUN(__glewTextureStorageSparseAMD) - -#define GLEW_AMD_sparse_texture GLEW_GET_VAR(__GLEW_AMD_sparse_texture) - -#endif /* GL_AMD_sparse_texture */ - -/* ------------------- GL_AMD_stencil_operation_extended ------------------- */ - -#ifndef GL_AMD_stencil_operation_extended -#define GL_AMD_stencil_operation_extended 1 - -#define GL_SET_AMD 0x874A -#define GL_REPLACE_VALUE_AMD 0x874B -#define GL_STENCIL_OP_VALUE_AMD 0x874C -#define GL_STENCIL_BACK_OP_VALUE_AMD 0x874D - -typedef void (GLAPIENTRY * PFNGLSTENCILOPVALUEAMDPROC) (GLenum face, GLuint value); - -#define glStencilOpValueAMD GLEW_GET_FUN(__glewStencilOpValueAMD) - -#define GLEW_AMD_stencil_operation_extended GLEW_GET_VAR(__GLEW_AMD_stencil_operation_extended) - -#endif /* GL_AMD_stencil_operation_extended */ - -/* ------------------------ GL_AMD_texture_texture4 ------------------------ */ - -#ifndef GL_AMD_texture_texture4 -#define GL_AMD_texture_texture4 1 - -#define GLEW_AMD_texture_texture4 GLEW_GET_VAR(__GLEW_AMD_texture_texture4) - -#endif /* GL_AMD_texture_texture4 */ - -/* --------------- GL_AMD_transform_feedback3_lines_triangles -------------- */ - -#ifndef GL_AMD_transform_feedback3_lines_triangles -#define GL_AMD_transform_feedback3_lines_triangles 1 - -#define GLEW_AMD_transform_feedback3_lines_triangles GLEW_GET_VAR(__GLEW_AMD_transform_feedback3_lines_triangles) - -#endif /* GL_AMD_transform_feedback3_lines_triangles */ - -/* ----------------------- GL_AMD_transform_feedback4 ---------------------- */ - -#ifndef GL_AMD_transform_feedback4 -#define GL_AMD_transform_feedback4 1 - -#define GL_STREAM_RASTERIZATION_AMD 0x91A0 - -#define GLEW_AMD_transform_feedback4 GLEW_GET_VAR(__GLEW_AMD_transform_feedback4) - -#endif /* GL_AMD_transform_feedback4 */ - -/* ----------------------- GL_AMD_vertex_shader_layer ---------------------- */ - -#ifndef GL_AMD_vertex_shader_layer -#define GL_AMD_vertex_shader_layer 1 - -#define GLEW_AMD_vertex_shader_layer GLEW_GET_VAR(__GLEW_AMD_vertex_shader_layer) - -#endif /* GL_AMD_vertex_shader_layer */ - -/* -------------------- GL_AMD_vertex_shader_tessellator ------------------- */ - -#ifndef GL_AMD_vertex_shader_tessellator -#define GL_AMD_vertex_shader_tessellator 1 - -#define GL_SAMPLER_BUFFER_AMD 0x9001 -#define GL_INT_SAMPLER_BUFFER_AMD 0x9002 -#define GL_UNSIGNED_INT_SAMPLER_BUFFER_AMD 0x9003 -#define GL_TESSELLATION_MODE_AMD 0x9004 -#define GL_TESSELLATION_FACTOR_AMD 0x9005 -#define GL_DISCRETE_AMD 0x9006 -#define GL_CONTINUOUS_AMD 0x9007 - -typedef void (GLAPIENTRY * PFNGLTESSELLATIONFACTORAMDPROC) (GLfloat factor); -typedef void (GLAPIENTRY * PFNGLTESSELLATIONMODEAMDPROC) (GLenum mode); - -#define glTessellationFactorAMD GLEW_GET_FUN(__glewTessellationFactorAMD) -#define glTessellationModeAMD GLEW_GET_FUN(__glewTessellationModeAMD) - -#define GLEW_AMD_vertex_shader_tessellator GLEW_GET_VAR(__GLEW_AMD_vertex_shader_tessellator) - -#endif /* GL_AMD_vertex_shader_tessellator */ - -/* ------------------ GL_AMD_vertex_shader_viewport_index ------------------ */ - -#ifndef GL_AMD_vertex_shader_viewport_index -#define GL_AMD_vertex_shader_viewport_index 1 - -#define GLEW_AMD_vertex_shader_viewport_index GLEW_GET_VAR(__GLEW_AMD_vertex_shader_viewport_index) - -#endif /* GL_AMD_vertex_shader_viewport_index */ - -/* ------------------------- GL_ANGLE_depth_texture ------------------------ */ - -#ifndef GL_ANGLE_depth_texture -#define GL_ANGLE_depth_texture 1 - -#define GLEW_ANGLE_depth_texture GLEW_GET_VAR(__GLEW_ANGLE_depth_texture) - -#endif /* GL_ANGLE_depth_texture */ - -/* ----------------------- GL_ANGLE_framebuffer_blit ----------------------- */ - -#ifndef GL_ANGLE_framebuffer_blit -#define GL_ANGLE_framebuffer_blit 1 - -#define GL_DRAW_FRAMEBUFFER_BINDING_ANGLE 0x8CA6 -#define GL_READ_FRAMEBUFFER_ANGLE 0x8CA8 -#define GL_DRAW_FRAMEBUFFER_ANGLE 0x8CA9 -#define GL_READ_FRAMEBUFFER_BINDING_ANGLE 0x8CAA - -typedef void (GLAPIENTRY * PFNGLBLITFRAMEBUFFERANGLEPROC) (GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter); - -#define glBlitFramebufferANGLE GLEW_GET_FUN(__glewBlitFramebufferANGLE) - -#define GLEW_ANGLE_framebuffer_blit GLEW_GET_VAR(__GLEW_ANGLE_framebuffer_blit) - -#endif /* GL_ANGLE_framebuffer_blit */ - -/* -------------------- GL_ANGLE_framebuffer_multisample ------------------- */ - -#ifndef GL_ANGLE_framebuffer_multisample -#define GL_ANGLE_framebuffer_multisample 1 - -#define GL_RENDERBUFFER_SAMPLES_ANGLE 0x8CAB -#define GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE_ANGLE 0x8D56 -#define GL_MAX_SAMPLES_ANGLE 0x8D57 - -typedef void (GLAPIENTRY * PFNGLRENDERBUFFERSTORAGEMULTISAMPLEANGLEPROC) (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height); - -#define glRenderbufferStorageMultisampleANGLE GLEW_GET_FUN(__glewRenderbufferStorageMultisampleANGLE) - -#define GLEW_ANGLE_framebuffer_multisample GLEW_GET_VAR(__GLEW_ANGLE_framebuffer_multisample) - -#endif /* GL_ANGLE_framebuffer_multisample */ - -/* ----------------------- GL_ANGLE_instanced_arrays ----------------------- */ - -#ifndef GL_ANGLE_instanced_arrays -#define GL_ANGLE_instanced_arrays 1 - -#define GL_VERTEX_ATTRIB_ARRAY_DIVISOR_ANGLE 0x88FE - -typedef void (GLAPIENTRY * PFNGLDRAWARRAYSINSTANCEDANGLEPROC) (GLenum mode, GLint first, GLsizei count, GLsizei primcount); -typedef void (GLAPIENTRY * PFNGLDRAWELEMENTSINSTANCEDANGLEPROC) (GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei primcount); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBDIVISORANGLEPROC) (GLuint index, GLuint divisor); - -#define glDrawArraysInstancedANGLE GLEW_GET_FUN(__glewDrawArraysInstancedANGLE) -#define glDrawElementsInstancedANGLE GLEW_GET_FUN(__glewDrawElementsInstancedANGLE) -#define glVertexAttribDivisorANGLE GLEW_GET_FUN(__glewVertexAttribDivisorANGLE) - -#define GLEW_ANGLE_instanced_arrays GLEW_GET_VAR(__GLEW_ANGLE_instanced_arrays) - -#endif /* GL_ANGLE_instanced_arrays */ - -/* -------------------- GL_ANGLE_pack_reverse_row_order -------------------- */ - -#ifndef GL_ANGLE_pack_reverse_row_order -#define GL_ANGLE_pack_reverse_row_order 1 - -#define GL_PACK_REVERSE_ROW_ORDER_ANGLE 0x93A4 - -#define GLEW_ANGLE_pack_reverse_row_order GLEW_GET_VAR(__GLEW_ANGLE_pack_reverse_row_order) - -#endif /* GL_ANGLE_pack_reverse_row_order */ - -/* ------------------------ GL_ANGLE_program_binary ------------------------ */ - -#ifndef GL_ANGLE_program_binary -#define GL_ANGLE_program_binary 1 - -#define GL_PROGRAM_BINARY_ANGLE 0x93A6 - -#define GLEW_ANGLE_program_binary GLEW_GET_VAR(__GLEW_ANGLE_program_binary) - -#endif /* GL_ANGLE_program_binary */ - -/* ------------------- GL_ANGLE_texture_compression_dxt1 ------------------- */ - -#ifndef GL_ANGLE_texture_compression_dxt1 -#define GL_ANGLE_texture_compression_dxt1 1 - -#define GL_COMPRESSED_RGB_S3TC_DXT1_ANGLE 0x83F0 -#define GL_COMPRESSED_RGBA_S3TC_DXT1_ANGLE 0x83F1 -#define GL_COMPRESSED_RGBA_S3TC_DXT3_ANGLE 0x83F2 -#define GL_COMPRESSED_RGBA_S3TC_DXT5_ANGLE 0x83F3 - -#define GLEW_ANGLE_texture_compression_dxt1 GLEW_GET_VAR(__GLEW_ANGLE_texture_compression_dxt1) - -#endif /* GL_ANGLE_texture_compression_dxt1 */ - -/* ------------------- GL_ANGLE_texture_compression_dxt3 ------------------- */ - -#ifndef GL_ANGLE_texture_compression_dxt3 -#define GL_ANGLE_texture_compression_dxt3 1 - -#define GL_COMPRESSED_RGB_S3TC_DXT1_ANGLE 0x83F0 -#define GL_COMPRESSED_RGBA_S3TC_DXT1_ANGLE 0x83F1 -#define GL_COMPRESSED_RGBA_S3TC_DXT3_ANGLE 0x83F2 -#define GL_COMPRESSED_RGBA_S3TC_DXT5_ANGLE 0x83F3 - -#define GLEW_ANGLE_texture_compression_dxt3 GLEW_GET_VAR(__GLEW_ANGLE_texture_compression_dxt3) - -#endif /* GL_ANGLE_texture_compression_dxt3 */ - -/* ------------------- GL_ANGLE_texture_compression_dxt5 ------------------- */ - -#ifndef GL_ANGLE_texture_compression_dxt5 -#define GL_ANGLE_texture_compression_dxt5 1 - -#define GL_COMPRESSED_RGB_S3TC_DXT1_ANGLE 0x83F0 -#define GL_COMPRESSED_RGBA_S3TC_DXT1_ANGLE 0x83F1 -#define GL_COMPRESSED_RGBA_S3TC_DXT3_ANGLE 0x83F2 -#define GL_COMPRESSED_RGBA_S3TC_DXT5_ANGLE 0x83F3 - -#define GLEW_ANGLE_texture_compression_dxt5 GLEW_GET_VAR(__GLEW_ANGLE_texture_compression_dxt5) - -#endif /* GL_ANGLE_texture_compression_dxt5 */ - -/* ------------------------- GL_ANGLE_texture_usage ------------------------ */ - -#ifndef GL_ANGLE_texture_usage -#define GL_ANGLE_texture_usage 1 - -#define GL_TEXTURE_USAGE_ANGLE 0x93A2 -#define GL_FRAMEBUFFER_ATTACHMENT_ANGLE 0x93A3 - -#define GLEW_ANGLE_texture_usage GLEW_GET_VAR(__GLEW_ANGLE_texture_usage) - -#endif /* GL_ANGLE_texture_usage */ - -/* -------------------------- GL_ANGLE_timer_query ------------------------- */ - -#ifndef GL_ANGLE_timer_query -#define GL_ANGLE_timer_query 1 - -#define GL_QUERY_COUNTER_BITS_ANGLE 0x8864 -#define GL_CURRENT_QUERY_ANGLE 0x8865 -#define GL_QUERY_RESULT_ANGLE 0x8866 -#define GL_QUERY_RESULT_AVAILABLE_ANGLE 0x8867 -#define GL_TIME_ELAPSED_ANGLE 0x88BF -#define GL_TIMESTAMP_ANGLE 0x8E28 - -typedef void (GLAPIENTRY * PFNGLBEGINQUERYANGLEPROC) (GLenum target, GLuint id); -typedef void (GLAPIENTRY * PFNGLDELETEQUERIESANGLEPROC) (GLsizei n, const GLuint* ids); -typedef void (GLAPIENTRY * PFNGLENDQUERYANGLEPROC) (GLenum target); -typedef void (GLAPIENTRY * PFNGLGENQUERIESANGLEPROC) (GLsizei n, GLuint* ids); -typedef void (GLAPIENTRY * PFNGLGETQUERYOBJECTI64VANGLEPROC) (GLuint id, GLenum pname, GLint64* params); -typedef void (GLAPIENTRY * PFNGLGETQUERYOBJECTIVANGLEPROC) (GLuint id, GLenum pname, GLint* params); -typedef void (GLAPIENTRY * PFNGLGETQUERYOBJECTUI64VANGLEPROC) (GLuint id, GLenum pname, GLuint64* params); -typedef void (GLAPIENTRY * PFNGLGETQUERYOBJECTUIVANGLEPROC) (GLuint id, GLenum pname, GLuint* params); -typedef void (GLAPIENTRY * PFNGLGETQUERYIVANGLEPROC) (GLenum target, GLenum pname, GLint* params); -typedef GLboolean (GLAPIENTRY * PFNGLISQUERYANGLEPROC) (GLuint id); -typedef void (GLAPIENTRY * PFNGLQUERYCOUNTERANGLEPROC) (GLuint id, GLenum target); - -#define glBeginQueryANGLE GLEW_GET_FUN(__glewBeginQueryANGLE) -#define glDeleteQueriesANGLE GLEW_GET_FUN(__glewDeleteQueriesANGLE) -#define glEndQueryANGLE GLEW_GET_FUN(__glewEndQueryANGLE) -#define glGenQueriesANGLE GLEW_GET_FUN(__glewGenQueriesANGLE) -#define glGetQueryObjecti64vANGLE GLEW_GET_FUN(__glewGetQueryObjecti64vANGLE) -#define glGetQueryObjectivANGLE GLEW_GET_FUN(__glewGetQueryObjectivANGLE) -#define glGetQueryObjectui64vANGLE GLEW_GET_FUN(__glewGetQueryObjectui64vANGLE) -#define glGetQueryObjectuivANGLE GLEW_GET_FUN(__glewGetQueryObjectuivANGLE) -#define glGetQueryivANGLE GLEW_GET_FUN(__glewGetQueryivANGLE) -#define glIsQueryANGLE GLEW_GET_FUN(__glewIsQueryANGLE) -#define glQueryCounterANGLE GLEW_GET_FUN(__glewQueryCounterANGLE) - -#define GLEW_ANGLE_timer_query GLEW_GET_VAR(__GLEW_ANGLE_timer_query) - -#endif /* GL_ANGLE_timer_query */ - -/* ------------------- GL_ANGLE_translated_shader_source ------------------- */ - -#ifndef GL_ANGLE_translated_shader_source -#define GL_ANGLE_translated_shader_source 1 - -#define GL_TRANSLATED_SHADER_SOURCE_LENGTH_ANGLE 0x93A0 - -typedef void (GLAPIENTRY * PFNGLGETTRANSLATEDSHADERSOURCEANGLEPROC) (GLuint shader, GLsizei bufsize, GLsizei* length, GLchar* source); - -#define glGetTranslatedShaderSourceANGLE GLEW_GET_FUN(__glewGetTranslatedShaderSourceANGLE) - -#define GLEW_ANGLE_translated_shader_source GLEW_GET_VAR(__GLEW_ANGLE_translated_shader_source) - -#endif /* GL_ANGLE_translated_shader_source */ - -/* ----------------------- GL_APPLE_aux_depth_stencil ---------------------- */ - -#ifndef GL_APPLE_aux_depth_stencil -#define GL_APPLE_aux_depth_stencil 1 - -#define GL_AUX_DEPTH_STENCIL_APPLE 0x8A14 - -#define GLEW_APPLE_aux_depth_stencil GLEW_GET_VAR(__GLEW_APPLE_aux_depth_stencil) - -#endif /* GL_APPLE_aux_depth_stencil */ - -/* ------------------------ GL_APPLE_client_storage ------------------------ */ - -#ifndef GL_APPLE_client_storage -#define GL_APPLE_client_storage 1 - -#define GL_UNPACK_CLIENT_STORAGE_APPLE 0x85B2 - -#define GLEW_APPLE_client_storage GLEW_GET_VAR(__GLEW_APPLE_client_storage) - -#endif /* GL_APPLE_client_storage */ - -/* ------------------------- GL_APPLE_element_array ------------------------ */ - -#ifndef GL_APPLE_element_array -#define GL_APPLE_element_array 1 - -#define GL_ELEMENT_ARRAY_APPLE 0x8A0C -#define GL_ELEMENT_ARRAY_TYPE_APPLE 0x8A0D -#define GL_ELEMENT_ARRAY_POINTER_APPLE 0x8A0E - -typedef void (GLAPIENTRY * PFNGLDRAWELEMENTARRAYAPPLEPROC) (GLenum mode, GLint first, GLsizei count); -typedef void (GLAPIENTRY * PFNGLDRAWRANGEELEMENTARRAYAPPLEPROC) (GLenum mode, GLuint start, GLuint end, GLint first, GLsizei count); -typedef void (GLAPIENTRY * PFNGLELEMENTPOINTERAPPLEPROC) (GLenum type, const void *pointer); -typedef void (GLAPIENTRY * PFNGLMULTIDRAWELEMENTARRAYAPPLEPROC) (GLenum mode, const GLint* first, const GLsizei *count, GLsizei primcount); -typedef void (GLAPIENTRY * PFNGLMULTIDRAWRANGEELEMENTARRAYAPPLEPROC) (GLenum mode, GLuint start, GLuint end, const GLint* first, const GLsizei *count, GLsizei primcount); - -#define glDrawElementArrayAPPLE GLEW_GET_FUN(__glewDrawElementArrayAPPLE) -#define glDrawRangeElementArrayAPPLE GLEW_GET_FUN(__glewDrawRangeElementArrayAPPLE) -#define glElementPointerAPPLE GLEW_GET_FUN(__glewElementPointerAPPLE) -#define glMultiDrawElementArrayAPPLE GLEW_GET_FUN(__glewMultiDrawElementArrayAPPLE) -#define glMultiDrawRangeElementArrayAPPLE GLEW_GET_FUN(__glewMultiDrawRangeElementArrayAPPLE) - -#define GLEW_APPLE_element_array GLEW_GET_VAR(__GLEW_APPLE_element_array) - -#endif /* GL_APPLE_element_array */ - -/* ----------------------------- GL_APPLE_fence ---------------------------- */ - -#ifndef GL_APPLE_fence -#define GL_APPLE_fence 1 - -#define GL_DRAW_PIXELS_APPLE 0x8A0A -#define GL_FENCE_APPLE 0x8A0B - -typedef void (GLAPIENTRY * PFNGLDELETEFENCESAPPLEPROC) (GLsizei n, const GLuint* fences); -typedef void (GLAPIENTRY * PFNGLFINISHFENCEAPPLEPROC) (GLuint fence); -typedef void (GLAPIENTRY * PFNGLFINISHOBJECTAPPLEPROC) (GLenum object, GLint name); -typedef void (GLAPIENTRY * PFNGLGENFENCESAPPLEPROC) (GLsizei n, GLuint* fences); -typedef GLboolean (GLAPIENTRY * PFNGLISFENCEAPPLEPROC) (GLuint fence); -typedef void (GLAPIENTRY * PFNGLSETFENCEAPPLEPROC) (GLuint fence); -typedef GLboolean (GLAPIENTRY * PFNGLTESTFENCEAPPLEPROC) (GLuint fence); -typedef GLboolean (GLAPIENTRY * PFNGLTESTOBJECTAPPLEPROC) (GLenum object, GLuint name); - -#define glDeleteFencesAPPLE GLEW_GET_FUN(__glewDeleteFencesAPPLE) -#define glFinishFenceAPPLE GLEW_GET_FUN(__glewFinishFenceAPPLE) -#define glFinishObjectAPPLE GLEW_GET_FUN(__glewFinishObjectAPPLE) -#define glGenFencesAPPLE GLEW_GET_FUN(__glewGenFencesAPPLE) -#define glIsFenceAPPLE GLEW_GET_FUN(__glewIsFenceAPPLE) -#define glSetFenceAPPLE GLEW_GET_FUN(__glewSetFenceAPPLE) -#define glTestFenceAPPLE GLEW_GET_FUN(__glewTestFenceAPPLE) -#define glTestObjectAPPLE GLEW_GET_FUN(__glewTestObjectAPPLE) - -#define GLEW_APPLE_fence GLEW_GET_VAR(__GLEW_APPLE_fence) - -#endif /* GL_APPLE_fence */ - -/* ------------------------- GL_APPLE_float_pixels ------------------------- */ - -#ifndef GL_APPLE_float_pixels -#define GL_APPLE_float_pixels 1 - -#define GL_HALF_APPLE 0x140B -#define GL_RGBA_FLOAT32_APPLE 0x8814 -#define GL_RGB_FLOAT32_APPLE 0x8815 -#define GL_ALPHA_FLOAT32_APPLE 0x8816 -#define GL_INTENSITY_FLOAT32_APPLE 0x8817 -#define GL_LUMINANCE_FLOAT32_APPLE 0x8818 -#define GL_LUMINANCE_ALPHA_FLOAT32_APPLE 0x8819 -#define GL_RGBA_FLOAT16_APPLE 0x881A -#define GL_RGB_FLOAT16_APPLE 0x881B -#define GL_ALPHA_FLOAT16_APPLE 0x881C -#define GL_INTENSITY_FLOAT16_APPLE 0x881D -#define GL_LUMINANCE_FLOAT16_APPLE 0x881E -#define GL_LUMINANCE_ALPHA_FLOAT16_APPLE 0x881F -#define GL_COLOR_FLOAT_APPLE 0x8A0F - -#define GLEW_APPLE_float_pixels GLEW_GET_VAR(__GLEW_APPLE_float_pixels) - -#endif /* GL_APPLE_float_pixels */ - -/* ---------------------- GL_APPLE_flush_buffer_range ---------------------- */ - -#ifndef GL_APPLE_flush_buffer_range -#define GL_APPLE_flush_buffer_range 1 - -#define GL_BUFFER_SERIALIZED_MODIFY_APPLE 0x8A12 -#define GL_BUFFER_FLUSHING_UNMAP_APPLE 0x8A13 - -typedef void (GLAPIENTRY * PFNGLBUFFERPARAMETERIAPPLEPROC) (GLenum target, GLenum pname, GLint param); -typedef void (GLAPIENTRY * PFNGLFLUSHMAPPEDBUFFERRANGEAPPLEPROC) (GLenum target, GLintptr offset, GLsizeiptr size); - -#define glBufferParameteriAPPLE GLEW_GET_FUN(__glewBufferParameteriAPPLE) -#define glFlushMappedBufferRangeAPPLE GLEW_GET_FUN(__glewFlushMappedBufferRangeAPPLE) - -#define GLEW_APPLE_flush_buffer_range GLEW_GET_VAR(__GLEW_APPLE_flush_buffer_range) - -#endif /* GL_APPLE_flush_buffer_range */ - -/* ----------------------- GL_APPLE_object_purgeable ----------------------- */ - -#ifndef GL_APPLE_object_purgeable -#define GL_APPLE_object_purgeable 1 - -#define GL_BUFFER_OBJECT_APPLE 0x85B3 -#define GL_RELEASED_APPLE 0x8A19 -#define GL_VOLATILE_APPLE 0x8A1A -#define GL_RETAINED_APPLE 0x8A1B -#define GL_UNDEFINED_APPLE 0x8A1C -#define GL_PURGEABLE_APPLE 0x8A1D - -typedef void (GLAPIENTRY * PFNGLGETOBJECTPARAMETERIVAPPLEPROC) (GLenum objectType, GLuint name, GLenum pname, GLint* params); -typedef GLenum (GLAPIENTRY * PFNGLOBJECTPURGEABLEAPPLEPROC) (GLenum objectType, GLuint name, GLenum option); -typedef GLenum (GLAPIENTRY * PFNGLOBJECTUNPURGEABLEAPPLEPROC) (GLenum objectType, GLuint name, GLenum option); - -#define glGetObjectParameterivAPPLE GLEW_GET_FUN(__glewGetObjectParameterivAPPLE) -#define glObjectPurgeableAPPLE GLEW_GET_FUN(__glewObjectPurgeableAPPLE) -#define glObjectUnpurgeableAPPLE GLEW_GET_FUN(__glewObjectUnpurgeableAPPLE) - -#define GLEW_APPLE_object_purgeable GLEW_GET_VAR(__GLEW_APPLE_object_purgeable) - -#endif /* GL_APPLE_object_purgeable */ - -/* ------------------------- GL_APPLE_pixel_buffer ------------------------- */ - -#ifndef GL_APPLE_pixel_buffer -#define GL_APPLE_pixel_buffer 1 - -#define GL_MIN_PBUFFER_VIEWPORT_DIMS_APPLE 0x8A10 - -#define GLEW_APPLE_pixel_buffer GLEW_GET_VAR(__GLEW_APPLE_pixel_buffer) - -#endif /* GL_APPLE_pixel_buffer */ - -/* ---------------------------- GL_APPLE_rgb_422 --------------------------- */ - -#ifndef GL_APPLE_rgb_422 -#define GL_APPLE_rgb_422 1 - -#define GL_UNSIGNED_SHORT_8_8_APPLE 0x85BA -#define GL_UNSIGNED_SHORT_8_8_REV_APPLE 0x85BB -#define GL_RGB_422_APPLE 0x8A1F -#define GL_RGB_RAW_422_APPLE 0x8A51 - -#define GLEW_APPLE_rgb_422 GLEW_GET_VAR(__GLEW_APPLE_rgb_422) - -#endif /* GL_APPLE_rgb_422 */ - -/* --------------------------- GL_APPLE_row_bytes -------------------------- */ - -#ifndef GL_APPLE_row_bytes -#define GL_APPLE_row_bytes 1 - -#define GL_PACK_ROW_BYTES_APPLE 0x8A15 -#define GL_UNPACK_ROW_BYTES_APPLE 0x8A16 - -#define GLEW_APPLE_row_bytes GLEW_GET_VAR(__GLEW_APPLE_row_bytes) - -#endif /* GL_APPLE_row_bytes */ - -/* ------------------------ GL_APPLE_specular_vector ----------------------- */ - -#ifndef GL_APPLE_specular_vector -#define GL_APPLE_specular_vector 1 - -#define GL_LIGHT_MODEL_SPECULAR_VECTOR_APPLE 0x85B0 - -#define GLEW_APPLE_specular_vector GLEW_GET_VAR(__GLEW_APPLE_specular_vector) - -#endif /* GL_APPLE_specular_vector */ - -/* ------------------------- GL_APPLE_texture_range ------------------------ */ - -#ifndef GL_APPLE_texture_range -#define GL_APPLE_texture_range 1 - -#define GL_TEXTURE_RANGE_LENGTH_APPLE 0x85B7 -#define GL_TEXTURE_RANGE_POINTER_APPLE 0x85B8 -#define GL_TEXTURE_STORAGE_HINT_APPLE 0x85BC -#define GL_STORAGE_PRIVATE_APPLE 0x85BD -#define GL_STORAGE_CACHED_APPLE 0x85BE -#define GL_STORAGE_SHARED_APPLE 0x85BF - -typedef void (GLAPIENTRY * PFNGLGETTEXPARAMETERPOINTERVAPPLEPROC) (GLenum target, GLenum pname, void **params); -typedef void (GLAPIENTRY * PFNGLTEXTURERANGEAPPLEPROC) (GLenum target, GLsizei length, void *pointer); - -#define glGetTexParameterPointervAPPLE GLEW_GET_FUN(__glewGetTexParameterPointervAPPLE) -#define glTextureRangeAPPLE GLEW_GET_FUN(__glewTextureRangeAPPLE) - -#define GLEW_APPLE_texture_range GLEW_GET_VAR(__GLEW_APPLE_texture_range) - -#endif /* GL_APPLE_texture_range */ - -/* ------------------------ GL_APPLE_transform_hint ------------------------ */ - -#ifndef GL_APPLE_transform_hint -#define GL_APPLE_transform_hint 1 - -#define GL_TRANSFORM_HINT_APPLE 0x85B1 - -#define GLEW_APPLE_transform_hint GLEW_GET_VAR(__GLEW_APPLE_transform_hint) - -#endif /* GL_APPLE_transform_hint */ - -/* ---------------------- GL_APPLE_vertex_array_object --------------------- */ - -#ifndef GL_APPLE_vertex_array_object -#define GL_APPLE_vertex_array_object 1 - -#define GL_VERTEX_ARRAY_BINDING_APPLE 0x85B5 - -typedef void (GLAPIENTRY * PFNGLBINDVERTEXARRAYAPPLEPROC) (GLuint array); -typedef void (GLAPIENTRY * PFNGLDELETEVERTEXARRAYSAPPLEPROC) (GLsizei n, const GLuint* arrays); -typedef void (GLAPIENTRY * PFNGLGENVERTEXARRAYSAPPLEPROC) (GLsizei n, const GLuint* arrays); -typedef GLboolean (GLAPIENTRY * PFNGLISVERTEXARRAYAPPLEPROC) (GLuint array); - -#define glBindVertexArrayAPPLE GLEW_GET_FUN(__glewBindVertexArrayAPPLE) -#define glDeleteVertexArraysAPPLE GLEW_GET_FUN(__glewDeleteVertexArraysAPPLE) -#define glGenVertexArraysAPPLE GLEW_GET_FUN(__glewGenVertexArraysAPPLE) -#define glIsVertexArrayAPPLE GLEW_GET_FUN(__glewIsVertexArrayAPPLE) - -#define GLEW_APPLE_vertex_array_object GLEW_GET_VAR(__GLEW_APPLE_vertex_array_object) - -#endif /* GL_APPLE_vertex_array_object */ - -/* ---------------------- GL_APPLE_vertex_array_range ---------------------- */ - -#ifndef GL_APPLE_vertex_array_range -#define GL_APPLE_vertex_array_range 1 - -#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_MAX_VERTEX_ARRAY_RANGE_ELEMENT_APPLE 0x8520 -#define GL_VERTEX_ARRAY_RANGE_POINTER_APPLE 0x8521 -#define GL_STORAGE_CLIENT_APPLE 0x85B4 -#define GL_STORAGE_CACHED_APPLE 0x85BE -#define GL_STORAGE_SHARED_APPLE 0x85BF - -typedef void (GLAPIENTRY * PFNGLFLUSHVERTEXARRAYRANGEAPPLEPROC) (GLsizei length, void *pointer); -typedef void (GLAPIENTRY * PFNGLVERTEXARRAYPARAMETERIAPPLEPROC) (GLenum pname, GLint param); -typedef void (GLAPIENTRY * PFNGLVERTEXARRAYRANGEAPPLEPROC) (GLsizei length, void *pointer); - -#define glFlushVertexArrayRangeAPPLE GLEW_GET_FUN(__glewFlushVertexArrayRangeAPPLE) -#define glVertexArrayParameteriAPPLE GLEW_GET_FUN(__glewVertexArrayParameteriAPPLE) -#define glVertexArrayRangeAPPLE GLEW_GET_FUN(__glewVertexArrayRangeAPPLE) - -#define GLEW_APPLE_vertex_array_range GLEW_GET_VAR(__GLEW_APPLE_vertex_array_range) - -#endif /* GL_APPLE_vertex_array_range */ - -/* ------------------- GL_APPLE_vertex_program_evaluators ------------------ */ - -#ifndef GL_APPLE_vertex_program_evaluators -#define GL_APPLE_vertex_program_evaluators 1 - -#define GL_VERTEX_ATTRIB_MAP1_APPLE 0x8A00 -#define GL_VERTEX_ATTRIB_MAP2_APPLE 0x8A01 -#define GL_VERTEX_ATTRIB_MAP1_SIZE_APPLE 0x8A02 -#define GL_VERTEX_ATTRIB_MAP1_COEFF_APPLE 0x8A03 -#define GL_VERTEX_ATTRIB_MAP1_ORDER_APPLE 0x8A04 -#define GL_VERTEX_ATTRIB_MAP1_DOMAIN_APPLE 0x8A05 -#define GL_VERTEX_ATTRIB_MAP2_SIZE_APPLE 0x8A06 -#define GL_VERTEX_ATTRIB_MAP2_COEFF_APPLE 0x8A07 -#define GL_VERTEX_ATTRIB_MAP2_ORDER_APPLE 0x8A08 -#define GL_VERTEX_ATTRIB_MAP2_DOMAIN_APPLE 0x8A09 - -typedef void (GLAPIENTRY * PFNGLDISABLEVERTEXATTRIBAPPLEPROC) (GLuint index, GLenum pname); -typedef void (GLAPIENTRY * PFNGLENABLEVERTEXATTRIBAPPLEPROC) (GLuint index, GLenum pname); -typedef GLboolean (GLAPIENTRY * PFNGLISVERTEXATTRIBENABLEDAPPLEPROC) (GLuint index, GLenum pname); -typedef void (GLAPIENTRY * PFNGLMAPVERTEXATTRIB1DAPPLEPROC) (GLuint index, GLuint size, GLdouble u1, GLdouble u2, GLint stride, GLint order, const GLdouble* points); -typedef void (GLAPIENTRY * PFNGLMAPVERTEXATTRIB1FAPPLEPROC) (GLuint index, GLuint size, GLfloat u1, GLfloat u2, GLint stride, GLint order, const GLfloat* points); -typedef void (GLAPIENTRY * PFNGLMAPVERTEXATTRIB2DAPPLEPROC) (GLuint index, GLuint size, GLdouble u1, GLdouble u2, GLint ustride, GLint uorder, GLdouble v1, GLdouble v2, GLint vstride, GLint vorder, const GLdouble* points); -typedef void (GLAPIENTRY * PFNGLMAPVERTEXATTRIB2FAPPLEPROC) (GLuint index, GLuint size, GLfloat u1, GLfloat u2, GLint ustride, GLint uorder, GLfloat v1, GLfloat v2, GLint vstride, GLint vorder, const GLfloat* points); - -#define glDisableVertexAttribAPPLE GLEW_GET_FUN(__glewDisableVertexAttribAPPLE) -#define glEnableVertexAttribAPPLE GLEW_GET_FUN(__glewEnableVertexAttribAPPLE) -#define glIsVertexAttribEnabledAPPLE GLEW_GET_FUN(__glewIsVertexAttribEnabledAPPLE) -#define glMapVertexAttrib1dAPPLE GLEW_GET_FUN(__glewMapVertexAttrib1dAPPLE) -#define glMapVertexAttrib1fAPPLE GLEW_GET_FUN(__glewMapVertexAttrib1fAPPLE) -#define glMapVertexAttrib2dAPPLE GLEW_GET_FUN(__glewMapVertexAttrib2dAPPLE) -#define glMapVertexAttrib2fAPPLE GLEW_GET_FUN(__glewMapVertexAttrib2fAPPLE) - -#define GLEW_APPLE_vertex_program_evaluators GLEW_GET_VAR(__GLEW_APPLE_vertex_program_evaluators) - -#endif /* GL_APPLE_vertex_program_evaluators */ - -/* --------------------------- GL_APPLE_ycbcr_422 -------------------------- */ - -#ifndef GL_APPLE_ycbcr_422 -#define GL_APPLE_ycbcr_422 1 - -#define GL_YCBCR_422_APPLE 0x85B9 - -#define GLEW_APPLE_ycbcr_422 GLEW_GET_VAR(__GLEW_APPLE_ycbcr_422) - -#endif /* GL_APPLE_ycbcr_422 */ - -/* ------------------------ GL_ARB_ES2_compatibility ----------------------- */ - -#ifndef GL_ARB_ES2_compatibility -#define GL_ARB_ES2_compatibility 1 - -#define GL_FIXED 0x140C -#define GL_IMPLEMENTATION_COLOR_READ_TYPE 0x8B9A -#define GL_IMPLEMENTATION_COLOR_READ_FORMAT 0x8B9B -#define GL_RGB565 0x8D62 -#define GL_LOW_FLOAT 0x8DF0 -#define GL_MEDIUM_FLOAT 0x8DF1 -#define GL_HIGH_FLOAT 0x8DF2 -#define GL_LOW_INT 0x8DF3 -#define GL_MEDIUM_INT 0x8DF4 -#define GL_HIGH_INT 0x8DF5 -#define GL_SHADER_BINARY_FORMATS 0x8DF8 -#define GL_NUM_SHADER_BINARY_FORMATS 0x8DF9 -#define GL_SHADER_COMPILER 0x8DFA -#define GL_MAX_VERTEX_UNIFORM_VECTORS 0x8DFB -#define GL_MAX_VARYING_VECTORS 0x8DFC -#define GL_MAX_FRAGMENT_UNIFORM_VECTORS 0x8DFD - -typedef int GLfixed; - -typedef void (GLAPIENTRY * PFNGLCLEARDEPTHFPROC) (GLclampf d); -typedef void (GLAPIENTRY * PFNGLDEPTHRANGEFPROC) (GLclampf n, GLclampf f); -typedef void (GLAPIENTRY * PFNGLGETSHADERPRECISIONFORMATPROC) (GLenum shadertype, GLenum precisiontype, GLint* range, GLint *precision); -typedef void (GLAPIENTRY * PFNGLRELEASESHADERCOMPILERPROC) (void); -typedef void (GLAPIENTRY * PFNGLSHADERBINARYPROC) (GLsizei count, const GLuint* shaders, GLenum binaryformat, const void*binary, GLsizei length); - -#define glClearDepthf GLEW_GET_FUN(__glewClearDepthf) -#define glDepthRangef GLEW_GET_FUN(__glewDepthRangef) -#define glGetShaderPrecisionFormat GLEW_GET_FUN(__glewGetShaderPrecisionFormat) -#define glReleaseShaderCompiler GLEW_GET_FUN(__glewReleaseShaderCompiler) -#define glShaderBinary GLEW_GET_FUN(__glewShaderBinary) - -#define GLEW_ARB_ES2_compatibility GLEW_GET_VAR(__GLEW_ARB_ES2_compatibility) - -#endif /* GL_ARB_ES2_compatibility */ - -/* ----------------------- GL_ARB_ES3_1_compatibility ---------------------- */ - -#ifndef GL_ARB_ES3_1_compatibility -#define GL_ARB_ES3_1_compatibility 1 - -typedef void (GLAPIENTRY * PFNGLMEMORYBARRIERBYREGIONPROC) (GLbitfield barriers); - -#define glMemoryBarrierByRegion GLEW_GET_FUN(__glewMemoryBarrierByRegion) - -#define GLEW_ARB_ES3_1_compatibility GLEW_GET_VAR(__GLEW_ARB_ES3_1_compatibility) - -#endif /* GL_ARB_ES3_1_compatibility */ - -/* ----------------------- GL_ARB_ES3_2_compatibility ---------------------- */ - -#ifndef GL_ARB_ES3_2_compatibility -#define GL_ARB_ES3_2_compatibility 1 - -#define GL_PRIMITIVE_BOUNDING_BOX_ARB 0x92BE -#define GL_MULTISAMPLE_LINE_WIDTH_RANGE_ARB 0x9381 -#define GL_MULTISAMPLE_LINE_WIDTH_GRANULARITY_ARB 0x9382 - -typedef void (GLAPIENTRY * PFNGLPRIMITIVEBOUNDINGBOXARBPROC) (GLfloat minX, GLfloat minY, GLfloat minZ, GLfloat minW, GLfloat maxX, GLfloat maxY, GLfloat maxZ, GLfloat maxW); - -#define glPrimitiveBoundingBoxARB GLEW_GET_FUN(__glewPrimitiveBoundingBoxARB) - -#define GLEW_ARB_ES3_2_compatibility GLEW_GET_VAR(__GLEW_ARB_ES3_2_compatibility) - -#endif /* GL_ARB_ES3_2_compatibility */ - -/* ------------------------ GL_ARB_ES3_compatibility ----------------------- */ - -#ifndef GL_ARB_ES3_compatibility -#define GL_ARB_ES3_compatibility 1 - -#define GL_TEXTURE_IMMUTABLE_LEVELS 0x82DF -#define GL_PRIMITIVE_RESTART_FIXED_INDEX 0x8D69 -#define GL_ANY_SAMPLES_PASSED_CONSERVATIVE 0x8D6A -#define GL_MAX_ELEMENT_INDEX 0x8D6B -#define GL_COMPRESSED_R11_EAC 0x9270 -#define GL_COMPRESSED_SIGNED_R11_EAC 0x9271 -#define GL_COMPRESSED_RG11_EAC 0x9272 -#define GL_COMPRESSED_SIGNED_RG11_EAC 0x9273 -#define GL_COMPRESSED_RGB8_ETC2 0x9274 -#define GL_COMPRESSED_SRGB8_ETC2 0x9275 -#define GL_COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2 0x9276 -#define GL_COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2 0x9277 -#define GL_COMPRESSED_RGBA8_ETC2_EAC 0x9278 -#define GL_COMPRESSED_SRGB8_ALPHA8_ETC2_EAC 0x9279 - -#define GLEW_ARB_ES3_compatibility GLEW_GET_VAR(__GLEW_ARB_ES3_compatibility) - -#endif /* GL_ARB_ES3_compatibility */ - -/* ------------------------ GL_ARB_arrays_of_arrays ------------------------ */ - -#ifndef GL_ARB_arrays_of_arrays -#define GL_ARB_arrays_of_arrays 1 - -#define GLEW_ARB_arrays_of_arrays GLEW_GET_VAR(__GLEW_ARB_arrays_of_arrays) - -#endif /* GL_ARB_arrays_of_arrays */ - -/* -------------------------- GL_ARB_base_instance ------------------------- */ - -#ifndef GL_ARB_base_instance -#define GL_ARB_base_instance 1 - -typedef void (GLAPIENTRY * PFNGLDRAWARRAYSINSTANCEDBASEINSTANCEPROC) (GLenum mode, GLint first, GLsizei count, GLsizei primcount, GLuint baseinstance); -typedef void (GLAPIENTRY * PFNGLDRAWELEMENTSINSTANCEDBASEINSTANCEPROC) (GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei primcount, GLuint baseinstance); -typedef void (GLAPIENTRY * PFNGLDRAWELEMENTSINSTANCEDBASEVERTEXBASEINSTANCEPROC) (GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei primcount, GLint basevertex, GLuint baseinstance); - -#define glDrawArraysInstancedBaseInstance GLEW_GET_FUN(__glewDrawArraysInstancedBaseInstance) -#define glDrawElementsInstancedBaseInstance GLEW_GET_FUN(__glewDrawElementsInstancedBaseInstance) -#define glDrawElementsInstancedBaseVertexBaseInstance GLEW_GET_FUN(__glewDrawElementsInstancedBaseVertexBaseInstance) - -#define GLEW_ARB_base_instance GLEW_GET_VAR(__GLEW_ARB_base_instance) - -#endif /* GL_ARB_base_instance */ - -/* ------------------------ GL_ARB_bindless_texture ------------------------ */ - -#ifndef GL_ARB_bindless_texture -#define GL_ARB_bindless_texture 1 - -#define GL_UNSIGNED_INT64_ARB 0x140F - -typedef GLuint64 (GLAPIENTRY * PFNGLGETIMAGEHANDLEARBPROC) (GLuint texture, GLint level, GLboolean layered, GLint layer, GLenum format); -typedef GLuint64 (GLAPIENTRY * PFNGLGETTEXTUREHANDLEARBPROC) (GLuint texture); -typedef GLuint64 (GLAPIENTRY * PFNGLGETTEXTURESAMPLERHANDLEARBPROC) (GLuint texture, GLuint sampler); -typedef void (GLAPIENTRY * PFNGLGETVERTEXATTRIBLUI64VARBPROC) (GLuint index, GLenum pname, GLuint64EXT* params); -typedef GLboolean (GLAPIENTRY * PFNGLISIMAGEHANDLERESIDENTARBPROC) (GLuint64 handle); -typedef GLboolean (GLAPIENTRY * PFNGLISTEXTUREHANDLERESIDENTARBPROC) (GLuint64 handle); -typedef void (GLAPIENTRY * PFNGLMAKEIMAGEHANDLENONRESIDENTARBPROC) (GLuint64 handle); -typedef void (GLAPIENTRY * PFNGLMAKEIMAGEHANDLERESIDENTARBPROC) (GLuint64 handle, GLenum access); -typedef void (GLAPIENTRY * PFNGLMAKETEXTUREHANDLENONRESIDENTARBPROC) (GLuint64 handle); -typedef void (GLAPIENTRY * PFNGLMAKETEXTUREHANDLERESIDENTARBPROC) (GLuint64 handle); -typedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORMHANDLEUI64ARBPROC) (GLuint program, GLint location, GLuint64 value); -typedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORMHANDLEUI64VARBPROC) (GLuint program, GLint location, GLsizei count, const GLuint64* values); -typedef void (GLAPIENTRY * PFNGLUNIFORMHANDLEUI64ARBPROC) (GLint location, GLuint64 value); -typedef void (GLAPIENTRY * PFNGLUNIFORMHANDLEUI64VARBPROC) (GLint location, GLsizei count, const GLuint64* value); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBL1UI64ARBPROC) (GLuint index, GLuint64EXT x); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBL1UI64VARBPROC) (GLuint index, const GLuint64EXT* v); - -#define glGetImageHandleARB GLEW_GET_FUN(__glewGetImageHandleARB) -#define glGetTextureHandleARB GLEW_GET_FUN(__glewGetTextureHandleARB) -#define glGetTextureSamplerHandleARB GLEW_GET_FUN(__glewGetTextureSamplerHandleARB) -#define glGetVertexAttribLui64vARB GLEW_GET_FUN(__glewGetVertexAttribLui64vARB) -#define glIsImageHandleResidentARB GLEW_GET_FUN(__glewIsImageHandleResidentARB) -#define glIsTextureHandleResidentARB GLEW_GET_FUN(__glewIsTextureHandleResidentARB) -#define glMakeImageHandleNonResidentARB GLEW_GET_FUN(__glewMakeImageHandleNonResidentARB) -#define glMakeImageHandleResidentARB GLEW_GET_FUN(__glewMakeImageHandleResidentARB) -#define glMakeTextureHandleNonResidentARB GLEW_GET_FUN(__glewMakeTextureHandleNonResidentARB) -#define glMakeTextureHandleResidentARB GLEW_GET_FUN(__glewMakeTextureHandleResidentARB) -#define glProgramUniformHandleui64ARB GLEW_GET_FUN(__glewProgramUniformHandleui64ARB) -#define glProgramUniformHandleui64vARB GLEW_GET_FUN(__glewProgramUniformHandleui64vARB) -#define glUniformHandleui64ARB GLEW_GET_FUN(__glewUniformHandleui64ARB) -#define glUniformHandleui64vARB GLEW_GET_FUN(__glewUniformHandleui64vARB) -#define glVertexAttribL1ui64ARB GLEW_GET_FUN(__glewVertexAttribL1ui64ARB) -#define glVertexAttribL1ui64vARB GLEW_GET_FUN(__glewVertexAttribL1ui64vARB) - -#define GLEW_ARB_bindless_texture GLEW_GET_VAR(__GLEW_ARB_bindless_texture) - -#endif /* GL_ARB_bindless_texture */ - -/* ----------------------- GL_ARB_blend_func_extended ---------------------- */ - -#ifndef GL_ARB_blend_func_extended -#define GL_ARB_blend_func_extended 1 - -#define GL_SRC1_COLOR 0x88F9 -#define GL_ONE_MINUS_SRC1_COLOR 0x88FA -#define GL_ONE_MINUS_SRC1_ALPHA 0x88FB -#define GL_MAX_DUAL_SOURCE_DRAW_BUFFERS 0x88FC - -typedef void (GLAPIENTRY * PFNGLBINDFRAGDATALOCATIONINDEXEDPROC) (GLuint program, GLuint colorNumber, GLuint index, const GLchar * name); -typedef GLint (GLAPIENTRY * PFNGLGETFRAGDATAINDEXPROC) (GLuint program, const GLchar * name); - -#define glBindFragDataLocationIndexed GLEW_GET_FUN(__glewBindFragDataLocationIndexed) -#define glGetFragDataIndex GLEW_GET_FUN(__glewGetFragDataIndex) - -#define GLEW_ARB_blend_func_extended GLEW_GET_VAR(__GLEW_ARB_blend_func_extended) - -#endif /* GL_ARB_blend_func_extended */ - -/* ------------------------- GL_ARB_buffer_storage ------------------------- */ - -#ifndef GL_ARB_buffer_storage -#define GL_ARB_buffer_storage 1 - -#define GL_MAP_READ_BIT 0x0001 -#define GL_MAP_WRITE_BIT 0x0002 -#define GL_MAP_PERSISTENT_BIT 0x00000040 -#define GL_MAP_COHERENT_BIT 0x00000080 -#define GL_DYNAMIC_STORAGE_BIT 0x0100 -#define GL_CLIENT_STORAGE_BIT 0x0200 -#define GL_CLIENT_MAPPED_BUFFER_BARRIER_BIT 0x00004000 -#define GL_BUFFER_IMMUTABLE_STORAGE 0x821F -#define GL_BUFFER_STORAGE_FLAGS 0x8220 - -typedef void (GLAPIENTRY * PFNGLBUFFERSTORAGEPROC) (GLenum target, GLsizeiptr size, const void *data, GLbitfield flags); -typedef void (GLAPIENTRY * PFNGLNAMEDBUFFERSTORAGEEXTPROC) (GLuint buffer, GLsizeiptr size, const void *data, GLbitfield flags); - -#define glBufferStorage GLEW_GET_FUN(__glewBufferStorage) -#define glNamedBufferStorageEXT GLEW_GET_FUN(__glewNamedBufferStorageEXT) - -#define GLEW_ARB_buffer_storage GLEW_GET_VAR(__GLEW_ARB_buffer_storage) - -#endif /* GL_ARB_buffer_storage */ - -/* ---------------------------- GL_ARB_cl_event ---------------------------- */ - -#ifndef GL_ARB_cl_event -#define GL_ARB_cl_event 1 - -#define GL_SYNC_CL_EVENT_ARB 0x8240 -#define GL_SYNC_CL_EVENT_COMPLETE_ARB 0x8241 - -typedef struct _cl_context *cl_context; -typedef struct _cl_event *cl_event; - -typedef GLsync (GLAPIENTRY * PFNGLCREATESYNCFROMCLEVENTARBPROC) (cl_context context, cl_event event, GLbitfield flags); - -#define glCreateSyncFromCLeventARB GLEW_GET_FUN(__glewCreateSyncFromCLeventARB) - -#define GLEW_ARB_cl_event GLEW_GET_VAR(__GLEW_ARB_cl_event) - -#endif /* GL_ARB_cl_event */ - -/* ----------------------- GL_ARB_clear_buffer_object ---------------------- */ - -#ifndef GL_ARB_clear_buffer_object -#define GL_ARB_clear_buffer_object 1 - -typedef void (GLAPIENTRY * PFNGLCLEARBUFFERDATAPROC) (GLenum target, GLenum internalformat, GLenum format, GLenum type, const void *data); -typedef void (GLAPIENTRY * PFNGLCLEARBUFFERSUBDATAPROC) (GLenum target, GLenum internalformat, GLintptr offset, GLsizeiptr size, GLenum format, GLenum type, const void *data); -typedef void (GLAPIENTRY * PFNGLCLEARNAMEDBUFFERDATAEXTPROC) (GLuint buffer, GLenum internalformat, GLenum format, GLenum type, const void *data); -typedef void (GLAPIENTRY * PFNGLCLEARNAMEDBUFFERSUBDATAEXTPROC) (GLuint buffer, GLenum internalformat, GLintptr offset, GLsizeiptr size, GLenum format, GLenum type, const void *data); - -#define glClearBufferData GLEW_GET_FUN(__glewClearBufferData) -#define glClearBufferSubData GLEW_GET_FUN(__glewClearBufferSubData) -#define glClearNamedBufferDataEXT GLEW_GET_FUN(__glewClearNamedBufferDataEXT) -#define glClearNamedBufferSubDataEXT GLEW_GET_FUN(__glewClearNamedBufferSubDataEXT) - -#define GLEW_ARB_clear_buffer_object GLEW_GET_VAR(__GLEW_ARB_clear_buffer_object) - -#endif /* GL_ARB_clear_buffer_object */ - -/* -------------------------- GL_ARB_clear_texture ------------------------- */ - -#ifndef GL_ARB_clear_texture -#define GL_ARB_clear_texture 1 - -#define GL_CLEAR_TEXTURE 0x9365 - -typedef void (GLAPIENTRY * PFNGLCLEARTEXIMAGEPROC) (GLuint texture, GLint level, GLenum format, GLenum type, const void *data); -typedef void (GLAPIENTRY * PFNGLCLEARTEXSUBIMAGEPROC) (GLuint texture, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const void *data); - -#define glClearTexImage GLEW_GET_FUN(__glewClearTexImage) -#define glClearTexSubImage GLEW_GET_FUN(__glewClearTexSubImage) - -#define GLEW_ARB_clear_texture GLEW_GET_VAR(__GLEW_ARB_clear_texture) - -#endif /* GL_ARB_clear_texture */ - -/* -------------------------- GL_ARB_clip_control -------------------------- */ - -#ifndef GL_ARB_clip_control -#define GL_ARB_clip_control 1 - -#define GL_LOWER_LEFT 0x8CA1 -#define GL_UPPER_LEFT 0x8CA2 -#define GL_CLIP_ORIGIN 0x935C -#define GL_CLIP_DEPTH_MODE 0x935D -#define GL_NEGATIVE_ONE_TO_ONE 0x935E -#define GL_ZERO_TO_ONE 0x935F - -typedef void (GLAPIENTRY * PFNGLCLIPCONTROLPROC) (GLenum origin, GLenum depth); - -#define glClipControl GLEW_GET_FUN(__glewClipControl) - -#define GLEW_ARB_clip_control GLEW_GET_VAR(__GLEW_ARB_clip_control) - -#endif /* GL_ARB_clip_control */ - -/* ----------------------- GL_ARB_color_buffer_float ----------------------- */ - -#ifndef GL_ARB_color_buffer_float -#define GL_ARB_color_buffer_float 1 - -#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 - -typedef void (GLAPIENTRY * PFNGLCLAMPCOLORARBPROC) (GLenum target, GLenum clamp); - -#define glClampColorARB GLEW_GET_FUN(__glewClampColorARB) - -#define GLEW_ARB_color_buffer_float GLEW_GET_VAR(__GLEW_ARB_color_buffer_float) - -#endif /* GL_ARB_color_buffer_float */ - -/* -------------------------- GL_ARB_compatibility ------------------------- */ - -#ifndef GL_ARB_compatibility -#define GL_ARB_compatibility 1 - -#define GLEW_ARB_compatibility GLEW_GET_VAR(__GLEW_ARB_compatibility) - -#endif /* GL_ARB_compatibility */ - -/* ---------------- GL_ARB_compressed_texture_pixel_storage ---------------- */ - -#ifndef GL_ARB_compressed_texture_pixel_storage -#define GL_ARB_compressed_texture_pixel_storage 1 - -#define GL_UNPACK_COMPRESSED_BLOCK_WIDTH 0x9127 -#define GL_UNPACK_COMPRESSED_BLOCK_HEIGHT 0x9128 -#define GL_UNPACK_COMPRESSED_BLOCK_DEPTH 0x9129 -#define GL_UNPACK_COMPRESSED_BLOCK_SIZE 0x912A -#define GL_PACK_COMPRESSED_BLOCK_WIDTH 0x912B -#define GL_PACK_COMPRESSED_BLOCK_HEIGHT 0x912C -#define GL_PACK_COMPRESSED_BLOCK_DEPTH 0x912D -#define GL_PACK_COMPRESSED_BLOCK_SIZE 0x912E - -#define GLEW_ARB_compressed_texture_pixel_storage GLEW_GET_VAR(__GLEW_ARB_compressed_texture_pixel_storage) - -#endif /* GL_ARB_compressed_texture_pixel_storage */ - -/* ------------------------- GL_ARB_compute_shader ------------------------- */ - -#ifndef GL_ARB_compute_shader -#define GL_ARB_compute_shader 1 - -#define GL_COMPUTE_SHADER_BIT 0x00000020 -#define GL_MAX_COMPUTE_SHARED_MEMORY_SIZE 0x8262 -#define GL_MAX_COMPUTE_UNIFORM_COMPONENTS 0x8263 -#define GL_MAX_COMPUTE_ATOMIC_COUNTER_BUFFERS 0x8264 -#define GL_MAX_COMPUTE_ATOMIC_COUNTERS 0x8265 -#define GL_MAX_COMBINED_COMPUTE_UNIFORM_COMPONENTS 0x8266 -#define GL_COMPUTE_WORK_GROUP_SIZE 0x8267 -#define GL_MAX_COMPUTE_WORK_GROUP_INVOCATIONS 0x90EB -#define GL_UNIFORM_BLOCK_REFERENCED_BY_COMPUTE_SHADER 0x90EC -#define GL_ATOMIC_COUNTER_BUFFER_REFERENCED_BY_COMPUTE_SHADER 0x90ED -#define GL_DISPATCH_INDIRECT_BUFFER 0x90EE -#define GL_DISPATCH_INDIRECT_BUFFER_BINDING 0x90EF -#define GL_COMPUTE_SHADER 0x91B9 -#define GL_MAX_COMPUTE_UNIFORM_BLOCKS 0x91BB -#define GL_MAX_COMPUTE_TEXTURE_IMAGE_UNITS 0x91BC -#define GL_MAX_COMPUTE_IMAGE_UNIFORMS 0x91BD -#define GL_MAX_COMPUTE_WORK_GROUP_COUNT 0x91BE -#define GL_MAX_COMPUTE_WORK_GROUP_SIZE 0x91BF - -typedef void (GLAPIENTRY * PFNGLDISPATCHCOMPUTEPROC) (GLuint num_groups_x, GLuint num_groups_y, GLuint num_groups_z); -typedef void (GLAPIENTRY * PFNGLDISPATCHCOMPUTEINDIRECTPROC) (GLintptr indirect); - -#define glDispatchCompute GLEW_GET_FUN(__glewDispatchCompute) -#define glDispatchComputeIndirect GLEW_GET_FUN(__glewDispatchComputeIndirect) - -#define GLEW_ARB_compute_shader GLEW_GET_VAR(__GLEW_ARB_compute_shader) - -#endif /* GL_ARB_compute_shader */ - -/* ------------------- GL_ARB_compute_variable_group_size ------------------ */ - -#ifndef GL_ARB_compute_variable_group_size -#define GL_ARB_compute_variable_group_size 1 - -#define GL_MAX_COMPUTE_FIXED_GROUP_INVOCATIONS_ARB 0x90EB -#define GL_MAX_COMPUTE_FIXED_GROUP_SIZE_ARB 0x91BF -#define GL_MAX_COMPUTE_VARIABLE_GROUP_INVOCATIONS_ARB 0x9344 -#define GL_MAX_COMPUTE_VARIABLE_GROUP_SIZE_ARB 0x9345 - -typedef void (GLAPIENTRY * PFNGLDISPATCHCOMPUTEGROUPSIZEARBPROC) (GLuint num_groups_x, GLuint num_groups_y, GLuint num_groups_z, GLuint group_size_x, GLuint group_size_y, GLuint group_size_z); - -#define glDispatchComputeGroupSizeARB GLEW_GET_FUN(__glewDispatchComputeGroupSizeARB) - -#define GLEW_ARB_compute_variable_group_size GLEW_GET_VAR(__GLEW_ARB_compute_variable_group_size) - -#endif /* GL_ARB_compute_variable_group_size */ - -/* ------------------- GL_ARB_conditional_render_inverted ------------------ */ - -#ifndef GL_ARB_conditional_render_inverted -#define GL_ARB_conditional_render_inverted 1 - -#define GL_QUERY_WAIT_INVERTED 0x8E17 -#define GL_QUERY_NO_WAIT_INVERTED 0x8E18 -#define GL_QUERY_BY_REGION_WAIT_INVERTED 0x8E19 -#define GL_QUERY_BY_REGION_NO_WAIT_INVERTED 0x8E1A - -#define GLEW_ARB_conditional_render_inverted GLEW_GET_VAR(__GLEW_ARB_conditional_render_inverted) - -#endif /* GL_ARB_conditional_render_inverted */ - -/* ----------------------- GL_ARB_conservative_depth ----------------------- */ - -#ifndef GL_ARB_conservative_depth -#define GL_ARB_conservative_depth 1 - -#define GLEW_ARB_conservative_depth GLEW_GET_VAR(__GLEW_ARB_conservative_depth) - -#endif /* GL_ARB_conservative_depth */ - -/* --------------------------- GL_ARB_copy_buffer -------------------------- */ - -#ifndef GL_ARB_copy_buffer -#define GL_ARB_copy_buffer 1 - -#define GL_COPY_READ_BUFFER 0x8F36 -#define GL_COPY_WRITE_BUFFER 0x8F37 - -typedef void (GLAPIENTRY * PFNGLCOPYBUFFERSUBDATAPROC) (GLenum readtarget, GLenum writetarget, GLintptr readoffset, GLintptr writeoffset, GLsizeiptr size); - -#define glCopyBufferSubData GLEW_GET_FUN(__glewCopyBufferSubData) - -#define GLEW_ARB_copy_buffer GLEW_GET_VAR(__GLEW_ARB_copy_buffer) - -#endif /* GL_ARB_copy_buffer */ - -/* --------------------------- GL_ARB_copy_image --------------------------- */ - -#ifndef GL_ARB_copy_image -#define GL_ARB_copy_image 1 - -typedef void (GLAPIENTRY * PFNGLCOPYIMAGESUBDATAPROC) (GLuint srcName, GLenum srcTarget, GLint srcLevel, GLint srcX, GLint srcY, GLint srcZ, GLuint dstName, GLenum dstTarget, GLint dstLevel, GLint dstX, GLint dstY, GLint dstZ, GLsizei srcWidth, GLsizei srcHeight, GLsizei srcDepth); - -#define glCopyImageSubData GLEW_GET_FUN(__glewCopyImageSubData) - -#define GLEW_ARB_copy_image GLEW_GET_VAR(__GLEW_ARB_copy_image) - -#endif /* GL_ARB_copy_image */ - -/* -------------------------- GL_ARB_cull_distance ------------------------- */ - -#ifndef GL_ARB_cull_distance -#define GL_ARB_cull_distance 1 - -#define GL_MAX_CULL_DISTANCES 0x82F9 -#define GL_MAX_COMBINED_CLIP_AND_CULL_DISTANCES 0x82FA - -#define GLEW_ARB_cull_distance GLEW_GET_VAR(__GLEW_ARB_cull_distance) - -#endif /* GL_ARB_cull_distance */ - -/* -------------------------- GL_ARB_debug_output -------------------------- */ - -#ifndef GL_ARB_debug_output -#define GL_ARB_debug_output 1 - -#define GL_DEBUG_OUTPUT_SYNCHRONOUS_ARB 0x8242 -#define GL_DEBUG_NEXT_LOGGED_MESSAGE_LENGTH_ARB 0x8243 -#define GL_DEBUG_CALLBACK_FUNCTION_ARB 0x8244 -#define GL_DEBUG_CALLBACK_USER_PARAM_ARB 0x8245 -#define GL_DEBUG_SOURCE_API_ARB 0x8246 -#define GL_DEBUG_SOURCE_WINDOW_SYSTEM_ARB 0x8247 -#define GL_DEBUG_SOURCE_SHADER_COMPILER_ARB 0x8248 -#define GL_DEBUG_SOURCE_THIRD_PARTY_ARB 0x8249 -#define GL_DEBUG_SOURCE_APPLICATION_ARB 0x824A -#define GL_DEBUG_SOURCE_OTHER_ARB 0x824B -#define GL_DEBUG_TYPE_ERROR_ARB 0x824C -#define GL_DEBUG_TYPE_DEPRECATED_BEHAVIOR_ARB 0x824D -#define GL_DEBUG_TYPE_UNDEFINED_BEHAVIOR_ARB 0x824E -#define GL_DEBUG_TYPE_PORTABILITY_ARB 0x824F -#define GL_DEBUG_TYPE_PERFORMANCE_ARB 0x8250 -#define GL_DEBUG_TYPE_OTHER_ARB 0x8251 -#define GL_MAX_DEBUG_MESSAGE_LENGTH_ARB 0x9143 -#define GL_MAX_DEBUG_LOGGED_MESSAGES_ARB 0x9144 -#define GL_DEBUG_LOGGED_MESSAGES_ARB 0x9145 -#define GL_DEBUG_SEVERITY_HIGH_ARB 0x9146 -#define GL_DEBUG_SEVERITY_MEDIUM_ARB 0x9147 -#define GL_DEBUG_SEVERITY_LOW_ARB 0x9148 - -typedef void (GLAPIENTRY *GLDEBUGPROCARB)(GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length, const GLchar* message, const void* userParam); - -typedef void (GLAPIENTRY * PFNGLDEBUGMESSAGECALLBACKARBPROC) (GLDEBUGPROCARB callback, const void *userParam); -typedef void (GLAPIENTRY * PFNGLDEBUGMESSAGECONTROLARBPROC) (GLenum source, GLenum type, GLenum severity, GLsizei count, const GLuint* ids, GLboolean enabled); -typedef void (GLAPIENTRY * PFNGLDEBUGMESSAGEINSERTARBPROC) (GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length, const GLchar* buf); -typedef GLuint (GLAPIENTRY * PFNGLGETDEBUGMESSAGELOGARBPROC) (GLuint count, GLsizei bufSize, GLenum* sources, GLenum* types, GLuint* ids, GLenum* severities, GLsizei* lengths, GLchar* messageLog); - -#define glDebugMessageCallbackARB GLEW_GET_FUN(__glewDebugMessageCallbackARB) -#define glDebugMessageControlARB GLEW_GET_FUN(__glewDebugMessageControlARB) -#define glDebugMessageInsertARB GLEW_GET_FUN(__glewDebugMessageInsertARB) -#define glGetDebugMessageLogARB GLEW_GET_FUN(__glewGetDebugMessageLogARB) - -#define GLEW_ARB_debug_output GLEW_GET_VAR(__GLEW_ARB_debug_output) - -#endif /* GL_ARB_debug_output */ - -/* ----------------------- GL_ARB_depth_buffer_float ----------------------- */ - -#ifndef GL_ARB_depth_buffer_float -#define GL_ARB_depth_buffer_float 1 - -#define GL_DEPTH_COMPONENT32F 0x8CAC -#define GL_DEPTH32F_STENCIL8 0x8CAD -#define GL_FLOAT_32_UNSIGNED_INT_24_8_REV 0x8DAD - -#define GLEW_ARB_depth_buffer_float GLEW_GET_VAR(__GLEW_ARB_depth_buffer_float) - -#endif /* GL_ARB_depth_buffer_float */ - -/* --------------------------- GL_ARB_depth_clamp -------------------------- */ - -#ifndef GL_ARB_depth_clamp -#define GL_ARB_depth_clamp 1 - -#define GL_DEPTH_CLAMP 0x864F - -#define GLEW_ARB_depth_clamp GLEW_GET_VAR(__GLEW_ARB_depth_clamp) - -#endif /* GL_ARB_depth_clamp */ - -/* -------------------------- GL_ARB_depth_texture ------------------------- */ - -#ifndef GL_ARB_depth_texture -#define GL_ARB_depth_texture 1 - -#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 - -#define GLEW_ARB_depth_texture GLEW_GET_VAR(__GLEW_ARB_depth_texture) - -#endif /* GL_ARB_depth_texture */ - -/* ----------------------- GL_ARB_derivative_control ----------------------- */ - -#ifndef GL_ARB_derivative_control -#define GL_ARB_derivative_control 1 - -#define GLEW_ARB_derivative_control GLEW_GET_VAR(__GLEW_ARB_derivative_control) - -#endif /* GL_ARB_derivative_control */ - -/* ----------------------- GL_ARB_direct_state_access ---------------------- */ - -#ifndef GL_ARB_direct_state_access -#define GL_ARB_direct_state_access 1 - -#define GL_TEXTURE_TARGET 0x1006 -#define GL_QUERY_TARGET 0x82EA - -typedef void (GLAPIENTRY * PFNGLBINDTEXTUREUNITPROC) (GLuint unit, GLuint texture); -typedef void (GLAPIENTRY * PFNGLBLITNAMEDFRAMEBUFFERPROC) (GLuint readFramebuffer, GLuint drawFramebuffer, GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter); -typedef GLenum (GLAPIENTRY * PFNGLCHECKNAMEDFRAMEBUFFERSTATUSPROC) (GLuint framebuffer, GLenum target); -typedef void (GLAPIENTRY * PFNGLCLEARNAMEDBUFFERDATAPROC) (GLuint buffer, GLenum internalformat, GLenum format, GLenum type, const void *data); -typedef void (GLAPIENTRY * PFNGLCLEARNAMEDBUFFERSUBDATAPROC) (GLuint buffer, GLenum internalformat, GLintptr offset, GLsizeiptr size, GLenum format, GLenum type, const void *data); -typedef void (GLAPIENTRY * PFNGLCLEARNAMEDFRAMEBUFFERFIPROC) (GLuint framebuffer, GLenum buffer, GLint drawbuffer, GLfloat depth, GLint stencil); -typedef void (GLAPIENTRY * PFNGLCLEARNAMEDFRAMEBUFFERFVPROC) (GLuint framebuffer, GLenum buffer, GLint drawbuffer, GLfloat* value); -typedef void (GLAPIENTRY * PFNGLCLEARNAMEDFRAMEBUFFERIVPROC) (GLuint framebuffer, GLenum buffer, GLint drawbuffer, const GLint* value); -typedef void (GLAPIENTRY * PFNGLCLEARNAMEDFRAMEBUFFERUIVPROC) (GLuint framebuffer, GLenum buffer, GLint drawbuffer, const GLuint* value); -typedef void (GLAPIENTRY * PFNGLCOMPRESSEDTEXTURESUBIMAGE1DPROC) (GLuint texture, GLint level, GLint xoffset, GLsizei width, GLenum format, GLsizei imageSize, const void *data); -typedef void (GLAPIENTRY * PFNGLCOMPRESSEDTEXTURESUBIMAGE2DPROC) (GLuint texture, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const void *data); -typedef void (GLAPIENTRY * PFNGLCOMPRESSEDTEXTURESUBIMAGE3DPROC) (GLuint texture, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const void *data); -typedef void (GLAPIENTRY * PFNGLCOPYNAMEDBUFFERSUBDATAPROC) (GLuint readBuffer, GLuint writeBuffer, GLintptr readOffset, GLintptr writeOffset, GLsizeiptr size); -typedef void (GLAPIENTRY * PFNGLCOPYTEXTURESUBIMAGE1DPROC) (GLuint texture, GLint level, GLint xoffset, GLint x, GLint y, GLsizei width); -typedef void (GLAPIENTRY * PFNGLCOPYTEXTURESUBIMAGE2DPROC) (GLuint texture, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height); -typedef void (GLAPIENTRY * PFNGLCOPYTEXTURESUBIMAGE3DPROC) (GLuint texture, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height); -typedef void (GLAPIENTRY * PFNGLCREATEBUFFERSPROC) (GLsizei n, GLuint* buffers); -typedef void (GLAPIENTRY * PFNGLCREATEFRAMEBUFFERSPROC) (GLsizei n, GLuint* framebuffers); -typedef void (GLAPIENTRY * PFNGLCREATEPROGRAMPIPELINESPROC) (GLsizei n, GLuint* pipelines); -typedef void (GLAPIENTRY * PFNGLCREATEQUERIESPROC) (GLenum target, GLsizei n, GLuint* ids); -typedef void (GLAPIENTRY * PFNGLCREATERENDERBUFFERSPROC) (GLsizei n, GLuint* renderbuffers); -typedef void (GLAPIENTRY * PFNGLCREATESAMPLERSPROC) (GLsizei n, GLuint* samplers); -typedef void (GLAPIENTRY * PFNGLCREATETEXTURESPROC) (GLenum target, GLsizei n, GLuint* textures); -typedef void (GLAPIENTRY * PFNGLCREATETRANSFORMFEEDBACKSPROC) (GLsizei n, GLuint* ids); -typedef void (GLAPIENTRY * PFNGLCREATEVERTEXARRAYSPROC) (GLsizei n, GLuint* arrays); -typedef void (GLAPIENTRY * PFNGLDISABLEVERTEXARRAYATTRIBPROC) (GLuint vaobj, GLuint index); -typedef void (GLAPIENTRY * PFNGLENABLEVERTEXARRAYATTRIBPROC) (GLuint vaobj, GLuint index); -typedef void (GLAPIENTRY * PFNGLFLUSHMAPPEDNAMEDBUFFERRANGEPROC) (GLuint buffer, GLintptr offset, GLsizeiptr length); -typedef void (GLAPIENTRY * PFNGLGENERATETEXTUREMIPMAPPROC) (GLuint texture); -typedef void (GLAPIENTRY * PFNGLGETCOMPRESSEDTEXTUREIMAGEPROC) (GLuint texture, GLint level, GLsizei bufSize, void *pixels); -typedef void (GLAPIENTRY * PFNGLGETNAMEDBUFFERPARAMETERI64VPROC) (GLuint buffer, GLenum pname, GLint64* params); -typedef void (GLAPIENTRY * PFNGLGETNAMEDBUFFERPARAMETERIVPROC) (GLuint buffer, GLenum pname, GLint* params); -typedef void (GLAPIENTRY * PFNGLGETNAMEDBUFFERPOINTERVPROC) (GLuint buffer, GLenum pname, void** params); -typedef void (GLAPIENTRY * PFNGLGETNAMEDBUFFERSUBDATAPROC) (GLuint buffer, GLintptr offset, GLsizeiptr size, void *data); -typedef void (GLAPIENTRY * PFNGLGETNAMEDFRAMEBUFFERATTACHMENTPARAMETERIVPROC) (GLuint framebuffer, GLenum attachment, GLenum pname, GLint* params); -typedef void (GLAPIENTRY * PFNGLGETNAMEDFRAMEBUFFERPARAMETERIVPROC) (GLuint framebuffer, GLenum pname, GLint* param); -typedef void (GLAPIENTRY * PFNGLGETNAMEDRENDERBUFFERPARAMETERIVPROC) (GLuint renderbuffer, GLenum pname, GLint* params); -typedef void (GLAPIENTRY * PFNGLGETQUERYBUFFEROBJECTI64VPROC) (GLuint id,GLuint buffer,GLenum pname,GLintptr offset); -typedef void (GLAPIENTRY * PFNGLGETQUERYBUFFEROBJECTIVPROC) (GLuint id,GLuint buffer,GLenum pname,GLintptr offset); -typedef void (GLAPIENTRY * PFNGLGETQUERYBUFFEROBJECTUI64VPROC) (GLuint id,GLuint buffer,GLenum pname,GLintptr offset); -typedef void (GLAPIENTRY * PFNGLGETQUERYBUFFEROBJECTUIVPROC) (GLuint id,GLuint buffer,GLenum pname,GLintptr offset); -typedef void (GLAPIENTRY * PFNGLGETTEXTUREIMAGEPROC) (GLuint texture, GLint level, GLenum format, GLenum type, GLsizei bufSize, void *pixels); -typedef void (GLAPIENTRY * PFNGLGETTEXTURELEVELPARAMETERFVPROC) (GLuint texture, GLint level, GLenum pname, GLfloat* params); -typedef void (GLAPIENTRY * PFNGLGETTEXTURELEVELPARAMETERIVPROC) (GLuint texture, GLint level, GLenum pname, GLint* params); -typedef void (GLAPIENTRY * PFNGLGETTEXTUREPARAMETERIIVPROC) (GLuint texture, GLenum pname, GLint* params); -typedef void (GLAPIENTRY * PFNGLGETTEXTUREPARAMETERIUIVPROC) (GLuint texture, GLenum pname, GLuint* params); -typedef void (GLAPIENTRY * PFNGLGETTEXTUREPARAMETERFVPROC) (GLuint texture, GLenum pname, GLfloat* params); -typedef void (GLAPIENTRY * PFNGLGETTEXTUREPARAMETERIVPROC) (GLuint texture, GLenum pname, GLint* params); -typedef void (GLAPIENTRY * PFNGLGETTRANSFORMFEEDBACKI64_VPROC) (GLuint xfb, GLenum pname, GLuint index, GLint64* param); -typedef void (GLAPIENTRY * PFNGLGETTRANSFORMFEEDBACKI_VPROC) (GLuint xfb, GLenum pname, GLuint index, GLint* param); -typedef void (GLAPIENTRY * PFNGLGETTRANSFORMFEEDBACKIVPROC) (GLuint xfb, GLenum pname, GLint* param); -typedef void (GLAPIENTRY * PFNGLGETVERTEXARRAYINDEXED64IVPROC) (GLuint vaobj, GLuint index, GLenum pname, GLint64* param); -typedef void (GLAPIENTRY * PFNGLGETVERTEXARRAYINDEXEDIVPROC) (GLuint vaobj, GLuint index, GLenum pname, GLint* param); -typedef void (GLAPIENTRY * PFNGLGETVERTEXARRAYIVPROC) (GLuint vaobj, GLenum pname, GLint* param); -typedef void (GLAPIENTRY * PFNGLINVALIDATENAMEDFRAMEBUFFERDATAPROC) (GLuint framebuffer, GLsizei numAttachments, const GLenum* attachments); -typedef void (GLAPIENTRY * PFNGLINVALIDATENAMEDFRAMEBUFFERSUBDATAPROC) (GLuint framebuffer, GLsizei numAttachments, const GLenum* attachments, GLint x, GLint y, GLsizei width, GLsizei height); -typedef void * (GLAPIENTRY * PFNGLMAPNAMEDBUFFERPROC) (GLuint buffer, GLenum access); -typedef void * (GLAPIENTRY * PFNGLMAPNAMEDBUFFERRANGEPROC) (GLuint buffer, GLintptr offset, GLsizeiptr length, GLbitfield access); -typedef void (GLAPIENTRY * PFNGLNAMEDBUFFERDATAPROC) (GLuint buffer, GLsizeiptr size, const void *data, GLenum usage); -typedef void (GLAPIENTRY * PFNGLNAMEDBUFFERSTORAGEPROC) (GLuint buffer, GLsizeiptr size, const void *data, GLbitfield flags); -typedef void (GLAPIENTRY * PFNGLNAMEDBUFFERSUBDATAPROC) (GLuint buffer, GLintptr offset, GLsizeiptr size, const void *data); -typedef void (GLAPIENTRY * PFNGLNAMEDFRAMEBUFFERDRAWBUFFERPROC) (GLuint framebuffer, GLenum mode); -typedef void (GLAPIENTRY * PFNGLNAMEDFRAMEBUFFERDRAWBUFFERSPROC) (GLuint framebuffer, GLsizei n, const GLenum* bufs); -typedef void (GLAPIENTRY * PFNGLNAMEDFRAMEBUFFERPARAMETERIPROC) (GLuint framebuffer, GLenum pname, GLint param); -typedef void (GLAPIENTRY * PFNGLNAMEDFRAMEBUFFERREADBUFFERPROC) (GLuint framebuffer, GLenum mode); -typedef void (GLAPIENTRY * PFNGLNAMEDFRAMEBUFFERRENDERBUFFERPROC) (GLuint framebuffer, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer); -typedef void (GLAPIENTRY * PFNGLNAMEDFRAMEBUFFERTEXTUREPROC) (GLuint framebuffer, GLenum attachment, GLuint texture, GLint level); -typedef void (GLAPIENTRY * PFNGLNAMEDFRAMEBUFFERTEXTURELAYERPROC) (GLuint framebuffer, GLenum attachment, GLuint texture, GLint level, GLint layer); -typedef void (GLAPIENTRY * PFNGLNAMEDRENDERBUFFERSTORAGEPROC) (GLuint renderbuffer, GLenum internalformat, GLsizei width, GLsizei height); -typedef void (GLAPIENTRY * PFNGLNAMEDRENDERBUFFERSTORAGEMULTISAMPLEPROC) (GLuint renderbuffer, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height); -typedef void (GLAPIENTRY * PFNGLTEXTUREBUFFERPROC) (GLuint texture, GLenum internalformat, GLuint buffer); -typedef void (GLAPIENTRY * PFNGLTEXTUREBUFFERRANGEPROC) (GLuint texture, GLenum internalformat, GLuint buffer, GLintptr offset, GLsizeiptr size); -typedef void (GLAPIENTRY * PFNGLTEXTUREPARAMETERIIVPROC) (GLuint texture, GLenum pname, const GLint* params); -typedef void (GLAPIENTRY * PFNGLTEXTUREPARAMETERIUIVPROC) (GLuint texture, GLenum pname, const GLuint* params); -typedef void (GLAPIENTRY * PFNGLTEXTUREPARAMETERFPROC) (GLuint texture, GLenum pname, GLfloat param); -typedef void (GLAPIENTRY * PFNGLTEXTUREPARAMETERFVPROC) (GLuint texture, GLenum pname, const GLfloat* param); -typedef void (GLAPIENTRY * PFNGLTEXTUREPARAMETERIPROC) (GLuint texture, GLenum pname, GLint param); -typedef void (GLAPIENTRY * PFNGLTEXTUREPARAMETERIVPROC) (GLuint texture, GLenum pname, const GLint* param); -typedef void (GLAPIENTRY * PFNGLTEXTURESTORAGE1DPROC) (GLuint texture, GLsizei levels, GLenum internalformat, GLsizei width); -typedef void (GLAPIENTRY * PFNGLTEXTURESTORAGE2DPROC) (GLuint texture, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height); -typedef void (GLAPIENTRY * PFNGLTEXTURESTORAGE2DMULTISAMPLEPROC) (GLuint texture, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLboolean fixedsamplelocations); -typedef void (GLAPIENTRY * PFNGLTEXTURESTORAGE3DPROC) (GLuint texture, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth); -typedef void (GLAPIENTRY * PFNGLTEXTURESTORAGE3DMULTISAMPLEPROC) (GLuint texture, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedsamplelocations); -typedef void (GLAPIENTRY * PFNGLTEXTURESUBIMAGE1DPROC) (GLuint texture, GLint level, GLint xoffset, GLsizei width, GLenum format, GLenum type, const void *pixels); -typedef void (GLAPIENTRY * PFNGLTEXTURESUBIMAGE2DPROC) (GLuint texture, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const void *pixels); -typedef void (GLAPIENTRY * PFNGLTEXTURESUBIMAGE3DPROC) (GLuint texture, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const void *pixels); -typedef void (GLAPIENTRY * PFNGLTRANSFORMFEEDBACKBUFFERBASEPROC) (GLuint xfb, GLuint index, GLuint buffer); -typedef void (GLAPIENTRY * PFNGLTRANSFORMFEEDBACKBUFFERRANGEPROC) (GLuint xfb, GLuint index, GLuint buffer, GLintptr offset, GLsizeiptr size); -typedef GLboolean (GLAPIENTRY * PFNGLUNMAPNAMEDBUFFERPROC) (GLuint buffer); -typedef void (GLAPIENTRY * PFNGLVERTEXARRAYATTRIBBINDINGPROC) (GLuint vaobj, GLuint attribindex, GLuint bindingindex); -typedef void (GLAPIENTRY * PFNGLVERTEXARRAYATTRIBFORMATPROC) (GLuint vaobj, GLuint attribindex, GLint size, GLenum type, GLboolean normalized, GLuint relativeoffset); -typedef void (GLAPIENTRY * PFNGLVERTEXARRAYATTRIBIFORMATPROC) (GLuint vaobj, GLuint attribindex, GLint size, GLenum type, GLuint relativeoffset); -typedef void (GLAPIENTRY * PFNGLVERTEXARRAYATTRIBLFORMATPROC) (GLuint vaobj, GLuint attribindex, GLint size, GLenum type, GLuint relativeoffset); -typedef void (GLAPIENTRY * PFNGLVERTEXARRAYBINDINGDIVISORPROC) (GLuint vaobj, GLuint bindingindex, GLuint divisor); -typedef void (GLAPIENTRY * PFNGLVERTEXARRAYELEMENTBUFFERPROC) (GLuint vaobj, GLuint buffer); -typedef void (GLAPIENTRY * PFNGLVERTEXARRAYVERTEXBUFFERPROC) (GLuint vaobj, GLuint bindingindex, GLuint buffer, GLintptr offset, GLsizei stride); -typedef void (GLAPIENTRY * PFNGLVERTEXARRAYVERTEXBUFFERSPROC) (GLuint vaobj, GLuint first, GLsizei count, const GLuint* buffers, const GLintptr *offsets, const GLsizei *strides); - -#define glBindTextureUnit GLEW_GET_FUN(__glewBindTextureUnit) -#define glBlitNamedFramebuffer GLEW_GET_FUN(__glewBlitNamedFramebuffer) -#define glCheckNamedFramebufferStatus GLEW_GET_FUN(__glewCheckNamedFramebufferStatus) -#define glClearNamedBufferData GLEW_GET_FUN(__glewClearNamedBufferData) -#define glClearNamedBufferSubData GLEW_GET_FUN(__glewClearNamedBufferSubData) -#define glClearNamedFramebufferfi GLEW_GET_FUN(__glewClearNamedFramebufferfi) -#define glClearNamedFramebufferfv GLEW_GET_FUN(__glewClearNamedFramebufferfv) -#define glClearNamedFramebufferiv GLEW_GET_FUN(__glewClearNamedFramebufferiv) -#define glClearNamedFramebufferuiv GLEW_GET_FUN(__glewClearNamedFramebufferuiv) -#define glCompressedTextureSubImage1D GLEW_GET_FUN(__glewCompressedTextureSubImage1D) -#define glCompressedTextureSubImage2D GLEW_GET_FUN(__glewCompressedTextureSubImage2D) -#define glCompressedTextureSubImage3D GLEW_GET_FUN(__glewCompressedTextureSubImage3D) -#define glCopyNamedBufferSubData GLEW_GET_FUN(__glewCopyNamedBufferSubData) -#define glCopyTextureSubImage1D GLEW_GET_FUN(__glewCopyTextureSubImage1D) -#define glCopyTextureSubImage2D GLEW_GET_FUN(__glewCopyTextureSubImage2D) -#define glCopyTextureSubImage3D GLEW_GET_FUN(__glewCopyTextureSubImage3D) -#define glCreateBuffers GLEW_GET_FUN(__glewCreateBuffers) -#define glCreateFramebuffers GLEW_GET_FUN(__glewCreateFramebuffers) -#define glCreateProgramPipelines GLEW_GET_FUN(__glewCreateProgramPipelines) -#define glCreateQueries GLEW_GET_FUN(__glewCreateQueries) -#define glCreateRenderbuffers GLEW_GET_FUN(__glewCreateRenderbuffers) -#define glCreateSamplers GLEW_GET_FUN(__glewCreateSamplers) -#define glCreateTextures GLEW_GET_FUN(__glewCreateTextures) -#define glCreateTransformFeedbacks GLEW_GET_FUN(__glewCreateTransformFeedbacks) -#define glCreateVertexArrays GLEW_GET_FUN(__glewCreateVertexArrays) -#define glDisableVertexArrayAttrib GLEW_GET_FUN(__glewDisableVertexArrayAttrib) -#define glEnableVertexArrayAttrib GLEW_GET_FUN(__glewEnableVertexArrayAttrib) -#define glFlushMappedNamedBufferRange GLEW_GET_FUN(__glewFlushMappedNamedBufferRange) -#define glGenerateTextureMipmap GLEW_GET_FUN(__glewGenerateTextureMipmap) -#define glGetCompressedTextureImage GLEW_GET_FUN(__glewGetCompressedTextureImage) -#define glGetNamedBufferParameteri64v GLEW_GET_FUN(__glewGetNamedBufferParameteri64v) -#define glGetNamedBufferParameteriv GLEW_GET_FUN(__glewGetNamedBufferParameteriv) -#define glGetNamedBufferPointerv GLEW_GET_FUN(__glewGetNamedBufferPointerv) -#define glGetNamedBufferSubData GLEW_GET_FUN(__glewGetNamedBufferSubData) -#define glGetNamedFramebufferAttachmentParameteriv GLEW_GET_FUN(__glewGetNamedFramebufferAttachmentParameteriv) -#define glGetNamedFramebufferParameteriv GLEW_GET_FUN(__glewGetNamedFramebufferParameteriv) -#define glGetNamedRenderbufferParameteriv GLEW_GET_FUN(__glewGetNamedRenderbufferParameteriv) -#define glGetQueryBufferObjecti64v GLEW_GET_FUN(__glewGetQueryBufferObjecti64v) -#define glGetQueryBufferObjectiv GLEW_GET_FUN(__glewGetQueryBufferObjectiv) -#define glGetQueryBufferObjectui64v GLEW_GET_FUN(__glewGetQueryBufferObjectui64v) -#define glGetQueryBufferObjectuiv GLEW_GET_FUN(__glewGetQueryBufferObjectuiv) -#define glGetTextureImage GLEW_GET_FUN(__glewGetTextureImage) -#define glGetTextureLevelParameterfv GLEW_GET_FUN(__glewGetTextureLevelParameterfv) -#define glGetTextureLevelParameteriv GLEW_GET_FUN(__glewGetTextureLevelParameteriv) -#define glGetTextureParameterIiv GLEW_GET_FUN(__glewGetTextureParameterIiv) -#define glGetTextureParameterIuiv GLEW_GET_FUN(__glewGetTextureParameterIuiv) -#define glGetTextureParameterfv GLEW_GET_FUN(__glewGetTextureParameterfv) -#define glGetTextureParameteriv GLEW_GET_FUN(__glewGetTextureParameteriv) -#define glGetTransformFeedbacki64_v GLEW_GET_FUN(__glewGetTransformFeedbacki64_v) -#define glGetTransformFeedbacki_v GLEW_GET_FUN(__glewGetTransformFeedbacki_v) -#define glGetTransformFeedbackiv GLEW_GET_FUN(__glewGetTransformFeedbackiv) -#define glGetVertexArrayIndexed64iv GLEW_GET_FUN(__glewGetVertexArrayIndexed64iv) -#define glGetVertexArrayIndexediv GLEW_GET_FUN(__glewGetVertexArrayIndexediv) -#define glGetVertexArrayiv GLEW_GET_FUN(__glewGetVertexArrayiv) -#define glInvalidateNamedFramebufferData GLEW_GET_FUN(__glewInvalidateNamedFramebufferData) -#define glInvalidateNamedFramebufferSubData GLEW_GET_FUN(__glewInvalidateNamedFramebufferSubData) -#define glMapNamedBuffer GLEW_GET_FUN(__glewMapNamedBuffer) -#define glMapNamedBufferRange GLEW_GET_FUN(__glewMapNamedBufferRange) -#define glNamedBufferData GLEW_GET_FUN(__glewNamedBufferData) -#define glNamedBufferStorage GLEW_GET_FUN(__glewNamedBufferStorage) -#define glNamedBufferSubData GLEW_GET_FUN(__glewNamedBufferSubData) -#define glNamedFramebufferDrawBuffer GLEW_GET_FUN(__glewNamedFramebufferDrawBuffer) -#define glNamedFramebufferDrawBuffers GLEW_GET_FUN(__glewNamedFramebufferDrawBuffers) -#define glNamedFramebufferParameteri GLEW_GET_FUN(__glewNamedFramebufferParameteri) -#define glNamedFramebufferReadBuffer GLEW_GET_FUN(__glewNamedFramebufferReadBuffer) -#define glNamedFramebufferRenderbuffer GLEW_GET_FUN(__glewNamedFramebufferRenderbuffer) -#define glNamedFramebufferTexture GLEW_GET_FUN(__glewNamedFramebufferTexture) -#define glNamedFramebufferTextureLayer GLEW_GET_FUN(__glewNamedFramebufferTextureLayer) -#define glNamedRenderbufferStorage GLEW_GET_FUN(__glewNamedRenderbufferStorage) -#define glNamedRenderbufferStorageMultisample GLEW_GET_FUN(__glewNamedRenderbufferStorageMultisample) -#define glTextureBuffer GLEW_GET_FUN(__glewTextureBuffer) -#define glTextureBufferRange GLEW_GET_FUN(__glewTextureBufferRange) -#define glTextureParameterIiv GLEW_GET_FUN(__glewTextureParameterIiv) -#define glTextureParameterIuiv GLEW_GET_FUN(__glewTextureParameterIuiv) -#define glTextureParameterf GLEW_GET_FUN(__glewTextureParameterf) -#define glTextureParameterfv GLEW_GET_FUN(__glewTextureParameterfv) -#define glTextureParameteri GLEW_GET_FUN(__glewTextureParameteri) -#define glTextureParameteriv GLEW_GET_FUN(__glewTextureParameteriv) -#define glTextureStorage1D GLEW_GET_FUN(__glewTextureStorage1D) -#define glTextureStorage2D GLEW_GET_FUN(__glewTextureStorage2D) -#define glTextureStorage2DMultisample GLEW_GET_FUN(__glewTextureStorage2DMultisample) -#define glTextureStorage3D GLEW_GET_FUN(__glewTextureStorage3D) -#define glTextureStorage3DMultisample GLEW_GET_FUN(__glewTextureStorage3DMultisample) -#define glTextureSubImage1D GLEW_GET_FUN(__glewTextureSubImage1D) -#define glTextureSubImage2D GLEW_GET_FUN(__glewTextureSubImage2D) -#define glTextureSubImage3D GLEW_GET_FUN(__glewTextureSubImage3D) -#define glTransformFeedbackBufferBase GLEW_GET_FUN(__glewTransformFeedbackBufferBase) -#define glTransformFeedbackBufferRange GLEW_GET_FUN(__glewTransformFeedbackBufferRange) -#define glUnmapNamedBuffer GLEW_GET_FUN(__glewUnmapNamedBuffer) -#define glVertexArrayAttribBinding GLEW_GET_FUN(__glewVertexArrayAttribBinding) -#define glVertexArrayAttribFormat GLEW_GET_FUN(__glewVertexArrayAttribFormat) -#define glVertexArrayAttribIFormat GLEW_GET_FUN(__glewVertexArrayAttribIFormat) -#define glVertexArrayAttribLFormat GLEW_GET_FUN(__glewVertexArrayAttribLFormat) -#define glVertexArrayBindingDivisor GLEW_GET_FUN(__glewVertexArrayBindingDivisor) -#define glVertexArrayElementBuffer GLEW_GET_FUN(__glewVertexArrayElementBuffer) -#define glVertexArrayVertexBuffer GLEW_GET_FUN(__glewVertexArrayVertexBuffer) -#define glVertexArrayVertexBuffers GLEW_GET_FUN(__glewVertexArrayVertexBuffers) - -#define GLEW_ARB_direct_state_access GLEW_GET_VAR(__GLEW_ARB_direct_state_access) - -#endif /* GL_ARB_direct_state_access */ - -/* -------------------------- GL_ARB_draw_buffers -------------------------- */ - -#ifndef GL_ARB_draw_buffers -#define GL_ARB_draw_buffers 1 - -#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 - -typedef void (GLAPIENTRY * PFNGLDRAWBUFFERSARBPROC) (GLsizei n, const GLenum* bufs); - -#define glDrawBuffersARB GLEW_GET_FUN(__glewDrawBuffersARB) - -#define GLEW_ARB_draw_buffers GLEW_GET_VAR(__GLEW_ARB_draw_buffers) - -#endif /* GL_ARB_draw_buffers */ - -/* ----------------------- GL_ARB_draw_buffers_blend ----------------------- */ - -#ifndef GL_ARB_draw_buffers_blend -#define GL_ARB_draw_buffers_blend 1 - -typedef void (GLAPIENTRY * PFNGLBLENDEQUATIONSEPARATEIARBPROC) (GLuint buf, GLenum modeRGB, GLenum modeAlpha); -typedef void (GLAPIENTRY * PFNGLBLENDEQUATIONIARBPROC) (GLuint buf, GLenum mode); -typedef void (GLAPIENTRY * PFNGLBLENDFUNCSEPARATEIARBPROC) (GLuint buf, GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha); -typedef void (GLAPIENTRY * PFNGLBLENDFUNCIARBPROC) (GLuint buf, GLenum src, GLenum dst); - -#define glBlendEquationSeparateiARB GLEW_GET_FUN(__glewBlendEquationSeparateiARB) -#define glBlendEquationiARB GLEW_GET_FUN(__glewBlendEquationiARB) -#define glBlendFuncSeparateiARB GLEW_GET_FUN(__glewBlendFuncSeparateiARB) -#define glBlendFunciARB GLEW_GET_FUN(__glewBlendFunciARB) - -#define GLEW_ARB_draw_buffers_blend GLEW_GET_VAR(__GLEW_ARB_draw_buffers_blend) - -#endif /* GL_ARB_draw_buffers_blend */ - -/* -------------------- GL_ARB_draw_elements_base_vertex ------------------- */ - -#ifndef GL_ARB_draw_elements_base_vertex -#define GL_ARB_draw_elements_base_vertex 1 - -typedef void (GLAPIENTRY * PFNGLDRAWELEMENTSBASEVERTEXPROC) (GLenum mode, GLsizei count, GLenum type, const void *indices, GLint basevertex); -typedef void (GLAPIENTRY * PFNGLDRAWELEMENTSINSTANCEDBASEVERTEXPROC) (GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei primcount, GLint basevertex); -typedef void (GLAPIENTRY * PFNGLDRAWRANGEELEMENTSBASEVERTEXPROC) (GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const void *indices, GLint basevertex); -typedef void (GLAPIENTRY * PFNGLMULTIDRAWELEMENTSBASEVERTEXPROC) (GLenum mode, const GLsizei* count, GLenum type, const void *const *indices, GLsizei primcount, const GLint *basevertex); - -#define glDrawElementsBaseVertex GLEW_GET_FUN(__glewDrawElementsBaseVertex) -#define glDrawElementsInstancedBaseVertex GLEW_GET_FUN(__glewDrawElementsInstancedBaseVertex) -#define glDrawRangeElementsBaseVertex GLEW_GET_FUN(__glewDrawRangeElementsBaseVertex) -#define glMultiDrawElementsBaseVertex GLEW_GET_FUN(__glewMultiDrawElementsBaseVertex) - -#define GLEW_ARB_draw_elements_base_vertex GLEW_GET_VAR(__GLEW_ARB_draw_elements_base_vertex) - -#endif /* GL_ARB_draw_elements_base_vertex */ - -/* -------------------------- GL_ARB_draw_indirect ------------------------- */ - -#ifndef GL_ARB_draw_indirect -#define GL_ARB_draw_indirect 1 - -#define GL_DRAW_INDIRECT_BUFFER 0x8F3F -#define GL_DRAW_INDIRECT_BUFFER_BINDING 0x8F43 - -typedef void (GLAPIENTRY * PFNGLDRAWARRAYSINDIRECTPROC) (GLenum mode, const void *indirect); -typedef void (GLAPIENTRY * PFNGLDRAWELEMENTSINDIRECTPROC) (GLenum mode, GLenum type, const void *indirect); - -#define glDrawArraysIndirect GLEW_GET_FUN(__glewDrawArraysIndirect) -#define glDrawElementsIndirect GLEW_GET_FUN(__glewDrawElementsIndirect) - -#define GLEW_ARB_draw_indirect GLEW_GET_VAR(__GLEW_ARB_draw_indirect) - -#endif /* GL_ARB_draw_indirect */ - -/* ------------------------- GL_ARB_draw_instanced ------------------------- */ - -#ifndef GL_ARB_draw_instanced -#define GL_ARB_draw_instanced 1 - -#define GLEW_ARB_draw_instanced GLEW_GET_VAR(__GLEW_ARB_draw_instanced) - -#endif /* GL_ARB_draw_instanced */ - -/* ------------------------ GL_ARB_enhanced_layouts ------------------------ */ - -#ifndef GL_ARB_enhanced_layouts -#define GL_ARB_enhanced_layouts 1 - -#define GL_LOCATION_COMPONENT 0x934A -#define GL_TRANSFORM_FEEDBACK_BUFFER_INDEX 0x934B -#define GL_TRANSFORM_FEEDBACK_BUFFER_STRIDE 0x934C - -#define GLEW_ARB_enhanced_layouts GLEW_GET_VAR(__GLEW_ARB_enhanced_layouts) - -#endif /* GL_ARB_enhanced_layouts */ - -/* -------------------- GL_ARB_explicit_attrib_location -------------------- */ - -#ifndef GL_ARB_explicit_attrib_location -#define GL_ARB_explicit_attrib_location 1 - -#define GLEW_ARB_explicit_attrib_location GLEW_GET_VAR(__GLEW_ARB_explicit_attrib_location) - -#endif /* GL_ARB_explicit_attrib_location */ - -/* -------------------- GL_ARB_explicit_uniform_location ------------------- */ - -#ifndef GL_ARB_explicit_uniform_location -#define GL_ARB_explicit_uniform_location 1 - -#define GL_MAX_UNIFORM_LOCATIONS 0x826E - -#define GLEW_ARB_explicit_uniform_location GLEW_GET_VAR(__GLEW_ARB_explicit_uniform_location) - -#endif /* GL_ARB_explicit_uniform_location */ - -/* ------------------- GL_ARB_fragment_coord_conventions ------------------- */ - -#ifndef GL_ARB_fragment_coord_conventions -#define GL_ARB_fragment_coord_conventions 1 - -#define GLEW_ARB_fragment_coord_conventions GLEW_GET_VAR(__GLEW_ARB_fragment_coord_conventions) - -#endif /* GL_ARB_fragment_coord_conventions */ - -/* --------------------- GL_ARB_fragment_layer_viewport -------------------- */ - -#ifndef GL_ARB_fragment_layer_viewport -#define GL_ARB_fragment_layer_viewport 1 - -#define GLEW_ARB_fragment_layer_viewport GLEW_GET_VAR(__GLEW_ARB_fragment_layer_viewport) - -#endif /* GL_ARB_fragment_layer_viewport */ - -/* ------------------------ GL_ARB_fragment_program ------------------------ */ - -#ifndef GL_ARB_fragment_program -#define GL_ARB_fragment_program 1 - -#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 - -#define GLEW_ARB_fragment_program GLEW_GET_VAR(__GLEW_ARB_fragment_program) - -#endif /* GL_ARB_fragment_program */ - -/* --------------------- GL_ARB_fragment_program_shadow -------------------- */ - -#ifndef GL_ARB_fragment_program_shadow -#define GL_ARB_fragment_program_shadow 1 - -#define GLEW_ARB_fragment_program_shadow GLEW_GET_VAR(__GLEW_ARB_fragment_program_shadow) - -#endif /* GL_ARB_fragment_program_shadow */ - -/* ------------------------- GL_ARB_fragment_shader ------------------------ */ - -#ifndef GL_ARB_fragment_shader -#define GL_ARB_fragment_shader 1 - -#define GL_FRAGMENT_SHADER_ARB 0x8B30 -#define GL_MAX_FRAGMENT_UNIFORM_COMPONENTS_ARB 0x8B49 -#define GL_FRAGMENT_SHADER_DERIVATIVE_HINT_ARB 0x8B8B - -#define GLEW_ARB_fragment_shader GLEW_GET_VAR(__GLEW_ARB_fragment_shader) - -#endif /* GL_ARB_fragment_shader */ - -/* -------------------- GL_ARB_fragment_shader_interlock ------------------- */ - -#ifndef GL_ARB_fragment_shader_interlock -#define GL_ARB_fragment_shader_interlock 1 - -#define GLEW_ARB_fragment_shader_interlock GLEW_GET_VAR(__GLEW_ARB_fragment_shader_interlock) - -#endif /* GL_ARB_fragment_shader_interlock */ - -/* ------------------- GL_ARB_framebuffer_no_attachments ------------------- */ - -#ifndef GL_ARB_framebuffer_no_attachments -#define GL_ARB_framebuffer_no_attachments 1 - -#define GL_FRAMEBUFFER_DEFAULT_WIDTH 0x9310 -#define GL_FRAMEBUFFER_DEFAULT_HEIGHT 0x9311 -#define GL_FRAMEBUFFER_DEFAULT_LAYERS 0x9312 -#define GL_FRAMEBUFFER_DEFAULT_SAMPLES 0x9313 -#define GL_FRAMEBUFFER_DEFAULT_FIXED_SAMPLE_LOCATIONS 0x9314 -#define GL_MAX_FRAMEBUFFER_WIDTH 0x9315 -#define GL_MAX_FRAMEBUFFER_HEIGHT 0x9316 -#define GL_MAX_FRAMEBUFFER_LAYERS 0x9317 -#define GL_MAX_FRAMEBUFFER_SAMPLES 0x9318 - -typedef void (GLAPIENTRY * PFNGLFRAMEBUFFERPARAMETERIPROC) (GLenum target, GLenum pname, GLint param); -typedef void (GLAPIENTRY * PFNGLGETFRAMEBUFFERPARAMETERIVPROC) (GLenum target, GLenum pname, GLint* params); -typedef void (GLAPIENTRY * PFNGLGETNAMEDFRAMEBUFFERPARAMETERIVEXTPROC) (GLuint framebuffer, GLenum pname, GLint* params); -typedef void (GLAPIENTRY * PFNGLNAMEDFRAMEBUFFERPARAMETERIEXTPROC) (GLuint framebuffer, GLenum pname, GLint param); - -#define glFramebufferParameteri GLEW_GET_FUN(__glewFramebufferParameteri) -#define glGetFramebufferParameteriv GLEW_GET_FUN(__glewGetFramebufferParameteriv) -#define glGetNamedFramebufferParameterivEXT GLEW_GET_FUN(__glewGetNamedFramebufferParameterivEXT) -#define glNamedFramebufferParameteriEXT GLEW_GET_FUN(__glewNamedFramebufferParameteriEXT) - -#define GLEW_ARB_framebuffer_no_attachments GLEW_GET_VAR(__GLEW_ARB_framebuffer_no_attachments) - -#endif /* GL_ARB_framebuffer_no_attachments */ - -/* ----------------------- GL_ARB_framebuffer_object ----------------------- */ - -#ifndef GL_ARB_framebuffer_object -#define GL_ARB_framebuffer_object 1 - -#define GL_INVALID_FRAMEBUFFER_OPERATION 0x0506 -#define GL_FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING 0x8210 -#define GL_FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE 0x8211 -#define GL_FRAMEBUFFER_ATTACHMENT_RED_SIZE 0x8212 -#define GL_FRAMEBUFFER_ATTACHMENT_GREEN_SIZE 0x8213 -#define GL_FRAMEBUFFER_ATTACHMENT_BLUE_SIZE 0x8214 -#define GL_FRAMEBUFFER_ATTACHMENT_ALPHA_SIZE 0x8215 -#define GL_FRAMEBUFFER_ATTACHMENT_DEPTH_SIZE 0x8216 -#define GL_FRAMEBUFFER_ATTACHMENT_STENCIL_SIZE 0x8217 -#define GL_FRAMEBUFFER_DEFAULT 0x8218 -#define GL_FRAMEBUFFER_UNDEFINED 0x8219 -#define GL_DEPTH_STENCIL_ATTACHMENT 0x821A -#define GL_INDEX 0x8222 -#define GL_MAX_RENDERBUFFER_SIZE 0x84E8 -#define GL_DEPTH_STENCIL 0x84F9 -#define GL_UNSIGNED_INT_24_8 0x84FA -#define GL_DEPTH24_STENCIL8 0x88F0 -#define GL_TEXTURE_STENCIL_SIZE 0x88F1 -#define GL_UNSIGNED_NORMALIZED 0x8C17 -#define GL_SRGB 0x8C40 -#define GL_DRAW_FRAMEBUFFER_BINDING 0x8CA6 -#define GL_FRAMEBUFFER_BINDING 0x8CA6 -#define GL_RENDERBUFFER_BINDING 0x8CA7 -#define GL_READ_FRAMEBUFFER 0x8CA8 -#define GL_DRAW_FRAMEBUFFER 0x8CA9 -#define GL_READ_FRAMEBUFFER_BINDING 0x8CAA -#define GL_RENDERBUFFER_SAMPLES 0x8CAB -#define GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE 0x8CD0 -#define GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME 0x8CD1 -#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL 0x8CD2 -#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE 0x8CD3 -#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER 0x8CD4 -#define GL_FRAMEBUFFER_COMPLETE 0x8CD5 -#define GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT 0x8CD6 -#define GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT 0x8CD7 -#define GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER 0x8CDB -#define GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER 0x8CDC -#define GL_FRAMEBUFFER_UNSUPPORTED 0x8CDD -#define GL_MAX_COLOR_ATTACHMENTS 0x8CDF -#define GL_COLOR_ATTACHMENT0 0x8CE0 -#define GL_COLOR_ATTACHMENT1 0x8CE1 -#define GL_COLOR_ATTACHMENT2 0x8CE2 -#define GL_COLOR_ATTACHMENT3 0x8CE3 -#define GL_COLOR_ATTACHMENT4 0x8CE4 -#define GL_COLOR_ATTACHMENT5 0x8CE5 -#define GL_COLOR_ATTACHMENT6 0x8CE6 -#define GL_COLOR_ATTACHMENT7 0x8CE7 -#define GL_COLOR_ATTACHMENT8 0x8CE8 -#define GL_COLOR_ATTACHMENT9 0x8CE9 -#define GL_COLOR_ATTACHMENT10 0x8CEA -#define GL_COLOR_ATTACHMENT11 0x8CEB -#define GL_COLOR_ATTACHMENT12 0x8CEC -#define GL_COLOR_ATTACHMENT13 0x8CED -#define GL_COLOR_ATTACHMENT14 0x8CEE -#define GL_COLOR_ATTACHMENT15 0x8CEF -#define GL_DEPTH_ATTACHMENT 0x8D00 -#define GL_STENCIL_ATTACHMENT 0x8D20 -#define GL_FRAMEBUFFER 0x8D40 -#define GL_RENDERBUFFER 0x8D41 -#define GL_RENDERBUFFER_WIDTH 0x8D42 -#define GL_RENDERBUFFER_HEIGHT 0x8D43 -#define GL_RENDERBUFFER_INTERNAL_FORMAT 0x8D44 -#define GL_STENCIL_INDEX1 0x8D46 -#define GL_STENCIL_INDEX4 0x8D47 -#define GL_STENCIL_INDEX8 0x8D48 -#define GL_STENCIL_INDEX16 0x8D49 -#define GL_RENDERBUFFER_RED_SIZE 0x8D50 -#define GL_RENDERBUFFER_GREEN_SIZE 0x8D51 -#define GL_RENDERBUFFER_BLUE_SIZE 0x8D52 -#define GL_RENDERBUFFER_ALPHA_SIZE 0x8D53 -#define GL_RENDERBUFFER_DEPTH_SIZE 0x8D54 -#define GL_RENDERBUFFER_STENCIL_SIZE 0x8D55 -#define GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE 0x8D56 -#define GL_MAX_SAMPLES 0x8D57 - -typedef void (GLAPIENTRY * PFNGLBINDFRAMEBUFFERPROC) (GLenum target, GLuint framebuffer); -typedef void (GLAPIENTRY * PFNGLBINDRENDERBUFFERPROC) (GLenum target, GLuint renderbuffer); -typedef void (GLAPIENTRY * PFNGLBLITFRAMEBUFFERPROC) (GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter); -typedef GLenum (GLAPIENTRY * PFNGLCHECKFRAMEBUFFERSTATUSPROC) (GLenum target); -typedef void (GLAPIENTRY * PFNGLDELETEFRAMEBUFFERSPROC) (GLsizei n, const GLuint* framebuffers); -typedef void (GLAPIENTRY * PFNGLDELETERENDERBUFFERSPROC) (GLsizei n, const GLuint* renderbuffers); -typedef void (GLAPIENTRY * PFNGLFRAMEBUFFERRENDERBUFFERPROC) (GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer); -typedef void (GLAPIENTRY * PFNGLFRAMEBUFFERTEXTURE1DPROC) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level); -typedef void (GLAPIENTRY * PFNGLFRAMEBUFFERTEXTURE2DPROC) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level); -typedef void (GLAPIENTRY * PFNGLFRAMEBUFFERTEXTURE3DPROC) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLint layer); -typedef void (GLAPIENTRY * PFNGLFRAMEBUFFERTEXTURELAYERPROC) (GLenum target,GLenum attachment, GLuint texture,GLint level,GLint layer); -typedef void (GLAPIENTRY * PFNGLGENFRAMEBUFFERSPROC) (GLsizei n, GLuint* framebuffers); -typedef void (GLAPIENTRY * PFNGLGENRENDERBUFFERSPROC) (GLsizei n, GLuint* renderbuffers); -typedef void (GLAPIENTRY * PFNGLGENERATEMIPMAPPROC) (GLenum target); -typedef void (GLAPIENTRY * PFNGLGETFRAMEBUFFERATTACHMENTPARAMETERIVPROC) (GLenum target, GLenum attachment, GLenum pname, GLint* params); -typedef void (GLAPIENTRY * PFNGLGETRENDERBUFFERPARAMETERIVPROC) (GLenum target, GLenum pname, GLint* params); -typedef GLboolean (GLAPIENTRY * PFNGLISFRAMEBUFFERPROC) (GLuint framebuffer); -typedef GLboolean (GLAPIENTRY * PFNGLISRENDERBUFFERPROC) (GLuint renderbuffer); -typedef void (GLAPIENTRY * PFNGLRENDERBUFFERSTORAGEPROC) (GLenum target, GLenum internalformat, GLsizei width, GLsizei height); -typedef void (GLAPIENTRY * PFNGLRENDERBUFFERSTORAGEMULTISAMPLEPROC) (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height); - -#define glBindFramebuffer GLEW_GET_FUN(__glewBindFramebuffer) -#define glBindRenderbuffer GLEW_GET_FUN(__glewBindRenderbuffer) -#define glBlitFramebuffer GLEW_GET_FUN(__glewBlitFramebuffer) -#define glCheckFramebufferStatus GLEW_GET_FUN(__glewCheckFramebufferStatus) -#define glDeleteFramebuffers GLEW_GET_FUN(__glewDeleteFramebuffers) -#define glDeleteRenderbuffers GLEW_GET_FUN(__glewDeleteRenderbuffers) -#define glFramebufferRenderbuffer GLEW_GET_FUN(__glewFramebufferRenderbuffer) -#define glFramebufferTexture1D GLEW_GET_FUN(__glewFramebufferTexture1D) -#define glFramebufferTexture2D GLEW_GET_FUN(__glewFramebufferTexture2D) -#define glFramebufferTexture3D GLEW_GET_FUN(__glewFramebufferTexture3D) -#define glFramebufferTextureLayer GLEW_GET_FUN(__glewFramebufferTextureLayer) -#define glGenFramebuffers GLEW_GET_FUN(__glewGenFramebuffers) -#define glGenRenderbuffers GLEW_GET_FUN(__glewGenRenderbuffers) -#define glGenerateMipmap GLEW_GET_FUN(__glewGenerateMipmap) -#define glGetFramebufferAttachmentParameteriv GLEW_GET_FUN(__glewGetFramebufferAttachmentParameteriv) -#define glGetRenderbufferParameteriv GLEW_GET_FUN(__glewGetRenderbufferParameteriv) -#define glIsFramebuffer GLEW_GET_FUN(__glewIsFramebuffer) -#define glIsRenderbuffer GLEW_GET_FUN(__glewIsRenderbuffer) -#define glRenderbufferStorage GLEW_GET_FUN(__glewRenderbufferStorage) -#define glRenderbufferStorageMultisample GLEW_GET_FUN(__glewRenderbufferStorageMultisample) - -#define GLEW_ARB_framebuffer_object GLEW_GET_VAR(__GLEW_ARB_framebuffer_object) - -#endif /* GL_ARB_framebuffer_object */ - -/* ------------------------ GL_ARB_framebuffer_sRGB ------------------------ */ - -#ifndef GL_ARB_framebuffer_sRGB -#define GL_ARB_framebuffer_sRGB 1 - -#define GL_FRAMEBUFFER_SRGB 0x8DB9 - -#define GLEW_ARB_framebuffer_sRGB GLEW_GET_VAR(__GLEW_ARB_framebuffer_sRGB) - -#endif /* GL_ARB_framebuffer_sRGB */ - -/* ------------------------ GL_ARB_geometry_shader4 ------------------------ */ - -#ifndef GL_ARB_geometry_shader4 -#define GL_ARB_geometry_shader4 1 - -#define GL_LINES_ADJACENCY_ARB 0xA -#define GL_LINE_STRIP_ADJACENCY_ARB 0xB -#define GL_TRIANGLES_ADJACENCY_ARB 0xC -#define GL_TRIANGLE_STRIP_ADJACENCY_ARB 0xD -#define GL_PROGRAM_POINT_SIZE_ARB 0x8642 -#define GL_MAX_GEOMETRY_TEXTURE_IMAGE_UNITS_ARB 0x8C29 -#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER 0x8CD4 -#define GL_FRAMEBUFFER_ATTACHMENT_LAYERED_ARB 0x8DA7 -#define GL_FRAMEBUFFER_INCOMPLETE_LAYER_TARGETS_ARB 0x8DA8 -#define GL_FRAMEBUFFER_INCOMPLETE_LAYER_COUNT_ARB 0x8DA9 -#define GL_GEOMETRY_SHADER_ARB 0x8DD9 -#define GL_GEOMETRY_VERTICES_OUT_ARB 0x8DDA -#define GL_GEOMETRY_INPUT_TYPE_ARB 0x8DDB -#define GL_GEOMETRY_OUTPUT_TYPE_ARB 0x8DDC -#define GL_MAX_GEOMETRY_VARYING_COMPONENTS_ARB 0x8DDD -#define GL_MAX_VERTEX_VARYING_COMPONENTS_ARB 0x8DDE -#define GL_MAX_GEOMETRY_UNIFORM_COMPONENTS_ARB 0x8DDF -#define GL_MAX_GEOMETRY_OUTPUT_VERTICES_ARB 0x8DE0 -#define GL_MAX_GEOMETRY_TOTAL_OUTPUT_COMPONENTS_ARB 0x8DE1 - -typedef void (GLAPIENTRY * PFNGLFRAMEBUFFERTEXTUREARBPROC) (GLenum target, GLenum attachment, GLuint texture, GLint level); -typedef void (GLAPIENTRY * PFNGLFRAMEBUFFERTEXTUREFACEARBPROC) (GLenum target, GLenum attachment, GLuint texture, GLint level, GLenum face); -typedef void (GLAPIENTRY * PFNGLFRAMEBUFFERTEXTURELAYERARBPROC) (GLenum target, GLenum attachment, GLuint texture, GLint level, GLint layer); -typedef void (GLAPIENTRY * PFNGLPROGRAMPARAMETERIARBPROC) (GLuint program, GLenum pname, GLint value); - -#define glFramebufferTextureARB GLEW_GET_FUN(__glewFramebufferTextureARB) -#define glFramebufferTextureFaceARB GLEW_GET_FUN(__glewFramebufferTextureFaceARB) -#define glFramebufferTextureLayerARB GLEW_GET_FUN(__glewFramebufferTextureLayerARB) -#define glProgramParameteriARB GLEW_GET_FUN(__glewProgramParameteriARB) - -#define GLEW_ARB_geometry_shader4 GLEW_GET_VAR(__GLEW_ARB_geometry_shader4) - -#endif /* GL_ARB_geometry_shader4 */ - -/* ----------------------- GL_ARB_get_program_binary ----------------------- */ - -#ifndef GL_ARB_get_program_binary -#define GL_ARB_get_program_binary 1 - -#define GL_PROGRAM_BINARY_RETRIEVABLE_HINT 0x8257 -#define GL_PROGRAM_BINARY_LENGTH 0x8741 -#define GL_NUM_PROGRAM_BINARY_FORMATS 0x87FE -#define GL_PROGRAM_BINARY_FORMATS 0x87FF - -typedef void (GLAPIENTRY * PFNGLGETPROGRAMBINARYPROC) (GLuint program, GLsizei bufSize, GLsizei* length, GLenum *binaryFormat, void*binary); -typedef void (GLAPIENTRY * PFNGLPROGRAMBINARYPROC) (GLuint program, GLenum binaryFormat, const void *binary, GLsizei length); -typedef void (GLAPIENTRY * PFNGLPROGRAMPARAMETERIPROC) (GLuint program, GLenum pname, GLint value); - -#define glGetProgramBinary GLEW_GET_FUN(__glewGetProgramBinary) -#define glProgramBinary GLEW_GET_FUN(__glewProgramBinary) -#define glProgramParameteri GLEW_GET_FUN(__glewProgramParameteri) - -#define GLEW_ARB_get_program_binary GLEW_GET_VAR(__GLEW_ARB_get_program_binary) - -#endif /* GL_ARB_get_program_binary */ - -/* ---------------------- GL_ARB_get_texture_sub_image --------------------- */ - -#ifndef GL_ARB_get_texture_sub_image -#define GL_ARB_get_texture_sub_image 1 - -typedef void (GLAPIENTRY * PFNGLGETCOMPRESSEDTEXTURESUBIMAGEPROC) (GLuint texture, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLsizei bufSize, void *pixels); -typedef void (GLAPIENTRY * PFNGLGETTEXTURESUBIMAGEPROC) (GLuint texture, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, GLsizei bufSize, void *pixels); - -#define glGetCompressedTextureSubImage GLEW_GET_FUN(__glewGetCompressedTextureSubImage) -#define glGetTextureSubImage GLEW_GET_FUN(__glewGetTextureSubImage) - -#define GLEW_ARB_get_texture_sub_image GLEW_GET_VAR(__GLEW_ARB_get_texture_sub_image) - -#endif /* GL_ARB_get_texture_sub_image */ - -/* ---------------------------- GL_ARB_gl_spirv ---------------------------- */ - -#ifndef GL_ARB_gl_spirv -#define GL_ARB_gl_spirv 1 - -#define GL_SHADER_BINARY_FORMAT_SPIR_V_ARB 0x9551 -#define GL_SPIR_V_BINARY_ARB 0x9552 - -typedef void (GLAPIENTRY * PFNGLSPECIALIZESHADERARBPROC) (GLuint shader, const GLchar* pEntryPoint, GLuint numSpecializationConstants, const GLuint* pConstantIndex, const GLuint* pConstantValue); - -#define glSpecializeShaderARB GLEW_GET_FUN(__glewSpecializeShaderARB) - -#define GLEW_ARB_gl_spirv GLEW_GET_VAR(__GLEW_ARB_gl_spirv) - -#endif /* GL_ARB_gl_spirv */ - -/* --------------------------- GL_ARB_gpu_shader5 -------------------------- */ - -#ifndef GL_ARB_gpu_shader5 -#define GL_ARB_gpu_shader5 1 - -#define GL_GEOMETRY_SHADER_INVOCATIONS 0x887F -#define GL_MAX_GEOMETRY_SHADER_INVOCATIONS 0x8E5A -#define GL_MIN_FRAGMENT_INTERPOLATION_OFFSET 0x8E5B -#define GL_MAX_FRAGMENT_INTERPOLATION_OFFSET 0x8E5C -#define GL_FRAGMENT_INTERPOLATION_OFFSET_BITS 0x8E5D -#define GL_MAX_VERTEX_STREAMS 0x8E71 - -#define GLEW_ARB_gpu_shader5 GLEW_GET_VAR(__GLEW_ARB_gpu_shader5) - -#endif /* GL_ARB_gpu_shader5 */ - -/* ------------------------- GL_ARB_gpu_shader_fp64 ------------------------ */ - -#ifndef GL_ARB_gpu_shader_fp64 -#define GL_ARB_gpu_shader_fp64 1 - -#define GL_DOUBLE_MAT2 0x8F46 -#define GL_DOUBLE_MAT3 0x8F47 -#define GL_DOUBLE_MAT4 0x8F48 -#define GL_DOUBLE_MAT2x3 0x8F49 -#define GL_DOUBLE_MAT2x4 0x8F4A -#define GL_DOUBLE_MAT3x2 0x8F4B -#define GL_DOUBLE_MAT3x4 0x8F4C -#define GL_DOUBLE_MAT4x2 0x8F4D -#define GL_DOUBLE_MAT4x3 0x8F4E -#define GL_DOUBLE_VEC2 0x8FFC -#define GL_DOUBLE_VEC3 0x8FFD -#define GL_DOUBLE_VEC4 0x8FFE - -typedef void (GLAPIENTRY * PFNGLGETUNIFORMDVPROC) (GLuint program, GLint location, GLdouble* params); -typedef void (GLAPIENTRY * PFNGLUNIFORM1DPROC) (GLint location, GLdouble x); -typedef void (GLAPIENTRY * PFNGLUNIFORM1DVPROC) (GLint location, GLsizei count, const GLdouble* value); -typedef void (GLAPIENTRY * PFNGLUNIFORM2DPROC) (GLint location, GLdouble x, GLdouble y); -typedef void (GLAPIENTRY * PFNGLUNIFORM2DVPROC) (GLint location, GLsizei count, const GLdouble* value); -typedef void (GLAPIENTRY * PFNGLUNIFORM3DPROC) (GLint location, GLdouble x, GLdouble y, GLdouble z); -typedef void (GLAPIENTRY * PFNGLUNIFORM3DVPROC) (GLint location, GLsizei count, const GLdouble* value); -typedef void (GLAPIENTRY * PFNGLUNIFORM4DPROC) (GLint location, GLdouble x, GLdouble y, GLdouble z, GLdouble w); -typedef void (GLAPIENTRY * PFNGLUNIFORM4DVPROC) (GLint location, GLsizei count, const GLdouble* value); -typedef void (GLAPIENTRY * PFNGLUNIFORMMATRIX2DVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLdouble* value); -typedef void (GLAPIENTRY * PFNGLUNIFORMMATRIX2X3DVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLdouble* value); -typedef void (GLAPIENTRY * PFNGLUNIFORMMATRIX2X4DVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLdouble* value); -typedef void (GLAPIENTRY * PFNGLUNIFORMMATRIX3DVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLdouble* value); -typedef void (GLAPIENTRY * PFNGLUNIFORMMATRIX3X2DVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLdouble* value); -typedef void (GLAPIENTRY * PFNGLUNIFORMMATRIX3X4DVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLdouble* value); -typedef void (GLAPIENTRY * PFNGLUNIFORMMATRIX4DVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLdouble* value); -typedef void (GLAPIENTRY * PFNGLUNIFORMMATRIX4X2DVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLdouble* value); -typedef void (GLAPIENTRY * PFNGLUNIFORMMATRIX4X3DVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLdouble* value); - -#define glGetUniformdv GLEW_GET_FUN(__glewGetUniformdv) -#define glUniform1d GLEW_GET_FUN(__glewUniform1d) -#define glUniform1dv GLEW_GET_FUN(__glewUniform1dv) -#define glUniform2d GLEW_GET_FUN(__glewUniform2d) -#define glUniform2dv GLEW_GET_FUN(__glewUniform2dv) -#define glUniform3d GLEW_GET_FUN(__glewUniform3d) -#define glUniform3dv GLEW_GET_FUN(__glewUniform3dv) -#define glUniform4d GLEW_GET_FUN(__glewUniform4d) -#define glUniform4dv GLEW_GET_FUN(__glewUniform4dv) -#define glUniformMatrix2dv GLEW_GET_FUN(__glewUniformMatrix2dv) -#define glUniformMatrix2x3dv GLEW_GET_FUN(__glewUniformMatrix2x3dv) -#define glUniformMatrix2x4dv GLEW_GET_FUN(__glewUniformMatrix2x4dv) -#define glUniformMatrix3dv GLEW_GET_FUN(__glewUniformMatrix3dv) -#define glUniformMatrix3x2dv GLEW_GET_FUN(__glewUniformMatrix3x2dv) -#define glUniformMatrix3x4dv GLEW_GET_FUN(__glewUniformMatrix3x4dv) -#define glUniformMatrix4dv GLEW_GET_FUN(__glewUniformMatrix4dv) -#define glUniformMatrix4x2dv GLEW_GET_FUN(__glewUniformMatrix4x2dv) -#define glUniformMatrix4x3dv GLEW_GET_FUN(__glewUniformMatrix4x3dv) - -#define GLEW_ARB_gpu_shader_fp64 GLEW_GET_VAR(__GLEW_ARB_gpu_shader_fp64) - -#endif /* GL_ARB_gpu_shader_fp64 */ - -/* ------------------------ GL_ARB_gpu_shader_int64 ------------------------ */ - -#ifndef GL_ARB_gpu_shader_int64 -#define GL_ARB_gpu_shader_int64 1 - -#define GL_INT64_ARB 0x140E -#define GL_UNSIGNED_INT64_ARB 0x140F -#define GL_INT64_VEC2_ARB 0x8FE9 -#define GL_INT64_VEC3_ARB 0x8FEA -#define GL_INT64_VEC4_ARB 0x8FEB -#define GL_UNSIGNED_INT64_VEC2_ARB 0x8FF5 -#define GL_UNSIGNED_INT64_VEC3_ARB 0x8FF6 -#define GL_UNSIGNED_INT64_VEC4_ARB 0x8FF7 - -typedef void (GLAPIENTRY * PFNGLGETUNIFORMI64VARBPROC) (GLuint program, GLint location, GLint64* params); -typedef void (GLAPIENTRY * PFNGLGETUNIFORMUI64VARBPROC) (GLuint program, GLint location, GLuint64* params); -typedef void (GLAPIENTRY * PFNGLGETNUNIFORMI64VARBPROC) (GLuint program, GLint location, GLsizei bufSize, GLint64* params); -typedef void (GLAPIENTRY * PFNGLGETNUNIFORMUI64VARBPROC) (GLuint program, GLint location, GLsizei bufSize, GLuint64* params); -typedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM1I64ARBPROC) (GLuint program, GLint location, GLint64 x); -typedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM1I64VARBPROC) (GLuint program, GLint location, GLsizei count, const GLint64* value); -typedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM1UI64ARBPROC) (GLuint program, GLint location, GLuint64 x); -typedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM1UI64VARBPROC) (GLuint program, GLint location, GLsizei count, const GLuint64* value); -typedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM2I64ARBPROC) (GLuint program, GLint location, GLint64 x, GLint64 y); -typedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM2I64VARBPROC) (GLuint program, GLint location, GLsizei count, const GLint64* value); -typedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM2UI64ARBPROC) (GLuint program, GLint location, GLuint64 x, GLuint64 y); -typedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM2UI64VARBPROC) (GLuint program, GLint location, GLsizei count, const GLuint64* value); -typedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM3I64ARBPROC) (GLuint program, GLint location, GLint64 x, GLint64 y, GLint64 z); -typedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM3I64VARBPROC) (GLuint program, GLint location, GLsizei count, const GLint64* value); -typedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM3UI64ARBPROC) (GLuint program, GLint location, GLuint64 x, GLuint64 y, GLuint64 z); -typedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM3UI64VARBPROC) (GLuint program, GLint location, GLsizei count, const GLuint64* value); -typedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM4I64ARBPROC) (GLuint program, GLint location, GLint64 x, GLint64 y, GLint64 z, GLint64 w); -typedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM4I64VARBPROC) (GLuint program, GLint location, GLsizei count, const GLint64* value); -typedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM4UI64ARBPROC) (GLuint program, GLint location, GLuint64 x, GLuint64 y, GLuint64 z, GLuint64 w); -typedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM4UI64VARBPROC) (GLuint program, GLint location, GLsizei count, const GLuint64* value); -typedef void (GLAPIENTRY * PFNGLUNIFORM1I64ARBPROC) (GLint location, GLint64 x); -typedef void (GLAPIENTRY * PFNGLUNIFORM1I64VARBPROC) (GLint location, GLsizei count, const GLint64* value); -typedef void (GLAPIENTRY * PFNGLUNIFORM1UI64ARBPROC) (GLint location, GLuint64 x); -typedef void (GLAPIENTRY * PFNGLUNIFORM1UI64VARBPROC) (GLint location, GLsizei count, const GLuint64* value); -typedef void (GLAPIENTRY * PFNGLUNIFORM2I64ARBPROC) (GLint location, GLint64 x, GLint64 y); -typedef void (GLAPIENTRY * PFNGLUNIFORM2I64VARBPROC) (GLint location, GLsizei count, const GLint64* value); -typedef void (GLAPIENTRY * PFNGLUNIFORM2UI64ARBPROC) (GLint location, GLuint64 x, GLuint64 y); -typedef void (GLAPIENTRY * PFNGLUNIFORM2UI64VARBPROC) (GLint location, GLsizei count, const GLuint64* value); -typedef void (GLAPIENTRY * PFNGLUNIFORM3I64ARBPROC) (GLint location, GLint64 x, GLint64 y, GLint64 z); -typedef void (GLAPIENTRY * PFNGLUNIFORM3I64VARBPROC) (GLint location, GLsizei count, const GLint64* value); -typedef void (GLAPIENTRY * PFNGLUNIFORM3UI64ARBPROC) (GLint location, GLuint64 x, GLuint64 y, GLuint64 z); -typedef void (GLAPIENTRY * PFNGLUNIFORM3UI64VARBPROC) (GLint location, GLsizei count, const GLuint64* value); -typedef void (GLAPIENTRY * PFNGLUNIFORM4I64ARBPROC) (GLint location, GLint64 x, GLint64 y, GLint64 z, GLint64 w); -typedef void (GLAPIENTRY * PFNGLUNIFORM4I64VARBPROC) (GLint location, GLsizei count, const GLint64* value); -typedef void (GLAPIENTRY * PFNGLUNIFORM4UI64ARBPROC) (GLint location, GLuint64 x, GLuint64 y, GLuint64 z, GLuint64 w); -typedef void (GLAPIENTRY * PFNGLUNIFORM4UI64VARBPROC) (GLint location, GLsizei count, const GLuint64* value); - -#define glGetUniformi64vARB GLEW_GET_FUN(__glewGetUniformi64vARB) -#define glGetUniformui64vARB GLEW_GET_FUN(__glewGetUniformui64vARB) -#define glGetnUniformi64vARB GLEW_GET_FUN(__glewGetnUniformi64vARB) -#define glGetnUniformui64vARB GLEW_GET_FUN(__glewGetnUniformui64vARB) -#define glProgramUniform1i64ARB GLEW_GET_FUN(__glewProgramUniform1i64ARB) -#define glProgramUniform1i64vARB GLEW_GET_FUN(__glewProgramUniform1i64vARB) -#define glProgramUniform1ui64ARB GLEW_GET_FUN(__glewProgramUniform1ui64ARB) -#define glProgramUniform1ui64vARB GLEW_GET_FUN(__glewProgramUniform1ui64vARB) -#define glProgramUniform2i64ARB GLEW_GET_FUN(__glewProgramUniform2i64ARB) -#define glProgramUniform2i64vARB GLEW_GET_FUN(__glewProgramUniform2i64vARB) -#define glProgramUniform2ui64ARB GLEW_GET_FUN(__glewProgramUniform2ui64ARB) -#define glProgramUniform2ui64vARB GLEW_GET_FUN(__glewProgramUniform2ui64vARB) -#define glProgramUniform3i64ARB GLEW_GET_FUN(__glewProgramUniform3i64ARB) -#define glProgramUniform3i64vARB GLEW_GET_FUN(__glewProgramUniform3i64vARB) -#define glProgramUniform3ui64ARB GLEW_GET_FUN(__glewProgramUniform3ui64ARB) -#define glProgramUniform3ui64vARB GLEW_GET_FUN(__glewProgramUniform3ui64vARB) -#define glProgramUniform4i64ARB GLEW_GET_FUN(__glewProgramUniform4i64ARB) -#define glProgramUniform4i64vARB GLEW_GET_FUN(__glewProgramUniform4i64vARB) -#define glProgramUniform4ui64ARB GLEW_GET_FUN(__glewProgramUniform4ui64ARB) -#define glProgramUniform4ui64vARB GLEW_GET_FUN(__glewProgramUniform4ui64vARB) -#define glUniform1i64ARB GLEW_GET_FUN(__glewUniform1i64ARB) -#define glUniform1i64vARB GLEW_GET_FUN(__glewUniform1i64vARB) -#define glUniform1ui64ARB GLEW_GET_FUN(__glewUniform1ui64ARB) -#define glUniform1ui64vARB GLEW_GET_FUN(__glewUniform1ui64vARB) -#define glUniform2i64ARB GLEW_GET_FUN(__glewUniform2i64ARB) -#define glUniform2i64vARB GLEW_GET_FUN(__glewUniform2i64vARB) -#define glUniform2ui64ARB GLEW_GET_FUN(__glewUniform2ui64ARB) -#define glUniform2ui64vARB GLEW_GET_FUN(__glewUniform2ui64vARB) -#define glUniform3i64ARB GLEW_GET_FUN(__glewUniform3i64ARB) -#define glUniform3i64vARB GLEW_GET_FUN(__glewUniform3i64vARB) -#define glUniform3ui64ARB GLEW_GET_FUN(__glewUniform3ui64ARB) -#define glUniform3ui64vARB GLEW_GET_FUN(__glewUniform3ui64vARB) -#define glUniform4i64ARB GLEW_GET_FUN(__glewUniform4i64ARB) -#define glUniform4i64vARB GLEW_GET_FUN(__glewUniform4i64vARB) -#define glUniform4ui64ARB GLEW_GET_FUN(__glewUniform4ui64ARB) -#define glUniform4ui64vARB GLEW_GET_FUN(__glewUniform4ui64vARB) - -#define GLEW_ARB_gpu_shader_int64 GLEW_GET_VAR(__GLEW_ARB_gpu_shader_int64) - -#endif /* GL_ARB_gpu_shader_int64 */ - -/* ------------------------ GL_ARB_half_float_pixel ------------------------ */ - -#ifndef GL_ARB_half_float_pixel -#define GL_ARB_half_float_pixel 1 - -#define GL_HALF_FLOAT_ARB 0x140B - -#define GLEW_ARB_half_float_pixel GLEW_GET_VAR(__GLEW_ARB_half_float_pixel) - -#endif /* GL_ARB_half_float_pixel */ - -/* ------------------------ GL_ARB_half_float_vertex ----------------------- */ - -#ifndef GL_ARB_half_float_vertex -#define GL_ARB_half_float_vertex 1 - -#define GL_HALF_FLOAT 0x140B - -#define GLEW_ARB_half_float_vertex GLEW_GET_VAR(__GLEW_ARB_half_float_vertex) - -#endif /* GL_ARB_half_float_vertex */ - -/* ----------------------------- GL_ARB_imaging ---------------------------- */ - -#ifndef GL_ARB_imaging -#define GL_ARB_imaging 1 - -#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_IGNORE_BORDER 0x8150 -#define GL_CONSTANT_BORDER 0x8151 -#define GL_WRAP_BORDER 0x8152 -#define GL_REPLICATE_BORDER 0x8153 -#define GL_CONVOLUTION_BORDER_COLOR 0x8154 - -typedef void (GLAPIENTRY * PFNGLCOLORSUBTABLEPROC) (GLenum target, GLsizei start, GLsizei count, GLenum format, GLenum type, const void *data); -typedef void (GLAPIENTRY * PFNGLCOLORTABLEPROC) (GLenum target, GLenum internalformat, GLsizei width, GLenum format, GLenum type, const void *table); -typedef void (GLAPIENTRY * PFNGLCOLORTABLEPARAMETERFVPROC) (GLenum target, GLenum pname, const GLfloat *params); -typedef void (GLAPIENTRY * PFNGLCOLORTABLEPARAMETERIVPROC) (GLenum target, GLenum pname, const GLint *params); -typedef void (GLAPIENTRY * PFNGLCONVOLUTIONFILTER1DPROC) (GLenum target, GLenum internalformat, GLsizei width, GLenum format, GLenum type, const void *image); -typedef void (GLAPIENTRY * PFNGLCONVOLUTIONFILTER2DPROC) (GLenum target, GLenum internalformat, GLsizei width, GLsizei height, GLenum format, GLenum type, const void *image); -typedef void (GLAPIENTRY * PFNGLCONVOLUTIONPARAMETERFPROC) (GLenum target, GLenum pname, GLfloat params); -typedef void (GLAPIENTRY * PFNGLCONVOLUTIONPARAMETERFVPROC) (GLenum target, GLenum pname, const GLfloat *params); -typedef void (GLAPIENTRY * PFNGLCONVOLUTIONPARAMETERIPROC) (GLenum target, GLenum pname, GLint params); -typedef void (GLAPIENTRY * PFNGLCONVOLUTIONPARAMETERIVPROC) (GLenum target, GLenum pname, const GLint *params); -typedef void (GLAPIENTRY * PFNGLCOPYCOLORSUBTABLEPROC) (GLenum target, GLsizei start, GLint x, GLint y, GLsizei width); -typedef void (GLAPIENTRY * PFNGLCOPYCOLORTABLEPROC) (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width); -typedef void (GLAPIENTRY * PFNGLCOPYCONVOLUTIONFILTER1DPROC) (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width); -typedef void (GLAPIENTRY * PFNGLCOPYCONVOLUTIONFILTER2DPROC) (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height); -typedef void (GLAPIENTRY * PFNGLGETCOLORTABLEPROC) (GLenum target, GLenum format, GLenum type, void *table); -typedef void (GLAPIENTRY * PFNGLGETCOLORTABLEPARAMETERFVPROC) (GLenum target, GLenum pname, GLfloat *params); -typedef void (GLAPIENTRY * PFNGLGETCOLORTABLEPARAMETERIVPROC) (GLenum target, GLenum pname, GLint *params); -typedef void (GLAPIENTRY * PFNGLGETCONVOLUTIONFILTERPROC) (GLenum target, GLenum format, GLenum type, void *image); -typedef void (GLAPIENTRY * PFNGLGETCONVOLUTIONPARAMETERFVPROC) (GLenum target, GLenum pname, GLfloat *params); -typedef void (GLAPIENTRY * PFNGLGETCONVOLUTIONPARAMETERIVPROC) (GLenum target, GLenum pname, GLint *params); -typedef void (GLAPIENTRY * PFNGLGETHISTOGRAMPROC) (GLenum target, GLboolean reset, GLenum format, GLenum type, void *values); -typedef void (GLAPIENTRY * PFNGLGETHISTOGRAMPARAMETERFVPROC) (GLenum target, GLenum pname, GLfloat *params); -typedef void (GLAPIENTRY * PFNGLGETHISTOGRAMPARAMETERIVPROC) (GLenum target, GLenum pname, GLint *params); -typedef void (GLAPIENTRY * PFNGLGETMINMAXPROC) (GLenum target, GLboolean reset, GLenum format, GLenum types, void *values); -typedef void (GLAPIENTRY * PFNGLGETMINMAXPARAMETERFVPROC) (GLenum target, GLenum pname, GLfloat *params); -typedef void (GLAPIENTRY * PFNGLGETMINMAXPARAMETERIVPROC) (GLenum target, GLenum pname, GLint *params); -typedef void (GLAPIENTRY * PFNGLGETSEPARABLEFILTERPROC) (GLenum target, GLenum format, GLenum type, void *row, void *column, void *span); -typedef void (GLAPIENTRY * PFNGLHISTOGRAMPROC) (GLenum target, GLsizei width, GLenum internalformat, GLboolean sink); -typedef void (GLAPIENTRY * PFNGLMINMAXPROC) (GLenum target, GLenum internalformat, GLboolean sink); -typedef void (GLAPIENTRY * PFNGLRESETHISTOGRAMPROC) (GLenum target); -typedef void (GLAPIENTRY * PFNGLRESETMINMAXPROC) (GLenum target); -typedef void (GLAPIENTRY * PFNGLSEPARABLEFILTER2DPROC) (GLenum target, GLenum internalformat, GLsizei width, GLsizei height, GLenum format, GLenum type, const void *row, const void *column); - -#define glColorSubTable GLEW_GET_FUN(__glewColorSubTable) -#define glColorTable GLEW_GET_FUN(__glewColorTable) -#define glColorTableParameterfv GLEW_GET_FUN(__glewColorTableParameterfv) -#define glColorTableParameteriv GLEW_GET_FUN(__glewColorTableParameteriv) -#define glConvolutionFilter1D GLEW_GET_FUN(__glewConvolutionFilter1D) -#define glConvolutionFilter2D GLEW_GET_FUN(__glewConvolutionFilter2D) -#define glConvolutionParameterf GLEW_GET_FUN(__glewConvolutionParameterf) -#define glConvolutionParameterfv GLEW_GET_FUN(__glewConvolutionParameterfv) -#define glConvolutionParameteri GLEW_GET_FUN(__glewConvolutionParameteri) -#define glConvolutionParameteriv GLEW_GET_FUN(__glewConvolutionParameteriv) -#define glCopyColorSubTable GLEW_GET_FUN(__glewCopyColorSubTable) -#define glCopyColorTable GLEW_GET_FUN(__glewCopyColorTable) -#define glCopyConvolutionFilter1D GLEW_GET_FUN(__glewCopyConvolutionFilter1D) -#define glCopyConvolutionFilter2D GLEW_GET_FUN(__glewCopyConvolutionFilter2D) -#define glGetColorTable GLEW_GET_FUN(__glewGetColorTable) -#define glGetColorTableParameterfv GLEW_GET_FUN(__glewGetColorTableParameterfv) -#define glGetColorTableParameteriv GLEW_GET_FUN(__glewGetColorTableParameteriv) -#define glGetConvolutionFilter GLEW_GET_FUN(__glewGetConvolutionFilter) -#define glGetConvolutionParameterfv GLEW_GET_FUN(__glewGetConvolutionParameterfv) -#define glGetConvolutionParameteriv GLEW_GET_FUN(__glewGetConvolutionParameteriv) -#define glGetHistogram GLEW_GET_FUN(__glewGetHistogram) -#define glGetHistogramParameterfv GLEW_GET_FUN(__glewGetHistogramParameterfv) -#define glGetHistogramParameteriv GLEW_GET_FUN(__glewGetHistogramParameteriv) -#define glGetMinmax GLEW_GET_FUN(__glewGetMinmax) -#define glGetMinmaxParameterfv GLEW_GET_FUN(__glewGetMinmaxParameterfv) -#define glGetMinmaxParameteriv GLEW_GET_FUN(__glewGetMinmaxParameteriv) -#define glGetSeparableFilter GLEW_GET_FUN(__glewGetSeparableFilter) -#define glHistogram GLEW_GET_FUN(__glewHistogram) -#define glMinmax GLEW_GET_FUN(__glewMinmax) -#define glResetHistogram GLEW_GET_FUN(__glewResetHistogram) -#define glResetMinmax GLEW_GET_FUN(__glewResetMinmax) -#define glSeparableFilter2D GLEW_GET_FUN(__glewSeparableFilter2D) - -#define GLEW_ARB_imaging GLEW_GET_VAR(__GLEW_ARB_imaging) - -#endif /* GL_ARB_imaging */ - -/* ----------------------- GL_ARB_indirect_parameters ---------------------- */ - -#ifndef GL_ARB_indirect_parameters -#define GL_ARB_indirect_parameters 1 - -#define GL_PARAMETER_BUFFER_ARB 0x80EE -#define GL_PARAMETER_BUFFER_BINDING_ARB 0x80EF - -typedef void (GLAPIENTRY * PFNGLMULTIDRAWARRAYSINDIRECTCOUNTARBPROC) (GLenum mode, const void *indirect, GLintptr drawcount, GLsizei maxdrawcount, GLsizei stride); -typedef void (GLAPIENTRY * PFNGLMULTIDRAWELEMENTSINDIRECTCOUNTARBPROC) (GLenum mode, GLenum type, const void *indirect, GLintptr drawcount, GLsizei maxdrawcount, GLsizei stride); - -#define glMultiDrawArraysIndirectCountARB GLEW_GET_FUN(__glewMultiDrawArraysIndirectCountARB) -#define glMultiDrawElementsIndirectCountARB GLEW_GET_FUN(__glewMultiDrawElementsIndirectCountARB) - -#define GLEW_ARB_indirect_parameters GLEW_GET_VAR(__GLEW_ARB_indirect_parameters) - -#endif /* GL_ARB_indirect_parameters */ - -/* ------------------------ GL_ARB_instanced_arrays ------------------------ */ - -#ifndef GL_ARB_instanced_arrays -#define GL_ARB_instanced_arrays 1 - -#define GL_VERTEX_ATTRIB_ARRAY_DIVISOR_ARB 0x88FE - -typedef void (GLAPIENTRY * PFNGLDRAWARRAYSINSTANCEDARBPROC) (GLenum mode, GLint first, GLsizei count, GLsizei primcount); -typedef void (GLAPIENTRY * PFNGLDRAWELEMENTSINSTANCEDARBPROC) (GLenum mode, GLsizei count, GLenum type, const void* indices, GLsizei primcount); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBDIVISORARBPROC) (GLuint index, GLuint divisor); - -#define glDrawArraysInstancedARB GLEW_GET_FUN(__glewDrawArraysInstancedARB) -#define glDrawElementsInstancedARB GLEW_GET_FUN(__glewDrawElementsInstancedARB) -#define glVertexAttribDivisorARB GLEW_GET_FUN(__glewVertexAttribDivisorARB) - -#define GLEW_ARB_instanced_arrays GLEW_GET_VAR(__GLEW_ARB_instanced_arrays) - -#endif /* GL_ARB_instanced_arrays */ - -/* ---------------------- GL_ARB_internalformat_query ---------------------- */ - -#ifndef GL_ARB_internalformat_query -#define GL_ARB_internalformat_query 1 - -#define GL_NUM_SAMPLE_COUNTS 0x9380 - -typedef void (GLAPIENTRY * PFNGLGETINTERNALFORMATIVPROC) (GLenum target, GLenum internalformat, GLenum pname, GLsizei bufSize, GLint* params); - -#define glGetInternalformativ GLEW_GET_FUN(__glewGetInternalformativ) - -#define GLEW_ARB_internalformat_query GLEW_GET_VAR(__GLEW_ARB_internalformat_query) - -#endif /* GL_ARB_internalformat_query */ - -/* ---------------------- GL_ARB_internalformat_query2 --------------------- */ - -#ifndef GL_ARB_internalformat_query2 -#define GL_ARB_internalformat_query2 1 - -#define GL_INTERNALFORMAT_SUPPORTED 0x826F -#define GL_INTERNALFORMAT_PREFERRED 0x8270 -#define GL_INTERNALFORMAT_RED_SIZE 0x8271 -#define GL_INTERNALFORMAT_GREEN_SIZE 0x8272 -#define GL_INTERNALFORMAT_BLUE_SIZE 0x8273 -#define GL_INTERNALFORMAT_ALPHA_SIZE 0x8274 -#define GL_INTERNALFORMAT_DEPTH_SIZE 0x8275 -#define GL_INTERNALFORMAT_STENCIL_SIZE 0x8276 -#define GL_INTERNALFORMAT_SHARED_SIZE 0x8277 -#define GL_INTERNALFORMAT_RED_TYPE 0x8278 -#define GL_INTERNALFORMAT_GREEN_TYPE 0x8279 -#define GL_INTERNALFORMAT_BLUE_TYPE 0x827A -#define GL_INTERNALFORMAT_ALPHA_TYPE 0x827B -#define GL_INTERNALFORMAT_DEPTH_TYPE 0x827C -#define GL_INTERNALFORMAT_STENCIL_TYPE 0x827D -#define GL_MAX_WIDTH 0x827E -#define GL_MAX_HEIGHT 0x827F -#define GL_MAX_DEPTH 0x8280 -#define GL_MAX_LAYERS 0x8281 -#define GL_MAX_COMBINED_DIMENSIONS 0x8282 -#define GL_COLOR_COMPONENTS 0x8283 -#define GL_DEPTH_COMPONENTS 0x8284 -#define GL_STENCIL_COMPONENTS 0x8285 -#define GL_COLOR_RENDERABLE 0x8286 -#define GL_DEPTH_RENDERABLE 0x8287 -#define GL_STENCIL_RENDERABLE 0x8288 -#define GL_FRAMEBUFFER_RENDERABLE 0x8289 -#define GL_FRAMEBUFFER_RENDERABLE_LAYERED 0x828A -#define GL_FRAMEBUFFER_BLEND 0x828B -#define GL_READ_PIXELS 0x828C -#define GL_READ_PIXELS_FORMAT 0x828D -#define GL_READ_PIXELS_TYPE 0x828E -#define GL_TEXTURE_IMAGE_FORMAT 0x828F -#define GL_TEXTURE_IMAGE_TYPE 0x8290 -#define GL_GET_TEXTURE_IMAGE_FORMAT 0x8291 -#define GL_GET_TEXTURE_IMAGE_TYPE 0x8292 -#define GL_MIPMAP 0x8293 -#define GL_MANUAL_GENERATE_MIPMAP 0x8294 -#define GL_AUTO_GENERATE_MIPMAP 0x8295 -#define GL_COLOR_ENCODING 0x8296 -#define GL_SRGB_READ 0x8297 -#define GL_SRGB_WRITE 0x8298 -#define GL_SRGB_DECODE_ARB 0x8299 -#define GL_FILTER 0x829A -#define GL_VERTEX_TEXTURE 0x829B -#define GL_TESS_CONTROL_TEXTURE 0x829C -#define GL_TESS_EVALUATION_TEXTURE 0x829D -#define GL_GEOMETRY_TEXTURE 0x829E -#define GL_FRAGMENT_TEXTURE 0x829F -#define GL_COMPUTE_TEXTURE 0x82A0 -#define GL_TEXTURE_SHADOW 0x82A1 -#define GL_TEXTURE_GATHER 0x82A2 -#define GL_TEXTURE_GATHER_SHADOW 0x82A3 -#define GL_SHADER_IMAGE_LOAD 0x82A4 -#define GL_SHADER_IMAGE_STORE 0x82A5 -#define GL_SHADER_IMAGE_ATOMIC 0x82A6 -#define GL_IMAGE_TEXEL_SIZE 0x82A7 -#define GL_IMAGE_COMPATIBILITY_CLASS 0x82A8 -#define GL_IMAGE_PIXEL_FORMAT 0x82A9 -#define GL_IMAGE_PIXEL_TYPE 0x82AA -#define GL_SIMULTANEOUS_TEXTURE_AND_DEPTH_TEST 0x82AC -#define GL_SIMULTANEOUS_TEXTURE_AND_STENCIL_TEST 0x82AD -#define GL_SIMULTANEOUS_TEXTURE_AND_DEPTH_WRITE 0x82AE -#define GL_SIMULTANEOUS_TEXTURE_AND_STENCIL_WRITE 0x82AF -#define GL_TEXTURE_COMPRESSED_BLOCK_WIDTH 0x82B1 -#define GL_TEXTURE_COMPRESSED_BLOCK_HEIGHT 0x82B2 -#define GL_TEXTURE_COMPRESSED_BLOCK_SIZE 0x82B3 -#define GL_CLEAR_BUFFER 0x82B4 -#define GL_TEXTURE_VIEW 0x82B5 -#define GL_VIEW_COMPATIBILITY_CLASS 0x82B6 -#define GL_FULL_SUPPORT 0x82B7 -#define GL_CAVEAT_SUPPORT 0x82B8 -#define GL_IMAGE_CLASS_4_X_32 0x82B9 -#define GL_IMAGE_CLASS_2_X_32 0x82BA -#define GL_IMAGE_CLASS_1_X_32 0x82BB -#define GL_IMAGE_CLASS_4_X_16 0x82BC -#define GL_IMAGE_CLASS_2_X_16 0x82BD -#define GL_IMAGE_CLASS_1_X_16 0x82BE -#define GL_IMAGE_CLASS_4_X_8 0x82BF -#define GL_IMAGE_CLASS_2_X_8 0x82C0 -#define GL_IMAGE_CLASS_1_X_8 0x82C1 -#define GL_IMAGE_CLASS_11_11_10 0x82C2 -#define GL_IMAGE_CLASS_10_10_10_2 0x82C3 -#define GL_VIEW_CLASS_128_BITS 0x82C4 -#define GL_VIEW_CLASS_96_BITS 0x82C5 -#define GL_VIEW_CLASS_64_BITS 0x82C6 -#define GL_VIEW_CLASS_48_BITS 0x82C7 -#define GL_VIEW_CLASS_32_BITS 0x82C8 -#define GL_VIEW_CLASS_24_BITS 0x82C9 -#define GL_VIEW_CLASS_16_BITS 0x82CA -#define GL_VIEW_CLASS_8_BITS 0x82CB -#define GL_VIEW_CLASS_S3TC_DXT1_RGB 0x82CC -#define GL_VIEW_CLASS_S3TC_DXT1_RGBA 0x82CD -#define GL_VIEW_CLASS_S3TC_DXT3_RGBA 0x82CE -#define GL_VIEW_CLASS_S3TC_DXT5_RGBA 0x82CF -#define GL_VIEW_CLASS_RGTC1_RED 0x82D0 -#define GL_VIEW_CLASS_RGTC2_RG 0x82D1 -#define GL_VIEW_CLASS_BPTC_UNORM 0x82D2 -#define GL_VIEW_CLASS_BPTC_FLOAT 0x82D3 - -typedef void (GLAPIENTRY * PFNGLGETINTERNALFORMATI64VPROC) (GLenum target, GLenum internalformat, GLenum pname, GLsizei bufSize, GLint64* params); - -#define glGetInternalformati64v GLEW_GET_FUN(__glewGetInternalformati64v) - -#define GLEW_ARB_internalformat_query2 GLEW_GET_VAR(__GLEW_ARB_internalformat_query2) - -#endif /* GL_ARB_internalformat_query2 */ - -/* ----------------------- GL_ARB_invalidate_subdata ----------------------- */ - -#ifndef GL_ARB_invalidate_subdata -#define GL_ARB_invalidate_subdata 1 - -typedef void (GLAPIENTRY * PFNGLINVALIDATEBUFFERDATAPROC) (GLuint buffer); -typedef void (GLAPIENTRY * PFNGLINVALIDATEBUFFERSUBDATAPROC) (GLuint buffer, GLintptr offset, GLsizeiptr length); -typedef void (GLAPIENTRY * PFNGLINVALIDATEFRAMEBUFFERPROC) (GLenum target, GLsizei numAttachments, const GLenum* attachments); -typedef void (GLAPIENTRY * PFNGLINVALIDATESUBFRAMEBUFFERPROC) (GLenum target, GLsizei numAttachments, const GLenum* attachments, GLint x, GLint y, GLsizei width, GLsizei height); -typedef void (GLAPIENTRY * PFNGLINVALIDATETEXIMAGEPROC) (GLuint texture, GLint level); -typedef void (GLAPIENTRY * PFNGLINVALIDATETEXSUBIMAGEPROC) (GLuint texture, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth); - -#define glInvalidateBufferData GLEW_GET_FUN(__glewInvalidateBufferData) -#define glInvalidateBufferSubData GLEW_GET_FUN(__glewInvalidateBufferSubData) -#define glInvalidateFramebuffer GLEW_GET_FUN(__glewInvalidateFramebuffer) -#define glInvalidateSubFramebuffer GLEW_GET_FUN(__glewInvalidateSubFramebuffer) -#define glInvalidateTexImage GLEW_GET_FUN(__glewInvalidateTexImage) -#define glInvalidateTexSubImage GLEW_GET_FUN(__glewInvalidateTexSubImage) - -#define GLEW_ARB_invalidate_subdata GLEW_GET_VAR(__GLEW_ARB_invalidate_subdata) - -#endif /* GL_ARB_invalidate_subdata */ - -/* ---------------------- GL_ARB_map_buffer_alignment ---------------------- */ - -#ifndef GL_ARB_map_buffer_alignment -#define GL_ARB_map_buffer_alignment 1 - -#define GL_MIN_MAP_BUFFER_ALIGNMENT 0x90BC - -#define GLEW_ARB_map_buffer_alignment GLEW_GET_VAR(__GLEW_ARB_map_buffer_alignment) - -#endif /* GL_ARB_map_buffer_alignment */ - -/* ------------------------ GL_ARB_map_buffer_range ------------------------ */ - -#ifndef GL_ARB_map_buffer_range -#define GL_ARB_map_buffer_range 1 - -#define GL_MAP_READ_BIT 0x0001 -#define GL_MAP_WRITE_BIT 0x0002 -#define GL_MAP_INVALIDATE_RANGE_BIT 0x0004 -#define GL_MAP_INVALIDATE_BUFFER_BIT 0x0008 -#define GL_MAP_FLUSH_EXPLICIT_BIT 0x0010 -#define GL_MAP_UNSYNCHRONIZED_BIT 0x0020 - -typedef void (GLAPIENTRY * PFNGLFLUSHMAPPEDBUFFERRANGEPROC) (GLenum target, GLintptr offset, GLsizeiptr length); -typedef void * (GLAPIENTRY * PFNGLMAPBUFFERRANGEPROC) (GLenum target, GLintptr offset, GLsizeiptr length, GLbitfield access); - -#define glFlushMappedBufferRange GLEW_GET_FUN(__glewFlushMappedBufferRange) -#define glMapBufferRange GLEW_GET_FUN(__glewMapBufferRange) - -#define GLEW_ARB_map_buffer_range GLEW_GET_VAR(__GLEW_ARB_map_buffer_range) - -#endif /* GL_ARB_map_buffer_range */ - -/* ------------------------- GL_ARB_matrix_palette ------------------------- */ - -#ifndef GL_ARB_matrix_palette -#define GL_ARB_matrix_palette 1 - -#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 - -typedef void (GLAPIENTRY * PFNGLCURRENTPALETTEMATRIXARBPROC) (GLint index); -typedef void (GLAPIENTRY * PFNGLMATRIXINDEXPOINTERARBPROC) (GLint size, GLenum type, GLsizei stride, void *pointer); -typedef void (GLAPIENTRY * PFNGLMATRIXINDEXUBVARBPROC) (GLint size, GLubyte *indices); -typedef void (GLAPIENTRY * PFNGLMATRIXINDEXUIVARBPROC) (GLint size, GLuint *indices); -typedef void (GLAPIENTRY * PFNGLMATRIXINDEXUSVARBPROC) (GLint size, GLushort *indices); - -#define glCurrentPaletteMatrixARB GLEW_GET_FUN(__glewCurrentPaletteMatrixARB) -#define glMatrixIndexPointerARB GLEW_GET_FUN(__glewMatrixIndexPointerARB) -#define glMatrixIndexubvARB GLEW_GET_FUN(__glewMatrixIndexubvARB) -#define glMatrixIndexuivARB GLEW_GET_FUN(__glewMatrixIndexuivARB) -#define glMatrixIndexusvARB GLEW_GET_FUN(__glewMatrixIndexusvARB) - -#define GLEW_ARB_matrix_palette GLEW_GET_VAR(__GLEW_ARB_matrix_palette) - -#endif /* GL_ARB_matrix_palette */ - -/* --------------------------- GL_ARB_multi_bind --------------------------- */ - -#ifndef GL_ARB_multi_bind -#define GL_ARB_multi_bind 1 - -typedef void (GLAPIENTRY * PFNGLBINDBUFFERSBASEPROC) (GLenum target, GLuint first, GLsizei count, const GLuint* buffers); -typedef void (GLAPIENTRY * PFNGLBINDBUFFERSRANGEPROC) (GLenum target, GLuint first, GLsizei count, const GLuint* buffers, const GLintptr *offsets, const GLsizeiptr *sizes); -typedef void (GLAPIENTRY * PFNGLBINDIMAGETEXTURESPROC) (GLuint first, GLsizei count, const GLuint* textures); -typedef void (GLAPIENTRY * PFNGLBINDSAMPLERSPROC) (GLuint first, GLsizei count, const GLuint* samplers); -typedef void (GLAPIENTRY * PFNGLBINDTEXTURESPROC) (GLuint first, GLsizei count, const GLuint* textures); -typedef void (GLAPIENTRY * PFNGLBINDVERTEXBUFFERSPROC) (GLuint first, GLsizei count, const GLuint* buffers, const GLintptr *offsets, const GLsizei *strides); - -#define glBindBuffersBase GLEW_GET_FUN(__glewBindBuffersBase) -#define glBindBuffersRange GLEW_GET_FUN(__glewBindBuffersRange) -#define glBindImageTextures GLEW_GET_FUN(__glewBindImageTextures) -#define glBindSamplers GLEW_GET_FUN(__glewBindSamplers) -#define glBindTextures GLEW_GET_FUN(__glewBindTextures) -#define glBindVertexBuffers GLEW_GET_FUN(__glewBindVertexBuffers) - -#define GLEW_ARB_multi_bind GLEW_GET_VAR(__GLEW_ARB_multi_bind) - -#endif /* GL_ARB_multi_bind */ - -/* ----------------------- GL_ARB_multi_draw_indirect ---------------------- */ - -#ifndef GL_ARB_multi_draw_indirect -#define GL_ARB_multi_draw_indirect 1 - -typedef void (GLAPIENTRY * PFNGLMULTIDRAWARRAYSINDIRECTPROC) (GLenum mode, const void *indirect, GLsizei primcount, GLsizei stride); -typedef void (GLAPIENTRY * PFNGLMULTIDRAWELEMENTSINDIRECTPROC) (GLenum mode, GLenum type, const void *indirect, GLsizei primcount, GLsizei stride); - -#define glMultiDrawArraysIndirect GLEW_GET_FUN(__glewMultiDrawArraysIndirect) -#define glMultiDrawElementsIndirect GLEW_GET_FUN(__glewMultiDrawElementsIndirect) - -#define GLEW_ARB_multi_draw_indirect GLEW_GET_VAR(__GLEW_ARB_multi_draw_indirect) - -#endif /* GL_ARB_multi_draw_indirect */ - -/* --------------------------- GL_ARB_multisample -------------------------- */ - -#ifndef GL_ARB_multisample -#define GL_ARB_multisample 1 - -#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 - -typedef void (GLAPIENTRY * PFNGLSAMPLECOVERAGEARBPROC) (GLclampf value, GLboolean invert); - -#define glSampleCoverageARB GLEW_GET_FUN(__glewSampleCoverageARB) - -#define GLEW_ARB_multisample GLEW_GET_VAR(__GLEW_ARB_multisample) - -#endif /* GL_ARB_multisample */ - -/* -------------------------- GL_ARB_multitexture -------------------------- */ - -#ifndef GL_ARB_multitexture -#define GL_ARB_multitexture 1 - -#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 - -typedef void (GLAPIENTRY * PFNGLACTIVETEXTUREARBPROC) (GLenum texture); -typedef void (GLAPIENTRY * PFNGLCLIENTACTIVETEXTUREARBPROC) (GLenum texture); -typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD1DARBPROC) (GLenum target, GLdouble s); -typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD1DVARBPROC) (GLenum target, const GLdouble *v); -typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD1FARBPROC) (GLenum target, GLfloat s); -typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD1FVARBPROC) (GLenum target, const GLfloat *v); -typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD1IARBPROC) (GLenum target, GLint s); -typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD1IVARBPROC) (GLenum target, const GLint *v); -typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD1SARBPROC) (GLenum target, GLshort s); -typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD1SVARBPROC) (GLenum target, const GLshort *v); -typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD2DARBPROC) (GLenum target, GLdouble s, GLdouble t); -typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD2DVARBPROC) (GLenum target, const GLdouble *v); -typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD2FARBPROC) (GLenum target, GLfloat s, GLfloat t); -typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD2FVARBPROC) (GLenum target, const GLfloat *v); -typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD2IARBPROC) (GLenum target, GLint s, GLint t); -typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD2IVARBPROC) (GLenum target, const GLint *v); -typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD2SARBPROC) (GLenum target, GLshort s, GLshort t); -typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD2SVARBPROC) (GLenum target, const GLshort *v); -typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD3DARBPROC) (GLenum target, GLdouble s, GLdouble t, GLdouble r); -typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD3DVARBPROC) (GLenum target, const GLdouble *v); -typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD3FARBPROC) (GLenum target, GLfloat s, GLfloat t, GLfloat r); -typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD3FVARBPROC) (GLenum target, const GLfloat *v); -typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD3IARBPROC) (GLenum target, GLint s, GLint t, GLint r); -typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD3IVARBPROC) (GLenum target, const GLint *v); -typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD3SARBPROC) (GLenum target, GLshort s, GLshort t, GLshort r); -typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD3SVARBPROC) (GLenum target, const GLshort *v); -typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD4DARBPROC) (GLenum target, GLdouble s, GLdouble t, GLdouble r, GLdouble q); -typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD4DVARBPROC) (GLenum target, const GLdouble *v); -typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD4FARBPROC) (GLenum target, GLfloat s, GLfloat t, GLfloat r, GLfloat q); -typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD4FVARBPROC) (GLenum target, const GLfloat *v); -typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD4IARBPROC) (GLenum target, GLint s, GLint t, GLint r, GLint q); -typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD4IVARBPROC) (GLenum target, const GLint *v); -typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD4SARBPROC) (GLenum target, GLshort s, GLshort t, GLshort r, GLshort q); -typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD4SVARBPROC) (GLenum target, const GLshort *v); - -#define glActiveTextureARB GLEW_GET_FUN(__glewActiveTextureARB) -#define glClientActiveTextureARB GLEW_GET_FUN(__glewClientActiveTextureARB) -#define glMultiTexCoord1dARB GLEW_GET_FUN(__glewMultiTexCoord1dARB) -#define glMultiTexCoord1dvARB GLEW_GET_FUN(__glewMultiTexCoord1dvARB) -#define glMultiTexCoord1fARB GLEW_GET_FUN(__glewMultiTexCoord1fARB) -#define glMultiTexCoord1fvARB GLEW_GET_FUN(__glewMultiTexCoord1fvARB) -#define glMultiTexCoord1iARB GLEW_GET_FUN(__glewMultiTexCoord1iARB) -#define glMultiTexCoord1ivARB GLEW_GET_FUN(__glewMultiTexCoord1ivARB) -#define glMultiTexCoord1sARB GLEW_GET_FUN(__glewMultiTexCoord1sARB) -#define glMultiTexCoord1svARB GLEW_GET_FUN(__glewMultiTexCoord1svARB) -#define glMultiTexCoord2dARB GLEW_GET_FUN(__glewMultiTexCoord2dARB) -#define glMultiTexCoord2dvARB GLEW_GET_FUN(__glewMultiTexCoord2dvARB) -#define glMultiTexCoord2fARB GLEW_GET_FUN(__glewMultiTexCoord2fARB) -#define glMultiTexCoord2fvARB GLEW_GET_FUN(__glewMultiTexCoord2fvARB) -#define glMultiTexCoord2iARB GLEW_GET_FUN(__glewMultiTexCoord2iARB) -#define glMultiTexCoord2ivARB GLEW_GET_FUN(__glewMultiTexCoord2ivARB) -#define glMultiTexCoord2sARB GLEW_GET_FUN(__glewMultiTexCoord2sARB) -#define glMultiTexCoord2svARB GLEW_GET_FUN(__glewMultiTexCoord2svARB) -#define glMultiTexCoord3dARB GLEW_GET_FUN(__glewMultiTexCoord3dARB) -#define glMultiTexCoord3dvARB GLEW_GET_FUN(__glewMultiTexCoord3dvARB) -#define glMultiTexCoord3fARB GLEW_GET_FUN(__glewMultiTexCoord3fARB) -#define glMultiTexCoord3fvARB GLEW_GET_FUN(__glewMultiTexCoord3fvARB) -#define glMultiTexCoord3iARB GLEW_GET_FUN(__glewMultiTexCoord3iARB) -#define glMultiTexCoord3ivARB GLEW_GET_FUN(__glewMultiTexCoord3ivARB) -#define glMultiTexCoord3sARB GLEW_GET_FUN(__glewMultiTexCoord3sARB) -#define glMultiTexCoord3svARB GLEW_GET_FUN(__glewMultiTexCoord3svARB) -#define glMultiTexCoord4dARB GLEW_GET_FUN(__glewMultiTexCoord4dARB) -#define glMultiTexCoord4dvARB GLEW_GET_FUN(__glewMultiTexCoord4dvARB) -#define glMultiTexCoord4fARB GLEW_GET_FUN(__glewMultiTexCoord4fARB) -#define glMultiTexCoord4fvARB GLEW_GET_FUN(__glewMultiTexCoord4fvARB) -#define glMultiTexCoord4iARB GLEW_GET_FUN(__glewMultiTexCoord4iARB) -#define glMultiTexCoord4ivARB GLEW_GET_FUN(__glewMultiTexCoord4ivARB) -#define glMultiTexCoord4sARB GLEW_GET_FUN(__glewMultiTexCoord4sARB) -#define glMultiTexCoord4svARB GLEW_GET_FUN(__glewMultiTexCoord4svARB) - -#define GLEW_ARB_multitexture GLEW_GET_VAR(__GLEW_ARB_multitexture) - -#endif /* GL_ARB_multitexture */ - -/* ------------------------- GL_ARB_occlusion_query ------------------------ */ - -#ifndef GL_ARB_occlusion_query -#define GL_ARB_occlusion_query 1 - -#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 - -typedef void (GLAPIENTRY * PFNGLBEGINQUERYARBPROC) (GLenum target, GLuint id); -typedef void (GLAPIENTRY * PFNGLDELETEQUERIESARBPROC) (GLsizei n, const GLuint* ids); -typedef void (GLAPIENTRY * PFNGLENDQUERYARBPROC) (GLenum target); -typedef void (GLAPIENTRY * PFNGLGENQUERIESARBPROC) (GLsizei n, GLuint* ids); -typedef void (GLAPIENTRY * PFNGLGETQUERYOBJECTIVARBPROC) (GLuint id, GLenum pname, GLint* params); -typedef void (GLAPIENTRY * PFNGLGETQUERYOBJECTUIVARBPROC) (GLuint id, GLenum pname, GLuint* params); -typedef void (GLAPIENTRY * PFNGLGETQUERYIVARBPROC) (GLenum target, GLenum pname, GLint* params); -typedef GLboolean (GLAPIENTRY * PFNGLISQUERYARBPROC) (GLuint id); - -#define glBeginQueryARB GLEW_GET_FUN(__glewBeginQueryARB) -#define glDeleteQueriesARB GLEW_GET_FUN(__glewDeleteQueriesARB) -#define glEndQueryARB GLEW_GET_FUN(__glewEndQueryARB) -#define glGenQueriesARB GLEW_GET_FUN(__glewGenQueriesARB) -#define glGetQueryObjectivARB GLEW_GET_FUN(__glewGetQueryObjectivARB) -#define glGetQueryObjectuivARB GLEW_GET_FUN(__glewGetQueryObjectuivARB) -#define glGetQueryivARB GLEW_GET_FUN(__glewGetQueryivARB) -#define glIsQueryARB GLEW_GET_FUN(__glewIsQueryARB) - -#define GLEW_ARB_occlusion_query GLEW_GET_VAR(__GLEW_ARB_occlusion_query) - -#endif /* GL_ARB_occlusion_query */ - -/* ------------------------ GL_ARB_occlusion_query2 ------------------------ */ - -#ifndef GL_ARB_occlusion_query2 -#define GL_ARB_occlusion_query2 1 - -#define GL_ANY_SAMPLES_PASSED 0x8C2F - -#define GLEW_ARB_occlusion_query2 GLEW_GET_VAR(__GLEW_ARB_occlusion_query2) - -#endif /* GL_ARB_occlusion_query2 */ - -/* --------------------- GL_ARB_parallel_shader_compile -------------------- */ - -#ifndef GL_ARB_parallel_shader_compile -#define GL_ARB_parallel_shader_compile 1 - -#define GL_MAX_SHADER_COMPILER_THREADS_ARB 0x91B0 -#define GL_COMPLETION_STATUS_ARB 0x91B1 - -typedef void (GLAPIENTRY * PFNGLMAXSHADERCOMPILERTHREADSARBPROC) (GLuint count); - -#define glMaxShaderCompilerThreadsARB GLEW_GET_FUN(__glewMaxShaderCompilerThreadsARB) - -#define GLEW_ARB_parallel_shader_compile GLEW_GET_VAR(__GLEW_ARB_parallel_shader_compile) - -#endif /* GL_ARB_parallel_shader_compile */ - -/* -------------------- GL_ARB_pipeline_statistics_query ------------------- */ - -#ifndef GL_ARB_pipeline_statistics_query -#define GL_ARB_pipeline_statistics_query 1 - -#define GL_VERTICES_SUBMITTED_ARB 0x82EE -#define GL_PRIMITIVES_SUBMITTED_ARB 0x82EF -#define GL_VERTEX_SHADER_INVOCATIONS_ARB 0x82F0 -#define GL_TESS_CONTROL_SHADER_PATCHES_ARB 0x82F1 -#define GL_TESS_EVALUATION_SHADER_INVOCATIONS_ARB 0x82F2 -#define GL_GEOMETRY_SHADER_PRIMITIVES_EMITTED_ARB 0x82F3 -#define GL_FRAGMENT_SHADER_INVOCATIONS_ARB 0x82F4 -#define GL_COMPUTE_SHADER_INVOCATIONS_ARB 0x82F5 -#define GL_CLIPPING_INPUT_PRIMITIVES_ARB 0x82F6 -#define GL_CLIPPING_OUTPUT_PRIMITIVES_ARB 0x82F7 -#define GL_GEOMETRY_SHADER_INVOCATIONS 0x887F - -#define GLEW_ARB_pipeline_statistics_query GLEW_GET_VAR(__GLEW_ARB_pipeline_statistics_query) - -#endif /* GL_ARB_pipeline_statistics_query */ - -/* ----------------------- GL_ARB_pixel_buffer_object ---------------------- */ - -#ifndef GL_ARB_pixel_buffer_object -#define GL_ARB_pixel_buffer_object 1 - -#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 - -#define GLEW_ARB_pixel_buffer_object GLEW_GET_VAR(__GLEW_ARB_pixel_buffer_object) - -#endif /* GL_ARB_pixel_buffer_object */ - -/* ------------------------ GL_ARB_point_parameters ------------------------ */ - -#ifndef GL_ARB_point_parameters -#define GL_ARB_point_parameters 1 - -#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 - -typedef void (GLAPIENTRY * PFNGLPOINTPARAMETERFARBPROC) (GLenum pname, GLfloat param); -typedef void (GLAPIENTRY * PFNGLPOINTPARAMETERFVARBPROC) (GLenum pname, const GLfloat* params); - -#define glPointParameterfARB GLEW_GET_FUN(__glewPointParameterfARB) -#define glPointParameterfvARB GLEW_GET_FUN(__glewPointParameterfvARB) - -#define GLEW_ARB_point_parameters GLEW_GET_VAR(__GLEW_ARB_point_parameters) - -#endif /* GL_ARB_point_parameters */ - -/* -------------------------- GL_ARB_point_sprite -------------------------- */ - -#ifndef GL_ARB_point_sprite -#define GL_ARB_point_sprite 1 - -#define GL_POINT_SPRITE_ARB 0x8861 -#define GL_COORD_REPLACE_ARB 0x8862 - -#define GLEW_ARB_point_sprite GLEW_GET_VAR(__GLEW_ARB_point_sprite) - -#endif /* GL_ARB_point_sprite */ - -/* ----------------------- GL_ARB_post_depth_coverage ---------------------- */ - -#ifndef GL_ARB_post_depth_coverage -#define GL_ARB_post_depth_coverage 1 - -#define GLEW_ARB_post_depth_coverage GLEW_GET_VAR(__GLEW_ARB_post_depth_coverage) - -#endif /* GL_ARB_post_depth_coverage */ - -/* --------------------- GL_ARB_program_interface_query -------------------- */ - -#ifndef GL_ARB_program_interface_query -#define GL_ARB_program_interface_query 1 - -#define GL_UNIFORM 0x92E1 -#define GL_UNIFORM_BLOCK 0x92E2 -#define GL_PROGRAM_INPUT 0x92E3 -#define GL_PROGRAM_OUTPUT 0x92E4 -#define GL_BUFFER_VARIABLE 0x92E5 -#define GL_SHADER_STORAGE_BLOCK 0x92E6 -#define GL_IS_PER_PATCH 0x92E7 -#define GL_VERTEX_SUBROUTINE 0x92E8 -#define GL_TESS_CONTROL_SUBROUTINE 0x92E9 -#define GL_TESS_EVALUATION_SUBROUTINE 0x92EA -#define GL_GEOMETRY_SUBROUTINE 0x92EB -#define GL_FRAGMENT_SUBROUTINE 0x92EC -#define GL_COMPUTE_SUBROUTINE 0x92ED -#define GL_VERTEX_SUBROUTINE_UNIFORM 0x92EE -#define GL_TESS_CONTROL_SUBROUTINE_UNIFORM 0x92EF -#define GL_TESS_EVALUATION_SUBROUTINE_UNIFORM 0x92F0 -#define GL_GEOMETRY_SUBROUTINE_UNIFORM 0x92F1 -#define GL_FRAGMENT_SUBROUTINE_UNIFORM 0x92F2 -#define GL_COMPUTE_SUBROUTINE_UNIFORM 0x92F3 -#define GL_TRANSFORM_FEEDBACK_VARYING 0x92F4 -#define GL_ACTIVE_RESOURCES 0x92F5 -#define GL_MAX_NAME_LENGTH 0x92F6 -#define GL_MAX_NUM_ACTIVE_VARIABLES 0x92F7 -#define GL_MAX_NUM_COMPATIBLE_SUBROUTINES 0x92F8 -#define GL_NAME_LENGTH 0x92F9 -#define GL_TYPE 0x92FA -#define GL_ARRAY_SIZE 0x92FB -#define GL_OFFSET 0x92FC -#define GL_BLOCK_INDEX 0x92FD -#define GL_ARRAY_STRIDE 0x92FE -#define GL_MATRIX_STRIDE 0x92FF -#define GL_IS_ROW_MAJOR 0x9300 -#define GL_ATOMIC_COUNTER_BUFFER_INDEX 0x9301 -#define GL_BUFFER_BINDING 0x9302 -#define GL_BUFFER_DATA_SIZE 0x9303 -#define GL_NUM_ACTIVE_VARIABLES 0x9304 -#define GL_ACTIVE_VARIABLES 0x9305 -#define GL_REFERENCED_BY_VERTEX_SHADER 0x9306 -#define GL_REFERENCED_BY_TESS_CONTROL_SHADER 0x9307 -#define GL_REFERENCED_BY_TESS_EVALUATION_SHADER 0x9308 -#define GL_REFERENCED_BY_GEOMETRY_SHADER 0x9309 -#define GL_REFERENCED_BY_FRAGMENT_SHADER 0x930A -#define GL_REFERENCED_BY_COMPUTE_SHADER 0x930B -#define GL_TOP_LEVEL_ARRAY_SIZE 0x930C -#define GL_TOP_LEVEL_ARRAY_STRIDE 0x930D -#define GL_LOCATION 0x930E -#define GL_LOCATION_INDEX 0x930F - -typedef void (GLAPIENTRY * PFNGLGETPROGRAMINTERFACEIVPROC) (GLuint program, GLenum programInterface, GLenum pname, GLint* params); -typedef GLuint (GLAPIENTRY * PFNGLGETPROGRAMRESOURCEINDEXPROC) (GLuint program, GLenum programInterface, const GLchar* name); -typedef GLint (GLAPIENTRY * PFNGLGETPROGRAMRESOURCELOCATIONPROC) (GLuint program, GLenum programInterface, const GLchar* name); -typedef GLint (GLAPIENTRY * PFNGLGETPROGRAMRESOURCELOCATIONINDEXPROC) (GLuint program, GLenum programInterface, const GLchar* name); -typedef void (GLAPIENTRY * PFNGLGETPROGRAMRESOURCENAMEPROC) (GLuint program, GLenum programInterface, GLuint index, GLsizei bufSize, GLsizei* length, GLchar *name); -typedef void (GLAPIENTRY * PFNGLGETPROGRAMRESOURCEIVPROC) (GLuint program, GLenum programInterface, GLuint index, GLsizei propCount, const GLenum* props, GLsizei bufSize, GLsizei *length, GLint *params); - -#define glGetProgramInterfaceiv GLEW_GET_FUN(__glewGetProgramInterfaceiv) -#define glGetProgramResourceIndex GLEW_GET_FUN(__glewGetProgramResourceIndex) -#define glGetProgramResourceLocation GLEW_GET_FUN(__glewGetProgramResourceLocation) -#define glGetProgramResourceLocationIndex GLEW_GET_FUN(__glewGetProgramResourceLocationIndex) -#define glGetProgramResourceName GLEW_GET_FUN(__glewGetProgramResourceName) -#define glGetProgramResourceiv GLEW_GET_FUN(__glewGetProgramResourceiv) - -#define GLEW_ARB_program_interface_query GLEW_GET_VAR(__GLEW_ARB_program_interface_query) - -#endif /* GL_ARB_program_interface_query */ - -/* ------------------------ GL_ARB_provoking_vertex ------------------------ */ - -#ifndef GL_ARB_provoking_vertex -#define GL_ARB_provoking_vertex 1 - -#define GL_QUADS_FOLLOW_PROVOKING_VERTEX_CONVENTION 0x8E4C -#define GL_FIRST_VERTEX_CONVENTION 0x8E4D -#define GL_LAST_VERTEX_CONVENTION 0x8E4E -#define GL_PROVOKING_VERTEX 0x8E4F - -typedef void (GLAPIENTRY * PFNGLPROVOKINGVERTEXPROC) (GLenum mode); - -#define glProvokingVertex GLEW_GET_FUN(__glewProvokingVertex) - -#define GLEW_ARB_provoking_vertex GLEW_GET_VAR(__GLEW_ARB_provoking_vertex) - -#endif /* GL_ARB_provoking_vertex */ - -/* ----------------------- GL_ARB_query_buffer_object ---------------------- */ - -#ifndef GL_ARB_query_buffer_object -#define GL_ARB_query_buffer_object 1 - -#define GL_QUERY_BUFFER_BARRIER_BIT 0x00008000 -#define GL_QUERY_BUFFER 0x9192 -#define GL_QUERY_BUFFER_BINDING 0x9193 -#define GL_QUERY_RESULT_NO_WAIT 0x9194 - -#define GLEW_ARB_query_buffer_object GLEW_GET_VAR(__GLEW_ARB_query_buffer_object) - -#endif /* GL_ARB_query_buffer_object */ - -/* ------------------ GL_ARB_robust_buffer_access_behavior ----------------- */ - -#ifndef GL_ARB_robust_buffer_access_behavior -#define GL_ARB_robust_buffer_access_behavior 1 - -#define GLEW_ARB_robust_buffer_access_behavior GLEW_GET_VAR(__GLEW_ARB_robust_buffer_access_behavior) - -#endif /* GL_ARB_robust_buffer_access_behavior */ - -/* --------------------------- GL_ARB_robustness --------------------------- */ - -#ifndef GL_ARB_robustness -#define GL_ARB_robustness 1 - -#define GL_CONTEXT_FLAG_ROBUST_ACCESS_BIT_ARB 0x00000004 -#define GL_LOSE_CONTEXT_ON_RESET_ARB 0x8252 -#define GL_GUILTY_CONTEXT_RESET_ARB 0x8253 -#define GL_INNOCENT_CONTEXT_RESET_ARB 0x8254 -#define GL_UNKNOWN_CONTEXT_RESET_ARB 0x8255 -#define GL_RESET_NOTIFICATION_STRATEGY_ARB 0x8256 -#define GL_NO_RESET_NOTIFICATION_ARB 0x8261 - -typedef GLenum (GLAPIENTRY * PFNGLGETGRAPHICSRESETSTATUSARBPROC) (void); -typedef void (GLAPIENTRY * PFNGLGETNCOLORTABLEARBPROC) (GLenum target, GLenum format, GLenum type, GLsizei bufSize, void* table); -typedef void (GLAPIENTRY * PFNGLGETNCOMPRESSEDTEXIMAGEARBPROC) (GLenum target, GLint lod, GLsizei bufSize, void* img); -typedef void (GLAPIENTRY * PFNGLGETNCONVOLUTIONFILTERARBPROC) (GLenum target, GLenum format, GLenum type, GLsizei bufSize, void* image); -typedef void (GLAPIENTRY * PFNGLGETNHISTOGRAMARBPROC) (GLenum target, GLboolean reset, GLenum format, GLenum type, GLsizei bufSize, void* values); -typedef void (GLAPIENTRY * PFNGLGETNMAPDVARBPROC) (GLenum target, GLenum query, GLsizei bufSize, GLdouble* v); -typedef void (GLAPIENTRY * PFNGLGETNMAPFVARBPROC) (GLenum target, GLenum query, GLsizei bufSize, GLfloat* v); -typedef void (GLAPIENTRY * PFNGLGETNMAPIVARBPROC) (GLenum target, GLenum query, GLsizei bufSize, GLint* v); -typedef void (GLAPIENTRY * PFNGLGETNMINMAXARBPROC) (GLenum target, GLboolean reset, GLenum format, GLenum type, GLsizei bufSize, void* values); -typedef void (GLAPIENTRY * PFNGLGETNPIXELMAPFVARBPROC) (GLenum map, GLsizei bufSize, GLfloat* values); -typedef void (GLAPIENTRY * PFNGLGETNPIXELMAPUIVARBPROC) (GLenum map, GLsizei bufSize, GLuint* values); -typedef void (GLAPIENTRY * PFNGLGETNPIXELMAPUSVARBPROC) (GLenum map, GLsizei bufSize, GLushort* values); -typedef void (GLAPIENTRY * PFNGLGETNPOLYGONSTIPPLEARBPROC) (GLsizei bufSize, GLubyte* pattern); -typedef void (GLAPIENTRY * PFNGLGETNSEPARABLEFILTERARBPROC) (GLenum target, GLenum format, GLenum type, GLsizei rowBufSize, void* row, GLsizei columnBufSize, void*column, void*span); -typedef void (GLAPIENTRY * PFNGLGETNTEXIMAGEARBPROC) (GLenum target, GLint level, GLenum format, GLenum type, GLsizei bufSize, void* img); -typedef void (GLAPIENTRY * PFNGLGETNUNIFORMDVARBPROC) (GLuint program, GLint location, GLsizei bufSize, GLdouble* params); -typedef void (GLAPIENTRY * PFNGLGETNUNIFORMFVARBPROC) (GLuint program, GLint location, GLsizei bufSize, GLfloat* params); -typedef void (GLAPIENTRY * PFNGLGETNUNIFORMIVARBPROC) (GLuint program, GLint location, GLsizei bufSize, GLint* params); -typedef void (GLAPIENTRY * PFNGLGETNUNIFORMUIVARBPROC) (GLuint program, GLint location, GLsizei bufSize, GLuint* params); -typedef void (GLAPIENTRY * PFNGLREADNPIXELSARBPROC) (GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLsizei bufSize, void* data); - -#define glGetGraphicsResetStatusARB GLEW_GET_FUN(__glewGetGraphicsResetStatusARB) -#define glGetnColorTableARB GLEW_GET_FUN(__glewGetnColorTableARB) -#define glGetnCompressedTexImageARB GLEW_GET_FUN(__glewGetnCompressedTexImageARB) -#define glGetnConvolutionFilterARB GLEW_GET_FUN(__glewGetnConvolutionFilterARB) -#define glGetnHistogramARB GLEW_GET_FUN(__glewGetnHistogramARB) -#define glGetnMapdvARB GLEW_GET_FUN(__glewGetnMapdvARB) -#define glGetnMapfvARB GLEW_GET_FUN(__glewGetnMapfvARB) -#define glGetnMapivARB GLEW_GET_FUN(__glewGetnMapivARB) -#define glGetnMinmaxARB GLEW_GET_FUN(__glewGetnMinmaxARB) -#define glGetnPixelMapfvARB GLEW_GET_FUN(__glewGetnPixelMapfvARB) -#define glGetnPixelMapuivARB GLEW_GET_FUN(__glewGetnPixelMapuivARB) -#define glGetnPixelMapusvARB GLEW_GET_FUN(__glewGetnPixelMapusvARB) -#define glGetnPolygonStippleARB GLEW_GET_FUN(__glewGetnPolygonStippleARB) -#define glGetnSeparableFilterARB GLEW_GET_FUN(__glewGetnSeparableFilterARB) -#define glGetnTexImageARB GLEW_GET_FUN(__glewGetnTexImageARB) -#define glGetnUniformdvARB GLEW_GET_FUN(__glewGetnUniformdvARB) -#define glGetnUniformfvARB GLEW_GET_FUN(__glewGetnUniformfvARB) -#define glGetnUniformivARB GLEW_GET_FUN(__glewGetnUniformivARB) -#define glGetnUniformuivARB GLEW_GET_FUN(__glewGetnUniformuivARB) -#define glReadnPixelsARB GLEW_GET_FUN(__glewReadnPixelsARB) - -#define GLEW_ARB_robustness GLEW_GET_VAR(__GLEW_ARB_robustness) - -#endif /* GL_ARB_robustness */ - -/* ---------------- GL_ARB_robustness_application_isolation ---------------- */ - -#ifndef GL_ARB_robustness_application_isolation -#define GL_ARB_robustness_application_isolation 1 - -#define GLEW_ARB_robustness_application_isolation GLEW_GET_VAR(__GLEW_ARB_robustness_application_isolation) - -#endif /* GL_ARB_robustness_application_isolation */ - -/* ---------------- GL_ARB_robustness_share_group_isolation ---------------- */ - -#ifndef GL_ARB_robustness_share_group_isolation -#define GL_ARB_robustness_share_group_isolation 1 - -#define GLEW_ARB_robustness_share_group_isolation GLEW_GET_VAR(__GLEW_ARB_robustness_share_group_isolation) - -#endif /* GL_ARB_robustness_share_group_isolation */ - -/* ------------------------ GL_ARB_sample_locations ------------------------ */ - -#ifndef GL_ARB_sample_locations -#define GL_ARB_sample_locations 1 - -#define GL_SAMPLE_LOCATION_ARB 0x8E50 -#define GL_SAMPLE_LOCATION_SUBPIXEL_BITS_ARB 0x933D -#define GL_SAMPLE_LOCATION_PIXEL_GRID_WIDTH_ARB 0x933E -#define GL_SAMPLE_LOCATION_PIXEL_GRID_HEIGHT_ARB 0x933F -#define GL_PROGRAMMABLE_SAMPLE_LOCATION_TABLE_SIZE_ARB 0x9340 -#define GL_PROGRAMMABLE_SAMPLE_LOCATION_ARB 0x9341 -#define GL_FRAMEBUFFER_PROGRAMMABLE_SAMPLE_LOCATIONS_ARB 0x9342 -#define GL_FRAMEBUFFER_SAMPLE_LOCATION_PIXEL_GRID_ARB 0x9343 - -typedef void (GLAPIENTRY * PFNGLFRAMEBUFFERSAMPLELOCATIONSFVARBPROC) (GLenum target, GLuint start, GLsizei count, const GLfloat* v); -typedef void (GLAPIENTRY * PFNGLNAMEDFRAMEBUFFERSAMPLELOCATIONSFVARBPROC) (GLuint framebuffer, GLuint start, GLsizei count, const GLfloat* v); - -#define glFramebufferSampleLocationsfvARB GLEW_GET_FUN(__glewFramebufferSampleLocationsfvARB) -#define glNamedFramebufferSampleLocationsfvARB GLEW_GET_FUN(__glewNamedFramebufferSampleLocationsfvARB) - -#define GLEW_ARB_sample_locations GLEW_GET_VAR(__GLEW_ARB_sample_locations) - -#endif /* GL_ARB_sample_locations */ - -/* ------------------------- GL_ARB_sample_shading ------------------------- */ - -#ifndef GL_ARB_sample_shading -#define GL_ARB_sample_shading 1 - -#define GL_SAMPLE_SHADING_ARB 0x8C36 -#define GL_MIN_SAMPLE_SHADING_VALUE_ARB 0x8C37 - -typedef void (GLAPIENTRY * PFNGLMINSAMPLESHADINGARBPROC) (GLclampf value); - -#define glMinSampleShadingARB GLEW_GET_FUN(__glewMinSampleShadingARB) - -#define GLEW_ARB_sample_shading GLEW_GET_VAR(__GLEW_ARB_sample_shading) - -#endif /* GL_ARB_sample_shading */ - -/* ------------------------- GL_ARB_sampler_objects ------------------------ */ - -#ifndef GL_ARB_sampler_objects -#define GL_ARB_sampler_objects 1 - -#define GL_SAMPLER_BINDING 0x8919 - -typedef void (GLAPIENTRY * PFNGLBINDSAMPLERPROC) (GLuint unit, GLuint sampler); -typedef void (GLAPIENTRY * PFNGLDELETESAMPLERSPROC) (GLsizei count, const GLuint * samplers); -typedef void (GLAPIENTRY * PFNGLGENSAMPLERSPROC) (GLsizei count, GLuint* samplers); -typedef void (GLAPIENTRY * PFNGLGETSAMPLERPARAMETERIIVPROC) (GLuint sampler, GLenum pname, GLint* params); -typedef void (GLAPIENTRY * PFNGLGETSAMPLERPARAMETERIUIVPROC) (GLuint sampler, GLenum pname, GLuint* params); -typedef void (GLAPIENTRY * PFNGLGETSAMPLERPARAMETERFVPROC) (GLuint sampler, GLenum pname, GLfloat* params); -typedef void (GLAPIENTRY * PFNGLGETSAMPLERPARAMETERIVPROC) (GLuint sampler, GLenum pname, GLint* params); -typedef GLboolean (GLAPIENTRY * PFNGLISSAMPLERPROC) (GLuint sampler); -typedef void (GLAPIENTRY * PFNGLSAMPLERPARAMETERIIVPROC) (GLuint sampler, GLenum pname, const GLint* params); -typedef void (GLAPIENTRY * PFNGLSAMPLERPARAMETERIUIVPROC) (GLuint sampler, GLenum pname, const GLuint* params); -typedef void (GLAPIENTRY * PFNGLSAMPLERPARAMETERFPROC) (GLuint sampler, GLenum pname, GLfloat param); -typedef void (GLAPIENTRY * PFNGLSAMPLERPARAMETERFVPROC) (GLuint sampler, GLenum pname, const GLfloat* params); -typedef void (GLAPIENTRY * PFNGLSAMPLERPARAMETERIPROC) (GLuint sampler, GLenum pname, GLint param); -typedef void (GLAPIENTRY * PFNGLSAMPLERPARAMETERIVPROC) (GLuint sampler, GLenum pname, const GLint* params); - -#define glBindSampler GLEW_GET_FUN(__glewBindSampler) -#define glDeleteSamplers GLEW_GET_FUN(__glewDeleteSamplers) -#define glGenSamplers GLEW_GET_FUN(__glewGenSamplers) -#define glGetSamplerParameterIiv GLEW_GET_FUN(__glewGetSamplerParameterIiv) -#define glGetSamplerParameterIuiv GLEW_GET_FUN(__glewGetSamplerParameterIuiv) -#define glGetSamplerParameterfv GLEW_GET_FUN(__glewGetSamplerParameterfv) -#define glGetSamplerParameteriv GLEW_GET_FUN(__glewGetSamplerParameteriv) -#define glIsSampler GLEW_GET_FUN(__glewIsSampler) -#define glSamplerParameterIiv GLEW_GET_FUN(__glewSamplerParameterIiv) -#define glSamplerParameterIuiv GLEW_GET_FUN(__glewSamplerParameterIuiv) -#define glSamplerParameterf GLEW_GET_FUN(__glewSamplerParameterf) -#define glSamplerParameterfv GLEW_GET_FUN(__glewSamplerParameterfv) -#define glSamplerParameteri GLEW_GET_FUN(__glewSamplerParameteri) -#define glSamplerParameteriv GLEW_GET_FUN(__glewSamplerParameteriv) - -#define GLEW_ARB_sampler_objects GLEW_GET_VAR(__GLEW_ARB_sampler_objects) - -#endif /* GL_ARB_sampler_objects */ - -/* ------------------------ GL_ARB_seamless_cube_map ----------------------- */ - -#ifndef GL_ARB_seamless_cube_map -#define GL_ARB_seamless_cube_map 1 - -#define GL_TEXTURE_CUBE_MAP_SEAMLESS 0x884F - -#define GLEW_ARB_seamless_cube_map GLEW_GET_VAR(__GLEW_ARB_seamless_cube_map) - -#endif /* GL_ARB_seamless_cube_map */ - -/* ------------------ GL_ARB_seamless_cubemap_per_texture ------------------ */ - -#ifndef GL_ARB_seamless_cubemap_per_texture -#define GL_ARB_seamless_cubemap_per_texture 1 - -#define GL_TEXTURE_CUBE_MAP_SEAMLESS 0x884F - -#define GLEW_ARB_seamless_cubemap_per_texture GLEW_GET_VAR(__GLEW_ARB_seamless_cubemap_per_texture) - -#endif /* GL_ARB_seamless_cubemap_per_texture */ - -/* --------------------- GL_ARB_separate_shader_objects -------------------- */ - -#ifndef GL_ARB_separate_shader_objects -#define GL_ARB_separate_shader_objects 1 - -#define GL_VERTEX_SHADER_BIT 0x00000001 -#define GL_FRAGMENT_SHADER_BIT 0x00000002 -#define GL_GEOMETRY_SHADER_BIT 0x00000004 -#define GL_TESS_CONTROL_SHADER_BIT 0x00000008 -#define GL_TESS_EVALUATION_SHADER_BIT 0x00000010 -#define GL_PROGRAM_SEPARABLE 0x8258 -#define GL_ACTIVE_PROGRAM 0x8259 -#define GL_PROGRAM_PIPELINE_BINDING 0x825A -#define GL_ALL_SHADER_BITS 0xFFFFFFFF - -typedef void (GLAPIENTRY * PFNGLACTIVESHADERPROGRAMPROC) (GLuint pipeline, GLuint program); -typedef void (GLAPIENTRY * PFNGLBINDPROGRAMPIPELINEPROC) (GLuint pipeline); -typedef GLuint (GLAPIENTRY * PFNGLCREATESHADERPROGRAMVPROC) (GLenum type, GLsizei count, const GLchar * const * strings); -typedef void (GLAPIENTRY * PFNGLDELETEPROGRAMPIPELINESPROC) (GLsizei n, const GLuint* pipelines); -typedef void (GLAPIENTRY * PFNGLGENPROGRAMPIPELINESPROC) (GLsizei n, GLuint* pipelines); -typedef void (GLAPIENTRY * PFNGLGETPROGRAMPIPELINEINFOLOGPROC) (GLuint pipeline, GLsizei bufSize, GLsizei* length, GLchar *infoLog); -typedef void (GLAPIENTRY * PFNGLGETPROGRAMPIPELINEIVPROC) (GLuint pipeline, GLenum pname, GLint* params); -typedef GLboolean (GLAPIENTRY * PFNGLISPROGRAMPIPELINEPROC) (GLuint pipeline); -typedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM1DPROC) (GLuint program, GLint location, GLdouble x); -typedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM1DVPROC) (GLuint program, GLint location, GLsizei count, const GLdouble* value); -typedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM1FPROC) (GLuint program, GLint location, GLfloat x); -typedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM1FVPROC) (GLuint program, GLint location, GLsizei count, const GLfloat* value); -typedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM1IPROC) (GLuint program, GLint location, GLint x); -typedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM1IVPROC) (GLuint program, GLint location, GLsizei count, const GLint* value); -typedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM1UIPROC) (GLuint program, GLint location, GLuint x); -typedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM1UIVPROC) (GLuint program, GLint location, GLsizei count, const GLuint* value); -typedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM2DPROC) (GLuint program, GLint location, GLdouble x, GLdouble y); -typedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM2DVPROC) (GLuint program, GLint location, GLsizei count, const GLdouble* value); -typedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM2FPROC) (GLuint program, GLint location, GLfloat x, GLfloat y); -typedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM2FVPROC) (GLuint program, GLint location, GLsizei count, const GLfloat* value); -typedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM2IPROC) (GLuint program, GLint location, GLint x, GLint y); -typedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM2IVPROC) (GLuint program, GLint location, GLsizei count, const GLint* value); -typedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM2UIPROC) (GLuint program, GLint location, GLuint x, GLuint y); -typedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM2UIVPROC) (GLuint program, GLint location, GLsizei count, const GLuint* value); -typedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM3DPROC) (GLuint program, GLint location, GLdouble x, GLdouble y, GLdouble z); -typedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM3DVPROC) (GLuint program, GLint location, GLsizei count, const GLdouble* value); -typedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM3FPROC) (GLuint program, GLint location, GLfloat x, GLfloat y, GLfloat z); -typedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM3FVPROC) (GLuint program, GLint location, GLsizei count, const GLfloat* value); -typedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM3IPROC) (GLuint program, GLint location, GLint x, GLint y, GLint z); -typedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM3IVPROC) (GLuint program, GLint location, GLsizei count, const GLint* value); -typedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM3UIPROC) (GLuint program, GLint location, GLuint x, GLuint y, GLuint z); -typedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM3UIVPROC) (GLuint program, GLint location, GLsizei count, const GLuint* value); -typedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM4DPROC) (GLuint program, GLint location, GLdouble x, GLdouble y, GLdouble z, GLdouble w); -typedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM4DVPROC) (GLuint program, GLint location, GLsizei count, const GLdouble* value); -typedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM4FPROC) (GLuint program, GLint location, GLfloat x, GLfloat y, GLfloat z, GLfloat w); -typedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM4FVPROC) (GLuint program, GLint location, GLsizei count, const GLfloat* value); -typedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM4IPROC) (GLuint program, GLint location, GLint x, GLint y, GLint z, GLint w); -typedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM4IVPROC) (GLuint program, GLint location, GLsizei count, const GLint* value); -typedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM4UIPROC) (GLuint program, GLint location, GLuint x, GLuint y, GLuint z, GLuint w); -typedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM4UIVPROC) (GLuint program, GLint location, GLsizei count, const GLuint* value); -typedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORMMATRIX2DVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble* value); -typedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORMMATRIX2FVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat* value); -typedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORMMATRIX2X3DVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble* value); -typedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORMMATRIX2X3FVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat* value); -typedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORMMATRIX2X4DVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble* value); -typedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORMMATRIX2X4FVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat* value); -typedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORMMATRIX3DVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble* value); -typedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORMMATRIX3FVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat* value); -typedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORMMATRIX3X2DVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble* value); -typedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORMMATRIX3X2FVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat* value); -typedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORMMATRIX3X4DVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble* value); -typedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORMMATRIX3X4FVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat* value); -typedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORMMATRIX4DVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble* value); -typedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORMMATRIX4FVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat* value); -typedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORMMATRIX4X2DVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble* value); -typedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORMMATRIX4X2FVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat* value); -typedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORMMATRIX4X3DVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble* value); -typedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORMMATRIX4X3FVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat* value); -typedef void (GLAPIENTRY * PFNGLUSEPROGRAMSTAGESPROC) (GLuint pipeline, GLbitfield stages, GLuint program); -typedef void (GLAPIENTRY * PFNGLVALIDATEPROGRAMPIPELINEPROC) (GLuint pipeline); - -#define glActiveShaderProgram GLEW_GET_FUN(__glewActiveShaderProgram) -#define glBindProgramPipeline GLEW_GET_FUN(__glewBindProgramPipeline) -#define glCreateShaderProgramv GLEW_GET_FUN(__glewCreateShaderProgramv) -#define glDeleteProgramPipelines GLEW_GET_FUN(__glewDeleteProgramPipelines) -#define glGenProgramPipelines GLEW_GET_FUN(__glewGenProgramPipelines) -#define glGetProgramPipelineInfoLog GLEW_GET_FUN(__glewGetProgramPipelineInfoLog) -#define glGetProgramPipelineiv GLEW_GET_FUN(__glewGetProgramPipelineiv) -#define glIsProgramPipeline GLEW_GET_FUN(__glewIsProgramPipeline) -#define glProgramUniform1d GLEW_GET_FUN(__glewProgramUniform1d) -#define glProgramUniform1dv GLEW_GET_FUN(__glewProgramUniform1dv) -#define glProgramUniform1f GLEW_GET_FUN(__glewProgramUniform1f) -#define glProgramUniform1fv GLEW_GET_FUN(__glewProgramUniform1fv) -#define glProgramUniform1i GLEW_GET_FUN(__glewProgramUniform1i) -#define glProgramUniform1iv GLEW_GET_FUN(__glewProgramUniform1iv) -#define glProgramUniform1ui GLEW_GET_FUN(__glewProgramUniform1ui) -#define glProgramUniform1uiv GLEW_GET_FUN(__glewProgramUniform1uiv) -#define glProgramUniform2d GLEW_GET_FUN(__glewProgramUniform2d) -#define glProgramUniform2dv GLEW_GET_FUN(__glewProgramUniform2dv) -#define glProgramUniform2f GLEW_GET_FUN(__glewProgramUniform2f) -#define glProgramUniform2fv GLEW_GET_FUN(__glewProgramUniform2fv) -#define glProgramUniform2i GLEW_GET_FUN(__glewProgramUniform2i) -#define glProgramUniform2iv GLEW_GET_FUN(__glewProgramUniform2iv) -#define glProgramUniform2ui GLEW_GET_FUN(__glewProgramUniform2ui) -#define glProgramUniform2uiv GLEW_GET_FUN(__glewProgramUniform2uiv) -#define glProgramUniform3d GLEW_GET_FUN(__glewProgramUniform3d) -#define glProgramUniform3dv GLEW_GET_FUN(__glewProgramUniform3dv) -#define glProgramUniform3f GLEW_GET_FUN(__glewProgramUniform3f) -#define glProgramUniform3fv GLEW_GET_FUN(__glewProgramUniform3fv) -#define glProgramUniform3i GLEW_GET_FUN(__glewProgramUniform3i) -#define glProgramUniform3iv GLEW_GET_FUN(__glewProgramUniform3iv) -#define glProgramUniform3ui GLEW_GET_FUN(__glewProgramUniform3ui) -#define glProgramUniform3uiv GLEW_GET_FUN(__glewProgramUniform3uiv) -#define glProgramUniform4d GLEW_GET_FUN(__glewProgramUniform4d) -#define glProgramUniform4dv GLEW_GET_FUN(__glewProgramUniform4dv) -#define glProgramUniform4f GLEW_GET_FUN(__glewProgramUniform4f) -#define glProgramUniform4fv GLEW_GET_FUN(__glewProgramUniform4fv) -#define glProgramUniform4i GLEW_GET_FUN(__glewProgramUniform4i) -#define glProgramUniform4iv GLEW_GET_FUN(__glewProgramUniform4iv) -#define glProgramUniform4ui GLEW_GET_FUN(__glewProgramUniform4ui) -#define glProgramUniform4uiv GLEW_GET_FUN(__glewProgramUniform4uiv) -#define glProgramUniformMatrix2dv GLEW_GET_FUN(__glewProgramUniformMatrix2dv) -#define glProgramUniformMatrix2fv GLEW_GET_FUN(__glewProgramUniformMatrix2fv) -#define glProgramUniformMatrix2x3dv GLEW_GET_FUN(__glewProgramUniformMatrix2x3dv) -#define glProgramUniformMatrix2x3fv GLEW_GET_FUN(__glewProgramUniformMatrix2x3fv) -#define glProgramUniformMatrix2x4dv GLEW_GET_FUN(__glewProgramUniformMatrix2x4dv) -#define glProgramUniformMatrix2x4fv GLEW_GET_FUN(__glewProgramUniformMatrix2x4fv) -#define glProgramUniformMatrix3dv GLEW_GET_FUN(__glewProgramUniformMatrix3dv) -#define glProgramUniformMatrix3fv GLEW_GET_FUN(__glewProgramUniformMatrix3fv) -#define glProgramUniformMatrix3x2dv GLEW_GET_FUN(__glewProgramUniformMatrix3x2dv) -#define glProgramUniformMatrix3x2fv GLEW_GET_FUN(__glewProgramUniformMatrix3x2fv) -#define glProgramUniformMatrix3x4dv GLEW_GET_FUN(__glewProgramUniformMatrix3x4dv) -#define glProgramUniformMatrix3x4fv GLEW_GET_FUN(__glewProgramUniformMatrix3x4fv) -#define glProgramUniformMatrix4dv GLEW_GET_FUN(__glewProgramUniformMatrix4dv) -#define glProgramUniformMatrix4fv GLEW_GET_FUN(__glewProgramUniformMatrix4fv) -#define glProgramUniformMatrix4x2dv GLEW_GET_FUN(__glewProgramUniformMatrix4x2dv) -#define glProgramUniformMatrix4x2fv GLEW_GET_FUN(__glewProgramUniformMatrix4x2fv) -#define glProgramUniformMatrix4x3dv GLEW_GET_FUN(__glewProgramUniformMatrix4x3dv) -#define glProgramUniformMatrix4x3fv GLEW_GET_FUN(__glewProgramUniformMatrix4x3fv) -#define glUseProgramStages GLEW_GET_FUN(__glewUseProgramStages) -#define glValidateProgramPipeline GLEW_GET_FUN(__glewValidateProgramPipeline) - -#define GLEW_ARB_separate_shader_objects GLEW_GET_VAR(__GLEW_ARB_separate_shader_objects) - -#endif /* GL_ARB_separate_shader_objects */ - -/* -------------------- GL_ARB_shader_atomic_counter_ops ------------------- */ - -#ifndef GL_ARB_shader_atomic_counter_ops -#define GL_ARB_shader_atomic_counter_ops 1 - -#define GLEW_ARB_shader_atomic_counter_ops GLEW_GET_VAR(__GLEW_ARB_shader_atomic_counter_ops) - -#endif /* GL_ARB_shader_atomic_counter_ops */ - -/* --------------------- GL_ARB_shader_atomic_counters --------------------- */ - -#ifndef GL_ARB_shader_atomic_counters -#define GL_ARB_shader_atomic_counters 1 - -#define GL_ATOMIC_COUNTER_BUFFER 0x92C0 -#define GL_ATOMIC_COUNTER_BUFFER_BINDING 0x92C1 -#define GL_ATOMIC_COUNTER_BUFFER_START 0x92C2 -#define GL_ATOMIC_COUNTER_BUFFER_SIZE 0x92C3 -#define GL_ATOMIC_COUNTER_BUFFER_DATA_SIZE 0x92C4 -#define GL_ATOMIC_COUNTER_BUFFER_ACTIVE_ATOMIC_COUNTERS 0x92C5 -#define GL_ATOMIC_COUNTER_BUFFER_ACTIVE_ATOMIC_COUNTER_INDICES 0x92C6 -#define GL_ATOMIC_COUNTER_BUFFER_REFERENCED_BY_VERTEX_SHADER 0x92C7 -#define GL_ATOMIC_COUNTER_BUFFER_REFERENCED_BY_TESS_CONTROL_SHADER 0x92C8 -#define GL_ATOMIC_COUNTER_BUFFER_REFERENCED_BY_TESS_EVALUATION_SHADER 0x92C9 -#define GL_ATOMIC_COUNTER_BUFFER_REFERENCED_BY_GEOMETRY_SHADER 0x92CA -#define GL_ATOMIC_COUNTER_BUFFER_REFERENCED_BY_FRAGMENT_SHADER 0x92CB -#define GL_MAX_VERTEX_ATOMIC_COUNTER_BUFFERS 0x92CC -#define GL_MAX_TESS_CONTROL_ATOMIC_COUNTER_BUFFERS 0x92CD -#define GL_MAX_TESS_EVALUATION_ATOMIC_COUNTER_BUFFERS 0x92CE -#define GL_MAX_GEOMETRY_ATOMIC_COUNTER_BUFFERS 0x92CF -#define GL_MAX_FRAGMENT_ATOMIC_COUNTER_BUFFERS 0x92D0 -#define GL_MAX_COMBINED_ATOMIC_COUNTER_BUFFERS 0x92D1 -#define GL_MAX_VERTEX_ATOMIC_COUNTERS 0x92D2 -#define GL_MAX_TESS_CONTROL_ATOMIC_COUNTERS 0x92D3 -#define GL_MAX_TESS_EVALUATION_ATOMIC_COUNTERS 0x92D4 -#define GL_MAX_GEOMETRY_ATOMIC_COUNTERS 0x92D5 -#define GL_MAX_FRAGMENT_ATOMIC_COUNTERS 0x92D6 -#define GL_MAX_COMBINED_ATOMIC_COUNTERS 0x92D7 -#define GL_MAX_ATOMIC_COUNTER_BUFFER_SIZE 0x92D8 -#define GL_ACTIVE_ATOMIC_COUNTER_BUFFERS 0x92D9 -#define GL_UNIFORM_ATOMIC_COUNTER_BUFFER_INDEX 0x92DA -#define GL_UNSIGNED_INT_ATOMIC_COUNTER 0x92DB -#define GL_MAX_ATOMIC_COUNTER_BUFFER_BINDINGS 0x92DC - -typedef void (GLAPIENTRY * PFNGLGETACTIVEATOMICCOUNTERBUFFERIVPROC) (GLuint program, GLuint bufferIndex, GLenum pname, GLint* params); - -#define glGetActiveAtomicCounterBufferiv GLEW_GET_FUN(__glewGetActiveAtomicCounterBufferiv) - -#define GLEW_ARB_shader_atomic_counters GLEW_GET_VAR(__GLEW_ARB_shader_atomic_counters) - -#endif /* GL_ARB_shader_atomic_counters */ - -/* -------------------------- GL_ARB_shader_ballot ------------------------- */ - -#ifndef GL_ARB_shader_ballot -#define GL_ARB_shader_ballot 1 - -#define GLEW_ARB_shader_ballot GLEW_GET_VAR(__GLEW_ARB_shader_ballot) - -#endif /* GL_ARB_shader_ballot */ - -/* ----------------------- GL_ARB_shader_bit_encoding ---------------------- */ - -#ifndef GL_ARB_shader_bit_encoding -#define GL_ARB_shader_bit_encoding 1 - -#define GLEW_ARB_shader_bit_encoding GLEW_GET_VAR(__GLEW_ARB_shader_bit_encoding) - -#endif /* GL_ARB_shader_bit_encoding */ - -/* -------------------------- GL_ARB_shader_clock -------------------------- */ - -#ifndef GL_ARB_shader_clock -#define GL_ARB_shader_clock 1 - -#define GLEW_ARB_shader_clock GLEW_GET_VAR(__GLEW_ARB_shader_clock) - -#endif /* GL_ARB_shader_clock */ - -/* --------------------- GL_ARB_shader_draw_parameters --------------------- */ - -#ifndef GL_ARB_shader_draw_parameters -#define GL_ARB_shader_draw_parameters 1 - -#define GLEW_ARB_shader_draw_parameters GLEW_GET_VAR(__GLEW_ARB_shader_draw_parameters) - -#endif /* GL_ARB_shader_draw_parameters */ - -/* ------------------------ GL_ARB_shader_group_vote ----------------------- */ - -#ifndef GL_ARB_shader_group_vote -#define GL_ARB_shader_group_vote 1 - -#define GLEW_ARB_shader_group_vote GLEW_GET_VAR(__GLEW_ARB_shader_group_vote) - -#endif /* GL_ARB_shader_group_vote */ - -/* --------------------- GL_ARB_shader_image_load_store -------------------- */ - -#ifndef GL_ARB_shader_image_load_store -#define GL_ARB_shader_image_load_store 1 - -#define GL_VERTEX_ATTRIB_ARRAY_BARRIER_BIT 0x00000001 -#define GL_ELEMENT_ARRAY_BARRIER_BIT 0x00000002 -#define GL_UNIFORM_BARRIER_BIT 0x00000004 -#define GL_TEXTURE_FETCH_BARRIER_BIT 0x00000008 -#define GL_SHADER_IMAGE_ACCESS_BARRIER_BIT 0x00000020 -#define GL_COMMAND_BARRIER_BIT 0x00000040 -#define GL_PIXEL_BUFFER_BARRIER_BIT 0x00000080 -#define GL_TEXTURE_UPDATE_BARRIER_BIT 0x00000100 -#define GL_BUFFER_UPDATE_BARRIER_BIT 0x00000200 -#define GL_FRAMEBUFFER_BARRIER_BIT 0x00000400 -#define GL_TRANSFORM_FEEDBACK_BARRIER_BIT 0x00000800 -#define GL_ATOMIC_COUNTER_BARRIER_BIT 0x00001000 -#define GL_MAX_IMAGE_UNITS 0x8F38 -#define GL_MAX_COMBINED_IMAGE_UNITS_AND_FRAGMENT_OUTPUTS 0x8F39 -#define GL_IMAGE_BINDING_NAME 0x8F3A -#define GL_IMAGE_BINDING_LEVEL 0x8F3B -#define GL_IMAGE_BINDING_LAYERED 0x8F3C -#define GL_IMAGE_BINDING_LAYER 0x8F3D -#define GL_IMAGE_BINDING_ACCESS 0x8F3E -#define GL_IMAGE_1D 0x904C -#define GL_IMAGE_2D 0x904D -#define GL_IMAGE_3D 0x904E -#define GL_IMAGE_2D_RECT 0x904F -#define GL_IMAGE_CUBE 0x9050 -#define GL_IMAGE_BUFFER 0x9051 -#define GL_IMAGE_1D_ARRAY 0x9052 -#define GL_IMAGE_2D_ARRAY 0x9053 -#define GL_IMAGE_CUBE_MAP_ARRAY 0x9054 -#define GL_IMAGE_2D_MULTISAMPLE 0x9055 -#define GL_IMAGE_2D_MULTISAMPLE_ARRAY 0x9056 -#define GL_INT_IMAGE_1D 0x9057 -#define GL_INT_IMAGE_2D 0x9058 -#define GL_INT_IMAGE_3D 0x9059 -#define GL_INT_IMAGE_2D_RECT 0x905A -#define GL_INT_IMAGE_CUBE 0x905B -#define GL_INT_IMAGE_BUFFER 0x905C -#define GL_INT_IMAGE_1D_ARRAY 0x905D -#define GL_INT_IMAGE_2D_ARRAY 0x905E -#define GL_INT_IMAGE_CUBE_MAP_ARRAY 0x905F -#define GL_INT_IMAGE_2D_MULTISAMPLE 0x9060 -#define GL_INT_IMAGE_2D_MULTISAMPLE_ARRAY 0x9061 -#define GL_UNSIGNED_INT_IMAGE_1D 0x9062 -#define GL_UNSIGNED_INT_IMAGE_2D 0x9063 -#define GL_UNSIGNED_INT_IMAGE_3D 0x9064 -#define GL_UNSIGNED_INT_IMAGE_2D_RECT 0x9065 -#define GL_UNSIGNED_INT_IMAGE_CUBE 0x9066 -#define GL_UNSIGNED_INT_IMAGE_BUFFER 0x9067 -#define GL_UNSIGNED_INT_IMAGE_1D_ARRAY 0x9068 -#define GL_UNSIGNED_INT_IMAGE_2D_ARRAY 0x9069 -#define GL_UNSIGNED_INT_IMAGE_CUBE_MAP_ARRAY 0x906A -#define GL_UNSIGNED_INT_IMAGE_2D_MULTISAMPLE 0x906B -#define GL_UNSIGNED_INT_IMAGE_2D_MULTISAMPLE_ARRAY 0x906C -#define GL_MAX_IMAGE_SAMPLES 0x906D -#define GL_IMAGE_BINDING_FORMAT 0x906E -#define GL_IMAGE_FORMAT_COMPATIBILITY_TYPE 0x90C7 -#define GL_IMAGE_FORMAT_COMPATIBILITY_BY_SIZE 0x90C8 -#define GL_IMAGE_FORMAT_COMPATIBILITY_BY_CLASS 0x90C9 -#define GL_MAX_VERTEX_IMAGE_UNIFORMS 0x90CA -#define GL_MAX_TESS_CONTROL_IMAGE_UNIFORMS 0x90CB -#define GL_MAX_TESS_EVALUATION_IMAGE_UNIFORMS 0x90CC -#define GL_MAX_GEOMETRY_IMAGE_UNIFORMS 0x90CD -#define GL_MAX_FRAGMENT_IMAGE_UNIFORMS 0x90CE -#define GL_MAX_COMBINED_IMAGE_UNIFORMS 0x90CF -#define GL_ALL_BARRIER_BITS 0xFFFFFFFF - -typedef void (GLAPIENTRY * PFNGLBINDIMAGETEXTUREPROC) (GLuint unit, GLuint texture, GLint level, GLboolean layered, GLint layer, GLenum access, GLenum format); -typedef void (GLAPIENTRY * PFNGLMEMORYBARRIERPROC) (GLbitfield barriers); - -#define glBindImageTexture GLEW_GET_FUN(__glewBindImageTexture) -#define glMemoryBarrier GLEW_GET_FUN(__glewMemoryBarrier) - -#define GLEW_ARB_shader_image_load_store GLEW_GET_VAR(__GLEW_ARB_shader_image_load_store) - -#endif /* GL_ARB_shader_image_load_store */ - -/* ------------------------ GL_ARB_shader_image_size ----------------------- */ - -#ifndef GL_ARB_shader_image_size -#define GL_ARB_shader_image_size 1 - -#define GLEW_ARB_shader_image_size GLEW_GET_VAR(__GLEW_ARB_shader_image_size) - -#endif /* GL_ARB_shader_image_size */ - -/* ------------------------- GL_ARB_shader_objects ------------------------- */ - -#ifndef GL_ARB_shader_objects -#define GL_ARB_shader_objects 1 - -#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 - -typedef char GLcharARB; -typedef unsigned int GLhandleARB; - -typedef void (GLAPIENTRY * PFNGLATTACHOBJECTARBPROC) (GLhandleARB containerObj, GLhandleARB obj); -typedef void (GLAPIENTRY * PFNGLCOMPILESHADERARBPROC) (GLhandleARB shaderObj); -typedef GLhandleARB (GLAPIENTRY * PFNGLCREATEPROGRAMOBJECTARBPROC) (void); -typedef GLhandleARB (GLAPIENTRY * PFNGLCREATESHADEROBJECTARBPROC) (GLenum shaderType); -typedef void (GLAPIENTRY * PFNGLDELETEOBJECTARBPROC) (GLhandleARB obj); -typedef void (GLAPIENTRY * PFNGLDETACHOBJECTARBPROC) (GLhandleARB containerObj, GLhandleARB attachedObj); -typedef void (GLAPIENTRY * PFNGLGETACTIVEUNIFORMARBPROC) (GLhandleARB programObj, GLuint index, GLsizei maxLength, GLsizei* length, GLint *size, GLenum *type, GLcharARB *name); -typedef void (GLAPIENTRY * PFNGLGETATTACHEDOBJECTSARBPROC) (GLhandleARB containerObj, GLsizei maxCount, GLsizei* count, GLhandleARB *obj); -typedef GLhandleARB (GLAPIENTRY * PFNGLGETHANDLEARBPROC) (GLenum pname); -typedef void (GLAPIENTRY * PFNGLGETINFOLOGARBPROC) (GLhandleARB obj, GLsizei maxLength, GLsizei* length, GLcharARB *infoLog); -typedef void (GLAPIENTRY * PFNGLGETOBJECTPARAMETERFVARBPROC) (GLhandleARB obj, GLenum pname, GLfloat* params); -typedef void (GLAPIENTRY * PFNGLGETOBJECTPARAMETERIVARBPROC) (GLhandleARB obj, GLenum pname, GLint* params); -typedef void (GLAPIENTRY * PFNGLGETSHADERSOURCEARBPROC) (GLhandleARB obj, GLsizei maxLength, GLsizei* length, GLcharARB *source); -typedef GLint (GLAPIENTRY * PFNGLGETUNIFORMLOCATIONARBPROC) (GLhandleARB programObj, const GLcharARB* name); -typedef void (GLAPIENTRY * PFNGLGETUNIFORMFVARBPROC) (GLhandleARB programObj, GLint location, GLfloat* params); -typedef void (GLAPIENTRY * PFNGLGETUNIFORMIVARBPROC) (GLhandleARB programObj, GLint location, GLint* params); -typedef void (GLAPIENTRY * PFNGLLINKPROGRAMARBPROC) (GLhandleARB programObj); -typedef void (GLAPIENTRY * PFNGLSHADERSOURCEARBPROC) (GLhandleARB shaderObj, GLsizei count, const GLcharARB ** string, const GLint *length); -typedef void (GLAPIENTRY * PFNGLUNIFORM1FARBPROC) (GLint location, GLfloat v0); -typedef void (GLAPIENTRY * PFNGLUNIFORM1FVARBPROC) (GLint location, GLsizei count, const GLfloat* value); -typedef void (GLAPIENTRY * PFNGLUNIFORM1IARBPROC) (GLint location, GLint v0); -typedef void (GLAPIENTRY * PFNGLUNIFORM1IVARBPROC) (GLint location, GLsizei count, const GLint* value); -typedef void (GLAPIENTRY * PFNGLUNIFORM2FARBPROC) (GLint location, GLfloat v0, GLfloat v1); -typedef void (GLAPIENTRY * PFNGLUNIFORM2FVARBPROC) (GLint location, GLsizei count, const GLfloat* value); -typedef void (GLAPIENTRY * PFNGLUNIFORM2IARBPROC) (GLint location, GLint v0, GLint v1); -typedef void (GLAPIENTRY * PFNGLUNIFORM2IVARBPROC) (GLint location, GLsizei count, const GLint* value); -typedef void (GLAPIENTRY * PFNGLUNIFORM3FARBPROC) (GLint location, GLfloat v0, GLfloat v1, GLfloat v2); -typedef void (GLAPIENTRY * PFNGLUNIFORM3FVARBPROC) (GLint location, GLsizei count, const GLfloat* value); -typedef void (GLAPIENTRY * PFNGLUNIFORM3IARBPROC) (GLint location, GLint v0, GLint v1, GLint v2); -typedef void (GLAPIENTRY * PFNGLUNIFORM3IVARBPROC) (GLint location, GLsizei count, const GLint* value); -typedef void (GLAPIENTRY * PFNGLUNIFORM4FARBPROC) (GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3); -typedef void (GLAPIENTRY * PFNGLUNIFORM4FVARBPROC) (GLint location, GLsizei count, const GLfloat* value); -typedef void (GLAPIENTRY * PFNGLUNIFORM4IARBPROC) (GLint location, GLint v0, GLint v1, GLint v2, GLint v3); -typedef void (GLAPIENTRY * PFNGLUNIFORM4IVARBPROC) (GLint location, GLsizei count, const GLint* value); -typedef void (GLAPIENTRY * PFNGLUNIFORMMATRIX2FVARBPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat* value); -typedef void (GLAPIENTRY * PFNGLUNIFORMMATRIX3FVARBPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat* value); -typedef void (GLAPIENTRY * PFNGLUNIFORMMATRIX4FVARBPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat* value); -typedef void (GLAPIENTRY * PFNGLUSEPROGRAMOBJECTARBPROC) (GLhandleARB programObj); -typedef void (GLAPIENTRY * PFNGLVALIDATEPROGRAMARBPROC) (GLhandleARB programObj); - -#define glAttachObjectARB GLEW_GET_FUN(__glewAttachObjectARB) -#define glCompileShaderARB GLEW_GET_FUN(__glewCompileShaderARB) -#define glCreateProgramObjectARB GLEW_GET_FUN(__glewCreateProgramObjectARB) -#define glCreateShaderObjectARB GLEW_GET_FUN(__glewCreateShaderObjectARB) -#define glDeleteObjectARB GLEW_GET_FUN(__glewDeleteObjectARB) -#define glDetachObjectARB GLEW_GET_FUN(__glewDetachObjectARB) -#define glGetActiveUniformARB GLEW_GET_FUN(__glewGetActiveUniformARB) -#define glGetAttachedObjectsARB GLEW_GET_FUN(__glewGetAttachedObjectsARB) -#define glGetHandleARB GLEW_GET_FUN(__glewGetHandleARB) -#define glGetInfoLogARB GLEW_GET_FUN(__glewGetInfoLogARB) -#define glGetObjectParameterfvARB GLEW_GET_FUN(__glewGetObjectParameterfvARB) -#define glGetObjectParameterivARB GLEW_GET_FUN(__glewGetObjectParameterivARB) -#define glGetShaderSourceARB GLEW_GET_FUN(__glewGetShaderSourceARB) -#define glGetUniformLocationARB GLEW_GET_FUN(__glewGetUniformLocationARB) -#define glGetUniformfvARB GLEW_GET_FUN(__glewGetUniformfvARB) -#define glGetUniformivARB GLEW_GET_FUN(__glewGetUniformivARB) -#define glLinkProgramARB GLEW_GET_FUN(__glewLinkProgramARB) -#define glShaderSourceARB GLEW_GET_FUN(__glewShaderSourceARB) -#define glUniform1fARB GLEW_GET_FUN(__glewUniform1fARB) -#define glUniform1fvARB GLEW_GET_FUN(__glewUniform1fvARB) -#define glUniform1iARB GLEW_GET_FUN(__glewUniform1iARB) -#define glUniform1ivARB GLEW_GET_FUN(__glewUniform1ivARB) -#define glUniform2fARB GLEW_GET_FUN(__glewUniform2fARB) -#define glUniform2fvARB GLEW_GET_FUN(__glewUniform2fvARB) -#define glUniform2iARB GLEW_GET_FUN(__glewUniform2iARB) -#define glUniform2ivARB GLEW_GET_FUN(__glewUniform2ivARB) -#define glUniform3fARB GLEW_GET_FUN(__glewUniform3fARB) -#define glUniform3fvARB GLEW_GET_FUN(__glewUniform3fvARB) -#define glUniform3iARB GLEW_GET_FUN(__glewUniform3iARB) -#define glUniform3ivARB GLEW_GET_FUN(__glewUniform3ivARB) -#define glUniform4fARB GLEW_GET_FUN(__glewUniform4fARB) -#define glUniform4fvARB GLEW_GET_FUN(__glewUniform4fvARB) -#define glUniform4iARB GLEW_GET_FUN(__glewUniform4iARB) -#define glUniform4ivARB GLEW_GET_FUN(__glewUniform4ivARB) -#define glUniformMatrix2fvARB GLEW_GET_FUN(__glewUniformMatrix2fvARB) -#define glUniformMatrix3fvARB GLEW_GET_FUN(__glewUniformMatrix3fvARB) -#define glUniformMatrix4fvARB GLEW_GET_FUN(__glewUniformMatrix4fvARB) -#define glUseProgramObjectARB GLEW_GET_FUN(__glewUseProgramObjectARB) -#define glValidateProgramARB GLEW_GET_FUN(__glewValidateProgramARB) - -#define GLEW_ARB_shader_objects GLEW_GET_VAR(__GLEW_ARB_shader_objects) - -#endif /* GL_ARB_shader_objects */ - -/* ------------------------ GL_ARB_shader_precision ------------------------ */ - -#ifndef GL_ARB_shader_precision -#define GL_ARB_shader_precision 1 - -#define GLEW_ARB_shader_precision GLEW_GET_VAR(__GLEW_ARB_shader_precision) - -#endif /* GL_ARB_shader_precision */ - -/* ---------------------- GL_ARB_shader_stencil_export --------------------- */ - -#ifndef GL_ARB_shader_stencil_export -#define GL_ARB_shader_stencil_export 1 - -#define GLEW_ARB_shader_stencil_export GLEW_GET_VAR(__GLEW_ARB_shader_stencil_export) - -#endif /* GL_ARB_shader_stencil_export */ - -/* ------------------ GL_ARB_shader_storage_buffer_object ------------------ */ - -#ifndef GL_ARB_shader_storage_buffer_object -#define GL_ARB_shader_storage_buffer_object 1 - -#define GL_SHADER_STORAGE_BARRIER_BIT 0x2000 -#define GL_MAX_COMBINED_SHADER_OUTPUT_RESOURCES 0x8F39 -#define GL_SHADER_STORAGE_BUFFER 0x90D2 -#define GL_SHADER_STORAGE_BUFFER_BINDING 0x90D3 -#define GL_SHADER_STORAGE_BUFFER_START 0x90D4 -#define GL_SHADER_STORAGE_BUFFER_SIZE 0x90D5 -#define GL_MAX_VERTEX_SHADER_STORAGE_BLOCKS 0x90D6 -#define GL_MAX_GEOMETRY_SHADER_STORAGE_BLOCKS 0x90D7 -#define GL_MAX_TESS_CONTROL_SHADER_STORAGE_BLOCKS 0x90D8 -#define GL_MAX_TESS_EVALUATION_SHADER_STORAGE_BLOCKS 0x90D9 -#define GL_MAX_FRAGMENT_SHADER_STORAGE_BLOCKS 0x90DA -#define GL_MAX_COMPUTE_SHADER_STORAGE_BLOCKS 0x90DB -#define GL_MAX_COMBINED_SHADER_STORAGE_BLOCKS 0x90DC -#define GL_MAX_SHADER_STORAGE_BUFFER_BINDINGS 0x90DD -#define GL_MAX_SHADER_STORAGE_BLOCK_SIZE 0x90DE -#define GL_SHADER_STORAGE_BUFFER_OFFSET_ALIGNMENT 0x90DF - -typedef void (GLAPIENTRY * PFNGLSHADERSTORAGEBLOCKBINDINGPROC) (GLuint program, GLuint storageBlockIndex, GLuint storageBlockBinding); - -#define glShaderStorageBlockBinding GLEW_GET_FUN(__glewShaderStorageBlockBinding) - -#define GLEW_ARB_shader_storage_buffer_object GLEW_GET_VAR(__GLEW_ARB_shader_storage_buffer_object) - -#endif /* GL_ARB_shader_storage_buffer_object */ - -/* ------------------------ GL_ARB_shader_subroutine ----------------------- */ - -#ifndef GL_ARB_shader_subroutine -#define GL_ARB_shader_subroutine 1 - -#define GL_ACTIVE_SUBROUTINES 0x8DE5 -#define GL_ACTIVE_SUBROUTINE_UNIFORMS 0x8DE6 -#define GL_MAX_SUBROUTINES 0x8DE7 -#define GL_MAX_SUBROUTINE_UNIFORM_LOCATIONS 0x8DE8 -#define GL_ACTIVE_SUBROUTINE_UNIFORM_LOCATIONS 0x8E47 -#define GL_ACTIVE_SUBROUTINE_MAX_LENGTH 0x8E48 -#define GL_ACTIVE_SUBROUTINE_UNIFORM_MAX_LENGTH 0x8E49 -#define GL_NUM_COMPATIBLE_SUBROUTINES 0x8E4A -#define GL_COMPATIBLE_SUBROUTINES 0x8E4B - -typedef void (GLAPIENTRY * PFNGLGETACTIVESUBROUTINENAMEPROC) (GLuint program, GLenum shadertype, GLuint index, GLsizei bufsize, GLsizei* length, GLchar *name); -typedef void (GLAPIENTRY * PFNGLGETACTIVESUBROUTINEUNIFORMNAMEPROC) (GLuint program, GLenum shadertype, GLuint index, GLsizei bufsize, GLsizei* length, GLchar *name); -typedef void (GLAPIENTRY * PFNGLGETACTIVESUBROUTINEUNIFORMIVPROC) (GLuint program, GLenum shadertype, GLuint index, GLenum pname, GLint* values); -typedef void (GLAPIENTRY * PFNGLGETPROGRAMSTAGEIVPROC) (GLuint program, GLenum shadertype, GLenum pname, GLint* values); -typedef GLuint (GLAPIENTRY * PFNGLGETSUBROUTINEINDEXPROC) (GLuint program, GLenum shadertype, const GLchar* name); -typedef GLint (GLAPIENTRY * PFNGLGETSUBROUTINEUNIFORMLOCATIONPROC) (GLuint program, GLenum shadertype, const GLchar* name); -typedef void (GLAPIENTRY * PFNGLGETUNIFORMSUBROUTINEUIVPROC) (GLenum shadertype, GLint location, GLuint* params); -typedef void (GLAPIENTRY * PFNGLUNIFORMSUBROUTINESUIVPROC) (GLenum shadertype, GLsizei count, const GLuint* indices); - -#define glGetActiveSubroutineName GLEW_GET_FUN(__glewGetActiveSubroutineName) -#define glGetActiveSubroutineUniformName GLEW_GET_FUN(__glewGetActiveSubroutineUniformName) -#define glGetActiveSubroutineUniformiv GLEW_GET_FUN(__glewGetActiveSubroutineUniformiv) -#define glGetProgramStageiv GLEW_GET_FUN(__glewGetProgramStageiv) -#define glGetSubroutineIndex GLEW_GET_FUN(__glewGetSubroutineIndex) -#define glGetSubroutineUniformLocation GLEW_GET_FUN(__glewGetSubroutineUniformLocation) -#define glGetUniformSubroutineuiv GLEW_GET_FUN(__glewGetUniformSubroutineuiv) -#define glUniformSubroutinesuiv GLEW_GET_FUN(__glewUniformSubroutinesuiv) - -#define GLEW_ARB_shader_subroutine GLEW_GET_VAR(__GLEW_ARB_shader_subroutine) - -#endif /* GL_ARB_shader_subroutine */ - -/* ------------------ GL_ARB_shader_texture_image_samples ------------------ */ - -#ifndef GL_ARB_shader_texture_image_samples -#define GL_ARB_shader_texture_image_samples 1 - -#define GLEW_ARB_shader_texture_image_samples GLEW_GET_VAR(__GLEW_ARB_shader_texture_image_samples) - -#endif /* GL_ARB_shader_texture_image_samples */ - -/* ----------------------- GL_ARB_shader_texture_lod ----------------------- */ - -#ifndef GL_ARB_shader_texture_lod -#define GL_ARB_shader_texture_lod 1 - -#define GLEW_ARB_shader_texture_lod GLEW_GET_VAR(__GLEW_ARB_shader_texture_lod) - -#endif /* GL_ARB_shader_texture_lod */ - -/* ------------------- GL_ARB_shader_viewport_layer_array ------------------ */ - -#ifndef GL_ARB_shader_viewport_layer_array -#define GL_ARB_shader_viewport_layer_array 1 - -#define GLEW_ARB_shader_viewport_layer_array GLEW_GET_VAR(__GLEW_ARB_shader_viewport_layer_array) - -#endif /* GL_ARB_shader_viewport_layer_array */ - -/* ---------------------- GL_ARB_shading_language_100 ---------------------- */ - -#ifndef GL_ARB_shading_language_100 -#define GL_ARB_shading_language_100 1 - -#define GL_SHADING_LANGUAGE_VERSION_ARB 0x8B8C - -#define GLEW_ARB_shading_language_100 GLEW_GET_VAR(__GLEW_ARB_shading_language_100) - -#endif /* GL_ARB_shading_language_100 */ - -/* -------------------- GL_ARB_shading_language_420pack -------------------- */ - -#ifndef GL_ARB_shading_language_420pack -#define GL_ARB_shading_language_420pack 1 - -#define GLEW_ARB_shading_language_420pack GLEW_GET_VAR(__GLEW_ARB_shading_language_420pack) - -#endif /* GL_ARB_shading_language_420pack */ - -/* -------------------- GL_ARB_shading_language_include -------------------- */ - -#ifndef GL_ARB_shading_language_include -#define GL_ARB_shading_language_include 1 - -#define GL_SHADER_INCLUDE_ARB 0x8DAE -#define GL_NAMED_STRING_LENGTH_ARB 0x8DE9 -#define GL_NAMED_STRING_TYPE_ARB 0x8DEA - -typedef void (GLAPIENTRY * PFNGLCOMPILESHADERINCLUDEARBPROC) (GLuint shader, GLsizei count, const GLchar* const *path, const GLint *length); -typedef void (GLAPIENTRY * PFNGLDELETENAMEDSTRINGARBPROC) (GLint namelen, const GLchar* name); -typedef void (GLAPIENTRY * PFNGLGETNAMEDSTRINGARBPROC) (GLint namelen, const GLchar* name, GLsizei bufSize, GLint *stringlen, GLchar *string); -typedef void (GLAPIENTRY * PFNGLGETNAMEDSTRINGIVARBPROC) (GLint namelen, const GLchar* name, GLenum pname, GLint *params); -typedef GLboolean (GLAPIENTRY * PFNGLISNAMEDSTRINGARBPROC) (GLint namelen, const GLchar* name); -typedef void (GLAPIENTRY * PFNGLNAMEDSTRINGARBPROC) (GLenum type, GLint namelen, const GLchar* name, GLint stringlen, const GLchar *string); - -#define glCompileShaderIncludeARB GLEW_GET_FUN(__glewCompileShaderIncludeARB) -#define glDeleteNamedStringARB GLEW_GET_FUN(__glewDeleteNamedStringARB) -#define glGetNamedStringARB GLEW_GET_FUN(__glewGetNamedStringARB) -#define glGetNamedStringivARB GLEW_GET_FUN(__glewGetNamedStringivARB) -#define glIsNamedStringARB GLEW_GET_FUN(__glewIsNamedStringARB) -#define glNamedStringARB GLEW_GET_FUN(__glewNamedStringARB) - -#define GLEW_ARB_shading_language_include GLEW_GET_VAR(__GLEW_ARB_shading_language_include) - -#endif /* GL_ARB_shading_language_include */ - -/* -------------------- GL_ARB_shading_language_packing -------------------- */ - -#ifndef GL_ARB_shading_language_packing -#define GL_ARB_shading_language_packing 1 - -#define GLEW_ARB_shading_language_packing GLEW_GET_VAR(__GLEW_ARB_shading_language_packing) - -#endif /* GL_ARB_shading_language_packing */ - -/* ----------------------------- GL_ARB_shadow ----------------------------- */ - -#ifndef GL_ARB_shadow -#define GL_ARB_shadow 1 - -#define GL_TEXTURE_COMPARE_MODE_ARB 0x884C -#define GL_TEXTURE_COMPARE_FUNC_ARB 0x884D -#define GL_COMPARE_R_TO_TEXTURE_ARB 0x884E - -#define GLEW_ARB_shadow GLEW_GET_VAR(__GLEW_ARB_shadow) - -#endif /* GL_ARB_shadow */ - -/* ------------------------- GL_ARB_shadow_ambient ------------------------- */ - -#ifndef GL_ARB_shadow_ambient -#define GL_ARB_shadow_ambient 1 - -#define GL_TEXTURE_COMPARE_FAIL_VALUE_ARB 0x80BF - -#define GLEW_ARB_shadow_ambient GLEW_GET_VAR(__GLEW_ARB_shadow_ambient) - -#endif /* GL_ARB_shadow_ambient */ - -/* -------------------------- GL_ARB_sparse_buffer ------------------------- */ - -#ifndef GL_ARB_sparse_buffer -#define GL_ARB_sparse_buffer 1 - -#define GL_SPARSE_STORAGE_BIT_ARB 0x0400 -#define GL_SPARSE_BUFFER_PAGE_SIZE_ARB 0x82F8 - -typedef void (GLAPIENTRY * PFNGLBUFFERPAGECOMMITMENTARBPROC) (GLenum target, GLintptr offset, GLsizeiptr size, GLboolean commit); - -#define glBufferPageCommitmentARB GLEW_GET_FUN(__glewBufferPageCommitmentARB) - -#define GLEW_ARB_sparse_buffer GLEW_GET_VAR(__GLEW_ARB_sparse_buffer) - -#endif /* GL_ARB_sparse_buffer */ - -/* ------------------------- GL_ARB_sparse_texture ------------------------- */ - -#ifndef GL_ARB_sparse_texture -#define GL_ARB_sparse_texture 1 - -#define GL_VIRTUAL_PAGE_SIZE_X_ARB 0x9195 -#define GL_VIRTUAL_PAGE_SIZE_Y_ARB 0x9196 -#define GL_VIRTUAL_PAGE_SIZE_Z_ARB 0x9197 -#define GL_MAX_SPARSE_TEXTURE_SIZE_ARB 0x9198 -#define GL_MAX_SPARSE_3D_TEXTURE_SIZE_ARB 0x9199 -#define GL_MAX_SPARSE_ARRAY_TEXTURE_LAYERS_ARB 0x919A -#define GL_TEXTURE_SPARSE_ARB 0x91A6 -#define GL_VIRTUAL_PAGE_SIZE_INDEX_ARB 0x91A7 -#define GL_NUM_VIRTUAL_PAGE_SIZES_ARB 0x91A8 -#define GL_SPARSE_TEXTURE_FULL_ARRAY_CUBE_MIPMAPS_ARB 0x91A9 -#define GL_NUM_SPARSE_LEVELS_ARB 0x91AA - -typedef void (GLAPIENTRY * PFNGLTEXPAGECOMMITMENTARBPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLboolean commit); -typedef void (GLAPIENTRY * PFNGLTEXTUREPAGECOMMITMENTEXTPROC) (GLuint texture, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLboolean commit); - -#define glTexPageCommitmentARB GLEW_GET_FUN(__glewTexPageCommitmentARB) -#define glTexturePageCommitmentEXT GLEW_GET_FUN(__glewTexturePageCommitmentEXT) - -#define GLEW_ARB_sparse_texture GLEW_GET_VAR(__GLEW_ARB_sparse_texture) - -#endif /* GL_ARB_sparse_texture */ - -/* ------------------------- GL_ARB_sparse_texture2 ------------------------ */ - -#ifndef GL_ARB_sparse_texture2 -#define GL_ARB_sparse_texture2 1 - -#define GLEW_ARB_sparse_texture2 GLEW_GET_VAR(__GLEW_ARB_sparse_texture2) - -#endif /* GL_ARB_sparse_texture2 */ - -/* ---------------------- GL_ARB_sparse_texture_clamp ---------------------- */ - -#ifndef GL_ARB_sparse_texture_clamp -#define GL_ARB_sparse_texture_clamp 1 - -#define GLEW_ARB_sparse_texture_clamp GLEW_GET_VAR(__GLEW_ARB_sparse_texture_clamp) - -#endif /* GL_ARB_sparse_texture_clamp */ - -/* ------------------------ GL_ARB_stencil_texturing ----------------------- */ - -#ifndef GL_ARB_stencil_texturing -#define GL_ARB_stencil_texturing 1 - -#define GL_DEPTH_STENCIL_TEXTURE_MODE 0x90EA - -#define GLEW_ARB_stencil_texturing GLEW_GET_VAR(__GLEW_ARB_stencil_texturing) - -#endif /* GL_ARB_stencil_texturing */ - -/* ------------------------------ GL_ARB_sync ------------------------------ */ - -#ifndef GL_ARB_sync -#define GL_ARB_sync 1 - -#define GL_SYNC_FLUSH_COMMANDS_BIT 0x00000001 -#define GL_MAX_SERVER_WAIT_TIMEOUT 0x9111 -#define GL_OBJECT_TYPE 0x9112 -#define GL_SYNC_CONDITION 0x9113 -#define GL_SYNC_STATUS 0x9114 -#define GL_SYNC_FLAGS 0x9115 -#define GL_SYNC_FENCE 0x9116 -#define GL_SYNC_GPU_COMMANDS_COMPLETE 0x9117 -#define GL_UNSIGNALED 0x9118 -#define GL_SIGNALED 0x9119 -#define GL_ALREADY_SIGNALED 0x911A -#define GL_TIMEOUT_EXPIRED 0x911B -#define GL_CONDITION_SATISFIED 0x911C -#define GL_WAIT_FAILED 0x911D -#define GL_TIMEOUT_IGNORED 0xFFFFFFFFFFFFFFFFull - -typedef GLenum (GLAPIENTRY * PFNGLCLIENTWAITSYNCPROC) (GLsync GLsync,GLbitfield flags,GLuint64 timeout); -typedef void (GLAPIENTRY * PFNGLDELETESYNCPROC) (GLsync GLsync); -typedef GLsync (GLAPIENTRY * PFNGLFENCESYNCPROC) (GLenum condition,GLbitfield flags); -typedef void (GLAPIENTRY * PFNGLGETINTEGER64VPROC) (GLenum pname, GLint64* params); -typedef void (GLAPIENTRY * PFNGLGETSYNCIVPROC) (GLsync GLsync,GLenum pname,GLsizei bufSize,GLsizei* length, GLint *values); -typedef GLboolean (GLAPIENTRY * PFNGLISSYNCPROC) (GLsync GLsync); -typedef void (GLAPIENTRY * PFNGLWAITSYNCPROC) (GLsync GLsync,GLbitfield flags,GLuint64 timeout); - -#define glClientWaitSync GLEW_GET_FUN(__glewClientWaitSync) -#define glDeleteSync GLEW_GET_FUN(__glewDeleteSync) -#define glFenceSync GLEW_GET_FUN(__glewFenceSync) -#define glGetInteger64v GLEW_GET_FUN(__glewGetInteger64v) -#define glGetSynciv GLEW_GET_FUN(__glewGetSynciv) -#define glIsSync GLEW_GET_FUN(__glewIsSync) -#define glWaitSync GLEW_GET_FUN(__glewWaitSync) - -#define GLEW_ARB_sync GLEW_GET_VAR(__GLEW_ARB_sync) - -#endif /* GL_ARB_sync */ - -/* ----------------------- GL_ARB_tessellation_shader ---------------------- */ - -#ifndef GL_ARB_tessellation_shader -#define GL_ARB_tessellation_shader 1 - -#define GL_PATCHES 0xE -#define GL_UNIFORM_BLOCK_REFERENCED_BY_TESS_CONTROL_SHADER 0x84F0 -#define GL_UNIFORM_BLOCK_REFERENCED_BY_TESS_EVALUATION_SHADER 0x84F1 -#define GL_MAX_TESS_CONTROL_INPUT_COMPONENTS 0x886C -#define GL_MAX_TESS_EVALUATION_INPUT_COMPONENTS 0x886D -#define GL_MAX_COMBINED_TESS_CONTROL_UNIFORM_COMPONENTS 0x8E1E -#define GL_MAX_COMBINED_TESS_EVALUATION_UNIFORM_COMPONENTS 0x8E1F -#define GL_PATCH_VERTICES 0x8E72 -#define GL_PATCH_DEFAULT_INNER_LEVEL 0x8E73 -#define GL_PATCH_DEFAULT_OUTER_LEVEL 0x8E74 -#define GL_TESS_CONTROL_OUTPUT_VERTICES 0x8E75 -#define GL_TESS_GEN_MODE 0x8E76 -#define GL_TESS_GEN_SPACING 0x8E77 -#define GL_TESS_GEN_VERTEX_ORDER 0x8E78 -#define GL_TESS_GEN_POINT_MODE 0x8E79 -#define GL_ISOLINES 0x8E7A -#define GL_FRACTIONAL_ODD 0x8E7B -#define GL_FRACTIONAL_EVEN 0x8E7C -#define GL_MAX_PATCH_VERTICES 0x8E7D -#define GL_MAX_TESS_GEN_LEVEL 0x8E7E -#define GL_MAX_TESS_CONTROL_UNIFORM_COMPONENTS 0x8E7F -#define GL_MAX_TESS_EVALUATION_UNIFORM_COMPONENTS 0x8E80 -#define GL_MAX_TESS_CONTROL_TEXTURE_IMAGE_UNITS 0x8E81 -#define GL_MAX_TESS_EVALUATION_TEXTURE_IMAGE_UNITS 0x8E82 -#define GL_MAX_TESS_CONTROL_OUTPUT_COMPONENTS 0x8E83 -#define GL_MAX_TESS_PATCH_COMPONENTS 0x8E84 -#define GL_MAX_TESS_CONTROL_TOTAL_OUTPUT_COMPONENTS 0x8E85 -#define GL_MAX_TESS_EVALUATION_OUTPUT_COMPONENTS 0x8E86 -#define GL_TESS_EVALUATION_SHADER 0x8E87 -#define GL_TESS_CONTROL_SHADER 0x8E88 -#define GL_MAX_TESS_CONTROL_UNIFORM_BLOCKS 0x8E89 -#define GL_MAX_TESS_EVALUATION_UNIFORM_BLOCKS 0x8E8A - -typedef void (GLAPIENTRY * PFNGLPATCHPARAMETERFVPROC) (GLenum pname, const GLfloat* values); -typedef void (GLAPIENTRY * PFNGLPATCHPARAMETERIPROC) (GLenum pname, GLint value); - -#define glPatchParameterfv GLEW_GET_FUN(__glewPatchParameterfv) -#define glPatchParameteri GLEW_GET_FUN(__glewPatchParameteri) - -#define GLEW_ARB_tessellation_shader GLEW_GET_VAR(__GLEW_ARB_tessellation_shader) - -#endif /* GL_ARB_tessellation_shader */ - -/* ------------------------- GL_ARB_texture_barrier ------------------------ */ - -#ifndef GL_ARB_texture_barrier -#define GL_ARB_texture_barrier 1 - -typedef void (GLAPIENTRY * PFNGLTEXTUREBARRIERPROC) (void); - -#define glTextureBarrier GLEW_GET_FUN(__glewTextureBarrier) - -#define GLEW_ARB_texture_barrier GLEW_GET_VAR(__GLEW_ARB_texture_barrier) - -#endif /* GL_ARB_texture_barrier */ - -/* ---------------------- GL_ARB_texture_border_clamp ---------------------- */ - -#ifndef GL_ARB_texture_border_clamp -#define GL_ARB_texture_border_clamp 1 - -#define GL_CLAMP_TO_BORDER_ARB 0x812D - -#define GLEW_ARB_texture_border_clamp GLEW_GET_VAR(__GLEW_ARB_texture_border_clamp) - -#endif /* GL_ARB_texture_border_clamp */ - -/* ---------------------- GL_ARB_texture_buffer_object --------------------- */ - -#ifndef GL_ARB_texture_buffer_object -#define GL_ARB_texture_buffer_object 1 - -#define GL_TEXTURE_BUFFER_ARB 0x8C2A -#define GL_MAX_TEXTURE_BUFFER_SIZE_ARB 0x8C2B -#define GL_TEXTURE_BINDING_BUFFER_ARB 0x8C2C -#define GL_TEXTURE_BUFFER_DATA_STORE_BINDING_ARB 0x8C2D -#define GL_TEXTURE_BUFFER_FORMAT_ARB 0x8C2E - -typedef void (GLAPIENTRY * PFNGLTEXBUFFERARBPROC) (GLenum target, GLenum internalformat, GLuint buffer); - -#define glTexBufferARB GLEW_GET_FUN(__glewTexBufferARB) - -#define GLEW_ARB_texture_buffer_object GLEW_GET_VAR(__GLEW_ARB_texture_buffer_object) - -#endif /* GL_ARB_texture_buffer_object */ - -/* ------------------- GL_ARB_texture_buffer_object_rgb32 ------------------ */ - -#ifndef GL_ARB_texture_buffer_object_rgb32 -#define GL_ARB_texture_buffer_object_rgb32 1 - -#define GLEW_ARB_texture_buffer_object_rgb32 GLEW_GET_VAR(__GLEW_ARB_texture_buffer_object_rgb32) - -#endif /* GL_ARB_texture_buffer_object_rgb32 */ - -/* ---------------------- GL_ARB_texture_buffer_range ---------------------- */ - -#ifndef GL_ARB_texture_buffer_range -#define GL_ARB_texture_buffer_range 1 - -#define GL_TEXTURE_BUFFER_OFFSET 0x919D -#define GL_TEXTURE_BUFFER_SIZE 0x919E -#define GL_TEXTURE_BUFFER_OFFSET_ALIGNMENT 0x919F - -typedef void (GLAPIENTRY * PFNGLTEXBUFFERRANGEPROC) (GLenum target, GLenum internalformat, GLuint buffer, GLintptr offset, GLsizeiptr size); -typedef void (GLAPIENTRY * PFNGLTEXTUREBUFFERRANGEEXTPROC) (GLuint texture, GLenum target, GLenum internalformat, GLuint buffer, GLintptr offset, GLsizeiptr size); - -#define glTexBufferRange GLEW_GET_FUN(__glewTexBufferRange) -#define glTextureBufferRangeEXT GLEW_GET_FUN(__glewTextureBufferRangeEXT) - -#define GLEW_ARB_texture_buffer_range GLEW_GET_VAR(__GLEW_ARB_texture_buffer_range) - -#endif /* GL_ARB_texture_buffer_range */ - -/* ----------------------- GL_ARB_texture_compression ---------------------- */ - -#ifndef GL_ARB_texture_compression -#define GL_ARB_texture_compression 1 - -#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 - -typedef void (GLAPIENTRY * PFNGLCOMPRESSEDTEXIMAGE1DARBPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLsizei imageSize, const void *data); -typedef void (GLAPIENTRY * PFNGLCOMPRESSEDTEXIMAGE2DARBPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const void *data); -typedef void (GLAPIENTRY * PFNGLCOMPRESSEDTEXIMAGE3DARBPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const void *data); -typedef void (GLAPIENTRY * PFNGLCOMPRESSEDTEXSUBIMAGE1DARBPROC) (GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLsizei imageSize, const void *data); -typedef void (GLAPIENTRY * PFNGLCOMPRESSEDTEXSUBIMAGE2DARBPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const void *data); -typedef void (GLAPIENTRY * PFNGLCOMPRESSEDTEXSUBIMAGE3DARBPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const void *data); -typedef void (GLAPIENTRY * PFNGLGETCOMPRESSEDTEXIMAGEARBPROC) (GLenum target, GLint lod, void *img); - -#define glCompressedTexImage1DARB GLEW_GET_FUN(__glewCompressedTexImage1DARB) -#define glCompressedTexImage2DARB GLEW_GET_FUN(__glewCompressedTexImage2DARB) -#define glCompressedTexImage3DARB GLEW_GET_FUN(__glewCompressedTexImage3DARB) -#define glCompressedTexSubImage1DARB GLEW_GET_FUN(__glewCompressedTexSubImage1DARB) -#define glCompressedTexSubImage2DARB GLEW_GET_FUN(__glewCompressedTexSubImage2DARB) -#define glCompressedTexSubImage3DARB GLEW_GET_FUN(__glewCompressedTexSubImage3DARB) -#define glGetCompressedTexImageARB GLEW_GET_FUN(__glewGetCompressedTexImageARB) - -#define GLEW_ARB_texture_compression GLEW_GET_VAR(__GLEW_ARB_texture_compression) - -#endif /* GL_ARB_texture_compression */ - -/* -------------------- GL_ARB_texture_compression_bptc -------------------- */ - -#ifndef GL_ARB_texture_compression_bptc -#define GL_ARB_texture_compression_bptc 1 - -#define GL_COMPRESSED_RGBA_BPTC_UNORM_ARB 0x8E8C -#define GL_COMPRESSED_SRGB_ALPHA_BPTC_UNORM_ARB 0x8E8D -#define GL_COMPRESSED_RGB_BPTC_SIGNED_FLOAT_ARB 0x8E8E -#define GL_COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_ARB 0x8E8F - -#define GLEW_ARB_texture_compression_bptc GLEW_GET_VAR(__GLEW_ARB_texture_compression_bptc) - -#endif /* GL_ARB_texture_compression_bptc */ - -/* -------------------- GL_ARB_texture_compression_rgtc -------------------- */ - -#ifndef GL_ARB_texture_compression_rgtc -#define GL_ARB_texture_compression_rgtc 1 - -#define GL_COMPRESSED_RED_RGTC1 0x8DBB -#define GL_COMPRESSED_SIGNED_RED_RGTC1 0x8DBC -#define GL_COMPRESSED_RG_RGTC2 0x8DBD -#define GL_COMPRESSED_SIGNED_RG_RGTC2 0x8DBE - -#define GLEW_ARB_texture_compression_rgtc GLEW_GET_VAR(__GLEW_ARB_texture_compression_rgtc) - -#endif /* GL_ARB_texture_compression_rgtc */ - -/* ------------------------ GL_ARB_texture_cube_map ------------------------ */ - -#ifndef GL_ARB_texture_cube_map -#define GL_ARB_texture_cube_map 1 - -#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 - -#define GLEW_ARB_texture_cube_map GLEW_GET_VAR(__GLEW_ARB_texture_cube_map) - -#endif /* GL_ARB_texture_cube_map */ - -/* --------------------- GL_ARB_texture_cube_map_array --------------------- */ - -#ifndef GL_ARB_texture_cube_map_array -#define GL_ARB_texture_cube_map_array 1 - -#define GL_TEXTURE_CUBE_MAP_ARRAY_ARB 0x9009 -#define GL_TEXTURE_BINDING_CUBE_MAP_ARRAY_ARB 0x900A -#define GL_PROXY_TEXTURE_CUBE_MAP_ARRAY_ARB 0x900B -#define GL_SAMPLER_CUBE_MAP_ARRAY_ARB 0x900C -#define GL_SAMPLER_CUBE_MAP_ARRAY_SHADOW_ARB 0x900D -#define GL_INT_SAMPLER_CUBE_MAP_ARRAY_ARB 0x900E -#define GL_UNSIGNED_INT_SAMPLER_CUBE_MAP_ARRAY_ARB 0x900F - -#define GLEW_ARB_texture_cube_map_array GLEW_GET_VAR(__GLEW_ARB_texture_cube_map_array) - -#endif /* GL_ARB_texture_cube_map_array */ - -/* ------------------------- GL_ARB_texture_env_add ------------------------ */ - -#ifndef GL_ARB_texture_env_add -#define GL_ARB_texture_env_add 1 - -#define GLEW_ARB_texture_env_add GLEW_GET_VAR(__GLEW_ARB_texture_env_add) - -#endif /* GL_ARB_texture_env_add */ - -/* ----------------------- GL_ARB_texture_env_combine ---------------------- */ - -#ifndef GL_ARB_texture_env_combine -#define GL_ARB_texture_env_combine 1 - -#define GL_SUBTRACT_ARB 0x84E7 -#define GL_COMBINE_ARB 0x8570 -#define GL_COMBINE_RGB_ARB 0x8571 -#define GL_COMBINE_ALPHA_ARB 0x8572 -#define GL_RGB_SCALE_ARB 0x8573 -#define GL_ADD_SIGNED_ARB 0x8574 -#define GL_INTERPOLATE_ARB 0x8575 -#define GL_CONSTANT_ARB 0x8576 -#define GL_PRIMARY_COLOR_ARB 0x8577 -#define GL_PREVIOUS_ARB 0x8578 -#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 GLEW_ARB_texture_env_combine GLEW_GET_VAR(__GLEW_ARB_texture_env_combine) - -#endif /* GL_ARB_texture_env_combine */ - -/* ---------------------- GL_ARB_texture_env_crossbar ---------------------- */ - -#ifndef GL_ARB_texture_env_crossbar -#define GL_ARB_texture_env_crossbar 1 - -#define GLEW_ARB_texture_env_crossbar GLEW_GET_VAR(__GLEW_ARB_texture_env_crossbar) - -#endif /* GL_ARB_texture_env_crossbar */ - -/* ------------------------ GL_ARB_texture_env_dot3 ------------------------ */ - -#ifndef GL_ARB_texture_env_dot3 -#define GL_ARB_texture_env_dot3 1 - -#define GL_DOT3_RGB_ARB 0x86AE -#define GL_DOT3_RGBA_ARB 0x86AF - -#define GLEW_ARB_texture_env_dot3 GLEW_GET_VAR(__GLEW_ARB_texture_env_dot3) - -#endif /* GL_ARB_texture_env_dot3 */ - -/* ---------------------- GL_ARB_texture_filter_minmax --------------------- */ - -#ifndef GL_ARB_texture_filter_minmax -#define GL_ARB_texture_filter_minmax 1 - -#define GL_TEXTURE_REDUCTION_MODE_ARB 0x9366 -#define GL_WEIGHTED_AVERAGE_ARB 0x9367 - -#define GLEW_ARB_texture_filter_minmax GLEW_GET_VAR(__GLEW_ARB_texture_filter_minmax) - -#endif /* GL_ARB_texture_filter_minmax */ - -/* -------------------------- GL_ARB_texture_float ------------------------- */ - -#ifndef GL_ARB_texture_float -#define GL_ARB_texture_float 1 - -#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 -#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 GLEW_ARB_texture_float GLEW_GET_VAR(__GLEW_ARB_texture_float) - -#endif /* GL_ARB_texture_float */ - -/* ------------------------- GL_ARB_texture_gather ------------------------- */ - -#ifndef GL_ARB_texture_gather -#define GL_ARB_texture_gather 1 - -#define GL_MIN_PROGRAM_TEXTURE_GATHER_OFFSET_ARB 0x8E5E -#define GL_MAX_PROGRAM_TEXTURE_GATHER_OFFSET_ARB 0x8E5F -#define GL_MAX_PROGRAM_TEXTURE_GATHER_COMPONENTS_ARB 0x8F9F - -#define GLEW_ARB_texture_gather GLEW_GET_VAR(__GLEW_ARB_texture_gather) - -#endif /* GL_ARB_texture_gather */ - -/* ------------------ GL_ARB_texture_mirror_clamp_to_edge ------------------ */ - -#ifndef GL_ARB_texture_mirror_clamp_to_edge -#define GL_ARB_texture_mirror_clamp_to_edge 1 - -#define GL_MIRROR_CLAMP_TO_EDGE 0x8743 - -#define GLEW_ARB_texture_mirror_clamp_to_edge GLEW_GET_VAR(__GLEW_ARB_texture_mirror_clamp_to_edge) - -#endif /* GL_ARB_texture_mirror_clamp_to_edge */ - -/* --------------------- GL_ARB_texture_mirrored_repeat -------------------- */ - -#ifndef GL_ARB_texture_mirrored_repeat -#define GL_ARB_texture_mirrored_repeat 1 - -#define GL_MIRRORED_REPEAT_ARB 0x8370 - -#define GLEW_ARB_texture_mirrored_repeat GLEW_GET_VAR(__GLEW_ARB_texture_mirrored_repeat) - -#endif /* GL_ARB_texture_mirrored_repeat */ - -/* ----------------------- GL_ARB_texture_multisample ---------------------- */ - -#ifndef GL_ARB_texture_multisample -#define GL_ARB_texture_multisample 1 - -#define GL_SAMPLE_POSITION 0x8E50 -#define GL_SAMPLE_MASK 0x8E51 -#define GL_SAMPLE_MASK_VALUE 0x8E52 -#define GL_MAX_SAMPLE_MASK_WORDS 0x8E59 -#define GL_TEXTURE_2D_MULTISAMPLE 0x9100 -#define GL_PROXY_TEXTURE_2D_MULTISAMPLE 0x9101 -#define GL_TEXTURE_2D_MULTISAMPLE_ARRAY 0x9102 -#define GL_PROXY_TEXTURE_2D_MULTISAMPLE_ARRAY 0x9103 -#define GL_TEXTURE_BINDING_2D_MULTISAMPLE 0x9104 -#define GL_TEXTURE_BINDING_2D_MULTISAMPLE_ARRAY 0x9105 -#define GL_TEXTURE_SAMPLES 0x9106 -#define GL_TEXTURE_FIXED_SAMPLE_LOCATIONS 0x9107 -#define GL_SAMPLER_2D_MULTISAMPLE 0x9108 -#define GL_INT_SAMPLER_2D_MULTISAMPLE 0x9109 -#define GL_UNSIGNED_INT_SAMPLER_2D_MULTISAMPLE 0x910A -#define GL_SAMPLER_2D_MULTISAMPLE_ARRAY 0x910B -#define GL_INT_SAMPLER_2D_MULTISAMPLE_ARRAY 0x910C -#define GL_UNSIGNED_INT_SAMPLER_2D_MULTISAMPLE_ARRAY 0x910D -#define GL_MAX_COLOR_TEXTURE_SAMPLES 0x910E -#define GL_MAX_DEPTH_TEXTURE_SAMPLES 0x910F -#define GL_MAX_INTEGER_SAMPLES 0x9110 - -typedef void (GLAPIENTRY * PFNGLGETMULTISAMPLEFVPROC) (GLenum pname, GLuint index, GLfloat* val); -typedef void (GLAPIENTRY * PFNGLSAMPLEMASKIPROC) (GLuint index, GLbitfield mask); -typedef void (GLAPIENTRY * PFNGLTEXIMAGE2DMULTISAMPLEPROC) (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLboolean fixedsamplelocations); -typedef void (GLAPIENTRY * PFNGLTEXIMAGE3DMULTISAMPLEPROC) (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedsamplelocations); - -#define glGetMultisamplefv GLEW_GET_FUN(__glewGetMultisamplefv) -#define glSampleMaski GLEW_GET_FUN(__glewSampleMaski) -#define glTexImage2DMultisample GLEW_GET_FUN(__glewTexImage2DMultisample) -#define glTexImage3DMultisample GLEW_GET_FUN(__glewTexImage3DMultisample) - -#define GLEW_ARB_texture_multisample GLEW_GET_VAR(__GLEW_ARB_texture_multisample) - -#endif /* GL_ARB_texture_multisample */ - -/* -------------------- GL_ARB_texture_non_power_of_two -------------------- */ - -#ifndef GL_ARB_texture_non_power_of_two -#define GL_ARB_texture_non_power_of_two 1 - -#define GLEW_ARB_texture_non_power_of_two GLEW_GET_VAR(__GLEW_ARB_texture_non_power_of_two) - -#endif /* GL_ARB_texture_non_power_of_two */ - -/* ---------------------- GL_ARB_texture_query_levels ---------------------- */ - -#ifndef GL_ARB_texture_query_levels -#define GL_ARB_texture_query_levels 1 - -#define GLEW_ARB_texture_query_levels GLEW_GET_VAR(__GLEW_ARB_texture_query_levels) - -#endif /* GL_ARB_texture_query_levels */ - -/* ------------------------ GL_ARB_texture_query_lod ----------------------- */ - -#ifndef GL_ARB_texture_query_lod -#define GL_ARB_texture_query_lod 1 - -#define GLEW_ARB_texture_query_lod GLEW_GET_VAR(__GLEW_ARB_texture_query_lod) - -#endif /* GL_ARB_texture_query_lod */ - -/* ------------------------ GL_ARB_texture_rectangle ----------------------- */ - -#ifndef GL_ARB_texture_rectangle -#define GL_ARB_texture_rectangle 1 - -#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 -#define GL_SAMPLER_2D_RECT_ARB 0x8B63 -#define GL_SAMPLER_2D_RECT_SHADOW_ARB 0x8B64 - -#define GLEW_ARB_texture_rectangle GLEW_GET_VAR(__GLEW_ARB_texture_rectangle) - -#endif /* GL_ARB_texture_rectangle */ - -/* --------------------------- GL_ARB_texture_rg --------------------------- */ - -#ifndef GL_ARB_texture_rg -#define GL_ARB_texture_rg 1 - -#define GL_COMPRESSED_RED 0x8225 -#define GL_COMPRESSED_RG 0x8226 -#define GL_RG 0x8227 -#define GL_RG_INTEGER 0x8228 -#define GL_R8 0x8229 -#define GL_R16 0x822A -#define GL_RG8 0x822B -#define GL_RG16 0x822C -#define GL_R16F 0x822D -#define GL_R32F 0x822E -#define GL_RG16F 0x822F -#define GL_RG32F 0x8230 -#define GL_R8I 0x8231 -#define GL_R8UI 0x8232 -#define GL_R16I 0x8233 -#define GL_R16UI 0x8234 -#define GL_R32I 0x8235 -#define GL_R32UI 0x8236 -#define GL_RG8I 0x8237 -#define GL_RG8UI 0x8238 -#define GL_RG16I 0x8239 -#define GL_RG16UI 0x823A -#define GL_RG32I 0x823B -#define GL_RG32UI 0x823C - -#define GLEW_ARB_texture_rg GLEW_GET_VAR(__GLEW_ARB_texture_rg) - -#endif /* GL_ARB_texture_rg */ - -/* ----------------------- GL_ARB_texture_rgb10_a2ui ----------------------- */ - -#ifndef GL_ARB_texture_rgb10_a2ui -#define GL_ARB_texture_rgb10_a2ui 1 - -#define GL_RGB10_A2UI 0x906F - -#define GLEW_ARB_texture_rgb10_a2ui GLEW_GET_VAR(__GLEW_ARB_texture_rgb10_a2ui) - -#endif /* GL_ARB_texture_rgb10_a2ui */ - -/* ------------------------ GL_ARB_texture_stencil8 ------------------------ */ - -#ifndef GL_ARB_texture_stencil8 -#define GL_ARB_texture_stencil8 1 - -#define GL_STENCIL_INDEX 0x1901 -#define GL_STENCIL_INDEX8 0x8D48 - -#define GLEW_ARB_texture_stencil8 GLEW_GET_VAR(__GLEW_ARB_texture_stencil8) - -#endif /* GL_ARB_texture_stencil8 */ - -/* ------------------------- GL_ARB_texture_storage ------------------------ */ - -#ifndef GL_ARB_texture_storage -#define GL_ARB_texture_storage 1 - -#define GL_TEXTURE_IMMUTABLE_FORMAT 0x912F - -typedef void (GLAPIENTRY * PFNGLTEXSTORAGE1DPROC) (GLenum target, GLsizei levels, GLenum internalformat, GLsizei width); -typedef void (GLAPIENTRY * PFNGLTEXSTORAGE2DPROC) (GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height); -typedef void (GLAPIENTRY * PFNGLTEXSTORAGE3DPROC) (GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth); -typedef void (GLAPIENTRY * PFNGLTEXTURESTORAGE1DEXTPROC) (GLuint texture, GLenum target, GLsizei levels, GLenum internalformat, GLsizei width); -typedef void (GLAPIENTRY * PFNGLTEXTURESTORAGE2DEXTPROC) (GLuint texture, GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height); -typedef void (GLAPIENTRY * PFNGLTEXTURESTORAGE3DEXTPROC) (GLuint texture, GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth); - -#define glTexStorage1D GLEW_GET_FUN(__glewTexStorage1D) -#define glTexStorage2D GLEW_GET_FUN(__glewTexStorage2D) -#define glTexStorage3D GLEW_GET_FUN(__glewTexStorage3D) -#define glTextureStorage1DEXT GLEW_GET_FUN(__glewTextureStorage1DEXT) -#define glTextureStorage2DEXT GLEW_GET_FUN(__glewTextureStorage2DEXT) -#define glTextureStorage3DEXT GLEW_GET_FUN(__glewTextureStorage3DEXT) - -#define GLEW_ARB_texture_storage GLEW_GET_VAR(__GLEW_ARB_texture_storage) - -#endif /* GL_ARB_texture_storage */ - -/* ------------------- GL_ARB_texture_storage_multisample ------------------ */ - -#ifndef GL_ARB_texture_storage_multisample -#define GL_ARB_texture_storage_multisample 1 - -typedef void (GLAPIENTRY * PFNGLTEXSTORAGE2DMULTISAMPLEPROC) (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLboolean fixedsamplelocations); -typedef void (GLAPIENTRY * PFNGLTEXSTORAGE3DMULTISAMPLEPROC) (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedsamplelocations); -typedef void (GLAPIENTRY * PFNGLTEXTURESTORAGE2DMULTISAMPLEEXTPROC) (GLuint texture, GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLboolean fixedsamplelocations); -typedef void (GLAPIENTRY * PFNGLTEXTURESTORAGE3DMULTISAMPLEEXTPROC) (GLuint texture, GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedsamplelocations); - -#define glTexStorage2DMultisample GLEW_GET_FUN(__glewTexStorage2DMultisample) -#define glTexStorage3DMultisample GLEW_GET_FUN(__glewTexStorage3DMultisample) -#define glTextureStorage2DMultisampleEXT GLEW_GET_FUN(__glewTextureStorage2DMultisampleEXT) -#define glTextureStorage3DMultisampleEXT GLEW_GET_FUN(__glewTextureStorage3DMultisampleEXT) - -#define GLEW_ARB_texture_storage_multisample GLEW_GET_VAR(__GLEW_ARB_texture_storage_multisample) - -#endif /* GL_ARB_texture_storage_multisample */ - -/* ------------------------- GL_ARB_texture_swizzle ------------------------ */ - -#ifndef GL_ARB_texture_swizzle -#define GL_ARB_texture_swizzle 1 - -#define GL_TEXTURE_SWIZZLE_R 0x8E42 -#define GL_TEXTURE_SWIZZLE_G 0x8E43 -#define GL_TEXTURE_SWIZZLE_B 0x8E44 -#define GL_TEXTURE_SWIZZLE_A 0x8E45 -#define GL_TEXTURE_SWIZZLE_RGBA 0x8E46 - -#define GLEW_ARB_texture_swizzle GLEW_GET_VAR(__GLEW_ARB_texture_swizzle) - -#endif /* GL_ARB_texture_swizzle */ - -/* -------------------------- GL_ARB_texture_view -------------------------- */ - -#ifndef GL_ARB_texture_view -#define GL_ARB_texture_view 1 - -#define GL_TEXTURE_VIEW_MIN_LEVEL 0x82DB -#define GL_TEXTURE_VIEW_NUM_LEVELS 0x82DC -#define GL_TEXTURE_VIEW_MIN_LAYER 0x82DD -#define GL_TEXTURE_VIEW_NUM_LAYERS 0x82DE -#define GL_TEXTURE_IMMUTABLE_LEVELS 0x82DF - -typedef void (GLAPIENTRY * PFNGLTEXTUREVIEWPROC) (GLuint texture, GLenum target, GLuint origtexture, GLenum internalformat, GLuint minlevel, GLuint numlevels, GLuint minlayer, GLuint numlayers); - -#define glTextureView GLEW_GET_FUN(__glewTextureView) - -#define GLEW_ARB_texture_view GLEW_GET_VAR(__GLEW_ARB_texture_view) - -#endif /* GL_ARB_texture_view */ - -/* --------------------------- GL_ARB_timer_query -------------------------- */ - -#ifndef GL_ARB_timer_query -#define GL_ARB_timer_query 1 - -#define GL_TIME_ELAPSED 0x88BF -#define GL_TIMESTAMP 0x8E28 - -typedef void (GLAPIENTRY * PFNGLGETQUERYOBJECTI64VPROC) (GLuint id, GLenum pname, GLint64* params); -typedef void (GLAPIENTRY * PFNGLGETQUERYOBJECTUI64VPROC) (GLuint id, GLenum pname, GLuint64* params); -typedef void (GLAPIENTRY * PFNGLQUERYCOUNTERPROC) (GLuint id, GLenum target); - -#define glGetQueryObjecti64v GLEW_GET_FUN(__glewGetQueryObjecti64v) -#define glGetQueryObjectui64v GLEW_GET_FUN(__glewGetQueryObjectui64v) -#define glQueryCounter GLEW_GET_FUN(__glewQueryCounter) - -#define GLEW_ARB_timer_query GLEW_GET_VAR(__GLEW_ARB_timer_query) - -#endif /* GL_ARB_timer_query */ - -/* ----------------------- GL_ARB_transform_feedback2 ---------------------- */ - -#ifndef GL_ARB_transform_feedback2 -#define GL_ARB_transform_feedback2 1 - -#define GL_TRANSFORM_FEEDBACK 0x8E22 -#define GL_TRANSFORM_FEEDBACK_BUFFER_PAUSED 0x8E23 -#define GL_TRANSFORM_FEEDBACK_BUFFER_ACTIVE 0x8E24 -#define GL_TRANSFORM_FEEDBACK_BINDING 0x8E25 - -typedef void (GLAPIENTRY * PFNGLBINDTRANSFORMFEEDBACKPROC) (GLenum target, GLuint id); -typedef void (GLAPIENTRY * PFNGLDELETETRANSFORMFEEDBACKSPROC) (GLsizei n, const GLuint* ids); -typedef void (GLAPIENTRY * PFNGLDRAWTRANSFORMFEEDBACKPROC) (GLenum mode, GLuint id); -typedef void (GLAPIENTRY * PFNGLGENTRANSFORMFEEDBACKSPROC) (GLsizei n, GLuint* ids); -typedef GLboolean (GLAPIENTRY * PFNGLISTRANSFORMFEEDBACKPROC) (GLuint id); -typedef void (GLAPIENTRY * PFNGLPAUSETRANSFORMFEEDBACKPROC) (void); -typedef void (GLAPIENTRY * PFNGLRESUMETRANSFORMFEEDBACKPROC) (void); - -#define glBindTransformFeedback GLEW_GET_FUN(__glewBindTransformFeedback) -#define glDeleteTransformFeedbacks GLEW_GET_FUN(__glewDeleteTransformFeedbacks) -#define glDrawTransformFeedback GLEW_GET_FUN(__glewDrawTransformFeedback) -#define glGenTransformFeedbacks GLEW_GET_FUN(__glewGenTransformFeedbacks) -#define glIsTransformFeedback GLEW_GET_FUN(__glewIsTransformFeedback) -#define glPauseTransformFeedback GLEW_GET_FUN(__glewPauseTransformFeedback) -#define glResumeTransformFeedback GLEW_GET_FUN(__glewResumeTransformFeedback) - -#define GLEW_ARB_transform_feedback2 GLEW_GET_VAR(__GLEW_ARB_transform_feedback2) - -#endif /* GL_ARB_transform_feedback2 */ - -/* ----------------------- GL_ARB_transform_feedback3 ---------------------- */ - -#ifndef GL_ARB_transform_feedback3 -#define GL_ARB_transform_feedback3 1 - -#define GL_MAX_TRANSFORM_FEEDBACK_BUFFERS 0x8E70 -#define GL_MAX_VERTEX_STREAMS 0x8E71 - -typedef void (GLAPIENTRY * PFNGLBEGINQUERYINDEXEDPROC) (GLenum target, GLuint index, GLuint id); -typedef void (GLAPIENTRY * PFNGLDRAWTRANSFORMFEEDBACKSTREAMPROC) (GLenum mode, GLuint id, GLuint stream); -typedef void (GLAPIENTRY * PFNGLENDQUERYINDEXEDPROC) (GLenum target, GLuint index); -typedef void (GLAPIENTRY * PFNGLGETQUERYINDEXEDIVPROC) (GLenum target, GLuint index, GLenum pname, GLint* params); - -#define glBeginQueryIndexed GLEW_GET_FUN(__glewBeginQueryIndexed) -#define glDrawTransformFeedbackStream GLEW_GET_FUN(__glewDrawTransformFeedbackStream) -#define glEndQueryIndexed GLEW_GET_FUN(__glewEndQueryIndexed) -#define glGetQueryIndexediv GLEW_GET_FUN(__glewGetQueryIndexediv) - -#define GLEW_ARB_transform_feedback3 GLEW_GET_VAR(__GLEW_ARB_transform_feedback3) - -#endif /* GL_ARB_transform_feedback3 */ - -/* ------------------ GL_ARB_transform_feedback_instanced ------------------ */ - -#ifndef GL_ARB_transform_feedback_instanced -#define GL_ARB_transform_feedback_instanced 1 - -typedef void (GLAPIENTRY * PFNGLDRAWTRANSFORMFEEDBACKINSTANCEDPROC) (GLenum mode, GLuint id, GLsizei primcount); -typedef void (GLAPIENTRY * PFNGLDRAWTRANSFORMFEEDBACKSTREAMINSTANCEDPROC) (GLenum mode, GLuint id, GLuint stream, GLsizei primcount); - -#define glDrawTransformFeedbackInstanced GLEW_GET_FUN(__glewDrawTransformFeedbackInstanced) -#define glDrawTransformFeedbackStreamInstanced GLEW_GET_FUN(__glewDrawTransformFeedbackStreamInstanced) - -#define GLEW_ARB_transform_feedback_instanced GLEW_GET_VAR(__GLEW_ARB_transform_feedback_instanced) - -#endif /* GL_ARB_transform_feedback_instanced */ - -/* ---------------- GL_ARB_transform_feedback_overflow_query --------------- */ - -#ifndef GL_ARB_transform_feedback_overflow_query -#define GL_ARB_transform_feedback_overflow_query 1 - -#define GL_TRANSFORM_FEEDBACK_OVERFLOW_ARB 0x82EC -#define GL_TRANSFORM_FEEDBACK_STREAM_OVERFLOW_ARB 0x82ED - -#define GLEW_ARB_transform_feedback_overflow_query GLEW_GET_VAR(__GLEW_ARB_transform_feedback_overflow_query) - -#endif /* GL_ARB_transform_feedback_overflow_query */ - -/* ------------------------ GL_ARB_transpose_matrix ------------------------ */ - -#ifndef GL_ARB_transpose_matrix -#define GL_ARB_transpose_matrix 1 - -#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 - -typedef void (GLAPIENTRY * PFNGLLOADTRANSPOSEMATRIXDARBPROC) (GLdouble m[16]); -typedef void (GLAPIENTRY * PFNGLLOADTRANSPOSEMATRIXFARBPROC) (GLfloat m[16]); -typedef void (GLAPIENTRY * PFNGLMULTTRANSPOSEMATRIXDARBPROC) (GLdouble m[16]); -typedef void (GLAPIENTRY * PFNGLMULTTRANSPOSEMATRIXFARBPROC) (GLfloat m[16]); - -#define glLoadTransposeMatrixdARB GLEW_GET_FUN(__glewLoadTransposeMatrixdARB) -#define glLoadTransposeMatrixfARB GLEW_GET_FUN(__glewLoadTransposeMatrixfARB) -#define glMultTransposeMatrixdARB GLEW_GET_FUN(__glewMultTransposeMatrixdARB) -#define glMultTransposeMatrixfARB GLEW_GET_FUN(__glewMultTransposeMatrixfARB) - -#define GLEW_ARB_transpose_matrix GLEW_GET_VAR(__GLEW_ARB_transpose_matrix) - -#endif /* GL_ARB_transpose_matrix */ - -/* ---------------------- GL_ARB_uniform_buffer_object --------------------- */ - -#ifndef GL_ARB_uniform_buffer_object -#define GL_ARB_uniform_buffer_object 1 - -#define GL_UNIFORM_BUFFER 0x8A11 -#define GL_UNIFORM_BUFFER_BINDING 0x8A28 -#define GL_UNIFORM_BUFFER_START 0x8A29 -#define GL_UNIFORM_BUFFER_SIZE 0x8A2A -#define GL_MAX_VERTEX_UNIFORM_BLOCKS 0x8A2B -#define GL_MAX_GEOMETRY_UNIFORM_BLOCKS 0x8A2C -#define GL_MAX_FRAGMENT_UNIFORM_BLOCKS 0x8A2D -#define GL_MAX_COMBINED_UNIFORM_BLOCKS 0x8A2E -#define GL_MAX_UNIFORM_BUFFER_BINDINGS 0x8A2F -#define GL_MAX_UNIFORM_BLOCK_SIZE 0x8A30 -#define GL_MAX_COMBINED_VERTEX_UNIFORM_COMPONENTS 0x8A31 -#define GL_MAX_COMBINED_GEOMETRY_UNIFORM_COMPONENTS 0x8A32 -#define GL_MAX_COMBINED_FRAGMENT_UNIFORM_COMPONENTS 0x8A33 -#define GL_UNIFORM_BUFFER_OFFSET_ALIGNMENT 0x8A34 -#define GL_ACTIVE_UNIFORM_BLOCK_MAX_NAME_LENGTH 0x8A35 -#define GL_ACTIVE_UNIFORM_BLOCKS 0x8A36 -#define GL_UNIFORM_TYPE 0x8A37 -#define GL_UNIFORM_SIZE 0x8A38 -#define GL_UNIFORM_NAME_LENGTH 0x8A39 -#define GL_UNIFORM_BLOCK_INDEX 0x8A3A -#define GL_UNIFORM_OFFSET 0x8A3B -#define GL_UNIFORM_ARRAY_STRIDE 0x8A3C -#define GL_UNIFORM_MATRIX_STRIDE 0x8A3D -#define GL_UNIFORM_IS_ROW_MAJOR 0x8A3E -#define GL_UNIFORM_BLOCK_BINDING 0x8A3F -#define GL_UNIFORM_BLOCK_DATA_SIZE 0x8A40 -#define GL_UNIFORM_BLOCK_NAME_LENGTH 0x8A41 -#define GL_UNIFORM_BLOCK_ACTIVE_UNIFORMS 0x8A42 -#define GL_UNIFORM_BLOCK_ACTIVE_UNIFORM_INDICES 0x8A43 -#define GL_UNIFORM_BLOCK_REFERENCED_BY_VERTEX_SHADER 0x8A44 -#define GL_UNIFORM_BLOCK_REFERENCED_BY_GEOMETRY_SHADER 0x8A45 -#define GL_UNIFORM_BLOCK_REFERENCED_BY_FRAGMENT_SHADER 0x8A46 -#define GL_INVALID_INDEX 0xFFFFFFFFu - -typedef void (GLAPIENTRY * PFNGLBINDBUFFERBASEPROC) (GLenum target, GLuint index, GLuint buffer); -typedef void (GLAPIENTRY * PFNGLBINDBUFFERRANGEPROC) (GLenum target, GLuint index, GLuint buffer, GLintptr offset, GLsizeiptr size); -typedef void (GLAPIENTRY * PFNGLGETACTIVEUNIFORMBLOCKNAMEPROC) (GLuint program, GLuint uniformBlockIndex, GLsizei bufSize, GLsizei* length, GLchar* uniformBlockName); -typedef void (GLAPIENTRY * PFNGLGETACTIVEUNIFORMBLOCKIVPROC) (GLuint program, GLuint uniformBlockIndex, GLenum pname, GLint* params); -typedef void (GLAPIENTRY * PFNGLGETACTIVEUNIFORMNAMEPROC) (GLuint program, GLuint uniformIndex, GLsizei bufSize, GLsizei* length, GLchar* uniformName); -typedef void (GLAPIENTRY * PFNGLGETACTIVEUNIFORMSIVPROC) (GLuint program, GLsizei uniformCount, const GLuint* uniformIndices, GLenum pname, GLint* params); -typedef void (GLAPIENTRY * PFNGLGETINTEGERI_VPROC) (GLenum target, GLuint index, GLint* data); -typedef GLuint (GLAPIENTRY * PFNGLGETUNIFORMBLOCKINDEXPROC) (GLuint program, const GLchar* uniformBlockName); -typedef void (GLAPIENTRY * PFNGLGETUNIFORMINDICESPROC) (GLuint program, GLsizei uniformCount, const GLchar* const * uniformNames, GLuint* uniformIndices); -typedef void (GLAPIENTRY * PFNGLUNIFORMBLOCKBINDINGPROC) (GLuint program, GLuint uniformBlockIndex, GLuint uniformBlockBinding); - -#define glBindBufferBase GLEW_GET_FUN(__glewBindBufferBase) -#define glBindBufferRange GLEW_GET_FUN(__glewBindBufferRange) -#define glGetActiveUniformBlockName GLEW_GET_FUN(__glewGetActiveUniformBlockName) -#define glGetActiveUniformBlockiv GLEW_GET_FUN(__glewGetActiveUniformBlockiv) -#define glGetActiveUniformName GLEW_GET_FUN(__glewGetActiveUniformName) -#define glGetActiveUniformsiv GLEW_GET_FUN(__glewGetActiveUniformsiv) -#define glGetIntegeri_v GLEW_GET_FUN(__glewGetIntegeri_v) -#define glGetUniformBlockIndex GLEW_GET_FUN(__glewGetUniformBlockIndex) -#define glGetUniformIndices GLEW_GET_FUN(__glewGetUniformIndices) -#define glUniformBlockBinding GLEW_GET_FUN(__glewUniformBlockBinding) - -#define GLEW_ARB_uniform_buffer_object GLEW_GET_VAR(__GLEW_ARB_uniform_buffer_object) - -#endif /* GL_ARB_uniform_buffer_object */ - -/* ------------------------ GL_ARB_vertex_array_bgra ----------------------- */ - -#ifndef GL_ARB_vertex_array_bgra -#define GL_ARB_vertex_array_bgra 1 - -#define GL_BGRA 0x80E1 - -#define GLEW_ARB_vertex_array_bgra GLEW_GET_VAR(__GLEW_ARB_vertex_array_bgra) - -#endif /* GL_ARB_vertex_array_bgra */ - -/* ----------------------- GL_ARB_vertex_array_object ---------------------- */ - -#ifndef GL_ARB_vertex_array_object -#define GL_ARB_vertex_array_object 1 - -#define GL_VERTEX_ARRAY_BINDING 0x85B5 - -typedef void (GLAPIENTRY * PFNGLBINDVERTEXARRAYPROC) (GLuint array); -typedef void (GLAPIENTRY * PFNGLDELETEVERTEXARRAYSPROC) (GLsizei n, const GLuint* arrays); -typedef void (GLAPIENTRY * PFNGLGENVERTEXARRAYSPROC) (GLsizei n, GLuint* arrays); -typedef GLboolean (GLAPIENTRY * PFNGLISVERTEXARRAYPROC) (GLuint array); - -#define glBindVertexArray GLEW_GET_FUN(__glewBindVertexArray) -#define glDeleteVertexArrays GLEW_GET_FUN(__glewDeleteVertexArrays) -#define glGenVertexArrays GLEW_GET_FUN(__glewGenVertexArrays) -#define glIsVertexArray GLEW_GET_FUN(__glewIsVertexArray) - -#define GLEW_ARB_vertex_array_object GLEW_GET_VAR(__GLEW_ARB_vertex_array_object) - -#endif /* GL_ARB_vertex_array_object */ - -/* ----------------------- GL_ARB_vertex_attrib_64bit ---------------------- */ - -#ifndef GL_ARB_vertex_attrib_64bit -#define GL_ARB_vertex_attrib_64bit 1 - -typedef void (GLAPIENTRY * PFNGLGETVERTEXATTRIBLDVPROC) (GLuint index, GLenum pname, GLdouble* params); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBL1DPROC) (GLuint index, GLdouble x); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBL1DVPROC) (GLuint index, const GLdouble* v); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBL2DPROC) (GLuint index, GLdouble x, GLdouble y); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBL2DVPROC) (GLuint index, const GLdouble* v); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBL3DPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBL3DVPROC) (GLuint index, const GLdouble* v); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBL4DPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBL4DVPROC) (GLuint index, const GLdouble* v); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBLPOINTERPROC) (GLuint index, GLint size, GLenum type, GLsizei stride, const void* pointer); - -#define glGetVertexAttribLdv GLEW_GET_FUN(__glewGetVertexAttribLdv) -#define glVertexAttribL1d GLEW_GET_FUN(__glewVertexAttribL1d) -#define glVertexAttribL1dv GLEW_GET_FUN(__glewVertexAttribL1dv) -#define glVertexAttribL2d GLEW_GET_FUN(__glewVertexAttribL2d) -#define glVertexAttribL2dv GLEW_GET_FUN(__glewVertexAttribL2dv) -#define glVertexAttribL3d GLEW_GET_FUN(__glewVertexAttribL3d) -#define glVertexAttribL3dv GLEW_GET_FUN(__glewVertexAttribL3dv) -#define glVertexAttribL4d GLEW_GET_FUN(__glewVertexAttribL4d) -#define glVertexAttribL4dv GLEW_GET_FUN(__glewVertexAttribL4dv) -#define glVertexAttribLPointer GLEW_GET_FUN(__glewVertexAttribLPointer) - -#define GLEW_ARB_vertex_attrib_64bit GLEW_GET_VAR(__GLEW_ARB_vertex_attrib_64bit) - -#endif /* GL_ARB_vertex_attrib_64bit */ - -/* ---------------------- GL_ARB_vertex_attrib_binding --------------------- */ - -#ifndef GL_ARB_vertex_attrib_binding -#define GL_ARB_vertex_attrib_binding 1 - -#define GL_VERTEX_ATTRIB_BINDING 0x82D4 -#define GL_VERTEX_ATTRIB_RELATIVE_OFFSET 0x82D5 -#define GL_VERTEX_BINDING_DIVISOR 0x82D6 -#define GL_VERTEX_BINDING_OFFSET 0x82D7 -#define GL_VERTEX_BINDING_STRIDE 0x82D8 -#define GL_MAX_VERTEX_ATTRIB_RELATIVE_OFFSET 0x82D9 -#define GL_MAX_VERTEX_ATTRIB_BINDINGS 0x82DA -#define GL_VERTEX_BINDING_BUFFER 0x8F4F - -typedef void (GLAPIENTRY * PFNGLBINDVERTEXBUFFERPROC) (GLuint bindingindex, GLuint buffer, GLintptr offset, GLsizei stride); -typedef void (GLAPIENTRY * PFNGLVERTEXARRAYBINDVERTEXBUFFEREXTPROC) (GLuint vaobj, GLuint bindingindex, GLuint buffer, GLintptr offset, GLsizei stride); -typedef void (GLAPIENTRY * PFNGLVERTEXARRAYVERTEXATTRIBBINDINGEXTPROC) (GLuint vaobj, GLuint attribindex, GLuint bindingindex); -typedef void (GLAPIENTRY * PFNGLVERTEXARRAYVERTEXATTRIBFORMATEXTPROC) (GLuint vaobj, GLuint attribindex, GLint size, GLenum type, GLboolean normalized, GLuint relativeoffset); -typedef void (GLAPIENTRY * PFNGLVERTEXARRAYVERTEXATTRIBIFORMATEXTPROC) (GLuint vaobj, GLuint attribindex, GLint size, GLenum type, GLuint relativeoffset); -typedef void (GLAPIENTRY * PFNGLVERTEXARRAYVERTEXATTRIBLFORMATEXTPROC) (GLuint vaobj, GLuint attribindex, GLint size, GLenum type, GLuint relativeoffset); -typedef void (GLAPIENTRY * PFNGLVERTEXARRAYVERTEXBINDINGDIVISOREXTPROC) (GLuint vaobj, GLuint bindingindex, GLuint divisor); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBBINDINGPROC) (GLuint attribindex, GLuint bindingindex); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBFORMATPROC) (GLuint attribindex, GLint size, GLenum type, GLboolean normalized, GLuint relativeoffset); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBIFORMATPROC) (GLuint attribindex, GLint size, GLenum type, GLuint relativeoffset); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBLFORMATPROC) (GLuint attribindex, GLint size, GLenum type, GLuint relativeoffset); -typedef void (GLAPIENTRY * PFNGLVERTEXBINDINGDIVISORPROC) (GLuint bindingindex, GLuint divisor); - -#define glBindVertexBuffer GLEW_GET_FUN(__glewBindVertexBuffer) -#define glVertexArrayBindVertexBufferEXT GLEW_GET_FUN(__glewVertexArrayBindVertexBufferEXT) -#define glVertexArrayVertexAttribBindingEXT GLEW_GET_FUN(__glewVertexArrayVertexAttribBindingEXT) -#define glVertexArrayVertexAttribFormatEXT GLEW_GET_FUN(__glewVertexArrayVertexAttribFormatEXT) -#define glVertexArrayVertexAttribIFormatEXT GLEW_GET_FUN(__glewVertexArrayVertexAttribIFormatEXT) -#define glVertexArrayVertexAttribLFormatEXT GLEW_GET_FUN(__glewVertexArrayVertexAttribLFormatEXT) -#define glVertexArrayVertexBindingDivisorEXT GLEW_GET_FUN(__glewVertexArrayVertexBindingDivisorEXT) -#define glVertexAttribBinding GLEW_GET_FUN(__glewVertexAttribBinding) -#define glVertexAttribFormat GLEW_GET_FUN(__glewVertexAttribFormat) -#define glVertexAttribIFormat GLEW_GET_FUN(__glewVertexAttribIFormat) -#define glVertexAttribLFormat GLEW_GET_FUN(__glewVertexAttribLFormat) -#define glVertexBindingDivisor GLEW_GET_FUN(__glewVertexBindingDivisor) - -#define GLEW_ARB_vertex_attrib_binding GLEW_GET_VAR(__GLEW_ARB_vertex_attrib_binding) - -#endif /* GL_ARB_vertex_attrib_binding */ - -/* -------------------------- GL_ARB_vertex_blend -------------------------- */ - -#ifndef GL_ARB_vertex_blend -#define GL_ARB_vertex_blend 1 - -#define GL_MODELVIEW0_ARB 0x1700 -#define GL_MODELVIEW1_ARB 0x850A -#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_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 - -typedef void (GLAPIENTRY * PFNGLVERTEXBLENDARBPROC) (GLint count); -typedef void (GLAPIENTRY * PFNGLWEIGHTPOINTERARBPROC) (GLint size, GLenum type, GLsizei stride, void *pointer); -typedef void (GLAPIENTRY * PFNGLWEIGHTBVARBPROC) (GLint size, GLbyte *weights); -typedef void (GLAPIENTRY * PFNGLWEIGHTDVARBPROC) (GLint size, GLdouble *weights); -typedef void (GLAPIENTRY * PFNGLWEIGHTFVARBPROC) (GLint size, GLfloat *weights); -typedef void (GLAPIENTRY * PFNGLWEIGHTIVARBPROC) (GLint size, GLint *weights); -typedef void (GLAPIENTRY * PFNGLWEIGHTSVARBPROC) (GLint size, GLshort *weights); -typedef void (GLAPIENTRY * PFNGLWEIGHTUBVARBPROC) (GLint size, GLubyte *weights); -typedef void (GLAPIENTRY * PFNGLWEIGHTUIVARBPROC) (GLint size, GLuint *weights); -typedef void (GLAPIENTRY * PFNGLWEIGHTUSVARBPROC) (GLint size, GLushort *weights); - -#define glVertexBlendARB GLEW_GET_FUN(__glewVertexBlendARB) -#define glWeightPointerARB GLEW_GET_FUN(__glewWeightPointerARB) -#define glWeightbvARB GLEW_GET_FUN(__glewWeightbvARB) -#define glWeightdvARB GLEW_GET_FUN(__glewWeightdvARB) -#define glWeightfvARB GLEW_GET_FUN(__glewWeightfvARB) -#define glWeightivARB GLEW_GET_FUN(__glewWeightivARB) -#define glWeightsvARB GLEW_GET_FUN(__glewWeightsvARB) -#define glWeightubvARB GLEW_GET_FUN(__glewWeightubvARB) -#define glWeightuivARB GLEW_GET_FUN(__glewWeightuivARB) -#define glWeightusvARB GLEW_GET_FUN(__glewWeightusvARB) - -#define GLEW_ARB_vertex_blend GLEW_GET_VAR(__GLEW_ARB_vertex_blend) - -#endif /* GL_ARB_vertex_blend */ - -/* ---------------------- GL_ARB_vertex_buffer_object ---------------------- */ - -#ifndef GL_ARB_vertex_buffer_object -#define GL_ARB_vertex_buffer_object 1 - -#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 - -typedef ptrdiff_t GLintptrARB; -typedef ptrdiff_t GLsizeiptrARB; - -typedef void (GLAPIENTRY * PFNGLBINDBUFFERARBPROC) (GLenum target, GLuint buffer); -typedef void (GLAPIENTRY * PFNGLBUFFERDATAARBPROC) (GLenum target, GLsizeiptrARB size, const void *data, GLenum usage); -typedef void (GLAPIENTRY * PFNGLBUFFERSUBDATAARBPROC) (GLenum target, GLintptrARB offset, GLsizeiptrARB size, const void *data); -typedef void (GLAPIENTRY * PFNGLDELETEBUFFERSARBPROC) (GLsizei n, const GLuint* buffers); -typedef void (GLAPIENTRY * PFNGLGENBUFFERSARBPROC) (GLsizei n, GLuint* buffers); -typedef void (GLAPIENTRY * PFNGLGETBUFFERPARAMETERIVARBPROC) (GLenum target, GLenum pname, GLint* params); -typedef void (GLAPIENTRY * PFNGLGETBUFFERPOINTERVARBPROC) (GLenum target, GLenum pname, void** params); -typedef void (GLAPIENTRY * PFNGLGETBUFFERSUBDATAARBPROC) (GLenum target, GLintptrARB offset, GLsizeiptrARB size, void *data); -typedef GLboolean (GLAPIENTRY * PFNGLISBUFFERARBPROC) (GLuint buffer); -typedef void * (GLAPIENTRY * PFNGLMAPBUFFERARBPROC) (GLenum target, GLenum access); -typedef GLboolean (GLAPIENTRY * PFNGLUNMAPBUFFERARBPROC) (GLenum target); - -#define glBindBufferARB GLEW_GET_FUN(__glewBindBufferARB) -#define glBufferDataARB GLEW_GET_FUN(__glewBufferDataARB) -#define glBufferSubDataARB GLEW_GET_FUN(__glewBufferSubDataARB) -#define glDeleteBuffersARB GLEW_GET_FUN(__glewDeleteBuffersARB) -#define glGenBuffersARB GLEW_GET_FUN(__glewGenBuffersARB) -#define glGetBufferParameterivARB GLEW_GET_FUN(__glewGetBufferParameterivARB) -#define glGetBufferPointervARB GLEW_GET_FUN(__glewGetBufferPointervARB) -#define glGetBufferSubDataARB GLEW_GET_FUN(__glewGetBufferSubDataARB) -#define glIsBufferARB GLEW_GET_FUN(__glewIsBufferARB) -#define glMapBufferARB GLEW_GET_FUN(__glewMapBufferARB) -#define glUnmapBufferARB GLEW_GET_FUN(__glewUnmapBufferARB) - -#define GLEW_ARB_vertex_buffer_object GLEW_GET_VAR(__GLEW_ARB_vertex_buffer_object) - -#endif /* GL_ARB_vertex_buffer_object */ - -/* ------------------------- GL_ARB_vertex_program ------------------------- */ - -#ifndef GL_ARB_vertex_program -#define GL_ARB_vertex_program 1 - -#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 - -typedef void (GLAPIENTRY * PFNGLBINDPROGRAMARBPROC) (GLenum target, GLuint program); -typedef void (GLAPIENTRY * PFNGLDELETEPROGRAMSARBPROC) (GLsizei n, const GLuint* programs); -typedef void (GLAPIENTRY * PFNGLDISABLEVERTEXATTRIBARRAYARBPROC) (GLuint index); -typedef void (GLAPIENTRY * PFNGLENABLEVERTEXATTRIBARRAYARBPROC) (GLuint index); -typedef void (GLAPIENTRY * PFNGLGENPROGRAMSARBPROC) (GLsizei n, GLuint* programs); -typedef void (GLAPIENTRY * PFNGLGETPROGRAMENVPARAMETERDVARBPROC) (GLenum target, GLuint index, GLdouble* params); -typedef void (GLAPIENTRY * PFNGLGETPROGRAMENVPARAMETERFVARBPROC) (GLenum target, GLuint index, GLfloat* params); -typedef void (GLAPIENTRY * PFNGLGETPROGRAMLOCALPARAMETERDVARBPROC) (GLenum target, GLuint index, GLdouble* params); -typedef void (GLAPIENTRY * PFNGLGETPROGRAMLOCALPARAMETERFVARBPROC) (GLenum target, GLuint index, GLfloat* params); -typedef void (GLAPIENTRY * PFNGLGETPROGRAMSTRINGARBPROC) (GLenum target, GLenum pname, void *string); -typedef void (GLAPIENTRY * PFNGLGETPROGRAMIVARBPROC) (GLenum target, GLenum pname, GLint* params); -typedef void (GLAPIENTRY * PFNGLGETVERTEXATTRIBPOINTERVARBPROC) (GLuint index, GLenum pname, void** pointer); -typedef void (GLAPIENTRY * PFNGLGETVERTEXATTRIBDVARBPROC) (GLuint index, GLenum pname, GLdouble* params); -typedef void (GLAPIENTRY * PFNGLGETVERTEXATTRIBFVARBPROC) (GLuint index, GLenum pname, GLfloat* params); -typedef void (GLAPIENTRY * PFNGLGETVERTEXATTRIBIVARBPROC) (GLuint index, GLenum pname, GLint* params); -typedef GLboolean (GLAPIENTRY * PFNGLISPROGRAMARBPROC) (GLuint program); -typedef void (GLAPIENTRY * PFNGLPROGRAMENVPARAMETER4DARBPROC) (GLenum target, GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); -typedef void (GLAPIENTRY * PFNGLPROGRAMENVPARAMETER4DVARBPROC) (GLenum target, GLuint index, const GLdouble* params); -typedef void (GLAPIENTRY * PFNGLPROGRAMENVPARAMETER4FARBPROC) (GLenum target, GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); -typedef void (GLAPIENTRY * PFNGLPROGRAMENVPARAMETER4FVARBPROC) (GLenum target, GLuint index, const GLfloat* params); -typedef void (GLAPIENTRY * PFNGLPROGRAMLOCALPARAMETER4DARBPROC) (GLenum target, GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); -typedef void (GLAPIENTRY * PFNGLPROGRAMLOCALPARAMETER4DVARBPROC) (GLenum target, GLuint index, const GLdouble* params); -typedef void (GLAPIENTRY * PFNGLPROGRAMLOCALPARAMETER4FARBPROC) (GLenum target, GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); -typedef void (GLAPIENTRY * PFNGLPROGRAMLOCALPARAMETER4FVARBPROC) (GLenum target, GLuint index, const GLfloat* params); -typedef void (GLAPIENTRY * PFNGLPROGRAMSTRINGARBPROC) (GLenum target, GLenum format, GLsizei len, const void *string); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB1DARBPROC) (GLuint index, GLdouble x); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB1DVARBPROC) (GLuint index, const GLdouble* v); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB1FARBPROC) (GLuint index, GLfloat x); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB1FVARBPROC) (GLuint index, const GLfloat* v); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB1SARBPROC) (GLuint index, GLshort x); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB1SVARBPROC) (GLuint index, const GLshort* v); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB2DARBPROC) (GLuint index, GLdouble x, GLdouble y); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB2DVARBPROC) (GLuint index, const GLdouble* v); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB2FARBPROC) (GLuint index, GLfloat x, GLfloat y); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB2FVARBPROC) (GLuint index, const GLfloat* v); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB2SARBPROC) (GLuint index, GLshort x, GLshort y); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB2SVARBPROC) (GLuint index, const GLshort* v); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB3DARBPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB3DVARBPROC) (GLuint index, const GLdouble* v); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB3FARBPROC) (GLuint index, GLfloat x, GLfloat y, GLfloat z); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB3FVARBPROC) (GLuint index, const GLfloat* v); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB3SARBPROC) (GLuint index, GLshort x, GLshort y, GLshort z); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB3SVARBPROC) (GLuint index, const GLshort* v); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4NBVARBPROC) (GLuint index, const GLbyte* v); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4NIVARBPROC) (GLuint index, const GLint* v); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4NSVARBPROC) (GLuint index, const GLshort* v); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4NUBARBPROC) (GLuint index, GLubyte x, GLubyte y, GLubyte z, GLubyte w); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4NUBVARBPROC) (GLuint index, const GLubyte* v); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4NUIVARBPROC) (GLuint index, const GLuint* v); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4NUSVARBPROC) (GLuint index, const GLushort* v); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4BVARBPROC) (GLuint index, const GLbyte* v); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4DARBPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4DVARBPROC) (GLuint index, const GLdouble* v); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4FARBPROC) (GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4FVARBPROC) (GLuint index, const GLfloat* v); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4IVARBPROC) (GLuint index, const GLint* v); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4SARBPROC) (GLuint index, GLshort x, GLshort y, GLshort z, GLshort w); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4SVARBPROC) (GLuint index, const GLshort* v); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4UBVARBPROC) (GLuint index, const GLubyte* v); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4UIVARBPROC) (GLuint index, const GLuint* v); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4USVARBPROC) (GLuint index, const GLushort* v); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBPOINTERARBPROC) (GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const void *pointer); - -#define glBindProgramARB GLEW_GET_FUN(__glewBindProgramARB) -#define glDeleteProgramsARB GLEW_GET_FUN(__glewDeleteProgramsARB) -#define glDisableVertexAttribArrayARB GLEW_GET_FUN(__glewDisableVertexAttribArrayARB) -#define glEnableVertexAttribArrayARB GLEW_GET_FUN(__glewEnableVertexAttribArrayARB) -#define glGenProgramsARB GLEW_GET_FUN(__glewGenProgramsARB) -#define glGetProgramEnvParameterdvARB GLEW_GET_FUN(__glewGetProgramEnvParameterdvARB) -#define glGetProgramEnvParameterfvARB GLEW_GET_FUN(__glewGetProgramEnvParameterfvARB) -#define glGetProgramLocalParameterdvARB GLEW_GET_FUN(__glewGetProgramLocalParameterdvARB) -#define glGetProgramLocalParameterfvARB GLEW_GET_FUN(__glewGetProgramLocalParameterfvARB) -#define glGetProgramStringARB GLEW_GET_FUN(__glewGetProgramStringARB) -#define glGetProgramivARB GLEW_GET_FUN(__glewGetProgramivARB) -#define glGetVertexAttribPointervARB GLEW_GET_FUN(__glewGetVertexAttribPointervARB) -#define glGetVertexAttribdvARB GLEW_GET_FUN(__glewGetVertexAttribdvARB) -#define glGetVertexAttribfvARB GLEW_GET_FUN(__glewGetVertexAttribfvARB) -#define glGetVertexAttribivARB GLEW_GET_FUN(__glewGetVertexAttribivARB) -#define glIsProgramARB GLEW_GET_FUN(__glewIsProgramARB) -#define glProgramEnvParameter4dARB GLEW_GET_FUN(__glewProgramEnvParameter4dARB) -#define glProgramEnvParameter4dvARB GLEW_GET_FUN(__glewProgramEnvParameter4dvARB) -#define glProgramEnvParameter4fARB GLEW_GET_FUN(__glewProgramEnvParameter4fARB) -#define glProgramEnvParameter4fvARB GLEW_GET_FUN(__glewProgramEnvParameter4fvARB) -#define glProgramLocalParameter4dARB GLEW_GET_FUN(__glewProgramLocalParameter4dARB) -#define glProgramLocalParameter4dvARB GLEW_GET_FUN(__glewProgramLocalParameter4dvARB) -#define glProgramLocalParameter4fARB GLEW_GET_FUN(__glewProgramLocalParameter4fARB) -#define glProgramLocalParameter4fvARB GLEW_GET_FUN(__glewProgramLocalParameter4fvARB) -#define glProgramStringARB GLEW_GET_FUN(__glewProgramStringARB) -#define glVertexAttrib1dARB GLEW_GET_FUN(__glewVertexAttrib1dARB) -#define glVertexAttrib1dvARB GLEW_GET_FUN(__glewVertexAttrib1dvARB) -#define glVertexAttrib1fARB GLEW_GET_FUN(__glewVertexAttrib1fARB) -#define glVertexAttrib1fvARB GLEW_GET_FUN(__glewVertexAttrib1fvARB) -#define glVertexAttrib1sARB GLEW_GET_FUN(__glewVertexAttrib1sARB) -#define glVertexAttrib1svARB GLEW_GET_FUN(__glewVertexAttrib1svARB) -#define glVertexAttrib2dARB GLEW_GET_FUN(__glewVertexAttrib2dARB) -#define glVertexAttrib2dvARB GLEW_GET_FUN(__glewVertexAttrib2dvARB) -#define glVertexAttrib2fARB GLEW_GET_FUN(__glewVertexAttrib2fARB) -#define glVertexAttrib2fvARB GLEW_GET_FUN(__glewVertexAttrib2fvARB) -#define glVertexAttrib2sARB GLEW_GET_FUN(__glewVertexAttrib2sARB) -#define glVertexAttrib2svARB GLEW_GET_FUN(__glewVertexAttrib2svARB) -#define glVertexAttrib3dARB GLEW_GET_FUN(__glewVertexAttrib3dARB) -#define glVertexAttrib3dvARB GLEW_GET_FUN(__glewVertexAttrib3dvARB) -#define glVertexAttrib3fARB GLEW_GET_FUN(__glewVertexAttrib3fARB) -#define glVertexAttrib3fvARB GLEW_GET_FUN(__glewVertexAttrib3fvARB) -#define glVertexAttrib3sARB GLEW_GET_FUN(__glewVertexAttrib3sARB) -#define glVertexAttrib3svARB GLEW_GET_FUN(__glewVertexAttrib3svARB) -#define glVertexAttrib4NbvARB GLEW_GET_FUN(__glewVertexAttrib4NbvARB) -#define glVertexAttrib4NivARB GLEW_GET_FUN(__glewVertexAttrib4NivARB) -#define glVertexAttrib4NsvARB GLEW_GET_FUN(__glewVertexAttrib4NsvARB) -#define glVertexAttrib4NubARB GLEW_GET_FUN(__glewVertexAttrib4NubARB) -#define glVertexAttrib4NubvARB GLEW_GET_FUN(__glewVertexAttrib4NubvARB) -#define glVertexAttrib4NuivARB GLEW_GET_FUN(__glewVertexAttrib4NuivARB) -#define glVertexAttrib4NusvARB GLEW_GET_FUN(__glewVertexAttrib4NusvARB) -#define glVertexAttrib4bvARB GLEW_GET_FUN(__glewVertexAttrib4bvARB) -#define glVertexAttrib4dARB GLEW_GET_FUN(__glewVertexAttrib4dARB) -#define glVertexAttrib4dvARB GLEW_GET_FUN(__glewVertexAttrib4dvARB) -#define glVertexAttrib4fARB GLEW_GET_FUN(__glewVertexAttrib4fARB) -#define glVertexAttrib4fvARB GLEW_GET_FUN(__glewVertexAttrib4fvARB) -#define glVertexAttrib4ivARB GLEW_GET_FUN(__glewVertexAttrib4ivARB) -#define glVertexAttrib4sARB GLEW_GET_FUN(__glewVertexAttrib4sARB) -#define glVertexAttrib4svARB GLEW_GET_FUN(__glewVertexAttrib4svARB) -#define glVertexAttrib4ubvARB GLEW_GET_FUN(__glewVertexAttrib4ubvARB) -#define glVertexAttrib4uivARB GLEW_GET_FUN(__glewVertexAttrib4uivARB) -#define glVertexAttrib4usvARB GLEW_GET_FUN(__glewVertexAttrib4usvARB) -#define glVertexAttribPointerARB GLEW_GET_FUN(__glewVertexAttribPointerARB) - -#define GLEW_ARB_vertex_program GLEW_GET_VAR(__GLEW_ARB_vertex_program) - -#endif /* GL_ARB_vertex_program */ - -/* -------------------------- GL_ARB_vertex_shader ------------------------- */ - -#ifndef GL_ARB_vertex_shader -#define GL_ARB_vertex_shader 1 - -#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 - -typedef void (GLAPIENTRY * PFNGLBINDATTRIBLOCATIONARBPROC) (GLhandleARB programObj, GLuint index, const GLcharARB* name); -typedef void (GLAPIENTRY * PFNGLGETACTIVEATTRIBARBPROC) (GLhandleARB programObj, GLuint index, GLsizei maxLength, GLsizei* length, GLint *size, GLenum *type, GLcharARB *name); -typedef GLint (GLAPIENTRY * PFNGLGETATTRIBLOCATIONARBPROC) (GLhandleARB programObj, const GLcharARB* name); - -#define glBindAttribLocationARB GLEW_GET_FUN(__glewBindAttribLocationARB) -#define glGetActiveAttribARB GLEW_GET_FUN(__glewGetActiveAttribARB) -#define glGetAttribLocationARB GLEW_GET_FUN(__glewGetAttribLocationARB) - -#define GLEW_ARB_vertex_shader GLEW_GET_VAR(__GLEW_ARB_vertex_shader) - -#endif /* GL_ARB_vertex_shader */ - -/* ------------------- GL_ARB_vertex_type_10f_11f_11f_rev ------------------ */ - -#ifndef GL_ARB_vertex_type_10f_11f_11f_rev -#define GL_ARB_vertex_type_10f_11f_11f_rev 1 - -#define GL_UNSIGNED_INT_10F_11F_11F_REV 0x8C3B - -#define GLEW_ARB_vertex_type_10f_11f_11f_rev GLEW_GET_VAR(__GLEW_ARB_vertex_type_10f_11f_11f_rev) - -#endif /* GL_ARB_vertex_type_10f_11f_11f_rev */ - -/* ------------------- GL_ARB_vertex_type_2_10_10_10_rev ------------------- */ - -#ifndef GL_ARB_vertex_type_2_10_10_10_rev -#define GL_ARB_vertex_type_2_10_10_10_rev 1 - -#define GL_UNSIGNED_INT_2_10_10_10_REV 0x8368 -#define GL_INT_2_10_10_10_REV 0x8D9F - -typedef void (GLAPIENTRY * PFNGLCOLORP3UIPROC) (GLenum type, GLuint color); -typedef void (GLAPIENTRY * PFNGLCOLORP3UIVPROC) (GLenum type, const GLuint* color); -typedef void (GLAPIENTRY * PFNGLCOLORP4UIPROC) (GLenum type, GLuint color); -typedef void (GLAPIENTRY * PFNGLCOLORP4UIVPROC) (GLenum type, const GLuint* color); -typedef void (GLAPIENTRY * PFNGLMULTITEXCOORDP1UIPROC) (GLenum texture, GLenum type, GLuint coords); -typedef void (GLAPIENTRY * PFNGLMULTITEXCOORDP1UIVPROC) (GLenum texture, GLenum type, const GLuint* coords); -typedef void (GLAPIENTRY * PFNGLMULTITEXCOORDP2UIPROC) (GLenum texture, GLenum type, GLuint coords); -typedef void (GLAPIENTRY * PFNGLMULTITEXCOORDP2UIVPROC) (GLenum texture, GLenum type, const GLuint* coords); -typedef void (GLAPIENTRY * PFNGLMULTITEXCOORDP3UIPROC) (GLenum texture, GLenum type, GLuint coords); -typedef void (GLAPIENTRY * PFNGLMULTITEXCOORDP3UIVPROC) (GLenum texture, GLenum type, const GLuint* coords); -typedef void (GLAPIENTRY * PFNGLMULTITEXCOORDP4UIPROC) (GLenum texture, GLenum type, GLuint coords); -typedef void (GLAPIENTRY * PFNGLMULTITEXCOORDP4UIVPROC) (GLenum texture, GLenum type, const GLuint* coords); -typedef void (GLAPIENTRY * PFNGLNORMALP3UIPROC) (GLenum type, GLuint coords); -typedef void (GLAPIENTRY * PFNGLNORMALP3UIVPROC) (GLenum type, const GLuint* coords); -typedef void (GLAPIENTRY * PFNGLSECONDARYCOLORP3UIPROC) (GLenum type, GLuint color); -typedef void (GLAPIENTRY * PFNGLSECONDARYCOLORP3UIVPROC) (GLenum type, const GLuint* color); -typedef void (GLAPIENTRY * PFNGLTEXCOORDP1UIPROC) (GLenum type, GLuint coords); -typedef void (GLAPIENTRY * PFNGLTEXCOORDP1UIVPROC) (GLenum type, const GLuint* coords); -typedef void (GLAPIENTRY * PFNGLTEXCOORDP2UIPROC) (GLenum type, GLuint coords); -typedef void (GLAPIENTRY * PFNGLTEXCOORDP2UIVPROC) (GLenum type, const GLuint* coords); -typedef void (GLAPIENTRY * PFNGLTEXCOORDP3UIPROC) (GLenum type, GLuint coords); -typedef void (GLAPIENTRY * PFNGLTEXCOORDP3UIVPROC) (GLenum type, const GLuint* coords); -typedef void (GLAPIENTRY * PFNGLTEXCOORDP4UIPROC) (GLenum type, GLuint coords); -typedef void (GLAPIENTRY * PFNGLTEXCOORDP4UIVPROC) (GLenum type, const GLuint* coords); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBP1UIPROC) (GLuint index, GLenum type, GLboolean normalized, GLuint value); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBP1UIVPROC) (GLuint index, GLenum type, GLboolean normalized, const GLuint* value); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBP2UIPROC) (GLuint index, GLenum type, GLboolean normalized, GLuint value); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBP2UIVPROC) (GLuint index, GLenum type, GLboolean normalized, const GLuint* value); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBP3UIPROC) (GLuint index, GLenum type, GLboolean normalized, GLuint value); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBP3UIVPROC) (GLuint index, GLenum type, GLboolean normalized, const GLuint* value); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBP4UIPROC) (GLuint index, GLenum type, GLboolean normalized, GLuint value); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBP4UIVPROC) (GLuint index, GLenum type, GLboolean normalized, const GLuint* value); -typedef void (GLAPIENTRY * PFNGLVERTEXP2UIPROC) (GLenum type, GLuint value); -typedef void (GLAPIENTRY * PFNGLVERTEXP2UIVPROC) (GLenum type, const GLuint* value); -typedef void (GLAPIENTRY * PFNGLVERTEXP3UIPROC) (GLenum type, GLuint value); -typedef void (GLAPIENTRY * PFNGLVERTEXP3UIVPROC) (GLenum type, const GLuint* value); -typedef void (GLAPIENTRY * PFNGLVERTEXP4UIPROC) (GLenum type, GLuint value); -typedef void (GLAPIENTRY * PFNGLVERTEXP4UIVPROC) (GLenum type, const GLuint* value); - -#define glColorP3ui GLEW_GET_FUN(__glewColorP3ui) -#define glColorP3uiv GLEW_GET_FUN(__glewColorP3uiv) -#define glColorP4ui GLEW_GET_FUN(__glewColorP4ui) -#define glColorP4uiv GLEW_GET_FUN(__glewColorP4uiv) -#define glMultiTexCoordP1ui GLEW_GET_FUN(__glewMultiTexCoordP1ui) -#define glMultiTexCoordP1uiv GLEW_GET_FUN(__glewMultiTexCoordP1uiv) -#define glMultiTexCoordP2ui GLEW_GET_FUN(__glewMultiTexCoordP2ui) -#define glMultiTexCoordP2uiv GLEW_GET_FUN(__glewMultiTexCoordP2uiv) -#define glMultiTexCoordP3ui GLEW_GET_FUN(__glewMultiTexCoordP3ui) -#define glMultiTexCoordP3uiv GLEW_GET_FUN(__glewMultiTexCoordP3uiv) -#define glMultiTexCoordP4ui GLEW_GET_FUN(__glewMultiTexCoordP4ui) -#define glMultiTexCoordP4uiv GLEW_GET_FUN(__glewMultiTexCoordP4uiv) -#define glNormalP3ui GLEW_GET_FUN(__glewNormalP3ui) -#define glNormalP3uiv GLEW_GET_FUN(__glewNormalP3uiv) -#define glSecondaryColorP3ui GLEW_GET_FUN(__glewSecondaryColorP3ui) -#define glSecondaryColorP3uiv GLEW_GET_FUN(__glewSecondaryColorP3uiv) -#define glTexCoordP1ui GLEW_GET_FUN(__glewTexCoordP1ui) -#define glTexCoordP1uiv GLEW_GET_FUN(__glewTexCoordP1uiv) -#define glTexCoordP2ui GLEW_GET_FUN(__glewTexCoordP2ui) -#define glTexCoordP2uiv GLEW_GET_FUN(__glewTexCoordP2uiv) -#define glTexCoordP3ui GLEW_GET_FUN(__glewTexCoordP3ui) -#define glTexCoordP3uiv GLEW_GET_FUN(__glewTexCoordP3uiv) -#define glTexCoordP4ui GLEW_GET_FUN(__glewTexCoordP4ui) -#define glTexCoordP4uiv GLEW_GET_FUN(__glewTexCoordP4uiv) -#define glVertexAttribP1ui GLEW_GET_FUN(__glewVertexAttribP1ui) -#define glVertexAttribP1uiv GLEW_GET_FUN(__glewVertexAttribP1uiv) -#define glVertexAttribP2ui GLEW_GET_FUN(__glewVertexAttribP2ui) -#define glVertexAttribP2uiv GLEW_GET_FUN(__glewVertexAttribP2uiv) -#define glVertexAttribP3ui GLEW_GET_FUN(__glewVertexAttribP3ui) -#define glVertexAttribP3uiv GLEW_GET_FUN(__glewVertexAttribP3uiv) -#define glVertexAttribP4ui GLEW_GET_FUN(__glewVertexAttribP4ui) -#define glVertexAttribP4uiv GLEW_GET_FUN(__glewVertexAttribP4uiv) -#define glVertexP2ui GLEW_GET_FUN(__glewVertexP2ui) -#define glVertexP2uiv GLEW_GET_FUN(__glewVertexP2uiv) -#define glVertexP3ui GLEW_GET_FUN(__glewVertexP3ui) -#define glVertexP3uiv GLEW_GET_FUN(__glewVertexP3uiv) -#define glVertexP4ui GLEW_GET_FUN(__glewVertexP4ui) -#define glVertexP4uiv GLEW_GET_FUN(__glewVertexP4uiv) - -#define GLEW_ARB_vertex_type_2_10_10_10_rev GLEW_GET_VAR(__GLEW_ARB_vertex_type_2_10_10_10_rev) - -#endif /* GL_ARB_vertex_type_2_10_10_10_rev */ - -/* ------------------------- GL_ARB_viewport_array ------------------------- */ - -#ifndef GL_ARB_viewport_array -#define GL_ARB_viewport_array 1 - -#define GL_DEPTH_RANGE 0x0B70 -#define GL_VIEWPORT 0x0BA2 -#define GL_SCISSOR_BOX 0x0C10 -#define GL_SCISSOR_TEST 0x0C11 -#define GL_MAX_VIEWPORTS 0x825B -#define GL_VIEWPORT_SUBPIXEL_BITS 0x825C -#define GL_VIEWPORT_BOUNDS_RANGE 0x825D -#define GL_LAYER_PROVOKING_VERTEX 0x825E -#define GL_VIEWPORT_INDEX_PROVOKING_VERTEX 0x825F -#define GL_UNDEFINED_VERTEX 0x8260 -#define GL_FIRST_VERTEX_CONVENTION 0x8E4D -#define GL_LAST_VERTEX_CONVENTION 0x8E4E -#define GL_PROVOKING_VERTEX 0x8E4F - -typedef void (GLAPIENTRY * PFNGLDEPTHRANGEARRAYVPROC) (GLuint first, GLsizei count, const GLclampd * v); -typedef void (GLAPIENTRY * PFNGLDEPTHRANGEINDEXEDPROC) (GLuint index, GLclampd n, GLclampd f); -typedef void (GLAPIENTRY * PFNGLGETDOUBLEI_VPROC) (GLenum target, GLuint index, GLdouble* data); -typedef void (GLAPIENTRY * PFNGLGETFLOATI_VPROC) (GLenum target, GLuint index, GLfloat* data); -typedef void (GLAPIENTRY * PFNGLSCISSORARRAYVPROC) (GLuint first, GLsizei count, const GLint * v); -typedef void (GLAPIENTRY * PFNGLSCISSORINDEXEDPROC) (GLuint index, GLint left, GLint bottom, GLsizei width, GLsizei height); -typedef void (GLAPIENTRY * PFNGLSCISSORINDEXEDVPROC) (GLuint index, const GLint * v); -typedef void (GLAPIENTRY * PFNGLVIEWPORTARRAYVPROC) (GLuint first, GLsizei count, const GLfloat * v); -typedef void (GLAPIENTRY * PFNGLVIEWPORTINDEXEDFPROC) (GLuint index, GLfloat x, GLfloat y, GLfloat w, GLfloat h); -typedef void (GLAPIENTRY * PFNGLVIEWPORTINDEXEDFVPROC) (GLuint index, const GLfloat * v); - -#define glDepthRangeArrayv GLEW_GET_FUN(__glewDepthRangeArrayv) -#define glDepthRangeIndexed GLEW_GET_FUN(__glewDepthRangeIndexed) -#define glGetDoublei_v GLEW_GET_FUN(__glewGetDoublei_v) -#define glGetFloati_v GLEW_GET_FUN(__glewGetFloati_v) -#define glScissorArrayv GLEW_GET_FUN(__glewScissorArrayv) -#define glScissorIndexed GLEW_GET_FUN(__glewScissorIndexed) -#define glScissorIndexedv GLEW_GET_FUN(__glewScissorIndexedv) -#define glViewportArrayv GLEW_GET_FUN(__glewViewportArrayv) -#define glViewportIndexedf GLEW_GET_FUN(__glewViewportIndexedf) -#define glViewportIndexedfv GLEW_GET_FUN(__glewViewportIndexedfv) - -#define GLEW_ARB_viewport_array GLEW_GET_VAR(__GLEW_ARB_viewport_array) - -#endif /* GL_ARB_viewport_array */ - -/* --------------------------- GL_ARB_window_pos --------------------------- */ - -#ifndef GL_ARB_window_pos -#define GL_ARB_window_pos 1 - -typedef void (GLAPIENTRY * PFNGLWINDOWPOS2DARBPROC) (GLdouble x, GLdouble y); -typedef void (GLAPIENTRY * PFNGLWINDOWPOS2DVARBPROC) (const GLdouble* p); -typedef void (GLAPIENTRY * PFNGLWINDOWPOS2FARBPROC) (GLfloat x, GLfloat y); -typedef void (GLAPIENTRY * PFNGLWINDOWPOS2FVARBPROC) (const GLfloat* p); -typedef void (GLAPIENTRY * PFNGLWINDOWPOS2IARBPROC) (GLint x, GLint y); -typedef void (GLAPIENTRY * PFNGLWINDOWPOS2IVARBPROC) (const GLint* p); -typedef void (GLAPIENTRY * PFNGLWINDOWPOS2SARBPROC) (GLshort x, GLshort y); -typedef void (GLAPIENTRY * PFNGLWINDOWPOS2SVARBPROC) (const GLshort* p); -typedef void (GLAPIENTRY * PFNGLWINDOWPOS3DARBPROC) (GLdouble x, GLdouble y, GLdouble z); -typedef void (GLAPIENTRY * PFNGLWINDOWPOS3DVARBPROC) (const GLdouble* p); -typedef void (GLAPIENTRY * PFNGLWINDOWPOS3FARBPROC) (GLfloat x, GLfloat y, GLfloat z); -typedef void (GLAPIENTRY * PFNGLWINDOWPOS3FVARBPROC) (const GLfloat* p); -typedef void (GLAPIENTRY * PFNGLWINDOWPOS3IARBPROC) (GLint x, GLint y, GLint z); -typedef void (GLAPIENTRY * PFNGLWINDOWPOS3IVARBPROC) (const GLint* p); -typedef void (GLAPIENTRY * PFNGLWINDOWPOS3SARBPROC) (GLshort x, GLshort y, GLshort z); -typedef void (GLAPIENTRY * PFNGLWINDOWPOS3SVARBPROC) (const GLshort* p); - -#define glWindowPos2dARB GLEW_GET_FUN(__glewWindowPos2dARB) -#define glWindowPos2dvARB GLEW_GET_FUN(__glewWindowPos2dvARB) -#define glWindowPos2fARB GLEW_GET_FUN(__glewWindowPos2fARB) -#define glWindowPos2fvARB GLEW_GET_FUN(__glewWindowPos2fvARB) -#define glWindowPos2iARB GLEW_GET_FUN(__glewWindowPos2iARB) -#define glWindowPos2ivARB GLEW_GET_FUN(__glewWindowPos2ivARB) -#define glWindowPos2sARB GLEW_GET_FUN(__glewWindowPos2sARB) -#define glWindowPos2svARB GLEW_GET_FUN(__glewWindowPos2svARB) -#define glWindowPos3dARB GLEW_GET_FUN(__glewWindowPos3dARB) -#define glWindowPos3dvARB GLEW_GET_FUN(__glewWindowPos3dvARB) -#define glWindowPos3fARB GLEW_GET_FUN(__glewWindowPos3fARB) -#define glWindowPos3fvARB GLEW_GET_FUN(__glewWindowPos3fvARB) -#define glWindowPos3iARB GLEW_GET_FUN(__glewWindowPos3iARB) -#define glWindowPos3ivARB GLEW_GET_FUN(__glewWindowPos3ivARB) -#define glWindowPos3sARB GLEW_GET_FUN(__glewWindowPos3sARB) -#define glWindowPos3svARB GLEW_GET_FUN(__glewWindowPos3svARB) - -#define GLEW_ARB_window_pos GLEW_GET_VAR(__GLEW_ARB_window_pos) - -#endif /* GL_ARB_window_pos */ - -/* ------------------------- GL_ATIX_point_sprites ------------------------- */ - -#ifndef GL_ATIX_point_sprites -#define GL_ATIX_point_sprites 1 - -#define GL_TEXTURE_POINT_MODE_ATIX 0x60B0 -#define GL_TEXTURE_POINT_ONE_COORD_ATIX 0x60B1 -#define GL_TEXTURE_POINT_SPRITE_ATIX 0x60B2 -#define GL_POINT_SPRITE_CULL_MODE_ATIX 0x60B3 -#define GL_POINT_SPRITE_CULL_CENTER_ATIX 0x60B4 -#define GL_POINT_SPRITE_CULL_CLIP_ATIX 0x60B5 - -#define GLEW_ATIX_point_sprites GLEW_GET_VAR(__GLEW_ATIX_point_sprites) - -#endif /* GL_ATIX_point_sprites */ - -/* ---------------------- GL_ATIX_texture_env_combine3 --------------------- */ - -#ifndef GL_ATIX_texture_env_combine3 -#define GL_ATIX_texture_env_combine3 1 - -#define GL_MODULATE_ADD_ATIX 0x8744 -#define GL_MODULATE_SIGNED_ADD_ATIX 0x8745 -#define GL_MODULATE_SUBTRACT_ATIX 0x8746 - -#define GLEW_ATIX_texture_env_combine3 GLEW_GET_VAR(__GLEW_ATIX_texture_env_combine3) - -#endif /* GL_ATIX_texture_env_combine3 */ - -/* ----------------------- GL_ATIX_texture_env_route ----------------------- */ - -#ifndef GL_ATIX_texture_env_route -#define GL_ATIX_texture_env_route 1 - -#define GL_SECONDARY_COLOR_ATIX 0x8747 -#define GL_TEXTURE_OUTPUT_RGB_ATIX 0x8748 -#define GL_TEXTURE_OUTPUT_ALPHA_ATIX 0x8749 - -#define GLEW_ATIX_texture_env_route GLEW_GET_VAR(__GLEW_ATIX_texture_env_route) - -#endif /* GL_ATIX_texture_env_route */ - -/* ---------------- GL_ATIX_vertex_shader_output_point_size ---------------- */ - -#ifndef GL_ATIX_vertex_shader_output_point_size -#define GL_ATIX_vertex_shader_output_point_size 1 - -#define GL_OUTPUT_POINT_SIZE_ATIX 0x610E - -#define GLEW_ATIX_vertex_shader_output_point_size GLEW_GET_VAR(__GLEW_ATIX_vertex_shader_output_point_size) - -#endif /* GL_ATIX_vertex_shader_output_point_size */ - -/* -------------------------- GL_ATI_draw_buffers -------------------------- */ - -#ifndef GL_ATI_draw_buffers -#define GL_ATI_draw_buffers 1 - -#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 - -typedef void (GLAPIENTRY * PFNGLDRAWBUFFERSATIPROC) (GLsizei n, const GLenum* bufs); - -#define glDrawBuffersATI GLEW_GET_FUN(__glewDrawBuffersATI) - -#define GLEW_ATI_draw_buffers GLEW_GET_VAR(__GLEW_ATI_draw_buffers) - -#endif /* GL_ATI_draw_buffers */ - -/* -------------------------- GL_ATI_element_array ------------------------- */ - -#ifndef GL_ATI_element_array -#define GL_ATI_element_array 1 - -#define GL_ELEMENT_ARRAY_ATI 0x8768 -#define GL_ELEMENT_ARRAY_TYPE_ATI 0x8769 -#define GL_ELEMENT_ARRAY_POINTER_ATI 0x876A - -typedef void (GLAPIENTRY * PFNGLDRAWELEMENTARRAYATIPROC) (GLenum mode, GLsizei count); -typedef void (GLAPIENTRY * PFNGLDRAWRANGEELEMENTARRAYATIPROC) (GLenum mode, GLuint start, GLuint end, GLsizei count); -typedef void (GLAPIENTRY * PFNGLELEMENTPOINTERATIPROC) (GLenum type, const void *pointer); - -#define glDrawElementArrayATI GLEW_GET_FUN(__glewDrawElementArrayATI) -#define glDrawRangeElementArrayATI GLEW_GET_FUN(__glewDrawRangeElementArrayATI) -#define glElementPointerATI GLEW_GET_FUN(__glewElementPointerATI) - -#define GLEW_ATI_element_array GLEW_GET_VAR(__GLEW_ATI_element_array) - -#endif /* GL_ATI_element_array */ - -/* ------------------------- GL_ATI_envmap_bumpmap ------------------------- */ - -#ifndef GL_ATI_envmap_bumpmap -#define GL_ATI_envmap_bumpmap 1 - -#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 - -typedef void (GLAPIENTRY * PFNGLGETTEXBUMPPARAMETERFVATIPROC) (GLenum pname, GLfloat *param); -typedef void (GLAPIENTRY * PFNGLGETTEXBUMPPARAMETERIVATIPROC) (GLenum pname, GLint *param); -typedef void (GLAPIENTRY * PFNGLTEXBUMPPARAMETERFVATIPROC) (GLenum pname, GLfloat *param); -typedef void (GLAPIENTRY * PFNGLTEXBUMPPARAMETERIVATIPROC) (GLenum pname, GLint *param); - -#define glGetTexBumpParameterfvATI GLEW_GET_FUN(__glewGetTexBumpParameterfvATI) -#define glGetTexBumpParameterivATI GLEW_GET_FUN(__glewGetTexBumpParameterivATI) -#define glTexBumpParameterfvATI GLEW_GET_FUN(__glewTexBumpParameterfvATI) -#define glTexBumpParameterivATI GLEW_GET_FUN(__glewTexBumpParameterivATI) - -#define GLEW_ATI_envmap_bumpmap GLEW_GET_VAR(__GLEW_ATI_envmap_bumpmap) - -#endif /* GL_ATI_envmap_bumpmap */ - -/* ------------------------- GL_ATI_fragment_shader ------------------------ */ - -#ifndef GL_ATI_fragment_shader -#define GL_ATI_fragment_shader 1 - -#define GL_2X_BIT_ATI 0x00000001 -#define GL_RED_BIT_ATI 0x00000001 -#define GL_4X_BIT_ATI 0x00000002 -#define GL_COMP_BIT_ATI 0x00000002 -#define GL_GREEN_BIT_ATI 0x00000002 -#define GL_8X_BIT_ATI 0x00000004 -#define GL_BLUE_BIT_ATI 0x00000004 -#define GL_NEGATE_BIT_ATI 0x00000004 -#define GL_BIAS_BIT_ATI 0x00000008 -#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_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_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_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 - -typedef void (GLAPIENTRY * PFNGLALPHAFRAGMENTOP1ATIPROC) (GLenum op, GLuint dst, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod); -typedef void (GLAPIENTRY * PFNGLALPHAFRAGMENTOP2ATIPROC) (GLenum op, GLuint dst, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod, GLuint arg2, GLuint arg2Rep, GLuint arg2Mod); -typedef void (GLAPIENTRY * 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 (GLAPIENTRY * PFNGLBEGINFRAGMENTSHADERATIPROC) (void); -typedef void (GLAPIENTRY * PFNGLBINDFRAGMENTSHADERATIPROC) (GLuint id); -typedef void (GLAPIENTRY * PFNGLCOLORFRAGMENTOP1ATIPROC) (GLenum op, GLuint dst, GLuint dstMask, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod); -typedef void (GLAPIENTRY * PFNGLCOLORFRAGMENTOP2ATIPROC) (GLenum op, GLuint dst, GLuint dstMask, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod, GLuint arg2, GLuint arg2Rep, GLuint arg2Mod); -typedef void (GLAPIENTRY * 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 (GLAPIENTRY * PFNGLDELETEFRAGMENTSHADERATIPROC) (GLuint id); -typedef void (GLAPIENTRY * PFNGLENDFRAGMENTSHADERATIPROC) (void); -typedef GLuint (GLAPIENTRY * PFNGLGENFRAGMENTSHADERSATIPROC) (GLuint range); -typedef void (GLAPIENTRY * PFNGLPASSTEXCOORDATIPROC) (GLuint dst, GLuint coord, GLenum swizzle); -typedef void (GLAPIENTRY * PFNGLSAMPLEMAPATIPROC) (GLuint dst, GLuint interp, GLenum swizzle); -typedef void (GLAPIENTRY * PFNGLSETFRAGMENTSHADERCONSTANTATIPROC) (GLuint dst, const GLfloat* value); - -#define glAlphaFragmentOp1ATI GLEW_GET_FUN(__glewAlphaFragmentOp1ATI) -#define glAlphaFragmentOp2ATI GLEW_GET_FUN(__glewAlphaFragmentOp2ATI) -#define glAlphaFragmentOp3ATI GLEW_GET_FUN(__glewAlphaFragmentOp3ATI) -#define glBeginFragmentShaderATI GLEW_GET_FUN(__glewBeginFragmentShaderATI) -#define glBindFragmentShaderATI GLEW_GET_FUN(__glewBindFragmentShaderATI) -#define glColorFragmentOp1ATI GLEW_GET_FUN(__glewColorFragmentOp1ATI) -#define glColorFragmentOp2ATI GLEW_GET_FUN(__glewColorFragmentOp2ATI) -#define glColorFragmentOp3ATI GLEW_GET_FUN(__glewColorFragmentOp3ATI) -#define glDeleteFragmentShaderATI GLEW_GET_FUN(__glewDeleteFragmentShaderATI) -#define glEndFragmentShaderATI GLEW_GET_FUN(__glewEndFragmentShaderATI) -#define glGenFragmentShadersATI GLEW_GET_FUN(__glewGenFragmentShadersATI) -#define glPassTexCoordATI GLEW_GET_FUN(__glewPassTexCoordATI) -#define glSampleMapATI GLEW_GET_FUN(__glewSampleMapATI) -#define glSetFragmentShaderConstantATI GLEW_GET_FUN(__glewSetFragmentShaderConstantATI) - -#define GLEW_ATI_fragment_shader GLEW_GET_VAR(__GLEW_ATI_fragment_shader) - -#endif /* GL_ATI_fragment_shader */ - -/* ------------------------ GL_ATI_map_object_buffer ----------------------- */ - -#ifndef GL_ATI_map_object_buffer -#define GL_ATI_map_object_buffer 1 - -typedef void * (GLAPIENTRY * PFNGLMAPOBJECTBUFFERATIPROC) (GLuint buffer); -typedef void (GLAPIENTRY * PFNGLUNMAPOBJECTBUFFERATIPROC) (GLuint buffer); - -#define glMapObjectBufferATI GLEW_GET_FUN(__glewMapObjectBufferATI) -#define glUnmapObjectBufferATI GLEW_GET_FUN(__glewUnmapObjectBufferATI) - -#define GLEW_ATI_map_object_buffer GLEW_GET_VAR(__GLEW_ATI_map_object_buffer) - -#endif /* GL_ATI_map_object_buffer */ - -/* ----------------------------- GL_ATI_meminfo ---------------------------- */ - -#ifndef GL_ATI_meminfo -#define GL_ATI_meminfo 1 - -#define GL_VBO_FREE_MEMORY_ATI 0x87FB -#define GL_TEXTURE_FREE_MEMORY_ATI 0x87FC -#define GL_RENDERBUFFER_FREE_MEMORY_ATI 0x87FD - -#define GLEW_ATI_meminfo GLEW_GET_VAR(__GLEW_ATI_meminfo) - -#endif /* GL_ATI_meminfo */ - -/* -------------------------- GL_ATI_pn_triangles -------------------------- */ - -#ifndef GL_ATI_pn_triangles -#define GL_ATI_pn_triangles 1 - -#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 - -typedef void (GLAPIENTRY * PFNGLPNTRIANGLESFATIPROC) (GLenum pname, GLfloat param); -typedef void (GLAPIENTRY * PFNGLPNTRIANGLESIATIPROC) (GLenum pname, GLint param); - -#define glPNTrianglesfATI GLEW_GET_FUN(__glewPNTrianglesfATI) -#define glPNTrianglesiATI GLEW_GET_FUN(__glewPNTrianglesiATI) - -#define GLEW_ATI_pn_triangles GLEW_GET_VAR(__GLEW_ATI_pn_triangles) - -#endif /* GL_ATI_pn_triangles */ - -/* ------------------------ GL_ATI_separate_stencil ------------------------ */ - -#ifndef GL_ATI_separate_stencil -#define GL_ATI_separate_stencil 1 - -#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 - -typedef void (GLAPIENTRY * PFNGLSTENCILFUNCSEPARATEATIPROC) (GLenum frontfunc, GLenum backfunc, GLint ref, GLuint mask); -typedef void (GLAPIENTRY * PFNGLSTENCILOPSEPARATEATIPROC) (GLenum face, GLenum sfail, GLenum dpfail, GLenum dppass); - -#define glStencilFuncSeparateATI GLEW_GET_FUN(__glewStencilFuncSeparateATI) -#define glStencilOpSeparateATI GLEW_GET_FUN(__glewStencilOpSeparateATI) - -#define GLEW_ATI_separate_stencil GLEW_GET_VAR(__GLEW_ATI_separate_stencil) - -#endif /* GL_ATI_separate_stencil */ - -/* ----------------------- GL_ATI_shader_texture_lod ----------------------- */ - -#ifndef GL_ATI_shader_texture_lod -#define GL_ATI_shader_texture_lod 1 - -#define GLEW_ATI_shader_texture_lod GLEW_GET_VAR(__GLEW_ATI_shader_texture_lod) - -#endif /* GL_ATI_shader_texture_lod */ - -/* ---------------------- GL_ATI_text_fragment_shader ---------------------- */ - -#ifndef GL_ATI_text_fragment_shader -#define GL_ATI_text_fragment_shader 1 - -#define GL_TEXT_FRAGMENT_SHADER_ATI 0x8200 - -#define GLEW_ATI_text_fragment_shader GLEW_GET_VAR(__GLEW_ATI_text_fragment_shader) - -#endif /* GL_ATI_text_fragment_shader */ - -/* --------------------- GL_ATI_texture_compression_3dc -------------------- */ - -#ifndef GL_ATI_texture_compression_3dc -#define GL_ATI_texture_compression_3dc 1 - -#define GL_COMPRESSED_LUMINANCE_ALPHA_3DC_ATI 0x8837 - -#define GLEW_ATI_texture_compression_3dc GLEW_GET_VAR(__GLEW_ATI_texture_compression_3dc) - -#endif /* GL_ATI_texture_compression_3dc */ - -/* ---------------------- GL_ATI_texture_env_combine3 ---------------------- */ - -#ifndef GL_ATI_texture_env_combine3 -#define GL_ATI_texture_env_combine3 1 - -#define GL_MODULATE_ADD_ATI 0x8744 -#define GL_MODULATE_SIGNED_ADD_ATI 0x8745 -#define GL_MODULATE_SUBTRACT_ATI 0x8746 - -#define GLEW_ATI_texture_env_combine3 GLEW_GET_VAR(__GLEW_ATI_texture_env_combine3) - -#endif /* GL_ATI_texture_env_combine3 */ - -/* -------------------------- GL_ATI_texture_float ------------------------- */ - -#ifndef GL_ATI_texture_float -#define GL_ATI_texture_float 1 - -#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 - -#define GLEW_ATI_texture_float GLEW_GET_VAR(__GLEW_ATI_texture_float) - -#endif /* GL_ATI_texture_float */ - -/* ----------------------- GL_ATI_texture_mirror_once ---------------------- */ - -#ifndef GL_ATI_texture_mirror_once -#define GL_ATI_texture_mirror_once 1 - -#define GL_MIRROR_CLAMP_ATI 0x8742 -#define GL_MIRROR_CLAMP_TO_EDGE_ATI 0x8743 - -#define GLEW_ATI_texture_mirror_once GLEW_GET_VAR(__GLEW_ATI_texture_mirror_once) - -#endif /* GL_ATI_texture_mirror_once */ - -/* ----------------------- GL_ATI_vertex_array_object ---------------------- */ - -#ifndef GL_ATI_vertex_array_object -#define GL_ATI_vertex_array_object 1 - -#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 - -typedef void (GLAPIENTRY * PFNGLARRAYOBJECTATIPROC) (GLenum array, GLint size, GLenum type, GLsizei stride, GLuint buffer, GLuint offset); -typedef void (GLAPIENTRY * PFNGLFREEOBJECTBUFFERATIPROC) (GLuint buffer); -typedef void (GLAPIENTRY * PFNGLGETARRAYOBJECTFVATIPROC) (GLenum array, GLenum pname, GLfloat* params); -typedef void (GLAPIENTRY * PFNGLGETARRAYOBJECTIVATIPROC) (GLenum array, GLenum pname, GLint* params); -typedef void (GLAPIENTRY * PFNGLGETOBJECTBUFFERFVATIPROC) (GLuint buffer, GLenum pname, GLfloat* params); -typedef void (GLAPIENTRY * PFNGLGETOBJECTBUFFERIVATIPROC) (GLuint buffer, GLenum pname, GLint* params); -typedef void (GLAPIENTRY * PFNGLGETVARIANTARRAYOBJECTFVATIPROC) (GLuint id, GLenum pname, GLfloat* params); -typedef void (GLAPIENTRY * PFNGLGETVARIANTARRAYOBJECTIVATIPROC) (GLuint id, GLenum pname, GLint* params); -typedef GLboolean (GLAPIENTRY * PFNGLISOBJECTBUFFERATIPROC) (GLuint buffer); -typedef GLuint (GLAPIENTRY * PFNGLNEWOBJECTBUFFERATIPROC) (GLsizei size, const void *pointer, GLenum usage); -typedef void (GLAPIENTRY * PFNGLUPDATEOBJECTBUFFERATIPROC) (GLuint buffer, GLuint offset, GLsizei size, const void *pointer, GLenum preserve); -typedef void (GLAPIENTRY * PFNGLVARIANTARRAYOBJECTATIPROC) (GLuint id, GLenum type, GLsizei stride, GLuint buffer, GLuint offset); - -#define glArrayObjectATI GLEW_GET_FUN(__glewArrayObjectATI) -#define glFreeObjectBufferATI GLEW_GET_FUN(__glewFreeObjectBufferATI) -#define glGetArrayObjectfvATI GLEW_GET_FUN(__glewGetArrayObjectfvATI) -#define glGetArrayObjectivATI GLEW_GET_FUN(__glewGetArrayObjectivATI) -#define glGetObjectBufferfvATI GLEW_GET_FUN(__glewGetObjectBufferfvATI) -#define glGetObjectBufferivATI GLEW_GET_FUN(__glewGetObjectBufferivATI) -#define glGetVariantArrayObjectfvATI GLEW_GET_FUN(__glewGetVariantArrayObjectfvATI) -#define glGetVariantArrayObjectivATI GLEW_GET_FUN(__glewGetVariantArrayObjectivATI) -#define glIsObjectBufferATI GLEW_GET_FUN(__glewIsObjectBufferATI) -#define glNewObjectBufferATI GLEW_GET_FUN(__glewNewObjectBufferATI) -#define glUpdateObjectBufferATI GLEW_GET_FUN(__glewUpdateObjectBufferATI) -#define glVariantArrayObjectATI GLEW_GET_FUN(__glewVariantArrayObjectATI) - -#define GLEW_ATI_vertex_array_object GLEW_GET_VAR(__GLEW_ATI_vertex_array_object) - -#endif /* GL_ATI_vertex_array_object */ - -/* ------------------- GL_ATI_vertex_attrib_array_object ------------------- */ - -#ifndef GL_ATI_vertex_attrib_array_object -#define GL_ATI_vertex_attrib_array_object 1 - -typedef void (GLAPIENTRY * PFNGLGETVERTEXATTRIBARRAYOBJECTFVATIPROC) (GLuint index, GLenum pname, GLfloat* params); -typedef void (GLAPIENTRY * PFNGLGETVERTEXATTRIBARRAYOBJECTIVATIPROC) (GLuint index, GLenum pname, GLint* params); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBARRAYOBJECTATIPROC) (GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, GLuint buffer, GLuint offset); - -#define glGetVertexAttribArrayObjectfvATI GLEW_GET_FUN(__glewGetVertexAttribArrayObjectfvATI) -#define glGetVertexAttribArrayObjectivATI GLEW_GET_FUN(__glewGetVertexAttribArrayObjectivATI) -#define glVertexAttribArrayObjectATI GLEW_GET_FUN(__glewVertexAttribArrayObjectATI) - -#define GLEW_ATI_vertex_attrib_array_object GLEW_GET_VAR(__GLEW_ATI_vertex_attrib_array_object) - -#endif /* GL_ATI_vertex_attrib_array_object */ - -/* ------------------------- GL_ATI_vertex_streams ------------------------- */ - -#ifndef GL_ATI_vertex_streams -#define GL_ATI_vertex_streams 1 - -#define GL_MAX_VERTEX_STREAMS_ATI 0x876B -#define GL_VERTEX_SOURCE_ATI 0x876C -#define GL_VERTEX_STREAM0_ATI 0x876D -#define GL_VERTEX_STREAM1_ATI 0x876E -#define GL_VERTEX_STREAM2_ATI 0x876F -#define GL_VERTEX_STREAM3_ATI 0x8770 -#define GL_VERTEX_STREAM4_ATI 0x8771 -#define GL_VERTEX_STREAM5_ATI 0x8772 -#define GL_VERTEX_STREAM6_ATI 0x8773 -#define GL_VERTEX_STREAM7_ATI 0x8774 - -typedef void (GLAPIENTRY * PFNGLCLIENTACTIVEVERTEXSTREAMATIPROC) (GLenum stream); -typedef void (GLAPIENTRY * PFNGLNORMALSTREAM3BATIPROC) (GLenum stream, GLbyte x, GLbyte y, GLbyte z); -typedef void (GLAPIENTRY * PFNGLNORMALSTREAM3BVATIPROC) (GLenum stream, const GLbyte *coords); -typedef void (GLAPIENTRY * PFNGLNORMALSTREAM3DATIPROC) (GLenum stream, GLdouble x, GLdouble y, GLdouble z); -typedef void (GLAPIENTRY * PFNGLNORMALSTREAM3DVATIPROC) (GLenum stream, const GLdouble *coords); -typedef void (GLAPIENTRY * PFNGLNORMALSTREAM3FATIPROC) (GLenum stream, GLfloat x, GLfloat y, GLfloat z); -typedef void (GLAPIENTRY * PFNGLNORMALSTREAM3FVATIPROC) (GLenum stream, const GLfloat *coords); -typedef void (GLAPIENTRY * PFNGLNORMALSTREAM3IATIPROC) (GLenum stream, GLint x, GLint y, GLint z); -typedef void (GLAPIENTRY * PFNGLNORMALSTREAM3IVATIPROC) (GLenum stream, const GLint *coords); -typedef void (GLAPIENTRY * PFNGLNORMALSTREAM3SATIPROC) (GLenum stream, GLshort x, GLshort y, GLshort z); -typedef void (GLAPIENTRY * PFNGLNORMALSTREAM3SVATIPROC) (GLenum stream, const GLshort *coords); -typedef void (GLAPIENTRY * PFNGLVERTEXBLENDENVFATIPROC) (GLenum pname, GLfloat param); -typedef void (GLAPIENTRY * PFNGLVERTEXBLENDENVIATIPROC) (GLenum pname, GLint param); -typedef void (GLAPIENTRY * PFNGLVERTEXSTREAM1DATIPROC) (GLenum stream, GLdouble x); -typedef void (GLAPIENTRY * PFNGLVERTEXSTREAM1DVATIPROC) (GLenum stream, const GLdouble *coords); -typedef void (GLAPIENTRY * PFNGLVERTEXSTREAM1FATIPROC) (GLenum stream, GLfloat x); -typedef void (GLAPIENTRY * PFNGLVERTEXSTREAM1FVATIPROC) (GLenum stream, const GLfloat *coords); -typedef void (GLAPIENTRY * PFNGLVERTEXSTREAM1IATIPROC) (GLenum stream, GLint x); -typedef void (GLAPIENTRY * PFNGLVERTEXSTREAM1IVATIPROC) (GLenum stream, const GLint *coords); -typedef void (GLAPIENTRY * PFNGLVERTEXSTREAM1SATIPROC) (GLenum stream, GLshort x); -typedef void (GLAPIENTRY * PFNGLVERTEXSTREAM1SVATIPROC) (GLenum stream, const GLshort *coords); -typedef void (GLAPIENTRY * PFNGLVERTEXSTREAM2DATIPROC) (GLenum stream, GLdouble x, GLdouble y); -typedef void (GLAPIENTRY * PFNGLVERTEXSTREAM2DVATIPROC) (GLenum stream, const GLdouble *coords); -typedef void (GLAPIENTRY * PFNGLVERTEXSTREAM2FATIPROC) (GLenum stream, GLfloat x, GLfloat y); -typedef void (GLAPIENTRY * PFNGLVERTEXSTREAM2FVATIPROC) (GLenum stream, const GLfloat *coords); -typedef void (GLAPIENTRY * PFNGLVERTEXSTREAM2IATIPROC) (GLenum stream, GLint x, GLint y); -typedef void (GLAPIENTRY * PFNGLVERTEXSTREAM2IVATIPROC) (GLenum stream, const GLint *coords); -typedef void (GLAPIENTRY * PFNGLVERTEXSTREAM2SATIPROC) (GLenum stream, GLshort x, GLshort y); -typedef void (GLAPIENTRY * PFNGLVERTEXSTREAM2SVATIPROC) (GLenum stream, const GLshort *coords); -typedef void (GLAPIENTRY * PFNGLVERTEXSTREAM3DATIPROC) (GLenum stream, GLdouble x, GLdouble y, GLdouble z); -typedef void (GLAPIENTRY * PFNGLVERTEXSTREAM3DVATIPROC) (GLenum stream, const GLdouble *coords); -typedef void (GLAPIENTRY * PFNGLVERTEXSTREAM3FATIPROC) (GLenum stream, GLfloat x, GLfloat y, GLfloat z); -typedef void (GLAPIENTRY * PFNGLVERTEXSTREAM3FVATIPROC) (GLenum stream, const GLfloat *coords); -typedef void (GLAPIENTRY * PFNGLVERTEXSTREAM3IATIPROC) (GLenum stream, GLint x, GLint y, GLint z); -typedef void (GLAPIENTRY * PFNGLVERTEXSTREAM3IVATIPROC) (GLenum stream, const GLint *coords); -typedef void (GLAPIENTRY * PFNGLVERTEXSTREAM3SATIPROC) (GLenum stream, GLshort x, GLshort y, GLshort z); -typedef void (GLAPIENTRY * PFNGLVERTEXSTREAM3SVATIPROC) (GLenum stream, const GLshort *coords); -typedef void (GLAPIENTRY * PFNGLVERTEXSTREAM4DATIPROC) (GLenum stream, GLdouble x, GLdouble y, GLdouble z, GLdouble w); -typedef void (GLAPIENTRY * PFNGLVERTEXSTREAM4DVATIPROC) (GLenum stream, const GLdouble *coords); -typedef void (GLAPIENTRY * PFNGLVERTEXSTREAM4FATIPROC) (GLenum stream, GLfloat x, GLfloat y, GLfloat z, GLfloat w); -typedef void (GLAPIENTRY * PFNGLVERTEXSTREAM4FVATIPROC) (GLenum stream, const GLfloat *coords); -typedef void (GLAPIENTRY * PFNGLVERTEXSTREAM4IATIPROC) (GLenum stream, GLint x, GLint y, GLint z, GLint w); -typedef void (GLAPIENTRY * PFNGLVERTEXSTREAM4IVATIPROC) (GLenum stream, const GLint *coords); -typedef void (GLAPIENTRY * PFNGLVERTEXSTREAM4SATIPROC) (GLenum stream, GLshort x, GLshort y, GLshort z, GLshort w); -typedef void (GLAPIENTRY * PFNGLVERTEXSTREAM4SVATIPROC) (GLenum stream, const GLshort *coords); - -#define glClientActiveVertexStreamATI GLEW_GET_FUN(__glewClientActiveVertexStreamATI) -#define glNormalStream3bATI GLEW_GET_FUN(__glewNormalStream3bATI) -#define glNormalStream3bvATI GLEW_GET_FUN(__glewNormalStream3bvATI) -#define glNormalStream3dATI GLEW_GET_FUN(__glewNormalStream3dATI) -#define glNormalStream3dvATI GLEW_GET_FUN(__glewNormalStream3dvATI) -#define glNormalStream3fATI GLEW_GET_FUN(__glewNormalStream3fATI) -#define glNormalStream3fvATI GLEW_GET_FUN(__glewNormalStream3fvATI) -#define glNormalStream3iATI GLEW_GET_FUN(__glewNormalStream3iATI) -#define glNormalStream3ivATI GLEW_GET_FUN(__glewNormalStream3ivATI) -#define glNormalStream3sATI GLEW_GET_FUN(__glewNormalStream3sATI) -#define glNormalStream3svATI GLEW_GET_FUN(__glewNormalStream3svATI) -#define glVertexBlendEnvfATI GLEW_GET_FUN(__glewVertexBlendEnvfATI) -#define glVertexBlendEnviATI GLEW_GET_FUN(__glewVertexBlendEnviATI) -#define glVertexStream1dATI GLEW_GET_FUN(__glewVertexStream1dATI) -#define glVertexStream1dvATI GLEW_GET_FUN(__glewVertexStream1dvATI) -#define glVertexStream1fATI GLEW_GET_FUN(__glewVertexStream1fATI) -#define glVertexStream1fvATI GLEW_GET_FUN(__glewVertexStream1fvATI) -#define glVertexStream1iATI GLEW_GET_FUN(__glewVertexStream1iATI) -#define glVertexStream1ivATI GLEW_GET_FUN(__glewVertexStream1ivATI) -#define glVertexStream1sATI GLEW_GET_FUN(__glewVertexStream1sATI) -#define glVertexStream1svATI GLEW_GET_FUN(__glewVertexStream1svATI) -#define glVertexStream2dATI GLEW_GET_FUN(__glewVertexStream2dATI) -#define glVertexStream2dvATI GLEW_GET_FUN(__glewVertexStream2dvATI) -#define glVertexStream2fATI GLEW_GET_FUN(__glewVertexStream2fATI) -#define glVertexStream2fvATI GLEW_GET_FUN(__glewVertexStream2fvATI) -#define glVertexStream2iATI GLEW_GET_FUN(__glewVertexStream2iATI) -#define glVertexStream2ivATI GLEW_GET_FUN(__glewVertexStream2ivATI) -#define glVertexStream2sATI GLEW_GET_FUN(__glewVertexStream2sATI) -#define glVertexStream2svATI GLEW_GET_FUN(__glewVertexStream2svATI) -#define glVertexStream3dATI GLEW_GET_FUN(__glewVertexStream3dATI) -#define glVertexStream3dvATI GLEW_GET_FUN(__glewVertexStream3dvATI) -#define glVertexStream3fATI GLEW_GET_FUN(__glewVertexStream3fATI) -#define glVertexStream3fvATI GLEW_GET_FUN(__glewVertexStream3fvATI) -#define glVertexStream3iATI GLEW_GET_FUN(__glewVertexStream3iATI) -#define glVertexStream3ivATI GLEW_GET_FUN(__glewVertexStream3ivATI) -#define glVertexStream3sATI GLEW_GET_FUN(__glewVertexStream3sATI) -#define glVertexStream3svATI GLEW_GET_FUN(__glewVertexStream3svATI) -#define glVertexStream4dATI GLEW_GET_FUN(__glewVertexStream4dATI) -#define glVertexStream4dvATI GLEW_GET_FUN(__glewVertexStream4dvATI) -#define glVertexStream4fATI GLEW_GET_FUN(__glewVertexStream4fATI) -#define glVertexStream4fvATI GLEW_GET_FUN(__glewVertexStream4fvATI) -#define glVertexStream4iATI GLEW_GET_FUN(__glewVertexStream4iATI) -#define glVertexStream4ivATI GLEW_GET_FUN(__glewVertexStream4ivATI) -#define glVertexStream4sATI GLEW_GET_FUN(__glewVertexStream4sATI) -#define glVertexStream4svATI GLEW_GET_FUN(__glewVertexStream4svATI) - -#define GLEW_ATI_vertex_streams GLEW_GET_VAR(__GLEW_ATI_vertex_streams) - -#endif /* GL_ATI_vertex_streams */ - -/* ---------------- GL_EGL_NV_robustness_video_memory_purge ---------------- */ - -#ifndef GL_EGL_NV_robustness_video_memory_purge -#define GL_EGL_NV_robustness_video_memory_purge 1 - -#define GL_EGL_GENERATE_RESET_ON_VIDEO_MEMORY_PURGE_NV 0x334C -#define GL_PURGED_CONTEXT_RESET_NV 0x92BB - -#define GLEW_EGL_NV_robustness_video_memory_purge GLEW_GET_VAR(__GLEW_EGL_NV_robustness_video_memory_purge) - -#endif /* GL_EGL_NV_robustness_video_memory_purge */ - -/* --------------------------- GL_EXT_422_pixels --------------------------- */ - -#ifndef GL_EXT_422_pixels -#define GL_EXT_422_pixels 1 - -#define GL_422_EXT 0x80CC -#define GL_422_REV_EXT 0x80CD -#define GL_422_AVERAGE_EXT 0x80CE -#define GL_422_REV_AVERAGE_EXT 0x80CF - -#define GLEW_EXT_422_pixels GLEW_GET_VAR(__GLEW_EXT_422_pixels) - -#endif /* GL_EXT_422_pixels */ - -/* ---------------------------- GL_EXT_Cg_shader --------------------------- */ - -#ifndef GL_EXT_Cg_shader -#define GL_EXT_Cg_shader 1 - -#define GL_CG_VERTEX_SHADER_EXT 0x890E -#define GL_CG_FRAGMENT_SHADER_EXT 0x890F - -#define GLEW_EXT_Cg_shader GLEW_GET_VAR(__GLEW_EXT_Cg_shader) - -#endif /* GL_EXT_Cg_shader */ - -/* ------------------------------ GL_EXT_abgr ------------------------------ */ - -#ifndef GL_EXT_abgr -#define GL_EXT_abgr 1 - -#define GL_ABGR_EXT 0x8000 - -#define GLEW_EXT_abgr GLEW_GET_VAR(__GLEW_EXT_abgr) - -#endif /* GL_EXT_abgr */ - -/* ------------------------------ GL_EXT_bgra ------------------------------ */ - -#ifndef GL_EXT_bgra -#define GL_EXT_bgra 1 - -#define GL_BGR_EXT 0x80E0 -#define GL_BGRA_EXT 0x80E1 - -#define GLEW_EXT_bgra GLEW_GET_VAR(__GLEW_EXT_bgra) - -#endif /* GL_EXT_bgra */ - -/* ------------------------ GL_EXT_bindable_uniform ------------------------ */ - -#ifndef GL_EXT_bindable_uniform -#define GL_EXT_bindable_uniform 1 - -#define GL_MAX_VERTEX_BINDABLE_UNIFORMS_EXT 0x8DE2 -#define GL_MAX_FRAGMENT_BINDABLE_UNIFORMS_EXT 0x8DE3 -#define GL_MAX_GEOMETRY_BINDABLE_UNIFORMS_EXT 0x8DE4 -#define GL_MAX_BINDABLE_UNIFORM_SIZE_EXT 0x8DED -#define GL_UNIFORM_BUFFER_EXT 0x8DEE -#define GL_UNIFORM_BUFFER_BINDING_EXT 0x8DEF - -typedef GLint (GLAPIENTRY * PFNGLGETUNIFORMBUFFERSIZEEXTPROC) (GLuint program, GLint location); -typedef GLintptr (GLAPIENTRY * PFNGLGETUNIFORMOFFSETEXTPROC) (GLuint program, GLint location); -typedef void (GLAPIENTRY * PFNGLUNIFORMBUFFEREXTPROC) (GLuint program, GLint location, GLuint buffer); - -#define glGetUniformBufferSizeEXT GLEW_GET_FUN(__glewGetUniformBufferSizeEXT) -#define glGetUniformOffsetEXT GLEW_GET_FUN(__glewGetUniformOffsetEXT) -#define glUniformBufferEXT GLEW_GET_FUN(__glewUniformBufferEXT) - -#define GLEW_EXT_bindable_uniform GLEW_GET_VAR(__GLEW_EXT_bindable_uniform) - -#endif /* GL_EXT_bindable_uniform */ - -/* --------------------------- GL_EXT_blend_color -------------------------- */ - -#ifndef GL_EXT_blend_color -#define GL_EXT_blend_color 1 - -#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 - -typedef void (GLAPIENTRY * PFNGLBLENDCOLOREXTPROC) (GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha); - -#define glBlendColorEXT GLEW_GET_FUN(__glewBlendColorEXT) - -#define GLEW_EXT_blend_color GLEW_GET_VAR(__GLEW_EXT_blend_color) - -#endif /* GL_EXT_blend_color */ - -/* --------------------- GL_EXT_blend_equation_separate -------------------- */ - -#ifndef GL_EXT_blend_equation_separate -#define GL_EXT_blend_equation_separate 1 - -#define GL_BLEND_EQUATION_RGB_EXT 0x8009 -#define GL_BLEND_EQUATION_ALPHA_EXT 0x883D - -typedef void (GLAPIENTRY * PFNGLBLENDEQUATIONSEPARATEEXTPROC) (GLenum modeRGB, GLenum modeAlpha); - -#define glBlendEquationSeparateEXT GLEW_GET_FUN(__glewBlendEquationSeparateEXT) - -#define GLEW_EXT_blend_equation_separate GLEW_GET_VAR(__GLEW_EXT_blend_equation_separate) - -#endif /* GL_EXT_blend_equation_separate */ - -/* ----------------------- GL_EXT_blend_func_separate ---------------------- */ - -#ifndef GL_EXT_blend_func_separate -#define GL_EXT_blend_func_separate 1 - -#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 - -typedef void (GLAPIENTRY * PFNGLBLENDFUNCSEPARATEEXTPROC) (GLenum sfactorRGB, GLenum dfactorRGB, GLenum sfactorAlpha, GLenum dfactorAlpha); - -#define glBlendFuncSeparateEXT GLEW_GET_FUN(__glewBlendFuncSeparateEXT) - -#define GLEW_EXT_blend_func_separate GLEW_GET_VAR(__GLEW_EXT_blend_func_separate) - -#endif /* GL_EXT_blend_func_separate */ - -/* ------------------------- GL_EXT_blend_logic_op ------------------------- */ - -#ifndef GL_EXT_blend_logic_op -#define GL_EXT_blend_logic_op 1 - -#define GLEW_EXT_blend_logic_op GLEW_GET_VAR(__GLEW_EXT_blend_logic_op) - -#endif /* GL_EXT_blend_logic_op */ - -/* -------------------------- GL_EXT_blend_minmax -------------------------- */ - -#ifndef GL_EXT_blend_minmax -#define GL_EXT_blend_minmax 1 - -#define GL_FUNC_ADD_EXT 0x8006 -#define GL_MIN_EXT 0x8007 -#define GL_MAX_EXT 0x8008 -#define GL_BLEND_EQUATION_EXT 0x8009 - -typedef void (GLAPIENTRY * PFNGLBLENDEQUATIONEXTPROC) (GLenum mode); - -#define glBlendEquationEXT GLEW_GET_FUN(__glewBlendEquationEXT) - -#define GLEW_EXT_blend_minmax GLEW_GET_VAR(__GLEW_EXT_blend_minmax) - -#endif /* GL_EXT_blend_minmax */ - -/* ------------------------- GL_EXT_blend_subtract ------------------------- */ - -#ifndef GL_EXT_blend_subtract -#define GL_EXT_blend_subtract 1 - -#define GL_FUNC_SUBTRACT_EXT 0x800A -#define GL_FUNC_REVERSE_SUBTRACT_EXT 0x800B - -#define GLEW_EXT_blend_subtract GLEW_GET_VAR(__GLEW_EXT_blend_subtract) - -#endif /* GL_EXT_blend_subtract */ - -/* ------------------------ GL_EXT_clip_volume_hint ------------------------ */ - -#ifndef GL_EXT_clip_volume_hint -#define GL_EXT_clip_volume_hint 1 - -#define GL_CLIP_VOLUME_CLIPPING_HINT_EXT 0x80F0 - -#define GLEW_EXT_clip_volume_hint GLEW_GET_VAR(__GLEW_EXT_clip_volume_hint) - -#endif /* GL_EXT_clip_volume_hint */ - -/* ------------------------------ GL_EXT_cmyka ----------------------------- */ - -#ifndef GL_EXT_cmyka -#define GL_EXT_cmyka 1 - -#define GL_CMYK_EXT 0x800C -#define GL_CMYKA_EXT 0x800D -#define GL_PACK_CMYK_HINT_EXT 0x800E -#define GL_UNPACK_CMYK_HINT_EXT 0x800F - -#define GLEW_EXT_cmyka GLEW_GET_VAR(__GLEW_EXT_cmyka) - -#endif /* GL_EXT_cmyka */ - -/* ------------------------- GL_EXT_color_subtable ------------------------- */ - -#ifndef GL_EXT_color_subtable -#define GL_EXT_color_subtable 1 - -typedef void (GLAPIENTRY * PFNGLCOLORSUBTABLEEXTPROC) (GLenum target, GLsizei start, GLsizei count, GLenum format, GLenum type, const void *data); -typedef void (GLAPIENTRY * PFNGLCOPYCOLORSUBTABLEEXTPROC) (GLenum target, GLsizei start, GLint x, GLint y, GLsizei width); - -#define glColorSubTableEXT GLEW_GET_FUN(__glewColorSubTableEXT) -#define glCopyColorSubTableEXT GLEW_GET_FUN(__glewCopyColorSubTableEXT) - -#define GLEW_EXT_color_subtable GLEW_GET_VAR(__GLEW_EXT_color_subtable) - -#endif /* GL_EXT_color_subtable */ - -/* ---------------------- GL_EXT_compiled_vertex_array --------------------- */ - -#ifndef GL_EXT_compiled_vertex_array -#define GL_EXT_compiled_vertex_array 1 - -#define GL_ARRAY_ELEMENT_LOCK_FIRST_EXT 0x81A8 -#define GL_ARRAY_ELEMENT_LOCK_COUNT_EXT 0x81A9 - -typedef void (GLAPIENTRY * PFNGLLOCKARRAYSEXTPROC) (GLint first, GLsizei count); -typedef void (GLAPIENTRY * PFNGLUNLOCKARRAYSEXTPROC) (void); - -#define glLockArraysEXT GLEW_GET_FUN(__glewLockArraysEXT) -#define glUnlockArraysEXT GLEW_GET_FUN(__glewUnlockArraysEXT) - -#define GLEW_EXT_compiled_vertex_array GLEW_GET_VAR(__GLEW_EXT_compiled_vertex_array) - -#endif /* GL_EXT_compiled_vertex_array */ - -/* --------------------------- GL_EXT_convolution -------------------------- */ - -#ifndef GL_EXT_convolution -#define GL_EXT_convolution 1 - -#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 - -typedef void (GLAPIENTRY * PFNGLCONVOLUTIONFILTER1DEXTPROC) (GLenum target, GLenum internalformat, GLsizei width, GLenum format, GLenum type, const void *image); -typedef void (GLAPIENTRY * PFNGLCONVOLUTIONFILTER2DEXTPROC) (GLenum target, GLenum internalformat, GLsizei width, GLsizei height, GLenum format, GLenum type, const void *image); -typedef void (GLAPIENTRY * PFNGLCONVOLUTIONPARAMETERFEXTPROC) (GLenum target, GLenum pname, GLfloat param); -typedef void (GLAPIENTRY * PFNGLCONVOLUTIONPARAMETERFVEXTPROC) (GLenum target, GLenum pname, const GLfloat* params); -typedef void (GLAPIENTRY * PFNGLCONVOLUTIONPARAMETERIEXTPROC) (GLenum target, GLenum pname, GLint param); -typedef void (GLAPIENTRY * PFNGLCONVOLUTIONPARAMETERIVEXTPROC) (GLenum target, GLenum pname, const GLint* params); -typedef void (GLAPIENTRY * PFNGLCOPYCONVOLUTIONFILTER1DEXTPROC) (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width); -typedef void (GLAPIENTRY * PFNGLCOPYCONVOLUTIONFILTER2DEXTPROC) (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height); -typedef void (GLAPIENTRY * PFNGLGETCONVOLUTIONFILTEREXTPROC) (GLenum target, GLenum format, GLenum type, void *image); -typedef void (GLAPIENTRY * PFNGLGETCONVOLUTIONPARAMETERFVEXTPROC) (GLenum target, GLenum pname, GLfloat* params); -typedef void (GLAPIENTRY * PFNGLGETCONVOLUTIONPARAMETERIVEXTPROC) (GLenum target, GLenum pname, GLint* params); -typedef void (GLAPIENTRY * PFNGLGETSEPARABLEFILTEREXTPROC) (GLenum target, GLenum format, GLenum type, void *row, void *column, void *span); -typedef void (GLAPIENTRY * PFNGLSEPARABLEFILTER2DEXTPROC) (GLenum target, GLenum internalformat, GLsizei width, GLsizei height, GLenum format, GLenum type, const void *row, const void *column); - -#define glConvolutionFilter1DEXT GLEW_GET_FUN(__glewConvolutionFilter1DEXT) -#define glConvolutionFilter2DEXT GLEW_GET_FUN(__glewConvolutionFilter2DEXT) -#define glConvolutionParameterfEXT GLEW_GET_FUN(__glewConvolutionParameterfEXT) -#define glConvolutionParameterfvEXT GLEW_GET_FUN(__glewConvolutionParameterfvEXT) -#define glConvolutionParameteriEXT GLEW_GET_FUN(__glewConvolutionParameteriEXT) -#define glConvolutionParameterivEXT GLEW_GET_FUN(__glewConvolutionParameterivEXT) -#define glCopyConvolutionFilter1DEXT GLEW_GET_FUN(__glewCopyConvolutionFilter1DEXT) -#define glCopyConvolutionFilter2DEXT GLEW_GET_FUN(__glewCopyConvolutionFilter2DEXT) -#define glGetConvolutionFilterEXT GLEW_GET_FUN(__glewGetConvolutionFilterEXT) -#define glGetConvolutionParameterfvEXT GLEW_GET_FUN(__glewGetConvolutionParameterfvEXT) -#define glGetConvolutionParameterivEXT GLEW_GET_FUN(__glewGetConvolutionParameterivEXT) -#define glGetSeparableFilterEXT GLEW_GET_FUN(__glewGetSeparableFilterEXT) -#define glSeparableFilter2DEXT GLEW_GET_FUN(__glewSeparableFilter2DEXT) - -#define GLEW_EXT_convolution GLEW_GET_VAR(__GLEW_EXT_convolution) - -#endif /* GL_EXT_convolution */ - -/* ------------------------ GL_EXT_coordinate_frame ------------------------ */ - -#ifndef GL_EXT_coordinate_frame -#define GL_EXT_coordinate_frame 1 - -#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 - -typedef void (GLAPIENTRY * PFNGLBINORMALPOINTEREXTPROC) (GLenum type, GLsizei stride, void *pointer); -typedef void (GLAPIENTRY * PFNGLTANGENTPOINTEREXTPROC) (GLenum type, GLsizei stride, void *pointer); - -#define glBinormalPointerEXT GLEW_GET_FUN(__glewBinormalPointerEXT) -#define glTangentPointerEXT GLEW_GET_FUN(__glewTangentPointerEXT) - -#define GLEW_EXT_coordinate_frame GLEW_GET_VAR(__GLEW_EXT_coordinate_frame) - -#endif /* GL_EXT_coordinate_frame */ - -/* -------------------------- GL_EXT_copy_texture -------------------------- */ - -#ifndef GL_EXT_copy_texture -#define GL_EXT_copy_texture 1 - -typedef void (GLAPIENTRY * PFNGLCOPYTEXIMAGE1DEXTPROC) (GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLint border); -typedef void (GLAPIENTRY * PFNGLCOPYTEXIMAGE2DEXTPROC) (GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border); -typedef void (GLAPIENTRY * PFNGLCOPYTEXSUBIMAGE1DEXTPROC) (GLenum target, GLint level, GLint xoffset, GLint x, GLint y, GLsizei width); -typedef void (GLAPIENTRY * PFNGLCOPYTEXSUBIMAGE2DEXTPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height); -typedef void (GLAPIENTRY * PFNGLCOPYTEXSUBIMAGE3DEXTPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height); - -#define glCopyTexImage1DEXT GLEW_GET_FUN(__glewCopyTexImage1DEXT) -#define glCopyTexImage2DEXT GLEW_GET_FUN(__glewCopyTexImage2DEXT) -#define glCopyTexSubImage1DEXT GLEW_GET_FUN(__glewCopyTexSubImage1DEXT) -#define glCopyTexSubImage2DEXT GLEW_GET_FUN(__glewCopyTexSubImage2DEXT) -#define glCopyTexSubImage3DEXT GLEW_GET_FUN(__glewCopyTexSubImage3DEXT) - -#define GLEW_EXT_copy_texture GLEW_GET_VAR(__GLEW_EXT_copy_texture) - -#endif /* GL_EXT_copy_texture */ - -/* --------------------------- GL_EXT_cull_vertex -------------------------- */ - -#ifndef GL_EXT_cull_vertex -#define GL_EXT_cull_vertex 1 - -#define GL_CULL_VERTEX_EXT 0x81AA -#define GL_CULL_VERTEX_EYE_POSITION_EXT 0x81AB -#define GL_CULL_VERTEX_OBJECT_POSITION_EXT 0x81AC - -typedef void (GLAPIENTRY * PFNGLCULLPARAMETERDVEXTPROC) (GLenum pname, GLdouble* params); -typedef void (GLAPIENTRY * PFNGLCULLPARAMETERFVEXTPROC) (GLenum pname, GLfloat* params); - -#define glCullParameterdvEXT GLEW_GET_FUN(__glewCullParameterdvEXT) -#define glCullParameterfvEXT GLEW_GET_FUN(__glewCullParameterfvEXT) - -#define GLEW_EXT_cull_vertex GLEW_GET_VAR(__GLEW_EXT_cull_vertex) - -#endif /* GL_EXT_cull_vertex */ - -/* --------------------------- GL_EXT_debug_label -------------------------- */ - -#ifndef GL_EXT_debug_label -#define GL_EXT_debug_label 1 - -#define GL_PROGRAM_PIPELINE_OBJECT_EXT 0x8A4F -#define GL_PROGRAM_OBJECT_EXT 0x8B40 -#define GL_SHADER_OBJECT_EXT 0x8B48 -#define GL_BUFFER_OBJECT_EXT 0x9151 -#define GL_QUERY_OBJECT_EXT 0x9153 -#define GL_VERTEX_ARRAY_OBJECT_EXT 0x9154 - -typedef void (GLAPIENTRY * PFNGLGETOBJECTLABELEXTPROC) (GLenum type, GLuint object, GLsizei bufSize, GLsizei* length, GLchar *label); -typedef void (GLAPIENTRY * PFNGLLABELOBJECTEXTPROC) (GLenum type, GLuint object, GLsizei length, const GLchar* label); - -#define glGetObjectLabelEXT GLEW_GET_FUN(__glewGetObjectLabelEXT) -#define glLabelObjectEXT GLEW_GET_FUN(__glewLabelObjectEXT) - -#define GLEW_EXT_debug_label GLEW_GET_VAR(__GLEW_EXT_debug_label) - -#endif /* GL_EXT_debug_label */ - -/* -------------------------- GL_EXT_debug_marker -------------------------- */ - -#ifndef GL_EXT_debug_marker -#define GL_EXT_debug_marker 1 - -typedef void (GLAPIENTRY * PFNGLINSERTEVENTMARKEREXTPROC) (GLsizei length, const GLchar* marker); -typedef void (GLAPIENTRY * PFNGLPOPGROUPMARKEREXTPROC) (void); -typedef void (GLAPIENTRY * PFNGLPUSHGROUPMARKEREXTPROC) (GLsizei length, const GLchar* marker); - -#define glInsertEventMarkerEXT GLEW_GET_FUN(__glewInsertEventMarkerEXT) -#define glPopGroupMarkerEXT GLEW_GET_FUN(__glewPopGroupMarkerEXT) -#define glPushGroupMarkerEXT GLEW_GET_FUN(__glewPushGroupMarkerEXT) - -#define GLEW_EXT_debug_marker GLEW_GET_VAR(__GLEW_EXT_debug_marker) - -#endif /* GL_EXT_debug_marker */ - -/* ------------------------ GL_EXT_depth_bounds_test ----------------------- */ - -#ifndef GL_EXT_depth_bounds_test -#define GL_EXT_depth_bounds_test 1 - -#define GL_DEPTH_BOUNDS_TEST_EXT 0x8890 -#define GL_DEPTH_BOUNDS_EXT 0x8891 - -typedef void (GLAPIENTRY * PFNGLDEPTHBOUNDSEXTPROC) (GLclampd zmin, GLclampd zmax); - -#define glDepthBoundsEXT GLEW_GET_FUN(__glewDepthBoundsEXT) - -#define GLEW_EXT_depth_bounds_test GLEW_GET_VAR(__GLEW_EXT_depth_bounds_test) - -#endif /* GL_EXT_depth_bounds_test */ - -/* ----------------------- GL_EXT_direct_state_access ---------------------- */ - -#ifndef GL_EXT_direct_state_access -#define GL_EXT_direct_state_access 1 - -#define GL_PROGRAM_MATRIX_EXT 0x8E2D -#define GL_TRANSPOSE_PROGRAM_MATRIX_EXT 0x8E2E -#define GL_PROGRAM_MATRIX_STACK_DEPTH_EXT 0x8E2F - -typedef void (GLAPIENTRY * PFNGLBINDMULTITEXTUREEXTPROC) (GLenum texunit, GLenum target, GLuint texture); -typedef GLenum (GLAPIENTRY * PFNGLCHECKNAMEDFRAMEBUFFERSTATUSEXTPROC) (GLuint framebuffer, GLenum target); -typedef void (GLAPIENTRY * PFNGLCLIENTATTRIBDEFAULTEXTPROC) (GLbitfield mask); -typedef void (GLAPIENTRY * PFNGLCOMPRESSEDMULTITEXIMAGE1DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLsizei imageSize, const void *data); -typedef void (GLAPIENTRY * PFNGLCOMPRESSEDMULTITEXIMAGE2DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const void *data); -typedef void (GLAPIENTRY * PFNGLCOMPRESSEDMULTITEXIMAGE3DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const void *data); -typedef void (GLAPIENTRY * PFNGLCOMPRESSEDMULTITEXSUBIMAGE1DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLsizei imageSize, const void *data); -typedef void (GLAPIENTRY * PFNGLCOMPRESSEDMULTITEXSUBIMAGE2DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const void *data); -typedef void (GLAPIENTRY * PFNGLCOMPRESSEDMULTITEXSUBIMAGE3DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const void *data); -typedef void (GLAPIENTRY * PFNGLCOMPRESSEDTEXTUREIMAGE1DEXTPROC) (GLuint texture, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLsizei imageSize, const void *data); -typedef void (GLAPIENTRY * PFNGLCOMPRESSEDTEXTUREIMAGE2DEXTPROC) (GLuint texture, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const void *data); -typedef void (GLAPIENTRY * PFNGLCOMPRESSEDTEXTUREIMAGE3DEXTPROC) (GLuint texture, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const void *data); -typedef void (GLAPIENTRY * PFNGLCOMPRESSEDTEXTURESUBIMAGE1DEXTPROC) (GLuint texture, GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLsizei imageSize, const void *data); -typedef void (GLAPIENTRY * PFNGLCOMPRESSEDTEXTURESUBIMAGE2DEXTPROC) (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const void *data); -typedef void (GLAPIENTRY * PFNGLCOMPRESSEDTEXTURESUBIMAGE3DEXTPROC) (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const void *data); -typedef void (GLAPIENTRY * PFNGLCOPYMULTITEXIMAGE1DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLint border); -typedef void (GLAPIENTRY * PFNGLCOPYMULTITEXIMAGE2DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border); -typedef void (GLAPIENTRY * PFNGLCOPYMULTITEXSUBIMAGE1DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint x, GLint y, GLsizei width); -typedef void (GLAPIENTRY * PFNGLCOPYMULTITEXSUBIMAGE2DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height); -typedef void (GLAPIENTRY * PFNGLCOPYMULTITEXSUBIMAGE3DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height); -typedef void (GLAPIENTRY * PFNGLCOPYTEXTUREIMAGE1DEXTPROC) (GLuint texture, GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLint border); -typedef void (GLAPIENTRY * PFNGLCOPYTEXTUREIMAGE2DEXTPROC) (GLuint texture, GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border); -typedef void (GLAPIENTRY * PFNGLCOPYTEXTURESUBIMAGE1DEXTPROC) (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint x, GLint y, GLsizei width); -typedef void (GLAPIENTRY * PFNGLCOPYTEXTURESUBIMAGE2DEXTPROC) (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height); -typedef void (GLAPIENTRY * PFNGLCOPYTEXTURESUBIMAGE3DEXTPROC) (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height); -typedef void (GLAPIENTRY * PFNGLDISABLECLIENTSTATEINDEXEDEXTPROC) (GLenum array, GLuint index); -typedef void (GLAPIENTRY * PFNGLDISABLECLIENTSTATEIEXTPROC) (GLenum array, GLuint index); -typedef void (GLAPIENTRY * PFNGLDISABLEVERTEXARRAYATTRIBEXTPROC) (GLuint vaobj, GLuint index); -typedef void (GLAPIENTRY * PFNGLDISABLEVERTEXARRAYEXTPROC) (GLuint vaobj, GLenum array); -typedef void (GLAPIENTRY * PFNGLENABLECLIENTSTATEINDEXEDEXTPROC) (GLenum array, GLuint index); -typedef void (GLAPIENTRY * PFNGLENABLECLIENTSTATEIEXTPROC) (GLenum array, GLuint index); -typedef void (GLAPIENTRY * PFNGLENABLEVERTEXARRAYATTRIBEXTPROC) (GLuint vaobj, GLuint index); -typedef void (GLAPIENTRY * PFNGLENABLEVERTEXARRAYEXTPROC) (GLuint vaobj, GLenum array); -typedef void (GLAPIENTRY * PFNGLFLUSHMAPPEDNAMEDBUFFERRANGEEXTPROC) (GLuint buffer, GLintptr offset, GLsizeiptr length); -typedef void (GLAPIENTRY * PFNGLFRAMEBUFFERDRAWBUFFEREXTPROC) (GLuint framebuffer, GLenum mode); -typedef void (GLAPIENTRY * PFNGLFRAMEBUFFERDRAWBUFFERSEXTPROC) (GLuint framebuffer, GLsizei n, const GLenum* bufs); -typedef void (GLAPIENTRY * PFNGLFRAMEBUFFERREADBUFFEREXTPROC) (GLuint framebuffer, GLenum mode); -typedef void (GLAPIENTRY * PFNGLGENERATEMULTITEXMIPMAPEXTPROC) (GLenum texunit, GLenum target); -typedef void (GLAPIENTRY * PFNGLGENERATETEXTUREMIPMAPEXTPROC) (GLuint texture, GLenum target); -typedef void (GLAPIENTRY * PFNGLGETCOMPRESSEDMULTITEXIMAGEEXTPROC) (GLenum texunit, GLenum target, GLint level, void *img); -typedef void (GLAPIENTRY * PFNGLGETCOMPRESSEDTEXTUREIMAGEEXTPROC) (GLuint texture, GLenum target, GLint level, void *img); -typedef void (GLAPIENTRY * PFNGLGETDOUBLEINDEXEDVEXTPROC) (GLenum target, GLuint index, GLdouble* params); -typedef void (GLAPIENTRY * PFNGLGETDOUBLEI_VEXTPROC) (GLenum pname, GLuint index, GLdouble* params); -typedef void (GLAPIENTRY * PFNGLGETFLOATINDEXEDVEXTPROC) (GLenum target, GLuint index, GLfloat* params); -typedef void (GLAPIENTRY * PFNGLGETFLOATI_VEXTPROC) (GLenum pname, GLuint index, GLfloat* params); -typedef void (GLAPIENTRY * PFNGLGETFRAMEBUFFERPARAMETERIVEXTPROC) (GLuint framebuffer, GLenum pname, GLint* param); -typedef void (GLAPIENTRY * PFNGLGETMULTITEXENVFVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, GLfloat* params); -typedef void (GLAPIENTRY * PFNGLGETMULTITEXENVIVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, GLint* params); -typedef void (GLAPIENTRY * PFNGLGETMULTITEXGENDVEXTPROC) (GLenum texunit, GLenum coord, GLenum pname, GLdouble* params); -typedef void (GLAPIENTRY * PFNGLGETMULTITEXGENFVEXTPROC) (GLenum texunit, GLenum coord, GLenum pname, GLfloat* params); -typedef void (GLAPIENTRY * PFNGLGETMULTITEXGENIVEXTPROC) (GLenum texunit, GLenum coord, GLenum pname, GLint* params); -typedef void (GLAPIENTRY * PFNGLGETMULTITEXIMAGEEXTPROC) (GLenum texunit, GLenum target, GLint level, GLenum format, GLenum type, void *pixels); -typedef void (GLAPIENTRY * PFNGLGETMULTITEXLEVELPARAMETERFVEXTPROC) (GLenum texunit, GLenum target, GLint level, GLenum pname, GLfloat* params); -typedef void (GLAPIENTRY * PFNGLGETMULTITEXLEVELPARAMETERIVEXTPROC) (GLenum texunit, GLenum target, GLint level, GLenum pname, GLint* params); -typedef void (GLAPIENTRY * PFNGLGETMULTITEXPARAMETERIIVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, GLint* params); -typedef void (GLAPIENTRY * PFNGLGETMULTITEXPARAMETERIUIVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, GLuint* params); -typedef void (GLAPIENTRY * PFNGLGETMULTITEXPARAMETERFVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, GLfloat* params); -typedef void (GLAPIENTRY * PFNGLGETMULTITEXPARAMETERIVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, GLint* params); -typedef void (GLAPIENTRY * PFNGLGETNAMEDBUFFERPARAMETERIVEXTPROC) (GLuint buffer, GLenum pname, GLint* params); -typedef void (GLAPIENTRY * PFNGLGETNAMEDBUFFERPOINTERVEXTPROC) (GLuint buffer, GLenum pname, void** params); -typedef void (GLAPIENTRY * PFNGLGETNAMEDBUFFERSUBDATAEXTPROC) (GLuint buffer, GLintptr offset, GLsizeiptr size, void *data); -typedef void (GLAPIENTRY * PFNGLGETNAMEDFRAMEBUFFERATTACHMENTPARAMETERIVEXTPROC) (GLuint framebuffer, GLenum attachment, GLenum pname, GLint* params); -typedef void (GLAPIENTRY * PFNGLGETNAMEDPROGRAMLOCALPARAMETERIIVEXTPROC) (GLuint program, GLenum target, GLuint index, GLint* params); -typedef void (GLAPIENTRY * PFNGLGETNAMEDPROGRAMLOCALPARAMETERIUIVEXTPROC) (GLuint program, GLenum target, GLuint index, GLuint* params); -typedef void (GLAPIENTRY * PFNGLGETNAMEDPROGRAMLOCALPARAMETERDVEXTPROC) (GLuint program, GLenum target, GLuint index, GLdouble* params); -typedef void (GLAPIENTRY * PFNGLGETNAMEDPROGRAMLOCALPARAMETERFVEXTPROC) (GLuint program, GLenum target, GLuint index, GLfloat* params); -typedef void (GLAPIENTRY * PFNGLGETNAMEDPROGRAMSTRINGEXTPROC) (GLuint program, GLenum target, GLenum pname, void *string); -typedef void (GLAPIENTRY * PFNGLGETNAMEDPROGRAMIVEXTPROC) (GLuint program, GLenum target, GLenum pname, GLint* params); -typedef void (GLAPIENTRY * PFNGLGETNAMEDRENDERBUFFERPARAMETERIVEXTPROC) (GLuint renderbuffer, GLenum pname, GLint* params); -typedef void (GLAPIENTRY * PFNGLGETPOINTERINDEXEDVEXTPROC) (GLenum target, GLuint index, void** params); -typedef void (GLAPIENTRY * PFNGLGETPOINTERI_VEXTPROC) (GLenum pname, GLuint index, void** params); -typedef void (GLAPIENTRY * PFNGLGETTEXTUREIMAGEEXTPROC) (GLuint texture, GLenum target, GLint level, GLenum format, GLenum type, void *pixels); -typedef void (GLAPIENTRY * PFNGLGETTEXTURELEVELPARAMETERFVEXTPROC) (GLuint texture, GLenum target, GLint level, GLenum pname, GLfloat* params); -typedef void (GLAPIENTRY * PFNGLGETTEXTURELEVELPARAMETERIVEXTPROC) (GLuint texture, GLenum target, GLint level, GLenum pname, GLint* params); -typedef void (GLAPIENTRY * PFNGLGETTEXTUREPARAMETERIIVEXTPROC) (GLuint texture, GLenum target, GLenum pname, GLint* params); -typedef void (GLAPIENTRY * PFNGLGETTEXTUREPARAMETERIUIVEXTPROC) (GLuint texture, GLenum target, GLenum pname, GLuint* params); -typedef void (GLAPIENTRY * PFNGLGETTEXTUREPARAMETERFVEXTPROC) (GLuint texture, GLenum target, GLenum pname, GLfloat* params); -typedef void (GLAPIENTRY * PFNGLGETTEXTUREPARAMETERIVEXTPROC) (GLuint texture, GLenum target, GLenum pname, GLint* params); -typedef void (GLAPIENTRY * PFNGLGETVERTEXARRAYINTEGERI_VEXTPROC) (GLuint vaobj, GLuint index, GLenum pname, GLint* param); -typedef void (GLAPIENTRY * PFNGLGETVERTEXARRAYINTEGERVEXTPROC) (GLuint vaobj, GLenum pname, GLint* param); -typedef void (GLAPIENTRY * PFNGLGETVERTEXARRAYPOINTERI_VEXTPROC) (GLuint vaobj, GLuint index, GLenum pname, void** param); -typedef void (GLAPIENTRY * PFNGLGETVERTEXARRAYPOINTERVEXTPROC) (GLuint vaobj, GLenum pname, void** param); -typedef void * (GLAPIENTRY * PFNGLMAPNAMEDBUFFEREXTPROC) (GLuint buffer, GLenum access); -typedef void * (GLAPIENTRY * PFNGLMAPNAMEDBUFFERRANGEEXTPROC) (GLuint buffer, GLintptr offset, GLsizeiptr length, GLbitfield access); -typedef void (GLAPIENTRY * PFNGLMATRIXFRUSTUMEXTPROC) (GLenum matrixMode, GLdouble l, GLdouble r, GLdouble b, GLdouble t, GLdouble n, GLdouble f); -typedef void (GLAPIENTRY * PFNGLMATRIXLOADIDENTITYEXTPROC) (GLenum matrixMode); -typedef void (GLAPIENTRY * PFNGLMATRIXLOADTRANSPOSEDEXTPROC) (GLenum matrixMode, const GLdouble* m); -typedef void (GLAPIENTRY * PFNGLMATRIXLOADTRANSPOSEFEXTPROC) (GLenum matrixMode, const GLfloat* m); -typedef void (GLAPIENTRY * PFNGLMATRIXLOADDEXTPROC) (GLenum matrixMode, const GLdouble* m); -typedef void (GLAPIENTRY * PFNGLMATRIXLOADFEXTPROC) (GLenum matrixMode, const GLfloat* m); -typedef void (GLAPIENTRY * PFNGLMATRIXMULTTRANSPOSEDEXTPROC) (GLenum matrixMode, const GLdouble* m); -typedef void (GLAPIENTRY * PFNGLMATRIXMULTTRANSPOSEFEXTPROC) (GLenum matrixMode, const GLfloat* m); -typedef void (GLAPIENTRY * PFNGLMATRIXMULTDEXTPROC) (GLenum matrixMode, const GLdouble* m); -typedef void (GLAPIENTRY * PFNGLMATRIXMULTFEXTPROC) (GLenum matrixMode, const GLfloat* m); -typedef void (GLAPIENTRY * PFNGLMATRIXORTHOEXTPROC) (GLenum matrixMode, GLdouble l, GLdouble r, GLdouble b, GLdouble t, GLdouble n, GLdouble f); -typedef void (GLAPIENTRY * PFNGLMATRIXPOPEXTPROC) (GLenum matrixMode); -typedef void (GLAPIENTRY * PFNGLMATRIXPUSHEXTPROC) (GLenum matrixMode); -typedef void (GLAPIENTRY * PFNGLMATRIXROTATEDEXTPROC) (GLenum matrixMode, GLdouble angle, GLdouble x, GLdouble y, GLdouble z); -typedef void (GLAPIENTRY * PFNGLMATRIXROTATEFEXTPROC) (GLenum matrixMode, GLfloat angle, GLfloat x, GLfloat y, GLfloat z); -typedef void (GLAPIENTRY * PFNGLMATRIXSCALEDEXTPROC) (GLenum matrixMode, GLdouble x, GLdouble y, GLdouble z); -typedef void (GLAPIENTRY * PFNGLMATRIXSCALEFEXTPROC) (GLenum matrixMode, GLfloat x, GLfloat y, GLfloat z); -typedef void (GLAPIENTRY * PFNGLMATRIXTRANSLATEDEXTPROC) (GLenum matrixMode, GLdouble x, GLdouble y, GLdouble z); -typedef void (GLAPIENTRY * PFNGLMATRIXTRANSLATEFEXTPROC) (GLenum matrixMode, GLfloat x, GLfloat y, GLfloat z); -typedef void (GLAPIENTRY * PFNGLMULTITEXBUFFEREXTPROC) (GLenum texunit, GLenum target, GLenum internalformat, GLuint buffer); -typedef void (GLAPIENTRY * PFNGLMULTITEXCOORDPOINTEREXTPROC) (GLenum texunit, GLint size, GLenum type, GLsizei stride, const void *pointer); -typedef void (GLAPIENTRY * PFNGLMULTITEXENVFEXTPROC) (GLenum texunit, GLenum target, GLenum pname, GLfloat param); -typedef void (GLAPIENTRY * PFNGLMULTITEXENVFVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, const GLfloat* params); -typedef void (GLAPIENTRY * PFNGLMULTITEXENVIEXTPROC) (GLenum texunit, GLenum target, GLenum pname, GLint param); -typedef void (GLAPIENTRY * PFNGLMULTITEXENVIVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, const GLint* params); -typedef void (GLAPIENTRY * PFNGLMULTITEXGENDEXTPROC) (GLenum texunit, GLenum coord, GLenum pname, GLdouble param); -typedef void (GLAPIENTRY * PFNGLMULTITEXGENDVEXTPROC) (GLenum texunit, GLenum coord, GLenum pname, const GLdouble* params); -typedef void (GLAPIENTRY * PFNGLMULTITEXGENFEXTPROC) (GLenum texunit, GLenum coord, GLenum pname, GLfloat param); -typedef void (GLAPIENTRY * PFNGLMULTITEXGENFVEXTPROC) (GLenum texunit, GLenum coord, GLenum pname, const GLfloat* params); -typedef void (GLAPIENTRY * PFNGLMULTITEXGENIEXTPROC) (GLenum texunit, GLenum coord, GLenum pname, GLint param); -typedef void (GLAPIENTRY * PFNGLMULTITEXGENIVEXTPROC) (GLenum texunit, GLenum coord, GLenum pname, const GLint* params); -typedef void (GLAPIENTRY * PFNGLMULTITEXIMAGE1DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLint internalformat, GLsizei width, GLint border, GLenum format, GLenum type, const void *pixels); -typedef void (GLAPIENTRY * PFNGLMULTITEXIMAGE2DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const void *pixels); -typedef void (GLAPIENTRY * PFNGLMULTITEXIMAGE3DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const void *pixels); -typedef void (GLAPIENTRY * PFNGLMULTITEXPARAMETERIIVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, const GLint* params); -typedef void (GLAPIENTRY * PFNGLMULTITEXPARAMETERIUIVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, const GLuint* params); -typedef void (GLAPIENTRY * PFNGLMULTITEXPARAMETERFEXTPROC) (GLenum texunit, GLenum target, GLenum pname, GLfloat param); -typedef void (GLAPIENTRY * PFNGLMULTITEXPARAMETERFVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, const GLfloat* param); -typedef void (GLAPIENTRY * PFNGLMULTITEXPARAMETERIEXTPROC) (GLenum texunit, GLenum target, GLenum pname, GLint param); -typedef void (GLAPIENTRY * PFNGLMULTITEXPARAMETERIVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, const GLint* param); -typedef void (GLAPIENTRY * PFNGLMULTITEXRENDERBUFFEREXTPROC) (GLenum texunit, GLenum target, GLuint renderbuffer); -typedef void (GLAPIENTRY * PFNGLMULTITEXSUBIMAGE1DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLenum type, const void *pixels); -typedef void (GLAPIENTRY * PFNGLMULTITEXSUBIMAGE2DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const void *pixels); -typedef void (GLAPIENTRY * PFNGLMULTITEXSUBIMAGE3DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const void *pixels); -typedef void (GLAPIENTRY * PFNGLNAMEDBUFFERDATAEXTPROC) (GLuint buffer, GLsizeiptr size, const void *data, GLenum usage); -typedef void (GLAPIENTRY * PFNGLNAMEDBUFFERSUBDATAEXTPROC) (GLuint buffer, GLintptr offset, GLsizeiptr size, const void *data); -typedef void (GLAPIENTRY * PFNGLNAMEDCOPYBUFFERSUBDATAEXTPROC) (GLuint readBuffer, GLuint writeBuffer, GLintptr readOffset, GLintptr writeOffset, GLsizeiptr size); -typedef void (GLAPIENTRY * PFNGLNAMEDFRAMEBUFFERRENDERBUFFEREXTPROC) (GLuint framebuffer, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer); -typedef void (GLAPIENTRY * PFNGLNAMEDFRAMEBUFFERTEXTURE1DEXTPROC) (GLuint framebuffer, GLenum attachment, GLenum textarget, GLuint texture, GLint level); -typedef void (GLAPIENTRY * PFNGLNAMEDFRAMEBUFFERTEXTURE2DEXTPROC) (GLuint framebuffer, GLenum attachment, GLenum textarget, GLuint texture, GLint level); -typedef void (GLAPIENTRY * PFNGLNAMEDFRAMEBUFFERTEXTURE3DEXTPROC) (GLuint framebuffer, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLint zoffset); -typedef void (GLAPIENTRY * PFNGLNAMEDFRAMEBUFFERTEXTUREEXTPROC) (GLuint framebuffer, GLenum attachment, GLuint texture, GLint level); -typedef void (GLAPIENTRY * PFNGLNAMEDFRAMEBUFFERTEXTUREFACEEXTPROC) (GLuint framebuffer, GLenum attachment, GLuint texture, GLint level, GLenum face); -typedef void (GLAPIENTRY * PFNGLNAMEDFRAMEBUFFERTEXTURELAYEREXTPROC) (GLuint framebuffer, GLenum attachment, GLuint texture, GLint level, GLint layer); -typedef void (GLAPIENTRY * PFNGLNAMEDPROGRAMLOCALPARAMETER4DEXTPROC) (GLuint program, GLenum target, GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); -typedef void (GLAPIENTRY * PFNGLNAMEDPROGRAMLOCALPARAMETER4DVEXTPROC) (GLuint program, GLenum target, GLuint index, const GLdouble* params); -typedef void (GLAPIENTRY * PFNGLNAMEDPROGRAMLOCALPARAMETER4FEXTPROC) (GLuint program, GLenum target, GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); -typedef void (GLAPIENTRY * PFNGLNAMEDPROGRAMLOCALPARAMETER4FVEXTPROC) (GLuint program, GLenum target, GLuint index, const GLfloat* params); -typedef void (GLAPIENTRY * PFNGLNAMEDPROGRAMLOCALPARAMETERI4IEXTPROC) (GLuint program, GLenum target, GLuint index, GLint x, GLint y, GLint z, GLint w); -typedef void (GLAPIENTRY * PFNGLNAMEDPROGRAMLOCALPARAMETERI4IVEXTPROC) (GLuint program, GLenum target, GLuint index, const GLint* params); -typedef void (GLAPIENTRY * PFNGLNAMEDPROGRAMLOCALPARAMETERI4UIEXTPROC) (GLuint program, GLenum target, GLuint index, GLuint x, GLuint y, GLuint z, GLuint w); -typedef void (GLAPIENTRY * PFNGLNAMEDPROGRAMLOCALPARAMETERI4UIVEXTPROC) (GLuint program, GLenum target, GLuint index, const GLuint* params); -typedef void (GLAPIENTRY * PFNGLNAMEDPROGRAMLOCALPARAMETERS4FVEXTPROC) (GLuint program, GLenum target, GLuint index, GLsizei count, const GLfloat* params); -typedef void (GLAPIENTRY * PFNGLNAMEDPROGRAMLOCALPARAMETERSI4IVEXTPROC) (GLuint program, GLenum target, GLuint index, GLsizei count, const GLint* params); -typedef void (GLAPIENTRY * PFNGLNAMEDPROGRAMLOCALPARAMETERSI4UIVEXTPROC) (GLuint program, GLenum target, GLuint index, GLsizei count, const GLuint* params); -typedef void (GLAPIENTRY * PFNGLNAMEDPROGRAMSTRINGEXTPROC) (GLuint program, GLenum target, GLenum format, GLsizei len, const void *string); -typedef void (GLAPIENTRY * PFNGLNAMEDRENDERBUFFERSTORAGEEXTPROC) (GLuint renderbuffer, GLenum internalformat, GLsizei width, GLsizei height); -typedef void (GLAPIENTRY * PFNGLNAMEDRENDERBUFFERSTORAGEMULTISAMPLECOVERAGEEXTPROC) (GLuint renderbuffer, GLsizei coverageSamples, GLsizei colorSamples, GLenum internalformat, GLsizei width, GLsizei height); -typedef void (GLAPIENTRY * PFNGLNAMEDRENDERBUFFERSTORAGEMULTISAMPLEEXTPROC) (GLuint renderbuffer, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height); -typedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM1FEXTPROC) (GLuint program, GLint location, GLfloat v0); -typedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM1FVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLfloat* value); -typedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM1IEXTPROC) (GLuint program, GLint location, GLint v0); -typedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM1IVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLint* value); -typedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM1UIEXTPROC) (GLuint program, GLint location, GLuint v0); -typedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM1UIVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLuint* value); -typedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM2FEXTPROC) (GLuint program, GLint location, GLfloat v0, GLfloat v1); -typedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM2FVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLfloat* value); -typedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM2IEXTPROC) (GLuint program, GLint location, GLint v0, GLint v1); -typedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM2IVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLint* value); -typedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM2UIEXTPROC) (GLuint program, GLint location, GLuint v0, GLuint v1); -typedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM2UIVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLuint* value); -typedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM3FEXTPROC) (GLuint program, GLint location, GLfloat v0, GLfloat v1, GLfloat v2); -typedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM3FVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLfloat* value); -typedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM3IEXTPROC) (GLuint program, GLint location, GLint v0, GLint v1, GLint v2); -typedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM3IVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLint* value); -typedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM3UIEXTPROC) (GLuint program, GLint location, GLuint v0, GLuint v1, GLuint v2); -typedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM3UIVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLuint* value); -typedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM4FEXTPROC) (GLuint program, GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3); -typedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM4FVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLfloat* value); -typedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM4IEXTPROC) (GLuint program, GLint location, GLint v0, GLint v1, GLint v2, GLint v3); -typedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM4IVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLint* value); -typedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM4UIEXTPROC) (GLuint program, GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3); -typedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM4UIVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLuint* value); -typedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORMMATRIX2FVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat* value); -typedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORMMATRIX2X3FVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat* value); -typedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORMMATRIX2X4FVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat* value); -typedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORMMATRIX3FVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat* value); -typedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORMMATRIX3X2FVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat* value); -typedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORMMATRIX3X4FVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat* value); -typedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORMMATRIX4FVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat* value); -typedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORMMATRIX4X2FVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat* value); -typedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORMMATRIX4X3FVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat* value); -typedef void (GLAPIENTRY * PFNGLPUSHCLIENTATTRIBDEFAULTEXTPROC) (GLbitfield mask); -typedef void (GLAPIENTRY * PFNGLTEXTUREBUFFEREXTPROC) (GLuint texture, GLenum target, GLenum internalformat, GLuint buffer); -typedef void (GLAPIENTRY * PFNGLTEXTUREIMAGE1DEXTPROC) (GLuint texture, GLenum target, GLint level, GLint internalformat, GLsizei width, GLint border, GLenum format, GLenum type, const void *pixels); -typedef void (GLAPIENTRY * PFNGLTEXTUREIMAGE2DEXTPROC) (GLuint texture, GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const void *pixels); -typedef void (GLAPIENTRY * PFNGLTEXTUREIMAGE3DEXTPROC) (GLuint texture, GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const void *pixels); -typedef void (GLAPIENTRY * PFNGLTEXTUREPARAMETERIIVEXTPROC) (GLuint texture, GLenum target, GLenum pname, const GLint* params); -typedef void (GLAPIENTRY * PFNGLTEXTUREPARAMETERIUIVEXTPROC) (GLuint texture, GLenum target, GLenum pname, const GLuint* params); -typedef void (GLAPIENTRY * PFNGLTEXTUREPARAMETERFEXTPROC) (GLuint texture, GLenum target, GLenum pname, GLfloat param); -typedef void (GLAPIENTRY * PFNGLTEXTUREPARAMETERFVEXTPROC) (GLuint texture, GLenum target, GLenum pname, const GLfloat* param); -typedef void (GLAPIENTRY * PFNGLTEXTUREPARAMETERIEXTPROC) (GLuint texture, GLenum target, GLenum pname, GLint param); -typedef void (GLAPIENTRY * PFNGLTEXTUREPARAMETERIVEXTPROC) (GLuint texture, GLenum target, GLenum pname, const GLint* param); -typedef void (GLAPIENTRY * PFNGLTEXTURERENDERBUFFEREXTPROC) (GLuint texture, GLenum target, GLuint renderbuffer); -typedef void (GLAPIENTRY * PFNGLTEXTURESUBIMAGE1DEXTPROC) (GLuint texture, GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLenum type, const void *pixels); -typedef void (GLAPIENTRY * PFNGLTEXTURESUBIMAGE2DEXTPROC) (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const void *pixels); -typedef void (GLAPIENTRY * PFNGLTEXTURESUBIMAGE3DEXTPROC) (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const void *pixels); -typedef GLboolean (GLAPIENTRY * PFNGLUNMAPNAMEDBUFFEREXTPROC) (GLuint buffer); -typedef void (GLAPIENTRY * PFNGLVERTEXARRAYCOLOROFFSETEXTPROC) (GLuint vaobj, GLuint buffer, GLint size, GLenum type, GLsizei stride, GLintptr offset); -typedef void (GLAPIENTRY * PFNGLVERTEXARRAYEDGEFLAGOFFSETEXTPROC) (GLuint vaobj, GLuint buffer, GLsizei stride, GLintptr offset); -typedef void (GLAPIENTRY * PFNGLVERTEXARRAYFOGCOORDOFFSETEXTPROC) (GLuint vaobj, GLuint buffer, GLenum type, GLsizei stride, GLintptr offset); -typedef void (GLAPIENTRY * PFNGLVERTEXARRAYINDEXOFFSETEXTPROC) (GLuint vaobj, GLuint buffer, GLenum type, GLsizei stride, GLintptr offset); -typedef void (GLAPIENTRY * PFNGLVERTEXARRAYMULTITEXCOORDOFFSETEXTPROC) (GLuint vaobj, GLuint buffer, GLenum texunit, GLint size, GLenum type, GLsizei stride, GLintptr offset); -typedef void (GLAPIENTRY * PFNGLVERTEXARRAYNORMALOFFSETEXTPROC) (GLuint vaobj, GLuint buffer, GLenum type, GLsizei stride, GLintptr offset); -typedef void (GLAPIENTRY * PFNGLVERTEXARRAYSECONDARYCOLOROFFSETEXTPROC) (GLuint vaobj, GLuint buffer, GLint size, GLenum type, GLsizei stride, GLintptr offset); -typedef void (GLAPIENTRY * PFNGLVERTEXARRAYTEXCOORDOFFSETEXTPROC) (GLuint vaobj, GLuint buffer, GLint size, GLenum type, GLsizei stride, GLintptr offset); -typedef void (GLAPIENTRY * PFNGLVERTEXARRAYVERTEXATTRIBDIVISOREXTPROC) (GLuint vaobj, GLuint index, GLuint divisor); -typedef void (GLAPIENTRY * PFNGLVERTEXARRAYVERTEXATTRIBIOFFSETEXTPROC) (GLuint vaobj, GLuint buffer, GLuint index, GLint size, GLenum type, GLsizei stride, GLintptr offset); -typedef void (GLAPIENTRY * PFNGLVERTEXARRAYVERTEXATTRIBOFFSETEXTPROC) (GLuint vaobj, GLuint buffer, GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, GLintptr offset); -typedef void (GLAPIENTRY * PFNGLVERTEXARRAYVERTEXOFFSETEXTPROC) (GLuint vaobj, GLuint buffer, GLint size, GLenum type, GLsizei stride, GLintptr offset); - -#define glBindMultiTextureEXT GLEW_GET_FUN(__glewBindMultiTextureEXT) -#define glCheckNamedFramebufferStatusEXT GLEW_GET_FUN(__glewCheckNamedFramebufferStatusEXT) -#define glClientAttribDefaultEXT GLEW_GET_FUN(__glewClientAttribDefaultEXT) -#define glCompressedMultiTexImage1DEXT GLEW_GET_FUN(__glewCompressedMultiTexImage1DEXT) -#define glCompressedMultiTexImage2DEXT GLEW_GET_FUN(__glewCompressedMultiTexImage2DEXT) -#define glCompressedMultiTexImage3DEXT GLEW_GET_FUN(__glewCompressedMultiTexImage3DEXT) -#define glCompressedMultiTexSubImage1DEXT GLEW_GET_FUN(__glewCompressedMultiTexSubImage1DEXT) -#define glCompressedMultiTexSubImage2DEXT GLEW_GET_FUN(__glewCompressedMultiTexSubImage2DEXT) -#define glCompressedMultiTexSubImage3DEXT GLEW_GET_FUN(__glewCompressedMultiTexSubImage3DEXT) -#define glCompressedTextureImage1DEXT GLEW_GET_FUN(__glewCompressedTextureImage1DEXT) -#define glCompressedTextureImage2DEXT GLEW_GET_FUN(__glewCompressedTextureImage2DEXT) -#define glCompressedTextureImage3DEXT GLEW_GET_FUN(__glewCompressedTextureImage3DEXT) -#define glCompressedTextureSubImage1DEXT GLEW_GET_FUN(__glewCompressedTextureSubImage1DEXT) -#define glCompressedTextureSubImage2DEXT GLEW_GET_FUN(__glewCompressedTextureSubImage2DEXT) -#define glCompressedTextureSubImage3DEXT GLEW_GET_FUN(__glewCompressedTextureSubImage3DEXT) -#define glCopyMultiTexImage1DEXT GLEW_GET_FUN(__glewCopyMultiTexImage1DEXT) -#define glCopyMultiTexImage2DEXT GLEW_GET_FUN(__glewCopyMultiTexImage2DEXT) -#define glCopyMultiTexSubImage1DEXT GLEW_GET_FUN(__glewCopyMultiTexSubImage1DEXT) -#define glCopyMultiTexSubImage2DEXT GLEW_GET_FUN(__glewCopyMultiTexSubImage2DEXT) -#define glCopyMultiTexSubImage3DEXT GLEW_GET_FUN(__glewCopyMultiTexSubImage3DEXT) -#define glCopyTextureImage1DEXT GLEW_GET_FUN(__glewCopyTextureImage1DEXT) -#define glCopyTextureImage2DEXT GLEW_GET_FUN(__glewCopyTextureImage2DEXT) -#define glCopyTextureSubImage1DEXT GLEW_GET_FUN(__glewCopyTextureSubImage1DEXT) -#define glCopyTextureSubImage2DEXT GLEW_GET_FUN(__glewCopyTextureSubImage2DEXT) -#define glCopyTextureSubImage3DEXT GLEW_GET_FUN(__glewCopyTextureSubImage3DEXT) -#define glDisableClientStateIndexedEXT GLEW_GET_FUN(__glewDisableClientStateIndexedEXT) -#define glDisableClientStateiEXT GLEW_GET_FUN(__glewDisableClientStateiEXT) -#define glDisableVertexArrayAttribEXT GLEW_GET_FUN(__glewDisableVertexArrayAttribEXT) -#define glDisableVertexArrayEXT GLEW_GET_FUN(__glewDisableVertexArrayEXT) -#define glEnableClientStateIndexedEXT GLEW_GET_FUN(__glewEnableClientStateIndexedEXT) -#define glEnableClientStateiEXT GLEW_GET_FUN(__glewEnableClientStateiEXT) -#define glEnableVertexArrayAttribEXT GLEW_GET_FUN(__glewEnableVertexArrayAttribEXT) -#define glEnableVertexArrayEXT GLEW_GET_FUN(__glewEnableVertexArrayEXT) -#define glFlushMappedNamedBufferRangeEXT GLEW_GET_FUN(__glewFlushMappedNamedBufferRangeEXT) -#define glFramebufferDrawBufferEXT GLEW_GET_FUN(__glewFramebufferDrawBufferEXT) -#define glFramebufferDrawBuffersEXT GLEW_GET_FUN(__glewFramebufferDrawBuffersEXT) -#define glFramebufferReadBufferEXT GLEW_GET_FUN(__glewFramebufferReadBufferEXT) -#define glGenerateMultiTexMipmapEXT GLEW_GET_FUN(__glewGenerateMultiTexMipmapEXT) -#define glGenerateTextureMipmapEXT GLEW_GET_FUN(__glewGenerateTextureMipmapEXT) -#define glGetCompressedMultiTexImageEXT GLEW_GET_FUN(__glewGetCompressedMultiTexImageEXT) -#define glGetCompressedTextureImageEXT GLEW_GET_FUN(__glewGetCompressedTextureImageEXT) -#define glGetDoubleIndexedvEXT GLEW_GET_FUN(__glewGetDoubleIndexedvEXT) -#define glGetDoublei_vEXT GLEW_GET_FUN(__glewGetDoublei_vEXT) -#define glGetFloatIndexedvEXT GLEW_GET_FUN(__glewGetFloatIndexedvEXT) -#define glGetFloati_vEXT GLEW_GET_FUN(__glewGetFloati_vEXT) -#define glGetFramebufferParameterivEXT GLEW_GET_FUN(__glewGetFramebufferParameterivEXT) -#define glGetMultiTexEnvfvEXT GLEW_GET_FUN(__glewGetMultiTexEnvfvEXT) -#define glGetMultiTexEnvivEXT GLEW_GET_FUN(__glewGetMultiTexEnvivEXT) -#define glGetMultiTexGendvEXT GLEW_GET_FUN(__glewGetMultiTexGendvEXT) -#define glGetMultiTexGenfvEXT GLEW_GET_FUN(__glewGetMultiTexGenfvEXT) -#define glGetMultiTexGenivEXT GLEW_GET_FUN(__glewGetMultiTexGenivEXT) -#define glGetMultiTexImageEXT GLEW_GET_FUN(__glewGetMultiTexImageEXT) -#define glGetMultiTexLevelParameterfvEXT GLEW_GET_FUN(__glewGetMultiTexLevelParameterfvEXT) -#define glGetMultiTexLevelParameterivEXT GLEW_GET_FUN(__glewGetMultiTexLevelParameterivEXT) -#define glGetMultiTexParameterIivEXT GLEW_GET_FUN(__glewGetMultiTexParameterIivEXT) -#define glGetMultiTexParameterIuivEXT GLEW_GET_FUN(__glewGetMultiTexParameterIuivEXT) -#define glGetMultiTexParameterfvEXT GLEW_GET_FUN(__glewGetMultiTexParameterfvEXT) -#define glGetMultiTexParameterivEXT GLEW_GET_FUN(__glewGetMultiTexParameterivEXT) -#define glGetNamedBufferParameterivEXT GLEW_GET_FUN(__glewGetNamedBufferParameterivEXT) -#define glGetNamedBufferPointervEXT GLEW_GET_FUN(__glewGetNamedBufferPointervEXT) -#define glGetNamedBufferSubDataEXT GLEW_GET_FUN(__glewGetNamedBufferSubDataEXT) -#define glGetNamedFramebufferAttachmentParameterivEXT GLEW_GET_FUN(__glewGetNamedFramebufferAttachmentParameterivEXT) -#define glGetNamedProgramLocalParameterIivEXT GLEW_GET_FUN(__glewGetNamedProgramLocalParameterIivEXT) -#define glGetNamedProgramLocalParameterIuivEXT GLEW_GET_FUN(__glewGetNamedProgramLocalParameterIuivEXT) -#define glGetNamedProgramLocalParameterdvEXT GLEW_GET_FUN(__glewGetNamedProgramLocalParameterdvEXT) -#define glGetNamedProgramLocalParameterfvEXT GLEW_GET_FUN(__glewGetNamedProgramLocalParameterfvEXT) -#define glGetNamedProgramStringEXT GLEW_GET_FUN(__glewGetNamedProgramStringEXT) -#define glGetNamedProgramivEXT GLEW_GET_FUN(__glewGetNamedProgramivEXT) -#define glGetNamedRenderbufferParameterivEXT GLEW_GET_FUN(__glewGetNamedRenderbufferParameterivEXT) -#define glGetPointerIndexedvEXT GLEW_GET_FUN(__glewGetPointerIndexedvEXT) -#define glGetPointeri_vEXT GLEW_GET_FUN(__glewGetPointeri_vEXT) -#define glGetTextureImageEXT GLEW_GET_FUN(__glewGetTextureImageEXT) -#define glGetTextureLevelParameterfvEXT GLEW_GET_FUN(__glewGetTextureLevelParameterfvEXT) -#define glGetTextureLevelParameterivEXT GLEW_GET_FUN(__glewGetTextureLevelParameterivEXT) -#define glGetTextureParameterIivEXT GLEW_GET_FUN(__glewGetTextureParameterIivEXT) -#define glGetTextureParameterIuivEXT GLEW_GET_FUN(__glewGetTextureParameterIuivEXT) -#define glGetTextureParameterfvEXT GLEW_GET_FUN(__glewGetTextureParameterfvEXT) -#define glGetTextureParameterivEXT GLEW_GET_FUN(__glewGetTextureParameterivEXT) -#define glGetVertexArrayIntegeri_vEXT GLEW_GET_FUN(__glewGetVertexArrayIntegeri_vEXT) -#define glGetVertexArrayIntegervEXT GLEW_GET_FUN(__glewGetVertexArrayIntegervEXT) -#define glGetVertexArrayPointeri_vEXT GLEW_GET_FUN(__glewGetVertexArrayPointeri_vEXT) -#define glGetVertexArrayPointervEXT GLEW_GET_FUN(__glewGetVertexArrayPointervEXT) -#define glMapNamedBufferEXT GLEW_GET_FUN(__glewMapNamedBufferEXT) -#define glMapNamedBufferRangeEXT GLEW_GET_FUN(__glewMapNamedBufferRangeEXT) -#define glMatrixFrustumEXT GLEW_GET_FUN(__glewMatrixFrustumEXT) -#define glMatrixLoadIdentityEXT GLEW_GET_FUN(__glewMatrixLoadIdentityEXT) -#define glMatrixLoadTransposedEXT GLEW_GET_FUN(__glewMatrixLoadTransposedEXT) -#define glMatrixLoadTransposefEXT GLEW_GET_FUN(__glewMatrixLoadTransposefEXT) -#define glMatrixLoaddEXT GLEW_GET_FUN(__glewMatrixLoaddEXT) -#define glMatrixLoadfEXT GLEW_GET_FUN(__glewMatrixLoadfEXT) -#define glMatrixMultTransposedEXT GLEW_GET_FUN(__glewMatrixMultTransposedEXT) -#define glMatrixMultTransposefEXT GLEW_GET_FUN(__glewMatrixMultTransposefEXT) -#define glMatrixMultdEXT GLEW_GET_FUN(__glewMatrixMultdEXT) -#define glMatrixMultfEXT GLEW_GET_FUN(__glewMatrixMultfEXT) -#define glMatrixOrthoEXT GLEW_GET_FUN(__glewMatrixOrthoEXT) -#define glMatrixPopEXT GLEW_GET_FUN(__glewMatrixPopEXT) -#define glMatrixPushEXT GLEW_GET_FUN(__glewMatrixPushEXT) -#define glMatrixRotatedEXT GLEW_GET_FUN(__glewMatrixRotatedEXT) -#define glMatrixRotatefEXT GLEW_GET_FUN(__glewMatrixRotatefEXT) -#define glMatrixScaledEXT GLEW_GET_FUN(__glewMatrixScaledEXT) -#define glMatrixScalefEXT GLEW_GET_FUN(__glewMatrixScalefEXT) -#define glMatrixTranslatedEXT GLEW_GET_FUN(__glewMatrixTranslatedEXT) -#define glMatrixTranslatefEXT GLEW_GET_FUN(__glewMatrixTranslatefEXT) -#define glMultiTexBufferEXT GLEW_GET_FUN(__glewMultiTexBufferEXT) -#define glMultiTexCoordPointerEXT GLEW_GET_FUN(__glewMultiTexCoordPointerEXT) -#define glMultiTexEnvfEXT GLEW_GET_FUN(__glewMultiTexEnvfEXT) -#define glMultiTexEnvfvEXT GLEW_GET_FUN(__glewMultiTexEnvfvEXT) -#define glMultiTexEnviEXT GLEW_GET_FUN(__glewMultiTexEnviEXT) -#define glMultiTexEnvivEXT GLEW_GET_FUN(__glewMultiTexEnvivEXT) -#define glMultiTexGendEXT GLEW_GET_FUN(__glewMultiTexGendEXT) -#define glMultiTexGendvEXT GLEW_GET_FUN(__glewMultiTexGendvEXT) -#define glMultiTexGenfEXT GLEW_GET_FUN(__glewMultiTexGenfEXT) -#define glMultiTexGenfvEXT GLEW_GET_FUN(__glewMultiTexGenfvEXT) -#define glMultiTexGeniEXT GLEW_GET_FUN(__glewMultiTexGeniEXT) -#define glMultiTexGenivEXT GLEW_GET_FUN(__glewMultiTexGenivEXT) -#define glMultiTexImage1DEXT GLEW_GET_FUN(__glewMultiTexImage1DEXT) -#define glMultiTexImage2DEXT GLEW_GET_FUN(__glewMultiTexImage2DEXT) -#define glMultiTexImage3DEXT GLEW_GET_FUN(__glewMultiTexImage3DEXT) -#define glMultiTexParameterIivEXT GLEW_GET_FUN(__glewMultiTexParameterIivEXT) -#define glMultiTexParameterIuivEXT GLEW_GET_FUN(__glewMultiTexParameterIuivEXT) -#define glMultiTexParameterfEXT GLEW_GET_FUN(__glewMultiTexParameterfEXT) -#define glMultiTexParameterfvEXT GLEW_GET_FUN(__glewMultiTexParameterfvEXT) -#define glMultiTexParameteriEXT GLEW_GET_FUN(__glewMultiTexParameteriEXT) -#define glMultiTexParameterivEXT GLEW_GET_FUN(__glewMultiTexParameterivEXT) -#define glMultiTexRenderbufferEXT GLEW_GET_FUN(__glewMultiTexRenderbufferEXT) -#define glMultiTexSubImage1DEXT GLEW_GET_FUN(__glewMultiTexSubImage1DEXT) -#define glMultiTexSubImage2DEXT GLEW_GET_FUN(__glewMultiTexSubImage2DEXT) -#define glMultiTexSubImage3DEXT GLEW_GET_FUN(__glewMultiTexSubImage3DEXT) -#define glNamedBufferDataEXT GLEW_GET_FUN(__glewNamedBufferDataEXT) -#define glNamedBufferSubDataEXT GLEW_GET_FUN(__glewNamedBufferSubDataEXT) -#define glNamedCopyBufferSubDataEXT GLEW_GET_FUN(__glewNamedCopyBufferSubDataEXT) -#define glNamedFramebufferRenderbufferEXT GLEW_GET_FUN(__glewNamedFramebufferRenderbufferEXT) -#define glNamedFramebufferTexture1DEXT GLEW_GET_FUN(__glewNamedFramebufferTexture1DEXT) -#define glNamedFramebufferTexture2DEXT GLEW_GET_FUN(__glewNamedFramebufferTexture2DEXT) -#define glNamedFramebufferTexture3DEXT GLEW_GET_FUN(__glewNamedFramebufferTexture3DEXT) -#define glNamedFramebufferTextureEXT GLEW_GET_FUN(__glewNamedFramebufferTextureEXT) -#define glNamedFramebufferTextureFaceEXT GLEW_GET_FUN(__glewNamedFramebufferTextureFaceEXT) -#define glNamedFramebufferTextureLayerEXT GLEW_GET_FUN(__glewNamedFramebufferTextureLayerEXT) -#define glNamedProgramLocalParameter4dEXT GLEW_GET_FUN(__glewNamedProgramLocalParameter4dEXT) -#define glNamedProgramLocalParameter4dvEXT GLEW_GET_FUN(__glewNamedProgramLocalParameter4dvEXT) -#define glNamedProgramLocalParameter4fEXT GLEW_GET_FUN(__glewNamedProgramLocalParameter4fEXT) -#define glNamedProgramLocalParameter4fvEXT GLEW_GET_FUN(__glewNamedProgramLocalParameter4fvEXT) -#define glNamedProgramLocalParameterI4iEXT GLEW_GET_FUN(__glewNamedProgramLocalParameterI4iEXT) -#define glNamedProgramLocalParameterI4ivEXT GLEW_GET_FUN(__glewNamedProgramLocalParameterI4ivEXT) -#define glNamedProgramLocalParameterI4uiEXT GLEW_GET_FUN(__glewNamedProgramLocalParameterI4uiEXT) -#define glNamedProgramLocalParameterI4uivEXT GLEW_GET_FUN(__glewNamedProgramLocalParameterI4uivEXT) -#define glNamedProgramLocalParameters4fvEXT GLEW_GET_FUN(__glewNamedProgramLocalParameters4fvEXT) -#define glNamedProgramLocalParametersI4ivEXT GLEW_GET_FUN(__glewNamedProgramLocalParametersI4ivEXT) -#define glNamedProgramLocalParametersI4uivEXT GLEW_GET_FUN(__glewNamedProgramLocalParametersI4uivEXT) -#define glNamedProgramStringEXT GLEW_GET_FUN(__glewNamedProgramStringEXT) -#define glNamedRenderbufferStorageEXT GLEW_GET_FUN(__glewNamedRenderbufferStorageEXT) -#define glNamedRenderbufferStorageMultisampleCoverageEXT GLEW_GET_FUN(__glewNamedRenderbufferStorageMultisampleCoverageEXT) -#define glNamedRenderbufferStorageMultisampleEXT GLEW_GET_FUN(__glewNamedRenderbufferStorageMultisampleEXT) -#define glProgramUniform1fEXT GLEW_GET_FUN(__glewProgramUniform1fEXT) -#define glProgramUniform1fvEXT GLEW_GET_FUN(__glewProgramUniform1fvEXT) -#define glProgramUniform1iEXT GLEW_GET_FUN(__glewProgramUniform1iEXT) -#define glProgramUniform1ivEXT GLEW_GET_FUN(__glewProgramUniform1ivEXT) -#define glProgramUniform1uiEXT GLEW_GET_FUN(__glewProgramUniform1uiEXT) -#define glProgramUniform1uivEXT GLEW_GET_FUN(__glewProgramUniform1uivEXT) -#define glProgramUniform2fEXT GLEW_GET_FUN(__glewProgramUniform2fEXT) -#define glProgramUniform2fvEXT GLEW_GET_FUN(__glewProgramUniform2fvEXT) -#define glProgramUniform2iEXT GLEW_GET_FUN(__glewProgramUniform2iEXT) -#define glProgramUniform2ivEXT GLEW_GET_FUN(__glewProgramUniform2ivEXT) -#define glProgramUniform2uiEXT GLEW_GET_FUN(__glewProgramUniform2uiEXT) -#define glProgramUniform2uivEXT GLEW_GET_FUN(__glewProgramUniform2uivEXT) -#define glProgramUniform3fEXT GLEW_GET_FUN(__glewProgramUniform3fEXT) -#define glProgramUniform3fvEXT GLEW_GET_FUN(__glewProgramUniform3fvEXT) -#define glProgramUniform3iEXT GLEW_GET_FUN(__glewProgramUniform3iEXT) -#define glProgramUniform3ivEXT GLEW_GET_FUN(__glewProgramUniform3ivEXT) -#define glProgramUniform3uiEXT GLEW_GET_FUN(__glewProgramUniform3uiEXT) -#define glProgramUniform3uivEXT GLEW_GET_FUN(__glewProgramUniform3uivEXT) -#define glProgramUniform4fEXT GLEW_GET_FUN(__glewProgramUniform4fEXT) -#define glProgramUniform4fvEXT GLEW_GET_FUN(__glewProgramUniform4fvEXT) -#define glProgramUniform4iEXT GLEW_GET_FUN(__glewProgramUniform4iEXT) -#define glProgramUniform4ivEXT GLEW_GET_FUN(__glewProgramUniform4ivEXT) -#define glProgramUniform4uiEXT GLEW_GET_FUN(__glewProgramUniform4uiEXT) -#define glProgramUniform4uivEXT GLEW_GET_FUN(__glewProgramUniform4uivEXT) -#define glProgramUniformMatrix2fvEXT GLEW_GET_FUN(__glewProgramUniformMatrix2fvEXT) -#define glProgramUniformMatrix2x3fvEXT GLEW_GET_FUN(__glewProgramUniformMatrix2x3fvEXT) -#define glProgramUniformMatrix2x4fvEXT GLEW_GET_FUN(__glewProgramUniformMatrix2x4fvEXT) -#define glProgramUniformMatrix3fvEXT GLEW_GET_FUN(__glewProgramUniformMatrix3fvEXT) -#define glProgramUniformMatrix3x2fvEXT GLEW_GET_FUN(__glewProgramUniformMatrix3x2fvEXT) -#define glProgramUniformMatrix3x4fvEXT GLEW_GET_FUN(__glewProgramUniformMatrix3x4fvEXT) -#define glProgramUniformMatrix4fvEXT GLEW_GET_FUN(__glewProgramUniformMatrix4fvEXT) -#define glProgramUniformMatrix4x2fvEXT GLEW_GET_FUN(__glewProgramUniformMatrix4x2fvEXT) -#define glProgramUniformMatrix4x3fvEXT GLEW_GET_FUN(__glewProgramUniformMatrix4x3fvEXT) -#define glPushClientAttribDefaultEXT GLEW_GET_FUN(__glewPushClientAttribDefaultEXT) -#define glTextureBufferEXT GLEW_GET_FUN(__glewTextureBufferEXT) -#define glTextureImage1DEXT GLEW_GET_FUN(__glewTextureImage1DEXT) -#define glTextureImage2DEXT GLEW_GET_FUN(__glewTextureImage2DEXT) -#define glTextureImage3DEXT GLEW_GET_FUN(__glewTextureImage3DEXT) -#define glTextureParameterIivEXT GLEW_GET_FUN(__glewTextureParameterIivEXT) -#define glTextureParameterIuivEXT GLEW_GET_FUN(__glewTextureParameterIuivEXT) -#define glTextureParameterfEXT GLEW_GET_FUN(__glewTextureParameterfEXT) -#define glTextureParameterfvEXT GLEW_GET_FUN(__glewTextureParameterfvEXT) -#define glTextureParameteriEXT GLEW_GET_FUN(__glewTextureParameteriEXT) -#define glTextureParameterivEXT GLEW_GET_FUN(__glewTextureParameterivEXT) -#define glTextureRenderbufferEXT GLEW_GET_FUN(__glewTextureRenderbufferEXT) -#define glTextureSubImage1DEXT GLEW_GET_FUN(__glewTextureSubImage1DEXT) -#define glTextureSubImage2DEXT GLEW_GET_FUN(__glewTextureSubImage2DEXT) -#define glTextureSubImage3DEXT GLEW_GET_FUN(__glewTextureSubImage3DEXT) -#define glUnmapNamedBufferEXT GLEW_GET_FUN(__glewUnmapNamedBufferEXT) -#define glVertexArrayColorOffsetEXT GLEW_GET_FUN(__glewVertexArrayColorOffsetEXT) -#define glVertexArrayEdgeFlagOffsetEXT GLEW_GET_FUN(__glewVertexArrayEdgeFlagOffsetEXT) -#define glVertexArrayFogCoordOffsetEXT GLEW_GET_FUN(__glewVertexArrayFogCoordOffsetEXT) -#define glVertexArrayIndexOffsetEXT GLEW_GET_FUN(__glewVertexArrayIndexOffsetEXT) -#define glVertexArrayMultiTexCoordOffsetEXT GLEW_GET_FUN(__glewVertexArrayMultiTexCoordOffsetEXT) -#define glVertexArrayNormalOffsetEXT GLEW_GET_FUN(__glewVertexArrayNormalOffsetEXT) -#define glVertexArraySecondaryColorOffsetEXT GLEW_GET_FUN(__glewVertexArraySecondaryColorOffsetEXT) -#define glVertexArrayTexCoordOffsetEXT GLEW_GET_FUN(__glewVertexArrayTexCoordOffsetEXT) -#define glVertexArrayVertexAttribDivisorEXT GLEW_GET_FUN(__glewVertexArrayVertexAttribDivisorEXT) -#define glVertexArrayVertexAttribIOffsetEXT GLEW_GET_FUN(__glewVertexArrayVertexAttribIOffsetEXT) -#define glVertexArrayVertexAttribOffsetEXT GLEW_GET_FUN(__glewVertexArrayVertexAttribOffsetEXT) -#define glVertexArrayVertexOffsetEXT GLEW_GET_FUN(__glewVertexArrayVertexOffsetEXT) - -#define GLEW_EXT_direct_state_access GLEW_GET_VAR(__GLEW_EXT_direct_state_access) - -#endif /* GL_EXT_direct_state_access */ - -/* -------------------------- GL_EXT_draw_buffers2 ------------------------- */ - -#ifndef GL_EXT_draw_buffers2 -#define GL_EXT_draw_buffers2 1 - -typedef void (GLAPIENTRY * PFNGLCOLORMASKINDEXEDEXTPROC) (GLuint buf, GLboolean r, GLboolean g, GLboolean b, GLboolean a); -typedef void (GLAPIENTRY * PFNGLDISABLEINDEXEDEXTPROC) (GLenum target, GLuint index); -typedef void (GLAPIENTRY * PFNGLENABLEINDEXEDEXTPROC) (GLenum target, GLuint index); -typedef void (GLAPIENTRY * PFNGLGETBOOLEANINDEXEDVEXTPROC) (GLenum value, GLuint index, GLboolean* data); -typedef void (GLAPIENTRY * PFNGLGETINTEGERINDEXEDVEXTPROC) (GLenum value, GLuint index, GLint* data); -typedef GLboolean (GLAPIENTRY * PFNGLISENABLEDINDEXEDEXTPROC) (GLenum target, GLuint index); - -#define glColorMaskIndexedEXT GLEW_GET_FUN(__glewColorMaskIndexedEXT) -#define glDisableIndexedEXT GLEW_GET_FUN(__glewDisableIndexedEXT) -#define glEnableIndexedEXT GLEW_GET_FUN(__glewEnableIndexedEXT) -#define glGetBooleanIndexedvEXT GLEW_GET_FUN(__glewGetBooleanIndexedvEXT) -#define glGetIntegerIndexedvEXT GLEW_GET_FUN(__glewGetIntegerIndexedvEXT) -#define glIsEnabledIndexedEXT GLEW_GET_FUN(__glewIsEnabledIndexedEXT) - -#define GLEW_EXT_draw_buffers2 GLEW_GET_VAR(__GLEW_EXT_draw_buffers2) - -#endif /* GL_EXT_draw_buffers2 */ - -/* ------------------------- GL_EXT_draw_instanced ------------------------- */ - -#ifndef GL_EXT_draw_instanced -#define GL_EXT_draw_instanced 1 - -typedef void (GLAPIENTRY * PFNGLDRAWARRAYSINSTANCEDEXTPROC) (GLenum mode, GLint start, GLsizei count, GLsizei primcount); -typedef void (GLAPIENTRY * PFNGLDRAWELEMENTSINSTANCEDEXTPROC) (GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei primcount); - -#define glDrawArraysInstancedEXT GLEW_GET_FUN(__glewDrawArraysInstancedEXT) -#define glDrawElementsInstancedEXT GLEW_GET_FUN(__glewDrawElementsInstancedEXT) - -#define GLEW_EXT_draw_instanced GLEW_GET_VAR(__GLEW_EXT_draw_instanced) - -#endif /* GL_EXT_draw_instanced */ - -/* ----------------------- GL_EXT_draw_range_elements ---------------------- */ - -#ifndef GL_EXT_draw_range_elements -#define GL_EXT_draw_range_elements 1 - -#define GL_MAX_ELEMENTS_VERTICES_EXT 0x80E8 -#define GL_MAX_ELEMENTS_INDICES_EXT 0x80E9 - -typedef void (GLAPIENTRY * PFNGLDRAWRANGEELEMENTSEXTPROC) (GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const void *indices); - -#define glDrawRangeElementsEXT GLEW_GET_FUN(__glewDrawRangeElementsEXT) - -#define GLEW_EXT_draw_range_elements GLEW_GET_VAR(__GLEW_EXT_draw_range_elements) - -#endif /* GL_EXT_draw_range_elements */ - -/* ---------------------------- GL_EXT_fog_coord --------------------------- */ - -#ifndef GL_EXT_fog_coord -#define GL_EXT_fog_coord 1 - -#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 - -typedef void (GLAPIENTRY * PFNGLFOGCOORDPOINTEREXTPROC) (GLenum type, GLsizei stride, const void *pointer); -typedef void (GLAPIENTRY * PFNGLFOGCOORDDEXTPROC) (GLdouble coord); -typedef void (GLAPIENTRY * PFNGLFOGCOORDDVEXTPROC) (const GLdouble *coord); -typedef void (GLAPIENTRY * PFNGLFOGCOORDFEXTPROC) (GLfloat coord); -typedef void (GLAPIENTRY * PFNGLFOGCOORDFVEXTPROC) (const GLfloat *coord); - -#define glFogCoordPointerEXT GLEW_GET_FUN(__glewFogCoordPointerEXT) -#define glFogCoorddEXT GLEW_GET_FUN(__glewFogCoorddEXT) -#define glFogCoorddvEXT GLEW_GET_FUN(__glewFogCoorddvEXT) -#define glFogCoordfEXT GLEW_GET_FUN(__glewFogCoordfEXT) -#define glFogCoordfvEXT GLEW_GET_FUN(__glewFogCoordfvEXT) - -#define GLEW_EXT_fog_coord GLEW_GET_VAR(__GLEW_EXT_fog_coord) - -#endif /* GL_EXT_fog_coord */ - -/* ------------------------ GL_EXT_fragment_lighting ----------------------- */ - -#ifndef GL_EXT_fragment_lighting -#define GL_EXT_fragment_lighting 1 - -#define GL_FRAGMENT_LIGHTING_EXT 0x8400 -#define GL_FRAGMENT_COLOR_MATERIAL_EXT 0x8401 -#define GL_FRAGMENT_COLOR_MATERIAL_FACE_EXT 0x8402 -#define GL_FRAGMENT_COLOR_MATERIAL_PARAMETER_EXT 0x8403 -#define GL_MAX_FRAGMENT_LIGHTS_EXT 0x8404 -#define GL_MAX_ACTIVE_LIGHTS_EXT 0x8405 -#define GL_CURRENT_RASTER_NORMAL_EXT 0x8406 -#define GL_LIGHT_ENV_MODE_EXT 0x8407 -#define GL_FRAGMENT_LIGHT_MODEL_LOCAL_VIEWER_EXT 0x8408 -#define GL_FRAGMENT_LIGHT_MODEL_TWO_SIDE_EXT 0x8409 -#define GL_FRAGMENT_LIGHT_MODEL_AMBIENT_EXT 0x840A -#define GL_FRAGMENT_LIGHT_MODEL_NORMAL_INTERPOLATION_EXT 0x840B -#define GL_FRAGMENT_LIGHT0_EXT 0x840C -#define GL_FRAGMENT_LIGHT7_EXT 0x8413 - -typedef void (GLAPIENTRY * PFNGLFRAGMENTCOLORMATERIALEXTPROC) (GLenum face, GLenum mode); -typedef void (GLAPIENTRY * PFNGLFRAGMENTLIGHTMODELFEXTPROC) (GLenum pname, GLfloat param); -typedef void (GLAPIENTRY * PFNGLFRAGMENTLIGHTMODELFVEXTPROC) (GLenum pname, GLfloat* params); -typedef void (GLAPIENTRY * PFNGLFRAGMENTLIGHTMODELIEXTPROC) (GLenum pname, GLint param); -typedef void (GLAPIENTRY * PFNGLFRAGMENTLIGHTMODELIVEXTPROC) (GLenum pname, GLint* params); -typedef void (GLAPIENTRY * PFNGLFRAGMENTLIGHTFEXTPROC) (GLenum light, GLenum pname, GLfloat param); -typedef void (GLAPIENTRY * PFNGLFRAGMENTLIGHTFVEXTPROC) (GLenum light, GLenum pname, GLfloat* params); -typedef void (GLAPIENTRY * PFNGLFRAGMENTLIGHTIEXTPROC) (GLenum light, GLenum pname, GLint param); -typedef void (GLAPIENTRY * PFNGLFRAGMENTLIGHTIVEXTPROC) (GLenum light, GLenum pname, GLint* params); -typedef void (GLAPIENTRY * PFNGLFRAGMENTMATERIALFEXTPROC) (GLenum face, GLenum pname, const GLfloat param); -typedef void (GLAPIENTRY * PFNGLFRAGMENTMATERIALFVEXTPROC) (GLenum face, GLenum pname, const GLfloat* params); -typedef void (GLAPIENTRY * PFNGLFRAGMENTMATERIALIEXTPROC) (GLenum face, GLenum pname, const GLint param); -typedef void (GLAPIENTRY * PFNGLFRAGMENTMATERIALIVEXTPROC) (GLenum face, GLenum pname, const GLint* params); -typedef void (GLAPIENTRY * PFNGLGETFRAGMENTLIGHTFVEXTPROC) (GLenum light, GLenum pname, GLfloat* params); -typedef void (GLAPIENTRY * PFNGLGETFRAGMENTLIGHTIVEXTPROC) (GLenum light, GLenum pname, GLint* params); -typedef void (GLAPIENTRY * PFNGLGETFRAGMENTMATERIALFVEXTPROC) (GLenum face, GLenum pname, const GLfloat* params); -typedef void (GLAPIENTRY * PFNGLGETFRAGMENTMATERIALIVEXTPROC) (GLenum face, GLenum pname, const GLint* params); -typedef void (GLAPIENTRY * PFNGLLIGHTENVIEXTPROC) (GLenum pname, GLint param); - -#define glFragmentColorMaterialEXT GLEW_GET_FUN(__glewFragmentColorMaterialEXT) -#define glFragmentLightModelfEXT GLEW_GET_FUN(__glewFragmentLightModelfEXT) -#define glFragmentLightModelfvEXT GLEW_GET_FUN(__glewFragmentLightModelfvEXT) -#define glFragmentLightModeliEXT GLEW_GET_FUN(__glewFragmentLightModeliEXT) -#define glFragmentLightModelivEXT GLEW_GET_FUN(__glewFragmentLightModelivEXT) -#define glFragmentLightfEXT GLEW_GET_FUN(__glewFragmentLightfEXT) -#define glFragmentLightfvEXT GLEW_GET_FUN(__glewFragmentLightfvEXT) -#define glFragmentLightiEXT GLEW_GET_FUN(__glewFragmentLightiEXT) -#define glFragmentLightivEXT GLEW_GET_FUN(__glewFragmentLightivEXT) -#define glFragmentMaterialfEXT GLEW_GET_FUN(__glewFragmentMaterialfEXT) -#define glFragmentMaterialfvEXT GLEW_GET_FUN(__glewFragmentMaterialfvEXT) -#define glFragmentMaterialiEXT GLEW_GET_FUN(__glewFragmentMaterialiEXT) -#define glFragmentMaterialivEXT GLEW_GET_FUN(__glewFragmentMaterialivEXT) -#define glGetFragmentLightfvEXT GLEW_GET_FUN(__glewGetFragmentLightfvEXT) -#define glGetFragmentLightivEXT GLEW_GET_FUN(__glewGetFragmentLightivEXT) -#define glGetFragmentMaterialfvEXT GLEW_GET_FUN(__glewGetFragmentMaterialfvEXT) -#define glGetFragmentMaterialivEXT GLEW_GET_FUN(__glewGetFragmentMaterialivEXT) -#define glLightEnviEXT GLEW_GET_FUN(__glewLightEnviEXT) - -#define GLEW_EXT_fragment_lighting GLEW_GET_VAR(__GLEW_EXT_fragment_lighting) - -#endif /* GL_EXT_fragment_lighting */ - -/* ------------------------ GL_EXT_framebuffer_blit ------------------------ */ - -#ifndef GL_EXT_framebuffer_blit -#define GL_EXT_framebuffer_blit 1 - -#define GL_DRAW_FRAMEBUFFER_BINDING_EXT 0x8CA6 -#define GL_READ_FRAMEBUFFER_EXT 0x8CA8 -#define GL_DRAW_FRAMEBUFFER_EXT 0x8CA9 -#define GL_READ_FRAMEBUFFER_BINDING_EXT 0x8CAA - -typedef void (GLAPIENTRY * PFNGLBLITFRAMEBUFFEREXTPROC) (GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter); - -#define glBlitFramebufferEXT GLEW_GET_FUN(__glewBlitFramebufferEXT) - -#define GLEW_EXT_framebuffer_blit GLEW_GET_VAR(__GLEW_EXT_framebuffer_blit) - -#endif /* GL_EXT_framebuffer_blit */ - -/* --------------------- GL_EXT_framebuffer_multisample -------------------- */ - -#ifndef GL_EXT_framebuffer_multisample -#define GL_EXT_framebuffer_multisample 1 - -#define GL_RENDERBUFFER_SAMPLES_EXT 0x8CAB -#define GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE_EXT 0x8D56 -#define GL_MAX_SAMPLES_EXT 0x8D57 - -typedef void (GLAPIENTRY * PFNGLRENDERBUFFERSTORAGEMULTISAMPLEEXTPROC) (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height); - -#define glRenderbufferStorageMultisampleEXT GLEW_GET_FUN(__glewRenderbufferStorageMultisampleEXT) - -#define GLEW_EXT_framebuffer_multisample GLEW_GET_VAR(__GLEW_EXT_framebuffer_multisample) - -#endif /* GL_EXT_framebuffer_multisample */ - -/* --------------- GL_EXT_framebuffer_multisample_blit_scaled -------------- */ - -#ifndef GL_EXT_framebuffer_multisample_blit_scaled -#define GL_EXT_framebuffer_multisample_blit_scaled 1 - -#define GL_SCALED_RESOLVE_FASTEST_EXT 0x90BA -#define GL_SCALED_RESOLVE_NICEST_EXT 0x90BB - -#define GLEW_EXT_framebuffer_multisample_blit_scaled GLEW_GET_VAR(__GLEW_EXT_framebuffer_multisample_blit_scaled) - -#endif /* GL_EXT_framebuffer_multisample_blit_scaled */ - -/* ----------------------- GL_EXT_framebuffer_object ----------------------- */ - -#ifndef GL_EXT_framebuffer_object -#define GL_EXT_framebuffer_object 1 - -#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_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 - -typedef void (GLAPIENTRY * PFNGLBINDFRAMEBUFFEREXTPROC) (GLenum target, GLuint framebuffer); -typedef void (GLAPIENTRY * PFNGLBINDRENDERBUFFEREXTPROC) (GLenum target, GLuint renderbuffer); -typedef GLenum (GLAPIENTRY * PFNGLCHECKFRAMEBUFFERSTATUSEXTPROC) (GLenum target); -typedef void (GLAPIENTRY * PFNGLDELETEFRAMEBUFFERSEXTPROC) (GLsizei n, const GLuint* framebuffers); -typedef void (GLAPIENTRY * PFNGLDELETERENDERBUFFERSEXTPROC) (GLsizei n, const GLuint* renderbuffers); -typedef void (GLAPIENTRY * PFNGLFRAMEBUFFERRENDERBUFFEREXTPROC) (GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer); -typedef void (GLAPIENTRY * PFNGLFRAMEBUFFERTEXTURE1DEXTPROC) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level); -typedef void (GLAPIENTRY * PFNGLFRAMEBUFFERTEXTURE2DEXTPROC) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level); -typedef void (GLAPIENTRY * PFNGLFRAMEBUFFERTEXTURE3DEXTPROC) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLint zoffset); -typedef void (GLAPIENTRY * PFNGLGENFRAMEBUFFERSEXTPROC) (GLsizei n, GLuint* framebuffers); -typedef void (GLAPIENTRY * PFNGLGENRENDERBUFFERSEXTPROC) (GLsizei n, GLuint* renderbuffers); -typedef void (GLAPIENTRY * PFNGLGENERATEMIPMAPEXTPROC) (GLenum target); -typedef void (GLAPIENTRY * PFNGLGETFRAMEBUFFERATTACHMENTPARAMETERIVEXTPROC) (GLenum target, GLenum attachment, GLenum pname, GLint* params); -typedef void (GLAPIENTRY * PFNGLGETRENDERBUFFERPARAMETERIVEXTPROC) (GLenum target, GLenum pname, GLint* params); -typedef GLboolean (GLAPIENTRY * PFNGLISFRAMEBUFFEREXTPROC) (GLuint framebuffer); -typedef GLboolean (GLAPIENTRY * PFNGLISRENDERBUFFEREXTPROC) (GLuint renderbuffer); -typedef void (GLAPIENTRY * PFNGLRENDERBUFFERSTORAGEEXTPROC) (GLenum target, GLenum internalformat, GLsizei width, GLsizei height); - -#define glBindFramebufferEXT GLEW_GET_FUN(__glewBindFramebufferEXT) -#define glBindRenderbufferEXT GLEW_GET_FUN(__glewBindRenderbufferEXT) -#define glCheckFramebufferStatusEXT GLEW_GET_FUN(__glewCheckFramebufferStatusEXT) -#define glDeleteFramebuffersEXT GLEW_GET_FUN(__glewDeleteFramebuffersEXT) -#define glDeleteRenderbuffersEXT GLEW_GET_FUN(__glewDeleteRenderbuffersEXT) -#define glFramebufferRenderbufferEXT GLEW_GET_FUN(__glewFramebufferRenderbufferEXT) -#define glFramebufferTexture1DEXT GLEW_GET_FUN(__glewFramebufferTexture1DEXT) -#define glFramebufferTexture2DEXT GLEW_GET_FUN(__glewFramebufferTexture2DEXT) -#define glFramebufferTexture3DEXT GLEW_GET_FUN(__glewFramebufferTexture3DEXT) -#define glGenFramebuffersEXT GLEW_GET_FUN(__glewGenFramebuffersEXT) -#define glGenRenderbuffersEXT GLEW_GET_FUN(__glewGenRenderbuffersEXT) -#define glGenerateMipmapEXT GLEW_GET_FUN(__glewGenerateMipmapEXT) -#define glGetFramebufferAttachmentParameterivEXT GLEW_GET_FUN(__glewGetFramebufferAttachmentParameterivEXT) -#define glGetRenderbufferParameterivEXT GLEW_GET_FUN(__glewGetRenderbufferParameterivEXT) -#define glIsFramebufferEXT GLEW_GET_FUN(__glewIsFramebufferEXT) -#define glIsRenderbufferEXT GLEW_GET_FUN(__glewIsRenderbufferEXT) -#define glRenderbufferStorageEXT GLEW_GET_FUN(__glewRenderbufferStorageEXT) - -#define GLEW_EXT_framebuffer_object GLEW_GET_VAR(__GLEW_EXT_framebuffer_object) - -#endif /* GL_EXT_framebuffer_object */ - -/* ------------------------ GL_EXT_framebuffer_sRGB ------------------------ */ - -#ifndef GL_EXT_framebuffer_sRGB -#define GL_EXT_framebuffer_sRGB 1 - -#define GL_FRAMEBUFFER_SRGB_EXT 0x8DB9 -#define GL_FRAMEBUFFER_SRGB_CAPABLE_EXT 0x8DBA - -#define GLEW_EXT_framebuffer_sRGB GLEW_GET_VAR(__GLEW_EXT_framebuffer_sRGB) - -#endif /* GL_EXT_framebuffer_sRGB */ - -/* ------------------------ GL_EXT_geometry_shader4 ------------------------ */ - -#ifndef GL_EXT_geometry_shader4 -#define GL_EXT_geometry_shader4 1 - -#define GL_LINES_ADJACENCY_EXT 0xA -#define GL_LINE_STRIP_ADJACENCY_EXT 0xB -#define GL_TRIANGLES_ADJACENCY_EXT 0xC -#define GL_TRIANGLE_STRIP_ADJACENCY_EXT 0xD -#define GL_PROGRAM_POINT_SIZE_EXT 0x8642 -#define GL_MAX_VARYING_COMPONENTS_EXT 0x8B4B -#define GL_MAX_GEOMETRY_TEXTURE_IMAGE_UNITS_EXT 0x8C29 -#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER_EXT 0x8CD4 -#define GL_FRAMEBUFFER_ATTACHMENT_LAYERED_EXT 0x8DA7 -#define GL_FRAMEBUFFER_INCOMPLETE_LAYER_TARGETS_EXT 0x8DA8 -#define GL_FRAMEBUFFER_INCOMPLETE_LAYER_COUNT_EXT 0x8DA9 -#define GL_GEOMETRY_SHADER_EXT 0x8DD9 -#define GL_GEOMETRY_VERTICES_OUT_EXT 0x8DDA -#define GL_GEOMETRY_INPUT_TYPE_EXT 0x8DDB -#define GL_GEOMETRY_OUTPUT_TYPE_EXT 0x8DDC -#define GL_MAX_GEOMETRY_VARYING_COMPONENTS_EXT 0x8DDD -#define GL_MAX_VERTEX_VARYING_COMPONENTS_EXT 0x8DDE -#define GL_MAX_GEOMETRY_UNIFORM_COMPONENTS_EXT 0x8DDF -#define GL_MAX_GEOMETRY_OUTPUT_VERTICES_EXT 0x8DE0 -#define GL_MAX_GEOMETRY_TOTAL_OUTPUT_COMPONENTS_EXT 0x8DE1 - -typedef void (GLAPIENTRY * PFNGLFRAMEBUFFERTEXTUREEXTPROC) (GLenum target, GLenum attachment, GLuint texture, GLint level); -typedef void (GLAPIENTRY * PFNGLFRAMEBUFFERTEXTUREFACEEXTPROC) (GLenum target, GLenum attachment, GLuint texture, GLint level, GLenum face); -typedef void (GLAPIENTRY * PFNGLPROGRAMPARAMETERIEXTPROC) (GLuint program, GLenum pname, GLint value); - -#define glFramebufferTextureEXT GLEW_GET_FUN(__glewFramebufferTextureEXT) -#define glFramebufferTextureFaceEXT GLEW_GET_FUN(__glewFramebufferTextureFaceEXT) -#define glProgramParameteriEXT GLEW_GET_FUN(__glewProgramParameteriEXT) - -#define GLEW_EXT_geometry_shader4 GLEW_GET_VAR(__GLEW_EXT_geometry_shader4) - -#endif /* GL_EXT_geometry_shader4 */ - -/* --------------------- GL_EXT_gpu_program_parameters --------------------- */ - -#ifndef GL_EXT_gpu_program_parameters -#define GL_EXT_gpu_program_parameters 1 - -typedef void (GLAPIENTRY * PFNGLPROGRAMENVPARAMETERS4FVEXTPROC) (GLenum target, GLuint index, GLsizei count, const GLfloat* params); -typedef void (GLAPIENTRY * PFNGLPROGRAMLOCALPARAMETERS4FVEXTPROC) (GLenum target, GLuint index, GLsizei count, const GLfloat* params); - -#define glProgramEnvParameters4fvEXT GLEW_GET_FUN(__glewProgramEnvParameters4fvEXT) -#define glProgramLocalParameters4fvEXT GLEW_GET_FUN(__glewProgramLocalParameters4fvEXT) - -#define GLEW_EXT_gpu_program_parameters GLEW_GET_VAR(__GLEW_EXT_gpu_program_parameters) - -#endif /* GL_EXT_gpu_program_parameters */ - -/* --------------------------- GL_EXT_gpu_shader4 -------------------------- */ - -#ifndef GL_EXT_gpu_shader4 -#define GL_EXT_gpu_shader4 1 - -#define GL_VERTEX_ATTRIB_ARRAY_INTEGER_EXT 0x88FD -#define GL_SAMPLER_1D_ARRAY_EXT 0x8DC0 -#define GL_SAMPLER_2D_ARRAY_EXT 0x8DC1 -#define GL_SAMPLER_BUFFER_EXT 0x8DC2 -#define GL_SAMPLER_1D_ARRAY_SHADOW_EXT 0x8DC3 -#define GL_SAMPLER_2D_ARRAY_SHADOW_EXT 0x8DC4 -#define GL_SAMPLER_CUBE_SHADOW_EXT 0x8DC5 -#define GL_UNSIGNED_INT_VEC2_EXT 0x8DC6 -#define GL_UNSIGNED_INT_VEC3_EXT 0x8DC7 -#define GL_UNSIGNED_INT_VEC4_EXT 0x8DC8 -#define GL_INT_SAMPLER_1D_EXT 0x8DC9 -#define GL_INT_SAMPLER_2D_EXT 0x8DCA -#define GL_INT_SAMPLER_3D_EXT 0x8DCB -#define GL_INT_SAMPLER_CUBE_EXT 0x8DCC -#define GL_INT_SAMPLER_2D_RECT_EXT 0x8DCD -#define GL_INT_SAMPLER_1D_ARRAY_EXT 0x8DCE -#define GL_INT_SAMPLER_2D_ARRAY_EXT 0x8DCF -#define GL_INT_SAMPLER_BUFFER_EXT 0x8DD0 -#define GL_UNSIGNED_INT_SAMPLER_1D_EXT 0x8DD1 -#define GL_UNSIGNED_INT_SAMPLER_2D_EXT 0x8DD2 -#define GL_UNSIGNED_INT_SAMPLER_3D_EXT 0x8DD3 -#define GL_UNSIGNED_INT_SAMPLER_CUBE_EXT 0x8DD4 -#define GL_UNSIGNED_INT_SAMPLER_2D_RECT_EXT 0x8DD5 -#define GL_UNSIGNED_INT_SAMPLER_1D_ARRAY_EXT 0x8DD6 -#define GL_UNSIGNED_INT_SAMPLER_2D_ARRAY_EXT 0x8DD7 -#define GL_UNSIGNED_INT_SAMPLER_BUFFER_EXT 0x8DD8 - -typedef void (GLAPIENTRY * PFNGLBINDFRAGDATALOCATIONEXTPROC) (GLuint program, GLuint color, const GLchar *name); -typedef GLint (GLAPIENTRY * PFNGLGETFRAGDATALOCATIONEXTPROC) (GLuint program, const GLchar *name); -typedef void (GLAPIENTRY * PFNGLGETUNIFORMUIVEXTPROC) (GLuint program, GLint location, GLuint *params); -typedef void (GLAPIENTRY * PFNGLGETVERTEXATTRIBIIVEXTPROC) (GLuint index, GLenum pname, GLint *params); -typedef void (GLAPIENTRY * PFNGLGETVERTEXATTRIBIUIVEXTPROC) (GLuint index, GLenum pname, GLuint *params); -typedef void (GLAPIENTRY * PFNGLUNIFORM1UIEXTPROC) (GLint location, GLuint v0); -typedef void (GLAPIENTRY * PFNGLUNIFORM1UIVEXTPROC) (GLint location, GLsizei count, const GLuint *value); -typedef void (GLAPIENTRY * PFNGLUNIFORM2UIEXTPROC) (GLint location, GLuint v0, GLuint v1); -typedef void (GLAPIENTRY * PFNGLUNIFORM2UIVEXTPROC) (GLint location, GLsizei count, const GLuint *value); -typedef void (GLAPIENTRY * PFNGLUNIFORM3UIEXTPROC) (GLint location, GLuint v0, GLuint v1, GLuint v2); -typedef void (GLAPIENTRY * PFNGLUNIFORM3UIVEXTPROC) (GLint location, GLsizei count, const GLuint *value); -typedef void (GLAPIENTRY * PFNGLUNIFORM4UIEXTPROC) (GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3); -typedef void (GLAPIENTRY * PFNGLUNIFORM4UIVEXTPROC) (GLint location, GLsizei count, const GLuint *value); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBI1IEXTPROC) (GLuint index, GLint x); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBI1IVEXTPROC) (GLuint index, const GLint *v); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBI1UIEXTPROC) (GLuint index, GLuint x); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBI1UIVEXTPROC) (GLuint index, const GLuint *v); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBI2IEXTPROC) (GLuint index, GLint x, GLint y); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBI2IVEXTPROC) (GLuint index, const GLint *v); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBI2UIEXTPROC) (GLuint index, GLuint x, GLuint y); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBI2UIVEXTPROC) (GLuint index, const GLuint *v); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBI3IEXTPROC) (GLuint index, GLint x, GLint y, GLint z); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBI3IVEXTPROC) (GLuint index, const GLint *v); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBI3UIEXTPROC) (GLuint index, GLuint x, GLuint y, GLuint z); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBI3UIVEXTPROC) (GLuint index, const GLuint *v); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBI4BVEXTPROC) (GLuint index, const GLbyte *v); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBI4IEXTPROC) (GLuint index, GLint x, GLint y, GLint z, GLint w); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBI4IVEXTPROC) (GLuint index, const GLint *v); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBI4SVEXTPROC) (GLuint index, const GLshort *v); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBI4UBVEXTPROC) (GLuint index, const GLubyte *v); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBI4UIEXTPROC) (GLuint index, GLuint x, GLuint y, GLuint z, GLuint w); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBI4UIVEXTPROC) (GLuint index, const GLuint *v); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBI4USVEXTPROC) (GLuint index, const GLushort *v); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBIPOINTEREXTPROC) (GLuint index, GLint size, GLenum type, GLsizei stride, const void *pointer); - -#define glBindFragDataLocationEXT GLEW_GET_FUN(__glewBindFragDataLocationEXT) -#define glGetFragDataLocationEXT GLEW_GET_FUN(__glewGetFragDataLocationEXT) -#define glGetUniformuivEXT GLEW_GET_FUN(__glewGetUniformuivEXT) -#define glGetVertexAttribIivEXT GLEW_GET_FUN(__glewGetVertexAttribIivEXT) -#define glGetVertexAttribIuivEXT GLEW_GET_FUN(__glewGetVertexAttribIuivEXT) -#define glUniform1uiEXT GLEW_GET_FUN(__glewUniform1uiEXT) -#define glUniform1uivEXT GLEW_GET_FUN(__glewUniform1uivEXT) -#define glUniform2uiEXT GLEW_GET_FUN(__glewUniform2uiEXT) -#define glUniform2uivEXT GLEW_GET_FUN(__glewUniform2uivEXT) -#define glUniform3uiEXT GLEW_GET_FUN(__glewUniform3uiEXT) -#define glUniform3uivEXT GLEW_GET_FUN(__glewUniform3uivEXT) -#define glUniform4uiEXT GLEW_GET_FUN(__glewUniform4uiEXT) -#define glUniform4uivEXT GLEW_GET_FUN(__glewUniform4uivEXT) -#define glVertexAttribI1iEXT GLEW_GET_FUN(__glewVertexAttribI1iEXT) -#define glVertexAttribI1ivEXT GLEW_GET_FUN(__glewVertexAttribI1ivEXT) -#define glVertexAttribI1uiEXT GLEW_GET_FUN(__glewVertexAttribI1uiEXT) -#define glVertexAttribI1uivEXT GLEW_GET_FUN(__glewVertexAttribI1uivEXT) -#define glVertexAttribI2iEXT GLEW_GET_FUN(__glewVertexAttribI2iEXT) -#define glVertexAttribI2ivEXT GLEW_GET_FUN(__glewVertexAttribI2ivEXT) -#define glVertexAttribI2uiEXT GLEW_GET_FUN(__glewVertexAttribI2uiEXT) -#define glVertexAttribI2uivEXT GLEW_GET_FUN(__glewVertexAttribI2uivEXT) -#define glVertexAttribI3iEXT GLEW_GET_FUN(__glewVertexAttribI3iEXT) -#define glVertexAttribI3ivEXT GLEW_GET_FUN(__glewVertexAttribI3ivEXT) -#define glVertexAttribI3uiEXT GLEW_GET_FUN(__glewVertexAttribI3uiEXT) -#define glVertexAttribI3uivEXT GLEW_GET_FUN(__glewVertexAttribI3uivEXT) -#define glVertexAttribI4bvEXT GLEW_GET_FUN(__glewVertexAttribI4bvEXT) -#define glVertexAttribI4iEXT GLEW_GET_FUN(__glewVertexAttribI4iEXT) -#define glVertexAttribI4ivEXT GLEW_GET_FUN(__glewVertexAttribI4ivEXT) -#define glVertexAttribI4svEXT GLEW_GET_FUN(__glewVertexAttribI4svEXT) -#define glVertexAttribI4ubvEXT GLEW_GET_FUN(__glewVertexAttribI4ubvEXT) -#define glVertexAttribI4uiEXT GLEW_GET_FUN(__glewVertexAttribI4uiEXT) -#define glVertexAttribI4uivEXT GLEW_GET_FUN(__glewVertexAttribI4uivEXT) -#define glVertexAttribI4usvEXT GLEW_GET_FUN(__glewVertexAttribI4usvEXT) -#define glVertexAttribIPointerEXT GLEW_GET_FUN(__glewVertexAttribIPointerEXT) - -#define GLEW_EXT_gpu_shader4 GLEW_GET_VAR(__GLEW_EXT_gpu_shader4) - -#endif /* GL_EXT_gpu_shader4 */ - -/* ---------------------------- GL_EXT_histogram --------------------------- */ - -#ifndef GL_EXT_histogram -#define GL_EXT_histogram 1 - -#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 - -typedef void (GLAPIENTRY * PFNGLGETHISTOGRAMEXTPROC) (GLenum target, GLboolean reset, GLenum format, GLenum type, void *values); -typedef void (GLAPIENTRY * PFNGLGETHISTOGRAMPARAMETERFVEXTPROC) (GLenum target, GLenum pname, GLfloat* params); -typedef void (GLAPIENTRY * PFNGLGETHISTOGRAMPARAMETERIVEXTPROC) (GLenum target, GLenum pname, GLint* params); -typedef void (GLAPIENTRY * PFNGLGETMINMAXEXTPROC) (GLenum target, GLboolean reset, GLenum format, GLenum type, void *values); -typedef void (GLAPIENTRY * PFNGLGETMINMAXPARAMETERFVEXTPROC) (GLenum target, GLenum pname, GLfloat* params); -typedef void (GLAPIENTRY * PFNGLGETMINMAXPARAMETERIVEXTPROC) (GLenum target, GLenum pname, GLint* params); -typedef void (GLAPIENTRY * PFNGLHISTOGRAMEXTPROC) (GLenum target, GLsizei width, GLenum internalformat, GLboolean sink); -typedef void (GLAPIENTRY * PFNGLMINMAXEXTPROC) (GLenum target, GLenum internalformat, GLboolean sink); -typedef void (GLAPIENTRY * PFNGLRESETHISTOGRAMEXTPROC) (GLenum target); -typedef void (GLAPIENTRY * PFNGLRESETMINMAXEXTPROC) (GLenum target); - -#define glGetHistogramEXT GLEW_GET_FUN(__glewGetHistogramEXT) -#define glGetHistogramParameterfvEXT GLEW_GET_FUN(__glewGetHistogramParameterfvEXT) -#define glGetHistogramParameterivEXT GLEW_GET_FUN(__glewGetHistogramParameterivEXT) -#define glGetMinmaxEXT GLEW_GET_FUN(__glewGetMinmaxEXT) -#define glGetMinmaxParameterfvEXT GLEW_GET_FUN(__glewGetMinmaxParameterfvEXT) -#define glGetMinmaxParameterivEXT GLEW_GET_FUN(__glewGetMinmaxParameterivEXT) -#define glHistogramEXT GLEW_GET_FUN(__glewHistogramEXT) -#define glMinmaxEXT GLEW_GET_FUN(__glewMinmaxEXT) -#define glResetHistogramEXT GLEW_GET_FUN(__glewResetHistogramEXT) -#define glResetMinmaxEXT GLEW_GET_FUN(__glewResetMinmaxEXT) - -#define GLEW_EXT_histogram GLEW_GET_VAR(__GLEW_EXT_histogram) - -#endif /* GL_EXT_histogram */ - -/* ----------------------- GL_EXT_index_array_formats ---------------------- */ - -#ifndef GL_EXT_index_array_formats -#define GL_EXT_index_array_formats 1 - -#define GLEW_EXT_index_array_formats GLEW_GET_VAR(__GLEW_EXT_index_array_formats) - -#endif /* GL_EXT_index_array_formats */ - -/* --------------------------- GL_EXT_index_func --------------------------- */ - -#ifndef GL_EXT_index_func -#define GL_EXT_index_func 1 - -typedef void (GLAPIENTRY * PFNGLINDEXFUNCEXTPROC) (GLenum func, GLfloat ref); - -#define glIndexFuncEXT GLEW_GET_FUN(__glewIndexFuncEXT) - -#define GLEW_EXT_index_func GLEW_GET_VAR(__GLEW_EXT_index_func) - -#endif /* GL_EXT_index_func */ - -/* ------------------------- GL_EXT_index_material ------------------------- */ - -#ifndef GL_EXT_index_material -#define GL_EXT_index_material 1 - -typedef void (GLAPIENTRY * PFNGLINDEXMATERIALEXTPROC) (GLenum face, GLenum mode); - -#define glIndexMaterialEXT GLEW_GET_FUN(__glewIndexMaterialEXT) - -#define GLEW_EXT_index_material GLEW_GET_VAR(__GLEW_EXT_index_material) - -#endif /* GL_EXT_index_material */ - -/* -------------------------- GL_EXT_index_texture ------------------------- */ - -#ifndef GL_EXT_index_texture -#define GL_EXT_index_texture 1 - -#define GLEW_EXT_index_texture GLEW_GET_VAR(__GLEW_EXT_index_texture) - -#endif /* GL_EXT_index_texture */ - -/* -------------------------- GL_EXT_light_texture ------------------------- */ - -#ifndef GL_EXT_light_texture -#define GL_EXT_light_texture 1 - -#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 - -typedef void (GLAPIENTRY * PFNGLAPPLYTEXTUREEXTPROC) (GLenum mode); -typedef void (GLAPIENTRY * PFNGLTEXTURELIGHTEXTPROC) (GLenum pname); -typedef void (GLAPIENTRY * PFNGLTEXTUREMATERIALEXTPROC) (GLenum face, GLenum mode); - -#define glApplyTextureEXT GLEW_GET_FUN(__glewApplyTextureEXT) -#define glTextureLightEXT GLEW_GET_FUN(__glewTextureLightEXT) -#define glTextureMaterialEXT GLEW_GET_FUN(__glewTextureMaterialEXT) - -#define GLEW_EXT_light_texture GLEW_GET_VAR(__GLEW_EXT_light_texture) - -#endif /* GL_EXT_light_texture */ - -/* ------------------------- GL_EXT_misc_attribute ------------------------- */ - -#ifndef GL_EXT_misc_attribute -#define GL_EXT_misc_attribute 1 - -#define GLEW_EXT_misc_attribute GLEW_GET_VAR(__GLEW_EXT_misc_attribute) - -#endif /* GL_EXT_misc_attribute */ - -/* ------------------------ GL_EXT_multi_draw_arrays ----------------------- */ - -#ifndef GL_EXT_multi_draw_arrays -#define GL_EXT_multi_draw_arrays 1 - -typedef void (GLAPIENTRY * PFNGLMULTIDRAWARRAYSEXTPROC) (GLenum mode, const GLint* first, const GLsizei *count, GLsizei primcount); -typedef void (GLAPIENTRY * PFNGLMULTIDRAWELEMENTSEXTPROC) (GLenum mode, GLsizei* count, GLenum type, const void *const *indices, GLsizei primcount); - -#define glMultiDrawArraysEXT GLEW_GET_FUN(__glewMultiDrawArraysEXT) -#define glMultiDrawElementsEXT GLEW_GET_FUN(__glewMultiDrawElementsEXT) - -#define GLEW_EXT_multi_draw_arrays GLEW_GET_VAR(__GLEW_EXT_multi_draw_arrays) - -#endif /* GL_EXT_multi_draw_arrays */ - -/* --------------------------- GL_EXT_multisample -------------------------- */ - -#ifndef GL_EXT_multisample -#define GL_EXT_multisample 1 - -#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 - -typedef void (GLAPIENTRY * PFNGLSAMPLEMASKEXTPROC) (GLclampf value, GLboolean invert); -typedef void (GLAPIENTRY * PFNGLSAMPLEPATTERNEXTPROC) (GLenum pattern); - -#define glSampleMaskEXT GLEW_GET_FUN(__glewSampleMaskEXT) -#define glSamplePatternEXT GLEW_GET_FUN(__glewSamplePatternEXT) - -#define GLEW_EXT_multisample GLEW_GET_VAR(__GLEW_EXT_multisample) - -#endif /* GL_EXT_multisample */ - -/* ---------------------- GL_EXT_packed_depth_stencil ---------------------- */ - -#ifndef GL_EXT_packed_depth_stencil -#define GL_EXT_packed_depth_stencil 1 - -#define GL_DEPTH_STENCIL_EXT 0x84F9 -#define GL_UNSIGNED_INT_24_8_EXT 0x84FA -#define GL_DEPTH24_STENCIL8_EXT 0x88F0 -#define GL_TEXTURE_STENCIL_SIZE_EXT 0x88F1 - -#define GLEW_EXT_packed_depth_stencil GLEW_GET_VAR(__GLEW_EXT_packed_depth_stencil) - -#endif /* GL_EXT_packed_depth_stencil */ - -/* -------------------------- GL_EXT_packed_float -------------------------- */ - -#ifndef GL_EXT_packed_float -#define GL_EXT_packed_float 1 - -#define GL_R11F_G11F_B10F_EXT 0x8C3A -#define GL_UNSIGNED_INT_10F_11F_11F_REV_EXT 0x8C3B -#define GL_RGBA_SIGNED_COMPONENTS_EXT 0x8C3C - -#define GLEW_EXT_packed_float GLEW_GET_VAR(__GLEW_EXT_packed_float) - -#endif /* GL_EXT_packed_float */ - -/* -------------------------- GL_EXT_packed_pixels ------------------------- */ - -#ifndef GL_EXT_packed_pixels -#define GL_EXT_packed_pixels 1 - -#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 - -#define GLEW_EXT_packed_pixels GLEW_GET_VAR(__GLEW_EXT_packed_pixels) - -#endif /* GL_EXT_packed_pixels */ - -/* ------------------------ GL_EXT_paletted_texture ------------------------ */ - -#ifndef GL_EXT_paletted_texture -#define GL_EXT_paletted_texture 1 - -#define GL_TEXTURE_1D 0x0DE0 -#define GL_TEXTURE_2D 0x0DE1 -#define GL_PROXY_TEXTURE_1D 0x8063 -#define GL_PROXY_TEXTURE_2D 0x8064 -#define GL_COLOR_TABLE_FORMAT_EXT 0x80D8 -#define GL_COLOR_TABLE_WIDTH_EXT 0x80D9 -#define GL_COLOR_TABLE_RED_SIZE_EXT 0x80DA -#define GL_COLOR_TABLE_GREEN_SIZE_EXT 0x80DB -#define GL_COLOR_TABLE_BLUE_SIZE_EXT 0x80DC -#define GL_COLOR_TABLE_ALPHA_SIZE_EXT 0x80DD -#define GL_COLOR_TABLE_LUMINANCE_SIZE_EXT 0x80DE -#define GL_COLOR_TABLE_INTENSITY_SIZE_EXT 0x80DF -#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 -#define GL_TEXTURE_CUBE_MAP_ARB 0x8513 -#define GL_PROXY_TEXTURE_CUBE_MAP_ARB 0x851B - -typedef void (GLAPIENTRY * PFNGLCOLORTABLEEXTPROC) (GLenum target, GLenum internalFormat, GLsizei width, GLenum format, GLenum type, const void *data); -typedef void (GLAPIENTRY * PFNGLGETCOLORTABLEEXTPROC) (GLenum target, GLenum format, GLenum type, void *data); -typedef void (GLAPIENTRY * PFNGLGETCOLORTABLEPARAMETERFVEXTPROC) (GLenum target, GLenum pname, GLfloat* params); -typedef void (GLAPIENTRY * PFNGLGETCOLORTABLEPARAMETERIVEXTPROC) (GLenum target, GLenum pname, GLint* params); - -#define glColorTableEXT GLEW_GET_FUN(__glewColorTableEXT) -#define glGetColorTableEXT GLEW_GET_FUN(__glewGetColorTableEXT) -#define glGetColorTableParameterfvEXT GLEW_GET_FUN(__glewGetColorTableParameterfvEXT) -#define glGetColorTableParameterivEXT GLEW_GET_FUN(__glewGetColorTableParameterivEXT) - -#define GLEW_EXT_paletted_texture GLEW_GET_VAR(__GLEW_EXT_paletted_texture) - -#endif /* GL_EXT_paletted_texture */ - -/* ----------------------- GL_EXT_pixel_buffer_object ---------------------- */ - -#ifndef GL_EXT_pixel_buffer_object -#define GL_EXT_pixel_buffer_object 1 - -#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 - -#define GLEW_EXT_pixel_buffer_object GLEW_GET_VAR(__GLEW_EXT_pixel_buffer_object) - -#endif /* GL_EXT_pixel_buffer_object */ - -/* ------------------------- GL_EXT_pixel_transform ------------------------ */ - -#ifndef GL_EXT_pixel_transform -#define GL_EXT_pixel_transform 1 - -#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 - -typedef void (GLAPIENTRY * PFNGLGETPIXELTRANSFORMPARAMETERFVEXTPROC) (GLenum target, GLenum pname, const GLfloat* params); -typedef void (GLAPIENTRY * PFNGLGETPIXELTRANSFORMPARAMETERIVEXTPROC) (GLenum target, GLenum pname, const GLint* params); -typedef void (GLAPIENTRY * PFNGLPIXELTRANSFORMPARAMETERFEXTPROC) (GLenum target, GLenum pname, const GLfloat param); -typedef void (GLAPIENTRY * PFNGLPIXELTRANSFORMPARAMETERFVEXTPROC) (GLenum target, GLenum pname, const GLfloat* params); -typedef void (GLAPIENTRY * PFNGLPIXELTRANSFORMPARAMETERIEXTPROC) (GLenum target, GLenum pname, const GLint param); -typedef void (GLAPIENTRY * PFNGLPIXELTRANSFORMPARAMETERIVEXTPROC) (GLenum target, GLenum pname, const GLint* params); - -#define glGetPixelTransformParameterfvEXT GLEW_GET_FUN(__glewGetPixelTransformParameterfvEXT) -#define glGetPixelTransformParameterivEXT GLEW_GET_FUN(__glewGetPixelTransformParameterivEXT) -#define glPixelTransformParameterfEXT GLEW_GET_FUN(__glewPixelTransformParameterfEXT) -#define glPixelTransformParameterfvEXT GLEW_GET_FUN(__glewPixelTransformParameterfvEXT) -#define glPixelTransformParameteriEXT GLEW_GET_FUN(__glewPixelTransformParameteriEXT) -#define glPixelTransformParameterivEXT GLEW_GET_FUN(__glewPixelTransformParameterivEXT) - -#define GLEW_EXT_pixel_transform GLEW_GET_VAR(__GLEW_EXT_pixel_transform) - -#endif /* GL_EXT_pixel_transform */ - -/* ------------------- GL_EXT_pixel_transform_color_table ------------------ */ - -#ifndef GL_EXT_pixel_transform_color_table -#define GL_EXT_pixel_transform_color_table 1 - -#define GLEW_EXT_pixel_transform_color_table GLEW_GET_VAR(__GLEW_EXT_pixel_transform_color_table) - -#endif /* GL_EXT_pixel_transform_color_table */ - -/* ------------------------ GL_EXT_point_parameters ------------------------ */ - -#ifndef GL_EXT_point_parameters -#define GL_EXT_point_parameters 1 - -#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 - -typedef void (GLAPIENTRY * PFNGLPOINTPARAMETERFEXTPROC) (GLenum pname, GLfloat param); -typedef void (GLAPIENTRY * PFNGLPOINTPARAMETERFVEXTPROC) (GLenum pname, const GLfloat* params); - -#define glPointParameterfEXT GLEW_GET_FUN(__glewPointParameterfEXT) -#define glPointParameterfvEXT GLEW_GET_FUN(__glewPointParameterfvEXT) - -#define GLEW_EXT_point_parameters GLEW_GET_VAR(__GLEW_EXT_point_parameters) - -#endif /* GL_EXT_point_parameters */ - -/* ------------------------- GL_EXT_polygon_offset ------------------------- */ - -#ifndef GL_EXT_polygon_offset -#define GL_EXT_polygon_offset 1 - -#define GL_POLYGON_OFFSET_EXT 0x8037 -#define GL_POLYGON_OFFSET_FACTOR_EXT 0x8038 -#define GL_POLYGON_OFFSET_BIAS_EXT 0x8039 - -typedef void (GLAPIENTRY * PFNGLPOLYGONOFFSETEXTPROC) (GLfloat factor, GLfloat bias); - -#define glPolygonOffsetEXT GLEW_GET_FUN(__glewPolygonOffsetEXT) - -#define GLEW_EXT_polygon_offset GLEW_GET_VAR(__GLEW_EXT_polygon_offset) - -#endif /* GL_EXT_polygon_offset */ - -/* ---------------------- GL_EXT_polygon_offset_clamp ---------------------- */ - -#ifndef GL_EXT_polygon_offset_clamp -#define GL_EXT_polygon_offset_clamp 1 - -#define GL_POLYGON_OFFSET_CLAMP_EXT 0x8E1B - -typedef void (GLAPIENTRY * PFNGLPOLYGONOFFSETCLAMPEXTPROC) (GLfloat factor, GLfloat units, GLfloat clamp); - -#define glPolygonOffsetClampEXT GLEW_GET_FUN(__glewPolygonOffsetClampEXT) - -#define GLEW_EXT_polygon_offset_clamp GLEW_GET_VAR(__GLEW_EXT_polygon_offset_clamp) - -#endif /* GL_EXT_polygon_offset_clamp */ - -/* ----------------------- GL_EXT_post_depth_coverage ---------------------- */ - -#ifndef GL_EXT_post_depth_coverage -#define GL_EXT_post_depth_coverage 1 - -#define GLEW_EXT_post_depth_coverage GLEW_GET_VAR(__GLEW_EXT_post_depth_coverage) - -#endif /* GL_EXT_post_depth_coverage */ - -/* ------------------------ GL_EXT_provoking_vertex ------------------------ */ - -#ifndef GL_EXT_provoking_vertex -#define GL_EXT_provoking_vertex 1 - -#define GL_QUADS_FOLLOW_PROVOKING_VERTEX_CONVENTION_EXT 0x8E4C -#define GL_FIRST_VERTEX_CONVENTION_EXT 0x8E4D -#define GL_LAST_VERTEX_CONVENTION_EXT 0x8E4E -#define GL_PROVOKING_VERTEX_EXT 0x8E4F - -typedef void (GLAPIENTRY * PFNGLPROVOKINGVERTEXEXTPROC) (GLenum mode); - -#define glProvokingVertexEXT GLEW_GET_FUN(__glewProvokingVertexEXT) - -#define GLEW_EXT_provoking_vertex GLEW_GET_VAR(__GLEW_EXT_provoking_vertex) - -#endif /* GL_EXT_provoking_vertex */ - -/* ----------------------- GL_EXT_raster_multisample ----------------------- */ - -#ifndef GL_EXT_raster_multisample -#define GL_EXT_raster_multisample 1 - -#define GL_COLOR_SAMPLES_NV 0x8E20 -#define GL_RASTER_MULTISAMPLE_EXT 0x9327 -#define GL_RASTER_SAMPLES_EXT 0x9328 -#define GL_MAX_RASTER_SAMPLES_EXT 0x9329 -#define GL_RASTER_FIXED_SAMPLE_LOCATIONS_EXT 0x932A -#define GL_MULTISAMPLE_RASTERIZATION_ALLOWED_EXT 0x932B -#define GL_EFFECTIVE_RASTER_SAMPLES_EXT 0x932C -#define GL_DEPTH_SAMPLES_NV 0x932D -#define GL_STENCIL_SAMPLES_NV 0x932E -#define GL_MIXED_DEPTH_SAMPLES_SUPPORTED_NV 0x932F -#define GL_MIXED_STENCIL_SAMPLES_SUPPORTED_NV 0x9330 -#define GL_COVERAGE_MODULATION_TABLE_NV 0x9331 -#define GL_COVERAGE_MODULATION_NV 0x9332 -#define GL_COVERAGE_MODULATION_TABLE_SIZE_NV 0x9333 - -typedef void (GLAPIENTRY * PFNGLCOVERAGEMODULATIONNVPROC) (GLenum components); -typedef void (GLAPIENTRY * PFNGLCOVERAGEMODULATIONTABLENVPROC) (GLsizei n, const GLfloat* v); -typedef void (GLAPIENTRY * PFNGLGETCOVERAGEMODULATIONTABLENVPROC) (GLsizei bufsize, GLfloat* v); -typedef void (GLAPIENTRY * PFNGLRASTERSAMPLESEXTPROC) (GLuint samples, GLboolean fixedsamplelocations); - -#define glCoverageModulationNV GLEW_GET_FUN(__glewCoverageModulationNV) -#define glCoverageModulationTableNV GLEW_GET_FUN(__glewCoverageModulationTableNV) -#define glGetCoverageModulationTableNV GLEW_GET_FUN(__glewGetCoverageModulationTableNV) -#define glRasterSamplesEXT GLEW_GET_FUN(__glewRasterSamplesEXT) - -#define GLEW_EXT_raster_multisample GLEW_GET_VAR(__GLEW_EXT_raster_multisample) - -#endif /* GL_EXT_raster_multisample */ - -/* ------------------------- GL_EXT_rescale_normal ------------------------- */ - -#ifndef GL_EXT_rescale_normal -#define GL_EXT_rescale_normal 1 - -#define GL_RESCALE_NORMAL_EXT 0x803A - -#define GLEW_EXT_rescale_normal GLEW_GET_VAR(__GLEW_EXT_rescale_normal) - -#endif /* GL_EXT_rescale_normal */ - -/* -------------------------- GL_EXT_scene_marker -------------------------- */ - -#ifndef GL_EXT_scene_marker -#define GL_EXT_scene_marker 1 - -typedef void (GLAPIENTRY * PFNGLBEGINSCENEEXTPROC) (void); -typedef void (GLAPIENTRY * PFNGLENDSCENEEXTPROC) (void); - -#define glBeginSceneEXT GLEW_GET_FUN(__glewBeginSceneEXT) -#define glEndSceneEXT GLEW_GET_FUN(__glewEndSceneEXT) - -#define GLEW_EXT_scene_marker GLEW_GET_VAR(__GLEW_EXT_scene_marker) - -#endif /* GL_EXT_scene_marker */ - -/* ------------------------- GL_EXT_secondary_color ------------------------ */ - -#ifndef GL_EXT_secondary_color -#define GL_EXT_secondary_color 1 - -#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 - -typedef void (GLAPIENTRY * PFNGLSECONDARYCOLOR3BEXTPROC) (GLbyte red, GLbyte green, GLbyte blue); -typedef void (GLAPIENTRY * PFNGLSECONDARYCOLOR3BVEXTPROC) (const GLbyte *v); -typedef void (GLAPIENTRY * PFNGLSECONDARYCOLOR3DEXTPROC) (GLdouble red, GLdouble green, GLdouble blue); -typedef void (GLAPIENTRY * PFNGLSECONDARYCOLOR3DVEXTPROC) (const GLdouble *v); -typedef void (GLAPIENTRY * PFNGLSECONDARYCOLOR3FEXTPROC) (GLfloat red, GLfloat green, GLfloat blue); -typedef void (GLAPIENTRY * PFNGLSECONDARYCOLOR3FVEXTPROC) (const GLfloat *v); -typedef void (GLAPIENTRY * PFNGLSECONDARYCOLOR3IEXTPROC) (GLint red, GLint green, GLint blue); -typedef void (GLAPIENTRY * PFNGLSECONDARYCOLOR3IVEXTPROC) (const GLint *v); -typedef void (GLAPIENTRY * PFNGLSECONDARYCOLOR3SEXTPROC) (GLshort red, GLshort green, GLshort blue); -typedef void (GLAPIENTRY * PFNGLSECONDARYCOLOR3SVEXTPROC) (const GLshort *v); -typedef void (GLAPIENTRY * PFNGLSECONDARYCOLOR3UBEXTPROC) (GLubyte red, GLubyte green, GLubyte blue); -typedef void (GLAPIENTRY * PFNGLSECONDARYCOLOR3UBVEXTPROC) (const GLubyte *v); -typedef void (GLAPIENTRY * PFNGLSECONDARYCOLOR3UIEXTPROC) (GLuint red, GLuint green, GLuint blue); -typedef void (GLAPIENTRY * PFNGLSECONDARYCOLOR3UIVEXTPROC) (const GLuint *v); -typedef void (GLAPIENTRY * PFNGLSECONDARYCOLOR3USEXTPROC) (GLushort red, GLushort green, GLushort blue); -typedef void (GLAPIENTRY * PFNGLSECONDARYCOLOR3USVEXTPROC) (const GLushort *v); -typedef void (GLAPIENTRY * PFNGLSECONDARYCOLORPOINTEREXTPROC) (GLint size, GLenum type, GLsizei stride, const void *pointer); - -#define glSecondaryColor3bEXT GLEW_GET_FUN(__glewSecondaryColor3bEXT) -#define glSecondaryColor3bvEXT GLEW_GET_FUN(__glewSecondaryColor3bvEXT) -#define glSecondaryColor3dEXT GLEW_GET_FUN(__glewSecondaryColor3dEXT) -#define glSecondaryColor3dvEXT GLEW_GET_FUN(__glewSecondaryColor3dvEXT) -#define glSecondaryColor3fEXT GLEW_GET_FUN(__glewSecondaryColor3fEXT) -#define glSecondaryColor3fvEXT GLEW_GET_FUN(__glewSecondaryColor3fvEXT) -#define glSecondaryColor3iEXT GLEW_GET_FUN(__glewSecondaryColor3iEXT) -#define glSecondaryColor3ivEXT GLEW_GET_FUN(__glewSecondaryColor3ivEXT) -#define glSecondaryColor3sEXT GLEW_GET_FUN(__glewSecondaryColor3sEXT) -#define glSecondaryColor3svEXT GLEW_GET_FUN(__glewSecondaryColor3svEXT) -#define glSecondaryColor3ubEXT GLEW_GET_FUN(__glewSecondaryColor3ubEXT) -#define glSecondaryColor3ubvEXT GLEW_GET_FUN(__glewSecondaryColor3ubvEXT) -#define glSecondaryColor3uiEXT GLEW_GET_FUN(__glewSecondaryColor3uiEXT) -#define glSecondaryColor3uivEXT GLEW_GET_FUN(__glewSecondaryColor3uivEXT) -#define glSecondaryColor3usEXT GLEW_GET_FUN(__glewSecondaryColor3usEXT) -#define glSecondaryColor3usvEXT GLEW_GET_FUN(__glewSecondaryColor3usvEXT) -#define glSecondaryColorPointerEXT GLEW_GET_FUN(__glewSecondaryColorPointerEXT) - -#define GLEW_EXT_secondary_color GLEW_GET_VAR(__GLEW_EXT_secondary_color) - -#endif /* GL_EXT_secondary_color */ - -/* --------------------- GL_EXT_separate_shader_objects -------------------- */ - -#ifndef GL_EXT_separate_shader_objects -#define GL_EXT_separate_shader_objects 1 - -#define GL_ACTIVE_PROGRAM_EXT 0x8B8D - -typedef void (GLAPIENTRY * PFNGLACTIVEPROGRAMEXTPROC) (GLuint program); -typedef GLuint (GLAPIENTRY * PFNGLCREATESHADERPROGRAMEXTPROC) (GLenum type, const GLchar* string); -typedef void (GLAPIENTRY * PFNGLUSESHADERPROGRAMEXTPROC) (GLenum type, GLuint program); - -#define glActiveProgramEXT GLEW_GET_FUN(__glewActiveProgramEXT) -#define glCreateShaderProgramEXT GLEW_GET_FUN(__glewCreateShaderProgramEXT) -#define glUseShaderProgramEXT GLEW_GET_FUN(__glewUseShaderProgramEXT) - -#define GLEW_EXT_separate_shader_objects GLEW_GET_VAR(__GLEW_EXT_separate_shader_objects) - -#endif /* GL_EXT_separate_shader_objects */ - -/* --------------------- GL_EXT_separate_specular_color -------------------- */ - -#ifndef GL_EXT_separate_specular_color -#define GL_EXT_separate_specular_color 1 - -#define GL_LIGHT_MODEL_COLOR_CONTROL_EXT 0x81F8 -#define GL_SINGLE_COLOR_EXT 0x81F9 -#define GL_SEPARATE_SPECULAR_COLOR_EXT 0x81FA - -#define GLEW_EXT_separate_specular_color GLEW_GET_VAR(__GLEW_EXT_separate_specular_color) - -#endif /* GL_EXT_separate_specular_color */ - -/* ------------------- GL_EXT_shader_image_load_formatted ------------------ */ - -#ifndef GL_EXT_shader_image_load_formatted -#define GL_EXT_shader_image_load_formatted 1 - -#define GLEW_EXT_shader_image_load_formatted GLEW_GET_VAR(__GLEW_EXT_shader_image_load_formatted) - -#endif /* GL_EXT_shader_image_load_formatted */ - -/* --------------------- GL_EXT_shader_image_load_store -------------------- */ - -#ifndef GL_EXT_shader_image_load_store -#define GL_EXT_shader_image_load_store 1 - -#define GL_VERTEX_ATTRIB_ARRAY_BARRIER_BIT_EXT 0x00000001 -#define GL_ELEMENT_ARRAY_BARRIER_BIT_EXT 0x00000002 -#define GL_UNIFORM_BARRIER_BIT_EXT 0x00000004 -#define GL_TEXTURE_FETCH_BARRIER_BIT_EXT 0x00000008 -#define GL_SHADER_IMAGE_ACCESS_BARRIER_BIT_EXT 0x00000020 -#define GL_COMMAND_BARRIER_BIT_EXT 0x00000040 -#define GL_PIXEL_BUFFER_BARRIER_BIT_EXT 0x00000080 -#define GL_TEXTURE_UPDATE_BARRIER_BIT_EXT 0x00000100 -#define GL_BUFFER_UPDATE_BARRIER_BIT_EXT 0x00000200 -#define GL_FRAMEBUFFER_BARRIER_BIT_EXT 0x00000400 -#define GL_TRANSFORM_FEEDBACK_BARRIER_BIT_EXT 0x00000800 -#define GL_ATOMIC_COUNTER_BARRIER_BIT_EXT 0x00001000 -#define GL_MAX_IMAGE_UNITS_EXT 0x8F38 -#define GL_MAX_COMBINED_IMAGE_UNITS_AND_FRAGMENT_OUTPUTS_EXT 0x8F39 -#define GL_IMAGE_BINDING_NAME_EXT 0x8F3A -#define GL_IMAGE_BINDING_LEVEL_EXT 0x8F3B -#define GL_IMAGE_BINDING_LAYERED_EXT 0x8F3C -#define GL_IMAGE_BINDING_LAYER_EXT 0x8F3D -#define GL_IMAGE_BINDING_ACCESS_EXT 0x8F3E -#define GL_IMAGE_1D_EXT 0x904C -#define GL_IMAGE_2D_EXT 0x904D -#define GL_IMAGE_3D_EXT 0x904E -#define GL_IMAGE_2D_RECT_EXT 0x904F -#define GL_IMAGE_CUBE_EXT 0x9050 -#define GL_IMAGE_BUFFER_EXT 0x9051 -#define GL_IMAGE_1D_ARRAY_EXT 0x9052 -#define GL_IMAGE_2D_ARRAY_EXT 0x9053 -#define GL_IMAGE_CUBE_MAP_ARRAY_EXT 0x9054 -#define GL_IMAGE_2D_MULTISAMPLE_EXT 0x9055 -#define GL_IMAGE_2D_MULTISAMPLE_ARRAY_EXT 0x9056 -#define GL_INT_IMAGE_1D_EXT 0x9057 -#define GL_INT_IMAGE_2D_EXT 0x9058 -#define GL_INT_IMAGE_3D_EXT 0x9059 -#define GL_INT_IMAGE_2D_RECT_EXT 0x905A -#define GL_INT_IMAGE_CUBE_EXT 0x905B -#define GL_INT_IMAGE_BUFFER_EXT 0x905C -#define GL_INT_IMAGE_1D_ARRAY_EXT 0x905D -#define GL_INT_IMAGE_2D_ARRAY_EXT 0x905E -#define GL_INT_IMAGE_CUBE_MAP_ARRAY_EXT 0x905F -#define GL_INT_IMAGE_2D_MULTISAMPLE_EXT 0x9060 -#define GL_INT_IMAGE_2D_MULTISAMPLE_ARRAY_EXT 0x9061 -#define GL_UNSIGNED_INT_IMAGE_1D_EXT 0x9062 -#define GL_UNSIGNED_INT_IMAGE_2D_EXT 0x9063 -#define GL_UNSIGNED_INT_IMAGE_3D_EXT 0x9064 -#define GL_UNSIGNED_INT_IMAGE_2D_RECT_EXT 0x9065 -#define GL_UNSIGNED_INT_IMAGE_CUBE_EXT 0x9066 -#define GL_UNSIGNED_INT_IMAGE_BUFFER_EXT 0x9067 -#define GL_UNSIGNED_INT_IMAGE_1D_ARRAY_EXT 0x9068 -#define GL_UNSIGNED_INT_IMAGE_2D_ARRAY_EXT 0x9069 -#define GL_UNSIGNED_INT_IMAGE_CUBE_MAP_ARRAY_EXT 0x906A -#define GL_UNSIGNED_INT_IMAGE_2D_MULTISAMPLE_EXT 0x906B -#define GL_UNSIGNED_INT_IMAGE_2D_MULTISAMPLE_ARRAY_EXT 0x906C -#define GL_MAX_IMAGE_SAMPLES_EXT 0x906D -#define GL_IMAGE_BINDING_FORMAT_EXT 0x906E -#define GL_ALL_BARRIER_BITS_EXT 0xFFFFFFFF - -typedef void (GLAPIENTRY * PFNGLBINDIMAGETEXTUREEXTPROC) (GLuint index, GLuint texture, GLint level, GLboolean layered, GLint layer, GLenum access, GLint format); -typedef void (GLAPIENTRY * PFNGLMEMORYBARRIEREXTPROC) (GLbitfield barriers); - -#define glBindImageTextureEXT GLEW_GET_FUN(__glewBindImageTextureEXT) -#define glMemoryBarrierEXT GLEW_GET_FUN(__glewMemoryBarrierEXT) - -#define GLEW_EXT_shader_image_load_store GLEW_GET_VAR(__GLEW_EXT_shader_image_load_store) - -#endif /* GL_EXT_shader_image_load_store */ - -/* ----------------------- GL_EXT_shader_integer_mix ----------------------- */ - -#ifndef GL_EXT_shader_integer_mix -#define GL_EXT_shader_integer_mix 1 - -#define GLEW_EXT_shader_integer_mix GLEW_GET_VAR(__GLEW_EXT_shader_integer_mix) - -#endif /* GL_EXT_shader_integer_mix */ - -/* -------------------------- GL_EXT_shadow_funcs -------------------------- */ - -#ifndef GL_EXT_shadow_funcs -#define GL_EXT_shadow_funcs 1 - -#define GLEW_EXT_shadow_funcs GLEW_GET_VAR(__GLEW_EXT_shadow_funcs) - -#endif /* GL_EXT_shadow_funcs */ - -/* --------------------- GL_EXT_shared_texture_palette --------------------- */ - -#ifndef GL_EXT_shared_texture_palette -#define GL_EXT_shared_texture_palette 1 - -#define GL_SHARED_TEXTURE_PALETTE_EXT 0x81FB - -#define GLEW_EXT_shared_texture_palette GLEW_GET_VAR(__GLEW_EXT_shared_texture_palette) - -#endif /* GL_EXT_shared_texture_palette */ - -/* ------------------------- GL_EXT_sparse_texture2 ------------------------ */ - -#ifndef GL_EXT_sparse_texture2 -#define GL_EXT_sparse_texture2 1 - -#define GLEW_EXT_sparse_texture2 GLEW_GET_VAR(__GLEW_EXT_sparse_texture2) - -#endif /* GL_EXT_sparse_texture2 */ - -/* ------------------------ GL_EXT_stencil_clear_tag ----------------------- */ - -#ifndef GL_EXT_stencil_clear_tag -#define GL_EXT_stencil_clear_tag 1 - -#define GL_STENCIL_TAG_BITS_EXT 0x88F2 -#define GL_STENCIL_CLEAR_TAG_VALUE_EXT 0x88F3 - -#define GLEW_EXT_stencil_clear_tag GLEW_GET_VAR(__GLEW_EXT_stencil_clear_tag) - -#endif /* GL_EXT_stencil_clear_tag */ - -/* ------------------------ GL_EXT_stencil_two_side ------------------------ */ - -#ifndef GL_EXT_stencil_two_side -#define GL_EXT_stencil_two_side 1 - -#define GL_STENCIL_TEST_TWO_SIDE_EXT 0x8910 -#define GL_ACTIVE_STENCIL_FACE_EXT 0x8911 - -typedef void (GLAPIENTRY * PFNGLACTIVESTENCILFACEEXTPROC) (GLenum face); - -#define glActiveStencilFaceEXT GLEW_GET_FUN(__glewActiveStencilFaceEXT) - -#define GLEW_EXT_stencil_two_side GLEW_GET_VAR(__GLEW_EXT_stencil_two_side) - -#endif /* GL_EXT_stencil_two_side */ - -/* -------------------------- GL_EXT_stencil_wrap -------------------------- */ - -#ifndef GL_EXT_stencil_wrap -#define GL_EXT_stencil_wrap 1 - -#define GL_INCR_WRAP_EXT 0x8507 -#define GL_DECR_WRAP_EXT 0x8508 - -#define GLEW_EXT_stencil_wrap GLEW_GET_VAR(__GLEW_EXT_stencil_wrap) - -#endif /* GL_EXT_stencil_wrap */ - -/* --------------------------- GL_EXT_subtexture --------------------------- */ - -#ifndef GL_EXT_subtexture -#define GL_EXT_subtexture 1 - -typedef void (GLAPIENTRY * PFNGLTEXSUBIMAGE1DEXTPROC) (GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLenum type, const void *pixels); -typedef void (GLAPIENTRY * PFNGLTEXSUBIMAGE2DEXTPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const void *pixels); -typedef void (GLAPIENTRY * PFNGLTEXSUBIMAGE3DEXTPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const void *pixels); - -#define glTexSubImage1DEXT GLEW_GET_FUN(__glewTexSubImage1DEXT) -#define glTexSubImage2DEXT GLEW_GET_FUN(__glewTexSubImage2DEXT) -#define glTexSubImage3DEXT GLEW_GET_FUN(__glewTexSubImage3DEXT) - -#define GLEW_EXT_subtexture GLEW_GET_VAR(__GLEW_EXT_subtexture) - -#endif /* GL_EXT_subtexture */ - -/* ----------------------------- GL_EXT_texture ---------------------------- */ - -#ifndef GL_EXT_texture -#define GL_EXT_texture 1 - -#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 GLEW_EXT_texture GLEW_GET_VAR(__GLEW_EXT_texture) - -#endif /* GL_EXT_texture */ - -/* ---------------------------- GL_EXT_texture3D --------------------------- */ - -#ifndef GL_EXT_texture3D -#define GL_EXT_texture3D 1 - -#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 - -typedef void (GLAPIENTRY * PFNGLTEXIMAGE3DEXTPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const void *pixels); - -#define glTexImage3DEXT GLEW_GET_FUN(__glewTexImage3DEXT) - -#define GLEW_EXT_texture3D GLEW_GET_VAR(__GLEW_EXT_texture3D) - -#endif /* GL_EXT_texture3D */ - -/* -------------------------- GL_EXT_texture_array ------------------------- */ - -#ifndef GL_EXT_texture_array -#define GL_EXT_texture_array 1 - -#define GL_COMPARE_REF_DEPTH_TO_TEXTURE_EXT 0x884E -#define GL_MAX_ARRAY_TEXTURE_LAYERS_EXT 0x88FF -#define GL_TEXTURE_1D_ARRAY_EXT 0x8C18 -#define GL_PROXY_TEXTURE_1D_ARRAY_EXT 0x8C19 -#define GL_TEXTURE_2D_ARRAY_EXT 0x8C1A -#define GL_PROXY_TEXTURE_2D_ARRAY_EXT 0x8C1B -#define GL_TEXTURE_BINDING_1D_ARRAY_EXT 0x8C1C -#define GL_TEXTURE_BINDING_2D_ARRAY_EXT 0x8C1D - -typedef void (GLAPIENTRY * PFNGLFRAMEBUFFERTEXTURELAYEREXTPROC) (GLenum target, GLenum attachment, GLuint texture, GLint level, GLint layer); - -#define glFramebufferTextureLayerEXT GLEW_GET_FUN(__glewFramebufferTextureLayerEXT) - -#define GLEW_EXT_texture_array GLEW_GET_VAR(__GLEW_EXT_texture_array) - -#endif /* GL_EXT_texture_array */ - -/* ---------------------- GL_EXT_texture_buffer_object --------------------- */ - -#ifndef GL_EXT_texture_buffer_object -#define GL_EXT_texture_buffer_object 1 - -#define GL_TEXTURE_BUFFER_EXT 0x8C2A -#define GL_MAX_TEXTURE_BUFFER_SIZE_EXT 0x8C2B -#define GL_TEXTURE_BINDING_BUFFER_EXT 0x8C2C -#define GL_TEXTURE_BUFFER_DATA_STORE_BINDING_EXT 0x8C2D -#define GL_TEXTURE_BUFFER_FORMAT_EXT 0x8C2E - -typedef void (GLAPIENTRY * PFNGLTEXBUFFEREXTPROC) (GLenum target, GLenum internalformat, GLuint buffer); - -#define glTexBufferEXT GLEW_GET_FUN(__glewTexBufferEXT) - -#define GLEW_EXT_texture_buffer_object GLEW_GET_VAR(__GLEW_EXT_texture_buffer_object) - -#endif /* GL_EXT_texture_buffer_object */ - -/* -------------------- GL_EXT_texture_compression_dxt1 -------------------- */ - -#ifndef GL_EXT_texture_compression_dxt1 -#define GL_EXT_texture_compression_dxt1 1 - -#define GLEW_EXT_texture_compression_dxt1 GLEW_GET_VAR(__GLEW_EXT_texture_compression_dxt1) - -#endif /* GL_EXT_texture_compression_dxt1 */ - -/* -------------------- GL_EXT_texture_compression_latc -------------------- */ - -#ifndef GL_EXT_texture_compression_latc -#define GL_EXT_texture_compression_latc 1 - -#define GL_COMPRESSED_LUMINANCE_LATC1_EXT 0x8C70 -#define GL_COMPRESSED_SIGNED_LUMINANCE_LATC1_EXT 0x8C71 -#define GL_COMPRESSED_LUMINANCE_ALPHA_LATC2_EXT 0x8C72 -#define GL_COMPRESSED_SIGNED_LUMINANCE_ALPHA_LATC2_EXT 0x8C73 - -#define GLEW_EXT_texture_compression_latc GLEW_GET_VAR(__GLEW_EXT_texture_compression_latc) - -#endif /* GL_EXT_texture_compression_latc */ - -/* -------------------- GL_EXT_texture_compression_rgtc -------------------- */ - -#ifndef GL_EXT_texture_compression_rgtc -#define GL_EXT_texture_compression_rgtc 1 - -#define GL_COMPRESSED_RED_RGTC1_EXT 0x8DBB -#define GL_COMPRESSED_SIGNED_RED_RGTC1_EXT 0x8DBC -#define GL_COMPRESSED_RED_GREEN_RGTC2_EXT 0x8DBD -#define GL_COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT 0x8DBE - -#define GLEW_EXT_texture_compression_rgtc GLEW_GET_VAR(__GLEW_EXT_texture_compression_rgtc) - -#endif /* GL_EXT_texture_compression_rgtc */ - -/* -------------------- GL_EXT_texture_compression_s3tc -------------------- */ - -#ifndef GL_EXT_texture_compression_s3tc -#define GL_EXT_texture_compression_s3tc 1 - -#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 - -#define GLEW_EXT_texture_compression_s3tc GLEW_GET_VAR(__GLEW_EXT_texture_compression_s3tc) - -#endif /* GL_EXT_texture_compression_s3tc */ - -/* ------------------------ GL_EXT_texture_cube_map ------------------------ */ - -#ifndef GL_EXT_texture_cube_map -#define GL_EXT_texture_cube_map 1 - -#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 - -#define GLEW_EXT_texture_cube_map GLEW_GET_VAR(__GLEW_EXT_texture_cube_map) - -#endif /* GL_EXT_texture_cube_map */ - -/* ----------------------- GL_EXT_texture_edge_clamp ----------------------- */ - -#ifndef GL_EXT_texture_edge_clamp -#define GL_EXT_texture_edge_clamp 1 - -#define GL_CLAMP_TO_EDGE_EXT 0x812F - -#define GLEW_EXT_texture_edge_clamp GLEW_GET_VAR(__GLEW_EXT_texture_edge_clamp) - -#endif /* GL_EXT_texture_edge_clamp */ - -/* --------------------------- GL_EXT_texture_env -------------------------- */ - -#ifndef GL_EXT_texture_env -#define GL_EXT_texture_env 1 - -#define GLEW_EXT_texture_env GLEW_GET_VAR(__GLEW_EXT_texture_env) - -#endif /* GL_EXT_texture_env */ - -/* ------------------------- GL_EXT_texture_env_add ------------------------ */ - -#ifndef GL_EXT_texture_env_add -#define GL_EXT_texture_env_add 1 - -#define GLEW_EXT_texture_env_add GLEW_GET_VAR(__GLEW_EXT_texture_env_add) - -#endif /* GL_EXT_texture_env_add */ - -/* ----------------------- GL_EXT_texture_env_combine ---------------------- */ - -#ifndef GL_EXT_texture_env_combine -#define GL_EXT_texture_env_combine 1 - -#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 - -#define GLEW_EXT_texture_env_combine GLEW_GET_VAR(__GLEW_EXT_texture_env_combine) - -#endif /* GL_EXT_texture_env_combine */ - -/* ------------------------ GL_EXT_texture_env_dot3 ------------------------ */ - -#ifndef GL_EXT_texture_env_dot3 -#define GL_EXT_texture_env_dot3 1 - -#define GL_DOT3_RGB_EXT 0x8740 -#define GL_DOT3_RGBA_EXT 0x8741 - -#define GLEW_EXT_texture_env_dot3 GLEW_GET_VAR(__GLEW_EXT_texture_env_dot3) - -#endif /* GL_EXT_texture_env_dot3 */ - -/* ------------------- GL_EXT_texture_filter_anisotropic ------------------- */ - -#ifndef GL_EXT_texture_filter_anisotropic -#define GL_EXT_texture_filter_anisotropic 1 - -#define GL_TEXTURE_MAX_ANISOTROPY_EXT 0x84FE -#define GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT 0x84FF - -#define GLEW_EXT_texture_filter_anisotropic GLEW_GET_VAR(__GLEW_EXT_texture_filter_anisotropic) - -#endif /* GL_EXT_texture_filter_anisotropic */ - -/* ---------------------- GL_EXT_texture_filter_minmax --------------------- */ - -#ifndef GL_EXT_texture_filter_minmax -#define GL_EXT_texture_filter_minmax 1 - -#define GL_TEXTURE_REDUCTION_MODE_EXT 0x9366 -#define GL_WEIGHTED_AVERAGE_EXT 0x9367 - -#define GLEW_EXT_texture_filter_minmax GLEW_GET_VAR(__GLEW_EXT_texture_filter_minmax) - -#endif /* GL_EXT_texture_filter_minmax */ - -/* ------------------------- GL_EXT_texture_integer ------------------------ */ - -#ifndef GL_EXT_texture_integer -#define GL_EXT_texture_integer 1 - -#define GL_RGBA32UI_EXT 0x8D70 -#define GL_RGB32UI_EXT 0x8D71 -#define GL_ALPHA32UI_EXT 0x8D72 -#define GL_INTENSITY32UI_EXT 0x8D73 -#define GL_LUMINANCE32UI_EXT 0x8D74 -#define GL_LUMINANCE_ALPHA32UI_EXT 0x8D75 -#define GL_RGBA16UI_EXT 0x8D76 -#define GL_RGB16UI_EXT 0x8D77 -#define GL_ALPHA16UI_EXT 0x8D78 -#define GL_INTENSITY16UI_EXT 0x8D79 -#define GL_LUMINANCE16UI_EXT 0x8D7A -#define GL_LUMINANCE_ALPHA16UI_EXT 0x8D7B -#define GL_RGBA8UI_EXT 0x8D7C -#define GL_RGB8UI_EXT 0x8D7D -#define GL_ALPHA8UI_EXT 0x8D7E -#define GL_INTENSITY8UI_EXT 0x8D7F -#define GL_LUMINANCE8UI_EXT 0x8D80 -#define GL_LUMINANCE_ALPHA8UI_EXT 0x8D81 -#define GL_RGBA32I_EXT 0x8D82 -#define GL_RGB32I_EXT 0x8D83 -#define GL_ALPHA32I_EXT 0x8D84 -#define GL_INTENSITY32I_EXT 0x8D85 -#define GL_LUMINANCE32I_EXT 0x8D86 -#define GL_LUMINANCE_ALPHA32I_EXT 0x8D87 -#define GL_RGBA16I_EXT 0x8D88 -#define GL_RGB16I_EXT 0x8D89 -#define GL_ALPHA16I_EXT 0x8D8A -#define GL_INTENSITY16I_EXT 0x8D8B -#define GL_LUMINANCE16I_EXT 0x8D8C -#define GL_LUMINANCE_ALPHA16I_EXT 0x8D8D -#define GL_RGBA8I_EXT 0x8D8E -#define GL_RGB8I_EXT 0x8D8F -#define GL_ALPHA8I_EXT 0x8D90 -#define GL_INTENSITY8I_EXT 0x8D91 -#define GL_LUMINANCE8I_EXT 0x8D92 -#define GL_LUMINANCE_ALPHA8I_EXT 0x8D93 -#define GL_RED_INTEGER_EXT 0x8D94 -#define GL_GREEN_INTEGER_EXT 0x8D95 -#define GL_BLUE_INTEGER_EXT 0x8D96 -#define GL_ALPHA_INTEGER_EXT 0x8D97 -#define GL_RGB_INTEGER_EXT 0x8D98 -#define GL_RGBA_INTEGER_EXT 0x8D99 -#define GL_BGR_INTEGER_EXT 0x8D9A -#define GL_BGRA_INTEGER_EXT 0x8D9B -#define GL_LUMINANCE_INTEGER_EXT 0x8D9C -#define GL_LUMINANCE_ALPHA_INTEGER_EXT 0x8D9D -#define GL_RGBA_INTEGER_MODE_EXT 0x8D9E - -typedef void (GLAPIENTRY * PFNGLCLEARCOLORIIEXTPROC) (GLint red, GLint green, GLint blue, GLint alpha); -typedef void (GLAPIENTRY * PFNGLCLEARCOLORIUIEXTPROC) (GLuint red, GLuint green, GLuint blue, GLuint alpha); -typedef void (GLAPIENTRY * PFNGLGETTEXPARAMETERIIVEXTPROC) (GLenum target, GLenum pname, GLint *params); -typedef void (GLAPIENTRY * PFNGLGETTEXPARAMETERIUIVEXTPROC) (GLenum target, GLenum pname, GLuint *params); -typedef void (GLAPIENTRY * PFNGLTEXPARAMETERIIVEXTPROC) (GLenum target, GLenum pname, const GLint *params); -typedef void (GLAPIENTRY * PFNGLTEXPARAMETERIUIVEXTPROC) (GLenum target, GLenum pname, const GLuint *params); - -#define glClearColorIiEXT GLEW_GET_FUN(__glewClearColorIiEXT) -#define glClearColorIuiEXT GLEW_GET_FUN(__glewClearColorIuiEXT) -#define glGetTexParameterIivEXT GLEW_GET_FUN(__glewGetTexParameterIivEXT) -#define glGetTexParameterIuivEXT GLEW_GET_FUN(__glewGetTexParameterIuivEXT) -#define glTexParameterIivEXT GLEW_GET_FUN(__glewTexParameterIivEXT) -#define glTexParameterIuivEXT GLEW_GET_FUN(__glewTexParameterIuivEXT) - -#define GLEW_EXT_texture_integer GLEW_GET_VAR(__GLEW_EXT_texture_integer) - -#endif /* GL_EXT_texture_integer */ - -/* ------------------------ GL_EXT_texture_lod_bias ------------------------ */ - -#ifndef GL_EXT_texture_lod_bias -#define GL_EXT_texture_lod_bias 1 - -#define GL_MAX_TEXTURE_LOD_BIAS_EXT 0x84FD -#define GL_TEXTURE_FILTER_CONTROL_EXT 0x8500 -#define GL_TEXTURE_LOD_BIAS_EXT 0x8501 - -#define GLEW_EXT_texture_lod_bias GLEW_GET_VAR(__GLEW_EXT_texture_lod_bias) - -#endif /* GL_EXT_texture_lod_bias */ - -/* ---------------------- GL_EXT_texture_mirror_clamp ---------------------- */ - -#ifndef GL_EXT_texture_mirror_clamp -#define GL_EXT_texture_mirror_clamp 1 - -#define GL_MIRROR_CLAMP_EXT 0x8742 -#define GL_MIRROR_CLAMP_TO_EDGE_EXT 0x8743 -#define GL_MIRROR_CLAMP_TO_BORDER_EXT 0x8912 - -#define GLEW_EXT_texture_mirror_clamp GLEW_GET_VAR(__GLEW_EXT_texture_mirror_clamp) - -#endif /* GL_EXT_texture_mirror_clamp */ - -/* ------------------------- GL_EXT_texture_object ------------------------- */ - -#ifndef GL_EXT_texture_object -#define GL_EXT_texture_object 1 - -#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 - -typedef GLboolean (GLAPIENTRY * PFNGLARETEXTURESRESIDENTEXTPROC) (GLsizei n, const GLuint* textures, GLboolean* residences); -typedef void (GLAPIENTRY * PFNGLBINDTEXTUREEXTPROC) (GLenum target, GLuint texture); -typedef void (GLAPIENTRY * PFNGLDELETETEXTURESEXTPROC) (GLsizei n, const GLuint* textures); -typedef void (GLAPIENTRY * PFNGLGENTEXTURESEXTPROC) (GLsizei n, GLuint* textures); -typedef GLboolean (GLAPIENTRY * PFNGLISTEXTUREEXTPROC) (GLuint texture); -typedef void (GLAPIENTRY * PFNGLPRIORITIZETEXTURESEXTPROC) (GLsizei n, const GLuint* textures, const GLclampf* priorities); - -#define glAreTexturesResidentEXT GLEW_GET_FUN(__glewAreTexturesResidentEXT) -#define glBindTextureEXT GLEW_GET_FUN(__glewBindTextureEXT) -#define glDeleteTexturesEXT GLEW_GET_FUN(__glewDeleteTexturesEXT) -#define glGenTexturesEXT GLEW_GET_FUN(__glewGenTexturesEXT) -#define glIsTextureEXT GLEW_GET_FUN(__glewIsTextureEXT) -#define glPrioritizeTexturesEXT GLEW_GET_FUN(__glewPrioritizeTexturesEXT) - -#define GLEW_EXT_texture_object GLEW_GET_VAR(__GLEW_EXT_texture_object) - -#endif /* GL_EXT_texture_object */ - -/* --------------------- GL_EXT_texture_perturb_normal --------------------- */ - -#ifndef GL_EXT_texture_perturb_normal -#define GL_EXT_texture_perturb_normal 1 - -#define GL_PERTURB_EXT 0x85AE -#define GL_TEXTURE_NORMAL_EXT 0x85AF - -typedef void (GLAPIENTRY * PFNGLTEXTURENORMALEXTPROC) (GLenum mode); - -#define glTextureNormalEXT GLEW_GET_FUN(__glewTextureNormalEXT) - -#define GLEW_EXT_texture_perturb_normal GLEW_GET_VAR(__GLEW_EXT_texture_perturb_normal) - -#endif /* GL_EXT_texture_perturb_normal */ - -/* ------------------------ GL_EXT_texture_rectangle ----------------------- */ - -#ifndef GL_EXT_texture_rectangle -#define GL_EXT_texture_rectangle 1 - -#define GL_TEXTURE_RECTANGLE_EXT 0x84F5 -#define GL_TEXTURE_BINDING_RECTANGLE_EXT 0x84F6 -#define GL_PROXY_TEXTURE_RECTANGLE_EXT 0x84F7 -#define GL_MAX_RECTANGLE_TEXTURE_SIZE_EXT 0x84F8 - -#define GLEW_EXT_texture_rectangle GLEW_GET_VAR(__GLEW_EXT_texture_rectangle) - -#endif /* GL_EXT_texture_rectangle */ - -/* -------------------------- GL_EXT_texture_sRGB -------------------------- */ - -#ifndef GL_EXT_texture_sRGB -#define GL_EXT_texture_sRGB 1 - -#define GL_SRGB_EXT 0x8C40 -#define GL_SRGB8_EXT 0x8C41 -#define GL_SRGB_ALPHA_EXT 0x8C42 -#define GL_SRGB8_ALPHA8_EXT 0x8C43 -#define GL_SLUMINANCE_ALPHA_EXT 0x8C44 -#define GL_SLUMINANCE8_ALPHA8_EXT 0x8C45 -#define GL_SLUMINANCE_EXT 0x8C46 -#define GL_SLUMINANCE8_EXT 0x8C47 -#define GL_COMPRESSED_SRGB_EXT 0x8C48 -#define GL_COMPRESSED_SRGB_ALPHA_EXT 0x8C49 -#define GL_COMPRESSED_SLUMINANCE_EXT 0x8C4A -#define GL_COMPRESSED_SLUMINANCE_ALPHA_EXT 0x8C4B -#define GL_COMPRESSED_SRGB_S3TC_DXT1_EXT 0x8C4C -#define GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT 0x8C4D -#define GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT 0x8C4E -#define GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT 0x8C4F - -#define GLEW_EXT_texture_sRGB GLEW_GET_VAR(__GLEW_EXT_texture_sRGB) - -#endif /* GL_EXT_texture_sRGB */ - -/* ----------------------- GL_EXT_texture_sRGB_decode ---------------------- */ - -#ifndef GL_EXT_texture_sRGB_decode -#define GL_EXT_texture_sRGB_decode 1 - -#define GL_TEXTURE_SRGB_DECODE_EXT 0x8A48 -#define GL_DECODE_EXT 0x8A49 -#define GL_SKIP_DECODE_EXT 0x8A4A - -#define GLEW_EXT_texture_sRGB_decode GLEW_GET_VAR(__GLEW_EXT_texture_sRGB_decode) - -#endif /* GL_EXT_texture_sRGB_decode */ - -/* --------------------- GL_EXT_texture_shared_exponent -------------------- */ - -#ifndef GL_EXT_texture_shared_exponent -#define GL_EXT_texture_shared_exponent 1 - -#define GL_RGB9_E5_EXT 0x8C3D -#define GL_UNSIGNED_INT_5_9_9_9_REV_EXT 0x8C3E -#define GL_TEXTURE_SHARED_SIZE_EXT 0x8C3F - -#define GLEW_EXT_texture_shared_exponent GLEW_GET_VAR(__GLEW_EXT_texture_shared_exponent) - -#endif /* GL_EXT_texture_shared_exponent */ - -/* -------------------------- GL_EXT_texture_snorm ------------------------- */ - -#ifndef GL_EXT_texture_snorm -#define GL_EXT_texture_snorm 1 - -#define GL_RED_SNORM 0x8F90 -#define GL_RG_SNORM 0x8F91 -#define GL_RGB_SNORM 0x8F92 -#define GL_RGBA_SNORM 0x8F93 -#define GL_R8_SNORM 0x8F94 -#define GL_RG8_SNORM 0x8F95 -#define GL_RGB8_SNORM 0x8F96 -#define GL_RGBA8_SNORM 0x8F97 -#define GL_R16_SNORM 0x8F98 -#define GL_RG16_SNORM 0x8F99 -#define GL_RGB16_SNORM 0x8F9A -#define GL_RGBA16_SNORM 0x8F9B -#define GL_SIGNED_NORMALIZED 0x8F9C -#define GL_ALPHA_SNORM 0x9010 -#define GL_LUMINANCE_SNORM 0x9011 -#define GL_LUMINANCE_ALPHA_SNORM 0x9012 -#define GL_INTENSITY_SNORM 0x9013 -#define GL_ALPHA8_SNORM 0x9014 -#define GL_LUMINANCE8_SNORM 0x9015 -#define GL_LUMINANCE8_ALPHA8_SNORM 0x9016 -#define GL_INTENSITY8_SNORM 0x9017 -#define GL_ALPHA16_SNORM 0x9018 -#define GL_LUMINANCE16_SNORM 0x9019 -#define GL_LUMINANCE16_ALPHA16_SNORM 0x901A -#define GL_INTENSITY16_SNORM 0x901B - -#define GLEW_EXT_texture_snorm GLEW_GET_VAR(__GLEW_EXT_texture_snorm) - -#endif /* GL_EXT_texture_snorm */ - -/* ------------------------- GL_EXT_texture_swizzle ------------------------ */ - -#ifndef GL_EXT_texture_swizzle -#define GL_EXT_texture_swizzle 1 - -#define GL_TEXTURE_SWIZZLE_R_EXT 0x8E42 -#define GL_TEXTURE_SWIZZLE_G_EXT 0x8E43 -#define GL_TEXTURE_SWIZZLE_B_EXT 0x8E44 -#define GL_TEXTURE_SWIZZLE_A_EXT 0x8E45 -#define GL_TEXTURE_SWIZZLE_RGBA_EXT 0x8E46 - -#define GLEW_EXT_texture_swizzle GLEW_GET_VAR(__GLEW_EXT_texture_swizzle) - -#endif /* GL_EXT_texture_swizzle */ - -/* --------------------------- GL_EXT_timer_query -------------------------- */ - -#ifndef GL_EXT_timer_query -#define GL_EXT_timer_query 1 - -#define GL_TIME_ELAPSED_EXT 0x88BF - -typedef void (GLAPIENTRY * PFNGLGETQUERYOBJECTI64VEXTPROC) (GLuint id, GLenum pname, GLint64EXT *params); -typedef void (GLAPIENTRY * PFNGLGETQUERYOBJECTUI64VEXTPROC) (GLuint id, GLenum pname, GLuint64EXT *params); - -#define glGetQueryObjecti64vEXT GLEW_GET_FUN(__glewGetQueryObjecti64vEXT) -#define glGetQueryObjectui64vEXT GLEW_GET_FUN(__glewGetQueryObjectui64vEXT) - -#define GLEW_EXT_timer_query GLEW_GET_VAR(__GLEW_EXT_timer_query) - -#endif /* GL_EXT_timer_query */ - -/* ----------------------- GL_EXT_transform_feedback ----------------------- */ - -#ifndef GL_EXT_transform_feedback -#define GL_EXT_transform_feedback 1 - -#define GL_TRANSFORM_FEEDBACK_VARYING_MAX_LENGTH_EXT 0x8C76 -#define GL_TRANSFORM_FEEDBACK_BUFFER_MODE_EXT 0x8C7F -#define GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS_EXT 0x8C80 -#define GL_TRANSFORM_FEEDBACK_VARYINGS_EXT 0x8C83 -#define GL_TRANSFORM_FEEDBACK_BUFFER_START_EXT 0x8C84 -#define GL_TRANSFORM_FEEDBACK_BUFFER_SIZE_EXT 0x8C85 -#define GL_PRIMITIVES_GENERATED_EXT 0x8C87 -#define GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN_EXT 0x8C88 -#define GL_RASTERIZER_DISCARD_EXT 0x8C89 -#define GL_MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS_EXT 0x8C8A -#define GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS_EXT 0x8C8B -#define GL_INTERLEAVED_ATTRIBS_EXT 0x8C8C -#define GL_SEPARATE_ATTRIBS_EXT 0x8C8D -#define GL_TRANSFORM_FEEDBACK_BUFFER_EXT 0x8C8E -#define GL_TRANSFORM_FEEDBACK_BUFFER_BINDING_EXT 0x8C8F - -typedef void (GLAPIENTRY * PFNGLBEGINTRANSFORMFEEDBACKEXTPROC) (GLenum primitiveMode); -typedef void (GLAPIENTRY * PFNGLBINDBUFFERBASEEXTPROC) (GLenum target, GLuint index, GLuint buffer); -typedef void (GLAPIENTRY * PFNGLBINDBUFFEROFFSETEXTPROC) (GLenum target, GLuint index, GLuint buffer, GLintptr offset); -typedef void (GLAPIENTRY * PFNGLBINDBUFFERRANGEEXTPROC) (GLenum target, GLuint index, GLuint buffer, GLintptr offset, GLsizeiptr size); -typedef void (GLAPIENTRY * PFNGLENDTRANSFORMFEEDBACKEXTPROC) (void); -typedef void (GLAPIENTRY * PFNGLGETTRANSFORMFEEDBACKVARYINGEXTPROC) (GLuint program, GLuint index, GLsizei bufSize, GLsizei* length, GLsizei *size, GLenum *type, GLchar *name); -typedef void (GLAPIENTRY * PFNGLTRANSFORMFEEDBACKVARYINGSEXTPROC) (GLuint program, GLsizei count, const GLchar * const* varyings, GLenum bufferMode); - -#define glBeginTransformFeedbackEXT GLEW_GET_FUN(__glewBeginTransformFeedbackEXT) -#define glBindBufferBaseEXT GLEW_GET_FUN(__glewBindBufferBaseEXT) -#define glBindBufferOffsetEXT GLEW_GET_FUN(__glewBindBufferOffsetEXT) -#define glBindBufferRangeEXT GLEW_GET_FUN(__glewBindBufferRangeEXT) -#define glEndTransformFeedbackEXT GLEW_GET_FUN(__glewEndTransformFeedbackEXT) -#define glGetTransformFeedbackVaryingEXT GLEW_GET_FUN(__glewGetTransformFeedbackVaryingEXT) -#define glTransformFeedbackVaryingsEXT GLEW_GET_FUN(__glewTransformFeedbackVaryingsEXT) - -#define GLEW_EXT_transform_feedback GLEW_GET_VAR(__GLEW_EXT_transform_feedback) - -#endif /* GL_EXT_transform_feedback */ - -/* -------------------------- GL_EXT_vertex_array -------------------------- */ - -#ifndef GL_EXT_vertex_array -#define GL_EXT_vertex_array 1 - -#define GL_DOUBLE_EXT 0x140A -#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 - -typedef void (GLAPIENTRY * PFNGLARRAYELEMENTEXTPROC) (GLint i); -typedef void (GLAPIENTRY * PFNGLCOLORPOINTEREXTPROC) (GLint size, GLenum type, GLsizei stride, GLsizei count, const void *pointer); -typedef void (GLAPIENTRY * PFNGLDRAWARRAYSEXTPROC) (GLenum mode, GLint first, GLsizei count); -typedef void (GLAPIENTRY * PFNGLEDGEFLAGPOINTEREXTPROC) (GLsizei stride, GLsizei count, const GLboolean* pointer); -typedef void (GLAPIENTRY * PFNGLINDEXPOINTEREXTPROC) (GLenum type, GLsizei stride, GLsizei count, const void *pointer); -typedef void (GLAPIENTRY * PFNGLNORMALPOINTEREXTPROC) (GLenum type, GLsizei stride, GLsizei count, const void *pointer); -typedef void (GLAPIENTRY * PFNGLTEXCOORDPOINTEREXTPROC) (GLint size, GLenum type, GLsizei stride, GLsizei count, const void *pointer); -typedef void (GLAPIENTRY * PFNGLVERTEXPOINTEREXTPROC) (GLint size, GLenum type, GLsizei stride, GLsizei count, const void *pointer); - -#define glArrayElementEXT GLEW_GET_FUN(__glewArrayElementEXT) -#define glColorPointerEXT GLEW_GET_FUN(__glewColorPointerEXT) -#define glDrawArraysEXT GLEW_GET_FUN(__glewDrawArraysEXT) -#define glEdgeFlagPointerEXT GLEW_GET_FUN(__glewEdgeFlagPointerEXT) -#define glIndexPointerEXT GLEW_GET_FUN(__glewIndexPointerEXT) -#define glNormalPointerEXT GLEW_GET_FUN(__glewNormalPointerEXT) -#define glTexCoordPointerEXT GLEW_GET_FUN(__glewTexCoordPointerEXT) -#define glVertexPointerEXT GLEW_GET_FUN(__glewVertexPointerEXT) - -#define GLEW_EXT_vertex_array GLEW_GET_VAR(__GLEW_EXT_vertex_array) - -#endif /* GL_EXT_vertex_array */ - -/* ------------------------ GL_EXT_vertex_array_bgra ----------------------- */ - -#ifndef GL_EXT_vertex_array_bgra -#define GL_EXT_vertex_array_bgra 1 - -#define GL_BGRA 0x80E1 - -#define GLEW_EXT_vertex_array_bgra GLEW_GET_VAR(__GLEW_EXT_vertex_array_bgra) - -#endif /* GL_EXT_vertex_array_bgra */ - -/* ----------------------- GL_EXT_vertex_attrib_64bit ---------------------- */ - -#ifndef GL_EXT_vertex_attrib_64bit -#define GL_EXT_vertex_attrib_64bit 1 - -#define GL_DOUBLE_MAT2_EXT 0x8F46 -#define GL_DOUBLE_MAT3_EXT 0x8F47 -#define GL_DOUBLE_MAT4_EXT 0x8F48 -#define GL_DOUBLE_MAT2x3_EXT 0x8F49 -#define GL_DOUBLE_MAT2x4_EXT 0x8F4A -#define GL_DOUBLE_MAT3x2_EXT 0x8F4B -#define GL_DOUBLE_MAT3x4_EXT 0x8F4C -#define GL_DOUBLE_MAT4x2_EXT 0x8F4D -#define GL_DOUBLE_MAT4x3_EXT 0x8F4E -#define GL_DOUBLE_VEC2_EXT 0x8FFC -#define GL_DOUBLE_VEC3_EXT 0x8FFD -#define GL_DOUBLE_VEC4_EXT 0x8FFE - -typedef void (GLAPIENTRY * PFNGLGETVERTEXATTRIBLDVEXTPROC) (GLuint index, GLenum pname, GLdouble* params); -typedef void (GLAPIENTRY * PFNGLVERTEXARRAYVERTEXATTRIBLOFFSETEXTPROC) (GLuint vaobj, GLuint buffer, GLuint index, GLint size, GLenum type, GLsizei stride, GLintptr offset); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBL1DEXTPROC) (GLuint index, GLdouble x); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBL1DVEXTPROC) (GLuint index, const GLdouble* v); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBL2DEXTPROC) (GLuint index, GLdouble x, GLdouble y); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBL2DVEXTPROC) (GLuint index, const GLdouble* v); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBL3DEXTPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBL3DVEXTPROC) (GLuint index, const GLdouble* v); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBL4DEXTPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBL4DVEXTPROC) (GLuint index, const GLdouble* v); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBLPOINTEREXTPROC) (GLuint index, GLint size, GLenum type, GLsizei stride, const void *pointer); - -#define glGetVertexAttribLdvEXT GLEW_GET_FUN(__glewGetVertexAttribLdvEXT) -#define glVertexArrayVertexAttribLOffsetEXT GLEW_GET_FUN(__glewVertexArrayVertexAttribLOffsetEXT) -#define glVertexAttribL1dEXT GLEW_GET_FUN(__glewVertexAttribL1dEXT) -#define glVertexAttribL1dvEXT GLEW_GET_FUN(__glewVertexAttribL1dvEXT) -#define glVertexAttribL2dEXT GLEW_GET_FUN(__glewVertexAttribL2dEXT) -#define glVertexAttribL2dvEXT GLEW_GET_FUN(__glewVertexAttribL2dvEXT) -#define glVertexAttribL3dEXT GLEW_GET_FUN(__glewVertexAttribL3dEXT) -#define glVertexAttribL3dvEXT GLEW_GET_FUN(__glewVertexAttribL3dvEXT) -#define glVertexAttribL4dEXT GLEW_GET_FUN(__glewVertexAttribL4dEXT) -#define glVertexAttribL4dvEXT GLEW_GET_FUN(__glewVertexAttribL4dvEXT) -#define glVertexAttribLPointerEXT GLEW_GET_FUN(__glewVertexAttribLPointerEXT) - -#define GLEW_EXT_vertex_attrib_64bit GLEW_GET_VAR(__GLEW_EXT_vertex_attrib_64bit) - -#endif /* GL_EXT_vertex_attrib_64bit */ - -/* -------------------------- GL_EXT_vertex_shader ------------------------- */ - -#ifndef GL_EXT_vertex_shader -#define GL_EXT_vertex_shader 1 - -#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_INVARIANTS_EXT 0x87CC -#define GL_MAX_OPTIMIZED_VERTEX_SHADER_LOCAL_CONSTANTS_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 - -typedef void (GLAPIENTRY * PFNGLBEGINVERTEXSHADEREXTPROC) (void); -typedef GLuint (GLAPIENTRY * PFNGLBINDLIGHTPARAMETEREXTPROC) (GLenum light, GLenum value); -typedef GLuint (GLAPIENTRY * PFNGLBINDMATERIALPARAMETEREXTPROC) (GLenum face, GLenum value); -typedef GLuint (GLAPIENTRY * PFNGLBINDPARAMETEREXTPROC) (GLenum value); -typedef GLuint (GLAPIENTRY * PFNGLBINDTEXGENPARAMETEREXTPROC) (GLenum unit, GLenum coord, GLenum value); -typedef GLuint (GLAPIENTRY * PFNGLBINDTEXTUREUNITPARAMETEREXTPROC) (GLenum unit, GLenum value); -typedef void (GLAPIENTRY * PFNGLBINDVERTEXSHADEREXTPROC) (GLuint id); -typedef void (GLAPIENTRY * PFNGLDELETEVERTEXSHADEREXTPROC) (GLuint id); -typedef void (GLAPIENTRY * PFNGLDISABLEVARIANTCLIENTSTATEEXTPROC) (GLuint id); -typedef void (GLAPIENTRY * PFNGLENABLEVARIANTCLIENTSTATEEXTPROC) (GLuint id); -typedef void (GLAPIENTRY * PFNGLENDVERTEXSHADEREXTPROC) (void); -typedef void (GLAPIENTRY * PFNGLEXTRACTCOMPONENTEXTPROC) (GLuint res, GLuint src, GLuint num); -typedef GLuint (GLAPIENTRY * PFNGLGENSYMBOLSEXTPROC) (GLenum dataType, GLenum storageType, GLenum range, GLuint components); -typedef GLuint (GLAPIENTRY * PFNGLGENVERTEXSHADERSEXTPROC) (GLuint range); -typedef void (GLAPIENTRY * PFNGLGETINVARIANTBOOLEANVEXTPROC) (GLuint id, GLenum value, GLboolean *data); -typedef void (GLAPIENTRY * PFNGLGETINVARIANTFLOATVEXTPROC) (GLuint id, GLenum value, GLfloat *data); -typedef void (GLAPIENTRY * PFNGLGETINVARIANTINTEGERVEXTPROC) (GLuint id, GLenum value, GLint *data); -typedef void (GLAPIENTRY * PFNGLGETLOCALCONSTANTBOOLEANVEXTPROC) (GLuint id, GLenum value, GLboolean *data); -typedef void (GLAPIENTRY * PFNGLGETLOCALCONSTANTFLOATVEXTPROC) (GLuint id, GLenum value, GLfloat *data); -typedef void (GLAPIENTRY * PFNGLGETLOCALCONSTANTINTEGERVEXTPROC) (GLuint id, GLenum value, GLint *data); -typedef void (GLAPIENTRY * PFNGLGETVARIANTBOOLEANVEXTPROC) (GLuint id, GLenum value, GLboolean *data); -typedef void (GLAPIENTRY * PFNGLGETVARIANTFLOATVEXTPROC) (GLuint id, GLenum value, GLfloat *data); -typedef void (GLAPIENTRY * PFNGLGETVARIANTINTEGERVEXTPROC) (GLuint id, GLenum value, GLint *data); -typedef void (GLAPIENTRY * PFNGLGETVARIANTPOINTERVEXTPROC) (GLuint id, GLenum value, void **data); -typedef void (GLAPIENTRY * PFNGLINSERTCOMPONENTEXTPROC) (GLuint res, GLuint src, GLuint num); -typedef GLboolean (GLAPIENTRY * PFNGLISVARIANTENABLEDEXTPROC) (GLuint id, GLenum cap); -typedef void (GLAPIENTRY * PFNGLSETINVARIANTEXTPROC) (GLuint id, GLenum type, void *addr); -typedef void (GLAPIENTRY * PFNGLSETLOCALCONSTANTEXTPROC) (GLuint id, GLenum type, void *addr); -typedef void (GLAPIENTRY * PFNGLSHADEROP1EXTPROC) (GLenum op, GLuint res, GLuint arg1); -typedef void (GLAPIENTRY * PFNGLSHADEROP2EXTPROC) (GLenum op, GLuint res, GLuint arg1, GLuint arg2); -typedef void (GLAPIENTRY * PFNGLSHADEROP3EXTPROC) (GLenum op, GLuint res, GLuint arg1, GLuint arg2, GLuint arg3); -typedef void (GLAPIENTRY * PFNGLSWIZZLEEXTPROC) (GLuint res, GLuint in, GLenum outX, GLenum outY, GLenum outZ, GLenum outW); -typedef void (GLAPIENTRY * PFNGLVARIANTPOINTEREXTPROC) (GLuint id, GLenum type, GLuint stride, void *addr); -typedef void (GLAPIENTRY * PFNGLVARIANTBVEXTPROC) (GLuint id, GLbyte *addr); -typedef void (GLAPIENTRY * PFNGLVARIANTDVEXTPROC) (GLuint id, GLdouble *addr); -typedef void (GLAPIENTRY * PFNGLVARIANTFVEXTPROC) (GLuint id, GLfloat *addr); -typedef void (GLAPIENTRY * PFNGLVARIANTIVEXTPROC) (GLuint id, GLint *addr); -typedef void (GLAPIENTRY * PFNGLVARIANTSVEXTPROC) (GLuint id, GLshort *addr); -typedef void (GLAPIENTRY * PFNGLVARIANTUBVEXTPROC) (GLuint id, GLubyte *addr); -typedef void (GLAPIENTRY * PFNGLVARIANTUIVEXTPROC) (GLuint id, GLuint *addr); -typedef void (GLAPIENTRY * PFNGLVARIANTUSVEXTPROC) (GLuint id, GLushort *addr); -typedef void (GLAPIENTRY * PFNGLWRITEMASKEXTPROC) (GLuint res, GLuint in, GLenum outX, GLenum outY, GLenum outZ, GLenum outW); - -#define glBeginVertexShaderEXT GLEW_GET_FUN(__glewBeginVertexShaderEXT) -#define glBindLightParameterEXT GLEW_GET_FUN(__glewBindLightParameterEXT) -#define glBindMaterialParameterEXT GLEW_GET_FUN(__glewBindMaterialParameterEXT) -#define glBindParameterEXT GLEW_GET_FUN(__glewBindParameterEXT) -#define glBindTexGenParameterEXT GLEW_GET_FUN(__glewBindTexGenParameterEXT) -#define glBindTextureUnitParameterEXT GLEW_GET_FUN(__glewBindTextureUnitParameterEXT) -#define glBindVertexShaderEXT GLEW_GET_FUN(__glewBindVertexShaderEXT) -#define glDeleteVertexShaderEXT GLEW_GET_FUN(__glewDeleteVertexShaderEXT) -#define glDisableVariantClientStateEXT GLEW_GET_FUN(__glewDisableVariantClientStateEXT) -#define glEnableVariantClientStateEXT GLEW_GET_FUN(__glewEnableVariantClientStateEXT) -#define glEndVertexShaderEXT GLEW_GET_FUN(__glewEndVertexShaderEXT) -#define glExtractComponentEXT GLEW_GET_FUN(__glewExtractComponentEXT) -#define glGenSymbolsEXT GLEW_GET_FUN(__glewGenSymbolsEXT) -#define glGenVertexShadersEXT GLEW_GET_FUN(__glewGenVertexShadersEXT) -#define glGetInvariantBooleanvEXT GLEW_GET_FUN(__glewGetInvariantBooleanvEXT) -#define glGetInvariantFloatvEXT GLEW_GET_FUN(__glewGetInvariantFloatvEXT) -#define glGetInvariantIntegervEXT GLEW_GET_FUN(__glewGetInvariantIntegervEXT) -#define glGetLocalConstantBooleanvEXT GLEW_GET_FUN(__glewGetLocalConstantBooleanvEXT) -#define glGetLocalConstantFloatvEXT GLEW_GET_FUN(__glewGetLocalConstantFloatvEXT) -#define glGetLocalConstantIntegervEXT GLEW_GET_FUN(__glewGetLocalConstantIntegervEXT) -#define glGetVariantBooleanvEXT GLEW_GET_FUN(__glewGetVariantBooleanvEXT) -#define glGetVariantFloatvEXT GLEW_GET_FUN(__glewGetVariantFloatvEXT) -#define glGetVariantIntegervEXT GLEW_GET_FUN(__glewGetVariantIntegervEXT) -#define glGetVariantPointervEXT GLEW_GET_FUN(__glewGetVariantPointervEXT) -#define glInsertComponentEXT GLEW_GET_FUN(__glewInsertComponentEXT) -#define glIsVariantEnabledEXT GLEW_GET_FUN(__glewIsVariantEnabledEXT) -#define glSetInvariantEXT GLEW_GET_FUN(__glewSetInvariantEXT) -#define glSetLocalConstantEXT GLEW_GET_FUN(__glewSetLocalConstantEXT) -#define glShaderOp1EXT GLEW_GET_FUN(__glewShaderOp1EXT) -#define glShaderOp2EXT GLEW_GET_FUN(__glewShaderOp2EXT) -#define glShaderOp3EXT GLEW_GET_FUN(__glewShaderOp3EXT) -#define glSwizzleEXT GLEW_GET_FUN(__glewSwizzleEXT) -#define glVariantPointerEXT GLEW_GET_FUN(__glewVariantPointerEXT) -#define glVariantbvEXT GLEW_GET_FUN(__glewVariantbvEXT) -#define glVariantdvEXT GLEW_GET_FUN(__glewVariantdvEXT) -#define glVariantfvEXT GLEW_GET_FUN(__glewVariantfvEXT) -#define glVariantivEXT GLEW_GET_FUN(__glewVariantivEXT) -#define glVariantsvEXT GLEW_GET_FUN(__glewVariantsvEXT) -#define glVariantubvEXT GLEW_GET_FUN(__glewVariantubvEXT) -#define glVariantuivEXT GLEW_GET_FUN(__glewVariantuivEXT) -#define glVariantusvEXT GLEW_GET_FUN(__glewVariantusvEXT) -#define glWriteMaskEXT GLEW_GET_FUN(__glewWriteMaskEXT) - -#define GLEW_EXT_vertex_shader GLEW_GET_VAR(__GLEW_EXT_vertex_shader) - -#endif /* GL_EXT_vertex_shader */ - -/* ------------------------ GL_EXT_vertex_weighting ------------------------ */ - -#ifndef GL_EXT_vertex_weighting -#define GL_EXT_vertex_weighting 1 - -#define GL_MODELVIEW0_STACK_DEPTH_EXT 0x0BA3 -#define GL_MODELVIEW0_MATRIX_EXT 0x0BA6 -#define GL_MODELVIEW0_EXT 0x1700 -#define GL_MODELVIEW1_STACK_DEPTH_EXT 0x8502 -#define GL_MODELVIEW1_MATRIX_EXT 0x8506 -#define GL_VERTEX_WEIGHTING_EXT 0x8509 -#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 - -typedef void (GLAPIENTRY * PFNGLVERTEXWEIGHTPOINTEREXTPROC) (GLint size, GLenum type, GLsizei stride, void *pointer); -typedef void (GLAPIENTRY * PFNGLVERTEXWEIGHTFEXTPROC) (GLfloat weight); -typedef void (GLAPIENTRY * PFNGLVERTEXWEIGHTFVEXTPROC) (GLfloat* weight); - -#define glVertexWeightPointerEXT GLEW_GET_FUN(__glewVertexWeightPointerEXT) -#define glVertexWeightfEXT GLEW_GET_FUN(__glewVertexWeightfEXT) -#define glVertexWeightfvEXT GLEW_GET_FUN(__glewVertexWeightfvEXT) - -#define GLEW_EXT_vertex_weighting GLEW_GET_VAR(__GLEW_EXT_vertex_weighting) - -#endif /* GL_EXT_vertex_weighting */ - -/* ------------------------ GL_EXT_window_rectangles ----------------------- */ - -#ifndef GL_EXT_window_rectangles -#define GL_EXT_window_rectangles 1 - -#define GL_INCLUSIVE_EXT 0x8F10 -#define GL_EXCLUSIVE_EXT 0x8F11 -#define GL_WINDOW_RECTANGLE_EXT 0x8F12 -#define GL_WINDOW_RECTANGLE_MODE_EXT 0x8F13 -#define GL_MAX_WINDOW_RECTANGLES_EXT 0x8F14 -#define GL_NUM_WINDOW_RECTANGLES_EXT 0x8F15 - -typedef void (GLAPIENTRY * PFNGLWINDOWRECTANGLESEXTPROC) (GLenum mode, GLsizei count, const GLint box[]); - -#define glWindowRectanglesEXT GLEW_GET_FUN(__glewWindowRectanglesEXT) - -#define GLEW_EXT_window_rectangles GLEW_GET_VAR(__GLEW_EXT_window_rectangles) - -#endif /* GL_EXT_window_rectangles */ - -/* ------------------------- GL_EXT_x11_sync_object ------------------------ */ - -#ifndef GL_EXT_x11_sync_object -#define GL_EXT_x11_sync_object 1 - -#define GL_SYNC_X11_FENCE_EXT 0x90E1 - -typedef GLsync (GLAPIENTRY * PFNGLIMPORTSYNCEXTPROC) (GLenum external_sync_type, GLintptr external_sync, GLbitfield flags); - -#define glImportSyncEXT GLEW_GET_FUN(__glewImportSyncEXT) - -#define GLEW_EXT_x11_sync_object GLEW_GET_VAR(__GLEW_EXT_x11_sync_object) - -#endif /* GL_EXT_x11_sync_object */ - -/* ---------------------- GL_GREMEDY_frame_terminator ---------------------- */ - -#ifndef GL_GREMEDY_frame_terminator -#define GL_GREMEDY_frame_terminator 1 - -typedef void (GLAPIENTRY * PFNGLFRAMETERMINATORGREMEDYPROC) (void); - -#define glFrameTerminatorGREMEDY GLEW_GET_FUN(__glewFrameTerminatorGREMEDY) - -#define GLEW_GREMEDY_frame_terminator GLEW_GET_VAR(__GLEW_GREMEDY_frame_terminator) - -#endif /* GL_GREMEDY_frame_terminator */ - -/* ------------------------ GL_GREMEDY_string_marker ----------------------- */ - -#ifndef GL_GREMEDY_string_marker -#define GL_GREMEDY_string_marker 1 - -typedef void (GLAPIENTRY * PFNGLSTRINGMARKERGREMEDYPROC) (GLsizei len, const void *string); - -#define glStringMarkerGREMEDY GLEW_GET_FUN(__glewStringMarkerGREMEDY) - -#define GLEW_GREMEDY_string_marker GLEW_GET_VAR(__GLEW_GREMEDY_string_marker) - -#endif /* GL_GREMEDY_string_marker */ - -/* --------------------- GL_HP_convolution_border_modes -------------------- */ - -#ifndef GL_HP_convolution_border_modes -#define GL_HP_convolution_border_modes 1 - -#define GLEW_HP_convolution_border_modes GLEW_GET_VAR(__GLEW_HP_convolution_border_modes) - -#endif /* GL_HP_convolution_border_modes */ - -/* ------------------------- GL_HP_image_transform ------------------------- */ - -#ifndef GL_HP_image_transform -#define GL_HP_image_transform 1 - -typedef void (GLAPIENTRY * PFNGLGETIMAGETRANSFORMPARAMETERFVHPPROC) (GLenum target, GLenum pname, const GLfloat* params); -typedef void (GLAPIENTRY * PFNGLGETIMAGETRANSFORMPARAMETERIVHPPROC) (GLenum target, GLenum pname, const GLint* params); -typedef void (GLAPIENTRY * PFNGLIMAGETRANSFORMPARAMETERFHPPROC) (GLenum target, GLenum pname, const GLfloat param); -typedef void (GLAPIENTRY * PFNGLIMAGETRANSFORMPARAMETERFVHPPROC) (GLenum target, GLenum pname, const GLfloat* params); -typedef void (GLAPIENTRY * PFNGLIMAGETRANSFORMPARAMETERIHPPROC) (GLenum target, GLenum pname, const GLint param); -typedef void (GLAPIENTRY * PFNGLIMAGETRANSFORMPARAMETERIVHPPROC) (GLenum target, GLenum pname, const GLint* params); - -#define glGetImageTransformParameterfvHP GLEW_GET_FUN(__glewGetImageTransformParameterfvHP) -#define glGetImageTransformParameterivHP GLEW_GET_FUN(__glewGetImageTransformParameterivHP) -#define glImageTransformParameterfHP GLEW_GET_FUN(__glewImageTransformParameterfHP) -#define glImageTransformParameterfvHP GLEW_GET_FUN(__glewImageTransformParameterfvHP) -#define glImageTransformParameteriHP GLEW_GET_FUN(__glewImageTransformParameteriHP) -#define glImageTransformParameterivHP GLEW_GET_FUN(__glewImageTransformParameterivHP) - -#define GLEW_HP_image_transform GLEW_GET_VAR(__GLEW_HP_image_transform) - -#endif /* GL_HP_image_transform */ - -/* -------------------------- GL_HP_occlusion_test ------------------------- */ - -#ifndef GL_HP_occlusion_test -#define GL_HP_occlusion_test 1 - -#define GLEW_HP_occlusion_test GLEW_GET_VAR(__GLEW_HP_occlusion_test) - -#endif /* GL_HP_occlusion_test */ - -/* ------------------------- GL_HP_texture_lighting ------------------------ */ - -#ifndef GL_HP_texture_lighting -#define GL_HP_texture_lighting 1 - -#define GLEW_HP_texture_lighting GLEW_GET_VAR(__GLEW_HP_texture_lighting) - -#endif /* GL_HP_texture_lighting */ - -/* --------------------------- GL_IBM_cull_vertex -------------------------- */ - -#ifndef GL_IBM_cull_vertex -#define GL_IBM_cull_vertex 1 - -#define GL_CULL_VERTEX_IBM 103050 - -#define GLEW_IBM_cull_vertex GLEW_GET_VAR(__GLEW_IBM_cull_vertex) - -#endif /* GL_IBM_cull_vertex */ - -/* ---------------------- GL_IBM_multimode_draw_arrays --------------------- */ - -#ifndef GL_IBM_multimode_draw_arrays -#define GL_IBM_multimode_draw_arrays 1 - -typedef void (GLAPIENTRY * PFNGLMULTIMODEDRAWARRAYSIBMPROC) (const GLenum* mode, const GLint *first, const GLsizei *count, GLsizei primcount, GLint modestride); -typedef void (GLAPIENTRY * PFNGLMULTIMODEDRAWELEMENTSIBMPROC) (const GLenum* mode, const GLsizei *count, GLenum type, const void *const *indices, GLsizei primcount, GLint modestride); - -#define glMultiModeDrawArraysIBM GLEW_GET_FUN(__glewMultiModeDrawArraysIBM) -#define glMultiModeDrawElementsIBM GLEW_GET_FUN(__glewMultiModeDrawElementsIBM) - -#define GLEW_IBM_multimode_draw_arrays GLEW_GET_VAR(__GLEW_IBM_multimode_draw_arrays) - -#endif /* GL_IBM_multimode_draw_arrays */ - -/* ------------------------- GL_IBM_rasterpos_clip ------------------------- */ - -#ifndef GL_IBM_rasterpos_clip -#define GL_IBM_rasterpos_clip 1 - -#define GL_RASTER_POSITION_UNCLIPPED_IBM 103010 - -#define GLEW_IBM_rasterpos_clip GLEW_GET_VAR(__GLEW_IBM_rasterpos_clip) - -#endif /* GL_IBM_rasterpos_clip */ - -/* --------------------------- GL_IBM_static_data -------------------------- */ - -#ifndef GL_IBM_static_data -#define GL_IBM_static_data 1 - -#define GL_ALL_STATIC_DATA_IBM 103060 -#define GL_STATIC_VERTEX_ARRAY_IBM 103061 - -#define GLEW_IBM_static_data GLEW_GET_VAR(__GLEW_IBM_static_data) - -#endif /* GL_IBM_static_data */ - -/* --------------------- GL_IBM_texture_mirrored_repeat -------------------- */ - -#ifndef GL_IBM_texture_mirrored_repeat -#define GL_IBM_texture_mirrored_repeat 1 - -#define GL_MIRRORED_REPEAT_IBM 0x8370 - -#define GLEW_IBM_texture_mirrored_repeat GLEW_GET_VAR(__GLEW_IBM_texture_mirrored_repeat) - -#endif /* GL_IBM_texture_mirrored_repeat */ - -/* ----------------------- GL_IBM_vertex_array_lists ----------------------- */ - -#ifndef GL_IBM_vertex_array_lists -#define GL_IBM_vertex_array_lists 1 - -#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 - -typedef void (GLAPIENTRY * PFNGLCOLORPOINTERLISTIBMPROC) (GLint size, GLenum type, GLint stride, const void** pointer, GLint ptrstride); -typedef void (GLAPIENTRY * PFNGLEDGEFLAGPOINTERLISTIBMPROC) (GLint stride, const GLboolean ** pointer, GLint ptrstride); -typedef void (GLAPIENTRY * PFNGLFOGCOORDPOINTERLISTIBMPROC) (GLenum type, GLint stride, const void** pointer, GLint ptrstride); -typedef void (GLAPIENTRY * PFNGLINDEXPOINTERLISTIBMPROC) (GLenum type, GLint stride, const void** pointer, GLint ptrstride); -typedef void (GLAPIENTRY * PFNGLNORMALPOINTERLISTIBMPROC) (GLenum type, GLint stride, const void** pointer, GLint ptrstride); -typedef void (GLAPIENTRY * PFNGLSECONDARYCOLORPOINTERLISTIBMPROC) (GLint size, GLenum type, GLint stride, const void** pointer, GLint ptrstride); -typedef void (GLAPIENTRY * PFNGLTEXCOORDPOINTERLISTIBMPROC) (GLint size, GLenum type, GLint stride, const void** pointer, GLint ptrstride); -typedef void (GLAPIENTRY * PFNGLVERTEXPOINTERLISTIBMPROC) (GLint size, GLenum type, GLint stride, const void** pointer, GLint ptrstride); - -#define glColorPointerListIBM GLEW_GET_FUN(__glewColorPointerListIBM) -#define glEdgeFlagPointerListIBM GLEW_GET_FUN(__glewEdgeFlagPointerListIBM) -#define glFogCoordPointerListIBM GLEW_GET_FUN(__glewFogCoordPointerListIBM) -#define glIndexPointerListIBM GLEW_GET_FUN(__glewIndexPointerListIBM) -#define glNormalPointerListIBM GLEW_GET_FUN(__glewNormalPointerListIBM) -#define glSecondaryColorPointerListIBM GLEW_GET_FUN(__glewSecondaryColorPointerListIBM) -#define glTexCoordPointerListIBM GLEW_GET_FUN(__glewTexCoordPointerListIBM) -#define glVertexPointerListIBM GLEW_GET_FUN(__glewVertexPointerListIBM) - -#define GLEW_IBM_vertex_array_lists GLEW_GET_VAR(__GLEW_IBM_vertex_array_lists) - -#endif /* GL_IBM_vertex_array_lists */ - -/* -------------------------- GL_INGR_color_clamp -------------------------- */ - -#ifndef GL_INGR_color_clamp -#define GL_INGR_color_clamp 1 - -#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 - -#define GLEW_INGR_color_clamp GLEW_GET_VAR(__GLEW_INGR_color_clamp) - -#endif /* GL_INGR_color_clamp */ - -/* ------------------------- GL_INGR_interlace_read ------------------------ */ - -#ifndef GL_INGR_interlace_read -#define GL_INGR_interlace_read 1 - -#define GL_INTERLACE_READ_INGR 0x8568 - -#define GLEW_INGR_interlace_read GLEW_GET_VAR(__GLEW_INGR_interlace_read) - -#endif /* GL_INGR_interlace_read */ - -/* ------------------ GL_INTEL_conservative_rasterization ------------------ */ - -#ifndef GL_INTEL_conservative_rasterization -#define GL_INTEL_conservative_rasterization 1 - -#define GL_CONSERVATIVE_RASTERIZATION_INTEL 0x83FE - -#define GLEW_INTEL_conservative_rasterization GLEW_GET_VAR(__GLEW_INTEL_conservative_rasterization) - -#endif /* GL_INTEL_conservative_rasterization */ - -/* ------------------- GL_INTEL_fragment_shader_ordering ------------------- */ - -#ifndef GL_INTEL_fragment_shader_ordering -#define GL_INTEL_fragment_shader_ordering 1 - -#define GLEW_INTEL_fragment_shader_ordering GLEW_GET_VAR(__GLEW_INTEL_fragment_shader_ordering) - -#endif /* GL_INTEL_fragment_shader_ordering */ - -/* ----------------------- GL_INTEL_framebuffer_CMAA ----------------------- */ - -#ifndef GL_INTEL_framebuffer_CMAA -#define GL_INTEL_framebuffer_CMAA 1 - -#define GLEW_INTEL_framebuffer_CMAA GLEW_GET_VAR(__GLEW_INTEL_framebuffer_CMAA) - -#endif /* GL_INTEL_framebuffer_CMAA */ - -/* -------------------------- GL_INTEL_map_texture ------------------------- */ - -#ifndef GL_INTEL_map_texture -#define GL_INTEL_map_texture 1 - -#define GL_LAYOUT_DEFAULT_INTEL 0 -#define GL_LAYOUT_LINEAR_INTEL 1 -#define GL_LAYOUT_LINEAR_CPU_CACHED_INTEL 2 -#define GL_TEXTURE_MEMORY_LAYOUT_INTEL 0x83FF - -typedef void * (GLAPIENTRY * PFNGLMAPTEXTURE2DINTELPROC) (GLuint texture, GLint level, GLbitfield access, GLint* stride, GLenum *layout); -typedef void (GLAPIENTRY * PFNGLSYNCTEXTUREINTELPROC) (GLuint texture); -typedef void (GLAPIENTRY * PFNGLUNMAPTEXTURE2DINTELPROC) (GLuint texture, GLint level); - -#define glMapTexture2DINTEL GLEW_GET_FUN(__glewMapTexture2DINTEL) -#define glSyncTextureINTEL GLEW_GET_FUN(__glewSyncTextureINTEL) -#define glUnmapTexture2DINTEL GLEW_GET_FUN(__glewUnmapTexture2DINTEL) - -#define GLEW_INTEL_map_texture GLEW_GET_VAR(__GLEW_INTEL_map_texture) - -#endif /* GL_INTEL_map_texture */ - -/* ------------------------ GL_INTEL_parallel_arrays ----------------------- */ - -#ifndef GL_INTEL_parallel_arrays -#define GL_INTEL_parallel_arrays 1 - -#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 - -typedef void (GLAPIENTRY * PFNGLCOLORPOINTERVINTELPROC) (GLint size, GLenum type, const void** pointer); -typedef void (GLAPIENTRY * PFNGLNORMALPOINTERVINTELPROC) (GLenum type, const void** pointer); -typedef void (GLAPIENTRY * PFNGLTEXCOORDPOINTERVINTELPROC) (GLint size, GLenum type, const void** pointer); -typedef void (GLAPIENTRY * PFNGLVERTEXPOINTERVINTELPROC) (GLint size, GLenum type, const void** pointer); - -#define glColorPointervINTEL GLEW_GET_FUN(__glewColorPointervINTEL) -#define glNormalPointervINTEL GLEW_GET_FUN(__glewNormalPointervINTEL) -#define glTexCoordPointervINTEL GLEW_GET_FUN(__glewTexCoordPointervINTEL) -#define glVertexPointervINTEL GLEW_GET_FUN(__glewVertexPointervINTEL) - -#define GLEW_INTEL_parallel_arrays GLEW_GET_VAR(__GLEW_INTEL_parallel_arrays) - -#endif /* GL_INTEL_parallel_arrays */ - -/* ----------------------- GL_INTEL_performance_query ---------------------- */ - -#ifndef GL_INTEL_performance_query -#define GL_INTEL_performance_query 1 - -#define GL_PERFQUERY_SINGLE_CONTEXT_INTEL 0x0000 -#define GL_PERFQUERY_GLOBAL_CONTEXT_INTEL 0x0001 -#define GL_PERFQUERY_DONOT_FLUSH_INTEL 0x83F9 -#define GL_PERFQUERY_FLUSH_INTEL 0x83FA -#define GL_PERFQUERY_WAIT_INTEL 0x83FB -#define GL_PERFQUERY_COUNTER_EVENT_INTEL 0x94F0 -#define GL_PERFQUERY_COUNTER_DURATION_NORM_INTEL 0x94F1 -#define GL_PERFQUERY_COUNTER_DURATION_RAW_INTEL 0x94F2 -#define GL_PERFQUERY_COUNTER_THROUGHPUT_INTEL 0x94F3 -#define GL_PERFQUERY_COUNTER_RAW_INTEL 0x94F4 -#define GL_PERFQUERY_COUNTER_TIMESTAMP_INTEL 0x94F5 -#define GL_PERFQUERY_COUNTER_DATA_UINT32_INTEL 0x94F8 -#define GL_PERFQUERY_COUNTER_DATA_UINT64_INTEL 0x94F9 -#define GL_PERFQUERY_COUNTER_DATA_FLOAT_INTEL 0x94FA -#define GL_PERFQUERY_COUNTER_DATA_DOUBLE_INTEL 0x94FB -#define GL_PERFQUERY_COUNTER_DATA_BOOL32_INTEL 0x94FC -#define GL_PERFQUERY_QUERY_NAME_LENGTH_MAX_INTEL 0x94FD -#define GL_PERFQUERY_COUNTER_NAME_LENGTH_MAX_INTEL 0x94FE -#define GL_PERFQUERY_COUNTER_DESC_LENGTH_MAX_INTEL 0x94FF -#define GL_PERFQUERY_GPA_EXTENDED_COUNTERS_INTEL 0x9500 - -typedef void (GLAPIENTRY * PFNGLBEGINPERFQUERYINTELPROC) (GLuint queryHandle); -typedef void (GLAPIENTRY * PFNGLCREATEPERFQUERYINTELPROC) (GLuint queryId, GLuint* queryHandle); -typedef void (GLAPIENTRY * PFNGLDELETEPERFQUERYINTELPROC) (GLuint queryHandle); -typedef void (GLAPIENTRY * PFNGLENDPERFQUERYINTELPROC) (GLuint queryHandle); -typedef void (GLAPIENTRY * PFNGLGETFIRSTPERFQUERYIDINTELPROC) (GLuint* queryId); -typedef void (GLAPIENTRY * PFNGLGETNEXTPERFQUERYIDINTELPROC) (GLuint queryId, GLuint* nextQueryId); -typedef void (GLAPIENTRY * PFNGLGETPERFCOUNTERINFOINTELPROC) (GLuint queryId, GLuint counterId, GLuint counterNameLength, GLchar* counterName, GLuint counterDescLength, GLchar *counterDesc, GLuint *counterOffset, GLuint *counterDataSize, GLuint *counterTypeEnum, GLuint *counterDataTypeEnum, GLuint64 *rawCounterMaxValue); -typedef void (GLAPIENTRY * PFNGLGETPERFQUERYDATAINTELPROC) (GLuint queryHandle, GLuint flags, GLsizei dataSize, void *data, GLuint *bytesWritten); -typedef void (GLAPIENTRY * PFNGLGETPERFQUERYIDBYNAMEINTELPROC) (GLchar* queryName, GLuint *queryId); -typedef void (GLAPIENTRY * PFNGLGETPERFQUERYINFOINTELPROC) (GLuint queryId, GLuint queryNameLength, GLchar* queryName, GLuint *dataSize, GLuint *noCounters, GLuint *noInstances, GLuint *capsMask); - -#define glBeginPerfQueryINTEL GLEW_GET_FUN(__glewBeginPerfQueryINTEL) -#define glCreatePerfQueryINTEL GLEW_GET_FUN(__glewCreatePerfQueryINTEL) -#define glDeletePerfQueryINTEL GLEW_GET_FUN(__glewDeletePerfQueryINTEL) -#define glEndPerfQueryINTEL GLEW_GET_FUN(__glewEndPerfQueryINTEL) -#define glGetFirstPerfQueryIdINTEL GLEW_GET_FUN(__glewGetFirstPerfQueryIdINTEL) -#define glGetNextPerfQueryIdINTEL GLEW_GET_FUN(__glewGetNextPerfQueryIdINTEL) -#define glGetPerfCounterInfoINTEL GLEW_GET_FUN(__glewGetPerfCounterInfoINTEL) -#define glGetPerfQueryDataINTEL GLEW_GET_FUN(__glewGetPerfQueryDataINTEL) -#define glGetPerfQueryIdByNameINTEL GLEW_GET_FUN(__glewGetPerfQueryIdByNameINTEL) -#define glGetPerfQueryInfoINTEL GLEW_GET_FUN(__glewGetPerfQueryInfoINTEL) - -#define GLEW_INTEL_performance_query GLEW_GET_VAR(__GLEW_INTEL_performance_query) - -#endif /* GL_INTEL_performance_query */ - -/* ------------------------ GL_INTEL_texture_scissor ----------------------- */ - -#ifndef GL_INTEL_texture_scissor -#define GL_INTEL_texture_scissor 1 - -typedef void (GLAPIENTRY * PFNGLTEXSCISSORFUNCINTELPROC) (GLenum target, GLenum lfunc, GLenum hfunc); -typedef void (GLAPIENTRY * PFNGLTEXSCISSORINTELPROC) (GLenum target, GLclampf tlow, GLclampf thigh); - -#define glTexScissorFuncINTEL GLEW_GET_FUN(__glewTexScissorFuncINTEL) -#define glTexScissorINTEL GLEW_GET_FUN(__glewTexScissorINTEL) - -#define GLEW_INTEL_texture_scissor GLEW_GET_VAR(__GLEW_INTEL_texture_scissor) - -#endif /* GL_INTEL_texture_scissor */ - -/* --------------------- GL_KHR_blend_equation_advanced -------------------- */ - -#ifndef GL_KHR_blend_equation_advanced -#define GL_KHR_blend_equation_advanced 1 - -#define GL_BLEND_ADVANCED_COHERENT_KHR 0x9285 -#define GL_MULTIPLY_KHR 0x9294 -#define GL_SCREEN_KHR 0x9295 -#define GL_OVERLAY_KHR 0x9296 -#define GL_DARKEN_KHR 0x9297 -#define GL_LIGHTEN_KHR 0x9298 -#define GL_COLORDODGE_KHR 0x9299 -#define GL_COLORBURN_KHR 0x929A -#define GL_HARDLIGHT_KHR 0x929B -#define GL_SOFTLIGHT_KHR 0x929C -#define GL_DIFFERENCE_KHR 0x929E -#define GL_EXCLUSION_KHR 0x92A0 -#define GL_HSL_HUE_KHR 0x92AD -#define GL_HSL_SATURATION_KHR 0x92AE -#define GL_HSL_COLOR_KHR 0x92AF -#define GL_HSL_LUMINOSITY_KHR 0x92B0 - -typedef void (GLAPIENTRY * PFNGLBLENDBARRIERKHRPROC) (void); - -#define glBlendBarrierKHR GLEW_GET_FUN(__glewBlendBarrierKHR) - -#define GLEW_KHR_blend_equation_advanced GLEW_GET_VAR(__GLEW_KHR_blend_equation_advanced) - -#endif /* GL_KHR_blend_equation_advanced */ - -/* ---------------- GL_KHR_blend_equation_advanced_coherent ---------------- */ - -#ifndef GL_KHR_blend_equation_advanced_coherent -#define GL_KHR_blend_equation_advanced_coherent 1 - -#define GLEW_KHR_blend_equation_advanced_coherent GLEW_GET_VAR(__GLEW_KHR_blend_equation_advanced_coherent) - -#endif /* GL_KHR_blend_equation_advanced_coherent */ - -/* ---------------------- GL_KHR_context_flush_control --------------------- */ - -#ifndef GL_KHR_context_flush_control -#define GL_KHR_context_flush_control 1 - -#define GL_CONTEXT_RELEASE_BEHAVIOR 0x82FB -#define GL_CONTEXT_RELEASE_BEHAVIOR_FLUSH 0x82FC - -#define GLEW_KHR_context_flush_control GLEW_GET_VAR(__GLEW_KHR_context_flush_control) - -#endif /* GL_KHR_context_flush_control */ - -/* ------------------------------ GL_KHR_debug ----------------------------- */ - -#ifndef GL_KHR_debug -#define GL_KHR_debug 1 - -#define GL_CONTEXT_FLAG_DEBUG_BIT 0x00000002 -#define GL_STACK_OVERFLOW 0x0503 -#define GL_STACK_UNDERFLOW 0x0504 -#define GL_DEBUG_OUTPUT_SYNCHRONOUS 0x8242 -#define GL_DEBUG_NEXT_LOGGED_MESSAGE_LENGTH 0x8243 -#define GL_DEBUG_CALLBACK_FUNCTION 0x8244 -#define GL_DEBUG_CALLBACK_USER_PARAM 0x8245 -#define GL_DEBUG_SOURCE_API 0x8246 -#define GL_DEBUG_SOURCE_WINDOW_SYSTEM 0x8247 -#define GL_DEBUG_SOURCE_SHADER_COMPILER 0x8248 -#define GL_DEBUG_SOURCE_THIRD_PARTY 0x8249 -#define GL_DEBUG_SOURCE_APPLICATION 0x824A -#define GL_DEBUG_SOURCE_OTHER 0x824B -#define GL_DEBUG_TYPE_ERROR 0x824C -#define GL_DEBUG_TYPE_DEPRECATED_BEHAVIOR 0x824D -#define GL_DEBUG_TYPE_UNDEFINED_BEHAVIOR 0x824E -#define GL_DEBUG_TYPE_PORTABILITY 0x824F -#define GL_DEBUG_TYPE_PERFORMANCE 0x8250 -#define GL_DEBUG_TYPE_OTHER 0x8251 -#define GL_DEBUG_TYPE_MARKER 0x8268 -#define GL_DEBUG_TYPE_PUSH_GROUP 0x8269 -#define GL_DEBUG_TYPE_POP_GROUP 0x826A -#define GL_DEBUG_SEVERITY_NOTIFICATION 0x826B -#define GL_MAX_DEBUG_GROUP_STACK_DEPTH 0x826C -#define GL_DEBUG_GROUP_STACK_DEPTH 0x826D -#define GL_BUFFER 0x82E0 -#define GL_SHADER 0x82E1 -#define GL_PROGRAM 0x82E2 -#define GL_QUERY 0x82E3 -#define GL_PROGRAM_PIPELINE 0x82E4 -#define GL_SAMPLER 0x82E6 -#define GL_DISPLAY_LIST 0x82E7 -#define GL_MAX_LABEL_LENGTH 0x82E8 -#define GL_MAX_DEBUG_MESSAGE_LENGTH 0x9143 -#define GL_MAX_DEBUG_LOGGED_MESSAGES 0x9144 -#define GL_DEBUG_LOGGED_MESSAGES 0x9145 -#define GL_DEBUG_SEVERITY_HIGH 0x9146 -#define GL_DEBUG_SEVERITY_MEDIUM 0x9147 -#define GL_DEBUG_SEVERITY_LOW 0x9148 -#define GL_DEBUG_OUTPUT 0x92E0 - -typedef void (GLAPIENTRY *GLDEBUGPROC)(GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length, const GLchar* message, const void* userParam); - -typedef void (GLAPIENTRY * PFNGLDEBUGMESSAGECALLBACKPROC) (GLDEBUGPROC callback, const void *userParam); -typedef void (GLAPIENTRY * PFNGLDEBUGMESSAGECONTROLPROC) (GLenum source, GLenum type, GLenum severity, GLsizei count, const GLuint* ids, GLboolean enabled); -typedef void (GLAPIENTRY * PFNGLDEBUGMESSAGEINSERTPROC) (GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length, const GLchar* buf); -typedef GLuint (GLAPIENTRY * PFNGLGETDEBUGMESSAGELOGPROC) (GLuint count, GLsizei bufSize, GLenum* sources, GLenum* types, GLuint* ids, GLenum* severities, GLsizei* lengths, GLchar* messageLog); -typedef void (GLAPIENTRY * PFNGLGETOBJECTLABELPROC) (GLenum identifier, GLuint name, GLsizei bufSize, GLsizei* length, GLchar *label); -typedef void (GLAPIENTRY * PFNGLGETOBJECTPTRLABELPROC) (const void *ptr, GLsizei bufSize, GLsizei* length, GLchar *label); -typedef void (GLAPIENTRY * PFNGLOBJECTLABELPROC) (GLenum identifier, GLuint name, GLsizei length, const GLchar* label); -typedef void (GLAPIENTRY * PFNGLOBJECTPTRLABELPROC) (const void *ptr, GLsizei length, const GLchar* label); -typedef void (GLAPIENTRY * PFNGLPOPDEBUGGROUPPROC) (void); -typedef void (GLAPIENTRY * PFNGLPUSHDEBUGGROUPPROC) (GLenum source, GLuint id, GLsizei length, const GLchar * message); - -#define glDebugMessageCallback GLEW_GET_FUN(__glewDebugMessageCallback) -#define glDebugMessageControl GLEW_GET_FUN(__glewDebugMessageControl) -#define glDebugMessageInsert GLEW_GET_FUN(__glewDebugMessageInsert) -#define glGetDebugMessageLog GLEW_GET_FUN(__glewGetDebugMessageLog) -#define glGetObjectLabel GLEW_GET_FUN(__glewGetObjectLabel) -#define glGetObjectPtrLabel GLEW_GET_FUN(__glewGetObjectPtrLabel) -#define glObjectLabel GLEW_GET_FUN(__glewObjectLabel) -#define glObjectPtrLabel GLEW_GET_FUN(__glewObjectPtrLabel) -#define glPopDebugGroup GLEW_GET_FUN(__glewPopDebugGroup) -#define glPushDebugGroup GLEW_GET_FUN(__glewPushDebugGroup) - -#define GLEW_KHR_debug GLEW_GET_VAR(__GLEW_KHR_debug) - -#endif /* GL_KHR_debug */ - -/* ---------------------------- GL_KHR_no_error ---------------------------- */ - -#ifndef GL_KHR_no_error -#define GL_KHR_no_error 1 - -#define GL_CONTEXT_FLAG_NO_ERROR_BIT_KHR 0x00000008 - -#define GLEW_KHR_no_error GLEW_GET_VAR(__GLEW_KHR_no_error) - -#endif /* GL_KHR_no_error */ - -/* ------------------ GL_KHR_robust_buffer_access_behavior ----------------- */ - -#ifndef GL_KHR_robust_buffer_access_behavior -#define GL_KHR_robust_buffer_access_behavior 1 - -#define GLEW_KHR_robust_buffer_access_behavior GLEW_GET_VAR(__GLEW_KHR_robust_buffer_access_behavior) - -#endif /* GL_KHR_robust_buffer_access_behavior */ - -/* --------------------------- GL_KHR_robustness --------------------------- */ - -#ifndef GL_KHR_robustness -#define GL_KHR_robustness 1 - -#define GL_CONTEXT_LOST 0x0507 -#define GL_LOSE_CONTEXT_ON_RESET 0x8252 -#define GL_GUILTY_CONTEXT_RESET 0x8253 -#define GL_INNOCENT_CONTEXT_RESET 0x8254 -#define GL_UNKNOWN_CONTEXT_RESET 0x8255 -#define GL_RESET_NOTIFICATION_STRATEGY 0x8256 -#define GL_NO_RESET_NOTIFICATION 0x8261 -#define GL_CONTEXT_ROBUST_ACCESS 0x90F3 - -typedef void (GLAPIENTRY * PFNGLGETNUNIFORMFVPROC) (GLuint program, GLint location, GLsizei bufSize, GLfloat* params); -typedef void (GLAPIENTRY * PFNGLGETNUNIFORMIVPROC) (GLuint program, GLint location, GLsizei bufSize, GLint* params); -typedef void (GLAPIENTRY * PFNGLGETNUNIFORMUIVPROC) (GLuint program, GLint location, GLsizei bufSize, GLuint* params); -typedef void (GLAPIENTRY * PFNGLREADNPIXELSPROC) (GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLsizei bufSize, void *data); - -#define glGetnUniformfv GLEW_GET_FUN(__glewGetnUniformfv) -#define glGetnUniformiv GLEW_GET_FUN(__glewGetnUniformiv) -#define glGetnUniformuiv GLEW_GET_FUN(__glewGetnUniformuiv) -#define glReadnPixels GLEW_GET_FUN(__glewReadnPixels) - -#define GLEW_KHR_robustness GLEW_GET_VAR(__GLEW_KHR_robustness) - -#endif /* GL_KHR_robustness */ - -/* ------------------ GL_KHR_texture_compression_astc_hdr ------------------ */ - -#ifndef GL_KHR_texture_compression_astc_hdr -#define GL_KHR_texture_compression_astc_hdr 1 - -#define GL_COMPRESSED_RGBA_ASTC_4x4_KHR 0x93B0 -#define GL_COMPRESSED_RGBA_ASTC_5x4_KHR 0x93B1 -#define GL_COMPRESSED_RGBA_ASTC_5x5_KHR 0x93B2 -#define GL_COMPRESSED_RGBA_ASTC_6x5_KHR 0x93B3 -#define GL_COMPRESSED_RGBA_ASTC_6x6_KHR 0x93B4 -#define GL_COMPRESSED_RGBA_ASTC_8x5_KHR 0x93B5 -#define GL_COMPRESSED_RGBA_ASTC_8x6_KHR 0x93B6 -#define GL_COMPRESSED_RGBA_ASTC_8x8_KHR 0x93B7 -#define GL_COMPRESSED_RGBA_ASTC_10x5_KHR 0x93B8 -#define GL_COMPRESSED_RGBA_ASTC_10x6_KHR 0x93B9 -#define GL_COMPRESSED_RGBA_ASTC_10x8_KHR 0x93BA -#define GL_COMPRESSED_RGBA_ASTC_10x10_KHR 0x93BB -#define GL_COMPRESSED_RGBA_ASTC_12x10_KHR 0x93BC -#define GL_COMPRESSED_RGBA_ASTC_12x12_KHR 0x93BD -#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR 0x93D0 -#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR 0x93D1 -#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR 0x93D2 -#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR 0x93D3 -#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR 0x93D4 -#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR 0x93D5 -#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR 0x93D6 -#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR 0x93D7 -#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR 0x93D8 -#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR 0x93D9 -#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR 0x93DA -#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR 0x93DB -#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR 0x93DC -#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR 0x93DD - -#define GLEW_KHR_texture_compression_astc_hdr GLEW_GET_VAR(__GLEW_KHR_texture_compression_astc_hdr) - -#endif /* GL_KHR_texture_compression_astc_hdr */ - -/* ------------------ GL_KHR_texture_compression_astc_ldr ------------------ */ - -#ifndef GL_KHR_texture_compression_astc_ldr -#define GL_KHR_texture_compression_astc_ldr 1 - -#define GL_COMPRESSED_RGBA_ASTC_4x4_KHR 0x93B0 -#define GL_COMPRESSED_RGBA_ASTC_5x4_KHR 0x93B1 -#define GL_COMPRESSED_RGBA_ASTC_5x5_KHR 0x93B2 -#define GL_COMPRESSED_RGBA_ASTC_6x5_KHR 0x93B3 -#define GL_COMPRESSED_RGBA_ASTC_6x6_KHR 0x93B4 -#define GL_COMPRESSED_RGBA_ASTC_8x5_KHR 0x93B5 -#define GL_COMPRESSED_RGBA_ASTC_8x6_KHR 0x93B6 -#define GL_COMPRESSED_RGBA_ASTC_8x8_KHR 0x93B7 -#define GL_COMPRESSED_RGBA_ASTC_10x5_KHR 0x93B8 -#define GL_COMPRESSED_RGBA_ASTC_10x6_KHR 0x93B9 -#define GL_COMPRESSED_RGBA_ASTC_10x8_KHR 0x93BA -#define GL_COMPRESSED_RGBA_ASTC_10x10_KHR 0x93BB -#define GL_COMPRESSED_RGBA_ASTC_12x10_KHR 0x93BC -#define GL_COMPRESSED_RGBA_ASTC_12x12_KHR 0x93BD -#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR 0x93D0 -#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR 0x93D1 -#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR 0x93D2 -#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR 0x93D3 -#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR 0x93D4 -#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR 0x93D5 -#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR 0x93D6 -#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR 0x93D7 -#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR 0x93D8 -#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR 0x93D9 -#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR 0x93DA -#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR 0x93DB -#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR 0x93DC -#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR 0x93DD - -#define GLEW_KHR_texture_compression_astc_ldr GLEW_GET_VAR(__GLEW_KHR_texture_compression_astc_ldr) - -#endif /* GL_KHR_texture_compression_astc_ldr */ - -/* --------------- GL_KHR_texture_compression_astc_sliced_3d --------------- */ - -#ifndef GL_KHR_texture_compression_astc_sliced_3d -#define GL_KHR_texture_compression_astc_sliced_3d 1 - -#define GLEW_KHR_texture_compression_astc_sliced_3d GLEW_GET_VAR(__GLEW_KHR_texture_compression_astc_sliced_3d) - -#endif /* GL_KHR_texture_compression_astc_sliced_3d */ - -/* -------------------------- GL_KTX_buffer_region ------------------------- */ - -#ifndef GL_KTX_buffer_region -#define GL_KTX_buffer_region 1 - -#define GL_KTX_FRONT_REGION 0x0 -#define GL_KTX_BACK_REGION 0x1 -#define GL_KTX_Z_REGION 0x2 -#define GL_KTX_STENCIL_REGION 0x3 - -typedef GLuint (GLAPIENTRY * PFNGLBUFFERREGIONENABLEDPROC) (void); -typedef void (GLAPIENTRY * PFNGLDELETEBUFFERREGIONPROC) (GLenum region); -typedef void (GLAPIENTRY * PFNGLDRAWBUFFERREGIONPROC) (GLuint region, GLint x, GLint y, GLsizei width, GLsizei height, GLint xDest, GLint yDest); -typedef GLuint (GLAPIENTRY * PFNGLNEWBUFFERREGIONPROC) (GLenum region); -typedef void (GLAPIENTRY * PFNGLREADBUFFERREGIONPROC) (GLuint region, GLint x, GLint y, GLsizei width, GLsizei height); - -#define glBufferRegionEnabled GLEW_GET_FUN(__glewBufferRegionEnabled) -#define glDeleteBufferRegion GLEW_GET_FUN(__glewDeleteBufferRegion) -#define glDrawBufferRegion GLEW_GET_FUN(__glewDrawBufferRegion) -#define glNewBufferRegion GLEW_GET_FUN(__glewNewBufferRegion) -#define glReadBufferRegion GLEW_GET_FUN(__glewReadBufferRegion) - -#define GLEW_KTX_buffer_region GLEW_GET_VAR(__GLEW_KTX_buffer_region) - -#endif /* GL_KTX_buffer_region */ - -/* ------------------------- GL_MESAX_texture_stack ------------------------ */ - -#ifndef GL_MESAX_texture_stack -#define GL_MESAX_texture_stack 1 - -#define GL_TEXTURE_1D_STACK_MESAX 0x8759 -#define GL_TEXTURE_2D_STACK_MESAX 0x875A -#define GL_PROXY_TEXTURE_1D_STACK_MESAX 0x875B -#define GL_PROXY_TEXTURE_2D_STACK_MESAX 0x875C -#define GL_TEXTURE_1D_STACK_BINDING_MESAX 0x875D -#define GL_TEXTURE_2D_STACK_BINDING_MESAX 0x875E - -#define GLEW_MESAX_texture_stack GLEW_GET_VAR(__GLEW_MESAX_texture_stack) - -#endif /* GL_MESAX_texture_stack */ - -/* -------------------------- GL_MESA_pack_invert -------------------------- */ - -#ifndef GL_MESA_pack_invert -#define GL_MESA_pack_invert 1 - -#define GL_PACK_INVERT_MESA 0x8758 - -#define GLEW_MESA_pack_invert GLEW_GET_VAR(__GLEW_MESA_pack_invert) - -#endif /* GL_MESA_pack_invert */ - -/* ------------------------- GL_MESA_resize_buffers ------------------------ */ - -#ifndef GL_MESA_resize_buffers -#define GL_MESA_resize_buffers 1 - -typedef void (GLAPIENTRY * PFNGLRESIZEBUFFERSMESAPROC) (void); - -#define glResizeBuffersMESA GLEW_GET_FUN(__glewResizeBuffersMESA) - -#define GLEW_MESA_resize_buffers GLEW_GET_VAR(__GLEW_MESA_resize_buffers) - -#endif /* GL_MESA_resize_buffers */ - -/* -------------------- GL_MESA_shader_integer_functions ------------------- */ - -#ifndef GL_MESA_shader_integer_functions -#define GL_MESA_shader_integer_functions 1 - -#define GLEW_MESA_shader_integer_functions GLEW_GET_VAR(__GLEW_MESA_shader_integer_functions) - -#endif /* GL_MESA_shader_integer_functions */ - -/* --------------------------- GL_MESA_window_pos -------------------------- */ - -#ifndef GL_MESA_window_pos -#define GL_MESA_window_pos 1 - -typedef void (GLAPIENTRY * PFNGLWINDOWPOS2DMESAPROC) (GLdouble x, GLdouble y); -typedef void (GLAPIENTRY * PFNGLWINDOWPOS2DVMESAPROC) (const GLdouble* p); -typedef void (GLAPIENTRY * PFNGLWINDOWPOS2FMESAPROC) (GLfloat x, GLfloat y); -typedef void (GLAPIENTRY * PFNGLWINDOWPOS2FVMESAPROC) (const GLfloat* p); -typedef void (GLAPIENTRY * PFNGLWINDOWPOS2IMESAPROC) (GLint x, GLint y); -typedef void (GLAPIENTRY * PFNGLWINDOWPOS2IVMESAPROC) (const GLint* p); -typedef void (GLAPIENTRY * PFNGLWINDOWPOS2SMESAPROC) (GLshort x, GLshort y); -typedef void (GLAPIENTRY * PFNGLWINDOWPOS2SVMESAPROC) (const GLshort* p); -typedef void (GLAPIENTRY * PFNGLWINDOWPOS3DMESAPROC) (GLdouble x, GLdouble y, GLdouble z); -typedef void (GLAPIENTRY * PFNGLWINDOWPOS3DVMESAPROC) (const GLdouble* p); -typedef void (GLAPIENTRY * PFNGLWINDOWPOS3FMESAPROC) (GLfloat x, GLfloat y, GLfloat z); -typedef void (GLAPIENTRY * PFNGLWINDOWPOS3FVMESAPROC) (const GLfloat* p); -typedef void (GLAPIENTRY * PFNGLWINDOWPOS3IMESAPROC) (GLint x, GLint y, GLint z); -typedef void (GLAPIENTRY * PFNGLWINDOWPOS3IVMESAPROC) (const GLint* p); -typedef void (GLAPIENTRY * PFNGLWINDOWPOS3SMESAPROC) (GLshort x, GLshort y, GLshort z); -typedef void (GLAPIENTRY * PFNGLWINDOWPOS3SVMESAPROC) (const GLshort* p); -typedef void (GLAPIENTRY * PFNGLWINDOWPOS4DMESAPROC) (GLdouble x, GLdouble y, GLdouble z, GLdouble); -typedef void (GLAPIENTRY * PFNGLWINDOWPOS4DVMESAPROC) (const GLdouble* p); -typedef void (GLAPIENTRY * PFNGLWINDOWPOS4FMESAPROC) (GLfloat x, GLfloat y, GLfloat z, GLfloat w); -typedef void (GLAPIENTRY * PFNGLWINDOWPOS4FVMESAPROC) (const GLfloat* p); -typedef void (GLAPIENTRY * PFNGLWINDOWPOS4IMESAPROC) (GLint x, GLint y, GLint z, GLint w); -typedef void (GLAPIENTRY * PFNGLWINDOWPOS4IVMESAPROC) (const GLint* p); -typedef void (GLAPIENTRY * PFNGLWINDOWPOS4SMESAPROC) (GLshort x, GLshort y, GLshort z, GLshort w); -typedef void (GLAPIENTRY * PFNGLWINDOWPOS4SVMESAPROC) (const GLshort* p); - -#define glWindowPos2dMESA GLEW_GET_FUN(__glewWindowPos2dMESA) -#define glWindowPos2dvMESA GLEW_GET_FUN(__glewWindowPos2dvMESA) -#define glWindowPos2fMESA GLEW_GET_FUN(__glewWindowPos2fMESA) -#define glWindowPos2fvMESA GLEW_GET_FUN(__glewWindowPos2fvMESA) -#define glWindowPos2iMESA GLEW_GET_FUN(__glewWindowPos2iMESA) -#define glWindowPos2ivMESA GLEW_GET_FUN(__glewWindowPos2ivMESA) -#define glWindowPos2sMESA GLEW_GET_FUN(__glewWindowPos2sMESA) -#define glWindowPos2svMESA GLEW_GET_FUN(__glewWindowPos2svMESA) -#define glWindowPos3dMESA GLEW_GET_FUN(__glewWindowPos3dMESA) -#define glWindowPos3dvMESA GLEW_GET_FUN(__glewWindowPos3dvMESA) -#define glWindowPos3fMESA GLEW_GET_FUN(__glewWindowPos3fMESA) -#define glWindowPos3fvMESA GLEW_GET_FUN(__glewWindowPos3fvMESA) -#define glWindowPos3iMESA GLEW_GET_FUN(__glewWindowPos3iMESA) -#define glWindowPos3ivMESA GLEW_GET_FUN(__glewWindowPos3ivMESA) -#define glWindowPos3sMESA GLEW_GET_FUN(__glewWindowPos3sMESA) -#define glWindowPos3svMESA GLEW_GET_FUN(__glewWindowPos3svMESA) -#define glWindowPos4dMESA GLEW_GET_FUN(__glewWindowPos4dMESA) -#define glWindowPos4dvMESA GLEW_GET_FUN(__glewWindowPos4dvMESA) -#define glWindowPos4fMESA GLEW_GET_FUN(__glewWindowPos4fMESA) -#define glWindowPos4fvMESA GLEW_GET_FUN(__glewWindowPos4fvMESA) -#define glWindowPos4iMESA GLEW_GET_FUN(__glewWindowPos4iMESA) -#define glWindowPos4ivMESA GLEW_GET_FUN(__glewWindowPos4ivMESA) -#define glWindowPos4sMESA GLEW_GET_FUN(__glewWindowPos4sMESA) -#define glWindowPos4svMESA GLEW_GET_FUN(__glewWindowPos4svMESA) - -#define GLEW_MESA_window_pos GLEW_GET_VAR(__GLEW_MESA_window_pos) - -#endif /* GL_MESA_window_pos */ - -/* ------------------------- GL_MESA_ycbcr_texture ------------------------- */ - -#ifndef GL_MESA_ycbcr_texture -#define GL_MESA_ycbcr_texture 1 - -#define GL_UNSIGNED_SHORT_8_8_MESA 0x85BA -#define GL_UNSIGNED_SHORT_8_8_REV_MESA 0x85BB -#define GL_YCBCR_MESA 0x8757 - -#define GLEW_MESA_ycbcr_texture GLEW_GET_VAR(__GLEW_MESA_ycbcr_texture) - -#endif /* GL_MESA_ycbcr_texture */ - -/* ----------- GL_NVX_blend_equation_advanced_multi_draw_buffers ----------- */ - -#ifndef GL_NVX_blend_equation_advanced_multi_draw_buffers -#define GL_NVX_blend_equation_advanced_multi_draw_buffers 1 - -#define GLEW_NVX_blend_equation_advanced_multi_draw_buffers GLEW_GET_VAR(__GLEW_NVX_blend_equation_advanced_multi_draw_buffers) - -#endif /* GL_NVX_blend_equation_advanced_multi_draw_buffers */ - -/* ----------------------- GL_NVX_conditional_render ----------------------- */ - -#ifndef GL_NVX_conditional_render -#define GL_NVX_conditional_render 1 - -typedef void (GLAPIENTRY * PFNGLBEGINCONDITIONALRENDERNVXPROC) (GLuint id); -typedef void (GLAPIENTRY * PFNGLENDCONDITIONALRENDERNVXPROC) (void); - -#define glBeginConditionalRenderNVX GLEW_GET_FUN(__glewBeginConditionalRenderNVX) -#define glEndConditionalRenderNVX GLEW_GET_FUN(__glewEndConditionalRenderNVX) - -#define GLEW_NVX_conditional_render GLEW_GET_VAR(__GLEW_NVX_conditional_render) - -#endif /* GL_NVX_conditional_render */ - -/* ------------------------- GL_NVX_gpu_memory_info ------------------------ */ - -#ifndef GL_NVX_gpu_memory_info -#define GL_NVX_gpu_memory_info 1 - -#define GL_GPU_MEMORY_INFO_DEDICATED_VIDMEM_NVX 0x9047 -#define GL_GPU_MEMORY_INFO_TOTAL_AVAILABLE_MEMORY_NVX 0x9048 -#define GL_GPU_MEMORY_INFO_CURRENT_AVAILABLE_VIDMEM_NVX 0x9049 -#define GL_GPU_MEMORY_INFO_EVICTION_COUNT_NVX 0x904A -#define GL_GPU_MEMORY_INFO_EVICTED_MEMORY_NVX 0x904B - -#define GLEW_NVX_gpu_memory_info GLEW_GET_VAR(__GLEW_NVX_gpu_memory_info) - -#endif /* GL_NVX_gpu_memory_info */ - -/* ---------------------- GL_NVX_linked_gpu_multicast ---------------------- */ - -#ifndef GL_NVX_linked_gpu_multicast -#define GL_NVX_linked_gpu_multicast 1 - -#define GL_LGPU_SEPARATE_STORAGE_BIT_NVX 0x0800 -#define GL_MAX_LGPU_GPUS_NVX 0x92BA - -typedef void (GLAPIENTRY * PFNGLLGPUCOPYIMAGESUBDATANVXPROC) (GLuint sourceGpu, GLbitfield destinationGpuMask, GLuint srcName, GLenum srcTarget, GLint srcLevel, GLint srcX, GLint srxY, GLint srcZ, GLuint dstName, GLenum dstTarget, GLint dstLevel, GLint dstX, GLint dstY, GLint dstZ, GLsizei width, GLsizei height, GLsizei depth); -typedef void (GLAPIENTRY * PFNGLLGPUINTERLOCKNVXPROC) (void); -typedef void (GLAPIENTRY * PFNGLLGPUNAMEDBUFFERSUBDATANVXPROC) (GLbitfield gpuMask, GLuint buffer, GLintptr offset, GLsizeiptr size, const void *data); - -#define glLGPUCopyImageSubDataNVX GLEW_GET_FUN(__glewLGPUCopyImageSubDataNVX) -#define glLGPUInterlockNVX GLEW_GET_FUN(__glewLGPUInterlockNVX) -#define glLGPUNamedBufferSubDataNVX GLEW_GET_FUN(__glewLGPUNamedBufferSubDataNVX) - -#define GLEW_NVX_linked_gpu_multicast GLEW_GET_VAR(__GLEW_NVX_linked_gpu_multicast) - -#endif /* GL_NVX_linked_gpu_multicast */ - -/* ------------------- GL_NV_bindless_multi_draw_indirect ------------------ */ - -#ifndef GL_NV_bindless_multi_draw_indirect -#define GL_NV_bindless_multi_draw_indirect 1 - -typedef void (GLAPIENTRY * PFNGLMULTIDRAWARRAYSINDIRECTBINDLESSNVPROC) (GLenum mode, const void *indirect, GLsizei drawCount, GLsizei stride, GLint vertexBufferCount); -typedef void (GLAPIENTRY * PFNGLMULTIDRAWELEMENTSINDIRECTBINDLESSNVPROC) (GLenum mode, GLenum type, const void *indirect, GLsizei drawCount, GLsizei stride, GLint vertexBufferCount); - -#define glMultiDrawArraysIndirectBindlessNV GLEW_GET_FUN(__glewMultiDrawArraysIndirectBindlessNV) -#define glMultiDrawElementsIndirectBindlessNV GLEW_GET_FUN(__glewMultiDrawElementsIndirectBindlessNV) - -#define GLEW_NV_bindless_multi_draw_indirect GLEW_GET_VAR(__GLEW_NV_bindless_multi_draw_indirect) - -#endif /* GL_NV_bindless_multi_draw_indirect */ - -/* ---------------- GL_NV_bindless_multi_draw_indirect_count --------------- */ - -#ifndef GL_NV_bindless_multi_draw_indirect_count -#define GL_NV_bindless_multi_draw_indirect_count 1 - -typedef void (GLAPIENTRY * PFNGLMULTIDRAWARRAYSINDIRECTBINDLESSCOUNTNVPROC) (GLenum mode, const void *indirect, GLintptr drawCount, GLsizei maxDrawCount, GLsizei stride, GLint vertexBufferCount); -typedef void (GLAPIENTRY * PFNGLMULTIDRAWELEMENTSINDIRECTBINDLESSCOUNTNVPROC) (GLenum mode, GLenum type, const void *indirect, GLintptr drawCount, GLsizei maxDrawCount, GLsizei stride, GLint vertexBufferCount); - -#define glMultiDrawArraysIndirectBindlessCountNV GLEW_GET_FUN(__glewMultiDrawArraysIndirectBindlessCountNV) -#define glMultiDrawElementsIndirectBindlessCountNV GLEW_GET_FUN(__glewMultiDrawElementsIndirectBindlessCountNV) - -#define GLEW_NV_bindless_multi_draw_indirect_count GLEW_GET_VAR(__GLEW_NV_bindless_multi_draw_indirect_count) - -#endif /* GL_NV_bindless_multi_draw_indirect_count */ - -/* ------------------------- GL_NV_bindless_texture ------------------------ */ - -#ifndef GL_NV_bindless_texture -#define GL_NV_bindless_texture 1 - -typedef GLuint64 (GLAPIENTRY * PFNGLGETIMAGEHANDLENVPROC) (GLuint texture, GLint level, GLboolean layered, GLint layer, GLenum format); -typedef GLuint64 (GLAPIENTRY * PFNGLGETTEXTUREHANDLENVPROC) (GLuint texture); -typedef GLuint64 (GLAPIENTRY * PFNGLGETTEXTURESAMPLERHANDLENVPROC) (GLuint texture, GLuint sampler); -typedef GLboolean (GLAPIENTRY * PFNGLISIMAGEHANDLERESIDENTNVPROC) (GLuint64 handle); -typedef GLboolean (GLAPIENTRY * PFNGLISTEXTUREHANDLERESIDENTNVPROC) (GLuint64 handle); -typedef void (GLAPIENTRY * PFNGLMAKEIMAGEHANDLENONRESIDENTNVPROC) (GLuint64 handle); -typedef void (GLAPIENTRY * PFNGLMAKEIMAGEHANDLERESIDENTNVPROC) (GLuint64 handle, GLenum access); -typedef void (GLAPIENTRY * PFNGLMAKETEXTUREHANDLENONRESIDENTNVPROC) (GLuint64 handle); -typedef void (GLAPIENTRY * PFNGLMAKETEXTUREHANDLERESIDENTNVPROC) (GLuint64 handle); -typedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORMHANDLEUI64NVPROC) (GLuint program, GLint location, GLuint64 value); -typedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORMHANDLEUI64VNVPROC) (GLuint program, GLint location, GLsizei count, const GLuint64* values); -typedef void (GLAPIENTRY * PFNGLUNIFORMHANDLEUI64NVPROC) (GLint location, GLuint64 value); -typedef void (GLAPIENTRY * PFNGLUNIFORMHANDLEUI64VNVPROC) (GLint location, GLsizei count, const GLuint64* value); - -#define glGetImageHandleNV GLEW_GET_FUN(__glewGetImageHandleNV) -#define glGetTextureHandleNV GLEW_GET_FUN(__glewGetTextureHandleNV) -#define glGetTextureSamplerHandleNV GLEW_GET_FUN(__glewGetTextureSamplerHandleNV) -#define glIsImageHandleResidentNV GLEW_GET_FUN(__glewIsImageHandleResidentNV) -#define glIsTextureHandleResidentNV GLEW_GET_FUN(__glewIsTextureHandleResidentNV) -#define glMakeImageHandleNonResidentNV GLEW_GET_FUN(__glewMakeImageHandleNonResidentNV) -#define glMakeImageHandleResidentNV GLEW_GET_FUN(__glewMakeImageHandleResidentNV) -#define glMakeTextureHandleNonResidentNV GLEW_GET_FUN(__glewMakeTextureHandleNonResidentNV) -#define glMakeTextureHandleResidentNV GLEW_GET_FUN(__glewMakeTextureHandleResidentNV) -#define glProgramUniformHandleui64NV GLEW_GET_FUN(__glewProgramUniformHandleui64NV) -#define glProgramUniformHandleui64vNV GLEW_GET_FUN(__glewProgramUniformHandleui64vNV) -#define glUniformHandleui64NV GLEW_GET_FUN(__glewUniformHandleui64NV) -#define glUniformHandleui64vNV GLEW_GET_FUN(__glewUniformHandleui64vNV) - -#define GLEW_NV_bindless_texture GLEW_GET_VAR(__GLEW_NV_bindless_texture) - -#endif /* GL_NV_bindless_texture */ - -/* --------------------- GL_NV_blend_equation_advanced --------------------- */ - -#ifndef GL_NV_blend_equation_advanced -#define GL_NV_blend_equation_advanced 1 - -#define GL_XOR_NV 0x1506 -#define GL_RED_NV 0x1903 -#define GL_GREEN_NV 0x1904 -#define GL_BLUE_NV 0x1905 -#define GL_BLEND_PREMULTIPLIED_SRC_NV 0x9280 -#define GL_BLEND_OVERLAP_NV 0x9281 -#define GL_UNCORRELATED_NV 0x9282 -#define GL_DISJOINT_NV 0x9283 -#define GL_CONJOINT_NV 0x9284 -#define GL_BLEND_ADVANCED_COHERENT_NV 0x9285 -#define GL_SRC_NV 0x9286 -#define GL_DST_NV 0x9287 -#define GL_SRC_OVER_NV 0x9288 -#define GL_DST_OVER_NV 0x9289 -#define GL_SRC_IN_NV 0x928A -#define GL_DST_IN_NV 0x928B -#define GL_SRC_OUT_NV 0x928C -#define GL_DST_OUT_NV 0x928D -#define GL_SRC_ATOP_NV 0x928E -#define GL_DST_ATOP_NV 0x928F -#define GL_PLUS_NV 0x9291 -#define GL_PLUS_DARKER_NV 0x9292 -#define GL_MULTIPLY_NV 0x9294 -#define GL_SCREEN_NV 0x9295 -#define GL_OVERLAY_NV 0x9296 -#define GL_DARKEN_NV 0x9297 -#define GL_LIGHTEN_NV 0x9298 -#define GL_COLORDODGE_NV 0x9299 -#define GL_COLORBURN_NV 0x929A -#define GL_HARDLIGHT_NV 0x929B -#define GL_SOFTLIGHT_NV 0x929C -#define GL_DIFFERENCE_NV 0x929E -#define GL_MINUS_NV 0x929F -#define GL_EXCLUSION_NV 0x92A0 -#define GL_CONTRAST_NV 0x92A1 -#define GL_INVERT_RGB_NV 0x92A3 -#define GL_LINEARDODGE_NV 0x92A4 -#define GL_LINEARBURN_NV 0x92A5 -#define GL_VIVIDLIGHT_NV 0x92A6 -#define GL_LINEARLIGHT_NV 0x92A7 -#define GL_PINLIGHT_NV 0x92A8 -#define GL_HARDMIX_NV 0x92A9 -#define GL_HSL_HUE_NV 0x92AD -#define GL_HSL_SATURATION_NV 0x92AE -#define GL_HSL_COLOR_NV 0x92AF -#define GL_HSL_LUMINOSITY_NV 0x92B0 -#define GL_PLUS_CLAMPED_NV 0x92B1 -#define GL_PLUS_CLAMPED_ALPHA_NV 0x92B2 -#define GL_MINUS_CLAMPED_NV 0x92B3 -#define GL_INVERT_OVG_NV 0x92B4 - -typedef void (GLAPIENTRY * PFNGLBLENDBARRIERNVPROC) (void); -typedef void (GLAPIENTRY * PFNGLBLENDPARAMETERINVPROC) (GLenum pname, GLint value); - -#define glBlendBarrierNV GLEW_GET_FUN(__glewBlendBarrierNV) -#define glBlendParameteriNV GLEW_GET_FUN(__glewBlendParameteriNV) - -#define GLEW_NV_blend_equation_advanced GLEW_GET_VAR(__GLEW_NV_blend_equation_advanced) - -#endif /* GL_NV_blend_equation_advanced */ - -/* ----------------- GL_NV_blend_equation_advanced_coherent ---------------- */ - -#ifndef GL_NV_blend_equation_advanced_coherent -#define GL_NV_blend_equation_advanced_coherent 1 - -#define GLEW_NV_blend_equation_advanced_coherent GLEW_GET_VAR(__GLEW_NV_blend_equation_advanced_coherent) - -#endif /* GL_NV_blend_equation_advanced_coherent */ - -/* --------------------------- GL_NV_blend_square -------------------------- */ - -#ifndef GL_NV_blend_square -#define GL_NV_blend_square 1 - -#define GLEW_NV_blend_square GLEW_GET_VAR(__GLEW_NV_blend_square) - -#endif /* GL_NV_blend_square */ - -/* ----------------------- GL_NV_clip_space_w_scaling ---------------------- */ - -#ifndef GL_NV_clip_space_w_scaling -#define GL_NV_clip_space_w_scaling 1 - -#define GL_VIEWPORT_POSITION_W_SCALE_NV 0x937C -#define GL_VIEWPORT_POSITION_W_SCALE_X_COEFF_NV 0x937D -#define GL_VIEWPORT_POSITION_W_SCALE_Y_COEFF_NV 0x937E - -typedef void (GLAPIENTRY * PFNGLVIEWPORTPOSITIONWSCALENVPROC) (GLuint index, GLfloat xcoeff, GLfloat ycoeff); - -#define glViewportPositionWScaleNV GLEW_GET_FUN(__glewViewportPositionWScaleNV) - -#define GLEW_NV_clip_space_w_scaling GLEW_GET_VAR(__GLEW_NV_clip_space_w_scaling) - -#endif /* GL_NV_clip_space_w_scaling */ - -/* --------------------------- GL_NV_command_list -------------------------- */ - -#ifndef GL_NV_command_list -#define GL_NV_command_list 1 - -#define GL_TERMINATE_SEQUENCE_COMMAND_NV 0x0000 -#define GL_NOP_COMMAND_NV 0x0001 -#define GL_DRAW_ELEMENTS_COMMAND_NV 0x0002 -#define GL_DRAW_ARRAYS_COMMAND_NV 0x0003 -#define GL_DRAW_ELEMENTS_STRIP_COMMAND_NV 0x0004 -#define GL_DRAW_ARRAYS_STRIP_COMMAND_NV 0x0005 -#define GL_DRAW_ELEMENTS_INSTANCED_COMMAND_NV 0x0006 -#define GL_DRAW_ARRAYS_INSTANCED_COMMAND_NV 0x0007 -#define GL_ELEMENT_ADDRESS_COMMAND_NV 0x0008 -#define GL_ATTRIBUTE_ADDRESS_COMMAND_NV 0x0009 -#define GL_UNIFORM_ADDRESS_COMMAND_NV 0x000a -#define GL_BLEND_COLOR_COMMAND_NV 0x000b -#define GL_STENCIL_REF_COMMAND_NV 0x000c -#define GL_LINE_WIDTH_COMMAND_NV 0x000d -#define GL_POLYGON_OFFSET_COMMAND_NV 0x000e -#define GL_ALPHA_REF_COMMAND_NV 0x000f -#define GL_VIEWPORT_COMMAND_NV 0x0010 -#define GL_SCISSOR_COMMAND_NV 0x0011 -#define GL_FRONT_FACE_COMMAND_NV 0x0012 - -typedef void (GLAPIENTRY * PFNGLCALLCOMMANDLISTNVPROC) (GLuint list); -typedef void (GLAPIENTRY * PFNGLCOMMANDLISTSEGMENTSNVPROC) (GLuint list, GLuint segments); -typedef void (GLAPIENTRY * PFNGLCOMPILECOMMANDLISTNVPROC) (GLuint list); -typedef void (GLAPIENTRY * PFNGLCREATECOMMANDLISTSNVPROC) (GLsizei n, GLuint* lists); -typedef void (GLAPIENTRY * PFNGLCREATESTATESNVPROC) (GLsizei n, GLuint* states); -typedef void (GLAPIENTRY * PFNGLDELETECOMMANDLISTSNVPROC) (GLsizei n, const GLuint* lists); -typedef void (GLAPIENTRY * PFNGLDELETESTATESNVPROC) (GLsizei n, const GLuint* states); -typedef void (GLAPIENTRY * PFNGLDRAWCOMMANDSADDRESSNVPROC) (GLenum primitiveMode, const GLuint64* indirects, const GLsizei* sizes, GLuint count); -typedef void (GLAPIENTRY * PFNGLDRAWCOMMANDSNVPROC) (GLenum primitiveMode, GLuint buffer, const GLintptr* indirects, const GLsizei* sizes, GLuint count); -typedef void (GLAPIENTRY * PFNGLDRAWCOMMANDSSTATESADDRESSNVPROC) (const GLuint64* indirects, const GLsizei* sizes, const GLuint* states, const GLuint* fbos, GLuint count); -typedef void (GLAPIENTRY * PFNGLDRAWCOMMANDSSTATESNVPROC) (GLuint buffer, const GLintptr* indirects, const GLsizei* sizes, const GLuint* states, const GLuint* fbos, GLuint count); -typedef GLuint (GLAPIENTRY * PFNGLGETCOMMANDHEADERNVPROC) (GLenum tokenID, GLuint size); -typedef GLushort (GLAPIENTRY * PFNGLGETSTAGEINDEXNVPROC) (GLenum shadertype); -typedef GLboolean (GLAPIENTRY * PFNGLISCOMMANDLISTNVPROC) (GLuint list); -typedef GLboolean (GLAPIENTRY * PFNGLISSTATENVPROC) (GLuint state); -typedef void (GLAPIENTRY * PFNGLLISTDRAWCOMMANDSSTATESCLIENTNVPROC) (GLuint list, GLuint segment, const void** indirects, const GLsizei* sizes, const GLuint* states, const GLuint* fbos, GLuint count); -typedef void (GLAPIENTRY * PFNGLSTATECAPTURENVPROC) (GLuint state, GLenum mode); - -#define glCallCommandListNV GLEW_GET_FUN(__glewCallCommandListNV) -#define glCommandListSegmentsNV GLEW_GET_FUN(__glewCommandListSegmentsNV) -#define glCompileCommandListNV GLEW_GET_FUN(__glewCompileCommandListNV) -#define glCreateCommandListsNV GLEW_GET_FUN(__glewCreateCommandListsNV) -#define glCreateStatesNV GLEW_GET_FUN(__glewCreateStatesNV) -#define glDeleteCommandListsNV GLEW_GET_FUN(__glewDeleteCommandListsNV) -#define glDeleteStatesNV GLEW_GET_FUN(__glewDeleteStatesNV) -#define glDrawCommandsAddressNV GLEW_GET_FUN(__glewDrawCommandsAddressNV) -#define glDrawCommandsNV GLEW_GET_FUN(__glewDrawCommandsNV) -#define glDrawCommandsStatesAddressNV GLEW_GET_FUN(__glewDrawCommandsStatesAddressNV) -#define glDrawCommandsStatesNV GLEW_GET_FUN(__glewDrawCommandsStatesNV) -#define glGetCommandHeaderNV GLEW_GET_FUN(__glewGetCommandHeaderNV) -#define glGetStageIndexNV GLEW_GET_FUN(__glewGetStageIndexNV) -#define glIsCommandListNV GLEW_GET_FUN(__glewIsCommandListNV) -#define glIsStateNV GLEW_GET_FUN(__glewIsStateNV) -#define glListDrawCommandsStatesClientNV GLEW_GET_FUN(__glewListDrawCommandsStatesClientNV) -#define glStateCaptureNV GLEW_GET_FUN(__glewStateCaptureNV) - -#define GLEW_NV_command_list GLEW_GET_VAR(__GLEW_NV_command_list) - -#endif /* GL_NV_command_list */ - -/* ------------------------- GL_NV_compute_program5 ------------------------ */ - -#ifndef GL_NV_compute_program5 -#define GL_NV_compute_program5 1 - -#define GL_COMPUTE_PROGRAM_NV 0x90FB -#define GL_COMPUTE_PROGRAM_PARAMETER_BUFFER_NV 0x90FC - -#define GLEW_NV_compute_program5 GLEW_GET_VAR(__GLEW_NV_compute_program5) - -#endif /* GL_NV_compute_program5 */ - -/* ------------------------ GL_NV_conditional_render ----------------------- */ - -#ifndef GL_NV_conditional_render -#define GL_NV_conditional_render 1 - -#define GL_QUERY_WAIT_NV 0x8E13 -#define GL_QUERY_NO_WAIT_NV 0x8E14 -#define GL_QUERY_BY_REGION_WAIT_NV 0x8E15 -#define GL_QUERY_BY_REGION_NO_WAIT_NV 0x8E16 - -typedef void (GLAPIENTRY * PFNGLBEGINCONDITIONALRENDERNVPROC) (GLuint id, GLenum mode); -typedef void (GLAPIENTRY * PFNGLENDCONDITIONALRENDERNVPROC) (void); - -#define glBeginConditionalRenderNV GLEW_GET_FUN(__glewBeginConditionalRenderNV) -#define glEndConditionalRenderNV GLEW_GET_FUN(__glewEndConditionalRenderNV) - -#define GLEW_NV_conditional_render GLEW_GET_VAR(__GLEW_NV_conditional_render) - -#endif /* GL_NV_conditional_render */ - -/* ----------------------- GL_NV_conservative_raster ----------------------- */ - -#ifndef GL_NV_conservative_raster -#define GL_NV_conservative_raster 1 - -#define GL_CONSERVATIVE_RASTERIZATION_NV 0x9346 -#define GL_SUBPIXEL_PRECISION_BIAS_X_BITS_NV 0x9347 -#define GL_SUBPIXEL_PRECISION_BIAS_Y_BITS_NV 0x9348 -#define GL_MAX_SUBPIXEL_PRECISION_BIAS_BITS_NV 0x9349 - -typedef void (GLAPIENTRY * PFNGLSUBPIXELPRECISIONBIASNVPROC) (GLuint xbits, GLuint ybits); - -#define glSubpixelPrecisionBiasNV GLEW_GET_FUN(__glewSubpixelPrecisionBiasNV) - -#define GLEW_NV_conservative_raster GLEW_GET_VAR(__GLEW_NV_conservative_raster) - -#endif /* GL_NV_conservative_raster */ - -/* -------------------- GL_NV_conservative_raster_dilate ------------------- */ - -#ifndef GL_NV_conservative_raster_dilate -#define GL_NV_conservative_raster_dilate 1 - -#define GL_CONSERVATIVE_RASTER_DILATE_NV 0x9379 -#define GL_CONSERVATIVE_RASTER_DILATE_RANGE_NV 0x937A -#define GL_CONSERVATIVE_RASTER_DILATE_GRANULARITY_NV 0x937B - -typedef void (GLAPIENTRY * PFNGLCONSERVATIVERASTERPARAMETERFNVPROC) (GLenum pname, GLfloat value); - -#define glConservativeRasterParameterfNV GLEW_GET_FUN(__glewConservativeRasterParameterfNV) - -#define GLEW_NV_conservative_raster_dilate GLEW_GET_VAR(__GLEW_NV_conservative_raster_dilate) - -#endif /* GL_NV_conservative_raster_dilate */ - -/* -------------- GL_NV_conservative_raster_pre_snap_triangles ------------- */ - -#ifndef GL_NV_conservative_raster_pre_snap_triangles -#define GL_NV_conservative_raster_pre_snap_triangles 1 - -#define GL_CONSERVATIVE_RASTER_MODE_NV 0x954D -#define GL_CONSERVATIVE_RASTER_MODE_POST_SNAP_NV 0x954E -#define GL_CONSERVATIVE_RASTER_MODE_PRE_SNAP_TRIANGLES_NV 0x954F - -typedef void (GLAPIENTRY * PFNGLCONSERVATIVERASTERPARAMETERINVPROC) (GLenum pname, GLint param); - -#define glConservativeRasterParameteriNV GLEW_GET_FUN(__glewConservativeRasterParameteriNV) - -#define GLEW_NV_conservative_raster_pre_snap_triangles GLEW_GET_VAR(__GLEW_NV_conservative_raster_pre_snap_triangles) - -#endif /* GL_NV_conservative_raster_pre_snap_triangles */ - -/* ----------------------- GL_NV_copy_depth_to_color ----------------------- */ - -#ifndef GL_NV_copy_depth_to_color -#define GL_NV_copy_depth_to_color 1 - -#define GL_DEPTH_STENCIL_TO_RGBA_NV 0x886E -#define GL_DEPTH_STENCIL_TO_BGRA_NV 0x886F - -#define GLEW_NV_copy_depth_to_color GLEW_GET_VAR(__GLEW_NV_copy_depth_to_color) - -#endif /* GL_NV_copy_depth_to_color */ - -/* ---------------------------- GL_NV_copy_image --------------------------- */ - -#ifndef GL_NV_copy_image -#define GL_NV_copy_image 1 - -typedef void (GLAPIENTRY * PFNGLCOPYIMAGESUBDATANVPROC) (GLuint srcName, GLenum srcTarget, GLint srcLevel, GLint srcX, GLint srcY, GLint srcZ, GLuint dstName, GLenum dstTarget, GLint dstLevel, GLint dstX, GLint dstY, GLint dstZ, GLsizei width, GLsizei height, GLsizei depth); - -#define glCopyImageSubDataNV GLEW_GET_FUN(__glewCopyImageSubDataNV) - -#define GLEW_NV_copy_image GLEW_GET_VAR(__GLEW_NV_copy_image) - -#endif /* GL_NV_copy_image */ - -/* -------------------------- GL_NV_deep_texture3D ------------------------- */ - -#ifndef GL_NV_deep_texture3D -#define GL_NV_deep_texture3D 1 - -#define GL_MAX_DEEP_3D_TEXTURE_WIDTH_HEIGHT_NV 0x90D0 -#define GL_MAX_DEEP_3D_TEXTURE_DEPTH_NV 0x90D1 - -#define GLEW_NV_deep_texture3D GLEW_GET_VAR(__GLEW_NV_deep_texture3D) - -#endif /* GL_NV_deep_texture3D */ - -/* ------------------------ GL_NV_depth_buffer_float ----------------------- */ - -#ifndef GL_NV_depth_buffer_float -#define GL_NV_depth_buffer_float 1 - -#define GL_DEPTH_COMPONENT32F_NV 0x8DAB -#define GL_DEPTH32F_STENCIL8_NV 0x8DAC -#define GL_FLOAT_32_UNSIGNED_INT_24_8_REV_NV 0x8DAD -#define GL_DEPTH_BUFFER_FLOAT_MODE_NV 0x8DAF - -typedef void (GLAPIENTRY * PFNGLCLEARDEPTHDNVPROC) (GLdouble depth); -typedef void (GLAPIENTRY * PFNGLDEPTHBOUNDSDNVPROC) (GLdouble zmin, GLdouble zmax); -typedef void (GLAPIENTRY * PFNGLDEPTHRANGEDNVPROC) (GLdouble zNear, GLdouble zFar); - -#define glClearDepthdNV GLEW_GET_FUN(__glewClearDepthdNV) -#define glDepthBoundsdNV GLEW_GET_FUN(__glewDepthBoundsdNV) -#define glDepthRangedNV GLEW_GET_FUN(__glewDepthRangedNV) - -#define GLEW_NV_depth_buffer_float GLEW_GET_VAR(__GLEW_NV_depth_buffer_float) - -#endif /* GL_NV_depth_buffer_float */ - -/* --------------------------- GL_NV_depth_clamp --------------------------- */ - -#ifndef GL_NV_depth_clamp -#define GL_NV_depth_clamp 1 - -#define GL_DEPTH_CLAMP_NV 0x864F - -#define GLEW_NV_depth_clamp GLEW_GET_VAR(__GLEW_NV_depth_clamp) - -#endif /* GL_NV_depth_clamp */ - -/* ---------------------- GL_NV_depth_range_unclamped ---------------------- */ - -#ifndef GL_NV_depth_range_unclamped -#define GL_NV_depth_range_unclamped 1 - -#define GL_SAMPLE_COUNT_BITS_NV 0x8864 -#define GL_CURRENT_SAMPLE_COUNT_QUERY_NV 0x8865 -#define GL_QUERY_RESULT_NV 0x8866 -#define GL_QUERY_RESULT_AVAILABLE_NV 0x8867 -#define GL_SAMPLE_COUNT_NV 0x8914 - -#define GLEW_NV_depth_range_unclamped GLEW_GET_VAR(__GLEW_NV_depth_range_unclamped) - -#endif /* GL_NV_depth_range_unclamped */ - -/* --------------------------- GL_NV_draw_texture -------------------------- */ - -#ifndef GL_NV_draw_texture -#define GL_NV_draw_texture 1 - -typedef void (GLAPIENTRY * PFNGLDRAWTEXTURENVPROC) (GLuint texture, GLuint sampler, GLfloat x0, GLfloat y0, GLfloat x1, GLfloat y1, GLfloat z, GLfloat s0, GLfloat t0, GLfloat s1, GLfloat t1); - -#define glDrawTextureNV GLEW_GET_FUN(__glewDrawTextureNV) - -#define GLEW_NV_draw_texture GLEW_GET_VAR(__GLEW_NV_draw_texture) - -#endif /* GL_NV_draw_texture */ - -/* ------------------------ GL_NV_draw_vulkan_image ------------------------ */ - -#ifndef GL_NV_draw_vulkan_image -#define GL_NV_draw_vulkan_image 1 - -typedef void (APIENTRY *GLVULKANPROCNV)(void); - -typedef void (GLAPIENTRY * PFNGLDRAWVKIMAGENVPROC) (GLuint64 vkImage, GLuint sampler, GLfloat x0, GLfloat y0, GLfloat x1, GLfloat y1, GLfloat z, GLfloat s0, GLfloat t0, GLfloat s1, GLfloat t1); -typedef GLVULKANPROCNV (GLAPIENTRY * PFNGLGETVKPROCADDRNVPROC) (const GLchar* name); -typedef void (GLAPIENTRY * PFNGLSIGNALVKFENCENVPROC) (GLuint64 vkFence); -typedef void (GLAPIENTRY * PFNGLSIGNALVKSEMAPHORENVPROC) (GLuint64 vkSemaphore); -typedef void (GLAPIENTRY * PFNGLWAITVKSEMAPHORENVPROC) (GLuint64 vkSemaphore); - -#define glDrawVkImageNV GLEW_GET_FUN(__glewDrawVkImageNV) -#define glGetVkProcAddrNV GLEW_GET_FUN(__glewGetVkProcAddrNV) -#define glSignalVkFenceNV GLEW_GET_FUN(__glewSignalVkFenceNV) -#define glSignalVkSemaphoreNV GLEW_GET_FUN(__glewSignalVkSemaphoreNV) -#define glWaitVkSemaphoreNV GLEW_GET_FUN(__glewWaitVkSemaphoreNV) - -#define GLEW_NV_draw_vulkan_image GLEW_GET_VAR(__GLEW_NV_draw_vulkan_image) - -#endif /* GL_NV_draw_vulkan_image */ - -/* ---------------------------- GL_NV_evaluators --------------------------- */ - -#ifndef GL_NV_evaluators -#define GL_NV_evaluators 1 - -#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 - -typedef void (GLAPIENTRY * PFNGLEVALMAPSNVPROC) (GLenum target, GLenum mode); -typedef void (GLAPIENTRY * PFNGLGETMAPATTRIBPARAMETERFVNVPROC) (GLenum target, GLuint index, GLenum pname, GLfloat* params); -typedef void (GLAPIENTRY * PFNGLGETMAPATTRIBPARAMETERIVNVPROC) (GLenum target, GLuint index, GLenum pname, GLint* params); -typedef void (GLAPIENTRY * PFNGLGETMAPCONTROLPOINTSNVPROC) (GLenum target, GLuint index, GLenum type, GLsizei ustride, GLsizei vstride, GLboolean packed, void *points); -typedef void (GLAPIENTRY * PFNGLGETMAPPARAMETERFVNVPROC) (GLenum target, GLenum pname, GLfloat* params); -typedef void (GLAPIENTRY * PFNGLGETMAPPARAMETERIVNVPROC) (GLenum target, GLenum pname, GLint* params); -typedef void (GLAPIENTRY * PFNGLMAPCONTROLPOINTSNVPROC) (GLenum target, GLuint index, GLenum type, GLsizei ustride, GLsizei vstride, GLint uorder, GLint vorder, GLboolean packed, const void *points); -typedef void (GLAPIENTRY * PFNGLMAPPARAMETERFVNVPROC) (GLenum target, GLenum pname, const GLfloat* params); -typedef void (GLAPIENTRY * PFNGLMAPPARAMETERIVNVPROC) (GLenum target, GLenum pname, const GLint* params); - -#define glEvalMapsNV GLEW_GET_FUN(__glewEvalMapsNV) -#define glGetMapAttribParameterfvNV GLEW_GET_FUN(__glewGetMapAttribParameterfvNV) -#define glGetMapAttribParameterivNV GLEW_GET_FUN(__glewGetMapAttribParameterivNV) -#define glGetMapControlPointsNV GLEW_GET_FUN(__glewGetMapControlPointsNV) -#define glGetMapParameterfvNV GLEW_GET_FUN(__glewGetMapParameterfvNV) -#define glGetMapParameterivNV GLEW_GET_FUN(__glewGetMapParameterivNV) -#define glMapControlPointsNV GLEW_GET_FUN(__glewMapControlPointsNV) -#define glMapParameterfvNV GLEW_GET_FUN(__glewMapParameterfvNV) -#define glMapParameterivNV GLEW_GET_FUN(__glewMapParameterivNV) - -#define GLEW_NV_evaluators GLEW_GET_VAR(__GLEW_NV_evaluators) - -#endif /* GL_NV_evaluators */ - -/* ----------------------- GL_NV_explicit_multisample ---------------------- */ - -#ifndef GL_NV_explicit_multisample -#define GL_NV_explicit_multisample 1 - -#define GL_SAMPLE_POSITION_NV 0x8E50 -#define GL_SAMPLE_MASK_NV 0x8E51 -#define GL_SAMPLE_MASK_VALUE_NV 0x8E52 -#define GL_TEXTURE_BINDING_RENDERBUFFER_NV 0x8E53 -#define GL_TEXTURE_RENDERBUFFER_DATA_STORE_BINDING_NV 0x8E54 -#define GL_TEXTURE_RENDERBUFFER_NV 0x8E55 -#define GL_SAMPLER_RENDERBUFFER_NV 0x8E56 -#define GL_INT_SAMPLER_RENDERBUFFER_NV 0x8E57 -#define GL_UNSIGNED_INT_SAMPLER_RENDERBUFFER_NV 0x8E58 -#define GL_MAX_SAMPLE_MASK_WORDS_NV 0x8E59 - -typedef void (GLAPIENTRY * PFNGLGETMULTISAMPLEFVNVPROC) (GLenum pname, GLuint index, GLfloat* val); -typedef void (GLAPIENTRY * PFNGLSAMPLEMASKINDEXEDNVPROC) (GLuint index, GLbitfield mask); -typedef void (GLAPIENTRY * PFNGLTEXRENDERBUFFERNVPROC) (GLenum target, GLuint renderbuffer); - -#define glGetMultisamplefvNV GLEW_GET_FUN(__glewGetMultisamplefvNV) -#define glSampleMaskIndexedNV GLEW_GET_FUN(__glewSampleMaskIndexedNV) -#define glTexRenderbufferNV GLEW_GET_FUN(__glewTexRenderbufferNV) - -#define GLEW_NV_explicit_multisample GLEW_GET_VAR(__GLEW_NV_explicit_multisample) - -#endif /* GL_NV_explicit_multisample */ - -/* ------------------------------ GL_NV_fence ------------------------------ */ - -#ifndef GL_NV_fence -#define GL_NV_fence 1 - -#define GL_ALL_COMPLETED_NV 0x84F2 -#define GL_FENCE_STATUS_NV 0x84F3 -#define GL_FENCE_CONDITION_NV 0x84F4 - -typedef void (GLAPIENTRY * PFNGLDELETEFENCESNVPROC) (GLsizei n, const GLuint* fences); -typedef void (GLAPIENTRY * PFNGLFINISHFENCENVPROC) (GLuint fence); -typedef void (GLAPIENTRY * PFNGLGENFENCESNVPROC) (GLsizei n, GLuint* fences); -typedef void (GLAPIENTRY * PFNGLGETFENCEIVNVPROC) (GLuint fence, GLenum pname, GLint* params); -typedef GLboolean (GLAPIENTRY * PFNGLISFENCENVPROC) (GLuint fence); -typedef void (GLAPIENTRY * PFNGLSETFENCENVPROC) (GLuint fence, GLenum condition); -typedef GLboolean (GLAPIENTRY * PFNGLTESTFENCENVPROC) (GLuint fence); - -#define glDeleteFencesNV GLEW_GET_FUN(__glewDeleteFencesNV) -#define glFinishFenceNV GLEW_GET_FUN(__glewFinishFenceNV) -#define glGenFencesNV GLEW_GET_FUN(__glewGenFencesNV) -#define glGetFenceivNV GLEW_GET_FUN(__glewGetFenceivNV) -#define glIsFenceNV GLEW_GET_FUN(__glewIsFenceNV) -#define glSetFenceNV GLEW_GET_FUN(__glewSetFenceNV) -#define glTestFenceNV GLEW_GET_FUN(__glewTestFenceNV) - -#define GLEW_NV_fence GLEW_GET_VAR(__GLEW_NV_fence) - -#endif /* GL_NV_fence */ - -/* -------------------------- GL_NV_fill_rectangle ------------------------- */ - -#ifndef GL_NV_fill_rectangle -#define GL_NV_fill_rectangle 1 - -#define GL_FILL_RECTANGLE_NV 0x933C - -#define GLEW_NV_fill_rectangle GLEW_GET_VAR(__GLEW_NV_fill_rectangle) - -#endif /* GL_NV_fill_rectangle */ - -/* --------------------------- GL_NV_float_buffer -------------------------- */ - -#ifndef GL_NV_float_buffer -#define GL_NV_float_buffer 1 - -#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 - -#define GLEW_NV_float_buffer GLEW_GET_VAR(__GLEW_NV_float_buffer) - -#endif /* GL_NV_float_buffer */ - -/* --------------------------- GL_NV_fog_distance -------------------------- */ - -#ifndef GL_NV_fog_distance -#define GL_NV_fog_distance 1 - -#define GL_FOG_DISTANCE_MODE_NV 0x855A -#define GL_EYE_RADIAL_NV 0x855B -#define GL_EYE_PLANE_ABSOLUTE_NV 0x855C - -#define GLEW_NV_fog_distance GLEW_GET_VAR(__GLEW_NV_fog_distance) - -#endif /* GL_NV_fog_distance */ - -/* -------------------- GL_NV_fragment_coverage_to_color ------------------- */ - -#ifndef GL_NV_fragment_coverage_to_color -#define GL_NV_fragment_coverage_to_color 1 - -#define GL_FRAGMENT_COVERAGE_TO_COLOR_NV 0x92DD -#define GL_FRAGMENT_COVERAGE_COLOR_NV 0x92DE - -typedef void (GLAPIENTRY * PFNGLFRAGMENTCOVERAGECOLORNVPROC) (GLuint color); - -#define glFragmentCoverageColorNV GLEW_GET_FUN(__glewFragmentCoverageColorNV) - -#define GLEW_NV_fragment_coverage_to_color GLEW_GET_VAR(__GLEW_NV_fragment_coverage_to_color) - -#endif /* GL_NV_fragment_coverage_to_color */ - -/* ------------------------- GL_NV_fragment_program ------------------------ */ - -#ifndef GL_NV_fragment_program -#define GL_NV_fragment_program 1 - -#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 - -typedef void (GLAPIENTRY * PFNGLGETPROGRAMNAMEDPARAMETERDVNVPROC) (GLuint id, GLsizei len, const GLubyte* name, GLdouble *params); -typedef void (GLAPIENTRY * PFNGLGETPROGRAMNAMEDPARAMETERFVNVPROC) (GLuint id, GLsizei len, const GLubyte* name, GLfloat *params); -typedef void (GLAPIENTRY * PFNGLPROGRAMNAMEDPARAMETER4DNVPROC) (GLuint id, GLsizei len, const GLubyte* name, GLdouble x, GLdouble y, GLdouble z, GLdouble w); -typedef void (GLAPIENTRY * PFNGLPROGRAMNAMEDPARAMETER4DVNVPROC) (GLuint id, GLsizei len, const GLubyte* name, const GLdouble v[]); -typedef void (GLAPIENTRY * PFNGLPROGRAMNAMEDPARAMETER4FNVPROC) (GLuint id, GLsizei len, const GLubyte* name, GLfloat x, GLfloat y, GLfloat z, GLfloat w); -typedef void (GLAPIENTRY * PFNGLPROGRAMNAMEDPARAMETER4FVNVPROC) (GLuint id, GLsizei len, const GLubyte* name, const GLfloat v[]); - -#define glGetProgramNamedParameterdvNV GLEW_GET_FUN(__glewGetProgramNamedParameterdvNV) -#define glGetProgramNamedParameterfvNV GLEW_GET_FUN(__glewGetProgramNamedParameterfvNV) -#define glProgramNamedParameter4dNV GLEW_GET_FUN(__glewProgramNamedParameter4dNV) -#define glProgramNamedParameter4dvNV GLEW_GET_FUN(__glewProgramNamedParameter4dvNV) -#define glProgramNamedParameter4fNV GLEW_GET_FUN(__glewProgramNamedParameter4fNV) -#define glProgramNamedParameter4fvNV GLEW_GET_FUN(__glewProgramNamedParameter4fvNV) - -#define GLEW_NV_fragment_program GLEW_GET_VAR(__GLEW_NV_fragment_program) - -#endif /* GL_NV_fragment_program */ - -/* ------------------------ GL_NV_fragment_program2 ------------------------ */ - -#ifndef GL_NV_fragment_program2 -#define GL_NV_fragment_program2 1 - -#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 - -#define GLEW_NV_fragment_program2 GLEW_GET_VAR(__GLEW_NV_fragment_program2) - -#endif /* GL_NV_fragment_program2 */ - -/* ------------------------ GL_NV_fragment_program4 ------------------------ */ - -#ifndef GL_NV_fragment_program4 -#define GL_NV_fragment_program4 1 - -#define GLEW_NV_fragment_program4 GLEW_GET_VAR(__GLEW_NV_fragment_program4) - -#endif /* GL_NV_fragment_program4 */ - -/* --------------------- GL_NV_fragment_program_option --------------------- */ - -#ifndef GL_NV_fragment_program_option -#define GL_NV_fragment_program_option 1 - -#define GLEW_NV_fragment_program_option GLEW_GET_VAR(__GLEW_NV_fragment_program_option) - -#endif /* GL_NV_fragment_program_option */ - -/* -------------------- GL_NV_fragment_shader_interlock -------------------- */ - -#ifndef GL_NV_fragment_shader_interlock -#define GL_NV_fragment_shader_interlock 1 - -#define GLEW_NV_fragment_shader_interlock GLEW_GET_VAR(__GLEW_NV_fragment_shader_interlock) - -#endif /* GL_NV_fragment_shader_interlock */ - -/* -------------------- GL_NV_framebuffer_mixed_samples -------------------- */ - -#ifndef GL_NV_framebuffer_mixed_samples -#define GL_NV_framebuffer_mixed_samples 1 - -#define GL_COLOR_SAMPLES_NV 0x8E20 -#define GL_RASTER_MULTISAMPLE_EXT 0x9327 -#define GL_RASTER_SAMPLES_EXT 0x9328 -#define GL_MAX_RASTER_SAMPLES_EXT 0x9329 -#define GL_RASTER_FIXED_SAMPLE_LOCATIONS_EXT 0x932A -#define GL_MULTISAMPLE_RASTERIZATION_ALLOWED_EXT 0x932B -#define GL_EFFECTIVE_RASTER_SAMPLES_EXT 0x932C -#define GL_DEPTH_SAMPLES_NV 0x932D -#define GL_STENCIL_SAMPLES_NV 0x932E -#define GL_MIXED_DEPTH_SAMPLES_SUPPORTED_NV 0x932F -#define GL_MIXED_STENCIL_SAMPLES_SUPPORTED_NV 0x9330 -#define GL_COVERAGE_MODULATION_TABLE_NV 0x9331 -#define GL_COVERAGE_MODULATION_NV 0x9332 -#define GL_COVERAGE_MODULATION_TABLE_SIZE_NV 0x9333 - -#define GLEW_NV_framebuffer_mixed_samples GLEW_GET_VAR(__GLEW_NV_framebuffer_mixed_samples) - -#endif /* GL_NV_framebuffer_mixed_samples */ - -/* ----------------- GL_NV_framebuffer_multisample_coverage ---------------- */ - -#ifndef GL_NV_framebuffer_multisample_coverage -#define GL_NV_framebuffer_multisample_coverage 1 - -#define GL_RENDERBUFFER_COVERAGE_SAMPLES_NV 0x8CAB -#define GL_RENDERBUFFER_COLOR_SAMPLES_NV 0x8E10 -#define GL_MAX_MULTISAMPLE_COVERAGE_MODES_NV 0x8E11 -#define GL_MULTISAMPLE_COVERAGE_MODES_NV 0x8E12 - -typedef void (GLAPIENTRY * PFNGLRENDERBUFFERSTORAGEMULTISAMPLECOVERAGENVPROC) (GLenum target, GLsizei coverageSamples, GLsizei colorSamples, GLenum internalformat, GLsizei width, GLsizei height); - -#define glRenderbufferStorageMultisampleCoverageNV GLEW_GET_FUN(__glewRenderbufferStorageMultisampleCoverageNV) - -#define GLEW_NV_framebuffer_multisample_coverage GLEW_GET_VAR(__GLEW_NV_framebuffer_multisample_coverage) - -#endif /* GL_NV_framebuffer_multisample_coverage */ - -/* ------------------------ GL_NV_geometry_program4 ------------------------ */ - -#ifndef GL_NV_geometry_program4 -#define GL_NV_geometry_program4 1 - -#define GL_GEOMETRY_PROGRAM_NV 0x8C26 -#define GL_MAX_PROGRAM_OUTPUT_VERTICES_NV 0x8C27 -#define GL_MAX_PROGRAM_TOTAL_OUTPUT_COMPONENTS_NV 0x8C28 - -typedef void (GLAPIENTRY * PFNGLPROGRAMVERTEXLIMITNVPROC) (GLenum target, GLint limit); - -#define glProgramVertexLimitNV GLEW_GET_FUN(__glewProgramVertexLimitNV) - -#define GLEW_NV_geometry_program4 GLEW_GET_VAR(__GLEW_NV_geometry_program4) - -#endif /* GL_NV_geometry_program4 */ - -/* ------------------------- GL_NV_geometry_shader4 ------------------------ */ - -#ifndef GL_NV_geometry_shader4 -#define GL_NV_geometry_shader4 1 - -#define GLEW_NV_geometry_shader4 GLEW_GET_VAR(__GLEW_NV_geometry_shader4) - -#endif /* GL_NV_geometry_shader4 */ - -/* ------------------- GL_NV_geometry_shader_passthrough ------------------- */ - -#ifndef GL_NV_geometry_shader_passthrough -#define GL_NV_geometry_shader_passthrough 1 - -#define GLEW_NV_geometry_shader_passthrough GLEW_GET_VAR(__GLEW_NV_geometry_shader_passthrough) - -#endif /* GL_NV_geometry_shader_passthrough */ - -/* -------------------------- GL_NV_gpu_multicast -------------------------- */ - -#ifndef GL_NV_gpu_multicast -#define GL_NV_gpu_multicast 1 - -#define GL_PER_GPU_STORAGE_BIT_NV 0x0800 -#define GL_MULTICAST_GPUS_NV 0x92BA -#define GL_PER_GPU_STORAGE_NV 0x9548 -#define GL_MULTICAST_PROGRAMMABLE_SAMPLE_LOCATION_NV 0x9549 -#define GL_RENDER_GPU_MASK_NV 0x9558 - -typedef void (GLAPIENTRY * PFNGLMULTICASTBARRIERNVPROC) (void); -typedef void (GLAPIENTRY * PFNGLMULTICASTBLITFRAMEBUFFERNVPROC) (GLuint srcGpu, GLuint dstGpu, GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter); -typedef void (GLAPIENTRY * PFNGLMULTICASTBUFFERSUBDATANVPROC) (GLbitfield gpuMask, GLuint buffer, GLintptr offset, GLsizeiptr size, const void *data); -typedef void (GLAPIENTRY * PFNGLMULTICASTCOPYBUFFERSUBDATANVPROC) (GLuint readGpu, GLbitfield writeGpuMask, GLuint readBuffer, GLuint writeBuffer, GLintptr readOffset, GLintptr writeOffset, GLsizeiptr size); -typedef void (GLAPIENTRY * PFNGLMULTICASTCOPYIMAGESUBDATANVPROC) (GLuint srcGpu, GLbitfield dstGpuMask, GLuint srcName, GLenum srcTarget, GLint srcLevel, GLint srcX, GLint srxY, GLint srcZ, GLuint dstName, GLenum dstTarget, GLint dstLevel, GLint dstX, GLint dstY, GLint dstZ, GLsizei srcWidth, GLsizei srcHeight, GLsizei srcDepth); -typedef void (GLAPIENTRY * PFNGLMULTICASTFRAMEBUFFERSAMPLELOCATIONSFVNVPROC) (GLuint gpu, GLuint framebuffer, GLuint start, GLsizei count, const GLfloat* v); -typedef void (GLAPIENTRY * PFNGLMULTICASTGETQUERYOBJECTI64VNVPROC) (GLuint gpu, GLuint id, GLenum pname, GLint64* params); -typedef void (GLAPIENTRY * PFNGLMULTICASTGETQUERYOBJECTIVNVPROC) (GLuint gpu, GLuint id, GLenum pname, GLint* params); -typedef void (GLAPIENTRY * PFNGLMULTICASTGETQUERYOBJECTUI64VNVPROC) (GLuint gpu, GLuint id, GLenum pname, GLuint64* params); -typedef void (GLAPIENTRY * PFNGLMULTICASTGETQUERYOBJECTUIVNVPROC) (GLuint gpu, GLuint id, GLenum pname, GLuint* params); -typedef void (GLAPIENTRY * PFNGLMULTICASTWAITSYNCNVPROC) (GLuint signalGpu, GLbitfield waitGpuMask); -typedef void (GLAPIENTRY * PFNGLRENDERGPUMASKNVPROC) (GLbitfield mask); - -#define glMulticastBarrierNV GLEW_GET_FUN(__glewMulticastBarrierNV) -#define glMulticastBlitFramebufferNV GLEW_GET_FUN(__glewMulticastBlitFramebufferNV) -#define glMulticastBufferSubDataNV GLEW_GET_FUN(__glewMulticastBufferSubDataNV) -#define glMulticastCopyBufferSubDataNV GLEW_GET_FUN(__glewMulticastCopyBufferSubDataNV) -#define glMulticastCopyImageSubDataNV GLEW_GET_FUN(__glewMulticastCopyImageSubDataNV) -#define glMulticastFramebufferSampleLocationsfvNV GLEW_GET_FUN(__glewMulticastFramebufferSampleLocationsfvNV) -#define glMulticastGetQueryObjecti64vNV GLEW_GET_FUN(__glewMulticastGetQueryObjecti64vNV) -#define glMulticastGetQueryObjectivNV GLEW_GET_FUN(__glewMulticastGetQueryObjectivNV) -#define glMulticastGetQueryObjectui64vNV GLEW_GET_FUN(__glewMulticastGetQueryObjectui64vNV) -#define glMulticastGetQueryObjectuivNV GLEW_GET_FUN(__glewMulticastGetQueryObjectuivNV) -#define glMulticastWaitSyncNV GLEW_GET_FUN(__glewMulticastWaitSyncNV) -#define glRenderGpuMaskNV GLEW_GET_FUN(__glewRenderGpuMaskNV) - -#define GLEW_NV_gpu_multicast GLEW_GET_VAR(__GLEW_NV_gpu_multicast) - -#endif /* GL_NV_gpu_multicast */ - -/* --------------------------- GL_NV_gpu_program4 -------------------------- */ - -#ifndef GL_NV_gpu_program4 -#define GL_NV_gpu_program4 1 - -#define GL_MIN_PROGRAM_TEXEL_OFFSET_NV 0x8904 -#define GL_MAX_PROGRAM_TEXEL_OFFSET_NV 0x8905 -#define GL_PROGRAM_ATTRIB_COMPONENTS_NV 0x8906 -#define GL_PROGRAM_RESULT_COMPONENTS_NV 0x8907 -#define GL_MAX_PROGRAM_ATTRIB_COMPONENTS_NV 0x8908 -#define GL_MAX_PROGRAM_RESULT_COMPONENTS_NV 0x8909 -#define GL_MAX_PROGRAM_GENERIC_ATTRIBS_NV 0x8DA5 -#define GL_MAX_PROGRAM_GENERIC_RESULTS_NV 0x8DA6 - -typedef void (GLAPIENTRY * PFNGLPROGRAMENVPARAMETERI4INVPROC) (GLenum target, GLuint index, GLint x, GLint y, GLint z, GLint w); -typedef void (GLAPIENTRY * PFNGLPROGRAMENVPARAMETERI4IVNVPROC) (GLenum target, GLuint index, const GLint *params); -typedef void (GLAPIENTRY * PFNGLPROGRAMENVPARAMETERI4UINVPROC) (GLenum target, GLuint index, GLuint x, GLuint y, GLuint z, GLuint w); -typedef void (GLAPIENTRY * PFNGLPROGRAMENVPARAMETERI4UIVNVPROC) (GLenum target, GLuint index, const GLuint *params); -typedef void (GLAPIENTRY * PFNGLPROGRAMENVPARAMETERSI4IVNVPROC) (GLenum target, GLuint index, GLsizei count, const GLint *params); -typedef void (GLAPIENTRY * PFNGLPROGRAMENVPARAMETERSI4UIVNVPROC) (GLenum target, GLuint index, GLsizei count, const GLuint *params); -typedef void (GLAPIENTRY * PFNGLPROGRAMLOCALPARAMETERI4INVPROC) (GLenum target, GLuint index, GLint x, GLint y, GLint z, GLint w); -typedef void (GLAPIENTRY * PFNGLPROGRAMLOCALPARAMETERI4IVNVPROC) (GLenum target, GLuint index, const GLint *params); -typedef void (GLAPIENTRY * PFNGLPROGRAMLOCALPARAMETERI4UINVPROC) (GLenum target, GLuint index, GLuint x, GLuint y, GLuint z, GLuint w); -typedef void (GLAPIENTRY * PFNGLPROGRAMLOCALPARAMETERI4UIVNVPROC) (GLenum target, GLuint index, const GLuint *params); -typedef void (GLAPIENTRY * PFNGLPROGRAMLOCALPARAMETERSI4IVNVPROC) (GLenum target, GLuint index, GLsizei count, const GLint *params); -typedef void (GLAPIENTRY * PFNGLPROGRAMLOCALPARAMETERSI4UIVNVPROC) (GLenum target, GLuint index, GLsizei count, const GLuint *params); - -#define glProgramEnvParameterI4iNV GLEW_GET_FUN(__glewProgramEnvParameterI4iNV) -#define glProgramEnvParameterI4ivNV GLEW_GET_FUN(__glewProgramEnvParameterI4ivNV) -#define glProgramEnvParameterI4uiNV GLEW_GET_FUN(__glewProgramEnvParameterI4uiNV) -#define glProgramEnvParameterI4uivNV GLEW_GET_FUN(__glewProgramEnvParameterI4uivNV) -#define glProgramEnvParametersI4ivNV GLEW_GET_FUN(__glewProgramEnvParametersI4ivNV) -#define glProgramEnvParametersI4uivNV GLEW_GET_FUN(__glewProgramEnvParametersI4uivNV) -#define glProgramLocalParameterI4iNV GLEW_GET_FUN(__glewProgramLocalParameterI4iNV) -#define glProgramLocalParameterI4ivNV GLEW_GET_FUN(__glewProgramLocalParameterI4ivNV) -#define glProgramLocalParameterI4uiNV GLEW_GET_FUN(__glewProgramLocalParameterI4uiNV) -#define glProgramLocalParameterI4uivNV GLEW_GET_FUN(__glewProgramLocalParameterI4uivNV) -#define glProgramLocalParametersI4ivNV GLEW_GET_FUN(__glewProgramLocalParametersI4ivNV) -#define glProgramLocalParametersI4uivNV GLEW_GET_FUN(__glewProgramLocalParametersI4uivNV) - -#define GLEW_NV_gpu_program4 GLEW_GET_VAR(__GLEW_NV_gpu_program4) - -#endif /* GL_NV_gpu_program4 */ - -/* --------------------------- GL_NV_gpu_program5 -------------------------- */ - -#ifndef GL_NV_gpu_program5 -#define GL_NV_gpu_program5 1 - -#define GL_MAX_GEOMETRY_PROGRAM_INVOCATIONS_NV 0x8E5A -#define GL_MIN_FRAGMENT_INTERPOLATION_OFFSET_NV 0x8E5B -#define GL_MAX_FRAGMENT_INTERPOLATION_OFFSET_NV 0x8E5C -#define GL_FRAGMENT_PROGRAM_INTERPOLATION_OFFSET_BITS_NV 0x8E5D -#define GL_MIN_PROGRAM_TEXTURE_GATHER_OFFSET_NV 0x8E5E -#define GL_MAX_PROGRAM_TEXTURE_GATHER_OFFSET_NV 0x8E5F - -#define GLEW_NV_gpu_program5 GLEW_GET_VAR(__GLEW_NV_gpu_program5) - -#endif /* GL_NV_gpu_program5 */ - -/* -------------------- GL_NV_gpu_program5_mem_extended -------------------- */ - -#ifndef GL_NV_gpu_program5_mem_extended -#define GL_NV_gpu_program5_mem_extended 1 - -#define GLEW_NV_gpu_program5_mem_extended GLEW_GET_VAR(__GLEW_NV_gpu_program5_mem_extended) - -#endif /* GL_NV_gpu_program5_mem_extended */ - -/* ------------------------- GL_NV_gpu_program_fp64 ------------------------ */ - -#ifndef GL_NV_gpu_program_fp64 -#define GL_NV_gpu_program_fp64 1 - -#define GLEW_NV_gpu_program_fp64 GLEW_GET_VAR(__GLEW_NV_gpu_program_fp64) - -#endif /* GL_NV_gpu_program_fp64 */ - -/* --------------------------- GL_NV_gpu_shader5 --------------------------- */ - -#ifndef GL_NV_gpu_shader5 -#define GL_NV_gpu_shader5 1 - -#define GL_INT64_NV 0x140E -#define GL_UNSIGNED_INT64_NV 0x140F -#define GL_INT8_NV 0x8FE0 -#define GL_INT8_VEC2_NV 0x8FE1 -#define GL_INT8_VEC3_NV 0x8FE2 -#define GL_INT8_VEC4_NV 0x8FE3 -#define GL_INT16_NV 0x8FE4 -#define GL_INT16_VEC2_NV 0x8FE5 -#define GL_INT16_VEC3_NV 0x8FE6 -#define GL_INT16_VEC4_NV 0x8FE7 -#define GL_INT64_VEC2_NV 0x8FE9 -#define GL_INT64_VEC3_NV 0x8FEA -#define GL_INT64_VEC4_NV 0x8FEB -#define GL_UNSIGNED_INT8_NV 0x8FEC -#define GL_UNSIGNED_INT8_VEC2_NV 0x8FED -#define GL_UNSIGNED_INT8_VEC3_NV 0x8FEE -#define GL_UNSIGNED_INT8_VEC4_NV 0x8FEF -#define GL_UNSIGNED_INT16_NV 0x8FF0 -#define GL_UNSIGNED_INT16_VEC2_NV 0x8FF1 -#define GL_UNSIGNED_INT16_VEC3_NV 0x8FF2 -#define GL_UNSIGNED_INT16_VEC4_NV 0x8FF3 -#define GL_UNSIGNED_INT64_VEC2_NV 0x8FF5 -#define GL_UNSIGNED_INT64_VEC3_NV 0x8FF6 -#define GL_UNSIGNED_INT64_VEC4_NV 0x8FF7 -#define GL_FLOAT16_NV 0x8FF8 -#define GL_FLOAT16_VEC2_NV 0x8FF9 -#define GL_FLOAT16_VEC3_NV 0x8FFA -#define GL_FLOAT16_VEC4_NV 0x8FFB - -typedef void (GLAPIENTRY * PFNGLGETUNIFORMI64VNVPROC) (GLuint program, GLint location, GLint64EXT* params); -typedef void (GLAPIENTRY * PFNGLGETUNIFORMUI64VNVPROC) (GLuint program, GLint location, GLuint64EXT* params); -typedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM1I64NVPROC) (GLuint program, GLint location, GLint64EXT x); -typedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM1I64VNVPROC) (GLuint program, GLint location, GLsizei count, const GLint64EXT* value); -typedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM1UI64NVPROC) (GLuint program, GLint location, GLuint64EXT x); -typedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM1UI64VNVPROC) (GLuint program, GLint location, GLsizei count, const GLuint64EXT* value); -typedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM2I64NVPROC) (GLuint program, GLint location, GLint64EXT x, GLint64EXT y); -typedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM2I64VNVPROC) (GLuint program, GLint location, GLsizei count, const GLint64EXT* value); -typedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM2UI64NVPROC) (GLuint program, GLint location, GLuint64EXT x, GLuint64EXT y); -typedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM2UI64VNVPROC) (GLuint program, GLint location, GLsizei count, const GLuint64EXT* value); -typedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM3I64NVPROC) (GLuint program, GLint location, GLint64EXT x, GLint64EXT y, GLint64EXT z); -typedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM3I64VNVPROC) (GLuint program, GLint location, GLsizei count, const GLint64EXT* value); -typedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM3UI64NVPROC) (GLuint program, GLint location, GLuint64EXT x, GLuint64EXT y, GLuint64EXT z); -typedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM3UI64VNVPROC) (GLuint program, GLint location, GLsizei count, const GLuint64EXT* value); -typedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM4I64NVPROC) (GLuint program, GLint location, GLint64EXT x, GLint64EXT y, GLint64EXT z, GLint64EXT w); -typedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM4I64VNVPROC) (GLuint program, GLint location, GLsizei count, const GLint64EXT* value); -typedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM4UI64NVPROC) (GLuint program, GLint location, GLuint64EXT x, GLuint64EXT y, GLuint64EXT z, GLuint64EXT w); -typedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM4UI64VNVPROC) (GLuint program, GLint location, GLsizei count, const GLuint64EXT* value); -typedef void (GLAPIENTRY * PFNGLUNIFORM1I64NVPROC) (GLint location, GLint64EXT x); -typedef void (GLAPIENTRY * PFNGLUNIFORM1I64VNVPROC) (GLint location, GLsizei count, const GLint64EXT* value); -typedef void (GLAPIENTRY * PFNGLUNIFORM1UI64NVPROC) (GLint location, GLuint64EXT x); -typedef void (GLAPIENTRY * PFNGLUNIFORM1UI64VNVPROC) (GLint location, GLsizei count, const GLuint64EXT* value); -typedef void (GLAPIENTRY * PFNGLUNIFORM2I64NVPROC) (GLint location, GLint64EXT x, GLint64EXT y); -typedef void (GLAPIENTRY * PFNGLUNIFORM2I64VNVPROC) (GLint location, GLsizei count, const GLint64EXT* value); -typedef void (GLAPIENTRY * PFNGLUNIFORM2UI64NVPROC) (GLint location, GLuint64EXT x, GLuint64EXT y); -typedef void (GLAPIENTRY * PFNGLUNIFORM2UI64VNVPROC) (GLint location, GLsizei count, const GLuint64EXT* value); -typedef void (GLAPIENTRY * PFNGLUNIFORM3I64NVPROC) (GLint location, GLint64EXT x, GLint64EXT y, GLint64EXT z); -typedef void (GLAPIENTRY * PFNGLUNIFORM3I64VNVPROC) (GLint location, GLsizei count, const GLint64EXT* value); -typedef void (GLAPIENTRY * PFNGLUNIFORM3UI64NVPROC) (GLint location, GLuint64EXT x, GLuint64EXT y, GLuint64EXT z); -typedef void (GLAPIENTRY * PFNGLUNIFORM3UI64VNVPROC) (GLint location, GLsizei count, const GLuint64EXT* value); -typedef void (GLAPIENTRY * PFNGLUNIFORM4I64NVPROC) (GLint location, GLint64EXT x, GLint64EXT y, GLint64EXT z, GLint64EXT w); -typedef void (GLAPIENTRY * PFNGLUNIFORM4I64VNVPROC) (GLint location, GLsizei count, const GLint64EXT* value); -typedef void (GLAPIENTRY * PFNGLUNIFORM4UI64NVPROC) (GLint location, GLuint64EXT x, GLuint64EXT y, GLuint64EXT z, GLuint64EXT w); -typedef void (GLAPIENTRY * PFNGLUNIFORM4UI64VNVPROC) (GLint location, GLsizei count, const GLuint64EXT* value); - -#define glGetUniformi64vNV GLEW_GET_FUN(__glewGetUniformi64vNV) -#define glGetUniformui64vNV GLEW_GET_FUN(__glewGetUniformui64vNV) -#define glProgramUniform1i64NV GLEW_GET_FUN(__glewProgramUniform1i64NV) -#define glProgramUniform1i64vNV GLEW_GET_FUN(__glewProgramUniform1i64vNV) -#define glProgramUniform1ui64NV GLEW_GET_FUN(__glewProgramUniform1ui64NV) -#define glProgramUniform1ui64vNV GLEW_GET_FUN(__glewProgramUniform1ui64vNV) -#define glProgramUniform2i64NV GLEW_GET_FUN(__glewProgramUniform2i64NV) -#define glProgramUniform2i64vNV GLEW_GET_FUN(__glewProgramUniform2i64vNV) -#define glProgramUniform2ui64NV GLEW_GET_FUN(__glewProgramUniform2ui64NV) -#define glProgramUniform2ui64vNV GLEW_GET_FUN(__glewProgramUniform2ui64vNV) -#define glProgramUniform3i64NV GLEW_GET_FUN(__glewProgramUniform3i64NV) -#define glProgramUniform3i64vNV GLEW_GET_FUN(__glewProgramUniform3i64vNV) -#define glProgramUniform3ui64NV GLEW_GET_FUN(__glewProgramUniform3ui64NV) -#define glProgramUniform3ui64vNV GLEW_GET_FUN(__glewProgramUniform3ui64vNV) -#define glProgramUniform4i64NV GLEW_GET_FUN(__glewProgramUniform4i64NV) -#define glProgramUniform4i64vNV GLEW_GET_FUN(__glewProgramUniform4i64vNV) -#define glProgramUniform4ui64NV GLEW_GET_FUN(__glewProgramUniform4ui64NV) -#define glProgramUniform4ui64vNV GLEW_GET_FUN(__glewProgramUniform4ui64vNV) -#define glUniform1i64NV GLEW_GET_FUN(__glewUniform1i64NV) -#define glUniform1i64vNV GLEW_GET_FUN(__glewUniform1i64vNV) -#define glUniform1ui64NV GLEW_GET_FUN(__glewUniform1ui64NV) -#define glUniform1ui64vNV GLEW_GET_FUN(__glewUniform1ui64vNV) -#define glUniform2i64NV GLEW_GET_FUN(__glewUniform2i64NV) -#define glUniform2i64vNV GLEW_GET_FUN(__glewUniform2i64vNV) -#define glUniform2ui64NV GLEW_GET_FUN(__glewUniform2ui64NV) -#define glUniform2ui64vNV GLEW_GET_FUN(__glewUniform2ui64vNV) -#define glUniform3i64NV GLEW_GET_FUN(__glewUniform3i64NV) -#define glUniform3i64vNV GLEW_GET_FUN(__glewUniform3i64vNV) -#define glUniform3ui64NV GLEW_GET_FUN(__glewUniform3ui64NV) -#define glUniform3ui64vNV GLEW_GET_FUN(__glewUniform3ui64vNV) -#define glUniform4i64NV GLEW_GET_FUN(__glewUniform4i64NV) -#define glUniform4i64vNV GLEW_GET_FUN(__glewUniform4i64vNV) -#define glUniform4ui64NV GLEW_GET_FUN(__glewUniform4ui64NV) -#define glUniform4ui64vNV GLEW_GET_FUN(__glewUniform4ui64vNV) - -#define GLEW_NV_gpu_shader5 GLEW_GET_VAR(__GLEW_NV_gpu_shader5) - -#endif /* GL_NV_gpu_shader5 */ - -/* ---------------------------- GL_NV_half_float --------------------------- */ - -#ifndef GL_NV_half_float -#define GL_NV_half_float 1 - -#define GL_HALF_FLOAT_NV 0x140B - -typedef unsigned short GLhalf; - -typedef void (GLAPIENTRY * PFNGLCOLOR3HNVPROC) (GLhalf red, GLhalf green, GLhalf blue); -typedef void (GLAPIENTRY * PFNGLCOLOR3HVNVPROC) (const GLhalf* v); -typedef void (GLAPIENTRY * PFNGLCOLOR4HNVPROC) (GLhalf red, GLhalf green, GLhalf blue, GLhalf alpha); -typedef void (GLAPIENTRY * PFNGLCOLOR4HVNVPROC) (const GLhalf* v); -typedef void (GLAPIENTRY * PFNGLFOGCOORDHNVPROC) (GLhalf fog); -typedef void (GLAPIENTRY * PFNGLFOGCOORDHVNVPROC) (const GLhalf* fog); -typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD1HNVPROC) (GLenum target, GLhalf s); -typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD1HVNVPROC) (GLenum target, const GLhalf* v); -typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD2HNVPROC) (GLenum target, GLhalf s, GLhalf t); -typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD2HVNVPROC) (GLenum target, const GLhalf* v); -typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD3HNVPROC) (GLenum target, GLhalf s, GLhalf t, GLhalf r); -typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD3HVNVPROC) (GLenum target, const GLhalf* v); -typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD4HNVPROC) (GLenum target, GLhalf s, GLhalf t, GLhalf r, GLhalf q); -typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD4HVNVPROC) (GLenum target, const GLhalf* v); -typedef void (GLAPIENTRY * PFNGLNORMAL3HNVPROC) (GLhalf nx, GLhalf ny, GLhalf nz); -typedef void (GLAPIENTRY * PFNGLNORMAL3HVNVPROC) (const GLhalf* v); -typedef void (GLAPIENTRY * PFNGLSECONDARYCOLOR3HNVPROC) (GLhalf red, GLhalf green, GLhalf blue); -typedef void (GLAPIENTRY * PFNGLSECONDARYCOLOR3HVNVPROC) (const GLhalf* v); -typedef void (GLAPIENTRY * PFNGLTEXCOORD1HNVPROC) (GLhalf s); -typedef void (GLAPIENTRY * PFNGLTEXCOORD1HVNVPROC) (const GLhalf* v); -typedef void (GLAPIENTRY * PFNGLTEXCOORD2HNVPROC) (GLhalf s, GLhalf t); -typedef void (GLAPIENTRY * PFNGLTEXCOORD2HVNVPROC) (const GLhalf* v); -typedef void (GLAPIENTRY * PFNGLTEXCOORD3HNVPROC) (GLhalf s, GLhalf t, GLhalf r); -typedef void (GLAPIENTRY * PFNGLTEXCOORD3HVNVPROC) (const GLhalf* v); -typedef void (GLAPIENTRY * PFNGLTEXCOORD4HNVPROC) (GLhalf s, GLhalf t, GLhalf r, GLhalf q); -typedef void (GLAPIENTRY * PFNGLTEXCOORD4HVNVPROC) (const GLhalf* v); -typedef void (GLAPIENTRY * PFNGLVERTEX2HNVPROC) (GLhalf x, GLhalf y); -typedef void (GLAPIENTRY * PFNGLVERTEX2HVNVPROC) (const GLhalf* v); -typedef void (GLAPIENTRY * PFNGLVERTEX3HNVPROC) (GLhalf x, GLhalf y, GLhalf z); -typedef void (GLAPIENTRY * PFNGLVERTEX3HVNVPROC) (const GLhalf* v); -typedef void (GLAPIENTRY * PFNGLVERTEX4HNVPROC) (GLhalf x, GLhalf y, GLhalf z, GLhalf w); -typedef void (GLAPIENTRY * PFNGLVERTEX4HVNVPROC) (const GLhalf* v); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB1HNVPROC) (GLuint index, GLhalf x); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB1HVNVPROC) (GLuint index, const GLhalf* v); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB2HNVPROC) (GLuint index, GLhalf x, GLhalf y); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB2HVNVPROC) (GLuint index, const GLhalf* v); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB3HNVPROC) (GLuint index, GLhalf x, GLhalf y, GLhalf z); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB3HVNVPROC) (GLuint index, const GLhalf* v); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4HNVPROC) (GLuint index, GLhalf x, GLhalf y, GLhalf z, GLhalf w); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4HVNVPROC) (GLuint index, const GLhalf* v); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBS1HVNVPROC) (GLuint index, GLsizei n, const GLhalf* v); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBS2HVNVPROC) (GLuint index, GLsizei n, const GLhalf* v); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBS3HVNVPROC) (GLuint index, GLsizei n, const GLhalf* v); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBS4HVNVPROC) (GLuint index, GLsizei n, const GLhalf* v); -typedef void (GLAPIENTRY * PFNGLVERTEXWEIGHTHNVPROC) (GLhalf weight); -typedef void (GLAPIENTRY * PFNGLVERTEXWEIGHTHVNVPROC) (const GLhalf* weight); - -#define glColor3hNV GLEW_GET_FUN(__glewColor3hNV) -#define glColor3hvNV GLEW_GET_FUN(__glewColor3hvNV) -#define glColor4hNV GLEW_GET_FUN(__glewColor4hNV) -#define glColor4hvNV GLEW_GET_FUN(__glewColor4hvNV) -#define glFogCoordhNV GLEW_GET_FUN(__glewFogCoordhNV) -#define glFogCoordhvNV GLEW_GET_FUN(__glewFogCoordhvNV) -#define glMultiTexCoord1hNV GLEW_GET_FUN(__glewMultiTexCoord1hNV) -#define glMultiTexCoord1hvNV GLEW_GET_FUN(__glewMultiTexCoord1hvNV) -#define glMultiTexCoord2hNV GLEW_GET_FUN(__glewMultiTexCoord2hNV) -#define glMultiTexCoord2hvNV GLEW_GET_FUN(__glewMultiTexCoord2hvNV) -#define glMultiTexCoord3hNV GLEW_GET_FUN(__glewMultiTexCoord3hNV) -#define glMultiTexCoord3hvNV GLEW_GET_FUN(__glewMultiTexCoord3hvNV) -#define glMultiTexCoord4hNV GLEW_GET_FUN(__glewMultiTexCoord4hNV) -#define glMultiTexCoord4hvNV GLEW_GET_FUN(__glewMultiTexCoord4hvNV) -#define glNormal3hNV GLEW_GET_FUN(__glewNormal3hNV) -#define glNormal3hvNV GLEW_GET_FUN(__glewNormal3hvNV) -#define glSecondaryColor3hNV GLEW_GET_FUN(__glewSecondaryColor3hNV) -#define glSecondaryColor3hvNV GLEW_GET_FUN(__glewSecondaryColor3hvNV) -#define glTexCoord1hNV GLEW_GET_FUN(__glewTexCoord1hNV) -#define glTexCoord1hvNV GLEW_GET_FUN(__glewTexCoord1hvNV) -#define glTexCoord2hNV GLEW_GET_FUN(__glewTexCoord2hNV) -#define glTexCoord2hvNV GLEW_GET_FUN(__glewTexCoord2hvNV) -#define glTexCoord3hNV GLEW_GET_FUN(__glewTexCoord3hNV) -#define glTexCoord3hvNV GLEW_GET_FUN(__glewTexCoord3hvNV) -#define glTexCoord4hNV GLEW_GET_FUN(__glewTexCoord4hNV) -#define glTexCoord4hvNV GLEW_GET_FUN(__glewTexCoord4hvNV) -#define glVertex2hNV GLEW_GET_FUN(__glewVertex2hNV) -#define glVertex2hvNV GLEW_GET_FUN(__glewVertex2hvNV) -#define glVertex3hNV GLEW_GET_FUN(__glewVertex3hNV) -#define glVertex3hvNV GLEW_GET_FUN(__glewVertex3hvNV) -#define glVertex4hNV GLEW_GET_FUN(__glewVertex4hNV) -#define glVertex4hvNV GLEW_GET_FUN(__glewVertex4hvNV) -#define glVertexAttrib1hNV GLEW_GET_FUN(__glewVertexAttrib1hNV) -#define glVertexAttrib1hvNV GLEW_GET_FUN(__glewVertexAttrib1hvNV) -#define glVertexAttrib2hNV GLEW_GET_FUN(__glewVertexAttrib2hNV) -#define glVertexAttrib2hvNV GLEW_GET_FUN(__glewVertexAttrib2hvNV) -#define glVertexAttrib3hNV GLEW_GET_FUN(__glewVertexAttrib3hNV) -#define glVertexAttrib3hvNV GLEW_GET_FUN(__glewVertexAttrib3hvNV) -#define glVertexAttrib4hNV GLEW_GET_FUN(__glewVertexAttrib4hNV) -#define glVertexAttrib4hvNV GLEW_GET_FUN(__glewVertexAttrib4hvNV) -#define glVertexAttribs1hvNV GLEW_GET_FUN(__glewVertexAttribs1hvNV) -#define glVertexAttribs2hvNV GLEW_GET_FUN(__glewVertexAttribs2hvNV) -#define glVertexAttribs3hvNV GLEW_GET_FUN(__glewVertexAttribs3hvNV) -#define glVertexAttribs4hvNV GLEW_GET_FUN(__glewVertexAttribs4hvNV) -#define glVertexWeighthNV GLEW_GET_FUN(__glewVertexWeighthNV) -#define glVertexWeighthvNV GLEW_GET_FUN(__glewVertexWeighthvNV) - -#define GLEW_NV_half_float GLEW_GET_VAR(__GLEW_NV_half_float) - -#endif /* GL_NV_half_float */ - -/* ------------------- GL_NV_internalformat_sample_query ------------------- */ - -#ifndef GL_NV_internalformat_sample_query -#define GL_NV_internalformat_sample_query 1 - -#define GL_MULTISAMPLES_NV 0x9371 -#define GL_SUPERSAMPLE_SCALE_X_NV 0x9372 -#define GL_SUPERSAMPLE_SCALE_Y_NV 0x9373 -#define GL_CONFORMANT_NV 0x9374 - -typedef void (GLAPIENTRY * PFNGLGETINTERNALFORMATSAMPLEIVNVPROC) (GLenum target, GLenum internalformat, GLsizei samples, GLenum pname, GLsizei bufSize, GLint* params); - -#define glGetInternalformatSampleivNV GLEW_GET_FUN(__glewGetInternalformatSampleivNV) - -#define GLEW_NV_internalformat_sample_query GLEW_GET_VAR(__GLEW_NV_internalformat_sample_query) - -#endif /* GL_NV_internalformat_sample_query */ - -/* ------------------------ GL_NV_light_max_exponent ----------------------- */ - -#ifndef GL_NV_light_max_exponent -#define GL_NV_light_max_exponent 1 - -#define GL_MAX_SHININESS_NV 0x8504 -#define GL_MAX_SPOT_EXPONENT_NV 0x8505 - -#define GLEW_NV_light_max_exponent GLEW_GET_VAR(__GLEW_NV_light_max_exponent) - -#endif /* GL_NV_light_max_exponent */ - -/* ----------------------- GL_NV_multisample_coverage ---------------------- */ - -#ifndef GL_NV_multisample_coverage -#define GL_NV_multisample_coverage 1 - -#define GL_COLOR_SAMPLES_NV 0x8E20 - -#define GLEW_NV_multisample_coverage GLEW_GET_VAR(__GLEW_NV_multisample_coverage) - -#endif /* GL_NV_multisample_coverage */ - -/* --------------------- GL_NV_multisample_filter_hint --------------------- */ - -#ifndef GL_NV_multisample_filter_hint -#define GL_NV_multisample_filter_hint 1 - -#define GL_MULTISAMPLE_FILTER_HINT_NV 0x8534 - -#define GLEW_NV_multisample_filter_hint GLEW_GET_VAR(__GLEW_NV_multisample_filter_hint) - -#endif /* GL_NV_multisample_filter_hint */ - -/* ------------------------- GL_NV_occlusion_query ------------------------- */ - -#ifndef GL_NV_occlusion_query -#define GL_NV_occlusion_query 1 - -#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 - -typedef void (GLAPIENTRY * PFNGLBEGINOCCLUSIONQUERYNVPROC) (GLuint id); -typedef void (GLAPIENTRY * PFNGLDELETEOCCLUSIONQUERIESNVPROC) (GLsizei n, const GLuint* ids); -typedef void (GLAPIENTRY * PFNGLENDOCCLUSIONQUERYNVPROC) (void); -typedef void (GLAPIENTRY * PFNGLGENOCCLUSIONQUERIESNVPROC) (GLsizei n, GLuint* ids); -typedef void (GLAPIENTRY * PFNGLGETOCCLUSIONQUERYIVNVPROC) (GLuint id, GLenum pname, GLint* params); -typedef void (GLAPIENTRY * PFNGLGETOCCLUSIONQUERYUIVNVPROC) (GLuint id, GLenum pname, GLuint* params); -typedef GLboolean (GLAPIENTRY * PFNGLISOCCLUSIONQUERYNVPROC) (GLuint id); - -#define glBeginOcclusionQueryNV GLEW_GET_FUN(__glewBeginOcclusionQueryNV) -#define glDeleteOcclusionQueriesNV GLEW_GET_FUN(__glewDeleteOcclusionQueriesNV) -#define glEndOcclusionQueryNV GLEW_GET_FUN(__glewEndOcclusionQueryNV) -#define glGenOcclusionQueriesNV GLEW_GET_FUN(__glewGenOcclusionQueriesNV) -#define glGetOcclusionQueryivNV GLEW_GET_FUN(__glewGetOcclusionQueryivNV) -#define glGetOcclusionQueryuivNV GLEW_GET_FUN(__glewGetOcclusionQueryuivNV) -#define glIsOcclusionQueryNV GLEW_GET_FUN(__glewIsOcclusionQueryNV) - -#define GLEW_NV_occlusion_query GLEW_GET_VAR(__GLEW_NV_occlusion_query) - -#endif /* GL_NV_occlusion_query */ - -/* ----------------------- GL_NV_packed_depth_stencil ---------------------- */ - -#ifndef GL_NV_packed_depth_stencil -#define GL_NV_packed_depth_stencil 1 - -#define GL_DEPTH_STENCIL_NV 0x84F9 -#define GL_UNSIGNED_INT_24_8_NV 0x84FA - -#define GLEW_NV_packed_depth_stencil GLEW_GET_VAR(__GLEW_NV_packed_depth_stencil) - -#endif /* GL_NV_packed_depth_stencil */ - -/* --------------------- GL_NV_parameter_buffer_object --------------------- */ - -#ifndef GL_NV_parameter_buffer_object -#define GL_NV_parameter_buffer_object 1 - -#define GL_MAX_PROGRAM_PARAMETER_BUFFER_BINDINGS_NV 0x8DA0 -#define GL_MAX_PROGRAM_PARAMETER_BUFFER_SIZE_NV 0x8DA1 -#define GL_VERTEX_PROGRAM_PARAMETER_BUFFER_NV 0x8DA2 -#define GL_GEOMETRY_PROGRAM_PARAMETER_BUFFER_NV 0x8DA3 -#define GL_FRAGMENT_PROGRAM_PARAMETER_BUFFER_NV 0x8DA4 - -typedef void (GLAPIENTRY * PFNGLPROGRAMBUFFERPARAMETERSIIVNVPROC) (GLenum target, GLuint buffer, GLuint index, GLsizei count, const GLint *params); -typedef void (GLAPIENTRY * PFNGLPROGRAMBUFFERPARAMETERSIUIVNVPROC) (GLenum target, GLuint buffer, GLuint index, GLsizei count, const GLuint *params); -typedef void (GLAPIENTRY * PFNGLPROGRAMBUFFERPARAMETERSFVNVPROC) (GLenum target, GLuint buffer, GLuint index, GLsizei count, const GLfloat *params); - -#define glProgramBufferParametersIivNV GLEW_GET_FUN(__glewProgramBufferParametersIivNV) -#define glProgramBufferParametersIuivNV GLEW_GET_FUN(__glewProgramBufferParametersIuivNV) -#define glProgramBufferParametersfvNV GLEW_GET_FUN(__glewProgramBufferParametersfvNV) - -#define GLEW_NV_parameter_buffer_object GLEW_GET_VAR(__GLEW_NV_parameter_buffer_object) - -#endif /* GL_NV_parameter_buffer_object */ - -/* --------------------- GL_NV_parameter_buffer_object2 -------------------- */ - -#ifndef GL_NV_parameter_buffer_object2 -#define GL_NV_parameter_buffer_object2 1 - -#define GLEW_NV_parameter_buffer_object2 GLEW_GET_VAR(__GLEW_NV_parameter_buffer_object2) - -#endif /* GL_NV_parameter_buffer_object2 */ - -/* -------------------------- GL_NV_path_rendering ------------------------- */ - -#ifndef GL_NV_path_rendering -#define GL_NV_path_rendering 1 - -#define GL_CLOSE_PATH_NV 0x00 -#define GL_BOLD_BIT_NV 0x01 -#define GL_GLYPH_WIDTH_BIT_NV 0x01 -#define GL_GLYPH_HEIGHT_BIT_NV 0x02 -#define GL_ITALIC_BIT_NV 0x02 -#define GL_MOVE_TO_NV 0x02 -#define GL_RELATIVE_MOVE_TO_NV 0x03 -#define GL_GLYPH_HORIZONTAL_BEARING_X_BIT_NV 0x04 -#define GL_LINE_TO_NV 0x04 -#define GL_RELATIVE_LINE_TO_NV 0x05 -#define GL_HORIZONTAL_LINE_TO_NV 0x06 -#define GL_RELATIVE_HORIZONTAL_LINE_TO_NV 0x07 -#define GL_GLYPH_HORIZONTAL_BEARING_Y_BIT_NV 0x08 -#define GL_VERTICAL_LINE_TO_NV 0x08 -#define GL_RELATIVE_VERTICAL_LINE_TO_NV 0x09 -#define GL_QUADRATIC_CURVE_TO_NV 0x0A -#define GL_RELATIVE_QUADRATIC_CURVE_TO_NV 0x0B -#define GL_CUBIC_CURVE_TO_NV 0x0C -#define GL_RELATIVE_CUBIC_CURVE_TO_NV 0x0D -#define GL_SMOOTH_QUADRATIC_CURVE_TO_NV 0x0E -#define GL_RELATIVE_SMOOTH_QUADRATIC_CURVE_TO_NV 0x0F -#define GL_GLYPH_HORIZONTAL_BEARING_ADVANCE_BIT_NV 0x10 -#define GL_SMOOTH_CUBIC_CURVE_TO_NV 0x10 -#define GL_RELATIVE_SMOOTH_CUBIC_CURVE_TO_NV 0x11 -#define GL_SMALL_CCW_ARC_TO_NV 0x12 -#define GL_RELATIVE_SMALL_CCW_ARC_TO_NV 0x13 -#define GL_SMALL_CW_ARC_TO_NV 0x14 -#define GL_RELATIVE_SMALL_CW_ARC_TO_NV 0x15 -#define GL_LARGE_CCW_ARC_TO_NV 0x16 -#define GL_RELATIVE_LARGE_CCW_ARC_TO_NV 0x17 -#define GL_LARGE_CW_ARC_TO_NV 0x18 -#define GL_RELATIVE_LARGE_CW_ARC_TO_NV 0x19 -#define GL_CONIC_CURVE_TO_NV 0x1A -#define GL_RELATIVE_CONIC_CURVE_TO_NV 0x1B -#define GL_GLYPH_VERTICAL_BEARING_X_BIT_NV 0x20 -#define GL_GLYPH_VERTICAL_BEARING_Y_BIT_NV 0x40 -#define GL_GLYPH_VERTICAL_BEARING_ADVANCE_BIT_NV 0x80 -#define GL_ROUNDED_RECT_NV 0xE8 -#define GL_RELATIVE_ROUNDED_RECT_NV 0xE9 -#define GL_ROUNDED_RECT2_NV 0xEA -#define GL_RELATIVE_ROUNDED_RECT2_NV 0xEB -#define GL_ROUNDED_RECT4_NV 0xEC -#define GL_RELATIVE_ROUNDED_RECT4_NV 0xED -#define GL_ROUNDED_RECT8_NV 0xEE -#define GL_RELATIVE_ROUNDED_RECT8_NV 0xEF -#define GL_RESTART_PATH_NV 0xF0 -#define GL_DUP_FIRST_CUBIC_CURVE_TO_NV 0xF2 -#define GL_DUP_LAST_CUBIC_CURVE_TO_NV 0xF4 -#define GL_RECT_NV 0xF6 -#define GL_RELATIVE_RECT_NV 0xF7 -#define GL_CIRCULAR_CCW_ARC_TO_NV 0xF8 -#define GL_CIRCULAR_CW_ARC_TO_NV 0xFA -#define GL_CIRCULAR_TANGENT_ARC_TO_NV 0xFC -#define GL_ARC_TO_NV 0xFE -#define GL_RELATIVE_ARC_TO_NV 0xFF -#define GL_GLYPH_HAS_KERNING_BIT_NV 0x100 -#define GL_PRIMARY_COLOR_NV 0x852C -#define GL_SECONDARY_COLOR_NV 0x852D -#define GL_PRIMARY_COLOR 0x8577 -#define GL_PATH_FORMAT_SVG_NV 0x9070 -#define GL_PATH_FORMAT_PS_NV 0x9071 -#define GL_STANDARD_FONT_NAME_NV 0x9072 -#define GL_SYSTEM_FONT_NAME_NV 0x9073 -#define GL_FILE_NAME_NV 0x9074 -#define GL_PATH_STROKE_WIDTH_NV 0x9075 -#define GL_PATH_END_CAPS_NV 0x9076 -#define GL_PATH_INITIAL_END_CAP_NV 0x9077 -#define GL_PATH_TERMINAL_END_CAP_NV 0x9078 -#define GL_PATH_JOIN_STYLE_NV 0x9079 -#define GL_PATH_MITER_LIMIT_NV 0x907A -#define GL_PATH_DASH_CAPS_NV 0x907B -#define GL_PATH_INITIAL_DASH_CAP_NV 0x907C -#define GL_PATH_TERMINAL_DASH_CAP_NV 0x907D -#define GL_PATH_DASH_OFFSET_NV 0x907E -#define GL_PATH_CLIENT_LENGTH_NV 0x907F -#define GL_PATH_FILL_MODE_NV 0x9080 -#define GL_PATH_FILL_MASK_NV 0x9081 -#define GL_PATH_FILL_COVER_MODE_NV 0x9082 -#define GL_PATH_STROKE_COVER_MODE_NV 0x9083 -#define GL_PATH_STROKE_MASK_NV 0x9084 -#define GL_PATH_STROKE_BOUND_NV 0x9086 -#define GL_COUNT_UP_NV 0x9088 -#define GL_COUNT_DOWN_NV 0x9089 -#define GL_PATH_OBJECT_BOUNDING_BOX_NV 0x908A -#define GL_CONVEX_HULL_NV 0x908B -#define GL_BOUNDING_BOX_NV 0x908D -#define GL_TRANSLATE_X_NV 0x908E -#define GL_TRANSLATE_Y_NV 0x908F -#define GL_TRANSLATE_2D_NV 0x9090 -#define GL_TRANSLATE_3D_NV 0x9091 -#define GL_AFFINE_2D_NV 0x9092 -#define GL_AFFINE_3D_NV 0x9094 -#define GL_TRANSPOSE_AFFINE_2D_NV 0x9096 -#define GL_TRANSPOSE_AFFINE_3D_NV 0x9098 -#define GL_UTF8_NV 0x909A -#define GL_UTF16_NV 0x909B -#define GL_BOUNDING_BOX_OF_BOUNDING_BOXES_NV 0x909C -#define GL_PATH_COMMAND_COUNT_NV 0x909D -#define GL_PATH_COORD_COUNT_NV 0x909E -#define GL_PATH_DASH_ARRAY_COUNT_NV 0x909F -#define GL_PATH_COMPUTED_LENGTH_NV 0x90A0 -#define GL_PATH_FILL_BOUNDING_BOX_NV 0x90A1 -#define GL_PATH_STROKE_BOUNDING_BOX_NV 0x90A2 -#define GL_SQUARE_NV 0x90A3 -#define GL_ROUND_NV 0x90A4 -#define GL_TRIANGULAR_NV 0x90A5 -#define GL_BEVEL_NV 0x90A6 -#define GL_MITER_REVERT_NV 0x90A7 -#define GL_MITER_TRUNCATE_NV 0x90A8 -#define GL_SKIP_MISSING_GLYPH_NV 0x90A9 -#define GL_USE_MISSING_GLYPH_NV 0x90AA -#define GL_PATH_ERROR_POSITION_NV 0x90AB -#define GL_PATH_FOG_GEN_MODE_NV 0x90AC -#define GL_ACCUM_ADJACENT_PAIRS_NV 0x90AD -#define GL_ADJACENT_PAIRS_NV 0x90AE -#define GL_FIRST_TO_REST_NV 0x90AF -#define GL_PATH_GEN_MODE_NV 0x90B0 -#define GL_PATH_GEN_COEFF_NV 0x90B1 -#define GL_PATH_GEN_COLOR_FORMAT_NV 0x90B2 -#define GL_PATH_GEN_COMPONENTS_NV 0x90B3 -#define GL_PATH_DASH_OFFSET_RESET_NV 0x90B4 -#define GL_MOVE_TO_RESETS_NV 0x90B5 -#define GL_MOVE_TO_CONTINUES_NV 0x90B6 -#define GL_PATH_STENCIL_FUNC_NV 0x90B7 -#define GL_PATH_STENCIL_REF_NV 0x90B8 -#define GL_PATH_STENCIL_VALUE_MASK_NV 0x90B9 -#define GL_PATH_STENCIL_DEPTH_OFFSET_FACTOR_NV 0x90BD -#define GL_PATH_STENCIL_DEPTH_OFFSET_UNITS_NV 0x90BE -#define GL_PATH_COVER_DEPTH_FUNC_NV 0x90BF -#define GL_FONT_GLYPHS_AVAILABLE_NV 0x9368 -#define GL_FONT_TARGET_UNAVAILABLE_NV 0x9369 -#define GL_FONT_UNAVAILABLE_NV 0x936A -#define GL_FONT_UNINTELLIGIBLE_NV 0x936B -#define GL_STANDARD_FONT_FORMAT_NV 0x936C -#define GL_FRAGMENT_INPUT_NV 0x936D -#define GL_FONT_X_MIN_BOUNDS_BIT_NV 0x00010000 -#define GL_FONT_Y_MIN_BOUNDS_BIT_NV 0x00020000 -#define GL_FONT_X_MAX_BOUNDS_BIT_NV 0x00040000 -#define GL_FONT_Y_MAX_BOUNDS_BIT_NV 0x00080000 -#define GL_FONT_UNITS_PER_EM_BIT_NV 0x00100000 -#define GL_FONT_ASCENDER_BIT_NV 0x00200000 -#define GL_FONT_DESCENDER_BIT_NV 0x00400000 -#define GL_FONT_HEIGHT_BIT_NV 0x00800000 -#define GL_FONT_MAX_ADVANCE_WIDTH_BIT_NV 0x01000000 -#define GL_FONT_MAX_ADVANCE_HEIGHT_BIT_NV 0x02000000 -#define GL_FONT_UNDERLINE_POSITION_BIT_NV 0x04000000 -#define GL_FONT_UNDERLINE_THICKNESS_BIT_NV 0x08000000 -#define GL_FONT_HAS_KERNING_BIT_NV 0x10000000 -#define GL_FONT_NUM_GLYPH_INDICES_BIT_NV 0x20000000 - -typedef void (GLAPIENTRY * PFNGLCOPYPATHNVPROC) (GLuint resultPath, GLuint srcPath); -typedef void (GLAPIENTRY * PFNGLCOVERFILLPATHINSTANCEDNVPROC) (GLsizei numPaths, GLenum pathNameType, const void *paths, GLuint pathBase, GLenum coverMode, GLenum transformType, const GLfloat *transformValues); -typedef void (GLAPIENTRY * PFNGLCOVERFILLPATHNVPROC) (GLuint path, GLenum coverMode); -typedef void (GLAPIENTRY * PFNGLCOVERSTROKEPATHINSTANCEDNVPROC) (GLsizei numPaths, GLenum pathNameType, const void *paths, GLuint pathBase, GLenum coverMode, GLenum transformType, const GLfloat *transformValues); -typedef void (GLAPIENTRY * PFNGLCOVERSTROKEPATHNVPROC) (GLuint path, GLenum coverMode); -typedef void (GLAPIENTRY * PFNGLDELETEPATHSNVPROC) (GLuint path, GLsizei range); -typedef GLuint (GLAPIENTRY * PFNGLGENPATHSNVPROC) (GLsizei range); -typedef void (GLAPIENTRY * PFNGLGETPATHCOLORGENFVNVPROC) (GLenum color, GLenum pname, GLfloat* value); -typedef void (GLAPIENTRY * PFNGLGETPATHCOLORGENIVNVPROC) (GLenum color, GLenum pname, GLint* value); -typedef void (GLAPIENTRY * PFNGLGETPATHCOMMANDSNVPROC) (GLuint path, GLubyte* commands); -typedef void (GLAPIENTRY * PFNGLGETPATHCOORDSNVPROC) (GLuint path, GLfloat* coords); -typedef void (GLAPIENTRY * PFNGLGETPATHDASHARRAYNVPROC) (GLuint path, GLfloat* dashArray); -typedef GLfloat (GLAPIENTRY * PFNGLGETPATHLENGTHNVPROC) (GLuint path, GLsizei startSegment, GLsizei numSegments); -typedef void (GLAPIENTRY * PFNGLGETPATHMETRICRANGENVPROC) (GLbitfield metricQueryMask, GLuint firstPathName, GLsizei numPaths, GLsizei stride, GLfloat* metrics); -typedef void (GLAPIENTRY * PFNGLGETPATHMETRICSNVPROC) (GLbitfield metricQueryMask, GLsizei numPaths, GLenum pathNameType, const void *paths, GLuint pathBase, GLsizei stride, GLfloat *metrics); -typedef void (GLAPIENTRY * PFNGLGETPATHPARAMETERFVNVPROC) (GLuint path, GLenum pname, GLfloat* value); -typedef void (GLAPIENTRY * PFNGLGETPATHPARAMETERIVNVPROC) (GLuint path, GLenum pname, GLint* value); -typedef void (GLAPIENTRY * PFNGLGETPATHSPACINGNVPROC) (GLenum pathListMode, GLsizei numPaths, GLenum pathNameType, const void *paths, GLuint pathBase, GLfloat advanceScale, GLfloat kerningScale, GLenum transformType, GLfloat *returnedSpacing); -typedef void (GLAPIENTRY * PFNGLGETPATHTEXGENFVNVPROC) (GLenum texCoordSet, GLenum pname, GLfloat* value); -typedef void (GLAPIENTRY * PFNGLGETPATHTEXGENIVNVPROC) (GLenum texCoordSet, GLenum pname, GLint* value); -typedef void (GLAPIENTRY * PFNGLGETPROGRAMRESOURCEFVNVPROC) (GLuint program, GLenum programInterface, GLuint index, GLsizei propCount, const GLenum* props, GLsizei bufSize, GLsizei *length, GLfloat *params); -typedef void (GLAPIENTRY * PFNGLINTERPOLATEPATHSNVPROC) (GLuint resultPath, GLuint pathA, GLuint pathB, GLfloat weight); -typedef GLboolean (GLAPIENTRY * PFNGLISPATHNVPROC) (GLuint path); -typedef GLboolean (GLAPIENTRY * PFNGLISPOINTINFILLPATHNVPROC) (GLuint path, GLuint mask, GLfloat x, GLfloat y); -typedef GLboolean (GLAPIENTRY * PFNGLISPOINTINSTROKEPATHNVPROC) (GLuint path, GLfloat x, GLfloat y); -typedef void (GLAPIENTRY * PFNGLMATRIXLOAD3X2FNVPROC) (GLenum matrixMode, const GLfloat* m); -typedef void (GLAPIENTRY * PFNGLMATRIXLOAD3X3FNVPROC) (GLenum matrixMode, const GLfloat* m); -typedef void (GLAPIENTRY * PFNGLMATRIXLOADTRANSPOSE3X3FNVPROC) (GLenum matrixMode, const GLfloat* m); -typedef void (GLAPIENTRY * PFNGLMATRIXMULT3X2FNVPROC) (GLenum matrixMode, const GLfloat* m); -typedef void (GLAPIENTRY * PFNGLMATRIXMULT3X3FNVPROC) (GLenum matrixMode, const GLfloat* m); -typedef void (GLAPIENTRY * PFNGLMATRIXMULTTRANSPOSE3X3FNVPROC) (GLenum matrixMode, const GLfloat* m); -typedef void (GLAPIENTRY * PFNGLPATHCOLORGENNVPROC) (GLenum color, GLenum genMode, GLenum colorFormat, const GLfloat* coeffs); -typedef void (GLAPIENTRY * PFNGLPATHCOMMANDSNVPROC) (GLuint path, GLsizei numCommands, const GLubyte* commands, GLsizei numCoords, GLenum coordType, const void*coords); -typedef void (GLAPIENTRY * PFNGLPATHCOORDSNVPROC) (GLuint path, GLsizei numCoords, GLenum coordType, const void *coords); -typedef void (GLAPIENTRY * PFNGLPATHCOVERDEPTHFUNCNVPROC) (GLenum zfunc); -typedef void (GLAPIENTRY * PFNGLPATHDASHARRAYNVPROC) (GLuint path, GLsizei dashCount, const GLfloat* dashArray); -typedef void (GLAPIENTRY * PFNGLPATHFOGGENNVPROC) (GLenum genMode); -typedef GLenum (GLAPIENTRY * PFNGLPATHGLYPHINDEXARRAYNVPROC) (GLuint firstPathName, GLenum fontTarget, const void *fontName, GLbitfield fontStyle, GLuint firstGlyphIndex, GLsizei numGlyphs, GLuint pathParameterTemplate, GLfloat emScale); -typedef GLenum (GLAPIENTRY * PFNGLPATHGLYPHINDEXRANGENVPROC) (GLenum fontTarget, const void *fontName, GLbitfield fontStyle, GLuint pathParameterTemplate, GLfloat emScale, GLuint baseAndCount[2]); -typedef void (GLAPIENTRY * PFNGLPATHGLYPHRANGENVPROC) (GLuint firstPathName, GLenum fontTarget, const void *fontName, GLbitfield fontStyle, GLuint firstGlyph, GLsizei numGlyphs, GLenum handleMissingGlyphs, GLuint pathParameterTemplate, GLfloat emScale); -typedef void (GLAPIENTRY * PFNGLPATHGLYPHSNVPROC) (GLuint firstPathName, GLenum fontTarget, const void *fontName, GLbitfield fontStyle, GLsizei numGlyphs, GLenum type, const void*charcodes, GLenum handleMissingGlyphs, GLuint pathParameterTemplate, GLfloat emScale); -typedef GLenum (GLAPIENTRY * PFNGLPATHMEMORYGLYPHINDEXARRAYNVPROC) (GLuint firstPathName, GLenum fontTarget, GLsizeiptr fontSize, const void *fontData, GLsizei faceIndex, GLuint firstGlyphIndex, GLsizei numGlyphs, GLuint pathParameterTemplate, GLfloat emScale); -typedef void (GLAPIENTRY * PFNGLPATHPARAMETERFNVPROC) (GLuint path, GLenum pname, GLfloat value); -typedef void (GLAPIENTRY * PFNGLPATHPARAMETERFVNVPROC) (GLuint path, GLenum pname, const GLfloat* value); -typedef void (GLAPIENTRY * PFNGLPATHPARAMETERINVPROC) (GLuint path, GLenum pname, GLint value); -typedef void (GLAPIENTRY * PFNGLPATHPARAMETERIVNVPROC) (GLuint path, GLenum pname, const GLint* value); -typedef void (GLAPIENTRY * PFNGLPATHSTENCILDEPTHOFFSETNVPROC) (GLfloat factor, GLfloat units); -typedef void (GLAPIENTRY * PFNGLPATHSTENCILFUNCNVPROC) (GLenum func, GLint ref, GLuint mask); -typedef void (GLAPIENTRY * PFNGLPATHSTRINGNVPROC) (GLuint path, GLenum format, GLsizei length, const void *pathString); -typedef void (GLAPIENTRY * PFNGLPATHSUBCOMMANDSNVPROC) (GLuint path, GLsizei commandStart, GLsizei commandsToDelete, GLsizei numCommands, const GLubyte* commands, GLsizei numCoords, GLenum coordType, const void*coords); -typedef void (GLAPIENTRY * PFNGLPATHSUBCOORDSNVPROC) (GLuint path, GLsizei coordStart, GLsizei numCoords, GLenum coordType, const void *coords); -typedef void (GLAPIENTRY * PFNGLPATHTEXGENNVPROC) (GLenum texCoordSet, GLenum genMode, GLint components, const GLfloat* coeffs); -typedef GLboolean (GLAPIENTRY * PFNGLPOINTALONGPATHNVPROC) (GLuint path, GLsizei startSegment, GLsizei numSegments, GLfloat distance, GLfloat* x, GLfloat *y, GLfloat *tangentX, GLfloat *tangentY); -typedef void (GLAPIENTRY * PFNGLPROGRAMPATHFRAGMENTINPUTGENNVPROC) (GLuint program, GLint location, GLenum genMode, GLint components, const GLfloat* coeffs); -typedef void (GLAPIENTRY * PFNGLSTENCILFILLPATHINSTANCEDNVPROC) (GLsizei numPaths, GLenum pathNameType, const void *paths, GLuint pathBase, GLenum fillMode, GLuint mask, GLenum transformType, const GLfloat *transformValues); -typedef void (GLAPIENTRY * PFNGLSTENCILFILLPATHNVPROC) (GLuint path, GLenum fillMode, GLuint mask); -typedef void (GLAPIENTRY * PFNGLSTENCILSTROKEPATHINSTANCEDNVPROC) (GLsizei numPaths, GLenum pathNameType, const void *paths, GLuint pathBase, GLint reference, GLuint mask, GLenum transformType, const GLfloat *transformValues); -typedef void (GLAPIENTRY * PFNGLSTENCILSTROKEPATHNVPROC) (GLuint path, GLint reference, GLuint mask); -typedef void (GLAPIENTRY * PFNGLSTENCILTHENCOVERFILLPATHINSTANCEDNVPROC) (GLsizei numPaths, GLenum pathNameType, const void *paths, GLuint pathBase, GLenum fillMode, GLuint mask, GLenum coverMode, GLenum transformType, const GLfloat *transformValues); -typedef void (GLAPIENTRY * PFNGLSTENCILTHENCOVERFILLPATHNVPROC) (GLuint path, GLenum fillMode, GLuint mask, GLenum coverMode); -typedef void (GLAPIENTRY * PFNGLSTENCILTHENCOVERSTROKEPATHINSTANCEDNVPROC) (GLsizei numPaths, GLenum pathNameType, const void *paths, GLuint pathBase, GLint reference, GLuint mask, GLenum coverMode, GLenum transformType, const GLfloat *transformValues); -typedef void (GLAPIENTRY * PFNGLSTENCILTHENCOVERSTROKEPATHNVPROC) (GLuint path, GLint reference, GLuint mask, GLenum coverMode); -typedef void (GLAPIENTRY * PFNGLTRANSFORMPATHNVPROC) (GLuint resultPath, GLuint srcPath, GLenum transformType, const GLfloat* transformValues); -typedef void (GLAPIENTRY * PFNGLWEIGHTPATHSNVPROC) (GLuint resultPath, GLsizei numPaths, const GLuint paths[], const GLfloat weights[]); - -#define glCopyPathNV GLEW_GET_FUN(__glewCopyPathNV) -#define glCoverFillPathInstancedNV GLEW_GET_FUN(__glewCoverFillPathInstancedNV) -#define glCoverFillPathNV GLEW_GET_FUN(__glewCoverFillPathNV) -#define glCoverStrokePathInstancedNV GLEW_GET_FUN(__glewCoverStrokePathInstancedNV) -#define glCoverStrokePathNV GLEW_GET_FUN(__glewCoverStrokePathNV) -#define glDeletePathsNV GLEW_GET_FUN(__glewDeletePathsNV) -#define glGenPathsNV GLEW_GET_FUN(__glewGenPathsNV) -#define glGetPathColorGenfvNV GLEW_GET_FUN(__glewGetPathColorGenfvNV) -#define glGetPathColorGenivNV GLEW_GET_FUN(__glewGetPathColorGenivNV) -#define glGetPathCommandsNV GLEW_GET_FUN(__glewGetPathCommandsNV) -#define glGetPathCoordsNV GLEW_GET_FUN(__glewGetPathCoordsNV) -#define glGetPathDashArrayNV GLEW_GET_FUN(__glewGetPathDashArrayNV) -#define glGetPathLengthNV GLEW_GET_FUN(__glewGetPathLengthNV) -#define glGetPathMetricRangeNV GLEW_GET_FUN(__glewGetPathMetricRangeNV) -#define glGetPathMetricsNV GLEW_GET_FUN(__glewGetPathMetricsNV) -#define glGetPathParameterfvNV GLEW_GET_FUN(__glewGetPathParameterfvNV) -#define glGetPathParameterivNV GLEW_GET_FUN(__glewGetPathParameterivNV) -#define glGetPathSpacingNV GLEW_GET_FUN(__glewGetPathSpacingNV) -#define glGetPathTexGenfvNV GLEW_GET_FUN(__glewGetPathTexGenfvNV) -#define glGetPathTexGenivNV GLEW_GET_FUN(__glewGetPathTexGenivNV) -#define glGetProgramResourcefvNV GLEW_GET_FUN(__glewGetProgramResourcefvNV) -#define glInterpolatePathsNV GLEW_GET_FUN(__glewInterpolatePathsNV) -#define glIsPathNV GLEW_GET_FUN(__glewIsPathNV) -#define glIsPointInFillPathNV GLEW_GET_FUN(__glewIsPointInFillPathNV) -#define glIsPointInStrokePathNV GLEW_GET_FUN(__glewIsPointInStrokePathNV) -#define glMatrixLoad3x2fNV GLEW_GET_FUN(__glewMatrixLoad3x2fNV) -#define glMatrixLoad3x3fNV GLEW_GET_FUN(__glewMatrixLoad3x3fNV) -#define glMatrixLoadTranspose3x3fNV GLEW_GET_FUN(__glewMatrixLoadTranspose3x3fNV) -#define glMatrixMult3x2fNV GLEW_GET_FUN(__glewMatrixMult3x2fNV) -#define glMatrixMult3x3fNV GLEW_GET_FUN(__glewMatrixMult3x3fNV) -#define glMatrixMultTranspose3x3fNV GLEW_GET_FUN(__glewMatrixMultTranspose3x3fNV) -#define glPathColorGenNV GLEW_GET_FUN(__glewPathColorGenNV) -#define glPathCommandsNV GLEW_GET_FUN(__glewPathCommandsNV) -#define glPathCoordsNV GLEW_GET_FUN(__glewPathCoordsNV) -#define glPathCoverDepthFuncNV GLEW_GET_FUN(__glewPathCoverDepthFuncNV) -#define glPathDashArrayNV GLEW_GET_FUN(__glewPathDashArrayNV) -#define glPathFogGenNV GLEW_GET_FUN(__glewPathFogGenNV) -#define glPathGlyphIndexArrayNV GLEW_GET_FUN(__glewPathGlyphIndexArrayNV) -#define glPathGlyphIndexRangeNV GLEW_GET_FUN(__glewPathGlyphIndexRangeNV) -#define glPathGlyphRangeNV GLEW_GET_FUN(__glewPathGlyphRangeNV) -#define glPathGlyphsNV GLEW_GET_FUN(__glewPathGlyphsNV) -#define glPathMemoryGlyphIndexArrayNV GLEW_GET_FUN(__glewPathMemoryGlyphIndexArrayNV) -#define glPathParameterfNV GLEW_GET_FUN(__glewPathParameterfNV) -#define glPathParameterfvNV GLEW_GET_FUN(__glewPathParameterfvNV) -#define glPathParameteriNV GLEW_GET_FUN(__glewPathParameteriNV) -#define glPathParameterivNV GLEW_GET_FUN(__glewPathParameterivNV) -#define glPathStencilDepthOffsetNV GLEW_GET_FUN(__glewPathStencilDepthOffsetNV) -#define glPathStencilFuncNV GLEW_GET_FUN(__glewPathStencilFuncNV) -#define glPathStringNV GLEW_GET_FUN(__glewPathStringNV) -#define glPathSubCommandsNV GLEW_GET_FUN(__glewPathSubCommandsNV) -#define glPathSubCoordsNV GLEW_GET_FUN(__glewPathSubCoordsNV) -#define glPathTexGenNV GLEW_GET_FUN(__glewPathTexGenNV) -#define glPointAlongPathNV GLEW_GET_FUN(__glewPointAlongPathNV) -#define glProgramPathFragmentInputGenNV GLEW_GET_FUN(__glewProgramPathFragmentInputGenNV) -#define glStencilFillPathInstancedNV GLEW_GET_FUN(__glewStencilFillPathInstancedNV) -#define glStencilFillPathNV GLEW_GET_FUN(__glewStencilFillPathNV) -#define glStencilStrokePathInstancedNV GLEW_GET_FUN(__glewStencilStrokePathInstancedNV) -#define glStencilStrokePathNV GLEW_GET_FUN(__glewStencilStrokePathNV) -#define glStencilThenCoverFillPathInstancedNV GLEW_GET_FUN(__glewStencilThenCoverFillPathInstancedNV) -#define glStencilThenCoverFillPathNV GLEW_GET_FUN(__glewStencilThenCoverFillPathNV) -#define glStencilThenCoverStrokePathInstancedNV GLEW_GET_FUN(__glewStencilThenCoverStrokePathInstancedNV) -#define glStencilThenCoverStrokePathNV GLEW_GET_FUN(__glewStencilThenCoverStrokePathNV) -#define glTransformPathNV GLEW_GET_FUN(__glewTransformPathNV) -#define glWeightPathsNV GLEW_GET_FUN(__glewWeightPathsNV) - -#define GLEW_NV_path_rendering GLEW_GET_VAR(__GLEW_NV_path_rendering) - -#endif /* GL_NV_path_rendering */ - -/* -------------------- GL_NV_path_rendering_shared_edge ------------------- */ - -#ifndef GL_NV_path_rendering_shared_edge -#define GL_NV_path_rendering_shared_edge 1 - -#define GL_SHARED_EDGE_NV 0xC0 - -#define GLEW_NV_path_rendering_shared_edge GLEW_GET_VAR(__GLEW_NV_path_rendering_shared_edge) - -#endif /* GL_NV_path_rendering_shared_edge */ - -/* ------------------------- GL_NV_pixel_data_range ------------------------ */ - -#ifndef GL_NV_pixel_data_range -#define GL_NV_pixel_data_range 1 - -#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 - -typedef void (GLAPIENTRY * PFNGLFLUSHPIXELDATARANGENVPROC) (GLenum target); -typedef void (GLAPIENTRY * PFNGLPIXELDATARANGENVPROC) (GLenum target, GLsizei length, void *pointer); - -#define glFlushPixelDataRangeNV GLEW_GET_FUN(__glewFlushPixelDataRangeNV) -#define glPixelDataRangeNV GLEW_GET_FUN(__glewPixelDataRangeNV) - -#define GLEW_NV_pixel_data_range GLEW_GET_VAR(__GLEW_NV_pixel_data_range) - -#endif /* GL_NV_pixel_data_range */ - -/* --------------------------- GL_NV_point_sprite -------------------------- */ - -#ifndef GL_NV_point_sprite -#define GL_NV_point_sprite 1 - -#define GL_POINT_SPRITE_NV 0x8861 -#define GL_COORD_REPLACE_NV 0x8862 -#define GL_POINT_SPRITE_R_MODE_NV 0x8863 - -typedef void (GLAPIENTRY * PFNGLPOINTPARAMETERINVPROC) (GLenum pname, GLint param); -typedef void (GLAPIENTRY * PFNGLPOINTPARAMETERIVNVPROC) (GLenum pname, const GLint* params); - -#define glPointParameteriNV GLEW_GET_FUN(__glewPointParameteriNV) -#define glPointParameterivNV GLEW_GET_FUN(__glewPointParameterivNV) - -#define GLEW_NV_point_sprite GLEW_GET_VAR(__GLEW_NV_point_sprite) - -#endif /* GL_NV_point_sprite */ - -/* -------------------------- GL_NV_present_video -------------------------- */ - -#ifndef GL_NV_present_video -#define GL_NV_present_video 1 - -#define GL_FRAME_NV 0x8E26 -#define GL_FIELDS_NV 0x8E27 -#define GL_CURRENT_TIME_NV 0x8E28 -#define GL_NUM_FILL_STREAMS_NV 0x8E29 -#define GL_PRESENT_TIME_NV 0x8E2A -#define GL_PRESENT_DURATION_NV 0x8E2B - -typedef void (GLAPIENTRY * PFNGLGETVIDEOI64VNVPROC) (GLuint video_slot, GLenum pname, GLint64EXT* params); -typedef void (GLAPIENTRY * PFNGLGETVIDEOIVNVPROC) (GLuint video_slot, GLenum pname, GLint* params); -typedef void (GLAPIENTRY * PFNGLGETVIDEOUI64VNVPROC) (GLuint video_slot, GLenum pname, GLuint64EXT* params); -typedef void (GLAPIENTRY * PFNGLGETVIDEOUIVNVPROC) (GLuint video_slot, GLenum pname, GLuint* params); -typedef void (GLAPIENTRY * PFNGLPRESENTFRAMEDUALFILLNVPROC) (GLuint video_slot, GLuint64EXT minPresentTime, GLuint beginPresentTimeId, GLuint presentDurationId, GLenum type, GLenum target0, GLuint fill0, GLenum target1, GLuint fill1, GLenum target2, GLuint fill2, GLenum target3, GLuint fill3); -typedef void (GLAPIENTRY * PFNGLPRESENTFRAMEKEYEDNVPROC) (GLuint video_slot, GLuint64EXT minPresentTime, GLuint beginPresentTimeId, GLuint presentDurationId, GLenum type, GLenum target0, GLuint fill0, GLuint key0, GLenum target1, GLuint fill1, GLuint key1); - -#define glGetVideoi64vNV GLEW_GET_FUN(__glewGetVideoi64vNV) -#define glGetVideoivNV GLEW_GET_FUN(__glewGetVideoivNV) -#define glGetVideoui64vNV GLEW_GET_FUN(__glewGetVideoui64vNV) -#define glGetVideouivNV GLEW_GET_FUN(__glewGetVideouivNV) -#define glPresentFrameDualFillNV GLEW_GET_FUN(__glewPresentFrameDualFillNV) -#define glPresentFrameKeyedNV GLEW_GET_FUN(__glewPresentFrameKeyedNV) - -#define GLEW_NV_present_video GLEW_GET_VAR(__GLEW_NV_present_video) - -#endif /* GL_NV_present_video */ - -/* ------------------------ GL_NV_primitive_restart ------------------------ */ - -#ifndef GL_NV_primitive_restart -#define GL_NV_primitive_restart 1 - -#define GL_PRIMITIVE_RESTART_NV 0x8558 -#define GL_PRIMITIVE_RESTART_INDEX_NV 0x8559 - -typedef void (GLAPIENTRY * PFNGLPRIMITIVERESTARTINDEXNVPROC) (GLuint index); -typedef void (GLAPIENTRY * PFNGLPRIMITIVERESTARTNVPROC) (void); - -#define glPrimitiveRestartIndexNV GLEW_GET_FUN(__glewPrimitiveRestartIndexNV) -#define glPrimitiveRestartNV GLEW_GET_FUN(__glewPrimitiveRestartNV) - -#define GLEW_NV_primitive_restart GLEW_GET_VAR(__GLEW_NV_primitive_restart) - -#endif /* GL_NV_primitive_restart */ - -/* ------------------------ GL_NV_register_combiners ----------------------- */ - -#ifndef GL_NV_register_combiners -#define GL_NV_register_combiners 1 - -#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 - -typedef void (GLAPIENTRY * PFNGLCOMBINERINPUTNVPROC) (GLenum stage, GLenum portion, GLenum variable, GLenum input, GLenum mapping, GLenum componentUsage); -typedef void (GLAPIENTRY * PFNGLCOMBINEROUTPUTNVPROC) (GLenum stage, GLenum portion, GLenum abOutput, GLenum cdOutput, GLenum sumOutput, GLenum scale, GLenum bias, GLboolean abDotProduct, GLboolean cdDotProduct, GLboolean muxSum); -typedef void (GLAPIENTRY * PFNGLCOMBINERPARAMETERFNVPROC) (GLenum pname, GLfloat param); -typedef void (GLAPIENTRY * PFNGLCOMBINERPARAMETERFVNVPROC) (GLenum pname, const GLfloat* params); -typedef void (GLAPIENTRY * PFNGLCOMBINERPARAMETERINVPROC) (GLenum pname, GLint param); -typedef void (GLAPIENTRY * PFNGLCOMBINERPARAMETERIVNVPROC) (GLenum pname, const GLint* params); -typedef void (GLAPIENTRY * PFNGLFINALCOMBINERINPUTNVPROC) (GLenum variable, GLenum input, GLenum mapping, GLenum componentUsage); -typedef void (GLAPIENTRY * PFNGLGETCOMBINERINPUTPARAMETERFVNVPROC) (GLenum stage, GLenum portion, GLenum variable, GLenum pname, GLfloat* params); -typedef void (GLAPIENTRY * PFNGLGETCOMBINERINPUTPARAMETERIVNVPROC) (GLenum stage, GLenum portion, GLenum variable, GLenum pname, GLint* params); -typedef void (GLAPIENTRY * PFNGLGETCOMBINEROUTPUTPARAMETERFVNVPROC) (GLenum stage, GLenum portion, GLenum pname, GLfloat* params); -typedef void (GLAPIENTRY * PFNGLGETCOMBINEROUTPUTPARAMETERIVNVPROC) (GLenum stage, GLenum portion, GLenum pname, GLint* params); -typedef void (GLAPIENTRY * PFNGLGETFINALCOMBINERINPUTPARAMETERFVNVPROC) (GLenum variable, GLenum pname, GLfloat* params); -typedef void (GLAPIENTRY * PFNGLGETFINALCOMBINERINPUTPARAMETERIVNVPROC) (GLenum variable, GLenum pname, GLint* params); - -#define glCombinerInputNV GLEW_GET_FUN(__glewCombinerInputNV) -#define glCombinerOutputNV GLEW_GET_FUN(__glewCombinerOutputNV) -#define glCombinerParameterfNV GLEW_GET_FUN(__glewCombinerParameterfNV) -#define glCombinerParameterfvNV GLEW_GET_FUN(__glewCombinerParameterfvNV) -#define glCombinerParameteriNV GLEW_GET_FUN(__glewCombinerParameteriNV) -#define glCombinerParameterivNV GLEW_GET_FUN(__glewCombinerParameterivNV) -#define glFinalCombinerInputNV GLEW_GET_FUN(__glewFinalCombinerInputNV) -#define glGetCombinerInputParameterfvNV GLEW_GET_FUN(__glewGetCombinerInputParameterfvNV) -#define glGetCombinerInputParameterivNV GLEW_GET_FUN(__glewGetCombinerInputParameterivNV) -#define glGetCombinerOutputParameterfvNV GLEW_GET_FUN(__glewGetCombinerOutputParameterfvNV) -#define glGetCombinerOutputParameterivNV GLEW_GET_FUN(__glewGetCombinerOutputParameterivNV) -#define glGetFinalCombinerInputParameterfvNV GLEW_GET_FUN(__glewGetFinalCombinerInputParameterfvNV) -#define glGetFinalCombinerInputParameterivNV GLEW_GET_FUN(__glewGetFinalCombinerInputParameterivNV) - -#define GLEW_NV_register_combiners GLEW_GET_VAR(__GLEW_NV_register_combiners) - -#endif /* GL_NV_register_combiners */ - -/* ----------------------- GL_NV_register_combiners2 ----------------------- */ - -#ifndef GL_NV_register_combiners2 -#define GL_NV_register_combiners2 1 - -#define GL_PER_STAGE_CONSTANTS_NV 0x8535 - -typedef void (GLAPIENTRY * PFNGLCOMBINERSTAGEPARAMETERFVNVPROC) (GLenum stage, GLenum pname, const GLfloat* params); -typedef void (GLAPIENTRY * PFNGLGETCOMBINERSTAGEPARAMETERFVNVPROC) (GLenum stage, GLenum pname, GLfloat* params); - -#define glCombinerStageParameterfvNV GLEW_GET_FUN(__glewCombinerStageParameterfvNV) -#define glGetCombinerStageParameterfvNV GLEW_GET_FUN(__glewGetCombinerStageParameterfvNV) - -#define GLEW_NV_register_combiners2 GLEW_GET_VAR(__GLEW_NV_register_combiners2) - -#endif /* GL_NV_register_combiners2 */ - -/* ------------------ GL_NV_robustness_video_memory_purge ------------------ */ - -#ifndef GL_NV_robustness_video_memory_purge -#define GL_NV_robustness_video_memory_purge 1 - -#define GL_EGL_GENERATE_RESET_ON_VIDEO_MEMORY_PURGE_NV 0x334C -#define GL_PURGED_CONTEXT_RESET_NV 0x92BB - -#define GLEW_NV_robustness_video_memory_purge GLEW_GET_VAR(__GLEW_NV_robustness_video_memory_purge) - -#endif /* GL_NV_robustness_video_memory_purge */ - -/* ------------------------- GL_NV_sample_locations ------------------------ */ - -#ifndef GL_NV_sample_locations -#define GL_NV_sample_locations 1 - -#define GL_SAMPLE_LOCATION_NV 0x8E50 -#define GL_SAMPLE_LOCATION_SUBPIXEL_BITS_NV 0x933D -#define GL_SAMPLE_LOCATION_PIXEL_GRID_WIDTH_NV 0x933E -#define GL_SAMPLE_LOCATION_PIXEL_GRID_HEIGHT_NV 0x933F -#define GL_PROGRAMMABLE_SAMPLE_LOCATION_TABLE_SIZE_NV 0x9340 -#define GL_PROGRAMMABLE_SAMPLE_LOCATION_NV 0x9341 -#define GL_FRAMEBUFFER_PROGRAMMABLE_SAMPLE_LOCATIONS_NV 0x9342 -#define GL_FRAMEBUFFER_SAMPLE_LOCATION_PIXEL_GRID_NV 0x9343 - -typedef void (GLAPIENTRY * PFNGLFRAMEBUFFERSAMPLELOCATIONSFVNVPROC) (GLenum target, GLuint start, GLsizei count, const GLfloat* v); -typedef void (GLAPIENTRY * PFNGLNAMEDFRAMEBUFFERSAMPLELOCATIONSFVNVPROC) (GLuint framebuffer, GLuint start, GLsizei count, const GLfloat* v); - -#define glFramebufferSampleLocationsfvNV GLEW_GET_FUN(__glewFramebufferSampleLocationsfvNV) -#define glNamedFramebufferSampleLocationsfvNV GLEW_GET_FUN(__glewNamedFramebufferSampleLocationsfvNV) - -#define GLEW_NV_sample_locations GLEW_GET_VAR(__GLEW_NV_sample_locations) - -#endif /* GL_NV_sample_locations */ - -/* ------------------ GL_NV_sample_mask_override_coverage ------------------ */ - -#ifndef GL_NV_sample_mask_override_coverage -#define GL_NV_sample_mask_override_coverage 1 - -#define GLEW_NV_sample_mask_override_coverage GLEW_GET_VAR(__GLEW_NV_sample_mask_override_coverage) - -#endif /* GL_NV_sample_mask_override_coverage */ - -/* ---------------------- GL_NV_shader_atomic_counters --------------------- */ - -#ifndef GL_NV_shader_atomic_counters -#define GL_NV_shader_atomic_counters 1 - -#define GLEW_NV_shader_atomic_counters GLEW_GET_VAR(__GLEW_NV_shader_atomic_counters) - -#endif /* GL_NV_shader_atomic_counters */ - -/* ----------------------- GL_NV_shader_atomic_float ----------------------- */ - -#ifndef GL_NV_shader_atomic_float -#define GL_NV_shader_atomic_float 1 - -#define GLEW_NV_shader_atomic_float GLEW_GET_VAR(__GLEW_NV_shader_atomic_float) - -#endif /* GL_NV_shader_atomic_float */ - -/* ---------------------- GL_NV_shader_atomic_float64 ---------------------- */ - -#ifndef GL_NV_shader_atomic_float64 -#define GL_NV_shader_atomic_float64 1 - -#define GLEW_NV_shader_atomic_float64 GLEW_GET_VAR(__GLEW_NV_shader_atomic_float64) - -#endif /* GL_NV_shader_atomic_float64 */ - -/* -------------------- GL_NV_shader_atomic_fp16_vector -------------------- */ - -#ifndef GL_NV_shader_atomic_fp16_vector -#define GL_NV_shader_atomic_fp16_vector 1 - -#define GLEW_NV_shader_atomic_fp16_vector GLEW_GET_VAR(__GLEW_NV_shader_atomic_fp16_vector) - -#endif /* GL_NV_shader_atomic_fp16_vector */ - -/* ----------------------- GL_NV_shader_atomic_int64 ----------------------- */ - -#ifndef GL_NV_shader_atomic_int64 -#define GL_NV_shader_atomic_int64 1 - -#define GLEW_NV_shader_atomic_int64 GLEW_GET_VAR(__GLEW_NV_shader_atomic_int64) - -#endif /* GL_NV_shader_atomic_int64 */ - -/* ------------------------ GL_NV_shader_buffer_load ----------------------- */ - -#ifndef GL_NV_shader_buffer_load -#define GL_NV_shader_buffer_load 1 - -#define GL_BUFFER_GPU_ADDRESS_NV 0x8F1D -#define GL_GPU_ADDRESS_NV 0x8F34 -#define GL_MAX_SHADER_BUFFER_ADDRESS_NV 0x8F35 - -typedef void (GLAPIENTRY * PFNGLGETBUFFERPARAMETERUI64VNVPROC) (GLenum target, GLenum pname, GLuint64EXT* params); -typedef void (GLAPIENTRY * PFNGLGETINTEGERUI64VNVPROC) (GLenum value, GLuint64EXT* result); -typedef void (GLAPIENTRY * PFNGLGETNAMEDBUFFERPARAMETERUI64VNVPROC) (GLuint buffer, GLenum pname, GLuint64EXT* params); -typedef GLboolean (GLAPIENTRY * PFNGLISBUFFERRESIDENTNVPROC) (GLenum target); -typedef GLboolean (GLAPIENTRY * PFNGLISNAMEDBUFFERRESIDENTNVPROC) (GLuint buffer); -typedef void (GLAPIENTRY * PFNGLMAKEBUFFERNONRESIDENTNVPROC) (GLenum target); -typedef void (GLAPIENTRY * PFNGLMAKEBUFFERRESIDENTNVPROC) (GLenum target, GLenum access); -typedef void (GLAPIENTRY * PFNGLMAKENAMEDBUFFERNONRESIDENTNVPROC) (GLuint buffer); -typedef void (GLAPIENTRY * PFNGLMAKENAMEDBUFFERRESIDENTNVPROC) (GLuint buffer, GLenum access); -typedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORMUI64NVPROC) (GLuint program, GLint location, GLuint64EXT value); -typedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORMUI64VNVPROC) (GLuint program, GLint location, GLsizei count, const GLuint64EXT* value); -typedef void (GLAPIENTRY * PFNGLUNIFORMUI64NVPROC) (GLint location, GLuint64EXT value); -typedef void (GLAPIENTRY * PFNGLUNIFORMUI64VNVPROC) (GLint location, GLsizei count, const GLuint64EXT* value); - -#define glGetBufferParameterui64vNV GLEW_GET_FUN(__glewGetBufferParameterui64vNV) -#define glGetIntegerui64vNV GLEW_GET_FUN(__glewGetIntegerui64vNV) -#define glGetNamedBufferParameterui64vNV GLEW_GET_FUN(__glewGetNamedBufferParameterui64vNV) -#define glIsBufferResidentNV GLEW_GET_FUN(__glewIsBufferResidentNV) -#define glIsNamedBufferResidentNV GLEW_GET_FUN(__glewIsNamedBufferResidentNV) -#define glMakeBufferNonResidentNV GLEW_GET_FUN(__glewMakeBufferNonResidentNV) -#define glMakeBufferResidentNV GLEW_GET_FUN(__glewMakeBufferResidentNV) -#define glMakeNamedBufferNonResidentNV GLEW_GET_FUN(__glewMakeNamedBufferNonResidentNV) -#define glMakeNamedBufferResidentNV GLEW_GET_FUN(__glewMakeNamedBufferResidentNV) -#define glProgramUniformui64NV GLEW_GET_FUN(__glewProgramUniformui64NV) -#define glProgramUniformui64vNV GLEW_GET_FUN(__glewProgramUniformui64vNV) -#define glUniformui64NV GLEW_GET_FUN(__glewUniformui64NV) -#define glUniformui64vNV GLEW_GET_FUN(__glewUniformui64vNV) - -#define GLEW_NV_shader_buffer_load GLEW_GET_VAR(__GLEW_NV_shader_buffer_load) - -#endif /* GL_NV_shader_buffer_load */ - -/* ------------------- GL_NV_shader_storage_buffer_object ------------------ */ - -#ifndef GL_NV_shader_storage_buffer_object -#define GL_NV_shader_storage_buffer_object 1 - -#define GLEW_NV_shader_storage_buffer_object GLEW_GET_VAR(__GLEW_NV_shader_storage_buffer_object) - -#endif /* GL_NV_shader_storage_buffer_object */ - -/* ----------------------- GL_NV_shader_thread_group ----------------------- */ - -#ifndef GL_NV_shader_thread_group -#define GL_NV_shader_thread_group 1 - -#define GL_WARP_SIZE_NV 0x9339 -#define GL_WARPS_PER_SM_NV 0x933A -#define GL_SM_COUNT_NV 0x933B - -#define GLEW_NV_shader_thread_group GLEW_GET_VAR(__GLEW_NV_shader_thread_group) - -#endif /* GL_NV_shader_thread_group */ - -/* ---------------------- GL_NV_shader_thread_shuffle ---------------------- */ - -#ifndef GL_NV_shader_thread_shuffle -#define GL_NV_shader_thread_shuffle 1 - -#define GLEW_NV_shader_thread_shuffle GLEW_GET_VAR(__GLEW_NV_shader_thread_shuffle) - -#endif /* GL_NV_shader_thread_shuffle */ - -/* ---------------------- GL_NV_stereo_view_rendering ---------------------- */ - -#ifndef GL_NV_stereo_view_rendering -#define GL_NV_stereo_view_rendering 1 - -#define GLEW_NV_stereo_view_rendering GLEW_GET_VAR(__GLEW_NV_stereo_view_rendering) - -#endif /* GL_NV_stereo_view_rendering */ - -/* ---------------------- GL_NV_tessellation_program5 ---------------------- */ - -#ifndef GL_NV_tessellation_program5 -#define GL_NV_tessellation_program5 1 - -#define GL_MAX_PROGRAM_PATCH_ATTRIBS_NV 0x86D8 -#define GL_TESS_CONTROL_PROGRAM_NV 0x891E -#define GL_TESS_EVALUATION_PROGRAM_NV 0x891F -#define GL_TESS_CONTROL_PROGRAM_PARAMETER_BUFFER_NV 0x8C74 -#define GL_TESS_EVALUATION_PROGRAM_PARAMETER_BUFFER_NV 0x8C75 - -#define GLEW_NV_tessellation_program5 GLEW_GET_VAR(__GLEW_NV_tessellation_program5) - -#endif /* GL_NV_tessellation_program5 */ - -/* -------------------------- GL_NV_texgen_emboss -------------------------- */ - -#ifndef GL_NV_texgen_emboss -#define GL_NV_texgen_emboss 1 - -#define GL_EMBOSS_LIGHT_NV 0x855D -#define GL_EMBOSS_CONSTANT_NV 0x855E -#define GL_EMBOSS_MAP_NV 0x855F - -#define GLEW_NV_texgen_emboss GLEW_GET_VAR(__GLEW_NV_texgen_emboss) - -#endif /* GL_NV_texgen_emboss */ - -/* ------------------------ GL_NV_texgen_reflection ------------------------ */ - -#ifndef GL_NV_texgen_reflection -#define GL_NV_texgen_reflection 1 - -#define GL_NORMAL_MAP_NV 0x8511 -#define GL_REFLECTION_MAP_NV 0x8512 - -#define GLEW_NV_texgen_reflection GLEW_GET_VAR(__GLEW_NV_texgen_reflection) - -#endif /* GL_NV_texgen_reflection */ - -/* ------------------------- GL_NV_texture_barrier ------------------------- */ - -#ifndef GL_NV_texture_barrier -#define GL_NV_texture_barrier 1 - -typedef void (GLAPIENTRY * PFNGLTEXTUREBARRIERNVPROC) (void); - -#define glTextureBarrierNV GLEW_GET_FUN(__glewTextureBarrierNV) - -#define GLEW_NV_texture_barrier GLEW_GET_VAR(__GLEW_NV_texture_barrier) - -#endif /* GL_NV_texture_barrier */ - -/* --------------------- GL_NV_texture_compression_vtc --------------------- */ - -#ifndef GL_NV_texture_compression_vtc -#define GL_NV_texture_compression_vtc 1 - -#define GLEW_NV_texture_compression_vtc GLEW_GET_VAR(__GLEW_NV_texture_compression_vtc) - -#endif /* GL_NV_texture_compression_vtc */ - -/* ----------------------- GL_NV_texture_env_combine4 ---------------------- */ - -#ifndef GL_NV_texture_env_combine4 -#define GL_NV_texture_env_combine4 1 - -#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 - -#define GLEW_NV_texture_env_combine4 GLEW_GET_VAR(__GLEW_NV_texture_env_combine4) - -#endif /* GL_NV_texture_env_combine4 */ - -/* ---------------------- GL_NV_texture_expand_normal ---------------------- */ - -#ifndef GL_NV_texture_expand_normal -#define GL_NV_texture_expand_normal 1 - -#define GL_TEXTURE_UNSIGNED_REMAP_MODE_NV 0x888F - -#define GLEW_NV_texture_expand_normal GLEW_GET_VAR(__GLEW_NV_texture_expand_normal) - -#endif /* GL_NV_texture_expand_normal */ - -/* ----------------------- GL_NV_texture_multisample ----------------------- */ - -#ifndef GL_NV_texture_multisample -#define GL_NV_texture_multisample 1 - -#define GL_TEXTURE_COVERAGE_SAMPLES_NV 0x9045 -#define GL_TEXTURE_COLOR_SAMPLES_NV 0x9046 - -typedef void (GLAPIENTRY * PFNGLTEXIMAGE2DMULTISAMPLECOVERAGENVPROC) (GLenum target, GLsizei coverageSamples, GLsizei colorSamples, GLint internalFormat, GLsizei width, GLsizei height, GLboolean fixedSampleLocations); -typedef void (GLAPIENTRY * PFNGLTEXIMAGE3DMULTISAMPLECOVERAGENVPROC) (GLenum target, GLsizei coverageSamples, GLsizei colorSamples, GLint internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedSampleLocations); -typedef void (GLAPIENTRY * PFNGLTEXTUREIMAGE2DMULTISAMPLECOVERAGENVPROC) (GLuint texture, GLenum target, GLsizei coverageSamples, GLsizei colorSamples, GLint internalFormat, GLsizei width, GLsizei height, GLboolean fixedSampleLocations); -typedef void (GLAPIENTRY * PFNGLTEXTUREIMAGE2DMULTISAMPLENVPROC) (GLuint texture, GLenum target, GLsizei samples, GLint internalFormat, GLsizei width, GLsizei height, GLboolean fixedSampleLocations); -typedef void (GLAPIENTRY * PFNGLTEXTUREIMAGE3DMULTISAMPLECOVERAGENVPROC) (GLuint texture, GLenum target, GLsizei coverageSamples, GLsizei colorSamples, GLint internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedSampleLocations); -typedef void (GLAPIENTRY * PFNGLTEXTUREIMAGE3DMULTISAMPLENVPROC) (GLuint texture, GLenum target, GLsizei samples, GLint internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedSampleLocations); - -#define glTexImage2DMultisampleCoverageNV GLEW_GET_FUN(__glewTexImage2DMultisampleCoverageNV) -#define glTexImage3DMultisampleCoverageNV GLEW_GET_FUN(__glewTexImage3DMultisampleCoverageNV) -#define glTextureImage2DMultisampleCoverageNV GLEW_GET_FUN(__glewTextureImage2DMultisampleCoverageNV) -#define glTextureImage2DMultisampleNV GLEW_GET_FUN(__glewTextureImage2DMultisampleNV) -#define glTextureImage3DMultisampleCoverageNV GLEW_GET_FUN(__glewTextureImage3DMultisampleCoverageNV) -#define glTextureImage3DMultisampleNV GLEW_GET_FUN(__glewTextureImage3DMultisampleNV) - -#define GLEW_NV_texture_multisample GLEW_GET_VAR(__GLEW_NV_texture_multisample) - -#endif /* GL_NV_texture_multisample */ - -/* ------------------------ GL_NV_texture_rectangle ------------------------ */ - -#ifndef GL_NV_texture_rectangle -#define GL_NV_texture_rectangle 1 - -#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 - -#define GLEW_NV_texture_rectangle GLEW_GET_VAR(__GLEW_NV_texture_rectangle) - -#endif /* GL_NV_texture_rectangle */ - -/* -------------------------- GL_NV_texture_shader ------------------------- */ - -#ifndef GL_NV_texture_shader -#define GL_NV_texture_shader 1 - -#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_2D_MATRIX_NV 0x86E1 -#define GL_OFFSET_TEXTURE_MATRIX_NV 0x86E1 -#define GL_OFFSET_TEXTURE_2D_SCALE_NV 0x86E2 -#define GL_OFFSET_TEXTURE_SCALE_NV 0x86E2 -#define GL_OFFSET_TEXTURE_2D_BIAS_NV 0x86E3 -#define GL_OFFSET_TEXTURE_BIAS_NV 0x86E3 -#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 - -#define GLEW_NV_texture_shader GLEW_GET_VAR(__GLEW_NV_texture_shader) - -#endif /* GL_NV_texture_shader */ - -/* ------------------------- GL_NV_texture_shader2 ------------------------- */ - -#ifndef GL_NV_texture_shader2 -#define GL_NV_texture_shader2 1 - -#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_DOT_PRODUCT_TEXTURE_3D_NV 0x86EF -#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 GLEW_NV_texture_shader2 GLEW_GET_VAR(__GLEW_NV_texture_shader2) - -#endif /* GL_NV_texture_shader2 */ - -/* ------------------------- GL_NV_texture_shader3 ------------------------- */ - -#ifndef GL_NV_texture_shader3 -#define GL_NV_texture_shader3 1 - -#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 - -#define GLEW_NV_texture_shader3 GLEW_GET_VAR(__GLEW_NV_texture_shader3) - -#endif /* GL_NV_texture_shader3 */ - -/* ------------------------ GL_NV_transform_feedback ----------------------- */ - -#ifndef GL_NV_transform_feedback -#define GL_NV_transform_feedback 1 - -#define GL_BACK_PRIMARY_COLOR_NV 0x8C77 -#define GL_BACK_SECONDARY_COLOR_NV 0x8C78 -#define GL_TEXTURE_COORD_NV 0x8C79 -#define GL_CLIP_DISTANCE_NV 0x8C7A -#define GL_VERTEX_ID_NV 0x8C7B -#define GL_PRIMITIVE_ID_NV 0x8C7C -#define GL_GENERIC_ATTRIB_NV 0x8C7D -#define GL_TRANSFORM_FEEDBACK_ATTRIBS_NV 0x8C7E -#define GL_TRANSFORM_FEEDBACK_BUFFER_MODE_NV 0x8C7F -#define GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS_NV 0x8C80 -#define GL_ACTIVE_VARYINGS_NV 0x8C81 -#define GL_ACTIVE_VARYING_MAX_LENGTH_NV 0x8C82 -#define GL_TRANSFORM_FEEDBACK_VARYINGS_NV 0x8C83 -#define GL_TRANSFORM_FEEDBACK_BUFFER_START_NV 0x8C84 -#define GL_TRANSFORM_FEEDBACK_BUFFER_SIZE_NV 0x8C85 -#define GL_TRANSFORM_FEEDBACK_RECORD_NV 0x8C86 -#define GL_PRIMITIVES_GENERATED_NV 0x8C87 -#define GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN_NV 0x8C88 -#define GL_RASTERIZER_DISCARD_NV 0x8C89 -#define GL_MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS_NV 0x8C8A -#define GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS_NV 0x8C8B -#define GL_INTERLEAVED_ATTRIBS_NV 0x8C8C -#define GL_SEPARATE_ATTRIBS_NV 0x8C8D -#define GL_TRANSFORM_FEEDBACK_BUFFER_NV 0x8C8E -#define GL_TRANSFORM_FEEDBACK_BUFFER_BINDING_NV 0x8C8F - -typedef void (GLAPIENTRY * PFNGLACTIVEVARYINGNVPROC) (GLuint program, const GLchar *name); -typedef void (GLAPIENTRY * PFNGLBEGINTRANSFORMFEEDBACKNVPROC) (GLenum primitiveMode); -typedef void (GLAPIENTRY * PFNGLBINDBUFFERBASENVPROC) (GLenum target, GLuint index, GLuint buffer); -typedef void (GLAPIENTRY * PFNGLBINDBUFFEROFFSETNVPROC) (GLenum target, GLuint index, GLuint buffer, GLintptr offset); -typedef void (GLAPIENTRY * PFNGLBINDBUFFERRANGENVPROC) (GLenum target, GLuint index, GLuint buffer, GLintptr offset, GLsizeiptr size); -typedef void (GLAPIENTRY * PFNGLENDTRANSFORMFEEDBACKNVPROC) (void); -typedef void (GLAPIENTRY * PFNGLGETACTIVEVARYINGNVPROC) (GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLsizei *size, GLenum *type, GLchar *name); -typedef void (GLAPIENTRY * PFNGLGETTRANSFORMFEEDBACKVARYINGNVPROC) (GLuint program, GLuint index, GLint *location); -typedef GLint (GLAPIENTRY * PFNGLGETVARYINGLOCATIONNVPROC) (GLuint program, const GLchar *name); -typedef void (GLAPIENTRY * PFNGLTRANSFORMFEEDBACKATTRIBSNVPROC) (GLuint count, const GLint *attribs, GLenum bufferMode); -typedef void (GLAPIENTRY * PFNGLTRANSFORMFEEDBACKVARYINGSNVPROC) (GLuint program, GLsizei count, const GLint *locations, GLenum bufferMode); - -#define glActiveVaryingNV GLEW_GET_FUN(__glewActiveVaryingNV) -#define glBeginTransformFeedbackNV GLEW_GET_FUN(__glewBeginTransformFeedbackNV) -#define glBindBufferBaseNV GLEW_GET_FUN(__glewBindBufferBaseNV) -#define glBindBufferOffsetNV GLEW_GET_FUN(__glewBindBufferOffsetNV) -#define glBindBufferRangeNV GLEW_GET_FUN(__glewBindBufferRangeNV) -#define glEndTransformFeedbackNV GLEW_GET_FUN(__glewEndTransformFeedbackNV) -#define glGetActiveVaryingNV GLEW_GET_FUN(__glewGetActiveVaryingNV) -#define glGetTransformFeedbackVaryingNV GLEW_GET_FUN(__glewGetTransformFeedbackVaryingNV) -#define glGetVaryingLocationNV GLEW_GET_FUN(__glewGetVaryingLocationNV) -#define glTransformFeedbackAttribsNV GLEW_GET_FUN(__glewTransformFeedbackAttribsNV) -#define glTransformFeedbackVaryingsNV GLEW_GET_FUN(__glewTransformFeedbackVaryingsNV) - -#define GLEW_NV_transform_feedback GLEW_GET_VAR(__GLEW_NV_transform_feedback) - -#endif /* GL_NV_transform_feedback */ - -/* ----------------------- GL_NV_transform_feedback2 ----------------------- */ - -#ifndef GL_NV_transform_feedback2 -#define GL_NV_transform_feedback2 1 - -#define GL_TRANSFORM_FEEDBACK_NV 0x8E22 -#define GL_TRANSFORM_FEEDBACK_BUFFER_PAUSED_NV 0x8E23 -#define GL_TRANSFORM_FEEDBACK_BUFFER_ACTIVE_NV 0x8E24 -#define GL_TRANSFORM_FEEDBACK_BINDING_NV 0x8E25 - -typedef void (GLAPIENTRY * PFNGLBINDTRANSFORMFEEDBACKNVPROC) (GLenum target, GLuint id); -typedef void (GLAPIENTRY * PFNGLDELETETRANSFORMFEEDBACKSNVPROC) (GLsizei n, const GLuint* ids); -typedef void (GLAPIENTRY * PFNGLDRAWTRANSFORMFEEDBACKNVPROC) (GLenum mode, GLuint id); -typedef void (GLAPIENTRY * PFNGLGENTRANSFORMFEEDBACKSNVPROC) (GLsizei n, GLuint* ids); -typedef GLboolean (GLAPIENTRY * PFNGLISTRANSFORMFEEDBACKNVPROC) (GLuint id); -typedef void (GLAPIENTRY * PFNGLPAUSETRANSFORMFEEDBACKNVPROC) (void); -typedef void (GLAPIENTRY * PFNGLRESUMETRANSFORMFEEDBACKNVPROC) (void); - -#define glBindTransformFeedbackNV GLEW_GET_FUN(__glewBindTransformFeedbackNV) -#define glDeleteTransformFeedbacksNV GLEW_GET_FUN(__glewDeleteTransformFeedbacksNV) -#define glDrawTransformFeedbackNV GLEW_GET_FUN(__glewDrawTransformFeedbackNV) -#define glGenTransformFeedbacksNV GLEW_GET_FUN(__glewGenTransformFeedbacksNV) -#define glIsTransformFeedbackNV GLEW_GET_FUN(__glewIsTransformFeedbackNV) -#define glPauseTransformFeedbackNV GLEW_GET_FUN(__glewPauseTransformFeedbackNV) -#define glResumeTransformFeedbackNV GLEW_GET_FUN(__glewResumeTransformFeedbackNV) - -#define GLEW_NV_transform_feedback2 GLEW_GET_VAR(__GLEW_NV_transform_feedback2) - -#endif /* GL_NV_transform_feedback2 */ - -/* ------------------ GL_NV_uniform_buffer_unified_memory ------------------ */ - -#ifndef GL_NV_uniform_buffer_unified_memory -#define GL_NV_uniform_buffer_unified_memory 1 - -#define GL_UNIFORM_BUFFER_UNIFIED_NV 0x936E -#define GL_UNIFORM_BUFFER_ADDRESS_NV 0x936F -#define GL_UNIFORM_BUFFER_LENGTH_NV 0x9370 - -#define GLEW_NV_uniform_buffer_unified_memory GLEW_GET_VAR(__GLEW_NV_uniform_buffer_unified_memory) - -#endif /* GL_NV_uniform_buffer_unified_memory */ - -/* -------------------------- GL_NV_vdpau_interop -------------------------- */ - -#ifndef GL_NV_vdpau_interop -#define GL_NV_vdpau_interop 1 - -#define GL_SURFACE_STATE_NV 0x86EB -#define GL_SURFACE_REGISTERED_NV 0x86FD -#define GL_SURFACE_MAPPED_NV 0x8700 -#define GL_WRITE_DISCARD_NV 0x88BE - -typedef GLintptr GLvdpauSurfaceNV; - -typedef void (GLAPIENTRY * PFNGLVDPAUFININVPROC) (void); -typedef void (GLAPIENTRY * PFNGLVDPAUGETSURFACEIVNVPROC) (GLvdpauSurfaceNV surface, GLenum pname, GLsizei bufSize, GLsizei* length, GLint *values); -typedef void (GLAPIENTRY * PFNGLVDPAUINITNVPROC) (const void* vdpDevice, const void*getProcAddress); -typedef void (GLAPIENTRY * PFNGLVDPAUISSURFACENVPROC) (GLvdpauSurfaceNV surface); -typedef void (GLAPIENTRY * PFNGLVDPAUMAPSURFACESNVPROC) (GLsizei numSurfaces, const GLvdpauSurfaceNV* surfaces); -typedef GLvdpauSurfaceNV (GLAPIENTRY * PFNGLVDPAUREGISTEROUTPUTSURFACENVPROC) (const void* vdpSurface, GLenum target, GLsizei numTextureNames, const GLuint *textureNames); -typedef GLvdpauSurfaceNV (GLAPIENTRY * PFNGLVDPAUREGISTERVIDEOSURFACENVPROC) (const void* vdpSurface, GLenum target, GLsizei numTextureNames, const GLuint *textureNames); -typedef void (GLAPIENTRY * PFNGLVDPAUSURFACEACCESSNVPROC) (GLvdpauSurfaceNV surface, GLenum access); -typedef void (GLAPIENTRY * PFNGLVDPAUUNMAPSURFACESNVPROC) (GLsizei numSurface, const GLvdpauSurfaceNV* surfaces); -typedef void (GLAPIENTRY * PFNGLVDPAUUNREGISTERSURFACENVPROC) (GLvdpauSurfaceNV surface); - -#define glVDPAUFiniNV GLEW_GET_FUN(__glewVDPAUFiniNV) -#define glVDPAUGetSurfaceivNV GLEW_GET_FUN(__glewVDPAUGetSurfaceivNV) -#define glVDPAUInitNV GLEW_GET_FUN(__glewVDPAUInitNV) -#define glVDPAUIsSurfaceNV GLEW_GET_FUN(__glewVDPAUIsSurfaceNV) -#define glVDPAUMapSurfacesNV GLEW_GET_FUN(__glewVDPAUMapSurfacesNV) -#define glVDPAURegisterOutputSurfaceNV GLEW_GET_FUN(__glewVDPAURegisterOutputSurfaceNV) -#define glVDPAURegisterVideoSurfaceNV GLEW_GET_FUN(__glewVDPAURegisterVideoSurfaceNV) -#define glVDPAUSurfaceAccessNV GLEW_GET_FUN(__glewVDPAUSurfaceAccessNV) -#define glVDPAUUnmapSurfacesNV GLEW_GET_FUN(__glewVDPAUUnmapSurfacesNV) -#define glVDPAUUnregisterSurfaceNV GLEW_GET_FUN(__glewVDPAUUnregisterSurfaceNV) - -#define GLEW_NV_vdpau_interop GLEW_GET_VAR(__GLEW_NV_vdpau_interop) - -#endif /* GL_NV_vdpau_interop */ - -/* ------------------------ GL_NV_vertex_array_range ----------------------- */ - -#ifndef GL_NV_vertex_array_range -#define GL_NV_vertex_array_range 1 - -#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 - -typedef void (GLAPIENTRY * PFNGLFLUSHVERTEXARRAYRANGENVPROC) (void); -typedef void (GLAPIENTRY * PFNGLVERTEXARRAYRANGENVPROC) (GLsizei length, void *pointer); - -#define glFlushVertexArrayRangeNV GLEW_GET_FUN(__glewFlushVertexArrayRangeNV) -#define glVertexArrayRangeNV GLEW_GET_FUN(__glewVertexArrayRangeNV) - -#define GLEW_NV_vertex_array_range GLEW_GET_VAR(__GLEW_NV_vertex_array_range) - -#endif /* GL_NV_vertex_array_range */ - -/* ----------------------- GL_NV_vertex_array_range2 ----------------------- */ - -#ifndef GL_NV_vertex_array_range2 -#define GL_NV_vertex_array_range2 1 - -#define GL_VERTEX_ARRAY_RANGE_WITHOUT_FLUSH_NV 0x8533 - -#define GLEW_NV_vertex_array_range2 GLEW_GET_VAR(__GLEW_NV_vertex_array_range2) - -#endif /* GL_NV_vertex_array_range2 */ - -/* ------------------- GL_NV_vertex_attrib_integer_64bit ------------------- */ - -#ifndef GL_NV_vertex_attrib_integer_64bit -#define GL_NV_vertex_attrib_integer_64bit 1 - -#define GL_INT64_NV 0x140E -#define GL_UNSIGNED_INT64_NV 0x140F - -typedef void (GLAPIENTRY * PFNGLGETVERTEXATTRIBLI64VNVPROC) (GLuint index, GLenum pname, GLint64EXT* params); -typedef void (GLAPIENTRY * PFNGLGETVERTEXATTRIBLUI64VNVPROC) (GLuint index, GLenum pname, GLuint64EXT* params); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBL1I64NVPROC) (GLuint index, GLint64EXT x); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBL1I64VNVPROC) (GLuint index, const GLint64EXT* v); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBL1UI64NVPROC) (GLuint index, GLuint64EXT x); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBL1UI64VNVPROC) (GLuint index, const GLuint64EXT* v); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBL2I64NVPROC) (GLuint index, GLint64EXT x, GLint64EXT y); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBL2I64VNVPROC) (GLuint index, const GLint64EXT* v); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBL2UI64NVPROC) (GLuint index, GLuint64EXT x, GLuint64EXT y); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBL2UI64VNVPROC) (GLuint index, const GLuint64EXT* v); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBL3I64NVPROC) (GLuint index, GLint64EXT x, GLint64EXT y, GLint64EXT z); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBL3I64VNVPROC) (GLuint index, const GLint64EXT* v); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBL3UI64NVPROC) (GLuint index, GLuint64EXT x, GLuint64EXT y, GLuint64EXT z); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBL3UI64VNVPROC) (GLuint index, const GLuint64EXT* v); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBL4I64NVPROC) (GLuint index, GLint64EXT x, GLint64EXT y, GLint64EXT z, GLint64EXT w); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBL4I64VNVPROC) (GLuint index, const GLint64EXT* v); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBL4UI64NVPROC) (GLuint index, GLuint64EXT x, GLuint64EXT y, GLuint64EXT z, GLuint64EXT w); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBL4UI64VNVPROC) (GLuint index, const GLuint64EXT* v); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBLFORMATNVPROC) (GLuint index, GLint size, GLenum type, GLsizei stride); - -#define glGetVertexAttribLi64vNV GLEW_GET_FUN(__glewGetVertexAttribLi64vNV) -#define glGetVertexAttribLui64vNV GLEW_GET_FUN(__glewGetVertexAttribLui64vNV) -#define glVertexAttribL1i64NV GLEW_GET_FUN(__glewVertexAttribL1i64NV) -#define glVertexAttribL1i64vNV GLEW_GET_FUN(__glewVertexAttribL1i64vNV) -#define glVertexAttribL1ui64NV GLEW_GET_FUN(__glewVertexAttribL1ui64NV) -#define glVertexAttribL1ui64vNV GLEW_GET_FUN(__glewVertexAttribL1ui64vNV) -#define glVertexAttribL2i64NV GLEW_GET_FUN(__glewVertexAttribL2i64NV) -#define glVertexAttribL2i64vNV GLEW_GET_FUN(__glewVertexAttribL2i64vNV) -#define glVertexAttribL2ui64NV GLEW_GET_FUN(__glewVertexAttribL2ui64NV) -#define glVertexAttribL2ui64vNV GLEW_GET_FUN(__glewVertexAttribL2ui64vNV) -#define glVertexAttribL3i64NV GLEW_GET_FUN(__glewVertexAttribL3i64NV) -#define glVertexAttribL3i64vNV GLEW_GET_FUN(__glewVertexAttribL3i64vNV) -#define glVertexAttribL3ui64NV GLEW_GET_FUN(__glewVertexAttribL3ui64NV) -#define glVertexAttribL3ui64vNV GLEW_GET_FUN(__glewVertexAttribL3ui64vNV) -#define glVertexAttribL4i64NV GLEW_GET_FUN(__glewVertexAttribL4i64NV) -#define glVertexAttribL4i64vNV GLEW_GET_FUN(__glewVertexAttribL4i64vNV) -#define glVertexAttribL4ui64NV GLEW_GET_FUN(__glewVertexAttribL4ui64NV) -#define glVertexAttribL4ui64vNV GLEW_GET_FUN(__glewVertexAttribL4ui64vNV) -#define glVertexAttribLFormatNV GLEW_GET_FUN(__glewVertexAttribLFormatNV) - -#define GLEW_NV_vertex_attrib_integer_64bit GLEW_GET_VAR(__GLEW_NV_vertex_attrib_integer_64bit) - -#endif /* GL_NV_vertex_attrib_integer_64bit */ - -/* ------------------- GL_NV_vertex_buffer_unified_memory ------------------ */ - -#ifndef GL_NV_vertex_buffer_unified_memory -#define GL_NV_vertex_buffer_unified_memory 1 - -#define GL_VERTEX_ATTRIB_ARRAY_UNIFIED_NV 0x8F1E -#define GL_ELEMENT_ARRAY_UNIFIED_NV 0x8F1F -#define GL_VERTEX_ATTRIB_ARRAY_ADDRESS_NV 0x8F20 -#define GL_VERTEX_ARRAY_ADDRESS_NV 0x8F21 -#define GL_NORMAL_ARRAY_ADDRESS_NV 0x8F22 -#define GL_COLOR_ARRAY_ADDRESS_NV 0x8F23 -#define GL_INDEX_ARRAY_ADDRESS_NV 0x8F24 -#define GL_TEXTURE_COORD_ARRAY_ADDRESS_NV 0x8F25 -#define GL_EDGE_FLAG_ARRAY_ADDRESS_NV 0x8F26 -#define GL_SECONDARY_COLOR_ARRAY_ADDRESS_NV 0x8F27 -#define GL_FOG_COORD_ARRAY_ADDRESS_NV 0x8F28 -#define GL_ELEMENT_ARRAY_ADDRESS_NV 0x8F29 -#define GL_VERTEX_ATTRIB_ARRAY_LENGTH_NV 0x8F2A -#define GL_VERTEX_ARRAY_LENGTH_NV 0x8F2B -#define GL_NORMAL_ARRAY_LENGTH_NV 0x8F2C -#define GL_COLOR_ARRAY_LENGTH_NV 0x8F2D -#define GL_INDEX_ARRAY_LENGTH_NV 0x8F2E -#define GL_TEXTURE_COORD_ARRAY_LENGTH_NV 0x8F2F -#define GL_EDGE_FLAG_ARRAY_LENGTH_NV 0x8F30 -#define GL_SECONDARY_COLOR_ARRAY_LENGTH_NV 0x8F31 -#define GL_FOG_COORD_ARRAY_LENGTH_NV 0x8F32 -#define GL_ELEMENT_ARRAY_LENGTH_NV 0x8F33 -#define GL_DRAW_INDIRECT_UNIFIED_NV 0x8F40 -#define GL_DRAW_INDIRECT_ADDRESS_NV 0x8F41 -#define GL_DRAW_INDIRECT_LENGTH_NV 0x8F42 - -typedef void (GLAPIENTRY * PFNGLBUFFERADDRESSRANGENVPROC) (GLenum pname, GLuint index, GLuint64EXT address, GLsizeiptr length); -typedef void (GLAPIENTRY * PFNGLCOLORFORMATNVPROC) (GLint size, GLenum type, GLsizei stride); -typedef void (GLAPIENTRY * PFNGLEDGEFLAGFORMATNVPROC) (GLsizei stride); -typedef void (GLAPIENTRY * PFNGLFOGCOORDFORMATNVPROC) (GLenum type, GLsizei stride); -typedef void (GLAPIENTRY * PFNGLGETINTEGERUI64I_VNVPROC) (GLenum value, GLuint index, GLuint64EXT result[]); -typedef void (GLAPIENTRY * PFNGLINDEXFORMATNVPROC) (GLenum type, GLsizei stride); -typedef void (GLAPIENTRY * PFNGLNORMALFORMATNVPROC) (GLenum type, GLsizei stride); -typedef void (GLAPIENTRY * PFNGLSECONDARYCOLORFORMATNVPROC) (GLint size, GLenum type, GLsizei stride); -typedef void (GLAPIENTRY * PFNGLTEXCOORDFORMATNVPROC) (GLint size, GLenum type, GLsizei stride); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBFORMATNVPROC) (GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBIFORMATNVPROC) (GLuint index, GLint size, GLenum type, GLsizei stride); -typedef void (GLAPIENTRY * PFNGLVERTEXFORMATNVPROC) (GLint size, GLenum type, GLsizei stride); - -#define glBufferAddressRangeNV GLEW_GET_FUN(__glewBufferAddressRangeNV) -#define glColorFormatNV GLEW_GET_FUN(__glewColorFormatNV) -#define glEdgeFlagFormatNV GLEW_GET_FUN(__glewEdgeFlagFormatNV) -#define glFogCoordFormatNV GLEW_GET_FUN(__glewFogCoordFormatNV) -#define glGetIntegerui64i_vNV GLEW_GET_FUN(__glewGetIntegerui64i_vNV) -#define glIndexFormatNV GLEW_GET_FUN(__glewIndexFormatNV) -#define glNormalFormatNV GLEW_GET_FUN(__glewNormalFormatNV) -#define glSecondaryColorFormatNV GLEW_GET_FUN(__glewSecondaryColorFormatNV) -#define glTexCoordFormatNV GLEW_GET_FUN(__glewTexCoordFormatNV) -#define glVertexAttribFormatNV GLEW_GET_FUN(__glewVertexAttribFormatNV) -#define glVertexAttribIFormatNV GLEW_GET_FUN(__glewVertexAttribIFormatNV) -#define glVertexFormatNV GLEW_GET_FUN(__glewVertexFormatNV) - -#define GLEW_NV_vertex_buffer_unified_memory GLEW_GET_VAR(__GLEW_NV_vertex_buffer_unified_memory) - -#endif /* GL_NV_vertex_buffer_unified_memory */ - -/* -------------------------- GL_NV_vertex_program ------------------------- */ - -#ifndef GL_NV_vertex_program -#define GL_NV_vertex_program 1 - -#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 - -typedef GLboolean (GLAPIENTRY * PFNGLAREPROGRAMSRESIDENTNVPROC) (GLsizei n, const GLuint* ids, GLboolean *residences); -typedef void (GLAPIENTRY * PFNGLBINDPROGRAMNVPROC) (GLenum target, GLuint id); -typedef void (GLAPIENTRY * PFNGLDELETEPROGRAMSNVPROC) (GLsizei n, const GLuint* ids); -typedef void (GLAPIENTRY * PFNGLEXECUTEPROGRAMNVPROC) (GLenum target, GLuint id, const GLfloat* params); -typedef void (GLAPIENTRY * PFNGLGENPROGRAMSNVPROC) (GLsizei n, GLuint* ids); -typedef void (GLAPIENTRY * PFNGLGETPROGRAMPARAMETERDVNVPROC) (GLenum target, GLuint index, GLenum pname, GLdouble* params); -typedef void (GLAPIENTRY * PFNGLGETPROGRAMPARAMETERFVNVPROC) (GLenum target, GLuint index, GLenum pname, GLfloat* params); -typedef void (GLAPIENTRY * PFNGLGETPROGRAMSTRINGNVPROC) (GLuint id, GLenum pname, GLubyte* program); -typedef void (GLAPIENTRY * PFNGLGETPROGRAMIVNVPROC) (GLuint id, GLenum pname, GLint* params); -typedef void (GLAPIENTRY * PFNGLGETTRACKMATRIXIVNVPROC) (GLenum target, GLuint address, GLenum pname, GLint* params); -typedef void (GLAPIENTRY * PFNGLGETVERTEXATTRIBPOINTERVNVPROC) (GLuint index, GLenum pname, void** pointer); -typedef void (GLAPIENTRY * PFNGLGETVERTEXATTRIBDVNVPROC) (GLuint index, GLenum pname, GLdouble* params); -typedef void (GLAPIENTRY * PFNGLGETVERTEXATTRIBFVNVPROC) (GLuint index, GLenum pname, GLfloat* params); -typedef void (GLAPIENTRY * PFNGLGETVERTEXATTRIBIVNVPROC) (GLuint index, GLenum pname, GLint* params); -typedef GLboolean (GLAPIENTRY * PFNGLISPROGRAMNVPROC) (GLuint id); -typedef void (GLAPIENTRY * PFNGLLOADPROGRAMNVPROC) (GLenum target, GLuint id, GLsizei len, const GLubyte* program); -typedef void (GLAPIENTRY * PFNGLPROGRAMPARAMETER4DNVPROC) (GLenum target, GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); -typedef void (GLAPIENTRY * PFNGLPROGRAMPARAMETER4DVNVPROC) (GLenum target, GLuint index, const GLdouble* params); -typedef void (GLAPIENTRY * PFNGLPROGRAMPARAMETER4FNVPROC) (GLenum target, GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); -typedef void (GLAPIENTRY * PFNGLPROGRAMPARAMETER4FVNVPROC) (GLenum target, GLuint index, const GLfloat* params); -typedef void (GLAPIENTRY * PFNGLPROGRAMPARAMETERS4DVNVPROC) (GLenum target, GLuint index, GLsizei num, const GLdouble* params); -typedef void (GLAPIENTRY * PFNGLPROGRAMPARAMETERS4FVNVPROC) (GLenum target, GLuint index, GLsizei num, const GLfloat* params); -typedef void (GLAPIENTRY * PFNGLREQUESTRESIDENTPROGRAMSNVPROC) (GLsizei n, GLuint* ids); -typedef void (GLAPIENTRY * PFNGLTRACKMATRIXNVPROC) (GLenum target, GLuint address, GLenum matrix, GLenum transform); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB1DNVPROC) (GLuint index, GLdouble x); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB1DVNVPROC) (GLuint index, const GLdouble* v); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB1FNVPROC) (GLuint index, GLfloat x); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB1FVNVPROC) (GLuint index, const GLfloat* v); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB1SNVPROC) (GLuint index, GLshort x); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB1SVNVPROC) (GLuint index, const GLshort* v); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB2DNVPROC) (GLuint index, GLdouble x, GLdouble y); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB2DVNVPROC) (GLuint index, const GLdouble* v); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB2FNVPROC) (GLuint index, GLfloat x, GLfloat y); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB2FVNVPROC) (GLuint index, const GLfloat* v); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB2SNVPROC) (GLuint index, GLshort x, GLshort y); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB2SVNVPROC) (GLuint index, const GLshort* v); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB3DNVPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB3DVNVPROC) (GLuint index, const GLdouble* v); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB3FNVPROC) (GLuint index, GLfloat x, GLfloat y, GLfloat z); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB3FVNVPROC) (GLuint index, const GLfloat* v); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB3SNVPROC) (GLuint index, GLshort x, GLshort y, GLshort z); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB3SVNVPROC) (GLuint index, const GLshort* v); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4DNVPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4DVNVPROC) (GLuint index, const GLdouble* v); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4FNVPROC) (GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4FVNVPROC) (GLuint index, const GLfloat* v); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4SNVPROC) (GLuint index, GLshort x, GLshort y, GLshort z, GLshort w); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4SVNVPROC) (GLuint index, const GLshort* v); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4UBNVPROC) (GLuint index, GLubyte x, GLubyte y, GLubyte z, GLubyte w); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4UBVNVPROC) (GLuint index, const GLubyte* v); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBPOINTERNVPROC) (GLuint index, GLint size, GLenum type, GLsizei stride, const void *pointer); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBS1DVNVPROC) (GLuint index, GLsizei n, const GLdouble* v); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBS1FVNVPROC) (GLuint index, GLsizei n, const GLfloat* v); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBS1SVNVPROC) (GLuint index, GLsizei n, const GLshort* v); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBS2DVNVPROC) (GLuint index, GLsizei n, const GLdouble* v); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBS2FVNVPROC) (GLuint index, GLsizei n, const GLfloat* v); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBS2SVNVPROC) (GLuint index, GLsizei n, const GLshort* v); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBS3DVNVPROC) (GLuint index, GLsizei n, const GLdouble* v); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBS3FVNVPROC) (GLuint index, GLsizei n, const GLfloat* v); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBS3SVNVPROC) (GLuint index, GLsizei n, const GLshort* v); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBS4DVNVPROC) (GLuint index, GLsizei n, const GLdouble* v); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBS4FVNVPROC) (GLuint index, GLsizei n, const GLfloat* v); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBS4SVNVPROC) (GLuint index, GLsizei n, const GLshort* v); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBS4UBVNVPROC) (GLuint index, GLsizei n, const GLubyte* v); - -#define glAreProgramsResidentNV GLEW_GET_FUN(__glewAreProgramsResidentNV) -#define glBindProgramNV GLEW_GET_FUN(__glewBindProgramNV) -#define glDeleteProgramsNV GLEW_GET_FUN(__glewDeleteProgramsNV) -#define glExecuteProgramNV GLEW_GET_FUN(__glewExecuteProgramNV) -#define glGenProgramsNV GLEW_GET_FUN(__glewGenProgramsNV) -#define glGetProgramParameterdvNV GLEW_GET_FUN(__glewGetProgramParameterdvNV) -#define glGetProgramParameterfvNV GLEW_GET_FUN(__glewGetProgramParameterfvNV) -#define glGetProgramStringNV GLEW_GET_FUN(__glewGetProgramStringNV) -#define glGetProgramivNV GLEW_GET_FUN(__glewGetProgramivNV) -#define glGetTrackMatrixivNV GLEW_GET_FUN(__glewGetTrackMatrixivNV) -#define glGetVertexAttribPointervNV GLEW_GET_FUN(__glewGetVertexAttribPointervNV) -#define glGetVertexAttribdvNV GLEW_GET_FUN(__glewGetVertexAttribdvNV) -#define glGetVertexAttribfvNV GLEW_GET_FUN(__glewGetVertexAttribfvNV) -#define glGetVertexAttribivNV GLEW_GET_FUN(__glewGetVertexAttribivNV) -#define glIsProgramNV GLEW_GET_FUN(__glewIsProgramNV) -#define glLoadProgramNV GLEW_GET_FUN(__glewLoadProgramNV) -#define glProgramParameter4dNV GLEW_GET_FUN(__glewProgramParameter4dNV) -#define glProgramParameter4dvNV GLEW_GET_FUN(__glewProgramParameter4dvNV) -#define glProgramParameter4fNV GLEW_GET_FUN(__glewProgramParameter4fNV) -#define glProgramParameter4fvNV GLEW_GET_FUN(__glewProgramParameter4fvNV) -#define glProgramParameters4dvNV GLEW_GET_FUN(__glewProgramParameters4dvNV) -#define glProgramParameters4fvNV GLEW_GET_FUN(__glewProgramParameters4fvNV) -#define glRequestResidentProgramsNV GLEW_GET_FUN(__glewRequestResidentProgramsNV) -#define glTrackMatrixNV GLEW_GET_FUN(__glewTrackMatrixNV) -#define glVertexAttrib1dNV GLEW_GET_FUN(__glewVertexAttrib1dNV) -#define glVertexAttrib1dvNV GLEW_GET_FUN(__glewVertexAttrib1dvNV) -#define glVertexAttrib1fNV GLEW_GET_FUN(__glewVertexAttrib1fNV) -#define glVertexAttrib1fvNV GLEW_GET_FUN(__glewVertexAttrib1fvNV) -#define glVertexAttrib1sNV GLEW_GET_FUN(__glewVertexAttrib1sNV) -#define glVertexAttrib1svNV GLEW_GET_FUN(__glewVertexAttrib1svNV) -#define glVertexAttrib2dNV GLEW_GET_FUN(__glewVertexAttrib2dNV) -#define glVertexAttrib2dvNV GLEW_GET_FUN(__glewVertexAttrib2dvNV) -#define glVertexAttrib2fNV GLEW_GET_FUN(__glewVertexAttrib2fNV) -#define glVertexAttrib2fvNV GLEW_GET_FUN(__glewVertexAttrib2fvNV) -#define glVertexAttrib2sNV GLEW_GET_FUN(__glewVertexAttrib2sNV) -#define glVertexAttrib2svNV GLEW_GET_FUN(__glewVertexAttrib2svNV) -#define glVertexAttrib3dNV GLEW_GET_FUN(__glewVertexAttrib3dNV) -#define glVertexAttrib3dvNV GLEW_GET_FUN(__glewVertexAttrib3dvNV) -#define glVertexAttrib3fNV GLEW_GET_FUN(__glewVertexAttrib3fNV) -#define glVertexAttrib3fvNV GLEW_GET_FUN(__glewVertexAttrib3fvNV) -#define glVertexAttrib3sNV GLEW_GET_FUN(__glewVertexAttrib3sNV) -#define glVertexAttrib3svNV GLEW_GET_FUN(__glewVertexAttrib3svNV) -#define glVertexAttrib4dNV GLEW_GET_FUN(__glewVertexAttrib4dNV) -#define glVertexAttrib4dvNV GLEW_GET_FUN(__glewVertexAttrib4dvNV) -#define glVertexAttrib4fNV GLEW_GET_FUN(__glewVertexAttrib4fNV) -#define glVertexAttrib4fvNV GLEW_GET_FUN(__glewVertexAttrib4fvNV) -#define glVertexAttrib4sNV GLEW_GET_FUN(__glewVertexAttrib4sNV) -#define glVertexAttrib4svNV GLEW_GET_FUN(__glewVertexAttrib4svNV) -#define glVertexAttrib4ubNV GLEW_GET_FUN(__glewVertexAttrib4ubNV) -#define glVertexAttrib4ubvNV GLEW_GET_FUN(__glewVertexAttrib4ubvNV) -#define glVertexAttribPointerNV GLEW_GET_FUN(__glewVertexAttribPointerNV) -#define glVertexAttribs1dvNV GLEW_GET_FUN(__glewVertexAttribs1dvNV) -#define glVertexAttribs1fvNV GLEW_GET_FUN(__glewVertexAttribs1fvNV) -#define glVertexAttribs1svNV GLEW_GET_FUN(__glewVertexAttribs1svNV) -#define glVertexAttribs2dvNV GLEW_GET_FUN(__glewVertexAttribs2dvNV) -#define glVertexAttribs2fvNV GLEW_GET_FUN(__glewVertexAttribs2fvNV) -#define glVertexAttribs2svNV GLEW_GET_FUN(__glewVertexAttribs2svNV) -#define glVertexAttribs3dvNV GLEW_GET_FUN(__glewVertexAttribs3dvNV) -#define glVertexAttribs3fvNV GLEW_GET_FUN(__glewVertexAttribs3fvNV) -#define glVertexAttribs3svNV GLEW_GET_FUN(__glewVertexAttribs3svNV) -#define glVertexAttribs4dvNV GLEW_GET_FUN(__glewVertexAttribs4dvNV) -#define glVertexAttribs4fvNV GLEW_GET_FUN(__glewVertexAttribs4fvNV) -#define glVertexAttribs4svNV GLEW_GET_FUN(__glewVertexAttribs4svNV) -#define glVertexAttribs4ubvNV GLEW_GET_FUN(__glewVertexAttribs4ubvNV) - -#define GLEW_NV_vertex_program GLEW_GET_VAR(__GLEW_NV_vertex_program) - -#endif /* GL_NV_vertex_program */ - -/* ------------------------ GL_NV_vertex_program1_1 ------------------------ */ - -#ifndef GL_NV_vertex_program1_1 -#define GL_NV_vertex_program1_1 1 - -#define GLEW_NV_vertex_program1_1 GLEW_GET_VAR(__GLEW_NV_vertex_program1_1) - -#endif /* GL_NV_vertex_program1_1 */ - -/* ------------------------- GL_NV_vertex_program2 ------------------------- */ - -#ifndef GL_NV_vertex_program2 -#define GL_NV_vertex_program2 1 - -#define GLEW_NV_vertex_program2 GLEW_GET_VAR(__GLEW_NV_vertex_program2) - -#endif /* GL_NV_vertex_program2 */ - -/* ---------------------- GL_NV_vertex_program2_option --------------------- */ - -#ifndef GL_NV_vertex_program2_option -#define GL_NV_vertex_program2_option 1 - -#define GL_MAX_PROGRAM_EXEC_INSTRUCTIONS_NV 0x88F4 -#define GL_MAX_PROGRAM_CALL_DEPTH_NV 0x88F5 - -#define GLEW_NV_vertex_program2_option GLEW_GET_VAR(__GLEW_NV_vertex_program2_option) - -#endif /* GL_NV_vertex_program2_option */ - -/* ------------------------- GL_NV_vertex_program3 ------------------------- */ - -#ifndef GL_NV_vertex_program3 -#define GL_NV_vertex_program3 1 - -#define MAX_VERTEX_TEXTURE_IMAGE_UNITS_ARB 0x8B4C - -#define GLEW_NV_vertex_program3 GLEW_GET_VAR(__GLEW_NV_vertex_program3) - -#endif /* GL_NV_vertex_program3 */ - -/* ------------------------- GL_NV_vertex_program4 ------------------------- */ - -#ifndef GL_NV_vertex_program4 -#define GL_NV_vertex_program4 1 - -#define GL_VERTEX_ATTRIB_ARRAY_INTEGER_NV 0x88FD - -#define GLEW_NV_vertex_program4 GLEW_GET_VAR(__GLEW_NV_vertex_program4) - -#endif /* GL_NV_vertex_program4 */ - -/* -------------------------- GL_NV_video_capture -------------------------- */ - -#ifndef GL_NV_video_capture -#define GL_NV_video_capture 1 - -#define GL_VIDEO_BUFFER_NV 0x9020 -#define GL_VIDEO_BUFFER_BINDING_NV 0x9021 -#define GL_FIELD_UPPER_NV 0x9022 -#define GL_FIELD_LOWER_NV 0x9023 -#define GL_NUM_VIDEO_CAPTURE_STREAMS_NV 0x9024 -#define GL_NEXT_VIDEO_CAPTURE_BUFFER_STATUS_NV 0x9025 -#define GL_VIDEO_CAPTURE_TO_422_SUPPORTED_NV 0x9026 -#define GL_LAST_VIDEO_CAPTURE_STATUS_NV 0x9027 -#define GL_VIDEO_BUFFER_PITCH_NV 0x9028 -#define GL_VIDEO_COLOR_CONVERSION_MATRIX_NV 0x9029 -#define GL_VIDEO_COLOR_CONVERSION_MAX_NV 0x902A -#define GL_VIDEO_COLOR_CONVERSION_MIN_NV 0x902B -#define GL_VIDEO_COLOR_CONVERSION_OFFSET_NV 0x902C -#define GL_VIDEO_BUFFER_INTERNAL_FORMAT_NV 0x902D -#define GL_PARTIAL_SUCCESS_NV 0x902E -#define GL_SUCCESS_NV 0x902F -#define GL_FAILURE_NV 0x9030 -#define GL_YCBYCR8_422_NV 0x9031 -#define GL_YCBAYCR8A_4224_NV 0x9032 -#define GL_Z6Y10Z6CB10Z6Y10Z6CR10_422_NV 0x9033 -#define GL_Z6Y10Z6CB10Z6A10Z6Y10Z6CR10Z6A10_4224_NV 0x9034 -#define GL_Z4Y12Z4CB12Z4Y12Z4CR12_422_NV 0x9035 -#define GL_Z4Y12Z4CB12Z4A12Z4Y12Z4CR12Z4A12_4224_NV 0x9036 -#define GL_Z4Y12Z4CB12Z4CR12_444_NV 0x9037 -#define GL_VIDEO_CAPTURE_FRAME_WIDTH_NV 0x9038 -#define GL_VIDEO_CAPTURE_FRAME_HEIGHT_NV 0x9039 -#define GL_VIDEO_CAPTURE_FIELD_UPPER_HEIGHT_NV 0x903A -#define GL_VIDEO_CAPTURE_FIELD_LOWER_HEIGHT_NV 0x903B -#define GL_VIDEO_CAPTURE_SURFACE_ORIGIN_NV 0x903C - -typedef void (GLAPIENTRY * PFNGLBEGINVIDEOCAPTURENVPROC) (GLuint video_capture_slot); -typedef void (GLAPIENTRY * PFNGLBINDVIDEOCAPTURESTREAMBUFFERNVPROC) (GLuint video_capture_slot, GLuint stream, GLenum frame_region, GLintptrARB offset); -typedef void (GLAPIENTRY * PFNGLBINDVIDEOCAPTURESTREAMTEXTURENVPROC) (GLuint video_capture_slot, GLuint stream, GLenum frame_region, GLenum target, GLuint texture); -typedef void (GLAPIENTRY * PFNGLENDVIDEOCAPTURENVPROC) (GLuint video_capture_slot); -typedef void (GLAPIENTRY * PFNGLGETVIDEOCAPTURESTREAMDVNVPROC) (GLuint video_capture_slot, GLuint stream, GLenum pname, GLdouble* params); -typedef void (GLAPIENTRY * PFNGLGETVIDEOCAPTURESTREAMFVNVPROC) (GLuint video_capture_slot, GLuint stream, GLenum pname, GLfloat* params); -typedef void (GLAPIENTRY * PFNGLGETVIDEOCAPTURESTREAMIVNVPROC) (GLuint video_capture_slot, GLuint stream, GLenum pname, GLint* params); -typedef void (GLAPIENTRY * PFNGLGETVIDEOCAPTUREIVNVPROC) (GLuint video_capture_slot, GLenum pname, GLint* params); -typedef GLenum (GLAPIENTRY * PFNGLVIDEOCAPTURENVPROC) (GLuint video_capture_slot, GLuint* sequence_num, GLuint64EXT *capture_time); -typedef void (GLAPIENTRY * PFNGLVIDEOCAPTURESTREAMPARAMETERDVNVPROC) (GLuint video_capture_slot, GLuint stream, GLenum pname, const GLdouble* params); -typedef void (GLAPIENTRY * PFNGLVIDEOCAPTURESTREAMPARAMETERFVNVPROC) (GLuint video_capture_slot, GLuint stream, GLenum pname, const GLfloat* params); -typedef void (GLAPIENTRY * PFNGLVIDEOCAPTURESTREAMPARAMETERIVNVPROC) (GLuint video_capture_slot, GLuint stream, GLenum pname, const GLint* params); - -#define glBeginVideoCaptureNV GLEW_GET_FUN(__glewBeginVideoCaptureNV) -#define glBindVideoCaptureStreamBufferNV GLEW_GET_FUN(__glewBindVideoCaptureStreamBufferNV) -#define glBindVideoCaptureStreamTextureNV GLEW_GET_FUN(__glewBindVideoCaptureStreamTextureNV) -#define glEndVideoCaptureNV GLEW_GET_FUN(__glewEndVideoCaptureNV) -#define glGetVideoCaptureStreamdvNV GLEW_GET_FUN(__glewGetVideoCaptureStreamdvNV) -#define glGetVideoCaptureStreamfvNV GLEW_GET_FUN(__glewGetVideoCaptureStreamfvNV) -#define glGetVideoCaptureStreamivNV GLEW_GET_FUN(__glewGetVideoCaptureStreamivNV) -#define glGetVideoCaptureivNV GLEW_GET_FUN(__glewGetVideoCaptureivNV) -#define glVideoCaptureNV GLEW_GET_FUN(__glewVideoCaptureNV) -#define glVideoCaptureStreamParameterdvNV GLEW_GET_FUN(__glewVideoCaptureStreamParameterdvNV) -#define glVideoCaptureStreamParameterfvNV GLEW_GET_FUN(__glewVideoCaptureStreamParameterfvNV) -#define glVideoCaptureStreamParameterivNV GLEW_GET_FUN(__glewVideoCaptureStreamParameterivNV) - -#define GLEW_NV_video_capture GLEW_GET_VAR(__GLEW_NV_video_capture) - -#endif /* GL_NV_video_capture */ - -/* ------------------------- GL_NV_viewport_array2 ------------------------- */ - -#ifndef GL_NV_viewport_array2 -#define GL_NV_viewport_array2 1 - -#define GLEW_NV_viewport_array2 GLEW_GET_VAR(__GLEW_NV_viewport_array2) - -#endif /* GL_NV_viewport_array2 */ - -/* ------------------------- GL_NV_viewport_swizzle ------------------------ */ - -#ifndef GL_NV_viewport_swizzle -#define GL_NV_viewport_swizzle 1 - -#define GL_VIEWPORT_SWIZZLE_POSITIVE_X_NV 0x9350 -#define GL_VIEWPORT_SWIZZLE_NEGATIVE_X_NV 0x9351 -#define GL_VIEWPORT_SWIZZLE_POSITIVE_Y_NV 0x9352 -#define GL_VIEWPORT_SWIZZLE_NEGATIVE_Y_NV 0x9353 -#define GL_VIEWPORT_SWIZZLE_POSITIVE_Z_NV 0x9354 -#define GL_VIEWPORT_SWIZZLE_NEGATIVE_Z_NV 0x9355 -#define GL_VIEWPORT_SWIZZLE_POSITIVE_W_NV 0x9356 -#define GL_VIEWPORT_SWIZZLE_NEGATIVE_W_NV 0x9357 -#define GL_VIEWPORT_SWIZZLE_X_NV 0x9358 -#define GL_VIEWPORT_SWIZZLE_Y_NV 0x9359 -#define GL_VIEWPORT_SWIZZLE_Z_NV 0x935A -#define GL_VIEWPORT_SWIZZLE_W_NV 0x935B - -typedef void (GLAPIENTRY * PFNGLVIEWPORTSWIZZLENVPROC) (GLuint index, GLenum swizzlex, GLenum swizzley, GLenum swizzlez, GLenum swizzlew); - -#define glViewportSwizzleNV GLEW_GET_FUN(__glewViewportSwizzleNV) - -#define GLEW_NV_viewport_swizzle GLEW_GET_VAR(__GLEW_NV_viewport_swizzle) - -#endif /* GL_NV_viewport_swizzle */ - -/* ------------------------ GL_OES_byte_coordinates ------------------------ */ - -#ifndef GL_OES_byte_coordinates -#define GL_OES_byte_coordinates 1 - -#define GLEW_OES_byte_coordinates GLEW_GET_VAR(__GLEW_OES_byte_coordinates) - -#endif /* GL_OES_byte_coordinates */ - -/* ------------------- GL_OES_compressed_paletted_texture ------------------ */ - -#ifndef GL_OES_compressed_paletted_texture -#define GL_OES_compressed_paletted_texture 1 - -#define GL_PALETTE4_RGB8_OES 0x8B90 -#define GL_PALETTE4_RGBA8_OES 0x8B91 -#define GL_PALETTE4_R5_G6_B5_OES 0x8B92 -#define GL_PALETTE4_RGBA4_OES 0x8B93 -#define GL_PALETTE4_RGB5_A1_OES 0x8B94 -#define GL_PALETTE8_RGB8_OES 0x8B95 -#define GL_PALETTE8_RGBA8_OES 0x8B96 -#define GL_PALETTE8_R5_G6_B5_OES 0x8B97 -#define GL_PALETTE8_RGBA4_OES 0x8B98 -#define GL_PALETTE8_RGB5_A1_OES 0x8B99 - -#define GLEW_OES_compressed_paletted_texture GLEW_GET_VAR(__GLEW_OES_compressed_paletted_texture) - -#endif /* GL_OES_compressed_paletted_texture */ - -/* --------------------------- GL_OES_read_format -------------------------- */ - -#ifndef GL_OES_read_format -#define GL_OES_read_format 1 - -#define GL_IMPLEMENTATION_COLOR_READ_TYPE_OES 0x8B9A -#define GL_IMPLEMENTATION_COLOR_READ_FORMAT_OES 0x8B9B - -#define GLEW_OES_read_format GLEW_GET_VAR(__GLEW_OES_read_format) - -#endif /* GL_OES_read_format */ - -/* ------------------------ GL_OES_single_precision ------------------------ */ - -#ifndef GL_OES_single_precision -#define GL_OES_single_precision 1 - -typedef void (GLAPIENTRY * PFNGLCLEARDEPTHFOESPROC) (GLclampf depth); -typedef void (GLAPIENTRY * PFNGLCLIPPLANEFOESPROC) (GLenum plane, const GLfloat* equation); -typedef void (GLAPIENTRY * PFNGLDEPTHRANGEFOESPROC) (GLclampf n, GLclampf f); -typedef void (GLAPIENTRY * PFNGLFRUSTUMFOESPROC) (GLfloat l, GLfloat r, GLfloat b, GLfloat t, GLfloat n, GLfloat f); -typedef void (GLAPIENTRY * PFNGLGETCLIPPLANEFOESPROC) (GLenum plane, GLfloat* equation); -typedef void (GLAPIENTRY * PFNGLORTHOFOESPROC) (GLfloat l, GLfloat r, GLfloat b, GLfloat t, GLfloat n, GLfloat f); - -#define glClearDepthfOES GLEW_GET_FUN(__glewClearDepthfOES) -#define glClipPlanefOES GLEW_GET_FUN(__glewClipPlanefOES) -#define glDepthRangefOES GLEW_GET_FUN(__glewDepthRangefOES) -#define glFrustumfOES GLEW_GET_FUN(__glewFrustumfOES) -#define glGetClipPlanefOES GLEW_GET_FUN(__glewGetClipPlanefOES) -#define glOrthofOES GLEW_GET_FUN(__glewOrthofOES) - -#define GLEW_OES_single_precision GLEW_GET_VAR(__GLEW_OES_single_precision) - -#endif /* GL_OES_single_precision */ - -/* ---------------------------- GL_OML_interlace --------------------------- */ - -#ifndef GL_OML_interlace -#define GL_OML_interlace 1 - -#define GL_INTERLACE_OML 0x8980 -#define GL_INTERLACE_READ_OML 0x8981 - -#define GLEW_OML_interlace GLEW_GET_VAR(__GLEW_OML_interlace) - -#endif /* GL_OML_interlace */ - -/* ---------------------------- GL_OML_resample ---------------------------- */ - -#ifndef GL_OML_resample -#define GL_OML_resample 1 - -#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 - -#define GLEW_OML_resample GLEW_GET_VAR(__GLEW_OML_resample) - -#endif /* GL_OML_resample */ - -/* ---------------------------- GL_OML_subsample --------------------------- */ - -#ifndef GL_OML_subsample -#define GL_OML_subsample 1 - -#define GL_FORMAT_SUBSAMPLE_24_24_OML 0x8982 -#define GL_FORMAT_SUBSAMPLE_244_244_OML 0x8983 - -#define GLEW_OML_subsample GLEW_GET_VAR(__GLEW_OML_subsample) - -#endif /* GL_OML_subsample */ - -/* ---------------------------- GL_OVR_multiview --------------------------- */ - -#ifndef GL_OVR_multiview -#define GL_OVR_multiview 1 - -#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_NUM_VIEWS_OVR 0x9630 -#define GL_MAX_VIEWS_OVR 0x9631 -#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_BASE_VIEW_INDEX_OVR 0x9632 -#define GL_FRAMEBUFFER_INCOMPLETE_VIEW_TARGETS_OVR 0x9633 - -typedef void (GLAPIENTRY * PFNGLFRAMEBUFFERTEXTUREMULTIVIEWOVRPROC) (GLenum target, GLenum attachment, GLuint texture, GLint level, GLint baseViewIndex, GLsizei numViews); - -#define glFramebufferTextureMultiviewOVR GLEW_GET_FUN(__glewFramebufferTextureMultiviewOVR) - -#define GLEW_OVR_multiview GLEW_GET_VAR(__GLEW_OVR_multiview) - -#endif /* GL_OVR_multiview */ - -/* --------------------------- GL_OVR_multiview2 --------------------------- */ - -#ifndef GL_OVR_multiview2 -#define GL_OVR_multiview2 1 - -#define GLEW_OVR_multiview2 GLEW_GET_VAR(__GLEW_OVR_multiview2) - -#endif /* GL_OVR_multiview2 */ - -/* --------------------------- GL_PGI_misc_hints --------------------------- */ - -#ifndef GL_PGI_misc_hints -#define GL_PGI_misc_hints 1 - -#define GL_PREFER_DOUBLEBUFFER_HINT_PGI 107000 -#define GL_CONSERVE_MEMORY_HINT_PGI 107005 -#define GL_RECLAIM_MEMORY_HINT_PGI 107006 -#define GL_NATIVE_GRAPHICS_HANDLE_PGI 107010 -#define GL_NATIVE_GRAPHICS_BEGIN_HINT_PGI 107011 -#define GL_NATIVE_GRAPHICS_END_HINT_PGI 107012 -#define GL_ALWAYS_FAST_HINT_PGI 107020 -#define GL_ALWAYS_SOFT_HINT_PGI 107021 -#define GL_ALLOW_DRAW_OBJ_HINT_PGI 107022 -#define GL_ALLOW_DRAW_WIN_HINT_PGI 107023 -#define GL_ALLOW_DRAW_FRG_HINT_PGI 107024 -#define GL_ALLOW_DRAW_MEM_HINT_PGI 107025 -#define GL_STRICT_DEPTHFUNC_HINT_PGI 107030 -#define GL_STRICT_LIGHTING_HINT_PGI 107031 -#define GL_STRICT_SCISSOR_HINT_PGI 107032 -#define GL_FULL_STIPPLE_HINT_PGI 107033 -#define GL_CLIP_NEAR_HINT_PGI 107040 -#define GL_CLIP_FAR_HINT_PGI 107041 -#define GL_WIDE_LINE_HINT_PGI 107042 -#define GL_BACK_NORMALS_HINT_PGI 107043 - -#define GLEW_PGI_misc_hints GLEW_GET_VAR(__GLEW_PGI_misc_hints) - -#endif /* GL_PGI_misc_hints */ - -/* -------------------------- GL_PGI_vertex_hints -------------------------- */ - -#ifndef GL_PGI_vertex_hints -#define GL_PGI_vertex_hints 1 - -#define GL_VERTEX23_BIT_PGI 0x00000004 -#define GL_VERTEX4_BIT_PGI 0x00000008 -#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_VERTEX_DATA_HINT_PGI 107050 -#define GL_VERTEX_CONSISTENT_HINT_PGI 107051 -#define GL_MATERIAL_SIDE_HINT_PGI 107052 -#define GL_MAX_VERTEX_HINT_PGI 107053 -#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 GLEW_PGI_vertex_hints GLEW_GET_VAR(__GLEW_PGI_vertex_hints) - -#endif /* GL_PGI_vertex_hints */ - -/* ---------------------- GL_REGAL_ES1_0_compatibility --------------------- */ - -#ifndef GL_REGAL_ES1_0_compatibility -#define GL_REGAL_ES1_0_compatibility 1 - -typedef int GLclampx; - -typedef void (GLAPIENTRY * PFNGLALPHAFUNCXPROC) (GLenum func, GLclampx ref); -typedef void (GLAPIENTRY * PFNGLCLEARCOLORXPROC) (GLclampx red, GLclampx green, GLclampx blue, GLclampx alpha); -typedef void (GLAPIENTRY * PFNGLCLEARDEPTHXPROC) (GLclampx depth); -typedef void (GLAPIENTRY * PFNGLCOLOR4XPROC) (GLfixed red, GLfixed green, GLfixed blue, GLfixed alpha); -typedef void (GLAPIENTRY * PFNGLDEPTHRANGEXPROC) (GLclampx zNear, GLclampx zFar); -typedef void (GLAPIENTRY * PFNGLFOGXPROC) (GLenum pname, GLfixed param); -typedef void (GLAPIENTRY * PFNGLFOGXVPROC) (GLenum pname, const GLfixed* params); -typedef void (GLAPIENTRY * PFNGLFRUSTUMFPROC) (GLfloat left, GLfloat right, GLfloat bottom, GLfloat top, GLfloat zNear, GLfloat zFar); -typedef void (GLAPIENTRY * PFNGLFRUSTUMXPROC) (GLfixed left, GLfixed right, GLfixed bottom, GLfixed top, GLfixed zNear, GLfixed zFar); -typedef void (GLAPIENTRY * PFNGLLIGHTMODELXPROC) (GLenum pname, GLfixed param); -typedef void (GLAPIENTRY * PFNGLLIGHTMODELXVPROC) (GLenum pname, const GLfixed* params); -typedef void (GLAPIENTRY * PFNGLLIGHTXPROC) (GLenum light, GLenum pname, GLfixed param); -typedef void (GLAPIENTRY * PFNGLLIGHTXVPROC) (GLenum light, GLenum pname, const GLfixed* params); -typedef void (GLAPIENTRY * PFNGLLINEWIDTHXPROC) (GLfixed width); -typedef void (GLAPIENTRY * PFNGLLOADMATRIXXPROC) (const GLfixed* m); -typedef void (GLAPIENTRY * PFNGLMATERIALXPROC) (GLenum face, GLenum pname, GLfixed param); -typedef void (GLAPIENTRY * PFNGLMATERIALXVPROC) (GLenum face, GLenum pname, const GLfixed* params); -typedef void (GLAPIENTRY * PFNGLMULTMATRIXXPROC) (const GLfixed* m); -typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD4XPROC) (GLenum target, GLfixed s, GLfixed t, GLfixed r, GLfixed q); -typedef void (GLAPIENTRY * PFNGLNORMAL3XPROC) (GLfixed nx, GLfixed ny, GLfixed nz); -typedef void (GLAPIENTRY * PFNGLORTHOFPROC) (GLfloat left, GLfloat right, GLfloat bottom, GLfloat top, GLfloat zNear, GLfloat zFar); -typedef void (GLAPIENTRY * PFNGLORTHOXPROC) (GLfixed left, GLfixed right, GLfixed bottom, GLfixed top, GLfixed zNear, GLfixed zFar); -typedef void (GLAPIENTRY * PFNGLPOINTSIZEXPROC) (GLfixed size); -typedef void (GLAPIENTRY * PFNGLPOLYGONOFFSETXPROC) (GLfixed factor, GLfixed units); -typedef void (GLAPIENTRY * PFNGLROTATEXPROC) (GLfixed angle, GLfixed x, GLfixed y, GLfixed z); -typedef void (GLAPIENTRY * PFNGLSAMPLECOVERAGEXPROC) (GLclampx value, GLboolean invert); -typedef void (GLAPIENTRY * PFNGLSCALEXPROC) (GLfixed x, GLfixed y, GLfixed z); -typedef void (GLAPIENTRY * PFNGLTEXENVXPROC) (GLenum target, GLenum pname, GLfixed param); -typedef void (GLAPIENTRY * PFNGLTEXENVXVPROC) (GLenum target, GLenum pname, const GLfixed* params); -typedef void (GLAPIENTRY * PFNGLTEXPARAMETERXPROC) (GLenum target, GLenum pname, GLfixed param); -typedef void (GLAPIENTRY * PFNGLTRANSLATEXPROC) (GLfixed x, GLfixed y, GLfixed z); - -#define glAlphaFuncx GLEW_GET_FUN(__glewAlphaFuncx) -#define glClearColorx GLEW_GET_FUN(__glewClearColorx) -#define glClearDepthx GLEW_GET_FUN(__glewClearDepthx) -#define glColor4x GLEW_GET_FUN(__glewColor4x) -#define glDepthRangex GLEW_GET_FUN(__glewDepthRangex) -#define glFogx GLEW_GET_FUN(__glewFogx) -#define glFogxv GLEW_GET_FUN(__glewFogxv) -#define glFrustumf GLEW_GET_FUN(__glewFrustumf) -#define glFrustumx GLEW_GET_FUN(__glewFrustumx) -#define glLightModelx GLEW_GET_FUN(__glewLightModelx) -#define glLightModelxv GLEW_GET_FUN(__glewLightModelxv) -#define glLightx GLEW_GET_FUN(__glewLightx) -#define glLightxv GLEW_GET_FUN(__glewLightxv) -#define glLineWidthx GLEW_GET_FUN(__glewLineWidthx) -#define glLoadMatrixx GLEW_GET_FUN(__glewLoadMatrixx) -#define glMaterialx GLEW_GET_FUN(__glewMaterialx) -#define glMaterialxv GLEW_GET_FUN(__glewMaterialxv) -#define glMultMatrixx GLEW_GET_FUN(__glewMultMatrixx) -#define glMultiTexCoord4x GLEW_GET_FUN(__glewMultiTexCoord4x) -#define glNormal3x GLEW_GET_FUN(__glewNormal3x) -#define glOrthof GLEW_GET_FUN(__glewOrthof) -#define glOrthox GLEW_GET_FUN(__glewOrthox) -#define glPointSizex GLEW_GET_FUN(__glewPointSizex) -#define glPolygonOffsetx GLEW_GET_FUN(__glewPolygonOffsetx) -#define glRotatex GLEW_GET_FUN(__glewRotatex) -#define glSampleCoveragex GLEW_GET_FUN(__glewSampleCoveragex) -#define glScalex GLEW_GET_FUN(__glewScalex) -#define glTexEnvx GLEW_GET_FUN(__glewTexEnvx) -#define glTexEnvxv GLEW_GET_FUN(__glewTexEnvxv) -#define glTexParameterx GLEW_GET_FUN(__glewTexParameterx) -#define glTranslatex GLEW_GET_FUN(__glewTranslatex) - -#define GLEW_REGAL_ES1_0_compatibility GLEW_GET_VAR(__GLEW_REGAL_ES1_0_compatibility) - -#endif /* GL_REGAL_ES1_0_compatibility */ - -/* ---------------------- GL_REGAL_ES1_1_compatibility --------------------- */ - -#ifndef GL_REGAL_ES1_1_compatibility -#define GL_REGAL_ES1_1_compatibility 1 - -typedef void (GLAPIENTRY * PFNGLCLIPPLANEFPROC) (GLenum plane, const GLfloat* equation); -typedef void (GLAPIENTRY * PFNGLCLIPPLANEXPROC) (GLenum plane, const GLfixed* equation); -typedef void (GLAPIENTRY * PFNGLGETCLIPPLANEFPROC) (GLenum pname, GLfloat eqn[4]); -typedef void (GLAPIENTRY * PFNGLGETCLIPPLANEXPROC) (GLenum pname, GLfixed eqn[4]); -typedef void (GLAPIENTRY * PFNGLGETFIXEDVPROC) (GLenum pname, GLfixed* params); -typedef void (GLAPIENTRY * PFNGLGETLIGHTXVPROC) (GLenum light, GLenum pname, GLfixed* params); -typedef void (GLAPIENTRY * PFNGLGETMATERIALXVPROC) (GLenum face, GLenum pname, GLfixed* params); -typedef void (GLAPIENTRY * PFNGLGETTEXENVXVPROC) (GLenum env, GLenum pname, GLfixed* params); -typedef void (GLAPIENTRY * PFNGLGETTEXPARAMETERXVPROC) (GLenum target, GLenum pname, GLfixed* params); -typedef void (GLAPIENTRY * PFNGLPOINTPARAMETERXPROC) (GLenum pname, GLfixed param); -typedef void (GLAPIENTRY * PFNGLPOINTPARAMETERXVPROC) (GLenum pname, const GLfixed* params); -typedef void (GLAPIENTRY * PFNGLPOINTSIZEPOINTEROESPROC) (GLenum type, GLsizei stride, const void *pointer); -typedef void (GLAPIENTRY * PFNGLTEXPARAMETERXVPROC) (GLenum target, GLenum pname, const GLfixed* params); - -#define glClipPlanef GLEW_GET_FUN(__glewClipPlanef) -#define glClipPlanex GLEW_GET_FUN(__glewClipPlanex) -#define glGetClipPlanef GLEW_GET_FUN(__glewGetClipPlanef) -#define glGetClipPlanex GLEW_GET_FUN(__glewGetClipPlanex) -#define glGetFixedv GLEW_GET_FUN(__glewGetFixedv) -#define glGetLightxv GLEW_GET_FUN(__glewGetLightxv) -#define glGetMaterialxv GLEW_GET_FUN(__glewGetMaterialxv) -#define glGetTexEnvxv GLEW_GET_FUN(__glewGetTexEnvxv) -#define glGetTexParameterxv GLEW_GET_FUN(__glewGetTexParameterxv) -#define glPointParameterx GLEW_GET_FUN(__glewPointParameterx) -#define glPointParameterxv GLEW_GET_FUN(__glewPointParameterxv) -#define glPointSizePointerOES GLEW_GET_FUN(__glewPointSizePointerOES) -#define glTexParameterxv GLEW_GET_FUN(__glewTexParameterxv) - -#define GLEW_REGAL_ES1_1_compatibility GLEW_GET_VAR(__GLEW_REGAL_ES1_1_compatibility) - -#endif /* GL_REGAL_ES1_1_compatibility */ - -/* ---------------------------- GL_REGAL_enable ---------------------------- */ - -#ifndef GL_REGAL_enable -#define GL_REGAL_enable 1 - -#define GL_ERROR_REGAL 0x9322 -#define GL_DEBUG_REGAL 0x9323 -#define GL_LOG_REGAL 0x9324 -#define GL_EMULATION_REGAL 0x9325 -#define GL_DRIVER_REGAL 0x9326 -#define GL_MISSING_REGAL 0x9360 -#define GL_TRACE_REGAL 0x9361 -#define GL_CACHE_REGAL 0x9362 -#define GL_CODE_REGAL 0x9363 -#define GL_STATISTICS_REGAL 0x9364 - -#define GLEW_REGAL_enable GLEW_GET_VAR(__GLEW_REGAL_enable) - -#endif /* GL_REGAL_enable */ - -/* ------------------------- GL_REGAL_error_string ------------------------- */ - -#ifndef GL_REGAL_error_string -#define GL_REGAL_error_string 1 - -typedef const GLchar* (GLAPIENTRY * PFNGLERRORSTRINGREGALPROC) (GLenum error); - -#define glErrorStringREGAL GLEW_GET_FUN(__glewErrorStringREGAL) - -#define GLEW_REGAL_error_string GLEW_GET_VAR(__GLEW_REGAL_error_string) - -#endif /* GL_REGAL_error_string */ - -/* ------------------------ GL_REGAL_extension_query ----------------------- */ - -#ifndef GL_REGAL_extension_query -#define GL_REGAL_extension_query 1 - -typedef GLboolean (GLAPIENTRY * PFNGLGETEXTENSIONREGALPROC) (const GLchar* ext); -typedef GLboolean (GLAPIENTRY * PFNGLISSUPPORTEDREGALPROC) (const GLchar* ext); - -#define glGetExtensionREGAL GLEW_GET_FUN(__glewGetExtensionREGAL) -#define glIsSupportedREGAL GLEW_GET_FUN(__glewIsSupportedREGAL) - -#define GLEW_REGAL_extension_query GLEW_GET_VAR(__GLEW_REGAL_extension_query) - -#endif /* GL_REGAL_extension_query */ - -/* ------------------------------ GL_REGAL_log ----------------------------- */ - -#ifndef GL_REGAL_log -#define GL_REGAL_log 1 - -#define GL_LOG_ERROR_REGAL 0x9319 -#define GL_LOG_WARNING_REGAL 0x931A -#define GL_LOG_INFO_REGAL 0x931B -#define GL_LOG_APP_REGAL 0x931C -#define GL_LOG_DRIVER_REGAL 0x931D -#define GL_LOG_INTERNAL_REGAL 0x931E -#define GL_LOG_DEBUG_REGAL 0x931F -#define GL_LOG_STATUS_REGAL 0x9320 -#define GL_LOG_HTTP_REGAL 0x9321 - -typedef void (APIENTRY *GLLOGPROCREGAL)(GLenum stream, GLsizei length, const GLchar *message, void *context); - -typedef void (GLAPIENTRY * PFNGLLOGMESSAGECALLBACKREGALPROC) (GLLOGPROCREGAL callback); - -#define glLogMessageCallbackREGAL GLEW_GET_FUN(__glewLogMessageCallbackREGAL) - -#define GLEW_REGAL_log GLEW_GET_VAR(__GLEW_REGAL_log) - -#endif /* GL_REGAL_log */ - -/* ------------------------- GL_REGAL_proc_address ------------------------- */ - -#ifndef GL_REGAL_proc_address -#define GL_REGAL_proc_address 1 - -typedef void * (GLAPIENTRY * PFNGLGETPROCADDRESSREGALPROC) (const GLchar *name); - -#define glGetProcAddressREGAL GLEW_GET_FUN(__glewGetProcAddressREGAL) - -#define GLEW_REGAL_proc_address GLEW_GET_VAR(__GLEW_REGAL_proc_address) - -#endif /* GL_REGAL_proc_address */ - -/* ----------------------- GL_REND_screen_coordinates ---------------------- */ - -#ifndef GL_REND_screen_coordinates -#define GL_REND_screen_coordinates 1 - -#define GL_SCREEN_COORDINATES_REND 0x8490 -#define GL_INVERTED_SCREEN_W_REND 0x8491 - -#define GLEW_REND_screen_coordinates GLEW_GET_VAR(__GLEW_REND_screen_coordinates) - -#endif /* GL_REND_screen_coordinates */ - -/* ------------------------------- GL_S3_s3tc ------------------------------ */ - -#ifndef GL_S3_s3tc -#define GL_S3_s3tc 1 - -#define GL_RGB_S3TC 0x83A0 -#define GL_RGB4_S3TC 0x83A1 -#define GL_RGBA_S3TC 0x83A2 -#define GL_RGBA4_S3TC 0x83A3 -#define GL_RGBA_DXT5_S3TC 0x83A4 -#define GL_RGBA4_DXT5_S3TC 0x83A5 - -#define GLEW_S3_s3tc GLEW_GET_VAR(__GLEW_S3_s3tc) - -#endif /* GL_S3_s3tc */ - -/* -------------------------- GL_SGIS_color_range -------------------------- */ - -#ifndef GL_SGIS_color_range -#define GL_SGIS_color_range 1 - -#define GL_EXTENDED_RANGE_SGIS 0x85A5 -#define GL_MIN_RED_SGIS 0x85A6 -#define GL_MAX_RED_SGIS 0x85A7 -#define GL_MIN_GREEN_SGIS 0x85A8 -#define GL_MAX_GREEN_SGIS 0x85A9 -#define GL_MIN_BLUE_SGIS 0x85AA -#define GL_MAX_BLUE_SGIS 0x85AB -#define GL_MIN_ALPHA_SGIS 0x85AC -#define GL_MAX_ALPHA_SGIS 0x85AD - -#define GLEW_SGIS_color_range GLEW_GET_VAR(__GLEW_SGIS_color_range) - -#endif /* GL_SGIS_color_range */ - -/* ------------------------- GL_SGIS_detail_texture ------------------------ */ - -#ifndef GL_SGIS_detail_texture -#define GL_SGIS_detail_texture 1 - -typedef void (GLAPIENTRY * PFNGLDETAILTEXFUNCSGISPROC) (GLenum target, GLsizei n, const GLfloat* points); -typedef void (GLAPIENTRY * PFNGLGETDETAILTEXFUNCSGISPROC) (GLenum target, GLfloat* points); - -#define glDetailTexFuncSGIS GLEW_GET_FUN(__glewDetailTexFuncSGIS) -#define glGetDetailTexFuncSGIS GLEW_GET_FUN(__glewGetDetailTexFuncSGIS) - -#define GLEW_SGIS_detail_texture GLEW_GET_VAR(__GLEW_SGIS_detail_texture) - -#endif /* GL_SGIS_detail_texture */ - -/* -------------------------- GL_SGIS_fog_function ------------------------- */ - -#ifndef GL_SGIS_fog_function -#define GL_SGIS_fog_function 1 - -typedef void (GLAPIENTRY * PFNGLFOGFUNCSGISPROC) (GLsizei n, const GLfloat* points); -typedef void (GLAPIENTRY * PFNGLGETFOGFUNCSGISPROC) (GLfloat* points); - -#define glFogFuncSGIS GLEW_GET_FUN(__glewFogFuncSGIS) -#define glGetFogFuncSGIS GLEW_GET_FUN(__glewGetFogFuncSGIS) - -#define GLEW_SGIS_fog_function GLEW_GET_VAR(__GLEW_SGIS_fog_function) - -#endif /* GL_SGIS_fog_function */ - -/* ------------------------ GL_SGIS_generate_mipmap ------------------------ */ - -#ifndef GL_SGIS_generate_mipmap -#define GL_SGIS_generate_mipmap 1 - -#define GL_GENERATE_MIPMAP_SGIS 0x8191 -#define GL_GENERATE_MIPMAP_HINT_SGIS 0x8192 - -#define GLEW_SGIS_generate_mipmap GLEW_GET_VAR(__GLEW_SGIS_generate_mipmap) - -#endif /* GL_SGIS_generate_mipmap */ - -/* -------------------------- GL_SGIS_multisample -------------------------- */ - -#ifndef GL_SGIS_multisample -#define GL_SGIS_multisample 1 - -#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 - -typedef void (GLAPIENTRY * PFNGLSAMPLEMASKSGISPROC) (GLclampf value, GLboolean invert); -typedef void (GLAPIENTRY * PFNGLSAMPLEPATTERNSGISPROC) (GLenum pattern); - -#define glSampleMaskSGIS GLEW_GET_FUN(__glewSampleMaskSGIS) -#define glSamplePatternSGIS GLEW_GET_FUN(__glewSamplePatternSGIS) - -#define GLEW_SGIS_multisample GLEW_GET_VAR(__GLEW_SGIS_multisample) - -#endif /* GL_SGIS_multisample */ - -/* ------------------------- GL_SGIS_pixel_texture ------------------------- */ - -#ifndef GL_SGIS_pixel_texture -#define GL_SGIS_pixel_texture 1 - -#define GLEW_SGIS_pixel_texture GLEW_GET_VAR(__GLEW_SGIS_pixel_texture) - -#endif /* GL_SGIS_pixel_texture */ - -/* ----------------------- GL_SGIS_point_line_texgen ----------------------- */ - -#ifndef GL_SGIS_point_line_texgen -#define GL_SGIS_point_line_texgen 1 - -#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 - -#define GLEW_SGIS_point_line_texgen GLEW_GET_VAR(__GLEW_SGIS_point_line_texgen) - -#endif /* GL_SGIS_point_line_texgen */ - -/* ------------------------ GL_SGIS_sharpen_texture ------------------------ */ - -#ifndef GL_SGIS_sharpen_texture -#define GL_SGIS_sharpen_texture 1 - -typedef void (GLAPIENTRY * PFNGLGETSHARPENTEXFUNCSGISPROC) (GLenum target, GLfloat* points); -typedef void (GLAPIENTRY * PFNGLSHARPENTEXFUNCSGISPROC) (GLenum target, GLsizei n, const GLfloat* points); - -#define glGetSharpenTexFuncSGIS GLEW_GET_FUN(__glewGetSharpenTexFuncSGIS) -#define glSharpenTexFuncSGIS GLEW_GET_FUN(__glewSharpenTexFuncSGIS) - -#define GLEW_SGIS_sharpen_texture GLEW_GET_VAR(__GLEW_SGIS_sharpen_texture) - -#endif /* GL_SGIS_sharpen_texture */ - -/* --------------------------- GL_SGIS_texture4D --------------------------- */ - -#ifndef GL_SGIS_texture4D -#define GL_SGIS_texture4D 1 - -typedef void (GLAPIENTRY * PFNGLTEXIMAGE4DSGISPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLsizei extent, GLint border, GLenum format, GLenum type, const void *pixels); -typedef void (GLAPIENTRY * PFNGLTEXSUBIMAGE4DSGISPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint woffset, GLsizei width, GLsizei height, GLsizei depth, GLsizei extent, GLenum format, GLenum type, const void *pixels); - -#define glTexImage4DSGIS GLEW_GET_FUN(__glewTexImage4DSGIS) -#define glTexSubImage4DSGIS GLEW_GET_FUN(__glewTexSubImage4DSGIS) - -#define GLEW_SGIS_texture4D GLEW_GET_VAR(__GLEW_SGIS_texture4D) - -#endif /* GL_SGIS_texture4D */ - -/* ---------------------- GL_SGIS_texture_border_clamp --------------------- */ - -#ifndef GL_SGIS_texture_border_clamp -#define GL_SGIS_texture_border_clamp 1 - -#define GL_CLAMP_TO_BORDER_SGIS 0x812D - -#define GLEW_SGIS_texture_border_clamp GLEW_GET_VAR(__GLEW_SGIS_texture_border_clamp) - -#endif /* GL_SGIS_texture_border_clamp */ - -/* ----------------------- GL_SGIS_texture_edge_clamp ---------------------- */ - -#ifndef GL_SGIS_texture_edge_clamp -#define GL_SGIS_texture_edge_clamp 1 - -#define GL_CLAMP_TO_EDGE_SGIS 0x812F - -#define GLEW_SGIS_texture_edge_clamp GLEW_GET_VAR(__GLEW_SGIS_texture_edge_clamp) - -#endif /* GL_SGIS_texture_edge_clamp */ - -/* ------------------------ GL_SGIS_texture_filter4 ------------------------ */ - -#ifndef GL_SGIS_texture_filter4 -#define GL_SGIS_texture_filter4 1 - -typedef void (GLAPIENTRY * PFNGLGETTEXFILTERFUNCSGISPROC) (GLenum target, GLenum filter, GLfloat* weights); -typedef void (GLAPIENTRY * PFNGLTEXFILTERFUNCSGISPROC) (GLenum target, GLenum filter, GLsizei n, const GLfloat* weights); - -#define glGetTexFilterFuncSGIS GLEW_GET_FUN(__glewGetTexFilterFuncSGIS) -#define glTexFilterFuncSGIS GLEW_GET_FUN(__glewTexFilterFuncSGIS) - -#define GLEW_SGIS_texture_filter4 GLEW_GET_VAR(__GLEW_SGIS_texture_filter4) - -#endif /* GL_SGIS_texture_filter4 */ - -/* -------------------------- GL_SGIS_texture_lod -------------------------- */ - -#ifndef GL_SGIS_texture_lod -#define GL_SGIS_texture_lod 1 - -#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 - -#define GLEW_SGIS_texture_lod GLEW_GET_VAR(__GLEW_SGIS_texture_lod) - -#endif /* GL_SGIS_texture_lod */ - -/* ------------------------- GL_SGIS_texture_select ------------------------ */ - -#ifndef GL_SGIS_texture_select -#define GL_SGIS_texture_select 1 - -#define GLEW_SGIS_texture_select GLEW_GET_VAR(__GLEW_SGIS_texture_select) - -#endif /* GL_SGIS_texture_select */ - -/* ----------------------------- GL_SGIX_async ----------------------------- */ - -#ifndef GL_SGIX_async -#define GL_SGIX_async 1 - -#define GL_ASYNC_MARKER_SGIX 0x8329 - -typedef void (GLAPIENTRY * PFNGLASYNCMARKERSGIXPROC) (GLuint marker); -typedef void (GLAPIENTRY * PFNGLDELETEASYNCMARKERSSGIXPROC) (GLuint marker, GLsizei range); -typedef GLint (GLAPIENTRY * PFNGLFINISHASYNCSGIXPROC) (GLuint* markerp); -typedef GLuint (GLAPIENTRY * PFNGLGENASYNCMARKERSSGIXPROC) (GLsizei range); -typedef GLboolean (GLAPIENTRY * PFNGLISASYNCMARKERSGIXPROC) (GLuint marker); -typedef GLint (GLAPIENTRY * PFNGLPOLLASYNCSGIXPROC) (GLuint* markerp); - -#define glAsyncMarkerSGIX GLEW_GET_FUN(__glewAsyncMarkerSGIX) -#define glDeleteAsyncMarkersSGIX GLEW_GET_FUN(__glewDeleteAsyncMarkersSGIX) -#define glFinishAsyncSGIX GLEW_GET_FUN(__glewFinishAsyncSGIX) -#define glGenAsyncMarkersSGIX GLEW_GET_FUN(__glewGenAsyncMarkersSGIX) -#define glIsAsyncMarkerSGIX GLEW_GET_FUN(__glewIsAsyncMarkerSGIX) -#define glPollAsyncSGIX GLEW_GET_FUN(__glewPollAsyncSGIX) - -#define GLEW_SGIX_async GLEW_GET_VAR(__GLEW_SGIX_async) - -#endif /* GL_SGIX_async */ - -/* ------------------------ GL_SGIX_async_histogram ------------------------ */ - -#ifndef GL_SGIX_async_histogram -#define GL_SGIX_async_histogram 1 - -#define GL_ASYNC_HISTOGRAM_SGIX 0x832C -#define GL_MAX_ASYNC_HISTOGRAM_SGIX 0x832D - -#define GLEW_SGIX_async_histogram GLEW_GET_VAR(__GLEW_SGIX_async_histogram) - -#endif /* GL_SGIX_async_histogram */ - -/* -------------------------- GL_SGIX_async_pixel -------------------------- */ - -#ifndef GL_SGIX_async_pixel -#define GL_SGIX_async_pixel 1 - -#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 - -#define GLEW_SGIX_async_pixel GLEW_GET_VAR(__GLEW_SGIX_async_pixel) - -#endif /* GL_SGIX_async_pixel */ - -/* ----------------------- GL_SGIX_blend_alpha_minmax ---------------------- */ - -#ifndef GL_SGIX_blend_alpha_minmax -#define GL_SGIX_blend_alpha_minmax 1 - -#define GL_ALPHA_MIN_SGIX 0x8320 -#define GL_ALPHA_MAX_SGIX 0x8321 - -#define GLEW_SGIX_blend_alpha_minmax GLEW_GET_VAR(__GLEW_SGIX_blend_alpha_minmax) - -#endif /* GL_SGIX_blend_alpha_minmax */ - -/* ---------------------------- GL_SGIX_clipmap ---------------------------- */ - -#ifndef GL_SGIX_clipmap -#define GL_SGIX_clipmap 1 - -#define GLEW_SGIX_clipmap GLEW_GET_VAR(__GLEW_SGIX_clipmap) - -#endif /* GL_SGIX_clipmap */ - -/* ---------------------- GL_SGIX_convolution_accuracy --------------------- */ - -#ifndef GL_SGIX_convolution_accuracy -#define GL_SGIX_convolution_accuracy 1 - -#define GL_CONVOLUTION_HINT_SGIX 0x8316 - -#define GLEW_SGIX_convolution_accuracy GLEW_GET_VAR(__GLEW_SGIX_convolution_accuracy) - -#endif /* GL_SGIX_convolution_accuracy */ - -/* ------------------------- GL_SGIX_depth_texture ------------------------- */ - -#ifndef GL_SGIX_depth_texture -#define GL_SGIX_depth_texture 1 - -#define GL_DEPTH_COMPONENT16_SGIX 0x81A5 -#define GL_DEPTH_COMPONENT24_SGIX 0x81A6 -#define GL_DEPTH_COMPONENT32_SGIX 0x81A7 - -#define GLEW_SGIX_depth_texture GLEW_GET_VAR(__GLEW_SGIX_depth_texture) - -#endif /* GL_SGIX_depth_texture */ - -/* -------------------------- GL_SGIX_flush_raster ------------------------- */ - -#ifndef GL_SGIX_flush_raster -#define GL_SGIX_flush_raster 1 - -typedef void (GLAPIENTRY * PFNGLFLUSHRASTERSGIXPROC) (void); - -#define glFlushRasterSGIX GLEW_GET_FUN(__glewFlushRasterSGIX) - -#define GLEW_SGIX_flush_raster GLEW_GET_VAR(__GLEW_SGIX_flush_raster) - -#endif /* GL_SGIX_flush_raster */ - -/* --------------------------- GL_SGIX_fog_offset -------------------------- */ - -#ifndef GL_SGIX_fog_offset -#define GL_SGIX_fog_offset 1 - -#define GL_FOG_OFFSET_SGIX 0x8198 -#define GL_FOG_OFFSET_VALUE_SGIX 0x8199 - -#define GLEW_SGIX_fog_offset GLEW_GET_VAR(__GLEW_SGIX_fog_offset) - -#endif /* GL_SGIX_fog_offset */ - -/* -------------------------- GL_SGIX_fog_texture -------------------------- */ - -#ifndef GL_SGIX_fog_texture -#define GL_SGIX_fog_texture 1 - -typedef void (GLAPIENTRY * PFNGLTEXTUREFOGSGIXPROC) (GLenum pname); - -#define glTextureFogSGIX GLEW_GET_FUN(__glewTextureFogSGIX) - -#define GLEW_SGIX_fog_texture GLEW_GET_VAR(__GLEW_SGIX_fog_texture) - -#endif /* GL_SGIX_fog_texture */ - -/* ------------------- GL_SGIX_fragment_specular_lighting ------------------ */ - -#ifndef GL_SGIX_fragment_specular_lighting -#define GL_SGIX_fragment_specular_lighting 1 - -typedef void (GLAPIENTRY * PFNGLFRAGMENTCOLORMATERIALSGIXPROC) (GLenum face, GLenum mode); -typedef void (GLAPIENTRY * PFNGLFRAGMENTLIGHTMODELFSGIXPROC) (GLenum pname, GLfloat param); -typedef void (GLAPIENTRY * PFNGLFRAGMENTLIGHTMODELFVSGIXPROC) (GLenum pname, GLfloat* params); -typedef void (GLAPIENTRY * PFNGLFRAGMENTLIGHTMODELISGIXPROC) (GLenum pname, GLint param); -typedef void (GLAPIENTRY * PFNGLFRAGMENTLIGHTMODELIVSGIXPROC) (GLenum pname, GLint* params); -typedef void (GLAPIENTRY * PFNGLFRAGMENTLIGHTFSGIXPROC) (GLenum light, GLenum pname, GLfloat param); -typedef void (GLAPIENTRY * PFNGLFRAGMENTLIGHTFVSGIXPROC) (GLenum light, GLenum pname, GLfloat* params); -typedef void (GLAPIENTRY * PFNGLFRAGMENTLIGHTISGIXPROC) (GLenum light, GLenum pname, GLint param); -typedef void (GLAPIENTRY * PFNGLFRAGMENTLIGHTIVSGIXPROC) (GLenum light, GLenum pname, GLint* params); -typedef void (GLAPIENTRY * PFNGLFRAGMENTMATERIALFSGIXPROC) (GLenum face, GLenum pname, const GLfloat param); -typedef void (GLAPIENTRY * PFNGLFRAGMENTMATERIALFVSGIXPROC) (GLenum face, GLenum pname, const GLfloat* params); -typedef void (GLAPIENTRY * PFNGLFRAGMENTMATERIALISGIXPROC) (GLenum face, GLenum pname, const GLint param); -typedef void (GLAPIENTRY * PFNGLFRAGMENTMATERIALIVSGIXPROC) (GLenum face, GLenum pname, const GLint* params); -typedef void (GLAPIENTRY * PFNGLGETFRAGMENTLIGHTFVSGIXPROC) (GLenum light, GLenum value, GLfloat* data); -typedef void (GLAPIENTRY * PFNGLGETFRAGMENTLIGHTIVSGIXPROC) (GLenum light, GLenum value, GLint* data); -typedef void (GLAPIENTRY * PFNGLGETFRAGMENTMATERIALFVSGIXPROC) (GLenum face, GLenum pname, const GLfloat* data); -typedef void (GLAPIENTRY * PFNGLGETFRAGMENTMATERIALIVSGIXPROC) (GLenum face, GLenum pname, const GLint* data); - -#define glFragmentColorMaterialSGIX GLEW_GET_FUN(__glewFragmentColorMaterialSGIX) -#define glFragmentLightModelfSGIX GLEW_GET_FUN(__glewFragmentLightModelfSGIX) -#define glFragmentLightModelfvSGIX GLEW_GET_FUN(__glewFragmentLightModelfvSGIX) -#define glFragmentLightModeliSGIX GLEW_GET_FUN(__glewFragmentLightModeliSGIX) -#define glFragmentLightModelivSGIX GLEW_GET_FUN(__glewFragmentLightModelivSGIX) -#define glFragmentLightfSGIX GLEW_GET_FUN(__glewFragmentLightfSGIX) -#define glFragmentLightfvSGIX GLEW_GET_FUN(__glewFragmentLightfvSGIX) -#define glFragmentLightiSGIX GLEW_GET_FUN(__glewFragmentLightiSGIX) -#define glFragmentLightivSGIX GLEW_GET_FUN(__glewFragmentLightivSGIX) -#define glFragmentMaterialfSGIX GLEW_GET_FUN(__glewFragmentMaterialfSGIX) -#define glFragmentMaterialfvSGIX GLEW_GET_FUN(__glewFragmentMaterialfvSGIX) -#define glFragmentMaterialiSGIX GLEW_GET_FUN(__glewFragmentMaterialiSGIX) -#define glFragmentMaterialivSGIX GLEW_GET_FUN(__glewFragmentMaterialivSGIX) -#define glGetFragmentLightfvSGIX GLEW_GET_FUN(__glewGetFragmentLightfvSGIX) -#define glGetFragmentLightivSGIX GLEW_GET_FUN(__glewGetFragmentLightivSGIX) -#define glGetFragmentMaterialfvSGIX GLEW_GET_FUN(__glewGetFragmentMaterialfvSGIX) -#define glGetFragmentMaterialivSGIX GLEW_GET_FUN(__glewGetFragmentMaterialivSGIX) - -#define GLEW_SGIX_fragment_specular_lighting GLEW_GET_VAR(__GLEW_SGIX_fragment_specular_lighting) - -#endif /* GL_SGIX_fragment_specular_lighting */ - -/* --------------------------- GL_SGIX_framezoom --------------------------- */ - -#ifndef GL_SGIX_framezoom -#define GL_SGIX_framezoom 1 - -typedef void (GLAPIENTRY * PFNGLFRAMEZOOMSGIXPROC) (GLint factor); - -#define glFrameZoomSGIX GLEW_GET_FUN(__glewFrameZoomSGIX) - -#define GLEW_SGIX_framezoom GLEW_GET_VAR(__GLEW_SGIX_framezoom) - -#endif /* GL_SGIX_framezoom */ - -/* --------------------------- GL_SGIX_interlace --------------------------- */ - -#ifndef GL_SGIX_interlace -#define GL_SGIX_interlace 1 - -#define GL_INTERLACE_SGIX 0x8094 - -#define GLEW_SGIX_interlace GLEW_GET_VAR(__GLEW_SGIX_interlace) - -#endif /* GL_SGIX_interlace */ - -/* ------------------------- GL_SGIX_ir_instrument1 ------------------------ */ - -#ifndef GL_SGIX_ir_instrument1 -#define GL_SGIX_ir_instrument1 1 - -#define GLEW_SGIX_ir_instrument1 GLEW_GET_VAR(__GLEW_SGIX_ir_instrument1) - -#endif /* GL_SGIX_ir_instrument1 */ - -/* ------------------------- GL_SGIX_list_priority ------------------------- */ - -#ifndef GL_SGIX_list_priority -#define GL_SGIX_list_priority 1 - -#define GLEW_SGIX_list_priority GLEW_GET_VAR(__GLEW_SGIX_list_priority) - -#endif /* GL_SGIX_list_priority */ - -/* ------------------------- GL_SGIX_pixel_texture ------------------------- */ - -#ifndef GL_SGIX_pixel_texture -#define GL_SGIX_pixel_texture 1 - -typedef void (GLAPIENTRY * PFNGLPIXELTEXGENSGIXPROC) (GLenum mode); - -#define glPixelTexGenSGIX GLEW_GET_FUN(__glewPixelTexGenSGIX) - -#define GLEW_SGIX_pixel_texture GLEW_GET_VAR(__GLEW_SGIX_pixel_texture) - -#endif /* GL_SGIX_pixel_texture */ - -/* ----------------------- GL_SGIX_pixel_texture_bits ---------------------- */ - -#ifndef GL_SGIX_pixel_texture_bits -#define GL_SGIX_pixel_texture_bits 1 - -#define GLEW_SGIX_pixel_texture_bits GLEW_GET_VAR(__GLEW_SGIX_pixel_texture_bits) - -#endif /* GL_SGIX_pixel_texture_bits */ - -/* ------------------------ GL_SGIX_reference_plane ------------------------ */ - -#ifndef GL_SGIX_reference_plane -#define GL_SGIX_reference_plane 1 - -typedef void (GLAPIENTRY * PFNGLREFERENCEPLANESGIXPROC) (const GLdouble* equation); - -#define glReferencePlaneSGIX GLEW_GET_FUN(__glewReferencePlaneSGIX) - -#define GLEW_SGIX_reference_plane GLEW_GET_VAR(__GLEW_SGIX_reference_plane) - -#endif /* GL_SGIX_reference_plane */ - -/* ---------------------------- GL_SGIX_resample --------------------------- */ - -#ifndef GL_SGIX_resample -#define GL_SGIX_resample 1 - -#define GL_PACK_RESAMPLE_SGIX 0x842E -#define GL_UNPACK_RESAMPLE_SGIX 0x842F -#define GL_RESAMPLE_DECIMATE_SGIX 0x8430 -#define GL_RESAMPLE_REPLICATE_SGIX 0x8433 -#define GL_RESAMPLE_ZERO_FILL_SGIX 0x8434 - -#define GLEW_SGIX_resample GLEW_GET_VAR(__GLEW_SGIX_resample) - -#endif /* GL_SGIX_resample */ - -/* ----------------------------- GL_SGIX_shadow ---------------------------- */ - -#ifndef GL_SGIX_shadow -#define GL_SGIX_shadow 1 - -#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 - -#define GLEW_SGIX_shadow GLEW_GET_VAR(__GLEW_SGIX_shadow) - -#endif /* GL_SGIX_shadow */ - -/* ------------------------- GL_SGIX_shadow_ambient ------------------------ */ - -#ifndef GL_SGIX_shadow_ambient -#define GL_SGIX_shadow_ambient 1 - -#define GL_SHADOW_AMBIENT_SGIX 0x80BF - -#define GLEW_SGIX_shadow_ambient GLEW_GET_VAR(__GLEW_SGIX_shadow_ambient) - -#endif /* GL_SGIX_shadow_ambient */ - -/* ----------------------------- GL_SGIX_sprite ---------------------------- */ - -#ifndef GL_SGIX_sprite -#define GL_SGIX_sprite 1 - -typedef void (GLAPIENTRY * PFNGLSPRITEPARAMETERFSGIXPROC) (GLenum pname, GLfloat param); -typedef void (GLAPIENTRY * PFNGLSPRITEPARAMETERFVSGIXPROC) (GLenum pname, GLfloat* params); -typedef void (GLAPIENTRY * PFNGLSPRITEPARAMETERISGIXPROC) (GLenum pname, GLint param); -typedef void (GLAPIENTRY * PFNGLSPRITEPARAMETERIVSGIXPROC) (GLenum pname, GLint* params); - -#define glSpriteParameterfSGIX GLEW_GET_FUN(__glewSpriteParameterfSGIX) -#define glSpriteParameterfvSGIX GLEW_GET_FUN(__glewSpriteParameterfvSGIX) -#define glSpriteParameteriSGIX GLEW_GET_FUN(__glewSpriteParameteriSGIX) -#define glSpriteParameterivSGIX GLEW_GET_FUN(__glewSpriteParameterivSGIX) - -#define GLEW_SGIX_sprite GLEW_GET_VAR(__GLEW_SGIX_sprite) - -#endif /* GL_SGIX_sprite */ - -/* ----------------------- GL_SGIX_tag_sample_buffer ----------------------- */ - -#ifndef GL_SGIX_tag_sample_buffer -#define GL_SGIX_tag_sample_buffer 1 - -typedef void (GLAPIENTRY * PFNGLTAGSAMPLEBUFFERSGIXPROC) (void); - -#define glTagSampleBufferSGIX GLEW_GET_FUN(__glewTagSampleBufferSGIX) - -#define GLEW_SGIX_tag_sample_buffer GLEW_GET_VAR(__GLEW_SGIX_tag_sample_buffer) - -#endif /* GL_SGIX_tag_sample_buffer */ - -/* ------------------------ GL_SGIX_texture_add_env ------------------------ */ - -#ifndef GL_SGIX_texture_add_env -#define GL_SGIX_texture_add_env 1 - -#define GLEW_SGIX_texture_add_env GLEW_GET_VAR(__GLEW_SGIX_texture_add_env) - -#endif /* GL_SGIX_texture_add_env */ - -/* -------------------- GL_SGIX_texture_coordinate_clamp ------------------- */ - -#ifndef GL_SGIX_texture_coordinate_clamp -#define GL_SGIX_texture_coordinate_clamp 1 - -#define GL_TEXTURE_MAX_CLAMP_S_SGIX 0x8369 -#define GL_TEXTURE_MAX_CLAMP_T_SGIX 0x836A -#define GL_TEXTURE_MAX_CLAMP_R_SGIX 0x836B - -#define GLEW_SGIX_texture_coordinate_clamp GLEW_GET_VAR(__GLEW_SGIX_texture_coordinate_clamp) - -#endif /* GL_SGIX_texture_coordinate_clamp */ - -/* ------------------------ GL_SGIX_texture_lod_bias ----------------------- */ - -#ifndef GL_SGIX_texture_lod_bias -#define GL_SGIX_texture_lod_bias 1 - -#define GLEW_SGIX_texture_lod_bias GLEW_GET_VAR(__GLEW_SGIX_texture_lod_bias) - -#endif /* GL_SGIX_texture_lod_bias */ - -/* ---------------------- GL_SGIX_texture_multi_buffer --------------------- */ - -#ifndef GL_SGIX_texture_multi_buffer -#define GL_SGIX_texture_multi_buffer 1 - -#define GL_TEXTURE_MULTI_BUFFER_HINT_SGIX 0x812E - -#define GLEW_SGIX_texture_multi_buffer GLEW_GET_VAR(__GLEW_SGIX_texture_multi_buffer) - -#endif /* GL_SGIX_texture_multi_buffer */ - -/* ------------------------- GL_SGIX_texture_range ------------------------- */ - -#ifndef GL_SGIX_texture_range -#define GL_SGIX_texture_range 1 - -#define GL_RGB_SIGNED_SGIX 0x85E0 -#define GL_RGBA_SIGNED_SGIX 0x85E1 -#define GL_ALPHA_SIGNED_SGIX 0x85E2 -#define GL_LUMINANCE_SIGNED_SGIX 0x85E3 -#define GL_INTENSITY_SIGNED_SGIX 0x85E4 -#define GL_LUMINANCE_ALPHA_SIGNED_SGIX 0x85E5 -#define GL_RGB16_SIGNED_SGIX 0x85E6 -#define GL_RGBA16_SIGNED_SGIX 0x85E7 -#define GL_ALPHA16_SIGNED_SGIX 0x85E8 -#define GL_LUMINANCE16_SIGNED_SGIX 0x85E9 -#define GL_INTENSITY16_SIGNED_SGIX 0x85EA -#define GL_LUMINANCE16_ALPHA16_SIGNED_SGIX 0x85EB -#define GL_RGB_EXTENDED_RANGE_SGIX 0x85EC -#define GL_RGBA_EXTENDED_RANGE_SGIX 0x85ED -#define GL_ALPHA_EXTENDED_RANGE_SGIX 0x85EE -#define GL_LUMINANCE_EXTENDED_RANGE_SGIX 0x85EF -#define GL_INTENSITY_EXTENDED_RANGE_SGIX 0x85F0 -#define GL_LUMINANCE_ALPHA_EXTENDED_RANGE_SGIX 0x85F1 -#define GL_RGB16_EXTENDED_RANGE_SGIX 0x85F2 -#define GL_RGBA16_EXTENDED_RANGE_SGIX 0x85F3 -#define GL_ALPHA16_EXTENDED_RANGE_SGIX 0x85F4 -#define GL_LUMINANCE16_EXTENDED_RANGE_SGIX 0x85F5 -#define GL_INTENSITY16_EXTENDED_RANGE_SGIX 0x85F6 -#define GL_LUMINANCE16_ALPHA16_EXTENDED_RANGE_SGIX 0x85F7 -#define GL_MIN_LUMINANCE_SGIS 0x85F8 -#define GL_MAX_LUMINANCE_SGIS 0x85F9 -#define GL_MIN_INTENSITY_SGIS 0x85FA -#define GL_MAX_INTENSITY_SGIS 0x85FB - -#define GLEW_SGIX_texture_range GLEW_GET_VAR(__GLEW_SGIX_texture_range) - -#endif /* GL_SGIX_texture_range */ - -/* ----------------------- GL_SGIX_texture_scale_bias ---------------------- */ - -#ifndef GL_SGIX_texture_scale_bias -#define GL_SGIX_texture_scale_bias 1 - -#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 - -#define GLEW_SGIX_texture_scale_bias GLEW_GET_VAR(__GLEW_SGIX_texture_scale_bias) - -#endif /* GL_SGIX_texture_scale_bias */ - -/* ------------------------- GL_SGIX_vertex_preclip ------------------------ */ - -#ifndef GL_SGIX_vertex_preclip -#define GL_SGIX_vertex_preclip 1 - -#define GL_VERTEX_PRECLIP_SGIX 0x83EE -#define GL_VERTEX_PRECLIP_HINT_SGIX 0x83EF - -#define GLEW_SGIX_vertex_preclip GLEW_GET_VAR(__GLEW_SGIX_vertex_preclip) - -#endif /* GL_SGIX_vertex_preclip */ - -/* ---------------------- GL_SGIX_vertex_preclip_hint ---------------------- */ - -#ifndef GL_SGIX_vertex_preclip_hint -#define GL_SGIX_vertex_preclip_hint 1 - -#define GL_VERTEX_PRECLIP_SGIX 0x83EE -#define GL_VERTEX_PRECLIP_HINT_SGIX 0x83EF - -#define GLEW_SGIX_vertex_preclip_hint GLEW_GET_VAR(__GLEW_SGIX_vertex_preclip_hint) - -#endif /* GL_SGIX_vertex_preclip_hint */ - -/* ----------------------------- GL_SGIX_ycrcb ----------------------------- */ - -#ifndef GL_SGIX_ycrcb -#define GL_SGIX_ycrcb 1 - -#define GLEW_SGIX_ycrcb GLEW_GET_VAR(__GLEW_SGIX_ycrcb) - -#endif /* GL_SGIX_ycrcb */ - -/* -------------------------- GL_SGI_color_matrix -------------------------- */ - -#ifndef GL_SGI_color_matrix -#define GL_SGI_color_matrix 1 - -#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 - -#define GLEW_SGI_color_matrix GLEW_GET_VAR(__GLEW_SGI_color_matrix) - -#endif /* GL_SGI_color_matrix */ - -/* --------------------------- GL_SGI_color_table -------------------------- */ - -#ifndef GL_SGI_color_table -#define GL_SGI_color_table 1 - -#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 - -typedef void (GLAPIENTRY * PFNGLCOLORTABLEPARAMETERFVSGIPROC) (GLenum target, GLenum pname, const GLfloat* params); -typedef void (GLAPIENTRY * PFNGLCOLORTABLEPARAMETERIVSGIPROC) (GLenum target, GLenum pname, const GLint* params); -typedef void (GLAPIENTRY * PFNGLCOLORTABLESGIPROC) (GLenum target, GLenum internalformat, GLsizei width, GLenum format, GLenum type, const void *table); -typedef void (GLAPIENTRY * PFNGLCOPYCOLORTABLESGIPROC) (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width); -typedef void (GLAPIENTRY * PFNGLGETCOLORTABLEPARAMETERFVSGIPROC) (GLenum target, GLenum pname, GLfloat* params); -typedef void (GLAPIENTRY * PFNGLGETCOLORTABLEPARAMETERIVSGIPROC) (GLenum target, GLenum pname, GLint* params); -typedef void (GLAPIENTRY * PFNGLGETCOLORTABLESGIPROC) (GLenum target, GLenum format, GLenum type, void *table); - -#define glColorTableParameterfvSGI GLEW_GET_FUN(__glewColorTableParameterfvSGI) -#define glColorTableParameterivSGI GLEW_GET_FUN(__glewColorTableParameterivSGI) -#define glColorTableSGI GLEW_GET_FUN(__glewColorTableSGI) -#define glCopyColorTableSGI GLEW_GET_FUN(__glewCopyColorTableSGI) -#define glGetColorTableParameterfvSGI GLEW_GET_FUN(__glewGetColorTableParameterfvSGI) -#define glGetColorTableParameterivSGI GLEW_GET_FUN(__glewGetColorTableParameterivSGI) -#define glGetColorTableSGI GLEW_GET_FUN(__glewGetColorTableSGI) - -#define GLEW_SGI_color_table GLEW_GET_VAR(__GLEW_SGI_color_table) - -#endif /* GL_SGI_color_table */ - -/* ----------------------- GL_SGI_texture_color_table ---------------------- */ - -#ifndef GL_SGI_texture_color_table -#define GL_SGI_texture_color_table 1 - -#define GL_TEXTURE_COLOR_TABLE_SGI 0x80BC -#define GL_PROXY_TEXTURE_COLOR_TABLE_SGI 0x80BD - -#define GLEW_SGI_texture_color_table GLEW_GET_VAR(__GLEW_SGI_texture_color_table) - -#endif /* GL_SGI_texture_color_table */ - -/* ------------------------- GL_SUNX_constant_data ------------------------- */ - -#ifndef GL_SUNX_constant_data -#define GL_SUNX_constant_data 1 - -#define GL_UNPACK_CONSTANT_DATA_SUNX 0x81D5 -#define GL_TEXTURE_CONSTANT_DATA_SUNX 0x81D6 - -typedef void (GLAPIENTRY * PFNGLFINISHTEXTURESUNXPROC) (void); - -#define glFinishTextureSUNX GLEW_GET_FUN(__glewFinishTextureSUNX) - -#define GLEW_SUNX_constant_data GLEW_GET_VAR(__GLEW_SUNX_constant_data) - -#endif /* GL_SUNX_constant_data */ - -/* -------------------- GL_SUN_convolution_border_modes -------------------- */ - -#ifndef GL_SUN_convolution_border_modes -#define GL_SUN_convolution_border_modes 1 - -#define GL_WRAP_BORDER_SUN 0x81D4 - -#define GLEW_SUN_convolution_border_modes GLEW_GET_VAR(__GLEW_SUN_convolution_border_modes) - -#endif /* GL_SUN_convolution_border_modes */ - -/* -------------------------- GL_SUN_global_alpha -------------------------- */ - -#ifndef GL_SUN_global_alpha -#define GL_SUN_global_alpha 1 - -#define GL_GLOBAL_ALPHA_SUN 0x81D9 -#define GL_GLOBAL_ALPHA_FACTOR_SUN 0x81DA - -typedef void (GLAPIENTRY * PFNGLGLOBALALPHAFACTORBSUNPROC) (GLbyte factor); -typedef void (GLAPIENTRY * PFNGLGLOBALALPHAFACTORDSUNPROC) (GLdouble factor); -typedef void (GLAPIENTRY * PFNGLGLOBALALPHAFACTORFSUNPROC) (GLfloat factor); -typedef void (GLAPIENTRY * PFNGLGLOBALALPHAFACTORISUNPROC) (GLint factor); -typedef void (GLAPIENTRY * PFNGLGLOBALALPHAFACTORSSUNPROC) (GLshort factor); -typedef void (GLAPIENTRY * PFNGLGLOBALALPHAFACTORUBSUNPROC) (GLubyte factor); -typedef void (GLAPIENTRY * PFNGLGLOBALALPHAFACTORUISUNPROC) (GLuint factor); -typedef void (GLAPIENTRY * PFNGLGLOBALALPHAFACTORUSSUNPROC) (GLushort factor); - -#define glGlobalAlphaFactorbSUN GLEW_GET_FUN(__glewGlobalAlphaFactorbSUN) -#define glGlobalAlphaFactordSUN GLEW_GET_FUN(__glewGlobalAlphaFactordSUN) -#define glGlobalAlphaFactorfSUN GLEW_GET_FUN(__glewGlobalAlphaFactorfSUN) -#define glGlobalAlphaFactoriSUN GLEW_GET_FUN(__glewGlobalAlphaFactoriSUN) -#define glGlobalAlphaFactorsSUN GLEW_GET_FUN(__glewGlobalAlphaFactorsSUN) -#define glGlobalAlphaFactorubSUN GLEW_GET_FUN(__glewGlobalAlphaFactorubSUN) -#define glGlobalAlphaFactoruiSUN GLEW_GET_FUN(__glewGlobalAlphaFactoruiSUN) -#define glGlobalAlphaFactorusSUN GLEW_GET_FUN(__glewGlobalAlphaFactorusSUN) - -#define GLEW_SUN_global_alpha GLEW_GET_VAR(__GLEW_SUN_global_alpha) - -#endif /* GL_SUN_global_alpha */ - -/* --------------------------- GL_SUN_mesh_array --------------------------- */ - -#ifndef GL_SUN_mesh_array -#define GL_SUN_mesh_array 1 - -#define GL_QUAD_MESH_SUN 0x8614 -#define GL_TRIANGLE_MESH_SUN 0x8615 - -#define GLEW_SUN_mesh_array GLEW_GET_VAR(__GLEW_SUN_mesh_array) - -#endif /* GL_SUN_mesh_array */ - -/* ------------------------ GL_SUN_read_video_pixels ----------------------- */ - -#ifndef GL_SUN_read_video_pixels -#define GL_SUN_read_video_pixels 1 - -typedef void (GLAPIENTRY * PFNGLREADVIDEOPIXELSSUNPROC) (GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, void* pixels); - -#define glReadVideoPixelsSUN GLEW_GET_FUN(__glewReadVideoPixelsSUN) - -#define GLEW_SUN_read_video_pixels GLEW_GET_VAR(__GLEW_SUN_read_video_pixels) - -#endif /* GL_SUN_read_video_pixels */ - -/* --------------------------- GL_SUN_slice_accum -------------------------- */ - -#ifndef GL_SUN_slice_accum -#define GL_SUN_slice_accum 1 - -#define GL_SLICE_ACCUM_SUN 0x85CC - -#define GLEW_SUN_slice_accum GLEW_GET_VAR(__GLEW_SUN_slice_accum) - -#endif /* GL_SUN_slice_accum */ - -/* -------------------------- GL_SUN_triangle_list ------------------------- */ - -#ifndef GL_SUN_triangle_list -#define GL_SUN_triangle_list 1 - -#define GL_RESTART_SUN 0x01 -#define GL_REPLACE_MIDDLE_SUN 0x02 -#define GL_REPLACE_OLDEST_SUN 0x03 -#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 - -typedef void (GLAPIENTRY * PFNGLREPLACEMENTCODEPOINTERSUNPROC) (GLenum type, GLsizei stride, const void *pointer); -typedef void (GLAPIENTRY * PFNGLREPLACEMENTCODEUBSUNPROC) (GLubyte code); -typedef void (GLAPIENTRY * PFNGLREPLACEMENTCODEUBVSUNPROC) (const GLubyte* code); -typedef void (GLAPIENTRY * PFNGLREPLACEMENTCODEUISUNPROC) (GLuint code); -typedef void (GLAPIENTRY * PFNGLREPLACEMENTCODEUIVSUNPROC) (const GLuint* code); -typedef void (GLAPIENTRY * PFNGLREPLACEMENTCODEUSSUNPROC) (GLushort code); -typedef void (GLAPIENTRY * PFNGLREPLACEMENTCODEUSVSUNPROC) (const GLushort* code); - -#define glReplacementCodePointerSUN GLEW_GET_FUN(__glewReplacementCodePointerSUN) -#define glReplacementCodeubSUN GLEW_GET_FUN(__glewReplacementCodeubSUN) -#define glReplacementCodeubvSUN GLEW_GET_FUN(__glewReplacementCodeubvSUN) -#define glReplacementCodeuiSUN GLEW_GET_FUN(__glewReplacementCodeuiSUN) -#define glReplacementCodeuivSUN GLEW_GET_FUN(__glewReplacementCodeuivSUN) -#define glReplacementCodeusSUN GLEW_GET_FUN(__glewReplacementCodeusSUN) -#define glReplacementCodeusvSUN GLEW_GET_FUN(__glewReplacementCodeusvSUN) - -#define GLEW_SUN_triangle_list GLEW_GET_VAR(__GLEW_SUN_triangle_list) - -#endif /* GL_SUN_triangle_list */ - -/* ----------------------------- GL_SUN_vertex ----------------------------- */ - -#ifndef GL_SUN_vertex -#define GL_SUN_vertex 1 - -typedef void (GLAPIENTRY * PFNGLCOLOR3FVERTEX3FSUNPROC) (GLfloat r, GLfloat g, GLfloat b, GLfloat x, GLfloat y, GLfloat z); -typedef void (GLAPIENTRY * PFNGLCOLOR3FVERTEX3FVSUNPROC) (const GLfloat* c, const GLfloat *v); -typedef void (GLAPIENTRY * PFNGLCOLOR4FNORMAL3FVERTEX3FSUNPROC) (GLfloat r, GLfloat g, GLfloat b, GLfloat a, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); -typedef void (GLAPIENTRY * PFNGLCOLOR4FNORMAL3FVERTEX3FVSUNPROC) (const GLfloat* c, const GLfloat *n, const GLfloat *v); -typedef void (GLAPIENTRY * PFNGLCOLOR4UBVERTEX2FSUNPROC) (GLubyte r, GLubyte g, GLubyte b, GLubyte a, GLfloat x, GLfloat y); -typedef void (GLAPIENTRY * PFNGLCOLOR4UBVERTEX2FVSUNPROC) (const GLubyte* c, const GLfloat *v); -typedef void (GLAPIENTRY * PFNGLCOLOR4UBVERTEX3FSUNPROC) (GLubyte r, GLubyte g, GLubyte b, GLubyte a, GLfloat x, GLfloat y, GLfloat z); -typedef void (GLAPIENTRY * PFNGLCOLOR4UBVERTEX3FVSUNPROC) (const GLubyte* c, const GLfloat *v); -typedef void (GLAPIENTRY * PFNGLNORMAL3FVERTEX3FSUNPROC) (GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); -typedef void (GLAPIENTRY * PFNGLNORMAL3FVERTEX3FVSUNPROC) (const GLfloat* n, const GLfloat *v); -typedef void (GLAPIENTRY * PFNGLREPLACEMENTCODEUICOLOR3FVERTEX3FSUNPROC) (GLuint rc, GLfloat r, GLfloat g, GLfloat b, GLfloat x, GLfloat y, GLfloat z); -typedef void (GLAPIENTRY * PFNGLREPLACEMENTCODEUICOLOR3FVERTEX3FVSUNPROC) (const GLuint* rc, const GLfloat *c, const GLfloat *v); -typedef void (GLAPIENTRY * 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 (GLAPIENTRY * PFNGLREPLACEMENTCODEUICOLOR4FNORMAL3FVERTEX3FVSUNPROC) (const GLuint* rc, const GLfloat *c, const GLfloat *n, const GLfloat *v); -typedef void (GLAPIENTRY * PFNGLREPLACEMENTCODEUICOLOR4UBVERTEX3FSUNPROC) (GLuint rc, GLubyte r, GLubyte g, GLubyte b, GLubyte a, GLfloat x, GLfloat y, GLfloat z); -typedef void (GLAPIENTRY * PFNGLREPLACEMENTCODEUICOLOR4UBVERTEX3FVSUNPROC) (const GLuint* rc, const GLubyte *c, const GLfloat *v); -typedef void (GLAPIENTRY * PFNGLREPLACEMENTCODEUINORMAL3FVERTEX3FSUNPROC) (GLuint rc, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); -typedef void (GLAPIENTRY * PFNGLREPLACEMENTCODEUINORMAL3FVERTEX3FVSUNPROC) (const GLuint* rc, const GLfloat *n, const GLfloat *v); -typedef void (GLAPIENTRY * 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 (GLAPIENTRY * PFNGLREPLACEMENTCODEUITEXCOORD2FCOLOR4FNORMAL3FVERTEX3FVSUNPROC) (const GLuint* rc, const GLfloat *tc, const GLfloat *c, const GLfloat *n, const GLfloat *v); -typedef void (GLAPIENTRY * PFNGLREPLACEMENTCODEUITEXCOORD2FNORMAL3FVERTEX3FSUNPROC) (GLuint rc, GLfloat s, GLfloat t, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); -typedef void (GLAPIENTRY * PFNGLREPLACEMENTCODEUITEXCOORD2FNORMAL3FVERTEX3FVSUNPROC) (const GLuint* rc, const GLfloat *tc, const GLfloat *n, const GLfloat *v); -typedef void (GLAPIENTRY * PFNGLREPLACEMENTCODEUITEXCOORD2FVERTEX3FSUNPROC) (GLuint rc, GLfloat s, GLfloat t, GLfloat x, GLfloat y, GLfloat z); -typedef void (GLAPIENTRY * PFNGLREPLACEMENTCODEUITEXCOORD2FVERTEX3FVSUNPROC) (const GLuint* rc, const GLfloat *tc, const GLfloat *v); -typedef void (GLAPIENTRY * PFNGLREPLACEMENTCODEUIVERTEX3FSUNPROC) (GLuint rc, GLfloat x, GLfloat y, GLfloat z); -typedef void (GLAPIENTRY * PFNGLREPLACEMENTCODEUIVERTEX3FVSUNPROC) (const GLuint* rc, const GLfloat *v); -typedef void (GLAPIENTRY * PFNGLTEXCOORD2FCOLOR3FVERTEX3FSUNPROC) (GLfloat s, GLfloat t, GLfloat r, GLfloat g, GLfloat b, GLfloat x, GLfloat y, GLfloat z); -typedef void (GLAPIENTRY * PFNGLTEXCOORD2FCOLOR3FVERTEX3FVSUNPROC) (const GLfloat* tc, const GLfloat *c, const GLfloat *v); -typedef void (GLAPIENTRY * 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 (GLAPIENTRY * PFNGLTEXCOORD2FCOLOR4FNORMAL3FVERTEX3FVSUNPROC) (const GLfloat* tc, const GLfloat *c, const GLfloat *n, const GLfloat *v); -typedef void (GLAPIENTRY * PFNGLTEXCOORD2FCOLOR4UBVERTEX3FSUNPROC) (GLfloat s, GLfloat t, GLubyte r, GLubyte g, GLubyte b, GLubyte a, GLfloat x, GLfloat y, GLfloat z); -typedef void (GLAPIENTRY * PFNGLTEXCOORD2FCOLOR4UBVERTEX3FVSUNPROC) (const GLfloat* tc, const GLubyte *c, const GLfloat *v); -typedef void (GLAPIENTRY * PFNGLTEXCOORD2FNORMAL3FVERTEX3FSUNPROC) (GLfloat s, GLfloat t, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); -typedef void (GLAPIENTRY * PFNGLTEXCOORD2FNORMAL3FVERTEX3FVSUNPROC) (const GLfloat* tc, const GLfloat *n, const GLfloat *v); -typedef void (GLAPIENTRY * PFNGLTEXCOORD2FVERTEX3FSUNPROC) (GLfloat s, GLfloat t, GLfloat x, GLfloat y, GLfloat z); -typedef void (GLAPIENTRY * PFNGLTEXCOORD2FVERTEX3FVSUNPROC) (const GLfloat* tc, const GLfloat *v); -typedef void (GLAPIENTRY * 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 (GLAPIENTRY * PFNGLTEXCOORD4FCOLOR4FNORMAL3FVERTEX4FVSUNPROC) (const GLfloat* tc, const GLfloat *c, const GLfloat *n, const GLfloat *v); -typedef void (GLAPIENTRY * PFNGLTEXCOORD4FVERTEX4FSUNPROC) (GLfloat s, GLfloat t, GLfloat p, GLfloat q, GLfloat x, GLfloat y, GLfloat z, GLfloat w); -typedef void (GLAPIENTRY * PFNGLTEXCOORD4FVERTEX4FVSUNPROC) (const GLfloat* tc, const GLfloat *v); - -#define glColor3fVertex3fSUN GLEW_GET_FUN(__glewColor3fVertex3fSUN) -#define glColor3fVertex3fvSUN GLEW_GET_FUN(__glewColor3fVertex3fvSUN) -#define glColor4fNormal3fVertex3fSUN GLEW_GET_FUN(__glewColor4fNormal3fVertex3fSUN) -#define glColor4fNormal3fVertex3fvSUN GLEW_GET_FUN(__glewColor4fNormal3fVertex3fvSUN) -#define glColor4ubVertex2fSUN GLEW_GET_FUN(__glewColor4ubVertex2fSUN) -#define glColor4ubVertex2fvSUN GLEW_GET_FUN(__glewColor4ubVertex2fvSUN) -#define glColor4ubVertex3fSUN GLEW_GET_FUN(__glewColor4ubVertex3fSUN) -#define glColor4ubVertex3fvSUN GLEW_GET_FUN(__glewColor4ubVertex3fvSUN) -#define glNormal3fVertex3fSUN GLEW_GET_FUN(__glewNormal3fVertex3fSUN) -#define glNormal3fVertex3fvSUN GLEW_GET_FUN(__glewNormal3fVertex3fvSUN) -#define glReplacementCodeuiColor3fVertex3fSUN GLEW_GET_FUN(__glewReplacementCodeuiColor3fVertex3fSUN) -#define glReplacementCodeuiColor3fVertex3fvSUN GLEW_GET_FUN(__glewReplacementCodeuiColor3fVertex3fvSUN) -#define glReplacementCodeuiColor4fNormal3fVertex3fSUN GLEW_GET_FUN(__glewReplacementCodeuiColor4fNormal3fVertex3fSUN) -#define glReplacementCodeuiColor4fNormal3fVertex3fvSUN GLEW_GET_FUN(__glewReplacementCodeuiColor4fNormal3fVertex3fvSUN) -#define glReplacementCodeuiColor4ubVertex3fSUN GLEW_GET_FUN(__glewReplacementCodeuiColor4ubVertex3fSUN) -#define glReplacementCodeuiColor4ubVertex3fvSUN GLEW_GET_FUN(__glewReplacementCodeuiColor4ubVertex3fvSUN) -#define glReplacementCodeuiNormal3fVertex3fSUN GLEW_GET_FUN(__glewReplacementCodeuiNormal3fVertex3fSUN) -#define glReplacementCodeuiNormal3fVertex3fvSUN GLEW_GET_FUN(__glewReplacementCodeuiNormal3fVertex3fvSUN) -#define glReplacementCodeuiTexCoord2fColor4fNormal3fVertex3fSUN GLEW_GET_FUN(__glewReplacementCodeuiTexCoord2fColor4fNormal3fVertex3fSUN) -#define glReplacementCodeuiTexCoord2fColor4fNormal3fVertex3fvSUN GLEW_GET_FUN(__glewReplacementCodeuiTexCoord2fColor4fNormal3fVertex3fvSUN) -#define glReplacementCodeuiTexCoord2fNormal3fVertex3fSUN GLEW_GET_FUN(__glewReplacementCodeuiTexCoord2fNormal3fVertex3fSUN) -#define glReplacementCodeuiTexCoord2fNormal3fVertex3fvSUN GLEW_GET_FUN(__glewReplacementCodeuiTexCoord2fNormal3fVertex3fvSUN) -#define glReplacementCodeuiTexCoord2fVertex3fSUN GLEW_GET_FUN(__glewReplacementCodeuiTexCoord2fVertex3fSUN) -#define glReplacementCodeuiTexCoord2fVertex3fvSUN GLEW_GET_FUN(__glewReplacementCodeuiTexCoord2fVertex3fvSUN) -#define glReplacementCodeuiVertex3fSUN GLEW_GET_FUN(__glewReplacementCodeuiVertex3fSUN) -#define glReplacementCodeuiVertex3fvSUN GLEW_GET_FUN(__glewReplacementCodeuiVertex3fvSUN) -#define glTexCoord2fColor3fVertex3fSUN GLEW_GET_FUN(__glewTexCoord2fColor3fVertex3fSUN) -#define glTexCoord2fColor3fVertex3fvSUN GLEW_GET_FUN(__glewTexCoord2fColor3fVertex3fvSUN) -#define glTexCoord2fColor4fNormal3fVertex3fSUN GLEW_GET_FUN(__glewTexCoord2fColor4fNormal3fVertex3fSUN) -#define glTexCoord2fColor4fNormal3fVertex3fvSUN GLEW_GET_FUN(__glewTexCoord2fColor4fNormal3fVertex3fvSUN) -#define glTexCoord2fColor4ubVertex3fSUN GLEW_GET_FUN(__glewTexCoord2fColor4ubVertex3fSUN) -#define glTexCoord2fColor4ubVertex3fvSUN GLEW_GET_FUN(__glewTexCoord2fColor4ubVertex3fvSUN) -#define glTexCoord2fNormal3fVertex3fSUN GLEW_GET_FUN(__glewTexCoord2fNormal3fVertex3fSUN) -#define glTexCoord2fNormal3fVertex3fvSUN GLEW_GET_FUN(__glewTexCoord2fNormal3fVertex3fvSUN) -#define glTexCoord2fVertex3fSUN GLEW_GET_FUN(__glewTexCoord2fVertex3fSUN) -#define glTexCoord2fVertex3fvSUN GLEW_GET_FUN(__glewTexCoord2fVertex3fvSUN) -#define glTexCoord4fColor4fNormal3fVertex4fSUN GLEW_GET_FUN(__glewTexCoord4fColor4fNormal3fVertex4fSUN) -#define glTexCoord4fColor4fNormal3fVertex4fvSUN GLEW_GET_FUN(__glewTexCoord4fColor4fNormal3fVertex4fvSUN) -#define glTexCoord4fVertex4fSUN GLEW_GET_FUN(__glewTexCoord4fVertex4fSUN) -#define glTexCoord4fVertex4fvSUN GLEW_GET_FUN(__glewTexCoord4fVertex4fvSUN) - -#define GLEW_SUN_vertex GLEW_GET_VAR(__GLEW_SUN_vertex) - -#endif /* GL_SUN_vertex */ - -/* -------------------------- GL_WIN_phong_shading ------------------------- */ - -#ifndef GL_WIN_phong_shading -#define GL_WIN_phong_shading 1 - -#define GL_PHONG_WIN 0x80EA -#define GL_PHONG_HINT_WIN 0x80EB - -#define GLEW_WIN_phong_shading GLEW_GET_VAR(__GLEW_WIN_phong_shading) - -#endif /* GL_WIN_phong_shading */ - -/* -------------------------- GL_WIN_specular_fog -------------------------- */ - -#ifndef GL_WIN_specular_fog -#define GL_WIN_specular_fog 1 - -#define GL_FOG_SPECULAR_TEXTURE_WIN 0x80EC - -#define GLEW_WIN_specular_fog GLEW_GET_VAR(__GLEW_WIN_specular_fog) - -#endif /* GL_WIN_specular_fog */ - -/* ---------------------------- GL_WIN_swap_hint --------------------------- */ - -#ifndef GL_WIN_swap_hint -#define GL_WIN_swap_hint 1 - -typedef void (GLAPIENTRY * PFNGLADDSWAPHINTRECTWINPROC) (GLint x, GLint y, GLsizei width, GLsizei height); - -#define glAddSwapHintRectWIN GLEW_GET_FUN(__glewAddSwapHintRectWIN) - -#define GLEW_WIN_swap_hint GLEW_GET_VAR(__GLEW_WIN_swap_hint) - -#endif /* GL_WIN_swap_hint */ - -/* ------------------------------------------------------------------------- */ - - - -GLEW_FUN_EXPORT PFNGLCOPYTEXSUBIMAGE3DPROC __glewCopyTexSubImage3D; -GLEW_FUN_EXPORT PFNGLDRAWRANGEELEMENTSPROC __glewDrawRangeElements; -GLEW_FUN_EXPORT PFNGLTEXIMAGE3DPROC __glewTexImage3D; -GLEW_FUN_EXPORT PFNGLTEXSUBIMAGE3DPROC __glewTexSubImage3D; - -GLEW_FUN_EXPORT PFNGLACTIVETEXTUREPROC __glewActiveTexture; -GLEW_FUN_EXPORT PFNGLCLIENTACTIVETEXTUREPROC __glewClientActiveTexture; -GLEW_FUN_EXPORT PFNGLCOMPRESSEDTEXIMAGE1DPROC __glewCompressedTexImage1D; -GLEW_FUN_EXPORT PFNGLCOMPRESSEDTEXIMAGE2DPROC __glewCompressedTexImage2D; -GLEW_FUN_EXPORT PFNGLCOMPRESSEDTEXIMAGE3DPROC __glewCompressedTexImage3D; -GLEW_FUN_EXPORT PFNGLCOMPRESSEDTEXSUBIMAGE1DPROC __glewCompressedTexSubImage1D; -GLEW_FUN_EXPORT PFNGLCOMPRESSEDTEXSUBIMAGE2DPROC __glewCompressedTexSubImage2D; -GLEW_FUN_EXPORT PFNGLCOMPRESSEDTEXSUBIMAGE3DPROC __glewCompressedTexSubImage3D; -GLEW_FUN_EXPORT PFNGLGETCOMPRESSEDTEXIMAGEPROC __glewGetCompressedTexImage; -GLEW_FUN_EXPORT PFNGLLOADTRANSPOSEMATRIXDPROC __glewLoadTransposeMatrixd; -GLEW_FUN_EXPORT PFNGLLOADTRANSPOSEMATRIXFPROC __glewLoadTransposeMatrixf; -GLEW_FUN_EXPORT PFNGLMULTTRANSPOSEMATRIXDPROC __glewMultTransposeMatrixd; -GLEW_FUN_EXPORT PFNGLMULTTRANSPOSEMATRIXFPROC __glewMultTransposeMatrixf; -GLEW_FUN_EXPORT PFNGLMULTITEXCOORD1DPROC __glewMultiTexCoord1d; -GLEW_FUN_EXPORT PFNGLMULTITEXCOORD1DVPROC __glewMultiTexCoord1dv; -GLEW_FUN_EXPORT PFNGLMULTITEXCOORD1FPROC __glewMultiTexCoord1f; -GLEW_FUN_EXPORT PFNGLMULTITEXCOORD1FVPROC __glewMultiTexCoord1fv; -GLEW_FUN_EXPORT PFNGLMULTITEXCOORD1IPROC __glewMultiTexCoord1i; -GLEW_FUN_EXPORT PFNGLMULTITEXCOORD1IVPROC __glewMultiTexCoord1iv; -GLEW_FUN_EXPORT PFNGLMULTITEXCOORD1SPROC __glewMultiTexCoord1s; -GLEW_FUN_EXPORT PFNGLMULTITEXCOORD1SVPROC __glewMultiTexCoord1sv; -GLEW_FUN_EXPORT PFNGLMULTITEXCOORD2DPROC __glewMultiTexCoord2d; -GLEW_FUN_EXPORT PFNGLMULTITEXCOORD2DVPROC __glewMultiTexCoord2dv; -GLEW_FUN_EXPORT PFNGLMULTITEXCOORD2FPROC __glewMultiTexCoord2f; -GLEW_FUN_EXPORT PFNGLMULTITEXCOORD2FVPROC __glewMultiTexCoord2fv; -GLEW_FUN_EXPORT PFNGLMULTITEXCOORD2IPROC __glewMultiTexCoord2i; -GLEW_FUN_EXPORT PFNGLMULTITEXCOORD2IVPROC __glewMultiTexCoord2iv; -GLEW_FUN_EXPORT PFNGLMULTITEXCOORD2SPROC __glewMultiTexCoord2s; -GLEW_FUN_EXPORT PFNGLMULTITEXCOORD2SVPROC __glewMultiTexCoord2sv; -GLEW_FUN_EXPORT PFNGLMULTITEXCOORD3DPROC __glewMultiTexCoord3d; -GLEW_FUN_EXPORT PFNGLMULTITEXCOORD3DVPROC __glewMultiTexCoord3dv; -GLEW_FUN_EXPORT PFNGLMULTITEXCOORD3FPROC __glewMultiTexCoord3f; -GLEW_FUN_EXPORT PFNGLMULTITEXCOORD3FVPROC __glewMultiTexCoord3fv; -GLEW_FUN_EXPORT PFNGLMULTITEXCOORD3IPROC __glewMultiTexCoord3i; -GLEW_FUN_EXPORT PFNGLMULTITEXCOORD3IVPROC __glewMultiTexCoord3iv; -GLEW_FUN_EXPORT PFNGLMULTITEXCOORD3SPROC __glewMultiTexCoord3s; -GLEW_FUN_EXPORT PFNGLMULTITEXCOORD3SVPROC __glewMultiTexCoord3sv; -GLEW_FUN_EXPORT PFNGLMULTITEXCOORD4DPROC __glewMultiTexCoord4d; -GLEW_FUN_EXPORT PFNGLMULTITEXCOORD4DVPROC __glewMultiTexCoord4dv; -GLEW_FUN_EXPORT PFNGLMULTITEXCOORD4FPROC __glewMultiTexCoord4f; -GLEW_FUN_EXPORT PFNGLMULTITEXCOORD4FVPROC __glewMultiTexCoord4fv; -GLEW_FUN_EXPORT PFNGLMULTITEXCOORD4IPROC __glewMultiTexCoord4i; -GLEW_FUN_EXPORT PFNGLMULTITEXCOORD4IVPROC __glewMultiTexCoord4iv; -GLEW_FUN_EXPORT PFNGLMULTITEXCOORD4SPROC __glewMultiTexCoord4s; -GLEW_FUN_EXPORT PFNGLMULTITEXCOORD4SVPROC __glewMultiTexCoord4sv; -GLEW_FUN_EXPORT PFNGLSAMPLECOVERAGEPROC __glewSampleCoverage; - -GLEW_FUN_EXPORT PFNGLBLENDCOLORPROC __glewBlendColor; -GLEW_FUN_EXPORT PFNGLBLENDEQUATIONPROC __glewBlendEquation; -GLEW_FUN_EXPORT PFNGLBLENDFUNCSEPARATEPROC __glewBlendFuncSeparate; -GLEW_FUN_EXPORT PFNGLFOGCOORDPOINTERPROC __glewFogCoordPointer; -GLEW_FUN_EXPORT PFNGLFOGCOORDDPROC __glewFogCoordd; -GLEW_FUN_EXPORT PFNGLFOGCOORDDVPROC __glewFogCoorddv; -GLEW_FUN_EXPORT PFNGLFOGCOORDFPROC __glewFogCoordf; -GLEW_FUN_EXPORT PFNGLFOGCOORDFVPROC __glewFogCoordfv; -GLEW_FUN_EXPORT PFNGLMULTIDRAWARRAYSPROC __glewMultiDrawArrays; -GLEW_FUN_EXPORT PFNGLMULTIDRAWELEMENTSPROC __glewMultiDrawElements; -GLEW_FUN_EXPORT PFNGLPOINTPARAMETERFPROC __glewPointParameterf; -GLEW_FUN_EXPORT PFNGLPOINTPARAMETERFVPROC __glewPointParameterfv; -GLEW_FUN_EXPORT PFNGLPOINTPARAMETERIPROC __glewPointParameteri; -GLEW_FUN_EXPORT PFNGLPOINTPARAMETERIVPROC __glewPointParameteriv; -GLEW_FUN_EXPORT PFNGLSECONDARYCOLOR3BPROC __glewSecondaryColor3b; -GLEW_FUN_EXPORT PFNGLSECONDARYCOLOR3BVPROC __glewSecondaryColor3bv; -GLEW_FUN_EXPORT PFNGLSECONDARYCOLOR3DPROC __glewSecondaryColor3d; -GLEW_FUN_EXPORT PFNGLSECONDARYCOLOR3DVPROC __glewSecondaryColor3dv; -GLEW_FUN_EXPORT PFNGLSECONDARYCOLOR3FPROC __glewSecondaryColor3f; -GLEW_FUN_EXPORT PFNGLSECONDARYCOLOR3FVPROC __glewSecondaryColor3fv; -GLEW_FUN_EXPORT PFNGLSECONDARYCOLOR3IPROC __glewSecondaryColor3i; -GLEW_FUN_EXPORT PFNGLSECONDARYCOLOR3IVPROC __glewSecondaryColor3iv; -GLEW_FUN_EXPORT PFNGLSECONDARYCOLOR3SPROC __glewSecondaryColor3s; -GLEW_FUN_EXPORT PFNGLSECONDARYCOLOR3SVPROC __glewSecondaryColor3sv; -GLEW_FUN_EXPORT PFNGLSECONDARYCOLOR3UBPROC __glewSecondaryColor3ub; -GLEW_FUN_EXPORT PFNGLSECONDARYCOLOR3UBVPROC __glewSecondaryColor3ubv; -GLEW_FUN_EXPORT PFNGLSECONDARYCOLOR3UIPROC __glewSecondaryColor3ui; -GLEW_FUN_EXPORT PFNGLSECONDARYCOLOR3UIVPROC __glewSecondaryColor3uiv; -GLEW_FUN_EXPORT PFNGLSECONDARYCOLOR3USPROC __glewSecondaryColor3us; -GLEW_FUN_EXPORT PFNGLSECONDARYCOLOR3USVPROC __glewSecondaryColor3usv; -GLEW_FUN_EXPORT PFNGLSECONDARYCOLORPOINTERPROC __glewSecondaryColorPointer; -GLEW_FUN_EXPORT PFNGLWINDOWPOS2DPROC __glewWindowPos2d; -GLEW_FUN_EXPORT PFNGLWINDOWPOS2DVPROC __glewWindowPos2dv; -GLEW_FUN_EXPORT PFNGLWINDOWPOS2FPROC __glewWindowPos2f; -GLEW_FUN_EXPORT PFNGLWINDOWPOS2FVPROC __glewWindowPos2fv; -GLEW_FUN_EXPORT PFNGLWINDOWPOS2IPROC __glewWindowPos2i; -GLEW_FUN_EXPORT PFNGLWINDOWPOS2IVPROC __glewWindowPos2iv; -GLEW_FUN_EXPORT PFNGLWINDOWPOS2SPROC __glewWindowPos2s; -GLEW_FUN_EXPORT PFNGLWINDOWPOS2SVPROC __glewWindowPos2sv; -GLEW_FUN_EXPORT PFNGLWINDOWPOS3DPROC __glewWindowPos3d; -GLEW_FUN_EXPORT PFNGLWINDOWPOS3DVPROC __glewWindowPos3dv; -GLEW_FUN_EXPORT PFNGLWINDOWPOS3FPROC __glewWindowPos3f; -GLEW_FUN_EXPORT PFNGLWINDOWPOS3FVPROC __glewWindowPos3fv; -GLEW_FUN_EXPORT PFNGLWINDOWPOS3IPROC __glewWindowPos3i; -GLEW_FUN_EXPORT PFNGLWINDOWPOS3IVPROC __glewWindowPos3iv; -GLEW_FUN_EXPORT PFNGLWINDOWPOS3SPROC __glewWindowPos3s; -GLEW_FUN_EXPORT PFNGLWINDOWPOS3SVPROC __glewWindowPos3sv; - -GLEW_FUN_EXPORT PFNGLBEGINQUERYPROC __glewBeginQuery; -GLEW_FUN_EXPORT PFNGLBINDBUFFERPROC __glewBindBuffer; -GLEW_FUN_EXPORT PFNGLBUFFERDATAPROC __glewBufferData; -GLEW_FUN_EXPORT PFNGLBUFFERSUBDATAPROC __glewBufferSubData; -GLEW_FUN_EXPORT PFNGLDELETEBUFFERSPROC __glewDeleteBuffers; -GLEW_FUN_EXPORT PFNGLDELETEQUERIESPROC __glewDeleteQueries; -GLEW_FUN_EXPORT PFNGLENDQUERYPROC __glewEndQuery; -GLEW_FUN_EXPORT PFNGLGENBUFFERSPROC __glewGenBuffers; -GLEW_FUN_EXPORT PFNGLGENQUERIESPROC __glewGenQueries; -GLEW_FUN_EXPORT PFNGLGETBUFFERPARAMETERIVPROC __glewGetBufferParameteriv; -GLEW_FUN_EXPORT PFNGLGETBUFFERPOINTERVPROC __glewGetBufferPointerv; -GLEW_FUN_EXPORT PFNGLGETBUFFERSUBDATAPROC __glewGetBufferSubData; -GLEW_FUN_EXPORT PFNGLGETQUERYOBJECTIVPROC __glewGetQueryObjectiv; -GLEW_FUN_EXPORT PFNGLGETQUERYOBJECTUIVPROC __glewGetQueryObjectuiv; -GLEW_FUN_EXPORT PFNGLGETQUERYIVPROC __glewGetQueryiv; -GLEW_FUN_EXPORT PFNGLISBUFFERPROC __glewIsBuffer; -GLEW_FUN_EXPORT PFNGLISQUERYPROC __glewIsQuery; -GLEW_FUN_EXPORT PFNGLMAPBUFFERPROC __glewMapBuffer; -GLEW_FUN_EXPORT PFNGLUNMAPBUFFERPROC __glewUnmapBuffer; - -GLEW_FUN_EXPORT PFNGLATTACHSHADERPROC __glewAttachShader; -GLEW_FUN_EXPORT PFNGLBINDATTRIBLOCATIONPROC __glewBindAttribLocation; -GLEW_FUN_EXPORT PFNGLBLENDEQUATIONSEPARATEPROC __glewBlendEquationSeparate; -GLEW_FUN_EXPORT PFNGLCOMPILESHADERPROC __glewCompileShader; -GLEW_FUN_EXPORT PFNGLCREATEPROGRAMPROC __glewCreateProgram; -GLEW_FUN_EXPORT PFNGLCREATESHADERPROC __glewCreateShader; -GLEW_FUN_EXPORT PFNGLDELETEPROGRAMPROC __glewDeleteProgram; -GLEW_FUN_EXPORT PFNGLDELETESHADERPROC __glewDeleteShader; -GLEW_FUN_EXPORT PFNGLDETACHSHADERPROC __glewDetachShader; -GLEW_FUN_EXPORT PFNGLDISABLEVERTEXATTRIBARRAYPROC __glewDisableVertexAttribArray; -GLEW_FUN_EXPORT PFNGLDRAWBUFFERSPROC __glewDrawBuffers; -GLEW_FUN_EXPORT PFNGLENABLEVERTEXATTRIBARRAYPROC __glewEnableVertexAttribArray; -GLEW_FUN_EXPORT PFNGLGETACTIVEATTRIBPROC __glewGetActiveAttrib; -GLEW_FUN_EXPORT PFNGLGETACTIVEUNIFORMPROC __glewGetActiveUniform; -GLEW_FUN_EXPORT PFNGLGETATTACHEDSHADERSPROC __glewGetAttachedShaders; -GLEW_FUN_EXPORT PFNGLGETATTRIBLOCATIONPROC __glewGetAttribLocation; -GLEW_FUN_EXPORT PFNGLGETPROGRAMINFOLOGPROC __glewGetProgramInfoLog; -GLEW_FUN_EXPORT PFNGLGETPROGRAMIVPROC __glewGetProgramiv; -GLEW_FUN_EXPORT PFNGLGETSHADERINFOLOGPROC __glewGetShaderInfoLog; -GLEW_FUN_EXPORT PFNGLGETSHADERSOURCEPROC __glewGetShaderSource; -GLEW_FUN_EXPORT PFNGLGETSHADERIVPROC __glewGetShaderiv; -GLEW_FUN_EXPORT PFNGLGETUNIFORMLOCATIONPROC __glewGetUniformLocation; -GLEW_FUN_EXPORT PFNGLGETUNIFORMFVPROC __glewGetUniformfv; -GLEW_FUN_EXPORT PFNGLGETUNIFORMIVPROC __glewGetUniformiv; -GLEW_FUN_EXPORT PFNGLGETVERTEXATTRIBPOINTERVPROC __glewGetVertexAttribPointerv; -GLEW_FUN_EXPORT PFNGLGETVERTEXATTRIBDVPROC __glewGetVertexAttribdv; -GLEW_FUN_EXPORT PFNGLGETVERTEXATTRIBFVPROC __glewGetVertexAttribfv; -GLEW_FUN_EXPORT PFNGLGETVERTEXATTRIBIVPROC __glewGetVertexAttribiv; -GLEW_FUN_EXPORT PFNGLISPROGRAMPROC __glewIsProgram; -GLEW_FUN_EXPORT PFNGLISSHADERPROC __glewIsShader; -GLEW_FUN_EXPORT PFNGLLINKPROGRAMPROC __glewLinkProgram; -GLEW_FUN_EXPORT PFNGLSHADERSOURCEPROC __glewShaderSource; -GLEW_FUN_EXPORT PFNGLSTENCILFUNCSEPARATEPROC __glewStencilFuncSeparate; -GLEW_FUN_EXPORT PFNGLSTENCILMASKSEPARATEPROC __glewStencilMaskSeparate; -GLEW_FUN_EXPORT PFNGLSTENCILOPSEPARATEPROC __glewStencilOpSeparate; -GLEW_FUN_EXPORT PFNGLUNIFORM1FPROC __glewUniform1f; -GLEW_FUN_EXPORT PFNGLUNIFORM1FVPROC __glewUniform1fv; -GLEW_FUN_EXPORT PFNGLUNIFORM1IPROC __glewUniform1i; -GLEW_FUN_EXPORT PFNGLUNIFORM1IVPROC __glewUniform1iv; -GLEW_FUN_EXPORT PFNGLUNIFORM2FPROC __glewUniform2f; -GLEW_FUN_EXPORT PFNGLUNIFORM2FVPROC __glewUniform2fv; -GLEW_FUN_EXPORT PFNGLUNIFORM2IPROC __glewUniform2i; -GLEW_FUN_EXPORT PFNGLUNIFORM2IVPROC __glewUniform2iv; -GLEW_FUN_EXPORT PFNGLUNIFORM3FPROC __glewUniform3f; -GLEW_FUN_EXPORT PFNGLUNIFORM3FVPROC __glewUniform3fv; -GLEW_FUN_EXPORT PFNGLUNIFORM3IPROC __glewUniform3i; -GLEW_FUN_EXPORT PFNGLUNIFORM3IVPROC __glewUniform3iv; -GLEW_FUN_EXPORT PFNGLUNIFORM4FPROC __glewUniform4f; -GLEW_FUN_EXPORT PFNGLUNIFORM4FVPROC __glewUniform4fv; -GLEW_FUN_EXPORT PFNGLUNIFORM4IPROC __glewUniform4i; -GLEW_FUN_EXPORT PFNGLUNIFORM4IVPROC __glewUniform4iv; -GLEW_FUN_EXPORT PFNGLUNIFORMMATRIX2FVPROC __glewUniformMatrix2fv; -GLEW_FUN_EXPORT PFNGLUNIFORMMATRIX3FVPROC __glewUniformMatrix3fv; -GLEW_FUN_EXPORT PFNGLUNIFORMMATRIX4FVPROC __glewUniformMatrix4fv; -GLEW_FUN_EXPORT PFNGLUSEPROGRAMPROC __glewUseProgram; -GLEW_FUN_EXPORT PFNGLVALIDATEPROGRAMPROC __glewValidateProgram; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIB1DPROC __glewVertexAttrib1d; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIB1DVPROC __glewVertexAttrib1dv; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIB1FPROC __glewVertexAttrib1f; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIB1FVPROC __glewVertexAttrib1fv; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIB1SPROC __glewVertexAttrib1s; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIB1SVPROC __glewVertexAttrib1sv; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIB2DPROC __glewVertexAttrib2d; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIB2DVPROC __glewVertexAttrib2dv; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIB2FPROC __glewVertexAttrib2f; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIB2FVPROC __glewVertexAttrib2fv; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIB2SPROC __glewVertexAttrib2s; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIB2SVPROC __glewVertexAttrib2sv; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIB3DPROC __glewVertexAttrib3d; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIB3DVPROC __glewVertexAttrib3dv; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIB3FPROC __glewVertexAttrib3f; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIB3FVPROC __glewVertexAttrib3fv; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIB3SPROC __glewVertexAttrib3s; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIB3SVPROC __glewVertexAttrib3sv; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIB4NBVPROC __glewVertexAttrib4Nbv; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIB4NIVPROC __glewVertexAttrib4Niv; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIB4NSVPROC __glewVertexAttrib4Nsv; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIB4NUBPROC __glewVertexAttrib4Nub; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIB4NUBVPROC __glewVertexAttrib4Nubv; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIB4NUIVPROC __glewVertexAttrib4Nuiv; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIB4NUSVPROC __glewVertexAttrib4Nusv; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIB4BVPROC __glewVertexAttrib4bv; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIB4DPROC __glewVertexAttrib4d; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIB4DVPROC __glewVertexAttrib4dv; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIB4FPROC __glewVertexAttrib4f; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIB4FVPROC __glewVertexAttrib4fv; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIB4IVPROC __glewVertexAttrib4iv; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIB4SPROC __glewVertexAttrib4s; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIB4SVPROC __glewVertexAttrib4sv; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIB4UBVPROC __glewVertexAttrib4ubv; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIB4UIVPROC __glewVertexAttrib4uiv; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIB4USVPROC __glewVertexAttrib4usv; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIBPOINTERPROC __glewVertexAttribPointer; - -GLEW_FUN_EXPORT PFNGLUNIFORMMATRIX2X3FVPROC __glewUniformMatrix2x3fv; -GLEW_FUN_EXPORT PFNGLUNIFORMMATRIX2X4FVPROC __glewUniformMatrix2x4fv; -GLEW_FUN_EXPORT PFNGLUNIFORMMATRIX3X2FVPROC __glewUniformMatrix3x2fv; -GLEW_FUN_EXPORT PFNGLUNIFORMMATRIX3X4FVPROC __glewUniformMatrix3x4fv; -GLEW_FUN_EXPORT PFNGLUNIFORMMATRIX4X2FVPROC __glewUniformMatrix4x2fv; -GLEW_FUN_EXPORT PFNGLUNIFORMMATRIX4X3FVPROC __glewUniformMatrix4x3fv; - -GLEW_FUN_EXPORT PFNGLBEGINCONDITIONALRENDERPROC __glewBeginConditionalRender; -GLEW_FUN_EXPORT PFNGLBEGINTRANSFORMFEEDBACKPROC __glewBeginTransformFeedback; -GLEW_FUN_EXPORT PFNGLBINDFRAGDATALOCATIONPROC __glewBindFragDataLocation; -GLEW_FUN_EXPORT PFNGLCLAMPCOLORPROC __glewClampColor; -GLEW_FUN_EXPORT PFNGLCLEARBUFFERFIPROC __glewClearBufferfi; -GLEW_FUN_EXPORT PFNGLCLEARBUFFERFVPROC __glewClearBufferfv; -GLEW_FUN_EXPORT PFNGLCLEARBUFFERIVPROC __glewClearBufferiv; -GLEW_FUN_EXPORT PFNGLCLEARBUFFERUIVPROC __glewClearBufferuiv; -GLEW_FUN_EXPORT PFNGLCOLORMASKIPROC __glewColorMaski; -GLEW_FUN_EXPORT PFNGLDISABLEIPROC __glewDisablei; -GLEW_FUN_EXPORT PFNGLENABLEIPROC __glewEnablei; -GLEW_FUN_EXPORT PFNGLENDCONDITIONALRENDERPROC __glewEndConditionalRender; -GLEW_FUN_EXPORT PFNGLENDTRANSFORMFEEDBACKPROC __glewEndTransformFeedback; -GLEW_FUN_EXPORT PFNGLGETBOOLEANI_VPROC __glewGetBooleani_v; -GLEW_FUN_EXPORT PFNGLGETFRAGDATALOCATIONPROC __glewGetFragDataLocation; -GLEW_FUN_EXPORT PFNGLGETSTRINGIPROC __glewGetStringi; -GLEW_FUN_EXPORT PFNGLGETTEXPARAMETERIIVPROC __glewGetTexParameterIiv; -GLEW_FUN_EXPORT PFNGLGETTEXPARAMETERIUIVPROC __glewGetTexParameterIuiv; -GLEW_FUN_EXPORT PFNGLGETTRANSFORMFEEDBACKVARYINGPROC __glewGetTransformFeedbackVarying; -GLEW_FUN_EXPORT PFNGLGETUNIFORMUIVPROC __glewGetUniformuiv; -GLEW_FUN_EXPORT PFNGLGETVERTEXATTRIBIIVPROC __glewGetVertexAttribIiv; -GLEW_FUN_EXPORT PFNGLGETVERTEXATTRIBIUIVPROC __glewGetVertexAttribIuiv; -GLEW_FUN_EXPORT PFNGLISENABLEDIPROC __glewIsEnabledi; -GLEW_FUN_EXPORT PFNGLTEXPARAMETERIIVPROC __glewTexParameterIiv; -GLEW_FUN_EXPORT PFNGLTEXPARAMETERIUIVPROC __glewTexParameterIuiv; -GLEW_FUN_EXPORT PFNGLTRANSFORMFEEDBACKVARYINGSPROC __glewTransformFeedbackVaryings; -GLEW_FUN_EXPORT PFNGLUNIFORM1UIPROC __glewUniform1ui; -GLEW_FUN_EXPORT PFNGLUNIFORM1UIVPROC __glewUniform1uiv; -GLEW_FUN_EXPORT PFNGLUNIFORM2UIPROC __glewUniform2ui; -GLEW_FUN_EXPORT PFNGLUNIFORM2UIVPROC __glewUniform2uiv; -GLEW_FUN_EXPORT PFNGLUNIFORM3UIPROC __glewUniform3ui; -GLEW_FUN_EXPORT PFNGLUNIFORM3UIVPROC __glewUniform3uiv; -GLEW_FUN_EXPORT PFNGLUNIFORM4UIPROC __glewUniform4ui; -GLEW_FUN_EXPORT PFNGLUNIFORM4UIVPROC __glewUniform4uiv; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIBI1IPROC __glewVertexAttribI1i; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIBI1IVPROC __glewVertexAttribI1iv; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIBI1UIPROC __glewVertexAttribI1ui; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIBI1UIVPROC __glewVertexAttribI1uiv; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIBI2IPROC __glewVertexAttribI2i; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIBI2IVPROC __glewVertexAttribI2iv; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIBI2UIPROC __glewVertexAttribI2ui; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIBI2UIVPROC __glewVertexAttribI2uiv; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIBI3IPROC __glewVertexAttribI3i; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIBI3IVPROC __glewVertexAttribI3iv; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIBI3UIPROC __glewVertexAttribI3ui; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIBI3UIVPROC __glewVertexAttribI3uiv; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIBI4BVPROC __glewVertexAttribI4bv; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIBI4IPROC __glewVertexAttribI4i; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIBI4IVPROC __glewVertexAttribI4iv; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIBI4SVPROC __glewVertexAttribI4sv; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIBI4UBVPROC __glewVertexAttribI4ubv; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIBI4UIPROC __glewVertexAttribI4ui; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIBI4UIVPROC __glewVertexAttribI4uiv; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIBI4USVPROC __glewVertexAttribI4usv; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIBIPOINTERPROC __glewVertexAttribIPointer; - -GLEW_FUN_EXPORT PFNGLDRAWARRAYSINSTANCEDPROC __glewDrawArraysInstanced; -GLEW_FUN_EXPORT PFNGLDRAWELEMENTSINSTANCEDPROC __glewDrawElementsInstanced; -GLEW_FUN_EXPORT PFNGLPRIMITIVERESTARTINDEXPROC __glewPrimitiveRestartIndex; -GLEW_FUN_EXPORT PFNGLTEXBUFFERPROC __glewTexBuffer; - -GLEW_FUN_EXPORT PFNGLFRAMEBUFFERTEXTUREPROC __glewFramebufferTexture; -GLEW_FUN_EXPORT PFNGLGETBUFFERPARAMETERI64VPROC __glewGetBufferParameteri64v; -GLEW_FUN_EXPORT PFNGLGETINTEGER64I_VPROC __glewGetInteger64i_v; - -GLEW_FUN_EXPORT PFNGLVERTEXATTRIBDIVISORPROC __glewVertexAttribDivisor; - -GLEW_FUN_EXPORT PFNGLBLENDEQUATIONSEPARATEIPROC __glewBlendEquationSeparatei; -GLEW_FUN_EXPORT PFNGLBLENDEQUATIONIPROC __glewBlendEquationi; -GLEW_FUN_EXPORT PFNGLBLENDFUNCSEPARATEIPROC __glewBlendFuncSeparatei; -GLEW_FUN_EXPORT PFNGLBLENDFUNCIPROC __glewBlendFunci; -GLEW_FUN_EXPORT PFNGLMINSAMPLESHADINGPROC __glewMinSampleShading; - -GLEW_FUN_EXPORT PFNGLGETGRAPHICSRESETSTATUSPROC __glewGetGraphicsResetStatus; -GLEW_FUN_EXPORT PFNGLGETNCOMPRESSEDTEXIMAGEPROC __glewGetnCompressedTexImage; -GLEW_FUN_EXPORT PFNGLGETNTEXIMAGEPROC __glewGetnTexImage; -GLEW_FUN_EXPORT PFNGLGETNUNIFORMDVPROC __glewGetnUniformdv; - -GLEW_FUN_EXPORT PFNGLTBUFFERMASK3DFXPROC __glewTbufferMask3DFX; - -GLEW_FUN_EXPORT PFNGLDEBUGMESSAGECALLBACKAMDPROC __glewDebugMessageCallbackAMD; -GLEW_FUN_EXPORT PFNGLDEBUGMESSAGEENABLEAMDPROC __glewDebugMessageEnableAMD; -GLEW_FUN_EXPORT PFNGLDEBUGMESSAGEINSERTAMDPROC __glewDebugMessageInsertAMD; -GLEW_FUN_EXPORT PFNGLGETDEBUGMESSAGELOGAMDPROC __glewGetDebugMessageLogAMD; - -GLEW_FUN_EXPORT PFNGLBLENDEQUATIONINDEXEDAMDPROC __glewBlendEquationIndexedAMD; -GLEW_FUN_EXPORT PFNGLBLENDEQUATIONSEPARATEINDEXEDAMDPROC __glewBlendEquationSeparateIndexedAMD; -GLEW_FUN_EXPORT PFNGLBLENDFUNCINDEXEDAMDPROC __glewBlendFuncIndexedAMD; -GLEW_FUN_EXPORT PFNGLBLENDFUNCSEPARATEINDEXEDAMDPROC __glewBlendFuncSeparateIndexedAMD; - -GLEW_FUN_EXPORT PFNGLVERTEXATTRIBPARAMETERIAMDPROC __glewVertexAttribParameteriAMD; - -GLEW_FUN_EXPORT PFNGLMULTIDRAWARRAYSINDIRECTAMDPROC __glewMultiDrawArraysIndirectAMD; -GLEW_FUN_EXPORT PFNGLMULTIDRAWELEMENTSINDIRECTAMDPROC __glewMultiDrawElementsIndirectAMD; - -GLEW_FUN_EXPORT PFNGLDELETENAMESAMDPROC __glewDeleteNamesAMD; -GLEW_FUN_EXPORT PFNGLGENNAMESAMDPROC __glewGenNamesAMD; -GLEW_FUN_EXPORT PFNGLISNAMEAMDPROC __glewIsNameAMD; - -GLEW_FUN_EXPORT PFNGLQUERYOBJECTPARAMETERUIAMDPROC __glewQueryObjectParameteruiAMD; - -GLEW_FUN_EXPORT PFNGLBEGINPERFMONITORAMDPROC __glewBeginPerfMonitorAMD; -GLEW_FUN_EXPORT PFNGLDELETEPERFMONITORSAMDPROC __glewDeletePerfMonitorsAMD; -GLEW_FUN_EXPORT PFNGLENDPERFMONITORAMDPROC __glewEndPerfMonitorAMD; -GLEW_FUN_EXPORT PFNGLGENPERFMONITORSAMDPROC __glewGenPerfMonitorsAMD; -GLEW_FUN_EXPORT PFNGLGETPERFMONITORCOUNTERDATAAMDPROC __glewGetPerfMonitorCounterDataAMD; -GLEW_FUN_EXPORT PFNGLGETPERFMONITORCOUNTERINFOAMDPROC __glewGetPerfMonitorCounterInfoAMD; -GLEW_FUN_EXPORT PFNGLGETPERFMONITORCOUNTERSTRINGAMDPROC __glewGetPerfMonitorCounterStringAMD; -GLEW_FUN_EXPORT PFNGLGETPERFMONITORCOUNTERSAMDPROC __glewGetPerfMonitorCountersAMD; -GLEW_FUN_EXPORT PFNGLGETPERFMONITORGROUPSTRINGAMDPROC __glewGetPerfMonitorGroupStringAMD; -GLEW_FUN_EXPORT PFNGLGETPERFMONITORGROUPSAMDPROC __glewGetPerfMonitorGroupsAMD; -GLEW_FUN_EXPORT PFNGLSELECTPERFMONITORCOUNTERSAMDPROC __glewSelectPerfMonitorCountersAMD; - -GLEW_FUN_EXPORT PFNGLSETMULTISAMPLEFVAMDPROC __glewSetMultisamplefvAMD; - -GLEW_FUN_EXPORT PFNGLTEXSTORAGESPARSEAMDPROC __glewTexStorageSparseAMD; -GLEW_FUN_EXPORT PFNGLTEXTURESTORAGESPARSEAMDPROC __glewTextureStorageSparseAMD; - -GLEW_FUN_EXPORT PFNGLSTENCILOPVALUEAMDPROC __glewStencilOpValueAMD; - -GLEW_FUN_EXPORT PFNGLTESSELLATIONFACTORAMDPROC __glewTessellationFactorAMD; -GLEW_FUN_EXPORT PFNGLTESSELLATIONMODEAMDPROC __glewTessellationModeAMD; - -GLEW_FUN_EXPORT PFNGLBLITFRAMEBUFFERANGLEPROC __glewBlitFramebufferANGLE; - -GLEW_FUN_EXPORT PFNGLRENDERBUFFERSTORAGEMULTISAMPLEANGLEPROC __glewRenderbufferStorageMultisampleANGLE; - -GLEW_FUN_EXPORT PFNGLDRAWARRAYSINSTANCEDANGLEPROC __glewDrawArraysInstancedANGLE; -GLEW_FUN_EXPORT PFNGLDRAWELEMENTSINSTANCEDANGLEPROC __glewDrawElementsInstancedANGLE; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIBDIVISORANGLEPROC __glewVertexAttribDivisorANGLE; - -GLEW_FUN_EXPORT PFNGLBEGINQUERYANGLEPROC __glewBeginQueryANGLE; -GLEW_FUN_EXPORT PFNGLDELETEQUERIESANGLEPROC __glewDeleteQueriesANGLE; -GLEW_FUN_EXPORT PFNGLENDQUERYANGLEPROC __glewEndQueryANGLE; -GLEW_FUN_EXPORT PFNGLGENQUERIESANGLEPROC __glewGenQueriesANGLE; -GLEW_FUN_EXPORT PFNGLGETQUERYOBJECTI64VANGLEPROC __glewGetQueryObjecti64vANGLE; -GLEW_FUN_EXPORT PFNGLGETQUERYOBJECTIVANGLEPROC __glewGetQueryObjectivANGLE; -GLEW_FUN_EXPORT PFNGLGETQUERYOBJECTUI64VANGLEPROC __glewGetQueryObjectui64vANGLE; -GLEW_FUN_EXPORT PFNGLGETQUERYOBJECTUIVANGLEPROC __glewGetQueryObjectuivANGLE; -GLEW_FUN_EXPORT PFNGLGETQUERYIVANGLEPROC __glewGetQueryivANGLE; -GLEW_FUN_EXPORT PFNGLISQUERYANGLEPROC __glewIsQueryANGLE; -GLEW_FUN_EXPORT PFNGLQUERYCOUNTERANGLEPROC __glewQueryCounterANGLE; - -GLEW_FUN_EXPORT PFNGLGETTRANSLATEDSHADERSOURCEANGLEPROC __glewGetTranslatedShaderSourceANGLE; - -GLEW_FUN_EXPORT PFNGLDRAWELEMENTARRAYAPPLEPROC __glewDrawElementArrayAPPLE; -GLEW_FUN_EXPORT PFNGLDRAWRANGEELEMENTARRAYAPPLEPROC __glewDrawRangeElementArrayAPPLE; -GLEW_FUN_EXPORT PFNGLELEMENTPOINTERAPPLEPROC __glewElementPointerAPPLE; -GLEW_FUN_EXPORT PFNGLMULTIDRAWELEMENTARRAYAPPLEPROC __glewMultiDrawElementArrayAPPLE; -GLEW_FUN_EXPORT PFNGLMULTIDRAWRANGEELEMENTARRAYAPPLEPROC __glewMultiDrawRangeElementArrayAPPLE; - -GLEW_FUN_EXPORT PFNGLDELETEFENCESAPPLEPROC __glewDeleteFencesAPPLE; -GLEW_FUN_EXPORT PFNGLFINISHFENCEAPPLEPROC __glewFinishFenceAPPLE; -GLEW_FUN_EXPORT PFNGLFINISHOBJECTAPPLEPROC __glewFinishObjectAPPLE; -GLEW_FUN_EXPORT PFNGLGENFENCESAPPLEPROC __glewGenFencesAPPLE; -GLEW_FUN_EXPORT PFNGLISFENCEAPPLEPROC __glewIsFenceAPPLE; -GLEW_FUN_EXPORT PFNGLSETFENCEAPPLEPROC __glewSetFenceAPPLE; -GLEW_FUN_EXPORT PFNGLTESTFENCEAPPLEPROC __glewTestFenceAPPLE; -GLEW_FUN_EXPORT PFNGLTESTOBJECTAPPLEPROC __glewTestObjectAPPLE; - -GLEW_FUN_EXPORT PFNGLBUFFERPARAMETERIAPPLEPROC __glewBufferParameteriAPPLE; -GLEW_FUN_EXPORT PFNGLFLUSHMAPPEDBUFFERRANGEAPPLEPROC __glewFlushMappedBufferRangeAPPLE; - -GLEW_FUN_EXPORT PFNGLGETOBJECTPARAMETERIVAPPLEPROC __glewGetObjectParameterivAPPLE; -GLEW_FUN_EXPORT PFNGLOBJECTPURGEABLEAPPLEPROC __glewObjectPurgeableAPPLE; -GLEW_FUN_EXPORT PFNGLOBJECTUNPURGEABLEAPPLEPROC __glewObjectUnpurgeableAPPLE; - -GLEW_FUN_EXPORT PFNGLGETTEXPARAMETERPOINTERVAPPLEPROC __glewGetTexParameterPointervAPPLE; -GLEW_FUN_EXPORT PFNGLTEXTURERANGEAPPLEPROC __glewTextureRangeAPPLE; - -GLEW_FUN_EXPORT PFNGLBINDVERTEXARRAYAPPLEPROC __glewBindVertexArrayAPPLE; -GLEW_FUN_EXPORT PFNGLDELETEVERTEXARRAYSAPPLEPROC __glewDeleteVertexArraysAPPLE; -GLEW_FUN_EXPORT PFNGLGENVERTEXARRAYSAPPLEPROC __glewGenVertexArraysAPPLE; -GLEW_FUN_EXPORT PFNGLISVERTEXARRAYAPPLEPROC __glewIsVertexArrayAPPLE; - -GLEW_FUN_EXPORT PFNGLFLUSHVERTEXARRAYRANGEAPPLEPROC __glewFlushVertexArrayRangeAPPLE; -GLEW_FUN_EXPORT PFNGLVERTEXARRAYPARAMETERIAPPLEPROC __glewVertexArrayParameteriAPPLE; -GLEW_FUN_EXPORT PFNGLVERTEXARRAYRANGEAPPLEPROC __glewVertexArrayRangeAPPLE; - -GLEW_FUN_EXPORT PFNGLDISABLEVERTEXATTRIBAPPLEPROC __glewDisableVertexAttribAPPLE; -GLEW_FUN_EXPORT PFNGLENABLEVERTEXATTRIBAPPLEPROC __glewEnableVertexAttribAPPLE; -GLEW_FUN_EXPORT PFNGLISVERTEXATTRIBENABLEDAPPLEPROC __glewIsVertexAttribEnabledAPPLE; -GLEW_FUN_EXPORT PFNGLMAPVERTEXATTRIB1DAPPLEPROC __glewMapVertexAttrib1dAPPLE; -GLEW_FUN_EXPORT PFNGLMAPVERTEXATTRIB1FAPPLEPROC __glewMapVertexAttrib1fAPPLE; -GLEW_FUN_EXPORT PFNGLMAPVERTEXATTRIB2DAPPLEPROC __glewMapVertexAttrib2dAPPLE; -GLEW_FUN_EXPORT PFNGLMAPVERTEXATTRIB2FAPPLEPROC __glewMapVertexAttrib2fAPPLE; - -GLEW_FUN_EXPORT PFNGLCLEARDEPTHFPROC __glewClearDepthf; -GLEW_FUN_EXPORT PFNGLDEPTHRANGEFPROC __glewDepthRangef; -GLEW_FUN_EXPORT PFNGLGETSHADERPRECISIONFORMATPROC __glewGetShaderPrecisionFormat; -GLEW_FUN_EXPORT PFNGLRELEASESHADERCOMPILERPROC __glewReleaseShaderCompiler; -GLEW_FUN_EXPORT PFNGLSHADERBINARYPROC __glewShaderBinary; - -GLEW_FUN_EXPORT PFNGLMEMORYBARRIERBYREGIONPROC __glewMemoryBarrierByRegion; - -GLEW_FUN_EXPORT PFNGLPRIMITIVEBOUNDINGBOXARBPROC __glewPrimitiveBoundingBoxARB; - -GLEW_FUN_EXPORT PFNGLDRAWARRAYSINSTANCEDBASEINSTANCEPROC __glewDrawArraysInstancedBaseInstance; -GLEW_FUN_EXPORT PFNGLDRAWELEMENTSINSTANCEDBASEINSTANCEPROC __glewDrawElementsInstancedBaseInstance; -GLEW_FUN_EXPORT PFNGLDRAWELEMENTSINSTANCEDBASEVERTEXBASEINSTANCEPROC __glewDrawElementsInstancedBaseVertexBaseInstance; - -GLEW_FUN_EXPORT PFNGLGETIMAGEHANDLEARBPROC __glewGetImageHandleARB; -GLEW_FUN_EXPORT PFNGLGETTEXTUREHANDLEARBPROC __glewGetTextureHandleARB; -GLEW_FUN_EXPORT PFNGLGETTEXTURESAMPLERHANDLEARBPROC __glewGetTextureSamplerHandleARB; -GLEW_FUN_EXPORT PFNGLGETVERTEXATTRIBLUI64VARBPROC __glewGetVertexAttribLui64vARB; -GLEW_FUN_EXPORT PFNGLISIMAGEHANDLERESIDENTARBPROC __glewIsImageHandleResidentARB; -GLEW_FUN_EXPORT PFNGLISTEXTUREHANDLERESIDENTARBPROC __glewIsTextureHandleResidentARB; -GLEW_FUN_EXPORT PFNGLMAKEIMAGEHANDLENONRESIDENTARBPROC __glewMakeImageHandleNonResidentARB; -GLEW_FUN_EXPORT PFNGLMAKEIMAGEHANDLERESIDENTARBPROC __glewMakeImageHandleResidentARB; -GLEW_FUN_EXPORT PFNGLMAKETEXTUREHANDLENONRESIDENTARBPROC __glewMakeTextureHandleNonResidentARB; -GLEW_FUN_EXPORT PFNGLMAKETEXTUREHANDLERESIDENTARBPROC __glewMakeTextureHandleResidentARB; -GLEW_FUN_EXPORT PFNGLPROGRAMUNIFORMHANDLEUI64ARBPROC __glewProgramUniformHandleui64ARB; -GLEW_FUN_EXPORT PFNGLPROGRAMUNIFORMHANDLEUI64VARBPROC __glewProgramUniformHandleui64vARB; -GLEW_FUN_EXPORT PFNGLUNIFORMHANDLEUI64ARBPROC __glewUniformHandleui64ARB; -GLEW_FUN_EXPORT PFNGLUNIFORMHANDLEUI64VARBPROC __glewUniformHandleui64vARB; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIBL1UI64ARBPROC __glewVertexAttribL1ui64ARB; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIBL1UI64VARBPROC __glewVertexAttribL1ui64vARB; - -GLEW_FUN_EXPORT PFNGLBINDFRAGDATALOCATIONINDEXEDPROC __glewBindFragDataLocationIndexed; -GLEW_FUN_EXPORT PFNGLGETFRAGDATAINDEXPROC __glewGetFragDataIndex; - -GLEW_FUN_EXPORT PFNGLBUFFERSTORAGEPROC __glewBufferStorage; -GLEW_FUN_EXPORT PFNGLNAMEDBUFFERSTORAGEEXTPROC __glewNamedBufferStorageEXT; - -GLEW_FUN_EXPORT PFNGLCREATESYNCFROMCLEVENTARBPROC __glewCreateSyncFromCLeventARB; - -GLEW_FUN_EXPORT PFNGLCLEARBUFFERDATAPROC __glewClearBufferData; -GLEW_FUN_EXPORT PFNGLCLEARBUFFERSUBDATAPROC __glewClearBufferSubData; -GLEW_FUN_EXPORT PFNGLCLEARNAMEDBUFFERDATAEXTPROC __glewClearNamedBufferDataEXT; -GLEW_FUN_EXPORT PFNGLCLEARNAMEDBUFFERSUBDATAEXTPROC __glewClearNamedBufferSubDataEXT; - -GLEW_FUN_EXPORT PFNGLCLEARTEXIMAGEPROC __glewClearTexImage; -GLEW_FUN_EXPORT PFNGLCLEARTEXSUBIMAGEPROC __glewClearTexSubImage; - -GLEW_FUN_EXPORT PFNGLCLIPCONTROLPROC __glewClipControl; - -GLEW_FUN_EXPORT PFNGLCLAMPCOLORARBPROC __glewClampColorARB; - -GLEW_FUN_EXPORT PFNGLDISPATCHCOMPUTEPROC __glewDispatchCompute; -GLEW_FUN_EXPORT PFNGLDISPATCHCOMPUTEINDIRECTPROC __glewDispatchComputeIndirect; - -GLEW_FUN_EXPORT PFNGLDISPATCHCOMPUTEGROUPSIZEARBPROC __glewDispatchComputeGroupSizeARB; - -GLEW_FUN_EXPORT PFNGLCOPYBUFFERSUBDATAPROC __glewCopyBufferSubData; - -GLEW_FUN_EXPORT PFNGLCOPYIMAGESUBDATAPROC __glewCopyImageSubData; - -GLEW_FUN_EXPORT PFNGLDEBUGMESSAGECALLBACKARBPROC __glewDebugMessageCallbackARB; -GLEW_FUN_EXPORT PFNGLDEBUGMESSAGECONTROLARBPROC __glewDebugMessageControlARB; -GLEW_FUN_EXPORT PFNGLDEBUGMESSAGEINSERTARBPROC __glewDebugMessageInsertARB; -GLEW_FUN_EXPORT PFNGLGETDEBUGMESSAGELOGARBPROC __glewGetDebugMessageLogARB; - -GLEW_FUN_EXPORT PFNGLBINDTEXTUREUNITPROC __glewBindTextureUnit; -GLEW_FUN_EXPORT PFNGLBLITNAMEDFRAMEBUFFERPROC __glewBlitNamedFramebuffer; -GLEW_FUN_EXPORT PFNGLCHECKNAMEDFRAMEBUFFERSTATUSPROC __glewCheckNamedFramebufferStatus; -GLEW_FUN_EXPORT PFNGLCLEARNAMEDBUFFERDATAPROC __glewClearNamedBufferData; -GLEW_FUN_EXPORT PFNGLCLEARNAMEDBUFFERSUBDATAPROC __glewClearNamedBufferSubData; -GLEW_FUN_EXPORT PFNGLCLEARNAMEDFRAMEBUFFERFIPROC __glewClearNamedFramebufferfi; -GLEW_FUN_EXPORT PFNGLCLEARNAMEDFRAMEBUFFERFVPROC __glewClearNamedFramebufferfv; -GLEW_FUN_EXPORT PFNGLCLEARNAMEDFRAMEBUFFERIVPROC __glewClearNamedFramebufferiv; -GLEW_FUN_EXPORT PFNGLCLEARNAMEDFRAMEBUFFERUIVPROC __glewClearNamedFramebufferuiv; -GLEW_FUN_EXPORT PFNGLCOMPRESSEDTEXTURESUBIMAGE1DPROC __glewCompressedTextureSubImage1D; -GLEW_FUN_EXPORT PFNGLCOMPRESSEDTEXTURESUBIMAGE2DPROC __glewCompressedTextureSubImage2D; -GLEW_FUN_EXPORT PFNGLCOMPRESSEDTEXTURESUBIMAGE3DPROC __glewCompressedTextureSubImage3D; -GLEW_FUN_EXPORT PFNGLCOPYNAMEDBUFFERSUBDATAPROC __glewCopyNamedBufferSubData; -GLEW_FUN_EXPORT PFNGLCOPYTEXTURESUBIMAGE1DPROC __glewCopyTextureSubImage1D; -GLEW_FUN_EXPORT PFNGLCOPYTEXTURESUBIMAGE2DPROC __glewCopyTextureSubImage2D; -GLEW_FUN_EXPORT PFNGLCOPYTEXTURESUBIMAGE3DPROC __glewCopyTextureSubImage3D; -GLEW_FUN_EXPORT PFNGLCREATEBUFFERSPROC __glewCreateBuffers; -GLEW_FUN_EXPORT PFNGLCREATEFRAMEBUFFERSPROC __glewCreateFramebuffers; -GLEW_FUN_EXPORT PFNGLCREATEPROGRAMPIPELINESPROC __glewCreateProgramPipelines; -GLEW_FUN_EXPORT PFNGLCREATEQUERIESPROC __glewCreateQueries; -GLEW_FUN_EXPORT PFNGLCREATERENDERBUFFERSPROC __glewCreateRenderbuffers; -GLEW_FUN_EXPORT PFNGLCREATESAMPLERSPROC __glewCreateSamplers; -GLEW_FUN_EXPORT PFNGLCREATETEXTURESPROC __glewCreateTextures; -GLEW_FUN_EXPORT PFNGLCREATETRANSFORMFEEDBACKSPROC __glewCreateTransformFeedbacks; -GLEW_FUN_EXPORT PFNGLCREATEVERTEXARRAYSPROC __glewCreateVertexArrays; -GLEW_FUN_EXPORT PFNGLDISABLEVERTEXARRAYATTRIBPROC __glewDisableVertexArrayAttrib; -GLEW_FUN_EXPORT PFNGLENABLEVERTEXARRAYATTRIBPROC __glewEnableVertexArrayAttrib; -GLEW_FUN_EXPORT PFNGLFLUSHMAPPEDNAMEDBUFFERRANGEPROC __glewFlushMappedNamedBufferRange; -GLEW_FUN_EXPORT PFNGLGENERATETEXTUREMIPMAPPROC __glewGenerateTextureMipmap; -GLEW_FUN_EXPORT PFNGLGETCOMPRESSEDTEXTUREIMAGEPROC __glewGetCompressedTextureImage; -GLEW_FUN_EXPORT PFNGLGETNAMEDBUFFERPARAMETERI64VPROC __glewGetNamedBufferParameteri64v; -GLEW_FUN_EXPORT PFNGLGETNAMEDBUFFERPARAMETERIVPROC __glewGetNamedBufferParameteriv; -GLEW_FUN_EXPORT PFNGLGETNAMEDBUFFERPOINTERVPROC __glewGetNamedBufferPointerv; -GLEW_FUN_EXPORT PFNGLGETNAMEDBUFFERSUBDATAPROC __glewGetNamedBufferSubData; -GLEW_FUN_EXPORT PFNGLGETNAMEDFRAMEBUFFERATTACHMENTPARAMETERIVPROC __glewGetNamedFramebufferAttachmentParameteriv; -GLEW_FUN_EXPORT PFNGLGETNAMEDFRAMEBUFFERPARAMETERIVPROC __glewGetNamedFramebufferParameteriv; -GLEW_FUN_EXPORT PFNGLGETNAMEDRENDERBUFFERPARAMETERIVPROC __glewGetNamedRenderbufferParameteriv; -GLEW_FUN_EXPORT PFNGLGETQUERYBUFFEROBJECTI64VPROC __glewGetQueryBufferObjecti64v; -GLEW_FUN_EXPORT PFNGLGETQUERYBUFFEROBJECTIVPROC __glewGetQueryBufferObjectiv; -GLEW_FUN_EXPORT PFNGLGETQUERYBUFFEROBJECTUI64VPROC __glewGetQueryBufferObjectui64v; -GLEW_FUN_EXPORT PFNGLGETQUERYBUFFEROBJECTUIVPROC __glewGetQueryBufferObjectuiv; -GLEW_FUN_EXPORT PFNGLGETTEXTUREIMAGEPROC __glewGetTextureImage; -GLEW_FUN_EXPORT PFNGLGETTEXTURELEVELPARAMETERFVPROC __glewGetTextureLevelParameterfv; -GLEW_FUN_EXPORT PFNGLGETTEXTURELEVELPARAMETERIVPROC __glewGetTextureLevelParameteriv; -GLEW_FUN_EXPORT PFNGLGETTEXTUREPARAMETERIIVPROC __glewGetTextureParameterIiv; -GLEW_FUN_EXPORT PFNGLGETTEXTUREPARAMETERIUIVPROC __glewGetTextureParameterIuiv; -GLEW_FUN_EXPORT PFNGLGETTEXTUREPARAMETERFVPROC __glewGetTextureParameterfv; -GLEW_FUN_EXPORT PFNGLGETTEXTUREPARAMETERIVPROC __glewGetTextureParameteriv; -GLEW_FUN_EXPORT PFNGLGETTRANSFORMFEEDBACKI64_VPROC __glewGetTransformFeedbacki64_v; -GLEW_FUN_EXPORT PFNGLGETTRANSFORMFEEDBACKI_VPROC __glewGetTransformFeedbacki_v; -GLEW_FUN_EXPORT PFNGLGETTRANSFORMFEEDBACKIVPROC __glewGetTransformFeedbackiv; -GLEW_FUN_EXPORT PFNGLGETVERTEXARRAYINDEXED64IVPROC __glewGetVertexArrayIndexed64iv; -GLEW_FUN_EXPORT PFNGLGETVERTEXARRAYINDEXEDIVPROC __glewGetVertexArrayIndexediv; -GLEW_FUN_EXPORT PFNGLGETVERTEXARRAYIVPROC __glewGetVertexArrayiv; -GLEW_FUN_EXPORT PFNGLINVALIDATENAMEDFRAMEBUFFERDATAPROC __glewInvalidateNamedFramebufferData; -GLEW_FUN_EXPORT PFNGLINVALIDATENAMEDFRAMEBUFFERSUBDATAPROC __glewInvalidateNamedFramebufferSubData; -GLEW_FUN_EXPORT PFNGLMAPNAMEDBUFFERPROC __glewMapNamedBuffer; -GLEW_FUN_EXPORT PFNGLMAPNAMEDBUFFERRANGEPROC __glewMapNamedBufferRange; -GLEW_FUN_EXPORT PFNGLNAMEDBUFFERDATAPROC __glewNamedBufferData; -GLEW_FUN_EXPORT PFNGLNAMEDBUFFERSTORAGEPROC __glewNamedBufferStorage; -GLEW_FUN_EXPORT PFNGLNAMEDBUFFERSUBDATAPROC __glewNamedBufferSubData; -GLEW_FUN_EXPORT PFNGLNAMEDFRAMEBUFFERDRAWBUFFERPROC __glewNamedFramebufferDrawBuffer; -GLEW_FUN_EXPORT PFNGLNAMEDFRAMEBUFFERDRAWBUFFERSPROC __glewNamedFramebufferDrawBuffers; -GLEW_FUN_EXPORT PFNGLNAMEDFRAMEBUFFERPARAMETERIPROC __glewNamedFramebufferParameteri; -GLEW_FUN_EXPORT PFNGLNAMEDFRAMEBUFFERREADBUFFERPROC __glewNamedFramebufferReadBuffer; -GLEW_FUN_EXPORT PFNGLNAMEDFRAMEBUFFERRENDERBUFFERPROC __glewNamedFramebufferRenderbuffer; -GLEW_FUN_EXPORT PFNGLNAMEDFRAMEBUFFERTEXTUREPROC __glewNamedFramebufferTexture; -GLEW_FUN_EXPORT PFNGLNAMEDFRAMEBUFFERTEXTURELAYERPROC __glewNamedFramebufferTextureLayer; -GLEW_FUN_EXPORT PFNGLNAMEDRENDERBUFFERSTORAGEPROC __glewNamedRenderbufferStorage; -GLEW_FUN_EXPORT PFNGLNAMEDRENDERBUFFERSTORAGEMULTISAMPLEPROC __glewNamedRenderbufferStorageMultisample; -GLEW_FUN_EXPORT PFNGLTEXTUREBUFFERPROC __glewTextureBuffer; -GLEW_FUN_EXPORT PFNGLTEXTUREBUFFERRANGEPROC __glewTextureBufferRange; -GLEW_FUN_EXPORT PFNGLTEXTUREPARAMETERIIVPROC __glewTextureParameterIiv; -GLEW_FUN_EXPORT PFNGLTEXTUREPARAMETERIUIVPROC __glewTextureParameterIuiv; -GLEW_FUN_EXPORT PFNGLTEXTUREPARAMETERFPROC __glewTextureParameterf; -GLEW_FUN_EXPORT PFNGLTEXTUREPARAMETERFVPROC __glewTextureParameterfv; -GLEW_FUN_EXPORT PFNGLTEXTUREPARAMETERIPROC __glewTextureParameteri; -GLEW_FUN_EXPORT PFNGLTEXTUREPARAMETERIVPROC __glewTextureParameteriv; -GLEW_FUN_EXPORT PFNGLTEXTURESTORAGE1DPROC __glewTextureStorage1D; -GLEW_FUN_EXPORT PFNGLTEXTURESTORAGE2DPROC __glewTextureStorage2D; -GLEW_FUN_EXPORT PFNGLTEXTURESTORAGE2DMULTISAMPLEPROC __glewTextureStorage2DMultisample; -GLEW_FUN_EXPORT PFNGLTEXTURESTORAGE3DPROC __glewTextureStorage3D; -GLEW_FUN_EXPORT PFNGLTEXTURESTORAGE3DMULTISAMPLEPROC __glewTextureStorage3DMultisample; -GLEW_FUN_EXPORT PFNGLTEXTURESUBIMAGE1DPROC __glewTextureSubImage1D; -GLEW_FUN_EXPORT PFNGLTEXTURESUBIMAGE2DPROC __glewTextureSubImage2D; -GLEW_FUN_EXPORT PFNGLTEXTURESUBIMAGE3DPROC __glewTextureSubImage3D; -GLEW_FUN_EXPORT PFNGLTRANSFORMFEEDBACKBUFFERBASEPROC __glewTransformFeedbackBufferBase; -GLEW_FUN_EXPORT PFNGLTRANSFORMFEEDBACKBUFFERRANGEPROC __glewTransformFeedbackBufferRange; -GLEW_FUN_EXPORT PFNGLUNMAPNAMEDBUFFERPROC __glewUnmapNamedBuffer; -GLEW_FUN_EXPORT PFNGLVERTEXARRAYATTRIBBINDINGPROC __glewVertexArrayAttribBinding; -GLEW_FUN_EXPORT PFNGLVERTEXARRAYATTRIBFORMATPROC __glewVertexArrayAttribFormat; -GLEW_FUN_EXPORT PFNGLVERTEXARRAYATTRIBIFORMATPROC __glewVertexArrayAttribIFormat; -GLEW_FUN_EXPORT PFNGLVERTEXARRAYATTRIBLFORMATPROC __glewVertexArrayAttribLFormat; -GLEW_FUN_EXPORT PFNGLVERTEXARRAYBINDINGDIVISORPROC __glewVertexArrayBindingDivisor; -GLEW_FUN_EXPORT PFNGLVERTEXARRAYELEMENTBUFFERPROC __glewVertexArrayElementBuffer; -GLEW_FUN_EXPORT PFNGLVERTEXARRAYVERTEXBUFFERPROC __glewVertexArrayVertexBuffer; -GLEW_FUN_EXPORT PFNGLVERTEXARRAYVERTEXBUFFERSPROC __glewVertexArrayVertexBuffers; - -GLEW_FUN_EXPORT PFNGLDRAWBUFFERSARBPROC __glewDrawBuffersARB; - -GLEW_FUN_EXPORT PFNGLBLENDEQUATIONSEPARATEIARBPROC __glewBlendEquationSeparateiARB; -GLEW_FUN_EXPORT PFNGLBLENDEQUATIONIARBPROC __glewBlendEquationiARB; -GLEW_FUN_EXPORT PFNGLBLENDFUNCSEPARATEIARBPROC __glewBlendFuncSeparateiARB; -GLEW_FUN_EXPORT PFNGLBLENDFUNCIARBPROC __glewBlendFunciARB; - -GLEW_FUN_EXPORT PFNGLDRAWELEMENTSBASEVERTEXPROC __glewDrawElementsBaseVertex; -GLEW_FUN_EXPORT PFNGLDRAWELEMENTSINSTANCEDBASEVERTEXPROC __glewDrawElementsInstancedBaseVertex; -GLEW_FUN_EXPORT PFNGLDRAWRANGEELEMENTSBASEVERTEXPROC __glewDrawRangeElementsBaseVertex; -GLEW_FUN_EXPORT PFNGLMULTIDRAWELEMENTSBASEVERTEXPROC __glewMultiDrawElementsBaseVertex; - -GLEW_FUN_EXPORT PFNGLDRAWARRAYSINDIRECTPROC __glewDrawArraysIndirect; -GLEW_FUN_EXPORT PFNGLDRAWELEMENTSINDIRECTPROC __glewDrawElementsIndirect; - -GLEW_FUN_EXPORT PFNGLFRAMEBUFFERPARAMETERIPROC __glewFramebufferParameteri; -GLEW_FUN_EXPORT PFNGLGETFRAMEBUFFERPARAMETERIVPROC __glewGetFramebufferParameteriv; -GLEW_FUN_EXPORT PFNGLGETNAMEDFRAMEBUFFERPARAMETERIVEXTPROC __glewGetNamedFramebufferParameterivEXT; -GLEW_FUN_EXPORT PFNGLNAMEDFRAMEBUFFERPARAMETERIEXTPROC __glewNamedFramebufferParameteriEXT; - -GLEW_FUN_EXPORT PFNGLBINDFRAMEBUFFERPROC __glewBindFramebuffer; -GLEW_FUN_EXPORT PFNGLBINDRENDERBUFFERPROC __glewBindRenderbuffer; -GLEW_FUN_EXPORT PFNGLBLITFRAMEBUFFERPROC __glewBlitFramebuffer; -GLEW_FUN_EXPORT PFNGLCHECKFRAMEBUFFERSTATUSPROC __glewCheckFramebufferStatus; -GLEW_FUN_EXPORT PFNGLDELETEFRAMEBUFFERSPROC __glewDeleteFramebuffers; -GLEW_FUN_EXPORT PFNGLDELETERENDERBUFFERSPROC __glewDeleteRenderbuffers; -GLEW_FUN_EXPORT PFNGLFRAMEBUFFERRENDERBUFFERPROC __glewFramebufferRenderbuffer; -GLEW_FUN_EXPORT PFNGLFRAMEBUFFERTEXTURE1DPROC __glewFramebufferTexture1D; -GLEW_FUN_EXPORT PFNGLFRAMEBUFFERTEXTURE2DPROC __glewFramebufferTexture2D; -GLEW_FUN_EXPORT PFNGLFRAMEBUFFERTEXTURE3DPROC __glewFramebufferTexture3D; -GLEW_FUN_EXPORT PFNGLFRAMEBUFFERTEXTURELAYERPROC __glewFramebufferTextureLayer; -GLEW_FUN_EXPORT PFNGLGENFRAMEBUFFERSPROC __glewGenFramebuffers; -GLEW_FUN_EXPORT PFNGLGENRENDERBUFFERSPROC __glewGenRenderbuffers; -GLEW_FUN_EXPORT PFNGLGENERATEMIPMAPPROC __glewGenerateMipmap; -GLEW_FUN_EXPORT PFNGLGETFRAMEBUFFERATTACHMENTPARAMETERIVPROC __glewGetFramebufferAttachmentParameteriv; -GLEW_FUN_EXPORT PFNGLGETRENDERBUFFERPARAMETERIVPROC __glewGetRenderbufferParameteriv; -GLEW_FUN_EXPORT PFNGLISFRAMEBUFFERPROC __glewIsFramebuffer; -GLEW_FUN_EXPORT PFNGLISRENDERBUFFERPROC __glewIsRenderbuffer; -GLEW_FUN_EXPORT PFNGLRENDERBUFFERSTORAGEPROC __glewRenderbufferStorage; -GLEW_FUN_EXPORT PFNGLRENDERBUFFERSTORAGEMULTISAMPLEPROC __glewRenderbufferStorageMultisample; - -GLEW_FUN_EXPORT PFNGLFRAMEBUFFERTEXTUREARBPROC __glewFramebufferTextureARB; -GLEW_FUN_EXPORT PFNGLFRAMEBUFFERTEXTUREFACEARBPROC __glewFramebufferTextureFaceARB; -GLEW_FUN_EXPORT PFNGLFRAMEBUFFERTEXTURELAYERARBPROC __glewFramebufferTextureLayerARB; -GLEW_FUN_EXPORT PFNGLPROGRAMPARAMETERIARBPROC __glewProgramParameteriARB; - -GLEW_FUN_EXPORT PFNGLGETPROGRAMBINARYPROC __glewGetProgramBinary; -GLEW_FUN_EXPORT PFNGLPROGRAMBINARYPROC __glewProgramBinary; -GLEW_FUN_EXPORT PFNGLPROGRAMPARAMETERIPROC __glewProgramParameteri; - -GLEW_FUN_EXPORT PFNGLGETCOMPRESSEDTEXTURESUBIMAGEPROC __glewGetCompressedTextureSubImage; -GLEW_FUN_EXPORT PFNGLGETTEXTURESUBIMAGEPROC __glewGetTextureSubImage; - -GLEW_FUN_EXPORT PFNGLSPECIALIZESHADERARBPROC __glewSpecializeShaderARB; - -GLEW_FUN_EXPORT PFNGLGETUNIFORMDVPROC __glewGetUniformdv; -GLEW_FUN_EXPORT PFNGLUNIFORM1DPROC __glewUniform1d; -GLEW_FUN_EXPORT PFNGLUNIFORM1DVPROC __glewUniform1dv; -GLEW_FUN_EXPORT PFNGLUNIFORM2DPROC __glewUniform2d; -GLEW_FUN_EXPORT PFNGLUNIFORM2DVPROC __glewUniform2dv; -GLEW_FUN_EXPORT PFNGLUNIFORM3DPROC __glewUniform3d; -GLEW_FUN_EXPORT PFNGLUNIFORM3DVPROC __glewUniform3dv; -GLEW_FUN_EXPORT PFNGLUNIFORM4DPROC __glewUniform4d; -GLEW_FUN_EXPORT PFNGLUNIFORM4DVPROC __glewUniform4dv; -GLEW_FUN_EXPORT PFNGLUNIFORMMATRIX2DVPROC __glewUniformMatrix2dv; -GLEW_FUN_EXPORT PFNGLUNIFORMMATRIX2X3DVPROC __glewUniformMatrix2x3dv; -GLEW_FUN_EXPORT PFNGLUNIFORMMATRIX2X4DVPROC __glewUniformMatrix2x4dv; -GLEW_FUN_EXPORT PFNGLUNIFORMMATRIX3DVPROC __glewUniformMatrix3dv; -GLEW_FUN_EXPORT PFNGLUNIFORMMATRIX3X2DVPROC __glewUniformMatrix3x2dv; -GLEW_FUN_EXPORT PFNGLUNIFORMMATRIX3X4DVPROC __glewUniformMatrix3x4dv; -GLEW_FUN_EXPORT PFNGLUNIFORMMATRIX4DVPROC __glewUniformMatrix4dv; -GLEW_FUN_EXPORT PFNGLUNIFORMMATRIX4X2DVPROC __glewUniformMatrix4x2dv; -GLEW_FUN_EXPORT PFNGLUNIFORMMATRIX4X3DVPROC __glewUniformMatrix4x3dv; - -GLEW_FUN_EXPORT PFNGLGETUNIFORMI64VARBPROC __glewGetUniformi64vARB; -GLEW_FUN_EXPORT PFNGLGETUNIFORMUI64VARBPROC __glewGetUniformui64vARB; -GLEW_FUN_EXPORT PFNGLGETNUNIFORMI64VARBPROC __glewGetnUniformi64vARB; -GLEW_FUN_EXPORT PFNGLGETNUNIFORMUI64VARBPROC __glewGetnUniformui64vARB; -GLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM1I64ARBPROC __glewProgramUniform1i64ARB; -GLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM1I64VARBPROC __glewProgramUniform1i64vARB; -GLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM1UI64ARBPROC __glewProgramUniform1ui64ARB; -GLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM1UI64VARBPROC __glewProgramUniform1ui64vARB; -GLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM2I64ARBPROC __glewProgramUniform2i64ARB; -GLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM2I64VARBPROC __glewProgramUniform2i64vARB; -GLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM2UI64ARBPROC __glewProgramUniform2ui64ARB; -GLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM2UI64VARBPROC __glewProgramUniform2ui64vARB; -GLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM3I64ARBPROC __glewProgramUniform3i64ARB; -GLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM3I64VARBPROC __glewProgramUniform3i64vARB; -GLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM3UI64ARBPROC __glewProgramUniform3ui64ARB; -GLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM3UI64VARBPROC __glewProgramUniform3ui64vARB; -GLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM4I64ARBPROC __glewProgramUniform4i64ARB; -GLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM4I64VARBPROC __glewProgramUniform4i64vARB; -GLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM4UI64ARBPROC __glewProgramUniform4ui64ARB; -GLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM4UI64VARBPROC __glewProgramUniform4ui64vARB; -GLEW_FUN_EXPORT PFNGLUNIFORM1I64ARBPROC __glewUniform1i64ARB; -GLEW_FUN_EXPORT PFNGLUNIFORM1I64VARBPROC __glewUniform1i64vARB; -GLEW_FUN_EXPORT PFNGLUNIFORM1UI64ARBPROC __glewUniform1ui64ARB; -GLEW_FUN_EXPORT PFNGLUNIFORM1UI64VARBPROC __glewUniform1ui64vARB; -GLEW_FUN_EXPORT PFNGLUNIFORM2I64ARBPROC __glewUniform2i64ARB; -GLEW_FUN_EXPORT PFNGLUNIFORM2I64VARBPROC __glewUniform2i64vARB; -GLEW_FUN_EXPORT PFNGLUNIFORM2UI64ARBPROC __glewUniform2ui64ARB; -GLEW_FUN_EXPORT PFNGLUNIFORM2UI64VARBPROC __glewUniform2ui64vARB; -GLEW_FUN_EXPORT PFNGLUNIFORM3I64ARBPROC __glewUniform3i64ARB; -GLEW_FUN_EXPORT PFNGLUNIFORM3I64VARBPROC __glewUniform3i64vARB; -GLEW_FUN_EXPORT PFNGLUNIFORM3UI64ARBPROC __glewUniform3ui64ARB; -GLEW_FUN_EXPORT PFNGLUNIFORM3UI64VARBPROC __glewUniform3ui64vARB; -GLEW_FUN_EXPORT PFNGLUNIFORM4I64ARBPROC __glewUniform4i64ARB; -GLEW_FUN_EXPORT PFNGLUNIFORM4I64VARBPROC __glewUniform4i64vARB; -GLEW_FUN_EXPORT PFNGLUNIFORM4UI64ARBPROC __glewUniform4ui64ARB; -GLEW_FUN_EXPORT PFNGLUNIFORM4UI64VARBPROC __glewUniform4ui64vARB; - -GLEW_FUN_EXPORT PFNGLCOLORSUBTABLEPROC __glewColorSubTable; -GLEW_FUN_EXPORT PFNGLCOLORTABLEPROC __glewColorTable; -GLEW_FUN_EXPORT PFNGLCOLORTABLEPARAMETERFVPROC __glewColorTableParameterfv; -GLEW_FUN_EXPORT PFNGLCOLORTABLEPARAMETERIVPROC __glewColorTableParameteriv; -GLEW_FUN_EXPORT PFNGLCONVOLUTIONFILTER1DPROC __glewConvolutionFilter1D; -GLEW_FUN_EXPORT PFNGLCONVOLUTIONFILTER2DPROC __glewConvolutionFilter2D; -GLEW_FUN_EXPORT PFNGLCONVOLUTIONPARAMETERFPROC __glewConvolutionParameterf; -GLEW_FUN_EXPORT PFNGLCONVOLUTIONPARAMETERFVPROC __glewConvolutionParameterfv; -GLEW_FUN_EXPORT PFNGLCONVOLUTIONPARAMETERIPROC __glewConvolutionParameteri; -GLEW_FUN_EXPORT PFNGLCONVOLUTIONPARAMETERIVPROC __glewConvolutionParameteriv; -GLEW_FUN_EXPORT PFNGLCOPYCOLORSUBTABLEPROC __glewCopyColorSubTable; -GLEW_FUN_EXPORT PFNGLCOPYCOLORTABLEPROC __glewCopyColorTable; -GLEW_FUN_EXPORT PFNGLCOPYCONVOLUTIONFILTER1DPROC __glewCopyConvolutionFilter1D; -GLEW_FUN_EXPORT PFNGLCOPYCONVOLUTIONFILTER2DPROC __glewCopyConvolutionFilter2D; -GLEW_FUN_EXPORT PFNGLGETCOLORTABLEPROC __glewGetColorTable; -GLEW_FUN_EXPORT PFNGLGETCOLORTABLEPARAMETERFVPROC __glewGetColorTableParameterfv; -GLEW_FUN_EXPORT PFNGLGETCOLORTABLEPARAMETERIVPROC __glewGetColorTableParameteriv; -GLEW_FUN_EXPORT PFNGLGETCONVOLUTIONFILTERPROC __glewGetConvolutionFilter; -GLEW_FUN_EXPORT PFNGLGETCONVOLUTIONPARAMETERFVPROC __glewGetConvolutionParameterfv; -GLEW_FUN_EXPORT PFNGLGETCONVOLUTIONPARAMETERIVPROC __glewGetConvolutionParameteriv; -GLEW_FUN_EXPORT PFNGLGETHISTOGRAMPROC __glewGetHistogram; -GLEW_FUN_EXPORT PFNGLGETHISTOGRAMPARAMETERFVPROC __glewGetHistogramParameterfv; -GLEW_FUN_EXPORT PFNGLGETHISTOGRAMPARAMETERIVPROC __glewGetHistogramParameteriv; -GLEW_FUN_EXPORT PFNGLGETMINMAXPROC __glewGetMinmax; -GLEW_FUN_EXPORT PFNGLGETMINMAXPARAMETERFVPROC __glewGetMinmaxParameterfv; -GLEW_FUN_EXPORT PFNGLGETMINMAXPARAMETERIVPROC __glewGetMinmaxParameteriv; -GLEW_FUN_EXPORT PFNGLGETSEPARABLEFILTERPROC __glewGetSeparableFilter; -GLEW_FUN_EXPORT PFNGLHISTOGRAMPROC __glewHistogram; -GLEW_FUN_EXPORT PFNGLMINMAXPROC __glewMinmax; -GLEW_FUN_EXPORT PFNGLRESETHISTOGRAMPROC __glewResetHistogram; -GLEW_FUN_EXPORT PFNGLRESETMINMAXPROC __glewResetMinmax; -GLEW_FUN_EXPORT PFNGLSEPARABLEFILTER2DPROC __glewSeparableFilter2D; - -GLEW_FUN_EXPORT PFNGLMULTIDRAWARRAYSINDIRECTCOUNTARBPROC __glewMultiDrawArraysIndirectCountARB; -GLEW_FUN_EXPORT PFNGLMULTIDRAWELEMENTSINDIRECTCOUNTARBPROC __glewMultiDrawElementsIndirectCountARB; - -GLEW_FUN_EXPORT PFNGLDRAWARRAYSINSTANCEDARBPROC __glewDrawArraysInstancedARB; -GLEW_FUN_EXPORT PFNGLDRAWELEMENTSINSTANCEDARBPROC __glewDrawElementsInstancedARB; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIBDIVISORARBPROC __glewVertexAttribDivisorARB; - -GLEW_FUN_EXPORT PFNGLGETINTERNALFORMATIVPROC __glewGetInternalformativ; - -GLEW_FUN_EXPORT PFNGLGETINTERNALFORMATI64VPROC __glewGetInternalformati64v; - -GLEW_FUN_EXPORT PFNGLINVALIDATEBUFFERDATAPROC __glewInvalidateBufferData; -GLEW_FUN_EXPORT PFNGLINVALIDATEBUFFERSUBDATAPROC __glewInvalidateBufferSubData; -GLEW_FUN_EXPORT PFNGLINVALIDATEFRAMEBUFFERPROC __glewInvalidateFramebuffer; -GLEW_FUN_EXPORT PFNGLINVALIDATESUBFRAMEBUFFERPROC __glewInvalidateSubFramebuffer; -GLEW_FUN_EXPORT PFNGLINVALIDATETEXIMAGEPROC __glewInvalidateTexImage; -GLEW_FUN_EXPORT PFNGLINVALIDATETEXSUBIMAGEPROC __glewInvalidateTexSubImage; - -GLEW_FUN_EXPORT PFNGLFLUSHMAPPEDBUFFERRANGEPROC __glewFlushMappedBufferRange; -GLEW_FUN_EXPORT PFNGLMAPBUFFERRANGEPROC __glewMapBufferRange; - -GLEW_FUN_EXPORT PFNGLCURRENTPALETTEMATRIXARBPROC __glewCurrentPaletteMatrixARB; -GLEW_FUN_EXPORT PFNGLMATRIXINDEXPOINTERARBPROC __glewMatrixIndexPointerARB; -GLEW_FUN_EXPORT PFNGLMATRIXINDEXUBVARBPROC __glewMatrixIndexubvARB; -GLEW_FUN_EXPORT PFNGLMATRIXINDEXUIVARBPROC __glewMatrixIndexuivARB; -GLEW_FUN_EXPORT PFNGLMATRIXINDEXUSVARBPROC __glewMatrixIndexusvARB; - -GLEW_FUN_EXPORT PFNGLBINDBUFFERSBASEPROC __glewBindBuffersBase; -GLEW_FUN_EXPORT PFNGLBINDBUFFERSRANGEPROC __glewBindBuffersRange; -GLEW_FUN_EXPORT PFNGLBINDIMAGETEXTURESPROC __glewBindImageTextures; -GLEW_FUN_EXPORT PFNGLBINDSAMPLERSPROC __glewBindSamplers; -GLEW_FUN_EXPORT PFNGLBINDTEXTURESPROC __glewBindTextures; -GLEW_FUN_EXPORT PFNGLBINDVERTEXBUFFERSPROC __glewBindVertexBuffers; - -GLEW_FUN_EXPORT PFNGLMULTIDRAWARRAYSINDIRECTPROC __glewMultiDrawArraysIndirect; -GLEW_FUN_EXPORT PFNGLMULTIDRAWELEMENTSINDIRECTPROC __glewMultiDrawElementsIndirect; - -GLEW_FUN_EXPORT PFNGLSAMPLECOVERAGEARBPROC __glewSampleCoverageARB; - -GLEW_FUN_EXPORT PFNGLACTIVETEXTUREARBPROC __glewActiveTextureARB; -GLEW_FUN_EXPORT PFNGLCLIENTACTIVETEXTUREARBPROC __glewClientActiveTextureARB; -GLEW_FUN_EXPORT PFNGLMULTITEXCOORD1DARBPROC __glewMultiTexCoord1dARB; -GLEW_FUN_EXPORT PFNGLMULTITEXCOORD1DVARBPROC __glewMultiTexCoord1dvARB; -GLEW_FUN_EXPORT PFNGLMULTITEXCOORD1FARBPROC __glewMultiTexCoord1fARB; -GLEW_FUN_EXPORT PFNGLMULTITEXCOORD1FVARBPROC __glewMultiTexCoord1fvARB; -GLEW_FUN_EXPORT PFNGLMULTITEXCOORD1IARBPROC __glewMultiTexCoord1iARB; -GLEW_FUN_EXPORT PFNGLMULTITEXCOORD1IVARBPROC __glewMultiTexCoord1ivARB; -GLEW_FUN_EXPORT PFNGLMULTITEXCOORD1SARBPROC __glewMultiTexCoord1sARB; -GLEW_FUN_EXPORT PFNGLMULTITEXCOORD1SVARBPROC __glewMultiTexCoord1svARB; -GLEW_FUN_EXPORT PFNGLMULTITEXCOORD2DARBPROC __glewMultiTexCoord2dARB; -GLEW_FUN_EXPORT PFNGLMULTITEXCOORD2DVARBPROC __glewMultiTexCoord2dvARB; -GLEW_FUN_EXPORT PFNGLMULTITEXCOORD2FARBPROC __glewMultiTexCoord2fARB; -GLEW_FUN_EXPORT PFNGLMULTITEXCOORD2FVARBPROC __glewMultiTexCoord2fvARB; -GLEW_FUN_EXPORT PFNGLMULTITEXCOORD2IARBPROC __glewMultiTexCoord2iARB; -GLEW_FUN_EXPORT PFNGLMULTITEXCOORD2IVARBPROC __glewMultiTexCoord2ivARB; -GLEW_FUN_EXPORT PFNGLMULTITEXCOORD2SARBPROC __glewMultiTexCoord2sARB; -GLEW_FUN_EXPORT PFNGLMULTITEXCOORD2SVARBPROC __glewMultiTexCoord2svARB; -GLEW_FUN_EXPORT PFNGLMULTITEXCOORD3DARBPROC __glewMultiTexCoord3dARB; -GLEW_FUN_EXPORT PFNGLMULTITEXCOORD3DVARBPROC __glewMultiTexCoord3dvARB; -GLEW_FUN_EXPORT PFNGLMULTITEXCOORD3FARBPROC __glewMultiTexCoord3fARB; -GLEW_FUN_EXPORT PFNGLMULTITEXCOORD3FVARBPROC __glewMultiTexCoord3fvARB; -GLEW_FUN_EXPORT PFNGLMULTITEXCOORD3IARBPROC __glewMultiTexCoord3iARB; -GLEW_FUN_EXPORT PFNGLMULTITEXCOORD3IVARBPROC __glewMultiTexCoord3ivARB; -GLEW_FUN_EXPORT PFNGLMULTITEXCOORD3SARBPROC __glewMultiTexCoord3sARB; -GLEW_FUN_EXPORT PFNGLMULTITEXCOORD3SVARBPROC __glewMultiTexCoord3svARB; -GLEW_FUN_EXPORT PFNGLMULTITEXCOORD4DARBPROC __glewMultiTexCoord4dARB; -GLEW_FUN_EXPORT PFNGLMULTITEXCOORD4DVARBPROC __glewMultiTexCoord4dvARB; -GLEW_FUN_EXPORT PFNGLMULTITEXCOORD4FARBPROC __glewMultiTexCoord4fARB; -GLEW_FUN_EXPORT PFNGLMULTITEXCOORD4FVARBPROC __glewMultiTexCoord4fvARB; -GLEW_FUN_EXPORT PFNGLMULTITEXCOORD4IARBPROC __glewMultiTexCoord4iARB; -GLEW_FUN_EXPORT PFNGLMULTITEXCOORD4IVARBPROC __glewMultiTexCoord4ivARB; -GLEW_FUN_EXPORT PFNGLMULTITEXCOORD4SARBPROC __glewMultiTexCoord4sARB; -GLEW_FUN_EXPORT PFNGLMULTITEXCOORD4SVARBPROC __glewMultiTexCoord4svARB; - -GLEW_FUN_EXPORT PFNGLBEGINQUERYARBPROC __glewBeginQueryARB; -GLEW_FUN_EXPORT PFNGLDELETEQUERIESARBPROC __glewDeleteQueriesARB; -GLEW_FUN_EXPORT PFNGLENDQUERYARBPROC __glewEndQueryARB; -GLEW_FUN_EXPORT PFNGLGENQUERIESARBPROC __glewGenQueriesARB; -GLEW_FUN_EXPORT PFNGLGETQUERYOBJECTIVARBPROC __glewGetQueryObjectivARB; -GLEW_FUN_EXPORT PFNGLGETQUERYOBJECTUIVARBPROC __glewGetQueryObjectuivARB; -GLEW_FUN_EXPORT PFNGLGETQUERYIVARBPROC __glewGetQueryivARB; -GLEW_FUN_EXPORT PFNGLISQUERYARBPROC __glewIsQueryARB; - -GLEW_FUN_EXPORT PFNGLMAXSHADERCOMPILERTHREADSARBPROC __glewMaxShaderCompilerThreadsARB; - -GLEW_FUN_EXPORT PFNGLPOINTPARAMETERFARBPROC __glewPointParameterfARB; -GLEW_FUN_EXPORT PFNGLPOINTPARAMETERFVARBPROC __glewPointParameterfvARB; - -GLEW_FUN_EXPORT PFNGLGETPROGRAMINTERFACEIVPROC __glewGetProgramInterfaceiv; -GLEW_FUN_EXPORT PFNGLGETPROGRAMRESOURCEINDEXPROC __glewGetProgramResourceIndex; -GLEW_FUN_EXPORT PFNGLGETPROGRAMRESOURCELOCATIONPROC __glewGetProgramResourceLocation; -GLEW_FUN_EXPORT PFNGLGETPROGRAMRESOURCELOCATIONINDEXPROC __glewGetProgramResourceLocationIndex; -GLEW_FUN_EXPORT PFNGLGETPROGRAMRESOURCENAMEPROC __glewGetProgramResourceName; -GLEW_FUN_EXPORT PFNGLGETPROGRAMRESOURCEIVPROC __glewGetProgramResourceiv; - -GLEW_FUN_EXPORT PFNGLPROVOKINGVERTEXPROC __glewProvokingVertex; - -GLEW_FUN_EXPORT PFNGLGETGRAPHICSRESETSTATUSARBPROC __glewGetGraphicsResetStatusARB; -GLEW_FUN_EXPORT PFNGLGETNCOLORTABLEARBPROC __glewGetnColorTableARB; -GLEW_FUN_EXPORT PFNGLGETNCOMPRESSEDTEXIMAGEARBPROC __glewGetnCompressedTexImageARB; -GLEW_FUN_EXPORT PFNGLGETNCONVOLUTIONFILTERARBPROC __glewGetnConvolutionFilterARB; -GLEW_FUN_EXPORT PFNGLGETNHISTOGRAMARBPROC __glewGetnHistogramARB; -GLEW_FUN_EXPORT PFNGLGETNMAPDVARBPROC __glewGetnMapdvARB; -GLEW_FUN_EXPORT PFNGLGETNMAPFVARBPROC __glewGetnMapfvARB; -GLEW_FUN_EXPORT PFNGLGETNMAPIVARBPROC __glewGetnMapivARB; -GLEW_FUN_EXPORT PFNGLGETNMINMAXARBPROC __glewGetnMinmaxARB; -GLEW_FUN_EXPORT PFNGLGETNPIXELMAPFVARBPROC __glewGetnPixelMapfvARB; -GLEW_FUN_EXPORT PFNGLGETNPIXELMAPUIVARBPROC __glewGetnPixelMapuivARB; -GLEW_FUN_EXPORT PFNGLGETNPIXELMAPUSVARBPROC __glewGetnPixelMapusvARB; -GLEW_FUN_EXPORT PFNGLGETNPOLYGONSTIPPLEARBPROC __glewGetnPolygonStippleARB; -GLEW_FUN_EXPORT PFNGLGETNSEPARABLEFILTERARBPROC __glewGetnSeparableFilterARB; -GLEW_FUN_EXPORT PFNGLGETNTEXIMAGEARBPROC __glewGetnTexImageARB; -GLEW_FUN_EXPORT PFNGLGETNUNIFORMDVARBPROC __glewGetnUniformdvARB; -GLEW_FUN_EXPORT PFNGLGETNUNIFORMFVARBPROC __glewGetnUniformfvARB; -GLEW_FUN_EXPORT PFNGLGETNUNIFORMIVARBPROC __glewGetnUniformivARB; -GLEW_FUN_EXPORT PFNGLGETNUNIFORMUIVARBPROC __glewGetnUniformuivARB; -GLEW_FUN_EXPORT PFNGLREADNPIXELSARBPROC __glewReadnPixelsARB; - -GLEW_FUN_EXPORT PFNGLFRAMEBUFFERSAMPLELOCATIONSFVARBPROC __glewFramebufferSampleLocationsfvARB; -GLEW_FUN_EXPORT PFNGLNAMEDFRAMEBUFFERSAMPLELOCATIONSFVARBPROC __glewNamedFramebufferSampleLocationsfvARB; - -GLEW_FUN_EXPORT PFNGLMINSAMPLESHADINGARBPROC __glewMinSampleShadingARB; - -GLEW_FUN_EXPORT PFNGLBINDSAMPLERPROC __glewBindSampler; -GLEW_FUN_EXPORT PFNGLDELETESAMPLERSPROC __glewDeleteSamplers; -GLEW_FUN_EXPORT PFNGLGENSAMPLERSPROC __glewGenSamplers; -GLEW_FUN_EXPORT PFNGLGETSAMPLERPARAMETERIIVPROC __glewGetSamplerParameterIiv; -GLEW_FUN_EXPORT PFNGLGETSAMPLERPARAMETERIUIVPROC __glewGetSamplerParameterIuiv; -GLEW_FUN_EXPORT PFNGLGETSAMPLERPARAMETERFVPROC __glewGetSamplerParameterfv; -GLEW_FUN_EXPORT PFNGLGETSAMPLERPARAMETERIVPROC __glewGetSamplerParameteriv; -GLEW_FUN_EXPORT PFNGLISSAMPLERPROC __glewIsSampler; -GLEW_FUN_EXPORT PFNGLSAMPLERPARAMETERIIVPROC __glewSamplerParameterIiv; -GLEW_FUN_EXPORT PFNGLSAMPLERPARAMETERIUIVPROC __glewSamplerParameterIuiv; -GLEW_FUN_EXPORT PFNGLSAMPLERPARAMETERFPROC __glewSamplerParameterf; -GLEW_FUN_EXPORT PFNGLSAMPLERPARAMETERFVPROC __glewSamplerParameterfv; -GLEW_FUN_EXPORT PFNGLSAMPLERPARAMETERIPROC __glewSamplerParameteri; -GLEW_FUN_EXPORT PFNGLSAMPLERPARAMETERIVPROC __glewSamplerParameteriv; - -GLEW_FUN_EXPORT PFNGLACTIVESHADERPROGRAMPROC __glewActiveShaderProgram; -GLEW_FUN_EXPORT PFNGLBINDPROGRAMPIPELINEPROC __glewBindProgramPipeline; -GLEW_FUN_EXPORT PFNGLCREATESHADERPROGRAMVPROC __glewCreateShaderProgramv; -GLEW_FUN_EXPORT PFNGLDELETEPROGRAMPIPELINESPROC __glewDeleteProgramPipelines; -GLEW_FUN_EXPORT PFNGLGENPROGRAMPIPELINESPROC __glewGenProgramPipelines; -GLEW_FUN_EXPORT PFNGLGETPROGRAMPIPELINEINFOLOGPROC __glewGetProgramPipelineInfoLog; -GLEW_FUN_EXPORT PFNGLGETPROGRAMPIPELINEIVPROC __glewGetProgramPipelineiv; -GLEW_FUN_EXPORT PFNGLISPROGRAMPIPELINEPROC __glewIsProgramPipeline; -GLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM1DPROC __glewProgramUniform1d; -GLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM1DVPROC __glewProgramUniform1dv; -GLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM1FPROC __glewProgramUniform1f; -GLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM1FVPROC __glewProgramUniform1fv; -GLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM1IPROC __glewProgramUniform1i; -GLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM1IVPROC __glewProgramUniform1iv; -GLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM1UIPROC __glewProgramUniform1ui; -GLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM1UIVPROC __glewProgramUniform1uiv; -GLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM2DPROC __glewProgramUniform2d; -GLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM2DVPROC __glewProgramUniform2dv; -GLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM2FPROC __glewProgramUniform2f; -GLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM2FVPROC __glewProgramUniform2fv; -GLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM2IPROC __glewProgramUniform2i; -GLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM2IVPROC __glewProgramUniform2iv; -GLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM2UIPROC __glewProgramUniform2ui; -GLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM2UIVPROC __glewProgramUniform2uiv; -GLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM3DPROC __glewProgramUniform3d; -GLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM3DVPROC __glewProgramUniform3dv; -GLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM3FPROC __glewProgramUniform3f; -GLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM3FVPROC __glewProgramUniform3fv; -GLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM3IPROC __glewProgramUniform3i; -GLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM3IVPROC __glewProgramUniform3iv; -GLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM3UIPROC __glewProgramUniform3ui; -GLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM3UIVPROC __glewProgramUniform3uiv; -GLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM4DPROC __glewProgramUniform4d; -GLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM4DVPROC __glewProgramUniform4dv; -GLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM4FPROC __glewProgramUniform4f; -GLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM4FVPROC __glewProgramUniform4fv; -GLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM4IPROC __glewProgramUniform4i; -GLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM4IVPROC __glewProgramUniform4iv; -GLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM4UIPROC __glewProgramUniform4ui; -GLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM4UIVPROC __glewProgramUniform4uiv; -GLEW_FUN_EXPORT PFNGLPROGRAMUNIFORMMATRIX2DVPROC __glewProgramUniformMatrix2dv; -GLEW_FUN_EXPORT PFNGLPROGRAMUNIFORMMATRIX2FVPROC __glewProgramUniformMatrix2fv; -GLEW_FUN_EXPORT PFNGLPROGRAMUNIFORMMATRIX2X3DVPROC __glewProgramUniformMatrix2x3dv; -GLEW_FUN_EXPORT PFNGLPROGRAMUNIFORMMATRIX2X3FVPROC __glewProgramUniformMatrix2x3fv; -GLEW_FUN_EXPORT PFNGLPROGRAMUNIFORMMATRIX2X4DVPROC __glewProgramUniformMatrix2x4dv; -GLEW_FUN_EXPORT PFNGLPROGRAMUNIFORMMATRIX2X4FVPROC __glewProgramUniformMatrix2x4fv; -GLEW_FUN_EXPORT PFNGLPROGRAMUNIFORMMATRIX3DVPROC __glewProgramUniformMatrix3dv; -GLEW_FUN_EXPORT PFNGLPROGRAMUNIFORMMATRIX3FVPROC __glewProgramUniformMatrix3fv; -GLEW_FUN_EXPORT PFNGLPROGRAMUNIFORMMATRIX3X2DVPROC __glewProgramUniformMatrix3x2dv; -GLEW_FUN_EXPORT PFNGLPROGRAMUNIFORMMATRIX3X2FVPROC __glewProgramUniformMatrix3x2fv; -GLEW_FUN_EXPORT PFNGLPROGRAMUNIFORMMATRIX3X4DVPROC __glewProgramUniformMatrix3x4dv; -GLEW_FUN_EXPORT PFNGLPROGRAMUNIFORMMATRIX3X4FVPROC __glewProgramUniformMatrix3x4fv; -GLEW_FUN_EXPORT PFNGLPROGRAMUNIFORMMATRIX4DVPROC __glewProgramUniformMatrix4dv; -GLEW_FUN_EXPORT PFNGLPROGRAMUNIFORMMATRIX4FVPROC __glewProgramUniformMatrix4fv; -GLEW_FUN_EXPORT PFNGLPROGRAMUNIFORMMATRIX4X2DVPROC __glewProgramUniformMatrix4x2dv; -GLEW_FUN_EXPORT PFNGLPROGRAMUNIFORMMATRIX4X2FVPROC __glewProgramUniformMatrix4x2fv; -GLEW_FUN_EXPORT PFNGLPROGRAMUNIFORMMATRIX4X3DVPROC __glewProgramUniformMatrix4x3dv; -GLEW_FUN_EXPORT PFNGLPROGRAMUNIFORMMATRIX4X3FVPROC __glewProgramUniformMatrix4x3fv; -GLEW_FUN_EXPORT PFNGLUSEPROGRAMSTAGESPROC __glewUseProgramStages; -GLEW_FUN_EXPORT PFNGLVALIDATEPROGRAMPIPELINEPROC __glewValidateProgramPipeline; - -GLEW_FUN_EXPORT PFNGLGETACTIVEATOMICCOUNTERBUFFERIVPROC __glewGetActiveAtomicCounterBufferiv; - -GLEW_FUN_EXPORT PFNGLBINDIMAGETEXTUREPROC __glewBindImageTexture; -GLEW_FUN_EXPORT PFNGLMEMORYBARRIERPROC __glewMemoryBarrier; - -GLEW_FUN_EXPORT PFNGLATTACHOBJECTARBPROC __glewAttachObjectARB; -GLEW_FUN_EXPORT PFNGLCOMPILESHADERARBPROC __glewCompileShaderARB; -GLEW_FUN_EXPORT PFNGLCREATEPROGRAMOBJECTARBPROC __glewCreateProgramObjectARB; -GLEW_FUN_EXPORT PFNGLCREATESHADEROBJECTARBPROC __glewCreateShaderObjectARB; -GLEW_FUN_EXPORT PFNGLDELETEOBJECTARBPROC __glewDeleteObjectARB; -GLEW_FUN_EXPORT PFNGLDETACHOBJECTARBPROC __glewDetachObjectARB; -GLEW_FUN_EXPORT PFNGLGETACTIVEUNIFORMARBPROC __glewGetActiveUniformARB; -GLEW_FUN_EXPORT PFNGLGETATTACHEDOBJECTSARBPROC __glewGetAttachedObjectsARB; -GLEW_FUN_EXPORT PFNGLGETHANDLEARBPROC __glewGetHandleARB; -GLEW_FUN_EXPORT PFNGLGETINFOLOGARBPROC __glewGetInfoLogARB; -GLEW_FUN_EXPORT PFNGLGETOBJECTPARAMETERFVARBPROC __glewGetObjectParameterfvARB; -GLEW_FUN_EXPORT PFNGLGETOBJECTPARAMETERIVARBPROC __glewGetObjectParameterivARB; -GLEW_FUN_EXPORT PFNGLGETSHADERSOURCEARBPROC __glewGetShaderSourceARB; -GLEW_FUN_EXPORT PFNGLGETUNIFORMLOCATIONARBPROC __glewGetUniformLocationARB; -GLEW_FUN_EXPORT PFNGLGETUNIFORMFVARBPROC __glewGetUniformfvARB; -GLEW_FUN_EXPORT PFNGLGETUNIFORMIVARBPROC __glewGetUniformivARB; -GLEW_FUN_EXPORT PFNGLLINKPROGRAMARBPROC __glewLinkProgramARB; -GLEW_FUN_EXPORT PFNGLSHADERSOURCEARBPROC __glewShaderSourceARB; -GLEW_FUN_EXPORT PFNGLUNIFORM1FARBPROC __glewUniform1fARB; -GLEW_FUN_EXPORT PFNGLUNIFORM1FVARBPROC __glewUniform1fvARB; -GLEW_FUN_EXPORT PFNGLUNIFORM1IARBPROC __glewUniform1iARB; -GLEW_FUN_EXPORT PFNGLUNIFORM1IVARBPROC __glewUniform1ivARB; -GLEW_FUN_EXPORT PFNGLUNIFORM2FARBPROC __glewUniform2fARB; -GLEW_FUN_EXPORT PFNGLUNIFORM2FVARBPROC __glewUniform2fvARB; -GLEW_FUN_EXPORT PFNGLUNIFORM2IARBPROC __glewUniform2iARB; -GLEW_FUN_EXPORT PFNGLUNIFORM2IVARBPROC __glewUniform2ivARB; -GLEW_FUN_EXPORT PFNGLUNIFORM3FARBPROC __glewUniform3fARB; -GLEW_FUN_EXPORT PFNGLUNIFORM3FVARBPROC __glewUniform3fvARB; -GLEW_FUN_EXPORT PFNGLUNIFORM3IARBPROC __glewUniform3iARB; -GLEW_FUN_EXPORT PFNGLUNIFORM3IVARBPROC __glewUniform3ivARB; -GLEW_FUN_EXPORT PFNGLUNIFORM4FARBPROC __glewUniform4fARB; -GLEW_FUN_EXPORT PFNGLUNIFORM4FVARBPROC __glewUniform4fvARB; -GLEW_FUN_EXPORT PFNGLUNIFORM4IARBPROC __glewUniform4iARB; -GLEW_FUN_EXPORT PFNGLUNIFORM4IVARBPROC __glewUniform4ivARB; -GLEW_FUN_EXPORT PFNGLUNIFORMMATRIX2FVARBPROC __glewUniformMatrix2fvARB; -GLEW_FUN_EXPORT PFNGLUNIFORMMATRIX3FVARBPROC __glewUniformMatrix3fvARB; -GLEW_FUN_EXPORT PFNGLUNIFORMMATRIX4FVARBPROC __glewUniformMatrix4fvARB; -GLEW_FUN_EXPORT PFNGLUSEPROGRAMOBJECTARBPROC __glewUseProgramObjectARB; -GLEW_FUN_EXPORT PFNGLVALIDATEPROGRAMARBPROC __glewValidateProgramARB; - -GLEW_FUN_EXPORT PFNGLSHADERSTORAGEBLOCKBINDINGPROC __glewShaderStorageBlockBinding; - -GLEW_FUN_EXPORT PFNGLGETACTIVESUBROUTINENAMEPROC __glewGetActiveSubroutineName; -GLEW_FUN_EXPORT PFNGLGETACTIVESUBROUTINEUNIFORMNAMEPROC __glewGetActiveSubroutineUniformName; -GLEW_FUN_EXPORT PFNGLGETACTIVESUBROUTINEUNIFORMIVPROC __glewGetActiveSubroutineUniformiv; -GLEW_FUN_EXPORT PFNGLGETPROGRAMSTAGEIVPROC __glewGetProgramStageiv; -GLEW_FUN_EXPORT PFNGLGETSUBROUTINEINDEXPROC __glewGetSubroutineIndex; -GLEW_FUN_EXPORT PFNGLGETSUBROUTINEUNIFORMLOCATIONPROC __glewGetSubroutineUniformLocation; -GLEW_FUN_EXPORT PFNGLGETUNIFORMSUBROUTINEUIVPROC __glewGetUniformSubroutineuiv; -GLEW_FUN_EXPORT PFNGLUNIFORMSUBROUTINESUIVPROC __glewUniformSubroutinesuiv; - -GLEW_FUN_EXPORT PFNGLCOMPILESHADERINCLUDEARBPROC __glewCompileShaderIncludeARB; -GLEW_FUN_EXPORT PFNGLDELETENAMEDSTRINGARBPROC __glewDeleteNamedStringARB; -GLEW_FUN_EXPORT PFNGLGETNAMEDSTRINGARBPROC __glewGetNamedStringARB; -GLEW_FUN_EXPORT PFNGLGETNAMEDSTRINGIVARBPROC __glewGetNamedStringivARB; -GLEW_FUN_EXPORT PFNGLISNAMEDSTRINGARBPROC __glewIsNamedStringARB; -GLEW_FUN_EXPORT PFNGLNAMEDSTRINGARBPROC __glewNamedStringARB; - -GLEW_FUN_EXPORT PFNGLBUFFERPAGECOMMITMENTARBPROC __glewBufferPageCommitmentARB; - -GLEW_FUN_EXPORT PFNGLTEXPAGECOMMITMENTARBPROC __glewTexPageCommitmentARB; -GLEW_FUN_EXPORT PFNGLTEXTUREPAGECOMMITMENTEXTPROC __glewTexturePageCommitmentEXT; - -GLEW_FUN_EXPORT PFNGLCLIENTWAITSYNCPROC __glewClientWaitSync; -GLEW_FUN_EXPORT PFNGLDELETESYNCPROC __glewDeleteSync; -GLEW_FUN_EXPORT PFNGLFENCESYNCPROC __glewFenceSync; -GLEW_FUN_EXPORT PFNGLGETINTEGER64VPROC __glewGetInteger64v; -GLEW_FUN_EXPORT PFNGLGETSYNCIVPROC __glewGetSynciv; -GLEW_FUN_EXPORT PFNGLISSYNCPROC __glewIsSync; -GLEW_FUN_EXPORT PFNGLWAITSYNCPROC __glewWaitSync; - -GLEW_FUN_EXPORT PFNGLPATCHPARAMETERFVPROC __glewPatchParameterfv; -GLEW_FUN_EXPORT PFNGLPATCHPARAMETERIPROC __glewPatchParameteri; - -GLEW_FUN_EXPORT PFNGLTEXTUREBARRIERPROC __glewTextureBarrier; - -GLEW_FUN_EXPORT PFNGLTEXBUFFERARBPROC __glewTexBufferARB; - -GLEW_FUN_EXPORT PFNGLTEXBUFFERRANGEPROC __glewTexBufferRange; -GLEW_FUN_EXPORT PFNGLTEXTUREBUFFERRANGEEXTPROC __glewTextureBufferRangeEXT; - -GLEW_FUN_EXPORT PFNGLCOMPRESSEDTEXIMAGE1DARBPROC __glewCompressedTexImage1DARB; -GLEW_FUN_EXPORT PFNGLCOMPRESSEDTEXIMAGE2DARBPROC __glewCompressedTexImage2DARB; -GLEW_FUN_EXPORT PFNGLCOMPRESSEDTEXIMAGE3DARBPROC __glewCompressedTexImage3DARB; -GLEW_FUN_EXPORT PFNGLCOMPRESSEDTEXSUBIMAGE1DARBPROC __glewCompressedTexSubImage1DARB; -GLEW_FUN_EXPORT PFNGLCOMPRESSEDTEXSUBIMAGE2DARBPROC __glewCompressedTexSubImage2DARB; -GLEW_FUN_EXPORT PFNGLCOMPRESSEDTEXSUBIMAGE3DARBPROC __glewCompressedTexSubImage3DARB; -GLEW_FUN_EXPORT PFNGLGETCOMPRESSEDTEXIMAGEARBPROC __glewGetCompressedTexImageARB; - -GLEW_FUN_EXPORT PFNGLGETMULTISAMPLEFVPROC __glewGetMultisamplefv; -GLEW_FUN_EXPORT PFNGLSAMPLEMASKIPROC __glewSampleMaski; -GLEW_FUN_EXPORT PFNGLTEXIMAGE2DMULTISAMPLEPROC __glewTexImage2DMultisample; -GLEW_FUN_EXPORT PFNGLTEXIMAGE3DMULTISAMPLEPROC __glewTexImage3DMultisample; - -GLEW_FUN_EXPORT PFNGLTEXSTORAGE1DPROC __glewTexStorage1D; -GLEW_FUN_EXPORT PFNGLTEXSTORAGE2DPROC __glewTexStorage2D; -GLEW_FUN_EXPORT PFNGLTEXSTORAGE3DPROC __glewTexStorage3D; -GLEW_FUN_EXPORT PFNGLTEXTURESTORAGE1DEXTPROC __glewTextureStorage1DEXT; -GLEW_FUN_EXPORT PFNGLTEXTURESTORAGE2DEXTPROC __glewTextureStorage2DEXT; -GLEW_FUN_EXPORT PFNGLTEXTURESTORAGE3DEXTPROC __glewTextureStorage3DEXT; - -GLEW_FUN_EXPORT PFNGLTEXSTORAGE2DMULTISAMPLEPROC __glewTexStorage2DMultisample; -GLEW_FUN_EXPORT PFNGLTEXSTORAGE3DMULTISAMPLEPROC __glewTexStorage3DMultisample; -GLEW_FUN_EXPORT PFNGLTEXTURESTORAGE2DMULTISAMPLEEXTPROC __glewTextureStorage2DMultisampleEXT; -GLEW_FUN_EXPORT PFNGLTEXTURESTORAGE3DMULTISAMPLEEXTPROC __glewTextureStorage3DMultisampleEXT; - -GLEW_FUN_EXPORT PFNGLTEXTUREVIEWPROC __glewTextureView; - -GLEW_FUN_EXPORT PFNGLGETQUERYOBJECTI64VPROC __glewGetQueryObjecti64v; -GLEW_FUN_EXPORT PFNGLGETQUERYOBJECTUI64VPROC __glewGetQueryObjectui64v; -GLEW_FUN_EXPORT PFNGLQUERYCOUNTERPROC __glewQueryCounter; - -GLEW_FUN_EXPORT PFNGLBINDTRANSFORMFEEDBACKPROC __glewBindTransformFeedback; -GLEW_FUN_EXPORT PFNGLDELETETRANSFORMFEEDBACKSPROC __glewDeleteTransformFeedbacks; -GLEW_FUN_EXPORT PFNGLDRAWTRANSFORMFEEDBACKPROC __glewDrawTransformFeedback; -GLEW_FUN_EXPORT PFNGLGENTRANSFORMFEEDBACKSPROC __glewGenTransformFeedbacks; -GLEW_FUN_EXPORT PFNGLISTRANSFORMFEEDBACKPROC __glewIsTransformFeedback; -GLEW_FUN_EXPORT PFNGLPAUSETRANSFORMFEEDBACKPROC __glewPauseTransformFeedback; -GLEW_FUN_EXPORT PFNGLRESUMETRANSFORMFEEDBACKPROC __glewResumeTransformFeedback; - -GLEW_FUN_EXPORT PFNGLBEGINQUERYINDEXEDPROC __glewBeginQueryIndexed; -GLEW_FUN_EXPORT PFNGLDRAWTRANSFORMFEEDBACKSTREAMPROC __glewDrawTransformFeedbackStream; -GLEW_FUN_EXPORT PFNGLENDQUERYINDEXEDPROC __glewEndQueryIndexed; -GLEW_FUN_EXPORT PFNGLGETQUERYINDEXEDIVPROC __glewGetQueryIndexediv; - -GLEW_FUN_EXPORT PFNGLDRAWTRANSFORMFEEDBACKINSTANCEDPROC __glewDrawTransformFeedbackInstanced; -GLEW_FUN_EXPORT PFNGLDRAWTRANSFORMFEEDBACKSTREAMINSTANCEDPROC __glewDrawTransformFeedbackStreamInstanced; - -GLEW_FUN_EXPORT PFNGLLOADTRANSPOSEMATRIXDARBPROC __glewLoadTransposeMatrixdARB; -GLEW_FUN_EXPORT PFNGLLOADTRANSPOSEMATRIXFARBPROC __glewLoadTransposeMatrixfARB; -GLEW_FUN_EXPORT PFNGLMULTTRANSPOSEMATRIXDARBPROC __glewMultTransposeMatrixdARB; -GLEW_FUN_EXPORT PFNGLMULTTRANSPOSEMATRIXFARBPROC __glewMultTransposeMatrixfARB; - -GLEW_FUN_EXPORT PFNGLBINDBUFFERBASEPROC __glewBindBufferBase; -GLEW_FUN_EXPORT PFNGLBINDBUFFERRANGEPROC __glewBindBufferRange; -GLEW_FUN_EXPORT PFNGLGETACTIVEUNIFORMBLOCKNAMEPROC __glewGetActiveUniformBlockName; -GLEW_FUN_EXPORT PFNGLGETACTIVEUNIFORMBLOCKIVPROC __glewGetActiveUniformBlockiv; -GLEW_FUN_EXPORT PFNGLGETACTIVEUNIFORMNAMEPROC __glewGetActiveUniformName; -GLEW_FUN_EXPORT PFNGLGETACTIVEUNIFORMSIVPROC __glewGetActiveUniformsiv; -GLEW_FUN_EXPORT PFNGLGETINTEGERI_VPROC __glewGetIntegeri_v; -GLEW_FUN_EXPORT PFNGLGETUNIFORMBLOCKINDEXPROC __glewGetUniformBlockIndex; -GLEW_FUN_EXPORT PFNGLGETUNIFORMINDICESPROC __glewGetUniformIndices; -GLEW_FUN_EXPORT PFNGLUNIFORMBLOCKBINDINGPROC __glewUniformBlockBinding; - -GLEW_FUN_EXPORT PFNGLBINDVERTEXARRAYPROC __glewBindVertexArray; -GLEW_FUN_EXPORT PFNGLDELETEVERTEXARRAYSPROC __glewDeleteVertexArrays; -GLEW_FUN_EXPORT PFNGLGENVERTEXARRAYSPROC __glewGenVertexArrays; -GLEW_FUN_EXPORT PFNGLISVERTEXARRAYPROC __glewIsVertexArray; - -GLEW_FUN_EXPORT PFNGLGETVERTEXATTRIBLDVPROC __glewGetVertexAttribLdv; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIBL1DPROC __glewVertexAttribL1d; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIBL1DVPROC __glewVertexAttribL1dv; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIBL2DPROC __glewVertexAttribL2d; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIBL2DVPROC __glewVertexAttribL2dv; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIBL3DPROC __glewVertexAttribL3d; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIBL3DVPROC __glewVertexAttribL3dv; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIBL4DPROC __glewVertexAttribL4d; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIBL4DVPROC __glewVertexAttribL4dv; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIBLPOINTERPROC __glewVertexAttribLPointer; - -GLEW_FUN_EXPORT PFNGLBINDVERTEXBUFFERPROC __glewBindVertexBuffer; -GLEW_FUN_EXPORT PFNGLVERTEXARRAYBINDVERTEXBUFFEREXTPROC __glewVertexArrayBindVertexBufferEXT; -GLEW_FUN_EXPORT PFNGLVERTEXARRAYVERTEXATTRIBBINDINGEXTPROC __glewVertexArrayVertexAttribBindingEXT; -GLEW_FUN_EXPORT PFNGLVERTEXARRAYVERTEXATTRIBFORMATEXTPROC __glewVertexArrayVertexAttribFormatEXT; -GLEW_FUN_EXPORT PFNGLVERTEXARRAYVERTEXATTRIBIFORMATEXTPROC __glewVertexArrayVertexAttribIFormatEXT; -GLEW_FUN_EXPORT PFNGLVERTEXARRAYVERTEXATTRIBLFORMATEXTPROC __glewVertexArrayVertexAttribLFormatEXT; -GLEW_FUN_EXPORT PFNGLVERTEXARRAYVERTEXBINDINGDIVISOREXTPROC __glewVertexArrayVertexBindingDivisorEXT; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIBBINDINGPROC __glewVertexAttribBinding; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIBFORMATPROC __glewVertexAttribFormat; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIBIFORMATPROC __glewVertexAttribIFormat; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIBLFORMATPROC __glewVertexAttribLFormat; -GLEW_FUN_EXPORT PFNGLVERTEXBINDINGDIVISORPROC __glewVertexBindingDivisor; - -GLEW_FUN_EXPORT PFNGLVERTEXBLENDARBPROC __glewVertexBlendARB; -GLEW_FUN_EXPORT PFNGLWEIGHTPOINTERARBPROC __glewWeightPointerARB; -GLEW_FUN_EXPORT PFNGLWEIGHTBVARBPROC __glewWeightbvARB; -GLEW_FUN_EXPORT PFNGLWEIGHTDVARBPROC __glewWeightdvARB; -GLEW_FUN_EXPORT PFNGLWEIGHTFVARBPROC __glewWeightfvARB; -GLEW_FUN_EXPORT PFNGLWEIGHTIVARBPROC __glewWeightivARB; -GLEW_FUN_EXPORT PFNGLWEIGHTSVARBPROC __glewWeightsvARB; -GLEW_FUN_EXPORT PFNGLWEIGHTUBVARBPROC __glewWeightubvARB; -GLEW_FUN_EXPORT PFNGLWEIGHTUIVARBPROC __glewWeightuivARB; -GLEW_FUN_EXPORT PFNGLWEIGHTUSVARBPROC __glewWeightusvARB; - -GLEW_FUN_EXPORT PFNGLBINDBUFFERARBPROC __glewBindBufferARB; -GLEW_FUN_EXPORT PFNGLBUFFERDATAARBPROC __glewBufferDataARB; -GLEW_FUN_EXPORT PFNGLBUFFERSUBDATAARBPROC __glewBufferSubDataARB; -GLEW_FUN_EXPORT PFNGLDELETEBUFFERSARBPROC __glewDeleteBuffersARB; -GLEW_FUN_EXPORT PFNGLGENBUFFERSARBPROC __glewGenBuffersARB; -GLEW_FUN_EXPORT PFNGLGETBUFFERPARAMETERIVARBPROC __glewGetBufferParameterivARB; -GLEW_FUN_EXPORT PFNGLGETBUFFERPOINTERVARBPROC __glewGetBufferPointervARB; -GLEW_FUN_EXPORT PFNGLGETBUFFERSUBDATAARBPROC __glewGetBufferSubDataARB; -GLEW_FUN_EXPORT PFNGLISBUFFERARBPROC __glewIsBufferARB; -GLEW_FUN_EXPORT PFNGLMAPBUFFERARBPROC __glewMapBufferARB; -GLEW_FUN_EXPORT PFNGLUNMAPBUFFERARBPROC __glewUnmapBufferARB; - -GLEW_FUN_EXPORT PFNGLBINDPROGRAMARBPROC __glewBindProgramARB; -GLEW_FUN_EXPORT PFNGLDELETEPROGRAMSARBPROC __glewDeleteProgramsARB; -GLEW_FUN_EXPORT PFNGLDISABLEVERTEXATTRIBARRAYARBPROC __glewDisableVertexAttribArrayARB; -GLEW_FUN_EXPORT PFNGLENABLEVERTEXATTRIBARRAYARBPROC __glewEnableVertexAttribArrayARB; -GLEW_FUN_EXPORT PFNGLGENPROGRAMSARBPROC __glewGenProgramsARB; -GLEW_FUN_EXPORT PFNGLGETPROGRAMENVPARAMETERDVARBPROC __glewGetProgramEnvParameterdvARB; -GLEW_FUN_EXPORT PFNGLGETPROGRAMENVPARAMETERFVARBPROC __glewGetProgramEnvParameterfvARB; -GLEW_FUN_EXPORT PFNGLGETPROGRAMLOCALPARAMETERDVARBPROC __glewGetProgramLocalParameterdvARB; -GLEW_FUN_EXPORT PFNGLGETPROGRAMLOCALPARAMETERFVARBPROC __glewGetProgramLocalParameterfvARB; -GLEW_FUN_EXPORT PFNGLGETPROGRAMSTRINGARBPROC __glewGetProgramStringARB; -GLEW_FUN_EXPORT PFNGLGETPROGRAMIVARBPROC __glewGetProgramivARB; -GLEW_FUN_EXPORT PFNGLGETVERTEXATTRIBPOINTERVARBPROC __glewGetVertexAttribPointervARB; -GLEW_FUN_EXPORT PFNGLGETVERTEXATTRIBDVARBPROC __glewGetVertexAttribdvARB; -GLEW_FUN_EXPORT PFNGLGETVERTEXATTRIBFVARBPROC __glewGetVertexAttribfvARB; -GLEW_FUN_EXPORT PFNGLGETVERTEXATTRIBIVARBPROC __glewGetVertexAttribivARB; -GLEW_FUN_EXPORT PFNGLISPROGRAMARBPROC __glewIsProgramARB; -GLEW_FUN_EXPORT PFNGLPROGRAMENVPARAMETER4DARBPROC __glewProgramEnvParameter4dARB; -GLEW_FUN_EXPORT PFNGLPROGRAMENVPARAMETER4DVARBPROC __glewProgramEnvParameter4dvARB; -GLEW_FUN_EXPORT PFNGLPROGRAMENVPARAMETER4FARBPROC __glewProgramEnvParameter4fARB; -GLEW_FUN_EXPORT PFNGLPROGRAMENVPARAMETER4FVARBPROC __glewProgramEnvParameter4fvARB; -GLEW_FUN_EXPORT PFNGLPROGRAMLOCALPARAMETER4DARBPROC __glewProgramLocalParameter4dARB; -GLEW_FUN_EXPORT PFNGLPROGRAMLOCALPARAMETER4DVARBPROC __glewProgramLocalParameter4dvARB; -GLEW_FUN_EXPORT PFNGLPROGRAMLOCALPARAMETER4FARBPROC __glewProgramLocalParameter4fARB; -GLEW_FUN_EXPORT PFNGLPROGRAMLOCALPARAMETER4FVARBPROC __glewProgramLocalParameter4fvARB; -GLEW_FUN_EXPORT PFNGLPROGRAMSTRINGARBPROC __glewProgramStringARB; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIB1DARBPROC __glewVertexAttrib1dARB; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIB1DVARBPROC __glewVertexAttrib1dvARB; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIB1FARBPROC __glewVertexAttrib1fARB; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIB1FVARBPROC __glewVertexAttrib1fvARB; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIB1SARBPROC __glewVertexAttrib1sARB; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIB1SVARBPROC __glewVertexAttrib1svARB; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIB2DARBPROC __glewVertexAttrib2dARB; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIB2DVARBPROC __glewVertexAttrib2dvARB; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIB2FARBPROC __glewVertexAttrib2fARB; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIB2FVARBPROC __glewVertexAttrib2fvARB; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIB2SARBPROC __glewVertexAttrib2sARB; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIB2SVARBPROC __glewVertexAttrib2svARB; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIB3DARBPROC __glewVertexAttrib3dARB; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIB3DVARBPROC __glewVertexAttrib3dvARB; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIB3FARBPROC __glewVertexAttrib3fARB; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIB3FVARBPROC __glewVertexAttrib3fvARB; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIB3SARBPROC __glewVertexAttrib3sARB; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIB3SVARBPROC __glewVertexAttrib3svARB; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIB4NBVARBPROC __glewVertexAttrib4NbvARB; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIB4NIVARBPROC __glewVertexAttrib4NivARB; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIB4NSVARBPROC __glewVertexAttrib4NsvARB; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIB4NUBARBPROC __glewVertexAttrib4NubARB; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIB4NUBVARBPROC __glewVertexAttrib4NubvARB; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIB4NUIVARBPROC __glewVertexAttrib4NuivARB; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIB4NUSVARBPROC __glewVertexAttrib4NusvARB; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIB4BVARBPROC __glewVertexAttrib4bvARB; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIB4DARBPROC __glewVertexAttrib4dARB; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIB4DVARBPROC __glewVertexAttrib4dvARB; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIB4FARBPROC __glewVertexAttrib4fARB; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIB4FVARBPROC __glewVertexAttrib4fvARB; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIB4IVARBPROC __glewVertexAttrib4ivARB; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIB4SARBPROC __glewVertexAttrib4sARB; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIB4SVARBPROC __glewVertexAttrib4svARB; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIB4UBVARBPROC __glewVertexAttrib4ubvARB; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIB4UIVARBPROC __glewVertexAttrib4uivARB; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIB4USVARBPROC __glewVertexAttrib4usvARB; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIBPOINTERARBPROC __glewVertexAttribPointerARB; - -GLEW_FUN_EXPORT PFNGLBINDATTRIBLOCATIONARBPROC __glewBindAttribLocationARB; -GLEW_FUN_EXPORT PFNGLGETACTIVEATTRIBARBPROC __glewGetActiveAttribARB; -GLEW_FUN_EXPORT PFNGLGETATTRIBLOCATIONARBPROC __glewGetAttribLocationARB; - -GLEW_FUN_EXPORT PFNGLCOLORP3UIPROC __glewColorP3ui; -GLEW_FUN_EXPORT PFNGLCOLORP3UIVPROC __glewColorP3uiv; -GLEW_FUN_EXPORT PFNGLCOLORP4UIPROC __glewColorP4ui; -GLEW_FUN_EXPORT PFNGLCOLORP4UIVPROC __glewColorP4uiv; -GLEW_FUN_EXPORT PFNGLMULTITEXCOORDP1UIPROC __glewMultiTexCoordP1ui; -GLEW_FUN_EXPORT PFNGLMULTITEXCOORDP1UIVPROC __glewMultiTexCoordP1uiv; -GLEW_FUN_EXPORT PFNGLMULTITEXCOORDP2UIPROC __glewMultiTexCoordP2ui; -GLEW_FUN_EXPORT PFNGLMULTITEXCOORDP2UIVPROC __glewMultiTexCoordP2uiv; -GLEW_FUN_EXPORT PFNGLMULTITEXCOORDP3UIPROC __glewMultiTexCoordP3ui; -GLEW_FUN_EXPORT PFNGLMULTITEXCOORDP3UIVPROC __glewMultiTexCoordP3uiv; -GLEW_FUN_EXPORT PFNGLMULTITEXCOORDP4UIPROC __glewMultiTexCoordP4ui; -GLEW_FUN_EXPORT PFNGLMULTITEXCOORDP4UIVPROC __glewMultiTexCoordP4uiv; -GLEW_FUN_EXPORT PFNGLNORMALP3UIPROC __glewNormalP3ui; -GLEW_FUN_EXPORT PFNGLNORMALP3UIVPROC __glewNormalP3uiv; -GLEW_FUN_EXPORT PFNGLSECONDARYCOLORP3UIPROC __glewSecondaryColorP3ui; -GLEW_FUN_EXPORT PFNGLSECONDARYCOLORP3UIVPROC __glewSecondaryColorP3uiv; -GLEW_FUN_EXPORT PFNGLTEXCOORDP1UIPROC __glewTexCoordP1ui; -GLEW_FUN_EXPORT PFNGLTEXCOORDP1UIVPROC __glewTexCoordP1uiv; -GLEW_FUN_EXPORT PFNGLTEXCOORDP2UIPROC __glewTexCoordP2ui; -GLEW_FUN_EXPORT PFNGLTEXCOORDP2UIVPROC __glewTexCoordP2uiv; -GLEW_FUN_EXPORT PFNGLTEXCOORDP3UIPROC __glewTexCoordP3ui; -GLEW_FUN_EXPORT PFNGLTEXCOORDP3UIVPROC __glewTexCoordP3uiv; -GLEW_FUN_EXPORT PFNGLTEXCOORDP4UIPROC __glewTexCoordP4ui; -GLEW_FUN_EXPORT PFNGLTEXCOORDP4UIVPROC __glewTexCoordP4uiv; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIBP1UIPROC __glewVertexAttribP1ui; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIBP1UIVPROC __glewVertexAttribP1uiv; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIBP2UIPROC __glewVertexAttribP2ui; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIBP2UIVPROC __glewVertexAttribP2uiv; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIBP3UIPROC __glewVertexAttribP3ui; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIBP3UIVPROC __glewVertexAttribP3uiv; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIBP4UIPROC __glewVertexAttribP4ui; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIBP4UIVPROC __glewVertexAttribP4uiv; -GLEW_FUN_EXPORT PFNGLVERTEXP2UIPROC __glewVertexP2ui; -GLEW_FUN_EXPORT PFNGLVERTEXP2UIVPROC __glewVertexP2uiv; -GLEW_FUN_EXPORT PFNGLVERTEXP3UIPROC __glewVertexP3ui; -GLEW_FUN_EXPORT PFNGLVERTEXP3UIVPROC __glewVertexP3uiv; -GLEW_FUN_EXPORT PFNGLVERTEXP4UIPROC __glewVertexP4ui; -GLEW_FUN_EXPORT PFNGLVERTEXP4UIVPROC __glewVertexP4uiv; - -GLEW_FUN_EXPORT PFNGLDEPTHRANGEARRAYVPROC __glewDepthRangeArrayv; -GLEW_FUN_EXPORT PFNGLDEPTHRANGEINDEXEDPROC __glewDepthRangeIndexed; -GLEW_FUN_EXPORT PFNGLGETDOUBLEI_VPROC __glewGetDoublei_v; -GLEW_FUN_EXPORT PFNGLGETFLOATI_VPROC __glewGetFloati_v; -GLEW_FUN_EXPORT PFNGLSCISSORARRAYVPROC __glewScissorArrayv; -GLEW_FUN_EXPORT PFNGLSCISSORINDEXEDPROC __glewScissorIndexed; -GLEW_FUN_EXPORT PFNGLSCISSORINDEXEDVPROC __glewScissorIndexedv; -GLEW_FUN_EXPORT PFNGLVIEWPORTARRAYVPROC __glewViewportArrayv; -GLEW_FUN_EXPORT PFNGLVIEWPORTINDEXEDFPROC __glewViewportIndexedf; -GLEW_FUN_EXPORT PFNGLVIEWPORTINDEXEDFVPROC __glewViewportIndexedfv; - -GLEW_FUN_EXPORT PFNGLWINDOWPOS2DARBPROC __glewWindowPos2dARB; -GLEW_FUN_EXPORT PFNGLWINDOWPOS2DVARBPROC __glewWindowPos2dvARB; -GLEW_FUN_EXPORT PFNGLWINDOWPOS2FARBPROC __glewWindowPos2fARB; -GLEW_FUN_EXPORT PFNGLWINDOWPOS2FVARBPROC __glewWindowPos2fvARB; -GLEW_FUN_EXPORT PFNGLWINDOWPOS2IARBPROC __glewWindowPos2iARB; -GLEW_FUN_EXPORT PFNGLWINDOWPOS2IVARBPROC __glewWindowPos2ivARB; -GLEW_FUN_EXPORT PFNGLWINDOWPOS2SARBPROC __glewWindowPos2sARB; -GLEW_FUN_EXPORT PFNGLWINDOWPOS2SVARBPROC __glewWindowPos2svARB; -GLEW_FUN_EXPORT PFNGLWINDOWPOS3DARBPROC __glewWindowPos3dARB; -GLEW_FUN_EXPORT PFNGLWINDOWPOS3DVARBPROC __glewWindowPos3dvARB; -GLEW_FUN_EXPORT PFNGLWINDOWPOS3FARBPROC __glewWindowPos3fARB; -GLEW_FUN_EXPORT PFNGLWINDOWPOS3FVARBPROC __glewWindowPos3fvARB; -GLEW_FUN_EXPORT PFNGLWINDOWPOS3IARBPROC __glewWindowPos3iARB; -GLEW_FUN_EXPORT PFNGLWINDOWPOS3IVARBPROC __glewWindowPos3ivARB; -GLEW_FUN_EXPORT PFNGLWINDOWPOS3SARBPROC __glewWindowPos3sARB; -GLEW_FUN_EXPORT PFNGLWINDOWPOS3SVARBPROC __glewWindowPos3svARB; - -GLEW_FUN_EXPORT PFNGLDRAWBUFFERSATIPROC __glewDrawBuffersATI; - -GLEW_FUN_EXPORT PFNGLDRAWELEMENTARRAYATIPROC __glewDrawElementArrayATI; -GLEW_FUN_EXPORT PFNGLDRAWRANGEELEMENTARRAYATIPROC __glewDrawRangeElementArrayATI; -GLEW_FUN_EXPORT PFNGLELEMENTPOINTERATIPROC __glewElementPointerATI; - -GLEW_FUN_EXPORT PFNGLGETTEXBUMPPARAMETERFVATIPROC __glewGetTexBumpParameterfvATI; -GLEW_FUN_EXPORT PFNGLGETTEXBUMPPARAMETERIVATIPROC __glewGetTexBumpParameterivATI; -GLEW_FUN_EXPORT PFNGLTEXBUMPPARAMETERFVATIPROC __glewTexBumpParameterfvATI; -GLEW_FUN_EXPORT PFNGLTEXBUMPPARAMETERIVATIPROC __glewTexBumpParameterivATI; - -GLEW_FUN_EXPORT PFNGLALPHAFRAGMENTOP1ATIPROC __glewAlphaFragmentOp1ATI; -GLEW_FUN_EXPORT PFNGLALPHAFRAGMENTOP2ATIPROC __glewAlphaFragmentOp2ATI; -GLEW_FUN_EXPORT PFNGLALPHAFRAGMENTOP3ATIPROC __glewAlphaFragmentOp3ATI; -GLEW_FUN_EXPORT PFNGLBEGINFRAGMENTSHADERATIPROC __glewBeginFragmentShaderATI; -GLEW_FUN_EXPORT PFNGLBINDFRAGMENTSHADERATIPROC __glewBindFragmentShaderATI; -GLEW_FUN_EXPORT PFNGLCOLORFRAGMENTOP1ATIPROC __glewColorFragmentOp1ATI; -GLEW_FUN_EXPORT PFNGLCOLORFRAGMENTOP2ATIPROC __glewColorFragmentOp2ATI; -GLEW_FUN_EXPORT PFNGLCOLORFRAGMENTOP3ATIPROC __glewColorFragmentOp3ATI; -GLEW_FUN_EXPORT PFNGLDELETEFRAGMENTSHADERATIPROC __glewDeleteFragmentShaderATI; -GLEW_FUN_EXPORT PFNGLENDFRAGMENTSHADERATIPROC __glewEndFragmentShaderATI; -GLEW_FUN_EXPORT PFNGLGENFRAGMENTSHADERSATIPROC __glewGenFragmentShadersATI; -GLEW_FUN_EXPORT PFNGLPASSTEXCOORDATIPROC __glewPassTexCoordATI; -GLEW_FUN_EXPORT PFNGLSAMPLEMAPATIPROC __glewSampleMapATI; -GLEW_FUN_EXPORT PFNGLSETFRAGMENTSHADERCONSTANTATIPROC __glewSetFragmentShaderConstantATI; - -GLEW_FUN_EXPORT PFNGLMAPOBJECTBUFFERATIPROC __glewMapObjectBufferATI; -GLEW_FUN_EXPORT PFNGLUNMAPOBJECTBUFFERATIPROC __glewUnmapObjectBufferATI; - -GLEW_FUN_EXPORT PFNGLPNTRIANGLESFATIPROC __glewPNTrianglesfATI; -GLEW_FUN_EXPORT PFNGLPNTRIANGLESIATIPROC __glewPNTrianglesiATI; - -GLEW_FUN_EXPORT PFNGLSTENCILFUNCSEPARATEATIPROC __glewStencilFuncSeparateATI; -GLEW_FUN_EXPORT PFNGLSTENCILOPSEPARATEATIPROC __glewStencilOpSeparateATI; - -GLEW_FUN_EXPORT PFNGLARRAYOBJECTATIPROC __glewArrayObjectATI; -GLEW_FUN_EXPORT PFNGLFREEOBJECTBUFFERATIPROC __glewFreeObjectBufferATI; -GLEW_FUN_EXPORT PFNGLGETARRAYOBJECTFVATIPROC __glewGetArrayObjectfvATI; -GLEW_FUN_EXPORT PFNGLGETARRAYOBJECTIVATIPROC __glewGetArrayObjectivATI; -GLEW_FUN_EXPORT PFNGLGETOBJECTBUFFERFVATIPROC __glewGetObjectBufferfvATI; -GLEW_FUN_EXPORT PFNGLGETOBJECTBUFFERIVATIPROC __glewGetObjectBufferivATI; -GLEW_FUN_EXPORT PFNGLGETVARIANTARRAYOBJECTFVATIPROC __glewGetVariantArrayObjectfvATI; -GLEW_FUN_EXPORT PFNGLGETVARIANTARRAYOBJECTIVATIPROC __glewGetVariantArrayObjectivATI; -GLEW_FUN_EXPORT PFNGLISOBJECTBUFFERATIPROC __glewIsObjectBufferATI; -GLEW_FUN_EXPORT PFNGLNEWOBJECTBUFFERATIPROC __glewNewObjectBufferATI; -GLEW_FUN_EXPORT PFNGLUPDATEOBJECTBUFFERATIPROC __glewUpdateObjectBufferATI; -GLEW_FUN_EXPORT PFNGLVARIANTARRAYOBJECTATIPROC __glewVariantArrayObjectATI; - -GLEW_FUN_EXPORT PFNGLGETVERTEXATTRIBARRAYOBJECTFVATIPROC __glewGetVertexAttribArrayObjectfvATI; -GLEW_FUN_EXPORT PFNGLGETVERTEXATTRIBARRAYOBJECTIVATIPROC __glewGetVertexAttribArrayObjectivATI; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIBARRAYOBJECTATIPROC __glewVertexAttribArrayObjectATI; - -GLEW_FUN_EXPORT PFNGLCLIENTACTIVEVERTEXSTREAMATIPROC __glewClientActiveVertexStreamATI; -GLEW_FUN_EXPORT PFNGLNORMALSTREAM3BATIPROC __glewNormalStream3bATI; -GLEW_FUN_EXPORT PFNGLNORMALSTREAM3BVATIPROC __glewNormalStream3bvATI; -GLEW_FUN_EXPORT PFNGLNORMALSTREAM3DATIPROC __glewNormalStream3dATI; -GLEW_FUN_EXPORT PFNGLNORMALSTREAM3DVATIPROC __glewNormalStream3dvATI; -GLEW_FUN_EXPORT PFNGLNORMALSTREAM3FATIPROC __glewNormalStream3fATI; -GLEW_FUN_EXPORT PFNGLNORMALSTREAM3FVATIPROC __glewNormalStream3fvATI; -GLEW_FUN_EXPORT PFNGLNORMALSTREAM3IATIPROC __glewNormalStream3iATI; -GLEW_FUN_EXPORT PFNGLNORMALSTREAM3IVATIPROC __glewNormalStream3ivATI; -GLEW_FUN_EXPORT PFNGLNORMALSTREAM3SATIPROC __glewNormalStream3sATI; -GLEW_FUN_EXPORT PFNGLNORMALSTREAM3SVATIPROC __glewNormalStream3svATI; -GLEW_FUN_EXPORT PFNGLVERTEXBLENDENVFATIPROC __glewVertexBlendEnvfATI; -GLEW_FUN_EXPORT PFNGLVERTEXBLENDENVIATIPROC __glewVertexBlendEnviATI; -GLEW_FUN_EXPORT PFNGLVERTEXSTREAM1DATIPROC __glewVertexStream1dATI; -GLEW_FUN_EXPORT PFNGLVERTEXSTREAM1DVATIPROC __glewVertexStream1dvATI; -GLEW_FUN_EXPORT PFNGLVERTEXSTREAM1FATIPROC __glewVertexStream1fATI; -GLEW_FUN_EXPORT PFNGLVERTEXSTREAM1FVATIPROC __glewVertexStream1fvATI; -GLEW_FUN_EXPORT PFNGLVERTEXSTREAM1IATIPROC __glewVertexStream1iATI; -GLEW_FUN_EXPORT PFNGLVERTEXSTREAM1IVATIPROC __glewVertexStream1ivATI; -GLEW_FUN_EXPORT PFNGLVERTEXSTREAM1SATIPROC __glewVertexStream1sATI; -GLEW_FUN_EXPORT PFNGLVERTEXSTREAM1SVATIPROC __glewVertexStream1svATI; -GLEW_FUN_EXPORT PFNGLVERTEXSTREAM2DATIPROC __glewVertexStream2dATI; -GLEW_FUN_EXPORT PFNGLVERTEXSTREAM2DVATIPROC __glewVertexStream2dvATI; -GLEW_FUN_EXPORT PFNGLVERTEXSTREAM2FATIPROC __glewVertexStream2fATI; -GLEW_FUN_EXPORT PFNGLVERTEXSTREAM2FVATIPROC __glewVertexStream2fvATI; -GLEW_FUN_EXPORT PFNGLVERTEXSTREAM2IATIPROC __glewVertexStream2iATI; -GLEW_FUN_EXPORT PFNGLVERTEXSTREAM2IVATIPROC __glewVertexStream2ivATI; -GLEW_FUN_EXPORT PFNGLVERTEXSTREAM2SATIPROC __glewVertexStream2sATI; -GLEW_FUN_EXPORT PFNGLVERTEXSTREAM2SVATIPROC __glewVertexStream2svATI; -GLEW_FUN_EXPORT PFNGLVERTEXSTREAM3DATIPROC __glewVertexStream3dATI; -GLEW_FUN_EXPORT PFNGLVERTEXSTREAM3DVATIPROC __glewVertexStream3dvATI; -GLEW_FUN_EXPORT PFNGLVERTEXSTREAM3FATIPROC __glewVertexStream3fATI; -GLEW_FUN_EXPORT PFNGLVERTEXSTREAM3FVATIPROC __glewVertexStream3fvATI; -GLEW_FUN_EXPORT PFNGLVERTEXSTREAM3IATIPROC __glewVertexStream3iATI; -GLEW_FUN_EXPORT PFNGLVERTEXSTREAM3IVATIPROC __glewVertexStream3ivATI; -GLEW_FUN_EXPORT PFNGLVERTEXSTREAM3SATIPROC __glewVertexStream3sATI; -GLEW_FUN_EXPORT PFNGLVERTEXSTREAM3SVATIPROC __glewVertexStream3svATI; -GLEW_FUN_EXPORT PFNGLVERTEXSTREAM4DATIPROC __glewVertexStream4dATI; -GLEW_FUN_EXPORT PFNGLVERTEXSTREAM4DVATIPROC __glewVertexStream4dvATI; -GLEW_FUN_EXPORT PFNGLVERTEXSTREAM4FATIPROC __glewVertexStream4fATI; -GLEW_FUN_EXPORT PFNGLVERTEXSTREAM4FVATIPROC __glewVertexStream4fvATI; -GLEW_FUN_EXPORT PFNGLVERTEXSTREAM4IATIPROC __glewVertexStream4iATI; -GLEW_FUN_EXPORT PFNGLVERTEXSTREAM4IVATIPROC __glewVertexStream4ivATI; -GLEW_FUN_EXPORT PFNGLVERTEXSTREAM4SATIPROC __glewVertexStream4sATI; -GLEW_FUN_EXPORT PFNGLVERTEXSTREAM4SVATIPROC __glewVertexStream4svATI; - -GLEW_FUN_EXPORT PFNGLGETUNIFORMBUFFERSIZEEXTPROC __glewGetUniformBufferSizeEXT; -GLEW_FUN_EXPORT PFNGLGETUNIFORMOFFSETEXTPROC __glewGetUniformOffsetEXT; -GLEW_FUN_EXPORT PFNGLUNIFORMBUFFEREXTPROC __glewUniformBufferEXT; - -GLEW_FUN_EXPORT PFNGLBLENDCOLOREXTPROC __glewBlendColorEXT; - -GLEW_FUN_EXPORT PFNGLBLENDEQUATIONSEPARATEEXTPROC __glewBlendEquationSeparateEXT; - -GLEW_FUN_EXPORT PFNGLBLENDFUNCSEPARATEEXTPROC __glewBlendFuncSeparateEXT; - -GLEW_FUN_EXPORT PFNGLBLENDEQUATIONEXTPROC __glewBlendEquationEXT; - -GLEW_FUN_EXPORT PFNGLCOLORSUBTABLEEXTPROC __glewColorSubTableEXT; -GLEW_FUN_EXPORT PFNGLCOPYCOLORSUBTABLEEXTPROC __glewCopyColorSubTableEXT; - -GLEW_FUN_EXPORT PFNGLLOCKARRAYSEXTPROC __glewLockArraysEXT; -GLEW_FUN_EXPORT PFNGLUNLOCKARRAYSEXTPROC __glewUnlockArraysEXT; - -GLEW_FUN_EXPORT PFNGLCONVOLUTIONFILTER1DEXTPROC __glewConvolutionFilter1DEXT; -GLEW_FUN_EXPORT PFNGLCONVOLUTIONFILTER2DEXTPROC __glewConvolutionFilter2DEXT; -GLEW_FUN_EXPORT PFNGLCONVOLUTIONPARAMETERFEXTPROC __glewConvolutionParameterfEXT; -GLEW_FUN_EXPORT PFNGLCONVOLUTIONPARAMETERFVEXTPROC __glewConvolutionParameterfvEXT; -GLEW_FUN_EXPORT PFNGLCONVOLUTIONPARAMETERIEXTPROC __glewConvolutionParameteriEXT; -GLEW_FUN_EXPORT PFNGLCONVOLUTIONPARAMETERIVEXTPROC __glewConvolutionParameterivEXT; -GLEW_FUN_EXPORT PFNGLCOPYCONVOLUTIONFILTER1DEXTPROC __glewCopyConvolutionFilter1DEXT; -GLEW_FUN_EXPORT PFNGLCOPYCONVOLUTIONFILTER2DEXTPROC __glewCopyConvolutionFilter2DEXT; -GLEW_FUN_EXPORT PFNGLGETCONVOLUTIONFILTEREXTPROC __glewGetConvolutionFilterEXT; -GLEW_FUN_EXPORT PFNGLGETCONVOLUTIONPARAMETERFVEXTPROC __glewGetConvolutionParameterfvEXT; -GLEW_FUN_EXPORT PFNGLGETCONVOLUTIONPARAMETERIVEXTPROC __glewGetConvolutionParameterivEXT; -GLEW_FUN_EXPORT PFNGLGETSEPARABLEFILTEREXTPROC __glewGetSeparableFilterEXT; -GLEW_FUN_EXPORT PFNGLSEPARABLEFILTER2DEXTPROC __glewSeparableFilter2DEXT; - -GLEW_FUN_EXPORT PFNGLBINORMALPOINTEREXTPROC __glewBinormalPointerEXT; -GLEW_FUN_EXPORT PFNGLTANGENTPOINTEREXTPROC __glewTangentPointerEXT; - -GLEW_FUN_EXPORT PFNGLCOPYTEXIMAGE1DEXTPROC __glewCopyTexImage1DEXT; -GLEW_FUN_EXPORT PFNGLCOPYTEXIMAGE2DEXTPROC __glewCopyTexImage2DEXT; -GLEW_FUN_EXPORT PFNGLCOPYTEXSUBIMAGE1DEXTPROC __glewCopyTexSubImage1DEXT; -GLEW_FUN_EXPORT PFNGLCOPYTEXSUBIMAGE2DEXTPROC __glewCopyTexSubImage2DEXT; -GLEW_FUN_EXPORT PFNGLCOPYTEXSUBIMAGE3DEXTPROC __glewCopyTexSubImage3DEXT; - -GLEW_FUN_EXPORT PFNGLCULLPARAMETERDVEXTPROC __glewCullParameterdvEXT; -GLEW_FUN_EXPORT PFNGLCULLPARAMETERFVEXTPROC __glewCullParameterfvEXT; - -GLEW_FUN_EXPORT PFNGLGETOBJECTLABELEXTPROC __glewGetObjectLabelEXT; -GLEW_FUN_EXPORT PFNGLLABELOBJECTEXTPROC __glewLabelObjectEXT; - -GLEW_FUN_EXPORT PFNGLINSERTEVENTMARKEREXTPROC __glewInsertEventMarkerEXT; -GLEW_FUN_EXPORT PFNGLPOPGROUPMARKEREXTPROC __glewPopGroupMarkerEXT; -GLEW_FUN_EXPORT PFNGLPUSHGROUPMARKEREXTPROC __glewPushGroupMarkerEXT; - -GLEW_FUN_EXPORT PFNGLDEPTHBOUNDSEXTPROC __glewDepthBoundsEXT; - -GLEW_FUN_EXPORT PFNGLBINDMULTITEXTUREEXTPROC __glewBindMultiTextureEXT; -GLEW_FUN_EXPORT PFNGLCHECKNAMEDFRAMEBUFFERSTATUSEXTPROC __glewCheckNamedFramebufferStatusEXT; -GLEW_FUN_EXPORT PFNGLCLIENTATTRIBDEFAULTEXTPROC __glewClientAttribDefaultEXT; -GLEW_FUN_EXPORT PFNGLCOMPRESSEDMULTITEXIMAGE1DEXTPROC __glewCompressedMultiTexImage1DEXT; -GLEW_FUN_EXPORT PFNGLCOMPRESSEDMULTITEXIMAGE2DEXTPROC __glewCompressedMultiTexImage2DEXT; -GLEW_FUN_EXPORT PFNGLCOMPRESSEDMULTITEXIMAGE3DEXTPROC __glewCompressedMultiTexImage3DEXT; -GLEW_FUN_EXPORT PFNGLCOMPRESSEDMULTITEXSUBIMAGE1DEXTPROC __glewCompressedMultiTexSubImage1DEXT; -GLEW_FUN_EXPORT PFNGLCOMPRESSEDMULTITEXSUBIMAGE2DEXTPROC __glewCompressedMultiTexSubImage2DEXT; -GLEW_FUN_EXPORT PFNGLCOMPRESSEDMULTITEXSUBIMAGE3DEXTPROC __glewCompressedMultiTexSubImage3DEXT; -GLEW_FUN_EXPORT PFNGLCOMPRESSEDTEXTUREIMAGE1DEXTPROC __glewCompressedTextureImage1DEXT; -GLEW_FUN_EXPORT PFNGLCOMPRESSEDTEXTUREIMAGE2DEXTPROC __glewCompressedTextureImage2DEXT; -GLEW_FUN_EXPORT PFNGLCOMPRESSEDTEXTUREIMAGE3DEXTPROC __glewCompressedTextureImage3DEXT; -GLEW_FUN_EXPORT PFNGLCOMPRESSEDTEXTURESUBIMAGE1DEXTPROC __glewCompressedTextureSubImage1DEXT; -GLEW_FUN_EXPORT PFNGLCOMPRESSEDTEXTURESUBIMAGE2DEXTPROC __glewCompressedTextureSubImage2DEXT; -GLEW_FUN_EXPORT PFNGLCOMPRESSEDTEXTURESUBIMAGE3DEXTPROC __glewCompressedTextureSubImage3DEXT; -GLEW_FUN_EXPORT PFNGLCOPYMULTITEXIMAGE1DEXTPROC __glewCopyMultiTexImage1DEXT; -GLEW_FUN_EXPORT PFNGLCOPYMULTITEXIMAGE2DEXTPROC __glewCopyMultiTexImage2DEXT; -GLEW_FUN_EXPORT PFNGLCOPYMULTITEXSUBIMAGE1DEXTPROC __glewCopyMultiTexSubImage1DEXT; -GLEW_FUN_EXPORT PFNGLCOPYMULTITEXSUBIMAGE2DEXTPROC __glewCopyMultiTexSubImage2DEXT; -GLEW_FUN_EXPORT PFNGLCOPYMULTITEXSUBIMAGE3DEXTPROC __glewCopyMultiTexSubImage3DEXT; -GLEW_FUN_EXPORT PFNGLCOPYTEXTUREIMAGE1DEXTPROC __glewCopyTextureImage1DEXT; -GLEW_FUN_EXPORT PFNGLCOPYTEXTUREIMAGE2DEXTPROC __glewCopyTextureImage2DEXT; -GLEW_FUN_EXPORT PFNGLCOPYTEXTURESUBIMAGE1DEXTPROC __glewCopyTextureSubImage1DEXT; -GLEW_FUN_EXPORT PFNGLCOPYTEXTURESUBIMAGE2DEXTPROC __glewCopyTextureSubImage2DEXT; -GLEW_FUN_EXPORT PFNGLCOPYTEXTURESUBIMAGE3DEXTPROC __glewCopyTextureSubImage3DEXT; -GLEW_FUN_EXPORT PFNGLDISABLECLIENTSTATEINDEXEDEXTPROC __glewDisableClientStateIndexedEXT; -GLEW_FUN_EXPORT PFNGLDISABLECLIENTSTATEIEXTPROC __glewDisableClientStateiEXT; -GLEW_FUN_EXPORT PFNGLDISABLEVERTEXARRAYATTRIBEXTPROC __glewDisableVertexArrayAttribEXT; -GLEW_FUN_EXPORT PFNGLDISABLEVERTEXARRAYEXTPROC __glewDisableVertexArrayEXT; -GLEW_FUN_EXPORT PFNGLENABLECLIENTSTATEINDEXEDEXTPROC __glewEnableClientStateIndexedEXT; -GLEW_FUN_EXPORT PFNGLENABLECLIENTSTATEIEXTPROC __glewEnableClientStateiEXT; -GLEW_FUN_EXPORT PFNGLENABLEVERTEXARRAYATTRIBEXTPROC __glewEnableVertexArrayAttribEXT; -GLEW_FUN_EXPORT PFNGLENABLEVERTEXARRAYEXTPROC __glewEnableVertexArrayEXT; -GLEW_FUN_EXPORT PFNGLFLUSHMAPPEDNAMEDBUFFERRANGEEXTPROC __glewFlushMappedNamedBufferRangeEXT; -GLEW_FUN_EXPORT PFNGLFRAMEBUFFERDRAWBUFFEREXTPROC __glewFramebufferDrawBufferEXT; -GLEW_FUN_EXPORT PFNGLFRAMEBUFFERDRAWBUFFERSEXTPROC __glewFramebufferDrawBuffersEXT; -GLEW_FUN_EXPORT PFNGLFRAMEBUFFERREADBUFFEREXTPROC __glewFramebufferReadBufferEXT; -GLEW_FUN_EXPORT PFNGLGENERATEMULTITEXMIPMAPEXTPROC __glewGenerateMultiTexMipmapEXT; -GLEW_FUN_EXPORT PFNGLGENERATETEXTUREMIPMAPEXTPROC __glewGenerateTextureMipmapEXT; -GLEW_FUN_EXPORT PFNGLGETCOMPRESSEDMULTITEXIMAGEEXTPROC __glewGetCompressedMultiTexImageEXT; -GLEW_FUN_EXPORT PFNGLGETCOMPRESSEDTEXTUREIMAGEEXTPROC __glewGetCompressedTextureImageEXT; -GLEW_FUN_EXPORT PFNGLGETDOUBLEINDEXEDVEXTPROC __glewGetDoubleIndexedvEXT; -GLEW_FUN_EXPORT PFNGLGETDOUBLEI_VEXTPROC __glewGetDoublei_vEXT; -GLEW_FUN_EXPORT PFNGLGETFLOATINDEXEDVEXTPROC __glewGetFloatIndexedvEXT; -GLEW_FUN_EXPORT PFNGLGETFLOATI_VEXTPROC __glewGetFloati_vEXT; -GLEW_FUN_EXPORT PFNGLGETFRAMEBUFFERPARAMETERIVEXTPROC __glewGetFramebufferParameterivEXT; -GLEW_FUN_EXPORT PFNGLGETMULTITEXENVFVEXTPROC __glewGetMultiTexEnvfvEXT; -GLEW_FUN_EXPORT PFNGLGETMULTITEXENVIVEXTPROC __glewGetMultiTexEnvivEXT; -GLEW_FUN_EXPORT PFNGLGETMULTITEXGENDVEXTPROC __glewGetMultiTexGendvEXT; -GLEW_FUN_EXPORT PFNGLGETMULTITEXGENFVEXTPROC __glewGetMultiTexGenfvEXT; -GLEW_FUN_EXPORT PFNGLGETMULTITEXGENIVEXTPROC __glewGetMultiTexGenivEXT; -GLEW_FUN_EXPORT PFNGLGETMULTITEXIMAGEEXTPROC __glewGetMultiTexImageEXT; -GLEW_FUN_EXPORT PFNGLGETMULTITEXLEVELPARAMETERFVEXTPROC __glewGetMultiTexLevelParameterfvEXT; -GLEW_FUN_EXPORT PFNGLGETMULTITEXLEVELPARAMETERIVEXTPROC __glewGetMultiTexLevelParameterivEXT; -GLEW_FUN_EXPORT PFNGLGETMULTITEXPARAMETERIIVEXTPROC __glewGetMultiTexParameterIivEXT; -GLEW_FUN_EXPORT PFNGLGETMULTITEXPARAMETERIUIVEXTPROC __glewGetMultiTexParameterIuivEXT; -GLEW_FUN_EXPORT PFNGLGETMULTITEXPARAMETERFVEXTPROC __glewGetMultiTexParameterfvEXT; -GLEW_FUN_EXPORT PFNGLGETMULTITEXPARAMETERIVEXTPROC __glewGetMultiTexParameterivEXT; -GLEW_FUN_EXPORT PFNGLGETNAMEDBUFFERPARAMETERIVEXTPROC __glewGetNamedBufferParameterivEXT; -GLEW_FUN_EXPORT PFNGLGETNAMEDBUFFERPOINTERVEXTPROC __glewGetNamedBufferPointervEXT; -GLEW_FUN_EXPORT PFNGLGETNAMEDBUFFERSUBDATAEXTPROC __glewGetNamedBufferSubDataEXT; -GLEW_FUN_EXPORT PFNGLGETNAMEDFRAMEBUFFERATTACHMENTPARAMETERIVEXTPROC __glewGetNamedFramebufferAttachmentParameterivEXT; -GLEW_FUN_EXPORT PFNGLGETNAMEDPROGRAMLOCALPARAMETERIIVEXTPROC __glewGetNamedProgramLocalParameterIivEXT; -GLEW_FUN_EXPORT PFNGLGETNAMEDPROGRAMLOCALPARAMETERIUIVEXTPROC __glewGetNamedProgramLocalParameterIuivEXT; -GLEW_FUN_EXPORT PFNGLGETNAMEDPROGRAMLOCALPARAMETERDVEXTPROC __glewGetNamedProgramLocalParameterdvEXT; -GLEW_FUN_EXPORT PFNGLGETNAMEDPROGRAMLOCALPARAMETERFVEXTPROC __glewGetNamedProgramLocalParameterfvEXT; -GLEW_FUN_EXPORT PFNGLGETNAMEDPROGRAMSTRINGEXTPROC __glewGetNamedProgramStringEXT; -GLEW_FUN_EXPORT PFNGLGETNAMEDPROGRAMIVEXTPROC __glewGetNamedProgramivEXT; -GLEW_FUN_EXPORT PFNGLGETNAMEDRENDERBUFFERPARAMETERIVEXTPROC __glewGetNamedRenderbufferParameterivEXT; -GLEW_FUN_EXPORT PFNGLGETPOINTERINDEXEDVEXTPROC __glewGetPointerIndexedvEXT; -GLEW_FUN_EXPORT PFNGLGETPOINTERI_VEXTPROC __glewGetPointeri_vEXT; -GLEW_FUN_EXPORT PFNGLGETTEXTUREIMAGEEXTPROC __glewGetTextureImageEXT; -GLEW_FUN_EXPORT PFNGLGETTEXTURELEVELPARAMETERFVEXTPROC __glewGetTextureLevelParameterfvEXT; -GLEW_FUN_EXPORT PFNGLGETTEXTURELEVELPARAMETERIVEXTPROC __glewGetTextureLevelParameterivEXT; -GLEW_FUN_EXPORT PFNGLGETTEXTUREPARAMETERIIVEXTPROC __glewGetTextureParameterIivEXT; -GLEW_FUN_EXPORT PFNGLGETTEXTUREPARAMETERIUIVEXTPROC __glewGetTextureParameterIuivEXT; -GLEW_FUN_EXPORT PFNGLGETTEXTUREPARAMETERFVEXTPROC __glewGetTextureParameterfvEXT; -GLEW_FUN_EXPORT PFNGLGETTEXTUREPARAMETERIVEXTPROC __glewGetTextureParameterivEXT; -GLEW_FUN_EXPORT PFNGLGETVERTEXARRAYINTEGERI_VEXTPROC __glewGetVertexArrayIntegeri_vEXT; -GLEW_FUN_EXPORT PFNGLGETVERTEXARRAYINTEGERVEXTPROC __glewGetVertexArrayIntegervEXT; -GLEW_FUN_EXPORT PFNGLGETVERTEXARRAYPOINTERI_VEXTPROC __glewGetVertexArrayPointeri_vEXT; -GLEW_FUN_EXPORT PFNGLGETVERTEXARRAYPOINTERVEXTPROC __glewGetVertexArrayPointervEXT; -GLEW_FUN_EXPORT PFNGLMAPNAMEDBUFFEREXTPROC __glewMapNamedBufferEXT; -GLEW_FUN_EXPORT PFNGLMAPNAMEDBUFFERRANGEEXTPROC __glewMapNamedBufferRangeEXT; -GLEW_FUN_EXPORT PFNGLMATRIXFRUSTUMEXTPROC __glewMatrixFrustumEXT; -GLEW_FUN_EXPORT PFNGLMATRIXLOADIDENTITYEXTPROC __glewMatrixLoadIdentityEXT; -GLEW_FUN_EXPORT PFNGLMATRIXLOADTRANSPOSEDEXTPROC __glewMatrixLoadTransposedEXT; -GLEW_FUN_EXPORT PFNGLMATRIXLOADTRANSPOSEFEXTPROC __glewMatrixLoadTransposefEXT; -GLEW_FUN_EXPORT PFNGLMATRIXLOADDEXTPROC __glewMatrixLoaddEXT; -GLEW_FUN_EXPORT PFNGLMATRIXLOADFEXTPROC __glewMatrixLoadfEXT; -GLEW_FUN_EXPORT PFNGLMATRIXMULTTRANSPOSEDEXTPROC __glewMatrixMultTransposedEXT; -GLEW_FUN_EXPORT PFNGLMATRIXMULTTRANSPOSEFEXTPROC __glewMatrixMultTransposefEXT; -GLEW_FUN_EXPORT PFNGLMATRIXMULTDEXTPROC __glewMatrixMultdEXT; -GLEW_FUN_EXPORT PFNGLMATRIXMULTFEXTPROC __glewMatrixMultfEXT; -GLEW_FUN_EXPORT PFNGLMATRIXORTHOEXTPROC __glewMatrixOrthoEXT; -GLEW_FUN_EXPORT PFNGLMATRIXPOPEXTPROC __glewMatrixPopEXT; -GLEW_FUN_EXPORT PFNGLMATRIXPUSHEXTPROC __glewMatrixPushEXT; -GLEW_FUN_EXPORT PFNGLMATRIXROTATEDEXTPROC __glewMatrixRotatedEXT; -GLEW_FUN_EXPORT PFNGLMATRIXROTATEFEXTPROC __glewMatrixRotatefEXT; -GLEW_FUN_EXPORT PFNGLMATRIXSCALEDEXTPROC __glewMatrixScaledEXT; -GLEW_FUN_EXPORT PFNGLMATRIXSCALEFEXTPROC __glewMatrixScalefEXT; -GLEW_FUN_EXPORT PFNGLMATRIXTRANSLATEDEXTPROC __glewMatrixTranslatedEXT; -GLEW_FUN_EXPORT PFNGLMATRIXTRANSLATEFEXTPROC __glewMatrixTranslatefEXT; -GLEW_FUN_EXPORT PFNGLMULTITEXBUFFEREXTPROC __glewMultiTexBufferEXT; -GLEW_FUN_EXPORT PFNGLMULTITEXCOORDPOINTEREXTPROC __glewMultiTexCoordPointerEXT; -GLEW_FUN_EXPORT PFNGLMULTITEXENVFEXTPROC __glewMultiTexEnvfEXT; -GLEW_FUN_EXPORT PFNGLMULTITEXENVFVEXTPROC __glewMultiTexEnvfvEXT; -GLEW_FUN_EXPORT PFNGLMULTITEXENVIEXTPROC __glewMultiTexEnviEXT; -GLEW_FUN_EXPORT PFNGLMULTITEXENVIVEXTPROC __glewMultiTexEnvivEXT; -GLEW_FUN_EXPORT PFNGLMULTITEXGENDEXTPROC __glewMultiTexGendEXT; -GLEW_FUN_EXPORT PFNGLMULTITEXGENDVEXTPROC __glewMultiTexGendvEXT; -GLEW_FUN_EXPORT PFNGLMULTITEXGENFEXTPROC __glewMultiTexGenfEXT; -GLEW_FUN_EXPORT PFNGLMULTITEXGENFVEXTPROC __glewMultiTexGenfvEXT; -GLEW_FUN_EXPORT PFNGLMULTITEXGENIEXTPROC __glewMultiTexGeniEXT; -GLEW_FUN_EXPORT PFNGLMULTITEXGENIVEXTPROC __glewMultiTexGenivEXT; -GLEW_FUN_EXPORT PFNGLMULTITEXIMAGE1DEXTPROC __glewMultiTexImage1DEXT; -GLEW_FUN_EXPORT PFNGLMULTITEXIMAGE2DEXTPROC __glewMultiTexImage2DEXT; -GLEW_FUN_EXPORT PFNGLMULTITEXIMAGE3DEXTPROC __glewMultiTexImage3DEXT; -GLEW_FUN_EXPORT PFNGLMULTITEXPARAMETERIIVEXTPROC __glewMultiTexParameterIivEXT; -GLEW_FUN_EXPORT PFNGLMULTITEXPARAMETERIUIVEXTPROC __glewMultiTexParameterIuivEXT; -GLEW_FUN_EXPORT PFNGLMULTITEXPARAMETERFEXTPROC __glewMultiTexParameterfEXT; -GLEW_FUN_EXPORT PFNGLMULTITEXPARAMETERFVEXTPROC __glewMultiTexParameterfvEXT; -GLEW_FUN_EXPORT PFNGLMULTITEXPARAMETERIEXTPROC __glewMultiTexParameteriEXT; -GLEW_FUN_EXPORT PFNGLMULTITEXPARAMETERIVEXTPROC __glewMultiTexParameterivEXT; -GLEW_FUN_EXPORT PFNGLMULTITEXRENDERBUFFEREXTPROC __glewMultiTexRenderbufferEXT; -GLEW_FUN_EXPORT PFNGLMULTITEXSUBIMAGE1DEXTPROC __glewMultiTexSubImage1DEXT; -GLEW_FUN_EXPORT PFNGLMULTITEXSUBIMAGE2DEXTPROC __glewMultiTexSubImage2DEXT; -GLEW_FUN_EXPORT PFNGLMULTITEXSUBIMAGE3DEXTPROC __glewMultiTexSubImage3DEXT; -GLEW_FUN_EXPORT PFNGLNAMEDBUFFERDATAEXTPROC __glewNamedBufferDataEXT; -GLEW_FUN_EXPORT PFNGLNAMEDBUFFERSUBDATAEXTPROC __glewNamedBufferSubDataEXT; -GLEW_FUN_EXPORT PFNGLNAMEDCOPYBUFFERSUBDATAEXTPROC __glewNamedCopyBufferSubDataEXT; -GLEW_FUN_EXPORT PFNGLNAMEDFRAMEBUFFERRENDERBUFFEREXTPROC __glewNamedFramebufferRenderbufferEXT; -GLEW_FUN_EXPORT PFNGLNAMEDFRAMEBUFFERTEXTURE1DEXTPROC __glewNamedFramebufferTexture1DEXT; -GLEW_FUN_EXPORT PFNGLNAMEDFRAMEBUFFERTEXTURE2DEXTPROC __glewNamedFramebufferTexture2DEXT; -GLEW_FUN_EXPORT PFNGLNAMEDFRAMEBUFFERTEXTURE3DEXTPROC __glewNamedFramebufferTexture3DEXT; -GLEW_FUN_EXPORT PFNGLNAMEDFRAMEBUFFERTEXTUREEXTPROC __glewNamedFramebufferTextureEXT; -GLEW_FUN_EXPORT PFNGLNAMEDFRAMEBUFFERTEXTUREFACEEXTPROC __glewNamedFramebufferTextureFaceEXT; -GLEW_FUN_EXPORT PFNGLNAMEDFRAMEBUFFERTEXTURELAYEREXTPROC __glewNamedFramebufferTextureLayerEXT; -GLEW_FUN_EXPORT PFNGLNAMEDPROGRAMLOCALPARAMETER4DEXTPROC __glewNamedProgramLocalParameter4dEXT; -GLEW_FUN_EXPORT PFNGLNAMEDPROGRAMLOCALPARAMETER4DVEXTPROC __glewNamedProgramLocalParameter4dvEXT; -GLEW_FUN_EXPORT PFNGLNAMEDPROGRAMLOCALPARAMETER4FEXTPROC __glewNamedProgramLocalParameter4fEXT; -GLEW_FUN_EXPORT PFNGLNAMEDPROGRAMLOCALPARAMETER4FVEXTPROC __glewNamedProgramLocalParameter4fvEXT; -GLEW_FUN_EXPORT PFNGLNAMEDPROGRAMLOCALPARAMETERI4IEXTPROC __glewNamedProgramLocalParameterI4iEXT; -GLEW_FUN_EXPORT PFNGLNAMEDPROGRAMLOCALPARAMETERI4IVEXTPROC __glewNamedProgramLocalParameterI4ivEXT; -GLEW_FUN_EXPORT PFNGLNAMEDPROGRAMLOCALPARAMETERI4UIEXTPROC __glewNamedProgramLocalParameterI4uiEXT; -GLEW_FUN_EXPORT PFNGLNAMEDPROGRAMLOCALPARAMETERI4UIVEXTPROC __glewNamedProgramLocalParameterI4uivEXT; -GLEW_FUN_EXPORT PFNGLNAMEDPROGRAMLOCALPARAMETERS4FVEXTPROC __glewNamedProgramLocalParameters4fvEXT; -GLEW_FUN_EXPORT PFNGLNAMEDPROGRAMLOCALPARAMETERSI4IVEXTPROC __glewNamedProgramLocalParametersI4ivEXT; -GLEW_FUN_EXPORT PFNGLNAMEDPROGRAMLOCALPARAMETERSI4UIVEXTPROC __glewNamedProgramLocalParametersI4uivEXT; -GLEW_FUN_EXPORT PFNGLNAMEDPROGRAMSTRINGEXTPROC __glewNamedProgramStringEXT; -GLEW_FUN_EXPORT PFNGLNAMEDRENDERBUFFERSTORAGEEXTPROC __glewNamedRenderbufferStorageEXT; -GLEW_FUN_EXPORT PFNGLNAMEDRENDERBUFFERSTORAGEMULTISAMPLECOVERAGEEXTPROC __glewNamedRenderbufferStorageMultisampleCoverageEXT; -GLEW_FUN_EXPORT PFNGLNAMEDRENDERBUFFERSTORAGEMULTISAMPLEEXTPROC __glewNamedRenderbufferStorageMultisampleEXT; -GLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM1FEXTPROC __glewProgramUniform1fEXT; -GLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM1FVEXTPROC __glewProgramUniform1fvEXT; -GLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM1IEXTPROC __glewProgramUniform1iEXT; -GLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM1IVEXTPROC __glewProgramUniform1ivEXT; -GLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM1UIEXTPROC __glewProgramUniform1uiEXT; -GLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM1UIVEXTPROC __glewProgramUniform1uivEXT; -GLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM2FEXTPROC __glewProgramUniform2fEXT; -GLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM2FVEXTPROC __glewProgramUniform2fvEXT; -GLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM2IEXTPROC __glewProgramUniform2iEXT; -GLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM2IVEXTPROC __glewProgramUniform2ivEXT; -GLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM2UIEXTPROC __glewProgramUniform2uiEXT; -GLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM2UIVEXTPROC __glewProgramUniform2uivEXT; -GLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM3FEXTPROC __glewProgramUniform3fEXT; -GLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM3FVEXTPROC __glewProgramUniform3fvEXT; -GLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM3IEXTPROC __glewProgramUniform3iEXT; -GLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM3IVEXTPROC __glewProgramUniform3ivEXT; -GLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM3UIEXTPROC __glewProgramUniform3uiEXT; -GLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM3UIVEXTPROC __glewProgramUniform3uivEXT; -GLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM4FEXTPROC __glewProgramUniform4fEXT; -GLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM4FVEXTPROC __glewProgramUniform4fvEXT; -GLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM4IEXTPROC __glewProgramUniform4iEXT; -GLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM4IVEXTPROC __glewProgramUniform4ivEXT; -GLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM4UIEXTPROC __glewProgramUniform4uiEXT; -GLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM4UIVEXTPROC __glewProgramUniform4uivEXT; -GLEW_FUN_EXPORT PFNGLPROGRAMUNIFORMMATRIX2FVEXTPROC __glewProgramUniformMatrix2fvEXT; -GLEW_FUN_EXPORT PFNGLPROGRAMUNIFORMMATRIX2X3FVEXTPROC __glewProgramUniformMatrix2x3fvEXT; -GLEW_FUN_EXPORT PFNGLPROGRAMUNIFORMMATRIX2X4FVEXTPROC __glewProgramUniformMatrix2x4fvEXT; -GLEW_FUN_EXPORT PFNGLPROGRAMUNIFORMMATRIX3FVEXTPROC __glewProgramUniformMatrix3fvEXT; -GLEW_FUN_EXPORT PFNGLPROGRAMUNIFORMMATRIX3X2FVEXTPROC __glewProgramUniformMatrix3x2fvEXT; -GLEW_FUN_EXPORT PFNGLPROGRAMUNIFORMMATRIX3X4FVEXTPROC __glewProgramUniformMatrix3x4fvEXT; -GLEW_FUN_EXPORT PFNGLPROGRAMUNIFORMMATRIX4FVEXTPROC __glewProgramUniformMatrix4fvEXT; -GLEW_FUN_EXPORT PFNGLPROGRAMUNIFORMMATRIX4X2FVEXTPROC __glewProgramUniformMatrix4x2fvEXT; -GLEW_FUN_EXPORT PFNGLPROGRAMUNIFORMMATRIX4X3FVEXTPROC __glewProgramUniformMatrix4x3fvEXT; -GLEW_FUN_EXPORT PFNGLPUSHCLIENTATTRIBDEFAULTEXTPROC __glewPushClientAttribDefaultEXT; -GLEW_FUN_EXPORT PFNGLTEXTUREBUFFEREXTPROC __glewTextureBufferEXT; -GLEW_FUN_EXPORT PFNGLTEXTUREIMAGE1DEXTPROC __glewTextureImage1DEXT; -GLEW_FUN_EXPORT PFNGLTEXTUREIMAGE2DEXTPROC __glewTextureImage2DEXT; -GLEW_FUN_EXPORT PFNGLTEXTUREIMAGE3DEXTPROC __glewTextureImage3DEXT; -GLEW_FUN_EXPORT PFNGLTEXTUREPARAMETERIIVEXTPROC __glewTextureParameterIivEXT; -GLEW_FUN_EXPORT PFNGLTEXTUREPARAMETERIUIVEXTPROC __glewTextureParameterIuivEXT; -GLEW_FUN_EXPORT PFNGLTEXTUREPARAMETERFEXTPROC __glewTextureParameterfEXT; -GLEW_FUN_EXPORT PFNGLTEXTUREPARAMETERFVEXTPROC __glewTextureParameterfvEXT; -GLEW_FUN_EXPORT PFNGLTEXTUREPARAMETERIEXTPROC __glewTextureParameteriEXT; -GLEW_FUN_EXPORT PFNGLTEXTUREPARAMETERIVEXTPROC __glewTextureParameterivEXT; -GLEW_FUN_EXPORT PFNGLTEXTURERENDERBUFFEREXTPROC __glewTextureRenderbufferEXT; -GLEW_FUN_EXPORT PFNGLTEXTURESUBIMAGE1DEXTPROC __glewTextureSubImage1DEXT; -GLEW_FUN_EXPORT PFNGLTEXTURESUBIMAGE2DEXTPROC __glewTextureSubImage2DEXT; -GLEW_FUN_EXPORT PFNGLTEXTURESUBIMAGE3DEXTPROC __glewTextureSubImage3DEXT; -GLEW_FUN_EXPORT PFNGLUNMAPNAMEDBUFFEREXTPROC __glewUnmapNamedBufferEXT; -GLEW_FUN_EXPORT PFNGLVERTEXARRAYCOLOROFFSETEXTPROC __glewVertexArrayColorOffsetEXT; -GLEW_FUN_EXPORT PFNGLVERTEXARRAYEDGEFLAGOFFSETEXTPROC __glewVertexArrayEdgeFlagOffsetEXT; -GLEW_FUN_EXPORT PFNGLVERTEXARRAYFOGCOORDOFFSETEXTPROC __glewVertexArrayFogCoordOffsetEXT; -GLEW_FUN_EXPORT PFNGLVERTEXARRAYINDEXOFFSETEXTPROC __glewVertexArrayIndexOffsetEXT; -GLEW_FUN_EXPORT PFNGLVERTEXARRAYMULTITEXCOORDOFFSETEXTPROC __glewVertexArrayMultiTexCoordOffsetEXT; -GLEW_FUN_EXPORT PFNGLVERTEXARRAYNORMALOFFSETEXTPROC __glewVertexArrayNormalOffsetEXT; -GLEW_FUN_EXPORT PFNGLVERTEXARRAYSECONDARYCOLOROFFSETEXTPROC __glewVertexArraySecondaryColorOffsetEXT; -GLEW_FUN_EXPORT PFNGLVERTEXARRAYTEXCOORDOFFSETEXTPROC __glewVertexArrayTexCoordOffsetEXT; -GLEW_FUN_EXPORT PFNGLVERTEXARRAYVERTEXATTRIBDIVISOREXTPROC __glewVertexArrayVertexAttribDivisorEXT; -GLEW_FUN_EXPORT PFNGLVERTEXARRAYVERTEXATTRIBIOFFSETEXTPROC __glewVertexArrayVertexAttribIOffsetEXT; -GLEW_FUN_EXPORT PFNGLVERTEXARRAYVERTEXATTRIBOFFSETEXTPROC __glewVertexArrayVertexAttribOffsetEXT; -GLEW_FUN_EXPORT PFNGLVERTEXARRAYVERTEXOFFSETEXTPROC __glewVertexArrayVertexOffsetEXT; - -GLEW_FUN_EXPORT PFNGLCOLORMASKINDEXEDEXTPROC __glewColorMaskIndexedEXT; -GLEW_FUN_EXPORT PFNGLDISABLEINDEXEDEXTPROC __glewDisableIndexedEXT; -GLEW_FUN_EXPORT PFNGLENABLEINDEXEDEXTPROC __glewEnableIndexedEXT; -GLEW_FUN_EXPORT PFNGLGETBOOLEANINDEXEDVEXTPROC __glewGetBooleanIndexedvEXT; -GLEW_FUN_EXPORT PFNGLGETINTEGERINDEXEDVEXTPROC __glewGetIntegerIndexedvEXT; -GLEW_FUN_EXPORT PFNGLISENABLEDINDEXEDEXTPROC __glewIsEnabledIndexedEXT; - -GLEW_FUN_EXPORT PFNGLDRAWARRAYSINSTANCEDEXTPROC __glewDrawArraysInstancedEXT; -GLEW_FUN_EXPORT PFNGLDRAWELEMENTSINSTANCEDEXTPROC __glewDrawElementsInstancedEXT; - -GLEW_FUN_EXPORT PFNGLDRAWRANGEELEMENTSEXTPROC __glewDrawRangeElementsEXT; - -GLEW_FUN_EXPORT PFNGLFOGCOORDPOINTEREXTPROC __glewFogCoordPointerEXT; -GLEW_FUN_EXPORT PFNGLFOGCOORDDEXTPROC __glewFogCoorddEXT; -GLEW_FUN_EXPORT PFNGLFOGCOORDDVEXTPROC __glewFogCoorddvEXT; -GLEW_FUN_EXPORT PFNGLFOGCOORDFEXTPROC __glewFogCoordfEXT; -GLEW_FUN_EXPORT PFNGLFOGCOORDFVEXTPROC __glewFogCoordfvEXT; - -GLEW_FUN_EXPORT PFNGLFRAGMENTCOLORMATERIALEXTPROC __glewFragmentColorMaterialEXT; -GLEW_FUN_EXPORT PFNGLFRAGMENTLIGHTMODELFEXTPROC __glewFragmentLightModelfEXT; -GLEW_FUN_EXPORT PFNGLFRAGMENTLIGHTMODELFVEXTPROC __glewFragmentLightModelfvEXT; -GLEW_FUN_EXPORT PFNGLFRAGMENTLIGHTMODELIEXTPROC __glewFragmentLightModeliEXT; -GLEW_FUN_EXPORT PFNGLFRAGMENTLIGHTMODELIVEXTPROC __glewFragmentLightModelivEXT; -GLEW_FUN_EXPORT PFNGLFRAGMENTLIGHTFEXTPROC __glewFragmentLightfEXT; -GLEW_FUN_EXPORT PFNGLFRAGMENTLIGHTFVEXTPROC __glewFragmentLightfvEXT; -GLEW_FUN_EXPORT PFNGLFRAGMENTLIGHTIEXTPROC __glewFragmentLightiEXT; -GLEW_FUN_EXPORT PFNGLFRAGMENTLIGHTIVEXTPROC __glewFragmentLightivEXT; -GLEW_FUN_EXPORT PFNGLFRAGMENTMATERIALFEXTPROC __glewFragmentMaterialfEXT; -GLEW_FUN_EXPORT PFNGLFRAGMENTMATERIALFVEXTPROC __glewFragmentMaterialfvEXT; -GLEW_FUN_EXPORT PFNGLFRAGMENTMATERIALIEXTPROC __glewFragmentMaterialiEXT; -GLEW_FUN_EXPORT PFNGLFRAGMENTMATERIALIVEXTPROC __glewFragmentMaterialivEXT; -GLEW_FUN_EXPORT PFNGLGETFRAGMENTLIGHTFVEXTPROC __glewGetFragmentLightfvEXT; -GLEW_FUN_EXPORT PFNGLGETFRAGMENTLIGHTIVEXTPROC __glewGetFragmentLightivEXT; -GLEW_FUN_EXPORT PFNGLGETFRAGMENTMATERIALFVEXTPROC __glewGetFragmentMaterialfvEXT; -GLEW_FUN_EXPORT PFNGLGETFRAGMENTMATERIALIVEXTPROC __glewGetFragmentMaterialivEXT; -GLEW_FUN_EXPORT PFNGLLIGHTENVIEXTPROC __glewLightEnviEXT; - -GLEW_FUN_EXPORT PFNGLBLITFRAMEBUFFEREXTPROC __glewBlitFramebufferEXT; - -GLEW_FUN_EXPORT PFNGLRENDERBUFFERSTORAGEMULTISAMPLEEXTPROC __glewRenderbufferStorageMultisampleEXT; - -GLEW_FUN_EXPORT PFNGLBINDFRAMEBUFFEREXTPROC __glewBindFramebufferEXT; -GLEW_FUN_EXPORT PFNGLBINDRENDERBUFFEREXTPROC __glewBindRenderbufferEXT; -GLEW_FUN_EXPORT PFNGLCHECKFRAMEBUFFERSTATUSEXTPROC __glewCheckFramebufferStatusEXT; -GLEW_FUN_EXPORT PFNGLDELETEFRAMEBUFFERSEXTPROC __glewDeleteFramebuffersEXT; -GLEW_FUN_EXPORT PFNGLDELETERENDERBUFFERSEXTPROC __glewDeleteRenderbuffersEXT; -GLEW_FUN_EXPORT PFNGLFRAMEBUFFERRENDERBUFFEREXTPROC __glewFramebufferRenderbufferEXT; -GLEW_FUN_EXPORT PFNGLFRAMEBUFFERTEXTURE1DEXTPROC __glewFramebufferTexture1DEXT; -GLEW_FUN_EXPORT PFNGLFRAMEBUFFERTEXTURE2DEXTPROC __glewFramebufferTexture2DEXT; -GLEW_FUN_EXPORT PFNGLFRAMEBUFFERTEXTURE3DEXTPROC __glewFramebufferTexture3DEXT; -GLEW_FUN_EXPORT PFNGLGENFRAMEBUFFERSEXTPROC __glewGenFramebuffersEXT; -GLEW_FUN_EXPORT PFNGLGENRENDERBUFFERSEXTPROC __glewGenRenderbuffersEXT; -GLEW_FUN_EXPORT PFNGLGENERATEMIPMAPEXTPROC __glewGenerateMipmapEXT; -GLEW_FUN_EXPORT PFNGLGETFRAMEBUFFERATTACHMENTPARAMETERIVEXTPROC __glewGetFramebufferAttachmentParameterivEXT; -GLEW_FUN_EXPORT PFNGLGETRENDERBUFFERPARAMETERIVEXTPROC __glewGetRenderbufferParameterivEXT; -GLEW_FUN_EXPORT PFNGLISFRAMEBUFFEREXTPROC __glewIsFramebufferEXT; -GLEW_FUN_EXPORT PFNGLISRENDERBUFFEREXTPROC __glewIsRenderbufferEXT; -GLEW_FUN_EXPORT PFNGLRENDERBUFFERSTORAGEEXTPROC __glewRenderbufferStorageEXT; - -GLEW_FUN_EXPORT PFNGLFRAMEBUFFERTEXTUREEXTPROC __glewFramebufferTextureEXT; -GLEW_FUN_EXPORT PFNGLFRAMEBUFFERTEXTUREFACEEXTPROC __glewFramebufferTextureFaceEXT; -GLEW_FUN_EXPORT PFNGLPROGRAMPARAMETERIEXTPROC __glewProgramParameteriEXT; - -GLEW_FUN_EXPORT PFNGLPROGRAMENVPARAMETERS4FVEXTPROC __glewProgramEnvParameters4fvEXT; -GLEW_FUN_EXPORT PFNGLPROGRAMLOCALPARAMETERS4FVEXTPROC __glewProgramLocalParameters4fvEXT; - -GLEW_FUN_EXPORT PFNGLBINDFRAGDATALOCATIONEXTPROC __glewBindFragDataLocationEXT; -GLEW_FUN_EXPORT PFNGLGETFRAGDATALOCATIONEXTPROC __glewGetFragDataLocationEXT; -GLEW_FUN_EXPORT PFNGLGETUNIFORMUIVEXTPROC __glewGetUniformuivEXT; -GLEW_FUN_EXPORT PFNGLGETVERTEXATTRIBIIVEXTPROC __glewGetVertexAttribIivEXT; -GLEW_FUN_EXPORT PFNGLGETVERTEXATTRIBIUIVEXTPROC __glewGetVertexAttribIuivEXT; -GLEW_FUN_EXPORT PFNGLUNIFORM1UIEXTPROC __glewUniform1uiEXT; -GLEW_FUN_EXPORT PFNGLUNIFORM1UIVEXTPROC __glewUniform1uivEXT; -GLEW_FUN_EXPORT PFNGLUNIFORM2UIEXTPROC __glewUniform2uiEXT; -GLEW_FUN_EXPORT PFNGLUNIFORM2UIVEXTPROC __glewUniform2uivEXT; -GLEW_FUN_EXPORT PFNGLUNIFORM3UIEXTPROC __glewUniform3uiEXT; -GLEW_FUN_EXPORT PFNGLUNIFORM3UIVEXTPROC __glewUniform3uivEXT; -GLEW_FUN_EXPORT PFNGLUNIFORM4UIEXTPROC __glewUniform4uiEXT; -GLEW_FUN_EXPORT PFNGLUNIFORM4UIVEXTPROC __glewUniform4uivEXT; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIBI1IEXTPROC __glewVertexAttribI1iEXT; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIBI1IVEXTPROC __glewVertexAttribI1ivEXT; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIBI1UIEXTPROC __glewVertexAttribI1uiEXT; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIBI1UIVEXTPROC __glewVertexAttribI1uivEXT; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIBI2IEXTPROC __glewVertexAttribI2iEXT; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIBI2IVEXTPROC __glewVertexAttribI2ivEXT; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIBI2UIEXTPROC __glewVertexAttribI2uiEXT; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIBI2UIVEXTPROC __glewVertexAttribI2uivEXT; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIBI3IEXTPROC __glewVertexAttribI3iEXT; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIBI3IVEXTPROC __glewVertexAttribI3ivEXT; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIBI3UIEXTPROC __glewVertexAttribI3uiEXT; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIBI3UIVEXTPROC __glewVertexAttribI3uivEXT; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIBI4BVEXTPROC __glewVertexAttribI4bvEXT; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIBI4IEXTPROC __glewVertexAttribI4iEXT; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIBI4IVEXTPROC __glewVertexAttribI4ivEXT; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIBI4SVEXTPROC __glewVertexAttribI4svEXT; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIBI4UBVEXTPROC __glewVertexAttribI4ubvEXT; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIBI4UIEXTPROC __glewVertexAttribI4uiEXT; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIBI4UIVEXTPROC __glewVertexAttribI4uivEXT; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIBI4USVEXTPROC __glewVertexAttribI4usvEXT; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIBIPOINTEREXTPROC __glewVertexAttribIPointerEXT; - -GLEW_FUN_EXPORT PFNGLGETHISTOGRAMEXTPROC __glewGetHistogramEXT; -GLEW_FUN_EXPORT PFNGLGETHISTOGRAMPARAMETERFVEXTPROC __glewGetHistogramParameterfvEXT; -GLEW_FUN_EXPORT PFNGLGETHISTOGRAMPARAMETERIVEXTPROC __glewGetHistogramParameterivEXT; -GLEW_FUN_EXPORT PFNGLGETMINMAXEXTPROC __glewGetMinmaxEXT; -GLEW_FUN_EXPORT PFNGLGETMINMAXPARAMETERFVEXTPROC __glewGetMinmaxParameterfvEXT; -GLEW_FUN_EXPORT PFNGLGETMINMAXPARAMETERIVEXTPROC __glewGetMinmaxParameterivEXT; -GLEW_FUN_EXPORT PFNGLHISTOGRAMEXTPROC __glewHistogramEXT; -GLEW_FUN_EXPORT PFNGLMINMAXEXTPROC __glewMinmaxEXT; -GLEW_FUN_EXPORT PFNGLRESETHISTOGRAMEXTPROC __glewResetHistogramEXT; -GLEW_FUN_EXPORT PFNGLRESETMINMAXEXTPROC __glewResetMinmaxEXT; - -GLEW_FUN_EXPORT PFNGLINDEXFUNCEXTPROC __glewIndexFuncEXT; - -GLEW_FUN_EXPORT PFNGLINDEXMATERIALEXTPROC __glewIndexMaterialEXT; - -GLEW_FUN_EXPORT PFNGLAPPLYTEXTUREEXTPROC __glewApplyTextureEXT; -GLEW_FUN_EXPORT PFNGLTEXTURELIGHTEXTPROC __glewTextureLightEXT; -GLEW_FUN_EXPORT PFNGLTEXTUREMATERIALEXTPROC __glewTextureMaterialEXT; - -GLEW_FUN_EXPORT PFNGLMULTIDRAWARRAYSEXTPROC __glewMultiDrawArraysEXT; -GLEW_FUN_EXPORT PFNGLMULTIDRAWELEMENTSEXTPROC __glewMultiDrawElementsEXT; - -GLEW_FUN_EXPORT PFNGLSAMPLEMASKEXTPROC __glewSampleMaskEXT; -GLEW_FUN_EXPORT PFNGLSAMPLEPATTERNEXTPROC __glewSamplePatternEXT; - -GLEW_FUN_EXPORT PFNGLCOLORTABLEEXTPROC __glewColorTableEXT; -GLEW_FUN_EXPORT PFNGLGETCOLORTABLEEXTPROC __glewGetColorTableEXT; -GLEW_FUN_EXPORT PFNGLGETCOLORTABLEPARAMETERFVEXTPROC __glewGetColorTableParameterfvEXT; -GLEW_FUN_EXPORT PFNGLGETCOLORTABLEPARAMETERIVEXTPROC __glewGetColorTableParameterivEXT; - -GLEW_FUN_EXPORT PFNGLGETPIXELTRANSFORMPARAMETERFVEXTPROC __glewGetPixelTransformParameterfvEXT; -GLEW_FUN_EXPORT PFNGLGETPIXELTRANSFORMPARAMETERIVEXTPROC __glewGetPixelTransformParameterivEXT; -GLEW_FUN_EXPORT PFNGLPIXELTRANSFORMPARAMETERFEXTPROC __glewPixelTransformParameterfEXT; -GLEW_FUN_EXPORT PFNGLPIXELTRANSFORMPARAMETERFVEXTPROC __glewPixelTransformParameterfvEXT; -GLEW_FUN_EXPORT PFNGLPIXELTRANSFORMPARAMETERIEXTPROC __glewPixelTransformParameteriEXT; -GLEW_FUN_EXPORT PFNGLPIXELTRANSFORMPARAMETERIVEXTPROC __glewPixelTransformParameterivEXT; - -GLEW_FUN_EXPORT PFNGLPOINTPARAMETERFEXTPROC __glewPointParameterfEXT; -GLEW_FUN_EXPORT PFNGLPOINTPARAMETERFVEXTPROC __glewPointParameterfvEXT; - -GLEW_FUN_EXPORT PFNGLPOLYGONOFFSETEXTPROC __glewPolygonOffsetEXT; - -GLEW_FUN_EXPORT PFNGLPOLYGONOFFSETCLAMPEXTPROC __glewPolygonOffsetClampEXT; - -GLEW_FUN_EXPORT PFNGLPROVOKINGVERTEXEXTPROC __glewProvokingVertexEXT; - -GLEW_FUN_EXPORT PFNGLCOVERAGEMODULATIONNVPROC __glewCoverageModulationNV; -GLEW_FUN_EXPORT PFNGLCOVERAGEMODULATIONTABLENVPROC __glewCoverageModulationTableNV; -GLEW_FUN_EXPORT PFNGLGETCOVERAGEMODULATIONTABLENVPROC __glewGetCoverageModulationTableNV; -GLEW_FUN_EXPORT PFNGLRASTERSAMPLESEXTPROC __glewRasterSamplesEXT; - -GLEW_FUN_EXPORT PFNGLBEGINSCENEEXTPROC __glewBeginSceneEXT; -GLEW_FUN_EXPORT PFNGLENDSCENEEXTPROC __glewEndSceneEXT; - -GLEW_FUN_EXPORT PFNGLSECONDARYCOLOR3BEXTPROC __glewSecondaryColor3bEXT; -GLEW_FUN_EXPORT PFNGLSECONDARYCOLOR3BVEXTPROC __glewSecondaryColor3bvEXT; -GLEW_FUN_EXPORT PFNGLSECONDARYCOLOR3DEXTPROC __glewSecondaryColor3dEXT; -GLEW_FUN_EXPORT PFNGLSECONDARYCOLOR3DVEXTPROC __glewSecondaryColor3dvEXT; -GLEW_FUN_EXPORT PFNGLSECONDARYCOLOR3FEXTPROC __glewSecondaryColor3fEXT; -GLEW_FUN_EXPORT PFNGLSECONDARYCOLOR3FVEXTPROC __glewSecondaryColor3fvEXT; -GLEW_FUN_EXPORT PFNGLSECONDARYCOLOR3IEXTPROC __glewSecondaryColor3iEXT; -GLEW_FUN_EXPORT PFNGLSECONDARYCOLOR3IVEXTPROC __glewSecondaryColor3ivEXT; -GLEW_FUN_EXPORT PFNGLSECONDARYCOLOR3SEXTPROC __glewSecondaryColor3sEXT; -GLEW_FUN_EXPORT PFNGLSECONDARYCOLOR3SVEXTPROC __glewSecondaryColor3svEXT; -GLEW_FUN_EXPORT PFNGLSECONDARYCOLOR3UBEXTPROC __glewSecondaryColor3ubEXT; -GLEW_FUN_EXPORT PFNGLSECONDARYCOLOR3UBVEXTPROC __glewSecondaryColor3ubvEXT; -GLEW_FUN_EXPORT PFNGLSECONDARYCOLOR3UIEXTPROC __glewSecondaryColor3uiEXT; -GLEW_FUN_EXPORT PFNGLSECONDARYCOLOR3UIVEXTPROC __glewSecondaryColor3uivEXT; -GLEW_FUN_EXPORT PFNGLSECONDARYCOLOR3USEXTPROC __glewSecondaryColor3usEXT; -GLEW_FUN_EXPORT PFNGLSECONDARYCOLOR3USVEXTPROC __glewSecondaryColor3usvEXT; -GLEW_FUN_EXPORT PFNGLSECONDARYCOLORPOINTEREXTPROC __glewSecondaryColorPointerEXT; - -GLEW_FUN_EXPORT PFNGLACTIVEPROGRAMEXTPROC __glewActiveProgramEXT; -GLEW_FUN_EXPORT PFNGLCREATESHADERPROGRAMEXTPROC __glewCreateShaderProgramEXT; -GLEW_FUN_EXPORT PFNGLUSESHADERPROGRAMEXTPROC __glewUseShaderProgramEXT; - -GLEW_FUN_EXPORT PFNGLBINDIMAGETEXTUREEXTPROC __glewBindImageTextureEXT; -GLEW_FUN_EXPORT PFNGLMEMORYBARRIEREXTPROC __glewMemoryBarrierEXT; - -GLEW_FUN_EXPORT PFNGLACTIVESTENCILFACEEXTPROC __glewActiveStencilFaceEXT; - -GLEW_FUN_EXPORT PFNGLTEXSUBIMAGE1DEXTPROC __glewTexSubImage1DEXT; -GLEW_FUN_EXPORT PFNGLTEXSUBIMAGE2DEXTPROC __glewTexSubImage2DEXT; -GLEW_FUN_EXPORT PFNGLTEXSUBIMAGE3DEXTPROC __glewTexSubImage3DEXT; - -GLEW_FUN_EXPORT PFNGLTEXIMAGE3DEXTPROC __glewTexImage3DEXT; - -GLEW_FUN_EXPORT PFNGLFRAMEBUFFERTEXTURELAYEREXTPROC __glewFramebufferTextureLayerEXT; - -GLEW_FUN_EXPORT PFNGLTEXBUFFEREXTPROC __glewTexBufferEXT; - -GLEW_FUN_EXPORT PFNGLCLEARCOLORIIEXTPROC __glewClearColorIiEXT; -GLEW_FUN_EXPORT PFNGLCLEARCOLORIUIEXTPROC __glewClearColorIuiEXT; -GLEW_FUN_EXPORT PFNGLGETTEXPARAMETERIIVEXTPROC __glewGetTexParameterIivEXT; -GLEW_FUN_EXPORT PFNGLGETTEXPARAMETERIUIVEXTPROC __glewGetTexParameterIuivEXT; -GLEW_FUN_EXPORT PFNGLTEXPARAMETERIIVEXTPROC __glewTexParameterIivEXT; -GLEW_FUN_EXPORT PFNGLTEXPARAMETERIUIVEXTPROC __glewTexParameterIuivEXT; - -GLEW_FUN_EXPORT PFNGLARETEXTURESRESIDENTEXTPROC __glewAreTexturesResidentEXT; -GLEW_FUN_EXPORT PFNGLBINDTEXTUREEXTPROC __glewBindTextureEXT; -GLEW_FUN_EXPORT PFNGLDELETETEXTURESEXTPROC __glewDeleteTexturesEXT; -GLEW_FUN_EXPORT PFNGLGENTEXTURESEXTPROC __glewGenTexturesEXT; -GLEW_FUN_EXPORT PFNGLISTEXTUREEXTPROC __glewIsTextureEXT; -GLEW_FUN_EXPORT PFNGLPRIORITIZETEXTURESEXTPROC __glewPrioritizeTexturesEXT; - -GLEW_FUN_EXPORT PFNGLTEXTURENORMALEXTPROC __glewTextureNormalEXT; - -GLEW_FUN_EXPORT PFNGLGETQUERYOBJECTI64VEXTPROC __glewGetQueryObjecti64vEXT; -GLEW_FUN_EXPORT PFNGLGETQUERYOBJECTUI64VEXTPROC __glewGetQueryObjectui64vEXT; - -GLEW_FUN_EXPORT PFNGLBEGINTRANSFORMFEEDBACKEXTPROC __glewBeginTransformFeedbackEXT; -GLEW_FUN_EXPORT PFNGLBINDBUFFERBASEEXTPROC __glewBindBufferBaseEXT; -GLEW_FUN_EXPORT PFNGLBINDBUFFEROFFSETEXTPROC __glewBindBufferOffsetEXT; -GLEW_FUN_EXPORT PFNGLBINDBUFFERRANGEEXTPROC __glewBindBufferRangeEXT; -GLEW_FUN_EXPORT PFNGLENDTRANSFORMFEEDBACKEXTPROC __glewEndTransformFeedbackEXT; -GLEW_FUN_EXPORT PFNGLGETTRANSFORMFEEDBACKVARYINGEXTPROC __glewGetTransformFeedbackVaryingEXT; -GLEW_FUN_EXPORT PFNGLTRANSFORMFEEDBACKVARYINGSEXTPROC __glewTransformFeedbackVaryingsEXT; - -GLEW_FUN_EXPORT PFNGLARRAYELEMENTEXTPROC __glewArrayElementEXT; -GLEW_FUN_EXPORT PFNGLCOLORPOINTEREXTPROC __glewColorPointerEXT; -GLEW_FUN_EXPORT PFNGLDRAWARRAYSEXTPROC __glewDrawArraysEXT; -GLEW_FUN_EXPORT PFNGLEDGEFLAGPOINTEREXTPROC __glewEdgeFlagPointerEXT; -GLEW_FUN_EXPORT PFNGLINDEXPOINTEREXTPROC __glewIndexPointerEXT; -GLEW_FUN_EXPORT PFNGLNORMALPOINTEREXTPROC __glewNormalPointerEXT; -GLEW_FUN_EXPORT PFNGLTEXCOORDPOINTEREXTPROC __glewTexCoordPointerEXT; -GLEW_FUN_EXPORT PFNGLVERTEXPOINTEREXTPROC __glewVertexPointerEXT; - -GLEW_FUN_EXPORT PFNGLGETVERTEXATTRIBLDVEXTPROC __glewGetVertexAttribLdvEXT; -GLEW_FUN_EXPORT PFNGLVERTEXARRAYVERTEXATTRIBLOFFSETEXTPROC __glewVertexArrayVertexAttribLOffsetEXT; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIBL1DEXTPROC __glewVertexAttribL1dEXT; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIBL1DVEXTPROC __glewVertexAttribL1dvEXT; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIBL2DEXTPROC __glewVertexAttribL2dEXT; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIBL2DVEXTPROC __glewVertexAttribL2dvEXT; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIBL3DEXTPROC __glewVertexAttribL3dEXT; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIBL3DVEXTPROC __glewVertexAttribL3dvEXT; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIBL4DEXTPROC __glewVertexAttribL4dEXT; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIBL4DVEXTPROC __glewVertexAttribL4dvEXT; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIBLPOINTEREXTPROC __glewVertexAttribLPointerEXT; - -GLEW_FUN_EXPORT PFNGLBEGINVERTEXSHADEREXTPROC __glewBeginVertexShaderEXT; -GLEW_FUN_EXPORT PFNGLBINDLIGHTPARAMETEREXTPROC __glewBindLightParameterEXT; -GLEW_FUN_EXPORT PFNGLBINDMATERIALPARAMETEREXTPROC __glewBindMaterialParameterEXT; -GLEW_FUN_EXPORT PFNGLBINDPARAMETEREXTPROC __glewBindParameterEXT; -GLEW_FUN_EXPORT PFNGLBINDTEXGENPARAMETEREXTPROC __glewBindTexGenParameterEXT; -GLEW_FUN_EXPORT PFNGLBINDTEXTUREUNITPARAMETEREXTPROC __glewBindTextureUnitParameterEXT; -GLEW_FUN_EXPORT PFNGLBINDVERTEXSHADEREXTPROC __glewBindVertexShaderEXT; -GLEW_FUN_EXPORT PFNGLDELETEVERTEXSHADEREXTPROC __glewDeleteVertexShaderEXT; -GLEW_FUN_EXPORT PFNGLDISABLEVARIANTCLIENTSTATEEXTPROC __glewDisableVariantClientStateEXT; -GLEW_FUN_EXPORT PFNGLENABLEVARIANTCLIENTSTATEEXTPROC __glewEnableVariantClientStateEXT; -GLEW_FUN_EXPORT PFNGLENDVERTEXSHADEREXTPROC __glewEndVertexShaderEXT; -GLEW_FUN_EXPORT PFNGLEXTRACTCOMPONENTEXTPROC __glewExtractComponentEXT; -GLEW_FUN_EXPORT PFNGLGENSYMBOLSEXTPROC __glewGenSymbolsEXT; -GLEW_FUN_EXPORT PFNGLGENVERTEXSHADERSEXTPROC __glewGenVertexShadersEXT; -GLEW_FUN_EXPORT PFNGLGETINVARIANTBOOLEANVEXTPROC __glewGetInvariantBooleanvEXT; -GLEW_FUN_EXPORT PFNGLGETINVARIANTFLOATVEXTPROC __glewGetInvariantFloatvEXT; -GLEW_FUN_EXPORT PFNGLGETINVARIANTINTEGERVEXTPROC __glewGetInvariantIntegervEXT; -GLEW_FUN_EXPORT PFNGLGETLOCALCONSTANTBOOLEANVEXTPROC __glewGetLocalConstantBooleanvEXT; -GLEW_FUN_EXPORT PFNGLGETLOCALCONSTANTFLOATVEXTPROC __glewGetLocalConstantFloatvEXT; -GLEW_FUN_EXPORT PFNGLGETLOCALCONSTANTINTEGERVEXTPROC __glewGetLocalConstantIntegervEXT; -GLEW_FUN_EXPORT PFNGLGETVARIANTBOOLEANVEXTPROC __glewGetVariantBooleanvEXT; -GLEW_FUN_EXPORT PFNGLGETVARIANTFLOATVEXTPROC __glewGetVariantFloatvEXT; -GLEW_FUN_EXPORT PFNGLGETVARIANTINTEGERVEXTPROC __glewGetVariantIntegervEXT; -GLEW_FUN_EXPORT PFNGLGETVARIANTPOINTERVEXTPROC __glewGetVariantPointervEXT; -GLEW_FUN_EXPORT PFNGLINSERTCOMPONENTEXTPROC __glewInsertComponentEXT; -GLEW_FUN_EXPORT PFNGLISVARIANTENABLEDEXTPROC __glewIsVariantEnabledEXT; -GLEW_FUN_EXPORT PFNGLSETINVARIANTEXTPROC __glewSetInvariantEXT; -GLEW_FUN_EXPORT PFNGLSETLOCALCONSTANTEXTPROC __glewSetLocalConstantEXT; -GLEW_FUN_EXPORT PFNGLSHADEROP1EXTPROC __glewShaderOp1EXT; -GLEW_FUN_EXPORT PFNGLSHADEROP2EXTPROC __glewShaderOp2EXT; -GLEW_FUN_EXPORT PFNGLSHADEROP3EXTPROC __glewShaderOp3EXT; -GLEW_FUN_EXPORT PFNGLSWIZZLEEXTPROC __glewSwizzleEXT; -GLEW_FUN_EXPORT PFNGLVARIANTPOINTEREXTPROC __glewVariantPointerEXT; -GLEW_FUN_EXPORT PFNGLVARIANTBVEXTPROC __glewVariantbvEXT; -GLEW_FUN_EXPORT PFNGLVARIANTDVEXTPROC __glewVariantdvEXT; -GLEW_FUN_EXPORT PFNGLVARIANTFVEXTPROC __glewVariantfvEXT; -GLEW_FUN_EXPORT PFNGLVARIANTIVEXTPROC __glewVariantivEXT; -GLEW_FUN_EXPORT PFNGLVARIANTSVEXTPROC __glewVariantsvEXT; -GLEW_FUN_EXPORT PFNGLVARIANTUBVEXTPROC __glewVariantubvEXT; -GLEW_FUN_EXPORT PFNGLVARIANTUIVEXTPROC __glewVariantuivEXT; -GLEW_FUN_EXPORT PFNGLVARIANTUSVEXTPROC __glewVariantusvEXT; -GLEW_FUN_EXPORT PFNGLWRITEMASKEXTPROC __glewWriteMaskEXT; - -GLEW_FUN_EXPORT PFNGLVERTEXWEIGHTPOINTEREXTPROC __glewVertexWeightPointerEXT; -GLEW_FUN_EXPORT PFNGLVERTEXWEIGHTFEXTPROC __glewVertexWeightfEXT; -GLEW_FUN_EXPORT PFNGLVERTEXWEIGHTFVEXTPROC __glewVertexWeightfvEXT; - -GLEW_FUN_EXPORT PFNGLWINDOWRECTANGLESEXTPROC __glewWindowRectanglesEXT; - -GLEW_FUN_EXPORT PFNGLIMPORTSYNCEXTPROC __glewImportSyncEXT; - -GLEW_FUN_EXPORT PFNGLFRAMETERMINATORGREMEDYPROC __glewFrameTerminatorGREMEDY; - -GLEW_FUN_EXPORT PFNGLSTRINGMARKERGREMEDYPROC __glewStringMarkerGREMEDY; - -GLEW_FUN_EXPORT PFNGLGETIMAGETRANSFORMPARAMETERFVHPPROC __glewGetImageTransformParameterfvHP; -GLEW_FUN_EXPORT PFNGLGETIMAGETRANSFORMPARAMETERIVHPPROC __glewGetImageTransformParameterivHP; -GLEW_FUN_EXPORT PFNGLIMAGETRANSFORMPARAMETERFHPPROC __glewImageTransformParameterfHP; -GLEW_FUN_EXPORT PFNGLIMAGETRANSFORMPARAMETERFVHPPROC __glewImageTransformParameterfvHP; -GLEW_FUN_EXPORT PFNGLIMAGETRANSFORMPARAMETERIHPPROC __glewImageTransformParameteriHP; -GLEW_FUN_EXPORT PFNGLIMAGETRANSFORMPARAMETERIVHPPROC __glewImageTransformParameterivHP; - -GLEW_FUN_EXPORT PFNGLMULTIMODEDRAWARRAYSIBMPROC __glewMultiModeDrawArraysIBM; -GLEW_FUN_EXPORT PFNGLMULTIMODEDRAWELEMENTSIBMPROC __glewMultiModeDrawElementsIBM; - -GLEW_FUN_EXPORT PFNGLCOLORPOINTERLISTIBMPROC __glewColorPointerListIBM; -GLEW_FUN_EXPORT PFNGLEDGEFLAGPOINTERLISTIBMPROC __glewEdgeFlagPointerListIBM; -GLEW_FUN_EXPORT PFNGLFOGCOORDPOINTERLISTIBMPROC __glewFogCoordPointerListIBM; -GLEW_FUN_EXPORT PFNGLINDEXPOINTERLISTIBMPROC __glewIndexPointerListIBM; -GLEW_FUN_EXPORT PFNGLNORMALPOINTERLISTIBMPROC __glewNormalPointerListIBM; -GLEW_FUN_EXPORT PFNGLSECONDARYCOLORPOINTERLISTIBMPROC __glewSecondaryColorPointerListIBM; -GLEW_FUN_EXPORT PFNGLTEXCOORDPOINTERLISTIBMPROC __glewTexCoordPointerListIBM; -GLEW_FUN_EXPORT PFNGLVERTEXPOINTERLISTIBMPROC __glewVertexPointerListIBM; - -GLEW_FUN_EXPORT PFNGLMAPTEXTURE2DINTELPROC __glewMapTexture2DINTEL; -GLEW_FUN_EXPORT PFNGLSYNCTEXTUREINTELPROC __glewSyncTextureINTEL; -GLEW_FUN_EXPORT PFNGLUNMAPTEXTURE2DINTELPROC __glewUnmapTexture2DINTEL; - -GLEW_FUN_EXPORT PFNGLCOLORPOINTERVINTELPROC __glewColorPointervINTEL; -GLEW_FUN_EXPORT PFNGLNORMALPOINTERVINTELPROC __glewNormalPointervINTEL; -GLEW_FUN_EXPORT PFNGLTEXCOORDPOINTERVINTELPROC __glewTexCoordPointervINTEL; -GLEW_FUN_EXPORT PFNGLVERTEXPOINTERVINTELPROC __glewVertexPointervINTEL; - -GLEW_FUN_EXPORT PFNGLBEGINPERFQUERYINTELPROC __glewBeginPerfQueryINTEL; -GLEW_FUN_EXPORT PFNGLCREATEPERFQUERYINTELPROC __glewCreatePerfQueryINTEL; -GLEW_FUN_EXPORT PFNGLDELETEPERFQUERYINTELPROC __glewDeletePerfQueryINTEL; -GLEW_FUN_EXPORT PFNGLENDPERFQUERYINTELPROC __glewEndPerfQueryINTEL; -GLEW_FUN_EXPORT PFNGLGETFIRSTPERFQUERYIDINTELPROC __glewGetFirstPerfQueryIdINTEL; -GLEW_FUN_EXPORT PFNGLGETNEXTPERFQUERYIDINTELPROC __glewGetNextPerfQueryIdINTEL; -GLEW_FUN_EXPORT PFNGLGETPERFCOUNTERINFOINTELPROC __glewGetPerfCounterInfoINTEL; -GLEW_FUN_EXPORT PFNGLGETPERFQUERYDATAINTELPROC __glewGetPerfQueryDataINTEL; -GLEW_FUN_EXPORT PFNGLGETPERFQUERYIDBYNAMEINTELPROC __glewGetPerfQueryIdByNameINTEL; -GLEW_FUN_EXPORT PFNGLGETPERFQUERYINFOINTELPROC __glewGetPerfQueryInfoINTEL; - -GLEW_FUN_EXPORT PFNGLTEXSCISSORFUNCINTELPROC __glewTexScissorFuncINTEL; -GLEW_FUN_EXPORT PFNGLTEXSCISSORINTELPROC __glewTexScissorINTEL; - -GLEW_FUN_EXPORT PFNGLBLENDBARRIERKHRPROC __glewBlendBarrierKHR; - -GLEW_FUN_EXPORT PFNGLDEBUGMESSAGECALLBACKPROC __glewDebugMessageCallback; -GLEW_FUN_EXPORT PFNGLDEBUGMESSAGECONTROLPROC __glewDebugMessageControl; -GLEW_FUN_EXPORT PFNGLDEBUGMESSAGEINSERTPROC __glewDebugMessageInsert; -GLEW_FUN_EXPORT PFNGLGETDEBUGMESSAGELOGPROC __glewGetDebugMessageLog; -GLEW_FUN_EXPORT PFNGLGETOBJECTLABELPROC __glewGetObjectLabel; -GLEW_FUN_EXPORT PFNGLGETOBJECTPTRLABELPROC __glewGetObjectPtrLabel; -GLEW_FUN_EXPORT PFNGLOBJECTLABELPROC __glewObjectLabel; -GLEW_FUN_EXPORT PFNGLOBJECTPTRLABELPROC __glewObjectPtrLabel; -GLEW_FUN_EXPORT PFNGLPOPDEBUGGROUPPROC __glewPopDebugGroup; -GLEW_FUN_EXPORT PFNGLPUSHDEBUGGROUPPROC __glewPushDebugGroup; - -GLEW_FUN_EXPORT PFNGLGETNUNIFORMFVPROC __glewGetnUniformfv; -GLEW_FUN_EXPORT PFNGLGETNUNIFORMIVPROC __glewGetnUniformiv; -GLEW_FUN_EXPORT PFNGLGETNUNIFORMUIVPROC __glewGetnUniformuiv; -GLEW_FUN_EXPORT PFNGLREADNPIXELSPROC __glewReadnPixels; - -GLEW_FUN_EXPORT PFNGLBUFFERREGIONENABLEDPROC __glewBufferRegionEnabled; -GLEW_FUN_EXPORT PFNGLDELETEBUFFERREGIONPROC __glewDeleteBufferRegion; -GLEW_FUN_EXPORT PFNGLDRAWBUFFERREGIONPROC __glewDrawBufferRegion; -GLEW_FUN_EXPORT PFNGLNEWBUFFERREGIONPROC __glewNewBufferRegion; -GLEW_FUN_EXPORT PFNGLREADBUFFERREGIONPROC __glewReadBufferRegion; - -GLEW_FUN_EXPORT PFNGLRESIZEBUFFERSMESAPROC __glewResizeBuffersMESA; - -GLEW_FUN_EXPORT PFNGLWINDOWPOS2DMESAPROC __glewWindowPos2dMESA; -GLEW_FUN_EXPORT PFNGLWINDOWPOS2DVMESAPROC __glewWindowPos2dvMESA; -GLEW_FUN_EXPORT PFNGLWINDOWPOS2FMESAPROC __glewWindowPos2fMESA; -GLEW_FUN_EXPORT PFNGLWINDOWPOS2FVMESAPROC __glewWindowPos2fvMESA; -GLEW_FUN_EXPORT PFNGLWINDOWPOS2IMESAPROC __glewWindowPos2iMESA; -GLEW_FUN_EXPORT PFNGLWINDOWPOS2IVMESAPROC __glewWindowPos2ivMESA; -GLEW_FUN_EXPORT PFNGLWINDOWPOS2SMESAPROC __glewWindowPos2sMESA; -GLEW_FUN_EXPORT PFNGLWINDOWPOS2SVMESAPROC __glewWindowPos2svMESA; -GLEW_FUN_EXPORT PFNGLWINDOWPOS3DMESAPROC __glewWindowPos3dMESA; -GLEW_FUN_EXPORT PFNGLWINDOWPOS3DVMESAPROC __glewWindowPos3dvMESA; -GLEW_FUN_EXPORT PFNGLWINDOWPOS3FMESAPROC __glewWindowPos3fMESA; -GLEW_FUN_EXPORT PFNGLWINDOWPOS3FVMESAPROC __glewWindowPos3fvMESA; -GLEW_FUN_EXPORT PFNGLWINDOWPOS3IMESAPROC __glewWindowPos3iMESA; -GLEW_FUN_EXPORT PFNGLWINDOWPOS3IVMESAPROC __glewWindowPos3ivMESA; -GLEW_FUN_EXPORT PFNGLWINDOWPOS3SMESAPROC __glewWindowPos3sMESA; -GLEW_FUN_EXPORT PFNGLWINDOWPOS3SVMESAPROC __glewWindowPos3svMESA; -GLEW_FUN_EXPORT PFNGLWINDOWPOS4DMESAPROC __glewWindowPos4dMESA; -GLEW_FUN_EXPORT PFNGLWINDOWPOS4DVMESAPROC __glewWindowPos4dvMESA; -GLEW_FUN_EXPORT PFNGLWINDOWPOS4FMESAPROC __glewWindowPos4fMESA; -GLEW_FUN_EXPORT PFNGLWINDOWPOS4FVMESAPROC __glewWindowPos4fvMESA; -GLEW_FUN_EXPORT PFNGLWINDOWPOS4IMESAPROC __glewWindowPos4iMESA; -GLEW_FUN_EXPORT PFNGLWINDOWPOS4IVMESAPROC __glewWindowPos4ivMESA; -GLEW_FUN_EXPORT PFNGLWINDOWPOS4SMESAPROC __glewWindowPos4sMESA; -GLEW_FUN_EXPORT PFNGLWINDOWPOS4SVMESAPROC __glewWindowPos4svMESA; - -GLEW_FUN_EXPORT PFNGLBEGINCONDITIONALRENDERNVXPROC __glewBeginConditionalRenderNVX; -GLEW_FUN_EXPORT PFNGLENDCONDITIONALRENDERNVXPROC __glewEndConditionalRenderNVX; - -GLEW_FUN_EXPORT PFNGLLGPUCOPYIMAGESUBDATANVXPROC __glewLGPUCopyImageSubDataNVX; -GLEW_FUN_EXPORT PFNGLLGPUINTERLOCKNVXPROC __glewLGPUInterlockNVX; -GLEW_FUN_EXPORT PFNGLLGPUNAMEDBUFFERSUBDATANVXPROC __glewLGPUNamedBufferSubDataNVX; - -GLEW_FUN_EXPORT PFNGLMULTIDRAWARRAYSINDIRECTBINDLESSNVPROC __glewMultiDrawArraysIndirectBindlessNV; -GLEW_FUN_EXPORT PFNGLMULTIDRAWELEMENTSINDIRECTBINDLESSNVPROC __glewMultiDrawElementsIndirectBindlessNV; - -GLEW_FUN_EXPORT PFNGLMULTIDRAWARRAYSINDIRECTBINDLESSCOUNTNVPROC __glewMultiDrawArraysIndirectBindlessCountNV; -GLEW_FUN_EXPORT PFNGLMULTIDRAWELEMENTSINDIRECTBINDLESSCOUNTNVPROC __glewMultiDrawElementsIndirectBindlessCountNV; - -GLEW_FUN_EXPORT PFNGLGETIMAGEHANDLENVPROC __glewGetImageHandleNV; -GLEW_FUN_EXPORT PFNGLGETTEXTUREHANDLENVPROC __glewGetTextureHandleNV; -GLEW_FUN_EXPORT PFNGLGETTEXTURESAMPLERHANDLENVPROC __glewGetTextureSamplerHandleNV; -GLEW_FUN_EXPORT PFNGLISIMAGEHANDLERESIDENTNVPROC __glewIsImageHandleResidentNV; -GLEW_FUN_EXPORT PFNGLISTEXTUREHANDLERESIDENTNVPROC __glewIsTextureHandleResidentNV; -GLEW_FUN_EXPORT PFNGLMAKEIMAGEHANDLENONRESIDENTNVPROC __glewMakeImageHandleNonResidentNV; -GLEW_FUN_EXPORT PFNGLMAKEIMAGEHANDLERESIDENTNVPROC __glewMakeImageHandleResidentNV; -GLEW_FUN_EXPORT PFNGLMAKETEXTUREHANDLENONRESIDENTNVPROC __glewMakeTextureHandleNonResidentNV; -GLEW_FUN_EXPORT PFNGLMAKETEXTUREHANDLERESIDENTNVPROC __glewMakeTextureHandleResidentNV; -GLEW_FUN_EXPORT PFNGLPROGRAMUNIFORMHANDLEUI64NVPROC __glewProgramUniformHandleui64NV; -GLEW_FUN_EXPORT PFNGLPROGRAMUNIFORMHANDLEUI64VNVPROC __glewProgramUniformHandleui64vNV; -GLEW_FUN_EXPORT PFNGLUNIFORMHANDLEUI64NVPROC __glewUniformHandleui64NV; -GLEW_FUN_EXPORT PFNGLUNIFORMHANDLEUI64VNVPROC __glewUniformHandleui64vNV; - -GLEW_FUN_EXPORT PFNGLBLENDBARRIERNVPROC __glewBlendBarrierNV; -GLEW_FUN_EXPORT PFNGLBLENDPARAMETERINVPROC __glewBlendParameteriNV; - -GLEW_FUN_EXPORT PFNGLVIEWPORTPOSITIONWSCALENVPROC __glewViewportPositionWScaleNV; - -GLEW_FUN_EXPORT PFNGLCALLCOMMANDLISTNVPROC __glewCallCommandListNV; -GLEW_FUN_EXPORT PFNGLCOMMANDLISTSEGMENTSNVPROC __glewCommandListSegmentsNV; -GLEW_FUN_EXPORT PFNGLCOMPILECOMMANDLISTNVPROC __glewCompileCommandListNV; -GLEW_FUN_EXPORT PFNGLCREATECOMMANDLISTSNVPROC __glewCreateCommandListsNV; -GLEW_FUN_EXPORT PFNGLCREATESTATESNVPROC __glewCreateStatesNV; -GLEW_FUN_EXPORT PFNGLDELETECOMMANDLISTSNVPROC __glewDeleteCommandListsNV; -GLEW_FUN_EXPORT PFNGLDELETESTATESNVPROC __glewDeleteStatesNV; -GLEW_FUN_EXPORT PFNGLDRAWCOMMANDSADDRESSNVPROC __glewDrawCommandsAddressNV; -GLEW_FUN_EXPORT PFNGLDRAWCOMMANDSNVPROC __glewDrawCommandsNV; -GLEW_FUN_EXPORT PFNGLDRAWCOMMANDSSTATESADDRESSNVPROC __glewDrawCommandsStatesAddressNV; -GLEW_FUN_EXPORT PFNGLDRAWCOMMANDSSTATESNVPROC __glewDrawCommandsStatesNV; -GLEW_FUN_EXPORT PFNGLGETCOMMANDHEADERNVPROC __glewGetCommandHeaderNV; -GLEW_FUN_EXPORT PFNGLGETSTAGEINDEXNVPROC __glewGetStageIndexNV; -GLEW_FUN_EXPORT PFNGLISCOMMANDLISTNVPROC __glewIsCommandListNV; -GLEW_FUN_EXPORT PFNGLISSTATENVPROC __glewIsStateNV; -GLEW_FUN_EXPORT PFNGLLISTDRAWCOMMANDSSTATESCLIENTNVPROC __glewListDrawCommandsStatesClientNV; -GLEW_FUN_EXPORT PFNGLSTATECAPTURENVPROC __glewStateCaptureNV; - -GLEW_FUN_EXPORT PFNGLBEGINCONDITIONALRENDERNVPROC __glewBeginConditionalRenderNV; -GLEW_FUN_EXPORT PFNGLENDCONDITIONALRENDERNVPROC __glewEndConditionalRenderNV; - -GLEW_FUN_EXPORT PFNGLSUBPIXELPRECISIONBIASNVPROC __glewSubpixelPrecisionBiasNV; - -GLEW_FUN_EXPORT PFNGLCONSERVATIVERASTERPARAMETERFNVPROC __glewConservativeRasterParameterfNV; - -GLEW_FUN_EXPORT PFNGLCONSERVATIVERASTERPARAMETERINVPROC __glewConservativeRasterParameteriNV; - -GLEW_FUN_EXPORT PFNGLCOPYIMAGESUBDATANVPROC __glewCopyImageSubDataNV; - -GLEW_FUN_EXPORT PFNGLCLEARDEPTHDNVPROC __glewClearDepthdNV; -GLEW_FUN_EXPORT PFNGLDEPTHBOUNDSDNVPROC __glewDepthBoundsdNV; -GLEW_FUN_EXPORT PFNGLDEPTHRANGEDNVPROC __glewDepthRangedNV; - -GLEW_FUN_EXPORT PFNGLDRAWTEXTURENVPROC __glewDrawTextureNV; - -GLEW_FUN_EXPORT PFNGLDRAWVKIMAGENVPROC __glewDrawVkImageNV; -GLEW_FUN_EXPORT PFNGLGETVKPROCADDRNVPROC __glewGetVkProcAddrNV; -GLEW_FUN_EXPORT PFNGLSIGNALVKFENCENVPROC __glewSignalVkFenceNV; -GLEW_FUN_EXPORT PFNGLSIGNALVKSEMAPHORENVPROC __glewSignalVkSemaphoreNV; -GLEW_FUN_EXPORT PFNGLWAITVKSEMAPHORENVPROC __glewWaitVkSemaphoreNV; - -GLEW_FUN_EXPORT PFNGLEVALMAPSNVPROC __glewEvalMapsNV; -GLEW_FUN_EXPORT PFNGLGETMAPATTRIBPARAMETERFVNVPROC __glewGetMapAttribParameterfvNV; -GLEW_FUN_EXPORT PFNGLGETMAPATTRIBPARAMETERIVNVPROC __glewGetMapAttribParameterivNV; -GLEW_FUN_EXPORT PFNGLGETMAPCONTROLPOINTSNVPROC __glewGetMapControlPointsNV; -GLEW_FUN_EXPORT PFNGLGETMAPPARAMETERFVNVPROC __glewGetMapParameterfvNV; -GLEW_FUN_EXPORT PFNGLGETMAPPARAMETERIVNVPROC __glewGetMapParameterivNV; -GLEW_FUN_EXPORT PFNGLMAPCONTROLPOINTSNVPROC __glewMapControlPointsNV; -GLEW_FUN_EXPORT PFNGLMAPPARAMETERFVNVPROC __glewMapParameterfvNV; -GLEW_FUN_EXPORT PFNGLMAPPARAMETERIVNVPROC __glewMapParameterivNV; - -GLEW_FUN_EXPORT PFNGLGETMULTISAMPLEFVNVPROC __glewGetMultisamplefvNV; -GLEW_FUN_EXPORT PFNGLSAMPLEMASKINDEXEDNVPROC __glewSampleMaskIndexedNV; -GLEW_FUN_EXPORT PFNGLTEXRENDERBUFFERNVPROC __glewTexRenderbufferNV; - -GLEW_FUN_EXPORT PFNGLDELETEFENCESNVPROC __glewDeleteFencesNV; -GLEW_FUN_EXPORT PFNGLFINISHFENCENVPROC __glewFinishFenceNV; -GLEW_FUN_EXPORT PFNGLGENFENCESNVPROC __glewGenFencesNV; -GLEW_FUN_EXPORT PFNGLGETFENCEIVNVPROC __glewGetFenceivNV; -GLEW_FUN_EXPORT PFNGLISFENCENVPROC __glewIsFenceNV; -GLEW_FUN_EXPORT PFNGLSETFENCENVPROC __glewSetFenceNV; -GLEW_FUN_EXPORT PFNGLTESTFENCENVPROC __glewTestFenceNV; - -GLEW_FUN_EXPORT PFNGLFRAGMENTCOVERAGECOLORNVPROC __glewFragmentCoverageColorNV; - -GLEW_FUN_EXPORT PFNGLGETPROGRAMNAMEDPARAMETERDVNVPROC __glewGetProgramNamedParameterdvNV; -GLEW_FUN_EXPORT PFNGLGETPROGRAMNAMEDPARAMETERFVNVPROC __glewGetProgramNamedParameterfvNV; -GLEW_FUN_EXPORT PFNGLPROGRAMNAMEDPARAMETER4DNVPROC __glewProgramNamedParameter4dNV; -GLEW_FUN_EXPORT PFNGLPROGRAMNAMEDPARAMETER4DVNVPROC __glewProgramNamedParameter4dvNV; -GLEW_FUN_EXPORT PFNGLPROGRAMNAMEDPARAMETER4FNVPROC __glewProgramNamedParameter4fNV; -GLEW_FUN_EXPORT PFNGLPROGRAMNAMEDPARAMETER4FVNVPROC __glewProgramNamedParameter4fvNV; - -GLEW_FUN_EXPORT PFNGLRENDERBUFFERSTORAGEMULTISAMPLECOVERAGENVPROC __glewRenderbufferStorageMultisampleCoverageNV; - -GLEW_FUN_EXPORT PFNGLPROGRAMVERTEXLIMITNVPROC __glewProgramVertexLimitNV; - -GLEW_FUN_EXPORT PFNGLMULTICASTBARRIERNVPROC __glewMulticastBarrierNV; -GLEW_FUN_EXPORT PFNGLMULTICASTBLITFRAMEBUFFERNVPROC __glewMulticastBlitFramebufferNV; -GLEW_FUN_EXPORT PFNGLMULTICASTBUFFERSUBDATANVPROC __glewMulticastBufferSubDataNV; -GLEW_FUN_EXPORT PFNGLMULTICASTCOPYBUFFERSUBDATANVPROC __glewMulticastCopyBufferSubDataNV; -GLEW_FUN_EXPORT PFNGLMULTICASTCOPYIMAGESUBDATANVPROC __glewMulticastCopyImageSubDataNV; -GLEW_FUN_EXPORT PFNGLMULTICASTFRAMEBUFFERSAMPLELOCATIONSFVNVPROC __glewMulticastFramebufferSampleLocationsfvNV; -GLEW_FUN_EXPORT PFNGLMULTICASTGETQUERYOBJECTI64VNVPROC __glewMulticastGetQueryObjecti64vNV; -GLEW_FUN_EXPORT PFNGLMULTICASTGETQUERYOBJECTIVNVPROC __glewMulticastGetQueryObjectivNV; -GLEW_FUN_EXPORT PFNGLMULTICASTGETQUERYOBJECTUI64VNVPROC __glewMulticastGetQueryObjectui64vNV; -GLEW_FUN_EXPORT PFNGLMULTICASTGETQUERYOBJECTUIVNVPROC __glewMulticastGetQueryObjectuivNV; -GLEW_FUN_EXPORT PFNGLMULTICASTWAITSYNCNVPROC __glewMulticastWaitSyncNV; -GLEW_FUN_EXPORT PFNGLRENDERGPUMASKNVPROC __glewRenderGpuMaskNV; - -GLEW_FUN_EXPORT PFNGLPROGRAMENVPARAMETERI4INVPROC __glewProgramEnvParameterI4iNV; -GLEW_FUN_EXPORT PFNGLPROGRAMENVPARAMETERI4IVNVPROC __glewProgramEnvParameterI4ivNV; -GLEW_FUN_EXPORT PFNGLPROGRAMENVPARAMETERI4UINVPROC __glewProgramEnvParameterI4uiNV; -GLEW_FUN_EXPORT PFNGLPROGRAMENVPARAMETERI4UIVNVPROC __glewProgramEnvParameterI4uivNV; -GLEW_FUN_EXPORT PFNGLPROGRAMENVPARAMETERSI4IVNVPROC __glewProgramEnvParametersI4ivNV; -GLEW_FUN_EXPORT PFNGLPROGRAMENVPARAMETERSI4UIVNVPROC __glewProgramEnvParametersI4uivNV; -GLEW_FUN_EXPORT PFNGLPROGRAMLOCALPARAMETERI4INVPROC __glewProgramLocalParameterI4iNV; -GLEW_FUN_EXPORT PFNGLPROGRAMLOCALPARAMETERI4IVNVPROC __glewProgramLocalParameterI4ivNV; -GLEW_FUN_EXPORT PFNGLPROGRAMLOCALPARAMETERI4UINVPROC __glewProgramLocalParameterI4uiNV; -GLEW_FUN_EXPORT PFNGLPROGRAMLOCALPARAMETERI4UIVNVPROC __glewProgramLocalParameterI4uivNV; -GLEW_FUN_EXPORT PFNGLPROGRAMLOCALPARAMETERSI4IVNVPROC __glewProgramLocalParametersI4ivNV; -GLEW_FUN_EXPORT PFNGLPROGRAMLOCALPARAMETERSI4UIVNVPROC __glewProgramLocalParametersI4uivNV; - -GLEW_FUN_EXPORT PFNGLGETUNIFORMI64VNVPROC __glewGetUniformi64vNV; -GLEW_FUN_EXPORT PFNGLGETUNIFORMUI64VNVPROC __glewGetUniformui64vNV; -GLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM1I64NVPROC __glewProgramUniform1i64NV; -GLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM1I64VNVPROC __glewProgramUniform1i64vNV; -GLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM1UI64NVPROC __glewProgramUniform1ui64NV; -GLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM1UI64VNVPROC __glewProgramUniform1ui64vNV; -GLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM2I64NVPROC __glewProgramUniform2i64NV; -GLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM2I64VNVPROC __glewProgramUniform2i64vNV; -GLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM2UI64NVPROC __glewProgramUniform2ui64NV; -GLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM2UI64VNVPROC __glewProgramUniform2ui64vNV; -GLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM3I64NVPROC __glewProgramUniform3i64NV; -GLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM3I64VNVPROC __glewProgramUniform3i64vNV; -GLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM3UI64NVPROC __glewProgramUniform3ui64NV; -GLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM3UI64VNVPROC __glewProgramUniform3ui64vNV; -GLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM4I64NVPROC __glewProgramUniform4i64NV; -GLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM4I64VNVPROC __glewProgramUniform4i64vNV; -GLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM4UI64NVPROC __glewProgramUniform4ui64NV; -GLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM4UI64VNVPROC __glewProgramUniform4ui64vNV; -GLEW_FUN_EXPORT PFNGLUNIFORM1I64NVPROC __glewUniform1i64NV; -GLEW_FUN_EXPORT PFNGLUNIFORM1I64VNVPROC __glewUniform1i64vNV; -GLEW_FUN_EXPORT PFNGLUNIFORM1UI64NVPROC __glewUniform1ui64NV; -GLEW_FUN_EXPORT PFNGLUNIFORM1UI64VNVPROC __glewUniform1ui64vNV; -GLEW_FUN_EXPORT PFNGLUNIFORM2I64NVPROC __glewUniform2i64NV; -GLEW_FUN_EXPORT PFNGLUNIFORM2I64VNVPROC __glewUniform2i64vNV; -GLEW_FUN_EXPORT PFNGLUNIFORM2UI64NVPROC __glewUniform2ui64NV; -GLEW_FUN_EXPORT PFNGLUNIFORM2UI64VNVPROC __glewUniform2ui64vNV; -GLEW_FUN_EXPORT PFNGLUNIFORM3I64NVPROC __glewUniform3i64NV; -GLEW_FUN_EXPORT PFNGLUNIFORM3I64VNVPROC __glewUniform3i64vNV; -GLEW_FUN_EXPORT PFNGLUNIFORM3UI64NVPROC __glewUniform3ui64NV; -GLEW_FUN_EXPORT PFNGLUNIFORM3UI64VNVPROC __glewUniform3ui64vNV; -GLEW_FUN_EXPORT PFNGLUNIFORM4I64NVPROC __glewUniform4i64NV; -GLEW_FUN_EXPORT PFNGLUNIFORM4I64VNVPROC __glewUniform4i64vNV; -GLEW_FUN_EXPORT PFNGLUNIFORM4UI64NVPROC __glewUniform4ui64NV; -GLEW_FUN_EXPORT PFNGLUNIFORM4UI64VNVPROC __glewUniform4ui64vNV; - -GLEW_FUN_EXPORT PFNGLCOLOR3HNVPROC __glewColor3hNV; -GLEW_FUN_EXPORT PFNGLCOLOR3HVNVPROC __glewColor3hvNV; -GLEW_FUN_EXPORT PFNGLCOLOR4HNVPROC __glewColor4hNV; -GLEW_FUN_EXPORT PFNGLCOLOR4HVNVPROC __glewColor4hvNV; -GLEW_FUN_EXPORT PFNGLFOGCOORDHNVPROC __glewFogCoordhNV; -GLEW_FUN_EXPORT PFNGLFOGCOORDHVNVPROC __glewFogCoordhvNV; -GLEW_FUN_EXPORT PFNGLMULTITEXCOORD1HNVPROC __glewMultiTexCoord1hNV; -GLEW_FUN_EXPORT PFNGLMULTITEXCOORD1HVNVPROC __glewMultiTexCoord1hvNV; -GLEW_FUN_EXPORT PFNGLMULTITEXCOORD2HNVPROC __glewMultiTexCoord2hNV; -GLEW_FUN_EXPORT PFNGLMULTITEXCOORD2HVNVPROC __glewMultiTexCoord2hvNV; -GLEW_FUN_EXPORT PFNGLMULTITEXCOORD3HNVPROC __glewMultiTexCoord3hNV; -GLEW_FUN_EXPORT PFNGLMULTITEXCOORD3HVNVPROC __glewMultiTexCoord3hvNV; -GLEW_FUN_EXPORT PFNGLMULTITEXCOORD4HNVPROC __glewMultiTexCoord4hNV; -GLEW_FUN_EXPORT PFNGLMULTITEXCOORD4HVNVPROC __glewMultiTexCoord4hvNV; -GLEW_FUN_EXPORT PFNGLNORMAL3HNVPROC __glewNormal3hNV; -GLEW_FUN_EXPORT PFNGLNORMAL3HVNVPROC __glewNormal3hvNV; -GLEW_FUN_EXPORT PFNGLSECONDARYCOLOR3HNVPROC __glewSecondaryColor3hNV; -GLEW_FUN_EXPORT PFNGLSECONDARYCOLOR3HVNVPROC __glewSecondaryColor3hvNV; -GLEW_FUN_EXPORT PFNGLTEXCOORD1HNVPROC __glewTexCoord1hNV; -GLEW_FUN_EXPORT PFNGLTEXCOORD1HVNVPROC __glewTexCoord1hvNV; -GLEW_FUN_EXPORT PFNGLTEXCOORD2HNVPROC __glewTexCoord2hNV; -GLEW_FUN_EXPORT PFNGLTEXCOORD2HVNVPROC __glewTexCoord2hvNV; -GLEW_FUN_EXPORT PFNGLTEXCOORD3HNVPROC __glewTexCoord3hNV; -GLEW_FUN_EXPORT PFNGLTEXCOORD3HVNVPROC __glewTexCoord3hvNV; -GLEW_FUN_EXPORT PFNGLTEXCOORD4HNVPROC __glewTexCoord4hNV; -GLEW_FUN_EXPORT PFNGLTEXCOORD4HVNVPROC __glewTexCoord4hvNV; -GLEW_FUN_EXPORT PFNGLVERTEX2HNVPROC __glewVertex2hNV; -GLEW_FUN_EXPORT PFNGLVERTEX2HVNVPROC __glewVertex2hvNV; -GLEW_FUN_EXPORT PFNGLVERTEX3HNVPROC __glewVertex3hNV; -GLEW_FUN_EXPORT PFNGLVERTEX3HVNVPROC __glewVertex3hvNV; -GLEW_FUN_EXPORT PFNGLVERTEX4HNVPROC __glewVertex4hNV; -GLEW_FUN_EXPORT PFNGLVERTEX4HVNVPROC __glewVertex4hvNV; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIB1HNVPROC __glewVertexAttrib1hNV; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIB1HVNVPROC __glewVertexAttrib1hvNV; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIB2HNVPROC __glewVertexAttrib2hNV; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIB2HVNVPROC __glewVertexAttrib2hvNV; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIB3HNVPROC __glewVertexAttrib3hNV; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIB3HVNVPROC __glewVertexAttrib3hvNV; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIB4HNVPROC __glewVertexAttrib4hNV; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIB4HVNVPROC __glewVertexAttrib4hvNV; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIBS1HVNVPROC __glewVertexAttribs1hvNV; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIBS2HVNVPROC __glewVertexAttribs2hvNV; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIBS3HVNVPROC __glewVertexAttribs3hvNV; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIBS4HVNVPROC __glewVertexAttribs4hvNV; -GLEW_FUN_EXPORT PFNGLVERTEXWEIGHTHNVPROC __glewVertexWeighthNV; -GLEW_FUN_EXPORT PFNGLVERTEXWEIGHTHVNVPROC __glewVertexWeighthvNV; - -GLEW_FUN_EXPORT PFNGLGETINTERNALFORMATSAMPLEIVNVPROC __glewGetInternalformatSampleivNV; - -GLEW_FUN_EXPORT PFNGLBEGINOCCLUSIONQUERYNVPROC __glewBeginOcclusionQueryNV; -GLEW_FUN_EXPORT PFNGLDELETEOCCLUSIONQUERIESNVPROC __glewDeleteOcclusionQueriesNV; -GLEW_FUN_EXPORT PFNGLENDOCCLUSIONQUERYNVPROC __glewEndOcclusionQueryNV; -GLEW_FUN_EXPORT PFNGLGENOCCLUSIONQUERIESNVPROC __glewGenOcclusionQueriesNV; -GLEW_FUN_EXPORT PFNGLGETOCCLUSIONQUERYIVNVPROC __glewGetOcclusionQueryivNV; -GLEW_FUN_EXPORT PFNGLGETOCCLUSIONQUERYUIVNVPROC __glewGetOcclusionQueryuivNV; -GLEW_FUN_EXPORT PFNGLISOCCLUSIONQUERYNVPROC __glewIsOcclusionQueryNV; - -GLEW_FUN_EXPORT PFNGLPROGRAMBUFFERPARAMETERSIIVNVPROC __glewProgramBufferParametersIivNV; -GLEW_FUN_EXPORT PFNGLPROGRAMBUFFERPARAMETERSIUIVNVPROC __glewProgramBufferParametersIuivNV; -GLEW_FUN_EXPORT PFNGLPROGRAMBUFFERPARAMETERSFVNVPROC __glewProgramBufferParametersfvNV; - -GLEW_FUN_EXPORT PFNGLCOPYPATHNVPROC __glewCopyPathNV; -GLEW_FUN_EXPORT PFNGLCOVERFILLPATHINSTANCEDNVPROC __glewCoverFillPathInstancedNV; -GLEW_FUN_EXPORT PFNGLCOVERFILLPATHNVPROC __glewCoverFillPathNV; -GLEW_FUN_EXPORT PFNGLCOVERSTROKEPATHINSTANCEDNVPROC __glewCoverStrokePathInstancedNV; -GLEW_FUN_EXPORT PFNGLCOVERSTROKEPATHNVPROC __glewCoverStrokePathNV; -GLEW_FUN_EXPORT PFNGLDELETEPATHSNVPROC __glewDeletePathsNV; -GLEW_FUN_EXPORT PFNGLGENPATHSNVPROC __glewGenPathsNV; -GLEW_FUN_EXPORT PFNGLGETPATHCOLORGENFVNVPROC __glewGetPathColorGenfvNV; -GLEW_FUN_EXPORT PFNGLGETPATHCOLORGENIVNVPROC __glewGetPathColorGenivNV; -GLEW_FUN_EXPORT PFNGLGETPATHCOMMANDSNVPROC __glewGetPathCommandsNV; -GLEW_FUN_EXPORT PFNGLGETPATHCOORDSNVPROC __glewGetPathCoordsNV; -GLEW_FUN_EXPORT PFNGLGETPATHDASHARRAYNVPROC __glewGetPathDashArrayNV; -GLEW_FUN_EXPORT PFNGLGETPATHLENGTHNVPROC __glewGetPathLengthNV; -GLEW_FUN_EXPORT PFNGLGETPATHMETRICRANGENVPROC __glewGetPathMetricRangeNV; -GLEW_FUN_EXPORT PFNGLGETPATHMETRICSNVPROC __glewGetPathMetricsNV; -GLEW_FUN_EXPORT PFNGLGETPATHPARAMETERFVNVPROC __glewGetPathParameterfvNV; -GLEW_FUN_EXPORT PFNGLGETPATHPARAMETERIVNVPROC __glewGetPathParameterivNV; -GLEW_FUN_EXPORT PFNGLGETPATHSPACINGNVPROC __glewGetPathSpacingNV; -GLEW_FUN_EXPORT PFNGLGETPATHTEXGENFVNVPROC __glewGetPathTexGenfvNV; -GLEW_FUN_EXPORT PFNGLGETPATHTEXGENIVNVPROC __glewGetPathTexGenivNV; -GLEW_FUN_EXPORT PFNGLGETPROGRAMRESOURCEFVNVPROC __glewGetProgramResourcefvNV; -GLEW_FUN_EXPORT PFNGLINTERPOLATEPATHSNVPROC __glewInterpolatePathsNV; -GLEW_FUN_EXPORT PFNGLISPATHNVPROC __glewIsPathNV; -GLEW_FUN_EXPORT PFNGLISPOINTINFILLPATHNVPROC __glewIsPointInFillPathNV; -GLEW_FUN_EXPORT PFNGLISPOINTINSTROKEPATHNVPROC __glewIsPointInStrokePathNV; -GLEW_FUN_EXPORT PFNGLMATRIXLOAD3X2FNVPROC __glewMatrixLoad3x2fNV; -GLEW_FUN_EXPORT PFNGLMATRIXLOAD3X3FNVPROC __glewMatrixLoad3x3fNV; -GLEW_FUN_EXPORT PFNGLMATRIXLOADTRANSPOSE3X3FNVPROC __glewMatrixLoadTranspose3x3fNV; -GLEW_FUN_EXPORT PFNGLMATRIXMULT3X2FNVPROC __glewMatrixMult3x2fNV; -GLEW_FUN_EXPORT PFNGLMATRIXMULT3X3FNVPROC __glewMatrixMult3x3fNV; -GLEW_FUN_EXPORT PFNGLMATRIXMULTTRANSPOSE3X3FNVPROC __glewMatrixMultTranspose3x3fNV; -GLEW_FUN_EXPORT PFNGLPATHCOLORGENNVPROC __glewPathColorGenNV; -GLEW_FUN_EXPORT PFNGLPATHCOMMANDSNVPROC __glewPathCommandsNV; -GLEW_FUN_EXPORT PFNGLPATHCOORDSNVPROC __glewPathCoordsNV; -GLEW_FUN_EXPORT PFNGLPATHCOVERDEPTHFUNCNVPROC __glewPathCoverDepthFuncNV; -GLEW_FUN_EXPORT PFNGLPATHDASHARRAYNVPROC __glewPathDashArrayNV; -GLEW_FUN_EXPORT PFNGLPATHFOGGENNVPROC __glewPathFogGenNV; -GLEW_FUN_EXPORT PFNGLPATHGLYPHINDEXARRAYNVPROC __glewPathGlyphIndexArrayNV; -GLEW_FUN_EXPORT PFNGLPATHGLYPHINDEXRANGENVPROC __glewPathGlyphIndexRangeNV; -GLEW_FUN_EXPORT PFNGLPATHGLYPHRANGENVPROC __glewPathGlyphRangeNV; -GLEW_FUN_EXPORT PFNGLPATHGLYPHSNVPROC __glewPathGlyphsNV; -GLEW_FUN_EXPORT PFNGLPATHMEMORYGLYPHINDEXARRAYNVPROC __glewPathMemoryGlyphIndexArrayNV; -GLEW_FUN_EXPORT PFNGLPATHPARAMETERFNVPROC __glewPathParameterfNV; -GLEW_FUN_EXPORT PFNGLPATHPARAMETERFVNVPROC __glewPathParameterfvNV; -GLEW_FUN_EXPORT PFNGLPATHPARAMETERINVPROC __glewPathParameteriNV; -GLEW_FUN_EXPORT PFNGLPATHPARAMETERIVNVPROC __glewPathParameterivNV; -GLEW_FUN_EXPORT PFNGLPATHSTENCILDEPTHOFFSETNVPROC __glewPathStencilDepthOffsetNV; -GLEW_FUN_EXPORT PFNGLPATHSTENCILFUNCNVPROC __glewPathStencilFuncNV; -GLEW_FUN_EXPORT PFNGLPATHSTRINGNVPROC __glewPathStringNV; -GLEW_FUN_EXPORT PFNGLPATHSUBCOMMANDSNVPROC __glewPathSubCommandsNV; -GLEW_FUN_EXPORT PFNGLPATHSUBCOORDSNVPROC __glewPathSubCoordsNV; -GLEW_FUN_EXPORT PFNGLPATHTEXGENNVPROC __glewPathTexGenNV; -GLEW_FUN_EXPORT PFNGLPOINTALONGPATHNVPROC __glewPointAlongPathNV; -GLEW_FUN_EXPORT PFNGLPROGRAMPATHFRAGMENTINPUTGENNVPROC __glewProgramPathFragmentInputGenNV; -GLEW_FUN_EXPORT PFNGLSTENCILFILLPATHINSTANCEDNVPROC __glewStencilFillPathInstancedNV; -GLEW_FUN_EXPORT PFNGLSTENCILFILLPATHNVPROC __glewStencilFillPathNV; -GLEW_FUN_EXPORT PFNGLSTENCILSTROKEPATHINSTANCEDNVPROC __glewStencilStrokePathInstancedNV; -GLEW_FUN_EXPORT PFNGLSTENCILSTROKEPATHNVPROC __glewStencilStrokePathNV; -GLEW_FUN_EXPORT PFNGLSTENCILTHENCOVERFILLPATHINSTANCEDNVPROC __glewStencilThenCoverFillPathInstancedNV; -GLEW_FUN_EXPORT PFNGLSTENCILTHENCOVERFILLPATHNVPROC __glewStencilThenCoverFillPathNV; -GLEW_FUN_EXPORT PFNGLSTENCILTHENCOVERSTROKEPATHINSTANCEDNVPROC __glewStencilThenCoverStrokePathInstancedNV; -GLEW_FUN_EXPORT PFNGLSTENCILTHENCOVERSTROKEPATHNVPROC __glewStencilThenCoverStrokePathNV; -GLEW_FUN_EXPORT PFNGLTRANSFORMPATHNVPROC __glewTransformPathNV; -GLEW_FUN_EXPORT PFNGLWEIGHTPATHSNVPROC __glewWeightPathsNV; - -GLEW_FUN_EXPORT PFNGLFLUSHPIXELDATARANGENVPROC __glewFlushPixelDataRangeNV; -GLEW_FUN_EXPORT PFNGLPIXELDATARANGENVPROC __glewPixelDataRangeNV; - -GLEW_FUN_EXPORT PFNGLPOINTPARAMETERINVPROC __glewPointParameteriNV; -GLEW_FUN_EXPORT PFNGLPOINTPARAMETERIVNVPROC __glewPointParameterivNV; - -GLEW_FUN_EXPORT PFNGLGETVIDEOI64VNVPROC __glewGetVideoi64vNV; -GLEW_FUN_EXPORT PFNGLGETVIDEOIVNVPROC __glewGetVideoivNV; -GLEW_FUN_EXPORT PFNGLGETVIDEOUI64VNVPROC __glewGetVideoui64vNV; -GLEW_FUN_EXPORT PFNGLGETVIDEOUIVNVPROC __glewGetVideouivNV; -GLEW_FUN_EXPORT PFNGLPRESENTFRAMEDUALFILLNVPROC __glewPresentFrameDualFillNV; -GLEW_FUN_EXPORT PFNGLPRESENTFRAMEKEYEDNVPROC __glewPresentFrameKeyedNV; - -GLEW_FUN_EXPORT PFNGLPRIMITIVERESTARTINDEXNVPROC __glewPrimitiveRestartIndexNV; -GLEW_FUN_EXPORT PFNGLPRIMITIVERESTARTNVPROC __glewPrimitiveRestartNV; - -GLEW_FUN_EXPORT PFNGLCOMBINERINPUTNVPROC __glewCombinerInputNV; -GLEW_FUN_EXPORT PFNGLCOMBINEROUTPUTNVPROC __glewCombinerOutputNV; -GLEW_FUN_EXPORT PFNGLCOMBINERPARAMETERFNVPROC __glewCombinerParameterfNV; -GLEW_FUN_EXPORT PFNGLCOMBINERPARAMETERFVNVPROC __glewCombinerParameterfvNV; -GLEW_FUN_EXPORT PFNGLCOMBINERPARAMETERINVPROC __glewCombinerParameteriNV; -GLEW_FUN_EXPORT PFNGLCOMBINERPARAMETERIVNVPROC __glewCombinerParameterivNV; -GLEW_FUN_EXPORT PFNGLFINALCOMBINERINPUTNVPROC __glewFinalCombinerInputNV; -GLEW_FUN_EXPORT PFNGLGETCOMBINERINPUTPARAMETERFVNVPROC __glewGetCombinerInputParameterfvNV; -GLEW_FUN_EXPORT PFNGLGETCOMBINERINPUTPARAMETERIVNVPROC __glewGetCombinerInputParameterivNV; -GLEW_FUN_EXPORT PFNGLGETCOMBINEROUTPUTPARAMETERFVNVPROC __glewGetCombinerOutputParameterfvNV; -GLEW_FUN_EXPORT PFNGLGETCOMBINEROUTPUTPARAMETERIVNVPROC __glewGetCombinerOutputParameterivNV; -GLEW_FUN_EXPORT PFNGLGETFINALCOMBINERINPUTPARAMETERFVNVPROC __glewGetFinalCombinerInputParameterfvNV; -GLEW_FUN_EXPORT PFNGLGETFINALCOMBINERINPUTPARAMETERIVNVPROC __glewGetFinalCombinerInputParameterivNV; - -GLEW_FUN_EXPORT PFNGLCOMBINERSTAGEPARAMETERFVNVPROC __glewCombinerStageParameterfvNV; -GLEW_FUN_EXPORT PFNGLGETCOMBINERSTAGEPARAMETERFVNVPROC __glewGetCombinerStageParameterfvNV; - -GLEW_FUN_EXPORT PFNGLFRAMEBUFFERSAMPLELOCATIONSFVNVPROC __glewFramebufferSampleLocationsfvNV; -GLEW_FUN_EXPORT PFNGLNAMEDFRAMEBUFFERSAMPLELOCATIONSFVNVPROC __glewNamedFramebufferSampleLocationsfvNV; - -GLEW_FUN_EXPORT PFNGLGETBUFFERPARAMETERUI64VNVPROC __glewGetBufferParameterui64vNV; -GLEW_FUN_EXPORT PFNGLGETINTEGERUI64VNVPROC __glewGetIntegerui64vNV; -GLEW_FUN_EXPORT PFNGLGETNAMEDBUFFERPARAMETERUI64VNVPROC __glewGetNamedBufferParameterui64vNV; -GLEW_FUN_EXPORT PFNGLISBUFFERRESIDENTNVPROC __glewIsBufferResidentNV; -GLEW_FUN_EXPORT PFNGLISNAMEDBUFFERRESIDENTNVPROC __glewIsNamedBufferResidentNV; -GLEW_FUN_EXPORT PFNGLMAKEBUFFERNONRESIDENTNVPROC __glewMakeBufferNonResidentNV; -GLEW_FUN_EXPORT PFNGLMAKEBUFFERRESIDENTNVPROC __glewMakeBufferResidentNV; -GLEW_FUN_EXPORT PFNGLMAKENAMEDBUFFERNONRESIDENTNVPROC __glewMakeNamedBufferNonResidentNV; -GLEW_FUN_EXPORT PFNGLMAKENAMEDBUFFERRESIDENTNVPROC __glewMakeNamedBufferResidentNV; -GLEW_FUN_EXPORT PFNGLPROGRAMUNIFORMUI64NVPROC __glewProgramUniformui64NV; -GLEW_FUN_EXPORT PFNGLPROGRAMUNIFORMUI64VNVPROC __glewProgramUniformui64vNV; -GLEW_FUN_EXPORT PFNGLUNIFORMUI64NVPROC __glewUniformui64NV; -GLEW_FUN_EXPORT PFNGLUNIFORMUI64VNVPROC __glewUniformui64vNV; - -GLEW_FUN_EXPORT PFNGLTEXTUREBARRIERNVPROC __glewTextureBarrierNV; - -GLEW_FUN_EXPORT PFNGLTEXIMAGE2DMULTISAMPLECOVERAGENVPROC __glewTexImage2DMultisampleCoverageNV; -GLEW_FUN_EXPORT PFNGLTEXIMAGE3DMULTISAMPLECOVERAGENVPROC __glewTexImage3DMultisampleCoverageNV; -GLEW_FUN_EXPORT PFNGLTEXTUREIMAGE2DMULTISAMPLECOVERAGENVPROC __glewTextureImage2DMultisampleCoverageNV; -GLEW_FUN_EXPORT PFNGLTEXTUREIMAGE2DMULTISAMPLENVPROC __glewTextureImage2DMultisampleNV; -GLEW_FUN_EXPORT PFNGLTEXTUREIMAGE3DMULTISAMPLECOVERAGENVPROC __glewTextureImage3DMultisampleCoverageNV; -GLEW_FUN_EXPORT PFNGLTEXTUREIMAGE3DMULTISAMPLENVPROC __glewTextureImage3DMultisampleNV; - -GLEW_FUN_EXPORT PFNGLACTIVEVARYINGNVPROC __glewActiveVaryingNV; -GLEW_FUN_EXPORT PFNGLBEGINTRANSFORMFEEDBACKNVPROC __glewBeginTransformFeedbackNV; -GLEW_FUN_EXPORT PFNGLBINDBUFFERBASENVPROC __glewBindBufferBaseNV; -GLEW_FUN_EXPORT PFNGLBINDBUFFEROFFSETNVPROC __glewBindBufferOffsetNV; -GLEW_FUN_EXPORT PFNGLBINDBUFFERRANGENVPROC __glewBindBufferRangeNV; -GLEW_FUN_EXPORT PFNGLENDTRANSFORMFEEDBACKNVPROC __glewEndTransformFeedbackNV; -GLEW_FUN_EXPORT PFNGLGETACTIVEVARYINGNVPROC __glewGetActiveVaryingNV; -GLEW_FUN_EXPORT PFNGLGETTRANSFORMFEEDBACKVARYINGNVPROC __glewGetTransformFeedbackVaryingNV; -GLEW_FUN_EXPORT PFNGLGETVARYINGLOCATIONNVPROC __glewGetVaryingLocationNV; -GLEW_FUN_EXPORT PFNGLTRANSFORMFEEDBACKATTRIBSNVPROC __glewTransformFeedbackAttribsNV; -GLEW_FUN_EXPORT PFNGLTRANSFORMFEEDBACKVARYINGSNVPROC __glewTransformFeedbackVaryingsNV; - -GLEW_FUN_EXPORT PFNGLBINDTRANSFORMFEEDBACKNVPROC __glewBindTransformFeedbackNV; -GLEW_FUN_EXPORT PFNGLDELETETRANSFORMFEEDBACKSNVPROC __glewDeleteTransformFeedbacksNV; -GLEW_FUN_EXPORT PFNGLDRAWTRANSFORMFEEDBACKNVPROC __glewDrawTransformFeedbackNV; -GLEW_FUN_EXPORT PFNGLGENTRANSFORMFEEDBACKSNVPROC __glewGenTransformFeedbacksNV; -GLEW_FUN_EXPORT PFNGLISTRANSFORMFEEDBACKNVPROC __glewIsTransformFeedbackNV; -GLEW_FUN_EXPORT PFNGLPAUSETRANSFORMFEEDBACKNVPROC __glewPauseTransformFeedbackNV; -GLEW_FUN_EXPORT PFNGLRESUMETRANSFORMFEEDBACKNVPROC __glewResumeTransformFeedbackNV; - -GLEW_FUN_EXPORT PFNGLVDPAUFININVPROC __glewVDPAUFiniNV; -GLEW_FUN_EXPORT PFNGLVDPAUGETSURFACEIVNVPROC __glewVDPAUGetSurfaceivNV; -GLEW_FUN_EXPORT PFNGLVDPAUINITNVPROC __glewVDPAUInitNV; -GLEW_FUN_EXPORT PFNGLVDPAUISSURFACENVPROC __glewVDPAUIsSurfaceNV; -GLEW_FUN_EXPORT PFNGLVDPAUMAPSURFACESNVPROC __glewVDPAUMapSurfacesNV; -GLEW_FUN_EXPORT PFNGLVDPAUREGISTEROUTPUTSURFACENVPROC __glewVDPAURegisterOutputSurfaceNV; -GLEW_FUN_EXPORT PFNGLVDPAUREGISTERVIDEOSURFACENVPROC __glewVDPAURegisterVideoSurfaceNV; -GLEW_FUN_EXPORT PFNGLVDPAUSURFACEACCESSNVPROC __glewVDPAUSurfaceAccessNV; -GLEW_FUN_EXPORT PFNGLVDPAUUNMAPSURFACESNVPROC __glewVDPAUUnmapSurfacesNV; -GLEW_FUN_EXPORT PFNGLVDPAUUNREGISTERSURFACENVPROC __glewVDPAUUnregisterSurfaceNV; - -GLEW_FUN_EXPORT PFNGLFLUSHVERTEXARRAYRANGENVPROC __glewFlushVertexArrayRangeNV; -GLEW_FUN_EXPORT PFNGLVERTEXARRAYRANGENVPROC __glewVertexArrayRangeNV; - -GLEW_FUN_EXPORT PFNGLGETVERTEXATTRIBLI64VNVPROC __glewGetVertexAttribLi64vNV; -GLEW_FUN_EXPORT PFNGLGETVERTEXATTRIBLUI64VNVPROC __glewGetVertexAttribLui64vNV; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIBL1I64NVPROC __glewVertexAttribL1i64NV; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIBL1I64VNVPROC __glewVertexAttribL1i64vNV; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIBL1UI64NVPROC __glewVertexAttribL1ui64NV; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIBL1UI64VNVPROC __glewVertexAttribL1ui64vNV; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIBL2I64NVPROC __glewVertexAttribL2i64NV; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIBL2I64VNVPROC __glewVertexAttribL2i64vNV; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIBL2UI64NVPROC __glewVertexAttribL2ui64NV; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIBL2UI64VNVPROC __glewVertexAttribL2ui64vNV; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIBL3I64NVPROC __glewVertexAttribL3i64NV; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIBL3I64VNVPROC __glewVertexAttribL3i64vNV; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIBL3UI64NVPROC __glewVertexAttribL3ui64NV; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIBL3UI64VNVPROC __glewVertexAttribL3ui64vNV; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIBL4I64NVPROC __glewVertexAttribL4i64NV; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIBL4I64VNVPROC __glewVertexAttribL4i64vNV; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIBL4UI64NVPROC __glewVertexAttribL4ui64NV; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIBL4UI64VNVPROC __glewVertexAttribL4ui64vNV; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIBLFORMATNVPROC __glewVertexAttribLFormatNV; - -GLEW_FUN_EXPORT PFNGLBUFFERADDRESSRANGENVPROC __glewBufferAddressRangeNV; -GLEW_FUN_EXPORT PFNGLCOLORFORMATNVPROC __glewColorFormatNV; -GLEW_FUN_EXPORT PFNGLEDGEFLAGFORMATNVPROC __glewEdgeFlagFormatNV; -GLEW_FUN_EXPORT PFNGLFOGCOORDFORMATNVPROC __glewFogCoordFormatNV; -GLEW_FUN_EXPORT PFNGLGETINTEGERUI64I_VNVPROC __glewGetIntegerui64i_vNV; -GLEW_FUN_EXPORT PFNGLINDEXFORMATNVPROC __glewIndexFormatNV; -GLEW_FUN_EXPORT PFNGLNORMALFORMATNVPROC __glewNormalFormatNV; -GLEW_FUN_EXPORT PFNGLSECONDARYCOLORFORMATNVPROC __glewSecondaryColorFormatNV; -GLEW_FUN_EXPORT PFNGLTEXCOORDFORMATNVPROC __glewTexCoordFormatNV; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIBFORMATNVPROC __glewVertexAttribFormatNV; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIBIFORMATNVPROC __glewVertexAttribIFormatNV; -GLEW_FUN_EXPORT PFNGLVERTEXFORMATNVPROC __glewVertexFormatNV; - -GLEW_FUN_EXPORT PFNGLAREPROGRAMSRESIDENTNVPROC __glewAreProgramsResidentNV; -GLEW_FUN_EXPORT PFNGLBINDPROGRAMNVPROC __glewBindProgramNV; -GLEW_FUN_EXPORT PFNGLDELETEPROGRAMSNVPROC __glewDeleteProgramsNV; -GLEW_FUN_EXPORT PFNGLEXECUTEPROGRAMNVPROC __glewExecuteProgramNV; -GLEW_FUN_EXPORT PFNGLGENPROGRAMSNVPROC __glewGenProgramsNV; -GLEW_FUN_EXPORT PFNGLGETPROGRAMPARAMETERDVNVPROC __glewGetProgramParameterdvNV; -GLEW_FUN_EXPORT PFNGLGETPROGRAMPARAMETERFVNVPROC __glewGetProgramParameterfvNV; -GLEW_FUN_EXPORT PFNGLGETPROGRAMSTRINGNVPROC __glewGetProgramStringNV; -GLEW_FUN_EXPORT PFNGLGETPROGRAMIVNVPROC __glewGetProgramivNV; -GLEW_FUN_EXPORT PFNGLGETTRACKMATRIXIVNVPROC __glewGetTrackMatrixivNV; -GLEW_FUN_EXPORT PFNGLGETVERTEXATTRIBPOINTERVNVPROC __glewGetVertexAttribPointervNV; -GLEW_FUN_EXPORT PFNGLGETVERTEXATTRIBDVNVPROC __glewGetVertexAttribdvNV; -GLEW_FUN_EXPORT PFNGLGETVERTEXATTRIBFVNVPROC __glewGetVertexAttribfvNV; -GLEW_FUN_EXPORT PFNGLGETVERTEXATTRIBIVNVPROC __glewGetVertexAttribivNV; -GLEW_FUN_EXPORT PFNGLISPROGRAMNVPROC __glewIsProgramNV; -GLEW_FUN_EXPORT PFNGLLOADPROGRAMNVPROC __glewLoadProgramNV; -GLEW_FUN_EXPORT PFNGLPROGRAMPARAMETER4DNVPROC __glewProgramParameter4dNV; -GLEW_FUN_EXPORT PFNGLPROGRAMPARAMETER4DVNVPROC __glewProgramParameter4dvNV; -GLEW_FUN_EXPORT PFNGLPROGRAMPARAMETER4FNVPROC __glewProgramParameter4fNV; -GLEW_FUN_EXPORT PFNGLPROGRAMPARAMETER4FVNVPROC __glewProgramParameter4fvNV; -GLEW_FUN_EXPORT PFNGLPROGRAMPARAMETERS4DVNVPROC __glewProgramParameters4dvNV; -GLEW_FUN_EXPORT PFNGLPROGRAMPARAMETERS4FVNVPROC __glewProgramParameters4fvNV; -GLEW_FUN_EXPORT PFNGLREQUESTRESIDENTPROGRAMSNVPROC __glewRequestResidentProgramsNV; -GLEW_FUN_EXPORT PFNGLTRACKMATRIXNVPROC __glewTrackMatrixNV; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIB1DNVPROC __glewVertexAttrib1dNV; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIB1DVNVPROC __glewVertexAttrib1dvNV; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIB1FNVPROC __glewVertexAttrib1fNV; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIB1FVNVPROC __glewVertexAttrib1fvNV; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIB1SNVPROC __glewVertexAttrib1sNV; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIB1SVNVPROC __glewVertexAttrib1svNV; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIB2DNVPROC __glewVertexAttrib2dNV; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIB2DVNVPROC __glewVertexAttrib2dvNV; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIB2FNVPROC __glewVertexAttrib2fNV; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIB2FVNVPROC __glewVertexAttrib2fvNV; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIB2SNVPROC __glewVertexAttrib2sNV; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIB2SVNVPROC __glewVertexAttrib2svNV; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIB3DNVPROC __glewVertexAttrib3dNV; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIB3DVNVPROC __glewVertexAttrib3dvNV; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIB3FNVPROC __glewVertexAttrib3fNV; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIB3FVNVPROC __glewVertexAttrib3fvNV; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIB3SNVPROC __glewVertexAttrib3sNV; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIB3SVNVPROC __glewVertexAttrib3svNV; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIB4DNVPROC __glewVertexAttrib4dNV; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIB4DVNVPROC __glewVertexAttrib4dvNV; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIB4FNVPROC __glewVertexAttrib4fNV; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIB4FVNVPROC __glewVertexAttrib4fvNV; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIB4SNVPROC __glewVertexAttrib4sNV; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIB4SVNVPROC __glewVertexAttrib4svNV; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIB4UBNVPROC __glewVertexAttrib4ubNV; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIB4UBVNVPROC __glewVertexAttrib4ubvNV; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIBPOINTERNVPROC __glewVertexAttribPointerNV; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIBS1DVNVPROC __glewVertexAttribs1dvNV; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIBS1FVNVPROC __glewVertexAttribs1fvNV; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIBS1SVNVPROC __glewVertexAttribs1svNV; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIBS2DVNVPROC __glewVertexAttribs2dvNV; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIBS2FVNVPROC __glewVertexAttribs2fvNV; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIBS2SVNVPROC __glewVertexAttribs2svNV; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIBS3DVNVPROC __glewVertexAttribs3dvNV; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIBS3FVNVPROC __glewVertexAttribs3fvNV; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIBS3SVNVPROC __glewVertexAttribs3svNV; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIBS4DVNVPROC __glewVertexAttribs4dvNV; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIBS4FVNVPROC __glewVertexAttribs4fvNV; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIBS4SVNVPROC __glewVertexAttribs4svNV; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIBS4UBVNVPROC __glewVertexAttribs4ubvNV; - -GLEW_FUN_EXPORT PFNGLBEGINVIDEOCAPTURENVPROC __glewBeginVideoCaptureNV; -GLEW_FUN_EXPORT PFNGLBINDVIDEOCAPTURESTREAMBUFFERNVPROC __glewBindVideoCaptureStreamBufferNV; -GLEW_FUN_EXPORT PFNGLBINDVIDEOCAPTURESTREAMTEXTURENVPROC __glewBindVideoCaptureStreamTextureNV; -GLEW_FUN_EXPORT PFNGLENDVIDEOCAPTURENVPROC __glewEndVideoCaptureNV; -GLEW_FUN_EXPORT PFNGLGETVIDEOCAPTURESTREAMDVNVPROC __glewGetVideoCaptureStreamdvNV; -GLEW_FUN_EXPORT PFNGLGETVIDEOCAPTURESTREAMFVNVPROC __glewGetVideoCaptureStreamfvNV; -GLEW_FUN_EXPORT PFNGLGETVIDEOCAPTURESTREAMIVNVPROC __glewGetVideoCaptureStreamivNV; -GLEW_FUN_EXPORT PFNGLGETVIDEOCAPTUREIVNVPROC __glewGetVideoCaptureivNV; -GLEW_FUN_EXPORT PFNGLVIDEOCAPTURENVPROC __glewVideoCaptureNV; -GLEW_FUN_EXPORT PFNGLVIDEOCAPTURESTREAMPARAMETERDVNVPROC __glewVideoCaptureStreamParameterdvNV; -GLEW_FUN_EXPORT PFNGLVIDEOCAPTURESTREAMPARAMETERFVNVPROC __glewVideoCaptureStreamParameterfvNV; -GLEW_FUN_EXPORT PFNGLVIDEOCAPTURESTREAMPARAMETERIVNVPROC __glewVideoCaptureStreamParameterivNV; - -GLEW_FUN_EXPORT PFNGLVIEWPORTSWIZZLENVPROC __glewViewportSwizzleNV; - -GLEW_FUN_EXPORT PFNGLCLEARDEPTHFOESPROC __glewClearDepthfOES; -GLEW_FUN_EXPORT PFNGLCLIPPLANEFOESPROC __glewClipPlanefOES; -GLEW_FUN_EXPORT PFNGLDEPTHRANGEFOESPROC __glewDepthRangefOES; -GLEW_FUN_EXPORT PFNGLFRUSTUMFOESPROC __glewFrustumfOES; -GLEW_FUN_EXPORT PFNGLGETCLIPPLANEFOESPROC __glewGetClipPlanefOES; -GLEW_FUN_EXPORT PFNGLORTHOFOESPROC __glewOrthofOES; - -GLEW_FUN_EXPORT PFNGLFRAMEBUFFERTEXTUREMULTIVIEWOVRPROC __glewFramebufferTextureMultiviewOVR; - -GLEW_FUN_EXPORT PFNGLALPHAFUNCXPROC __glewAlphaFuncx; -GLEW_FUN_EXPORT PFNGLCLEARCOLORXPROC __glewClearColorx; -GLEW_FUN_EXPORT PFNGLCLEARDEPTHXPROC __glewClearDepthx; -GLEW_FUN_EXPORT PFNGLCOLOR4XPROC __glewColor4x; -GLEW_FUN_EXPORT PFNGLDEPTHRANGEXPROC __glewDepthRangex; -GLEW_FUN_EXPORT PFNGLFOGXPROC __glewFogx; -GLEW_FUN_EXPORT PFNGLFOGXVPROC __glewFogxv; -GLEW_FUN_EXPORT PFNGLFRUSTUMFPROC __glewFrustumf; -GLEW_FUN_EXPORT PFNGLFRUSTUMXPROC __glewFrustumx; -GLEW_FUN_EXPORT PFNGLLIGHTMODELXPROC __glewLightModelx; -GLEW_FUN_EXPORT PFNGLLIGHTMODELXVPROC __glewLightModelxv; -GLEW_FUN_EXPORT PFNGLLIGHTXPROC __glewLightx; -GLEW_FUN_EXPORT PFNGLLIGHTXVPROC __glewLightxv; -GLEW_FUN_EXPORT PFNGLLINEWIDTHXPROC __glewLineWidthx; -GLEW_FUN_EXPORT PFNGLLOADMATRIXXPROC __glewLoadMatrixx; -GLEW_FUN_EXPORT PFNGLMATERIALXPROC __glewMaterialx; -GLEW_FUN_EXPORT PFNGLMATERIALXVPROC __glewMaterialxv; -GLEW_FUN_EXPORT PFNGLMULTMATRIXXPROC __glewMultMatrixx; -GLEW_FUN_EXPORT PFNGLMULTITEXCOORD4XPROC __glewMultiTexCoord4x; -GLEW_FUN_EXPORT PFNGLNORMAL3XPROC __glewNormal3x; -GLEW_FUN_EXPORT PFNGLORTHOFPROC __glewOrthof; -GLEW_FUN_EXPORT PFNGLORTHOXPROC __glewOrthox; -GLEW_FUN_EXPORT PFNGLPOINTSIZEXPROC __glewPointSizex; -GLEW_FUN_EXPORT PFNGLPOLYGONOFFSETXPROC __glewPolygonOffsetx; -GLEW_FUN_EXPORT PFNGLROTATEXPROC __glewRotatex; -GLEW_FUN_EXPORT PFNGLSAMPLECOVERAGEXPROC __glewSampleCoveragex; -GLEW_FUN_EXPORT PFNGLSCALEXPROC __glewScalex; -GLEW_FUN_EXPORT PFNGLTEXENVXPROC __glewTexEnvx; -GLEW_FUN_EXPORT PFNGLTEXENVXVPROC __glewTexEnvxv; -GLEW_FUN_EXPORT PFNGLTEXPARAMETERXPROC __glewTexParameterx; -GLEW_FUN_EXPORT PFNGLTRANSLATEXPROC __glewTranslatex; - -GLEW_FUN_EXPORT PFNGLCLIPPLANEFPROC __glewClipPlanef; -GLEW_FUN_EXPORT PFNGLCLIPPLANEXPROC __glewClipPlanex; -GLEW_FUN_EXPORT PFNGLGETCLIPPLANEFPROC __glewGetClipPlanef; -GLEW_FUN_EXPORT PFNGLGETCLIPPLANEXPROC __glewGetClipPlanex; -GLEW_FUN_EXPORT PFNGLGETFIXEDVPROC __glewGetFixedv; -GLEW_FUN_EXPORT PFNGLGETLIGHTXVPROC __glewGetLightxv; -GLEW_FUN_EXPORT PFNGLGETMATERIALXVPROC __glewGetMaterialxv; -GLEW_FUN_EXPORT PFNGLGETTEXENVXVPROC __glewGetTexEnvxv; -GLEW_FUN_EXPORT PFNGLGETTEXPARAMETERXVPROC __glewGetTexParameterxv; -GLEW_FUN_EXPORT PFNGLPOINTPARAMETERXPROC __glewPointParameterx; -GLEW_FUN_EXPORT PFNGLPOINTPARAMETERXVPROC __glewPointParameterxv; -GLEW_FUN_EXPORT PFNGLPOINTSIZEPOINTEROESPROC __glewPointSizePointerOES; -GLEW_FUN_EXPORT PFNGLTEXPARAMETERXVPROC __glewTexParameterxv; - -GLEW_FUN_EXPORT PFNGLERRORSTRINGREGALPROC __glewErrorStringREGAL; - -GLEW_FUN_EXPORT PFNGLGETEXTENSIONREGALPROC __glewGetExtensionREGAL; -GLEW_FUN_EXPORT PFNGLISSUPPORTEDREGALPROC __glewIsSupportedREGAL; - -GLEW_FUN_EXPORT PFNGLLOGMESSAGECALLBACKREGALPROC __glewLogMessageCallbackREGAL; - -GLEW_FUN_EXPORT PFNGLGETPROCADDRESSREGALPROC __glewGetProcAddressREGAL; - -GLEW_FUN_EXPORT PFNGLDETAILTEXFUNCSGISPROC __glewDetailTexFuncSGIS; -GLEW_FUN_EXPORT PFNGLGETDETAILTEXFUNCSGISPROC __glewGetDetailTexFuncSGIS; - -GLEW_FUN_EXPORT PFNGLFOGFUNCSGISPROC __glewFogFuncSGIS; -GLEW_FUN_EXPORT PFNGLGETFOGFUNCSGISPROC __glewGetFogFuncSGIS; - -GLEW_FUN_EXPORT PFNGLSAMPLEMASKSGISPROC __glewSampleMaskSGIS; -GLEW_FUN_EXPORT PFNGLSAMPLEPATTERNSGISPROC __glewSamplePatternSGIS; - -GLEW_FUN_EXPORT PFNGLGETSHARPENTEXFUNCSGISPROC __glewGetSharpenTexFuncSGIS; -GLEW_FUN_EXPORT PFNGLSHARPENTEXFUNCSGISPROC __glewSharpenTexFuncSGIS; - -GLEW_FUN_EXPORT PFNGLTEXIMAGE4DSGISPROC __glewTexImage4DSGIS; -GLEW_FUN_EXPORT PFNGLTEXSUBIMAGE4DSGISPROC __glewTexSubImage4DSGIS; - -GLEW_FUN_EXPORT PFNGLGETTEXFILTERFUNCSGISPROC __glewGetTexFilterFuncSGIS; -GLEW_FUN_EXPORT PFNGLTEXFILTERFUNCSGISPROC __glewTexFilterFuncSGIS; - -GLEW_FUN_EXPORT PFNGLASYNCMARKERSGIXPROC __glewAsyncMarkerSGIX; -GLEW_FUN_EXPORT PFNGLDELETEASYNCMARKERSSGIXPROC __glewDeleteAsyncMarkersSGIX; -GLEW_FUN_EXPORT PFNGLFINISHASYNCSGIXPROC __glewFinishAsyncSGIX; -GLEW_FUN_EXPORT PFNGLGENASYNCMARKERSSGIXPROC __glewGenAsyncMarkersSGIX; -GLEW_FUN_EXPORT PFNGLISASYNCMARKERSGIXPROC __glewIsAsyncMarkerSGIX; -GLEW_FUN_EXPORT PFNGLPOLLASYNCSGIXPROC __glewPollAsyncSGIX; - -GLEW_FUN_EXPORT PFNGLFLUSHRASTERSGIXPROC __glewFlushRasterSGIX; - -GLEW_FUN_EXPORT PFNGLTEXTUREFOGSGIXPROC __glewTextureFogSGIX; - -GLEW_FUN_EXPORT PFNGLFRAGMENTCOLORMATERIALSGIXPROC __glewFragmentColorMaterialSGIX; -GLEW_FUN_EXPORT PFNGLFRAGMENTLIGHTMODELFSGIXPROC __glewFragmentLightModelfSGIX; -GLEW_FUN_EXPORT PFNGLFRAGMENTLIGHTMODELFVSGIXPROC __glewFragmentLightModelfvSGIX; -GLEW_FUN_EXPORT PFNGLFRAGMENTLIGHTMODELISGIXPROC __glewFragmentLightModeliSGIX; -GLEW_FUN_EXPORT PFNGLFRAGMENTLIGHTMODELIVSGIXPROC __glewFragmentLightModelivSGIX; -GLEW_FUN_EXPORT PFNGLFRAGMENTLIGHTFSGIXPROC __glewFragmentLightfSGIX; -GLEW_FUN_EXPORT PFNGLFRAGMENTLIGHTFVSGIXPROC __glewFragmentLightfvSGIX; -GLEW_FUN_EXPORT PFNGLFRAGMENTLIGHTISGIXPROC __glewFragmentLightiSGIX; -GLEW_FUN_EXPORT PFNGLFRAGMENTLIGHTIVSGIXPROC __glewFragmentLightivSGIX; -GLEW_FUN_EXPORT PFNGLFRAGMENTMATERIALFSGIXPROC __glewFragmentMaterialfSGIX; -GLEW_FUN_EXPORT PFNGLFRAGMENTMATERIALFVSGIXPROC __glewFragmentMaterialfvSGIX; -GLEW_FUN_EXPORT PFNGLFRAGMENTMATERIALISGIXPROC __glewFragmentMaterialiSGIX; -GLEW_FUN_EXPORT PFNGLFRAGMENTMATERIALIVSGIXPROC __glewFragmentMaterialivSGIX; -GLEW_FUN_EXPORT PFNGLGETFRAGMENTLIGHTFVSGIXPROC __glewGetFragmentLightfvSGIX; -GLEW_FUN_EXPORT PFNGLGETFRAGMENTLIGHTIVSGIXPROC __glewGetFragmentLightivSGIX; -GLEW_FUN_EXPORT PFNGLGETFRAGMENTMATERIALFVSGIXPROC __glewGetFragmentMaterialfvSGIX; -GLEW_FUN_EXPORT PFNGLGETFRAGMENTMATERIALIVSGIXPROC __glewGetFragmentMaterialivSGIX; - -GLEW_FUN_EXPORT PFNGLFRAMEZOOMSGIXPROC __glewFrameZoomSGIX; - -GLEW_FUN_EXPORT PFNGLPIXELTEXGENSGIXPROC __glewPixelTexGenSGIX; - -GLEW_FUN_EXPORT PFNGLREFERENCEPLANESGIXPROC __glewReferencePlaneSGIX; - -GLEW_FUN_EXPORT PFNGLSPRITEPARAMETERFSGIXPROC __glewSpriteParameterfSGIX; -GLEW_FUN_EXPORT PFNGLSPRITEPARAMETERFVSGIXPROC __glewSpriteParameterfvSGIX; -GLEW_FUN_EXPORT PFNGLSPRITEPARAMETERISGIXPROC __glewSpriteParameteriSGIX; -GLEW_FUN_EXPORT PFNGLSPRITEPARAMETERIVSGIXPROC __glewSpriteParameterivSGIX; - -GLEW_FUN_EXPORT PFNGLTAGSAMPLEBUFFERSGIXPROC __glewTagSampleBufferSGIX; - -GLEW_FUN_EXPORT PFNGLCOLORTABLEPARAMETERFVSGIPROC __glewColorTableParameterfvSGI; -GLEW_FUN_EXPORT PFNGLCOLORTABLEPARAMETERIVSGIPROC __glewColorTableParameterivSGI; -GLEW_FUN_EXPORT PFNGLCOLORTABLESGIPROC __glewColorTableSGI; -GLEW_FUN_EXPORT PFNGLCOPYCOLORTABLESGIPROC __glewCopyColorTableSGI; -GLEW_FUN_EXPORT PFNGLGETCOLORTABLEPARAMETERFVSGIPROC __glewGetColorTableParameterfvSGI; -GLEW_FUN_EXPORT PFNGLGETCOLORTABLEPARAMETERIVSGIPROC __glewGetColorTableParameterivSGI; -GLEW_FUN_EXPORT PFNGLGETCOLORTABLESGIPROC __glewGetColorTableSGI; - -GLEW_FUN_EXPORT PFNGLFINISHTEXTURESUNXPROC __glewFinishTextureSUNX; - -GLEW_FUN_EXPORT PFNGLGLOBALALPHAFACTORBSUNPROC __glewGlobalAlphaFactorbSUN; -GLEW_FUN_EXPORT PFNGLGLOBALALPHAFACTORDSUNPROC __glewGlobalAlphaFactordSUN; -GLEW_FUN_EXPORT PFNGLGLOBALALPHAFACTORFSUNPROC __glewGlobalAlphaFactorfSUN; -GLEW_FUN_EXPORT PFNGLGLOBALALPHAFACTORISUNPROC __glewGlobalAlphaFactoriSUN; -GLEW_FUN_EXPORT PFNGLGLOBALALPHAFACTORSSUNPROC __glewGlobalAlphaFactorsSUN; -GLEW_FUN_EXPORT PFNGLGLOBALALPHAFACTORUBSUNPROC __glewGlobalAlphaFactorubSUN; -GLEW_FUN_EXPORT PFNGLGLOBALALPHAFACTORUISUNPROC __glewGlobalAlphaFactoruiSUN; -GLEW_FUN_EXPORT PFNGLGLOBALALPHAFACTORUSSUNPROC __glewGlobalAlphaFactorusSUN; - -GLEW_FUN_EXPORT PFNGLREADVIDEOPIXELSSUNPROC __glewReadVideoPixelsSUN; - -GLEW_FUN_EXPORT PFNGLREPLACEMENTCODEPOINTERSUNPROC __glewReplacementCodePointerSUN; -GLEW_FUN_EXPORT PFNGLREPLACEMENTCODEUBSUNPROC __glewReplacementCodeubSUN; -GLEW_FUN_EXPORT PFNGLREPLACEMENTCODEUBVSUNPROC __glewReplacementCodeubvSUN; -GLEW_FUN_EXPORT PFNGLREPLACEMENTCODEUISUNPROC __glewReplacementCodeuiSUN; -GLEW_FUN_EXPORT PFNGLREPLACEMENTCODEUIVSUNPROC __glewReplacementCodeuivSUN; -GLEW_FUN_EXPORT PFNGLREPLACEMENTCODEUSSUNPROC __glewReplacementCodeusSUN; -GLEW_FUN_EXPORT PFNGLREPLACEMENTCODEUSVSUNPROC __glewReplacementCodeusvSUN; - -GLEW_FUN_EXPORT PFNGLCOLOR3FVERTEX3FSUNPROC __glewColor3fVertex3fSUN; -GLEW_FUN_EXPORT PFNGLCOLOR3FVERTEX3FVSUNPROC __glewColor3fVertex3fvSUN; -GLEW_FUN_EXPORT PFNGLCOLOR4FNORMAL3FVERTEX3FSUNPROC __glewColor4fNormal3fVertex3fSUN; -GLEW_FUN_EXPORT PFNGLCOLOR4FNORMAL3FVERTEX3FVSUNPROC __glewColor4fNormal3fVertex3fvSUN; -GLEW_FUN_EXPORT PFNGLCOLOR4UBVERTEX2FSUNPROC __glewColor4ubVertex2fSUN; -GLEW_FUN_EXPORT PFNGLCOLOR4UBVERTEX2FVSUNPROC __glewColor4ubVertex2fvSUN; -GLEW_FUN_EXPORT PFNGLCOLOR4UBVERTEX3FSUNPROC __glewColor4ubVertex3fSUN; -GLEW_FUN_EXPORT PFNGLCOLOR4UBVERTEX3FVSUNPROC __glewColor4ubVertex3fvSUN; -GLEW_FUN_EXPORT PFNGLNORMAL3FVERTEX3FSUNPROC __glewNormal3fVertex3fSUN; -GLEW_FUN_EXPORT PFNGLNORMAL3FVERTEX3FVSUNPROC __glewNormal3fVertex3fvSUN; -GLEW_FUN_EXPORT PFNGLREPLACEMENTCODEUICOLOR3FVERTEX3FSUNPROC __glewReplacementCodeuiColor3fVertex3fSUN; -GLEW_FUN_EXPORT PFNGLREPLACEMENTCODEUICOLOR3FVERTEX3FVSUNPROC __glewReplacementCodeuiColor3fVertex3fvSUN; -GLEW_FUN_EXPORT PFNGLREPLACEMENTCODEUICOLOR4FNORMAL3FVERTEX3FSUNPROC __glewReplacementCodeuiColor4fNormal3fVertex3fSUN; -GLEW_FUN_EXPORT PFNGLREPLACEMENTCODEUICOLOR4FNORMAL3FVERTEX3FVSUNPROC __glewReplacementCodeuiColor4fNormal3fVertex3fvSUN; -GLEW_FUN_EXPORT PFNGLREPLACEMENTCODEUICOLOR4UBVERTEX3FSUNPROC __glewReplacementCodeuiColor4ubVertex3fSUN; -GLEW_FUN_EXPORT PFNGLREPLACEMENTCODEUICOLOR4UBVERTEX3FVSUNPROC __glewReplacementCodeuiColor4ubVertex3fvSUN; -GLEW_FUN_EXPORT PFNGLREPLACEMENTCODEUINORMAL3FVERTEX3FSUNPROC __glewReplacementCodeuiNormal3fVertex3fSUN; -GLEW_FUN_EXPORT PFNGLREPLACEMENTCODEUINORMAL3FVERTEX3FVSUNPROC __glewReplacementCodeuiNormal3fVertex3fvSUN; -GLEW_FUN_EXPORT PFNGLREPLACEMENTCODEUITEXCOORD2FCOLOR4FNORMAL3FVERTEX3FSUNPROC __glewReplacementCodeuiTexCoord2fColor4fNormal3fVertex3fSUN; -GLEW_FUN_EXPORT PFNGLREPLACEMENTCODEUITEXCOORD2FCOLOR4FNORMAL3FVERTEX3FVSUNPROC __glewReplacementCodeuiTexCoord2fColor4fNormal3fVertex3fvSUN; -GLEW_FUN_EXPORT PFNGLREPLACEMENTCODEUITEXCOORD2FNORMAL3FVERTEX3FSUNPROC __glewReplacementCodeuiTexCoord2fNormal3fVertex3fSUN; -GLEW_FUN_EXPORT PFNGLREPLACEMENTCODEUITEXCOORD2FNORMAL3FVERTEX3FVSUNPROC __glewReplacementCodeuiTexCoord2fNormal3fVertex3fvSUN; -GLEW_FUN_EXPORT PFNGLREPLACEMENTCODEUITEXCOORD2FVERTEX3FSUNPROC __glewReplacementCodeuiTexCoord2fVertex3fSUN; -GLEW_FUN_EXPORT PFNGLREPLACEMENTCODEUITEXCOORD2FVERTEX3FVSUNPROC __glewReplacementCodeuiTexCoord2fVertex3fvSUN; -GLEW_FUN_EXPORT PFNGLREPLACEMENTCODEUIVERTEX3FSUNPROC __glewReplacementCodeuiVertex3fSUN; -GLEW_FUN_EXPORT PFNGLREPLACEMENTCODEUIVERTEX3FVSUNPROC __glewReplacementCodeuiVertex3fvSUN; -GLEW_FUN_EXPORT PFNGLTEXCOORD2FCOLOR3FVERTEX3FSUNPROC __glewTexCoord2fColor3fVertex3fSUN; -GLEW_FUN_EXPORT PFNGLTEXCOORD2FCOLOR3FVERTEX3FVSUNPROC __glewTexCoord2fColor3fVertex3fvSUN; -GLEW_FUN_EXPORT PFNGLTEXCOORD2FCOLOR4FNORMAL3FVERTEX3FSUNPROC __glewTexCoord2fColor4fNormal3fVertex3fSUN; -GLEW_FUN_EXPORT PFNGLTEXCOORD2FCOLOR4FNORMAL3FVERTEX3FVSUNPROC __glewTexCoord2fColor4fNormal3fVertex3fvSUN; -GLEW_FUN_EXPORT PFNGLTEXCOORD2FCOLOR4UBVERTEX3FSUNPROC __glewTexCoord2fColor4ubVertex3fSUN; -GLEW_FUN_EXPORT PFNGLTEXCOORD2FCOLOR4UBVERTEX3FVSUNPROC __glewTexCoord2fColor4ubVertex3fvSUN; -GLEW_FUN_EXPORT PFNGLTEXCOORD2FNORMAL3FVERTEX3FSUNPROC __glewTexCoord2fNormal3fVertex3fSUN; -GLEW_FUN_EXPORT PFNGLTEXCOORD2FNORMAL3FVERTEX3FVSUNPROC __glewTexCoord2fNormal3fVertex3fvSUN; -GLEW_FUN_EXPORT PFNGLTEXCOORD2FVERTEX3FSUNPROC __glewTexCoord2fVertex3fSUN; -GLEW_FUN_EXPORT PFNGLTEXCOORD2FVERTEX3FVSUNPROC __glewTexCoord2fVertex3fvSUN; -GLEW_FUN_EXPORT PFNGLTEXCOORD4FCOLOR4FNORMAL3FVERTEX4FSUNPROC __glewTexCoord4fColor4fNormal3fVertex4fSUN; -GLEW_FUN_EXPORT PFNGLTEXCOORD4FCOLOR4FNORMAL3FVERTEX4FVSUNPROC __glewTexCoord4fColor4fNormal3fVertex4fvSUN; -GLEW_FUN_EXPORT PFNGLTEXCOORD4FVERTEX4FSUNPROC __glewTexCoord4fVertex4fSUN; -GLEW_FUN_EXPORT PFNGLTEXCOORD4FVERTEX4FVSUNPROC __glewTexCoord4fVertex4fvSUN; - -GLEW_FUN_EXPORT PFNGLADDSWAPHINTRECTWINPROC __glewAddSwapHintRectWIN; -GLEW_VAR_EXPORT GLboolean __GLEW_VERSION_1_1; -GLEW_VAR_EXPORT GLboolean __GLEW_VERSION_1_2; -GLEW_VAR_EXPORT GLboolean __GLEW_VERSION_1_2_1; -GLEW_VAR_EXPORT GLboolean __GLEW_VERSION_1_3; -GLEW_VAR_EXPORT GLboolean __GLEW_VERSION_1_4; -GLEW_VAR_EXPORT GLboolean __GLEW_VERSION_1_5; -GLEW_VAR_EXPORT GLboolean __GLEW_VERSION_2_0; -GLEW_VAR_EXPORT GLboolean __GLEW_VERSION_2_1; -GLEW_VAR_EXPORT GLboolean __GLEW_VERSION_3_0; -GLEW_VAR_EXPORT GLboolean __GLEW_VERSION_3_1; -GLEW_VAR_EXPORT GLboolean __GLEW_VERSION_3_2; -GLEW_VAR_EXPORT GLboolean __GLEW_VERSION_3_3; -GLEW_VAR_EXPORT GLboolean __GLEW_VERSION_4_0; -GLEW_VAR_EXPORT GLboolean __GLEW_VERSION_4_1; -GLEW_VAR_EXPORT GLboolean __GLEW_VERSION_4_2; -GLEW_VAR_EXPORT GLboolean __GLEW_VERSION_4_3; -GLEW_VAR_EXPORT GLboolean __GLEW_VERSION_4_4; -GLEW_VAR_EXPORT GLboolean __GLEW_VERSION_4_5; -GLEW_VAR_EXPORT GLboolean __GLEW_3DFX_multisample; -GLEW_VAR_EXPORT GLboolean __GLEW_3DFX_tbuffer; -GLEW_VAR_EXPORT GLboolean __GLEW_3DFX_texture_compression_FXT1; -GLEW_VAR_EXPORT GLboolean __GLEW_AMD_blend_minmax_factor; -GLEW_VAR_EXPORT GLboolean __GLEW_AMD_conservative_depth; -GLEW_VAR_EXPORT GLboolean __GLEW_AMD_debug_output; -GLEW_VAR_EXPORT GLboolean __GLEW_AMD_depth_clamp_separate; -GLEW_VAR_EXPORT GLboolean __GLEW_AMD_draw_buffers_blend; -GLEW_VAR_EXPORT GLboolean __GLEW_AMD_gcn_shader; -GLEW_VAR_EXPORT GLboolean __GLEW_AMD_gpu_shader_int64; -GLEW_VAR_EXPORT GLboolean __GLEW_AMD_interleaved_elements; -GLEW_VAR_EXPORT GLboolean __GLEW_AMD_multi_draw_indirect; -GLEW_VAR_EXPORT GLboolean __GLEW_AMD_name_gen_delete; -GLEW_VAR_EXPORT GLboolean __GLEW_AMD_occlusion_query_event; -GLEW_VAR_EXPORT GLboolean __GLEW_AMD_performance_monitor; -GLEW_VAR_EXPORT GLboolean __GLEW_AMD_pinned_memory; -GLEW_VAR_EXPORT GLboolean __GLEW_AMD_query_buffer_object; -GLEW_VAR_EXPORT GLboolean __GLEW_AMD_sample_positions; -GLEW_VAR_EXPORT GLboolean __GLEW_AMD_seamless_cubemap_per_texture; -GLEW_VAR_EXPORT GLboolean __GLEW_AMD_shader_atomic_counter_ops; -GLEW_VAR_EXPORT GLboolean __GLEW_AMD_shader_explicit_vertex_parameter; -GLEW_VAR_EXPORT GLboolean __GLEW_AMD_shader_stencil_export; -GLEW_VAR_EXPORT GLboolean __GLEW_AMD_shader_stencil_value_export; -GLEW_VAR_EXPORT GLboolean __GLEW_AMD_shader_trinary_minmax; -GLEW_VAR_EXPORT GLboolean __GLEW_AMD_sparse_texture; -GLEW_VAR_EXPORT GLboolean __GLEW_AMD_stencil_operation_extended; -GLEW_VAR_EXPORT GLboolean __GLEW_AMD_texture_texture4; -GLEW_VAR_EXPORT GLboolean __GLEW_AMD_transform_feedback3_lines_triangles; -GLEW_VAR_EXPORT GLboolean __GLEW_AMD_transform_feedback4; -GLEW_VAR_EXPORT GLboolean __GLEW_AMD_vertex_shader_layer; -GLEW_VAR_EXPORT GLboolean __GLEW_AMD_vertex_shader_tessellator; -GLEW_VAR_EXPORT GLboolean __GLEW_AMD_vertex_shader_viewport_index; -GLEW_VAR_EXPORT GLboolean __GLEW_ANGLE_depth_texture; -GLEW_VAR_EXPORT GLboolean __GLEW_ANGLE_framebuffer_blit; -GLEW_VAR_EXPORT GLboolean __GLEW_ANGLE_framebuffer_multisample; -GLEW_VAR_EXPORT GLboolean __GLEW_ANGLE_instanced_arrays; -GLEW_VAR_EXPORT GLboolean __GLEW_ANGLE_pack_reverse_row_order; -GLEW_VAR_EXPORT GLboolean __GLEW_ANGLE_program_binary; -GLEW_VAR_EXPORT GLboolean __GLEW_ANGLE_texture_compression_dxt1; -GLEW_VAR_EXPORT GLboolean __GLEW_ANGLE_texture_compression_dxt3; -GLEW_VAR_EXPORT GLboolean __GLEW_ANGLE_texture_compression_dxt5; -GLEW_VAR_EXPORT GLboolean __GLEW_ANGLE_texture_usage; -GLEW_VAR_EXPORT GLboolean __GLEW_ANGLE_timer_query; -GLEW_VAR_EXPORT GLboolean __GLEW_ANGLE_translated_shader_source; -GLEW_VAR_EXPORT GLboolean __GLEW_APPLE_aux_depth_stencil; -GLEW_VAR_EXPORT GLboolean __GLEW_APPLE_client_storage; -GLEW_VAR_EXPORT GLboolean __GLEW_APPLE_element_array; -GLEW_VAR_EXPORT GLboolean __GLEW_APPLE_fence; -GLEW_VAR_EXPORT GLboolean __GLEW_APPLE_float_pixels; -GLEW_VAR_EXPORT GLboolean __GLEW_APPLE_flush_buffer_range; -GLEW_VAR_EXPORT GLboolean __GLEW_APPLE_object_purgeable; -GLEW_VAR_EXPORT GLboolean __GLEW_APPLE_pixel_buffer; -GLEW_VAR_EXPORT GLboolean __GLEW_APPLE_rgb_422; -GLEW_VAR_EXPORT GLboolean __GLEW_APPLE_row_bytes; -GLEW_VAR_EXPORT GLboolean __GLEW_APPLE_specular_vector; -GLEW_VAR_EXPORT GLboolean __GLEW_APPLE_texture_range; -GLEW_VAR_EXPORT GLboolean __GLEW_APPLE_transform_hint; -GLEW_VAR_EXPORT GLboolean __GLEW_APPLE_vertex_array_object; -GLEW_VAR_EXPORT GLboolean __GLEW_APPLE_vertex_array_range; -GLEW_VAR_EXPORT GLboolean __GLEW_APPLE_vertex_program_evaluators; -GLEW_VAR_EXPORT GLboolean __GLEW_APPLE_ycbcr_422; -GLEW_VAR_EXPORT GLboolean __GLEW_ARB_ES2_compatibility; -GLEW_VAR_EXPORT GLboolean __GLEW_ARB_ES3_1_compatibility; -GLEW_VAR_EXPORT GLboolean __GLEW_ARB_ES3_2_compatibility; -GLEW_VAR_EXPORT GLboolean __GLEW_ARB_ES3_compatibility; -GLEW_VAR_EXPORT GLboolean __GLEW_ARB_arrays_of_arrays; -GLEW_VAR_EXPORT GLboolean __GLEW_ARB_base_instance; -GLEW_VAR_EXPORT GLboolean __GLEW_ARB_bindless_texture; -GLEW_VAR_EXPORT GLboolean __GLEW_ARB_blend_func_extended; -GLEW_VAR_EXPORT GLboolean __GLEW_ARB_buffer_storage; -GLEW_VAR_EXPORT GLboolean __GLEW_ARB_cl_event; -GLEW_VAR_EXPORT GLboolean __GLEW_ARB_clear_buffer_object; -GLEW_VAR_EXPORT GLboolean __GLEW_ARB_clear_texture; -GLEW_VAR_EXPORT GLboolean __GLEW_ARB_clip_control; -GLEW_VAR_EXPORT GLboolean __GLEW_ARB_color_buffer_float; -GLEW_VAR_EXPORT GLboolean __GLEW_ARB_compatibility; -GLEW_VAR_EXPORT GLboolean __GLEW_ARB_compressed_texture_pixel_storage; -GLEW_VAR_EXPORT GLboolean __GLEW_ARB_compute_shader; -GLEW_VAR_EXPORT GLboolean __GLEW_ARB_compute_variable_group_size; -GLEW_VAR_EXPORT GLboolean __GLEW_ARB_conditional_render_inverted; -GLEW_VAR_EXPORT GLboolean __GLEW_ARB_conservative_depth; -GLEW_VAR_EXPORT GLboolean __GLEW_ARB_copy_buffer; -GLEW_VAR_EXPORT GLboolean __GLEW_ARB_copy_image; -GLEW_VAR_EXPORT GLboolean __GLEW_ARB_cull_distance; -GLEW_VAR_EXPORT GLboolean __GLEW_ARB_debug_output; -GLEW_VAR_EXPORT GLboolean __GLEW_ARB_depth_buffer_float; -GLEW_VAR_EXPORT GLboolean __GLEW_ARB_depth_clamp; -GLEW_VAR_EXPORT GLboolean __GLEW_ARB_depth_texture; -GLEW_VAR_EXPORT GLboolean __GLEW_ARB_derivative_control; -GLEW_VAR_EXPORT GLboolean __GLEW_ARB_direct_state_access; -GLEW_VAR_EXPORT GLboolean __GLEW_ARB_draw_buffers; -GLEW_VAR_EXPORT GLboolean __GLEW_ARB_draw_buffers_blend; -GLEW_VAR_EXPORT GLboolean __GLEW_ARB_draw_elements_base_vertex; -GLEW_VAR_EXPORT GLboolean __GLEW_ARB_draw_indirect; -GLEW_VAR_EXPORT GLboolean __GLEW_ARB_draw_instanced; -GLEW_VAR_EXPORT GLboolean __GLEW_ARB_enhanced_layouts; -GLEW_VAR_EXPORT GLboolean __GLEW_ARB_explicit_attrib_location; -GLEW_VAR_EXPORT GLboolean __GLEW_ARB_explicit_uniform_location; -GLEW_VAR_EXPORT GLboolean __GLEW_ARB_fragment_coord_conventions; -GLEW_VAR_EXPORT GLboolean __GLEW_ARB_fragment_layer_viewport; -GLEW_VAR_EXPORT GLboolean __GLEW_ARB_fragment_program; -GLEW_VAR_EXPORT GLboolean __GLEW_ARB_fragment_program_shadow; -GLEW_VAR_EXPORT GLboolean __GLEW_ARB_fragment_shader; -GLEW_VAR_EXPORT GLboolean __GLEW_ARB_fragment_shader_interlock; -GLEW_VAR_EXPORT GLboolean __GLEW_ARB_framebuffer_no_attachments; -GLEW_VAR_EXPORT GLboolean __GLEW_ARB_framebuffer_object; -GLEW_VAR_EXPORT GLboolean __GLEW_ARB_framebuffer_sRGB; -GLEW_VAR_EXPORT GLboolean __GLEW_ARB_geometry_shader4; -GLEW_VAR_EXPORT GLboolean __GLEW_ARB_get_program_binary; -GLEW_VAR_EXPORT GLboolean __GLEW_ARB_get_texture_sub_image; -GLEW_VAR_EXPORT GLboolean __GLEW_ARB_gl_spirv; -GLEW_VAR_EXPORT GLboolean __GLEW_ARB_gpu_shader5; -GLEW_VAR_EXPORT GLboolean __GLEW_ARB_gpu_shader_fp64; -GLEW_VAR_EXPORT GLboolean __GLEW_ARB_gpu_shader_int64; -GLEW_VAR_EXPORT GLboolean __GLEW_ARB_half_float_pixel; -GLEW_VAR_EXPORT GLboolean __GLEW_ARB_half_float_vertex; -GLEW_VAR_EXPORT GLboolean __GLEW_ARB_imaging; -GLEW_VAR_EXPORT GLboolean __GLEW_ARB_indirect_parameters; -GLEW_VAR_EXPORT GLboolean __GLEW_ARB_instanced_arrays; -GLEW_VAR_EXPORT GLboolean __GLEW_ARB_internalformat_query; -GLEW_VAR_EXPORT GLboolean __GLEW_ARB_internalformat_query2; -GLEW_VAR_EXPORT GLboolean __GLEW_ARB_invalidate_subdata; -GLEW_VAR_EXPORT GLboolean __GLEW_ARB_map_buffer_alignment; -GLEW_VAR_EXPORT GLboolean __GLEW_ARB_map_buffer_range; -GLEW_VAR_EXPORT GLboolean __GLEW_ARB_matrix_palette; -GLEW_VAR_EXPORT GLboolean __GLEW_ARB_multi_bind; -GLEW_VAR_EXPORT GLboolean __GLEW_ARB_multi_draw_indirect; -GLEW_VAR_EXPORT GLboolean __GLEW_ARB_multisample; -GLEW_VAR_EXPORT GLboolean __GLEW_ARB_multitexture; -GLEW_VAR_EXPORT GLboolean __GLEW_ARB_occlusion_query; -GLEW_VAR_EXPORT GLboolean __GLEW_ARB_occlusion_query2; -GLEW_VAR_EXPORT GLboolean __GLEW_ARB_parallel_shader_compile; -GLEW_VAR_EXPORT GLboolean __GLEW_ARB_pipeline_statistics_query; -GLEW_VAR_EXPORT GLboolean __GLEW_ARB_pixel_buffer_object; -GLEW_VAR_EXPORT GLboolean __GLEW_ARB_point_parameters; -GLEW_VAR_EXPORT GLboolean __GLEW_ARB_point_sprite; -GLEW_VAR_EXPORT GLboolean __GLEW_ARB_post_depth_coverage; -GLEW_VAR_EXPORT GLboolean __GLEW_ARB_program_interface_query; -GLEW_VAR_EXPORT GLboolean __GLEW_ARB_provoking_vertex; -GLEW_VAR_EXPORT GLboolean __GLEW_ARB_query_buffer_object; -GLEW_VAR_EXPORT GLboolean __GLEW_ARB_robust_buffer_access_behavior; -GLEW_VAR_EXPORT GLboolean __GLEW_ARB_robustness; -GLEW_VAR_EXPORT GLboolean __GLEW_ARB_robustness_application_isolation; -GLEW_VAR_EXPORT GLboolean __GLEW_ARB_robustness_share_group_isolation; -GLEW_VAR_EXPORT GLboolean __GLEW_ARB_sample_locations; -GLEW_VAR_EXPORT GLboolean __GLEW_ARB_sample_shading; -GLEW_VAR_EXPORT GLboolean __GLEW_ARB_sampler_objects; -GLEW_VAR_EXPORT GLboolean __GLEW_ARB_seamless_cube_map; -GLEW_VAR_EXPORT GLboolean __GLEW_ARB_seamless_cubemap_per_texture; -GLEW_VAR_EXPORT GLboolean __GLEW_ARB_separate_shader_objects; -GLEW_VAR_EXPORT GLboolean __GLEW_ARB_shader_atomic_counter_ops; -GLEW_VAR_EXPORT GLboolean __GLEW_ARB_shader_atomic_counters; -GLEW_VAR_EXPORT GLboolean __GLEW_ARB_shader_ballot; -GLEW_VAR_EXPORT GLboolean __GLEW_ARB_shader_bit_encoding; -GLEW_VAR_EXPORT GLboolean __GLEW_ARB_shader_clock; -GLEW_VAR_EXPORT GLboolean __GLEW_ARB_shader_draw_parameters; -GLEW_VAR_EXPORT GLboolean __GLEW_ARB_shader_group_vote; -GLEW_VAR_EXPORT GLboolean __GLEW_ARB_shader_image_load_store; -GLEW_VAR_EXPORT GLboolean __GLEW_ARB_shader_image_size; -GLEW_VAR_EXPORT GLboolean __GLEW_ARB_shader_objects; -GLEW_VAR_EXPORT GLboolean __GLEW_ARB_shader_precision; -GLEW_VAR_EXPORT GLboolean __GLEW_ARB_shader_stencil_export; -GLEW_VAR_EXPORT GLboolean __GLEW_ARB_shader_storage_buffer_object; -GLEW_VAR_EXPORT GLboolean __GLEW_ARB_shader_subroutine; -GLEW_VAR_EXPORT GLboolean __GLEW_ARB_shader_texture_image_samples; -GLEW_VAR_EXPORT GLboolean __GLEW_ARB_shader_texture_lod; -GLEW_VAR_EXPORT GLboolean __GLEW_ARB_shader_viewport_layer_array; -GLEW_VAR_EXPORT GLboolean __GLEW_ARB_shading_language_100; -GLEW_VAR_EXPORT GLboolean __GLEW_ARB_shading_language_420pack; -GLEW_VAR_EXPORT GLboolean __GLEW_ARB_shading_language_include; -GLEW_VAR_EXPORT GLboolean __GLEW_ARB_shading_language_packing; -GLEW_VAR_EXPORT GLboolean __GLEW_ARB_shadow; -GLEW_VAR_EXPORT GLboolean __GLEW_ARB_shadow_ambient; -GLEW_VAR_EXPORT GLboolean __GLEW_ARB_sparse_buffer; -GLEW_VAR_EXPORT GLboolean __GLEW_ARB_sparse_texture; -GLEW_VAR_EXPORT GLboolean __GLEW_ARB_sparse_texture2; -GLEW_VAR_EXPORT GLboolean __GLEW_ARB_sparse_texture_clamp; -GLEW_VAR_EXPORT GLboolean __GLEW_ARB_stencil_texturing; -GLEW_VAR_EXPORT GLboolean __GLEW_ARB_sync; -GLEW_VAR_EXPORT GLboolean __GLEW_ARB_tessellation_shader; -GLEW_VAR_EXPORT GLboolean __GLEW_ARB_texture_barrier; -GLEW_VAR_EXPORT GLboolean __GLEW_ARB_texture_border_clamp; -GLEW_VAR_EXPORT GLboolean __GLEW_ARB_texture_buffer_object; -GLEW_VAR_EXPORT GLboolean __GLEW_ARB_texture_buffer_object_rgb32; -GLEW_VAR_EXPORT GLboolean __GLEW_ARB_texture_buffer_range; -GLEW_VAR_EXPORT GLboolean __GLEW_ARB_texture_compression; -GLEW_VAR_EXPORT GLboolean __GLEW_ARB_texture_compression_bptc; -GLEW_VAR_EXPORT GLboolean __GLEW_ARB_texture_compression_rgtc; -GLEW_VAR_EXPORT GLboolean __GLEW_ARB_texture_cube_map; -GLEW_VAR_EXPORT GLboolean __GLEW_ARB_texture_cube_map_array; -GLEW_VAR_EXPORT GLboolean __GLEW_ARB_texture_env_add; -GLEW_VAR_EXPORT GLboolean __GLEW_ARB_texture_env_combine; -GLEW_VAR_EXPORT GLboolean __GLEW_ARB_texture_env_crossbar; -GLEW_VAR_EXPORT GLboolean __GLEW_ARB_texture_env_dot3; -GLEW_VAR_EXPORT GLboolean __GLEW_ARB_texture_filter_minmax; -GLEW_VAR_EXPORT GLboolean __GLEW_ARB_texture_float; -GLEW_VAR_EXPORT GLboolean __GLEW_ARB_texture_gather; -GLEW_VAR_EXPORT GLboolean __GLEW_ARB_texture_mirror_clamp_to_edge; -GLEW_VAR_EXPORT GLboolean __GLEW_ARB_texture_mirrored_repeat; -GLEW_VAR_EXPORT GLboolean __GLEW_ARB_texture_multisample; -GLEW_VAR_EXPORT GLboolean __GLEW_ARB_texture_non_power_of_two; -GLEW_VAR_EXPORT GLboolean __GLEW_ARB_texture_query_levels; -GLEW_VAR_EXPORT GLboolean __GLEW_ARB_texture_query_lod; -GLEW_VAR_EXPORT GLboolean __GLEW_ARB_texture_rectangle; -GLEW_VAR_EXPORT GLboolean __GLEW_ARB_texture_rg; -GLEW_VAR_EXPORT GLboolean __GLEW_ARB_texture_rgb10_a2ui; -GLEW_VAR_EXPORT GLboolean __GLEW_ARB_texture_stencil8; -GLEW_VAR_EXPORT GLboolean __GLEW_ARB_texture_storage; -GLEW_VAR_EXPORT GLboolean __GLEW_ARB_texture_storage_multisample; -GLEW_VAR_EXPORT GLboolean __GLEW_ARB_texture_swizzle; -GLEW_VAR_EXPORT GLboolean __GLEW_ARB_texture_view; -GLEW_VAR_EXPORT GLboolean __GLEW_ARB_timer_query; -GLEW_VAR_EXPORT GLboolean __GLEW_ARB_transform_feedback2; -GLEW_VAR_EXPORT GLboolean __GLEW_ARB_transform_feedback3; -GLEW_VAR_EXPORT GLboolean __GLEW_ARB_transform_feedback_instanced; -GLEW_VAR_EXPORT GLboolean __GLEW_ARB_transform_feedback_overflow_query; -GLEW_VAR_EXPORT GLboolean __GLEW_ARB_transpose_matrix; -GLEW_VAR_EXPORT GLboolean __GLEW_ARB_uniform_buffer_object; -GLEW_VAR_EXPORT GLboolean __GLEW_ARB_vertex_array_bgra; -GLEW_VAR_EXPORT GLboolean __GLEW_ARB_vertex_array_object; -GLEW_VAR_EXPORT GLboolean __GLEW_ARB_vertex_attrib_64bit; -GLEW_VAR_EXPORT GLboolean __GLEW_ARB_vertex_attrib_binding; -GLEW_VAR_EXPORT GLboolean __GLEW_ARB_vertex_blend; -GLEW_VAR_EXPORT GLboolean __GLEW_ARB_vertex_buffer_object; -GLEW_VAR_EXPORT GLboolean __GLEW_ARB_vertex_program; -GLEW_VAR_EXPORT GLboolean __GLEW_ARB_vertex_shader; -GLEW_VAR_EXPORT GLboolean __GLEW_ARB_vertex_type_10f_11f_11f_rev; -GLEW_VAR_EXPORT GLboolean __GLEW_ARB_vertex_type_2_10_10_10_rev; -GLEW_VAR_EXPORT GLboolean __GLEW_ARB_viewport_array; -GLEW_VAR_EXPORT GLboolean __GLEW_ARB_window_pos; -GLEW_VAR_EXPORT GLboolean __GLEW_ATIX_point_sprites; -GLEW_VAR_EXPORT GLboolean __GLEW_ATIX_texture_env_combine3; -GLEW_VAR_EXPORT GLboolean __GLEW_ATIX_texture_env_route; -GLEW_VAR_EXPORT GLboolean __GLEW_ATIX_vertex_shader_output_point_size; -GLEW_VAR_EXPORT GLboolean __GLEW_ATI_draw_buffers; -GLEW_VAR_EXPORT GLboolean __GLEW_ATI_element_array; -GLEW_VAR_EXPORT GLboolean __GLEW_ATI_envmap_bumpmap; -GLEW_VAR_EXPORT GLboolean __GLEW_ATI_fragment_shader; -GLEW_VAR_EXPORT GLboolean __GLEW_ATI_map_object_buffer; -GLEW_VAR_EXPORT GLboolean __GLEW_ATI_meminfo; -GLEW_VAR_EXPORT GLboolean __GLEW_ATI_pn_triangles; -GLEW_VAR_EXPORT GLboolean __GLEW_ATI_separate_stencil; -GLEW_VAR_EXPORT GLboolean __GLEW_ATI_shader_texture_lod; -GLEW_VAR_EXPORT GLboolean __GLEW_ATI_text_fragment_shader; -GLEW_VAR_EXPORT GLboolean __GLEW_ATI_texture_compression_3dc; -GLEW_VAR_EXPORT GLboolean __GLEW_ATI_texture_env_combine3; -GLEW_VAR_EXPORT GLboolean __GLEW_ATI_texture_float; -GLEW_VAR_EXPORT GLboolean __GLEW_ATI_texture_mirror_once; -GLEW_VAR_EXPORT GLboolean __GLEW_ATI_vertex_array_object; -GLEW_VAR_EXPORT GLboolean __GLEW_ATI_vertex_attrib_array_object; -GLEW_VAR_EXPORT GLboolean __GLEW_ATI_vertex_streams; -GLEW_VAR_EXPORT GLboolean __GLEW_EGL_NV_robustness_video_memory_purge; -GLEW_VAR_EXPORT GLboolean __GLEW_EXT_422_pixels; -GLEW_VAR_EXPORT GLboolean __GLEW_EXT_Cg_shader; -GLEW_VAR_EXPORT GLboolean __GLEW_EXT_abgr; -GLEW_VAR_EXPORT GLboolean __GLEW_EXT_bgra; -GLEW_VAR_EXPORT GLboolean __GLEW_EXT_bindable_uniform; -GLEW_VAR_EXPORT GLboolean __GLEW_EXT_blend_color; -GLEW_VAR_EXPORT GLboolean __GLEW_EXT_blend_equation_separate; -GLEW_VAR_EXPORT GLboolean __GLEW_EXT_blend_func_separate; -GLEW_VAR_EXPORT GLboolean __GLEW_EXT_blend_logic_op; -GLEW_VAR_EXPORT GLboolean __GLEW_EXT_blend_minmax; -GLEW_VAR_EXPORT GLboolean __GLEW_EXT_blend_subtract; -GLEW_VAR_EXPORT GLboolean __GLEW_EXT_clip_volume_hint; -GLEW_VAR_EXPORT GLboolean __GLEW_EXT_cmyka; -GLEW_VAR_EXPORT GLboolean __GLEW_EXT_color_subtable; -GLEW_VAR_EXPORT GLboolean __GLEW_EXT_compiled_vertex_array; -GLEW_VAR_EXPORT GLboolean __GLEW_EXT_convolution; -GLEW_VAR_EXPORT GLboolean __GLEW_EXT_coordinate_frame; -GLEW_VAR_EXPORT GLboolean __GLEW_EXT_copy_texture; -GLEW_VAR_EXPORT GLboolean __GLEW_EXT_cull_vertex; -GLEW_VAR_EXPORT GLboolean __GLEW_EXT_debug_label; -GLEW_VAR_EXPORT GLboolean __GLEW_EXT_debug_marker; -GLEW_VAR_EXPORT GLboolean __GLEW_EXT_depth_bounds_test; -GLEW_VAR_EXPORT GLboolean __GLEW_EXT_direct_state_access; -GLEW_VAR_EXPORT GLboolean __GLEW_EXT_draw_buffers2; -GLEW_VAR_EXPORT GLboolean __GLEW_EXT_draw_instanced; -GLEW_VAR_EXPORT GLboolean __GLEW_EXT_draw_range_elements; -GLEW_VAR_EXPORT GLboolean __GLEW_EXT_fog_coord; -GLEW_VAR_EXPORT GLboolean __GLEW_EXT_fragment_lighting; -GLEW_VAR_EXPORT GLboolean __GLEW_EXT_framebuffer_blit; -GLEW_VAR_EXPORT GLboolean __GLEW_EXT_framebuffer_multisample; -GLEW_VAR_EXPORT GLboolean __GLEW_EXT_framebuffer_multisample_blit_scaled; -GLEW_VAR_EXPORT GLboolean __GLEW_EXT_framebuffer_object; -GLEW_VAR_EXPORT GLboolean __GLEW_EXT_framebuffer_sRGB; -GLEW_VAR_EXPORT GLboolean __GLEW_EXT_geometry_shader4; -GLEW_VAR_EXPORT GLboolean __GLEW_EXT_gpu_program_parameters; -GLEW_VAR_EXPORT GLboolean __GLEW_EXT_gpu_shader4; -GLEW_VAR_EXPORT GLboolean __GLEW_EXT_histogram; -GLEW_VAR_EXPORT GLboolean __GLEW_EXT_index_array_formats; -GLEW_VAR_EXPORT GLboolean __GLEW_EXT_index_func; -GLEW_VAR_EXPORT GLboolean __GLEW_EXT_index_material; -GLEW_VAR_EXPORT GLboolean __GLEW_EXT_index_texture; -GLEW_VAR_EXPORT GLboolean __GLEW_EXT_light_texture; -GLEW_VAR_EXPORT GLboolean __GLEW_EXT_misc_attribute; -GLEW_VAR_EXPORT GLboolean __GLEW_EXT_multi_draw_arrays; -GLEW_VAR_EXPORT GLboolean __GLEW_EXT_multisample; -GLEW_VAR_EXPORT GLboolean __GLEW_EXT_packed_depth_stencil; -GLEW_VAR_EXPORT GLboolean __GLEW_EXT_packed_float; -GLEW_VAR_EXPORT GLboolean __GLEW_EXT_packed_pixels; -GLEW_VAR_EXPORT GLboolean __GLEW_EXT_paletted_texture; -GLEW_VAR_EXPORT GLboolean __GLEW_EXT_pixel_buffer_object; -GLEW_VAR_EXPORT GLboolean __GLEW_EXT_pixel_transform; -GLEW_VAR_EXPORT GLboolean __GLEW_EXT_pixel_transform_color_table; -GLEW_VAR_EXPORT GLboolean __GLEW_EXT_point_parameters; -GLEW_VAR_EXPORT GLboolean __GLEW_EXT_polygon_offset; -GLEW_VAR_EXPORT GLboolean __GLEW_EXT_polygon_offset_clamp; -GLEW_VAR_EXPORT GLboolean __GLEW_EXT_post_depth_coverage; -GLEW_VAR_EXPORT GLboolean __GLEW_EXT_provoking_vertex; -GLEW_VAR_EXPORT GLboolean __GLEW_EXT_raster_multisample; -GLEW_VAR_EXPORT GLboolean __GLEW_EXT_rescale_normal; -GLEW_VAR_EXPORT GLboolean __GLEW_EXT_scene_marker; -GLEW_VAR_EXPORT GLboolean __GLEW_EXT_secondary_color; -GLEW_VAR_EXPORT GLboolean __GLEW_EXT_separate_shader_objects; -GLEW_VAR_EXPORT GLboolean __GLEW_EXT_separate_specular_color; -GLEW_VAR_EXPORT GLboolean __GLEW_EXT_shader_image_load_formatted; -GLEW_VAR_EXPORT GLboolean __GLEW_EXT_shader_image_load_store; -GLEW_VAR_EXPORT GLboolean __GLEW_EXT_shader_integer_mix; -GLEW_VAR_EXPORT GLboolean __GLEW_EXT_shadow_funcs; -GLEW_VAR_EXPORT GLboolean __GLEW_EXT_shared_texture_palette; -GLEW_VAR_EXPORT GLboolean __GLEW_EXT_sparse_texture2; -GLEW_VAR_EXPORT GLboolean __GLEW_EXT_stencil_clear_tag; -GLEW_VAR_EXPORT GLboolean __GLEW_EXT_stencil_two_side; -GLEW_VAR_EXPORT GLboolean __GLEW_EXT_stencil_wrap; -GLEW_VAR_EXPORT GLboolean __GLEW_EXT_subtexture; -GLEW_VAR_EXPORT GLboolean __GLEW_EXT_texture; -GLEW_VAR_EXPORT GLboolean __GLEW_EXT_texture3D; -GLEW_VAR_EXPORT GLboolean __GLEW_EXT_texture_array; -GLEW_VAR_EXPORT GLboolean __GLEW_EXT_texture_buffer_object; -GLEW_VAR_EXPORT GLboolean __GLEW_EXT_texture_compression_dxt1; -GLEW_VAR_EXPORT GLboolean __GLEW_EXT_texture_compression_latc; -GLEW_VAR_EXPORT GLboolean __GLEW_EXT_texture_compression_rgtc; -GLEW_VAR_EXPORT GLboolean __GLEW_EXT_texture_compression_s3tc; -GLEW_VAR_EXPORT GLboolean __GLEW_EXT_texture_cube_map; -GLEW_VAR_EXPORT GLboolean __GLEW_EXT_texture_edge_clamp; -GLEW_VAR_EXPORT GLboolean __GLEW_EXT_texture_env; -GLEW_VAR_EXPORT GLboolean __GLEW_EXT_texture_env_add; -GLEW_VAR_EXPORT GLboolean __GLEW_EXT_texture_env_combine; -GLEW_VAR_EXPORT GLboolean __GLEW_EXT_texture_env_dot3; -GLEW_VAR_EXPORT GLboolean __GLEW_EXT_texture_filter_anisotropic; -GLEW_VAR_EXPORT GLboolean __GLEW_EXT_texture_filter_minmax; -GLEW_VAR_EXPORT GLboolean __GLEW_EXT_texture_integer; -GLEW_VAR_EXPORT GLboolean __GLEW_EXT_texture_lod_bias; -GLEW_VAR_EXPORT GLboolean __GLEW_EXT_texture_mirror_clamp; -GLEW_VAR_EXPORT GLboolean __GLEW_EXT_texture_object; -GLEW_VAR_EXPORT GLboolean __GLEW_EXT_texture_perturb_normal; -GLEW_VAR_EXPORT GLboolean __GLEW_EXT_texture_rectangle; -GLEW_VAR_EXPORT GLboolean __GLEW_EXT_texture_sRGB; -GLEW_VAR_EXPORT GLboolean __GLEW_EXT_texture_sRGB_decode; -GLEW_VAR_EXPORT GLboolean __GLEW_EXT_texture_shared_exponent; -GLEW_VAR_EXPORT GLboolean __GLEW_EXT_texture_snorm; -GLEW_VAR_EXPORT GLboolean __GLEW_EXT_texture_swizzle; -GLEW_VAR_EXPORT GLboolean __GLEW_EXT_timer_query; -GLEW_VAR_EXPORT GLboolean __GLEW_EXT_transform_feedback; -GLEW_VAR_EXPORT GLboolean __GLEW_EXT_vertex_array; -GLEW_VAR_EXPORT GLboolean __GLEW_EXT_vertex_array_bgra; -GLEW_VAR_EXPORT GLboolean __GLEW_EXT_vertex_attrib_64bit; -GLEW_VAR_EXPORT GLboolean __GLEW_EXT_vertex_shader; -GLEW_VAR_EXPORT GLboolean __GLEW_EXT_vertex_weighting; -GLEW_VAR_EXPORT GLboolean __GLEW_EXT_window_rectangles; -GLEW_VAR_EXPORT GLboolean __GLEW_EXT_x11_sync_object; -GLEW_VAR_EXPORT GLboolean __GLEW_GREMEDY_frame_terminator; -GLEW_VAR_EXPORT GLboolean __GLEW_GREMEDY_string_marker; -GLEW_VAR_EXPORT GLboolean __GLEW_HP_convolution_border_modes; -GLEW_VAR_EXPORT GLboolean __GLEW_HP_image_transform; -GLEW_VAR_EXPORT GLboolean __GLEW_HP_occlusion_test; -GLEW_VAR_EXPORT GLboolean __GLEW_HP_texture_lighting; -GLEW_VAR_EXPORT GLboolean __GLEW_IBM_cull_vertex; -GLEW_VAR_EXPORT GLboolean __GLEW_IBM_multimode_draw_arrays; -GLEW_VAR_EXPORT GLboolean __GLEW_IBM_rasterpos_clip; -GLEW_VAR_EXPORT GLboolean __GLEW_IBM_static_data; -GLEW_VAR_EXPORT GLboolean __GLEW_IBM_texture_mirrored_repeat; -GLEW_VAR_EXPORT GLboolean __GLEW_IBM_vertex_array_lists; -GLEW_VAR_EXPORT GLboolean __GLEW_INGR_color_clamp; -GLEW_VAR_EXPORT GLboolean __GLEW_INGR_interlace_read; -GLEW_VAR_EXPORT GLboolean __GLEW_INTEL_conservative_rasterization; -GLEW_VAR_EXPORT GLboolean __GLEW_INTEL_fragment_shader_ordering; -GLEW_VAR_EXPORT GLboolean __GLEW_INTEL_framebuffer_CMAA; -GLEW_VAR_EXPORT GLboolean __GLEW_INTEL_map_texture; -GLEW_VAR_EXPORT GLboolean __GLEW_INTEL_parallel_arrays; -GLEW_VAR_EXPORT GLboolean __GLEW_INTEL_performance_query; -GLEW_VAR_EXPORT GLboolean __GLEW_INTEL_texture_scissor; -GLEW_VAR_EXPORT GLboolean __GLEW_KHR_blend_equation_advanced; -GLEW_VAR_EXPORT GLboolean __GLEW_KHR_blend_equation_advanced_coherent; -GLEW_VAR_EXPORT GLboolean __GLEW_KHR_context_flush_control; -GLEW_VAR_EXPORT GLboolean __GLEW_KHR_debug; -GLEW_VAR_EXPORT GLboolean __GLEW_KHR_no_error; -GLEW_VAR_EXPORT GLboolean __GLEW_KHR_robust_buffer_access_behavior; -GLEW_VAR_EXPORT GLboolean __GLEW_KHR_robustness; -GLEW_VAR_EXPORT GLboolean __GLEW_KHR_texture_compression_astc_hdr; -GLEW_VAR_EXPORT GLboolean __GLEW_KHR_texture_compression_astc_ldr; -GLEW_VAR_EXPORT GLboolean __GLEW_KHR_texture_compression_astc_sliced_3d; -GLEW_VAR_EXPORT GLboolean __GLEW_KTX_buffer_region; -GLEW_VAR_EXPORT GLboolean __GLEW_MESAX_texture_stack; -GLEW_VAR_EXPORT GLboolean __GLEW_MESA_pack_invert; -GLEW_VAR_EXPORT GLboolean __GLEW_MESA_resize_buffers; -GLEW_VAR_EXPORT GLboolean __GLEW_MESA_shader_integer_functions; -GLEW_VAR_EXPORT GLboolean __GLEW_MESA_window_pos; -GLEW_VAR_EXPORT GLboolean __GLEW_MESA_ycbcr_texture; -GLEW_VAR_EXPORT GLboolean __GLEW_NVX_blend_equation_advanced_multi_draw_buffers; -GLEW_VAR_EXPORT GLboolean __GLEW_NVX_conditional_render; -GLEW_VAR_EXPORT GLboolean __GLEW_NVX_gpu_memory_info; -GLEW_VAR_EXPORT GLboolean __GLEW_NVX_linked_gpu_multicast; -GLEW_VAR_EXPORT GLboolean __GLEW_NV_bindless_multi_draw_indirect; -GLEW_VAR_EXPORT GLboolean __GLEW_NV_bindless_multi_draw_indirect_count; -GLEW_VAR_EXPORT GLboolean __GLEW_NV_bindless_texture; -GLEW_VAR_EXPORT GLboolean __GLEW_NV_blend_equation_advanced; -GLEW_VAR_EXPORT GLboolean __GLEW_NV_blend_equation_advanced_coherent; -GLEW_VAR_EXPORT GLboolean __GLEW_NV_blend_square; -GLEW_VAR_EXPORT GLboolean __GLEW_NV_clip_space_w_scaling; -GLEW_VAR_EXPORT GLboolean __GLEW_NV_command_list; -GLEW_VAR_EXPORT GLboolean __GLEW_NV_compute_program5; -GLEW_VAR_EXPORT GLboolean __GLEW_NV_conditional_render; -GLEW_VAR_EXPORT GLboolean __GLEW_NV_conservative_raster; -GLEW_VAR_EXPORT GLboolean __GLEW_NV_conservative_raster_dilate; -GLEW_VAR_EXPORT GLboolean __GLEW_NV_conservative_raster_pre_snap_triangles; -GLEW_VAR_EXPORT GLboolean __GLEW_NV_copy_depth_to_color; -GLEW_VAR_EXPORT GLboolean __GLEW_NV_copy_image; -GLEW_VAR_EXPORT GLboolean __GLEW_NV_deep_texture3D; -GLEW_VAR_EXPORT GLboolean __GLEW_NV_depth_buffer_float; -GLEW_VAR_EXPORT GLboolean __GLEW_NV_depth_clamp; -GLEW_VAR_EXPORT GLboolean __GLEW_NV_depth_range_unclamped; -GLEW_VAR_EXPORT GLboolean __GLEW_NV_draw_texture; -GLEW_VAR_EXPORT GLboolean __GLEW_NV_draw_vulkan_image; -GLEW_VAR_EXPORT GLboolean __GLEW_NV_evaluators; -GLEW_VAR_EXPORT GLboolean __GLEW_NV_explicit_multisample; -GLEW_VAR_EXPORT GLboolean __GLEW_NV_fence; -GLEW_VAR_EXPORT GLboolean __GLEW_NV_fill_rectangle; -GLEW_VAR_EXPORT GLboolean __GLEW_NV_float_buffer; -GLEW_VAR_EXPORT GLboolean __GLEW_NV_fog_distance; -GLEW_VAR_EXPORT GLboolean __GLEW_NV_fragment_coverage_to_color; -GLEW_VAR_EXPORT GLboolean __GLEW_NV_fragment_program; -GLEW_VAR_EXPORT GLboolean __GLEW_NV_fragment_program2; -GLEW_VAR_EXPORT GLboolean __GLEW_NV_fragment_program4; -GLEW_VAR_EXPORT GLboolean __GLEW_NV_fragment_program_option; -GLEW_VAR_EXPORT GLboolean __GLEW_NV_fragment_shader_interlock; -GLEW_VAR_EXPORT GLboolean __GLEW_NV_framebuffer_mixed_samples; -GLEW_VAR_EXPORT GLboolean __GLEW_NV_framebuffer_multisample_coverage; -GLEW_VAR_EXPORT GLboolean __GLEW_NV_geometry_program4; -GLEW_VAR_EXPORT GLboolean __GLEW_NV_geometry_shader4; -GLEW_VAR_EXPORT GLboolean __GLEW_NV_geometry_shader_passthrough; -GLEW_VAR_EXPORT GLboolean __GLEW_NV_gpu_multicast; -GLEW_VAR_EXPORT GLboolean __GLEW_NV_gpu_program4; -GLEW_VAR_EXPORT GLboolean __GLEW_NV_gpu_program5; -GLEW_VAR_EXPORT GLboolean __GLEW_NV_gpu_program5_mem_extended; -GLEW_VAR_EXPORT GLboolean __GLEW_NV_gpu_program_fp64; -GLEW_VAR_EXPORT GLboolean __GLEW_NV_gpu_shader5; -GLEW_VAR_EXPORT GLboolean __GLEW_NV_half_float; -GLEW_VAR_EXPORT GLboolean __GLEW_NV_internalformat_sample_query; -GLEW_VAR_EXPORT GLboolean __GLEW_NV_light_max_exponent; -GLEW_VAR_EXPORT GLboolean __GLEW_NV_multisample_coverage; -GLEW_VAR_EXPORT GLboolean __GLEW_NV_multisample_filter_hint; -GLEW_VAR_EXPORT GLboolean __GLEW_NV_occlusion_query; -GLEW_VAR_EXPORT GLboolean __GLEW_NV_packed_depth_stencil; -GLEW_VAR_EXPORT GLboolean __GLEW_NV_parameter_buffer_object; -GLEW_VAR_EXPORT GLboolean __GLEW_NV_parameter_buffer_object2; -GLEW_VAR_EXPORT GLboolean __GLEW_NV_path_rendering; -GLEW_VAR_EXPORT GLboolean __GLEW_NV_path_rendering_shared_edge; -GLEW_VAR_EXPORT GLboolean __GLEW_NV_pixel_data_range; -GLEW_VAR_EXPORT GLboolean __GLEW_NV_point_sprite; -GLEW_VAR_EXPORT GLboolean __GLEW_NV_present_video; -GLEW_VAR_EXPORT GLboolean __GLEW_NV_primitive_restart; -GLEW_VAR_EXPORT GLboolean __GLEW_NV_register_combiners; -GLEW_VAR_EXPORT GLboolean __GLEW_NV_register_combiners2; -GLEW_VAR_EXPORT GLboolean __GLEW_NV_robustness_video_memory_purge; -GLEW_VAR_EXPORT GLboolean __GLEW_NV_sample_locations; -GLEW_VAR_EXPORT GLboolean __GLEW_NV_sample_mask_override_coverage; -GLEW_VAR_EXPORT GLboolean __GLEW_NV_shader_atomic_counters; -GLEW_VAR_EXPORT GLboolean __GLEW_NV_shader_atomic_float; -GLEW_VAR_EXPORT GLboolean __GLEW_NV_shader_atomic_float64; -GLEW_VAR_EXPORT GLboolean __GLEW_NV_shader_atomic_fp16_vector; -GLEW_VAR_EXPORT GLboolean __GLEW_NV_shader_atomic_int64; -GLEW_VAR_EXPORT GLboolean __GLEW_NV_shader_buffer_load; -GLEW_VAR_EXPORT GLboolean __GLEW_NV_shader_storage_buffer_object; -GLEW_VAR_EXPORT GLboolean __GLEW_NV_shader_thread_group; -GLEW_VAR_EXPORT GLboolean __GLEW_NV_shader_thread_shuffle; -GLEW_VAR_EXPORT GLboolean __GLEW_NV_stereo_view_rendering; -GLEW_VAR_EXPORT GLboolean __GLEW_NV_tessellation_program5; -GLEW_VAR_EXPORT GLboolean __GLEW_NV_texgen_emboss; -GLEW_VAR_EXPORT GLboolean __GLEW_NV_texgen_reflection; -GLEW_VAR_EXPORT GLboolean __GLEW_NV_texture_barrier; -GLEW_VAR_EXPORT GLboolean __GLEW_NV_texture_compression_vtc; -GLEW_VAR_EXPORT GLboolean __GLEW_NV_texture_env_combine4; -GLEW_VAR_EXPORT GLboolean __GLEW_NV_texture_expand_normal; -GLEW_VAR_EXPORT GLboolean __GLEW_NV_texture_multisample; -GLEW_VAR_EXPORT GLboolean __GLEW_NV_texture_rectangle; -GLEW_VAR_EXPORT GLboolean __GLEW_NV_texture_shader; -GLEW_VAR_EXPORT GLboolean __GLEW_NV_texture_shader2; -GLEW_VAR_EXPORT GLboolean __GLEW_NV_texture_shader3; -GLEW_VAR_EXPORT GLboolean __GLEW_NV_transform_feedback; -GLEW_VAR_EXPORT GLboolean __GLEW_NV_transform_feedback2; -GLEW_VAR_EXPORT GLboolean __GLEW_NV_uniform_buffer_unified_memory; -GLEW_VAR_EXPORT GLboolean __GLEW_NV_vdpau_interop; -GLEW_VAR_EXPORT GLboolean __GLEW_NV_vertex_array_range; -GLEW_VAR_EXPORT GLboolean __GLEW_NV_vertex_array_range2; -GLEW_VAR_EXPORT GLboolean __GLEW_NV_vertex_attrib_integer_64bit; -GLEW_VAR_EXPORT GLboolean __GLEW_NV_vertex_buffer_unified_memory; -GLEW_VAR_EXPORT GLboolean __GLEW_NV_vertex_program; -GLEW_VAR_EXPORT GLboolean __GLEW_NV_vertex_program1_1; -GLEW_VAR_EXPORT GLboolean __GLEW_NV_vertex_program2; -GLEW_VAR_EXPORT GLboolean __GLEW_NV_vertex_program2_option; -GLEW_VAR_EXPORT GLboolean __GLEW_NV_vertex_program3; -GLEW_VAR_EXPORT GLboolean __GLEW_NV_vertex_program4; -GLEW_VAR_EXPORT GLboolean __GLEW_NV_video_capture; -GLEW_VAR_EXPORT GLboolean __GLEW_NV_viewport_array2; -GLEW_VAR_EXPORT GLboolean __GLEW_NV_viewport_swizzle; -GLEW_VAR_EXPORT GLboolean __GLEW_OES_byte_coordinates; -GLEW_VAR_EXPORT GLboolean __GLEW_OES_compressed_paletted_texture; -GLEW_VAR_EXPORT GLboolean __GLEW_OES_read_format; -GLEW_VAR_EXPORT GLboolean __GLEW_OES_single_precision; -GLEW_VAR_EXPORT GLboolean __GLEW_OML_interlace; -GLEW_VAR_EXPORT GLboolean __GLEW_OML_resample; -GLEW_VAR_EXPORT GLboolean __GLEW_OML_subsample; -GLEW_VAR_EXPORT GLboolean __GLEW_OVR_multiview; -GLEW_VAR_EXPORT GLboolean __GLEW_OVR_multiview2; -GLEW_VAR_EXPORT GLboolean __GLEW_PGI_misc_hints; -GLEW_VAR_EXPORT GLboolean __GLEW_PGI_vertex_hints; -GLEW_VAR_EXPORT GLboolean __GLEW_REGAL_ES1_0_compatibility; -GLEW_VAR_EXPORT GLboolean __GLEW_REGAL_ES1_1_compatibility; -GLEW_VAR_EXPORT GLboolean __GLEW_REGAL_enable; -GLEW_VAR_EXPORT GLboolean __GLEW_REGAL_error_string; -GLEW_VAR_EXPORT GLboolean __GLEW_REGAL_extension_query; -GLEW_VAR_EXPORT GLboolean __GLEW_REGAL_log; -GLEW_VAR_EXPORT GLboolean __GLEW_REGAL_proc_address; -GLEW_VAR_EXPORT GLboolean __GLEW_REND_screen_coordinates; -GLEW_VAR_EXPORT GLboolean __GLEW_S3_s3tc; -GLEW_VAR_EXPORT GLboolean __GLEW_SGIS_color_range; -GLEW_VAR_EXPORT GLboolean __GLEW_SGIS_detail_texture; -GLEW_VAR_EXPORT GLboolean __GLEW_SGIS_fog_function; -GLEW_VAR_EXPORT GLboolean __GLEW_SGIS_generate_mipmap; -GLEW_VAR_EXPORT GLboolean __GLEW_SGIS_multisample; -GLEW_VAR_EXPORT GLboolean __GLEW_SGIS_pixel_texture; -GLEW_VAR_EXPORT GLboolean __GLEW_SGIS_point_line_texgen; -GLEW_VAR_EXPORT GLboolean __GLEW_SGIS_sharpen_texture; -GLEW_VAR_EXPORT GLboolean __GLEW_SGIS_texture4D; -GLEW_VAR_EXPORT GLboolean __GLEW_SGIS_texture_border_clamp; -GLEW_VAR_EXPORT GLboolean __GLEW_SGIS_texture_edge_clamp; -GLEW_VAR_EXPORT GLboolean __GLEW_SGIS_texture_filter4; -GLEW_VAR_EXPORT GLboolean __GLEW_SGIS_texture_lod; -GLEW_VAR_EXPORT GLboolean __GLEW_SGIS_texture_select; -GLEW_VAR_EXPORT GLboolean __GLEW_SGIX_async; -GLEW_VAR_EXPORT GLboolean __GLEW_SGIX_async_histogram; -GLEW_VAR_EXPORT GLboolean __GLEW_SGIX_async_pixel; -GLEW_VAR_EXPORT GLboolean __GLEW_SGIX_blend_alpha_minmax; -GLEW_VAR_EXPORT GLboolean __GLEW_SGIX_clipmap; -GLEW_VAR_EXPORT GLboolean __GLEW_SGIX_convolution_accuracy; -GLEW_VAR_EXPORT GLboolean __GLEW_SGIX_depth_texture; -GLEW_VAR_EXPORT GLboolean __GLEW_SGIX_flush_raster; -GLEW_VAR_EXPORT GLboolean __GLEW_SGIX_fog_offset; -GLEW_VAR_EXPORT GLboolean __GLEW_SGIX_fog_texture; -GLEW_VAR_EXPORT GLboolean __GLEW_SGIX_fragment_specular_lighting; -GLEW_VAR_EXPORT GLboolean __GLEW_SGIX_framezoom; -GLEW_VAR_EXPORT GLboolean __GLEW_SGIX_interlace; -GLEW_VAR_EXPORT GLboolean __GLEW_SGIX_ir_instrument1; -GLEW_VAR_EXPORT GLboolean __GLEW_SGIX_list_priority; -GLEW_VAR_EXPORT GLboolean __GLEW_SGIX_pixel_texture; -GLEW_VAR_EXPORT GLboolean __GLEW_SGIX_pixel_texture_bits; -GLEW_VAR_EXPORT GLboolean __GLEW_SGIX_reference_plane; -GLEW_VAR_EXPORT GLboolean __GLEW_SGIX_resample; -GLEW_VAR_EXPORT GLboolean __GLEW_SGIX_shadow; -GLEW_VAR_EXPORT GLboolean __GLEW_SGIX_shadow_ambient; -GLEW_VAR_EXPORT GLboolean __GLEW_SGIX_sprite; -GLEW_VAR_EXPORT GLboolean __GLEW_SGIX_tag_sample_buffer; -GLEW_VAR_EXPORT GLboolean __GLEW_SGIX_texture_add_env; -GLEW_VAR_EXPORT GLboolean __GLEW_SGIX_texture_coordinate_clamp; -GLEW_VAR_EXPORT GLboolean __GLEW_SGIX_texture_lod_bias; -GLEW_VAR_EXPORT GLboolean __GLEW_SGIX_texture_multi_buffer; -GLEW_VAR_EXPORT GLboolean __GLEW_SGIX_texture_range; -GLEW_VAR_EXPORT GLboolean __GLEW_SGIX_texture_scale_bias; -GLEW_VAR_EXPORT GLboolean __GLEW_SGIX_vertex_preclip; -GLEW_VAR_EXPORT GLboolean __GLEW_SGIX_vertex_preclip_hint; -GLEW_VAR_EXPORT GLboolean __GLEW_SGIX_ycrcb; -GLEW_VAR_EXPORT GLboolean __GLEW_SGI_color_matrix; -GLEW_VAR_EXPORT GLboolean __GLEW_SGI_color_table; -GLEW_VAR_EXPORT GLboolean __GLEW_SGI_texture_color_table; -GLEW_VAR_EXPORT GLboolean __GLEW_SUNX_constant_data; -GLEW_VAR_EXPORT GLboolean __GLEW_SUN_convolution_border_modes; -GLEW_VAR_EXPORT GLboolean __GLEW_SUN_global_alpha; -GLEW_VAR_EXPORT GLboolean __GLEW_SUN_mesh_array; -GLEW_VAR_EXPORT GLboolean __GLEW_SUN_read_video_pixels; -GLEW_VAR_EXPORT GLboolean __GLEW_SUN_slice_accum; -GLEW_VAR_EXPORT GLboolean __GLEW_SUN_triangle_list; -GLEW_VAR_EXPORT GLboolean __GLEW_SUN_vertex; -GLEW_VAR_EXPORT GLboolean __GLEW_WIN_phong_shading; -GLEW_VAR_EXPORT GLboolean __GLEW_WIN_specular_fog; -GLEW_VAR_EXPORT GLboolean __GLEW_WIN_swap_hint; -/* ------------------------------------------------------------------------- */ - -/* error codes */ -#define GLEW_OK 0 -#define GLEW_NO_ERROR 0 -#define GLEW_ERROR_NO_GL_VERSION 1 /* missing GL version */ -#define GLEW_ERROR_GL_VERSION_10_ONLY 2 /* Need at least OpenGL 1.1 */ -#define GLEW_ERROR_GLX_VERSION_11_ONLY 3 /* Need at least GLX 1.2 */ - -/* string codes */ -#define GLEW_VERSION 1 -#define GLEW_VERSION_MAJOR 2 -#define GLEW_VERSION_MINOR 3 -#define GLEW_VERSION_MICRO 4 - -/* ------------------------------------------------------------------------- */ - -/* GLEW version info */ - -/* -VERSION 2.0.0 -VERSION_MAJOR 2 -VERSION_MINOR 0 -VERSION_MICRO 0 -*/ - -/* API */ -GLEWAPI GLenum GLEWAPIENTRY glewInit (void); -GLEWAPI GLboolean GLEWAPIENTRY glewIsSupported (const char *name); -#define glewIsExtensionSupported(x) glewIsSupported(x) - -#ifndef GLEW_GET_VAR -#define GLEW_GET_VAR(x) (*(const GLboolean*)&x) -#endif - -#ifndef GLEW_GET_FUN -#define GLEW_GET_FUN(x) x -#endif - -GLEWAPI GLboolean glewExperimental; -GLEWAPI GLboolean GLEWAPIENTRY glewGetExtension (const char *name); -GLEWAPI const GLubyte * GLEWAPIENTRY glewGetErrorString (GLenum error); -GLEWAPI const GLubyte * GLEWAPIENTRY glewGetString (GLenum name); - -#ifdef __cplusplus -} -#endif - -#ifdef GLEW_APIENTRY_DEFINED -#undef GLEW_APIENTRY_DEFINED -#undef APIENTRY -#endif - -#ifdef GLEW_CALLBACK_DEFINED -#undef GLEW_CALLBACK_DEFINED -#undef CALLBACK -#endif - -#ifdef GLEW_WINGDIAPI_DEFINED -#undef GLEW_WINGDIAPI_DEFINED -#undef WINGDIAPI -#endif - -#undef GLAPI -/* #undef GLEWAPI */ - -#endif /* __glew_h__ */ diff --git a/opengl/glew32.lib b/opengl/glew32.lib deleted file mode 100644 index 24793a72..00000000 Binary files a/opengl/glew32.lib and /dev/null differ diff --git a/opengl/glew32s.lib b/opengl/glew32s.lib deleted file mode 100644 index 18510029..00000000 Binary files a/opengl/glew32s.lib and /dev/null differ diff --git a/opengl/glext.h b/opengl/glext.h deleted file mode 100644 index 7bb8e6e7..00000000 --- a/opengl/glext.h +++ /dev/null @@ -1,6495 +0,0 @@ -#ifndef __glext_h_ -#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 diff --git a/opengl/glut32.lib b/opengl/glut32.lib deleted file mode 100644 index 494cad96..00000000 Binary files a/opengl/glut32.lib and /dev/null differ diff --git a/opengl/wglew.h b/opengl/wglew.h deleted file mode 100644 index 71ee0f30..00000000 --- a/opengl/wglew.h +++ /dev/null @@ -1,1427 +0,0 @@ -/* -** The OpenGL Extension Wrangler Library -** Copyright (C) 2008-2015, Nigel Stewart -** Copyright (C) 2002-2008, Milan Ikits -** Copyright (C) 2002-2008, Marcelo E. Magallon -** Copyright (C) 2002, Lev Povalahev -** All rights reserved. -** -** Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are met: -** -** * Redistributions of source code must retain the above copyright notice, -** this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright notice, -** this list of conditions and the following disclaimer in the documentation -** and/or other materials provided with the distribution. -** * The name of the author may be used to endorse or promote products -** derived from this software without specific prior written permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -** AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -** IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -** ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE -** LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -** CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -** SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -** INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -** CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -** ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF -** THE POSSIBILITY OF SUCH DAMAGE. -*/ - -/* -** Copyright (c) 2007 The Khronos Group Inc. -** -** Permission is hereby granted, free of charge, to any person obtaining a -** copy of this software and/or associated documentation files (the -** "Materials"), to deal in the Materials without restriction, including -** without limitation the rights to use, copy, modify, merge, publish, -** distribute, sublicense, and/or sell copies of the Materials, and to -** permit persons to whom the Materials are furnished to do so, subject to -** the following conditions: -** -** The above copyright notice and this permission notice shall be included -** in all copies or substantial portions of the Materials. -** -** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. -** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY -** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, -** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE -** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS. -*/ - -#ifndef __wglew_h__ -#define __wglew_h__ -#define __WGLEW_H__ - -#ifdef __wglext_h_ -#error wglext.h included before wglew.h -#endif - -#define __wglext_h_ - -#if !defined(WINAPI) -# ifndef WIN32_LEAN_AND_MEAN -# define WIN32_LEAN_AND_MEAN 1 -# endif -#include -# undef WIN32_LEAN_AND_MEAN -#endif - -/* - * GLEW_STATIC needs to be set when using the static version. - * GLEW_BUILD is set when building the DLL version. - */ -#ifdef GLEW_STATIC -# define GLEWAPI extern -#else -# ifdef GLEW_BUILD -# define GLEWAPI extern __declspec(dllexport) -# else -# define GLEWAPI extern __declspec(dllimport) -# endif -#endif - -#ifdef __cplusplus -extern "C" { -#endif - -/* -------------------------- WGL_3DFX_multisample ------------------------- */ - -#ifndef WGL_3DFX_multisample -#define WGL_3DFX_multisample 1 - -#define WGL_SAMPLE_BUFFERS_3DFX 0x2060 -#define WGL_SAMPLES_3DFX 0x2061 - -#define WGLEW_3DFX_multisample WGLEW_GET_VAR(__WGLEW_3DFX_multisample) - -#endif /* WGL_3DFX_multisample */ - -/* ------------------------- WGL_3DL_stereo_control ------------------------ */ - -#ifndef WGL_3DL_stereo_control -#define WGL_3DL_stereo_control 1 - -#define WGL_STEREO_EMITTER_ENABLE_3DL 0x2055 -#define WGL_STEREO_EMITTER_DISABLE_3DL 0x2056 -#define WGL_STEREO_POLARITY_NORMAL_3DL 0x2057 -#define WGL_STEREO_POLARITY_INVERT_3DL 0x2058 - -typedef BOOL (WINAPI * PFNWGLSETSTEREOEMITTERSTATE3DLPROC) (HDC hDC, UINT uState); - -#define wglSetStereoEmitterState3DL WGLEW_GET_FUN(__wglewSetStereoEmitterState3DL) - -#define WGLEW_3DL_stereo_control WGLEW_GET_VAR(__WGLEW_3DL_stereo_control) - -#endif /* WGL_3DL_stereo_control */ - -/* ------------------------ WGL_AMD_gpu_association ------------------------ */ - -#ifndef WGL_AMD_gpu_association -#define WGL_AMD_gpu_association 1 - -#define WGL_GPU_VENDOR_AMD 0x1F00 -#define WGL_GPU_RENDERER_STRING_AMD 0x1F01 -#define WGL_GPU_OPENGL_VERSION_STRING_AMD 0x1F02 -#define WGL_GPU_FASTEST_TARGET_GPUS_AMD 0x21A2 -#define WGL_GPU_RAM_AMD 0x21A3 -#define WGL_GPU_CLOCK_AMD 0x21A4 -#define WGL_GPU_NUM_PIPES_AMD 0x21A5 -#define WGL_GPU_NUM_SIMD_AMD 0x21A6 -#define WGL_GPU_NUM_RB_AMD 0x21A7 -#define WGL_GPU_NUM_SPI_AMD 0x21A8 - -typedef VOID (WINAPI * PFNWGLBLITCONTEXTFRAMEBUFFERAMDPROC) (HGLRC dstCtx, GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter); -typedef HGLRC (WINAPI * PFNWGLCREATEASSOCIATEDCONTEXTAMDPROC) (UINT id); -typedef HGLRC (WINAPI * PFNWGLCREATEASSOCIATEDCONTEXTATTRIBSAMDPROC) (UINT id, HGLRC hShareContext, const int* attribList); -typedef BOOL (WINAPI * PFNWGLDELETEASSOCIATEDCONTEXTAMDPROC) (HGLRC hglrc); -typedef UINT (WINAPI * PFNWGLGETCONTEXTGPUIDAMDPROC) (HGLRC hglrc); -typedef HGLRC (WINAPI * PFNWGLGETCURRENTASSOCIATEDCONTEXTAMDPROC) (void); -typedef UINT (WINAPI * PFNWGLGETGPUIDSAMDPROC) (UINT maxCount, UINT* ids); -typedef INT (WINAPI * PFNWGLGETGPUINFOAMDPROC) (UINT id, INT property, GLenum dataType, UINT size, void* data); -typedef BOOL (WINAPI * PFNWGLMAKEASSOCIATEDCONTEXTCURRENTAMDPROC) (HGLRC hglrc); - -#define wglBlitContextFramebufferAMD WGLEW_GET_FUN(__wglewBlitContextFramebufferAMD) -#define wglCreateAssociatedContextAMD WGLEW_GET_FUN(__wglewCreateAssociatedContextAMD) -#define wglCreateAssociatedContextAttribsAMD WGLEW_GET_FUN(__wglewCreateAssociatedContextAttribsAMD) -#define wglDeleteAssociatedContextAMD WGLEW_GET_FUN(__wglewDeleteAssociatedContextAMD) -#define wglGetContextGPUIDAMD WGLEW_GET_FUN(__wglewGetContextGPUIDAMD) -#define wglGetCurrentAssociatedContextAMD WGLEW_GET_FUN(__wglewGetCurrentAssociatedContextAMD) -#define wglGetGPUIDsAMD WGLEW_GET_FUN(__wglewGetGPUIDsAMD) -#define wglGetGPUInfoAMD WGLEW_GET_FUN(__wglewGetGPUInfoAMD) -#define wglMakeAssociatedContextCurrentAMD WGLEW_GET_FUN(__wglewMakeAssociatedContextCurrentAMD) - -#define WGLEW_AMD_gpu_association WGLEW_GET_VAR(__WGLEW_AMD_gpu_association) - -#endif /* WGL_AMD_gpu_association */ - -/* ------------------------- WGL_ARB_buffer_region ------------------------- */ - -#ifndef WGL_ARB_buffer_region -#define WGL_ARB_buffer_region 1 - -#define WGL_FRONT_COLOR_BUFFER_BIT_ARB 0x00000001 -#define WGL_BACK_COLOR_BUFFER_BIT_ARB 0x00000002 -#define WGL_DEPTH_BUFFER_BIT_ARB 0x00000004 -#define WGL_STENCIL_BUFFER_BIT_ARB 0x00000008 - -typedef HANDLE (WINAPI * PFNWGLCREATEBUFFERREGIONARBPROC) (HDC hDC, int iLayerPlane, UINT uType); -typedef VOID (WINAPI * PFNWGLDELETEBUFFERREGIONARBPROC) (HANDLE hRegion); -typedef BOOL (WINAPI * PFNWGLRESTOREBUFFERREGIONARBPROC) (HANDLE hRegion, int x, int y, int width, int height, int xSrc, int ySrc); -typedef BOOL (WINAPI * PFNWGLSAVEBUFFERREGIONARBPROC) (HANDLE hRegion, int x, int y, int width, int height); - -#define wglCreateBufferRegionARB WGLEW_GET_FUN(__wglewCreateBufferRegionARB) -#define wglDeleteBufferRegionARB WGLEW_GET_FUN(__wglewDeleteBufferRegionARB) -#define wglRestoreBufferRegionARB WGLEW_GET_FUN(__wglewRestoreBufferRegionARB) -#define wglSaveBufferRegionARB WGLEW_GET_FUN(__wglewSaveBufferRegionARB) - -#define WGLEW_ARB_buffer_region WGLEW_GET_VAR(__WGLEW_ARB_buffer_region) - -#endif /* WGL_ARB_buffer_region */ - -/* --------------------- WGL_ARB_context_flush_control --------------------- */ - -#ifndef WGL_ARB_context_flush_control -#define WGL_ARB_context_flush_control 1 - -#define WGL_CONTEXT_RELEASE_BEHAVIOR_NONE_ARB 0x0000 -#define WGL_CONTEXT_RELEASE_BEHAVIOR_ARB 0x2097 -#define WGL_CONTEXT_RELEASE_BEHAVIOR_FLUSH_ARB 0x2098 - -#define WGLEW_ARB_context_flush_control WGLEW_GET_VAR(__WGLEW_ARB_context_flush_control) - -#endif /* WGL_ARB_context_flush_control */ - -/* ------------------------- WGL_ARB_create_context ------------------------ */ - -#ifndef WGL_ARB_create_context -#define WGL_ARB_create_context 1 - -#define WGL_CONTEXT_DEBUG_BIT_ARB 0x0001 -#define WGL_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB 0x0002 -#define WGL_CONTEXT_MAJOR_VERSION_ARB 0x2091 -#define WGL_CONTEXT_MINOR_VERSION_ARB 0x2092 -#define WGL_CONTEXT_LAYER_PLANE_ARB 0x2093 -#define WGL_CONTEXT_FLAGS_ARB 0x2094 -#define ERROR_INVALID_VERSION_ARB 0x2095 -#define ERROR_INVALID_PROFILE_ARB 0x2096 - -typedef HGLRC (WINAPI * PFNWGLCREATECONTEXTATTRIBSARBPROC) (HDC hDC, HGLRC hShareContext, const int* attribList); - -#define wglCreateContextAttribsARB WGLEW_GET_FUN(__wglewCreateContextAttribsARB) - -#define WGLEW_ARB_create_context WGLEW_GET_VAR(__WGLEW_ARB_create_context) - -#endif /* WGL_ARB_create_context */ - -/* --------------------- WGL_ARB_create_context_profile -------------------- */ - -#ifndef WGL_ARB_create_context_profile -#define WGL_ARB_create_context_profile 1 - -#define WGL_CONTEXT_CORE_PROFILE_BIT_ARB 0x00000001 -#define WGL_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB 0x00000002 -#define WGL_CONTEXT_PROFILE_MASK_ARB 0x9126 - -#define WGLEW_ARB_create_context_profile WGLEW_GET_VAR(__WGLEW_ARB_create_context_profile) - -#endif /* WGL_ARB_create_context_profile */ - -/* ------------------- WGL_ARB_create_context_robustness ------------------- */ - -#ifndef WGL_ARB_create_context_robustness -#define WGL_ARB_create_context_robustness 1 - -#define WGL_CONTEXT_ROBUST_ACCESS_BIT_ARB 0x00000004 -#define WGL_LOSE_CONTEXT_ON_RESET_ARB 0x8252 -#define WGL_CONTEXT_RESET_NOTIFICATION_STRATEGY_ARB 0x8256 -#define WGL_NO_RESET_NOTIFICATION_ARB 0x8261 - -#define WGLEW_ARB_create_context_robustness WGLEW_GET_VAR(__WGLEW_ARB_create_context_robustness) - -#endif /* WGL_ARB_create_context_robustness */ - -/* ----------------------- WGL_ARB_extensions_string ----------------------- */ - -#ifndef WGL_ARB_extensions_string -#define WGL_ARB_extensions_string 1 - -typedef const char* (WINAPI * PFNWGLGETEXTENSIONSSTRINGARBPROC) (HDC hdc); - -#define wglGetExtensionsStringARB WGLEW_GET_FUN(__wglewGetExtensionsStringARB) - -#define WGLEW_ARB_extensions_string WGLEW_GET_VAR(__WGLEW_ARB_extensions_string) - -#endif /* WGL_ARB_extensions_string */ - -/* ------------------------ WGL_ARB_framebuffer_sRGB ----------------------- */ - -#ifndef WGL_ARB_framebuffer_sRGB -#define WGL_ARB_framebuffer_sRGB 1 - -#define WGL_FRAMEBUFFER_SRGB_CAPABLE_ARB 0x20A9 - -#define WGLEW_ARB_framebuffer_sRGB WGLEW_GET_VAR(__WGLEW_ARB_framebuffer_sRGB) - -#endif /* WGL_ARB_framebuffer_sRGB */ - -/* ----------------------- WGL_ARB_make_current_read ----------------------- */ - -#ifndef WGL_ARB_make_current_read -#define WGL_ARB_make_current_read 1 - -#define ERROR_INVALID_PIXEL_TYPE_ARB 0x2043 -#define ERROR_INCOMPATIBLE_DEVICE_CONTEXTS_ARB 0x2054 - -typedef HDC (WINAPI * PFNWGLGETCURRENTREADDCARBPROC) (VOID); -typedef BOOL (WINAPI * PFNWGLMAKECONTEXTCURRENTARBPROC) (HDC hDrawDC, HDC hReadDC, HGLRC hglrc); - -#define wglGetCurrentReadDCARB WGLEW_GET_FUN(__wglewGetCurrentReadDCARB) -#define wglMakeContextCurrentARB WGLEW_GET_FUN(__wglewMakeContextCurrentARB) - -#define WGLEW_ARB_make_current_read WGLEW_GET_VAR(__WGLEW_ARB_make_current_read) - -#endif /* WGL_ARB_make_current_read */ - -/* -------------------------- WGL_ARB_multisample -------------------------- */ - -#ifndef WGL_ARB_multisample -#define WGL_ARB_multisample 1 - -#define WGL_SAMPLE_BUFFERS_ARB 0x2041 -#define WGL_SAMPLES_ARB 0x2042 - -#define WGLEW_ARB_multisample WGLEW_GET_VAR(__WGLEW_ARB_multisample) - -#endif /* WGL_ARB_multisample */ - -/* ---------------------------- WGL_ARB_pbuffer ---------------------------- */ - -#ifndef WGL_ARB_pbuffer -#define WGL_ARB_pbuffer 1 - -#define WGL_DRAW_TO_PBUFFER_ARB 0x202D -#define WGL_MAX_PBUFFER_PIXELS_ARB 0x202E -#define WGL_MAX_PBUFFER_WIDTH_ARB 0x202F -#define WGL_MAX_PBUFFER_HEIGHT_ARB 0x2030 -#define WGL_PBUFFER_LARGEST_ARB 0x2033 -#define WGL_PBUFFER_WIDTH_ARB 0x2034 -#define WGL_PBUFFER_HEIGHT_ARB 0x2035 -#define WGL_PBUFFER_LOST_ARB 0x2036 - -DECLARE_HANDLE(HPBUFFERARB); - -typedef HPBUFFERARB (WINAPI * PFNWGLCREATEPBUFFERARBPROC) (HDC hDC, int iPixelFormat, int iWidth, int iHeight, const int* piAttribList); -typedef BOOL (WINAPI * PFNWGLDESTROYPBUFFERARBPROC) (HPBUFFERARB hPbuffer); -typedef HDC (WINAPI * PFNWGLGETPBUFFERDCARBPROC) (HPBUFFERARB hPbuffer); -typedef BOOL (WINAPI * PFNWGLQUERYPBUFFERARBPROC) (HPBUFFERARB hPbuffer, int iAttribute, int* piValue); -typedef int (WINAPI * PFNWGLRELEASEPBUFFERDCARBPROC) (HPBUFFERARB hPbuffer, HDC hDC); - -#define wglCreatePbufferARB WGLEW_GET_FUN(__wglewCreatePbufferARB) -#define wglDestroyPbufferARB WGLEW_GET_FUN(__wglewDestroyPbufferARB) -#define wglGetPbufferDCARB WGLEW_GET_FUN(__wglewGetPbufferDCARB) -#define wglQueryPbufferARB WGLEW_GET_FUN(__wglewQueryPbufferARB) -#define wglReleasePbufferDCARB WGLEW_GET_FUN(__wglewReleasePbufferDCARB) - -#define WGLEW_ARB_pbuffer WGLEW_GET_VAR(__WGLEW_ARB_pbuffer) - -#endif /* WGL_ARB_pbuffer */ - -/* -------------------------- WGL_ARB_pixel_format ------------------------- */ - -#ifndef WGL_ARB_pixel_format -#define WGL_ARB_pixel_format 1 - -#define WGL_NUMBER_PIXEL_FORMATS_ARB 0x2000 -#define WGL_DRAW_TO_WINDOW_ARB 0x2001 -#define WGL_DRAW_TO_BITMAP_ARB 0x2002 -#define WGL_ACCELERATION_ARB 0x2003 -#define WGL_NEED_PALETTE_ARB 0x2004 -#define WGL_NEED_SYSTEM_PALETTE_ARB 0x2005 -#define WGL_SWAP_LAYER_BUFFERS_ARB 0x2006 -#define WGL_SWAP_METHOD_ARB 0x2007 -#define WGL_NUMBER_OVERLAYS_ARB 0x2008 -#define WGL_NUMBER_UNDERLAYS_ARB 0x2009 -#define WGL_TRANSPARENT_ARB 0x200A -#define WGL_SHARE_DEPTH_ARB 0x200C -#define WGL_SHARE_STENCIL_ARB 0x200D -#define WGL_SHARE_ACCUM_ARB 0x200E -#define WGL_SUPPORT_GDI_ARB 0x200F -#define WGL_SUPPORT_OPENGL_ARB 0x2010 -#define WGL_DOUBLE_BUFFER_ARB 0x2011 -#define WGL_STEREO_ARB 0x2012 -#define WGL_PIXEL_TYPE_ARB 0x2013 -#define WGL_COLOR_BITS_ARB 0x2014 -#define WGL_RED_BITS_ARB 0x2015 -#define WGL_RED_SHIFT_ARB 0x2016 -#define WGL_GREEN_BITS_ARB 0x2017 -#define WGL_GREEN_SHIFT_ARB 0x2018 -#define WGL_BLUE_BITS_ARB 0x2019 -#define WGL_BLUE_SHIFT_ARB 0x201A -#define WGL_ALPHA_BITS_ARB 0x201B -#define WGL_ALPHA_SHIFT_ARB 0x201C -#define WGL_ACCUM_BITS_ARB 0x201D -#define WGL_ACCUM_RED_BITS_ARB 0x201E -#define WGL_ACCUM_GREEN_BITS_ARB 0x201F -#define WGL_ACCUM_BLUE_BITS_ARB 0x2020 -#define WGL_ACCUM_ALPHA_BITS_ARB 0x2021 -#define WGL_DEPTH_BITS_ARB 0x2022 -#define WGL_STENCIL_BITS_ARB 0x2023 -#define WGL_AUX_BUFFERS_ARB 0x2024 -#define WGL_NO_ACCELERATION_ARB 0x2025 -#define WGL_GENERIC_ACCELERATION_ARB 0x2026 -#define WGL_FULL_ACCELERATION_ARB 0x2027 -#define WGL_SWAP_EXCHANGE_ARB 0x2028 -#define WGL_SWAP_COPY_ARB 0x2029 -#define WGL_SWAP_UNDEFINED_ARB 0x202A -#define WGL_TYPE_RGBA_ARB 0x202B -#define WGL_TYPE_COLORINDEX_ARB 0x202C -#define WGL_TRANSPARENT_RED_VALUE_ARB 0x2037 -#define WGL_TRANSPARENT_GREEN_VALUE_ARB 0x2038 -#define WGL_TRANSPARENT_BLUE_VALUE_ARB 0x2039 -#define WGL_TRANSPARENT_ALPHA_VALUE_ARB 0x203A -#define WGL_TRANSPARENT_INDEX_VALUE_ARB 0x203B - -typedef BOOL (WINAPI * PFNWGLCHOOSEPIXELFORMATARBPROC) (HDC hdc, const int* piAttribIList, const FLOAT *pfAttribFList, UINT nMaxFormats, int *piFormats, UINT *nNumFormats); -typedef BOOL (WINAPI * PFNWGLGETPIXELFORMATATTRIBFVARBPROC) (HDC hdc, int iPixelFormat, int iLayerPlane, UINT nAttributes, const int* piAttributes, FLOAT *pfValues); -typedef BOOL (WINAPI * PFNWGLGETPIXELFORMATATTRIBIVARBPROC) (HDC hdc, int iPixelFormat, int iLayerPlane, UINT nAttributes, const int* piAttributes, int *piValues); - -#define wglChoosePixelFormatARB WGLEW_GET_FUN(__wglewChoosePixelFormatARB) -#define wglGetPixelFormatAttribfvARB WGLEW_GET_FUN(__wglewGetPixelFormatAttribfvARB) -#define wglGetPixelFormatAttribivARB WGLEW_GET_FUN(__wglewGetPixelFormatAttribivARB) - -#define WGLEW_ARB_pixel_format WGLEW_GET_VAR(__WGLEW_ARB_pixel_format) - -#endif /* WGL_ARB_pixel_format */ - -/* ----------------------- WGL_ARB_pixel_format_float ---------------------- */ - -#ifndef WGL_ARB_pixel_format_float -#define WGL_ARB_pixel_format_float 1 - -#define WGL_TYPE_RGBA_FLOAT_ARB 0x21A0 - -#define WGLEW_ARB_pixel_format_float WGLEW_GET_VAR(__WGLEW_ARB_pixel_format_float) - -#endif /* WGL_ARB_pixel_format_float */ - -/* ------------------------- WGL_ARB_render_texture ------------------------ */ - -#ifndef WGL_ARB_render_texture -#define WGL_ARB_render_texture 1 - -#define WGL_BIND_TO_TEXTURE_RGB_ARB 0x2070 -#define WGL_BIND_TO_TEXTURE_RGBA_ARB 0x2071 -#define WGL_TEXTURE_FORMAT_ARB 0x2072 -#define WGL_TEXTURE_TARGET_ARB 0x2073 -#define WGL_MIPMAP_TEXTURE_ARB 0x2074 -#define WGL_TEXTURE_RGB_ARB 0x2075 -#define WGL_TEXTURE_RGBA_ARB 0x2076 -#define WGL_NO_TEXTURE_ARB 0x2077 -#define WGL_TEXTURE_CUBE_MAP_ARB 0x2078 -#define WGL_TEXTURE_1D_ARB 0x2079 -#define WGL_TEXTURE_2D_ARB 0x207A -#define WGL_MIPMAP_LEVEL_ARB 0x207B -#define WGL_CUBE_MAP_FACE_ARB 0x207C -#define WGL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB 0x207D -#define WGL_TEXTURE_CUBE_MAP_NEGATIVE_X_ARB 0x207E -#define WGL_TEXTURE_CUBE_MAP_POSITIVE_Y_ARB 0x207F -#define WGL_TEXTURE_CUBE_MAP_NEGATIVE_Y_ARB 0x2080 -#define WGL_TEXTURE_CUBE_MAP_POSITIVE_Z_ARB 0x2081 -#define WGL_TEXTURE_CUBE_MAP_NEGATIVE_Z_ARB 0x2082 -#define WGL_FRONT_LEFT_ARB 0x2083 -#define WGL_FRONT_RIGHT_ARB 0x2084 -#define WGL_BACK_LEFT_ARB 0x2085 -#define WGL_BACK_RIGHT_ARB 0x2086 -#define WGL_AUX0_ARB 0x2087 -#define WGL_AUX1_ARB 0x2088 -#define WGL_AUX2_ARB 0x2089 -#define WGL_AUX3_ARB 0x208A -#define WGL_AUX4_ARB 0x208B -#define WGL_AUX5_ARB 0x208C -#define WGL_AUX6_ARB 0x208D -#define WGL_AUX7_ARB 0x208E -#define WGL_AUX8_ARB 0x208F -#define WGL_AUX9_ARB 0x2090 - -typedef BOOL (WINAPI * PFNWGLBINDTEXIMAGEARBPROC) (HPBUFFERARB hPbuffer, int iBuffer); -typedef BOOL (WINAPI * PFNWGLRELEASETEXIMAGEARBPROC) (HPBUFFERARB hPbuffer, int iBuffer); -typedef BOOL (WINAPI * PFNWGLSETPBUFFERATTRIBARBPROC) (HPBUFFERARB hPbuffer, const int* piAttribList); - -#define wglBindTexImageARB WGLEW_GET_FUN(__wglewBindTexImageARB) -#define wglReleaseTexImageARB WGLEW_GET_FUN(__wglewReleaseTexImageARB) -#define wglSetPbufferAttribARB WGLEW_GET_FUN(__wglewSetPbufferAttribARB) - -#define WGLEW_ARB_render_texture WGLEW_GET_VAR(__WGLEW_ARB_render_texture) - -#endif /* WGL_ARB_render_texture */ - -/* ---------------- WGL_ARB_robustness_application_isolation --------------- */ - -#ifndef WGL_ARB_robustness_application_isolation -#define WGL_ARB_robustness_application_isolation 1 - -#define WGL_CONTEXT_RESET_ISOLATION_BIT_ARB 0x00000008 - -#define WGLEW_ARB_robustness_application_isolation WGLEW_GET_VAR(__WGLEW_ARB_robustness_application_isolation) - -#endif /* WGL_ARB_robustness_application_isolation */ - -/* ---------------- WGL_ARB_robustness_share_group_isolation --------------- */ - -#ifndef WGL_ARB_robustness_share_group_isolation -#define WGL_ARB_robustness_share_group_isolation 1 - -#define WGL_CONTEXT_RESET_ISOLATION_BIT_ARB 0x00000008 - -#define WGLEW_ARB_robustness_share_group_isolation WGLEW_GET_VAR(__WGLEW_ARB_robustness_share_group_isolation) - -#endif /* WGL_ARB_robustness_share_group_isolation */ - -/* ----------------------- WGL_ATI_pixel_format_float ---------------------- */ - -#ifndef WGL_ATI_pixel_format_float -#define WGL_ATI_pixel_format_float 1 - -#define WGL_TYPE_RGBA_FLOAT_ATI 0x21A0 -#define GL_RGBA_FLOAT_MODE_ATI 0x8820 -#define GL_COLOR_CLEAR_UNCLAMPED_VALUE_ATI 0x8835 - -#define WGLEW_ATI_pixel_format_float WGLEW_GET_VAR(__WGLEW_ATI_pixel_format_float) - -#endif /* WGL_ATI_pixel_format_float */ - -/* -------------------- WGL_ATI_render_texture_rectangle ------------------- */ - -#ifndef WGL_ATI_render_texture_rectangle -#define WGL_ATI_render_texture_rectangle 1 - -#define WGL_TEXTURE_RECTANGLE_ATI 0x21A5 - -#define WGLEW_ATI_render_texture_rectangle WGLEW_GET_VAR(__WGLEW_ATI_render_texture_rectangle) - -#endif /* WGL_ATI_render_texture_rectangle */ - -/* ------------------- WGL_EXT_create_context_es2_profile ------------------ */ - -#ifndef WGL_EXT_create_context_es2_profile -#define WGL_EXT_create_context_es2_profile 1 - -#define WGL_CONTEXT_ES2_PROFILE_BIT_EXT 0x00000004 - -#define WGLEW_EXT_create_context_es2_profile WGLEW_GET_VAR(__WGLEW_EXT_create_context_es2_profile) - -#endif /* WGL_EXT_create_context_es2_profile */ - -/* ------------------- WGL_EXT_create_context_es_profile ------------------- */ - -#ifndef WGL_EXT_create_context_es_profile -#define WGL_EXT_create_context_es_profile 1 - -#define WGL_CONTEXT_ES_PROFILE_BIT_EXT 0x00000004 - -#define WGLEW_EXT_create_context_es_profile WGLEW_GET_VAR(__WGLEW_EXT_create_context_es_profile) - -#endif /* WGL_EXT_create_context_es_profile */ - -/* -------------------------- WGL_EXT_depth_float -------------------------- */ - -#ifndef WGL_EXT_depth_float -#define WGL_EXT_depth_float 1 - -#define WGL_DEPTH_FLOAT_EXT 0x2040 - -#define WGLEW_EXT_depth_float WGLEW_GET_VAR(__WGLEW_EXT_depth_float) - -#endif /* WGL_EXT_depth_float */ - -/* ---------------------- WGL_EXT_display_color_table ---------------------- */ - -#ifndef WGL_EXT_display_color_table -#define WGL_EXT_display_color_table 1 - -typedef GLboolean (WINAPI * PFNWGLBINDDISPLAYCOLORTABLEEXTPROC) (GLushort id); -typedef GLboolean (WINAPI * PFNWGLCREATEDISPLAYCOLORTABLEEXTPROC) (GLushort id); -typedef void (WINAPI * PFNWGLDESTROYDISPLAYCOLORTABLEEXTPROC) (GLushort id); -typedef GLboolean (WINAPI * PFNWGLLOADDISPLAYCOLORTABLEEXTPROC) (GLushort* table, GLuint length); - -#define wglBindDisplayColorTableEXT WGLEW_GET_FUN(__wglewBindDisplayColorTableEXT) -#define wglCreateDisplayColorTableEXT WGLEW_GET_FUN(__wglewCreateDisplayColorTableEXT) -#define wglDestroyDisplayColorTableEXT WGLEW_GET_FUN(__wglewDestroyDisplayColorTableEXT) -#define wglLoadDisplayColorTableEXT WGLEW_GET_FUN(__wglewLoadDisplayColorTableEXT) - -#define WGLEW_EXT_display_color_table WGLEW_GET_VAR(__WGLEW_EXT_display_color_table) - -#endif /* WGL_EXT_display_color_table */ - -/* ----------------------- WGL_EXT_extensions_string ----------------------- */ - -#ifndef WGL_EXT_extensions_string -#define WGL_EXT_extensions_string 1 - -typedef const char* (WINAPI * PFNWGLGETEXTENSIONSSTRINGEXTPROC) (void); - -#define wglGetExtensionsStringEXT WGLEW_GET_FUN(__wglewGetExtensionsStringEXT) - -#define WGLEW_EXT_extensions_string WGLEW_GET_VAR(__WGLEW_EXT_extensions_string) - -#endif /* WGL_EXT_extensions_string */ - -/* ------------------------ WGL_EXT_framebuffer_sRGB ----------------------- */ - -#ifndef WGL_EXT_framebuffer_sRGB -#define WGL_EXT_framebuffer_sRGB 1 - -#define WGL_FRAMEBUFFER_SRGB_CAPABLE_EXT 0x20A9 - -#define WGLEW_EXT_framebuffer_sRGB WGLEW_GET_VAR(__WGLEW_EXT_framebuffer_sRGB) - -#endif /* WGL_EXT_framebuffer_sRGB */ - -/* ----------------------- WGL_EXT_make_current_read ----------------------- */ - -#ifndef WGL_EXT_make_current_read -#define WGL_EXT_make_current_read 1 - -#define ERROR_INVALID_PIXEL_TYPE_EXT 0x2043 - -typedef HDC (WINAPI * PFNWGLGETCURRENTREADDCEXTPROC) (VOID); -typedef BOOL (WINAPI * PFNWGLMAKECONTEXTCURRENTEXTPROC) (HDC hDrawDC, HDC hReadDC, HGLRC hglrc); - -#define wglGetCurrentReadDCEXT WGLEW_GET_FUN(__wglewGetCurrentReadDCEXT) -#define wglMakeContextCurrentEXT WGLEW_GET_FUN(__wglewMakeContextCurrentEXT) - -#define WGLEW_EXT_make_current_read WGLEW_GET_VAR(__WGLEW_EXT_make_current_read) - -#endif /* WGL_EXT_make_current_read */ - -/* -------------------------- WGL_EXT_multisample -------------------------- */ - -#ifndef WGL_EXT_multisample -#define WGL_EXT_multisample 1 - -#define WGL_SAMPLE_BUFFERS_EXT 0x2041 -#define WGL_SAMPLES_EXT 0x2042 - -#define WGLEW_EXT_multisample WGLEW_GET_VAR(__WGLEW_EXT_multisample) - -#endif /* WGL_EXT_multisample */ - -/* ---------------------------- WGL_EXT_pbuffer ---------------------------- */ - -#ifndef WGL_EXT_pbuffer -#define WGL_EXT_pbuffer 1 - -#define WGL_DRAW_TO_PBUFFER_EXT 0x202D -#define WGL_MAX_PBUFFER_PIXELS_EXT 0x202E -#define WGL_MAX_PBUFFER_WIDTH_EXT 0x202F -#define WGL_MAX_PBUFFER_HEIGHT_EXT 0x2030 -#define WGL_OPTIMAL_PBUFFER_WIDTH_EXT 0x2031 -#define WGL_OPTIMAL_PBUFFER_HEIGHT_EXT 0x2032 -#define WGL_PBUFFER_LARGEST_EXT 0x2033 -#define WGL_PBUFFER_WIDTH_EXT 0x2034 -#define WGL_PBUFFER_HEIGHT_EXT 0x2035 - -DECLARE_HANDLE(HPBUFFEREXT); - -typedef HPBUFFEREXT (WINAPI * PFNWGLCREATEPBUFFEREXTPROC) (HDC hDC, int iPixelFormat, int iWidth, int iHeight, const int* piAttribList); -typedef BOOL (WINAPI * PFNWGLDESTROYPBUFFEREXTPROC) (HPBUFFEREXT hPbuffer); -typedef HDC (WINAPI * PFNWGLGETPBUFFERDCEXTPROC) (HPBUFFEREXT hPbuffer); -typedef BOOL (WINAPI * PFNWGLQUERYPBUFFEREXTPROC) (HPBUFFEREXT hPbuffer, int iAttribute, int* piValue); -typedef int (WINAPI * PFNWGLRELEASEPBUFFERDCEXTPROC) (HPBUFFEREXT hPbuffer, HDC hDC); - -#define wglCreatePbufferEXT WGLEW_GET_FUN(__wglewCreatePbufferEXT) -#define wglDestroyPbufferEXT WGLEW_GET_FUN(__wglewDestroyPbufferEXT) -#define wglGetPbufferDCEXT WGLEW_GET_FUN(__wglewGetPbufferDCEXT) -#define wglQueryPbufferEXT WGLEW_GET_FUN(__wglewQueryPbufferEXT) -#define wglReleasePbufferDCEXT WGLEW_GET_FUN(__wglewReleasePbufferDCEXT) - -#define WGLEW_EXT_pbuffer WGLEW_GET_VAR(__WGLEW_EXT_pbuffer) - -#endif /* WGL_EXT_pbuffer */ - -/* -------------------------- WGL_EXT_pixel_format ------------------------- */ - -#ifndef WGL_EXT_pixel_format -#define WGL_EXT_pixel_format 1 - -#define WGL_NUMBER_PIXEL_FORMATS_EXT 0x2000 -#define WGL_DRAW_TO_WINDOW_EXT 0x2001 -#define WGL_DRAW_TO_BITMAP_EXT 0x2002 -#define WGL_ACCELERATION_EXT 0x2003 -#define WGL_NEED_PALETTE_EXT 0x2004 -#define WGL_NEED_SYSTEM_PALETTE_EXT 0x2005 -#define WGL_SWAP_LAYER_BUFFERS_EXT 0x2006 -#define WGL_SWAP_METHOD_EXT 0x2007 -#define WGL_NUMBER_OVERLAYS_EXT 0x2008 -#define WGL_NUMBER_UNDERLAYS_EXT 0x2009 -#define WGL_TRANSPARENT_EXT 0x200A -#define WGL_TRANSPARENT_VALUE_EXT 0x200B -#define WGL_SHARE_DEPTH_EXT 0x200C -#define WGL_SHARE_STENCIL_EXT 0x200D -#define WGL_SHARE_ACCUM_EXT 0x200E -#define WGL_SUPPORT_GDI_EXT 0x200F -#define WGL_SUPPORT_OPENGL_EXT 0x2010 -#define WGL_DOUBLE_BUFFER_EXT 0x2011 -#define WGL_STEREO_EXT 0x2012 -#define WGL_PIXEL_TYPE_EXT 0x2013 -#define WGL_COLOR_BITS_EXT 0x2014 -#define WGL_RED_BITS_EXT 0x2015 -#define WGL_RED_SHIFT_EXT 0x2016 -#define WGL_GREEN_BITS_EXT 0x2017 -#define WGL_GREEN_SHIFT_EXT 0x2018 -#define WGL_BLUE_BITS_EXT 0x2019 -#define WGL_BLUE_SHIFT_EXT 0x201A -#define WGL_ALPHA_BITS_EXT 0x201B -#define WGL_ALPHA_SHIFT_EXT 0x201C -#define WGL_ACCUM_BITS_EXT 0x201D -#define WGL_ACCUM_RED_BITS_EXT 0x201E -#define WGL_ACCUM_GREEN_BITS_EXT 0x201F -#define WGL_ACCUM_BLUE_BITS_EXT 0x2020 -#define WGL_ACCUM_ALPHA_BITS_EXT 0x2021 -#define WGL_DEPTH_BITS_EXT 0x2022 -#define WGL_STENCIL_BITS_EXT 0x2023 -#define WGL_AUX_BUFFERS_EXT 0x2024 -#define WGL_NO_ACCELERATION_EXT 0x2025 -#define WGL_GENERIC_ACCELERATION_EXT 0x2026 -#define WGL_FULL_ACCELERATION_EXT 0x2027 -#define WGL_SWAP_EXCHANGE_EXT 0x2028 -#define WGL_SWAP_COPY_EXT 0x2029 -#define WGL_SWAP_UNDEFINED_EXT 0x202A -#define WGL_TYPE_RGBA_EXT 0x202B -#define WGL_TYPE_COLORINDEX_EXT 0x202C - -typedef BOOL (WINAPI * PFNWGLCHOOSEPIXELFORMATEXTPROC) (HDC hdc, const int* piAttribIList, const FLOAT *pfAttribFList, UINT nMaxFormats, int *piFormats, UINT *nNumFormats); -typedef BOOL (WINAPI * PFNWGLGETPIXELFORMATATTRIBFVEXTPROC) (HDC hdc, int iPixelFormat, int iLayerPlane, UINT nAttributes, int* piAttributes, FLOAT *pfValues); -typedef BOOL (WINAPI * PFNWGLGETPIXELFORMATATTRIBIVEXTPROC) (HDC hdc, int iPixelFormat, int iLayerPlane, UINT nAttributes, int* piAttributes, int *piValues); - -#define wglChoosePixelFormatEXT WGLEW_GET_FUN(__wglewChoosePixelFormatEXT) -#define wglGetPixelFormatAttribfvEXT WGLEW_GET_FUN(__wglewGetPixelFormatAttribfvEXT) -#define wglGetPixelFormatAttribivEXT WGLEW_GET_FUN(__wglewGetPixelFormatAttribivEXT) - -#define WGLEW_EXT_pixel_format WGLEW_GET_VAR(__WGLEW_EXT_pixel_format) - -#endif /* WGL_EXT_pixel_format */ - -/* ------------------- WGL_EXT_pixel_format_packed_float ------------------- */ - -#ifndef WGL_EXT_pixel_format_packed_float -#define WGL_EXT_pixel_format_packed_float 1 - -#define WGL_TYPE_RGBA_UNSIGNED_FLOAT_EXT 0x20A8 - -#define WGLEW_EXT_pixel_format_packed_float WGLEW_GET_VAR(__WGLEW_EXT_pixel_format_packed_float) - -#endif /* WGL_EXT_pixel_format_packed_float */ - -/* -------------------------- WGL_EXT_swap_control ------------------------- */ - -#ifndef WGL_EXT_swap_control -#define WGL_EXT_swap_control 1 - -typedef int (WINAPI * PFNWGLGETSWAPINTERVALEXTPROC) (void); -typedef BOOL (WINAPI * PFNWGLSWAPINTERVALEXTPROC) (int interval); - -#define wglGetSwapIntervalEXT WGLEW_GET_FUN(__wglewGetSwapIntervalEXT) -#define wglSwapIntervalEXT WGLEW_GET_FUN(__wglewSwapIntervalEXT) - -#define WGLEW_EXT_swap_control WGLEW_GET_VAR(__WGLEW_EXT_swap_control) - -#endif /* WGL_EXT_swap_control */ - -/* ----------------------- WGL_EXT_swap_control_tear ----------------------- */ - -#ifndef WGL_EXT_swap_control_tear -#define WGL_EXT_swap_control_tear 1 - -#define WGLEW_EXT_swap_control_tear WGLEW_GET_VAR(__WGLEW_EXT_swap_control_tear) - -#endif /* WGL_EXT_swap_control_tear */ - -/* --------------------- WGL_I3D_digital_video_control --------------------- */ - -#ifndef WGL_I3D_digital_video_control -#define WGL_I3D_digital_video_control 1 - -#define WGL_DIGITAL_VIDEO_CURSOR_ALPHA_FRAMEBUFFER_I3D 0x2050 -#define WGL_DIGITAL_VIDEO_CURSOR_ALPHA_VALUE_I3D 0x2051 -#define WGL_DIGITAL_VIDEO_CURSOR_INCLUDED_I3D 0x2052 -#define WGL_DIGITAL_VIDEO_GAMMA_CORRECTED_I3D 0x2053 - -typedef BOOL (WINAPI * PFNWGLGETDIGITALVIDEOPARAMETERSI3DPROC) (HDC hDC, int iAttribute, int* piValue); -typedef BOOL (WINAPI * PFNWGLSETDIGITALVIDEOPARAMETERSI3DPROC) (HDC hDC, int iAttribute, const int* piValue); - -#define wglGetDigitalVideoParametersI3D WGLEW_GET_FUN(__wglewGetDigitalVideoParametersI3D) -#define wglSetDigitalVideoParametersI3D WGLEW_GET_FUN(__wglewSetDigitalVideoParametersI3D) - -#define WGLEW_I3D_digital_video_control WGLEW_GET_VAR(__WGLEW_I3D_digital_video_control) - -#endif /* WGL_I3D_digital_video_control */ - -/* ----------------------------- WGL_I3D_gamma ----------------------------- */ - -#ifndef WGL_I3D_gamma -#define WGL_I3D_gamma 1 - -#define WGL_GAMMA_TABLE_SIZE_I3D 0x204E -#define WGL_GAMMA_EXCLUDE_DESKTOP_I3D 0x204F - -typedef BOOL (WINAPI * PFNWGLGETGAMMATABLEI3DPROC) (HDC hDC, int iEntries, USHORT* puRed, USHORT *puGreen, USHORT *puBlue); -typedef BOOL (WINAPI * PFNWGLGETGAMMATABLEPARAMETERSI3DPROC) (HDC hDC, int iAttribute, int* piValue); -typedef BOOL (WINAPI * PFNWGLSETGAMMATABLEI3DPROC) (HDC hDC, int iEntries, const USHORT* puRed, const USHORT *puGreen, const USHORT *puBlue); -typedef BOOL (WINAPI * PFNWGLSETGAMMATABLEPARAMETERSI3DPROC) (HDC hDC, int iAttribute, const int* piValue); - -#define wglGetGammaTableI3D WGLEW_GET_FUN(__wglewGetGammaTableI3D) -#define wglGetGammaTableParametersI3D WGLEW_GET_FUN(__wglewGetGammaTableParametersI3D) -#define wglSetGammaTableI3D WGLEW_GET_FUN(__wglewSetGammaTableI3D) -#define wglSetGammaTableParametersI3D WGLEW_GET_FUN(__wglewSetGammaTableParametersI3D) - -#define WGLEW_I3D_gamma WGLEW_GET_VAR(__WGLEW_I3D_gamma) - -#endif /* WGL_I3D_gamma */ - -/* ---------------------------- WGL_I3D_genlock ---------------------------- */ - -#ifndef WGL_I3D_genlock -#define WGL_I3D_genlock 1 - -#define WGL_GENLOCK_SOURCE_MULTIVIEW_I3D 0x2044 -#define WGL_GENLOCK_SOURCE_EXTERNAL_SYNC_I3D 0x2045 -#define WGL_GENLOCK_SOURCE_EXTERNAL_FIELD_I3D 0x2046 -#define WGL_GENLOCK_SOURCE_EXTERNAL_TTL_I3D 0x2047 -#define WGL_GENLOCK_SOURCE_DIGITAL_SYNC_I3D 0x2048 -#define WGL_GENLOCK_SOURCE_DIGITAL_FIELD_I3D 0x2049 -#define WGL_GENLOCK_SOURCE_EDGE_FALLING_I3D 0x204A -#define WGL_GENLOCK_SOURCE_EDGE_RISING_I3D 0x204B -#define WGL_GENLOCK_SOURCE_EDGE_BOTH_I3D 0x204C - -typedef BOOL (WINAPI * PFNWGLDISABLEGENLOCKI3DPROC) (HDC hDC); -typedef BOOL (WINAPI * PFNWGLENABLEGENLOCKI3DPROC) (HDC hDC); -typedef BOOL (WINAPI * PFNWGLGENLOCKSAMPLERATEI3DPROC) (HDC hDC, UINT uRate); -typedef BOOL (WINAPI * PFNWGLGENLOCKSOURCEDELAYI3DPROC) (HDC hDC, UINT uDelay); -typedef BOOL (WINAPI * PFNWGLGENLOCKSOURCEEDGEI3DPROC) (HDC hDC, UINT uEdge); -typedef BOOL (WINAPI * PFNWGLGENLOCKSOURCEI3DPROC) (HDC hDC, UINT uSource); -typedef BOOL (WINAPI * PFNWGLGETGENLOCKSAMPLERATEI3DPROC) (HDC hDC, UINT* uRate); -typedef BOOL (WINAPI * PFNWGLGETGENLOCKSOURCEDELAYI3DPROC) (HDC hDC, UINT* uDelay); -typedef BOOL (WINAPI * PFNWGLGETGENLOCKSOURCEEDGEI3DPROC) (HDC hDC, UINT* uEdge); -typedef BOOL (WINAPI * PFNWGLGETGENLOCKSOURCEI3DPROC) (HDC hDC, UINT* uSource); -typedef BOOL (WINAPI * PFNWGLISENABLEDGENLOCKI3DPROC) (HDC hDC, BOOL* pFlag); -typedef BOOL (WINAPI * PFNWGLQUERYGENLOCKMAXSOURCEDELAYI3DPROC) (HDC hDC, UINT* uMaxLineDelay, UINT *uMaxPixelDelay); - -#define wglDisableGenlockI3D WGLEW_GET_FUN(__wglewDisableGenlockI3D) -#define wglEnableGenlockI3D WGLEW_GET_FUN(__wglewEnableGenlockI3D) -#define wglGenlockSampleRateI3D WGLEW_GET_FUN(__wglewGenlockSampleRateI3D) -#define wglGenlockSourceDelayI3D WGLEW_GET_FUN(__wglewGenlockSourceDelayI3D) -#define wglGenlockSourceEdgeI3D WGLEW_GET_FUN(__wglewGenlockSourceEdgeI3D) -#define wglGenlockSourceI3D WGLEW_GET_FUN(__wglewGenlockSourceI3D) -#define wglGetGenlockSampleRateI3D WGLEW_GET_FUN(__wglewGetGenlockSampleRateI3D) -#define wglGetGenlockSourceDelayI3D WGLEW_GET_FUN(__wglewGetGenlockSourceDelayI3D) -#define wglGetGenlockSourceEdgeI3D WGLEW_GET_FUN(__wglewGetGenlockSourceEdgeI3D) -#define wglGetGenlockSourceI3D WGLEW_GET_FUN(__wglewGetGenlockSourceI3D) -#define wglIsEnabledGenlockI3D WGLEW_GET_FUN(__wglewIsEnabledGenlockI3D) -#define wglQueryGenlockMaxSourceDelayI3D WGLEW_GET_FUN(__wglewQueryGenlockMaxSourceDelayI3D) - -#define WGLEW_I3D_genlock WGLEW_GET_VAR(__WGLEW_I3D_genlock) - -#endif /* WGL_I3D_genlock */ - -/* -------------------------- WGL_I3D_image_buffer ------------------------- */ - -#ifndef WGL_I3D_image_buffer -#define WGL_I3D_image_buffer 1 - -#define WGL_IMAGE_BUFFER_MIN_ACCESS_I3D 0x00000001 -#define WGL_IMAGE_BUFFER_LOCK_I3D 0x00000002 - -typedef BOOL (WINAPI * PFNWGLASSOCIATEIMAGEBUFFEREVENTSI3DPROC) (HDC hdc, HANDLE* pEvent, LPVOID *pAddress, DWORD *pSize, UINT count); -typedef LPVOID (WINAPI * PFNWGLCREATEIMAGEBUFFERI3DPROC) (HDC hDC, DWORD dwSize, UINT uFlags); -typedef BOOL (WINAPI * PFNWGLDESTROYIMAGEBUFFERI3DPROC) (HDC hDC, LPVOID pAddress); -typedef BOOL (WINAPI * PFNWGLRELEASEIMAGEBUFFEREVENTSI3DPROC) (HDC hdc, LPVOID* pAddress, UINT count); - -#define wglAssociateImageBufferEventsI3D WGLEW_GET_FUN(__wglewAssociateImageBufferEventsI3D) -#define wglCreateImageBufferI3D WGLEW_GET_FUN(__wglewCreateImageBufferI3D) -#define wglDestroyImageBufferI3D WGLEW_GET_FUN(__wglewDestroyImageBufferI3D) -#define wglReleaseImageBufferEventsI3D WGLEW_GET_FUN(__wglewReleaseImageBufferEventsI3D) - -#define WGLEW_I3D_image_buffer WGLEW_GET_VAR(__WGLEW_I3D_image_buffer) - -#endif /* WGL_I3D_image_buffer */ - -/* ------------------------ WGL_I3D_swap_frame_lock ------------------------ */ - -#ifndef WGL_I3D_swap_frame_lock -#define WGL_I3D_swap_frame_lock 1 - -typedef BOOL (WINAPI * PFNWGLDISABLEFRAMELOCKI3DPROC) (VOID); -typedef BOOL (WINAPI * PFNWGLENABLEFRAMELOCKI3DPROC) (VOID); -typedef BOOL (WINAPI * PFNWGLISENABLEDFRAMELOCKI3DPROC) (BOOL* pFlag); -typedef BOOL (WINAPI * PFNWGLQUERYFRAMELOCKMASTERI3DPROC) (BOOL* pFlag); - -#define wglDisableFrameLockI3D WGLEW_GET_FUN(__wglewDisableFrameLockI3D) -#define wglEnableFrameLockI3D WGLEW_GET_FUN(__wglewEnableFrameLockI3D) -#define wglIsEnabledFrameLockI3D WGLEW_GET_FUN(__wglewIsEnabledFrameLockI3D) -#define wglQueryFrameLockMasterI3D WGLEW_GET_FUN(__wglewQueryFrameLockMasterI3D) - -#define WGLEW_I3D_swap_frame_lock WGLEW_GET_VAR(__WGLEW_I3D_swap_frame_lock) - -#endif /* WGL_I3D_swap_frame_lock */ - -/* ------------------------ WGL_I3D_swap_frame_usage ----------------------- */ - -#ifndef WGL_I3D_swap_frame_usage -#define WGL_I3D_swap_frame_usage 1 - -typedef BOOL (WINAPI * PFNWGLBEGINFRAMETRACKINGI3DPROC) (void); -typedef BOOL (WINAPI * PFNWGLENDFRAMETRACKINGI3DPROC) (void); -typedef BOOL (WINAPI * PFNWGLGETFRAMEUSAGEI3DPROC) (float* pUsage); -typedef BOOL (WINAPI * PFNWGLQUERYFRAMETRACKINGI3DPROC) (DWORD* pFrameCount, DWORD *pMissedFrames, float *pLastMissedUsage); - -#define wglBeginFrameTrackingI3D WGLEW_GET_FUN(__wglewBeginFrameTrackingI3D) -#define wglEndFrameTrackingI3D WGLEW_GET_FUN(__wglewEndFrameTrackingI3D) -#define wglGetFrameUsageI3D WGLEW_GET_FUN(__wglewGetFrameUsageI3D) -#define wglQueryFrameTrackingI3D WGLEW_GET_FUN(__wglewQueryFrameTrackingI3D) - -#define WGLEW_I3D_swap_frame_usage WGLEW_GET_VAR(__WGLEW_I3D_swap_frame_usage) - -#endif /* WGL_I3D_swap_frame_usage */ - -/* --------------------------- WGL_NV_DX_interop --------------------------- */ - -#ifndef WGL_NV_DX_interop -#define WGL_NV_DX_interop 1 - -#define WGL_ACCESS_READ_ONLY_NV 0x0000 -#define WGL_ACCESS_READ_WRITE_NV 0x0001 -#define WGL_ACCESS_WRITE_DISCARD_NV 0x0002 - -typedef BOOL (WINAPI * PFNWGLDXCLOSEDEVICENVPROC) (HANDLE hDevice); -typedef BOOL (WINAPI * PFNWGLDXLOCKOBJECTSNVPROC) (HANDLE hDevice, GLint count, HANDLE* hObjects); -typedef BOOL (WINAPI * PFNWGLDXOBJECTACCESSNVPROC) (HANDLE hObject, GLenum access); -typedef HANDLE (WINAPI * PFNWGLDXOPENDEVICENVPROC) (void* dxDevice); -typedef HANDLE (WINAPI * PFNWGLDXREGISTEROBJECTNVPROC) (HANDLE hDevice, void* dxObject, GLuint name, GLenum type, GLenum access); -typedef BOOL (WINAPI * PFNWGLDXSETRESOURCESHAREHANDLENVPROC) (void* dxObject, HANDLE shareHandle); -typedef BOOL (WINAPI * PFNWGLDXUNLOCKOBJECTSNVPROC) (HANDLE hDevice, GLint count, HANDLE* hObjects); -typedef BOOL (WINAPI * PFNWGLDXUNREGISTEROBJECTNVPROC) (HANDLE hDevice, HANDLE hObject); - -#define wglDXCloseDeviceNV WGLEW_GET_FUN(__wglewDXCloseDeviceNV) -#define wglDXLockObjectsNV WGLEW_GET_FUN(__wglewDXLockObjectsNV) -#define wglDXObjectAccessNV WGLEW_GET_FUN(__wglewDXObjectAccessNV) -#define wglDXOpenDeviceNV WGLEW_GET_FUN(__wglewDXOpenDeviceNV) -#define wglDXRegisterObjectNV WGLEW_GET_FUN(__wglewDXRegisterObjectNV) -#define wglDXSetResourceShareHandleNV WGLEW_GET_FUN(__wglewDXSetResourceShareHandleNV) -#define wglDXUnlockObjectsNV WGLEW_GET_FUN(__wglewDXUnlockObjectsNV) -#define wglDXUnregisterObjectNV WGLEW_GET_FUN(__wglewDXUnregisterObjectNV) - -#define WGLEW_NV_DX_interop WGLEW_GET_VAR(__WGLEW_NV_DX_interop) - -#endif /* WGL_NV_DX_interop */ - -/* --------------------------- WGL_NV_DX_interop2 -------------------------- */ - -#ifndef WGL_NV_DX_interop2 -#define WGL_NV_DX_interop2 1 - -#define WGLEW_NV_DX_interop2 WGLEW_GET_VAR(__WGLEW_NV_DX_interop2) - -#endif /* WGL_NV_DX_interop2 */ - -/* --------------------------- WGL_NV_copy_image --------------------------- */ - -#ifndef WGL_NV_copy_image -#define WGL_NV_copy_image 1 - -typedef BOOL (WINAPI * PFNWGLCOPYIMAGESUBDATANVPROC) (HGLRC hSrcRC, GLuint srcName, GLenum srcTarget, GLint srcLevel, GLint srcX, GLint srcY, GLint srcZ, HGLRC hDstRC, GLuint dstName, GLenum dstTarget, GLint dstLevel, GLint dstX, GLint dstY, GLint dstZ, GLsizei width, GLsizei height, GLsizei depth); - -#define wglCopyImageSubDataNV WGLEW_GET_FUN(__wglewCopyImageSubDataNV) - -#define WGLEW_NV_copy_image WGLEW_GET_VAR(__WGLEW_NV_copy_image) - -#endif /* WGL_NV_copy_image */ - -/* ------------------------ WGL_NV_delay_before_swap ----------------------- */ - -#ifndef WGL_NV_delay_before_swap -#define WGL_NV_delay_before_swap 1 - -typedef BOOL (WINAPI * PFNWGLDELAYBEFORESWAPNVPROC) (HDC hDC, GLfloat seconds); - -#define wglDelayBeforeSwapNV WGLEW_GET_FUN(__wglewDelayBeforeSwapNV) - -#define WGLEW_NV_delay_before_swap WGLEW_GET_VAR(__WGLEW_NV_delay_before_swap) - -#endif /* WGL_NV_delay_before_swap */ - -/* -------------------------- WGL_NV_float_buffer -------------------------- */ - -#ifndef WGL_NV_float_buffer -#define WGL_NV_float_buffer 1 - -#define WGL_FLOAT_COMPONENTS_NV 0x20B0 -#define WGL_BIND_TO_TEXTURE_RECTANGLE_FLOAT_R_NV 0x20B1 -#define WGL_BIND_TO_TEXTURE_RECTANGLE_FLOAT_RG_NV 0x20B2 -#define WGL_BIND_TO_TEXTURE_RECTANGLE_FLOAT_RGB_NV 0x20B3 -#define WGL_BIND_TO_TEXTURE_RECTANGLE_FLOAT_RGBA_NV 0x20B4 -#define WGL_TEXTURE_FLOAT_R_NV 0x20B5 -#define WGL_TEXTURE_FLOAT_RG_NV 0x20B6 -#define WGL_TEXTURE_FLOAT_RGB_NV 0x20B7 -#define WGL_TEXTURE_FLOAT_RGBA_NV 0x20B8 - -#define WGLEW_NV_float_buffer WGLEW_GET_VAR(__WGLEW_NV_float_buffer) - -#endif /* WGL_NV_float_buffer */ - -/* -------------------------- WGL_NV_gpu_affinity -------------------------- */ - -#ifndef WGL_NV_gpu_affinity -#define WGL_NV_gpu_affinity 1 - -#define WGL_ERROR_INCOMPATIBLE_AFFINITY_MASKS_NV 0x20D0 -#define WGL_ERROR_MISSING_AFFINITY_MASK_NV 0x20D1 - -DECLARE_HANDLE(HGPUNV); -typedef struct _GPU_DEVICE { - DWORD cb; - CHAR DeviceName[32]; - CHAR DeviceString[128]; - DWORD Flags; - RECT rcVirtualScreen; -} GPU_DEVICE, *PGPU_DEVICE; - -typedef HDC (WINAPI * PFNWGLCREATEAFFINITYDCNVPROC) (const HGPUNV *phGpuList); -typedef BOOL (WINAPI * PFNWGLDELETEDCNVPROC) (HDC hdc); -typedef BOOL (WINAPI * PFNWGLENUMGPUDEVICESNVPROC) (HGPUNV hGpu, UINT iDeviceIndex, PGPU_DEVICE lpGpuDevice); -typedef BOOL (WINAPI * PFNWGLENUMGPUSFROMAFFINITYDCNVPROC) (HDC hAffinityDC, UINT iGpuIndex, HGPUNV *hGpu); -typedef BOOL (WINAPI * PFNWGLENUMGPUSNVPROC) (UINT iGpuIndex, HGPUNV *phGpu); - -#define wglCreateAffinityDCNV WGLEW_GET_FUN(__wglewCreateAffinityDCNV) -#define wglDeleteDCNV WGLEW_GET_FUN(__wglewDeleteDCNV) -#define wglEnumGpuDevicesNV WGLEW_GET_FUN(__wglewEnumGpuDevicesNV) -#define wglEnumGpusFromAffinityDCNV WGLEW_GET_FUN(__wglewEnumGpusFromAffinityDCNV) -#define wglEnumGpusNV WGLEW_GET_FUN(__wglewEnumGpusNV) - -#define WGLEW_NV_gpu_affinity WGLEW_GET_VAR(__WGLEW_NV_gpu_affinity) - -#endif /* WGL_NV_gpu_affinity */ - -/* ---------------------- WGL_NV_multisample_coverage ---------------------- */ - -#ifndef WGL_NV_multisample_coverage -#define WGL_NV_multisample_coverage 1 - -#define WGL_COVERAGE_SAMPLES_NV 0x2042 -#define WGL_COLOR_SAMPLES_NV 0x20B9 - -#define WGLEW_NV_multisample_coverage WGLEW_GET_VAR(__WGLEW_NV_multisample_coverage) - -#endif /* WGL_NV_multisample_coverage */ - -/* -------------------------- WGL_NV_present_video ------------------------- */ - -#ifndef WGL_NV_present_video -#define WGL_NV_present_video 1 - -#define WGL_NUM_VIDEO_SLOTS_NV 0x20F0 - -DECLARE_HANDLE(HVIDEOOUTPUTDEVICENV); - -typedef BOOL (WINAPI * PFNWGLBINDVIDEODEVICENVPROC) (HDC hDc, unsigned int uVideoSlot, HVIDEOOUTPUTDEVICENV hVideoDevice, const int* piAttribList); -typedef int (WINAPI * PFNWGLENUMERATEVIDEODEVICESNVPROC) (HDC hDc, HVIDEOOUTPUTDEVICENV* phDeviceList); -typedef BOOL (WINAPI * PFNWGLQUERYCURRENTCONTEXTNVPROC) (int iAttribute, int* piValue); - -#define wglBindVideoDeviceNV WGLEW_GET_FUN(__wglewBindVideoDeviceNV) -#define wglEnumerateVideoDevicesNV WGLEW_GET_FUN(__wglewEnumerateVideoDevicesNV) -#define wglQueryCurrentContextNV WGLEW_GET_FUN(__wglewQueryCurrentContextNV) - -#define WGLEW_NV_present_video WGLEW_GET_VAR(__WGLEW_NV_present_video) - -#endif /* WGL_NV_present_video */ - -/* ---------------------- WGL_NV_render_depth_texture ---------------------- */ - -#ifndef WGL_NV_render_depth_texture -#define WGL_NV_render_depth_texture 1 - -#define WGL_NO_TEXTURE_ARB 0x2077 -#define WGL_BIND_TO_TEXTURE_DEPTH_NV 0x20A3 -#define WGL_BIND_TO_TEXTURE_RECTANGLE_DEPTH_NV 0x20A4 -#define WGL_DEPTH_TEXTURE_FORMAT_NV 0x20A5 -#define WGL_TEXTURE_DEPTH_COMPONENT_NV 0x20A6 -#define WGL_DEPTH_COMPONENT_NV 0x20A7 - -#define WGLEW_NV_render_depth_texture WGLEW_GET_VAR(__WGLEW_NV_render_depth_texture) - -#endif /* WGL_NV_render_depth_texture */ - -/* -------------------- WGL_NV_render_texture_rectangle -------------------- */ - -#ifndef WGL_NV_render_texture_rectangle -#define WGL_NV_render_texture_rectangle 1 - -#define WGL_BIND_TO_TEXTURE_RECTANGLE_RGB_NV 0x20A0 -#define WGL_BIND_TO_TEXTURE_RECTANGLE_RGBA_NV 0x20A1 -#define WGL_TEXTURE_RECTANGLE_NV 0x20A2 - -#define WGLEW_NV_render_texture_rectangle WGLEW_GET_VAR(__WGLEW_NV_render_texture_rectangle) - -#endif /* WGL_NV_render_texture_rectangle */ - -/* --------------------------- WGL_NV_swap_group --------------------------- */ - -#ifndef WGL_NV_swap_group -#define WGL_NV_swap_group 1 - -typedef BOOL (WINAPI * PFNWGLBINDSWAPBARRIERNVPROC) (GLuint group, GLuint barrier); -typedef BOOL (WINAPI * PFNWGLJOINSWAPGROUPNVPROC) (HDC hDC, GLuint group); -typedef BOOL (WINAPI * PFNWGLQUERYFRAMECOUNTNVPROC) (HDC hDC, GLuint* count); -typedef BOOL (WINAPI * PFNWGLQUERYMAXSWAPGROUPSNVPROC) (HDC hDC, GLuint* maxGroups, GLuint *maxBarriers); -typedef BOOL (WINAPI * PFNWGLQUERYSWAPGROUPNVPROC) (HDC hDC, GLuint* group, GLuint *barrier); -typedef BOOL (WINAPI * PFNWGLRESETFRAMECOUNTNVPROC) (HDC hDC); - -#define wglBindSwapBarrierNV WGLEW_GET_FUN(__wglewBindSwapBarrierNV) -#define wglJoinSwapGroupNV WGLEW_GET_FUN(__wglewJoinSwapGroupNV) -#define wglQueryFrameCountNV WGLEW_GET_FUN(__wglewQueryFrameCountNV) -#define wglQueryMaxSwapGroupsNV WGLEW_GET_FUN(__wglewQueryMaxSwapGroupsNV) -#define wglQuerySwapGroupNV WGLEW_GET_FUN(__wglewQuerySwapGroupNV) -#define wglResetFrameCountNV WGLEW_GET_FUN(__wglewResetFrameCountNV) - -#define WGLEW_NV_swap_group WGLEW_GET_VAR(__WGLEW_NV_swap_group) - -#endif /* WGL_NV_swap_group */ - -/* ----------------------- WGL_NV_vertex_array_range ----------------------- */ - -#ifndef WGL_NV_vertex_array_range -#define WGL_NV_vertex_array_range 1 - -typedef void * (WINAPI * PFNWGLALLOCATEMEMORYNVPROC) (GLsizei size, GLfloat readFrequency, GLfloat writeFrequency, GLfloat priority); -typedef void (WINAPI * PFNWGLFREEMEMORYNVPROC) (void *pointer); - -#define wglAllocateMemoryNV WGLEW_GET_FUN(__wglewAllocateMemoryNV) -#define wglFreeMemoryNV WGLEW_GET_FUN(__wglewFreeMemoryNV) - -#define WGLEW_NV_vertex_array_range WGLEW_GET_VAR(__WGLEW_NV_vertex_array_range) - -#endif /* WGL_NV_vertex_array_range */ - -/* -------------------------- WGL_NV_video_capture ------------------------- */ - -#ifndef WGL_NV_video_capture -#define WGL_NV_video_capture 1 - -#define WGL_UNIQUE_ID_NV 0x20CE -#define WGL_NUM_VIDEO_CAPTURE_SLOTS_NV 0x20CF - -DECLARE_HANDLE(HVIDEOINPUTDEVICENV); - -typedef BOOL (WINAPI * PFNWGLBINDVIDEOCAPTUREDEVICENVPROC) (UINT uVideoSlot, HVIDEOINPUTDEVICENV hDevice); -typedef UINT (WINAPI * PFNWGLENUMERATEVIDEOCAPTUREDEVICESNVPROC) (HDC hDc, HVIDEOINPUTDEVICENV* phDeviceList); -typedef BOOL (WINAPI * PFNWGLLOCKVIDEOCAPTUREDEVICENVPROC) (HDC hDc, HVIDEOINPUTDEVICENV hDevice); -typedef BOOL (WINAPI * PFNWGLQUERYVIDEOCAPTUREDEVICENVPROC) (HDC hDc, HVIDEOINPUTDEVICENV hDevice, int iAttribute, int* piValue); -typedef BOOL (WINAPI * PFNWGLRELEASEVIDEOCAPTUREDEVICENVPROC) (HDC hDc, HVIDEOINPUTDEVICENV hDevice); - -#define wglBindVideoCaptureDeviceNV WGLEW_GET_FUN(__wglewBindVideoCaptureDeviceNV) -#define wglEnumerateVideoCaptureDevicesNV WGLEW_GET_FUN(__wglewEnumerateVideoCaptureDevicesNV) -#define wglLockVideoCaptureDeviceNV WGLEW_GET_FUN(__wglewLockVideoCaptureDeviceNV) -#define wglQueryVideoCaptureDeviceNV WGLEW_GET_FUN(__wglewQueryVideoCaptureDeviceNV) -#define wglReleaseVideoCaptureDeviceNV WGLEW_GET_FUN(__wglewReleaseVideoCaptureDeviceNV) - -#define WGLEW_NV_video_capture WGLEW_GET_VAR(__WGLEW_NV_video_capture) - -#endif /* WGL_NV_video_capture */ - -/* -------------------------- WGL_NV_video_output -------------------------- */ - -#ifndef WGL_NV_video_output -#define WGL_NV_video_output 1 - -#define WGL_BIND_TO_VIDEO_RGB_NV 0x20C0 -#define WGL_BIND_TO_VIDEO_RGBA_NV 0x20C1 -#define WGL_BIND_TO_VIDEO_RGB_AND_DEPTH_NV 0x20C2 -#define WGL_VIDEO_OUT_COLOR_NV 0x20C3 -#define WGL_VIDEO_OUT_ALPHA_NV 0x20C4 -#define WGL_VIDEO_OUT_DEPTH_NV 0x20C5 -#define WGL_VIDEO_OUT_COLOR_AND_ALPHA_NV 0x20C6 -#define WGL_VIDEO_OUT_COLOR_AND_DEPTH_NV 0x20C7 -#define WGL_VIDEO_OUT_FRAME 0x20C8 -#define WGL_VIDEO_OUT_FIELD_1 0x20C9 -#define WGL_VIDEO_OUT_FIELD_2 0x20CA -#define WGL_VIDEO_OUT_STACKED_FIELDS_1_2 0x20CB -#define WGL_VIDEO_OUT_STACKED_FIELDS_2_1 0x20CC - -DECLARE_HANDLE(HPVIDEODEV); - -typedef BOOL (WINAPI * PFNWGLBINDVIDEOIMAGENVPROC) (HPVIDEODEV hVideoDevice, HPBUFFERARB hPbuffer, int iVideoBuffer); -typedef BOOL (WINAPI * PFNWGLGETVIDEODEVICENVPROC) (HDC hDC, int numDevices, HPVIDEODEV* hVideoDevice); -typedef BOOL (WINAPI * PFNWGLGETVIDEOINFONVPROC) (HPVIDEODEV hpVideoDevice, unsigned long* pulCounterOutputPbuffer, unsigned long *pulCounterOutputVideo); -typedef BOOL (WINAPI * PFNWGLRELEASEVIDEODEVICENVPROC) (HPVIDEODEV hVideoDevice); -typedef BOOL (WINAPI * PFNWGLRELEASEVIDEOIMAGENVPROC) (HPBUFFERARB hPbuffer, int iVideoBuffer); -typedef BOOL (WINAPI * PFNWGLSENDPBUFFERTOVIDEONVPROC) (HPBUFFERARB hPbuffer, int iBufferType, unsigned long* pulCounterPbuffer, BOOL bBlock); - -#define wglBindVideoImageNV WGLEW_GET_FUN(__wglewBindVideoImageNV) -#define wglGetVideoDeviceNV WGLEW_GET_FUN(__wglewGetVideoDeviceNV) -#define wglGetVideoInfoNV WGLEW_GET_FUN(__wglewGetVideoInfoNV) -#define wglReleaseVideoDeviceNV WGLEW_GET_FUN(__wglewReleaseVideoDeviceNV) -#define wglReleaseVideoImageNV WGLEW_GET_FUN(__wglewReleaseVideoImageNV) -#define wglSendPbufferToVideoNV WGLEW_GET_FUN(__wglewSendPbufferToVideoNV) - -#define WGLEW_NV_video_output WGLEW_GET_VAR(__WGLEW_NV_video_output) - -#endif /* WGL_NV_video_output */ - -/* -------------------------- WGL_OML_sync_control ------------------------- */ - -#ifndef WGL_OML_sync_control -#define WGL_OML_sync_control 1 - -typedef BOOL (WINAPI * PFNWGLGETMSCRATEOMLPROC) (HDC hdc, INT32* numerator, INT32 *denominator); -typedef BOOL (WINAPI * PFNWGLGETSYNCVALUESOMLPROC) (HDC hdc, INT64* ust, INT64 *msc, INT64 *sbc); -typedef INT64 (WINAPI * PFNWGLSWAPBUFFERSMSCOMLPROC) (HDC hdc, INT64 target_msc, INT64 divisor, INT64 remainder); -typedef INT64 (WINAPI * PFNWGLSWAPLAYERBUFFERSMSCOMLPROC) (HDC hdc, INT fuPlanes, INT64 target_msc, INT64 divisor, INT64 remainder); -typedef BOOL (WINAPI * PFNWGLWAITFORMSCOMLPROC) (HDC hdc, INT64 target_msc, INT64 divisor, INT64 remainder, INT64* ust, INT64 *msc, INT64 *sbc); -typedef BOOL (WINAPI * PFNWGLWAITFORSBCOMLPROC) (HDC hdc, INT64 target_sbc, INT64* ust, INT64 *msc, INT64 *sbc); - -#define wglGetMscRateOML WGLEW_GET_FUN(__wglewGetMscRateOML) -#define wglGetSyncValuesOML WGLEW_GET_FUN(__wglewGetSyncValuesOML) -#define wglSwapBuffersMscOML WGLEW_GET_FUN(__wglewSwapBuffersMscOML) -#define wglSwapLayerBuffersMscOML WGLEW_GET_FUN(__wglewSwapLayerBuffersMscOML) -#define wglWaitForMscOML WGLEW_GET_FUN(__wglewWaitForMscOML) -#define wglWaitForSbcOML WGLEW_GET_FUN(__wglewWaitForSbcOML) - -#define WGLEW_OML_sync_control WGLEW_GET_VAR(__WGLEW_OML_sync_control) - -#endif /* WGL_OML_sync_control */ - -/* ------------------------------------------------------------------------- */ - -#define WGLEW_FUN_EXPORT GLEW_FUN_EXPORT -#define WGLEW_VAR_EXPORT GLEW_VAR_EXPORT - -WGLEW_FUN_EXPORT PFNWGLSETSTEREOEMITTERSTATE3DLPROC __wglewSetStereoEmitterState3DL; - -WGLEW_FUN_EXPORT PFNWGLBLITCONTEXTFRAMEBUFFERAMDPROC __wglewBlitContextFramebufferAMD; -WGLEW_FUN_EXPORT PFNWGLCREATEASSOCIATEDCONTEXTAMDPROC __wglewCreateAssociatedContextAMD; -WGLEW_FUN_EXPORT PFNWGLCREATEASSOCIATEDCONTEXTATTRIBSAMDPROC __wglewCreateAssociatedContextAttribsAMD; -WGLEW_FUN_EXPORT PFNWGLDELETEASSOCIATEDCONTEXTAMDPROC __wglewDeleteAssociatedContextAMD; -WGLEW_FUN_EXPORT PFNWGLGETCONTEXTGPUIDAMDPROC __wglewGetContextGPUIDAMD; -WGLEW_FUN_EXPORT PFNWGLGETCURRENTASSOCIATEDCONTEXTAMDPROC __wglewGetCurrentAssociatedContextAMD; -WGLEW_FUN_EXPORT PFNWGLGETGPUIDSAMDPROC __wglewGetGPUIDsAMD; -WGLEW_FUN_EXPORT PFNWGLGETGPUINFOAMDPROC __wglewGetGPUInfoAMD; -WGLEW_FUN_EXPORT PFNWGLMAKEASSOCIATEDCONTEXTCURRENTAMDPROC __wglewMakeAssociatedContextCurrentAMD; - -WGLEW_FUN_EXPORT PFNWGLCREATEBUFFERREGIONARBPROC __wglewCreateBufferRegionARB; -WGLEW_FUN_EXPORT PFNWGLDELETEBUFFERREGIONARBPROC __wglewDeleteBufferRegionARB; -WGLEW_FUN_EXPORT PFNWGLRESTOREBUFFERREGIONARBPROC __wglewRestoreBufferRegionARB; -WGLEW_FUN_EXPORT PFNWGLSAVEBUFFERREGIONARBPROC __wglewSaveBufferRegionARB; - -WGLEW_FUN_EXPORT PFNWGLCREATECONTEXTATTRIBSARBPROC __wglewCreateContextAttribsARB; - -WGLEW_FUN_EXPORT PFNWGLGETEXTENSIONSSTRINGARBPROC __wglewGetExtensionsStringARB; - -WGLEW_FUN_EXPORT PFNWGLGETCURRENTREADDCARBPROC __wglewGetCurrentReadDCARB; -WGLEW_FUN_EXPORT PFNWGLMAKECONTEXTCURRENTARBPROC __wglewMakeContextCurrentARB; - -WGLEW_FUN_EXPORT PFNWGLCREATEPBUFFERARBPROC __wglewCreatePbufferARB; -WGLEW_FUN_EXPORT PFNWGLDESTROYPBUFFERARBPROC __wglewDestroyPbufferARB; -WGLEW_FUN_EXPORT PFNWGLGETPBUFFERDCARBPROC __wglewGetPbufferDCARB; -WGLEW_FUN_EXPORT PFNWGLQUERYPBUFFERARBPROC __wglewQueryPbufferARB; -WGLEW_FUN_EXPORT PFNWGLRELEASEPBUFFERDCARBPROC __wglewReleasePbufferDCARB; - -WGLEW_FUN_EXPORT PFNWGLCHOOSEPIXELFORMATARBPROC __wglewChoosePixelFormatARB; -WGLEW_FUN_EXPORT PFNWGLGETPIXELFORMATATTRIBFVARBPROC __wglewGetPixelFormatAttribfvARB; -WGLEW_FUN_EXPORT PFNWGLGETPIXELFORMATATTRIBIVARBPROC __wglewGetPixelFormatAttribivARB; - -WGLEW_FUN_EXPORT PFNWGLBINDTEXIMAGEARBPROC __wglewBindTexImageARB; -WGLEW_FUN_EXPORT PFNWGLRELEASETEXIMAGEARBPROC __wglewReleaseTexImageARB; -WGLEW_FUN_EXPORT PFNWGLSETPBUFFERATTRIBARBPROC __wglewSetPbufferAttribARB; - -WGLEW_FUN_EXPORT PFNWGLBINDDISPLAYCOLORTABLEEXTPROC __wglewBindDisplayColorTableEXT; -WGLEW_FUN_EXPORT PFNWGLCREATEDISPLAYCOLORTABLEEXTPROC __wglewCreateDisplayColorTableEXT; -WGLEW_FUN_EXPORT PFNWGLDESTROYDISPLAYCOLORTABLEEXTPROC __wglewDestroyDisplayColorTableEXT; -WGLEW_FUN_EXPORT PFNWGLLOADDISPLAYCOLORTABLEEXTPROC __wglewLoadDisplayColorTableEXT; - -WGLEW_FUN_EXPORT PFNWGLGETEXTENSIONSSTRINGEXTPROC __wglewGetExtensionsStringEXT; - -WGLEW_FUN_EXPORT PFNWGLGETCURRENTREADDCEXTPROC __wglewGetCurrentReadDCEXT; -WGLEW_FUN_EXPORT PFNWGLMAKECONTEXTCURRENTEXTPROC __wglewMakeContextCurrentEXT; - -WGLEW_FUN_EXPORT PFNWGLCREATEPBUFFEREXTPROC __wglewCreatePbufferEXT; -WGLEW_FUN_EXPORT PFNWGLDESTROYPBUFFEREXTPROC __wglewDestroyPbufferEXT; -WGLEW_FUN_EXPORT PFNWGLGETPBUFFERDCEXTPROC __wglewGetPbufferDCEXT; -WGLEW_FUN_EXPORT PFNWGLQUERYPBUFFEREXTPROC __wglewQueryPbufferEXT; -WGLEW_FUN_EXPORT PFNWGLRELEASEPBUFFERDCEXTPROC __wglewReleasePbufferDCEXT; - -WGLEW_FUN_EXPORT PFNWGLCHOOSEPIXELFORMATEXTPROC __wglewChoosePixelFormatEXT; -WGLEW_FUN_EXPORT PFNWGLGETPIXELFORMATATTRIBFVEXTPROC __wglewGetPixelFormatAttribfvEXT; -WGLEW_FUN_EXPORT PFNWGLGETPIXELFORMATATTRIBIVEXTPROC __wglewGetPixelFormatAttribivEXT; - -WGLEW_FUN_EXPORT PFNWGLGETSWAPINTERVALEXTPROC __wglewGetSwapIntervalEXT; -WGLEW_FUN_EXPORT PFNWGLSWAPINTERVALEXTPROC __wglewSwapIntervalEXT; - -WGLEW_FUN_EXPORT PFNWGLGETDIGITALVIDEOPARAMETERSI3DPROC __wglewGetDigitalVideoParametersI3D; -WGLEW_FUN_EXPORT PFNWGLSETDIGITALVIDEOPARAMETERSI3DPROC __wglewSetDigitalVideoParametersI3D; - -WGLEW_FUN_EXPORT PFNWGLGETGAMMATABLEI3DPROC __wglewGetGammaTableI3D; -WGLEW_FUN_EXPORT PFNWGLGETGAMMATABLEPARAMETERSI3DPROC __wglewGetGammaTableParametersI3D; -WGLEW_FUN_EXPORT PFNWGLSETGAMMATABLEI3DPROC __wglewSetGammaTableI3D; -WGLEW_FUN_EXPORT PFNWGLSETGAMMATABLEPARAMETERSI3DPROC __wglewSetGammaTableParametersI3D; - -WGLEW_FUN_EXPORT PFNWGLDISABLEGENLOCKI3DPROC __wglewDisableGenlockI3D; -WGLEW_FUN_EXPORT PFNWGLENABLEGENLOCKI3DPROC __wglewEnableGenlockI3D; -WGLEW_FUN_EXPORT PFNWGLGENLOCKSAMPLERATEI3DPROC __wglewGenlockSampleRateI3D; -WGLEW_FUN_EXPORT PFNWGLGENLOCKSOURCEDELAYI3DPROC __wglewGenlockSourceDelayI3D; -WGLEW_FUN_EXPORT PFNWGLGENLOCKSOURCEEDGEI3DPROC __wglewGenlockSourceEdgeI3D; -WGLEW_FUN_EXPORT PFNWGLGENLOCKSOURCEI3DPROC __wglewGenlockSourceI3D; -WGLEW_FUN_EXPORT PFNWGLGETGENLOCKSAMPLERATEI3DPROC __wglewGetGenlockSampleRateI3D; -WGLEW_FUN_EXPORT PFNWGLGETGENLOCKSOURCEDELAYI3DPROC __wglewGetGenlockSourceDelayI3D; -WGLEW_FUN_EXPORT PFNWGLGETGENLOCKSOURCEEDGEI3DPROC __wglewGetGenlockSourceEdgeI3D; -WGLEW_FUN_EXPORT PFNWGLGETGENLOCKSOURCEI3DPROC __wglewGetGenlockSourceI3D; -WGLEW_FUN_EXPORT PFNWGLISENABLEDGENLOCKI3DPROC __wglewIsEnabledGenlockI3D; -WGLEW_FUN_EXPORT PFNWGLQUERYGENLOCKMAXSOURCEDELAYI3DPROC __wglewQueryGenlockMaxSourceDelayI3D; - -WGLEW_FUN_EXPORT PFNWGLASSOCIATEIMAGEBUFFEREVENTSI3DPROC __wglewAssociateImageBufferEventsI3D; -WGLEW_FUN_EXPORT PFNWGLCREATEIMAGEBUFFERI3DPROC __wglewCreateImageBufferI3D; -WGLEW_FUN_EXPORT PFNWGLDESTROYIMAGEBUFFERI3DPROC __wglewDestroyImageBufferI3D; -WGLEW_FUN_EXPORT PFNWGLRELEASEIMAGEBUFFEREVENTSI3DPROC __wglewReleaseImageBufferEventsI3D; - -WGLEW_FUN_EXPORT PFNWGLDISABLEFRAMELOCKI3DPROC __wglewDisableFrameLockI3D; -WGLEW_FUN_EXPORT PFNWGLENABLEFRAMELOCKI3DPROC __wglewEnableFrameLockI3D; -WGLEW_FUN_EXPORT PFNWGLISENABLEDFRAMELOCKI3DPROC __wglewIsEnabledFrameLockI3D; -WGLEW_FUN_EXPORT PFNWGLQUERYFRAMELOCKMASTERI3DPROC __wglewQueryFrameLockMasterI3D; - -WGLEW_FUN_EXPORT PFNWGLBEGINFRAMETRACKINGI3DPROC __wglewBeginFrameTrackingI3D; -WGLEW_FUN_EXPORT PFNWGLENDFRAMETRACKINGI3DPROC __wglewEndFrameTrackingI3D; -WGLEW_FUN_EXPORT PFNWGLGETFRAMEUSAGEI3DPROC __wglewGetFrameUsageI3D; -WGLEW_FUN_EXPORT PFNWGLQUERYFRAMETRACKINGI3DPROC __wglewQueryFrameTrackingI3D; - -WGLEW_FUN_EXPORT PFNWGLDXCLOSEDEVICENVPROC __wglewDXCloseDeviceNV; -WGLEW_FUN_EXPORT PFNWGLDXLOCKOBJECTSNVPROC __wglewDXLockObjectsNV; -WGLEW_FUN_EXPORT PFNWGLDXOBJECTACCESSNVPROC __wglewDXObjectAccessNV; -WGLEW_FUN_EXPORT PFNWGLDXOPENDEVICENVPROC __wglewDXOpenDeviceNV; -WGLEW_FUN_EXPORT PFNWGLDXREGISTEROBJECTNVPROC __wglewDXRegisterObjectNV; -WGLEW_FUN_EXPORT PFNWGLDXSETRESOURCESHAREHANDLENVPROC __wglewDXSetResourceShareHandleNV; -WGLEW_FUN_EXPORT PFNWGLDXUNLOCKOBJECTSNVPROC __wglewDXUnlockObjectsNV; -WGLEW_FUN_EXPORT PFNWGLDXUNREGISTEROBJECTNVPROC __wglewDXUnregisterObjectNV; - -WGLEW_FUN_EXPORT PFNWGLCOPYIMAGESUBDATANVPROC __wglewCopyImageSubDataNV; - -WGLEW_FUN_EXPORT PFNWGLDELAYBEFORESWAPNVPROC __wglewDelayBeforeSwapNV; - -WGLEW_FUN_EXPORT PFNWGLCREATEAFFINITYDCNVPROC __wglewCreateAffinityDCNV; -WGLEW_FUN_EXPORT PFNWGLDELETEDCNVPROC __wglewDeleteDCNV; -WGLEW_FUN_EXPORT PFNWGLENUMGPUDEVICESNVPROC __wglewEnumGpuDevicesNV; -WGLEW_FUN_EXPORT PFNWGLENUMGPUSFROMAFFINITYDCNVPROC __wglewEnumGpusFromAffinityDCNV; -WGLEW_FUN_EXPORT PFNWGLENUMGPUSNVPROC __wglewEnumGpusNV; - -WGLEW_FUN_EXPORT PFNWGLBINDVIDEODEVICENVPROC __wglewBindVideoDeviceNV; -WGLEW_FUN_EXPORT PFNWGLENUMERATEVIDEODEVICESNVPROC __wglewEnumerateVideoDevicesNV; -WGLEW_FUN_EXPORT PFNWGLQUERYCURRENTCONTEXTNVPROC __wglewQueryCurrentContextNV; - -WGLEW_FUN_EXPORT PFNWGLBINDSWAPBARRIERNVPROC __wglewBindSwapBarrierNV; -WGLEW_FUN_EXPORT PFNWGLJOINSWAPGROUPNVPROC __wglewJoinSwapGroupNV; -WGLEW_FUN_EXPORT PFNWGLQUERYFRAMECOUNTNVPROC __wglewQueryFrameCountNV; -WGLEW_FUN_EXPORT PFNWGLQUERYMAXSWAPGROUPSNVPROC __wglewQueryMaxSwapGroupsNV; -WGLEW_FUN_EXPORT PFNWGLQUERYSWAPGROUPNVPROC __wglewQuerySwapGroupNV; -WGLEW_FUN_EXPORT PFNWGLRESETFRAMECOUNTNVPROC __wglewResetFrameCountNV; - -WGLEW_FUN_EXPORT PFNWGLALLOCATEMEMORYNVPROC __wglewAllocateMemoryNV; -WGLEW_FUN_EXPORT PFNWGLFREEMEMORYNVPROC __wglewFreeMemoryNV; - -WGLEW_FUN_EXPORT PFNWGLBINDVIDEOCAPTUREDEVICENVPROC __wglewBindVideoCaptureDeviceNV; -WGLEW_FUN_EXPORT PFNWGLENUMERATEVIDEOCAPTUREDEVICESNVPROC __wglewEnumerateVideoCaptureDevicesNV; -WGLEW_FUN_EXPORT PFNWGLLOCKVIDEOCAPTUREDEVICENVPROC __wglewLockVideoCaptureDeviceNV; -WGLEW_FUN_EXPORT PFNWGLQUERYVIDEOCAPTUREDEVICENVPROC __wglewQueryVideoCaptureDeviceNV; -WGLEW_FUN_EXPORT PFNWGLRELEASEVIDEOCAPTUREDEVICENVPROC __wglewReleaseVideoCaptureDeviceNV; - -WGLEW_FUN_EXPORT PFNWGLBINDVIDEOIMAGENVPROC __wglewBindVideoImageNV; -WGLEW_FUN_EXPORT PFNWGLGETVIDEODEVICENVPROC __wglewGetVideoDeviceNV; -WGLEW_FUN_EXPORT PFNWGLGETVIDEOINFONVPROC __wglewGetVideoInfoNV; -WGLEW_FUN_EXPORT PFNWGLRELEASEVIDEODEVICENVPROC __wglewReleaseVideoDeviceNV; -WGLEW_FUN_EXPORT PFNWGLRELEASEVIDEOIMAGENVPROC __wglewReleaseVideoImageNV; -WGLEW_FUN_EXPORT PFNWGLSENDPBUFFERTOVIDEONVPROC __wglewSendPbufferToVideoNV; - -WGLEW_FUN_EXPORT PFNWGLGETMSCRATEOMLPROC __wglewGetMscRateOML; -WGLEW_FUN_EXPORT PFNWGLGETSYNCVALUESOMLPROC __wglewGetSyncValuesOML; -WGLEW_FUN_EXPORT PFNWGLSWAPBUFFERSMSCOMLPROC __wglewSwapBuffersMscOML; -WGLEW_FUN_EXPORT PFNWGLSWAPLAYERBUFFERSMSCOMLPROC __wglewSwapLayerBuffersMscOML; -WGLEW_FUN_EXPORT PFNWGLWAITFORMSCOMLPROC __wglewWaitForMscOML; -WGLEW_FUN_EXPORT PFNWGLWAITFORSBCOMLPROC __wglewWaitForSbcOML; -WGLEW_VAR_EXPORT GLboolean __WGLEW_3DFX_multisample; -WGLEW_VAR_EXPORT GLboolean __WGLEW_3DL_stereo_control; -WGLEW_VAR_EXPORT GLboolean __WGLEW_AMD_gpu_association; -WGLEW_VAR_EXPORT GLboolean __WGLEW_ARB_buffer_region; -WGLEW_VAR_EXPORT GLboolean __WGLEW_ARB_context_flush_control; -WGLEW_VAR_EXPORT GLboolean __WGLEW_ARB_create_context; -WGLEW_VAR_EXPORT GLboolean __WGLEW_ARB_create_context_profile; -WGLEW_VAR_EXPORT GLboolean __WGLEW_ARB_create_context_robustness; -WGLEW_VAR_EXPORT GLboolean __WGLEW_ARB_extensions_string; -WGLEW_VAR_EXPORT GLboolean __WGLEW_ARB_framebuffer_sRGB; -WGLEW_VAR_EXPORT GLboolean __WGLEW_ARB_make_current_read; -WGLEW_VAR_EXPORT GLboolean __WGLEW_ARB_multisample; -WGLEW_VAR_EXPORT GLboolean __WGLEW_ARB_pbuffer; -WGLEW_VAR_EXPORT GLboolean __WGLEW_ARB_pixel_format; -WGLEW_VAR_EXPORT GLboolean __WGLEW_ARB_pixel_format_float; -WGLEW_VAR_EXPORT GLboolean __WGLEW_ARB_render_texture; -WGLEW_VAR_EXPORT GLboolean __WGLEW_ARB_robustness_application_isolation; -WGLEW_VAR_EXPORT GLboolean __WGLEW_ARB_robustness_share_group_isolation; -WGLEW_VAR_EXPORT GLboolean __WGLEW_ATI_pixel_format_float; -WGLEW_VAR_EXPORT GLboolean __WGLEW_ATI_render_texture_rectangle; -WGLEW_VAR_EXPORT GLboolean __WGLEW_EXT_create_context_es2_profile; -WGLEW_VAR_EXPORT GLboolean __WGLEW_EXT_create_context_es_profile; -WGLEW_VAR_EXPORT GLboolean __WGLEW_EXT_depth_float; -WGLEW_VAR_EXPORT GLboolean __WGLEW_EXT_display_color_table; -WGLEW_VAR_EXPORT GLboolean __WGLEW_EXT_extensions_string; -WGLEW_VAR_EXPORT GLboolean __WGLEW_EXT_framebuffer_sRGB; -WGLEW_VAR_EXPORT GLboolean __WGLEW_EXT_make_current_read; -WGLEW_VAR_EXPORT GLboolean __WGLEW_EXT_multisample; -WGLEW_VAR_EXPORT GLboolean __WGLEW_EXT_pbuffer; -WGLEW_VAR_EXPORT GLboolean __WGLEW_EXT_pixel_format; -WGLEW_VAR_EXPORT GLboolean __WGLEW_EXT_pixel_format_packed_float; -WGLEW_VAR_EXPORT GLboolean __WGLEW_EXT_swap_control; -WGLEW_VAR_EXPORT GLboolean __WGLEW_EXT_swap_control_tear; -WGLEW_VAR_EXPORT GLboolean __WGLEW_I3D_digital_video_control; -WGLEW_VAR_EXPORT GLboolean __WGLEW_I3D_gamma; -WGLEW_VAR_EXPORT GLboolean __WGLEW_I3D_genlock; -WGLEW_VAR_EXPORT GLboolean __WGLEW_I3D_image_buffer; -WGLEW_VAR_EXPORT GLboolean __WGLEW_I3D_swap_frame_lock; -WGLEW_VAR_EXPORT GLboolean __WGLEW_I3D_swap_frame_usage; -WGLEW_VAR_EXPORT GLboolean __WGLEW_NV_DX_interop; -WGLEW_VAR_EXPORT GLboolean __WGLEW_NV_DX_interop2; -WGLEW_VAR_EXPORT GLboolean __WGLEW_NV_copy_image; -WGLEW_VAR_EXPORT GLboolean __WGLEW_NV_delay_before_swap; -WGLEW_VAR_EXPORT GLboolean __WGLEW_NV_float_buffer; -WGLEW_VAR_EXPORT GLboolean __WGLEW_NV_gpu_affinity; -WGLEW_VAR_EXPORT GLboolean __WGLEW_NV_multisample_coverage; -WGLEW_VAR_EXPORT GLboolean __WGLEW_NV_present_video; -WGLEW_VAR_EXPORT GLboolean __WGLEW_NV_render_depth_texture; -WGLEW_VAR_EXPORT GLboolean __WGLEW_NV_render_texture_rectangle; -WGLEW_VAR_EXPORT GLboolean __WGLEW_NV_swap_group; -WGLEW_VAR_EXPORT GLboolean __WGLEW_NV_vertex_array_range; -WGLEW_VAR_EXPORT GLboolean __WGLEW_NV_video_capture; -WGLEW_VAR_EXPORT GLboolean __WGLEW_NV_video_output; -WGLEW_VAR_EXPORT GLboolean __WGLEW_OML_sync_control; -/* ------------------------------------------------------------------------- */ - -GLEWAPI GLenum GLEWAPIENTRY wglewInit (); -GLEWAPI GLboolean GLEWAPIENTRY wglewIsSupported (const char *name); - -#ifndef WGLEW_GET_VAR -#define WGLEW_GET_VAR(x) (*(const GLboolean*)&x) -#endif - -#ifndef WGLEW_GET_FUN -#define WGLEW_GET_FUN(x) x -#endif - -GLEWAPI GLboolean GLEWAPIENTRY wglewGetExtension (const char *name); - -#ifdef __cplusplus -} -#endif - -#undef GLEWAPI - -#endif /* __wglew_h__ */ diff --git a/opengl/wglext.h b/opengl/wglext.h deleted file mode 100644 index 3fe2e2df..00000000 --- a/opengl/wglext.h +++ /dev/null @@ -1,929 +0,0 @@ -#ifndef __wglext_h_ -#define __wglext_h_ - -#ifdef __cplusplus -extern "C" { -#endif - -/* -** Copyright (c) 2007-2010 The Khronos Group Inc. -** -** Permission is hereby granted, free of charge, to any person obtaining a -** copy of this software and/or associated documentation files (the -** "Materials"), to deal in the Materials without restriction, including -** without limitation the rights to use, copy, modify, merge, publish, -** distribute, sublicense, and/or sell copies of the Materials, and to -** permit persons to whom the Materials are furnished to do so, subject to -** the following conditions: -** -** The above copyright notice and this permission notice shall be included -** in all copies or substantial portions of the Materials. -** -** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. -** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY -** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, -** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE -** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS. -*/ - -/* Function declaration macros - to move into glplatform.h */ - -#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 */ -/* wglext.h last updated 2011/04/13 */ -/* Current version at http://www.opengl.org/registry/ */ -#define WGL_WGLEXT_VERSION 23 - -#ifndef WGL_ARB_buffer_region -#define WGL_FRONT_COLOR_BUFFER_BIT_ARB 0x00000001 -#define WGL_BACK_COLOR_BUFFER_BIT_ARB 0x00000002 -#define WGL_DEPTH_BUFFER_BIT_ARB 0x00000004 -#define WGL_STENCIL_BUFFER_BIT_ARB 0x00000008 -#endif - -#ifndef WGL_ARB_multisample -#define WGL_SAMPLE_BUFFERS_ARB 0x2041 -#define WGL_SAMPLES_ARB 0x2042 -#endif - -#ifndef WGL_ARB_extensions_string -#endif - -#ifndef WGL_ARB_pixel_format -#define WGL_NUMBER_PIXEL_FORMATS_ARB 0x2000 -#define WGL_DRAW_TO_WINDOW_ARB 0x2001 -#define WGL_DRAW_TO_BITMAP_ARB 0x2002 -#define WGL_ACCELERATION_ARB 0x2003 -#define WGL_NEED_PALETTE_ARB 0x2004 -#define WGL_NEED_SYSTEM_PALETTE_ARB 0x2005 -#define WGL_SWAP_LAYER_BUFFERS_ARB 0x2006 -#define WGL_SWAP_METHOD_ARB 0x2007 -#define WGL_NUMBER_OVERLAYS_ARB 0x2008 -#define WGL_NUMBER_UNDERLAYS_ARB 0x2009 -#define WGL_TRANSPARENT_ARB 0x200A -#define WGL_TRANSPARENT_RED_VALUE_ARB 0x2037 -#define WGL_TRANSPARENT_GREEN_VALUE_ARB 0x2038 -#define WGL_TRANSPARENT_BLUE_VALUE_ARB 0x2039 -#define WGL_TRANSPARENT_ALPHA_VALUE_ARB 0x203A -#define WGL_TRANSPARENT_INDEX_VALUE_ARB 0x203B -#define WGL_SHARE_DEPTH_ARB 0x200C -#define WGL_SHARE_STENCIL_ARB 0x200D -#define WGL_SHARE_ACCUM_ARB 0x200E -#define WGL_SUPPORT_GDI_ARB 0x200F -#define WGL_SUPPORT_OPENGL_ARB 0x2010 -#define WGL_DOUBLE_BUFFER_ARB 0x2011 -#define WGL_STEREO_ARB 0x2012 -#define WGL_PIXEL_TYPE_ARB 0x2013 -#define WGL_COLOR_BITS_ARB 0x2014 -#define WGL_RED_BITS_ARB 0x2015 -#define WGL_RED_SHIFT_ARB 0x2016 -#define WGL_GREEN_BITS_ARB 0x2017 -#define WGL_GREEN_SHIFT_ARB 0x2018 -#define WGL_BLUE_BITS_ARB 0x2019 -#define WGL_BLUE_SHIFT_ARB 0x201A -#define WGL_ALPHA_BITS_ARB 0x201B -#define WGL_ALPHA_SHIFT_ARB 0x201C -#define WGL_ACCUM_BITS_ARB 0x201D -#define WGL_ACCUM_RED_BITS_ARB 0x201E -#define WGL_ACCUM_GREEN_BITS_ARB 0x201F -#define WGL_ACCUM_BLUE_BITS_ARB 0x2020 -#define WGL_ACCUM_ALPHA_BITS_ARB 0x2021 -#define WGL_DEPTH_BITS_ARB 0x2022 -#define WGL_STENCIL_BITS_ARB 0x2023 -#define WGL_AUX_BUFFERS_ARB 0x2024 -#define WGL_NO_ACCELERATION_ARB 0x2025 -#define WGL_GENERIC_ACCELERATION_ARB 0x2026 -#define WGL_FULL_ACCELERATION_ARB 0x2027 -#define WGL_SWAP_EXCHANGE_ARB 0x2028 -#define WGL_SWAP_COPY_ARB 0x2029 -#define WGL_SWAP_UNDEFINED_ARB 0x202A -#define WGL_TYPE_RGBA_ARB 0x202B -#define WGL_TYPE_COLORINDEX_ARB 0x202C -#endif - -#ifndef WGL_ARB_make_current_read -#define ERROR_INVALID_PIXEL_TYPE_ARB 0x2043 -#define ERROR_INCOMPATIBLE_DEVICE_CONTEXTS_ARB 0x2054 -#endif - -#ifndef WGL_ARB_pbuffer -#define WGL_DRAW_TO_PBUFFER_ARB 0x202D -#define WGL_MAX_PBUFFER_PIXELS_ARB 0x202E -#define WGL_MAX_PBUFFER_WIDTH_ARB 0x202F -#define WGL_MAX_PBUFFER_HEIGHT_ARB 0x2030 -#define WGL_PBUFFER_LARGEST_ARB 0x2033 -#define WGL_PBUFFER_WIDTH_ARB 0x2034 -#define WGL_PBUFFER_HEIGHT_ARB 0x2035 -#define WGL_PBUFFER_LOST_ARB 0x2036 -#endif - -#ifndef WGL_ARB_render_texture -#define WGL_BIND_TO_TEXTURE_RGB_ARB 0x2070 -#define WGL_BIND_TO_TEXTURE_RGBA_ARB 0x2071 -#define WGL_TEXTURE_FORMAT_ARB 0x2072 -#define WGL_TEXTURE_TARGET_ARB 0x2073 -#define WGL_MIPMAP_TEXTURE_ARB 0x2074 -#define WGL_TEXTURE_RGB_ARB 0x2075 -#define WGL_TEXTURE_RGBA_ARB 0x2076 -#define WGL_NO_TEXTURE_ARB 0x2077 -#define WGL_TEXTURE_CUBE_MAP_ARB 0x2078 -#define WGL_TEXTURE_1D_ARB 0x2079 -#define WGL_TEXTURE_2D_ARB 0x207A -#define WGL_MIPMAP_LEVEL_ARB 0x207B -#define WGL_CUBE_MAP_FACE_ARB 0x207C -#define WGL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB 0x207D -#define WGL_TEXTURE_CUBE_MAP_NEGATIVE_X_ARB 0x207E -#define WGL_TEXTURE_CUBE_MAP_POSITIVE_Y_ARB 0x207F -#define WGL_TEXTURE_CUBE_MAP_NEGATIVE_Y_ARB 0x2080 -#define WGL_TEXTURE_CUBE_MAP_POSITIVE_Z_ARB 0x2081 -#define WGL_TEXTURE_CUBE_MAP_NEGATIVE_Z_ARB 0x2082 -#define WGL_FRONT_LEFT_ARB 0x2083 -#define WGL_FRONT_RIGHT_ARB 0x2084 -#define WGL_BACK_LEFT_ARB 0x2085 -#define WGL_BACK_RIGHT_ARB 0x2086 -#define WGL_AUX0_ARB 0x2087 -#define WGL_AUX1_ARB 0x2088 -#define WGL_AUX2_ARB 0x2089 -#define WGL_AUX3_ARB 0x208A -#define WGL_AUX4_ARB 0x208B -#define WGL_AUX5_ARB 0x208C -#define WGL_AUX6_ARB 0x208D -#define WGL_AUX7_ARB 0x208E -#define WGL_AUX8_ARB 0x208F -#define WGL_AUX9_ARB 0x2090 -#endif - -#ifndef WGL_ARB_pixel_format_float -#define WGL_TYPE_RGBA_FLOAT_ARB 0x21A0 -#endif - -#ifndef WGL_ARB_framebuffer_sRGB -#define WGL_FRAMEBUFFER_SRGB_CAPABLE_ARB 0x20A9 -#endif - -#ifndef WGL_ARB_create_context -#define WGL_CONTEXT_DEBUG_BIT_ARB 0x00000001 -#define WGL_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB 0x00000002 -#define WGL_CONTEXT_MAJOR_VERSION_ARB 0x2091 -#define WGL_CONTEXT_MINOR_VERSION_ARB 0x2092 -#define WGL_CONTEXT_LAYER_PLANE_ARB 0x2093 -#define WGL_CONTEXT_FLAGS_ARB 0x2094 -#define ERROR_INVALID_VERSION_ARB 0x2095 -#endif - -#ifndef WGL_ARB_create_context_profile -#define WGL_CONTEXT_PROFILE_MASK_ARB 0x9126 -#define WGL_CONTEXT_CORE_PROFILE_BIT_ARB 0x00000001 -#define WGL_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB 0x00000002 -#define ERROR_INVALID_PROFILE_ARB 0x2096 -#endif - -#ifndef WGL_ARB_create_context_robustness -#define WGL_CONTEXT_ROBUST_ACCESS_BIT_ARB 0x00000004 -#define WGL_LOSE_CONTEXT_ON_RESET_ARB 0x8252 -#define WGL_CONTEXT_RESET_NOTIFICATION_STRATEGY_ARB 0x8256 -#define WGL_NO_RESET_NOTIFICATION_ARB 0x8261 -#endif - -#ifndef WGL_EXT_make_current_read -#define ERROR_INVALID_PIXEL_TYPE_EXT 0x2043 -#endif - -#ifndef WGL_EXT_pixel_format -#define WGL_NUMBER_PIXEL_FORMATS_EXT 0x2000 -#define WGL_DRAW_TO_WINDOW_EXT 0x2001 -#define WGL_DRAW_TO_BITMAP_EXT 0x2002 -#define WGL_ACCELERATION_EXT 0x2003 -#define WGL_NEED_PALETTE_EXT 0x2004 -#define WGL_NEED_SYSTEM_PALETTE_EXT 0x2005 -#define WGL_SWAP_LAYER_BUFFERS_EXT 0x2006 -#define WGL_SWAP_METHOD_EXT 0x2007 -#define WGL_NUMBER_OVERLAYS_EXT 0x2008 -#define WGL_NUMBER_UNDERLAYS_EXT 0x2009 -#define WGL_TRANSPARENT_EXT 0x200A -#define WGL_TRANSPARENT_VALUE_EXT 0x200B -#define WGL_SHARE_DEPTH_EXT 0x200C -#define WGL_SHARE_STENCIL_EXT 0x200D -#define WGL_SHARE_ACCUM_EXT 0x200E -#define WGL_SUPPORT_GDI_EXT 0x200F -#define WGL_SUPPORT_OPENGL_EXT 0x2010 -#define WGL_DOUBLE_BUFFER_EXT 0x2011 -#define WGL_STEREO_EXT 0x2012 -#define WGL_PIXEL_TYPE_EXT 0x2013 -#define WGL_COLOR_BITS_EXT 0x2014 -#define WGL_RED_BITS_EXT 0x2015 -#define WGL_RED_SHIFT_EXT 0x2016 -#define WGL_GREEN_BITS_EXT 0x2017 -#define WGL_GREEN_SHIFT_EXT 0x2018 -#define WGL_BLUE_BITS_EXT 0x2019 -#define WGL_BLUE_SHIFT_EXT 0x201A -#define WGL_ALPHA_BITS_EXT 0x201B -#define WGL_ALPHA_SHIFT_EXT 0x201C -#define WGL_ACCUM_BITS_EXT 0x201D -#define WGL_ACCUM_RED_BITS_EXT 0x201E -#define WGL_ACCUM_GREEN_BITS_EXT 0x201F -#define WGL_ACCUM_BLUE_BITS_EXT 0x2020 -#define WGL_ACCUM_ALPHA_BITS_EXT 0x2021 -#define WGL_DEPTH_BITS_EXT 0x2022 -#define WGL_STENCIL_BITS_EXT 0x2023 -#define WGL_AUX_BUFFERS_EXT 0x2024 -#define WGL_NO_ACCELERATION_EXT 0x2025 -#define WGL_GENERIC_ACCELERATION_EXT 0x2026 -#define WGL_FULL_ACCELERATION_EXT 0x2027 -#define WGL_SWAP_EXCHANGE_EXT 0x2028 -#define WGL_SWAP_COPY_EXT 0x2029 -#define WGL_SWAP_UNDEFINED_EXT 0x202A -#define WGL_TYPE_RGBA_EXT 0x202B -#define WGL_TYPE_COLORINDEX_EXT 0x202C -#endif - -#ifndef WGL_EXT_pbuffer -#define WGL_DRAW_TO_PBUFFER_EXT 0x202D -#define WGL_MAX_PBUFFER_PIXELS_EXT 0x202E -#define WGL_MAX_PBUFFER_WIDTH_EXT 0x202F -#define WGL_MAX_PBUFFER_HEIGHT_EXT 0x2030 -#define WGL_OPTIMAL_PBUFFER_WIDTH_EXT 0x2031 -#define WGL_OPTIMAL_PBUFFER_HEIGHT_EXT 0x2032 -#define WGL_PBUFFER_LARGEST_EXT 0x2033 -#define WGL_PBUFFER_WIDTH_EXT 0x2034 -#define WGL_PBUFFER_HEIGHT_EXT 0x2035 -#endif - -#ifndef WGL_EXT_depth_float -#define WGL_DEPTH_FLOAT_EXT 0x2040 -#endif - -#ifndef WGL_3DFX_multisample -#define WGL_SAMPLE_BUFFERS_3DFX 0x2060 -#define WGL_SAMPLES_3DFX 0x2061 -#endif - -#ifndef WGL_EXT_multisample -#define WGL_SAMPLE_BUFFERS_EXT 0x2041 -#define WGL_SAMPLES_EXT 0x2042 -#endif - -#ifndef WGL_I3D_digital_video_control -#define WGL_DIGITAL_VIDEO_CURSOR_ALPHA_FRAMEBUFFER_I3D 0x2050 -#define WGL_DIGITAL_VIDEO_CURSOR_ALPHA_VALUE_I3D 0x2051 -#define WGL_DIGITAL_VIDEO_CURSOR_INCLUDED_I3D 0x2052 -#define WGL_DIGITAL_VIDEO_GAMMA_CORRECTED_I3D 0x2053 -#endif - -#ifndef WGL_I3D_gamma -#define WGL_GAMMA_TABLE_SIZE_I3D 0x204E -#define WGL_GAMMA_EXCLUDE_DESKTOP_I3D 0x204F -#endif - -#ifndef WGL_I3D_genlock -#define WGL_GENLOCK_SOURCE_MULTIVIEW_I3D 0x2044 -#define WGL_GENLOCK_SOURCE_EXTENAL_SYNC_I3D 0x2045 -#define WGL_GENLOCK_SOURCE_EXTENAL_FIELD_I3D 0x2046 -#define WGL_GENLOCK_SOURCE_EXTENAL_TTL_I3D 0x2047 -#define WGL_GENLOCK_SOURCE_DIGITAL_SYNC_I3D 0x2048 -#define WGL_GENLOCK_SOURCE_DIGITAL_FIELD_I3D 0x2049 -#define WGL_GENLOCK_SOURCE_EDGE_FALLING_I3D 0x204A -#define WGL_GENLOCK_SOURCE_EDGE_RISING_I3D 0x204B -#define WGL_GENLOCK_SOURCE_EDGE_BOTH_I3D 0x204C -#endif - -#ifndef WGL_I3D_image_buffer -#define WGL_IMAGE_BUFFER_MIN_ACCESS_I3D 0x00000001 -#define WGL_IMAGE_BUFFER_LOCK_I3D 0x00000002 -#endif - -#ifndef WGL_I3D_swap_frame_lock -#endif - -#ifndef WGL_NV_render_depth_texture -#define WGL_BIND_TO_TEXTURE_DEPTH_NV 0x20A3 -#define WGL_BIND_TO_TEXTURE_RECTANGLE_DEPTH_NV 0x20A4 -#define WGL_DEPTH_TEXTURE_FORMAT_NV 0x20A5 -#define WGL_TEXTURE_DEPTH_COMPONENT_NV 0x20A6 -#define WGL_DEPTH_COMPONENT_NV 0x20A7 -#endif - -#ifndef WGL_NV_render_texture_rectangle -#define WGL_BIND_TO_TEXTURE_RECTANGLE_RGB_NV 0x20A0 -#define WGL_BIND_TO_TEXTURE_RECTANGLE_RGBA_NV 0x20A1 -#define WGL_TEXTURE_RECTANGLE_NV 0x20A2 -#endif - -#ifndef WGL_ATI_pixel_format_float -#define WGL_TYPE_RGBA_FLOAT_ATI 0x21A0 -#endif - -#ifndef WGL_NV_float_buffer -#define WGL_FLOAT_COMPONENTS_NV 0x20B0 -#define WGL_BIND_TO_TEXTURE_RECTANGLE_FLOAT_R_NV 0x20B1 -#define WGL_BIND_TO_TEXTURE_RECTANGLE_FLOAT_RG_NV 0x20B2 -#define WGL_BIND_TO_TEXTURE_RECTANGLE_FLOAT_RGB_NV 0x20B3 -#define WGL_BIND_TO_TEXTURE_RECTANGLE_FLOAT_RGBA_NV 0x20B4 -#define WGL_TEXTURE_FLOAT_R_NV 0x20B5 -#define WGL_TEXTURE_FLOAT_RG_NV 0x20B6 -#define WGL_TEXTURE_FLOAT_RGB_NV 0x20B7 -#define WGL_TEXTURE_FLOAT_RGBA_NV 0x20B8 -#endif - -#ifndef WGL_3DL_stereo_control -#define WGL_STEREO_EMITTER_ENABLE_3DL 0x2055 -#define WGL_STEREO_EMITTER_DISABLE_3DL 0x2056 -#define WGL_STEREO_POLARITY_NORMAL_3DL 0x2057 -#define WGL_STEREO_POLARITY_INVERT_3DL 0x2058 -#endif - -#ifndef WGL_EXT_pixel_format_packed_float -#define WGL_TYPE_RGBA_UNSIGNED_FLOAT_EXT 0x20A8 -#endif - -#ifndef WGL_EXT_framebuffer_sRGB -#define WGL_FRAMEBUFFER_SRGB_CAPABLE_EXT 0x20A9 -#endif - -#ifndef WGL_NV_present_video -#define WGL_NUM_VIDEO_SLOTS_NV 0x20F0 -#endif - -#ifndef WGL_NV_video_out -#define WGL_BIND_TO_VIDEO_RGB_NV 0x20C0 -#define WGL_BIND_TO_VIDEO_RGBA_NV 0x20C1 -#define WGL_BIND_TO_VIDEO_RGB_AND_DEPTH_NV 0x20C2 -#define WGL_VIDEO_OUT_COLOR_NV 0x20C3 -#define WGL_VIDEO_OUT_ALPHA_NV 0x20C4 -#define WGL_VIDEO_OUT_DEPTH_NV 0x20C5 -#define WGL_VIDEO_OUT_COLOR_AND_ALPHA_NV 0x20C6 -#define WGL_VIDEO_OUT_COLOR_AND_DEPTH_NV 0x20C7 -#define WGL_VIDEO_OUT_FRAME 0x20C8 -#define WGL_VIDEO_OUT_FIELD_1 0x20C9 -#define WGL_VIDEO_OUT_FIELD_2 0x20CA -#define WGL_VIDEO_OUT_STACKED_FIELDS_1_2 0x20CB -#define WGL_VIDEO_OUT_STACKED_FIELDS_2_1 0x20CC -#endif - -#ifndef WGL_NV_swap_group -#endif - -#ifndef WGL_NV_gpu_affinity -#define WGL_ERROR_INCOMPATIBLE_AFFINITY_MASKS_NV 0x20D0 -#define WGL_ERROR_MISSING_AFFINITY_MASK_NV 0x20D1 -#endif - -#ifndef WGL_AMD_gpu_association -#define WGL_GPU_VENDOR_AMD 0x1F00 -#define WGL_GPU_RENDERER_STRING_AMD 0x1F01 -#define WGL_GPU_OPENGL_VERSION_STRING_AMD 0x1F02 -#define WGL_GPU_FASTEST_TARGET_GPUS_AMD 0x21A2 -#define WGL_GPU_RAM_AMD 0x21A3 -#define WGL_GPU_CLOCK_AMD 0x21A4 -#define WGL_GPU_NUM_PIPES_AMD 0x21A5 -#define WGL_GPU_NUM_SIMD_AMD 0x21A6 -#define WGL_GPU_NUM_RB_AMD 0x21A7 -#define WGL_GPU_NUM_SPI_AMD 0x21A8 -#endif - -#ifndef WGL_NV_video_capture -#define WGL_UNIQUE_ID_NV 0x20CE -#define WGL_NUM_VIDEO_CAPTURE_SLOTS_NV 0x20CF -#endif - -#ifndef WGL_NV_copy_image -#endif - -#ifndef WGL_NV_multisample_coverage -#define WGL_COVERAGE_SAMPLES_NV 0x2042 -#define WGL_COLOR_SAMPLES_NV 0x20B9 -#endif - -#ifndef WGL_EXT_create_context_es2_profile -#define WGL_CONTEXT_ES2_PROFILE_BIT_EXT 0x00000004 -#endif - -#ifndef WGL_NV_DX_interop -#define WGL_ACCESS_READ_ONLY_NV 0x00000000 -#define WGL_ACCESS_READ_WRITE_NV 0x00000001 -#define WGL_ACCESS_WRITE_DISCARD_NV 0x00000002 -#endif - - -/*************************************************************/ - -#ifndef WGL_ARB_pbuffer -DECLARE_HANDLE(HPBUFFERARB); -#endif -#ifndef WGL_EXT_pbuffer -DECLARE_HANDLE(HPBUFFEREXT); -#endif -#ifndef WGL_NV_present_video -DECLARE_HANDLE(HVIDEOOUTPUTDEVICENV); -#endif -#ifndef WGL_NV_video_output -DECLARE_HANDLE(HPVIDEODEV); -#endif -#ifndef WGL_NV_gpu_affinity -DECLARE_HANDLE(HPGPUNV); -DECLARE_HANDLE(HGPUNV); - -typedef struct _GPU_DEVICE { - DWORD cb; - CHAR DeviceName[32]; - CHAR DeviceString[128]; - DWORD Flags; - RECT rcVirtualScreen; -} GPU_DEVICE, *PGPU_DEVICE; -#endif -#ifndef WGL_NV_video_capture -DECLARE_HANDLE(HVIDEOINPUTDEVICENV); -#endif - -#ifndef WGL_ARB_buffer_region -#define WGL_ARB_buffer_region 1 -#ifdef WGL_WGLEXT_PROTOTYPES -extern HANDLE WINAPI wglCreateBufferRegionARB (HDC hDC, int iLayerPlane, UINT uType); -extern VOID WINAPI wglDeleteBufferRegionARB (HANDLE hRegion); -extern BOOL WINAPI wglSaveBufferRegionARB (HANDLE hRegion, int x, int y, int width, int height); -extern BOOL WINAPI wglRestoreBufferRegionARB (HANDLE hRegion, int x, int y, int width, int height, int xSrc, int ySrc); -#endif /* WGL_WGLEXT_PROTOTYPES */ -typedef HANDLE (WINAPI * PFNWGLCREATEBUFFERREGIONARBPROC) (HDC hDC, int iLayerPlane, UINT uType); -typedef VOID (WINAPI * PFNWGLDELETEBUFFERREGIONARBPROC) (HANDLE hRegion); -typedef BOOL (WINAPI * PFNWGLSAVEBUFFERREGIONARBPROC) (HANDLE hRegion, int x, int y, int width, int height); -typedef BOOL (WINAPI * PFNWGLRESTOREBUFFERREGIONARBPROC) (HANDLE hRegion, int x, int y, int width, int height, int xSrc, int ySrc); -#endif - -#ifndef WGL_ARB_multisample -#define WGL_ARB_multisample 1 -#endif - -#ifndef WGL_ARB_extensions_string -#define WGL_ARB_extensions_string 1 -#ifdef WGL_WGLEXT_PROTOTYPES -extern const char * WINAPI wglGetExtensionsStringARB (HDC hdc); -#endif /* WGL_WGLEXT_PROTOTYPES */ -typedef const char * (WINAPI * PFNWGLGETEXTENSIONSSTRINGARBPROC) (HDC hdc); -#endif - -#ifndef WGL_ARB_pixel_format -#define WGL_ARB_pixel_format 1 -#ifdef WGL_WGLEXT_PROTOTYPES -extern BOOL WINAPI wglGetPixelFormatAttribivARB (HDC hdc, int iPixelFormat, int iLayerPlane, UINT nAttributes, const int *piAttributes, int *piValues); -extern BOOL WINAPI wglGetPixelFormatAttribfvARB (HDC hdc, int iPixelFormat, int iLayerPlane, UINT nAttributes, const int *piAttributes, FLOAT *pfValues); -extern BOOL WINAPI wglChoosePixelFormatARB (HDC hdc, const int *piAttribIList, const FLOAT *pfAttribFList, UINT nMaxFormats, int *piFormats, UINT *nNumFormats); -#endif /* WGL_WGLEXT_PROTOTYPES */ -typedef BOOL (WINAPI * PFNWGLGETPIXELFORMATATTRIBIVARBPROC) (HDC hdc, int iPixelFormat, int iLayerPlane, UINT nAttributes, const int *piAttributes, int *piValues); -typedef BOOL (WINAPI * PFNWGLGETPIXELFORMATATTRIBFVARBPROC) (HDC hdc, int iPixelFormat, int iLayerPlane, UINT nAttributes, const int *piAttributes, FLOAT *pfValues); -typedef BOOL (WINAPI * PFNWGLCHOOSEPIXELFORMATARBPROC) (HDC hdc, const int *piAttribIList, const FLOAT *pfAttribFList, UINT nMaxFormats, int *piFormats, UINT *nNumFormats); -#endif - -#ifndef WGL_ARB_make_current_read -#define WGL_ARB_make_current_read 1 -#ifdef WGL_WGLEXT_PROTOTYPES -extern BOOL WINAPI wglMakeContextCurrentARB (HDC hDrawDC, HDC hReadDC, HGLRC hglrc); -extern HDC WINAPI wglGetCurrentReadDCARB (void); -#endif /* WGL_WGLEXT_PROTOTYPES */ -typedef BOOL (WINAPI * PFNWGLMAKECONTEXTCURRENTARBPROC) (HDC hDrawDC, HDC hReadDC, HGLRC hglrc); -typedef HDC (WINAPI * PFNWGLGETCURRENTREADDCARBPROC) (void); -#endif - -#ifndef WGL_ARB_pbuffer -#define WGL_ARB_pbuffer 1 -#ifdef WGL_WGLEXT_PROTOTYPES -extern HPBUFFERARB WINAPI wglCreatePbufferARB (HDC hDC, int iPixelFormat, int iWidth, int iHeight, const int *piAttribList); -extern HDC WINAPI wglGetPbufferDCARB (HPBUFFERARB hPbuffer); -extern int WINAPI wglReleasePbufferDCARB (HPBUFFERARB hPbuffer, HDC hDC); -extern BOOL WINAPI wglDestroyPbufferARB (HPBUFFERARB hPbuffer); -extern BOOL WINAPI wglQueryPbufferARB (HPBUFFERARB hPbuffer, int iAttribute, int *piValue); -#endif /* WGL_WGLEXT_PROTOTYPES */ -typedef HPBUFFERARB (WINAPI * PFNWGLCREATEPBUFFERARBPROC) (HDC hDC, int iPixelFormat, int iWidth, int iHeight, const int *piAttribList); -typedef HDC (WINAPI * PFNWGLGETPBUFFERDCARBPROC) (HPBUFFERARB hPbuffer); -typedef int (WINAPI * PFNWGLRELEASEPBUFFERDCARBPROC) (HPBUFFERARB hPbuffer, HDC hDC); -typedef BOOL (WINAPI * PFNWGLDESTROYPBUFFERARBPROC) (HPBUFFERARB hPbuffer); -typedef BOOL (WINAPI * PFNWGLQUERYPBUFFERARBPROC) (HPBUFFERARB hPbuffer, int iAttribute, int *piValue); -#endif - -#ifndef WGL_ARB_render_texture -#define WGL_ARB_render_texture 1 -#ifdef WGL_WGLEXT_PROTOTYPES -extern BOOL WINAPI wglBindTexImageARB (HPBUFFERARB hPbuffer, int iBuffer); -extern BOOL WINAPI wglReleaseTexImageARB (HPBUFFERARB hPbuffer, int iBuffer); -extern BOOL WINAPI wglSetPbufferAttribARB (HPBUFFERARB hPbuffer, const int *piAttribList); -#endif /* WGL_WGLEXT_PROTOTYPES */ -typedef BOOL (WINAPI * PFNWGLBINDTEXIMAGEARBPROC) (HPBUFFERARB hPbuffer, int iBuffer); -typedef BOOL (WINAPI * PFNWGLRELEASETEXIMAGEARBPROC) (HPBUFFERARB hPbuffer, int iBuffer); -typedef BOOL (WINAPI * PFNWGLSETPBUFFERATTRIBARBPROC) (HPBUFFERARB hPbuffer, const int *piAttribList); -#endif - -#ifndef WGL_ARB_pixel_format_float -#define WGL_ARB_pixel_format_float 1 -#endif - -#ifndef WGL_ARB_framebuffer_sRGB -#define WGL_ARB_framebuffer_sRGB 1 -#endif - -#ifndef WGL_ARB_create_context -#define WGL_ARB_create_context 1 -#ifdef WGL_WGLEXT_PROTOTYPES -extern HGLRC WINAPI wglCreateContextAttribsARB (HDC hDC, HGLRC hShareContext, const int *attribList); -#endif /* WGL_WGLEXT_PROTOTYPES */ -typedef HGLRC (WINAPI * PFNWGLCREATECONTEXTATTRIBSARBPROC) (HDC hDC, HGLRC hShareContext, const int *attribList); -#endif - -#ifndef WGL_ARB_create_context_profile -#define WGL_ARB_create_context_profile 1 -#endif - -#ifndef WGL_ARB_create_context_robustness -#define WGL_ARB_create_context_robustness 1 -#endif - -#ifndef WGL_EXT_display_color_table -#define WGL_EXT_display_color_table 1 -#ifdef WGL_WGLEXT_PROTOTYPES -extern GLboolean WINAPI wglCreateDisplayColorTableEXT (GLushort id); -extern GLboolean WINAPI wglLoadDisplayColorTableEXT (const GLushort *table, GLuint length); -extern GLboolean WINAPI wglBindDisplayColorTableEXT (GLushort id); -extern VOID WINAPI wglDestroyDisplayColorTableEXT (GLushort id); -#endif /* WGL_WGLEXT_PROTOTYPES */ -typedef GLboolean (WINAPI * PFNWGLCREATEDISPLAYCOLORTABLEEXTPROC) (GLushort id); -typedef GLboolean (WINAPI * PFNWGLLOADDISPLAYCOLORTABLEEXTPROC) (const GLushort *table, GLuint length); -typedef GLboolean (WINAPI * PFNWGLBINDDISPLAYCOLORTABLEEXTPROC) (GLushort id); -typedef VOID (WINAPI * PFNWGLDESTROYDISPLAYCOLORTABLEEXTPROC) (GLushort id); -#endif - -#ifndef WGL_EXT_extensions_string -#define WGL_EXT_extensions_string 1 -#ifdef WGL_WGLEXT_PROTOTYPES -extern const char * WINAPI wglGetExtensionsStringEXT (void); -#endif /* WGL_WGLEXT_PROTOTYPES */ -typedef const char * (WINAPI * PFNWGLGETEXTENSIONSSTRINGEXTPROC) (void); -#endif - -#ifndef WGL_EXT_make_current_read -#define WGL_EXT_make_current_read 1 -#ifdef WGL_WGLEXT_PROTOTYPES -extern BOOL WINAPI wglMakeContextCurrentEXT (HDC hDrawDC, HDC hReadDC, HGLRC hglrc); -extern HDC WINAPI wglGetCurrentReadDCEXT (void); -#endif /* WGL_WGLEXT_PROTOTYPES */ -typedef BOOL (WINAPI * PFNWGLMAKECONTEXTCURRENTEXTPROC) (HDC hDrawDC, HDC hReadDC, HGLRC hglrc); -typedef HDC (WINAPI * PFNWGLGETCURRENTREADDCEXTPROC) (void); -#endif - -#ifndef WGL_EXT_pbuffer -#define WGL_EXT_pbuffer 1 -#ifdef WGL_WGLEXT_PROTOTYPES -extern HPBUFFEREXT WINAPI wglCreatePbufferEXT (HDC hDC, int iPixelFormat, int iWidth, int iHeight, const int *piAttribList); -extern HDC WINAPI wglGetPbufferDCEXT (HPBUFFEREXT hPbuffer); -extern int WINAPI wglReleasePbufferDCEXT (HPBUFFEREXT hPbuffer, HDC hDC); -extern BOOL WINAPI wglDestroyPbufferEXT (HPBUFFEREXT hPbuffer); -extern BOOL WINAPI wglQueryPbufferEXT (HPBUFFEREXT hPbuffer, int iAttribute, int *piValue); -#endif /* WGL_WGLEXT_PROTOTYPES */ -typedef HPBUFFEREXT (WINAPI * PFNWGLCREATEPBUFFEREXTPROC) (HDC hDC, int iPixelFormat, int iWidth, int iHeight, const int *piAttribList); -typedef HDC (WINAPI * PFNWGLGETPBUFFERDCEXTPROC) (HPBUFFEREXT hPbuffer); -typedef int (WINAPI * PFNWGLRELEASEPBUFFERDCEXTPROC) (HPBUFFEREXT hPbuffer, HDC hDC); -typedef BOOL (WINAPI * PFNWGLDESTROYPBUFFEREXTPROC) (HPBUFFEREXT hPbuffer); -typedef BOOL (WINAPI * PFNWGLQUERYPBUFFEREXTPROC) (HPBUFFEREXT hPbuffer, int iAttribute, int *piValue); -#endif - -#ifndef WGL_EXT_pixel_format -#define WGL_EXT_pixel_format 1 -#ifdef WGL_WGLEXT_PROTOTYPES -extern BOOL WINAPI wglGetPixelFormatAttribivEXT (HDC hdc, int iPixelFormat, int iLayerPlane, UINT nAttributes, int *piAttributes, int *piValues); -extern BOOL WINAPI wglGetPixelFormatAttribfvEXT (HDC hdc, int iPixelFormat, int iLayerPlane, UINT nAttributes, int *piAttributes, FLOAT *pfValues); -extern BOOL WINAPI wglChoosePixelFormatEXT (HDC hdc, const int *piAttribIList, const FLOAT *pfAttribFList, UINT nMaxFormats, int *piFormats, UINT *nNumFormats); -#endif /* WGL_WGLEXT_PROTOTYPES */ -typedef BOOL (WINAPI * PFNWGLGETPIXELFORMATATTRIBIVEXTPROC) (HDC hdc, int iPixelFormat, int iLayerPlane, UINT nAttributes, int *piAttributes, int *piValues); -typedef BOOL (WINAPI * PFNWGLGETPIXELFORMATATTRIBFVEXTPROC) (HDC hdc, int iPixelFormat, int iLayerPlane, UINT nAttributes, int *piAttributes, FLOAT *pfValues); -typedef BOOL (WINAPI * PFNWGLCHOOSEPIXELFORMATEXTPROC) (HDC hdc, const int *piAttribIList, const FLOAT *pfAttribFList, UINT nMaxFormats, int *piFormats, UINT *nNumFormats); -#endif - -#ifndef WGL_EXT_swap_control -#define WGL_EXT_swap_control 1 -#ifdef WGL_WGLEXT_PROTOTYPES -extern BOOL WINAPI wglSwapIntervalEXT (int interval); -extern int WINAPI wglGetSwapIntervalEXT (void); -#endif /* WGL_WGLEXT_PROTOTYPES */ -typedef BOOL (WINAPI * PFNWGLSWAPINTERVALEXTPROC) (int interval); -typedef int (WINAPI * PFNWGLGETSWAPINTERVALEXTPROC) (void); -#endif - -#ifndef WGL_EXT_depth_float -#define WGL_EXT_depth_float 1 -#endif - -#ifndef WGL_NV_vertex_array_range -#define WGL_NV_vertex_array_range 1 -#ifdef WGL_WGLEXT_PROTOTYPES -extern void* WINAPI wglAllocateMemoryNV (GLsizei size, GLfloat readfreq, GLfloat writefreq, GLfloat priority); -extern void WINAPI wglFreeMemoryNV (void *pointer); -#endif /* WGL_WGLEXT_PROTOTYPES */ -typedef void* (WINAPI * PFNWGLALLOCATEMEMORYNVPROC) (GLsizei size, GLfloat readfreq, GLfloat writefreq, GLfloat priority); -typedef void (WINAPI * PFNWGLFREEMEMORYNVPROC) (void *pointer); -#endif - -#ifndef WGL_3DFX_multisample -#define WGL_3DFX_multisample 1 -#endif - -#ifndef WGL_EXT_multisample -#define WGL_EXT_multisample 1 -#endif - -#ifndef WGL_OML_sync_control -#define WGL_OML_sync_control 1 -#ifdef WGL_WGLEXT_PROTOTYPES -extern BOOL WINAPI wglGetSyncValuesOML (HDC hdc, INT64 *ust, INT64 *msc, INT64 *sbc); -extern BOOL WINAPI wglGetMscRateOML (HDC hdc, INT32 *numerator, INT32 *denominator); -extern INT64 WINAPI wglSwapBuffersMscOML (HDC hdc, INT64 target_msc, INT64 divisor, INT64 remainder); -extern INT64 WINAPI wglSwapLayerBuffersMscOML (HDC hdc, int fuPlanes, INT64 target_msc, INT64 divisor, INT64 remainder); -extern BOOL WINAPI wglWaitForMscOML (HDC hdc, INT64 target_msc, INT64 divisor, INT64 remainder, INT64 *ust, INT64 *msc, INT64 *sbc); -extern BOOL WINAPI wglWaitForSbcOML (HDC hdc, INT64 target_sbc, INT64 *ust, INT64 *msc, INT64 *sbc); -#endif /* WGL_WGLEXT_PROTOTYPES */ -typedef BOOL (WINAPI * PFNWGLGETSYNCVALUESOMLPROC) (HDC hdc, INT64 *ust, INT64 *msc, INT64 *sbc); -typedef BOOL (WINAPI * PFNWGLGETMSCRATEOMLPROC) (HDC hdc, INT32 *numerator, INT32 *denominator); -typedef INT64 (WINAPI * PFNWGLSWAPBUFFERSMSCOMLPROC) (HDC hdc, INT64 target_msc, INT64 divisor, INT64 remainder); -typedef INT64 (WINAPI * PFNWGLSWAPLAYERBUFFERSMSCOMLPROC) (HDC hdc, int fuPlanes, INT64 target_msc, INT64 divisor, INT64 remainder); -typedef BOOL (WINAPI * PFNWGLWAITFORMSCOMLPROC) (HDC hdc, INT64 target_msc, INT64 divisor, INT64 remainder, INT64 *ust, INT64 *msc, INT64 *sbc); -typedef BOOL (WINAPI * PFNWGLWAITFORSBCOMLPROC) (HDC hdc, INT64 target_sbc, INT64 *ust, INT64 *msc, INT64 *sbc); -#endif - -#ifndef WGL_I3D_digital_video_control -#define WGL_I3D_digital_video_control 1 -#ifdef WGL_WGLEXT_PROTOTYPES -extern BOOL WINAPI wglGetDigitalVideoParametersI3D (HDC hDC, int iAttribute, int *piValue); -extern BOOL WINAPI wglSetDigitalVideoParametersI3D (HDC hDC, int iAttribute, const int *piValue); -#endif /* WGL_WGLEXT_PROTOTYPES */ -typedef BOOL (WINAPI * PFNWGLGETDIGITALVIDEOPARAMETERSI3DPROC) (HDC hDC, int iAttribute, int *piValue); -typedef BOOL (WINAPI * PFNWGLSETDIGITALVIDEOPARAMETERSI3DPROC) (HDC hDC, int iAttribute, const int *piValue); -#endif - -#ifndef WGL_I3D_gamma -#define WGL_I3D_gamma 1 -#ifdef WGL_WGLEXT_PROTOTYPES -extern BOOL WINAPI wglGetGammaTableParametersI3D (HDC hDC, int iAttribute, int *piValue); -extern BOOL WINAPI wglSetGammaTableParametersI3D (HDC hDC, int iAttribute, const int *piValue); -extern BOOL WINAPI wglGetGammaTableI3D (HDC hDC, int iEntries, USHORT *puRed, USHORT *puGreen, USHORT *puBlue); -extern BOOL WINAPI wglSetGammaTableI3D (HDC hDC, int iEntries, const USHORT *puRed, const USHORT *puGreen, const USHORT *puBlue); -#endif /* WGL_WGLEXT_PROTOTYPES */ -typedef BOOL (WINAPI * PFNWGLGETGAMMATABLEPARAMETERSI3DPROC) (HDC hDC, int iAttribute, int *piValue); -typedef BOOL (WINAPI * PFNWGLSETGAMMATABLEPARAMETERSI3DPROC) (HDC hDC, int iAttribute, const int *piValue); -typedef BOOL (WINAPI * PFNWGLGETGAMMATABLEI3DPROC) (HDC hDC, int iEntries, USHORT *puRed, USHORT *puGreen, USHORT *puBlue); -typedef BOOL (WINAPI * PFNWGLSETGAMMATABLEI3DPROC) (HDC hDC, int iEntries, const USHORT *puRed, const USHORT *puGreen, const USHORT *puBlue); -#endif - -#ifndef WGL_I3D_genlock -#define WGL_I3D_genlock 1 -#ifdef WGL_WGLEXT_PROTOTYPES -extern BOOL WINAPI wglEnableGenlockI3D (HDC hDC); -extern BOOL WINAPI wglDisableGenlockI3D (HDC hDC); -extern BOOL WINAPI wglIsEnabledGenlockI3D (HDC hDC, BOOL *pFlag); -extern BOOL WINAPI wglGenlockSourceI3D (HDC hDC, UINT uSource); -extern BOOL WINAPI wglGetGenlockSourceI3D (HDC hDC, UINT *uSource); -extern BOOL WINAPI wglGenlockSourceEdgeI3D (HDC hDC, UINT uEdge); -extern BOOL WINAPI wglGetGenlockSourceEdgeI3D (HDC hDC, UINT *uEdge); -extern BOOL WINAPI wglGenlockSampleRateI3D (HDC hDC, UINT uRate); -extern BOOL WINAPI wglGetGenlockSampleRateI3D (HDC hDC, UINT *uRate); -extern BOOL WINAPI wglGenlockSourceDelayI3D (HDC hDC, UINT uDelay); -extern BOOL WINAPI wglGetGenlockSourceDelayI3D (HDC hDC, UINT *uDelay); -extern BOOL WINAPI wglQueryGenlockMaxSourceDelayI3D (HDC hDC, UINT *uMaxLineDelay, UINT *uMaxPixelDelay); -#endif /* WGL_WGLEXT_PROTOTYPES */ -typedef BOOL (WINAPI * PFNWGLENABLEGENLOCKI3DPROC) (HDC hDC); -typedef BOOL (WINAPI * PFNWGLDISABLEGENLOCKI3DPROC) (HDC hDC); -typedef BOOL (WINAPI * PFNWGLISENABLEDGENLOCKI3DPROC) (HDC hDC, BOOL *pFlag); -typedef BOOL (WINAPI * PFNWGLGENLOCKSOURCEI3DPROC) (HDC hDC, UINT uSource); -typedef BOOL (WINAPI * PFNWGLGETGENLOCKSOURCEI3DPROC) (HDC hDC, UINT *uSource); -typedef BOOL (WINAPI * PFNWGLGENLOCKSOURCEEDGEI3DPROC) (HDC hDC, UINT uEdge); -typedef BOOL (WINAPI * PFNWGLGETGENLOCKSOURCEEDGEI3DPROC) (HDC hDC, UINT *uEdge); -typedef BOOL (WINAPI * PFNWGLGENLOCKSAMPLERATEI3DPROC) (HDC hDC, UINT uRate); -typedef BOOL (WINAPI * PFNWGLGETGENLOCKSAMPLERATEI3DPROC) (HDC hDC, UINT *uRate); -typedef BOOL (WINAPI * PFNWGLGENLOCKSOURCEDELAYI3DPROC) (HDC hDC, UINT uDelay); -typedef BOOL (WINAPI * PFNWGLGETGENLOCKSOURCEDELAYI3DPROC) (HDC hDC, UINT *uDelay); -typedef BOOL (WINAPI * PFNWGLQUERYGENLOCKMAXSOURCEDELAYI3DPROC) (HDC hDC, UINT *uMaxLineDelay, UINT *uMaxPixelDelay); -#endif - -#ifndef WGL_I3D_image_buffer -#define WGL_I3D_image_buffer 1 -#ifdef WGL_WGLEXT_PROTOTYPES -extern LPVOID WINAPI wglCreateImageBufferI3D (HDC hDC, DWORD dwSize, UINT uFlags); -extern BOOL WINAPI wglDestroyImageBufferI3D (HDC hDC, LPVOID pAddress); -extern BOOL WINAPI wglAssociateImageBufferEventsI3D (HDC hDC, const HANDLE *pEvent, const LPVOID *pAddress, const DWORD *pSize, UINT count); -extern BOOL WINAPI wglReleaseImageBufferEventsI3D (HDC hDC, const LPVOID *pAddress, UINT count); -#endif /* WGL_WGLEXT_PROTOTYPES */ -typedef LPVOID (WINAPI * PFNWGLCREATEIMAGEBUFFERI3DPROC) (HDC hDC, DWORD dwSize, UINT uFlags); -typedef BOOL (WINAPI * PFNWGLDESTROYIMAGEBUFFERI3DPROC) (HDC hDC, LPVOID pAddress); -typedef BOOL (WINAPI * PFNWGLASSOCIATEIMAGEBUFFEREVENTSI3DPROC) (HDC hDC, const HANDLE *pEvent, const LPVOID *pAddress, const DWORD *pSize, UINT count); -typedef BOOL (WINAPI * PFNWGLRELEASEIMAGEBUFFEREVENTSI3DPROC) (HDC hDC, const LPVOID *pAddress, UINT count); -#endif - -#ifndef WGL_I3D_swap_frame_lock -#define WGL_I3D_swap_frame_lock 1 -#ifdef WGL_WGLEXT_PROTOTYPES -extern BOOL WINAPI wglEnableFrameLockI3D (void); -extern BOOL WINAPI wglDisableFrameLockI3D (void); -extern BOOL WINAPI wglIsEnabledFrameLockI3D (BOOL *pFlag); -extern BOOL WINAPI wglQueryFrameLockMasterI3D (BOOL *pFlag); -#endif /* WGL_WGLEXT_PROTOTYPES */ -typedef BOOL (WINAPI * PFNWGLENABLEFRAMELOCKI3DPROC) (void); -typedef BOOL (WINAPI * PFNWGLDISABLEFRAMELOCKI3DPROC) (void); -typedef BOOL (WINAPI * PFNWGLISENABLEDFRAMELOCKI3DPROC) (BOOL *pFlag); -typedef BOOL (WINAPI * PFNWGLQUERYFRAMELOCKMASTERI3DPROC) (BOOL *pFlag); -#endif - -#ifndef WGL_I3D_swap_frame_usage -#define WGL_I3D_swap_frame_usage 1 -#ifdef WGL_WGLEXT_PROTOTYPES -extern BOOL WINAPI wglGetFrameUsageI3D (float *pUsage); -extern BOOL WINAPI wglBeginFrameTrackingI3D (void); -extern BOOL WINAPI wglEndFrameTrackingI3D (void); -extern BOOL WINAPI wglQueryFrameTrackingI3D (DWORD *pFrameCount, DWORD *pMissedFrames, float *pLastMissedUsage); -#endif /* WGL_WGLEXT_PROTOTYPES */ -typedef BOOL (WINAPI * PFNWGLGETFRAMEUSAGEI3DPROC) (float *pUsage); -typedef BOOL (WINAPI * PFNWGLBEGINFRAMETRACKINGI3DPROC) (void); -typedef BOOL (WINAPI * PFNWGLENDFRAMETRACKINGI3DPROC) (void); -typedef BOOL (WINAPI * PFNWGLQUERYFRAMETRACKINGI3DPROC) (DWORD *pFrameCount, DWORD *pMissedFrames, float *pLastMissedUsage); -#endif - -#ifndef WGL_ATI_pixel_format_float -#define WGL_ATI_pixel_format_float 1 -#endif - -#ifndef WGL_NV_float_buffer -#define WGL_NV_float_buffer 1 -#endif - -#ifndef WGL_3DL_stereo_control -#define WGL_3DL_stereo_control 1 -#ifdef WGL_WGLEXT_PROTOTYPES -extern BOOL WINAPI wglSetStereoEmitterState3DL (HDC hDC, UINT uState); -#endif /* WGL_WGLEXT_PROTOTYPES */ -typedef BOOL (WINAPI * PFNWGLSETSTEREOEMITTERSTATE3DLPROC) (HDC hDC, UINT uState); -#endif - -#ifndef WGL_EXT_pixel_format_packed_float -#define WGL_EXT_pixel_format_packed_float 1 -#endif - -#ifndef WGL_EXT_framebuffer_sRGB -#define WGL_EXT_framebuffer_sRGB 1 -#endif - -#ifndef WGL_NV_present_video -#define WGL_NV_present_video 1 -#ifdef WGL_WGLEXT_PROTOTYPES -extern int WINAPI wglEnumerateVideoDevicesNV (HDC hDC, HVIDEOOUTPUTDEVICENV *phDeviceList); -extern BOOL WINAPI wglBindVideoDeviceNV (HDC hDC, unsigned int uVideoSlot, HVIDEOOUTPUTDEVICENV hVideoDevice, const int *piAttribList); -extern BOOL WINAPI wglQueryCurrentContextNV (int iAttribute, int *piValue); -#endif /* WGL_WGLEXT_PROTOTYPES */ -typedef int (WINAPI * PFNWGLENUMERATEVIDEODEVICESNVPROC) (HDC hDC, HVIDEOOUTPUTDEVICENV *phDeviceList); -typedef BOOL (WINAPI * PFNWGLBINDVIDEODEVICENVPROC) (HDC hDC, unsigned int uVideoSlot, HVIDEOOUTPUTDEVICENV hVideoDevice, const int *piAttribList); -typedef BOOL (WINAPI * PFNWGLQUERYCURRENTCONTEXTNVPROC) (int iAttribute, int *piValue); -#endif - -#ifndef WGL_NV_video_output -#define WGL_NV_video_output 1 -#ifdef WGL_WGLEXT_PROTOTYPES -extern BOOL WINAPI wglGetVideoDeviceNV (HDC hDC, int numDevices, HPVIDEODEV *hVideoDevice); -extern BOOL WINAPI wglReleaseVideoDeviceNV (HPVIDEODEV hVideoDevice); -extern BOOL WINAPI wglBindVideoImageNV (HPVIDEODEV hVideoDevice, HPBUFFERARB hPbuffer, int iVideoBuffer); -extern BOOL WINAPI wglReleaseVideoImageNV (HPBUFFERARB hPbuffer, int iVideoBuffer); -extern BOOL WINAPI wglSendPbufferToVideoNV (HPBUFFERARB hPbuffer, int iBufferType, unsigned long *pulCounterPbuffer, BOOL bBlock); -extern BOOL WINAPI wglGetVideoInfoNV (HPVIDEODEV hpVideoDevice, unsigned long *pulCounterOutputPbuffer, unsigned long *pulCounterOutputVideo); -#endif /* WGL_WGLEXT_PROTOTYPES */ -typedef BOOL (WINAPI * PFNWGLGETVIDEODEVICENVPROC) (HDC hDC, int numDevices, HPVIDEODEV *hVideoDevice); -typedef BOOL (WINAPI * PFNWGLRELEASEVIDEODEVICENVPROC) (HPVIDEODEV hVideoDevice); -typedef BOOL (WINAPI * PFNWGLBINDVIDEOIMAGENVPROC) (HPVIDEODEV hVideoDevice, HPBUFFERARB hPbuffer, int iVideoBuffer); -typedef BOOL (WINAPI * PFNWGLRELEASEVIDEOIMAGENVPROC) (HPBUFFERARB hPbuffer, int iVideoBuffer); -typedef BOOL (WINAPI * PFNWGLSENDPBUFFERTOVIDEONVPROC) (HPBUFFERARB hPbuffer, int iBufferType, unsigned long *pulCounterPbuffer, BOOL bBlock); -typedef BOOL (WINAPI * PFNWGLGETVIDEOINFONVPROC) (HPVIDEODEV hpVideoDevice, unsigned long *pulCounterOutputPbuffer, unsigned long *pulCounterOutputVideo); -#endif - -#ifndef WGL_NV_swap_group -#define WGL_NV_swap_group 1 -#ifdef WGL_WGLEXT_PROTOTYPES -extern BOOL WINAPI wglJoinSwapGroupNV (HDC hDC, GLuint group); -extern BOOL WINAPI wglBindSwapBarrierNV (GLuint group, GLuint barrier); -extern BOOL WINAPI wglQuerySwapGroupNV (HDC hDC, GLuint *group, GLuint *barrier); -extern BOOL WINAPI wglQueryMaxSwapGroupsNV (HDC hDC, GLuint *maxGroups, GLuint *maxBarriers); -extern BOOL WINAPI wglQueryFrameCountNV (HDC hDC, GLuint *count); -extern BOOL WINAPI wglResetFrameCountNV (HDC hDC); -#endif /* WGL_WGLEXT_PROTOTYPES */ -typedef BOOL (WINAPI * PFNWGLJOINSWAPGROUPNVPROC) (HDC hDC, GLuint group); -typedef BOOL (WINAPI * PFNWGLBINDSWAPBARRIERNVPROC) (GLuint group, GLuint barrier); -typedef BOOL (WINAPI * PFNWGLQUERYSWAPGROUPNVPROC) (HDC hDC, GLuint *group, GLuint *barrier); -typedef BOOL (WINAPI * PFNWGLQUERYMAXSWAPGROUPSNVPROC) (HDC hDC, GLuint *maxGroups, GLuint *maxBarriers); -typedef BOOL (WINAPI * PFNWGLQUERYFRAMECOUNTNVPROC) (HDC hDC, GLuint *count); -typedef BOOL (WINAPI * PFNWGLRESETFRAMECOUNTNVPROC) (HDC hDC); -#endif - -#ifndef WGL_NV_gpu_affinity -#define WGL_NV_gpu_affinity 1 -#ifdef WGL_WGLEXT_PROTOTYPES -extern BOOL WINAPI wglEnumGpusNV (UINT iGpuIndex, HGPUNV *phGpu); -extern BOOL WINAPI wglEnumGpuDevicesNV (HGPUNV hGpu, UINT iDeviceIndex, PGPU_DEVICE lpGpuDevice); -extern HDC WINAPI wglCreateAffinityDCNV (const HGPUNV *phGpuList); -extern BOOL WINAPI wglEnumGpusFromAffinityDCNV (HDC hAffinityDC, UINT iGpuIndex, HGPUNV *hGpu); -extern BOOL WINAPI wglDeleteDCNV (HDC hdc); -#endif /* WGL_WGLEXT_PROTOTYPES */ -typedef BOOL (WINAPI * PFNWGLENUMGPUSNVPROC) (UINT iGpuIndex, HGPUNV *phGpu); -typedef BOOL (WINAPI * PFNWGLENUMGPUDEVICESNVPROC) (HGPUNV hGpu, UINT iDeviceIndex, PGPU_DEVICE lpGpuDevice); -typedef HDC (WINAPI * PFNWGLCREATEAFFINITYDCNVPROC) (const HGPUNV *phGpuList); -typedef BOOL (WINAPI * PFNWGLENUMGPUSFROMAFFINITYDCNVPROC) (HDC hAffinityDC, UINT iGpuIndex, HGPUNV *hGpu); -typedef BOOL (WINAPI * PFNWGLDELETEDCNVPROC) (HDC hdc); -#endif - -#ifndef WGL_AMD_gpu_association -#define WGL_AMD_gpu_association 1 -#ifdef WGL_WGLEXT_PROTOTYPES -extern UINT WINAPI wglGetGPUIDsAMD (UINT maxCount, UINT *ids); -extern INT WINAPI wglGetGPUInfoAMD (UINT id, int property, GLenum dataType, UINT size, void *data); -extern UINT WINAPI wglGetContextGPUIDAMD (HGLRC hglrc); -extern HGLRC WINAPI wglCreateAssociatedContextAMD (UINT id); -extern HGLRC WINAPI wglCreateAssociatedContextAttribsAMD (UINT id, HGLRC hShareContext, const int *attribList); -extern BOOL WINAPI wglDeleteAssociatedContextAMD (HGLRC hglrc); -extern BOOL WINAPI wglMakeAssociatedContextCurrentAMD (HGLRC hglrc); -extern HGLRC WINAPI wglGetCurrentAssociatedContextAMD (void); -extern VOID WINAPI wglBlitContextFramebufferAMD (HGLRC dstCtx, GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter); -#endif /* WGL_WGLEXT_PROTOTYPES */ -typedef UINT (WINAPI * PFNWGLGETGPUIDSAMDPROC) (UINT maxCount, UINT *ids); -typedef INT (WINAPI * PFNWGLGETGPUINFOAMDPROC) (UINT id, int property, GLenum dataType, UINT size, void *data); -typedef UINT (WINAPI * PFNWGLGETCONTEXTGPUIDAMDPROC) (HGLRC hglrc); -typedef HGLRC (WINAPI * PFNWGLCREATEASSOCIATEDCONTEXTAMDPROC) (UINT id); -typedef HGLRC (WINAPI * PFNWGLCREATEASSOCIATEDCONTEXTATTRIBSAMDPROC) (UINT id, HGLRC hShareContext, const int *attribList); -typedef BOOL (WINAPI * PFNWGLDELETEASSOCIATEDCONTEXTAMDPROC) (HGLRC hglrc); -typedef BOOL (WINAPI * PFNWGLMAKEASSOCIATEDCONTEXTCURRENTAMDPROC) (HGLRC hglrc); -typedef HGLRC (WINAPI * PFNWGLGETCURRENTASSOCIATEDCONTEXTAMDPROC) (void); -typedef VOID (WINAPI * PFNWGLBLITCONTEXTFRAMEBUFFERAMDPROC) (HGLRC dstCtx, GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter); -#endif - -#ifndef WGL_NV_video_capture -#define WGL_NV_video_capture 1 -#ifdef WGL_WGLEXT_PROTOTYPES -extern BOOL WINAPI wglBindVideoCaptureDeviceNV (UINT uVideoSlot, HVIDEOINPUTDEVICENV hDevice); -extern UINT WINAPI wglEnumerateVideoCaptureDevicesNV (HDC hDc, HVIDEOINPUTDEVICENV *phDeviceList); -extern BOOL WINAPI wglLockVideoCaptureDeviceNV (HDC hDc, HVIDEOINPUTDEVICENV hDevice); -extern BOOL WINAPI wglQueryVideoCaptureDeviceNV (HDC hDc, HVIDEOINPUTDEVICENV hDevice, int iAttribute, int *piValue); -extern BOOL WINAPI wglReleaseVideoCaptureDeviceNV (HDC hDc, HVIDEOINPUTDEVICENV hDevice); -#endif /* WGL_WGLEXT_PROTOTYPES */ -typedef BOOL (WINAPI * PFNWGLBINDVIDEOCAPTUREDEVICENVPROC) (UINT uVideoSlot, HVIDEOINPUTDEVICENV hDevice); -typedef UINT (WINAPI * PFNWGLENUMERATEVIDEOCAPTUREDEVICESNVPROC) (HDC hDc, HVIDEOINPUTDEVICENV *phDeviceList); -typedef BOOL (WINAPI * PFNWGLLOCKVIDEOCAPTUREDEVICENVPROC) (HDC hDc, HVIDEOINPUTDEVICENV hDevice); -typedef BOOL (WINAPI * PFNWGLQUERYVIDEOCAPTUREDEVICENVPROC) (HDC hDc, HVIDEOINPUTDEVICENV hDevice, int iAttribute, int *piValue); -typedef BOOL (WINAPI * PFNWGLRELEASEVIDEOCAPTUREDEVICENVPROC) (HDC hDc, HVIDEOINPUTDEVICENV hDevice); -#endif - -#ifndef WGL_NV_copy_image -#define WGL_NV_copy_image 1 -#ifdef WGL_WGLEXT_PROTOTYPES -extern BOOL WINAPI wglCopyImageSubDataNV (HGLRC hSrcRC, GLuint srcName, GLenum srcTarget, GLint srcLevel, GLint srcX, GLint srcY, GLint srcZ, HGLRC hDstRC, GLuint dstName, GLenum dstTarget, GLint dstLevel, GLint dstX, GLint dstY, GLint dstZ, GLsizei width, GLsizei height, GLsizei depth); -#endif /* WGL_WGLEXT_PROTOTYPES */ -typedef BOOL (WINAPI * PFNWGLCOPYIMAGESUBDATANVPROC) (HGLRC hSrcRC, GLuint srcName, GLenum srcTarget, GLint srcLevel, GLint srcX, GLint srcY, GLint srcZ, HGLRC hDstRC, GLuint dstName, GLenum dstTarget, GLint dstLevel, GLint dstX, GLint dstY, GLint dstZ, GLsizei width, GLsizei height, GLsizei depth); -#endif - -#ifndef WGL_NV_multisample_coverage -#define WGL_NV_multisample_coverage 1 -#endif - -#ifndef WGL_NV_DX_interop -#define WGL_NV_DX_interop 1 -#ifdef WGL_WGLEXT_PROTOTYPES -extern BOOL WINAPI wglDXSetResourceShareHandleNV (void *dxObject, HANDLE shareHandle); -extern HANDLE WINAPI wglDXOpenDeviceNV (void *dxDevice); -extern BOOL WINAPI wglDXCloseDeviceNV (HANDLE hDevice); -extern HANDLE WINAPI wglDXRegisterObjectNV (HANDLE hDevice, void *dxObject, GLuint name, GLenum type, GLenum access); -extern BOOL WINAPI wglDXUnregisterObjectNV (HANDLE hDevice, HANDLE hObject); -extern BOOL WINAPI wglDXObjectAccessNV (HANDLE hObject, GLenum access); -extern BOOL WINAPI wglDXLockObjectsNV (HANDLE hDevice, GLint count, HANDLE *hObjects); -extern BOOL WINAPI wglDXUnlockObjectsNV (HANDLE hDevice, GLint count, HANDLE *hObjects); -#endif /* WGL_WGLEXT_PROTOTYPES */ -typedef BOOL (WINAPI * PFNWGLDXSETRESOURCESHAREHANDLENVPROC) (void *dxObject, HANDLE shareHandle); -typedef HANDLE (WINAPI * PFNWGLDXOPENDEVICENVPROC) (void *dxDevice); -typedef BOOL (WINAPI * PFNWGLDXCLOSEDEVICENVPROC) (HANDLE hDevice); -typedef HANDLE (WINAPI * PFNWGLDXREGISTEROBJECTNVPROC) (HANDLE hDevice, void *dxObject, GLuint name, GLenum type, GLenum access); -typedef BOOL (WINAPI * PFNWGLDXUNREGISTEROBJECTNVPROC) (HANDLE hDevice, HANDLE hObject); -typedef BOOL (WINAPI * PFNWGLDXOBJECTACCESSNVPROC) (HANDLE hObject, GLenum access); -typedef BOOL (WINAPI * PFNWGLDXLOCKOBJECTSNVPROC) (HANDLE hDevice, GLint count, HANDLE *hObjects); -typedef BOOL (WINAPI * PFNWGLDXUNLOCKOBJECTSNVPROC) (HANDLE hDevice, GLint count, HANDLE *hObjects); -#endif - - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/openglcolor.cpp b/openglcolor.cpp new file mode 100644 index 00000000..65e36d51 --- /dev/null +++ b/openglcolor.cpp @@ -0,0 +1,13 @@ +/* +This Source Code Form is subject to the +terms of the Mozilla Public License, v. +2.0. If a copy of the MPL was not +distributed with this file, You can +obtain one at +http://mozilla.org/MPL/2.0/. +*/ + +#include "stdafx.h" +#include "openglcolor.h" + +opengl_color OpenGLColor; diff --git a/openglcolor.h b/openglcolor.h new file mode 100644 index 00000000..39281880 --- /dev/null +++ b/openglcolor.h @@ -0,0 +1,71 @@ +/* +This Source Code Form is subject to the +terms of the Mozilla Public License, v. +2.0. If a copy of the MPL was not +distributed with this file, You can +obtain one at +http://mozilla.org/MPL/2.0/. +*/ + +#pragma once + +#include "globals.h" + +// encapsulation of the fixed pipeline opengl color +class opengl_color { + +public: +// constructors: + opengl_color() = default; + +// methods: + inline + void + color3( glm::vec3 const &Color ) { + return color4( glm::vec4{ Color, 1.f } ); } + inline + void + color3( float const Red, float const Green, float const Blue ) { + return color3( glm::vec3 { Red, Green, Blue } ); } + inline + void + color3( float const *Value ) { + return color3( glm::make_vec3( Value ) ); } + inline + void + color4( glm::vec4 const &Color ) { + if( ( Color != m_color ) || ( false == Global.bUseVBO ) ) { + m_color = Color; + ::glColor4fv( glm::value_ptr( m_color ) ); } } + inline + void + color4( float const Red, float const Green, float const Blue, float const Alpha ) { + return color4( glm::vec4{ Red, Green, Blue, Alpha } ); } + inline + void + color4( float const *Value ) { + return color4( glm::make_vec4( Value ) ); + } + inline + glm::vec4 const & + data() const { + return m_color; } + inline + float const * + data_array() const { + return glm::value_ptr( m_color ); } + +private: +// members: + glm::vec4 m_color { -1 }; +}; + +extern opengl_color OpenGLColor; + +// NOTE: standard opengl calls re-definitions +#define glColor3f OpenGLColor.color3 +#define glColor3fv OpenGLColor.color3 +#define glColor4f OpenGLColor.color4 +#define glColor4fv OpenGLColor.color4 + +//--------------------------------------------------------------------------- diff --git a/openglgeometrybank.cpp b/openglgeometrybank.cpp new file mode 100644 index 00000000..02fde9db --- /dev/null +++ b/openglgeometrybank.cpp @@ -0,0 +1,443 @@ +/* +This Source Code Form is subject to the +terms of the Mozilla Public License, v. +2.0. If a copy of the MPL was not +distributed with this file, You can +obtain one at +http://mozilla.org/MPL/2.0/. +*/ + +#include "stdafx.h" +#include "openglgeometrybank.h" + +#include "sn_utils.h" +#include "logs.h" +#include "globals.h" + +namespace gfx { + +void +basic_vertex::serialize( std::ostream &s ) const { + + sn_utils::ls_float32( s, position.x ); + sn_utils::ls_float32( s, position.y ); + sn_utils::ls_float32( s, position.z ); + + sn_utils::ls_float32( s, normal.x ); + sn_utils::ls_float32( s, normal.y ); + sn_utils::ls_float32( s, normal.z ); + + sn_utils::ls_float32( s, texture.x ); + sn_utils::ls_float32( s, texture.y ); +} + +void +basic_vertex::deserialize( std::istream &s ) { + + position.x = sn_utils::ld_float32( s ); + position.y = sn_utils::ld_float32( s ); + position.z = sn_utils::ld_float32( s ); + + normal.x = sn_utils::ld_float32( s ); + normal.y = sn_utils::ld_float32( s ); + normal.z = sn_utils::ld_float32( s ); + + texture.x = sn_utils::ld_float32( s ); + texture.y = sn_utils::ld_float32( s ); +} + +// generic geometry bank class, allows storage, update and drawing of geometry chunks + +// creates a new geometry chunk of specified type from supplied vertex data. returns: handle to the chunk +gfx::geometry_handle +geometry_bank::create( gfx::vertex_array &Vertices, unsigned int const Type ) { + + if( true == Vertices.empty() ) { return { 0, 0 }; } + + m_chunks.emplace_back( Vertices, Type ); + // NOTE: handle is effectively (index into chunk array + 1) this leaves value of 0 to serve as error/empty handle indication + gfx::geometry_handle chunkhandle { 0, static_cast(m_chunks.size()) }; + // template method implementation + create_( chunkhandle ); + // all done + return chunkhandle; +} + +// replaces data of specified chunk with the supplied vertex data, starting from specified offset +bool +geometry_bank::replace( gfx::vertex_array &Vertices, gfx::geometry_handle const &Geometry, std::size_t const Offset ) { + + if( ( Geometry.chunk == 0 ) || ( Geometry.chunk > m_chunks.size() ) ) { return false; } + + auto &chunk = gfx::geometry_bank::chunk( Geometry ); + + if( ( Offset == 0 ) + && ( Vertices.size() == chunk.vertices.size() ) ) { + // check first if we can get away with a simple swap... + chunk.vertices.swap( Vertices ); + } + else { + // ...otherwise we need to do some legwork + // NOTE: if the offset is larger than existing size of the chunk, it'll bridge the gap with 'blank' vertices + // TBD: we could bail out with an error instead if such request occurs + chunk.vertices.resize( Offset + Vertices.size(), gfx::basic_vertex() ); + chunk.vertices.insert( std::end( chunk.vertices ), std::begin( Vertices ), std::end( Vertices ) ); + } + // template method implementation + replace_( Geometry ); + // all done + return true; +} + +// adds supplied vertex data at the end of specified chunk +bool +geometry_bank::append( gfx::vertex_array &Vertices, gfx::geometry_handle const &Geometry ) { + + if( ( Geometry.chunk == 0 ) || ( Geometry.chunk > m_chunks.size() ) ) { return false; } + + return replace( Vertices, Geometry, gfx::geometry_bank::chunk( Geometry ).vertices.size() ); +} + +// draws geometry stored in specified chunk +void +geometry_bank::draw( gfx::geometry_handle const &Geometry, gfx::stream_units const &Units, unsigned int const Streams ) { + // template method implementation + draw_( Geometry, Units, Streams ); +} + +// frees subclass-specific resources associated with the bank, typically called when the bank wasn't in use for a period of time +void +geometry_bank::release() { + // template method implementation + release_(); +} + +vertex_array const & +geometry_bank::vertices( gfx::geometry_handle const &Geometry ) const { + + return geometry_bank::chunk( Geometry ).vertices; +} + +// opengl vbo-based variant of the geometry bank + +GLuint opengl_vbogeometrybank::m_activebuffer { 0 }; // buffer bound currently on the opengl end, if any +unsigned int opengl_vbogeometrybank::m_activestreams { gfx::stream::none }; // currently enabled data type pointers +std::vector opengl_vbogeometrybank::m_activetexturearrays; // currently enabled texture coord arrays + +// create() subclass details +void +opengl_vbogeometrybank::create_( gfx::geometry_handle const &Geometry ) { + // adding a chunk means we'll be (re)building the buffer, which will fill the chunk records, amongst other things. + // thus we don't need to initialize the values here + m_chunkrecords.emplace_back( chunk_record() ); + // kiss the existing buffer goodbye, new overall data size means we'll be making a new one + delete_buffer(); +} + +// replace() subclass details +void +opengl_vbogeometrybank::replace_( gfx::geometry_handle const &Geometry ) { + + auto &chunkrecord = m_chunkrecords[ Geometry.chunk - 1 ]; + chunkrecord.is_good = false; + // if the overall length of the chunk didn't change we can get away with reusing the old buffer... + if( geometry_bank::chunk( Geometry ).vertices.size() != chunkrecord.size ) { + // ...but otherwise we'll need to allocate a new one + // TBD: we could keep and reuse the old buffer also if the new chunk is smaller than the old one, + // but it'd require some extra tracking and work to keep all chunks up to date; also wasting vram; may be not worth it? + delete_buffer(); + } +} + +// draw() subclass details +void +opengl_vbogeometrybank::draw_( gfx::geometry_handle const &Geometry, gfx::stream_units const &Units, unsigned int const Streams ) { + + if( m_buffer == 0 ) { + // if there's no buffer, we'll have to make one + // NOTE: this isn't exactly optimal in terms of ensuring the gfx card doesn't stall waiting for the data + // may be better to initiate upload earlier (during update phase) and trust this effort won't go to waste + if( true == m_chunks.empty() ) { return; } + + std::size_t datasize{ 0 }; + auto chunkiterator = m_chunks.cbegin(); + for( auto &chunkrecord : m_chunkrecords ) { + // fill records for all chunks, based on the chunk data + chunkrecord.is_good = false; // if we're re-creating buffer, chunks might've been uploaded in the old one + chunkrecord.offset = datasize; + chunkrecord.size = chunkiterator->vertices.size(); + datasize += chunkrecord.size; + ++chunkiterator; + } + // the odds for all created chunks to get replaced with empty ones are quite low, but the possibility does exist + if( datasize == 0 ) { return; } + // try to set up the buffer we need + ::glGenBuffers( 1, &m_buffer ); + bind_buffer(); + // NOTE: we're using static_draw since it's generally true for all we have implemented at the moment + // TODO: allow to specify usage hint at the object creation, and pass it here + ::glBufferData( + GL_ARRAY_BUFFER, + datasize * sizeof( gfx::basic_vertex ), + nullptr, + GL_STATIC_DRAW ); + if( ::glGetError() == GL_OUT_OF_MEMORY ) { + // TBD: throw a bad_alloc? + ErrorLog( "openGL error: out of memory; failed to create a geometry buffer" ); + delete_buffer(); + return; + } + m_buffercapacity = datasize; + } + // actual draw procedure starts here + // setup... + if( m_activebuffer != m_buffer ) { + bind_buffer(); + } + auto &chunkrecord = m_chunkrecords[ Geometry.chunk - 1 ]; + auto const &chunk = gfx::geometry_bank::chunk( Geometry ); + if( false == chunkrecord.is_good ) { + // we may potentially need to upload new buffer data before we can draw it + ::glBufferSubData( + GL_ARRAY_BUFFER, + chunkrecord.offset * sizeof( gfx::basic_vertex ), + chunkrecord.size * sizeof( gfx::basic_vertex ), + chunk.vertices.data() ); + chunkrecord.is_good = true; + } + if( m_activestreams != Streams ) { + bind_streams( Units, Streams ); + } + // ...render... + ::glDrawArrays( chunk.type, chunkrecord.offset, chunkrecord.size ); + // ...post-render cleanup +/* + ::glDisableClientState( GL_VERTEX_ARRAY ); + ::glDisableClientState( GL_NORMAL_ARRAY ); + ::glDisableClientState( GL_TEXTURE_COORD_ARRAY ); + ::glBindBuffer( GL_ARRAY_BUFFER, 0 ); m_activebuffer = 0; +*/ +} + +// release () subclass details +void +opengl_vbogeometrybank::release_() { + + delete_buffer(); +} + +void +opengl_vbogeometrybank::bind_buffer() { + + ::glBindBuffer( GL_ARRAY_BUFFER, m_buffer ); + m_activebuffer = m_buffer; + m_activestreams = gfx::stream::none; +} + +void +opengl_vbogeometrybank::delete_buffer() { + + if( m_buffer != 0 ) { + + ::glDeleteBuffers( 1, &m_buffer ); + if( m_activebuffer == m_buffer ) { + m_activebuffer = 0; + release_streams(); + } + m_buffer = 0; + m_buffercapacity = 0; + // NOTE: since we've deleted the buffer all chunks it held were rendered invalid as well + // instead of clearing their state here we're delaying it until new buffer is created to avoid looping through chunk records twice + } +} + +void +opengl_vbogeometrybank::bind_streams( gfx::stream_units const &Units, unsigned int const Streams ) { + + if( Streams & gfx::stream::position ) { + ::glVertexPointer( 3, GL_FLOAT, sizeof( gfx::basic_vertex ), static_cast( nullptr ) ); + ::glEnableClientState( GL_VERTEX_ARRAY ); + } + else { + ::glDisableClientState( GL_VERTEX_ARRAY ); + } + // NOTE: normal and color streams share the data, making them effectively mutually exclusive + if( Streams & gfx::stream::normal ) { + ::glNormalPointer( GL_FLOAT, sizeof( gfx::basic_vertex ), static_cast( nullptr ) + sizeof( float ) * 3 ); + ::glEnableClientState( GL_NORMAL_ARRAY ); + } + else { + ::glDisableClientState( GL_NORMAL_ARRAY ); + } + if( Streams & gfx::stream::color ) { + ::glColorPointer( 3, GL_FLOAT, sizeof( gfx::basic_vertex ), static_cast( nullptr ) + sizeof( float ) * 3 ); + ::glEnableClientState( GL_COLOR_ARRAY ); + } + else { + ::glDisableClientState( GL_COLOR_ARRAY ); + } + if( Streams & gfx::stream::texture ) { + for( auto unit : Units.texture ) { + ::glClientActiveTexture( unit ); + ::glTexCoordPointer( 2, GL_FLOAT, sizeof( gfx::basic_vertex ), static_cast( nullptr ) + 24 ); + ::glEnableClientState( GL_TEXTURE_COORD_ARRAY ); + } + m_activetexturearrays = Units.texture; + } + else { + for( auto unit : Units.texture ) { + ::glClientActiveTexture( unit ); + ::glDisableClientState( GL_TEXTURE_COORD_ARRAY ); + } + m_activetexturearrays.clear(); // NOTE: we're simplifying here, since we always toggle the same texture coord sets + } + + m_activestreams = Streams; +} + +void +opengl_vbogeometrybank::release_streams() { + + ::glDisableClientState( GL_VERTEX_ARRAY ); + ::glDisableClientState( GL_NORMAL_ARRAY ); + ::glDisableClientState( GL_COLOR_ARRAY ); + for( auto unit : m_activetexturearrays ) { + ::glClientActiveTexture( unit ); + ::glDisableClientState( GL_TEXTURE_COORD_ARRAY ); + } + + m_activestreams = gfx::stream::none; + m_activetexturearrays.clear(); +} + +// opengl display list based variant of the geometry bank + +// create() subclass details +void +opengl_dlgeometrybank::create_( gfx::geometry_handle const &Geometry ) { + + m_chunkrecords.emplace_back( chunk_record() ); +} + +// replace() subclass details +void +opengl_dlgeometrybank::replace_( gfx::geometry_handle const &Geometry ) { + + delete_list( Geometry ); +} + +// draw() subclass details +void +opengl_dlgeometrybank::draw_( gfx::geometry_handle const &Geometry, gfx::stream_units const &Units, unsigned int const Streams ) { + + auto &chunkrecord = m_chunkrecords[ Geometry.chunk - 1 ]; + if( chunkrecord.streams != Streams ) { + delete_list( Geometry ); + } + if( chunkrecord.list == 0 ) { + // we don't have a list ready, so compile one + chunkrecord.streams = Streams; + chunkrecord.list = ::glGenLists( 1 ); + auto const &chunk = gfx::geometry_bank::chunk( Geometry ); + ::glNewList( chunkrecord.list, GL_COMPILE ); + + ::glBegin( chunk.type ); + for( auto const &vertex : chunk.vertices ) { + if( Streams & gfx::stream::normal ) { ::glNormal3fv( glm::value_ptr( vertex.normal ) ); } + else if( Streams & gfx::stream::color ) { ::glColor3fv( glm::value_ptr( vertex.normal ) ); } + if( Streams & gfx::stream::texture ) { for( auto unit : Units.texture ) { ::glMultiTexCoord2fv( unit, glm::value_ptr( vertex.texture ) ); } } + if( Streams & gfx::stream::position ) { ::glVertex3fv( glm::value_ptr( vertex.position ) ); } + } + ::glEnd(); + ::glEndList(); + } + // with the list done we can just play it + ::glCallList( chunkrecord.list ); +} + +// release () subclass details +void +opengl_dlgeometrybank::release_() { + + for( auto &chunkrecord : m_chunkrecords ) { + if( chunkrecord.list != 0 ) { + ::glDeleteLists( chunkrecord.list, 1 ); + chunkrecord.list = 0; + } + chunkrecord.streams = gfx::stream::none; + } +} + +void +opengl_dlgeometrybank::delete_list( gfx::geometry_handle const &Geometry ) { + // NOTE: given it's our own internal method we trust it to be called with valid parameters + auto &chunkrecord = m_chunkrecords[ Geometry.chunk - 1 ]; + if( chunkrecord.list != 0 ) { + ::glDeleteLists( chunkrecord.list, 1 ); + chunkrecord.list = 0; + } + chunkrecord.streams = gfx::stream::none; +} + +// geometry bank manager, holds collection of geometry banks + +// performs a resource sweep +void +geometrybank_manager::update() { + + m_garbagecollector.sweep(); +} + +// creates a new geometry bank. returns: handle to the bank or NULL +gfx::geometrybank_handle +geometrybank_manager::create_bank() { + + if( true == Global.bUseVBO ) { m_geometrybanks.emplace_back( std::make_shared(), std::chrono::steady_clock::time_point() ); } + else { m_geometrybanks.emplace_back( std::make_shared(), std::chrono::steady_clock::time_point() ); } + // NOTE: handle is effectively (index into chunk array + 1) this leaves value of 0 to serve as error/empty handle indication + return { static_cast( m_geometrybanks.size() ), 0 }; +} + +// creates a new geometry chunk of specified type from supplied vertex data, in specified bank. returns: handle to the chunk or NULL +gfx::geometry_handle +geometrybank_manager::create_chunk( gfx::vertex_array &Vertices, gfx::geometrybank_handle const &Geometry, int const Type ) { + + auto const newchunkhandle = bank( Geometry ).first->create( Vertices, Type ); + + if( newchunkhandle.chunk != 0 ) { return { Geometry.bank, newchunkhandle.chunk }; } + else { return { 0, 0 }; } +} + +// replaces data of specified chunk with the supplied vertex data, starting from specified offset +bool +geometrybank_manager::replace( gfx::vertex_array &Vertices, gfx::geometry_handle const &Geometry, std::size_t const Offset ) { + + return bank( Geometry ).first->replace( Vertices, Geometry, Offset ); +} + +// adds supplied vertex data at the end of specified chunk +bool +geometrybank_manager::append( gfx::vertex_array &Vertices, gfx::geometry_handle const &Geometry ) { + + return bank( Geometry ).first->append( Vertices, Geometry ); +} +// draws geometry stored in specified chunk +void +geometrybank_manager::draw( gfx::geometry_handle const &Geometry, unsigned int const Streams ) { + + if( Geometry == null_handle ) { return; } + + auto &bankrecord = bank( Geometry ); + + bankrecord.second = m_garbagecollector.timestamp(); + bankrecord.first->draw( Geometry, m_units, Streams ); +} + +// provides direct access to vertex data of specfied chunk +gfx::vertex_array const & +geometrybank_manager::vertices( gfx::geometry_handle const &Geometry ) const { + + return bank( Geometry ).first->vertices( Geometry ); +} + +} // namespace gfx diff --git a/openglgeometrybank.h b/openglgeometrybank.h new file mode 100644 index 00000000..f83d575d --- /dev/null +++ b/openglgeometrybank.h @@ -0,0 +1,330 @@ +/* +This Source Code Form is subject to the +terms of the Mozilla Public License, v. +2.0. If a copy of the MPL was not +distributed with this file, You can +obtain one at +http://mozilla.org/MPL/2.0/. +*/ + +#pragma once + +#include +#include +#include +#include "GL/glew.h" +#ifdef _WIN32 +#include "GL/wglew.h" +#endif +#include "ResourceManager.h" + +namespace gfx { + +struct basic_vertex { + + glm::vec3 position; // 3d space + glm::vec3 normal; // 3d space + glm::vec2 texture; // uv space + + basic_vertex() = default; + basic_vertex( glm::vec3 Position, glm::vec3 Normal, glm::vec2 Texture ) : + position( Position ), normal( Normal ), texture( Texture ) + {} + void serialize( std::ostream& ) const; + void deserialize( std::istream& ); +}; + +// data streams carried in a vertex +enum stream { + none = 0x0, + position = 0x1, + normal = 0x2, + color = 0x4, // currently normal and colour streams are stored in the same slot, and mutually exclusive + texture = 0x8 +}; + +unsigned int const basic_streams { stream::position | stream::normal | stream::texture }; +unsigned int const color_streams { stream::position | stream::color | stream::texture }; + +struct stream_units { + + std::vector texture { GL_TEXTURE0 }; // unit associated with main texture data stream. TODO: allow multiple units per stream +}; + +using vertex_array = std::vector; + +// generic geometry bank class, allows storage, update and drawing of geometry chunks + +struct geometry_handle { +// constructors + geometry_handle() : + bank( 0 ), chunk( 0 ) + {} + geometry_handle( std::uint32_t Bank, std::uint32_t Chunk ) : + bank( Bank ), chunk( Chunk ) + {} +// methods + inline + operator std::uint64_t() const { +/* + return bank << 14 | chunk; } +*/ + return ( std::uint64_t { bank } << 32 | chunk ); + } + +// members +/* + std::uint32_t + bank : 18, // 250k banks + chunk : 14; // 16k chunks per bank +*/ + std::uint32_t bank; + std::uint32_t chunk; +}; + +class geometry_bank { + +public: +// types: + +// constructors: + +// destructor: + virtual + ~geometry_bank() {} + +// methods: + // creates a new geometry chunk of specified type from supplied vertex data. returns: handle to the chunk or NULL + gfx::geometry_handle + create( gfx::vertex_array &Vertices, unsigned int const Type ); + // replaces data of specified chunk with the supplied vertex data, starting from specified offset + bool + replace( gfx::vertex_array &Vertices, gfx::geometry_handle const &Geometry, std::size_t const Offset = 0 ); + // adds supplied vertex data at the end of specified chunk + bool + append( gfx::vertex_array &Vertices, gfx::geometry_handle const &Geometry ); + // draws geometry stored in specified chunk + void + draw( gfx::geometry_handle const &Geometry, gfx::stream_units const &Units, unsigned int const Streams = basic_streams ); + // draws geometry stored in supplied list of chunks + template + void + draw( Iterator_ First, Iterator_ Last, gfx::stream_units const &Units, unsigned int const Streams = basic_streams ) { while( First != Last ) { draw( *First, Units, Streams ); ++First; } } + // frees subclass-specific resources associated with the bank, typically called when the bank wasn't in use for a period of time + void + release(); + // provides direct access to vertex data of specfied chunk + gfx::vertex_array const & + vertices( gfx::geometry_handle const &Geometry ) const; + +protected: +// types: + struct geometry_chunk { + unsigned int type; // kind of geometry used by the chunk + gfx::vertex_array vertices; // geometry data + // NOTE: constructor doesn't copy provided vertex data, but moves it + geometry_chunk( gfx::vertex_array &Vertices, unsigned int Type ) : + type( Type ) + { + vertices.swap( Vertices ); + } + }; + + using geometrychunk_sequence = std::vector; + +// methods + inline + geometry_chunk & + chunk( gfx::geometry_handle const Geometry ) { + return m_chunks[ Geometry.chunk - 1 ]; } + inline + geometry_chunk const & + chunk( gfx::geometry_handle const Geometry ) const { + return m_chunks[ Geometry.chunk - 1 ]; } + +// members: + geometrychunk_sequence m_chunks; + +private: +// methods: + // create() subclass details + virtual void create_( gfx::geometry_handle const &Geometry ) = 0; + // replace() subclass details + virtual void replace_( gfx::geometry_handle const &Geometry ) = 0; + // draw() subclass details + virtual void draw_( gfx::geometry_handle const &Geometry, gfx::stream_units const &Units, unsigned int const Streams ) = 0; + // resource release subclass details + virtual void release_() = 0; +}; + +// opengl vbo-based variant of the geometry bank + +class opengl_vbogeometrybank : public geometry_bank { + +public: +// constructors: + opengl_vbogeometrybank() = default; +// destructor + ~opengl_vbogeometrybank() { + delete_buffer(); } +// methods: + static + void + reset() { + m_activebuffer = 0; + m_activestreams = gfx::stream::none; } + +private: +// types: + struct chunk_record{ + std::size_t offset{ 0 }; // beginning of the chunk data as offset from the beginning of the last established buffer + std::size_t size{ 0 }; // size of the chunk in the last established buffer + bool is_good{ false }; // true if local content of the chunk matches the data on the opengl end + }; + + using chunkrecord_sequence = std::vector; + +// methods: + // create() subclass details + void + create_( gfx::geometry_handle const &Geometry ) override; + // replace() subclass details + void + replace_( gfx::geometry_handle const &Geometry ) override; + // draw() subclass details + void + draw_( gfx::geometry_handle const &Geometry, gfx::stream_units const &Units, unsigned int const Streams ) override; + // release() subclass details + void + release_() override; + void + bind_buffer(); + void + delete_buffer(); + static + void + bind_streams( gfx::stream_units const &Units, unsigned int const Streams ); + static + void + release_streams(); + +// members: + static GLuint m_activebuffer; // buffer bound currently on the opengl end, if any + static unsigned int m_activestreams; + static std::vector m_activetexturearrays; + GLuint m_buffer { 0 }; // id of the buffer holding data on the opengl end + std::size_t m_buffercapacity{ 0 }; // total capacity of the last established buffer + chunkrecord_sequence m_chunkrecords; // helper data for all stored geometry chunks, in matching order + +}; + +// opengl display list based variant of the geometry bank + +class opengl_dlgeometrybank : public geometry_bank { + +public: +// constructors: + opengl_dlgeometrybank() = default; +// destructor: + ~opengl_dlgeometrybank() { + for( auto &chunkrecord : m_chunkrecords ) { + ::glDeleteLists( chunkrecord.list, 1 ); } } + +private: +// types: + struct chunk_record { + GLuint list { 0 }; // display list associated with the chunk + unsigned int streams { 0 }; // stream combination used to generate the display list + }; + + using chunkrecord_sequence = std::vector; + +// methods: + // create() subclass details + void + create_( gfx::geometry_handle const &Geometry ) override; + // replace() subclass details + void + replace_( gfx::geometry_handle const &Geometry ) override; + // draw() subclass details + void + draw_( gfx::geometry_handle const &Geometry, gfx::stream_units const &Units, unsigned int const Streams ) override; + // release () subclass details + void + release_() override; + void + delete_list( gfx::geometry_handle const &Geometry ); + +// members: + chunkrecord_sequence m_chunkrecords; // helper data for all stored geometry chunks, in matching order + +}; + +// geometry bank manager, holds collection of geometry banks + +using geometrybank_handle = geometry_handle; + +class geometrybank_manager { + +public: +// constructors + geometrybank_manager() = default; +// methods: + // performs a resource sweep + void update(); + // creates a new geometry bank. returns: handle to the bank or NULL + gfx::geometrybank_handle + create_bank(); + // creates a new geometry chunk of specified type from supplied vertex data, in specified bank. returns: handle to the chunk or NULL + gfx::geometry_handle + create_chunk( gfx::vertex_array &Vertices, gfx::geometrybank_handle const &Geometry, int const Type ); + // replaces data of specified chunk with the supplied vertex data, starting from specified offset + bool + replace( gfx::vertex_array &Vertices, gfx::geometry_handle const &Geometry, std::size_t const Offset = 0 ); + // adds supplied vertex data at the end of specified chunk + bool + append( gfx::vertex_array &Vertices, gfx::geometry_handle const &Geometry ); + // draws geometry stored in specified chunk + void + draw( gfx::geometry_handle const &Geometry, unsigned int const Streams = basic_streams ); + template + void + draw( Iterator_ First, Iterator_ Last, unsigned int const Streams = basic_streams ) { + while( First != Last ) { + draw( *First, Streams ); + ++First; } } + // provides direct access to vertex data of specfied chunk + gfx::vertex_array const & + vertices( gfx::geometry_handle const &Geometry ) const; + // sets target texture unit for the texture data stream + gfx::stream_units & + units() { return m_units; } + +private: +// types: + using geometrybanktimepoint_pair = std::pair< std::shared_ptr, resource_timestamp >; + using geometrybanktimepointpair_sequence = std::deque< geometrybanktimepoint_pair >; + + // members: + geometrybanktimepointpair_sequence m_geometrybanks; + garbage_collector m_garbagecollector { m_geometrybanks, 60, 120, "geometry buffer" }; + gfx::stream_units m_units; + +// methods + inline + bool + valid( gfx::geometry_handle const &Geometry ) const { + return ( ( Geometry.bank != 0 ) + && ( Geometry.bank <= m_geometrybanks.size() ) ); } + inline + geometrybanktimepointpair_sequence::value_type & + bank( gfx::geometry_handle const Geometry ) { + return m_geometrybanks[ Geometry.bank - 1 ]; } + inline + geometrybanktimepointpair_sequence::value_type const & + bank( gfx::geometry_handle const Geometry ) const { + return m_geometrybanks[ Geometry.bank - 1 ]; } + +}; + +} // namespace gfx \ No newline at end of file diff --git a/openglmatrixstack.cpp b/openglmatrixstack.cpp new file mode 100644 index 00000000..f01c98e2 --- /dev/null +++ b/openglmatrixstack.cpp @@ -0,0 +1,13 @@ +/* +This Source Code Form is subject to the +terms of the Mozilla Public License, v. +2.0. If a copy of the MPL was not +distributed with this file, You can +obtain one at +http://mozilla.org/MPL/2.0/. +*/ + +#include "stdafx.h" +#include "openglmatrixstack.h" + +opengl_matrices OpenGLMatrices; diff --git a/openglmatrixstack.h b/openglmatrixstack.h new file mode 100644 index 00000000..b37a1532 --- /dev/null +++ b/openglmatrixstack.h @@ -0,0 +1,227 @@ +/* +This Source Code Form is subject to the +terms of the Mozilla Public License, v. +2.0. If a copy of the MPL was not +distributed with this file, You can +obtain one at +http://mozilla.org/MPL/2.0/. +*/ + +#pragma once + +#include +#include +#include +#include +#include +#include "GL/glew.h" +#ifdef _WIN32 +#include "GL/wglew.h" +#endif + +// encapsulation of the fixed pipeline opengl matrix stack +class opengl_matrices { + +// types: +class opengl_stack { + +public: +// constructors: + opengl_stack() { m_stack.emplace(1.f); } + +// methods: + glm::mat4 const & + data() const { + return m_stack.top(); } + void + push_matrix() { + m_stack.emplace( m_stack.top() ); } + void + pop_matrix() { + if( m_stack.size() > 1 ) { + m_stack.pop(); + upload(); } } + void + load_identity() { + m_stack.top() = glm::mat4( 1.f ); + upload(); } + void + load_matrix( glm::mat4 const &Matrix ) { + m_stack.top() = Matrix; + upload(); } + void + rotate( float const Angle, glm::vec3 const &Axis ) { + m_stack.top() = glm::rotate( m_stack.top(), Angle, Axis ); + upload(); } + void + translate( glm::vec3 const &Translation ) { + m_stack.top() = glm::translate( m_stack.top(), Translation ); + upload(); } + void + scale( glm::vec3 const &Scale ) { + m_stack.top() = glm::scale( m_stack.top(), Scale ); + upload(); } + void + multiply( glm::mat4 const &Matrix ) { + m_stack.top() *= Matrix; + upload(); } + void + ortho( float const Left, float const Right, float const Bottom, float const Top, float const Znear, float const Zfar ) { + m_stack.top() *= glm::ortho( Left, Right, Bottom, Top, Znear, Zfar ); + upload(); } + void + perspective( float const Fovy, float const Aspect, float const Znear, float const Zfar ) { + m_stack.top() *= glm::perspective( Fovy, Aspect, Znear, Zfar ); + upload(); } + void + look_at( glm::vec3 const &Eye, glm::vec3 const &Center, glm::vec3 const &Up ) { + m_stack.top() *= glm::lookAt( Eye, Center, Up ); + upload(); } + +private: +// types: + typedef std::stack mat4_stack; + +// methods: + void + upload() { ::glLoadMatrixf( glm::value_ptr( m_stack.top() ) ); } + +// members: + mat4_stack m_stack; +}; + +enum stack_mode { gl_modelview = 0, gl_projection = 1, gl_texture = 2 }; +typedef std::vector openglstack_array; + +public: +// constructors: + opengl_matrices() { + m_stacks.emplace_back(); // modelview + m_stacks.emplace_back(); // projection + m_stacks.emplace_back(); // texture + } + +// methods: + void + mode( GLuint const Mode ) { + switch( Mode ) { + case GL_MODELVIEW: { m_mode = stack_mode::gl_modelview; break; } + case GL_PROJECTION: { m_mode = stack_mode::gl_projection; break; } + case GL_TEXTURE: { m_mode = stack_mode::gl_texture; break; } + default: { break; } } + ::glMatrixMode( Mode ); } + glm::mat4 const & + data( GLuint const Mode = -1 ) const { + switch( Mode ) { + case GL_MODELVIEW: { return m_stacks[ stack_mode::gl_modelview ].data(); } + case GL_PROJECTION: { return m_stacks[ stack_mode::gl_projection ].data(); } + case GL_TEXTURE: { return m_stacks[ stack_mode::gl_texture ].data(); } + default: { return m_stacks[ m_mode ].data(); } } } + float const * + data_array( GLuint const Mode = -1 ) const { + return glm::value_ptr( data( Mode ) ); } + void + push_matrix() { m_stacks[ m_mode ].push_matrix(); } + void + pop_matrix() { m_stacks[ m_mode ].pop_matrix(); } + void + load_identity() { m_stacks[ m_mode ].load_identity(); } + void + load_matrix( glm::mat4 const &Matrix ) { m_stacks[ m_mode ].load_matrix( Matrix ); } + template + void + load_matrix( Type_ const *Matrix ) { load_matrix( glm::make_mat4( Matrix ) ); } + template + void + rotate( Type_ const Angle, Type_ const X, Type_ const Y, Type_ const Z ) { + m_stacks[ m_mode ].rotate( + static_cast(glm::radians(Angle)), + glm::vec3( + static_cast( X ), + static_cast( Y ), + static_cast( Z ) ) ); } + template + void + translate( Type_ const X, Type_ const Y, Type_ const Z ) { + m_stacks[ m_mode ].translate( + glm::vec3( + static_cast( X ), + static_cast( Y ), + static_cast( Z ) ) ); } + template + void + scale( Type_ const X, Type_ const Y, Type_ const Z ) { + m_stacks[ m_mode ].scale( + glm::vec3( + static_cast( X ), + static_cast( Y ), + static_cast( Z ) ) ); } + template + void + multiply( Type_ const *Matrix ) { + m_stacks[ m_mode ].multiply( + glm::make_mat4( Matrix ) ); } + template + void + ortho( Type_ const Left, Type_ const Right, Type_ const Bottom, Type_ const Top, Type_ const Znear, Type_ const Zfar ) { + m_stacks[ m_mode ].ortho( + static_cast( Left ), + static_cast( Right ), + static_cast( Bottom ), + static_cast( Top ), + static_cast( Znear ), + static_cast( Zfar ) ); } + template + void + perspective( Type_ const Fovy, Type_ const Aspect, Type_ const Znear, Type_ const Zfar ) { + m_stacks[ m_mode ].perspective( + static_cast( glm::radians( Fovy ) ), + static_cast( Aspect ), + static_cast( Znear ), + static_cast( Zfar ) ); } + template + void + look_at( Type_ const Eyex, Type_ const Eyey, Type_ const Eyez, Type_ const Centerx, Type_ const Centery, Type_ const Centerz, Type_ const Upx, Type_ const Upy, Type_ const Upz ) { + m_stacks[ m_mode ].look_at( + glm::vec3( + static_cast( Eyex ), + static_cast( Eyey ), + static_cast( Eyez ) ), + glm::vec3( + static_cast( Centerx ), + static_cast( Centery ), + static_cast( Centerz ) ), + glm::vec3( + static_cast( Upx ), + static_cast( Upy ), + static_cast( Upz ) ) ); } + +private: +// members: + stack_mode m_mode{ stack_mode::gl_projection }; + openglstack_array m_stacks; + +}; + +extern opengl_matrices OpenGLMatrices; + +// NOTE: standard opengl calls re-definitions +#define glMatrixMode OpenGLMatrices.mode +#define glPushMatrix OpenGLMatrices.push_matrix +#define glPopMatrix OpenGLMatrices.pop_matrix +#define glLoadIdentity OpenGLMatrices.load_identity +#define glLoadMatrixf OpenGLMatrices.load_matrix +#define glLoadMatrixd OpenGLMatrices.load_matrix +#define glRotated OpenGLMatrices.rotate +#define glRotatef OpenGLMatrices.rotate +#define glTranslated OpenGLMatrices.translate +#define glTranslatef OpenGLMatrices.translate +#define glScaled OpenGLMatrices.scale +#define glScalef OpenGLMatrices.scale +#define glMultMatrixd OpenGLMatrices.multiply +#define glMultMatrixf OpenGLMatrices.multiply +#define glOrtho OpenGLMatrices.ortho +#define gluPerspective OpenGLMatrices.perspective +#define gluLookAt OpenGLMatrices.look_at + +//--------------------------------------------------------------------------- diff --git a/parser.cpp b/parser.cpp index 46cd8701..01820a80 100644 --- a/parser.cpp +++ b/parser.cpp @@ -9,8 +9,11 @@ http://mozilla.org/MPL/2.0/. #include "stdafx.h" #include "parser.h" +#include "utilities.h" #include "logs.h" +#include "scenenodegroups.h" + /* MaSzyna EU07 locomotive simulator parser Copyright (C) 2003 TOLARIS @@ -21,52 +24,113 @@ http://mozilla.org/MPL/2.0/. // cParser -- generic class for parsing text data. // constructors -cParser::cParser( std::string const &Stream, buffertype const Type, std::string Path, bool const Loadtraction ) -{ - LoadTraction = Loadtraction; - // build comments map - mComments.insert(commentmap::value_type("/*", "*/")); - mComments.insert(commentmap::value_type("//", "\n")); - // mComments.insert(commentmap::value_type("--","\n")); //Ra: to chyba nie używane +cParser::cParser( std::string const &Stream, buffertype const Type, std::string Path, bool const Loadtraction, std::vector Parameters ) : + mPath(Path), + LoadTraction( Loadtraction ) { // store to calculate sub-sequent includes from relative path - mPath = Path; - // reset pointers and attach proper type of buffer - switch (Type) - { - case buffer_FILE: - Path.append(Stream); - mStream = new std::ifstream(Path.c_str()); - break; - case buffer_TEXT: - mStream = new std::istringstream(Stream); - break; - default: - mStream = NULL; + if( Type == buffertype::buffer_FILE ) { + mFile = Stream; + } + // reset pointers and attach proper type of buffer + switch (Type) { + case buffer_FILE: { + Path.append( Stream ); + mStream = std::make_shared( Path ); + // content of *.inc files is potentially grouped together + if( ( Stream.size() >= 4 ) + && ( ToLower( Stream.substr( Stream.size() - 4 ) ) == ".inc" ) ) { + mIncFile = true; + scene::Groups.create(); + } + break; + } + case buffer_TEXT: { + mStream = std::make_shared( Stream ); + break; + } + default: { + break; + } } - mIncludeParser = NULL; // calculate stream size if (mStream) { - mSize = mStream->rdbuf()->pubseekoff(0, std::ios_base::end); - mStream->rdbuf()->pubseekoff(0, std::ios_base::beg); + if( true == mStream->fail() ) { + ErrorLog( "Failed to open file \"" + Path + "\"" ); + } + else { + mSize = mStream->rdbuf()->pubseekoff( 0, std::ios_base::end ); + mStream->rdbuf()->pubseekoff( 0, std::ios_base::beg ); + mLine = 1; + } + } + // set parameter set if one was provided + if( false == Parameters.empty() ) { + parameters.swap( Parameters ); } - else - mSize = 0; } // destructor -cParser::~cParser() -{ - if (mIncludeParser) - delete mIncludeParser; - if (mStream) - delete mStream; - mComments.clear(); +cParser::~cParser() { + + if( true == mIncFile ) { + // wrap up the node group holding content of processed file + scene::Groups.close(); + } +} + +template<> +cParser& +cParser::operator>>( std::string &Right ) { + + if( true == this->tokens.empty() ) { return *this; } + + Right = this->tokens.front(); + this->tokens.pop_front(); + + return *this; +} + +template<> +cParser& +cParser::operator>>( bool &Right ) { + + if( true == this->tokens.empty() ) { return *this; } + + Right = ( ( this->tokens.front() == "true" ) + || ( this->tokens.front() == "yes" ) + || ( this->tokens.front() == "1" ) ); + this->tokens.pop_front(); + + return *this; +} + +template <> +bool +cParser::getToken( bool const ToLower, const char *Break ) { + + auto const token = getToken( true, Break ); + return ( ( token == "true" ) + || ( token == "yes" ) + || ( token == "1" ) ); } // methods -bool cParser::getTokens(int Count, bool ToLower, const char *Break) +cParser & +cParser::autoclear( bool const Autoclear ) { + + m_autoclear = Autoclear; + if( mIncludeParser ) { mIncludeParser->autoclear( Autoclear ); } + + return *this; +} + +bool cParser::getTokens(unsigned int Count, bool ToLower, const char *Break) { + if( true == m_autoclear ) { + // legacy parser behaviour + tokens.clear(); + } /* if (LoadTraction==true) trtest="niemaproblema"; //wczytywać @@ -78,7 +142,7 @@ bool cParser::getTokens(int Count, bool ToLower, const char *Break) this->str(""); this->clear(); */ - for (int i = 0; i < Count; ++i) + for (unsigned int i = tokens.size(); i < Count; ++i) { std::string token = readToken(ToLower, Break); if( true == token.empty() ) { @@ -105,106 +169,120 @@ bool cParser::getTokens(int Count, bool ToLower, const char *Break) return true; } -std::string cParser::readToken(bool ToLower, const char *Break) -{ - std::string token = ""; - size_t pos; // początek podmienianego ciągu - // see if there's include parsing going on. clean up when it's done. - if (mIncludeParser) - { - token = (*mIncludeParser).readToken(ToLower, Break); - if (!token.empty()) - { - pos = token.find("(p"); - // check if the token is a parameter which should be replaced with stored true value - if (pos != std::string::npos) //!=npos to znalezione - { - std::string parameter = - token.substr(pos + 2, token.find(")", pos) - pos + 2); // numer parametru - token.erase(pos, token.find(")", pos) - pos + 1); // najpierw usunięcie "(pN)" - size_t nr = atoi(parameter.c_str()) - 1; - if (nr < parameters.size()) - { - token.insert(pos, parameters.at(nr)); // wklejenie wartości parametru - if (ToLower) - for (; pos < token.length(); ++pos) - token[pos] = tolower(token[pos]); - } - else - token.insert(pos, "none"); // zabezpieczenie przed brakiem parametru - } - return token; - } - else - { - delete mIncludeParser; - mIncludeParser = NULL; - parameters.clear(); +std::string cParser::readToken( bool ToLower, const char *Break ) { + + std::string token; + if( mIncludeParser ) { + // see if there's include parsing going on. clean up when it's done. + token = mIncludeParser->readToken( ToLower, Break ); + if( true == token.empty() ) { + mIncludeParser = nullptr; } } - // get the token yourself if there's no child to delegate it to. - char c; - do - { - while (mStream->peek() != EOF && strchr(Break, c = mStream->get()) == NULL) - { - if (ToLower) - c = tolower(c); - token += c; - if (findQuotes(token)) // do glue together words enclosed in quotes - break; - if (trimComments(token)) // don't glue together words separated with comment - break; - } - } while (token == "" && mStream->peek() != EOF); // double check to deal with trailing spaces - // launch child parser if include directive found. - // NOTE: parameter collecting uses default set of token separators. - if (token.compare("include") == 0) - { // obsługa include - std::string includefile = readToken(ToLower); // nazwa pliku - if (LoadTraction ? true : ((includefile.find("tr/") == std::string::npos) && - (includefile.find("tra/") == std::string::npos))) - { - // std::string trtest2="niemaproblema"; //nazwa odporna na znalezienie "tr/" - // if (trtest=="x") //jeśli nie wczytywać drutów - // trtest2=includefile; //kopiowanie ścieżki do pliku - std::string parameter = readToken(false); // w parametrach nie zmniejszamy - while( (parameter.empty() == false) - && (parameter.compare("end") != 0) ) - { - parameters.push_back(parameter); - parameter = readToken(ToLower); + if( true == token.empty() ) { + // get the token yourself if the delegation attempt failed + char c { 0 }; + do { + while( mStream->peek() != EOF && strchr( Break, c = mStream->get() ) == NULL ) { + if( ToLower ) + c = tolower( c ); + token += c; + if( findQuotes( token ) ) // do glue together words enclosed in quotes + break; + if( trimComments( token ) ) // don't glue together words separated with comment + break; + } + if( c == '\n' ) { + // update line counter + ++mLine; + } + } while( token == "" && mStream->peek() != EOF ); // double check in case of consecutive separators + } + + if( false == parameters.empty() ) { + // if there's parameter list, check the token for potential parameters to replace + size_t pos; // początek podmienianego ciągu + while( ( pos = token.find( "(p" ) ) != std::string::npos ) { + // check if the token is a parameter which should be replaced with stored true value + auto const parameter{ token.substr( pos + 2, token.find( ")", pos ) - ( pos + 2 ) ) }; // numer parametru + token.erase( pos, token.find( ")", pos ) - pos + 1 ); // najpierw usunięcie "(pN)" + size_t nr = atoi( parameter.c_str() ) - 1; + if( nr < parameters.size() ) { + token.insert( pos, parameters.at( nr ) ); // wklejenie wartości parametru + if( ToLower ) + for( ; pos < parameters.at( nr ).size(); ++pos ) + token[ pos ] = tolower( token[ pos ] ); + } + else + token.insert( pos, "none" ); // zabezpieczenie przed brakiem parametru + } + } + + if( token == "include" ) { + // launch child parser if include directive found. + // NOTE: parameter collecting uses default set of token separators. + std::string includefile = readToken(ToLower); // nazwa pliku + if( ( true == LoadTraction ) + || ( ( includefile.find( "tr/" ) == std::string::npos ) + && ( includefile.find( "tra/" ) == std::string::npos ) ) ) { + // get parameter list for the child parser + std::vector includeparameters; + std::string parameter = readToken( false ); // w parametrach nie zmniejszamy + while( ( parameter.empty() == false ) + && ( parameter != "end" ) ) { + includeparameters.emplace_back( parameter ); + parameter = readToken( false ); + } + mIncludeParser = std::make_shared( includefile, buffer_FILE, mPath, LoadTraction, includeparameters ); + mIncludeParser->autoclear( m_autoclear ); + if( mIncludeParser->mSize <= 0 ) { + ErrorLog( "Bad include: can't open file \"" + includefile + "\"" ); + } + } + else { + while( token != "end" ) { + token = readToken( true ); // minimize risk of case mismatch on comparison } - // if (trtest2.find("tr/")!=0) - mIncludeParser = new cParser(includefile, buffer_FILE, mPath, LoadTraction); - if (mIncludeParser->mSize <= 0) - ErrorLog("Missed include: " + includefile); } - else - while (token.compare("end") != 0) - token = readToken(ToLower); token = readToken(ToLower, Break); } + // all done return token; } std::string cParser::readQuotes(char const Quote) { // read the stream until specified char or stream end std::string token = ""; - char c; + char c { 0 }; while( mStream->peek() != EOF && Quote != (c = mStream->get()) ) { // get all chars until the quote mark + if( c == '\n' ) { + // update line counter + ++mLine; + } token += c; } return token; } -std::string cParser::readComment( std::string const &Break ) { // pobieranie znaków aż do znalezienia znacznika końca - std::string token = ""; - while( mStream->peek() != EOF ) { // o ile nie koniec pliku - token += mStream->get(); // pobranie znaku - if( token.rfind( Break ) != std::string::npos ) // szukanie znacznika końca +void cParser::skipComment( std::string const &Endmark ) { // pobieranie znaków aż do znalezienia znacznika końca + std::string input = ""; + char c { 0 }; + auto const endmarksize = Endmark.size(); + while( mStream->peek() != EOF ) { + // o ile nie koniec pliku + c = mStream->get(); // pobranie znaku + if( c == '\n' ) { + // update line counter + ++mLine; + } + input += c; + if( input.find( Endmark ) != std::string::npos ) // szukanie znacznika końca break; + if( input.size() >= endmarksize ) { + // keep the read text short, to avoid pointless string re-allocations on longer comments + input = input.substr( 1 ); + } } - return token; + return; } bool cParser::findQuotes( std::string &String ) { @@ -224,7 +302,7 @@ bool cParser::trimComments(std::string &String) { if (String.rfind((*cmIt).first) != std::string::npos) { - readComment((*cmIt).second); + skipComment((*cmIt).second); String.resize(String.rfind((*cmIt).first)); return true; } @@ -237,7 +315,48 @@ int cParser::getProgress() const return static_cast( mStream->rdbuf()->pubseekoff(0, std::ios_base::cur) * 100 / mSize ); } +int cParser::getFullProgress() const { + + int progress = getProgress(); + if( mIncludeParser ) return progress + ( ( 100 - progress )*( mIncludeParser->getProgress() ) / 100 ); + else return progress; +} + +std::size_t cParser::countTokens( std::string const &Stream, std::string Path ) { + + return cParser( Stream, buffer_FILE, Path ).count(); +} + +std::size_t cParser::count() { + + std::string token; + size_t count { 0 }; + do { + token = ""; + token = readToken( false ); + ++count; + } while( false == token.empty() ); + + return count - 1; +} + void cParser::addCommentStyle( std::string const &Commentstart, std::string const &Commentend ) { mComments.insert( commentmap::value_type(Commentstart, Commentend) ); } + +// returns name of currently open file, or empty string for text type stream +std::string +cParser::Name() const { + + if( mIncludeParser ) { return mIncludeParser->Name(); } + else { return mPath + mFile; } +} + +// returns number of currently processed line +std::size_t +cParser::Line() const { + + if( mIncludeParser ) { return mIncludeParser->Line(); } + else { return mLine; } +} diff --git a/parser.h b/parser.h index d3d5f746..9dd96657 100644 --- a/parser.h +++ b/parser.h @@ -28,84 +28,89 @@ class cParser //: public std::stringstream buffer_TEXT }; // constructors: - cParser(std::string const &Stream, buffertype const Type = buffer_TEXT, std::string Path = "", bool const Loadtraction = true ); + cParser(std::string const &Stream, buffertype const Type = buffer_TEXT, std::string Path = "", bool const Loadtraction = true, std::vector Parameters = std::vector() ); // destructor: virtual ~cParser(); // methods: - template - cParser& - operator>>( _Type &Right ); - template <> - cParser& - operator>>( std::string &Right ); - template <> - cParser& - operator>>( bool &Right ); - template - _Output - getToken( bool const ToLower = true ) - { - getTokens( 1, ToLower ); - _Output output; - *this >> output; - return output; - }; - template <> - bool - getToken( bool const ToLower ) { - - return ( getToken() == "true" ); - } - inline void ignoreToken() - { - readToken(); - }; - inline void ignoreTokens(int count) - { - for (int i = 0; i < count; i++) - readToken(); - }; - inline bool expectToken(std::string const &value) - { - return readToken() == value; - }; - bool eof() - { - return mStream->eof(); - }; - bool ok() - { - return !mStream->fail(); - }; - bool getTokens(int Count = 1, bool ToLower = true, const char *Break = "\n\r\t ;"); + template + cParser & + operator>>( Type_ &Right ); + template + Output_ + getToken( bool const ToLower = true, const char *Break = "\n\r\t ;" ) { + getTokens( 1, ToLower, Break ); + Output_ output; + *this >> output; + return output; }; + inline + void + ignoreToken() { + readToken(); }; + inline + bool + expectToken( std::string const &Value ) { + return readToken() == Value; }; + bool + eof() { + return mStream->eof(); }; + bool + ok() { + return !mStream->fail(); }; + cParser & + autoclear( bool const Autoclear ); + bool + autoclear() const { + return m_autoclear; } + bool + getTokens( unsigned int Count = 1, bool ToLower = true, char const *Break = "\n\r\t ;" ); + // returns next incoming token, if any, without removing it from the set + std::string + peek() const { + return ( + false == tokens.empty() ? + tokens.front() : + "" ); } // returns percentage of file processed so far int getProgress() const; + int getFullProgress() const; + // + static std::size_t countTokens( std::string const &Stream, std::string Path = "" ); // add custom definition of text which should be ignored when retrieving tokens void addCommentStyle( std::string const &Commentstart, std::string const &Commentend ); + // returns name of currently open file, or empty string for text type stream + std::string Name() const; + // returns number of currently processed line + std::size_t Line() const; private: // methods: std::string readToken(bool ToLower = true, const char *Break = "\n\r\t ;"); std::string readQuotes( char const Quote = '\"' ); - std::string readComment( std::string const &Break = "\n\r\t ;" ); -// std::string trtest; + void skipComment( std::string const &Endmark ); bool findQuotes( std::string &String ); bool trimComments( std::string &String ); + std::size_t count(); // members: - bool LoadTraction; // load traction? - std::istream *mStream; // relevant kind of buffer is attached on creation. + bool m_autoclear { true }; // unretrieved tokens are discarded when another read command is issued (legacy behaviour) + bool LoadTraction { true }; // load traction? + std::shared_ptr mStream; // relevant kind of buffer is attached on creation. + std::string mFile; // name of the open file, if any std::string mPath; // path to open stream, for relative path lookups. - std::streamoff mSize; // size of open stream, for progress report. + std::streamoff mSize { 0 }; // size of open stream, for progress report. + std::size_t mLine { 0 }; // currently processed line + bool mIncFile { false }; // the parser is processing an *.inc file typedef std::map commentmap; - commentmap mComments; - cParser *mIncludeParser; // child class to handle include directives. + commentmap mComments { + commentmap::value_type( "/*", "*/" ), + commentmap::value_type( "//", "\n" ) }; + std::shared_ptr mIncludeParser; // child class to handle include directives. std::vector parameters; // parameter list for included file. std::deque tokens; }; -template +template cParser& -cParser::operator>>( _Type &Right ) { +cParser::operator>>( Type_ &Right ) { if( true == this->tokens.empty() ) { return *this; } @@ -118,26 +123,12 @@ cParser::operator>>( _Type &Right ) { template<> cParser& -cParser::operator>>( std::string &Right ) { - - if( true == this->tokens.empty() ) { return *this; } - - Right = this->tokens.front(); - this->tokens.pop_front(); - - return *this; -} +cParser::operator>>( std::string &Right ); template<> cParser& -cParser::operator>>( bool &Right ) { +cParser::operator>>( bool &Right ); - if( true == this->tokens.empty() ) { return *this; } - - Right = ( ( this->tokens.front() == "true" ) - || ( this->tokens.front() == "yes" ) - || ( this->tokens.front() == "1" ) ); - this->tokens.pop_front(); - - return *this; -} +template<> +bool +cParser::getToken( bool const ToLower, const char *Break ); diff --git a/precipitation.cpp b/precipitation.cpp new file mode 100644 index 00000000..848fec24 --- /dev/null +++ b/precipitation.cpp @@ -0,0 +1,202 @@ +/* +This Source Code Form is subject to the +terms of the Mozilla Public License, v. +2.0. If a copy of the MPL was not +distributed with this file, You can +obtain one at +http://mozilla.org/MPL/2.0/. +*/ + +#include "stdafx.h" +#include "precipitation.h" + +#include "globals.h" +#include "openglmatrixstack.h" +#include "renderer.h" +#include "timer.h" +#include "simulation.h" +#include "train.h" + +basic_precipitation::~basic_precipitation() { + // TODO: release allocated resources +} + +void +basic_precipitation::create( int const Tesselation ) { + + auto const heightfactor { 10.f }; // height-to-radius factor + m_moverate *= heightfactor; + auto const verticaltexturestretchfactor { 1.5f }; // crude motion blur + + // create geometry chunk + auto const latitudes { 3 }; // just a cylinder with end cones + auto const longitudes { Tesselation }; + auto const longitudehalfstep { 0.5f * static_cast( 2.0 * M_PI * 1.f / longitudes ) }; // for crude uv correction + + std::uint16_t index = 0; + +// auto const radius { 25.f }; // cylinder radius + std::vector radii { 25.f, 10.f, 5.f, 1.f }; + for( auto radius : radii ) { + + for( int i = 0; i <= latitudes; ++i ) { + + auto const latitude{ static_cast( M_PI * ( -0.5f + (float)( i ) / latitudes ) ) }; + auto const z{ std::sin( latitude ) }; + auto const zr{ std::cos( latitude ) }; + + for( int j = 0; j <= longitudes; ++j ) { + // NOTE: for the first and last row half of the points we create end up unused but, eh + auto const longitude{ static_cast( 2.0 * M_PI * (float)( j ) / longitudes ) }; + auto const x{ std::cos( longitude ) }; + auto const y{ std::sin( longitude ) }; + // NOTE: cartesian to opengl swap would be: -x, -z, -y + m_vertices.emplace_back( glm::vec3( -x * zr, -z * heightfactor, -y * zr ) * radius ); + // uvs + // NOTE: first and last row receives modified u values to deal with limitation of mapping onto triangles + auto u = ( + i == 0 ? longitude + longitudehalfstep : + i == latitudes ? longitude - longitudehalfstep : + longitude ); + m_uvs.emplace_back( + u / ( 2.0 * M_PI ) * radius, + 1.f - (float)( i ) / latitudes * radius * heightfactor * 0.5f / verticaltexturestretchfactor ); + + if( ( i == 0 ) || ( j == 0 ) ) { + // initial edge of the dome, don't start indices yet + ++index; + } + else { + // the end cones are built from one triangle of each quad, the middle rows use both + if( i < latitudes ) { + m_indices.emplace_back( index - 1 - ( longitudes + 1 ) ); + m_indices.emplace_back( index - 1 ); + m_indices.emplace_back( index ); + } + if( i > 1 ) { + m_indices.emplace_back( index ); + m_indices.emplace_back( index - ( longitudes + 1 ) ); + m_indices.emplace_back( index - 1 - ( longitudes + 1 ) ); + } + ++index; + } + } // longitude + } // latitude + } // radius +} + +bool +basic_precipitation::init() { + + create( 18 ); + + // TODO: select texture based on current overcast level + // TODO: when the overcast level dynamic change is in check the current level during render and pick the appropriate texture on the fly + std::string const densitysuffix { ( + Global.Overcast < 1.35 ? + "_light" : + "_medium" ) }; + if( Global.Weather == "rain:" ) { + m_moverateweathertypefactor = 2.f; + m_texture = GfxRenderer.Fetch_Texture( "fx/rain" + densitysuffix ); + } + else if( Global.Weather == "snow:" ) { + m_moverateweathertypefactor = 1.25f; + m_texture = GfxRenderer.Fetch_Texture( "fx/snow" + densitysuffix ); + } + + return true; +} + +void +basic_precipitation::update() { + + auto const timedelta { static_cast( ( DebugModeFlag ? Timer::GetDeltaTime() : Timer::GetDeltaTime() ) ) }; + + if( timedelta == 0.0 ) { return; } + + m_textureoffset += m_moverate * m_moverateweathertypefactor * timedelta; + m_textureoffset = clamp_circular( m_textureoffset, 10.f ); + + auto cameramove { glm::dvec3{ Global.pCamera.Pos - m_camerapos} }; + cameramove.y = 0.0; // vertical movement messes up vector calculation + + m_camerapos = Global.pCamera.Pos; + + // intercept sudden user-induced camera jumps + if( m_freeflymode != FreeFlyModeFlag ) { + m_freeflymode = FreeFlyModeFlag; + if( true == m_freeflymode ) { + // cache last precipitation vector in the cab + m_cabcameramove = m_cameramove; + // don't carry previous precipitation vector to a new unrelated location + m_cameramove = glm::dvec3{ 0.0 }; + } + else { + // restore last cached precipitation vector + m_cameramove = m_cabcameramove; + } + cameramove = glm::dvec3{ 0.0 }; + } + if( m_windowopen != Global.CabWindowOpen ) { + m_windowopen = Global.CabWindowOpen; + cameramove = glm::dvec3{ 0.0 }; + } + if( ( simulation::Train != nullptr ) && ( simulation::Train->iCabn != m_activecab ) ) { + m_activecab = simulation::Train->iCabn; + cameramove = glm::dvec3{ 0.0 }; + } + if( glm::length( cameramove ) > 100.0 ) { + cameramove = glm::dvec3{ 0.0 }; + } + + m_cameramove = m_cameramove * std::max( 0.0, 1.0 - 5.0 * timedelta ) + cameramove * ( 30.0 * timedelta ); + if( std::abs( m_cameramove.x ) < 0.001 ) { m_cameramove.x = 0.0; } + if( std::abs( m_cameramove.y ) < 0.001 ) { m_cameramove.y = 0.0; } + if( std::abs( m_cameramove.z ) < 0.001 ) { m_cameramove.z = 0.0; } +} + +void +basic_precipitation::render() { + + GfxRenderer.Bind_Texture( m_texture ); + + // cache entry state + ::glPushClientAttrib( GL_CLIENT_VERTEX_ARRAY_BIT ); + + if( m_vertexbuffer == -1 ) { + // build the buffers + ::glGenBuffers( 1, &m_vertexbuffer ); + ::glBindBuffer( GL_ARRAY_BUFFER, m_vertexbuffer ); + ::glBufferData( GL_ARRAY_BUFFER, m_vertices.size() * sizeof( glm::vec3 ), m_vertices.data(), GL_STATIC_DRAW ); + + ::glGenBuffers( 1, &m_uvbuffer ); + ::glBindBuffer( GL_ARRAY_BUFFER, m_uvbuffer ); + ::glBufferData( GL_ARRAY_BUFFER, m_uvs.size() * sizeof( glm::vec2 ), m_uvs.data(), GL_STATIC_DRAW ); + + ::glGenBuffers( 1, &m_indexbuffer ); + ::glBindBuffer( GL_ELEMENT_ARRAY_BUFFER, m_indexbuffer ); + ::glBufferData( GL_ELEMENT_ARRAY_BUFFER, m_indices.size() * sizeof( unsigned short ), m_indices.data(), GL_STATIC_DRAW ); + // NOTE: vertex and index source data is superfluous past this point, but, eh + } + // positions + ::glBindBuffer( GL_ARRAY_BUFFER, m_vertexbuffer ); + ::glVertexPointer( 3, GL_FLOAT, sizeof( glm::vec3 ), reinterpret_cast( 0 ) ); + ::glEnableClientState( GL_VERTEX_ARRAY ); + // uvs + ::glBindBuffer( GL_ARRAY_BUFFER, m_uvbuffer ); + ::glClientActiveTexture( m_textureunit ); + ::glTexCoordPointer( 2, GL_FLOAT, sizeof( glm::vec2 ), reinterpret_cast( 0 ) ); + ::glEnableClientState( GL_TEXTURE_COORD_ARRAY ); + // uv transformation matrix + ::glMatrixMode( GL_TEXTURE ); + ::glLoadIdentity(); + ::glTranslatef( 0.f, m_textureoffset, 0.f ); + // indices + ::glBindBuffer( GL_ELEMENT_ARRAY_BUFFER, m_indexbuffer ); + ::glDrawElements( GL_TRIANGLES, static_cast( m_indices.size() ), GL_UNSIGNED_SHORT, reinterpret_cast( 0 ) ); + // cleanup + ::glLoadIdentity(); + ::glMatrixMode( GL_MODELVIEW ); + ::glPopClientAttrib(); +} diff --git a/precipitation.h b/precipitation.h new file mode 100644 index 00000000..f2f2fcd8 --- /dev/null +++ b/precipitation.h @@ -0,0 +1,59 @@ +/* +This Source Code Form is subject to the +terms of the Mozilla Public License, v. +2.0. If a copy of the MPL was not +distributed with this file, You can +obtain one at +http://mozilla.org/MPL/2.0/. +*/ + +#pragma once + +#include "texture.h" + +// based on "Rendering Falling Rain and Snow" +// by Niniane Wang, Bretton Wade + +class basic_precipitation { + +public: +// constructors + basic_precipitation() = default; +// destructor + ~basic_precipitation(); +// methods + inline + void + set_unit( GLint const Textureunit ) { + m_textureunit = Textureunit; } + bool + init(); + void + update(); + void + render(); + + glm::dvec3 m_cameramove{ 0.0 }; + +private: +// methods + void create( int const Tesselation ); + +// members + std::vector m_vertices; + std::vector m_uvs; + std::vector m_indices; + GLuint m_vertexbuffer { (GLuint)-1 }; + GLuint m_uvbuffer { (GLuint)-1 }; + GLuint m_indexbuffer { (GLuint)-1 }; + GLint m_textureunit { 0 }; + texture_handle m_texture { -1 }; + float m_textureoffset { 0.f }; + float m_moverate { 30 * 0.001f }; + float m_moverateweathertypefactor { 1.f }; // medium-dependent; 1.0 for snow, faster for rain + glm::dvec3 m_camerapos { 0.0 }; + bool m_freeflymode { true }; + bool m_windowopen { true }; + int m_activecab{ 0 }; + glm::dvec3 m_cabcameramove{ 0.0 }; +}; diff --git a/python/include/Python-ast.h b/python/include/Python-ast.h deleted file mode 100644 index 3f35bbb6..00000000 --- a/python/include/Python-ast.h +++ /dev/null @@ -1,535 +0,0 @@ -/* File automatically generated by Parser/asdl_c.py. */ - -#include "asdl.h" - -typedef struct _mod *mod_ty; - -typedef struct _stmt *stmt_ty; - -typedef struct _expr *expr_ty; - -typedef enum _expr_context { Load=1, Store=2, Del=3, AugLoad=4, AugStore=5, - Param=6 } expr_context_ty; - -typedef struct _slice *slice_ty; - -typedef enum _boolop { And=1, Or=2 } boolop_ty; - -typedef enum _operator { Add=1, Sub=2, Mult=3, Div=4, Mod=5, Pow=6, LShift=7, - RShift=8, BitOr=9, BitXor=10, BitAnd=11, FloorDiv=12 } - operator_ty; - -typedef enum _unaryop { Invert=1, Not=2, UAdd=3, USub=4 } unaryop_ty; - -typedef enum _cmpop { Eq=1, NotEq=2, Lt=3, LtE=4, Gt=5, GtE=6, Is=7, IsNot=8, - In=9, NotIn=10 } cmpop_ty; - -typedef struct _comprehension *comprehension_ty; - -typedef struct _excepthandler *excepthandler_ty; - -typedef struct _arguments *arguments_ty; - -typedef struct _keyword *keyword_ty; - -typedef struct _alias *alias_ty; - - -enum _mod_kind {Module_kind=1, Interactive_kind=2, Expression_kind=3, - Suite_kind=4}; -struct _mod { - enum _mod_kind kind; - union { - struct { - asdl_seq *body; - } Module; - - struct { - asdl_seq *body; - } Interactive; - - struct { - expr_ty body; - } Expression; - - struct { - asdl_seq *body; - } Suite; - - } v; -}; - -enum _stmt_kind {FunctionDef_kind=1, ClassDef_kind=2, Return_kind=3, - Delete_kind=4, Assign_kind=5, AugAssign_kind=6, Print_kind=7, - For_kind=8, While_kind=9, If_kind=10, With_kind=11, - Raise_kind=12, TryExcept_kind=13, TryFinally_kind=14, - Assert_kind=15, Import_kind=16, ImportFrom_kind=17, - Exec_kind=18, Global_kind=19, Expr_kind=20, Pass_kind=21, - Break_kind=22, Continue_kind=23}; -struct _stmt { - enum _stmt_kind kind; - union { - struct { - identifier name; - arguments_ty args; - asdl_seq *body; - asdl_seq *decorator_list; - } FunctionDef; - - struct { - identifier name; - asdl_seq *bases; - asdl_seq *body; - asdl_seq *decorator_list; - } ClassDef; - - struct { - expr_ty value; - } Return; - - struct { - asdl_seq *targets; - } Delete; - - struct { - asdl_seq *targets; - expr_ty value; - } Assign; - - struct { - expr_ty target; - operator_ty op; - expr_ty value; - } AugAssign; - - struct { - expr_ty dest; - asdl_seq *values; - bool nl; - } Print; - - struct { - expr_ty target; - expr_ty iter; - asdl_seq *body; - asdl_seq *orelse; - } For; - - struct { - expr_ty test; - asdl_seq *body; - asdl_seq *orelse; - } While; - - struct { - expr_ty test; - asdl_seq *body; - asdl_seq *orelse; - } If; - - struct { - expr_ty context_expr; - expr_ty optional_vars; - asdl_seq *body; - } With; - - struct { - expr_ty type; - expr_ty inst; - expr_ty tback; - } Raise; - - struct { - asdl_seq *body; - asdl_seq *handlers; - asdl_seq *orelse; - } TryExcept; - - struct { - asdl_seq *body; - asdl_seq *finalbody; - } TryFinally; - - struct { - expr_ty test; - expr_ty msg; - } Assert; - - struct { - asdl_seq *names; - } Import; - - struct { - identifier module; - asdl_seq *names; - int level; - } ImportFrom; - - struct { - expr_ty body; - expr_ty globals; - expr_ty locals; - } Exec; - - struct { - asdl_seq *names; - } Global; - - struct { - expr_ty value; - } Expr; - - } v; - int lineno; - int col_offset; -}; - -enum _expr_kind {BoolOp_kind=1, BinOp_kind=2, UnaryOp_kind=3, Lambda_kind=4, - IfExp_kind=5, Dict_kind=6, Set_kind=7, ListComp_kind=8, - SetComp_kind=9, DictComp_kind=10, GeneratorExp_kind=11, - Yield_kind=12, Compare_kind=13, Call_kind=14, Repr_kind=15, - Num_kind=16, Str_kind=17, Attribute_kind=18, - Subscript_kind=19, Name_kind=20, List_kind=21, Tuple_kind=22}; -struct _expr { - enum _expr_kind kind; - union { - struct { - boolop_ty op; - asdl_seq *values; - } BoolOp; - - struct { - expr_ty left; - operator_ty op; - expr_ty right; - } BinOp; - - struct { - unaryop_ty op; - expr_ty operand; - } UnaryOp; - - struct { - arguments_ty args; - expr_ty body; - } Lambda; - - struct { - expr_ty test; - expr_ty body; - expr_ty orelse; - } IfExp; - - struct { - asdl_seq *keys; - asdl_seq *values; - } Dict; - - struct { - asdl_seq *elts; - } Set; - - struct { - expr_ty elt; - asdl_seq *generators; - } ListComp; - - struct { - expr_ty elt; - asdl_seq *generators; - } SetComp; - - struct { - expr_ty key; - expr_ty value; - asdl_seq *generators; - } DictComp; - - struct { - expr_ty elt; - asdl_seq *generators; - } GeneratorExp; - - struct { - expr_ty value; - } Yield; - - struct { - expr_ty left; - asdl_int_seq *ops; - asdl_seq *comparators; - } Compare; - - struct { - expr_ty func; - asdl_seq *args; - asdl_seq *keywords; - expr_ty starargs; - expr_ty kwargs; - } Call; - - struct { - expr_ty value; - } Repr; - - struct { - object n; - } Num; - - struct { - string s; - } Str; - - struct { - expr_ty value; - identifier attr; - expr_context_ty ctx; - } Attribute; - - struct { - expr_ty value; - slice_ty slice; - expr_context_ty ctx; - } Subscript; - - struct { - identifier id; - expr_context_ty ctx; - } Name; - - struct { - asdl_seq *elts; - expr_context_ty ctx; - } List; - - struct { - asdl_seq *elts; - expr_context_ty ctx; - } Tuple; - - } v; - int lineno; - int col_offset; -}; - -enum _slice_kind {Ellipsis_kind=1, Slice_kind=2, ExtSlice_kind=3, Index_kind=4}; -struct _slice { - enum _slice_kind kind; - union { - struct { - expr_ty lower; - expr_ty upper; - expr_ty step; - } Slice; - - struct { - asdl_seq *dims; - } ExtSlice; - - struct { - expr_ty value; - } Index; - - } v; -}; - -struct _comprehension { - expr_ty target; - expr_ty iter; - asdl_seq *ifs; -}; - -enum _excepthandler_kind {ExceptHandler_kind=1}; -struct _excepthandler { - enum _excepthandler_kind kind; - union { - struct { - expr_ty type; - expr_ty name; - asdl_seq *body; - } ExceptHandler; - - } v; - int lineno; - int col_offset; -}; - -struct _arguments { - asdl_seq *args; - identifier vararg; - identifier kwarg; - asdl_seq *defaults; -}; - -struct _keyword { - identifier arg; - expr_ty value; -}; - -struct _alias { - identifier name; - identifier asname; -}; - - -#define Module(a0, a1) _Py_Module(a0, a1) -mod_ty _Py_Module(asdl_seq * body, PyArena *arena); -#define Interactive(a0, a1) _Py_Interactive(a0, a1) -mod_ty _Py_Interactive(asdl_seq * body, PyArena *arena); -#define Expression(a0, a1) _Py_Expression(a0, a1) -mod_ty _Py_Expression(expr_ty body, PyArena *arena); -#define Suite(a0, a1) _Py_Suite(a0, a1) -mod_ty _Py_Suite(asdl_seq * body, PyArena *arena); -#define FunctionDef(a0, a1, a2, a3, a4, a5, a6) _Py_FunctionDef(a0, a1, a2, a3, a4, a5, a6) -stmt_ty _Py_FunctionDef(identifier name, arguments_ty args, asdl_seq * body, - asdl_seq * decorator_list, int lineno, int col_offset, - PyArena *arena); -#define ClassDef(a0, a1, a2, a3, a4, a5, a6) _Py_ClassDef(a0, a1, a2, a3, a4, a5, a6) -stmt_ty _Py_ClassDef(identifier name, asdl_seq * bases, asdl_seq * body, - asdl_seq * decorator_list, int lineno, int col_offset, - PyArena *arena); -#define Return(a0, a1, a2, a3) _Py_Return(a0, a1, a2, a3) -stmt_ty _Py_Return(expr_ty value, int lineno, int col_offset, PyArena *arena); -#define Delete(a0, a1, a2, a3) _Py_Delete(a0, a1, a2, a3) -stmt_ty _Py_Delete(asdl_seq * targets, int lineno, int col_offset, PyArena - *arena); -#define Assign(a0, a1, a2, a3, a4) _Py_Assign(a0, a1, a2, a3, a4) -stmt_ty _Py_Assign(asdl_seq * targets, expr_ty value, int lineno, int - col_offset, PyArena *arena); -#define AugAssign(a0, a1, a2, a3, a4, a5) _Py_AugAssign(a0, a1, a2, a3, a4, a5) -stmt_ty _Py_AugAssign(expr_ty target, operator_ty op, expr_ty value, int - lineno, int col_offset, PyArena *arena); -#define Print(a0, a1, a2, a3, a4, a5) _Py_Print(a0, a1, a2, a3, a4, a5) -stmt_ty _Py_Print(expr_ty dest, asdl_seq * values, bool nl, int lineno, int - col_offset, PyArena *arena); -#define For(a0, a1, a2, a3, a4, a5, a6) _Py_For(a0, a1, a2, a3, a4, a5, a6) -stmt_ty _Py_For(expr_ty target, expr_ty iter, asdl_seq * body, asdl_seq * - orelse, int lineno, int col_offset, PyArena *arena); -#define While(a0, a1, a2, a3, a4, a5) _Py_While(a0, a1, a2, a3, a4, a5) -stmt_ty _Py_While(expr_ty test, asdl_seq * body, asdl_seq * orelse, int lineno, - int col_offset, PyArena *arena); -#define If(a0, a1, a2, a3, a4, a5) _Py_If(a0, a1, a2, a3, a4, a5) -stmt_ty _Py_If(expr_ty test, asdl_seq * body, asdl_seq * orelse, int lineno, - int col_offset, PyArena *arena); -#define With(a0, a1, a2, a3, a4, a5) _Py_With(a0, a1, a2, a3, a4, a5) -stmt_ty _Py_With(expr_ty context_expr, expr_ty optional_vars, asdl_seq * body, - int lineno, int col_offset, PyArena *arena); -#define Raise(a0, a1, a2, a3, a4, a5) _Py_Raise(a0, a1, a2, a3, a4, a5) -stmt_ty _Py_Raise(expr_ty type, expr_ty inst, expr_ty tback, int lineno, int - col_offset, PyArena *arena); -#define TryExcept(a0, a1, a2, a3, a4, a5) _Py_TryExcept(a0, a1, a2, a3, a4, a5) -stmt_ty _Py_TryExcept(asdl_seq * body, asdl_seq * handlers, asdl_seq * orelse, - int lineno, int col_offset, PyArena *arena); -#define TryFinally(a0, a1, a2, a3, a4) _Py_TryFinally(a0, a1, a2, a3, a4) -stmt_ty _Py_TryFinally(asdl_seq * body, asdl_seq * finalbody, int lineno, int - col_offset, PyArena *arena); -#define Assert(a0, a1, a2, a3, a4) _Py_Assert(a0, a1, a2, a3, a4) -stmt_ty _Py_Assert(expr_ty test, expr_ty msg, int lineno, int col_offset, - PyArena *arena); -#define Import(a0, a1, a2, a3) _Py_Import(a0, a1, a2, a3) -stmt_ty _Py_Import(asdl_seq * names, int lineno, int col_offset, PyArena - *arena); -#define ImportFrom(a0, a1, a2, a3, a4, a5) _Py_ImportFrom(a0, a1, a2, a3, a4, a5) -stmt_ty _Py_ImportFrom(identifier module, asdl_seq * names, int level, int - lineno, int col_offset, PyArena *arena); -#define Exec(a0, a1, a2, a3, a4, a5) _Py_Exec(a0, a1, a2, a3, a4, a5) -stmt_ty _Py_Exec(expr_ty body, expr_ty globals, expr_ty locals, int lineno, int - col_offset, PyArena *arena); -#define Global(a0, a1, a2, a3) _Py_Global(a0, a1, a2, a3) -stmt_ty _Py_Global(asdl_seq * names, int lineno, int col_offset, PyArena - *arena); -#define Expr(a0, a1, a2, a3) _Py_Expr(a0, a1, a2, a3) -stmt_ty _Py_Expr(expr_ty value, int lineno, int col_offset, PyArena *arena); -#define Pass(a0, a1, a2) _Py_Pass(a0, a1, a2) -stmt_ty _Py_Pass(int lineno, int col_offset, PyArena *arena); -#define Break(a0, a1, a2) _Py_Break(a0, a1, a2) -stmt_ty _Py_Break(int lineno, int col_offset, PyArena *arena); -#define Continue(a0, a1, a2) _Py_Continue(a0, a1, a2) -stmt_ty _Py_Continue(int lineno, int col_offset, PyArena *arena); -#define BoolOp(a0, a1, a2, a3, a4) _Py_BoolOp(a0, a1, a2, a3, a4) -expr_ty _Py_BoolOp(boolop_ty op, asdl_seq * values, int lineno, int col_offset, - PyArena *arena); -#define BinOp(a0, a1, a2, a3, a4, a5) _Py_BinOp(a0, a1, a2, a3, a4, a5) -expr_ty _Py_BinOp(expr_ty left, operator_ty op, expr_ty right, int lineno, int - col_offset, PyArena *arena); -#define UnaryOp(a0, a1, a2, a3, a4) _Py_UnaryOp(a0, a1, a2, a3, a4) -expr_ty _Py_UnaryOp(unaryop_ty op, expr_ty operand, int lineno, int col_offset, - PyArena *arena); -#define Lambda(a0, a1, a2, a3, a4) _Py_Lambda(a0, a1, a2, a3, a4) -expr_ty _Py_Lambda(arguments_ty args, expr_ty body, int lineno, int col_offset, - PyArena *arena); -#define IfExp(a0, a1, a2, a3, a4, a5) _Py_IfExp(a0, a1, a2, a3, a4, a5) -expr_ty _Py_IfExp(expr_ty test, expr_ty body, expr_ty orelse, int lineno, int - col_offset, PyArena *arena); -#define Dict(a0, a1, a2, a3, a4) _Py_Dict(a0, a1, a2, a3, a4) -expr_ty _Py_Dict(asdl_seq * keys, asdl_seq * values, int lineno, int - col_offset, PyArena *arena); -#define Set(a0, a1, a2, a3) _Py_Set(a0, a1, a2, a3) -expr_ty _Py_Set(asdl_seq * elts, int lineno, int col_offset, PyArena *arena); -#define ListComp(a0, a1, a2, a3, a4) _Py_ListComp(a0, a1, a2, a3, a4) -expr_ty _Py_ListComp(expr_ty elt, asdl_seq * generators, int lineno, int - col_offset, PyArena *arena); -#define SetComp(a0, a1, a2, a3, a4) _Py_SetComp(a0, a1, a2, a3, a4) -expr_ty _Py_SetComp(expr_ty elt, asdl_seq * generators, int lineno, int - col_offset, PyArena *arena); -#define DictComp(a0, a1, a2, a3, a4, a5) _Py_DictComp(a0, a1, a2, a3, a4, a5) -expr_ty _Py_DictComp(expr_ty key, expr_ty value, asdl_seq * generators, int - lineno, int col_offset, PyArena *arena); -#define GeneratorExp(a0, a1, a2, a3, a4) _Py_GeneratorExp(a0, a1, a2, a3, a4) -expr_ty _Py_GeneratorExp(expr_ty elt, asdl_seq * generators, int lineno, int - col_offset, PyArena *arena); -#define Yield(a0, a1, a2, a3) _Py_Yield(a0, a1, a2, a3) -expr_ty _Py_Yield(expr_ty value, int lineno, int col_offset, PyArena *arena); -#define Compare(a0, a1, a2, a3, a4, a5) _Py_Compare(a0, a1, a2, a3, a4, a5) -expr_ty _Py_Compare(expr_ty left, asdl_int_seq * ops, asdl_seq * comparators, - int lineno, int col_offset, PyArena *arena); -#define Call(a0, a1, a2, a3, a4, a5, a6, a7) _Py_Call(a0, a1, a2, a3, a4, a5, a6, a7) -expr_ty _Py_Call(expr_ty func, asdl_seq * args, asdl_seq * keywords, expr_ty - starargs, expr_ty kwargs, int lineno, int col_offset, PyArena - *arena); -#define Repr(a0, a1, a2, a3) _Py_Repr(a0, a1, a2, a3) -expr_ty _Py_Repr(expr_ty value, int lineno, int col_offset, PyArena *arena); -#define Num(a0, a1, a2, a3) _Py_Num(a0, a1, a2, a3) -expr_ty _Py_Num(object n, int lineno, int col_offset, PyArena *arena); -#define Str(a0, a1, a2, a3) _Py_Str(a0, a1, a2, a3) -expr_ty _Py_Str(string s, int lineno, int col_offset, PyArena *arena); -#define Attribute(a0, a1, a2, a3, a4, a5) _Py_Attribute(a0, a1, a2, a3, a4, a5) -expr_ty _Py_Attribute(expr_ty value, identifier attr, expr_context_ty ctx, int - lineno, int col_offset, PyArena *arena); -#define Subscript(a0, a1, a2, a3, a4, a5) _Py_Subscript(a0, a1, a2, a3, a4, a5) -expr_ty _Py_Subscript(expr_ty value, slice_ty slice, expr_context_ty ctx, int - lineno, int col_offset, PyArena *arena); -#define Name(a0, a1, a2, a3, a4) _Py_Name(a0, a1, a2, a3, a4) -expr_ty _Py_Name(identifier id, expr_context_ty ctx, int lineno, int - col_offset, PyArena *arena); -#define List(a0, a1, a2, a3, a4) _Py_List(a0, a1, a2, a3, a4) -expr_ty _Py_List(asdl_seq * elts, expr_context_ty ctx, int lineno, int - col_offset, PyArena *arena); -#define Tuple(a0, a1, a2, a3, a4) _Py_Tuple(a0, a1, a2, a3, a4) -expr_ty _Py_Tuple(asdl_seq * elts, expr_context_ty ctx, int lineno, int - col_offset, PyArena *arena); -#define Ellipsis(a0) _Py_Ellipsis(a0) -slice_ty _Py_Ellipsis(PyArena *arena); -#define Slice(a0, a1, a2, a3) _Py_Slice(a0, a1, a2, a3) -slice_ty _Py_Slice(expr_ty lower, expr_ty upper, expr_ty step, PyArena *arena); -#define ExtSlice(a0, a1) _Py_ExtSlice(a0, a1) -slice_ty _Py_ExtSlice(asdl_seq * dims, PyArena *arena); -#define Index(a0, a1) _Py_Index(a0, a1) -slice_ty _Py_Index(expr_ty value, PyArena *arena); -#define comprehension(a0, a1, a2, a3) _Py_comprehension(a0, a1, a2, a3) -comprehension_ty _Py_comprehension(expr_ty target, expr_ty iter, asdl_seq * - ifs, PyArena *arena); -#define ExceptHandler(a0, a1, a2, a3, a4, a5) _Py_ExceptHandler(a0, a1, a2, a3, a4, a5) -excepthandler_ty _Py_ExceptHandler(expr_ty type, expr_ty name, asdl_seq * body, - int lineno, int col_offset, PyArena *arena); -#define arguments(a0, a1, a2, a3, a4) _Py_arguments(a0, a1, a2, a3, a4) -arguments_ty _Py_arguments(asdl_seq * args, identifier vararg, identifier - kwarg, asdl_seq * defaults, PyArena *arena); -#define keyword(a0, a1, a2) _Py_keyword(a0, a1, a2) -keyword_ty _Py_keyword(identifier arg, expr_ty value, PyArena *arena); -#define alias(a0, a1, a2) _Py_alias(a0, a1, a2) -alias_ty _Py_alias(identifier name, identifier asname, PyArena *arena); - -PyObject* PyAST_mod2obj(mod_ty t); -mod_ty PyAST_obj2mod(PyObject* ast, PyArena* arena, int mode); -int PyAST_Check(PyObject* obj); diff --git a/python/include/Python.h b/python/include/Python.h deleted file mode 100644 index 775412b8..00000000 --- a/python/include/Python.h +++ /dev/null @@ -1,178 +0,0 @@ -#ifndef Py_PYTHON_H -#define Py_PYTHON_H -/* Since this is a "meta-include" file, no #ifdef __cplusplus / extern "C" { */ - -/* Include nearly all Python header files */ - -#include "patchlevel.h" -#include "pyconfig.h" -#include "pymacconfig.h" - -/* Cyclic gc is always enabled, starting with release 2.3a1. Supply the - * old symbol for the benefit of extension modules written before then - * that may be conditionalizing on it. The core doesn't use it anymore. - */ -#ifndef WITH_CYCLE_GC -#define WITH_CYCLE_GC 1 -#endif - -#include - -#ifndef UCHAR_MAX -#error "Something's broken. UCHAR_MAX should be defined in limits.h." -#endif - -#if UCHAR_MAX != 255 -#error "Python's source code assumes C's unsigned char is an 8-bit type." -#endif - -#if defined(__sgi) && defined(WITH_THREAD) && !defined(_SGI_MP_SOURCE) -#define _SGI_MP_SOURCE -#endif - -#include -#ifndef NULL -# error "Python.h requires that stdio.h define NULL." -#endif - -#include -#ifdef HAVE_ERRNO_H -#include -#endif -#include -#ifdef HAVE_UNISTD_H -#include -#endif - -/* For size_t? */ -#ifdef HAVE_STDDEF_H -#include -#endif - -/* CAUTION: Build setups should ensure that NDEBUG is defined on the - * compiler command line when building Python in release mode; else - * assert() calls won't be removed. - */ -#include - -#include "pyport.h" - -/* pyconfig.h or pyport.h may or may not define DL_IMPORT */ -#ifndef DL_IMPORT /* declarations for DLL import/export */ -#define DL_IMPORT(RTYPE) RTYPE -#endif -#ifndef DL_EXPORT /* declarations for DLL import/export */ -#define DL_EXPORT(RTYPE) RTYPE -#endif - -/* Debug-mode build with pymalloc implies PYMALLOC_DEBUG. - * PYMALLOC_DEBUG is in error if pymalloc is not in use. - */ -#if defined(Py_DEBUG) && defined(WITH_PYMALLOC) && !defined(PYMALLOC_DEBUG) -#define PYMALLOC_DEBUG -#endif -#if defined(PYMALLOC_DEBUG) && !defined(WITH_PYMALLOC) -#error "PYMALLOC_DEBUG requires WITH_PYMALLOC" -#endif -#include "pymath.h" -#include "pymem.h" - -#include "object.h" -#include "objimpl.h" - -#include "pydebug.h" - -#include "unicodeobject.h" -#include "intobject.h" -#include "boolobject.h" -#include "longobject.h" -#include "floatobject.h" -#ifndef WITHOUT_COMPLEX -#include "complexobject.h" -#endif -#include "rangeobject.h" -#include "stringobject.h" -#include "memoryobject.h" -#include "bufferobject.h" -#include "bytesobject.h" -#include "bytearrayobject.h" -#include "tupleobject.h" -#include "listobject.h" -#include "dictobject.h" -#include "enumobject.h" -#include "setobject.h" -#include "methodobject.h" -#include "moduleobject.h" -#include "funcobject.h" -#include "classobject.h" -#include "fileobject.h" -#include "cobject.h" -#include "pycapsule.h" -#include "traceback.h" -#include "sliceobject.h" -#include "cellobject.h" -#include "iterobject.h" -#include "genobject.h" -#include "descrobject.h" -#include "warnings.h" -#include "weakrefobject.h" - -#include "codecs.h" -#include "pyerrors.h" - -#include "pystate.h" - -#include "pyarena.h" -#include "modsupport.h" -#include "pythonrun.h" -#include "ceval.h" -#include "sysmodule.h" -#include "intrcheck.h" -#include "import.h" - -#include "abstract.h" - -#include "compile.h" -#include "eval.h" - -#include "pyctype.h" -#include "pystrtod.h" -#include "pystrcmp.h" -#include "dtoa.h" - -/* _Py_Mangle is defined in compile.c */ -PyAPI_FUNC(PyObject*) _Py_Mangle(PyObject *p, PyObject *name); - -/* PyArg_GetInt is deprecated and should not be used, use PyArg_Parse(). */ -#define PyArg_GetInt(v, a) PyArg_Parse((v), "i", (a)) - -/* PyArg_NoArgs should not be necessary. - Set ml_flags in the PyMethodDef to METH_NOARGS. */ -#define PyArg_NoArgs(v) PyArg_Parse(v, "") - -/* Argument must be a char or an int in [-128, 127] or [0, 255]. */ -#define Py_CHARMASK(c) ((unsigned char)((c) & 0xff)) - -#include "pyfpe.h" - -/* These definitions must match corresponding definitions in graminit.h. - There's code in compile.c that checks that they are the same. */ -#define Py_single_input 256 -#define Py_file_input 257 -#define Py_eval_input 258 - -#ifdef HAVE_PTH -/* GNU pth user-space thread support */ -#include -#endif - -/* Define macros for inline documentation. */ -#define PyDoc_VAR(name) static char name[] -#define PyDoc_STRVAR(name,str) PyDoc_VAR(name) = PyDoc_STR(str) -#ifdef WITH_DOC_STRINGS -#define PyDoc_STR(str) str -#else -#define PyDoc_STR(str) "" -#endif - -#endif /* !Py_PYTHON_H */ diff --git a/python/include/abstract.h b/python/include/abstract.h deleted file mode 100644 index a3774238..00000000 --- a/python/include/abstract.h +++ /dev/null @@ -1,1396 +0,0 @@ -#ifndef Py_ABSTRACTOBJECT_H -#define Py_ABSTRACTOBJECT_H -#ifdef __cplusplus -extern "C" { -#endif - -#ifdef PY_SSIZE_T_CLEAN -#define PyObject_CallFunction _PyObject_CallFunction_SizeT -#define PyObject_CallMethod _PyObject_CallMethod_SizeT -#endif - -/* Abstract Object Interface (many thanks to Jim Fulton) */ - -/* - PROPOSAL: A Generic Python Object Interface for Python C Modules - -Problem - - Python modules written in C that must access Python objects must do - so through routines whose interfaces are described by a set of - include files. Unfortunately, these routines vary according to the - object accessed. To use these routines, the C programmer must check - the type of the object being used and must call a routine based on - the object type. For example, to access an element of a sequence, - the programmer must determine whether the sequence is a list or a - tuple: - - if(is_tupleobject(o)) - e=gettupleitem(o,i) - else if(is_listitem(o)) - e=getlistitem(o,i) - - If the programmer wants to get an item from another type of object - that provides sequence behavior, there is no clear way to do it - correctly. - - The persistent programmer may peruse object.h and find that the - _typeobject structure provides a means of invoking up to (currently - about) 41 special operators. So, for example, a routine can get an - item from any object that provides sequence behavior. However, to - use this mechanism, the programmer must make their code dependent on - the current Python implementation. - - Also, certain semantics, especially memory management semantics, may - differ by the type of object being used. Unfortunately, these - semantics are not clearly described in the current include files. - An abstract interface providing more consistent semantics is needed. - -Proposal - - I propose the creation of a standard interface (with an associated - library of routines and/or macros) for generically obtaining the - services of Python objects. This proposal can be viewed as one - components of a Python C interface consisting of several components. - - From the viewpoint of C access to Python services, we have (as - suggested by Guido in off-line discussions): - - - "Very high level layer": two or three functions that let you exec or - eval arbitrary Python code given as a string in a module whose name is - given, passing C values in and getting C values out using - mkvalue/getargs style format strings. This does not require the user - to declare any variables of type "PyObject *". This should be enough - to write a simple application that gets Python code from the user, - execs it, and returns the output or errors. (Error handling must also - be part of this API.) - - - "Abstract objects layer": which is the subject of this proposal. - It has many functions operating on objects, and lest you do many - things from C that you can also write in Python, without going - through the Python parser. - - - "Concrete objects layer": This is the public type-dependent - interface provided by the standard built-in types, such as floats, - strings, and lists. This interface exists and is currently - documented by the collection of include files provided with the - Python distributions. - - From the point of view of Python accessing services provided by C - modules: - - - "Python module interface": this interface consist of the basic - routines used to define modules and their members. Most of the - current extensions-writing guide deals with this interface. - - - "Built-in object interface": this is the interface that a new - built-in type must provide and the mechanisms and rules that a - developer of a new built-in type must use and follow. - - This proposal is a "first-cut" that is intended to spur - discussion. See especially the lists of notes. - - The Python C object interface will provide four protocols: object, - numeric, sequence, and mapping. Each protocol consists of a - collection of related operations. If an operation that is not - provided by a particular type is invoked, then a standard exception, - NotImplementedError is raised with a operation name as an argument. - In addition, for convenience this interface defines a set of - constructors for building objects of built-in types. This is needed - so new objects can be returned from C functions that otherwise treat - objects generically. - -Memory Management - - For all of the functions described in this proposal, if a function - retains a reference to a Python object passed as an argument, then the - function will increase the reference count of the object. It is - unnecessary for the caller to increase the reference count of an - argument in anticipation of the object's retention. - - All Python objects returned from functions should be treated as new - objects. Functions that return objects assume that the caller will - retain a reference and the reference count of the object has already - been incremented to account for this fact. A caller that does not - retain a reference to an object that is returned from a function - must decrement the reference count of the object (using - DECREF(object)) to prevent memory leaks. - - Note that the behavior mentioned here is different from the current - behavior for some objects (e.g. lists and tuples) when certain - type-specific routines are called directly (e.g. setlistitem). The - proposed abstraction layer will provide a consistent memory - management interface, correcting for inconsistent behavior for some - built-in types. - -Protocols - -xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx*/ - -/* Object Protocol: */ - - /* Implemented elsewhere: - - int PyObject_Print(PyObject *o, FILE *fp, int flags); - - Print an object, o, on file, fp. Returns -1 on - error. The flags argument is used to enable certain printing - options. The only option currently supported is Py_Print_RAW. - - (What should be said about Py_Print_RAW?) - - */ - - /* Implemented elsewhere: - - int PyObject_HasAttrString(PyObject *o, char *attr_name); - - Returns 1 if o has the attribute attr_name, and 0 otherwise. - This is equivalent to the Python expression: - hasattr(o,attr_name). - - This function always succeeds. - - */ - - /* Implemented elsewhere: - - PyObject* PyObject_GetAttrString(PyObject *o, char *attr_name); - - Retrieve an attributed named attr_name form object o. - Returns the attribute value on success, or NULL on failure. - This is the equivalent of the Python expression: o.attr_name. - - */ - - /* Implemented elsewhere: - - int PyObject_HasAttr(PyObject *o, PyObject *attr_name); - - Returns 1 if o has the attribute attr_name, and 0 otherwise. - This is equivalent to the Python expression: - hasattr(o,attr_name). - - This function always succeeds. - - */ - - /* Implemented elsewhere: - - PyObject* PyObject_GetAttr(PyObject *o, PyObject *attr_name); - - Retrieve an attributed named attr_name form object o. - Returns the attribute value on success, or NULL on failure. - This is the equivalent of the Python expression: o.attr_name. - - */ - - - /* Implemented elsewhere: - - int PyObject_SetAttrString(PyObject *o, char *attr_name, PyObject *v); - - Set the value of the attribute named attr_name, for object o, - to the value, v. Returns -1 on failure. This is - the equivalent of the Python statement: o.attr_name=v. - - */ - - /* Implemented elsewhere: - - int PyObject_SetAttr(PyObject *o, PyObject *attr_name, PyObject *v); - - Set the value of the attribute named attr_name, for object o, - to the value, v. Returns -1 on failure. This is - the equivalent of the Python statement: o.attr_name=v. - - */ - - /* implemented as a macro: - - int PyObject_DelAttrString(PyObject *o, char *attr_name); - - Delete attribute named attr_name, for object o. Returns - -1 on failure. This is the equivalent of the Python - statement: del o.attr_name. - - */ -#define PyObject_DelAttrString(O,A) PyObject_SetAttrString((O),(A),NULL) - - /* implemented as a macro: - - int PyObject_DelAttr(PyObject *o, PyObject *attr_name); - - Delete attribute named attr_name, for object o. Returns -1 - on failure. This is the equivalent of the Python - statement: del o.attr_name. - - */ -#define PyObject_DelAttr(O,A) PyObject_SetAttr((O),(A),NULL) - - PyAPI_FUNC(int) PyObject_Cmp(PyObject *o1, PyObject *o2, int *result); - - /* - Compare the values of o1 and o2 using a routine provided by - o1, if one exists, otherwise with a routine provided by o2. - The result of the comparison is returned in result. Returns - -1 on failure. This is the equivalent of the Python - statement: result=cmp(o1,o2). - - */ - - /* Implemented elsewhere: - - int PyObject_Compare(PyObject *o1, PyObject *o2); - - Compare the values of o1 and o2 using a routine provided by - o1, if one exists, otherwise with a routine provided by o2. - Returns the result of the comparison on success. On error, - the value returned is undefined. This is equivalent to the - Python expression: cmp(o1,o2). - - */ - - /* Implemented elsewhere: - - PyObject *PyObject_Repr(PyObject *o); - - Compute the string representation of object, o. Returns the - string representation on success, NULL on failure. This is - the equivalent of the Python expression: repr(o). - - Called by the repr() built-in function and by reverse quotes. - - */ - - /* Implemented elsewhere: - - PyObject *PyObject_Str(PyObject *o); - - Compute the string representation of object, o. Returns the - string representation on success, NULL on failure. This is - the equivalent of the Python expression: str(o).) - - Called by the str() built-in function and by the print - statement. - - */ - - /* Implemented elsewhere: - - PyObject *PyObject_Unicode(PyObject *o); - - Compute the unicode representation of object, o. Returns the - unicode representation on success, NULL on failure. This is - the equivalent of the Python expression: unistr(o).) - - Called by the unistr() built-in function. - - */ - - /* Declared elsewhere - - PyAPI_FUNC(int) PyCallable_Check(PyObject *o); - - Determine if the object, o, is callable. Return 1 if the - object is callable and 0 otherwise. - - This function always succeeds. - - */ - - - - PyAPI_FUNC(PyObject *) PyObject_Call(PyObject *callable_object, - PyObject *args, PyObject *kw); - - /* - Call a callable Python object, callable_object, with - arguments and keywords arguments. The 'args' argument can not be - NULL, but the 'kw' argument can be NULL. - - */ - - PyAPI_FUNC(PyObject *) PyObject_CallObject(PyObject *callable_object, - PyObject *args); - - /* - Call a callable Python object, callable_object, with - arguments given by the tuple, args. If no arguments are - needed, then args may be NULL. Returns the result of the - call on success, or NULL on failure. This is the equivalent - of the Python expression: apply(o,args). - - */ - - PyAPI_FUNC(PyObject *) PyObject_CallFunction(PyObject *callable_object, - char *format, ...); - - /* - Call a callable Python object, callable_object, with a - variable number of C arguments. The C arguments are described - using a mkvalue-style format string. The format may be NULL, - indicating that no arguments are provided. Returns the - result of the call on success, or NULL on failure. This is - the equivalent of the Python expression: apply(o,args). - - */ - - - PyAPI_FUNC(PyObject *) PyObject_CallMethod(PyObject *o, char *m, - char *format, ...); - - /* - Call the method named m of object o with a variable number of - C arguments. The C arguments are described by a mkvalue - format string. The format may be NULL, indicating that no - arguments are provided. Returns the result of the call on - success, or NULL on failure. This is the equivalent of the - Python expression: o.method(args). - */ - - PyAPI_FUNC(PyObject *) _PyObject_CallFunction_SizeT(PyObject *callable, - char *format, ...); - PyAPI_FUNC(PyObject *) _PyObject_CallMethod_SizeT(PyObject *o, - char *name, - char *format, ...); - - PyAPI_FUNC(PyObject *) PyObject_CallFunctionObjArgs(PyObject *callable, - ...); - - /* - Call a callable Python object, callable_object, with a - variable number of C arguments. The C arguments are provided - as PyObject * values, terminated by a NULL. Returns the - result of the call on success, or NULL on failure. This is - the equivalent of the Python expression: apply(o,args). - */ - - - PyAPI_FUNC(PyObject *) PyObject_CallMethodObjArgs(PyObject *o, - PyObject *m, ...); - - /* - Call the method named m of object o with a variable number of - C arguments. The C arguments are provided as PyObject * - values, terminated by NULL. Returns the result of the call - on success, or NULL on failure. This is the equivalent of - the Python expression: o.method(args). - */ - - - /* Implemented elsewhere: - - long PyObject_Hash(PyObject *o); - - Compute and return the hash, hash_value, of an object, o. On - failure, return -1. This is the equivalent of the Python - expression: hash(o). - - */ - - - /* Implemented elsewhere: - - int PyObject_IsTrue(PyObject *o); - - Returns 1 if the object, o, is considered to be true, 0 if o is - considered to be false and -1 on failure. This is equivalent to the - Python expression: not not o - - */ - - /* Implemented elsewhere: - - int PyObject_Not(PyObject *o); - - Returns 0 if the object, o, is considered to be true, 1 if o is - considered to be false and -1 on failure. This is equivalent to the - Python expression: not o - - */ - - PyAPI_FUNC(PyObject *) PyObject_Type(PyObject *o); - - /* - On success, returns a type object corresponding to the object - type of object o. On failure, returns NULL. This is - equivalent to the Python expression: type(o). - */ - - PyAPI_FUNC(Py_ssize_t) PyObject_Size(PyObject *o); - - /* - Return the size of object o. If the object, o, provides - both sequence and mapping protocols, the sequence size is - returned. On error, -1 is returned. This is the equivalent - to the Python expression: len(o). - - */ - - /* For DLL compatibility */ -#undef PyObject_Length - PyAPI_FUNC(Py_ssize_t) PyObject_Length(PyObject *o); -#define PyObject_Length PyObject_Size - - PyAPI_FUNC(Py_ssize_t) _PyObject_LengthHint(PyObject *o, Py_ssize_t); - - /* - Guess the size of object o using len(o) or o.__length_hint__(). - If neither of those return a non-negative value, then return the - default value. If one of the calls fails, this function returns -1. - */ - - PyAPI_FUNC(PyObject *) PyObject_GetItem(PyObject *o, PyObject *key); - - /* - Return element of o corresponding to the object, key, or NULL - on failure. This is the equivalent of the Python expression: - o[key]. - - */ - - PyAPI_FUNC(int) PyObject_SetItem(PyObject *o, PyObject *key, PyObject *v); - - /* - Map the object, key, to the value, v. Returns - -1 on failure. This is the equivalent of the Python - statement: o[key]=v. - */ - - PyAPI_FUNC(int) PyObject_DelItemString(PyObject *o, char *key); - - /* - Remove the mapping for object, key, from the object *o. - Returns -1 on failure. This is equivalent to - the Python statement: del o[key]. - */ - - PyAPI_FUNC(int) PyObject_DelItem(PyObject *o, PyObject *key); - - /* - Delete the mapping for key from *o. Returns -1 on failure. - This is the equivalent of the Python statement: del o[key]. - */ - - PyAPI_FUNC(int) PyObject_AsCharBuffer(PyObject *obj, - const char **buffer, - Py_ssize_t *buffer_len); - - /* - Takes an arbitrary object which must support the (character, - single segment) buffer interface and returns a pointer to a - read-only memory location useable as character based input - for subsequent processing. - - 0 is returned on success. buffer and buffer_len are only - set in case no error occurs. Otherwise, -1 is returned and - an exception set. - - */ - - PyAPI_FUNC(int) PyObject_CheckReadBuffer(PyObject *obj); - - /* - Checks whether an arbitrary object supports the (character, - single segment) buffer interface. Returns 1 on success, 0 - on failure. - - */ - - PyAPI_FUNC(int) PyObject_AsReadBuffer(PyObject *obj, - const void **buffer, - Py_ssize_t *buffer_len); - - /* - Same as PyObject_AsCharBuffer() except that this API expects - (readable, single segment) buffer interface and returns a - pointer to a read-only memory location which can contain - arbitrary data. - - 0 is returned on success. buffer and buffer_len are only - set in case no error occurs. Otherwise, -1 is returned and - an exception set. - - */ - - PyAPI_FUNC(int) PyObject_AsWriteBuffer(PyObject *obj, - void **buffer, - Py_ssize_t *buffer_len); - - /* - Takes an arbitrary object which must support the (writeable, - single segment) buffer interface and returns a pointer to a - writeable memory location in buffer of size buffer_len. - - 0 is returned on success. buffer and buffer_len are only - set in case no error occurs. Otherwise, -1 is returned and - an exception set. - - */ - - /* new buffer API */ - -#define PyObject_CheckBuffer(obj) \ - (((obj)->ob_type->tp_as_buffer != NULL) && \ - (PyType_HasFeature((obj)->ob_type, Py_TPFLAGS_HAVE_NEWBUFFER)) && \ - ((obj)->ob_type->tp_as_buffer->bf_getbuffer != NULL)) - - /* Return 1 if the getbuffer function is available, otherwise - return 0 */ - - PyAPI_FUNC(int) PyObject_GetBuffer(PyObject *obj, Py_buffer *view, - int flags); - - /* This is a C-API version of the getbuffer function call. It checks - to make sure object has the required function pointer and issues the - call. Returns -1 and raises an error on failure and returns 0 on - success - */ - - - PyAPI_FUNC(void *) PyBuffer_GetPointer(Py_buffer *view, Py_ssize_t *indices); - - /* Get the memory area pointed to by the indices for the buffer given. - Note that view->ndim is the assumed size of indices - */ - - PyAPI_FUNC(int) PyBuffer_SizeFromFormat(const char *); - - /* Return the implied itemsize of the data-format area from a - struct-style description */ - - - - PyAPI_FUNC(int) PyBuffer_ToContiguous(void *buf, Py_buffer *view, - Py_ssize_t len, char fort); - - PyAPI_FUNC(int) PyBuffer_FromContiguous(Py_buffer *view, void *buf, - Py_ssize_t len, char fort); - - - /* Copy len bytes of data from the contiguous chunk of memory - pointed to by buf into the buffer exported by obj. Return - 0 on success and return -1 and raise a PyBuffer_Error on - error (i.e. the object does not have a buffer interface or - it is not working). - - If fort is 'F' and the object is multi-dimensional, - then the data will be copied into the array in - Fortran-style (first dimension varies the fastest). If - fort is 'C', then the data will be copied into the array - in C-style (last dimension varies the fastest). If fort - is 'A', then it does not matter and the copy will be made - in whatever way is more efficient. - - */ - - PyAPI_FUNC(int) PyObject_CopyData(PyObject *dest, PyObject *src); - - /* Copy the data from the src buffer to the buffer of destination - */ - - PyAPI_FUNC(int) PyBuffer_IsContiguous(Py_buffer *view, char fort); - - - PyAPI_FUNC(void) PyBuffer_FillContiguousStrides(int ndims, - Py_ssize_t *shape, - Py_ssize_t *strides, - int itemsize, - char fort); - - /* Fill the strides array with byte-strides of a contiguous - (Fortran-style if fort is 'F' or C-style otherwise) - array of the given shape with the given number of bytes - per element. - */ - - PyAPI_FUNC(int) PyBuffer_FillInfo(Py_buffer *view, PyObject *o, void *buf, - Py_ssize_t len, int readonly, - int flags); - - /* Fills in a buffer-info structure correctly for an exporter - that can only share a contiguous chunk of memory of - "unsigned bytes" of the given length. Returns 0 on success - and -1 (with raising an error) on error. - */ - - PyAPI_FUNC(void) PyBuffer_Release(Py_buffer *view); - - /* Releases a Py_buffer obtained from getbuffer ParseTuple's s*. - */ - - PyAPI_FUNC(PyObject *) PyObject_Format(PyObject* obj, - PyObject *format_spec); - /* - Takes an arbitrary object and returns the result of - calling obj.__format__(format_spec). - */ - -/* Iterators */ - - PyAPI_FUNC(PyObject *) PyObject_GetIter(PyObject *); - /* Takes an object and returns an iterator for it. - This is typically a new iterator but if the argument - is an iterator, this returns itself. */ - -#define PyIter_Check(obj) \ - (PyType_HasFeature((obj)->ob_type, Py_TPFLAGS_HAVE_ITER) && \ - (obj)->ob_type->tp_iternext != NULL && \ - (obj)->ob_type->tp_iternext != &_PyObject_NextNotImplemented) - - PyAPI_FUNC(PyObject *) PyIter_Next(PyObject *); - /* Takes an iterator object and calls its tp_iternext slot, - returning the next value. If the iterator is exhausted, - this returns NULL without setting an exception. - NULL with an exception means an error occurred. */ - -/* Number Protocol:*/ - - PyAPI_FUNC(int) PyNumber_Check(PyObject *o); - - /* - Returns 1 if the object, o, provides numeric protocols, and - false otherwise. - - This function always succeeds. - - */ - - PyAPI_FUNC(PyObject *) PyNumber_Add(PyObject *o1, PyObject *o2); - - /* - Returns the result of adding o1 and o2, or null on failure. - This is the equivalent of the Python expression: o1+o2. - - - */ - - PyAPI_FUNC(PyObject *) PyNumber_Subtract(PyObject *o1, PyObject *o2); - - /* - Returns the result of subtracting o2 from o1, or null on - failure. This is the equivalent of the Python expression: - o1-o2. - - */ - - PyAPI_FUNC(PyObject *) PyNumber_Multiply(PyObject *o1, PyObject *o2); - - /* - Returns the result of multiplying o1 and o2, or null on - failure. This is the equivalent of the Python expression: - o1*o2. - - - */ - - PyAPI_FUNC(PyObject *) PyNumber_Divide(PyObject *o1, PyObject *o2); - - /* - Returns the result of dividing o1 by o2, or null on failure. - This is the equivalent of the Python expression: o1/o2. - - - */ - - PyAPI_FUNC(PyObject *) PyNumber_FloorDivide(PyObject *o1, PyObject *o2); - - /* - Returns the result of dividing o1 by o2 giving an integral result, - or null on failure. - This is the equivalent of the Python expression: o1//o2. - - - */ - - PyAPI_FUNC(PyObject *) PyNumber_TrueDivide(PyObject *o1, PyObject *o2); - - /* - Returns the result of dividing o1 by o2 giving a float result, - or null on failure. - This is the equivalent of the Python expression: o1/o2. - - - */ - - PyAPI_FUNC(PyObject *) PyNumber_Remainder(PyObject *o1, PyObject *o2); - - /* - Returns the remainder of dividing o1 by o2, or null on - failure. This is the equivalent of the Python expression: - o1%o2. - - - */ - - PyAPI_FUNC(PyObject *) PyNumber_Divmod(PyObject *o1, PyObject *o2); - - /* - See the built-in function divmod. Returns NULL on failure. - This is the equivalent of the Python expression: - divmod(o1,o2). - - - */ - - PyAPI_FUNC(PyObject *) PyNumber_Power(PyObject *o1, PyObject *o2, - PyObject *o3); - - /* - See the built-in function pow. Returns NULL on failure. - This is the equivalent of the Python expression: - pow(o1,o2,o3), where o3 is optional. - - */ - - PyAPI_FUNC(PyObject *) PyNumber_Negative(PyObject *o); - - /* - Returns the negation of o on success, or null on failure. - This is the equivalent of the Python expression: -o. - - */ - - PyAPI_FUNC(PyObject *) PyNumber_Positive(PyObject *o); - - /* - Returns the (what?) of o on success, or NULL on failure. - This is the equivalent of the Python expression: +o. - - */ - - PyAPI_FUNC(PyObject *) PyNumber_Absolute(PyObject *o); - - /* - Returns the absolute value of o, or null on failure. This is - the equivalent of the Python expression: abs(o). - - */ - - PyAPI_FUNC(PyObject *) PyNumber_Invert(PyObject *o); - - /* - Returns the bitwise negation of o on success, or NULL on - failure. This is the equivalent of the Python expression: - ~o. - - - */ - - PyAPI_FUNC(PyObject *) PyNumber_Lshift(PyObject *o1, PyObject *o2); - - /* - Returns the result of left shifting o1 by o2 on success, or - NULL on failure. This is the equivalent of the Python - expression: o1 << o2. - - - */ - - PyAPI_FUNC(PyObject *) PyNumber_Rshift(PyObject *o1, PyObject *o2); - - /* - Returns the result of right shifting o1 by o2 on success, or - NULL on failure. This is the equivalent of the Python - expression: o1 >> o2. - - */ - - PyAPI_FUNC(PyObject *) PyNumber_And(PyObject *o1, PyObject *o2); - - /* - Returns the result of bitwise and of o1 and o2 on success, or - NULL on failure. This is the equivalent of the Python - expression: o1&o2. - - - */ - - PyAPI_FUNC(PyObject *) PyNumber_Xor(PyObject *o1, PyObject *o2); - - /* - Returns the bitwise exclusive or of o1 by o2 on success, or - NULL on failure. This is the equivalent of the Python - expression: o1^o2. - - - */ - - PyAPI_FUNC(PyObject *) PyNumber_Or(PyObject *o1, PyObject *o2); - - /* - Returns the result of bitwise or on o1 and o2 on success, or - NULL on failure. This is the equivalent of the Python - expression: o1|o2. - - */ - - /* Implemented elsewhere: - - int PyNumber_Coerce(PyObject **p1, PyObject **p2); - - This function takes the addresses of two variables of type - PyObject*. - - If the objects pointed to by *p1 and *p2 have the same type, - increment their reference count and return 0 (success). - If the objects can be converted to a common numeric type, - replace *p1 and *p2 by their converted value (with 'new' - reference counts), and return 0. - If no conversion is possible, or if some other error occurs, - return -1 (failure) and don't increment the reference counts. - The call PyNumber_Coerce(&o1, &o2) is equivalent to the Python - statement o1, o2 = coerce(o1, o2). - - */ - -#define PyIndex_Check(obj) \ - ((obj)->ob_type->tp_as_number != NULL && \ - PyType_HasFeature((obj)->ob_type, Py_TPFLAGS_HAVE_INDEX) && \ - (obj)->ob_type->tp_as_number->nb_index != NULL) - - PyAPI_FUNC(PyObject *) PyNumber_Index(PyObject *o); - - /* - Returns the object converted to a Python long or int - or NULL with an error raised on failure. - */ - - PyAPI_FUNC(Py_ssize_t) PyNumber_AsSsize_t(PyObject *o, PyObject *exc); - - /* - Returns the Integral instance converted to an int. The - instance is expected to be int or long or have an __int__ - method. Steals integral's reference. error_format will be - used to create the TypeError if integral isn't actually an - Integral instance. error_format should be a format string - that can accept a char* naming integral's type. - */ - - PyAPI_FUNC(PyObject *) _PyNumber_ConvertIntegralToInt( - PyObject *integral, - const char* error_format); - - /* - Returns the object converted to Py_ssize_t by going through - PyNumber_Index first. If an overflow error occurs while - converting the int-or-long to Py_ssize_t, then the second argument - is the error-type to return. If it is NULL, then the overflow error - is cleared and the value is clipped. - */ - - PyAPI_FUNC(PyObject *) PyNumber_Int(PyObject *o); - - /* - Returns the o converted to an integer object on success, or - NULL on failure. This is the equivalent of the Python - expression: int(o). - - */ - - PyAPI_FUNC(PyObject *) PyNumber_Long(PyObject *o); - - /* - Returns the o converted to a long integer object on success, - or NULL on failure. This is the equivalent of the Python - expression: long(o). - - */ - - PyAPI_FUNC(PyObject *) PyNumber_Float(PyObject *o); - - /* - Returns the o converted to a float object on success, or NULL - on failure. This is the equivalent of the Python expression: - float(o). - */ - -/* In-place variants of (some of) the above number protocol functions */ - - PyAPI_FUNC(PyObject *) PyNumber_InPlaceAdd(PyObject *o1, PyObject *o2); - - /* - Returns the result of adding o2 to o1, possibly in-place, or null - on failure. This is the equivalent of the Python expression: - o1 += o2. - - */ - - PyAPI_FUNC(PyObject *) PyNumber_InPlaceSubtract(PyObject *o1, PyObject *o2); - - /* - Returns the result of subtracting o2 from o1, possibly in-place or - null on failure. This is the equivalent of the Python expression: - o1 -= o2. - - */ - - PyAPI_FUNC(PyObject *) PyNumber_InPlaceMultiply(PyObject *o1, PyObject *o2); - - /* - Returns the result of multiplying o1 by o2, possibly in-place, or - null on failure. This is the equivalent of the Python expression: - o1 *= o2. - - */ - - PyAPI_FUNC(PyObject *) PyNumber_InPlaceDivide(PyObject *o1, PyObject *o2); - - /* - Returns the result of dividing o1 by o2, possibly in-place, or null - on failure. This is the equivalent of the Python expression: - o1 /= o2. - - */ - - PyAPI_FUNC(PyObject *) PyNumber_InPlaceFloorDivide(PyObject *o1, - PyObject *o2); - - /* - Returns the result of dividing o1 by o2 giving an integral result, - possibly in-place, or null on failure. - This is the equivalent of the Python expression: - o1 /= o2. - - */ - - PyAPI_FUNC(PyObject *) PyNumber_InPlaceTrueDivide(PyObject *o1, - PyObject *o2); - - /* - Returns the result of dividing o1 by o2 giving a float result, - possibly in-place, or null on failure. - This is the equivalent of the Python expression: - o1 /= o2. - - */ - - PyAPI_FUNC(PyObject *) PyNumber_InPlaceRemainder(PyObject *o1, PyObject *o2); - - /* - Returns the remainder of dividing o1 by o2, possibly in-place, or - null on failure. This is the equivalent of the Python expression: - o1 %= o2. - - */ - - PyAPI_FUNC(PyObject *) PyNumber_InPlacePower(PyObject *o1, PyObject *o2, - PyObject *o3); - - /* - Returns the result of raising o1 to the power of o2, possibly - in-place, or null on failure. This is the equivalent of the Python - expression: o1 **= o2, or pow(o1, o2, o3) if o3 is present. - - */ - - PyAPI_FUNC(PyObject *) PyNumber_InPlaceLshift(PyObject *o1, PyObject *o2); - - /* - Returns the result of left shifting o1 by o2, possibly in-place, or - null on failure. This is the equivalent of the Python expression: - o1 <<= o2. - - */ - - PyAPI_FUNC(PyObject *) PyNumber_InPlaceRshift(PyObject *o1, PyObject *o2); - - /* - Returns the result of right shifting o1 by o2, possibly in-place or - null on failure. This is the equivalent of the Python expression: - o1 >>= o2. - - */ - - PyAPI_FUNC(PyObject *) PyNumber_InPlaceAnd(PyObject *o1, PyObject *o2); - - /* - Returns the result of bitwise and of o1 and o2, possibly in-place, - or null on failure. This is the equivalent of the Python - expression: o1 &= o2. - - */ - - PyAPI_FUNC(PyObject *) PyNumber_InPlaceXor(PyObject *o1, PyObject *o2); - - /* - Returns the bitwise exclusive or of o1 by o2, possibly in-place, or - null on failure. This is the equivalent of the Python expression: - o1 ^= o2. - - */ - - PyAPI_FUNC(PyObject *) PyNumber_InPlaceOr(PyObject *o1, PyObject *o2); - - /* - Returns the result of bitwise or of o1 and o2, possibly in-place, - or null on failure. This is the equivalent of the Python - expression: o1 |= o2. - - */ - - - PyAPI_FUNC(PyObject *) PyNumber_ToBase(PyObject *n, int base); - - /* - Returns the integer n converted to a string with a base, with a base - marker of 0b, 0o or 0x prefixed if applicable. - If n is not an int object, it is converted with PyNumber_Index first. - */ - - -/* Sequence protocol:*/ - - PyAPI_FUNC(int) PySequence_Check(PyObject *o); - - /* - Return 1 if the object provides sequence protocol, and zero - otherwise. - - This function always succeeds. - - */ - - PyAPI_FUNC(Py_ssize_t) PySequence_Size(PyObject *o); - - /* - Return the size of sequence object o, or -1 on failure. - - */ - - /* For DLL compatibility */ -#undef PySequence_Length - PyAPI_FUNC(Py_ssize_t) PySequence_Length(PyObject *o); -#define PySequence_Length PySequence_Size - - - PyAPI_FUNC(PyObject *) PySequence_Concat(PyObject *o1, PyObject *o2); - - /* - Return the concatenation of o1 and o2 on success, and NULL on - failure. This is the equivalent of the Python - expression: o1+o2. - - */ - - PyAPI_FUNC(PyObject *) PySequence_Repeat(PyObject *o, Py_ssize_t count); - - /* - Return the result of repeating sequence object o count times, - or NULL on failure. This is the equivalent of the Python - expression: o1*count. - - */ - - PyAPI_FUNC(PyObject *) PySequence_GetItem(PyObject *o, Py_ssize_t i); - - /* - Return the ith element of o, or NULL on failure. This is the - equivalent of the Python expression: o[i]. - */ - - PyAPI_FUNC(PyObject *) PySequence_GetSlice(PyObject *o, Py_ssize_t i1, Py_ssize_t i2); - - /* - Return the slice of sequence object o between i1 and i2, or - NULL on failure. This is the equivalent of the Python - expression: o[i1:i2]. - - */ - - PyAPI_FUNC(int) PySequence_SetItem(PyObject *o, Py_ssize_t i, PyObject *v); - - /* - Assign object v to the ith element of o. Returns - -1 on failure. This is the equivalent of the Python - statement: o[i]=v. - - */ - - PyAPI_FUNC(int) PySequence_DelItem(PyObject *o, Py_ssize_t i); - - /* - Delete the ith element of object v. Returns - -1 on failure. This is the equivalent of the Python - statement: del o[i]. - */ - - PyAPI_FUNC(int) PySequence_SetSlice(PyObject *o, Py_ssize_t i1, Py_ssize_t i2, - PyObject *v); - - /* - Assign the sequence object, v, to the slice in sequence - object, o, from i1 to i2. Returns -1 on failure. This is the - equivalent of the Python statement: o[i1:i2]=v. - */ - - PyAPI_FUNC(int) PySequence_DelSlice(PyObject *o, Py_ssize_t i1, Py_ssize_t i2); - - /* - Delete the slice in sequence object, o, from i1 to i2. - Returns -1 on failure. This is the equivalent of the Python - statement: del o[i1:i2]. - */ - - PyAPI_FUNC(PyObject *) PySequence_Tuple(PyObject *o); - - /* - Returns the sequence, o, as a tuple on success, and NULL on failure. - This is equivalent to the Python expression: tuple(o) - */ - - - PyAPI_FUNC(PyObject *) PySequence_List(PyObject *o); - /* - Returns the sequence, o, as a list on success, and NULL on failure. - This is equivalent to the Python expression: list(o) - */ - - PyAPI_FUNC(PyObject *) PySequence_Fast(PyObject *o, const char* m); - /* - Returns the sequence, o, as a tuple, unless it's already a - tuple or list. Use PySequence_Fast_GET_ITEM to access the - members of this list, and PySequence_Fast_GET_SIZE to get its length. - - Returns NULL on failure. If the object does not support iteration, - raises a TypeError exception with m as the message text. - */ - -#define PySequence_Fast_GET_SIZE(o) \ - (PyList_Check(o) ? PyList_GET_SIZE(o) : PyTuple_GET_SIZE(o)) - /* - Return the size of o, assuming that o was returned by - PySequence_Fast and is not NULL. - */ - -#define PySequence_Fast_GET_ITEM(o, i)\ - (PyList_Check(o) ? PyList_GET_ITEM(o, i) : PyTuple_GET_ITEM(o, i)) - /* - Return the ith element of o, assuming that o was returned by - PySequence_Fast, and that i is within bounds. - */ - -#define PySequence_ITEM(o, i)\ - ( Py_TYPE(o)->tp_as_sequence->sq_item(o, i) ) - /* Assume tp_as_sequence and sq_item exist and that i does not - need to be corrected for a negative index - */ - -#define PySequence_Fast_ITEMS(sf) \ - (PyList_Check(sf) ? ((PyListObject *)(sf))->ob_item \ - : ((PyTupleObject *)(sf))->ob_item) - /* Return a pointer to the underlying item array for - an object retured by PySequence_Fast */ - - PyAPI_FUNC(Py_ssize_t) PySequence_Count(PyObject *o, PyObject *value); - - /* - Return the number of occurrences on value on o, that is, - return the number of keys for which o[key]==value. On - failure, return -1. This is equivalent to the Python - expression: o.count(value). - */ - - PyAPI_FUNC(int) PySequence_Contains(PyObject *seq, PyObject *ob); - /* - Return -1 if error; 1 if ob in seq; 0 if ob not in seq. - Use __contains__ if possible, else _PySequence_IterSearch(). - */ - -#define PY_ITERSEARCH_COUNT 1 -#define PY_ITERSEARCH_INDEX 2 -#define PY_ITERSEARCH_CONTAINS 3 - PyAPI_FUNC(Py_ssize_t) _PySequence_IterSearch(PyObject *seq, - PyObject *obj, int operation); - /* - Iterate over seq. Result depends on the operation: - PY_ITERSEARCH_COUNT: return # of times obj appears in seq; -1 if - error. - PY_ITERSEARCH_INDEX: return 0-based index of first occurrence of - obj in seq; set ValueError and return -1 if none found; - also return -1 on error. - PY_ITERSEARCH_CONTAINS: return 1 if obj in seq, else 0; -1 on - error. - */ - -/* For DLL-level backwards compatibility */ -#undef PySequence_In - PyAPI_FUNC(int) PySequence_In(PyObject *o, PyObject *value); - -/* For source-level backwards compatibility */ -#define PySequence_In PySequence_Contains - - /* - Determine if o contains value. If an item in o is equal to - X, return 1, otherwise return 0. On error, return -1. This - is equivalent to the Python expression: value in o. - */ - - PyAPI_FUNC(Py_ssize_t) PySequence_Index(PyObject *o, PyObject *value); - - /* - Return the first index for which o[i]=value. On error, - return -1. This is equivalent to the Python - expression: o.index(value). - */ - -/* In-place versions of some of the above Sequence functions. */ - - PyAPI_FUNC(PyObject *) PySequence_InPlaceConcat(PyObject *o1, PyObject *o2); - - /* - Append o2 to o1, in-place when possible. Return the resulting - object, which could be o1, or NULL on failure. This is the - equivalent of the Python expression: o1 += o2. - - */ - - PyAPI_FUNC(PyObject *) PySequence_InPlaceRepeat(PyObject *o, Py_ssize_t count); - - /* - Repeat o1 by count, in-place when possible. Return the resulting - object, which could be o1, or NULL on failure. This is the - equivalent of the Python expression: o1 *= count. - - */ - -/* Mapping protocol:*/ - - PyAPI_FUNC(int) PyMapping_Check(PyObject *o); - - /* - Return 1 if the object provides mapping protocol, and zero - otherwise. - - This function always succeeds. - */ - - PyAPI_FUNC(Py_ssize_t) PyMapping_Size(PyObject *o); - - /* - Returns the number of keys in object o on success, and -1 on - failure. For objects that do not provide sequence protocol, - this is equivalent to the Python expression: len(o). - */ - - /* For DLL compatibility */ -#undef PyMapping_Length - PyAPI_FUNC(Py_ssize_t) PyMapping_Length(PyObject *o); -#define PyMapping_Length PyMapping_Size - - - /* implemented as a macro: - - int PyMapping_DelItemString(PyObject *o, char *key); - - Remove the mapping for object, key, from the object *o. - Returns -1 on failure. This is equivalent to - the Python statement: del o[key]. - */ -#define PyMapping_DelItemString(O,K) PyObject_DelItemString((O),(K)) - - /* implemented as a macro: - - int PyMapping_DelItem(PyObject *o, PyObject *key); - - Remove the mapping for object, key, from the object *o. - Returns -1 on failure. This is equivalent to - the Python statement: del o[key]. - */ -#define PyMapping_DelItem(O,K) PyObject_DelItem((O),(K)) - - PyAPI_FUNC(int) PyMapping_HasKeyString(PyObject *o, char *key); - - /* - On success, return 1 if the mapping object has the key, key, - and 0 otherwise. This is equivalent to the Python expression: - o.has_key(key). - - This function always succeeds. - */ - - PyAPI_FUNC(int) PyMapping_HasKey(PyObject *o, PyObject *key); - - /* - Return 1 if the mapping object has the key, key, - and 0 otherwise. This is equivalent to the Python expression: - o.has_key(key). - - This function always succeeds. - - */ - - /* Implemented as macro: - - PyObject *PyMapping_Keys(PyObject *o); - - On success, return a list of the keys in object o. On - failure, return NULL. This is equivalent to the Python - expression: o.keys(). - */ -#define PyMapping_Keys(O) PyObject_CallMethod(O,"keys",NULL) - - /* Implemented as macro: - - PyObject *PyMapping_Values(PyObject *o); - - On success, return a list of the values in object o. On - failure, return NULL. This is equivalent to the Python - expression: o.values(). - */ -#define PyMapping_Values(O) PyObject_CallMethod(O,"values",NULL) - - /* Implemented as macro: - - PyObject *PyMapping_Items(PyObject *o); - - On success, return a list of the items in object o, where - each item is a tuple containing a key-value pair. On - failure, return NULL. This is equivalent to the Python - expression: o.items(). - - */ -#define PyMapping_Items(O) PyObject_CallMethod(O,"items",NULL) - - PyAPI_FUNC(PyObject *) PyMapping_GetItemString(PyObject *o, char *key); - - /* - Return element of o corresponding to the object, key, or NULL - on failure. This is the equivalent of the Python expression: - o[key]. - */ - - PyAPI_FUNC(int) PyMapping_SetItemString(PyObject *o, char *key, - PyObject *value); - - /* - Map the object, key, to the value, v. Returns - -1 on failure. This is the equivalent of the Python - statement: o[key]=v. - */ - - -PyAPI_FUNC(int) PyObject_IsInstance(PyObject *object, PyObject *typeorclass); - /* isinstance(object, typeorclass) */ - -PyAPI_FUNC(int) PyObject_IsSubclass(PyObject *object, PyObject *typeorclass); - /* issubclass(object, typeorclass) */ - - -PyAPI_FUNC(int) _PyObject_RealIsInstance(PyObject *inst, PyObject *cls); - -PyAPI_FUNC(int) _PyObject_RealIsSubclass(PyObject *derived, PyObject *cls); - - -/* For internal use by buffer API functions */ -PyAPI_FUNC(void) _Py_add_one_to_index_F(int nd, Py_ssize_t *index, - const Py_ssize_t *shape); -PyAPI_FUNC(void) _Py_add_one_to_index_C(int nd, Py_ssize_t *index, - const Py_ssize_t *shape); - - -#ifdef __cplusplus -} -#endif -#endif /* Py_ABSTRACTOBJECT_H */ diff --git a/python/include/asdl.h b/python/include/asdl.h deleted file mode 100644 index 84e837e7..00000000 --- a/python/include/asdl.h +++ /dev/null @@ -1,45 +0,0 @@ -#ifndef Py_ASDL_H -#define Py_ASDL_H - -typedef PyObject * identifier; -typedef PyObject * string; -typedef PyObject * object; - -#ifndef __cplusplus -typedef enum {false, true} bool; -#endif - -/* It would be nice if the code generated by asdl_c.py was completely - independent of Python, but it is a goal the requires too much work - at this stage. So, for example, I'll represent identifiers as - interned Python strings. -*/ - -/* XXX A sequence should be typed so that its use can be typechecked. */ - -typedef struct { - int size; - void *elements[1]; -} asdl_seq; - -typedef struct { - int size; - int elements[1]; -} asdl_int_seq; - -asdl_seq *asdl_seq_new(int size, PyArena *arena); -asdl_int_seq *asdl_int_seq_new(int size, PyArena *arena); - -#define asdl_seq_GET(S, I) (S)->elements[(I)] -#define asdl_seq_LEN(S) ((S) == NULL ? 0 : (S)->size) -#ifdef Py_DEBUG -#define asdl_seq_SET(S, I, V) { \ - int _asdl_i = (I); \ - assert((S) && _asdl_i < (S)->size); \ - (S)->elements[_asdl_i] = (V); \ -} -#else -#define asdl_seq_SET(S, I, V) (S)->elements[I] = (V) -#endif - -#endif /* !Py_ASDL_H */ diff --git a/python/include/ast.h b/python/include/ast.h deleted file mode 100644 index cc14b7fd..00000000 --- a/python/include/ast.h +++ /dev/null @@ -1,13 +0,0 @@ -#ifndef Py_AST_H -#define Py_AST_H -#ifdef __cplusplus -extern "C" { -#endif - -PyAPI_FUNC(mod_ty) PyAST_FromNode(const node *, PyCompilerFlags *flags, - const char *, PyArena *); - -#ifdef __cplusplus -} -#endif -#endif /* !Py_AST_H */ diff --git a/python/include/bitset.h b/python/include/bitset.h deleted file mode 100644 index faeb4191..00000000 --- a/python/include/bitset.h +++ /dev/null @@ -1,32 +0,0 @@ - -#ifndef Py_BITSET_H -#define Py_BITSET_H -#ifdef __cplusplus -extern "C" { -#endif - -/* Bitset interface */ - -#define BYTE char - -typedef BYTE *bitset; - -bitset newbitset(int nbits); -void delbitset(bitset bs); -#define testbit(ss, ibit) (((ss)[BIT2BYTE(ibit)] & BIT2MASK(ibit)) != 0) -int addbit(bitset bs, int ibit); /* Returns 0 if already set */ -int samebitset(bitset bs1, bitset bs2, int nbits); -void mergebitset(bitset bs1, bitset bs2, int nbits); - -#define BITSPERBYTE (8*sizeof(BYTE)) -#define NBYTES(nbits) (((nbits) + BITSPERBYTE - 1) / BITSPERBYTE) - -#define BIT2BYTE(ibit) ((ibit) / BITSPERBYTE) -#define BIT2SHIFT(ibit) ((ibit) % BITSPERBYTE) -#define BIT2MASK(ibit) (1 << BIT2SHIFT(ibit)) -#define BYTE2BIT(ibyte) ((ibyte) * BITSPERBYTE) - -#ifdef __cplusplus -} -#endif -#endif /* !Py_BITSET_H */ diff --git a/python/include/boolobject.h b/python/include/boolobject.h deleted file mode 100644 index 74e854f7..00000000 --- a/python/include/boolobject.h +++ /dev/null @@ -1,36 +0,0 @@ -/* Boolean object interface */ - -#ifndef Py_BOOLOBJECT_H -#define Py_BOOLOBJECT_H -#ifdef __cplusplus -extern "C" { -#endif - - -typedef PyIntObject PyBoolObject; - -PyAPI_DATA(PyTypeObject) PyBool_Type; - -#define PyBool_Check(x) (Py_TYPE(x) == &PyBool_Type) - -/* Py_False and Py_True are the only two bools in existence. -Don't forget to apply Py_INCREF() when returning either!!! */ - -/* Don't use these directly */ -PyAPI_DATA(PyIntObject) _Py_ZeroStruct, _Py_TrueStruct; - -/* Use these macros */ -#define Py_False ((PyObject *) &_Py_ZeroStruct) -#define Py_True ((PyObject *) &_Py_TrueStruct) - -/* Macros for returning Py_True or Py_False, respectively */ -#define Py_RETURN_TRUE return Py_INCREF(Py_True), Py_True -#define Py_RETURN_FALSE return Py_INCREF(Py_False), Py_False - -/* Function to return a bool from a C long */ -PyAPI_FUNC(PyObject *) PyBool_FromLong(long); - -#ifdef __cplusplus -} -#endif -#endif /* !Py_BOOLOBJECT_H */ diff --git a/python/include/bufferobject.h b/python/include/bufferobject.h deleted file mode 100644 index 6dd83458..00000000 --- a/python/include/bufferobject.h +++ /dev/null @@ -1,33 +0,0 @@ - -/* Buffer object interface */ - -/* Note: the object's structure is private */ - -#ifndef Py_BUFFEROBJECT_H -#define Py_BUFFEROBJECT_H -#ifdef __cplusplus -extern "C" { -#endif - - -PyAPI_DATA(PyTypeObject) PyBuffer_Type; - -#define PyBuffer_Check(op) (Py_TYPE(op) == &PyBuffer_Type) - -#define Py_END_OF_BUFFER (-1) - -PyAPI_FUNC(PyObject *) PyBuffer_FromObject(PyObject *base, - Py_ssize_t offset, Py_ssize_t size); -PyAPI_FUNC(PyObject *) PyBuffer_FromReadWriteObject(PyObject *base, - Py_ssize_t offset, - Py_ssize_t size); - -PyAPI_FUNC(PyObject *) PyBuffer_FromMemory(void *ptr, Py_ssize_t size); -PyAPI_FUNC(PyObject *) PyBuffer_FromReadWriteMemory(void *ptr, Py_ssize_t size); - -PyAPI_FUNC(PyObject *) PyBuffer_New(Py_ssize_t size); - -#ifdef __cplusplus -} -#endif -#endif /* !Py_BUFFEROBJECT_H */ diff --git a/python/include/bytearrayobject.h b/python/include/bytearrayobject.h deleted file mode 100644 index e1281a62..00000000 --- a/python/include/bytearrayobject.h +++ /dev/null @@ -1,57 +0,0 @@ -/* ByteArray object interface */ - -#ifndef Py_BYTEARRAYOBJECT_H -#define Py_BYTEARRAYOBJECT_H -#ifdef __cplusplus -extern "C" { -#endif - -#include - -/* Type PyByteArrayObject represents a mutable array of bytes. - * The Python API is that of a sequence; - * the bytes are mapped to ints in [0, 256). - * Bytes are not characters; they may be used to encode characters. - * The only way to go between bytes and str/unicode is via encoding - * and decoding. - * For the convenience of C programmers, the bytes type is considered - * to contain a char pointer, not an unsigned char pointer. - */ - -/* Object layout */ -typedef struct { - PyObject_VAR_HEAD - /* XXX(nnorwitz): should ob_exports be Py_ssize_t? */ - int ob_exports; /* how many buffer exports */ - Py_ssize_t ob_alloc; /* How many bytes allocated */ - char *ob_bytes; -} PyByteArrayObject; - -/* Type object */ -PyAPI_DATA(PyTypeObject) PyByteArray_Type; -PyAPI_DATA(PyTypeObject) PyByteArrayIter_Type; - -/* Type check macros */ -#define PyByteArray_Check(self) PyObject_TypeCheck(self, &PyByteArray_Type) -#define PyByteArray_CheckExact(self) (Py_TYPE(self) == &PyByteArray_Type) - -/* Direct API functions */ -PyAPI_FUNC(PyObject *) PyByteArray_FromObject(PyObject *); -PyAPI_FUNC(PyObject *) PyByteArray_Concat(PyObject *, PyObject *); -PyAPI_FUNC(PyObject *) PyByteArray_FromStringAndSize(const char *, Py_ssize_t); -PyAPI_FUNC(Py_ssize_t) PyByteArray_Size(PyObject *); -PyAPI_FUNC(char *) PyByteArray_AsString(PyObject *); -PyAPI_FUNC(int) PyByteArray_Resize(PyObject *, Py_ssize_t); - -/* Macros, trading safety for speed */ -#define PyByteArray_AS_STRING(self) \ - (assert(PyByteArray_Check(self)), \ - Py_SIZE(self) ? ((PyByteArrayObject *)(self))->ob_bytes : _PyByteArray_empty_string) -#define PyByteArray_GET_SIZE(self) (assert(PyByteArray_Check(self)),Py_SIZE(self)) - -PyAPI_DATA(char) _PyByteArray_empty_string[]; - -#ifdef __cplusplus -} -#endif -#endif /* !Py_BYTEARRAYOBJECT_H */ diff --git a/python/include/bytes_methods.h b/python/include/bytes_methods.h deleted file mode 100644 index 41256662..00000000 --- a/python/include/bytes_methods.h +++ /dev/null @@ -1,75 +0,0 @@ -#ifndef Py_BYTES_CTYPE_H -#define Py_BYTES_CTYPE_H - -/* - * The internal implementation behind PyString (bytes) and PyBytes (buffer) - * methods of the given names, they operate on ASCII byte strings. - */ -extern PyObject* _Py_bytes_isspace(const char *cptr, Py_ssize_t len); -extern PyObject* _Py_bytes_isalpha(const char *cptr, Py_ssize_t len); -extern PyObject* _Py_bytes_isalnum(const char *cptr, Py_ssize_t len); -extern PyObject* _Py_bytes_isdigit(const char *cptr, Py_ssize_t len); -extern PyObject* _Py_bytes_islower(const char *cptr, Py_ssize_t len); -extern PyObject* _Py_bytes_isupper(const char *cptr, Py_ssize_t len); -extern PyObject* _Py_bytes_istitle(const char *cptr, Py_ssize_t len); - -/* These store their len sized answer in the given preallocated *result arg. */ -extern void _Py_bytes_lower(char *result, const char *cptr, Py_ssize_t len); -extern void _Py_bytes_upper(char *result, const char *cptr, Py_ssize_t len); -extern void _Py_bytes_title(char *result, char *s, Py_ssize_t len); -extern void _Py_bytes_capitalize(char *result, char *s, Py_ssize_t len); -extern void _Py_bytes_swapcase(char *result, char *s, Py_ssize_t len); - -/* Shared __doc__ strings. */ -extern const char _Py_isspace__doc__[]; -extern const char _Py_isalpha__doc__[]; -extern const char _Py_isalnum__doc__[]; -extern const char _Py_isdigit__doc__[]; -extern const char _Py_islower__doc__[]; -extern const char _Py_isupper__doc__[]; -extern const char _Py_istitle__doc__[]; -extern const char _Py_lower__doc__[]; -extern const char _Py_upper__doc__[]; -extern const char _Py_title__doc__[]; -extern const char _Py_capitalize__doc__[]; -extern const char _Py_swapcase__doc__[]; - -/* These are left in for backward compatibility and will be removed - in 2.8/3.2 */ -#define ISLOWER(c) Py_ISLOWER(c) -#define ISUPPER(c) Py_ISUPPER(c) -#define ISALPHA(c) Py_ISALPHA(c) -#define ISDIGIT(c) Py_ISDIGIT(c) -#define ISXDIGIT(c) Py_ISXDIGIT(c) -#define ISALNUM(c) Py_ISALNUM(c) -#define ISSPACE(c) Py_ISSPACE(c) - -#undef islower -#define islower(c) undefined_islower(c) -#undef isupper -#define isupper(c) undefined_isupper(c) -#undef isalpha -#define isalpha(c) undefined_isalpha(c) -#undef isdigit -#define isdigit(c) undefined_isdigit(c) -#undef isxdigit -#define isxdigit(c) undefined_isxdigit(c) -#undef isalnum -#define isalnum(c) undefined_isalnum(c) -#undef isspace -#define isspace(c) undefined_isspace(c) - -/* These are left in for backward compatibility and will be removed - in 2.8/3.2 */ -#define TOLOWER(c) Py_TOLOWER(c) -#define TOUPPER(c) Py_TOUPPER(c) - -#undef tolower -#define tolower(c) undefined_tolower(c) -#undef toupper -#define toupper(c) undefined_toupper(c) - -/* this is needed because some docs are shared from the .o, not static */ -#define PyDoc_STRVAR_shared(name,str) const char name[] = PyDoc_STR(str) - -#endif /* !Py_BYTES_CTYPE_H */ diff --git a/python/include/bytesobject.h b/python/include/bytesobject.h deleted file mode 100644 index 1083da9c..00000000 --- a/python/include/bytesobject.h +++ /dev/null @@ -1,27 +0,0 @@ -#define PyBytesObject PyStringObject -#define PyBytes_Type PyString_Type - -#define PyBytes_Check PyString_Check -#define PyBytes_CheckExact PyString_CheckExact -#define PyBytes_CHECK_INTERNED PyString_CHECK_INTERNED -#define PyBytes_AS_STRING PyString_AS_STRING -#define PyBytes_GET_SIZE PyString_GET_SIZE -#define Py_TPFLAGS_BYTES_SUBCLASS Py_TPFLAGS_STRING_SUBCLASS - -#define PyBytes_FromStringAndSize PyString_FromStringAndSize -#define PyBytes_FromString PyString_FromString -#define PyBytes_FromFormatV PyString_FromFormatV -#define PyBytes_FromFormat PyString_FromFormat -#define PyBytes_Size PyString_Size -#define PyBytes_AsString PyString_AsString -#define PyBytes_Repr PyString_Repr -#define PyBytes_Concat PyString_Concat -#define PyBytes_ConcatAndDel PyString_ConcatAndDel -#define _PyBytes_Resize _PyString_Resize -#define _PyBytes_Eq _PyString_Eq -#define PyBytes_Format PyString_Format -#define _PyBytes_FormatLong _PyString_FormatLong -#define PyBytes_DecodeEscape PyString_DecodeEscape -#define _PyBytes_Join _PyString_Join -#define PyBytes_AsStringAndSize PyString_AsStringAndSize -#define _PyBytes_InsertThousandsGrouping _PyString_InsertThousandsGrouping diff --git a/python/include/cStringIO.h b/python/include/cStringIO.h deleted file mode 100644 index 6ca44a83..00000000 --- a/python/include/cStringIO.h +++ /dev/null @@ -1,73 +0,0 @@ -#ifndef Py_CSTRINGIO_H -#define Py_CSTRINGIO_H -#ifdef __cplusplus -extern "C" { -#endif -/* - - This header provides access to cStringIO objects from C. - Functions are provided for calling cStringIO objects and - macros are provided for testing whether you have cStringIO - objects. - - Before calling any of the functions or macros, you must initialize - the routines with: - - PycString_IMPORT - - This would typically be done in your init function. - -*/ - -#define PycStringIO_CAPSULE_NAME "cStringIO.cStringIO_CAPI" - -#define PycString_IMPORT \ - PycStringIO = ((struct PycStringIO_CAPI*)PyCapsule_Import(\ - PycStringIO_CAPSULE_NAME, 0)) - -/* Basic functions to manipulate cStringIO objects from C */ - -static struct PycStringIO_CAPI { - - /* Read a string from an input object. If the last argument - is -1, the remainder will be read. - */ - int(*cread)(PyObject *, char **, Py_ssize_t); - - /* Read a line from an input object. Returns the length of the read - line as an int and a pointer inside the object buffer as char** (so - the caller doesn't have to provide its own buffer as destination). - */ - int(*creadline)(PyObject *, char **); - - /* Write a string to an output object*/ - int(*cwrite)(PyObject *, const char *, Py_ssize_t); - - /* Get the output object as a Python string (returns new reference). */ - PyObject *(*cgetvalue)(PyObject *); - - /* Create a new output object */ - PyObject *(*NewOutput)(int); - - /* Create an input object from a Python string - (copies the Python string reference). - */ - PyObject *(*NewInput)(PyObject *); - - /* The Python types for cStringIO input and output objects. - Note that you can do input on an output object. - */ - PyTypeObject *InputType, *OutputType; - -} *PycStringIO; - -/* These can be used to test if you have one */ -#define PycStringIO_InputCheck(O) \ - (Py_TYPE(O)==PycStringIO->InputType) -#define PycStringIO_OutputCheck(O) \ - (Py_TYPE(O)==PycStringIO->OutputType) - -#ifdef __cplusplus -} -#endif -#endif /* !Py_CSTRINGIO_H */ diff --git a/python/include/cellobject.h b/python/include/cellobject.h deleted file mode 100644 index c927ee5d..00000000 --- a/python/include/cellobject.h +++ /dev/null @@ -1,28 +0,0 @@ -/* Cell object interface */ - -#ifndef Py_CELLOBJECT_H -#define Py_CELLOBJECT_H -#ifdef __cplusplus -extern "C" { -#endif - -typedef struct { - PyObject_HEAD - PyObject *ob_ref; /* Content of the cell or NULL when empty */ -} PyCellObject; - -PyAPI_DATA(PyTypeObject) PyCell_Type; - -#define PyCell_Check(op) (Py_TYPE(op) == &PyCell_Type) - -PyAPI_FUNC(PyObject *) PyCell_New(PyObject *); -PyAPI_FUNC(PyObject *) PyCell_Get(PyObject *); -PyAPI_FUNC(int) PyCell_Set(PyObject *, PyObject *); - -#define PyCell_GET(op) (((PyCellObject *)(op))->ob_ref) -#define PyCell_SET(op, v) (((PyCellObject *)(op))->ob_ref = v) - -#ifdef __cplusplus -} -#endif -#endif /* !Py_TUPLEOBJECT_H */ diff --git a/python/include/ceval.h b/python/include/ceval.h deleted file mode 100644 index 0e8bd2ab..00000000 --- a/python/include/ceval.h +++ /dev/null @@ -1,153 +0,0 @@ -#ifndef Py_CEVAL_H -#define Py_CEVAL_H -#ifdef __cplusplus -extern "C" { -#endif - - -/* Interface to random parts in ceval.c */ - -PyAPI_FUNC(PyObject *) PyEval_CallObjectWithKeywords( - PyObject *, PyObject *, PyObject *); - -/* Inline this */ -#define PyEval_CallObject(func,arg) \ - PyEval_CallObjectWithKeywords(func, arg, (PyObject *)NULL) - -PyAPI_FUNC(PyObject *) PyEval_CallFunction(PyObject *obj, - const char *format, ...); -PyAPI_FUNC(PyObject *) PyEval_CallMethod(PyObject *obj, - const char *methodname, - const char *format, ...); - -PyAPI_FUNC(void) PyEval_SetProfile(Py_tracefunc, PyObject *); -PyAPI_FUNC(void) PyEval_SetTrace(Py_tracefunc, PyObject *); - -struct _frame; /* Avoid including frameobject.h */ - -PyAPI_FUNC(PyObject *) PyEval_GetBuiltins(void); -PyAPI_FUNC(PyObject *) PyEval_GetGlobals(void); -PyAPI_FUNC(PyObject *) PyEval_GetLocals(void); -PyAPI_FUNC(struct _frame *) PyEval_GetFrame(void); -PyAPI_FUNC(int) PyEval_GetRestricted(void); - -/* Look at the current frame's (if any) code's co_flags, and turn on - the corresponding compiler flags in cf->cf_flags. Return 1 if any - flag was set, else return 0. */ -PyAPI_FUNC(int) PyEval_MergeCompilerFlags(PyCompilerFlags *cf); - -PyAPI_FUNC(int) Py_FlushLine(void); - -PyAPI_FUNC(int) Py_AddPendingCall(int (*func)(void *), void *arg); -PyAPI_FUNC(int) Py_MakePendingCalls(void); - -/* Protection against deeply nested recursive calls */ -PyAPI_FUNC(void) Py_SetRecursionLimit(int); -PyAPI_FUNC(int) Py_GetRecursionLimit(void); - -#define Py_EnterRecursiveCall(where) \ - (_Py_MakeRecCheck(PyThreadState_GET()->recursion_depth) && \ - _Py_CheckRecursiveCall(where)) -#define Py_LeaveRecursiveCall() \ - (--PyThreadState_GET()->recursion_depth) -PyAPI_FUNC(int) _Py_CheckRecursiveCall(char *where); -PyAPI_DATA(int) _Py_CheckRecursionLimit; -#ifdef USE_STACKCHECK -# define _Py_MakeRecCheck(x) (++(x) > --_Py_CheckRecursionLimit) -#else -# define _Py_MakeRecCheck(x) (++(x) > _Py_CheckRecursionLimit) -#endif - -PyAPI_FUNC(const char *) PyEval_GetFuncName(PyObject *); -PyAPI_FUNC(const char *) PyEval_GetFuncDesc(PyObject *); - -PyAPI_FUNC(PyObject *) PyEval_GetCallStats(PyObject *); -PyAPI_FUNC(PyObject *) PyEval_EvalFrame(struct _frame *); -PyAPI_FUNC(PyObject *) PyEval_EvalFrameEx(struct _frame *f, int exc); - -/* this used to be handled on a per-thread basis - now just two globals */ -PyAPI_DATA(volatile int) _Py_Ticker; -PyAPI_DATA(int) _Py_CheckInterval; - -/* Interface for threads. - - A module that plans to do a blocking system call (or something else - that lasts a long time and doesn't touch Python data) can allow other - threads to run as follows: - - ...preparations here... - Py_BEGIN_ALLOW_THREADS - ...blocking system call here... - Py_END_ALLOW_THREADS - ...interpret result here... - - The Py_BEGIN_ALLOW_THREADS/Py_END_ALLOW_THREADS pair expands to a - {}-surrounded block. - To leave the block in the middle (e.g., with return), you must insert - a line containing Py_BLOCK_THREADS before the return, e.g. - - if (...premature_exit...) { - Py_BLOCK_THREADS - PyErr_SetFromErrno(PyExc_IOError); - return NULL; - } - - An alternative is: - - Py_BLOCK_THREADS - if (...premature_exit...) { - PyErr_SetFromErrno(PyExc_IOError); - return NULL; - } - Py_UNBLOCK_THREADS - - For convenience, that the value of 'errno' is restored across - Py_END_ALLOW_THREADS and Py_BLOCK_THREADS. - - WARNING: NEVER NEST CALLS TO Py_BEGIN_ALLOW_THREADS AND - Py_END_ALLOW_THREADS!!! - - The function PyEval_InitThreads() should be called only from - initthread() in "threadmodule.c". - - Note that not yet all candidates have been converted to use this - mechanism! -*/ - -PyAPI_FUNC(PyThreadState *) PyEval_SaveThread(void); -PyAPI_FUNC(void) PyEval_RestoreThread(PyThreadState *); - -#ifdef WITH_THREAD - -PyAPI_FUNC(int) PyEval_ThreadsInitialized(void); -PyAPI_FUNC(void) PyEval_InitThreads(void); -PyAPI_FUNC(void) PyEval_AcquireLock(void); -PyAPI_FUNC(void) PyEval_ReleaseLock(void); -PyAPI_FUNC(void) PyEval_AcquireThread(PyThreadState *tstate); -PyAPI_FUNC(void) PyEval_ReleaseThread(PyThreadState *tstate); -PyAPI_FUNC(void) PyEval_ReInitThreads(void); - -#define Py_BEGIN_ALLOW_THREADS { \ - PyThreadState *_save; \ - _save = PyEval_SaveThread(); -#define Py_BLOCK_THREADS PyEval_RestoreThread(_save); -#define Py_UNBLOCK_THREADS _save = PyEval_SaveThread(); -#define Py_END_ALLOW_THREADS PyEval_RestoreThread(_save); \ - } - -#else /* !WITH_THREAD */ - -#define Py_BEGIN_ALLOW_THREADS { -#define Py_BLOCK_THREADS -#define Py_UNBLOCK_THREADS -#define Py_END_ALLOW_THREADS } - -#endif /* !WITH_THREAD */ - -PyAPI_FUNC(int) _PyEval_SliceIndex(PyObject *, Py_ssize_t *); - - -#ifdef __cplusplus -} -#endif -#endif /* !Py_CEVAL_H */ diff --git a/python/include/classobject.h b/python/include/classobject.h deleted file mode 100644 index bc03e0d0..00000000 --- a/python/include/classobject.h +++ /dev/null @@ -1,83 +0,0 @@ - -/* Class object interface */ - -/* Revealing some structures (not for general use) */ - -#ifndef Py_CLASSOBJECT_H -#define Py_CLASSOBJECT_H -#ifdef __cplusplus -extern "C" { -#endif - -typedef struct { - PyObject_HEAD - PyObject *cl_bases; /* A tuple of class objects */ - PyObject *cl_dict; /* A dictionary */ - PyObject *cl_name; /* A string */ - /* The following three are functions or NULL */ - PyObject *cl_getattr; - PyObject *cl_setattr; - PyObject *cl_delattr; - PyObject *cl_weakreflist; /* List of weak references */ -} PyClassObject; - -typedef struct { - PyObject_HEAD - PyClassObject *in_class; /* The class object */ - PyObject *in_dict; /* A dictionary */ - PyObject *in_weakreflist; /* List of weak references */ -} PyInstanceObject; - -typedef struct { - PyObject_HEAD - PyObject *im_func; /* The callable object implementing the method */ - PyObject *im_self; /* The instance it is bound to, or NULL */ - PyObject *im_class; /* The class that asked for the method */ - PyObject *im_weakreflist; /* List of weak references */ -} PyMethodObject; - -PyAPI_DATA(PyTypeObject) PyClass_Type, PyInstance_Type, PyMethod_Type; - -#define PyClass_Check(op) ((op)->ob_type == &PyClass_Type) -#define PyInstance_Check(op) ((op)->ob_type == &PyInstance_Type) -#define PyMethod_Check(op) ((op)->ob_type == &PyMethod_Type) - -PyAPI_FUNC(PyObject *) PyClass_New(PyObject *, PyObject *, PyObject *); -PyAPI_FUNC(PyObject *) PyInstance_New(PyObject *, PyObject *, - PyObject *); -PyAPI_FUNC(PyObject *) PyInstance_NewRaw(PyObject *, PyObject *); -PyAPI_FUNC(PyObject *) PyMethod_New(PyObject *, PyObject *, PyObject *); - -PyAPI_FUNC(PyObject *) PyMethod_Function(PyObject *); -PyAPI_FUNC(PyObject *) PyMethod_Self(PyObject *); -PyAPI_FUNC(PyObject *) PyMethod_Class(PyObject *); - -/* Look up attribute with name (a string) on instance object pinst, using - * only the instance and base class dicts. If a descriptor is found in - * a class dict, the descriptor is returned without calling it. - * Returns NULL if nothing found, else a borrowed reference to the - * value associated with name in the dict in which name was found. - * The point of this routine is that it never calls arbitrary Python - * code, so is always "safe": all it does is dict lookups. The function - * can't fail, never sets an exception, and NULL is not an error (it just - * means "not found"). - */ -PyAPI_FUNC(PyObject *) _PyInstance_Lookup(PyObject *pinst, PyObject *name); - -/* Macros for direct access to these values. Type checks are *not* - done, so use with care. */ -#define PyMethod_GET_FUNCTION(meth) \ - (((PyMethodObject *)meth) -> im_func) -#define PyMethod_GET_SELF(meth) \ - (((PyMethodObject *)meth) -> im_self) -#define PyMethod_GET_CLASS(meth) \ - (((PyMethodObject *)meth) -> im_class) - -PyAPI_FUNC(int) PyClass_IsSubclass(PyObject *, PyObject *); - -PyAPI_FUNC(int) PyMethod_ClearFreeList(void); - -#ifdef __cplusplus -} -#endif -#endif /* !Py_CLASSOBJECT_H */ diff --git a/python/include/cobject.h b/python/include/cobject.h deleted file mode 100644 index ad3cd9c9..00000000 --- a/python/include/cobject.h +++ /dev/null @@ -1,89 +0,0 @@ -/* - CObjects are marked Pending Deprecation as of Python 2.7. - The full schedule for 2.x is as follows: - - CObjects are marked Pending Deprecation in Python 2.7. - - CObjects will be marked Deprecated in Python 2.8 - (if there is one). - - CObjects will be removed in Python 2.9 (if there is one). - - Additionally, for the Python 3.x series: - - CObjects were marked Deprecated in Python 3.1. - - CObjects will be removed in Python 3.2. - - You should switch all use of CObjects to capsules. Capsules - have a safer and more consistent API. For more information, - see Include/pycapsule.h, or read the "Capsules" topic in - the "Python/C API Reference Manual". - - Python 2.7 no longer uses CObjects itself; all objects which - were formerly CObjects are now capsules. Note that this change - does not by itself break binary compatibility with extensions - built for previous versions of Python--PyCObject_AsVoidPtr() - has been changed to also understand capsules. - -*/ - -/* original file header comment follows: */ - -/* C objects to be exported from one extension module to another. - - C objects are used for communication between extension modules. - They provide a way for an extension module to export a C interface - to other extension modules, so that extension modules can use the - Python import mechanism to link to one another. - -*/ - -#ifndef Py_COBJECT_H -#define Py_COBJECT_H -#ifdef __cplusplus -extern "C" { -#endif - -PyAPI_DATA(PyTypeObject) PyCObject_Type; - -#define PyCObject_Check(op) (Py_TYPE(op) == &PyCObject_Type) - -/* Create a PyCObject from a pointer to a C object and an optional - destructor function. If the second argument is non-null, then it - will be called with the first argument if and when the PyCObject is - destroyed. - -*/ -PyAPI_FUNC(PyObject *) PyCObject_FromVoidPtr( - void *cobj, void (*destruct)(void*)); - - -/* Create a PyCObject from a pointer to a C object, a description object, - and an optional destructor function. If the third argument is non-null, - then it will be called with the first and second arguments if and when - the PyCObject is destroyed. -*/ -PyAPI_FUNC(PyObject *) PyCObject_FromVoidPtrAndDesc( - void *cobj, void *desc, void (*destruct)(void*,void*)); - -/* Retrieve a pointer to a C object from a PyCObject. */ -PyAPI_FUNC(void *) PyCObject_AsVoidPtr(PyObject *); - -/* Retrieve a pointer to a description object from a PyCObject. */ -PyAPI_FUNC(void *) PyCObject_GetDesc(PyObject *); - -/* Import a pointer to a C object from a module using a PyCObject. */ -PyAPI_FUNC(void *) PyCObject_Import(char *module_name, char *cobject_name); - -/* Modify a C object. Fails (==0) if object has a destructor. */ -PyAPI_FUNC(int) PyCObject_SetVoidPtr(PyObject *self, void *cobj); - - -typedef struct { - PyObject_HEAD - void *cobject; - void *desc; - void (*destructor)(void *); -} PyCObject; - - -#ifdef __cplusplus -} -#endif -#endif /* !Py_COBJECT_H */ diff --git a/python/include/code.h b/python/include/code.h deleted file mode 100644 index 38b29580..00000000 --- a/python/include/code.h +++ /dev/null @@ -1,107 +0,0 @@ -/* Definitions for bytecode */ - -#ifndef Py_CODE_H -#define Py_CODE_H -#ifdef __cplusplus -extern "C" { -#endif - -/* Bytecode object */ -typedef struct { - PyObject_HEAD - int co_argcount; /* #arguments, except *args */ - int co_nlocals; /* #local variables */ - int co_stacksize; /* #entries needed for evaluation stack */ - int co_flags; /* CO_..., see below */ - PyObject *co_code; /* instruction opcodes */ - PyObject *co_consts; /* list (constants used) */ - PyObject *co_names; /* list of strings (names used) */ - PyObject *co_varnames; /* tuple of strings (local variable names) */ - PyObject *co_freevars; /* tuple of strings (free variable names) */ - PyObject *co_cellvars; /* tuple of strings (cell variable names) */ - /* The rest doesn't count for hash/cmp */ - PyObject *co_filename; /* string (where it was loaded from) */ - PyObject *co_name; /* string (name, for reference) */ - int co_firstlineno; /* first source line number */ - PyObject *co_lnotab; /* string (encoding addr<->lineno mapping) See - Objects/lnotab_notes.txt for details. */ - void *co_zombieframe; /* for optimization only (see frameobject.c) */ - PyObject *co_weakreflist; /* to support weakrefs to code objects */ -} PyCodeObject; - -/* Masks for co_flags above */ -#define CO_OPTIMIZED 0x0001 -#define CO_NEWLOCALS 0x0002 -#define CO_VARARGS 0x0004 -#define CO_VARKEYWORDS 0x0008 -#define CO_NESTED 0x0010 -#define CO_GENERATOR 0x0020 -/* The CO_NOFREE flag is set if there are no free or cell variables. - This information is redundant, but it allows a single flag test - to determine whether there is any extra work to be done when the - call frame it setup. -*/ -#define CO_NOFREE 0x0040 - -#if 0 -/* This is no longer used. Stopped defining in 2.5, do not re-use. */ -#define CO_GENERATOR_ALLOWED 0x1000 -#endif -#define CO_FUTURE_DIVISION 0x2000 -#define CO_FUTURE_ABSOLUTE_IMPORT 0x4000 /* do absolute imports by default */ -#define CO_FUTURE_WITH_STATEMENT 0x8000 -#define CO_FUTURE_PRINT_FUNCTION 0x10000 -#define CO_FUTURE_UNICODE_LITERALS 0x20000 - -/* This should be defined if a future statement modifies the syntax. - For example, when a keyword is added. -*/ -#if 1 -#define PY_PARSER_REQUIRES_FUTURE_KEYWORD -#endif - -#define CO_MAXBLOCKS 20 /* Max static block nesting within a function */ - -PyAPI_DATA(PyTypeObject) PyCode_Type; - -#define PyCode_Check(op) (Py_TYPE(op) == &PyCode_Type) -#define PyCode_GetNumFree(op) (PyTuple_GET_SIZE((op)->co_freevars)) - -/* Public interface */ -PyAPI_FUNC(PyCodeObject *) PyCode_New( - int, int, int, int, PyObject *, PyObject *, PyObject *, PyObject *, - PyObject *, PyObject *, PyObject *, PyObject *, int, PyObject *); - /* same as struct above */ - -/* Creates a new empty code object with the specified source location. */ -PyAPI_FUNC(PyCodeObject *) -PyCode_NewEmpty(const char *filename, const char *funcname, int firstlineno); - -/* Return the line number associated with the specified bytecode index - in this code object. If you just need the line number of a frame, - use PyFrame_GetLineNumber() instead. */ -PyAPI_FUNC(int) PyCode_Addr2Line(PyCodeObject *, int); - -/* for internal use only */ -#define _PyCode_GETCODEPTR(co, pp) \ - ((*Py_TYPE((co)->co_code)->tp_as_buffer->bf_getreadbuffer) \ - ((co)->co_code, 0, (void **)(pp))) - -typedef struct _addr_pair { - int ap_lower; - int ap_upper; -} PyAddrPair; - -/* Update *bounds to describe the first and one-past-the-last instructions in the - same line as lasti. Return the number of that line. -*/ -PyAPI_FUNC(int) _PyCode_CheckLineNumber(PyCodeObject* co, - int lasti, PyAddrPair *bounds); - -PyAPI_FUNC(PyObject*) PyCode_Optimize(PyObject *code, PyObject* consts, - PyObject *names, PyObject *lineno_obj); - -#ifdef __cplusplus -} -#endif -#endif /* !Py_CODE_H */ diff --git a/python/include/codecs.h b/python/include/codecs.h deleted file mode 100644 index c038c6a9..00000000 --- a/python/include/codecs.h +++ /dev/null @@ -1,167 +0,0 @@ -#ifndef Py_CODECREGISTRY_H -#define Py_CODECREGISTRY_H -#ifdef __cplusplus -extern "C" { -#endif - -/* ------------------------------------------------------------------------ - - Python Codec Registry and support functions - - -Written by Marc-Andre Lemburg (mal@lemburg.com). - -Copyright (c) Corporation for National Research Initiatives. - - ------------------------------------------------------------------------ */ - -/* Register a new codec search function. - - As side effect, this tries to load the encodings package, if not - yet done, to make sure that it is always first in the list of - search functions. - - The search_function's refcount is incremented by this function. */ - -PyAPI_FUNC(int) PyCodec_Register( - PyObject *search_function - ); - -/* Codec register lookup API. - - Looks up the given encoding and returns a CodecInfo object with - function attributes which implement the different aspects of - processing the encoding. - - The encoding string is looked up converted to all lower-case - characters. This makes encodings looked up through this mechanism - effectively case-insensitive. - - If no codec is found, a KeyError is set and NULL returned. - - As side effect, this tries to load the encodings package, if not - yet done. This is part of the lazy load strategy for the encodings - package. - - */ - -PyAPI_FUNC(PyObject *) _PyCodec_Lookup( - const char *encoding - ); - -/* Generic codec based encoding API. - - object is passed through the encoder function found for the given - encoding using the error handling method defined by errors. errors - may be NULL to use the default method defined for the codec. - - Raises a LookupError in case no encoder can be found. - - */ - -PyAPI_FUNC(PyObject *) PyCodec_Encode( - PyObject *object, - const char *encoding, - const char *errors - ); - -/* Generic codec based decoding API. - - object is passed through the decoder function found for the given - encoding using the error handling method defined by errors. errors - may be NULL to use the default method defined for the codec. - - Raises a LookupError in case no encoder can be found. - - */ - -PyAPI_FUNC(PyObject *) PyCodec_Decode( - PyObject *object, - const char *encoding, - const char *errors - ); - -/* --- Codec Lookup APIs -------------------------------------------------- - - All APIs return a codec object with incremented refcount and are - based on _PyCodec_Lookup(). The same comments w/r to the encoding - name also apply to these APIs. - -*/ - -/* Get an encoder function for the given encoding. */ - -PyAPI_FUNC(PyObject *) PyCodec_Encoder( - const char *encoding - ); - -/* Get a decoder function for the given encoding. */ - -PyAPI_FUNC(PyObject *) PyCodec_Decoder( - const char *encoding - ); - -/* Get a IncrementalEncoder object for the given encoding. */ - -PyAPI_FUNC(PyObject *) PyCodec_IncrementalEncoder( - const char *encoding, - const char *errors - ); - -/* Get a IncrementalDecoder object function for the given encoding. */ - -PyAPI_FUNC(PyObject *) PyCodec_IncrementalDecoder( - const char *encoding, - const char *errors - ); - -/* Get a StreamReader factory function for the given encoding. */ - -PyAPI_FUNC(PyObject *) PyCodec_StreamReader( - const char *encoding, - PyObject *stream, - const char *errors - ); - -/* Get a StreamWriter factory function for the given encoding. */ - -PyAPI_FUNC(PyObject *) PyCodec_StreamWriter( - const char *encoding, - PyObject *stream, - const char *errors - ); - -/* Unicode encoding error handling callback registry API */ - -/* Register the error handling callback function error under the given - name. This function will be called by the codec when it encounters - unencodable characters/undecodable bytes and doesn't know the - callback name, when name is specified as the error parameter - in the call to the encode/decode function. - Return 0 on success, -1 on error */ -PyAPI_FUNC(int) PyCodec_RegisterError(const char *name, PyObject *error); - -/* Lookup the error handling callback function registered under the given - name. As a special case NULL can be passed, in which case - the error handling callback for "strict" will be returned. */ -PyAPI_FUNC(PyObject *) PyCodec_LookupError(const char *name); - -/* raise exc as an exception */ -PyAPI_FUNC(PyObject *) PyCodec_StrictErrors(PyObject *exc); - -/* ignore the unicode error, skipping the faulty input */ -PyAPI_FUNC(PyObject *) PyCodec_IgnoreErrors(PyObject *exc); - -/* replace the unicode encode error with ? or U+FFFD */ -PyAPI_FUNC(PyObject *) PyCodec_ReplaceErrors(PyObject *exc); - -/* replace the unicode encode error with XML character references */ -PyAPI_FUNC(PyObject *) PyCodec_XMLCharRefReplaceErrors(PyObject *exc); - -/* replace the unicode encode error with backslash escapes (\x, \u and \U) */ -PyAPI_FUNC(PyObject *) PyCodec_BackslashReplaceErrors(PyObject *exc); - -#ifdef __cplusplus -} -#endif -#endif /* !Py_CODECREGISTRY_H */ diff --git a/python/include/compile.h b/python/include/compile.h deleted file mode 100644 index 61001016..00000000 --- a/python/include/compile.h +++ /dev/null @@ -1,40 +0,0 @@ - -#ifndef Py_COMPILE_H -#define Py_COMPILE_H - -#include "code.h" - -#ifdef __cplusplus -extern "C" { -#endif - -/* Public interface */ -struct _node; /* Declare the existence of this type */ -PyAPI_FUNC(PyCodeObject *) PyNode_Compile(struct _node *, const char *); - -/* Future feature support */ - -typedef struct { - int ff_features; /* flags set by future statements */ - int ff_lineno; /* line number of last future statement */ -} PyFutureFeatures; - -#define FUTURE_NESTED_SCOPES "nested_scopes" -#define FUTURE_GENERATORS "generators" -#define FUTURE_DIVISION "division" -#define FUTURE_ABSOLUTE_IMPORT "absolute_import" -#define FUTURE_WITH_STATEMENT "with_statement" -#define FUTURE_PRINT_FUNCTION "print_function" -#define FUTURE_UNICODE_LITERALS "unicode_literals" - - -struct _mod; /* Declare the existence of this type */ -PyAPI_FUNC(PyCodeObject *) PyAST_Compile(struct _mod *, const char *, - PyCompilerFlags *, PyArena *); -PyAPI_FUNC(PyFutureFeatures *) PyFuture_FromAST(struct _mod *, const char *); - - -#ifdef __cplusplus -} -#endif -#endif /* !Py_COMPILE_H */ diff --git a/python/include/complexobject.h b/python/include/complexobject.h deleted file mode 100644 index c9a9500f..00000000 --- a/python/include/complexobject.h +++ /dev/null @@ -1,66 +0,0 @@ -/* Complex number structure */ - -#ifndef Py_COMPLEXOBJECT_H -#define Py_COMPLEXOBJECT_H -#ifdef __cplusplus -extern "C" { -#endif - -typedef struct { - double real; - double imag; -} Py_complex; - -/* Operations on complex numbers from complexmodule.c */ - -#define c_sum _Py_c_sum -#define c_diff _Py_c_diff -#define c_neg _Py_c_neg -#define c_prod _Py_c_prod -#define c_quot _Py_c_quot -#define c_pow _Py_c_pow -#define c_abs _Py_c_abs - -PyAPI_FUNC(Py_complex) c_sum(Py_complex, Py_complex); -PyAPI_FUNC(Py_complex) c_diff(Py_complex, Py_complex); -PyAPI_FUNC(Py_complex) c_neg(Py_complex); -PyAPI_FUNC(Py_complex) c_prod(Py_complex, Py_complex); -PyAPI_FUNC(Py_complex) c_quot(Py_complex, Py_complex); -PyAPI_FUNC(Py_complex) c_pow(Py_complex, Py_complex); -PyAPI_FUNC(double) c_abs(Py_complex); - - -/* Complex object interface */ - -/* -PyComplexObject represents a complex number with double-precision -real and imaginary parts. -*/ - -typedef struct { - PyObject_HEAD - Py_complex cval; -} PyComplexObject; - -PyAPI_DATA(PyTypeObject) PyComplex_Type; - -#define PyComplex_Check(op) PyObject_TypeCheck(op, &PyComplex_Type) -#define PyComplex_CheckExact(op) (Py_TYPE(op) == &PyComplex_Type) - -PyAPI_FUNC(PyObject *) PyComplex_FromCComplex(Py_complex); -PyAPI_FUNC(PyObject *) PyComplex_FromDoubles(double real, double imag); - -PyAPI_FUNC(double) PyComplex_RealAsDouble(PyObject *op); -PyAPI_FUNC(double) PyComplex_ImagAsDouble(PyObject *op); -PyAPI_FUNC(Py_complex) PyComplex_AsCComplex(PyObject *op); - -/* Format the object based on the format_spec, as defined in PEP 3101 - (Advanced String Formatting). */ -PyAPI_FUNC(PyObject *) _PyComplex_FormatAdvanced(PyObject *obj, - char *format_spec, - Py_ssize_t format_spec_len); - -#ifdef __cplusplus -} -#endif -#endif /* !Py_COMPLEXOBJECT_H */ diff --git a/python/include/datetime.h b/python/include/datetime.h deleted file mode 100644 index 47abe5cb..00000000 --- a/python/include/datetime.h +++ /dev/null @@ -1,239 +0,0 @@ -/* datetime.h - */ - -#ifndef DATETIME_H -#define DATETIME_H -#ifdef __cplusplus -extern "C" { -#endif - -/* Fields are packed into successive bytes, each viewed as unsigned and - * big-endian, unless otherwise noted: - * - * byte offset - * 0 year 2 bytes, 1-9999 - * 2 month 1 byte, 1-12 - * 3 day 1 byte, 1-31 - * 4 hour 1 byte, 0-23 - * 5 minute 1 byte, 0-59 - * 6 second 1 byte, 0-59 - * 7 usecond 3 bytes, 0-999999 - * 10 - */ - -/* # of bytes for year, month, and day. */ -#define _PyDateTime_DATE_DATASIZE 4 - -/* # of bytes for hour, minute, second, and usecond. */ -#define _PyDateTime_TIME_DATASIZE 6 - -/* # of bytes for year, month, day, hour, minute, second, and usecond. */ -#define _PyDateTime_DATETIME_DATASIZE 10 - - -typedef struct -{ - PyObject_HEAD - long hashcode; /* -1 when unknown */ - int days; /* -MAX_DELTA_DAYS <= days <= MAX_DELTA_DAYS */ - int seconds; /* 0 <= seconds < 24*3600 is invariant */ - int microseconds; /* 0 <= microseconds < 1000000 is invariant */ -} PyDateTime_Delta; - -typedef struct -{ - PyObject_HEAD /* a pure abstract base clase */ -} PyDateTime_TZInfo; - - -/* The datetime and time types have hashcodes, and an optional tzinfo member, - * present if and only if hastzinfo is true. - */ -#define _PyTZINFO_HEAD \ - PyObject_HEAD \ - long hashcode; \ - char hastzinfo; /* boolean flag */ - -/* No _PyDateTime_BaseTZInfo is allocated; it's just to have something - * convenient to cast to, when getting at the hastzinfo member of objects - * starting with _PyTZINFO_HEAD. - */ -typedef struct -{ - _PyTZINFO_HEAD -} _PyDateTime_BaseTZInfo; - -/* All time objects are of PyDateTime_TimeType, but that can be allocated - * in two ways, with or without a tzinfo member. Without is the same as - * tzinfo == None, but consumes less memory. _PyDateTime_BaseTime is an - * internal struct used to allocate the right amount of space for the - * "without" case. - */ -#define _PyDateTime_TIMEHEAD \ - _PyTZINFO_HEAD \ - unsigned char data[_PyDateTime_TIME_DATASIZE]; - -typedef struct -{ - _PyDateTime_TIMEHEAD -} _PyDateTime_BaseTime; /* hastzinfo false */ - -typedef struct -{ - _PyDateTime_TIMEHEAD - PyObject *tzinfo; -} PyDateTime_Time; /* hastzinfo true */ - - -/* All datetime objects are of PyDateTime_DateTimeType, but that can be - * allocated in two ways too, just like for time objects above. In addition, - * the plain date type is a base class for datetime, so it must also have - * a hastzinfo member (although it's unused there). - */ -typedef struct -{ - _PyTZINFO_HEAD - unsigned char data[_PyDateTime_DATE_DATASIZE]; -} PyDateTime_Date; - -#define _PyDateTime_DATETIMEHEAD \ - _PyTZINFO_HEAD \ - unsigned char data[_PyDateTime_DATETIME_DATASIZE]; - -typedef struct -{ - _PyDateTime_DATETIMEHEAD -} _PyDateTime_BaseDateTime; /* hastzinfo false */ - -typedef struct -{ - _PyDateTime_DATETIMEHEAD - PyObject *tzinfo; -} PyDateTime_DateTime; /* hastzinfo true */ - - -/* Apply for date and datetime instances. */ -#define PyDateTime_GET_YEAR(o) ((((PyDateTime_Date*)o)->data[0] << 8) | \ - ((PyDateTime_Date*)o)->data[1]) -#define PyDateTime_GET_MONTH(o) (((PyDateTime_Date*)o)->data[2]) -#define PyDateTime_GET_DAY(o) (((PyDateTime_Date*)o)->data[3]) - -#define PyDateTime_DATE_GET_HOUR(o) (((PyDateTime_DateTime*)o)->data[4]) -#define PyDateTime_DATE_GET_MINUTE(o) (((PyDateTime_DateTime*)o)->data[5]) -#define PyDateTime_DATE_GET_SECOND(o) (((PyDateTime_DateTime*)o)->data[6]) -#define PyDateTime_DATE_GET_MICROSECOND(o) \ - ((((PyDateTime_DateTime*)o)->data[7] << 16) | \ - (((PyDateTime_DateTime*)o)->data[8] << 8) | \ - ((PyDateTime_DateTime*)o)->data[9]) - -/* Apply for time instances. */ -#define PyDateTime_TIME_GET_HOUR(o) (((PyDateTime_Time*)o)->data[0]) -#define PyDateTime_TIME_GET_MINUTE(o) (((PyDateTime_Time*)o)->data[1]) -#define PyDateTime_TIME_GET_SECOND(o) (((PyDateTime_Time*)o)->data[2]) -#define PyDateTime_TIME_GET_MICROSECOND(o) \ - ((((PyDateTime_Time*)o)->data[3] << 16) | \ - (((PyDateTime_Time*)o)->data[4] << 8) | \ - ((PyDateTime_Time*)o)->data[5]) - - -/* Define structure for C API. */ -typedef struct { - /* type objects */ - PyTypeObject *DateType; - PyTypeObject *DateTimeType; - PyTypeObject *TimeType; - PyTypeObject *DeltaType; - PyTypeObject *TZInfoType; - - /* constructors */ - PyObject *(*Date_FromDate)(int, int, int, PyTypeObject*); - PyObject *(*DateTime_FromDateAndTime)(int, int, int, int, int, int, int, - PyObject*, PyTypeObject*); - PyObject *(*Time_FromTime)(int, int, int, int, PyObject*, PyTypeObject*); - PyObject *(*Delta_FromDelta)(int, int, int, int, PyTypeObject*); - - /* constructors for the DB API */ - PyObject *(*DateTime_FromTimestamp)(PyObject*, PyObject*, PyObject*); - PyObject *(*Date_FromTimestamp)(PyObject*, PyObject*); - -} PyDateTime_CAPI; - -#define PyDateTime_CAPSULE_NAME "datetime.datetime_CAPI" - - -/* "magic" constant used to partially protect against developer mistakes. */ -#define DATETIME_API_MAGIC 0x414548d5 - -#ifdef Py_BUILD_CORE - -/* Macros for type checking when building the Python core. */ -#define PyDate_Check(op) PyObject_TypeCheck(op, &PyDateTime_DateType) -#define PyDate_CheckExact(op) (Py_TYPE(op) == &PyDateTime_DateType) - -#define PyDateTime_Check(op) PyObject_TypeCheck(op, &PyDateTime_DateTimeType) -#define PyDateTime_CheckExact(op) (Py_TYPE(op) == &PyDateTime_DateTimeType) - -#define PyTime_Check(op) PyObject_TypeCheck(op, &PyDateTime_TimeType) -#define PyTime_CheckExact(op) (Py_TYPE(op) == &PyDateTime_TimeType) - -#define PyDelta_Check(op) PyObject_TypeCheck(op, &PyDateTime_DeltaType) -#define PyDelta_CheckExact(op) (Py_TYPE(op) == &PyDateTime_DeltaType) - -#define PyTZInfo_Check(op) PyObject_TypeCheck(op, &PyDateTime_TZInfoType) -#define PyTZInfo_CheckExact(op) (Py_TYPE(op) == &PyDateTime_TZInfoType) - -#else - -/* Define global variable for the C API and a macro for setting it. */ -static PyDateTime_CAPI *PyDateTimeAPI = NULL; - -#define PyDateTime_IMPORT \ - PyDateTimeAPI = (PyDateTime_CAPI *)PyCapsule_Import(PyDateTime_CAPSULE_NAME, 0) - -/* Macros for type checking when not building the Python core. */ -#define PyDate_Check(op) PyObject_TypeCheck(op, PyDateTimeAPI->DateType) -#define PyDate_CheckExact(op) (Py_TYPE(op) == PyDateTimeAPI->DateType) - -#define PyDateTime_Check(op) PyObject_TypeCheck(op, PyDateTimeAPI->DateTimeType) -#define PyDateTime_CheckExact(op) (Py_TYPE(op) == PyDateTimeAPI->DateTimeType) - -#define PyTime_Check(op) PyObject_TypeCheck(op, PyDateTimeAPI->TimeType) -#define PyTime_CheckExact(op) (Py_TYPE(op) == PyDateTimeAPI->TimeType) - -#define PyDelta_Check(op) PyObject_TypeCheck(op, PyDateTimeAPI->DeltaType) -#define PyDelta_CheckExact(op) (Py_TYPE(op) == PyDateTimeAPI->DeltaType) - -#define PyTZInfo_Check(op) PyObject_TypeCheck(op, PyDateTimeAPI->TZInfoType) -#define PyTZInfo_CheckExact(op) (Py_TYPE(op) == PyDateTimeAPI->TZInfoType) - -/* Macros for accessing constructors in a simplified fashion. */ -#define PyDate_FromDate(year, month, day) \ - PyDateTimeAPI->Date_FromDate(year, month, day, PyDateTimeAPI->DateType) - -#define PyDateTime_FromDateAndTime(year, month, day, hour, min, sec, usec) \ - PyDateTimeAPI->DateTime_FromDateAndTime(year, month, day, hour, \ - min, sec, usec, Py_None, PyDateTimeAPI->DateTimeType) - -#define PyTime_FromTime(hour, minute, second, usecond) \ - PyDateTimeAPI->Time_FromTime(hour, minute, second, usecond, \ - Py_None, PyDateTimeAPI->TimeType) - -#define PyDelta_FromDSU(days, seconds, useconds) \ - PyDateTimeAPI->Delta_FromDelta(days, seconds, useconds, 1, \ - PyDateTimeAPI->DeltaType) - -/* Macros supporting the DB API. */ -#define PyDateTime_FromTimestamp(args) \ - PyDateTimeAPI->DateTime_FromTimestamp( \ - (PyObject*) (PyDateTimeAPI->DateTimeType), args, NULL) - -#define PyDate_FromTimestamp(args) \ - PyDateTimeAPI->Date_FromTimestamp( \ - (PyObject*) (PyDateTimeAPI->DateType), args) - -#endif /* Py_BUILD_CORE */ - -#ifdef __cplusplus -} -#endif -#endif diff --git a/python/include/descrobject.h b/python/include/descrobject.h deleted file mode 100644 index b542732b..00000000 --- a/python/include/descrobject.h +++ /dev/null @@ -1,94 +0,0 @@ -/* Descriptors */ -#ifndef Py_DESCROBJECT_H -#define Py_DESCROBJECT_H -#ifdef __cplusplus -extern "C" { -#endif - -typedef PyObject *(*getter)(PyObject *, void *); -typedef int (*setter)(PyObject *, PyObject *, void *); - -typedef struct PyGetSetDef { - char *name; - getter get; - setter set; - char *doc; - void *closure; -} PyGetSetDef; - -typedef PyObject *(*wrapperfunc)(PyObject *self, PyObject *args, - void *wrapped); - -typedef PyObject *(*wrapperfunc_kwds)(PyObject *self, PyObject *args, - void *wrapped, PyObject *kwds); - -struct wrapperbase { - char *name; - int offset; - void *function; - wrapperfunc wrapper; - char *doc; - int flags; - PyObject *name_strobj; -}; - -/* Flags for above struct */ -#define PyWrapperFlag_KEYWORDS 1 /* wrapper function takes keyword args */ - -/* Various kinds of descriptor objects */ - -#define PyDescr_COMMON \ - PyObject_HEAD \ - PyTypeObject *d_type; \ - PyObject *d_name - -typedef struct { - PyDescr_COMMON; -} PyDescrObject; - -typedef struct { - PyDescr_COMMON; - PyMethodDef *d_method; -} PyMethodDescrObject; - -typedef struct { - PyDescr_COMMON; - struct PyMemberDef *d_member; -} PyMemberDescrObject; - -typedef struct { - PyDescr_COMMON; - PyGetSetDef *d_getset; -} PyGetSetDescrObject; - -typedef struct { - PyDescr_COMMON; - struct wrapperbase *d_base; - void *d_wrapped; /* This can be any function pointer */ -} PyWrapperDescrObject; - -PyAPI_DATA(PyTypeObject) PyWrapperDescr_Type; -PyAPI_DATA(PyTypeObject) PyDictProxy_Type; -PyAPI_DATA(PyTypeObject) PyGetSetDescr_Type; -PyAPI_DATA(PyTypeObject) PyMemberDescr_Type; - -PyAPI_FUNC(PyObject *) PyDescr_NewMethod(PyTypeObject *, PyMethodDef *); -PyAPI_FUNC(PyObject *) PyDescr_NewClassMethod(PyTypeObject *, PyMethodDef *); -PyAPI_FUNC(PyObject *) PyDescr_NewMember(PyTypeObject *, - struct PyMemberDef *); -PyAPI_FUNC(PyObject *) PyDescr_NewGetSet(PyTypeObject *, - struct PyGetSetDef *); -PyAPI_FUNC(PyObject *) PyDescr_NewWrapper(PyTypeObject *, - struct wrapperbase *, void *); -#define PyDescr_IsData(d) (Py_TYPE(d)->tp_descr_set != NULL) - -PyAPI_FUNC(PyObject *) PyDictProxy_New(PyObject *); -PyAPI_FUNC(PyObject *) PyWrapper_New(PyObject *, PyObject *); - - -PyAPI_DATA(PyTypeObject) PyProperty_Type; -#ifdef __cplusplus -} -#endif -#endif /* !Py_DESCROBJECT_H */ - diff --git a/python/include/dictobject.h b/python/include/dictobject.h deleted file mode 100644 index ece01c64..00000000 --- a/python/include/dictobject.h +++ /dev/null @@ -1,156 +0,0 @@ -#ifndef Py_DICTOBJECT_H -#define Py_DICTOBJECT_H -#ifdef __cplusplus -extern "C" { -#endif - - -/* Dictionary object type -- mapping from hashable object to object */ - -/* The distribution includes a separate file, Objects/dictnotes.txt, - describing explorations into dictionary design and optimization. - It covers typical dictionary use patterns, the parameters for - tuning dictionaries, and several ideas for possible optimizations. -*/ - -/* -There are three kinds of slots in the table: - -1. Unused. me_key == me_value == NULL - Does not hold an active (key, value) pair now and never did. Unused can - transition to Active upon key insertion. This is the only case in which - me_key is NULL, and is each slot's initial state. - -2. Active. me_key != NULL and me_key != dummy and me_value != NULL - Holds an active (key, value) pair. Active can transition to Dummy upon - key deletion. This is the only case in which me_value != NULL. - -3. Dummy. me_key == dummy and me_value == NULL - Previously held an active (key, value) pair, but that was deleted and an - active pair has not yet overwritten the slot. Dummy can transition to - Active upon key insertion. Dummy slots cannot be made Unused again - (cannot have me_key set to NULL), else the probe sequence in case of - collision would have no way to know they were once active. - -Note: .popitem() abuses the me_hash field of an Unused or Dummy slot to -hold a search finger. The me_hash field of Unused or Dummy slots has no -meaning otherwise. -*/ - -/* PyDict_MINSIZE is the minimum size of a dictionary. This many slots are - * allocated directly in the dict object (in the ma_smalltable member). - * It must be a power of 2, and at least 4. 8 allows dicts with no more - * than 5 active entries to live in ma_smalltable (and so avoid an - * additional malloc); instrumentation suggested this suffices for the - * majority of dicts (consisting mostly of usually-small instance dicts and - * usually-small dicts created to pass keyword arguments). - */ -#define PyDict_MINSIZE 8 - -typedef struct { - /* Cached hash code of me_key. Note that hash codes are C longs. - * We have to use Py_ssize_t instead because dict_popitem() abuses - * me_hash to hold a search finger. - */ - Py_ssize_t me_hash; - PyObject *me_key; - PyObject *me_value; -} PyDictEntry; - -/* -To ensure the lookup algorithm terminates, there must be at least one Unused -slot (NULL key) in the table. -The value ma_fill is the number of non-NULL keys (sum of Active and Dummy); -ma_used is the number of non-NULL, non-dummy keys (== the number of non-NULL -values == the number of Active items). -To avoid slowing down lookups on a near-full table, we resize the table when -it's two-thirds full. -*/ -typedef struct _dictobject PyDictObject; -struct _dictobject { - PyObject_HEAD - Py_ssize_t ma_fill; /* # Active + # Dummy */ - Py_ssize_t ma_used; /* # Active */ - - /* The table contains ma_mask + 1 slots, and that's a power of 2. - * We store the mask instead of the size because the mask is more - * frequently needed. - */ - Py_ssize_t ma_mask; - - /* ma_table points to ma_smalltable for small tables, else to - * additional malloc'ed memory. ma_table is never NULL! This rule - * saves repeated runtime null-tests in the workhorse getitem and - * setitem calls. - */ - PyDictEntry *ma_table; - PyDictEntry *(*ma_lookup)(PyDictObject *mp, PyObject *key, long hash); - PyDictEntry ma_smalltable[PyDict_MINSIZE]; -}; - -PyAPI_DATA(PyTypeObject) PyDict_Type; -PyAPI_DATA(PyTypeObject) PyDictIterKey_Type; -PyAPI_DATA(PyTypeObject) PyDictIterValue_Type; -PyAPI_DATA(PyTypeObject) PyDictIterItem_Type; -PyAPI_DATA(PyTypeObject) PyDictKeys_Type; -PyAPI_DATA(PyTypeObject) PyDictItems_Type; -PyAPI_DATA(PyTypeObject) PyDictValues_Type; - -#define PyDict_Check(op) \ - PyType_FastSubclass(Py_TYPE(op), Py_TPFLAGS_DICT_SUBCLASS) -#define PyDict_CheckExact(op) (Py_TYPE(op) == &PyDict_Type) -#define PyDictKeys_Check(op) (Py_TYPE(op) == &PyDictKeys_Type) -#define PyDictItems_Check(op) (Py_TYPE(op) == &PyDictItems_Type) -#define PyDictValues_Check(op) (Py_TYPE(op) == &PyDictValues_Type) -/* This excludes Values, since they are not sets. */ -# define PyDictViewSet_Check(op) \ - (PyDictKeys_Check(op) || PyDictItems_Check(op)) - -PyAPI_FUNC(PyObject *) PyDict_New(void); -PyAPI_FUNC(PyObject *) PyDict_GetItem(PyObject *mp, PyObject *key); -PyAPI_FUNC(int) PyDict_SetItem(PyObject *mp, PyObject *key, PyObject *item); -PyAPI_FUNC(int) PyDict_DelItem(PyObject *mp, PyObject *key); -PyAPI_FUNC(void) PyDict_Clear(PyObject *mp); -PyAPI_FUNC(int) PyDict_Next( - PyObject *mp, Py_ssize_t *pos, PyObject **key, PyObject **value); -PyAPI_FUNC(int) _PyDict_Next( - PyObject *mp, Py_ssize_t *pos, PyObject **key, PyObject **value, long *hash); -PyAPI_FUNC(PyObject *) PyDict_Keys(PyObject *mp); -PyAPI_FUNC(PyObject *) PyDict_Values(PyObject *mp); -PyAPI_FUNC(PyObject *) PyDict_Items(PyObject *mp); -PyAPI_FUNC(Py_ssize_t) PyDict_Size(PyObject *mp); -PyAPI_FUNC(PyObject *) PyDict_Copy(PyObject *mp); -PyAPI_FUNC(int) PyDict_Contains(PyObject *mp, PyObject *key); -PyAPI_FUNC(int) _PyDict_Contains(PyObject *mp, PyObject *key, long hash); -PyAPI_FUNC(PyObject *) _PyDict_NewPresized(Py_ssize_t minused); -PyAPI_FUNC(void) _PyDict_MaybeUntrack(PyObject *mp); - -/* PyDict_Update(mp, other) is equivalent to PyDict_Merge(mp, other, 1). */ -PyAPI_FUNC(int) PyDict_Update(PyObject *mp, PyObject *other); - -/* PyDict_Merge updates/merges from a mapping object (an object that - supports PyMapping_Keys() and PyObject_GetItem()). If override is true, - the last occurrence of a key wins, else the first. The Python - dict.update(other) is equivalent to PyDict_Merge(dict, other, 1). -*/ -PyAPI_FUNC(int) PyDict_Merge(PyObject *mp, - PyObject *other, - int override); - -/* PyDict_MergeFromSeq2 updates/merges from an iterable object producing - iterable objects of length 2. If override is true, the last occurrence - of a key wins, else the first. The Python dict constructor dict(seq2) - is equivalent to dict={}; PyDict_MergeFromSeq(dict, seq2, 1). -*/ -PyAPI_FUNC(int) PyDict_MergeFromSeq2(PyObject *d, - PyObject *seq2, - int override); - -PyAPI_FUNC(PyObject *) PyDict_GetItemString(PyObject *dp, const char *key); -PyAPI_FUNC(int) PyDict_SetItemString(PyObject *dp, const char *key, PyObject *item); -PyAPI_FUNC(int) PyDict_DelItemString(PyObject *dp, const char *key); - -#ifdef __cplusplus -} -#endif -#endif /* !Py_DICTOBJECT_H */ diff --git a/python/include/dtoa.h b/python/include/dtoa.h deleted file mode 100644 index 9b434b77..00000000 --- a/python/include/dtoa.h +++ /dev/null @@ -1,15 +0,0 @@ -#ifndef PY_NO_SHORT_FLOAT_REPR -#ifdef __cplusplus -extern "C" { -#endif - -PyAPI_FUNC(double) _Py_dg_strtod(const char *str, char **ptr); -PyAPI_FUNC(char *) _Py_dg_dtoa(double d, int mode, int ndigits, - int *decpt, int *sign, char **rve); -PyAPI_FUNC(void) _Py_dg_freedtoa(char *s); - - -#ifdef __cplusplus -} -#endif -#endif diff --git a/python/include/enumobject.h b/python/include/enumobject.h deleted file mode 100644 index c14dbfc8..00000000 --- a/python/include/enumobject.h +++ /dev/null @@ -1,17 +0,0 @@ -#ifndef Py_ENUMOBJECT_H -#define Py_ENUMOBJECT_H - -/* Enumerate Object */ - -#ifdef __cplusplus -extern "C" { -#endif - -PyAPI_DATA(PyTypeObject) PyEnum_Type; -PyAPI_DATA(PyTypeObject) PyReversed_Type; - -#ifdef __cplusplus -} -#endif - -#endif /* !Py_ENUMOBJECT_H */ diff --git a/python/include/errcode.h b/python/include/errcode.h deleted file mode 100644 index becec80c..00000000 --- a/python/include/errcode.h +++ /dev/null @@ -1,36 +0,0 @@ -#ifndef Py_ERRCODE_H -#define Py_ERRCODE_H -#ifdef __cplusplus -extern "C" { -#endif - - -/* Error codes passed around between file input, tokenizer, parser and - interpreter. This is necessary so we can turn them into Python - exceptions at a higher level. Note that some errors have a - slightly different meaning when passed from the tokenizer to the - parser than when passed from the parser to the interpreter; e.g. - the parser only returns E_EOF when it hits EOF immediately, and it - never returns E_OK. */ - -#define E_OK 10 /* No error */ -#define E_EOF 11 /* End Of File */ -#define E_INTR 12 /* Interrupted */ -#define E_TOKEN 13 /* Bad token */ -#define E_SYNTAX 14 /* Syntax error */ -#define E_NOMEM 15 /* Ran out of memory */ -#define E_DONE 16 /* Parsing complete */ -#define E_ERROR 17 /* Execution error */ -#define E_TABSPACE 18 /* Inconsistent mixing of tabs and spaces */ -#define E_OVERFLOW 19 /* Node had too many children */ -#define E_TOODEEP 20 /* Too many indentation levels */ -#define E_DEDENT 21 /* No matching outer block for dedent */ -#define E_DECODE 22 /* Error in decoding into Unicode */ -#define E_EOFS 23 /* EOF in triple-quoted string */ -#define E_EOLS 24 /* EOL in single-quoted string */ -#define E_LINECONT 25 /* Unexpected characters after a line continuation */ - -#ifdef __cplusplus -} -#endif -#endif /* !Py_ERRCODE_H */ diff --git a/python/include/eval.h b/python/include/eval.h deleted file mode 100644 index b78dfe0f..00000000 --- a/python/include/eval.h +++ /dev/null @@ -1,25 +0,0 @@ - -/* Interface to execute compiled code */ - -#ifndef Py_EVAL_H -#define Py_EVAL_H -#ifdef __cplusplus -extern "C" { -#endif - -PyAPI_FUNC(PyObject *) PyEval_EvalCode(PyCodeObject *, PyObject *, PyObject *); - -PyAPI_FUNC(PyObject *) PyEval_EvalCodeEx(PyCodeObject *co, - PyObject *globals, - PyObject *locals, - PyObject **args, int argc, - PyObject **kwds, int kwdc, - PyObject **defs, int defc, - PyObject *closure); - -PyAPI_FUNC(PyObject *) _PyEval_CallTracing(PyObject *func, PyObject *args); - -#ifdef __cplusplus -} -#endif -#endif /* !Py_EVAL_H */ diff --git a/python/include/fileobject.h b/python/include/fileobject.h deleted file mode 100644 index 1b540f90..00000000 --- a/python/include/fileobject.h +++ /dev/null @@ -1,97 +0,0 @@ - -/* File object interface */ - -#ifndef Py_FILEOBJECT_H -#define Py_FILEOBJECT_H -#ifdef __cplusplus -extern "C" { -#endif - -typedef struct { - PyObject_HEAD - FILE *f_fp; - PyObject *f_name; - PyObject *f_mode; - int (*f_close)(FILE *); - int f_softspace; /* Flag used by 'print' command */ - int f_binary; /* Flag which indicates whether the file is - open in binary (1) or text (0) mode */ - char* f_buf; /* Allocated readahead buffer */ - char* f_bufend; /* Points after last occupied position */ - char* f_bufptr; /* Current buffer position */ - char *f_setbuf; /* Buffer for setbuf(3) and setvbuf(3) */ - int f_univ_newline; /* Handle any newline convention */ - int f_newlinetypes; /* Types of newlines seen */ - int f_skipnextlf; /* Skip next \n */ - PyObject *f_encoding; - PyObject *f_errors; - PyObject *weakreflist; /* List of weak references */ - int unlocked_count; /* Num. currently running sections of code - using f_fp with the GIL released. */ - int readable; - int writable; -} PyFileObject; - -PyAPI_DATA(PyTypeObject) PyFile_Type; - -#define PyFile_Check(op) PyObject_TypeCheck(op, &PyFile_Type) -#define PyFile_CheckExact(op) (Py_TYPE(op) == &PyFile_Type) - -PyAPI_FUNC(PyObject *) PyFile_FromString(char *, char *); -PyAPI_FUNC(void) PyFile_SetBufSize(PyObject *, int); -PyAPI_FUNC(int) PyFile_SetEncoding(PyObject *, const char *); -PyAPI_FUNC(int) PyFile_SetEncodingAndErrors(PyObject *, const char *, char *errors); -PyAPI_FUNC(PyObject *) PyFile_FromFile(FILE *, char *, char *, - int (*)(FILE *)); -PyAPI_FUNC(FILE *) PyFile_AsFile(PyObject *); -PyAPI_FUNC(void) PyFile_IncUseCount(PyFileObject *); -PyAPI_FUNC(void) PyFile_DecUseCount(PyFileObject *); -PyAPI_FUNC(PyObject *) PyFile_Name(PyObject *); -PyAPI_FUNC(PyObject *) PyFile_GetLine(PyObject *, int); -PyAPI_FUNC(int) PyFile_WriteObject(PyObject *, PyObject *, int); -PyAPI_FUNC(int) PyFile_SoftSpace(PyObject *, int); -PyAPI_FUNC(int) PyFile_WriteString(const char *, PyObject *); -PyAPI_FUNC(int) PyObject_AsFileDescriptor(PyObject *); - -/* The default encoding used by the platform file system APIs - If non-NULL, this is different than the default encoding for strings -*/ -PyAPI_DATA(const char *) Py_FileSystemDefaultEncoding; - -/* Routines to replace fread() and fgets() which accept any of \r, \n - or \r\n as line terminators. -*/ -#define PY_STDIOTEXTMODE "b" -char *Py_UniversalNewlineFgets(char *, int, FILE*, PyObject *); -size_t Py_UniversalNewlineFread(char *, size_t, FILE *, PyObject *); - -/* A routine to do sanity checking on the file mode string. returns - non-zero on if an exception occurred -*/ -int _PyFile_SanitizeMode(char *mode); - -#if defined _MSC_VER && _MSC_VER >= 1400 -/* A routine to check if a file descriptor is valid on Windows. Returns 0 - * and sets errno to EBADF if it isn't. This is to avoid Assertions - * from various functions in the Windows CRT beginning with - * Visual Studio 2005 - */ -int _PyVerify_fd(int fd); -#elif defined _MSC_VER && _MSC_VER >= 1200 -/* fdopen doesn't set errno EBADF and crashes for large fd on debug build */ -#define _PyVerify_fd(fd) (_get_osfhandle(fd) >= 0) -#else -#define _PyVerify_fd(A) (1) /* dummy */ -#endif - -/* A routine to check if a file descriptor can be select()-ed. */ -#ifdef HAVE_SELECT - #define _PyIsSelectable_fd(FD) (((FD) >= 0) && ((FD) < FD_SETSIZE)) -#else - #define _PyIsSelectable_fd(FD) (1) -#endif /* HAVE_SELECT */ - -#ifdef __cplusplus -} -#endif -#endif /* !Py_FILEOBJECT_H */ diff --git a/python/include/floatobject.h b/python/include/floatobject.h deleted file mode 100644 index 54e88256..00000000 --- a/python/include/floatobject.h +++ /dev/null @@ -1,140 +0,0 @@ - -/* Float object interface */ - -/* -PyFloatObject represents a (double precision) floating point number. -*/ - -#ifndef Py_FLOATOBJECT_H -#define Py_FLOATOBJECT_H -#ifdef __cplusplus -extern "C" { -#endif - -typedef struct { - PyObject_HEAD - double ob_fval; -} PyFloatObject; - -PyAPI_DATA(PyTypeObject) PyFloat_Type; - -#define PyFloat_Check(op) PyObject_TypeCheck(op, &PyFloat_Type) -#define PyFloat_CheckExact(op) (Py_TYPE(op) == &PyFloat_Type) - -/* The str() precision PyFloat_STR_PRECISION is chosen so that in most cases, - the rounding noise created by various operations is suppressed, while - giving plenty of precision for practical use. */ - -#define PyFloat_STR_PRECISION 12 - -#ifdef Py_NAN -#define Py_RETURN_NAN return PyFloat_FromDouble(Py_NAN) -#endif - -#define Py_RETURN_INF(sign) do \ - if (copysign(1., sign) == 1.) { \ - return PyFloat_FromDouble(Py_HUGE_VAL); \ - } else { \ - return PyFloat_FromDouble(-Py_HUGE_VAL); \ - } while(0) - -PyAPI_FUNC(double) PyFloat_GetMax(void); -PyAPI_FUNC(double) PyFloat_GetMin(void); -PyAPI_FUNC(PyObject *) PyFloat_GetInfo(void); - -/* Return Python float from string PyObject. Second argument ignored on - input, and, if non-NULL, NULL is stored into *junk (this tried to serve a - purpose once but can't be made to work as intended). */ -PyAPI_FUNC(PyObject *) PyFloat_FromString(PyObject*, char** junk); - -/* Return Python float from C double. */ -PyAPI_FUNC(PyObject *) PyFloat_FromDouble(double); - -/* Extract C double from Python float. The macro version trades safety for - speed. */ -PyAPI_FUNC(double) PyFloat_AsDouble(PyObject *); -#define PyFloat_AS_DOUBLE(op) (((PyFloatObject *)(op))->ob_fval) - -/* Write repr(v) into the char buffer argument, followed by null byte. The - buffer must be "big enough"; >= 100 is very safe. - PyFloat_AsReprString(buf, x) strives to print enough digits so that - PyFloat_FromString(buf) then reproduces x exactly. */ -PyAPI_FUNC(void) PyFloat_AsReprString(char*, PyFloatObject *v); - -/* Write str(v) into the char buffer argument, followed by null byte. The - buffer must be "big enough"; >= 100 is very safe. Note that it's - unusual to be able to get back the float you started with from - PyFloat_AsString's result -- use PyFloat_AsReprString() if you want to - preserve precision across conversions. */ -PyAPI_FUNC(void) PyFloat_AsString(char*, PyFloatObject *v); - -/* _PyFloat_{Pack,Unpack}{4,8} - * - * The struct and pickle (at least) modules need an efficient platform- - * independent way to store floating-point values as byte strings. - * The Pack routines produce a string from a C double, and the Unpack - * routines produce a C double from such a string. The suffix (4 or 8) - * specifies the number of bytes in the string. - * - * On platforms that appear to use (see _PyFloat_Init()) IEEE-754 formats - * these functions work by copying bits. On other platforms, the formats the - * 4- byte format is identical to the IEEE-754 single precision format, and - * the 8-byte format to the IEEE-754 double precision format, although the - * packing of INFs and NaNs (if such things exist on the platform) isn't - * handled correctly, and attempting to unpack a string containing an IEEE - * INF or NaN will raise an exception. - * - * On non-IEEE platforms with more precision, or larger dynamic range, than - * 754 supports, not all values can be packed; on non-IEEE platforms with less - * precision, or smaller dynamic range, not all values can be unpacked. What - * happens in such cases is partly accidental (alas). - */ - -/* The pack routines write 4 or 8 bytes, starting at p. le is a bool - * argument, true if you want the string in little-endian format (exponent - * last, at p+3 or p+7), false if you want big-endian format (exponent - * first, at p). - * Return value: 0 if all is OK, -1 if error (and an exception is - * set, most likely OverflowError). - * There are two problems on non-IEEE platforms: - * 1): What this does is undefined if x is a NaN or infinity. - * 2): -0.0 and +0.0 produce the same string. - */ -PyAPI_FUNC(int) _PyFloat_Pack4(double x, unsigned char *p, int le); -PyAPI_FUNC(int) _PyFloat_Pack8(double x, unsigned char *p, int le); - -/* Used to get the important decimal digits of a double */ -PyAPI_FUNC(int) _PyFloat_Digits(char *buf, double v, int *signum); -PyAPI_FUNC(void) _PyFloat_DigitsInit(void); - -/* The unpack routines read 4 or 8 bytes, starting at p. le is a bool - * argument, true if the string is in little-endian format (exponent - * last, at p+3 or p+7), false if big-endian (exponent first, at p). - * Return value: The unpacked double. On error, this is -1.0 and - * PyErr_Occurred() is true (and an exception is set, most likely - * OverflowError). Note that on a non-IEEE platform this will refuse - * to unpack a string that represents a NaN or infinity. - */ -PyAPI_FUNC(double) _PyFloat_Unpack4(const unsigned char *p, int le); -PyAPI_FUNC(double) _PyFloat_Unpack8(const unsigned char *p, int le); - -/* free list api */ -PyAPI_FUNC(int) PyFloat_ClearFreeList(void); - -/* Format the object based on the format_spec, as defined in PEP 3101 - (Advanced String Formatting). */ -PyAPI_FUNC(PyObject *) _PyFloat_FormatAdvanced(PyObject *obj, - char *format_spec, - Py_ssize_t format_spec_len); - -/* Round a C double x to the closest multiple of 10**-ndigits. Returns a - Python float on success, or NULL (with an appropriate exception set) on - failure. Used in builtin_round in bltinmodule.c. */ -PyAPI_FUNC(PyObject *) _Py_double_round(double x, int ndigits); - - - -#ifdef __cplusplus -} -#endif -#endif /* !Py_FLOATOBJECT_H */ diff --git a/python/include/frameobject.h b/python/include/frameobject.h deleted file mode 100644 index 17e7679a..00000000 --- a/python/include/frameobject.h +++ /dev/null @@ -1,89 +0,0 @@ - -/* Frame object interface */ - -#ifndef Py_FRAMEOBJECT_H -#define Py_FRAMEOBJECT_H -#ifdef __cplusplus -extern "C" { -#endif - -typedef struct { - int b_type; /* what kind of block this is */ - int b_handler; /* where to jump to find handler */ - int b_level; /* value stack level to pop to */ -} PyTryBlock; - -typedef struct _frame { - PyObject_VAR_HEAD - struct _frame *f_back; /* previous frame, or NULL */ - PyCodeObject *f_code; /* code segment */ - PyObject *f_builtins; /* builtin symbol table (PyDictObject) */ - PyObject *f_globals; /* global symbol table (PyDictObject) */ - PyObject *f_locals; /* local symbol table (any mapping) */ - PyObject **f_valuestack; /* points after the last local */ - /* Next free slot in f_valuestack. Frame creation sets to f_valuestack. - Frame evaluation usually NULLs it, but a frame that yields sets it - to the current stack top. */ - PyObject **f_stacktop; - PyObject *f_trace; /* Trace function */ - - /* If an exception is raised in this frame, the next three are used to - * record the exception info (if any) originally in the thread state. See - * comments before set_exc_info() -- it's not obvious. - * Invariant: if _type is NULL, then so are _value and _traceback. - * Desired invariant: all three are NULL, or all three are non-NULL. That - * one isn't currently true, but "should be". - */ - PyObject *f_exc_type, *f_exc_value, *f_exc_traceback; - - PyThreadState *f_tstate; - int f_lasti; /* Last instruction if called */ - /* Call PyFrame_GetLineNumber() instead of reading this field - directly. As of 2.3 f_lineno is only valid when tracing is - active (i.e. when f_trace is set). At other times we use - PyCode_Addr2Line to calculate the line from the current - bytecode index. */ - int f_lineno; /* Current line number */ - int f_iblock; /* index in f_blockstack */ - PyTryBlock f_blockstack[CO_MAXBLOCKS]; /* for try and loop blocks */ - PyObject *f_localsplus[1]; /* locals+stack, dynamically sized */ -} PyFrameObject; - - -/* Standard object interface */ - -PyAPI_DATA(PyTypeObject) PyFrame_Type; - -#define PyFrame_Check(op) ((op)->ob_type == &PyFrame_Type) -#define PyFrame_IsRestricted(f) \ - ((f)->f_builtins != (f)->f_tstate->interp->builtins) - -PyAPI_FUNC(PyFrameObject *) PyFrame_New(PyThreadState *, PyCodeObject *, - PyObject *, PyObject *); - - -/* The rest of the interface is specific for frame objects */ - -/* Block management functions */ - -PyAPI_FUNC(void) PyFrame_BlockSetup(PyFrameObject *, int, int, int); -PyAPI_FUNC(PyTryBlock *) PyFrame_BlockPop(PyFrameObject *); - -/* Extend the value stack */ - -PyAPI_FUNC(PyObject **) PyFrame_ExtendStack(PyFrameObject *, int, int); - -/* Conversions between "fast locals" and locals in dictionary */ - -PyAPI_FUNC(void) PyFrame_LocalsToFast(PyFrameObject *, int); -PyAPI_FUNC(void) PyFrame_FastToLocals(PyFrameObject *); - -PyAPI_FUNC(int) PyFrame_ClearFreeList(void); - -/* Return the line of code the frame is currently executing. */ -PyAPI_FUNC(int) PyFrame_GetLineNumber(PyFrameObject *); - -#ifdef __cplusplus -} -#endif -#endif /* !Py_FRAMEOBJECT_H */ diff --git a/python/include/funcobject.h b/python/include/funcobject.h deleted file mode 100644 index eb19f4c3..00000000 --- a/python/include/funcobject.h +++ /dev/null @@ -1,76 +0,0 @@ - -/* Function object interface */ - -#ifndef Py_FUNCOBJECT_H -#define Py_FUNCOBJECT_H -#ifdef __cplusplus -extern "C" { -#endif - -/* Function objects and code objects should not be confused with each other: - * - * Function objects are created by the execution of the 'def' statement. - * They reference a code object in their func_code attribute, which is a - * purely syntactic object, i.e. nothing more than a compiled version of some - * source code lines. There is one code object per source code "fragment", - * but each code object can be referenced by zero or many function objects - * depending only on how many times the 'def' statement in the source was - * executed so far. - */ - -typedef struct { - PyObject_HEAD - PyObject *func_code; /* A code object */ - PyObject *func_globals; /* A dictionary (other mappings won't do) */ - PyObject *func_defaults; /* NULL or a tuple */ - PyObject *func_closure; /* NULL or a tuple of cell objects */ - PyObject *func_doc; /* The __doc__ attribute, can be anything */ - PyObject *func_name; /* The __name__ attribute, a string object */ - PyObject *func_dict; /* The __dict__ attribute, a dict or NULL */ - PyObject *func_weakreflist; /* List of weak references */ - PyObject *func_module; /* The __module__ attribute, can be anything */ - - /* Invariant: - * func_closure contains the bindings for func_code->co_freevars, so - * PyTuple_Size(func_closure) == PyCode_GetNumFree(func_code) - * (func_closure may be NULL if PyCode_GetNumFree(func_code) == 0). - */ -} PyFunctionObject; - -PyAPI_DATA(PyTypeObject) PyFunction_Type; - -#define PyFunction_Check(op) (Py_TYPE(op) == &PyFunction_Type) - -PyAPI_FUNC(PyObject *) PyFunction_New(PyObject *, PyObject *); -PyAPI_FUNC(PyObject *) PyFunction_GetCode(PyObject *); -PyAPI_FUNC(PyObject *) PyFunction_GetGlobals(PyObject *); -PyAPI_FUNC(PyObject *) PyFunction_GetModule(PyObject *); -PyAPI_FUNC(PyObject *) PyFunction_GetDefaults(PyObject *); -PyAPI_FUNC(int) PyFunction_SetDefaults(PyObject *, PyObject *); -PyAPI_FUNC(PyObject *) PyFunction_GetClosure(PyObject *); -PyAPI_FUNC(int) PyFunction_SetClosure(PyObject *, PyObject *); - -/* Macros for direct access to these values. Type checks are *not* - done, so use with care. */ -#define PyFunction_GET_CODE(func) \ - (((PyFunctionObject *)func) -> func_code) -#define PyFunction_GET_GLOBALS(func) \ - (((PyFunctionObject *)func) -> func_globals) -#define PyFunction_GET_MODULE(func) \ - (((PyFunctionObject *)func) -> func_module) -#define PyFunction_GET_DEFAULTS(func) \ - (((PyFunctionObject *)func) -> func_defaults) -#define PyFunction_GET_CLOSURE(func) \ - (((PyFunctionObject *)func) -> func_closure) - -/* The classmethod and staticmethod types lives here, too */ -PyAPI_DATA(PyTypeObject) PyClassMethod_Type; -PyAPI_DATA(PyTypeObject) PyStaticMethod_Type; - -PyAPI_FUNC(PyObject *) PyClassMethod_New(PyObject *); -PyAPI_FUNC(PyObject *) PyStaticMethod_New(PyObject *); - -#ifdef __cplusplus -} -#endif -#endif /* !Py_FUNCOBJECT_H */ diff --git a/python/include/genobject.h b/python/include/genobject.h deleted file mode 100644 index 135561b7..00000000 --- a/python/include/genobject.h +++ /dev/null @@ -1,40 +0,0 @@ - -/* Generator object interface */ - -#ifndef Py_GENOBJECT_H -#define Py_GENOBJECT_H -#ifdef __cplusplus -extern "C" { -#endif - -struct _frame; /* Avoid including frameobject.h */ - -typedef struct { - PyObject_HEAD - /* The gi_ prefix is intended to remind of generator-iterator. */ - - /* Note: gi_frame can be NULL if the generator is "finished" */ - struct _frame *gi_frame; - - /* True if generator is being executed. */ - int gi_running; - - /* The code object backing the generator */ - PyObject *gi_code; - - /* List of weak reference. */ - PyObject *gi_weakreflist; -} PyGenObject; - -PyAPI_DATA(PyTypeObject) PyGen_Type; - -#define PyGen_Check(op) PyObject_TypeCheck(op, &PyGen_Type) -#define PyGen_CheckExact(op) (Py_TYPE(op) == &PyGen_Type) - -PyAPI_FUNC(PyObject *) PyGen_New(struct _frame *); -PyAPI_FUNC(int) PyGen_NeedsFinalizing(PyGenObject *); - -#ifdef __cplusplus -} -#endif -#endif /* !Py_GENOBJECT_H */ diff --git a/python/include/graminit.h b/python/include/graminit.h deleted file mode 100644 index 40d531e8..00000000 --- a/python/include/graminit.h +++ /dev/null @@ -1,87 +0,0 @@ -/* Generated by Parser/pgen */ - -#define single_input 256 -#define file_input 257 -#define eval_input 258 -#define decorator 259 -#define decorators 260 -#define decorated 261 -#define funcdef 262 -#define parameters 263 -#define varargslist 264 -#define fpdef 265 -#define fplist 266 -#define stmt 267 -#define simple_stmt 268 -#define small_stmt 269 -#define expr_stmt 270 -#define augassign 271 -#define print_stmt 272 -#define del_stmt 273 -#define pass_stmt 274 -#define flow_stmt 275 -#define break_stmt 276 -#define continue_stmt 277 -#define return_stmt 278 -#define yield_stmt 279 -#define raise_stmt 280 -#define import_stmt 281 -#define import_name 282 -#define import_from 283 -#define import_as_name 284 -#define dotted_as_name 285 -#define import_as_names 286 -#define dotted_as_names 287 -#define dotted_name 288 -#define global_stmt 289 -#define exec_stmt 290 -#define assert_stmt 291 -#define compound_stmt 292 -#define if_stmt 293 -#define while_stmt 294 -#define for_stmt 295 -#define try_stmt 296 -#define with_stmt 297 -#define with_item 298 -#define except_clause 299 -#define suite 300 -#define testlist_safe 301 -#define old_test 302 -#define old_lambdef 303 -#define test 304 -#define or_test 305 -#define and_test 306 -#define not_test 307 -#define comparison 308 -#define comp_op 309 -#define expr 310 -#define xor_expr 311 -#define and_expr 312 -#define shift_expr 313 -#define arith_expr 314 -#define term 315 -#define factor 316 -#define power 317 -#define atom 318 -#define listmaker 319 -#define testlist_comp 320 -#define lambdef 321 -#define trailer 322 -#define subscriptlist 323 -#define subscript 324 -#define sliceop 325 -#define exprlist 326 -#define testlist 327 -#define dictorsetmaker 328 -#define classdef 329 -#define arglist 330 -#define argument 331 -#define list_iter 332 -#define list_for 333 -#define list_if 334 -#define comp_iter 335 -#define comp_for 336 -#define comp_if 337 -#define testlist1 338 -#define encoding_decl 339 -#define yield_expr 340 diff --git a/python/include/grammar.h b/python/include/grammar.h deleted file mode 100644 index 8426da30..00000000 --- a/python/include/grammar.h +++ /dev/null @@ -1,93 +0,0 @@ - -/* Grammar interface */ - -#ifndef Py_GRAMMAR_H -#define Py_GRAMMAR_H -#ifdef __cplusplus -extern "C" { -#endif - -#include "bitset.h" /* Sigh... */ - -/* A label of an arc */ - -typedef struct { - int lb_type; - char *lb_str; -} label; - -#define EMPTY 0 /* Label number 0 is by definition the empty label */ - -/* A list of labels */ - -typedef struct { - int ll_nlabels; - label *ll_label; -} labellist; - -/* An arc from one state to another */ - -typedef struct { - short a_lbl; /* Label of this arc */ - short a_arrow; /* State where this arc goes to */ -} arc; - -/* A state in a DFA */ - -typedef struct { - int s_narcs; - arc *s_arc; /* Array of arcs */ - - /* Optional accelerators */ - int s_lower; /* Lowest label index */ - int s_upper; /* Highest label index */ - int *s_accel; /* Accelerator */ - int s_accept; /* Nonzero for accepting state */ -} state; - -/* A DFA */ - -typedef struct { - int d_type; /* Non-terminal this represents */ - char *d_name; /* For printing */ - int d_initial; /* Initial state */ - int d_nstates; - state *d_state; /* Array of states */ - bitset d_first; -} dfa; - -/* A grammar */ - -typedef struct { - int g_ndfas; - dfa *g_dfa; /* Array of DFAs */ - labellist g_ll; - int g_start; /* Start symbol of the grammar */ - int g_accel; /* Set if accelerators present */ -} grammar; - -/* FUNCTIONS */ - -grammar *newgrammar(int start); -dfa *adddfa(grammar *g, int type, char *name); -int addstate(dfa *d); -void addarc(dfa *d, int from, int to, int lbl); -dfa *PyGrammar_FindDFA(grammar *g, int type); - -int addlabel(labellist *ll, int type, char *str); -int findlabel(labellist *ll, int type, char *str); -char *PyGrammar_LabelRepr(label *lb); -void translatelabels(grammar *g); - -void addfirstsets(grammar *g); - -void PyGrammar_AddAccelerators(grammar *g); -void PyGrammar_RemoveAccelerators(grammar *); - -void printgrammar(grammar *g, FILE *fp); -void printnonterminals(grammar *g, FILE *fp); - -#ifdef __cplusplus -} -#endif -#endif /* !Py_GRAMMAR_H */ diff --git a/python/include/import.h b/python/include/import.h deleted file mode 100644 index 1b7fe0a7..00000000 --- a/python/include/import.h +++ /dev/null @@ -1,71 +0,0 @@ - -/* Module definition and import interface */ - -#ifndef Py_IMPORT_H -#define Py_IMPORT_H -#ifdef __cplusplus -extern "C" { -#endif - -PyAPI_FUNC(long) PyImport_GetMagicNumber(void); -PyAPI_FUNC(PyObject *) PyImport_ExecCodeModule(char *name, PyObject *co); -PyAPI_FUNC(PyObject *) PyImport_ExecCodeModuleEx( - char *name, PyObject *co, char *pathname); -PyAPI_FUNC(PyObject *) PyImport_GetModuleDict(void); -PyAPI_FUNC(PyObject *) PyImport_AddModule(const char *name); -PyAPI_FUNC(PyObject *) PyImport_ImportModule(const char *name); -PyAPI_FUNC(PyObject *) PyImport_ImportModuleNoBlock(const char *); -PyAPI_FUNC(PyObject *) PyImport_ImportModuleLevel(char *name, - PyObject *globals, PyObject *locals, PyObject *fromlist, int level); - -#define PyImport_ImportModuleEx(n, g, l, f) \ - PyImport_ImportModuleLevel(n, g, l, f, -1) - -PyAPI_FUNC(PyObject *) PyImport_GetImporter(PyObject *path); -PyAPI_FUNC(PyObject *) PyImport_Import(PyObject *name); -PyAPI_FUNC(PyObject *) PyImport_ReloadModule(PyObject *m); -PyAPI_FUNC(void) PyImport_Cleanup(void); -PyAPI_FUNC(int) PyImport_ImportFrozenModule(char *); - -#ifdef WITH_THREAD -PyAPI_FUNC(void) _PyImport_AcquireLock(void); -PyAPI_FUNC(int) _PyImport_ReleaseLock(void); -#else -#define _PyImport_AcquireLock() -#define _PyImport_ReleaseLock() 1 -#endif - -PyAPI_FUNC(struct filedescr *) _PyImport_FindModule( - const char *, PyObject *, char *, size_t, FILE **, PyObject **); -PyAPI_FUNC(int) _PyImport_IsScript(struct filedescr *); -PyAPI_FUNC(void) _PyImport_ReInitLock(void); - -PyAPI_FUNC(PyObject *)_PyImport_FindExtension(char *, char *); -PyAPI_FUNC(PyObject *)_PyImport_FixupExtension(char *, char *); - -struct _inittab { - char *name; - void (*initfunc)(void); -}; - -PyAPI_DATA(PyTypeObject) PyNullImporter_Type; -PyAPI_DATA(struct _inittab *) PyImport_Inittab; - -PyAPI_FUNC(int) PyImport_AppendInittab(const char *name, void (*initfunc)(void)); -PyAPI_FUNC(int) PyImport_ExtendInittab(struct _inittab *newtab); - -struct _frozen { - char *name; - unsigned char *code; - int size; -}; - -/* Embedding apps may change this pointer to point to their favorite - collection of frozen modules: */ - -PyAPI_DATA(struct _frozen *) PyImport_FrozenModules; - -#ifdef __cplusplus -} -#endif -#endif /* !Py_IMPORT_H */ diff --git a/python/include/intobject.h b/python/include/intobject.h deleted file mode 100644 index 78746a63..00000000 --- a/python/include/intobject.h +++ /dev/null @@ -1,80 +0,0 @@ - -/* Integer object interface */ - -/* -PyIntObject represents a (long) integer. This is an immutable object; -an integer cannot change its value after creation. - -There are functions to create new integer objects, to test an object -for integer-ness, and to get the integer value. The latter functions -returns -1 and sets errno to EBADF if the object is not an PyIntObject. -None of the functions should be applied to nil objects. - -The type PyIntObject is (unfortunately) exposed here so we can declare -_Py_TrueStruct and _Py_ZeroStruct in boolobject.h; don't use this. -*/ - -#ifndef Py_INTOBJECT_H -#define Py_INTOBJECT_H -#ifdef __cplusplus -extern "C" { -#endif - -typedef struct { - PyObject_HEAD - long ob_ival; -} PyIntObject; - -PyAPI_DATA(PyTypeObject) PyInt_Type; - -#define PyInt_Check(op) \ - PyType_FastSubclass((op)->ob_type, Py_TPFLAGS_INT_SUBCLASS) -#define PyInt_CheckExact(op) ((op)->ob_type == &PyInt_Type) - -PyAPI_FUNC(PyObject *) PyInt_FromString(char*, char**, int); -#ifdef Py_USING_UNICODE -PyAPI_FUNC(PyObject *) PyInt_FromUnicode(Py_UNICODE*, Py_ssize_t, int); -#endif -PyAPI_FUNC(PyObject *) PyInt_FromLong(long); -PyAPI_FUNC(PyObject *) PyInt_FromSize_t(size_t); -PyAPI_FUNC(PyObject *) PyInt_FromSsize_t(Py_ssize_t); -PyAPI_FUNC(long) PyInt_AsLong(PyObject *); -PyAPI_FUNC(Py_ssize_t) PyInt_AsSsize_t(PyObject *); -PyAPI_FUNC(unsigned long) PyInt_AsUnsignedLongMask(PyObject *); -#ifdef HAVE_LONG_LONG -PyAPI_FUNC(unsigned PY_LONG_LONG) PyInt_AsUnsignedLongLongMask(PyObject *); -#endif - -PyAPI_FUNC(long) PyInt_GetMax(void); - -/* Macro, trading safety for speed */ -#define PyInt_AS_LONG(op) (((PyIntObject *)(op))->ob_ival) - -/* These aren't really part of the Int object, but they're handy; the protos - * are necessary for systems that need the magic of PyAPI_FUNC and that want - * to have stropmodule as a dynamically loaded module instead of building it - * into the main Python shared library/DLL. Guido thinks I'm weird for - * building it this way. :-) [cjh] - */ -PyAPI_FUNC(unsigned long) PyOS_strtoul(char *, char **, int); -PyAPI_FUNC(long) PyOS_strtol(char *, char **, int); - -/* free list api */ -PyAPI_FUNC(int) PyInt_ClearFreeList(void); - -/* Convert an integer to the given base. Returns a string. - If base is 2, 8 or 16, add the proper prefix '0b', '0o' or '0x'. - If newstyle is zero, then use the pre-2.6 behavior of octal having - a leading "0" */ -PyAPI_FUNC(PyObject*) _PyInt_Format(PyIntObject* v, int base, int newstyle); - -/* Format the object based on the format_spec, as defined in PEP 3101 - (Advanced String Formatting). */ -PyAPI_FUNC(PyObject *) _PyInt_FormatAdvanced(PyObject *obj, - char *format_spec, - Py_ssize_t format_spec_len); - -#ifdef __cplusplus -} -#endif -#endif /* !Py_INTOBJECT_H */ diff --git a/python/include/intrcheck.h b/python/include/intrcheck.h deleted file mode 100644 index 3b67ed0d..00000000 --- a/python/include/intrcheck.h +++ /dev/null @@ -1,15 +0,0 @@ - -#ifndef Py_INTRCHECK_H -#define Py_INTRCHECK_H -#ifdef __cplusplus -extern "C" { -#endif - -PyAPI_FUNC(int) PyOS_InterruptOccurred(void); -PyAPI_FUNC(void) PyOS_InitInterrupts(void); -PyAPI_FUNC(void) PyOS_AfterFork(void); - -#ifdef __cplusplus -} -#endif -#endif /* !Py_INTRCHECK_H */ diff --git a/python/include/iterobject.h b/python/include/iterobject.h deleted file mode 100644 index 4bd19c29..00000000 --- a/python/include/iterobject.h +++ /dev/null @@ -1,23 +0,0 @@ -#ifndef Py_ITEROBJECT_H -#define Py_ITEROBJECT_H -/* Iterators (the basic kind, over a sequence) */ -#ifdef __cplusplus -extern "C" { -#endif - -PyAPI_DATA(PyTypeObject) PySeqIter_Type; - -#define PySeqIter_Check(op) (Py_TYPE(op) == &PySeqIter_Type) - -PyAPI_FUNC(PyObject *) PySeqIter_New(PyObject *); - -PyAPI_DATA(PyTypeObject) PyCallIter_Type; - -#define PyCallIter_Check(op) (Py_TYPE(op) == &PyCallIter_Type) - -PyAPI_FUNC(PyObject *) PyCallIter_New(PyObject *, PyObject *); -#ifdef __cplusplus -} -#endif -#endif /* !Py_ITEROBJECT_H */ - diff --git a/python/include/listobject.h b/python/include/listobject.h deleted file mode 100644 index c4458733..00000000 --- a/python/include/listobject.h +++ /dev/null @@ -1,68 +0,0 @@ - -/* List object interface */ - -/* -Another generally useful object type is an list of object pointers. -This is a mutable type: the list items can be changed, and items can be -added or removed. Out-of-range indices or non-list objects are ignored. - -*** WARNING *** PyList_SetItem does not increment the new item's reference -count, but does decrement the reference count of the item it replaces, -if not nil. It does *decrement* the reference count if it is *not* -inserted in the list. Similarly, PyList_GetItem does not increment the -returned item's reference count. -*/ - -#ifndef Py_LISTOBJECT_H -#define Py_LISTOBJECT_H -#ifdef __cplusplus -extern "C" { -#endif - -typedef struct { - PyObject_VAR_HEAD - /* Vector of pointers to list elements. list[0] is ob_item[0], etc. */ - PyObject **ob_item; - - /* ob_item contains space for 'allocated' elements. The number - * currently in use is ob_size. - * Invariants: - * 0 <= ob_size <= allocated - * len(list) == ob_size - * ob_item == NULL implies ob_size == allocated == 0 - * list.sort() temporarily sets allocated to -1 to detect mutations. - * - * Items must normally not be NULL, except during construction when - * the list is not yet visible outside the function that builds it. - */ - Py_ssize_t allocated; -} PyListObject; - -PyAPI_DATA(PyTypeObject) PyList_Type; - -#define PyList_Check(op) \ - PyType_FastSubclass(Py_TYPE(op), Py_TPFLAGS_LIST_SUBCLASS) -#define PyList_CheckExact(op) (Py_TYPE(op) == &PyList_Type) - -PyAPI_FUNC(PyObject *) PyList_New(Py_ssize_t size); -PyAPI_FUNC(Py_ssize_t) PyList_Size(PyObject *); -PyAPI_FUNC(PyObject *) PyList_GetItem(PyObject *, Py_ssize_t); -PyAPI_FUNC(int) PyList_SetItem(PyObject *, Py_ssize_t, PyObject *); -PyAPI_FUNC(int) PyList_Insert(PyObject *, Py_ssize_t, PyObject *); -PyAPI_FUNC(int) PyList_Append(PyObject *, PyObject *); -PyAPI_FUNC(PyObject *) PyList_GetSlice(PyObject *, Py_ssize_t, Py_ssize_t); -PyAPI_FUNC(int) PyList_SetSlice(PyObject *, Py_ssize_t, Py_ssize_t, PyObject *); -PyAPI_FUNC(int) PyList_Sort(PyObject *); -PyAPI_FUNC(int) PyList_Reverse(PyObject *); -PyAPI_FUNC(PyObject *) PyList_AsTuple(PyObject *); -PyAPI_FUNC(PyObject *) _PyList_Extend(PyListObject *, PyObject *); - -/* Macro, trading safety for speed */ -#define PyList_GET_ITEM(op, i) (((PyListObject *)(op))->ob_item[i]) -#define PyList_SET_ITEM(op, i, v) (((PyListObject *)(op))->ob_item[i] = (v)) -#define PyList_GET_SIZE(op) Py_SIZE(op) - -#ifdef __cplusplus -} -#endif -#endif /* !Py_LISTOBJECT_H */ diff --git a/python/include/longintrepr.h b/python/include/longintrepr.h deleted file mode 100644 index 6425c30f..00000000 --- a/python/include/longintrepr.h +++ /dev/null @@ -1,103 +0,0 @@ -#ifndef Py_LONGINTREPR_H -#define Py_LONGINTREPR_H -#ifdef __cplusplus -extern "C" { -#endif - - -/* This is published for the benefit of "friend" marshal.c only. */ - -/* Parameters of the long integer representation. There are two different - sets of parameters: one set for 30-bit digits, stored in an unsigned 32-bit - integer type, and one set for 15-bit digits with each digit stored in an - unsigned short. The value of PYLONG_BITS_IN_DIGIT, defined either at - configure time or in pyport.h, is used to decide which digit size to use. - - Type 'digit' should be able to hold 2*PyLong_BASE-1, and type 'twodigits' - should be an unsigned integer type able to hold all integers up to - PyLong_BASE*PyLong_BASE-1. x_sub assumes that 'digit' is an unsigned type, - and that overflow is handled by taking the result modulo 2**N for some N > - PyLong_SHIFT. The majority of the code doesn't care about the precise - value of PyLong_SHIFT, but there are some notable exceptions: - - - long_pow() requires that PyLong_SHIFT be divisible by 5 - - - PyLong_{As,From}ByteArray require that PyLong_SHIFT be at least 8 - - - long_hash() requires that PyLong_SHIFT is *strictly* less than the number - of bits in an unsigned long, as do the PyLong <-> long (or unsigned long) - conversion functions - - - the long <-> size_t/Py_ssize_t conversion functions expect that - PyLong_SHIFT is strictly less than the number of bits in a size_t - - - the marshal code currently expects that PyLong_SHIFT is a multiple of 15 - - The values 15 and 30 should fit all of the above requirements, on any - platform. -*/ - -#if PYLONG_BITS_IN_DIGIT == 30 -#if !(defined HAVE_UINT64_T && defined HAVE_UINT32_T && \ - defined HAVE_INT64_T && defined HAVE_INT32_T) -#error "30-bit long digits requested, but the necessary types are not available on this platform" -#endif -typedef PY_UINT32_T digit; -typedef PY_INT32_T sdigit; /* signed variant of digit */ -typedef PY_UINT64_T twodigits; -typedef PY_INT64_T stwodigits; /* signed variant of twodigits */ -#define PyLong_SHIFT 30 -#define _PyLong_DECIMAL_SHIFT 9 /* max(e such that 10**e fits in a digit) */ -#define _PyLong_DECIMAL_BASE ((digit)1000000000) /* 10 ** DECIMAL_SHIFT */ -#elif PYLONG_BITS_IN_DIGIT == 15 -typedef unsigned short digit; -typedef short sdigit; /* signed variant of digit */ -typedef unsigned long twodigits; -typedef long stwodigits; /* signed variant of twodigits */ -#define PyLong_SHIFT 15 -#define _PyLong_DECIMAL_SHIFT 4 /* max(e such that 10**e fits in a digit) */ -#define _PyLong_DECIMAL_BASE ((digit)10000) /* 10 ** DECIMAL_SHIFT */ -#else -#error "PYLONG_BITS_IN_DIGIT should be 15 or 30" -#endif -#define PyLong_BASE ((digit)1 << PyLong_SHIFT) -#define PyLong_MASK ((digit)(PyLong_BASE - 1)) - -/* b/w compatibility with Python 2.5 */ -#define SHIFT PyLong_SHIFT -#define BASE PyLong_BASE -#define MASK PyLong_MASK - -#if PyLong_SHIFT % 5 != 0 -#error "longobject.c requires that PyLong_SHIFT be divisible by 5" -#endif - -/* Long integer representation. - The absolute value of a number is equal to - SUM(for i=0 through abs(ob_size)-1) ob_digit[i] * 2**(SHIFT*i) - Negative numbers are represented with ob_size < 0; - zero is represented by ob_size == 0. - In a normalized number, ob_digit[abs(ob_size)-1] (the most significant - digit) is never zero. Also, in all cases, for all valid i, - 0 <= ob_digit[i] <= MASK. - The allocation function takes care of allocating extra memory - so that ob_digit[0] ... ob_digit[abs(ob_size)-1] are actually available. - - CAUTION: Generic code manipulating subtypes of PyVarObject has to - aware that longs abuse ob_size's sign bit. -*/ - -struct _longobject { - PyObject_VAR_HEAD - digit ob_digit[1]; -}; - -PyAPI_FUNC(PyLongObject *) _PyLong_New(Py_ssize_t); - -/* Return a copy of src. */ -PyAPI_FUNC(PyObject *) _PyLong_Copy(PyLongObject *src); - -#ifdef __cplusplus -} -#endif -#endif /* !Py_LONGINTREPR_H */ diff --git a/python/include/longobject.h b/python/include/longobject.h deleted file mode 100644 index 2b404612..00000000 --- a/python/include/longobject.h +++ /dev/null @@ -1,134 +0,0 @@ -#ifndef Py_LONGOBJECT_H -#define Py_LONGOBJECT_H -#ifdef __cplusplus -extern "C" { -#endif - - -/* Long (arbitrary precision) integer object interface */ - -typedef struct _longobject PyLongObject; /* Revealed in longintrepr.h */ - -PyAPI_DATA(PyTypeObject) PyLong_Type; - -#define PyLong_Check(op) \ - PyType_FastSubclass(Py_TYPE(op), Py_TPFLAGS_LONG_SUBCLASS) -#define PyLong_CheckExact(op) (Py_TYPE(op) == &PyLong_Type) - -PyAPI_FUNC(PyObject *) PyLong_FromLong(long); -PyAPI_FUNC(PyObject *) PyLong_FromUnsignedLong(unsigned long); -PyAPI_FUNC(PyObject *) PyLong_FromDouble(double); -PyAPI_FUNC(PyObject *) PyLong_FromSize_t(size_t); -PyAPI_FUNC(PyObject *) PyLong_FromSsize_t(Py_ssize_t); -PyAPI_FUNC(long) PyLong_AsLong(PyObject *); -PyAPI_FUNC(long) PyLong_AsLongAndOverflow(PyObject *, int *); -PyAPI_FUNC(unsigned long) PyLong_AsUnsignedLong(PyObject *); -PyAPI_FUNC(unsigned long) PyLong_AsUnsignedLongMask(PyObject *); -PyAPI_FUNC(Py_ssize_t) PyLong_AsSsize_t(PyObject *); -PyAPI_FUNC(PyObject *) PyLong_GetInfo(void); - -/* For use by intobject.c only */ -#define _PyLong_AsSsize_t PyLong_AsSsize_t -#define _PyLong_FromSize_t PyLong_FromSize_t -#define _PyLong_FromSsize_t PyLong_FromSsize_t -PyAPI_DATA(int) _PyLong_DigitValue[256]; - -/* _PyLong_Frexp returns a double x and an exponent e such that the - true value is approximately equal to x * 2**e. e is >= 0. x is - 0.0 if and only if the input is 0 (in which case, e and x are both - zeroes); otherwise, 0.5 <= abs(x) < 1.0. On overflow, which is - possible if the number of bits doesn't fit into a Py_ssize_t, sets - OverflowError and returns -1.0 for x, 0 for e. */ -PyAPI_FUNC(double) _PyLong_Frexp(PyLongObject *a, Py_ssize_t *e); - -PyAPI_FUNC(double) PyLong_AsDouble(PyObject *); -PyAPI_FUNC(PyObject *) PyLong_FromVoidPtr(void *); -PyAPI_FUNC(void *) PyLong_AsVoidPtr(PyObject *); - -#ifdef HAVE_LONG_LONG -PyAPI_FUNC(PyObject *) PyLong_FromLongLong(PY_LONG_LONG); -PyAPI_FUNC(PyObject *) PyLong_FromUnsignedLongLong(unsigned PY_LONG_LONG); -PyAPI_FUNC(PY_LONG_LONG) PyLong_AsLongLong(PyObject *); -PyAPI_FUNC(unsigned PY_LONG_LONG) PyLong_AsUnsignedLongLong(PyObject *); -PyAPI_FUNC(unsigned PY_LONG_LONG) PyLong_AsUnsignedLongLongMask(PyObject *); -PyAPI_FUNC(PY_LONG_LONG) PyLong_AsLongLongAndOverflow(PyObject *, int *); -#endif /* HAVE_LONG_LONG */ - -PyAPI_FUNC(PyObject *) PyLong_FromString(char *, char **, int); -#ifdef Py_USING_UNICODE -PyAPI_FUNC(PyObject *) PyLong_FromUnicode(Py_UNICODE*, Py_ssize_t, int); -#endif - -/* _PyLong_Sign. Return 0 if v is 0, -1 if v < 0, +1 if v > 0. - v must not be NULL, and must be a normalized long. - There are no error cases. -*/ -PyAPI_FUNC(int) _PyLong_Sign(PyObject *v); - - -/* _PyLong_NumBits. Return the number of bits needed to represent the - absolute value of a long. For example, this returns 1 for 1 and -1, 2 - for 2 and -2, and 2 for 3 and -3. It returns 0 for 0. - v must not be NULL, and must be a normalized long. - (size_t)-1 is returned and OverflowError set if the true result doesn't - fit in a size_t. -*/ -PyAPI_FUNC(size_t) _PyLong_NumBits(PyObject *v); - -/* _PyLong_FromByteArray: View the n unsigned bytes as a binary integer in - base 256, and return a Python long with the same numeric value. - If n is 0, the integer is 0. Else: - If little_endian is 1/true, bytes[n-1] is the MSB and bytes[0] the LSB; - else (little_endian is 0/false) bytes[0] is the MSB and bytes[n-1] the - LSB. - If is_signed is 0/false, view the bytes as a non-negative integer. - If is_signed is 1/true, view the bytes as a 2's-complement integer, - non-negative if bit 0x80 of the MSB is clear, negative if set. - Error returns: - + Return NULL with the appropriate exception set if there's not - enough memory to create the Python long. -*/ -PyAPI_FUNC(PyObject *) _PyLong_FromByteArray( - const unsigned char* bytes, size_t n, - int little_endian, int is_signed); - -/* _PyLong_AsByteArray: Convert the least-significant 8*n bits of long - v to a base-256 integer, stored in array bytes. Normally return 0, - return -1 on error. - If little_endian is 1/true, store the MSB at bytes[n-1] and the LSB at - bytes[0]; else (little_endian is 0/false) store the MSB at bytes[0] and - the LSB at bytes[n-1]. - If is_signed is 0/false, it's an error if v < 0; else (v >= 0) n bytes - are filled and there's nothing special about bit 0x80 of the MSB. - If is_signed is 1/true, bytes is filled with the 2's-complement - representation of v's value. Bit 0x80 of the MSB is the sign bit. - Error returns (-1): - + is_signed is 0 and v < 0. TypeError is set in this case, and bytes - isn't altered. - + n isn't big enough to hold the full mathematical value of v. For - example, if is_signed is 0 and there are more digits in the v than - fit in n; or if is_signed is 1, v < 0, and n is just 1 bit shy of - being large enough to hold a sign bit. OverflowError is set in this - case, but bytes holds the least-signficant n bytes of the true value. -*/ -PyAPI_FUNC(int) _PyLong_AsByteArray(PyLongObject* v, - unsigned char* bytes, size_t n, - int little_endian, int is_signed); - -/* _PyLong_Format: Convert the long to a string object with given base, - appending a base prefix of 0[box] if base is 2, 8 or 16. - Add a trailing "L" if addL is non-zero. - If newstyle is zero, then use the pre-2.6 behavior of octal having - a leading "0", instead of the prefix "0o" */ -PyAPI_FUNC(PyObject *) _PyLong_Format(PyObject *aa, int base, int addL, int newstyle); - -/* Format the object based on the format_spec, as defined in PEP 3101 - (Advanced String Formatting). */ -PyAPI_FUNC(PyObject *) _PyLong_FormatAdvanced(PyObject *obj, - char *format_spec, - Py_ssize_t format_spec_len); - -#ifdef __cplusplus -} -#endif -#endif /* !Py_LONGOBJECT_H */ diff --git a/python/include/marshal.h b/python/include/marshal.h deleted file mode 100644 index 411fdca3..00000000 --- a/python/include/marshal.h +++ /dev/null @@ -1,25 +0,0 @@ - -/* Interface for marshal.c */ - -#ifndef Py_MARSHAL_H -#define Py_MARSHAL_H -#ifdef __cplusplus -extern "C" { -#endif - -#define Py_MARSHAL_VERSION 2 - -PyAPI_FUNC(void) PyMarshal_WriteLongToFile(long, FILE *, int); -PyAPI_FUNC(void) PyMarshal_WriteObjectToFile(PyObject *, FILE *, int); -PyAPI_FUNC(PyObject *) PyMarshal_WriteObjectToString(PyObject *, int); - -PyAPI_FUNC(long) PyMarshal_ReadLongFromFile(FILE *); -PyAPI_FUNC(int) PyMarshal_ReadShortFromFile(FILE *); -PyAPI_FUNC(PyObject *) PyMarshal_ReadObjectFromFile(FILE *); -PyAPI_FUNC(PyObject *) PyMarshal_ReadLastObjectFromFile(FILE *); -PyAPI_FUNC(PyObject *) PyMarshal_ReadObjectFromString(char *, Py_ssize_t); - -#ifdef __cplusplus -} -#endif -#endif /* !Py_MARSHAL_H */ diff --git a/python/include/memoryobject.h b/python/include/memoryobject.h deleted file mode 100644 index bf0b621a..00000000 --- a/python/include/memoryobject.h +++ /dev/null @@ -1,74 +0,0 @@ -/* Memory view object. In Python this is available as "memoryview". */ - -#ifndef Py_MEMORYOBJECT_H -#define Py_MEMORYOBJECT_H -#ifdef __cplusplus -extern "C" { -#endif - -PyAPI_DATA(PyTypeObject) PyMemoryView_Type; - -#define PyMemoryView_Check(op) (Py_TYPE(op) == &PyMemoryView_Type) - -/* Get a pointer to the underlying Py_buffer of a memoryview object. */ -#define PyMemoryView_GET_BUFFER(op) (&((PyMemoryViewObject *)(op))->view) -/* Get a pointer to the PyObject from which originates a memoryview object. */ -#define PyMemoryView_GET_BASE(op) (((PyMemoryViewObject *)(op))->view.obj) - - -PyAPI_FUNC(PyObject *) PyMemoryView_GetContiguous(PyObject *base, - int buffertype, - char fort); - - /* Return a contiguous chunk of memory representing the buffer - from an object in a memory view object. If a copy is made then the - base object for the memory view will be a *new* bytes object. - - Otherwise, the base-object will be the object itself and no - data-copying will be done. - - The buffertype argument can be PyBUF_READ, PyBUF_WRITE, - PyBUF_SHADOW to determine whether the returned buffer - should be READONLY, WRITABLE, or set to update the - original buffer if a copy must be made. If buffertype is - PyBUF_WRITE and the buffer is not contiguous an error will - be raised. In this circumstance, the user can use - PyBUF_SHADOW to ensure that a a writable temporary - contiguous buffer is returned. The contents of this - contiguous buffer will be copied back into the original - object after the memoryview object is deleted as long as - the original object is writable and allows setting an - exclusive write lock. If this is not allowed by the - original object, then a BufferError is raised. - - If the object is multi-dimensional and if fortran is 'F', - the first dimension of the underlying array will vary the - fastest in the buffer. If fortran is 'C', then the last - dimension will vary the fastest (C-style contiguous). If - fortran is 'A', then it does not matter and you will get - whatever the object decides is more efficient. - - A new reference is returned that must be DECREF'd when finished. - */ - -PyAPI_FUNC(PyObject *) PyMemoryView_FromObject(PyObject *base); - -PyAPI_FUNC(PyObject *) PyMemoryView_FromBuffer(Py_buffer *info); - /* create new if bufptr is NULL - will be a new bytesobject in base */ - - -/* The struct is declared here so that macros can work, but it shouldn't - be considered public. Don't access those fields directly, use the macros - and functions instead! */ -typedef struct { - PyObject_HEAD - PyObject *base; - Py_buffer view; -} PyMemoryViewObject; - - -#ifdef __cplusplus -} -#endif -#endif /* !Py_MEMORYOBJECT_H */ diff --git a/python/include/metagrammar.h b/python/include/metagrammar.h deleted file mode 100644 index 15c8ef8f..00000000 --- a/python/include/metagrammar.h +++ /dev/null @@ -1,18 +0,0 @@ -#ifndef Py_METAGRAMMAR_H -#define Py_METAGRAMMAR_H -#ifdef __cplusplus -extern "C" { -#endif - - -#define MSTART 256 -#define RULE 257 -#define RHS 258 -#define ALT 259 -#define ITEM 260 -#define ATOM 261 - -#ifdef __cplusplus -} -#endif -#endif /* !Py_METAGRAMMAR_H */ diff --git a/python/include/methodobject.h b/python/include/methodobject.h deleted file mode 100644 index 6e160b63..00000000 --- a/python/include/methodobject.h +++ /dev/null @@ -1,93 +0,0 @@ - -/* Method object interface */ - -#ifndef Py_METHODOBJECT_H -#define Py_METHODOBJECT_H -#ifdef __cplusplus -extern "C" { -#endif - -/* This is about the type 'builtin_function_or_method', - not Python methods in user-defined classes. See classobject.h - for the latter. */ - -PyAPI_DATA(PyTypeObject) PyCFunction_Type; - -#define PyCFunction_Check(op) (Py_TYPE(op) == &PyCFunction_Type) - -typedef PyObject *(*PyCFunction)(PyObject *, PyObject *); -typedef PyObject *(*PyCFunctionWithKeywords)(PyObject *, PyObject *, - PyObject *); -typedef PyObject *(*PyNoArgsFunction)(PyObject *); - -PyAPI_FUNC(PyCFunction) PyCFunction_GetFunction(PyObject *); -PyAPI_FUNC(PyObject *) PyCFunction_GetSelf(PyObject *); -PyAPI_FUNC(int) PyCFunction_GetFlags(PyObject *); - -/* Macros for direct access to these values. Type checks are *not* - done, so use with care. */ -#define PyCFunction_GET_FUNCTION(func) \ - (((PyCFunctionObject *)func) -> m_ml -> ml_meth) -#define PyCFunction_GET_SELF(func) \ - (((PyCFunctionObject *)func) -> m_self) -#define PyCFunction_GET_FLAGS(func) \ - (((PyCFunctionObject *)func) -> m_ml -> ml_flags) -PyAPI_FUNC(PyObject *) PyCFunction_Call(PyObject *, PyObject *, PyObject *); - -struct PyMethodDef { - const char *ml_name; /* The name of the built-in function/method */ - PyCFunction ml_meth; /* The C function that implements it */ - int ml_flags; /* Combination of METH_xxx flags, which mostly - describe the args expected by the C func */ - const char *ml_doc; /* The __doc__ attribute, or NULL */ -}; -typedef struct PyMethodDef PyMethodDef; - -PyAPI_FUNC(PyObject *) Py_FindMethod(PyMethodDef[], PyObject *, const char *); - -#define PyCFunction_New(ML, SELF) PyCFunction_NewEx((ML), (SELF), NULL) -PyAPI_FUNC(PyObject *) PyCFunction_NewEx(PyMethodDef *, PyObject *, - PyObject *); - -/* Flag passed to newmethodobject */ -#define METH_OLDARGS 0x0000 -#define METH_VARARGS 0x0001 -#define METH_KEYWORDS 0x0002 -/* METH_NOARGS and METH_O must not be combined with the flags above. */ -#define METH_NOARGS 0x0004 -#define METH_O 0x0008 - -/* METH_CLASS and METH_STATIC are a little different; these control - the construction of methods for a class. These cannot be used for - functions in modules. */ -#define METH_CLASS 0x0010 -#define METH_STATIC 0x0020 - -/* METH_COEXIST allows a method to be entered eventhough a slot has - already filled the entry. When defined, the flag allows a separate - method, "__contains__" for example, to coexist with a defined - slot like sq_contains. */ - -#define METH_COEXIST 0x0040 - -typedef struct PyMethodChain { - PyMethodDef *methods; /* Methods of this type */ - struct PyMethodChain *link; /* NULL or base type */ -} PyMethodChain; - -PyAPI_FUNC(PyObject *) Py_FindMethodInChain(PyMethodChain *, PyObject *, - const char *); - -typedef struct { - PyObject_HEAD - PyMethodDef *m_ml; /* Description of the C function to call */ - PyObject *m_self; /* Passed as 'self' arg to the C func, can be NULL */ - PyObject *m_module; /* The __module__ attribute, can be anything */ -} PyCFunctionObject; - -PyAPI_FUNC(int) PyCFunction_ClearFreeList(void); - -#ifdef __cplusplus -} -#endif -#endif /* !Py_METHODOBJECT_H */ diff --git a/python/include/modsupport.h b/python/include/modsupport.h deleted file mode 100644 index d4dddef0..00000000 --- a/python/include/modsupport.h +++ /dev/null @@ -1,134 +0,0 @@ - -#ifndef Py_MODSUPPORT_H -#define Py_MODSUPPORT_H -#ifdef __cplusplus -extern "C" { -#endif - -/* Module support interface */ - -#include - -/* If PY_SSIZE_T_CLEAN is defined, each functions treats #-specifier - to mean Py_ssize_t */ -#ifdef PY_SSIZE_T_CLEAN -#define PyArg_Parse _PyArg_Parse_SizeT -#define PyArg_ParseTuple _PyArg_ParseTuple_SizeT -#define PyArg_ParseTupleAndKeywords _PyArg_ParseTupleAndKeywords_SizeT -#define PyArg_VaParse _PyArg_VaParse_SizeT -#define PyArg_VaParseTupleAndKeywords _PyArg_VaParseTupleAndKeywords_SizeT -#define Py_BuildValue _Py_BuildValue_SizeT -#define Py_VaBuildValue _Py_VaBuildValue_SizeT -#else -PyAPI_FUNC(PyObject *) _Py_VaBuildValue_SizeT(const char *, va_list); -#endif - -PyAPI_FUNC(int) PyArg_Parse(PyObject *, const char *, ...); -PyAPI_FUNC(int) PyArg_ParseTuple(PyObject *, const char *, ...) Py_FORMAT_PARSETUPLE(PyArg_ParseTuple, 2, 3); -PyAPI_FUNC(int) PyArg_ParseTupleAndKeywords(PyObject *, PyObject *, - const char *, char **, ...); -PyAPI_FUNC(int) PyArg_UnpackTuple(PyObject *, const char *, Py_ssize_t, Py_ssize_t, ...); -PyAPI_FUNC(PyObject *) Py_BuildValue(const char *, ...); -PyAPI_FUNC(PyObject *) _Py_BuildValue_SizeT(const char *, ...); -PyAPI_FUNC(int) _PyArg_NoKeywords(const char *funcname, PyObject *kw); - -PyAPI_FUNC(int) PyArg_VaParse(PyObject *, const char *, va_list); -PyAPI_FUNC(int) PyArg_VaParseTupleAndKeywords(PyObject *, PyObject *, - const char *, char **, va_list); -PyAPI_FUNC(PyObject *) Py_VaBuildValue(const char *, va_list); - -PyAPI_FUNC(int) PyModule_AddObject(PyObject *, const char *, PyObject *); -PyAPI_FUNC(int) PyModule_AddIntConstant(PyObject *, const char *, long); -PyAPI_FUNC(int) PyModule_AddStringConstant(PyObject *, const char *, const char *); -#define PyModule_AddIntMacro(m, c) PyModule_AddIntConstant(m, #c, c) -#define PyModule_AddStringMacro(m, c) PyModule_AddStringConstant(m, #c, c) - -#define PYTHON_API_VERSION 1013 -#define PYTHON_API_STRING "1013" -/* The API version is maintained (independently from the Python version) - so we can detect mismatches between the interpreter and dynamically - loaded modules. These are diagnosed by an error message but - the module is still loaded (because the mismatch can only be tested - after loading the module). The error message is intended to - explain the core dump a few seconds later. - - The symbol PYTHON_API_STRING defines the same value as a string - literal. *** PLEASE MAKE SURE THE DEFINITIONS MATCH. *** - - Please add a line or two to the top of this log for each API - version change: - - 22-Feb-2006 MvL 1013 PEP 353 - long indices for sequence lengths - - 19-Aug-2002 GvR 1012 Changes to string object struct for - interning changes, saving 3 bytes. - - 17-Jul-2001 GvR 1011 Descr-branch, just to be on the safe side - - 25-Jan-2001 FLD 1010 Parameters added to PyCode_New() and - PyFrame_New(); Python 2.1a2 - - 14-Mar-2000 GvR 1009 Unicode API added - - 3-Jan-1999 GvR 1007 Decided to change back! (Don't reuse 1008!) - - 3-Dec-1998 GvR 1008 Python 1.5.2b1 - - 18-Jan-1997 GvR 1007 string interning and other speedups - - 11-Oct-1996 GvR renamed Py_Ellipses to Py_Ellipsis :-( - - 30-Jul-1996 GvR Slice and ellipses syntax added - - 23-Jul-1996 GvR For 1.4 -- better safe than sorry this time :-) - - 7-Nov-1995 GvR Keyword arguments (should've been done at 1.3 :-( ) - - 10-Jan-1995 GvR Renamed globals to new naming scheme - - 9-Jan-1995 GvR Initial version (incompatible with older API) -*/ - -#ifdef MS_WINDOWS -/* Special defines for Windows versions used to live here. Things - have changed, and the "Version" is now in a global string variable. - Reason for this is that this for easier branding of a "custom DLL" - without actually needing a recompile. */ -#endif /* MS_WINDOWS */ - -#if SIZEOF_SIZE_T != SIZEOF_INT -/* On a 64-bit system, rename the Py_InitModule4 so that 2.4 - modules cannot get loaded into a 2.5 interpreter */ -#define Py_InitModule4 Py_InitModule4_64 -#endif - -#ifdef Py_TRACE_REFS - /* When we are tracing reference counts, rename Py_InitModule4 so - modules compiled with incompatible settings will generate a - link-time error. */ - #if SIZEOF_SIZE_T != SIZEOF_INT - #undef Py_InitModule4 - #define Py_InitModule4 Py_InitModule4TraceRefs_64 - #else - #define Py_InitModule4 Py_InitModule4TraceRefs - #endif -#endif - -PyAPI_FUNC(PyObject *) Py_InitModule4(const char *name, PyMethodDef *methods, - const char *doc, PyObject *self, - int apiver); - -#define Py_InitModule(name, methods) \ - Py_InitModule4(name, methods, (char *)NULL, (PyObject *)NULL, \ - PYTHON_API_VERSION) - -#define Py_InitModule3(name, methods, doc) \ - Py_InitModule4(name, methods, doc, (PyObject *)NULL, \ - PYTHON_API_VERSION) - -PyAPI_DATA(char *) _Py_PackageContext; - -#ifdef __cplusplus -} -#endif -#endif /* !Py_MODSUPPORT_H */ diff --git a/python/include/moduleobject.h b/python/include/moduleobject.h deleted file mode 100644 index b387f5bf..00000000 --- a/python/include/moduleobject.h +++ /dev/null @@ -1,24 +0,0 @@ - -/* Module object interface */ - -#ifndef Py_MODULEOBJECT_H -#define Py_MODULEOBJECT_H -#ifdef __cplusplus -extern "C" { -#endif - -PyAPI_DATA(PyTypeObject) PyModule_Type; - -#define PyModule_Check(op) PyObject_TypeCheck(op, &PyModule_Type) -#define PyModule_CheckExact(op) (Py_TYPE(op) == &PyModule_Type) - -PyAPI_FUNC(PyObject *) PyModule_New(const char *); -PyAPI_FUNC(PyObject *) PyModule_GetDict(PyObject *); -PyAPI_FUNC(char *) PyModule_GetName(PyObject *); -PyAPI_FUNC(char *) PyModule_GetFilename(PyObject *); -PyAPI_FUNC(void) _PyModule_Clear(PyObject *); - -#ifdef __cplusplus -} -#endif -#endif /* !Py_MODULEOBJECT_H */ diff --git a/python/include/node.h b/python/include/node.h deleted file mode 100644 index e23e709f..00000000 --- a/python/include/node.h +++ /dev/null @@ -1,40 +0,0 @@ - -/* Parse tree node interface */ - -#ifndef Py_NODE_H -#define Py_NODE_H -#ifdef __cplusplus -extern "C" { -#endif - -typedef struct _node { - short n_type; - char *n_str; - int n_lineno; - int n_col_offset; - int n_nchildren; - struct _node *n_child; -} node; - -PyAPI_FUNC(node *) PyNode_New(int type); -PyAPI_FUNC(int) PyNode_AddChild(node *n, int type, - char *str, int lineno, int col_offset); -PyAPI_FUNC(void) PyNode_Free(node *n); - -/* Node access functions */ -#define NCH(n) ((n)->n_nchildren) - -#define CHILD(n, i) (&(n)->n_child[i]) -#define RCHILD(n, i) (CHILD(n, NCH(n) + i)) -#define TYPE(n) ((n)->n_type) -#define STR(n) ((n)->n_str) - -/* Assert that the type of a node is what we expect */ -#define REQ(n, type) assert(TYPE(n) == (type)) - -PyAPI_FUNC(void) PyNode_ListTree(node *); - -#ifdef __cplusplus -} -#endif -#endif /* !Py_NODE_H */ diff --git a/python/include/object.h b/python/include/object.h deleted file mode 100644 index edcd3fc2..00000000 --- a/python/include/object.h +++ /dev/null @@ -1,996 +0,0 @@ -#ifndef Py_OBJECT_H -#define Py_OBJECT_H -#ifdef __cplusplus -extern "C" { -#endif - - -/* Object and type object interface */ - -/* -Objects are structures allocated on the heap. Special rules apply to -the use of objects to ensure they are properly garbage-collected. -Objects are never allocated statically or on the stack; they must be -accessed through special macros and functions only. (Type objects are -exceptions to the first rule; the standard types are represented by -statically initialized type objects, although work on type/class unification -for Python 2.2 made it possible to have heap-allocated type objects too). - -An object has a 'reference count' that is increased or decreased when a -pointer to the object is copied or deleted; when the reference count -reaches zero there are no references to the object left and it can be -removed from the heap. - -An object has a 'type' that determines what it represents and what kind -of data it contains. An object's type is fixed when it is created. -Types themselves are represented as objects; an object contains a -pointer to the corresponding type object. The type itself has a type -pointer pointing to the object representing the type 'type', which -contains a pointer to itself!). - -Objects do not float around in memory; once allocated an object keeps -the same size and address. Objects that must hold variable-size data -can contain pointers to variable-size parts of the object. Not all -objects of the same type have the same size; but the size cannot change -after allocation. (These restrictions are made so a reference to an -object can be simply a pointer -- moving an object would require -updating all the pointers, and changing an object's size would require -moving it if there was another object right next to it.) - -Objects are always accessed through pointers of the type 'PyObject *'. -The type 'PyObject' is a structure that only contains the reference count -and the type pointer. The actual memory allocated for an object -contains other data that can only be accessed after casting the pointer -to a pointer to a longer structure type. This longer type must start -with the reference count and type fields; the macro PyObject_HEAD should be -used for this (to accommodate for future changes). The implementation -of a particular object type can cast the object pointer to the proper -type and back. - -A standard interface exists for objects that contain an array of items -whose size is determined when the object is allocated. -*/ - -/* Py_DEBUG implies Py_TRACE_REFS. */ -#if defined(Py_DEBUG) && !defined(Py_TRACE_REFS) -#define Py_TRACE_REFS -#endif - -/* Py_TRACE_REFS implies Py_REF_DEBUG. */ -#if defined(Py_TRACE_REFS) && !defined(Py_REF_DEBUG) -#define Py_REF_DEBUG -#endif - -#ifdef Py_TRACE_REFS -/* Define pointers to support a doubly-linked list of all live heap objects. */ -#define _PyObject_HEAD_EXTRA \ - struct _object *_ob_next; \ - struct _object *_ob_prev; - -#define _PyObject_EXTRA_INIT 0, 0, - -#else -#define _PyObject_HEAD_EXTRA -#define _PyObject_EXTRA_INIT -#endif - -/* PyObject_HEAD defines the initial segment of every PyObject. */ -#define PyObject_HEAD \ - _PyObject_HEAD_EXTRA \ - Py_ssize_t ob_refcnt; \ - struct _typeobject *ob_type; - -#define PyObject_HEAD_INIT(type) \ - _PyObject_EXTRA_INIT \ - 1, type, - -#define PyVarObject_HEAD_INIT(type, size) \ - PyObject_HEAD_INIT(type) size, - -/* PyObject_VAR_HEAD defines the initial segment of all variable-size - * container objects. These end with a declaration of an array with 1 - * element, but enough space is malloc'ed so that the array actually - * has room for ob_size elements. Note that ob_size is an element count, - * not necessarily a byte count. - */ -#define PyObject_VAR_HEAD \ - PyObject_HEAD \ - Py_ssize_t ob_size; /* Number of items in variable part */ -#define Py_INVALID_SIZE (Py_ssize_t)-1 - -/* Nothing is actually declared to be a PyObject, but every pointer to - * a Python object can be cast to a PyObject*. This is inheritance built - * by hand. Similarly every pointer to a variable-size Python object can, - * in addition, be cast to PyVarObject*. - */ -typedef struct _object { - PyObject_HEAD -} PyObject; - -typedef struct { - PyObject_VAR_HEAD -} PyVarObject; - -#define Py_REFCNT(ob) (((PyObject*)(ob))->ob_refcnt) -#define Py_TYPE(ob) (((PyObject*)(ob))->ob_type) -#define Py_SIZE(ob) (((PyVarObject*)(ob))->ob_size) - -/* -Type objects contain a string containing the type name (to help somewhat -in debugging), the allocation parameters (see PyObject_New() and -PyObject_NewVar()), -and methods for accessing objects of the type. Methods are optional, a -nil pointer meaning that particular kind of access is not available for -this type. The Py_DECREF() macro uses the tp_dealloc method without -checking for a nil pointer; it should always be implemented except if -the implementation can guarantee that the reference count will never -reach zero (e.g., for statically allocated type objects). - -NB: the methods for certain type groups are now contained in separate -method blocks. -*/ - -typedef PyObject * (*unaryfunc)(PyObject *); -typedef PyObject * (*binaryfunc)(PyObject *, PyObject *); -typedef PyObject * (*ternaryfunc)(PyObject *, PyObject *, PyObject *); -typedef int (*inquiry)(PyObject *); -typedef Py_ssize_t (*lenfunc)(PyObject *); -typedef int (*coercion)(PyObject **, PyObject **); -typedef PyObject *(*intargfunc)(PyObject *, int) Py_DEPRECATED(2.5); -typedef PyObject *(*intintargfunc)(PyObject *, int, int) Py_DEPRECATED(2.5); -typedef PyObject *(*ssizeargfunc)(PyObject *, Py_ssize_t); -typedef PyObject *(*ssizessizeargfunc)(PyObject *, Py_ssize_t, Py_ssize_t); -typedef int(*intobjargproc)(PyObject *, int, PyObject *); -typedef int(*intintobjargproc)(PyObject *, int, int, PyObject *); -typedef int(*ssizeobjargproc)(PyObject *, Py_ssize_t, PyObject *); -typedef int(*ssizessizeobjargproc)(PyObject *, Py_ssize_t, Py_ssize_t, PyObject *); -typedef int(*objobjargproc)(PyObject *, PyObject *, PyObject *); - - - -/* int-based buffer interface */ -typedef int (*getreadbufferproc)(PyObject *, int, void **); -typedef int (*getwritebufferproc)(PyObject *, int, void **); -typedef int (*getsegcountproc)(PyObject *, int *); -typedef int (*getcharbufferproc)(PyObject *, int, char **); -/* ssize_t-based buffer interface */ -typedef Py_ssize_t (*readbufferproc)(PyObject *, Py_ssize_t, void **); -typedef Py_ssize_t (*writebufferproc)(PyObject *, Py_ssize_t, void **); -typedef Py_ssize_t (*segcountproc)(PyObject *, Py_ssize_t *); -typedef Py_ssize_t (*charbufferproc)(PyObject *, Py_ssize_t, char **); - - -/* Py3k buffer interface */ -typedef struct bufferinfo { - void *buf; - PyObject *obj; /* owned reference */ - Py_ssize_t len; - Py_ssize_t itemsize; /* This is Py_ssize_t so it can be - pointed to by strides in simple case.*/ - int readonly; - int ndim; - char *format; - Py_ssize_t *shape; - Py_ssize_t *strides; - Py_ssize_t *suboffsets; - Py_ssize_t smalltable[2]; /* static store for shape and strides of - mono-dimensional buffers. */ - void *internal; -} Py_buffer; - -typedef int (*getbufferproc)(PyObject *, Py_buffer *, int); -typedef void (*releasebufferproc)(PyObject *, Py_buffer *); - - /* Flags for getting buffers */ -#define PyBUF_SIMPLE 0 -#define PyBUF_WRITABLE 0x0001 -/* we used to include an E, backwards compatible alias */ -#define PyBUF_WRITEABLE PyBUF_WRITABLE -#define PyBUF_FORMAT 0x0004 -#define PyBUF_ND 0x0008 -#define PyBUF_STRIDES (0x0010 | PyBUF_ND) -#define PyBUF_C_CONTIGUOUS (0x0020 | PyBUF_STRIDES) -#define PyBUF_F_CONTIGUOUS (0x0040 | PyBUF_STRIDES) -#define PyBUF_ANY_CONTIGUOUS (0x0080 | PyBUF_STRIDES) -#define PyBUF_INDIRECT (0x0100 | PyBUF_STRIDES) - -#define PyBUF_CONTIG (PyBUF_ND | PyBUF_WRITABLE) -#define PyBUF_CONTIG_RO (PyBUF_ND) - -#define PyBUF_STRIDED (PyBUF_STRIDES | PyBUF_WRITABLE) -#define PyBUF_STRIDED_RO (PyBUF_STRIDES) - -#define PyBUF_RECORDS (PyBUF_STRIDES | PyBUF_WRITABLE | PyBUF_FORMAT) -#define PyBUF_RECORDS_RO (PyBUF_STRIDES | PyBUF_FORMAT) - -#define PyBUF_FULL (PyBUF_INDIRECT | PyBUF_WRITABLE | PyBUF_FORMAT) -#define PyBUF_FULL_RO (PyBUF_INDIRECT | PyBUF_FORMAT) - - -#define PyBUF_READ 0x100 -#define PyBUF_WRITE 0x200 -#define PyBUF_SHADOW 0x400 -/* end Py3k buffer interface */ - -typedef int (*objobjproc)(PyObject *, PyObject *); -typedef int (*visitproc)(PyObject *, void *); -typedef int (*traverseproc)(PyObject *, visitproc, void *); - -typedef struct { - /* For numbers without flag bit Py_TPFLAGS_CHECKTYPES set, all - arguments are guaranteed to be of the object's type (modulo - coercion hacks -- i.e. if the type's coercion function - returns other types, then these are allowed as well). Numbers that - have the Py_TPFLAGS_CHECKTYPES flag bit set should check *both* - arguments for proper type and implement the necessary conversions - in the slot functions themselves. */ - - binaryfunc nb_add; - binaryfunc nb_subtract; - binaryfunc nb_multiply; - binaryfunc nb_divide; - binaryfunc nb_remainder; - binaryfunc nb_divmod; - ternaryfunc nb_power; - unaryfunc nb_negative; - unaryfunc nb_positive; - unaryfunc nb_absolute; - inquiry nb_nonzero; - unaryfunc nb_invert; - binaryfunc nb_lshift; - binaryfunc nb_rshift; - binaryfunc nb_and; - binaryfunc nb_xor; - binaryfunc nb_or; - coercion nb_coerce; - unaryfunc nb_int; - unaryfunc nb_long; - unaryfunc nb_float; - unaryfunc nb_oct; - unaryfunc nb_hex; - /* Added in release 2.0 */ - binaryfunc nb_inplace_add; - binaryfunc nb_inplace_subtract; - binaryfunc nb_inplace_multiply; - binaryfunc nb_inplace_divide; - binaryfunc nb_inplace_remainder; - ternaryfunc nb_inplace_power; - binaryfunc nb_inplace_lshift; - binaryfunc nb_inplace_rshift; - binaryfunc nb_inplace_and; - binaryfunc nb_inplace_xor; - binaryfunc nb_inplace_or; - - /* Added in release 2.2 */ - /* The following require the Py_TPFLAGS_HAVE_CLASS flag */ - binaryfunc nb_floor_divide; - binaryfunc nb_true_divide; - binaryfunc nb_inplace_floor_divide; - binaryfunc nb_inplace_true_divide; - - /* Added in release 2.5 */ - unaryfunc nb_index; -} PyNumberMethods; - -typedef struct { - lenfunc sq_length; - binaryfunc sq_concat; - ssizeargfunc sq_repeat; - ssizeargfunc sq_item; - ssizessizeargfunc sq_slice; - ssizeobjargproc sq_ass_item; - ssizessizeobjargproc sq_ass_slice; - objobjproc sq_contains; - /* Added in release 2.0 */ - binaryfunc sq_inplace_concat; - ssizeargfunc sq_inplace_repeat; -} PySequenceMethods; - -typedef struct { - lenfunc mp_length; - binaryfunc mp_subscript; - objobjargproc mp_ass_subscript; -} PyMappingMethods; - -typedef struct { - readbufferproc bf_getreadbuffer; - writebufferproc bf_getwritebuffer; - segcountproc bf_getsegcount; - charbufferproc bf_getcharbuffer; - getbufferproc bf_getbuffer; - releasebufferproc bf_releasebuffer; -} PyBufferProcs; - - -typedef void (*freefunc)(void *); -typedef void (*destructor)(PyObject *); -typedef int (*printfunc)(PyObject *, FILE *, int); -typedef PyObject *(*getattrfunc)(PyObject *, char *); -typedef PyObject *(*getattrofunc)(PyObject *, PyObject *); -typedef int (*setattrfunc)(PyObject *, char *, PyObject *); -typedef int (*setattrofunc)(PyObject *, PyObject *, PyObject *); -typedef int (*cmpfunc)(PyObject *, PyObject *); -typedef PyObject *(*reprfunc)(PyObject *); -typedef long (*hashfunc)(PyObject *); -typedef PyObject *(*richcmpfunc) (PyObject *, PyObject *, int); -typedef PyObject *(*getiterfunc) (PyObject *); -typedef PyObject *(*iternextfunc) (PyObject *); -typedef PyObject *(*descrgetfunc) (PyObject *, PyObject *, PyObject *); -typedef int (*descrsetfunc) (PyObject *, PyObject *, PyObject *); -typedef int (*initproc)(PyObject *, PyObject *, PyObject *); -typedef PyObject *(*newfunc)(struct _typeobject *, PyObject *, PyObject *); -typedef PyObject *(*allocfunc)(struct _typeobject *, Py_ssize_t); - -typedef struct _typeobject { - PyObject_VAR_HEAD - const char *tp_name; /* For printing, in format "." */ - Py_ssize_t tp_basicsize, tp_itemsize; /* For allocation */ - - /* Methods to implement standard operations */ - - destructor tp_dealloc; - printfunc tp_print; - getattrfunc tp_getattr; - setattrfunc tp_setattr; - cmpfunc tp_compare; - reprfunc tp_repr; - - /* Method suites for standard classes */ - - PyNumberMethods *tp_as_number; - PySequenceMethods *tp_as_sequence; - PyMappingMethods *tp_as_mapping; - - /* More standard operations (here for binary compatibility) */ - - hashfunc tp_hash; - ternaryfunc tp_call; - reprfunc tp_str; - getattrofunc tp_getattro; - setattrofunc tp_setattro; - - /* Functions to access object as input/output buffer */ - PyBufferProcs *tp_as_buffer; - - /* Flags to define presence of optional/expanded features */ - long tp_flags; - - const char *tp_doc; /* Documentation string */ - - /* Assigned meaning in release 2.0 */ - /* call function for all accessible objects */ - traverseproc tp_traverse; - - /* delete references to contained objects */ - inquiry tp_clear; - - /* Assigned meaning in release 2.1 */ - /* rich comparisons */ - richcmpfunc tp_richcompare; - - /* weak reference enabler */ - Py_ssize_t tp_weaklistoffset; - - /* Added in release 2.2 */ - /* Iterators */ - getiterfunc tp_iter; - iternextfunc tp_iternext; - - /* Attribute descriptor and subclassing stuff */ - struct PyMethodDef *tp_methods; - struct PyMemberDef *tp_members; - struct PyGetSetDef *tp_getset; - struct _typeobject *tp_base; - PyObject *tp_dict; - descrgetfunc tp_descr_get; - descrsetfunc tp_descr_set; - Py_ssize_t tp_dictoffset; - initproc tp_init; - allocfunc tp_alloc; - newfunc tp_new; - freefunc tp_free; /* Low-level free-memory routine */ - inquiry tp_is_gc; /* For PyObject_IS_GC */ - PyObject *tp_bases; - PyObject *tp_mro; /* method resolution order */ - PyObject *tp_cache; - PyObject *tp_subclasses; - PyObject *tp_weaklist; - destructor tp_del; - - /* Type attribute cache version tag. Added in version 2.6 */ - unsigned int tp_version_tag; - -#ifdef COUNT_ALLOCS - /* these must be last and never explicitly initialized */ - Py_ssize_t tp_allocs; - Py_ssize_t tp_frees; - Py_ssize_t tp_maxalloc; - struct _typeobject *tp_prev; - struct _typeobject *tp_next; -#endif -} PyTypeObject; - - -/* The *real* layout of a type object when allocated on the heap */ -typedef struct _heaptypeobject { - /* Note: there's a dependency on the order of these members - in slotptr() in typeobject.c . */ - PyTypeObject ht_type; - PyNumberMethods as_number; - PyMappingMethods as_mapping; - PySequenceMethods as_sequence; /* as_sequence comes after as_mapping, - so that the mapping wins when both - the mapping and the sequence define - a given operator (e.g. __getitem__). - see add_operators() in typeobject.c . */ - PyBufferProcs as_buffer; - PyObject *ht_name, *ht_slots; - /* here are optional user slots, followed by the members. */ -} PyHeapTypeObject; - -/* access macro to the members which are floating "behind" the object */ -#define PyHeapType_GET_MEMBERS(etype) \ - ((PyMemberDef *)(((char *)etype) + Py_TYPE(etype)->tp_basicsize)) - - -/* Generic type check */ -PyAPI_FUNC(int) PyType_IsSubtype(PyTypeObject *, PyTypeObject *); -#define PyObject_TypeCheck(ob, tp) \ - (Py_TYPE(ob) == (tp) || PyType_IsSubtype(Py_TYPE(ob), (tp))) - -PyAPI_DATA(PyTypeObject) PyType_Type; /* built-in 'type' */ -PyAPI_DATA(PyTypeObject) PyBaseObject_Type; /* built-in 'object' */ -PyAPI_DATA(PyTypeObject) PySuper_Type; /* built-in 'super' */ - -#define PyType_Check(op) \ - PyType_FastSubclass(Py_TYPE(op), Py_TPFLAGS_TYPE_SUBCLASS) -#define PyType_CheckExact(op) (Py_TYPE(op) == &PyType_Type) - -PyAPI_FUNC(int) PyType_Ready(PyTypeObject *); -PyAPI_FUNC(PyObject *) PyType_GenericAlloc(PyTypeObject *, Py_ssize_t); -PyAPI_FUNC(PyObject *) PyType_GenericNew(PyTypeObject *, - PyObject *, PyObject *); -PyAPI_FUNC(PyObject *) _PyType_Lookup(PyTypeObject *, PyObject *); -PyAPI_FUNC(PyObject *) _PyObject_LookupSpecial(PyObject *, char *, PyObject **); -PyAPI_FUNC(unsigned int) PyType_ClearCache(void); -PyAPI_FUNC(void) PyType_Modified(PyTypeObject *); - -/* Generic operations on objects */ -PyAPI_FUNC(int) PyObject_Print(PyObject *, FILE *, int); -PyAPI_FUNC(void) _PyObject_Dump(PyObject *); -PyAPI_FUNC(PyObject *) PyObject_Repr(PyObject *); -PyAPI_FUNC(PyObject *) _PyObject_Str(PyObject *); -PyAPI_FUNC(PyObject *) PyObject_Str(PyObject *); -#define PyObject_Bytes PyObject_Str -#ifdef Py_USING_UNICODE -PyAPI_FUNC(PyObject *) PyObject_Unicode(PyObject *); -#endif -PyAPI_FUNC(int) PyObject_Compare(PyObject *, PyObject *); -PyAPI_FUNC(PyObject *) PyObject_RichCompare(PyObject *, PyObject *, int); -PyAPI_FUNC(int) PyObject_RichCompareBool(PyObject *, PyObject *, int); -PyAPI_FUNC(PyObject *) PyObject_GetAttrString(PyObject *, const char *); -PyAPI_FUNC(int) PyObject_SetAttrString(PyObject *, const char *, PyObject *); -PyAPI_FUNC(int) PyObject_HasAttrString(PyObject *, const char *); -PyAPI_FUNC(PyObject *) PyObject_GetAttr(PyObject *, PyObject *); -PyAPI_FUNC(int) PyObject_SetAttr(PyObject *, PyObject *, PyObject *); -PyAPI_FUNC(int) PyObject_HasAttr(PyObject *, PyObject *); -PyAPI_FUNC(PyObject **) _PyObject_GetDictPtr(PyObject *); -PyAPI_FUNC(PyObject *) PyObject_SelfIter(PyObject *); -PyAPI_FUNC(PyObject *) _PyObject_NextNotImplemented(PyObject *); -PyAPI_FUNC(PyObject *) PyObject_GenericGetAttr(PyObject *, PyObject *); -PyAPI_FUNC(int) PyObject_GenericSetAttr(PyObject *, - PyObject *, PyObject *); -PyAPI_FUNC(long) PyObject_Hash(PyObject *); -PyAPI_FUNC(long) PyObject_HashNotImplemented(PyObject *); -PyAPI_FUNC(int) PyObject_IsTrue(PyObject *); -PyAPI_FUNC(int) PyObject_Not(PyObject *); -PyAPI_FUNC(int) PyCallable_Check(PyObject *); -PyAPI_FUNC(int) PyNumber_Coerce(PyObject **, PyObject **); -PyAPI_FUNC(int) PyNumber_CoerceEx(PyObject **, PyObject **); - -PyAPI_FUNC(void) PyObject_ClearWeakRefs(PyObject *); - -/* A slot function whose address we need to compare */ -extern int _PyObject_SlotCompare(PyObject *, PyObject *); -/* Same as PyObject_Generic{Get,Set}Attr, but passing the attributes - dict as the last parameter. */ -PyAPI_FUNC(PyObject *) -_PyObject_GenericGetAttrWithDict(PyObject *, PyObject *, PyObject *); -PyAPI_FUNC(int) -_PyObject_GenericSetAttrWithDict(PyObject *, PyObject *, - PyObject *, PyObject *); - - -/* PyObject_Dir(obj) acts like Python __builtin__.dir(obj), returning a - list of strings. PyObject_Dir(NULL) is like __builtin__.dir(), - returning the names of the current locals. In this case, if there are - no current locals, NULL is returned, and PyErr_Occurred() is false. -*/ -PyAPI_FUNC(PyObject *) PyObject_Dir(PyObject *); - - -/* Helpers for printing recursive container types */ -PyAPI_FUNC(int) Py_ReprEnter(PyObject *); -PyAPI_FUNC(void) Py_ReprLeave(PyObject *); - -/* Helpers for hash functions */ -PyAPI_FUNC(long) _Py_HashDouble(double); -PyAPI_FUNC(long) _Py_HashPointer(void*); - -typedef struct { - long prefix; - long suffix; -} _Py_HashSecret_t; -PyAPI_DATA(_Py_HashSecret_t) _Py_HashSecret; - -#ifdef Py_DEBUG -PyAPI_DATA(int) _Py_HashSecret_Initialized; -#endif - -/* Helper for passing objects to printf and the like */ -#define PyObject_REPR(obj) PyString_AS_STRING(PyObject_Repr(obj)) - -/* Flag bits for printing: */ -#define Py_PRINT_RAW 1 /* No string quotes etc. */ - -/* -`Type flags (tp_flags) - -These flags are used to extend the type structure in a backwards-compatible -fashion. Extensions can use the flags to indicate (and test) when a given -type structure contains a new feature. The Python core will use these when -introducing new functionality between major revisions (to avoid mid-version -changes in the PYTHON_API_VERSION). - -Arbitration of the flag bit positions will need to be coordinated among -all extension writers who publically release their extensions (this will -be fewer than you might expect!).. - -Python 1.5.2 introduced the bf_getcharbuffer slot into PyBufferProcs. - -Type definitions should use Py_TPFLAGS_DEFAULT for their tp_flags value. - -Code can use PyType_HasFeature(type_ob, flag_value) to test whether the -given type object has a specified feature. - -NOTE: when building the core, Py_TPFLAGS_DEFAULT includes -Py_TPFLAGS_HAVE_VERSION_TAG; outside the core, it doesn't. This is so -that extensions that modify tp_dict of their own types directly don't -break, since this was allowed in 2.5. In 3.0 they will have to -manually remove this flag though! -*/ - -/* PyBufferProcs contains bf_getcharbuffer */ -#define Py_TPFLAGS_HAVE_GETCHARBUFFER (1L<<0) - -/* PySequenceMethods contains sq_contains */ -#define Py_TPFLAGS_HAVE_SEQUENCE_IN (1L<<1) - -/* This is here for backwards compatibility. Extensions that use the old GC - * API will still compile but the objects will not be tracked by the GC. */ -#define Py_TPFLAGS_GC 0 /* used to be (1L<<2) */ - -/* PySequenceMethods and PyNumberMethods contain in-place operators */ -#define Py_TPFLAGS_HAVE_INPLACEOPS (1L<<3) - -/* PyNumberMethods do their own coercion */ -#define Py_TPFLAGS_CHECKTYPES (1L<<4) - -/* tp_richcompare is defined */ -#define Py_TPFLAGS_HAVE_RICHCOMPARE (1L<<5) - -/* Objects which are weakly referencable if their tp_weaklistoffset is >0 */ -#define Py_TPFLAGS_HAVE_WEAKREFS (1L<<6) - -/* tp_iter is defined */ -#define Py_TPFLAGS_HAVE_ITER (1L<<7) - -/* New members introduced by Python 2.2 exist */ -#define Py_TPFLAGS_HAVE_CLASS (1L<<8) - -/* Set if the type object is dynamically allocated */ -#define Py_TPFLAGS_HEAPTYPE (1L<<9) - -/* Set if the type allows subclassing */ -#define Py_TPFLAGS_BASETYPE (1L<<10) - -/* Set if the type is 'ready' -- fully initialized */ -#define Py_TPFLAGS_READY (1L<<12) - -/* Set while the type is being 'readied', to prevent recursive ready calls */ -#define Py_TPFLAGS_READYING (1L<<13) - -/* Objects support garbage collection (see objimp.h) */ -#define Py_TPFLAGS_HAVE_GC (1L<<14) - -/* These two bits are preserved for Stackless Python, next after this is 17 */ -#ifdef STACKLESS -#define Py_TPFLAGS_HAVE_STACKLESS_EXTENSION (3L<<15) -#else -#define Py_TPFLAGS_HAVE_STACKLESS_EXTENSION 0 -#endif - -/* Objects support nb_index in PyNumberMethods */ -#define Py_TPFLAGS_HAVE_INDEX (1L<<17) - -/* Objects support type attribute cache */ -#define Py_TPFLAGS_HAVE_VERSION_TAG (1L<<18) -#define Py_TPFLAGS_VALID_VERSION_TAG (1L<<19) - -/* Type is abstract and cannot be instantiated */ -#define Py_TPFLAGS_IS_ABSTRACT (1L<<20) - -/* Has the new buffer protocol */ -#define Py_TPFLAGS_HAVE_NEWBUFFER (1L<<21) - -/* These flags are used to determine if a type is a subclass. */ -#define Py_TPFLAGS_INT_SUBCLASS (1L<<23) -#define Py_TPFLAGS_LONG_SUBCLASS (1L<<24) -#define Py_TPFLAGS_LIST_SUBCLASS (1L<<25) -#define Py_TPFLAGS_TUPLE_SUBCLASS (1L<<26) -#define Py_TPFLAGS_STRING_SUBCLASS (1L<<27) -#define Py_TPFLAGS_UNICODE_SUBCLASS (1L<<28) -#define Py_TPFLAGS_DICT_SUBCLASS (1L<<29) -#define Py_TPFLAGS_BASE_EXC_SUBCLASS (1L<<30) -#define Py_TPFLAGS_TYPE_SUBCLASS (1L<<31) - -#define Py_TPFLAGS_DEFAULT_EXTERNAL ( \ - Py_TPFLAGS_HAVE_GETCHARBUFFER | \ - Py_TPFLAGS_HAVE_SEQUENCE_IN | \ - Py_TPFLAGS_HAVE_INPLACEOPS | \ - Py_TPFLAGS_HAVE_RICHCOMPARE | \ - Py_TPFLAGS_HAVE_WEAKREFS | \ - Py_TPFLAGS_HAVE_ITER | \ - Py_TPFLAGS_HAVE_CLASS | \ - Py_TPFLAGS_HAVE_STACKLESS_EXTENSION | \ - Py_TPFLAGS_HAVE_INDEX | \ - 0) -#define Py_TPFLAGS_DEFAULT_CORE (Py_TPFLAGS_DEFAULT_EXTERNAL | \ - Py_TPFLAGS_HAVE_VERSION_TAG) - -#ifdef Py_BUILD_CORE -#define Py_TPFLAGS_DEFAULT Py_TPFLAGS_DEFAULT_CORE -#else -#define Py_TPFLAGS_DEFAULT Py_TPFLAGS_DEFAULT_EXTERNAL -#endif - -#define PyType_HasFeature(t,f) (((t)->tp_flags & (f)) != 0) -#define PyType_FastSubclass(t,f) PyType_HasFeature(t,f) - - -/* -The macros Py_INCREF(op) and Py_DECREF(op) are used to increment or decrement -reference counts. Py_DECREF calls the object's deallocator function when -the refcount falls to 0; for -objects that don't contain references to other objects or heap memory -this can be the standard function free(). Both macros can be used -wherever a void expression is allowed. The argument must not be a -NULL pointer. If it may be NULL, use Py_XINCREF/Py_XDECREF instead. -The macro _Py_NewReference(op) initialize reference counts to 1, and -in special builds (Py_REF_DEBUG, Py_TRACE_REFS) performs additional -bookkeeping appropriate to the special build. - -We assume that the reference count field can never overflow; this can -be proven when the size of the field is the same as the pointer size, so -we ignore the possibility. Provided a C int is at least 32 bits (which -is implicitly assumed in many parts of this code), that's enough for -about 2**31 references to an object. - -XXX The following became out of date in Python 2.2, but I'm not sure -XXX what the full truth is now. Certainly, heap-allocated type objects -XXX can and should be deallocated. -Type objects should never be deallocated; the type pointer in an object -is not considered to be a reference to the type object, to save -complications in the deallocation function. (This is actually a -decision that's up to the implementer of each new type so if you want, -you can count such references to the type object.) - -*** WARNING*** The Py_DECREF macro must have a side-effect-free argument -since it may evaluate its argument multiple times. (The alternative -would be to mace it a proper function or assign it to a global temporary -variable first, both of which are slower; and in a multi-threaded -environment the global variable trick is not safe.) -*/ - -/* First define a pile of simple helper macros, one set per special - * build symbol. These either expand to the obvious things, or to - * nothing at all when the special mode isn't in effect. The main - * macros can later be defined just once then, yet expand to different - * things depending on which special build options are and aren't in effect. - * Trust me : while painful, this is 20x easier to understand than, - * e.g, defining _Py_NewReference five different times in a maze of nested - * #ifdefs (we used to do that -- it was impenetrable). - */ -#ifdef Py_REF_DEBUG -PyAPI_DATA(Py_ssize_t) _Py_RefTotal; -PyAPI_FUNC(void) _Py_NegativeRefcount(const char *fname, - int lineno, PyObject *op); -PyAPI_FUNC(PyObject *) _PyDict_Dummy(void); -PyAPI_FUNC(PyObject *) _PySet_Dummy(void); -PyAPI_FUNC(Py_ssize_t) _Py_GetRefTotal(void); -#define _Py_INC_REFTOTAL _Py_RefTotal++ -#define _Py_DEC_REFTOTAL _Py_RefTotal-- -#define _Py_REF_DEBUG_COMMA , -#define _Py_CHECK_REFCNT(OP) \ -{ if (((PyObject*)OP)->ob_refcnt < 0) \ - _Py_NegativeRefcount(__FILE__, __LINE__, \ - (PyObject *)(OP)); \ -} -#else -#define _Py_INC_REFTOTAL -#define _Py_DEC_REFTOTAL -#define _Py_REF_DEBUG_COMMA -#define _Py_CHECK_REFCNT(OP) /* a semicolon */; -#endif /* Py_REF_DEBUG */ - -#ifdef COUNT_ALLOCS -PyAPI_FUNC(void) inc_count(PyTypeObject *); -PyAPI_FUNC(void) dec_count(PyTypeObject *); -#define _Py_INC_TPALLOCS(OP) inc_count(Py_TYPE(OP)) -#define _Py_INC_TPFREES(OP) dec_count(Py_TYPE(OP)) -#define _Py_DEC_TPFREES(OP) Py_TYPE(OP)->tp_frees-- -#define _Py_COUNT_ALLOCS_COMMA , -#else -#define _Py_INC_TPALLOCS(OP) -#define _Py_INC_TPFREES(OP) -#define _Py_DEC_TPFREES(OP) -#define _Py_COUNT_ALLOCS_COMMA -#endif /* COUNT_ALLOCS */ - -#ifdef Py_TRACE_REFS -/* Py_TRACE_REFS is such major surgery that we call external routines. */ -PyAPI_FUNC(void) _Py_NewReference(PyObject *); -PyAPI_FUNC(void) _Py_ForgetReference(PyObject *); -PyAPI_FUNC(void) _Py_Dealloc(PyObject *); -PyAPI_FUNC(void) _Py_PrintReferences(FILE *); -PyAPI_FUNC(void) _Py_PrintReferenceAddresses(FILE *); -PyAPI_FUNC(void) _Py_AddToAllObjects(PyObject *, int force); - -#else -/* Without Py_TRACE_REFS, there's little enough to do that we expand code - * inline. - */ -#define _Py_NewReference(op) ( \ - _Py_INC_TPALLOCS(op) _Py_COUNT_ALLOCS_COMMA \ - _Py_INC_REFTOTAL _Py_REF_DEBUG_COMMA \ - Py_REFCNT(op) = 1) - -#define _Py_ForgetReference(op) _Py_INC_TPFREES(op) - -#define _Py_Dealloc(op) ( \ - _Py_INC_TPFREES(op) _Py_COUNT_ALLOCS_COMMA \ - (*Py_TYPE(op)->tp_dealloc)((PyObject *)(op))) -#endif /* !Py_TRACE_REFS */ - -#define Py_INCREF(op) ( \ - _Py_INC_REFTOTAL _Py_REF_DEBUG_COMMA \ - ((PyObject*)(op))->ob_refcnt++) - -#define Py_DECREF(op) \ - do { \ - if (_Py_DEC_REFTOTAL _Py_REF_DEBUG_COMMA \ - --((PyObject*)(op))->ob_refcnt != 0) \ - _Py_CHECK_REFCNT(op) \ - else \ - _Py_Dealloc((PyObject *)(op)); \ - } while (0) - -/* Safely decref `op` and set `op` to NULL, especially useful in tp_clear - * and tp_dealloc implementatons. - * - * Note that "the obvious" code can be deadly: - * - * Py_XDECREF(op); - * op = NULL; - * - * Typically, `op` is something like self->containee, and `self` is done - * using its `containee` member. In the code sequence above, suppose - * `containee` is non-NULL with a refcount of 1. Its refcount falls to - * 0 on the first line, which can trigger an arbitrary amount of code, - * possibly including finalizers (like __del__ methods or weakref callbacks) - * coded in Python, which in turn can release the GIL and allow other threads - * to run, etc. Such code may even invoke methods of `self` again, or cause - * cyclic gc to trigger, but-- oops! --self->containee still points to the - * object being torn down, and it may be in an insane state while being torn - * down. This has in fact been a rich historic source of miserable (rare & - * hard-to-diagnose) segfaulting (and other) bugs. - * - * The safe way is: - * - * Py_CLEAR(op); - * - * That arranges to set `op` to NULL _before_ decref'ing, so that any code - * triggered as a side-effect of `op` getting torn down no longer believes - * `op` points to a valid object. - * - * There are cases where it's safe to use the naive code, but they're brittle. - * For example, if `op` points to a Python integer, you know that destroying - * one of those can't cause problems -- but in part that relies on that - * Python integers aren't currently weakly referencable. Best practice is - * to use Py_CLEAR() even if you can't think of a reason for why you need to. - */ -#define Py_CLEAR(op) \ - do { \ - if (op) { \ - PyObject *_py_tmp = (PyObject *)(op); \ - (op) = NULL; \ - Py_DECREF(_py_tmp); \ - } \ - } while (0) - -/* Macros to use in case the object pointer may be NULL: */ -#define Py_XINCREF(op) do { if ((op) == NULL) ; else Py_INCREF(op); } while (0) -#define Py_XDECREF(op) do { if ((op) == NULL) ; else Py_DECREF(op); } while (0) - -/* -These are provided as conveniences to Python runtime embedders, so that -they can have object code that is not dependent on Python compilation flags. -*/ -PyAPI_FUNC(void) Py_IncRef(PyObject *); -PyAPI_FUNC(void) Py_DecRef(PyObject *); - -/* -_Py_NoneStruct is an object of undefined type which can be used in contexts -where NULL (nil) is not suitable (since NULL often means 'error'). - -Don't forget to apply Py_INCREF() when returning this value!!! -*/ -PyAPI_DATA(PyObject) _Py_NoneStruct; /* Don't use this directly */ -#define Py_None (&_Py_NoneStruct) - -/* Macro for returning Py_None from a function */ -#define Py_RETURN_NONE return Py_INCREF(Py_None), Py_None - -/* -Py_NotImplemented is a singleton used to signal that an operation is -not implemented for a given type combination. -*/ -PyAPI_DATA(PyObject) _Py_NotImplementedStruct; /* Don't use this directly */ -#define Py_NotImplemented (&_Py_NotImplementedStruct) - -/* Rich comparison opcodes */ -#define Py_LT 0 -#define Py_LE 1 -#define Py_EQ 2 -#define Py_NE 3 -#define Py_GT 4 -#define Py_GE 5 - -/* Maps Py_LT to Py_GT, ..., Py_GE to Py_LE. - * Defined in object.c. - */ -PyAPI_DATA(int) _Py_SwappedOp[]; - -/* -Define staticforward and statichere for source compatibility with old -C extensions. - -The staticforward define was needed to support certain broken C -compilers (notably SCO ODT 3.0, perhaps early AIX as well) botched the -static keyword when it was used with a forward declaration of a static -initialized structure. Standard C allows the forward declaration with -static, and we've decided to stop catering to broken C compilers. -(In fact, we expect that the compilers are all fixed eight years later.) -*/ - -#define staticforward static -#define statichere static - - -/* -More conventions -================ - -Argument Checking ------------------ - -Functions that take objects as arguments normally don't check for nil -arguments, but they do check the type of the argument, and return an -error if the function doesn't apply to the type. - -Failure Modes -------------- - -Functions may fail for a variety of reasons, including running out of -memory. This is communicated to the caller in two ways: an error string -is set (see errors.h), and the function result differs: functions that -normally return a pointer return NULL for failure, functions returning -an integer return -1 (which could be a legal return value too!), and -other functions return 0 for success and -1 for failure. -Callers should always check for errors before using the result. If -an error was set, the caller must either explicitly clear it, or pass -the error on to its caller. - -Reference Counts ----------------- - -It takes a while to get used to the proper usage of reference counts. - -Functions that create an object set the reference count to 1; such new -objects must be stored somewhere or destroyed again with Py_DECREF(). -Some functions that 'store' objects, such as PyTuple_SetItem() and -PyList_SetItem(), -don't increment the reference count of the object, since the most -frequent use is to store a fresh object. Functions that 'retrieve' -objects, such as PyTuple_GetItem() and PyDict_GetItemString(), also -don't increment -the reference count, since most frequently the object is only looked at -quickly. Thus, to retrieve an object and store it again, the caller -must call Py_INCREF() explicitly. - -NOTE: functions that 'consume' a reference count, like -PyList_SetItem(), consume the reference even if the object wasn't -successfully stored, to simplify error handling. - -It seems attractive to make other functions that take an object as -argument consume a reference count; however, this may quickly get -confusing (even the current practice is already confusing). Consider -it carefully, it may save lots of calls to Py_INCREF() and Py_DECREF() at -times. -*/ - - -/* Trashcan mechanism, thanks to Christian Tismer. - -When deallocating a container object, it's possible to trigger an unbounded -chain of deallocations, as each Py_DECREF in turn drops the refcount on "the -next" object in the chain to 0. This can easily lead to stack faults, and -especially in threads (which typically have less stack space to work with). - -A container object that participates in cyclic gc can avoid this by -bracketing the body of its tp_dealloc function with a pair of macros: - -static void -mytype_dealloc(mytype *p) -{ - ... declarations go here ... - - PyObject_GC_UnTrack(p); // must untrack first - Py_TRASHCAN_SAFE_BEGIN(p) - ... The body of the deallocator goes here, including all calls ... - ... to Py_DECREF on contained objects. ... - Py_TRASHCAN_SAFE_END(p) -} - -CAUTION: Never return from the middle of the body! If the body needs to -"get out early", put a label immediately before the Py_TRASHCAN_SAFE_END -call, and goto it. Else the call-depth counter (see below) will stay -above 0 forever, and the trashcan will never get emptied. - -How it works: The BEGIN macro increments a call-depth counter. So long -as this counter is small, the body of the deallocator is run directly without -further ado. But if the counter gets large, it instead adds p to a list of -objects to be deallocated later, skips the body of the deallocator, and -resumes execution after the END macro. The tp_dealloc routine then returns -without deallocating anything (and so unbounded call-stack depth is avoided). - -When the call stack finishes unwinding again, code generated by the END macro -notices this, and calls another routine to deallocate all the objects that -may have been added to the list of deferred deallocations. In effect, a -chain of N deallocations is broken into N / PyTrash_UNWIND_LEVEL pieces, -with the call stack never exceeding a depth of PyTrash_UNWIND_LEVEL. -*/ - -PyAPI_FUNC(void) _PyTrash_deposit_object(PyObject*); -PyAPI_FUNC(void) _PyTrash_destroy_chain(void); -PyAPI_DATA(int) _PyTrash_delete_nesting; -PyAPI_DATA(PyObject *) _PyTrash_delete_later; - -#define PyTrash_UNWIND_LEVEL 50 - -#define Py_TRASHCAN_SAFE_BEGIN(op) \ - if (_PyTrash_delete_nesting < PyTrash_UNWIND_LEVEL) { \ - ++_PyTrash_delete_nesting; - /* The body of the deallocator is here. */ -#define Py_TRASHCAN_SAFE_END(op) \ - --_PyTrash_delete_nesting; \ - if (_PyTrash_delete_later && _PyTrash_delete_nesting <= 0) \ - _PyTrash_destroy_chain(); \ - } \ - else \ - _PyTrash_deposit_object((PyObject*)op); - -#ifdef __cplusplus -} -#endif -#endif /* !Py_OBJECT_H */ diff --git a/python/include/objimpl.h b/python/include/objimpl.h deleted file mode 100644 index 55e83ece..00000000 --- a/python/include/objimpl.h +++ /dev/null @@ -1,354 +0,0 @@ -/* The PyObject_ memory family: high-level object memory interfaces. - See pymem.h for the low-level PyMem_ family. -*/ - -#ifndef Py_OBJIMPL_H -#define Py_OBJIMPL_H - -#include "pymem.h" - -#ifdef __cplusplus -extern "C" { -#endif - -/* BEWARE: - - Each interface exports both functions and macros. Extension modules should - use the functions, to ensure binary compatibility across Python versions. - Because the Python implementation is free to change internal details, and - the macros may (or may not) expose details for speed, if you do use the - macros you must recompile your extensions with each Python release. - - Never mix calls to PyObject_ memory functions with calls to the platform - malloc/realloc/ calloc/free, or with calls to PyMem_. -*/ - -/* -Functions and macros for modules that implement new object types. - - - PyObject_New(type, typeobj) allocates memory for a new object of the given - type, and initializes part of it. 'type' must be the C structure type used - to represent the object, and 'typeobj' the address of the corresponding - type object. Reference count and type pointer are filled in; the rest of - the bytes of the object are *undefined*! The resulting expression type is - 'type *'. The size of the object is determined by the tp_basicsize field - of the type object. - - - PyObject_NewVar(type, typeobj, n) is similar but allocates a variable-size - object with room for n items. In addition to the refcount and type pointer - fields, this also fills in the ob_size field. - - - PyObject_Del(op) releases the memory allocated for an object. It does not - run a destructor -- it only frees the memory. PyObject_Free is identical. - - - PyObject_Init(op, typeobj) and PyObject_InitVar(op, typeobj, n) don't - allocate memory. Instead of a 'type' parameter, they take a pointer to a - new object (allocated by an arbitrary allocator), and initialize its object - header fields. - -Note that objects created with PyObject_{New, NewVar} are allocated using the -specialized Python allocator (implemented in obmalloc.c), if WITH_PYMALLOC is -enabled. In addition, a special debugging allocator is used if PYMALLOC_DEBUG -is also #defined. - -In case a specific form of memory management is needed (for example, if you -must use the platform malloc heap(s), or shared memory, or C++ local storage or -operator new), you must first allocate the object with your custom allocator, -then pass its pointer to PyObject_{Init, InitVar} for filling in its Python- -specific fields: reference count, type pointer, possibly others. You should -be aware that Python no control over these objects because they don't -cooperate with the Python memory manager. Such objects may not be eligible -for automatic garbage collection and you have to make sure that they are -released accordingly whenever their destructor gets called (cf. the specific -form of memory management you're using). - -Unless you have specific memory management requirements, use -PyObject_{New, NewVar, Del}. -*/ - -/* - * Raw object memory interface - * =========================== - */ - -/* Functions to call the same malloc/realloc/free as used by Python's - object allocator. If WITH_PYMALLOC is enabled, these may differ from - the platform malloc/realloc/free. The Python object allocator is - designed for fast, cache-conscious allocation of many "small" objects, - and with low hidden memory overhead. - - PyObject_Malloc(0) returns a unique non-NULL pointer if possible. - - PyObject_Realloc(NULL, n) acts like PyObject_Malloc(n). - PyObject_Realloc(p != NULL, 0) does not return NULL, or free the memory - at p. - - Returned pointers must be checked for NULL explicitly; no action is - performed on failure other than to return NULL (no warning it printed, no - exception is set, etc). - - For allocating objects, use PyObject_{New, NewVar} instead whenever - possible. The PyObject_{Malloc, Realloc, Free} family is exposed - so that you can exploit Python's small-block allocator for non-object - uses. If you must use these routines to allocate object memory, make sure - the object gets initialized via PyObject_{Init, InitVar} after obtaining - the raw memory. -*/ -PyAPI_FUNC(void *) PyObject_Malloc(size_t); -PyAPI_FUNC(void *) PyObject_Realloc(void *, size_t); -PyAPI_FUNC(void) PyObject_Free(void *); - - -/* Macros */ -#ifdef WITH_PYMALLOC -#ifdef PYMALLOC_DEBUG /* WITH_PYMALLOC && PYMALLOC_DEBUG */ -PyAPI_FUNC(void *) _PyObject_DebugMalloc(size_t nbytes); -PyAPI_FUNC(void *) _PyObject_DebugRealloc(void *p, size_t nbytes); -PyAPI_FUNC(void) _PyObject_DebugFree(void *p); -PyAPI_FUNC(void) _PyObject_DebugDumpAddress(const void *p); -PyAPI_FUNC(void) _PyObject_DebugCheckAddress(const void *p); -PyAPI_FUNC(void) _PyObject_DebugMallocStats(void); -PyAPI_FUNC(void *) _PyObject_DebugMallocApi(char api, size_t nbytes); -PyAPI_FUNC(void *) _PyObject_DebugReallocApi(char api, void *p, size_t nbytes); -PyAPI_FUNC(void) _PyObject_DebugFreeApi(char api, void *p); -PyAPI_FUNC(void) _PyObject_DebugCheckAddressApi(char api, const void *p); -PyAPI_FUNC(void *) _PyMem_DebugMalloc(size_t nbytes); -PyAPI_FUNC(void *) _PyMem_DebugRealloc(void *p, size_t nbytes); -PyAPI_FUNC(void) _PyMem_DebugFree(void *p); -#define PyObject_MALLOC _PyObject_DebugMalloc -#define PyObject_Malloc _PyObject_DebugMalloc -#define PyObject_REALLOC _PyObject_DebugRealloc -#define PyObject_Realloc _PyObject_DebugRealloc -#define PyObject_FREE _PyObject_DebugFree -#define PyObject_Free _PyObject_DebugFree - -#else /* WITH_PYMALLOC && ! PYMALLOC_DEBUG */ -#define PyObject_MALLOC PyObject_Malloc -#define PyObject_REALLOC PyObject_Realloc -#define PyObject_FREE PyObject_Free -#endif - -#else /* ! WITH_PYMALLOC */ -#define PyObject_MALLOC PyMem_MALLOC -#define PyObject_REALLOC PyMem_REALLOC -#define PyObject_FREE PyMem_FREE - -#endif /* WITH_PYMALLOC */ - -#define PyObject_Del PyObject_Free -#define PyObject_DEL PyObject_FREE - -/* for source compatibility with 2.2 */ -#define _PyObject_Del PyObject_Free - -/* - * Generic object allocator interface - * ================================== - */ - -/* Functions */ -PyAPI_FUNC(PyObject *) PyObject_Init(PyObject *, PyTypeObject *); -PyAPI_FUNC(PyVarObject *) PyObject_InitVar(PyVarObject *, - PyTypeObject *, Py_ssize_t); -PyAPI_FUNC(PyObject *) _PyObject_New(PyTypeObject *); -PyAPI_FUNC(PyVarObject *) _PyObject_NewVar(PyTypeObject *, Py_ssize_t); - -#define PyObject_New(type, typeobj) \ - ( (type *) _PyObject_New(typeobj) ) -#define PyObject_NewVar(type, typeobj, n) \ - ( (type *) _PyObject_NewVar((typeobj), (n)) ) - -/* Macros trading binary compatibility for speed. See also pymem.h. - Note that these macros expect non-NULL object pointers.*/ -#define PyObject_INIT(op, typeobj) \ - ( Py_TYPE(op) = (typeobj), _Py_NewReference((PyObject *)(op)), (op) ) -#define PyObject_INIT_VAR(op, typeobj, size) \ - ( Py_SIZE(op) = (size), PyObject_INIT((op), (typeobj)) ) - -#define _PyObject_SIZE(typeobj) ( (typeobj)->tp_basicsize ) - -/* _PyObject_VAR_SIZE returns the number of bytes (as size_t) allocated for a - vrbl-size object with nitems items, exclusive of gc overhead (if any). The - value is rounded up to the closest multiple of sizeof(void *), in order to - ensure that pointer fields at the end of the object are correctly aligned - for the platform (this is of special importance for subclasses of, e.g., - str or long, so that pointers can be stored after the embedded data). - - Note that there's no memory wastage in doing this, as malloc has to - return (at worst) pointer-aligned memory anyway. -*/ -#if ((SIZEOF_VOID_P - 1) & SIZEOF_VOID_P) != 0 -# error "_PyObject_VAR_SIZE requires SIZEOF_VOID_P be a power of 2" -#endif - -#define _PyObject_VAR_SIZE(typeobj, nitems) \ - (size_t) \ - ( ( (typeobj)->tp_basicsize + \ - (nitems)*(typeobj)->tp_itemsize + \ - (SIZEOF_VOID_P - 1) \ - ) & ~(SIZEOF_VOID_P - 1) \ - ) - -#define PyObject_NEW(type, typeobj) \ -( (type *) PyObject_Init( \ - (PyObject *) PyObject_MALLOC( _PyObject_SIZE(typeobj) ), (typeobj)) ) - -#define PyObject_NEW_VAR(type, typeobj, n) \ -( (type *) PyObject_InitVar( \ - (PyVarObject *) PyObject_MALLOC(_PyObject_VAR_SIZE((typeobj),(n)) ),\ - (typeobj), (n)) ) - -/* This example code implements an object constructor with a custom - allocator, where PyObject_New is inlined, and shows the important - distinction between two steps (at least): - 1) the actual allocation of the object storage; - 2) the initialization of the Python specific fields - in this storage with PyObject_{Init, InitVar}. - - PyObject * - YourObject_New(...) - { - PyObject *op; - - op = (PyObject *) Your_Allocator(_PyObject_SIZE(YourTypeStruct)); - if (op == NULL) - return PyErr_NoMemory(); - - PyObject_Init(op, &YourTypeStruct); - - op->ob_field = value; - ... - return op; - } - - Note that in C++, the use of the new operator usually implies that - the 1st step is performed automatically for you, so in a C++ class - constructor you would start directly with PyObject_Init/InitVar -*/ - -/* - * Garbage Collection Support - * ========================== - */ - -/* C equivalent of gc.collect(). */ -PyAPI_FUNC(Py_ssize_t) PyGC_Collect(void); - -/* Test if a type has a GC head */ -#define PyType_IS_GC(t) PyType_HasFeature((t), Py_TPFLAGS_HAVE_GC) - -/* Test if an object has a GC head */ -#define PyObject_IS_GC(o) (PyType_IS_GC(Py_TYPE(o)) && \ - (Py_TYPE(o)->tp_is_gc == NULL || Py_TYPE(o)->tp_is_gc(o))) - -PyAPI_FUNC(PyVarObject *) _PyObject_GC_Resize(PyVarObject *, Py_ssize_t); -#define PyObject_GC_Resize(type, op, n) \ - ( (type *) _PyObject_GC_Resize((PyVarObject *)(op), (n)) ) - -/* for source compatibility with 2.2 */ -#define _PyObject_GC_Del PyObject_GC_Del - -/* GC information is stored BEFORE the object structure. */ -typedef union _gc_head { - struct { - union _gc_head *gc_next; - union _gc_head *gc_prev; - Py_ssize_t gc_refs; - } gc; - long double dummy; /* force worst-case alignment */ -} PyGC_Head; - -extern PyGC_Head *_PyGC_generation0; - -#define _Py_AS_GC(o) ((PyGC_Head *)(o)-1) - -#define _PyGC_REFS_UNTRACKED (-2) -#define _PyGC_REFS_REACHABLE (-3) -#define _PyGC_REFS_TENTATIVELY_UNREACHABLE (-4) - -/* Tell the GC to track this object. NB: While the object is tracked the - * collector it must be safe to call the ob_traverse method. */ -#define _PyObject_GC_TRACK(o) do { \ - PyGC_Head *g = _Py_AS_GC(o); \ - if (g->gc.gc_refs != _PyGC_REFS_UNTRACKED) \ - Py_FatalError("GC object already tracked"); \ - g->gc.gc_refs = _PyGC_REFS_REACHABLE; \ - g->gc.gc_next = _PyGC_generation0; \ - g->gc.gc_prev = _PyGC_generation0->gc.gc_prev; \ - g->gc.gc_prev->gc.gc_next = g; \ - _PyGC_generation0->gc.gc_prev = g; \ - } while (0); - -/* Tell the GC to stop tracking this object. - * gc_next doesn't need to be set to NULL, but doing so is a good - * way to provoke memory errors if calling code is confused. - */ -#define _PyObject_GC_UNTRACK(o) do { \ - PyGC_Head *g = _Py_AS_GC(o); \ - assert(g->gc.gc_refs != _PyGC_REFS_UNTRACKED); \ - g->gc.gc_refs = _PyGC_REFS_UNTRACKED; \ - g->gc.gc_prev->gc.gc_next = g->gc.gc_next; \ - g->gc.gc_next->gc.gc_prev = g->gc.gc_prev; \ - g->gc.gc_next = NULL; \ - } while (0); - -/* True if the object is currently tracked by the GC. */ -#define _PyObject_GC_IS_TRACKED(o) \ - ((_Py_AS_GC(o))->gc.gc_refs != _PyGC_REFS_UNTRACKED) - -/* True if the object may be tracked by the GC in the future, or already is. - This can be useful to implement some optimizations. */ -#define _PyObject_GC_MAY_BE_TRACKED(obj) \ - (PyObject_IS_GC(obj) && \ - (!PyTuple_CheckExact(obj) || _PyObject_GC_IS_TRACKED(obj))) - - -PyAPI_FUNC(PyObject *) _PyObject_GC_Malloc(size_t); -PyAPI_FUNC(PyObject *) _PyObject_GC_New(PyTypeObject *); -PyAPI_FUNC(PyVarObject *) _PyObject_GC_NewVar(PyTypeObject *, Py_ssize_t); -PyAPI_FUNC(void) PyObject_GC_Track(void *); -PyAPI_FUNC(void) PyObject_GC_UnTrack(void *); -PyAPI_FUNC(void) PyObject_GC_Del(void *); - -#define PyObject_GC_New(type, typeobj) \ - ( (type *) _PyObject_GC_New(typeobj) ) -#define PyObject_GC_NewVar(type, typeobj, n) \ - ( (type *) _PyObject_GC_NewVar((typeobj), (n)) ) - - -/* Utility macro to help write tp_traverse functions. - * To use this macro, the tp_traverse function must name its arguments - * "visit" and "arg". This is intended to keep tp_traverse functions - * looking as much alike as possible. - */ -#define Py_VISIT(op) \ - do { \ - if (op) { \ - int vret = visit((PyObject *)(op), arg); \ - if (vret) \ - return vret; \ - } \ - } while (0) - -/* This is here for the sake of backwards compatibility. Extensions that - * use the old GC API will still compile but the objects will not be - * tracked by the GC. */ -#define PyGC_HEAD_SIZE 0 -#define PyObject_GC_Init(op) -#define PyObject_GC_Fini(op) -#define PyObject_AS_GC(op) (op) -#define PyObject_FROM_GC(op) (op) - - -/* Test if a type supports weak references */ -#define PyType_SUPPORTS_WEAKREFS(t) \ - (PyType_HasFeature((t), Py_TPFLAGS_HAVE_WEAKREFS) \ - && ((t)->tp_weaklistoffset > 0)) - -#define PyObject_GET_WEAKREFS_LISTPTR(o) \ - ((PyObject **) (((char *) (o)) + Py_TYPE(o)->tp_weaklistoffset)) - -#ifdef __cplusplus -} -#endif -#endif /* !Py_OBJIMPL_H */ diff --git a/python/include/opcode.h b/python/include/opcode.h deleted file mode 100644 index 9764109a..00000000 --- a/python/include/opcode.h +++ /dev/null @@ -1,162 +0,0 @@ -#ifndef Py_OPCODE_H -#define Py_OPCODE_H -#ifdef __cplusplus -extern "C" { -#endif - - -/* Instruction opcodes for compiled code */ - -#define STOP_CODE 0 -#define POP_TOP 1 -#define ROT_TWO 2 -#define ROT_THREE 3 -#define DUP_TOP 4 -#define ROT_FOUR 5 -#define NOP 9 - -#define UNARY_POSITIVE 10 -#define UNARY_NEGATIVE 11 -#define UNARY_NOT 12 -#define UNARY_CONVERT 13 - -#define UNARY_INVERT 15 - -#define BINARY_POWER 19 - -#define BINARY_MULTIPLY 20 -#define BINARY_DIVIDE 21 -#define BINARY_MODULO 22 -#define BINARY_ADD 23 -#define BINARY_SUBTRACT 24 -#define BINARY_SUBSCR 25 -#define BINARY_FLOOR_DIVIDE 26 -#define BINARY_TRUE_DIVIDE 27 -#define INPLACE_FLOOR_DIVIDE 28 -#define INPLACE_TRUE_DIVIDE 29 - -#define SLICE 30 -/* Also uses 31-33 */ - -#define STORE_SLICE 40 -/* Also uses 41-43 */ - -#define DELETE_SLICE 50 -/* Also uses 51-53 */ - -#define STORE_MAP 54 -#define INPLACE_ADD 55 -#define INPLACE_SUBTRACT 56 -#define INPLACE_MULTIPLY 57 -#define INPLACE_DIVIDE 58 -#define INPLACE_MODULO 59 -#define STORE_SUBSCR 60 -#define DELETE_SUBSCR 61 - -#define BINARY_LSHIFT 62 -#define BINARY_RSHIFT 63 -#define BINARY_AND 64 -#define BINARY_XOR 65 -#define BINARY_OR 66 -#define INPLACE_POWER 67 -#define GET_ITER 68 - -#define PRINT_EXPR 70 -#define PRINT_ITEM 71 -#define PRINT_NEWLINE 72 -#define PRINT_ITEM_TO 73 -#define PRINT_NEWLINE_TO 74 -#define INPLACE_LSHIFT 75 -#define INPLACE_RSHIFT 76 -#define INPLACE_AND 77 -#define INPLACE_XOR 78 -#define INPLACE_OR 79 -#define BREAK_LOOP 80 -#define WITH_CLEANUP 81 -#define LOAD_LOCALS 82 -#define RETURN_VALUE 83 -#define IMPORT_STAR 84 -#define EXEC_STMT 85 -#define YIELD_VALUE 86 -#define POP_BLOCK 87 -#define END_FINALLY 88 -#define BUILD_CLASS 89 - -#define HAVE_ARGUMENT 90 /* Opcodes from here have an argument: */ - -#define STORE_NAME 90 /* Index in name list */ -#define DELETE_NAME 91 /* "" */ -#define UNPACK_SEQUENCE 92 /* Number of sequence items */ -#define FOR_ITER 93 -#define LIST_APPEND 94 - -#define STORE_ATTR 95 /* Index in name list */ -#define DELETE_ATTR 96 /* "" */ -#define STORE_GLOBAL 97 /* "" */ -#define DELETE_GLOBAL 98 /* "" */ -#define DUP_TOPX 99 /* number of items to duplicate */ -#define LOAD_CONST 100 /* Index in const list */ -#define LOAD_NAME 101 /* Index in name list */ -#define BUILD_TUPLE 102 /* Number of tuple items */ -#define BUILD_LIST 103 /* Number of list items */ -#define BUILD_SET 104 /* Number of set items */ -#define BUILD_MAP 105 /* Always zero for now */ -#define LOAD_ATTR 106 /* Index in name list */ -#define COMPARE_OP 107 /* Comparison operator */ -#define IMPORT_NAME 108 /* Index in name list */ -#define IMPORT_FROM 109 /* Index in name list */ -#define JUMP_FORWARD 110 /* Number of bytes to skip */ - -#define JUMP_IF_FALSE_OR_POP 111 /* Target byte offset from beginning - of code */ -#define JUMP_IF_TRUE_OR_POP 112 /* "" */ -#define JUMP_ABSOLUTE 113 /* "" */ -#define POP_JUMP_IF_FALSE 114 /* "" */ -#define POP_JUMP_IF_TRUE 115 /* "" */ - -#define LOAD_GLOBAL 116 /* Index in name list */ - -#define CONTINUE_LOOP 119 /* Start of loop (absolute) */ -#define SETUP_LOOP 120 /* Target address (relative) */ -#define SETUP_EXCEPT 121 /* "" */ -#define SETUP_FINALLY 122 /* "" */ - -#define LOAD_FAST 124 /* Local variable number */ -#define STORE_FAST 125 /* Local variable number */ -#define DELETE_FAST 126 /* Local variable number */ - -#define RAISE_VARARGS 130 /* Number of raise arguments (1, 2 or 3) */ -/* CALL_FUNCTION_XXX opcodes defined below depend on this definition */ -#define CALL_FUNCTION 131 /* #args + (#kwargs<<8) */ -#define MAKE_FUNCTION 132 /* #defaults */ -#define BUILD_SLICE 133 /* Number of items */ - -#define MAKE_CLOSURE 134 /* #free vars */ -#define LOAD_CLOSURE 135 /* Load free variable from closure */ -#define LOAD_DEREF 136 /* Load and dereference from closure cell */ -#define STORE_DEREF 137 /* Store into cell */ - -/* The next 3 opcodes must be contiguous and satisfy - (CALL_FUNCTION_VAR - CALL_FUNCTION) & 3 == 1 */ -#define CALL_FUNCTION_VAR 140 /* #args + (#kwargs<<8) */ -#define CALL_FUNCTION_KW 141 /* #args + (#kwargs<<8) */ -#define CALL_FUNCTION_VAR_KW 142 /* #args + (#kwargs<<8) */ - -#define SETUP_WITH 143 - -/* Support for opargs more than 16 bits long */ -#define EXTENDED_ARG 145 - -#define SET_ADD 146 -#define MAP_ADD 147 - - -enum cmp_op {PyCmp_LT=Py_LT, PyCmp_LE=Py_LE, PyCmp_EQ=Py_EQ, PyCmp_NE=Py_NE, PyCmp_GT=Py_GT, PyCmp_GE=Py_GE, - PyCmp_IN, PyCmp_NOT_IN, PyCmp_IS, PyCmp_IS_NOT, PyCmp_EXC_MATCH, PyCmp_BAD}; - -#define HAS_ARG(op) ((op) >= HAVE_ARGUMENT) - -#ifdef __cplusplus -} -#endif -#endif /* !Py_OPCODE_H */ diff --git a/python/include/osdefs.h b/python/include/osdefs.h deleted file mode 100644 index 69376593..00000000 --- a/python/include/osdefs.h +++ /dev/null @@ -1,55 +0,0 @@ -#ifndef Py_OSDEFS_H -#define Py_OSDEFS_H -#ifdef __cplusplus -extern "C" { -#endif - - -/* Operating system dependencies */ - -/* Mod by chrish: QNX has WATCOM, but isn't DOS */ -#if !defined(__QNX__) -#if defined(MS_WINDOWS) || defined(__BORLANDC__) || defined(__WATCOMC__) || defined(__DJGPP__) || defined(PYOS_OS2) -#if defined(PYOS_OS2) && defined(PYCC_GCC) -#define MAXPATHLEN 260 -#define SEP '/' -#define ALTSEP '\\' -#else -#define SEP '\\' -#define ALTSEP '/' -#define MAXPATHLEN 256 -#endif -#define DELIM ';' -#endif -#endif - -#ifdef RISCOS -#define SEP '.' -#define MAXPATHLEN 256 -#define DELIM ',' -#endif - - -/* Filename separator */ -#ifndef SEP -#define SEP '/' -#endif - -/* Max pathname length */ -#ifndef MAXPATHLEN -#if defined(PATH_MAX) && PATH_MAX > 1024 -#define MAXPATHLEN PATH_MAX -#else -#define MAXPATHLEN 1024 -#endif -#endif - -/* Search path entry delimiter */ -#ifndef DELIM -#define DELIM ':' -#endif - -#ifdef __cplusplus -} -#endif -#endif /* !Py_OSDEFS_H */ diff --git a/python/include/parsetok.h b/python/include/parsetok.h deleted file mode 100644 index ec1eb6ff..00000000 --- a/python/include/parsetok.h +++ /dev/null @@ -1,64 +0,0 @@ - -/* Parser-tokenizer link interface */ - -#ifndef Py_PARSETOK_H -#define Py_PARSETOK_H -#ifdef __cplusplus -extern "C" { -#endif - -typedef struct { - int error; - const char *filename; - int lineno; - int offset; - char *text; - int token; - int expected; -} perrdetail; - -#if 0 -#define PyPARSE_YIELD_IS_KEYWORD 0x0001 -#endif - -#define PyPARSE_DONT_IMPLY_DEDENT 0x0002 - -#if 0 -#define PyPARSE_WITH_IS_KEYWORD 0x0003 -#endif - -#define PyPARSE_PRINT_IS_FUNCTION 0x0004 -#define PyPARSE_UNICODE_LITERALS 0x0008 - - - -PyAPI_FUNC(node *) PyParser_ParseString(const char *, grammar *, int, - perrdetail *); -PyAPI_FUNC(node *) PyParser_ParseFile (FILE *, const char *, grammar *, int, - char *, char *, perrdetail *); - -PyAPI_FUNC(node *) PyParser_ParseStringFlags(const char *, grammar *, int, - perrdetail *, int); -PyAPI_FUNC(node *) PyParser_ParseFileFlags(FILE *, const char *, grammar *, - int, char *, char *, - perrdetail *, int); -PyAPI_FUNC(node *) PyParser_ParseFileFlagsEx(FILE *, const char *, grammar *, - int, char *, char *, - perrdetail *, int *); - -PyAPI_FUNC(node *) PyParser_ParseStringFlagsFilename(const char *, - const char *, - grammar *, int, - perrdetail *, int); -PyAPI_FUNC(node *) PyParser_ParseStringFlagsFilenameEx(const char *, - const char *, - grammar *, int, - perrdetail *, int *); - -/* Note that he following function is defined in pythonrun.c not parsetok.c. */ -PyAPI_FUNC(void) PyParser_SetError(perrdetail *); - -#ifdef __cplusplus -} -#endif -#endif /* !Py_PARSETOK_H */ diff --git a/python/include/patchlevel.h b/python/include/patchlevel.h deleted file mode 100644 index 0a05696c..00000000 --- a/python/include/patchlevel.h +++ /dev/null @@ -1,43 +0,0 @@ - -/* Newfangled version identification scheme. - - This scheme was added in Python 1.5.2b2; before that time, only PATCHLEVEL - was available. To test for presence of the scheme, test for - defined(PY_MAJOR_VERSION). - - When the major or minor version changes, the VERSION variable in - configure.in must also be changed. - - There is also (independent) API version information in modsupport.h. -*/ - -/* Values for PY_RELEASE_LEVEL */ -#define PY_RELEASE_LEVEL_ALPHA 0xA -#define PY_RELEASE_LEVEL_BETA 0xB -#define PY_RELEASE_LEVEL_GAMMA 0xC /* For release candidates */ -#define PY_RELEASE_LEVEL_FINAL 0xF /* Serial should be 0 here */ - /* Higher for patch releases */ - -/* Version parsed out into numeric values */ -/*--start constants--*/ -#define PY_MAJOR_VERSION 2 -#define PY_MINOR_VERSION 7 -#define PY_MICRO_VERSION 3 -#define PY_RELEASE_LEVEL PY_RELEASE_LEVEL_FINAL -#define PY_RELEASE_SERIAL 0 - -/* Version as a string */ -#define PY_VERSION "2.7.3" -/*--end constants--*/ - -/* Subversion Revision number of this file (not of the repository). Empty - since Mercurial migration. */ -#define PY_PATCHLEVEL_REVISION "" - -/* Version as a single 4-byte hex number, e.g. 0x010502B2 == 1.5.2b2. - Use this for numeric comparisons, e.g. #if PY_VERSION_HEX >= ... */ -#define PY_VERSION_HEX ((PY_MAJOR_VERSION << 24) | \ - (PY_MINOR_VERSION << 16) | \ - (PY_MICRO_VERSION << 8) | \ - (PY_RELEASE_LEVEL << 4) | \ - (PY_RELEASE_SERIAL << 0)) diff --git a/python/include/pgen.h b/python/include/pgen.h deleted file mode 100644 index 8a325ed0..00000000 --- a/python/include/pgen.h +++ /dev/null @@ -1,18 +0,0 @@ -#ifndef Py_PGEN_H -#define Py_PGEN_H -#ifdef __cplusplus -extern "C" { -#endif - - -/* Parser generator interface */ - -extern grammar *meta_grammar(void); - -struct _node; -extern grammar *pgen(struct _node *); - -#ifdef __cplusplus -} -#endif -#endif /* !Py_PGEN_H */ diff --git a/python/include/pgenheaders.h b/python/include/pgenheaders.h deleted file mode 100644 index 2049ae32..00000000 --- a/python/include/pgenheaders.h +++ /dev/null @@ -1,42 +0,0 @@ -#ifndef Py_PGENHEADERS_H -#define Py_PGENHEADERS_H -#ifdef __cplusplus -extern "C" { -#endif - - -/* Include files and extern declarations used by most of the parser. */ - -#include "Python.h" - -PyAPI_FUNC(void) PySys_WriteStdout(const char *format, ...) - Py_GCC_ATTRIBUTE((format(printf, 1, 2))); -PyAPI_FUNC(void) PySys_WriteStderr(const char *format, ...) - Py_GCC_ATTRIBUTE((format(printf, 1, 2))); - -#define addarc _Py_addarc -#define addbit _Py_addbit -#define adddfa _Py_adddfa -#define addfirstsets _Py_addfirstsets -#define addlabel _Py_addlabel -#define addstate _Py_addstate -#define delbitset _Py_delbitset -#define dumptree _Py_dumptree -#define findlabel _Py_findlabel -#define mergebitset _Py_mergebitset -#define meta_grammar _Py_meta_grammar -#define newbitset _Py_newbitset -#define newgrammar _Py_newgrammar -#define pgen _Py_pgen -#define printgrammar _Py_printgrammar -#define printnonterminals _Py_printnonterminals -#define printtree _Py_printtree -#define samebitset _Py_samebitset -#define showtree _Py_showtree -#define tok_dump _Py_tok_dump -#define translatelabels _Py_translatelabels - -#ifdef __cplusplus -} -#endif -#endif /* !Py_PGENHEADERS_H */ diff --git a/python/include/py_curses.h b/python/include/py_curses.h deleted file mode 100644 index 657816cb..00000000 --- a/python/include/py_curses.h +++ /dev/null @@ -1,176 +0,0 @@ - -#ifndef Py_CURSES_H -#define Py_CURSES_H - -#ifdef __APPLE__ -/* -** On Mac OS X 10.2 [n]curses.h and stdlib.h use different guards -** against multiple definition of wchar_t. -*/ -#ifdef _BSD_WCHAR_T_DEFINED_ -#define _WCHAR_T -#endif - -/* the following define is necessary for OS X 10.6; without it, the - Apple-supplied ncurses.h sets NCURSES_OPAQUE to 1, and then Python - can't get at the WINDOW flags field. */ -#define NCURSES_OPAQUE 0 -#endif /* __APPLE__ */ - -#ifdef __FreeBSD__ -/* -** On FreeBSD, [n]curses.h and stdlib.h/wchar.h use different guards -** against multiple definition of wchar_t and wint_t. -*/ -#ifdef _XOPEN_SOURCE_EXTENDED -#ifndef __FreeBSD_version -#include -#endif -#if __FreeBSD_version >= 500000 -#ifndef __wchar_t -#define __wchar_t -#endif -#ifndef __wint_t -#define __wint_t -#endif -#else -#ifndef _WCHAR_T -#define _WCHAR_T -#endif -#ifndef _WINT_T -#define _WINT_T -#endif -#endif -#endif -#endif - -#ifdef HAVE_NCURSES_H -#include -#else -#include -#ifdef HAVE_TERM_H -/* for tigetstr, which is not declared in SysV curses */ -#include -#endif -#endif - -#ifdef HAVE_NCURSES_H -/* configure was checking , but we will - use , which has all these features. */ -#ifndef WINDOW_HAS_FLAGS -#define WINDOW_HAS_FLAGS 1 -#endif -#ifndef MVWDELCH_IS_EXPRESSION -#define MVWDELCH_IS_EXPRESSION 1 -#endif -#endif - -#ifdef __cplusplus -extern "C" { -#endif - -#define PyCurses_API_pointers 4 - -/* Type declarations */ - -typedef struct { - PyObject_HEAD - WINDOW *win; -} PyCursesWindowObject; - -#define PyCursesWindow_Check(v) (Py_TYPE(v) == &PyCursesWindow_Type) - -#define PyCurses_CAPSULE_NAME "_curses._C_API" - - -#ifdef CURSES_MODULE -/* This section is used when compiling _cursesmodule.c */ - -#else -/* This section is used in modules that use the _cursesmodule API */ - -static void **PyCurses_API; - -#define PyCursesWindow_Type (*(PyTypeObject *) PyCurses_API[0]) -#define PyCursesSetupTermCalled {if (! ((int (*)(void))PyCurses_API[1]) () ) return NULL;} -#define PyCursesInitialised {if (! ((int (*)(void))PyCurses_API[2]) () ) return NULL;} -#define PyCursesInitialisedColor {if (! ((int (*)(void))PyCurses_API[3]) () ) return NULL;} - -#define import_curses() \ - PyCurses_API = (void **)PyCapsule_Import(PyCurses_CAPSULE_NAME, 1); - -#endif - -/* general error messages */ -static char *catchall_ERR = "curses function returned ERR"; -static char *catchall_NULL = "curses function returned NULL"; - -/* Function Prototype Macros - They are ugly but very, very useful. ;-) - - X - function name - TYPE - parameter Type - ERGSTR - format string for construction of the return value - PARSESTR - format string for argument parsing - */ - -#define NoArgNoReturnFunction(X) \ -static PyObject *PyCurses_ ## X (PyObject *self) \ -{ \ - PyCursesInitialised \ - return PyCursesCheckERR(X(), # X); } - -#define NoArgOrFlagNoReturnFunction(X) \ -static PyObject *PyCurses_ ## X (PyObject *self, PyObject *args) \ -{ \ - int flag = 0; \ - PyCursesInitialised \ - switch(PyTuple_Size(args)) { \ - case 0: \ - return PyCursesCheckERR(X(), # X); \ - case 1: \ - if (!PyArg_ParseTuple(args, "i;True(1) or False(0)", &flag)) return NULL; \ - if (flag) return PyCursesCheckERR(X(), # X); \ - else return PyCursesCheckERR(no ## X (), # X); \ - default: \ - PyErr_SetString(PyExc_TypeError, # X " requires 0 or 1 arguments"); \ - return NULL; } } - -#define NoArgReturnIntFunction(X) \ -static PyObject *PyCurses_ ## X (PyObject *self) \ -{ \ - PyCursesInitialised \ - return PyInt_FromLong((long) X()); } - - -#define NoArgReturnStringFunction(X) \ -static PyObject *PyCurses_ ## X (PyObject *self) \ -{ \ - PyCursesInitialised \ - return PyString_FromString(X()); } - -#define NoArgTrueFalseFunction(X) \ -static PyObject *PyCurses_ ## X (PyObject *self) \ -{ \ - PyCursesInitialised \ - if (X () == FALSE) { \ - Py_INCREF(Py_False); \ - return Py_False; \ - } \ - Py_INCREF(Py_True); \ - return Py_True; } - -#define NoArgNoReturnVoidFunction(X) \ -static PyObject *PyCurses_ ## X (PyObject *self) \ -{ \ - PyCursesInitialised \ - X(); \ - Py_INCREF(Py_None); \ - return Py_None; } - -#ifdef __cplusplus -} -#endif - -#endif /* !defined(Py_CURSES_H) */ - - diff --git a/python/include/pyarena.h b/python/include/pyarena.h deleted file mode 100644 index 5f193fec..00000000 --- a/python/include/pyarena.h +++ /dev/null @@ -1,62 +0,0 @@ -/* An arena-like memory interface for the compiler. - */ - -#ifndef Py_PYARENA_H -#define Py_PYARENA_H - -#ifdef __cplusplus -extern "C" { -#endif - - typedef struct _arena PyArena; - - /* PyArena_New() and PyArena_Free() create a new arena and free it, - respectively. Once an arena has been created, it can be used - to allocate memory via PyArena_Malloc(). Pointers to PyObject can - also be registered with the arena via PyArena_AddPyObject(), and the - arena will ensure that the PyObjects stay alive at least until - PyArena_Free() is called. When an arena is freed, all the memory it - allocated is freed, the arena releases internal references to registered - PyObject*, and none of its pointers are valid. - XXX (tim) What does "none of its pointers are valid" mean? Does it - XXX mean that pointers previously obtained via PyArena_Malloc() are - XXX no longer valid? (That's clearly true, but not sure that's what - XXX the text is trying to say.) - - PyArena_New() returns an arena pointer. On error, it - returns a negative number and sets an exception. - XXX (tim): Not true. On error, PyArena_New() actually returns NULL, - XXX and looks like it may or may not set an exception (e.g., if the - XXX internal PyList_New(0) returns NULL, PyArena_New() passes that on - XXX and an exception is set; OTOH, if the internal - XXX block_new(DEFAULT_BLOCK_SIZE) returns NULL, that's passed on but - XXX an exception is not set in that case). - */ - PyAPI_FUNC(PyArena *) PyArena_New(void); - PyAPI_FUNC(void) PyArena_Free(PyArena *); - - /* Mostly like malloc(), return the address of a block of memory spanning - * `size` bytes, or return NULL (without setting an exception) if enough - * new memory can't be obtained. Unlike malloc(0), PyArena_Malloc() with - * size=0 does not guarantee to return a unique pointer (the pointer - * returned may equal one or more other pointers obtained from - * PyArena_Malloc()). - * Note that pointers obtained via PyArena_Malloc() must never be passed to - * the system free() or realloc(), or to any of Python's similar memory- - * management functions. PyArena_Malloc()-obtained pointers remain valid - * until PyArena_Free(ar) is called, at which point all pointers obtained - * from the arena `ar` become invalid simultaneously. - */ - PyAPI_FUNC(void *) PyArena_Malloc(PyArena *, size_t size); - - /* This routine isn't a proper arena allocation routine. It takes - * a PyObject* and records it so that it can be DECREFed when the - * arena is freed. - */ - PyAPI_FUNC(int) PyArena_AddPyObject(PyArena *, PyObject *); - -#ifdef __cplusplus -} -#endif - -#endif /* !Py_PYARENA_H */ diff --git a/python/include/pycapsule.h b/python/include/pycapsule.h deleted file mode 100644 index cd682fc7..00000000 --- a/python/include/pycapsule.h +++ /dev/null @@ -1,56 +0,0 @@ - -/* Capsule objects let you wrap a C "void *" pointer in a Python - object. They're a way of passing data through the Python interpreter - without creating your own custom type. - - Capsules are used for communication between extension modules. - They provide a way for an extension module to export a C interface - to other extension modules, so that extension modules can use the - Python import mechanism to link to one another. - - For more information, please see "c-api/capsule.html" in the - documentation. -*/ - -#ifndef Py_CAPSULE_H -#define Py_CAPSULE_H -#ifdef __cplusplus -extern "C" { -#endif - -PyAPI_DATA(PyTypeObject) PyCapsule_Type; - -typedef void (*PyCapsule_Destructor)(PyObject *); - -#define PyCapsule_CheckExact(op) (Py_TYPE(op) == &PyCapsule_Type) - - -PyAPI_FUNC(PyObject *) PyCapsule_New( - void *pointer, - const char *name, - PyCapsule_Destructor destructor); - -PyAPI_FUNC(void *) PyCapsule_GetPointer(PyObject *capsule, const char *name); - -PyAPI_FUNC(PyCapsule_Destructor) PyCapsule_GetDestructor(PyObject *capsule); - -PyAPI_FUNC(const char *) PyCapsule_GetName(PyObject *capsule); - -PyAPI_FUNC(void *) PyCapsule_GetContext(PyObject *capsule); - -PyAPI_FUNC(int) PyCapsule_IsValid(PyObject *capsule, const char *name); - -PyAPI_FUNC(int) PyCapsule_SetPointer(PyObject *capsule, void *pointer); - -PyAPI_FUNC(int) PyCapsule_SetDestructor(PyObject *capsule, PyCapsule_Destructor destructor); - -PyAPI_FUNC(int) PyCapsule_SetName(PyObject *capsule, const char *name); - -PyAPI_FUNC(int) PyCapsule_SetContext(PyObject *capsule, void *context); - -PyAPI_FUNC(void *) PyCapsule_Import(const char *name, int no_block); - -#ifdef __cplusplus -} -#endif -#endif /* !Py_CAPSULE_H */ diff --git a/python/include/pyconfig.h b/python/include/pyconfig.h deleted file mode 100644 index 1cfc59b8..00000000 --- a/python/include/pyconfig.h +++ /dev/null @@ -1,759 +0,0 @@ -#ifndef Py_CONFIG_H -#define Py_CONFIG_H - -/* pyconfig.h. NOT Generated automatically by configure. - -This is a manually maintained version used for the Watcom, -Borland and Microsoft Visual C++ compilers. It is a -standard part of the Python distribution. - -WINDOWS DEFINES: -The code specific to Windows should be wrapped around one of -the following #defines - -MS_WIN64 - Code specific to the MS Win64 API -MS_WIN32 - Code specific to the MS Win32 (and Win64) API (obsolete, this covers all supported APIs) -MS_WINDOWS - Code specific to Windows, but all versions. -MS_WINCE - Code specific to Windows CE -Py_ENABLE_SHARED - Code if the Python core is built as a DLL. - -Also note that neither "_M_IX86" or "_MSC_VER" should be used for -any purpose other than "Windows Intel x86 specific" and "Microsoft -compiler specific". Therefore, these should be very rare. - - -NOTE: The following symbols are deprecated: -NT, USE_DL_EXPORT, USE_DL_IMPORT, DL_EXPORT, DL_IMPORT -MS_CORE_DLL. - -WIN32 is still required for the locale module. - -*/ - -#ifdef _WIN32_WCE -#define MS_WINCE -#endif - -/* Deprecated USE_DL_EXPORT macro - please use Py_BUILD_CORE */ -#ifdef USE_DL_EXPORT -# define Py_BUILD_CORE -#endif /* USE_DL_EXPORT */ - -/* Visual Studio 2005 introduces deprecation warnings for - "insecure" and POSIX functions. The insecure functions should - be replaced by *_s versions (according to Microsoft); the - POSIX functions by _* versions (which, according to Microsoft, - would be ISO C conforming). Neither renaming is feasible, so - we just silence the warnings. */ - -#ifndef _CRT_SECURE_NO_DEPRECATE -#define _CRT_SECURE_NO_DEPRECATE 1 -#endif -#ifndef _CRT_NONSTDC_NO_DEPRECATE -#define _CRT_NONSTDC_NO_DEPRECATE 1 -#endif - -/* Windows CE does not have these */ -#ifndef MS_WINCE -#define HAVE_IO_H -#define HAVE_SYS_UTIME_H -#define HAVE_TEMPNAM -#define HAVE_TMPFILE -#define HAVE_TMPNAM -#define HAVE_CLOCK -#define HAVE_STRERROR -#endif - -#ifdef HAVE_IO_H -#include -#endif - -#define HAVE_HYPOT -#define HAVE_STRFTIME -#define DONT_HAVE_SIG_ALARM -#define DONT_HAVE_SIG_PAUSE -#define LONG_BIT 32 -#define WORD_BIT 32 -#define PREFIX "" -#define EXEC_PREFIX "" - -#define MS_WIN32 /* only support win32 and greater. */ -#define MS_WINDOWS -#ifndef PYTHONPATH -# define PYTHONPATH ".\\DLLs;.\\lib;.\\lib\\plat-win;.\\lib\\lib-tk" -#endif -#define NT_THREADS -#define WITH_THREAD -#ifndef NETSCAPE_PI -#define USE_SOCKET -#endif - -/* CE6 doesn't have strdup() but _strdup(). Assume the same for earlier versions. */ -#if defined(MS_WINCE) -# include -# define strdup _strdup -#endif - -#ifdef MS_WINCE -/* Windows CE does not support environment variables */ -#define getenv(v) (NULL) -#define environ (NULL) -#endif - -/* Compiler specific defines */ - -/* ------------------------------------------------------------------------*/ -/* Microsoft C defines _MSC_VER */ -#ifdef _MSC_VER - -/* We want COMPILER to expand to a string containing _MSC_VER's *value*. - * This is horridly tricky, because the stringization operator only works - * on macro arguments, and doesn't evaluate macros passed *as* arguments. - * Attempts simpler than the following appear doomed to produce "_MSC_VER" - * literally in the string. - */ -#define _Py_PASTE_VERSION(SUFFIX) \ - ("[MSC v." _Py_STRINGIZE(_MSC_VER) " " SUFFIX "]") -/* e.g., this produces, after compile-time string catenation, - * ("[MSC v.1200 32 bit (Intel)]") - * - * _Py_STRINGIZE(_MSC_VER) expands to - * _Py_STRINGIZE1((_MSC_VER)) expands to - * _Py_STRINGIZE2(_MSC_VER) but as this call is the result of token-pasting - * it's scanned again for macros and so further expands to (under MSVC 6) - * _Py_STRINGIZE2(1200) which then expands to - * "1200" - */ -#define _Py_STRINGIZE(X) _Py_STRINGIZE1((X)) -#define _Py_STRINGIZE1(X) _Py_STRINGIZE2 ## X -#define _Py_STRINGIZE2(X) #X - -/* MSVC defines _WINxx to differentiate the windows platform types - - Note that for compatibility reasons _WIN32 is defined on Win32 - *and* on Win64. For the same reasons, in Python, MS_WIN32 is - defined on Win32 *and* Win64. Win32 only code must therefore be - guarded as follows: - #if defined(MS_WIN32) && !defined(MS_WIN64) - Some modules are disabled on Itanium processors, therefore we - have MS_WINI64 set for those targets, otherwise MS_WINX64 -*/ -#ifdef _WIN64 -#define MS_WIN64 -#endif - -/* set the COMPILER */ -#ifdef MS_WIN64 -#if defined(_M_IA64) -#define COMPILER _Py_PASTE_VERSION("64 bit (Itanium)") -#define MS_WINI64 -#elif defined(_M_X64) || defined(_M_AMD64) -#define COMPILER _Py_PASTE_VERSION("64 bit (AMD64)") -#define MS_WINX64 -#else -#define COMPILER _Py_PASTE_VERSION("64 bit (Unknown)") -#endif -#endif /* MS_WIN64 */ - -/* set the version macros for the windows headers */ -#ifdef MS_WINX64 -/* 64 bit only runs on XP or greater */ -#define Py_WINVER _WIN32_WINNT_WINXP -#define Py_NTDDI NTDDI_WINXP -#else -/* Python 2.6+ requires Windows 2000 or greater */ -#ifdef _WIN32_WINNT_WIN2K -#define Py_WINVER _WIN32_WINNT_WIN2K -#else -#define Py_WINVER 0x0500 -#endif -#define Py_NTDDI NTDDI_WIN2KSP4 -#endif - -/* We only set these values when building Python - we don't want to force - these values on extensions, as that will affect the prototypes and - structures exposed in the Windows headers. Even when building Python, we - allow a single source file to override this - they may need access to - structures etc so it can optionally use new Windows features if it - determines at runtime they are available. -*/ -#if defined(Py_BUILD_CORE) || defined(Py_BUILD_CORE_MODULE) -#ifndef NTDDI_VERSION -#define NTDDI_VERSION Py_NTDDI -#endif -#ifndef WINVER -#define WINVER Py_WINVER -#endif -#ifndef _WIN32_WINNT -#define _WIN32_WINNT Py_WINVER -#endif -#endif - -/* _W64 is not defined for VC6 or eVC4 */ -#ifndef _W64 -#define _W64 -#endif - -/* Define like size_t, omitting the "unsigned" */ -#ifdef MS_WIN64 -typedef __int64 ssize_t; -#else -typedef _W64 int ssize_t; -#endif -#define HAVE_SSIZE_T 1 - -#if defined(MS_WIN32) && !defined(MS_WIN64) -#ifdef _M_IX86 -#define COMPILER _Py_PASTE_VERSION("32 bit (Intel)") -#else -#define COMPILER _Py_PASTE_VERSION("32 bit (Unknown)") -#endif -#endif /* MS_WIN32 && !MS_WIN64 */ - -typedef int pid_t; - -#include -#define Py_IS_NAN _isnan -#define Py_IS_INFINITY(X) (!_finite(X) && !_isnan(X)) -#define Py_IS_FINITE(X) _finite(X) -#define copysign _copysign -#define hypot _hypot - -#endif /* _MSC_VER */ - -/* define some ANSI types that are not defined in earlier Win headers */ -#if defined(_MSC_VER) && _MSC_VER >= 1200 -/* This file only exists in VC 6.0 or higher */ -#include -#endif - -/* ------------------------------------------------------------------------*/ -/* The Borland compiler defines __BORLANDC__ */ -/* XXX These defines are likely incomplete, but should be easy to fix. */ -#ifdef __BORLANDC__ -#define COMPILER "[Borland]" - -#ifdef _WIN32 -/* tested with BCC 5.5 (__BORLANDC__ >= 0x0550) - */ - -typedef int pid_t; -/* BCC55 seems to understand __declspec(dllimport), it is used in its - own header files (winnt.h, ...) - so we can do nothing and get the default*/ - -#undef HAVE_SYS_UTIME_H -#define HAVE_UTIME_H -#define HAVE_DIRENT_H - -/* rename a few functions for the Borland compiler */ -#include -#define _chsize chsize -#define _setmode setmode - -#else /* !_WIN32 */ -#error "Only Win32 and later are supported" -#endif /* !_WIN32 */ - -#endif /* BORLANDC */ - -/* ------------------------------------------------------------------------*/ -/* egcs/gnu-win32 defines __GNUC__ and _WIN32 */ -#if defined(__GNUC__) && defined(_WIN32) -/* XXX These defines are likely incomplete, but should be easy to fix. - They should be complete enough to build extension modules. */ -/* Suggested by Rene Liebscher to avoid a GCC 2.91.* - bug that requires structure imports. More recent versions of the - compiler don't exhibit this bug. -*/ -#if (__GNUC__==2) && (__GNUC_MINOR__<=91) -#warning "Please use an up-to-date version of gcc! (>2.91 recommended)" -#endif - -#define COMPILER "[gcc]" -#define hypot _hypot -#define PY_LONG_LONG long long -#define PY_LLONG_MIN LLONG_MIN -#define PY_LLONG_MAX LLONG_MAX -#define PY_ULLONG_MAX ULLONG_MAX -#endif /* GNUC */ - -/* ------------------------------------------------------------------------*/ -/* lcc-win32 defines __LCC__ */ -#if defined(__LCC__) -/* XXX These defines are likely incomplete, but should be easy to fix. - They should be complete enough to build extension modules. */ - -#define COMPILER "[lcc-win32]" -typedef int pid_t; -/* __declspec() is supported here too - do nothing to get the defaults */ - -#endif /* LCC */ - -/* ------------------------------------------------------------------------*/ -/* End of compilers - finish up */ - -#ifndef NO_STDIO_H -# include -#endif - -/* 64 bit ints are usually spelt __int64 unless compiler has overridden */ -#define HAVE_LONG_LONG 1 -#ifndef PY_LONG_LONG -# define PY_LONG_LONG __int64 -# define PY_LLONG_MAX _I64_MAX -# define PY_LLONG_MIN _I64_MIN -# define PY_ULLONG_MAX _UI64_MAX -#endif - -/* For Windows the Python core is in a DLL by default. Test -Py_NO_ENABLE_SHARED to find out. Also support MS_NO_COREDLL for b/w compat */ -#if !defined(MS_NO_COREDLL) && !defined(Py_NO_ENABLE_SHARED) -# define Py_ENABLE_SHARED 1 /* standard symbol for shared library */ -# define MS_COREDLL /* deprecated old symbol */ -#endif /* !MS_NO_COREDLL && ... */ - -/* All windows compilers that use this header support __declspec */ -#define HAVE_DECLSPEC_DLL - -/* For an MSVC DLL, we can nominate the .lib files used by extensions */ -#ifdef MS_COREDLL -# ifndef Py_BUILD_CORE /* not building the core - must be an ext */ -# if defined(_MSC_VER) - /* So MSVC users need not specify the .lib file in - their Makefile (other compilers are generally - taken care of by distutils.) */ -# ifdef _DEBUG -# pragma comment(lib,"python27_d.lib") -# else -# pragma comment(lib,"python27.lib") -# endif /* _DEBUG */ -# endif /* _MSC_VER */ -# endif /* Py_BUILD_CORE */ -#endif /* MS_COREDLL */ - -#if defined(MS_WIN64) -/* maintain "win32" sys.platform for backward compatibility of Python code, - the Win64 API should be close enough to the Win32 API to make this - preferable */ -# define PLATFORM "win32" -# define SIZEOF_VOID_P 8 -# define SIZEOF_TIME_T 8 -# define SIZEOF_OFF_T 4 -# define SIZEOF_FPOS_T 8 -# define SIZEOF_HKEY 8 -# define SIZEOF_SIZE_T 8 -/* configure.in defines HAVE_LARGEFILE_SUPPORT iff HAVE_LONG_LONG, - sizeof(off_t) > sizeof(long), and sizeof(PY_LONG_LONG) >= sizeof(off_t). - On Win64 the second condition is not true, but if fpos_t replaces off_t - then this is true. The uses of HAVE_LARGEFILE_SUPPORT imply that Win64 - should define this. */ -# define HAVE_LARGEFILE_SUPPORT -#elif defined(MS_WIN32) -# define PLATFORM "win32" -# define HAVE_LARGEFILE_SUPPORT -# define SIZEOF_VOID_P 4 -# define SIZEOF_OFF_T 4 -# define SIZEOF_FPOS_T 8 -# define SIZEOF_HKEY 4 -# define SIZEOF_SIZE_T 4 - /* MS VS2005 changes time_t to an 64-bit type on all platforms */ -# if defined(_MSC_VER) && _MSC_VER >= 1400 -# define SIZEOF_TIME_T 8 -# else -# define SIZEOF_TIME_T 4 -# endif -#endif - -#ifdef _DEBUG -# define Py_DEBUG -#endif - - -#ifdef MS_WIN32 - -#define SIZEOF_SHORT 2 -#define SIZEOF_INT 4 -#define SIZEOF_LONG 4 -#define SIZEOF_LONG_LONG 8 -#define SIZEOF_DOUBLE 8 -#define SIZEOF_FLOAT 4 - -/* VC 7.1 has them and VC 6.0 does not. VC 6.0 has a version number of 1200. - Microsoft eMbedded Visual C++ 4.0 has a version number of 1201 and doesn't - define these. - If some compiler does not provide them, modify the #if appropriately. */ -#if defined(_MSC_VER) -#if _MSC_VER > 1300 -#define HAVE_UINTPTR_T 1 -#define HAVE_INTPTR_T 1 -#else -/* VC6, VS 2002 and eVC4 don't support the C99 LL suffix for 64-bit integer literals */ -#define Py_LL(x) x##I64 -#endif /* _MSC_VER > 1200 */ -#endif /* _MSC_VER */ - -#endif - -/* define signed and unsigned exact-width 32-bit and 64-bit types, used in the - implementation of Python long integers. */ -#ifndef PY_UINT32_T -#if SIZEOF_INT == 4 -#define HAVE_UINT32_T 1 -#define PY_UINT32_T unsigned int -#elif SIZEOF_LONG == 4 -#define HAVE_UINT32_T 1 -#define PY_UINT32_T unsigned long -#endif -#endif - -#ifndef PY_UINT64_T -#if SIZEOF_LONG_LONG == 8 -#define HAVE_UINT64_T 1 -#define PY_UINT64_T unsigned PY_LONG_LONG -#endif -#endif - -#ifndef PY_INT32_T -#if SIZEOF_INT == 4 -#define HAVE_INT32_T 1 -#define PY_INT32_T int -#elif SIZEOF_LONG == 4 -#define HAVE_INT32_T 1 -#define PY_INT32_T long -#endif -#endif - -#ifndef PY_INT64_T -#if SIZEOF_LONG_LONG == 8 -#define HAVE_INT64_T 1 -#define PY_INT64_T PY_LONG_LONG -#endif -#endif - -/* Fairly standard from here! */ - -/* Define to 1 if you have the `copysign' function. */ -#define HAVE_COPYSIGN 1 - -/* Define to 1 if you have the `isinf' macro. */ -#define HAVE_DECL_ISINF 1 - -/* Define to 1 if you have the `isnan' function. */ -#define HAVE_DECL_ISNAN 1 - -/* Define if on AIX 3. - System headers sometimes define this. - We just want to avoid a redefinition error message. */ -#ifndef _ALL_SOURCE -/* #undef _ALL_SOURCE */ -#endif - -/* Define to empty if the keyword does not work. */ -/* #define const */ - -/* Define to 1 if you have the header file. */ -#ifndef MS_WINCE -#define HAVE_CONIO_H 1 -#endif - -/* Define to 1 if you have the header file. */ -#ifndef MS_WINCE -#define HAVE_DIRECT_H 1 -#endif - -/* Define if you have dirent.h. */ -/* #define DIRENT 1 */ - -/* Define to the type of elements in the array set by `getgroups'. - Usually this is either `int' or `gid_t'. */ -/* #undef GETGROUPS_T */ - -/* Define to `int' if doesn't define. */ -/* #undef gid_t */ - -/* Define if your struct tm has tm_zone. */ -/* #undef HAVE_TM_ZONE */ - -/* Define if you don't have tm_zone but do have the external array - tzname. */ -#define HAVE_TZNAME - -/* Define to `int' if doesn't define. */ -/* #undef mode_t */ - -/* Define if you don't have dirent.h, but have ndir.h. */ -/* #undef NDIR */ - -/* Define to `long' if doesn't define. */ -/* #undef off_t */ - -/* Define to `int' if doesn't define. */ -/* #undef pid_t */ - -/* Define if the system does not provide POSIX.1 features except - with this defined. */ -/* #undef _POSIX_1_SOURCE */ - -/* Define if you need to in order for stat and other things to work. */ -/* #undef _POSIX_SOURCE */ - -/* Define as the return type of signal handlers (int or void). */ -#define RETSIGTYPE void - -/* Define to `unsigned' if doesn't define. */ -/* #undef size_t */ - -/* Define if you have the ANSI C header files. */ -#define STDC_HEADERS 1 - -/* Define if you don't have dirent.h, but have sys/dir.h. */ -/* #undef SYSDIR */ - -/* Define if you don't have dirent.h, but have sys/ndir.h. */ -/* #undef SYSNDIR */ - -/* Define if you can safely include both and . */ -/* #undef TIME_WITH_SYS_TIME */ - -/* Define if your declares struct tm. */ -/* #define TM_IN_SYS_TIME 1 */ - -/* Define to `int' if doesn't define. */ -/* #undef uid_t */ - -/* Define if the closedir function returns void instead of int. */ -/* #undef VOID_CLOSEDIR */ - -/* Define if getpgrp() must be called as getpgrp(0) - and (consequently) setpgrp() as setpgrp(0, 0). */ -/* #undef GETPGRP_HAVE_ARGS */ - -/* Define this if your time.h defines altzone */ -/* #define HAVE_ALTZONE */ - -/* Define if you have the putenv function. */ -#ifndef MS_WINCE -#define HAVE_PUTENV -#endif - -/* Define if your compiler supports function prototypes */ -#define HAVE_PROTOTYPES - -/* Define if you can safely include both and - (which you can't on SCO ODT 3.0). */ -/* #undef SYS_SELECT_WITH_SYS_TIME */ - -/* Define if you want documentation strings in extension modules */ -#define WITH_DOC_STRINGS 1 - -/* Define if you want to compile in rudimentary thread support */ -/* #undef WITH_THREAD */ - -/* Define if you want to use the GNU readline library */ -/* #define WITH_READLINE 1 */ - -/* Define if you want to have a Unicode type. */ -#define Py_USING_UNICODE - -/* Define as the size of the unicode type. */ -/* This is enough for unicodeobject.h to do the "right thing" on Windows. */ -#define Py_UNICODE_SIZE 2 - -/* Use Python's own small-block memory-allocator. */ -#define WITH_PYMALLOC 1 - -/* Define if you have clock. */ -/* #define HAVE_CLOCK */ - -/* Define when any dynamic module loading is enabled */ -#define HAVE_DYNAMIC_LOADING - -/* Define if you have ftime. */ -#ifndef MS_WINCE -#define HAVE_FTIME -#endif - -/* Define if you have getpeername. */ -#define HAVE_GETPEERNAME - -/* Define if you have getpgrp. */ -/* #undef HAVE_GETPGRP */ - -/* Define if you have getpid. */ -#ifndef MS_WINCE -#define HAVE_GETPID -#endif - -/* Define if you have gettimeofday. */ -/* #undef HAVE_GETTIMEOFDAY */ - -/* Define if you have getwd. */ -/* #undef HAVE_GETWD */ - -/* Define if you have lstat. */ -/* #undef HAVE_LSTAT */ - -/* Define if you have the mktime function. */ -#define HAVE_MKTIME - -/* Define if you have nice. */ -/* #undef HAVE_NICE */ - -/* Define if you have readlink. */ -/* #undef HAVE_READLINK */ - -/* Define if you have select. */ -/* #undef HAVE_SELECT */ - -/* Define if you have setpgid. */ -/* #undef HAVE_SETPGID */ - -/* Define if you have setpgrp. */ -/* #undef HAVE_SETPGRP */ - -/* Define if you have setsid. */ -/* #undef HAVE_SETSID */ - -/* Define if you have setvbuf. */ -#define HAVE_SETVBUF - -/* Define if you have siginterrupt. */ -/* #undef HAVE_SIGINTERRUPT */ - -/* Define if you have symlink. */ -/* #undef HAVE_SYMLINK */ - -/* Define if you have tcgetpgrp. */ -/* #undef HAVE_TCGETPGRP */ - -/* Define if you have tcsetpgrp. */ -/* #undef HAVE_TCSETPGRP */ - -/* Define if you have times. */ -/* #undef HAVE_TIMES */ - -/* Define if you have uname. */ -/* #undef HAVE_UNAME */ - -/* Define if you have waitpid. */ -/* #undef HAVE_WAITPID */ - -/* Define to 1 if you have the `wcscoll' function. */ -#ifndef MS_WINCE -#define HAVE_WCSCOLL 1 -#endif - -/* Define if the zlib library has inflateCopy */ -#define HAVE_ZLIB_COPY 1 - -/* Define if you have the header file. */ -/* #undef HAVE_DLFCN_H */ - -/* Define to 1 if you have the header file. */ -#ifndef MS_WINCE -#define HAVE_ERRNO_H 1 -#endif - -/* Define if you have the header file. */ -#ifndef MS_WINCE -#define HAVE_FCNTL_H 1 -#endif - -/* Define to 1 if you have the header file. */ -#ifndef MS_WINCE -#define HAVE_PROCESS_H 1 -#endif - -/* Define to 1 if you have the header file. */ -#ifndef MS_WINCE -#define HAVE_SIGNAL_H 1 -#endif - -/* Define if you have the prototypes. */ -#define HAVE_STDARG_PROTOTYPES - -/* Define if you have the header file. */ -#define HAVE_STDDEF_H 1 - -/* Define if you have the header file. */ -/* #undef HAVE_SYS_AUDIOIO_H */ - -/* Define if you have the header file. */ -/* #define HAVE_SYS_PARAM_H 1 */ - -/* Define if you have the header file. */ -/* #define HAVE_SYS_SELECT_H 1 */ - -/* Define to 1 if you have the header file. */ -#ifndef MS_WINCE -#define HAVE_SYS_STAT_H 1 -#endif - -/* Define if you have the header file. */ -/* #define HAVE_SYS_TIME_H 1 */ - -/* Define if you have the header file. */ -/* #define HAVE_SYS_TIMES_H 1 */ - -/* Define to 1 if you have the header file. */ -#ifndef MS_WINCE -#define HAVE_SYS_TYPES_H 1 -#endif - -/* Define if you have the header file. */ -/* #define HAVE_SYS_UN_H 1 */ - -/* Define if you have the header file. */ -/* #define HAVE_SYS_UTIME_H 1 */ - -/* Define if you have the header file. */ -/* #define HAVE_SYS_UTSNAME_H 1 */ - -/* Define if you have the header file. */ -/* #undef HAVE_THREAD_H */ - -/* Define if you have the header file. */ -/* #define HAVE_UNISTD_H 1 */ - -/* Define if you have the header file. */ -/* #define HAVE_UTIME_H 1 */ - -/* Define if the compiler provides a wchar.h header file. */ -#define HAVE_WCHAR_H 1 - -/* Define if you have the dl library (-ldl). */ -/* #undef HAVE_LIBDL */ - -/* Define if you have the mpc library (-lmpc). */ -/* #undef HAVE_LIBMPC */ - -/* Define if you have the nsl library (-lnsl). */ -#define HAVE_LIBNSL 1 - -/* Define if you have the seq library (-lseq). */ -/* #undef HAVE_LIBSEQ */ - -/* Define if you have the socket library (-lsocket). */ -#define HAVE_LIBSOCKET 1 - -/* Define if you have the sun library (-lsun). */ -/* #undef HAVE_LIBSUN */ - -/* Define if you have the termcap library (-ltermcap). */ -/* #undef HAVE_LIBTERMCAP */ - -/* Define if you have the termlib library (-ltermlib). */ -/* #undef HAVE_LIBTERMLIB */ - -/* Define if you have the thread library (-lthread). */ -/* #undef HAVE_LIBTHREAD */ - -/* WinSock does not use a bitmask in select, and uses - socket handles greater than FD_SETSIZE */ -#define Py_SOCKET_FD_CAN_BE_GE_FD_SETSIZE - -/* Define if C doubles are 64-bit IEEE 754 binary format, stored with the - least significant byte first */ -#define DOUBLE_IS_LITTLE_ENDIAN_IEEE754 1 - -#endif /* !Py_CONFIG_H */ diff --git a/python/include/pyctype.h b/python/include/pyctype.h deleted file mode 100644 index 673cf2eb..00000000 --- a/python/include/pyctype.h +++ /dev/null @@ -1,31 +0,0 @@ -#ifndef PYCTYPE_H -#define PYCTYPE_H - -#define PY_CTF_LOWER 0x01 -#define PY_CTF_UPPER 0x02 -#define PY_CTF_ALPHA (PY_CTF_LOWER|PY_CTF_UPPER) -#define PY_CTF_DIGIT 0x04 -#define PY_CTF_ALNUM (PY_CTF_ALPHA|PY_CTF_DIGIT) -#define PY_CTF_SPACE 0x08 -#define PY_CTF_XDIGIT 0x10 - -PyAPI_DATA(const unsigned int) _Py_ctype_table[256]; - -/* Unlike their C counterparts, the following macros are not meant to - * handle an int with any of the values [EOF, 0-UCHAR_MAX]. The argument - * must be a signed/unsigned char. */ -#define Py_ISLOWER(c) (_Py_ctype_table[Py_CHARMASK(c)] & PY_CTF_LOWER) -#define Py_ISUPPER(c) (_Py_ctype_table[Py_CHARMASK(c)] & PY_CTF_UPPER) -#define Py_ISALPHA(c) (_Py_ctype_table[Py_CHARMASK(c)] & PY_CTF_ALPHA) -#define Py_ISDIGIT(c) (_Py_ctype_table[Py_CHARMASK(c)] & PY_CTF_DIGIT) -#define Py_ISXDIGIT(c) (_Py_ctype_table[Py_CHARMASK(c)] & PY_CTF_XDIGIT) -#define Py_ISALNUM(c) (_Py_ctype_table[Py_CHARMASK(c)] & PY_CTF_ALNUM) -#define Py_ISSPACE(c) (_Py_ctype_table[Py_CHARMASK(c)] & PY_CTF_SPACE) - -PyAPI_DATA(const unsigned char) _Py_ctype_tolower[256]; -PyAPI_DATA(const unsigned char) _Py_ctype_toupper[256]; - -#define Py_TOLOWER(c) (_Py_ctype_tolower[Py_CHARMASK(c)]) -#define Py_TOUPPER(c) (_Py_ctype_toupper[Py_CHARMASK(c)]) - -#endif /* !PYCTYPE_H */ diff --git a/python/include/pydebug.h b/python/include/pydebug.h deleted file mode 100644 index 0f45960f..00000000 --- a/python/include/pydebug.h +++ /dev/null @@ -1,41 +0,0 @@ - -#ifndef Py_PYDEBUG_H -#define Py_PYDEBUG_H -#ifdef __cplusplus -extern "C" { -#endif - -PyAPI_DATA(int) Py_DebugFlag; -PyAPI_DATA(int) Py_VerboseFlag; -PyAPI_DATA(int) Py_InteractiveFlag; -PyAPI_DATA(int) Py_InspectFlag; -PyAPI_DATA(int) Py_OptimizeFlag; -PyAPI_DATA(int) Py_NoSiteFlag; -PyAPI_DATA(int) Py_BytesWarningFlag; -PyAPI_DATA(int) Py_UseClassExceptionsFlag; -PyAPI_DATA(int) Py_FrozenFlag; -PyAPI_DATA(int) Py_TabcheckFlag; -PyAPI_DATA(int) Py_UnicodeFlag; -PyAPI_DATA(int) Py_IgnoreEnvironmentFlag; -PyAPI_DATA(int) Py_DivisionWarningFlag; -PyAPI_DATA(int) Py_DontWriteBytecodeFlag; -PyAPI_DATA(int) Py_NoUserSiteDirectory; -/* _XXX Py_QnewFlag should go away in 3.0. It's true iff -Qnew is passed, - on the command line, and is used in 2.2 by ceval.c to make all "/" divisions - true divisions (which they will be in 3.0). */ -PyAPI_DATA(int) _Py_QnewFlag; -/* Warn about 3.x issues */ -PyAPI_DATA(int) Py_Py3kWarningFlag; -PyAPI_DATA(int) Py_HashRandomizationFlag; - -/* this is a wrapper around getenv() that pays attention to - Py_IgnoreEnvironmentFlag. It should be used for getting variables like - PYTHONPATH and PYTHONHOME from the environment */ -#define Py_GETENV(s) (Py_IgnoreEnvironmentFlag ? NULL : getenv(s)) - -PyAPI_FUNC(void) Py_FatalError(const char *message); - -#ifdef __cplusplus -} -#endif -#endif /* !Py_PYDEBUG_H */ diff --git a/python/include/pyerrors.h b/python/include/pyerrors.h deleted file mode 100644 index dbe3bfa5..00000000 --- a/python/include/pyerrors.h +++ /dev/null @@ -1,328 +0,0 @@ -#ifndef Py_ERRORS_H -#define Py_ERRORS_H -#ifdef __cplusplus -extern "C" { -#endif - -/* Error objects */ - -typedef struct { - PyObject_HEAD - PyObject *dict; - PyObject *args; - PyObject *message; -} PyBaseExceptionObject; - -typedef struct { - PyObject_HEAD - PyObject *dict; - PyObject *args; - PyObject *message; - PyObject *msg; - PyObject *filename; - PyObject *lineno; - PyObject *offset; - PyObject *text; - PyObject *print_file_and_line; -} PySyntaxErrorObject; - -#ifdef Py_USING_UNICODE -typedef struct { - PyObject_HEAD - PyObject *dict; - PyObject *args; - PyObject *message; - PyObject *encoding; - PyObject *object; - Py_ssize_t start; - Py_ssize_t end; - PyObject *reason; -} PyUnicodeErrorObject; -#endif - -typedef struct { - PyObject_HEAD - PyObject *dict; - PyObject *args; - PyObject *message; - PyObject *code; -} PySystemExitObject; - -typedef struct { - PyObject_HEAD - PyObject *dict; - PyObject *args; - PyObject *message; - PyObject *myerrno; - PyObject *strerror; - PyObject *filename; -} PyEnvironmentErrorObject; - -#ifdef MS_WINDOWS -typedef struct { - PyObject_HEAD - PyObject *dict; - PyObject *args; - PyObject *message; - PyObject *myerrno; - PyObject *strerror; - PyObject *filename; - PyObject *winerror; -} PyWindowsErrorObject; -#endif - -/* Error handling definitions */ - -PyAPI_FUNC(void) PyErr_SetNone(PyObject *); -PyAPI_FUNC(void) PyErr_SetObject(PyObject *, PyObject *); -PyAPI_FUNC(void) PyErr_SetString(PyObject *, const char *); -PyAPI_FUNC(PyObject *) PyErr_Occurred(void); -PyAPI_FUNC(void) PyErr_Clear(void); -PyAPI_FUNC(void) PyErr_Fetch(PyObject **, PyObject **, PyObject **); -PyAPI_FUNC(void) PyErr_Restore(PyObject *, PyObject *, PyObject *); - -#ifdef Py_DEBUG -#define _PyErr_OCCURRED() PyErr_Occurred() -#else -#define _PyErr_OCCURRED() (_PyThreadState_Current->curexc_type) -#endif - -/* Error testing and normalization */ -PyAPI_FUNC(int) PyErr_GivenExceptionMatches(PyObject *, PyObject *); -PyAPI_FUNC(int) PyErr_ExceptionMatches(PyObject *); -PyAPI_FUNC(void) PyErr_NormalizeException(PyObject**, PyObject**, PyObject**); - -/* */ - -#define PyExceptionClass_Check(x) \ - (PyClass_Check((x)) || (PyType_Check((x)) && \ - PyType_FastSubclass((PyTypeObject*)(x), Py_TPFLAGS_BASE_EXC_SUBCLASS))) - -#define PyExceptionInstance_Check(x) \ - (PyInstance_Check((x)) || \ - PyType_FastSubclass((x)->ob_type, Py_TPFLAGS_BASE_EXC_SUBCLASS)) - -#define PyExceptionClass_Name(x) \ - (PyClass_Check((x)) \ - ? PyString_AS_STRING(((PyClassObject*)(x))->cl_name) \ - : (char *)(((PyTypeObject*)(x))->tp_name)) - -#define PyExceptionInstance_Class(x) \ - ((PyInstance_Check((x)) \ - ? (PyObject*)((PyInstanceObject*)(x))->in_class \ - : (PyObject*)((x)->ob_type))) - - -/* Predefined exceptions */ - -PyAPI_DATA(PyObject *) PyExc_BaseException; -PyAPI_DATA(PyObject *) PyExc_Exception; -PyAPI_DATA(PyObject *) PyExc_StopIteration; -PyAPI_DATA(PyObject *) PyExc_GeneratorExit; -PyAPI_DATA(PyObject *) PyExc_StandardError; -PyAPI_DATA(PyObject *) PyExc_ArithmeticError; -PyAPI_DATA(PyObject *) PyExc_LookupError; - -PyAPI_DATA(PyObject *) PyExc_AssertionError; -PyAPI_DATA(PyObject *) PyExc_AttributeError; -PyAPI_DATA(PyObject *) PyExc_EOFError; -PyAPI_DATA(PyObject *) PyExc_FloatingPointError; -PyAPI_DATA(PyObject *) PyExc_EnvironmentError; -PyAPI_DATA(PyObject *) PyExc_IOError; -PyAPI_DATA(PyObject *) PyExc_OSError; -PyAPI_DATA(PyObject *) PyExc_ImportError; -PyAPI_DATA(PyObject *) PyExc_IndexError; -PyAPI_DATA(PyObject *) PyExc_KeyError; -PyAPI_DATA(PyObject *) PyExc_KeyboardInterrupt; -PyAPI_DATA(PyObject *) PyExc_MemoryError; -PyAPI_DATA(PyObject *) PyExc_NameError; -PyAPI_DATA(PyObject *) PyExc_OverflowError; -PyAPI_DATA(PyObject *) PyExc_RuntimeError; -PyAPI_DATA(PyObject *) PyExc_NotImplementedError; -PyAPI_DATA(PyObject *) PyExc_SyntaxError; -PyAPI_DATA(PyObject *) PyExc_IndentationError; -PyAPI_DATA(PyObject *) PyExc_TabError; -PyAPI_DATA(PyObject *) PyExc_ReferenceError; -PyAPI_DATA(PyObject *) PyExc_SystemError; -PyAPI_DATA(PyObject *) PyExc_SystemExit; -PyAPI_DATA(PyObject *) PyExc_TypeError; -PyAPI_DATA(PyObject *) PyExc_UnboundLocalError; -PyAPI_DATA(PyObject *) PyExc_UnicodeError; -PyAPI_DATA(PyObject *) PyExc_UnicodeEncodeError; -PyAPI_DATA(PyObject *) PyExc_UnicodeDecodeError; -PyAPI_DATA(PyObject *) PyExc_UnicodeTranslateError; -PyAPI_DATA(PyObject *) PyExc_ValueError; -PyAPI_DATA(PyObject *) PyExc_ZeroDivisionError; -#ifdef MS_WINDOWS -PyAPI_DATA(PyObject *) PyExc_WindowsError; -#endif -#ifdef __VMS -PyAPI_DATA(PyObject *) PyExc_VMSError; -#endif - -PyAPI_DATA(PyObject *) PyExc_BufferError; - -PyAPI_DATA(PyObject *) PyExc_MemoryErrorInst; -PyAPI_DATA(PyObject *) PyExc_RecursionErrorInst; - -/* Predefined warning categories */ -PyAPI_DATA(PyObject *) PyExc_Warning; -PyAPI_DATA(PyObject *) PyExc_UserWarning; -PyAPI_DATA(PyObject *) PyExc_DeprecationWarning; -PyAPI_DATA(PyObject *) PyExc_PendingDeprecationWarning; -PyAPI_DATA(PyObject *) PyExc_SyntaxWarning; -PyAPI_DATA(PyObject *) PyExc_RuntimeWarning; -PyAPI_DATA(PyObject *) PyExc_FutureWarning; -PyAPI_DATA(PyObject *) PyExc_ImportWarning; -PyAPI_DATA(PyObject *) PyExc_UnicodeWarning; -PyAPI_DATA(PyObject *) PyExc_BytesWarning; - - -/* Convenience functions */ - -PyAPI_FUNC(int) PyErr_BadArgument(void); -PyAPI_FUNC(PyObject *) PyErr_NoMemory(void); -PyAPI_FUNC(PyObject *) PyErr_SetFromErrno(PyObject *); -PyAPI_FUNC(PyObject *) PyErr_SetFromErrnoWithFilenameObject( - PyObject *, PyObject *); -PyAPI_FUNC(PyObject *) PyErr_SetFromErrnoWithFilename( - PyObject *, const char *); -#ifdef MS_WINDOWS -PyAPI_FUNC(PyObject *) PyErr_SetFromErrnoWithUnicodeFilename( - PyObject *, const Py_UNICODE *); -#endif /* MS_WINDOWS */ - -PyAPI_FUNC(PyObject *) PyErr_Format(PyObject *, const char *, ...) - Py_GCC_ATTRIBUTE((format(printf, 2, 3))); - -#ifdef MS_WINDOWS -PyAPI_FUNC(PyObject *) PyErr_SetFromWindowsErrWithFilenameObject( - int, const char *); -PyAPI_FUNC(PyObject *) PyErr_SetFromWindowsErrWithFilename( - int, const char *); -PyAPI_FUNC(PyObject *) PyErr_SetFromWindowsErrWithUnicodeFilename( - int, const Py_UNICODE *); -PyAPI_FUNC(PyObject *) PyErr_SetFromWindowsErr(int); -PyAPI_FUNC(PyObject *) PyErr_SetExcFromWindowsErrWithFilenameObject( - PyObject *,int, PyObject *); -PyAPI_FUNC(PyObject *) PyErr_SetExcFromWindowsErrWithFilename( - PyObject *,int, const char *); -PyAPI_FUNC(PyObject *) PyErr_SetExcFromWindowsErrWithUnicodeFilename( - PyObject *,int, const Py_UNICODE *); -PyAPI_FUNC(PyObject *) PyErr_SetExcFromWindowsErr(PyObject *, int); -#endif /* MS_WINDOWS */ - -/* Export the old function so that the existing API remains available: */ -PyAPI_FUNC(void) PyErr_BadInternalCall(void); -PyAPI_FUNC(void) _PyErr_BadInternalCall(char *filename, int lineno); -/* Mask the old API with a call to the new API for code compiled under - Python 2.0: */ -#define PyErr_BadInternalCall() _PyErr_BadInternalCall(__FILE__, __LINE__) - -/* Function to create a new exception */ -PyAPI_FUNC(PyObject *) PyErr_NewException( - char *name, PyObject *base, PyObject *dict); -PyAPI_FUNC(PyObject *) PyErr_NewExceptionWithDoc( - char *name, char *doc, PyObject *base, PyObject *dict); -PyAPI_FUNC(void) PyErr_WriteUnraisable(PyObject *); - -/* In sigcheck.c or signalmodule.c */ -PyAPI_FUNC(int) PyErr_CheckSignals(void); -PyAPI_FUNC(void) PyErr_SetInterrupt(void); - -/* In signalmodule.c */ -int PySignal_SetWakeupFd(int fd); - -/* Support for adding program text to SyntaxErrors */ -PyAPI_FUNC(void) PyErr_SyntaxLocation(const char *, int); -PyAPI_FUNC(PyObject *) PyErr_ProgramText(const char *, int); - -#ifdef Py_USING_UNICODE -/* The following functions are used to create and modify unicode - exceptions from C */ - -/* create a UnicodeDecodeError object */ -PyAPI_FUNC(PyObject *) PyUnicodeDecodeError_Create( - const char *, const char *, Py_ssize_t, Py_ssize_t, Py_ssize_t, const char *); - -/* create a UnicodeEncodeError object */ -PyAPI_FUNC(PyObject *) PyUnicodeEncodeError_Create( - const char *, const Py_UNICODE *, Py_ssize_t, Py_ssize_t, Py_ssize_t, const char *); - -/* create a UnicodeTranslateError object */ -PyAPI_FUNC(PyObject *) PyUnicodeTranslateError_Create( - const Py_UNICODE *, Py_ssize_t, Py_ssize_t, Py_ssize_t, const char *); - -/* get the encoding attribute */ -PyAPI_FUNC(PyObject *) PyUnicodeEncodeError_GetEncoding(PyObject *); -PyAPI_FUNC(PyObject *) PyUnicodeDecodeError_GetEncoding(PyObject *); - -/* get the object attribute */ -PyAPI_FUNC(PyObject *) PyUnicodeEncodeError_GetObject(PyObject *); -PyAPI_FUNC(PyObject *) PyUnicodeDecodeError_GetObject(PyObject *); -PyAPI_FUNC(PyObject *) PyUnicodeTranslateError_GetObject(PyObject *); - -/* get the value of the start attribute (the int * may not be NULL) - return 0 on success, -1 on failure */ -PyAPI_FUNC(int) PyUnicodeEncodeError_GetStart(PyObject *, Py_ssize_t *); -PyAPI_FUNC(int) PyUnicodeDecodeError_GetStart(PyObject *, Py_ssize_t *); -PyAPI_FUNC(int) PyUnicodeTranslateError_GetStart(PyObject *, Py_ssize_t *); - -/* assign a new value to the start attribute - return 0 on success, -1 on failure */ -PyAPI_FUNC(int) PyUnicodeEncodeError_SetStart(PyObject *, Py_ssize_t); -PyAPI_FUNC(int) PyUnicodeDecodeError_SetStart(PyObject *, Py_ssize_t); -PyAPI_FUNC(int) PyUnicodeTranslateError_SetStart(PyObject *, Py_ssize_t); - -/* get the value of the end attribute (the int *may not be NULL) - return 0 on success, -1 on failure */ -PyAPI_FUNC(int) PyUnicodeEncodeError_GetEnd(PyObject *, Py_ssize_t *); -PyAPI_FUNC(int) PyUnicodeDecodeError_GetEnd(PyObject *, Py_ssize_t *); -PyAPI_FUNC(int) PyUnicodeTranslateError_GetEnd(PyObject *, Py_ssize_t *); - -/* assign a new value to the end attribute - return 0 on success, -1 on failure */ -PyAPI_FUNC(int) PyUnicodeEncodeError_SetEnd(PyObject *, Py_ssize_t); -PyAPI_FUNC(int) PyUnicodeDecodeError_SetEnd(PyObject *, Py_ssize_t); -PyAPI_FUNC(int) PyUnicodeTranslateError_SetEnd(PyObject *, Py_ssize_t); - -/* get the value of the reason attribute */ -PyAPI_FUNC(PyObject *) PyUnicodeEncodeError_GetReason(PyObject *); -PyAPI_FUNC(PyObject *) PyUnicodeDecodeError_GetReason(PyObject *); -PyAPI_FUNC(PyObject *) PyUnicodeTranslateError_GetReason(PyObject *); - -/* assign a new value to the reason attribute - return 0 on success, -1 on failure */ -PyAPI_FUNC(int) PyUnicodeEncodeError_SetReason( - PyObject *, const char *); -PyAPI_FUNC(int) PyUnicodeDecodeError_SetReason( - PyObject *, const char *); -PyAPI_FUNC(int) PyUnicodeTranslateError_SetReason( - PyObject *, const char *); -#endif - - -/* These APIs aren't really part of the error implementation, but - often needed to format error messages; the native C lib APIs are - not available on all platforms, which is why we provide emulations - for those platforms in Python/mysnprintf.c, - WARNING: The return value of snprintf varies across platforms; do - not rely on any particular behavior; eventually the C99 defn may - be reliable. -*/ -#if defined(MS_WIN32) && !defined(HAVE_SNPRINTF) -# define HAVE_SNPRINTF -# define snprintf _snprintf -# define vsnprintf _vsnprintf -#endif - -#include -PyAPI_FUNC(int) PyOS_snprintf(char *str, size_t size, const char *format, ...) - Py_GCC_ATTRIBUTE((format(printf, 3, 4))); -PyAPI_FUNC(int) PyOS_vsnprintf(char *str, size_t size, const char *format, va_list va) - Py_GCC_ATTRIBUTE((format(printf, 3, 0))); - -#ifdef __cplusplus -} -#endif -#endif /* !Py_ERRORS_H */ diff --git a/python/include/pyexpat.h b/python/include/pyexpat.h deleted file mode 100644 index 5340ef5f..00000000 --- a/python/include/pyexpat.h +++ /dev/null @@ -1,48 +0,0 @@ -/* Stuff to export relevant 'expat' entry points from pyexpat to other - * parser modules, such as cElementTree. */ - -/* note: you must import expat.h before importing this module! */ - -#define PyExpat_CAPI_MAGIC "pyexpat.expat_CAPI 1.0" -#define PyExpat_CAPSULE_NAME "pyexpat.expat_CAPI" - -struct PyExpat_CAPI -{ - char* magic; /* set to PyExpat_CAPI_MAGIC */ - int size; /* set to sizeof(struct PyExpat_CAPI) */ - int MAJOR_VERSION; - int MINOR_VERSION; - int MICRO_VERSION; - /* pointers to selected expat functions. add new functions at - the end, if needed */ - const XML_LChar * (*ErrorString)(enum XML_Error code); - enum XML_Error (*GetErrorCode)(XML_Parser parser); - XML_Size (*GetErrorColumnNumber)(XML_Parser parser); - XML_Size (*GetErrorLineNumber)(XML_Parser parser); - enum XML_Status (*Parse)( - XML_Parser parser, const char *s, int len, int isFinal); - XML_Parser (*ParserCreate_MM)( - const XML_Char *encoding, const XML_Memory_Handling_Suite *memsuite, - const XML_Char *namespaceSeparator); - void (*ParserFree)(XML_Parser parser); - void (*SetCharacterDataHandler)( - XML_Parser parser, XML_CharacterDataHandler handler); - void (*SetCommentHandler)( - XML_Parser parser, XML_CommentHandler handler); - void (*SetDefaultHandlerExpand)( - XML_Parser parser, XML_DefaultHandler handler); - void (*SetElementHandler)( - XML_Parser parser, XML_StartElementHandler start, - XML_EndElementHandler end); - void (*SetNamespaceDeclHandler)( - XML_Parser parser, XML_StartNamespaceDeclHandler start, - XML_EndNamespaceDeclHandler end); - void (*SetProcessingInstructionHandler)( - XML_Parser parser, XML_ProcessingInstructionHandler handler); - void (*SetUnknownEncodingHandler)( - XML_Parser parser, XML_UnknownEncodingHandler handler, - void *encodingHandlerData); - void (*SetUserData)(XML_Parser parser, void *userData); - /* always add new stuff to the end! */ -}; - diff --git a/python/include/pyfpe.h b/python/include/pyfpe.h deleted file mode 100644 index 19110ab0..00000000 --- a/python/include/pyfpe.h +++ /dev/null @@ -1,176 +0,0 @@ -#ifndef Py_PYFPE_H -#define Py_PYFPE_H -#ifdef __cplusplus -extern "C" { -#endif -/* - --------------------------------------------------------------------- - / Copyright (c) 1996. \ - | The Regents of the University of California. | - | All rights reserved. | - | | - | Permission to use, copy, modify, and distribute this software for | - | any purpose without fee is hereby granted, provided that this en- | - | tire notice is included in all copies of any software which is or | - | includes a copy or modification of this software and in all | - | copies of the supporting documentation for such software. | - | | - | This work was produced at the University of California, Lawrence | - | Livermore National Laboratory under contract no. W-7405-ENG-48 | - | between the U.S. Department of Energy and The Regents of the | - | University of California for the operation of UC LLNL. | - | | - | DISCLAIMER | - | | - | This software was prepared as an account of work sponsored by an | - | agency of the United States Government. Neither the United States | - | Government nor the University of California nor any of their em- | - | ployees, makes any warranty, express or implied, or assumes any | - | liability or responsibility for the accuracy, completeness, or | - | usefulness of any information, apparatus, product, or process | - | disclosed, or represents that its use would not infringe | - | privately-owned rights. Reference herein to any specific commer- | - | cial products, process, or service by trade name, trademark, | - | manufacturer, or otherwise, does not necessarily constitute or | - | imply its endorsement, recommendation, or favoring by the United | - | States Government or the University of California. The views and | - | opinions of authors expressed herein do not necessarily state or | - | reflect those of the United States Government or the University | - | of California, and shall not be used for advertising or product | - \ endorsement purposes. / - --------------------------------------------------------------------- -*/ - -/* - * Define macros for handling SIGFPE. - * Lee Busby, LLNL, November, 1996 - * busby1@llnl.gov - * - ********************************************* - * Overview of the system for handling SIGFPE: - * - * This file (Include/pyfpe.h) defines a couple of "wrapper" macros for - * insertion into your Python C code of choice. Their proper use is - * discussed below. The file Python/pyfpe.c defines a pair of global - * variables PyFPE_jbuf and PyFPE_counter which are used by the signal - * handler for SIGFPE to decide if a particular exception was protected - * by the macros. The signal handler itself, and code for enabling the - * generation of SIGFPE in the first place, is in a (new) Python module - * named fpectl. This module is standard in every respect. It can be loaded - * either statically or dynamically as you choose, and like any other - * Python module, has no effect until you import it. - * - * In the general case, there are three steps toward handling SIGFPE in any - * Python code: - * - * 1) Add the *_PROTECT macros to your C code as required to protect - * dangerous floating point sections. - * - * 2) Turn on the inclusion of the code by adding the ``--with-fpectl'' - * flag at the time you run configure. If the fpectl or other modules - * which use the *_PROTECT macros are to be dynamically loaded, be - * sure they are compiled with WANT_SIGFPE_HANDLER defined. - * - * 3) When python is built and running, import fpectl, and execute - * fpectl.turnon_sigfpe(). This sets up the signal handler and enables - * generation of SIGFPE whenever an exception occurs. From this point - * on, any properly trapped SIGFPE should result in the Python - * FloatingPointError exception. - * - * Step 1 has been done already for the Python kernel code, and should be - * done soon for the NumPy array package. Step 2 is usually done once at - * python install time. Python's behavior with respect to SIGFPE is not - * changed unless you also do step 3. Thus you can control this new - * facility at compile time, or run time, or both. - * - ******************************** - * Using the macros in your code: - * - * static PyObject *foobar(PyObject *self,PyObject *args) - * { - * .... - * PyFPE_START_PROTECT("Error in foobar", return 0) - * result = dangerous_op(somearg1, somearg2, ...); - * PyFPE_END_PROTECT(result) - * .... - * } - * - * If a floating point error occurs in dangerous_op, foobar returns 0 (NULL), - * after setting the associated value of the FloatingPointError exception to - * "Error in foobar". ``Dangerous_op'' can be a single operation, or a block - * of code, function calls, or any combination, so long as no alternate - * return is possible before the PyFPE_END_PROTECT macro is reached. - * - * The macros can only be used in a function context where an error return - * can be recognized as signaling a Python exception. (Generally, most - * functions that return a PyObject * will qualify.) - * - * Guido's original design suggestion for PyFPE_START_PROTECT and - * PyFPE_END_PROTECT had them open and close a local block, with a locally - * defined jmp_buf and jmp_buf pointer. This would allow recursive nesting - * of the macros. The Ansi C standard makes it clear that such local - * variables need to be declared with the "volatile" type qualifier to keep - * setjmp from corrupting their values. Some current implementations seem - * to be more restrictive. For example, the HPUX man page for setjmp says - * - * Upon the return from a setjmp() call caused by a longjmp(), the - * values of any non-static local variables belonging to the routine - * from which setjmp() was called are undefined. Code which depends on - * such values is not guaranteed to be portable. - * - * I therefore decided on a more limited form of nesting, using a counter - * variable (PyFPE_counter) to keep track of any recursion. If an exception - * occurs in an ``inner'' pair of macros, the return will apparently - * come from the outermost level. - * - */ - -#ifdef WANT_SIGFPE_HANDLER -#include -#include -#include -extern jmp_buf PyFPE_jbuf; -extern int PyFPE_counter; -extern double PyFPE_dummy(void *); - -#define PyFPE_START_PROTECT(err_string, leave_stmt) \ -if (!PyFPE_counter++ && setjmp(PyFPE_jbuf)) { \ - PyErr_SetString(PyExc_FloatingPointError, err_string); \ - PyFPE_counter = 0; \ - leave_stmt; \ -} - -/* - * This (following) is a heck of a way to decrement a counter. However, - * unless the macro argument is provided, code optimizers will sometimes move - * this statement so that it gets executed *before* the unsafe expression - * which we're trying to protect. That pretty well messes things up, - * of course. - * - * If the expression(s) you're trying to protect don't happen to return a - * value, you will need to manufacture a dummy result just to preserve the - * correct ordering of statements. Note that the macro passes the address - * of its argument (so you need to give it something which is addressable). - * If your expression returns multiple results, pass the last such result - * to PyFPE_END_PROTECT. - * - * Note that PyFPE_dummy returns a double, which is cast to int. - * This seeming insanity is to tickle the Floating Point Unit (FPU). - * If an exception has occurred in a preceding floating point operation, - * some architectures (notably Intel 80x86) will not deliver the interrupt - * until the *next* floating point operation. This is painful if you've - * already decremented PyFPE_counter. - */ -#define PyFPE_END_PROTECT(v) PyFPE_counter -= (int)PyFPE_dummy(&(v)); - -#else - -#define PyFPE_START_PROTECT(err_string, leave_stmt) -#define PyFPE_END_PROTECT(v) - -#endif - -#ifdef __cplusplus -} -#endif -#endif /* !Py_PYFPE_H */ diff --git a/python/include/pygetopt.h b/python/include/pygetopt.h deleted file mode 100644 index 9860d360..00000000 --- a/python/include/pygetopt.h +++ /dev/null @@ -1,18 +0,0 @@ - -#ifndef Py_PYGETOPT_H -#define Py_PYGETOPT_H -#ifdef __cplusplus -extern "C" { -#endif - -PyAPI_DATA(int) _PyOS_opterr; -PyAPI_DATA(int) _PyOS_optind; -PyAPI_DATA(char *) _PyOS_optarg; - -PyAPI_FUNC(void) _PyOS_ResetGetOpt(void); -PyAPI_FUNC(int) _PyOS_GetOpt(int argc, char **argv, char *optstring); - -#ifdef __cplusplus -} -#endif -#endif /* !Py_PYGETOPT_H */ diff --git a/python/include/pymacconfig.h b/python/include/pymacconfig.h deleted file mode 100644 index 24e7b8da..00000000 --- a/python/include/pymacconfig.h +++ /dev/null @@ -1,102 +0,0 @@ -#ifndef PYMACCONFIG_H -#define PYMACCONFIG_H - /* - * This file moves some of the autoconf magic to compile-time - * when building on MacOSX. This is needed for building 4-way - * universal binaries and for 64-bit universal binaries because - * the values redefined below aren't configure-time constant but - * only compile-time constant in these scenarios. - */ - -#if defined(__APPLE__) - -# undef SIZEOF_LONG -# undef SIZEOF_PTHREAD_T -# undef SIZEOF_SIZE_T -# undef SIZEOF_TIME_T -# undef SIZEOF_VOID_P -# undef SIZEOF__BOOL -# undef SIZEOF_UINTPTR_T -# undef SIZEOF_PTHREAD_T -# undef WORDS_BIGENDIAN -# undef DOUBLE_IS_ARM_MIXED_ENDIAN_IEEE754 -# undef DOUBLE_IS_BIG_ENDIAN_IEEE754 -# undef DOUBLE_IS_LITTLE_ENDIAN_IEEE754 -# undef HAVE_GCC_ASM_FOR_X87 - -# undef VA_LIST_IS_ARRAY -# if defined(__LP64__) && defined(__x86_64__) -# define VA_LIST_IS_ARRAY 1 -# endif - -# undef HAVE_LARGEFILE_SUPPORT -# ifndef __LP64__ -# define HAVE_LARGEFILE_SUPPORT 1 -# endif - -# undef SIZEOF_LONG -# ifdef __LP64__ -# define SIZEOF__BOOL 1 -# define SIZEOF__BOOL 1 -# define SIZEOF_LONG 8 -# define SIZEOF_PTHREAD_T 8 -# define SIZEOF_SIZE_T 8 -# define SIZEOF_TIME_T 8 -# define SIZEOF_VOID_P 8 -# define SIZEOF_UINTPTR_T 8 -# define SIZEOF_PTHREAD_T 8 -# else -# ifdef __ppc__ -# define SIZEOF__BOOL 4 -# else -# define SIZEOF__BOOL 1 -# endif -# define SIZEOF_LONG 4 -# define SIZEOF_PTHREAD_T 4 -# define SIZEOF_SIZE_T 4 -# define SIZEOF_TIME_T 4 -# define SIZEOF_VOID_P 4 -# define SIZEOF_UINTPTR_T 4 -# define SIZEOF_PTHREAD_T 4 -# endif - -# if defined(__LP64__) - /* MacOSX 10.4 (the first release to support 64-bit code - * at all) only supports 64-bit in the UNIX layer. - * Therefore surpress the toolbox-glue in 64-bit mode. - */ - - /* In 64-bit mode setpgrp always has no argments, in 32-bit - * mode that depends on the compilation environment - */ -# undef SETPGRP_HAVE_ARG - -# endif - -#ifdef __BIG_ENDIAN__ -#define WORDS_BIGENDIAN 1 -#define DOUBLE_IS_BIG_ENDIAN_IEEE754 -#else -#define DOUBLE_IS_LITTLE_ENDIAN_IEEE754 -#endif /* __BIG_ENDIAN */ - -#ifdef __i386__ -# define HAVE_GCC_ASM_FOR_X87 -#endif - - /* - * The definition in pyconfig.h is only valid on the OS release - * where configure ran on and not necessarily for all systems where - * the executable can be used on. - * - * Specifically: OSX 10.4 has limited supported for '%zd', while - * 10.5 has full support for '%zd'. A binary built on 10.5 won't - * work properly on 10.4 unless we surpress the definition - * of PY_FORMAT_SIZE_T - */ -#undef PY_FORMAT_SIZE_T - - -#endif /* defined(_APPLE__) */ - -#endif /* PYMACCONFIG_H */ diff --git a/python/include/pymactoolbox.h b/python/include/pymactoolbox.h deleted file mode 100644 index fd159752..00000000 --- a/python/include/pymactoolbox.h +++ /dev/null @@ -1,217 +0,0 @@ -/* -** pymactoolbox.h - globals defined in mactoolboxglue.c -*/ -#ifndef Py_PYMACTOOLBOX_H -#define Py_PYMACTOOLBOX_H -#ifdef __cplusplus - extern "C" { -#endif - -#include - -#ifndef __LP64__ -#include -#endif /* !__LP64__ */ - -/* -** Helper routines for error codes and such. -*/ -char *PyMac_StrError(int); /* strerror with mac errors */ -extern PyObject *PyMac_OSErrException; /* Exception for OSErr */ -PyObject *PyMac_GetOSErrException(void); /* Initialize & return it */ -PyObject *PyErr_Mac(PyObject *, int); /* Exception with a mac error */ -PyObject *PyMac_Error(OSErr); /* Uses PyMac_GetOSErrException */ -#ifndef __LP64__ -extern OSErr PyMac_GetFullPathname(FSSpec *, char *, int); /* convert - fsspec->path */ -#endif /* __LP64__ */ - -/* -** These conversion routines are defined in mactoolboxglue.c itself. -*/ -int PyMac_GetOSType(PyObject *, OSType *); /* argument parser for OSType */ -PyObject *PyMac_BuildOSType(OSType); /* Convert OSType to PyObject */ - -PyObject *PyMac_BuildNumVersion(NumVersion);/* Convert NumVersion to PyObject */ - -int PyMac_GetStr255(PyObject *, Str255); /* argument parser for Str255 */ -PyObject *PyMac_BuildStr255(Str255); /* Convert Str255 to PyObject */ -PyObject *PyMac_BuildOptStr255(Str255); /* Convert Str255 to PyObject, - NULL to None */ - -int PyMac_GetRect(PyObject *, Rect *); /* argument parser for Rect */ -PyObject *PyMac_BuildRect(Rect *); /* Convert Rect to PyObject */ - -int PyMac_GetPoint(PyObject *, Point *); /* argument parser for Point */ -PyObject *PyMac_BuildPoint(Point); /* Convert Point to PyObject */ - -int PyMac_GetEventRecord(PyObject *, EventRecord *); /* argument parser for - EventRecord */ -PyObject *PyMac_BuildEventRecord(EventRecord *); /* Convert EventRecord to - PyObject */ - -int PyMac_GetFixed(PyObject *, Fixed *); /* argument parser for Fixed */ -PyObject *PyMac_BuildFixed(Fixed); /* Convert Fixed to PyObject */ -int PyMac_Getwide(PyObject *, wide *); /* argument parser for wide */ -PyObject *PyMac_Buildwide(wide *); /* Convert wide to PyObject */ - -/* -** The rest of the routines are implemented by extension modules. If they are -** dynamically loaded mactoolboxglue will contain a stub implementation of the -** routine, which imports the module, whereupon the module's init routine will -** communicate the routine pointer back to the stub. -** If USE_TOOLBOX_OBJECT_GLUE is not defined there is no glue code, and the -** extension modules simply declare the routine. This is the case for static -** builds (and could be the case for MacPython CFM builds, because CFM extension -** modules can reference each other without problems). -*/ - -#ifdef USE_TOOLBOX_OBJECT_GLUE -/* -** These macros are used in the module init code. If we use toolbox object glue -** it sets the function pointer to point to the real function. -*/ -#define PyMac_INIT_TOOLBOX_OBJECT_NEW(object, rtn) { \ - extern PyObject *(*PyMacGluePtr_##rtn)(object); \ - PyMacGluePtr_##rtn = _##rtn; \ -} -#define PyMac_INIT_TOOLBOX_OBJECT_CONVERT(object, rtn) { \ - extern int (*PyMacGluePtr_##rtn)(PyObject *, object *); \ - PyMacGluePtr_##rtn = _##rtn; \ -} -#else -/* -** If we don't use toolbox object glue the init macros are empty. Moreover, we define -** _xxx_New to be the same as xxx_New, and the code in mactoolboxglue isn't included. -*/ -#define PyMac_INIT_TOOLBOX_OBJECT_NEW(object, rtn) -#define PyMac_INIT_TOOLBOX_OBJECT_CONVERT(object, rtn) -#endif /* USE_TOOLBOX_OBJECT_GLUE */ - -/* macfs exports */ -#ifndef __LP64__ -int PyMac_GetFSSpec(PyObject *, FSSpec *); /* argument parser for FSSpec */ -PyObject *PyMac_BuildFSSpec(FSSpec *); /* Convert FSSpec to PyObject */ -#endif /* !__LP64__ */ - -int PyMac_GetFSRef(PyObject *, FSRef *); /* argument parser for FSRef */ -PyObject *PyMac_BuildFSRef(FSRef *); /* Convert FSRef to PyObject */ - -/* AE exports */ -extern PyObject *AEDesc_New(AppleEvent *); /* XXXX Why passed by address?? */ -extern PyObject *AEDesc_NewBorrowed(AppleEvent *); -extern int AEDesc_Convert(PyObject *, AppleEvent *); - -/* Cm exports */ -extern PyObject *CmpObj_New(Component); -extern int CmpObj_Convert(PyObject *, Component *); -extern PyObject *CmpInstObj_New(ComponentInstance); -extern int CmpInstObj_Convert(PyObject *, ComponentInstance *); - -/* Ctl exports */ -#ifndef __LP64__ -extern PyObject *CtlObj_New(ControlHandle); -extern int CtlObj_Convert(PyObject *, ControlHandle *); -#endif /* !__LP64__ */ - -/* Dlg exports */ -#ifndef __LP64__ -extern PyObject *DlgObj_New(DialogPtr); -extern int DlgObj_Convert(PyObject *, DialogPtr *); -extern PyObject *DlgObj_WhichDialog(DialogPtr); -#endif /* !__LP64__ */ - -/* Drag exports */ -#ifndef __LP64__ -extern PyObject *DragObj_New(DragReference); -extern int DragObj_Convert(PyObject *, DragReference *); -#endif /* !__LP64__ */ - -/* List exports */ -#ifndef __LP64__ -extern PyObject *ListObj_New(ListHandle); -extern int ListObj_Convert(PyObject *, ListHandle *); -#endif /* !__LP64__ */ - -/* Menu exports */ -#ifndef __LP64__ -extern PyObject *MenuObj_New(MenuHandle); -extern int MenuObj_Convert(PyObject *, MenuHandle *); -#endif /* !__LP64__ */ - -/* Qd exports */ -#ifndef __LP64__ -extern PyObject *GrafObj_New(GrafPtr); -extern int GrafObj_Convert(PyObject *, GrafPtr *); -extern PyObject *BMObj_New(BitMapPtr); -extern int BMObj_Convert(PyObject *, BitMapPtr *); -extern PyObject *QdRGB_New(RGBColor *); -extern int QdRGB_Convert(PyObject *, RGBColor *); -#endif /* !__LP64__ */ - -/* Qdoffs exports */ -#ifndef __LP64__ -extern PyObject *GWorldObj_New(GWorldPtr); -extern int GWorldObj_Convert(PyObject *, GWorldPtr *); -#endif /* !__LP64__ */ - -/* Qt exports */ -#ifndef __LP64__ -extern PyObject *TrackObj_New(Track); -extern int TrackObj_Convert(PyObject *, Track *); -extern PyObject *MovieObj_New(Movie); -extern int MovieObj_Convert(PyObject *, Movie *); -extern PyObject *MovieCtlObj_New(MovieController); -extern int MovieCtlObj_Convert(PyObject *, MovieController *); -extern PyObject *TimeBaseObj_New(TimeBase); -extern int TimeBaseObj_Convert(PyObject *, TimeBase *); -extern PyObject *UserDataObj_New(UserData); -extern int UserDataObj_Convert(PyObject *, UserData *); -extern PyObject *MediaObj_New(Media); -extern int MediaObj_Convert(PyObject *, Media *); -#endif /* !__LP64__ */ - -/* Res exports */ -extern PyObject *ResObj_New(Handle); -extern int ResObj_Convert(PyObject *, Handle *); -extern PyObject *OptResObj_New(Handle); -extern int OptResObj_Convert(PyObject *, Handle *); - -/* TE exports */ -#ifndef __LP64__ -extern PyObject *TEObj_New(TEHandle); -extern int TEObj_Convert(PyObject *, TEHandle *); -#endif /* !__LP64__ */ - -/* Win exports */ -#ifndef __LP64__ -extern PyObject *WinObj_New(WindowPtr); -extern int WinObj_Convert(PyObject *, WindowPtr *); -extern PyObject *WinObj_WhichWindow(WindowPtr); -#endif /* !__LP64__ */ - -/* CF exports */ -extern PyObject *CFObj_New(CFTypeRef); -extern int CFObj_Convert(PyObject *, CFTypeRef *); -extern PyObject *CFTypeRefObj_New(CFTypeRef); -extern int CFTypeRefObj_Convert(PyObject *, CFTypeRef *); -extern PyObject *CFStringRefObj_New(CFStringRef); -extern int CFStringRefObj_Convert(PyObject *, CFStringRef *); -extern PyObject *CFMutableStringRefObj_New(CFMutableStringRef); -extern int CFMutableStringRefObj_Convert(PyObject *, CFMutableStringRef *); -extern PyObject *CFArrayRefObj_New(CFArrayRef); -extern int CFArrayRefObj_Convert(PyObject *, CFArrayRef *); -extern PyObject *CFMutableArrayRefObj_New(CFMutableArrayRef); -extern int CFMutableArrayRefObj_Convert(PyObject *, CFMutableArrayRef *); -extern PyObject *CFDictionaryRefObj_New(CFDictionaryRef); -extern int CFDictionaryRefObj_Convert(PyObject *, CFDictionaryRef *); -extern PyObject *CFMutableDictionaryRefObj_New(CFMutableDictionaryRef); -extern int CFMutableDictionaryRefObj_Convert(PyObject *, CFMutableDictionaryRef *); -extern PyObject *CFURLRefObj_New(CFURLRef); -extern int CFURLRefObj_Convert(PyObject *, CFURLRef *); -extern int OptionalCFURLRefObj_Convert(PyObject *, CFURLRef *); - -#ifdef __cplusplus - } -#endif -#endif diff --git a/python/include/pymath.h b/python/include/pymath.h deleted file mode 100644 index f77ce930..00000000 --- a/python/include/pymath.h +++ /dev/null @@ -1,192 +0,0 @@ -#ifndef Py_PYMATH_H -#define Py_PYMATH_H - -#include "pyconfig.h" /* include for defines */ - -/************************************************************************** -Symbols and macros to supply platform-independent interfaces to mathematical -functions and constants -**************************************************************************/ - -/* Python provides implementations for copysign, round and hypot in - * Python/pymath.c just in case your math library doesn't provide the - * functions. - * - *Note: PC/pyconfig.h defines copysign as _copysign - */ -#ifndef HAVE_COPYSIGN -extern double copysign(double, double); -#endif - -#ifndef HAVE_ROUND -extern double round(double); -#endif - -#ifndef HAVE_HYPOT -extern double hypot(double, double); -#endif - -/* extra declarations */ -#ifndef _MSC_VER -#ifndef __STDC__ -//extern double fmod (double, double); -//extern double frexp (double, int *); -//extern double ldexp (double, int); -//extern double modf (double, double *); -//extern double pow(double, double); -#endif /* __STDC__ */ -#endif /* _MSC_VER */ - -#ifdef _OSF_SOURCE -/* OSF1 5.1 doesn't make these available with XOPEN_SOURCE_EXTENDED defined */ -extern int finite(double); -extern double copysign(double, double); -#endif - -/* High precision defintion of pi and e (Euler) - * The values are taken from libc6's math.h. - */ -#ifndef Py_MATH_PIl -#define Py_MATH_PIl 3.1415926535897932384626433832795029L -#endif -#ifndef Py_MATH_PI -#define Py_MATH_PI 3.14159265358979323846 -#endif - -#ifndef Py_MATH_El -#define Py_MATH_El 2.7182818284590452353602874713526625L -#endif - -#ifndef Py_MATH_E -#define Py_MATH_E 2.7182818284590452354 -#endif - -/* On x86, Py_FORCE_DOUBLE forces a floating-point number out of an x87 FPU - register and into a 64-bit memory location, rounding from extended - precision to double precision in the process. On other platforms it does - nothing. */ - -/* we take double rounding as evidence of x87 usage */ -#ifndef Py_FORCE_DOUBLE -# ifdef X87_DOUBLE_ROUNDING -PyAPI_FUNC(double) _Py_force_double(double); -# define Py_FORCE_DOUBLE(X) (_Py_force_double(X)) -# else -# define Py_FORCE_DOUBLE(X) (X) -# endif -#endif - -#ifdef HAVE_GCC_ASM_FOR_X87 -PyAPI_FUNC(unsigned short) _Py_get_387controlword(void); -PyAPI_FUNC(void) _Py_set_387controlword(unsigned short); -#endif - -/* Py_IS_NAN(X) - * Return 1 if float or double arg is a NaN, else 0. - * Caution: - * X is evaluated more than once. - * This may not work on all platforms. Each platform has *some* - * way to spell this, though -- override in pyconfig.h if you have - * a platform where it doesn't work. - * Note: PC/pyconfig.h defines Py_IS_NAN as _isnan - */ -#ifndef Py_IS_NAN -#if defined HAVE_DECL_ISNAN && HAVE_DECL_ISNAN == 1 -#define Py_IS_NAN(X) isnan(X) -#else -#define Py_IS_NAN(X) ((X) != (X)) -#endif -#endif - -/* Py_IS_INFINITY(X) - * Return 1 if float or double arg is an infinity, else 0. - * Caution: - * X is evaluated more than once. - * This implementation may set the underflow flag if |X| is very small; - * it really can't be implemented correctly (& easily) before C99. - * Override in pyconfig.h if you have a better spelling on your platform. - * Py_FORCE_DOUBLE is used to avoid getting false negatives from a - * non-infinite value v sitting in an 80-bit x87 register such that - * v becomes infinite when spilled from the register to 64-bit memory. - * Note: PC/pyconfig.h defines Py_IS_INFINITY as _isinf - */ -#ifndef Py_IS_INFINITY -# if defined HAVE_DECL_ISINF && HAVE_DECL_ISINF == 1 -# define Py_IS_INFINITY(X) isinf(X) -# else -# define Py_IS_INFINITY(X) ((X) && \ - (Py_FORCE_DOUBLE(X)*0.5 == Py_FORCE_DOUBLE(X))) -# endif -#endif - -/* Py_IS_FINITE(X) - * Return 1 if float or double arg is neither infinite nor NAN, else 0. - * Some compilers (e.g. VisualStudio) have intrisics for this, so a special - * macro for this particular test is useful - * Note: PC/pyconfig.h defines Py_IS_FINITE as _finite - */ -#ifndef Py_IS_FINITE -#if defined HAVE_DECL_ISFINITE && HAVE_DECL_ISFINITE == 1 -#define Py_IS_FINITE(X) isfinite(X) -#elif defined HAVE_FINITE -#define Py_IS_FINITE(X) finite(X) -#else -#define Py_IS_FINITE(X) (!Py_IS_INFINITY(X) && !Py_IS_NAN(X)) -#endif -#endif - -/* HUGE_VAL is supposed to expand to a positive double infinity. Python - * uses Py_HUGE_VAL instead because some platforms are broken in this - * respect. We used to embed code in pyport.h to try to worm around that, - * but different platforms are broken in conflicting ways. If you're on - * a platform where HUGE_VAL is defined incorrectly, fiddle your Python - * config to #define Py_HUGE_VAL to something that works on your platform. - */ -#ifndef Py_HUGE_VAL -#define Py_HUGE_VAL HUGE_VAL -#endif - -/* Py_NAN - * A value that evaluates to a NaN. On IEEE 754 platforms INF*0 or - * INF/INF works. Define Py_NO_NAN in pyconfig.h if your platform - * doesn't support NaNs. - */ -#if !defined(Py_NAN) && !defined(Py_NO_NAN) -#define Py_NAN (Py_HUGE_VAL * 0.) -#endif - -/* Py_OVERFLOWED(X) - * Return 1 iff a libm function overflowed. Set errno to 0 before calling - * a libm function, and invoke this macro after, passing the function - * result. - * Caution: - * This isn't reliable. C99 no longer requires libm to set errno under - * any exceptional condition, but does require +- HUGE_VAL return - * values on overflow. A 754 box *probably* maps HUGE_VAL to a - * double infinity, and we're cool if that's so, unless the input - * was an infinity and an infinity is the expected result. A C89 - * system sets errno to ERANGE, so we check for that too. We're - * out of luck if a C99 754 box doesn't map HUGE_VAL to +Inf, or - * if the returned result is a NaN, or if a C89 box returns HUGE_VAL - * in non-overflow cases. - * X is evaluated more than once. - * Some platforms have better way to spell this, so expect some #ifdef'ery. - * - * OpenBSD uses 'isinf()' because a compiler bug on that platform causes - * the longer macro version to be mis-compiled. This isn't optimal, and - * should be removed once a newer compiler is available on that platform. - * The system that had the failure was running OpenBSD 3.2 on Intel, with - * gcc 2.95.3. - * - * According to Tim's checkin, the FreeBSD systems use isinf() to work - * around a FPE bug on that platform. - */ -#if defined(__FreeBSD__) || defined(__OpenBSD__) -#define Py_OVERFLOWED(X) isinf(X) -#else -#define Py_OVERFLOWED(X) ((X) != 0.0 && (errno == ERANGE || \ - (X) == Py_HUGE_VAL || \ - (X) == -Py_HUGE_VAL)) -#endif - -#endif /* Py_PYMATH_H */ diff --git a/python/include/pymem.h b/python/include/pymem.h deleted file mode 100644 index 10b5bea5..00000000 --- a/python/include/pymem.h +++ /dev/null @@ -1,122 +0,0 @@ -/* The PyMem_ family: low-level memory allocation interfaces. - See objimpl.h for the PyObject_ memory family. -*/ - -#ifndef Py_PYMEM_H -#define Py_PYMEM_H - -#include "pyport.h" - -#ifdef __cplusplus -extern "C" { -#endif - -/* BEWARE: - - Each interface exports both functions and macros. Extension modules should - use the functions, to ensure binary compatibility across Python versions. - Because the Python implementation is free to change internal details, and - the macros may (or may not) expose details for speed, if you do use the - macros you must recompile your extensions with each Python release. - - Never mix calls to PyMem_ with calls to the platform malloc/realloc/ - calloc/free. For example, on Windows different DLLs may end up using - different heaps, and if you use PyMem_Malloc you'll get the memory from the - heap used by the Python DLL; it could be a disaster if you free()'ed that - directly in your own extension. Using PyMem_Free instead ensures Python - can return the memory to the proper heap. As another example, in - PYMALLOC_DEBUG mode, Python wraps all calls to all PyMem_ and PyObject_ - memory functions in special debugging wrappers that add additional - debugging info to dynamic memory blocks. The system routines have no idea - what to do with that stuff, and the Python wrappers have no idea what to do - with raw blocks obtained directly by the system routines then. - - The GIL must be held when using these APIs. -*/ - -/* - * Raw memory interface - * ==================== - */ - -/* Functions - - Functions supplying platform-independent semantics for malloc/realloc/ - free. These functions make sure that allocating 0 bytes returns a distinct - non-NULL pointer (whenever possible -- if we're flat out of memory, NULL - may be returned), even if the platform malloc and realloc don't. - Returned pointers must be checked for NULL explicitly. No action is - performed on failure (no exception is set, no warning is printed, etc). -*/ - -PyAPI_FUNC(void *) PyMem_Malloc(size_t); -PyAPI_FUNC(void *) PyMem_Realloc(void *, size_t); -PyAPI_FUNC(void) PyMem_Free(void *); - -/* Starting from Python 1.6, the wrappers Py_{Malloc,Realloc,Free} are - no longer supported. They used to call PyErr_NoMemory() on failure. */ - -/* Macros. */ -#ifdef PYMALLOC_DEBUG -/* Redirect all memory operations to Python's debugging allocator. */ -#define PyMem_MALLOC _PyMem_DebugMalloc -#define PyMem_REALLOC _PyMem_DebugRealloc -#define PyMem_FREE _PyMem_DebugFree - -#else /* ! PYMALLOC_DEBUG */ - -/* PyMem_MALLOC(0) means malloc(1). Some systems would return NULL - for malloc(0), which would be treated as an error. Some platforms - would return a pointer with no memory behind it, which would break - pymalloc. To solve these problems, allocate an extra byte. */ -/* Returns NULL to indicate error if a negative size or size larger than - Py_ssize_t can represent is supplied. Helps prevents security holes. */ -#define PyMem_MALLOC(n) ((size_t)(n) > (size_t)PY_SSIZE_T_MAX ? NULL \ - : malloc((n) ? (n) : 1)) -#define PyMem_REALLOC(p, n) ((size_t)(n) > (size_t)PY_SSIZE_T_MAX ? NULL \ - : realloc((p), (n) ? (n) : 1)) -#define PyMem_FREE free - -#endif /* PYMALLOC_DEBUG */ - -/* - * Type-oriented memory interface - * ============================== - * - * Allocate memory for n objects of the given type. Returns a new pointer - * or NULL if the request was too large or memory allocation failed. Use - * these macros rather than doing the multiplication yourself so that proper - * overflow checking is always done. - */ - -#define PyMem_New(type, n) \ - ( ((size_t)(n) > PY_SSIZE_T_MAX / sizeof(type)) ? NULL : \ - ( (type *) PyMem_Malloc((n) * sizeof(type)) ) ) -#define PyMem_NEW(type, n) \ - ( ((size_t)(n) > PY_SSIZE_T_MAX / sizeof(type)) ? NULL : \ - ( (type *) PyMem_MALLOC((n) * sizeof(type)) ) ) - -/* - * The value of (p) is always clobbered by this macro regardless of success. - * The caller MUST check if (p) is NULL afterwards and deal with the memory - * error if so. This means the original value of (p) MUST be saved for the - * caller's memory error handler to not lose track of it. - */ -#define PyMem_Resize(p, type, n) \ - ( (p) = ((size_t)(n) > PY_SSIZE_T_MAX / sizeof(type)) ? NULL : \ - (type *) PyMem_Realloc((p), (n) * sizeof(type)) ) -#define PyMem_RESIZE(p, type, n) \ - ( (p) = ((size_t)(n) > PY_SSIZE_T_MAX / sizeof(type)) ? NULL : \ - (type *) PyMem_REALLOC((p), (n) * sizeof(type)) ) - -/* PyMem{Del,DEL} are left over from ancient days, and shouldn't be used - * anymore. They're just confusing aliases for PyMem_{Free,FREE} now. - */ -#define PyMem_Del PyMem_Free -#define PyMem_DEL PyMem_FREE - -#ifdef __cplusplus -} -#endif - -#endif /* !Py_PYMEM_H */ diff --git a/python/include/pyport.h b/python/include/pyport.h deleted file mode 100644 index 693d0935..00000000 --- a/python/include/pyport.h +++ /dev/null @@ -1,904 +0,0 @@ -#ifndef Py_PYPORT_H -#define Py_PYPORT_H - -#include "pyconfig.h" /* include for defines */ - -/* Some versions of HP-UX & Solaris need inttypes.h for int32_t, - INT32_MAX, etc. */ -#ifdef HAVE_INTTYPES_H -#include -#endif - -#ifdef HAVE_STDINT_H -#include -#endif - -/************************************************************************** -Symbols and macros to supply platform-independent interfaces to basic -C language & library operations whose spellings vary across platforms. - -Please try to make documentation here as clear as possible: by definition, -the stuff here is trying to illuminate C's darkest corners. - -Config #defines referenced here: - -SIGNED_RIGHT_SHIFT_ZERO_FILLS -Meaning: To be defined iff i>>j does not extend the sign bit when i is a - signed integral type and i < 0. -Used in: Py_ARITHMETIC_RIGHT_SHIFT - -Py_DEBUG -Meaning: Extra checks compiled in for debug mode. -Used in: Py_SAFE_DOWNCAST - -HAVE_UINTPTR_T -Meaning: The C9X type uintptr_t is supported by the compiler -Used in: Py_uintptr_t - -HAVE_LONG_LONG -Meaning: The compiler supports the C type "long long" -Used in: PY_LONG_LONG - -**************************************************************************/ - - -/* For backward compatibility only. Obsolete, do not use. */ -#ifdef HAVE_PROTOTYPES -#define Py_PROTO(x) x -#else -#define Py_PROTO(x) () -#endif -#ifndef Py_FPROTO -#define Py_FPROTO(x) Py_PROTO(x) -#endif - -/* typedefs for some C9X-defined synonyms for integral types. - * - * The names in Python are exactly the same as the C9X names, except with a - * Py_ prefix. Until C9X is universally implemented, this is the only way - * to ensure that Python gets reliable names that don't conflict with names - * in non-Python code that are playing their own tricks to define the C9X - * names. - * - * NOTE: don't go nuts here! Python has no use for *most* of the C9X - * integral synonyms. Only define the ones we actually need. - */ - -#ifdef HAVE_LONG_LONG -#ifndef PY_LONG_LONG -#define PY_LONG_LONG long long -#if defined(LLONG_MAX) -/* If LLONG_MAX is defined in limits.h, use that. */ -#define PY_LLONG_MIN LLONG_MIN -#define PY_LLONG_MAX LLONG_MAX -#define PY_ULLONG_MAX ULLONG_MAX -#elif defined(__LONG_LONG_MAX__) -/* Otherwise, if GCC has a builtin define, use that. */ -#define PY_LLONG_MAX __LONG_LONG_MAX__ -#define PY_LLONG_MIN (-PY_LLONG_MAX-1) -#define PY_ULLONG_MAX (__LONG_LONG_MAX__*2ULL + 1ULL) -#else -/* Otherwise, rely on two's complement. */ -#define PY_ULLONG_MAX (~0ULL) -#define PY_LLONG_MAX ((long long)(PY_ULLONG_MAX>>1)) -#define PY_LLONG_MIN (-PY_LLONG_MAX-1) -#endif /* LLONG_MAX */ -#endif -#endif /* HAVE_LONG_LONG */ - -/* a build with 30-bit digits for Python long integers needs an exact-width - * 32-bit unsigned integer type to store those digits. (We could just use - * type 'unsigned long', but that would be wasteful on a system where longs - * are 64-bits.) On Unix systems, the autoconf macro AC_TYPE_UINT32_T defines - * uint32_t to be such a type unless stdint.h or inttypes.h defines uint32_t. - * However, it doesn't set HAVE_UINT32_T, so we do that here. - */ -#if (defined UINT32_MAX || defined uint32_t) -#ifndef PY_UINT32_T -#define HAVE_UINT32_T 1 -#define PY_UINT32_T uint32_t -#endif -#endif - -/* Macros for a 64-bit unsigned integer type; used for type 'twodigits' in the - * long integer implementation, when 30-bit digits are enabled. - */ -#if (defined UINT64_MAX || defined uint64_t) -#ifndef PY_UINT64_T -#define HAVE_UINT64_T 1 -#define PY_UINT64_T uint64_t -#endif -#endif - -/* Signed variants of the above */ -#if (defined INT32_MAX || defined int32_t) -#ifndef PY_INT32_T -#define HAVE_INT32_T 1 -#define PY_INT32_T int32_t -#endif -#endif -#if (defined INT64_MAX || defined int64_t) -#ifndef PY_INT64_T -#define HAVE_INT64_T 1 -#define PY_INT64_T int64_t -#endif -#endif - -/* If PYLONG_BITS_IN_DIGIT is not defined then we'll use 30-bit digits if all - the necessary integer types are available, and we're on a 64-bit platform - (as determined by SIZEOF_VOID_P); otherwise we use 15-bit digits. */ - -#ifndef PYLONG_BITS_IN_DIGIT -#if (defined HAVE_UINT64_T && defined HAVE_INT64_T && \ - defined HAVE_UINT32_T && defined HAVE_INT32_T && SIZEOF_VOID_P >= 8) -#define PYLONG_BITS_IN_DIGIT 30 -#else -#define PYLONG_BITS_IN_DIGIT 15 -#endif -#endif - -/* uintptr_t is the C9X name for an unsigned integral type such that a - * legitimate void* can be cast to uintptr_t and then back to void* again - * without loss of information. Similarly for intptr_t, wrt a signed - * integral type. - */ -#ifdef HAVE_UINTPTR_T -typedef uintptr_t Py_uintptr_t; -typedef intptr_t Py_intptr_t; - -#elif SIZEOF_VOID_P <= SIZEOF_INT -typedef unsigned int Py_uintptr_t; -typedef int Py_intptr_t; - -#elif SIZEOF_VOID_P <= SIZEOF_LONG -typedef unsigned long Py_uintptr_t; -typedef long Py_intptr_t; - -#elif defined(HAVE_LONG_LONG) && (SIZEOF_VOID_P <= SIZEOF_LONG_LONG) -typedef unsigned PY_LONG_LONG Py_uintptr_t; -typedef PY_LONG_LONG Py_intptr_t; - -#else -# error "Python needs a typedef for Py_uintptr_t in pyport.h." -#endif /* HAVE_UINTPTR_T */ - -/* Py_ssize_t is a signed integral type such that sizeof(Py_ssize_t) == - * sizeof(size_t). C99 doesn't define such a thing directly (size_t is an - * unsigned integral type). See PEP 353 for details. - */ -#ifdef HAVE_SSIZE_T -typedef ssize_t Py_ssize_t; -#elif SIZEOF_VOID_P == SIZEOF_SIZE_T -typedef Py_intptr_t Py_ssize_t; -#else -# error "Python needs a typedef for Py_ssize_t in pyport.h." -#endif - -/* Largest possible value of size_t. - SIZE_MAX is part of C99, so it might be defined on some - platforms. If it is not defined, (size_t)-1 is a portable - definition for C89, due to the way signed->unsigned - conversion is defined. */ -#ifdef SIZE_MAX -#define PY_SIZE_MAX SIZE_MAX -#else -#define PY_SIZE_MAX ((size_t)-1) -#endif - -/* Largest positive value of type Py_ssize_t. */ -#define PY_SSIZE_T_MAX ((Py_ssize_t)(((size_t)-1)>>1)) -/* Smallest negative value of type Py_ssize_t. */ -#define PY_SSIZE_T_MIN (-PY_SSIZE_T_MAX-1) - -#if SIZEOF_PID_T > SIZEOF_LONG -# error "Python doesn't support sizeof(pid_t) > sizeof(long)" -#endif - -/* PY_FORMAT_SIZE_T is a platform-specific modifier for use in a printf - * format to convert an argument with the width of a size_t or Py_ssize_t. - * C99 introduced "z" for this purpose, but not all platforms support that; - * e.g., MS compilers use "I" instead. - * - * These "high level" Python format functions interpret "z" correctly on - * all platforms (Python interprets the format string itself, and does whatever - * the platform C requires to convert a size_t/Py_ssize_t argument): - * - * PyString_FromFormat - * PyErr_Format - * PyString_FromFormatV - * - * Lower-level uses require that you interpolate the correct format modifier - * yourself (e.g., calling printf, fprintf, sprintf, PyOS_snprintf); for - * example, - * - * Py_ssize_t index; - * fprintf(stderr, "index %" PY_FORMAT_SIZE_T "d sucks\n", index); - * - * That will expand to %ld, or %Id, or to something else correct for a - * Py_ssize_t on the platform. - */ -#ifndef PY_FORMAT_SIZE_T -# if SIZEOF_SIZE_T == SIZEOF_INT && !defined(__APPLE__) -# define PY_FORMAT_SIZE_T "" -# elif SIZEOF_SIZE_T == SIZEOF_LONG -# define PY_FORMAT_SIZE_T "l" -# elif defined(MS_WINDOWS) -# define PY_FORMAT_SIZE_T "I" -# else -# error "This platform's pyconfig.h needs to define PY_FORMAT_SIZE_T" -# endif -#endif - -/* PY_FORMAT_LONG_LONG is analogous to PY_FORMAT_SIZE_T above, but for - * the long long type instead of the size_t type. It's only available - * when HAVE_LONG_LONG is defined. The "high level" Python format - * functions listed above will interpret "lld" or "llu" correctly on - * all platforms. - */ -#ifdef HAVE_LONG_LONG -# ifndef PY_FORMAT_LONG_LONG -# if defined(MS_WIN64) || defined(MS_WINDOWS) -# define PY_FORMAT_LONG_LONG "I64" -# else -# error "This platform's pyconfig.h needs to define PY_FORMAT_LONG_LONG" -# endif -# endif -#endif - -/* Py_LOCAL can be used instead of static to get the fastest possible calling - * convention for functions that are local to a given module. - * - * Py_LOCAL_INLINE does the same thing, and also explicitly requests inlining, - * for platforms that support that. - * - * If PY_LOCAL_AGGRESSIVE is defined before python.h is included, more - * "aggressive" inlining/optimizaion is enabled for the entire module. This - * may lead to code bloat, and may slow things down for those reasons. It may - * also lead to errors, if the code relies on pointer aliasing. Use with - * care. - * - * NOTE: You can only use this for functions that are entirely local to a - * module; functions that are exported via method tables, callbacks, etc, - * should keep using static. - */ - -#undef USE_INLINE /* XXX - set via configure? */ - -#if defined(_MSC_VER) -#if defined(PY_LOCAL_AGGRESSIVE) -/* enable more aggressive optimization for visual studio */ -#pragma optimize("agtw", on) -#endif -/* ignore warnings if the compiler decides not to inline a function */ -#pragma warning(disable: 4710) -/* fastest possible local call under MSVC */ -#define Py_LOCAL(type) static type -#define Py_LOCAL_INLINE(type) static __inline type -#elif defined(USE_INLINE) -#define Py_LOCAL(type) static type -#define Py_LOCAL_INLINE(type) static inline type -#else -#define Py_LOCAL(type) static type -#define Py_LOCAL_INLINE(type) static type -#endif - -/* Py_MEMCPY can be used instead of memcpy in cases where the copied blocks - * are often very short. While most platforms have highly optimized code for - * large transfers, the setup costs for memcpy are often quite high. MEMCPY - * solves this by doing short copies "in line". - */ - -#if defined(_MSC_VER) -#define Py_MEMCPY(target, source, length) do { \ - size_t i_, n_ = (length); \ - char *t_ = (void*) (target); \ - const char *s_ = (void*) (source); \ - if (n_ >= 16) \ - memcpy(t_, s_, n_); \ - else \ - for (i_ = 0; i_ < n_; i_++) \ - t_[i_] = s_[i_]; \ - } while (0) -#else -#define Py_MEMCPY memcpy -#endif - -#include - -#ifdef HAVE_IEEEFP_H -#include /* needed for 'finite' declaration on some platforms */ -#endif - -#include /* Moved here from the math section, before extern "C" */ - -/******************************************** - * WRAPPER FOR and/or * - ********************************************/ - -#ifdef TIME_WITH_SYS_TIME -#include -#include -#else /* !TIME_WITH_SYS_TIME */ -#ifdef HAVE_SYS_TIME_H -#include -#else /* !HAVE_SYS_TIME_H */ -#include -#endif /* !HAVE_SYS_TIME_H */ -#endif /* !TIME_WITH_SYS_TIME */ - - -/****************************** - * WRAPPER FOR * - ******************************/ - -/* NB caller must include */ - -#ifdef HAVE_SYS_SELECT_H - -#include - -#endif /* !HAVE_SYS_SELECT_H */ - -/******************************* - * stat() and fstat() fiddling * - *******************************/ - -/* We expect that stat and fstat exist on most systems. - * It's confirmed on Unix, Mac and Windows. - * If you don't have them, add - * #define DONT_HAVE_STAT - * and/or - * #define DONT_HAVE_FSTAT - * to your pyconfig.h. Python code beyond this should check HAVE_STAT and - * HAVE_FSTAT instead. - * Also - * #define HAVE_SYS_STAT_H - * if exists on your platform, and - * #define HAVE_STAT_H - * if does. - */ -#ifndef DONT_HAVE_STAT -#define HAVE_STAT -#endif - -#ifndef DONT_HAVE_FSTAT -#define HAVE_FSTAT -#endif - -#ifdef RISCOS -#include -#include "unixstuff.h" -#endif - -#ifdef HAVE_SYS_STAT_H -#if defined(PYOS_OS2) && defined(PYCC_GCC) -#include -#endif -#include -#elif defined(HAVE_STAT_H) -#include -#endif - -#if defined(PYCC_VACPP) -/* VisualAge C/C++ Failed to Define MountType Field in sys/stat.h */ -#define S_IFMT (S_IFDIR|S_IFCHR|S_IFREG) -#endif - -#ifndef S_ISREG -#define S_ISREG(x) (((x) & S_IFMT) == S_IFREG) -#endif - -#ifndef S_ISDIR -#define S_ISDIR(x) (((x) & S_IFMT) == S_IFDIR) -#endif - - -#ifdef __cplusplus -/* Move this down here since some C++ #include's don't like to be included - inside an extern "C" */ -extern "C" { -#endif - - -/* Py_ARITHMETIC_RIGHT_SHIFT - * C doesn't define whether a right-shift of a signed integer sign-extends - * or zero-fills. Here a macro to force sign extension: - * Py_ARITHMETIC_RIGHT_SHIFT(TYPE, I, J) - * Return I >> J, forcing sign extension. Arithmetically, return the - * floor of I/2**J. - * Requirements: - * I should have signed integer type. In the terminology of C99, this can - * be either one of the five standard signed integer types (signed char, - * short, int, long, long long) or an extended signed integer type. - * J is an integer >= 0 and strictly less than the number of bits in the - * type of I (because C doesn't define what happens for J outside that - * range either). - * TYPE used to specify the type of I, but is now ignored. It's been left - * in for backwards compatibility with versions <= 2.6 or 3.0. - * Caution: - * I may be evaluated more than once. - */ -#ifdef SIGNED_RIGHT_SHIFT_ZERO_FILLS -#define Py_ARITHMETIC_RIGHT_SHIFT(TYPE, I, J) \ - ((I) < 0 ? -1-((-1-(I)) >> (J)) : (I) >> (J)) -#else -#define Py_ARITHMETIC_RIGHT_SHIFT(TYPE, I, J) ((I) >> (J)) -#endif - -/* Py_FORCE_EXPANSION(X) - * "Simply" returns its argument. However, macro expansions within the - * argument are evaluated. This unfortunate trickery is needed to get - * token-pasting to work as desired in some cases. - */ -#define Py_FORCE_EXPANSION(X) X - -/* Py_SAFE_DOWNCAST(VALUE, WIDE, NARROW) - * Cast VALUE to type NARROW from type WIDE. In Py_DEBUG mode, this - * assert-fails if any information is lost. - * Caution: - * VALUE may be evaluated more than once. - */ -#ifdef Py_DEBUG -#define Py_SAFE_DOWNCAST(VALUE, WIDE, NARROW) \ - (assert((WIDE)(NARROW)(VALUE) == (VALUE)), (NARROW)(VALUE)) -#else -#define Py_SAFE_DOWNCAST(VALUE, WIDE, NARROW) (NARROW)(VALUE) -#endif - -/* Py_SET_ERRNO_ON_MATH_ERROR(x) - * If a libm function did not set errno, but it looks like the result - * overflowed or not-a-number, set errno to ERANGE or EDOM. Set errno - * to 0 before calling a libm function, and invoke this macro after, - * passing the function result. - * Caution: - * This isn't reliable. See Py_OVERFLOWED comments. - * X is evaluated more than once. - */ -#if defined(__FreeBSD__) || defined(__OpenBSD__) || (defined(__hpux) && defined(__ia64)) -#define _Py_SET_EDOM_FOR_NAN(X) if (isnan(X)) errno = EDOM; -#else -#define _Py_SET_EDOM_FOR_NAN(X) ; -#endif -#define Py_SET_ERRNO_ON_MATH_ERROR(X) \ - do { \ - if (errno == 0) { \ - if ((X) == Py_HUGE_VAL || (X) == -Py_HUGE_VAL) \ - errno = ERANGE; \ - else _Py_SET_EDOM_FOR_NAN(X) \ - } \ - } while(0) - -/* Py_SET_ERANGE_ON_OVERFLOW(x) - * An alias of Py_SET_ERRNO_ON_MATH_ERROR for backward-compatibility. - */ -#define Py_SET_ERANGE_IF_OVERFLOW(X) Py_SET_ERRNO_ON_MATH_ERROR(X) - -/* Py_ADJUST_ERANGE1(x) - * Py_ADJUST_ERANGE2(x, y) - * Set errno to 0 before calling a libm function, and invoke one of these - * macros after, passing the function result(s) (Py_ADJUST_ERANGE2 is useful - * for functions returning complex results). This makes two kinds of - * adjustments to errno: (A) If it looks like the platform libm set - * errno=ERANGE due to underflow, clear errno. (B) If it looks like the - * platform libm overflowed but didn't set errno, force errno to ERANGE. In - * effect, we're trying to force a useful implementation of C89 errno - * behavior. - * Caution: - * This isn't reliable. See Py_OVERFLOWED comments. - * X and Y may be evaluated more than once. - */ -#define Py_ADJUST_ERANGE1(X) \ - do { \ - if (errno == 0) { \ - if ((X) == Py_HUGE_VAL || (X) == -Py_HUGE_VAL) \ - errno = ERANGE; \ - } \ - else if (errno == ERANGE && (X) == 0.0) \ - errno = 0; \ - } while(0) - -#define Py_ADJUST_ERANGE2(X, Y) \ - do { \ - if ((X) == Py_HUGE_VAL || (X) == -Py_HUGE_VAL || \ - (Y) == Py_HUGE_VAL || (Y) == -Py_HUGE_VAL) { \ - if (errno == 0) \ - errno = ERANGE; \ - } \ - else if (errno == ERANGE) \ - errno = 0; \ - } while(0) - -/* The functions _Py_dg_strtod and _Py_dg_dtoa in Python/dtoa.c (which are - * required to support the short float repr introduced in Python 3.1) require - * that the floating-point unit that's being used for arithmetic operations - * on C doubles is set to use 53-bit precision. It also requires that the - * FPU rounding mode is round-half-to-even, but that's less often an issue. - * - * If your FPU isn't already set to 53-bit precision/round-half-to-even, and - * you want to make use of _Py_dg_strtod and _Py_dg_dtoa, then you should - * - * #define HAVE_PY_SET_53BIT_PRECISION 1 - * - * and also give appropriate definitions for the following three macros: - * - * _PY_SET_53BIT_PRECISION_START : store original FPU settings, and - * set FPU to 53-bit precision/round-half-to-even - * _PY_SET_53BIT_PRECISION_END : restore original FPU settings - * _PY_SET_53BIT_PRECISION_HEADER : any variable declarations needed to - * use the two macros above. - * - * The macros are designed to be used within a single C function: see - * Python/pystrtod.c for an example of their use. - */ - -/* get and set x87 control word for gcc/x86 */ -#ifdef HAVE_GCC_ASM_FOR_X87 -#define HAVE_PY_SET_53BIT_PRECISION 1 -/* _Py_get/set_387controlword functions are defined in Python/pymath.c */ -#define _Py_SET_53BIT_PRECISION_HEADER \ - unsigned short old_387controlword, new_387controlword -#define _Py_SET_53BIT_PRECISION_START \ - do { \ - old_387controlword = _Py_get_387controlword(); \ - new_387controlword = (old_387controlword & ~0x0f00) | 0x0200; \ - if (new_387controlword != old_387controlword) \ - _Py_set_387controlword(new_387controlword); \ - } while (0) -#define _Py_SET_53BIT_PRECISION_END \ - if (new_387controlword != old_387controlword) \ - _Py_set_387controlword(old_387controlword) -#endif - -/* default definitions are empty */ -#ifndef HAVE_PY_SET_53BIT_PRECISION -#define _Py_SET_53BIT_PRECISION_HEADER -#define _Py_SET_53BIT_PRECISION_START -#define _Py_SET_53BIT_PRECISION_END -#endif - -/* If we can't guarantee 53-bit precision, don't use the code - in Python/dtoa.c, but fall back to standard code. This - means that repr of a float will be long (17 sig digits). - - Realistically, there are two things that could go wrong: - - (1) doubles aren't IEEE 754 doubles, or - (2) we're on x86 with the rounding precision set to 64-bits - (extended precision), and we don't know how to change - the rounding precision. - */ - -#if !defined(DOUBLE_IS_LITTLE_ENDIAN_IEEE754) && \ - !defined(DOUBLE_IS_BIG_ENDIAN_IEEE754) && \ - !defined(DOUBLE_IS_ARM_MIXED_ENDIAN_IEEE754) -#define PY_NO_SHORT_FLOAT_REPR -#endif - -/* double rounding is symptomatic of use of extended precision on x86. If - we're seeing double rounding, and we don't have any mechanism available for - changing the FPU rounding precision, then don't use Python/dtoa.c. */ -#if defined(X87_DOUBLE_ROUNDING) && !defined(HAVE_PY_SET_53BIT_PRECISION) -#define PY_NO_SHORT_FLOAT_REPR -#endif - -/* Py_DEPRECATED(version) - * Declare a variable, type, or function deprecated. - * Usage: - * extern int old_var Py_DEPRECATED(2.3); - * typedef int T1 Py_DEPRECATED(2.4); - * extern int x() Py_DEPRECATED(2.5); - */ -#if defined(__GNUC__) && ((__GNUC__ >= 4) || \ - (__GNUC__ == 3) && (__GNUC_MINOR__ >= 1)) -#define Py_DEPRECATED(VERSION_UNUSED) __attribute__((__deprecated__)) -#else -#define Py_DEPRECATED(VERSION_UNUSED) -#endif - -/************************************************************************** -Prototypes that are missing from the standard include files on some systems -(and possibly only some versions of such systems.) - -Please be conservative with adding new ones, document them and enclose them -in platform-specific #ifdefs. -**************************************************************************/ - -#ifdef SOLARIS -/* Unchecked */ -extern int gethostname(char *, int); -#endif - -#ifdef __BEOS__ -/* Unchecked */ -/* It's in the libs, but not the headers... - [cjh] */ -int shutdown( int, int ); -#endif - -#ifdef HAVE__GETPTY -#include /* we need to import mode_t */ -extern char * _getpty(int *, int, mode_t, int); -#endif - -/* On QNX 6, struct termio must be declared by including sys/termio.h - if TCGETA, TCSETA, TCSETAW, or TCSETAF are used. sys/termio.h must - be included before termios.h or it will generate an error. */ -#ifdef HAVE_SYS_TERMIO_H -#include -#endif - -#if defined(HAVE_OPENPTY) || defined(HAVE_FORKPTY) -#if !defined(HAVE_PTY_H) && !defined(HAVE_LIBUTIL_H) && !defined(HAVE_UTIL_H) -/* BSDI does not supply a prototype for the 'openpty' and 'forkpty' - functions, even though they are included in libutil. */ -#include -extern int openpty(int *, int *, char *, struct termios *, struct winsize *); -extern pid_t forkpty(int *, char *, struct termios *, struct winsize *); -#endif /* !defined(HAVE_PTY_H) && !defined(HAVE_LIBUTIL_H) */ -#endif /* defined(HAVE_OPENPTY) || defined(HAVE_FORKPTY) */ - - -/* These are pulled from various places. It isn't obvious on what platforms - they are necessary, nor what the exact prototype should look like (which - is likely to vary between platforms!) If you find you need one of these - declarations, please move them to a platform-specific block and include - proper prototypes. */ -#if 0 - -/* From Modules/resource.c */ -extern int getrusage(); -extern int getpagesize(); - -/* From Python/sysmodule.c and Modules/posixmodule.c */ -extern int fclose(FILE *); - -/* From Modules/posixmodule.c */ -extern int fdatasync(int); -#endif /* 0 */ - - -/* On 4.4BSD-descendants, ctype functions serves the whole range of - * wchar_t character set rather than single byte code points only. - * This characteristic can break some operations of string object - * including str.upper() and str.split() on UTF-8 locales. This - * workaround was provided by Tim Robbins of FreeBSD project. - */ - -#ifdef __FreeBSD__ -#include -#if __FreeBSD_version > 500039 -# define _PY_PORT_CTYPE_UTF8_ISSUE -#endif -#endif - - -#if defined(__APPLE__) -# define _PY_PORT_CTYPE_UTF8_ISSUE -#endif - -#ifdef _PY_PORT_CTYPE_UTF8_ISSUE -#include -#include -#undef isalnum -#define isalnum(c) iswalnum(btowc(c)) -#undef isalpha -#define isalpha(c) iswalpha(btowc(c)) -#undef islower -#define islower(c) iswlower(btowc(c)) -#undef isspace -#define isspace(c) iswspace(btowc(c)) -#undef isupper -#define isupper(c) iswupper(btowc(c)) -#undef tolower -#define tolower(c) towlower(btowc(c)) -#undef toupper -#define toupper(c) towupper(btowc(c)) -#endif - - -/* Declarations for symbol visibility. - - PyAPI_FUNC(type): Declares a public Python API function and return type - PyAPI_DATA(type): Declares public Python data and its type - PyMODINIT_FUNC: A Python module init function. If these functions are - inside the Python core, they are private to the core. - If in an extension module, it may be declared with - external linkage depending on the platform. - - As a number of platforms support/require "__declspec(dllimport/dllexport)", - we support a HAVE_DECLSPEC_DLL macro to save duplication. -*/ - -/* - All windows ports, except cygwin, are handled in PC/pyconfig.h. - - BeOS and cygwin are the only other autoconf platform requiring special - linkage handling and both of these use __declspec(). -*/ -#if defined(__CYGWIN__) || defined(__BEOS__) -# define HAVE_DECLSPEC_DLL -#endif - -/* only get special linkage if built as shared or platform is Cygwin */ -#if defined(Py_ENABLE_SHARED) || defined(__CYGWIN__) -# if defined(HAVE_DECLSPEC_DLL) -# ifdef Py_BUILD_CORE -# define PyAPI_FUNC(RTYPE) __declspec(dllexport) RTYPE -# define PyAPI_DATA(RTYPE) extern __declspec(dllexport) RTYPE - /* module init functions inside the core need no external linkage */ - /* except for Cygwin to handle embedding (FIXME: BeOS too?) */ -# if defined(__CYGWIN__) -# define PyMODINIT_FUNC __declspec(dllexport) void -# else /* __CYGWIN__ */ -# define PyMODINIT_FUNC void -# endif /* __CYGWIN__ */ -# else /* Py_BUILD_CORE */ - /* Building an extension module, or an embedded situation */ - /* public Python functions and data are imported */ - /* Under Cygwin, auto-import functions to prevent compilation */ - /* failures similar to those described at the bottom of 4.1: */ - /* http://docs.python.org/extending/windows.html#a-cookbook-approach */ -# if !defined(__CYGWIN__) -# define PyAPI_FUNC(RTYPE) __declspec(dllimport) RTYPE -# endif /* !__CYGWIN__ */ -# define PyAPI_DATA(RTYPE) extern __declspec(dllimport) RTYPE - /* module init functions outside the core must be exported */ -# if defined(__cplusplus) -# define PyMODINIT_FUNC extern "C" __declspec(dllexport) void -# else /* __cplusplus */ -# define PyMODINIT_FUNC __declspec(dllexport) void -# endif /* __cplusplus */ -# endif /* Py_BUILD_CORE */ -# endif /* HAVE_DECLSPEC */ -#endif /* Py_ENABLE_SHARED */ - -/* If no external linkage macros defined by now, create defaults */ -#ifndef PyAPI_FUNC -# define PyAPI_FUNC(RTYPE) RTYPE -#endif -#ifndef PyAPI_DATA -# define PyAPI_DATA(RTYPE) extern RTYPE -#endif -#ifndef PyMODINIT_FUNC -# if defined(__cplusplus) -# define PyMODINIT_FUNC extern "C" void -# else /* __cplusplus */ -# define PyMODINIT_FUNC void -# endif /* __cplusplus */ -#endif - -/* Deprecated DL_IMPORT and DL_EXPORT macros */ -#if defined(Py_ENABLE_SHARED) && defined (HAVE_DECLSPEC_DLL) -# if defined(Py_BUILD_CORE) -# define DL_IMPORT(RTYPE) __declspec(dllexport) RTYPE -# define DL_EXPORT(RTYPE) __declspec(dllexport) RTYPE -# else -# define DL_IMPORT(RTYPE) __declspec(dllimport) RTYPE -# define DL_EXPORT(RTYPE) __declspec(dllexport) RTYPE -# endif -#endif -#ifndef DL_EXPORT -# define DL_EXPORT(RTYPE) RTYPE -#endif -#ifndef DL_IMPORT -# define DL_IMPORT(RTYPE) RTYPE -#endif -/* End of deprecated DL_* macros */ - -/* If the fd manipulation macros aren't defined, - here is a set that should do the job */ - -#if 0 /* disabled and probably obsolete */ - -#ifndef FD_SETSIZE -#define FD_SETSIZE 256 -#endif - -#ifndef FD_SET - -typedef long fd_mask; - -#define NFDBITS (sizeof(fd_mask) * NBBY) /* bits per mask */ -#ifndef howmany -#define howmany(x, y) (((x)+((y)-1))/(y)) -#endif /* howmany */ - -typedef struct fd_set { - fd_mask fds_bits[howmany(FD_SETSIZE, NFDBITS)]; -} fd_set; - -#define FD_SET(n, p) ((p)->fds_bits[(n)/NFDBITS] |= (1 << ((n) % NFDBITS))) -#define FD_CLR(n, p) ((p)->fds_bits[(n)/NFDBITS] &= ~(1 << ((n) % NFDBITS))) -#define FD_ISSET(n, p) ((p)->fds_bits[(n)/NFDBITS] & (1 << ((n) % NFDBITS))) -#define FD_ZERO(p) memset((char *)(p), '\0', sizeof(*(p))) - -#endif /* FD_SET */ - -#endif /* fd manipulation macros */ - - -/* limits.h constants that may be missing */ - -#ifndef INT_MAX -#define INT_MAX 2147483647 -#endif - -#ifndef LONG_MAX -#if SIZEOF_LONG == 4 -#define LONG_MAX 0X7FFFFFFFL -#elif SIZEOF_LONG == 8 -#define LONG_MAX 0X7FFFFFFFFFFFFFFFL -#else -#error "could not set LONG_MAX in pyport.h" -#endif -#endif - -#ifndef LONG_MIN -#define LONG_MIN (-LONG_MAX-1) -#endif - -#ifndef LONG_BIT -#define LONG_BIT (8 * SIZEOF_LONG) -#endif - -#if LONG_BIT != 8 * SIZEOF_LONG -/* 04-Oct-2000 LONG_BIT is apparently (mis)defined as 64 on some recent - * 32-bit platforms using gcc. We try to catch that here at compile-time - * rather than waiting for integer multiplication to trigger bogus - * overflows. - */ -#error "LONG_BIT definition appears wrong for platform (bad gcc/glibc config?)." -#endif - -#ifdef __cplusplus -} -#endif - -/* - * Hide GCC attributes from compilers that don't support them. - */ -#if (!defined(__GNUC__) || __GNUC__ < 2 || \ - (__GNUC__ == 2 && __GNUC_MINOR__ < 7) ) && \ - !defined(RISCOS) -#define Py_GCC_ATTRIBUTE(x) -#else -#define Py_GCC_ATTRIBUTE(x) __attribute__(x) -#endif - -/* - * Add PyArg_ParseTuple format where available. - */ -#ifdef HAVE_ATTRIBUTE_FORMAT_PARSETUPLE -#define Py_FORMAT_PARSETUPLE(func,p1,p2) __attribute__((format(func,p1,p2))) -#else -#define Py_FORMAT_PARSETUPLE(func,p1,p2) -#endif - -/* - * Specify alignment on compilers that support it. - */ -#if defined(__GNUC__) && __GNUC__ >= 3 -#define Py_ALIGNED(x) __attribute__((aligned(x))) -#else -#define Py_ALIGNED(x) -#endif - -/* Eliminate end-of-loop code not reached warnings from SunPro C - * when using do{...}while(0) macros - */ -#ifdef __SUNPRO_C -#pragma error_messages (off,E_END_OF_LOOP_CODE_NOT_REACHED) -#endif - -/* - * Older Microsoft compilers don't support the C99 long long literal suffixes, - * so these will be defined in PC/pyconfig.h for those compilers. - */ -#ifndef Py_LL -#define Py_LL(x) x##LL -#endif - -#ifndef Py_ULL -#define Py_ULL(x) Py_LL(x##U) -#endif - -#endif /* Py_PYPORT_H */ diff --git a/python/include/pystate.h b/python/include/pystate.h deleted file mode 100644 index 8d74940f..00000000 --- a/python/include/pystate.h +++ /dev/null @@ -1,197 +0,0 @@ - -/* Thread and interpreter state structures and their interfaces */ - - -#ifndef Py_PYSTATE_H -#define Py_PYSTATE_H -#ifdef __cplusplus -extern "C" { -#endif - -/* State shared between threads */ - -struct _ts; /* Forward */ -struct _is; /* Forward */ - -typedef struct _is { - - struct _is *next; - struct _ts *tstate_head; - - PyObject *modules; - PyObject *sysdict; - PyObject *builtins; - PyObject *modules_reloading; - - PyObject *codec_search_path; - PyObject *codec_search_cache; - PyObject *codec_error_registry; - -#ifdef HAVE_DLOPEN - int dlopenflags; -#endif -#ifdef WITH_TSC - int tscdump; -#endif - -} PyInterpreterState; - - -/* State unique per thread */ - -struct _frame; /* Avoid including frameobject.h */ - -/* Py_tracefunc return -1 when raising an exception, or 0 for success. */ -typedef int (*Py_tracefunc)(PyObject *, struct _frame *, int, PyObject *); - -/* The following values are used for 'what' for tracefunc functions: */ -#define PyTrace_CALL 0 -#define PyTrace_EXCEPTION 1 -#define PyTrace_LINE 2 -#define PyTrace_RETURN 3 -#define PyTrace_C_CALL 4 -#define PyTrace_C_EXCEPTION 5 -#define PyTrace_C_RETURN 6 - -typedef struct _ts { - /* See Python/ceval.c for comments explaining most fields */ - - struct _ts *next; - PyInterpreterState *interp; - - struct _frame *frame; - int recursion_depth; - /* 'tracing' keeps track of the execution depth when tracing/profiling. - This is to prevent the actual trace/profile code from being recorded in - the trace/profile. */ - int tracing; - int use_tracing; - - Py_tracefunc c_profilefunc; - Py_tracefunc c_tracefunc; - PyObject *c_profileobj; - PyObject *c_traceobj; - - PyObject *curexc_type; - PyObject *curexc_value; - PyObject *curexc_traceback; - - PyObject *exc_type; - PyObject *exc_value; - PyObject *exc_traceback; - - PyObject *dict; /* Stores per-thread state */ - - /* tick_counter is incremented whenever the check_interval ticker - * reaches zero. The purpose is to give a useful measure of the number - * of interpreted bytecode instructions in a given thread. This - * extremely lightweight statistic collector may be of interest to - * profilers (like psyco.jit()), although nothing in the core uses it. - */ - int tick_counter; - - int gilstate_counter; - - PyObject *async_exc; /* Asynchronous exception to raise */ - long thread_id; /* Thread id where this tstate was created */ - - /* XXX signal handlers should also be here */ - -} PyThreadState; - - -PyAPI_FUNC(PyInterpreterState *) PyInterpreterState_New(void); -PyAPI_FUNC(void) PyInterpreterState_Clear(PyInterpreterState *); -PyAPI_FUNC(void) PyInterpreterState_Delete(PyInterpreterState *); - -PyAPI_FUNC(PyThreadState *) PyThreadState_New(PyInterpreterState *); -PyAPI_FUNC(PyThreadState *) _PyThreadState_Prealloc(PyInterpreterState *); -PyAPI_FUNC(void) _PyThreadState_Init(PyThreadState *); -PyAPI_FUNC(void) PyThreadState_Clear(PyThreadState *); -PyAPI_FUNC(void) PyThreadState_Delete(PyThreadState *); -#ifdef WITH_THREAD -PyAPI_FUNC(void) PyThreadState_DeleteCurrent(void); -#endif - -PyAPI_FUNC(PyThreadState *) PyThreadState_Get(void); -PyAPI_FUNC(PyThreadState *) PyThreadState_Swap(PyThreadState *); -PyAPI_FUNC(PyObject *) PyThreadState_GetDict(void); -PyAPI_FUNC(int) PyThreadState_SetAsyncExc(long, PyObject *); - - -/* Variable and macro for in-line access to current thread state */ - -PyAPI_DATA(PyThreadState *) _PyThreadState_Current; - -#ifdef Py_DEBUG -#define PyThreadState_GET() PyThreadState_Get() -#else -#define PyThreadState_GET() (_PyThreadState_Current) -#endif - -typedef - enum {PyGILState_LOCKED, PyGILState_UNLOCKED} - PyGILState_STATE; - -/* Ensure that the current thread is ready to call the Python - C API, regardless of the current state of Python, or of its - thread lock. This may be called as many times as desired - by a thread so long as each call is matched with a call to - PyGILState_Release(). In general, other thread-state APIs may - be used between _Ensure() and _Release() calls, so long as the - thread-state is restored to its previous state before the Release(). - For example, normal use of the Py_BEGIN_ALLOW_THREADS/ - Py_END_ALLOW_THREADS macros are acceptable. - - The return value is an opaque "handle" to the thread state when - PyGILState_Ensure() was called, and must be passed to - PyGILState_Release() to ensure Python is left in the same state. Even - though recursive calls are allowed, these handles can *not* be shared - - each unique call to PyGILState_Ensure must save the handle for its - call to PyGILState_Release. - - When the function returns, the current thread will hold the GIL. - - Failure is a fatal error. -*/ -PyAPI_FUNC(PyGILState_STATE) PyGILState_Ensure(void); - -/* Release any resources previously acquired. After this call, Python's - state will be the same as it was prior to the corresponding - PyGILState_Ensure() call (but generally this state will be unknown to - the caller, hence the use of the GILState API.) - - Every call to PyGILState_Ensure must be matched by a call to - PyGILState_Release on the same thread. -*/ -PyAPI_FUNC(void) PyGILState_Release(PyGILState_STATE); - -/* Helper/diagnostic function - get the current thread state for - this thread. May return NULL if no GILState API has been used - on the current thread. Note that the main thread always has such a - thread-state, even if no auto-thread-state call has been made - on the main thread. -*/ -PyAPI_FUNC(PyThreadState *) PyGILState_GetThisThreadState(void); - -/* The implementation of sys._current_frames() Returns a dict mapping - thread id to that thread's current frame. -*/ -PyAPI_FUNC(PyObject *) _PyThread_CurrentFrames(void); - -/* Routines for advanced debuggers, requested by David Beazley. - Don't use unless you know what you are doing! */ -PyAPI_FUNC(PyInterpreterState *) PyInterpreterState_Head(void); -PyAPI_FUNC(PyInterpreterState *) PyInterpreterState_Next(PyInterpreterState *); -PyAPI_FUNC(PyThreadState *) PyInterpreterState_ThreadHead(PyInterpreterState *); -PyAPI_FUNC(PyThreadState *) PyThreadState_Next(PyThreadState *); - -typedef struct _frame *(*PyThreadFrameGetter)(PyThreadState *self_); - -/* hook for PyEval_GetFrame(), requested for Psyco */ -PyAPI_DATA(PyThreadFrameGetter) _PyThreadState_GetFrame; - -#ifdef __cplusplus -} -#endif -#endif /* !Py_PYSTATE_H */ diff --git a/python/include/pystrcmp.h b/python/include/pystrcmp.h deleted file mode 100644 index 369c7e77..00000000 --- a/python/include/pystrcmp.h +++ /dev/null @@ -1,23 +0,0 @@ -#ifndef Py_STRCMP_H -#define Py_STRCMP_H - -#ifdef __cplusplus -extern "C" { -#endif - -PyAPI_FUNC(int) PyOS_mystrnicmp(const char *, const char *, Py_ssize_t); -PyAPI_FUNC(int) PyOS_mystricmp(const char *, const char *); - -#if defined(MS_WINDOWS) || defined(PYOS_OS2) -#define PyOS_strnicmp strnicmp -#define PyOS_stricmp stricmp -#else -#define PyOS_strnicmp PyOS_mystrnicmp -#define PyOS_stricmp PyOS_mystricmp -#endif - -#ifdef __cplusplus -} -#endif - -#endif /* !Py_STRCMP_H */ diff --git a/python/include/pystrtod.h b/python/include/pystrtod.h deleted file mode 100644 index eec434f1..00000000 --- a/python/include/pystrtod.h +++ /dev/null @@ -1,45 +0,0 @@ -#ifndef Py_STRTOD_H -#define Py_STRTOD_H - -#ifdef __cplusplus -extern "C" { -#endif - - -PyAPI_FUNC(double) PyOS_ascii_strtod(const char *str, char **ptr); -PyAPI_FUNC(double) PyOS_ascii_atof(const char *str); - -/* Deprecated in 2.7 and 3.1. Will disappear in 2.8 (if it exists) and 3.2 */ -PyAPI_FUNC(char *) PyOS_ascii_formatd(char *buffer, size_t buf_len, - const char *format, double d); -PyAPI_FUNC(double) PyOS_string_to_double(const char *str, - char **endptr, - PyObject *overflow_exception); - -/* The caller is responsible for calling PyMem_Free to free the buffer - that's is returned. */ -PyAPI_FUNC(char *) PyOS_double_to_string(double val, - char format_code, - int precision, - int flags, - int *type); - -PyAPI_FUNC(double) _Py_parse_inf_or_nan(const char *p, char **endptr); - - -/* PyOS_double_to_string's "flags" parameter can be set to 0 or more of: */ -#define Py_DTSF_SIGN 0x01 /* always add the sign */ -#define Py_DTSF_ADD_DOT_0 0x02 /* if the result is an integer add ".0" */ -#define Py_DTSF_ALT 0x04 /* "alternate" formatting. it's format_code - specific */ - -/* PyOS_double_to_string's "type", if non-NULL, will be set to one of: */ -#define Py_DTST_FINITE 0 -#define Py_DTST_INFINITE 1 -#define Py_DTST_NAN 2 - -#ifdef __cplusplus -} -#endif - -#endif /* !Py_STRTOD_H */ diff --git a/python/include/pythonrun.h b/python/include/pythonrun.h deleted file mode 100644 index 6bfc1750..00000000 --- a/python/include/pythonrun.h +++ /dev/null @@ -1,181 +0,0 @@ - -/* Interfaces to parse and execute pieces of python code */ - -#ifndef Py_PYTHONRUN_H -#define Py_PYTHONRUN_H -#ifdef __cplusplus -extern "C" { -#endif - -#define PyCF_MASK (CO_FUTURE_DIVISION | CO_FUTURE_ABSOLUTE_IMPORT | \ - CO_FUTURE_WITH_STATEMENT | CO_FUTURE_PRINT_FUNCTION | \ - CO_FUTURE_UNICODE_LITERALS) -#define PyCF_MASK_OBSOLETE (CO_NESTED) -#define PyCF_SOURCE_IS_UTF8 0x0100 -#define PyCF_DONT_IMPLY_DEDENT 0x0200 -#define PyCF_ONLY_AST 0x0400 - -typedef struct { - int cf_flags; /* bitmask of CO_xxx flags relevant to future */ -} PyCompilerFlags; - -PyAPI_FUNC(void) Py_SetProgramName(char *); -PyAPI_FUNC(char *) Py_GetProgramName(void); - -PyAPI_FUNC(void) Py_SetPythonHome(char *); -PyAPI_FUNC(char *) Py_GetPythonHome(void); - -PyAPI_FUNC(void) Py_Initialize(void); -PyAPI_FUNC(void) Py_InitializeEx(int); -PyAPI_FUNC(void) Py_Finalize(void); -PyAPI_FUNC(int) Py_IsInitialized(void); -PyAPI_FUNC(PyThreadState *) Py_NewInterpreter(void); -PyAPI_FUNC(void) Py_EndInterpreter(PyThreadState *); - -PyAPI_FUNC(int) PyRun_AnyFileFlags(FILE *, const char *, PyCompilerFlags *); -PyAPI_FUNC(int) PyRun_AnyFileExFlags(FILE *, const char *, int, PyCompilerFlags *); -PyAPI_FUNC(int) PyRun_SimpleStringFlags(const char *, PyCompilerFlags *); -PyAPI_FUNC(int) PyRun_SimpleFileExFlags(FILE *, const char *, int, PyCompilerFlags *); -PyAPI_FUNC(int) PyRun_InteractiveOneFlags(FILE *, const char *, PyCompilerFlags *); -PyAPI_FUNC(int) PyRun_InteractiveLoopFlags(FILE *, const char *, PyCompilerFlags *); - -PyAPI_FUNC(struct _mod *) PyParser_ASTFromString(const char *, const char *, - int, PyCompilerFlags *flags, - PyArena *); -PyAPI_FUNC(struct _mod *) PyParser_ASTFromFile(FILE *, const char *, int, - char *, char *, - PyCompilerFlags *, int *, - PyArena *); -#define PyParser_SimpleParseString(S, B) \ - PyParser_SimpleParseStringFlags(S, B, 0) -#define PyParser_SimpleParseFile(FP, S, B) \ - PyParser_SimpleParseFileFlags(FP, S, B, 0) -PyAPI_FUNC(struct _node *) PyParser_SimpleParseStringFlags(const char *, int, - int); -PyAPI_FUNC(struct _node *) PyParser_SimpleParseFileFlags(FILE *, const char *, - int, int); - -PyAPI_FUNC(PyObject *) PyRun_StringFlags(const char *, int, PyObject *, - PyObject *, PyCompilerFlags *); - -PyAPI_FUNC(PyObject *) PyRun_FileExFlags(FILE *, const char *, int, - PyObject *, PyObject *, int, - PyCompilerFlags *); - -#define Py_CompileString(str, p, s) Py_CompileStringFlags(str, p, s, NULL) -PyAPI_FUNC(PyObject *) Py_CompileStringFlags(const char *, const char *, int, - PyCompilerFlags *); -PyAPI_FUNC(struct symtable *) Py_SymtableString(const char *, const char *, int); - -PyAPI_FUNC(void) PyErr_Print(void); -PyAPI_FUNC(void) PyErr_PrintEx(int); -PyAPI_FUNC(void) PyErr_Display(PyObject *, PyObject *, PyObject *); - -PyAPI_FUNC(int) Py_AtExit(void (*func)(void)); - -PyAPI_FUNC(void) Py_Exit(int); - -PyAPI_FUNC(int) Py_FdIsInteractive(FILE *, const char *); - -/* Bootstrap */ -PyAPI_FUNC(int) Py_Main(int argc, char **argv); - -/* Use macros for a bunch of old variants */ -#define PyRun_String(str, s, g, l) PyRun_StringFlags(str, s, g, l, NULL) -#define PyRun_AnyFile(fp, name) PyRun_AnyFileExFlags(fp, name, 0, NULL) -#define PyRun_AnyFileEx(fp, name, closeit) \ - PyRun_AnyFileExFlags(fp, name, closeit, NULL) -#define PyRun_AnyFileFlags(fp, name, flags) \ - PyRun_AnyFileExFlags(fp, name, 0, flags) -#define PyRun_SimpleString(s) PyRun_SimpleStringFlags(s, NULL) -#define PyRun_SimpleFile(f, p) PyRun_SimpleFileExFlags(f, p, 0, NULL) -#define PyRun_SimpleFileEx(f, p, c) PyRun_SimpleFileExFlags(f, p, c, NULL) -#define PyRun_InteractiveOne(f, p) PyRun_InteractiveOneFlags(f, p, NULL) -#define PyRun_InteractiveLoop(f, p) PyRun_InteractiveLoopFlags(f, p, NULL) -#define PyRun_File(fp, p, s, g, l) \ - PyRun_FileExFlags(fp, p, s, g, l, 0, NULL) -#define PyRun_FileEx(fp, p, s, g, l, c) \ - PyRun_FileExFlags(fp, p, s, g, l, c, NULL) -#define PyRun_FileFlags(fp, p, s, g, l, flags) \ - PyRun_FileExFlags(fp, p, s, g, l, 0, flags) - -/* In getpath.c */ -PyAPI_FUNC(char *) Py_GetProgramFullPath(void); -PyAPI_FUNC(char *) Py_GetPrefix(void); -PyAPI_FUNC(char *) Py_GetExecPrefix(void); -PyAPI_FUNC(char *) Py_GetPath(void); - -/* In their own files */ -PyAPI_FUNC(const char *) Py_GetVersion(void); -PyAPI_FUNC(const char *) Py_GetPlatform(void); -PyAPI_FUNC(const char *) Py_GetCopyright(void); -PyAPI_FUNC(const char *) Py_GetCompiler(void); -PyAPI_FUNC(const char *) Py_GetBuildInfo(void); -PyAPI_FUNC(const char *) _Py_svnversion(void); -PyAPI_FUNC(const char *) Py_SubversionRevision(void); -PyAPI_FUNC(const char *) Py_SubversionShortBranch(void); -PyAPI_FUNC(const char *) _Py_hgidentifier(void); -PyAPI_FUNC(const char *) _Py_hgversion(void); - -/* Internal -- various one-time initializations */ -PyAPI_FUNC(PyObject *) _PyBuiltin_Init(void); -PyAPI_FUNC(PyObject *) _PySys_Init(void); -PyAPI_FUNC(void) _PyImport_Init(void); -PyAPI_FUNC(void) _PyExc_Init(void); -PyAPI_FUNC(void) _PyImportHooks_Init(void); -PyAPI_FUNC(int) _PyFrame_Init(void); -PyAPI_FUNC(int) _PyInt_Init(void); -PyAPI_FUNC(int) _PyLong_Init(void); -PyAPI_FUNC(void) _PyFloat_Init(void); -PyAPI_FUNC(int) PyByteArray_Init(void); -PyAPI_FUNC(void) _PyRandom_Init(void); - -/* Various internal finalizers */ -PyAPI_FUNC(void) _PyExc_Fini(void); -PyAPI_FUNC(void) _PyImport_Fini(void); -PyAPI_FUNC(void) PyMethod_Fini(void); -PyAPI_FUNC(void) PyFrame_Fini(void); -PyAPI_FUNC(void) PyCFunction_Fini(void); -PyAPI_FUNC(void) PyDict_Fini(void); -PyAPI_FUNC(void) PyTuple_Fini(void); -PyAPI_FUNC(void) PyList_Fini(void); -PyAPI_FUNC(void) PySet_Fini(void); -PyAPI_FUNC(void) PyString_Fini(void); -PyAPI_FUNC(void) PyInt_Fini(void); -PyAPI_FUNC(void) PyFloat_Fini(void); -PyAPI_FUNC(void) PyOS_FiniInterrupts(void); -PyAPI_FUNC(void) PyByteArray_Fini(void); - -/* Stuff with no proper home (yet) */ -PyAPI_FUNC(char *) PyOS_Readline(FILE *, FILE *, char *); -PyAPI_DATA(int) (*PyOS_InputHook)(void); -PyAPI_DATA(char) *(*PyOS_ReadlineFunctionPointer)(FILE *, FILE *, char *); -PyAPI_DATA(PyThreadState*) _PyOS_ReadlineTState; - -/* Stack size, in "pointers" (so we get extra safety margins - on 64-bit platforms). On a 32-bit platform, this translates - to a 8k margin. */ -#define PYOS_STACK_MARGIN 2048 - -#if defined(WIN32) && !defined(MS_WIN64) && defined(_MSC_VER) && _MSC_VER >= 1300 -/* Enable stack checking under Microsoft C */ -#define USE_STACKCHECK -#endif - -#ifdef USE_STACKCHECK -/* Check that we aren't overflowing our stack */ -PyAPI_FUNC(int) PyOS_CheckStack(void); -#endif - -/* Signals */ -typedef void (*PyOS_sighandler_t)(int); -PyAPI_FUNC(PyOS_sighandler_t) PyOS_getsig(int); -PyAPI_FUNC(PyOS_sighandler_t) PyOS_setsig(int, PyOS_sighandler_t); - -/* Random */ -PyAPI_FUNC(int) _PyOS_URandom (void *buffer, Py_ssize_t size); - -#ifdef __cplusplus -} -#endif -#endif /* !Py_PYTHONRUN_H */ diff --git a/python/include/pythread.h b/python/include/pythread.h deleted file mode 100644 index dfd61575..00000000 --- a/python/include/pythread.h +++ /dev/null @@ -1,41 +0,0 @@ - -#ifndef Py_PYTHREAD_H -#define Py_PYTHREAD_H - -typedef void *PyThread_type_lock; -typedef void *PyThread_type_sema; - -#ifdef __cplusplus -extern "C" { -#endif - -PyAPI_FUNC(void) PyThread_init_thread(void); -PyAPI_FUNC(long) PyThread_start_new_thread(void (*)(void *), void *); -PyAPI_FUNC(void) PyThread_exit_thread(void); -PyAPI_FUNC(long) PyThread_get_thread_ident(void); - -PyAPI_FUNC(PyThread_type_lock) PyThread_allocate_lock(void); -PyAPI_FUNC(void) PyThread_free_lock(PyThread_type_lock); -PyAPI_FUNC(int) PyThread_acquire_lock(PyThread_type_lock, int); -#define WAIT_LOCK 1 -#define NOWAIT_LOCK 0 -PyAPI_FUNC(void) PyThread_release_lock(PyThread_type_lock); - -PyAPI_FUNC(size_t) PyThread_get_stacksize(void); -PyAPI_FUNC(int) PyThread_set_stacksize(size_t); - -/* Thread Local Storage (TLS) API */ -PyAPI_FUNC(int) PyThread_create_key(void); -PyAPI_FUNC(void) PyThread_delete_key(int); -PyAPI_FUNC(int) PyThread_set_key_value(int, void *); -PyAPI_FUNC(void *) PyThread_get_key_value(int); -PyAPI_FUNC(void) PyThread_delete_key_value(int key); - -/* Cleanup after a fork */ -PyAPI_FUNC(void) PyThread_ReInitTLS(void); - -#ifdef __cplusplus -} -#endif - -#endif /* !Py_PYTHREAD_H */ diff --git a/python/include/rangeobject.h b/python/include/rangeobject.h deleted file mode 100644 index 36c9cee5..00000000 --- a/python/include/rangeobject.h +++ /dev/null @@ -1,28 +0,0 @@ - -/* Range object interface */ - -#ifndef Py_RANGEOBJECT_H -#define Py_RANGEOBJECT_H -#ifdef __cplusplus -extern "C" { -#endif - -/* This is about the type 'xrange', not the built-in function range(), which - returns regular lists. */ - -/* -A range object represents an integer range. This is an immutable object; -a range cannot change its value after creation. - -Range objects behave like the corresponding tuple objects except that -they are represented by a start, stop, and step datamembers. -*/ - -PyAPI_DATA(PyTypeObject) PyRange_Type; - -#define PyRange_Check(op) (Py_TYPE(op) == &PyRange_Type) - -#ifdef __cplusplus -} -#endif -#endif /* !Py_RANGEOBJECT_H */ diff --git a/python/include/setobject.h b/python/include/setobject.h deleted file mode 100644 index 52b07d52..00000000 --- a/python/include/setobject.h +++ /dev/null @@ -1,99 +0,0 @@ -/* Set object interface */ - -#ifndef Py_SETOBJECT_H -#define Py_SETOBJECT_H -#ifdef __cplusplus -extern "C" { -#endif - - -/* -There are three kinds of slots in the table: - -1. Unused: key == NULL -2. Active: key != NULL and key != dummy -3. Dummy: key == dummy - -Note: .pop() abuses the hash field of an Unused or Dummy slot to -hold a search finger. The hash field of Unused or Dummy slots has -no meaning otherwise. -*/ - -#define PySet_MINSIZE 8 - -typedef struct { - long hash; /* cached hash code for the entry key */ - PyObject *key; -} setentry; - - -/* -This data structure is shared by set and frozenset objects. -*/ - -typedef struct _setobject PySetObject; -struct _setobject { - PyObject_HEAD - - Py_ssize_t fill; /* # Active + # Dummy */ - Py_ssize_t used; /* # Active */ - - /* The table contains mask + 1 slots, and that's a power of 2. - * We store the mask instead of the size because the mask is more - * frequently needed. - */ - Py_ssize_t mask; - - /* table points to smalltable for small tables, else to - * additional malloc'ed memory. table is never NULL! This rule - * saves repeated runtime null-tests. - */ - setentry *table; - setentry *(*lookup)(PySetObject *so, PyObject *key, long hash); - setentry smalltable[PySet_MINSIZE]; - - long hash; /* only used by frozenset objects */ - PyObject *weakreflist; /* List of weak references */ -}; - -PyAPI_DATA(PyTypeObject) PySet_Type; -PyAPI_DATA(PyTypeObject) PyFrozenSet_Type; - -/* Invariants for frozensets: - * data is immutable. - * hash is the hash of the frozenset or -1 if not computed yet. - * Invariants for sets: - * hash is -1 - */ - -#define PyFrozenSet_CheckExact(ob) (Py_TYPE(ob) == &PyFrozenSet_Type) -#define PyAnySet_CheckExact(ob) \ - (Py_TYPE(ob) == &PySet_Type || Py_TYPE(ob) == &PyFrozenSet_Type) -#define PyAnySet_Check(ob) \ - (Py_TYPE(ob) == &PySet_Type || Py_TYPE(ob) == &PyFrozenSet_Type || \ - PyType_IsSubtype(Py_TYPE(ob), &PySet_Type) || \ - PyType_IsSubtype(Py_TYPE(ob), &PyFrozenSet_Type)) -#define PySet_Check(ob) \ - (Py_TYPE(ob) == &PySet_Type || \ - PyType_IsSubtype(Py_TYPE(ob), &PySet_Type)) -#define PyFrozenSet_Check(ob) \ - (Py_TYPE(ob) == &PyFrozenSet_Type || \ - PyType_IsSubtype(Py_TYPE(ob), &PyFrozenSet_Type)) - -PyAPI_FUNC(PyObject *) PySet_New(PyObject *); -PyAPI_FUNC(PyObject *) PyFrozenSet_New(PyObject *); -PyAPI_FUNC(Py_ssize_t) PySet_Size(PyObject *anyset); -#define PySet_GET_SIZE(so) (((PySetObject *)(so))->used) -PyAPI_FUNC(int) PySet_Clear(PyObject *set); -PyAPI_FUNC(int) PySet_Contains(PyObject *anyset, PyObject *key); -PyAPI_FUNC(int) PySet_Discard(PyObject *set, PyObject *key); -PyAPI_FUNC(int) PySet_Add(PyObject *set, PyObject *key); -PyAPI_FUNC(int) _PySet_Next(PyObject *set, Py_ssize_t *pos, PyObject **key); -PyAPI_FUNC(int) _PySet_NextEntry(PyObject *set, Py_ssize_t *pos, PyObject **key, long *hash); -PyAPI_FUNC(PyObject *) PySet_Pop(PyObject *set); -PyAPI_FUNC(int) _PySet_Update(PyObject *set, PyObject *iterable); - -#ifdef __cplusplus -} -#endif -#endif /* !Py_SETOBJECT_H */ diff --git a/python/include/sliceobject.h b/python/include/sliceobject.h deleted file mode 100644 index 8ab62dd4..00000000 --- a/python/include/sliceobject.h +++ /dev/null @@ -1,44 +0,0 @@ -#ifndef Py_SLICEOBJECT_H -#define Py_SLICEOBJECT_H -#ifdef __cplusplus -extern "C" { -#endif - -/* The unique ellipsis object "..." */ - -PyAPI_DATA(PyObject) _Py_EllipsisObject; /* Don't use this directly */ - -#define Py_Ellipsis (&_Py_EllipsisObject) - -/* Slice object interface */ - -/* - -A slice object containing start, stop, and step data members (the -names are from range). After much talk with Guido, it was decided to -let these be any arbitrary python type. Py_None stands for omitted values. -*/ - -typedef struct { - PyObject_HEAD - PyObject *start, *stop, *step; /* not NULL */ -} PySliceObject; - -PyAPI_DATA(PyTypeObject) PySlice_Type; -PyAPI_DATA(PyTypeObject) PyEllipsis_Type; - -#define PySlice_Check(op) (Py_TYPE(op) == &PySlice_Type) - -PyAPI_FUNC(PyObject *) PySlice_New(PyObject* start, PyObject* stop, - PyObject* step); -PyAPI_FUNC(PyObject *) _PySlice_FromIndices(Py_ssize_t start, Py_ssize_t stop); -PyAPI_FUNC(int) PySlice_GetIndices(PySliceObject *r, Py_ssize_t length, - Py_ssize_t *start, Py_ssize_t *stop, Py_ssize_t *step); -PyAPI_FUNC(int) PySlice_GetIndicesEx(PySliceObject *r, Py_ssize_t length, - Py_ssize_t *start, Py_ssize_t *stop, - Py_ssize_t *step, Py_ssize_t *slicelength); - -#ifdef __cplusplus -} -#endif -#endif /* !Py_SLICEOBJECT_H */ diff --git a/python/include/stringobject.h b/python/include/stringobject.h deleted file mode 100644 index 18b5b411..00000000 --- a/python/include/stringobject.h +++ /dev/null @@ -1,210 +0,0 @@ - -/* String (str/bytes) object interface */ - -#ifndef Py_STRINGOBJECT_H -#define Py_STRINGOBJECT_H -#ifdef __cplusplus -extern "C" { -#endif - -#include - -/* -Type PyStringObject represents a character string. An extra zero byte is -reserved at the end to ensure it is zero-terminated, but a size is -present so strings with null bytes in them can be represented. This -is an immutable object type. - -There are functions to create new string objects, to test -an object for string-ness, and to get the -string value. The latter function returns a null pointer -if the object is not of the proper type. -There is a variant that takes an explicit size as well as a -variant that assumes a zero-terminated string. Note that none of the -functions should be applied to nil objects. -*/ - -/* Caching the hash (ob_shash) saves recalculation of a string's hash value. - Interning strings (ob_sstate) tries to ensure that only one string - object with a given value exists, so equality tests can be one pointer - comparison. This is generally restricted to strings that "look like" - Python identifiers, although the intern() builtin can be used to force - interning of any string. - Together, these sped the interpreter by up to 20%. */ - -typedef struct { - PyObject_VAR_HEAD - long ob_shash; - int ob_sstate; - char ob_sval[1]; - - /* Invariants: - * ob_sval contains space for 'ob_size+1' elements. - * ob_sval[ob_size] == 0. - * ob_shash is the hash of the string or -1 if not computed yet. - * ob_sstate != 0 iff the string object is in stringobject.c's - * 'interned' dictionary; in this case the two references - * from 'interned' to this object are *not counted* in ob_refcnt. - */ -} PyStringObject; - -#define SSTATE_NOT_INTERNED 0 -#define SSTATE_INTERNED_MORTAL 1 -#define SSTATE_INTERNED_IMMORTAL 2 - -PyAPI_DATA(PyTypeObject) PyBaseString_Type; -PyAPI_DATA(PyTypeObject) PyString_Type; - -#define PyString_Check(op) \ - PyType_FastSubclass(Py_TYPE(op), Py_TPFLAGS_STRING_SUBCLASS) -#define PyString_CheckExact(op) (Py_TYPE(op) == &PyString_Type) - -PyAPI_FUNC(PyObject *) PyString_FromStringAndSize(const char *, Py_ssize_t); -PyAPI_FUNC(PyObject *) PyString_FromString(const char *); -PyAPI_FUNC(PyObject *) PyString_FromFormatV(const char*, va_list) - Py_GCC_ATTRIBUTE((format(printf, 1, 0))); -PyAPI_FUNC(PyObject *) PyString_FromFormat(const char*, ...) - Py_GCC_ATTRIBUTE((format(printf, 1, 2))); -PyAPI_FUNC(Py_ssize_t) PyString_Size(PyObject *); -PyAPI_FUNC(char *) PyString_AsString(PyObject *); -PyAPI_FUNC(PyObject *) PyString_Repr(PyObject *, int); -PyAPI_FUNC(void) PyString_Concat(PyObject **, PyObject *); -PyAPI_FUNC(void) PyString_ConcatAndDel(PyObject **, PyObject *); -PyAPI_FUNC(int) _PyString_Resize(PyObject **, Py_ssize_t); -PyAPI_FUNC(int) _PyString_Eq(PyObject *, PyObject*); -PyAPI_FUNC(PyObject *) PyString_Format(PyObject *, PyObject *); -PyAPI_FUNC(PyObject *) _PyString_FormatLong(PyObject*, int, int, - int, char**, int*); -PyAPI_FUNC(PyObject *) PyString_DecodeEscape(const char *, Py_ssize_t, - const char *, Py_ssize_t, - const char *); - -PyAPI_FUNC(void) PyString_InternInPlace(PyObject **); -PyAPI_FUNC(void) PyString_InternImmortal(PyObject **); -PyAPI_FUNC(PyObject *) PyString_InternFromString(const char *); -PyAPI_FUNC(void) _Py_ReleaseInternedStrings(void); - -/* Use only if you know it's a string */ -#define PyString_CHECK_INTERNED(op) (((PyStringObject *)(op))->ob_sstate) - -/* Macro, trading safety for speed */ -#define PyString_AS_STRING(op) (((PyStringObject *)(op))->ob_sval) -#define PyString_GET_SIZE(op) Py_SIZE(op) - -/* _PyString_Join(sep, x) is like sep.join(x). sep must be PyStringObject*, - x must be an iterable object. */ -PyAPI_FUNC(PyObject *) _PyString_Join(PyObject *sep, PyObject *x); - -/* --- Generic Codecs ----------------------------------------------------- */ - -/* Create an object by decoding the encoded string s of the - given size. */ - -PyAPI_FUNC(PyObject*) PyString_Decode( - const char *s, /* encoded string */ - Py_ssize_t size, /* size of buffer */ - const char *encoding, /* encoding */ - const char *errors /* error handling */ - ); - -/* Encodes a char buffer of the given size and returns a - Python object. */ - -PyAPI_FUNC(PyObject*) PyString_Encode( - const char *s, /* string char buffer */ - Py_ssize_t size, /* number of chars to encode */ - const char *encoding, /* encoding */ - const char *errors /* error handling */ - ); - -/* Encodes a string object and returns the result as Python - object. */ - -PyAPI_FUNC(PyObject*) PyString_AsEncodedObject( - PyObject *str, /* string object */ - const char *encoding, /* encoding */ - const char *errors /* error handling */ - ); - -/* Encodes a string object and returns the result as Python string - object. - - If the codec returns an Unicode object, the object is converted - back to a string using the default encoding. - - DEPRECATED - use PyString_AsEncodedObject() instead. */ - -PyAPI_FUNC(PyObject*) PyString_AsEncodedString( - PyObject *str, /* string object */ - const char *encoding, /* encoding */ - const char *errors /* error handling */ - ); - -/* Decodes a string object and returns the result as Python - object. */ - -PyAPI_FUNC(PyObject*) PyString_AsDecodedObject( - PyObject *str, /* string object */ - const char *encoding, /* encoding */ - const char *errors /* error handling */ - ); - -/* Decodes a string object and returns the result as Python string - object. - - If the codec returns an Unicode object, the object is converted - back to a string using the default encoding. - - DEPRECATED - use PyString_AsDecodedObject() instead. */ - -PyAPI_FUNC(PyObject*) PyString_AsDecodedString( - PyObject *str, /* string object */ - const char *encoding, /* encoding */ - const char *errors /* error handling */ - ); - -/* Provides access to the internal data buffer and size of a string - object or the default encoded version of an Unicode object. Passing - NULL as *len parameter will force the string buffer to be - 0-terminated (passing a string with embedded NULL characters will - cause an exception). */ - -PyAPI_FUNC(int) PyString_AsStringAndSize( - register PyObject *obj, /* string or Unicode object */ - register char **s, /* pointer to buffer variable */ - register Py_ssize_t *len /* pointer to length variable or NULL - (only possible for 0-terminated - strings) */ - ); - - -/* Using the current locale, insert the thousands grouping - into the string pointed to by buffer. For the argument descriptions, - see Objects/stringlib/localeutil.h */ -PyAPI_FUNC(Py_ssize_t) _PyString_InsertThousandsGroupingLocale(char *buffer, - Py_ssize_t n_buffer, - char *digits, - Py_ssize_t n_digits, - Py_ssize_t min_width); - -/* Using explicit passed-in values, insert the thousands grouping - into the string pointed to by buffer. For the argument descriptions, - see Objects/stringlib/localeutil.h */ -PyAPI_FUNC(Py_ssize_t) _PyString_InsertThousandsGrouping(char *buffer, - Py_ssize_t n_buffer, - char *digits, - Py_ssize_t n_digits, - Py_ssize_t min_width, - const char *grouping, - const char *thousands_sep); - -/* Format the object based on the format_spec, as defined in PEP 3101 - (Advanced String Formatting). */ -PyAPI_FUNC(PyObject *) _PyBytes_FormatAdvanced(PyObject *obj, - char *format_spec, - Py_ssize_t format_spec_len); - -#ifdef __cplusplus -} -#endif -#endif /* !Py_STRINGOBJECT_H */ diff --git a/python/include/structmember.h b/python/include/structmember.h deleted file mode 100644 index fe5b44ea..00000000 --- a/python/include/structmember.h +++ /dev/null @@ -1,99 +0,0 @@ -#ifndef Py_STRUCTMEMBER_H -#define Py_STRUCTMEMBER_H -#ifdef __cplusplus -extern "C" { -#endif - - -/* Interface to map C struct members to Python object attributes */ - -#include /* For offsetof */ - -/* The offsetof() macro calculates the offset of a structure member - in its structure. Unfortunately this cannot be written down - portably, hence it is provided by a Standard C header file. - For pre-Standard C compilers, here is a version that usually works - (but watch out!): */ - -#ifndef offsetof -#define offsetof(type, member) ( (int) & ((type*)0) -> member ) -#endif - -/* An array of memberlist structures defines the name, type and offset - of selected members of a C structure. These can be read by - PyMember_Get() and set by PyMember_Set() (except if their READONLY flag - is set). The array must be terminated with an entry whose name - pointer is NULL. */ - -struct memberlist { - /* Obsolete version, for binary backwards compatibility */ - char *name; - int type; - int offset; - int flags; -}; - -typedef struct PyMemberDef { - /* Current version, use this */ - char *name; - int type; - Py_ssize_t offset; - int flags; - char *doc; -} PyMemberDef; - -/* Types */ -#define T_SHORT 0 -#define T_INT 1 -#define T_LONG 2 -#define T_FLOAT 3 -#define T_DOUBLE 4 -#define T_STRING 5 -#define T_OBJECT 6 -/* XXX the ordering here is weird for binary compatibility */ -#define T_CHAR 7 /* 1-character string */ -#define T_BYTE 8 /* 8-bit signed int */ -/* unsigned variants: */ -#define T_UBYTE 9 -#define T_USHORT 10 -#define T_UINT 11 -#define T_ULONG 12 - -/* Added by Jack: strings contained in the structure */ -#define T_STRING_INPLACE 13 - -/* Added by Lillo: bools contained in the structure (assumed char) */ -#define T_BOOL 14 - -#define T_OBJECT_EX 16 /* Like T_OBJECT, but raises AttributeError - when the value is NULL, instead of - converting to None. */ -#ifdef HAVE_LONG_LONG -#define T_LONGLONG 17 -#define T_ULONGLONG 18 -#endif /* HAVE_LONG_LONG */ - -#define T_PYSSIZET 19 /* Py_ssize_t */ - - -/* Flags */ -#define READONLY 1 -#define RO READONLY /* Shorthand */ -#define READ_RESTRICTED 2 -#define PY_WRITE_RESTRICTED 4 -#define RESTRICTED (READ_RESTRICTED | PY_WRITE_RESTRICTED) - - -/* Obsolete API, for binary backwards compatibility */ -PyAPI_FUNC(PyObject *) PyMember_Get(const char *, struct memberlist *, const char *); -PyAPI_FUNC(int) PyMember_Set(char *, struct memberlist *, const char *, PyObject *); - -/* Current API, use this */ -PyAPI_FUNC(PyObject *) PyMember_GetOne(const char *, struct PyMemberDef *); -PyAPI_FUNC(int) PyMember_SetOne(char *, struct PyMemberDef *, PyObject *); - - -#ifdef __cplusplus -} -#endif -#endif /* !Py_STRUCTMEMBER_H */ diff --git a/python/include/structseq.h b/python/include/structseq.h deleted file mode 100644 index e662916f..00000000 --- a/python/include/structseq.h +++ /dev/null @@ -1,41 +0,0 @@ - -/* Tuple object interface */ - -#ifndef Py_STRUCTSEQ_H -#define Py_STRUCTSEQ_H -#ifdef __cplusplus -extern "C" { -#endif - -typedef struct PyStructSequence_Field { - char *name; - char *doc; -} PyStructSequence_Field; - -typedef struct PyStructSequence_Desc { - char *name; - char *doc; - struct PyStructSequence_Field *fields; - int n_in_sequence; -} PyStructSequence_Desc; - -extern char* PyStructSequence_UnnamedField; - -PyAPI_FUNC(void) PyStructSequence_InitType(PyTypeObject *type, - PyStructSequence_Desc *desc); - -PyAPI_FUNC(PyObject *) PyStructSequence_New(PyTypeObject* type); - -typedef struct { - PyObject_VAR_HEAD - PyObject *ob_item[1]; -} PyStructSequence; - -/* Macro, *only* to be used to fill in brand new objects */ -#define PyStructSequence_SET_ITEM(op, i, v) \ - (((PyStructSequence *)(op))->ob_item[i] = v) - -#ifdef __cplusplus -} -#endif -#endif /* !Py_STRUCTSEQ_H */ diff --git a/python/include/symtable.h b/python/include/symtable.h deleted file mode 100644 index e0a0be41..00000000 --- a/python/include/symtable.h +++ /dev/null @@ -1,98 +0,0 @@ -#ifndef Py_SYMTABLE_H -#define Py_SYMTABLE_H - -#ifdef __cplusplus -extern "C" { -#endif - -typedef enum _block_type { FunctionBlock, ClassBlock, ModuleBlock } - _Py_block_ty; - -struct _symtable_entry; - -struct symtable { - const char *st_filename; /* name of file being compiled */ - struct _symtable_entry *st_cur; /* current symbol table entry */ - struct _symtable_entry *st_top; /* module entry */ - PyObject *st_symbols; /* dictionary of symbol table entries */ - PyObject *st_stack; /* stack of namespace info */ - PyObject *st_global; /* borrowed ref to MODULE in st_symbols */ - int st_nblocks; /* number of blocks */ - PyObject *st_private; /* name of current class or NULL */ - PyFutureFeatures *st_future; /* module's future features */ -}; - -typedef struct _symtable_entry { - PyObject_HEAD - PyObject *ste_id; /* int: key in st_symbols */ - PyObject *ste_symbols; /* dict: name to flags */ - PyObject *ste_name; /* string: name of block */ - PyObject *ste_varnames; /* list of variable names */ - PyObject *ste_children; /* list of child ids */ - _Py_block_ty ste_type; /* module, class, or function */ - int ste_unoptimized; /* false if namespace is optimized */ - int ste_nested; /* true if block is nested */ - unsigned ste_free : 1; /* true if block has free variables */ - unsigned ste_child_free : 1; /* true if a child block has free vars, - including free refs to globals */ - unsigned ste_generator : 1; /* true if namespace is a generator */ - unsigned ste_varargs : 1; /* true if block has varargs */ - unsigned ste_varkeywords : 1; /* true if block has varkeywords */ - unsigned ste_returns_value : 1; /* true if namespace uses return with - an argument */ - int ste_lineno; /* first line of block */ - int ste_opt_lineno; /* lineno of last exec or import * */ - int ste_tmpname; /* counter for listcomp temp vars */ - struct symtable *ste_table; -} PySTEntryObject; - -PyAPI_DATA(PyTypeObject) PySTEntry_Type; - -#define PySTEntry_Check(op) (Py_TYPE(op) == &PySTEntry_Type) - -PyAPI_FUNC(int) PyST_GetScope(PySTEntryObject *, PyObject *); - -PyAPI_FUNC(struct symtable *) PySymtable_Build(mod_ty, const char *, - PyFutureFeatures *); -PyAPI_FUNC(PySTEntryObject *) PySymtable_Lookup(struct symtable *, void *); - -PyAPI_FUNC(void) PySymtable_Free(struct symtable *); - -/* Flags for def-use information */ - -#define DEF_GLOBAL 1 /* global stmt */ -#define DEF_LOCAL 2 /* assignment in code block */ -#define DEF_PARAM 2<<1 /* formal parameter */ -#define USE 2<<2 /* name is used */ -#define DEF_FREE 2<<3 /* name used but not defined in nested block */ -#define DEF_FREE_CLASS 2<<4 /* free variable from class's method */ -#define DEF_IMPORT 2<<5 /* assignment occurred via import */ - -#define DEF_BOUND (DEF_LOCAL | DEF_PARAM | DEF_IMPORT) - -/* GLOBAL_EXPLICIT and GLOBAL_IMPLICIT are used internally by the symbol - table. GLOBAL is returned from PyST_GetScope() for either of them. - It is stored in ste_symbols at bits 12-14. -*/ -#define SCOPE_OFF 11 -#define SCOPE_MASK 7 - -#define LOCAL 1 -#define GLOBAL_EXPLICIT 2 -#define GLOBAL_IMPLICIT 3 -#define FREE 4 -#define CELL 5 - -/* The following three names are used for the ste_unoptimized bit field */ -#define OPT_IMPORT_STAR 1 -#define OPT_EXEC 2 -#define OPT_BARE_EXEC 4 -#define OPT_TOPLEVEL 8 /* top-level names, including eval and exec */ - -#define GENERATOR 1 -#define GENERATOR_EXPRESSION 2 - -#ifdef __cplusplus -} -#endif -#endif /* !Py_SYMTABLE_H */ diff --git a/python/include/sysmodule.h b/python/include/sysmodule.h deleted file mode 100644 index 16af1196..00000000 --- a/python/include/sysmodule.h +++ /dev/null @@ -1,32 +0,0 @@ - -/* System module interface */ - -#ifndef Py_SYSMODULE_H -#define Py_SYSMODULE_H -#ifdef __cplusplus -extern "C" { -#endif - -PyAPI_FUNC(PyObject *) PySys_GetObject(char *); -PyAPI_FUNC(int) PySys_SetObject(char *, PyObject *); -PyAPI_FUNC(FILE *) PySys_GetFile(char *, FILE *); -PyAPI_FUNC(void) PySys_SetArgv(int, char **); -PyAPI_FUNC(void) PySys_SetArgvEx(int, char **, int); -PyAPI_FUNC(void) PySys_SetPath(char *); - -PyAPI_FUNC(void) PySys_WriteStdout(const char *format, ...) - Py_GCC_ATTRIBUTE((format(printf, 1, 2))); -PyAPI_FUNC(void) PySys_WriteStderr(const char *format, ...) - Py_GCC_ATTRIBUTE((format(printf, 1, 2))); - -PyAPI_DATA(PyObject *) _PySys_TraceFunc, *_PySys_ProfileFunc; -PyAPI_DATA(int) _PySys_CheckInterval; - -PyAPI_FUNC(void) PySys_ResetWarnOptions(void); -PyAPI_FUNC(void) PySys_AddWarnOption(char *); -PyAPI_FUNC(int) PySys_HasWarnOptions(void); - -#ifdef __cplusplus -} -#endif -#endif /* !Py_SYSMODULE_H */ diff --git a/python/include/timefuncs.h b/python/include/timefuncs.h deleted file mode 100644 index 553142db..00000000 --- a/python/include/timefuncs.h +++ /dev/null @@ -1,23 +0,0 @@ -/* timefuncs.h - */ - -/* Utility function related to timemodule.c. */ - -#ifndef TIMEFUNCS_H -#define TIMEFUNCS_H -#ifdef __cplusplus -extern "C" { -#endif - - -/* Cast double x to time_t, but raise ValueError if x is too large - * to fit in a time_t. ValueError is set on return iff the return - * value is (time_t)-1 and PyErr_Occurred(). - */ -PyAPI_FUNC(time_t) _PyTime_DoubleToTimet(double x); - - -#ifdef __cplusplus -} -#endif -#endif /* TIMEFUNCS_H */ diff --git a/python/include/token.h b/python/include/token.h deleted file mode 100644 index 72659ac0..00000000 --- a/python/include/token.h +++ /dev/null @@ -1,85 +0,0 @@ - -/* Token types */ - -#ifndef Py_TOKEN_H -#define Py_TOKEN_H -#ifdef __cplusplus -extern "C" { -#endif - -#undef TILDE /* Prevent clash of our definition with system macro. Ex AIX, ioctl.h */ - -#define ENDMARKER 0 -#define NAME 1 -#define NUMBER 2 -#define STRING 3 -#define NEWLINE 4 -#define INDENT 5 -#define DEDENT 6 -#define LPAR 7 -#define RPAR 8 -#define LSQB 9 -#define RSQB 10 -#define COLON 11 -#define COMMA 12 -#define SEMI 13 -#define PLUS 14 -#define MINUS 15 -#define STAR 16 -#define SLASH 17 -#define VBAR 18 -#define AMPER 19 -#define LESS 20 -#define GREATER 21 -#define EQUAL 22 -#define DOT 23 -#define PERCENT 24 -#define BACKQUOTE 25 -#define LBRACE 26 -#define RBRACE 27 -#define EQEQUAL 28 -#define NOTEQUAL 29 -#define LESSEQUAL 30 -#define GREATEREQUAL 31 -#define TILDE 32 -#define CIRCUMFLEX 33 -#define LEFTSHIFT 34 -#define RIGHTSHIFT 35 -#define DOUBLESTAR 36 -#define PLUSEQUAL 37 -#define MINEQUAL 38 -#define STAREQUAL 39 -#define SLASHEQUAL 40 -#define PERCENTEQUAL 41 -#define AMPEREQUAL 42 -#define VBAREQUAL 43 -#define CIRCUMFLEXEQUAL 44 -#define LEFTSHIFTEQUAL 45 -#define RIGHTSHIFTEQUAL 46 -#define DOUBLESTAREQUAL 47 -#define DOUBLESLASH 48 -#define DOUBLESLASHEQUAL 49 -#define AT 50 -/* Don't forget to update the table _PyParser_TokenNames in tokenizer.c! */ -#define OP 51 -#define ERRORTOKEN 52 -#define N_TOKENS 53 - -/* Special definitions for cooperation with parser */ - -#define NT_OFFSET 256 - -#define ISTERMINAL(x) ((x) < NT_OFFSET) -#define ISNONTERMINAL(x) ((x) >= NT_OFFSET) -#define ISEOF(x) ((x) == ENDMARKER) - - -PyAPI_DATA(char *) _PyParser_TokenNames[]; /* Token names */ -PyAPI_FUNC(int) PyToken_OneChar(int); -PyAPI_FUNC(int) PyToken_TwoChars(int, int); -PyAPI_FUNC(int) PyToken_ThreeChars(int, int, int); - -#ifdef __cplusplus -} -#endif -#endif /* !Py_TOKEN_H */ diff --git a/python/include/traceback.h b/python/include/traceback.h deleted file mode 100644 index e7943dae..00000000 --- a/python/include/traceback.h +++ /dev/null @@ -1,31 +0,0 @@ - -#ifndef Py_TRACEBACK_H -#define Py_TRACEBACK_H -#ifdef __cplusplus -extern "C" { -#endif - -struct _frame; - -/* Traceback interface */ - -typedef struct _traceback { - PyObject_HEAD - struct _traceback *tb_next; - struct _frame *tb_frame; - int tb_lasti; - int tb_lineno; -} PyTracebackObject; - -PyAPI_FUNC(int) PyTraceBack_Here(struct _frame *); -PyAPI_FUNC(int) PyTraceBack_Print(PyObject *, PyObject *); -PyAPI_FUNC(int) _Py_DisplaySourceLine(PyObject *, const char *, int, int); - -/* Reveal traceback type so we can typecheck traceback objects */ -PyAPI_DATA(PyTypeObject) PyTraceBack_Type; -#define PyTraceBack_Check(v) (Py_TYPE(v) == &PyTraceBack_Type) - -#ifdef __cplusplus -} -#endif -#endif /* !Py_TRACEBACK_H */ diff --git a/python/include/tupleobject.h b/python/include/tupleobject.h deleted file mode 100644 index a5ab7332..00000000 --- a/python/include/tupleobject.h +++ /dev/null @@ -1,61 +0,0 @@ - -/* Tuple object interface */ - -#ifndef Py_TUPLEOBJECT_H -#define Py_TUPLEOBJECT_H -#ifdef __cplusplus -extern "C" { -#endif - -/* -Another generally useful object type is a tuple of object pointers. -For Python, this is an immutable type. C code can change the tuple items -(but not their number), and even use tuples are general-purpose arrays of -object references, but in general only brand new tuples should be mutated, -not ones that might already have been exposed to Python code. - -*** WARNING *** PyTuple_SetItem does not increment the new item's reference -count, but does decrement the reference count of the item it replaces, -if not nil. It does *decrement* the reference count if it is *not* -inserted in the tuple. Similarly, PyTuple_GetItem does not increment the -returned item's reference count. -*/ - -typedef struct { - PyObject_VAR_HEAD - PyObject *ob_item[1]; - - /* ob_item contains space for 'ob_size' elements. - * Items must normally not be NULL, except during construction when - * the tuple is not yet visible outside the function that builds it. - */ -} PyTupleObject; - -PyAPI_DATA(PyTypeObject) PyTuple_Type; - -#define PyTuple_Check(op) \ - PyType_FastSubclass(Py_TYPE(op), Py_TPFLAGS_TUPLE_SUBCLASS) -#define PyTuple_CheckExact(op) (Py_TYPE(op) == &PyTuple_Type) - -PyAPI_FUNC(PyObject *) PyTuple_New(Py_ssize_t size); -PyAPI_FUNC(Py_ssize_t) PyTuple_Size(PyObject *); -PyAPI_FUNC(PyObject *) PyTuple_GetItem(PyObject *, Py_ssize_t); -PyAPI_FUNC(int) PyTuple_SetItem(PyObject *, Py_ssize_t, PyObject *); -PyAPI_FUNC(PyObject *) PyTuple_GetSlice(PyObject *, Py_ssize_t, Py_ssize_t); -PyAPI_FUNC(int) _PyTuple_Resize(PyObject **, Py_ssize_t); -PyAPI_FUNC(PyObject *) PyTuple_Pack(Py_ssize_t, ...); -PyAPI_FUNC(void) _PyTuple_MaybeUntrack(PyObject *); - -/* Macro, trading safety for speed */ -#define PyTuple_GET_ITEM(op, i) (((PyTupleObject *)(op))->ob_item[i]) -#define PyTuple_GET_SIZE(op) Py_SIZE(op) - -/* Macro, *only* to be used to fill in brand new tuples */ -#define PyTuple_SET_ITEM(op, i, v) (((PyTupleObject *)(op))->ob_item[i] = v) - -PyAPI_FUNC(int) PyTuple_ClearFreeList(void); - -#ifdef __cplusplus -} -#endif -#endif /* !Py_TUPLEOBJECT_H */ diff --git a/python/include/ucnhash.h b/python/include/ucnhash.h deleted file mode 100644 index 69b7774a..00000000 --- a/python/include/ucnhash.h +++ /dev/null @@ -1,33 +0,0 @@ -/* Unicode name database interface */ - -#ifndef Py_UCNHASH_H -#define Py_UCNHASH_H -#ifdef __cplusplus -extern "C" { -#endif - -/* revised ucnhash CAPI interface (exported through a "wrapper") */ - -#define PyUnicodeData_CAPSULE_NAME "unicodedata.ucnhash_CAPI" - -typedef struct { - - /* Size of this struct */ - int size; - - /* Get name for a given character code. Returns non-zero if - success, zero if not. Does not set Python exceptions. - If self is NULL, data come from the default version of the database. - If it is not NULL, it should be a unicodedata.ucd_X_Y_Z object */ - int (*getname)(PyObject *self, Py_UCS4 code, char* buffer, int buflen); - - /* Get character code for a given name. Same error handling - as for getname. */ - int (*getcode)(PyObject *self, const char* name, int namelen, Py_UCS4* code); - -} _PyUnicode_Name_CAPI; - -#ifdef __cplusplus -} -#endif -#endif /* !Py_UCNHASH_H */ diff --git a/python/include/unicodeobject.h b/python/include/unicodeobject.h deleted file mode 100644 index 9ab724aa..00000000 --- a/python/include/unicodeobject.h +++ /dev/null @@ -1,1413 +0,0 @@ -#ifndef Py_UNICODEOBJECT_H -#define Py_UNICODEOBJECT_H - -#include - -/* - -Unicode implementation based on original code by Fredrik Lundh, -modified by Marc-Andre Lemburg (mal@lemburg.com) according to the -Unicode Integration Proposal (see file Misc/unicode.txt). - -Copyright (c) Corporation for National Research Initiatives. - - - Original header: - -------------------------------------------------------------------- - - * Yet another Unicode string type for Python. This type supports the - * 16-bit Basic Multilingual Plane (BMP) only. - * - * Written by Fredrik Lundh, January 1999. - * - * Copyright (c) 1999 by Secret Labs AB. - * Copyright (c) 1999 by Fredrik Lundh. - * - * fredrik@pythonware.com - * http://www.pythonware.com - * - * -------------------------------------------------------------------- - * This Unicode String Type is - * - * Copyright (c) 1999 by Secret Labs AB - * Copyright (c) 1999 by Fredrik Lundh - * - * By obtaining, using, and/or copying this software and/or its - * associated documentation, you agree that you have read, understood, - * and will comply with the following terms and conditions: - * - * Permission to use, copy, modify, and distribute this software and its - * associated documentation for any purpose and without fee is hereby - * granted, provided that the above copyright notice appears in all - * copies, and that both that copyright notice and this permission notice - * appear in supporting documentation, and that the name of Secret Labs - * AB or the author not be used in advertising or publicity pertaining to - * distribution of the software without specific, written prior - * permission. - * - * SECRET LABS AB AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO - * THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND - * FITNESS. IN NO EVENT SHALL SECRET LABS AB OR THE AUTHOR BE LIABLE FOR - * ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT - * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - * -------------------------------------------------------------------- */ - -#include - -/* === Internal API ======================================================= */ - -/* --- Internal Unicode Format -------------------------------------------- */ - -#ifndef Py_USING_UNICODE - -#define PyUnicode_Check(op) 0 -#define PyUnicode_CheckExact(op) 0 - -#else - -/* FIXME: MvL's new implementation assumes that Py_UNICODE_SIZE is - properly set, but the default rules below doesn't set it. I'll - sort this out some other day -- fredrik@pythonware.com */ - -#ifndef Py_UNICODE_SIZE -#error Must define Py_UNICODE_SIZE -#endif - -/* Setting Py_UNICODE_WIDE enables UCS-4 storage. Otherwise, Unicode - strings are stored as UCS-2 (with limited support for UTF-16) */ - -#if Py_UNICODE_SIZE >= 4 -#define Py_UNICODE_WIDE -#endif - -/* Set these flags if the platform has "wchar.h", "wctype.h" and the - wchar_t type is a 16-bit unsigned type */ -/* #define HAVE_WCHAR_H */ -/* #define HAVE_USABLE_WCHAR_T */ - -/* Defaults for various platforms */ -#ifndef PY_UNICODE_TYPE - -/* Windows has a usable wchar_t type (unless we're using UCS-4) */ -# if defined(MS_WIN32) && Py_UNICODE_SIZE == 2 -# define HAVE_USABLE_WCHAR_T -# define PY_UNICODE_TYPE wchar_t -# endif - -# if defined(Py_UNICODE_WIDE) -# define PY_UNICODE_TYPE Py_UCS4 -# endif - -#endif - -/* If the compiler provides a wchar_t type we try to support it - through the interface functions PyUnicode_FromWideChar() and - PyUnicode_AsWideChar(). */ - -#ifdef HAVE_USABLE_WCHAR_T -# ifndef HAVE_WCHAR_H -# define HAVE_WCHAR_H -# endif -#endif - -#ifdef HAVE_WCHAR_H -/* Work around a cosmetic bug in BSDI 4.x wchar.h; thanks to Thomas Wouters */ -# ifdef _HAVE_BSDI -# include -# endif -# include -#endif - -/* - * Use this typedef when you need to represent a UTF-16 surrogate pair - * as single unsigned integer. - */ -#if SIZEOF_INT >= 4 -typedef unsigned int Py_UCS4; -#elif SIZEOF_LONG >= 4 -typedef unsigned long Py_UCS4; -#endif - -/* Py_UNICODE is the native Unicode storage format (code unit) used by - Python and represents a single Unicode element in the Unicode - type. */ - -typedef PY_UNICODE_TYPE Py_UNICODE; - -/* --- UCS-2/UCS-4 Name Mangling ------------------------------------------ */ - -/* Unicode API names are mangled to assure that UCS-2 and UCS-4 builds - produce different external names and thus cause import errors in - case Python interpreters and extensions with mixed compiled in - Unicode width assumptions are combined. */ - -#ifndef Py_UNICODE_WIDE - -# define PyUnicode_AsASCIIString PyUnicodeUCS2_AsASCIIString -# define PyUnicode_AsCharmapString PyUnicodeUCS2_AsCharmapString -# define PyUnicode_AsEncodedObject PyUnicodeUCS2_AsEncodedObject -# define PyUnicode_AsEncodedString PyUnicodeUCS2_AsEncodedString -# define PyUnicode_AsLatin1String PyUnicodeUCS2_AsLatin1String -# define PyUnicode_AsRawUnicodeEscapeString PyUnicodeUCS2_AsRawUnicodeEscapeString -# define PyUnicode_AsUTF32String PyUnicodeUCS2_AsUTF32String -# define PyUnicode_AsUTF16String PyUnicodeUCS2_AsUTF16String -# define PyUnicode_AsUTF8String PyUnicodeUCS2_AsUTF8String -# define PyUnicode_AsUnicode PyUnicodeUCS2_AsUnicode -# define PyUnicode_AsUnicodeEscapeString PyUnicodeUCS2_AsUnicodeEscapeString -# define PyUnicode_AsWideChar PyUnicodeUCS2_AsWideChar -# define PyUnicode_ClearFreeList PyUnicodeUCS2_ClearFreelist -# define PyUnicode_Compare PyUnicodeUCS2_Compare -# define PyUnicode_Concat PyUnicodeUCS2_Concat -# define PyUnicode_Contains PyUnicodeUCS2_Contains -# define PyUnicode_Count PyUnicodeUCS2_Count -# define PyUnicode_Decode PyUnicodeUCS2_Decode -# define PyUnicode_DecodeASCII PyUnicodeUCS2_DecodeASCII -# define PyUnicode_DecodeCharmap PyUnicodeUCS2_DecodeCharmap -# define PyUnicode_DecodeLatin1 PyUnicodeUCS2_DecodeLatin1 -# define PyUnicode_DecodeRawUnicodeEscape PyUnicodeUCS2_DecodeRawUnicodeEscape -# define PyUnicode_DecodeUTF32 PyUnicodeUCS2_DecodeUTF32 -# define PyUnicode_DecodeUTF32Stateful PyUnicodeUCS2_DecodeUTF32Stateful -# define PyUnicode_DecodeUTF16 PyUnicodeUCS2_DecodeUTF16 -# define PyUnicode_DecodeUTF16Stateful PyUnicodeUCS2_DecodeUTF16Stateful -# define PyUnicode_DecodeUTF8 PyUnicodeUCS2_DecodeUTF8 -# define PyUnicode_DecodeUTF8Stateful PyUnicodeUCS2_DecodeUTF8Stateful -# define PyUnicode_DecodeUnicodeEscape PyUnicodeUCS2_DecodeUnicodeEscape -# define PyUnicode_Encode PyUnicodeUCS2_Encode -# define PyUnicode_EncodeASCII PyUnicodeUCS2_EncodeASCII -# define PyUnicode_EncodeCharmap PyUnicodeUCS2_EncodeCharmap -# define PyUnicode_EncodeDecimal PyUnicodeUCS2_EncodeDecimal -# define PyUnicode_EncodeLatin1 PyUnicodeUCS2_EncodeLatin1 -# define PyUnicode_EncodeRawUnicodeEscape PyUnicodeUCS2_EncodeRawUnicodeEscape -# define PyUnicode_EncodeUTF32 PyUnicodeUCS2_EncodeUTF32 -# define PyUnicode_EncodeUTF16 PyUnicodeUCS2_EncodeUTF16 -# define PyUnicode_EncodeUTF8 PyUnicodeUCS2_EncodeUTF8 -# define PyUnicode_EncodeUnicodeEscape PyUnicodeUCS2_EncodeUnicodeEscape -# define PyUnicode_Find PyUnicodeUCS2_Find -# define PyUnicode_Format PyUnicodeUCS2_Format -# define PyUnicode_FromEncodedObject PyUnicodeUCS2_FromEncodedObject -# define PyUnicode_FromFormat PyUnicodeUCS2_FromFormat -# define PyUnicode_FromFormatV PyUnicodeUCS2_FromFormatV -# define PyUnicode_FromObject PyUnicodeUCS2_FromObject -# define PyUnicode_FromOrdinal PyUnicodeUCS2_FromOrdinal -# define PyUnicode_FromString PyUnicodeUCS2_FromString -# define PyUnicode_FromStringAndSize PyUnicodeUCS2_FromStringAndSize -# define PyUnicode_FromUnicode PyUnicodeUCS2_FromUnicode -# define PyUnicode_FromWideChar PyUnicodeUCS2_FromWideChar -# define PyUnicode_GetDefaultEncoding PyUnicodeUCS2_GetDefaultEncoding -# define PyUnicode_GetMax PyUnicodeUCS2_GetMax -# define PyUnicode_GetSize PyUnicodeUCS2_GetSize -# define PyUnicode_Join PyUnicodeUCS2_Join -# define PyUnicode_Partition PyUnicodeUCS2_Partition -# define PyUnicode_RPartition PyUnicodeUCS2_RPartition -# define PyUnicode_RSplit PyUnicodeUCS2_RSplit -# define PyUnicode_Replace PyUnicodeUCS2_Replace -# define PyUnicode_Resize PyUnicodeUCS2_Resize -# define PyUnicode_RichCompare PyUnicodeUCS2_RichCompare -# define PyUnicode_SetDefaultEncoding PyUnicodeUCS2_SetDefaultEncoding -# define PyUnicode_Split PyUnicodeUCS2_Split -# define PyUnicode_Splitlines PyUnicodeUCS2_Splitlines -# define PyUnicode_Tailmatch PyUnicodeUCS2_Tailmatch -# define PyUnicode_Translate PyUnicodeUCS2_Translate -# define PyUnicode_TranslateCharmap PyUnicodeUCS2_TranslateCharmap -# define _PyUnicode_AsDefaultEncodedString _PyUnicodeUCS2_AsDefaultEncodedString -# define _PyUnicode_Fini _PyUnicodeUCS2_Fini -# define _PyUnicode_Init _PyUnicodeUCS2_Init -# define _PyUnicode_IsAlpha _PyUnicodeUCS2_IsAlpha -# define _PyUnicode_IsDecimalDigit _PyUnicodeUCS2_IsDecimalDigit -# define _PyUnicode_IsDigit _PyUnicodeUCS2_IsDigit -# define _PyUnicode_IsLinebreak _PyUnicodeUCS2_IsLinebreak -# define _PyUnicode_IsLowercase _PyUnicodeUCS2_IsLowercase -# define _PyUnicode_IsNumeric _PyUnicodeUCS2_IsNumeric -# define _PyUnicode_IsTitlecase _PyUnicodeUCS2_IsTitlecase -# define _PyUnicode_IsUppercase _PyUnicodeUCS2_IsUppercase -# define _PyUnicode_IsWhitespace _PyUnicodeUCS2_IsWhitespace -# define _PyUnicode_ToDecimalDigit _PyUnicodeUCS2_ToDecimalDigit -# define _PyUnicode_ToDigit _PyUnicodeUCS2_ToDigit -# define _PyUnicode_ToLowercase _PyUnicodeUCS2_ToLowercase -# define _PyUnicode_ToNumeric _PyUnicodeUCS2_ToNumeric -# define _PyUnicode_ToTitlecase _PyUnicodeUCS2_ToTitlecase -# define _PyUnicode_ToUppercase _PyUnicodeUCS2_ToUppercase - -#else - -# define PyUnicode_AsASCIIString PyUnicodeUCS4_AsASCIIString -# define PyUnicode_AsCharmapString PyUnicodeUCS4_AsCharmapString -# define PyUnicode_AsEncodedObject PyUnicodeUCS4_AsEncodedObject -# define PyUnicode_AsEncodedString PyUnicodeUCS4_AsEncodedString -# define PyUnicode_AsLatin1String PyUnicodeUCS4_AsLatin1String -# define PyUnicode_AsRawUnicodeEscapeString PyUnicodeUCS4_AsRawUnicodeEscapeString -# define PyUnicode_AsUTF32String PyUnicodeUCS4_AsUTF32String -# define PyUnicode_AsUTF16String PyUnicodeUCS4_AsUTF16String -# define PyUnicode_AsUTF8String PyUnicodeUCS4_AsUTF8String -# define PyUnicode_AsUnicode PyUnicodeUCS4_AsUnicode -# define PyUnicode_AsUnicodeEscapeString PyUnicodeUCS4_AsUnicodeEscapeString -# define PyUnicode_AsWideChar PyUnicodeUCS4_AsWideChar -# define PyUnicode_ClearFreeList PyUnicodeUCS4_ClearFreelist -# define PyUnicode_Compare PyUnicodeUCS4_Compare -# define PyUnicode_Concat PyUnicodeUCS4_Concat -# define PyUnicode_Contains PyUnicodeUCS4_Contains -# define PyUnicode_Count PyUnicodeUCS4_Count -# define PyUnicode_Decode PyUnicodeUCS4_Decode -# define PyUnicode_DecodeASCII PyUnicodeUCS4_DecodeASCII -# define PyUnicode_DecodeCharmap PyUnicodeUCS4_DecodeCharmap -# define PyUnicode_DecodeLatin1 PyUnicodeUCS4_DecodeLatin1 -# define PyUnicode_DecodeRawUnicodeEscape PyUnicodeUCS4_DecodeRawUnicodeEscape -# define PyUnicode_DecodeUTF32 PyUnicodeUCS4_DecodeUTF32 -# define PyUnicode_DecodeUTF32Stateful PyUnicodeUCS4_DecodeUTF32Stateful -# define PyUnicode_DecodeUTF16 PyUnicodeUCS4_DecodeUTF16 -# define PyUnicode_DecodeUTF16Stateful PyUnicodeUCS4_DecodeUTF16Stateful -# define PyUnicode_DecodeUTF8 PyUnicodeUCS4_DecodeUTF8 -# define PyUnicode_DecodeUTF8Stateful PyUnicodeUCS4_DecodeUTF8Stateful -# define PyUnicode_DecodeUnicodeEscape PyUnicodeUCS4_DecodeUnicodeEscape -# define PyUnicode_Encode PyUnicodeUCS4_Encode -# define PyUnicode_EncodeASCII PyUnicodeUCS4_EncodeASCII -# define PyUnicode_EncodeCharmap PyUnicodeUCS4_EncodeCharmap -# define PyUnicode_EncodeDecimal PyUnicodeUCS4_EncodeDecimal -# define PyUnicode_EncodeLatin1 PyUnicodeUCS4_EncodeLatin1 -# define PyUnicode_EncodeRawUnicodeEscape PyUnicodeUCS4_EncodeRawUnicodeEscape -# define PyUnicode_EncodeUTF32 PyUnicodeUCS4_EncodeUTF32 -# define PyUnicode_EncodeUTF16 PyUnicodeUCS4_EncodeUTF16 -# define PyUnicode_EncodeUTF8 PyUnicodeUCS4_EncodeUTF8 -# define PyUnicode_EncodeUnicodeEscape PyUnicodeUCS4_EncodeUnicodeEscape -# define PyUnicode_Find PyUnicodeUCS4_Find -# define PyUnicode_Format PyUnicodeUCS4_Format -# define PyUnicode_FromEncodedObject PyUnicodeUCS4_FromEncodedObject -# define PyUnicode_FromFormat PyUnicodeUCS4_FromFormat -# define PyUnicode_FromFormatV PyUnicodeUCS4_FromFormatV -# define PyUnicode_FromObject PyUnicodeUCS4_FromObject -# define PyUnicode_FromOrdinal PyUnicodeUCS4_FromOrdinal -# define PyUnicode_FromString PyUnicodeUCS4_FromString -# define PyUnicode_FromStringAndSize PyUnicodeUCS4_FromStringAndSize -# define PyUnicode_FromUnicode PyUnicodeUCS4_FromUnicode -# define PyUnicode_FromWideChar PyUnicodeUCS4_FromWideChar -# define PyUnicode_GetDefaultEncoding PyUnicodeUCS4_GetDefaultEncoding -# define PyUnicode_GetMax PyUnicodeUCS4_GetMax -# define PyUnicode_GetSize PyUnicodeUCS4_GetSize -# define PyUnicode_Join PyUnicodeUCS4_Join -# define PyUnicode_Partition PyUnicodeUCS4_Partition -# define PyUnicode_RPartition PyUnicodeUCS4_RPartition -# define PyUnicode_RSplit PyUnicodeUCS4_RSplit -# define PyUnicode_Replace PyUnicodeUCS4_Replace -# define PyUnicode_Resize PyUnicodeUCS4_Resize -# define PyUnicode_RichCompare PyUnicodeUCS4_RichCompare -# define PyUnicode_SetDefaultEncoding PyUnicodeUCS4_SetDefaultEncoding -# define PyUnicode_Split PyUnicodeUCS4_Split -# define PyUnicode_Splitlines PyUnicodeUCS4_Splitlines -# define PyUnicode_Tailmatch PyUnicodeUCS4_Tailmatch -# define PyUnicode_Translate PyUnicodeUCS4_Translate -# define PyUnicode_TranslateCharmap PyUnicodeUCS4_TranslateCharmap -# define _PyUnicode_AsDefaultEncodedString _PyUnicodeUCS4_AsDefaultEncodedString -# define _PyUnicode_Fini _PyUnicodeUCS4_Fini -# define _PyUnicode_Init _PyUnicodeUCS4_Init -# define _PyUnicode_IsAlpha _PyUnicodeUCS4_IsAlpha -# define _PyUnicode_IsDecimalDigit _PyUnicodeUCS4_IsDecimalDigit -# define _PyUnicode_IsDigit _PyUnicodeUCS4_IsDigit -# define _PyUnicode_IsLinebreak _PyUnicodeUCS4_IsLinebreak -# define _PyUnicode_IsLowercase _PyUnicodeUCS4_IsLowercase -# define _PyUnicode_IsNumeric _PyUnicodeUCS4_IsNumeric -# define _PyUnicode_IsTitlecase _PyUnicodeUCS4_IsTitlecase -# define _PyUnicode_IsUppercase _PyUnicodeUCS4_IsUppercase -# define _PyUnicode_IsWhitespace _PyUnicodeUCS4_IsWhitespace -# define _PyUnicode_ToDecimalDigit _PyUnicodeUCS4_ToDecimalDigit -# define _PyUnicode_ToDigit _PyUnicodeUCS4_ToDigit -# define _PyUnicode_ToLowercase _PyUnicodeUCS4_ToLowercase -# define _PyUnicode_ToNumeric _PyUnicodeUCS4_ToNumeric -# define _PyUnicode_ToTitlecase _PyUnicodeUCS4_ToTitlecase -# define _PyUnicode_ToUppercase _PyUnicodeUCS4_ToUppercase - - -#endif - -/* --- Internal Unicode Operations ---------------------------------------- */ - -/* If you want Python to use the compiler's wctype.h functions instead - of the ones supplied with Python, define WANT_WCTYPE_FUNCTIONS or - configure Python using --with-wctype-functions. This reduces the - interpreter's code size. */ - -#if defined(HAVE_USABLE_WCHAR_T) && defined(WANT_WCTYPE_FUNCTIONS) - -#include - -#define Py_UNICODE_ISSPACE(ch) iswspace(ch) - -#define Py_UNICODE_ISLOWER(ch) iswlower(ch) -#define Py_UNICODE_ISUPPER(ch) iswupper(ch) -#define Py_UNICODE_ISTITLE(ch) _PyUnicode_IsTitlecase(ch) -#define Py_UNICODE_ISLINEBREAK(ch) _PyUnicode_IsLinebreak(ch) - -#define Py_UNICODE_TOLOWER(ch) towlower(ch) -#define Py_UNICODE_TOUPPER(ch) towupper(ch) -#define Py_UNICODE_TOTITLE(ch) _PyUnicode_ToTitlecase(ch) - -#define Py_UNICODE_ISDECIMAL(ch) _PyUnicode_IsDecimalDigit(ch) -#define Py_UNICODE_ISDIGIT(ch) _PyUnicode_IsDigit(ch) -#define Py_UNICODE_ISNUMERIC(ch) _PyUnicode_IsNumeric(ch) - -#define Py_UNICODE_TODECIMAL(ch) _PyUnicode_ToDecimalDigit(ch) -#define Py_UNICODE_TODIGIT(ch) _PyUnicode_ToDigit(ch) -#define Py_UNICODE_TONUMERIC(ch) _PyUnicode_ToNumeric(ch) - -#define Py_UNICODE_ISALPHA(ch) iswalpha(ch) - -#else - -/* Since splitting on whitespace is an important use case, and - whitespace in most situations is solely ASCII whitespace, we - optimize for the common case by using a quick look-up table - _Py_ascii_whitespace (see below) with an inlined check. - - */ -#define Py_UNICODE_ISSPACE(ch) \ - ((ch) < 128U ? _Py_ascii_whitespace[(ch)] : _PyUnicode_IsWhitespace(ch)) - -#define Py_UNICODE_ISLOWER(ch) _PyUnicode_IsLowercase(ch) -#define Py_UNICODE_ISUPPER(ch) _PyUnicode_IsUppercase(ch) -#define Py_UNICODE_ISTITLE(ch) _PyUnicode_IsTitlecase(ch) -#define Py_UNICODE_ISLINEBREAK(ch) _PyUnicode_IsLinebreak(ch) - -#define Py_UNICODE_TOLOWER(ch) _PyUnicode_ToLowercase(ch) -#define Py_UNICODE_TOUPPER(ch) _PyUnicode_ToUppercase(ch) -#define Py_UNICODE_TOTITLE(ch) _PyUnicode_ToTitlecase(ch) - -#define Py_UNICODE_ISDECIMAL(ch) _PyUnicode_IsDecimalDigit(ch) -#define Py_UNICODE_ISDIGIT(ch) _PyUnicode_IsDigit(ch) -#define Py_UNICODE_ISNUMERIC(ch) _PyUnicode_IsNumeric(ch) - -#define Py_UNICODE_TODECIMAL(ch) _PyUnicode_ToDecimalDigit(ch) -#define Py_UNICODE_TODIGIT(ch) _PyUnicode_ToDigit(ch) -#define Py_UNICODE_TONUMERIC(ch) _PyUnicode_ToNumeric(ch) - -#define Py_UNICODE_ISALPHA(ch) _PyUnicode_IsAlpha(ch) - -#endif - -#define Py_UNICODE_ISALNUM(ch) \ - (Py_UNICODE_ISALPHA(ch) || \ - Py_UNICODE_ISDECIMAL(ch) || \ - Py_UNICODE_ISDIGIT(ch) || \ - Py_UNICODE_ISNUMERIC(ch)) - -#define Py_UNICODE_COPY(target, source, length) \ - Py_MEMCPY((target), (source), (length)*sizeof(Py_UNICODE)) - -#define Py_UNICODE_FILL(target, value, length) \ - do {Py_ssize_t i_; Py_UNICODE *t_ = (target); Py_UNICODE v_ = (value);\ - for (i_ = 0; i_ < (length); i_++) t_[i_] = v_;\ - } while (0) - -/* Check if substring matches at given offset. the offset must be - valid, and the substring must not be empty */ - -#define Py_UNICODE_MATCH(string, offset, substring) \ - ((*((string)->str + (offset)) == *((substring)->str)) && \ - ((*((string)->str + (offset) + (substring)->length-1) == *((substring)->str + (substring)->length-1))) && \ - !memcmp((string)->str + (offset), (substring)->str, (substring)->length*sizeof(Py_UNICODE))) - -#ifdef __cplusplus -extern "C" { -#endif - -/* --- Unicode Type ------------------------------------------------------- */ - -typedef struct { - PyObject_HEAD - Py_ssize_t length; /* Length of raw Unicode data in buffer */ - Py_UNICODE *str; /* Raw Unicode buffer */ - long hash; /* Hash value; -1 if not set */ - PyObject *defenc; /* (Default) Encoded version as Python - string, or NULL; this is used for - implementing the buffer protocol */ -} PyUnicodeObject; - -PyAPI_DATA(PyTypeObject) PyUnicode_Type; - -#define PyUnicode_Check(op) \ - PyType_FastSubclass(Py_TYPE(op), Py_TPFLAGS_UNICODE_SUBCLASS) -#define PyUnicode_CheckExact(op) (Py_TYPE(op) == &PyUnicode_Type) - -/* Fast access macros */ -#define PyUnicode_GET_SIZE(op) \ - (((PyUnicodeObject *)(op))->length) -#define PyUnicode_GET_DATA_SIZE(op) \ - (((PyUnicodeObject *)(op))->length * sizeof(Py_UNICODE)) -#define PyUnicode_AS_UNICODE(op) \ - (((PyUnicodeObject *)(op))->str) -#define PyUnicode_AS_DATA(op) \ - ((const char *)((PyUnicodeObject *)(op))->str) - -/* --- Constants ---------------------------------------------------------- */ - -/* This Unicode character will be used as replacement character during - decoding if the errors argument is set to "replace". Note: the - Unicode character U+FFFD is the official REPLACEMENT CHARACTER in - Unicode 3.0. */ - -#define Py_UNICODE_REPLACEMENT_CHARACTER ((Py_UNICODE) 0xFFFD) - -/* === Public API ========================================================= */ - -/* --- Plain Py_UNICODE --------------------------------------------------- */ - -/* Create a Unicode Object from the Py_UNICODE buffer u of the given - size. - - u may be NULL which causes the contents to be undefined. It is the - user's responsibility to fill in the needed data afterwards. Note - that modifying the Unicode object contents after construction is - only allowed if u was set to NULL. - - The buffer is copied into the new object. */ - -PyAPI_FUNC(PyObject*) PyUnicode_FromUnicode( - const Py_UNICODE *u, /* Unicode buffer */ - Py_ssize_t size /* size of buffer */ - ); - -/* Similar to PyUnicode_FromUnicode(), but u points to Latin-1 encoded bytes */ -PyAPI_FUNC(PyObject*) PyUnicode_FromStringAndSize( - const char *u, /* char buffer */ - Py_ssize_t size /* size of buffer */ - ); - -/* Similar to PyUnicode_FromUnicode(), but u points to null-terminated - Latin-1 encoded bytes */ -PyAPI_FUNC(PyObject*) PyUnicode_FromString( - const char *u /* string */ - ); - -/* Return a read-only pointer to the Unicode object's internal - Py_UNICODE buffer. */ - -PyAPI_FUNC(Py_UNICODE *) PyUnicode_AsUnicode( - PyObject *unicode /* Unicode object */ - ); - -/* Get the length of the Unicode object. */ - -PyAPI_FUNC(Py_ssize_t) PyUnicode_GetSize( - PyObject *unicode /* Unicode object */ - ); - -/* Get the maximum ordinal for a Unicode character. */ -PyAPI_FUNC(Py_UNICODE) PyUnicode_GetMax(void); - -/* Resize an already allocated Unicode object to the new size length. - - *unicode is modified to point to the new (resized) object and 0 - returned on success. - - This API may only be called by the function which also called the - Unicode constructor. The refcount on the object must be 1. Otherwise, - an error is returned. - - Error handling is implemented as follows: an exception is set, -1 - is returned and *unicode left untouched. - -*/ - -PyAPI_FUNC(int) PyUnicode_Resize( - PyObject **unicode, /* Pointer to the Unicode object */ - Py_ssize_t length /* New length */ - ); - -/* Coerce obj to an Unicode object and return a reference with - *incremented* refcount. - - Coercion is done in the following way: - - 1. String and other char buffer compatible objects are decoded - under the assumptions that they contain data using the current - default encoding. Decoding is done in "strict" mode. - - 2. All other objects (including Unicode objects) raise an - exception. - - The API returns NULL in case of an error. The caller is responsible - for decref'ing the returned objects. - -*/ - -PyAPI_FUNC(PyObject*) PyUnicode_FromEncodedObject( - register PyObject *obj, /* Object */ - const char *encoding, /* encoding */ - const char *errors /* error handling */ - ); - -/* Coerce obj to an Unicode object and return a reference with - *incremented* refcount. - - Unicode objects are passed back as-is (subclasses are converted to - true Unicode objects), all other objects are delegated to - PyUnicode_FromEncodedObject(obj, NULL, "strict") which results in - using the default encoding as basis for decoding the object. - - The API returns NULL in case of an error. The caller is responsible - for decref'ing the returned objects. - -*/ - -PyAPI_FUNC(PyObject*) PyUnicode_FromObject( - register PyObject *obj /* Object */ - ); - -PyAPI_FUNC(PyObject *) PyUnicode_FromFormatV(const char*, va_list); -PyAPI_FUNC(PyObject *) PyUnicode_FromFormat(const char*, ...); - -/* Format the object based on the format_spec, as defined in PEP 3101 - (Advanced String Formatting). */ -PyAPI_FUNC(PyObject *) _PyUnicode_FormatAdvanced(PyObject *obj, - Py_UNICODE *format_spec, - Py_ssize_t format_spec_len); - -/* --- wchar_t support for platforms which support it --------------------- */ - -#ifdef HAVE_WCHAR_H - -/* Create a Unicode Object from the whcar_t buffer w of the given - size. - - The buffer is copied into the new object. */ - -PyAPI_FUNC(PyObject*) PyUnicode_FromWideChar( - register const wchar_t *w, /* wchar_t buffer */ - Py_ssize_t size /* size of buffer */ - ); - -/* Copies the Unicode Object contents into the wchar_t buffer w. At - most size wchar_t characters are copied. - - Note that the resulting wchar_t string may or may not be - 0-terminated. It is the responsibility of the caller to make sure - that the wchar_t string is 0-terminated in case this is required by - the application. - - Returns the number of wchar_t characters copied (excluding a - possibly trailing 0-termination character) or -1 in case of an - error. */ - -PyAPI_FUNC(Py_ssize_t) PyUnicode_AsWideChar( - PyUnicodeObject *unicode, /* Unicode object */ - register wchar_t *w, /* wchar_t buffer */ - Py_ssize_t size /* size of buffer */ - ); - -#endif - -/* --- Unicode ordinals --------------------------------------------------- */ - -/* Create a Unicode Object from the given Unicode code point ordinal. - - The ordinal must be in range(0x10000) on narrow Python builds - (UCS2), and range(0x110000) on wide builds (UCS4). A ValueError is - raised in case it is not. - -*/ - -PyAPI_FUNC(PyObject*) PyUnicode_FromOrdinal(int ordinal); - -/* --- Free-list management ----------------------------------------------- */ - -/* Clear the free list used by the Unicode implementation. - - This can be used to release memory used for objects on the free - list back to the Python memory allocator. - -*/ - -PyAPI_FUNC(int) PyUnicode_ClearFreeList(void); - -/* === Builtin Codecs ===================================================== - - Many of these APIs take two arguments encoding and errors. These - parameters encoding and errors have the same semantics as the ones - of the builtin unicode() API. - - Setting encoding to NULL causes the default encoding to be used. - - Error handling is set by errors which may also be set to NULL - meaning to use the default handling defined for the codec. Default - error handling for all builtin codecs is "strict" (ValueErrors are - raised). - - The codecs all use a similar interface. Only deviation from the - generic ones are documented. - -*/ - -/* --- Manage the default encoding ---------------------------------------- */ - -/* Return a Python string holding the default encoded value of the - Unicode object. - - The resulting string is cached in the Unicode object for subsequent - usage by this function. The cached version is needed to implement - the character buffer interface and will live (at least) as long as - the Unicode object itself. - - The refcount of the string is *not* incremented. - - *** Exported for internal use by the interpreter only !!! *** - -*/ - -PyAPI_FUNC(PyObject *) _PyUnicode_AsDefaultEncodedString( - PyObject *, const char *); - -/* Returns the currently active default encoding. - - The default encoding is currently implemented as run-time settable - process global. This may change in future versions of the - interpreter to become a parameter which is managed on a per-thread - basis. - - */ - -PyAPI_FUNC(const char*) PyUnicode_GetDefaultEncoding(void); - -/* Sets the currently active default encoding. - - Returns 0 on success, -1 in case of an error. - - */ - -PyAPI_FUNC(int) PyUnicode_SetDefaultEncoding( - const char *encoding /* Encoding name in standard form */ - ); - -/* --- Generic Codecs ----------------------------------------------------- */ - -/* Create a Unicode object by decoding the encoded string s of the - given size. */ - -PyAPI_FUNC(PyObject*) PyUnicode_Decode( - const char *s, /* encoded string */ - Py_ssize_t size, /* size of buffer */ - const char *encoding, /* encoding */ - const char *errors /* error handling */ - ); - -/* Encodes a Py_UNICODE buffer of the given size and returns a - Python string object. */ - -PyAPI_FUNC(PyObject*) PyUnicode_Encode( - const Py_UNICODE *s, /* Unicode char buffer */ - Py_ssize_t size, /* number of Py_UNICODE chars to encode */ - const char *encoding, /* encoding */ - const char *errors /* error handling */ - ); - -/* Encodes a Unicode object and returns the result as Python - object. */ - -PyAPI_FUNC(PyObject*) PyUnicode_AsEncodedObject( - PyObject *unicode, /* Unicode object */ - const char *encoding, /* encoding */ - const char *errors /* error handling */ - ); - -/* Encodes a Unicode object and returns the result as Python string - object. */ - -PyAPI_FUNC(PyObject*) PyUnicode_AsEncodedString( - PyObject *unicode, /* Unicode object */ - const char *encoding, /* encoding */ - const char *errors /* error handling */ - ); - -PyAPI_FUNC(PyObject*) PyUnicode_BuildEncodingMap( - PyObject* string /* 256 character map */ - ); - - -/* --- UTF-7 Codecs ------------------------------------------------------- */ - -PyAPI_FUNC(PyObject*) PyUnicode_DecodeUTF7( - const char *string, /* UTF-7 encoded string */ - Py_ssize_t length, /* size of string */ - const char *errors /* error handling */ - ); - -PyAPI_FUNC(PyObject*) PyUnicode_DecodeUTF7Stateful( - const char *string, /* UTF-7 encoded string */ - Py_ssize_t length, /* size of string */ - const char *errors, /* error handling */ - Py_ssize_t *consumed /* bytes consumed */ - ); - -PyAPI_FUNC(PyObject*) PyUnicode_EncodeUTF7( - const Py_UNICODE *data, /* Unicode char buffer */ - Py_ssize_t length, /* number of Py_UNICODE chars to encode */ - int base64SetO, /* Encode RFC2152 Set O characters in base64 */ - int base64WhiteSpace, /* Encode whitespace (sp, ht, nl, cr) in base64 */ - const char *errors /* error handling */ - ); - -/* --- UTF-8 Codecs ------------------------------------------------------- */ - -PyAPI_FUNC(PyObject*) PyUnicode_DecodeUTF8( - const char *string, /* UTF-8 encoded string */ - Py_ssize_t length, /* size of string */ - const char *errors /* error handling */ - ); - -PyAPI_FUNC(PyObject*) PyUnicode_DecodeUTF8Stateful( - const char *string, /* UTF-8 encoded string */ - Py_ssize_t length, /* size of string */ - const char *errors, /* error handling */ - Py_ssize_t *consumed /* bytes consumed */ - ); - -PyAPI_FUNC(PyObject*) PyUnicode_AsUTF8String( - PyObject *unicode /* Unicode object */ - ); - -PyAPI_FUNC(PyObject*) PyUnicode_EncodeUTF8( - const Py_UNICODE *data, /* Unicode char buffer */ - Py_ssize_t length, /* number of Py_UNICODE chars to encode */ - const char *errors /* error handling */ - ); - -/* --- UTF-32 Codecs ------------------------------------------------------ */ - -/* Decodes length bytes from a UTF-32 encoded buffer string and returns - the corresponding Unicode object. - - errors (if non-NULL) defines the error handling. It defaults - to "strict". - - If byteorder is non-NULL, the decoder starts decoding using the - given byte order: - - *byteorder == -1: little endian - *byteorder == 0: native order - *byteorder == 1: big endian - - In native mode, the first four bytes of the stream are checked for a - BOM mark. If found, the BOM mark is analysed, the byte order - adjusted and the BOM skipped. In the other modes, no BOM mark - interpretation is done. After completion, *byteorder is set to the - current byte order at the end of input data. - - If byteorder is NULL, the codec starts in native order mode. - -*/ - -PyAPI_FUNC(PyObject*) PyUnicode_DecodeUTF32( - const char *string, /* UTF-32 encoded string */ - Py_ssize_t length, /* size of string */ - const char *errors, /* error handling */ - int *byteorder /* pointer to byteorder to use - 0=native;-1=LE,1=BE; updated on - exit */ - ); - -PyAPI_FUNC(PyObject*) PyUnicode_DecodeUTF32Stateful( - const char *string, /* UTF-32 encoded string */ - Py_ssize_t length, /* size of string */ - const char *errors, /* error handling */ - int *byteorder, /* pointer to byteorder to use - 0=native;-1=LE,1=BE; updated on - exit */ - Py_ssize_t *consumed /* bytes consumed */ - ); - -/* Returns a Python string using the UTF-32 encoding in native byte - order. The string always starts with a BOM mark. */ - -PyAPI_FUNC(PyObject*) PyUnicode_AsUTF32String( - PyObject *unicode /* Unicode object */ - ); - -/* Returns a Python string object holding the UTF-32 encoded value of - the Unicode data. - - If byteorder is not 0, output is written according to the following - byte order: - - byteorder == -1: little endian - byteorder == 0: native byte order (writes a BOM mark) - byteorder == 1: big endian - - If byteorder is 0, the output string will always start with the - Unicode BOM mark (U+FEFF). In the other two modes, no BOM mark is - prepended. - -*/ - -PyAPI_FUNC(PyObject*) PyUnicode_EncodeUTF32( - const Py_UNICODE *data, /* Unicode char buffer */ - Py_ssize_t length, /* number of Py_UNICODE chars to encode */ - const char *errors, /* error handling */ - int byteorder /* byteorder to use 0=BOM+native;-1=LE,1=BE */ - ); - -/* --- UTF-16 Codecs ------------------------------------------------------ */ - -/* Decodes length bytes from a UTF-16 encoded buffer string and returns - the corresponding Unicode object. - - errors (if non-NULL) defines the error handling. It defaults - to "strict". - - If byteorder is non-NULL, the decoder starts decoding using the - given byte order: - - *byteorder == -1: little endian - *byteorder == 0: native order - *byteorder == 1: big endian - - In native mode, the first two bytes of the stream are checked for a - BOM mark. If found, the BOM mark is analysed, the byte order - adjusted and the BOM skipped. In the other modes, no BOM mark - interpretation is done. After completion, *byteorder is set to the - current byte order at the end of input data. - - If byteorder is NULL, the codec starts in native order mode. - -*/ - -PyAPI_FUNC(PyObject*) PyUnicode_DecodeUTF16( - const char *string, /* UTF-16 encoded string */ - Py_ssize_t length, /* size of string */ - const char *errors, /* error handling */ - int *byteorder /* pointer to byteorder to use - 0=native;-1=LE,1=BE; updated on - exit */ - ); - -PyAPI_FUNC(PyObject*) PyUnicode_DecodeUTF16Stateful( - const char *string, /* UTF-16 encoded string */ - Py_ssize_t length, /* size of string */ - const char *errors, /* error handling */ - int *byteorder, /* pointer to byteorder to use - 0=native;-1=LE,1=BE; updated on - exit */ - Py_ssize_t *consumed /* bytes consumed */ - ); - -/* Returns a Python string using the UTF-16 encoding in native byte - order. The string always starts with a BOM mark. */ - -PyAPI_FUNC(PyObject*) PyUnicode_AsUTF16String( - PyObject *unicode /* Unicode object */ - ); - -/* Returns a Python string object holding the UTF-16 encoded value of - the Unicode data. - - If byteorder is not 0, output is written according to the following - byte order: - - byteorder == -1: little endian - byteorder == 0: native byte order (writes a BOM mark) - byteorder == 1: big endian - - If byteorder is 0, the output string will always start with the - Unicode BOM mark (U+FEFF). In the other two modes, no BOM mark is - prepended. - - Note that Py_UNICODE data is being interpreted as UTF-16 reduced to - UCS-2. This trick makes it possible to add full UTF-16 capabilities - at a later point without compromising the APIs. - -*/ - -PyAPI_FUNC(PyObject*) PyUnicode_EncodeUTF16( - const Py_UNICODE *data, /* Unicode char buffer */ - Py_ssize_t length, /* number of Py_UNICODE chars to encode */ - const char *errors, /* error handling */ - int byteorder /* byteorder to use 0=BOM+native;-1=LE,1=BE */ - ); - -/* --- Unicode-Escape Codecs ---------------------------------------------- */ - -PyAPI_FUNC(PyObject*) PyUnicode_DecodeUnicodeEscape( - const char *string, /* Unicode-Escape encoded string */ - Py_ssize_t length, /* size of string */ - const char *errors /* error handling */ - ); - -PyAPI_FUNC(PyObject*) PyUnicode_AsUnicodeEscapeString( - PyObject *unicode /* Unicode object */ - ); - -PyAPI_FUNC(PyObject*) PyUnicode_EncodeUnicodeEscape( - const Py_UNICODE *data, /* Unicode char buffer */ - Py_ssize_t length /* Number of Py_UNICODE chars to encode */ - ); - -/* --- Raw-Unicode-Escape Codecs ------------------------------------------ */ - -PyAPI_FUNC(PyObject*) PyUnicode_DecodeRawUnicodeEscape( - const char *string, /* Raw-Unicode-Escape encoded string */ - Py_ssize_t length, /* size of string */ - const char *errors /* error handling */ - ); - -PyAPI_FUNC(PyObject*) PyUnicode_AsRawUnicodeEscapeString( - PyObject *unicode /* Unicode object */ - ); - -PyAPI_FUNC(PyObject*) PyUnicode_EncodeRawUnicodeEscape( - const Py_UNICODE *data, /* Unicode char buffer */ - Py_ssize_t length /* Number of Py_UNICODE chars to encode */ - ); - -/* --- Unicode Internal Codec --------------------------------------------- - - Only for internal use in _codecsmodule.c */ - -PyObject *_PyUnicode_DecodeUnicodeInternal( - const char *string, - Py_ssize_t length, - const char *errors - ); - -/* --- Latin-1 Codecs ----------------------------------------------------- - - Note: Latin-1 corresponds to the first 256 Unicode ordinals. - -*/ - -PyAPI_FUNC(PyObject*) PyUnicode_DecodeLatin1( - const char *string, /* Latin-1 encoded string */ - Py_ssize_t length, /* size of string */ - const char *errors /* error handling */ - ); - -PyAPI_FUNC(PyObject*) PyUnicode_AsLatin1String( - PyObject *unicode /* Unicode object */ - ); - -PyAPI_FUNC(PyObject*) PyUnicode_EncodeLatin1( - const Py_UNICODE *data, /* Unicode char buffer */ - Py_ssize_t length, /* Number of Py_UNICODE chars to encode */ - const char *errors /* error handling */ - ); - -/* --- ASCII Codecs ------------------------------------------------------- - - Only 7-bit ASCII data is excepted. All other codes generate errors. - -*/ - -PyAPI_FUNC(PyObject*) PyUnicode_DecodeASCII( - const char *string, /* ASCII encoded string */ - Py_ssize_t length, /* size of string */ - const char *errors /* error handling */ - ); - -PyAPI_FUNC(PyObject*) PyUnicode_AsASCIIString( - PyObject *unicode /* Unicode object */ - ); - -PyAPI_FUNC(PyObject*) PyUnicode_EncodeASCII( - const Py_UNICODE *data, /* Unicode char buffer */ - Py_ssize_t length, /* Number of Py_UNICODE chars to encode */ - const char *errors /* error handling */ - ); - -/* --- Character Map Codecs ----------------------------------------------- - - This codec uses mappings to encode and decode characters. - - Decoding mappings must map single string characters to single - Unicode characters, integers (which are then interpreted as Unicode - ordinals) or None (meaning "undefined mapping" and causing an - error). - - Encoding mappings must map single Unicode characters to single - string characters, integers (which are then interpreted as Latin-1 - ordinals) or None (meaning "undefined mapping" and causing an - error). - - If a character lookup fails with a LookupError, the character is - copied as-is meaning that its ordinal value will be interpreted as - Unicode or Latin-1 ordinal resp. Because of this mappings only need - to contain those mappings which map characters to different code - points. - -*/ - -PyAPI_FUNC(PyObject*) PyUnicode_DecodeCharmap( - const char *string, /* Encoded string */ - Py_ssize_t length, /* size of string */ - PyObject *mapping, /* character mapping - (char ordinal -> unicode ordinal) */ - const char *errors /* error handling */ - ); - -PyAPI_FUNC(PyObject*) PyUnicode_AsCharmapString( - PyObject *unicode, /* Unicode object */ - PyObject *mapping /* character mapping - (unicode ordinal -> char ordinal) */ - ); - -PyAPI_FUNC(PyObject*) PyUnicode_EncodeCharmap( - const Py_UNICODE *data, /* Unicode char buffer */ - Py_ssize_t length, /* Number of Py_UNICODE chars to encode */ - PyObject *mapping, /* character mapping - (unicode ordinal -> char ordinal) */ - const char *errors /* error handling */ - ); - -/* Translate a Py_UNICODE buffer of the given length by applying a - character mapping table to it and return the resulting Unicode - object. - - The mapping table must map Unicode ordinal integers to Unicode - ordinal integers or None (causing deletion of the character). - - Mapping tables may be dictionaries or sequences. Unmapped character - ordinals (ones which cause a LookupError) are left untouched and - are copied as-is. - -*/ - -PyAPI_FUNC(PyObject *) PyUnicode_TranslateCharmap( - const Py_UNICODE *data, /* Unicode char buffer */ - Py_ssize_t length, /* Number of Py_UNICODE chars to encode */ - PyObject *table, /* Translate table */ - const char *errors /* error handling */ - ); - -#ifdef MS_WIN32 - -/* --- MBCS codecs for Windows -------------------------------------------- */ - -PyAPI_FUNC(PyObject*) PyUnicode_DecodeMBCS( - const char *string, /* MBCS encoded string */ - Py_ssize_t length, /* size of string */ - const char *errors /* error handling */ - ); - -PyAPI_FUNC(PyObject*) PyUnicode_DecodeMBCSStateful( - const char *string, /* MBCS encoded string */ - Py_ssize_t length, /* size of string */ - const char *errors, /* error handling */ - Py_ssize_t *consumed /* bytes consumed */ - ); - -PyAPI_FUNC(PyObject*) PyUnicode_AsMBCSString( - PyObject *unicode /* Unicode object */ - ); - -PyAPI_FUNC(PyObject*) PyUnicode_EncodeMBCS( - const Py_UNICODE *data, /* Unicode char buffer */ - Py_ssize_t length, /* Number of Py_UNICODE chars to encode */ - const char *errors /* error handling */ - ); - -#endif /* MS_WIN32 */ - -/* --- Decimal Encoder ---------------------------------------------------- */ - -/* Takes a Unicode string holding a decimal value and writes it into - an output buffer using standard ASCII digit codes. - - The output buffer has to provide at least length+1 bytes of storage - area. The output string is 0-terminated. - - The encoder converts whitespace to ' ', decimal characters to their - corresponding ASCII digit and all other Latin-1 characters except - \0 as-is. Characters outside this range (Unicode ordinals 1-256) - are treated as errors. This includes embedded NULL bytes. - - Error handling is defined by the errors argument: - - NULL or "strict": raise a ValueError - "ignore": ignore the wrong characters (these are not copied to the - output buffer) - "replace": replaces illegal characters with '?' - - Returns 0 on success, -1 on failure. - -*/ - -PyAPI_FUNC(int) PyUnicode_EncodeDecimal( - Py_UNICODE *s, /* Unicode buffer */ - Py_ssize_t length, /* Number of Py_UNICODE chars to encode */ - char *output, /* Output buffer; must have size >= length */ - const char *errors /* error handling */ - ); - -/* --- Methods & Slots ---------------------------------------------------- - - These are capable of handling Unicode objects and strings on input - (we refer to them as strings in the descriptions) and return - Unicode objects or integers as apporpriate. */ - -/* Concat two strings giving a new Unicode string. */ - -PyAPI_FUNC(PyObject*) PyUnicode_Concat( - PyObject *left, /* Left string */ - PyObject *right /* Right string */ - ); - -/* Split a string giving a list of Unicode strings. - - If sep is NULL, splitting will be done at all whitespace - substrings. Otherwise, splits occur at the given separator. - - At most maxsplit splits will be done. If negative, no limit is set. - - Separators are not included in the resulting list. - -*/ - -PyAPI_FUNC(PyObject*) PyUnicode_Split( - PyObject *s, /* String to split */ - PyObject *sep, /* String separator */ - Py_ssize_t maxsplit /* Maxsplit count */ - ); - -/* Dito, but split at line breaks. - - CRLF is considered to be one line break. Line breaks are not - included in the resulting list. */ - -PyAPI_FUNC(PyObject*) PyUnicode_Splitlines( - PyObject *s, /* String to split */ - int keepends /* If true, line end markers are included */ - ); - -/* Partition a string using a given separator. */ - -PyAPI_FUNC(PyObject*) PyUnicode_Partition( - PyObject *s, /* String to partition */ - PyObject *sep /* String separator */ - ); - -/* Partition a string using a given separator, searching from the end of the - string. */ - -PyAPI_FUNC(PyObject*) PyUnicode_RPartition( - PyObject *s, /* String to partition */ - PyObject *sep /* String separator */ - ); - -/* Split a string giving a list of Unicode strings. - - If sep is NULL, splitting will be done at all whitespace - substrings. Otherwise, splits occur at the given separator. - - At most maxsplit splits will be done. But unlike PyUnicode_Split - PyUnicode_RSplit splits from the end of the string. If negative, - no limit is set. - - Separators are not included in the resulting list. - -*/ - -PyAPI_FUNC(PyObject*) PyUnicode_RSplit( - PyObject *s, /* String to split */ - PyObject *sep, /* String separator */ - Py_ssize_t maxsplit /* Maxsplit count */ - ); - -/* Translate a string by applying a character mapping table to it and - return the resulting Unicode object. - - The mapping table must map Unicode ordinal integers to Unicode - ordinal integers or None (causing deletion of the character). - - Mapping tables may be dictionaries or sequences. Unmapped character - ordinals (ones which cause a LookupError) are left untouched and - are copied as-is. - -*/ - -PyAPI_FUNC(PyObject *) PyUnicode_Translate( - PyObject *str, /* String */ - PyObject *table, /* Translate table */ - const char *errors /* error handling */ - ); - -/* Join a sequence of strings using the given separator and return - the resulting Unicode string. */ - -PyAPI_FUNC(PyObject*) PyUnicode_Join( - PyObject *separator, /* Separator string */ - PyObject *seq /* Sequence object */ - ); - -/* Return 1 if substr matches str[start:end] at the given tail end, 0 - otherwise. */ - -PyAPI_FUNC(Py_ssize_t) PyUnicode_Tailmatch( - PyObject *str, /* String */ - PyObject *substr, /* Prefix or Suffix string */ - Py_ssize_t start, /* Start index */ - Py_ssize_t end, /* Stop index */ - int direction /* Tail end: -1 prefix, +1 suffix */ - ); - -/* Return the first position of substr in str[start:end] using the - given search direction or -1 if not found. -2 is returned in case - an error occurred and an exception is set. */ - -PyAPI_FUNC(Py_ssize_t) PyUnicode_Find( - PyObject *str, /* String */ - PyObject *substr, /* Substring to find */ - Py_ssize_t start, /* Start index */ - Py_ssize_t end, /* Stop index */ - int direction /* Find direction: +1 forward, -1 backward */ - ); - -/* Count the number of occurrences of substr in str[start:end]. */ - -PyAPI_FUNC(Py_ssize_t) PyUnicode_Count( - PyObject *str, /* String */ - PyObject *substr, /* Substring to count */ - Py_ssize_t start, /* Start index */ - Py_ssize_t end /* Stop index */ - ); - -/* Replace at most maxcount occurrences of substr in str with replstr - and return the resulting Unicode object. */ - -PyAPI_FUNC(PyObject *) PyUnicode_Replace( - PyObject *str, /* String */ - PyObject *substr, /* Substring to find */ - PyObject *replstr, /* Substring to replace */ - Py_ssize_t maxcount /* Max. number of replacements to apply; - -1 = all */ - ); - -/* Compare two strings and return -1, 0, 1 for less than, equal, - greater than resp. */ - -PyAPI_FUNC(int) PyUnicode_Compare( - PyObject *left, /* Left string */ - PyObject *right /* Right string */ - ); - -/* Rich compare two strings and return one of the following: - - - NULL in case an exception was raised - - Py_True or Py_False for successfuly comparisons - - Py_NotImplemented in case the type combination is unknown - - Note that Py_EQ and Py_NE comparisons can cause a UnicodeWarning in - case the conversion of the arguments to Unicode fails with a - UnicodeDecodeError. - - Possible values for op: - - Py_GT, Py_GE, Py_EQ, Py_NE, Py_LT, Py_LE - -*/ - -PyAPI_FUNC(PyObject *) PyUnicode_RichCompare( - PyObject *left, /* Left string */ - PyObject *right, /* Right string */ - int op /* Operation: Py_EQ, Py_NE, Py_GT, etc. */ - ); - -/* Apply a argument tuple or dictionary to a format string and return - the resulting Unicode string. */ - -PyAPI_FUNC(PyObject *) PyUnicode_Format( - PyObject *format, /* Format string */ - PyObject *args /* Argument tuple or dictionary */ - ); - -/* Checks whether element is contained in container and return 1/0 - accordingly. - - element has to coerce to an one element Unicode string. -1 is - returned in case of an error. */ - -PyAPI_FUNC(int) PyUnicode_Contains( - PyObject *container, /* Container string */ - PyObject *element /* Element string */ - ); - -/* Externally visible for str.strip(unicode) */ -PyAPI_FUNC(PyObject *) _PyUnicode_XStrip( - PyUnicodeObject *self, - int striptype, - PyObject *sepobj - ); - -/* === Characters Type APIs =============================================== */ - -/* Helper array used by Py_UNICODE_ISSPACE(). */ - -PyAPI_DATA(const unsigned char) _Py_ascii_whitespace[]; - -/* These should not be used directly. Use the Py_UNICODE_IS* and - Py_UNICODE_TO* macros instead. - - These APIs are implemented in Objects/unicodectype.c. - -*/ - -PyAPI_FUNC(int) _PyUnicode_IsLowercase( - Py_UNICODE ch /* Unicode character */ - ); - -PyAPI_FUNC(int) _PyUnicode_IsUppercase( - Py_UNICODE ch /* Unicode character */ - ); - -PyAPI_FUNC(int) _PyUnicode_IsTitlecase( - Py_UNICODE ch /* Unicode character */ - ); - -PyAPI_FUNC(int) _PyUnicode_IsWhitespace( - const Py_UNICODE ch /* Unicode character */ - ); - -PyAPI_FUNC(int) _PyUnicode_IsLinebreak( - const Py_UNICODE ch /* Unicode character */ - ); - -PyAPI_FUNC(Py_UNICODE) _PyUnicode_ToLowercase( - Py_UNICODE ch /* Unicode character */ - ); - -PyAPI_FUNC(Py_UNICODE) _PyUnicode_ToUppercase( - Py_UNICODE ch /* Unicode character */ - ); - -PyAPI_FUNC(Py_UNICODE) _PyUnicode_ToTitlecase( - Py_UNICODE ch /* Unicode character */ - ); - -PyAPI_FUNC(int) _PyUnicode_ToDecimalDigit( - Py_UNICODE ch /* Unicode character */ - ); - -PyAPI_FUNC(int) _PyUnicode_ToDigit( - Py_UNICODE ch /* Unicode character */ - ); - -PyAPI_FUNC(double) _PyUnicode_ToNumeric( - Py_UNICODE ch /* Unicode character */ - ); - -PyAPI_FUNC(int) _PyUnicode_IsDecimalDigit( - Py_UNICODE ch /* Unicode character */ - ); - -PyAPI_FUNC(int) _PyUnicode_IsDigit( - Py_UNICODE ch /* Unicode character */ - ); - -PyAPI_FUNC(int) _PyUnicode_IsNumeric( - Py_UNICODE ch /* Unicode character */ - ); - -PyAPI_FUNC(int) _PyUnicode_IsAlpha( - Py_UNICODE ch /* Unicode character */ - ); - -#ifdef __cplusplus -} -#endif -#endif /* Py_USING_UNICODE */ -#endif /* !Py_UNICODEOBJECT_H */ diff --git a/python/include/warnings.h b/python/include/warnings.h deleted file mode 100644 index 0818d7a1..00000000 --- a/python/include/warnings.h +++ /dev/null @@ -1,23 +0,0 @@ -#ifndef Py_WARNINGS_H -#define Py_WARNINGS_H -#ifdef __cplusplus -extern "C" { -#endif - -PyAPI_FUNC(void) _PyWarnings_Init(void); - -PyAPI_FUNC(int) PyErr_WarnEx(PyObject *, const char *, Py_ssize_t); -PyAPI_FUNC(int) PyErr_WarnExplicit(PyObject *, const char *, const char *, int, - const char *, PyObject *); - -#define PyErr_WarnPy3k(msg, stacklevel) \ - (Py_Py3kWarningFlag ? PyErr_WarnEx(PyExc_DeprecationWarning, msg, stacklevel) : 0) - -/* DEPRECATED: Use PyErr_WarnEx() instead. */ -#define PyErr_Warn(category, msg) PyErr_WarnEx(category, msg, 1) - -#ifdef __cplusplus -} -#endif -#endif /* !Py_WARNINGS_H */ - diff --git a/python/include/weakrefobject.h b/python/include/weakrefobject.h deleted file mode 100644 index f15c9d9c..00000000 --- a/python/include/weakrefobject.h +++ /dev/null @@ -1,75 +0,0 @@ -/* Weak references objects for Python. */ - -#ifndef Py_WEAKREFOBJECT_H -#define Py_WEAKREFOBJECT_H -#ifdef __cplusplus -extern "C" { -#endif - - -typedef struct _PyWeakReference PyWeakReference; - -/* PyWeakReference is the base struct for the Python ReferenceType, ProxyType, - * and CallableProxyType. - */ -struct _PyWeakReference { - PyObject_HEAD - - /* The object to which this is a weak reference, or Py_None if none. - * Note that this is a stealth reference: wr_object's refcount is - * not incremented to reflect this pointer. - */ - PyObject *wr_object; - - /* A callable to invoke when wr_object dies, or NULL if none. */ - PyObject *wr_callback; - - /* A cache for wr_object's hash code. As usual for hashes, this is -1 - * if the hash code isn't known yet. - */ - long hash; - - /* If wr_object is weakly referenced, wr_object has a doubly-linked NULL- - * terminated list of weak references to it. These are the list pointers. - * If wr_object goes away, wr_object is set to Py_None, and these pointers - * have no meaning then. - */ - PyWeakReference *wr_prev; - PyWeakReference *wr_next; -}; - -PyAPI_DATA(PyTypeObject) _PyWeakref_RefType; -PyAPI_DATA(PyTypeObject) _PyWeakref_ProxyType; -PyAPI_DATA(PyTypeObject) _PyWeakref_CallableProxyType; - -#define PyWeakref_CheckRef(op) PyObject_TypeCheck(op, &_PyWeakref_RefType) -#define PyWeakref_CheckRefExact(op) \ - (Py_TYPE(op) == &_PyWeakref_RefType) -#define PyWeakref_CheckProxy(op) \ - ((Py_TYPE(op) == &_PyWeakref_ProxyType) || \ - (Py_TYPE(op) == &_PyWeakref_CallableProxyType)) - -/* This macro calls PyWeakref_CheckRef() last since that can involve a - function call; this makes it more likely that the function call - will be avoided. */ -#define PyWeakref_Check(op) \ - (PyWeakref_CheckRef(op) || PyWeakref_CheckProxy(op)) - - -PyAPI_FUNC(PyObject *) PyWeakref_NewRef(PyObject *ob, - PyObject *callback); -PyAPI_FUNC(PyObject *) PyWeakref_NewProxy(PyObject *ob, - PyObject *callback); -PyAPI_FUNC(PyObject *) PyWeakref_GetObject(PyObject *ref); - -PyAPI_FUNC(Py_ssize_t) _PyWeakref_GetWeakrefCount(PyWeakReference *head); - -PyAPI_FUNC(void) _PyWeakref_ClearRef(PyWeakReference *self); - -#define PyWeakref_GET_OBJECT(ref) (((PyWeakReference *)(ref))->wr_object) - - -#ifdef __cplusplus -} -#endif -#endif /* !Py_WEAKREFOBJECT_H */ diff --git a/python/libs/_bsddb.lib b/python/libs/_bsddb.lib deleted file mode 100644 index 9f840ed9..00000000 Binary files a/python/libs/_bsddb.lib and /dev/null differ diff --git a/python/libs/_ctypes.lib b/python/libs/_ctypes.lib deleted file mode 100644 index 7cc4d0fa..00000000 Binary files a/python/libs/_ctypes.lib and /dev/null differ diff --git a/python/libs/_ctypes_test.lib b/python/libs/_ctypes_test.lib deleted file mode 100644 index 2307e980..00000000 Binary files a/python/libs/_ctypes_test.lib and /dev/null differ diff --git a/python/libs/_elementtree.lib b/python/libs/_elementtree.lib deleted file mode 100644 index 4217b7ea..00000000 Binary files a/python/libs/_elementtree.lib and /dev/null differ diff --git a/python/libs/_hashlib.lib b/python/libs/_hashlib.lib deleted file mode 100644 index 2fee578f..00000000 Binary files a/python/libs/_hashlib.lib and /dev/null differ diff --git a/python/libs/_msi.lib b/python/libs/_msi.lib deleted file mode 100644 index ca2b30f6..00000000 Binary files a/python/libs/_msi.lib and /dev/null differ diff --git a/python/libs/_multiprocessing.lib b/python/libs/_multiprocessing.lib deleted file mode 100644 index 4fc78275..00000000 Binary files a/python/libs/_multiprocessing.lib and /dev/null differ diff --git a/python/libs/_socket.lib b/python/libs/_socket.lib deleted file mode 100644 index f795f147..00000000 Binary files a/python/libs/_socket.lib and /dev/null differ diff --git a/python/libs/_sqlite3.lib b/python/libs/_sqlite3.lib deleted file mode 100644 index 2b47f451..00000000 Binary files a/python/libs/_sqlite3.lib and /dev/null differ diff --git a/python/libs/_ssl.lib b/python/libs/_ssl.lib deleted file mode 100644 index 176c166f..00000000 Binary files a/python/libs/_ssl.lib and /dev/null differ diff --git a/python/libs/_testcapi.lib b/python/libs/_testcapi.lib deleted file mode 100644 index ae59b094..00000000 Binary files a/python/libs/_testcapi.lib and /dev/null differ diff --git a/python/libs/_tkinter.lib b/python/libs/_tkinter.lib deleted file mode 100644 index 6d8865d5..00000000 Binary files a/python/libs/_tkinter.lib and /dev/null differ diff --git a/python/libs/bz2.lib b/python/libs/bz2.lib deleted file mode 100644 index 4214d1f8..00000000 Binary files a/python/libs/bz2.lib and /dev/null differ diff --git a/python/libs/omf_python27.lib b/python/libs/omf_python27.lib deleted file mode 100644 index a239e707..00000000 Binary files a/python/libs/omf_python27.lib and /dev/null differ diff --git a/python/libs/pyexpat.lib b/python/libs/pyexpat.lib deleted file mode 100644 index 9e65bc87..00000000 Binary files a/python/libs/pyexpat.lib and /dev/null differ diff --git a/python/libs/python27.lib b/python/libs/python27.lib deleted file mode 100644 index 94542ea1..00000000 Binary files a/python/libs/python27.lib and /dev/null differ diff --git a/python/libs/select.lib b/python/libs/select.lib deleted file mode 100644 index 7df0fb69..00000000 Binary files a/python/libs/select.lib and /dev/null differ diff --git a/python/libs/unicodedata.lib b/python/libs/unicodedata.lib deleted file mode 100644 index d6e6f64a..00000000 Binary files a/python/libs/unicodedata.lib and /dev/null differ diff --git a/python/libs/winsound.lib b/python/libs/winsound.lib deleted file mode 100644 index efa8af83..00000000 Binary files a/python/libs/winsound.lib and /dev/null differ diff --git a/python_var_doc.md b/python_var_doc.md new file mode 100644 index 00000000..2f24dcbb --- /dev/null +++ b/python_var_doc.md @@ -0,0 +1,17 @@ +| nazwa | typ |opis | +|------------------------|-------|------------------------------------------------------------| +| direction | int | kiernek jazdy (-1: do tyu, 0: aden, 1: do przodu) | +| slipping_wheels | bool | polizg | +| converter | bool | dziaanie przetwornicy | +| main_ctrl_actual_pos | int | numer pozycji nastawnika (wskanik RList) | +| scnd_ctrl_actual_pos | int | numer pozycji bocznika (wskanik MotorParam) | +| fuse | bool | wycznik szybki (bezpiecznik nadmiarowy) | +| converter_overload | bool | wycznik nadmiarowy przetwornicy i ogrzewania | +| voltage | float | napicie w sieci | +| velocity | float | aktualna prdko | +| im | float | prd silnika | +| compress | bool | dziaanie sprarki | +| hours | int | aktualny czas | +| minutes | int | aktualny czas | +| seconds | int | aktualny czas | +| velocity_desired | float | prdkos zadana | diff --git a/renderer.cpp b/renderer.cpp new file mode 100644 index 00000000..f8f81058 --- /dev/null +++ b/renderer.cpp @@ -0,0 +1,4027 @@ +/* +This Source Code Form is subject to the +terms of the Mozilla Public License, v. +2.0. If a copy of the MPL was not +distributed with this file, You can +obtain one at +http://mozilla.org/MPL/2.0/. +*/ + +#include "stdafx.h" + +#include "renderer.h" +#include "color.h" +#include "globals.h" +#include "camera.h" +#include "timer.h" +#include "simulation.h" +#include "simulationtime.h" +#include "train.h" +#include "dynobj.h" +#include "animmodel.h" +#include "traction.h" +#include "application.h" +#include "logs.h" +#include "utilities.h" + +opengl_renderer GfxRenderer; + +int const EU07_PICKBUFFERSIZE { 1024 }; // size of (square) textures bound with the pick framebuffer +int const EU07_ENVIRONMENTBUFFERSIZE { 256 }; // size of (square) environmental cube map texture + +void +opengl_light::apply_intensity( float const Factor ) { + + if( Factor == 1.0 ) { + + ::glLightfv( id, GL_AMBIENT, glm::value_ptr( ambient ) ); + ::glLightfv( id, GL_DIFFUSE, glm::value_ptr( diffuse ) ); + ::glLightfv( id, GL_SPECULAR, glm::value_ptr( specular ) ); + } + else { + // temporary light scaling mechanics (ultimately this work will be left to the shaders + glm::vec4 scaledambient( ambient.r * Factor, ambient.g * Factor, ambient.b * Factor, ambient.a ); + glm::vec4 scaleddiffuse( diffuse.r * Factor, diffuse.g * Factor, diffuse.b * Factor, diffuse.a ); + glm::vec4 scaledspecular( specular.r * Factor, specular.g * Factor, specular.b * Factor, specular.a ); + glLightfv( id, GL_AMBIENT, glm::value_ptr( scaledambient ) ); + glLightfv( id, GL_DIFFUSE, glm::value_ptr( scaleddiffuse ) ); + glLightfv( id, GL_SPECULAR, glm::value_ptr( scaledspecular ) ); + } +} + +void +opengl_light::apply_angle() { + + ::glLightfv( id, GL_POSITION, glm::value_ptr( glm::vec4{ position, ( is_directional ? 0.f : 1.f ) } ) ); + if( false == is_directional ) { + ::glLightfv( id, GL_SPOT_DIRECTION, glm::value_ptr( direction ) ); + } +} + + +void +opengl_camera::update_frustum( glm::mat4 const &Projection, glm::mat4 const &Modelview ) { + + m_frustum.calculate( Projection, Modelview ); + // cache inverse tranformation matrix + // NOTE: transformation is done only to camera-centric space + m_inversetransformation = glm::inverse( Projection * glm::mat4{ glm::mat3{ Modelview } } ); + // calculate frustum corners + m_frustumpoints = ndcfrustumshapepoints; + transform_to_world( + std::begin( m_frustumpoints ), + std::end( m_frustumpoints ) ); +} + +// returns true if specified object is within camera frustum, false otherwise +bool +opengl_camera::visible( scene::bounding_area const &Area ) const { + + return ( m_frustum.sphere_inside( Area.center, Area.radius ) > 0.f ); +} + +bool +opengl_camera::visible( TDynamicObject const *Dynamic ) const { + + // sphere test is faster than AABB, so we'll use it here + glm::vec3 diagonal( + static_cast( Dynamic->MoverParameters->Dim.L ), + static_cast( Dynamic->MoverParameters->Dim.H ), + static_cast( Dynamic->MoverParameters->Dim.W ) ); + // we're giving vehicles some extra padding, to allow for things like shared bogeys extending past the main body + float const radius = glm::length( diagonal ) * 0.65f; + + return ( m_frustum.sphere_inside( Dynamic->GetPosition(), radius ) > 0.0f ); +} + +// debug helper, draws shape of frustum in world space +void +opengl_camera::draw( glm::vec3 const &Offset ) const { + + ::glBegin( GL_LINES ); + for( auto const pointindex : frustumshapepoinstorder ) { + ::glVertex3fv( glm::value_ptr( glm::vec3{ m_frustumpoints[ pointindex ] } - Offset ) ); + } + ::glEnd(); +} + +bool +opengl_renderer::Init( GLFWwindow *Window ) { + + if( false == Init_caps() ) { return false; } + + m_window = Window; + + ::glPixelStorei( GL_UNPACK_ALIGNMENT, 1 ); + ::glPixelStorei( GL_PACK_ALIGNMENT, 1 ); + + glClearDepth( 1.0f ); + glClearColor( 51.0f / 255.0f, 102.0f / 255.0f, 85.0f / 255.0f, 1.0f ); // initial background Color + + glPolygonMode( GL_FRONT, GL_FILL ); + glFrontFace( GL_CCW ); // Counter clock-wise polygons face out + glEnable( GL_CULL_FACE ); // Cull back-facing triangles + glShadeModel( GL_SMOOTH ); // Enable Smooth Shading + + m_geometry.units().texture = ( + Global.BasicRenderer ? + std::vector{ m_diffusetextureunit } : + std::vector{ m_normaltextureunit, m_diffusetextureunit } ); + m_textures.assign_units( m_helpertextureunit, m_shadowtextureunit, m_normaltextureunit, m_diffusetextureunit ); // TODO: add reflections unit + ui_layer::set_unit( m_diffusetextureunit ); + simulation::Environment.m_precipitation.set_unit( m_diffusetextureunit ); + select_unit( m_diffusetextureunit ); + + ::glDepthFunc( GL_LEQUAL ); + glEnable( GL_DEPTH_TEST ); + glAlphaFunc( GL_GREATER, 0.f ); + glEnable( GL_ALPHA_TEST ); + glBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA ); + glEnable( GL_BLEND ); + glEnable( GL_TEXTURE_2D ); // Enable Texture Mapping + + glHint( GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST ); // Really Nice Perspective Calculations + glHint( GL_POLYGON_SMOOTH_HINT, GL_NICEST ); + glHint( GL_LINE_SMOOTH_HINT, GL_NICEST ); + glLineWidth( 1.0f ); + glPointSize( 3.0f ); + glEnable( GL_POINT_SMOOTH ); + + ::glLightModeli( GL_LIGHT_MODEL_COLOR_CONTROL, GL_SEPARATE_SPECULAR_COLOR ); + ::glMaterialf( GL_FRONT, GL_SHININESS, 15.0f ); + if( true == Global.ScaleSpecularValues ) { + m_specularopaquescalefactor = 0.25f; + m_speculartranslucentscalefactor = 1.5f; + } + ::glEnable( GL_COLOR_MATERIAL ); + ::glColorMaterial( GL_FRONT, GL_AMBIENT_AND_DIFFUSE ); + + // setup lighting + ::glLightModelfv( GL_LIGHT_MODEL_AMBIENT, glm::value_ptr(m_baseambient) ); + ::glEnable( GL_LIGHTING ); + ::glEnable( opengl_renderer::sunlight ); + + // rgb value for 5780 kelvin + Global.DayLight.diffuse[ 0 ] = 255.0f / 255.0f; + Global.DayLight.diffuse[ 1 ] = 242.0f / 255.0f; + Global.DayLight.diffuse[ 2 ] = 231.0f / 255.0f; + Global.DayLight.is_directional = true; + m_sunlight.id = opengl_renderer::sunlight; + // ::glLightf( opengl_renderer::sunlight, GL_SPOT_CUTOFF, 90.0f ); + + // create dynamic light pool + for( int idx = 0; idx < Global.DynamicLightCount; ++idx ) { + + opengl_light light; + light.id = GL_LIGHT1 + idx; + + light.is_directional = false; + ::glEnable( light.id ); // experimental intel chipset fix + ::glLightf( light.id, GL_SPOT_CUTOFF, 7.5f ); + ::glLightf( light.id, GL_SPOT_EXPONENT, 7.5f ); + ::glLightf( light.id, GL_CONSTANT_ATTENUATION, 0.0f ); + ::glLightf( light.id, GL_LINEAR_ATTENUATION, 0.035f ); + ::glDisable( light.id ); // experimental intel chipset fix + + m_lights.emplace_back( light ); + } + // preload some common textures + WriteLog( "Loading common gfx data..." ); + m_glaretexture = Fetch_Texture( "fx/lightglare" ); + m_suntexture = Fetch_Texture( "fx/sun" ); + m_moontexture = Fetch_Texture( "fx/moon" ); + if( m_helpertextureunit >= 0 ) { + m_reflectiontexture = Fetch_Texture( "fx/reflections" ); + } + WriteLog( "...gfx data pre-loading done" ); + +#ifdef EU07_USE_PICKING_FRAMEBUFFER + // pick buffer resources + if( true == m_framebuffersupport ) { + // try to create the pick buffer. RGBA8 2D texture, 24 bit depth texture, 1024x1024 (height of 512 would suffice but, eh) + // texture + ::glGenTextures( 1, &m_picktexture ); + ::glBindTexture( GL_TEXTURE_2D, m_picktexture ); + ::glTexImage2D( GL_TEXTURE_2D, 0, GL_RGBA8, EU07_PICKBUFFERSIZE, EU07_PICKBUFFERSIZE, 0, GL_BGRA, GL_UNSIGNED_BYTE, NULL ); + ::glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE ); + ::glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE ); + ::glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST ); + ::glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST ); + // depth buffer + ::glGenRenderbuffersEXT( 1, &m_pickdepthbuffer ); + ::glBindRenderbufferEXT( GL_RENDERBUFFER_EXT, m_pickdepthbuffer ); + ::glRenderbufferStorageEXT( GL_RENDERBUFFER_EXT, GL_DEPTH_COMPONENT24, EU07_PICKBUFFERSIZE, EU07_PICKBUFFERSIZE ); + // create and assemble the framebuffer + ::glGenFramebuffersEXT( 1, &m_pickframebuffer ); + ::glBindFramebufferEXT( GL_FRAMEBUFFER_EXT, m_pickframebuffer ); + ::glFramebufferTexture2DEXT( GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL_TEXTURE_2D, m_picktexture, 0 ); + ::glFramebufferRenderbufferEXT( GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT, GL_RENDERBUFFER_EXT, m_pickdepthbuffer ); + // check if we got it working + GLenum status = ::glCheckFramebufferStatusEXT( GL_FRAMEBUFFER_EXT ); + if( status == GL_FRAMEBUFFER_COMPLETE_EXT ) { + WriteLog( "Picking framebuffer setup complete" ); + } + else{ + ErrorLog( "Picking framebuffer setup failed" ); + m_framebuffersupport = false; + } + ::glBindFramebufferEXT( GL_FRAMEBUFFER_EXT, 0 ); // switch back to primary render target for now + } +#endif + // shadowmap resources + if( ( true == Global.RenderShadows ) + && ( true == m_framebuffersupport ) ) { + // primary shadow map + { + // texture: + ::glGenTextures( 1, &m_shadowtexture ); + ::glBindTexture( GL_TEXTURE_2D, m_shadowtexture ); + // allocate memory + ::glTexImage2D( GL_TEXTURE_2D, 0, GL_DEPTH_COMPONENT24, m_shadowbuffersize, m_shadowbuffersize, 0, GL_DEPTH_COMPONENT, GL_UNSIGNED_BYTE, NULL ); + // setup parameters + ::glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE ); + ::glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE ); + ::glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR ); + ::glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR ); + // enable shadow comparison: true (ie not in shadow) if r<=texture... + ::glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_COMPARE_MODE, GL_COMPARE_R_TO_TEXTURE ); + ::glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_COMPARE_FUNC, GL_LEQUAL ); + ::glTexParameteri( GL_TEXTURE_2D, GL_DEPTH_TEXTURE_MODE, GL_LUMINANCE ); + ::glBindTexture( GL_TEXTURE_2D, 0 ); +#ifdef EU07_USE_DEBUG_SHADOWMAP + ::glGenTextures( 1, &m_shadowdebugtexture ); + ::glBindTexture( GL_TEXTURE_2D, m_shadowdebugtexture ); + // allocate memory + ::glTexImage2D( GL_TEXTURE_2D, 0, GL_RGBA8, m_shadowbuffersize, m_shadowbuffersize, 0, GL_BGRA, GL_UNSIGNED_BYTE, NULL ); + // setup parameters + ::glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE ); + ::glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE ); + ::glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR ); + ::glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR ); + ::glBindTexture( GL_TEXTURE_2D, 0 ); +#endif + // create and assemble the framebuffer + ::glGenFramebuffersEXT( 1, &m_shadowframebuffer ); + ::glBindFramebufferEXT( GL_FRAMEBUFFER_EXT, m_shadowframebuffer ); +#ifdef EU07_USE_DEBUG_SHADOWMAP + ::glFramebufferTexture2DEXT( GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL_TEXTURE_2D, m_shadowdebugtexture, 0 ); +#else + ::glDrawBuffer( GL_NONE ); // we won't be rendering colour data, so can skip the colour attachment + ::glReadBuffer( GL_NONE ); +#endif + ::glFramebufferTexture2DEXT( GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT, GL_TEXTURE_2D, m_shadowtexture, 0 ); + // check if we got it working + GLenum const status{ ::glCheckFramebufferStatusEXT( GL_FRAMEBUFFER_EXT ) }; + if( status == GL_FRAMEBUFFER_COMPLETE_EXT ) { + WriteLog( "Shadows framebuffer setup complete" ); + } + else { + ErrorLog( "Shadows framebuffer setup failed" ); + Global.RenderShadows = false; + } + // switch back to primary render target for now + ::glBindFramebufferEXT( GL_FRAMEBUFFER_EXT, 0 ); + } + // cab shadow map + { + // NOTE: using separate framebuffer as more efficient arrangement than swapping attachments on a single one + // TODO: for shader-based implementation use instead a quarter of the CSM + // texture: + ::glGenTextures( 1, &m_cabshadowtexture ); + ::glBindTexture( GL_TEXTURE_2D, m_cabshadowtexture ); + // allocate memory + ::glTexImage2D( GL_TEXTURE_2D, 0, GL_DEPTH_COMPONENT24, m_shadowbuffersize / 2, m_shadowbuffersize / 2, 0, GL_DEPTH_COMPONENT, GL_UNSIGNED_BYTE, NULL ); + // setup parameters + ::glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE ); + ::glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE ); + ::glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR ); + ::glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR ); + // enable shadow comparison: true (ie not in shadow) if r<=texture... + ::glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_COMPARE_MODE, GL_COMPARE_R_TO_TEXTURE ); + ::glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_COMPARE_FUNC, GL_LEQUAL ); + ::glTexParameteri( GL_TEXTURE_2D, GL_DEPTH_TEXTURE_MODE, GL_LUMINANCE ); + ::glBindTexture( GL_TEXTURE_2D, 0 ); +#ifdef EU07_USE_DEBUG_CABSHADOWMAP + ::glGenTextures( 1, &m_cabshadowdebugtexture ); + ::glBindTexture( GL_TEXTURE_2D, m_cabshadowdebugtexture ); + // allocate memory + ::glTexImage2D( GL_TEXTURE_2D, 0, GL_RGBA8, m_shadowbuffersize / 2, m_shadowbuffersize / 2, 0, GL_BGRA, GL_UNSIGNED_BYTE, NULL ); + // setup parameters + ::glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE ); + ::glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE ); + ::glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR ); + ::glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR ); + ::glBindTexture( GL_TEXTURE_2D, 0 ); +#endif + // create and assemble the framebuffer + ::glGenFramebuffersEXT( 1, &m_cabshadowframebuffer ); + ::glBindFramebufferEXT( GL_FRAMEBUFFER_EXT, m_cabshadowframebuffer ); +#ifdef EU07_USE_DEBUG_CABSHADOWMAP + ::glFramebufferTexture2DEXT( GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL_TEXTURE_2D, m_cabshadowdebugtexture, 0 ); +#else + ::glDrawBuffer( GL_NONE ); // we won't be rendering colour data, so can skip the colour attachment + ::glReadBuffer( GL_NONE ); +#endif + ::glFramebufferTexture2DEXT( GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT, GL_TEXTURE_2D, m_cabshadowtexture, 0 ); + // check if we got it working + GLenum const status{ ::glCheckFramebufferStatusEXT( GL_FRAMEBUFFER_EXT ) }; + if( status == GL_FRAMEBUFFER_COMPLETE_EXT ) { + WriteLog( "Cab shadows framebuffer setup complete" ); + } + else { + ErrorLog( "Cab shadows framebuffer setup failed" ); + Global.RenderShadows = false; + } + } + // switch back to primary render target for now + ::glBindFramebufferEXT( GL_FRAMEBUFFER_EXT, 0 ); + } + // environment cube map resources + if( ( false == Global.BasicRenderer ) + && ( true == m_framebuffersupport ) ) { + // texture: + ::glGenTextures( 1, &m_environmentcubetexture ); + ::glBindTexture( GL_TEXTURE_CUBE_MAP, m_environmentcubetexture ); + // allocate space + for( GLuint faceindex = GL_TEXTURE_CUBE_MAP_POSITIVE_X; faceindex < GL_TEXTURE_CUBE_MAP_POSITIVE_X + 6; ++faceindex ) { + ::glTexImage2D( faceindex, 0, GL_RGBA8, EU07_ENVIRONMENTBUFFERSIZE, EU07_ENVIRONMENTBUFFERSIZE, 0, GL_BGRA, GL_UNSIGNED_BYTE, NULL ); + } + // setup parameters + ::glTexParameteri( GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MIN_FILTER, GL_LINEAR ); + ::glTexParameteri( GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MAG_FILTER, GL_LINEAR ); + ::glTexParameteri( GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE ); + ::glTexParameteri( GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE ); + ::glTexParameteri( GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_R, GL_CLAMP_TO_EDGE ); + // depth buffer + ::glGenRenderbuffersEXT( 1, &m_environmentdepthbuffer ); + ::glBindRenderbufferEXT( GL_RENDERBUFFER_EXT, m_environmentdepthbuffer ); + ::glRenderbufferStorageEXT( GL_RENDERBUFFER_EXT, GL_DEPTH_COMPONENT24, EU07_ENVIRONMENTBUFFERSIZE, EU07_ENVIRONMENTBUFFERSIZE ); + // create and assemble the framebuffer + ::glGenFramebuffersEXT( 1, &m_environmentframebuffer ); + ::glBindFramebufferEXT( GL_FRAMEBUFFER_EXT, m_environmentframebuffer ); + ::glFramebufferTexture2DEXT( GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL_TEXTURE_CUBE_MAP_POSITIVE_X, m_environmentcubetexture, 0 ); + ::glFramebufferRenderbufferEXT( GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT, GL_RENDERBUFFER_EXT, m_environmentdepthbuffer ); + // check if we got it working + GLenum status = ::glCheckFramebufferStatusEXT( GL_FRAMEBUFFER_EXT ); + if( status == GL_FRAMEBUFFER_COMPLETE_EXT ) { + WriteLog( "Reflections framebuffer setup complete" ); + m_environmentcubetexturesupport = true; + } + else { + ErrorLog( "Reflections framebuffer setup failed" ); + m_environmentcubetexturesupport = false; + } + ::glBindFramebufferEXT( GL_FRAMEBUFFER_EXT, 0 ); // switch back to primary render target for now + } + // prepare basic geometry chunks + auto const geometrybank = m_geometry.create_bank(); + float const size = 2.5f; + m_billboardgeometry = m_geometry.create_chunk( + gfx::vertex_array{ + { { -size, size, 0.f }, glm::vec3(), { 1.f, 1.f } }, + { { size, size, 0.f }, glm::vec3(), { 0.f, 1.f } }, + { { -size, -size, 0.f }, glm::vec3(), { 1.f, 0.f } }, + { { size, -size, 0.f }, glm::vec3(), { 0.f, 0.f } } }, + geometrybank, + GL_TRIANGLE_STRIP ); + // prepare debug mode objects + m_quadric = ::gluNewQuadric(); + ::gluQuadricNormals( m_quadric, GLU_FLAT ); + + return true; +} + +bool +opengl_renderer::Render() { + + Timer::subsystem.gfx_total.stop(); + Timer::subsystem.gfx_total.start(); // note: gfx_total is actually frame total, clean this up + Timer::subsystem.gfx_color.start(); + // fetch simulation data + if( simulation::is_ready ) { + m_sunlight = Global.DayLight; + // quantize sun angle to reduce shadow crawl + auto const quantizationstep { 0.004f }; + m_sunlight.direction = glm::normalize( quantizationstep * glm::roundEven( m_sunlight.direction * ( 1.f / quantizationstep ) ) ); + } + // generate new frame + m_renderpass.draw_mode = rendermode::none; // force setup anew + m_debugtimestext.clear(); + m_debugstats = debug_stats(); + Render_pass( rendermode::color ); + Timer::subsystem.gfx_color.stop(); + // add user interface + setup_units( true, false, false ); + Application.render_ui(); + + if( Global.bUseVBO ) { + // swapbuffers() will unbind current buffers so we prepare for it on our end + gfx::opengl_vbogeometrybank::reset(); + } + Timer::subsystem.gfx_swap.start(); + glfwSwapBuffers( m_window ); + Timer::subsystem.gfx_swap.stop(); + + m_drawcount = m_cellqueue.size(); + m_debugtimestext + += "color: " + to_string( Timer::subsystem.gfx_color.average(), 2 ) + " msec (" + std::to_string( m_cellqueue.size() ) + " sectors)\n" + += "gpu side: " + to_string( Timer::subsystem.gfx_swap.average(), 2 ) + " msec\n" + += "frame total: " + to_string( Timer::subsystem.gfx_color.average() + Timer::subsystem.gfx_swap.average(), 2 ) + " msec"; + + m_debugstatstext = + "drawcalls: " + to_string( m_debugstats.drawcalls ) + "\n" + + " vehicles: " + to_string( m_debugstats.dynamics ) + "\n" + + " models: " + to_string( m_debugstats.models ) + "\n" + + " submodels: " + to_string( m_debugstats.submodels ) + "\n" + + " paths: " + to_string( m_debugstats.paths ) + "\n" + + " shapes: " + to_string( m_debugstats.shapes ) + "\n" + + " traction: " + to_string( m_debugstats.traction ) + "\n" + + " lines: " + to_string( m_debugstats.lines ); + + ++m_framestamp; + + return true; // for now always succeed +} + +// runs jobs needed to generate graphics for specified render pass +void +opengl_renderer::Render_pass( rendermode const Mode ) { + +#ifdef EU07_USE_DEBUG_CAMERA + // setup world camera for potential visualization + setup_pass( + m_worldcamera, + rendermode::color, + 0.f, + 1.0, + true ); +#endif + setup_pass( m_renderpass, Mode ); + switch( m_renderpass.draw_mode ) { + + case rendermode::color: { + + m_colorpass = m_renderpass; + + if( ( true == Global.RenderShadows ) + && ( false == Global.bWireFrame ) + && ( true == simulation::is_ready ) + && ( m_shadowcolor != colors::white ) ) { + + // run shadowmaps pass before color + Timer::subsystem.gfx_shadows.start(); + Render_pass( rendermode::shadows ); + if( false == FreeFlyModeFlag ) { + Render_pass( rendermode::cabshadows ); + } + Timer::subsystem.gfx_shadows.stop(); + m_debugtimestext += "shadows: " + to_string( Timer::subsystem.gfx_shadows.average(), 2 ) + " msec (" + std::to_string( m_cellqueue.size() ) + " sectors)\n"; +#ifdef EU07_USE_DEBUG_SHADOWMAP + UILayer.set_texture( m_shadowdebugtexture ); +#endif +#ifdef EU07_USE_DEBUG_CABSHADOWMAP + UILayer.set_texture( m_cabshadowdebugtexture ); +#endif + setup_pass( m_renderpass, Mode ); // restore draw mode. TBD, TODO: render mode stack + // setup shadowmap matrices + m_shadowtexturematrix = + glm::mat4 { 0.5f, 0.0f, 0.0f, 0.0f, 0.0f, 0.5f, 0.0f, 0.0f, 0.0f, 0.0f, 0.5f, 0.0f, 0.5f, 0.5f, 0.5f, 1.0f } // bias from [-1, 1] to [0, 1] + * m_shadowpass.camera.projection() + // during colour pass coordinates are moved from camera-centric to light-centric, essentially the difference between these two origins + * glm::translate( + glm::mat4{ glm::mat3{ m_shadowpass.camera.modelview() } }, + glm::vec3{ m_renderpass.camera.position() - m_shadowpass.camera.position() } ); + + if( false == FreeFlyModeFlag ) { + m_cabshadowtexturematrix = + glm::mat4{ 0.5f, 0.0f, 0.0f, 0.0f, 0.0f, 0.5f, 0.0f, 0.0f, 0.0f, 0.0f, 0.5f, 0.0f, 0.5f, 0.5f, 0.5f, 1.0f } // bias from [-1, 1] to [0, 1] + * m_cabshadowpass.camera.projection() + // during colour pass coordinates are moved from camera-centric to light-centric, essentially the difference between these two origins + * glm::translate( + glm::mat4{ glm::mat3{ m_cabshadowpass.camera.modelview() } }, + glm::vec3{ m_renderpass.camera.position() - m_cabshadowpass.camera.position() } ); + } + } + + if( ( true == m_environmentcubetexturesupport ) + && ( true == simulation::is_ready ) ) { + // potentially update environmental cube map + if( true == Render_reflections() ) { + setup_pass( m_renderpass, Mode ); // restore draw mode. TBD, TODO: render mode stack + } + } + + ::glViewport( 0, 0, Global.iWindowWidth, Global.iWindowHeight ); + + if( simulation::is_ready ) { + auto const skydomecolour = simulation::Environment.m_skydome.GetAverageColor(); + ::glClearColor( skydomecolour.x, skydomecolour.y, skydomecolour.z, 0.f ); // kolor nieba + } + else { + ::glClearColor( 51.0f / 255.f, 102.0f / 255.f, 85.0f / 255.f, 1.f ); // initial background Color + } + ::glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT ); + + if( simulation::is_ready ) { + // setup + setup_matrices(); + // render + setup_drawing( true ); + setup_units( true, false, false ); + Render( &simulation::Environment ); + // opaque parts... + setup_drawing( false ); + setup_units( true, true, true ); +#ifdef EU07_USE_DEBUG_CAMERA + if( DebugModeFlag ) { + // draw light frustum + ::glLineWidth( 2.f ); + ::glColor4f( 1.f, 0.9f, 0.8f, 1.f ); + ::glDisable( GL_LIGHTING ); + ::glDisable( GL_TEXTURE_2D ); + if( ( true == Global.RenderShadows ) && ( false == Global.bWireFrame ) ) { + m_shadowpass.camera.draw( m_renderpass.camera.position() - m_shadowpass.camera.position() ); + } + if( DebugCameraFlag ) { + ::glColor4f( 0.8f, 1.f, 0.9f, 1.f ); + m_worldcamera.camera.draw( m_renderpass.camera.position() - m_worldcamera.camera.position() ); + } + ::glLineWidth( 1.f ); + ::glEnable( GL_LIGHTING ); + ::glEnable( GL_TEXTURE_2D ); + } +#endif + // without rain/snow we can render the cab early to limit the overdraw + if( ( false == FreeFlyModeFlag ) + && ( Global.Overcast <= 1.f ) ) { // precipitation happens when overcast is in 1-2 range + switch_units( true, true, false ); + setup_shadow_map( m_cabshadowtexture, m_cabshadowtexturematrix ); + // cache shadow colour in case we need to account for cab light + auto const shadowcolor { m_shadowcolor }; + auto const *vehicle{ simulation::Train->Dynamic() }; + if( vehicle->InteriorLightLevel > 0.f ) { + setup_shadow_color( glm::min( colors::white, shadowcolor + glm::vec4( vehicle->InteriorLight * vehicle->InteriorLightLevel, 1.f ) ) ); + } + Render_cab( vehicle, false ); + if( vehicle->InteriorLightLevel > 0.f ) { + setup_shadow_color( shadowcolor ); + } + } + switch_units( true, true, true ); + setup_shadow_map( m_shadowtexture, m_shadowtexturematrix ); + Render( simulation::Region ); + // ...translucent parts + setup_drawing( true ); + Render_Alpha( simulation::Region ); + // precipitation; done at the end, only before cab render + Render_precipitation(); + // cab render + if( false == FreeFlyModeFlag ) { + switch_units( true, true, false ); + setup_shadow_map( m_cabshadowtexture, m_cabshadowtexturematrix ); + // cache shadow colour in case we need to account for cab light + auto const shadowcolor{ m_shadowcolor }; + auto const *vehicle{ simulation::Train->Dynamic() }; + if( vehicle->InteriorLightLevel > 0.f ) { + setup_shadow_color( glm::min( colors::white, shadowcolor + glm::vec4( vehicle->InteriorLight * vehicle->InteriorLightLevel, 1.f ) ) ); + } + if( Global.Overcast > 1.f ) { + // with active precipitation draw the opaque cab parts here to mask rain/snow placed 'inside' the cab + setup_drawing( false ); + Render_cab( vehicle, false ); + setup_drawing( true ); + } + Render_cab( vehicle, true ); + if( vehicle->InteriorLightLevel > 0.f ) { + setup_shadow_color( shadowcolor ); + } + } + + if( m_environmentcubetexturesupport ) { + // restore default texture matrix for reflections cube map + select_unit( m_helpertextureunit ); + ::glMatrixMode( GL_TEXTURE ); +// ::glPopMatrix(); + ::glLoadIdentity(); + select_unit( m_diffusetextureunit ); + ::glMatrixMode( GL_MODELVIEW ); + } + } + break; + } + + case rendermode::shadows: { + + if( simulation::is_ready ) { + // setup + ::glEnable( GL_POLYGON_OFFSET_FILL ); // alleviate depth-fighting + ::glPolygonOffset( 1.f, 1.f ); + + // main shadowmap + ::glBindFramebufferEXT( GL_FRAMEBUFFER, m_shadowframebuffer ); + ::glViewport( 0, 0, m_shadowbuffersize, m_shadowbuffersize ); + +#ifdef EU07_USE_DEBUG_SHADOWMAP + ::glClearColor( 0.f / 255.f, 0.f / 255.f, 0.f / 255.f, 1.f ); // initial background Color + ::glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT ); +#else + ::glClear( GL_DEPTH_BUFFER_BIT ); +#endif + ::glScissor( 1, 1, m_shadowbuffersize - 2, m_shadowbuffersize - 2 ); + ::glEnable( GL_SCISSOR_TEST ); + + setup_matrices(); + // render + // opaque parts... + setup_drawing( false ); +#ifdef EU07_USE_DEBUG_SHADOWMAP + setup_units( true, false, false ); +#else + setup_units( false, false, false ); +#endif + Render( simulation::Region ); + m_shadowpass = m_renderpass; + + // post-render restore + ::glDisable( GL_SCISSOR_TEST ); + ::glDisable( GL_POLYGON_OFFSET_FILL ); + + ::glBindFramebufferEXT( GL_FRAMEBUFFER_EXT, 0 ); // switch back to primary render target + } + break; + } + + case rendermode::cabshadows: { + + if( ( simulation::is_ready ) + && ( false == FreeFlyModeFlag ) ) { + // setup + ::glEnable( GL_POLYGON_OFFSET_FILL ); // alleviate depth-fighting + ::glPolygonOffset( 1.f, 1.f ); + ::glDisable( GL_CULL_FACE ); + + ::glBindFramebufferEXT( GL_FRAMEBUFFER, m_cabshadowframebuffer ); + ::glViewport( 0, 0, m_shadowbuffersize / 2, m_shadowbuffersize / 2 ); + +#ifdef EU07_USE_DEBUG_CABSHADOWMAP + ::glClearColor( 0.f / 255.f, 0.f / 255.f, 0.f / 255.f, 1.f ); // initial background Color + ::glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT ); +#else + ::glClear( GL_DEPTH_BUFFER_BIT ); +#endif + ::glScissor( 1, 1, m_shadowbuffersize / 2 - 2, m_shadowbuffersize / 2 - 2 ); + ::glEnable( GL_SCISSOR_TEST ); + + setup_matrices(); + // render + // opaque parts... + setup_drawing( false ); +#ifdef EU07_USE_DEBUG_CABSHADOWMAP + setup_units( true, false, false ); +#else + setup_units( false, false, false ); +#endif + Render_cab( simulation::Train->Dynamic(), false ); + Render_cab( simulation::Train->Dynamic(), true ); + m_cabshadowpass = m_renderpass; + + // post-render restore + ::glDisable( GL_SCISSOR_TEST ); + ::glEnable( GL_CULL_FACE ); + ::glDisable( GL_POLYGON_OFFSET_FILL ); + + ::glBindFramebufferEXT( GL_FRAMEBUFFER_EXT, 0 ); // switch back to primary render target + } + break; + } + + case rendermode::reflections: { + // NOTE: buffer and viewport setup in this mode is handled by the wrapper method + ::glClearColor( 0.f, 0.f, 0.f, 1.f ); + ::glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT ); + + if( simulation::is_ready ) { + + ::glColorMask( GL_TRUE, GL_TRUE, GL_TRUE, GL_FALSE ); + // setup + setup_matrices(); + // render + setup_drawing( true ); + setup_units( true, false, false ); + Render( &simulation::Environment ); + // opaque parts... + setup_drawing( false ); + setup_units( true, true, true ); + setup_shadow_map( m_shadowtexture, m_shadowtexturematrix ); + Render( simulation::Region ); +/* + // reflections are limited to sky and ground only, the update rate is too low for anything else + // ...translucent parts + setup_drawing( true ); + Render_Alpha( &World.Ground ); + // cab render is performed without shadows, due to low resolution and number of models without windows :| + switch_units( true, false, false ); + // cab render is done in translucent phase to deal with badly configured vehicles + if( World.Train != nullptr ) { Render_cab( World.Train->Dynamic() ); } +*/ + ::glColorMask( GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE ); + } + break; + } + + case rendermode::pickcontrols: { + if( simulation::is_ready ) { + // setup +#ifdef EU07_USE_PICKING_FRAMEBUFFER + ::glViewport( 0, 0, EU07_PICKBUFFERSIZE, EU07_PICKBUFFERSIZE ); +#endif + ::glClearColor( 0.f, 0.f, 0.f, 1.f ); + ::glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT ); + + m_pickcontrolsitems.clear(); + setup_matrices(); + // render + // opaque parts... + setup_drawing( false ); + setup_units( false, false, false ); + // cab render skips translucent parts, so we can do it here + if( simulation::Train != nullptr ) { Render_cab( simulation::Train->Dynamic() ); } + // post-render cleanup + } + break; + } + + case rendermode::pickscenery: { + if( simulation::is_ready ) { + // setup + m_picksceneryitems.clear(); +#ifdef EU07_USE_PICKING_FRAMEBUFFER + ::glViewport( 0, 0, EU07_PICKBUFFERSIZE, EU07_PICKBUFFERSIZE ); +#endif + ::glClearColor( 0.f, 0.f, 0.f, 1.f ); + ::glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT ); + + setup_matrices(); + // render + // opaque parts... + setup_drawing( false ); + setup_units( false, false, false ); + Render( simulation::Region ); + // post-render cleanup + } + break; + } + + default: { + break; + } + } +} + +// creates dynamic environment cubemap +bool +opengl_renderer::Render_reflections() { + + auto const &time = simulation::Time.data(); + auto const timestamp = time.wDay * 24 * 60 + time.wHour * 60 + time.wMinute; + if( ( timestamp - m_environmentupdatetime < 5 ) + && ( glm::length( m_renderpass.camera.position() - m_environmentupdatelocation ) < 1000.0 ) ) { + // run update every 5+ mins of simulation time, or at least 1km from the last location + return false; + } + m_environmentupdatetime = timestamp; + m_environmentupdatelocation = m_renderpass.camera.position(); + + ::glBindFramebufferEXT( GL_FRAMEBUFFER_EXT, m_environmentframebuffer ); + ::glViewport( 0, 0, EU07_ENVIRONMENTBUFFERSIZE, EU07_ENVIRONMENTBUFFERSIZE ); + for( m_environmentcubetextureface = GL_TEXTURE_CUBE_MAP_POSITIVE_X; + m_environmentcubetextureface < GL_TEXTURE_CUBE_MAP_POSITIVE_X + 6; + ++m_environmentcubetextureface ) { + + ::glFramebufferTexture2DEXT( GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0, m_environmentcubetextureface, m_environmentcubetexture, 0 ); + Render_pass( rendermode::reflections ); + } + ::glBindFramebufferEXT( GL_FRAMEBUFFER_EXT, 0 ); + + return true; +} + +void +opengl_renderer::setup_pass( renderpass_config &Config, rendermode const Mode, float const Znear, float const Zfar, bool const Ignoredebug ) { + + Config.draw_mode = Mode; + + if( false == simulation::is_ready ) { return; } + // setup draw range + switch( Mode ) { + case rendermode::color: { Config.draw_range = Global.BaseDrawRange; break; } + case rendermode::shadows: { Config.draw_range = Global.BaseDrawRange * 0.5f; break; } + case rendermode::cabshadows: { Config.draw_range = ( simulation::Train->Occupied()->ActiveCab != 0 ? 10.f : 20.f ); break; } + case rendermode::reflections: { Config.draw_range = Global.BaseDrawRange; break; } + case rendermode::pickcontrols: { Config.draw_range = 50.f; break; } + case rendermode::pickscenery: { Config.draw_range = Global.BaseDrawRange * 0.5f; break; } + default: { Config.draw_range = 0.f; break; } + } + // setup camera + auto &camera = Config.camera; + + camera.projection() = glm::mat4( 1.f ); + glm::dmat4 viewmatrix( 1.0 ); + + switch( Mode ) { + case rendermode::color: { + // modelview + if( ( false == DebugCameraFlag ) || ( true == Ignoredebug ) ) { + camera.position() = Global.pCamera.Pos; + Global.pCamera.SetMatrix( viewmatrix ); + } + else { + camera.position() = Global.pDebugCamera.Pos; + Global.pDebugCamera.SetMatrix( viewmatrix ); + } + // projection + auto const zfar = Config.draw_range * Global.fDistanceFactor * Zfar; + auto const znear = ( + Znear > 0.f ? + Znear * zfar : + 0.1f * Global.ZoomFactor ); + camera.projection() *= + glm::perspective( + glm::radians( Global.FieldOfView / Global.ZoomFactor ), + std::max( 1.f, (float)Global.iWindowWidth ) / std::max( 1.f, (float)Global.iWindowHeight ), + znear, + zfar ); +/* + m_sunandviewangle = + glm::dot( + m_sunlight.direction, + glm::vec3( 0.f, 0.f, -1.f ) * glm::mat3( viewmatrix ) ); +*/ + break; + } + case rendermode::shadows: { + // calculate lightview boundaries based on relevant area of the world camera frustum: + // ...setup chunk of frustum we're interested in... + auto const zfar = std::min( 1.f, Global.shadowtune.depth / ( Global.BaseDrawRange * Global.fDistanceFactor ) * std::max( 1.f, Global.ZoomFactor * 0.5f ) ); + renderpass_config worldview; + setup_pass( worldview, rendermode::color, 0.f, zfar, true ); + auto &frustumchunkshapepoints = worldview.camera.frustum_points(); + // ...modelview matrix: determine the centre of frustum chunk in world space... + glm::vec3 frustumchunkmin, frustumchunkmax; + bounding_box( frustumchunkmin, frustumchunkmax, std::begin( frustumchunkshapepoints ), std::end( frustumchunkshapepoints ) ); + auto const frustumchunkcentre = ( frustumchunkmin + frustumchunkmax ) * 0.5f; + // ...cap the vertical angle to keep shadows from getting too long... + auto const lightvector = + glm::normalize( glm::vec3{ + m_sunlight.direction.x, + std::min( m_sunlight.direction.y, -0.2f ), + m_sunlight.direction.z } ); + // ...place the light source at the calculated centre and setup world space light view matrix... + camera.position() = worldview.camera.position() + glm::dvec3{ frustumchunkcentre }; + viewmatrix *= glm::lookAt( + camera.position(), + camera.position() + glm::dvec3{ lightvector }, + glm::dvec3{ 0.f, 1.f, 0.f } ); + // ...projection matrix: calculate boundaries of the frustum chunk in light space... + auto const lightviewmatrix = + glm::translate( + glm::mat4{ glm::mat3{ viewmatrix } }, + -frustumchunkcentre ); + for( auto &point : frustumchunkshapepoints ) { + point = lightviewmatrix * point; + } + bounding_box( frustumchunkmin, frustumchunkmax, std::begin( frustumchunkshapepoints ), std::end( frustumchunkshapepoints ) ); + // quantize the frustum points and add some padding, to reduce shadow shimmer on scale changes + auto const quantizationstep{ std::min( Global.shadowtune.depth, 50.f ) }; + frustumchunkmin = quantizationstep * glm::floor( frustumchunkmin * ( 1.f / quantizationstep ) ); + frustumchunkmax = quantizationstep * glm::ceil( frustumchunkmax * ( 1.f / quantizationstep ) ); + // ...use the dimensions to set up light projection boundaries... + // NOTE: since we only have one cascade map stage, we extend the chunk forward/back to catch areas normally covered by other stages + camera.projection() *= + glm::ortho( + frustumchunkmin.x, frustumchunkmax.x, + frustumchunkmin.y, frustumchunkmax.y, + frustumchunkmin.z - 500.f, frustumchunkmax.z + 500.f ); +/* + // fixed ortho projection from old build, for quick quality comparisons + camera.projection() *= + glm::ortho( + -Global.shadowtune.width, Global.shadowtune.width, + -Global.shadowtune.width, Global.shadowtune.width, + -Global.shadowtune.depth, Global.shadowtune.depth ); + camera.position() = Global.pCameraPosition - glm::dvec3{ m_sunlight.direction }; + if( camera.position().y - Global.pCameraPosition.y < 0.1 ) { + camera.position().y = Global.pCameraPosition.y + 0.1; + } + viewmatrix *= glm::lookAt( + camera.position(), + glm::dvec3{ Global.pCameraPosition }, + glm::dvec3{ 0.f, 1.f, 0.f } ); +*/ + // ... and adjust the projection to sample complete shadow map texels: + // get coordinates for a sample texel... + auto shadowmaptexel = glm::vec2 { camera.projection() * glm::mat4{ viewmatrix } * glm::vec4{ 0.f, 0.f, 0.f, 1.f } }; + // ...convert result from clip space to texture coordinates, and calculate adjustment... + shadowmaptexel *= m_shadowbuffersize * 0.5f; + auto shadowmapadjustment = glm::round( shadowmaptexel ) - shadowmaptexel; + // ...transform coordinate change back to homogenous light space... + shadowmapadjustment /= m_shadowbuffersize * 0.5f; + // ... and bake the adjustment into the projection matrix + camera.projection() = + glm::translate( + glm::mat4{ 1.f }, + glm::vec3{ shadowmapadjustment, 0.f } ) + * camera.projection(); + + break; + } + case rendermode::cabshadows: { + // fixed size cube large enough to enclose a vehicle compartment + // modelview + auto const lightvector = + glm::normalize( glm::vec3{ + m_sunlight.direction.x, + std::min( m_sunlight.direction.y, -0.2f ), + m_sunlight.direction.z } ); + camera.position() = Global.pCamera.Pos - glm::dvec3 { lightvector }; + viewmatrix *= glm::lookAt( + camera.position(), + glm::dvec3 { Global.pCamera.Pos }, + glm::dvec3 { 0.f, 1.f, 0.f } ); + // projection + auto const maphalfsize { Config.draw_range * 0.5f }; + camera.projection() *= + glm::ortho( + -maphalfsize, maphalfsize, + -maphalfsize, maphalfsize, + -Config.draw_range, Config.draw_range ); +/* + // adjust the projection to sample complete shadow map texels + auto shadowmaptexel = glm::vec2 { camera.projection() * glm::mat4{ viewmatrix } * glm::vec4{ 0.f, 0.f, 0.f, 1.f } }; + shadowmaptexel *= ( m_shadowbuffersize / 2 ) * 0.5f; + auto shadowmapadjustment = glm::round( shadowmaptexel ) - shadowmaptexel; + shadowmapadjustment /= ( m_shadowbuffersize / 2 ) * 0.5f; + camera.projection() = glm::translate( glm::mat4{ 1.f }, glm::vec3{ shadowmapadjustment, 0.f } ) * camera.projection(); +*/ + break; + } + case rendermode::reflections: { + // modelview + camera.position() = ( + ( ( true == DebugCameraFlag ) && ( false == Ignoredebug ) ) ? + Global.pDebugCamera.Pos : + Global.pCamera.Pos ); + glm::dvec3 const cubefacetargetvectors[ 6 ] = { { 1.0, 0.0, 0.0 }, { -1.0, 0.0, 0.0 }, { 0.0, 1.0, 0.0 }, { 0.0, -1.0, 0.0 }, { 0.0, 0.0, 1.0 }, { 0.0, 0.0, -1.0 } }; + glm::dvec3 const cubefaceupvectors[ 6 ] = { { 0.0, -1.0, 0.0 }, { 0.0, -1.0, 0.0 }, { 0.0, 0.0, 1.0 }, { 0.0, 0.0, -1.0 }, { 0.0, -1.0, 0.0 }, { 0.0, -1.0, 0.0 } }; + auto const cubefaceindex = m_environmentcubetextureface - GL_TEXTURE_CUBE_MAP_POSITIVE_X; + viewmatrix *= + glm::lookAt( + camera.position(), + camera.position() + cubefacetargetvectors[ cubefaceindex ], + cubefaceupvectors[ cubefaceindex ] ); + // projection + camera.projection() *= + glm::perspective( + glm::radians( 90.f ), + 1.f, + 0.1f * Global.ZoomFactor, + Config.draw_range * Global.fDistanceFactor ); + break; + } + + case rendermode::pickcontrols: + case rendermode::pickscenery: { + // TODO: scissor test for pick modes + // modelview + camera.position() = Global.pCamera.Pos; + Global.pCamera.SetMatrix( viewmatrix ); + // projection + camera.projection() *= + glm::perspective( + glm::radians( Global.FieldOfView / Global.ZoomFactor ), + std::max( 1.f, (float)Global.iWindowWidth ) / std::max( 1.f, (float)Global.iWindowHeight ), + 0.1f * Global.ZoomFactor, + Config.draw_range * Global.fDistanceFactor ); + break; + } + default: { + break; + } + } + camera.modelview() = viewmatrix; + camera.update_frustum(); +} + +void +opengl_renderer::setup_matrices() { + + ::glMatrixMode( GL_PROJECTION ); + OpenGLMatrices.load_matrix( m_renderpass.camera.projection() ); + + if( ( m_renderpass.draw_mode == rendermode::color ) + && ( m_environmentcubetexturesupport ) ) { + // special case, for colour render pass setup texture matrix for reflections cube map + select_unit( m_helpertextureunit ); + ::glMatrixMode( GL_TEXTURE ); +// ::glPushMatrix(); + ::glLoadIdentity(); + ::glMultMatrixf( glm::value_ptr( glm::inverse( glm::mat4{ glm::mat3{ m_renderpass.camera.modelview() } } ) ) ); + select_unit( m_diffusetextureunit ); + } + + // trim modelview matrix just to rotation, since rendering is done in camera-centric world space + ::glMatrixMode( GL_MODELVIEW ); + OpenGLMatrices.load_matrix( glm::mat4( glm::mat3( m_renderpass.camera.modelview() ) ) ); +} + +void +opengl_renderer::setup_drawing( bool const Alpha ) { + + if( true == Alpha ) { + + ::glEnable( GL_BLEND ); + ::glAlphaFunc( GL_GREATER, 0.f ); + } + else { + ::glDisable( GL_BLEND ); + ::glAlphaFunc( GL_GREATER, 0.5f ); + } + + switch( m_renderpass.draw_mode ) { + case rendermode::color: + case rendermode::reflections: { + ::glEnable( GL_LIGHTING ); + ::glShadeModel( GL_SMOOTH ); + if( Global.iMultisampling ) { + ::glEnable( GL_MULTISAMPLE ); + } + // setup fog + if( Global.fFogEnd > 0 ) { + // fog setup + m_fogrange = Global.fFogEnd / std::max( 1.f, Global.Overcast * 2.f ); + ::glFogfv( GL_FOG_COLOR, glm::value_ptr( Global.FogColor ) ); + ::glFogf( GL_FOG_DENSITY, static_cast( 1.0 / m_fogrange ) ); + ::glEnable( GL_FOG ); + } + else { ::glDisable( GL_FOG ); } + + break; + } + case rendermode::shadows: + case rendermode::cabshadows: + case rendermode::pickcontrols: + case rendermode::pickscenery: { + ::glColor4fv( glm::value_ptr( colors::white ) ); + ::glDisable( GL_LIGHTING ); + ::glShadeModel( GL_FLAT ); + if( Global.iMultisampling ) { + ::glDisable( GL_MULTISAMPLE ); + } + ::glDisable( GL_FOG ); + + break; + } + default: { + break; + } + } +} + +// configures, enables and disables specified texture units +void +opengl_renderer::setup_units( bool const Diffuse, bool const Shadows, bool const Reflections ) { + // helper texture unit. + // darkens previous stage, preparing data for the shadow texture unit to select from + if( m_helpertextureunit >= 0 ) { + + select_unit( m_helpertextureunit ); + + if( ( true == Reflections ) + || ( ( true == Global.RenderShadows ) && ( true == Shadows ) && ( false == Global.bWireFrame ) ) ) { + // we need to have texture on the helper for either the reflection and shadow generation (or both) + if( true == m_environmentcubetexturesupport ) { + // bind dynamic environment cube if it's enabled... + // NOTE: environment cube map isn't part of regular texture system, so we use direct bind call here + ::glBindTexture( GL_TEXTURE_CUBE_MAP, m_environmentcubetexture ); + ::glEnable( GL_TEXTURE_CUBE_MAP ); + } + else { + // ...otherwise fallback on static spherical image + m_textures.bind( textureunit::helper, m_reflectiontexture ); + ::glEnable( GL_TEXTURE_2D ); + } + } + else { + if( true == m_environmentcubetexturesupport ) { + ::glDisable( GL_TEXTURE_CUBE_MAP ); + } + else { + ::glDisable( GL_TEXTURE_2D ); + } + } + + if( ( true == Global.RenderShadows ) && ( true == Shadows ) && ( false == Global.bWireFrame ) ) { + + ::glTexEnvi( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE ); + ::glTexEnvfv( GL_TEXTURE_ENV, GL_TEXTURE_ENV_COLOR, glm::value_ptr( m_shadowcolor ) ); + + ::glTexEnvi( GL_TEXTURE_ENV, GL_COMBINE_RGB, GL_MODULATE ); // darken the previous stage + ::glTexEnvi( GL_TEXTURE_ENV, GL_SOURCE0_RGB, GL_PREVIOUS ); + ::glTexEnvi( GL_TEXTURE_ENV, GL_OPERAND0_RGB, GL_SRC_COLOR ); + ::glTexEnvi( GL_TEXTURE_ENV, GL_SOURCE1_RGB, GL_CONSTANT ); + ::glTexEnvi( GL_TEXTURE_ENV, GL_OPERAND1_RGB, GL_SRC_COLOR ); + + ::glTexEnvi( GL_TEXTURE_ENV, GL_COMBINE_ALPHA, GL_REPLACE ); // pass the previous stage alpha down the chain + ::glTexEnvi( GL_TEXTURE_ENV, GL_SOURCE0_ALPHA, GL_PREVIOUS ); + } + else { + + ::glTexEnvi( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE ); + ::glTexEnvi( GL_TEXTURE_ENV, GL_COMBINE_RGB, GL_REPLACE ); // pass the previous stage colour down the chain + ::glTexEnvi( GL_TEXTURE_ENV, GL_SOURCE0_RGB, GL_PREVIOUS ); + + ::glTexEnvi( GL_TEXTURE_ENV, GL_COMBINE_ALPHA, GL_REPLACE ); // pass the previous stage alpha down the chain + ::glTexEnvi( GL_TEXTURE_ENV, GL_SOURCE0_ALPHA, GL_PREVIOUS ); + } + + if( true == Reflections ) { + if( true == m_environmentcubetexturesupport ) { + ::glTexGeni( GL_S, GL_TEXTURE_GEN_MODE, GL_REFLECTION_MAP ); + ::glTexGeni( GL_T, GL_TEXTURE_GEN_MODE, GL_REFLECTION_MAP ); + ::glTexGeni( GL_R, GL_TEXTURE_GEN_MODE, GL_REFLECTION_MAP ); + ::glEnable( GL_TEXTURE_GEN_S ); + ::glEnable( GL_TEXTURE_GEN_T ); + ::glEnable( GL_TEXTURE_GEN_R ); + } + else { + // fixed texture fall back + ::glTexGeni( GL_S, GL_TEXTURE_GEN_MODE, GL_SPHERE_MAP ); + ::glTexGeni( GL_T, GL_TEXTURE_GEN_MODE, GL_SPHERE_MAP ); + ::glEnable( GL_TEXTURE_GEN_S ); + ::glEnable( GL_TEXTURE_GEN_T ); + } + } + else { + if( true == m_environmentcubetexturesupport ) { + ::glDisable( GL_TEXTURE_GEN_S ); + ::glDisable( GL_TEXTURE_GEN_T ); + ::glDisable( GL_TEXTURE_GEN_R ); + } + else { + ::glDisable( GL_TEXTURE_GEN_S ); + ::glDisable( GL_TEXTURE_GEN_T ); + } + } + } + // shadow texture unit. + // interpolates between primary colour and the previous unit, which should hold darkened variant of the primary colour + if( m_shadowtextureunit >= 0 ) { + if( ( true == Global.RenderShadows ) + && ( true == Shadows ) + && ( false == Global.bWireFrame ) + && ( m_shadowcolor != colors::white ) ) { + + select_unit( m_shadowtextureunit ); + // NOTE: texture and transformation matrix setup are done through separate call + ::glEnable( GL_TEXTURE_2D ); + // s + ::glEnable( GL_TEXTURE_GEN_S ); + // t + ::glEnable( GL_TEXTURE_GEN_T ); + // r + ::glEnable( GL_TEXTURE_GEN_R ); + // q + ::glEnable( GL_TEXTURE_GEN_Q ); + + ::glTexEnvi( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE ); + ::glTexEnvi( GL_TEXTURE_ENV, GL_COMBINE_RGB, GL_INTERPOLATE ); // choose between lit and lit * shadow colour, based on depth test + ::glTexEnvi( GL_TEXTURE_ENV, GL_SOURCE0_RGB, GL_PRIMARY_COLOR ); + ::glTexEnvi( GL_TEXTURE_ENV, GL_OPERAND0_RGB, GL_SRC_COLOR ); + ::glTexEnvi( GL_TEXTURE_ENV, GL_SOURCE1_RGB, GL_PREVIOUS ); + ::glTexEnvi( GL_TEXTURE_ENV, GL_OPERAND1_RGB, GL_SRC_COLOR ); + ::glTexEnvi( GL_TEXTURE_ENV, GL_SOURCE2_RGB, GL_TEXTURE ); + ::glTexEnvi( GL_TEXTURE_ENV, GL_OPERAND2_RGB, GL_SRC_COLOR ); + + ::glTexEnvi( GL_TEXTURE_ENV, GL_COMBINE_ALPHA, GL_REPLACE ); // pass the previous stage alpha down the chain + ::glTexEnvi( GL_TEXTURE_ENV, GL_SOURCE0_ALPHA, GL_PREVIOUS ); + } + else { + // turn off shadow map tests + select_unit( m_shadowtextureunit ); + + ::glDisable( GL_TEXTURE_2D ); + ::glDisable( GL_TEXTURE_GEN_S ); + ::glDisable( GL_TEXTURE_GEN_T ); + ::glDisable( GL_TEXTURE_GEN_R ); + ::glDisable( GL_TEXTURE_GEN_Q ); + } + } + // reflections/normals texture unit + // NOTE: comes after diffuse stage in the operation chain + if( m_normaltextureunit >= 0 ) { + + select_unit( m_normaltextureunit ); + + if( true == Reflections ) { + ::glEnable( GL_TEXTURE_2D ); + + ::glTexEnvi( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE ); + ::glTexEnvi( GL_TEXTURE_ENV, GL_COMBINE_RGB, GL_INTERPOLATE ); // blend between object colour and env.reflection + ::glTexEnvi( GL_TEXTURE_ENV, GL_SOURCE0_RGB, GL_TEXTURE0 ); + ::glTexEnvi( GL_TEXTURE_ENV, GL_OPERAND0_RGB, GL_SRC_COLOR ); + ::glTexEnvi( GL_TEXTURE_ENV, GL_SOURCE1_RGB, GL_PREVIOUS ); + ::glTexEnvi( GL_TEXTURE_ENV, GL_OPERAND1_RGB, GL_SRC_COLOR ); + ::glTexEnvi( GL_TEXTURE_ENV, GL_SOURCE2_RGB, GL_TEXTURE ); // alpha channel of the normal map controls reflection strength + ::glTexEnvi( GL_TEXTURE_ENV, GL_OPERAND2_RGB, GL_SRC_ALPHA ); + + ::glTexEnvi( GL_TEXTURE_ENV, GL_COMBINE_ALPHA, GL_REPLACE ); // pass the previous stage alpha down the chain + ::glTexEnvi( GL_TEXTURE_ENV, GL_SOURCE0_ALPHA, GL_PREVIOUS ); + } + else { + ::glDisable( GL_TEXTURE_2D ); + } + } + // diffuse texture unit. + // NOTE: diffuse texture mapping is never fully disabled, alpha channel information is always included + select_unit( m_diffusetextureunit ); + ::glEnable( GL_TEXTURE_2D ); + if( true == Diffuse ) { + // default behaviour, modulate with previous stage + ::glTexEnvi( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE ); + ::glTexEnvi( GL_TEXTURE_ENV, GL_COMBINE_RGB, GL_MODULATE ); + ::glTexEnvi( GL_TEXTURE_ENV, GL_SOURCE0_RGB, GL_TEXTURE ); + ::glTexEnvi( GL_TEXTURE_ENV, GL_OPERAND0_RGB, GL_SRC_COLOR ); +/* + ::glTexEnvi( GL_TEXTURE_ENV, GL_COMBINE_ALPHA, GL_MODULATE ); + ::glTexEnvi( GL_TEXTURE_ENV, GL_SOURCE0_ALPHA, GL_TEXTURE ); + ::glTexEnvi( GL_TEXTURE_ENV, GL_OPERAND0_ALPHA, GL_SRC_ALPHA ); +*/ + } + else { + // solid colour with texture alpha + ::glTexEnvi( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE ); + ::glTexEnvi( GL_TEXTURE_ENV, GL_COMBINE_RGB, GL_REPLACE ); + ::glTexEnvi( GL_TEXTURE_ENV, GL_SOURCE0_RGB, GL_PREVIOUS ); + ::glTexEnvi( GL_TEXTURE_ENV, GL_OPERAND0_RGB, GL_SRC_COLOR ); +/* + ::glTexEnvi( GL_TEXTURE_ENV, GL_COMBINE_ALPHA, GL_REPLACE ); + ::glTexEnvi( GL_TEXTURE_ENV, GL_SOURCE0_ALPHA, GL_TEXTURE ); + ::glTexEnvi( GL_TEXTURE_ENV, GL_OPERAND0_ALPHA, GL_SRC_ALPHA ); +*/ + } + // update unit state + m_unitstate.diffuse = Diffuse; + m_unitstate.shadows = Shadows; + m_unitstate.reflections = Reflections; +} + +// configures shadow texture unit for specified shadow map and conersion matrix +void +opengl_renderer::setup_shadow_map( GLuint const Texture, glm::mat4 const &Transformation ) { + + if( ( m_shadowtextureunit == -1 ) + || ( false == Global.RenderShadows ) + || ( true == Global.bWireFrame ) + || ( m_shadowcolor == colors::white ) ) { + // shadows are off + return; + } + + select_unit( m_shadowtextureunit ); + // NOTE: shadowmap isn't part of regular texture system, so we use direct bind call here + ::glBindTexture( GL_TEXTURE_2D, Texture ); + // s + ::glTexGenfv( GL_S, GL_EYE_PLANE, glm::value_ptr( glm::row( Transformation, 0 ) ) ); + // t + ::glTexGenfv( GL_T, GL_EYE_PLANE, glm::value_ptr( glm::row( Transformation, 1 ) ) ); + // r + ::glTexGenfv( GL_R, GL_EYE_PLANE, glm::value_ptr( glm::row( Transformation, 2 ) ) ); + // q + ::glTexGenfv( GL_Q, GL_EYE_PLANE, glm::value_ptr( glm::row( Transformation, 3 ) ) ); + + select_unit( m_diffusetextureunit ); +} + +// enables and disables specified texture units +void +opengl_renderer::switch_units( bool const Diffuse, bool const Shadows, bool const Reflections ) { + // helper texture unit. + if( m_helpertextureunit >= 0 ) { + + select_unit( m_helpertextureunit ); + if( ( true == Reflections ) + || ( ( true == Global.RenderShadows ) + && ( true == Shadows ) + && ( false == Global.bWireFrame ) + && ( m_shadowcolor != colors::white ) ) ) { + if( true == m_environmentcubetexturesupport ) { + ::glEnable( GL_TEXTURE_CUBE_MAP ); + } + else { + ::glEnable( GL_TEXTURE_2D ); + } + } + else { + if( true == m_environmentcubetexturesupport ) { + ::glDisable( GL_TEXTURE_CUBE_MAP ); + } + else { + ::glDisable( GL_TEXTURE_2D ); + } + } + } + // shadow texture unit. + if( m_shadowtextureunit >= 0 ) { + if( ( true == Global.RenderShadows ) && ( true == Shadows ) && ( false == Global.bWireFrame ) ) { + + select_unit( m_shadowtextureunit ); + ::glEnable( GL_TEXTURE_2D ); + } + else { + + select_unit( m_shadowtextureunit ); + ::glDisable( GL_TEXTURE_2D ); + } + } + // normal/reflection texture unit + if( m_normaltextureunit >= 0 ) { + if( true == Reflections ) { + + select_unit( m_normaltextureunit ); + ::glEnable( GL_TEXTURE_2D ); + } + else { + select_unit( m_normaltextureunit ); + ::glDisable( GL_TEXTURE_2D ); + } + } + // diffuse texture unit. + // NOTE: toggle actually disables diffuse texture mapping, unlike setup counterpart + if( true == Diffuse ) { + + select_unit( m_diffusetextureunit ); + ::glEnable( GL_TEXTURE_2D ); + } + else { + + select_unit( m_diffusetextureunit ); + ::glDisable( GL_TEXTURE_2D ); + } + // update unit state + m_unitstate.diffuse = Diffuse; + m_unitstate.shadows = Shadows; + m_unitstate.reflections = Reflections; +} + +void +opengl_renderer::setup_shadow_color( glm::vec4 const &Shadowcolor ) { + + select_unit( m_helpertextureunit ); + ::glTexEnvfv( GL_TEXTURE_ENV, GL_TEXTURE_ENV_COLOR, glm::value_ptr( Shadowcolor ) ); // in-shadow colour multiplier + select_unit( m_diffusetextureunit ); +} + +void +opengl_renderer::setup_environment_light( TEnvironmentType const Environment ) { + + switch( Environment ) { + case e_flat: { + m_sunlight.apply_intensity(); +// m_environment = Environment; + break; + } + case e_canyon: { + m_sunlight.apply_intensity( 0.4f ); +// m_environment = Environment; + break; + } + case e_tunnel: { + m_sunlight.apply_intensity( 0.2f ); +// m_environment = Environment; + break; + } + default: { + break; + } + } +} + +bool +opengl_renderer::Render( world_environment *Environment ) { + + // calculate shadow tone, based on positions of celestial bodies + m_shadowcolor = interpolate( + glm::vec4{ colors::shadow }, + glm::vec4{ colors::white }, + clamp( -Environment->m_sun.getAngle(), 0.f, 6.f ) / 6.f ); + if( ( Environment->m_sun.getAngle() < -18.f ) + && ( Environment->m_moon.getAngle() > 0.f ) ) { + // turn on moon shadows after nautical twilight, if the moon is actually up + m_shadowcolor = colors::shadow; + } + // soften shadows depending on sky overcast factor + m_shadowcolor = glm::min( + colors::white, + m_shadowcolor + ( ( colors::white - colors::shadow ) * Global.Overcast ) ); + + if( Global.bWireFrame ) { + // bez nieba w trybie rysowania linii + return false; + } + + Bind_Material( null_handle ); + ::glDisable( GL_LIGHTING ); + ::glDisable( GL_DEPTH_TEST ); + ::glDepthMask( GL_FALSE ); + // skydome + // drawn with 500m radius to blend in if the fog range is low + ::glPushMatrix(); + ::glScalef( 500.f, 500.f, 500.f ); + Environment->m_skydome.Render(); + ::glPopMatrix(); + // stars + if( Environment->m_stars.m_stars != nullptr ) { + // setup + ::glPushMatrix(); + ::glRotatef( Environment->m_stars.m_latitude, 1.f, 0.f, 0.f ); // ustawienie osi OY na północ + ::glRotatef( -std::fmod( (float)Global.fTimeAngleDeg, 360.f ), 0.f, 1.f, 0.f ); // obrót dobowy osi OX + ::glPointSize( 2.f ); + // render + GfxRenderer.Render( Environment->m_stars.m_stars, nullptr, 1.0 ); + // post-render cleanup + ::glPointSize( 3.f ); + ::glPopMatrix(); + } + // celestial bodies + if( DebugModeFlag == true ) { + // mark sun position for easier debugging + Environment->m_sun.render(); + Environment->m_moon.render(); + } + // render actual sun and moon + ::glPushAttrib( GL_ENABLE_BIT | GL_COLOR_BUFFER_BIT ); + + ::glDisable( GL_LIGHTING ); + ::glDisable( GL_ALPHA_TEST ); + ::glEnable( GL_BLEND ); + ::glBlendFunc( GL_SRC_ALPHA, GL_ONE ); + + auto const &modelview = OpenGLMatrices.data( GL_MODELVIEW ); + + auto const fogfactor { clamp( Global.fFogEnd / 2000.f, 0.f, 1.f ) }; // stronger fog reduces opacity of the celestial bodies + float const duskfactor = 1.0f - clamp( std::abs( Environment->m_sun.getAngle() ), 0.0f, 12.0f ) / 12.0f; + glm::vec3 suncolor = interpolate( + glm::vec3( 255.0f / 255.0f, 242.0f / 255.0f, 231.0f / 255.0f ), + glm::vec3( 235.0f / 255.0f, 140.0f / 255.0f, 36.0f / 255.0f ), + duskfactor ); + // sun + { + Bind_Texture( m_suntexture ); + ::glColor4f( suncolor.x, suncolor.y, suncolor.z, clamp( 1.5f - Global.Overcast, 0.f, 1.f ) * fogfactor ); + auto const sunvector = Environment->m_sun.getDirection(); + auto const sunposition = modelview * glm::vec4( sunvector.x, sunvector.y, sunvector.z, 1.0f ); + + ::glPushMatrix(); + ::glLoadIdentity(); // macierz jedynkowa + ::glTranslatef( sunposition.x, sunposition.y, sunposition.z ); // początek układu zostaje bez zmian + + float const size = 0.045f; + ::glBegin( GL_TRIANGLE_STRIP ); + ::glMultiTexCoord2f( m_diffusetextureunit, 1.f, 1.f ); ::glVertex3f( -size, size, 0.f ); + ::glMultiTexCoord2f( m_diffusetextureunit, 1.f, 0.f ); ::glVertex3f( -size, -size, 0.f ); + ::glMultiTexCoord2f( m_diffusetextureunit, 0.f, 1.f ); ::glVertex3f( size, size, 0.f ); + ::glMultiTexCoord2f( m_diffusetextureunit, 0.f, 0.f ); ::glVertex3f( size, -size, 0.f ); + ::glEnd(); + + ::glPopMatrix(); + } + // moon + { + Bind_Texture( m_moontexture ); + glm::vec3 mooncolor( 255.0f / 255.0f, 242.0f / 255.0f, 231.0f / 255.0f ); + ::glColor4f( + mooncolor.r, mooncolor.g, mooncolor.b, + // fade the moon if it's near the sun in the sky, especially during the day + std::max( + 0.f, + 1.0 + - 0.5 * Global.fLuminance + - 0.65 * std::max( 0.f, glm::dot( Environment->m_sun.getDirection(), Environment->m_moon.getDirection() ) ) ) + * fogfactor ); + + auto const moonposition = modelview * glm::vec4( Environment->m_moon.getDirection(), 1.0f ); + ::glPushMatrix(); + ::glLoadIdentity(); // macierz jedynkowa + ::glTranslatef( moonposition.x, moonposition.y, moonposition.z ); + + float const size = interpolate( // TODO: expose distance/scale factor from the moon object + 0.0175f, + 0.015f, + clamp( Environment->m_moon.getAngle(), 0.f, 90.f ) / 90.f ); + // choose the moon appearance variant, based on current moon phase + // NOTE: implementation specific, 8 variants are laid out in 3x3 arrangement + // from new moon onwards, top left to right bottom (last spot is left for future use, if any) + auto const moonphase = Environment->m_moon.getPhase(); + float moonu, moonv; + if( moonphase < 1.84566f ) { moonv = 1.0f - 0.0f; moonu = 0.0f; } + else if( moonphase < 5.53699f ) { moonv = 1.0f - 0.0f; moonu = 0.333f; } + else if( moonphase < 9.22831f ) { moonv = 1.0f - 0.0f; moonu = 0.667f; } + else if( moonphase < 12.91963f ) { moonv = 1.0f - 0.333f; moonu = 0.0f; } + else if( moonphase < 16.61096f ) { moonv = 1.0f - 0.333f; moonu = 0.333f; } + else if( moonphase < 20.30228f ) { moonv = 1.0f - 0.333f; moonu = 0.667f; } + else if( moonphase < 23.99361f ) { moonv = 1.0f - 0.667f; moonu = 0.0f; } + else if( moonphase < 27.68493f ) { moonv = 1.0f - 0.667f; moonu = 0.333f; } + else { moonv = 1.0f - 0.0f; moonu = 0.0f; } + + ::glBegin( GL_TRIANGLE_STRIP ); + ::glMultiTexCoord2f( m_diffusetextureunit, moonu, moonv ); ::glVertex3f( -size, size, 0.0f ); + ::glMultiTexCoord2f( m_diffusetextureunit, moonu, moonv - 0.333f ); ::glVertex3f( -size, -size, 0.0f ); + ::glMultiTexCoord2f( m_diffusetextureunit, moonu + 0.333f, moonv ); ::glVertex3f( size, size, 0.0f ); + ::glMultiTexCoord2f( m_diffusetextureunit, moonu + 0.333f, moonv - 0.333f ); ::glVertex3f( size, -size, 0.0f ); + ::glEnd(); + + ::glPopMatrix(); + } + ::glPopAttrib(); + + m_sunlight.apply_angle(); + m_sunlight.apply_intensity(); + + // clouds + if( Environment->m_clouds.mdCloud ) { + // setup + Disable_Lights(); + ::glEnable( GL_LIGHTING ); + ::glEnable( GL_LIGHT0 ); // other lights will be enabled during lights update + ::glLightModelfv( + GL_LIGHT_MODEL_AMBIENT, + glm::value_ptr( + interpolate( Environment->m_skydome.GetAverageColor(), suncolor, duskfactor * 0.25f ) + * interpolate( 1.f, 0.35f, Global.Overcast / 2.f ) // overcast darkens the clouds + * 0.5f // arbitrary adjustment factor + ) ); + // render + Render( Environment->m_clouds.mdCloud, nullptr, 100.0 ); + Render_Alpha( Environment->m_clouds.mdCloud, nullptr, 100.0 ); + // post-render cleanup + ::glLightModelfv( GL_LIGHT_MODEL_AMBIENT, glm::value_ptr( colors::none ) ); + ::glDisable( GL_LIGHTING ); + } + + ::glDepthMask( GL_TRUE ); + ::glEnable( GL_DEPTH_TEST ); + ::glEnable( GL_LIGHTING ); + + return true; +} + +// geometry methods +// creates a new geometry bank. returns: handle to the bank or NULL +gfx::geometrybank_handle +opengl_renderer::Create_Bank() { + + return m_geometry.create_bank(); +} + +// creates a new geometry chunk of specified type from supplied vertex data, in specified bank. returns: handle to the chunk or NULL +gfx::geometry_handle +opengl_renderer::Insert( gfx::vertex_array &Vertices, gfx::geometrybank_handle const &Geometry, int const Type ) { + + return m_geometry.create_chunk( Vertices, Geometry, Type ); +} + +// replaces data of specified chunk with the supplied vertex data, starting from specified offset +bool +opengl_renderer::Replace( gfx::vertex_array &Vertices, gfx::geometry_handle const &Geometry, std::size_t const Offset ) { + + return m_geometry.replace( Vertices, Geometry, Offset ); +} + +// adds supplied vertex data at the end of specified chunk +bool +opengl_renderer::Append( gfx::vertex_array &Vertices, gfx::geometry_handle const &Geometry ) { + + return m_geometry.append( Vertices, Geometry ); +} + +// provides direct access to vertex data of specfied chunk +gfx::vertex_array const & +opengl_renderer::Vertices( gfx::geometry_handle const &Geometry ) const { + + return m_geometry.vertices( Geometry ); +} + +// material methods +material_handle +opengl_renderer::Fetch_Material( std::string const &Filename, bool const Loadnow ) { + + return m_materials.create( Filename, Loadnow ); +} + +void +opengl_renderer::Bind_Material( material_handle const Material ) { + + auto const &material = m_materials.material( Material ); + if( false == Global.BasicRenderer ) { + m_textures.bind( textureunit::normals, material.texture2 ); + } + m_textures.bind( textureunit::diffuse, material.texture1 ); +} + +opengl_material const & +opengl_renderer::Material( material_handle const Material ) const { + + return m_materials.material( Material ); +} + +// texture methods +void +opengl_renderer::select_unit( GLint const Textureunit ) { + + return m_textures.unit( Textureunit ); +} + +texture_handle +opengl_renderer::Fetch_Texture( std::string const &Filename, bool const Loadnow ) { + + return m_textures.create( Filename, Loadnow ); +} + +void +opengl_renderer::Bind_Texture( texture_handle const Texture ) { + + m_textures.bind( textureunit::diffuse, Texture ); +} + +opengl_texture const & +opengl_renderer::Texture( texture_handle const Texture ) const { + + return m_textures.texture( Texture ); +} + +void +opengl_renderer::Render( scene::basic_region *Region ) { + + m_sectionqueue.clear(); + m_cellqueue.clear(); + // build a list of region sections to render + glm::vec3 const cameraposition { m_renderpass.camera.position() }; + auto const camerax = static_cast( std::floor( cameraposition.x / scene::EU07_SECTIONSIZE + scene::EU07_REGIONSIDESECTIONCOUNT / 2 ) ); + auto const cameraz = static_cast( std::floor( cameraposition.z / scene::EU07_SECTIONSIZE + scene::EU07_REGIONSIDESECTIONCOUNT / 2 ) ); + int const segmentcount = 2 * static_cast( std::ceil( m_renderpass.draw_range * Global.fDistanceFactor / scene::EU07_SECTIONSIZE ) ); + int const originx = camerax - segmentcount / 2; + int const originz = cameraz - segmentcount / 2; + + for( int row = originz; row <= originz + segmentcount; ++row ) { + if( row < 0 ) { continue; } + if( row >= scene::EU07_REGIONSIDESECTIONCOUNT ) { break; } + for( int column = originx; column <= originx + segmentcount; ++column ) { + if( column < 0 ) { continue; } + if( column >= scene::EU07_REGIONSIDESECTIONCOUNT ) { break; } + auto *section { Region->m_sections[ row * scene::EU07_REGIONSIDESECTIONCOUNT + column ] }; + if( ( section != nullptr ) + && ( m_renderpass.camera.visible( section->m_area ) ) ) { + m_sectionqueue.emplace_back( section ); + } + } + } + + switch( m_renderpass.draw_mode ) { + case rendermode::color: { + + Update_Lights( simulation::Lights ); + + Render( std::begin( m_sectionqueue ), std::end( m_sectionqueue ) ); + if( EditorModeFlag ) { + // when editor mode is active calculate world position of the cursor + // at this stage the z-buffer is filled with only ground geometry + Update_Mouse_Position(); + } + // draw queue is filled while rendering sections + Render( std::begin( m_cellqueue ), std::end( m_cellqueue ) ); + break; + } + case rendermode::shadows: + case rendermode::pickscenery: { + // these render modes don't bother with lights + Render( std::begin( m_sectionqueue ), std::end( m_sectionqueue ) ); + // they can also skip queue sorting, as they only deal with opaque geometry + // NOTE: there's benefit from rendering front-to-back, but is it significant enough? TODO: investigate + Render( std::begin( m_cellqueue ), std::end( m_cellqueue ) ); + break; + } + case rendermode::reflections: { + // for the time being reflections render only terrain geometry + Render( std::begin( m_sectionqueue ), std::end( m_sectionqueue ) ); + break; + } + case rendermode::pickcontrols: + default: { + // no need to render anything ourside of the cab in control picking mode + break; + } + } +} + +void +opengl_renderer::Render( section_sequence::iterator First, section_sequence::iterator Last ) { + + switch( m_renderpass.draw_mode ) { + case rendermode::color: + case rendermode::reflections: { + + break; + } + case rendermode::shadows: { + // experimental, for shadows render both back and front faces, to supply back faces of the 'forest strips' + ::glDisable( GL_CULL_FACE ); + break; } + case rendermode::pickscenery: { + // non-interactive scenery elements get neutral colour + ::glColor3fv( glm::value_ptr( colors::none ) ); + break; + } + default: { + break; } + } + + while( First != Last ) { + + auto *section = *First; + section->create_geometry(); + + // render shapes held by the section + switch( m_renderpass.draw_mode ) { + case rendermode::color: + case rendermode::reflections: + case rendermode::shadows: + case rendermode::pickscenery: { + if( false == section->m_shapes.empty() ) { + // since all shapes of the section share center point we can optimize out a few calls here + ::glPushMatrix(); + auto const originoffset { section->m_area.center - m_renderpass.camera.position() }; + ::glTranslated( originoffset.x, originoffset.y, originoffset.z ); + // render + for( auto const &shape : section->m_shapes ) { Render( shape, true ); } + // post-render cleanup + ::glPopMatrix(); + } + break; + } + case rendermode::pickcontrols: + default: { + break; + } + } + + // add the section's cells to the cell queue + switch( m_renderpass.draw_mode ) { + case rendermode::color: + case rendermode::shadows: + case rendermode::pickscenery: { + for( auto &cell : section->m_cells ) { + if( ( true == cell.m_active ) + && ( m_renderpass.camera.visible( cell.m_area ) ) ) { + // store visible cells with content as well as their current distance, for sorting later + m_cellqueue.emplace_back( + glm::length2( m_renderpass.camera.position() - cell.m_area.center ), + &cell ); + } + } + break; + } + case rendermode::reflections: + case rendermode::pickcontrols: + default: { + break; + } + } + // proceed to next section + ++First; + } + + switch( m_renderpass.draw_mode ) { + case rendermode::shadows: { + // restore standard face cull mode + ::glEnable( GL_CULL_FACE ); + break; } + default: { + break; } + } +} + +void +opengl_renderer::Render( cell_sequence::iterator First, cell_sequence::iterator Last ) { + + // cache initial iterator for the second sweep + auto first { First }; + // first pass draws elements which we know are located in section banks, to reduce vbo switching + while( First != Last ) { + + auto *cell = First->second; + // przeliczenia animacji torów w sektorze + cell->RaAnimate( m_framestamp ); + + switch( m_renderpass.draw_mode ) { + case rendermode::color: { + // since all shapes of the section share center point we can optimize out a few calls here + ::glPushMatrix(); + auto const originoffset { cell->m_area.center - m_renderpass.camera.position() }; + ::glTranslated( originoffset.x, originoffset.y, originoffset.z ); + + // render + // opaque non-instanced shapes + for( auto const &shape : cell->m_shapesopaque ) { Render( shape, false ); } + // tracks + // TODO: update after path node refactoring + Render( std::begin( cell->m_paths ), std::end( cell->m_paths ) ); +#ifdef EU07_USE_DEBUG_CULLING + // debug + ::glLineWidth( 2.f ); + float const width = cell->m_area.radius; + float const height = cell->m_area.radius * 0.2f; + glDisable( GL_LIGHTING ); + glDisable( GL_TEXTURE_2D ); + glColor3ub( 255, 128, 128 ); + glBegin( GL_LINE_LOOP ); + glVertex3f( -width, height, width ); + glVertex3f( -width, height, -width ); + glVertex3f( width, height, -width ); + glVertex3f( width, height, width ); + glEnd(); + glBegin( GL_LINE_LOOP ); + glVertex3f( -width, 0, width ); + glVertex3f( -width, 0, -width ); + glVertex3f( width, 0, -width ); + glVertex3f( width, 0, width ); + glEnd(); + glBegin( GL_LINES ); + glVertex3f( -width, height, width ); glVertex3f( -width, 0, width ); + glVertex3f( -width, height, -width ); glVertex3f( -width, 0, -width ); + glVertex3f( width, height, -width ); glVertex3f( width, 0, -width ); + glVertex3f( width, height, width ); glVertex3f( width, 0, width ); + glEnd(); + glColor3ub( 255, 255, 255 ); + glEnable( GL_TEXTURE_2D ); + glEnable( GL_LIGHTING ); + glLineWidth( 1.f ); +#endif + // post-render cleanup + ::glPopMatrix(); + + break; + } + case rendermode::shadows: { + // since all shapes of the section share center point we can optimize out a few calls here + ::glPushMatrix(); + auto const originoffset { cell->m_area.center - m_renderpass.camera.position() }; + ::glTranslated( originoffset.x, originoffset.y, originoffset.z ); + + // render + // opaque non-instanced shapes + for( auto const &shape : cell->m_shapesopaque ) { Render( shape, false ); } + // tracks + Render( std::begin( cell->m_paths ), std::end( cell->m_paths ) ); + + // post-render cleanup + ::glPopMatrix(); + + break; + } + case rendermode::pickscenery: { + // same procedure like with regular render, but editor-enabled nodes receive custom colour used for picking + // since all shapes of the section share center point we can optimize out a few calls here + ::glPushMatrix(); + auto const originoffset { cell->m_area.center - m_renderpass.camera.position() }; + ::glTranslated( originoffset.x, originoffset.y, originoffset.z ); + // render + // opaque non-instanced shapes + // non-interactive scenery elements get neutral colour + ::glColor3fv( glm::value_ptr( colors::none ) ); + for( auto const &shape : cell->m_shapesopaque ) { Render( shape, false ); } + // tracks + for( auto *path : cell->m_paths ) { + ::glColor3fv( glm::value_ptr( pick_color( m_picksceneryitems.size() + 1 ) ) ); + Render( path ); + } + + // post-render cleanup + ::glPopMatrix(); + + break; + } + case rendermode::reflections: + case rendermode::pickcontrols: + default: { + break; + } + } + + ++First; + } + // second pass draws elements with their own vbos + while( first != Last ) { + + auto const *cell = first->second; + + switch( m_renderpass.draw_mode ) { + case rendermode::color: + case rendermode::shadows: { + // opaque parts of instanced models + for( auto *instance : cell->m_instancesopaque ) { Render( instance ); } + // opaque parts of vehicles + for( auto *path : cell->m_paths ) { + for( auto *dynamic : path->Dynamics ) { + Render( dynamic ); + } + } + // memcells + if( ( EditorModeFlag ) + && ( DebugModeFlag ) ) { + ::glPushAttrib( GL_ENABLE_BIT ); + ::glDisable( GL_TEXTURE_2D ); + ::glColor3f( 0.36f, 0.75f, 0.35f ); + for( auto *memorycell : cell->m_memorycells ) { + Render( memorycell ); + } + ::glPopAttrib(); + } + break; + } + case rendermode::pickscenery: { + // opaque parts of instanced models + // same procedure like with regular render, but each node receives custom colour used for picking + for( auto *instance : cell->m_instancesopaque ) { + ::glColor3fv( glm::value_ptr( pick_color( m_picksceneryitems.size() + 1 ) ) ); + Render( instance ); + } + // memcells + if( ( EditorModeFlag ) + && ( DebugModeFlag ) ) { + for( auto *memorycell : cell->m_memorycells ) { + ::glColor3fv( glm::value_ptr( pick_color( m_picksceneryitems.size() + 1 ) ) ); + Render( memorycell ); + } + } + // vehicles aren't included in scenery picking for the time being + break; + } + case rendermode::reflections: + case rendermode::pickcontrols: + default: { + break; + } + } + + ++first; + } +#ifdef EU07_USE_DEBUG_SOUNDEMITTERS + // sound emitters + if( DebugModeFlag ) { + switch( m_renderpass.draw_mode ) { + case rendermode::color: { + + ::glPushAttrib( GL_ENABLE_BIT ); + ::glDisable( GL_TEXTURE_2D ); + ::glColor3f( 0.36f, 0.75f, 0.35f ); + + for( auto const &audiosource : audio::renderer.m_sources ) { + + ::glPushMatrix(); + auto const position = audiosource.properties.location - m_renderpass.camera.position(); + ::glTranslated( position.x, position.y, position.z ); + + ::gluSphere( m_quadric, 0.1, 4, 2 ); + + ::glPopMatrix(); + } + + ::glPopAttrib(); + + break; + } + default: { + break; + } + } + } +#endif + +} + +void +opengl_renderer::Render( scene::shape_node const &Shape, bool const Ignorerange ) { + + auto const &data { Shape.data() }; + + if( false == Ignorerange ) { + double distancesquared; + switch( m_renderpass.draw_mode ) { + case rendermode::shadows: { + // 'camera' for the light pass is the light source, but we need to draw what the 'real' camera sees + distancesquared = Math3D::SquareMagnitude( ( data.area.center - Global.pCamera.Pos ) / Global.ZoomFactor ) / Global.fDistanceFactor; + break; + } + default: { + distancesquared = glm::length2( ( data.area.center - m_renderpass.camera.position() ) / (double)Global.ZoomFactor ) / Global.fDistanceFactor; + break; + } + } + if( ( distancesquared < data.rangesquared_min ) + || ( distancesquared >= data.rangesquared_max ) ) { + return; + } + } + + // setup + Bind_Material( data.material ); + switch( m_renderpass.draw_mode ) { + case rendermode::color: + case rendermode::reflections: { + ::glColor3fv( glm::value_ptr( data.lighting.diffuse ) ); +/* + // NOTE: ambient component is set by diffuse component + // NOTE: for the time being non-instanced shapes are rendered without specular component due to wrong/arbitrary values set in legacy scenarios + // TBD, TODO: find a way to resolve this with the least amount of tears? + ::glMaterialfv( GL_FRONT, GL_SPECULAR, glm::value_ptr( data.lighting.specular * m_sunlight.specular.a * m_specularopaquescalefactor ) ); +*/ + break; + } + // pick modes are painted with custom colours, and shadow pass doesn't use any + case rendermode::shadows: + case rendermode::pickscenery: + case rendermode::pickcontrols: + default: { + break; + } + } + // render + m_geometry.draw( data.geometry ); + // debug data + ++m_debugstats.shapes; + ++m_debugstats.drawcalls; +} + +void +opengl_renderer::Render( TAnimModel *Instance ) { + + if( false == Instance->m_visible ) { + return; + } + + double distancesquared; + switch( m_renderpass.draw_mode ) { + case rendermode::shadows: { + // 'camera' for the light pass is the light source, but we need to draw what the 'real' camera sees + distancesquared = Math3D::SquareMagnitude( ( Instance->location() - Global.pCamera.Pos ) / Global.ZoomFactor ) / Global.fDistanceFactor; + break; + } + default: { + distancesquared = Math3D::SquareMagnitude( ( Instance->location() - m_renderpass.camera.position() ) / (double)Global.ZoomFactor ) / Global.fDistanceFactor; + break; + } + } + if( ( distancesquared < Instance->m_rangesquaredmin ) + || ( distancesquared >= Instance->m_rangesquaredmax ) ) { + return; + } + + switch( m_renderpass.draw_mode ) { + case rendermode::pickscenery: { + // add the node to the pick list + m_picksceneryitems.emplace_back( Instance ); + break; + } + default: { + break; + } + } + + Instance->RaAnimate( m_framestamp ); // jednorazowe przeliczenie animacji + Instance->RaPrepare(); + if( Instance->pModel ) { + // renderowanie rekurencyjne submodeli + Render( + Instance->pModel, + Instance->Material(), + distancesquared, + Instance->location() - m_renderpass.camera.position(), + Instance->vAngle ); + } +} + +bool +opengl_renderer::Render( TDynamicObject *Dynamic ) { + + Dynamic->renderme = m_renderpass.camera.visible( Dynamic ); + if( false == Dynamic->renderme ) { + return false; + } + // debug data + ++m_debugstats.dynamics; + + // setup + TSubModel::iInstance = reinterpret_cast( Dynamic ); //żeby nie robić cudzych animacji + glm::dvec3 const originoffset = Dynamic->vPosition - m_renderpass.camera.position(); + // lod visibility ranges are defined for base (x 1.0) viewing distance. for render we adjust them for actual range multiplier and zoom + float squaredistance; + switch( m_renderpass.draw_mode ) { + case rendermode::shadows: { + squaredistance = glm::length2( glm::vec3{ glm::dvec3{ Dynamic->vPosition - Global.pCamera.Pos } } / Global.ZoomFactor ) / Global.fDistanceFactor; + break; + } + default: { + squaredistance = glm::length2( glm::vec3{ originoffset } / Global.ZoomFactor ) / Global.fDistanceFactor; + break; + } + } + Dynamic->ABuLittleUpdate( squaredistance ); // ustawianie zmiennych submodeli dla wspólnego modelu + ::glPushMatrix(); + + ::glTranslated( originoffset.x, originoffset.y, originoffset.z ); + ::glMultMatrixd( Dynamic->mMatrix.getArray() ); + + switch( m_renderpass.draw_mode ) { + + case rendermode::color: { + if( Dynamic->fShade > 0.0f ) { + // change light level based on light level of the occupied track + m_sunlight.apply_intensity( Dynamic->fShade ); + } + m_renderspecular = true; // vehicles are rendered with specular component. static models without, at least for the time being + // render + if( Dynamic->mdLowPolyInt ) { + // low poly interior + if( FreeFlyModeFlag ? true : !Dynamic->mdKabina || !Dynamic->bDisplayCab ) { + // enable cab light if needed + if( Dynamic->InteriorLightLevel > 0.0f ) { + + // crude way to light the cabin, until we have something more complete in place + ::glLightModelfv( GL_LIGHT_MODEL_AMBIENT, glm::value_ptr( Dynamic->InteriorLight * Dynamic->InteriorLightLevel ) ); + } + + Render( Dynamic->mdLowPolyInt, Dynamic->Material(), squaredistance ); + + if( Dynamic->InteriorLightLevel > 0.0f ) { + // reset the overall ambient + ::glLightModelfv( GL_LIGHT_MODEL_AMBIENT, glm::value_ptr( m_baseambient ) ); + } + } + } + + if( Dynamic->mdModel ) + Render( Dynamic->mdModel, Dynamic->Material(), squaredistance ); + + if( Dynamic->mdLoad ) // renderowanie nieprzezroczystego ładunku + Render( Dynamic->mdLoad, Dynamic->Material(), squaredistance, { 0.f, Dynamic->LoadOffset, 0.f }, {} ); + + // post-render cleanup + m_renderspecular = false; + if( Dynamic->fShade > 0.0f ) { + // restore regular light level + m_sunlight.apply_intensity(); + } + break; + } + case rendermode::shadows: { + if( Dynamic->mdLowPolyInt ) { + // low poly interior + if( FreeFlyModeFlag ? true : !Dynamic->mdKabina || !Dynamic->bDisplayCab ) { + Render( Dynamic->mdLowPolyInt, Dynamic->Material(), squaredistance ); + } + } + if( Dynamic->mdModel ) + Render( Dynamic->mdModel, Dynamic->Material(), squaredistance ); + if( Dynamic->mdLoad ) // renderowanie nieprzezroczystego ładunku + Render( Dynamic->mdLoad, Dynamic->Material(), squaredistance ); + // post-render cleanup + break; + } + case rendermode::pickcontrols: + case rendermode::pickscenery: + default: { + break; + } + } + + ::glPopMatrix(); + + // TODO: check if this reset is needed. In theory each object should render all parts based on its own instance data anyway? + if( Dynamic->btnOn ) + Dynamic->TurnOff(); // przywrócenie domyślnych pozycji submodeli + + return true; +} + +// rendering kabiny gdy jest oddzielnym modelem i ma byc wyswietlana +bool +opengl_renderer::Render_cab( TDynamicObject const *Dynamic, bool const Alpha ) { + + if( Dynamic == nullptr ) { + + TSubModel::iInstance = 0; + return false; + } + + TSubModel::iInstance = reinterpret_cast( Dynamic ); + + if( ( true == FreeFlyModeFlag ) + || ( false == Dynamic->bDisplayCab ) + || ( Dynamic->mdKabina == Dynamic->mdModel ) ) { + // ABu: Rendering kabiny jako ostatniej, zeby bylo widac przez szyby, tylko w widoku ze srodka + return false; + } + + if( Dynamic->mdKabina ) { // bo mogła zniknąć przy przechodzeniu do innego pojazdu + // setup shared by all render paths + ::glPushMatrix(); + + auto const originoffset = Dynamic->GetPosition() - m_renderpass.camera.position(); + ::glTranslated( originoffset.x, originoffset.y, originoffset.z ); + ::glMultMatrixd( Dynamic->mMatrix.readArray() ); + + switch( m_renderpass.draw_mode ) { + case rendermode::color: { + // render path specific setup: + if( Dynamic->fShade > 0.0f ) { + // change light level based on light level of the occupied track + m_sunlight.apply_intensity( Dynamic->fShade ); + } + if( Dynamic->InteriorLightLevel > 0.f ) { + // crude way to light the cabin, until we have something more complete in place + ::glLightModelfv( GL_LIGHT_MODEL_AMBIENT, glm::value_ptr( Dynamic->InteriorLight * Dynamic->InteriorLightLevel ) ); + } + // render + if( true == Alpha ) { + // translucent parts + Render_Alpha( Dynamic->mdKabina, Dynamic->Material(), 0.0 ); + } + else { + // opaque parts + Render( Dynamic->mdKabina, Dynamic->Material(), 0.0 ); + } + // post-render restore + if( Dynamic->fShade > 0.0f ) { + // change light level based on light level of the occupied track + m_sunlight.apply_intensity(); + } + if( Dynamic->InteriorLightLevel > 0.0f ) { + // reset the overall ambient + ::glLightModelfv( GL_LIGHT_MODEL_AMBIENT, glm::value_ptr(m_baseambient) ); + } + break; + } + case rendermode::cabshadows: { + // cab shadowmap mode skips lighting setup and translucent parts + // render + if( true == Alpha ) { + // translucent parts + Render_Alpha( Dynamic->mdKabina, Dynamic->Material(), 0.0 ); + } + else { + // opaque parts + Render( Dynamic->mdKabina, Dynamic->Material(), 0.0 ); + } + // since the setup is simpler, there's nothing to reset afterwards + break; + } + case rendermode::pickcontrols: { + // control picking mode skips lighting setup and translucent parts + // render + Render( Dynamic->mdKabina, Dynamic->Material(), 0.0 ); + // since the setup is simpler, there's nothing to reset afterwards + break; + } + default: { + break; + } + } + // post-render restore + ::glPopMatrix(); + } + + return true; +} + +bool +opengl_renderer::Render( TModel3d *Model, material_data const *Material, float const Squaredistance ) { + + auto alpha = + ( Material != nullptr ? + Material->textures_alpha : + 0x30300030 ); + alpha ^= 0x0F0F000F; // odwrócenie flag tekstur, aby wyłapać nieprzezroczyste + if( 0 == ( alpha & Model->iFlags & 0x1F1F001F ) ) { + // czy w ogóle jest co robić w tym cyklu? + return false; + } + + Model->Root->fSquareDist = Squaredistance; // zmienna globalna! + + // setup + Model->Root->ReplacableSet( + ( Material != nullptr ? + Material->replacable_skins : + nullptr ), + alpha ); + + Model->Root->pRoot = Model; + + // render + Render( Model->Root ); + + // debug data + ++m_debugstats.models; + + // post-render cleanup + + return true; +} + +bool +opengl_renderer::Render( TModel3d *Model, material_data const *Material, float const Squaredistance, Math3D::vector3 const &Position, glm::vec3 const &Angle ) { + + ::glPushMatrix(); + ::glTranslated( Position.x, Position.y, Position.z ); + if( Angle.y != 0.0 ) + ::glRotatef( Angle.y, 0.f, 1.f, 0.f ); + if( Angle.x != 0.0 ) + ::glRotatef( Angle.x, 1.f, 0.f, 0.f ); + if( Angle.z != 0.0 ) + ::glRotatef( Angle.z, 0.f, 0.f, 1.f ); + + auto const result = Render( Model, Material, Squaredistance ); + + ::glPopMatrix(); + + return result; +} + +void +opengl_renderer::Render( TSubModel *Submodel ) { + + if( ( Submodel->iVisible ) + && ( TSubModel::fSquareDist >= Submodel->fSquareMinDist ) + && ( TSubModel::fSquareDist < Submodel->fSquareMaxDist ) ) { + + // debug data + ++m_debugstats.submodels; + ++m_debugstats.drawcalls; + + if( Submodel->iFlags & 0xC000 ) { + ::glPushMatrix(); + if( Submodel->fMatrix ) + ::glMultMatrixf( Submodel->fMatrix->readArray() ); + if( Submodel->b_Anim != TAnimType::at_None ) + Submodel->RaAnimation( Submodel->b_Anim ); + } + + if( Submodel->eType < TP_ROTATOR ) { + // renderowanie obiektów OpenGL + if( Submodel->iAlpha & Submodel->iFlags & 0x1F ) { + // rysuj gdy element nieprzezroczysty + switch( m_renderpass.draw_mode ) { + case rendermode::color: + case rendermode::reflections: { +// NOTE: code disabled as normalization marking doesn't take into account scaling propagation down hierarchy chains +// for the time being we'll do with enforced worst-case scaling method, when speculars are enabled +#ifdef EU07_USE_OPTIMIZED_NORMALIZATION + switch( Submodel->m_normalizenormals ) { + case TSubModel::normalize: { + ::glEnable( GL_NORMALIZE ); break; } + case TSubModel::rescale: { + ::glEnable( GL_RESCALE_NORMAL ); break; } + default: { + break; } + } +#else + if( true == m_renderspecular ) { + ::glEnable( GL_NORMALIZE ); + } +#endif + // material configuration: + // textures... + if( Submodel->m_material < 0 ) { // zmienialne skóry + Bind_Material( Submodel->ReplacableSkinId[ -Submodel->m_material ] ); + } + else { + // również 0 + Bind_Material( Submodel->m_material ); + } + // ...colors... + if( Submodel->fVisible < 1.f ) { + // setup + ::glAlphaFunc( GL_GREATER, 0.f ); + ::glEnable( GL_BLEND ); + ::glColor4f( + Submodel->f4Diffuse.r, + Submodel->f4Diffuse.g, + Submodel->f4Diffuse.b, + Submodel->fVisible ); + } + else { + ::glColor3fv( glm::value_ptr( Submodel->f4Diffuse ) ); // McZapkie-240702: zamiast ub + } + // ...specular... + if( ( true == m_renderspecular ) && ( m_sunlight.specular.a > 0.01f ) ) { + // specular strength in legacy models is set uniformly to 150, 150, 150 so we scale it down for opaque elements + ::glMaterialfv( GL_FRONT, GL_SPECULAR, glm::value_ptr( Submodel->f4Specular * m_sunlight.specular.a * m_specularopaquescalefactor ) ); + ::glEnable( GL_RESCALE_NORMAL ); + } + // ...luminance + auto const unitstate = m_unitstate; + if( Global.fLuminance < Submodel->fLight ) { + // zeby swiecilo na kolorowo + ::glMaterialfv( GL_FRONT, GL_EMISSION, glm::value_ptr( Submodel->f4Diffuse * Submodel->f4Emision.a ) ); + // disable shadows so they don't obstruct self-lit items +/* + setup_shadow_color( colors::white ); +*/ + switch_units( unitstate.diffuse, false, false ); + } + + // main draw call + m_geometry.draw( Submodel->m_geometry ); +/* + if( DebugModeFlag ) { + auto const & vertices { m_geometry.vertices( Submodel->m_geometry ) }; + ::glBegin( GL_LINES ); + for( auto const &vertex : vertices ) { + ::glVertex3fv( glm::value_ptr( vertex.position ) ); + ::glVertex3fv( glm::value_ptr( vertex.position + vertex.normal * 0.2f ) ); + } + ::glEnd(); + } +*/ + // post-draw reset + if( Submodel->fVisible < 1.f ) { + ::glAlphaFunc( GL_GREATER, 0.5f ); + ::glDisable( GL_BLEND ); + } + if( ( true == m_renderspecular ) && ( m_sunlight.specular.a > 0.01f ) ) { + ::glMaterialfv( GL_FRONT, GL_SPECULAR, glm::value_ptr( colors::none ) ); + } + if( Global.fLuminance < Submodel->fLight ) { + // restore default (lack of) brightness + ::glMaterialfv( GL_FRONT, GL_EMISSION, glm::value_ptr( colors::none ) ); +/* + setup_shadow_color( m_shadowcolor ); +*/ + switch_units( unitstate.diffuse, unitstate.shadows, unitstate.reflections ); + } +#ifdef EU07_USE_OPTIMIZED_NORMALIZATION + switch( Submodel->m_normalizenormals ) { + case TSubModel::normalize: { + ::glDisable( GL_NORMALIZE ); break; } + case TSubModel::rescale: { + ::glDisable( GL_RESCALE_NORMAL ); break; } + default: { + break; } + } +#else + if( true == m_renderspecular ) { + ::glDisable( GL_NORMALIZE ); + } +#endif + break; + } + case rendermode::shadows: + case rendermode::cabshadows: + case rendermode::pickscenery: { + // scenery picking and shadow both use enforced colour and no frills + // material configuration: + // textures... + if( Submodel->m_material < 0 ) { // zmienialne skóry + Bind_Material( Submodel->ReplacableSkinId[ -Submodel->m_material ] ); + } + else { + // również 0 + Bind_Material( Submodel->m_material ); + } + // main draw call + m_geometry.draw( Submodel->m_geometry ); + // post-draw reset + break; + } + case rendermode::pickcontrols: { + // material configuration: + // control picking applies individual colour for each submodel + m_pickcontrolsitems.emplace_back( Submodel ); + ::glColor3fv( glm::value_ptr( pick_color( m_pickcontrolsitems.size() ) ) ); + // textures... + if( Submodel->m_material < 0 ) { // zmienialne skóry + Bind_Material( Submodel->ReplacableSkinId[ -Submodel->m_material ] ); + } + else { + // również 0 + Bind_Material( Submodel->m_material ); + } + // main draw call + m_geometry.draw( Submodel->m_geometry ); + // post-draw reset + break; + } + default: { + break; + } + } + } + } + else if( Submodel->eType == TP_FREESPOTLIGHT ) { + + switch( m_renderpass.draw_mode ) { + // spotlights are only rendered in colour mode(s) + case rendermode::color: + case rendermode::reflections: { + auto const &modelview = OpenGLMatrices.data( GL_MODELVIEW ); + auto const lightcenter = + modelview + * interpolate( + glm::vec4( 0.f, 0.f, -0.05f, 1.f ), + glm::vec4( 0.f, 0.f, -0.25f, 1.f ), + static_cast( TSubModel::fSquareDist / Submodel->fSquareMaxDist ) ); // pozycja punktu świecącego względem kamery + Submodel->fCosViewAngle = glm::dot( glm::normalize( modelview * glm::vec4( 0.f, 0.f, -1.f, 1.f ) - lightcenter ), glm::normalize( -lightcenter ) ); + + if( Submodel->fCosViewAngle > Submodel->fCosFalloffAngle ) { + // kąt większy niż maksymalny stożek swiatła + float lightlevel = 1.f; // TODO, TBD: parameter to control light strength + // view angle attenuation + float const anglefactor = clamp( + ( Submodel->fCosViewAngle - Submodel->fCosFalloffAngle ) / ( Submodel->fCosHotspotAngle - Submodel->fCosFalloffAngle ), + 0.f, 1.f ); + lightlevel *= anglefactor; + // distance attenuation. NOTE: since it's fixed pipeline with built-in gamma correction we're using linear attenuation + // we're capping how much effect the distance attenuation can have, otherwise the lights get too tiny at regular distances + float const distancefactor { std::max( 0.5f, ( Submodel->fSquareMaxDist - TSubModel::fSquareDist ) / Submodel->fSquareMaxDist ) }; + auto const pointsize { std::max( 3.f, 5.f * distancefactor * anglefactor ) }; + // additionally reduce light strength for farther sources in rain or snow + if( Global.Overcast > 0.75f ) { + float const precipitationfactor{ + interpolate( + interpolate( 1.f, 0.25f, clamp( Global.Overcast * 0.75f - 0.5f, 0.f, 1.f ) ), + 1.f, + distancefactor ) }; + lightlevel *= precipitationfactor; + } + + if( lightlevel > 0.f ) { + // material configuration: + Bind_Material( null_handle ); + // limit impact of dense fog on the lights + ::glFogf( GL_FOG_DENSITY, static_cast( 1.0 / std::min( Global.fFogEnd, m_fogrange * 2 ) ) ); + + ::glPushAttrib( GL_ENABLE_BIT | GL_COLOR_BUFFER_BIT | GL_POINT_BIT ); + ::glDisable( GL_LIGHTING ); + ::glEnable( GL_BLEND ); + ::glAlphaFunc( GL_GREATER, 0.f ); + + ::glPushMatrix(); + ::glLoadIdentity(); + ::glTranslatef( lightcenter.x, lightcenter.y, lightcenter.z ); // początek układu zostaje bez zmian + + auto const unitstate = m_unitstate; + switch_units( m_unitstate.diffuse, false, false ); + + // main draw call + if( Global.Overcast > 1.f ) { + // fake fog halo + float const fogfactor { + interpolate( + 2.f, 1.f, + clamp( Global.fFogEnd / 2000, 0.f, 1.f ) ) + * std::max( 1.f, Global.Overcast ) }; + ::glPointSize( pointsize * fogfactor ); + ::glColor4f( + Submodel->f4Diffuse[ 0 ], + Submodel->f4Diffuse[ 1 ], + Submodel->f4Diffuse[ 2 ], + Submodel->fVisible * std::min( 1.f, lightlevel ) * 0.5f ); + ::glDepthMask( GL_FALSE ); + m_geometry.draw( Submodel->m_geometry ); + ::glDepthMask( GL_TRUE ); + } + ::glPointSize( pointsize ); + ::glColor4f( + Submodel->f4Diffuse[ 0 ], + Submodel->f4Diffuse[ 1 ], + Submodel->f4Diffuse[ 2 ], + Submodel->fVisible * std::min( 1.f, lightlevel ) ); + m_geometry.draw( Submodel->m_geometry ); + + // post-draw reset + switch_units( unitstate.diffuse, unitstate.shadows, unitstate.reflections ); + + ::glPopMatrix(); + ::glPopAttrib(); + ::glFogf( GL_FOG_DENSITY, static_cast( 1.0 / m_fogrange ) ); + } + } + break; + } + default: { + break; + } + } + } + else if( Submodel->eType == TP_STARS ) { + + switch( m_renderpass.draw_mode ) { + // colour points are only rendered in colour mode(s) + case rendermode::color: + case rendermode::reflections: { + if( Global.fLuminance < Submodel->fLight ) { + + // material configuration: + ::glPushAttrib( GL_ENABLE_BIT ); + + Bind_Material( null_handle ); + ::glDisable( GL_LIGHTING ); + + // main draw call + m_geometry.draw( Submodel->m_geometry, gfx::color_streams ); + + // post-draw reset + ::glPopAttrib(); + } + break; + } + default: { + break; + } + } + } + if( Submodel->Child != nullptr ) + if( Submodel->iAlpha & Submodel->iFlags & 0x001F0000 ) + Render( Submodel->Child ); + + if( Submodel->iFlags & 0xC000 ) + ::glPopMatrix(); + } +/* + if( Submodel->b_Anim < at_SecondsJump ) + Submodel->b_Anim = at_None; // wyłączenie animacji dla kolejnego użycia subm +*/ + if( Submodel->Next ) + if( Submodel->iAlpha & Submodel->iFlags & 0x1F000000 ) + Render( Submodel->Next ); // dalsze rekurencyjnie +} + +void +opengl_renderer::Render( TTrack *Track ) { + + if( ( Track->m_material1 == 0 ) + && ( Track->m_material2 == 0 ) + && ( ( Track->eType != tt_Switch ) + || ( Track->SwitchExtension->m_material3 == 0 ) ) ) { + return; + } + if( false == Track->m_visible ) { + return; + } + + ++m_debugstats.paths; + ++m_debugstats.drawcalls; + + switch( m_renderpass.draw_mode ) { + case rendermode::color: + case rendermode::reflections: { + setup_environment_light( Track->eEnvironment ); + if( Track->m_material1 != 0 ) { + Bind_Material( Track->m_material1 ); + m_geometry.draw( std::begin( Track->Geometry1 ), std::end( Track->Geometry1 ) ); + } + if( Track->m_material2 != 0 ) { + Bind_Material( Track->m_material2 ); + m_geometry.draw( std::begin( Track->Geometry2 ), std::end( Track->Geometry2 ) ); + } + if( ( Track->eType == tt_Switch ) + && ( Track->SwitchExtension->m_material3 != 0 ) ) { + Bind_Material( Track->SwitchExtension->m_material3 ); + m_geometry.draw( Track->SwitchExtension->Geometry3 ); + } + setup_environment_light(); + break; + } + case rendermode::shadows: { + // shadow pass includes trackbeds but not tracks themselves due to low resolution of the map + // TODO: implement + break; + } + case rendermode::pickscenery: { + // add the node to the pick list + m_picksceneryitems.emplace_back( Track ); + + if( Track->m_material1 != 0 ) { + Bind_Material( Track->m_material1 ); + m_geometry.draw( std::begin( Track->Geometry1 ), std::end( Track->Geometry1 ) ); + } + if( Track->m_material2 != 0 ) { + Bind_Material( Track->m_material2 ); + m_geometry.draw( std::begin( Track->Geometry2 ), std::end( Track->Geometry2 ) ); + } + if( ( Track->eType == tt_Switch ) + && ( Track->SwitchExtension->m_material3 != 0 ) ) { + Bind_Material( Track->SwitchExtension->m_material3 ); + m_geometry.draw( Track->SwitchExtension->Geometry3 ); + } + break; + } + case rendermode::pickcontrols: + default: { + break; + } + } +} + +// experimental, does track rendering in two passes, to take advantage of reduced texture switching +void +opengl_renderer::Render( scene::basic_cell::path_sequence::const_iterator First, scene::basic_cell::path_sequence::const_iterator Last ) { + + ::glColor3fv( glm::value_ptr( colors::white ) ); + // setup + switch( m_renderpass.draw_mode ) { + case rendermode::shadows: { + // NOTE: roads-based platforms tend to miss parts of shadows if rendered with either back or front culling + ::glDisable( GL_CULL_FACE ); + break; + } + default: { + break; + } + } + + // TODO: render auto generated trackbeds together with regular trackbeds in pass 1, and all rails in pass 2 + // first pass, material 1 + for( auto first { First }; first != Last; ++first ) { + + auto const track { *first }; + + if( track->m_material1 == 0 ) { + continue; + } + if( false == track->m_visible ) { + continue; + } + + ++m_debugstats.paths; + ++m_debugstats.drawcalls; + + switch( m_renderpass.draw_mode ) { + case rendermode::color: + case rendermode::reflections: { + if( track->eEnvironment != e_flat ) { + setup_environment_light( track->eEnvironment ); + } + Bind_Material( track->m_material1 ); + m_geometry.draw( std::begin( track->Geometry1 ), std::end( track->Geometry1 ) ); + if( track->eEnvironment != e_flat ) { + // restore default lighting + setup_environment_light(); + } + break; + } + case rendermode::shadows: { + if( ( std::abs( track->fTexHeight1 ) < 0.35f ) + || ( track->iCategoryFlag != 2 ) ) { + // shadows are only calculated for high enough roads, typically meaning track platforms + continue; + } + Bind_Material( track->m_material1 ); + m_geometry.draw( std::begin( track->Geometry1 ), std::end( track->Geometry1 ) ); + break; + } + case rendermode::pickscenery: // pick scenery mode uses piece-by-piece approach + case rendermode::pickcontrols: + default: { + break; + } + } + } + // second pass, material 2 + for( auto first { First }; first != Last; ++first ) { + + auto const track { *first }; + + if( track->m_material2 == 0 ) { + continue; + } + if( false == track->m_visible ) { + continue; + } + + switch( m_renderpass.draw_mode ) { + case rendermode::color: + case rendermode::reflections: { + if( track->eEnvironment != e_flat ) { + setup_environment_light( track->eEnvironment ); + } + Bind_Material( track->m_material2 ); + m_geometry.draw( std::begin( track->Geometry2 ), std::end( track->Geometry2 ) ); + if( track->eEnvironment != e_flat ) { + // restore default lighting + setup_environment_light(); + } + break; + } + case rendermode::shadows: { + if( ( std::abs( track->fTexHeight1 ) < 0.35f ) + || ( ( track->iCategoryFlag == 1 ) + && ( track->eType != tt_Normal ) ) ) { + // shadows are only calculated for high enough trackbeds + continue; + } + Bind_Material( track->m_material2 ); + m_geometry.draw( std::begin( track->Geometry2 ), std::end( track->Geometry2 ) ); + break; + } + case rendermode::pickscenery: // pick scenery mode uses piece-by-piece approach + case rendermode::pickcontrols: + default: { + break; + } + } + } + // third pass, material 3 + for( auto first { First }; first != Last; ++first ) { + + auto const track { *first }; + + if( track->eType != tt_Switch ) { + continue; + } + if( track->SwitchExtension->m_material3 == 0 ) { + continue; + } + if( false == track->m_visible ) { + continue; + } + + switch( m_renderpass.draw_mode ) { + case rendermode::color: + case rendermode::reflections: { + if( track->eEnvironment != e_flat ) { + setup_environment_light( track->eEnvironment ); + } + Bind_Material( track->SwitchExtension->m_material3 ); + m_geometry.draw( track->SwitchExtension->Geometry3 ); + if( track->eEnvironment != e_flat ) { + // restore default lighting + setup_environment_light(); + } + break; + } + case rendermode::shadows: { + if( ( std::abs( track->fTexHeight1 ) < 0.35f ) + || ( ( track->iCategoryFlag == 1 ) + && ( track->eType != tt_Normal ) ) ) { + // shadows are only calculated for high enough trackbeds + continue; + } + Bind_Material( track->SwitchExtension->m_material3 ); + m_geometry.draw( track->SwitchExtension->Geometry3 ); + break; + } + case rendermode::pickscenery: // pick scenery mode uses piece-by-piece approach + case rendermode::pickcontrols: + default: { + break; + } + } + } + // post-render reset + switch( m_renderpass.draw_mode ) { + case rendermode::shadows: { + ::glEnable( GL_CULL_FACE ); + break; + } + default: { + break; + } + } +} + +void +opengl_renderer::Render( TMemCell *Memcell ) { + + ::glPushMatrix(); + auto const position = Memcell->location() - m_renderpass.camera.position(); + ::glTranslated( position.x, position.y + 0.5, position.z ); + + switch( m_renderpass.draw_mode ) { + case rendermode::color: + case rendermode::shadows: { + ::gluSphere( m_quadric, 0.35, 4, 2 ); + break; + } + case rendermode::pickscenery: { + // add the node to the pick list + m_picksceneryitems.emplace_back( Memcell ); + + ::gluSphere( m_quadric, 0.35, 4, 2 ); + break; + } + case rendermode::reflections: + case rendermode::pickcontrols: { + break; + } + default: { + break; + } + } + + ::glPopMatrix(); +} + +void +opengl_renderer::Render_precipitation() { + + if( Global.Overcast <= 1.f ) { return; } + + switch_units( true, false, false ); + +// ::glColor4fv( glm::value_ptr( glm::vec4( glm::min( glm::vec3( Global.fLuminance ), glm::vec3( 1 ) ), 1 ) ) ); + ::glColor4fv( + glm::value_ptr( + interpolate( + 0.5f * ( Global.DayLight.diffuse + Global.DayLight.ambient ), + colors::white, + 0.5f * clamp( Global.fLuminance, 0.f, 1.f ) ) ) ); + ::glPushMatrix(); + // tilt the precipitation cone against the velocity vector for crude motion blur + auto const velocity { simulation::Environment.m_precipitation.m_cameramove * -1.0 }; + if( glm::length2( velocity ) > 0.0 ) { + auto const forward{ glm::normalize( velocity ) }; + auto left { glm::cross( forward, {0.0,1.0,0.0} ) }; + auto const rotationangle { + std::min( + 45.0, + ( FreeFlyModeFlag ? + 5 * glm::length( velocity ) : + simulation::Train->Dynamic()->GetVelocity() * 0.2 ) ) }; + ::glRotated( rotationangle, left.x, 0.0, left.z ); + } + if( false == FreeFlyModeFlag ) { + // counter potential vehicle roll + auto const roll { 0.5 * glm::degrees( simulation::Train->Dynamic()->Roll() ) }; + if( roll != 0.0 ) { + auto const forward { simulation::Train->Dynamic()->VectorFront() }; + auto const vehicledirection = simulation::Train->Dynamic()->DirectionGet(); + ::glRotated( roll, forward.x, 0.0, forward.z ); + } + } + if( Global.Weather == "rain:" ) { + // oddly enough random streaks produce more natural looking rain than ones the eye can follow + ::glRotated( Random() * 360, 0.0, 1.0, 0.0 ); + } + + // TBD: leave lighting on to allow vehicle lights to affect it? + ::glDisable( GL_LIGHTING ); + // momentarily disable depth write, to allow vehicle cab drawn afterwards to mask it instead of leaving it 'inside' + ::glDepthMask( GL_FALSE ); + + simulation::Environment.m_precipitation.render(); + + ::glDepthMask( GL_TRUE ); + ::glEnable( GL_LIGHTING ); + ::glPopMatrix(); +} + +void +opengl_renderer::Render_Alpha( scene::basic_region *Region ) { + + // sort the nodes based on their distance to viewer + std::sort( + std::begin( m_cellqueue ), + std::end( m_cellqueue ), + []( distancecell_pair const &Left, distancecell_pair const &Right ) { + return ( Left.first ) < ( Right.first ); } ); + + Render_Alpha( std::rbegin( m_cellqueue ), std::rend( m_cellqueue ) ); +} + +void +opengl_renderer::Render_Alpha( cell_sequence::reverse_iterator First, cell_sequence::reverse_iterator Last ) { + + // NOTE: this method is launched only during color pass therefore we don't bother with mode test here + // first pass draws elements which we know are located in section banks, to reduce vbo switching + { + auto first { First }; + while( first != Last ) { + + auto const *cell = first->second; + + if( false == cell->m_shapestranslucent.empty() ) { + // since all shapes of the cell share center point we can optimize out a few calls here + ::glPushMatrix(); + auto const originoffset{ cell->m_area.center - m_renderpass.camera.position() }; + ::glTranslated( originoffset.x, originoffset.y, originoffset.z ); + // render + // NOTE: we can reuse the method used to draw opaque geometry + for( auto const &shape : cell->m_shapestranslucent ) { Render( shape, false ); } + // post-render cleanup + ::glPopMatrix(); + } + + ++first; + } + } + // second pass draws elements with their own vbos + { + auto first { First }; + while( first != Last ) { + + auto const *cell = first->second; + + // translucent parts of instanced models + for( auto *instance : cell->m_instancetranslucent ) { Render_Alpha( instance ); } + // translucent parts of vehicles + for( auto *path : cell->m_paths ) { + for( auto *dynamic : path->Dynamics ) { + Render_Alpha( dynamic ); + } + } + + ++first; + } + } + // third pass draws the wires; + // wires use section vbos, but for the time being we want to draw them at the very end + { + ::glDisable( GL_LIGHTING ); // linie nie powinny świecić + + auto first{ First }; + while( first != Last ) { + + auto const *cell = first->second; + + if( ( false == cell->m_traction.empty() + || ( false == cell->m_lines.empty() ) ) ) { + // since all shapes of the cell share center point we can optimize out a few calls here + ::glPushMatrix(); + auto const originoffset { cell->m_area.center - m_renderpass.camera.position() }; + ::glTranslated( originoffset.x, originoffset.y, originoffset.z ); + if( !Global.bSmoothTraction ) { + // na liniach kiepsko wygląda - robi gradient + ::glDisable( GL_LINE_SMOOTH ); + } + Bind_Material( null_handle ); + // render + for( auto *traction : cell->m_traction ) { Render_Alpha( traction ); } + for( auto &lines : cell->m_lines ) { Render_Alpha( lines ); } + // post-render cleanup + ::glLineWidth( 1.0 ); + if( !Global.bSmoothTraction ) { + ::glEnable( GL_LINE_SMOOTH ); + } + ::glPopMatrix(); + } + + ++first; + } + + ::glEnable( GL_LIGHTING ); + } +} + +void +opengl_renderer::Render_Alpha( TAnimModel *Instance ) { + + if( false == Instance->m_visible ) { + return; + } + + double distancesquared; + switch( m_renderpass.draw_mode ) { + case rendermode::shadows: { + // 'camera' for the light pass is the light source, but we need to draw what the 'real' camera sees + distancesquared = Math3D::SquareMagnitude( ( Instance->location() - Global.pCamera.Pos ) / Global.ZoomFactor ) / Global.fDistanceFactor; + break; + } + default: { + distancesquared = glm::length2( ( Instance->location() - m_renderpass.camera.position() ) / (double)Global.ZoomFactor ) / Global.fDistanceFactor; + break; + } + } + if( ( distancesquared < Instance->m_rangesquaredmin ) + || ( distancesquared >= Instance->m_rangesquaredmax ) ) { + return; + } + + Instance->RaPrepare(); + if( Instance->pModel ) { + // renderowanie rekurencyjne submodeli + Render_Alpha( + Instance->pModel, + Instance->Material(), + distancesquared, + Instance->location() - m_renderpass.camera.position(), + Instance->vAngle ); + } +} + +void +opengl_renderer::Render_Alpha( TTraction *Traction ) { + + double distancesquared; + switch( m_renderpass.draw_mode ) { + case rendermode::shadows: { + // 'camera' for the light pass is the light source, but we need to draw what the 'real' camera sees + distancesquared = Math3D::SquareMagnitude( ( Traction->location() - Global.pCamera.Pos ) / Global.ZoomFactor ) / Global.fDistanceFactor; + break; + } + default: { + distancesquared = glm::length2( ( Traction->location() - m_renderpass.camera.position() ) / (double)Global.ZoomFactor ) / Global.fDistanceFactor; + break; + } + } + if( ( distancesquared < Traction->m_rangesquaredmin ) + || ( distancesquared >= Traction->m_rangesquaredmax ) ) { + return; + } + + if( false == Traction->m_visible ) { + return; + } + // rysuj jesli sa druty i nie zerwana + if( ( Traction->Wires == 0 ) + || ( true == TestFlag( Traction->DamageFlag, 128 ) ) ) { + return; + } + // setup +/* + float const linealpha = static_cast( + std::min( + 1.25, + 5000 * Traction->WireThickness / ( distancesquared + 1.0 ) ) ); // zbyt grube nie są dobre + ::glLineWidth( linealpha ); +*/ + auto const distance { static_cast( std::sqrt( distancesquared ) ) }; + auto const linealpha { + 20.f * Traction->WireThickness + / std::max( + 0.5f * Traction->radius() + 1.f, + distance - ( 0.5f * Traction->radius() ) ) }; + ::glLineWidth( + clamp( + 0.5f * linealpha + Traction->WireThickness * Traction->radius() / 1000.f, + 1.f, 1.75f ) ); + // McZapkie-261102: kolor zalezy od materialu i zasniedzenia + ::glColor4fv( + glm::value_ptr( + glm::vec4{ + Traction->wire_color() /* * ( DebugModeFlag ? 1.f : clamp( m_sunandviewangle, 0.25f, 1.f ) ) */, + linealpha } ) ); + // render + m_geometry.draw( Traction->m_geometry ); + // debug data + ++m_debugstats.traction; + ++m_debugstats.drawcalls; +} + +void +opengl_renderer::Render_Alpha( scene::lines_node const &Lines ) { + + auto const &data { Lines.data() }; + + double distancesquared; + switch( m_renderpass.draw_mode ) { + case rendermode::shadows: { + // 'camera' for the light pass is the light source, but we need to draw what the 'real' camera sees + distancesquared = Math3D::SquareMagnitude( ( data.area.center - Global.pCamera.Pos ) / Global.ZoomFactor ) / Global.fDistanceFactor; + break; + } + default: { + distancesquared = glm::length2( ( data.area.center - m_renderpass.camera.position() ) / (double)Global.ZoomFactor ) / Global.fDistanceFactor; + break; + } + } + if( ( distancesquared < data.rangesquared_min ) + || ( distancesquared >= data.rangesquared_max ) ) { + return; + } + // setup + auto const distance { static_cast( std::sqrt( distancesquared ) ) }; + auto const linealpha = ( + data.line_width > 0.f ? + 10.f * data.line_width + / std::max( + 0.5f * data.area.radius + 1.f, + distance - ( 0.5f * data.area.radius ) ) : + 1.f ); // negative width means the lines are always opague + ::glLineWidth( + clamp( + 0.5f * linealpha + data.line_width * data.area.radius / 1000.f, + 1.f, 8.f ) ); + ::glColor4fv( + glm::value_ptr( + glm::vec4{ + glm::vec3{ data.lighting.diffuse * m_sunlight.ambient }, // w zaleznosci od koloru swiatla + std::min( 1.f, linealpha ) } ) ); + // render + m_geometry.draw( data.geometry ); + ++m_debugstats.lines; + ++m_debugstats.drawcalls; +} + +bool +opengl_renderer::Render_Alpha( TDynamicObject *Dynamic ) { + + if( false == Dynamic->renderme ) { return false; } + + // setup + TSubModel::iInstance = ( size_t )Dynamic; //żeby nie robić cudzych animacji + glm::dvec3 const originoffset = Dynamic->vPosition - m_renderpass.camera.position(); + // lod visibility ranges are defined for base (x 1.0) viewing distance. for render we adjust them for actual range multiplier and zoom + float squaredistance; + switch( m_renderpass.draw_mode ) { + case rendermode::shadows: { + squaredistance = glm::length2( glm::vec3{ glm::dvec3{ Dynamic->vPosition - Global.pCamera.Pos } } / Global.ZoomFactor ) / Global.fDistanceFactor; + break; + } + default: { + squaredistance = glm::length2( glm::vec3{ originoffset } / Global.ZoomFactor ) / Global.fDistanceFactor; + break; + } + } + Dynamic->ABuLittleUpdate( squaredistance ); // ustawianie zmiennych submodeli dla wspólnego modelu + ::glPushMatrix(); + + ::glTranslated( originoffset.x, originoffset.y, originoffset.z ); + ::glMultMatrixd( Dynamic->mMatrix.getArray() ); + + if( Dynamic->fShade > 0.0f ) { + // change light level based on light level of the occupied track + m_sunlight.apply_intensity( Dynamic->fShade ); + } + m_renderspecular = true; + + // render + if( Dynamic->mdLowPolyInt ) { + // low poly interior + if( FreeFlyModeFlag ? true : !Dynamic->mdKabina || !Dynamic->bDisplayCab ) { + // enable cab light if needed + if( Dynamic->InteriorLightLevel > 0.0f ) { + + // crude way to light the cabin, until we have something more complete in place + ::glLightModelfv( GL_LIGHT_MODEL_AMBIENT, glm::value_ptr( Dynamic->InteriorLight * Dynamic->InteriorLightLevel ) ); + } + + Render_Alpha( Dynamic->mdLowPolyInt, Dynamic->Material(), squaredistance ); + + if( Dynamic->InteriorLightLevel > 0.0f ) { + // reset the overall ambient + ::glLightModelfv( GL_LIGHT_MODEL_AMBIENT, glm::value_ptr( m_baseambient ) ); + } + } + } + + if( Dynamic->mdModel ) + Render_Alpha( Dynamic->mdModel, Dynamic->Material(), squaredistance ); + + if( Dynamic->mdLoad ) // renderowanie nieprzezroczystego ładunku + Render_Alpha( Dynamic->mdLoad, Dynamic->Material(), squaredistance, { 0.f, Dynamic->LoadOffset, 0.f }, {} ); + + // post-render cleanup + m_renderspecular = false; + if( Dynamic->fShade > 0.0f ) { + // restore regular light level + m_sunlight.apply_intensity(); + } + + ::glPopMatrix(); + + if( Dynamic->btnOn ) + Dynamic->TurnOff(); // przywrócenie domyślnych pozycji submodeli + + return true; +} + +bool +opengl_renderer::Render_Alpha( TModel3d *Model, material_data const *Material, float const Squaredistance ) { + + auto alpha = + ( Material != nullptr ? + Material->textures_alpha : + 0x30300030 ); + + if( 0 == ( alpha & Model->iFlags & 0x2F2F002F ) ) { + // nothing to render + return false; + } + + Model->Root->fSquareDist = Squaredistance; // zmienna globalna! + + // setup + Model->Root->ReplacableSet( + ( Material != nullptr ? + Material->replacable_skins : + nullptr ), + alpha ); + + Model->Root->pRoot = Model; + + // render + Render_Alpha( Model->Root ); + + // post-render cleanup + + return true; +} + +bool +opengl_renderer::Render_Alpha( TModel3d *Model, material_data const *Material, float const Squaredistance, Math3D::vector3 const &Position, glm::vec3 const &Angle ) { + + ::glPushMatrix(); + ::glTranslated( Position.x, Position.y, Position.z ); + if( Angle.y != 0.0 ) + ::glRotatef( Angle.y, 0.f, 1.f, 0.f ); + if( Angle.x != 0.0 ) + ::glRotatef( Angle.x, 1.f, 0.f, 0.f ); + if( Angle.z != 0.0 ) + ::glRotatef( Angle.z, 0.f, 0.f, 1.f ); + + auto const result = Render_Alpha( Model, Material, Squaredistance ); // position is effectively camera offset + + ::glPopMatrix(); + + return result; +} + +void +opengl_renderer::Render_Alpha( TSubModel *Submodel ) { + // renderowanie przezroczystych przez DL + if( ( Submodel->iVisible ) + && ( TSubModel::fSquareDist >= Submodel->fSquareMinDist ) + && ( TSubModel::fSquareDist < Submodel->fSquareMaxDist ) ) { + + // debug data + ++m_debugstats.submodels; + ++m_debugstats.drawcalls; + + if( Submodel->iFlags & 0xC000 ) { + ::glPushMatrix(); + if( Submodel->fMatrix ) + ::glMultMatrixf( Submodel->fMatrix->readArray() ); + if( Submodel->b_aAnim != TAnimType::at_None ) + Submodel->RaAnimation( Submodel->b_aAnim ); + } + + if( Submodel->eType < TP_ROTATOR ) { + // renderowanie obiektów OpenGL + if( Submodel->iAlpha & Submodel->iFlags & 0x2F ) { + // rysuj gdy element przezroczysty + switch( m_renderpass.draw_mode ) { + case rendermode::color: { + +// NOTE: code disabled as normalization marking doesn't take into account scaling propagation down hierarchy chains +// for the time being we'll do with enforced worst-case scaling method, when speculars are enabled +#ifdef EU07_USE_OPTIMIZED_NORMALIZATION + switch( Submodel->m_normalizenormals ) { + case TSubModel::normalize: { + ::glEnable( GL_NORMALIZE ); break; } + case TSubModel::rescale: { + ::glEnable( GL_RESCALE_NORMAL ); break; } + default: { + break; } + } +#else + if( true == m_renderspecular ) { + ::glEnable( GL_NORMALIZE ); + } +#endif + // material configuration: + // textures... + if( Submodel->m_material < 0 ) { // zmienialne skóry + Bind_Material( Submodel->ReplacableSkinId[ -Submodel->m_material ] ); + } + else { + // również 0 + Bind_Material( Submodel->m_material ); + } + // ...colors... + if( Submodel->fVisible < 1.f ) { + ::glColor4f( + Submodel->f4Diffuse.r, + Submodel->f4Diffuse.g, + Submodel->f4Diffuse.b, + Submodel->fVisible ); + } + else { + ::glColor3fv( glm::value_ptr( Submodel->f4Diffuse ) ); // McZapkie-240702: zamiast ub + } + if( ( true == m_renderspecular ) && ( m_sunlight.specular.a > 0.01f ) ) { + ::glMaterialfv( GL_FRONT, GL_SPECULAR, glm::value_ptr( Submodel->f4Specular * m_sunlight.specular.a * m_speculartranslucentscalefactor ) ); + } + // ...luminance + auto const unitstate = m_unitstate; + if( Global.fLuminance < Submodel->fLight ) { + // zeby swiecilo na kolorowo + ::glMaterialfv( GL_FRONT, GL_EMISSION, glm::value_ptr( Submodel->f4Diffuse * Submodel->f4Emision.a ) ); + // disable shadows so they don't obstruct self-lit items +/* + setup_shadow_color( colors::white ); +*/ + switch_units( unitstate.diffuse, false, false ); + } + + // main draw call + m_geometry.draw( Submodel->m_geometry ); + + // post-draw reset + if( ( true == m_renderspecular ) && ( m_sunlight.specular.a > 0.01f ) ) { + ::glMaterialfv( GL_FRONT, GL_SPECULAR, glm::value_ptr( colors::none ) ); + } + if( Global.fLuminance < Submodel->fLight ) { + // restore default (lack of) brightness + ::glMaterialfv( GL_FRONT, GL_EMISSION, glm::value_ptr( colors::none ) ); +/* + setup_shadow_color( m_shadowcolor ); +*/ + switch_units( unitstate.diffuse, unitstate.shadows, unitstate.reflections ); + } +#ifdef EU07_USE_OPTIMIZED_NORMALIZATION + switch( Submodel->m_normalizenormals ) { + case TSubModel::normalize: { + ::glDisable( GL_NORMALIZE ); break; } + case TSubModel::rescale: { + ::glDisable( GL_RESCALE_NORMAL ); break; } + default: { + break; } + } +#else + if( true == m_renderspecular ) { + ::glDisable( GL_NORMALIZE ); + } +#endif + break; + } + case rendermode::cabshadows: { + // scenery picking and shadow both use enforced colour and no frills + // material configuration: + // textures... + if( Submodel->m_material < 0 ) { // zmienialne skóry + Bind_Material( Submodel->ReplacableSkinId[ -Submodel->m_material ] ); + } + else { + // również 0 + Bind_Material( Submodel->m_material ); + } + // main draw call + m_geometry.draw( Submodel->m_geometry ); + // post-draw reset + break; + } + default: { + break; + } + } + } + } + else if( Submodel->eType == TP_FREESPOTLIGHT ) { + + if( ( Global.fLuminance < Submodel->fLight ) || ( Global.Overcast > 1.f ) ) { + // NOTE: we're forced here to redo view angle calculations etc, because this data isn't instanced but stored along with the single mesh + // TODO: separate instance data from reusable geometry + auto const &modelview = OpenGLMatrices.data( GL_MODELVIEW ); + auto const lightcenter = + modelview + * interpolate( + glm::vec4( 0.f, 0.f, -0.05f, 1.f ), + glm::vec4( 0.f, 0.f, -0.10f, 1.f ), + static_cast( TSubModel::fSquareDist / Submodel->fSquareMaxDist ) ); // pozycja punktu świecącego względem kamery + Submodel->fCosViewAngle = glm::dot( glm::normalize( modelview * glm::vec4( 0.f, 0.f, -1.f, 1.f ) - lightcenter ), glm::normalize( -lightcenter ) ); + + if( Submodel->fCosViewAngle > Submodel->fCosFalloffAngle ) { + // only bother if the viewer is inside the visibility cone + // luminosity at night is at level of ~0.1, so the overall resulting transparency in clear conditions is ~0.5 at full 'brightness' + auto glarelevel { clamp( + std::max( + 0.6f - Global.fLuminance, // reduce the glare in bright daylight + Global.Overcast - 1.f ), // ensure some glare in rainy/foggy conditions + 0.f, 1.f ) }; + // view angle attenuation + float const anglefactor { clamp( + ( Submodel->fCosViewAngle - Submodel->fCosFalloffAngle ) / ( Submodel->fCosHotspotAngle - Submodel->fCosFalloffAngle ), + 0.f, 1.f ) }; + glarelevel *= anglefactor; + + if( glarelevel > 0.0f ) { + // setup + ::glPushAttrib( GL_DEPTH_BUFFER_BIT | GL_COLOR_BUFFER_BIT | GL_ENABLE_BIT ); + + Bind_Texture( m_glaretexture ); + ::glColor4f( Submodel->f4Diffuse[ 0 ], Submodel->f4Diffuse[ 1 ], Submodel->f4Diffuse[ 2 ], Submodel->fVisible * glarelevel ); + ::glDisable( GL_LIGHTING ); + ::glDisable( GL_FOG ); + ::glDepthMask( GL_FALSE ); + ::glBlendFunc( GL_SRC_ALPHA, GL_ONE ); + + ::glPushMatrix(); + ::glLoadIdentity(); // macierz jedynkowa + ::glTranslatef( lightcenter.x, lightcenter.y, lightcenter.z ); // początek układu zostaje bez zmian + ::glRotated( std::atan2( lightcenter.x, lightcenter.z ) * 180.0 / M_PI, 0.0, 1.0, 0.0 ); // jedynie obracamy w pionie o kąt + // disable shadows so they don't obstruct self-lit items +/* + setup_shadow_color( colors::white ); +*/ + auto const unitstate = m_unitstate; + switch_units( unitstate.diffuse, false, false ); + + // main draw call + m_geometry.draw( m_billboardgeometry ); +/* + // NOTE: we could do simply... + vec3 vertexPosition_worldspace = + particleCenter_wordspace + + CameraRight_worldspace * squareVertices.x * BillboardSize.x + + CameraUp_worldspace * squareVertices.y * BillboardSize.y; + // ...etc instead IF we had easy access to camera's forward and right vectors. TODO: check if Camera matrix is accessible +*/ + // post-render cleanup +/* + setup_shadow_color( m_shadowcolor ); +*/ + switch_units( unitstate.diffuse, unitstate.shadows, unitstate.reflections ); + + ::glPopMatrix(); + ::glPopAttrib(); + } + } + } + } + + if( Submodel->Child != nullptr ) { + if( Submodel->eType == TP_TEXT ) { // tekst renderujemy w specjalny sposób, zamiast submodeli z łańcucha Child + int i, j = (int)Submodel->pasText->size(); + TSubModel *p; + if( !Submodel->smLetter ) { // jeśli nie ma tablicy, to ją stworzyć; miejsce nieodpowiednie, ale tymczasowo może być + Submodel->smLetter = new TSubModel *[ 256 ]; // tablica wskaźników submodeli dla wyświetlania tekstu + ::ZeroMemory( Submodel->smLetter, 256 * sizeof( TSubModel * ) ); // wypełnianie zerami + p = Submodel->Child; + while( p ) { + Submodel->smLetter[ p->pName[ 0 ] ] = p; + p = p->Next; // kolejny znak + } + } + for( i = 1; i <= j; ++i ) { + p = Submodel->smLetter[ ( *( Submodel->pasText) )[ i ] ]; // znak do wyświetlenia + if( p ) { // na razie tylko jako przezroczyste + Render_Alpha( p ); + if( p->fMatrix ) + ::glMultMatrixf( p->fMatrix->readArray() ); // przesuwanie widoku + } + } + } + else if( Submodel->iAlpha & Submodel->iFlags & 0x002F0000 ) + Render_Alpha( Submodel->Child ); + } + + if( Submodel->iFlags & 0xC000 ) + ::glPopMatrix(); + } +/* + if( Submodel->b_aAnim < at_SecondsJump ) + Submodel->b_aAnim = at_None; // wyłączenie animacji dla kolejnego użycia submodelu +*/ + if( Submodel->Next != nullptr ) + if( Submodel->iAlpha & Submodel->iFlags & 0x2F000000 ) + Render_Alpha( Submodel->Next ); +}; + + + +// utility methods +TSubModel * +opengl_renderer::Update_Pick_Control() { + +#ifdef EU07_USE_PICKING_FRAMEBUFFER + if( true == m_framebuffersupport ) { + ::glBindFramebufferEXT( GL_FRAMEBUFFER_EXT, m_pickframebuffer ); + } +#endif + Render_pass( rendermode::pickcontrols ); + // determine point to examine + glm::dvec2 mousepos; + glfwGetCursorPos( m_window, &mousepos.x, &mousepos.y ); + mousepos.y = Global.iWindowHeight - mousepos.y; // cursor coordinates are flipped compared to opengl + +#ifdef EU07_USE_PICKING_FRAMEBUFFER + glm::ivec2 pickbufferpos; + if( true == m_framebuffersupport ) { +// ::glReadBuffer( GL_COLOR_ATTACHMENT0_EXT ); + pickbufferpos = glm::ivec2{ + mousepos.x * EU07_PICKBUFFERSIZE / std::max( 1, Global.iWindowWidth ), + mousepos.y * EU07_PICKBUFFERSIZE / std::max( 1, Global.iWindowHeight ) }; + } + else { +// ::glReadBuffer( GL_BACK ); + pickbufferpos = glm::ivec2{ mousepos }; + } +#else +// ::glReadBuffer( GL_BACK ); + glm::ivec2 pickbufferpos{ mousepos }; +#endif + unsigned char pickreadout[4]; + ::glReadPixels( pickbufferpos.x, pickbufferpos.y, 1, 1, GL_BGRA, GL_UNSIGNED_BYTE, pickreadout ); + auto const controlindex = pick_index( glm::ivec3{ pickreadout[ 2 ], pickreadout[ 1 ], pickreadout[ 0 ] } ); + TSubModel *control { nullptr }; + if( ( controlindex > 0 ) + && ( controlindex <= m_pickcontrolsitems.size() ) ) { + control = m_pickcontrolsitems[ controlindex - 1 ]; + } +#ifdef EU07_USE_PICKING_FRAMEBUFFER + if( true == m_framebuffersupport ) { + ::glBindFramebufferEXT( GL_FRAMEBUFFER_EXT, 0 ); + } +#endif + m_pickcontrolitem = control; + return control; +} + +scene::basic_node * +opengl_renderer::Update_Pick_Node() { + +#ifdef EU07_USE_PICKING_FRAMEBUFFER + if( true == m_framebuffersupport ) { + ::glBindFramebufferEXT( GL_FRAMEBUFFER_EXT, m_pickframebuffer ); + } +#endif + Render_pass( rendermode::pickscenery ); + // determine point to examine + glm::dvec2 mousepos; + glfwGetCursorPos( m_window, &mousepos.x, &mousepos.y ); + mousepos.y = Global.iWindowHeight - mousepos.y; // cursor coordinates are flipped compared to opengl + +#ifdef EU07_USE_PICKING_FRAMEBUFFER + glm::ivec2 pickbufferpos; + if( true == m_framebuffersupport ) { +// ::glReadBuffer( GL_COLOR_ATTACHMENT0_EXT ); + pickbufferpos = glm::ivec2{ + mousepos.x * EU07_PICKBUFFERSIZE / Global.iWindowWidth, + mousepos.y * EU07_PICKBUFFERSIZE / Global.iWindowHeight + }; + } + else { +// ::glReadBuffer( GL_BACK ); + pickbufferpos = glm::ivec2{ mousepos }; + } +#else +// ::glReadBuffer( GL_BACK ); + glm::ivec2 pickbufferpos{ mousepos }; +#endif + + unsigned char pickreadout[4]; + ::glReadPixels( pickbufferpos.x, pickbufferpos.y, 1, 1, GL_BGRA, GL_UNSIGNED_BYTE, pickreadout ); + auto const nodeindex = pick_index( glm::ivec3{ pickreadout[ 2 ], pickreadout[ 1 ], pickreadout[ 0 ] } ); + scene::basic_node *node { nullptr }; + if( ( nodeindex > 0 ) + && ( nodeindex <= m_picksceneryitems.size() ) ) { + node = m_picksceneryitems[ nodeindex - 1 ]; + } +#ifdef EU07_USE_PICKING_FRAMEBUFFER + if( true == m_framebuffersupport ) { + ::glBindFramebufferEXT( GL_FRAMEBUFFER_EXT, 0 ); + } +#endif + m_picksceneryitem = node; + return node; +} + +// converts provided screen coordinates to world coordinates of most recent color pass +glm::dvec3 +opengl_renderer::Update_Mouse_Position() { + + glm::dvec2 mousepos; + Application.get_cursor_pos( mousepos.x, mousepos.y ); +// glfwGetCursorPos( m_window, &mousepos.x, &mousepos.y ); + mousepos.x = clamp( mousepos.x, 0, Global.iWindowWidth - 1 ); + mousepos.y = clamp( Global.iWindowHeight - clamp( mousepos.y, 0, Global.iWindowHeight ), 0, Global.iWindowHeight - 1 ) ; + GLfloat pointdepth; + ::glReadPixels( mousepos.x, mousepos.y, 1, 1, GL_DEPTH_COMPONENT, GL_FLOAT, &pointdepth ); + + if( pointdepth < 1.0 ) { + m_worldmousecoordinates = + glm::unProject( + glm::vec3{ mousepos, pointdepth }, + glm::mat4{ glm::mat3{ m_colorpass.camera.modelview() } }, + m_colorpass.camera.projection(), + glm::vec4{ 0, 0, Global.iWindowWidth, Global.iWindowHeight } ); + } + + return m_colorpass.camera.position() + glm::dvec3{ m_worldmousecoordinates }; +} + +void +opengl_renderer::Update( double const Deltatime ) { +/* + m_pickupdateaccumulator += Deltatime; + + if( m_updateaccumulator > 0.5 ) { + + m_pickupdateaccumulator = 0.0; + + if( ( true == Global.ControlPicking ) + && ( false == FreeFlyModeFlag ) ) { + Update_Pick_Control(); + } + else { + m_pickcontrolitem = nullptr; + } + // temporary conditions for testing. eventually will be coupled with editor mode + if( ( true == Global.ControlPicking ) + && ( true == DebugModeFlag ) + && ( true == FreeFlyModeFlag ) ) { + Update_Pick_Node(); + } + else { + m_picksceneryitem = nullptr; + } + } +*/ + m_updateaccumulator += Deltatime; + + if( m_updateaccumulator < 1.0 ) { + // too early for any work + return; + } + + m_updateaccumulator = 0.0; + m_framerate = 1000.f / ( Timer::subsystem.gfx_total.average() ); + + // adjust draw ranges etc, based on recent performance + auto const framerate = 1000.f / Timer::subsystem.gfx_color.average(); + + float targetfactor; + if( framerate > 90.0 ) { targetfactor = 3.0f; } + else if( framerate > 60.0 ) { targetfactor = 1.5f; } + else if( framerate > 30.0 ) { targetfactor = 1.25; } + else { targetfactor = std::max( Global.iWindowHeight / 768.f, 1.f ); } + + if( targetfactor > Global.fDistanceFactor ) { + + Global.fDistanceFactor = std::min( targetfactor, Global.fDistanceFactor + 0.05f ); + } + else if( targetfactor < Global.fDistanceFactor ) { + + Global.fDistanceFactor = std::max( targetfactor, Global.fDistanceFactor - 0.05f ); + } + + if( ( framerate < 15.0 ) && ( Global.iSlowMotion < 7 ) ) { + Global.iSlowMotion = ( Global.iSlowMotion << 1 ) + 1; // zapalenie kolejnego bitu + if( Global.iSlowMotionMask & 1 ) + if( Global.iMultisampling ) // a multisampling jest włączony + ::glDisable( GL_MULTISAMPLE ); // wyłączenie multisamplingu powinno poprawić FPS + } + else if( ( framerate > 20.0 ) && Global.iSlowMotion ) { // FPS się zwiększył, można włączyć bajery + Global.iSlowMotion = ( Global.iSlowMotion >> 1 ); // zgaszenie bitu + if( Global.iSlowMotion == 0 ) // jeśli jest pełna prędkość + if( Global.iMultisampling ) // a multisampling jest włączony + ::glEnable( GL_MULTISAMPLE ); + } + + if( ( true == Global.ResourceSweep ) + && ( true == simulation::is_ready ) ) { + // garbage collection + m_geometry.update(); + m_textures.update(); + } + + if( true == DebugModeFlag ) { + m_debugtimestext += m_textures.info(); + } + + if( ( true == Global.ControlPicking ) + && ( false == FreeFlyModeFlag ) ) { + Update_Pick_Control(); + } + else { + m_pickcontrolitem = nullptr; + } + // temporary conditions for testing. eventually will be coupled with editor mode + if( ( true == Global.ControlPicking ) + && ( true == DebugModeFlag ) + && ( true == FreeFlyModeFlag ) ) { + Update_Pick_Node(); + } + else { + m_picksceneryitem = nullptr; + } + // dump last opengl error, if any + auto const glerror = ::glGetError(); + if( glerror != GL_NO_ERROR ) { + std::string glerrorstring( ( char * )::gluErrorString( glerror ) ); + win1250_to_ascii( glerrorstring ); + Global.LastGLError = std::to_string( glerror ) + " (" + glerrorstring + ")"; + } +} + +// debug performance string +std::string const & +opengl_renderer::info_times() const { + + return m_debugtimestext; +} + +std::string const & +opengl_renderer::info_stats() const { + + return m_debugstatstext; +} + +void +opengl_renderer::Update_Lights( light_array &Lights ) { + // arrange the light array from closest to farthest from current position of the camera + auto const camera = m_renderpass.camera.position(); + std::sort( + std::begin( Lights.data ), + std::end( Lights.data ), + [&camera]( light_array::light_record const &Left, light_array::light_record const &Right ) { + // move lights which are off at the end... + if( Left.intensity == 0.f ) { return false; } + if( Right.intensity == 0.f ) { return true; } + // ...otherwise prefer closer and/or brigher light sources + return ( glm::length2( camera - Left.position ) * ( 1.f - Left.intensity ) ) < ( glm::length2( camera - Right.position ) * ( 1.f - Right.intensity ) ); } ); + + size_t const count = std::min( m_lights.size(), Lights.data.size() ); + if( count == 0 ) { return; } + + auto renderlight = m_lights.begin(); + + for( auto const &scenelight : Lights.data ) { + + if( renderlight == m_lights.end() ) { + // we ran out of lights to assign + break; + } + if( scenelight.intensity == 0.f ) { + // all lights past this one are bound to be off + break; + } + auto const lightoffset = glm::vec3{ scenelight.position - camera }; + if( glm::length( lightoffset ) > 1000.f ) { + // we don't care about lights past arbitrary limit of 1 km. + // but there could still be weaker lights which are closer, so keep looking + continue; + } + // if the light passed tests so far, it's good enough + renderlight->position = lightoffset; + renderlight->direction = scenelight.direction; + + auto luminance = static_cast( Global.fLuminance ); + // adjust luminance level based on vehicle's location, e.g. tunnels + auto const environment = scenelight.owner->fShade; + if( environment > 0.f ) { + luminance *= environment; + } + renderlight->diffuse = + glm::vec4{ + glm::max( glm::vec3{ colors::none }, scenelight.color - glm::vec3{ luminance } ), + renderlight->diffuse[ 3 ] }; + renderlight->ambient = + glm::vec4{ + glm::max( glm::vec3{ colors::none }, scenelight.color * glm::vec3{ scenelight.intensity } - glm::vec3{ luminance } ), + renderlight->ambient[ 3 ] }; + + ::glLightf( renderlight->id, GL_LINEAR_ATTENUATION, static_cast( (0.25 * scenelight.count) / std::pow( scenelight.count, 2 ) * (scenelight.owner->DimHeadlights ? 1.25 : 1.0) ) ); + ::glEnable( renderlight->id ); + + renderlight->apply_intensity(); + renderlight->apply_angle(); + + ++renderlight; + } + + while( renderlight != m_lights.end() ) { + // if we went through all scene lights and there's still opengl lights remaining, kill these + ::glDisable( renderlight->id ); + ++renderlight; + } +} + +void +opengl_renderer::Disable_Lights() { + + for( size_t idx = 0; idx < m_lights.size() + 1; ++idx ) { + + ::glDisable( GL_LIGHT0 + (int)idx ); + } +} + +bool +opengl_renderer::Init_caps() { + + std::string oglversion = ( (char *)glGetString( GL_VERSION ) ); + + WriteLog( + "Gfx Renderer: " + std::string( (char *)glGetString( GL_RENDERER ) ) + + " Vendor: " + std::string( (char *)glGetString( GL_VENDOR ) ) + + " OpenGL Version: " + oglversion ); + +#ifdef EU07_USEIMGUIIMPLOPENGL2 + if( !GLEW_VERSION_1_5 ) { + ErrorLog( "Requires openGL >= 1.5" ); +#else + if( !GLEW_VERSION_3_0 ) { + ErrorLog( "Requires openGL >= 3.0" ); +#endif + return false; + } + + WriteLog( "Supported extensions: " + std::string((char *)glGetString( GL_EXTENSIONS )) ); + + WriteLog( std::string("Render path: ") + ( Global.bUseVBO ? "VBO" : "Display lists" ) ); + if( GLEW_EXT_framebuffer_object ) { + m_framebuffersupport = true; + WriteLog( "Framebuffer objects enabled" ); + } + else { + WriteLog( "Framebuffer objects not supported, resorting to back buffer rendering where possible" ); + } + // ograniczenie maksymalnego rozmiaru tekstur - parametr dla skalowania tekstur + { + GLint texturesize; + ::glGetIntegerv( GL_MAX_TEXTURE_SIZE, &texturesize ); + Global.iMaxTextureSize = std::min( Global.iMaxTextureSize, texturesize ); + WriteLog( "Texture sizes capped at " + std::to_string( Global.iMaxTextureSize ) + " pixels" ); + m_shadowbuffersize = Global.shadowtune.map_size; + m_shadowbuffersize = std::min( m_shadowbuffersize, texturesize ); + WriteLog( "Shadows map size capped at " + std::to_string( m_shadowbuffersize ) + " pixels" ); + } + // cap the number of supported lights based on hardware + { + GLint maxlights; + ::glGetIntegerv( GL_MAX_LIGHTS, &maxlights ); + Global.DynamicLightCount = std::min( Global.DynamicLightCount, maxlights - 1 ); + WriteLog( "Dynamic light amount capped at " + std::to_string( Global.DynamicLightCount ) + " (" + std::to_string(maxlights) + " lights total supported by the gfx card)" ); + } + // select renderer mode + if( true == Global.BasicRenderer ) { + WriteLog( "Basic renderer selected, shadow and reflection mapping will be disabled" ); + Global.RenderShadows = false; + m_diffusetextureunit = GL_TEXTURE0; + m_helpertextureunit = -1; + m_shadowtextureunit = -1; + m_normaltextureunit = -1; + } + else { + GLint maxtextureunits; + ::glGetIntegerv( GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS, &maxtextureunits ); + if( maxtextureunits < 4 ) { + WriteLog( "Less than 4 texture units, shadow and reflection mapping will be disabled" ); + Global.BasicRenderer = true; + Global.RenderShadows = false; + m_diffusetextureunit = GL_TEXTURE0; + m_helpertextureunit = -1; + m_shadowtextureunit = -1; + m_normaltextureunit = -1; + } + } + + if( Global.iMultisampling ) { + WriteLog( "Using multisampling x" + std::to_string( 1 << Global.iMultisampling ) ); + } + + return true; +} + +glm::vec3 +opengl_renderer::pick_color( std::size_t const Index ) { +/* + // pick colours are set with step of 4 for some slightly easier visual debugging. not strictly needed but, eh + int const colourstep = 4; + int const componentcapacity = 256 / colourstep; + auto const redgreen = std::div( Index, componentcapacity * componentcapacity ); + auto const greenblue = std::div( redgreen.rem, componentcapacity ); + auto const blue = Index % componentcapacity; + return + glm::vec3 { + redgreen.quot * colourstep / 255.0f, + greenblue.quot * colourstep / 255.0f, + greenblue.rem * colourstep / 255.0f }; +*/ + // alternatively + return + glm::vec3{ + ( ( Index & 0xff0000 ) >> 16 ) / 255.0f, + ( ( Index & 0x00ff00 ) >> 8 ) / 255.0f, + ( Index & 0x0000ff ) / 255.0f }; + +} + +std::size_t +opengl_renderer::pick_index( glm::ivec3 const &Color ) { +/* + return ( + std::floor( Color.b / 4 ) + + std::floor( Color.g / 4 ) * 64 + + std::floor( Color.r / 4 ) * 64 * 64 ); +*/ + // alternatively + return + Color.b + + ( Color.g * 256 ) + + ( Color.r * 256 * 256 ); + +} + +//--------------------------------------------------------------------------- diff --git a/renderer.h b/renderer.h new file mode 100644 index 00000000..bf6c6d5f --- /dev/null +++ b/renderer.h @@ -0,0 +1,413 @@ +/* +This Source Code Form is subject to the +terms of the Mozilla Public License, v. +2.0. If a copy of the MPL was not +distributed with this file, You can +obtain one at +http://mozilla.org/MPL/2.0/. +*/ + +#pragma once + +#include "GL/glew.h" +#include "openglgeometrybank.h" +#include "material.h" +#include "light.h" +#include "lightarray.h" +#include "dumb3d.h" +#include "frustum.h" +#include "scene.h" +#include "simulationenvironment.h" +#include "memcell.h" + +#define EU07_USE_PICKING_FRAMEBUFFER +//#define EU07_USE_DEBUG_SHADOWMAP +//#define EU07_USE_DEBUG_CABSHADOWMAP +//#define EU07_USE_DEBUG_CAMERA +//#define EU07_USE_DEBUG_SOUNDEMITTERS +#define EU07_USEIMGUIIMPLOPENGL2 + +struct opengl_light : public basic_light { + + GLuint id { (GLuint)-1 }; + + void + apply_intensity( float const Factor = 1.0f ); + void + apply_angle(); + + opengl_light & + operator=( basic_light const &Right ) { + basic_light::operator=( Right ); + return *this; } +}; + +// encapsulates basic rendering setup. +// for modern opengl this translates to a specific collection of glsl shaders, +// for legacy opengl this is combination of blending modes, active texture units etc +struct opengl_technique { + +}; + +// simple camera object. paired with 'virtual camera' in the scene +class opengl_camera { + +public: +// constructors + opengl_camera() = default; +// methods: + inline + void + update_frustum() { update_frustum( m_projection, m_modelview ); } + void + update_frustum( glm::mat4 const &Projection, glm::mat4 const &Modelview ); + bool + visible( scene::bounding_area const &Area ) const; + bool + visible( TDynamicObject const *Dynamic ) const; + inline + glm::dvec3 const & + position() const { return m_position; } + inline + glm::dvec3 & + position() { return m_position; } + inline + glm::mat4 const & + projection() const { return m_projection; } + inline + glm::mat4 & + projection() { return m_projection; } + inline + glm::mat4 const & + modelview() const { return m_modelview; } + inline + glm::mat4 & + modelview() { return m_modelview; } + inline + std::vector & + frustum_points() { return m_frustumpoints; } + // transforms provided set of clip space points to world space + template + void + transform_to_world( Iterator_ First, Iterator_ Last ) const { + std::for_each( + First, Last, + [this]( glm::vec4 &point ) { + // transform each point using the cached matrix... + point = this->m_inversetransformation * point; + // ...and scale by transformed w + point = glm::vec4{ glm::vec3{ point } / point.w, 1.f }; } ); } + // debug helper, draws shape of frustum in world space + void + draw( glm::vec3 const &Offset ) const; + +private: +// members: + cFrustum m_frustum; + std::vector m_frustumpoints; // visualization helper; corners of defined frustum, in world space + glm::dvec3 m_position; + glm::mat4 m_projection; + glm::mat4 m_modelview; + glm::mat4 m_inversetransformation; // cached transformation to world space +}; + +// bare-bones render controller, in lack of anything better yet +class opengl_renderer { + +public: +// types +// constructors + opengl_renderer() = default; +// destructor + ~opengl_renderer() { gluDeleteQuadric( m_quadric ); } +// methods + bool + Init( GLFWwindow *Window ); + // main draw call. returns false on error + bool + Render(); + inline + float + Framerate() { return m_framerate; } + // geometry methods + // NOTE: hands-on geometry management is exposed as a temporary measure; ultimately all visualization data should be generated/handled automatically by the renderer itself + // creates a new geometry bank. returns: handle to the bank or NULL + gfx::geometrybank_handle + Create_Bank(); + // creates a new geometry chunk of specified type from supplied vertex data, in specified bank. returns: handle to the chunk or NULL + gfx::geometry_handle + Insert( gfx::vertex_array &Vertices, gfx::geometrybank_handle const &Geometry, int const Type ); + // replaces data of specified chunk with the supplied vertex data, starting from specified offset + bool + Replace( gfx::vertex_array &Vertices, gfx::geometry_handle const &Geometry, std::size_t const Offset = 0 ); + // adds supplied vertex data at the end of specified chunk + bool + Append( gfx::vertex_array &Vertices, gfx::geometry_handle const &Geometry ); + // provides direct access to vertex data of specfied chunk + gfx::vertex_array const & + Vertices( gfx::geometry_handle const &Geometry ) const; + // material methods + material_handle + Fetch_Material( std::string const &Filename, bool const Loadnow = true ); + void + Bind_Material( material_handle const Material ); + opengl_material const & + Material( material_handle const Material ) const; + // texture methods + texture_handle + Fetch_Texture( std::string const &Filename, bool const Loadnow = true ); + void + Bind_Texture( texture_handle const Texture ); + opengl_texture const & + Texture( texture_handle const Texture ) const; + // light methods + void + Disable_Lights(); + // utility methods + TSubModel const * + Pick_Control() const { return m_pickcontrolitem; } + scene::basic_node const * + Pick_Node() const { return m_picksceneryitem; } + glm::dvec3 + Mouse_Position() const { return m_worldmousecoordinates; } + // maintenance methods + void + Update( double const Deltatime ); + TSubModel * + Update_Pick_Control(); + scene::basic_node * + Update_Pick_Node(); + glm::dvec3 + Update_Mouse_Position(); + // debug methods + std::string const & + info_times() const; + std::string const & + info_stats() const; + +// members + GLenum static const sunlight { GL_LIGHT0 }; + std::size_t m_drawcount { 0 }; + +private: +// types + enum class rendermode { + none, + color, + shadows, + cabshadows, + reflections, + pickcontrols, + pickscenery + }; + + enum textureunit { + helper = 0, + shadows, + normals, + diffuse + }; + + struct debug_stats { + int dynamics { 0 }; + int models { 0 }; + int submodels { 0 }; + int paths { 0 }; + int traction { 0 }; + int shapes { 0 }; + int lines { 0 }; + int drawcalls { 0 }; + }; + + using section_sequence = std::vector; + using distancecell_pair = std::pair; + using cell_sequence = std::vector; + + struct renderpass_config { + + opengl_camera camera; + rendermode draw_mode { rendermode::none }; + float draw_range { 0.0f }; + }; + + struct units_state { + + bool diffuse { false }; + bool shadows { false }; + bool reflections { false }; + }; + + typedef std::vector opengllight_array; + +// methods + bool + Init_caps(); + void + setup_pass( renderpass_config &Config, rendermode const Mode, float const Znear = 0.f, float const Zfar = 1.f, bool const Ignoredebug = false ); + void + setup_matrices(); + void + setup_drawing( bool const Alpha = false ); + void + setup_units( bool const Diffuse, bool const Shadows, bool const Reflections ); + void + setup_shadow_map( GLuint const Texture, glm::mat4 const &Transformation ); + void + setup_shadow_color( glm::vec4 const &Shadowcolor ); + void + setup_environment_light( TEnvironmentType const Environment = e_flat ); + void + switch_units( bool const Diffuse, bool const Shadows, bool const Reflections ); + // helper, texture manager method; activates specified texture unit + void + select_unit( GLint const Textureunit ); + // runs jobs needed to generate graphics for specified render pass + void + Render_pass( rendermode const Mode ); + // creates dynamic environment cubemap + bool + Render_reflections(); + bool + Render( world_environment *Environment ); + void + Render( scene::basic_region *Region ); + void + Render( section_sequence::iterator First, section_sequence::iterator Last ); + void + Render( cell_sequence::iterator First, cell_sequence::iterator Last ); + void + Render( scene::shape_node const &Shape, bool const Ignorerange ); + void + Render( TAnimModel *Instance ); + bool + Render( TDynamicObject *Dynamic ); + bool + Render( TModel3d *Model, material_data const *Material, float const Squaredistance, Math3D::vector3 const &Position, glm::vec3 const &Angle ); + bool + Render( TModel3d *Model, material_data const *Material, float const Squaredistance ); + void + Render( TSubModel *Submodel ); + void + Render( TTrack *Track ); + void + Render( scene::basic_cell::path_sequence::const_iterator First, scene::basic_cell::path_sequence::const_iterator Last ); + bool + Render_cab( TDynamicObject const *Dynamic, bool const Alpha = false ); + void + Render( TMemCell *Memcell ); + void + Render_precipitation(); + void + Render_Alpha( scene::basic_region *Region ); + void + Render_Alpha( cell_sequence::reverse_iterator First, cell_sequence::reverse_iterator Last ); + void + Render_Alpha( TAnimModel *Instance ); + void + Render_Alpha( TTraction *Traction ); + void + Render_Alpha( scene::lines_node const &Lines ); + bool + Render_Alpha( TDynamicObject *Dynamic ); + bool + Render_Alpha( TModel3d *Model, material_data const *Material, float const Squaredistance, Math3D::vector3 const &Position, glm::vec3 const &Angle ); + bool + Render_Alpha( TModel3d *Model, material_data const *Material, float const Squaredistance ); + void + Render_Alpha( TSubModel *Submodel ); + void + Update_Lights( light_array &Lights ); + glm::vec3 + pick_color( std::size_t const Index ); + std::size_t + pick_index( glm::ivec3 const &Color ); + +// members + GLFWwindow *m_window { nullptr }; + gfx::geometrybank_manager m_geometry; + material_manager m_materials; + texture_manager m_textures; + opengl_light m_sunlight; + opengllight_array m_lights; +/* + float m_sunandviewangle; // cached dot product of sunlight and camera vectors +*/ + gfx::geometry_handle m_billboardgeometry { 0, 0 }; + texture_handle m_glaretexture { -1 }; + texture_handle m_suntexture { -1 }; + texture_handle m_moontexture { -1 }; + texture_handle m_reflectiontexture { -1 }; + GLUquadricObj *m_quadric { nullptr }; // helper object for drawing debug mode scene elements + // TODO: refactor framebuffer stuff into an object + bool m_framebuffersupport { false }; +#ifdef EU07_USE_PICKING_FRAMEBUFFER + GLuint m_pickframebuffer { 0 }; + GLuint m_picktexture { 0 }; + GLuint m_pickdepthbuffer { 0 }; +#endif + // main shadowmap resources + int m_shadowbuffersize { 2048 }; + GLuint m_shadowframebuffer { 0 }; + GLuint m_shadowtexture { 0 }; +#ifdef EU07_USE_DEBUG_SHADOWMAP + GLuint m_shadowdebugtexture{ 0 }; +#endif +#ifdef EU07_USE_DEBUG_CABSHADOWMAP + GLuint m_cabshadowdebugtexture{ 0 }; +#endif + glm::mat4 m_shadowtexturematrix; // conversion from camera-centric world space to light-centric clip space + // cab shadowmap resources + GLuint m_cabshadowframebuffer { 0 }; + GLuint m_cabshadowtexture { 0 }; + glm::mat4 m_cabshadowtexturematrix; // conversion from cab-centric world space to light-centric clip space + // environment map resources + GLuint m_environmentframebuffer { 0 }; + GLuint m_environmentcubetexture { 0 }; + GLuint m_environmentdepthbuffer { 0 }; + bool m_environmentcubetexturesupport { false }; // indicates whether we can use the dynamic environment cube map + int m_environmentcubetextureface { 0 }; // helper, currently processed cube map face + int m_environmentupdatetime { 0 }; // time of the most recent environment map update + glm::dvec3 m_environmentupdatelocation; // coordinates of most recent environment map update + + int m_helpertextureunit { GL_TEXTURE0 }; + int m_shadowtextureunit { GL_TEXTURE1 }; + int m_normaltextureunit { GL_TEXTURE2 }; + int m_diffusetextureunit{ GL_TEXTURE3 }; + units_state m_unitstate; + + unsigned int m_framestamp; // id of currently rendered gfx frame + float m_framerate; + double m_updateaccumulator { 0.0 }; +// double m_pickupdateaccumulator { 0.0 }; + std::string m_debugtimestext; + std::string m_pickdebuginfo; + debug_stats m_debugstats; + std::string m_debugstatstext; + + glm::vec4 m_baseambient { 0.0f, 0.0f, 0.0f, 1.0f }; + glm::vec4 m_shadowcolor { colors::shadow }; + float m_fogrange { 2000.f }; +// TEnvironmentType m_environment { e_flat }; + float m_specularopaquescalefactor { 1.f }; + float m_speculartranslucentscalefactor { 1.f }; + bool m_renderspecular{ false }; // controls whether to include specular component in the calculations + + renderpass_config m_renderpass; // parameters for current render pass + section_sequence m_sectionqueue; // list of sections in current render pass + cell_sequence m_cellqueue; + renderpass_config m_colorpass; // parametrs of most recent color pass + renderpass_config m_shadowpass; // parametrs of most recent shadowmap pass + renderpass_config m_cabshadowpass; // parameters of most recent cab shadowmap pass + std::vector m_pickcontrolsitems; + TSubModel *m_pickcontrolitem { nullptr }; + std::vector m_picksceneryitems; + scene::basic_node *m_picksceneryitem { nullptr }; + glm::vec3 m_worldmousecoordinates { 0.f }; +#ifdef EU07_USE_DEBUG_CAMERA + renderpass_config m_worldcamera; // debug item +#endif +}; + +extern opengl_renderer GfxRenderer; + +//--------------------------------------------------------------------------- diff --git a/resource.h b/resource.h index 52fca2ce..ead65dc1 100644 --- a/resource.h +++ b/resource.h @@ -2,7 +2,7 @@ // Microsoft Visual C++ generated include file. // Used by maszyna.rc // -#define IDI_ICON1 101 +//#define GLFW_ICON 101 // Next default values for new objects // diff --git a/scenarioloadermode.cpp b/scenarioloadermode.cpp new file mode 100644 index 00000000..128ce548 --- /dev/null +++ b/scenarioloadermode.cpp @@ -0,0 +1,79 @@ +/* +This Source Code Form is subject to the +terms of the Mozilla Public License, v. +2.0. If a copy of the MPL was not +distributed with this file, You can +obtain one at +http://mozilla.org/MPL/2.0/. +*/ + +#include "stdafx.h" +#include "scenarioloadermode.h" + +#include "globals.h" +#include "simulation.h" +#include "simulationtime.h" +#include "timer.h" +#include "application.h" +#include "scenarioloaderuilayer.h" +#include "renderer.h" +#include "logs.h" + + +scenarioloader_mode::scenarioloader_mode() { + + m_userinterface = std::make_shared(); +} + +// initializes internal data structures of the mode. returns: true on success, false otherwise +bool +scenarioloader_mode::init() { + // nothing to do here + return true; +} + +// mode-specific update of simulation data. returns: false on error, true otherwise +bool +scenarioloader_mode::update() { + + WriteLog( "\nLoading scenario..." ); + + auto timestart = std::chrono::system_clock::now(); + + if( true == simulation::State.deserialize( Global.SceneryFile ) ) { + WriteLog( "Scenario loading time: " + std::to_string( std::chrono::duration_cast( ( std::chrono::system_clock::now() - timestart ) ).count() ) + " seconds" ); + // TODO: implement and use next mode cue + Application.pop_mode(); + Application.push_mode( eu07_application::mode::driver ); + } + else { + ErrorLog( "Bad init: scenario loading failed" ); + Application.pop_mode(); + } + + return true; +} + +// maintenance method, called when the mode is activated +void +scenarioloader_mode::enter() { + + // TBD: hide cursor in fullscreen mode? + Application.set_cursor( GLFW_CURSOR_NORMAL ); + + simulation::is_ready = false; + + m_userinterface->set_background( "logo" ); + Application.set_title( Global.AppName + " (" + Global.SceneryFile + ")" ); + m_userinterface->set_progress(); + m_userinterface->set_progress( "Loading scenery / Wczytywanie scenerii" ); + GfxRenderer.Render(); +} + +// maintenance method, called when the mode is deactivated +void +scenarioloader_mode::exit() { + + simulation::Time.init(); + simulation::Environment.init(); +} diff --git a/scenarioloadermode.h b/scenarioloadermode.h new file mode 100644 index 00000000..630c8655 --- /dev/null +++ b/scenarioloadermode.h @@ -0,0 +1,43 @@ +/* +This Source Code Form is subject to the +terms of the Mozilla Public License, v. +2.0. If a copy of the MPL was not +distributed with this file, You can +obtain one at +http://mozilla.org/MPL/2.0/. +*/ + +#pragma once + +#include "applicationmode.h" + +class scenarioloader_mode : public application_mode { + +public: +// constructors + scenarioloader_mode(); +// methods + // initializes internal data structures of the mode. returns: true on success, false otherwise + bool + init() override; + // mode-specific update of simulation data. returns: false on error, true otherwise + bool + update() override; + // maintenance method, called when the mode is activated + void + enter() override; + // maintenance method, called when the mode is deactivated + void + exit() override; + // input handlers + void + on_key( int const Key, int const Scancode, int const Action, int const Mods ) override { ; } + void + on_cursor_pos( double const Horizontal, double const Vertical ) override { ; } + void + on_mouse_button( int const Button, int const Action, int const Mods ) override { ; } + void + on_scroll( double const Xoffset, double const Yoffset ) override { ; } + void + on_event_poll() override { ; } +}; diff --git a/scenarioloaderuilayer.h b/scenarioloaderuilayer.h new file mode 100644 index 00000000..c167a444 --- /dev/null +++ b/scenarioloaderuilayer.h @@ -0,0 +1,17 @@ +/* +This Source Code Form is subject to the +terms of the Mozilla Public License, v. +2.0. If a copy of the MPL was not +distributed with this file, You can +obtain one at +http://mozilla.org/MPL/2.0/. +*/ + +#pragma once + +#include "uilayer.h" + +class scenarioloader_ui : public ui_layer { + + // TODO: implement mode-specific elements +}; diff --git a/scene.cpp b/scene.cpp new file mode 100644 index 00000000..81933f3f --- /dev/null +++ b/scene.cpp @@ -0,0 +1,1623 @@ +/* +This Source Code Form is subject to the +terms of the Mozilla Public License, v. +2.0. If a copy of the MPL was not +distributed with this file, You can +obtain one at +http://mozilla.org/MPL/2.0/. +*/ + +#include "stdafx.h" +#include "scene.h" + +#include "simulation.h" +#include "globals.h" +#include "camera.h" +#include "animmodel.h" +#include "event.h" +#include "evlaunch.h" +#include "timer.h" +#include "logs.h" +#include "sn_utils.h" +#include "renderer.h" + +namespace scene { + +std::string const EU07_FILEEXTENSION_REGION { ".sbt" }; +std::uint32_t const EU07_FILEHEADER { MAKE_ID4( 'E','U','0','7' ) }; +std::uint32_t const EU07_FILEVERSION_REGION { MAKE_ID4( 'S', 'B', 'T', 1 ) }; + +// potentially activates event handler with the same name as provided node, and within handler activation range +void +basic_cell::on_click( TAnimModel const *Instance ) { + + for( auto *launcher : m_eventlaunchers ) { + if( ( launcher->name() == Instance->name() ) + && ( glm::length2( launcher->location() - Instance->location() ) < launcher->dRadius ) + && ( true == launcher->check_conditions() ) ) { + launch_event( launcher ); + } + } +} + +// legacy method, finds and assigns traction piece to specified pantograph of provided vehicle +void +basic_cell::update_traction( TDynamicObject *Vehicle, int const Pantographindex ) { + // Winger 170204 - szukanie trakcji nad pantografami + auto const vFront = glm::make_vec3( Vehicle->VectorFront().getArray() ); // wektor normalny dla płaszczyzny ruchu pantografu + auto const vUp = glm::make_vec3( Vehicle->VectorUp().getArray() ); // wektor pionu pudła (pochylony od pionu na przechyłce) + auto const vLeft = glm::make_vec3( Vehicle->VectorLeft().getArray() ); // wektor odległości w bok (odchylony od poziomu na przechyłce) + auto const position = glm::dvec3 { Vehicle->GetPosition() }; // współrzędne środka pojazdu + + auto pantograph = Vehicle->pants[ Pantographindex ].fParamPants; + auto const pantographposition = position + ( vLeft * pantograph->vPos.z ) + ( vUp * pantograph->vPos.y ) + ( vFront * pantograph->vPos.x ); + + for( auto *traction : m_directories.traction ) { + + // współczynniki równania parametrycznego + auto const paramfrontdot = glm::dot( traction->vParametric, vFront ); + auto const fRaParam = + -( glm::dot( traction->pPoint1, vFront ) - glm::dot( pantographposition, vFront ) ) + / ( paramfrontdot != 0.0 ? + paramfrontdot : + 0.001 ); // div0 trap + + if( ( fRaParam < -0.001 ) + || ( fRaParam > 1.001 ) ) { continue; } + // jeśli tylko jest w przedziale, wyznaczyć odległość wzdłuż wektorów vUp i vLeft + // punkt styku płaszczyzny z drutem (dla generatora łuku el.) + auto const vStyk = traction->pPoint1 + fRaParam * traction->vParametric; + // wektor musi się mieścić w przedziale ruchu pantografu + auto const vGdzie = vStyk - pantographposition; + auto fVertical = glm::dot( vGdzie, vUp ); + if( fVertical >= 0.0 ) { + // jeśli ponad pantografem (bo może łapać druty spod wiaduktu) + auto const fHorizontal = std::abs( glm::dot( vGdzie, vLeft ) ) - pantograph->fWidth; + + if( ( Global.bEnableTraction ) + && ( fVertical < pantograph->PantWys - 0.15 ) ) { + // jeśli drut jest niżej niż 15cm pod ślizgiem przełączamy w tryb połamania, o ile jedzie; + // (bEnableTraction) aby dało się jeździć na koślawych sceneriach + // i do tego jeszcze wejdzie pod ślizg + if( fHorizontal <= 0.0 ) { + // 0.635 dla AKP-1 AKP-4E + pantograph->PantWys = -1.0; // ujemna liczba oznacza połamanie + pantograph->hvPowerWire = nullptr; // bo inaczej się zasila w nieskończoność z połamanego + if( Vehicle->MoverParameters->EnginePowerSource.CollectorParameters.CollectorsNo > 0 ) { + // liczba pantografów teraz będzie mniejsza + --Vehicle->MoverParameters->EnginePowerSource.CollectorParameters.CollectorsNo; + } + if( DebugModeFlag ) { + ErrorLog( "Bad traction: " + Vehicle->name() + " broke pantograph at " + to_string( pantographposition ) ); + } + } + } + else if( fVertical < pantograph->PantTraction ) { + // ale niżej, niż poprzednio znaleziony + if( fHorizontal <= 0.0 ) { + // 0.635 dla AKP-1 AKP-4E + // to się musi mieścić w przedziale zaleznym od szerokości pantografu + pantograph->hvPowerWire = traction; // jakiś znaleziony + pantograph->PantTraction = fVertical; // zapamiętanie nowej wysokości + } + else if( fHorizontal < pantograph->fWidthExtra ) { + // czy zmieścił się w zakresie nabieżnika? problem jest, gdy nowy drut jest wyżej, + // wtedy pantograf odłącza się od starego, a na podniesienie do nowego potrzebuje czasu + // korekta wysokości o nabieżnik - drut nad nabieżnikiem jest geometrycznie jakby nieco wyżej + fVertical += 0.15 * fHorizontal / pantograph->fWidthExtra; + if( fVertical < pantograph->PantTraction ) { + // gdy po korekcie jest niżej, niż poprzednio znaleziony + // gdyby to wystarczyło, to możemy go uznać + pantograph->hvPowerWire = traction; // może być + pantograph->PantTraction = fVertical; // na razie liniowo na nabieżniku, dokładność poprawi się później + } + } + } + } + } +} + +// legacy method, updates sounds and polls event launchers within radius around specified point +void +basic_cell::update_events() { + + // event launchers + for( auto *launcher : m_eventlaunchers ) { + if( ( true == ( launcher->check_activation() && launcher->check_conditions() ) ) + && ( SquareMagnitude( launcher->location() - Global.pCamera.Pos ) < launcher->dRadius ) ) { + + launch_event( launcher ); + } + } +} + +// legacy method, updates sounds and polls event launchers within radius around specified point +void +basic_cell::update_sounds() { + + for( auto *sound : m_sounds ) { + sound->play_event(); + } + // TBD, TODO: move to sound renderer + for( auto *path : m_paths ) { + // dźwięki pojazdów, również niewidocznych + path->RenderDynSounds(); + } +} + +// legacy method, triggers radio-stop procedure for all vehicles located on paths in the cell +void +basic_cell::radio_stop() { + + for( auto *path : m_paths ) { + path->RadioStop(); + } +} + +// legacy method, adds specified path to the list of pieces undergoing state change +bool +basic_cell::RaTrackAnimAdd( TTrack *Track ) { + + if( false == m_geometrycreated ) { + // nie ma animacji, gdy nie widać + return true; + } + if (tTrackAnim) + tTrackAnim->RaAnimListAdd(Track); + else + tTrackAnim = Track; + return false; // będzie animowane... +} + +// legacy method, updates geometry for pieces in the animation list +void +basic_cell::RaAnimate( unsigned int const Framestamp ) { + + if( ( tTrackAnim == nullptr ) + || ( Framestamp == m_framestamp ) ) { + // nie ma nic do animowania + return; + } + tTrackAnim = tTrackAnim->RaAnimate(); // przeliczenie animacji kolejnego + + m_framestamp = Framestamp; +} + +// sends content of the class to provided stream +void +basic_cell::serialize( std::ostream &Output ) const { + + // region file version 0, cell data + // bounding area + m_area.serialize( Output ); + // NOTE: cell activation flag is set dynamically on load + // cell shapes + // shape count followed by opaque shape data + sn_utils::ls_uint32( Output, m_shapesopaque.size() ); + for( auto const &shape : m_shapesopaque ) { + shape.serialize( Output ); + } + // shape count followed by translucent shape data + sn_utils::ls_uint32( Output, m_shapestranslucent.size() ); + for( auto const &shape : m_shapestranslucent ) { + shape.serialize( Output ); + } + // cell lines + // line count followed by lines data + sn_utils::ls_uint32( Output, m_lines.size() ); + for( auto const &lines : m_lines ) { + lines.serialize( Output ); + } +} + +// restores content of the class from provided stream +void +basic_cell::deserialize( std::istream &Input ) { + + // region file version 0, cell data + // bounding area + m_area.deserialize( Input ); + // cell shapes + // shape count followed by opaque shape data + auto itemcount { sn_utils::ld_uint32( Input ) }; + while( itemcount-- ) { + m_shapesopaque.emplace_back( shape_node().deserialize( Input ) ); + } + itemcount = sn_utils::ld_uint32( Input ); + while( itemcount-- ) { + m_shapestranslucent.emplace_back( shape_node().deserialize( Input ) ); + } + itemcount = sn_utils::ld_uint32( Input ); + while( itemcount-- ) { + m_lines.emplace_back( lines_node().deserialize( Input ) ); + } + // cell activation flag + m_active = ( + ( true == m_active ) + || ( false == m_shapesopaque.empty() ) + || ( false == m_shapestranslucent.empty() ) + || ( false == m_lines.empty() ) ); +} + +// sends content of the class in legacy (text) format to provided stream +void +basic_cell::export_as_text( std::ostream &Output ) const { + + // text format export dumps only relevant basic objects + // sounds + for( auto const *sound : m_sounds ) { + sound->export_as_text( Output ); + } +} + +// adds provided shape to the cell +void +basic_cell::insert( shape_node Shape ) { + + m_active = true; + + // re-calculate cell radius, in case shape geometry extends outside the cell's boundaries + m_area.radius = std::max( + m_area.radius, + glm::length( m_area.center - Shape.data().area.center ) + Shape.data().area.radius ); + + auto const &shapedata { Shape.data() }; + auto &shapes = ( + shapedata.translucent ? + m_shapestranslucent : + m_shapesopaque ); + for( auto &targetshape : shapes ) { + // try to merge shapes with matching view ranges... + auto const &targetshapedata { targetshape.data() }; + if( ( shapedata.rangesquared_min == targetshapedata.rangesquared_min ) + && ( shapedata.rangesquared_max == targetshapedata.rangesquared_max ) + // ...and located close to each other (within arbitrary limit of 25m) + && ( glm::length( shapedata.area.center - targetshapedata.area.center ) < 25.0 ) ) { + + if( true == targetshape.merge( Shape ) ) { + // if the shape was merged there's nothing left to do + return; + } + } + } + // otherwise add the shape to the relevant list + Shape.origin( m_area.center ); + shapes.emplace_back( Shape ); +} + +// adds provided lines to the cell +void +basic_cell::insert( lines_node Lines ) { + + m_active = true; + + auto const &linesdata { Lines.data() }; + for( auto &targetlines : m_lines ) { + // try to merge shapes with matching view ranges... + auto const &targetlinesdata { targetlines.data() }; + if( ( linesdata.rangesquared_min == targetlinesdata.rangesquared_min ) + && ( linesdata.rangesquared_max == targetlinesdata.rangesquared_max ) + // ...and located close to each other (within arbitrary limit of 10m) + && ( glm::length( linesdata.area.center - targetlinesdata.area.center ) < 10.0 ) ) { + + if( true == targetlines.merge( Lines ) ) { + // if the shape was merged there's nothing left to do + return; + } + } + } + // otherwise add the shape to the relevant list + Lines.origin( m_area.center ); + m_lines.emplace_back( Lines ); +} + +// adds provided path to the cell +void +basic_cell::insert( TTrack *Path ) { + + m_active = true; + + Path->origin( m_area.center ); + m_paths.emplace_back( Path ); + // animation hook + Path->RaOwnerSet( this ); + // re-calculate cell radius, in case track extends outside the cell's boundaries + m_area.radius = std::max( + m_area.radius, + static_cast( glm::length( m_area.center - Path->location() ) + Path->radius() + 25.f ) ); // extra margin to prevent driven vehicle from flicking +} + +// adds provided traction piece to the cell +void +basic_cell::insert( TTraction *Traction ) { + + m_active = true; + + Traction->origin( m_area.center ); + m_traction.emplace_back( Traction ); + // re-calculate cell bounding area, in case traction piece extends outside the cell's boundaries + enclose_area( Traction ); +} + +// adds provided model instance to the cell +void +basic_cell::insert( TAnimModel *Instance ) { + + m_active = true; + + auto const flags = Instance->Flags(); + auto alpha = + ( Instance->Material() != nullptr ? + Instance->Material()->textures_alpha : + 0x30300030 ); + + // assign model to appropriate render phases + if( alpha & flags & 0x2F2F002F ) { + // translucent pieces + m_instancetranslucent.emplace_back( Instance ); + } + alpha ^= 0x0F0F000F; // odwrócenie flag tekstur, aby wyłapać nieprzezroczyste + if( alpha & flags & 0x1F1F001F ) { + // opaque pieces + m_instancesopaque.emplace_back( Instance ); + } + // re-calculate cell bounding area, in case model extends outside the cell's boundaries + enclose_area( Instance ); +} + +// adds provided sound instance to the cell +void +basic_cell::insert( sound_source *Sound ) { + + m_active = true; + + m_sounds.emplace_back( Sound ); + // NOTE: sound sources are virtual 'points' hence they don't ever expand cell range +} + +// adds provided sound instance to the cell +void +basic_cell::insert( TEventLauncher *Launcher ) { + + m_active = true; + + m_eventlaunchers.emplace_back( Launcher ); + // re-calculate cell bounding area, in case launcher range extends outside the cell's boundaries + enclose_area( Launcher ); +} + +// adds provided memory cell to the cell +void +basic_cell::insert( TMemCell *Memorycell ) { + + m_active = true; + + m_memorycells.emplace_back( Memorycell ); + // NOTE: memory cells are virtual 'points' hence they don't ever expand cell range +} + +// removes provided model instance from the cell +void +basic_cell::erase( TAnimModel *Instance ) { + + auto const flags = Instance->Flags(); + auto alpha = + ( Instance->Material() != nullptr ? + Instance->Material()->textures_alpha : + 0x30300030 ); + + if( alpha & flags & 0x2F2F002F ) { + // instance has translucent pieces + m_instancetranslucent.erase( + std::remove_if( + std::begin( m_instancetranslucent ), std::end( m_instancetranslucent ), + [=]( TAnimModel *instance ) { + return instance == Instance; } ), + std::end( m_instancetranslucent ) ); + } + alpha ^= 0x0F0F000F; // odwrócenie flag tekstur, aby wyłapać nieprzezroczyste + if( alpha & flags & 0x1F1F001F ) { + // instance has opaque pieces + m_instancesopaque.erase( + std::remove_if( + std::begin( m_instancesopaque ), std::end( m_instancesopaque ), + [=]( TAnimModel *instance ) { + return instance == Instance; } ), + std::end( m_instancesopaque ) ); + } + // TODO: update cell bounding area +} + +// removes provided memory cell from the cell +void +basic_cell::erase( TMemCell *Memorycell ) { + + m_memorycells.erase( + std::remove_if( + std::begin( m_memorycells ), std::end( m_memorycells ), + [=]( TMemCell *memorycell ) { + return memorycell == Memorycell; } ), + std::end( m_memorycells ) ); +} + +// registers provided path in the lookup directory of the cell +void +basic_cell::register_end( TTrack *Path ) { + + m_directories.paths.emplace_back( Path ); + // eliminate potential duplicates + m_directories.paths.erase( + std::unique( + std::begin( m_directories.paths ), + std::end( m_directories.paths ) ), + std::end( m_directories.paths ) ); +} + +// registers provided traction piece in the lookup directory of the cell +void +basic_cell::register_end( TTraction *Traction ) { + + m_directories.traction.emplace_back( Traction ); + // eliminate potential duplicates + m_directories.traction.erase( + std::unique( + std::begin( m_directories.traction ), + std::end( m_directories.traction ) ), + std::end( m_directories.traction ) ); +} + +// find a vehicle located nearest to specified point, within specified radius, optionally ignoring vehicles without drivers. reurns: located vehicle and distance +std::tuple +basic_cell::find( glm::dvec3 const &Point, float const Radius, bool const Onlycontrolled, bool const Findbycoupler ) const { + + TDynamicObject *vehiclenearest { nullptr }; + float leastdistance { std::numeric_limits::max() }; + float distance; + float const distancecutoff { Radius * Radius }; // we'll ignore vehicles farther than this + + for( auto *path : m_paths ) { + for( auto *vehicle : path->Dynamics ) { + if( ( true == Onlycontrolled ) + && ( vehicle->Mechanik == nullptr ) ) { + continue; + } + if( false == Findbycoupler ) { + // basic search, checks vehicles' center points + distance = glm::length2( glm::dvec3{ vehicle->GetPosition() } - Point ); + } + else { + // alternative search, checks positions of vehicles' couplers + distance = std::min( + glm::length2( glm::dvec3{ vehicle->HeadPosition() } - Point ), + glm::length2( glm::dvec3{ vehicle->RearPosition() } - Point ) ); + } + if( ( distance > distancecutoff ) + || ( distance > leastdistance ) ){ + continue; + } + std::tie( vehiclenearest, leastdistance ) = std::tie( vehicle, distance ); + } + } + return { vehiclenearest, leastdistance }; +} + +// finds a path with one of its ends located in specified point. returns: located path and id of the matching endpoint +std::tuple +basic_cell::find( glm::dvec3 const &Point, TTrack const *Exclude ) const { + + Math3D::vector3 point { Point.x, Point.y, Point.z }; // sad workaround until math classes unification + int endpointid; + + for( auto *path : m_directories.paths ) { + + if( path == Exclude ) { continue; } + + endpointid = path->TestPoint( &point ); + if( endpointid >= 0 ) { + + return { path, endpointid }; + } + } + return { nullptr, -1 }; +} + +// finds a traction piece with one of its ends located in specified point. returns: located traction piece and id of the matching endpoint +std::tuple +basic_cell::find( glm::dvec3 const &Point, TTraction const *Exclude ) const { + + int endpointid; + + for( auto *traction : m_directories.traction ) { + + if( traction == Exclude ) { continue; } + + endpointid = traction->TestPoint( Point ); + if( endpointid >= 0 ) { + + return { traction, endpointid }; + } + } + return { nullptr, -1 }; +} + +// finds a traction piece located nearest to specified point, sharing section with specified other piece and powered in specified direction. returns: located traction piece +std::tuple +basic_cell::find( glm::dvec3 const &Point, TTraction const *Other, int const Currentdirection ) const { + + TTraction + *tractionnearest { nullptr }; + float + distance, + distancenearest { std::numeric_limits::max() }; + int endpoint, + endpointnearest { -1 }; + + for( auto *traction : m_directories.traction ) { + + if( ( traction == Other ) + || ( traction->psSection != Other->psSection ) + || ( traction == Other->hvNext[ 0 ] ) + || ( traction == Other->hvNext[ 1 ] ) ) { + // ignore pieces from different sections, and ones connected to the other piece + continue; + } + endpoint = ( + glm::dot( traction->vParametric, Other->vParametric ) >= 0.0 ? + Currentdirection ^ 1 : + Currentdirection ); + if( ( traction->psPower[ endpoint ] == nullptr ) + || ( traction->fResistance[ endpoint ] < 0.0 ) ) { + continue; + } + distance = glm::length2( traction->location() - Point ); + if( distance < distancenearest ) { + std::tie( tractionnearest, endpointnearest, distancenearest ) = std::tie( traction, endpoint, distance ); + } + } + return { tractionnearest, endpointnearest, distancenearest }; +} + +// sets center point of the section +void +basic_cell::center( glm::dvec3 Center ) { + + m_area.center = Center; + // NOTE: we should also update origin point for the contained nodes, but in practice we can skip this + // as all nodes will be added only after the proper center point was set, and won't change +} + +// generates renderable version of held non-instanced geometry +void +basic_cell::create_geometry( gfx::geometrybank_handle const &Bank ) { + + if( false == m_active ) { return; } // nothing to do here + + for( auto &shape : m_shapesopaque ) { shape.create_geometry( Bank ); } + for( auto &shape : m_shapestranslucent ) { shape.create_geometry( Bank ); } + for( auto *path : m_paths ) { path->create_geometry( Bank ); } + for( auto *traction : m_traction ) { traction->create_geometry( Bank ); } + for( auto &lines : m_lines ) { lines.create_geometry( Bank ); } + // arrange content by assigned materials to minimize state switching + std::sort( + std::begin( m_paths ), std::end( m_paths ), + TTrack::sort_by_material ); + + m_geometrycreated = true; // helper for legacy animation code, get rid of it after refactoring +} + +// executes event assigned to specified launcher +void +basic_cell::launch_event( TEventLauncher *Launcher ) { + + WriteLog( "Eventlauncher " + Launcher->name() ); + if( ( true == Global.shiftState ) + && ( Launcher->Event2 != nullptr ) ) { + simulation::Events.AddToQuery( Launcher->Event2, nullptr ); + } + else if( Launcher->Event1 ) { + simulation::Events.AddToQuery( Launcher->Event1, nullptr ); + } +} + +// adjusts cell bounding area to enclose specified node +void +basic_cell::enclose_area( scene::basic_node *Node ) { + + m_area.radius = std::max( + m_area.radius, + static_cast( glm::length( m_area.center - Node->location() ) + Node->radius() ) ); +} + + + +// potentially activates event handler with the same name as provided node, and within handler activation range +void +basic_section::on_click( TAnimModel const *Instance ) { + + cell( Instance->location() ).on_click( Instance ); +} + +// legacy method, finds and assigns traction piece(s) to pantographs of provided vehicle +void +basic_section::update_traction( TDynamicObject *Vehicle, int const Pantographindex ) { + + auto const vFront = glm::make_vec3( Vehicle->VectorFront().getArray() ); // wektor normalny dla płaszczyzny ruchu pantografu + auto const vUp = glm::make_vec3( Vehicle->VectorUp().getArray() ); // wektor pionu pudła (pochylony od pionu na przechyłce) + auto const vLeft = glm::make_vec3( Vehicle->VectorLeft().getArray() ); // wektor odległości w bok (odchylony od poziomu na przechyłce) + auto const position = glm::dvec3{ Vehicle->GetPosition() }; // współrzędne środka pojazdu + + auto pantograph = Vehicle->pants[ Pantographindex ].fParamPants; + auto const pantographposition = position + ( vLeft * pantograph->vPos.z ) + ( vUp * pantograph->vPos.y ) + ( vFront * pantograph->vPos.x ); + + auto const radius { EU07_CELLSIZE * 0.5 }; // redius around point of interest + + for( auto &cell : m_cells ) { + // we reject early cells which aren't within our area of interest + if( glm::length2( cell.area().center - pantographposition ) < ( ( cell.area().radius + radius ) * ( cell.area().radius + radius ) ) ) { + cell.update_traction( Vehicle, Pantographindex ); + } + } +} + +// legacy method, polls event launchers within radius around specified point +void +basic_section::update_events( glm::dvec3 const &Location, float const Radius ) { + + for( auto &cell : m_cells ) { + + if( glm::length2( cell.area().center - Location ) < ( ( cell.area().radius + Radius ) * ( cell.area().radius + Radius ) ) ) { + // we reject cells which aren't within our area of interest + cell.update_events(); + } + } +} + +// legacy method, updates sounds within radius around specified point +void +basic_section::update_sounds( glm::dvec3 const &Location, float const Radius ) { + + for( auto &cell : m_cells ) { + + if( glm::length2( cell.area().center - Location ) < ( ( cell.area().radius + Radius ) * ( cell.area().radius + Radius ) ) ) { + // we reject cells which aren't within our area of interest + cell.update_sounds(); + } + } +} + +// legacy method, triggers radio-stop procedure for all vehicles in 2km radius around specified location +void +basic_section::radio_stop( glm::dvec3 const &Location, float const Radius ) { + + for( auto &cell : m_cells ) { + + if( glm::length2( cell.area().center - Location ) < ( ( cell.area().radius + Radius ) * ( cell.area().radius + Radius ) ) ) { + // we reject cells which aren't within our area of interest + cell.radio_stop(); + } + } +} + +// sends content of the class to provided stream +void +basic_section::serialize( std::ostream &Output ) const { + + auto const sectionstartpos { Output.tellp() }; + + // region file version 0, section data + // section size + sn_utils::ls_uint32( Output, 0 ); + // bounding area + m_area.serialize( Output ); + // section shapes: shape count followed by shape data + sn_utils::ls_uint32( Output, m_shapes.size() ); + for( auto const &shape : m_shapes ) { + shape.serialize( Output ); + } + // partitioned data + for( auto const &cell : m_cells ) { + cell.serialize( Output ); + } + // all done; calculate and record section size + auto const sectionendpos { Output.tellp() }; + Output.seekp( sectionstartpos ); + sn_utils::ls_uint32( Output, static_cast( ( sizeof( uint32_t ) + ( sectionendpos - sectionstartpos ) ) ) ); + Output.seekp( sectionendpos ); +} + +// restores content of the class from provided stream +void +basic_section::deserialize( std::istream &Input ) { + + // region file version 0, section data + // bounding area + m_area.deserialize( Input ); + // section shapes: shape count followed by shape data + auto shapecount { sn_utils::ld_uint32( Input ) }; + while( shapecount-- ) { + m_shapes.emplace_back( shape_node().deserialize( Input ) ); + } + // partitioned data + for( auto &cell : m_cells ) { + cell.deserialize( Input ); + } +} + +// sends content of the class in legacy (text) format to provided stream +void +basic_section::export_as_text( std::ostream &Output ) const { + + // text format export dumps only relevant basic objects from non-empty cells + for( auto const &cell : m_cells ) { + cell.export_as_text( Output ); + } +} + +// adds provided shape to the section +void +basic_section::insert( shape_node Shape ) { + + auto const &shapedata = Shape.data(); + + // re-calculate section radius, in case shape geometry extends outside the section's boundaries + m_area.radius = std::max( + m_area.radius, + static_cast( glm::length( m_area.center - shapedata.area.center ) + shapedata.area.radius ) ); + + if( ( true == shapedata.translucent ) + || ( shapedata.rangesquared_max <= 90000.0 ) + || ( shapedata.rangesquared_min > 0.0 ) ) { + // small, translucent or not always visible shapes are placed in the sub-cells + cell( shapedata.area.center ).insert( Shape ); + } + else { + // large, opaque shapes are placed on section level + for( auto &shape : m_shapes ) { + // check first if the shape can't be merged with one of the shapes already present in the section + if( true == shape.merge( Shape ) ) { + // if the shape was merged there's nothing left to do + return; + } + } + // otherwise add the shape to the section's list + Shape.origin( m_area.center ); + m_shapes.emplace_back( Shape ); + } +} + +// adds provided lines to the section +void +basic_section::insert( lines_node Lines ) { + + cell( Lines.data().area.center ).insert( Lines ); +} + +// find a vehicle located nearest to specified point, within specified radius, optionally ignoring vehicles without drivers. reurns: located vehicle and distance +std::tuple +basic_section::find( glm::dvec3 const &Point, float const Radius, bool const Onlycontrolled, bool const Findbycoupler ) { + + // go through sections within radius of interest, and pick the nearest candidate + TDynamicObject + *vehiclefound, + *vehiclenearest { nullptr }; + float + distancefound, + distancenearest { std::numeric_limits::max() }; + + for( auto &cell : m_cells ) { + // we reject early cells which aren't within our area of interest + if( glm::length2( cell.area().center - Point ) > ( ( cell.area().radius + Radius ) * ( cell.area().radius + Radius ) ) ) { + continue; + } + std::tie( vehiclefound, distancefound ) = cell.find( Point, Radius, Onlycontrolled, Findbycoupler ); + if( ( vehiclefound != nullptr ) + && ( distancefound < distancenearest ) ) { + + std::tie( vehiclenearest, distancenearest ) = std::tie( vehiclefound, distancefound ); + } + } + return { vehiclenearest, distancenearest }; +} + +// finds a path with one of its ends located in specified point. returns: located path and id of the matching endpoint +std::tuple +basic_section::find( glm::dvec3 const &Point, TTrack const *Exclude ) { + + return cell( Point ).find( Point, Exclude ); +} + +// finds a traction piece with one of its ends located in specified point. returns: located traction piece and id of the matching endpoint +std::tuple +basic_section::find( glm::dvec3 const &Point, TTraction const *Exclude ) { + + return cell( Point ).find( Point, Exclude ); +} + +// finds a traction piece located nearest to specified point, sharing section with specified other piece and powered in specified direction. returns: located traction piece +std::tuple +basic_section::find( glm::dvec3 const &Point, TTraction const *Other, int const Currentdirection ) { + + // go through sections within radius of interest, and pick the nearest candidate + TTraction + *tractionfound, + *tractionnearest { nullptr }; + float + distancefound, + distancenearest { std::numeric_limits::max() }; + int + endpointfound, + endpointnearest { -1 }; + + auto const radius { 0.0 }; // { EU07_CELLSIZE * 0.5 }; // experimentally limited, check if it has any negative effect + + for( auto &cell : m_cells ) { + // we reject early cells which aren't within our area of interest + if( glm::length2( cell.area().center - Point ) > ( ( cell.area().radius + radius ) * ( cell.area().radius + radius ) ) ) { + continue; + } + std::tie( tractionfound, endpointfound, distancefound ) = cell.find( Point, Other, Currentdirection ); + if( ( tractionfound != nullptr ) + && ( distancefound < distancenearest ) ) { + + std::tie( tractionnearest, endpointnearest, distancenearest ) = std::tie( tractionfound, endpointfound, distancefound ); + } + } + return { tractionnearest, endpointnearest, distancenearest }; +} + +// sets center point of the section +void +basic_section::center( glm::dvec3 Center ) { + + m_area.center = Center; + // set accordingly center points of the section's partitioning cells + // NOTE: we should also update origin point for the contained nodes, but in practice we can skip this + // as all nodes will be added only after the proper center point was set, and won't change + auto const centeroffset = -( EU07_SECTIONSIZE / EU07_CELLSIZE / 2 * EU07_CELLSIZE ) + EU07_CELLSIZE / 2; + glm::dvec3 sectioncornercenter { m_area.center + glm::dvec3{ centeroffset, 0, centeroffset } }; + auto row { 0 }, column { 0 }; + for( auto &cell : m_cells ) { + cell.center( sectioncornercenter + glm::dvec3{ column * EU07_CELLSIZE, 0.0, row * EU07_CELLSIZE } ); + if( ++column >= EU07_SECTIONSIZE / EU07_CELLSIZE ) { + ++row; + column = 0; + } + } +} + +// generates renderable version of held non-instanced geometry +void +basic_section::create_geometry() { + + if( true == m_geometrycreated ) { return; } + else { + // mark it done for future checks + m_geometrycreated = true; + } + + // since sections can be empty, we're doing lazy initialization of the geometry bank, when something may actually use it + if( m_geometrybank == null_handle ) { + m_geometrybank = GfxRenderer.Create_Bank(); + } + + for( auto &shape : m_shapes ) { + shape.create_geometry( m_geometrybank ); + } + for( auto &cell : m_cells ) { + cell.create_geometry( m_geometrybank ); + } +} + +// provides access to section enclosing specified point +basic_cell & +basic_section::cell( glm::dvec3 const &Location ) { + + auto const column = static_cast( std::floor( ( Location.x - ( m_area.center.x - EU07_SECTIONSIZE / 2 ) ) / EU07_CELLSIZE ) ); + auto const row = static_cast( std::floor( ( Location.z - ( m_area.center.z - EU07_SECTIONSIZE / 2 ) ) / EU07_CELLSIZE ) ); + + return + m_cells[ + clamp( row, 0, ( EU07_SECTIONSIZE / EU07_CELLSIZE ) - 1 ) * ( EU07_SECTIONSIZE / EU07_CELLSIZE ) + + clamp( column, 0, ( EU07_SECTIONSIZE / EU07_CELLSIZE ) - 1 ) ] ; +} + + + +basic_region::basic_region() { + + m_sections.fill( nullptr ); +} + +basic_region::~basic_region() { + + for( auto *section : m_sections ) { if( section != nullptr ) { delete section; } } +} + +// potentially activates event handler with the same name as provided node, and within handler activation range +void +basic_region::on_click( TAnimModel const *Instance ) { + + if( Instance->name().empty() || ( Instance->name() == "none" ) ) { return; } + + auto const location { Instance->location() }; + + if( point_inside( location ) ) { + section( location ).on_click( Instance ); + } +} + +// legacy method, polls event launchers around camera +void +basic_region::update_events() { + // render events and sounds from sectors near enough to the viewer + auto const range = EU07_SECTIONSIZE; // arbitrary range + auto const §ionlist = sections( Global.pCamera.Pos, range ); + for( auto *section : sectionlist ) { + section->update_events( Global.pCamera.Pos, range ); + } +} + +// legacy method, updates sounds and polls event launchers around camera +void +basic_region::update_sounds() { + // render events and sounds from sectors near enough to the viewer + auto const range = 2750.f; // audible range of 100 db sound + auto const §ionlist = sections( Global.pCamera.Pos, range ); + for( auto *section : sectionlist ) { + section->update_sounds( Global.pCamera.Pos, range ); + } +} + +// legacy method, finds and assigns traction piece(s) to pantographs of provided vehicle +void +basic_region::update_traction( TDynamicObject *Vehicle, int const Pantographindex ) { + // TODO: convert vectors to transformation matrix and pass them down the chain along with calculated position + auto const vFront = glm::make_vec3( Vehicle->VectorFront().getArray() ); // wektor normalny dla płaszczyzny ruchu pantografu + auto const vUp = glm::make_vec3( Vehicle->VectorUp().getArray() ); // wektor pionu pudła (pochylony od pionu na przechyłce) + auto const vLeft = glm::make_vec3( Vehicle->VectorLeft().getArray() ); // wektor odległości w bok (odchylony od poziomu na przechyłce) + auto const position = glm::dvec3 { Vehicle->GetPosition() }; // współrzędne środka pojazdu + + auto p = Vehicle->pants[ Pantographindex ].fParamPants; + auto const pant0 = position + ( vLeft * p->vPos.z ) + ( vUp * p->vPos.y ) + ( vFront * p->vPos.x ); + p->PantTraction = std::numeric_limits::max(); // taka za duża wartość + + auto const §ionlist = sections( pant0, EU07_CELLSIZE * 0.5 ); + for( auto *section : sectionlist ) { + section->update_traction( Vehicle, Pantographindex ); + } +} + +// checks whether specified file is a valid region data file +bool +basic_region::is_scene( std::string const &Scenariofile ) const { + + auto filename { Scenariofile }; + while( filename[ 0 ] == '$' ) { + // trim leading $ char rainsted utility may add to the base name for modified .scn files + filename.erase( 0, 1 ); + } + erase_extension( filename ); + filename = Global.asCurrentSceneryPath + filename; + filename += EU07_FILEEXTENSION_REGION; + + if( false == FileExists( filename ) ) { + return false; + } + // file type and version check + std::ifstream input( filename, std::ios::binary ); + + uint32_t headermain{ sn_utils::ld_uint32( input ) }; + uint32_t headertype{ sn_utils::ld_uint32( input ) }; + + if( ( headermain != EU07_FILEHEADER + || ( headertype != EU07_FILEVERSION_REGION ) ) ) { + // wrong file type + return false; + } + + return true; +} + +// stores content of the class in file with specified name +void +basic_region::serialize( std::string const &Scenariofile ) const { + + auto filename { Scenariofile }; + while( filename[ 0 ] == '$' ) { + // trim leading $ char rainsted utility may add to the base name for modified .scn files + filename.erase( 0, 1 ); + } + erase_extension( filename ); + filename = Global.asCurrentSceneryPath + filename; + filename += EU07_FILEEXTENSION_REGION; + + std::ofstream output { filename, std::ios::binary }; + + // region file version 1 + // header: EU07SBT + version (0-255) + sn_utils::ls_uint32( output, EU07_FILEHEADER ); + sn_utils::ls_uint32( output, EU07_FILEVERSION_REGION ); + // sections + // TBD, TODO: build table of sections and file offsets, if we postpone section loading until they're within range + std::uint32_t sectioncount { 0 }; + for( auto *section : m_sections ) { + if( section != nullptr ) { + ++sectioncount; + } + } + // section count, followed by section data + sn_utils::ls_uint32( output, sectioncount ); + std::uint32_t sectionindex { 0 }; + for( auto *section : m_sections ) { + // section data: section index, followed by length of section data, followed by section data + if( section != nullptr ) { + sn_utils::ls_uint32( output, sectionindex ); + section->serialize( output ); } + ++sectionindex; + } +} + +// restores content of the class from file with specified name. returns: true on success, false otherwise +bool +basic_region::deserialize( std::string const &Scenariofile ) { + + auto filename { Scenariofile }; + while( filename[ 0 ] == '$' ) { + // trim leading $ char rainsted utility may add to the base name for modified .scn files + filename.erase( 0, 1 ); + } + erase_extension( filename ); + filename = Global.asCurrentSceneryPath + filename; + filename += EU07_FILEEXTENSION_REGION; + + if( false == FileExists( filename ) ) { + return false; + } + // region file version 1 + // file type and version check + std::ifstream input( filename, std::ios::binary ); + + uint32_t headermain { sn_utils::ld_uint32( input ) }; + uint32_t headertype { sn_utils::ld_uint32( input ) }; + + if( ( headermain != EU07_FILEHEADER + || ( headertype != EU07_FILEVERSION_REGION ) ) ) { + // wrong file type + WriteLog( "Bad file: \"" + filename + "\" is of either unrecognized type or version" ); + return false; + } + // sections + // TBD, TODO: build table of sections and file offsets, if we postpone section loading until they're within range + // section count + auto sectioncount { sn_utils::ld_uint32( input ) }; + while( sectioncount-- ) { + // section index, followed by section data size, followed by section data + auto const sectionindex { sn_utils::ld_uint32( input ) }; + auto const sectionsize { sn_utils::ld_uint32( input ) }; + if( m_sections[ sectionindex ] == nullptr ) { + m_sections[ sectionindex ] = new basic_section(); + } + m_sections[ sectionindex ]->deserialize( input ); + } + + return true; +} + +// sends content of the class in legacy (text) format to provided stream +void +basic_region::export_as_text( std::ostream &Output ) const { + + for( auto *section : m_sections ) { + // text format export dumps only relevant basic objects from non-empty sections + if( section != nullptr ) { + section->export_as_text( Output ); + } + } +} + +// legacy method, links specified path piece with potential neighbours +void +basic_region::TrackJoin( TTrack *Track ) { + // wyszukiwanie sąsiednich torów do podłączenia (wydzielone na użytek obrotnicy) + TTrack *matchingtrack; + int endpointid; + if( Track->CurrentPrev() == nullptr ) { + std::tie( matchingtrack, endpointid ) = find_path( Track->CurrentSegment()->FastGetPoint_0(), Track ); + switch( endpointid ) { + case 0: + Track->ConnectPrevPrev( matchingtrack, 0 ); + break; + case 1: + Track->ConnectPrevNext( matchingtrack, 1 ); + break; + } + } + if( Track->CurrentNext() == nullptr ) { + std::tie( matchingtrack, endpointid ) = find_path( Track->CurrentSegment()->FastGetPoint_1(), Track ); + switch( endpointid ) { + case 0: + Track->ConnectNextPrev( matchingtrack, 0 ); + break; + case 1: + Track->ConnectNextNext( matchingtrack, 1 ); + break; + } + } +} + +// legacy method, triggers radio-stop procedure for all vehicles in 2km radius around specified location +void +basic_region::RadioStop( glm::dvec3 const &Location ) { + + auto const range = 2000.f; + auto const §ionlist = sections( Location, range ); + for( auto *section : sectionlist ) { + section->radio_stop( Location, range ); + } +} + +std::vector switchtrackbedtextures { + "rozkrz8r150-1pods-new", + "rozkrz8r150-2pods-new", + "rozkrz34r150-tpbps-new2", + "rozkrz34r150-tpd1", + "rkpd34r190-tpd1", + "rkpd34r190-tpd2", + "rkpd34r190-tpd-oil2", + "zwr41r500", + "zwrot-tpd-oil1", + "zwrot34r300pods-new" }; + +void +basic_region::insert( shape_node Shape, scratch_data &Scratchpad, bool const Transform ) { + + if( Global.CreateSwitchTrackbeds ) { + + auto const materialname{ GfxRenderer.Material( Shape.data().material ).name }; + for( auto const &switchtrackbedtexture : switchtrackbedtextures ) { + if( materialname.find( switchtrackbedtexture ) != std::string::npos ) { + // geometry with blacklisted texture, part of old switch trackbed; ignore it + return; + } + } + } + // shape might need to be split into smaller pieces, so we create list of nodes instead of just single one + // using deque so we can do single pass iterating and addding generated pieces without invalidating anything + std::deque shapes { Shape }; + auto &shape = shapes.front(); + if( shape.m_data.vertices.empty() ) { return; } + + // adjust input if necessary: + if( true == Transform ) { + // shapes generated from legacy terrain come with world space coordinates and don't need processing + if( Scratchpad.location.rotation != glm::vec3( 0, 0, 0 ) ) { + // rotate... + auto const rotation = glm::radians( Scratchpad.location.rotation ); + for( auto &vertex : shape.m_data.vertices ) { + vertex.position = glm::rotateZ( vertex.position, rotation.z ); + vertex.position = glm::rotateX( vertex.position, rotation.x ); + vertex.position = glm::rotateY( vertex.position, rotation.y ); + vertex.normal = glm::rotateZ( vertex.normal, rotation.z ); + vertex.normal = glm::rotateX( vertex.normal, rotation.x ); + vertex.normal = glm::rotateY( vertex.normal, rotation.y ); + } + } + if( ( false == Scratchpad.location.offset.empty() ) + && ( Scratchpad.location.offset.top() != glm::dvec3( 0, 0, 0 ) ) ) { + // ...and move + auto const offset = Scratchpad.location.offset.top(); + for( auto &vertex : shape.m_data.vertices ) { + vertex.position += offset; + } + } + // calculate bounding area + for( auto const &vertex : shape.m_data.vertices ) { + shape.m_data.area.center += vertex.position; + } + shape.m_data.area.center /= shape.m_data.vertices.size(); + // trim the shape if needed. trimmed parts will be added to list as separate nodes + for( std::size_t index = 0; index < shapes.size(); ++index ) { + while( true == RaTriangleDivider( shapes[ index ], shapes ) ) { + ; // all work is done during expression check + } + } + } + // move the data into appropriate section(s) + for( auto &shape : shapes ) { + // with the potential splitting done we can calculate each chunk's bounding radius + shape.compute_radius(); + if( point_inside( shape.m_data.area.center ) ) { + // NOTE: nodes placed outside of region boundaries are discarded + section( shape.m_data.area.center ).insert( shape ); + } + else { + ErrorLog( + "Bad scenario: shape node" + ( + shape.m_name.empty() ? + "" : + " \"" + shape.m_name + "\"" ) + + " placed in location outside region bounds (" + to_string( shape.m_data.area.center ) + ")" ); + } + } +} + +// inserts provided lines in the region +void +basic_region::insert( lines_node Lines, scratch_data &Scratchpad ) { + + if( Lines.m_data.vertices.empty() ) { return; } + // transform point coordinates if needed + if( Scratchpad.location.rotation != glm::vec3( 0, 0, 0 ) ) { + // rotate... + auto const rotation = glm::radians( Scratchpad.location.rotation ); + for( auto &vertex : Lines.m_data.vertices ) { + vertex.position = glm::rotateZ( vertex.position, rotation.z ); + vertex.position = glm::rotateX( vertex.position, rotation.x ); + vertex.position = glm::rotateY( vertex.position, rotation.y ); + } + } + if( ( false == Scratchpad.location.offset.empty() ) + && ( Scratchpad.location.offset.top() != glm::dvec3( 0, 0, 0 ) ) ) { + // ...and move + auto const offset = Scratchpad.location.offset.top(); + for( auto &vertex : Lines.m_data.vertices ) { + vertex.position += offset; + } + } + // calculate bounding area + for( auto const &vertex : Lines.m_data.vertices ) { + Lines.m_data.area.center += vertex.position; + } + Lines.m_data.area.center /= Lines.m_data.vertices.size(); + Lines.compute_radius(); + // move the data into appropriate section + if( point_inside( Lines.m_data.area.center ) ) { + // NOTE: nodes placed outside of region boundaries are discarded + section( Lines.m_data.area.center ).insert( Lines ); + } + else { + ErrorLog( + "Bad scenario: lines node" + ( + Lines.m_name.empty() ? + "" : + " \"" + Lines.m_name + "\"" ) + + " placed in location outside region bounds (" + to_string( Lines.m_data.area.center ) + ")" ); + } +} + +// find a vehicle located neares to specified location, within specified radius, optionally discarding vehicles without drivers +std::tuple +basic_region::find_vehicle( glm::dvec3 const &Point, float const Radius, bool const Onlycontrolled, bool const Findbycoupler ) { + + auto const §ionlist = sections( Point, Radius ); + // go through sections within radius of interest, and pick the nearest candidate + TDynamicObject + *foundvehicle, + *nearestvehicle { nullptr }; + float + founddistance, + nearestdistance { std::numeric_limits::max() }; + + for( auto *section : sectionlist ) { + std::tie( foundvehicle, founddistance ) = section->find( Point, Radius, Onlycontrolled, Findbycoupler ); + if( ( foundvehicle != nullptr ) + && ( founddistance < nearestdistance ) ) { + + std::tie( nearestvehicle, nearestdistance ) = std::tie( foundvehicle, founddistance ); + } + } + return { nearestvehicle, nearestdistance }; +} + +// finds a path with one of its ends located in specified point. returns: located path and id of the matching endpoint +std::tuple +basic_region::find_path( glm::dvec3 const &Point, TTrack const *Exclude ) { + + // TBD: throw out of bounds exception instead of checks all over the place..? + if( point_inside( Point ) ) { + + return section( Point ).find( Point, Exclude ); + } + + return { nullptr, -1 }; +} + +// finds a traction piece with one of its ends located in specified point. returns: located traction piece and id of the matching endpoint +std::tuple +basic_region::find_traction( glm::dvec3 const &Point, TTraction const *Exclude ) { + + // TBD: throw out of bounds exception instead of checks all over the place..? + if( point_inside( Point ) ) { + + return section( Point ).find( Point, Exclude ); + } + + return { nullptr, -1 }; +} + +// finds a traction piece located nearest to specified point, sharing section with specified other piece and powered in specified direction. returns: located traction piece +std::tuple +basic_region::find_traction( glm::dvec3 const &Point, TTraction const *Other, int const Currentdirection ) { + + auto const §ionlist = sections( Point, 0.f ); + // go through sections within radius of interest, and pick the nearest candidate + TTraction + *tractionfound, + *tractionnearest { nullptr }; + float + distancefound, + distancenearest { std::numeric_limits::max() }; + int + endpointfound, + endpointnearest { -1 }; + + for( auto *section : sectionlist ) { + std::tie( tractionfound, endpointfound, distancefound ) = section->find( Point, Other, Currentdirection ); + if( ( tractionfound != nullptr ) + && ( distancefound < distancenearest ) ) { + + std::tie( tractionnearest, endpointnearest, distancenearest ) = std::tie( tractionfound, endpointfound, distancefound ); + } + } + return { tractionnearest, endpointnearest }; +} + +// finds sections inside specified sphere. returns: list of sections +std::vector const & +basic_region::sections( glm::dvec3 const &Point, float const Radius ) { + + m_scratchpad.sections.clear(); + + auto const centerx { static_cast( std::floor( Point.x / EU07_SECTIONSIZE + EU07_REGIONSIDESECTIONCOUNT / 2 ) ) }; + auto const centerz { static_cast( std::floor( Point.z / EU07_SECTIONSIZE + EU07_REGIONSIDESECTIONCOUNT / 2 ) ) }; + auto const sectioncount { 2 * static_cast( std::ceil( Radius / EU07_SECTIONSIZE ) ) }; + + int const originx = centerx - sectioncount / 2; + int const originz = centerz - sectioncount / 2; + + auto const padding { 0.0 }; // { EU07_SECTIONSIZE * 0.25 }; // TODO: check if we can get away with padding of 0 + + for( int row = originz; row <= originz + sectioncount; ++row ) { + if( row < 0 ) { continue; } + if( row >= EU07_REGIONSIDESECTIONCOUNT ) { break; } + for( int column = originx; column <= originx + sectioncount; ++column ) { + if( column < 0 ) { continue; } + if( column >= EU07_REGIONSIDESECTIONCOUNT ) { break; } + + auto *section { m_sections[ row * EU07_REGIONSIDESECTIONCOUNT + column ] }; + if( ( section != nullptr ) + && ( glm::length2( section->area().center - Point ) <= ( ( section->area().radius + padding + Radius ) * ( section->area().radius + padding + Radius ) ) ) ) { + + m_scratchpad.sections.emplace_back( section ); + } + } + } + return m_scratchpad.sections; +} + +// checks whether specified point is within boundaries of the region +bool +basic_region::point_inside( glm::dvec3 const &Location ) { + + double const regionboundary = EU07_REGIONSIDESECTIONCOUNT / 2 * EU07_SECTIONSIZE; + return ( ( Location.x > -regionboundary ) && ( Location.x < regionboundary ) + && ( Location.z > -regionboundary ) && ( Location.z < regionboundary ) ); +} + +// trims provided shape to fit into a section, adds trimmed part at the end of provided list +// NOTE: legacy function. TBD, TODO: clean it up? +bool +basic_region::RaTriangleDivider( shape_node &Shape, std::deque &Shapes ) { + + if( Shape.m_data.vertices.size() != 3 ) { + // tylko gdy jeden trójkąt + return false; + } + + auto const margin { 200.0 }; + auto x0 = EU07_SECTIONSIZE * std::floor( 0.001 * Shape.m_data.area.center.x ) - margin; + auto x1 = x0 + EU07_SECTIONSIZE + margin * 2; + auto z0 = EU07_SECTIONSIZE * std::floor( 0.001 * Shape.m_data.area.center.z ) - margin; + auto z1 = z0 + EU07_SECTIONSIZE + margin * 2; + + if( ( Shape.m_data.vertices[ 0 ].position.x >= x0 ) && ( Shape.m_data.vertices[ 0 ].position.x <= x1 ) + && ( Shape.m_data.vertices[ 0 ].position.z >= z0 ) && ( Shape.m_data.vertices[ 0 ].position.z <= z1 ) + && ( Shape.m_data.vertices[ 1 ].position.x >= x0 ) && ( Shape.m_data.vertices[ 1 ].position.x <= x1 ) + && ( Shape.m_data.vertices[ 1 ].position.z >= z0 ) && ( Shape.m_data.vertices[ 1 ].position.z <= z1 ) + && ( Shape.m_data.vertices[ 2 ].position.x >= x0 ) && ( Shape.m_data.vertices[ 2 ].position.x <= x1 ) + && ( Shape.m_data.vertices[ 2 ].position.z >= z0 ) && ( Shape.m_data.vertices[ 2 ].position.z <= z1 ) ) { + // trójkąt wystający mniej niż 200m z kw. kilometrowego jest do przyjęcia + return false; + } + // Ra: przerobić na dzielenie na 2 trójkąty, podział w przecięciu z siatką kilometrową + // Ra: i z rekurencją będzie dzielić trzy trójkąty, jeśli będzie taka potrzeba + int divide { -1 }; // bok do podzielenia: 0=AB, 1=BC, 2=CA; +4=podział po OZ; +8 na x1/z1 + double + min { 0.0 }, + mul; // jeśli przechodzi przez oś, iloczyn będzie ujemny + x0 += margin; + x1 -= margin; // przestawienie na siatkę + z0 += margin; + z1 -= margin; + // AB na wschodzie + mul = ( Shape.m_data.vertices[ 0 ].position.x - x0 ) * ( Shape.m_data.vertices[ 1 ].position.x - x0 ); + if( mul < min ) { + min = mul; + divide = 0; + } + // BC na wschodzie + mul = ( Shape.m_data.vertices[ 1 ].position.x - x0 ) * ( Shape.m_data.vertices[ 2 ].position.x - x0 ); + if( mul < min ) { + min = mul; + divide = 1; + } + // CA na wschodzie + mul = ( Shape.m_data.vertices[ 2 ].position.x - x0 ) * ( Shape.m_data.vertices[ 0 ].position.x - x0 ); + if( mul < min ) { + min = mul; + divide = 2; + } + // AB na zachodzie + mul = ( Shape.m_data.vertices[ 0 ].position.x - x1 ) * ( Shape.m_data.vertices[ 1 ].position.x - x1 ); + if( mul < min ) { + min = mul; + divide = 8; + } + // BC na zachodzie + mul = ( Shape.m_data.vertices[ 1 ].position.x - x1 ) * ( Shape.m_data.vertices[ 2 ].position.x - x1 ); + if( mul < min ) { + min = mul; + divide = 9; + } + // CA na zachodzie + mul = ( Shape.m_data.vertices[ 2 ].position.x - x1 ) * ( Shape.m_data.vertices[ 0 ].position.x - x1 ); + if( mul < min ) { + min = mul; + divide = 10; + } + // AB na południu + mul = ( Shape.m_data.vertices[ 0 ].position.z - z0 ) * ( Shape.m_data.vertices[ 1 ].position.z - z0 ); + if( mul < min ) { + min = mul; + divide = 4; + } + // BC na południu + mul = ( Shape.m_data.vertices[ 1 ].position.z - z0 ) * ( Shape.m_data.vertices[ 2 ].position.z - z0 ); + if( mul < min ) { + min = mul; + divide = 5; + } + // CA na południu + mul = ( Shape.m_data.vertices[ 2 ].position.z - z0 ) * ( Shape.m_data.vertices[ 0 ].position.z - z0 ); + if( mul < min ) { + min = mul; + divide = 6; + } + // AB na północy + mul = ( Shape.m_data.vertices[ 0 ].position.z - z1 ) * ( Shape.m_data.vertices[ 1 ].position.z - z1 ); + if( mul < min ) { + min = mul; + divide = 12; + } + // BC na północy + mul = ( Shape.m_data.vertices[ 1 ].position.z - z1 ) * ( Shape.m_data.vertices[ 2 ].position.z - z1 ); + if( mul < min ) { + min = mul; + divide = 13; + } + // CA na północy + mul = (Shape.m_data.vertices[2].position.z - z1) * (Shape.m_data.vertices[0].position.z - z1); + if( mul < min ) { + divide = 14; + } + + // tworzymy jeden dodatkowy trójkąt, dzieląc jeden bok na przecięciu siatki kilometrowej + Shapes.emplace_back( Shape ); // copy current shape + auto &newshape = Shapes.back(); + + switch (divide & 3) { + // podzielenie jednego z boków, powstaje wierzchołek D + case 0: { + // podział AB (0-1) -> ADC i DBC + newshape.m_data.vertices[ 2 ] = Shape.m_data.vertices[ 2 ]; // wierzchołek C jest wspólny + newshape.m_data.vertices[ 1 ] = Shape.m_data.vertices[ 1 ]; // wierzchołek B przechodzi do nowego + if( divide & 4 ) { + Shape.m_data.vertices[ 1 ].set_from_z( + Shape.m_data.vertices[ 0 ], + Shape.m_data.vertices[ 1 ], + ( ( divide & 8 ) ? + z1 : + z0 ) ); + } + else { + Shape.m_data.vertices[ 1 ].set_from_x( + Shape.m_data.vertices[ 0 ], + Shape.m_data.vertices[ 1 ], + ( ( divide & 8 ) ? + x1 : + x0 ) ); + } + newshape.m_data.vertices[ 0 ] = Shape.m_data.vertices[ 1 ]; // wierzchołek D jest wspólny + break; + } + case 1: { + // podział BC (1-2) -> ABD i ADC + newshape.m_data.vertices[ 0 ] = Shape.m_data.vertices[ 0 ]; // wierzchołek A jest wspólny + newshape.m_data.vertices[ 2 ] = Shape.m_data.vertices[ 2 ]; // wierzchołek C przechodzi do nowego + if( divide & 4 ) { + Shape.m_data.vertices[ 2 ].set_from_z( + Shape.m_data.vertices[ 1 ], + Shape.m_data.vertices[ 2 ], + ( ( divide & 8 ) ? + z1 : + z0 ) ); + } + else { + Shape.m_data.vertices[ 2 ].set_from_x( + Shape.m_data.vertices[ 1 ], + Shape.m_data.vertices[ 2 ], + ( ( divide & 8 ) ? + x1 : + x0 ) ); + } + newshape.m_data.vertices[ 1 ] = Shape.m_data.vertices[ 2 ]; // wierzchołek D jest wspólny + break; + } + case 2: { + // podział CA (2-0) -> ABD i DBC + newshape.m_data.vertices[ 1 ] = Shape.m_data.vertices[ 1 ]; // wierzchołek B jest wspólny + newshape.m_data.vertices[ 2 ] = Shape.m_data.vertices[ 2 ]; // wierzchołek C przechodzi do nowego + if( divide & 4 ) { + Shape.m_data.vertices[ 2 ].set_from_z( + Shape.m_data.vertices[ 2 ], + Shape.m_data.vertices[ 0 ], + ( ( divide & 8 ) ? + z1 : + z0 ) ); + } + else { + Shape.m_data.vertices[ 2 ].set_from_x( + Shape.m_data.vertices[ 2 ], + Shape.m_data.vertices[ 0 ], + ( ( divide & 8 ) ? + x1 : + x0 ) ); + } + newshape.m_data.vertices[ 0 ] = Shape.m_data.vertices[ 2 ]; // wierzchołek D jest wspólny + break; + } + } + // przeliczenie środków ciężkości obu + Shape.m_data.area.center = ( Shape.m_data.vertices[ 0 ].position + Shape.m_data.vertices[ 1 ].position + Shape.m_data.vertices[ 2 ].position ) / 3.0; + newshape.m_data.area.center = ( newshape.m_data.vertices[ 0 ].position + newshape.m_data.vertices[ 1 ].position + newshape.m_data.vertices[ 2 ].position ) / 3.0; + + return true; +} + +// provides access to section enclosing specified point +basic_section & +basic_region::section( glm::dvec3 const &Location ) { + + auto const column { static_cast( std::floor( Location.x / EU07_SECTIONSIZE + EU07_REGIONSIDESECTIONCOUNT / 2 ) ) }; + auto const row { static_cast( std::floor( Location.z / EU07_SECTIONSIZE + EU07_REGIONSIDESECTIONCOUNT / 2 ) ) }; + + auto §ion = + m_sections[ + clamp( row, 0, EU07_REGIONSIDESECTIONCOUNT - 1 ) * EU07_REGIONSIDESECTIONCOUNT + + clamp( column, 0, EU07_REGIONSIDESECTIONCOUNT - 1 ) ] ; + + if( section == nullptr ) { + // there's no guarantee the section exists at this point, so check and if needed, create it + section = new basic_section(); + // assign center of the section + auto const centeroffset = -( EU07_REGIONSIDESECTIONCOUNT / 2 * EU07_SECTIONSIZE ) + EU07_SECTIONSIZE / 2; + glm::dvec3 regioncornercenter { centeroffset, 0, centeroffset }; + section->center( regioncornercenter + glm::dvec3{ column * EU07_SECTIONSIZE, 0.0, row * EU07_SECTIONSIZE } ); + } + + return *section; +} + +} // scene + +//--------------------------------------------------------------------------- diff --git a/scene.h b/scene.h new file mode 100644 index 00000000..926629ce --- /dev/null +++ b/scene.h @@ -0,0 +1,419 @@ +/* +This Source Code Form is subject to the +terms of the Mozilla Public License, v. +2.0. If a copy of the MPL was not +distributed with this file, You can +obtain one at +http://mozilla.org/MPL/2.0/. +*/ + +#pragma once + +#include +#include +#include +#include +#include + +#include "parser.h" +#include "openglgeometrybank.h" +#include "scenenode.h" +#include "track.h" +#include "traction.h" +#include "sound.h" + +namespace scene { + +int const EU07_CELLSIZE = 250; +int const EU07_SECTIONSIZE = 1000; +int const EU07_REGIONSIDESECTIONCOUNT = 500; // number of sections along a side of square region + +struct scratch_data { + + struct binary_data { + + bool terrain{ false }; + } binary; + + struct location_data { + + std::stack offset; + glm::vec3 rotation; + } location; + + struct trainset_data { + + std::string name; + std::string track; + float offset { 0.f }; + float velocity { 0.f }; + std::vector vehicles; + std::vector couplings; + TDynamicObject * driver { nullptr }; + bool is_open { false }; + } trainset; + + std::string name; + bool initialized { false }; +}; + +// basic element of rudimentary partitioning scheme for the section. fixed size, no further subdivision +// TBD, TODO: replace with quadtree scheme? +class basic_cell { + + friend opengl_renderer; + +public: +// constructors + basic_cell() = default; +// methods + // potentially activates event handler with the same name as provided node, and within handler activation range + void + on_click( TAnimModel const *Instance ); + // legacy method, finds and assigns traction piece to specified pantograph of provided vehicle + void + update_traction( TDynamicObject *Vehicle, int const Pantographindex ); + // legacy method, polls event launchers within radius around specified point + void + update_events(); + // legacy method, updates sounds within radius around specified point + void + update_sounds(); + // legacy method, triggers radio-stop procedure for all vehicles located on paths in the cell + void + radio_stop(); + // legacy method, adds specified path to the list of pieces undergoing state change + bool + RaTrackAnimAdd( TTrack *Track ); + // legacy method, updates geometry for pieces in the animation list + void + RaAnimate( unsigned int const Framestamp ); + // sends content of the class to provided stream + void + serialize( std::ostream &Output ) const; + // restores content of the class from provided stream + void + deserialize( std::istream &Input ); + // sends content of the class in legacy (text) format to provided stream + void + export_as_text( std::ostream &Output ) const; + // adds provided shape to the cell + void + insert( shape_node Shape ); + // adds provided lines to the cell + void + insert( lines_node Lines ); + // adds provided path to the cell + void + insert( TTrack *Path ); + // adds provided path to the cell + void + insert( TTraction *Traction ); + // adds provided model instance to the cell + void + insert( TAnimModel *Instance ); + // adds provided sound instance to the cell + void + insert( sound_source *Sound ); + // adds provided event launcher to the cell + void + insert( TEventLauncher *Launcher ); + // adds provided memory cell to the cell + void + insert( TMemCell *Memorycell ); + // registers provided path in the lookup directory of the cell + void + register_end( TTrack *Path ); + // registers provided traction piece in the lookup directory of the cell + void + register_end( TTraction *Traction ); + // removes provided model instance from the cell + void + erase( TAnimModel *Instance ); + // removes provided memory cell from the cell + void + erase( TMemCell *Memorycell ); + // find a vehicle located nearest to specified point, within specified radius. reurns: located vehicle and distance + std::tuple + find( glm::dvec3 const &Point, float const Radius, bool const Onlycontrolled, bool const Findbycoupler ) const; + // finds a path with one of its ends located in specified point. returns: located path and id of the matching endpoint + std::tuple + find( glm::dvec3 const &Point, TTrack const *Exclude ) const; + // finds a traction piece with one of its ends located in specified point. returns: located traction piece and id of the matching endpoint + std::tuple + find( glm::dvec3 const &Point, TTraction const *Exclude ) const; + // finds a traction piece located nearest to specified point, sharing section with specified other piece and powered in specified direction. returns: located traction piece + std::tuple + find( glm::dvec3 const &Point, TTraction const *Other, int const Currentdirection ) const; + // sets center point of the cell + void + center( glm::dvec3 Center ); + // generates renderable version of held non-instanced geometry in specified geometry bank + void + create_geometry( gfx::geometrybank_handle const &Bank ); + // provides access to bounding area data + bounding_area const & + area() const { + return m_area; } + +private: +// types + using shapenode_sequence = std::vector; + using linesnode_sequence = std::vector; + using path_sequence = std::vector; + using traction_sequence = std::vector; + using instance_sequence = std::vector; + using sound_sequence = std::vector; + using eventlauncher_sequence = std::vector; + using memorycell_sequence = std::vector; +// methods + void + launch_event( TEventLauncher *Launcher ); + void + enclose_area( scene::basic_node *Node ); +// members + scene::bounding_area m_area { glm::dvec3(), static_cast( 0.5 * M_SQRT2 * EU07_CELLSIZE ) }; + bool m_active { false }; // whether the cell holds any actual data content + shapenode_sequence m_shapesopaque; // opaque pieces of geometry + shapenode_sequence m_shapestranslucent; // translucent pieces of geometry + linesnode_sequence m_lines; + path_sequence m_paths; // path pieces + instance_sequence m_instancesopaque; + instance_sequence m_instancetranslucent; + traction_sequence m_traction; + sound_sequence m_sounds; + eventlauncher_sequence m_eventlaunchers; + memorycell_sequence m_memorycells; + // search helpers + struct lookup_data { + path_sequence paths; + traction_sequence traction; + } m_directories; + // animation of owned items (legacy code, clean up along with track refactoring) + bool m_geometrycreated { false }; + unsigned int m_framestamp { 0 }; // id of last rendered gfx frame + TTrack *tTrackAnim = nullptr; // obiekty do przeliczenia animacji +}; + +// basic scene partitioning structure, holds terrain geometry and collection of cells +class basic_section { + + friend opengl_renderer; + +public: +// constructors + basic_section() = default; +// methods + // potentially activates event handler with the same name as provided node, and within handler activation range + void + on_click( TAnimModel const *Instance ); + // legacy method, finds and assigns traction piece to specified pantograph of provided vehicle + void + update_traction( TDynamicObject *Vehicle, int const Pantographindex ); + // legacy method, updates sounds and polls event launchers within radius around specified point + void + update_events( glm::dvec3 const &Location, float const Radius ); + // legacy method, updates sounds and polls event launchers within radius around specified point + void + update_sounds( glm::dvec3 const &Location, float const Radius ); + // legacy method, triggers radio-stop procedure for all vehicles in 2km radius around specified location + void + radio_stop( glm::dvec3 const &Location, float const Radius ); + // sends content of the class to provided stream + void + serialize( std::ostream &Output ) const; + // restores content of the class from provided stream + void + deserialize( std::istream &Input ); + // sends content of the class in legacy (text) format to provided stream + void + export_as_text( std::ostream &Output ) const; + // adds provided shape to the section + void + insert( shape_node Shape ); + // adds provided lines to the section + void + insert( lines_node Lines ); + // adds provided node to the section + template + void + insert( Type_ *Node ) { + auto &targetcell { cell( Node->location() ) }; + targetcell.insert( Node ); + // some node types can extend bounding area of the target cell + m_area.radius = std::max( + m_area.radius, + static_cast( glm::length( m_area.center - targetcell.area().center ) + targetcell.area().radius ) ); } + // erases provided node from the section + template + void + erase( Type_ *Node ) { + auto &targetcell { cell( Node->location() ) }; + // TODO: re-calculate bounding area after removal + targetcell.erase( Node ); } + // registers provided node in the lookup directory of the section enclosing specified point + template + void + register_node( Type_ *Node, glm::dvec3 const &Point ) { + cell( Point ).register_end( Node ); } + // find a vehicle located nearest to specified point, within specified radius. reurns: located vehicle and distance + std::tuple + find( glm::dvec3 const &Point, float const Radius, bool const Onlycontrolled, bool const Findbycoupler ); + // finds a path with one of its ends located in specified point. returns: located path and id of the matching endpoint + std::tuple + find( glm::dvec3 const &Point, TTrack const *Exclude ); + // finds a traction piece with one of its ends located in specified point. returns: located traction piece and id of the matching endpoint + std::tuple + find( glm::dvec3 const &Point, TTraction const *Exclude ); + // finds a traction piece located nearest to specified point, sharing section with specified other piece and powered in specified direction. returns: located traction piece + std::tuple + find( glm::dvec3 const &Point, TTraction const *Other, int const Currentdirection ); + // sets center point of the section + void + center( glm::dvec3 Center ); + // generates renderable version of held non-instanced geometry + void + create_geometry(); + // provides access to bounding area data + bounding_area const & + area() const { + return m_area; } + +private: +// types + using cell_array = std::array; + using shapenode_sequence = std::vector; +// methods + // provides access to section enclosing specified point + basic_cell & + cell( glm::dvec3 const &Location ); +// members + // placement and visibility + scene::bounding_area m_area { glm::dvec3(), static_cast( 0.5 * M_SQRT2 * EU07_SECTIONSIZE ) }; + // content + cell_array m_cells; // partitioning scheme + shapenode_sequence m_shapes; // large pieces of opaque geometry and (legacy) terrain + // TODO: implement dedicated, higher fidelity, fixed resolution terrain mesh item + // gfx renderer data + gfx::geometrybank_handle m_geometrybank; + bool m_geometrycreated { false }; +}; + +// top-level of scene spatial structure, holds collection of sections +class basic_region { + + friend opengl_renderer; + +public: +// constructors + basic_region(); +// destructor + ~basic_region(); +// methods + // potentially activates event handler with the same name as provided node, and within handler activation range + void + on_click( TAnimModel const *Instance ); + // legacy method, finds and assigns traction piece to specified pantograph of provided vehicle + void + update_traction( TDynamicObject *Vehicle, int const Pantographindex ); + // legacy method, polls event launchers around camera + void + update_events(); + // legacy method, updates sounds around camera + void + update_sounds(); + // checks whether specified file is a valid region data file + bool + is_scene( std::string const &Scenariofile ) const; + // stores content of the class in file with specified name + void + serialize( std::string const &Scenariofile ) const; + // restores content of the class from file with specified name. returns: true on success, false otherwise + bool + deserialize( std::string const &Scenariofile ); + // sends content of the class in legacy (text) format to provided stream + void + export_as_text( std::ostream &Output ) const; + // legacy method, links specified path piece with potential neighbours + void + TrackJoin( TTrack *Track ); + // legacy method, triggers radio-stop procedure for all vehicles in 2km radius around specified location + void + RadioStop( glm::dvec3 const &Location ); + // inserts provided shape in the region + void + insert( shape_node Shape, scratch_data &Scratchpad, bool const Transform ); + // inserts provided lines in the region + void + insert( lines_node Lines, scratch_data &Scratchpad ); + // inserts provided node in the region + template + void + insert( Type_ *Node ) { + auto const location { Node->location() }; + if( false == point_inside( location ) ) { + // NOTE: nodes placed outside of region boundaries are discarded + // TBD, TODO: clamp coordinates to region boundaries? + return; } + section( location ).insert( Node ); } + // inserts provided node in the region and registers its ends in lookup directory + template + void + insert_and_register( Type_ *Node ) { + insert( Node ); + for( auto const &point : Node->endpoints() ) { + if( point_inside( point ) ) { + section( point ).register_node( Node, point ); } } } + // removes specified node from the region + template + void + erase( Type_ *Node ) { + auto const location{ Node->location() }; + if( point_inside( location ) ) { + section( location ).erase( Node ); } } + // find a vehicle located nearest to specified point, within specified radius. reurns: located vehicle and distance + std::tuple + find_vehicle( glm::dvec3 const &Point, float const Radius, bool const Onlycontrolled, bool const Findbycoupler ); + // finds a path with one of its ends located in specified point. returns: located path and id of the matching endpoint + std::tuple + find_path( glm::dvec3 const &Point, TTrack const *Exclude ); + // finds a traction piece with one of its ends located in specified point. returns: located traction piece and id of the matching endpoint + std::tuple + find_traction( glm::dvec3 const &Point, TTraction const *Exclude ); + // finds a traction piece located nearest to specified point, sharing section with specified other piece and powered in specified direction. returns: located traction piece + std::tuple + find_traction( glm::dvec3 const &Point, TTraction const *Other, int const Currentdirection ); + // finds sections inside specified sphere. returns: list of sections + std::vector const & + sections( glm::dvec3 const &Point, float const Radius ); + +private: +// types + using section_array = std::array; + + struct region_scratchpad { + + std::vector sections; + }; + +// methods + // checks whether specified point is within boundaries of the region + bool + point_inside( glm::dvec3 const &Location ); + // legacy method, trims provided shape to fit into a section. adds trimmed part at the end of provided list, returns true if changes were made + static + bool + RaTriangleDivider( shape_node &Shape, std::deque &Shapes ); + // provides access to section enclosing specified point + basic_section & + section( glm::dvec3 const &Location ); + +// members + section_array m_sections; + region_scratchpad m_scratchpad; + +}; + +} // scene + +//--------------------------------------------------------------------------- diff --git a/sceneeditor.cpp b/sceneeditor.cpp new file mode 100644 index 00000000..5aafa4ab --- /dev/null +++ b/sceneeditor.cpp @@ -0,0 +1,190 @@ +/* +This Source Code Form is subject to the +terms of the Mozilla Public License, v. +2.0. If a copy of the MPL was not +distributed with this file, You can +obtain one at +http://mozilla.org/MPL/2.0/. +*/ + +#include "stdafx.h" +#include "sceneeditor.h" +#include "scenenodegroups.h" + +#include "globals.h" +#include "application.h" +#include "simulation.h" +#include "camera.h" +#include "animmodel.h" +#include "renderer.h" + +namespace scene { + +void +basic_editor::translate( scene::basic_node *Node, glm::dvec3 const &Location, bool const Snaptoground ) { + + auto const initiallocation { Node->location() }; + auto targetlocation { Location }; + if( false == Snaptoground ) { + targetlocation.y = initiallocation.y; + } + // NOTE: bit of a waste for single nodes, for the sake of less varied code down the road + auto const translation { targetlocation - initiallocation }; + + if( Node->group() == null_handle ) { + translate_node( Node, Node->location() + translation ); + } + else { + // translate entire group + // TODO: contextual switch between group and item translation + // TODO: translation of affected/relevant events + auto &nodegroup { scene::Groups.group( Node->group() ).nodes }; + std::for_each( + std::begin( nodegroup ), std::end( nodegroup ), + [&]( auto *node ) { + translate_node( node, node->location() + translation ); } ); + } +} + +void +basic_editor::translate( scene::basic_node *Node, float const Offset ) { + + // NOTE: offset scaling is calculated early so the same multiplier can be applied to potential whole group + auto location { Node->location() }; + auto const distance { glm::length( location - glm::dvec3{ Global.pCamera.Pos } ) }; + auto const offset { static_cast( Offset * std::max( 1.0, distance * 0.01 ) ) }; + + if( Node->group() == null_handle ) { + translate_node( Node, offset ); + } + else { + // translate entire group + // TODO: contextual switch between group and item translation + // TODO: translation of affected/relevant events + auto &nodegroup { scene::Groups.group( Node->group() ).nodes }; + std::for_each( + std::begin( nodegroup ), std::end( nodegroup ), + [&]( auto *node ) { + translate_node( node, offset ); } ); + } +} + +void +basic_editor::translate_node( scene::basic_node *Node, glm::dvec3 const &Location ) { + + if( typeid( *Node ) == typeid( TAnimModel ) ) { + translate_instance( static_cast( Node ), Location ); + } + else if( typeid( *Node ) == typeid( TMemCell ) ) { + translate_memorycell( static_cast( Node ), Location ); + } +} + +void +basic_editor::translate_node( scene::basic_node *Node, float const Offset ) { + + if( typeid( *Node ) == typeid( TAnimModel ) ) { + translate_instance( static_cast( Node ), Offset ); + } + else if( typeid( *Node ) == typeid( TMemCell ) ) { + translate_memorycell( static_cast( Node ), Offset ); + } +} + +void +basic_editor::translate_instance( TAnimModel *Instance, glm::dvec3 const &Location ) { + + simulation::Region->erase( Instance ); + Instance->location( Location ); + simulation::Region->insert( Instance ); +} + +void +basic_editor::translate_instance( TAnimModel *Instance, float const Offset ) { + + auto location { Instance->location() }; + location.y += Offset; + Instance->location( location ); +} + +void +basic_editor::translate_memorycell( TMemCell *Memorycell, glm::dvec3 const &Location ) { + + simulation::Region->erase( Memorycell ); + Memorycell->location( Location ); + simulation::Region->insert( Memorycell ); +} + +void +basic_editor::translate_memorycell( TMemCell *Memorycell, float const Offset ) { + + auto location { Memorycell->location() }; + location.y += Offset; + Memorycell->location( location ); +} + +void +basic_editor::rotate( scene::basic_node *Node, glm::vec3 const &Angle, float const Quantization ) { + + glm::vec3 rotation { 0, Angle.y, 0 }; + + // quantize resulting angle if requested and type of the node allows it + // TBD, TODO: angle quantization for types other than instanced models + if( ( Quantization > 0.f ) + && ( typeid( *Node ) == typeid( TAnimModel ) ) ) { + + auto const initialangle { static_cast( Node )->Angles() }; + rotation += initialangle; + + // TBD, TODO: adjustable quantization step + rotation.y = quantize( rotation.y, Quantization ); + + rotation -= initialangle; + } + + if( Node->group() == null_handle ) { + rotate_node( Node, rotation ); + } + else { + // rotate entire group + // TODO: contextual switch between group and item rotation + // TODO: translation of affected/relevant events + auto const rotationcenter { Node->location() }; + auto &nodegroup { scene::Groups.group( Node->group() ).nodes }; + std::for_each( + std::begin( nodegroup ), std::end( nodegroup ), + [&]( auto *node ) { + rotate_node( node, rotation ); + if( node != Node ) { + translate_node( + node, + rotationcenter + + glm::rotateY( + node->location() - rotationcenter, + glm::radians( rotation.y ) ) ); } } ); + } +} + +void +basic_editor::rotate_node( scene::basic_node *Node, glm::vec3 const &Angle ) { + + if( typeid( *Node ) == typeid( TAnimModel ) ) { + rotate_instance( static_cast( Node ), Angle ); + } +} + +void +basic_editor::rotate_instance( TAnimModel *Instance, glm::vec3 const &Angle ) { + + auto targetangle { Instance->Angles() + Angle }; + + targetangle.x = clamp_circular( targetangle.x, 360.f ); + targetangle.y = clamp_circular( targetangle.y, 360.f ); + targetangle.z = clamp_circular( targetangle.z, 360.f ); + + Instance->Angles( targetangle ); +} + +} // scene + +//--------------------------------------------------------------------------- diff --git a/sceneeditor.h b/sceneeditor.h new file mode 100644 index 00000000..75e0ff6c --- /dev/null +++ b/sceneeditor.h @@ -0,0 +1,64 @@ +/* +This Source Code Form is subject to the +terms of the Mozilla Public License, v. +2.0. If a copy of the MPL was not +distributed with this file, You can +obtain one at +http://mozilla.org/MPL/2.0/. +*/ + +#pragma once + +#include "scenenode.h" + +namespace scene { + +// TODO: move the snapshot to history stack +struct node_snapshot { + + scene::basic_node *node; + std::string data; + + node_snapshot( scene::basic_node *Node ) : + node( Node ) { + if( Node != nullptr ) { + Node->export_as_text( data ); } }; +}; + +inline bool operator==( node_snapshot const &Left, node_snapshot const &Right ) { return ( ( Left.node == Right.node ) && ( Left.data == Right.data ) ); } +inline bool operator!=( node_snapshot const &Left, node_snapshot const &Right ) { return ( !( Left == Right ) ); } + +class basic_editor { + +public: +// methods + void + translate( scene::basic_node *Node, glm::dvec3 const &Location, bool const Snaptoground ); + void + translate( scene::basic_node *Node, float const Offset ); + void + rotate( scene::basic_node *Node, glm::vec3 const &Angle, float const Quantization ); + +private: +// methods + void + translate_node( scene::basic_node *Node, glm::dvec3 const &Location ); + void + translate_node( scene::basic_node *Node, float const Offset ); + void + translate_instance( TAnimModel *Instance, glm::dvec3 const &Location ); + void + translate_instance( TAnimModel *Instance, float const Offset ); + void + translate_memorycell( TMemCell *Memorycell, glm::dvec3 const &Location ); + void + translate_memorycell( TMemCell *Memorycell, float const Offset ); + void + rotate_node( scene::basic_node *Node, glm::vec3 const &Angle ); + void + rotate_instance( TAnimModel *Instance, glm::vec3 const &Angle ); +}; + +} // scene + +//--------------------------------------------------------------------------- diff --git a/scenenode.cpp b/scenenode.cpp new file mode 100644 index 00000000..1f1d9f8d --- /dev/null +++ b/scenenode.cpp @@ -0,0 +1,774 @@ +/* +This Source Code Form is subject to the +terms of the Mozilla Public License, v. +2.0. If a copy of the MPL was not +distributed with this file, You can +obtain one at +http://mozilla.org/MPL/2.0/. +*/ + +#include "stdafx.h" +#include "scenenode.h" + +#include "model3d.h" +#include "renderer.h" +#include "logs.h" +#include "sn_utils.h" + + +// stores content of the struct in provided output stream +void +lighting_data::serialize( std::ostream &Output ) const { + + sn_utils::s_vec4( Output, diffuse ); + sn_utils::s_vec4( Output, ambient ); + sn_utils::s_vec4( Output, specular ); +} + +// restores content of the struct from provided input stream +void +lighting_data::deserialize( std::istream &Input ) { + + diffuse = sn_utils::d_vec4( Input ); + ambient = sn_utils::d_vec4( Input ); + specular = sn_utils::d_vec4( Input ); +} + + + +namespace scene { + +// stores content of the struct in provided output stream +void +bounding_area::serialize( std::ostream &Output ) const { + // center + sn_utils::s_dvec3( Output, center ); + // radius + sn_utils::ls_float32( Output, radius ); +} + +// restores content of the struct from provided input stream +void +bounding_area::deserialize( std::istream &Input ) { + + center = sn_utils::d_dvec3( Input ); + radius = sn_utils::ld_float32( Input ); +} + + + +// sends content of the struct to provided stream +void +shape_node::shapenode_data::serialize( std::ostream &Output ) const { + // bounding area + area.serialize( Output ); + // visibility + sn_utils::ls_float64( Output, rangesquared_min ); + sn_utils::ls_float64( Output, rangesquared_max ); + sn_utils::s_bool( Output, visible ); + // material + sn_utils::s_bool( Output, translucent ); + // NOTE: material handle is created dynamically on load + sn_utils::s_str( + Output, + ( material != null_handle ? + GfxRenderer.Material( material ).name : + "" ) ); + lighting.serialize( Output ); + // geometry + sn_utils::s_dvec3( Output, origin ); + // NOTE: geometry handle is created dynamically on load + // vertex count, followed by vertex data + sn_utils::ls_uint32( Output, vertices.size() ); + for( auto const &vertex : vertices ) { + gfx::basic_vertex( + glm::vec3{ vertex.position - origin }, + vertex.normal, + vertex.texture ) + .serialize( Output ); + } +} + +// restores content of the struct from provided input stream +void +shape_node::shapenode_data::deserialize( std::istream &Input ) { + // bounding area + area.deserialize( Input ); + // visibility + rangesquared_min = sn_utils::ld_float64( Input ); + rangesquared_max = sn_utils::ld_float64( Input ); + visible = sn_utils::d_bool( Input ); + // material + translucent = sn_utils::d_bool( Input ); + auto const materialname { sn_utils::d_str( Input ) }; + if( false == materialname.empty() ) { + material = GfxRenderer.Fetch_Material( materialname ); + } + lighting.deserialize( Input ); + // geometry + origin = sn_utils::d_dvec3( Input ); + // NOTE: geometry handle is acquired during geometry creation + // vertex data + vertices.resize( sn_utils::ld_uint32( Input ) ); + gfx::basic_vertex localvertex; + for( auto &vertex : vertices ) { + localvertex.deserialize( Input ); + vertex.position = origin + glm::dvec3{ localvertex.position }; + vertex.normal = localvertex.normal; + vertex.texture = localvertex.texture; + } +} + + +// sends content of the class to provided stream +void +shape_node::serialize( std::ostream &Output ) const { + // name + sn_utils::s_str( Output, m_name ); + // node data + m_data.serialize( Output ); +} + +// restores content of the node from provided input stream +shape_node & +shape_node::deserialize( std::istream &Input ) { + // name + m_name = sn_utils::d_str( Input ); + // node data + m_data.deserialize( Input ); + + return *this; +} + +// restores content of the node from provided input stream +shape_node & +shape_node::import( cParser &Input, scene::node_data const &Nodedata ) { + + // import common data + m_name = Nodedata.name; + m_data.rangesquared_min = Nodedata.range_min * Nodedata.range_min; + m_data.rangesquared_max = ( + Nodedata.range_max >= 0.0 ? + Nodedata.range_max * Nodedata.range_max : + std::numeric_limits::max() ); + + std::string token = Input.getToken(); + if( token == "material" ) { + // lighting settings + token = Input.getToken(); + while( token != "endmaterial" ) { + + if( token == "ambient:" ) { + Input.getTokens( 3 ); + Input + >> m_data.lighting.ambient.r + >> m_data.lighting.ambient.g + >> m_data.lighting.ambient.b; + m_data.lighting.ambient /= 255.f; + m_data.lighting.ambient.a = 1.f; + } + else if( token == "diffuse:" ) { + Input.getTokens( 3 ); + Input + >> m_data.lighting.diffuse.r + >> m_data.lighting.diffuse.g + >> m_data.lighting.diffuse.b; + m_data.lighting.diffuse /= 255.f; + m_data.lighting.diffuse.a = 1.f; + } + else if( token == "specular:" ) { + Input.getTokens( 3 ); + Input + >> m_data.lighting.specular.r + >> m_data.lighting.specular.g + >> m_data.lighting.specular.b; + m_data.lighting.specular /= 255.f; + m_data.lighting.specular.a = 1.f; + } + token = Input.getToken(); + } + token = Input.getToken(); + } + + // assigned material + m_data.material = GfxRenderer.Fetch_Material( token ); + + // determine way to proceed from the assigned diffuse texture + // TBT, TODO: add methods to material manager to access these simpler + auto const texturehandle = ( + m_data.material != null_handle ? + GfxRenderer.Material( m_data.material ).texture1 : + null_handle ); + auto const &texture = ( + texturehandle ? + GfxRenderer.Texture( texturehandle ) : + opengl_texture() ); // dirty workaround for lack of better api + bool const clamps = ( + texturehandle ? + texture.traits.find( 's' ) != std::string::npos : + false ); + bool const clampt = ( + texturehandle ? + texture.traits.find( 't' ) != std::string::npos : + false ); + + // remainder of legacy 'problend' system -- geometry assigned a texture with '@' in its name is treated as translucent, opaque otherwise + if( texturehandle != null_handle ) { + m_data.translucent = ( + ( ( texture.name.find( '@' ) != std::string::npos ) + && ( true == texture.has_alpha ) ) ? + true : + false ); + } + else { + m_data.translucent = false; + } + + // geometry + enum subtype { + triangles, + triangle_strip, + triangle_fan + }; + + subtype const nodetype = ( + Nodedata.type == "triangles" ? triangles : + Nodedata.type == "triangle_strip" ? triangle_strip : + triangle_fan ); + std::size_t vertexcount{ 0 }; + world_vertex vertex, vertex1, vertex2; + do { + Input.getTokens( 8, false ); + Input + >> vertex.position.x + >> vertex.position.y + >> vertex.position.z + >> vertex.normal.x + >> vertex.normal.y + >> vertex.normal.z + >> vertex.texture.s + >> vertex.texture.t; + // clamp texture coordinates if texture wrapping is off + if( true == clamps ) { vertex.texture.s = clamp( vertex.texture.s, 0.001f, 0.999f ); } + if( true == clampt ) { vertex.texture.t = clamp( vertex.texture.t, 0.001f, 0.999f ); } + // convert all data to gl_triangles to allow data merge for matching nodes + switch( nodetype ) { + case triangles: { + + if( vertexcount == 0 ) { vertex1 = vertex; } + else if( vertexcount == 1 ) { vertex2 = vertex; } + else if( vertexcount >= 2 ) { + if( false == degenerate( vertex1.position, vertex2.position, vertex.position ) ) { + m_data.vertices.emplace_back( vertex1 ); + m_data.vertices.emplace_back( vertex2 ); + m_data.vertices.emplace_back( vertex ); + } + else { + ErrorLog( + "Bad geometry: degenerate triangle encountered" + + ( m_name != "" ? " in node \"" + m_name + "\"" : "" ) + + " (vertices: " + to_string( vertex1.position ) + " + " + to_string( vertex2.position ) + " + " + to_string( vertex.position ) + ")" ); + } + } + ++vertexcount; + if( vertexcount > 2 ) { vertexcount = 0; } // start new triangle if needed + break; + } + case triangle_fan: { + + if( vertexcount == 0 ) { vertex1 = vertex; } + else if( vertexcount == 1 ) { vertex2 = vertex; } + else if( vertexcount >= 2 ) { + if( false == degenerate( vertex1.position, vertex2.position, vertex.position ) ) { + m_data.vertices.emplace_back( vertex1 ); + m_data.vertices.emplace_back( vertex2 ); + m_data.vertices.emplace_back( vertex ); + vertex2 = vertex; + } + else { + ErrorLog( + "Bad geometry: degenerate triangle encountered" + + ( m_name != "" ? " in node \"" + m_name + "\"" : "" ) + + " (vertices: " + to_string( vertex1.position ) + " + " + to_string( vertex2.position ) + " + " + to_string( vertex.position ) + ")" ); + } + } + ++vertexcount; + break; + } + case triangle_strip: { + + if( vertexcount == 0 ) { vertex1 = vertex; } + else if( vertexcount == 1 ) { vertex2 = vertex; } + else if( vertexcount >= 2 ) { + if( false == degenerate( vertex1.position, vertex2.position, vertex.position ) ) { + // swap order every other triangle, to maintain consistent winding + if( vertexcount % 2 == 0 ) { + m_data.vertices.emplace_back( vertex1 ); + m_data.vertices.emplace_back( vertex2 ); + } + else { + m_data.vertices.emplace_back( vertex2 ); + m_data.vertices.emplace_back( vertex1 ); + } + m_data.vertices.emplace_back( vertex ); + + vertex1 = vertex2; + vertex2 = vertex; + } + else { + ErrorLog( + "Bad geometry: degenerate triangle encountered" + + ( m_name != "" ? " in node \"" + m_name + "\"" : "" ) + + " (vertices: " + to_string( vertex1.position ) + " + " + to_string( vertex2.position ) + " + " + to_string( vertex.position ) + ")" ); + } + } + ++vertexcount; + break; + } + default: { break; } + } + token = Input.getToken(); + + } while( token != "endtri" ); + + return *this; +} + +// imports data from provided submodel +shape_node & +shape_node::convert( TSubModel const *Submodel ) { + + m_name = Submodel->pName; + m_data.lighting.ambient = Submodel->f4Ambient; + m_data.lighting.diffuse = Submodel->f4Diffuse; + m_data.lighting.specular = Submodel->f4Specular; + m_data.material = Submodel->m_material; + m_data.translucent = ( true == GfxRenderer.Material( m_data.material ).has_alpha ); + // NOTE: we set unlimited view range typical for terrain, because we don't expect to convert any other 3d models + m_data.rangesquared_max = std::numeric_limits::max(); + + if( Submodel->m_geometry == null_handle ) { return *this; } + + int vertexcount { 0 }; + std::vector importedvertices; + world_vertex vertex, vertex1, vertex2; + for( auto const &sourcevertex : GfxRenderer.Vertices( Submodel->m_geometry ) ) { + vertex.position = sourcevertex.position; + vertex.normal = sourcevertex.normal; + vertex.texture = sourcevertex.texture; + if( vertexcount == 0 ) { vertex1 = vertex; } + else if( vertexcount == 1 ) { vertex2 = vertex; } + else if( vertexcount >= 2 ) { + if( false == degenerate( vertex1.position, vertex2.position, vertex.position ) ) { + importedvertices.emplace_back( vertex1 ); + importedvertices.emplace_back( vertex2 ); + importedvertices.emplace_back( vertex ); + } + // start a new triangle + vertexcount = -1; + } + ++vertexcount; + } + + if( true == importedvertices.empty() ) { return *this; } + + // assign imported geometry to the node... + m_data.vertices.swap( importedvertices ); + // ...and calculate center... + for( auto const &vertex : m_data.vertices ) { + m_data.area.center += vertex.position; + } + m_data.area.center /= m_data.vertices.size(); + // ...and bounding area + double squareradius { 0.0 }; + for( auto const &vertex : m_data.vertices ) { + squareradius = std::max( + squareradius, + glm::length2( vertex.position - m_data.area.center ) ); + } + m_data.area.radius = std::max( + m_data.area.radius, + static_cast( std::sqrt( squareradius ) ) ); + + return *this; +} + +// adds content of provided node to already enclosed geometry. returns: true if merge could be performed +bool +shape_node::merge( shape_node &Shape ) { + + if( ( m_data.material != Shape.m_data.material ) + || ( m_data.lighting != Shape.m_data.lighting ) ) { + // can't merge nodes with different appearance + return false; + } + // add geometry from provided node + m_data.area.center = + interpolate( + m_data.area.center, Shape.m_data.area.center, + static_cast( Shape.m_data.vertices.size() ) / ( Shape.m_data.vertices.size() + m_data.vertices.size() ) ); + m_data.vertices.insert( + std::end( m_data.vertices ), + std::begin( Shape.m_data.vertices ), std::end( Shape.m_data.vertices ) ); + // NOTE: we could recalculate radius with something other than brute force, but it'll do + compute_radius(); + + return true; +} + +// generates renderable version of held non-instanced geometry in specified geometry bank +void +shape_node::create_geometry( gfx::geometrybank_handle const &Bank ) { + + gfx::vertex_array vertices; vertices.reserve( m_data.vertices.size() ); + + for( auto const &vertex : m_data.vertices ) { + vertices.emplace_back( + vertex.position - m_data.origin, + vertex.normal, + vertex.texture ); + } + m_data.geometry = GfxRenderer.Insert( vertices, Bank, GL_TRIANGLES ); + std::vector().swap( m_data.vertices ); // hipster shrink_to_fit +} + +// calculates shape's bounding radius +void +shape_node::compute_radius() { + + auto squaredradius { 0.0 }; + for( auto const &vertex : m_data.vertices ) { + squaredradius = std::max( + squaredradius, + glm::length2( vertex.position - m_data.area.center ) ); + } + m_data.area.radius = static_cast( std::sqrt( squaredradius ) ); +} + + + +// sends content of the struct to provided stream +void +lines_node::linesnode_data::serialize( std::ostream &Output ) const { + // bounding area + area.serialize( Output ); + // visibility + sn_utils::ls_float64( Output, rangesquared_min ); + sn_utils::ls_float64( Output, rangesquared_max ); + sn_utils::s_bool( Output, visible ); + // material + sn_utils::ls_float32( Output, line_width ); + lighting.serialize( Output ); + // geometry + sn_utils::s_dvec3( Output, origin ); + // NOTE: geometry handle is created dynamically on load + // vertex count, followed by vertex data + sn_utils::ls_uint32( Output, vertices.size() ); + for( auto const &vertex : vertices ) { + gfx::basic_vertex( + glm::vec3{ vertex.position - origin }, + vertex.normal, + vertex.texture ) + .serialize( Output ); + } +} + +// restores content of the struct from provided input stream +void +lines_node::linesnode_data::deserialize( std::istream &Input ) { + // bounding area + area.deserialize( Input ); + // visibility + rangesquared_min = sn_utils::ld_float64( Input ); + rangesquared_max = sn_utils::ld_float64( Input ); + visible = sn_utils::d_bool( Input ); + // material + line_width = sn_utils::ld_float32( Input ); + lighting.deserialize( Input ); + // geometry + origin = sn_utils::d_dvec3( Input ); + // NOTE: geometry handle is acquired during geometry creation + // vertex data + vertices.resize( sn_utils::ld_uint32( Input ) ); + gfx::basic_vertex localvertex; + for( auto &vertex : vertices ) { + localvertex.deserialize( Input ); + vertex.position = origin + glm::dvec3{ localvertex.position }; + vertex.normal = localvertex.normal; + vertex.texture = localvertex.texture; + } +} + + + +// sends content of the class to provided stream +void +lines_node::serialize( std::ostream &Output ) const { + // name + sn_utils::s_str( Output, m_name ); + // node data + m_data.serialize( Output ); +} + +// restores content of the node from provided input stream +lines_node & +lines_node::deserialize( std::istream &Input ) { + // name + m_name = sn_utils::d_str( Input ); + // node data + m_data.deserialize( Input ); + + return *this; +} + +// restores content of the node from provded input stream +lines_node & +lines_node::import( cParser &Input, scene::node_data const &Nodedata ) { + + // import common data + m_name = Nodedata.name; + m_data.rangesquared_min = Nodedata.range_min * Nodedata.range_min; + m_data.rangesquared_max = ( + Nodedata.range_max >= 0.0 ? + Nodedata.range_max * Nodedata.range_max : + std::numeric_limits::max() ); + + // material + Input.getTokens( 3, false ); + Input + >> m_data.lighting.diffuse.r + >> m_data.lighting.diffuse.g + >> m_data.lighting.diffuse.b; + m_data.lighting.diffuse /= 255.f; + m_data.lighting.diffuse.a = 1.f; + Input.getTokens( 1, false ); + Input + >> m_data.line_width; + m_data.line_width = std::min( 30.f, m_data.line_width ); // 30 pix equals rougly width of a signal pole viewed from ~1m away + + // geometry + enum subtype { + lines, + line_strip, + line_loop + }; + + subtype const nodetype = ( + Nodedata.type == "lines" ? lines : + Nodedata.type == "line_strip" ? line_strip : + line_loop ); + std::size_t vertexcount { 0 }; + world_vertex vertex, vertex0, vertex1; + std::string token = Input.getToken(); + do { + vertex.position.x = std::atof( token.c_str() ); + Input.getTokens( 2, false ); + Input + >> vertex.position.y + >> vertex.position.z; + // convert all data to gl_lines to allow data merge for matching nodes + switch( nodetype ) { + case lines: { + m_data.vertices.emplace_back( vertex ); + break; + } + case line_strip: { + if( vertexcount > 0 ) { + m_data.vertices.emplace_back( vertex1 ); + m_data.vertices.emplace_back( vertex ); + } + vertex1 = vertex; + ++vertexcount; + break; + } + case line_loop: { + if( vertexcount == 0 ) { + vertex0 = vertex; + vertex1 = vertex; + } + else { + m_data.vertices.emplace_back( vertex1 ); + m_data.vertices.emplace_back( vertex ); + } + vertex1 = vertex; + ++vertexcount; + break; + } + default: { break; } + } + token = Input.getToken(); + + } while( token != "endline" ); + // add closing line for the loop + if( ( nodetype == line_loop ) + && ( vertexcount > 2 ) ) { + m_data.vertices.emplace_back( vertex1 ); + m_data.vertices.emplace_back( vertex0 ); + } + if( m_data.vertices.size() % 2 != 0 ) { + ErrorLog( "Lines node specified odd number of vertices, defined in file \"" + Input.Name() + "\" (line " + std::to_string( Input.Line() - 1 ) + ")" ); + m_data.vertices.pop_back(); + } + + return *this; +} + +// adds content of provided node to already enclosed geometry. returns: true if merge could be performed +bool +lines_node::merge( lines_node &Lines ) { + + if( ( m_data.line_width != Lines.m_data.line_width ) + || ( m_data.lighting != Lines.m_data.lighting ) ) { + // can't merge nodes with different appearance + return false; + } + // add geometry from provided node + m_data.area.center = + interpolate( + m_data.area.center, Lines.m_data.area.center, + static_cast( Lines.m_data.vertices.size() ) / ( Lines.m_data.vertices.size() + m_data.vertices.size() ) ); + m_data.vertices.insert( + std::end( m_data.vertices ), + std::begin( Lines.m_data.vertices ), std::end( Lines.m_data.vertices ) ); + // NOTE: we could recalculate radius with something other than brute force, but it'll do + compute_radius(); + + return true; +} + +// generates renderable version of held non-instanced geometry in specified geometry bank +void +lines_node::create_geometry( gfx::geometrybank_handle const &Bank ) { + + gfx::vertex_array vertices; vertices.reserve( m_data.vertices.size() ); + + for( auto const &vertex : m_data.vertices ) { + vertices.emplace_back( + vertex.position - m_data.origin, + vertex.normal, + vertex.texture ); + } + m_data.geometry = GfxRenderer.Insert( vertices, Bank, GL_LINES ); + std::vector().swap( m_data.vertices ); // hipster shrink_to_fit +} + +// calculates node's bounding radius +void +lines_node::compute_radius() { + + auto squaredradius { 0.0 }; + for( auto const &vertex : m_data.vertices ) { + squaredradius = std::max( + squaredradius, + glm::length2( vertex.position - m_data.area.center ) ); + } + m_data.area.radius = static_cast( std::sqrt( squaredradius ) ); +} + + + +/* +memory_node & +memory_node::deserialize( cParser &Input, node_data const &Nodedata ) { + + // import common data + m_name = Nodedata.name; + + Input.getTokens( 3 ); + Input + >> m_data.area.center.x + >> m_data.area.center.y + >> m_data.area.center.z; + + TMemCell memorycell( Nodedata.name ); + memorycell.Load( &Input ); +} +*/ + + + +basic_node::basic_node( scene::node_data const &Nodedata ) : + m_name( Nodedata.name ) +{ + m_rangesquaredmin = Nodedata.range_min * Nodedata.range_min; + m_rangesquaredmax = ( + Nodedata.range_max >= 0.0 ? + Nodedata.range_max * Nodedata.range_max : + std::numeric_limits::max() ); +} + +// sends content of the class to provided stream +void +basic_node::serialize( std::ostream &Output ) const { + // bounding area + m_area.serialize( Output ); + // visibility + sn_utils::ls_float64( Output, m_rangesquaredmin ); + sn_utils::ls_float64( Output, m_rangesquaredmax ); + sn_utils::s_bool( Output, m_visible ); + // name + sn_utils::s_str( Output, m_name ); + // template method implementation + serialize_( Output ); +} + +// restores content of the class from provided stream +void +basic_node::deserialize( std::istream &Input ) { + // bounding area + m_area.deserialize( Input ); + // visibility + m_rangesquaredmin = sn_utils::ld_float64( Input ); + m_rangesquaredmax = sn_utils::ld_float64( Input ); + m_visible = sn_utils::d_bool( Input ); + // name + m_name = sn_utils::d_str( Input ); + // template method implementation + deserialize_( Input ); +} + +// sends basic content of the class in legacy (text) format to provided stream +void +basic_node::export_as_text( std::ostream &Output ) const { + + Output + // header + << "node" + // visibility + << ' ' << ( m_rangesquaredmax < std::numeric_limits::max() ? std::sqrt( m_rangesquaredmax ) : -1 ) + << ' ' << std::sqrt( m_rangesquaredmin ) + // name + << ' ' << m_name << ' '; + // template method implementation + export_as_text_( Output ); +} + +void +basic_node::export_as_text( std::string &Output ) const { + + std::stringstream converter; + export_as_text( converter ); + Output += converter.str(); +} + +float const & +basic_node::radius() { + + if( m_area.radius == -1.0 ) { + // calculate if needed + m_area.radius = radius_(); + } + return m_area.radius; +} + +// radius() subclass details, calculates node's bounding radius +// by default nodes are 'virtual don't extend from their center point +float +basic_node::radius_() { + + return 0.f; +} + +} // scene + +//--------------------------------------------------------------------------- diff --git a/scenenode.h b/scenenode.h new file mode 100644 index 00000000..0d8fc1c5 --- /dev/null +++ b/scenenode.h @@ -0,0 +1,405 @@ +/* +This Source Code Form is subject to the +terms of the Mozilla Public License, v. +2.0. If a copy of the MPL was not +distributed with this file, You can +obtain one at +http://mozilla.org/MPL/2.0/. +*/ + +#pragma once + +#include + +#include "classes.h" +#include "material.h" +#include "vertex.h" +#include "openglgeometrybank.h" + +struct lighting_data { + + glm::vec4 diffuse { 0.8f, 0.8f, 0.8f, 1.0f }; + glm::vec4 ambient { 0.2f, 0.2f, 0.2f, 1.0f }; + glm::vec4 specular { 0.0f, 0.0f, 0.0f, 1.0f }; + + // stores content of the struct in provided output stream + void + serialize( std::ostream &Output ) const; + // restores content of the struct from provided input stream + void + deserialize( std::istream &Input ); +}; + +inline +bool +operator==( lighting_data const &Left, lighting_data const &Right ) { + return ( ( Left.diffuse == Right.diffuse ) + && ( Left.ambient == Right.ambient ) + && ( Left.specular == Right.specular ) ); +} + +inline +bool +operator!=( lighting_data const &Left, lighting_data const &Right ) { + return !( Left == Right ); +} + +namespace scene { + +struct bounding_area { + + glm::dvec3 center; // mid point of the rectangle + float radius { -1.0f }; // radius of the bounding sphere + + bounding_area() = default; + bounding_area( glm::dvec3 Center, float Radius ) : + center( Center ), + radius( Radius ) + {} + // stores content of the struct in provided output stream + void + serialize( std::ostream &Output ) const; + // restores content of the struct from provided input stream + void + deserialize( std::istream &Input ); +}; + +using group_handle = std::size_t; + +struct node_data { + + double range_min { 0.0 }; + double range_max { std::numeric_limits::max() }; + std::string name; + std::string type; +}; + +// holds unique piece of geometry, covered with single material +class shape_node { + + friend class basic_region; // region might want to modify node content when it's being inserted + +public: +// types + struct shapenode_data { + // members: + // placement and visibility + scene::bounding_area area; // bounding area, in world coordinates + double rangesquared_min { 0.0 }; // visibility range, min + double rangesquared_max { 0.0 }; // visibility range, max + bool visible { true }; // visibility flag + // material data + bool translucent { false }; // whether opaque or translucent + material_handle material { null_handle }; + lighting_data lighting; + // geometry data + glm::dvec3 origin; // world position of the relative coordinate system origin + gfx::geometry_handle geometry { 0, 0 }; // relative origin-centered chunk of geometry held by gfx renderer + std::vector vertices; // world space source data of the geometry + // methods: + // sends content of the struct to provided stream + void + serialize( std::ostream &Output ) const; + // restores content of the struct from provided input stream + void + deserialize( std::istream &Input ); + }; + +// methods + // sends content of the class to provided stream + void + serialize( std::ostream &Output ) const; + // restores content of the node from provided input stream + shape_node & + deserialize( std::istream &Input ); + // restores content of the node from provided input stream + shape_node & + import( cParser &Input, scene::node_data const &Nodedata ); + // imports data from provided submodel + shape_node & + convert( TSubModel const *Submodel ); + // adds content of provided node to already enclosed geometry. returns: true if merge could be performed + bool + merge( shape_node &Shape ); + // generates renderable version of held non-instanced geometry in specified geometry bank + void + create_geometry( gfx::geometrybank_handle const &Bank ); + // calculates shape's bounding radius + void + compute_radius(); + // set visibility + void + visible( bool State ); + // set origin point + void + origin( glm::dvec3 Origin ); + // data access + shapenode_data const & + data() const; + +private: +// members + std::string m_name; + shapenode_data m_data; +}; + +// set visibility +inline +void +shape_node::visible( bool State ) { + m_data.visible = State; +} +// set origin point +inline +void +shape_node::origin( glm::dvec3 Origin ) { + m_data.origin = Origin; +} +// data access +inline +shape_node::shapenode_data const & +shape_node::data() const { + return m_data; +} + + + +// holds a group of untextured lines +class lines_node { + + friend class basic_region; // region might want to modify node content when it's being inserted + +public: +// types + struct linesnode_data { + // members: + // placement and visibility + scene::bounding_area area; // bounding area, in world coordinates + double rangesquared_min { 0.0 }; // visibility range, min + double rangesquared_max { 0.0 }; // visibility range, max + bool visible { true }; // visibility flag + // material data + float line_width { 1.f }; // thickness of stored lines + lighting_data lighting; + // geometry data + glm::dvec3 origin; // world position of the relative coordinate system origin + gfx::geometry_handle geometry { 0, 0 }; // relative origin-centered chunk of geometry held by gfx renderer + std::vector vertices; // world space source data of the geometry + // methods: + // sends content of the struct to provided stream + void + serialize( std::ostream &Output ) const; + // restores content of the struct from provided input stream + void + deserialize( std::istream &Input ); + }; + +// methods + // sends content of the class to provided stream + void + serialize( std::ostream &Output ) const; + // restores content of the node from provided input stream + lines_node & + deserialize( std::istream &Input ); + // restores content of the node from provided input stream + lines_node & + import( cParser &Input, scene::node_data const &Nodedata ); + // adds content of provided node to already enclosed geometry. returns: true if merge could be performed + bool + merge( lines_node &Lines ); + // generates renderable version of held non-instanced geometry in specified geometry bank + void + create_geometry( gfx::geometrybank_handle const &Bank ); + // calculates shape's bounding radius + void + compute_radius(); + // set visibility + void + visible( bool State ); + // set origin point + void + origin( glm::dvec3 Origin ); + // data access + linesnode_data const & + data() const; + +private: +// members + std::string m_name; + linesnode_data m_data; +}; + +// set visibility +inline +void +lines_node::visible( bool State ) { + m_data.visible = State; +} +// set origin point +inline +void +lines_node::origin( glm::dvec3 Origin ) { + m_data.origin = Origin; +} +// data access +inline +lines_node::linesnode_data const & +lines_node::data() const { + return m_data; +} + + +/* +// holds geometry for specific piece of track/road/waterway +class path_node { + + friend class basic_region; // region might want to modify node content when it's being inserted + +public: +// types + // TODO: enable after track class refactoring + struct pathnode_data { + // placement and visibility + bounding_area area; // bounding area, in world coordinates + bool visible { true }; // visibility flag + // material data + material_handle material_1 { 0 }; + material_handle material_2 { 0 }; + lighting_data lighting; + TEnvironmentType environment { e_flat }; + // geometry data + std::vector vertices; // world space source data of the geometry + glm::dvec3 origin; // world position of the relative coordinate system origin + using geometryhandle_sequence = std::vector; + geometryhandle_sequence geometry_1; // geometry chunks textured with texture 1 + geometryhandle_sequence geometry_2; // geometry chunks textured with texture 2 + }; +// methods + // restores content of the node from provded input stream + // TODO: implement + path_node & + deserialize( cParser &Input, node_data const &Nodedata ); + // binds specified track to the node + // TODO: remove after track class refactoring + void + path( TTrack *Path ) { + m_path = Path; } + TTrack * + path() { + return m_path; } + +private: +// members + +// // TODO: enable after track class refactoring +// pathnode_data m_data; + + TTrack * m_path; +}; +*/ + + + +// base interface for nodes which can be actvated in scenario editor +class basic_node { + +public: +// constructor + explicit basic_node( scene::node_data const &Nodedata ); +// destructor + virtual ~basic_node() = default; +// methods + // sends content of the class to provided stream + void + serialize( std::ostream &Output ) const; + // restores content of the class from provided stream + void + deserialize( std::istream &Input ); + // sends basic content of the class in legacy (text) format to provided stream + void + export_as_text( std::ostream &Output ) const; + void + export_as_text( std::string &Output ) const; + std::string const & + name() const; + void + location( glm::dvec3 const Location ); + glm::dvec3 const & + location() const; + float const & + radius(); + void + visible( bool const Visible ); + bool + visible() const; + void + group( scene::group_handle Group ); + scene::group_handle + group() const; + +protected: +// members + scene::group_handle m_group { null_handle }; // group this node belongs to, if any + scene::bounding_area m_area; + double m_rangesquaredmin { 0.0 }; // visibility range, min + double m_rangesquaredmax { 0.0 }; // visibility range, max + bool m_visible { true }; // visibility flag + std::string m_name; + +private: +// methods + // radius() subclass details, calculates node's bounding radius + virtual float radius_(); + // serialize() subclass details, sends content of the subclass to provided stream + virtual void serialize_( std::ostream &Output ) const = 0; + // deserialize() subclass details, restores content of the subclass from provided stream + virtual void deserialize_( std::istream &Input ) = 0; + // export() subclass details, sends basic content of the class in legacy (text) format to provided stream + virtual void export_as_text_( std::ostream &Output ) const = 0; +}; + +inline +std::string const & +basic_node::name() const { + return m_name; +} + +inline +void +basic_node::location( glm::dvec3 const Location ) { + m_area.center = Location; +} + +inline +glm::dvec3 const & +basic_node::location() const { + return m_area.center; +} + +inline +void +basic_node::visible( bool const Visible ) { + m_visible = Visible; +} + +inline +bool +basic_node::visible() const { + return m_visible; +} + +inline +void +basic_node::group( scene::group_handle Group ) { + m_group = Group; +} + +inline +scene::group_handle +basic_node::group() const { + return m_group; +} + +} // scene + +//--------------------------------------------------------------------------- diff --git a/scenenodegroups.cpp b/scenenodegroups.cpp new file mode 100644 index 00000000..72b1351d --- /dev/null +++ b/scenenodegroups.cpp @@ -0,0 +1,142 @@ +/* +This Source Code Form is subject to the +terms of the Mozilla Public License, v. +2.0. If a copy of the MPL was not +distributed with this file, You can +obtain one at +http://mozilla.org/MPL/2.0/. +*/ + +#include "stdafx.h" +#include "scenenodegroups.h" + +#include "event.h" +#include "memcell.h" + +namespace scene { + +node_groups Groups; + +// requests creation of a new node group. returns: handle to the group +scene::group_handle +node_groups::create() { + + m_activegroup.push( create_handle() ); + + return handle(); +} + +// indicates creation of current group ended. returns: handle to the parent group or null_handle if group stack is empty +scene::group_handle +node_groups::close() { + + if( false == m_activegroup.empty() ) { + + auto const closinggroup { m_activegroup.top() }; + m_activegroup.pop(); + // if the completed group holds only one item and there's no chance more items will be added, disband it + if( ( true == m_activegroup.empty() ) + || ( m_activegroup.top() != closinggroup ) ) { + + auto lookup { m_groupmap.find( closinggroup ) }; + if( ( lookup != m_groupmap.end() ) + && ( ( lookup->second.nodes.size() + lookup->second.events.size() ) <= 1 ) ) { + + erase( lookup ); + } + } + } + return handle(); +} + +// returns current active group, or null_handle if group stack is empty +group_handle +node_groups::handle() const { + + return ( + m_activegroup.empty() ? + null_handle : + m_activegroup.top() ); +} + +// places provided node in specified group +void +node_groups::insert( scene::group_handle const Group, scene::basic_node *Node ) { + + // TBD, TODO: automatically unregister the node from its current group? + Node->group( Group ); + + if( Group == null_handle ) { return; } + + auto &nodesequence { m_groupmap[ Group ].nodes }; + if( std::find( std::begin( nodesequence ), std::end( nodesequence ), Node ) == std::end( nodesequence ) ) { + // don't add the same node twice + nodesequence.emplace_back( Node ); + } +} + +// places provided event in specified group +void +node_groups::insert( scene::group_handle const Group, basic_event *Event ) { + + // TBD, TODO: automatically unregister the event from its current group? + Event->group( Group ); + + if( Group == null_handle ) { return; } + + auto &eventsequence { m_groupmap[ Group ].events }; + if( std::find( std::begin( eventsequence ), std::end( eventsequence ), Event ) == std::end( eventsequence ) ) { + // don't add the same node twice + eventsequence.emplace_back( Event ); + } +} + +// sends basic content of the class in legacy (text) format to provided stream +void +node_groups::export_as_text( std::ostream &Output ) const { + + for( auto const &group : m_groupmap ) { + + Output << "group\n"; + for( auto *node : group.second.nodes ) { + // HACK: auto-generated memory cells aren't exported, so we check for this + // TODO: is_exportable as basic_node method + if( ( typeid( *node ) == typeid( TMemCell ) ) + && ( false == static_cast( node )->is_exportable ) ) { + continue; + } + node->export_as_text( Output ); + } + for( auto *event : group.second.events ) { + event->export_as_text( Output ); + } + Output << "endgroup\n"; + } +} + +// removes specified group from the group list and group information from the group's nodes +void +node_groups::erase( group_map::const_iterator Group ) { + + for( auto *node : Group->second.nodes ) { + node->group( null_handle ); + } + for( auto *event : Group->second.events ) { + event->group( null_handle ); + } + m_groupmap.erase( Group ); +} + +// creates handle for a new group +group_handle +node_groups::create_handle() { + // NOTE: for simplification nested group structure are flattened + return( + m_activegroup.empty() ? + m_groupmap.size() + 1 : // new group isn't created until node registration + m_activegroup.top() ); +} + +} // scene + +//--------------------------------------------------------------------------- diff --git a/scenenodegroups.h b/scenenodegroups.h new file mode 100644 index 00000000..d0815bae --- /dev/null +++ b/scenenodegroups.h @@ -0,0 +1,72 @@ +/* +This Source Code Form is subject to the +terms of the Mozilla Public License, v. +2.0. If a copy of the MPL was not +distributed with this file, You can +obtain one at +http://mozilla.org/MPL/2.0/. +*/ + +#pragma once + +#include "scenenode.h" + +namespace scene { + +struct basic_group { +// members + std::vector nodes; + std::vector events; +}; + +// holds lists of grouped scene nodes +class node_groups { + // NOTE: during scenario deserialization encountering *.inc file causes creation of a new group on the group stack + // this allows all nodes listed in this *.inc file to be grouped and potentially modified together by the editor. +public: +// constructors + node_groups() = default; +// methods + // requests creation of a new node group. returns: handle to the group + group_handle + create(); + // indicates creation of current group ended. returns: handle to the parent group or null_handle if group stack is empty + group_handle + close(); + // returns current active group, or null_handle if group stack is empty + group_handle + handle() const; + // places provided node in specified group + void + insert( scene::group_handle const Group, scene::basic_node *Node ); + // places provided event in specified group + void + insert( scene::group_handle const Group, basic_event *Event ); + // grants direct access to specified group + scene::basic_group & + group( scene::group_handle const Group ) { + return m_groupmap[ Group ]; } + // sends basic content of the class in legacy (text) format to provided stream + void + export_as_text( std::ostream &Output ) const; + +private: +// types + using group_map = std::unordered_map; +// methods + // removes specified group from the group list and group information from the group's nodes + void + erase( group_map::const_iterator Group ); + // creates handle for a new group + group_handle + create_handle(); +// members + group_map m_groupmap; // map of established node groups + std::stack m_activegroup; // helper, group to be assigned to newly created nodes +}; + +extern node_groups Groups; + +} // scene + +//--------------------------------------------------------------------------- diff --git a/simulation.cpp b/simulation.cpp new file mode 100644 index 00000000..779ce554 --- /dev/null +++ b/simulation.cpp @@ -0,0 +1,99 @@ +/* +This Source Code Form is subject to the +terms of the Mozilla Public License, v. +2.0. If a copy of the MPL was not +distributed with this file, You can +obtain one at +http://mozilla.org/MPL/2.0/. +*/ + +#include "stdafx.h" +#include "simulation.h" +#include "simulationtime.h" + +#include "globals.h" +#include "event.h" +#include "memcell.h" +#include "track.h" +#include "traction.h" +#include "tractionpower.h" +#include "sound.h" +#include "animmodel.h" +#include "dynobj.h" +#include "lightarray.h" +#include "scene.h" +#include "train.h" + +namespace simulation { + +state_manager State; +event_manager Events; +memory_table Memory; +path_table Paths; +traction_table Traction; +powergridsource_table Powergrid; +sound_table Sounds; +instance_table Instances; +vehicle_table Vehicles; +light_array Lights; + +scene::basic_region *Region { nullptr }; +TTrain *Train { nullptr }; + +bool is_ready { false }; + +bool +state_manager::deserialize( std::string const &Scenariofile ) { + + return m_serializer.deserialize( Scenariofile ); +} + +// stores class data in specified file, in legacy (text) format +void +state_manager::export_as_text( std::string const &Scenariofile ) const { + + return m_serializer.export_as_text( Scenariofile ); +} + +// legacy method, calculates changes in simulation state over specified time +void +state_manager::update( double const Deltatime, int Iterationcount ) { + // aktualizacja animacji krokiem FPS: dt=krok czasu [s], dt*iter=czas od ostatnich przeliczeń + if (Deltatime == 0.0) { + return; + } + + auto const totaltime { Deltatime * Iterationcount }; + // NOTE: we perform animations first, as they can determine factors like contact with powergrid + TAnimModel::AnimUpdate( totaltime ); // wykonanie zakolejkowanych animacji + + simulation::Powergrid.update( totaltime ); + simulation::Vehicles.update( Deltatime, Iterationcount ); +} + +void +state_manager::update_clocks() { + + // Ra 2014-07: przeliczenie kąta czasu (do animacji zależnych od czasu) + auto const &time = simulation::Time.data(); + Global.fTimeAngleDeg = time.wHour * 15.0 + time.wMinute * 0.25 + ( ( time.wSecond + 0.001 * time.wMilliseconds ) / 240.0 ); + Global.fClockAngleDeg[ 0 ] = 36.0 * ( time.wSecond % 10 ); // jednostki sekund + Global.fClockAngleDeg[ 1 ] = 36.0 * ( time.wSecond / 10 ); // dziesiątki sekund + Global.fClockAngleDeg[ 2 ] = 36.0 * ( time.wMinute % 10 ); // jednostki minut + Global.fClockAngleDeg[ 3 ] = 36.0 * ( time.wMinute / 10 ); // dziesiątki minut + Global.fClockAngleDeg[ 4 ] = 36.0 * ( time.wHour % 10 ); // jednostki godzin + Global.fClockAngleDeg[ 5 ] = 36.0 * ( time.wHour / 10 ); // dziesiątki godzin +} + +// passes specified sound to all vehicles within range as a radio message broadcasted on specified channel +void +radio_message( sound_source *Message, int const Channel ) { + + if( Train != nullptr ) { + Train->radio_message( Message, Channel ); + } +} + +} // simulation + +//--------------------------------------------------------------------------- diff --git a/simulation.h b/simulation.h new file mode 100644 index 00000000..28d76da6 --- /dev/null +++ b/simulation.h @@ -0,0 +1,59 @@ +/* +This Source Code Form is subject to the +terms of the Mozilla Public License, v. +2.0. If a copy of the MPL was not +distributed with this file, You can +obtain one at +http://mozilla.org/MPL/2.0/. +*/ + +#pragma once + +#include "simulationstateserializer.h" +#include "classes.h" + +namespace simulation { + +class state_manager { + +public: +// methods + // legacy method, calculates changes in simulation state over specified time + void + update( double Deltatime, int Iterationcount ); + void + update_clocks(); + // restores simulation data from specified file. returns: true on success, false otherwise + bool + deserialize( std::string const &Scenariofile ); + // stores class data in specified file, in legacy (text) format + void + export_as_text( std::string const &Scenariofile ) const; + +private: +// members + state_serializer m_serializer; +}; + +// passes specified sound to all vehicles within range as a radio message broadcasted on specified channel +void radio_message( sound_source *Message, int const Channel ); + +extern state_manager State; +extern event_manager Events; +extern memory_table Memory; +extern path_table Paths; +extern traction_table Traction; +extern powergridsource_table Powergrid; +extern sound_table Sounds; +extern instance_table Instances; +extern vehicle_table Vehicles; +extern light_array Lights; + +extern scene::basic_region *Region; +extern TTrain *Train; + +extern bool is_ready; + +} // simulation + +//--------------------------------------------------------------------------- diff --git a/simulationenvironment.cpp b/simulationenvironment.cpp new file mode 100644 index 00000000..5033c753 --- /dev/null +++ b/simulationenvironment.cpp @@ -0,0 +1,179 @@ +/* +This Source Code Form is subject to the +terms of the Mozilla Public License, v. +2.0. If a copy of the MPL was not +distributed with this file, You can +obtain one at +http://mozilla.org/MPL/2.0/. +*/ + +#include "stdafx.h" +#include "simulationenvironment.h" + +#include "globals.h" + +namespace simulation { + +world_environment Environment; + +} // simulation + +void +world_environment::toggle_daylight() { + + Global.FakeLight = !Global.FakeLight; + + if( Global.FakeLight ) { + // for fake daylight enter fixed hour + time( 10, 30, 0 ); + } + else { + // local clock based calculation + time(); + } +} + +// calculates current season of the year based on set simulation date +void +world_environment::compute_season( int const Yearday ) const { + + using dayseasonpair = std::pair; + + std::vector seasonsequence { + { 65, "winter:" }, + { 158, "spring:" }, + { 252, "summer:" }, + { 341, "autumn:" }, + { 366, "winter:" } }; + auto const lookup = + std::lower_bound( + std::begin( seasonsequence ), std::end( seasonsequence ), + clamp( Yearday, 1, seasonsequence.back().first ), + []( dayseasonpair const &Left, const int Right ) { + return Left.first < Right; } ); + + Global.Season = lookup->second; + // season can affect the weather so if it changes, re-calculate weather as well + compute_weather(); +} + +// calculates current weather +void +world_environment::compute_weather() const { + + Global.Weather = ( + Global.Overcast <= 0.25 ? "clear:" : + Global.Overcast <= 1.0 ? "cloudy:" : + ( Global.Season != "winter:" ? + "rain:" : + "snow:" ) ); +} + +void +world_environment::init() { + + m_sun.init(); + m_moon.init(); + m_stars.init(); + m_clouds.Init(); + m_precipitation.init(); + + m_precipitationsound.deserialize( "rain-sound-loop", sound_type::single ); +} + +void +world_environment::update() { + // move celestial bodies... + m_sun.update(); + m_moon.update(); + // ...determine source of key light and adjust global state accordingly... + // diffuse (sun) intensity goes down after twilight, and reaches minimum 18 degrees below horizon + float twilightfactor = clamp( -m_sun.getAngle(), 0.0f, 18.0f ) / 18.0f; + // NOTE: sun light receives extra padding to prevent moon from kicking in too soon + auto const sunlightlevel = m_sun.getIntensity() + 0.05f * ( 1.f - twilightfactor ); + auto const moonlightlevel = m_moon.getIntensity() * 0.65f; // scaled down by arbitrary factor, it's pretty bright otherwise + float keylightintensity; + glm::vec3 keylightcolor; + if( moonlightlevel > sunlightlevel ) { + // rare situations when the moon is brighter than the sun, typically at night + Global.SunAngle = m_moon.getAngle(); + Global.DayLight.position = m_moon.getDirection(); + Global.DayLight.direction = -1.0f * m_moon.getDirection(); + keylightintensity = moonlightlevel; + // if the moon is up, it overrides the twilight + twilightfactor = 0.0f; + keylightcolor = glm::vec3( 255.0f / 255.0f, 242.0f / 255.0f, 202.0f / 255.0f ); + } + else { + // regular situation with sun as the key light + Global.SunAngle = m_sun.getAngle(); + Global.DayLight.position = m_sun.getDirection(); + Global.DayLight.direction = -1.0f * m_sun.getDirection(); + keylightintensity = sunlightlevel; + // include 'golden hour' effect in twilight lighting + float const duskfactor = 1.0f - clamp( Global.SunAngle, 0.0f, 18.0f ) / 18.0f; + keylightcolor = interpolate( + glm::vec3( 255.0f / 255.0f, 242.0f / 255.0f, 231.0f / 255.0f ), + glm::vec3( 235.0f / 255.0f, 140.0f / 255.0f, 36.0f / 255.0f ), + duskfactor ); + } + // ...update skydome to match the current sun position as well... + m_skydome.SetOvercastFactor( Global.Overcast ); + m_skydome.Update( m_sun.getDirection() ); + // ...retrieve current sky colour and brightness... + auto const skydomecolour = m_skydome.GetAverageColor(); + auto const skydomehsv = colors::RGBtoHSV( skydomecolour ); + // sun strength is reduced by overcast level + keylightintensity *= ( 1.0f - std::min( 1.f, Global.Overcast ) * 0.65f ); + + // intensity combines intensity of the sun and the light reflected by the sky dome + // it'd be more technically correct to have just the intensity of the sun here, + // but whether it'd _look_ better is something to be tested + auto const intensity = std::min( 1.15f * ( 0.05f + keylightintensity + skydomehsv.z ), 1.25f ); + // the impact of sun component is reduced proportionally to overcast level, as overcast increases role of ambient light + auto const diffuselevel = interpolate( keylightintensity, intensity * ( 1.0f - twilightfactor ), 1.0f - std::min( 1.f, Global.Overcast ) * 0.75f ); + // ...update light colours and intensity. + keylightcolor = keylightcolor * diffuselevel; + Global.DayLight.diffuse = glm::vec4( keylightcolor, Global.DayLight.diffuse.a ); + Global.DayLight.specular = glm::vec4( keylightcolor * 0.85f, diffuselevel ); + + // tonal impact of skydome color is inversely proportional to how high the sun is above the horizon + // (this is pure conjecture, aimed more to 'look right' than be accurate) + float const ambienttone = clamp( 1.0f - ( Global.SunAngle / 90.0f ), 0.0f, 1.0f ); + Global.DayLight.ambient[ 0 ] = interpolate( skydomehsv.z, skydomecolour.r, ambienttone ); + Global.DayLight.ambient[ 1 ] = interpolate( skydomehsv.z, skydomecolour.g, ambienttone ); + Global.DayLight.ambient[ 2 ] = interpolate( skydomehsv.z, skydomecolour.b, ambienttone ); + + Global.fLuminance = intensity; + + // update the fog. setting it to match the average colour of the sky dome is cheap + // but quite effective way to make the distant items blend with background better + // NOTE: base brightness calculation provides scaled up value, so we bring it back to 'real' one here + Global.FogColor = m_skydome.GetAverageHorizonColor(); + + // weather-related simulation factors + // TODO: dynamic change of air temperature and overcast levels + if( Global.Weather == "rain:" ) { + // reduce friction in rain + Global.FrictionWeatherFactor = 0.85f; + m_precipitationsound.play( sound_flags::exclusive | sound_flags::looping ); + } + else if( Global.Weather == "snow:" ) { + // reduce friction due to snow + Global.FrictionWeatherFactor = 0.75f; + } +} + +void +world_environment::update_precipitation() { + + m_precipitation.update(); +} + +void +world_environment::time( int const Hour, int const Minute, int const Second ) { + + m_sun.setTime( Hour, Minute, Second ); +} + +//--------------------------------------------------------------------------- diff --git a/simulationenvironment.h b/simulationenvironment.h new file mode 100644 index 00000000..2f69f631 --- /dev/null +++ b/simulationenvironment.h @@ -0,0 +1,58 @@ +/* +This Source Code Form is subject to the +terms of the Mozilla Public License, v. +2.0. If a copy of the MPL was not +distributed with this file, You can +obtain one at +http://mozilla.org/MPL/2.0/. +*/ + +#pragma once + +#include "sky.h" +#include "sun.h" +#include "moon.h" +#include "stars.h" +#include "skydome.h" +#include "precipitation.h" +#include "sound.h" + +class opengl_renderer; + +// wrapper for environment elements -- sky, sun, stars, clouds etc +class world_environment { + + friend opengl_renderer; + +public: +// methods + void init(); + void update(); + void update_precipitation(); + void time( int const Hour = -1, int const Minute = -1, int const Second = -1 ); + // switches between static and dynamic daylight calculation + void toggle_daylight(); + // calculates current season of the year based on set simulation date + void compute_season( int const Yearday ) const; + // calculates current weather + void compute_weather() const; + +private: +// members + CSkyDome m_skydome; + cStars m_stars; + cSun m_sun; + cMoon m_moon; + TSky m_clouds; + basic_precipitation m_precipitation; + + sound_source m_precipitationsound { sound_placement::external, -1 }; +}; + +namespace simulation { + +extern world_environment Environment; + +} // simulation + +//--------------------------------------------------------------------------- diff --git a/simulationstateserializer.cpp b/simulationstateserializer.cpp new file mode 100644 index 00000000..d22a007b --- /dev/null +++ b/simulationstateserializer.cpp @@ -0,0 +1,1012 @@ +/* +This Source Code Form is subject to the +terms of the Mozilla Public License, v. +2.0. If a copy of the MPL was not +distributed with this file, You can +obtain one at +http://mozilla.org/MPL/2.0/. +*/ + +#pragma once + +#include "stdafx.h" +#include "simulationstateserializer.h" + +#include "globals.h" +#include "simulation.h" +#include "simulationtime.h" +#include "scenenodegroups.h" +#include "event.h" +#include "driver.h" +#include "dynobj.h" +#include "animmodel.h" +#include "tractionpower.h" +#include "application.h" +#include "renderer.h" +#include "logs.h" + +namespace simulation { + +bool +state_serializer::deserialize( std::string const &Scenariofile ) { + + // TODO: move initialization to separate routine so we can reuse it + SafeDelete( Region ); + Region = new scene::basic_region(); + + // TODO: check first for presence of serialized binary files + // if this fails, fall back on the legacy text format + scene::scratch_data importscratchpad; + importscratchpad.name = Scenariofile; + if( Scenariofile != "$.scn" ) { + // compilation to binary file isn't supported for rainsted-created overrides + // NOTE: we postpone actual loading of the scene until we process time, season and weather data + importscratchpad.binary.terrain = Region->is_scene( Scenariofile ) ; + } + // NOTE: for the time being import from text format is a given, since we don't have full binary serialization + cParser scenarioparser( Scenariofile, cParser::buffer_FILE, Global.asCurrentSceneryPath, Global.bLoadTraction ); + + if( false == scenarioparser.ok() ) { return false; } + + deserialize( scenarioparser, importscratchpad ); + if( ( false == importscratchpad.binary.terrain ) + && ( Scenariofile != "$.scn" ) ) { + // if we didn't find usable binary version of the scenario files, create them now for future use + // as long as the scenario file wasn't rainsted-created base file override + Region->serialize( Scenariofile ); + } + return true; +} + +// restores class data from provided stream +void +state_serializer::deserialize( cParser &Input, scene::scratch_data &Scratchpad ) { + + // prepare deserialization function table + // since all methods use the same objects, we can have simple, hard-coded binds or lambdas for the task + using deserializefunction = void( state_serializer::*)(cParser &, scene::scratch_data &); + std::vector< + std::pair< + std::string, + deserializefunction> > functionlist = { + { "area", &state_serializer::deserialize_area }, + { "atmo", &state_serializer::deserialize_atmo }, + { "camera", &state_serializer::deserialize_camera }, + { "config", &state_serializer::deserialize_config }, + { "description", &state_serializer::deserialize_description }, + { "event", &state_serializer::deserialize_event }, + { "firstinit", &state_serializer::deserialize_firstinit }, + { "group", &state_serializer::deserialize_group }, + { "endgroup", &state_serializer::deserialize_endgroup }, + { "light", &state_serializer::deserialize_light }, + { "node", &state_serializer::deserialize_node }, + { "origin", &state_serializer::deserialize_origin }, + { "endorigin", &state_serializer::deserialize_endorigin }, + { "rotate", &state_serializer::deserialize_rotate }, + { "sky", &state_serializer::deserialize_sky }, + { "test", &state_serializer::deserialize_test }, + { "time", &state_serializer::deserialize_time }, + { "trainset", &state_serializer::deserialize_trainset }, + { "endtrainset", &state_serializer::deserialize_endtrainset } }; + using deserializefunctionbind = std::function; + std::unordered_map< + std::string, + deserializefunctionbind> functionmap; + for( auto &function : functionlist ) { + functionmap.emplace( function.first, std::bind( function.second, this, std::ref( Input ), std::ref( Scratchpad ) ) ); + } + + // deserialize content from the provided input + auto + timelast { std::chrono::steady_clock::now() }, + timenow { timelast }; + std::string token { Input.getToken() }; + while( false == token.empty() ) { + + auto lookup = functionmap.find( token ); + if( lookup != functionmap.end() ) { + lookup->second(); + } + else { + ErrorLog( "Bad scenario: unexpected token \"" + token + "\" defined in file \"" + Input.Name() + "\" (line " + std::to_string( Input.Line() - 1 ) + ")" ); + } + + timenow = std::chrono::steady_clock::now(); + if( std::chrono::duration_cast( timenow - timelast ).count() >= 200 ) { + timelast = timenow; + glfwPollEvents(); + Application.set_progress( Input.getProgress(), Input.getFullProgress() ); + GfxRenderer.Render(); + } + + token = Input.getToken(); + } + + if( false == Scratchpad.initialized ) { + // manually perform scenario initialization + deserialize_firstinit( Input, Scratchpad ); + } +} + +void +state_serializer::deserialize_area( cParser &Input, scene::scratch_data &Scratchpad ) { + // first parameter specifies name of parent piece... + auto token { Input.getToken() }; + auto *groupowner { TIsolated::Find( token ) }; + // ...followed by list of its children + while( ( false == ( token = Input.getToken() ).empty() ) + && ( token != "endarea" ) ) { + // bind the children with their parent + auto *isolated { TIsolated::Find( token ) }; + isolated->parent( groupowner ); + } +} + +void +state_serializer::deserialize_atmo( cParser &Input, scene::scratch_data &Scratchpad ) { + + // NOTE: parameter system needs some decent replacement, but not worth the effort if we're moving to built-in editor + // atmosphere color; legacy parameter, no longer used + Input.getTokens( 3 ); + // fog range + Input.getTokens( 2 ); + Input + >> Global.fFogStart + >> Global.fFogEnd; + + if( Global.fFogEnd > 0.0 ) { + // fog colour; optional legacy parameter, no longer used + Input.getTokens( 3 ); + } + + std::string token { Input.getToken() }; + if( token != "endatmo" ) { + // optional overcast parameter + Global.Overcast = std::stof( token ); + if( Global.Overcast < 0.f ) { + // negative overcast means random value in range 0-abs(specified range) + Global.Overcast = + Random( + clamp( + std::abs( Global.Overcast ), + 0.f, 2.f ) ); + } + // overcast drives weather so do a calculation here + // NOTE: ugly, clean it up when we're done with world refactoring + simulation::Environment.compute_weather(); + } + while( ( false == token.empty() ) + && ( token != "endatmo" ) ) { + // anything else left in the section has no defined meaning + token = Input.getToken(); + } +} + +void +state_serializer::deserialize_camera( cParser &Input, scene::scratch_data &Scratchpad ) { + + glm::dvec3 xyz, abc; + int i = -1, into = -1; // do której definicji kamery wstawić + std::string token; + do { // opcjonalna siódma liczba określa numer kamery, a kiedyś były tylko 3 + Input.getTokens(); + Input >> token; + switch( ++i ) { // kiedyś camera miało tylko 3 współrzędne + case 0: { xyz.x = atof( token.c_str() ); break; } + case 1: { xyz.y = atof( token.c_str() ); break; } + case 2: { xyz.z = atof( token.c_str() ); break; } + case 3: { abc.x = atof( token.c_str() ); break; } + case 4: { abc.y = atof( token.c_str() ); break; } + case 5: { abc.z = atof( token.c_str() ); break; } + case 6: { into = atoi( token.c_str() ); break; } // takie sobie, bo można wpisać -1 + default: { break; } + } + } while( token.compare( "endcamera" ) != 0 ); + if( into < 0 ) + into = ++Global.iCameraLast; + if( into < 10 ) { // przepisanie do odpowiedniego miejsca w tabelce + Global.FreeCameraInit[ into ] = xyz; + Global.FreeCameraInitAngle[ into ] = + Math3D::vector3( + glm::radians( abc.x ), + glm::radians( abc.y ), + glm::radians( abc.z ) ); + Global.iCameraLast = into; // numer ostatniej + } +/* + // cleaned up version of the above. + // NOTE: no longer supports legacy mode where some parameters were optional + Input.getTokens( 7 ); + glm::vec3 + position, + rotation; + int index; + Input + >> position.x + >> position.y + >> position.z + >> rotation.x + >> rotation.y + >> rotation.z + >> index; + + skip_until( Input, "endcamera" ); + + // TODO: finish this +*/ +} + +void +state_serializer::deserialize_config( cParser &Input, scene::scratch_data &Scratchpad ) { + + // config parameters (re)definition + Global.ConfigParse( Input ); +} + +void +state_serializer::deserialize_description( cParser &Input, scene::scratch_data &Scratchpad ) { + + // legacy section, never really used; + skip_until( Input, "enddescription" ); +} + +void +state_serializer::deserialize_event( cParser &Input, scene::scratch_data &Scratchpad ) { + + // TODO: refactor event class and its de/serialization. do offset and rotation after deserialization is done + auto *event = make_event( Input, Scratchpad ); + if( event == nullptr ) { + // something went wrong at initial stage, move on + skip_until( Input, "endevent" ); + return; + } + + event->deserialize( Input, Scratchpad ); + + if( true == simulation::Events.insert( event ) ) { + scene::Groups.insert( scene::Groups.handle(), event ); + } + else { + delete event; + } +} + +void +state_serializer::deserialize_firstinit( cParser &Input, scene::scratch_data &Scratchpad ) { + + if( true == Scratchpad.initialized ) { return; } + + if( true == Scratchpad.binary.terrain ) { + // at this stage it should be safe to import terrain from the binary scene file + // TBD: postpone loading furter and only load required blocks during the simulation? + Region->deserialize( Scratchpad.name ); + } + + simulation::Paths.InitTracks(); + simulation::Traction.InitTraction(); + simulation::Events.InitEvents(); + simulation::Events.InitLaunchers(); + simulation::Memory.InitCells(); + + Scratchpad.initialized = true; +} + +void +state_serializer::deserialize_group( cParser &Input, scene::scratch_data &Scratchpad ) { + + scene::Groups.create(); +} + +void +state_serializer::deserialize_endgroup( cParser &Input, scene::scratch_data &Scratchpad ) { + + scene::Groups.close(); +} + +void +state_serializer::deserialize_light( cParser &Input, scene::scratch_data &Scratchpad ) { + + // legacy section, no longer used nor supported; + skip_until( Input, "endlight" ); +} + +void +state_serializer::deserialize_node( cParser &Input, scene::scratch_data &Scratchpad ) { + + auto const inputline = Input.Line(); // cache in case we need to report error + + scene::node_data nodedata; + // common data and node type indicator + Input.getTokens( 4 ); + Input + >> nodedata.range_max + >> nodedata.range_min + >> nodedata.name + >> nodedata.type; + // type-based deserialization. not elegant but it'll do + if( nodedata.type == "dynamic" ) { + + auto *vehicle { deserialize_dynamic( Input, Scratchpad, nodedata ) }; + // vehicle import can potentially fail + if( vehicle == nullptr ) { return; } + + if( false == simulation::Vehicles.insert( vehicle ) ) { + + ErrorLog( "Bad scenario: duplicate vehicle name \"" + vehicle->name() + "\" defined in file \"" + Input.Name() + "\" (line " + std::to_string( inputline ) + ")" ); + } + + if( ( vehicle->MoverParameters->CategoryFlag == 1 ) // trains only + && ( ( ( vehicle->LightList( side::front ) & ( light::headlight_left | light::headlight_right | light::headlight_upper ) ) != 0 ) + || ( ( vehicle->LightList( side::rear ) & ( light::headlight_left | light::headlight_right | light::headlight_upper ) ) != 0 ) ) ) { + simulation::Lights.insert( vehicle ); + } + } + else if( nodedata.type == "track" ) { + + auto *path { deserialize_path( Input, Scratchpad, nodedata ) }; + // duplicates of named tracks are currently experimentally allowed + if( false == simulation::Paths.insert( path ) ) { + ErrorLog( "Bad scenario: duplicate track name \"" + path->name() + "\" defined in file \"" + Input.Name() + "\" (line " + std::to_string( inputline ) + ")" ); +/* + delete path; + delete pathnode; +*/ + } + scene::Groups.insert( scene::Groups.handle(), path ); + simulation::Region->insert_and_register( path ); + } + else if( nodedata.type == "traction" ) { + + auto *traction { deserialize_traction( Input, Scratchpad, nodedata ) }; + // traction loading is optional + if( traction == nullptr ) { return; } + + if( false == simulation::Traction.insert( traction ) ) { + ErrorLog( "Bad scenario: duplicate traction piece name \"" + traction->name() + "\" defined in file \"" + Input.Name() + "\" (line " + std::to_string( inputline ) + ")" ); + } + scene::Groups.insert( scene::Groups.handle(), traction ); + simulation::Region->insert_and_register( traction ); + } + else if( nodedata.type == "tractionpowersource" ) { + + auto *powersource { deserialize_tractionpowersource( Input, Scratchpad, nodedata ) }; + // traction loading is optional + if( powersource == nullptr ) { return; } + + if( false == simulation::Powergrid.insert( powersource ) ) { + ErrorLog( "Bad scenario: duplicate power grid source name \"" + powersource->name() + "\" defined in file \"" + Input.Name() + "\" (line " + std::to_string( inputline ) + ")" ); + } +/* + // TODO: implement this + simulation::Region.insert_powersource( powersource, Scratchpad ); +*/ + } + else if( nodedata.type == "model" ) { + + if( nodedata.range_min < 0.0 ) { + // 3d terrain + if( false == Scratchpad.binary.terrain ) { + // if we're loading data from text .scn file convert and import + auto *instance { deserialize_model( Input, Scratchpad, nodedata ) }; + // model import can potentially fail + if( instance == nullptr ) { return; } + // go through submodels, and import them as shapes + auto const cellcount = instance->TerrainCount() + 1; // zliczenie submodeli + for( auto i = 1; i < cellcount; ++i ) { + auto *submodel = instance->TerrainSquare( i - 1 ); + simulation::Region->insert( + scene::shape_node().convert( submodel ), + Scratchpad, + false ); + // if there's more than one group of triangles in the cell they're held as children of the primary submodel + submodel = submodel->ChildGet(); + while( submodel != nullptr ) { + simulation::Region->insert( + scene::shape_node().convert( submodel ), + Scratchpad, + false ); + submodel = submodel->NextGet(); + } + } + // with the import done we can get rid of the source model + delete instance; + } + else { + // if binary terrain file was present, we already have this data + skip_until( Input, "endmodel" ); + } + } + else { + // regular instance of 3d mesh + auto *instance { deserialize_model( Input, Scratchpad, nodedata ) }; + // model import can potentially fail + if( instance == nullptr ) { return; } + + if( false == simulation::Instances.insert( instance ) ) { + ErrorLog( "Bad scenario: duplicate 3d model instance name \"" + instance->name() + "\" defined in file \"" + Input.Name() + "\" (line " + std::to_string( inputline ) + ")" ); + } + scene::Groups.insert( scene::Groups.handle(), instance ); + simulation::Region->insert( instance ); + } + } + else if( ( nodedata.type == "triangles" ) + || ( nodedata.type == "triangle_strip" ) + || ( nodedata.type == "triangle_fan" ) ) { + + auto const skip { + // all shapes will be loaded from the binary version of the file + ( true == Scratchpad.binary.terrain ) + // crude way to detect fixed switch trackbed geometry + || ( ( true == Global.CreateSwitchTrackbeds ) + && ( Input.Name().size() >= 15 ) + && ( Input.Name().substr( 0, 11 ) == "scenery/zwr" ) + && ( Input.Name().substr( Input.Name().size() - 4 ) == ".inc" ) ) }; + + if( false == skip ) { + + simulation::Region->insert( + scene::shape_node().import( + Input, nodedata ), + Scratchpad, + true ); + } + else { + skip_until( Input, "endtri" ); + } + } + else if( ( nodedata.type == "lines" ) + || ( nodedata.type == "line_strip" ) + || ( nodedata.type == "line_loop" ) ) { + + if( false == Scratchpad.binary.terrain ) { + + simulation::Region->insert( + scene::lines_node().import( + Input, nodedata ), + Scratchpad ); + } + else { + // all lines were already loaded from the binary version of the file + skip_until( Input, "endline" ); + } + } + else if( nodedata.type == "memcell" ) { + + auto *memorycell { deserialize_memorycell( Input, Scratchpad, nodedata ) }; + if( false == simulation::Memory.insert( memorycell ) ) { + ErrorLog( "Bad scenario: duplicate memory cell name \"" + memorycell->name() + "\" defined in file \"" + Input.Name() + "\" (line " + std::to_string( inputline ) + ")" ); + } + scene::Groups.insert( scene::Groups.handle(), memorycell ); + simulation::Region->insert( memorycell ); + } + else if( nodedata.type == "eventlauncher" ) { + + auto *eventlauncher { deserialize_eventlauncher( Input, Scratchpad, nodedata ) }; + if( false == simulation::Events.insert( eventlauncher ) ) { + ErrorLog( "Bad scenario: duplicate event launcher name \"" + eventlauncher->name() + "\" defined in file \"" + Input.Name() + "\" (line " + std::to_string( inputline ) + ")" ); + } + // event launchers can be either global, or local with limited range of activation + // each gets assigned different caretaker + if( true == eventlauncher->IsGlobal() ) { + simulation::Events.queue( eventlauncher ); + } + else { + scene::Groups.insert( scene::Groups.handle(), eventlauncher ); + simulation::Region->insert( eventlauncher ); + } + } + else if( nodedata.type == "sound" ) { + + auto *sound { deserialize_sound( Input, Scratchpad, nodedata ) }; + if( false == simulation::Sounds.insert( sound ) ) { + ErrorLog( "Bad scenario: duplicate sound node name \"" + sound->name() + "\" defined in file \"" + Input.Name() + "\" (line " + std::to_string( inputline ) + ")" ); + } + simulation::Region->insert( sound ); + } + +} + +void +state_serializer::deserialize_origin( cParser &Input, scene::scratch_data &Scratchpad ) { + + glm::dvec3 offset; + Input.getTokens( 3 ); + Input + >> offset.x + >> offset.y + >> offset.z; + // sumowanie całkowitego przesunięcia + Scratchpad.location.offset.emplace( + offset + ( + Scratchpad.location.offset.empty() ? + glm::dvec3() : + Scratchpad.location.offset.top() ) ); +} + +void +state_serializer::deserialize_endorigin( cParser &Input, scene::scratch_data &Scratchpad ) { + + if( false == Scratchpad.location.offset.empty() ) { + Scratchpad.location.offset.pop(); + } + else { + ErrorLog( "Bad origin: endorigin instruction with empty origin stack in file \"" + Input.Name() + "\" (line " + std::to_string( Input.Line() - 1 ) + ")" ); + } +} + +void +state_serializer::deserialize_rotate( cParser &Input, scene::scratch_data &Scratchpad ) { + + Input.getTokens( 3 ); + Input + >> Scratchpad.location.rotation.x + >> Scratchpad.location.rotation.y + >> Scratchpad.location.rotation.z; +} + +void +state_serializer::deserialize_sky( cParser &Input, scene::scratch_data &Scratchpad ) { + + // sky model + Input.getTokens( 1 ); + Input + >> Global.asSky; + // anything else left in the section has no defined meaning + skip_until( Input, "endsky" ); +} + +void +state_serializer::deserialize_test( cParser &Input, scene::scratch_data &Scratchpad ) { + + // legacy section, no longer supported; + skip_until( Input, "endtest" ); +} + +void +state_serializer::deserialize_time( cParser &Input, scene::scratch_data &Scratchpad ) { + + // current scenario time + cParser timeparser( Input.getToken() ); + timeparser.getTokens( 2, false, ":" ); + auto &time = simulation::Time.data(); + timeparser + >> time.wHour + >> time.wMinute; + + if( true == Global.ScenarioTimeCurrent ) { + // calculate time shift required to match scenario time with local clock + auto timenow = std::time( 0 ); + auto const *localtime = std::localtime( &timenow ); + Global.ScenarioTimeOffset = ( ( localtime->tm_hour * 60 + localtime->tm_min ) - ( time.wHour * 60 + time.wMinute ) ) / 60.f; + } + else if( false == std::isnan( Global.ScenarioTimeOverride ) ) { + // scenario time override takes precedence over scenario time offset + Global.ScenarioTimeOffset = ( ( Global.ScenarioTimeOverride * 60 ) - ( time.wHour * 60 + time.wMinute ) ) / 60.f; + } + + // remaining sunrise and sunset parameters are no longer used, as they're now calculated dynamically + // anything else left in the section has no defined meaning + skip_until( Input, "endtime" ); +} + +void +state_serializer::deserialize_trainset( cParser &Input, scene::scratch_data &Scratchpad ) { + + if( true == Scratchpad.trainset.is_open ) { + // shouldn't happen but if it does wrap up currently open trainset and report an error + deserialize_endtrainset( Input, Scratchpad ); + ErrorLog( "Bad scenario: encountered nested trainset definitions in file \"" + Input.Name() + "\" (line " + std::to_string( Input.Line() ) + ")" ); + } + + Scratchpad.trainset = scene::scratch_data::trainset_data(); + Scratchpad.trainset.is_open = true; + + Input.getTokens( 4 ); + Input + >> Scratchpad.trainset.name + >> Scratchpad.trainset.track + >> Scratchpad.trainset.offset + >> Scratchpad.trainset.velocity; +} + +void +state_serializer::deserialize_endtrainset( cParser &Input, scene::scratch_data &Scratchpad ) { + + if( ( false == Scratchpad.trainset.is_open ) + || ( true == Scratchpad.trainset.vehicles.empty() ) ) { + // not bloody likely but we better check for it just the same + ErrorLog( "Bad trainset: empty trainset defined in file \"" + Input.Name() + "\" (line " + std::to_string( Input.Line() - 1 ) + ")" ); + Scratchpad.trainset.is_open = false; + return; + } + + std::size_t vehicleindex { 0 }; + for( auto *vehicle : Scratchpad.trainset.vehicles ) { + // go through list of vehicles in the trainset, coupling them together and checking for potential driver + if( ( vehicle->Mechanik != nullptr ) + && ( vehicle->Mechanik->Primary() ) ) { + // primary driver will receive the timetable for this trainset + Scratchpad.trainset.driver = vehicle; + } + if( vehicleindex > 0 ) { + // from second vehicle on couple it with the previous one + Scratchpad.trainset.vehicles[ vehicleindex - 1 ]->AttachPrev( + vehicle, + Scratchpad.trainset.couplings[ vehicleindex - 1 ] ); + } + ++vehicleindex; + } + + if( Scratchpad.trainset.driver != nullptr ) { + // if present, send timetable to the driver + // wysłanie komendy "Timetable" ustawia odpowiedni tryb jazdy + auto *controller = Scratchpad.trainset.driver->Mechanik; + controller->DirectionInitial(); + controller->PutCommand( + "Timetable:" + Scratchpad.trainset.name, + Scratchpad.trainset.velocity, + 0, + nullptr ); + } + if( Scratchpad.trainset.couplings.back() == coupling::faux ) { + // jeśli ostatni pojazd ma sprzęg 0 to założymy mu końcówki blaszane (jak AI się odpali, to sobie poprawi) + Scratchpad.trainset.vehicles.back()->RaLightsSet( -1, light::rearendsignals ); + } + // all done + Scratchpad.trainset.is_open = false; +} + +// creates path and its wrapper, restoring class data from provided stream +TTrack * +state_serializer::deserialize_path( cParser &Input, scene::scratch_data &Scratchpad, scene::node_data const &Nodedata ) { + + // TODO: refactor track and wrapper classes and their de/serialization. do offset and rotation after deserialization is done + auto *track = new TTrack( Nodedata ); + auto const offset { ( + Scratchpad.location.offset.empty() ? + glm::dvec3 { 0.0 } : + glm::dvec3 { + Scratchpad.location.offset.top().x, + Scratchpad.location.offset.top().y, + Scratchpad.location.offset.top().z } ) }; + track->Load( &Input, offset ); + + return track; +} + +TTraction * +state_serializer::deserialize_traction( cParser &Input, scene::scratch_data &Scratchpad, scene::node_data const &Nodedata ) { + + if( false == Global.bLoadTraction ) { + skip_until( Input, "endtraction" ); + return nullptr; + } + // TODO: refactor track and wrapper classes and their de/serialization. do offset and rotation after deserialization is done + auto *traction = new TTraction( Nodedata ); + auto offset = ( + Scratchpad.location.offset.empty() ? + glm::dvec3() : + Scratchpad.location.offset.top() ); + traction->Load( &Input, offset ); + + return traction; +} + +TTractionPowerSource * +state_serializer::deserialize_tractionpowersource( cParser &Input, scene::scratch_data &Scratchpad, scene::node_data const &Nodedata ) { + + if( false == Global.bLoadTraction ) { + skip_until( Input, "end" ); + return nullptr; + } + + auto *powersource = new TTractionPowerSource( Nodedata ); + powersource->Load( &Input ); + // adjust location + powersource->location( transform( powersource->location(), Scratchpad ) ); + + return powersource; +} + +TMemCell * +state_serializer::deserialize_memorycell( cParser &Input, scene::scratch_data &Scratchpad, scene::node_data const &Nodedata ) { + + auto *memorycell = new TMemCell( Nodedata ); + memorycell->Load( &Input ); + // adjust location + memorycell->location( transform( memorycell->location(), Scratchpad ) ); + + return memorycell; +} + +TEventLauncher * +state_serializer::deserialize_eventlauncher( cParser &Input, scene::scratch_data &Scratchpad, scene::node_data const &Nodedata ) { + + glm::dvec3 location; + Input.getTokens( 3 ); + Input + >> location.x + >> location.y + >> location.z; + + auto *eventlauncher = new TEventLauncher( Nodedata ); + eventlauncher->Load( &Input ); + eventlauncher->location( transform( location, Scratchpad ) ); + + return eventlauncher; +} + +TAnimModel * +state_serializer::deserialize_model( cParser &Input, scene::scratch_data &Scratchpad, scene::node_data const &Nodedata ) { + + glm::dvec3 location; + glm::vec3 rotation; + Input.getTokens( 4 ); + Input + >> location.x + >> location.y + >> location.z + >> rotation.y; + + auto *instance = new TAnimModel( Nodedata ); + instance->Angles( Scratchpad.location.rotation + rotation ); // dostosowanie do pochylania linii + + if( instance->Load( &Input, false ) ) { + instance->location( transform( location, Scratchpad ) ); + } + else { + // model nie wczytał się - ignorowanie node + SafeDelete( instance ); + } + + return instance; +} + +TDynamicObject * +state_serializer::deserialize_dynamic( cParser &Input, scene::scratch_data &Scratchpad, scene::node_data const &Nodedata ) { + + if( false == Scratchpad.trainset.is_open ) { + // part of trainset data is used when loading standalone vehicles, so clear it just in case + Scratchpad.trainset = scene::scratch_data::trainset_data(); + } + auto const inputline { Input.Line() }; // cache in case of errors + // basic attributes + auto const datafolder { Input.getToken() }; + auto const skinfile { Input.getToken() }; + auto const mmdfile { Input.getToken() }; + auto const pathname = ( + Scratchpad.trainset.is_open ? + Scratchpad.trainset.track : + Input.getToken() ); + auto const offset { Input.getToken( false ) }; + auto const drivertype { Input.getToken() }; + auto const couplingdata = ( + Scratchpad.trainset.is_open ? + Input.getToken() : + "3" ); + auto const velocity = ( + Scratchpad.trainset.is_open ? + Scratchpad.trainset.velocity : + Input.getToken( false ) ); + // extract coupling type and optional parameters + auto const couplingdatawithparams = couplingdata.find( '.' ); + auto coupling = ( + couplingdatawithparams != std::string::npos ? + std::atoi( couplingdata.substr( 0, couplingdatawithparams ).c_str() ) : + std::atoi( couplingdata.c_str() ) ); + if( coupling < 0 ) { + // sprzęg zablokowany (pojazdy nierozłączalne przy manewrach) + coupling = ( -coupling ) | coupling::permanent; + } + if( ( offset != -1.0 ) + && ( std::abs( offset ) > 0.5 ) ) { // maksymalna odległość między sprzęgami - do przemyślenia + // likwidacja sprzęgu, jeśli odległość zbyt duża - to powinno być uwzględniane w fizyce sprzęgów... + coupling = coupling::faux; + } + auto const params = ( + couplingdatawithparams != std::string::npos ? + couplingdata.substr( couplingdatawithparams + 1 ) : + "" ); + // load amount and type + auto loadcount { Input.getToken( false ) }; + auto loadtype = ( + loadcount ? + Input.getToken() : + "" ); + if( loadtype == "enddynamic" ) { + // idiotoodporność: ładunek bez podanego typu nie liczy się jako ładunek + loadcount = 0; + loadtype = ""; + } + + auto *path = simulation::Paths.find( pathname ); + if( path == nullptr ) { + + ErrorLog( "Bad scenario: vehicle \"" + Nodedata.name + "\" placed on nonexistent path \"" + pathname + "\" in file \"" + Input.Name() + "\" (line " + std::to_string( inputline ) + ")" ); + skip_until( Input, "enddynamic" ); + return nullptr; + } + + if( ( true == Scratchpad.trainset.vehicles.empty() ) // jeśli pierwszy pojazd, + && ( false == path->m_events0.empty() ) // tor ma Event0 + && ( std::abs( velocity ) <= 1.f ) // a skład stoi + && ( Scratchpad.trainset.offset >= 0.0 ) // ale może nie sięgać na owy tor + && ( Scratchpad.trainset.offset < 8.0 ) ) { // i raczej nie sięga + // przesuwamy około pół EU07 dla wstecznej zgodności + Scratchpad.trainset.offset = 8.0; + } + + auto *vehicle = new TDynamicObject(); + + auto const length = + vehicle->Init( + Nodedata.name, + datafolder, skinfile, mmdfile, + path, + ( offset == -1.0 ? + Scratchpad.trainset.offset : + Scratchpad.trainset.offset - offset ), + drivertype, + velocity, + Scratchpad.trainset.name, + loadcount, loadtype, + ( offset == -1.0 ), + params ); + + if( length != 0.0 ) { // zero oznacza błąd + // przesunięcie dla kolejnego, minus bo idziemy w stronę punktu 1 + Scratchpad.trainset.offset -= length; + // automatically establish permanent connections for couplers which specify them in their definitions + if( ( coupling != 0 ) + && ( vehicle->MoverParameters->Couplers[ ( offset == -1.0 ? side::front : side::rear ) ].AllowedFlag & coupling::permanent ) ) { + coupling |= coupling::permanent; + } + if( true == Scratchpad.trainset.is_open ) { + Scratchpad.trainset.vehicles.emplace_back( vehicle ); + Scratchpad.trainset.couplings.emplace_back( coupling ); + } + } + else { + if( vehicle->MyTrack != nullptr ) { + // rare failure case where vehicle with length of 0 is added to the track, + // treated as error code and consequently deleted, but still remains on the track + vehicle->MyTrack->RemoveDynamicObject( vehicle ); + } + delete vehicle; + skip_until( Input, "enddynamic" ); + return nullptr; + } + + auto const destination { Input.getToken() }; + if( destination != "enddynamic" ) { + // optional vehicle destination parameter + vehicle->asDestination = Input.getToken(); + skip_until( Input, "enddynamic" ); + } + + return vehicle; +} + +sound_source * +state_serializer::deserialize_sound( cParser &Input, scene::scratch_data &Scratchpad, scene::node_data const &Nodedata ) { + + glm::dvec3 location; + Input.getTokens( 3 ); + Input + >> location.x + >> location.y + >> location.z; + // adjust location + location = transform( location, Scratchpad ); + + auto *sound = new sound_source( sound_placement::external, Nodedata.range_max ); + sound->offset( location ); + sound->name( Nodedata.name ); + sound->deserialize( Input, sound_type::single ); + + skip_until( Input, "endsound" ); + + return sound; +} + +// skips content of stream until specified token +void +state_serializer::skip_until( cParser &Input, std::string const &Token ) { + + std::string token { Input.getToken() }; + while( ( false == token.empty() ) + && ( token != Token ) ) { + + token = Input.getToken(); + } +} + +// transforms provided location by specifed rotation and offset +glm::dvec3 +state_serializer::transform( glm::dvec3 Location, scene::scratch_data const &Scratchpad ) { + + if( Scratchpad.location.rotation != glm::vec3( 0, 0, 0 ) ) { + auto const rotation = glm::radians( Scratchpad.location.rotation ); + Location = glm::rotateY( Location, rotation.y ); // Ra 2014-11: uwzględnienie rotacji + } + if( false == Scratchpad.location.offset.empty() ) { + Location += Scratchpad.location.offset.top(); + } + return Location; +} + + +// stores class data in specified file, in legacy (text) format +void +state_serializer::export_as_text( std::string const &Scenariofile ) const { + + if( Scenariofile == "$.scn" ) { + ErrorLog( "Bad file: scenery export not supported for file \"$.scn\"" ); + } + else { + WriteLog( "Scenery data export in progress..." ); + } + + auto filename { Scenariofile }; + while( filename[ 0 ] == '$' ) { + // trim leading $ char rainsted utility may add to the base name for modified .scn files + filename.erase( 0, 1 ); + } + erase_extension( filename ); + filename = Global.asCurrentSceneryPath + filename + "_export"; + + std::ofstream scmfile { filename + ".scm" }; + // groups + scmfile << "// groups\n"; + scene::Groups.export_as_text( scmfile ); + // tracks + scmfile << "// paths\n"; + for( auto const *path : Paths.sequence() ) { + if( path->group() == null_handle ) { + path->export_as_text( scmfile ); + } + } + // traction + scmfile << "// traction\n"; + for( auto const *traction : Traction.sequence() ) { + if( traction->group() == null_handle ) { + traction->export_as_text( scmfile ); + } + } + // power grid + scmfile << "// traction power sources\n"; + for( auto const *powersource : Powergrid.sequence() ) { + if( powersource->group() == null_handle ) { + powersource->export_as_text( scmfile ); + } + } + // models + scmfile << "// instanced models\n"; + for( auto const *instance : Instances.sequence() ) { + if( instance->group() == null_handle ) { + instance->export_as_text( scmfile ); + } + } + // sounds + // NOTE: sounds currently aren't included in groups + scmfile << "// sounds\n"; + Region->export_as_text( scmfile ); + + std::ofstream ctrfile { filename + ".ctr" }; + // mem cells + ctrfile << "// memory cells\n"; + for( auto const *memorycell : Memory.sequence() ) { + if( ( true == memorycell->is_exportable ) + && ( memorycell->group() == null_handle ) ) { + memorycell->export_as_text( ctrfile ); + } + } + // events + Events.export_as_text( ctrfile ); + + WriteLog( "Scenery data export done." ); +} + +} // simulation + + //--------------------------------------------------------------------------- diff --git a/simulationstateserializer.h b/simulationstateserializer.h new file mode 100644 index 00000000..58c8058f --- /dev/null +++ b/simulationstateserializer.h @@ -0,0 +1,67 @@ +/* +This Source Code Form is subject to the +terms of the Mozilla Public License, v. +2.0. If a copy of the MPL was not +distributed with this file, You can +obtain one at +http://mozilla.org/MPL/2.0/. +*/ + +#pragma once + +#include "parser.h" +#include "scene.h" + +namespace simulation { + +class state_serializer { + +public: +// methods + // restores simulation data from specified file. returns: true on success, false otherwise + bool + deserialize( std::string const &Scenariofile ); + // stores class data in specified file, in legacy (text) format + void + export_as_text( std::string const &Scenariofile ) const; + +private: +// methods + // restores class data from provided stream + void deserialize( cParser &Input, scene::scratch_data &Scratchpad ); + void deserialize_area( cParser &Input, scene::scratch_data &Scratchpad ); + void deserialize_atmo( cParser &Input, scene::scratch_data &Scratchpad ); + void deserialize_camera( cParser &Input, scene::scratch_data &Scratchpad ); + void deserialize_config( cParser &Input, scene::scratch_data &Scratchpad ); + void deserialize_description( cParser &Input, scene::scratch_data &Scratchpad ); + void deserialize_event( cParser &Input, scene::scratch_data &Scratchpad ); + void deserialize_firstinit( cParser &Input, scene::scratch_data &Scratchpad ); + void deserialize_group( cParser &Input, scene::scratch_data &Scratchpad ); + void deserialize_endgroup( cParser &Input, scene::scratch_data &Scratchpad ); + void deserialize_light( cParser &Input, scene::scratch_data &Scratchpad ); + void deserialize_node( cParser &Input, scene::scratch_data &Scratchpad ); + void deserialize_origin( cParser &Input, scene::scratch_data &Scratchpad ); + void deserialize_endorigin( cParser &Input, scene::scratch_data &Scratchpad ); + void deserialize_rotate( cParser &Input, scene::scratch_data &Scratchpad ); + void deserialize_sky( cParser &Input, scene::scratch_data &Scratchpad ); + void deserialize_test( cParser &Input, scene::scratch_data &Scratchpad ); + void deserialize_time( cParser &Input, scene::scratch_data &Scratchpad ); + void deserialize_trainset( cParser &Input, scene::scratch_data &Scratchpad ); + void deserialize_endtrainset( cParser &Input, scene::scratch_data &Scratchpad ); + TTrack * deserialize_path( cParser &Input, scene::scratch_data &Scratchpad, scene::node_data const &Nodedata ); + TTraction * deserialize_traction( cParser &Input, scene::scratch_data &Scratchpad, scene::node_data const &Nodedata ); + TTractionPowerSource * deserialize_tractionpowersource( cParser &Input, scene::scratch_data &Scratchpad, scene::node_data const &Nodedata ); + TMemCell * deserialize_memorycell( cParser &Input, scene::scratch_data &Scratchpad, scene::node_data const &Nodedata ); + TEventLauncher * deserialize_eventlauncher( cParser &Input, scene::scratch_data &Scratchpad, scene::node_data const &Nodedata ); + TAnimModel * deserialize_model( cParser &Input, scene::scratch_data &Scratchpad, scene::node_data const &Nodedata ); + TDynamicObject * deserialize_dynamic( cParser &Input, scene::scratch_data &Scratchpad, scene::node_data const &Nodedata ); + sound_source * deserialize_sound( cParser &Input, scene::scratch_data &Scratchpad, scene::node_data const &Nodedata ); + // skips content of stream until specified token + void skip_until( cParser &Input, std::string const &Token ); + // transforms provided location by specifed rotation and offset + glm::dvec3 transform( glm::dvec3 Location, scene::scratch_data const &Scratchpad ); +}; + +} // simulation + +//--------------------------------------------------------------------------- diff --git a/simulationtime.cpp b/simulationtime.cpp new file mode 100644 index 00000000..80994b5e --- /dev/null +++ b/simulationtime.cpp @@ -0,0 +1,192 @@ +/* +This Source Code Form is subject to the +terms of the Mozilla Public License, v. +2.0. If a copy of the MPL was not +distributed with this file, You can +obtain one at +http://mozilla.org/MPL/2.0/. +*/ + +#include "stdafx.h" +#include "simulationtime.h" + +#include "globals.h" +#include "utilities.h" + +namespace simulation { + +scenario_time Time; + +} // simulation + +void +scenario_time::init() { + + char monthdaycounts[ 2 ][ 13 ] = { + { 0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 }, + { 0, 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 } }; + ::memcpy( m_monthdaycounts, monthdaycounts, sizeof( monthdaycounts ) ); + + // potentially adjust scenario clock + auto const requestedtime { clamp_circular( m_time.wHour * 60 + m_time.wMinute + Global.ScenarioTimeOffset * 60, 24 * 60 ) }; + auto const requestedhour { ( requestedtime / 60 ) % 24 }; + auto const requestedminute { requestedtime % 60 }; + // cache requested elements, if any + ::GetLocalTime( &m_time ); + + if( Global.fMoveLight > 0.0 ) { + // day and month of the year can be overriden by scenario setup + daymonth( m_time.wDay, m_time.wMonth, m_time.wYear, static_cast( Global.fMoveLight ) ); + } + + if( requestedhour != -1 ) { m_time.wHour = static_cast( clamp( requestedhour, 0, 23 ) ); } + if( requestedminute != -1 ) { m_time.wMinute = static_cast( clamp( requestedminute, 0, 59 ) ); } + // if the time is taken from the local clock leave the seconds intact, otherwise set them to zero + if( ( requestedhour != -1 ) + || ( requestedminute != 1 ) ) { + m_time.wSecond = 0; + } + + m_yearday = year_day( m_time.wDay, m_time.wMonth, m_time.wYear ); + + // calculate time zone bias + // retrieve relevant time zone info from system registry (or fall back on supplied default) + // TODO: select timezone matching defined geographic location and/or country + struct registry_time_zone_info { + long Bias; + long StandardBias; + long DaylightBias; + SYSTEMTIME StandardDate; + SYSTEMTIME DaylightDate; + } registrytimezoneinfo = { -60, 0, -60, { 0, 10, 0, 5, 3, 0, 0, 0 }, { 0, 3, 0, 5, 2, 0, 0, 0 } }; + +#ifdef _WIN32 + TCHAR timezonekeyname[] { TEXT( "SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Time Zones\\Central European Standard Time" ) }; + HKEY timezonekey { NULL }; + DWORD size { sizeof( registrytimezoneinfo ) }; + if( ::RegOpenKeyEx( HKEY_LOCAL_MACHINE, timezonekeyname, 0, KEY_QUERY_VALUE, &timezonekey ) == ERROR_SUCCESS ) { + ::RegQueryValueEx( timezonekey, "TZI", NULL, NULL, (BYTE *)®istrytimezoneinfo, &size ); + } +#endif + TIME_ZONE_INFORMATION timezoneinfo { 0 }; + timezoneinfo.Bias = registrytimezoneinfo.Bias; + timezoneinfo.DaylightBias = registrytimezoneinfo.DaylightBias; + timezoneinfo.DaylightDate = registrytimezoneinfo.DaylightDate; + timezoneinfo.StandardBias = registrytimezoneinfo.StandardBias; + timezoneinfo.StandardDate = registrytimezoneinfo.StandardDate; + + auto zonebias { timezoneinfo.Bias }; + if( m_yearday < year_day( timezoneinfo.DaylightDate.wDay, timezoneinfo.DaylightDate.wMonth, m_time.wYear ) ) { + zonebias += timezoneinfo.StandardBias; + } + else if( m_yearday < year_day( timezoneinfo.StandardDate.wDay, timezoneinfo.StandardDate.wMonth, m_time.wYear ) ) { + zonebias += timezoneinfo.DaylightBias; + } + else { + zonebias += timezoneinfo.StandardBias; + } + + m_timezonebias = ( zonebias / 60.0 ); +} + +void +scenario_time::update( double const Deltatime ) { + + m_milliseconds += ( 1000.0 * Deltatime ); + while( m_milliseconds >= 1000.0 ) { + + ++m_time.wSecond; + m_milliseconds -= 1000.0; + } + m_time.wMilliseconds = std::floor( m_milliseconds ); + while( m_time.wSecond >= 60 ) { + + ++m_time.wMinute; + m_time.wSecond -= 60; + } + while( m_time.wMinute >= 60 ) { + + ++m_time.wHour; + m_time.wMinute -= 60; + } + while( m_time.wHour >= 24 ) { + + ++m_time.wDay; + ++m_time.wDayOfWeek; + if( m_time.wDayOfWeek >= 7 ) { + m_time.wDayOfWeek -= 7; + } + m_time.wHour -= 24; + } + int leap = ( m_time.wYear % 4 == 0 ) && ( m_time.wYear % 100 != 0 ) || ( m_time.wYear % 400 == 0 ); + while( m_time.wDay > m_monthdaycounts[ leap ][ m_time.wMonth ] ) { + + m_time.wDay -= m_monthdaycounts[ leap ][ m_time.wMonth ]; + ++m_time.wMonth; + // unlikely but we might've entered a new year + if( m_time.wMonth > 12 ) { + + ++m_time.wYear; + leap = ( m_time.wYear % 4 == 0 ) && ( m_time.wYear % 100 != 0 ) || ( m_time.wYear % 400 == 0 ); + m_time.wMonth -= 12; + } + } +} + +int +scenario_time::year_day( int Day, const int Month, const int Year ) const { + + char const daytab[ 2 ][ 13 ] = { + { 0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 }, + { 0, 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 } + }; + + int leap { ( Year % 4 == 0 ) && ( Year % 100 != 0 ) || ( Year % 400 == 0 ) }; + for( int i = 1; i < Month; ++i ) + Day += daytab[ leap ][ i ]; + + return Day; +} + +void +scenario_time::daymonth( WORD &Day, WORD &Month, WORD const Year, WORD const Yearday ) { + + WORD daytab[ 2 ][ 13 ] = { + { 0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334, 365 }, + { 0, 31, 60, 91, 121, 152, 182, 213, 244, 274, 305, 335, 366 } + }; + + int leap = ( Year % 4 == 0 ) && ( Year % 100 != 0 ) || ( Year % 400 == 0 ); + WORD idx = 1; + while( ( idx < 13 ) && ( Yearday >= daytab[ leap ][ idx ] ) ) { + + ++idx; + } + Month = idx; + Day = Yearday - daytab[ leap ][ idx - 1 ]; +} + +int +scenario_time::julian_day() const { + + int yy = ( m_time.wYear < 0 ? m_time.wYear + 1 : m_time.wYear ) - std::floor( ( 12 - m_time.wMonth ) / 10.f ); + int mm = m_time.wMonth + 9; + if( mm >= 12 ) { mm -= 12; } + + int K1 = std::floor( 365.25 * ( yy + 4712 ) ); + int K2 = std::floor( 30.6 * mm + 0.5 ); + + // for dates in Julian calendar + int JD = K1 + K2 + m_time.wDay + 59; + // for dates in Gregorian calendar; 2299160 is October 15th, 1582 + const int gregorianswitchday = 2299160; + if( JD > gregorianswitchday ) { + + int K3 = std::floor( std::floor( ( yy * 0.01 ) + 49 ) * 0.75 ) - 38; + JD -= K3; + } + + return JD; +} + +//--------------------------------------------------------------------------- diff --git a/simulationtime.h b/simulationtime.h new file mode 100644 index 00000000..069a66ca --- /dev/null +++ b/simulationtime.h @@ -0,0 +1,66 @@ +/* +This Source Code Form is subject to the +terms of the Mozilla Public License, v. +2.0. If a copy of the MPL was not +distributed with this file, You can +obtain one at +http://mozilla.org/MPL/2.0/. +*/ + +#pragma once + +// wrapper for scenario time +class scenario_time { + +public: + scenario_time() { + m_time.wHour = 10; m_time.wMinute = 30; } + void + init(); + void + update( double const Deltatime ); + inline + SYSTEMTIME & + data() { + return m_time; } + inline + SYSTEMTIME const & + data() const { + return m_time; } + inline + double + second() const { + return ( m_time.wMilliseconds * 0.001 + m_time.wSecond ); } + inline + int + year_day() const { + return m_yearday; } + // helper, calculates day of year from given date + int + year_day( int Day, int const Month, int const Year ) const; + int + julian_day() const; + inline + double + zone_bias() const { + return m_timezonebias; } + +private: + // calculates day and month from given day of year + void + daymonth( WORD &Day, WORD &Month, WORD const Year, WORD const Yearday ); + + SYSTEMTIME m_time; + double m_milliseconds{ 0.0 }; + int m_yearday; + char m_monthdaycounts[ 2 ][ 13 ]; + double m_timezonebias{ 0.0 }; +}; + +namespace simulation { + +extern scenario_time Time; + +} // simulation + +//--------------------------------------------------------------------------- diff --git a/sky.cpp b/sky.cpp index fd622f47..42a57cac 100644 --- a/sky.cpp +++ b/sky.cpp @@ -9,51 +9,18 @@ http://mozilla.org/MPL/2.0/. #include "stdafx.h" #include "sky.h" -#include "Logs.h" #include "Globals.h" #include "MdlMngr.h" //--------------------------------------------------------------------------- -GLfloat lightPos[4] = {0.0f, 0.0f, 0.0f, 1.0f}; +//GLfloat lightPos[4] = {0.0f, 0.0f, 0.0f, 1.0f}; -TSky::~TSky(){}; +void TSky::Init() { -TSky::TSky(){}; + if( ( Global.asSky != "1" ) + && ( Global.asSky != "0" ) ) { -void TSky::Init() -{ - WriteLog(Global::asSky.c_str()); - WriteLog("init"); - if ((Global::asSky != "1") && (Global::asSky != "0")) - // { - mdCloud = TModelsManager::GetModel(Global::asSky.c_str()); - // } -}; - -void TSky::Render() -{ - if (mdCloud) - { // jeśli jest model nieba - glPushMatrix(); - // glDisable(GL_DEPTH_TEST); - glTranslatef(Global::pCameraPosition.x, Global::pCameraPosition.y, - Global::pCameraPosition.z); - glLightfv(GL_LIGHT0, GL_POSITION, lightPos); - if (Global::bUseVBO) - { // renderowanie z VBO - mdCloud->RaRender(100, 0); - mdCloud->RaRenderAlpha(100, 0); - } - else - { // renderowanie z Display List - mdCloud->Render(100, 0); - mdCloud->RenderAlpha(100, 0); - } - // glEnable(GL_DEPTH_TEST); - glClear(GL_DEPTH_BUFFER_BIT); - // glEnable(GL_LIGHTING); - glPopMatrix(); - glLightfv(GL_LIGHT0, GL_POSITION, Global::lightPos); + mdCloud = TModelsManager::GetModel( Global.asSky ); } }; diff --git a/sky.h b/sky.h index 709c2887..571b7aa6 100644 --- a/sky.h +++ b/sky.h @@ -10,18 +10,19 @@ http://mozilla.org/MPL/2.0/. #pragma once -#include "Model3d.h" +#include "classes.h" -class TSky -{ - private: - TModel3d *mdCloud; +class TSky { + + friend opengl_renderer; + +public: + TSky() = default; - public: - TSky(); - ~TSky(); void Init(); - void Render(); + +private: + TModel3d *mdCloud { nullptr }; }; //--------------------------------------------------------------------------- diff --git a/skydome.cpp b/skydome.cpp new file mode 100644 index 00000000..020ead60 --- /dev/null +++ b/skydome.cpp @@ -0,0 +1,363 @@ + +#include "stdafx.h" +#include "skydome.h" +#include "color.h" +#include "utilities.h" + +// sky gradient based on "A practical analytic model for daylight" +// by A. J. Preetham Peter Shirley Brian Smits (University of Utah) + +float CSkyDome::m_distributionluminance[ 5 ][ 2 ] = { // Perez distributions + { 0.17872f , -1.46303f }, // a = darkening or brightening of the horizon + { -0.35540f , 0.42749f }, // b = luminance gradient near the horizon, + { -0.02266f , 5.32505f }, // c = relative intensity of the circumsolar region + { 0.12064f , -2.57705f }, // d = width of the circumsolar region + { -0.06696f , 0.37027f } // e = relative backscattered light + }; +float CSkyDome::m_distributionxcomp[ 5 ][ 2 ] = { + { -0.01925f , -0.25922f }, + { -0.06651f , 0.00081f }, + { -0.00041f , 0.21247f }, + { -0.06409f , -0.89887f }, + { -0.00325f , 0.04517f } + }; +float CSkyDome::m_distributionycomp[ 5 ][ 2 ] = { + { -0.01669f , -0.26078f }, + { -0.09495f , 0.00921f }, + { -0.00792f , 0.21023f }, + { -0.04405f , -1.65369f }, + { -0.01092f , 0.05291f } + }; + +float CSkyDome::m_zenithxmatrix[ 3 ][ 4 ] = { + { 0.00165f, -0.00375f, 0.00209f, 0.00000f }, + { -0.02903f, 0.06377f, -0.03202f, 0.00394f }, + { 0.11693f, -0.21196f, 0.06052f, 0.25886f } + }; +float CSkyDome::m_zenithymatrix[ 3 ][ 4 ] = { + { 0.00275f, -0.00610f, 0.00317f, 0.00000f }, + { -0.04214f, 0.08970f, -0.04153f, 0.00516f }, + { 0.15346f, -0.26756f, 0.06670f, 0.26688f } + }; + +//******************************************************************************// + +CSkyDome::CSkyDome (int const Tesselation) : + m_tesselation( Tesselation ) { + +// SetSunPosition( Math3D::vector3(75.0f, 0.0f, 0.0f) ); + SetTurbidity( 3.0f ); + SetExposure( true, 20.0f ); + SetOvercastFactor( 0.05f ); + SetGammaCorrection( 2.2f ); + Generate(); +} + +CSkyDome::~CSkyDome() { +} + +//******************************************************************************// + +void CSkyDome::Generate() { + // radius of dome + float const radius = 1.0f; + float const offset = 0.1f * radius; // horizontal offset, a cheap way to prevent a gap between ground and horizon + + // create geometry chunk + int const latitudes = m_tesselation / 2 / 2; // half-sphere only + int const longitudes = m_tesselation; + + std::uint16_t index = 0; + + for( int i = 0; i <= latitudes; ++i ) { + + float const latitude = M_PI * ( -0.5f + (float)( i ) / latitudes / 2 ); // half-sphere only + float const z = std::sin( latitude ); + float const zr = std::cos( latitude ); + + for( int j = 0; j <= longitudes; ++j ) { + + float const longitude = 2.0 * M_PI * (float)( j ) / longitudes; + float const x = std::cos( longitude ); + float const y = std::sin( longitude ); +/* + m_vertices.emplace_back( float3( x * zr, y * zr - offset, z ) * radius ); + // we aren't using normals, but the code is left here in case it's ever needed +// m_normals.emplace_back( float3( x * zr, -y * zr, -z ) ); +*/ + // cartesian to opengl swap: -x, -z, -y + m_vertices.emplace_back( glm::vec3( -x * zr, -z - offset, -y * zr ) * radius ); + m_colours.emplace_back( glm::vec3( 0.75f, 0.75f, 0.75f ) ); // placeholder + + if( (i == 0) || (j == 0) ) { + // initial edge of the dome, don't start indices yet + ++index; + } + else { + // indices for two triangles, formed between current and previous latitude + m_indices.emplace_back( index - 1 - (longitudes + 1) ); + m_indices.emplace_back( index - 1 ); + m_indices.emplace_back( index ); + m_indices.emplace_back( index ); + m_indices.emplace_back( index - ( longitudes + 1 ) ); + m_indices.emplace_back( index - 1 - ( longitudes + 1 ) ); + ++index; + } + } + } +} + +void CSkyDome::Update( glm::vec3 const &Sun ) { + + if( true == SetSunPosition( Sun ) ) { + // build colors if there's a change in sun position + RebuildColors(); + } +} + +// render skydome to screen +void CSkyDome::Render() { + + // cache entry state + ::glPushClientAttrib( GL_CLIENT_VERTEX_ARRAY_BIT ); + + if( m_vertexbuffer == -1 ) { + // build the buffers + ::glGenBuffers( 1, &m_vertexbuffer ); + ::glBindBuffer( GL_ARRAY_BUFFER, m_vertexbuffer ); + ::glBufferData( GL_ARRAY_BUFFER, m_vertices.size() * sizeof( glm::vec3 ), m_vertices.data(), GL_STATIC_DRAW ); + + ::glGenBuffers( 1, &m_coloursbuffer ); + ::glBindBuffer( GL_ARRAY_BUFFER, m_coloursbuffer ); + ::glBufferData( GL_ARRAY_BUFFER, m_colours.size() * sizeof( glm::vec3 ), m_colours.data(), GL_DYNAMIC_DRAW ); + + ::glGenBuffers( 1, &m_indexbuffer ); + ::glBindBuffer( GL_ELEMENT_ARRAY_BUFFER, m_indexbuffer ); + ::glBufferData( GL_ELEMENT_ARRAY_BUFFER, m_indices.size() * sizeof( unsigned short ), m_indices.data(), GL_STATIC_DRAW ); + // NOTE: vertex and index source data is superfluous past this point, but, eh + } + // begin + ::glEnableClientState( GL_VERTEX_ARRAY ); + ::glEnableClientState( GL_COLOR_ARRAY ); + // positions + ::glBindBuffer( GL_ARRAY_BUFFER, m_vertexbuffer ); + ::glVertexPointer( 3, GL_FLOAT, sizeof( glm::vec3 ), reinterpret_cast( 0 ) ); + // colours + ::glBindBuffer( GL_ARRAY_BUFFER, m_coloursbuffer ); + ::glColorPointer( 3, GL_FLOAT, sizeof( glm::vec3 ), reinterpret_cast( 0 ) ); + // indices + ::glBindBuffer( GL_ELEMENT_ARRAY_BUFFER, m_indexbuffer ); + ::glDrawElements( GL_TRIANGLES, static_cast( m_indices.size() ), GL_UNSIGNED_SHORT, reinterpret_cast( 0 ) ); + // cleanup + ::glPopClientAttrib(); +} + +bool CSkyDome::SetSunPosition( glm::vec3 const &Direction ) { + + if( Direction == m_sundirection ) { + + return false; + } + + m_sundirection = Direction; + m_thetasun = std::acosf( m_sundirection.y ); + m_phisun = std::atan2( m_sundirection.z, m_sundirection.x ); + + return true; +} + + +void CSkyDome::SetTurbidity( float const Turbidity ) { + + m_turbidity = clamp( Turbidity, 1.0f, 512.0f ); +} + +void CSkyDome::SetExposure( bool const Linearexposure, float const Expfactor ) { + + m_linearexpcontrol = Linearexposure; + m_expfactor = 1.0f / clamp( Expfactor, 1.0f, std::numeric_limits::infinity() ); +} + +void CSkyDome::SetGammaCorrection( float const Gamma ) { + + m_gammacorrection = 1.0f / clamp( Gamma, std::numeric_limits::epsilon(), std::numeric_limits::infinity() ); +} + +void CSkyDome::SetOvercastFactor( float const Overcast ) { + + m_overcast = clamp( Overcast, 0.0f, 1.0f ) * 0.75f; // going above 0.65 makes the model go pretty bad, appearance-wise +} + +void CSkyDome::GetPerez( float *Perez, float Distribution[ 5 ][ 2 ], const float Turbidity ) { + + Perez[ 0 ] = Distribution[ 0 ][ 0 ] * Turbidity + Distribution[ 0 ][ 1 ]; + Perez[ 1 ] = Distribution[ 1 ][ 0 ] * Turbidity + Distribution[ 1 ][ 1 ]; + Perez[ 2 ] = Distribution[ 2 ][ 0 ] * Turbidity + Distribution[ 2 ][ 1 ]; + Perez[ 3 ] = Distribution[ 3 ][ 0 ] * Turbidity + Distribution[ 3 ][ 1 ]; + Perez[ 4 ] = Distribution[ 4 ][ 0 ] * Turbidity + Distribution[ 4 ][ 1 ]; +} + +float CSkyDome::GetZenith( float Zenithmatrix[ 3 ][ 4 ], const float Theta, const float Turbidity ) { + + const float theta2 = Theta*Theta; + const float theta3 = Theta*theta2; + + return ( Zenithmatrix[0][0] * theta3 + Zenithmatrix[0][1] * theta2 + Zenithmatrix[0][2] * Theta + Zenithmatrix[0][3]) * Turbidity * Turbidity + + ( Zenithmatrix[1][0] * theta3 + Zenithmatrix[1][1] * theta2 + Zenithmatrix[1][2] * Theta + Zenithmatrix[1][3]) * Turbidity + + ( Zenithmatrix[2][0] * theta3 + Zenithmatrix[2][1] * theta2 + Zenithmatrix[2][2] * Theta + Zenithmatrix[2][3]); + +} + +float CSkyDome::PerezFunctionO1( float Perezcoeffs[ 5 ], const float Thetasun, const float Zenithval ) { + + const float val = ( 1.0f + Perezcoeffs[ 0 ] * std::exp( Perezcoeffs[ 1 ] ) ) * + ( 1.0f + Perezcoeffs[ 2 ] * std::exp( Perezcoeffs[ 3 ] * Thetasun ) + Perezcoeffs[ 4 ] * std::pow( std::cos( Thetasun ), 2 ) ); + + return Zenithval / val; +} + +float CSkyDome::PerezFunctionO2( float Perezcoeffs[ 5 ], const float Icostheta, const float Gamma, const float Cosgamma2, const float Zenithval ) { + // iCosTheta = 1.0f / cosf(theta) + // cosGamma2 = SQR( cosf( gamma ) ) + return Zenithval * ( 1.0f + Perezcoeffs[ 0 ] * std::exp( Perezcoeffs[ 1 ] * Icostheta ) ) * + ( 1.0f + Perezcoeffs[ 2 ] * std::exp( Perezcoeffs[ 3 ] * Gamma ) + Perezcoeffs[ 4 ] * Cosgamma2 ); +} + +void CSkyDome::RebuildColors() { + + // get zenith luminance + float const chi = ( (4.0f / 9.0f) - (m_turbidity / 120.0f) ) * ( M_PI - (2.0f * m_thetasun) ); + float zenithluminance = ( (4.0453f * m_turbidity) - 4.9710f ) * std::tan( chi ) - (0.2155f * m_turbidity) + 2.4192f; + + // get x / y zenith + float zenithx = GetZenith( m_zenithxmatrix, m_thetasun, m_turbidity ); + float zenithy = GetZenith( m_zenithymatrix, m_thetasun, m_turbidity ); + + // get perez function parametrs + float perezluminance[5], perezx[5], perezy[5]; + GetPerez( perezluminance, m_distributionluminance, m_turbidity ); + GetPerez( perezx, m_distributionxcomp, m_turbidity ); + GetPerez( perezy, m_distributionycomp, m_turbidity ); + + // make some precalculation + zenithx = PerezFunctionO1( perezx, m_thetasun, zenithx ); + zenithy = PerezFunctionO1( perezy, m_thetasun, zenithy ); + zenithluminance = PerezFunctionO1( perezluminance, m_thetasun, zenithluminance ); + + // start with fresh average for the new pass + glm::vec3 averagecolor, averagehorizoncolor; + + // trough all vertices + glm::vec3 vertex; + glm::vec3 color, colorconverter, shiftedcolor; + + for ( unsigned int i = 0; i < m_vertices.size(); ++i ) { + // grab it + vertex = glm::normalize( m_vertices[ i ] ); + + // angle between sun and vertex + const float gamma = std::acos( glm::dot( vertex, m_sundirection ) ); + + // warning : major hack!!! .. i had to do something with values under horizon + //vertex.y = Clamp( vertex.y, 0.05f, 1.0f ); + if ( vertex.y < 0.05f ) vertex.y = 0.05f; + +// from paper: +// const float theta = arccos( vertex.y ); +// const float iCosTheta = 1.0f / cosf( theta ); +// optimized: +// iCosTheta = +// = 1.0f / cosf( arccos( vertex.y ) ); +// = 1.0f / vertex.y; + float const icostheta = 1.0f / vertex.y; + float const cosgamma2 = std::pow( std::cos( gamma ), 2 ); + + // Compute x,y values + float const x = PerezFunctionO2( perezx, icostheta, gamma, cosgamma2, zenithx ); + float const y = PerezFunctionO2( perezy, icostheta, gamma, cosgamma2, zenithy ); + + // luminance(Y) for clear & overcast sky + float const yclear = std::max( 0.01f, PerezFunctionO2( perezluminance, icostheta, gamma, cosgamma2, zenithluminance ) ); + float const yover = std::max( 0.01f, zenithluminance * ( 1.0f + 2.0f * vertex.y ) / 3.0f ); + + float const Y = interpolate( yclear, yover, m_overcast ); + float const X = (x / y) * Y; + float const Z = ((1.0f - x - y) / y) * Y; + + colorconverter = glm::vec3( X, Y, Z ); + color = colors::XYZtoRGB( colorconverter ); + + colorconverter = colors::RGBtoHSV(color); + if ( m_linearexpcontrol ) { + // linear scale + colorconverter.z *= m_expfactor; + } else { + // exp scale + colorconverter.z = 1.0f - std::exp( -m_expfactor * colorconverter.z ); + } + + // desaturate sky colour, based on overcast level + if( colorconverter.y > 0.0f ) { + colorconverter.y *= ( 1.0f - m_overcast ); + } + + // override the hue, based on sun height above the horizon. crude way to deal with model shortcomings + // correction begins when the sun is higher than 10 degrees above the horizon, and fully in effect at 10+15 degrees + float const degreesabovehorizon = 90.0f - m_thetasun * ( 180.0f / M_PI ); + auto const sunbasedphase = clamp( (1.0f / 15.0f) * ( degreesabovehorizon - 10.0f ), 0.0f, 1.0f ); + // correction is applied in linear manner from the bottom, becomes fully in effect for vertices with y = 0.50 + auto const heightbasedphase = clamp( vertex.y * 2.0f, 0.0f, 1.0f ); + // this height-based factor is reduced the farther the sun is up in the sky + float const shiftfactor = clamp( interpolate(heightbasedphase, sunbasedphase, sunbasedphase), 0.0f, 1.0f ); + // h = 210 makes for 'typical' sky tone + shiftedcolor = glm::vec3( 210.0f, colorconverter.y, colorconverter.z ); + shiftedcolor = colors::HSVtoRGB( shiftedcolor ); + + color = colors::HSVtoRGB(colorconverter); + + color = interpolate( color, shiftedcolor, shiftfactor ); +/* + // gamma control + color.x = std::pow( color.x, m_gammacorrection ); + color.x = std::pow( color.y, m_gammacorrection ); + color.x = std::pow( color.z, m_gammacorrection ); +*/ + // crude correction for the times where the model breaks (late night) + // TODO: use proper night sky calculation for these times instead + if( ( color.x <= 0.05f ) + && ( color.y <= 0.05f ) ) { + // darken the sky as the sun goes deeper below the horizon + // 15:50:75 is picture-based night sky colour. it may not be accurate but looks 'right enough' + color.z = 0.75f * std::max( color.z + m_sundirection.y, 0.075f ); + color.x = 0.20f * color.z; + color.y = 0.65f * color.z; + color = color * ( 1.15f - vertex.y ); // simple gradient, darkening towards the top + } + // save + m_colours[ i ] = color; + averagecolor += color; + if( ( m_vertices.size() - i ) <= ( m_tesselation * 2 ) ) { + // calculate horizon colour from the bottom band of tris + averagehorizoncolor += color; + } + } + // NOTE: average reduced to 25% makes nice tint value for clouds lit from behind + // down the road we could interpolate between it and full strength average, to improve accuracy of cloud appearance + m_averagecolour = glm::max( glm::vec3(), averagecolor / static_cast( m_vertices.size() ) ); + m_averagehorizoncolour = glm::max( glm::vec3(), averagehorizoncolor / static_cast( m_tesselation * 2 ) ); + + if( m_coloursbuffer != -1 ) { + // the colour buffer was already initialized, so on this run we update its content + // cache entry state + ::glPushClientAttrib( GL_CLIENT_VERTEX_ARRAY_BIT ); + // begin + ::glEnableClientState( GL_VERTEX_ARRAY ); + // update + ::glBindBuffer( GL_ARRAY_BUFFER, m_coloursbuffer ); + ::glBufferSubData( GL_ARRAY_BUFFER, 0, m_colours.size() * sizeof( glm::vec3 ), m_colours.data() ); + // cleanup + ::glPopClientAttrib(); + } +} + +//******************************************************************************// diff --git a/skydome.h b/skydome.h new file mode 100644 index 00000000..9b867499 --- /dev/null +++ b/skydome.h @@ -0,0 +1,63 @@ +#pragma once + +// sky gradient based on "A practical analytic model for daylight" +// by A. J. Preetham Peter Shirley Brian Smits (University of Utah) + +class CSkyDome { +public: + CSkyDome( int const Tesselation = 54 ); + ~CSkyDome(); + void Generate(); + void RebuildColors(); + + bool SetSunPosition( glm::vec3 const &Direction ); + + void SetTurbidity( const float Turbidity = 5.0f ); + void SetExposure( const bool Linearexposure, const float Expfactor ); + void SetOvercastFactor( const float Overcast = 0.0f ); + void SetGammaCorrection( const float Gamma = 2.2f ); + + // update skydome + void Update( glm::vec3 const &Sun ); + // render skydome to screen + void Render(); + + // retrieves average colour of the sky dome + glm::vec3 GetAverageColor() { return m_averagecolour * 8.f / 6.f; } + glm::vec3 GetAverageHorizonColor() { return m_averagehorizoncolour; } + +private: + // shading parametrs + glm::vec3 m_sundirection; + float m_thetasun, m_phisun; + float m_turbidity; + bool m_linearexpcontrol; + float m_expfactor; + float m_overcast; + float m_gammacorrection; + glm::vec3 m_averagecolour; + glm::vec3 m_averagehorizoncolour; + + // data + int const m_tesselation; + std::vector m_vertices; + std::vector m_indices; +// std::vector m_normals; + std::vector m_colours; + GLuint m_vertexbuffer{ (GLuint)-1 }; + GLuint m_indexbuffer{ (GLuint)-1 }; + GLuint m_coloursbuffer{ (GLuint)-1 }; + + static float m_distributionluminance[ 5 ][ 2 ]; + static float m_distributionxcomp[ 5 ][ 2 ]; + static float m_distributionycomp[ 5 ][ 2 ]; + + static float m_zenithxmatrix[ 3 ][ 4 ]; + static float m_zenithymatrix[ 3 ][ 4 ]; + + // coloring + void GetPerez( float *Perez, float Distribution[ 5 ][ 2 ], const float Turbidity ); + float GetZenith( float Zenithmatrix[ 3 ][ 4 ], const float Theta, const float Turbidity ); + float PerezFunctionO1( float Perezcoeffs[ 5 ], const float Thetasun, const float Zenithval ); + float PerezFunctionO2( float Perezcoeffs[ 5 ], const float Icostheta, const float Gamma, const float Cosgamma2, const float Zenithval ); +}; diff --git a/sn_utils.cpp b/sn_utils.cpp new file mode 100644 index 00000000..9906d9c1 --- /dev/null +++ b/sn_utils.cpp @@ -0,0 +1,182 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public +* License, v. 2.0. If a copy of the MPL was not distributed with this +* file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +#include "stdafx.h" +#include "sn_utils.h" + +// sanity checks +static_assert(std::numeric_limits::is_iec559, "IEEE754 required"); +static_assert(sizeof(float) == 4, "Float must be 4 bytes"); +static_assert(sizeof(double) == 8, "Double must be 8 bytes"); +static_assert(-1 == ~0, "Two's complement required"); + +// deserialize little endian uint16 +uint16_t sn_utils::ld_uint16(std::istream &s) +{ + uint8_t buf[2]; + s.read((char*)buf, 2); + uint16_t v = (buf[1] << 8) | buf[0]; + return reinterpret_cast(v); +} + +// deserialize little endian uint32 +uint32_t sn_utils::ld_uint32(std::istream &s) +{ + uint8_t buf[4]; + s.read((char*)buf, 4); + uint32_t v = (buf[3] << 24) | (buf[2] << 16) | (buf[1] << 8) | buf[0]; + return reinterpret_cast(v); +} + +// deserialize little endian int32 +int32_t sn_utils::ld_int32(std::istream &s) +{ + uint8_t buf[4]; + s.read((char*)buf, 4); + uint32_t v = (buf[3] << 24) | (buf[2] << 16) | (buf[1] << 8) | buf[0]; + return reinterpret_cast(v); +} + +// deserialize little endian ieee754 float32 +float sn_utils::ld_float32(std::istream &s) +{ + uint8_t buf[4]; + s.read((char*)buf, 4); + uint32_t v = (buf[3] << 24) | (buf[2] << 16) | (buf[1] << 8) | buf[0]; + return reinterpret_cast(v); +} + +// deserialize little endian ieee754 float64 +double sn_utils::ld_float64(std::istream &s) +{ + uint8_t buf[8]; + s.read((char*)buf, 8); + uint64_t v = ((uint64_t)buf[7] << 56) | ((uint64_t)buf[6] << 48) | + ((uint64_t)buf[5] << 40) | ((uint64_t)buf[4] << 32) | + ((uint64_t)buf[3] << 24) | ((uint64_t)buf[2] << 16) | + ((uint64_t)buf[1] << 8) | (uint64_t)buf[0]; + return reinterpret_cast(v); +} + +// deserialize null-terminated string +std::string sn_utils::d_str(std::istream &s) +{ + std::string r; + r.reserve(32); + char buf[1]; + while (true) + { + s.read(buf, 1); + if (buf[0] == 0) + break; + r.push_back(buf[0]); + } + return r; +} + +bool sn_utils::d_bool(std::istream& s) +{ + return ( ld_uint16( s ) == 1 ); +} + +glm::dvec3 sn_utils::d_dvec3(std::istream& s) +{ + return { + ld_float64(s), + ld_float64(s), + ld_float64(s) }; +} + +glm::vec4 sn_utils::d_vec4( std::istream& s) +{ + return { + ld_float32(s), + ld_float32(s), + ld_float32(s), + ld_float32(s) }; +} + +void sn_utils::ls_uint16(std::ostream &s, uint16_t v) +{ + uint8_t buf[2]; + buf[0] = v; + buf[1] = v >> 8; + s.write((char*)buf, 2); +} + +void sn_utils::ls_uint32(std::ostream &s, uint32_t v) +{ + uint8_t buf[4]; + buf[0] = v; + buf[1] = v >> 8; + buf[2] = v >> 16; + buf[3] = v >> 24; + s.write((char*)buf, 4); +} + +void sn_utils::ls_int32(std::ostream &s, int32_t v) +{ + uint8_t buf[4]; + buf[0] = v; + buf[1] = v >> 8; + buf[2] = v >> 16; + buf[3] = v >> 24; + s.write((char*)buf, 4); +} + +void sn_utils::ls_float32(std::ostream &s, float t) +{ + uint32_t v = reinterpret_cast(t); + uint8_t buf[4]; + buf[0] = v; + buf[1] = v >> 8; + buf[2] = v >> 16; + buf[3] = v >> 24; + s.write((char*)buf, 4); +} + +void sn_utils::ls_float64(std::ostream &s, double t) +{ + uint64_t v = reinterpret_cast(t); + uint8_t buf[8]; + buf[0] = v; + buf[1] = v >> 8; + buf[2] = v >> 16; + buf[3] = v >> 24; + buf[4] = v >> 32; + buf[5] = v >> 40; + buf[6] = v >> 48; + buf[7] = v >> 56; + s.write((char*)buf, 8); +} + +void sn_utils::s_str(std::ostream &s, std::string v) +{ + const char* buf = v.c_str(); + s.write(buf, v.size() + 1); +} + +void sn_utils::s_bool(std::ostream &s, bool v) +{ + ls_uint16( + s, + ( true == v ? + 1 : + 0 ) ); +} + +void sn_utils::s_dvec3(std::ostream &s, glm::dvec3 const &v) +{ + ls_float64(s, v.x); + ls_float64(s, v.y); + ls_float64(s, v.z); +} + +void sn_utils::s_vec4(std::ostream &s, glm::vec4 const &v) +{ + ls_float32(s, v.x); + ls_float32(s, v.y); + ls_float32(s, v.z); + ls_float32(s, v.w); +} diff --git a/sn_utils.h b/sn_utils.h new file mode 100644 index 00000000..e11d1b31 --- /dev/null +++ b/sn_utils.h @@ -0,0 +1,29 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public +* License, v. 2.0. If a copy of the MPL was not distributed with this +* file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +#include + +class sn_utils +{ +public: + static uint16_t ld_uint16(std::istream&); + static uint32_t ld_uint32(std::istream&); + static int32_t ld_int32(std::istream&); + static float ld_float32(std::istream&); + static double ld_float64(std::istream&); + static std::string d_str(std::istream&); + static bool d_bool(std::istream&); + static glm::dvec3 d_dvec3(std::istream&); + static glm::vec4 d_vec4(std::istream&); + + static void ls_uint16(std::ostream&, uint16_t); + static void ls_uint32(std::ostream&, uint32_t); + static void ls_int32(std::ostream&, int32_t); + static void ls_float32(std::ostream&, float); + static void ls_float64(std::ostream&, double); + static void s_str(std::ostream&, std::string); + static void s_bool(std::ostream&, bool); + static void s_dvec3(std::ostream&, glm::dvec3 const &); + static void s_vec4(std::ostream&, glm::vec4 const &); +}; \ No newline at end of file diff --git a/sound.cpp b/sound.cpp new file mode 100644 index 00000000..3f349a1e --- /dev/null +++ b/sound.cpp @@ -0,0 +1,962 @@ +/* +This Source Code Form is subject to the +terms of the Mozilla Public License, v. +2.0. If a copy of the MPL was not +distributed with this file, You can +obtain one at +http://mozilla.org/MPL/2.0/. +*/ + +#include "stdafx.h" + +#include "sound.h" +#include "parser.h" +#include "globals.h" +#include "camera.h" +#include "train.h" +#include "dynobj.h" +#include "simulation.h" + +// constructors +sound_source::sound_source( sound_placement const Placement, float const Range ) : + m_placement( Placement ), + m_range( Range ) +{} + +// destructor +sound_source::~sound_source() { + + audio::renderer.erase( this ); +} + +// restores state of the class from provided data stream +sound_source & +sound_source::deserialize( std::string const &Input, sound_type const Legacytype, int const Legacyparameters ) { + + return deserialize( cParser{ Input }, Legacytype, Legacyparameters ); +} + +sound_source & +sound_source::deserialize( cParser &Input, sound_type const Legacytype, int const Legacyparameters, int const Chunkrange ) { + + // cache parser config, as it may change during deserialization + auto const inputautoclear { Input.autoclear() }; + + Input.getTokens( 1, true, "\n\r\t ,;" ); + if( Input.peek() == "{" ) { + // block type config + while( true == deserialize_mapping( Input ) ) { + ; // all work done by while() + } + + if( false == m_soundchunks.empty() ) { + // arrange loaded sound chunks in requested order + std::sort( + std::begin( m_soundchunks ), std::end( m_soundchunks ), + []( soundchunk_pair const &Left, soundchunk_pair const &Right ) { + return ( Left.second.threshold < Right.second.threshold ); } ); + // calculate and cache full range points for each chunk, including crossfade sections: + // on the far end the crossfade section extends to the threshold point of the next chunk... + for( std::size_t idx = 0; idx < m_soundchunks.size() - 1; ++idx ) { + m_soundchunks[ idx ].second.fadeout = m_soundchunks[ idx + 1 ].second.threshold; +/* + m_soundchunks[ idx ].second.fadeout = + interpolate( + m_soundchunks[ idx ].second.threshold, + m_soundchunks[ idx + 1 ].second.threshold, + m_crossfaderange * 0.01f ); +*/ + } + // ...and on the other end from the threshold point back into the range of previous chunk + m_soundchunks.front().second.fadein = std::max( 0, m_soundchunks.front().second.threshold ); +// m_soundchunks.front().second.fadein = m_soundchunks.front().second.threshold; + for( std::size_t idx = 1; idx < m_soundchunks.size(); ++idx ) { + auto const previouschunkwidth { m_soundchunks[ idx ].second.threshold - m_soundchunks[ idx - 1 ].second.threshold }; + m_soundchunks[ idx ].second.fadein = m_soundchunks[ idx ].second.threshold - 0.01f * m_crossfaderange * previouschunkwidth; +/* + m_soundchunks[ idx ].second.fadein = + interpolate( + m_soundchunks[ idx ].second.threshold, + m_soundchunks[ idx - 1 ].second.threshold, + m_crossfaderange * 0.01f ); +*/ + } + m_soundchunks.back().second.fadeout = std::max( Chunkrange, m_soundchunks.back().second.threshold ); +// m_soundchunks.back().second.fadeout = m_soundchunks.back().second.threshold; + // test if the chunk table contains any actual samples while at it + for( auto &soundchunk : m_soundchunks ) { + if( soundchunk.first.buffer != null_handle ) { + m_soundchunksempty = false; + break; + } + } + } + } + else { + // legacy type config + + // set the parser to preserve retrieved tokens, so we don't need to mess with separately passing the initial read + Input.autoclear( false ); + + switch( Legacytype ) { + case sound_type::single: { + // single sample only + m_sounds[ main ].buffer = audio::renderer.fetch_buffer( deserialize_random_set( Input, "\n\r\t ,;" ) ); + break; + } + case sound_type::multipart: { + // three samples: start, middle, stop + for( auto &sound : m_sounds ) { + sound.buffer = audio::renderer.fetch_buffer( deserialize_random_set( Input, "\n\r\t ,;" ) ); + } + break; + } + default: { + break; + } + } + + if( Legacyparameters & sound_parameters::range ) { + Input.getTokens( 1, false ); + Input >> m_range; + } + if( Legacyparameters & sound_parameters::amplitude ) { + Input.getTokens( 2, false ); + Input + >> m_amplitudefactor + >> m_amplitudeoffset; + } + if( Legacyparameters & sound_parameters::frequency ) { + Input.getTokens( 2, false ); + Input + >> m_frequencyfactor + >> m_frequencyoffset; + } + } + // restore parser behaviour + Input.autoclear( inputautoclear ); + + // catch and correct oddball cases with the same sample assigned as all parts of multipart sound + if( m_sounds[ begin ].buffer == m_sounds[ main ].buffer ) { + m_sounds[ begin ].buffer = null_handle; + } + if( m_sounds[ end ].buffer == m_sounds[ main ].buffer ) { + m_sounds[ end ].buffer = null_handle; + } + + return *this; +} + +// imports member data pair from the config file +bool +sound_source::deserialize_mapping( cParser &Input ) { + // token can be a key or block end + std::string const key { Input.getToken( true, "\n\r\t ,;[]" ) }; + + if( ( true == key.empty() ) || ( key == "}" ) ) { return false; } + + // if not block end then the key is followed by assigned value or sub-block + if( key == "soundmain:" ) { + sound( sound_id::main ).buffer = audio::renderer.fetch_buffer( deserialize_random_set( Input, "\n\r\t ,;" ) ); + } + else if( key == "soundset:" ) { + deserialize_soundset( Input ); + } + else if( key == "soundbegin:" ) { + sound( sound_id::begin ).buffer = audio::renderer.fetch_buffer( deserialize_random_set( Input, "\n\r\t ,;" ) ); + } + else if( key == "soundend:" ) { + sound( sound_id::end ).buffer = audio::renderer.fetch_buffer( deserialize_random_set( Input, "\n\r\t ,;" ) ); + } + else if( key.compare( 0, std::min( key.size(), 5 ), "sound" ) == 0 ) { + // sound chunks, defined with key soundX where X = activation threshold + auto const indexstart { key.find_first_of( "1234567890" ) }; + auto const indexend { key.find_first_not_of( "1234567890", indexstart ) }; + if( indexstart != std::string::npos ) { + // NOTE: we'll sort the chunks at the end of deserialization + m_soundchunks.emplace_back( + soundchunk_pair { + // sound data + { audio::renderer.fetch_buffer( deserialize_random_set( Input, "\n\r\t ,;" ) ), 0 }, + // chunk data + { std::stoi( key.substr( indexstart, indexend - indexstart ) ), 0, 0, 1.f } } ); + } + } + else if( key.compare( 0, std::min( key.size(), 5 ), "pitch" ) == 0 ) { + // sound chunk pitch, defined with key pitchX where X = activation threshold + auto const indexstart { key.find_first_of( "1234567890" ) }; + auto const indexend { key.find_first_not_of( "1234567890", indexstart ) }; + if( indexstart != std::string::npos ) { + auto const index { std::stoi( key.substr( indexstart, indexend - indexstart ) ) }; + auto const pitch { Input.getToken( false, "\n\r\t ,;" ) }; + for( auto &chunk : m_soundchunks ) { + if( chunk.second.threshold == index ) { + chunk.second.pitch = ( pitch > 0.f ? pitch : 1.f ); + break; + } + } + } + } + else if( key == "crossfade:" ) { + // for combined sounds, percentage of assigned range allocated to crossfade sections + Input.getTokens( 1, "\n\r\t ,;" ); + Input >> m_crossfaderange; + m_crossfaderange = clamp( m_crossfaderange, 0, 100 ); + } + else if( key == "placement:" ) { + auto const value { Input.getToken( true, "\n\r\t ,;" ) }; + std::map const placements { + { "internal", sound_placement::internal }, + { "engine", sound_placement::engine }, + { "external", sound_placement::external }, + { "general", sound_placement::general } }; + auto lookup{ placements.find( value ) }; + if( lookup != placements.end() ) { + m_placement = lookup->second; + } + } + else if( key == "offset:" ) { + // point in 3d space, in format [ x, y, z ] + Input.getTokens( 3, false, "\n\r\t ,;[]" ); + Input + >> m_offset.x + >> m_offset.y + >> m_offset.z; + } + else { + // floating point properties + std::map const properties { + { "frequencyfactor:", m_frequencyfactor }, + { "frequencyoffset:", m_frequencyoffset }, + { "amplitudefactor:", m_amplitudefactor }, + { "amplitudeoffset:", m_amplitudeoffset }, + { "range:", m_range } }; + + auto lookup { properties.find( key ) }; + if( lookup != properties.end() ) { + Input.getTokens( 1, false, "\n\r\t ,;" ); + Input >> lookup->second; + } + } + + return true; // return value marks a [ key: value ] pair was extracted, nothing about whether it's recognized +} + +// imports values for initial, main and ending sounds from provided data stream +void +sound_source::deserialize_soundset( cParser &Input ) { + + auto const soundset { deserialize_random_set( Input, "\n\r\t ,;" ) }; + // split retrieved set + cParser setparser( soundset ); + sound( sound_id::begin ).buffer = audio::renderer.fetch_buffer( setparser.getToken( true, "|" ) ); + sound( sound_id::main ).buffer = audio::renderer.fetch_buffer( setparser.getToken( true, "|" ) ); + sound( sound_id::end ).buffer = audio::renderer.fetch_buffer( setparser.getToken( true, "|" ) ); +} + +// sends content of the class in legacy (text) format to provided stream +// NOTE: currently exports only the main sound +void +sound_source::export_as_text( std::ostream &Output ) const { + + if( sound( sound_id::main ).buffer == null_handle ) { return; } + + // generic node header + Output + << "node " + // visibility + << m_range << ' ' + << 0 << ' ' + // name + << m_name << ' '; + // sound node header + Output + << "sound "; + // location + Output + << m_offset.x << ' ' + << m_offset.y << ' ' + << m_offset.z << ' '; + // sound data + auto soundfile { audio::renderer.buffer( sound( sound_id::main ).buffer ).name }; + if( soundfile.find( szSoundPath ) == 0 ) { + // don't include 'sounds/' in the path + soundfile.erase( 0, std::string{ szSoundPath }.size() ); + } + Output + << soundfile << ' '; + // footer + Output + << "endsound" + << "\n"; +} + +// copies list of sounds from provided source +sound_source & +sound_source::copy_sounds( sound_source const &Source ) { + + m_sounds = Source.m_sounds; + m_soundchunks = Source.m_soundchunks; + m_soundchunksempty = Source.m_soundchunksempty; + // reset source's playback counters + for( auto &sound : m_sounds ) { + sound.playing = 0; + } + for( auto &sound : m_soundchunks ) { + sound.first.playing = 0; + } + return *this; +} + +// issues contextual play commands for the audio renderer +void +sound_source::play( int const Flags ) { + + if( ( false == Global.bSoundEnabled ) + || ( true == empty() ) ) { + // if the sound is disabled altogether or nothing can be emitted from this source, no point wasting time + return; + } + + // NOTE: we cache the flags early, even if the sound is out of range, to mark activated event sounds + m_flags = Flags; + + if( m_range > 0 ) { + auto const cutoffrange { m_range * 5 }; + if( glm::length2( location() - glm::dvec3 { Global.pCamera.Pos } ) > std::min( 2750.f * 2750.f, cutoffrange * cutoffrange ) ) { + // while we drop sounds from beyond sensible and/or audible range + // we act as if it was activated normally, meaning no need to include the opening bookend in subsequent calls + m_playbeginning = false; + return; + } + } + + // initialize emitter-specific pitch variation if it wasn't yet set + if( m_pitchvariation == 0.f ) { + m_pitchvariation = 0.01f * static_cast( Random( 97.5, 102.5 ) ); + } +/* + if( ( ( m_flags & sound_flags::exclusive ) != 0 ) + && ( sound( sound_id::end ).playing > 0 ) ) { + // request termination of the optional ending bookend for single instance sounds + m_stopend = true; + } +*/ + if( sound( sound_id::main ).buffer != null_handle ) { + // basic variant: single main sound, with optional bookends + play_basic(); + } + else { + // combined variant, main sound consists of multiple chunks, with optional bookends + play_combined(); + } +} + +void +sound_source::play_basic() { + + if( false == is_playing() ) { + // dispatch appropriate sound + if( ( true == m_playbeginning ) + && ( sound( sound_id::begin ).buffer != null_handle ) ) { + std::vector sounds { sound_id::begin, sound_id::main }; + insert( std::begin( sounds ), std::end( sounds ) ); + m_playbeginning = false; + } + else { + insert( sound_id::main ); + } + } + else { + // for single part non-looping samples we allow spawning multiple instances, if not prevented by set flags + if( ( ( m_flags & ( sound_flags::exclusive | sound_flags::looping ) ) == 0 ) + && ( sound( sound_id::begin ).buffer == null_handle ) ) { + insert( sound_id::main ); + } + } +} + +void +sound_source::play_combined() { + // combined sound consists of table od samples, each sample associated with certain range of values of controlling variable + // current value of the controlling variable is passed to the source with pitch() call + auto const soundpoint { compute_combined_point() }; + for( std::uint32_t idx = 0; idx < m_soundchunks.size(); ++idx ) { + + auto const &soundchunk { m_soundchunks[ idx ] }; + // a chunk covers range from fade in point, where it starts rising in volume over crossfade distance, + // lasts until fadeout - crossfade distance point, past which it grows quiet until fade out point where it ends + if( soundpoint < soundchunk.second.fadein ) { break; } + if( soundpoint >= soundchunk.second.fadeout ) { continue; } + + if( ( soundchunk.first.buffer == null_handle ) + || ( ( ( m_flags & ( sound_flags::exclusive | sound_flags::looping ) ) != 0 ) + && ( soundchunk.first.playing > 0 ) ) ) { + // combined sounds only play looped, single copy of each activated chunk + continue; + } + + if( idx > 0 ) { + insert( sound_id::chunk | idx ); + } + else { + // initial chunk requires some safety checks if the optional bookend is present, + // so we don't queue another instance while the bookend is still playing + if( sound( sound_id::begin ).buffer == null_handle ) { + // no bookend, safe to play the chunk + insert( sound_id::chunk | idx ); + } + else { + // branches: + // beginning requested, not playing; queue beginning and chunk + // beginning not requested, not playing; queue chunk + // otherwise skip, one instance is already in the audio queue + if( sound( sound_id::begin ).playing == 0 ) { + if( true == m_playbeginning ) { + std::vector sounds{ sound_id::begin, sound_id::chunk | idx }; + insert( std::begin( sounds ), std::end( sounds ) ); + m_playbeginning = false; + } + else { + insert( sound_id::chunk | idx ); + } + } + } + } + } +} + +// calculates requested sound point, used to select specific sample from the sample table +float +sound_source::compute_combined_point() const { + + return ( + m_properties.pitch <= 1.f ? + // most sounds use 0-1 value range, we clamp these to 0-99 to allow more intuitive sound definition in .mmd files + clamp( m_properties.pitch, 0.f, 0.99f ) : + std::max( 0.f, m_properties.pitch ) + ) * 100.f; +} + +// maintains playback of sounds started by event +void +sound_source::play_event() { + + if( true == TestFlag( m_flags, ( sound_flags::event | sound_flags::looping ) ) ) { + // events can potentially start scenery sounds out of the sound's audible range + // such sounds are stopped on renderer side, but unless stopped by the simulation keep their activation flags + // we use this to discern event-started sounds which should be re-activated if the listener gets close enough + play( m_flags ); + } +} + +// stops currently active play commands controlled by this emitter +void +sound_source::stop( bool const Skipend ) { + + // if the source was stopped on simulation side, we should play the opening bookend next time it's activated + m_playbeginning = true; + // clear the event flags to discern between manual stop and out-of-range/sound-end stop + m_flags = 0; + + if( false == is_playing() ) { return; } + + m_stop = true; + + if( ( false == Skipend ) + && ( sound( sound_id::end ).buffer != null_handle ) +/* && ( sound( sound_id::end ).buffer != sound( sound_id::main ).buffer ) */ // end == main can happen in malformed legacy cases +/* && ( sound( sound_id::end ).playing == 0 ) */ ) { + // spawn potentially defined sound end sample, if the emitter is currently active + insert( sound_id::end ); + } +} + +// adjusts parameters of provided implementation-side sound source +void +sound_source::update( audio::openal_source &Source ) { + + if( sound( sound_id::main ).buffer != null_handle ) { + // basic variant: single main sound, with optional bookends + update_basic( Source ); + return; + } + if( false == m_soundchunksempty ) { + // combined variant, main sound consists of multiple chunks, with optional bookends + update_combined( Source ); + return; + } +} + +void +sound_source::update_basic( audio::openal_source &Source ) { + + if( true == Source.is_playing ) { + + auto const soundhandle { Source.sounds[ Source.sound_index ] }; + + if( sound( sound_id::begin ).buffer != null_handle ) { + // potentially a multipart sound + // detect the moment when the sound moves from startup sample to the main + if( true == Source.sound_change ) { + // when it happens update active sample counters, and potentially activate the looping + update_counter( sound_id::begin, -1 ); + update_counter( soundhandle, 1 ); + Source.loop( TestFlag( m_flags, sound_flags::looping ) ); + } + } + + if( ( true == m_stop ) + && ( soundhandle != sound_id::end ) ) { + // kill the sound if stop was requested, unless it's sound bookend sample + update_counter( soundhandle, -1 ); + Source.stop(); + m_stop = is_playing(); // end the stop mode when all active sounds are dead + return; + } +/* + if( ( true == m_stopend ) + && ( soundhandle == sound_id::end ) ) { + // kill the sound if it's the bookend sample and stopping it was requested + Source.stop(); + update_counter( sound_id::end, -1 ); + if( sound( sound_id::end ).playing == 0 ) { + m_stopend = false; + } + return; + } +*/ + // check and update if needed current sound properties + update_location(); + update_soundproofing(); + Source.sync_with( m_properties ); + if( Source.sync != sync_state::good ) { + // if the sync went wrong we let the renderer kill its part of the emitter, and update our playcounter(s) to match + update_counter( soundhandle, -1 ); + } + + } + else { + // if the emitter isn't playing it's either done or wasn't yet started + // we can determine this from number of processed buffers + if( Source.sound_index != Source.sounds.size() ) { + // the emitter wasn't yet started + auto const soundhandle { Source.sounds[ Source.sound_index ] }; + // emitter initialization + if( soundhandle == sound_id::main ) { + // main sample can be optionally set to loop + Source.loop( TestFlag( m_flags, sound_flags::looping ) ); + } + Source.range( m_range ); + Source.pitch( m_pitchvariation ); + update_location(); + update_soundproofing(); + Source.sync_with( m_properties ); + if( Source.sync == sync_state::good ) { + // all set, start playback + Source.play(); + if( false == Source.is_playing ) { + // if the playback didn't start update the state counter + update_counter( soundhandle, -1 ); + } + } + else { + // if the initial sync went wrong we skip the activation so the renderer can clean the emitter on its end + update_counter( soundhandle, -1 ); + } + } + else { + // the emitter is either all done or was terminated early + update_counter( Source.sounds[ Source.sound_index - 1 ], -1 ); + } + } +} + +void +sound_source::update_combined( audio::openal_source &Source ) { + + if( true == Source.is_playing ) { + + auto const soundhandle { Source.sounds[ Source.sound_index ] }; + + if( sound( sound_id::begin ).buffer != null_handle ) { + // potentially a multipart sound + // detect the moment when the sound moves from startup sample to the main + if( true == Source.sound_change ) { + // when it happens update active sample counters, and activate the looping + update_counter( sound_id::begin, -1 ); + update_counter( soundhandle, 1 ); + Source.loop( true ); + } + } + + if( ( true == m_stop ) + && ( soundhandle != sound_id::end ) ) { + // kill the sound if stop was requested, unless it's sound bookend sample + Source.stop(); + update_counter( soundhandle, -1 ); + if( false == is_playing() ) { + m_stop = false; + } + return; + } +/* + if( ( true == m_stopend ) + && ( soundhandle == sound_id::end ) ) { + // kill the sound if it's the bookend sample and stopping it was requested + Source.stop(); + update_counter( sound_id::end, -1 ); + if( sound( sound_id::end ).playing == 0 ) { + m_stopend = false; + } + return; + } +*/ + if( ( soundhandle & sound_id::chunk ) != 0 ) { + // for sound chunks, test whether the chunk should still be active given current value of the controlling variable + if( ( m_flags & ( sound_flags::exclusive | sound_flags::looping ) ) != 0 ) { + auto const soundpoint { compute_combined_point() }; + auto const &soundchunk { m_soundchunks[ soundhandle ^ sound_id::chunk ] }; + if( ( soundpoint < soundchunk.second.fadein ) + || ( soundpoint >= soundchunk.second.fadeout ) ) { + Source.stop(); + update_counter( soundhandle, -1 ); + return; + } + } + } + + // check and update if needed current sound properties + update_location(); + update_soundproofing(); + // pitch and volume are adjusted on per-chunk basis + // since they're relative to base values, backup these... + auto const baseproperties = m_properties; + // ...adjust per-chunk parameters... + update_crossfade( soundhandle ); + // ... pass the parameters to the audio renderer... + Source.sync_with( m_properties ); + if( Source.sync != sync_state::good ) { + // if the sync went wrong we let the renderer kill its part of the emitter, and update our playcounter(s) to match + update_counter( soundhandle, -1 ); + } + // ...and restore base properties + m_properties = baseproperties; + } + else { + // if the emitter isn't playing it's either done or wasn't yet started + // we can determine this from number of processed buffers + if( Source.sound_index != Source.sounds.size() ) { + // the emitter wasn't yet started + auto const soundhandle { Source.sounds[ Source.sound_index ] }; + // emitter initialization + if( ( soundhandle != sound_id::begin ) + && ( soundhandle != sound_id::end ) + && ( true == TestFlag( m_flags, sound_flags::looping ) ) ) { + // main sample can be optionally set to loop + Source.loop( true ); + } + Source.range( m_range ); + Source.pitch( m_pitchvariation ); + update_location(); + update_soundproofing(); + // pitch and volume are adjusted on per-chunk basis + auto const baseproperties = m_properties; + update_crossfade( soundhandle ); + Source.sync_with( m_properties ); + if( Source.sync == sync_state::good ) { + // all set, start playback + Source.play(); + if( false == Source.is_playing ) { + // if the playback didn't start update the state counter + update_counter( soundhandle, -1 ); + } + } + else { + // if the initial sync went wrong we skip the activation so the renderer can clean the emitter on its end + update_counter( soundhandle, -1 ); + } + m_properties = baseproperties; + } + else { + // the emitter is either all done or was terminated early + update_counter( Source.sounds[ Source.sound_index - 1 ], -1 ); + } + } +} + +void +sound_source::update_crossfade( sound_handle const Chunk ) { + + if( ( Chunk & sound_id::chunk ) == 0 ) { + // bookend sounds are played at their base pitch + m_properties.pitch = 1.f; + return; + } + + auto const soundpoint { compute_combined_point() }; + + // NOTE: direct access to implementation details ahead, kinda fugly + auto const chunkindex { Chunk ^ sound_id::chunk }; + auto const &chunkdata { m_soundchunks[ chunkindex ].second }; + + // relative pitch adjustment + // pitch of each chunk is modified based on ratio of the chunk's pitch to that of its neighbour + if( soundpoint < chunkdata.threshold ) { + + if( chunkindex > 0 ) { + // interpolate between the pitch of previous chunk and this chunk's base pitch, + // based on how far the current soundpoint is in the range of previous chunk + auto const &previouschunkdata{ m_soundchunks[ chunkindex - 1 ].second }; + m_properties.pitch = + interpolate( + previouschunkdata.pitch / chunkdata.pitch, + 1.f, + clamp( + ( soundpoint - previouschunkdata.threshold ) / ( chunkdata.threshold - previouschunkdata.threshold ), + 0.f, 1.f ) ); + } + } + else { + + if( chunkindex < ( m_soundchunks.size() - 1 ) ) { + // interpolate between this chunk's base pitch and the pitch of next chunk + // based on how far the current soundpoint is in the range of this chunk + auto const &nextchunkdata { m_soundchunks[ chunkindex + 1 ].second }; + m_properties.pitch = + interpolate( + 1.f, + nextchunkdata.pitch / chunkdata.pitch, + clamp( + ( soundpoint - chunkdata.threshold ) / ( nextchunkdata.threshold - chunkdata.threshold ), + 0.f, 1.f ) ); + } + else { + // pitch of the last (or the only) chunk remains fixed throughout + m_properties.pitch = 1.f; + } + } + // if there's no crossfade sections, our work is done + if( m_crossfaderange == 0 ) { return; } + + if( chunkindex > 0 ) { + // chunks other than the first can have fadein + auto const fadeinwidth { chunkdata.threshold - chunkdata.fadein }; + if( soundpoint < chunkdata.threshold ) { + m_properties.gain *= + interpolate( + 0.f, 1.f, + clamp( + ( soundpoint - chunkdata.fadein ) / fadeinwidth, + 0.f, 1.f ) ); + return; + } + } + if( chunkindex < ( m_soundchunks.size() - 1 ) ) { + // chunks other than the last can have fadeout + // TODO: cache widths in the chunk data struct? + // fadeout point of this chunk and activation threshold of the next are the same + // fadein range of the next chunk and the fadeout of the processed one are the same + auto const fadeoutwidth { chunkdata.fadeout - m_soundchunks[ chunkindex + 1 ].second.fadein }; + auto const fadeoutstart { chunkdata.fadeout - fadeoutwidth }; + if( soundpoint > fadeoutstart ) { + m_properties.gain *= + interpolate( + 1.f, 0.f, + clamp( + ( soundpoint - fadeoutstart ) / fadeoutwidth, + 0.f, 1.f ) ); + return; + } + } +} + +// sets base volume of the emiter to specified value +sound_source & +sound_source::gain( float const Gain ) { + + m_properties.gain = clamp( Gain, 0.f, 2.f ); + return *this; +} + +// returns current base volume of the emitter +float +sound_source::gain() const { + + return m_properties.gain; +} + +// sets base pitch of the emitter to specified value +sound_source & +sound_source::pitch( float const Pitch ) { + + m_properties.pitch = Pitch; + return *this; +} + +bool +sound_source::empty() const { + + // NOTE: we test only the main sound, won't bother playing potential bookends if this is missing + return ( ( sound( sound_id::main ).buffer == null_handle ) && ( m_soundchunksempty ) ); +} + +// returns true if the source is emitting any sound +bool +sound_source::is_playing( bool const Includesoundends ) const { + + auto isplaying { ( sound( sound_id::begin ).playing > 0 ) || ( sound( sound_id::main ).playing > 0 ) }; + if( ( false == isplaying ) + && ( false == m_soundchunks.empty() ) ) { + // for emitters with sample tables check also if any of the chunks is active + for( auto const &soundchunk : m_soundchunks ) { + if( soundchunk.first.playing > 0 ) { + isplaying = true; + break; // one will do + } + } + } + return isplaying; +} + +// returns true if the source uses sample table +bool +sound_source::is_combined() const { + + return ( ( !m_soundchunks.empty() ) && ( sound( sound_id::main ).buffer == null_handle ) ); +} + +// returns location of the sound source in simulation region space +glm::dvec3 const +sound_source::location() const { + + if( m_owner == nullptr ) { + // if emitter isn't attached to any vehicle the offset variable defines location in region space + return { m_offset }; + } + // otherwise combine offset with the location of the carrier + return { + m_owner->GetPosition() + + m_owner->VectorLeft() * m_offset.x + + m_owner->VectorUp() * m_offset.y + + m_owner->VectorFront() * m_offset.z }; +} + +// returns defined range of the sound +float const +sound_source::range() const { + + return m_range; +} + +void +sound_source::update_counter( sound_handle const Sound, int const Value ) { + +// sound( Sound ).playing = std::max( 0, sound( Sound ).playing + Value ); + sound( Sound ).playing += Value; + assert( sound( Sound ).playing >= 0 ); +} + +void +sound_source::update_location() { + + m_properties.location = location(); +} + +float const EU07_SOUNDPROOFING_STRONG { 0.25f }; +float const EU07_SOUNDPROOFING_SOME { 0.65f }; +float const EU07_SOUNDPROOFING_NONE { 1.f }; + +bool +sound_source::update_soundproofing() { + // NOTE, HACK: current cab id can vary from -1 to +1, and we use another higher priority value for open cab window + // we use this as modifier to force re-calculations when moving between compartments or changing window state + int const activecab = ( + Global.CabWindowOpen ? 2 : + FreeFlyModeFlag ? 0 : + ( simulation::Train ? + simulation::Train->Occupied()->ActiveCab : + 0 ) ); + // location-based gain factor: + std::uintptr_t soundproofingstamp = reinterpret_cast( ( + FreeFlyModeFlag ? + nullptr : + ( simulation::Train ? + simulation::Train->Dynamic() : + nullptr ) ) ) + + activecab; + + if( soundproofingstamp == m_properties.soundproofing_stamp ) { return false; } + + // listener location has changed, calculate new location-based gain factor + switch( m_placement ) { + case sound_placement::general: { + m_properties.soundproofing = EU07_SOUNDPROOFING_NONE; + break; + } + case sound_placement::external: { + m_properties.soundproofing = ( + ( ( soundproofingstamp == 0 ) || ( true == Global.CabWindowOpen ) ) ? + EU07_SOUNDPROOFING_NONE : // listener outside or has a window open + EU07_SOUNDPROOFING_STRONG ); // listener in a vehicle with windows shut + break; + } + case sound_placement::internal: { + m_properties.soundproofing = ( + soundproofingstamp == 0 ? + EU07_SOUNDPROOFING_STRONG : // listener outside HACK: won't be true if active vehicle has open window + ( simulation::Train->Dynamic() != m_owner ? + EU07_SOUNDPROOFING_STRONG : // in another vehicle + ( activecab == 0 ? + EU07_SOUNDPROOFING_STRONG : // listener in the engine compartment + EU07_SOUNDPROOFING_NONE ) ) ); // listener in the cab of the same vehicle + break; + } + case sound_placement::engine: { + m_properties.soundproofing = ( + ( ( soundproofingstamp == 0 ) || ( true == Global.CabWindowOpen ) ) ? + EU07_SOUNDPROOFING_SOME : // listener outside or has a window open + ( simulation::Train->Dynamic() != m_owner ? + EU07_SOUNDPROOFING_STRONG : // in another vehicle + ( activecab == 0 ? + EU07_SOUNDPROOFING_NONE : // listener in the engine compartment + EU07_SOUNDPROOFING_STRONG ) ) ); // listener in another compartment of the same vehicle + break; + } + default: { + // shouldn't ever land here, but, eh + m_properties.soundproofing = EU07_SOUNDPROOFING_NONE; + break; + } + } + + m_properties.soundproofing_stamp = soundproofingstamp; + return true; +} + +void +sound_source::insert( sound_handle const Sound ) { + + std::vector sounds { Sound }; + return insert( std::begin( sounds ), std::end( sounds ) ); +} + +sound_source::sound_data & +sound_source::sound( sound_handle const Sound ) { + + return ( + ( Sound & sound_id::chunk ) == sound_id::chunk ? + m_soundchunks[ Sound ^ sound_id::chunk ].first : + m_sounds[ Sound ] ); +} + +sound_source::sound_data const & +sound_source::sound( sound_handle const Sound ) const { + + return ( + ( Sound & sound_id::chunk ) == sound_id::chunk ? + m_soundchunks[ Sound ^ sound_id::chunk ].first : + m_sounds[ Sound ] ); +} + +//--------------------------------------------------------------------------- diff --git a/sound.h b/sound.h new file mode 100644 index 00000000..c1d012b7 --- /dev/null +++ b/sound.h @@ -0,0 +1,234 @@ +/* +This Source Code Form is subject to the +terms of the Mozilla Public License, v. +2.0. If a copy of the MPL was not +distributed with this file, You can +obtain one at +http://mozilla.org/MPL/2.0/. +*/ + +#pragma once + +#include "audiorenderer.h" +#include "classes.h" +#include "names.h" + +float const EU07_SOUND_GLOBALRANGE { -1.f }; +float const EU07_SOUND_CABCONTROLSCUTOFFRANGE { 7.5f }; +float const EU07_SOUND_BRAKINGCUTOFFRANGE { 100.f }; +float const EU07_SOUND_RUNNINGNOISECUTOFFRANGE { 200.f }; + +enum class sound_type { + single, + multipart +}; + +enum sound_parameters { + range = 0x1, + amplitude = 0x2, + frequency = 0x4 +}; + +enum sound_flags { + looping = 0x1, // the main sample will be looping + exclusive = 0x2, // the source won't dispatch more than one active instance of the sound + event = 0x80 // sound was activated by an event; we should keep note of the activation state for the update() calls it may receive +}; + +enum class sound_placement { + general, // source is equally audible in potential carrier and outside of it + internal, // source is located inside of the carrier, and less audible when the listener is outside + engine, // source is located in the engine compartment, less audible when the listener is outside and even less in the cabs + external // source is located on the outside of the carrier, and less audible when the listener is inside +}; + +// mini controller and audio dispatcher; issues play commands for the audio renderer, +// updates parameters of created audio emitters for the playback duration +// TODO: move to simulation namespace after clean up of owner classes +class sound_source { + +public: +// constructors + sound_source( sound_placement const Placement, float const Range = 50.f ); + +// destructor + ~sound_source(); + +// methods + // restores state of the class from provided data stream + sound_source & + deserialize( cParser &Input, sound_type const Legacytype, int const Legacyparameters = 0, int const Chunkrange = 100 ); + sound_source & + deserialize( std::string const &Input, sound_type const Legacytype, int const Legacyparameters = 0 ); + // sends content of the class in legacy (text) format to provided stream + void + export_as_text( std::ostream &Output ) const; + // copies list of sounds from provided source + sound_source & + copy_sounds( sound_source const &Source ); + // issues contextual play commands for the audio renderer + void + play( int const Flags = 0 ); + // maintains playback of sounds started by event + void + play_event(); + // stops currently active play commands controlled by this emitter + void + stop( bool const Skipend = false ); + // adjusts parameters of provided implementation-side sound source + void + update( audio::openal_source &Source ); + // sets base volume of the emiter to specified value + sound_source & + gain( float const Gain ); + // returns current base volume of the emitter + float + gain() const; + // sets base pitch of the emitter to specified value + sound_source & + pitch( float const Pitch ); + // owner setter/getter + void + owner( TDynamicObject const *Owner ); + TDynamicObject const * + owner() const; + // sound source offset setter/getter + void + offset( glm::vec3 const Offset ); + glm::vec3 const & + offset() const; + // sound source name setter/getter + void + name( std::string Name ); + std::string const & + name() const; + // returns true if there isn't any sound buffer associated with the object, false otherwise + bool + empty() const; + // returns true if the source is emitting any sound; by default doesn't take into account optional ending soudnds + bool + is_playing( bool const Includesoundends = false ) const; + // returns true if the source uses sample table + bool + is_combined() const; + // returns location of the sound source in simulation region space + glm::dvec3 const + location() const; + // returns defined range of the sound + float const + range() const; + +// members + float m_amplitudefactor { 1.f }; // helper, value potentially used by gain calculation + float m_amplitudeoffset { 0.f }; // helper, value potentially used by gain calculation + float m_frequencyfactor { 1.f }; // helper, value potentially used by pitch calculation + float m_frequencyoffset { 0.f }; // helper, value potentially used by pitch calculation + +private: +// types + struct sound_data { + audio::buffer_handle buffer; + int playing; // number of currently active sample instances + }; + + struct chunk_data { + int threshold; // nominal point of activation for the given chunk + float fadein; // actual activation point for the given chunk + float fadeout; // actual end point of activation range for the given chunk + float pitch; // base pitch of the chunk + }; + + using soundchunk_pair = std::pair; + + using sound_handle = std::uint32_t; + enum sound_id : std::uint32_t { + begin, + main, + end, + // 31 bits for index into relevant array, msb selects between the sample table and the basic array + chunk = ( 1u << 31 ) + }; + +// methods + // imports member data pair from the provided data stream + bool + deserialize_mapping( cParser &Input ); + // imports values for initial, main and ending sounds from provided data stream + void + deserialize_soundset( cParser &Input ); + // issues contextual play commands for the audio renderer + void + play_basic(); + void + play_combined(); + // calculates requested sound point, used to select specific sample from the sample table + float + compute_combined_point() const; + void + update_basic( audio::openal_source &Source ); + void + update_combined( audio::openal_source &Source ); + void + update_crossfade( sound_handle const Chunk ); + void + update_counter( sound_handle const Sound, int const Value ); + void + update_location(); + // potentially updates area-based gain factor of the source. returns: true if location has changed + bool + update_soundproofing(); + void + insert( sound_handle const Sound ); + template + void + insert( Iterator_ First, Iterator_ Last ) { + update_counter( *First, 1 ); + std::vector buffers; + uint32_sequence sounds; + std::for_each( + First, Last, + [&]( sound_handle const &soundhandle ) { + buffers.emplace_back( sound( soundhandle ).buffer ); + sounds.emplace_back( soundhandle ); } ); + audio::renderer.insert( std::begin( buffers ), std::end( buffers ), this, sounds ); } + sound_data & + sound( sound_handle const Sound ); + sound_data const & + sound( sound_handle const Sound ) const; + +// members + TDynamicObject const * m_owner { nullptr }; // optional, the vehicle carrying this sound source + glm::vec3 m_offset; // relative position of the source, either from the owner or the region centre + sound_placement m_placement; + float m_range { 50.f }; // audible range of the emitted sounds + std::string m_name; + int m_flags {}; // requested playback parameters + sound_properties m_properties; // current properties of the emitted sounds + float m_pitchvariation {}; // emitter-specific shift in base pitch + bool m_stop { false }; // indicates active sample instances should be terminated +/* + bool m_stopend { false }; // indicates active instances of optional ending sound should be terminated +*/ + bool m_playbeginning { true }; // indicates started sounds should be preceeded by opening bookend if there's one + std::array m_sounds { {} }; // basic sounds emitted by the source, main and optional bookends + std::vector m_soundchunks; // table of samples activated when associated variable is within certain range + bool m_soundchunksempty { true }; // helper, cached check whether sample table is linked with any actual samples + int m_crossfaderange {}; // range of transition from one chunk to another +}; + +// owner setter/getter +inline void sound_source::owner( TDynamicObject const *Owner ) { m_owner = Owner; } +inline TDynamicObject const * sound_source::owner() const { return m_owner; } +// sound source offset setter/getter +inline void sound_source::offset( glm::vec3 const Offset ) { m_offset = Offset; } +inline glm::vec3 const & sound_source::offset() const { return m_offset; } +// sound source name setter/getter +inline void sound_source::name( std::string Name ) { m_name = Name; } +inline std::string const & sound_source::name() const { return m_name; } + +// collection of sound sources present in the scene +class sound_table : public basic_table { + +}; + +//--------------------------------------------------------------------------- diff --git a/stars.cpp b/stars.cpp new file mode 100644 index 00000000..1f0b87ed --- /dev/null +++ b/stars.cpp @@ -0,0 +1,14 @@ + +#include "stdafx.h" +#include "stars.h" +#include "globals.h" +#include "MdlMngr.h" + +////////////////////////////////////////////////////////////////////////////////////////// +// cStars -- simple starfield model, simulating appearance of starry sky + +void +cStars::init() { + + m_stars = TModelsManager::GetModel( "skydome_stars.t3d", false ); +} diff --git a/stars.h b/stars.h new file mode 100644 index 00000000..a76973a9 --- /dev/null +++ b/stars.h @@ -0,0 +1,33 @@ +#pragma once + +#include "classes.h" + + +////////////////////////////////////////////////////////////////////////////////////////// +// cStars -- simple starfield model, simulating appearance of starry sky + +class cStars { + + friend opengl_renderer; + +public: +// types: + +// methods: + void init(); +// constructors: + cStars() = default; +// deconstructor: + +// members: + +private: +// types: + +// methods: + +// members: + float m_longitude{ 19.0f }; // geograpic coordinates hardcoded roughly to Poland location, for the time being + float m_latitude{ 52.0f }; + TModel3d *m_stars { nullptr }; +}; diff --git a/station.cpp b/station.cpp new file mode 100644 index 00000000..63b5b0a6 --- /dev/null +++ b/station.cpp @@ -0,0 +1,90 @@ +/* +This Source Code Form is subject to the +terms of the Mozilla Public License, v. +2.0. If a copy of the MPL was not +distributed with this file, You can +obtain one at +http://mozilla.org/MPL/2.0/. +*/ + +#include "stdafx.h" +#include "station.h" + +#include "dynobj.h" +#include "mtable.h" + +namespace simulation { + +basic_station Station; + +} + +// exchanges load with consist attached to specified vehicle, operating on specified schedule +double +basic_station::update_load( TDynamicObject *First, Mtable::TTrainParameters &Schedule, int const Platform ) { + + auto const firststop { Schedule.StationIndex == 1 }; + auto const laststop { Schedule.StationIndex == Schedule.StationCount }; + // HACK: determine whether current station is a (small) stop from the presence of "po" at the name end + auto const stationname { Schedule.TimeTable[ Schedule.StationIndex ].StationName }; + auto const stationequipment { Schedule.TimeTable[ Schedule.StationIndex ].StationWare }; + auto const trainstop { ( + ( ( stationname.size() >= 2 ) && ( stationname.substr( stationname.size() - 2 ) == "po" ) ) + || ( stationequipment.find( "po" ) != std::string::npos ) ) }; + // train stops exchange smaller groups than regular stations + // NOTE: this is crude and unaccurate, but for now will do + auto const stationsizemodifier { ( trainstop ? 1.0 : 2.0 ) }; + // go through all vehicles and update their load + // NOTE: for the time being we limit ourselves to passenger-carrying cars only + auto exchangetime { 0.f }; + // platform (1:left, 2:right, 3:both) + // with exchange performed on both sides waiting times are halved + auto const exchangetimemodifier { ( + Platform == 3 ? + 0.5f : + 1.0f ) }; + + auto *vehicle { First }; + while( vehicle != nullptr ) { + + auto ¶meters { *vehicle->MoverParameters }; + + if( parameters.LoadType.name.empty() ) { + // (try to) set the cargo type for empty cars + parameters.LoadAmount = 0.f; // safety measure against edge cases + parameters.AssignLoad( "passengers" ); + } + + if( parameters.LoadType.name == "passengers" ) { + // NOTE: for the time being we're doing simple, random load change calculation + // TODO: exchange driven by station parameters and time of the day + auto unloadcount = static_cast( + laststop ? parameters.LoadAmount : + firststop ? 0 : + std::min( + parameters.LoadAmount, + Random( parameters.MaxLoad * 0.10 * stationsizemodifier ) ) ); + auto loadcount = static_cast( + laststop ? + 0 : + Random( parameters.MaxLoad * 0.15f * stationsizemodifier ) ); + if( true == firststop ) { + // slightly larger group at the initial station + loadcount *= 2; + } + + if( ( unloadcount > 0 ) || ( loadcount > 0 ) ) { + + vehicle->LoadExchange( unloadcount, loadcount, Platform ); +/* + vehicle->LoadUpdate(); + vehicle->update_load_visibility(); +*/ + exchangetime = std::max( exchangetime, exchangetimemodifier * ( unloadcount / parameters.UnLoadSpeed + loadcount / parameters.LoadSpeed ) ); + } + } + vehicle = vehicle->Next(); + } + + return exchangetime; +} diff --git a/station.h b/station.h new file mode 100644 index 00000000..fca9d922 --- /dev/null +++ b/station.h @@ -0,0 +1,28 @@ +/* +This Source Code Form is subject to the +terms of the Mozilla Public License, v. +2.0. If a copy of the MPL was not +distributed with this file, You can +obtain one at +http://mozilla.org/MPL/2.0/. +*/ + +#pragma once + +#include "classes.h" + +// a simple station, performs freight and passenger exchanges with visiting consists +class basic_station { + +public: +// methods + // exchanges load with consist attached to specified vehicle, operating on specified schedule; returns: time needed for exchange, in seconds + double + update_load( TDynamicObject *First, Mtable::TTrainParameters &Schedule, int const Platform ); +}; + +namespace simulation { + +extern basic_station Station; // temporary object, for station functionality tests + +} // simulation diff --git a/stb_vorbis.c b/stb_vorbis.c new file mode 100644 index 00000000..69a23bca --- /dev/null +++ b/stb_vorbis.c @@ -0,0 +1,5462 @@ +// Ogg Vorbis audio decoder - v1.14 - public domain +// http://nothings.org/stb_vorbis/ +// +// Original version written by Sean Barrett in 2007. +// +// Originally sponsored by RAD Game Tools. Seeking implementation +// sponsored by Phillip Bennefall, Marc Andersen, Aaron Baker, +// Elias Software, Aras Pranckevicius, and Sean Barrett. +// +// LICENSE +// +// See end of file for license information. +// +// Limitations: +// +// - floor 0 not supported (used in old ogg vorbis files pre-2004) +// - lossless sample-truncation at beginning ignored +// - cannot concatenate multiple vorbis streams +// - sample positions are 32-bit, limiting seekable 192Khz +// files to around 6 hours (Ogg supports 64-bit) +// +// Feature contributors: +// Dougall Johnson (sample-exact seeking) +// +// Bugfix/warning contributors: +// Terje Mathisen Niklas Frykholm Andy Hill +// Casey Muratori John Bolton Gargaj +// Laurent Gomila Marc LeBlanc Ronny Chevalier +// Bernhard Wodo Evan Balster alxprd@github +// Tom Beaumont Ingo Leitgeb Nicolas Guillemot +// Phillip Bennefall Rohit Thiago Goulart +// manxorist@github saga musix github:infatum +// Timur Gagiev +// +// Partial history: +// 1.14 - 2018-02-11 - delete bogus dealloca usage +// 1.13 - 2018-01-29 - fix truncation of last frame (hopefully) +// 1.12 - 2017-11-21 - limit residue begin/end to blocksize/2 to avoid large temp allocs in bad/corrupt files +// 1.11 - 2017-07-23 - fix MinGW compilation +// 1.10 - 2017-03-03 - more robust seeking; fix negative ilog(); clear error in open_memory +// 1.09 - 2016-04-04 - back out 'truncation of last frame' fix from previous version +// 1.08 - 2016-04-02 - warnings; setup memory leaks; truncation of last frame +// 1.07 - 2015-01-16 - fixes for crashes on invalid files; warning fixes; const +// 1.06 - 2015-08-31 - full, correct support for seeking API (Dougall Johnson) +// some crash fixes when out of memory or with corrupt files +// fix some inappropriately signed shifts +// 1.05 - 2015-04-19 - don't define __forceinline if it's redundant +// 1.04 - 2014-08-27 - fix missing const-correct case in API +// 1.03 - 2014-08-07 - warning fixes +// 1.02 - 2014-07-09 - declare qsort comparison as explicitly _cdecl in Windows +// 1.01 - 2014-06-18 - fix stb_vorbis_get_samples_float (interleaved was correct) +// 1.0 - 2014-05-26 - fix memory leaks; fix warnings; fix bugs in >2-channel; +// (API change) report sample rate for decode-full-file funcs +// +// See end of file for full version history. + + +////////////////////////////////////////////////////////////////////////////// +// +// HEADER BEGINS HERE +// + +#ifndef STB_VORBIS_INCLUDE_STB_VORBIS_H +#define STB_VORBIS_INCLUDE_STB_VORBIS_H + +#if defined(STB_VORBIS_NO_CRT) && !defined(STB_VORBIS_NO_STDIO) +#define STB_VORBIS_NO_STDIO 1 +#endif + +#ifndef STB_VORBIS_NO_STDIO +#include +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +/////////// THREAD SAFETY + +// Individual stb_vorbis* handles are not thread-safe; you cannot decode from +// them from multiple threads at the same time. However, you can have multiple +// stb_vorbis* handles and decode from them independently in multiple thrads. + + +/////////// MEMORY ALLOCATION + +// normally stb_vorbis uses malloc() to allocate memory at startup, +// and alloca() to allocate temporary memory during a frame on the +// stack. (Memory consumption will depend on the amount of setup +// data in the file and how you set the compile flags for speed +// vs. size. In my test files the maximal-size usage is ~150KB.) +// +// You can modify the wrapper functions in the source (setup_malloc, +// setup_temp_malloc, temp_malloc) to change this behavior, or you +// can use a simpler allocation model: you pass in a buffer from +// which stb_vorbis will allocate _all_ its memory (including the +// temp memory). "open" may fail with a VORBIS_outofmem if you +// do not pass in enough data; there is no way to determine how +// much you do need except to succeed (at which point you can +// query get_info to find the exact amount required. yes I know +// this is lame). +// +// If you pass in a non-NULL buffer of the type below, allocation +// will occur from it as described above. Otherwise just pass NULL +// to use malloc()/alloca() + +typedef struct +{ + char *alloc_buffer; + int alloc_buffer_length_in_bytes; +} stb_vorbis_alloc; + + +/////////// FUNCTIONS USEABLE WITH ALL INPUT MODES + +typedef struct stb_vorbis stb_vorbis; + +typedef struct +{ + unsigned int sample_rate; + int channels; + + unsigned int setup_memory_required; + unsigned int setup_temp_memory_required; + unsigned int temp_memory_required; + + int max_frame_size; +} stb_vorbis_info; + +// get general information about the file +extern stb_vorbis_info stb_vorbis_get_info(stb_vorbis *f); + +// get the last error detected (clears it, too) +extern int stb_vorbis_get_error(stb_vorbis *f); + +// close an ogg vorbis file and free all memory in use +extern void stb_vorbis_close(stb_vorbis *f); + +// this function returns the offset (in samples) from the beginning of the +// file that will be returned by the next decode, if it is known, or -1 +// otherwise. after a flush_pushdata() call, this may take a while before +// it becomes valid again. +// NOT WORKING YET after a seek with PULLDATA API +extern int stb_vorbis_get_sample_offset(stb_vorbis *f); + +// returns the current seek point within the file, or offset from the beginning +// of the memory buffer. In pushdata mode it returns 0. +extern unsigned int stb_vorbis_get_file_offset(stb_vorbis *f); + +/////////// PUSHDATA API + +#ifndef STB_VORBIS_NO_PUSHDATA_API + +// this API allows you to get blocks of data from any source and hand +// them to stb_vorbis. you have to buffer them; stb_vorbis will tell +// you how much it used, and you have to give it the rest next time; +// and stb_vorbis may not have enough data to work with and you will +// need to give it the same data again PLUS more. Note that the Vorbis +// specification does not bound the size of an individual frame. + +extern stb_vorbis *stb_vorbis_open_pushdata( + const unsigned char * datablock, int datablock_length_in_bytes, + int *datablock_memory_consumed_in_bytes, + int *error, + const stb_vorbis_alloc *alloc_buffer); +// create a vorbis decoder by passing in the initial data block containing +// the ogg&vorbis headers (you don't need to do parse them, just provide +// the first N bytes of the file--you're told if it's not enough, see below) +// on success, returns an stb_vorbis *, does not set error, returns the amount of +// data parsed/consumed on this call in *datablock_memory_consumed_in_bytes; +// on failure, returns NULL on error and sets *error, does not change *datablock_memory_consumed +// if returns NULL and *error is VORBIS_need_more_data, then the input block was +// incomplete and you need to pass in a larger block from the start of the file + +extern int stb_vorbis_decode_frame_pushdata( + stb_vorbis *f, + const unsigned char *datablock, int datablock_length_in_bytes, + int *channels, // place to write number of float * buffers + float ***output, // place to write float ** array of float * buffers + int *samples // place to write number of output samples + ); +// decode a frame of audio sample data if possible from the passed-in data block +// +// return value: number of bytes we used from datablock +// +// possible cases: +// 0 bytes used, 0 samples output (need more data) +// N bytes used, 0 samples output (resynching the stream, keep going) +// N bytes used, M samples output (one frame of data) +// note that after opening a file, you will ALWAYS get one N-bytes,0-sample +// frame, because Vorbis always "discards" the first frame. +// +// Note that on resynch, stb_vorbis will rarely consume all of the buffer, +// instead only datablock_length_in_bytes-3 or less. This is because it wants +// to avoid missing parts of a page header if they cross a datablock boundary, +// without writing state-machiney code to record a partial detection. +// +// The number of channels returned are stored in *channels (which can be +// NULL--it is always the same as the number of channels reported by +// get_info). *output will contain an array of float* buffers, one per +// channel. In other words, (*output)[0][0] contains the first sample from +// the first channel, and (*output)[1][0] contains the first sample from +// the second channel. + +extern void stb_vorbis_flush_pushdata(stb_vorbis *f); +// inform stb_vorbis that your next datablock will not be contiguous with +// previous ones (e.g. you've seeked in the data); future attempts to decode +// frames will cause stb_vorbis to resynchronize (as noted above), and +// once it sees a valid Ogg page (typically 4-8KB, as large as 64KB), it +// will begin decoding the _next_ frame. +// +// if you want to seek using pushdata, you need to seek in your file, then +// call stb_vorbis_flush_pushdata(), then start calling decoding, then once +// decoding is returning you data, call stb_vorbis_get_sample_offset, and +// if you don't like the result, seek your file again and repeat. +#endif + + +////////// PULLING INPUT API + +#ifndef STB_VORBIS_NO_PULLDATA_API +// This API assumes stb_vorbis is allowed to pull data from a source-- +// either a block of memory containing the _entire_ vorbis stream, or a +// FILE * that you or it create, or possibly some other reading mechanism +// if you go modify the source to replace the FILE * case with some kind +// of callback to your code. (But if you don't support seeking, you may +// just want to go ahead and use pushdata.) + +#if !defined(STB_VORBIS_NO_STDIO) && !defined(STB_VORBIS_NO_INTEGER_CONVERSION) +extern int stb_vorbis_decode_filename(const char *filename, int *channels, int *sample_rate, short **output); +#endif +#if !defined(STB_VORBIS_NO_INTEGER_CONVERSION) +extern int stb_vorbis_decode_memory(const unsigned char *mem, int len, int *channels, int *sample_rate, short **output); +#endif +// decode an entire file and output the data interleaved into a malloc()ed +// buffer stored in *output. The return value is the number of samples +// decoded, or -1 if the file could not be opened or was not an ogg vorbis file. +// When you're done with it, just free() the pointer returned in *output. + +extern stb_vorbis * stb_vorbis_open_memory(const unsigned char *data, int len, + int *error, const stb_vorbis_alloc *alloc_buffer); +// create an ogg vorbis decoder from an ogg vorbis stream in memory (note +// this must be the entire stream!). on failure, returns NULL and sets *error + +#ifndef STB_VORBIS_NO_STDIO +extern stb_vorbis * stb_vorbis_open_filename(const char *filename, + int *error, const stb_vorbis_alloc *alloc_buffer); +// create an ogg vorbis decoder from a filename via fopen(). on failure, +// returns NULL and sets *error (possibly to VORBIS_file_open_failure). + +extern stb_vorbis * stb_vorbis_open_file(FILE *f, int close_handle_on_close, + int *error, const stb_vorbis_alloc *alloc_buffer); +// create an ogg vorbis decoder from an open FILE *, looking for a stream at +// the _current_ seek point (ftell). on failure, returns NULL and sets *error. +// note that stb_vorbis must "own" this stream; if you seek it in between +// calls to stb_vorbis, it will become confused. Morever, if you attempt to +// perform stb_vorbis_seek_*() operations on this file, it will assume it +// owns the _entire_ rest of the file after the start point. Use the next +// function, stb_vorbis_open_file_section(), to limit it. + +extern stb_vorbis * stb_vorbis_open_file_section(FILE *f, int close_handle_on_close, + int *error, const stb_vorbis_alloc *alloc_buffer, unsigned int len); +// create an ogg vorbis decoder from an open FILE *, looking for a stream at +// the _current_ seek point (ftell); the stream will be of length 'len' bytes. +// on failure, returns NULL and sets *error. note that stb_vorbis must "own" +// this stream; if you seek it in between calls to stb_vorbis, it will become +// confused. +#endif + +extern int stb_vorbis_seek_frame(stb_vorbis *f, unsigned int sample_number); +extern int stb_vorbis_seek(stb_vorbis *f, unsigned int sample_number); +// these functions seek in the Vorbis file to (approximately) 'sample_number'. +// after calling seek_frame(), the next call to get_frame_*() will include +// the specified sample. after calling stb_vorbis_seek(), the next call to +// stb_vorbis_get_samples_* will start with the specified sample. If you +// do not need to seek to EXACTLY the target sample when using get_samples_*, +// you can also use seek_frame(). + +extern int stb_vorbis_seek_start(stb_vorbis *f); +// this function is equivalent to stb_vorbis_seek(f,0) + +extern unsigned int stb_vorbis_stream_length_in_samples(stb_vorbis *f); +extern float stb_vorbis_stream_length_in_seconds(stb_vorbis *f); +// these functions return the total length of the vorbis stream + +extern int stb_vorbis_get_frame_float(stb_vorbis *f, int *channels, float ***output); +// decode the next frame and return the number of samples. the number of +// channels returned are stored in *channels (which can be NULL--it is always +// the same as the number of channels reported by get_info). *output will +// contain an array of float* buffers, one per channel. These outputs will +// be overwritten on the next call to stb_vorbis_get_frame_*. +// +// You generally should not intermix calls to stb_vorbis_get_frame_*() +// and stb_vorbis_get_samples_*(), since the latter calls the former. + +#ifndef STB_VORBIS_NO_INTEGER_CONVERSION +extern int stb_vorbis_get_frame_short_interleaved(stb_vorbis *f, int num_c, short *buffer, int num_shorts); +extern int stb_vorbis_get_frame_short (stb_vorbis *f, int num_c, short **buffer, int num_samples); +#endif +// decode the next frame and return the number of *samples* per channel. +// Note that for interleaved data, you pass in the number of shorts (the +// size of your array), but the return value is the number of samples per +// channel, not the total number of samples. +// +// The data is coerced to the number of channels you request according to the +// channel coercion rules (see below). You must pass in the size of your +// buffer(s) so that stb_vorbis will not overwrite the end of the buffer. +// The maximum buffer size needed can be gotten from get_info(); however, +// the Vorbis I specification implies an absolute maximum of 4096 samples +// per channel. + +// Channel coercion rules: +// Let M be the number of channels requested, and N the number of channels present, +// and Cn be the nth channel; let stereo L be the sum of all L and center channels, +// and stereo R be the sum of all R and center channels (channel assignment from the +// vorbis spec). +// M N output +// 1 k sum(Ck) for all k +// 2 * stereo L, stereo R +// k l k > l, the first l channels, then 0s +// k l k <= l, the first k channels +// Note that this is not _good_ surround etc. mixing at all! It's just so +// you get something useful. + +extern int stb_vorbis_get_samples_float_interleaved(stb_vorbis *f, int channels, float *buffer, int num_floats); +extern int stb_vorbis_get_samples_float(stb_vorbis *f, int channels, float **buffer, int num_samples); +// gets num_samples samples, not necessarily on a frame boundary--this requires +// buffering so you have to supply the buffers. DOES NOT APPLY THE COERCION RULES. +// Returns the number of samples stored per channel; it may be less than requested +// at the end of the file. If there are no more samples in the file, returns 0. + +#ifndef STB_VORBIS_NO_INTEGER_CONVERSION +extern int stb_vorbis_get_samples_short_interleaved(stb_vorbis *f, int channels, short *buffer, int num_shorts); +extern int stb_vorbis_get_samples_short(stb_vorbis *f, int channels, short **buffer, int num_samples); +#endif +// gets num_samples samples, not necessarily on a frame boundary--this requires +// buffering so you have to supply the buffers. Applies the coercion rules above +// to produce 'channels' channels. Returns the number of samples stored per channel; +// it may be less than requested at the end of the file. If there are no more +// samples in the file, returns 0. + +#endif + +//////// ERROR CODES + +enum STBVorbisError +{ + VORBIS__no_error, + + VORBIS_need_more_data=1, // not a real error + + VORBIS_invalid_api_mixing, // can't mix API modes + VORBIS_outofmem, // not enough memory + VORBIS_feature_not_supported, // uses floor 0 + VORBIS_too_many_channels, // STB_VORBIS_MAX_CHANNELS is too small + VORBIS_file_open_failure, // fopen() failed + VORBIS_seek_without_length, // can't seek in unknown-length file + + VORBIS_unexpected_eof=10, // file is truncated? + VORBIS_seek_invalid, // seek past EOF + + // decoding errors (corrupt/invalid stream) -- you probably + // don't care about the exact details of these + + // vorbis errors: + VORBIS_invalid_setup=20, + VORBIS_invalid_stream, + + // ogg errors: + VORBIS_missing_capture_pattern=30, + VORBIS_invalid_stream_structure_version, + VORBIS_continued_packet_flag_invalid, + VORBIS_incorrect_stream_serial_number, + VORBIS_invalid_first_page, + VORBIS_bad_packet_type, + VORBIS_cant_find_last_page, + VORBIS_seek_failed +}; + + +#ifdef __cplusplus +} +#endif + +#endif // STB_VORBIS_INCLUDE_STB_VORBIS_H +// +// HEADER ENDS HERE +// +////////////////////////////////////////////////////////////////////////////// + +#ifndef STB_VORBIS_HEADER_ONLY + +// global configuration settings (e.g. set these in the project/makefile), +// or just set them in this file at the top (although ideally the first few +// should be visible when the header file is compiled too, although it's not +// crucial) + +// STB_VORBIS_NO_PUSHDATA_API +// does not compile the code for the various stb_vorbis_*_pushdata() +// functions +// #define STB_VORBIS_NO_PUSHDATA_API + +// STB_VORBIS_NO_PULLDATA_API +// does not compile the code for the non-pushdata APIs +// #define STB_VORBIS_NO_PULLDATA_API + +// STB_VORBIS_NO_STDIO +// does not compile the code for the APIs that use FILE *s internally +// or externally (implied by STB_VORBIS_NO_PULLDATA_API) +// #define STB_VORBIS_NO_STDIO + +// STB_VORBIS_NO_INTEGER_CONVERSION +// does not compile the code for converting audio sample data from +// float to integer (implied by STB_VORBIS_NO_PULLDATA_API) +// #define STB_VORBIS_NO_INTEGER_CONVERSION + +// STB_VORBIS_NO_FAST_SCALED_FLOAT +// does not use a fast float-to-int trick to accelerate float-to-int on +// most platforms which requires endianness be defined correctly. +//#define STB_VORBIS_NO_FAST_SCALED_FLOAT + + +// STB_VORBIS_MAX_CHANNELS [number] +// globally define this to the maximum number of channels you need. +// The spec does not put a restriction on channels except that +// the count is stored in a byte, so 255 is the hard limit. +// Reducing this saves about 16 bytes per value, so using 16 saves +// (255-16)*16 or around 4KB. Plus anything other memory usage +// I forgot to account for. Can probably go as low as 8 (7.1 audio), +// 6 (5.1 audio), or 2 (stereo only). +#ifndef STB_VORBIS_MAX_CHANNELS +#define STB_VORBIS_MAX_CHANNELS 16 // enough for anyone? +#endif + +// STB_VORBIS_PUSHDATA_CRC_COUNT [number] +// after a flush_pushdata(), stb_vorbis begins scanning for the +// next valid page, without backtracking. when it finds something +// that looks like a page, it streams through it and verifies its +// CRC32. Should that validation fail, it keeps scanning. But it's +// possible that _while_ streaming through to check the CRC32 of +// one candidate page, it sees another candidate page. This #define +// determines how many "overlapping" candidate pages it can search +// at once. Note that "real" pages are typically ~4KB to ~8KB, whereas +// garbage pages could be as big as 64KB, but probably average ~16KB. +// So don't hose ourselves by scanning an apparent 64KB page and +// missing a ton of real ones in the interim; so minimum of 2 +#ifndef STB_VORBIS_PUSHDATA_CRC_COUNT +#define STB_VORBIS_PUSHDATA_CRC_COUNT 4 +#endif + +// STB_VORBIS_FAST_HUFFMAN_LENGTH [number] +// sets the log size of the huffman-acceleration table. Maximum +// supported value is 24. with larger numbers, more decodings are O(1), +// but the table size is larger so worse cache missing, so you'll have +// to probe (and try multiple ogg vorbis files) to find the sweet spot. +#ifndef STB_VORBIS_FAST_HUFFMAN_LENGTH +#define STB_VORBIS_FAST_HUFFMAN_LENGTH 10 +#endif + +// STB_VORBIS_FAST_BINARY_LENGTH [number] +// sets the log size of the binary-search acceleration table. this +// is used in similar fashion to the fast-huffman size to set initial +// parameters for the binary search + +// STB_VORBIS_FAST_HUFFMAN_INT +// The fast huffman tables are much more efficient if they can be +// stored as 16-bit results instead of 32-bit results. This restricts +// the codebooks to having only 65535 possible outcomes, though. +// (At least, accelerated by the huffman table.) +#ifndef STB_VORBIS_FAST_HUFFMAN_INT +#define STB_VORBIS_FAST_HUFFMAN_SHORT +#endif + +// STB_VORBIS_NO_HUFFMAN_BINARY_SEARCH +// If the 'fast huffman' search doesn't succeed, then stb_vorbis falls +// back on binary searching for the correct one. This requires storing +// extra tables with the huffman codes in sorted order. Defining this +// symbol trades off space for speed by forcing a linear search in the +// non-fast case, except for "sparse" codebooks. +// #define STB_VORBIS_NO_HUFFMAN_BINARY_SEARCH + +// STB_VORBIS_DIVIDES_IN_RESIDUE +// stb_vorbis precomputes the result of the scalar residue decoding +// that would otherwise require a divide per chunk. you can trade off +// space for time by defining this symbol. +// #define STB_VORBIS_DIVIDES_IN_RESIDUE + +// STB_VORBIS_DIVIDES_IN_CODEBOOK +// vorbis VQ codebooks can be encoded two ways: with every case explicitly +// stored, or with all elements being chosen from a small range of values, +// and all values possible in all elements. By default, stb_vorbis expands +// this latter kind out to look like the former kind for ease of decoding, +// because otherwise an integer divide-per-vector-element is required to +// unpack the index. If you define STB_VORBIS_DIVIDES_IN_CODEBOOK, you can +// trade off storage for speed. +//#define STB_VORBIS_DIVIDES_IN_CODEBOOK + +#ifdef STB_VORBIS_CODEBOOK_SHORTS +#error "STB_VORBIS_CODEBOOK_SHORTS is no longer supported as it produced incorrect results for some input formats" +#endif + +// STB_VORBIS_DIVIDE_TABLE +// this replaces small integer divides in the floor decode loop with +// table lookups. made less than 1% difference, so disabled by default. + +// STB_VORBIS_NO_INLINE_DECODE +// disables the inlining of the scalar codebook fast-huffman decode. +// might save a little codespace; useful for debugging +// #define STB_VORBIS_NO_INLINE_DECODE + +// STB_VORBIS_NO_DEFER_FLOOR +// Normally we only decode the floor without synthesizing the actual +// full curve. We can instead synthesize the curve immediately. This +// requires more memory and is very likely slower, so I don't think +// you'd ever want to do it except for debugging. +// #define STB_VORBIS_NO_DEFER_FLOOR + + + + +////////////////////////////////////////////////////////////////////////////// + +#ifdef STB_VORBIS_NO_PULLDATA_API + #define STB_VORBIS_NO_INTEGER_CONVERSION + #define STB_VORBIS_NO_STDIO +#endif + +#if defined(STB_VORBIS_NO_CRT) && !defined(STB_VORBIS_NO_STDIO) + #define STB_VORBIS_NO_STDIO 1 +#endif + +#ifndef STB_VORBIS_NO_INTEGER_CONVERSION +#ifndef STB_VORBIS_NO_FAST_SCALED_FLOAT + + // only need endianness for fast-float-to-int, which we don't + // use for pushdata + + #ifndef STB_VORBIS_BIG_ENDIAN + #define STB_VORBIS_ENDIAN 0 + #else + #define STB_VORBIS_ENDIAN 1 + #endif + +#endif +#endif + + +#ifndef STB_VORBIS_NO_STDIO +#include +#endif + +#ifndef STB_VORBIS_NO_CRT + #include + #include + #include + #include + + // find definition of alloca if it's not in stdlib.h: + #if defined(_MSC_VER) || defined(__MINGW32__) + #include + #endif + #if defined(__linux__) || defined(__linux) || defined(__EMSCRIPTEN__) + #include + #endif +#else // STB_VORBIS_NO_CRT + #define NULL 0 + #define malloc(s) 0 + #define free(s) ((void) 0) + #define realloc(s) 0 +#endif // STB_VORBIS_NO_CRT + +#include + +#ifdef __MINGW32__ + // eff you mingw: + // "fixed": + // http://sourceforge.net/p/mingw-w64/mailman/message/32882927/ + // "no that broke the build, reverted, who cares about C": + // http://sourceforge.net/p/mingw-w64/mailman/message/32890381/ + #ifdef __forceinline + #undef __forceinline + #endif + #define __forceinline + #define alloca __builtin_alloca +#elif !defined(_MSC_VER) + #if __GNUC__ + #define __forceinline inline + #else + #define __forceinline + #endif +#endif + +#if STB_VORBIS_MAX_CHANNELS > 256 +#error "Value of STB_VORBIS_MAX_CHANNELS outside of allowed range" +#endif + +#if STB_VORBIS_FAST_HUFFMAN_LENGTH > 24 +#error "Value of STB_VORBIS_FAST_HUFFMAN_LENGTH outside of allowed range" +#endif + + +#if 0 +#include +#define CHECK(f) _CrtIsValidHeapPointer(f->channel_buffers[1]) +#else +#define CHECK(f) ((void) 0) +#endif + +#define MAX_BLOCKSIZE_LOG 13 // from specification +#define MAX_BLOCKSIZE (1 << MAX_BLOCKSIZE_LOG) + + +typedef unsigned char uint8; +typedef signed char int8; +typedef unsigned short uint16; +typedef signed short int16; +typedef unsigned int uint32; +typedef signed int int32; + +#ifndef TRUE +#define TRUE 1 +#define FALSE 0 +#endif + +typedef float codetype; + +// @NOTE +// +// Some arrays below are tagged "//varies", which means it's actually +// a variable-sized piece of data, but rather than malloc I assume it's +// small enough it's better to just allocate it all together with the +// main thing +// +// Most of the variables are specified with the smallest size I could pack +// them into. It might give better performance to make them all full-sized +// integers. It should be safe to freely rearrange the structures or change +// the sizes larger--nothing relies on silently truncating etc., nor the +// order of variables. + +#define FAST_HUFFMAN_TABLE_SIZE (1 << STB_VORBIS_FAST_HUFFMAN_LENGTH) +#define FAST_HUFFMAN_TABLE_MASK (FAST_HUFFMAN_TABLE_SIZE - 1) + +typedef struct +{ + int dimensions, entries; + uint8 *codeword_lengths; + float minimum_value; + float delta_value; + uint8 value_bits; + uint8 lookup_type; + uint8 sequence_p; + uint8 sparse; + uint32 lookup_values; + codetype *multiplicands; + uint32 *codewords; + #ifdef STB_VORBIS_FAST_HUFFMAN_SHORT + int16 fast_huffman[FAST_HUFFMAN_TABLE_SIZE]; + #else + int32 fast_huffman[FAST_HUFFMAN_TABLE_SIZE]; + #endif + uint32 *sorted_codewords; + int *sorted_values; + int sorted_entries; +} Codebook; + +typedef struct +{ + uint8 order; + uint16 rate; + uint16 bark_map_size; + uint8 amplitude_bits; + uint8 amplitude_offset; + uint8 number_of_books; + uint8 book_list[16]; // varies +} Floor0; + +typedef struct +{ + uint8 partitions; + uint8 partition_class_list[32]; // varies + uint8 class_dimensions[16]; // varies + uint8 class_subclasses[16]; // varies + uint8 class_masterbooks[16]; // varies + int16 subclass_books[16][8]; // varies + uint16 Xlist[31*8+2]; // varies + uint8 sorted_order[31*8+2]; + uint8 neighbors[31*8+2][2]; + uint8 floor1_multiplier; + uint8 rangebits; + int values; +} Floor1; + +typedef union +{ + Floor0 floor0; + Floor1 floor1; +} Floor; + +typedef struct +{ + uint32 begin, end; + uint32 part_size; + uint8 classifications; + uint8 classbook; + uint8 **classdata; + int16 (*residue_books)[8]; +} Residue; + +typedef struct +{ + uint8 magnitude; + uint8 angle; + uint8 mux; +} MappingChannel; + +typedef struct +{ + uint16 coupling_steps; + MappingChannel *chan; + uint8 submaps; + uint8 submap_floor[15]; // varies + uint8 submap_residue[15]; // varies +} Mapping; + +typedef struct +{ + uint8 blockflag; + uint8 mapping; + uint16 windowtype; + uint16 transformtype; +} Mode; + +typedef struct +{ + uint32 goal_crc; // expected crc if match + int bytes_left; // bytes left in packet + uint32 crc_so_far; // running crc + int bytes_done; // bytes processed in _current_ chunk + uint32 sample_loc; // granule pos encoded in page +} CRCscan; + +typedef struct +{ + uint32 page_start, page_end; + uint32 last_decoded_sample; +} ProbedPage; + +struct stb_vorbis +{ + // user-accessible info + unsigned int sample_rate; + int channels; + + unsigned int setup_memory_required; + unsigned int temp_memory_required; + unsigned int setup_temp_memory_required; + + // input config +#ifndef STB_VORBIS_NO_STDIO + FILE *f; + uint32 f_start; + int close_on_free; +#endif + + uint8 *stream; + uint8 *stream_start; + uint8 *stream_end; + + uint32 stream_len; + + uint8 push_mode; + + uint32 first_audio_page_offset; + + ProbedPage p_first, p_last; + + // memory management + stb_vorbis_alloc alloc; + int setup_offset; + int temp_offset; + + // run-time results + int eof; + enum STBVorbisError error; + + // user-useful data + + // header info + int blocksize[2]; + int blocksize_0, blocksize_1; + int codebook_count; + Codebook *codebooks; + int floor_count; + uint16 floor_types[64]; // varies + Floor *floor_config; + int residue_count; + uint16 residue_types[64]; // varies + Residue *residue_config; + int mapping_count; + Mapping *mapping; + int mode_count; + Mode mode_config[64]; // varies + + uint32 total_samples; + + // decode buffer + float *channel_buffers[STB_VORBIS_MAX_CHANNELS]; + float *outputs [STB_VORBIS_MAX_CHANNELS]; + + float *previous_window[STB_VORBIS_MAX_CHANNELS]; + int previous_length; + + #ifndef STB_VORBIS_NO_DEFER_FLOOR + int16 *finalY[STB_VORBIS_MAX_CHANNELS]; + #else + float *floor_buffers[STB_VORBIS_MAX_CHANNELS]; + #endif + + uint32 current_loc; // sample location of next frame to decode + int current_loc_valid; + + // per-blocksize precomputed data + + // twiddle factors + float *A[2],*B[2],*C[2]; + float *window[2]; + uint16 *bit_reverse[2]; + + // current page/packet/segment streaming info + uint32 serial; // stream serial number for verification + int last_page; + int segment_count; + uint8 segments[255]; + uint8 page_flag; + uint8 bytes_in_seg; + uint8 first_decode; + int next_seg; + int last_seg; // flag that we're on the last segment + int last_seg_which; // what was the segment number of the last seg? + uint32 acc; + int valid_bits; + int packet_bytes; + int end_seg_with_known_loc; + uint32 known_loc_for_packet; + int discard_samples_deferred; + uint32 samples_output; + + // push mode scanning + int page_crc_tests; // only in push_mode: number of tests active; -1 if not searching +#ifndef STB_VORBIS_NO_PUSHDATA_API + CRCscan scan[STB_VORBIS_PUSHDATA_CRC_COUNT]; +#endif + + // sample-access + int channel_buffer_start; + int channel_buffer_end; +}; + +#if defined(STB_VORBIS_NO_PUSHDATA_API) + #define IS_PUSH_MODE(f) FALSE +#elif defined(STB_VORBIS_NO_PULLDATA_API) + #define IS_PUSH_MODE(f) TRUE +#else + #define IS_PUSH_MODE(f) ((f)->push_mode) +#endif + +typedef struct stb_vorbis vorb; + +static int error(vorb *f, enum STBVorbisError e) +{ + f->error = e; + if (!f->eof && e != VORBIS_need_more_data) { + f->error=e; // breakpoint for debugging + } + return 0; +} + + +// these functions are used for allocating temporary memory +// while decoding. if you can afford the stack space, use +// alloca(); otherwise, provide a temp buffer and it will +// allocate out of those. + +#define array_size_required(count,size) (count*(sizeof(void *)+(size))) + +#define temp_alloc(f,size) (f->alloc.alloc_buffer ? setup_temp_malloc(f,size) : alloca(size)) +#define temp_free(f,p) 0 +#define temp_alloc_save(f) ((f)->temp_offset) +#define temp_alloc_restore(f,p) ((f)->temp_offset = (p)) + +#define temp_block_array(f,count,size) make_block_array(temp_alloc(f,array_size_required(count,size)), count, size) + +// given a sufficiently large block of memory, make an array of pointers to subblocks of it +static void *make_block_array(void *mem, int count, int size) +{ + int i; + void ** p = (void **) mem; + char *q = (char *) (p + count); + for (i=0; i < count; ++i) { + p[i] = q; + q += size; + } + return p; +} + +static void *setup_malloc(vorb *f, int sz) +{ + sz = (sz+3) & ~3; + f->setup_memory_required += sz; + if (f->alloc.alloc_buffer) { + void *p = (char *) f->alloc.alloc_buffer + f->setup_offset; + if (f->setup_offset + sz > f->temp_offset) return NULL; + f->setup_offset += sz; + return p; + } + return sz ? malloc(sz) : NULL; +} + +static void setup_free(vorb *f, void *p) +{ + if (f->alloc.alloc_buffer) return; // do nothing; setup mem is a stack + free(p); +} + +static void *setup_temp_malloc(vorb *f, int sz) +{ + sz = (sz+3) & ~3; + if (f->alloc.alloc_buffer) { + if (f->temp_offset - sz < f->setup_offset) return NULL; + f->temp_offset -= sz; + return (char *) f->alloc.alloc_buffer + f->temp_offset; + } + return malloc(sz); +} + +static void setup_temp_free(vorb *f, void *p, int sz) +{ + if (f->alloc.alloc_buffer) { + f->temp_offset += (sz+3)&~3; + return; + } + free(p); +} + +#define CRC32_POLY 0x04c11db7 // from spec + +static uint32 crc_table[256]; +static void crc32_init(void) +{ + int i,j; + uint32 s; + for(i=0; i < 256; i++) { + for (s=(uint32) i << 24, j=0; j < 8; ++j) + s = (s << 1) ^ (s >= (1U<<31) ? CRC32_POLY : 0); + crc_table[i] = s; + } +} + +static __forceinline uint32 crc32_update(uint32 crc, uint8 byte) +{ + return (crc << 8) ^ crc_table[byte ^ (crc >> 24)]; +} + + +// used in setup, and for huffman that doesn't go fast path +static unsigned int bit_reverse(unsigned int n) +{ + n = ((n & 0xAAAAAAAA) >> 1) | ((n & 0x55555555) << 1); + n = ((n & 0xCCCCCCCC) >> 2) | ((n & 0x33333333) << 2); + n = ((n & 0xF0F0F0F0) >> 4) | ((n & 0x0F0F0F0F) << 4); + n = ((n & 0xFF00FF00) >> 8) | ((n & 0x00FF00FF) << 8); + return (n >> 16) | (n << 16); +} + +static float square(float x) +{ + return x*x; +} + +// this is a weird definition of log2() for which log2(1) = 1, log2(2) = 2, log2(4) = 3 +// as required by the specification. fast(?) implementation from stb.h +// @OPTIMIZE: called multiple times per-packet with "constants"; move to setup +static int ilog(int32 n) +{ + static signed char log2_4[16] = { 0,1,2,2,3,3,3,3,4,4,4,4,4,4,4,4 }; + + if (n < 0) return 0; // signed n returns 0 + + // 2 compares if n < 16, 3 compares otherwise (4 if signed or n > 1<<29) + if (n < (1 << 14)) + if (n < (1 << 4)) return 0 + log2_4[n ]; + else if (n < (1 << 9)) return 5 + log2_4[n >> 5]; + else return 10 + log2_4[n >> 10]; + else if (n < (1 << 24)) + if (n < (1 << 19)) return 15 + log2_4[n >> 15]; + else return 20 + log2_4[n >> 20]; + else if (n < (1 << 29)) return 25 + log2_4[n >> 25]; + else return 30 + log2_4[n >> 30]; +} + +#ifndef M_PI + #define M_PI 3.14159265358979323846264f // from CRC +#endif + +// code length assigned to a value with no huffman encoding +#define NO_CODE 255 + +/////////////////////// LEAF SETUP FUNCTIONS ////////////////////////// +// +// these functions are only called at setup, and only a few times +// per file + +static float float32_unpack(uint32 x) +{ + // from the specification + uint32 mantissa = x & 0x1fffff; + uint32 sign = x & 0x80000000; + uint32 exp = (x & 0x7fe00000) >> 21; + double res = sign ? -(double)mantissa : (double)mantissa; + return (float) ldexp((float)res, exp-788); +} + + +// zlib & jpeg huffman tables assume that the output symbols +// can either be arbitrarily arranged, or have monotonically +// increasing frequencies--they rely on the lengths being sorted; +// this makes for a very simple generation algorithm. +// vorbis allows a huffman table with non-sorted lengths. This +// requires a more sophisticated construction, since symbols in +// order do not map to huffman codes "in order". +static void add_entry(Codebook *c, uint32 huff_code, int symbol, int count, int len, uint32 *values) +{ + if (!c->sparse) { + c->codewords [symbol] = huff_code; + } else { + c->codewords [count] = huff_code; + c->codeword_lengths[count] = len; + values [count] = symbol; + } +} + +static int compute_codewords(Codebook *c, uint8 *len, int n, uint32 *values) +{ + int i,k,m=0; + uint32 available[32]; + + memset(available, 0, sizeof(available)); + // find the first entry + for (k=0; k < n; ++k) if (len[k] < NO_CODE) break; + if (k == n) { assert(c->sorted_entries == 0); return TRUE; } + // add to the list + add_entry(c, 0, k, m++, len[k], values); + // add all available leaves + for (i=1; i <= len[k]; ++i) + available[i] = 1U << (32-i); + // note that the above code treats the first case specially, + // but it's really the same as the following code, so they + // could probably be combined (except the initial code is 0, + // and I use 0 in available[] to mean 'empty') + for (i=k+1; i < n; ++i) { + uint32 res; + int z = len[i], y; + if (z == NO_CODE) continue; + // find lowest available leaf (should always be earliest, + // which is what the specification calls for) + // note that this property, and the fact we can never have + // more than one free leaf at a given level, isn't totally + // trivial to prove, but it seems true and the assert never + // fires, so! + while (z > 0 && !available[z]) --z; + if (z == 0) { return FALSE; } + res = available[z]; + assert(z >= 0 && z < 32); + available[z] = 0; + add_entry(c, bit_reverse(res), i, m++, len[i], values); + // propogate availability up the tree + if (z != len[i]) { + assert(len[i] >= 0 && len[i] < 32); + for (y=len[i]; y > z; --y) { + assert(available[y] == 0); + available[y] = res + (1 << (32-y)); + } + } + } + return TRUE; +} + +// accelerated huffman table allows fast O(1) match of all symbols +// of length <= STB_VORBIS_FAST_HUFFMAN_LENGTH +static void compute_accelerated_huffman(Codebook *c) +{ + int i, len; + for (i=0; i < FAST_HUFFMAN_TABLE_SIZE; ++i) + c->fast_huffman[i] = -1; + + len = c->sparse ? c->sorted_entries : c->entries; + #ifdef STB_VORBIS_FAST_HUFFMAN_SHORT + if (len > 32767) len = 32767; // largest possible value we can encode! + #endif + for (i=0; i < len; ++i) { + if (c->codeword_lengths[i] <= STB_VORBIS_FAST_HUFFMAN_LENGTH) { + uint32 z = c->sparse ? bit_reverse(c->sorted_codewords[i]) : c->codewords[i]; + // set table entries for all bit combinations in the higher bits + while (z < FAST_HUFFMAN_TABLE_SIZE) { + c->fast_huffman[z] = i; + z += 1 << c->codeword_lengths[i]; + } + } + } +} + +#ifdef _MSC_VER +#define STBV_CDECL __cdecl +#else +#define STBV_CDECL +#endif + +static int STBV_CDECL uint32_compare(const void *p, const void *q) +{ + uint32 x = * (uint32 *) p; + uint32 y = * (uint32 *) q; + return x < y ? -1 : x > y; +} + +static int include_in_sort(Codebook *c, uint8 len) +{ + if (c->sparse) { assert(len != NO_CODE); return TRUE; } + if (len == NO_CODE) return FALSE; + if (len > STB_VORBIS_FAST_HUFFMAN_LENGTH) return TRUE; + return FALSE; +} + +// if the fast table above doesn't work, we want to binary +// search them... need to reverse the bits +static void compute_sorted_huffman(Codebook *c, uint8 *lengths, uint32 *values) +{ + int i, len; + // build a list of all the entries + // OPTIMIZATION: don't include the short ones, since they'll be caught by FAST_HUFFMAN. + // this is kind of a frivolous optimization--I don't see any performance improvement, + // but it's like 4 extra lines of code, so. + if (!c->sparse) { + int k = 0; + for (i=0; i < c->entries; ++i) + if (include_in_sort(c, lengths[i])) + c->sorted_codewords[k++] = bit_reverse(c->codewords[i]); + assert(k == c->sorted_entries); + } else { + for (i=0; i < c->sorted_entries; ++i) + c->sorted_codewords[i] = bit_reverse(c->codewords[i]); + } + + qsort(c->sorted_codewords, c->sorted_entries, sizeof(c->sorted_codewords[0]), uint32_compare); + c->sorted_codewords[c->sorted_entries] = 0xffffffff; + + len = c->sparse ? c->sorted_entries : c->entries; + // now we need to indicate how they correspond; we could either + // #1: sort a different data structure that says who they correspond to + // #2: for each sorted entry, search the original list to find who corresponds + // #3: for each original entry, find the sorted entry + // #1 requires extra storage, #2 is slow, #3 can use binary search! + for (i=0; i < len; ++i) { + int huff_len = c->sparse ? lengths[values[i]] : lengths[i]; + if (include_in_sort(c,huff_len)) { + uint32 code = bit_reverse(c->codewords[i]); + int x=0, n=c->sorted_entries; + while (n > 1) { + // invariant: sc[x] <= code < sc[x+n] + int m = x + (n >> 1); + if (c->sorted_codewords[m] <= code) { + x = m; + n -= (n>>1); + } else { + n >>= 1; + } + } + assert(c->sorted_codewords[x] == code); + if (c->sparse) { + c->sorted_values[x] = values[i]; + c->codeword_lengths[x] = huff_len; + } else { + c->sorted_values[x] = i; + } + } + } +} + +// only run while parsing the header (3 times) +static int vorbis_validate(uint8 *data) +{ + static uint8 vorbis[6] = { 'v', 'o', 'r', 'b', 'i', 's' }; + return memcmp(data, vorbis, 6) == 0; +} + +// called from setup only, once per code book +// (formula implied by specification) +static int lookup1_values(int entries, int dim) +{ + int r = (int) floor(exp((float) log((float) entries) / dim)); + if ((int) floor(pow((float) r+1, dim)) <= entries) // (int) cast for MinGW warning; + ++r; // floor() to avoid _ftol() when non-CRT + assert(pow((float) r+1, dim) > entries); + assert((int) floor(pow((float) r, dim)) <= entries); // (int),floor() as above + return r; +} + +// called twice per file +static void compute_twiddle_factors(int n, float *A, float *B, float *C) +{ + int n4 = n >> 2, n8 = n >> 3; + int k,k2; + + for (k=k2=0; k < n4; ++k,k2+=2) { + A[k2 ] = (float) cos(4*k*M_PI/n); + A[k2+1] = (float) -sin(4*k*M_PI/n); + B[k2 ] = (float) cos((k2+1)*M_PI/n/2) * 0.5f; + B[k2+1] = (float) sin((k2+1)*M_PI/n/2) * 0.5f; + } + for (k=k2=0; k < n8; ++k,k2+=2) { + C[k2 ] = (float) cos(2*(k2+1)*M_PI/n); + C[k2+1] = (float) -sin(2*(k2+1)*M_PI/n); + } +} + +static void compute_window(int n, float *window) +{ + int n2 = n >> 1, i; + for (i=0; i < n2; ++i) + window[i] = (float) sin(0.5 * M_PI * square((float) sin((i - 0 + 0.5) / n2 * 0.5 * M_PI))); +} + +static void compute_bitreverse(int n, uint16 *rev) +{ + int ld = ilog(n) - 1; // ilog is off-by-one from normal definitions + int i, n8 = n >> 3; + for (i=0; i < n8; ++i) + rev[i] = (bit_reverse(i) >> (32-ld+3)) << 2; +} + +static int init_blocksize(vorb *f, int b, int n) +{ + int n2 = n >> 1, n4 = n >> 2, n8 = n >> 3; + f->A[b] = (float *) setup_malloc(f, sizeof(float) * n2); + f->B[b] = (float *) setup_malloc(f, sizeof(float) * n2); + f->C[b] = (float *) setup_malloc(f, sizeof(float) * n4); + if (!f->A[b] || !f->B[b] || !f->C[b]) return error(f, VORBIS_outofmem); + compute_twiddle_factors(n, f->A[b], f->B[b], f->C[b]); + f->window[b] = (float *) setup_malloc(f, sizeof(float) * n2); + if (!f->window[b]) return error(f, VORBIS_outofmem); + compute_window(n, f->window[b]); + f->bit_reverse[b] = (uint16 *) setup_malloc(f, sizeof(uint16) * n8); + if (!f->bit_reverse[b]) return error(f, VORBIS_outofmem); + compute_bitreverse(n, f->bit_reverse[b]); + return TRUE; +} + +static void neighbors(uint16 *x, int n, int *plow, int *phigh) +{ + int low = -1; + int high = 65536; + int i; + for (i=0; i < n; ++i) { + if (x[i] > low && x[i] < x[n]) { *plow = i; low = x[i]; } + if (x[i] < high && x[i] > x[n]) { *phigh = i; high = x[i]; } + } +} + +// this has been repurposed so y is now the original index instead of y +typedef struct +{ + uint16 x,id; +} stbv__floor_ordering; + +static int STBV_CDECL point_compare(const void *p, const void *q) +{ + stbv__floor_ordering *a = (stbv__floor_ordering *) p; + stbv__floor_ordering *b = (stbv__floor_ordering *) q; + return a->x < b->x ? -1 : a->x > b->x; +} + +// +/////////////////////// END LEAF SETUP FUNCTIONS ////////////////////////// + + +#if defined(STB_VORBIS_NO_STDIO) + #define USE_MEMORY(z) TRUE +#else + #define USE_MEMORY(z) ((z)->stream) +#endif + +static uint8 get8(vorb *z) +{ + if (USE_MEMORY(z)) { + if (z->stream >= z->stream_end) { z->eof = TRUE; return 0; } + return *z->stream++; + } + + #ifndef STB_VORBIS_NO_STDIO + { + int c = fgetc(z->f); + if (c == EOF) { z->eof = TRUE; return 0; } + return c; + } + #endif +} + +static uint32 get32(vorb *f) +{ + uint32 x; + x = get8(f); + x += get8(f) << 8; + x += get8(f) << 16; + x += (uint32) get8(f) << 24; + return x; +} + +static int getn(vorb *z, uint8 *data, int n) +{ + if (USE_MEMORY(z)) { + if (z->stream+n > z->stream_end) { z->eof = 1; return 0; } + memcpy(data, z->stream, n); + z->stream += n; + return 1; + } + + #ifndef STB_VORBIS_NO_STDIO + if (fread(data, n, 1, z->f) == 1) + return 1; + else { + z->eof = 1; + return 0; + } + #endif +} + +static void skip(vorb *z, int n) +{ + if (USE_MEMORY(z)) { + z->stream += n; + if (z->stream >= z->stream_end) z->eof = 1; + return; + } + #ifndef STB_VORBIS_NO_STDIO + { + long x = ftell(z->f); + fseek(z->f, x+n, SEEK_SET); + } + #endif +} + +static int set_file_offset(stb_vorbis *f, unsigned int loc) +{ + #ifndef STB_VORBIS_NO_PUSHDATA_API + if (f->push_mode) return 0; + #endif + f->eof = 0; + if (USE_MEMORY(f)) { + if (f->stream_start + loc >= f->stream_end || f->stream_start + loc < f->stream_start) { + f->stream = f->stream_end; + f->eof = 1; + return 0; + } else { + f->stream = f->stream_start + loc; + return 1; + } + } + #ifndef STB_VORBIS_NO_STDIO + if (loc + f->f_start < loc || loc >= 0x80000000) { + loc = 0x7fffffff; + f->eof = 1; + } else { + loc += f->f_start; + } + if (!fseek(f->f, loc, SEEK_SET)) + return 1; + f->eof = 1; + fseek(f->f, f->f_start, SEEK_END); + return 0; + #endif +} + + +static uint8 ogg_page_header[4] = { 0x4f, 0x67, 0x67, 0x53 }; + +static int capture_pattern(vorb *f) +{ + if (0x4f != get8(f)) return FALSE; + if (0x67 != get8(f)) return FALSE; + if (0x67 != get8(f)) return FALSE; + if (0x53 != get8(f)) return FALSE; + return TRUE; +} + +#define PAGEFLAG_continued_packet 1 +#define PAGEFLAG_first_page 2 +#define PAGEFLAG_last_page 4 + +static int start_page_no_capturepattern(vorb *f) +{ + uint32 loc0,loc1,n; + // stream structure version + if (0 != get8(f)) return error(f, VORBIS_invalid_stream_structure_version); + // header flag + f->page_flag = get8(f); + // absolute granule position + loc0 = get32(f); + loc1 = get32(f); + // @TODO: validate loc0,loc1 as valid positions? + // stream serial number -- vorbis doesn't interleave, so discard + get32(f); + //if (f->serial != get32(f)) return error(f, VORBIS_incorrect_stream_serial_number); + // page sequence number + n = get32(f); + f->last_page = n; + // CRC32 + get32(f); + // page_segments + f->segment_count = get8(f); + if (!getn(f, f->segments, f->segment_count)) + return error(f, VORBIS_unexpected_eof); + // assume we _don't_ know any the sample position of any segments + f->end_seg_with_known_loc = -2; + if (loc0 != ~0U || loc1 != ~0U) { + int i; + // determine which packet is the last one that will complete + for (i=f->segment_count-1; i >= 0; --i) + if (f->segments[i] < 255) + break; + // 'i' is now the index of the _last_ segment of a packet that ends + if (i >= 0) { + f->end_seg_with_known_loc = i; + f->known_loc_for_packet = loc0; + } + } + if (f->first_decode) { + int i,len; + ProbedPage p; + len = 0; + for (i=0; i < f->segment_count; ++i) + len += f->segments[i]; + len += 27 + f->segment_count; + p.page_start = f->first_audio_page_offset; + p.page_end = p.page_start + len; + p.last_decoded_sample = loc0; + f->p_first = p; + } + f->next_seg = 0; + return TRUE; +} + +static int start_page(vorb *f) +{ + if (!capture_pattern(f)) return error(f, VORBIS_missing_capture_pattern); + return start_page_no_capturepattern(f); +} + +static int start_packet(vorb *f) +{ + while (f->next_seg == -1) { + if (!start_page(f)) return FALSE; + if (f->page_flag & PAGEFLAG_continued_packet) + return error(f, VORBIS_continued_packet_flag_invalid); + } + f->last_seg = FALSE; + f->valid_bits = 0; + f->packet_bytes = 0; + f->bytes_in_seg = 0; + // f->next_seg is now valid + return TRUE; +} + +static int maybe_start_packet(vorb *f) +{ + if (f->next_seg == -1) { + int x = get8(f); + if (f->eof) return FALSE; // EOF at page boundary is not an error! + if (0x4f != x ) return error(f, VORBIS_missing_capture_pattern); + if (0x67 != get8(f)) return error(f, VORBIS_missing_capture_pattern); + if (0x67 != get8(f)) return error(f, VORBIS_missing_capture_pattern); + if (0x53 != get8(f)) return error(f, VORBIS_missing_capture_pattern); + if (!start_page_no_capturepattern(f)) return FALSE; + if (f->page_flag & PAGEFLAG_continued_packet) { + // set up enough state that we can read this packet if we want, + // e.g. during recovery + f->last_seg = FALSE; + f->bytes_in_seg = 0; + return error(f, VORBIS_continued_packet_flag_invalid); + } + } + return start_packet(f); +} + +static int next_segment(vorb *f) +{ + int len; + if (f->last_seg) return 0; + if (f->next_seg == -1) { + f->last_seg_which = f->segment_count-1; // in case start_page fails + if (!start_page(f)) { f->last_seg = 1; return 0; } + if (!(f->page_flag & PAGEFLAG_continued_packet)) return error(f, VORBIS_continued_packet_flag_invalid); + } + len = f->segments[f->next_seg++]; + if (len < 255) { + f->last_seg = TRUE; + f->last_seg_which = f->next_seg-1; + } + if (f->next_seg >= f->segment_count) + f->next_seg = -1; + assert(f->bytes_in_seg == 0); + f->bytes_in_seg = len; + return len; +} + +#define EOP (-1) +#define INVALID_BITS (-1) + +static int get8_packet_raw(vorb *f) +{ + if (!f->bytes_in_seg) { // CLANG! + if (f->last_seg) return EOP; + else if (!next_segment(f)) return EOP; + } + assert(f->bytes_in_seg > 0); + --f->bytes_in_seg; + ++f->packet_bytes; + return get8(f); +} + +static int get8_packet(vorb *f) +{ + int x = get8_packet_raw(f); + f->valid_bits = 0; + return x; +} + +static void flush_packet(vorb *f) +{ + while (get8_packet_raw(f) != EOP); +} + +// @OPTIMIZE: this is the secondary bit decoder, so it's probably not as important +// as the huffman decoder? +static uint32 get_bits(vorb *f, int n) +{ + uint32 z; + + if (f->valid_bits < 0) return 0; + if (f->valid_bits < n) { + if (n > 24) { + // the accumulator technique below would not work correctly in this case + z = get_bits(f, 24); + z += get_bits(f, n-24) << 24; + return z; + } + if (f->valid_bits == 0) f->acc = 0; + while (f->valid_bits < n) { + int z = get8_packet_raw(f); + if (z == EOP) { + f->valid_bits = INVALID_BITS; + return 0; + } + f->acc += z << f->valid_bits; + f->valid_bits += 8; + } + } + if (f->valid_bits < 0) return 0; + z = f->acc & ((1 << n)-1); + f->acc >>= n; + f->valid_bits -= n; + return z; +} + +// @OPTIMIZE: primary accumulator for huffman +// expand the buffer to as many bits as possible without reading off end of packet +// it might be nice to allow f->valid_bits and f->acc to be stored in registers, +// e.g. cache them locally and decode locally +static __forceinline void prep_huffman(vorb *f) +{ + if (f->valid_bits <= 24) { + if (f->valid_bits == 0) f->acc = 0; + do { + int z; + if (f->last_seg && !f->bytes_in_seg) return; + z = get8_packet_raw(f); + if (z == EOP) return; + f->acc += (unsigned) z << f->valid_bits; + f->valid_bits += 8; + } while (f->valid_bits <= 24); + } +} + +enum +{ + VORBIS_packet_id = 1, + VORBIS_packet_comment = 3, + VORBIS_packet_setup = 5 +}; + +static int codebook_decode_scalar_raw(vorb *f, Codebook *c) +{ + int i; + prep_huffman(f); + + if (c->codewords == NULL && c->sorted_codewords == NULL) + return -1; + + // cases to use binary search: sorted_codewords && !c->codewords + // sorted_codewords && c->entries > 8 + if (c->entries > 8 ? c->sorted_codewords!=NULL : !c->codewords) { + // binary search + uint32 code = bit_reverse(f->acc); + int x=0, n=c->sorted_entries, len; + + while (n > 1) { + // invariant: sc[x] <= code < sc[x+n] + int m = x + (n >> 1); + if (c->sorted_codewords[m] <= code) { + x = m; + n -= (n>>1); + } else { + n >>= 1; + } + } + // x is now the sorted index + if (!c->sparse) x = c->sorted_values[x]; + // x is now sorted index if sparse, or symbol otherwise + len = c->codeword_lengths[x]; + if (f->valid_bits >= len) { + f->acc >>= len; + f->valid_bits -= len; + return x; + } + + f->valid_bits = 0; + return -1; + } + + // if small, linear search + assert(!c->sparse); + for (i=0; i < c->entries; ++i) { + if (c->codeword_lengths[i] == NO_CODE) continue; + if (c->codewords[i] == (f->acc & ((1 << c->codeword_lengths[i])-1))) { + if (f->valid_bits >= c->codeword_lengths[i]) { + f->acc >>= c->codeword_lengths[i]; + f->valid_bits -= c->codeword_lengths[i]; + return i; + } + f->valid_bits = 0; + return -1; + } + } + + error(f, VORBIS_invalid_stream); + f->valid_bits = 0; + return -1; +} + +#ifndef STB_VORBIS_NO_INLINE_DECODE + +#define DECODE_RAW(var, f,c) \ + if (f->valid_bits < STB_VORBIS_FAST_HUFFMAN_LENGTH) \ + prep_huffman(f); \ + var = f->acc & FAST_HUFFMAN_TABLE_MASK; \ + var = c->fast_huffman[var]; \ + if (var >= 0) { \ + int n = c->codeword_lengths[var]; \ + f->acc >>= n; \ + f->valid_bits -= n; \ + if (f->valid_bits < 0) { f->valid_bits = 0; var = -1; } \ + } else { \ + var = codebook_decode_scalar_raw(f,c); \ + } + +#else + +static int codebook_decode_scalar(vorb *f, Codebook *c) +{ + int i; + if (f->valid_bits < STB_VORBIS_FAST_HUFFMAN_LENGTH) + prep_huffman(f); + // fast huffman table lookup + i = f->acc & FAST_HUFFMAN_TABLE_MASK; + i = c->fast_huffman[i]; + if (i >= 0) { + f->acc >>= c->codeword_lengths[i]; + f->valid_bits -= c->codeword_lengths[i]; + if (f->valid_bits < 0) { f->valid_bits = 0; return -1; } + return i; + } + return codebook_decode_scalar_raw(f,c); +} + +#define DECODE_RAW(var,f,c) var = codebook_decode_scalar(f,c); + +#endif + +#define DECODE(var,f,c) \ + DECODE_RAW(var,f,c) \ + if (c->sparse) var = c->sorted_values[var]; + +#ifndef STB_VORBIS_DIVIDES_IN_CODEBOOK + #define DECODE_VQ(var,f,c) DECODE_RAW(var,f,c) +#else + #define DECODE_VQ(var,f,c) DECODE(var,f,c) +#endif + + + + + + +// CODEBOOK_ELEMENT_FAST is an optimization for the CODEBOOK_FLOATS case +// where we avoid one addition +#define CODEBOOK_ELEMENT(c,off) (c->multiplicands[off]) +#define CODEBOOK_ELEMENT_FAST(c,off) (c->multiplicands[off]) +#define CODEBOOK_ELEMENT_BASE(c) (0) + +static int codebook_decode_start(vorb *f, Codebook *c) +{ + int z = -1; + + // type 0 is only legal in a scalar context + if (c->lookup_type == 0) + error(f, VORBIS_invalid_stream); + else { + DECODE_VQ(z,f,c); + if (c->sparse) assert(z < c->sorted_entries); + if (z < 0) { // check for EOP + if (!f->bytes_in_seg) + if (f->last_seg) + return z; + error(f, VORBIS_invalid_stream); + } + } + return z; +} + +static int codebook_decode(vorb *f, Codebook *c, float *output, int len) +{ + int i,z = codebook_decode_start(f,c); + if (z < 0) return FALSE; + if (len > c->dimensions) len = c->dimensions; + +#ifdef STB_VORBIS_DIVIDES_IN_CODEBOOK + if (c->lookup_type == 1) { + float last = CODEBOOK_ELEMENT_BASE(c); + int div = 1; + for (i=0; i < len; ++i) { + int off = (z / div) % c->lookup_values; + float val = CODEBOOK_ELEMENT_FAST(c,off) + last; + output[i] += val; + if (c->sequence_p) last = val + c->minimum_value; + div *= c->lookup_values; + } + return TRUE; + } +#endif + + z *= c->dimensions; + if (c->sequence_p) { + float last = CODEBOOK_ELEMENT_BASE(c); + for (i=0; i < len; ++i) { + float val = CODEBOOK_ELEMENT_FAST(c,z+i) + last; + output[i] += val; + last = val + c->minimum_value; + } + } else { + float last = CODEBOOK_ELEMENT_BASE(c); + for (i=0; i < len; ++i) { + output[i] += CODEBOOK_ELEMENT_FAST(c,z+i) + last; + } + } + + return TRUE; +} + +static int codebook_decode_step(vorb *f, Codebook *c, float *output, int len, int step) +{ + int i,z = codebook_decode_start(f,c); + float last = CODEBOOK_ELEMENT_BASE(c); + if (z < 0) return FALSE; + if (len > c->dimensions) len = c->dimensions; + +#ifdef STB_VORBIS_DIVIDES_IN_CODEBOOK + if (c->lookup_type == 1) { + int div = 1; + for (i=0; i < len; ++i) { + int off = (z / div) % c->lookup_values; + float val = CODEBOOK_ELEMENT_FAST(c,off) + last; + output[i*step] += val; + if (c->sequence_p) last = val; + div *= c->lookup_values; + } + return TRUE; + } +#endif + + z *= c->dimensions; + for (i=0; i < len; ++i) { + float val = CODEBOOK_ELEMENT_FAST(c,z+i) + last; + output[i*step] += val; + if (c->sequence_p) last = val; + } + + return TRUE; +} + +static int codebook_decode_deinterleave_repeat(vorb *f, Codebook *c, float **outputs, int ch, int *c_inter_p, int *p_inter_p, int len, int total_decode) +{ + int c_inter = *c_inter_p; + int p_inter = *p_inter_p; + int i,z, effective = c->dimensions; + + // type 0 is only legal in a scalar context + if (c->lookup_type == 0) return error(f, VORBIS_invalid_stream); + + while (total_decode > 0) { + float last = CODEBOOK_ELEMENT_BASE(c); + DECODE_VQ(z,f,c); + #ifndef STB_VORBIS_DIVIDES_IN_CODEBOOK + assert(!c->sparse || z < c->sorted_entries); + #endif + if (z < 0) { + if (!f->bytes_in_seg) + if (f->last_seg) return FALSE; + return error(f, VORBIS_invalid_stream); + } + + // if this will take us off the end of the buffers, stop short! + // we check by computing the length of the virtual interleaved + // buffer (len*ch), our current offset within it (p_inter*ch)+(c_inter), + // and the length we'll be using (effective) + if (c_inter + p_inter*ch + effective > len * ch) { + effective = len*ch - (p_inter*ch - c_inter); + } + + #ifdef STB_VORBIS_DIVIDES_IN_CODEBOOK + if (c->lookup_type == 1) { + int div = 1; + for (i=0; i < effective; ++i) { + int off = (z / div) % c->lookup_values; + float val = CODEBOOK_ELEMENT_FAST(c,off) + last; + if (outputs[c_inter]) + outputs[c_inter][p_inter] += val; + if (++c_inter == ch) { c_inter = 0; ++p_inter; } + if (c->sequence_p) last = val; + div *= c->lookup_values; + } + } else + #endif + { + z *= c->dimensions; + if (c->sequence_p) { + for (i=0; i < effective; ++i) { + float val = CODEBOOK_ELEMENT_FAST(c,z+i) + last; + if (outputs[c_inter]) + outputs[c_inter][p_inter] += val; + if (++c_inter == ch) { c_inter = 0; ++p_inter; } + last = val; + } + } else { + for (i=0; i < effective; ++i) { + float val = CODEBOOK_ELEMENT_FAST(c,z+i) + last; + if (outputs[c_inter]) + outputs[c_inter][p_inter] += val; + if (++c_inter == ch) { c_inter = 0; ++p_inter; } + } + } + } + + total_decode -= effective; + } + *c_inter_p = c_inter; + *p_inter_p = p_inter; + return TRUE; +} + +static int predict_point(int x, int x0, int x1, int y0, int y1) +{ + int dy = y1 - y0; + int adx = x1 - x0; + // @OPTIMIZE: force int division to round in the right direction... is this necessary on x86? + int err = abs(dy) * (x - x0); + int off = err / adx; + return dy < 0 ? y0 - off : y0 + off; +} + +// the following table is block-copied from the specification +static float inverse_db_table[256] = +{ + 1.0649863e-07f, 1.1341951e-07f, 1.2079015e-07f, 1.2863978e-07f, + 1.3699951e-07f, 1.4590251e-07f, 1.5538408e-07f, 1.6548181e-07f, + 1.7623575e-07f, 1.8768855e-07f, 1.9988561e-07f, 2.1287530e-07f, + 2.2670913e-07f, 2.4144197e-07f, 2.5713223e-07f, 2.7384213e-07f, + 2.9163793e-07f, 3.1059021e-07f, 3.3077411e-07f, 3.5226968e-07f, + 3.7516214e-07f, 3.9954229e-07f, 4.2550680e-07f, 4.5315863e-07f, + 4.8260743e-07f, 5.1396998e-07f, 5.4737065e-07f, 5.8294187e-07f, + 6.2082472e-07f, 6.6116941e-07f, 7.0413592e-07f, 7.4989464e-07f, + 7.9862701e-07f, 8.5052630e-07f, 9.0579828e-07f, 9.6466216e-07f, + 1.0273513e-06f, 1.0941144e-06f, 1.1652161e-06f, 1.2409384e-06f, + 1.3215816e-06f, 1.4074654e-06f, 1.4989305e-06f, 1.5963394e-06f, + 1.7000785e-06f, 1.8105592e-06f, 1.9282195e-06f, 2.0535261e-06f, + 2.1869758e-06f, 2.3290978e-06f, 2.4804557e-06f, 2.6416497e-06f, + 2.8133190e-06f, 2.9961443e-06f, 3.1908506e-06f, 3.3982101e-06f, + 3.6190449e-06f, 3.8542308e-06f, 4.1047004e-06f, 4.3714470e-06f, + 4.6555282e-06f, 4.9580707e-06f, 5.2802740e-06f, 5.6234160e-06f, + 5.9888572e-06f, 6.3780469e-06f, 6.7925283e-06f, 7.2339451e-06f, + 7.7040476e-06f, 8.2047000e-06f, 8.7378876e-06f, 9.3057248e-06f, + 9.9104632e-06f, 1.0554501e-05f, 1.1240392e-05f, 1.1970856e-05f, + 1.2748789e-05f, 1.3577278e-05f, 1.4459606e-05f, 1.5399272e-05f, + 1.6400004e-05f, 1.7465768e-05f, 1.8600792e-05f, 1.9809576e-05f, + 2.1096914e-05f, 2.2467911e-05f, 2.3928002e-05f, 2.5482978e-05f, + 2.7139006e-05f, 2.8902651e-05f, 3.0780908e-05f, 3.2781225e-05f, + 3.4911534e-05f, 3.7180282e-05f, 3.9596466e-05f, 4.2169667e-05f, + 4.4910090e-05f, 4.7828601e-05f, 5.0936773e-05f, 5.4246931e-05f, + 5.7772202e-05f, 6.1526565e-05f, 6.5524908e-05f, 6.9783085e-05f, + 7.4317983e-05f, 7.9147585e-05f, 8.4291040e-05f, 8.9768747e-05f, + 9.5602426e-05f, 0.00010181521f, 0.00010843174f, 0.00011547824f, + 0.00012298267f, 0.00013097477f, 0.00013948625f, 0.00014855085f, + 0.00015820453f, 0.00016848555f, 0.00017943469f, 0.00019109536f, + 0.00020351382f, 0.00021673929f, 0.00023082423f, 0.00024582449f, + 0.00026179955f, 0.00027881276f, 0.00029693158f, 0.00031622787f, + 0.00033677814f, 0.00035866388f, 0.00038197188f, 0.00040679456f, + 0.00043323036f, 0.00046138411f, 0.00049136745f, 0.00052329927f, + 0.00055730621f, 0.00059352311f, 0.00063209358f, 0.00067317058f, + 0.00071691700f, 0.00076350630f, 0.00081312324f, 0.00086596457f, + 0.00092223983f, 0.00098217216f, 0.0010459992f, 0.0011139742f, + 0.0011863665f, 0.0012634633f, 0.0013455702f, 0.0014330129f, + 0.0015261382f, 0.0016253153f, 0.0017309374f, 0.0018434235f, + 0.0019632195f, 0.0020908006f, 0.0022266726f, 0.0023713743f, + 0.0025254795f, 0.0026895994f, 0.0028643847f, 0.0030505286f, + 0.0032487691f, 0.0034598925f, 0.0036847358f, 0.0039241906f, + 0.0041792066f, 0.0044507950f, 0.0047400328f, 0.0050480668f, + 0.0053761186f, 0.0057254891f, 0.0060975636f, 0.0064938176f, + 0.0069158225f, 0.0073652516f, 0.0078438871f, 0.0083536271f, + 0.0088964928f, 0.009474637f, 0.010090352f, 0.010746080f, + 0.011444421f, 0.012188144f, 0.012980198f, 0.013823725f, + 0.014722068f, 0.015678791f, 0.016697687f, 0.017782797f, + 0.018938423f, 0.020169149f, 0.021479854f, 0.022875735f, + 0.024362330f, 0.025945531f, 0.027631618f, 0.029427276f, + 0.031339626f, 0.033376252f, 0.035545228f, 0.037855157f, + 0.040315199f, 0.042935108f, 0.045725273f, 0.048696758f, + 0.051861348f, 0.055231591f, 0.058820850f, 0.062643361f, + 0.066714279f, 0.071049749f, 0.075666962f, 0.080584227f, + 0.085821044f, 0.091398179f, 0.097337747f, 0.10366330f, + 0.11039993f, 0.11757434f, 0.12521498f, 0.13335215f, + 0.14201813f, 0.15124727f, 0.16107617f, 0.17154380f, + 0.18269168f, 0.19456402f, 0.20720788f, 0.22067342f, + 0.23501402f, 0.25028656f, 0.26655159f, 0.28387361f, + 0.30232132f, 0.32196786f, 0.34289114f, 0.36517414f, + 0.38890521f, 0.41417847f, 0.44109412f, 0.46975890f, + 0.50028648f, 0.53279791f, 0.56742212f, 0.60429640f, + 0.64356699f, 0.68538959f, 0.72993007f, 0.77736504f, + 0.82788260f, 0.88168307f, 0.9389798f, 1.0f +}; + + +// @OPTIMIZE: if you want to replace this bresenham line-drawing routine, +// note that you must produce bit-identical output to decode correctly; +// this specific sequence of operations is specified in the spec (it's +// drawing integer-quantized frequency-space lines that the encoder +// expects to be exactly the same) +// ... also, isn't the whole point of Bresenham's algorithm to NOT +// have to divide in the setup? sigh. +#ifndef STB_VORBIS_NO_DEFER_FLOOR +#define LINE_OP(a,b) a *= b +#else +#define LINE_OP(a,b) a = b +#endif + +#ifdef STB_VORBIS_DIVIDE_TABLE +#define DIVTAB_NUMER 32 +#define DIVTAB_DENOM 64 +int8 integer_divide_table[DIVTAB_NUMER][DIVTAB_DENOM]; // 2KB +#endif + +static __forceinline void draw_line(float *output, int x0, int y0, int x1, int y1, int n) +{ + int dy = y1 - y0; + int adx = x1 - x0; + int ady = abs(dy); + int base; + int x=x0,y=y0; + int err = 0; + int sy; + +#ifdef STB_VORBIS_DIVIDE_TABLE + if (adx < DIVTAB_DENOM && ady < DIVTAB_NUMER) { + if (dy < 0) { + base = -integer_divide_table[ady][adx]; + sy = base-1; + } else { + base = integer_divide_table[ady][adx]; + sy = base+1; + } + } else { + base = dy / adx; + if (dy < 0) + sy = base - 1; + else + sy = base+1; + } +#else + base = dy / adx; + if (dy < 0) + sy = base - 1; + else + sy = base+1; +#endif + ady -= abs(base) * adx; + if (x1 > n) x1 = n; + if (x < x1) { + LINE_OP(output[x], inverse_db_table[y]); + for (++x; x < x1; ++x) { + err += ady; + if (err >= adx) { + err -= adx; + y += sy; + } else + y += base; + LINE_OP(output[x], inverse_db_table[y]); + } + } +} + +static int residue_decode(vorb *f, Codebook *book, float *target, int offset, int n, int rtype) +{ + int k; + if (rtype == 0) { + int step = n / book->dimensions; + for (k=0; k < step; ++k) + if (!codebook_decode_step(f, book, target+offset+k, n-offset-k, step)) + return FALSE; + } else { + for (k=0; k < n; ) { + if (!codebook_decode(f, book, target+offset, n-k)) + return FALSE; + k += book->dimensions; + offset += book->dimensions; + } + } + return TRUE; +} + +// n is 1/2 of the blocksize -- +// specification: "Correct per-vector decode length is [n]/2" +static void decode_residue(vorb *f, float *residue_buffers[], int ch, int n, int rn, uint8 *do_not_decode) +{ + int i,j,pass; + Residue *r = f->residue_config + rn; + int rtype = f->residue_types[rn]; + int c = r->classbook; + int classwords = f->codebooks[c].dimensions; + unsigned int actual_size = rtype == 2 ? n*2 : n; + unsigned int limit_r_begin = (r->begin < actual_size ? r->begin : actual_size); + unsigned int limit_r_end = (r->end < actual_size ? r->end : actual_size); + int n_read = limit_r_end - limit_r_begin; + int part_read = n_read / r->part_size; + int temp_alloc_point = temp_alloc_save(f); + #ifndef STB_VORBIS_DIVIDES_IN_RESIDUE + uint8 ***part_classdata = (uint8 ***) temp_block_array(f,f->channels, part_read * sizeof(**part_classdata)); + #else + int **classifications = (int **) temp_block_array(f,f->channels, part_read * sizeof(**classifications)); + #endif + + CHECK(f); + + for (i=0; i < ch; ++i) + if (!do_not_decode[i]) + memset(residue_buffers[i], 0, sizeof(float) * n); + + if (rtype == 2 && ch != 1) { + for (j=0; j < ch; ++j) + if (!do_not_decode[j]) + break; + if (j == ch) + goto done; + + for (pass=0; pass < 8; ++pass) { + int pcount = 0, class_set = 0; + if (ch == 2) { + while (pcount < part_read) { + int z = r->begin + pcount*r->part_size; + int c_inter = (z & 1), p_inter = z>>1; + if (pass == 0) { + Codebook *c = f->codebooks+r->classbook; + int q; + DECODE(q,f,c); + if (q == EOP) goto done; + #ifndef STB_VORBIS_DIVIDES_IN_RESIDUE + part_classdata[0][class_set] = r->classdata[q]; + #else + for (i=classwords-1; i >= 0; --i) { + classifications[0][i+pcount] = q % r->classifications; + q /= r->classifications; + } + #endif + } + for (i=0; i < classwords && pcount < part_read; ++i, ++pcount) { + int z = r->begin + pcount*r->part_size; + #ifndef STB_VORBIS_DIVIDES_IN_RESIDUE + int c = part_classdata[0][class_set][i]; + #else + int c = classifications[0][pcount]; + #endif + int b = r->residue_books[c][pass]; + if (b >= 0) { + Codebook *book = f->codebooks + b; + #ifdef STB_VORBIS_DIVIDES_IN_CODEBOOK + if (!codebook_decode_deinterleave_repeat(f, book, residue_buffers, ch, &c_inter, &p_inter, n, r->part_size)) + goto done; + #else + // saves 1% + if (!codebook_decode_deinterleave_repeat(f, book, residue_buffers, ch, &c_inter, &p_inter, n, r->part_size)) + goto done; + #endif + } else { + z += r->part_size; + c_inter = z & 1; + p_inter = z >> 1; + } + } + #ifndef STB_VORBIS_DIVIDES_IN_RESIDUE + ++class_set; + #endif + } + } else if (ch == 1) { + while (pcount < part_read) { + int z = r->begin + pcount*r->part_size; + int c_inter = 0, p_inter = z; + if (pass == 0) { + Codebook *c = f->codebooks+r->classbook; + int q; + DECODE(q,f,c); + if (q == EOP) goto done; + #ifndef STB_VORBIS_DIVIDES_IN_RESIDUE + part_classdata[0][class_set] = r->classdata[q]; + #else + for (i=classwords-1; i >= 0; --i) { + classifications[0][i+pcount] = q % r->classifications; + q /= r->classifications; + } + #endif + } + for (i=0; i < classwords && pcount < part_read; ++i, ++pcount) { + int z = r->begin + pcount*r->part_size; + #ifndef STB_VORBIS_DIVIDES_IN_RESIDUE + int c = part_classdata[0][class_set][i]; + #else + int c = classifications[0][pcount]; + #endif + int b = r->residue_books[c][pass]; + if (b >= 0) { + Codebook *book = f->codebooks + b; + if (!codebook_decode_deinterleave_repeat(f, book, residue_buffers, ch, &c_inter, &p_inter, n, r->part_size)) + goto done; + } else { + z += r->part_size; + c_inter = 0; + p_inter = z; + } + } + #ifndef STB_VORBIS_DIVIDES_IN_RESIDUE + ++class_set; + #endif + } + } else { + while (pcount < part_read) { + int z = r->begin + pcount*r->part_size; + int c_inter = z % ch, p_inter = z/ch; + if (pass == 0) { + Codebook *c = f->codebooks+r->classbook; + int q; + DECODE(q,f,c); + if (q == EOP) goto done; + #ifndef STB_VORBIS_DIVIDES_IN_RESIDUE + part_classdata[0][class_set] = r->classdata[q]; + #else + for (i=classwords-1; i >= 0; --i) { + classifications[0][i+pcount] = q % r->classifications; + q /= r->classifications; + } + #endif + } + for (i=0; i < classwords && pcount < part_read; ++i, ++pcount) { + int z = r->begin + pcount*r->part_size; + #ifndef STB_VORBIS_DIVIDES_IN_RESIDUE + int c = part_classdata[0][class_set][i]; + #else + int c = classifications[0][pcount]; + #endif + int b = r->residue_books[c][pass]; + if (b >= 0) { + Codebook *book = f->codebooks + b; + if (!codebook_decode_deinterleave_repeat(f, book, residue_buffers, ch, &c_inter, &p_inter, n, r->part_size)) + goto done; + } else { + z += r->part_size; + c_inter = z % ch; + p_inter = z / ch; + } + } + #ifndef STB_VORBIS_DIVIDES_IN_RESIDUE + ++class_set; + #endif + } + } + } + goto done; + } + CHECK(f); + + for (pass=0; pass < 8; ++pass) { + int pcount = 0, class_set=0; + while (pcount < part_read) { + if (pass == 0) { + for (j=0; j < ch; ++j) { + if (!do_not_decode[j]) { + Codebook *c = f->codebooks+r->classbook; + int temp; + DECODE(temp,f,c); + if (temp == EOP) goto done; + #ifndef STB_VORBIS_DIVIDES_IN_RESIDUE + part_classdata[j][class_set] = r->classdata[temp]; + #else + for (i=classwords-1; i >= 0; --i) { + classifications[j][i+pcount] = temp % r->classifications; + temp /= r->classifications; + } + #endif + } + } + } + for (i=0; i < classwords && pcount < part_read; ++i, ++pcount) { + for (j=0; j < ch; ++j) { + if (!do_not_decode[j]) { + #ifndef STB_VORBIS_DIVIDES_IN_RESIDUE + int c = part_classdata[j][class_set][i]; + #else + int c = classifications[j][pcount]; + #endif + int b = r->residue_books[c][pass]; + if (b >= 0) { + float *target = residue_buffers[j]; + int offset = r->begin + pcount * r->part_size; + int n = r->part_size; + Codebook *book = f->codebooks + b; + if (!residue_decode(f, book, target, offset, n, rtype)) + goto done; + } + } + } + } + #ifndef STB_VORBIS_DIVIDES_IN_RESIDUE + ++class_set; + #endif + } + } + done: + CHECK(f); + #ifndef STB_VORBIS_DIVIDES_IN_RESIDUE + temp_free(f,part_classdata); + #else + temp_free(f,classifications); + #endif + temp_alloc_restore(f,temp_alloc_point); +} + + +#if 0 +// slow way for debugging +void inverse_mdct_slow(float *buffer, int n) +{ + int i,j; + int n2 = n >> 1; + float *x = (float *) malloc(sizeof(*x) * n2); + memcpy(x, buffer, sizeof(*x) * n2); + for (i=0; i < n; ++i) { + float acc = 0; + for (j=0; j < n2; ++j) + // formula from paper: + //acc += n/4.0f * x[j] * (float) cos(M_PI / 2 / n * (2 * i + 1 + n/2.0)*(2*j+1)); + // formula from wikipedia + //acc += 2.0f / n2 * x[j] * (float) cos(M_PI/n2 * (i + 0.5 + n2/2)*(j + 0.5)); + // these are equivalent, except the formula from the paper inverts the multiplier! + // however, what actually works is NO MULTIPLIER!?! + //acc += 64 * 2.0f / n2 * x[j] * (float) cos(M_PI/n2 * (i + 0.5 + n2/2)*(j + 0.5)); + acc += x[j] * (float) cos(M_PI / 2 / n * (2 * i + 1 + n/2.0)*(2*j+1)); + buffer[i] = acc; + } + free(x); +} +#elif 0 +// same as above, but just barely able to run in real time on modern machines +void inverse_mdct_slow(float *buffer, int n, vorb *f, int blocktype) +{ + float mcos[16384]; + int i,j; + int n2 = n >> 1, nmask = (n << 2) -1; + float *x = (float *) malloc(sizeof(*x) * n2); + memcpy(x, buffer, sizeof(*x) * n2); + for (i=0; i < 4*n; ++i) + mcos[i] = (float) cos(M_PI / 2 * i / n); + + for (i=0; i < n; ++i) { + float acc = 0; + for (j=0; j < n2; ++j) + acc += x[j] * mcos[(2 * i + 1 + n2)*(2*j+1) & nmask]; + buffer[i] = acc; + } + free(x); +} +#elif 0 +// transform to use a slow dct-iv; this is STILL basically trivial, +// but only requires half as many ops +void dct_iv_slow(float *buffer, int n) +{ + float mcos[16384]; + float x[2048]; + int i,j; + int n2 = n >> 1, nmask = (n << 3) - 1; + memcpy(x, buffer, sizeof(*x) * n); + for (i=0; i < 8*n; ++i) + mcos[i] = (float) cos(M_PI / 4 * i / n); + for (i=0; i < n; ++i) { + float acc = 0; + for (j=0; j < n; ++j) + acc += x[j] * mcos[((2 * i + 1)*(2*j+1)) & nmask]; + buffer[i] = acc; + } +} + +void inverse_mdct_slow(float *buffer, int n, vorb *f, int blocktype) +{ + int i, n4 = n >> 2, n2 = n >> 1, n3_4 = n - n4; + float temp[4096]; + + memcpy(temp, buffer, n2 * sizeof(float)); + dct_iv_slow(temp, n2); // returns -c'-d, a-b' + + for (i=0; i < n4 ; ++i) buffer[i] = temp[i+n4]; // a-b' + for ( ; i < n3_4; ++i) buffer[i] = -temp[n3_4 - i - 1]; // b-a', c+d' + for ( ; i < n ; ++i) buffer[i] = -temp[i - n3_4]; // c'+d +} +#endif + +#ifndef LIBVORBIS_MDCT +#define LIBVORBIS_MDCT 0 +#endif + +#if LIBVORBIS_MDCT +// directly call the vorbis MDCT using an interface documented +// by Jeff Roberts... useful for performance comparison +typedef struct +{ + int n; + int log2n; + + float *trig; + int *bitrev; + + float scale; +} mdct_lookup; + +extern void mdct_init(mdct_lookup *lookup, int n); +extern void mdct_clear(mdct_lookup *l); +extern void mdct_backward(mdct_lookup *init, float *in, float *out); + +mdct_lookup M1,M2; + +void inverse_mdct(float *buffer, int n, vorb *f, int blocktype) +{ + mdct_lookup *M; + if (M1.n == n) M = &M1; + else if (M2.n == n) M = &M2; + else if (M1.n == 0) { mdct_init(&M1, n); M = &M1; } + else { + if (M2.n) __asm int 3; + mdct_init(&M2, n); + M = &M2; + } + + mdct_backward(M, buffer, buffer); +} +#endif + + +// the following were split out into separate functions while optimizing; +// they could be pushed back up but eh. __forceinline showed no change; +// they're probably already being inlined. +static void imdct_step3_iter0_loop(int n, float *e, int i_off, int k_off, float *A) +{ + float *ee0 = e + i_off; + float *ee2 = ee0 + k_off; + int i; + + assert((n & 3) == 0); + for (i=(n>>2); i > 0; --i) { + float k00_20, k01_21; + k00_20 = ee0[ 0] - ee2[ 0]; + k01_21 = ee0[-1] - ee2[-1]; + ee0[ 0] += ee2[ 0];//ee0[ 0] = ee0[ 0] + ee2[ 0]; + ee0[-1] += ee2[-1];//ee0[-1] = ee0[-1] + ee2[-1]; + ee2[ 0] = k00_20 * A[0] - k01_21 * A[1]; + ee2[-1] = k01_21 * A[0] + k00_20 * A[1]; + A += 8; + + k00_20 = ee0[-2] - ee2[-2]; + k01_21 = ee0[-3] - ee2[-3]; + ee0[-2] += ee2[-2];//ee0[-2] = ee0[-2] + ee2[-2]; + ee0[-3] += ee2[-3];//ee0[-3] = ee0[-3] + ee2[-3]; + ee2[-2] = k00_20 * A[0] - k01_21 * A[1]; + ee2[-3] = k01_21 * A[0] + k00_20 * A[1]; + A += 8; + + k00_20 = ee0[-4] - ee2[-4]; + k01_21 = ee0[-5] - ee2[-5]; + ee0[-4] += ee2[-4];//ee0[-4] = ee0[-4] + ee2[-4]; + ee0[-5] += ee2[-5];//ee0[-5] = ee0[-5] + ee2[-5]; + ee2[-4] = k00_20 * A[0] - k01_21 * A[1]; + ee2[-5] = k01_21 * A[0] + k00_20 * A[1]; + A += 8; + + k00_20 = ee0[-6] - ee2[-6]; + k01_21 = ee0[-7] - ee2[-7]; + ee0[-6] += ee2[-6];//ee0[-6] = ee0[-6] + ee2[-6]; + ee0[-7] += ee2[-7];//ee0[-7] = ee0[-7] + ee2[-7]; + ee2[-6] = k00_20 * A[0] - k01_21 * A[1]; + ee2[-7] = k01_21 * A[0] + k00_20 * A[1]; + A += 8; + ee0 -= 8; + ee2 -= 8; + } +} + +static void imdct_step3_inner_r_loop(int lim, float *e, int d0, int k_off, float *A, int k1) +{ + int i; + float k00_20, k01_21; + + float *e0 = e + d0; + float *e2 = e0 + k_off; + + for (i=lim >> 2; i > 0; --i) { + k00_20 = e0[-0] - e2[-0]; + k01_21 = e0[-1] - e2[-1]; + e0[-0] += e2[-0];//e0[-0] = e0[-0] + e2[-0]; + e0[-1] += e2[-1];//e0[-1] = e0[-1] + e2[-1]; + e2[-0] = (k00_20)*A[0] - (k01_21) * A[1]; + e2[-1] = (k01_21)*A[0] + (k00_20) * A[1]; + + A += k1; + + k00_20 = e0[-2] - e2[-2]; + k01_21 = e0[-3] - e2[-3]; + e0[-2] += e2[-2];//e0[-2] = e0[-2] + e2[-2]; + e0[-3] += e2[-3];//e0[-3] = e0[-3] + e2[-3]; + e2[-2] = (k00_20)*A[0] - (k01_21) * A[1]; + e2[-3] = (k01_21)*A[0] + (k00_20) * A[1]; + + A += k1; + + k00_20 = e0[-4] - e2[-4]; + k01_21 = e0[-5] - e2[-5]; + e0[-4] += e2[-4];//e0[-4] = e0[-4] + e2[-4]; + e0[-5] += e2[-5];//e0[-5] = e0[-5] + e2[-5]; + e2[-4] = (k00_20)*A[0] - (k01_21) * A[1]; + e2[-5] = (k01_21)*A[0] + (k00_20) * A[1]; + + A += k1; + + k00_20 = e0[-6] - e2[-6]; + k01_21 = e0[-7] - e2[-7]; + e0[-6] += e2[-6];//e0[-6] = e0[-6] + e2[-6]; + e0[-7] += e2[-7];//e0[-7] = e0[-7] + e2[-7]; + e2[-6] = (k00_20)*A[0] - (k01_21) * A[1]; + e2[-7] = (k01_21)*A[0] + (k00_20) * A[1]; + + e0 -= 8; + e2 -= 8; + + A += k1; + } +} + +static void imdct_step3_inner_s_loop(int n, float *e, int i_off, int k_off, float *A, int a_off, int k0) +{ + int i; + float A0 = A[0]; + float A1 = A[0+1]; + float A2 = A[0+a_off]; + float A3 = A[0+a_off+1]; + float A4 = A[0+a_off*2+0]; + float A5 = A[0+a_off*2+1]; + float A6 = A[0+a_off*3+0]; + float A7 = A[0+a_off*3+1]; + + float k00,k11; + + float *ee0 = e +i_off; + float *ee2 = ee0+k_off; + + for (i=n; i > 0; --i) { + k00 = ee0[ 0] - ee2[ 0]; + k11 = ee0[-1] - ee2[-1]; + ee0[ 0] = ee0[ 0] + ee2[ 0]; + ee0[-1] = ee0[-1] + ee2[-1]; + ee2[ 0] = (k00) * A0 - (k11) * A1; + ee2[-1] = (k11) * A0 + (k00) * A1; + + k00 = ee0[-2] - ee2[-2]; + k11 = ee0[-3] - ee2[-3]; + ee0[-2] = ee0[-2] + ee2[-2]; + ee0[-3] = ee0[-3] + ee2[-3]; + ee2[-2] = (k00) * A2 - (k11) * A3; + ee2[-3] = (k11) * A2 + (k00) * A3; + + k00 = ee0[-4] - ee2[-4]; + k11 = ee0[-5] - ee2[-5]; + ee0[-4] = ee0[-4] + ee2[-4]; + ee0[-5] = ee0[-5] + ee2[-5]; + ee2[-4] = (k00) * A4 - (k11) * A5; + ee2[-5] = (k11) * A4 + (k00) * A5; + + k00 = ee0[-6] - ee2[-6]; + k11 = ee0[-7] - ee2[-7]; + ee0[-6] = ee0[-6] + ee2[-6]; + ee0[-7] = ee0[-7] + ee2[-7]; + ee2[-6] = (k00) * A6 - (k11) * A7; + ee2[-7] = (k11) * A6 + (k00) * A7; + + ee0 -= k0; + ee2 -= k0; + } +} + +static __forceinline void iter_54(float *z) +{ + float k00,k11,k22,k33; + float y0,y1,y2,y3; + + k00 = z[ 0] - z[-4]; + y0 = z[ 0] + z[-4]; + y2 = z[-2] + z[-6]; + k22 = z[-2] - z[-6]; + + z[-0] = y0 + y2; // z0 + z4 + z2 + z6 + z[-2] = y0 - y2; // z0 + z4 - z2 - z6 + + // done with y0,y2 + + k33 = z[-3] - z[-7]; + + z[-4] = k00 + k33; // z0 - z4 + z3 - z7 + z[-6] = k00 - k33; // z0 - z4 - z3 + z7 + + // done with k33 + + k11 = z[-1] - z[-5]; + y1 = z[-1] + z[-5]; + y3 = z[-3] + z[-7]; + + z[-1] = y1 + y3; // z1 + z5 + z3 + z7 + z[-3] = y1 - y3; // z1 + z5 - z3 - z7 + z[-5] = k11 - k22; // z1 - z5 + z2 - z6 + z[-7] = k11 + k22; // z1 - z5 - z2 + z6 +} + +static void imdct_step3_inner_s_loop_ld654(int n, float *e, int i_off, float *A, int base_n) +{ + int a_off = base_n >> 3; + float A2 = A[0+a_off]; + float *z = e + i_off; + float *base = z - 16 * n; + + while (z > base) { + float k00,k11; + + k00 = z[-0] - z[-8]; + k11 = z[-1] - z[-9]; + z[-0] = z[-0] + z[-8]; + z[-1] = z[-1] + z[-9]; + z[-8] = k00; + z[-9] = k11 ; + + k00 = z[ -2] - z[-10]; + k11 = z[ -3] - z[-11]; + z[ -2] = z[ -2] + z[-10]; + z[ -3] = z[ -3] + z[-11]; + z[-10] = (k00+k11) * A2; + z[-11] = (k11-k00) * A2; + + k00 = z[-12] - z[ -4]; // reverse to avoid a unary negation + k11 = z[ -5] - z[-13]; + z[ -4] = z[ -4] + z[-12]; + z[ -5] = z[ -5] + z[-13]; + z[-12] = k11; + z[-13] = k00; + + k00 = z[-14] - z[ -6]; // reverse to avoid a unary negation + k11 = z[ -7] - z[-15]; + z[ -6] = z[ -6] + z[-14]; + z[ -7] = z[ -7] + z[-15]; + z[-14] = (k00+k11) * A2; + z[-15] = (k00-k11) * A2; + + iter_54(z); + iter_54(z-8); + z -= 16; + } +} + +static void inverse_mdct(float *buffer, int n, vorb *f, int blocktype) +{ + int n2 = n >> 1, n4 = n >> 2, n8 = n >> 3, l; + int ld; + // @OPTIMIZE: reduce register pressure by using fewer variables? + int save_point = temp_alloc_save(f); + float *buf2 = (float *) temp_alloc(f, n2 * sizeof(*buf2)); + float *u=NULL,*v=NULL; + // twiddle factors + float *A = f->A[blocktype]; + + // IMDCT algorithm from "The use of multirate filter banks for coding of high quality digital audio" + // See notes about bugs in that paper in less-optimal implementation 'inverse_mdct_old' after this function. + + // kernel from paper + + + // merged: + // copy and reflect spectral data + // step 0 + + // note that it turns out that the items added together during + // this step are, in fact, being added to themselves (as reflected + // by step 0). inexplicable inefficiency! this became obvious + // once I combined the passes. + + // so there's a missing 'times 2' here (for adding X to itself). + // this propogates through linearly to the end, where the numbers + // are 1/2 too small, and need to be compensated for. + + { + float *d,*e, *AA, *e_stop; + d = &buf2[n2-2]; + AA = A; + e = &buffer[0]; + e_stop = &buffer[n2]; + while (e != e_stop) { + d[1] = (e[0] * AA[0] - e[2]*AA[1]); + d[0] = (e[0] * AA[1] + e[2]*AA[0]); + d -= 2; + AA += 2; + e += 4; + } + + e = &buffer[n2-3]; + while (d >= buf2) { + d[1] = (-e[2] * AA[0] - -e[0]*AA[1]); + d[0] = (-e[2] * AA[1] + -e[0]*AA[0]); + d -= 2; + AA += 2; + e -= 4; + } + } + + // now we use symbolic names for these, so that we can + // possibly swap their meaning as we change which operations + // are in place + + u = buffer; + v = buf2; + + // step 2 (paper output is w, now u) + // this could be in place, but the data ends up in the wrong + // place... _somebody_'s got to swap it, so this is nominated + { + float *AA = &A[n2-8]; + float *d0,*d1, *e0, *e1; + + e0 = &v[n4]; + e1 = &v[0]; + + d0 = &u[n4]; + d1 = &u[0]; + + while (AA >= A) { + float v40_20, v41_21; + + v41_21 = e0[1] - e1[1]; + v40_20 = e0[0] - e1[0]; + d0[1] = e0[1] + e1[1]; + d0[0] = e0[0] + e1[0]; + d1[1] = v41_21*AA[4] - v40_20*AA[5]; + d1[0] = v40_20*AA[4] + v41_21*AA[5]; + + v41_21 = e0[3] - e1[3]; + v40_20 = e0[2] - e1[2]; + d0[3] = e0[3] + e1[3]; + d0[2] = e0[2] + e1[2]; + d1[3] = v41_21*AA[0] - v40_20*AA[1]; + d1[2] = v40_20*AA[0] + v41_21*AA[1]; + + AA -= 8; + + d0 += 4; + d1 += 4; + e0 += 4; + e1 += 4; + } + } + + // step 3 + ld = ilog(n) - 1; // ilog is off-by-one from normal definitions + + // optimized step 3: + + // the original step3 loop can be nested r inside s or s inside r; + // it's written originally as s inside r, but this is dumb when r + // iterates many times, and s few. So I have two copies of it and + // switch between them halfway. + + // this is iteration 0 of step 3 + imdct_step3_iter0_loop(n >> 4, u, n2-1-n4*0, -(n >> 3), A); + imdct_step3_iter0_loop(n >> 4, u, n2-1-n4*1, -(n >> 3), A); + + // this is iteration 1 of step 3 + imdct_step3_inner_r_loop(n >> 5, u, n2-1 - n8*0, -(n >> 4), A, 16); + imdct_step3_inner_r_loop(n >> 5, u, n2-1 - n8*1, -(n >> 4), A, 16); + imdct_step3_inner_r_loop(n >> 5, u, n2-1 - n8*2, -(n >> 4), A, 16); + imdct_step3_inner_r_loop(n >> 5, u, n2-1 - n8*3, -(n >> 4), A, 16); + + l=2; + for (; l < (ld-3)>>1; ++l) { + int k0 = n >> (l+2), k0_2 = k0>>1; + int lim = 1 << (l+1); + int i; + for (i=0; i < lim; ++i) + imdct_step3_inner_r_loop(n >> (l+4), u, n2-1 - k0*i, -k0_2, A, 1 << (l+3)); + } + + for (; l < ld-6; ++l) { + int k0 = n >> (l+2), k1 = 1 << (l+3), k0_2 = k0>>1; + int rlim = n >> (l+6), r; + int lim = 1 << (l+1); + int i_off; + float *A0 = A; + i_off = n2-1; + for (r=rlim; r > 0; --r) { + imdct_step3_inner_s_loop(lim, u, i_off, -k0_2, A0, k1, k0); + A0 += k1*4; + i_off -= 8; + } + } + + // iterations with count: + // ld-6,-5,-4 all interleaved together + // the big win comes from getting rid of needless flops + // due to the constants on pass 5 & 4 being all 1 and 0; + // combining them to be simultaneous to improve cache made little difference + imdct_step3_inner_s_loop_ld654(n >> 5, u, n2-1, A, n); + + // output is u + + // step 4, 5, and 6 + // cannot be in-place because of step 5 + { + uint16 *bitrev = f->bit_reverse[blocktype]; + // weirdly, I'd have thought reading sequentially and writing + // erratically would have been better than vice-versa, but in + // fact that's not what my testing showed. (That is, with + // j = bitreverse(i), do you read i and write j, or read j and write i.) + + float *d0 = &v[n4-4]; + float *d1 = &v[n2-4]; + while (d0 >= v) { + int k4; + + k4 = bitrev[0]; + d1[3] = u[k4+0]; + d1[2] = u[k4+1]; + d0[3] = u[k4+2]; + d0[2] = u[k4+3]; + + k4 = bitrev[1]; + d1[1] = u[k4+0]; + d1[0] = u[k4+1]; + d0[1] = u[k4+2]; + d0[0] = u[k4+3]; + + d0 -= 4; + d1 -= 4; + bitrev += 2; + } + } + // (paper output is u, now v) + + + // data must be in buf2 + assert(v == buf2); + + // step 7 (paper output is v, now v) + // this is now in place + { + float *C = f->C[blocktype]; + float *d, *e; + + d = v; + e = v + n2 - 4; + + while (d < e) { + float a02,a11,b0,b1,b2,b3; + + a02 = d[0] - e[2]; + a11 = d[1] + e[3]; + + b0 = C[1]*a02 + C[0]*a11; + b1 = C[1]*a11 - C[0]*a02; + + b2 = d[0] + e[ 2]; + b3 = d[1] - e[ 3]; + + d[0] = b2 + b0; + d[1] = b3 + b1; + e[2] = b2 - b0; + e[3] = b1 - b3; + + a02 = d[2] - e[0]; + a11 = d[3] + e[1]; + + b0 = C[3]*a02 + C[2]*a11; + b1 = C[3]*a11 - C[2]*a02; + + b2 = d[2] + e[ 0]; + b3 = d[3] - e[ 1]; + + d[2] = b2 + b0; + d[3] = b3 + b1; + e[0] = b2 - b0; + e[1] = b1 - b3; + + C += 4; + d += 4; + e -= 4; + } + } + + // data must be in buf2 + + + // step 8+decode (paper output is X, now buffer) + // this generates pairs of data a la 8 and pushes them directly through + // the decode kernel (pushing rather than pulling) to avoid having + // to make another pass later + + // this cannot POSSIBLY be in place, so we refer to the buffers directly + + { + float *d0,*d1,*d2,*d3; + + float *B = f->B[blocktype] + n2 - 8; + float *e = buf2 + n2 - 8; + d0 = &buffer[0]; + d1 = &buffer[n2-4]; + d2 = &buffer[n2]; + d3 = &buffer[n-4]; + while (e >= v) { + float p0,p1,p2,p3; + + p3 = e[6]*B[7] - e[7]*B[6]; + p2 = -e[6]*B[6] - e[7]*B[7]; + + d0[0] = p3; + d1[3] = - p3; + d2[0] = p2; + d3[3] = p2; + + p1 = e[4]*B[5] - e[5]*B[4]; + p0 = -e[4]*B[4] - e[5]*B[5]; + + d0[1] = p1; + d1[2] = - p1; + d2[1] = p0; + d3[2] = p0; + + p3 = e[2]*B[3] - e[3]*B[2]; + p2 = -e[2]*B[2] - e[3]*B[3]; + + d0[2] = p3; + d1[1] = - p3; + d2[2] = p2; + d3[1] = p2; + + p1 = e[0]*B[1] - e[1]*B[0]; + p0 = -e[0]*B[0] - e[1]*B[1]; + + d0[3] = p1; + d1[0] = - p1; + d2[3] = p0; + d3[0] = p0; + + B -= 8; + e -= 8; + d0 += 4; + d2 += 4; + d1 -= 4; + d3 -= 4; + } + } + + temp_free(f,buf2); + temp_alloc_restore(f,save_point); +} + +#if 0 +// this is the original version of the above code, if you want to optimize it from scratch +void inverse_mdct_naive(float *buffer, int n) +{ + float s; + float A[1 << 12], B[1 << 12], C[1 << 11]; + int i,k,k2,k4, n2 = n >> 1, n4 = n >> 2, n8 = n >> 3, l; + int n3_4 = n - n4, ld; + // how can they claim this only uses N words?! + // oh, because they're only used sparsely, whoops + float u[1 << 13], X[1 << 13], v[1 << 13], w[1 << 13]; + // set up twiddle factors + + for (k=k2=0; k < n4; ++k,k2+=2) { + A[k2 ] = (float) cos(4*k*M_PI/n); + A[k2+1] = (float) -sin(4*k*M_PI/n); + B[k2 ] = (float) cos((k2+1)*M_PI/n/2); + B[k2+1] = (float) sin((k2+1)*M_PI/n/2); + } + for (k=k2=0; k < n8; ++k,k2+=2) { + C[k2 ] = (float) cos(2*(k2+1)*M_PI/n); + C[k2+1] = (float) -sin(2*(k2+1)*M_PI/n); + } + + // IMDCT algorithm from "The use of multirate filter banks for coding of high quality digital audio" + // Note there are bugs in that pseudocode, presumably due to them attempting + // to rename the arrays nicely rather than representing the way their actual + // implementation bounces buffers back and forth. As a result, even in the + // "some formulars corrected" version, a direct implementation fails. These + // are noted below as "paper bug". + + // copy and reflect spectral data + for (k=0; k < n2; ++k) u[k] = buffer[k]; + for ( ; k < n ; ++k) u[k] = -buffer[n - k - 1]; + // kernel from paper + // step 1 + for (k=k2=k4=0; k < n4; k+=1, k2+=2, k4+=4) { + v[n-k4-1] = (u[k4] - u[n-k4-1]) * A[k2] - (u[k4+2] - u[n-k4-3])*A[k2+1]; + v[n-k4-3] = (u[k4] - u[n-k4-1]) * A[k2+1] + (u[k4+2] - u[n-k4-3])*A[k2]; + } + // step 2 + for (k=k4=0; k < n8; k+=1, k4+=4) { + w[n2+3+k4] = v[n2+3+k4] + v[k4+3]; + w[n2+1+k4] = v[n2+1+k4] + v[k4+1]; + w[k4+3] = (v[n2+3+k4] - v[k4+3])*A[n2-4-k4] - (v[n2+1+k4]-v[k4+1])*A[n2-3-k4]; + w[k4+1] = (v[n2+1+k4] - v[k4+1])*A[n2-4-k4] + (v[n2+3+k4]-v[k4+3])*A[n2-3-k4]; + } + // step 3 + ld = ilog(n) - 1; // ilog is off-by-one from normal definitions + for (l=0; l < ld-3; ++l) { + int k0 = n >> (l+2), k1 = 1 << (l+3); + int rlim = n >> (l+4), r4, r; + int s2lim = 1 << (l+2), s2; + for (r=r4=0; r < rlim; r4+=4,++r) { + for (s2=0; s2 < s2lim; s2+=2) { + u[n-1-k0*s2-r4] = w[n-1-k0*s2-r4] + w[n-1-k0*(s2+1)-r4]; + u[n-3-k0*s2-r4] = w[n-3-k0*s2-r4] + w[n-3-k0*(s2+1)-r4]; + u[n-1-k0*(s2+1)-r4] = (w[n-1-k0*s2-r4] - w[n-1-k0*(s2+1)-r4]) * A[r*k1] + - (w[n-3-k0*s2-r4] - w[n-3-k0*(s2+1)-r4]) * A[r*k1+1]; + u[n-3-k0*(s2+1)-r4] = (w[n-3-k0*s2-r4] - w[n-3-k0*(s2+1)-r4]) * A[r*k1] + + (w[n-1-k0*s2-r4] - w[n-1-k0*(s2+1)-r4]) * A[r*k1+1]; + } + } + if (l+1 < ld-3) { + // paper bug: ping-ponging of u&w here is omitted + memcpy(w, u, sizeof(u)); + } + } + + // step 4 + for (i=0; i < n8; ++i) { + int j = bit_reverse(i) >> (32-ld+3); + assert(j < n8); + if (i == j) { + // paper bug: original code probably swapped in place; if copying, + // need to directly copy in this case + int i8 = i << 3; + v[i8+1] = u[i8+1]; + v[i8+3] = u[i8+3]; + v[i8+5] = u[i8+5]; + v[i8+7] = u[i8+7]; + } else if (i < j) { + int i8 = i << 3, j8 = j << 3; + v[j8+1] = u[i8+1], v[i8+1] = u[j8 + 1]; + v[j8+3] = u[i8+3], v[i8+3] = u[j8 + 3]; + v[j8+5] = u[i8+5], v[i8+5] = u[j8 + 5]; + v[j8+7] = u[i8+7], v[i8+7] = u[j8 + 7]; + } + } + // step 5 + for (k=0; k < n2; ++k) { + w[k] = v[k*2+1]; + } + // step 6 + for (k=k2=k4=0; k < n8; ++k, k2 += 2, k4 += 4) { + u[n-1-k2] = w[k4]; + u[n-2-k2] = w[k4+1]; + u[n3_4 - 1 - k2] = w[k4+2]; + u[n3_4 - 2 - k2] = w[k4+3]; + } + // step 7 + for (k=k2=0; k < n8; ++k, k2 += 2) { + v[n2 + k2 ] = ( u[n2 + k2] + u[n-2-k2] + C[k2+1]*(u[n2+k2]-u[n-2-k2]) + C[k2]*(u[n2+k2+1]+u[n-2-k2+1]))/2; + v[n-2 - k2] = ( u[n2 + k2] + u[n-2-k2] - C[k2+1]*(u[n2+k2]-u[n-2-k2]) - C[k2]*(u[n2+k2+1]+u[n-2-k2+1]))/2; + v[n2+1+ k2] = ( u[n2+1+k2] - u[n-1-k2] + C[k2+1]*(u[n2+1+k2]+u[n-1-k2]) - C[k2]*(u[n2+k2]-u[n-2-k2]))/2; + v[n-1 - k2] = (-u[n2+1+k2] + u[n-1-k2] + C[k2+1]*(u[n2+1+k2]+u[n-1-k2]) - C[k2]*(u[n2+k2]-u[n-2-k2]))/2; + } + // step 8 + for (k=k2=0; k < n4; ++k,k2 += 2) { + X[k] = v[k2+n2]*B[k2 ] + v[k2+1+n2]*B[k2+1]; + X[n2-1-k] = v[k2+n2]*B[k2+1] - v[k2+1+n2]*B[k2 ]; + } + + // decode kernel to output + // determined the following value experimentally + // (by first figuring out what made inverse_mdct_slow work); then matching that here + // (probably vorbis encoder premultiplies by n or n/2, to save it on the decoder?) + s = 0.5; // theoretically would be n4 + + // [[[ note! the s value of 0.5 is compensated for by the B[] in the current code, + // so it needs to use the "old" B values to behave correctly, or else + // set s to 1.0 ]]] + for (i=0; i < n4 ; ++i) buffer[i] = s * X[i+n4]; + for ( ; i < n3_4; ++i) buffer[i] = -s * X[n3_4 - i - 1]; + for ( ; i < n ; ++i) buffer[i] = -s * X[i - n3_4]; +} +#endif + +static float *get_window(vorb *f, int len) +{ + len <<= 1; + if (len == f->blocksize_0) return f->window[0]; + if (len == f->blocksize_1) return f->window[1]; + assert(0); + return NULL; +} + +#ifndef STB_VORBIS_NO_DEFER_FLOOR +typedef int16 YTYPE; +#else +typedef int YTYPE; +#endif +static int do_floor(vorb *f, Mapping *map, int i, int n, float *target, YTYPE *finalY, uint8 *step2_flag) +{ + int n2 = n >> 1; + int s = map->chan[i].mux, floor; + floor = map->submap_floor[s]; + if (f->floor_types[floor] == 0) { + return error(f, VORBIS_invalid_stream); + } else { + Floor1 *g = &f->floor_config[floor].floor1; + int j,q; + int lx = 0, ly = finalY[0] * g->floor1_multiplier; + for (q=1; q < g->values; ++q) { + j = g->sorted_order[q]; + #ifndef STB_VORBIS_NO_DEFER_FLOOR + if (finalY[j] >= 0) + #else + if (step2_flag[j]) + #endif + { + int hy = finalY[j] * g->floor1_multiplier; + int hx = g->Xlist[j]; + if (lx != hx) + draw_line(target, lx,ly, hx,hy, n2); + CHECK(f); + lx = hx, ly = hy; + } + } + if (lx < n2) { + // optimization of: draw_line(target, lx,ly, n,ly, n2); + for (j=lx; j < n2; ++j) + LINE_OP(target[j], inverse_db_table[ly]); + CHECK(f); + } + } + return TRUE; +} + +// The meaning of "left" and "right" +// +// For a given frame: +// we compute samples from 0..n +// window_center is n/2 +// we'll window and mix the samples from left_start to left_end with data from the previous frame +// all of the samples from left_end to right_start can be output without mixing; however, +// this interval is 0-length except when transitioning between short and long frames +// all of the samples from right_start to right_end need to be mixed with the next frame, +// which we don't have, so those get saved in a buffer +// frame N's right_end-right_start, the number of samples to mix with the next frame, +// has to be the same as frame N+1's left_end-left_start (which they are by +// construction) + +static int vorbis_decode_initial(vorb *f, int *p_left_start, int *p_left_end, int *p_right_start, int *p_right_end, int *mode) +{ + Mode *m; + int i, n, prev, next, window_center; + f->channel_buffer_start = f->channel_buffer_end = 0; + + retry: + if (f->eof) return FALSE; + if (!maybe_start_packet(f)) + return FALSE; + // check packet type + if (get_bits(f,1) != 0) { + if (IS_PUSH_MODE(f)) + return error(f,VORBIS_bad_packet_type); + while (EOP != get8_packet(f)); + goto retry; + } + + if (f->alloc.alloc_buffer) + assert(f->alloc.alloc_buffer_length_in_bytes == f->temp_offset); + + i = get_bits(f, ilog(f->mode_count-1)); + if (i == EOP) return FALSE; + if (i >= f->mode_count) return FALSE; + *mode = i; + m = f->mode_config + i; + if (m->blockflag) { + n = f->blocksize_1; + prev = get_bits(f,1); + next = get_bits(f,1); + } else { + prev = next = 0; + n = f->blocksize_0; + } + +// WINDOWING + + window_center = n >> 1; + if (m->blockflag && !prev) { + *p_left_start = (n - f->blocksize_0) >> 2; + *p_left_end = (n + f->blocksize_0) >> 2; + } else { + *p_left_start = 0; + *p_left_end = window_center; + } + if (m->blockflag && !next) { + *p_right_start = (n*3 - f->blocksize_0) >> 2; + *p_right_end = (n*3 + f->blocksize_0) >> 2; + } else { + *p_right_start = window_center; + *p_right_end = n; + } + + return TRUE; +} + +static int vorbis_decode_packet_rest(vorb *f, int *len, Mode *m, int left_start, int left_end, int right_start, int right_end, int *p_left) +{ + Mapping *map; + int i,j,k,n,n2; + int zero_channel[256]; + int really_zero_channel[256]; + +// WINDOWING + + n = f->blocksize[m->blockflag]; + map = &f->mapping[m->mapping]; + +// FLOORS + n2 = n >> 1; + + CHECK(f); + + for (i=0; i < f->channels; ++i) { + int s = map->chan[i].mux, floor; + zero_channel[i] = FALSE; + floor = map->submap_floor[s]; + if (f->floor_types[floor] == 0) { + return error(f, VORBIS_invalid_stream); + } else { + Floor1 *g = &f->floor_config[floor].floor1; + if (get_bits(f, 1)) { + short *finalY; + uint8 step2_flag[256]; + static int range_list[4] = { 256, 128, 86, 64 }; + int range = range_list[g->floor1_multiplier-1]; + int offset = 2; + finalY = f->finalY[i]; + finalY[0] = get_bits(f, ilog(range)-1); + finalY[1] = get_bits(f, ilog(range)-1); + for (j=0; j < g->partitions; ++j) { + int pclass = g->partition_class_list[j]; + int cdim = g->class_dimensions[pclass]; + int cbits = g->class_subclasses[pclass]; + int csub = (1 << cbits)-1; + int cval = 0; + if (cbits) { + Codebook *c = f->codebooks + g->class_masterbooks[pclass]; + DECODE(cval,f,c); + } + for (k=0; k < cdim; ++k) { + int book = g->subclass_books[pclass][cval & csub]; + cval = cval >> cbits; + if (book >= 0) { + int temp; + Codebook *c = f->codebooks + book; + DECODE(temp,f,c); + finalY[offset++] = temp; + } else + finalY[offset++] = 0; + } + } + if (f->valid_bits == INVALID_BITS) goto error; // behavior according to spec + step2_flag[0] = step2_flag[1] = 1; + for (j=2; j < g->values; ++j) { + int low, high, pred, highroom, lowroom, room, val; + low = g->neighbors[j][0]; + high = g->neighbors[j][1]; + //neighbors(g->Xlist, j, &low, &high); + pred = predict_point(g->Xlist[j], g->Xlist[low], g->Xlist[high], finalY[low], finalY[high]); + val = finalY[j]; + highroom = range - pred; + lowroom = pred; + if (highroom < lowroom) + room = highroom * 2; + else + room = lowroom * 2; + if (val) { + step2_flag[low] = step2_flag[high] = 1; + step2_flag[j] = 1; + if (val >= room) + if (highroom > lowroom) + finalY[j] = val - lowroom + pred; + else + finalY[j] = pred - val + highroom - 1; + else + if (val & 1) + finalY[j] = pred - ((val+1)>>1); + else + finalY[j] = pred + (val>>1); + } else { + step2_flag[j] = 0; + finalY[j] = pred; + } + } + +#ifdef STB_VORBIS_NO_DEFER_FLOOR + do_floor(f, map, i, n, f->floor_buffers[i], finalY, step2_flag); +#else + // defer final floor computation until _after_ residue + for (j=0; j < g->values; ++j) { + if (!step2_flag[j]) + finalY[j] = -1; + } +#endif + } else { + error: + zero_channel[i] = TRUE; + } + // So we just defer everything else to later + + // at this point we've decoded the floor into buffer + } + } + CHECK(f); + // at this point we've decoded all floors + + if (f->alloc.alloc_buffer) + assert(f->alloc.alloc_buffer_length_in_bytes == f->temp_offset); + + // re-enable coupled channels if necessary + memcpy(really_zero_channel, zero_channel, sizeof(really_zero_channel[0]) * f->channels); + for (i=0; i < map->coupling_steps; ++i) + if (!zero_channel[map->chan[i].magnitude] || !zero_channel[map->chan[i].angle]) { + zero_channel[map->chan[i].magnitude] = zero_channel[map->chan[i].angle] = FALSE; + } + + CHECK(f); +// RESIDUE DECODE + for (i=0; i < map->submaps; ++i) { + float *residue_buffers[STB_VORBIS_MAX_CHANNELS]; + int r; + uint8 do_not_decode[256]; + int ch = 0; + for (j=0; j < f->channels; ++j) { + if (map->chan[j].mux == i) { + if (zero_channel[j]) { + do_not_decode[ch] = TRUE; + residue_buffers[ch] = NULL; + } else { + do_not_decode[ch] = FALSE; + residue_buffers[ch] = f->channel_buffers[j]; + } + ++ch; + } + } + r = map->submap_residue[i]; + decode_residue(f, residue_buffers, ch, n2, r, do_not_decode); + } + + if (f->alloc.alloc_buffer) + assert(f->alloc.alloc_buffer_length_in_bytes == f->temp_offset); + CHECK(f); + +// INVERSE COUPLING + for (i = map->coupling_steps-1; i >= 0; --i) { + int n2 = n >> 1; + float *m = f->channel_buffers[map->chan[i].magnitude]; + float *a = f->channel_buffers[map->chan[i].angle ]; + for (j=0; j < n2; ++j) { + float a2,m2; + if (m[j] > 0) + if (a[j] > 0) + m2 = m[j], a2 = m[j] - a[j]; + else + a2 = m[j], m2 = m[j] + a[j]; + else + if (a[j] > 0) + m2 = m[j], a2 = m[j] + a[j]; + else + a2 = m[j], m2 = m[j] - a[j]; + m[j] = m2; + a[j] = a2; + } + } + CHECK(f); + + // finish decoding the floors +#ifndef STB_VORBIS_NO_DEFER_FLOOR + for (i=0; i < f->channels; ++i) { + if (really_zero_channel[i]) { + memset(f->channel_buffers[i], 0, sizeof(*f->channel_buffers[i]) * n2); + } else { + do_floor(f, map, i, n, f->channel_buffers[i], f->finalY[i], NULL); + } + } +#else + for (i=0; i < f->channels; ++i) { + if (really_zero_channel[i]) { + memset(f->channel_buffers[i], 0, sizeof(*f->channel_buffers[i]) * n2); + } else { + for (j=0; j < n2; ++j) + f->channel_buffers[i][j] *= f->floor_buffers[i][j]; + } + } +#endif + +// INVERSE MDCT + CHECK(f); + for (i=0; i < f->channels; ++i) + inverse_mdct(f->channel_buffers[i], n, f, m->blockflag); + CHECK(f); + + // this shouldn't be necessary, unless we exited on an error + // and want to flush to get to the next packet + flush_packet(f); + + if (f->first_decode) { + // assume we start so first non-discarded sample is sample 0 + // this isn't to spec, but spec would require us to read ahead + // and decode the size of all current frames--could be done, + // but presumably it's not a commonly used feature + f->current_loc = -n2; // start of first frame is positioned for discard + // we might have to discard samples "from" the next frame too, + // if we're lapping a large block then a small at the start? + f->discard_samples_deferred = n - right_end; + f->current_loc_valid = TRUE; + f->first_decode = FALSE; + } else if (f->discard_samples_deferred) { + if (f->discard_samples_deferred >= right_start - left_start) { + f->discard_samples_deferred -= (right_start - left_start); + left_start = right_start; + *p_left = left_start; + } else { + left_start += f->discard_samples_deferred; + *p_left = left_start; + f->discard_samples_deferred = 0; + } + } else if (f->previous_length == 0 && f->current_loc_valid) { + // we're recovering from a seek... that means we're going to discard + // the samples from this packet even though we know our position from + // the last page header, so we need to update the position based on + // the discarded samples here + // but wait, the code below is going to add this in itself even + // on a discard, so we don't need to do it here... + } + + // check if we have ogg information about the sample # for this packet + if (f->last_seg_which == f->end_seg_with_known_loc) { + // if we have a valid current loc, and this is final: + if (f->current_loc_valid && (f->page_flag & PAGEFLAG_last_page)) { + uint32 current_end = f->known_loc_for_packet; + // then let's infer the size of the (probably) short final frame + if (current_end < f->current_loc + (right_end-left_start)) { + if (current_end < f->current_loc) { + // negative truncation, that's impossible! + *len = 0; + } else { + *len = current_end - f->current_loc; + } + *len += left_start; // this doesn't seem right, but has no ill effect on my test files + if (*len > right_end) *len = right_end; // this should never happen + f->current_loc += *len; + return TRUE; + } + } + // otherwise, just set our sample loc + // guess that the ogg granule pos refers to the _middle_ of the + // last frame? + // set f->current_loc to the position of left_start + f->current_loc = f->known_loc_for_packet - (n2-left_start); + f->current_loc_valid = TRUE; + } + if (f->current_loc_valid) + f->current_loc += (right_start - left_start); + + if (f->alloc.alloc_buffer) + assert(f->alloc.alloc_buffer_length_in_bytes == f->temp_offset); + *len = right_end; // ignore samples after the window goes to 0 + CHECK(f); + + return TRUE; +} + +static int vorbis_decode_packet(vorb *f, int *len, int *p_left, int *p_right) +{ + int mode, left_end, right_end; + if (!vorbis_decode_initial(f, p_left, &left_end, p_right, &right_end, &mode)) return 0; + return vorbis_decode_packet_rest(f, len, f->mode_config + mode, *p_left, left_end, *p_right, right_end, p_left); +} + +static int vorbis_finish_frame(stb_vorbis *f, int len, int left, int right) +{ + int prev,i,j; + // we use right&left (the start of the right- and left-window sin()-regions) + // to determine how much to return, rather than inferring from the rules + // (same result, clearer code); 'left' indicates where our sin() window + // starts, therefore where the previous window's right edge starts, and + // therefore where to start mixing from the previous buffer. 'right' + // indicates where our sin() ending-window starts, therefore that's where + // we start saving, and where our returned-data ends. + + // mixin from previous window + if (f->previous_length) { + int i,j, n = f->previous_length; + float *w = get_window(f, n); + for (i=0; i < f->channels; ++i) { + for (j=0; j < n; ++j) + f->channel_buffers[i][left+j] = + f->channel_buffers[i][left+j]*w[ j] + + f->previous_window[i][ j]*w[n-1-j]; + } + } + + prev = f->previous_length; + + // last half of this data becomes previous window + f->previous_length = len - right; + + // @OPTIMIZE: could avoid this copy by double-buffering the + // output (flipping previous_window with channel_buffers), but + // then previous_window would have to be 2x as large, and + // channel_buffers couldn't be temp mem (although they're NOT + // currently temp mem, they could be (unless we want to level + // performance by spreading out the computation)) + for (i=0; i < f->channels; ++i) + for (j=0; right+j < len; ++j) + f->previous_window[i][j] = f->channel_buffers[i][right+j]; + + if (!prev) + // there was no previous packet, so this data isn't valid... + // this isn't entirely true, only the would-have-overlapped data + // isn't valid, but this seems to be what the spec requires + return 0; + + // truncate a short frame + if (len < right) right = len; + + f->samples_output += right-left; + + return right - left; +} + +static int vorbis_pump_first_frame(stb_vorbis *f) +{ + int len, right, left, res; + res = vorbis_decode_packet(f, &len, &left, &right); + if (res) + vorbis_finish_frame(f, len, left, right); + return res; +} + +#ifndef STB_VORBIS_NO_PUSHDATA_API +static int is_whole_packet_present(stb_vorbis *f, int end_page) +{ + // make sure that we have the packet available before continuing... + // this requires a full ogg parse, but we know we can fetch from f->stream + + // instead of coding this out explicitly, we could save the current read state, + // read the next packet with get8() until end-of-packet, check f->eof, then + // reset the state? but that would be slower, esp. since we'd have over 256 bytes + // of state to restore (primarily the page segment table) + + int s = f->next_seg, first = TRUE; + uint8 *p = f->stream; + + if (s != -1) { // if we're not starting the packet with a 'continue on next page' flag + for (; s < f->segment_count; ++s) { + p += f->segments[s]; + if (f->segments[s] < 255) // stop at first short segment + break; + } + // either this continues, or it ends it... + if (end_page) + if (s < f->segment_count-1) return error(f, VORBIS_invalid_stream); + if (s == f->segment_count) + s = -1; // set 'crosses page' flag + if (p > f->stream_end) return error(f, VORBIS_need_more_data); + first = FALSE; + } + for (; s == -1;) { + uint8 *q; + int n; + + // check that we have the page header ready + if (p + 26 >= f->stream_end) return error(f, VORBIS_need_more_data); + // validate the page + if (memcmp(p, ogg_page_header, 4)) return error(f, VORBIS_invalid_stream); + if (p[4] != 0) return error(f, VORBIS_invalid_stream); + if (first) { // the first segment must NOT have 'continued_packet', later ones MUST + if (f->previous_length) + if ((p[5] & PAGEFLAG_continued_packet)) return error(f, VORBIS_invalid_stream); + // if no previous length, we're resynching, so we can come in on a continued-packet, + // which we'll just drop + } else { + if (!(p[5] & PAGEFLAG_continued_packet)) return error(f, VORBIS_invalid_stream); + } + n = p[26]; // segment counts + q = p+27; // q points to segment table + p = q + n; // advance past header + // make sure we've read the segment table + if (p > f->stream_end) return error(f, VORBIS_need_more_data); + for (s=0; s < n; ++s) { + p += q[s]; + if (q[s] < 255) + break; + } + if (end_page) + if (s < n-1) return error(f, VORBIS_invalid_stream); + if (s == n) + s = -1; // set 'crosses page' flag + if (p > f->stream_end) return error(f, VORBIS_need_more_data); + first = FALSE; + } + return TRUE; +} +#endif // !STB_VORBIS_NO_PUSHDATA_API + +static int start_decoder(vorb *f) +{ + uint8 header[6], x,y; + int len,i,j,k, max_submaps = 0; + int longest_floorlist=0; + + // first page, first packet + + if (!start_page(f)) return FALSE; + // validate page flag + if (!(f->page_flag & PAGEFLAG_first_page)) return error(f, VORBIS_invalid_first_page); + if (f->page_flag & PAGEFLAG_last_page) return error(f, VORBIS_invalid_first_page); + if (f->page_flag & PAGEFLAG_continued_packet) return error(f, VORBIS_invalid_first_page); + // check for expected packet length + if (f->segment_count != 1) return error(f, VORBIS_invalid_first_page); + if (f->segments[0] != 30) return error(f, VORBIS_invalid_first_page); + // read packet + // check packet header + if (get8(f) != VORBIS_packet_id) return error(f, VORBIS_invalid_first_page); + if (!getn(f, header, 6)) return error(f, VORBIS_unexpected_eof); + if (!vorbis_validate(header)) return error(f, VORBIS_invalid_first_page); + // vorbis_version + if (get32(f) != 0) return error(f, VORBIS_invalid_first_page); + f->channels = get8(f); if (!f->channels) return error(f, VORBIS_invalid_first_page); + if (f->channels > STB_VORBIS_MAX_CHANNELS) return error(f, VORBIS_too_many_channels); + f->sample_rate = get32(f); if (!f->sample_rate) return error(f, VORBIS_invalid_first_page); + get32(f); // bitrate_maximum + get32(f); // bitrate_nominal + get32(f); // bitrate_minimum + x = get8(f); + { + int log0,log1; + log0 = x & 15; + log1 = x >> 4; + f->blocksize_0 = 1 << log0; + f->blocksize_1 = 1 << log1; + if (log0 < 6 || log0 > 13) return error(f, VORBIS_invalid_setup); + if (log1 < 6 || log1 > 13) return error(f, VORBIS_invalid_setup); + if (log0 > log1) return error(f, VORBIS_invalid_setup); + } + + // framing_flag + x = get8(f); + if (!(x & 1)) return error(f, VORBIS_invalid_first_page); + + // second packet! + if (!start_page(f)) return FALSE; + + if (!start_packet(f)) return FALSE; + do { + len = next_segment(f); + skip(f, len); + f->bytes_in_seg = 0; + } while (len); + + // third packet! + if (!start_packet(f)) return FALSE; + + #ifndef STB_VORBIS_NO_PUSHDATA_API + if (IS_PUSH_MODE(f)) { + if (!is_whole_packet_present(f, TRUE)) { + // convert error in ogg header to write type + if (f->error == VORBIS_invalid_stream) + f->error = VORBIS_invalid_setup; + return FALSE; + } + } + #endif + + crc32_init(); // always init it, to avoid multithread race conditions + + if (get8_packet(f) != VORBIS_packet_setup) return error(f, VORBIS_invalid_setup); + for (i=0; i < 6; ++i) header[i] = get8_packet(f); + if (!vorbis_validate(header)) return error(f, VORBIS_invalid_setup); + + // codebooks + + f->codebook_count = get_bits(f,8) + 1; + f->codebooks = (Codebook *) setup_malloc(f, sizeof(*f->codebooks) * f->codebook_count); + if (f->codebooks == NULL) return error(f, VORBIS_outofmem); + memset(f->codebooks, 0, sizeof(*f->codebooks) * f->codebook_count); + for (i=0; i < f->codebook_count; ++i) { + uint32 *values; + int ordered, sorted_count; + int total=0; + uint8 *lengths; + Codebook *c = f->codebooks+i; + CHECK(f); + x = get_bits(f, 8); if (x != 0x42) return error(f, VORBIS_invalid_setup); + x = get_bits(f, 8); if (x != 0x43) return error(f, VORBIS_invalid_setup); + x = get_bits(f, 8); if (x != 0x56) return error(f, VORBIS_invalid_setup); + x = get_bits(f, 8); + c->dimensions = (get_bits(f, 8)<<8) + x; + x = get_bits(f, 8); + y = get_bits(f, 8); + c->entries = (get_bits(f, 8)<<16) + (y<<8) + x; + ordered = get_bits(f,1); + c->sparse = ordered ? 0 : get_bits(f,1); + + if (c->dimensions == 0 && c->entries != 0) return error(f, VORBIS_invalid_setup); + + if (c->sparse) + lengths = (uint8 *) setup_temp_malloc(f, c->entries); + else + lengths = c->codeword_lengths = (uint8 *) setup_malloc(f, c->entries); + + if (!lengths) return error(f, VORBIS_outofmem); + + if (ordered) { + int current_entry = 0; + int current_length = get_bits(f,5) + 1; + while (current_entry < c->entries) { + int limit = c->entries - current_entry; + int n = get_bits(f, ilog(limit)); + if (current_entry + n > (int) c->entries) { return error(f, VORBIS_invalid_setup); } + memset(lengths + current_entry, current_length, n); + current_entry += n; + ++current_length; + } + } else { + for (j=0; j < c->entries; ++j) { + int present = c->sparse ? get_bits(f,1) : 1; + if (present) { + lengths[j] = get_bits(f, 5) + 1; + ++total; + if (lengths[j] == 32) + return error(f, VORBIS_invalid_setup); + } else { + lengths[j] = NO_CODE; + } + } + } + + if (c->sparse && total >= c->entries >> 2) { + // convert sparse items to non-sparse! + if (c->entries > (int) f->setup_temp_memory_required) + f->setup_temp_memory_required = c->entries; + + c->codeword_lengths = (uint8 *) setup_malloc(f, c->entries); + if (c->codeword_lengths == NULL) return error(f, VORBIS_outofmem); + memcpy(c->codeword_lengths, lengths, c->entries); + setup_temp_free(f, lengths, c->entries); // note this is only safe if there have been no intervening temp mallocs! + lengths = c->codeword_lengths; + c->sparse = 0; + } + + // compute the size of the sorted tables + if (c->sparse) { + sorted_count = total; + } else { + sorted_count = 0; + #ifndef STB_VORBIS_NO_HUFFMAN_BINARY_SEARCH + for (j=0; j < c->entries; ++j) + if (lengths[j] > STB_VORBIS_FAST_HUFFMAN_LENGTH && lengths[j] != NO_CODE) + ++sorted_count; + #endif + } + + c->sorted_entries = sorted_count; + values = NULL; + + CHECK(f); + if (!c->sparse) { + c->codewords = (uint32 *) setup_malloc(f, sizeof(c->codewords[0]) * c->entries); + if (!c->codewords) return error(f, VORBIS_outofmem); + } else { + unsigned int size; + if (c->sorted_entries) { + c->codeword_lengths = (uint8 *) setup_malloc(f, c->sorted_entries); + if (!c->codeword_lengths) return error(f, VORBIS_outofmem); + c->codewords = (uint32 *) setup_temp_malloc(f, sizeof(*c->codewords) * c->sorted_entries); + if (!c->codewords) return error(f, VORBIS_outofmem); + values = (uint32 *) setup_temp_malloc(f, sizeof(*values) * c->sorted_entries); + if (!values) return error(f, VORBIS_outofmem); + } + size = c->entries + (sizeof(*c->codewords) + sizeof(*values)) * c->sorted_entries; + if (size > f->setup_temp_memory_required) + f->setup_temp_memory_required = size; + } + + if (!compute_codewords(c, lengths, c->entries, values)) { + if (c->sparse) setup_temp_free(f, values, 0); + return error(f, VORBIS_invalid_setup); + } + + if (c->sorted_entries) { + // allocate an extra slot for sentinels + c->sorted_codewords = (uint32 *) setup_malloc(f, sizeof(*c->sorted_codewords) * (c->sorted_entries+1)); + if (c->sorted_codewords == NULL) return error(f, VORBIS_outofmem); + // allocate an extra slot at the front so that c->sorted_values[-1] is defined + // so that we can catch that case without an extra if + c->sorted_values = ( int *) setup_malloc(f, sizeof(*c->sorted_values ) * (c->sorted_entries+1)); + if (c->sorted_values == NULL) return error(f, VORBIS_outofmem); + ++c->sorted_values; + c->sorted_values[-1] = -1; + compute_sorted_huffman(c, lengths, values); + } + + if (c->sparse) { + setup_temp_free(f, values, sizeof(*values)*c->sorted_entries); + setup_temp_free(f, c->codewords, sizeof(*c->codewords)*c->sorted_entries); + setup_temp_free(f, lengths, c->entries); + c->codewords = NULL; + } + + compute_accelerated_huffman(c); + + CHECK(f); + c->lookup_type = get_bits(f, 4); + if (c->lookup_type > 2) return error(f, VORBIS_invalid_setup); + if (c->lookup_type > 0) { + uint16 *mults; + c->minimum_value = float32_unpack(get_bits(f, 32)); + c->delta_value = float32_unpack(get_bits(f, 32)); + c->value_bits = get_bits(f, 4)+1; + c->sequence_p = get_bits(f,1); + if (c->lookup_type == 1) { + c->lookup_values = lookup1_values(c->entries, c->dimensions); + } else { + c->lookup_values = c->entries * c->dimensions; + } + if (c->lookup_values == 0) return error(f, VORBIS_invalid_setup); + mults = (uint16 *) setup_temp_malloc(f, sizeof(mults[0]) * c->lookup_values); + if (mults == NULL) return error(f, VORBIS_outofmem); + for (j=0; j < (int) c->lookup_values; ++j) { + int q = get_bits(f, c->value_bits); + if (q == EOP) { setup_temp_free(f,mults,sizeof(mults[0])*c->lookup_values); return error(f, VORBIS_invalid_setup); } + mults[j] = q; + } + +#ifndef STB_VORBIS_DIVIDES_IN_CODEBOOK + if (c->lookup_type == 1) { + int len, sparse = c->sparse; + float last=0; + // pre-expand the lookup1-style multiplicands, to avoid a divide in the inner loop + if (sparse) { + if (c->sorted_entries == 0) goto skip; + c->multiplicands = (codetype *) setup_malloc(f, sizeof(c->multiplicands[0]) * c->sorted_entries * c->dimensions); + } else + c->multiplicands = (codetype *) setup_malloc(f, sizeof(c->multiplicands[0]) * c->entries * c->dimensions); + if (c->multiplicands == NULL) { setup_temp_free(f,mults,sizeof(mults[0])*c->lookup_values); return error(f, VORBIS_outofmem); } + len = sparse ? c->sorted_entries : c->entries; + for (j=0; j < len; ++j) { + unsigned int z = sparse ? c->sorted_values[j] : j; + unsigned int div=1; + for (k=0; k < c->dimensions; ++k) { + int off = (z / div) % c->lookup_values; + float val = mults[off]; + val = mults[off]*c->delta_value + c->minimum_value + last; + c->multiplicands[j*c->dimensions + k] = val; + if (c->sequence_p) + last = val; + if (k+1 < c->dimensions) { + if (div > UINT_MAX / (unsigned int) c->lookup_values) { + setup_temp_free(f, mults,sizeof(mults[0])*c->lookup_values); + return error(f, VORBIS_invalid_setup); + } + div *= c->lookup_values; + } + } + } + c->lookup_type = 2; + } + else +#endif + { + float last=0; + CHECK(f); + c->multiplicands = (codetype *) setup_malloc(f, sizeof(c->multiplicands[0]) * c->lookup_values); + if (c->multiplicands == NULL) { setup_temp_free(f, mults,sizeof(mults[0])*c->lookup_values); return error(f, VORBIS_outofmem); } + for (j=0; j < (int) c->lookup_values; ++j) { + float val = mults[j] * c->delta_value + c->minimum_value + last; + c->multiplicands[j] = val; + if (c->sequence_p) + last = val; + } + } +#ifndef STB_VORBIS_DIVIDES_IN_CODEBOOK + skip:; +#endif + setup_temp_free(f, mults, sizeof(mults[0])*c->lookup_values); + + CHECK(f); + } + CHECK(f); + } + + // time domain transfers (notused) + + x = get_bits(f, 6) + 1; + for (i=0; i < x; ++i) { + uint32 z = get_bits(f, 16); + if (z != 0) return error(f, VORBIS_invalid_setup); + } + + // Floors + f->floor_count = get_bits(f, 6)+1; + f->floor_config = (Floor *) setup_malloc(f, f->floor_count * sizeof(*f->floor_config)); + if (f->floor_config == NULL) return error(f, VORBIS_outofmem); + for (i=0; i < f->floor_count; ++i) { + f->floor_types[i] = get_bits(f, 16); + if (f->floor_types[i] > 1) return error(f, VORBIS_invalid_setup); + if (f->floor_types[i] == 0) { + Floor0 *g = &f->floor_config[i].floor0; + g->order = get_bits(f,8); + g->rate = get_bits(f,16); + g->bark_map_size = get_bits(f,16); + g->amplitude_bits = get_bits(f,6); + g->amplitude_offset = get_bits(f,8); + g->number_of_books = get_bits(f,4) + 1; + for (j=0; j < g->number_of_books; ++j) + g->book_list[j] = get_bits(f,8); + return error(f, VORBIS_feature_not_supported); + } else { + stbv__floor_ordering p[31*8+2]; + Floor1 *g = &f->floor_config[i].floor1; + int max_class = -1; + g->partitions = get_bits(f, 5); + for (j=0; j < g->partitions; ++j) { + g->partition_class_list[j] = get_bits(f, 4); + if (g->partition_class_list[j] > max_class) + max_class = g->partition_class_list[j]; + } + for (j=0; j <= max_class; ++j) { + g->class_dimensions[j] = get_bits(f, 3)+1; + g->class_subclasses[j] = get_bits(f, 2); + if (g->class_subclasses[j]) { + g->class_masterbooks[j] = get_bits(f, 8); + if (g->class_masterbooks[j] >= f->codebook_count) return error(f, VORBIS_invalid_setup); + } + for (k=0; k < 1 << g->class_subclasses[j]; ++k) { + g->subclass_books[j][k] = get_bits(f,8)-1; + if (g->subclass_books[j][k] >= f->codebook_count) return error(f, VORBIS_invalid_setup); + } + } + g->floor1_multiplier = get_bits(f,2)+1; + g->rangebits = get_bits(f,4); + g->Xlist[0] = 0; + g->Xlist[1] = 1 << g->rangebits; + g->values = 2; + for (j=0; j < g->partitions; ++j) { + int c = g->partition_class_list[j]; + for (k=0; k < g->class_dimensions[c]; ++k) { + g->Xlist[g->values] = get_bits(f, g->rangebits); + ++g->values; + } + } + // precompute the sorting + for (j=0; j < g->values; ++j) { + p[j].x = g->Xlist[j]; + p[j].id = j; + } + qsort(p, g->values, sizeof(p[0]), point_compare); + for (j=0; j < g->values; ++j) + g->sorted_order[j] = (uint8) p[j].id; + // precompute the neighbors + for (j=2; j < g->values; ++j) { + int low,hi; + neighbors(g->Xlist, j, &low,&hi); + g->neighbors[j][0] = low; + g->neighbors[j][1] = hi; + } + + if (g->values > longest_floorlist) + longest_floorlist = g->values; + } + } + + // Residue + f->residue_count = get_bits(f, 6)+1; + f->residue_config = (Residue *) setup_malloc(f, f->residue_count * sizeof(f->residue_config[0])); + if (f->residue_config == NULL) return error(f, VORBIS_outofmem); + memset(f->residue_config, 0, f->residue_count * sizeof(f->residue_config[0])); + for (i=0; i < f->residue_count; ++i) { + uint8 residue_cascade[64]; + Residue *r = f->residue_config+i; + f->residue_types[i] = get_bits(f, 16); + if (f->residue_types[i] > 2) return error(f, VORBIS_invalid_setup); + r->begin = get_bits(f, 24); + r->end = get_bits(f, 24); + if (r->end < r->begin) return error(f, VORBIS_invalid_setup); + r->part_size = get_bits(f,24)+1; + r->classifications = get_bits(f,6)+1; + r->classbook = get_bits(f,8); + if (r->classbook >= f->codebook_count) return error(f, VORBIS_invalid_setup); + for (j=0; j < r->classifications; ++j) { + uint8 high_bits=0; + uint8 low_bits=get_bits(f,3); + if (get_bits(f,1)) + high_bits = get_bits(f,5); + residue_cascade[j] = high_bits*8 + low_bits; + } + r->residue_books = (short (*)[8]) setup_malloc(f, sizeof(r->residue_books[0]) * r->classifications); + if (r->residue_books == NULL) return error(f, VORBIS_outofmem); + for (j=0; j < r->classifications; ++j) { + for (k=0; k < 8; ++k) { + if (residue_cascade[j] & (1 << k)) { + r->residue_books[j][k] = get_bits(f, 8); + if (r->residue_books[j][k] >= f->codebook_count) return error(f, VORBIS_invalid_setup); + } else { + r->residue_books[j][k] = -1; + } + } + } + // precompute the classifications[] array to avoid inner-loop mod/divide + // call it 'classdata' since we already have r->classifications + r->classdata = (uint8 **) setup_malloc(f, sizeof(*r->classdata) * f->codebooks[r->classbook].entries); + if (!r->classdata) return error(f, VORBIS_outofmem); + memset(r->classdata, 0, sizeof(*r->classdata) * f->codebooks[r->classbook].entries); + for (j=0; j < f->codebooks[r->classbook].entries; ++j) { + int classwords = f->codebooks[r->classbook].dimensions; + int temp = j; + r->classdata[j] = (uint8 *) setup_malloc(f, sizeof(r->classdata[j][0]) * classwords); + if (r->classdata[j] == NULL) return error(f, VORBIS_outofmem); + for (k=classwords-1; k >= 0; --k) { + r->classdata[j][k] = temp % r->classifications; + temp /= r->classifications; + } + } + } + + f->mapping_count = get_bits(f,6)+1; + f->mapping = (Mapping *) setup_malloc(f, f->mapping_count * sizeof(*f->mapping)); + if (f->mapping == NULL) return error(f, VORBIS_outofmem); + memset(f->mapping, 0, f->mapping_count * sizeof(*f->mapping)); + for (i=0; i < f->mapping_count; ++i) { + Mapping *m = f->mapping + i; + int mapping_type = get_bits(f,16); + if (mapping_type != 0) return error(f, VORBIS_invalid_setup); + m->chan = (MappingChannel *) setup_malloc(f, f->channels * sizeof(*m->chan)); + if (m->chan == NULL) return error(f, VORBIS_outofmem); + if (get_bits(f,1)) + m->submaps = get_bits(f,4)+1; + else + m->submaps = 1; + if (m->submaps > max_submaps) + max_submaps = m->submaps; + if (get_bits(f,1)) { + m->coupling_steps = get_bits(f,8)+1; + for (k=0; k < m->coupling_steps; ++k) { + m->chan[k].magnitude = get_bits(f, ilog(f->channels-1)); + m->chan[k].angle = get_bits(f, ilog(f->channels-1)); + if (m->chan[k].magnitude >= f->channels) return error(f, VORBIS_invalid_setup); + if (m->chan[k].angle >= f->channels) return error(f, VORBIS_invalid_setup); + if (m->chan[k].magnitude == m->chan[k].angle) return error(f, VORBIS_invalid_setup); + } + } else + m->coupling_steps = 0; + + // reserved field + if (get_bits(f,2)) return error(f, VORBIS_invalid_setup); + if (m->submaps > 1) { + for (j=0; j < f->channels; ++j) { + m->chan[j].mux = get_bits(f, 4); + if (m->chan[j].mux >= m->submaps) return error(f, VORBIS_invalid_setup); + } + } else + // @SPECIFICATION: this case is missing from the spec + for (j=0; j < f->channels; ++j) + m->chan[j].mux = 0; + + for (j=0; j < m->submaps; ++j) { + get_bits(f,8); // discard + m->submap_floor[j] = get_bits(f,8); + m->submap_residue[j] = get_bits(f,8); + if (m->submap_floor[j] >= f->floor_count) return error(f, VORBIS_invalid_setup); + if (m->submap_residue[j] >= f->residue_count) return error(f, VORBIS_invalid_setup); + } + } + + // Modes + f->mode_count = get_bits(f, 6)+1; + for (i=0; i < f->mode_count; ++i) { + Mode *m = f->mode_config+i; + m->blockflag = get_bits(f,1); + m->windowtype = get_bits(f,16); + m->transformtype = get_bits(f,16); + m->mapping = get_bits(f,8); + if (m->windowtype != 0) return error(f, VORBIS_invalid_setup); + if (m->transformtype != 0) return error(f, VORBIS_invalid_setup); + if (m->mapping >= f->mapping_count) return error(f, VORBIS_invalid_setup); + } + + flush_packet(f); + + f->previous_length = 0; + + for (i=0; i < f->channels; ++i) { + f->channel_buffers[i] = (float *) setup_malloc(f, sizeof(float) * f->blocksize_1); + f->previous_window[i] = (float *) setup_malloc(f, sizeof(float) * f->blocksize_1/2); + f->finalY[i] = (int16 *) setup_malloc(f, sizeof(int16) * longest_floorlist); + if (f->channel_buffers[i] == NULL || f->previous_window[i] == NULL || f->finalY[i] == NULL) return error(f, VORBIS_outofmem); + memset(f->channel_buffers[i], 0, sizeof(float) * f->blocksize_1); + #ifdef STB_VORBIS_NO_DEFER_FLOOR + f->floor_buffers[i] = (float *) setup_malloc(f, sizeof(float) * f->blocksize_1/2); + if (f->floor_buffers[i] == NULL) return error(f, VORBIS_outofmem); + #endif + } + + if (!init_blocksize(f, 0, f->blocksize_0)) return FALSE; + if (!init_blocksize(f, 1, f->blocksize_1)) return FALSE; + f->blocksize[0] = f->blocksize_0; + f->blocksize[1] = f->blocksize_1; + +#ifdef STB_VORBIS_DIVIDE_TABLE + if (integer_divide_table[1][1]==0) + for (i=0; i < DIVTAB_NUMER; ++i) + for (j=1; j < DIVTAB_DENOM; ++j) + integer_divide_table[i][j] = i / j; +#endif + + // compute how much temporary memory is needed + + // 1. + { + uint32 imdct_mem = (f->blocksize_1 * sizeof(float) >> 1); + uint32 classify_mem; + int i,max_part_read=0; + for (i=0; i < f->residue_count; ++i) { + Residue *r = f->residue_config + i; + unsigned int actual_size = f->blocksize_1 / 2; + unsigned int limit_r_begin = r->begin < actual_size ? r->begin : actual_size; + unsigned int limit_r_end = r->end < actual_size ? r->end : actual_size; + int n_read = limit_r_end - limit_r_begin; + int part_read = n_read / r->part_size; + if (part_read > max_part_read) + max_part_read = part_read; + } + #ifndef STB_VORBIS_DIVIDES_IN_RESIDUE + classify_mem = f->channels * (sizeof(void*) + max_part_read * sizeof(uint8 *)); + #else + classify_mem = f->channels * (sizeof(void*) + max_part_read * sizeof(int *)); + #endif + + // maximum reasonable partition size is f->blocksize_1 + + f->temp_memory_required = classify_mem; + if (imdct_mem > f->temp_memory_required) + f->temp_memory_required = imdct_mem; + } + + f->first_decode = TRUE; + + if (f->alloc.alloc_buffer) { + assert(f->temp_offset == f->alloc.alloc_buffer_length_in_bytes); + // check if there's enough temp memory so we don't error later + if (f->setup_offset + sizeof(*f) + f->temp_memory_required > (unsigned) f->temp_offset) + return error(f, VORBIS_outofmem); + } + + f->first_audio_page_offset = stb_vorbis_get_file_offset(f); + + return TRUE; +} + +static void vorbis_deinit(stb_vorbis *p) +{ + int i,j; + if (p->residue_config) { + for (i=0; i < p->residue_count; ++i) { + Residue *r = p->residue_config+i; + if (r->classdata) { + for (j=0; j < p->codebooks[r->classbook].entries; ++j) + setup_free(p, r->classdata[j]); + setup_free(p, r->classdata); + } + setup_free(p, r->residue_books); + } + } + + if (p->codebooks) { + CHECK(p); + for (i=0; i < p->codebook_count; ++i) { + Codebook *c = p->codebooks + i; + setup_free(p, c->codeword_lengths); + setup_free(p, c->multiplicands); + setup_free(p, c->codewords); + setup_free(p, c->sorted_codewords); + // c->sorted_values[-1] is the first entry in the array + setup_free(p, c->sorted_values ? c->sorted_values-1 : NULL); + } + setup_free(p, p->codebooks); + } + setup_free(p, p->floor_config); + setup_free(p, p->residue_config); + if (p->mapping) { + for (i=0; i < p->mapping_count; ++i) + setup_free(p, p->mapping[i].chan); + setup_free(p, p->mapping); + } + CHECK(p); + for (i=0; i < p->channels && i < STB_VORBIS_MAX_CHANNELS; ++i) { + setup_free(p, p->channel_buffers[i]); + setup_free(p, p->previous_window[i]); + #ifdef STB_VORBIS_NO_DEFER_FLOOR + setup_free(p, p->floor_buffers[i]); + #endif + setup_free(p, p->finalY[i]); + } + for (i=0; i < 2; ++i) { + setup_free(p, p->A[i]); + setup_free(p, p->B[i]); + setup_free(p, p->C[i]); + setup_free(p, p->window[i]); + setup_free(p, p->bit_reverse[i]); + } + #ifndef STB_VORBIS_NO_STDIO + if (p->close_on_free) fclose(p->f); + #endif +} + +void stb_vorbis_close(stb_vorbis *p) +{ + if (p == NULL) return; + vorbis_deinit(p); + setup_free(p,p); +} + +static void vorbis_init(stb_vorbis *p, const stb_vorbis_alloc *z) +{ + memset(p, 0, sizeof(*p)); // NULL out all malloc'd pointers to start + if (z) { + p->alloc = *z; + p->alloc.alloc_buffer_length_in_bytes = (p->alloc.alloc_buffer_length_in_bytes+3) & ~3; + p->temp_offset = p->alloc.alloc_buffer_length_in_bytes; + } + p->eof = 0; + p->error = VORBIS__no_error; + p->stream = NULL; + p->codebooks = NULL; + p->page_crc_tests = -1; + #ifndef STB_VORBIS_NO_STDIO + p->close_on_free = FALSE; + p->f = NULL; + #endif +} + +int stb_vorbis_get_sample_offset(stb_vorbis *f) +{ + if (f->current_loc_valid) + return f->current_loc; + else + return -1; +} + +stb_vorbis_info stb_vorbis_get_info(stb_vorbis *f) +{ + stb_vorbis_info d; + d.channels = f->channels; + d.sample_rate = f->sample_rate; + d.setup_memory_required = f->setup_memory_required; + d.setup_temp_memory_required = f->setup_temp_memory_required; + d.temp_memory_required = f->temp_memory_required; + d.max_frame_size = f->blocksize_1 >> 1; + return d; +} + +int stb_vorbis_get_error(stb_vorbis *f) +{ + int e = f->error; + f->error = VORBIS__no_error; + return e; +} + +static stb_vorbis * vorbis_alloc(stb_vorbis *f) +{ + stb_vorbis *p = (stb_vorbis *) setup_malloc(f, sizeof(*p)); + return p; +} + +#ifndef STB_VORBIS_NO_PUSHDATA_API + +void stb_vorbis_flush_pushdata(stb_vorbis *f) +{ + f->previous_length = 0; + f->page_crc_tests = 0; + f->discard_samples_deferred = 0; + f->current_loc_valid = FALSE; + f->first_decode = FALSE; + f->samples_output = 0; + f->channel_buffer_start = 0; + f->channel_buffer_end = 0; +} + +static int vorbis_search_for_page_pushdata(vorb *f, uint8 *data, int data_len) +{ + int i,n; + for (i=0; i < f->page_crc_tests; ++i) + f->scan[i].bytes_done = 0; + + // if we have room for more scans, search for them first, because + // they may cause us to stop early if their header is incomplete + if (f->page_crc_tests < STB_VORBIS_PUSHDATA_CRC_COUNT) { + if (data_len < 4) return 0; + data_len -= 3; // need to look for 4-byte sequence, so don't miss + // one that straddles a boundary + for (i=0; i < data_len; ++i) { + if (data[i] == 0x4f) { + if (0==memcmp(data+i, ogg_page_header, 4)) { + int j,len; + uint32 crc; + // make sure we have the whole page header + if (i+26 >= data_len || i+27+data[i+26] >= data_len) { + // only read up to this page start, so hopefully we'll + // have the whole page header start next time + data_len = i; + break; + } + // ok, we have it all; compute the length of the page + len = 27 + data[i+26]; + for (j=0; j < data[i+26]; ++j) + len += data[i+27+j]; + // scan everything up to the embedded crc (which we must 0) + crc = 0; + for (j=0; j < 22; ++j) + crc = crc32_update(crc, data[i+j]); + // now process 4 0-bytes + for ( ; j < 26; ++j) + crc = crc32_update(crc, 0); + // len is the total number of bytes we need to scan + n = f->page_crc_tests++; + f->scan[n].bytes_left = len-j; + f->scan[n].crc_so_far = crc; + f->scan[n].goal_crc = data[i+22] + (data[i+23] << 8) + (data[i+24]<<16) + (data[i+25]<<24); + // if the last frame on a page is continued to the next, then + // we can't recover the sample_loc immediately + if (data[i+27+data[i+26]-1] == 255) + f->scan[n].sample_loc = ~0; + else + f->scan[n].sample_loc = data[i+6] + (data[i+7] << 8) + (data[i+ 8]<<16) + (data[i+ 9]<<24); + f->scan[n].bytes_done = i+j; + if (f->page_crc_tests == STB_VORBIS_PUSHDATA_CRC_COUNT) + break; + // keep going if we still have room for more + } + } + } + } + + for (i=0; i < f->page_crc_tests;) { + uint32 crc; + int j; + int n = f->scan[i].bytes_done; + int m = f->scan[i].bytes_left; + if (m > data_len - n) m = data_len - n; + // m is the bytes to scan in the current chunk + crc = f->scan[i].crc_so_far; + for (j=0; j < m; ++j) + crc = crc32_update(crc, data[n+j]); + f->scan[i].bytes_left -= m; + f->scan[i].crc_so_far = crc; + if (f->scan[i].bytes_left == 0) { + // does it match? + if (f->scan[i].crc_so_far == f->scan[i].goal_crc) { + // Houston, we have page + data_len = n+m; // consumption amount is wherever that scan ended + f->page_crc_tests = -1; // drop out of page scan mode + f->previous_length = 0; // decode-but-don't-output one frame + f->next_seg = -1; // start a new page + f->current_loc = f->scan[i].sample_loc; // set the current sample location + // to the amount we'd have decoded had we decoded this page + f->current_loc_valid = f->current_loc != ~0U; + return data_len; + } + // delete entry + f->scan[i] = f->scan[--f->page_crc_tests]; + } else { + ++i; + } + } + + return data_len; +} + +// return value: number of bytes we used +int stb_vorbis_decode_frame_pushdata( + stb_vorbis *f, // the file we're decoding + const uint8 *data, int data_len, // the memory available for decoding + int *channels, // place to write number of float * buffers + float ***output, // place to write float ** array of float * buffers + int *samples // place to write number of output samples + ) +{ + int i; + int len,right,left; + + if (!IS_PUSH_MODE(f)) return error(f, VORBIS_invalid_api_mixing); + + if (f->page_crc_tests >= 0) { + *samples = 0; + return vorbis_search_for_page_pushdata(f, (uint8 *) data, data_len); + } + + f->stream = (uint8 *) data; + f->stream_end = (uint8 *) data + data_len; + f->error = VORBIS__no_error; + + // check that we have the entire packet in memory + if (!is_whole_packet_present(f, FALSE)) { + *samples = 0; + return 0; + } + + if (!vorbis_decode_packet(f, &len, &left, &right)) { + // save the actual error we encountered + enum STBVorbisError error = f->error; + if (error == VORBIS_bad_packet_type) { + // flush and resynch + f->error = VORBIS__no_error; + while (get8_packet(f) != EOP) + if (f->eof) break; + *samples = 0; + return (int) (f->stream - data); + } + if (error == VORBIS_continued_packet_flag_invalid) { + if (f->previous_length == 0) { + // we may be resynching, in which case it's ok to hit one + // of these; just discard the packet + f->error = VORBIS__no_error; + while (get8_packet(f) != EOP) + if (f->eof) break; + *samples = 0; + return (int) (f->stream - data); + } + } + // if we get an error while parsing, what to do? + // well, it DEFINITELY won't work to continue from where we are! + stb_vorbis_flush_pushdata(f); + // restore the error that actually made us bail + f->error = error; + *samples = 0; + return 1; + } + + // success! + len = vorbis_finish_frame(f, len, left, right); + for (i=0; i < f->channels; ++i) + f->outputs[i] = f->channel_buffers[i] + left; + + if (channels) *channels = f->channels; + *samples = len; + *output = f->outputs; + return (int) (f->stream - data); +} + +stb_vorbis *stb_vorbis_open_pushdata( + const unsigned char *data, int data_len, // the memory available for decoding + int *data_used, // only defined if result is not NULL + int *error, const stb_vorbis_alloc *alloc) +{ + stb_vorbis *f, p; + vorbis_init(&p, alloc); + p.stream = (uint8 *) data; + p.stream_end = (uint8 *) data + data_len; + p.push_mode = TRUE; + if (!start_decoder(&p)) { + if (p.eof) + *error = VORBIS_need_more_data; + else + *error = p.error; + return NULL; + } + f = vorbis_alloc(&p); + if (f) { + *f = p; + *data_used = (int) (f->stream - data); + *error = 0; + return f; + } else { + vorbis_deinit(&p); + return NULL; + } +} +#endif // STB_VORBIS_NO_PUSHDATA_API + +unsigned int stb_vorbis_get_file_offset(stb_vorbis *f) +{ + #ifndef STB_VORBIS_NO_PUSHDATA_API + if (f->push_mode) return 0; + #endif + if (USE_MEMORY(f)) return (unsigned int) (f->stream - f->stream_start); + #ifndef STB_VORBIS_NO_STDIO + return (unsigned int) (ftell(f->f) - f->f_start); + #endif +} + +#ifndef STB_VORBIS_NO_PULLDATA_API +// +// DATA-PULLING API +// + +static uint32 vorbis_find_page(stb_vorbis *f, uint32 *end, uint32 *last) +{ + for(;;) { + int n; + if (f->eof) return 0; + n = get8(f); + if (n == 0x4f) { // page header candidate + unsigned int retry_loc = stb_vorbis_get_file_offset(f); + int i; + // check if we're off the end of a file_section stream + if (retry_loc - 25 > f->stream_len) + return 0; + // check the rest of the header + for (i=1; i < 4; ++i) + if (get8(f) != ogg_page_header[i]) + break; + if (f->eof) return 0; + if (i == 4) { + uint8 header[27]; + uint32 i, crc, goal, len; + for (i=0; i < 4; ++i) + header[i] = ogg_page_header[i]; + for (; i < 27; ++i) + header[i] = get8(f); + if (f->eof) return 0; + if (header[4] != 0) goto invalid; + goal = header[22] + (header[23] << 8) + (header[24]<<16) + (header[25]<<24); + for (i=22; i < 26; ++i) + header[i] = 0; + crc = 0; + for (i=0; i < 27; ++i) + crc = crc32_update(crc, header[i]); + len = 0; + for (i=0; i < header[26]; ++i) { + int s = get8(f); + crc = crc32_update(crc, s); + len += s; + } + if (len && f->eof) return 0; + for (i=0; i < len; ++i) + crc = crc32_update(crc, get8(f)); + // finished parsing probable page + if (crc == goal) { + // we could now check that it's either got the last + // page flag set, OR it's followed by the capture + // pattern, but I guess TECHNICALLY you could have + // a file with garbage between each ogg page and recover + // from it automatically? So even though that paranoia + // might decrease the chance of an invalid decode by + // another 2^32, not worth it since it would hose those + // invalid-but-useful files? + if (end) + *end = stb_vorbis_get_file_offset(f); + if (last) { + if (header[5] & 0x04) + *last = 1; + else + *last = 0; + } + set_file_offset(f, retry_loc-1); + return 1; + } + } + invalid: + // not a valid page, so rewind and look for next one + set_file_offset(f, retry_loc); + } + } +} + + +#define SAMPLE_unknown 0xffffffff + +// seeking is implemented with a binary search, which narrows down the range to +// 64K, before using a linear search (because finding the synchronization +// pattern can be expensive, and the chance we'd find the end page again is +// relatively high for small ranges) +// +// two initial interpolation-style probes are used at the start of the search +// to try to bound either side of the binary search sensibly, while still +// working in O(log n) time if they fail. + +static int get_seek_page_info(stb_vorbis *f, ProbedPage *z) +{ + uint8 header[27], lacing[255]; + int i,len; + + // record where the page starts + z->page_start = stb_vorbis_get_file_offset(f); + + // parse the header + getn(f, header, 27); + if (header[0] != 'O' || header[1] != 'g' || header[2] != 'g' || header[3] != 'S') + return 0; + getn(f, lacing, header[26]); + + // determine the length of the payload + len = 0; + for (i=0; i < header[26]; ++i) + len += lacing[i]; + + // this implies where the page ends + z->page_end = z->page_start + 27 + header[26] + len; + + // read the last-decoded sample out of the data + z->last_decoded_sample = header[6] + (header[7] << 8) + (header[8] << 16) + (header[9] << 24); + + // restore file state to where we were + set_file_offset(f, z->page_start); + return 1; +} + +// rarely used function to seek back to the preceeding page while finding the +// start of a packet +static int go_to_page_before(stb_vorbis *f, unsigned int limit_offset) +{ + unsigned int previous_safe, end; + + // now we want to seek back 64K from the limit + if (limit_offset >= 65536 && limit_offset-65536 >= f->first_audio_page_offset) + previous_safe = limit_offset - 65536; + else + previous_safe = f->first_audio_page_offset; + + set_file_offset(f, previous_safe); + + while (vorbis_find_page(f, &end, NULL)) { + if (end >= limit_offset && stb_vorbis_get_file_offset(f) < limit_offset) + return 1; + set_file_offset(f, end); + } + + return 0; +} + +// implements the search logic for finding a page and starting decoding. if +// the function succeeds, current_loc_valid will be true and current_loc will +// be less than or equal to the provided sample number (the closer the +// better). +static int seek_to_sample_coarse(stb_vorbis *f, uint32 sample_number) +{ + ProbedPage left, right, mid; + int i, start_seg_with_known_loc, end_pos, page_start; + uint32 delta, stream_length, padding; + double offset, bytes_per_sample; + int probe = 0; + + // find the last page and validate the target sample + stream_length = stb_vorbis_stream_length_in_samples(f); + if (stream_length == 0) return error(f, VORBIS_seek_without_length); + if (sample_number > stream_length) return error(f, VORBIS_seek_invalid); + + // this is the maximum difference between the window-center (which is the + // actual granule position value), and the right-start (which the spec + // indicates should be the granule position (give or take one)). + padding = ((f->blocksize_1 - f->blocksize_0) >> 2); + if (sample_number < padding) + sample_number = 0; + else + sample_number -= padding; + + left = f->p_first; + while (left.last_decoded_sample == ~0U) { + // (untested) the first page does not have a 'last_decoded_sample' + set_file_offset(f, left.page_end); + if (!get_seek_page_info(f, &left)) goto error; + } + + right = f->p_last; + assert(right.last_decoded_sample != ~0U); + + // starting from the start is handled differently + if (sample_number <= left.last_decoded_sample) { + if (stb_vorbis_seek_start(f)) + return 1; + return 0; + } + + while (left.page_end != right.page_start) { + assert(left.page_end < right.page_start); + // search range in bytes + delta = right.page_start - left.page_end; + if (delta <= 65536) { + // there's only 64K left to search - handle it linearly + set_file_offset(f, left.page_end); + } else { + if (probe < 2) { + if (probe == 0) { + // first probe (interpolate) + double data_bytes = right.page_end - left.page_start; + bytes_per_sample = data_bytes / right.last_decoded_sample; + offset = left.page_start + bytes_per_sample * (sample_number - left.last_decoded_sample); + } else { + // second probe (try to bound the other side) + double error = ((double) sample_number - mid.last_decoded_sample) * bytes_per_sample; + if (error >= 0 && error < 8000) error = 8000; + if (error < 0 && error > -8000) error = -8000; + offset += error * 2; + } + + // ensure the offset is valid + if (offset < left.page_end) + offset = left.page_end; + if (offset > right.page_start - 65536) + offset = right.page_start - 65536; + + set_file_offset(f, (unsigned int) offset); + } else { + // binary search for large ranges (offset by 32K to ensure + // we don't hit the right page) + set_file_offset(f, left.page_end + (delta / 2) - 32768); + } + + if (!vorbis_find_page(f, NULL, NULL)) goto error; + } + + for (;;) { + if (!get_seek_page_info(f, &mid)) goto error; + if (mid.last_decoded_sample != ~0U) break; + // (untested) no frames end on this page + set_file_offset(f, mid.page_end); + assert(mid.page_start < right.page_start); + } + + // if we've just found the last page again then we're in a tricky file, + // and we're close enough. + if (mid.page_start == right.page_start) + break; + + if (sample_number < mid.last_decoded_sample) + right = mid; + else + left = mid; + + ++probe; + } + + // seek back to start of the last packet + page_start = left.page_start; + set_file_offset(f, page_start); + if (!start_page(f)) return error(f, VORBIS_seek_failed); + end_pos = f->end_seg_with_known_loc; + assert(end_pos >= 0); + + for (;;) { + for (i = end_pos; i > 0; --i) + if (f->segments[i-1] != 255) + break; + + start_seg_with_known_loc = i; + + if (start_seg_with_known_loc > 0 || !(f->page_flag & PAGEFLAG_continued_packet)) + break; + + // (untested) the final packet begins on an earlier page + if (!go_to_page_before(f, page_start)) + goto error; + + page_start = stb_vorbis_get_file_offset(f); + if (!start_page(f)) goto error; + end_pos = f->segment_count - 1; + } + + // prepare to start decoding + f->current_loc_valid = FALSE; + f->last_seg = FALSE; + f->valid_bits = 0; + f->packet_bytes = 0; + f->bytes_in_seg = 0; + f->previous_length = 0; + f->next_seg = start_seg_with_known_loc; + + for (i = 0; i < start_seg_with_known_loc; i++) + skip(f, f->segments[i]); + + // start decoding (optimizable - this frame is generally discarded) + if (!vorbis_pump_first_frame(f)) + return 0; + if (f->current_loc > sample_number) + return error(f, VORBIS_seek_failed); + return 1; + +error: + // try to restore the file to a valid state + stb_vorbis_seek_start(f); + return error(f, VORBIS_seek_failed); +} + +// the same as vorbis_decode_initial, but without advancing +static int peek_decode_initial(vorb *f, int *p_left_start, int *p_left_end, int *p_right_start, int *p_right_end, int *mode) +{ + int bits_read, bytes_read; + + if (!vorbis_decode_initial(f, p_left_start, p_left_end, p_right_start, p_right_end, mode)) + return 0; + + // either 1 or 2 bytes were read, figure out which so we can rewind + bits_read = 1 + ilog(f->mode_count-1); + if (f->mode_config[*mode].blockflag) + bits_read += 2; + bytes_read = (bits_read + 7) / 8; + + f->bytes_in_seg += bytes_read; + f->packet_bytes -= bytes_read; + skip(f, -bytes_read); + if (f->next_seg == -1) + f->next_seg = f->segment_count - 1; + else + f->next_seg--; + f->valid_bits = 0; + + return 1; +} + +int stb_vorbis_seek_frame(stb_vorbis *f, unsigned int sample_number) +{ + uint32 max_frame_samples; + + if (IS_PUSH_MODE(f)) return error(f, VORBIS_invalid_api_mixing); + + // fast page-level search + if (!seek_to_sample_coarse(f, sample_number)) + return 0; + + assert(f->current_loc_valid); + assert(f->current_loc <= sample_number); + + // linear search for the relevant packet + max_frame_samples = (f->blocksize_1*3 - f->blocksize_0) >> 2; + while (f->current_loc < sample_number) { + int left_start, left_end, right_start, right_end, mode, frame_samples; + if (!peek_decode_initial(f, &left_start, &left_end, &right_start, &right_end, &mode)) + return error(f, VORBIS_seek_failed); + // calculate the number of samples returned by the next frame + frame_samples = right_start - left_start; + if (f->current_loc + frame_samples > sample_number) { + return 1; // the next frame will contain the sample + } else if (f->current_loc + frame_samples + max_frame_samples > sample_number) { + // there's a chance the frame after this could contain the sample + vorbis_pump_first_frame(f); + } else { + // this frame is too early to be relevant + f->current_loc += frame_samples; + f->previous_length = 0; + maybe_start_packet(f); + flush_packet(f); + } + } + // the next frame will start with the sample + assert(f->current_loc == sample_number); + return 1; +} + +int stb_vorbis_seek(stb_vorbis *f, unsigned int sample_number) +{ + if (!stb_vorbis_seek_frame(f, sample_number)) + return 0; + + if (sample_number != f->current_loc) { + int n; + uint32 frame_start = f->current_loc; + stb_vorbis_get_frame_float(f, &n, NULL); + assert(sample_number > frame_start); + assert(f->channel_buffer_start + (int) (sample_number-frame_start) <= f->channel_buffer_end); + f->channel_buffer_start += (sample_number - frame_start); + } + + return 1; +} + +int stb_vorbis_seek_start(stb_vorbis *f) +{ + if (IS_PUSH_MODE(f)) { return error(f, VORBIS_invalid_api_mixing); } + set_file_offset(f, f->first_audio_page_offset); + f->previous_length = 0; + f->first_decode = TRUE; + f->next_seg = -1; + return vorbis_pump_first_frame(f); +} + +unsigned int stb_vorbis_stream_length_in_samples(stb_vorbis *f) +{ + unsigned int restore_offset, previous_safe; + unsigned int end, last_page_loc; + + if (IS_PUSH_MODE(f)) return error(f, VORBIS_invalid_api_mixing); + if (!f->total_samples) { + unsigned int last; + uint32 lo,hi; + char header[6]; + + // first, store the current decode position so we can restore it + restore_offset = stb_vorbis_get_file_offset(f); + + // now we want to seek back 64K from the end (the last page must + // be at most a little less than 64K, but let's allow a little slop) + if (f->stream_len >= 65536 && f->stream_len-65536 >= f->first_audio_page_offset) + previous_safe = f->stream_len - 65536; + else + previous_safe = f->first_audio_page_offset; + + set_file_offset(f, previous_safe); + // previous_safe is now our candidate 'earliest known place that seeking + // to will lead to the final page' + + if (!vorbis_find_page(f, &end, &last)) { + // if we can't find a page, we're hosed! + f->error = VORBIS_cant_find_last_page; + f->total_samples = 0xffffffff; + goto done; + } + + // check if there are more pages + last_page_loc = stb_vorbis_get_file_offset(f); + + // stop when the last_page flag is set, not when we reach eof; + // this allows us to stop short of a 'file_section' end without + // explicitly checking the length of the section + while (!last) { + set_file_offset(f, end); + if (!vorbis_find_page(f, &end, &last)) { + // the last page we found didn't have the 'last page' flag + // set. whoops! + break; + } + previous_safe = last_page_loc+1; + last_page_loc = stb_vorbis_get_file_offset(f); + } + + set_file_offset(f, last_page_loc); + + // parse the header + getn(f, (unsigned char *)header, 6); + // extract the absolute granule position + lo = get32(f); + hi = get32(f); + if (lo == 0xffffffff && hi == 0xffffffff) { + f->error = VORBIS_cant_find_last_page; + f->total_samples = SAMPLE_unknown; + goto done; + } + if (hi) + lo = 0xfffffffe; // saturate + f->total_samples = lo; + + f->p_last.page_start = last_page_loc; + f->p_last.page_end = end; + f->p_last.last_decoded_sample = lo; + + done: + set_file_offset(f, restore_offset); + } + return f->total_samples == SAMPLE_unknown ? 0 : f->total_samples; +} + +float stb_vorbis_stream_length_in_seconds(stb_vorbis *f) +{ + return stb_vorbis_stream_length_in_samples(f) / (float) f->sample_rate; +} + + + +int stb_vorbis_get_frame_float(stb_vorbis *f, int *channels, float ***output) +{ + int len, right,left,i; + if (IS_PUSH_MODE(f)) return error(f, VORBIS_invalid_api_mixing); + + if (!vorbis_decode_packet(f, &len, &left, &right)) { + f->channel_buffer_start = f->channel_buffer_end = 0; + return 0; + } + + len = vorbis_finish_frame(f, len, left, right); + for (i=0; i < f->channels; ++i) + f->outputs[i] = f->channel_buffers[i] + left; + + f->channel_buffer_start = left; + f->channel_buffer_end = left+len; + + if (channels) *channels = f->channels; + if (output) *output = f->outputs; + return len; +} + +#ifndef STB_VORBIS_NO_STDIO + +stb_vorbis * stb_vorbis_open_file_section(FILE *file, int close_on_free, int *error, const stb_vorbis_alloc *alloc, unsigned int length) +{ + stb_vorbis *f, p; + vorbis_init(&p, alloc); + p.f = file; + p.f_start = (uint32) ftell(file); + p.stream_len = length; + p.close_on_free = close_on_free; + if (start_decoder(&p)) { + f = vorbis_alloc(&p); + if (f) { + *f = p; + vorbis_pump_first_frame(f); + return f; + } + } + if (error) *error = p.error; + vorbis_deinit(&p); + return NULL; +} + +stb_vorbis * stb_vorbis_open_file(FILE *file, int close_on_free, int *error, const stb_vorbis_alloc *alloc) +{ + unsigned int len, start; + start = (unsigned int) ftell(file); + fseek(file, 0, SEEK_END); + len = (unsigned int) (ftell(file) - start); + fseek(file, start, SEEK_SET); + return stb_vorbis_open_file_section(file, close_on_free, error, alloc, len); +} + +stb_vorbis * stb_vorbis_open_filename(const char *filename, int *error, const stb_vorbis_alloc *alloc) +{ + FILE *f = fopen(filename, "rb"); + if (f) + return stb_vorbis_open_file(f, TRUE, error, alloc); + if (error) *error = VORBIS_file_open_failure; + return NULL; +} +#endif // STB_VORBIS_NO_STDIO + +stb_vorbis * stb_vorbis_open_memory(const unsigned char *data, int len, int *error, const stb_vorbis_alloc *alloc) +{ + stb_vorbis *f, p; + if (data == NULL) return NULL; + vorbis_init(&p, alloc); + p.stream = (uint8 *) data; + p.stream_end = (uint8 *) data + len; + p.stream_start = (uint8 *) p.stream; + p.stream_len = len; + p.push_mode = FALSE; + if (start_decoder(&p)) { + f = vorbis_alloc(&p); + if (f) { + *f = p; + vorbis_pump_first_frame(f); + if (error) *error = VORBIS__no_error; + return f; + } + } + if (error) *error = p.error; + vorbis_deinit(&p); + return NULL; +} + +#ifndef STB_VORBIS_NO_INTEGER_CONVERSION +#define PLAYBACK_MONO 1 +#define PLAYBACK_LEFT 2 +#define PLAYBACK_RIGHT 4 + +#define L (PLAYBACK_LEFT | PLAYBACK_MONO) +#define C (PLAYBACK_LEFT | PLAYBACK_RIGHT | PLAYBACK_MONO) +#define R (PLAYBACK_RIGHT | PLAYBACK_MONO) + +static int8 channel_position[7][6] = +{ + { 0 }, + { C }, + { L, R }, + { L, C, R }, + { L, R, L, R }, + { L, C, R, L, R }, + { L, C, R, L, R, C }, +}; + + +#ifndef STB_VORBIS_NO_FAST_SCALED_FLOAT + typedef union { + float f; + int i; + } float_conv; + typedef char stb_vorbis_float_size_test[sizeof(float)==4 && sizeof(int) == 4]; + #define FASTDEF(x) float_conv x + // add (1<<23) to convert to int, then divide by 2^SHIFT, then add 0.5/2^SHIFT to round + #define MAGIC(SHIFT) (1.5f * (1 << (23-SHIFT)) + 0.5f/(1 << SHIFT)) + #define ADDEND(SHIFT) (((150-SHIFT) << 23) + (1 << 22)) + #define FAST_SCALED_FLOAT_TO_INT(temp,x,s) (temp.f = (x) + MAGIC(s), temp.i - ADDEND(s)) + #define check_endianness() +#else + #define FAST_SCALED_FLOAT_TO_INT(temp,x,s) ((int) ((x) * (1 << (s)))) + #define check_endianness() + #define FASTDEF(x) +#endif + +static void copy_samples(short *dest, float *src, int len) +{ + int i; + check_endianness(); + for (i=0; i < len; ++i) { + FASTDEF(temp); + int v = FAST_SCALED_FLOAT_TO_INT(temp, src[i],15); + if ((unsigned int) (v + 32768) > 65535) + v = v < 0 ? -32768 : 32767; + dest[i] = v; + } +} + +static void compute_samples(int mask, short *output, int num_c, float **data, int d_offset, int len) +{ + #define BUFFER_SIZE 32 + float buffer[BUFFER_SIZE]; + int i,j,o,n = BUFFER_SIZE; + check_endianness(); + for (o = 0; o < len; o += BUFFER_SIZE) { + memset(buffer, 0, sizeof(buffer)); + if (o + n > len) n = len - o; + for (j=0; j < num_c; ++j) { + if (channel_position[num_c][j] & mask) { + for (i=0; i < n; ++i) + buffer[i] += data[j][d_offset+o+i]; + } + } + for (i=0; i < n; ++i) { + FASTDEF(temp); + int v = FAST_SCALED_FLOAT_TO_INT(temp,buffer[i],15); + if ((unsigned int) (v + 32768) > 65535) + v = v < 0 ? -32768 : 32767; + output[o+i] = v; + } + } +} + +static void compute_stereo_samples(short *output, int num_c, float **data, int d_offset, int len) +{ + #define BUFFER_SIZE 32 + float buffer[BUFFER_SIZE]; + int i,j,o,n = BUFFER_SIZE >> 1; + // o is the offset in the source data + check_endianness(); + for (o = 0; o < len; o += BUFFER_SIZE >> 1) { + // o2 is the offset in the output data + int o2 = o << 1; + memset(buffer, 0, sizeof(buffer)); + if (o + n > len) n = len - o; + for (j=0; j < num_c; ++j) { + int m = channel_position[num_c][j] & (PLAYBACK_LEFT | PLAYBACK_RIGHT); + if (m == (PLAYBACK_LEFT | PLAYBACK_RIGHT)) { + for (i=0; i < n; ++i) { + buffer[i*2+0] += data[j][d_offset+o+i]; + buffer[i*2+1] += data[j][d_offset+o+i]; + } + } else if (m == PLAYBACK_LEFT) { + for (i=0; i < n; ++i) { + buffer[i*2+0] += data[j][d_offset+o+i]; + } + } else if (m == PLAYBACK_RIGHT) { + for (i=0; i < n; ++i) { + buffer[i*2+1] += data[j][d_offset+o+i]; + } + } + } + for (i=0; i < (n<<1); ++i) { + FASTDEF(temp); + int v = FAST_SCALED_FLOAT_TO_INT(temp,buffer[i],15); + if ((unsigned int) (v + 32768) > 65535) + v = v < 0 ? -32768 : 32767; + output[o2+i] = v; + } + } +} + +static void convert_samples_short(int buf_c, short **buffer, int b_offset, int data_c, float **data, int d_offset, int samples) +{ + int i; + if (buf_c != data_c && buf_c <= 2 && data_c <= 6) { + static int channel_selector[3][2] = { {0}, {PLAYBACK_MONO}, {PLAYBACK_LEFT, PLAYBACK_RIGHT} }; + for (i=0; i < buf_c; ++i) + compute_samples(channel_selector[buf_c][i], buffer[i]+b_offset, data_c, data, d_offset, samples); + } else { + int limit = buf_c < data_c ? buf_c : data_c; + for (i=0; i < limit; ++i) + copy_samples(buffer[i]+b_offset, data[i]+d_offset, samples); + for ( ; i < buf_c; ++i) + memset(buffer[i]+b_offset, 0, sizeof(short) * samples); + } +} + +int stb_vorbis_get_frame_short(stb_vorbis *f, int num_c, short **buffer, int num_samples) +{ + float **output; + int len = stb_vorbis_get_frame_float(f, NULL, &output); + if (len > num_samples) len = num_samples; + if (len) + convert_samples_short(num_c, buffer, 0, f->channels, output, 0, len); + return len; +} + +static void convert_channels_short_interleaved(int buf_c, short *buffer, int data_c, float **data, int d_offset, int len) +{ + int i; + check_endianness(); + if (buf_c != data_c && buf_c <= 2 && data_c <= 6) { + assert(buf_c == 2); + for (i=0; i < buf_c; ++i) + compute_stereo_samples(buffer, data_c, data, d_offset, len); + } else { + int limit = buf_c < data_c ? buf_c : data_c; + int j; + for (j=0; j < len; ++j) { + for (i=0; i < limit; ++i) { + FASTDEF(temp); + float f = data[i][d_offset+j]; + int v = FAST_SCALED_FLOAT_TO_INT(temp, f,15);//data[i][d_offset+j],15); + if ((unsigned int) (v + 32768) > 65535) + v = v < 0 ? -32768 : 32767; + *buffer++ = v; + } + for ( ; i < buf_c; ++i) + *buffer++ = 0; + } + } +} + +int stb_vorbis_get_frame_short_interleaved(stb_vorbis *f, int num_c, short *buffer, int num_shorts) +{ + float **output; + int len; + if (num_c == 1) return stb_vorbis_get_frame_short(f,num_c,&buffer, num_shorts); + len = stb_vorbis_get_frame_float(f, NULL, &output); + if (len) { + if (len*num_c > num_shorts) len = num_shorts / num_c; + convert_channels_short_interleaved(num_c, buffer, f->channels, output, 0, len); + } + return len; +} + +int stb_vorbis_get_samples_short_interleaved(stb_vorbis *f, int channels, short *buffer, int num_shorts) +{ + float **outputs; + int len = num_shorts / channels; + int n=0; + int z = f->channels; + if (z > channels) z = channels; + while (n < len) { + int k = f->channel_buffer_end - f->channel_buffer_start; + if (n+k >= len) k = len - n; + if (k) + convert_channels_short_interleaved(channels, buffer, f->channels, f->channel_buffers, f->channel_buffer_start, k); + buffer += k*channels; + n += k; + f->channel_buffer_start += k; + if (n == len) break; + if (!stb_vorbis_get_frame_float(f, NULL, &outputs)) break; + } + return n; +} + +int stb_vorbis_get_samples_short(stb_vorbis *f, int channels, short **buffer, int len) +{ + float **outputs; + int n=0; + int z = f->channels; + if (z > channels) z = channels; + while (n < len) { + int k = f->channel_buffer_end - f->channel_buffer_start; + if (n+k >= len) k = len - n; + if (k) + convert_samples_short(channels, buffer, n, f->channels, f->channel_buffers, f->channel_buffer_start, k); + n += k; + f->channel_buffer_start += k; + if (n == len) break; + if (!stb_vorbis_get_frame_float(f, NULL, &outputs)) break; + } + return n; +} + +#ifndef STB_VORBIS_NO_STDIO +int stb_vorbis_decode_filename(const char *filename, int *channels, int *sample_rate, short **output) +{ + int data_len, offset, total, limit, error; + short *data; + stb_vorbis *v = stb_vorbis_open_filename(filename, &error, NULL); + if (v == NULL) return -1; + limit = v->channels * 4096; + *channels = v->channels; + if (sample_rate) + *sample_rate = v->sample_rate; + offset = data_len = 0; + total = limit; + data = (short *) malloc(total * sizeof(*data)); + if (data == NULL) { + stb_vorbis_close(v); + return -2; + } + for (;;) { + int n = stb_vorbis_get_frame_short_interleaved(v, v->channels, data+offset, total-offset); + if (n == 0) break; + data_len += n; + offset += n * v->channels; + if (offset + limit > total) { + short *data2; + total *= 2; + data2 = (short *) realloc(data, total * sizeof(*data)); + if (data2 == NULL) { + free(data); + stb_vorbis_close(v); + return -2; + } + data = data2; + } + } + *output = data; + stb_vorbis_close(v); + return data_len; +} +#endif // NO_STDIO + +int stb_vorbis_decode_memory(const uint8 *mem, int len, int *channels, int *sample_rate, short **output) +{ + int data_len, offset, total, limit, error; + short *data; + stb_vorbis *v = stb_vorbis_open_memory(mem, len, &error, NULL); + if (v == NULL) return -1; + limit = v->channels * 4096; + *channels = v->channels; + if (sample_rate) + *sample_rate = v->sample_rate; + offset = data_len = 0; + total = limit; + data = (short *) malloc(total * sizeof(*data)); + if (data == NULL) { + stb_vorbis_close(v); + return -2; + } + for (;;) { + int n = stb_vorbis_get_frame_short_interleaved(v, v->channels, data+offset, total-offset); + if (n == 0) break; + data_len += n; + offset += n * v->channels; + if (offset + limit > total) { + short *data2; + total *= 2; + data2 = (short *) realloc(data, total * sizeof(*data)); + if (data2 == NULL) { + free(data); + stb_vorbis_close(v); + return -2; + } + data = data2; + } + } + *output = data; + stb_vorbis_close(v); + return data_len; +} +#endif // STB_VORBIS_NO_INTEGER_CONVERSION + +int stb_vorbis_get_samples_float_interleaved(stb_vorbis *f, int channels, float *buffer, int num_floats) +{ + float **outputs; + int len = num_floats / channels; + int n=0; + int z = f->channels; + if (z > channels) z = channels; + while (n < len) { + int i,j; + int k = f->channel_buffer_end - f->channel_buffer_start; + if (n+k >= len) k = len - n; + for (j=0; j < k; ++j) { + for (i=0; i < z; ++i) + *buffer++ = f->channel_buffers[i][f->channel_buffer_start+j]; + for ( ; i < channels; ++i) + *buffer++ = 0; + } + n += k; + f->channel_buffer_start += k; + if (n == len) + break; + if (!stb_vorbis_get_frame_float(f, NULL, &outputs)) + break; + } + return n; +} + +int stb_vorbis_get_samples_float(stb_vorbis *f, int channels, float **buffer, int num_samples) +{ + float **outputs; + int n=0; + int z = f->channels; + if (z > channels) z = channels; + while (n < num_samples) { + int i; + int k = f->channel_buffer_end - f->channel_buffer_start; + if (n+k >= num_samples) k = num_samples - n; + if (k) { + for (i=0; i < z; ++i) + memcpy(buffer[i]+n, f->channel_buffers[i]+f->channel_buffer_start, sizeof(float)*k); + for ( ; i < channels; ++i) + memset(buffer[i]+n, 0, sizeof(float) * k); + } + n += k; + f->channel_buffer_start += k; + if (n == num_samples) + break; + if (!stb_vorbis_get_frame_float(f, NULL, &outputs)) + break; + } + return n; +} +#endif // STB_VORBIS_NO_PULLDATA_API + +/* Version history + 1.12 - 2017-11-21 - limit residue begin/end to blocksize/2 to avoid large temp allocs in bad/corrupt files + 1.11 - 2017-07-23 - fix MinGW compilation + 1.10 - 2017-03-03 - more robust seeking; fix negative ilog(); clear error in open_memory + 1.09 - 2016-04-04 - back out 'avoid discarding last frame' fix from previous version + 1.08 - 2016-04-02 - fixed multiple warnings; fix setup memory leaks; + avoid discarding last frame of audio data + 1.07 - 2015-01-16 - fixed some warnings, fix mingw, const-correct API + some more crash fixes when out of memory or with corrupt files + 1.06 - 2015-08-31 - full, correct support for seeking API (Dougall Johnson) + some crash fixes when out of memory or with corrupt files + 1.05 - 2015-04-19 - don't define __forceinline if it's redundant + 1.04 - 2014-08-27 - fix missing const-correct case in API + 1.03 - 2014-08-07 - Warning fixes + 1.02 - 2014-07-09 - Declare qsort compare function _cdecl on windows + 1.01 - 2014-06-18 - fix stb_vorbis_get_samples_float + 1.0 - 2014-05-26 - fix memory leaks; fix warnings; fix bugs in multichannel + (API change) report sample rate for decode-full-file funcs + 0.99996 - bracket #include for macintosh compilation by Laurent Gomila + 0.99995 - use union instead of pointer-cast for fast-float-to-int to avoid alias-optimization problem + 0.99994 - change fast-float-to-int to work in single-precision FPU mode, remove endian-dependence + 0.99993 - remove assert that fired on legal files with empty tables + 0.99992 - rewind-to-start + 0.99991 - bugfix to stb_vorbis_get_samples_short by Bernhard Wodo + 0.9999 - (should have been 0.99990) fix no-CRT support, compiling as C++ + 0.9998 - add a full-decode function with a memory source + 0.9997 - fix a bug in the read-from-FILE case in 0.9996 addition + 0.9996 - query length of vorbis stream in samples/seconds + 0.9995 - bugfix to another optimization that only happened in certain files + 0.9994 - bugfix to one of the optimizations that caused significant (but inaudible?) errors + 0.9993 - performance improvements; runs in 99% to 104% of time of reference implementation + 0.9992 - performance improvement of IMDCT; now performs close to reference implementation + 0.9991 - performance improvement of IMDCT + 0.999 - (should have been 0.9990) performance improvement of IMDCT + 0.998 - no-CRT support from Casey Muratori + 0.997 - bugfixes for bugs found by Terje Mathisen + 0.996 - bugfix: fast-huffman decode initialized incorrectly for sparse codebooks; fixing gives 10% speedup - found by Terje Mathisen + 0.995 - bugfix: fix to 'effective' overrun detection - found by Terje Mathisen + 0.994 - bugfix: garbage decode on final VQ symbol of a non-multiple - found by Terje Mathisen + 0.993 - bugfix: pushdata API required 1 extra byte for empty page (failed to consume final page if empty) - found by Terje Mathisen + 0.992 - fixes for MinGW warning + 0.991 - turn fast-float-conversion on by default + 0.990 - fix push-mode seek recovery if you seek into the headers + 0.98b - fix to bad release of 0.98 + 0.98 - fix push-mode seek recovery; robustify float-to-int and support non-fast mode + 0.97 - builds under c++ (typecasting, don't use 'class' keyword) + 0.96 - somehow MY 0.95 was right, but the web one was wrong, so here's my 0.95 rereleased as 0.96, fixes a typo in the clamping code + 0.95 - clamping code for 16-bit functions + 0.94 - not publically released + 0.93 - fixed all-zero-floor case (was decoding garbage) + 0.92 - fixed a memory leak + 0.91 - conditional compiles to omit parts of the API and the infrastructure to support them: STB_VORBIS_NO_PULLDATA_API, STB_VORBIS_NO_PUSHDATA_API, STB_VORBIS_NO_STDIO, STB_VORBIS_NO_INTEGER_CONVERSION + 0.90 - first public release +*/ + +#endif // STB_VORBIS_HEADER_ONLY + + +/* +------------------------------------------------------------------------------ +This software is available under 2 licenses -- choose whichever you prefer. +------------------------------------------------------------------------------ +ALTERNATIVE A - MIT License +Copyright (c) 2017 Sean Barrett +Permission is hereby granted, free of charge, to any person obtaining a copy of +this software and associated documentation files (the "Software"), to deal in +the Software without restriction, including without limitation the rights to +use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +of the Software, and to permit persons to whom the Software is furnished to do +so, subject to the following conditions: +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. +------------------------------------------------------------------------------ +ALTERNATIVE B - Public Domain (www.unlicense.org) +This is free and unencumbered software released into the public domain. +Anyone is free to copy, modify, publish, use, compile, sell, or distribute this +software, either in source code form or as a compiled binary, for any purpose, +commercial or non-commercial, and by any means. +In jurisdictions that recognize copyright laws, the author or authors of this +software dedicate any and all copyright interest in the software to the public +domain. We make this dedication for the benefit of the public at large and to +the detriment of our heirs and successors. We intend this dedication to be an +overt act of relinquishment in perpetuity of all present and future rights to +this software under copyright law. +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN +ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +------------------------------------------------------------------------------ +*/ \ No newline at end of file diff --git a/stdafx.h b/stdafx.h index d4c1225e..57bdfa9b 100644 --- a/stdafx.h +++ b/stdafx.h @@ -18,14 +18,20 @@ #endif // _DEBUG #endif // operating system +#ifdef _WIN32 #include "targetver.h" #define NOMINMAX #include #include #undef NOMINMAX #include +#include +#include +#endif // stl +#include #include +#include #include #define _USE_MATH_DEFINES #include @@ -35,6 +41,7 @@ #include #include #include +#include #include #include #include @@ -43,6 +50,7 @@ #include #include #include +#include #include #include #include @@ -58,3 +66,54 @@ #include #include #include + +#ifdef NDEBUG +#define EU07_BUILD_STATIC +#endif + +#ifdef EU07_BUILD_STATIC +#define GLEW_STATIC +#else +#ifdef _WIN32 +#define GLFW_DLL +#endif // _windows +#endif // build_static +#ifndef __ANDROID__ +#include "GL/glew.h" +#else +#include +#include +#endif +#ifdef _WIN32 +#include "GL/wglew.h" +#endif +#define GLFW_INCLUDE_GLU +//m7todo: jest tu bo nie chciao mi si wpycha do wszystkich plikw +#ifndef __ANDROID__ +#include +#endif + +#define GLM_ENABLE_EXPERIMENTAL +#define GLM_FORCE_CTOR_INIT +#include +#include +#include +#include +#include +#include +#include + +int const null_handle = 0; + +#include "openglmatrixstack.h" +#include "openglcolor.h" + +// imgui.h comes with its own operator new which gets wrecked by dbg_new, so we temporarily disable the latter +#ifdef DBG_NEW +#pragma push_macro("new") +#undef new +#include "imgui.h" +#pragma pop_macro("new") +#else +#include "imgui.h" +#endif diff --git a/sun.cpp b/sun.cpp new file mode 100644 index 00000000..c29c5856 --- /dev/null +++ b/sun.cpp @@ -0,0 +1,282 @@ + +#include "stdafx.h" +#include "sun.h" +#include "globals.h" +#include "mtable.h" +#include "utilities.h" +#include "simulationtime.h" + +////////////////////////////////////////////////////////////////////////////////////////// +// cSun -- class responsible for dynamic calculation of position and intensity of the Sun, + +cSun::cSun() { + + setLocation( 19.00f, 52.00f ); // default location roughly in centre of Poland + m_observer.press = 1013.0; // surface pressure, millibars + m_observer.temp = 15.0; // ambient dry-bulb temperature, degrees C +} + +cSun::~cSun() { gluDeleteQuadric( sunsphere ); } + +void +cSun::init() { + + m_observer.timezone = -1.0 * simulation::Time.zone_bias(); + + sunsphere = gluNewQuadric(); + gluQuadricNormals( sunsphere, GLU_SMOOTH ); +} + +void +cSun::update() { + + m_observer.temp = Global.AirTemperature; + + move(); + glm::vec3 position( 0.f, 0.f, -1.f ); + position = glm::rotateX( position, glm::radians( static_cast( m_body.elevref ) ) ); + position = glm::rotateY( position, glm::radians( static_cast( -m_body.hrang ) ) ); + + m_position = glm::normalize( position ); +} + +void +cSun::render() { + + ::glColor4f( 255.f / 255.f, 242.f / 255.f, 231.f / 255.f, 1.f ); + // debug line to locate the sun easier + auto const position { m_position * 2000.f }; + ::glBegin( GL_LINES ); + ::glVertex3fv( glm::value_ptr( position ) ); + ::glVertex3f( position.x, 0.f, position.z ); + ::glEnd(); + ::glPushMatrix(); + ::glTranslatef( position.x, position.y, position.z ); + // radius is a result of scaling true distance down to 2km -- it's scaled by equal ratio + ::gluSphere( sunsphere, m_body.distance * 9.359157, 12, 12 ); + ::glPopMatrix(); +} +/* +glm::vec3 +cSun::getPosition() { + + return m_position * 1000.f * Global.fDistanceFactor; +} +*/ +glm::vec3 +cSun::getDirection() { + + return m_position; +} + +float +cSun::getAngle() { + + return (float)m_body.elevref; +} + +// return current hour angle +double +cSun::getHourAngle() const { + + return m_body.hrang; +} + +float cSun::getIntensity() { + + irradiance(); + return (float)( m_body.etr/ 1399.0 ); // arbitrary scaling factor taken from etrn value +} + +void cSun::setLocation( float const Longitude, float const Latitude ) { + + // convert fraction from geographical base of 6o minutes + m_observer.longitude = (int)Longitude + (Longitude - (int)(Longitude)) * 100.0 / 60.0; + m_observer.latitude = (int)Latitude + (Latitude - (int)(Latitude)) * 100.0 / 60.0 ; +} + +// sets current time, overriding one acquired from the system clock +void cSun::setTime( int const Hour, int const Minute, int const Second ) { + + m_observer.hour = clamp( Hour, -1, 23 ); + m_observer.minute = clamp( Minute, -1, 59 ); + m_observer.second = clamp( Second, -1, 59 ); +} + +void cSun::setTemperature( float const Temperature ) { + + m_observer.temp = Temperature; +} + +void cSun::setPressure( float const Pressure ) { + + m_observer.press = Pressure; +} + +void cSun::move() { + + static double radtodeg = 57.295779513; // converts from radians to degrees + static double degtorad = 0.0174532925; // converts from degrees to radians + + SYSTEMTIME localtime = simulation::Time.data(); // time for the calculation + + if( m_observer.hour >= 0 ) { localtime.wHour = m_observer.hour; } + if( m_observer.minute >= 0 ) { localtime.wMinute = m_observer.minute; } + if( m_observer.second >= 0 ) { localtime.wSecond = m_observer.second; } + + double localut = + localtime.wHour + + localtime.wMinute / 60.0 // too low resolution, noticeable skips + + localtime.wSecond / 3600.0; // good enough in normal circumstances +/* + + localtime.wMilliseconds / 3600000.0; // for really smooth movement +*/ + double daynumber = + 367 * localtime.wYear + - 7 * ( localtime.wYear + ( localtime.wMonth + 9 ) / 12 ) / 4 + + 275 * localtime.wMonth / 9 + + localtime.wDay + - 730530 + + ( localut / 24.0 ); + + // Universal Coordinated (Greenwich standard) time + m_observer.utime = localut - m_observer.timezone; + // perihelion longitude + m_body.phlong = 282.9404 + 4.70935e-5 * daynumber; // w + // orbit eccentricity + double const e = 0.016709 - 1.151e-9 * daynumber; + // mean anomaly + m_body.mnanom = clamp_circular( 356.0470 + 0.9856002585 * daynumber ); // M + // obliquity of the ecliptic + m_body.oblecl = 23.4393 - 3.563e-7 * daynumber; + // mean longitude + m_body.mnlong = clamp_circular( m_body.phlong + m_body.mnanom ); // L = w + M + // eccentric anomaly + double const E = m_body.mnanom + radtodeg * e * std::sin( degtorad * m_body.mnanom ) * ( 1.0 + e * std::cos( degtorad * m_body.mnanom ) ); + // ecliptic plane rectangular coordinates + double const xv = std::cos( degtorad * E ) - e; + double const yv = std::sin( degtorad * E ) * std::sqrt( 1.0 - e*e ); + // distance + m_body.distance = std::sqrt( xv*xv + yv*yv ); // r + // true anomaly + m_body.tranom = radtodeg * std::atan2( yv, xv ); // v + // ecliptic longitude + m_body.eclong = clamp_circular( m_body.tranom + m_body.phlong ); // lon = v + w +/* + // ecliptic rectangular coordinates + double const x = m_body.distance * std::cos( degtorad * m_body.eclong ); + double const y = m_body.distance * std::sin( degtorad * m_body.eclong ); + double const z = 0.0; + // equatorial rectangular coordinates + double const xequat = x; + double const yequat = y * std::cos( degtorad * m_body.oblecl ) - 0.0 * std::sin( degtorad * m_body.oblecl ); + double const zequat = y * std::sin( degtorad * m_body.oblecl ) + 0.0 * std::cos( degtorad * m_body.oblecl ); + // declination + m_body.declin = radtodeg * std::atan2( zequat, std::sqrt( xequat*xequat + yequat*yequat ) ); + // right ascension + m_body.rascen = radtodeg * std::atan2( yequat, xequat ); +*/ + // declination + m_body.declin = radtodeg * std::asin( std::sin( m_body.oblecl * degtorad ) * std::sin( m_body.eclong * degtorad ) ); + + // right ascension + double top = std::cos( degtorad * m_body.oblecl ) * std::sin( degtorad * m_body.eclong ); + double bottom = std::cos( degtorad * m_body.eclong ); + + m_body.rascen = clamp_circular( radtodeg * std::atan2( top, bottom ) ); + + // Greenwich mean sidereal time + m_observer.gmst = 6.697375 + 0.0657098242 * daynumber + m_observer.utime; + + m_observer.gmst -= 24.0 * (int)( m_observer.gmst / 24.0 ); + if( m_observer.gmst < 0.0 ) m_observer.gmst += 24.0; + + // local mean sidereal time + m_observer.lmst = m_observer.gmst * 15.0 + m_observer.longitude; + + m_observer.lmst -= 360.0 * (int)( m_observer.lmst / 360.0 ); + if( m_observer.lmst < 0.0 ) m_observer.lmst += 360.0; + + // hour angle + m_body.hrang = m_observer.lmst - m_body.rascen; + + if( m_body.hrang < -180.0 ) m_body.hrang += 360.0; // (force it between -180 and 180 degrees) + else if( m_body.hrang > 180.0 ) m_body.hrang -= 360.0; + + double cz; // cosine of the solar zenith angle + + double tdatcd = std::cos( degtorad * m_body.declin ); + double tdatch = std::cos( degtorad * m_body.hrang ); + double tdatcl = std::cos( degtorad * m_observer.latitude ); + double tdatsd = std::sin( degtorad * m_body.declin ); + double tdatsl = std::sin( degtorad * m_observer.latitude ); + + cz = tdatsd * tdatsl + tdatcd * tdatcl * tdatch; + + // (watch out for the roundoff errors) + if( fabs( cz ) > 1.0 ) { cz >= 0.0 ? cz = 1.0 : cz = -1.0; } + + m_body.zenetr = std::acos( cz ) * radtodeg; + m_body.elevetr = 90.0 - m_body.zenetr; + refract(); +} + +void cSun::refract() { + + static double raddeg = 0.0174532925; // converts from degrees to radians + + double prestemp; // temporary pressure/temperature correction + double refcor; // temporary refraction correction + double tanelev; // tangent of the solar elevation angle + + // if the sun is near zenith, the algorithm bombs; refraction near 0. + if( m_body.elevetr > 85.0 ) + refcor = 0.0; + else { + + tanelev = tan( raddeg * m_body.elevetr ); + if( m_body.elevetr >= 5.0 ) + refcor = 58.1 / tanelev + - 0.07 / pow( tanelev, 3 ) + + 0.000086 / pow( tanelev, 5 ); + else if( m_body.elevetr >= -0.575 ) + refcor = 1735.0 + + m_body.elevetr * ( -518.2 + m_body.elevetr * + ( 103.4 + m_body.elevetr * ( -12.79 + m_body.elevetr * 0.711 ) ) ); + else + refcor = -20.774 / tanelev; + + prestemp = ( m_observer.press * 283.0 ) / ( 1013.0 * ( 273.0 + m_observer.temp ) ); + refcor *= prestemp / 3600.0; + } + + // refracted solar elevation angle + m_body.elevref = m_body.elevetr + refcor; + + // refracted solar zenith angle + m_body.zenref = 90.0 - m_body.elevref; +} + +void cSun::irradiance() { + + m_body.dayang = ( simulation::Time.year_day() - 1 ) * 360.0 / 365.0; + double sd = std::sin( glm::radians( m_body.dayang ) ); // sine of the day angle + double cd = std::cos( glm::radians( m_body.dayang ) ); // cosine of the day angle or delination + m_body.erv = 1.000110 + 0.034221*cd + 0.001280*sd; + double d2 = 2.0 * m_body.dayang; + double c2 = std::cos( glm::radians( d2 ) ); + double s2 = std::sin( glm::radians( d2 ) ); + m_body.erv += 0.000719*c2 + 0.000077*s2; + + double solcon = 1367.0; // Solar constant, 1367 W/sq m + + m_body.coszen = std::cos( glm::radians( m_body.zenref ) ); + if( m_body.coszen > 0.0 ) { + m_body.etrn = solcon * m_body.erv; + m_body.etr = m_body.etrn * m_body.coszen; + } + else { + m_body.etrn = 0.0; + m_body.etr = 0.0; + } +} diff --git a/sun.h b/sun.h new file mode 100644 index 00000000..babc14af --- /dev/null +++ b/sun.h @@ -0,0 +1,105 @@ +#pragma once + +#include "windows.h" +#include "GL/glew.h" +#include "GL/wglew.h" + + +////////////////////////////////////////////////////////////////////////////////////////// +// cSun -- class responsible for dynamic calculation of position and intensity of the Sun, +// given current weather, time and geographic location. + +class cSun { + +public: +// types: + +// methods: + void init(); + void update(); + void render(); +/* + // returns location of the sun in the 3d scene + glm::vec3 getPosition(); +*/ + // returns vector pointing at the sun + glm::vec3 getDirection(); + // returns current elevation above horizon + float getAngle(); + // return current hour angle + double getHourAngle() const; + // returns current intensity of the sun + float getIntensity(); + // sets current time, overriding one acquired from the system clock + void setTime( int const Hour, int const Minute, int const Second ); + // sets current geographic location + void setLocation( float const Longitude, float const Latitude ); + // sets ambient temperature in degrees C. + void setTemperature( float const Temperature ); + // sets surface pressure in milibars + void setPressure( float const Pressure ); + +// constructors: + cSun(); + +// deconstructor: + ~cSun(); + +// members: + +protected: +// types: + +// methods: + // calculates sun position on the sky given specified time and location + void move(); + // calculates position adjustment due to refraction + void refract(); + // calculates light intensity at current moment + void irradiance(); + +// members: + GLUquadricObj *sunsphere; // temporary handler for sun positioning test + + struct celestialbody { // main planet parameters + + double dayang; // day angle (daynum*360/year-length) degrees + double phlong; // longitude of perihelion + double mnlong; // mean longitude, degrees + double mnanom; // mean anomaly, degrees + double tranom; // true anomaly, degrees + double eclong; // ecliptic longitude, degrees. + double oblecl; // obliquity of ecliptic. + double declin; // declination--zenith angle of solar noon at equator, degrees NORTH. + double rascen; // right ascension, degrees + double hrang; // hour angle--hour of sun from solar noon, degrees WEST + double zenetr; // solar zenith angle, no atmospheric correction (= ETR) + double zenref; // solar zenith angle, deg. from zenith, refracted + double coszen; // cosine of refraction corrected solar zenith angle + double elevetr; // solar elevation, no atmospheric correction (= ETR) + double elevref; // solar elevation angle, deg. from horizon, refracted. + double distance; // distance from earth in AUs + double erv; // earth radius vector (multiplied to solar constant) + double etr; // extraterrestrial (top-of-atmosphere) W/sq m global horizontal solar irradiance + double etrn; // extraterrestrial (top-of-atmosphere) W/sq m direct normal solar irradiance + }; + + struct observer { // weather, time and position data in observer's location + + double latitude; // latitude, degrees north (south negative) + double longitude; // longitude, degrees east (west negative) + int hour{ -1 }; // current time, used for calculation of utime. if set to -1, time for + int minute{ -1 };// calculation will be obtained from the local clock + int second{ -1 }; + double utime; // universal (Greenwich) standard time + double timezone; // time zone, east (west negative). USA: Mountain = -7, Central = -6, etc. + double gmst; // Greenwich mean sidereal time, hours + double lmst; // local mean sidereal time, degrees + double temp; // ambient dry-bulb temperature, degrees C, used for refraction correction + double press; // surface pressure, millibars, used for refraction correction and ampress + }; + + celestialbody m_body; + observer m_observer; + glm::vec3 m_position; +}; diff --git a/translation.cpp b/translation.cpp new file mode 100644 index 00000000..1ffa38f9 --- /dev/null +++ b/translation.cpp @@ -0,0 +1,433 @@ +/* +This Source Code Form is subject to the +terms of the Mozilla Public License, v. +2.0. If a copy of the MPL was not +distributed with this file, You can +obtain one at +http://mozilla.org/MPL/2.0/. +*/ +/* + MaSzyna EU07 locomotive simulator + Copyright (C) 2001-2004 Marcin Wozniak, Maciej Czapkiewicz and others +*/ + +#include "stdafx.h" +#include "translation.h" + +#include "globals.h" + +namespace locale { + +void +init() { + // TODO: import localized strings from localization files + std::unordered_map> stringmap; + + stringmap.insert( + { "en", + { + "Driving Aid", + "Throttle: %2d+%d %c%s", + " Speed: %d km/h (limit %d km/h%s)%s", + ", new limit: %d km/h in %.1f km", + " Grade: %.1f%%%%", + "Brakes: %4.1f+%-2.0f%c%s", + " Pressure: %.2f kPa (train pipe: %.2f kPa)", + "!ALERTER! ", + "!SHP!", + " Loading/unloading in progress (%d s left)", + " Another vehicle ahead (distance: %.1f m)", + + "Timetable", + "Time: %d:%02d:%02d", + "(no timetable)", + + "Transcripts", + + "Simulation Paused", + "Resume", + "Quit", + + "Name: %s%s\nLoad: %.0f %s\nStatus: %s%s\nCouplers:\n front: %s\n rear: %s", + ", owned by: ", + "none", + "Devices: %c%c%c%c%c%c%c%c%c%c%c%c%c%c%s%s\nPower transfers: %.0f@%.0f%s%s%s%.0f@%.0f", + " radio: ", + " oil pressure: ", + "Controllers:\n master: %d(%d), secondary: %s\nEngine output: %.1f, current: %.0f\nRevolutions:\n engine: %.0f, motors: %.0f\n engine fans: %.0f, motor fans: %.0f+%.0f, cooling fans: %.0f+%.0f", + " (shunt mode)", + "\nTemperatures:\n engine: %.2f, oil: %.2f, water: %.2f%c%.2f", + "Brakes:\n train: %.2f, independent: %.2f, delay: %s, load flag: %d\nBrake cylinder pressures:\n train: %.2f, independent: %.2f, status: 0x%.2x\nPipe pressures:\n brake: %.2f (hat: %.2f), main: %.2f, control: %.2f\nTank pressures:\n auxiliary: %.2f, main: %.2f, control: %.2f", + " pantograph: %.2f%cMT", + "Forces:\n tractive: %.1f, brake: %.1f, friction: %.2f%s\nAcceleration:\n tangential: %.2f, normal: %.2f (path radius: %s)\nVelocity: %.2f, distance traveled: %.2f\nPosition: [%.2f, %.2f, %.2f]", + + "master controller", + "second controller", + "shunt mode power", + "reverser", + "train brake", + "independent brake", + "manual brake", + "emergency brake", + "brake acting speed", + "brake acting speed: cargo", + "brake acting speed: rapid", + "motor overload relay threshold", + "water pump", + "water pump breaker", + "water heater", + "water heater breaker", + "water circuits link", + "fuel pump", + "oil pump", + "motor blowers A", + "motor blowers B", + "all motor blowers", + "line breaker", + "line breaker", + "alerter", + "independent brake releaser", + "sandbox", + "wheelspin brake", + "horn", + "low tone horn", + "high tone horn", + "whistle", + "motor overload relay reset", + "converter overload relay reset", + "motor connectors", + "left door", + "right door", + "left door", + "right door", + "left door", + "right door", + "all doors", + "departure signal", + "upper headlight", + "left headlight", + "right headlight", + "headlights dimmer", + "left marker light", + "right marker light", + "light pattern", + "rear upper headlight", + "rear left headlight", + "rear right headlight", + "rear left marker light", + "rear right marker light", + "compressor", + "local compressor", + "converter", + "local converter", + "converter", + "line breaker", + "radio", + "radio channel", + "radio channel", + "radio channel", + "radiostop test", + "radiostop", + "pantograph A", + "pantograph B", + "pantograph A", + "pantograph B", + "all pantographs", + "selected pantograph", + "selected pantograph", + "pantograph compressor", + "pantograph 3 way valve", + "heating", + "braking indicator", + "door locking", + "current indicator source", + "instrument light", + "dashboard light", + "timetable light", + "interior light", + "interior light dimmer", + "battery", + "interactive part", + "interactive part", + "interactive part", + "interactive part", + "interactive part", + "interactive part", + "interactive part", + "interactive part", + "interactive part", + "interactive part" + } + } ); + + stringmap.insert( + { "pl", + { + "Pomocnik", + "Nastawnik: %2d+%d %c%s", + " Predkosc: %d km/h (limit %d km/h%s)%s", + ", nowy limit: %d km/h za %.1f km", + " Pochylenie: %.1f%%%%", + "Hamulce: %4.1f+%-2.0f%c%s", + " Cisnienie: %.2f kPa (przewod glowny: %.2f kPa)", + "!CZUWAK! ", + "!SHP!", + " Wsiadanie/wysiadanie pasazerow (do zakonczenia %d s)", + " Inny pojazd na drodze (odleglosc: %.1f m)", + + "Rozklad jazdy", + "Godzina: %d:%02d:%02d", + "(brak rozkladu)", + + "Transkrypcje", + + "Symulacja wstrzymana", + "Wznow", + "Zakoncz", + + "Nazwa: %s%s\nLadunek: %.0f %s\nStatus: %s%s\nSprzegi:\n przedni: %s\n tylny: %s", + ", wlasciciel: ", + "wolny", + "Urzadzenia: %c%c%c%c%c%c%c%c%c%c%c%c%c%c%s%s\nTransfer pradow: %.0f@%.0f%s%s%s%.0f@%.0f", + " radio: ", + " cisn.oleju: ", + "Nastawniki:\n glowny: %d(%d), dodatkowy: %s\nMoc silnika: %.1f, prad silnika: %.0f\nObroty:\n silnik: %.0f, motory: %.0f\n went.silnika: %.0f, went.motorow: %.0f+%.0f, went.chlodnicy: %.0f+%.0f", + " (tryb manewrowy)", + "\nTemperatury:\n silnik: %.2f, olej: %.2f, woda: %.2f%c%.2f", + "Hamulce:\n zespolony: %.2f, pomocniczy: %.2f, nastawa: %s, ladunek: %d\nCisnienie w cylindrach:\n zespolony: %.2f, pomocniczy: %.2f, status: 0x%.2x\nCisnienia w przewodach:\n glowny: %.2f (kapturek: %.2f), zasilajacy: %.2f, kontrolny: %.2f\nCisnienia w zbiornikach:\n pomocniczy: %.2f, glowny: %.2f, sterujacy: %.2f", + " pantograf: %.2f%cZG", + "Sily:\n napedna: %.1f, hamowania: %.1f, tarcie: %.2f%s\nPrzyspieszenia:\n styczne: %.2f, normalne: %.2f (promien: %s)\nPredkosc: %.2f, pokonana odleglosc: %.2f\nPozycja: [%.2f, %.2f, %.2f]", + + "nastawnik jazdy", + "nastawnik dodatkowy", + "sterowanie analogowe", + "nastawnik kierunku", + "hamulec zespolony", + "hamulec pomocniczy", + "hamulec reczny", + "hamulec bezpieczenstwa", + "nastawa hamulca", + "nastawa hamulca: towarowy", + "nastawa hamulca: pospieszny", + "zakres pradu rozruchu", + "pompa wody", + "wylacznik samoczynny pompy wody", + "podgrzewacz wody", + "wylacznik samoczynny podgrzewacza wody", + "zawor polaczenia obiegow wody", + "pompa paliwa", + "pompa oleju", + "wentylatory silnikow trakcyjnych A", + "wentylatory silnikow trakcyjnych B", + "wszystkie wentylatory silnikow trakcyjnych", + "wylacznik szybki", + "wylacznik szybki", + "czuwak", + "odluzniacz", + "piasecznica", + "hamulec przeciwposlizgowy", + "syrena", + "syrena (ton niski)", + "syrena (ton wysoki)", + "gwizdawka", + "przekaznik nadmiarowy silnikow trakcyjnych", + "przekaznik nadmiarowy przetwornicy", + "styczniki liniowe", + "drzwi lewe", + "drzwi prawe", + "drzwi lewe", + "drzwi prawe", + "drzwi lewe", + "drzwi prawe", + "drzwi", + "sygnal odjazdu", + "reflektor gorny", + "reflektor lewy", + "reflektor prawy", + "przyciemnienie reflektorow", + "sygnal lewy", + "sygnal prawy", + "programator swiatel", + "tylny reflektor gorny", + "tylny reflektor lewy", + "tylny reflektor prawy", + "tylny sygnal lewy", + "tylny sygnal prawy", + "sprezarka", + "sprezarka lokalna", + "przetwornica", + "przetwornica lokalna", + "przetwornica", + "wylacznik szybki", + "radio", + "kanal radia", + "kanal radia", + "kanal radia", + "test radiostopu", + "radiostop", + "pantograf A", + "pantograf B", + "pantograf A", + "pantograf B", + "wszystkie pantografy", + "wybrany pantograf", + "wybrany pantograf", + "sprezarka pantografow", + "kurek trojdrogowy pantografow", + "ogrzewanie pociagu", + "sygnalizacja hamowania", + "blokada drzwi", + "prady drugiego czlonu", + "oswietlenie przyrzadow", + "oswietlenie pulpitu", + "oswietlenie rozkladu jazdy", + "oswietlenie kabiny", + "przyciemnienie oswietlenia kabiny", + "bateria", + "element ruchomy", + "element ruchomy", + "element ruchomy", + "element ruchomy", + "element ruchomy", + "element ruchomy", + "element ruchomy", + "element ruchomy", + "element ruchomy", + "element ruchomy" + } + } ); + + auto lookup { stringmap.find( Global.asLang ) }; + if( lookup == stringmap.end() ) { + lookup = stringmap.find( "en" ); + } + + locale::strings = lookup->second; + + // prepare cab controls translation table + { + std::vector cabcontrols = { + "mainctrl:", + "scndctrl:", + "shuntmodepower:", + "dirkey:", + "brakectrl:", + "localbrake:", + "manualbrake:", + "alarmchain:", + "brakeprofile_sw:", + "brakeprofileg_sw:", + "brakeprofiler_sw:", + "maxcurrent_sw:", + "waterpump_sw:", + "waterpumpbreaker_sw:", + "waterheater_sw:", + "waterheaterbreaker_sw:", + "watercircuitslink_sw:", + "fuelpump_sw:", + "oilpump_sw:", + "motorblowersfront_sw:", + "motorblowersrear_sw:", + "motorblowersalloff_sw:", + "main_off_bt:", + "main_on_bt:", + "security_reset_bt:", + "releaser_bt:", + "sand_bt:", + "antislip_bt:", + "horn_bt:", + "hornlow_bt:", + "hornhigh_bt:", + "whistle_bt:", + "fuse_bt:", + "converterfuse_bt:", + "stlinoff_bt:", + "door_left_sw:", + "door_right_sw:", + "doorlefton_sw:", + "doorrighton_sw:", + "doorleftoff_sw:", + "doorrightoff_sw:", + "dooralloff_sw:", + "departure_signal_bt:", + "upperlight_sw:", + "leftlight_sw:", + "rightlight_sw:", + "dimheadlights_sw:", + "leftend_sw:", + "rightend_sw:", + "lights_sw:", + "rearupperlight_sw:", + "rearleftlight_sw:", + "rearrightlight_sw:", + "rearleftend_sw:", + "rearrightend_sw:", + "compressor_sw:", + "compressorlocal_sw:", + "converter_sw:", + "converterlocal_sw:", + "converteroff_sw:", + "main_sw:", + "radio_sw:", + "radiochannel_sw:", + "radiochannelprev_sw:", + "radiochannelnext_sw:", + "radiotest_sw:", + "radiostop_sw:", + "pantfront_sw:", + "pantrear_sw:", + "pantfrontoff_sw:", + "pantrearoff_sw:", + "pantalloff_sw:", + "pantselected_sw:", + "pantselectedoff_sw:", + "pantcompressor_sw:", + "pantcompressorvalve_sw:", + "trainheating_sw:", + "signalling_sw:", + "door_signalling_sw:", + "nextcurrent_sw:", + "instrumentlight_sw:", + "dashboardlight_sw:", + "timetablelight_sw:", + "cablight_sw:", + "cablightdim_sw:", + "battery_sw:", + "universal0:", + "universal1:", + "universal2:", + "universal3:", + "universal4:", + "universal5:", + "universal6:", + "universal7:", + "universal8:", + "universal9:" + }; + + std::size_t stringidx { string::cab_mainctrl }; + for( auto const &cabcontrol : cabcontrols ) { + m_cabcontrols.insert( { cabcontrol, strings[ stringidx++ ] } ); + } + } +} + +std::string +label_cab_control( std::string const &Label ) { + + if( Label.empty() ) { return ""; } + + auto const lookup = m_cabcontrols.find( Label ); + return ( + lookup != m_cabcontrols.end() ? + lookup->second : + "" ); +} + +std::vector strings; + +std::unordered_map m_cabcontrols; + +} // namespace locale + +//--------------------------------------------------------------------------- diff --git a/translation.h b/translation.h new file mode 100644 index 00000000..4d40b762 --- /dev/null +++ b/translation.h @@ -0,0 +1,165 @@ +/* +This Source Code Form is subject to the +terms of the Mozilla Public License, v. +2.0. If a copy of the MPL was not +distributed with this file, You can +obtain one at +http://mozilla.org/MPL/2.0/. +*/ + +#pragma once + +#include +#include + +namespace locale { + +enum string { + driver_aid_header, + driver_aid_throttle, + driver_aid_speedlimit, + driver_aid_nextlimit, + driver_aid_grade, + driver_aid_brakes, + driver_aid_pressures, + driver_aid_alerter, + driver_aid_shp, + driver_aid_loadinginprogress, + driver_aid_vehicleahead, + + driver_timetable_header, + driver_timetable_time, + driver_timetable_notimetable, + + driver_transcripts_header, + + driver_pause_header, + driver_pause_resume, + driver_pause_quit, + + debug_vehicle_nameloadstatuscouplers, + debug_vehicle_owned, + debug_vehicle_none, + debug_vehicle_devicespower, + debug_vehicle_radio, + debug_vehicle_oilpressure, + debug_vehicle_controllersenginerevolutions, + debug_vehicle_shuntmode, + debug_vehicle_temperatures, + debug_vehicle_brakespressures, + debug_vehicle_pantograph, + debug_vehicle_forcesaccelerationvelocityposition, + + cab_mainctrl, + cab_scndctrl, + cab_shuntmodepower, + cab_dirkey, + cab_brakectrl, + cab_localbrake, + cab_manualbrake, + cab_alarmchain, + cab_brakeprofile_sw, + cab_brakeprofileg_sw, + cab_brakeprofiler_sw, + cab_maxcurrent_sw, + cab_waterpump_sw, + cab_waterpumpbreaker_sw, + cab_waterheater_sw, + cab_waterheaterbreaker_sw, + cab_watercircuitslink_sw, + cab_fuelpump_sw, + cab_oilpump_sw, + cab_motorblowersfront_sw, + cab_motorblowersrear_sw, + cab_motorblowersalloff_sw, + cab_main_off_bt, + cab_main_on_bt, + cab_security_reset_bt, + cab_releaser_bt, + cab_sand_bt, + cab_antislip_bt, + cab_horn_bt, + cab_hornlow_bt, + cab_hornhigh_bt, + cab_whistle_bt, + cab_fuse_bt, + cab_converterfuse_bt, + cab_stlinoff_bt, + cab_door_left_sw, + cab_door_right_sw, + cab_doorlefton_sw, + cab_doorrighton_sw, + cab_doorleftoff_sw, + cab_doorrightoff_sw, + cab_dooralloff_sw, + cab_departure_signal_bt, + cab_upperlight_sw, + cab_leftlight_sw, + cab_rightlight_sw, + cab_dimheadlights_sw, + cab_leftend_sw, + cab_rightend_sw, + cab_lights_sw, + cab_rearupperlight_sw, + cab_rearleftlight_sw, + cab_rearrightlight_sw, + cab_rearleftend_sw, + cab_rearrightend_sw, + cab_compressor_sw, + cab_compressorlocal_sw, + cab_converter_sw, + cab_converterlocal_sw, + cab_converteroff_sw, + cab_main_sw, + cab_radio_sw, + cab_radiochannel_sw, + cab_radiochannelprev_sw, + cab_radiochannelnext_sw, + cab_radiotest_sw, + cab_radiostop_sw, + cab_pantfront_sw, + cab_pantrear_sw, + cab_pantfrontoff_sw, + cab_pantrearoff_sw, + cab_pantalloff_sw, + cab_pantselected_sw, + cab_pantselectedoff_sw, + cab_pantcompressor_sw, + cab_pantcompressorvalve_sw, + cab_trainheating_sw, + cab_signalling_sw, + cab_door_signalling_sw, + cab_nextcurrent_sw, + cab_instrumentlight_sw, + cab_dashboardlight_sw, + cab_timetablelight_sw, + cab_cablight_sw, + cab_cablightdim_sw, + cab_battery_sw, + cab_universal0, + cab_universal1, + cab_universal2, + cab_universal3, + cab_universal4, + cab_universal5, + cab_universal6, + cab_universal7, + cab_universal8, + cab_universal9, + + string_count +}; + +void + init(); +std::string + label_cab_control( std::string const &Label ); + +extern std::vector strings; + +extern std::unordered_map m_cabcontrols; + +} + +//--------------------------------------------------------------------------- + diff --git a/uart.cpp b/uart.cpp new file mode 100644 index 00000000..55d3b56d --- /dev/null +++ b/uart.cpp @@ -0,0 +1,311 @@ +#include "stdafx.h" +#include "uart.h" + +#include "Globals.h" +#include "simulation.h" +#include "Train.h" +#include "parser.h" +#include "Logs.h" + +uart_input::uart_input() +{ + conf = Global.uart_conf; + + if (sp_get_port_by_name(conf.port.c_str(), &port) != SP_OK) + throw std::runtime_error("uart: cannot find specified port"); + + if (sp_open(port, SP_MODE_READ_WRITE) != SP_OK) + throw std::runtime_error("uart: cannot open port"); + + sp_port_config *config; + + if (sp_new_config(&config) != SP_OK || + sp_set_config_baudrate(config, conf.baud) != SP_OK || + sp_set_config_flowcontrol(config, SP_FLOWCONTROL_NONE) != SP_OK || + sp_set_config_bits(config, 8) != SP_OK || + sp_set_config_stopbits(config, 1) != SP_OK || + sp_set_config_parity(config, SP_PARITY_NONE) != SP_OK || + sp_set_config(port, config) != SP_OK) + throw std::runtime_error("uart: cannot set config"); + + sp_free_config(config); + + if (sp_flush(port, SP_BUF_BOTH) != SP_OK) + throw std::runtime_error("uart: cannot flush"); + + old_packet.fill(0); + last_update = std::chrono::high_resolution_clock::now(); +} + +uart_input::~uart_input() +{ + std::array buffer = { 0 }; + sp_blocking_write(port, (void*)buffer.data(), buffer.size(), 0); + sp_drain(port); + + sp_close(port); + sp_free_port(port); +} + +bool +uart_input::recall_bindings() { + + m_inputbindings.clear(); + + cParser bindingparser( "eu07_input-uart.ini", cParser::buffer_FILE ); + if( false == bindingparser.ok() ) { + return false; + } + + // build helper translation tables + std::unordered_map nametocommandmap; + std::size_t commandid = 0; + for( auto const &description : simulation::Commands_descriptions ) { + nametocommandmap.emplace( + description.name, + static_cast( commandid ) ); + ++commandid; + } + std::unordered_map nametotypemap { + { "impulse", input_type_t::impulse }, + { "toggle", input_type_t::toggle }, + { "value", input_type_t::value } }; + + // NOTE: to simplify things we expect one entry per line, and whole entry in one line + while( true == bindingparser.getTokens( 1, true, "\n" ) ) { + + std::string bindingentry; + bindingparser >> bindingentry; + cParser entryparser( bindingentry ); + + if( true == entryparser.getTokens( 2, true, "\n\r\t " ) ) { + + std::size_t bindingpin {}; + std::string bindingtypename {}; + entryparser + >> bindingpin + >> bindingtypename; + + auto const typelookup = nametotypemap.find( bindingtypename ); + if( typelookup == nametotypemap.end() ) { + + WriteLog( "Uart binding for input pin " + std::to_string( bindingpin ) + " specified unknown control type, \"" + bindingtypename + "\"" ); + } + else { + + auto const bindingtype { typelookup->second }; + std::array bindingcommands { user_command::none, user_command::none }; + auto const commandcount { ( bindingtype == input_type_t::toggle ? 2 : 1 ) }; + for( int commandidx = 0; commandidx < commandcount; ++commandidx ) { + // grab command(s) associated with the input pin + auto const bindingcommandname { entryparser.getToken() }; + if( true == bindingcommandname.empty() ) { + // no tokens left, may as well complain then call it a day + WriteLog( "Uart binding for input pin " + std::to_string( bindingpin ) + " didn't specify associated command(s)" ); + break; + } + auto const commandlookup = nametocommandmap.find( bindingcommandname ); + if( commandlookup == nametocommandmap.end() ) { + WriteLog( "Uart binding for input pin " + std::to_string( bindingpin ) + " specified unknown command, \"" + bindingcommandname + "\"" ); + } + else { + bindingcommands[ commandidx ] = commandlookup->second; + } + } + // push the binding on the list + m_inputbindings.emplace_back( bindingpin, bindingtype, bindingcommands[ 0 ], bindingcommands[ 1 ] ); + } + } + } + + return true; +} + +#define SPLIT_INT16(x) (uint8_t)x, (uint8_t)(x >> 8) + +void uart_input::poll() +{ + auto now = std::chrono::high_resolution_clock::now(); + if (std::chrono::duration(now - last_update).count() < conf.updatetime) + return; + last_update = now; + + auto const *t =simulation::Train; + if (!t) + return; + + sp_return ret; + + if ((ret = sp_input_waiting(port)) >= 16) + { + std::array buffer; // TBD, TODO: replace with vector of configurable size? + ret = sp_blocking_read(port, (void*)buffer.data(), buffer.size(), 0); + if (ret < 0) + throw std::runtime_error("uart: failed to read from port"); + + if (conf.debug) + { + char buf[buffer.size() * 3 + 1]; + size_t pos = 0; + for (uint8_t b : buffer) + pos += sprintf(&buf[pos], "%02X ", b); + WriteLog("uart: rx: " + std::string(buf)); + } + + data_pending = false; + + for (auto const &entry : m_inputbindings) { + + auto const byte { std::get( entry ) / 8 }; + auto const bit { std::get( entry ) % 8 }; + + bool const state { ( ( buffer[ byte ] & ( 1 << bit ) ) != 0 ) }; + bool const changed { ( ( ( old_packet[ byte ] & ( 1 << bit ) ) != 0 ) != state ) }; + + if( false == changed ) { continue; } + + auto const type { std::get( entry ) }; + auto const action { ( + type != input_type_t::impulse ? + GLFW_PRESS : + ( true == state ? + GLFW_PRESS : + GLFW_RELEASE ) ) }; + + auto const command { ( + type != input_type_t::toggle ? + std::get<2>( entry ) : + ( true == state ? + std::get<2>( entry ) : + std::get<3>( entry ) ) ) }; + + // TODO: pass correct entity id once the missing systems are in place + relay.post( command, 0, 0, action, 0 ); + } + + if( true == conf.mainenable ) { + // master controller + relay.post( + user_command::mastercontrollerset, + buffer[ 6 ], + 0, + GLFW_PRESS, + // TODO: pass correct entity id once the missing systems are in place + 0 ); + } + if( true == conf.scndenable ) { + // second controller + relay.post( + user_command::secondcontrollerset, + buffer[ 7 ], + 0, + GLFW_PRESS, + // TODO: pass correct entity id once the missing systems are in place + 0 ); + } + if( true == conf.trainenable ) { + // train brake + double const position { (float)( ( (uint16_t)buffer[ 8 ] | ( (uint16_t)buffer[ 9 ] << 8 ) ) - conf.mainbrakemin ) / ( conf.mainbrakemax - conf.mainbrakemin ) }; + relay.post( + user_command::trainbrakeset, + position, + 0, + GLFW_PRESS, + // TODO: pass correct entity id once the missing systems are in place + 0 ); + } + if( true == conf.localenable ) { + // independent brake + double const position { (float)( ( (uint16_t)buffer[ 10 ] | ( (uint16_t)buffer[ 11 ] << 8 ) ) - conf.localbrakemin ) / ( conf.localbrakemax - conf.localbrakemin ) }; + relay.post( + user_command::independentbrakeset, + position, + 0, + GLFW_PRESS, + // TODO: pass correct entity id once the missing systems are in place + 0 ); + } + + old_packet = buffer; + } + + if (!data_pending && sp_output_waiting(port) == 0) + { + // TODO: ugly! move it into structure like input_bits + auto const trainstate = t->get_state(); + + uint8_t tacho = Global.iPause ? 0 : trainstate.velocity; + uint16_t tank_press = (uint16_t)std::min(conf.tankuart, trainstate.reservoir_pressure * 0.1f / conf.tankmax * conf.tankuart); + uint16_t pipe_press = (uint16_t)std::min(conf.pipeuart, trainstate.pipe_pressure * 0.1f / conf.pipemax * conf.pipeuart); + uint16_t brake_press = (uint16_t)std::min(conf.brakeuart, trainstate.brake_pressure * 0.1f / conf.brakemax * conf.brakeuart); + uint16_t hv_voltage = (uint16_t)std::min(conf.hvuart, trainstate.hv_voltage / conf.hvmax * conf.hvuart); + uint16_t current1 = (uint16_t)std::min(conf.currentuart, trainstate.hv_current[0] / conf.currentmax * conf.currentuart); + uint16_t current2 = (uint16_t)std::min(conf.currentuart, trainstate.hv_current[1] / conf.currentmax * conf.currentuart); + uint16_t current3 = (uint16_t)std::min(conf.currentuart, trainstate.hv_current[2] / conf.currentmax * conf.currentuart); + + std::array buffer { + //byte 0 + tacho, + //byte 1 + 0, + //byte 2 + (uint8_t)( + trainstate.ventilator_overload << 1 + | trainstate.motor_overload_threshold << 2), + //byte 3 + (uint8_t)( + trainstate.coupled_hv_voltage_relays << 0), + //byte 4 + (uint8_t)( + trainstate.train_heating << 0 + | trainstate.motor_resistors << 1 + | trainstate.wheelslip << 2 + | trainstate.alerter << 6 + | trainstate.shp << 7), + //byte 5 + (uint8_t)( + trainstate.motor_connectors << 0 + | trainstate.converter_overload << 2 + | trainstate.motor_overload << 4 + | trainstate.line_breaker << 5 + | trainstate.compressor_overload << 6), + //byte 6 + (uint8_t)( + trainstate.recorder_braking << 3 + | trainstate.recorder_power << 4 + | trainstate.radio_stop <<5 + | trainstate.alerter_sound << 7), + //byte 7-8 + SPLIT_INT16(brake_press), + //byte 9-10 + SPLIT_INT16(pipe_press), + //byte 11-12 + SPLIT_INT16(tank_press), + //byte 13-14 + SPLIT_INT16(hv_voltage), + //byte 15-16 + SPLIT_INT16(current1), + //byte 17-18 + SPLIT_INT16(current2), + //byte 19-20 + SPLIT_INT16(current3), + //byte 21-30 + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 + }; + + if (conf.debug) + { + char buf[buffer.size() * 3 + 1]; + size_t pos = 0; + for (uint8_t b : buffer) + pos += sprintf(&buf[pos], "%02X ", b); + WriteLog("uart: tx: " + std::string(buf)); + } + + ret = sp_blocking_write(port, (void*)buffer.data(), buffer.size(), 0); + if (ret != buffer.size()) + throw std::runtime_error("uart: failed to write to port"); + + data_pending = true; + } +} diff --git a/uart.h b/uart.h new file mode 100644 index 00000000..b6e1dd6b --- /dev/null +++ b/uart.h @@ -0,0 +1,69 @@ +#pragma once + +#include +#include "command.h" + +class uart_input +{ +public: +// types + struct conf_t { + bool enable = false; + std::string port; + int baud; + float updatetime; + + float mainbrakemin = 0.0f; + float mainbrakemax = 65535.0f; + float localbrakemin = 0.0f; + float localbrakemax = 65535.0f; + float tankmax = 10.0f; + float tankuart = 65535.0f; + float pipemax = 10.0f; + float pipeuart = 65535.0f; + float brakemax = 10.0f; + float brakeuart = 65535.0f; + float hvmax = 100000.0f; + float hvuart = 65535.0f; + float currentmax = 10000.0f; + float currentuart = 65535.0f; + + bool mainenable = true; + bool scndenable = true; + bool trainenable = true; + bool localenable = true; + + bool debug = false; + }; + +// methods + uart_input(); + ~uart_input(); + bool + init() { return recall_bindings(); } + bool + recall_bindings(); + void + poll(); + +private: +// types + enum class input_type_t + { + toggle, // two commands, each mapped to one state; press event on state change + impulse, // one command; press event when set, release when cleared + value // one command; press event, value of specified byte passed as param1 + }; + + using input_pin_t = std::tuple; + using inputpin_sequence = std::vector; + +// members + sp_port *port = nullptr; + inputpin_sequence m_inputbindings; + command_relay relay; + std::array old_packet; // TBD, TODO: replace with vector of configurable size? + std::chrono::time_point last_update; + conf_t conf; + bool data_pending = false; +}; diff --git a/uilayer.cpp b/uilayer.cpp new file mode 100644 index 00000000..f0d998f9 --- /dev/null +++ b/uilayer.cpp @@ -0,0 +1,399 @@ +/* +This Source Code Form is subject to the +terms of the Mozilla Public License, v. +2.0. If a copy of the MPL was not +distributed with this file, You can +obtain one at +http://mozilla.org/MPL/2.0/. +*/ + +#include "stdafx.h" +#include "uilayer.h" + +#include "globals.h" +#include "renderer.h" + +#include "imgui_impl_glfw.h" +#ifdef EU07_USEIMGUIIMPLOPENGL2 +#include "imgui_impl_opengl2.h" +#else +#include "imgui_impl_opengl3.h" +#endif + +extern "C" +{ + GLFWAPI HWND glfwGetWin32Window( GLFWwindow* window ); //m7todo: potrzebne do directsound +} + +GLFWwindow * ui_layer::m_window { nullptr }; +ImGuiIO *ui_layer::m_imguiio { nullptr }; +GLint ui_layer::m_textureunit { GL_TEXTURE0 }; +bool ui_layer::m_cursorvisible { true }; + + +ui_panel::ui_panel( std::string const &Identifier, bool const Isopen ) + : name( Identifier ), is_open( Isopen ) +{} + +void +ui_panel::render() { + + if( false == is_open ) { return; } + if( true == text_lines.empty() ) { return; } + + auto flags = + ImGuiWindowFlags_NoFocusOnAppearing + | ImGuiWindowFlags_NoCollapse + | ( size.x > 0 ? ImGuiWindowFlags_NoResize : 0 ); + + if( size.x > 0 ) { + ImGui::SetNextWindowSize( ImVec2( size.x, size.y ) ); + } + if( size_min.x > 0 ) { + ImGui::SetNextWindowSizeConstraints( ImVec2( size_min.x, size_min.y ), ImVec2( size_max.x, size_max.y ) ); + } + auto const panelname { ( + title.empty() ? + name : + title ) + + "###" + name }; + if( true == ImGui::Begin( panelname.c_str(), &is_open, flags ) ) { + for( auto const &line : text_lines ) { + ImGui::TextColored( ImVec4( line.color.r, line.color.g, line.color.b, line.color.a ), line.data.c_str() ); + } + } + ImGui::End(); +} + +ui_layer::~ui_layer() {} + +bool +ui_layer::init( GLFWwindow *Window ) { + + m_window = Window; + + IMGUI_CHECKVERSION(); + ImGui::CreateContext(); + m_imguiio = &ImGui::GetIO(); +// m_imguiio->Fonts->AddFontFromFileTTF( "c:/windows/fonts/lucon.ttf", 13.0f ); + + ImGui_ImplGlfw_InitForOpenGL( m_window, false ); +#ifdef EU07_USEIMGUIIMPLOPENGL2 + ImGui_ImplOpenGL2_Init(); +#else +// ImGui_ImplOpenGL3_Init( "#version 140" ); + ImGui_ImplOpenGL3_Init(); +#endif + + init_colors(); + + return true; +} + +void +ui_layer::init_colors() { + + // configure ui colours + auto *style = &ImGui::GetStyle(); + auto *colors = style->Colors; + auto const background { ImVec4( 38.0f / 255.0f, 38.0f / 255.0f, 38.0f / 255.0f, Global.UIBgOpacity ) }; + auto const accent { ImVec4( 44.0f / 255.0f, 88.0f / 255.0f, 72.0f / 255.0f, 0.75f ) }; + auto const itembase { ImVec4( accent.x, accent.y, accent.z, 0.35f ) }; + auto const itemhover { ImVec4( accent.x, accent.y, accent.z, 0.65f ) }; + auto const itemactive { ImVec4( accent.x, accent.y, accent.z, 0.95f ) }; + auto const modalbackground { ImVec4( accent.x, accent.y, accent.z, 0.95f ) }; + + colors[ ImGuiCol_WindowBg ] = background; + colors[ ImGuiCol_PopupBg ] = background; + colors[ ImGuiCol_FrameBg ] = itembase; + colors[ ImGuiCol_FrameBgHovered ] = itemhover; + colors[ ImGuiCol_FrameBgActive ] = itemactive; + colors[ ImGuiCol_TitleBg ] = background; + colors[ ImGuiCol_TitleBgActive ] = background; + colors[ ImGuiCol_TitleBgCollapsed ] = background; + colors[ ImGuiCol_CheckMark ] = colors[ ImGuiCol_Text ]; + colors[ ImGuiCol_Button ] = itembase; + colors[ ImGuiCol_ButtonHovered ] = itemhover; + colors[ ImGuiCol_ButtonActive ] = itemactive; + colors[ ImGuiCol_Header ] = itembase; + colors[ ImGuiCol_HeaderHovered ] = itemhover; + colors[ ImGuiCol_HeaderActive ] = itemactive; + colors[ ImGuiCol_ResizeGrip ] = itembase; + colors[ ImGuiCol_ResizeGripHovered ] = itemhover; + colors[ ImGuiCol_ResizeGripActive ] = itemactive; + colors[ ImGuiCol_ModalWindowDimBg ] = modalbackground; +} + +void +ui_layer::shutdown() { + +#ifdef EU07_USEIMGUIIMPLOPENGL2 + ImGui_ImplOpenGL2_Shutdown(); +#else + ImGui_ImplOpenGL3_Shutdown(); +#endif + ImGui_ImplGlfw_Shutdown(); + ImGui::DestroyContext(); +} + +bool +ui_layer::on_key( int const Key, int const Action ) { + + return false; +} + +bool +ui_layer::on_cursor_pos( double const Horizontal, double const Vertical ) { + + return false; +} + +bool +ui_layer::on_mouse_button( int const Button, int const Action ) { + + return false; +} + +void +ui_layer::update() { + + for( auto *panel : m_panels ) { + panel->update(); + } +} + +void +ui_layer::render() { + + // legacy ui code + glMatrixMode(GL_PROJECTION); + glLoadIdentity(); + glOrtho( 0, std::max( 1, Global.iWindowWidth ), std::max( 1, Global.iWindowHeight ), 0, -1, 1 ); + + glMatrixMode(GL_MODELVIEW); + glLoadIdentity(); + + glPushAttrib( GL_ENABLE_BIT | GL_COLOR_BUFFER_BIT ); // blendfunc included since 3rd party gui doesn't play nice + glDisable( GL_LIGHTING ); + glDisable( GL_DEPTH_TEST ); + glDisable( GL_ALPHA_TEST ); + glEnable( GL_TEXTURE_2D ); + glEnable( GL_BLEND ); + + ::glColor4fv( glm::value_ptr( colors::white ) ); + + // render code here + render_background(); + render_texture(); + + glDisable( GL_TEXTURE_2D ); + glDisable( GL_TEXTURE_CUBE_MAP ); + + render_progress(); + + glDisable( GL_BLEND ); + + glPopAttrib(); + + // imgui ui code + ::glPushClientAttrib( GL_CLIENT_VERTEX_ARRAY_BIT ); + + ::glClientActiveTexture( m_textureunit ); + ::glBindBuffer( GL_ARRAY_BUFFER, 0 ); + +#ifdef EU07_USEIMGUIIMPLOPENGL2 + ImGui_ImplOpenGL2_NewFrame(); +#else + ImGui_ImplOpenGL3_NewFrame(); +#endif + ImGui_ImplGlfw_NewFrame(); + ImGui::NewFrame(); + + render_panels(); + render_tooltip(); + // template method implementation + render_(); + + ImGui::Render(); +#ifdef EU07_USEIMGUIIMPLOPENGL2 + ImGui_ImplOpenGL2_RenderDrawData( ImGui::GetDrawData() ); +#else + ImGui_ImplOpenGL3_RenderDrawData( ImGui::GetDrawData() ); +#endif + + ::glPopClientAttrib(); +} + +void +ui_layer::set_cursor( int const Mode ) { + + glfwSetInputMode( m_window, GLFW_CURSOR, Mode ); + m_cursorvisible = ( Mode != GLFW_CURSOR_DISABLED ); +} + +void +ui_layer::set_progress( float const Progress, float const Subtaskprogress ) { + + m_progress = Progress * 0.01f; + m_subtaskprogress = Subtaskprogress * 0.01f; +} + +void +ui_layer::set_background( std::string const &Filename ) { + + if( false == Filename.empty() ) { + m_background = GfxRenderer.Fetch_Texture( Filename ); + } + else { + m_background = null_handle; + } + + if( m_background != null_handle ) { + auto const &texture = GfxRenderer.Texture( m_background ); + m_progressbottom = ( texture.width() != texture.height() ); + } + else { + m_progressbottom = true; + } +} + +void +ui_layer::render_progress() { + + if( (m_progress == 0.0f) && (m_subtaskprogress == 0.0f) ) return; + + glm::vec2 origin, size; + if( m_progressbottom == true ) { + origin = glm::vec2{ 0.0f, 768.0f - 20.0f }; + size = glm::vec2{ 1024.0f, 20.0f }; + } + else { + origin = glm::vec2{ 75.0f, 640.0f }; + size = glm::vec2{ 320.0f, 16.0f }; + } + + quad( glm::vec4( origin.x, origin.y, origin.x + size.x, origin.y + size.y ), glm::vec4(0.0f, 0.0f, 0.0f, 0.25f) ); + // secondary bar + if( m_subtaskprogress ) { + quad( + glm::vec4( origin.x, origin.y, origin.x + size.x * m_subtaskprogress, origin.y + size.y), + glm::vec4( 8.0f/255.0f, 160.0f/255.0f, 8.0f/255.0f, 0.35f ) ); + } + // primary bar + if( m_progress ) { + quad( + glm::vec4( origin.x, origin.y, origin.x + size.x * m_progress, origin.y + size.y ), + glm::vec4( 8.0f / 255.0f, 160.0f / 255.0f, 8.0f / 255.0f, 1.0f ) ); + } + + if( false == m_progresstext.empty() ) { + float const screenratio = static_cast( Global.iWindowWidth ) / Global.iWindowHeight; + float const width = + ( screenratio >= (4.0f/3.0f) ? + ( 4.0f / 3.0f ) * Global.iWindowHeight : + Global.iWindowWidth ); + float const heightratio = + ( screenratio >= ( 4.0f / 3.0f ) ? + Global.iWindowHeight / 768.f : + Global.iWindowHeight / 768.f * screenratio / ( 4.0f / 3.0f ) ); + float const height = 768.0f * heightratio; + + ::glColor4f( 216.0f / 255.0f, 216.0f / 255.0f, 216.0f / 255.0f, 1.0f ); + auto const charsize = 9.0f; + auto const textwidth = m_progresstext.size() * charsize; + auto const textheight = 12.0f; + ::glRasterPos2f( + ( 0.5f * ( Global.iWindowWidth - width ) + origin.x * heightratio ) + ( ( size.x * heightratio - textwidth ) * 0.5f * heightratio ), + ( 0.5f * ( Global.iWindowHeight - height ) + origin.y * heightratio ) + ( charsize ) + ( ( size.y * heightratio - textheight ) * 0.5f * heightratio ) ); + } +} + +void +ui_layer::render_panels() { + + for( auto *panel : m_panels ) { + panel->render(); + } +} + +void +ui_layer::render_tooltip() { + + if( m_tooltip.empty() ) { return; } + if( false == m_cursorvisible ) { return; } + + ImGui::SetTooltip( m_tooltip.c_str() ); +} + +void +ui_layer::render_background() { + + if( m_background == 0 ) return; + // NOTE: we limit/expect the background to come with 4:3 ratio. + // TODO, TBD: if we expose texture width or ratio from texture object, this limitation could be lifted + GfxRenderer.Bind_Texture( m_background ); + auto const height { 768.0f }; + auto const &texture = GfxRenderer.Texture( m_background ); + float const width = ( + texture.width() == texture.height() ? + 1024.0f : // legacy mode, square texture displayed as 4:3 image + texture.width() / ( texture.height() / 768.0f ) ); + quad( + glm::vec4( + ( 1024.0f * 0.5f ) - ( width * 0.5f ), + ( 768.0f * 0.5f ) - ( height * 0.5f ), + ( 1024.0f * 0.5f ) - ( width * 0.5f ) + width, + ( 768.0f * 0.5f ) - ( height * 0.5f ) + height ), + colors::white ); +} + +void +ui_layer::render_texture() { + + if( m_texture != 0 ) { + ::glColor4fv( glm::value_ptr( colors::white ) ); + + GfxRenderer.Bind_Texture( null_handle ); + ::glBindTexture( GL_TEXTURE_2D, m_texture ); + + auto const size = 512.f; + auto const offset = 64.f; + + glBegin( GL_TRIANGLE_STRIP ); + + glMultiTexCoord2f( m_textureunit, 0.f, 1.f ); glVertex2f( offset, Global.iWindowHeight - offset - size ); + glMultiTexCoord2f( m_textureunit, 0.f, 0.f ); glVertex2f( offset, Global.iWindowHeight - offset ); + glMultiTexCoord2f( m_textureunit, 1.f, 1.f ); glVertex2f( offset + size, Global.iWindowHeight - offset - size ); + glMultiTexCoord2f( m_textureunit, 1.f, 0.f ); glVertex2f( offset + size, Global.iWindowHeight - offset ); + + glEnd(); + + ::glBindTexture( GL_TEXTURE_2D, 0 ); + } +} + +void +ui_layer::quad( glm::vec4 const &Coordinates, glm::vec4 const &Color ) { + + float const screenratio = static_cast( Global.iWindowWidth ) / Global.iWindowHeight; + float const width = + ( screenratio >= ( 4.f / 3.f ) ? + ( 4.f / 3.f ) * Global.iWindowHeight : + Global.iWindowWidth ); + float const heightratio = + ( screenratio >= ( 4.f / 3.f ) ? + Global.iWindowHeight / 768.f : + Global.iWindowHeight / 768.f * screenratio / ( 4.f / 3.f ) ); + float const height = 768.f * heightratio; + + glColor4fv(glm::value_ptr(Color)); + + glBegin( GL_TRIANGLE_STRIP ); + + glMultiTexCoord2f( m_textureunit, 0.f, 1.f ); glVertex2f( 0.5f * ( Global.iWindowWidth - width ) + Coordinates.x * heightratio, 0.5f * ( Global.iWindowHeight - height ) + Coordinates.y * heightratio ); + glMultiTexCoord2f( m_textureunit, 0.f, 0.f ); glVertex2f( 0.5f * ( Global.iWindowWidth - width ) + Coordinates.x * heightratio, 0.5f * ( Global.iWindowHeight - height ) + Coordinates.w * heightratio ); + glMultiTexCoord2f( m_textureunit, 1.f, 1.f ); glVertex2f( 0.5f * ( Global.iWindowWidth - width ) + Coordinates.z * heightratio, 0.5f * ( Global.iWindowHeight - height ) + Coordinates.y * heightratio ); + glMultiTexCoord2f( m_textureunit, 1.f, 0.f ); glVertex2f( 0.5f * ( Global.iWindowWidth - width ) + Coordinates.z * heightratio, 0.5f * ( Global.iWindowHeight - height ) + Coordinates.w * heightratio ); + + glEnd(); +} diff --git a/uilayer.h b/uilayer.h new file mode 100644 index 00000000..156d8b8d --- /dev/null +++ b/uilayer.h @@ -0,0 +1,151 @@ +/* +This Source Code Form is subject to the +terms of the Mozilla Public License, v. +2.0. If a copy of the MPL was not +distributed with this file, You can +obtain one at +http://mozilla.org/MPL/2.0/. +*/ + +#pragma once + +#include +#include "texture.h" + +// GuiLayer -- basic user interface class. draws requested information on top of openGL screen + +class ui_panel { + +public: +// constructor + ui_panel( std::string const &Identifier, bool const Isopen ); +// methods + virtual void update() {}; + virtual void render(); + // temporary access +// types + struct text_line { + + std::string data; + glm::vec4 color; + + text_line( std::string const &Data, glm::vec4 const &Color) + : data(Data), color(Color) + {} + }; +// members + std::string title; + bool is_open; + glm::ivec2 size { -1, -1 }; + glm::ivec2 size_min { -1, -1 }; + glm::ivec2 size_max { -1, -1 }; + std::vector text_lines; + +protected: +// members + std::string name; +}; + +class ui_layer { + +public: +// constructors + ui_layer() = default; +// destructor + virtual ~ui_layer(); + +// methods + static + bool + init( GLFWwindow *Window ); + // assign texturing hardware unit + static + void + set_unit( GLint const Textureunit ) { m_textureunit = Textureunit; } + static + void + shutdown(); + // potentially processes provided input key. returns: true if the input was processed, false otherwise + virtual + bool + on_key( int const Key, int const Action ); + // potentially processes provided mouse movement. returns: true if the input was processed, false otherwise + virtual + bool + on_cursor_pos( double const Horizontal, double const Vertical ); + // potentially processes provided mouse button. returns: true if the input was processed, false otherwise + virtual + bool + on_mouse_button( int const Button, int const Action ); + // updates state of UI elements + virtual + void + update(); + // draws requested UI elements + void + render(); + // + static + void + set_cursor( int const Mode ); + // stores operation progress + void + set_progress( float const Progress = 0.0f, float const Subtaskprogress = 0.0f ); + void + set_progress( std::string const &Text ) { m_progresstext = Text; } + // sets the ui background texture, if any + void + set_background( std::string const &Filename = "" ); + void + set_texture( GLuint Texture = 0 ) { m_texture = Texture; } + void + set_tooltip( std::string const &Tooltip ) { m_tooltip = Tooltip; } + void + clear_panels() { m_panels.clear(); } + void + push_back( ui_panel *Panel ) { m_panels.emplace_back( Panel ); } + +protected: +// members + static GLFWwindow *m_window; + static ImGuiIO *m_imguiio; + static bool m_cursorvisible; + +private: +// methods + static + void + init_colors(); + // render() subclass details + virtual + void + render_() {}; + // draws background quad with specified earlier texture + void + render_background(); + void + render_texture(); + // draws a progress bar in defined earlier state + void + render_progress(); + void + render_panels(); + void + render_tooltip(); + // draws a quad between coordinates x,y and z,w with uv-coordinates spanning 0-1 + void + quad( glm::vec4 const &Coordinates, glm::vec4 const &Color ); +// members + static GLint m_textureunit; + + // progress bar config. TODO: put these together into an object + float m_progress { 0.0f }; // percentage of filled progres bar, to indicate lengthy operations. + float m_subtaskprogress{ 0.0f }; // percentage of filled progres bar, to indicate lengthy operations. + std::string m_progresstext; // label placed over the progress bar + bool m_progressbottom { true }; // location of the progress bar + + texture_handle m_background { null_handle }; // path to texture used as the background. size depends on mAspect. + GLuint m_texture { 0 }; + std::vector m_panels; + std::string m_tooltip; +}; diff --git a/uitranscripts.cpp b/uitranscripts.cpp new file mode 100644 index 00000000..73797b2b --- /dev/null +++ b/uitranscripts.cpp @@ -0,0 +1,79 @@ + + +#include "stdafx.h" +#include "uitranscripts.h" + +#include "globals.h" +#include "parser.h" +#include "utilities.h" + +namespace ui { + +TTranscripts Transcripts; + +// dodanie linii do tabeli, (show) i (hide) w [s] od aktualnego czasu +void +TTranscripts::AddLine( std::string const &txt, float show, float hide, bool it ) { + + if( show == hide ) { return; } // komentarz jest ignorowany + + show = Global.fTimeAngleDeg + show / 240.0; // jeśli doba to 360, to 1s będzie równe 1/240 + hide = Global.fTimeAngleDeg + hide / 240.0; + + TTranscript transcript; + transcript.asText = txt; + transcript.fShow = show; + transcript.fHide = hide; + transcript.bItalic = it; + aLines.emplace_back( transcript ); + // set the next refresh time while at it + // TODO, TBD: sort the transcript lines? in theory, they should be coming arranged in the right order anyway + // short of cases with multiple sounds overleaping + fRefreshTime = aLines.front().fHide; +} + +// dodanie tekstów, długość dźwięku, czy istotne +void +TTranscripts::Add( std::string const &txt, bool backgorund ) { + + if( true == txt.empty() ) { return; } + + std::string asciitext{ txt }; win1250_to_ascii( asciitext ); // TODO: launch relevant conversion table based on language + cParser parser( asciitext ); + while( true == parser.getTokens( 3, false, "[]\n" ) ) { + + float begin, end; + std::string transcript; + parser + >> begin + >> end + >> transcript; + AddLine( transcript, 0.10 * begin, 0.12 * end, false ); + } + // try to handle malformed(?) cases with no show/hide times + std::string transcript; parser >> transcript; + while( false == transcript.empty() ) { + + // WriteLog( "Transcript text with no display/hide times: \"" + transcript + "\"" ); + AddLine( transcript, 0.0, 0.12 * transcript.size(), false ); + transcript = ""; parser >> transcript; + } +} + +// usuwanie niepotrzebnych (nie częściej niż 10 razy na sekundę) +void +TTranscripts::Update() { + + if( Global.fTimeAngleDeg < fRefreshTime ) { return; } // nie czas jeszcze na zmiany + + while( ( false == aLines.empty() ) + && ( Global.fTimeAngleDeg >= aLines.front().fHide ) ) { + // remove expired lines + aLines.pop_front(); + } + // update next refresh time + if( false == aLines.empty() ) { fRefreshTime = aLines.front().fHide; } + else { fRefreshTime = 360.0f; } +} + +} // namespace ui diff --git a/uitranscripts.h b/uitranscripts.h new file mode 100644 index 00000000..7db201a1 --- /dev/null +++ b/uitranscripts.h @@ -0,0 +1,41 @@ + +#pragma once + +#include +#include + +namespace ui { + +// klasa obsługująca linijkę napisu do dźwięku +struct TTranscript { + + float fShow; // czas pokazania + float fHide; // czas ukrycia/usunięcia + std::string asText; // tekst gotowy do wyświetlenia (usunięte znaczniki czasu) + bool bItalic; // czy kursywa (dźwięk nieistotny dla prowadzącego) +}; + +// klasa obsługująca napisy do dźwięków +class TTranscripts { + +public: +// constructors + TTranscripts() = default; +// methods + void AddLine( std::string const &txt, float show, float hide, bool it ); + // dodanie tekstów, długość dźwięku, czy istotne + void Add( std::string const &txt, bool background = false ); + // usuwanie niepotrzebnych (ok. 10 razy na sekundę) + void Update(); +// members + std::deque aLines; + +private: +// members + float fRefreshTime { 360 }; // wartośc zaporowa + +}; + +extern TTranscripts Transcripts; + +} // namespace ui \ No newline at end of file diff --git a/usefull.h b/usefull.h deleted file mode 100644 index aabeba22..00000000 --- a/usefull.h +++ /dev/null @@ -1,61 +0,0 @@ -/* -This Source Code Form is subject to the -terms of the Mozilla Public License, v. -2.0. If a copy of the MPL was not -distributed with this file, You can -obtain one at -http://mozilla.org/MPL/2.0/. -*/ - -#pragma once - -//#define B1(t) (t*t*t) -//#define B2(t) (3*t*t*(1-t)) -//#define B3(t) (3*t*(1-t)*(1-t)) -//#define B4(t) ((1-t)*(1-t)*(1-t)) -// Ra: to jest mocno nieoptymalne: 10+3*4=22 mnożenia, 6 odejmowań, 3*3=9 dodawań -// Ra: po przeliczeniu współczynników mamy: 3*3=9 mnożeń i 3*3=9 dodawań -//#define Interpolate(t,p1,cp1,cp2,p2) (B4(t)*p1+B3(t)*cp1+B2(t)*cp2+B1(t)*p2) - -// Ra: "delete NULL" nic nie zrobi, więc "if (a!=NULL)" jest zbędne -//#define SafeFree(a) if (a!=NULL) free(a) -//#define M_PI = 3.141592653589793 - -#define SafeDelete(a) \ - { \ - delete (a); \ - a = nullptr; \ - } -#define SafeDeleteArray(a) \ - { \ - delete[](a); \ - a = nullptr; \ - } - -#define sign(x) ((x) < 0 ? -1 : ((x) > 0 ? 1 : 0)) - -#define DegToRad(a) ((M_PI / 180.0) * (a)) //(a) w nawiasie, bo może być dodawaniem -#define RadToDeg(r) ((180.0 / M_PI) * (r)) - -#define Fix(a, b, c) \ - { \ - if (a < b) \ - a = b; \ - if (a > c) \ - a = c; \ - } - -#define asModelsPath std::string("models\\") -#define asSceneryPath std::string("scenery\\") -//#define asTexturePath AnsiString("textures\\") -//#define asTextureExt AnsiString(".bmp") -#define szSceneryPath "scenery\\" -#define szTexturePath "textures\\" -//#define szDefaultTextureExt ".dds" - -//#define DevelopTime //FIXME -//#define EditorMode - -#define MAKE_ID4(a,b,c,d) (((std::uint32_t)(d)<<24)|((std::uint32_t)(c)<<16)|((std::uint32_t)(b)<<8)|(std::uint32_t)(a)) - -//--------------------------------------------------------------------------- diff --git a/utilities.cpp b/utilities.cpp new file mode 100644 index 00000000..ea27dd69 --- /dev/null +++ b/utilities.cpp @@ -0,0 +1,444 @@ +/* +This Source Code Form is subject to the +terms of the Mozilla Public License, v. +2.0. If a copy of the MPL was not +distributed with this file, You can +obtain one at +http://mozilla.org/MPL/2.0/. +*/ +/* +MaSzyna EU07 - SPKS +Brakes. +Copyright (C) 2007-2014 Maciej Cierniak +*/ +#include "stdafx.h" + +#include +#include +#ifndef WIN32 +#include +#endif + +#ifdef WIN32 +#define stat _stat +#endif + +#include "utilities.h" +#include "globals.h" +#include "parser.h" + +bool DebugModeFlag = false; +bool FreeFlyModeFlag = false; +bool EditorModeFlag = false; +bool DebugCameraFlag = false; + +double Max0R(double x1, double x2) +{ + if (x1 > x2) + return x1; + else + return x2; +} + +double Min0R(double x1, double x2) +{ + if (x1 < x2) + return x1; + else + return x2; +} + +// shitty replacement for Borland timestamp function +// TODO: replace with something sensible +std::string Now() { + + std::time_t timenow = std::time( nullptr ); + std::tm tm = *std::localtime( &timenow ); + std::stringstream converter; + converter << std::put_time( &tm, "%c" ); + return converter.str(); +} + +// zwraca różnicę czasu +// jeśli pierwsza jest aktualna, a druga rozkładowa, to ujemna oznacza opóżnienie +// na dłuższą metę trzeba uwzględnić datę, jakby opóżnienia miały przekraczać 12h (towarowych) +double CompareTime(double t1h, double t1m, double t2h, double t2m) { + + if ((t2h < 0)) + return 0; + else + { + auto t = (t2h - t1h) * 60 + t2m - t1m; // jeśli t2=00:05, a t1=23:50, to różnica wyjdzie ujemna + if ((t < -720)) // jeśli różnica przekracza 12h na minus + t = t + 1440; // to dodanie doby minut;else + if ((t > 720)) // jeśli przekracza 12h na plus + t = t - 1440; // to odjęcie doby minut + return t; + } +} + +bool SetFlag( int &Flag, int const Value ) { + + if( Value > 0 ) { + if( false == TestFlag( Flag, Value ) ) { + Flag |= Value; + return true; // true, gdy było wcześniej 0 i zostało ustawione + } + } + else if( Value < 0 ) { + // Value jest ujemne, czyli zerowanie flagi + return ClearFlag( Flag, -Value ); + } + return false; +} + +bool ClearFlag( int &Flag, int const Value ) { + + if( true == TestFlag( Flag, Value ) ) { + Flag &= ~Value; + return true; + } + else { + return false; + } +} + +double Random(double a, double b) +{ + std::uniform_real_distribution<> dis(a, b); + return dis(Global.random_engine); +} + +bool FuzzyLogic(double Test, double Threshold, double Probability) +{ + if ((Test > Threshold) && (!DebugModeFlag)) + return + (Random() < Probability * Threshold * 1.0 / Test) /*im wiekszy Test tym wieksza szansa*/; + else + return false; +} + +bool FuzzyLogicAI(double Test, double Threshold, double Probability) +{ + if ((Test > Threshold)) + return + (Random() < Probability * Threshold * 1.0 / Test) /*im wiekszy Test tym wieksza szansa*/; + else + return false; +} + +std::string DUE(std::string s) /*Delete Before Equal sign*/ +{ + //DUE = Copy(s, Pos("=", s) + 1, length(s)); + return s.substr(s.find("=") + 1, s.length()); +} + +std::string DWE(std::string s) /*Delete After Equal sign*/ +{ + size_t ep = s.find("="); + if (ep != std::string::npos) + //DWE = Copy(s, 1, ep - 1); + return s.substr(0, ep); + else + return s; +} + +std::string ExchangeCharInString( std::string const &Source, char const From, char const To ) +{ + std::string replacement; replacement.reserve( Source.size() ); + std::for_each( + std::begin( Source ), std::end( Source ), + [&](char const idx) { + if( idx != From ) { replacement += idx; } + else { replacement += To; } } ); + + return replacement; +} + +std::vector &Split(const std::string &s, char delim, std::vector &elems) +{ // dzieli tekst na wektor tekstow + + std::stringstream ss(s); + std::string item; + while (std::getline(ss, item, delim)) + { + elems.push_back(item); + } + return elems; +} + +std::vector Split(const std::string &s, char delim) +{ // dzieli tekst na wektor tekstow + std::vector elems; + Split(s, delim, elems); + return elems; +} + +std::vector Split(const std::string &s) +{ // dzieli tekst na wektor tekstow po białych znakach + std::vector elems; + std::stringstream ss(s); + std::string item; + while (ss >> item) + { + elems.push_back(item); + } + return elems; +} + +std::string to_string(int Value) +{ + std::ostringstream o; + o << Value; + return o.str(); +}; + +std::string to_string(unsigned int Value) +{ + std::ostringstream o; + o << Value; + return o.str(); +}; + +std::string to_string(double Value) +{ + std::ostringstream o; + o << Value; + return o.str(); +}; + +std::string to_string(int Value, int precision) +{ + std::ostringstream o; + o << std::fixed << std::setprecision(precision); + o << Value; + return o.str(); +}; + +std::string to_string(double Value, int precision) +{ + std::ostringstream o; + o << std::fixed << std::setprecision(precision); + o << Value; + return o.str(); +}; + +std::string to_string(int Value, int precision, int width) +{ + std::ostringstream o; + o.width(width); + o << std::fixed << std::setprecision(precision); + o << Value; + return o.str(); +}; + +std::string to_string(double const Value, int const Precision, int const Width) +{ + std::ostringstream converter; + converter << std::setw( Width ) << std::fixed << std::setprecision(Precision) << Value; + return converter.str(); +}; + +std::string to_hex_str( int const Value, int const Width ) +{ + std::ostringstream converter; + converter << "0x" << std::uppercase << std::setfill( '0' ) << std::setw( Width ) << std::hex << Value; + return converter.str(); +}; + +int stol_def(const std::string &str, const int &DefaultValue) { + + int result { DefaultValue }; + std::stringstream converter; + converter << str; + converter >> result; + return result; +} + +std::string ToLower(std::string const &text) { + + auto lowercase { text }; + std::transform( + std::begin( text ), std::end( text ), + std::begin( lowercase ), + []( unsigned char c ) { return std::tolower( c ); } ); + return lowercase; +} + +std::string ToUpper(std::string const &text) { + + auto uppercase { text }; + std::transform( + std::begin( text ), std::end( text ), + std::begin( uppercase ), + []( unsigned char c ) { return std::toupper( c ); } ); + return uppercase; +} + +// replaces polish letters with basic ascii +void +win1250_to_ascii( std::string &Input ) { + + std::unordered_map const charmap { + { 165, 'A' }, { 198, 'C' }, { 202, 'E' }, { 163, 'L' }, { 209, 'N' }, { 211, 'O' }, { 140, 'S' }, { 143, 'Z' }, { 175, 'Z' }, + { 185, 'a' }, { 230, 'c' }, { 234, 'e' }, { 179, 'l' }, { 241, 'n' }, { 243, 'o' }, { 156, 's' }, { 159, 'z' }, { 191, 'z' } + }; + std::unordered_map::const_iterator lookup; + for( auto &input : Input ) { + if( ( lookup = charmap.find( input ) ) != charmap.end() ) + input = lookup->second; + } +} + +// Ra: tymczasowe rozwiązanie kwestii zagranicznych (czeskich) napisów +char charsetconversiontable[] = + "E?,?\"_++?%Sstzz" + " ^^L$A|S^CS<--RZo±,l'uP.,as>L\"lz" + "RAAAALCCCEEEEIIDDNNOOOOxRUUUUYTB" + "raaaalccceeeeiiddnnoooo-ruuuuyt?"; + +// wycięcie liter z ogonkami +std::string Bezogonkow(std::string Input, bool const Underscorestospaces) { + + char const extendedcharsetbit { static_cast( 0x80 ) }; + char const space { ' ' }; + char const underscore { '_' }; + + for( auto &input : Input ) { + if( input & extendedcharsetbit ) { + input = charsetconversiontable[ input ^ extendedcharsetbit ]; + } + else if( input < space ) { + input = space; + } + else if( Underscorestospaces && ( input == underscore ) ) { + input = space; + } + } + + return Input; +} + +template <> +bool +extract_value( bool &Variable, std::string const &Key, std::string const &Input, std::string const &Default ) { + + auto value = extract_value( Key, Input ); + if( false == value.empty() ) { + // set the specified variable to retrieved value + Variable = ( ToLower( value ) == "yes" ); + return true; // located the variable + } + else { + // set the variable to provided default value + if( false == Default.empty() ) { + Variable = ( ToLower( Default ) == "yes" ); + } + return false; // couldn't locate the variable in provided input + } +} + +bool +FileExists( std::string const &Filename ) { + + std::ifstream file( Filename ); + return( true == file.is_open() ); +} + +std::pair +FileExists( std::vector const &Names, std::vector const &Extensions ) { + + for( auto const &name : Names ) { + for( auto const &extension : Extensions ) { + if( FileExists( name + extension ) ) { + return { name, extension }; + } + } + } + // nothing found + return { {}, {} }; +} + +// returns time of last modification for specified file +std::time_t +last_modified( std::string const &Filename ) { + + struct stat filestat; + if( ::stat( Filename.c_str(), &filestat ) == 0 ) { return filestat.st_mtime; } + else { return 0; } +} + +// potentially erases file extension from provided file name. returns: true if extension was removed, false otherwise +bool +erase_extension( std::string &Filename ) { + + auto const extensionpos { Filename.rfind( '.' ) }; + + if( extensionpos == std::string::npos ) { return false; } + + if( extensionpos != Filename.rfind( ".." ) + 1 ) { + // we can get extension for .mat or, in legacy files, some image format. just trim it and set it to material file extension + Filename.erase( extensionpos ); + return true; + } + return false; +} + +// potentially replaces backward slashes in provided file path with unix-compatible forward slashes +void +replace_slashes( std::string &Filename ) { + + std::replace( + std::begin( Filename ), std::end( Filename ), + '\\', '/' ); +} + +// returns potential path part from provided file name +std::string +substr_path( std::string const &Filename ) { + + return ( + Filename.rfind( '/' ) != std::string::npos ? + Filename.substr( 0, Filename.rfind( '/' ) + 1 ) : + "" ); +} + +// helper, restores content of a 3d vector from provided input stream +// TODO: review and clean up the helper routines, there's likely some redundant ones +glm::dvec3 LoadPoint( cParser &Input ) { + // pobranie współrzędnych punktu + Input.getTokens( 3 ); + glm::dvec3 point; + Input + >> point.x + >> point.y + >> point.z; + + return point; +} + +// extracts a group of tokens from provided data stream, returns one of them picked randomly +std::string +deserialize_random_set( cParser &Input, char const *Break ) { + + auto token { Input.getToken( true, Break ) }; + if( token != "[" ) { + // simple case, single token + return token; + } + // if instead of a single token we've encountered '[' this marks a beginning of a random set + // we retrieve all entries, then return a random one + std::vector tokens; + while( ( ( token = deserialize_random_set( Input, Break ) ) != "" ) + && ( token != "]" ) ) { + tokens.emplace_back( token ); + } + if( false == tokens.empty() ) { + std::shuffle( std::begin( tokens ), std::end( tokens ), Global.random_engine ); + return tokens.front(); + } + else { + // shouldn't ever get here but, eh + return ""; + } +} diff --git a/utilities.h b/utilities.h new file mode 100644 index 00000000..ee086586 --- /dev/null +++ b/utilities.h @@ -0,0 +1,373 @@ +/* +This Source Code Form is subject to the +terms of the Mozilla Public License, v. +2.0. If a copy of the MPL was not +distributed with this file, You can +obtain one at +http://mozilla.org/MPL/2.0/. +*/ + +#pragma once + +#include "stdafx.h" + +#include +#include +#include +#include +#include + +/*rozne takie duperele do operacji na stringach w paszczalu, pewnie w delfi sa lepsze*/ +/*konwersja zmiennych na stringi, funkcje matematyczne, logiczne, lancuchowe, I/O etc*/ + +#define sign(x) ((x) < 0 ? -1 : ((x) > 0 ? 1 : 0)) + +#define DegToRad(a) ((M_PI / 180.0) * (a)) //(a) w nawiasie, bo może być dodawaniem +#define RadToDeg(r) ((180.0 / M_PI) * (r)) + +#define szSceneryPath "scenery/" +#define szTexturePath "textures/" +#define szModelPath "models/" +#define szDynamicPath "dynamic/" +#define szSoundPath "sounds/" + +#define MAKE_ID4(a,b,c,d) (((std::uint32_t)(d)<<24)|((std::uint32_t)(c)<<16)|((std::uint32_t)(b)<<8)|(std::uint32_t)(a)) + +extern bool DebugModeFlag; +extern bool FreeFlyModeFlag; +extern bool EditorModeFlag; +extern bool DebugCameraFlag; + +/*funkcje matematyczne*/ +double Max0R(double x1, double x2); +double Min0R(double x1, double x2); + +inline double Sign(double x) +{ + return x >= 0 ? 1.0 : -1.0; +} + +inline long Round(double const f) +{ + return (long)(f + 0.5); + //return lround(f); +} + +double Random(double a, double b); + +inline double Random() +{ + return Random(0.0,1.0); +} + +inline double Random(double b) +{ + return Random(0.0, b); +} + +inline double BorlandTime() +{ + auto timesinceepoch = std::time( nullptr ); + return timesinceepoch / (24.0 * 60 * 60); +/* + // std alternative + auto timesinceepoch = std::chrono::system_clock::now().time_since_epoch(); + return std::chrono::duration_cast( timesinceepoch ).count() / (24.0 * 60 * 60); +*/ +} + +std::string Now(); + +double CompareTime( double t1h, double t1m, double t2h, double t2m ); + +/*funkcje logiczne*/ +inline bool TestFlag( int const Flag, int const Value ) { return ( ( Flag & Value ) == Value ); } +bool SetFlag( int &Flag, int const Value); +bool ClearFlag(int &Flag, int const Value); + +bool FuzzyLogic(double Test, double Threshold, double Probability); +/*jesli Test>Threshold to losowanie*/ +bool FuzzyLogicAI(double Test, double Threshold, double Probability); +/*to samo ale zawsze niezaleznie od DebugFlag*/ + +/*operacje na stringach*/ +std::string DUE(std::string s); /*Delete Until Equal sign*/ +std::string DWE(std::string s); /*Delete While Equal sign*/ +std::string ExchangeCharInString( std::string const &Source, char const From, char const To ); // zamienia jeden znak na drugi +std::vector &Split(const std::string &s, char delim, std::vector &elems); +std::vector Split(const std::string &s, char delim); +//std::vector Split(const std::string &s); + +std::string to_string(int Value); +std::string to_string(unsigned int Value); +std::string to_string(int Value, int precision); +std::string to_string(int Value, int precision, int width); +std::string to_string(double Value); +std::string to_string(double Value, int precision); +std::string to_string(double Value, int precision, int width); +std::string to_hex_str( int const Value, int const width = 4 ); + +inline std::string to_string(bool Value) { + + return ( Value == true ? "true" : "false" ); +} + +template +std::string to_string( glm::tvec3 const &Value ) { + return to_string( Value.x, 2 ) + ", " + to_string( Value.y, 2 ) + ", " + to_string( Value.z, 2 ); +} + +template +std::string to_string( glm::tvec4 const &Value, int const Width = 2 ) { + return to_string( Value.x, Width ) + ", " + to_string( Value.y, Width ) + ", " + to_string( Value.z, Width ) + ", " + to_string( Value.w, Width ); +} + +int stol_def(const std::string & str, const int & DefaultValue); + +std::string ToLower(std::string const &text); +std::string ToUpper(std::string const &text); + +// replaces polish letters with basic ascii +void win1250_to_ascii( std::string &Input ); +// TODO: unify with win1250_to_ascii() +std::string Bezogonkow( std::string Input, bool const Underscorestospaces = false ); + +inline +std::string +extract_value( std::string const &Key, std::string const &Input ) { + // NOTE, HACK: the leading space allows to uniformly look for " variable=" substring + std::string const input { " " + Input }; + std::string value; + auto lookup = input.find( " " + Key + "=" ); + if( lookup != std::string::npos ) { + value = input.substr( input.find_first_not_of( ' ', lookup + Key.size() + 2 ) ); + lookup = value.find( ' ' ); + if( lookup != std::string::npos ) { + // trim everything past the value + value.erase( lookup ); + } + } + return value; +} + +template +bool +extract_value( Type_ &Variable, std::string const &Key, std::string const &Input, std::string const &Default ) { + + auto value = extract_value( Key, Input ); + if( false == value.empty() ) { + // set the specified variable to retrieved value + std::stringstream converter; + converter << value; + converter >> Variable; + return true; // located the variable + } + else { + // set the variable to provided default value + if( false == Default.empty() ) { + std::stringstream converter; + converter << Default; + converter >> Variable; + } + return false; // couldn't locate the variable in provided input + } +} + +template <> +bool +extract_value( bool &Variable, std::string const &Key, std::string const &Input, std::string const &Default ); + +bool FileExists( std::string const &Filename ); + +std::pair FileExists( std::vector const &Names, std::vector const &Extensions ); + +// returns time of last modification for specified file +std::time_t last_modified( std::string const &Filename ); + +// potentially erases file extension from provided file name. returns: true if extension was removed, false otherwise +bool +erase_extension( std::string &Filename ); + +// potentially replaces backward slashes in provided file path with unix-compatible forward slashes +void +replace_slashes( std::string &Filename ); + +// returns potential path part from provided file name +std::string substr_path( std::string const &Filename ); + +template +void SafeDelete( Type_ &Pointer ) { + delete Pointer; + Pointer = nullptr; +} + +template +void SafeDeleteArray( Type_ &Pointer ) { + delete[] Pointer; + Pointer = nullptr; +} + +template +Type_ +clamp( Type_ const Value, Type_ const Min, Type_ const Max ) { + + Type_ value = Value; + if( value < Min ) { value = Min; } + if( value > Max ) { value = Max; } + return value; +} + +// keeps the provided value in specified range 0-Range, as if the range was circular buffer +template +Type_ +clamp_circular( Type_ Value, Type_ const Range = static_cast(360) ) { + + Value -= Range * (int)( Value / Range ); // clamp the range to 0-360 + if( Value < Type_(0) ) Value += Range; + + return Value; +} + +template +Type_ +quantize( Type_ const Value, Type_ const Step ) { + + return ( Step * std::round( Value / Step ) ); +} + +template +Type_ +min_speed( Type_ const Left, Type_ const Right ) { + + if( Left == Right ) { return Left; } + + return std::min( + ( Left != -1 ? + Left : + std::numeric_limits::max() ), + ( Right != -1 ? + Right : + std::numeric_limits::max() ) ); +} + +template +Type_ +interpolate( Type_ const &First, Type_ const &Second, float const Factor ) { + + return static_cast( ( First * ( 1.0f - Factor ) ) + ( Second * Factor ) ); +} + +template +Type_ +interpolate( Type_ const &First, Type_ const &Second, double const Factor ) { + + return static_cast( ( First * ( 1.0 - Factor ) ) + ( Second * Factor ) ); +} + +// tests whether provided points form a degenerate triangle +template +bool +degenerate( VecType_ const &Vertex1, VecType_ const &Vertex2, VecType_ const &Vertex3 ) { + + // degenerate( A, B, C, minarea ) = ( ( B - A ).cross( C - A ) ).lengthSquared() < ( 4.0f * minarea * minarea ); + return ( glm::length2( glm::cross( Vertex2 - Vertex1, Vertex3 - Vertex1 ) ) == 0.0 ); +} + +// calculates bounding box for provided set of points +template +void +bounding_box( VecType_ &Mincorner, VecType_ &Maxcorner, Iterator_ First, Iterator_ Last ) { + + Mincorner = VecType_( typename std::numeric_limits::max() ); + Maxcorner = VecType_( typename std::numeric_limits::lowest() ); + + std::for_each( + First, Last, + [&]( typename Iterator_::value_type &point ) { + Mincorner = glm::min( Mincorner, VecType_{ point } ); + Maxcorner = glm::max( Maxcorner, VecType_{ point } ); } ); +} + +// finds point on specified segment closest to specified point in 3d space. returns: point on segment as value in range 0-1 where 0 = start and 1 = end of the segment +template +typename VecType_::value_type +nearest_segment_point( VecType_ const &Segmentstart, VecType_ const &Segmentend, VecType_ const &Point ) { + + auto const v = Segmentend - Segmentstart; + auto const w = Point - Segmentstart; + + auto const c1 = glm::dot( w, v ); + if( c1 <= 0.0 ) { + return 0.0; + } + auto const c2 = glm::dot( v, v ); + if( c2 <= c1 ) { + return 1.0; + } + return c1 / c2; +} + +glm::dvec3 LoadPoint( class cParser &Input ); + +// extracts a group of tokens from provided data stream +std::string +deserialize_random_set( cParser &Input, char const *Break = "\n\r\t ;" ); + +namespace threading { + +// simple POD pairing of a data item and a mutex +// NOTE: doesn't do any locking itself, it's merely for cleaner argument arrangement and passing +template +struct lockable { + + Type_ data; + std::mutex mutex; +}; + +// basic wrapper simplifying use of std::condition_variable for most typical cases. +// has its own mutex and secondary variable to ignore spurious wakeups +class condition_variable { + +public: +// methods + void + wait() { + std::unique_lock lock( m_mutex ); + m_condition.wait( + lock, + [ this ]() { + return m_spurious == false; } ); } + template< class Rep_, class Period_ > + void + wait_for( const std::chrono::duration &Time ) { + std::unique_lock lock( m_mutex ); + m_condition.wait_for( + lock, + Time, + [ this ]() { + return m_spurious == false; } ); } + void + notify_one() { + spurious( false ); + m_condition.notify_one(); + } + void + notify_all() { + spurious( false ); + m_condition.notify_all(); + } + void + spurious( bool const Spurious ) { + std::lock_guard lock( m_mutex ); + m_spurious = Spurious; } + +private: +// members + mutable std::mutex m_mutex; + std::condition_variable m_condition; + bool m_spurious { true }; +}; + +} // threading + +//--------------------------------------------------------------------------- diff --git a/version.h b/version.h new file mode 100644 index 00000000..534a83d6 --- /dev/null +++ b/version.h @@ -0,0 +1,5 @@ +#pragma once + +#define VERSION_MAJOR 18 +#define VERSION_MINOR 1011 +#define VERSION_REVISION 0 diff --git a/vertex.cpp b/vertex.cpp new file mode 100644 index 00000000..e1d60fd2 --- /dev/null +++ b/vertex.cpp @@ -0,0 +1,66 @@ +/* +This Source Code Form is subject to the +terms of the Mozilla Public License, v. +2.0. If a copy of the MPL was not +distributed with this file, You can +obtain one at +http://mozilla.org/MPL/2.0/. +*/ + +#pragma once + +#include "stdafx.h" +#include "vertex.h" +#include "sn_utils.h" + +void +world_vertex::serialize( std::ostream &s ) const { + + sn_utils::ls_float64( s, position.x ); + sn_utils::ls_float64( s, position.y ); + sn_utils::ls_float64( s, position.z ); + + sn_utils::ls_float32( s, normal.x ); + sn_utils::ls_float32( s, normal.y ); + sn_utils::ls_float32( s, normal.z ); + + sn_utils::ls_float32( s, texture.x ); + sn_utils::ls_float32( s, texture.y ); +} + +void +world_vertex::deserialize( std::istream &s ) { + + position.x = sn_utils::ld_float64( s ); + position.y = sn_utils::ld_float64( s ); + position.z = sn_utils::ld_float64( s ); + + normal.x = sn_utils::ld_float32( s ); + normal.y = sn_utils::ld_float32( s ); + normal.z = sn_utils::ld_float32( s ); + + texture.x = sn_utils::ld_float32( s ); + texture.y = sn_utils::ld_float32( s ); +} + +template <> +world_vertex & +world_vertex::operator+=( world_vertex const &Right ) { + + position += Right.position; + normal += Right.normal; + texture += Right.texture; + return *this; +} + +template <> +world_vertex & +world_vertex::operator*=( world_vertex const &Right ) { + + position *= Right.position; + normal *= Right.normal; + texture *= Right.texture; + return *this; +} + +//--------------------------------------------------------------------------- diff --git a/vertex.h b/vertex.h new file mode 100644 index 00000000..8ce99afa --- /dev/null +++ b/vertex.h @@ -0,0 +1,89 @@ +/* +This Source Code Form is subject to the +terms of the Mozilla Public License, v. +2.0. If a copy of the MPL was not +distributed with this file, You can +obtain one at +http://mozilla.org/MPL/2.0/. +*/ + +#pragma once + +#include +#include "utilities.h" + +// geometry vertex with double precision position +struct world_vertex { + +// members + glm::dvec3 position; + glm::vec3 normal; + glm::vec2 texture; + +// overloads + // operator+ + template + world_vertex & + operator+=( Scalar_ const &Right ) { + position += Right; + normal += Right; + texture += Right; + return *this; } + template + friend + world_vertex + operator+( world_vertex Left, Scalar_ const &Right ) { + Left += Right; + return Left; } + // operator* + template + world_vertex & + operator*=( Scalar_ const &Right ) { + position *= Right; + normal *= Right; + texture *= Right; + return *this; } + template + friend + world_vertex + operator*( world_vertex Left, Type_ const &Right ) { + Left *= Right; + return Left; } +// methods + void serialize( std::ostream& ) const; + void deserialize( std::istream& ); + // wyliczenie współrzędnych i mapowania punktu na środku odcinka v1<->v2 + void + set_half( world_vertex const &Vertex1, world_vertex const &Vertex2 ) { + *this = + interpolate( + Vertex1, + Vertex2, + 0.5 ); } + // wyliczenie współrzędnych i mapowania punktu na odcinku v1<->v2 + void + set_from_x( world_vertex const &Vertex1, world_vertex const &Vertex2, double const X ) { + *this = + interpolate( + Vertex1, + Vertex2, + ( X - Vertex1.position.x ) / ( Vertex2.position.x - Vertex1.position.x ) ); } + // wyliczenie współrzędnych i mapowania punktu na odcinku v1<->v2 + void + set_from_z( world_vertex const &Vertex1, world_vertex const &Vertex2, double const Z ) { + *this = + interpolate( + Vertex1, + Vertex2, + ( Z - Vertex1.position.z ) / ( Vertex2.position.z - Vertex1.position.z ) ); } +}; + +template <> +world_vertex & +world_vertex::operator+=( world_vertex const &Right ); + +template <> +world_vertex & +world_vertex::operator*=( world_vertex const &Right ); + +//--------------------------------------------------------------------------- diff --git a/windows.cpp b/windows.cpp new file mode 100644 index 00000000..70c29127 --- /dev/null +++ b/windows.cpp @@ -0,0 +1,71 @@ +#include "stdafx.h" +#include "messaging.h" +#include "utilities.h" + +#pragma warning (disable: 4091) +#include + +LONG CALLBACK unhandled_handler(::EXCEPTION_POINTERS* e) +{ + auto hDbgHelp = ::LoadLibraryA("dbghelp"); + if (hDbgHelp == nullptr) + return EXCEPTION_CONTINUE_SEARCH; + auto pMiniDumpWriteDump = (decltype(&MiniDumpWriteDump))::GetProcAddress(hDbgHelp, "MiniDumpWriteDump"); + if (pMiniDumpWriteDump == nullptr) + return EXCEPTION_CONTINUE_SEARCH; + + char name[MAX_PATH]; + { + auto nameEnd = name + ::GetModuleFileNameA(::GetModuleHandleA(0), name, MAX_PATH); + ::SYSTEMTIME t; + ::GetLocalTime(&t); + wsprintfA(nameEnd - strlen(".exe"), + "_crashdump_%4d%02d%02d_%02d%02d%02d.dmp", + t.wYear, t.wMonth, t.wDay, t.wHour, t.wMinute, t.wSecond); + } + + auto hFile = ::CreateFileA(name, GENERIC_WRITE, FILE_SHARE_READ, 0, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, 0); + if (hFile == INVALID_HANDLE_VALUE) + return EXCEPTION_CONTINUE_SEARCH; + + ::MINIDUMP_EXCEPTION_INFORMATION exceptionInfo; + exceptionInfo.ThreadId = ::GetCurrentThreadId(); + exceptionInfo.ExceptionPointers = e; + exceptionInfo.ClientPointers = FALSE; + + auto dumped = pMiniDumpWriteDump( + ::GetCurrentProcess(), + ::GetCurrentProcessId(), + hFile, + ::MINIDUMP_TYPE(::MiniDumpWithIndirectlyReferencedMemory | ::MiniDumpScanMemory), + e ? &exceptionInfo : nullptr, + nullptr, + nullptr); + + ::CloseHandle(hFile); + + return EXCEPTION_CONTINUE_SEARCH; +} + +HWND Hwnd; +WNDPROC BaseWindowProc; +PCOPYDATASTRUCT pDane; + +LRESULT APIENTRY WndProc( HWND hWnd, // handle for this window + UINT uMsg, // message for this window + WPARAM wParam, // additional message information + LPARAM lParam) // additional message information +{ + switch( uMsg ) // check for windows messages + { + case WM_COPYDATA: { + // obsługa danych przesłanych przez program sterujący + pDane = (PCOPYDATASTRUCT)lParam; + if( pDane->dwData == MAKE_ID4('E', 'U', '0', '7')) // sygnatura danych + multiplayer::OnCommandGet( ( multiplayer::DaneRozkaz *)( pDane->lpData ) ); + break; + } + } + // pass all unhandled messages to DefWindowProc + return CallWindowProc( BaseWindowProc, Hwnd, uMsg, wParam, lParam ); +}; \ No newline at end of file