feat: updated engine version to 4.4

This commit is contained in:
Sara 2025-03-17 10:43:25 +01:00
parent d08586768d
commit ba58baf432
140 changed files with 108317 additions and 14666 deletions

View file

@ -856,9 +856,9 @@ bool EditorExportPlatformAndroid::_has_manage_external_storage_permission(const
}
bool EditorExportPlatformAndroid::_uses_vulkan() {
String current_renderer = GLOBAL_GET("rendering/renderer/rendering_method.mobile");
bool uses_vulkan = (current_renderer == "forward_plus" || current_renderer == "mobile") && GLOBAL_GET("rendering/rendering_device/driver.android") == "vulkan";
return uses_vulkan;
String rendering_method = GLOBAL_GET("rendering/renderer/rendering_method.mobile");
String rendering_driver = GLOBAL_GET("rendering/rendering_device/driver.android");
return (rendering_method == "forward_plus" || rendering_method == "mobile") && rendering_driver == "vulkan";
}
void EditorExportPlatformAndroid::_notification(int p_what) {

View file

@ -34,13 +34,20 @@
#include "editor/editor_interface.h"
#include "editor/editor_node.h"
#include "editor/plugins/game_view_plugin.h"
static GameViewPlugin *_get_game_view_plugin() {
ERR_FAIL_NULL_V(EditorNode::get_singleton(), nullptr);
ERR_FAIL_NULL_V(EditorNode::get_singleton()->get_editor_main_screen(), nullptr);
return Object::cast_to<GameViewPlugin>(EditorNode::get_singleton()->get_editor_main_screen()->get_plugin_by_name("Game"));
}
#endif
extern "C" {
JNIEXPORT void JNICALL Java_org_godotengine_godot_utils_GameMenuUtils_setSuspend(JNIEnv *env, jclass clazz, jboolean enabled) {
#ifdef TOOLS_ENABLED
GameViewPlugin *game_view_plugin = Object::cast_to<GameViewPlugin>(EditorNode::get_singleton()->get_editor_main_screen()->get_plugin_by_name("Game"));
GameViewPlugin *game_view_plugin = _get_game_view_plugin();
if (game_view_plugin != nullptr && game_view_plugin->get_debugger().is_valid()) {
game_view_plugin->get_debugger()->set_suspend(enabled);
}
@ -49,7 +56,7 @@ JNIEXPORT void JNICALL Java_org_godotengine_godot_utils_GameMenuUtils_setSuspend
JNIEXPORT void JNICALL Java_org_godotengine_godot_utils_GameMenuUtils_nextFrame(JNIEnv *env, jclass clazz) {
#ifdef TOOLS_ENABLED
GameViewPlugin *game_view_plugin = Object::cast_to<GameViewPlugin>(EditorNode::get_singleton()->get_editor_main_screen()->get_plugin_by_name("Game"));
GameViewPlugin *game_view_plugin = _get_game_view_plugin();
if (game_view_plugin != nullptr && game_view_plugin->get_debugger().is_valid()) {
game_view_plugin->get_debugger()->next_frame();
}
@ -58,7 +65,7 @@ JNIEXPORT void JNICALL Java_org_godotengine_godot_utils_GameMenuUtils_nextFrame(
JNIEXPORT void JNICALL Java_org_godotengine_godot_utils_GameMenuUtils_setNodeType(JNIEnv *env, jclass clazz, jint type) {
#ifdef TOOLS_ENABLED
GameViewPlugin *game_view_plugin = Object::cast_to<GameViewPlugin>(EditorNode::get_singleton()->get_editor_main_screen()->get_plugin_by_name("Game"));
GameViewPlugin *game_view_plugin = _get_game_view_plugin();
if (game_view_plugin != nullptr && game_view_plugin->get_debugger().is_valid()) {
game_view_plugin->get_debugger()->set_node_type(type);
}
@ -67,7 +74,7 @@ JNIEXPORT void JNICALL Java_org_godotengine_godot_utils_GameMenuUtils_setNodeTyp
JNIEXPORT void JNICALL Java_org_godotengine_godot_utils_GameMenuUtils_setSelectMode(JNIEnv *env, jclass clazz, jint mode) {
#ifdef TOOLS_ENABLED
GameViewPlugin *game_view_plugin = Object::cast_to<GameViewPlugin>(EditorNode::get_singleton()->get_editor_main_screen()->get_plugin_by_name("Game"));
GameViewPlugin *game_view_plugin = _get_game_view_plugin();
if (game_view_plugin != nullptr && game_view_plugin->get_debugger().is_valid()) {
game_view_plugin->get_debugger()->set_select_mode(mode);
}
@ -76,7 +83,7 @@ JNIEXPORT void JNICALL Java_org_godotengine_godot_utils_GameMenuUtils_setSelectM
JNIEXPORT void JNICALL Java_org_godotengine_godot_utils_GameMenuUtils_setSelectionVisible(JNIEnv *env, jclass clazz, jboolean visible) {
#ifdef TOOLS_ENABLED
GameViewPlugin *game_view_plugin = Object::cast_to<GameViewPlugin>(EditorNode::get_singleton()->get_editor_main_screen()->get_plugin_by_name("Game"));
GameViewPlugin *game_view_plugin = _get_game_view_plugin();
if (game_view_plugin != nullptr && game_view_plugin->get_debugger().is_valid()) {
game_view_plugin->get_debugger()->set_selection_visible(visible);
}
@ -85,7 +92,7 @@ JNIEXPORT void JNICALL Java_org_godotengine_godot_utils_GameMenuUtils_setSelecti
JNIEXPORT void JNICALL Java_org_godotengine_godot_utils_GameMenuUtils_setCameraOverride(JNIEnv *env, jclass clazz, jboolean enabled) {
#ifdef TOOLS_ENABLED
GameViewPlugin *game_view_plugin = Object::cast_to<GameViewPlugin>(EditorNode::get_singleton()->get_editor_main_screen()->get_plugin_by_name("Game"));
GameViewPlugin *game_view_plugin = _get_game_view_plugin();
if (game_view_plugin != nullptr && game_view_plugin->get_debugger().is_valid()) {
game_view_plugin->get_debugger()->set_camera_override(enabled);
}
@ -94,7 +101,7 @@ JNIEXPORT void JNICALL Java_org_godotengine_godot_utils_GameMenuUtils_setCameraO
JNIEXPORT void JNICALL Java_org_godotengine_godot_utils_GameMenuUtils_setCameraManipulateMode(JNIEnv *env, jclass clazz, jint mode) {
#ifdef TOOLS_ENABLED
GameViewPlugin *game_view_plugin = Object::cast_to<GameViewPlugin>(EditorNode::get_singleton()->get_editor_main_screen()->get_plugin_by_name("Game"));
GameViewPlugin *game_view_plugin = _get_game_view_plugin();
if (game_view_plugin != nullptr && game_view_plugin->get_debugger().is_valid()) {
game_view_plugin->get_debugger()->set_camera_manipulate_mode(static_cast<EditorDebuggerNode::CameraOverride>(mode));
}
@ -103,7 +110,7 @@ JNIEXPORT void JNICALL Java_org_godotengine_godot_utils_GameMenuUtils_setCameraM
JNIEXPORT void JNICALL Java_org_godotengine_godot_utils_GameMenuUtils_resetCamera2DPosition(JNIEnv *env, jclass clazz) {
#ifdef TOOLS_ENABLED
GameViewPlugin *game_view_plugin = Object::cast_to<GameViewPlugin>(EditorNode::get_singleton()->get_editor_main_screen()->get_plugin_by_name("Game"));
GameViewPlugin *game_view_plugin = _get_game_view_plugin();
if (game_view_plugin != nullptr && game_view_plugin->get_debugger().is_valid()) {
game_view_plugin->get_debugger()->reset_camera_2d_position();
}
@ -112,7 +119,7 @@ JNIEXPORT void JNICALL Java_org_godotengine_godot_utils_GameMenuUtils_resetCamer
JNIEXPORT void JNICALL Java_org_godotengine_godot_utils_GameMenuUtils_resetCamera3DPosition(JNIEnv *env, jclass clazz) {
#ifdef TOOLS_ENABLED
GameViewPlugin *game_view_plugin = Object::cast_to<GameViewPlugin>(EditorNode::get_singleton()->get_editor_main_screen()->get_plugin_by_name("Game"));
GameViewPlugin *game_view_plugin = _get_game_view_plugin();
if (game_view_plugin != nullptr && game_view_plugin->get_debugger().is_valid()) {
game_view_plugin->get_debugger()->reset_camera_3d_position();
}
@ -121,7 +128,9 @@ JNIEXPORT void JNICALL Java_org_godotengine_godot_utils_GameMenuUtils_resetCamer
JNIEXPORT void JNICALL Java_org_godotengine_godot_utils_GameMenuUtils_playMainScene(JNIEnv *env, jclass clazz) {
#ifdef TOOLS_ENABLED
EditorInterface::get_singleton()->play_main_scene();
if (EditorInterface::get_singleton()) {
EditorInterface::get_singleton()->play_main_scene();
}
#endif
}
}

View file

@ -1,7 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="GodotEditorTheme" parent="@android:style/Theme.DeviceDefault.NoActionBar.Fullscreen">
<item name ="android:windowDrawsSystemBarBackgrounds">false</item>
<item name="android:statusBarColor">@android:color/transparent</item>
<item name ="android:navigationBarColor">@android:color/transparent</item>
</style>
<style name="GodotEditorSplashScreenTheme" parent="Theme.SplashScreen.IconBackground">

View file

@ -664,6 +664,8 @@ class Godot(private val context: Context) {
* Configuration change callback
*/
fun onConfigurationChanged(newConfig: Configuration) {
renderView?.inputHandler?.onConfigurationChanged(newConfig)
val newDarkMode = newConfig.uiMode.and(Configuration.UI_MODE_NIGHT_MASK) == Configuration.UI_MODE_NIGHT_YES
if (darkMode != newDarkMode) {
darkMode = newDarkMode
@ -823,10 +825,11 @@ class Godot(private val context: Context) {
* Returns true if `Vulkan` is used for rendering.
*/
private fun usesVulkan(): Boolean {
var rendererSource = "ProjectSettings"
var renderer = GodotLib.getGlobal("rendering/renderer/rendering_method")
val rendererInfo = GodotLib.getRendererInfo()
var renderingDeviceSource = "ProjectSettings"
var renderingDevice = GodotLib.getGlobal("rendering/rendering_device/driver")
var renderingDevice = rendererInfo[0]
var rendererSource = "ProjectSettings"
var renderer = rendererInfo[1]
val cmdline = getCommandLine()
var index = cmdline.indexOf("--rendering-method")
if (index > -1 && cmdline.size > index + 1) {

View file

@ -189,6 +189,15 @@ public class GodotLib {
*/
public static native String getGlobal(String p_key);
/**
* Used to get info about the current rendering system.
*
* @return A String array with two elements:
* [0] Rendering driver name.
* [1] Rendering method.
*/
public static native String[] getRendererInfo();
/**
* Used to access Godot's editor settings.
* @param settingKey Setting key

View file

@ -37,6 +37,7 @@ import org.godotengine.godot.GodotLib;
import org.godotengine.godot.GodotRenderView;
import android.content.Context;
import android.content.res.Configuration;
import android.hardware.Sensor;
import android.hardware.SensorEvent;
import android.hardware.SensorEventListener;
@ -86,6 +87,8 @@ public class GodotInputHandler implements InputManager.InputDeviceListener, Sens
private int rotaryInputAxis = ROTARY_INPUT_VERTICAL_AXIS;
private int cachedRotation = -1;
public GodotInputHandler(Context context, Godot godot) {
this.godot = godot;
mInputManager = (InputManager)context.getSystemService(Context.INPUT_SERVICE);
@ -741,10 +744,14 @@ public class GodotInputHandler implements InputManager.InputDeviceListener, Sens
return;
}
if (cachedRotation == -1) {
updateCachedRotation();
}
float rotatedValue0 = 0f;
float rotatedValue1 = 0f;
float rotatedValue2 = 0f;
switch (windowManager.getDefaultDisplay().getRotation()) {
switch (cachedRotation) {
case Surface.ROTATION_0:
rotatedValue0 = values[0];
rotatedValue1 = values[1];
@ -776,4 +783,12 @@ public class GodotInputHandler implements InputManager.InputDeviceListener, Sens
@Override
public void onAccuracyChanged(Sensor sensor, int accuracy) {}
private void updateCachedRotation() {
cachedRotation = windowManager.getDefaultDisplay().getRotation();
}
public void onConfigurationChanged(Configuration newConfig) {
updateCachedRotation();
}
}

View file

@ -474,6 +474,17 @@ JNIEXPORT jstring JNICALL Java_org_godotengine_godot_GodotLib_getGlobal(JNIEnv *
return env->NewStringUTF(setting_value.utf8().get_data());
}
JNIEXPORT jobjectArray JNICALL Java_org_godotengine_godot_GodotLib_getRendererInfo(JNIEnv *env, jclass clazz) {
String rendering_driver = RenderingServer::get_singleton()->get_current_rendering_driver_name();
String rendering_method = RenderingServer::get_singleton()->get_current_rendering_method();
jobjectArray result = env->NewObjectArray(2, env->FindClass("java/lang/String"), nullptr);
env->SetObjectArrayElement(result, 0, env->NewStringUTF(rendering_driver.utf8().get_data()));
env->SetObjectArrayElement(result, 1, env->NewStringUTF(rendering_method.utf8().get_data()));
return result;
}
JNIEXPORT jstring JNICALL Java_org_godotengine_godot_GodotLib_getEditorSetting(JNIEnv *env, jclass clazz, jstring p_setting_key) {
String editor_setting_value = "";
#ifdef TOOLS_ENABLED

View file

@ -61,6 +61,7 @@ JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_gyroscope(JNIEnv *env
JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_focusin(JNIEnv *env, jclass clazz);
JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_focusout(JNIEnv *env, jclass clazz);
JNIEXPORT jstring JNICALL Java_org_godotengine_godot_GodotLib_getGlobal(JNIEnv *env, jclass clazz, jstring path);
JNIEXPORT jobjectArray JNICALL Java_org_godotengine_godot_GodotLib_getRendererInfo(JNIEnv *env, jclass clazz);
JNIEXPORT jstring JNICALL Java_org_godotengine_godot_GodotLib_getEditorSetting(JNIEnv *env, jclass clazz, jstring p_setting_key);
JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_setEditorSetting(JNIEnv *env, jclass clazz, jstring p_key, jobject p_data);
JNIEXPORT jobject JNICALL Java_org_godotengine_godot_GodotLib_getEditorProjectMetadata(JNIEnv *env, jclass clazz, jstring p_section, jstring p_key, jobject p_default_value);

View file

@ -2540,7 +2540,9 @@ bool EditorExportPlatformIOS::has_valid_export_configuration(const Ref<EditorExp
}
}
if (GLOBAL_GET("rendering/rendering_device/driver.ios") == "metal") {
String rendering_method = GLOBAL_GET("rendering/renderer/rendering_method.mobile");
String rendering_driver = GLOBAL_GET("rendering/rendering_device/driver.ios");
if ((rendering_method == "forward_plus" || rendering_method == "mobile") && rendering_driver == "metal") {
float version = p_preset->get("application/min_ios_version").operator String().to_float();
if (version < 14.0) {
err += TTR("Metal renderer require iOS 14+.") + "\n";

View file

@ -57,6 +57,10 @@ static void handle_crash(int sig) {
abort();
}
if (OS::get_singleton()->is_crash_handler_silent()) {
std::_Exit(0);
}
void *bt_buffer[256];
size_t size = backtrace(bt_buffer, 256);
String _execpath = OS::get_singleton()->get_executable_path();

View file

@ -2171,7 +2171,10 @@ void DisplayServerX11::window_set_current_screen(int p_screen, WindowID p_window
return;
}
ERR_FAIL_COND_MSG(wd.embed_parent, "Embedded window can't be moved to another screen.");
if (wd.embed_parent) {
print_line("Embedded window can't be moved to another screen.");
return;
}
if (window_get_mode(p_window) == WINDOW_MODE_FULLSCREEN || window_get_mode(p_window) == WINDOW_MODE_MAXIMIZED) {
Point2i position = screen_get_position(p_screen);
@ -2330,7 +2333,10 @@ void DisplayServerX11::window_set_position(const Point2i &p_position, WindowID p
ERR_FAIL_COND(!windows.has(p_window));
WindowData &wd = windows[p_window];
ERR_FAIL_COND_MSG(wd.embed_parent, "Embedded window can't be moved.");
if (wd.embed_parent) {
print_line("Embedded window can't be moved.");
return;
}
int x = 0;
int y = 0;
@ -2364,7 +2370,10 @@ void DisplayServerX11::window_set_max_size(const Size2i p_size, WindowID p_windo
ERR_FAIL_COND(!windows.has(p_window));
WindowData &wd = windows[p_window];
ERR_FAIL_COND_MSG(wd.embed_parent, "Embedded windows can't have a maximum size.");
if (wd.embed_parent) {
print_line("Embedded windows can't have a maximum size.");
return;
}
if ((p_size != Size2i()) && ((p_size.x < wd.min_size.x) || (p_size.y < wd.min_size.y))) {
ERR_PRINT("Maximum window size can't be smaller than minimum window size!");
@ -2391,7 +2400,10 @@ void DisplayServerX11::window_set_min_size(const Size2i p_size, WindowID p_windo
ERR_FAIL_COND(!windows.has(p_window));
WindowData &wd = windows[p_window];
ERR_FAIL_COND_MSG(wd.embed_parent, "Embedded windows can't have a minimum size.");
if (wd.embed_parent) {
print_line("Embedded windows can't have a minimum size.");
return;
}
if ((p_size != Size2i()) && (wd.max_size != Size2i()) && ((p_size.x > wd.max_size.x) || (p_size.y > wd.max_size.y))) {
ERR_PRINT("Minimum window size can't be larger than maximum window size!");
@ -2422,7 +2434,10 @@ void DisplayServerX11::window_set_size(const Size2i p_size, WindowID p_window) {
WindowData &wd = windows[p_window];
ERR_FAIL_COND_MSG(wd.embed_parent, "Embedded window can't be resized.");
if (wd.embed_parent) {
print_line("Embedded window can't be resized.");
return;
}
if (wd.size.width == size.width && wd.size.height == size.height) {
return;
@ -2842,7 +2857,10 @@ void DisplayServerX11::window_set_mode(WindowMode p_mode, WindowID p_window) {
return; // do nothing
}
ERR_FAIL_COND_MSG(p_mode != WINDOW_MODE_WINDOWED && wd.embed_parent, "Embedded window only supports Windowed mode.");
if (p_mode != WINDOW_MODE_WINDOWED && wd.embed_parent) {
print_line("Embedded window only supports Windowed mode.");
return;
}
// Remove all "extra" modes.
switch (old_mode) {
@ -2944,7 +2962,10 @@ void DisplayServerX11::window_set_flag(WindowFlags p_flag, bool p_enabled, Windo
switch (p_flag) {
case WINDOW_FLAG_RESIZE_DISABLED: {
ERR_FAIL_COND_MSG(p_enabled && wd.embed_parent, "Embedded window resize can't be disabled.");
if (p_enabled && wd.embed_parent) {
print_line("Embedded window resize can't be disabled.");
return;
}
wd.resize_disabled = p_enabled;
_update_size_hints(p_window);
@ -2971,7 +2992,10 @@ void DisplayServerX11::window_set_flag(WindowFlags p_flag, bool p_enabled, Windo
} break;
case WINDOW_FLAG_ALWAYS_ON_TOP: {
ERR_FAIL_COND_MSG(wd.transient_parent != INVALID_WINDOW_ID, "Can't make a window transient if the 'on top' flag is active.");
ERR_FAIL_COND_MSG(p_enabled && wd.embed_parent, "Embedded window can't become on top.");
if (p_enabled && wd.embed_parent) {
print_line("Embedded window can't become on top.");
return;
}
if (p_enabled && wd.fullscreen) {
_set_wm_maximized(p_window, true);
}
@ -3013,7 +3037,10 @@ void DisplayServerX11::window_set_flag(WindowFlags p_flag, bool p_enabled, Windo
ERR_FAIL_COND_MSG(p_window == MAIN_WINDOW_ID, "Main window can't be popup.");
ERR_FAIL_COND_MSG((xwa.map_state == IsViewable) && (wd.is_popup != p_enabled), "Popup flag can't changed while window is opened.");
ERR_FAIL_COND_MSG(p_enabled && wd.embed_parent, "Embedded window can't be popup.");
if (p_enabled && wd.embed_parent) {
print_line("Embedded window can't be popup.");
return;
}
wd.is_popup = p_enabled;
} break;
default: {

View file

@ -81,6 +81,10 @@ static void handle_crash(int sig) {
abort();
}
if (OS::get_singleton()->is_crash_handler_silent()) {
std::_Exit(0);
}
void *bt_buffer[256];
size_t size = backtrace(bt_buffer, 256);
String _execpath = OS::get_singleton()->get_executable_path();

View file

@ -3791,8 +3791,11 @@ DisplayServerMacOS::DisplayServerMacOS(const String &p_rendering_driver, WindowM
#if defined(VULKAN_ENABLED)
#if defined(__x86_64__)
bool fallback_to_vulkan = GLOBAL_GET("rendering/rendering_device/fallback_to_vulkan");
if (!fallback_to_vulkan) {
WARN_PRINT("Metal is not supported on Intel Macs, switching to Vulkan.");
}
// Metal rendering driver not available on Intel.
if (fallback_to_vulkan && rendering_driver == "metal") {
if (rendering_driver == "metal") {
rendering_driver = "vulkan";
OS::get_singleton()->set_current_rendering_driver_name(rendering_driver);
}

View file

@ -41,6 +41,7 @@
// Backtrace code based on: https://stackoverflow.com/questions/6205981/windows-c-stack-trace-from-a-running-app
#include <algorithm>
#include <cstdlib>
#include <iterator>
#include <string>
#include <vector>
@ -127,6 +128,10 @@ DWORD CrashHandlerException(EXCEPTION_POINTERS *ep) {
return EXCEPTION_CONTINUE_SEARCH;
}
if (OS::get_singleton()->is_crash_handler_silent()) {
std::_Exit(0);
}
String msg;
const ProjectSettings *proj_settings = ProjectSettings::get_singleton();
if (proj_settings) {

View file

@ -41,6 +41,7 @@
#include <cxxabi.h>
#include <signal.h>
#include <algorithm>
#include <cstdlib>
#include <iterator>
#include <string>
#include <vector>
@ -133,6 +134,10 @@ extern void CrashHandlerException(int signal) {
return;
}
if (OS::get_singleton()->is_crash_handler_silent()) {
std::_Exit(0);
}
String msg;
const ProjectSettings *proj_settings = ProjectSettings::get_singleton();
if (proj_settings) {

View file

@ -732,7 +732,7 @@ def configure_mingw(env: "SConsEnvironment"):
if env["use_static_cpp"]:
env.Append(LINKFLAGS=["-static"])
if env["arch"] in ["x86_32", "x86_64"]:
if env["arch"] == "x86_32":
env["x86_libtheora_opt_gcc"] = True
env.Append(CCFLAGS=["-ffp-contract=off"])

View file

@ -83,11 +83,6 @@
#define WM_INDICATOR_CALLBACK_MESSAGE (WM_USER + 1)
#if defined(__GNUC__)
// Workaround GCC warning from -Wcast-function-type.
#define GetProcAddress (void *)GetProcAddress
#endif
static String format_error_message(DWORD id) {
LPWSTR messageBuffer = nullptr;
size_t size = FormatMessageW(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS,
@ -1294,7 +1289,7 @@ static int QueryDpiForMonitor(HMONITOR hmon, _MonitorDpiType dpiType = MDT_Defau
if (Shcore == nullptr) {
Shcore = LoadLibraryW(L"Shcore.dll");
getDPIForMonitor = Shcore ? (GetDPIForMonitor_t)GetProcAddress(Shcore, "GetDpiForMonitor") : nullptr;
getDPIForMonitor = Shcore ? (GetDPIForMonitor_t)(void *)GetProcAddress(Shcore, "GetDpiForMonitor") : nullptr;
if ((Shcore == nullptr) || (getDPIForMonitor == nullptr)) {
if (Shcore) {
@ -1974,7 +1969,10 @@ void DisplayServerWindows::window_set_current_screen(int p_screen, WindowID p_wi
return;
}
const WindowData &wd = windows[p_window];
ERR_FAIL_COND_MSG(wd.parent_hwnd, "Embedded window can't be moved to another screen.");
if (wd.parent_hwnd) {
print_line("Embedded window can't be moved to another screen.");
return;
}
if (wd.fullscreen) {
Point2 pos = screen_get_position(p_screen) + _get_screens_origin();
Size2 size = screen_get_size(p_screen);
@ -2055,7 +2053,10 @@ void DisplayServerWindows::window_set_position(const Point2i &p_position, Window
ERR_FAIL_COND(!windows.has(p_window));
WindowData &wd = windows[p_window];
ERR_FAIL_COND_MSG(wd.parent_hwnd, "Embedded window can't be moved.");
if (wd.parent_hwnd) {
print_line("Embedded window can't be moved.");
return;
}
if (wd.fullscreen || wd.maximized) {
return;
@ -2141,7 +2142,10 @@ void DisplayServerWindows::window_set_max_size(const Size2i p_size, WindowID p_w
ERR_FAIL_COND(!windows.has(p_window));
WindowData &wd = windows[p_window];
ERR_FAIL_COND_MSG(wd.parent_hwnd, "Embedded windows can't have a maximum size.");
if (wd.parent_hwnd) {
print_line("Embedded windows can't have a maximum size.");
return;
}
if ((p_size != Size2()) && ((p_size.x < wd.min_size.x) || (p_size.y < wd.min_size.y))) {
ERR_PRINT("Maximum window size can't be smaller than minimum window size!");
@ -2164,7 +2168,10 @@ void DisplayServerWindows::window_set_min_size(const Size2i p_size, WindowID p_w
ERR_FAIL_COND(!windows.has(p_window));
WindowData &wd = windows[p_window];
ERR_FAIL_COND_MSG(wd.parent_hwnd, "Embedded windows can't have a minimum size.");
if (wd.parent_hwnd) {
print_line("Embedded windows can't have a minimum size.");
return;
}
if ((p_size != Size2()) && (wd.max_size != Size2()) && ((p_size.x > wd.max_size.x) || (p_size.y > wd.max_size.y))) {
ERR_PRINT("Minimum window size can't be larger than maximum window size!");
@ -2187,7 +2194,10 @@ void DisplayServerWindows::window_set_size(const Size2i p_size, WindowID p_windo
ERR_FAIL_COND(!windows.has(p_window));
WindowData &wd = windows[p_window];
ERR_FAIL_COND_MSG(wd.parent_hwnd, "Embedded window can't be resized.");
if (wd.parent_hwnd) {
print_line("Embedded window can't be resized.");
return;
}
if (wd.fullscreen || wd.maximized) {
return;
@ -2345,7 +2355,10 @@ void DisplayServerWindows::window_set_mode(WindowMode p_mode, WindowID p_window)
ERR_FAIL_COND(!windows.has(p_window));
WindowData &wd = windows[p_window];
ERR_FAIL_COND_MSG(p_mode != WINDOW_MODE_WINDOWED && wd.parent_hwnd, "Embedded window only supports Windowed mode.");
if (p_mode != WINDOW_MODE_WINDOWED && wd.parent_hwnd) {
print_line("Embedded window only supports Windowed mode.");
return;
}
bool was_fullscreen = wd.fullscreen;
wd.was_fullscreen_pre_min = false;
@ -2480,7 +2493,10 @@ void DisplayServerWindows::window_set_flag(WindowFlags p_flag, bool p_enabled, W
WindowData &wd = windows[p_window];
switch (p_flag) {
case WINDOW_FLAG_RESIZE_DISABLED: {
ERR_FAIL_COND_MSG(p_enabled && wd.parent_hwnd, "Embedded window resize can't be disabled.");
if (p_enabled && wd.parent_hwnd) {
print_line("Embedded window resize can't be disabled.");
return;
}
wd.resizable = !p_enabled;
_update_window_style(p_window);
} break;
@ -2492,7 +2508,10 @@ void DisplayServerWindows::window_set_flag(WindowFlags p_flag, bool p_enabled, W
} break;
case WINDOW_FLAG_ALWAYS_ON_TOP: {
ERR_FAIL_COND_MSG(wd.transient_parent != INVALID_WINDOW_ID && p_enabled, "Transient windows can't become on top.");
ERR_FAIL_COND_MSG(p_enabled && wd.parent_hwnd, "Embedded window can't become on top.");
if (p_enabled && wd.parent_hwnd) {
print_line("Embedded window can't become on top.");
return;
}
wd.always_on_top = p_enabled;
_update_window_style(p_window);
} break;
@ -2552,7 +2571,10 @@ void DisplayServerWindows::window_set_flag(WindowFlags p_flag, bool p_enabled, W
case WINDOW_FLAG_POPUP: {
ERR_FAIL_COND_MSG(p_window == MAIN_WINDOW_ID, "Main window can't be popup.");
ERR_FAIL_COND_MSG(IsWindowVisible(wd.hWnd) && (wd.is_popup != p_enabled), "Popup flag can't changed while window is opened.");
ERR_FAIL_COND_MSG(p_enabled && wd.parent_hwnd, "Embedded window can't be popup.");
if (p_enabled && wd.parent_hwnd) {
print_line("Embedded window can't be popup.");
return;
}
wd.is_popup = p_enabled;
} break;
default:
@ -3000,6 +3022,7 @@ Error DisplayServerWindows::embed_process(WindowID p_window, OS::ProcessID p_pid
}
if (p_grab_focus) {
SetForegroundWindow(ep->window_handle);
SetFocus(ep->window_handle);
}
@ -3136,7 +3159,7 @@ Error DisplayServerWindows::dialog_show(String p_title, String p_description, Ve
if (comctl) {
typedef HRESULT(WINAPI * TaskDialogIndirectPtr)(const TASKDIALOGCONFIG *pTaskConfig, int *pnButton, int *pnRadioButton, BOOL *pfVerificationFlagChecked);
TaskDialogIndirectPtr task_dialog_indirect = (TaskDialogIndirectPtr)GetProcAddress(comctl, "TaskDialogIndirect");
TaskDialogIndirectPtr task_dialog_indirect = (TaskDialogIndirectPtr)(void *)GetProcAddress(comctl, "TaskDialogIndirect");
int button_pressed;
if (task_dialog_indirect && SUCCEEDED(task_dialog_indirect(&config, &button_pressed, nullptr, nullptr))) {
@ -6591,9 +6614,9 @@ DisplayServerWindows::DisplayServerWindows(const String &p_rendering_driver, Win
HMODULE nt_lib = LoadLibraryW(L"ntdll.dll");
if (nt_lib) {
WineGetVersionPtr wine_get_version = (WineGetVersionPtr)GetProcAddress(nt_lib, "wine_get_version"); // Do not read Windows build number under Wine, it can be set to arbitrary value.
WineGetVersionPtr wine_get_version = (WineGetVersionPtr)(void *)GetProcAddress(nt_lib, "wine_get_version"); // Do not read Windows build number under Wine, it can be set to arbitrary value.
if (!wine_get_version) {
RtlGetVersionPtr RtlGetVersion = (RtlGetVersionPtr)GetProcAddress(nt_lib, "RtlGetVersion");
RtlGetVersionPtr RtlGetVersion = (RtlGetVersionPtr)(void *)GetProcAddress(nt_lib, "RtlGetVersion");
if (RtlGetVersion) {
RtlGetVersion(&os_ver);
}
@ -6604,28 +6627,28 @@ DisplayServerWindows::DisplayServerWindows(const String &p_rendering_driver, Win
// Load Shell API.
HMODULE shellapi_lib = LoadLibraryW(L"shlwapi.dll");
if (shellapi_lib) {
load_indirect_string = (SHLoadIndirectStringPtr)GetProcAddress(shellapi_lib, "SHLoadIndirectString");
load_indirect_string = (SHLoadIndirectStringPtr)(void *)GetProcAddress(shellapi_lib, "SHLoadIndirectString");
}
// Load UXTheme, available on Windows 10+ only.
if (os_ver.dwBuildNumber >= 10240) {
HMODULE ux_theme_lib = LoadLibraryW(L"uxtheme.dll");
if (ux_theme_lib) {
ShouldAppsUseDarkMode = (ShouldAppsUseDarkModePtr)GetProcAddress(ux_theme_lib, MAKEINTRESOURCEA(132));
GetImmersiveColorFromColorSetEx = (GetImmersiveColorFromColorSetExPtr)GetProcAddress(ux_theme_lib, MAKEINTRESOURCEA(95));
GetImmersiveColorTypeFromName = (GetImmersiveColorTypeFromNamePtr)GetProcAddress(ux_theme_lib, MAKEINTRESOURCEA(96));
GetImmersiveUserColorSetPreference = (GetImmersiveUserColorSetPreferencePtr)GetProcAddress(ux_theme_lib, MAKEINTRESOURCEA(98));
ShouldAppsUseDarkMode = (ShouldAppsUseDarkModePtr)(void *)GetProcAddress(ux_theme_lib, MAKEINTRESOURCEA(132));
GetImmersiveColorFromColorSetEx = (GetImmersiveColorFromColorSetExPtr)(void *)GetProcAddress(ux_theme_lib, MAKEINTRESOURCEA(95));
GetImmersiveColorTypeFromName = (GetImmersiveColorTypeFromNamePtr)(void *)GetProcAddress(ux_theme_lib, MAKEINTRESOURCEA(96));
GetImmersiveUserColorSetPreference = (GetImmersiveUserColorSetPreferencePtr)(void *)GetProcAddress(ux_theme_lib, MAKEINTRESOURCEA(98));
if (os_ver.dwBuildNumber >= 17763) { // Windows 10 Redstone 5 (1809)+ only.
AllowDarkModeForAppPtr AllowDarkModeForApp = nullptr;
SetPreferredAppModePtr SetPreferredAppMode = nullptr;
FlushMenuThemesPtr FlushMenuThemes = nullptr;
if (os_ver.dwBuildNumber < 18362) { // Windows 10 Redstone 5 (1809) and 19H1 (1903) only.
AllowDarkModeForApp = (AllowDarkModeForAppPtr)GetProcAddress(ux_theme_lib, MAKEINTRESOURCEA(135));
AllowDarkModeForApp = (AllowDarkModeForAppPtr)(void *)GetProcAddress(ux_theme_lib, MAKEINTRESOURCEA(135));
} else { // Windows 10 19H2 (1909)+ only.
SetPreferredAppMode = (SetPreferredAppModePtr)GetProcAddress(ux_theme_lib, MAKEINTRESOURCEA(135));
FlushMenuThemes = (FlushMenuThemesPtr)GetProcAddress(ux_theme_lib, MAKEINTRESOURCEA(136));
SetPreferredAppMode = (SetPreferredAppModePtr)(void *)GetProcAddress(ux_theme_lib, MAKEINTRESOURCEA(135));
FlushMenuThemes = (FlushMenuThemesPtr)(void *)GetProcAddress(ux_theme_lib, MAKEINTRESOURCEA(136));
}
RefreshImmersiveColorPolicyStatePtr RefreshImmersiveColorPolicyState = (RefreshImmersiveColorPolicyStatePtr)GetProcAddress(ux_theme_lib, MAKEINTRESOURCEA(104));
RefreshImmersiveColorPolicyStatePtr RefreshImmersiveColorPolicyState = (RefreshImmersiveColorPolicyStatePtr)(void *)GetProcAddress(ux_theme_lib, MAKEINTRESOURCEA(104));
if (ShouldAppsUseDarkMode) {
bool dark_mode = ShouldAppsUseDarkMode();
if (SetPreferredAppMode) {
@ -6658,10 +6681,10 @@ DisplayServerWindows::DisplayServerWindows(const String &p_rendering_driver, Win
// Note: DPI conversion API, available on Windows 8.1+ only.
HMODULE user32_lib = LoadLibraryW(L"user32.dll");
if (user32_lib) {
win8p_GetPointerType = (GetPointerTypePtr)GetProcAddress(user32_lib, "GetPointerType");
win8p_GetPointerPenInfo = (GetPointerPenInfoPtr)GetProcAddress(user32_lib, "GetPointerPenInfo");
win81p_LogicalToPhysicalPointForPerMonitorDPI = (LogicalToPhysicalPointForPerMonitorDPIPtr)GetProcAddress(user32_lib, "LogicalToPhysicalPointForPerMonitorDPI");
win81p_PhysicalToLogicalPointForPerMonitorDPI = (PhysicalToLogicalPointForPerMonitorDPIPtr)GetProcAddress(user32_lib, "PhysicalToLogicalPointForPerMonitorDPI");
win8p_GetPointerType = (GetPointerTypePtr)(void *)GetProcAddress(user32_lib, "GetPointerType");
win8p_GetPointerPenInfo = (GetPointerPenInfoPtr)(void *)GetProcAddress(user32_lib, "GetPointerPenInfo");
win81p_LogicalToPhysicalPointForPerMonitorDPI = (LogicalToPhysicalPointForPerMonitorDPIPtr)(void *)GetProcAddress(user32_lib, "LogicalToPhysicalPointForPerMonitorDPI");
win81p_PhysicalToLogicalPointForPerMonitorDPI = (PhysicalToLogicalPointForPerMonitorDPIPtr)(void *)GetProcAddress(user32_lib, "PhysicalToLogicalPointForPerMonitorDPI");
winink_available = win8p_GetPointerType && win8p_GetPointerPenInfo;
}
@ -6673,11 +6696,11 @@ DisplayServerWindows::DisplayServerWindows(const String &p_rendering_driver, Win
// Note: Wacom WinTab driver API for pen input, for devices incompatible with Windows Ink.
HMODULE wintab_lib = LoadLibraryW(L"wintab32.dll");
if (wintab_lib) {
wintab_WTOpen = (WTOpenPtr)GetProcAddress(wintab_lib, "WTOpenW");
wintab_WTClose = (WTClosePtr)GetProcAddress(wintab_lib, "WTClose");
wintab_WTInfo = (WTInfoPtr)GetProcAddress(wintab_lib, "WTInfoW");
wintab_WTPacket = (WTPacketPtr)GetProcAddress(wintab_lib, "WTPacket");
wintab_WTEnable = (WTEnablePtr)GetProcAddress(wintab_lib, "WTEnable");
wintab_WTOpen = (WTOpenPtr)(void *)GetProcAddress(wintab_lib, "WTOpenW");
wintab_WTClose = (WTClosePtr)(void *)GetProcAddress(wintab_lib, "WTClose");
wintab_WTInfo = (WTInfoPtr)(void *)GetProcAddress(wintab_lib, "WTInfoW");
wintab_WTPacket = (WTPacketPtr)(void *)GetProcAddress(wintab_lib, "WTPacket");
wintab_WTEnable = (WTEnablePtr)(void *)GetProcAddress(wintab_lib, "WTEnable");
wintab_available = wintab_WTOpen && wintab_WTClose && wintab_WTInfo && wintab_WTPacket && wintab_WTEnable;
}
@ -6715,7 +6738,7 @@ DisplayServerWindows::DisplayServerWindows(const String &p_rendering_driver, Win
if (Shcore != nullptr) {
typedef HRESULT(WINAPI * SetProcessDpiAwareness_t)(SHC_PROCESS_DPI_AWARENESS);
SetProcessDpiAwareness_t SetProcessDpiAwareness = (SetProcessDpiAwareness_t)GetProcAddress(Shcore, "SetProcessDpiAwareness");
SetProcessDpiAwareness_t SetProcessDpiAwareness = (SetProcessDpiAwareness_t)(void *)GetProcAddress(Shcore, "SetProcessDpiAwareness");
if (SetProcessDpiAwareness) {
SetProcessDpiAwareness(SHC_PROCESS_SYSTEM_DPI_AWARE);
@ -6726,7 +6749,7 @@ DisplayServerWindows::DisplayServerWindows(const String &p_rendering_driver, Win
HMODULE comctl32 = LoadLibraryW(L"comctl32.dll");
if (comctl32) {
typedef BOOL(WINAPI * InitCommonControlsExPtr)(_In_ const INITCOMMONCONTROLSEX *picce);
InitCommonControlsExPtr init_common_controls_ex = (InitCommonControlsExPtr)GetProcAddress(comctl32, "InitCommonControlsEx");
InitCommonControlsExPtr init_common_controls_ex = (InitCommonControlsExPtr)(void *)GetProcAddress(comctl32, "InitCommonControlsEx");
// Fails if the incorrect version was loaded. Probably not a big enough deal to print an error about.
if (init_common_controls_ex) {
@ -6763,24 +6786,30 @@ DisplayServerWindows::DisplayServerWindows(const String &p_rendering_driver, Win
_register_raw_input_devices(INVALID_WINDOW_ID);
#if defined(RD_ENABLED)
[[maybe_unused]] bool fallback_to_vulkan = GLOBAL_GET("rendering/rendering_device/fallback_to_vulkan");
[[maybe_unused]] bool fallback_to_d3d12 = GLOBAL_GET("rendering/rendering_device/fallback_to_d3d12");
#if defined(VULKAN_ENABLED)
if (rendering_driver == "vulkan") {
rendering_context = memnew(RenderingContextDriverVulkanWindows);
tested_drivers.set_flag(DRIVER_ID_RD_VULKAN);
}
#else
fallback_to_d3d12 = true; // Always enable fallback if engine was built w/o other driver support.
#endif
#if defined(D3D12_ENABLED)
if (rendering_driver == "d3d12") {
rendering_context = memnew(RenderingContextDriverD3D12);
tested_drivers.set_flag(DRIVER_ID_RD_D3D12);
}
#else
fallback_to_vulkan = true; // Always enable fallback if engine was built w/o other driver support.
#endif
if (rendering_context) {
if (rendering_context->initialize() != OK) {
bool failed = true;
#if defined(VULKAN_ENABLED)
bool fallback_to_vulkan = GLOBAL_GET("rendering/rendering_device/fallback_to_vulkan");
if (failed && fallback_to_vulkan && rendering_driver != "vulkan") {
memdelete(rendering_context);
rendering_context = memnew(RenderingContextDriverVulkanWindows);
@ -6794,7 +6823,6 @@ DisplayServerWindows::DisplayServerWindows(const String &p_rendering_driver, Win
}
#endif
#if defined(D3D12_ENABLED)
bool fallback_to_d3d12 = GLOBAL_GET("rendering/rendering_device/fallback_to_d3d12");
if (failed && fallback_to_d3d12 && rendering_driver != "d3d12") {
memdelete(rendering_context);
rendering_context = memnew(RenderingContextDriverD3D12);
@ -6843,7 +6871,7 @@ DisplayServerWindows::DisplayServerWindows(const String &p_rendering_driver, Win
#else
typedef BOOL(WINAPI * IsWow64Process2Ptr)(HANDLE, USHORT *, USHORT *);
IsWow64Process2Ptr IsWow64Process2 = (IsWow64Process2Ptr)GetProcAddress(GetModuleHandle(TEXT("kernel32")), "IsWow64Process2");
IsWow64Process2Ptr IsWow64Process2 = (IsWow64Process2Ptr)(void *)GetProcAddress(GetModuleHandle(TEXT("kernel32")), "IsWow64Process2");
if (IsWow64Process2) {
USHORT process_arch = 0;
USHORT machine_arch = 0;

View file

@ -50,11 +50,6 @@
#define _WGL_CONTEXT_DEBUG_BIT_ARB 0x0001
#if defined(__GNUC__)
// Workaround GCC warning from -Wcast-function-type.
#define GetProcAddress (void *)GetProcAddress
#endif
typedef HGLRC(APIENTRY *PFNWGLCREATECONTEXT)(HDC);
typedef BOOL(APIENTRY *PFNWGLDELETECONTEXT)(HGLRC);
typedef BOOL(APIENTRY *PFNWGLMAKECURRENT)(HDC, HGLRC);
@ -364,10 +359,10 @@ Error GLManagerNative_Windows::_create_context(GLWindow &win, GLDisplay &gl_disp
if (!module) {
return ERR_CANT_CREATE;
}
gd_wglCreateContext = (PFNWGLCREATECONTEXT)GetProcAddress(module, "wglCreateContext");
gd_wglMakeCurrent = (PFNWGLMAKECURRENT)GetProcAddress(module, "wglMakeCurrent");
gd_wglDeleteContext = (PFNWGLDELETECONTEXT)GetProcAddress(module, "wglDeleteContext");
gd_wglGetProcAddress = (PFNWGLGETPROCADDRESS)GetProcAddress(module, "wglGetProcAddress");
gd_wglCreateContext = (PFNWGLCREATECONTEXT)(void *)GetProcAddress(module, "wglCreateContext");
gd_wglMakeCurrent = (PFNWGLMAKECURRENT)(void *)GetProcAddress(module, "wglMakeCurrent");
gd_wglDeleteContext = (PFNWGLDELETECONTEXT)(void *)GetProcAddress(module, "wglDeleteContext");
gd_wglGetProcAddress = (PFNWGLGETPROCADDRESS)(void *)GetProcAddress(module, "wglGetProcAddress");
if (!gd_wglCreateContext || !gd_wglMakeCurrent || !gd_wglDeleteContext || !gd_wglGetProcAddress) {
return ERR_CANT_CREATE;
}

View file

@ -33,11 +33,6 @@
#include <oleauto.h>
#include <wbemidl.h>
#if defined(__GNUC__)
// Workaround GCC warning from -Wcast-function-type.
#define GetProcAddress (void *)GetProcAddress
#endif
DWORD WINAPI _xinput_get_state(DWORD dwUserIndex, XINPUT_STATE *pState) {
return ERROR_DEVICE_NOT_CONNECTED;
}
@ -597,8 +592,8 @@ void JoypadWindows::load_xinput() {
// (LPCSTR)100 is the magic number to get XInputGetStateEx, which also provides the state for the guide button
LPCSTR get_state_func_name = legacy_xinput ? "XInputGetState" : (LPCSTR)100;
XInputGetState_t func = (XInputGetState_t)GetProcAddress((HMODULE)xinput_dll, get_state_func_name);
XInputSetState_t set_func = (XInputSetState_t)GetProcAddress((HMODULE)xinput_dll, "XInputSetState");
XInputGetState_t func = (XInputGetState_t)(void *)GetProcAddress((HMODULE)xinput_dll, get_state_func_name);
XInputSetState_t set_func = (XInputSetState_t)(void *)GetProcAddress((HMODULE)xinput_dll, "XInputSetState");
if (!func || !set_func) {
unload_xinput();
return;
@ -608,7 +603,7 @@ void JoypadWindows::load_xinput() {
winmm_dll = LoadLibrary("Winmm.dll");
if (winmm_dll) {
joyGetDevCaps_t caps_func = (joyGetDevCaps_t)GetProcAddress((HMODULE)winmm_dll, "joyGetDevCapsW");
joyGetDevCaps_t caps_func = (joyGetDevCaps_t)(void *)GetProcAddress((HMODULE)winmm_dll, "joyGetDevCapsW");
if (caps_func) {
winmm_get_joycaps = caps_func;
} else {

View file

@ -62,6 +62,24 @@
#include <wbemcli.h>
#include <wincrypt.h>
#if defined(RD_ENABLED)
#include "servers/rendering/rendering_device.h"
#endif
#if defined(GLES3_ENABLED)
#include "gl_manager_windows_native.h"
#endif
#if defined(VULKAN_ENABLED)
#include "rendering_context_driver_vulkan_windows.h"
#endif
#if defined(D3D12_ENABLED)
#include "drivers/d3d12/rendering_context_driver_d3d12.h"
#endif
#if defined(GLES3_ENABLED)
#include "drivers/gles3/rasterizer_gles3.h"
#endif
#ifdef DEBUG_ENABLED
#pragma pack(push, before_imagehlp, 8)
#include <imagehlp.h>
@ -88,11 +106,6 @@ __declspec(dllexport) void NoHotPatch() {} // Disable Nahimic code injection.
#define DWRITE_FONT_WEIGHT_SEMI_LIGHT (DWRITE_FONT_WEIGHT)350
#endif
#if defined(__GNUC__)
// Workaround GCC warning from -Wcast-function-type.
#define GetProcAddress (void *)GetProcAddress
#endif
static String fix_path(const String &p_path) {
String path = p_path;
if (p_path.is_relative_path()) {
@ -485,8 +498,8 @@ Error OS_Windows::open_dynamic_library(const String &p_path, void *&p_library_ha
typedef DLL_DIRECTORY_COOKIE(WINAPI * PAddDllDirectory)(PCWSTR);
typedef BOOL(WINAPI * PRemoveDllDirectory)(DLL_DIRECTORY_COOKIE);
PAddDllDirectory add_dll_directory = (PAddDllDirectory)GetProcAddress(GetModuleHandle("kernel32.dll"), "AddDllDirectory");
PRemoveDllDirectory remove_dll_directory = (PRemoveDllDirectory)GetProcAddress(GetModuleHandle("kernel32.dll"), "RemoveDllDirectory");
PAddDllDirectory add_dll_directory = (PAddDllDirectory)(void *)GetProcAddress(GetModuleHandle("kernel32.dll"), "AddDllDirectory");
PRemoveDllDirectory remove_dll_directory = (PRemoveDllDirectory)(void *)GetProcAddress(GetModuleHandle("kernel32.dll"), "RemoveDllDirectory");
bool has_dll_directory_api = ((add_dll_directory != nullptr) && (remove_dll_directory != nullptr));
DLL_DIRECTORY_COOKIE cookie = nullptr;
@ -585,7 +598,7 @@ String OS_Windows::get_distribution_name() const {
}
String OS_Windows::get_version() const {
RtlGetVersionPtr version_ptr = (RtlGetVersionPtr)GetProcAddress(GetModuleHandle("ntdll.dll"), "RtlGetVersion");
RtlGetVersionPtr version_ptr = (RtlGetVersionPtr)(void *)GetProcAddress(GetModuleHandle("ntdll.dll"), "RtlGetVersion");
if (version_ptr != nullptr) {
RTL_OSVERSIONINFOEXW fow;
ZeroMemory(&fow, sizeof(fow));
@ -598,7 +611,7 @@ String OS_Windows::get_version() const {
}
String OS_Windows::get_version_alias() const {
RtlGetVersionPtr version_ptr = (RtlGetVersionPtr)GetProcAddress(GetModuleHandle("ntdll.dll"), "RtlGetVersion");
RtlGetVersionPtr version_ptr = (RtlGetVersionPtr)(void *)GetProcAddress(GetModuleHandle("ntdll.dll"), "RtlGetVersion");
if (version_ptr != nullptr) {
RTL_OSVERSIONINFOEXW fow;
ZeroMemory(&fow, sizeof(fow));
@ -771,7 +784,7 @@ bool OS_Windows::get_user_prefers_integrated_gpu() const {
HMODULE kernel32 = GetModuleHandleW(L"kernel32.dll");
if (kernel32) {
using GetCurrentApplicationUserModelIdPtr = LONG(WINAPI *)(UINT32 * length, PWSTR id);
GetCurrentApplicationUserModelIdPtr GetCurrentApplicationUserModelId = (GetCurrentApplicationUserModelIdPtr)GetProcAddress(kernel32, "GetCurrentApplicationUserModelId");
GetCurrentApplicationUserModelIdPtr GetCurrentApplicationUserModelId = (GetCurrentApplicationUserModelIdPtr)(void *)GetProcAddress(kernel32, "GetCurrentApplicationUserModelId");
if (GetCurrentApplicationUserModelId) {
UINT32 length = sizeof(value_name) / sizeof(value_name[0]);
@ -973,7 +986,7 @@ Dictionary OS_Windows::get_memory_info() const {
GetPerformanceInfo(&pref_info, sizeof(pref_info));
typedef void(WINAPI * PGetCurrentThreadStackLimits)(PULONG_PTR, PULONG_PTR);
PGetCurrentThreadStackLimits GetCurrentThreadStackLimits = (PGetCurrentThreadStackLimits)GetProcAddress(GetModuleHandleA("kernel32.dll"), "GetCurrentThreadStackLimits");
PGetCurrentThreadStackLimits GetCurrentThreadStackLimits = (PGetCurrentThreadStackLimits)(void *)GetProcAddress(GetModuleHandleA("kernel32.dll"), "GetCurrentThreadStackLimits");
ULONG_PTR LowLimit = 0;
ULONG_PTR HighLimit = 0;
@ -2346,6 +2359,99 @@ void OS_Windows::add_frame_delay(bool p_can_draw) {
}
}
bool OS_Windows::_test_create_rendering_device() const {
// Tests Rendering Device creation.
bool ok = false;
#if defined(RD_ENABLED)
Error err;
RenderingContextDriver *rcd = nullptr;
#if defined(VULKAN_ENABLED)
rcd = memnew(RenderingContextDriverVulkan);
#endif
#ifdef D3D12_ENABLED
if (rcd == nullptr) {
rcd = memnew(RenderingContextDriverD3D12);
}
#endif
if (rcd != nullptr) {
err = rcd->initialize();
if (err == OK) {
RenderingDevice *rd = memnew(RenderingDevice);
err = rd->initialize(rcd);
memdelete(rd);
rd = nullptr;
if (err == OK) {
ok = true;
}
}
memdelete(rcd);
rcd = nullptr;
}
#endif
return ok;
}
bool OS_Windows::_test_create_rendering_device_and_gl() const {
// Tests OpenGL context and Rendering Device simultaneous creation. This function is expected to crash on some NVIDIA drivers.
WNDCLASSEXW wc_probe;
memset(&wc_probe, 0, sizeof(WNDCLASSEXW));
wc_probe.cbSize = sizeof(WNDCLASSEXW);
wc_probe.style = CS_OWNDC | CS_DBLCLKS;
wc_probe.lpfnWndProc = (WNDPROC)::DefWindowProcW;
wc_probe.cbClsExtra = 0;
wc_probe.cbWndExtra = 0;
wc_probe.hInstance = GetModuleHandle(nullptr);
wc_probe.hIcon = LoadIcon(nullptr, IDI_WINLOGO);
wc_probe.hCursor = nullptr;
wc_probe.hbrBackground = nullptr;
wc_probe.lpszMenuName = nullptr;
wc_probe.lpszClassName = L"Engine probe window";
if (!RegisterClassExW(&wc_probe)) {
return false;
}
HWND hWnd = CreateWindowExW(WS_EX_WINDOWEDGE, L"Engine probe window", L"", WS_OVERLAPPEDWINDOW, 0, 0, 800, 600, nullptr, nullptr, GetModuleHandle(nullptr), nullptr);
if (!hWnd) {
UnregisterClassW(L"Engine probe window", GetModuleHandle(nullptr));
return false;
}
bool ok = true;
#ifdef GLES3_ENABLED
GLManagerNative_Windows *test_gl_manager_native = memnew(GLManagerNative_Windows);
if (test_gl_manager_native->window_create(DisplayServer::MAIN_WINDOW_ID, hWnd, GetModuleHandle(nullptr), 800, 600) == OK) {
RasterizerGLES3::make_current(true);
} else {
ok = false;
}
#endif
MSG msg = {};
while (PeekMessageW(&msg, nullptr, 0, 0, PM_REMOVE)) {
TranslateMessage(&msg);
DispatchMessageW(&msg);
}
if (ok) {
ok = _test_create_rendering_device();
}
#ifdef GLES3_ENABLED
if (test_gl_manager_native) {
memdelete(test_gl_manager_native);
}
#endif
DestroyWindow(hWnd);
UnregisterClassW(L"Engine probe window", GetModuleHandle(nullptr));
return ok;
}
OS_Windows::OS_Windows(HINSTANCE _hInstance) {
hInstance = _hInstance;

View file

@ -252,6 +252,9 @@ public:
void set_main_window(HWND p_main_window) { main_window = p_main_window; }
virtual bool _test_create_rendering_device_and_gl() const override;
virtual bool _test_create_rendering_device() const override;
HINSTANCE get_hinstance() { return hInstance; }
OS_Windows(HINSTANCE _hInstance);
~OS_Windows();

View file

@ -53,11 +53,6 @@
#define WGL_RENDERER 0x1F01
#define WGL_VERSION 0x1F02
#if defined(__GNUC__)
// Workaround GCC warning from -Wcast-function-type.
#define GetProcAddress (void *)GetProcAddress
#endif
typedef HGLRC(APIENTRY *PFNWGLCREATECONTEXT)(HDC);
typedef BOOL(APIENTRY *PFNWGLDELETECONTEXT)(HGLRC);
typedef BOOL(APIENTRY *PFNWGLMAKECURRENT)(HDC, HGLRC);
@ -80,10 +75,10 @@ Dictionary detect_wgl() {
if (!module) {
return gl_info;
}
gd_wglCreateContext = (PFNWGLCREATECONTEXT)GetProcAddress(module, "wglCreateContext");
gd_wglMakeCurrent = (PFNWGLMAKECURRENT)GetProcAddress(module, "wglMakeCurrent");
gd_wglDeleteContext = (PFNWGLDELETECONTEXT)GetProcAddress(module, "wglDeleteContext");
gd_wglGetProcAddress = (PFNWGLGETPROCADDRESS)GetProcAddress(module, "wglGetProcAddress");
gd_wglCreateContext = (PFNWGLCREATECONTEXT)(void *)GetProcAddress(module, "wglCreateContext");
gd_wglMakeCurrent = (PFNWGLMAKECURRENT)(void *)GetProcAddress(module, "wglMakeCurrent");
gd_wglDeleteContext = (PFNWGLDELETECONTEXT)(void *)GetProcAddress(module, "wglDeleteContext");
gd_wglGetProcAddress = (PFNWGLGETPROCADDRESS)(void *)GetProcAddress(module, "wglGetProcAddress");
if (!gd_wglCreateContext || !gd_wglMakeCurrent || !gd_wglDeleteContext || !gd_wglGetProcAddress) {
return gl_info;
}
@ -143,7 +138,7 @@ Dictionary detect_wgl() {
HGLRC new_hRC = gd_wglCreateContextAttribsARB(hDC, nullptr, attribs);
if (new_hRC) {
if (gd_wglMakeCurrent(hDC, new_hRC)) {
PFNWGLGETSTRINGPROC gd_wglGetString = (PFNWGLGETSTRINGPROC)GetProcAddress(module, "glGetString");
PFNWGLGETSTRINGPROC gd_wglGetString = (PFNWGLGETSTRINGPROC)(void *)GetProcAddress(module, "glGetString");
if (gd_wglGetString) {
const char *prefixes[] = {
"OpenGL ES-CM ",