diff options
author | Clay John <claynjohn@gmail.com> | 2021-10-26 08:18:39 -0700 |
---|---|---|
committer | Hugo Locurcio <hugo.locurcio@hugo.pro> | 2021-10-31 15:56:45 +0100 |
commit | 8a10bb7d0dd0cc03353bb751af25a0eca1357c9d (patch) | |
tree | ae63bd8b1d4bacd65673f7bc455994ed4d288a84 /platform/windows/gl_manager_windows.cpp | |
parent | ce97ddbcb125228cc88fbfdcae932e110ee7daee (diff) | |
download | redot-engine-8a10bb7d0dd0cc03353bb751af25a0eca1357c9d.tar.gz |
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/gl_manager_windows.cpp')
-rw-r--r-- | platform/windows/gl_manager_windows.cpp | 74 |
1 files changed, 35 insertions, 39 deletions
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 |