diff options
author | RSDuck <RSDuck@users.noreply.github.com> | 2022-10-17 22:55:11 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-10-17 22:55:11 +0200 |
commit | ac3118cbc54715da55856958b42817fbd1eed666 (patch) | |
tree | 717e66ec7df79171821f46e02b47d1357256ace2 /src/frontend/duckstation/gl/context_glx.h | |
parent | 31ba585d392c9745917a141c72b3349d029586f0 (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_glx.h')
-rw-r--r-- | src/frontend/duckstation/gl/context_glx.h | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/src/frontend/duckstation/gl/context_glx.h b/src/frontend/duckstation/gl/context_glx.h new file mode 100644 index 0000000..c8416e5 --- /dev/null +++ b/src/frontend/duckstation/gl/context_glx.h @@ -0,0 +1,44 @@ +#pragma once +#include "context.h" +#include "../../glad/glad_glx.h" +#include "x11_window.h" + +namespace GL { + +class ContextGLX final : public Context +{ +public: + ContextGLX(const WindowInfo& wi); + ~ContextGLX() 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 Display* GetDisplay() const { return static_cast<Display*>(m_wi.display_connection); } + ALWAYS_INLINE GLXDrawable GetDrawable() const { return static_cast<GLXDrawable>(m_window.GetWindow()); } + + bool Initialize(const Version* versions_to_try, size_t num_versions_to_try); + bool CreateWindow(int screen); + bool CreateAnyContext(GLXContext share_context, bool make_current); + bool CreateVersionContext(const Version& version, GLXContext share_context, bool make_current); + + GLXContext m_context = nullptr; + GLXFBConfig m_fb_config = {}; + XVisualInfo* m_vi = nullptr; + X11Window m_window; + + // GLAD releases its reference to libGL.so, so we need to maintain our own. + void* m_libGL_handle = nullptr; +}; + +} // namespace GL |