Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/cplusplus/150.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++ QOpenGLWidget update()不';启用多重采样时渲染场景_C++_Qt_Opengl - Fatal编程技术网

C++ QOpenGLWidget update()不';启用多重采样时渲染场景

C++ QOpenGLWidget update()不';启用多重采样时渲染场景,c++,qt,opengl,C++,Qt,Opengl,我正在尝试使用抗锯齿来获取场景中的造型器边缘。但是,当我启用多重采样并调用QOpenGLWidget::update()时,场景不会更新。虽然如果单击场景,则会渲染抗锯齿场景。如果注释掉设置使用的采样数的单行,则在调用update时,会将锯齿场景渲染为正常场景 我在main.cpp中设置了默认曲面格式,我使用的是CoreProfile 4.3,采样设置为4 #include <QApplication> #include "widgets/mainwindow.h" int mai

我正在尝试使用抗锯齿来获取场景中的造型器边缘。但是,当我启用多重采样并调用QOpenGLWidget::update()时,场景不会更新。虽然如果单击场景,则会渲染抗锯齿场景。如果注释掉设置使用的采样数的单行,则在调用update时,会将锯齿场景渲染为正常场景

我在main.cpp中设置了默认曲面格式,我使用的是CoreProfile 4.3,采样设置为4

#include <QApplication>
#include "widgets/mainwindow.h"

int main(int argc, char *argv[])
{
    auto format = QSurfaceFormat();
    format.setVersion(4,3);
    //If I comment out this line everything works great but with jagged edges 
    format.setSamples(4);
    format.setProfile(QSurfaceFormat::CoreProfile);
    QSurfaceFormat::setDefaultFormat(format);
    QApplication a(argc, argv);
    MainWindow w;
    w.show();
    w.resize(1200, 800);
    return a.exec();
}
使用多重采样时调用“更新”时不渲染的示例(还有更多)是加载新网格时

auto ViewerWidget::importMesh(QString filename) -> void
{
    mesh = new Mesh(filename);
    initializeGL();
    update();

}
但是,当我单击屏幕时,场景确实会更新。我的鼠标移动事件如下,与我的网格导入方法相比,不做任何特殊的事情

void ViewerWidget::mousePressEvent(QMouseEvent *event)
{
    if (event->buttons() & Qt::LeftButton) {
        m_rotationTrackball.push(pixelPosToViewPos(event->pos()), m_scaleTrackball.rotation().conjugate());
    }
    update();
}

void ViewerWidget::mouseReleaseEvent(QMouseEvent *event)
{
    if (event->buttons() & Qt::LeftButton) {
        m_rotationTrackball.release(pixelPosToViewPos(event->pos()), m_scaleTrackball.rotation().conjugate());
    }
    update();
}

void ViewerWidget::mouseMoveEvent(QMouseEvent *event)
{
    if (event->buttons() & Qt::LeftButton)
    {
        m_rotationTrackball.move(pixelPosToViewPos(event->pos()), m_scaleTrackball.rotation().conjugate());
    }
    else
    {
        m_rotationTrackball.release(pixelPosToViewPos(event->pos()), m_scaleTrackball.rotation().conjugate());
    }
    update();
}

任何关于如何解决此问题的建议都将不胜感激!提前感谢。

哪个平台/Qt版本?有许多与MSAA相关的bug,您可能想查看bug跟踪器…我使用的是OSX 10.10.5和Qt 5.4.0,您可以试试5.5.0或5.5.1吗?可能已经修好了。我已经切换到5.5.0,已经修好了-谢谢。
void ViewerWidget::mousePressEvent(QMouseEvent *event)
{
    if (event->buttons() & Qt::LeftButton) {
        m_rotationTrackball.push(pixelPosToViewPos(event->pos()), m_scaleTrackball.rotation().conjugate());
    }
    update();
}

void ViewerWidget::mouseReleaseEvent(QMouseEvent *event)
{
    if (event->buttons() & Qt::LeftButton) {
        m_rotationTrackball.release(pixelPosToViewPos(event->pos()), m_scaleTrackball.rotation().conjugate());
    }
    update();
}

void ViewerWidget::mouseMoveEvent(QMouseEvent *event)
{
    if (event->buttons() & Qt::LeftButton)
    {
        m_rotationTrackball.move(pixelPosToViewPos(event->pos()), m_scaleTrackball.rotation().conjugate());
    }
    else
    {
        m_rotationTrackball.release(pixelPosToViewPos(event->pos()), m_scaleTrackball.rotation().conjugate());
    }
    update();
}