16
0
mirror of https://github.com/MaSzyna-EU07/maszyna.git synced 2026-07-22 23:19:19 +02:00

introduced opengl texture object

This commit is contained in:
tmj-fstate
2017-02-11 21:02:21 +01:00
parent 1b6339e482
commit 22245a8801
17 changed files with 272 additions and 262 deletions

View File

@@ -449,12 +449,16 @@ bool TAnimModel::Init(std::string const &asName, std::string const &asReplacable
asText = asReplacableTexture.substr(1, asReplacableTexture.length() - 1); // zapamiętanie tekstu asText = asReplacableTexture.substr(1, asReplacableTexture.length() - 1); // zapamiętanie tekstu
else if (asReplacableTexture != "none") else if (asReplacableTexture != "none")
ReplacableSkinId[1] = ReplacableSkinId[1] =
TTexturesManager::GetTextureID(NULL, NULL, asReplacableTexture.c_str()); TTexturesManager.GetTextureId( asReplacableTexture, "" );
if (TTexturesManager::GetAlpha(ReplacableSkinId[1])) if( ( ReplacableSkinId[ 1 ] != 0 )
iTexAlpha = && ( TTexturesManager.Texture( ReplacableSkinId[ 1 ] ).has_alpha ) ) {
0x31310031; // tekstura z kanałem alfa - nie renderować w cyklu nieprzezroczystych // tekstura z kanałem alfa - nie renderować w cyklu nieprzezroczystych
else iTexAlpha = 0x31310031;
iTexAlpha = 0x30300030; // tekstura nieprzezroczysta - nie renderować w cyklu }
else{
// tekstura nieprzezroczysta - nie renderować w cyklu
iTexAlpha = 0x30300030;
}
// przezroczystych // przezroczystych
return (Init(TModelsManager::GetModel(asName.c_str()))); return (Init(TModelsManager::GetModel(asName.c_str())));
} }

View File

@@ -16,6 +16,7 @@ http://mozilla.org/MPL/2.0/.
#define AnimModelH #define AnimModelH
#include "Model3d.h" #include "Model3d.h"
#include "Texture.h"
const int iMaxNumLights = 8; const int iMaxNumLights = 8;
@@ -148,7 +149,7 @@ class TAnimModel
void RaAnimate(); // przeliczenie animacji egzemplarza void RaAnimate(); // przeliczenie animacji egzemplarza
void RaPrepare(); // ustawienie animacji egzemplarza na wzorcu void RaPrepare(); // ustawienie animacji egzemplarza na wzorcu
public: public:
GLuint ReplacableSkinId[5]; // McZapkie-020802: zmienialne skory texture_manager::size_type ReplacableSkinId[5]; // McZapkie-020802: zmienialne skory
static TAnimContainer *acAnimList; // lista animacji z eventem, które muszą być przeliczane static TAnimContainer *acAnimList; // lista animacji z eventem, które muszą być przeliczane
// również bez wyświetlania // również bez wyświetlania
TAnimModel(); TAnimModel();

View File

@@ -4417,7 +4417,7 @@ void TDynamicObject::LoadMMediaFile(std::string BaseDir, std::string TypeName,
Global::asCurrentTexturePath + ReplacableSkin; // skory tez z dynamic/... Global::asCurrentTexturePath + ReplacableSkin; // skory tez z dynamic/...
std::string x = TextureTest(Global::asCurrentTexturePath + "nowhere"); // na razie prymitywnie std::string x = TextureTest(Global::asCurrentTexturePath + "nowhere"); // na razie prymitywnie
if (!x.empty()) if (!x.empty())
ReplacableSkinID[4] = TTexturesManager::GetTextureID(NULL, NULL, Global::asCurrentTexturePath + "nowhere", 9); ReplacableSkinID[4] = TTexturesManager.GetTextureId( Global::asCurrentTexturePath + "nowhere", "", 9);
/* /*
if ((i = ReplacableSkin.Pos("|")) > 0) // replacable dzielone if ((i = ReplacableSkin.Pos("|")) > 0) // replacable dzielone
{ {
@@ -4480,24 +4480,22 @@ void TDynamicObject::LoadMMediaFile(std::string BaseDir, std::string TypeName,
*/ */
if (iMultiTex > 0) if (iMultiTex > 0)
{ // jeśli model ma 4 tekstury { // jeśli model ma 4 tekstury
ReplacableSkinID[1] = TTexturesManager::GetTextureID( ReplacableSkinID[1] = TTexturesManager.GetTextureId(
NULL, NULL, ReplacableSkin + ",1", Global::iDynamicFiltering); ReplacableSkin + ",1", "", Global::iDynamicFiltering);
if (ReplacableSkinID[1]) if (ReplacableSkinID[1])
{ // pierwsza z zestawu znaleziona { // pierwsza z zestawu znaleziona
ReplacableSkinID[2] = TTexturesManager::GetTextureID( ReplacableSkinID[2] = TTexturesManager.GetTextureId(
NULL, NULL, ReplacableSkin + ",2", Global::iDynamicFiltering); ReplacableSkin + ",2", "", Global::iDynamicFiltering);
if (ReplacableSkinID[2]) if (ReplacableSkinID[2])
{ {
iMultiTex = 2; // już są dwie iMultiTex = 2; // już są dwie
ReplacableSkinID[3] = TTexturesManager::GetTextureID( ReplacableSkinID[3] = TTexturesManager.GetTextureId(
NULL, NULL, ReplacableSkin + ",3", ReplacableSkin + ",3", "", Global::iDynamicFiltering);
Global::iDynamicFiltering);
if (ReplacableSkinID[3]) if (ReplacableSkinID[3])
{ {
iMultiTex = 3; // a teraz nawet trzy iMultiTex = 3; // a teraz nawet trzy
ReplacableSkinID[4] = TTexturesManager::GetTextureID( ReplacableSkinID[4] = TTexturesManager.GetTextureId(
NULL, NULL, ReplacableSkin + ",4", ReplacableSkin + ",4", "", Global::iDynamicFiltering);
Global::iDynamicFiltering);
if (ReplacableSkinID[4]) if (ReplacableSkinID[4])
iMultiTex = 4; // jak są cztery, to blokujemy podmianę tekstury iMultiTex = 4; // jak są cztery, to blokujemy podmianę tekstury
// rozkładem // rozkładem
@@ -4507,14 +4505,14 @@ void TDynamicObject::LoadMMediaFile(std::string BaseDir, std::string TypeName,
else else
{ // zestaw nie zadziałał, próbujemy normanie { // zestaw nie zadziałał, próbujemy normanie
iMultiTex = 0; iMultiTex = 0;
ReplacableSkinID[1] = TTexturesManager::GetTextureID( ReplacableSkinID[1] = TTexturesManager.GetTextureId(
NULL, NULL, ReplacableSkin, Global::iDynamicFiltering); ReplacableSkin, "", Global::iDynamicFiltering);
} }
} }
else else
ReplacableSkinID[1] = TTexturesManager::GetTextureID( ReplacableSkinID[1] = TTexturesManager.GetTextureId(
NULL, NULL, ReplacableSkin, Global::iDynamicFiltering); ReplacableSkin, "", Global::iDynamicFiltering);
if (TTexturesManager::GetAlpha(ReplacableSkinID[1])) if (TTexturesManager.Texture(ReplacableSkinID[1]).has_alpha)
iAlpha = 0x31310031; // tekstura -1 z kanałem alfa - nie renderować w cyklu iAlpha = 0x31310031; // tekstura -1 z kanałem alfa - nie renderować w cyklu
// nieprzezroczystych // nieprzezroczystych
else else
@@ -4522,21 +4520,22 @@ void TDynamicObject::LoadMMediaFile(std::string BaseDir, std::string TypeName,
// renderować w // renderować w
// cyklu przezroczystych // cyklu przezroczystych
if (ReplacableSkinID[2]) if (ReplacableSkinID[2])
if (TTexturesManager::GetAlpha(ReplacableSkinID[2])) if (TTexturesManager.Texture(ReplacableSkinID[2]).has_alpha)
iAlpha |= 0x02020002; // tekstura -2 z kanałem alfa - nie renderować iAlpha |= 0x02020002; // tekstura -2 z kanałem alfa - nie renderować
// w cyklu // w cyklu
// nieprzezroczystych // nieprzezroczystych
if (ReplacableSkinID[3]) if (ReplacableSkinID[3])
if (TTexturesManager::GetAlpha(ReplacableSkinID[3])) if (TTexturesManager.Texture(ReplacableSkinID[3]).has_alpha)
iAlpha |= 0x04040004; // tekstura -3 z kanałem alfa - nie renderować iAlpha |= 0x04040004; // tekstura -3 z kanałem alfa - nie renderować
// w cyklu // w cyklu
// nieprzezroczystych // nieprzezroczystych
if (ReplacableSkinID[4]) if (ReplacableSkinID[4])
if (TTexturesManager::GetAlpha(ReplacableSkinID[4])) if (TTexturesManager.Texture(ReplacableSkinID[4]).has_alpha)
iAlpha |= 0x08080008; // tekstura -4 z kanałem alfa - nie renderować iAlpha |= 0x08080008; // tekstura -4 z kanałem alfa - nie renderować
// w cyklu // w cyklu
// nieprzezroczystych // nieprzezroczystych
} }
/*
// Winger 040304 - ladowanie przedsionkow dla EZT // Winger 040304 - ladowanie przedsionkow dla EZT
if (MoverParameters->TrainType == dt_EZT) if (MoverParameters->TrainType == dt_EZT)
{ {
@@ -4544,6 +4543,7 @@ void TDynamicObject::LoadMMediaFile(std::string BaseDir, std::string TypeName,
asModel = BaseDir + asModel; asModel = BaseDir + asModel;
mdPrzedsionek = TModelsManager::GetModel(asModel, true); mdPrzedsionek = TModelsManager::GetModel(asModel, true);
} }
*/
if (!MoverParameters->LoadAccepted.empty()) if (!MoverParameters->LoadAccepted.empty())
// if (MoverParameters->LoadAccepted!=AnsiString("")); // && // if (MoverParameters->LoadAccepted!=AnsiString("")); // &&
// MoverParameters->LoadType!=AnsiString("passengers")) // MoverParameters->LoadType!=AnsiString("passengers"))
@@ -5849,13 +5849,13 @@ void TDynamicObject::DestinationSet(std::string to, std::string numer)
std::string x = TextureTest(asBaseDir + numer + "@" + MoverParameters->TypeName); std::string x = TextureTest(asBaseDir + numer + "@" + MoverParameters->TypeName);
if (!x.empty()) if (!x.empty())
{ {
ReplacableSkinID[4] = TTexturesManager::GetTextureID( NULL, NULL, x, 9); // rozmywania 0,1,4,5 nie nadają się ReplacableSkinID[4] = TTexturesManager.GetTextureId( x, "", 9); // rozmywania 0,1,4,5 nie nadają się
return; return;
} }
x = TextureTest(asBaseDir + numer ); x = TextureTest(asBaseDir + numer );
if (!x.empty()) if (!x.empty())
{ {
ReplacableSkinID[4] = TTexturesManager::GetTextureID( NULL, NULL, x, 9); // rozmywania 0,1,4,5 nie nadają się ReplacableSkinID[4] = TTexturesManager.GetTextureId( x, "", 9); // rozmywania 0,1,4,5 nie nadają się
return; return;
} }
if (to.empty()) if (to.empty())
@@ -5863,17 +5863,17 @@ void TDynamicObject::DestinationSet(std::string to, std::string numer)
x = TextureTest(asBaseDir + to + "@" + MoverParameters->TypeName); // w pierwszej kolejności z nazwą FIZ/MMD x = TextureTest(asBaseDir + to + "@" + MoverParameters->TypeName); // w pierwszej kolejności z nazwą FIZ/MMD
if (!x.empty()) if (!x.empty())
{ {
ReplacableSkinID[4] = TTexturesManager::GetTextureID( NULL, NULL, x, 9); // rozmywania 0,1,4,5 nie nadają się ReplacableSkinID[4] = TTexturesManager.GetTextureId( x, "", 9); // rozmywania 0,1,4,5 nie nadają się
return; return;
} }
x = TextureTest(asBaseDir + to); // na razie prymitywnie x = TextureTest(asBaseDir + to); // na razie prymitywnie
if (!x.empty()) if (!x.empty())
ReplacableSkinID[4] = TTexturesManager::GetTextureID( NULL, NULL, x, 9); // rozmywania 0,1,4,5 nie nadają się ReplacableSkinID[4] = TTexturesManager.GetTextureId( x, "", 9); // rozmywania 0,1,4,5 nie nadają się
else else
{ {
x = TextureTest(asBaseDir + "nowhere"); // jak nie znalazł dedykowanej, to niech daje nowhere x = TextureTest(asBaseDir + "nowhere"); // jak nie znalazł dedykowanej, to niech daje nowhere
if (!x.empty()) if (!x.empty())
ReplacableSkinID[4] = TTexturesManager::GetTextureID(NULL, NULL, x, 9); ReplacableSkinID[4] = TTexturesManager.GetTextureId( x, "", 9);
} }
// Ra 2015-01: żeby zalogować błąd, trzeba by mieć pewność, że model używa // Ra 2015-01: żeby zalogować błąd, trzeba by mieć pewność, że model używa
// tekstury nr 4 // tekstury nr 4

View File

@@ -395,7 +395,7 @@ private:
int iCabs; // maski bitowe modeli kabin int iCabs; // maski bitowe modeli kabin
TTrack *MyTrack; // McZapkie-030303: tor na ktorym stoi, ABu TTrack *MyTrack; // McZapkie-030303: tor na ktorym stoi, ABu
std::string asBaseDir; std::string asBaseDir;
GLuint ReplacableSkinID[5]; // McZapkie:zmienialne nadwozie texture_manager::size_type ReplacableSkinID[5]; // McZapkie:zmienialne nadwozie
int iAlpha; // maska przezroczystości tekstur int iAlpha; // maska przezroczystości tekstur
int iMultiTex; //<0 tekstury wskazane wpisem, >0 tekstury z przecinkami, =0 jedna 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 int iOverheadMask; // maska przydzielana przez AI pojazdom posiadającym pantograf, aby wymuszały

View File

@@ -60,8 +60,8 @@ int Global::iScreenMode[12] = {0, 0, 0, 0, 0, 0,
double Global::fSunDeclination = 0.0; // deklinacja Słońca double Global::fSunDeclination = 0.0; // deklinacja Słońca
double Global::fTimeAngleDeg = 0.0; // godzina w postaci kąta double Global::fTimeAngleDeg = 0.0; // godzina w postaci kąta
float Global::fClockAngleDeg[6]; // kąty obrotu cylindrów dla zegara cyfrowego float Global::fClockAngleDeg[6]; // kąty obrotu cylindrów dla zegara cyfrowego
char *Global::szTexturesTGA[4] = {"tga", "dds", "tex", "bmp"}; // lista tekstur od TGA std::string Global::szTexturesTGA = ".tga"; // lista tekstur od TGA
char *Global::szTexturesDDS[4] = {"dds", "tga", "tex", "bmp"}; // lista tekstur od DDS std::string Global::szTexturesDDS = ".dds"; // lista tekstur od DDS
int Global::iKeyLast = 0; // ostatnio naciśnięty klawisz w celu logowania int Global::iKeyLast = 0; // ostatnio naciśnięty klawisz w celu logowania
GLuint Global::iTextureId = 0; // ostatnio użyta tekstura 2D GLuint Global::iTextureId = 0; // ostatnio użyta tekstura 2D
int Global::iPause = 0x10; // globalna pauza ruchu int Global::iPause = 0x10; // globalna pauza ruchu
@@ -135,7 +135,7 @@ int Global::iDynamicFiltering = 5; // domyślne rozmywanie tekstur pojazdów
bool Global::bUseVBO = false; // czy jest VBO w karcie graficznej (czy użyć) bool Global::bUseVBO = false; // czy jest VBO w karcie graficznej (czy użyć)
GLint Global::iMaxTextureSize = 16384; // maksymalny rozmiar tekstury GLint Global::iMaxTextureSize = 16384; // maksymalny rozmiar tekstury
bool Global::bSmoothTraction = false; // wygładzanie drutów starym sposobem bool Global::bSmoothTraction = false; // wygładzanie drutów starym sposobem
char **Global::szDefaultExt = Global::szTexturesDDS; // domyślnie od DDS 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 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 bool Global::bGlutFont = false; // czy tekst generowany przez GLUT32.DLL
int Global::iConvertModels = 7; // tworzenie plików binarnych, +2-optymalizacja transformów int Global::iConvertModels = 7; // tworzenie plików binarnych, +2-optymalizacja transformów
@@ -422,6 +422,12 @@ void Global::ConfigParse(cParser &Parser)
// domyślnie od TGA // domyślnie od TGA
Global::szDefaultExt = Global::szTexturesTGA; Global::szDefaultExt = Global::szTexturesTGA;
} }
else {
Global::szDefaultExt =
( token[ 0 ] == '.' ?
token :
"." + token );
}
} }
else if (token == "newaircouplers") else if (token == "newaircouplers")
{ {

View File

@@ -184,7 +184,7 @@ class Global
static double fFogStart; static double fFogStart;
static double fFogEnd; static double fFogEnd;
static TGround *pGround; static TGround *pGround;
static char **szDefaultExt; static std::string szDefaultExt;
static std::string SceneryFile; static std::string SceneryFile;
static char CreatorName1[20]; static char CreatorName1[20];
static char CreatorName2[20]; static char CreatorName2[20];
@@ -258,8 +258,8 @@ class Global
static double fTimeAngleDeg; // godzina w postaci kąta static double fTimeAngleDeg; // godzina w postaci kąta
static float fClockAngleDeg[6]; // kąty obrotu cylindrów dla zegara cyfrowego static float fClockAngleDeg[6]; // kąty obrotu cylindrów dla zegara cyfrowego
static double fLatitudeDeg; // szerokość geograficzna static double fLatitudeDeg; // szerokość geograficzna
static char *szTexturesTGA[4]; // lista tekstur od TGA static std::string szTexturesTGA; // lista tekstur od TGA
static char *szTexturesDDS[4]; // lista tekstur od DDS static std::string szTexturesDDS; // lista tekstur od DDS
static int iMultisampling; // tryb antyaliasingu: 0=brak,1=2px,2=4px,3=8px,4=16px static int iMultisampling; // tryb antyaliasingu: 0=brak,1=2px,2=4px,3=8px,4=16px
static bool bGlutFont; // tekst generowany przez GLUT static bool bGlutFont; // tekst generowany przez GLUT
static int iKeyLast; // ostatnio naciśnięty klawisz w celu logowania static int iKeyLast; // ostatnio naciśnięty klawisz w celu logowania

View File

@@ -2103,14 +2103,14 @@ TGroundNode * TGround::AddGroundNode(cParser *parser)
// PROBLEND Q: 13122011 - Szociu: 27012012 // PROBLEND Q: 13122011 - Szociu: 27012012
PROBLEND = true; // domyslnie uruchomione nowe wyświetlanie PROBLEND = true; // domyslnie uruchomione nowe wyświetlanie
tmp->PROBLEND = true; // odwolanie do tgroundnode, bo rendering jest w tej klasie tmp->PROBLEND = true; // odwolanie do tgroundnode, bo rendering jest w tej klasie
if (str.find("@") != string::npos) // sprawdza, czy w nazwie tekstury jest znak "@" if (str.find('@') != string::npos) // sprawdza, czy w nazwie tekstury jest znak "@"
{ {
PROBLEND = false; // jeśli jest, wyswietla po staremu PROBLEND = false; // jeśli jest, wyswietla po staremu
tmp->PROBLEND = false; tmp->PROBLEND = false;
} }
#endif #endif
tmp->TextureID = TTexturesManager::GetTextureID(szTexturePath, szSceneryPath, str.c_str()); tmp->TextureID = TTexturesManager.GetTextureId( str, szTexturePath );
tmp->iFlags = TTexturesManager::GetAlpha(tmp->TextureID) ? 0x220 : 0x210; // z usuwaniem tmp->iFlags = TTexturesManager.Texture(tmp->TextureID).has_alpha ? 0x220 : 0x210; // z usuwaniem
if (((tmp->iType == GL_TRIANGLES) && (tmp->iFlags & 0x10)) ? if (((tmp->iType == GL_TRIANGLES) && (tmp->iFlags & 0x10)) ?
Global::pTerrainCompact->TerrainLoaded() : Global::pTerrainCompact->TerrainLoaded() :
false) false)

View File

@@ -14,6 +14,7 @@ http://mozilla.org/MPL/2.0/.
#include "VBO.h" #include "VBO.h"
#include "Classes.h" #include "Classes.h"
#include "ResourceManager.h" #include "ResourceManager.h"
#include "Texture.h"
#include "dumb3d.h" #include "dumb3d.h"
#include "Names.h" #include "Names.h"
@@ -141,7 +142,7 @@ class TGroundNode : public Resource
GLuint DisplayListID; // numer siatki DisplayLists GLuint DisplayListID; // numer siatki DisplayLists
bool PROBLEND; bool PROBLEND;
int iVboPtr; // indeks w buforze VBO int iVboPtr; // indeks w buforze VBO
GLuint TextureID; // główna (jedna) tekstura obiektu texture_manager::size_type TextureID; // główna (jedna) tekstura obiektu
int iFlags; // tryb przezroczystości: 0x10-nieprz.,0x20-przezroczysty,0x30-mieszany int iFlags; // tryb przezroczystości: 0x10-nieprz.,0x20-przezroczysty,0x30-mieszany
int Ambient[4], Diffuse[4], Specular[4]; // oświetlenie int Ambient[4], Diffuse[4], Specular[4]; // oświetlenie
bool bVisible; bool bVisible;

View File

@@ -411,13 +411,12 @@ int TSubModel::Load(cParser &parser, TModel3d *Model, int Pos, bool dynamic)
TextureNameSet(texture.c_str()); TextureNameSet(texture.c_str());
if (texture.find_first_of("/\\") == texture.npos) if (texture.find_first_of("/\\") == texture.npos)
texture.insert(0, Global::asCurrentTexturePath.c_str()); texture.insert(0, Global::asCurrentTexturePath.c_str());
TextureID = TTexturesManager::GetTextureID( TextureID = TTexturesManager.GetTextureId( texture, szTexturePath );
szTexturePath, const_cast<char *>(Global::asCurrentTexturePath.c_str()), texture);
// TexAlpha=TTexturesManager::GetAlpha(TextureID); // TexAlpha=TTexturesManager::GetAlpha(TextureID);
// iFlags|=TexAlpha?0x20:0x10; //0x10-nieprzezroczysta, 0x20-przezroczysta // iFlags|=TexAlpha?0x20:0x10; //0x10-nieprzezroczysta, 0x20-przezroczysta
if (Opacity < 1.0) // przezroczystość z tekstury brana tylko dla Opacity if (Opacity < 1.0) // przezroczystość z tekstury brana tylko dla Opacity
// 0! // 0!
iFlags |= TTexturesManager::GetAlpha(TextureID) ? iFlags |= TTexturesManager.Texture(TextureID).has_alpha ?
0x20 : 0x20 :
0x10; // 0x10-nieprzezroczysta, 0x20-przezroczysta 0x10; // 0x10-nieprzezroczysta, 0x20-przezroczysta
else else
@@ -616,7 +615,7 @@ int TSubModel::Load(cParser &parser, TModel3d *Model, int Pos, bool dynamic)
return iNumVerts; // do określenia wielkości VBO return iNumVerts; // do określenia wielkości VBO
}; };
int TSubModel::TriangleAdd(TModel3d *m, int tex, int tri) int TSubModel::TriangleAdd(TModel3d *m, texture_manager::size_type tex, int tri)
{ // dodanie trójkątów do submodelu, używane { // dodanie trójkątów do submodelu, używane
// przy tworzeniu E3D terenu // przy tworzeniu E3D terenu
TSubModel *s = this; TSubModel *s = this;
@@ -637,7 +636,7 @@ int TSubModel::TriangleAdd(TModel3d *m, int tex, int tri)
m->AddTo(this, s); m->AddTo(this, s);
} }
// s->asTexture=AnsiString(TTexturesManager::GetName(tex).c_str()); // s->asTexture=AnsiString(TTexturesManager::GetName(tex).c_str());
s->TextureNameSet(TTexturesManager::GetName(tex).c_str()); s->TextureNameSet(TTexturesManager.Texture(tex).name.c_str());
s->TextureID = tex; s->TextureID = tex;
s->eType = GL_TRIANGLES; s->eType = GL_TRIANGLES;
// iAnimOwner=0; //roboczy wskaźnik na wierzchołek // iAnimOwner=0; //roboczy wskaźnik na wierzchołek
@@ -1625,15 +1624,14 @@ void TSubModel::BinInit(TSubModel *s, float4x4 *m, float8 *v, TStringPack *t, TS
std::string tex = pTexture; std::string tex = pTexture;
if (tex.find_last_of("/\\") == std::string::npos) if (tex.find_last_of("/\\") == std::string::npos)
tex.insert(0, Global::asCurrentTexturePath); tex.insert(0, Global::asCurrentTexturePath);
TextureID = TTexturesManager::GetTextureID( TextureID = TTexturesManager.GetTextureId( tex, szTexturePath );
szTexturePath, const_cast<char *>(Global::asCurrentTexturePath.c_str()), tex);
// TexAlpha=TTexturesManager::GetAlpha(TextureID); //zmienna robocza // TexAlpha=TTexturesManager::GetAlpha(TextureID); //zmienna robocza
// ustawienie cyklu przezroczyste/nieprzezroczyste zależnie od własności // ustawienie cyklu przezroczyste/nieprzezroczyste zależnie od własności
// stałej tekstury // stałej tekstury
// iFlags=(iFlags&~0x30)|(TTexturesManager::GetAlpha(TextureID)?0x20:0x10); // iFlags=(iFlags&~0x30)|(TTexturesManager::GetAlpha(TextureID)?0x20:0x10);
// //0x10-nieprzezroczysta, 0x20-przezroczysta // //0x10-nieprzezroczysta, 0x20-przezroczysta
if (Opacity < 1.0) // przezroczystość z tekstury brana tylko dla Opacity 0! if (Opacity < 1.0) // przezroczystość z tekstury brana tylko dla Opacity 0!
iFlags |= TTexturesManager::GetAlpha(TextureID) ? iFlags |= TTexturesManager.Texture(TextureID).has_alpha ?
0x20 : 0x20 :
0x10; // 0x10-nieprzezroczysta, 0x20-przezroczysta 0x10; // 0x10-nieprzezroczysta, 0x20-przezroczysta
else else

View File

@@ -15,6 +15,7 @@ http://mozilla.org/MPL/2.0/.
#include "dumb3d.h" #include "dumb3d.h"
#include "Float3d.h" #include "Float3d.h"
#include "VBO.h" #include "VBO.h"
#include "Texture.h"
using namespace Math3D; using namespace Math3D;
@@ -215,7 +216,7 @@ class TSubModel
// światła // światła
float fCosViewAngle; // cos kata pod jakim sie teraz patrzy float fCosViewAngle; // cos kata pod jakim sie teraz patrzy
// Ra: dalej są zmienne robocze, można je przestawiać z zachowaniem rozmiaru klasy // Ra: dalej są zmienne robocze, można je przestawiać z zachowaniem rozmiaru klasy
int TextureID; // numer tekstury, -1 wymienna, 0 brak texture_manager::size_type TextureID; // numer tekstury, -1 wymienna, 0 brak
bool bWire; // nie używane, ale wczytywane bool bWire; // nie używane, ale wczytywane
// short TexAlpha; //Ra: nie używane już // short TexAlpha; //Ra: nie używane już
GLuint uiDisplayList; // roboczy numer listy wyświetlania GLuint uiDisplayList; // roboczy numer listy wyświetlania
@@ -271,7 +272,7 @@ class TSubModel
{ {
return Child; return Child;
}; };
int TriangleAdd(TModel3d *m, int tex, int tri); 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(int tex, int pos, int *la, int *ld, int *ls);
// float8* TrianglePtr(const char *tex,int tri); // float8* TrianglePtr(const char *tex,int tri);
// void SetRotate(vector3 vNewRotateAxis,float fNewAngle); // void SetRotate(vector3 vNewRotateAxis,float fNewAngle);

View File

@@ -26,11 +26,20 @@ http://mozilla.org/MPL/2.0/.
#include "Usefull.h" #include "Usefull.h"
#include "TextureDDS.h" #include "TextureDDS.h"
texture_manager TTexturesManager;
/*
TTexturesManager::Alphas TTexturesManager::_alphas; TTexturesManager::Alphas TTexturesManager::_alphas;
TTexturesManager::Names TTexturesManager::_names; TTexturesManager::Names TTexturesManager::_names;
*/
void
texture_manager::Init() {
void TTexturesManager::Init(){}; // 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() );
}
/*
TTexturesManager::Names::iterator TTexturesManager::LoadFromFile(std::string fileName, int filter) TTexturesManager::Names::iterator TTexturesManager::LoadFromFile(std::string fileName, int filter)
{ {
@@ -81,7 +90,8 @@ TTexturesManager::Names::iterator TTexturesManager::LoadFromFile(std::string fil
// WriteLog("OK"); //Ra: "OK" nie potrzeba, samo "Failed" wystarczy // WriteLog("OK"); //Ra: "OK" nie potrzeba, samo "Failed" wystarczy
return ret.first; return ret.first;
}; };
*/
/*
struct ReplaceSlash struct ReplaceSlash
{ {
const char operator()(const char input) const char operator()(const char input)
@@ -89,159 +99,137 @@ struct ReplaceSlash
return input == '/' ? '\\' : input; return input == '/' ? '\\' : input;
} }
}; };
*/
// ustalenie numeru tekstury, wczytanie jeśli nie jeszcze takiej nie było
texture_manager::size_type
texture_manager::GetTextureId( std::string Filename, std::string const &Dir, int const Filter ) {
GLuint TTexturesManager::GetTextureID(char *dir, char *where, std::string fileName, int filter) if( Filename.find( ':' ) != std::string::npos )
{ // ustalenie numeru tekstury, wczytanie jeśli nie jeszcze takiej nie było Filename.erase( Filename.find( ':' ) ); // po dwukropku mogą być podane dodatkowe informacje niebędące nazwą tekstury
/* if( Filename.find( '|' ) != std::string::npos )
// Ra: niby tak jest lepiej, ale działa gorzej, więc przywrócone jest oryginalne Filename.erase( Filename.find( '|' ) ); // po | może być nazwa kolejnej tekstury
//najpierw szukamy w katalogu, z którego wywoływana jest tekstura, potem z wyższego for( char &c : Filename ) {
//Ra: przerobić na wyszukiwanie w drzewie nazw, do którego zapisywać np. rozmiary, // change forward slashes to windows ones. NOTE: probably not strictly necessary, but eh
przezroczystość c = ( c == '/' ? '\\' : c );
//Ra: ustalać, które tekstury można wczytać już w trakcie symulacji }
size_t pos=fileName.find(':'); //szukamy dwukropka /*
if (pos!=std::string::npos) //po dwukropku mogą być podane dodatkowe informacje std::transform(
fileName=fileName.substr(0,pos); //niebędące nazwą tekstury Filename.begin(), Filename.end(),
std::transform(fileName.begin(),fileName.end(),fileName.begin(),ReplaceSlash()); //zamiana "/" Filename.begin(),
na "\" []( char Char ){ return Char == '/' ? '\\' : Char; } );
//jeśli bieżaca ścieżka do tekstur nie została dodana to dodajemy domyślną */
//if (fileName.find('\\')==std::string::npos) //bz sensu if( Filename.find( '\\' ) == std::string::npos ) {
// fileName.insert(0,szDefaultTexturePath); // jeśli bieżaca ścieżka do tekstur nie została dodana to dodajemy domyślną
//najpierw szukamy w podanym katalogu, potem w domyślnym Filename = szTexturePath + Filename;
Names::iterator iter; }
std::ifstream file;
if ((fileName.find('.')==fileName.npos)?true:(fileName.rfind('.')<fileName.rfind('\\'))) std::vector<std::string> extensions{ { ".dds" }, { ".tga" }, { ".bmp" }, { ".ext" } };
//pierwsza kropka od prawej jest wcześniej niż "\"
{//Ra: jeśli nie ma kropki w nazwie pliku, wypróbowanie rozszerzeń po kolei, zaczynając od // try to locate requested texture in the databank
domyślnego auto lookup = find_in_databank( Filename + Global::szDefaultExt );
fileName.append("."); //kropkę trzeba dodać na pewno, resztę trzeba próbować if( lookup != npos ) {
std::string test; //zmienna robocza // start with the default extension...
for (int i=0;i<4;++i) return lookup;
{//najpierw szukamy w magazynie }
test=fileName; else {
if (where) test.insert(0,where); //ścieżka obiektu wywołującego // ...then try recognized file extensions other than default
test.append(Global::szDefaultExt[i]); //dodanie jednego z kilku rozszerzeń for( auto const &extension : extensions ) {
iter=_names.find(test); //czy mamy już w magazynie?
if (iter!=_names.end()) if( extension == Global::szDefaultExt ) {
return iter->second; //znalezione! // we already tried this one
if (dir) continue;
{//może we wskazanym katalogu?
test=fileName;
test.insert(0,dir); //jeszcze próba z dodatkową ścieżką
test.append(Global::szDefaultExt[i]); //dodanie jednego z kilku rozszerzeń
iter=_names.find(test); //czy mamy już w magazynie?
if (iter!=_names.end())
return iter->second; //znalezione!
}
//}
//for (int i=0;i<4;++i)
//{//w magazynie nie ma, to sprawdzamy na dysku
test=fileName;
if (where) test.insert(0,where); //ścieżka obiektu wywołującego
test.append(Global::szDefaultExt[i]); //dodanie jednego z kilku rozszerzeń
file.open(test.c_str());
if (!file.is_open())
{test=fileName;
if (dir) test.insert(0,dir); //próba z dodatkową ścieżką
test.append(Global::szDefaultExt[i]); //dodanie jednego z kilku rozszerzeń
file.open(test.c_str());
}
if (file.is_open())
{//jak znaleziony, to plik zostaje otwarty
fileName=test; //zapamiętanie znalezionego rozszerzenia
break; //wyjście z pętli na etapie danego rozszerzenia
}
}
}
else
{//gdy jest kropka, to rozszerzenie jest jawne
std::string test; //zmienna robocza
//najpierw szukamy w magazynie
test=fileName;
if (where) test.insert(0,where); //ścieżka obiektu wywołującego
iter=_names.find(test); //czy mamy już w magazynie?
if (iter!=_names.end())
return iter->second; //znalezione!
test=fileName;
if (dir) test.insert(0,dir); //jeszcze próba z dodatkową ścieżką
iter=_names.find(test); //czy mamy już w magazynie?
if (iter!=_names.end())
return iter->second; //znalezione!
//w magazynie nie ma, to sprawdzamy na dysku
test=fileName;
if (where) test.insert(0,where); //ścieżka obiektu wywołującego
file.open(test.c_str());
if (!file.is_open())
{//jak znaleziony, to plik zostaje otwarty
test=fileName;
if (dir) test.insert(0,dir); //próba z dodatkową ścieżką
file.open(test.c_str());
if (file.is_open())
fileName=test; //ustalenie nowej nazwy
}
}
if (file.is_open())
{//plik pozostaje otwarty, gdy znaleziono na dysku
file.close(); //można już zamknąć
iter=LoadFromFile(fileName,filter); //doda się do magazynu i zwróci swoją pozycję
}
*/
size_t pos = fileName.find(':'); // szukamy dwukropka
if (pos != std::string::npos) // po dwukropku mogą być podane dodatkowe informacje
fileName = fileName.substr(0, pos); // niebędące nazwą tekstury
pos = fileName.find('|'); // szukamy separatora tekstur
if (pos != std::string::npos) // po | może być nazwa kolejnej tekstury
fileName = fileName.substr(0, pos); // i trzeba to obciąć
std::transform(fileName.begin(), fileName.end(), fileName.begin(), ReplaceSlash());
// jeśli bieżaca ścieżka do tekstur nie została dodana to dodajemy domyślną
if (fileName.find('\\') == std::string::npos)
fileName.insert(0, szTexturePath);
Names::iterator iter;
if (fileName.find('.') == std::string::npos)
{ // Ra: wypróbowanie rozszerzeń po kolei, zaczynając od domyślnego
fileName.append("."); // kropka będze na pewno, resztę trzeba próbować
std::string test; // zmienna robocza
for (int i = 0; i < 4; ++i)
{ // najpierw szukamy w magazynie
test = fileName;
test.append(Global::szDefaultExt[i]);
iter = _names.find(fileName); // czy mamy już w magazynie?
if (iter != _names.end())
return iter->second; // znalezione!
test.insert(0, szTexturePath); // jeszcze próba z dodatkową ścieżką
iter = _names.find(fileName); // czy mamy już w magazynie?
if (iter != _names.end())
return iter->second; // znalezione!
}
for (int i = 0; i < 4; ++i)
{ // w magazynie nie ma, to sprawdzamy na dysku
test = fileName;
test.append(Global::szDefaultExt[i]);
std::ifstream file(test.c_str());
if (!file.is_open())
{
test.insert(0, szTexturePath);
file.open(test.c_str());
} }
if (file.is_open()) lookup = find_in_databank( Filename + extension );
{ if( lookup != npos ) {
fileName.append(Global::szDefaultExt[i]); // dopisanie znalezionego
file.close(); return lookup;
break; // wyjście z pętli na etapie danego rozszerzenia
} }
} }
} }
iter = _names.find(fileName); // czy mamy już w magazynie // if we don't have the texture in the databank, check if it's on disk
if (iter == _names.end()) std::string filename = find_on_disk( Filename + Global::szDefaultExt );
iter = LoadFromFile(fileName, filter); if( true == filename.empty() ) {
return (iter != _names.end() ? iter->second : 0); // if the default lookup fails, try other known extensions
for( auto const &extension : extensions ) {
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() ) {
// there's nothing matching in the databank nor on the disk, report failure
return npos;
}
opengl_texture texture;
texture.name = filename;
m_textures.emplace_back( texture );
auto const textureindex = m_textures.size() - 1;
m_texturemappings.emplace( filename, textureindex );
WriteLog( "Created texture object for file \"" + filename + "\"" );
return textureindex;
}; };
// 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 "";
}
/*
bool TTexturesManager::GetAlpha(GLuint id) bool TTexturesManager::GetAlpha(GLuint id)
{ // atrybut przezroczystości dla tekstury o podanym numerze (id) { // atrybut przezroczystości dla tekstury o podanym numerze (id)
Alphas::iterator iter = _alphas.find(id); Alphas::iterator iter = _alphas.find(id);
return (iter != _alphas.end() ? iter->second : false); return (iter != _alphas.end() ? iter->second : false);
} }
*/
/*
TTexturesManager::AlphaValue TTexturesManager::LoadBMP(std::string const &fileName) TTexturesManager::AlphaValue TTexturesManager::LoadBMP(std::string const &fileName)
{ {
@@ -797,6 +785,8 @@ TTexturesManager::AlphaValue TTexturesManager::LoadDDS(std::string fileName, int
return std::make_pair(id, data.components == 4); return std::make_pair(id, data.components == 4);
}; };
*/
/*
void TTexturesManager::SetFiltering(int filter) void TTexturesManager::SetFiltering(int filter)
{ {
if (filter < 4) // rozmycie przy powiększeniu if (filter < 4) // rozmycie przy powiększeniu
@@ -910,17 +900,16 @@ GLuint TTexturesManager::CreateTexture(GLubyte *buff, GLint bpp, int width, int
return ID; return ID;
} }
*/
void TTexturesManager::Free() void
{ // usunięcie wszyskich tekstur (bez usuwania struktury) texture_manager::Free()
// for (Names::iterator iter = _names.begin(); iter != _names.end(); iter++) {
if( false == _names.empty() ) { for( auto const &texture : m_textures ) {
for( auto const &texture : _names ) { // usunięcie wszyskich tekstur (bez usuwania struktury)
glDeleteTextures( 1, &texture.second ); glDeleteTextures( 1, &texture.id );
} }
}
} }
/*
std::string TTexturesManager::GetName(GLuint id) std::string TTexturesManager::GetName(GLuint id)
{ // pobranie nazwy tekstury { // pobranie nazwy tekstury
for( auto const &pair : _names ) { for( auto const &pair : _names ) {
@@ -928,3 +917,4 @@ std::string TTexturesManager::GetName(GLuint id)
} }
return ""; return "";
}; };
*/

View File

@@ -12,49 +12,56 @@ http://mozilla.org/MPL/2.0/.
#include <string> #include <string>
#include "opengl/glew.h" #include "opengl/glew.h"
struct opengl_texture {
GLuint id{ -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 name; // name of the texture source file
std::vector<char> data; // texture data
/*std::atomic<bool>*/ bool is_loaded{ false }; // indicates the texture data was loaded and can be processed
/*std::atomic<bool>*/ bool is_good{ false }; // indicates the texture data was retrieved without errors
};
class texture_manager {
private:
typedef std::vector<opengl_texture> opengltexture_array;
public:
typedef opengltexture_array::size_type size_type;
~texture_manager() { Free(); }
size_type GetTextureId( std::string Filename, std::string const &Dir, int const Filter = -1 );
opengl_texture &Texture( size_type const Id ) { return m_textures.at( Id ); }
void Init();
void Free();
private:
typedef std::unordered_map<std::string, size_type> index_map;
/* /*
//Ra: miejsce umieszczenia tego jest deczko bezsensowne opengltexture_array::size_type LoadFromFile(std::string name, int filter = -1);
void glDebug()
{//logowanie błędów OpenGL
GLenum err;
if (Global::iErorrCounter==326) //tu wpisz o 1 mniej niz wartość, przy której się wyłożyło
Global::iErorrCounter=Global::iErorrCounter+0; //do zastawiania pułapki przed błędnym kodem
while ((err=glGetError())!=GL_NO_ERROR) //dalej jest pułapka po wykonaniu błędnego kodu
WriteLog("OpenGL error found: "+AnsiString(err)+", step:"+AnsiString(Global::iErorrCounter));
++Global::iErorrCounter;
};
*/ */
/*
class TTexturesManager bool LoadBMP( std::string const &fileName);
{ bool LoadTEX( std::string fileName );
public: bool LoadTGA( std::string fileName, int filter = -1 );
static void Init(); bool LoadDDS( std::string fileName, int filter = -1 );
static void Free(); */
// checks whether specified texture is in the texture bank. returns texture id, or npos.
static GLuint GetTextureID(char *dir, char *where, std::string name, int filter = -1); size_type find_in_databank( std::string const &Texturename );
static bool GetAlpha(GLuint ID); // McZapkie-141203: czy tekstura ma polprzeroczystosc // checks whether specified file exists. returns name of the located file, or empty string.
static std::string GetName(GLuint id); std::string find_on_disk( std::string const &Texturename );
/*
private: void SetFiltering(int filter);
typedef std::pair<GLuint, bool> AlphaValue; void SetFiltering(bool alpha, bool hash);
GLuint CreateTexture(GLubyte *buff, GLint bpp, int width, int height, bool bHasAlpha,
typedef std::map<std::string, GLuint> Names; bool bHash, bool bDollar = true, int filter = -1);
typedef std::map<GLuint, bool> Alphas; */
static const size_type npos{ 0 }; // should be -1, but the rest of the code uses -1 for something else
static Names::iterator LoadFromFile(std::string name, int filter = -1); opengltexture_array m_textures;
index_map m_texturemappings;
static AlphaValue LoadBMP(std::string const &fileName);
static AlphaValue LoadTEX(std::string fileName);
static AlphaValue LoadTGA(std::string fileName, int filter = -1);
static AlphaValue LoadDDS(std::string fileName, int filter = -1);
static void SetFiltering(int filter);
static void SetFiltering(bool alpha, bool hash);
static GLuint CreateTexture(GLubyte *buff, GLint bpp, int width, int height, bool bHasAlpha,
bool bHash, bool bDollar = true, int filter = -1);
static Names _names;
static Alphas _alphas;
// std::list<TTexture> Textures;
}; };
//---------------------------------------------------------------------------
extern texture_manager TTexturesManager;

View File

@@ -508,8 +508,8 @@ void TTrack::Load(cParser *parser, vector3 pOrigin, std::string name)
parser->getTokens(); parser->getTokens();
*parser >> token; *parser >> token;
str = token; // railtex str = token; // railtex
TextureID1 = (str == "none" ? 0 : TTexturesManager::GetTextureID( TextureID1 = (str == "none" ? 0 : TTexturesManager.GetTextureId(
szTexturePath, szSceneryPath, str, str, szTexturePath,
(iCategoryFlag & 1) ? Global::iRailProFiltering : (iCategoryFlag & 1) ? Global::iRailProFiltering :
Global::iBallastFiltering)); Global::iBallastFiltering));
parser->getTokens(); parser->getTokens();
@@ -519,8 +519,8 @@ void TTrack::Load(cParser *parser, vector3 pOrigin, std::string name)
parser->getTokens(); parser->getTokens();
*parser >> token; *parser >> token;
str = token; // sub || railtex str = token; // sub || railtex
TextureID2 = (str == "none" ? 0 : TTexturesManager::GetTextureID( TextureID2 = (str == "none" ? 0 : TTexturesManager.GetTextureId(
szTexturePath, szSceneryPath, str, str, szTexturePath,
(eType == tt_Normal) ? Global::iBallastFiltering : (eType == tt_Normal) ? Global::iBallastFiltering :
Global::iRailProFiltering)); Global::iRailProFiltering));
parser->getTokens(3); parser->getTokens(3);

View File

@@ -13,6 +13,7 @@ http://mozilla.org/MPL/2.0/.
#include "opengl/glew.h" #include "opengl/glew.h"
#include "ResourceManager.h" #include "ResourceManager.h"
#include "Segment.h" #include "Segment.h"
#include "Texture.h"
class TEvent; class TEvent;
@@ -136,8 +137,8 @@ class TTrack : public Resource
TTrack *trNext = nullptr; // odcinek od strony punktu 2 - to powinno być w segmencie TTrack *trNext = nullptr; // odcinek od strony punktu 2 - to powinno być w segmencie
TTrack *trPrev = nullptr; // odcinek od strony punktu 1 TTrack *trPrev = nullptr; // odcinek od strony punktu 1
// McZapkie-070402: dodalem zmienne opisujace rozmiary tekstur // McZapkie-070402: dodalem zmienne opisujace rozmiary tekstur
GLuint TextureID1 = 0; // tekstura szyn albo nawierzchni texture_manager::size_type TextureID1 = 0; // tekstura szyn albo nawierzchni
GLuint TextureID2 = 0; // tekstura automatycznej podsypki albo pobocza texture_manager::size_type TextureID2 = 0; // tekstura automatycznej podsypki albo pobocza
float fTexLength = 4.0; // długość powtarzania tekstury w metrach 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 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 fTexRatio2 = 1.0; // proporcja boków tekstury chodnika (żeby zaoszczędzić na rozmiarach tekstur...)

View File

@@ -71,7 +71,7 @@ TWorld::~TWorld()
// Ground.Free(); //Ra: usunięcie obiektów przed usunięciem dźwięków - sypie się // Ground.Free(); //Ra: usunięcie obiektów przed usunięciem dźwięków - sypie się
TSoundsManager::Free(); TSoundsManager::Free();
TModelsManager::Free(); TModelsManager::Free();
TTexturesManager::Free(); // TTexturesManager.Free();
glDeleteLists(base, 96); glDeleteLists(base, 96);
if (hinstGLUT32) if (hinstGLUT32)
FreeLibrary(hinstGLUT32); FreeLibrary(hinstGLUT32);
@@ -479,8 +479,7 @@ bool TWorld::Init(HWND NhWnd, HDC hDC)
glDisable(GL_DEPTH_TEST); // Disables depth testing glDisable(GL_DEPTH_TEST); // Disables depth testing
glColor3f(3.0f, 3.0f, 3.0f); glColor3f(3.0f, 3.0f, 3.0f);
GLuint logo; auto logo = TTexturesManager.GetTextureId( "logo", szTexturePath, 6 );
logo = TTexturesManager::GetTextureID(szTexturePath, szSceneryPath, "logo", 6);
glBindTexture(GL_TEXTURE_2D, logo); // Select our texture glBindTexture(GL_TEXTURE_2D, logo); // Select our texture
glBegin(GL_QUADS); // Drawing using triangles glBegin(GL_QUADS); // Drawing using triangles
@@ -527,8 +526,9 @@ bool TWorld::Init(HWND NhWnd, HDC hDC)
glPrint("Tekstury / Textures..."); glPrint("Tekstury / Textures...");
} }
SwapBuffers(hDC); // Swap Buffers (Double Buffering) SwapBuffers(hDC); // Swap Buffers (Double Buffering)
/*
TTexturesManager::Init(); TTexturesManager.Init();
*/
WriteLog("Textures init OK"); WriteLog("Textures init OK");
if (Global::detonatoryOK) if (Global::detonatoryOK)
{ {
@@ -663,9 +663,9 @@ bool TWorld::Init(HWND NhWnd, HDC hDC)
// glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); //{Texture blends with object // glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); //{Texture blends with object
// background} // background}
if (Global::bOldSmudge == true) if (Global::bOldSmudge == true)
light = TTexturesManager::GetTextureID(szTexturePath, szSceneryPath, "smuga.tga"); light = TTexturesManager.GetTextureId( "smuga.tga", szTexturePath );
else else
light = TTexturesManager::GetTextureID(szTexturePath, szSceneryPath, "smuga2.tga"); light = TTexturesManager.GetTextureId( "smuga2.tga", szTexturePath );
// Camera.Reset(); // Camera.Reset();
Timer::ResetTimers(); Timer::ResetTimers();
WriteLog( "Load time: " + WriteLog( "Load time: " +

View File

@@ -51,7 +51,7 @@ class TWorld
TDynamicObject *pDynamicNearest; TDynamicObject *pDynamicNearest;
bool Paused; bool Paused;
GLuint base; // numer DL dla znaków w napisach GLuint base; // numer DL dla znaków w napisach
GLuint light; // numer tekstury dla smugi texture_manager::size_type light; // numer tekstury dla smugi
TSky Clouds; TSky Clouds;
TEvent *KeyEvents[10]; // eventy wyzwalane z klawiaury TEvent *KeyEvents[10]; // eventy wyzwalane z klawiaury
TMoverParameters *mvControlled; // wskaźnik na człon silnikowy, do wyświetlania jego parametrów TMoverParameters *mvControlled; // wskaźnik na człon silnikowy, do wyświetlania jego parametrów

View File

@@ -54,6 +54,7 @@
#include <limits> #include <limits>
#include <memory> #include <memory>
#include <thread> #include <thread>
#include <atomic>
#include <mutex> #include <mutex>
#include <condition_variable> #include <condition_variable>
#include <typeinfo> #include <typeinfo>