summaryrefslogtreecommitdiff
path: root/platform/windows
diff options
context:
space:
mode:
authorClay John <claynjohn@gmail.com>2021-10-26 08:18:39 -0700
committerHugo Locurcio <hugo.locurcio@hugo.pro>2021-10-31 15:56:45 +0100
commit8a10bb7d0dd0cc03353bb751af25a0eca1357c9d (patch)
treeae63bd8b1d4bacd65673f7bc455994ed4d288a84 /platform/windows
parentce97ddbcb125228cc88fbfdcae932e110ee7daee (diff)
Use OpenGL 3.3 core profile instead of compatibility profile
- Rename OpenGL to GLES3 in the source code per community feedback. - The renderer is still exposed as "OpenGL 3" to the user. - Hide renderer selection dropdown until OpenGL support is more mature. - The renderer can still be changed in the Project Settings or using the `--rendering-driver opengl` command line argument. - Remove commented out exporter code. - Remove some OpenGL/DisplayServer-related debugging prints.
Diffstat (limited to 'platform/windows')
-rw-r--r--platform/windows/context_gl_windows.cpp186
-rw-r--r--platform/windows/detect.py4
-rw-r--r--platform/windows/display_server_windows.cpp69
-rw-r--r--platform/windows/display_server_windows.h4
-rw-r--r--platform/windows/gl_manager_windows.cpp74
-rw-r--r--platform/windows/gl_manager_windows.h5
6 files changed, 58 insertions, 284 deletions
diff --git a/platform/windows/context_gl_windows.cpp b/platform/windows/context_gl_windows.cpp
deleted file mode 100644
index 74b12cbb3b..0000000000
--- a/platform/windows/context_gl_windows.cpp
+++ /dev/null
@@ -1,186 +0,0 @@
-/*************************************************************************/
-/* context_gl_windows.cpp */
-/*************************************************************************/
-/* This file is part of: */
-/* GODOT ENGINE */
-/* https://godotengine.org */
-/*************************************************************************/
-/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */
-/* */
-/* Permission is hereby granted, free of charge, to any person obtaining */
-/* a copy of this software and associated documentation files (the */
-/* "Software"), to deal in the Software without restriction, including */
-/* without limitation the rights to use, copy, modify, merge, publish, */
-/* distribute, sublicense, and/or sell copies of the Software, and to */
-/* permit persons to whom the Software is furnished to do so, subject to */
-/* the following conditions: */
-/* */
-/* The above copyright notice and this permission notice shall be */
-/* included in all copies or substantial portions of the Software. */
-/* */
-/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
-/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
-/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
-/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
-/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
-/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
-/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
-/*************************************************************************/
-
-#if defined(OPENGL_ENABLED) || defined(GLES_ENABLED)
-
-// Author: Juan Linietsky <reduzio@gmail.com>, (C) 2008
-
-#include "context_gl_windows.h"
-
-#include <dwmapi.h>
-
-#define WGL_CONTEXT_MAJOR_VERSION_ARB 0x2091
-#define WGL_CONTEXT_MINOR_VERSION_ARB 0x2092
-#define WGL_CONTEXT_FLAGS_ARB 0x2094
-#define WGL_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB 0x00000002
-#define WGL_CONTEXT_PROFILE_MASK_ARB 0x9126
-#define WGL_CONTEXT_CORE_PROFILE_BIT_ARB 0x00000001
-
-#if defined(__GNUC__)
-// Workaround GCC warning from -Wcast-function-type.
-#define wglGetProcAddress (void *)wglGetProcAddress
-#endif
-
-typedef HGLRC(APIENTRY *PFNWGLCREATECONTEXTATTRIBSARBPROC)(HDC, HGLRC, const int *);
-
-void ContextGL_Windows::release_current() {
- wglMakeCurrent(hDC, nullptr);
-}
-
-void ContextGL_Windows::make_current() {
- wglMakeCurrent(hDC, hRC);
-}
-
-int ContextGL_Windows::get_window_width() {
- return OS::get_singleton()->get_video_mode().width;
-}
-
-int ContextGL_Windows::get_window_height() {
- return OS::get_singleton()->get_video_mode().height;
-}
-
-void ContextGL_Windows::swap_buffers() {
- SwapBuffers(hDC);
-}
-
-void ContextGL_Windows::set_use_vsync(bool p_use) {
- if (wglSwapIntervalEXT) {
- int swap_interval = p_use ? 1 : 0;
- wglSwapIntervalEXT(swap_interval);
- }
-
- use_vsync = p_use;
-}
-
-bool ContextGL_Windows::is_using_vsync() const {
- return use_vsync;
-}
-
-#define _WGL_CONTEXT_DEBUG_BIT_ARB 0x0001
-
-Error ContextGL_Windows::initialize() {
- static PIXELFORMATDESCRIPTOR pfd = {
- sizeof(PIXELFORMATDESCRIPTOR), // Size Of This Pixel Format Descriptor
- 1,
- PFD_DRAW_TO_WINDOW | // Format Must Support Window
- PFD_SUPPORT_OPENGL | // Format Must Support OpenGL
- PFD_DOUBLEBUFFER,
- (BYTE)PFD_TYPE_RGBA,
- (BYTE)(OS::get_singleton()->is_layered_allowed() ? 32 : 24),
- (BYTE)0, (BYTE)0, (BYTE)0, (BYTE)0, (BYTE)0, (BYTE)0, // Color Bits Ignored
- (BYTE)(OS::get_singleton()->is_layered_allowed() ? 8 : 0), // Alpha Buffer
- (BYTE)0, // Shift Bit Ignored
- (BYTE)0, // No Accumulation Buffer
- (BYTE)0, (BYTE)0, (BYTE)0, (BYTE)0, // Accumulation Bits Ignored
- (BYTE)24, // 24Bit Z-Buffer (Depth Buffer)
- (BYTE)0, // No Stencil Buffer
- (BYTE)0, // No Auxiliary Buffer
- (BYTE)PFD_MAIN_PLANE, // Main Drawing Layer
- (BYTE)0, // Reserved
- 0, 0, 0 // Layer Masks Ignored
- };
-
- hDC = GetDC(hWnd);
- if (!hDC) {
- return ERR_CANT_CREATE; // Return FALSE
- }
-
- pixel_format = ChoosePixelFormat(hDC, &pfd);
- if (!pixel_format) // Did Windows Find A Matching Pixel Format?
- {
- return ERR_CANT_CREATE; // Return FALSE
- }
-
- BOOL ret = SetPixelFormat(hDC, pixel_format, &pfd);
- if (!ret) // Are We Able To Set The Pixel Format?
- {
- return ERR_CANT_CREATE; // Return FALSE
- }
-
- hRC = wglCreateContext(hDC);
- if (!hRC) // Are We Able To Get A Rendering Context?
- {
- return ERR_CANT_CREATE; // Return FALSE
- }
-
- wglMakeCurrent(hDC, hRC);
-
- if (opengl_3_context) {
- int attribs[] = {
- WGL_CONTEXT_MAJOR_VERSION_ARB, 3, //we want a 3.3 context
- WGL_CONTEXT_MINOR_VERSION_ARB, 3,
- //and it shall be forward compatible so that we can only use up to date functionality
- WGL_CONTEXT_PROFILE_MASK_ARB, WGL_CONTEXT_CORE_PROFILE_BIT_ARB,
- WGL_CONTEXT_FLAGS_ARB, WGL_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB /*| _WGL_CONTEXT_DEBUG_BIT_ARB*/,
- 0
- }; //zero indicates the end of the array
-
- PFNWGLCREATECONTEXTATTRIBSARBPROC wglCreateContextAttribsARB = nullptr; //pointer to the method
- wglCreateContextAttribsARB = (PFNWGLCREATECONTEXTATTRIBSARBPROC)wglGetProcAddress("wglCreateContextAttribsARB");
-
- if (wglCreateContextAttribsARB == nullptr) //OpenGL 3.0 is not supported
- {
- wglDeleteContext(hRC);
- return ERR_CANT_CREATE;
- }
-
- HGLRC new_hRC = wglCreateContextAttribsARB(hDC, 0, attribs);
- if (!new_hRC) {
- wglDeleteContext(hRC);
- return ERR_CANT_CREATE; // Return false
- }
- wglMakeCurrent(hDC, nullptr);
- wglDeleteContext(hRC);
- hRC = new_hRC;
-
- if (!wglMakeCurrent(hDC, hRC)) // Try To Activate The Rendering Context
- {
- return ERR_CANT_CREATE; // Return FALSE
- }
- }
-
- wglSwapIntervalEXT = (PFNWGLSWAPINTERVALEXTPROC)wglGetProcAddress("wglSwapIntervalEXT");
- wglGetSwapIntervalEXT = (PFNWGLGETSWAPINTERVALEXTPROC)wglGetProcAddress("wglGetSwapIntervalEXT");
- //glWrapperInit(wrapper_get_proc_address);
-
- return OK;
-}
-
-ContextGL_Windows::ContextGL_Windows(HWND hwnd, bool p_opengl_3_context) {
- opengl_3_context = p_opengl_3_context;
- hWnd = hwnd;
- use_vsync = false;
- pixel_format = 0;
-}
-
-ContextGL_Windows::~ContextGL_Windows() {
-}
-
-#endif
diff --git a/platform/windows/detect.py b/platform/windows/detect.py
index 4740181df0..22fbbeb74f 100644
--- a/platform/windows/detect.py
+++ b/platform/windows/detect.py
@@ -279,7 +279,7 @@ def configure_msvc(env, manual_msvc_config):
if not env["use_volk"]:
LIBS += ["vulkan"]
- env.AppendUnique(CPPDEFINES=["OPENGL_ENABLED"])
+ env.AppendUnique(CPPDEFINES=["GLES3_ENABLED"])
LIBS += ["opengl32"]
env.Append(LINKFLAGS=[p + env["LIBSUFFIX"] for p in LIBS])
@@ -453,7 +453,7 @@ def configure_mingw(env):
if not env["use_volk"]:
env.Append(LIBS=["vulkan"])
- env.Append(CPPDEFINES=["OPENGL_ENABLED"])
+ env.Append(CPPDEFINES=["GLES3_ENABLED"])
env.Append(LIBS=["opengl32"])
env.Append(CPPDEFINES=["MINGW_ENABLED", ("MINGW_HAS_SECURE_API", 1)])
diff --git a/platform/windows/display_server_windows.cpp b/platform/windows/display_server_windows.cpp
index fda0bb1627..e2c9951692 100644
--- a/platform/windows/display_server_windows.cpp
+++ b/platform/windows/display_server_windows.cpp
@@ -38,8 +38,8 @@
#include <avrt.h>
-#if defined(OPENGL_ENABLED)
-#include "drivers/opengl/rasterizer_opengl.h"
+#if defined(GLES3_ENABLED)
+#include "drivers/gles3/rasterizer_gles3.h"
#endif
static String format_error_message(DWORD id) {
@@ -537,8 +537,8 @@ void DisplayServerWindows::delete_sub_window(WindowID p_window) {
context_vulkan->window_destroy(p_window);
}
#endif
-#ifdef OPENGL_ENABLED
- if (rendering_driver == "opengl") {
+#ifdef GLES3_ENABLED
+ if (rendering_driver == "opengl3") {
gl_manager->window_destroy(p_window);
}
#endif
@@ -552,7 +552,7 @@ void DisplayServerWindows::delete_sub_window(WindowID p_window) {
}
void DisplayServerWindows::gl_window_make_current(DisplayServer::WindowID p_window_id) {
-#if defined(OPENGL_ENABLED)
+#if defined(GLES3_ENABLED)
gl_manager->window_make_current(p_window_id);
#endif
}
@@ -827,8 +827,8 @@ void DisplayServerWindows::window_set_size(const Size2i p_size, WindowID p_windo
context_vulkan->window_resize(p_window, w, h);
}
#endif
-#if defined(OPENGL_ENABLED)
- if (rendering_driver == "opengl") {
+#if defined(GLES3_ENABLED)
+ if (rendering_driver == "opengl3") {
gl_manager->window_resize(p_window, w, h);
}
#endif
@@ -1611,7 +1611,7 @@ void DisplayServerWindows::make_rendering_thread() {
}
void DisplayServerWindows::swap_buffers() {
-#if defined(OPENGL_ENABLED)
+#if defined(GLES3_ENABLED)
gl_manager->swap_buffers();
#endif
}
@@ -3110,9 +3110,8 @@ DisplayServer::WindowID DisplayServerWindows::_create_window(WindowMode p_mode,
}
#endif
-#ifdef OPENGL_ENABLED
- print_line("rendering_driver " + rendering_driver);
- if (rendering_driver == "opengl") {
+#ifdef GLES3_ENABLED
+ if (rendering_driver == "opengl3") {
Error err = gl_manager->window_create(id, wd.hWnd, hInstance, WindowRect.right - WindowRect.left, WindowRect.bottom - WindowRect.top);
ERR_FAIL_COND_V_MSG(err != OK, INVALID_WINDOW_ID, "Failed to create an OpenGL window.");
}
@@ -3326,8 +3325,6 @@ DisplayServerWindows::DisplayServerWindows(const String &p_rendering_driver, Win
use_raw_input = false;
}
- print_line("rendering_driver " + rendering_driver);
-
#if defined(VULKAN_ENABLED)
if (rendering_driver == "vulkan") {
context_vulkan = memnew(VulkanContextWindows);
@@ -3340,9 +3337,9 @@ DisplayServerWindows::DisplayServerWindows(const String &p_rendering_driver, Win
}
#endif
// Init context and rendering device
-#if defined(OPENGL_ENABLED)
+#if defined(GLES3_ENABLED)
- if (rendering_driver == "opengl") {
+ if (rendering_driver == "opengl3") {
GLManager_Windows::ContextType opengl_api_type = GLManager_Windows::GLES_3_0_COMPATIBLE;
gl_manager = memnew(GLManager_Windows(opengl_api_type));
@@ -3355,42 +3352,10 @@ DisplayServerWindows::DisplayServerWindows(const String &p_rendering_driver, Win
}
// gl_manager->set_use_vsync(current_videomode.use_vsync);
-
- if (true) {
- RasterizerOpenGL::make_current();
- } else {
- memdelete(gl_manager);
- gl_manager = nullptr;
- r_error = ERR_UNAVAILABLE;
- return;
- }
+ RasterizerGLES3::make_current();
}
#endif
- /*
-#if defined(OPENGL_ENABLED)
- if (rendering_driver_index == VIDEO_DRIVER_GLES2) {
- context_gles2 = memnew(ContextGL_Windows(hWnd, false));
-
- if (context_gles2->initialize() != OK) {
- memdelete(context_gles2);
- context_gles2 = nullptr;
- ERR_FAIL_V(ERR_UNAVAILABLE);
- }
-
- context_gles2->set_use_vsync(video_mode.use_vsync);
-
- if (RasterizerOpenGL::is_viable() == OK) {
- RasterizerOpenGL::register_config();
- RasterizerOpenGL::make_current();
- } else {
- memdelete(context_gles2);
- context_gles2 = nullptr;
- ERR_FAIL_V(ERR_UNAVAILABLE);
- }
- }
-#endif
- */
Point2i window_position(
(screen_get_size(0).width - p_resolution.width) / 2,
(screen_get_size(0).height - p_resolution.height) / 2);
@@ -3448,8 +3413,8 @@ Vector<String> DisplayServerWindows::get_rendering_drivers_func() {
#ifdef VULKAN_ENABLED
drivers.push_back("vulkan");
#endif
-#ifdef OPENGL_ENABLED
- drivers.push_back("opengl");
+#ifdef GLES3_ENABLED
+ drivers.push_back("opengl3");
#endif
return drivers;
@@ -3479,7 +3444,7 @@ DisplayServerWindows::~DisplayServerWindows() {
SetWindowLongPtr(windows[MAIN_WINDOW_ID].hWnd, GWLP_WNDPROC, (LONG_PTR)user_proc);
};
-#ifdef OPENGL_ENABLED
+#ifdef GLES3_ENABLED
// destroy windows .. NYI?
#endif
@@ -3511,7 +3476,7 @@ DisplayServerWindows::~DisplayServerWindows() {
if (restore_mouse_trails > 1) {
SystemParametersInfoA(SPI_SETMOUSETRAILS, restore_mouse_trails, 0, 0);
}
-#ifdef OPENGL_ENABLED
+#ifdef GLES3_ENABLED
if (gl_manager) {
memdelete(gl_manager);
gl_manager = nullptr;
diff --git a/platform/windows/display_server_windows.h b/platform/windows/display_server_windows.h
index 86f47eabc8..8e2c346d5b 100644
--- a/platform/windows/display_server_windows.h
+++ b/platform/windows/display_server_windows.h
@@ -56,7 +56,7 @@
#include "platform/windows/vulkan_context_win.h"
#endif
-#if defined(OPENGL_ENABLED)
+#if defined(GLES3_ENABLED)
#include "gl_manager_windows.h"
#endif
@@ -304,7 +304,7 @@ class DisplayServerWindows : public DisplayServer {
int old_x, old_y;
Point2i center;
-#if defined(OPENGL_ENABLED)
+#if defined(GLES3_ENABLED)
GLManager_Windows *gl_manager;
#endif
diff --git a/platform/windows/gl_manager_windows.cpp b/platform/windows/gl_manager_windows.cpp
index 8a79da987b..98205d6282 100644
--- a/platform/windows/gl_manager_windows.cpp
+++ b/platform/windows/gl_manager_windows.cpp
@@ -31,7 +31,7 @@
#include "gl_manager_windows.h"
#ifdef WINDOWS_ENABLED
-#ifdef OPENGL_ENABLED
+#ifdef GLES3_ENABLED
#include <stdio.h>
#include <stdlib.h>
@@ -129,50 +129,46 @@ Error GLManager_Windows::_create_context(GLWindow &win, GLDisplay &gl_display) {
wglMakeCurrent(hDC, gl_display.hRC);
- if (opengl_3_context) {
- int attribs[] = {
- WGL_CONTEXT_MAJOR_VERSION_ARB, 3, //we want a 3.3 context
- WGL_CONTEXT_MINOR_VERSION_ARB, 3,
- //and it shall be forward compatible so that we can only use up to date functionality
- WGL_CONTEXT_PROFILE_MASK_ARB, WGL_CONTEXT_CORE_PROFILE_BIT_ARB,
- WGL_CONTEXT_FLAGS_ARB, WGL_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB /*| _WGL_CONTEXT_DEBUG_BIT_ARB*/,
- 0
- }; //zero indicates the end of the array
-
- PFNWGLCREATECONTEXTATTRIBSARBPROC wglCreateContextAttribsARB = nullptr; //pointer to the method
- wglCreateContextAttribsARB = (PFNWGLCREATECONTEXTATTRIBSARBPROC)wglGetProcAddress("wglCreateContextAttribsARB");
-
- if (wglCreateContextAttribsARB == nullptr) //OpenGL 3.0 is not supported
- {
- wglDeleteContext(gl_display.hRC);
- gl_display.hRC = 0;
- return ERR_CANT_CREATE;
- }
-
- HGLRC new_hRC = wglCreateContextAttribsARB(hDC, 0, attribs);
- if (!new_hRC) {
- wglDeleteContext(gl_display.hRC);
- gl_display.hRC = 0;
- return ERR_CANT_CREATE; // Return false
- }
- wglMakeCurrent(hDC, nullptr);
+ int attribs[] = {
+ WGL_CONTEXT_MAJOR_VERSION_ARB, 3, //we want a 3.3 context
+ WGL_CONTEXT_MINOR_VERSION_ARB, 3,
+ //and it shall be forward compatible so that we can only use up to date functionality
+ WGL_CONTEXT_PROFILE_MASK_ARB, WGL_CONTEXT_CORE_PROFILE_BIT_ARB,
+ WGL_CONTEXT_FLAGS_ARB, WGL_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB /*| _WGL_CONTEXT_DEBUG_BIT_ARB*/,
+ 0
+ }; //zero indicates the end of the array
+
+ PFNWGLCREATECONTEXTATTRIBSARBPROC wglCreateContextAttribsARB = nullptr; //pointer to the method
+ wglCreateContextAttribsARB = (PFNWGLCREATECONTEXTATTRIBSARBPROC)wglGetProcAddress("wglCreateContextAttribsARB");
+
+ if (wglCreateContextAttribsARB == nullptr) //OpenGL 3.0 is not supported
+ {
+ wglDeleteContext(gl_display.hRC);
+ gl_display.hRC = 0;
+ return ERR_CANT_CREATE;
+ }
+
+ HGLRC new_hRC = wglCreateContextAttribsARB(hDC, 0, attribs);
+ if (!new_hRC) {
wglDeleteContext(gl_display.hRC);
- gl_display.hRC = new_hRC;
-
- if (!wglMakeCurrent(hDC, gl_display.hRC)) // Try To Activate The Rendering Context
- {
- wglDeleteContext(gl_display.hRC);
- gl_display.hRC = 0;
- return ERR_CANT_CREATE; // Return FALSE
- }
+ gl_display.hRC = 0;
+ return ERR_CANT_CREATE; // Return false
+ }
+ wglMakeCurrent(hDC, nullptr);
+ wglDeleteContext(gl_display.hRC);
+ gl_display.hRC = new_hRC;
+
+ if (!wglMakeCurrent(hDC, gl_display.hRC)) // Try To Activate The Rendering Context
+ {
+ wglDeleteContext(gl_display.hRC);
+ gl_display.hRC = 0;
+ return ERR_CANT_CREATE; // Return FALSE
}
return OK;
}
Error GLManager_Windows::window_create(DisplayServer::WindowID p_window_id, HWND p_hwnd, HINSTANCE p_hinstance, int p_width, int p_height) {
- print_line("window_create window id " + itos(p_window_id));
-
HDC hdc = GetDC(p_hwnd);
if (!hdc) {
return ERR_CANT_CREATE; // Return FALSE
@@ -349,5 +345,5 @@ GLManager_Windows::~GLManager_Windows() {
release_current();
}
-#endif // OPENGL_ENABLED
+#endif // GLES3_ENABLED
#endif // WINDOWS
diff --git a/platform/windows/gl_manager_windows.h b/platform/windows/gl_manager_windows.h
index 53557cf68e..9733a57420 100644
--- a/platform/windows/gl_manager_windows.h
+++ b/platform/windows/gl_manager_windows.h
@@ -31,7 +31,7 @@
#ifndef GL_MANAGER_WINDOWS_H
#define GL_MANAGER_WINDOWS_H
-#if defined(WINDOWS_ENABLED) && defined(OPENGL_ENABLED)
+#if defined(WINDOWS_ENABLED) && defined(GLES3_ENABLED)
#include "core/error/error_list.h"
#include "core/os/os.h"
@@ -76,7 +76,6 @@ private:
LocalVector<GLDisplay> _displays;
GLWindow *_current_window;
- bool opengl_3_context = false;
PFNWGLSWAPINTERVALEXTPROC wglSwapIntervalEXT;
PFNWGLGETSWAPINTERVALEXTPROC wglGetSwapIntervalEXT;
@@ -123,6 +122,6 @@ public:
~GLManager_Windows();
};
-#endif // defined(WINDOWS_ENABLED) && defined(OPENGL_ENABLED)
+#endif // defined(WINDOWS_ENABLED) && defined(GLES3_ENABLED)
#endif // GL_MANAGER_WINDOWS_H