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

configurable fullscreen monitors

This commit is contained in:
milek7
2019-02-21 00:06:51 +01:00
parent cbd640a6aa
commit 56584dc13e
7 changed files with 72 additions and 9 deletions

View File

@@ -3,6 +3,7 @@
#include "application.h"
#include "gl/shader.h"
#include "gl/vao.h"
#include "Logs.h"
void texture_window_fb_resize(GLFWwindow *win, int w, int h)
{
@@ -10,7 +11,7 @@ void texture_window_fb_resize(GLFWwindow *win, int w, int h)
texwindow->notify_window_size(w, h);
}
texture_window::texture_window(texture_handle src)
texture_window::texture_window(texture_handle src, std::string surfacename)
{
opengl_texture &tex = GfxRenderer.Texture(src);
tex.create();
@@ -18,8 +19,34 @@ texture_window::texture_window(texture_handle src)
glfwWindowHint(GLFW_VISIBLE, GLFW_TRUE);
int window_w = m_win_w, window_h = m_win_h;
{
int monitor_count;
GLFWmonitor **monitors = glfwGetMonitors(&monitor_count);
for (size_t i = 0; i < monitor_count; i++) {
const char *name = glfwGetMonitorName(monitors[i]);
int x, y;
glfwGetMonitorPos(monitors[i], &x, &y);
std::string desc = std::string(name) + ":" + std::to_string(x) + "," + std::to_string(y);
auto iter = Global.python_monitormap.find(surfacename);
if (iter != Global.python_monitormap.end()
&& (*iter).second == desc) {
monitor = monitors[i];
const GLFWvidmode *mode = glfwGetVideoMode(monitor);
window_w = mode->width;
window_h = mode->height;
break;
}
}
}
GLFWwindow *root = Application.window();
m_window = glfwCreateWindow(m_win_w, m_win_h, ("EU07: texture " + std::to_string(m_source)).c_str(), nullptr, root);
m_window = glfwCreateWindow(window_w, window_h, ("EU07: surface " + surfacename).c_str(), monitor, root);
glfwSetWindowUserPointer(m_window, this);
glfwSetFramebufferSizeCallback(m_window, texture_window_fb_resize);
@@ -54,7 +81,8 @@ void texture_window::threadfunc()
while (!m_exit)
{
// if texture resized, update window size (maybe not necessary?)
if (GLAD_GL_VERSION_3_3 || GLAD_GL_ES_VERSION_3_1)
// don't care when on fullscreen
if ((GLAD_GL_VERSION_3_3 || GLAD_GL_ES_VERSION_3_1) && !monitor)
{
int w, h;
glGetTexLevelParameteriv(GL_TEXTURE_2D, 0, GL_TEXTURE_WIDTH, &w);