Merge branch 'develop'
[clinton/Virtual-Jaguar-Rx.git] / src / debugger / VideoWin.cpp
1 //
2 // VideoWin.cpp: Video output window
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
11 // JPM April/2021 Added video output display in the window
12
13 #include "VideoWin.h"
14 #include "tom.h"
15 #include "settings.h"
16 //#include "mainwin.h"
17
18
19 //
20 VideoOutputWindow::VideoOutputWindow(QWidget * parent/*= 0*/) : QWidget(parent, Qt::Dialog),
21 layout(new QVBoxLayout),
22 hbox1(new QHBoxLayout)
23 //gl(new GLWidget)
24 //layout(0),
25 //hbox1(0)
26 //statusbar(new QStatusBar),
27 //text(new QTextBrowser)
28 {
29 setWindowTitle(tr("Output Video"));
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);
37 #if 0
38 QHBoxLayout * hbox1 = new QHBoxLayout;
39 hbox1->addWidget(gl);
40 layout->addLayout(hbox1);
41
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);
48
49 //QWidget* myWidget = new QWidget;
50 //myWidget->setStyleSheet("QWidget{ background: red; }");
51
52 //GLWidget *glWidget = new GLWidget;
53 //QHBoxLayout *mainLayout = new QHBoxLayout;
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 //
65 void 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 }
89 }
90
91
92 // Refresh / Display the window contents
93 void VideoOutputWindow::RefreshContents(GLWidget *Lt)
94 {
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));
120
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();
144
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 //
162 void VideoOutputWindow::keyPressEvent(QKeyEvent * e)
163 {
164 if (e->key() == Qt::Key_Escape)
165 {
166 hide();
167 }
168 }
169
170
171 //
172 VideoOutputWindow::~VideoOutputWindow()
173 {
174 //delete gl;
175 delete hbox1;
176 delete layout;
177 }