Path: blob/master/platform/windows/gl_manager_windows_native.cpp
10277 views
/**************************************************************************/1/* gl_manager_windows_native.cpp */2/**************************************************************************/3/* This file is part of: */4/* GODOT ENGINE */5/* https://godotengine.org */6/**************************************************************************/7/* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */8/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */9/* */10/* Permission is hereby granted, free of charge, to any person obtaining */11/* a copy of this software and associated documentation files (the */12/* "Software"), to deal in the Software without restriction, including */13/* without limitation the rights to use, copy, modify, merge, publish, */14/* distribute, sublicense, and/or sell copies of the Software, and to */15/* permit persons to whom the Software is furnished to do so, subject to */16/* the following conditions: */17/* */18/* The above copyright notice and this permission notice shall be */19/* included in all copies or substantial portions of the Software. */20/* */21/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */22/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */23/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */24/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */25/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */26/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */27/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */28/**************************************************************************/2930#include "gl_manager_windows_native.h"3132#if defined(WINDOWS_ENABLED) && defined(GLES3_ENABLED)3334#include "core/config/project_settings.h"35#include "core/version.h"3637#include "thirdparty/misc/nvapi_minimal.h"3839#include <dwmapi.h>40#include <cstdio>41#include <cstdlib>4243#define WGL_CONTEXT_MAJOR_VERSION_ARB 0x209144#define WGL_CONTEXT_MINOR_VERSION_ARB 0x209245#define WGL_CONTEXT_FLAGS_ARB 0x209446#define WGL_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB 0x0000000247#define WGL_CONTEXT_PROFILE_MASK_ARB 0x912648#define WGL_CONTEXT_CORE_PROFILE_BIT_ARB 0x000000014950#define _WGL_CONTEXT_DEBUG_BIT_ARB 0x00015152typedef HGLRC(APIENTRY *PFNWGLCREATECONTEXT)(HDC);53typedef BOOL(APIENTRY *PFNWGLDELETECONTEXT)(HGLRC);54typedef BOOL(APIENTRY *PFNWGLMAKECURRENT)(HDC, HGLRC);55typedef HGLRC(APIENTRY *PFNWGLCREATECONTEXTATTRIBSARBPROC)(HDC, HGLRC, const int *);56typedef void *(APIENTRY *PFNWGLGETPROCADDRESS)(LPCSTR);5758static String format_error_message(DWORD id) {59LPWSTR messageBuffer = nullptr;60size_t size = FormatMessageW(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS,61nullptr, id, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), (LPWSTR)&messageBuffer, 0, nullptr);6263String msg = "Error " + itos(id) + ": " + String::utf16((const char16_t *)messageBuffer, size);6465LocalFree(messageBuffer);6667return msg;68}6970const int OGL_THREAD_CONTROL_ID = 0x20C1221E;71const int OGL_THREAD_CONTROL_DISABLE = 0x00000002;72const int OGL_THREAD_CONTROL_ENABLE = 0x00000001;73const int VRR_MODE_ID = 0x1194F158;74const int VRR_MODE_FULLSCREEN_ONLY = 0x1;7576typedef int(__cdecl *NvAPI_Initialize_t)();77typedef int(__cdecl *NvAPI_Unload_t)();78typedef int(__cdecl *NvAPI_GetErrorMessage_t)(unsigned int, NvAPI_ShortString);79typedef int(__cdecl *NvAPI_DRS_CreateSession_t)(NvDRSSessionHandle *);80typedef int(__cdecl *NvAPI_DRS_DestroySession_t)(NvDRSSessionHandle);81typedef int(__cdecl *NvAPI_DRS_LoadSettings_t)(NvDRSSessionHandle);82typedef int(__cdecl *NvAPI_DRS_CreateProfile_t)(NvDRSSessionHandle, NVDRS_PROFILE *, NvDRSProfileHandle *);83typedef int(__cdecl *NvAPI_DRS_CreateApplication_t)(NvDRSSessionHandle, NvDRSProfileHandle, NVDRS_APPLICATION *);84typedef int(__cdecl *NvAPI_DRS_SaveSettings_t)(NvDRSSessionHandle);85typedef int(__cdecl *NvAPI_DRS_SetSetting_t)(NvDRSSessionHandle, NvDRSProfileHandle, NVDRS_SETTING *);86typedef int(__cdecl *NvAPI_DRS_FindProfileByName_t)(NvDRSSessionHandle, NvAPI_UnicodeString, NvDRSProfileHandle *);87typedef int(__cdecl *NvAPI_DRS_GetApplicationInfo_t)(NvDRSSessionHandle, NvDRSProfileHandle, NvAPI_UnicodeString, NVDRS_APPLICATION *);88typedef int(__cdecl *NvAPI_DRS_DeleteProfile_t)(NvDRSSessionHandle, NvDRSProfileHandle);89NvAPI_GetErrorMessage_t NvAPI_GetErrorMessage__;9091static bool nvapi_err_check(const char *msg, int status) {92if (status != 0) {93if (OS::get_singleton()->is_stdout_verbose()) {94NvAPI_ShortString err_desc = { 0 };95NvAPI_GetErrorMessage__(status, err_desc);96print_verbose(vformat("%s: %s(code %d)", msg, err_desc, status));97}98return false;99}100return true;101}102103// On windows we have to customize the NVIDIA application profile:104// * disable threaded optimization when using NVIDIA cards to avoid stuttering, see105// https://stackoverflow.com/questions/36959508/nvidia-graphics-driver-causing-noticeable-frame-stuttering/37632948106// https://github.com/Ryujinx/Ryujinx/blob/master/src/Ryujinx.Common/GraphicsDriver/NVThreadedOptimization.cs107// * disable G-SYNC in windowed mode, as it results in unstable editor refresh rates108void GLManagerNative_Windows::_nvapi_setup_profile() {109HMODULE nvapi = nullptr;110#ifdef _WIN64111nvapi = LoadLibraryA("nvapi64.dll");112#else113nvapi = LoadLibraryA("nvapi.dll");114#endif115116if (nvapi == nullptr) {117return;118}119120void *(__cdecl * NvAPI_QueryInterface)(unsigned int interface_id) = nullptr;121122NvAPI_QueryInterface = (void *(__cdecl *)(unsigned int))(void *)GetProcAddress(nvapi, "nvapi_QueryInterface");123124if (NvAPI_QueryInterface == nullptr) {125print_verbose("Error getting NVAPI NvAPI_QueryInterface");126return;127}128129// Setup NVAPI function pointers130NvAPI_Initialize_t NvAPI_Initialize = (NvAPI_Initialize_t)NvAPI_QueryInterface(0x0150E828);131NvAPI_GetErrorMessage__ = (NvAPI_GetErrorMessage_t)NvAPI_QueryInterface(0x6C2D048C);132NvAPI_DRS_CreateSession_t NvAPI_DRS_CreateSession = (NvAPI_DRS_CreateSession_t)NvAPI_QueryInterface(0x0694D52E);133NvAPI_DRS_DestroySession_t NvAPI_DRS_DestroySession = (NvAPI_DRS_DestroySession_t)NvAPI_QueryInterface(0xDAD9CFF8);134NvAPI_Unload_t NvAPI_Unload = (NvAPI_Unload_t)NvAPI_QueryInterface(0xD22BDD7E);135NvAPI_DRS_LoadSettings_t NvAPI_DRS_LoadSettings = (NvAPI_DRS_LoadSettings_t)NvAPI_QueryInterface(0x375DBD6B);136NvAPI_DRS_CreateProfile_t NvAPI_DRS_CreateProfile = (NvAPI_DRS_CreateProfile_t)NvAPI_QueryInterface(0xCC176068);137NvAPI_DRS_CreateApplication_t NvAPI_DRS_CreateApplication = (NvAPI_DRS_CreateApplication_t)NvAPI_QueryInterface(0x4347A9DE);138NvAPI_DRS_SaveSettings_t NvAPI_DRS_SaveSettings = (NvAPI_DRS_SaveSettings_t)NvAPI_QueryInterface(0xFCBC7E14);139NvAPI_DRS_SetSetting_t NvAPI_DRS_SetSetting = (NvAPI_DRS_SetSetting_t)NvAPI_QueryInterface(0x577DD202);140NvAPI_DRS_FindProfileByName_t NvAPI_DRS_FindProfileByName = (NvAPI_DRS_FindProfileByName_t)NvAPI_QueryInterface(0x7E4A9A0B);141NvAPI_DRS_GetApplicationInfo_t NvAPI_DRS_GetApplicationInfo = (NvAPI_DRS_GetApplicationInfo_t)NvAPI_QueryInterface(0xED1F8C69);142NvAPI_DRS_DeleteProfile_t NvAPI_DRS_DeleteProfile = (NvAPI_DRS_DeleteProfile_t)NvAPI_QueryInterface(0x17093206);143144if (!nvapi_err_check("NVAPI: Init failed", NvAPI_Initialize())) {145return;146}147148print_verbose("NVAPI: Init OK!");149150NvDRSSessionHandle session_handle;151152if (NvAPI_DRS_CreateSession == nullptr) {153return;154}155156if (!nvapi_err_check("NVAPI: Error creating DRS session", NvAPI_DRS_CreateSession(&session_handle))) {157NvAPI_Unload();158return;159}160161if (!nvapi_err_check("NVAPI: Error loading DRS settings", NvAPI_DRS_LoadSettings(session_handle))) {162NvAPI_DRS_DestroySession(session_handle);163NvAPI_Unload();164return;165}166167String app_executable_name = OS::get_singleton()->get_executable_path().get_file();168String app_profile_name = GLOBAL_GET("application/config/name");169// We need a name anyways, so let's use the engine name if an application name is not available170// (this is used mostly by the Project Manager)171if (app_profile_name.is_empty()) {172app_profile_name = GODOT_VERSION_NAME;173}174String old_profile_name = app_profile_name + " Nvidia Profile";175Char16String app_profile_name_u16 = app_profile_name.utf16();176Char16String old_profile_name_u16 = old_profile_name.utf16();177Char16String app_executable_name_u16 = app_executable_name.utf16();178179// A previous error in app creation logic could result in invalid profiles,180// clean these if they exist before proceeding.181NvDRSProfileHandle old_profile_handle;182183int old_status = NvAPI_DRS_FindProfileByName(session_handle, (NvU16 *)(old_profile_name_u16.ptrw()), &old_profile_handle);184185if (old_status == 0) {186print_verbose("NVAPI: Deleting old profile...");187188if (!nvapi_err_check("NVAPI: Error deleting old profile", NvAPI_DRS_DeleteProfile(session_handle, old_profile_handle))) {189NvAPI_DRS_DestroySession(session_handle);190NvAPI_Unload();191return;192}193194if (!nvapi_err_check("NVAPI: Error deleting old profile", NvAPI_DRS_SaveSettings(session_handle))) {195NvAPI_DRS_DestroySession(session_handle);196NvAPI_Unload();197return;198}199}200201NvDRSProfileHandle profile_handle = nullptr;202203int profile_status = NvAPI_DRS_FindProfileByName(session_handle, (NvU16 *)(app_profile_name_u16.ptrw()), &profile_handle);204205if (profile_status != 0) {206print_verbose("NVAPI: Profile not found, creating...");207208NVDRS_PROFILE profile_info;209profile_info.version = NVDRS_PROFILE_VER;210profile_info.isPredefined = 0;211memcpy(profile_info.profileName, app_profile_name_u16.get_data(), sizeof(char16_t) * app_profile_name_u16.size());212213if (!nvapi_err_check("NVAPI: Error creating profile", NvAPI_DRS_CreateProfile(session_handle, &profile_info, &profile_handle))) {214NvAPI_DRS_DestroySession(session_handle);215NvAPI_Unload();216return;217}218}219220NVDRS_APPLICATION_V4 app;221app.version = NVDRS_APPLICATION_VER_V4;222223int app_status = NvAPI_DRS_GetApplicationInfo(session_handle, profile_handle, (NvU16 *)(app_executable_name_u16.ptrw()), &app);224225if (app_status != 0) {226print_verbose("NVAPI: Application not found in profile, creating...");227228app.isPredefined = 0;229memcpy(app.appName, app_executable_name_u16.get_data(), sizeof(char16_t) * app_executable_name_u16.size());230memcpy(app.launcher, L"", sizeof(wchar_t));231memcpy(app.fileInFolder, L"", sizeof(wchar_t));232233if (!nvapi_err_check("NVAPI: Error creating application", NvAPI_DRS_CreateApplication(session_handle, profile_handle, &app))) {234NvAPI_DRS_DestroySession(session_handle);235NvAPI_Unload();236return;237}238}239240NVDRS_SETTING ogl_thread_control_setting = {};241ogl_thread_control_setting.version = NVDRS_SETTING_VER;242ogl_thread_control_setting.settingId = OGL_THREAD_CONTROL_ID;243ogl_thread_control_setting.settingType = NVDRS_DWORD_TYPE;244int thread_control_val = OGL_THREAD_CONTROL_DISABLE;245if (!GLOBAL_GET("rendering/gl_compatibility/nvidia_disable_threaded_optimization")) {246thread_control_val = OGL_THREAD_CONTROL_ENABLE;247}248ogl_thread_control_setting.u32CurrentValue = thread_control_val;249250if (!nvapi_err_check("NVAPI: Error calling NvAPI_DRS_SetSetting", NvAPI_DRS_SetSetting(session_handle, profile_handle, &ogl_thread_control_setting))) {251NvAPI_DRS_DestroySession(session_handle);252NvAPI_Unload();253return;254}255256NVDRS_SETTING vrr_mode_setting = {};257vrr_mode_setting.version = NVDRS_SETTING_VER;258vrr_mode_setting.settingId = VRR_MODE_ID;259vrr_mode_setting.settingType = NVDRS_DWORD_TYPE;260vrr_mode_setting.u32CurrentValue = VRR_MODE_FULLSCREEN_ONLY;261262if (!nvapi_err_check("NVAPI: Error calling NvAPI_DRS_SetSetting", NvAPI_DRS_SetSetting(session_handle, profile_handle, &vrr_mode_setting))) {263NvAPI_DRS_DestroySession(session_handle);264NvAPI_Unload();265return;266}267268if (!nvapi_err_check("NVAPI: Error saving settings", NvAPI_DRS_SaveSettings(session_handle))) {269NvAPI_DRS_DestroySession(session_handle);270NvAPI_Unload();271return;272}273274if (thread_control_val == OGL_THREAD_CONTROL_DISABLE) {275print_verbose("NVAPI: Disabled OpenGL threaded optimization successfully");276} else {277print_verbose("NVAPI: Enabled OpenGL threaded optimization successfully");278}279print_verbose("NVAPI: Disabled G-SYNC for windowed mode successfully");280281NvAPI_DRS_DestroySession(session_handle);282}283284int GLManagerNative_Windows::_find_or_create_display(GLWindow &win) {285// find display NYI, only 1 supported so far286if (_displays.size()) {287return 0;288}289290// create291GLDisplay d_temp = {};292_displays.push_back(d_temp);293int new_display_id = _displays.size() - 1;294295// create context296GLDisplay &d = _displays[new_display_id];297Error err = _create_context(win, d);298299if (err != OK) {300// not good301// delete the _display?302_displays.remove_at(new_display_id);303return -1;304}305306return new_display_id;307}308309static Error _configure_pixel_format(HDC hDC) {310static PIXELFORMATDESCRIPTOR pfd = {311sizeof(PIXELFORMATDESCRIPTOR), // Size Of This Pixel Format Descriptor3121,313PFD_DRAW_TO_WINDOW | // Format Must Support Window314PFD_SUPPORT_OPENGL | // Format Must Support OpenGL315PFD_DOUBLEBUFFER,316(BYTE)PFD_TYPE_RGBA,317(BYTE)(OS::get_singleton()->is_layered_allowed() ? 32 : 24),318(BYTE)0, (BYTE)0, (BYTE)0, (BYTE)0, (BYTE)0, (BYTE)0, // Color Bits Ignored319(BYTE)(OS::get_singleton()->is_layered_allowed() ? 8 : 0), // Alpha Buffer320(BYTE)0, // Shift Bit Ignored321(BYTE)0, // No Accumulation Buffer322(BYTE)0, (BYTE)0, (BYTE)0, (BYTE)0, // Accumulation Bits Ignored323(BYTE)24, // 24Bit Z-Buffer (Depth Buffer)324(BYTE)0, // No Stencil Buffer325(BYTE)0, // No Auxiliary Buffer326(BYTE)PFD_MAIN_PLANE, // Main Drawing Layer327(BYTE)0, // Reserved3280, 0, 0 // Layer Masks Ignored329};330331int pixel_format = ChoosePixelFormat(hDC, &pfd);332if (!pixel_format) // Did Windows Find A Matching Pixel Format?333{334return ERR_CANT_CREATE; // Return FALSE335}336337BOOL ret = SetPixelFormat(hDC, pixel_format, &pfd);338if (!ret) // Are We Able To Set The Pixel Format?339{340return ERR_CANT_CREATE; // Return FALSE341}342343return OK;344}345346PFNWGLCREATECONTEXT gd_wglCreateContext;347PFNWGLMAKECURRENT gd_wglMakeCurrent;348PFNWGLDELETECONTEXT gd_wglDeleteContext;349PFNWGLGETPROCADDRESS gd_wglGetProcAddress;350351Error GLManagerNative_Windows::_create_context(GLWindow &win, GLDisplay &gl_display) {352Error err = _configure_pixel_format(win.hDC);353if (err != OK) {354return err;355}356357HMODULE module = LoadLibraryW(L"opengl32.dll");358if (!module) {359return ERR_CANT_CREATE;360}361gd_wglCreateContext = (PFNWGLCREATECONTEXT)(void *)GetProcAddress(module, "wglCreateContext");362gd_wglMakeCurrent = (PFNWGLMAKECURRENT)(void *)GetProcAddress(module, "wglMakeCurrent");363gd_wglDeleteContext = (PFNWGLDELETECONTEXT)(void *)GetProcAddress(module, "wglDeleteContext");364gd_wglGetProcAddress = (PFNWGLGETPROCADDRESS)(void *)GetProcAddress(module, "wglGetProcAddress");365if (!gd_wglCreateContext || !gd_wglMakeCurrent || !gd_wglDeleteContext || !gd_wglGetProcAddress) {366return ERR_CANT_CREATE;367}368369gl_display.hRC = gd_wglCreateContext(win.hDC);370if (!gl_display.hRC) // Are We Able To Get A Rendering Context?371{372return ERR_CANT_CREATE; // Return FALSE373}374375if (!gd_wglMakeCurrent(win.hDC, gl_display.hRC)) {376ERR_PRINT("Could not attach OpenGL context to newly created window: " + format_error_message(GetLastError()));377}378379int attribs[] = {380WGL_CONTEXT_MAJOR_VERSION_ARB, 3, //we want a 3.3 context381WGL_CONTEXT_MINOR_VERSION_ARB, 3,382//and it shall be forward compatible so that we can only use up to date functionality383WGL_CONTEXT_PROFILE_MASK_ARB, WGL_CONTEXT_CORE_PROFILE_BIT_ARB,384WGL_CONTEXT_FLAGS_ARB, WGL_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB /*| _WGL_CONTEXT_DEBUG_BIT_ARB*/,3850386}; //zero indicates the end of the array387388PFNWGLCREATECONTEXTATTRIBSARBPROC wglCreateContextAttribsARB = nullptr; //pointer to the method389wglCreateContextAttribsARB = (PFNWGLCREATECONTEXTATTRIBSARBPROC)gd_wglGetProcAddress("wglCreateContextAttribsARB");390391if (wglCreateContextAttribsARB == nullptr) //OpenGL 3.0 is not supported392{393gd_wglDeleteContext(gl_display.hRC);394gl_display.hRC = nullptr;395return ERR_CANT_CREATE;396}397398HGLRC new_hRC = wglCreateContextAttribsARB(win.hDC, nullptr, attribs);399if (!new_hRC) {400gd_wglDeleteContext(gl_display.hRC);401gl_display.hRC = nullptr;402return ERR_CANT_CREATE;403}404405if (!gd_wglMakeCurrent(win.hDC, nullptr)) {406ERR_PRINT("Could not detach OpenGL context from newly created window: " + format_error_message(GetLastError()));407}408409gd_wglDeleteContext(gl_display.hRC);410gl_display.hRC = new_hRC;411412if (!gd_wglMakeCurrent(win.hDC, gl_display.hRC)) // Try to activate the rendering context.413{414ERR_PRINT("Could not attach OpenGL context to newly created window with replaced OpenGL context: " + format_error_message(GetLastError()));415gd_wglDeleteContext(gl_display.hRC);416gl_display.hRC = nullptr;417return ERR_CANT_CREATE;418}419420if (!wglSwapIntervalEXT) {421wglSwapIntervalEXT = (PFNWGLSWAPINTERVALEXTPROC)gd_wglGetProcAddress("wglSwapIntervalEXT");422}423424return OK;425}426427Error GLManagerNative_Windows::window_create(DisplayServer::WindowID p_window_id, HWND p_hwnd, HINSTANCE p_hinstance, int p_width, int p_height) {428HDC hDC = GetDC(p_hwnd);429if (!hDC) {430return ERR_CANT_CREATE;431}432433// configure the HDC to use a compatible pixel format434Error result = _configure_pixel_format(hDC);435if (result != OK) {436return result;437}438439GLWindow win;440win.hwnd = p_hwnd;441win.hDC = hDC;442443win.gldisplay_id = _find_or_create_display(win);444445if (win.gldisplay_id == -1) {446return FAILED;447}448449// WARNING: `p_window_id` is an eternally growing integer since popup windows keep coming and going450// and each of them has a higher id than the previous, so it must be used in a map not a vector.451_windows[p_window_id] = win;452453// make current454window_make_current(p_window_id);455456return OK;457}458459void GLManagerNative_Windows::window_destroy(DisplayServer::WindowID p_window_id) {460GLWindow &win = get_window(p_window_id);461if (_current_window == &win) {462_current_window = nullptr;463}464_windows.erase(p_window_id);465}466467void GLManagerNative_Windows::release_current() {468if (!_current_window) {469return;470}471472if (!gd_wglMakeCurrent(_current_window->hDC, nullptr)) {473ERR_PRINT("Could not detach OpenGL context from window marked current: " + format_error_message(GetLastError()));474}475476_current_window = nullptr;477}478479void GLManagerNative_Windows::window_make_current(DisplayServer::WindowID p_window_id) {480if (p_window_id == -1) {481return;482}483484// crash if our data structures are out of sync, i.e. not found485GLWindow &win = _windows[p_window_id];486487// noop488if (&win == _current_window) {489return;490}491492const GLDisplay &disp = get_display(win.gldisplay_id);493if (!gd_wglMakeCurrent(win.hDC, disp.hRC)) {494ERR_PRINT("Could not switch OpenGL context to other window: " + format_error_message(GetLastError()));495}496497_current_window = &win;498}499500void GLManagerNative_Windows::swap_buffers() {501SwapBuffers(_current_window->hDC);502}503504Error GLManagerNative_Windows::initialize() {505_nvapi_setup_profile();506return OK;507}508509void GLManagerNative_Windows::set_use_vsync(DisplayServer::WindowID p_window_id, bool p_use) {510GLWindow &win = get_window(p_window_id);511512if (&win != _current_window) {513window_make_current(p_window_id);514}515516if (wglSwapIntervalEXT) {517win.use_vsync = p_use;518519if (!wglSwapIntervalEXT(p_use ? 1 : 0)) {520WARN_PRINT_ONCE("Could not set V-Sync mode, as changing V-Sync mode is not supported by the graphics driver.");521}522} else {523WARN_PRINT_ONCE("Could not set V-Sync mode, as changing V-Sync mode is not supported by the graphics driver.");524}525}526527bool GLManagerNative_Windows::is_using_vsync(DisplayServer::WindowID p_window_id) const {528return get_window(p_window_id).use_vsync;529}530531HDC GLManagerNative_Windows::get_hdc(DisplayServer::WindowID p_window_id) {532return get_window(p_window_id).hDC;533}534535HGLRC GLManagerNative_Windows::get_hglrc(DisplayServer::WindowID p_window_id) {536const GLWindow &win = get_window(p_window_id);537const GLDisplay &disp = get_display(win.gldisplay_id);538return disp.hRC;539}540541GLManagerNative_Windows::GLManagerNative_Windows() {542direct_render = false;543glx_minor = glx_major = 0;544_current_window = nullptr;545}546547GLManagerNative_Windows::~GLManagerNative_Windows() {548release_current();549}550551#endif // WINDOWS_ENABLED && GLES3_ENABLED552553554