1
0
mirror of https://github.com/TomHarte/CLK.git synced 2024-07-06 01:28:57 +00:00

Advances to having a selected machine actually run.

Albeit, invisibly.
This commit is contained in:
Thomas Harte 2020-06-03 23:39:16 -04:00
parent e2ceb77501
commit fdc234ed3b
7 changed files with 77 additions and 11 deletions

View File

@ -123,6 +123,7 @@ SOURCES += \
\
main.cpp \
mainwindow.cpp \
scantargetwidget.cpp \
timer.cpp
HEADERS += \
@ -247,6 +248,7 @@ HEADERS += \
../../Storage/Tape/Parsers/*.hpp \
\
mainwindow.h \
scantargetwidget.h \
timer.h
FORMS += \

View File

@ -4,6 +4,16 @@
int main(int argc, char *argv[])
{
// "Calling QSurfaceFormat::setDefaultFormat() before constructing the
// QApplication instance is mandatory on some platforms ... when an
// OpenGL core profile context is requested."
QSurfaceFormat format;
format.setVersion(3, 2);
format.setProfile(QSurfaceFormat::CoreProfile);
format.setDepthBufferSize(0);
format.setStencilBufferSize(0);
QSurfaceFormat::setDefaultFormat(format);
QApplication a(argc, argv);
MainWindow w;
w.show();

View File

@ -137,19 +137,19 @@ void MainWindow::launchMachine() {
return results;
};
Machine::Error error;
std::unique_ptr<Machine::DynamicMachine> machine(Machine::MachineForTargets(targets, rom_fetcher, error));
machine.reset(Machine::MachineForTargets(targets, rom_fetcher, error));
switch(error) {
default: {
ui->missingROMsBox->setVisible(false);
uiPhase = UIPhase::RunningMachine;
// TODO: Install the OpenGL scan target.
// This is subject to having created an OpenGL context.
// const auto scan_producer = machine->scan_producer();
// if(scan_producer) {
// scan_producer->set_scan_target(&scanTarget);
// }
// Supply the scan target.
// TODO: in the future, hypothetically, deal with non-scan producers.
const auto scan_producer = machine->scan_producer();
if(scan_producer) {
scan_producer->set_scan_target(ui->openGLWidget->getScanTarget());
}
// If this is a timed machine, start up the timer.
const auto timedMachine = machine->timed_machine();

View File

@ -8,7 +8,6 @@
#include "../../Analyser/Static/StaticAnalyser.hpp"
#include "../../Machines/Utility/MachineForTarget.hpp"
#include "../../Outputs/OpenGL/ScanTarget.hpp"
QT_BEGIN_NAMESPACE
namespace Ui { class MainWindow; }
@ -43,8 +42,8 @@ class MainWindow : public QMainWindow {
void dragEnterEvent(QDragEnterEvent* event) override;
void dropEvent(QDropEvent* event) override;
// Output.
Outputs::Display::OpenGL::ScanTarget scanTarget;
// Ongoing state.
std::unique_ptr<Machine::DynamicMachine> machine;
private slots:
void open();

View File

@ -22,7 +22,7 @@
<property name="windowTitle">
<string>MainWindow</string>
</property>
<widget class="QOpenGLWidget" name="openGLWidget">
<widget class="ScanTargetWidget" name="openGLWidget">
<widget class="QPlainTextEdit" name="missingROMsBox">
<property name="geometry">
<rect>
@ -60,6 +60,13 @@ Please drag and drop the following over this window:
</property>
</action>
</widget>
<customwidgets>
<customwidget>
<class>ScanTargetWidget</class>
<extends>QOpenGLWidget</extends>
<header>scantargetwidget.h</header>
</customwidget>
</customwidgets>
<resources/>
<connections/>
</ui>

View File

@ -0,0 +1,21 @@
#include "scantargetwidget.h"
ScanTargetWidget::ScanTargetWidget(QWidget *parent) : QOpenGLWidget(parent) {}
ScanTargetWidget::~ScanTargetWidget() {}
void ScanTargetWidget::initializeGL() {
scanTarget = std::make_unique<Outputs::Display::OpenGL::ScanTarget>(defaultFramebufferObject());
glClearColor(0.5, 0.5, 1.0, 1.0);
}
void ScanTargetWidget::paintGL() {
glClear(GL_COLOR_BUFFER_BIT);
}
void ScanTargetWidget::resizeGL(int w, int h) {
glViewport(0,0,w,h);
}
Outputs::Display::OpenGL::ScanTarget *ScanTargetWidget::getScanTarget() {
return scanTarget.get();
}

View File

@ -0,0 +1,27 @@
#ifndef SCANTARGETWIDGET_H
#define SCANTARGETWIDGET_H
#include <QOpenGLWidget>
#include "../../Outputs/OpenGL/ScanTarget.hpp"
class ScanTargetWidget : public QOpenGLWidget
{
public:
ScanTargetWidget(QWidget *parent = nullptr);
~ScanTargetWidget();
Outputs::Display::OpenGL::ScanTarget *getScanTarget();
protected:
void initializeGL() override;
void resizeGL(int w, int h) override;
void paintGL() override;
private:
// This should be created only once there's an OpenGL context. So it
// can't be done at creation time.4
std::unique_ptr<Outputs::Display::OpenGL::ScanTarget> scanTarget;
};
#endif // SCANTARGETWIDGET_H