2021-11-10 19:35:30 +00:00
|
|
|
/*
|
|
|
|
Copyright 2021 flyinghead
|
|
|
|
|
|
|
|
This file is part of Flycast.
|
|
|
|
|
|
|
|
Flycast is free software: you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation, either version 2 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
Flycast is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with Flycast. If not, see <https://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
#include "rend/imgui_driver.h"
|
|
|
|
#include "emulator.h"
|
2022-06-15 19:22:12 +00:00
|
|
|
#include <unordered_map>
|
2021-11-10 19:35:30 +00:00
|
|
|
|
|
|
|
class OpenGLDriver final : public ImGuiDriver
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
OpenGLDriver();
|
|
|
|
~OpenGLDriver() override;
|
|
|
|
|
|
|
|
void displayVmus() override;
|
|
|
|
void displayCrosshairs() override;
|
|
|
|
|
|
|
|
void newFrame() override;
|
2022-12-16 19:34:30 +00:00
|
|
|
void renderDrawData(ImDrawData* drawData, bool gui_open) override;
|
2021-11-10 19:35:30 +00:00
|
|
|
void present() override;
|
|
|
|
|
2022-02-14 17:38:58 +00:00
|
|
|
void setFrameRendered() override {
|
2021-12-26 15:02:53 +00:00
|
|
|
frameRendered = true;
|
|
|
|
}
|
|
|
|
|
2022-06-15 19:22:12 +00:00
|
|
|
ImTextureID getTexture(const std::string& name) override {
|
|
|
|
auto it = textures.find(name);
|
|
|
|
if (it != textures.end())
|
|
|
|
return it->second;
|
|
|
|
else
|
|
|
|
return ImTextureID{};
|
|
|
|
}
|
|
|
|
|
|
|
|
ImTextureID updateTexture(const std::string& name, const u8 *data, int width, int height) override;
|
|
|
|
|
2021-11-10 19:35:30 +00:00
|
|
|
private:
|
|
|
|
void emuEvent(Event event)
|
|
|
|
{
|
|
|
|
switch (event)
|
|
|
|
{
|
2023-02-22 16:46:14 +00:00
|
|
|
case Event::Resume:
|
2021-11-10 19:35:30 +00:00
|
|
|
gameStarted = true;
|
|
|
|
break;
|
2022-10-23 14:32:42 +00:00
|
|
|
case Event::Terminate:
|
2021-11-10 19:35:30 +00:00
|
|
|
gameStarted = false;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
static void emuEventCallback(Event event, void *p) {
|
|
|
|
((OpenGLDriver *)p)->emuEvent(event);
|
|
|
|
}
|
|
|
|
|
|
|
|
ImTextureID vmu_lcd_tex_ids[8];
|
|
|
|
ImTextureID crosshairTexId = ImTextureID();
|
|
|
|
bool gameStarted = false;
|
2021-11-11 10:17:39 +00:00
|
|
|
bool frameRendered = false;
|
2022-06-15 19:22:12 +00:00
|
|
|
std::unordered_map<std::string, ImTextureID> textures;
|
2021-11-10 19:35:30 +00:00
|
|
|
};
|