python task queue texture binding tweak, python task queue crash fix

This commit is contained in:
tmj-fstate
2018-10-12 22:07:42 +02:00
parent 7cf06246a6
commit 68f82be451
5 changed files with 10 additions and 7 deletions

View File

@@ -71,5 +71,6 @@ enum class TCommandType
};
using material_handle = int;
using texture_handle = int;
#endif

View File

@@ -27,7 +27,7 @@ void render_task::run() {
if( ( outputwidth != nullptr )
&& ( outputheight != nullptr ) ) {
GfxRenderer.Bind_Material( m_target );
::glBindTexture( GL_TEXTURE_2D, GfxRenderer.Texture( m_target ).id );
// setup texture parameters
::glTexParameteri( GL_TEXTURE_2D, GL_GENERATE_MIPMAP, GL_TRUE );
::glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR );

View File

@@ -29,7 +29,7 @@ class render_task {
public:
// constructors
render_task( PyObject *Renderer, PyObject *Input, material_handle Target ) :
render_task( PyObject *Renderer, PyObject *Input, texture_handle Target ) :
m_renderer( Renderer ), m_input( Input ), m_target( Target )
{}
// methods
@@ -39,7 +39,7 @@ private:
// members
PyObject *m_renderer {nullptr};
PyObject *m_input { nullptr };
material_handle m_target { null_handle };
texture_handle m_target { null_handle };
};
class python_taskqueue {
@@ -50,7 +50,7 @@ public:
std::string const &renderer;
PyObject *input;
material_handle target;
texture_handle target;
};
// constructors
python_taskqueue() = default;

View File

@@ -29,6 +29,7 @@ http://mozilla.org/MPL/2.0/.
#include "mtable.h"
#include "Console.h"
#include "application.h"
#include "renderer.h"
namespace input {
@@ -449,9 +450,9 @@ PyObject *TTrain::GetTrainState() {
auto const *mover = DynamicObject->MoverParameters;
PyEval_AcquireLock();
auto *dict = PyDict_New();
PyEval_ReleaseLock();
if( ( dict == nullptr )
|| ( mover == nullptr ) ) {
PyEval_ReleaseLock();
return nullptr;
}
@@ -581,6 +582,7 @@ PyObject *TTrain::GetTrainState() {
PyDict_SetItemString( dict, "seconds", PyGetInt( simulation::Time.second() ) );
PyDict_SetItemString( dict, "air_temperature", PyGetInt( Global.AirTemperature ) );
PyEval_ReleaseLock();
return dict;
}
@@ -6792,7 +6794,7 @@ bool TTrain::InitializeCab(int NewCabNo, std::string const &asFileName)
( substr_path(renderername).empty() ? // supply vehicle folder as path if none is provided
DynamicObject->asBaseDir + renderername :
renderername ),
material );
GfxRenderer.Material( material ).texture1 );
}
// btLampkaUnknown.Init("unknown",mdKabina,false);
} while (token != "");

View File

@@ -670,7 +670,7 @@ private:
// McZapkie: do syczenia
float fPPress, fNPress;
int iRadioChannel { 1 }; // numer aktualnego kana?u radiowego
std::vector<std::pair<std::string, material_handle>> m_screens;
std::vector<std::pair<std::string, texture_handle>> m_screens;
public:
float fPress[20][3]; // cisnienia dla wszystkich czlonow