Details
-
Bug
-
Resolution: Unresolved
-
P1: Critical
-
None
-
5.15.16
-
None
-
MACOS + M2 CPU
Description
I am using QT 5.15.16 + SDL 2.30.10 for testing, right now I create 2 widgets, one widget call video widget use to display YUV data, other widget call control widget which has some PushButtons.
on the video widget, use SDL_CreateWindowFrom() to bind this widget, and want to show YUV data via SDL_RenderCopy/SDL_RenderPresent API.
when render it on macOS, the control widget desn't work, it just show black. what is problem? is it the known issue on QT?
this code can work fine on Windows + Ubuntu.
#include "mainwindow.h"
#include "ui_mainwindow.h"
#include <thread>
#include <QTimer>
#include <QDebug>
MainWindow::MainWindow(QWidget *parent)
: QMainWindow(parent)
, ui(new Ui::MainWindow)
void MainWindow::renderYUV()
{
SDL_Rect rect = {};
width = ui->video->width();
height = ui->video->height();
qDebug() << "w :" << width << " h:" << height;
yPlane = new uint8_t[width * height]; // Y plane
uPlane = new uint8_t[width * height / 4]; // U plane
vPlane = new uint8_t[width * height / 4]; // V plane
// fill YUV data
for (int i = 0; i < width * height; ++i)
for (int i = 0; i < width * height / 4; ++i)
{ uPlane[i] = 128; // U vPlane[i] = 128; // V } SDL_Texture *texture = SDL_CreateTexture(render, SDL_PIXELFORMAT_YV12, SDL_TEXTUREACCESS_STREAMING, width, height);
if (!texture)
SDL_UpdateTexture(texture, nullptr, yPlane, width);
SDL_RenderClear(render);
rect.x = 0;
rect.y = 0;
rect.w = ui->video->width();
rect.h = ui->video->height();
qDebug() << "display rect x " << rect.x << " y " << rect.y << " w " << rect.w << " h " << rect.h;test.zip
SDL_RenderCopy(render, texture, nullptr, &rect);
SDL_RenderPresent(render);
SDL_DestroyTexture(texture);
}
MainWindow::~MainWindow()
{ delete ui; }