mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-07-22 17:29:18 +02:00
python without submodel texture
This commit is contained in:
@@ -43,6 +43,7 @@ struct opengl_texture {
|
|||||||
height() const {
|
height() const {
|
||||||
return data_height; }
|
return data_height; }
|
||||||
|
|
||||||
|
void make_stub();
|
||||||
void alloc_rendertarget(GLint format, GLint components, int width, int height, int samples = 1, GLint wrap = GL_CLAMP_TO_BORDER);
|
void alloc_rendertarget(GLint format, GLint components, int width, int height, int samples = 1, GLint wrap = GL_CLAMP_TO_BORDER);
|
||||||
void set_components_hint(GLint hint);
|
void set_components_hint(GLint hint);
|
||||||
static void reset_unit_cache();
|
static void reset_unit_cache();
|
||||||
@@ -62,7 +63,6 @@ struct opengl_texture {
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
// methods
|
// methods
|
||||||
void make_stub();
|
|
||||||
void make_request();
|
void make_request();
|
||||||
void load_BMP();
|
void load_BMP();
|
||||||
void load_PNG();
|
void load_PNG();
|
||||||
|
|||||||
45
Train.cpp
45
Train.cpp
@@ -6102,7 +6102,7 @@ bool TTrain::Update( double const Deltatime )
|
|||||||
&& !FreeFlyModeFlag && simulation::Train == this ) { // don't bother if we're outside
|
&& !FreeFlyModeFlag && simulation::Train == this ) { // don't bother if we're outside
|
||||||
fScreenTimer = 0.f;
|
fScreenTimer = 0.f;
|
||||||
for( auto const &screen : m_screens ) {
|
for( auto const &screen : m_screens ) {
|
||||||
Application.request( { std::get<0>(screen), GetTrainState(), GfxRenderer.Texture( std::get<1>(screen) ).id } );
|
Application.request( { std::get<0>(screen), GetTrainState(), std::get<1>(screen) } );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// sounds
|
// sounds
|
||||||
@@ -6864,30 +6864,45 @@ bool TTrain::InitializeCab(int NewCabNo, std::string const &asFileName)
|
|||||||
>> submodelname
|
>> submodelname
|
||||||
>> renderername;
|
>> renderername;
|
||||||
|
|
||||||
auto const *submodel { ( DynamicObject->mdKabina ? DynamicObject->mdKabina->GetFromName( submodelname ) : nullptr ) };
|
opengl_texture *tex = nullptr;
|
||||||
if( submodel == nullptr ) {
|
if (submodelname != "none") {
|
||||||
WriteLog( "Python Screen: submodel " + submodelname + " not found - Ignoring screen" );
|
auto const *submodel { ( DynamicObject->mdKabina ? DynamicObject->mdKabina->GetFromName( submodelname ) : nullptr ) };
|
||||||
continue;
|
if( submodel == nullptr ) {
|
||||||
}
|
WriteLog( "Python Screen: submodel " + submodelname + " not found - Ignoring screen" );
|
||||||
auto const material { submodel->GetMaterial() };
|
continue;
|
||||||
if( material <= 0 ) {
|
}
|
||||||
// sub model nie posiada tekstury lub tekstura wymienna - nie obslugiwana
|
auto const material { submodel->GetMaterial() };
|
||||||
WriteLog( "Python Screen: invalid texture id " + std::to_string( material ) + " - Ignoring screen" );
|
if( material <= 0 ) {
|
||||||
continue;
|
// sub model nie posiada tekstury lub tekstura wymienna - nie obslugiwana
|
||||||
}
|
WriteLog( "Python Screen: invalid texture id " + std::to_string( material ) + " - Ignoring screen" );
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
texture_handle &tex = GfxRenderer.Material( material ).textures[0];
|
tex = &GfxRenderer.Texture(GfxRenderer.Material( material ).textures[0]);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
// TODO: fix leak
|
||||||
|
tex = new opengl_texture();
|
||||||
|
tex->make_stub();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!tex) {
|
||||||
|
WriteLog( "Python Screen: missing texture in screen " + submodelname + " - Ignoring screen" );
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
tex->create();
|
||||||
|
|
||||||
// record renderer and material binding for future update requests
|
// record renderer and material binding for future update requests
|
||||||
m_screens.emplace_back(
|
m_screens.emplace_back(
|
||||||
( substr_path(renderername).empty() ? // supply vehicle folder as path if none is provided
|
( substr_path(renderername).empty() ? // supply vehicle folder as path if none is provided
|
||||||
DynamicObject->asBaseDir + renderername :
|
DynamicObject->asBaseDir + renderername :
|
||||||
renderername ),
|
renderername ),
|
||||||
tex,
|
tex->id,
|
||||||
std::nullopt);
|
std::nullopt);
|
||||||
|
|
||||||
if (Global.python_displaywindows)
|
if (Global.python_displaywindows)
|
||||||
std::get<2>(m_screens.back()).emplace(tex, submodelname);
|
std::get<2>(m_screens.back()).emplace(tex->id, submodelname);
|
||||||
}
|
}
|
||||||
// btLampkaUnknown.Init("unknown",mdKabina,false);
|
// btLampkaUnknown.Init("unknown",mdKabina,false);
|
||||||
} while (token != "");
|
} while (token != "");
|
||||||
|
|||||||
2
Train.h
2
Train.h
@@ -665,7 +665,7 @@ private:
|
|||||||
bool m_mastercontrollerinuse { false };
|
bool m_mastercontrollerinuse { false };
|
||||||
float m_mastercontrollerreturndelay { 0.f };
|
float m_mastercontrollerreturndelay { 0.f };
|
||||||
int iRadioChannel { 1 }; // numer aktualnego kana?u radiowego
|
int iRadioChannel { 1 }; // numer aktualnego kana?u radiowego
|
||||||
std::vector<std::tuple<std::string, texture_handle, std::optional<texture_window>>> m_screens;
|
std::vector<std::tuple<std::string, GLuint, std::optional<texture_window>>> m_screens;
|
||||||
uint16_t vid { 0 };
|
uint16_t vid { 0 };
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|||||||
@@ -11,11 +11,9 @@ void texture_window_fb_resize(GLFWwindow *win, int w, int h)
|
|||||||
texwindow->notify_window_size(w, h);
|
texwindow->notify_window_size(w, h);
|
||||||
}
|
}
|
||||||
|
|
||||||
texture_window::texture_window(texture_handle src, std::string surfacename)
|
texture_window::texture_window(GLuint src, std::string surfacename)
|
||||||
{
|
{
|
||||||
opengl_texture &tex = GfxRenderer.Texture(src);
|
m_source = src;
|
||||||
tex.create();
|
|
||||||
m_source = tex.id;
|
|
||||||
|
|
||||||
int window_w = m_win_w, window_h = m_win_h;
|
int window_w = m_win_w, window_h = m_win_h;
|
||||||
|
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ class texture_window
|
|||||||
void threadfunc();
|
void threadfunc();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
texture_window(texture_handle src, std::string name);
|
texture_window(GLuint src, std::string name);
|
||||||
~texture_window();
|
~texture_window();
|
||||||
|
|
||||||
void notify_window_size(int w, int h);
|
void notify_window_size(int w, int h);
|
||||||
|
|||||||
Reference in New Issue
Block a user