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

re-enabled vbo render path

This commit is contained in:
tmj-fstate
2017-03-20 17:17:17 +01:00
parent f10494fd6a
commit 4052bdea5c
10 changed files with 109 additions and 88 deletions

View File

@@ -708,21 +708,21 @@ void TAnimModel::RenderAlphaDL(vector3 *vPosition)
GfxRenderer.Render_Alpha( pModel, Material(), *vPosition, vAngle );
#endif
};
/*
void TAnimModel::RenderVBO(vector3 *vPosition)
{
RaAnimate(); // jednorazowe przeliczenie animacji
RaPrepare();
if (pModel) // renderowanie rekurencyjne submodeli
pModel->RaRender(vPosition, &vAngle, ReplacableSkinId, iTexAlpha);
pModel->RaRender(vPosition, &vAngle, Material()->replacable_skins, Material()->textures_alpha);
};
void TAnimModel::RenderAlphaVBO(vector3 *vPosition)
{
RaPrepare();
if (pModel) // renderowanie rekurencyjne submodeli
pModel->RaRenderAlpha(vPosition, &vAngle, ReplacableSkinId, iTexAlpha);
pModel->RaRenderAlpha(vPosition, &vAngle, Material()->replacable_skins, Material()->textures_alpha);
};
*/
//---------------------------------------------------------------------------
bool TAnimModel::TerrainLoaded()

View File

@@ -177,10 +177,8 @@ class TAnimModel
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)
{

View File

@@ -486,8 +486,6 @@ void Global::ConfigParse(cParser &Parser)
Parser.getTokens();
Parser >> Global::bUseVBO;
// NOTE: temporary override until render paths are sorted out
Global::bUseVBO = false;
}
else if (token == "feedbackmode")
{

View File

@@ -280,7 +280,7 @@ void TGroundNode::MoveMe(vector3 pPosition)
ResourceManager::Unregister(this);
}
}
/*
void TGroundNode::RaRenderVBO()
{ // renderowanie z domyslnego bufora VBO
glColor3ub(Diffuse[0], Diffuse[1], Diffuse[2]);
@@ -445,7 +445,7 @@ void TGroundNode::RenderAlphaVBO()
#endif
return;
}
*/
void TGroundNode::Compile(bool many)
{ // tworzenie skompilowanej listy w wyświetlaniu DL
if (!many)
@@ -1222,7 +1222,7 @@ void TSubRect::RenderAlphaDL()
for (int j = 0; j < iTracks; ++j)
tTracks[j]->RenderDynAlpha(); // przezroczyste fragmenty pojazdów na torach
};
/*
void TSubRect::RenderVBO()
{ // renderowanie nieprzezroczystych (VBO)
TGroundNode *node;
@@ -1256,7 +1256,7 @@ void TSubRect::RenderAlphaVBO()
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)
@@ -1355,7 +1355,7 @@ void TGroundRect::RenderDL()
glEnable( GL_LIGHTING );
*/
};
/*
void TGroundRect::RenderVBO()
{ // renderowanie kwadratu kilometrowego (VBO), jeśli jeszcze nie zrobione
if (iLastDisplay != iFrameNumber)
@@ -1372,7 +1372,7 @@ void TGroundRect::RenderVBO()
nTerrain->smTerrain->iVisible = iFrameNumber; // ma się wyświetlić w tej ramce
}
};
*/
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
@@ -4890,23 +4890,20 @@ bool
TGround::Render( Math3D::vector3 const &Camera ) {
GfxRenderer.Update_Lights( m_lights );
/*
if( Global::bUseVBO ) { // renderowanie przez VBO
if( !RenderVBO( Camera ) )
return false;
if( !RenderAlphaVBO( Camera ) )
return false;
if( !RenderVBO( Camera ) )
return false;
if( !RenderAlphaVBO( Camera ) )
return false;
}
else {
*/
// renderowanie przez Display List
if( !RenderDL( Camera ) )
return false;
if( !RenderAlphaDL( Camera ) )
return false;
/*
// renderowanie przez Display List
if( !RenderDL( Camera ) )
return false;
if( !RenderAlphaDL( Camera ) )
return false;
}
*/
return true;
}
@@ -4999,7 +4996,7 @@ bool TGround::RenderAlphaDL(vector3 pPosition)
}
return true;
}
/*
bool TGround::RenderVBO(vector3 pPosition)
{ // renderowanie scenerii z VBO - faza nieprzezroczystych
glDisable(GL_BLEND);
@@ -5102,7 +5099,7 @@ bool TGround::RenderAlphaVBO(vector3 pPosition)
}
return true;
};
*/
#ifdef _WINDOWS
//---------------------------------------------------------------------------
void TGround::Navigate(std::string const &ClassName, UINT Msg, WPARAM wParam, LPARAM lParam)

View File

@@ -178,11 +178,10 @@ class TGroundNode : public Resource
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
*/
};
struct bounding_area {
@@ -229,11 +228,9 @@ class TSubRect : public Resource, public CMesh
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
};
@@ -277,9 +274,7 @@ class TGroundRect : public TSubRect
pSubRects[i].Sort(); // optymalizacja obiektów w sektorach
};
void RenderDL();
/*
void RenderVBO();
*/
};
class TGround
@@ -368,10 +363,8 @@ class TGround
bool Render( Math3D::vector3 const &Camera );
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)]); };

View File

@@ -2185,8 +2185,8 @@ void TModel3d::RenderAlpha(double fSquareDistance, texture_manager::size_type *R
Root->RenderAlphaDL();
}
};
void TModel3d::RaRender(double fSquareDistance, texture_manager::size_type *ReplacableSkinId, int iAlpha)
#endif
void TModel3d::RaRender(double fSquareDistance, texture_manager::size_type const *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?
@@ -2202,7 +2202,7 @@ void TModel3d::RaRender(double fSquareDistance, texture_manager::size_type *Repl
}
};
void TModel3d::RaRenderAlpha(double fSquareDistance, texture_manager::size_type *ReplacableSkinId, int iAlpha)
void TModel3d::RaRenderAlpha(double fSquareDistance, texture_manager::size_type const *ReplacableSkinId, int iAlpha)
{ // renderowanie specjalne, np. kabiny
if (iAlpha & iFlags & 0x2F2F002F) // czy w ogóle jest co robić w tym cyklu?
{
@@ -2219,7 +2219,7 @@ void TModel3d::RaRenderAlpha(double fSquareDistance, texture_manager::size_type
//-----------------------------------------------------------------------------
// 2011-03-16 cztery nowe funkcje renderowania z możliwością pochylania obiektów
//-----------------------------------------------------------------------------
#ifdef EU07_USE_OLD_RENDERCODE
void TModel3d::Render(vector3 *vPosition, vector3 *vAngle, texture_manager::size_type *ReplacableSkinId, int iAlpha)
{ // nieprzezroczyste, Display List
glPushMatrix();
@@ -2254,8 +2254,8 @@ void TModel3d::RenderAlpha(vector3 *vPosition, vector3 *vAngle, texture_manager:
Root->RenderAlphaDL();
glPopMatrix();
};
void TModel3d::RaRender(vector3 *vPosition, vector3 *vAngle, texture_manager::size_type *ReplacableSkinId, int iAlpha)
#endif
void TModel3d::RaRender(vector3 *vPosition, vector3 *vAngle, texture_manager::size_type const *ReplacableSkinId, int iAlpha)
{ // nieprzezroczyste, VBO
glPushMatrix();
glTranslated(vPosition->x, vPosition->y, vPosition->z);
@@ -2275,7 +2275,7 @@ void TModel3d::RaRender(vector3 *vPosition, vector3 *vAngle, texture_manager::si
}
glPopMatrix();
};
void TModel3d::RaRenderAlpha(vector3 *vPosition, vector3 *vAngle, texture_manager::size_type *ReplacableSkinId,
void TModel3d::RaRenderAlpha(vector3 *vPosition, vector3 *vAngle, texture_manager::size_type const *ReplacableSkinId,
int iAlpha)
{ // przezroczyste, VBO
glPushMatrix();
@@ -2296,7 +2296,7 @@ void TModel3d::RaRenderAlpha(vector3 *vPosition, vector3 *vAngle, texture_manage
}
glPopMatrix();
};
#endif
//-----------------------------------------------------------------------------
// 2012-02 funkcje do tworzenia terenu z E3D

View File

@@ -363,14 +363,16 @@ public:
#ifdef EU07_USE_OLD_RENDERCODE
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);
// 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);
#endif
void RaRender(double fSquareDistance, texture_manager::size_type const *ReplacableSkinId = NULL, int iAlpha = 0x30300030);
void RaRenderAlpha(double fSquareDistance, texture_manager::size_type const *ReplacableSkinId = NULL, int iAlpha = 0x30300030);
// trzy kąty obrotu
#ifdef EU07_USE_OLD_RENDERCODE
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);
#endif
void RaRender(vector3 *vPosition, vector3 *vAngle, texture_manager::size_type const *ReplacableSkinId = NULL, int iAlpha = 0x30300030);
void RaRenderAlpha(vector3 *vPosition, vector3 *vAngle, texture_manager::size_type const *ReplacableSkinId = NULL, int iAlpha = 0x30300030);
// inline int GetSubModelsCount() { return (SubModelsCount); };
int Flags() const
{

View File

@@ -1386,13 +1386,13 @@ TWorld::Render_Cab() {
::glLightModelfv( GL_LIGHT_MODEL_AMBIENT, &cablight.x );
}
#endif
/*
if( Global::bUseVBO ) { // renderowanie z użyciem VBO. NOTE: disabled for the time being
dynamic->mdKabina->RaRender( 0.0, dynamic->ReplacableSkinID, dynamic->iAlpha );
dynamic->mdKabina->RaRenderAlpha( 0.0, dynamic->ReplacableSkinID, dynamic->iAlpha );
if( Global::bUseVBO ) {
// renderowanie z użyciem VBO. NOTE: needs update, and eventual merge into single render path down the road
dynamic->mdKabina->RaRender( 0.0, dynamic->Material()->replacable_skins, dynamic->Material()->textures_alpha );
dynamic->mdKabina->RaRenderAlpha( 0.0, dynamic->Material()->replacable_skins, dynamic->Material()->textures_alpha );
}
else {
*/
// renderowanie z Display List
#ifdef EU07_USE_OLD_RENDERCODE
dynamic->mdKabina->Render( 0.0, dynamic->ReplacableSkinID, dynamic->iAlpha );
@@ -1401,9 +1401,7 @@ TWorld::Render_Cab() {
GfxRenderer.Render( dynamic->mdKabina, dynamic->Material(), 0.0 );
GfxRenderer.Render_Alpha( dynamic->mdKabina, dynamic->Material(), 0.0 );
#endif
/*
}
*/
#ifdef EU07_USE_OLD_LIGHTING_MODEL
// przywrócenie standardowych, bo zawsze są zmieniane
glLightfv( GL_LIGHT0, GL_AMBIENT, Global::ambientDayLight );

View File

@@ -221,39 +221,76 @@ opengl_renderer::Render( TDynamicObject *Dynamic ) {
::glMultMatrixd( Dynamic->mMatrix.getArray() );
// wersja Display Lists
// NOTE: VBO path is removed
// TODO: implement universal render path down the road
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
auto const cablight = Dynamic->InteriorLight * Dynamic->InteriorLightLevel;
::glLightModelfv( GL_LIGHT_MODEL_AMBIENT, &cablight.x );
}
Render( Dynamic->mdLowPolyInt, Dynamic->Material(), squaredistance );
if( Dynamic->InteriorLightLevel > 0.0f ) {
// reset the overall ambient
GLfloat ambient[] = { 0.0f, 0.0f, 0.0f, 1.0f };
::glLightModelfv( GL_LIGHT_MODEL_AMBIENT, ambient );
}
}
if( Dynamic->fShade > 0.0f ) {
// change light level based on light level of the occupied track
Global::DayLight.apply_intensity( Dynamic->fShade );
}
// Dynamic->mdModel->Render( squaredistance, Dynamic->ReplacableSkinID, Dynamic->iAlpha );
Render( Dynamic->mdModel, Dynamic->Material(), squaredistance );
// TODO: implement universal render path down the road
if( Global::bUseVBO ) {
// wersja VBO
if( Dynamic->mdLowPolyInt ) {
if( FreeFlyModeFlag ? true : !Dynamic->mdKabina || !Dynamic->bDisplayCab ) {
// enable cab light if needed
if( Dynamic->InteriorLightLevel > 0.0f ) {
if( Dynamic->mdLoad ) // renderowanie nieprzezroczystego ładunku
Render( Dynamic->mdLoad, Dynamic->Material(), squaredistance );
// crude way to light the cabin, until we have something more complete in place
auto const cablight = Dynamic->InteriorLight * Dynamic->InteriorLightLevel;
::glLightModelfv( GL_LIGHT_MODEL_AMBIENT, &cablight.x );
}
Dynamic->mdLowPolyInt->RaRender( squaredistance, Dynamic->Material()->replacable_skins, Dynamic->Material()->textures_alpha );
if( Dynamic->InteriorLightLevel > 0.0f ) {
// reset the overall ambient
GLfloat ambient[] = { 0.0f, 0.0f, 0.0f, 1.0f };
::glLightModelfv( GL_LIGHT_MODEL_AMBIENT, ambient );
}
}
}
Dynamic->mdModel->RaRender( squaredistance, Dynamic->Material()->replacable_skins, Dynamic->Material()->textures_alpha );
if( Dynamic->mdLoad ) // renderowanie nieprzezroczystego ładunku
Dynamic->mdLoad->RaRender( squaredistance, Dynamic->Material()->replacable_skins, Dynamic->Material()->textures_alpha );
}
else {
// wersja Display Lists
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
auto const cablight = Dynamic->InteriorLight * Dynamic->InteriorLightLevel;
::glLightModelfv( GL_LIGHT_MODEL_AMBIENT, &cablight.x );
}
Render( Dynamic->mdLowPolyInt, Dynamic->Material(), squaredistance );
if( Dynamic->InteriorLightLevel > 0.0f ) {
// reset the overall ambient
GLfloat ambient[] = { 0.0f, 0.0f, 0.0f, 1.0f };
::glLightModelfv( GL_LIGHT_MODEL_AMBIENT, ambient );
}
}
}
Render( Dynamic->mdModel, Dynamic->Material(), squaredistance );
if( Dynamic->mdLoad ) // renderowanie nieprzezroczystego ładunku
Render( Dynamic->mdLoad, Dynamic->Material(), squaredistance );
}
if( Dynamic->fShade > 0.0f ) {
// restore regular light level
Global::DayLight.apply_intensity();
}
::glPopMatrix();
// TODO: check if this reset is needed. In theory each object should render all buttons based on its own instance data anyway?
// 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

View File

@@ -41,10 +41,8 @@ void TSky::Render( float3 const &Tint )
#endif
if (Global::bUseVBO)
{ // renderowanie z VBO
#ifdef EU07_USE_OLD_RENDERCODE
mdCloud->RaRender( 100, 0 );
mdCloud->RaRenderAlpha(100, 0);
#endif
}
else
{ // renderowanie z Display List