2019-11-03 14:39:48 +00:00
|
|
|
#pragma once
|
|
|
|
#include "common/gl/program.h"
|
|
|
|
#include "common/gl/texture.h"
|
|
|
|
#include "core/host_display.h"
|
|
|
|
#include <SDL.h>
|
2019-11-05 15:32:56 +00:00
|
|
|
#include <string>
|
2019-11-03 14:39:48 +00:00
|
|
|
#include <memory>
|
|
|
|
|
|
|
|
class OpenGLHostDisplay final : public HostDisplay
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
OpenGLHostDisplay(SDL_Window* window);
|
|
|
|
~OpenGLHostDisplay();
|
|
|
|
|
|
|
|
static std::unique_ptr<HostDisplay> Create(SDL_Window* window);
|
|
|
|
|
|
|
|
RenderAPI GetRenderAPI() const override;
|
2019-11-28 13:29:03 +00:00
|
|
|
void* GetRenderDevice() const override;
|
|
|
|
void* GetRenderContext() const override;
|
|
|
|
void* GetRenderWindow() const override;
|
|
|
|
|
|
|
|
void ChangeRenderWindow(void* new_window) override;
|
2019-11-03 14:39:48 +00:00
|
|
|
|
|
|
|
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;
|
|
|
|
|
2019-11-03 15:45:03 +00:00
|
|
|
void SetDisplayTexture(void* texture, s32 offset_x, s32 offset_y, s32 width, s32 height, u32 texture_width,
|
2019-11-03 14:39:48 +00:00
|
|
|
u32 texture_height, float aspect_ratio) override;
|
|
|
|
void SetDisplayLinearFiltering(bool enabled) override;
|
2019-11-15 04:57:27 +00:00
|
|
|
void SetDisplayTopMargin(int height) override;
|
2019-11-03 14:39:48 +00:00
|
|
|
|
|
|
|
void SetVSync(bool enabled) override;
|
|
|
|
|
|
|
|
std::tuple<u32, u32> GetWindowSize() const override;
|
|
|
|
void WindowResized() override;
|
|
|
|
|
|
|
|
private:
|
2019-11-05 15:32:56 +00:00
|
|
|
const char* GetGLSLVersionString() const;
|
|
|
|
std::string GetGLSLVersionHeader() const;
|
|
|
|
|
2019-11-03 14:39:48 +00:00
|
|
|
bool CreateGLContext();
|
|
|
|
bool CreateImGuiContext();
|
|
|
|
bool CreateGLResources();
|
|
|
|
|
|
|
|
void Render();
|
|
|
|
void RenderDisplay();
|
|
|
|
|
|
|
|
SDL_Window* m_window = nullptr;
|
|
|
|
SDL_GLContext m_gl_context = nullptr;
|
|
|
|
int m_window_width = 0;
|
|
|
|
int m_window_height = 0;
|
|
|
|
|
|
|
|
std::unique_ptr<GL::Texture> m_app_icon_texture = nullptr;
|
|
|
|
|
|
|
|
GL::Program m_display_program;
|
|
|
|
GLuint m_display_vao = 0;
|
|
|
|
GLuint m_display_texture_id = 0;
|
2019-11-03 15:45:03 +00:00
|
|
|
s32 m_display_offset_x = 0;
|
|
|
|
s32 m_display_offset_y = 0;
|
|
|
|
s32 m_display_width = 0;
|
|
|
|
s32 m_display_height = 0;
|
2019-11-03 14:39:48 +00:00
|
|
|
u32 m_display_texture_width = 0;
|
|
|
|
u32 m_display_texture_height = 0;
|
2019-11-15 04:57:27 +00:00
|
|
|
int m_display_top_margin = 0;
|
2019-11-03 14:39:48 +00:00
|
|
|
float m_display_aspect_ratio = 1.0f;
|
|
|
|
GLuint m_display_nearest_sampler = 0;
|
|
|
|
GLuint m_display_linear_sampler = 0;
|
|
|
|
|
2019-11-05 15:32:56 +00:00
|
|
|
bool m_is_gles = false;
|
2019-11-03 14:39:48 +00:00
|
|
|
bool m_display_texture_changed = false;
|
|
|
|
bool m_display_linear_filtering = false;
|
|
|
|
};
|