mirror of https://github.com/stenzek/duckstation
Qt: Move some functionalty from OpenGLDisplayWindow into QtDisplayWindow
parent
ac6a7bad3f
commit
9436ffc806
@ -0,0 +1,65 @@
|
||||
#include "qtdisplaywindow.h"
|
||||
#include "imgui.h"
|
||||
#include "qthostinterface.h"
|
||||
#include <QtGui/QKeyEvent>
|
||||
|
||||
QtDisplayWindow::QtDisplayWindow(QtHostInterface* host_interface, QWindow* parent)
|
||||
: QWindow(parent), m_host_interface(host_interface)
|
||||
{
|
||||
}
|
||||
|
||||
QtDisplayWindow::~QtDisplayWindow() = default;
|
||||
|
||||
HostDisplay* QtDisplayWindow::getHostDisplayInterface()
|
||||
{
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
bool QtDisplayWindow::createDeviceContext(QThread* worker_thread)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
bool QtDisplayWindow::initializeDeviceContext()
|
||||
{
|
||||
if (!createImGuiContext() || !createDeviceResources())
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void QtDisplayWindow::destroyDeviceContext()
|
||||
{
|
||||
destroyImGuiContext();
|
||||
destroyDeviceResources();
|
||||
}
|
||||
|
||||
bool QtDisplayWindow::createImGuiContext()
|
||||
{
|
||||
ImGui::CreateContext();
|
||||
return true;
|
||||
}
|
||||
|
||||
void QtDisplayWindow::destroyImGuiContext()
|
||||
{
|
||||
ImGui::DestroyContext();
|
||||
}
|
||||
|
||||
bool QtDisplayWindow::createDeviceResources()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
void QtDisplayWindow::destroyDeviceResources() {}
|
||||
|
||||
void QtDisplayWindow::Render() {}
|
||||
|
||||
void QtDisplayWindow::keyPressEvent(QKeyEvent* event)
|
||||
{
|
||||
m_host_interface->handleKeyEvent(event->key(), true);
|
||||
}
|
||||
|
||||
void QtDisplayWindow::keyReleaseEvent(QKeyEvent* event)
|
||||
{
|
||||
m_host_interface->handleKeyEvent(event->key(), false);
|
||||
}
|
@ -0,0 +1,36 @@
|
||||
#pragma once
|
||||
#include <QtGui/QWindow>
|
||||
|
||||
class QKeyEvent;
|
||||
|
||||
class HostDisplay;
|
||||
|
||||
class QtHostInterface;
|
||||
|
||||
class QtDisplayWindow : public QWindow
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
QtDisplayWindow(QtHostInterface* host_interface, QWindow* parent);
|
||||
virtual ~QtDisplayWindow();
|
||||
|
||||
virtual HostDisplay* getHostDisplayInterface();
|
||||
|
||||
virtual bool createDeviceContext(QThread* worker_thread);
|
||||
virtual bool initializeDeviceContext();
|
||||
virtual void destroyDeviceContext();
|
||||
|
||||
virtual void Render();
|
||||
|
||||
protected:
|
||||
virtual bool createImGuiContext();
|
||||
virtual void destroyImGuiContext();
|
||||
virtual bool createDeviceResources();
|
||||
virtual void destroyDeviceResources();
|
||||
|
||||
void keyPressEvent(QKeyEvent* event) override;
|
||||
void keyReleaseEvent(QKeyEvent* event) override;
|
||||
|
||||
QtHostInterface* m_host_interface;
|
||||
};
|
Loading…
Reference in New Issue