GPU: More work on OpenGL renderer
This commit is contained in:
@ -1,43 +1,36 @@
|
||||
#pragma once
|
||||
#include "common/display_renderer.h"
|
||||
#include "pse-sdl/sdl_audio_mixer.h"
|
||||
#include "YBaseLib/String.h"
|
||||
#include "YBaseLib/Timer.h"
|
||||
#include "common/gl_program.h"
|
||||
#include "common/gl_texture.h"
|
||||
#include "pse/host_interface.h"
|
||||
#include <SDL.h>
|
||||
#include <array>
|
||||
#include <deque>
|
||||
#include <mutex>
|
||||
|
||||
struct SDL_Window;
|
||||
union SDL_Event;
|
||||
|
||||
class System;
|
||||
|
||||
class SDLInterface
|
||||
class SDLInterface : public HostInterface
|
||||
{
|
||||
public:
|
||||
using MixerType = SDLAudioMixer;
|
||||
// using MixerType = Audio::NullMixer;
|
||||
|
||||
SDLInterface(SDL_Window* window, std::unique_ptr<DisplayRenderer> display_renderer,
|
||||
std::unique_ptr<MixerType> mixer);
|
||||
SDLInterface();
|
||||
~SDLInterface();
|
||||
|
||||
static std::unique_ptr<SDLInterface>
|
||||
Create(DisplayRenderer::BackendType display_renderer_backend = DisplayRenderer::GetDefaultBackendType());
|
||||
static std::unique_ptr<SDLInterface> Create();
|
||||
|
||||
static TinyString GetSaveStateFilename(u32 index);
|
||||
void SetDisplayTexture(GL::Texture* texture, u32 offset_x, u32 offset_y, u32 width, u32 height) override;
|
||||
|
||||
bool InitializeSystem(const char* filename, s32 save_state_index = -1);
|
||||
void ReportMessage(const char* message) override;
|
||||
|
||||
DisplayRenderer* GetDisplayRenderer() const { return m_display_renderer.get(); }
|
||||
Audio::Mixer* GetAudioMixer() const { return m_mixer.get(); }
|
||||
// Adds OSD messages, duration is in seconds.
|
||||
void AddOSDMessage(const char* message, float duration = 2.0f) override;
|
||||
|
||||
void ReportMessage(const char* message);
|
||||
bool InitializeSystem(const char* filename, s32 save_state_index /* = -1 */);
|
||||
|
||||
void Run();
|
||||
|
||||
// Adds OSD messages, duration is in seconds.
|
||||
void AddOSDMessage(const char* message, float duration = 2.0f);
|
||||
|
||||
protected:
|
||||
private:
|
||||
struct OSDMessage
|
||||
{
|
||||
String text;
|
||||
@ -45,6 +38,11 @@ protected:
|
||||
float duration;
|
||||
};
|
||||
|
||||
bool CreateSDLWindow();
|
||||
bool CreateGLContext();
|
||||
bool CreateImGuiContext();
|
||||
bool CreateGLResources();
|
||||
|
||||
// We only pass mouse input through if it's grabbed
|
||||
bool IsWindowFullscreen() const;
|
||||
void RenderImGui();
|
||||
@ -54,14 +52,24 @@ protected:
|
||||
bool HandleSDLEvent(const SDL_Event* event);
|
||||
bool PassEventToImGui(const SDL_Event* event);
|
||||
void Render();
|
||||
void RenderDisplay();
|
||||
void RenderMainMenuBar();
|
||||
void RenderOSDMessages();
|
||||
|
||||
SDL_Window* m_window;
|
||||
SDL_Window* m_window = nullptr;
|
||||
SDL_GLContext m_gl_context = nullptr;
|
||||
int m_window_width = 0;
|
||||
int m_window_height = 0;
|
||||
|
||||
std::unique_ptr<DisplayRenderer> m_display_renderer;
|
||||
std::unique_ptr<MixerType> m_mixer;
|
||||
std::unique_ptr<System> m_system;
|
||||
GL::Program m_display_program;
|
||||
GLuint m_display_vao = 0;
|
||||
GL::Texture* m_display_texture = nullptr;
|
||||
u32 m_display_texture_offset_x = 0;
|
||||
u32 m_display_texture_offset_y = 0;
|
||||
u32 m_display_texture_width = 0;
|
||||
u32 m_display_texture_height = 0;
|
||||
bool m_display_texture_changed = false;
|
||||
|
||||
std::deque<OSDMessage> m_osd_messages;
|
||||
std::mutex m_osd_messages_lock;
|
||||
|
||||
Reference in New Issue
Block a user