mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-03-22 15:05:03 +01:00
python windows improvements
This commit is contained in:
@@ -76,6 +76,8 @@ void python_screen_viewer::threadfunc()
|
||||
|
||||
while (!m_exit)
|
||||
{
|
||||
auto start_time = std::chrono::high_resolution_clock::now();
|
||||
|
||||
for (auto &window : m_windows) {
|
||||
glfwMakeContextCurrent(window->window);
|
||||
gl::program::unbind();
|
||||
@@ -88,16 +90,38 @@ void python_screen_viewer::threadfunc()
|
||||
window->ubo->update(m_ubs);
|
||||
|
||||
if (!Global.python_sharectx) {
|
||||
std::lock_guard<std::mutex> guard(m_rt->mutex);
|
||||
unsigned char *image;
|
||||
int format, components, width, height;
|
||||
|
||||
if (!m_rt->image)
|
||||
continue;
|
||||
{
|
||||
std::lock_guard<std::mutex> guard(m_rt->mutex);
|
||||
|
||||
if (window->timestamp == m_rt->timestamp)
|
||||
continue;
|
||||
|
||||
if (!m_rt->image)
|
||||
continue;
|
||||
|
||||
format = m_rt->format;
|
||||
components = m_rt->components;
|
||||
width = m_rt->width;
|
||||
height = m_rt->height;
|
||||
|
||||
size_t size = width * height * (components == GL_RGB ? 3 : 4);
|
||||
|
||||
image = new unsigned char[size];
|
||||
memcpy(image, m_rt->image, size);
|
||||
|
||||
window->timestamp = m_rt->timestamp;
|
||||
}
|
||||
|
||||
glTexImage2D(
|
||||
GL_TEXTURE_2D, 0,
|
||||
m_rt->format,
|
||||
m_rt->width, m_rt->height, 0,
|
||||
m_rt->components, GL_UNSIGNED_BYTE, m_rt->image);
|
||||
format,
|
||||
width, height, 0,
|
||||
components, GL_UNSIGNED_BYTE, image);
|
||||
|
||||
delete[] image;
|
||||
|
||||
if (Global.python_mipmaps) {
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR);
|
||||
@@ -115,6 +139,11 @@ void python_screen_viewer::threadfunc()
|
||||
|
||||
glfwSwapBuffers(window->window);
|
||||
}
|
||||
|
||||
auto frametime = std::chrono::high_resolution_clock::now() - start_time;
|
||||
|
||||
if ((Global.python_minframetime - frametime).count() > 0.0f)
|
||||
std::this_thread::sleep_for(Global.minframetime - frametime);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user