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

changed NULL use to c++11 compliant

This commit is contained in:
tmj-fstate
2017-08-15 00:55:38 +02:00
parent 7068a4ceff
commit 7e51d5d2e0
27 changed files with 92 additions and 92 deletions

View File

@@ -447,7 +447,7 @@ bool TAnimModel::Init(std::string const &asName, std::string const &asReplacable
else if( asReplacableTexture != "none" ) { else if( asReplacableTexture != "none" ) {
m_materialdata.replacable_skins[ 1 ] = GfxRenderer.Fetch_Material( asReplacableTexture ); m_materialdata.replacable_skins[ 1 ] = GfxRenderer.Fetch_Material( asReplacableTexture );
} }
if( ( m_materialdata.replacable_skins[ 1 ] != NULL ) if( ( m_materialdata.replacable_skins[ 1 ] != null_handle )
&& ( GfxRenderer.Material( m_materialdata.replacable_skins[ 1 ] ).has_alpha ) ) { && ( GfxRenderer.Material( 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
m_materialdata.textures_alpha = 0x31310031; m_materialdata.textures_alpha = 0x31310031;

View File

@@ -156,7 +156,7 @@ bool TPoKeys55::Connect()
// get the structure (after we have allocated enough memory for the structure.) // get the structure (after we have allocated enough memory for the structure.)
DetailedInterfaceDataStructure->cbSize = sizeof(SP_DEVICE_INTERFACE_DETAIL_DATA); DetailedInterfaceDataStructure->cbSize = sizeof(SP_DEVICE_INTERFACE_DETAIL_DATA);
// First call populates "StructureSize" with the correct value // First call populates "StructureSize" with the correct value
SetupDiGetDeviceInterfaceDetail(DeviceInfoTable, InterfaceDataStructure, NULL, NULL, SetupDiGetDeviceInterfaceDetail(DeviceInfoTable, InterfaceDataStructure, NULL, 0,
&StructureSize, NULL); &StructureSize, NULL);
DetailedInterfaceDataStructure = DetailedInterfaceDataStructure =
(PSP_DEVICE_INTERFACE_DETAIL_DATA)(malloc(StructureSize)); // Allocate enough memory (PSP_DEVICE_INTERFACE_DETAIL_DATA)(malloc(StructureSize)); // Allocate enough memory

View File

@@ -2928,7 +2928,7 @@ bool TController::PutCommand(std::string NewCommand, double NewValue1, double Ne
else else
TrainParams->NewName(NewCommand); // czyści tabelkę przystanków TrainParams->NewName(NewCommand); // czyści tabelkę przystanków
delete tsGuardSignal; delete tsGuardSignal;
tsGuardSignal = NULL; // wywalenie kierownika tsGuardSignal = nullptr; // wywalenie kierownika
if (NewCommand != "none") if (NewCommand != "none")
{ {
if (!TrainParams->LoadTTfile( if (!TrainParams->LoadTTfile(

View File

@@ -367,7 +367,7 @@ class TController
bool TableAddNew(); bool TableAddNew();
bool TableNotFound(TEvent const *Event) const; bool TableNotFound(TEvent const *Event) const;
// TEvent *TableCheckTrackEvent(double fDirection, TTrack *Track); // TEvent *TableCheckTrackEvent(double fDirection, TTrack *Track);
void TableTraceRoute(double fDistance, TDynamicObject *pVehicle = NULL); void TableTraceRoute(double fDistance, TDynamicObject *pVehicle = nullptr);
void TableCheck(double fDistance); void TableCheck(double fDistance);
TCommandType TableUpdate(double &fVelDes, double &fDist, double &fNext, double &fAcc); TCommandType TableUpdate(double &fVelDes, double &fDist, double &fNext, double &fAcc);
void TablePurger(); void TablePurger();

View File

@@ -4059,7 +4059,7 @@ void TDynamicObject::LoadMMediaFile(std::string BaseDir, std::string TypeName,
int skinindex = 0; int skinindex = 0;
do { do {
material_handle material = GfxRenderer.Fetch_Material( Global::asCurrentTexturePath + ReplacableSkin + "," + std::to_string( skinindex + 1 ), true ); material_handle material = GfxRenderer.Fetch_Material( Global::asCurrentTexturePath + ReplacableSkin + "," + std::to_string( skinindex + 1 ), true );
if( material == NULL ) { if( material == null_handle ) {
break; break;
} }
m_materialdata.replacable_skins[ skinindex + 1 ] = material; m_materialdata.replacable_skins[ skinindex + 1 ] = material;

View File

@@ -143,7 +143,7 @@ class TAnim
struct material_data { struct material_data {
int textures_alpha{ 0x30300030 }; // maska przezroczystości tekstur. default: tekstury wymienne nie mają przezroczystości int textures_alpha{ 0x30300030 }; // maska przezroczystości tekstur. default: tekstury wymienne nie mają przezroczystości
material_handle replacable_skins[ 5 ] = { NULL, NULL, NULL, NULL, NULL }; // McZapkie:zmienialne nadwozie material_handle replacable_skins[ 5 ] = { null_handle, null_handle, null_handle, null_handle, null_handle }; // McZapkie:zmienialne nadwozie
int multi_textures{ 0 }; //<0 tekstury wskazane wpisem, >0 tekstury z przecinkami, =0 jedna int multi_textures{ 0 }; //<0 tekstury wskazane wpisem, >0 tekstury z przecinkami, =0 jedna
}; };

View File

@@ -272,7 +272,7 @@ int main(int argc, char *argv[])
{ {
auto const fileversionsize = ::GetFileVersionInfoSize( argv[ 0 ], NULL ); auto const fileversionsize = ::GetFileVersionInfoSize( argv[ 0 ], NULL );
std::vector<BYTE>fileversiondata; fileversiondata.resize( fileversionsize ); std::vector<BYTE>fileversiondata; fileversiondata.resize( fileversionsize );
if( ::GetFileVersionInfo( argv[ 0 ], NULL, fileversionsize, fileversiondata.data() ) ) { if( ::GetFileVersionInfo( argv[ 0 ], 0, fileversionsize, fileversiondata.data() ) ) {
struct lang_codepage { struct lang_codepage {
WORD language; WORD language;

View File

@@ -232,7 +232,7 @@ void TSubRect::NodeAdd(TGroundNode *Node)
// since ground rectangle can be empty, we're doing lazy initialization of the geometry bank, when something may actually use it // since ground rectangle can be empty, we're doing lazy initialization of the geometry bank, when something may actually use it
// NOTE: this method is called for both subcell and cell, but subcells get first created and passed the handle from their parent // NOTE: this method is called for both subcell and cell, but subcells get first created and passed the handle from their parent
// thus, this effectively only gets executed for the 'parent' ground cells. Not the most elegant, but for now it'll do // thus, this effectively only gets executed for the 'parent' ground cells. Not the most elegant, but for now it'll do
if( m_geometrybank == NULL ) { if( m_geometrybank == null_handle ) {
m_geometrybank = GfxRenderer.Create_Bank(); m_geometrybank = GfxRenderer.Create_Bank();
} }
@@ -439,7 +439,7 @@ TGroundRect::~TGroundRect()
void void
TGroundRect::Init() { TGroundRect::Init() {
// since ground rectangle can be empty, we're doing lazy initialization of the geometry bank, when something may actually use it // since ground rectangle can be empty, we're doing lazy initialization of the geometry bank, when something may actually use it
if( m_geometrybank == NULL ) { if( m_geometrybank == null_handle ) {
m_geometrybank = GfxRenderer.Create_Bank(); m_geometrybank = GfxRenderer.Create_Bank();
} }
@@ -1378,9 +1378,9 @@ TGroundNode * TGround::AddGroundNode(cParser *parser)
str = token; str = token;
tmp->m_material = GfxRenderer.Fetch_Material( str ); tmp->m_material = GfxRenderer.Fetch_Material( str );
auto const texturehandle = ( auto const texturehandle = (
tmp->m_material != NULL ? tmp->m_material != null_handle ?
GfxRenderer.Material( tmp->m_material ).texture1 : GfxRenderer.Material( tmp->m_material ).texture1 :
NULL ); null_handle );
auto const &texture = ( auto const &texture = (
texturehandle ? texturehandle ?
GfxRenderer.Texture( texturehandle ) : GfxRenderer.Texture( texturehandle ) :
@@ -1396,7 +1396,7 @@ TGroundNode * TGround::AddGroundNode(cParser *parser)
tmp->iFlags |= 200; // z usuwaniem tmp->iFlags |= 200; // z usuwaniem
// remainder of legacy 'problend' system -- geometry assigned a texture with '@' in its name is treated as translucent, opaque otherwise // remainder of legacy 'problend' system -- geometry assigned a texture with '@' in its name is treated as translucent, opaque otherwise
if( texturehandle != NULL ) { if( texturehandle != null_handle ) {
tmp->iFlags |= ( tmp->iFlags |= (
( ( texture.name.find( '@' ) != std::string::npos ) ( ( texture.name.find( '@' ) != std::string::npos )
&& ( true == texture.has_alpha ) ) ? && ( true == texture.has_alpha ) ) ?

View File

@@ -118,9 +118,8 @@ std::string ExchangeCharInString( std::string const &Source, char const &From, c
{ {
std::string replacement; replacement.reserve( Source.size() ); std::string replacement; replacement.reserve( Source.size() );
std::for_each(Source.cbegin(), Source.cend(), [&](char const idx) { std::for_each(Source.cbegin(), Source.cend(), [&](char const idx) {
if( idx != From ) { replacement += idx; } if( idx != From ) { replacement += idx; }
else { else { replacement += To; }
if( To != NULL ) { replacement += To; } }
} ); } );
return replacement; return replacement;

View File

@@ -308,7 +308,7 @@ int TSubModel::Load( cParser &parser, TModel3d *Model, /*int Pos,*/ bool dynamic
std::string material = parser.getToken<std::string>(); std::string material = parser.getToken<std::string>();
if (material == "none") if (material == "none")
{ // rysowanie podanym kolorem { // rysowanie podanym kolorem
m_material = NULL; m_material = null_handle;
iFlags |= 0x10; // rysowane w cyklu nieprzezroczystych iFlags |= 0x10; // rysowane w cyklu nieprzezroczystych
} }
else if (material.find("replacableskin") != material.npos) else if (material.find("replacableskin") != material.npos)
@@ -348,7 +348,7 @@ int TSubModel::Load( cParser &parser, TModel3d *Model, /*int Pos,*/ bool dynamic
// 2. tekstura ma przezroczystość // 2. tekstura ma przezroczystość
iFlags |= iFlags |=
( ( ( Opacity < 1.0 ) ( ( ( Opacity < 1.0 )
&& ( ( m_material != NULL ) && ( ( m_material != null_handle )
&& ( GfxRenderer.Material( m_material ).has_alpha ) ) ) ? && ( GfxRenderer.Material( m_material ).has_alpha ) ) ) ?
0x20 : 0x20 :
0x10 ); // 0x10-nieprzezroczysta, 0x20-przezroczysta 0x10 ); // 0x10-nieprzezroczysta, 0x20-przezroczysta
@@ -1044,7 +1044,7 @@ void TSubModel::serialize_geometry( std::ostream &Output ) const {
if( Child ) { if( Child ) {
Child->serialize_geometry( Output ); Child->serialize_geometry( Output );
} }
if( m_geometry != NULL ) { if( m_geometry != null_handle ) {
for( auto const &vertex : GfxRenderer.Vertices( m_geometry ) ) { for( auto const &vertex : GfxRenderer.Vertices( m_geometry ) ) {
vertex.serialize( Output ); vertex.serialize( Output );
} }
@@ -1092,7 +1092,7 @@ TSubModel::convert( TGroundNode &Groundnode ) const {
0x20 : 0x20 :
0x10 ); 0x10 );
if( m_geometry == NULL ) { return; } if( m_geometry == null_handle ) { return; }
std::size_t vertexcount { 0 }; std::size_t vertexcount { 0 };
std::vector<TGroundVertex> importedvertices; std::vector<TGroundVertex> importedvertices;
@@ -1198,7 +1198,7 @@ float TSubModel::MaxY( float4x4 const &m ) {
auto maxy { 0.0f }; auto maxy { 0.0f };
// binary and text models invoke this function at different stages, either after or before geometry data was sent to the geometry manager // binary and text models invoke this function at different stages, either after or before geometry data was sent to the geometry manager
if( m_geometry != NULL ) { if( m_geometry != null_handle ) {
for( auto const &vertex : GfxRenderer.Vertices( m_geometry ) ) { for( auto const &vertex : GfxRenderer.Vertices( m_geometry ) ) {
maxy = std::max( maxy = std::max(
@@ -1539,7 +1539,7 @@ void TModel3d::deserialize(std::istream &s, size_t size, bool dynamic)
{ {
Root = nullptr; Root = nullptr;
float4x4 *tm = nullptr; float4x4 *tm = nullptr;
if( m_geometrybank == NULL ) { if( m_geometrybank == null_handle ) {
m_geometrybank = GfxRenderer.Create_Bank(); m_geometrybank = GfxRenderer.Create_Bank();
} }
@@ -1738,7 +1738,7 @@ void TSubModel::BinInit(TSubModel *s, float4x4 *m, std::vector<std::string> *t,
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 |= (
( ( m_material != NULL ) ( ( m_material != null_handle )
&& ( GfxRenderer.Material( m_material ).has_alpha ) ) ? && ( GfxRenderer.Material( m_material ).has_alpha ) ) ?
0x20 : 0x20 :
0x10 ); // 0x10-nieprzezroczysta, 0x20-przezroczysta 0x10 ); // 0x10-nieprzezroczysta, 0x20-przezroczysta
@@ -1746,7 +1746,7 @@ void TSubModel::BinInit(TSubModel *s, float4x4 *m, std::vector<std::string> *t,
} }
else { else {
ErrorLog( "Bad model: reference to non-existent texture index in sub-model" + ( pName.empty() ? "" : " \"" + pName + "\"" ) ); ErrorLog( "Bad model: reference to non-existent texture index in sub-model" + ( pName.empty() ? "" : " \"" + pName + "\"" ) );
m_material = NULL; m_material = null_handle;
} }
} }
else else
@@ -1878,7 +1878,7 @@ void TModel3d::Init()
} }
iFlags |= Root->FlagsCheck() | 0x8000; // flagi całego modelu iFlags |= Root->FlagsCheck() | 0x8000; // flagi całego modelu
if (iNumVerts) { if (iNumVerts) {
if( m_geometrybank == NULL ) { if( m_geometrybank == null_handle ) {
m_geometrybank = GfxRenderer.Create_Bank(); m_geometrybank = GfxRenderer.Create_Bank();
} }
std::size_t dataoffset = 0; std::size_t dataoffset = 0;

View File

@@ -68,8 +68,8 @@ public:
}; };
private: private:
int iNext{ NULL }; int iNext{ 0 };
int iChild{ NULL }; int iChild{ 0 };
int eType{ TP_ROTATOR }; // Ra: modele binarne dają więcej możliwości niż mesh złożony z trójkątów int eType{ TP_ROTATOR }; // Ra: modele binarne dają więcej możliwości niż mesh złożony z trójkątów
int iName{ -1 }; // numer łańcucha z nazwą submodelu, albo -1 gdy anonimowy int iName{ -1 }; // numer łańcucha z nazwą submodelu, albo -1 gdy anonimowy
public: // chwilowo public: // chwilowo
@@ -121,8 +121,8 @@ private:
TSubModel *Next { nullptr }; TSubModel *Next { nullptr };
TSubModel *Child { nullptr }; TSubModel *Child { nullptr };
geometry_handle m_geometry { NULL, NULL }; // geometry of the submodel geometry_handle m_geometry { 0, 0 }; // geometry of the submodel
material_handle m_material { NULL }; // numer tekstury, -1 wymienna, 0 brak material_handle m_material { null_handle }; // numer tekstury, -1 wymienna, 0 brak
bool bWire { false }; // nie używane, ale wczytywane bool bWire { false }; // nie używane, ale wczytywane
float Opacity { 1.0f }; float Opacity { 1.0f };
float f_Angle { 0.0f }; float f_Angle { 0.0f };
@@ -135,7 +135,7 @@ public: // chwilowo
basic_vertex *Vertices; // roboczy wskaźnik - wczytanie T3D do VBO basic_vertex *Vertices; // roboczy wskaźnik - wczytanie T3D do VBO
*/ */
vertex_array Vertices; vertex_array Vertices;
size_t iAnimOwner{ NULL }; // roboczy numer egzemplarza, który ustawił animację size_t iAnimOwner{ 0 }; // roboczy numer egzemplarza, który ustawił animację
TAnimType b_aAnim{ at_None }; // kody animacji oddzielnie, bo zerowane TAnimType b_aAnim{ at_None }; // kody animacji oddzielnie, bo zerowane
public: public:
float4x4 *mAnimMatrix{ nullptr }; // macierz do animacji kwaternionowych (należy do AnimContainer) float4x4 *mAnimMatrix{ nullptr }; // macierz do animacji kwaternionowych (należy do AnimContainer)

View File

@@ -454,7 +454,7 @@ bool TSegment::RenderLoft( vertex_array &Output, Math3D::vector3 const &Origin,
void TSegment::Render() void TSegment::Render()
{ {
vector3 pt; vector3 pt;
GfxRenderer.Bind_Material( NULL ); GfxRenderer.Bind_Material( null_handle );
if (bCurve) if (bCurve)
{ {

View File

@@ -224,7 +224,7 @@ void TSoundsManager::RestoreAll()
hr = Next->DSBuffer->Restore(); hr = Next->DSBuffer->Restore();
if (hr == DSERR_BUFFERLOST) if (hr == DSERR_BUFFERLOST)
Sleep(10); Sleep(10);
} while ((hr = Next->DSBuffer->Restore()) != NULL); } while ((hr = Next->DSBuffer->Restore()) != 0);
// char *Name= Next->Name; // char *Name= Next->Name;
// int cc= Next->Concurrent; // int cc= Next->Concurrent;

View File

@@ -817,9 +817,9 @@ texture_manager::bind( std::size_t const Unit, texture_handle const Texture ) {
return; return;
} }
// TBD, TODO: do binding in texture object, add support for other types than 2d // TBD, TODO: do binding in texture object, add support for other types than 2d
if( m_units[ Unit ].unit == NULL ) { return; } if( m_units[ Unit ].unit == 0 ) { return; }
unit( m_units[ Unit ].unit ); unit( m_units[ Unit ].unit );
if( Texture != NULL ) { if( Texture != null_handle ) {
#ifndef EU07_DEFERRED_TEXTURE_UPLOAD #ifndef EU07_DEFERRED_TEXTURE_UPLOAD
// NOTE: we could bind dedicated 'error' texture here if the id isn't valid // NOTE: we could bind dedicated 'error' texture here if the id isn't valid
::glBindTexture( GL_TEXTURE_2D, texture(Texture).id ); ::glBindTexture( GL_TEXTURE_2D, texture(Texture).id );
@@ -830,15 +830,14 @@ texture_manager::bind( std::size_t const Unit, texture_handle const Texture ) {
} }
else { else {
// TODO: bind a special 'error' texture on failure // TODO: bind a special 'error' texture on failure
::glBindTexture( GL_TEXTURE_2D, NULL ); ::glBindTexture( GL_TEXTURE_2D, 0 );
m_units[ Unit ].texture = NULL; m_units[ Unit ].texture = 0;
} }
#endif #endif
} }
else { else {
::glBindTexture( GL_TEXTURE_2D, 0 );
::glBindTexture( GL_TEXTURE_2D, NULL ); m_units[ Unit ].texture = 0;
m_units[ Unit ].texture = NULL;
} }
// all done // all done
return; return;

View File

@@ -78,6 +78,7 @@ private:
}; };
typedef int texture_handle; typedef int texture_handle;
int const null_handle = 0;
class texture_manager { class texture_manager {
@@ -114,8 +115,8 @@ private:
typedef std::unordered_map<std::string, std::size_t> index_map; typedef std::unordered_map<std::string, std::size_t> index_map;
struct texture_unit { struct texture_unit {
GLint unit { NULL }; GLint unit { 0 };
texture_handle texture { NULL }; // current (most recently bound) texture texture_handle texture { null_handle }; // current (most recently bound) texture
}; };
// methods: // methods:
@@ -134,7 +135,7 @@ private:
index_map m_texturemappings; index_map m_texturemappings;
garbage_collector<texturetimepointpair_sequence> m_garbagecollector { m_textures, 600, 60, "texture" }; garbage_collector<texturetimepointpair_sequence> m_garbagecollector { m_textures, 600, 60, "texture" };
std::array<texture_unit, 4> m_units; std::array<texture_unit, 4> m_units;
GLint m_activeunit { NULL }; GLint m_activeunit { 0 };
}; };
// reduces provided data image to half of original size, using basic 2x2 average // reduces provided data image to half of original size, using basic 2x2 average

View File

@@ -485,7 +485,7 @@ void TTrack::Load(cParser *parser, vector3 pOrigin, std::string name)
*parser >> str; // railtex *parser >> str; // railtex
m_material1 = ( m_material1 = (
str == "none" ? str == "none" ?
NULL : null_handle :
GfxRenderer.Fetch_Material( str ) ); GfxRenderer.Fetch_Material( str ) );
parser->getTokens(); parser->getTokens();
*parser >> fTexLength; // tex tile length *parser >> fTexLength; // tex tile length
@@ -495,7 +495,7 @@ void TTrack::Load(cParser *parser, vector3 pOrigin, std::string name)
*parser >> str; // sub || railtex *parser >> str; // sub || railtex
m_material2 = ( m_material2 = (
str == "none" ? str == "none" ?
NULL : null_handle :
GfxRenderer.Fetch_Material( str ) ); GfxRenderer.Fetch_Material( str ) );
parser->getTokens(3); parser->getTokens(3);
*parser >> fTexHeight1 >> fTexWidth >> fTexSlope; *parser >> fTexHeight1 >> fTexWidth >> fTexSlope;

View File

@@ -93,7 +93,7 @@ sekcji z sąsiedniego przęsła).
std::size_t std::size_t
TTraction::create_geometry( geometrybank_handle const &Bank, glm::dvec3 const &Origin ) { TTraction::create_geometry( geometrybank_handle const &Bank, glm::dvec3 const &Origin ) {
if( m_geometry != NULL ) { if( m_geometry != null_handle ) {
return GfxRenderer.Vertices( m_geometry ).size() / 2; return GfxRenderer.Vertices( m_geometry ).size() / 2;
} }

View File

@@ -47,9 +47,9 @@ RGBtoHSV( glm::vec3 const &RGB ) {
hsv.x = ( RGB.g - RGB.b ) / delta; // between yellow & magenta hsv.x = ( RGB.g - RGB.b ) / delta; // between yellow & magenta
else else
if( RGB.g >= max ) if( RGB.g >= max )
hsv.x = 2.0 + ( RGB.g - RGB.r ) / delta; // between cyan & yellow hsv.x = 2.f + ( RGB.g - RGB.r ) / delta; // between cyan & yellow
else else
hsv.x = 4.0 + ( RGB.r - RGB.g ) / delta; // between magenta & cyan hsv.x = 4.f + ( RGB.r - RGB.g ) / delta; // between magenta & cyan
hsv.x *= 60.0; // degrees hsv.x *= 60.0; // degrees

View File

@@ -23,7 +23,7 @@ opengl_material::deserialize( cParser &Input, bool const Loadnow ) {
} }
has_alpha = ( has_alpha = (
texture1 != NULL ? texture1 != null_handle ?
GfxRenderer.Texture( texture1 ).has_alpha : GfxRenderer.Texture( texture1 ).has_alpha :
false ); false );
@@ -93,15 +93,15 @@ material_manager::create( std::string const &Filename, bool const Loadnow ) {
cParser materialparser( disklookup, cParser::buffer_FILE ); cParser materialparser( disklookup, cParser::buffer_FILE );
if( false == material.deserialize( materialparser, Loadnow ) ) { if( false == material.deserialize( materialparser, Loadnow ) ) {
// deserialization failed but the .mat file does exist, so we give up at this point // deserialization failed but the .mat file does exist, so we give up at this point
return NULL; return null_handle;
} }
} }
else { else {
// if there's no .mat file, this could be legacy method of referring just to diffuse texture directly, make a material out of it in such case // if there's no .mat file, this could be legacy method of referring just to diffuse texture directly, make a material out of it in such case
material.texture1 = GfxRenderer.Fetch_Texture( Filename, Loadnow ); material.texture1 = GfxRenderer.Fetch_Texture( Filename, Loadnow );
if( material.texture1 == NULL ) { if( material.texture1 == null_handle ) {
// if there's also no texture, give up // if there's also no texture, give up
return NULL; return null_handle;
} }
material.has_alpha = GfxRenderer.Texture( material.texture1 ).has_alpha; material.has_alpha = GfxRenderer.Texture( material.texture1 ).has_alpha;
} }

View File

@@ -19,8 +19,8 @@ typedef int material_handle;
// for legacy opengl this is basically just texture(s) assigned to geometry // for legacy opengl this is basically just texture(s) assigned to geometry
struct opengl_material { struct opengl_material {
texture_handle texture1 { NULL }; // primary texture, typically diffuse+apha texture_handle texture1 { null_handle }; // primary texture, typically diffuse+apha
texture_handle texture2 { NULL }; // secondary texture, typically normal+reflection texture_handle texture2 { null_handle }; // secondary texture, typically normal+reflection
bool has_alpha { false }; // alpha state, calculated from presence of alpha in texture1 bool has_alpha { false }; // alpha state, calculated from presence of alpha in texture1
std::string name; std::string name;

View File

@@ -118,7 +118,7 @@ geometry_bank::vertices( geometry_handle const &Geometry ) const {
// opengl vbo-based variant of the geometry bank // opengl vbo-based variant of the geometry bank
GLuint opengl_vbogeometrybank::m_activebuffer { NULL }; // buffer bound currently on the opengl end, if any GLuint opengl_vbogeometrybank::m_activebuffer { 0 }; // buffer bound currently on the opengl end, if any
unsigned int opengl_vbogeometrybank::m_activestreams { stream::none }; // currently enabled data type pointers unsigned int opengl_vbogeometrybank::m_activestreams { stream::none }; // currently enabled data type pointers
std::vector<GLint> opengl_vbogeometrybank::m_activetexturearrays; // currently enabled texture coord arrays std::vector<GLint> opengl_vbogeometrybank::m_activetexturearrays; // currently enabled texture coord arrays
@@ -151,7 +151,7 @@ opengl_vbogeometrybank::replace_( geometry_handle const &Geometry ) {
void void
opengl_vbogeometrybank::draw_( geometry_handle const &Geometry, stream_units const &Units, unsigned int const Streams ) { opengl_vbogeometrybank::draw_( geometry_handle const &Geometry, stream_units const &Units, unsigned int const Streams ) {
if( m_buffer == NULL ) { if( m_buffer == 0 ) {
// if there's no buffer, we'll have to make one // if there's no buffer, we'll have to make one
// NOTE: this isn't exactly optimal in terms of ensuring the gfx card doesn't stall waiting for the data // NOTE: this isn't exactly optimal in terms of ensuring the gfx card doesn't stall waiting for the data
// may be better to initiate upload earlier (during update phase) and trust this effort won't go to waste // may be better to initiate upload earlier (during update phase) and trust this effort won't go to waste
@@ -235,14 +235,14 @@ opengl_vbogeometrybank::bind_buffer() {
void void
opengl_vbogeometrybank::delete_buffer() { opengl_vbogeometrybank::delete_buffer() {
if( m_buffer != NULL ) { if( m_buffer != 0 ) {
::glDeleteBuffers( 1, &m_buffer ); ::glDeleteBuffers( 1, &m_buffer );
if( m_activebuffer == m_buffer ) { if( m_activebuffer == m_buffer ) {
m_activebuffer = NULL; m_activebuffer = 0;
release_streams(); release_streams();
} }
m_buffer = NULL; m_buffer = 0;
m_buffercapacity = 0; m_buffercapacity = 0;
// NOTE: since we've deleted the buffer all chunks it held were rendered invalid as well // NOTE: since we've deleted the buffer all chunks it held were rendered invalid as well
// instead of clearing their state here we're delaying it until new buffer is created to avoid looping through chunk records twice // instead of clearing their state here we're delaying it until new buffer is created to avoid looping through chunk records twice
@@ -423,7 +423,7 @@ geometrybank_manager::append( vertex_array &Vertices, geometry_handle const &Geo
void void
geometrybank_manager::draw( geometry_handle const &Geometry, unsigned int const Streams ) { geometrybank_manager::draw( geometry_handle const &Geometry, unsigned int const Streams ) {
if( Geometry == NULL ) { return; } if( Geometry == null_handle ) { return; }
auto &bankrecord = bank( Geometry ); auto &bankrecord = bank( Geometry );

View File

@@ -208,7 +208,7 @@ private:
static GLuint m_activebuffer; // buffer bound currently on the opengl end, if any static GLuint m_activebuffer; // buffer bound currently on the opengl end, if any
static unsigned int m_activestreams; static unsigned int m_activestreams;
static std::vector<GLint> m_activetexturearrays; static std::vector<GLint> m_activetexturearrays;
GLuint m_buffer { NULL }; // id of the buffer holding data on the opengl end GLuint m_buffer { 0 }; // id of the buffer holding data on the opengl end
std::size_t m_buffercapacity{ 0 }; // total capacity of the last established buffer std::size_t m_buffercapacity{ 0 }; // total capacity of the last established buffer
chunkrecord_sequence m_chunkrecords; // helper data for all stored geometry chunks, in matching order chunkrecord_sequence m_chunkrecords; // helper data for all stored geometry chunks, in matching order

View File

@@ -217,7 +217,7 @@ opengl_renderer::Init( GLFWwindow *Window ) {
::glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_COMPARE_MODE, GL_COMPARE_R_TO_TEXTURE ); ::glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_COMPARE_MODE, GL_COMPARE_R_TO_TEXTURE );
::glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_COMPARE_FUNC, GL_LEQUAL ); ::glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_COMPARE_FUNC, GL_LEQUAL );
::glTexParameteri( GL_TEXTURE_2D, GL_DEPTH_TEXTURE_MODE, GL_LUMINANCE ); ::glTexParameteri( GL_TEXTURE_2D, GL_DEPTH_TEXTURE_MODE, GL_LUMINANCE );
::glBindTexture( GL_TEXTURE_2D, NULL ); ::glBindTexture( GL_TEXTURE_2D, 0 );
#ifdef EU07_USE_DEBUG_SHADOWMAP #ifdef EU07_USE_DEBUG_SHADOWMAP
::glGenTextures( 1, &m_shadowdebugtexture ); ::glGenTextures( 1, &m_shadowdebugtexture );
::glBindTexture( GL_TEXTURE_2D, m_shadowdebugtexture ); ::glBindTexture( GL_TEXTURE_2D, m_shadowdebugtexture );
@@ -1093,7 +1093,7 @@ opengl_renderer::Render( world_environment *Environment ) {
return false; return false;
} }
Bind_Material( NULL ); Bind_Material( null_handle );
::glDisable( GL_LIGHTING ); ::glDisable( GL_LIGHTING );
::glDisable( GL_DEPTH_TEST ); ::glDisable( GL_DEPTH_TEST );
::glDepthMask( GL_FALSE ); ::glDepthMask( GL_FALSE );
@@ -1690,7 +1690,7 @@ opengl_renderer::Render( TGroundNode *Node ) {
} }
case GL_LINES: { case GL_LINES: {
if( ( Node->Piece->geometry == NULL ) if( ( Node->Piece->geometry == null_handle )
|| ( Node->fLineThickness > 0.0 ) ) { || ( Node->fLineThickness > 0.0 ) ) {
return false; return false;
} }
@@ -1723,7 +1723,7 @@ opengl_renderer::Render( TGroundNode *Node ) {
::glLineWidth( static_cast<float>( linewidth ) ); ::glLineWidth( static_cast<float>( linewidth ) );
} }
GfxRenderer.Bind_Material( NULL ); GfxRenderer.Bind_Material( null_handle );
::glPushMatrix(); ::glPushMatrix();
auto const originoffset = Node->m_rootposition - m_renderpass.camera.position(); auto const originoffset = Node->m_rootposition - m_renderpass.camera.position();
@@ -1751,7 +1751,7 @@ opengl_renderer::Render( TGroundNode *Node ) {
} }
case GL_TRIANGLES: { case GL_TRIANGLES: {
if( ( Node->Piece->geometry == NULL ) if( ( Node->Piece->geometry == null_handle )
|| ( ( Node->iFlags & 0x10 ) == 0 ) ) { || ( ( Node->iFlags & 0x10 ) == 0 ) ) {
return false; return false;
} }
@@ -2203,7 +2203,7 @@ opengl_renderer::Render( TSubModel *Submodel ) {
// material configuration: // material configuration:
::glPushAttrib( GL_ENABLE_BIT | GL_CURRENT_BIT | GL_COLOR_BUFFER_BIT | GL_POINT_BIT ); ::glPushAttrib( GL_ENABLE_BIT | GL_CURRENT_BIT | GL_COLOR_BUFFER_BIT | GL_POINT_BIT );
Bind_Material( NULL ); Bind_Material( null_handle );
::glPointSize( std::max( 3.f, 5.f * distancefactor * anglefactor ) ); ::glPointSize( std::max( 3.f, 5.f * distancefactor * anglefactor ) );
::glColor4f( Submodel->f4Diffuse[ 0 ], Submodel->f4Diffuse[ 1 ], Submodel->f4Diffuse[ 2 ], lightlevel * anglefactor ); ::glColor4f( Submodel->f4Diffuse[ 0 ], Submodel->f4Diffuse[ 1 ], Submodel->f4Diffuse[ 2 ], lightlevel * anglefactor );
::glDisable( GL_LIGHTING ); ::glDisable( GL_LIGHTING );
@@ -2250,7 +2250,7 @@ opengl_renderer::Render( TSubModel *Submodel ) {
// material configuration: // material configuration:
::glPushAttrib( GL_ENABLE_BIT | GL_CURRENT_BIT ); ::glPushAttrib( GL_ENABLE_BIT | GL_CURRENT_BIT );
Bind_Material( NULL ); Bind_Material( null_handle );
::glDisable( GL_LIGHTING ); ::glDisable( GL_LIGHTING );
// main draw call // main draw call
@@ -2266,7 +2266,7 @@ opengl_renderer::Render( TSubModel *Submodel ) {
} }
} }
} }
if( Submodel->Child != NULL ) if( Submodel->Child != nullptr )
if( Submodel->iAlpha & Submodel->iFlags & 0x001F0000 ) if( Submodel->iAlpha & Submodel->iFlags & 0x001F0000 )
Render( Submodel->Child ); Render( Submodel->Child );
@@ -2452,7 +2452,7 @@ opengl_renderer::Render_Alpha( TGroundNode *Node ) {
auto const color { Node->hvTraction->wire_color() }; auto const color { Node->hvTraction->wire_color() };
::glColor4f( color.r, color.g, color.b, linealpha ); ::glColor4f( color.r, color.g, color.b, linealpha );
Bind_Material( NULL ); Bind_Material( null_handle );
::glPushMatrix(); ::glPushMatrix();
auto const originoffset = Node->m_rootposition - m_renderpass.camera.position(); auto const originoffset = Node->m_rootposition - m_renderpass.camera.position();
@@ -2507,7 +2507,7 @@ opengl_renderer::Render_Alpha( TGroundNode *Node ) {
} }
case GL_LINES: { case GL_LINES: {
if( ( Node->Piece->geometry == NULL ) if( ( Node->Piece->geometry == null_handle )
|| ( Node->fLineThickness < 0.0 ) ) { || ( Node->fLineThickness < 0.0 ) ) {
return false; return false;
} }
@@ -2528,7 +2528,7 @@ opengl_renderer::Render_Alpha( TGroundNode *Node ) {
::glLineWidth( static_cast<float>(linewidth) ); ::glLineWidth( static_cast<float>(linewidth) );
} }
GfxRenderer.Bind_Material( NULL ); GfxRenderer.Bind_Material( null_handle );
::glPushMatrix(); ::glPushMatrix();
auto const originoffset = Node->m_rootposition - m_renderpass.camera.position(); auto const originoffset = Node->m_rootposition - m_renderpass.camera.position();
@@ -2546,7 +2546,7 @@ opengl_renderer::Render_Alpha( TGroundNode *Node ) {
} }
case GL_TRIANGLES: { case GL_TRIANGLES: {
if( ( Node->Piece->geometry == NULL ) if( ( Node->Piece->geometry == null_handle )
|| ( ( Node->iFlags & 0x20 ) == 0 ) ) { || ( ( Node->iFlags & 0x20 ) == 0 ) ) {
return false; return false;
} }
@@ -2852,7 +2852,7 @@ opengl_renderer::Render_Alpha( TSubModel *Submodel ) {
} }
} }
if( Submodel->Child != NULL ) { if( Submodel->Child != nullptr ) {
if( Submodel->eType == TP_TEXT ) { // tekst renderujemy w specjalny sposób, zamiast submodeli z łańcucha Child if( Submodel->eType == TP_TEXT ) { // tekst renderujemy w specjalny sposób, zamiast submodeli z łańcucha Child
int i, j = (int)Submodel->pasText->size(); int i, j = (int)Submodel->pasText->size();
TSubModel *p; TSubModel *p;
@@ -2885,7 +2885,7 @@ opengl_renderer::Render_Alpha( TSubModel *Submodel ) {
if( Submodel->b_aAnim < at_SecondsJump ) if( Submodel->b_aAnim < at_SecondsJump )
Submodel->b_aAnim = at_None; // wyłączenie animacji dla kolejnego użycia submodelu Submodel->b_aAnim = at_None; // wyłączenie animacji dla kolejnego użycia submodelu
if( Submodel->Next != NULL ) if( Submodel->Next != nullptr )
if( Submodel->iAlpha & Submodel->iFlags & 0x2F000000 ) if( Submodel->iAlpha & Submodel->iFlags & 0x2F000000 )
Render_Alpha( Submodel->Next ); Render_Alpha( Submodel->Next );
}; };

View File

@@ -316,7 +316,7 @@ private:
texture_manager m_textures; texture_manager m_textures;
opengllight_array m_lights; opengllight_array m_lights;
geometry_handle m_billboardgeometry { NULL, NULL }; geometry_handle m_billboardgeometry { 0, 0 };
texture_handle m_glaretexture { -1 }; texture_handle m_glaretexture { -1 };
texture_handle m_suntexture { -1 }; texture_handle m_suntexture { -1 };
texture_handle m_moontexture { -1 }; texture_handle m_moontexture { -1 };
@@ -325,22 +325,22 @@ private:
// TODO: refactor framebuffer stuff into an object // TODO: refactor framebuffer stuff into an object
bool m_framebuffersupport { false }; bool m_framebuffersupport { false };
#ifdef EU07_USE_PICKING_FRAMEBUFFER #ifdef EU07_USE_PICKING_FRAMEBUFFER
GLuint m_pickframebuffer { NULL }; GLuint m_pickframebuffer { 0 };
GLuint m_picktexture { NULL }; GLuint m_picktexture { 0 };
GLuint m_pickdepthbuffer { NULL }; GLuint m_pickdepthbuffer { 0 };
#endif #endif
int m_shadowbuffersize { 2048 }; int m_shadowbuffersize { 2048 };
GLuint m_shadowframebuffer { NULL }; GLuint m_shadowframebuffer { 0 };
GLuint m_shadowtexture { NULL }; GLuint m_shadowtexture { 0 };
#ifdef EU07_USE_DEBUG_SHADOWMAP #ifdef EU07_USE_DEBUG_SHADOWMAP
GLuint m_shadowdebugtexture{ NULL }; GLuint m_shadowdebugtexture{ 0 };
#endif #endif
glm::mat4 m_shadowtexturematrix; // conversion from camera-centric world space to light-centric clip space glm::mat4 m_shadowtexturematrix; // conversion from camera-centric world space to light-centric clip space
GLuint m_environmentframebuffer { NULL }; GLuint m_environmentframebuffer { 0 };
GLuint m_environmentcubetexture { NULL }; GLuint m_environmentcubetexture { 0 };
GLuint m_environmentdepthbuffer { NULL }; GLuint m_environmentdepthbuffer { 0 };
bool m_environmentcubetexturesupport { false }; // indicates whether we can use the dynamic environment cube map bool m_environmentcubetexturesupport { false }; // indicates whether we can use the dynamic environment cube map
int m_environmentcubetextureface { NULL }; // helper, currently processed cube map face int m_environmentcubetextureface { 0 }; // helper, currently processed cube map face
int m_environmentupdatetime { 0 }; // time of the most recent environment map update int m_environmentupdatetime { 0 }; // time of the most recent environment map update
glm::dvec3 m_environmentupdatelocation; // coordinates of most recent environment map update glm::dvec3 m_environmentupdatelocation; // coordinates of most recent environment map update

View File

@@ -29,6 +29,7 @@
#include <strsafe.h> #include <strsafe.h>
#endif #endif
// stl // stl
#include <cstddef>
#include <cstdlib> #include <cstdlib>
#include <cassert> #include <cassert>
#define _USE_MATH_DEFINES #define _USE_MATH_DEFINES

View File

@@ -100,9 +100,9 @@ ui_layer::set_background( std::string const &Filename ) {
m_background = GfxRenderer.Fetch_Texture( Filename ); m_background = GfxRenderer.Fetch_Texture( Filename );
} }
else { else {
m_background = NULL; m_background = null_handle;
} }
if( m_background != NULL ) { if( m_background != null_handle ) {
auto const &texture = GfxRenderer.Texture( m_background ); auto const &texture = GfxRenderer.Texture( m_background );
m_progressbottom = ( texture.width() != texture.height() ); m_progressbottom = ( texture.width() != texture.height() );
} }
@@ -235,11 +235,11 @@ ui_layer::render_background() {
void void
ui_layer::render_texture() { ui_layer::render_texture() {
if( m_texture != NULL ) { if( m_texture != 0 ) {
::glColor4f( 1.f, 1.f, 1.f, 1.f ); ::glColor4f( 1.f, 1.f, 1.f, 1.f );
::glDisable( GL_BLEND ); ::glDisable( GL_BLEND );
GfxRenderer.Bind_Texture( NULL ); GfxRenderer.Bind_Texture( null_handle );
::glBindTexture( GL_TEXTURE_2D, m_texture ); ::glBindTexture( GL_TEXTURE_2D, m_texture );
auto const size = 512.f; auto const size = 512.f;
@@ -254,7 +254,7 @@ ui_layer::render_texture() {
glEnd(); glEnd();
::glBindTexture( GL_TEXTURE_2D, NULL ); ::glBindTexture( GL_TEXTURE_2D, 0 );
::glEnable( GL_BLEND ); ::glEnable( GL_BLEND );
} }

View File

@@ -55,7 +55,7 @@ public:
void void
set_background( std::string const &Filename = "" ); set_background( std::string const &Filename = "" );
void void
set_texture( GLuint Texture = NULL ) { m_texture = Texture; } set_texture( GLuint Texture = 0 ) { m_texture = Texture; }
void void
set_tooltip( std::string const &Tooltip ) { m_tooltip = Tooltip; } set_tooltip( std::string const &Tooltip ) { m_tooltip = Tooltip; }
void void
@@ -98,8 +98,8 @@ private:
std::string m_progresstext; // label placed over the progress bar std::string m_progresstext; // label placed over the progress bar
bool m_progressbottom { false }; // location of the progress bar bool m_progressbottom { false }; // location of the progress bar
texture_handle m_background { NULL }; // path to texture used as the background. size depends on mAspect. texture_handle m_background { null_handle }; // path to texture used as the background. size depends on mAspect.
GLuint m_texture { NULL }; GLuint m_texture { 0 };
std::vector<std::shared_ptr<ui_panel> > m_panels; std::vector<std::shared_ptr<ui_panel> > m_panels;
std::string m_tooltip; std::string m_tooltip;
}; };