aboutsummaryrefslogtreecommitdiff
path: root/src/frontend/duckstation/gl/context_agl.h
diff options
context:
space:
mode:
authorRSDuck <RSDuck@users.noreply.github.com>2022-10-17 22:55:11 +0200
committerGitHub <noreply@github.com>2022-10-17 22:55:11 +0200
commitac3118cbc54715da55856958b42817fbd1eed666 (patch)
tree717e66ec7df79171821f46e02b47d1357256ace2 /src/frontend/duckstation/gl/context_agl.h
parent31ba585d392c9745917a141c72b3349d029586f0 (diff)
No more context mess (#1531)
* WIP: use Duckstation's context code to directly render into QT Widget from separate thread without two OpenGL contexts currently only works on Windows * reenable gay OSD * add back vsync * make it atleast a little more thread safe * linux support * don't segfault on closing * reorganise and cleanup build system it's still not good, but better than before * macos? * try to get it working on Ubuntu CI also update instructions * let's try this * ok how about this * try creating an OGL 4.3 context first (https://i.kym-cdn.com/photos/images/original/001/264/842/220.png) * fix Ubuntu * hm * try again for Windows * let's try this * make the OpenGL renderer work again that was stupid * do OGL surface resizing from the mainthread * Fix small mistake in GL context creation on macOS causing version 3.2 to be considered invalid * C stupidness * cleanup * don't let the emuthread deinit OGL if there's no OGL * reset lastScreenWidth/Height when deiniting OpenGL * disable stencil test while drawing framebuffers * macOS: Link Cocoa framework explicitly when not building with Qt6 Seems to be needed for the classes used by DuckStation's GL context code. * Set ScreenPanelGL's minimum size immediately Fixes GL context creation for OpenGL display on macOS using the wrong size as the underlying window was not resized to the correct size by Qt yet. * don't emit window updates when OGL display is used * stuff Arisotura said Co-authored-by: Nadia Holmquist Pedersen <nadia@nhp.sh>
Diffstat (limited to 'src/frontend/duckstation/gl/context_agl.h')
-rw-r--r--src/frontend/duckstation/gl/context_agl.h49
1 files changed, 49 insertions, 0 deletions
diff --git a/src/frontend/duckstation/gl/context_agl.h b/src/frontend/duckstation/gl/context_agl.h
new file mode 100644
index 0000000..459bf2f
--- /dev/null
+++ b/src/frontend/duckstation/gl/context_agl.h
@@ -0,0 +1,49 @@
+#pragma once
+#include "context.h"
+#include "loader.h"
+
+#if defined(__APPLE__) && defined(__OBJC__)
+#import <AppKit/AppKit.h>
+#else
+struct NSOpenGLContext;
+struct NSOpenGLPixelFormat;
+struct NSView;
+#define __bridge
+#endif
+
+namespace GL {
+
+class ContextAGL final : public Context
+{
+public:
+ ContextAGL(const WindowInfo& wi);
+ ~ContextAGL() override;
+
+ static std::unique_ptr<Context> Create(const WindowInfo& wi, const Version* versions_to_try,
+ size_t num_versions_to_try);
+
+ void* GetProcAddress(const char* name) override;
+ bool ChangeSurface(const WindowInfo& new_wi) override;
+ void ResizeSurface(u32 new_surface_width = 0, u32 new_surface_height = 0) override;
+ bool SwapBuffers() override;
+ bool MakeCurrent() override;
+ bool DoneCurrent() override;
+ bool SetSwapInterval(s32 interval) override;
+ std::unique_ptr<Context> CreateSharedContext(const WindowInfo& wi) override;
+
+private:
+ ALWAYS_INLINE NSView* GetView() const { return static_cast<NSView*>((__bridge NSView*)m_wi.window_handle); }
+
+ bool Initialize(const Version* versions_to_try, size_t num_versions_to_try);
+ bool CreateContext(NSOpenGLContext* share_context, int profile, bool make_current);
+ void BindContextToView();
+
+ // returns true if dimensions have changed
+ bool UpdateDimensions();
+
+ NSOpenGLContext* m_context = nullptr;
+ NSOpenGLPixelFormat* m_pixel_format = nullptr;
+ void* m_opengl_module_handle = nullptr;
+};
+
+} // namespace GL