-
Notifications
You must be signed in to change notification settings - Fork 12
updated macOS cocoa backend to correctly render instead of sdl2/3 #51
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
Thanks for the pull request, but could you split it into multiple requests? This one is doing a lot of different unrelated stuff. As it is right now I can't merge it as some things I don't agree with (at least without further discussion), while other things are okay and could be merged. Things in this pull request:
That is a lot of different things to include into one big mega PR. While there's plenty of stuff in it that's good and I'd love to merge, at the same time there are blocking parts (Widget class changes and Linux system font lookup in particular) that prevents me from simply pressing the merge button. We have to find a solution to this, or alternatively split it into multiple pull requests where most of them can then merged and rest be discussed. |
|
Yes, you are right in that the codebase is not atomic and also has a lot of opinionated changes that will need to be modularized or removed before a pull request.
|
|
Okay changes made, let me know if I've missed anything or you need further modifications. I'll try to be more careful in future with commits, to try commit atomically. I did notice that I tried compiling your latest ZVulkan library and glslang was complaining that the minimum macOS build version was 10.15. A few of the features I am using for macOS require 10.15 so I wonder if in the near future/next version it gets bumped to 10.15 minimum? Also in terms of the shader translation library, I think for now I'll stick to glsl->SPIR-V->msl and look into cross compiling from glslang to spirv-cross and potentially hlsl(maybe the windows application can compile it for dxc so the shader translator just has to supply hlsl). Not sure yet, I think I'll just try get metal working for now. But I appreciate all the guidance and help so far along with this journey and the patience. |
|
In terms of the GTK code, it was run in a headless environment for testing, I wonder if we can create some kind of better loader for Linux that will detect on all desktop environments what fonts are available and conditionally load them? I'm going to pick up an old PC, probably a 6th gen Intel or something for testing and also Linux/Haiku work. In terms of the incompatibility with macOS 10.13, maybe GZDoom 4.15 could be the last version to support this, then we can bump compatibility up to 10.15 to support modern graphical functionality. However allowing 4.15 to support 10.13 would still allow a lot of modern functionality for that OS and older Macs that can still use Metal 2. However there's no reason to have an ancient OS hobble further developments of the engine in the near future. I was thinking a compatibility fork but a better solution would be to just recommend older builds for unsupported OS's. Since the code is open anyway, people can always fork and support whatever they like if they feel the support is warranted. Even macOS 12.7.6 what I'm on is ancient by macOS standards and hopefully I can get an ARM based machine soon. |
|
Thanks for adjusting the PR. About the gtk thing, I can change it so it dynamically loads it so its not a hard dependency. If gtk is not found we can use the fallback strategy you had, asking fontconfig to give us a generic sans-serif font to at least have something. Our problem with Linux in general is that nothing is actually standardized as far as I know. Essentially the "system UI font" depends on the desktop environment you're using. If that is KDE then it uses whatever they do. If its Gnome it uses Gtk's method. If windowmaker is used, or who knows what else, there might not even be a formal way to query for it. The current implementation is based on the assumption that a lot of Linux applications already use Gtk. Because of that, even if the desktop environment is something different, a good distro should attempt to keep all the various popular app toolkits in sync with what you pick in the (desktop environment specific) control panel. That's just an assumption of mine, I haven't verified if that's what the distros do, but its the best I got. In a perfect world we'd have code for each of the popular desktop environments to find the system UI font. However, even if we did have that, we'd also need to know which one is active. Simply locating gtk on the system is actually not a guarantee that this is the desktop environment actively being used. About your questions for zvulkan, I don't have any problems with bumping the macOS version in CMakeLists.txt if that solves some problems for you. Having Direct3D HLSL translation is mostly a nice-to-have feature. Vulkan support is strong on anything else than Apple hardware. It is not like in the old days with OpenGL where Intel had very broken drivers. |
|
Hey dpjudas, I wonder for the font configuration we could cycle through the most popular widget toolkit detection dynamically(Qt based and GTK) then falling back to font_config, finally if all else fails just loading a bundled font. This might help for other OS's such as the BSD's in the near future as well. I agree about Vulkan being the premier and only necessary renderer on all platforms beside MacOS(I like native if possible). Especially with the advent of Valve's new Steam hardware which is Vulkan based, making the api more popular than ever. I was just thinking HLSL since apparently it's a very popular language and might help some developers port their mods to the engine coming from a Windows background since HLSL-SPIR-V is going to become more common. glslang also supports older versions of HLSL as far as I'm aware and maybe it might get new functionality if added though it currently lags behind DXC. In terms of ZVulkan, it's perfectly functional for now, I just noticed the project is macOS 10.13(first OS to use Metal 2) based and there's a few macOS 10.15 features in the new ZVulkan glslang version. It means either the current version of ZVulkan an older library would have to remain in future gzdoom versions or else we'll just have to bump support to 10.15 minimum. It's not the only library complaining either, there's things like dark mode in the main cocoa implementation that also require 10.15. Maybe a last version on 10.13 for 4.15 might be a good idea? I'll speak to the developers when I pull request the cocoa window code. n.b According to Gemini after a quick search, it should be fairly simple to detect using getenv() #include <iostream>
#include <cstdlib>
#include <string>
// Include necessary headers for the libraries (e.g., for glib/gsettings)
// #include <glib.h>
// #include <gio/gio.h>
std::string getSystemFontDynamically() {
const char* desktop_env = std::getenv("XDG_CURRENT_DESKTOP");
if (desktop_env != nullptr) {
std::string env_str = desktop_env;
if (env_str.find("GNOME") != std::string::npos) {
// Use GSettings C API to get the font name
// Example: GSettings *settings = g_settings_new("org.gnome.desktop.interface");
// GChar* font_name = g_settings_get_string(settings, "font-name");
// return std::string(font_name);
return "GNOME Font Logic Needed";
} else if (env_str.find("KDE") != std::string::npos || env_str.find("Plasma") != std::string::npos) {
// Use KConfig C++ API to get the font name
// return "KDE Font Logic Needed";
} else if (env_str.find("XFCE") != std::string::npos) {
// Use Xfconf C API
// return "XFCE Font Logic Needed";
}
}
// Fallback using Fontconfig C API (universal)
// You would link against -lfontconfig
/*
FcPattern* pattern = FcPatternCreate();
// ... use FcFontMatch to find default font path
FcPatternDestroy(pattern);
*/
return "Fontconfig Default Fallback";
}
// In a real application, you would link the appropriate libraries
// and handle memory management (e.g., g_free for glib). |
So it turns out the reason the sdl2 libraries were needed was that the code wasn't calling the native cocoa backend. I've updated and tested the code to work with the native libraries and fixed a few bugs that were present because of that, now alleviating the need for sdl2 unless explicitly set. Sorry about that, a bit embarrassing.