mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-07-22 19:49:19 +02:00
configurable fullscreen monitors
This commit is contained in:
14
Globals.cpp
14
Globals.cpp
@@ -81,10 +81,14 @@ global_settings::ConfigParse(cParser &Parser) {
|
|||||||
}
|
}
|
||||||
else if (token == "fullscreen")
|
else if (token == "fullscreen")
|
||||||
{
|
{
|
||||||
|
|
||||||
Parser.getTokens();
|
Parser.getTokens();
|
||||||
Parser >> bFullScreen;
|
Parser >> bFullScreen;
|
||||||
}
|
}
|
||||||
|
else if (token == "fullscreenmonitor")
|
||||||
|
{
|
||||||
|
Parser.getTokens(1, false);
|
||||||
|
Parser >> fullscreen_monitor;
|
||||||
|
}
|
||||||
else if( token == "vsync" ) {
|
else if( token == "vsync" ) {
|
||||||
|
|
||||||
Parser.getTokens();
|
Parser.getTokens();
|
||||||
@@ -803,6 +807,14 @@ global_settings::ConfigParse(cParser &Parser) {
|
|||||||
Parser.getTokens(1);
|
Parser.getTokens(1);
|
||||||
Parser >> python_mipmaps;
|
Parser >> python_mipmaps;
|
||||||
}
|
}
|
||||||
|
else if (token == "python.monitormap")
|
||||||
|
{
|
||||||
|
Parser.getTokens(2, false);
|
||||||
|
std::string pythonscreen;
|
||||||
|
std::string monitorid;
|
||||||
|
Parser >> pythonscreen >> monitorid;
|
||||||
|
python_monitormap.emplace(std::make_pair(pythonscreen, monitorid));
|
||||||
|
}
|
||||||
else if (token == "network.server")
|
else if (token == "network.server")
|
||||||
{
|
{
|
||||||
Parser.getTokens(2);
|
Parser.getTokens(2);
|
||||||
|
|||||||
@@ -182,6 +182,9 @@ struct global_settings {
|
|||||||
|
|
||||||
std::chrono::duration<float> minframetime {0.0f};
|
std::chrono::duration<float> minframetime {0.0f};
|
||||||
|
|
||||||
|
std::unordered_map<std::string, std::string> python_monitormap;
|
||||||
|
std::string fullscreen_monitor;
|
||||||
|
|
||||||
bool python_mipmaps = true;
|
bool python_mipmaps = true;
|
||||||
bool python_displaywindows = false;
|
bool python_displaywindows = false;
|
||||||
bool python_threadedupload = true;
|
bool python_threadedupload = true;
|
||||||
|
|||||||
@@ -6755,7 +6755,7 @@ bool TTrain::InitializeCab(int NewCabNo, std::string const &asFileName)
|
|||||||
std::nullopt);
|
std::nullopt);
|
||||||
|
|
||||||
if (Global.python_displaywindows)
|
if (Global.python_displaywindows)
|
||||||
std::get<2>(m_screens.back()).emplace(tex);
|
std::get<2>(m_screens.back()).emplace(tex, submodelname);
|
||||||
}
|
}
|
||||||
// btLampkaUnknown.Init("unknown",mdKabina,false);
|
// btLampkaUnknown.Init("unknown",mdKabina,false);
|
||||||
} while (token != "");
|
} while (token != "");
|
||||||
|
|||||||
@@ -580,6 +580,24 @@ eu07_application::init_glfw() {
|
|||||||
// match requested video mode to current to allow for
|
// match requested video mode to current to allow for
|
||||||
// fullwindow creation when resolution is the same
|
// fullwindow creation when resolution is the same
|
||||||
auto *monitor { glfwGetPrimaryMonitor() };
|
auto *monitor { glfwGetPrimaryMonitor() };
|
||||||
|
{
|
||||||
|
int monitor_count;
|
||||||
|
GLFWmonitor **monitors = glfwGetMonitors(&monitor_count);
|
||||||
|
|
||||||
|
WriteLog("available monitors:");
|
||||||
|
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);
|
||||||
|
WriteLog(desc);
|
||||||
|
|
||||||
|
if (desc == Global.fullscreen_monitor)
|
||||||
|
monitor = monitors[i];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
auto const *vmode { glfwGetVideoMode( monitor ) };
|
auto const *vmode { glfwGetVideoMode( monitor ) };
|
||||||
|
|
||||||
glfwWindowHint( GLFW_RED_BITS, vmode->redBits );
|
glfwWindowHint( GLFW_RED_BITS, vmode->redBits );
|
||||||
|
|||||||
@@ -79,8 +79,9 @@ public:
|
|||||||
// gives access to specified window, creates a new window if index == -1
|
// gives access to specified window, creates a new window if index == -1
|
||||||
GLFWwindow *
|
GLFWwindow *
|
||||||
window( int const Windowindex = 0 );
|
window( int const Windowindex = 0 );
|
||||||
|
// generate network sync verification number
|
||||||
double generate_sync();
|
double
|
||||||
|
generate_sync();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// types
|
// types
|
||||||
|
|||||||
@@ -3,6 +3,7 @@
|
|||||||
#include "application.h"
|
#include "application.h"
|
||||||
#include "gl/shader.h"
|
#include "gl/shader.h"
|
||||||
#include "gl/vao.h"
|
#include "gl/vao.h"
|
||||||
|
#include "Logs.h"
|
||||||
|
|
||||||
void texture_window_fb_resize(GLFWwindow *win, int w, int 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);
|
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);
|
opengl_texture &tex = GfxRenderer.Texture(src);
|
||||||
tex.create();
|
tex.create();
|
||||||
@@ -18,8 +19,34 @@ texture_window::texture_window(texture_handle src)
|
|||||||
|
|
||||||
glfwWindowHint(GLFW_VISIBLE, GLFW_TRUE);
|
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();
|
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);
|
glfwSetWindowUserPointer(m_window, this);
|
||||||
glfwSetFramebufferSizeCallback(m_window, texture_window_fb_resize);
|
glfwSetFramebufferSizeCallback(m_window, texture_window_fb_resize);
|
||||||
@@ -54,7 +81,8 @@ void texture_window::threadfunc()
|
|||||||
while (!m_exit)
|
while (!m_exit)
|
||||||
{
|
{
|
||||||
// if texture resized, update window size (maybe not necessary?)
|
// 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;
|
int w, h;
|
||||||
glGetTexLevelParameteriv(GL_TEXTURE_2D, 0, GL_TEXTURE_WIDTH, &w);
|
glGetTexLevelParameteriv(GL_TEXTURE_2D, 0, GL_TEXTURE_WIDTH, &w);
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ class texture_window
|
|||||||
GLFWwindow *m_window;
|
GLFWwindow *m_window;
|
||||||
GLuint m_source;
|
GLuint m_source;
|
||||||
std::shared_ptr<std::thread> m_renderthread;
|
std::shared_ptr<std::thread> m_renderthread;
|
||||||
|
GLFWmonitor *monitor = nullptr;
|
||||||
|
|
||||||
bool m_exit = false;
|
bool m_exit = false;
|
||||||
|
|
||||||
@@ -15,7 +16,7 @@ class texture_window
|
|||||||
void threadfunc();
|
void threadfunc();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
texture_window(texture_handle src);
|
texture_window(texture_handle src, std::string name);
|
||||||
~texture_window();
|
~texture_window();
|
||||||
|
|
||||||
void notify_window_size(int w, int h);
|
void notify_window_size(int w, int h);
|
||||||
|
|||||||
Reference in New Issue
Block a user