Added video output display in a specific window
[clinton/Virtual-Jaguar-Rx.git] / src / debugger / VideoWin.cpp
CommitLineData
cf76e892 1//
96aa54e4 2// VideoWin.cpp: Video output window
cf76e892
JPM
3//
4// by Jean-Paul Mari
5//
6// JPM = Jean-Paul Mari <djipi.mari@gmail.com>
7//
8// WHO WHEN WHAT
9// --- ---------- ------------------------------------------------------------
10// JPM 06/23/2016 Created this file
96aa54e4 11// JPM April/2021 Added video output display in the window
cf76e892
JPM
12
13#include "VideoWin.h"
96aa54e4
JPM
14#include "tom.h"
15#include "settings.h"
cf76e892
JPM
16//#include "mainwin.h"
17
18
19//
96aa54e4
JPM
20VideoOutputWindow::VideoOutputWindow(QWidget * parent/*= 0*/) : QWidget(parent, Qt::Dialog),
21layout(new QVBoxLayout),
22hbox1(new QHBoxLayout)
23//gl(new GLWidget)
24//layout(0),
25//hbox1(0)
26//statusbar(new QStatusBar),
27//text(new QTextBrowser)
cf76e892 28{
96aa54e4 29 setWindowTitle(tr("Output Video"));
cf76e892
JPM
30 //setCentralWidget(videoWidget);
31
32// QFont fixedFont("Lucida Console", 8, QFont::Normal);
33 // QFont fixedFont("", 8, QFont::Normal);
34// fixedFont.setStyleHint(QFont::TypeWriter);
35// text->setFont(fixedFont);
36// setLayout(layout);
96aa54e4
JPM
37#if 0
38 QHBoxLayout * hbox1 = new QHBoxLayout;
39 hbox1->addWidget(gl);
40 layout->addLayout(hbox1);
cf76e892 41
96aa54e4
JPM
42 gl->setFixedSize(VIRTUAL_SCREEN_WIDTH, (vjs.hardwareTypeNTSC ? VIRTUAL_SCREEN_HEIGHT_NTSC : VIRTUAL_SCREEN_HEIGHT_PAL));
43#endif
44 //layout->addWidget(statusbar);
45 //statusbar->setStyleSheet("background-color: lightgreen; font: bold");
46 //layout->addWidget(text);
47 //layout->addWidget(gl);
cf76e892 48
96aa54e4
JPM
49 //QWidget* myWidget = new QWidget;
50 //myWidget->setStyleSheet("QWidget{ background: red; }");
cf76e892 51
96aa54e4 52 //GLWidget *glWidget = new GLWidget;
cf76e892 53 //QHBoxLayout *mainLayout = new QHBoxLayout;
96aa54e4
JPM
54 //layout->addWidget(myWidget);
55 //layout->setContentsMargins(100, 100, 100, 100);
56 //setLayout(layout);
57
58 //hbox1->addWidget(gl);
59 //layout->addLayout(hbox1);
60 //setLayout(layout);
61}
62
63
64//
65void VideoOutputWindow::SetupVideo(GLWidget *Lt)
66{
67 if (isVisible())
68 {
69 //layout = new QVBoxLayout;
70 //hbox1 = new QHBoxLayout;
71 // QHBoxLayout * hbox1 = new QHBoxLayout;
72 //Lt->setFixedSize(VIRTUAL_SCREEN_WIDTH, (vjs.hardwareTypeNTSC ? VIRTUAL_SCREEN_HEIGHT_NTSC : VIRTUAL_SCREEN_HEIGHT_PAL));
73 //QHBoxLayout * hbox1 = new QHBoxLayout;
74 hbox1->addWidget(Lt);
75 //hbox1->replaceWidget(gl, Lt);
76 layout->addLayout(hbox1);
77 setLayout(layout);
78 //layout->addLayout(hbox1);
79 //setLayout(layout);
80 //layout->addLayout(hbox1);
81 //setLayout(layout);
82 //show();
83 //resize(100, 100);
84 //adjustSize();
85 glViewport(0, 0, (VIRTUAL_SCREEN_WIDTH * 2), (vjs.hardwareTypeNTSC ? (VIRTUAL_SCREEN_HEIGHT_NTSC * 2) : (VIRTUAL_SCREEN_HEIGHT_PAL * 2)));
86 //adjustSize();
87 //resize(minimumWidth(), minimumHeight());
88 }
cf76e892
JPM
89}
90
91
92// Refresh / Display the window contents
93void VideoOutputWindow::RefreshContents(GLWidget *Lt)
94{
96aa54e4
JPM
95#if 0
96 if (isVisible())
97 {
98 for (uint32_t i = 0; i < (uint32_t)(Lt->textureWidth * Lt->rasterHeight); i++)
99 {
100 uint32_t pixel = Lt->buffer[i];
101 uint8_t r = (pixel >> 24) & 0xFF, g = (pixel >> 16) & 0xFF, b = (pixel >> 8) & 0xFF;
102 pixel = ((r + g + b) / 3) & 0x00FF;
103 gl->buffer[i] = 0x000000FF | (pixel << 16) | (pixel << 8);
104 }
105
106 gl->updateGL();
107 //adjustSize();
108 }
109#endif
110#if 0
111 if (isVisible())
112 {
113
114 QHBoxLayout * hbox1 = new QHBoxLayout;
115 hbox1->addWidget(Lt);
116 layout->addLayout(hbox1);
117 setLayout(layout);
118
119 //gl->setFixedSize(VIRTUAL_SCREEN_WIDTH, (vjs.hardwareTypeNTSC ? VIRTUAL_SCREEN_HEIGHT_NTSC : VIRTUAL_SCREEN_HEIGHT_PAL));
cf76e892 120
96aa54e4
JPM
121#if 0
122 for (uint32_t y = 0; y < Lt->rasterHeight; y++)
123 {
124 if (vjs.hardwareTypeNTSC)
125 {
126 memcpy(gl->buffer + (y * gl->textureWidth), Lt + (y * VIRTUAL_SCREEN_WIDTH), VIRTUAL_SCREEN_WIDTH * sizeof(uint32_t));
127 }
128 else
129 {
130 memcpy(gl->buffer + (y * gl->textureWidth), Lt + (y * VIRTUAL_SCREEN_WIDTH), VIRTUAL_SCREEN_WIDTH * sizeof(uint32_t));
131 }
132 }
133#endif
134#if 0
135 for (uint32_t i = 0; i < (uint32_t)(Lt->textureWidth * Lt->rasterHeight); i++)
136 {
137 uint32_t pixel = Lt->buffer[i];
138 uint8_t r = (pixel >> 24) & 0xFF, g = (pixel >> 16) & 0xFF, b = (pixel >> 8) & 0xFF;
139 pixel = ((r + g + b) / 3) & 0x00FF;
140 gl->buffer[i] = 0x000000FF | (pixel << 16) | (pixel << 8);
141 }
142#else
143 //gl->updateGL();
cf76e892 144
96aa54e4
JPM
145 //layout->addWidget(Lt);
146 //setLayout(layout);
147 // QString memDump;
148
149 // memDump += QString("Test");
150
151 // text->clear();
152 // text->setText(memDump);
153
154 //adjustSize();
155#endif
156 }
157#endif
158}
159
160
161//
162void VideoOutputWindow::keyPressEvent(QKeyEvent * e)
163{
164 if (e->key() == Qt::Key_Escape)
165 {
166 hide();
167 }
cf76e892
JPM
168}
169
170
171//
172VideoOutputWindow::~VideoOutputWindow()
173{
96aa54e4
JPM
174 //delete gl;
175 delete hbox1;
176 delete layout;
cf76e892 177}