mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-07-23 03:59:18 +02:00
completed basic separation of visual renderer from simulation
This commit is contained in:
@@ -445,7 +445,7 @@ 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")
|
||||||
m_materialdata.replacable_skins[1] =
|
m_materialdata.replacable_skins[1] =
|
||||||
GfxRenderer.GetTextureId( asReplacableTexture, "" );
|
GfxRenderer.Fetch_Texture( asReplacableTexture, "" );
|
||||||
if( ( m_materialdata.replacable_skins[ 1 ] != 0 )
|
if( ( m_materialdata.replacable_skins[ 1 ] != 0 )
|
||||||
&& ( GfxRenderer.Texture( m_materialdata.replacable_skins[ 1 ] ).has_alpha ) ) {
|
&& ( GfxRenderer.Texture( m_materialdata.replacable_skins[ 1 ] ).has_alpha ) ) {
|
||||||
// tekstura z kanałem alfa - nie renderować w cyklu nieprzezroczystych
|
// tekstura z kanałem alfa - nie renderować w cyklu nieprzezroczystych
|
||||||
@@ -606,6 +606,7 @@ int TAnimModel::Flags()
|
|||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
// 2011-03-16 funkcje renderowania z możliwością pochylania obiektów
|
// 2011-03-16 funkcje renderowania z możliwością pochylania obiektów
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
#ifdef EU07_USE_OLD_RENDERCODE
|
||||||
void TAnimModel::Render( vector3 const &Position ) {
|
void TAnimModel::Render( vector3 const &Position ) {
|
||||||
RaAnimate(); // jednorazowe przeliczenie animacji
|
RaAnimate(); // jednorazowe przeliczenie animacji
|
||||||
RaPrepare();
|
RaPrepare();
|
||||||
@@ -617,7 +618,7 @@ void TAnimModel::RenderAlpha( vector3 const &Position ) {
|
|||||||
if( pModel ) // renderowanie rekurencyjne submodeli
|
if( pModel ) // renderowanie rekurencyjne submodeli
|
||||||
GfxRenderer.Render_Alpha( pModel, Material(), Position, vAngle );
|
GfxRenderer.Render_Alpha( pModel, Material(), Position, vAngle );
|
||||||
};
|
};
|
||||||
|
#endif
|
||||||
//---------------------------------------------------------------------------
|
//---------------------------------------------------------------------------
|
||||||
bool TAnimModel::TerrainLoaded()
|
bool TAnimModel::TerrainLoaded()
|
||||||
{ // zliczanie kwadratów kilometrowych (główna linia po Next) do tworznia tablicy
|
{ // zliczanie kwadratów kilometrowych (główna linia po Next) do tworznia tablicy
|
||||||
|
|||||||
@@ -164,8 +164,10 @@ class TAnimModel {
|
|||||||
bool Load(cParser *parser, bool ter = false);
|
bool Load(cParser *parser, bool ter = false);
|
||||||
TAnimContainer * AddContainer(char *pName);
|
TAnimContainer * AddContainer(char *pName);
|
||||||
TAnimContainer * GetContainer(char *pName);
|
TAnimContainer * GetContainer(char *pName);
|
||||||
|
#ifdef EU07_USE_OLD_RENDERCODE
|
||||||
void Render( vector3 const &Position );
|
void Render( vector3 const &Position );
|
||||||
void RenderAlpha( vector3 const &Position );
|
void RenderAlpha( vector3 const &Position );
|
||||||
|
#endif
|
||||||
int Flags();
|
int Flags();
|
||||||
void RaAnglesSet(double a, double b, double c)
|
void RaAnglesSet(double a, double b, double c)
|
||||||
{
|
{
|
||||||
|
|||||||
20
DynObj.cpp
20
DynObj.cpp
@@ -4064,7 +4064,7 @@ void TDynamicObject::LoadMMediaFile(std::string BaseDir, std::string TypeName,
|
|||||||
{
|
{
|
||||||
std::string nowheretexture = TextureTest(Global::asCurrentTexturePath + "nowhere"); // na razie prymitywnie
|
std::string nowheretexture = TextureTest(Global::asCurrentTexturePath + "nowhere"); // na razie prymitywnie
|
||||||
if( false == nowheretexture.empty() ) {
|
if( false == nowheretexture.empty() ) {
|
||||||
m_materialdata.replacable_skins[ 4 ] = GfxRenderer.GetTextureId( nowheretexture, "", 9 );
|
m_materialdata.replacable_skins[ 4 ] = GfxRenderer.Fetch_Texture( nowheretexture, "", 9 );
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m_materialdata.multi_textures > 0) {
|
if (m_materialdata.multi_textures > 0) {
|
||||||
@@ -4076,7 +4076,7 @@ void TDynamicObject::LoadMMediaFile(std::string BaseDir, std::string TypeName,
|
|||||||
int skinindex = 0;
|
int skinindex = 0;
|
||||||
std::string texturename; nameparser >> texturename;
|
std::string texturename; nameparser >> texturename;
|
||||||
while( ( texturename != "" ) && ( skinindex < 4 ) ) {
|
while( ( texturename != "" ) && ( skinindex < 4 ) ) {
|
||||||
m_materialdata.replacable_skins[ skinindex + 1 ] = GfxRenderer.GetTextureId( Global::asCurrentTexturePath + texturename, "" );
|
m_materialdata.replacable_skins[ skinindex + 1 ] = GfxRenderer.Fetch_Texture( Global::asCurrentTexturePath + texturename, "" );
|
||||||
++skinindex;
|
++skinindex;
|
||||||
texturename = ""; nameparser >> texturename;
|
texturename = ""; nameparser >> texturename;
|
||||||
}
|
}
|
||||||
@@ -4086,7 +4086,7 @@ void TDynamicObject::LoadMMediaFile(std::string BaseDir, std::string TypeName,
|
|||||||
// otherwise try the basic approach
|
// otherwise try the basic approach
|
||||||
int skinindex = 0;
|
int skinindex = 0;
|
||||||
do {
|
do {
|
||||||
texture_handle texture = GfxRenderer.GetTextureId( Global::asCurrentTexturePath + ReplacableSkin + "," + std::to_string( skinindex + 1 ), "", Global::iDynamicFiltering, true );
|
texture_handle texture = GfxRenderer.Fetch_Texture( Global::asCurrentTexturePath + ReplacableSkin + "," + std::to_string( skinindex + 1 ), "", Global::iDynamicFiltering, true );
|
||||||
if( texture == NULL ) {
|
if( texture == NULL ) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -4096,12 +4096,12 @@ void TDynamicObject::LoadMMediaFile(std::string BaseDir, std::string TypeName,
|
|||||||
m_materialdata.multi_textures = skinindex;
|
m_materialdata.multi_textures = skinindex;
|
||||||
if( m_materialdata.multi_textures == 0 ) {
|
if( m_materialdata.multi_textures == 0 ) {
|
||||||
// zestaw nie zadziałał, próbujemy normanie
|
// zestaw nie zadziałał, próbujemy normanie
|
||||||
m_materialdata.replacable_skins[ 1 ] = GfxRenderer.GetTextureId( Global::asCurrentTexturePath + ReplacableSkin, "", Global::iDynamicFiltering );
|
m_materialdata.replacable_skins[ 1 ] = GfxRenderer.Fetch_Texture( Global::asCurrentTexturePath + ReplacableSkin, "", Global::iDynamicFiltering );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
m_materialdata.replacable_skins[ 1 ] = GfxRenderer.GetTextureId( Global::asCurrentTexturePath + ReplacableSkin, "", Global::iDynamicFiltering );
|
m_materialdata.replacable_skins[ 1 ] = GfxRenderer.Fetch_Texture( Global::asCurrentTexturePath + ReplacableSkin, "", Global::iDynamicFiltering );
|
||||||
}
|
}
|
||||||
if( GfxRenderer.Texture( m_materialdata.replacable_skins[ 1 ] ).has_alpha ) {
|
if( GfxRenderer.Texture( m_materialdata.replacable_skins[ 1 ] ).has_alpha ) {
|
||||||
// tekstura -1 z kanałem alfa - nie renderować w cyklu nieprzezroczystych
|
// tekstura -1 z kanałem alfa - nie renderować w cyklu nieprzezroczystych
|
||||||
@@ -5424,13 +5424,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())
|
||||||
{
|
{
|
||||||
m_materialdata.replacable_skins[ 4 ] = GfxRenderer.GetTextureId( x, "", 9 ); // rozmywania 0,1,4,5 nie nadają się
|
m_materialdata.replacable_skins[ 4 ] = GfxRenderer.Fetch_Texture( 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())
|
||||||
{
|
{
|
||||||
m_materialdata.replacable_skins[ 4 ] = GfxRenderer.GetTextureId( x, "", 9 ); // rozmywania 0,1,4,5 nie nadają się
|
m_materialdata.replacable_skins[ 4 ] = GfxRenderer.Fetch_Texture( x, "", 9 ); // rozmywania 0,1,4,5 nie nadają się
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (to.empty())
|
if (to.empty())
|
||||||
@@ -5438,17 +5438,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())
|
||||||
{
|
{
|
||||||
m_materialdata.replacable_skins[ 4 ] = GfxRenderer.GetTextureId( x, "", 9 ); // rozmywania 0,1,4,5 nie nadają się
|
m_materialdata.replacable_skins[ 4 ] = GfxRenderer.Fetch_Texture( 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())
|
||||||
m_materialdata.replacable_skins[ 4 ] = GfxRenderer.GetTextureId( x, "", 9 ); // rozmywania 0,1,4,5 nie nadają się
|
m_materialdata.replacable_skins[ 4 ] = GfxRenderer.Fetch_Texture( 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())
|
||||||
m_materialdata.replacable_skins[ 4 ] = GfxRenderer.GetTextureId( x, "", 9 );
|
m_materialdata.replacable_skins[ 4 ] = GfxRenderer.Fetch_Texture( x, "", 9 );
|
||||||
}
|
}
|
||||||
// Ra 2015-01: żeby zalogować błąd, trzeba by mieć pewność, że model używa tekstury nr 4
|
// Ra 2015-01: żeby zalogować błąd, trzeba by mieć pewność, że model używa tekstury nr 4
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -53,9 +53,8 @@ std::string LogComment;
|
|||||||
bool
|
bool
|
||||||
degenerate( glm::dvec3 const &Vertex1, glm::dvec3 const &Vertex2, glm::dvec3 const &Vertex3 ) {
|
degenerate( glm::dvec3 const &Vertex1, glm::dvec3 const &Vertex2, glm::dvec3 const &Vertex3 ) {
|
||||||
|
|
||||||
return ( ( Vertex1 == Vertex2 )
|
// degenerate( A, B, C, minarea ) = ( ( B - A ).cross( C - A ) ).lengthSquared() < ( 4.0f * minarea * minarea );
|
||||||
|| ( Vertex2 == Vertex3 )
|
return glm::length2( glm::cross( Vertex2 - Vertex1, Vertex3 - Vertex1 ) ) < std::numeric_limits<double>::epsilon();
|
||||||
|| ( Vertex3 == Vertex1 ) );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------
|
//---------------------------------------------------------------------------
|
||||||
@@ -1330,7 +1329,7 @@ TGroundNode * TGround::AddGroundNode(cParser *parser)
|
|||||||
*parser >> token;
|
*parser >> token;
|
||||||
}
|
}
|
||||||
str = token;
|
str = token;
|
||||||
tmp->TextureID = GfxRenderer.GetTextureId( str, szTexturePath );
|
tmp->TextureID = GfxRenderer.Fetch_Texture( str );
|
||||||
bool const clamps = (
|
bool const clamps = (
|
||||||
tmp->TextureID ?
|
tmp->TextureID ?
|
||||||
GfxRenderer.Texture( tmp->TextureID ).traits.find( 's' ) != std::string::npos :
|
GfxRenderer.Texture( tmp->TextureID ).traits.find( 's' ) != std::string::npos :
|
||||||
|
|||||||
@@ -341,7 +341,7 @@ int TSubModel::Load( cParser &parser, TModel3d *Model, /*int Pos,*/ bool dynamic
|
|||||||
if( texture.find_first_of( "/\\" ) == texture.npos ) {
|
if( texture.find_first_of( "/\\" ) == texture.npos ) {
|
||||||
texture.insert( 0, Global::asCurrentTexturePath );
|
texture.insert( 0, Global::asCurrentTexturePath );
|
||||||
}
|
}
|
||||||
TextureID = GfxRenderer.GetTextureId( texture, szTexturePath );
|
TextureID = GfxRenderer.Fetch_Texture( texture );
|
||||||
// renderowanie w cyklu przezroczystych tylko jeśli:
|
// renderowanie w cyklu przezroczystych tylko jeśli:
|
||||||
// 1. Opacity=0 (przejściowo <1, czy tam <100) oraz
|
// 1. Opacity=0 (przejściowo <1, czy tam <100) oraz
|
||||||
// 2. tekstura ma przezroczystość
|
// 2. tekstura ma przezroczystość
|
||||||
@@ -1670,7 +1670,7 @@ void TSubModel::BinInit(TSubModel *s, float4x4 *m, std::vector<std::string> *t,
|
|||||||
pTexture = t->at(iTexture);
|
pTexture = t->at(iTexture);
|
||||||
if (pTexture.find_last_of("/\\") == std::string::npos)
|
if (pTexture.find_last_of("/\\") == std::string::npos)
|
||||||
pTexture.insert(0, Global::asCurrentTexturePath);
|
pTexture.insert(0, Global::asCurrentTexturePath);
|
||||||
TextureID = GfxRenderer.GetTextureId(pTexture, szTexturePath);
|
TextureID = GfxRenderer.Fetch_Texture(pTexture);
|
||||||
if( ( iFlags & 0x30 ) == 0 ) {
|
if( ( iFlags & 0x30 ) == 0 ) {
|
||||||
// texture-alpha based fallback if for some reason we don't have opacity flag set yet
|
// texture-alpha based fallback if for some reason we don't have opacity flag set yet
|
||||||
iFlags |=
|
iFlags |=
|
||||||
|
|||||||
32
Track.cpp
32
Track.cpp
@@ -483,20 +483,20 @@ void TTrack::Load(cParser *parser, vector3 pOrigin, std::string name)
|
|||||||
{
|
{
|
||||||
parser->getTokens();
|
parser->getTokens();
|
||||||
*parser >> str; // railtex
|
*parser >> str; // railtex
|
||||||
TextureID1 = (str == "none" ? 0 : GfxRenderer.GetTextureId(
|
TextureID1 = (
|
||||||
str, szTexturePath,
|
str == "none" ?
|
||||||
(iCategoryFlag & 1) ? Global::iRailProFiltering :
|
NULL :
|
||||||
Global::iBallastFiltering));
|
GfxRenderer.Fetch_Texture( str ) );
|
||||||
parser->getTokens();
|
parser->getTokens();
|
||||||
*parser >> fTexLength; // tex tile length
|
*parser >> fTexLength; // tex tile length
|
||||||
if (fTexLength < 0.01)
|
if (fTexLength < 0.01)
|
||||||
fTexLength = 4; // Ra: zabezpiecznie przed zawieszeniem
|
fTexLength = 4; // Ra: zabezpiecznie przed zawieszeniem
|
||||||
parser->getTokens();
|
parser->getTokens();
|
||||||
*parser >> str; // sub || railtex
|
*parser >> str; // sub || railtex
|
||||||
TextureID2 = (str == "none" ? 0 : GfxRenderer.GetTextureId(
|
TextureID2 = (
|
||||||
str, szTexturePath,
|
str == "none" ?
|
||||||
(eType == tt_Normal) ? Global::iBallastFiltering :
|
NULL :
|
||||||
Global::iRailProFiltering));
|
GfxRenderer.Fetch_Texture( str ) );
|
||||||
parser->getTokens(3);
|
parser->getTokens(3);
|
||||||
*parser >> fTexHeight1 >> fTexWidth >> fTexSlope;
|
*parser >> fTexHeight1 >> fTexWidth >> fTexSlope;
|
||||||
if (iCategoryFlag & 4)
|
if (iCategoryFlag & 4)
|
||||||
@@ -1866,22 +1866,6 @@ void TTrack::EnvironmentReset()
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
void TTrack::RenderDyn()
|
|
||||||
{ // renderowanie nieprzezroczystych fragmentów pojazdów
|
|
||||||
for( auto dynamic : Dynamics ) {
|
|
||||||
// sam sprawdza, czy VBO; zmienia kontekst VBO!
|
|
||||||
GfxRenderer.Render( dynamic );
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
void TTrack::RenderDynAlpha()
|
|
||||||
{ // renderowanie przezroczystych fragmentów pojazdów
|
|
||||||
for( auto dynamic : Dynamics ) {
|
|
||||||
// sam sprawdza, czy VBO; zmienia kontekst VBO!
|
|
||||||
GfxRenderer.Render_Alpha( dynamic );
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
void TTrack::RenderDynSounds()
|
void TTrack::RenderDynSounds()
|
||||||
{ // odtwarzanie dźwięków pojazdów jest niezależne od ich wyświetlania
|
{ // odtwarzanie dźwięków pojazdów jest niezależne od ich wyświetlania
|
||||||
for( auto dynamic : Dynamics ) {
|
for( auto dynamic : Dynamics ) {
|
||||||
|
|||||||
2
Track.h
2
Track.h
@@ -236,8 +236,6 @@ public:
|
|||||||
/*
|
/*
|
||||||
void RaRenderVBO(int iPtr); // renderowanie z VBO sektora
|
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 RenderDynSounds(); // odtwarzanie dźwięków pojazdów jest niezależne od ich wyświetlania
|
||||||
|
|
||||||
void RaOwnerSet(TSubRect *o) {
|
void RaOwnerSet(TSubRect *o) {
|
||||||
|
|||||||
163
renderer.cpp
163
renderer.cpp
@@ -190,9 +190,9 @@ opengl_renderer::Init( GLFWwindow *Window ) {
|
|||||||
::glPixelStorei( GL_UNPACK_ALIGNMENT, 1 );
|
::glPixelStorei( GL_UNPACK_ALIGNMENT, 1 );
|
||||||
// preload some common textures
|
// preload some common textures
|
||||||
WriteLog( "Loading common gfx data..." );
|
WriteLog( "Loading common gfx data..." );
|
||||||
m_glaretexture = GetTextureId( "fx\\lightglare", szTexturePath );
|
m_glaretexture = Fetch_Texture( "fx\\lightglare" );
|
||||||
m_suntexture = GetTextureId( "fx\\sun", szTexturePath );
|
m_suntexture = Fetch_Texture( "fx\\sun" );
|
||||||
m_moontexture = GetTextureId( "fx\\moon", szTexturePath );
|
m_moontexture = Fetch_Texture( "fx\\moon" );
|
||||||
WriteLog( "...gfx data pre-loading done" );
|
WriteLog( "...gfx data pre-loading done" );
|
||||||
// prepare basic geometry chunks
|
// prepare basic geometry chunks
|
||||||
auto const geometrybank = m_geometry.create_bank();
|
auto const geometrybank = m_geometry.create_bank();
|
||||||
@@ -236,15 +236,27 @@ opengl_renderer::Render_pass( rendermode const Mode ) {
|
|||||||
|
|
||||||
case rendermode::color: {
|
case rendermode::color: {
|
||||||
|
|
||||||
// TODO: run shadowmap pass before color
|
if( Global::RenderShadows && World.InitPerformed() ) {
|
||||||
|
// run shadowmap pass before color
|
||||||
|
::glBindFramebufferEXT( GL_FRAMEBUFFER_EXT, m_shadowframebuffer );
|
||||||
|
::glDrawBuffer( GL_NONE ); // we won't be rendering colour data, so can skip the colour attachment
|
||||||
|
|
||||||
|
Render_pass( rendermode::shadows );
|
||||||
|
m_renderpass.draw_mode = rendermode::color; // restore draw mode. TODO: render mode stack
|
||||||
|
|
||||||
|
::glBindFramebufferEXT( GL_FRAMEBUFFER_EXT, 0 ); // switch back to primary render target
|
||||||
|
::glDrawBuffer( GL_BACK );
|
||||||
|
}
|
||||||
|
|
||||||
#ifdef EU07_USE_PICKING_FRAMEBUFFER
|
|
||||||
::glViewport( 0, 0, Global::ScreenWidth, Global::ScreenHeight );
|
::glViewport( 0, 0, Global::ScreenWidth, Global::ScreenHeight );
|
||||||
#endif
|
|
||||||
if( World.InitPerformed() ) {
|
if( World.InitPerformed() ) {
|
||||||
auto const skydomecolour = World.Environment.m_skydome.GetAverageColor();
|
auto const skydomecolour = World.Environment.m_skydome.GetAverageColor();
|
||||||
::glClearColor( skydomecolour.x, skydomecolour.y, skydomecolour.z, 0.0f ); // kolor nieba
|
::glClearColor( skydomecolour.x, skydomecolour.y, skydomecolour.z, 0.0f ); // kolor nieba
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
::glClearColor( 51.0f / 255.0f, 102.0f / 255.0f, 85.0f / 255.0f, 1.0f ); // initial background Color
|
||||||
|
}
|
||||||
::glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );
|
::glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );
|
||||||
|
|
||||||
if( World.InitPerformed() ) {
|
if( World.InitPerformed() ) {
|
||||||
@@ -271,15 +283,14 @@ opengl_renderer::Render_pass( rendermode const Mode ) {
|
|||||||
|
|
||||||
case rendermode::shadows: {
|
case rendermode::shadows: {
|
||||||
|
|
||||||
#ifdef EU07_USE_PICKING_FRAMEBUFFER
|
::glViewport( 0, 0, m_shadowbuffersize, m_shadowbuffersize );
|
||||||
::glViewport( 0, 0, m_pickbuffersize, m_pickbuffersize ); // TODO: separate shadow buffer
|
|
||||||
#endif
|
|
||||||
::glClearColor( 0.0f, 0.0f, 0.0f, 0.0f );
|
::glClearColor( 0.0f, 0.0f, 0.0f, 0.0f );
|
||||||
::glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );
|
::glClear( GL_DEPTH_BUFFER_BIT );
|
||||||
|
|
||||||
if( World.InitPerformed() ) {
|
if( World.InitPerformed() ) {
|
||||||
// setup
|
// setup
|
||||||
m_renderpass.draw_range = 500.0f; // 1.5km square centered around camera
|
m_renderpass.draw_range = 500.0f; // 1.0km square centered around camera
|
||||||
Render_projection();
|
Render_projection();
|
||||||
Render_camera();
|
Render_camera();
|
||||||
::glDepthFunc( GL_LEQUAL );
|
::glDepthFunc( GL_LEQUAL );
|
||||||
@@ -355,9 +366,11 @@ opengl_renderer::Render_projection() {
|
|||||||
|
|
||||||
switch( m_renderpass.draw_mode ) {
|
switch( m_renderpass.draw_mode ) {
|
||||||
|
|
||||||
case rendermode::color:
|
#ifndef EU07_USE_PICKING_FRAMEBUFFER
|
||||||
case rendermode::pickcontrols:
|
case rendermode::pickcontrols:
|
||||||
case rendermode::pickscenery: {
|
case rendermode::pickscenery:
|
||||||
|
#endif
|
||||||
|
case rendermode::color: {
|
||||||
::gluPerspective(
|
::gluPerspective(
|
||||||
Global::FieldOfView / Global::ZoomFactor,
|
Global::FieldOfView / Global::ZoomFactor,
|
||||||
std::max( 1.0f, (float)Global::ScreenWidth ) / std::max( 1.0f, (float)Global::ScreenHeight ),
|
std::max( 1.0f, (float)Global::ScreenWidth ) / std::max( 1.0f, (float)Global::ScreenHeight ),
|
||||||
@@ -365,19 +378,20 @@ opengl_renderer::Render_projection() {
|
|||||||
m_renderpass.draw_range * Global::fDistanceFactor );
|
m_renderpass.draw_range * Global::fDistanceFactor );
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
/*
|
#ifdef EU07_USE_PICKING_FRAMEBUFFER
|
||||||
// version for the smaller pickbuffer. ultimately scratched because resolution isn't comfortable/reliable enough for the user
|
|
||||||
case rendermode::pickcontrols:
|
case rendermode::pickcontrols:
|
||||||
case rendermode::pickscenery: {
|
case rendermode::pickscenery: {
|
||||||
// TODO: render to buffer and scissor test for pick modes
|
// TODO: scissor test for pick modes
|
||||||
|
auto const angle = Global::FieldOfView / Global::ZoomFactor;
|
||||||
|
auto const height = std::max( 1.0f, (float)Global::ScreenWidth ) / std::max( 1.0f, (float)Global::ScreenHeight ) / ( Global::ScreenWidth / m_pickbuffersize );
|
||||||
::gluPerspective(
|
::gluPerspective(
|
||||||
Global::FieldOfView / Global::ZoomFactor,
|
Global::FieldOfView / Global::ZoomFactor,
|
||||||
std::max( 1.0f, (float)Global::ScreenWidth ) / std::max( 1.0f, (float)Global::ScreenHeight ) / ( Global::ScreenWidth / 1024.0f ),
|
std::max( 1.0f, (float)Global::ScreenWidth ) / std::max( 1.0f, (float)Global::ScreenHeight ) / ( Global::ScreenWidth / m_pickbuffersize ),
|
||||||
0.1f * Global::ZoomFactor,
|
0.1f * Global::ZoomFactor,
|
||||||
m_renderpass.draw_range * Global::fDistanceFactor );
|
m_renderpass.draw_range * Global::fDistanceFactor );
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
*/
|
#endif
|
||||||
case rendermode::shadows: {
|
case rendermode::shadows: {
|
||||||
// TODO: set parallel projection
|
// TODO: set parallel projection
|
||||||
::gluPerspective(
|
::gluPerspective(
|
||||||
@@ -447,6 +461,9 @@ opengl_renderer::Render_setup( bool const Alpha ) {
|
|||||||
case rendermode::color: {
|
case rendermode::color: {
|
||||||
::glEnable( GL_LIGHTING );
|
::glEnable( GL_LIGHTING );
|
||||||
::glShadeModel( GL_SMOOTH );
|
::glShadeModel( GL_SMOOTH );
|
||||||
|
if( Global::iMultisampling ) {
|
||||||
|
::glEnable( GL_MULTISAMPLE );
|
||||||
|
}
|
||||||
// setup fog
|
// setup fog
|
||||||
if( Global::fFogEnd > 0 ) {
|
if( Global::fFogEnd > 0 ) {
|
||||||
// fog setup
|
// fog setup
|
||||||
@@ -474,9 +491,12 @@ opengl_renderer::Render_setup( bool const Alpha ) {
|
|||||||
case rendermode::shadows:
|
case rendermode::shadows:
|
||||||
case rendermode::pickcontrols:
|
case rendermode::pickcontrols:
|
||||||
case rendermode::pickscenery: {
|
case rendermode::pickscenery: {
|
||||||
::glDisable( GL_FOG );
|
|
||||||
::glDisable( GL_LIGHTING );
|
::glDisable( GL_LIGHTING );
|
||||||
::glShadeModel( GL_FLAT );
|
::glShadeModel( GL_FLAT );
|
||||||
|
if( Global::iMultisampling ) {
|
||||||
|
::glDisable( GL_MULTISAMPLE );
|
||||||
|
}
|
||||||
|
::glDisable( GL_FOG );
|
||||||
|
|
||||||
if( m_texenvmode != m_renderpass.draw_mode ) {
|
if( m_texenvmode != m_renderpass.draw_mode ) {
|
||||||
// solid colour with texture alpha
|
// solid colour with texture alpha
|
||||||
@@ -508,19 +528,32 @@ opengl_renderer::Render( world_environment *Environment ) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Bind( NULL );
|
Bind( NULL );
|
||||||
|
|
||||||
::glDisable( GL_LIGHTING );
|
::glDisable( GL_LIGHTING );
|
||||||
::glDisable( GL_DEPTH_TEST );
|
::glDisable( GL_DEPTH_TEST );
|
||||||
::glDepthMask( GL_FALSE );
|
::glDepthMask( GL_FALSE );
|
||||||
::glPushMatrix();
|
::glPushMatrix();
|
||||||
|
|
||||||
|
// skydome
|
||||||
Environment->m_skydome.Render();
|
Environment->m_skydome.Render();
|
||||||
if( true == Global::bUseVBO ) {
|
if( true == Global::bUseVBO ) {
|
||||||
// skydome uses a custom vbo which could potentially confuse the main geometry system. hardly elegant but, eh
|
// skydome uses a custom vbo which could potentially confuse the main geometry system. hardly elegant but, eh
|
||||||
opengl_vbogeometrybank::reset();
|
opengl_vbogeometrybank::reset();
|
||||||
}
|
}
|
||||||
Environment->m_stars.render();
|
// 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
|
||||||
float const duskfactor = 1.0f - clamp( std::abs( Environment->m_sun.getAngle() ), 0.0f, 12.0f ) / 12.0f;
|
float const duskfactor = 1.0f - clamp( std::abs( Environment->m_sun.getAngle() ), 0.0f, 12.0f ) / 12.0f;
|
||||||
glm::vec3 suncolor = interpolate(
|
glm::vec3 suncolor = interpolate(
|
||||||
glm::vec3( 255.0f / 255.0f, 242.0f / 255.0f, 231.0f / 255.0f ),
|
glm::vec3( 255.0f / 255.0f, 242.0f / 255.0f, 231.0f / 255.0f ),
|
||||||
@@ -601,10 +634,26 @@ opengl_renderer::Render( world_environment *Environment ) {
|
|||||||
::glPopAttrib();
|
::glPopAttrib();
|
||||||
|
|
||||||
// clouds
|
// clouds
|
||||||
Environment->m_clouds.Render(
|
if( Environment->m_clouds.mdCloud ) {
|
||||||
|
// setup
|
||||||
|
Disable_Lights();
|
||||||
|
::glEnable( GL_LIGHTING );
|
||||||
|
::glLightModelfv(
|
||||||
|
GL_LIGHT_MODEL_AMBIENT,
|
||||||
|
glm::value_ptr(
|
||||||
interpolate( Environment->m_skydome.GetAverageColor(), suncolor, duskfactor * 0.25f )
|
interpolate( Environment->m_skydome.GetAverageColor(), suncolor, duskfactor * 0.25f )
|
||||||
* ( 1.0f - Global::Overcast * 0.5f ) // overcast darkens the clouds
|
* ( 1.0f - Global::Overcast * 0.5f ) // overcast darkens the clouds
|
||||||
* 2.5f ); // arbitrary adjustment factor
|
* 2.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
|
||||||
|
GLfloat noambient[] = { 0.0f, 0.0f, 0.0f, 1.0f };
|
||||||
|
::glLightModelfv( GL_LIGHT_MODEL_AMBIENT, noambient );
|
||||||
|
::glEnable( GL_LIGHT0 ); // other lights will be enabled during lights update
|
||||||
|
::glDisable( GL_LIGHTING );
|
||||||
|
}
|
||||||
|
|
||||||
Global::DayLight.apply_angle();
|
Global::DayLight.apply_angle();
|
||||||
Global::DayLight.apply_intensity();
|
Global::DayLight.apply_intensity();
|
||||||
@@ -655,7 +704,7 @@ opengl_renderer::Vertices( geometry_handle const &Geometry ) const {
|
|||||||
|
|
||||||
// texture methods
|
// texture methods
|
||||||
texture_handle
|
texture_handle
|
||||||
opengl_renderer::GetTextureId( std::string Filename, std::string const &Dir, int const Filter, bool const Loadnow ) {
|
opengl_renderer::Fetch_Texture( std::string const &Filename, std::string const &Dir, int const Filter, bool const Loadnow ) {
|
||||||
|
|
||||||
return m_textures.create( Filename, Dir, Filter, Loadnow );
|
return m_textures.create( Filename, Dir, Filter, Loadnow );
|
||||||
}
|
}
|
||||||
@@ -854,7 +903,7 @@ opengl_renderer::Render( TSubRect *Groundsubcell ) {
|
|||||||
#ifdef EU07_SCENERY_EDITOR
|
#ifdef EU07_SCENERY_EDITOR
|
||||||
// memcells
|
// memcells
|
||||||
if( EditorModeFlag ) {
|
if( EditorModeFlag ) {
|
||||||
for( auto const memcell : m_memcells ) {
|
for( auto const memcell : Groundsubcell->m_memcells ) {
|
||||||
Render( memcell );
|
Render( memcell );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -888,7 +937,7 @@ opengl_renderer::Render( TSubRect *Groundsubcell ) {
|
|||||||
#ifdef EU07_SCENERY_EDITOR
|
#ifdef EU07_SCENERY_EDITOR
|
||||||
// memcells
|
// memcells
|
||||||
if( EditorModeFlag ) {
|
if( EditorModeFlag ) {
|
||||||
for( auto const memcell : m_memcells ) {
|
for( auto const memcell : Groundsubcell->m_memcells ) {
|
||||||
::glColor3fv( glm::value_ptr( pick_color( m_picksceneryitems.size() + 1 ) ) );
|
::glColor3fv( glm::value_ptr( pick_color( m_picksceneryitems.size() + 1 ) ) );
|
||||||
Render( memcell );
|
Render( memcell );
|
||||||
}
|
}
|
||||||
@@ -961,7 +1010,14 @@ opengl_renderer::Render( TGroundNode *Node ) {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#ifdef EU07_USE_OLD_RENDERCODE
|
||||||
Node->Model->Render( Node->pCenter - m_renderpass.camera.position() );
|
Node->Model->Render( Node->pCenter - m_renderpass.camera.position() );
|
||||||
|
#else
|
||||||
|
Node->Model->RaAnimate(); // jednorazowe przeliczenie animacji
|
||||||
|
Node->Model->RaPrepare();
|
||||||
|
if( Node->Model->pModel ) // renderowanie rekurencyjne submodeli
|
||||||
|
Render( Node->Model->pModel, Node->Model->Material(), Node->pCenter - m_renderpass.camera.position(), Node->Model->vAngle );
|
||||||
|
#endif
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1559,19 +1615,35 @@ opengl_renderer::Render( TTrack *Track ) {
|
|||||||
void
|
void
|
||||||
opengl_renderer::Render( TMemCell *Memcell ) {
|
opengl_renderer::Render( TMemCell *Memcell ) {
|
||||||
|
|
||||||
::glPushAttrib( GL_ENABLE_BIT );
|
|
||||||
// ::glDisable( GL_LIGHTING );
|
|
||||||
::glDisable( GL_TEXTURE_2D );
|
|
||||||
// ::glEnable( GL_BLEND );
|
|
||||||
::glPushMatrix();
|
::glPushMatrix();
|
||||||
|
auto const position = Memcell->Position() - m_renderpass.camera.position();
|
||||||
auto const position = Memcell->Position();
|
|
||||||
::glTranslated( position.x, position.y + 0.5, position.z );
|
::glTranslated( position.x, position.y + 0.5, position.z );
|
||||||
|
|
||||||
|
switch( m_renderpass.draw_mode ) {
|
||||||
|
case rendermode::color: {
|
||||||
|
::glPushAttrib( GL_ENABLE_BIT );
|
||||||
|
::glDisable( GL_TEXTURE_2D );
|
||||||
::glColor3f( 0.36f, 0.75f, 0.35f );
|
::glColor3f( 0.36f, 0.75f, 0.35f );
|
||||||
|
|
||||||
::gluSphere( m_quadric, 0.35, 4, 2 );
|
::gluSphere( m_quadric, 0.35, 4, 2 );
|
||||||
|
|
||||||
::glPopMatrix();
|
|
||||||
::glPopAttrib();
|
::glPopAttrib();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case rendermode::pickscenery:
|
||||||
|
case rendermode::shadows: {
|
||||||
|
::gluSphere( m_quadric, 0.35, 4, 2 );
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case rendermode::pickcontrols: {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
default: {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
::glPopMatrix();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
@@ -1615,8 +1687,11 @@ opengl_renderer::Render_Alpha( TSubRect *Groundsubcell ) {
|
|||||||
Render_Alpha( node ); // przezroczyste z mieszanych modeli
|
Render_Alpha( node ); // przezroczyste z mieszanych modeli
|
||||||
for( node = Groundsubcell->nRenderAlpha; node; node = node->nNext3 )
|
for( node = Groundsubcell->nRenderAlpha; node; node = node->nNext3 )
|
||||||
Render_Alpha( node ); // przezroczyste modele
|
Render_Alpha( node ); // przezroczyste modele
|
||||||
for( int j = 0; j < Groundsubcell->iTracks; ++j )
|
for( int trackidx = 0; trackidx < Groundsubcell->iTracks; ++trackidx ) {
|
||||||
Groundsubcell->tTracks[ j ]->RenderDynAlpha(); // przezroczyste fragmenty pojazdów na torach
|
for( auto dynamic : Groundsubcell->tTracks[ trackidx ]->Dynamics ) {
|
||||||
|
Render_Alpha( dynamic ); // przezroczyste fragmenty pojazdów na torach
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -1677,7 +1752,13 @@ opengl_renderer::Render_Alpha( TGroundNode *Node ) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
case TP_MODEL: {
|
case TP_MODEL: {
|
||||||
|
#ifdef EU07_USE_OLD_RENDERCODE
|
||||||
Node->Model->RenderAlpha( Node->pCenter - m_renderpass.camera.position() );
|
Node->Model->RenderAlpha( Node->pCenter - m_renderpass.camera.position() );
|
||||||
|
#else
|
||||||
|
Node->Model->RaPrepare();
|
||||||
|
if( Node->Model->pModel ) // renderowanie rekurencyjne submodeli
|
||||||
|
Render_Alpha( Node->Model->pModel, Node->Model->Material(), Node->pCenter - m_renderpass.camera.position(), Node->Model->vAngle );
|
||||||
|
#endif
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2137,15 +2218,11 @@ opengl_renderer::Update( double const Deltatime ) {
|
|||||||
// adjust draw ranges etc, based on recent performance
|
// adjust draw ranges etc, based on recent performance
|
||||||
auto const framerate = 1000.0f / (m_drawtime / 20.0f);
|
auto const framerate = 1000.0f / (m_drawtime / 20.0f);
|
||||||
|
|
||||||
// NOTE: until we have quadtree in place we have to rely on the legacy rendering
|
|
||||||
// once this is resolved we should be able to simply adjust draw range
|
|
||||||
int targetsegments;
|
|
||||||
float targetfactor;
|
float targetfactor;
|
||||||
|
if( framerate > 90.0 ) { targetfactor = 3.0f; }
|
||||||
if( framerate > 90.0 ) { targetsegments = 400; targetfactor = 3.0f; }
|
else if( framerate > 60.0 ) { targetfactor = 1.5f; }
|
||||||
else if( framerate > 60.0 ) { targetsegments = 225; targetfactor = 1.5f; }
|
else if( framerate > 30.0 ) { targetfactor = Global::ScreenHeight / 768.0f; }
|
||||||
else if( framerate > 30.0 ) { targetsegments = 90; targetfactor = Global::ScreenHeight / 768.0f; }
|
else { targetfactor = Global::ScreenHeight / 768.0f * 0.75f; }
|
||||||
else { targetsegments = 9; targetfactor = Global::ScreenHeight / 768.0f * 0.75f; }
|
|
||||||
|
|
||||||
if( targetfactor > Global::fDistanceFactor ) {
|
if( targetfactor > Global::fDistanceFactor ) {
|
||||||
|
|
||||||
|
|||||||
32
renderer.h
32
renderer.h
@@ -119,21 +119,6 @@ public:
|
|||||||
// main draw call. returns false on error
|
// main draw call. returns false on error
|
||||||
bool
|
bool
|
||||||
Render();
|
Render();
|
||||||
// render sub-methods, temporarily exposed until we complete migrating render code to the renderer
|
|
||||||
bool
|
|
||||||
Render( TDynamicObject *Dynamic );
|
|
||||||
bool
|
|
||||||
Render( TModel3d *Model, material_data const *Material, Math3D::vector3 const &Position, Math3D::vector3 const &Angle );
|
|
||||||
bool
|
|
||||||
Render( TModel3d *Model, material_data const *Material, double const Squaredistance );
|
|
||||||
void
|
|
||||||
Render( TSubModel *Submodel );
|
|
||||||
bool
|
|
||||||
Render_Alpha( TDynamicObject *Dynamic );
|
|
||||||
bool
|
|
||||||
Render_Alpha( TModel3d *Model, material_data const *Material, Math3D::vector3 const &Position, Math3D::vector3 const &Angle );
|
|
||||||
bool
|
|
||||||
Render_Alpha( TModel3d *Model, material_data const *Material, double const Squaredistance );
|
|
||||||
// geometry methods
|
// 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
|
// 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
|
// creates a new geometry bank. returns: handle to the bank or NULL
|
||||||
@@ -153,7 +138,7 @@ public:
|
|||||||
Vertices( geometry_handle const &Geometry ) const;
|
Vertices( geometry_handle const &Geometry ) const;
|
||||||
// texture methods
|
// texture methods
|
||||||
texture_handle
|
texture_handle
|
||||||
GetTextureId( std::string Filename, std::string const &Dir, int const Filter = -1, bool const Loadnow = true );
|
Fetch_Texture( std::string const &Filename, std::string const &Dir = szTexturePath, int const Filter = -1, bool const Loadnow = true );
|
||||||
void
|
void
|
||||||
Bind( texture_handle const Texture );
|
Bind( texture_handle const Texture );
|
||||||
opengl_texture const &
|
opengl_texture const &
|
||||||
@@ -225,6 +210,14 @@ private:
|
|||||||
Render( TSubRect *Groundsubcell );
|
Render( TSubRect *Groundsubcell );
|
||||||
bool
|
bool
|
||||||
Render( TGroundNode *Node );
|
Render( TGroundNode *Node );
|
||||||
|
bool
|
||||||
|
Render( TDynamicObject *Dynamic );
|
||||||
|
bool
|
||||||
|
Render( TModel3d *Model, material_data const *Material, Math3D::vector3 const &Position, Math3D::vector3 const &Angle );
|
||||||
|
bool
|
||||||
|
Render( TModel3d *Model, material_data const *Material, double const Squaredistance );
|
||||||
|
void
|
||||||
|
Render( TSubModel *Submodel );
|
||||||
void
|
void
|
||||||
Render( TTrack *Track );
|
Render( TTrack *Track );
|
||||||
bool
|
bool
|
||||||
@@ -237,6 +230,12 @@ private:
|
|||||||
Render_Alpha( TSubRect *Groundsubcell );
|
Render_Alpha( TSubRect *Groundsubcell );
|
||||||
bool
|
bool
|
||||||
Render_Alpha( TGroundNode *Node );
|
Render_Alpha( TGroundNode *Node );
|
||||||
|
bool
|
||||||
|
Render_Alpha( TDynamicObject *Dynamic );
|
||||||
|
bool
|
||||||
|
Render_Alpha( TModel3d *Model, material_data const *Material, Math3D::vector3 const &Position, Math3D::vector3 const &Angle );
|
||||||
|
bool
|
||||||
|
Render_Alpha( TModel3d *Model, material_data const *Material, double const Squaredistance );
|
||||||
void
|
void
|
||||||
Render_Alpha( TSubModel *Submodel );
|
Render_Alpha( TSubModel *Submodel );
|
||||||
void
|
void
|
||||||
@@ -277,6 +276,7 @@ private:
|
|||||||
bool m_framebuffersupport { false };
|
bool m_framebuffersupport { false };
|
||||||
rendermode m_texenvmode { rendermode::color }; // last configured texture environment
|
rendermode m_texenvmode { rendermode::color }; // last configured texture environment
|
||||||
renderpass_config m_renderpass;
|
renderpass_config m_renderpass;
|
||||||
|
// std::stack<renderpass_config> m_renderpasses;
|
||||||
bool m_renderspecular { false }; // controls whether to include specular component in the calculations
|
bool m_renderspecular { false }; // controls whether to include specular component in the calculations
|
||||||
std::vector<TGroundNode const *> m_picksceneryitems;
|
std::vector<TGroundNode const *> m_picksceneryitems;
|
||||||
std::vector<TSubModel const *> m_pickcontrolsitems;
|
std::vector<TSubModel const *> m_pickcontrolsitems;
|
||||||
|
|||||||
15
sky.cpp
15
sky.cpp
@@ -9,24 +9,22 @@ http://mozilla.org/MPL/2.0/.
|
|||||||
|
|
||||||
#include "stdafx.h"
|
#include "stdafx.h"
|
||||||
#include "sky.h"
|
#include "sky.h"
|
||||||
#include "Logs.h"
|
|
||||||
#include "Globals.h"
|
#include "Globals.h"
|
||||||
#include "MdlMngr.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( "Clouds init" );
|
|
||||||
if ((Global::asSky != "1") && (Global::asSky != "0"))
|
|
||||||
mdCloud = TModelsManager::GetModel( Global::asSky );
|
mdCloud = TModelsManager::GetModel( Global::asSky );
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#ifdef EU07_USE_OLD_RENDERCODE
|
||||||
void TSky::Render( glm::vec3 const &Tint )
|
void TSky::Render( glm::vec3 const &Tint )
|
||||||
{
|
{
|
||||||
if (mdCloud)
|
if (mdCloud)
|
||||||
@@ -45,5 +43,6 @@ void TSky::Render( glm::vec3 const &Tint )
|
|||||||
::glDisable( GL_LIGHTING );
|
::glDisable( GL_LIGHTING );
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
#endif
|
||||||
|
|
||||||
//---------------------------------------------------------------------------
|
//---------------------------------------------------------------------------
|
||||||
|
|||||||
16
sky.h
16
sky.h
@@ -12,16 +12,18 @@ http://mozilla.org/MPL/2.0/.
|
|||||||
|
|
||||||
#include "Model3d.h"
|
#include "Model3d.h"
|
||||||
|
|
||||||
class TSky
|
class TSky {
|
||||||
{
|
|
||||||
private:
|
|
||||||
TModel3d *mdCloud;
|
|
||||||
|
|
||||||
public:
|
friend class opengl_renderer;
|
||||||
TSky();
|
|
||||||
~TSky();
|
private:
|
||||||
|
TModel3d *mdCloud { nullptr };
|
||||||
|
|
||||||
|
public:
|
||||||
void Init();
|
void Init();
|
||||||
|
#ifdef EU07_USE_OLD_RENDERCODE
|
||||||
void Render( glm::vec3 const &Tint = glm::vec3(1.0f, 1.0f, 1.0f) );
|
void Render( glm::vec3 const &Tint = glm::vec3(1.0f, 1.0f, 1.0f) );
|
||||||
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
//---------------------------------------------------------------------------
|
//---------------------------------------------------------------------------
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
#include "stdafx.h"
|
#include "stdafx.h"
|
||||||
#include "stars.h"
|
#include "stars.h"
|
||||||
#include "globals.h"
|
#include "globals.h"
|
||||||
|
#include "MdlMngr.h"
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////////////////////
|
||||||
// cStars -- simple starfield model, simulating appearance of starry sky
|
// cStars -- simple starfield model, simulating appearance of starry sky
|
||||||
@@ -9,9 +10,9 @@
|
|||||||
void
|
void
|
||||||
cStars::init() {
|
cStars::init() {
|
||||||
|
|
||||||
m_stars.LoadFromFile( "models\\skydome_stars.t3d", false );
|
m_stars = TModelsManager::GetModel( "models\\skydome_stars.t3d", false );
|
||||||
}
|
}
|
||||||
|
#ifdef EU07_USE_OLD_RENDERCODE
|
||||||
void
|
void
|
||||||
cStars::render() {
|
cStars::render() {
|
||||||
// setup
|
// setup
|
||||||
@@ -28,3 +29,4 @@ cStars::render() {
|
|||||||
|
|
||||||
::glPopMatrix();
|
::glPopMatrix();
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|||||||
7
stars.h
7
stars.h
@@ -8,13 +8,16 @@
|
|||||||
|
|
||||||
class cStars {
|
class cStars {
|
||||||
|
|
||||||
|
friend class opengl_renderer;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
// types:
|
// types:
|
||||||
|
|
||||||
// methods:
|
// methods:
|
||||||
void init();
|
void init();
|
||||||
|
#ifdef EU07_USE_OLD_RENDERCODE
|
||||||
void render();
|
void render();
|
||||||
|
#endif
|
||||||
// constructors:
|
// constructors:
|
||||||
|
|
||||||
// deconstructor:
|
// deconstructor:
|
||||||
@@ -29,5 +32,5 @@ private:
|
|||||||
// members:
|
// members:
|
||||||
float m_longitude{ 19.0f }; // geograpic coordinates hardcoded roughly to Poland location, for the time being
|
float m_longitude{ 19.0f }; // geograpic coordinates hardcoded roughly to Poland location, for the time being
|
||||||
float m_latitude{ 52.0f };
|
float m_latitude{ 52.0f };
|
||||||
TModel3d m_stars;
|
TModel3d *m_stars { nullptr };
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -96,7 +96,7 @@ void
|
|||||||
ui_layer::set_background( std::string const &Filename ) {
|
ui_layer::set_background( std::string const &Filename ) {
|
||||||
|
|
||||||
if( false == Filename.empty() ) {
|
if( false == Filename.empty() ) {
|
||||||
m_background = GfxRenderer.GetTextureId( Filename, szTexturePath );
|
m_background = GfxRenderer.Fetch_Texture( Filename );
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
m_background = NULL;
|
m_background = NULL;
|
||||||
|
|||||||
Reference in New Issue
Block a user