У меня есть проблема с QT6 и, в частности, на MacOS, но также и Linux.
Когда я создаю VulkanWindow и использую его таким:
"vulkan_area_ = qwidget :: createwindowcontainer (vw);" < /p>
останавливается за пределы секунды. На Linux он много заикается, и на macos он полностью замораживает через несколько секунд/случайным образом.
Почему это так?
class VulkanWindow final : public QWindow {
public:
explicit VulkanWindow() {
engine_ = new GameEngine(1280, 720, nullptr);
instance_ = new QVulkanInstance();
instance_->setVkInstance(ServiceLocator::GetInstance()->GetService()->Get());
instance_->create();
setSurfaceType(VulkanSurface);
setVulkanInstance(instance_);
}
public slots:
void renderLater() {
if (!m_updatePending) {
m_updatePending = true;
QCoreApplication::postEvent(this, new QEvent(QEvent::UpdateRequest));
}
}
protected:
void exposeEvent(QExposeEvent*) override {
if (isExposed()) renderLater();
}
bool event(QEvent* e) override {
if (e->type() == QEvent::UpdateRequest) {
m_updatePending = false;
renderNow();
return true;
}
auto *surfaceEvent = static_cast(e);
if (e->type() == QEvent::PlatformSurface) {
if (surfaceEvent->surfaceEventType() == QPlatformSurfaceEvent::SurfaceAboutToBeDestroyed) {
auto sl = ServiceLocator::GetInstance();
sl->GetService()->Destroy();
return true;
}
if (const auto *surfaceEvent = dynamic_cast(e);surfaceEvent->surfaceEventType() == QPlatformSurfaceEvent::SurfaceCreated) {
qDebug() GetService();
swapchain->Build(std::make_shared(surface), VkExtent2D{640, 640}, nullptr);
engine_->surface = surface;
sl->GetService()->Build(640, 640);
return true;
}
}
}
return QWindow::event(e);
}
void renderNow() {
if (!isExposed()) return;
engine_->Run([](float delta_time, int32_t screen_width, int32_t screen_height) {
CSharpOnUpdate(delta_time, screen_width, screen_height);
}, width, height);
renderLater();
}
void resizeEvent(QResizeEvent *event) override {
QScreen *screen = QGuiApplication::primaryScreen(); // or widget->screen()
qreal dpiScale = screen->devicePixelRatio(); // integer
const auto size = this->size();
width = std::max(1, size.width()) * dpiScale;
height = std::max(1, size.height()) * dpiScale;
// Recreate swapchain/resources for new size
const ServiceLocator *sl = ServiceLocator::GetInstance();
sl->GetService()->Resize(width * dpiScale, height * dpiScale);
}
private:
QVulkanInstance *instance_ = nullptr;
GameEngine *engine_ = nullptr;
uint32_t width = 1024;
uint32_t height = 640;
bool m_updatePending = false;
};
Подробнее здесь: https://stackoverflow.com/questions/797 ... r-freezing
QT 6 QWindow Подкласс заикание/замораживание ⇐ C++
Программы на C++. Форум разработчиков
-
Anonymous
1758385131
Anonymous
У меня есть проблема с QT6 и, в частности, на MacOS, но также и Linux.
Когда я создаю VulkanWindow и использую его таким:
"vulkan_area_ = qwidget :: createwindowcontainer (vw);" < /p>
останавливается за пределы секунды. На Linux он много заикается, и на macos он полностью замораживает через несколько секунд/случайным образом.
Почему это так?
class VulkanWindow final : public QWindow {
public:
explicit VulkanWindow() {
engine_ = new GameEngine(1280, 720, nullptr);
instance_ = new QVulkanInstance();
instance_->setVkInstance(ServiceLocator::GetInstance()->GetService()->Get());
instance_->create();
setSurfaceType(VulkanSurface);
setVulkanInstance(instance_);
}
public slots:
void renderLater() {
if (!m_updatePending) {
m_updatePending = true;
QCoreApplication::postEvent(this, new QEvent(QEvent::UpdateRequest));
}
}
protected:
void exposeEvent(QExposeEvent*) override {
if (isExposed()) renderLater();
}
bool event(QEvent* e) override {
if (e->type() == QEvent::UpdateRequest) {
m_updatePending = false;
renderNow();
return true;
}
auto *surfaceEvent = static_cast(e);
if (e->type() == QEvent::PlatformSurface) {
if (surfaceEvent->surfaceEventType() == QPlatformSurfaceEvent::SurfaceAboutToBeDestroyed) {
auto sl = ServiceLocator::GetInstance();
sl->GetService()->Destroy();
return true;
}
if (const auto *surfaceEvent = dynamic_cast(e);surfaceEvent->surfaceEventType() == QPlatformSurfaceEvent::SurfaceCreated) {
qDebug() GetService();
swapchain->Build(std::make_shared(surface), VkExtent2D{640, 640}, nullptr);
engine_->surface = surface;
sl->GetService()->Build(640, 640);
return true;
}
}
}
return QWindow::event(e);
}
void renderNow() {
if (!isExposed()) return;
engine_->Run([](float delta_time, int32_t screen_width, int32_t screen_height) {
CSharpOnUpdate(delta_time, screen_width, screen_height);
}, width, height);
renderLater();
}
void resizeEvent(QResizeEvent *event) override {
QScreen *screen = QGuiApplication::primaryScreen(); // or widget->screen()
qreal dpiScale = screen->devicePixelRatio(); // integer
const auto size = this->size();
width = std::max(1, size.width()) * dpiScale;
height = std::max(1, size.height()) * dpiScale;
// Recreate swapchain/resources for new size
const ServiceLocator *sl = ServiceLocator::GetInstance();
sl->GetService()->Resize(width * dpiScale, height * dpiScale);
}
private:
QVulkanInstance *instance_ = nullptr;
GameEngine *engine_ = nullptr;
uint32_t width = 1024;
uint32_t height = 640;
bool m_updatePending = false;
};
Подробнее здесь: [url]https://stackoverflow.com/questions/79770280/qt-6-qwindow-subclass-stutter-freezing[/url]
Ответить
1 сообщение
• Страница 1 из 1
Перейти
- Кемерово-IT
- ↳ Javascript
- ↳ C#
- ↳ JAVA
- ↳ Elasticsearch aggregation
- ↳ Python
- ↳ Php
- ↳ Android
- ↳ Html
- ↳ Jquery
- ↳ C++
- ↳ IOS
- ↳ CSS
- ↳ Excel
- ↳ Linux
- ↳ Apache
- ↳ MySql
- Детский мир
- Для души
- ↳ Музыкальные инструменты даром
- ↳ Печатная продукция даром
- Внешняя красота и здоровье
- ↳ Одежда и обувь для взрослых даром
- ↳ Товары для здоровья
- ↳ Физкультура и спорт
- Техника - даром!
- ↳ Автомобилистам
- ↳ Компьютерная техника
- ↳ Плиты: газовые и электрические
- ↳ Холодильники
- ↳ Стиральные машины
- ↳ Телевизоры
- ↳ Телефоны, смартфоны, плашеты
- ↳ Швейные машинки
- ↳ Прочая электроника и техника
- ↳ Фототехника
- Ремонт и интерьер
- ↳ Стройматериалы, инструмент
- ↳ Мебель и предметы интерьера даром
- ↳ Cантехника
- Другие темы
- ↳ Разное даром
- ↳ Давай меняться!
- ↳ Отдам\возьму за копеечку
- ↳ Работа и подработка в Кемерове
- ↳ Давай с тобой поговорим...
Мобильная версия