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

python without submodel texture

This commit is contained in:
milek7
2019-03-12 23:11:31 +01:00
parent dba2308997
commit 38ea3f5737
5 changed files with 35 additions and 22 deletions

View File

@@ -43,6 +43,7 @@ struct opengl_texture {
height() const {
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 set_components_hint(GLint hint);
static void reset_unit_cache();
@@ -62,7 +63,6 @@ struct opengl_texture {
private:
// methods
void make_stub();
void make_request();
void load_BMP();
void load_PNG();

View File

@@ -6102,7 +6102,7 @@ bool TTrain::Update( double const Deltatime )
&& !FreeFlyModeFlag && simulation::Train == this ) { // don't bother if we're outside
fScreenTimer = 0.f;
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
@@ -6864,30 +6864,45 @@ bool TTrain::InitializeCab(int NewCabNo, std::string const &asFileName)
>> submodelname
>> renderername;
auto const *submodel { ( DynamicObject->mdKabina ? DynamicObject->mdKabina->GetFromName( submodelname ) : nullptr ) };
if( submodel == nullptr ) {
WriteLog( "Python Screen: submodel " + submodelname + " not found - Ignoring screen" );
continue;
}
auto const material { submodel->GetMaterial() };
if( material <= 0 ) {
// sub model nie posiada tekstury lub tekstura wymienna - nie obslugiwana
WriteLog( "Python Screen: invalid texture id " + std::to_string( material ) + " - Ignoring screen" );
continue;
}
opengl_texture *tex = nullptr;
if (submodelname != "none") {
auto const *submodel { ( DynamicObject->mdKabina ? DynamicObject->mdKabina->GetFromName( submodelname ) : nullptr ) };
if( submodel == nullptr ) {
WriteLog( "Python Screen: submodel " + submodelname + " not found - Ignoring screen" );
continue;
}
auto const material { submodel->GetMaterial() };
if( material <= 0 ) {
// 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
m_screens.emplace_back(
( substr_path(renderername).empty() ? // supply vehicle folder as path if none is provided
DynamicObject->asBaseDir + renderername :
renderername ),
tex,
tex->id,
std::nullopt);
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);
} while (token != "");

View File

@@ -665,7 +665,7 @@ private:
bool m_mastercontrollerinuse { false };
float m_mastercontrollerreturndelay { 0.f };
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 };
public:

View File

@@ -11,11 +11,9 @@ void texture_window_fb_resize(GLFWwindow *win, int w, int 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);
tex.create();
m_source = tex.id;
m_source = src;
int window_w = m_win_w, window_h = m_win_h;

View File

@@ -16,7 +16,7 @@ class texture_window
void threadfunc();
public:
texture_window(texture_handle src, std::string name);
texture_window(GLuint src, std::string name);
~texture_window();
void notify_window_size(int w, int h);