//! [0]
GLWidgetShader::GLWidgetShader(QWidget *parent)
    : QGLWidget(QGLFormat(QGL::SampleBuffers), parent)
{
    glEnable(GL_MULTISAMPLE);

    // Important to enable the shaders
    QGLFormat rgbaformat;
    rgbaformat.setRgba(true);
    rgbaformat.setSampleBuffers(true);
    rgbaformat.setDoubleBuffer(true);
    rgbaformat.setSamples(4);
    rgbaformat.setOverlay(0);
    this->setFormat(rgbaformat);
    this->makeCurrent();
    // Very important
    this->setAutoFillBackground(false);

    QTimer *timer = new QTimer(this);
    timer->start(15);
    timer->setInterval(15);
    QObject::connect(timer,SIGNAL(timeout()),this,SLOT(repaint()));

    this->isDrawing=false;
    qglClearColor(Qt::white);
    this->nVertices = 0;
}
GLWidget::GLWidget(const QGLFormat& format, QWidget *parent, const char *name)
    : QGLWidget(parent, this) ,
    glt(*this) {
        QGLFormat f = QGLFormat::defaultFormat();
        f.setSampleBuffers(true);
        f.setOverlay(false);
        this->setFormat(f);
        setMouseTracking(true);
        setAttribute(Qt::WA_OpaquePaintEvent,true);
        this->setAutoBufferSwap(true);
    }
Exemple #3
0
    void GridsPlugin::initDockWidget()
    {
        // create and add doc widget
        _dock_widget = new QDockWidget(QObject::tr("Grid Viewer"));
        _dock_widget->setAllowedAreas(Qt::RightDockWidgetArea);
        _dock_widget->setObjectName("gridViewerDock");

        QGLFormat format;
        format.setVersion(2, 1);
        format.setDoubleBuffer(true);
        format.setDepth(true);
        format.setRgba(true);
        format.setAlpha(false);
        format.setAccum(false);
        format.setStencil(false);
        format.setStereo(false);
        format.setDirectRendering(true);
        format.setOverlay(false);

        _viewer = new GridViewer(format);
        _viewer->setMinimumSize(250, 0);
        _viewer->setObjectName("gridViewer");

        QVBoxLayout *layout = new QVBoxLayout();
        layout->addWidget(_viewer);

        QWidget *widget = new QWidget();
        widget->setLayout(layout);

        _dock_widget->setWidget(widget);

        NeuroGui::MainWindow::instance()->addDockWidget(Qt::RightDockWidgetArea, _dock_widget);

        // add to view menu
        NeuroGui::MainWindow::instance()->toolBarsMenu()->addAction(_dock_widget->toggleViewAction());
    }