2 // VideoWin.cpp: Video output window
6 // JPM = Jean-Paul Mari <djipi.mari@gmail.com>
9 // --- ---------- ------------------------------------------------------------
10 // JPM 06/23/2016 Created this file
11 // JPM April/2021 Added video output display in the window
16 //#include "mainwin.h"
20 VideoOutputWindow::VideoOutputWindow(QWidget
* parent
/*= 0*/) : QWidget(parent
, Qt::Dialog
),
21 layout(new QVBoxLayout
),
22 hbox1(new QHBoxLayout
)
26 //statusbar(new QStatusBar),
27 //text(new QTextBrowser)
29 setWindowTitle(tr("Output Video"));
30 //setCentralWidget(videoWidget);
32 // QFont fixedFont("Lucida Console", 8, QFont::Normal);
33 // QFont fixedFont("", 8, QFont::Normal);
34 // fixedFont.setStyleHint(QFont::TypeWriter);
35 // text->setFont(fixedFont);
38 QHBoxLayout
* hbox1
= new QHBoxLayout
;
40 layout
->addLayout(hbox1
);
42 gl
->setFixedSize(VIRTUAL_SCREEN_WIDTH
, (vjs
.hardwareTypeNTSC
? VIRTUAL_SCREEN_HEIGHT_NTSC
: VIRTUAL_SCREEN_HEIGHT_PAL
));
44 //layout->addWidget(statusbar);
45 //statusbar->setStyleSheet("background-color: lightgreen; font: bold");
46 //layout->addWidget(text);
47 //layout->addWidget(gl);
49 //QWidget* myWidget = new QWidget;
50 //myWidget->setStyleSheet("QWidget{ background: red; }");
52 //GLWidget *glWidget = new GLWidget;
53 //QHBoxLayout *mainLayout = new QHBoxLayout;
54 //layout->addWidget(myWidget);
55 //layout->setContentsMargins(100, 100, 100, 100);
58 //hbox1->addWidget(gl);
59 //layout->addLayout(hbox1);
65 void VideoOutputWindow::SetupVideo(GLWidget
*Lt
)
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;
75 //hbox1->replaceWidget(gl, Lt);
76 layout
->addLayout(hbox1
);
78 //layout->addLayout(hbox1);
80 //layout->addLayout(hbox1);
85 glViewport(0, 0, (VIRTUAL_SCREEN_WIDTH
* 2), (vjs
.hardwareTypeNTSC
? (VIRTUAL_SCREEN_HEIGHT_NTSC
* 2) : (VIRTUAL_SCREEN_HEIGHT_PAL
* 2)));
87 //resize(minimumWidth(), minimumHeight());
92 // Refresh / Display the window contents
93 void VideoOutputWindow::RefreshContents(GLWidget
*Lt
)
98 for (uint32_t i
= 0; i
< (uint32_t)(Lt
->textureWidth
* Lt
->rasterHeight
); i
++)
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);
114 QHBoxLayout
* hbox1
= new QHBoxLayout
;
115 hbox1
->addWidget(Lt
);
116 layout
->addLayout(hbox1
);
119 //gl->setFixedSize(VIRTUAL_SCREEN_WIDTH, (vjs.hardwareTypeNTSC ? VIRTUAL_SCREEN_HEIGHT_NTSC : VIRTUAL_SCREEN_HEIGHT_PAL));
122 for (uint32_t y
= 0; y
< Lt
->rasterHeight
; y
++)
124 if (vjs
.hardwareTypeNTSC
)
126 memcpy(gl
->buffer
+ (y
* gl
->textureWidth
), Lt
+ (y
* VIRTUAL_SCREEN_WIDTH
), VIRTUAL_SCREEN_WIDTH
* sizeof(uint32_t));
130 memcpy(gl
->buffer
+ (y
* gl
->textureWidth
), Lt
+ (y
* VIRTUAL_SCREEN_WIDTH
), VIRTUAL_SCREEN_WIDTH
* sizeof(uint32_t));
135 for (uint32_t i
= 0; i
< (uint32_t)(Lt
->textureWidth
* Lt
->rasterHeight
); i
++)
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);
145 //layout->addWidget(Lt);
149 // memDump += QString("Test");
152 // text->setText(memDump);
162 void VideoOutputWindow::keyPressEvent(QKeyEvent
* e
)
164 if (e
->key() == Qt::Key_Escape
)
172 VideoOutputWindow::~VideoOutputWindow()