2019-12-31 06:17:17 +00:00
|
|
|
#pragma once
|
2020-02-15 08:23:21 +00:00
|
|
|
|
|
|
|
// 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>
|
|
|
|
|
2020-02-15 08:23:21 +00:00
|
|
|
// 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
|
|
|
|
|
2020-05-07 12:49:04 +00:00
|
|
|
#include "common/gl/context.h"
|
2019-12-31 06:17:17 +00:00
|
|
|
#include "common/gl/program.h"
|
|
|
|
#include "common/gl/texture.h"
|
2020-05-07 12:49:04 +00:00
|
|
|
#include "common/window_info.h"
|
2019-12-31 06:17:17 +00:00
|
|
|
#include "core/host_display.h"
|
2020-03-12 03:53:51 +00:00
|
|
|
#include "qtdisplaywidget.h"
|
2020-04-22 11:13:51 +00:00
|
|
|
#include "qthostdisplay.h"
|
2019-12-31 06:17:17 +00:00
|
|
|
#include <memory>
|
|
|
|
|
2020-01-02 06:13:03 +00:00
|
|
|
class QtHostInterface;
|
|
|
|
|
2020-04-22 11:13:51 +00:00
|
|
|
class OpenGLHostDisplay final : public QtHostDisplay
|
2019-12-31 06:17:17 +00:00
|
|
|
{
|
|
|
|
public:
|
2020-04-22 11:13:51 +00:00
|
|
|
OpenGLHostDisplay(QtHostInterface* host_interface);
|
|
|
|
~OpenGLHostDisplay();
|
2019-12-31 06:17:17 +00:00
|
|
|
|
2020-04-22 11:13:51 +00:00
|
|
|
QtDisplayWidget* createWidget(QWidget* parent) override;
|
2020-01-02 07:45:25 +00:00
|
|
|
|
2020-02-15 15:14:28 +00:00
|
|
|
bool hasDeviceContext() const override;
|
2020-04-22 11:13:51 +00:00
|
|
|
bool createDeviceContext(bool debug_device) override;
|
2020-01-19 04:53:49 +00:00
|
|
|
bool initializeDeviceContext(bool debug_device) override;
|
2020-05-07 12:49:04 +00:00
|
|
|
bool activateDeviceContext() override;
|
|
|
|
void deactivateDeviceContext() override;
|
2020-01-02 07:45:25 +00:00
|
|
|
void destroyDeviceContext() override;
|
2020-04-22 11:13:51 +00:00
|
|
|
bool createSurface() override;
|
|
|
|
void destroySurface();
|
2019-12-31 06:17:17 +00:00
|
|
|
|
|
|
|
RenderAPI GetRenderAPI() const override;
|
|
|
|
void* GetRenderDevice() const override;
|
|
|
|
void* GetRenderContext() const override;
|
2020-05-07 12:49:04 +00:00
|
|
|
void WindowResized(s32 new_window_width, s32 new_window_height) override;
|
2019-12-31 06:17:17 +00:00
|
|
|
|
2020-03-12 03:53:51 +00:00
|
|
|
std::unique_ptr<HostDisplayTexture> CreateTexture(u32 width, u32 height, const void* initial_data,
|
|
|
|
u32 initial_data_stride, bool dynamic) override;
|
|
|
|
void UpdateTexture(HostDisplayTexture* texture, u32 x, u32 y, u32 width, u32 height, const void* texture_data,
|
|
|
|
u32 texture_data_stride) override;
|
2020-03-15 14:03:49 +00:00
|
|
|
bool DownloadTexture(const void* texture_handle, u32 x, u32 y, u32 width, u32 height, void* out_data,
|
|
|
|
u32 out_data_stride) override;
|
2019-12-31 06:17:17 +00:00
|
|
|
|
|
|
|
void SetVSync(bool enabled) override;
|
|
|
|
|
2020-01-02 07:45:25 +00:00
|
|
|
void Render() override;
|
2020-01-02 06:13:03 +00:00
|
|
|
|
2019-12-31 06:17:17 +00:00
|
|
|
private:
|
|
|
|
const char* GetGLSLVersionString() const;
|
|
|
|
std::string GetGLSLVersionHeader() const;
|
|
|
|
|
2020-05-07 12:49:04 +00:00
|
|
|
WindowInfo getWindowInfo() const;
|
|
|
|
|
2020-01-02 07:45:25 +00:00
|
|
|
bool createImGuiContext() override;
|
|
|
|
void destroyImGuiContext() override;
|
|
|
|
bool createDeviceResources() override;
|
|
|
|
void destroyDeviceResources() override;
|
2019-12-31 06:17:17 +00:00
|
|
|
|
2020-01-02 07:45:25 +00:00
|
|
|
void renderDisplay();
|
2020-01-02 06:13:03 +00:00
|
|
|
|
2020-05-07 12:49:04 +00:00
|
|
|
std::unique_ptr<GL::Context> 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;
|
|
|
|
};
|