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

python screen windows without context sharing

This commit is contained in:
milek7
2019-03-18 17:02:54 +01:00
parent efb041aaa0
commit 99e7ef5513
12 changed files with 156 additions and 54 deletions

View File

@@ -45,7 +45,7 @@ void render_task::run() {
// upload texture data
if( ( outputwidth != nullptr )
&& ( outputheight != nullptr )
&& m_target != -1) {
&& m_target) {
m_width = PyInt_AsLong( outputwidth );
m_height = PyInt_AsLong( outputheight );
@@ -86,13 +86,29 @@ void render_task::upload()
{
if (m_image)
{
glBindTexture(GL_TEXTURE_2D, m_target);
glBindTexture(GL_TEXTURE_2D, m_target->shared_tex);
glTexImage2D(
GL_TEXTURE_2D, 0,
m_format,
m_width, m_height, 0,
m_components, GL_UNSIGNED_BYTE, m_image);
{
std::lock_guard<std::mutex> guard(m_target->mutex);
if (m_target->image)
delete[] m_target->image;
size_t size = m_width * m_height * (m_components == GL_RGB ? 3 : 4);
m_target->image = new unsigned char[size];
memcpy(m_target->image, m_image, size);
m_target->width = m_width;
m_target->height = m_height;
m_target->components = m_components;
m_target->format = m_format;
}
delete[] m_image;
if (Global.python_mipmaps)