// SPDX-FileCopyrightText: 2019-2024 Connor McLaughlin // SPDX-License-Identifier: CC-BY-NC-ND-4.0 #pragma once #include "opengl_context.h" #include "opengl_loader.h" #if defined(__APPLE__) && defined(__OBJC__) #import #else struct NSOpenGLContext; struct NSOpenGLPixelFormat; struct NSView; #define __bridge #endif class OpenGLContextAGL final : public OpenGLContext { public: OpenGLContextAGL(); ~OpenGLContextAGL() override; static std::unique_ptr Create(WindowInfo& wi, SurfaceHandle* surface, std::span versions_to_try, Error* error); void* GetProcAddress(const char* name) override; SurfaceHandle CreateSurface(WindowInfo& wi, Error* error = nullptr) override; void DestroySurface(SurfaceHandle handle) override; void ResizeSurface(WindowInfo& wi, SurfaceHandle handle) override; bool SwapBuffers() override; bool IsCurrent() const override; bool MakeCurrent(SurfaceHandle surface, Error* error = nullptr) override; bool DoneCurrent() override; bool SupportsNegativeSwapInterval() const override; bool SetSwapInterval(s32 interval, Error* error = nullptr) override; std::unique_ptr CreateSharedContext(WindowInfo& wi, SurfaceHandle* surface, Error* error) override; private: bool Initialize(WindowInfo& wi, SurfaceHandle* surface, std::span versions_to_try, Error* error); bool CreateContext(NSOpenGLContext* share_context, int profile, Error* error); static void BindContextToView(WindowInfo& wi, NSOpenGLContext* context); static void UpdateSurfaceSize(WindowInfo& wi, NSOpenGLContext* context); NSOpenGLContext* m_context = nullptr; NSOpenGLPixelFormat* m_pixel_format = nullptr; void* m_opengl_module_handle = nullptr; };