dep/glad: Update to v2.0.5

This commit is contained in:
Stenzek
2024-02-25 15:32:26 +10:00
parent fcb8ce1ebc
commit 143fb0876d
36 changed files with 30541 additions and 35576 deletions

View File

@ -130,11 +130,6 @@ if(ENABLE_OPENGL)
gl/context_egl_x11.cpp
gl/context_egl_x11.h
)
# We set EGL_NO_X11 because otherwise X comes in with its macros and breaks
# a bunch of files from compiling, if we include the EGL headers. This just
# makes the data types opaque, we can still use it with X11 if needed.
target_compile_definitions(util PRIVATE "-DEGL_NO_X11=1")
endif()
if(ENABLE_WAYLAND)
target_sources(util PRIVATE

View File

@ -186,7 +186,7 @@ std::unique_ptr<GL::Context> Context::Create(const WindowInfo& wi, Error* error)
// load up glad
if (!context->IsGLES())
{
if (!gladLoadGLLoader([](const char* name) { return context_being_created->GetProcAddress(name); }))
if (!gladLoadGL([](const char* name) { return (GLADapiproc)context_being_created->GetProcAddress(name); }))
{
Error::SetStringView(error, "Failed to load GL functions for GLAD");
return nullptr;
@ -194,7 +194,7 @@ std::unique_ptr<GL::Context> Context::Create(const WindowInfo& wi, Error* error)
}
else
{
if (!gladLoadGLES2Loader([](const char* name) { return context_being_created->GetProcAddress(name); }))
if (!gladLoadGLES2([](const char* name) { return (GLADapiproc)context_being_created->GetProcAddress(name); }))
{
Error::SetStringView(error, "Failed to load GLES functions for GLAD");
return nullptr;

View File

@ -55,7 +55,7 @@ public:
virtual bool MakeCurrent() = 0;
virtual bool DoneCurrent() = 0;
virtual bool SetSwapInterval(s32 interval) = 0;
virtual std::unique_ptr<Context> CreateSharedContext(const WindowInfo& wi) = 0;
virtual std::unique_ptr<Context> CreateSharedContext(const WindowInfo& wi, Error* error) = 0;
virtual std::vector<FullscreenModeInfo> EnumerateFullscreenModes();

View File

@ -2,8 +2,8 @@
// SPDX-License-Identifier: (GPL-3.0 OR CC-BY-NC-ND-4.0)
#pragma once
#include "context.h"
#include "../opengl_loader.h"
#include "context.h"
#if defined(__APPLE__) && defined(__OBJC__)
#import <AppKit/AppKit.h>
@ -32,7 +32,7 @@ public:
bool MakeCurrent() override;
bool DoneCurrent() override;
bool SetSwapInterval(s32 interval) override;
std::unique_ptr<Context> CreateSharedContext(const WindowInfo& wi) override;
std::unique_ptr<Context> CreateSharedContext(const WindowInfo& wi, Error* error) override;
private:
ALWAYS_INLINE NSView* GetView() const { return static_cast<NSView*>((__bridge NSView*)m_wi.window_handle); }

View File

@ -3,6 +3,7 @@
#include "context_agl.h"
#include "common/assert.h"
#include "common/error.h"
#include "common/log.h"
#include <dlfcn.h>
Log_SetChannel(GL::Context);
@ -53,10 +54,11 @@ bool ContextAGL::Initialize(const std::span<const Version> versions_to_try)
{
if (cv.major_version > 4 || cv.minor_version > 1)
continue;
const NSOpenGLPixelFormatAttribute profile = (cv.major_version > 3 || cv.minor_version > 2) ? NSOpenGLProfileVersion4_1Core : NSOpenGLProfileVersion3_2Core;
const NSOpenGLPixelFormatAttribute profile =
(cv.major_version > 3 || cv.minor_version > 2) ? NSOpenGLProfileVersion4_1Core : NSOpenGLProfileVersion3_2Core;
if (CreateContext(nullptr, static_cast<int>(profile), true))
{
{
m_version = cv;
return true;
}
@ -142,13 +144,16 @@ bool ContextAGL::SetSwapInterval(s32 interval)
return true;
}
std::unique_ptr<Context> ContextAGL::CreateSharedContext(const WindowInfo& wi)
std::unique_ptr<Context> ContextAGL::CreateSharedContext(const WindowInfo& wi, Error* error)
{
std::unique_ptr<ContextAGL> context = std::make_unique<ContextAGL>(wi);
context->m_context = [[NSOpenGLContext alloc] initWithFormat:m_pixel_format shareContext:m_context];
if (context->m_context == nil)
{
Error::SetStringView(error, "NSOpenGLContext initWithFormat failed");
return nullptr;
}
context->m_version = m_version;
context->m_pixel_format = m_pixel_format;
@ -156,7 +161,7 @@ std::unique_ptr<Context> ContextAGL::CreateSharedContext(const WindowInfo& wi)
if (wi.type == WindowInfo::Type::MacOS)
context->BindContextToView();
return context;
}
@ -171,12 +176,9 @@ bool ContextAGL::CreateContext(NSOpenGLContext* share_context, int profile, bool
if (m_pixel_format)
[m_pixel_format release];
const std::array<NSOpenGLPixelFormatAttribute, 5> attribs = {{
NSOpenGLPFADoubleBuffer,
NSOpenGLPFAOpenGLProfile,
static_cast<NSOpenGLPixelFormatAttribute>(profile),
NSOpenGLPFAAccelerated,
0}};
const std::array<NSOpenGLPixelFormatAttribute, 5> attribs = {{NSOpenGLPFADoubleBuffer, NSOpenGLPFAOpenGLProfile,
static_cast<NSOpenGLPixelFormatAttribute>(profile),
NSOpenGLPFAAccelerated, 0}};
m_pixel_format = [[NSOpenGLPixelFormat alloc] initWithAttributes:attribs.data()];
if (m_pixel_format == nil)
{

View File

@ -4,26 +4,74 @@
#include "context_egl.h"
#include "common/assert.h"
#include "common/log.h"
#include "common/dynamic_library.h"
#include "common/error.h"
#include "common/log.h"
#include <atomic>
#include <optional>
#include <vector>
Log_SetChannel(GL::Context);
static DynamicLibrary s_egl_library;
static std::atomic_uint32_t s_egl_refcount = 0;
static bool LoadEGL()
{
// We're not going to be calling this from multiple threads concurrently.
// So, not wrapping this in a mutex should be fine.
if (s_egl_refcount.fetch_add(1, std::memory_order_acq_rel) == 0)
{
DebugAssert(!s_egl_library.IsOpen());
const std::string egl_libname = DynamicLibrary::GetVersionedFilename("libEGL");
Log_InfoFmt("Loading EGL from {}...", egl_libname);
Error error;
if (!s_egl_library.Open(egl_libname.c_str(), &error))
Log_ErrorFmt("Failed to load EGL: {}", error.GetDescription());
}
return s_egl_library.IsOpen();
}
static void UnloadEGL()
{
DebugAssert(s_egl_refcount.load(std::memory_order_acquire) > 0);
if (s_egl_refcount.fetch_sub(1, std::memory_order_acq_rel) == 1)
{
Log_InfoPrint("Unloading EGL.");
s_egl_library.Close();
}
}
static bool LoadGLADEGL(EGLDisplay display, Error* error)
{
if (!gladLoadEGL(display, [](const char* name) { return (GLADapiproc)s_egl_library.GetSymbolAddress(name); }))
{
Error::SetStringView(error, "Loading GLAD EGL functions failed");
return false;
}
return true;
}
namespace GL {
ContextEGL::ContextEGL(const WindowInfo& wi) : Context(wi)
{
LoadEGL();
}
ContextEGL::~ContextEGL()
{
DestroySurface();
DestroyContext();
UnloadEGL();
}
std::unique_ptr<Context> ContextEGL::Create(const WindowInfo& wi, std::span<const Version> versions_to_try, Error* error)
std::unique_ptr<Context> ContextEGL::Create(const WindowInfo& wi, std::span<const Version> versions_to_try,
Error* error)
{
std::unique_ptr<ContextEGL> context = std::make_unique<ContextEGL>(wi);
if (!context->Initialize(versions_to_try, error))
@ -34,30 +82,29 @@ std::unique_ptr<Context> ContextEGL::Create(const WindowInfo& wi, std::span<cons
bool ContextEGL::Initialize(std::span<const Version> versions_to_try, Error* error)
{
if (!gladLoadEGL())
{
Log_ErrorPrint("Loading GLAD EGL functions failed");
Error::SetStringView(error, "Loading GLAD EGL functions failed");
if (!LoadGLADEGL(EGL_NO_DISPLAY, error))
return false;
}
if (!SetDisplay())
return false;
// Re-initialize GLAD.
if (!LoadGLADEGL(m_display, error))
return false;
int egl_major, egl_minor;
if (!eglInitialize(m_display, &egl_major, &egl_minor))
{
const int gerror = static_cast<int>(eglGetError());
Log_ErrorFmt("eglInitialize() failed: {} (0x{:X})", gerror, gerror);
Error::SetStringFmt(error, "eglInitialize() failed: {} (0x{:X})", gerror, gerror);
return false;
}
Log_InfoPrintf("EGL Version: %d.%d", egl_major, egl_minor);
Log_InfoFmt("EGL Version: {}.{}", egl_major, egl_minor);
const char* extensions = eglQueryString(m_display, EGL_EXTENSIONS);
if (extensions)
{
Log_InfoPrintf("EGL Extensions: %s", extensions);
Log_DebugFmt("EGL Extensions: {}", extensions);
m_supports_surfaceless = std::strstr(extensions, "EGL_KHR_surfaceless_context") != nullptr;
}
if (!m_supports_surfaceless)
@ -168,14 +215,17 @@ bool ContextEGL::SetSwapInterval(s32 interval)
return eglSwapInterval(m_display, interval);
}
std::unique_ptr<Context> ContextEGL::CreateSharedContext(const WindowInfo& wi)
std::unique_ptr<Context> ContextEGL::CreateSharedContext(const WindowInfo& wi, Error* error)
{
std::unique_ptr<ContextEGL> context = std::make_unique<ContextEGL>(wi);
context->m_display = m_display;
context->m_supports_surfaceless = m_supports_surfaceless;
if (!context->CreateContextAndSurface(m_version, m_context, false))
{
Error::SetStringView(error, "Failed to create context/surface");
return nullptr;
}
return context;
}

View File

@ -5,7 +5,7 @@
#include "context.h"
#include "glad_egl.h"
#include "glad/egl.h"
namespace GL {
@ -25,7 +25,7 @@ public:
bool MakeCurrent() override;
bool DoneCurrent() override;
bool SetSwapInterval(s32 interval) override;
virtual std::unique_ptr<Context> CreateSharedContext(const WindowInfo& wi) override;
virtual std::unique_ptr<Context> CreateSharedContext(const WindowInfo& wi, Error* error) override;
protected:
virtual bool SetDisplay();

View File

@ -33,7 +33,7 @@ std::unique_ptr<Context> ContextEGLWayland::Create(const WindowInfo& wi, std::sp
return context;
}
std::unique_ptr<Context> ContextEGLWayland::CreateSharedContext(const WindowInfo& wi)
std::unique_ptr<Context> ContextEGLWayland::CreateSharedContext(const WindowInfo& wi, Error* error)
{
std::unique_ptr<ContextEGLWayland> context = std::make_unique<ContextEGLWayland>(wi);
context->m_display = m_display;

View File

@ -15,7 +15,7 @@ public:
static std::unique_ptr<Context> Create(const WindowInfo& wi, std::span<const Version> versions_to_try, Error* error);
std::unique_ptr<Context> CreateSharedContext(const WindowInfo& wi) override;
std::unique_ptr<Context> CreateSharedContext(const WindowInfo& wi, Error* error) override;
void ResizeSurface(u32 new_surface_width = 0, u32 new_surface_height = 0) override;
protected:

View File

@ -19,7 +19,7 @@ std::unique_ptr<Context> ContextEGLX11::Create(const WindowInfo& wi, std::span<c
return context;
}
std::unique_ptr<Context> ContextEGLX11::CreateSharedContext(const WindowInfo& wi)
std::unique_ptr<Context> ContextEGLX11::CreateSharedContext(const WindowInfo& wi, Error* error)
{
std::unique_ptr<ContextEGLX11> context = std::make_unique<ContextEGLX11>(wi);
context->m_display = m_display;

View File

@ -14,7 +14,7 @@ public:
static std::unique_ptr<Context> Create(const WindowInfo& wi, std::span<const Version> versions_to_try, Error* error);
std::unique_ptr<Context> CreateSharedContext(const WindowInfo& wi) override;
std::unique_ptr<Context> CreateSharedContext(const WindowInfo& wi, Error* error) override;
void ResizeSurface(u32 new_surface_width = 0, u32 new_surface_height = 0) override;
protected:

View File

@ -27,7 +27,7 @@ static void* GetProcAddressCallback(const char* name)
static bool ReloadWGL(HDC dc)
{
if (!gladLoadWGLLoader([](const char* name) -> void* { return wglGetProcAddress(name); }, dc))
if (!gladLoadWGL(dc, [](const char* name) { return (GLADapiproc)wglGetProcAddress(name); }))
{
Log_ErrorPrint("Loading GLAD WGL functions failed");
return false;
@ -66,27 +66,18 @@ bool ContextWGL::Initialize(std::span<const Version> versions_to_try, Error* err
{
if (m_wi.type == WindowInfo::Type::Win32)
{
if (!InitializeDC())
{
Error::SetStringView(error, "Failed to create DC.");
if (!InitializeDC(error))
return false;
}
}
else
{
if (!CreatePBuffer())
{
Error::SetStringView(error, "Failed to create PBuffer");
if (!CreatePBuffer(error))
return false;
}
}
// Everything including core/ES requires a dummy profile to load the WGL extensions.
if (!CreateAnyContext(nullptr, true))
{
Error::SetStringView(error, "Failed to create dummy context.");
if (!CreateAnyContext(nullptr, true, error))
return false;
}
for (const Version& cv : versions_to_try)
{
@ -96,7 +87,7 @@ bool ContextWGL::Initialize(std::span<const Version> versions_to_try, Error* err
m_version = cv;
return true;
}
else if (CreateVersionContext(cv, nullptr, true))
else if (CreateVersionContext(cv, nullptr, true, error))
{
m_version = cv;
return true;
@ -115,16 +106,21 @@ void* ContextWGL::GetProcAddress(const char* name)
bool ContextWGL::ChangeSurface(const WindowInfo& new_wi)
{
const bool was_current = (wglGetCurrentContext() == m_rc);
Error error;
ReleaseDC();
m_wi = new_wi;
if (!InitializeDC())
if (!InitializeDC(&error))
{
Log_ErrorFmt("Failed to change surface: {}", error.GetDescription());
return false;
}
if (was_current && !wglMakeCurrent(m_dc, m_rc))
{
Log_ErrorPrintf("Failed to make context current again after surface change: 0x%08X", GetLastError());
error.SetWin32(GetLastError());
Log_ErrorFmt("Failed to make context current again after surface change: {}", error.GetDescription());
return false;
}
@ -153,7 +149,7 @@ bool ContextWGL::MakeCurrent()
{
if (!wglMakeCurrent(m_dc, m_rc))
{
Log_ErrorPrintf("wglMakeCurrent() failed: 0x%08X", GetLastError());
Log_ErrorFmt("wglMakeCurrent() failed: {}", GetLastError());
return false;
}
@ -173,28 +169,28 @@ bool ContextWGL::SetSwapInterval(s32 interval)
return wglSwapIntervalEXT(interval);
}
std::unique_ptr<Context> ContextWGL::CreateSharedContext(const WindowInfo& wi)
std::unique_ptr<Context> ContextWGL::CreateSharedContext(const WindowInfo& wi, Error* error)
{
std::unique_ptr<ContextWGL> context = std::make_unique<ContextWGL>(wi);
if (wi.type == WindowInfo::Type::Win32)
{
if (!context->InitializeDC())
if (!context->InitializeDC(error))
return nullptr;
}
else
{
if (!context->CreatePBuffer())
if (!context->CreatePBuffer(error))
return nullptr;
}
if (m_version.profile == Profile::NoProfile)
{
if (!context->CreateAnyContext(m_rc, false))
if (!context->CreateAnyContext(m_rc, false, error))
return nullptr;
}
else
{
if (!context->CreateVersionContext(m_version, m_rc, false))
if (!context->CreateVersionContext(m_version, m_rc, false, error))
return nullptr;
}
@ -202,7 +198,7 @@ std::unique_ptr<Context> ContextWGL::CreateSharedContext(const WindowInfo& wi)
return context;
}
HDC ContextWGL::GetDCAndSetPixelFormat(HWND hwnd)
HDC ContextWGL::GetDCAndSetPixelFormat(HWND hwnd, Error* error)
{
PIXELFORMATDESCRIPTOR pfd = {};
pfd.nSize = sizeof(pfd);
@ -218,7 +214,7 @@ HDC ContextWGL::GetDCAndSetPixelFormat(HWND hwnd)
HDC hDC = ::GetDC(hwnd);
if (!hDC)
{
Log_ErrorPrintf("GetDC() failed: 0x%08X", GetLastError());
Error::SetWin32(error, "GetDC() failed: ", GetLastError());
return {};
}
@ -227,7 +223,7 @@ HDC ContextWGL::GetDCAndSetPixelFormat(HWND hwnd)
const int pf = ChoosePixelFormat(hDC, &pfd);
if (pf == 0)
{
Log_ErrorPrintf("ChoosePixelFormat() failed: 0x%08X", GetLastError());
Error::SetWin32(error, "ChoosePixelFormat() failed: ", GetLastError());
::ReleaseDC(hwnd, hDC);
return {};
}
@ -237,7 +233,7 @@ HDC ContextWGL::GetDCAndSetPixelFormat(HWND hwnd)
if (!SetPixelFormat(hDC, m_pixel_format.value(), &pfd))
{
Log_ErrorPrintf("SetPixelFormat() failed: 0x%08X", GetLastError());
Error::SetWin32(error, "SetPixelFormat() failed: ", GetLastError());
::ReleaseDC(hwnd, hDC);
return {};
}
@ -246,26 +242,23 @@ HDC ContextWGL::GetDCAndSetPixelFormat(HWND hwnd)
return hDC;
}
bool ContextWGL::InitializeDC()
bool ContextWGL::InitializeDC(Error* error)
{
if (m_wi.type == WindowInfo::Type::Win32)
{
m_dc = GetDCAndSetPixelFormat(GetHWND());
m_dc = GetDCAndSetPixelFormat(GetHWND(), error);
if (!m_dc)
{
Log_ErrorPrint("Failed to get DC for window");
return false;
}
return true;
}
else if (m_wi.type == WindowInfo::Type::Surfaceless)
{
return CreatePBuffer();
return CreatePBuffer(error);
}
else
{
Log_ErrorPrintf("Unknown window info type %u", static_cast<unsigned>(m_wi.type));
Error::SetStringFmt(error, "Unknown window info type {}", static_cast<unsigned>(m_wi.type));
return false;
}
}
@ -293,7 +286,7 @@ void ContextWGL::ReleaseDC()
}
}
bool ContextWGL::CreatePBuffer()
bool ContextWGL::CreatePBuffer(Error* error)
{
static bool window_class_registered = false;
static const wchar_t* window_class_name = L"ContextWGLPBuffer";
@ -316,7 +309,7 @@ bool ContextWGL::CreatePBuffer()
if (!RegisterClassExW(&wc))
{
Log_ErrorPrint("(ContextWGL::CreatePBuffer) RegisterClassExW() failed");
Error::SetStringView(error, "(ContextWGL::CreatePBuffer) RegisterClassExW() failed");
return false;
}
@ -326,13 +319,13 @@ bool ContextWGL::CreatePBuffer()
HWND hwnd = CreateWindowExW(0, window_class_name, window_class_name, 0, 0, 0, 0, 0, NULL, NULL, NULL, NULL);
if (!hwnd)
{
Log_ErrorPrint("(ContextWGL::CreatePBuffer) CreateWindowEx() failed");
Error::SetStringView(error, "(ContextWGL::CreatePBuffer) CreateWindowEx() failed");
return false;
}
ScopedGuard hwnd_guard([hwnd]() { DestroyWindow(hwnd); });
HDC hdc = GetDCAndSetPixelFormat(hwnd);
HDC hdc = GetDCAndSetPixelFormat(hwnd, error);
if (!hdc)
return false;
@ -355,13 +348,13 @@ bool ContextWGL::CreatePBuffer()
temp_rc = wglCreateContext(hdc);
if (!temp_rc || !wglMakeCurrent(hdc, temp_rc))
{
Log_ErrorPrint("Failed to create temporary context to load WGL for pbuffer.");
Error::SetStringView(error, "Failed to create temporary context to load WGL for pbuffer.");
return false;
}
if (!ReloadWGL(hdc) || !GLAD_WGL_ARB_pbuffer)
{
Log_ErrorPrint("Missing WGL_ARB_pbuffer");
Error::SetStringView(error, "Missing WGL_ARB_pbuffer");
return false;
}
}
@ -370,7 +363,7 @@ bool ContextWGL::CreatePBuffer()
HPBUFFERARB pbuffer = wglCreatePbufferARB(hdc, m_pixel_format.value(), 1, 1, pb_attribs);
if (!pbuffer)
{
Log_ErrorPrintf("(ContextWGL::CreatePBuffer) wglCreatePbufferARB() failed");
Error::SetStringView(error, "(ContextWGL::CreatePBuffer) wglCreatePbufferARB() failed");
return false;
}
@ -379,7 +372,7 @@ bool ContextWGL::CreatePBuffer()
m_dc = wglGetPbufferDCARB(pbuffer);
if (!m_dc)
{
Log_ErrorPrintf("(ContextWGL::CreatePbuffer) wglGetPbufferDCARB() failed");
Error::SetStringView(error, "(ContextWGL::CreatePbuffer) wglGetPbufferDCARB() failed");
return false;
}
@ -394,12 +387,12 @@ bool ContextWGL::CreatePBuffer()
return true;
}
bool ContextWGL::CreateAnyContext(HGLRC share_context, bool make_current)
bool ContextWGL::CreateAnyContext(HGLRC share_context, bool make_current, Error* error)
{
m_rc = wglCreateContext(m_dc);
if (!m_rc)
{
Log_ErrorPrintf("wglCreateContext() failed: 0x%08X", GetLastError());
Error::SetWin32(error, "wglCreateContext() failed: ", GetLastError());
return false;
}
@ -407,33 +400,33 @@ bool ContextWGL::CreateAnyContext(HGLRC share_context, bool make_current)
{
if (!wglMakeCurrent(m_dc, m_rc))
{
Log_ErrorPrintf("wglMakeCurrent() failed: 0x%08X", GetLastError());
Error::SetWin32(error, "wglMakeCurrent() failed: ", GetLastError());
return false;
}
// re-init glad-wgl
if (!gladLoadWGLLoader([](const char* name) -> void* { return wglGetProcAddress(name); }, m_dc))
if (!gladLoadWGL(m_dc, [](const char* name) { return (GLADapiproc)wglGetProcAddress(name); }))
{
Log_ErrorPrint("Loading GLAD WGL functions failed");
Error::SetStringView(error, "Loading GLAD WGL functions failed");
return false;
}
}
if (share_context && !wglShareLists(share_context, m_rc))
{
Log_ErrorPrintf("wglShareLists() failed: 0x%08X", GetLastError());
Error::SetWin32(error, "wglShareLists() failed: ", GetLastError());
return false;
}
return true;
}
bool ContextWGL::CreateVersionContext(const Version& version, HGLRC share_context, bool make_current)
bool ContextWGL::CreateVersionContext(const Version& version, HGLRC share_context, bool make_current, Error* error)
{
// we need create context attribs
if (!GLAD_WGL_ARB_create_context)
{
Log_ErrorPrint("Missing GLAD_WGL_ARB_create_context.");
Error::SetStringView(error, "Missing GLAD_WGL_ARB_create_context.");
return false;
}
@ -463,7 +456,7 @@ bool ContextWGL::CreateVersionContext(const Version& version, HGLRC share_contex
if ((version.major_version >= 2 && !GLAD_WGL_EXT_create_context_es2_profile) ||
(version.major_version < 2 && !GLAD_WGL_EXT_create_context_es_profile))
{
Log_ErrorPrintf("WGL_EXT_create_context_es_profile not supported");
Error::SetStringView(error, "WGL_EXT_create_context_es_profile not supported");
return false;
}
@ -481,7 +474,7 @@ bool ContextWGL::CreateVersionContext(const Version& version, HGLRC share_contex
}
else
{
Log_ErrorPrint("Unknown profile");
Error::SetStringView(error, "Unknown profile");
return false;
}
@ -493,7 +486,7 @@ bool ContextWGL::CreateVersionContext(const Version& version, HGLRC share_contex
{
if (!wglMakeCurrent(m_dc, make_current ? new_rc : nullptr))
{
Log_ErrorPrintf("wglMakeCurrent() failed: 0x%08X", GetLastError());
Error::SetWin32(error, "wglMakeCurrent() failed: ", GetLastError());
wglDeleteContext(new_rc);
return false;
}

View File

@ -1,4 +1,4 @@
// SPDX-FileCopyrightText: 2019-2023 Connor McLaughlin <stenzek@gmail.com>
// SPDX-FileCopyrightText: 2019-2024 Connor McLaughlin <stenzek@gmail.com>
// SPDX-License-Identifier: (GPL-3.0 OR CC-BY-NC-ND-4.0)
#pragma once
@ -8,7 +8,7 @@
#include "common/windows_headers.h"
#include "glad_wgl.h"
#include "glad/wgl.h"
#include <optional>
@ -30,19 +30,19 @@ public:
bool MakeCurrent() override;
bool DoneCurrent() override;
bool SetSwapInterval(s32 interval) override;
std::unique_ptr<Context> CreateSharedContext(const WindowInfo& wi) override;
std::unique_ptr<Context> CreateSharedContext(const WindowInfo& wi, Error* error) override;
private:
ALWAYS_INLINE HWND GetHWND() const { return static_cast<HWND>(m_wi.window_handle); }
HDC GetDCAndSetPixelFormat(HWND hwnd);
HDC GetDCAndSetPixelFormat(HWND hwnd, Error* error);
bool Initialize(std::span<const Version> versions_to_try, Error* error);
bool InitializeDC();
bool InitializeDC(Error* error);
void ReleaseDC();
bool CreatePBuffer();
bool CreateAnyContext(HGLRC share_context, bool make_current);
bool CreateVersionContext(const Version& version, HGLRC share_context, bool make_current);
bool CreatePBuffer(Error* error);
bool CreateAnyContext(HGLRC share_context, bool make_current, Error* error);
bool CreateVersionContext(const Version& version, HGLRC share_context, bool make_current, Error* error);
HDC m_dc = {};
HGLRC m_rc = {};

View File

@ -287,8 +287,8 @@ void OpenGLDevice::SetVSync(bool enabled)
SetSwapInterval();
}
static void APIENTRY GLDebugCallback(GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length,
const GLchar* message, const void* userParam)
static void GLAD_API_PTR GLDebugCallback(GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length,
const GLchar* message, const void* userParam)
{
switch (severity)
{

View File

@ -1,4 +1,4 @@
// SPDX-FileCopyrightText: 2019-2022 Connor McLaughlin <stenzek@gmail.com>
// SPDX-FileCopyrightText: 2019-2024 Connor McLaughlin <stenzek@gmail.com>
// SPDX-License-Identifier: (GPL-3.0 OR CC-BY-NC-ND-4.0)
#pragma once
@ -8,4 +8,4 @@
#include "common/windows_headers.h"
#endif
#include "glad.h"
#include "glad/gl.h"