Duckstation/src/duckstation-qt/opengldisplaywindow.h

71 lines
2.1 KiB
C
Raw Normal View History

2019-12-31 06:17:17 +00:00
#pragma once
// GLAD has to come first so that Qt doesn't pull in the system GL headers, which are incompatible with glad.
2019-12-31 06:17:17 +00:00
#include <glad.h>
// Hack to prevent Apple's glext.h headers from getting included via qopengl.h, since we still want to use glad.
#ifdef __APPLE__
#define __glext_h_
#endif
2019-12-31 06:17:17 +00:00
#include "common/gl/program.h"
#include "common/gl/texture.h"
#include "core/host_display.h"
#include "qtdisplaywindow.h"
#include <QtGui/QOpenGLContext>
2019-12-31 06:17:17 +00:00
#include <memory>
class QtHostInterface;
class OpenGLDisplayWindow final : public QtDisplayWindow, public HostDisplay
2019-12-31 06:17:17 +00:00
{
Q_OBJECT
public:
OpenGLDisplayWindow(QtHostInterface* host_interface, QWindow* parent);
2019-12-31 06:17:17 +00:00
~OpenGLDisplayWindow();
HostDisplay* getHostDisplayInterface() override;
bool createDeviceContext(QThread* worker_thread, bool debug_device) override;
bool initializeDeviceContext(bool debug_device) override;
void destroyDeviceContext() override;
2019-12-31 06:17:17 +00:00
RenderAPI GetRenderAPI() const override;
void* GetRenderDevice() const override;
void* GetRenderContext() const override;
void* GetRenderWindow() const override;
void ChangeRenderWindow(void* new_window) override;
std::unique_ptr<HostDisplayTexture> CreateTexture(u32 width, u32 height, const void* data, u32 data_stride,
bool dynamic) override;
void UpdateTexture(HostDisplayTexture* texture, u32 x, u32 y, u32 width, u32 height, const void* data,
u32 data_stride) override;
void SetVSync(bool enabled) override;
std::tuple<u32, u32> GetWindowSize() const override;
void WindowResized() override;
void Render() override;
2019-12-31 06:17:17 +00:00
private:
const char* GetGLSLVersionString() const;
std::string GetGLSLVersionHeader() const;
bool createImGuiContext() override;
void destroyImGuiContext() override;
bool createDeviceResources() override;
void destroyDeviceResources() override;
2019-12-31 06:17:17 +00:00
void renderDisplay();
std::unique_ptr<QOpenGLContext> m_gl_context = nullptr;
2019-12-31 06:17:17 +00:00
GL::Program m_display_program;
GLuint m_display_vao = 0;
GLuint m_display_nearest_sampler = 0;
GLuint m_display_linear_sampler = 0;
};