Ejemplo n.º 1
0
ArthurFrame::ArthurFrame(QWidget *parent)
    : QWidget(parent)
    , m_prefer_image(false)
{
#ifdef QT_OPENGL_SUPPORT
  std::cout << "Using Open GL" << std::endl;
    glw = 0;
    m_use_opengl = false;
    QGLFormat f = QGLFormat::defaultFormat();
    f.setSampleBuffers(true);
    f.setStencil(true);
    f.setAlpha(true);
    f.setAlphaBufferSize(8);
    QGLFormat::setDefaultFormat(f);
#endif
    m_document = 0;
    m_show_doc = false;

    m_tile = QPixmap(100, 100);
    m_tile.fill(Qt::white);
    QPainter pt(&m_tile);
    QColor color(240, 240, 240);
    pt.fillRect(0, 0, 50, 50, color);
    pt.fillRect(50, 50, 50, 50, color);
    pt.end();

//     QPalette pal = palette();
//     pal.setBrush(backgroundRole(), m_tile);
//     setPalette(pal);

#ifdef Q_WS_X11
    QPixmap xRenderPixmap(1, 1);
    m_prefer_image = !xRenderPixmap.x11PictureHandle();
#endif
}
Ejemplo n.º 2
0
/*===========================================================================*/
void ScreenBase::create()
{
    KVS_ASSERT( m_id == -1 );

    // Initialize display mode.
    QGLFormat f = QGLFormat::defaultFormat();
    f.setDoubleBuffer( displayFormat().doubleBuffer() );
    f.setRgba( displayFormat().colorBuffer() );
    f.setDepth( displayFormat().depthBuffer() );
    f.setAccum( displayFormat().accumulationBuffer() );
    f.setStencil( displayFormat().stencilBuffer() );
    f.setStereo( displayFormat().stereoBuffer() );
    f.setSampleBuffers( displayFormat().multisampleBuffer() );
    f.setAlpha( displayFormat().alphaChannel() );
    QGLFormat::setDefaultFormat( f );

    // Set screen geometry.
    QWidget::setGeometry( BaseClass::x(), BaseClass::y(), BaseClass::width(), BaseClass::height() );

    QGLWidget::makeCurrent();

    // Initialize GLEW.
    GLenum result = glewInit();
    if ( result != GLEW_OK )
    {
        const GLubyte* message = glewGetErrorString( result );
        kvsMessageError( "GLEW initialization failed: %s.", message );
    }

    // Create window.
    static int counter = 0;
    m_id = counter++;
}
Ejemplo n.º 3
0
const QGLFormat GLFormat::asQGLFormat() const
{
    QGLFormat format;

    format.setVersion(m_majorVersion, m_minorVersion);
    
    switch(m_profile)
    {
    default:
    case NoProfile:
        format.setProfile(QGLFormat::NoProfile); 
        break;
    case CoreProfile:
        format.setProfile(QGLFormat::CoreProfile); 
        break;
    case CompatibilityProfile:
        format.setProfile(QGLFormat::CompatibilityProfile); 
        break;
    };

    format.setRedBufferSize    (m_redBufferSize);
    format.setGreenBufferSize  (m_greenBufferSize);
    format.setBlueBufferSize   (m_blueBufferSize);
    format.setAlphaBufferSize  (m_alphaBufferSize);

    format.setDepthBufferSize  (m_depthBufferSize);
    format.setStencilBufferSize(m_stencilBufferSize);
    format.setDoubleBuffer     (m_doubleBuffer);
    format.setStereo           (m_stereo);
    format.setSampleBuffers    (m_sampleBuffers);
    format.setSamples          (m_samples);
    format.setSwapInterval     (m_swapInterval);

    return format;
}
Ejemplo n.º 4
0
void SkGLWidget::setSampleCount(int sampleCount)
{
    QGLFormat currentFormat = format();
    currentFormat.setSampleBuffers(sampleCount > 0);
    currentFormat.setSamples(sampleCount);
    setFormat(currentFormat);
}
Ejemplo n.º 5
0
//! [0]
FLGLWindow::FLGLWindow(QWidget * parent) : QWidget(parent), mdi_(parent)
{
    QGLFormat glFormat;
    glFormat.setVersion( 4, 1 );
    glFormat.setProfile( QGLFormat::CoreProfile ); // Requires >=Qt-4.8.0
    glFormat.setSampleBuffers( true );
    glWidget = new FLGLWidget(glFormat);

    xSlider = createSlider();
    ySlider = createSlider();
    zSlider = createSlider();

    connect(xSlider, SIGNAL(valueChanged(int)), glWidget, SLOT(setXRotation(int)));
    connect(glWidget, SIGNAL(xRotationChanged(int)), xSlider, SLOT(setValue(int)));
    connect(ySlider, SIGNAL(valueChanged(int)), glWidget, SLOT(setYRotation(int)));
    connect(glWidget, SIGNAL(yRotationChanged(int)), ySlider, SLOT(setValue(int)));
    connect(zSlider, SIGNAL(valueChanged(int)), glWidget, SLOT(setZRotation(int)));
    connect(glWidget, SIGNAL(zRotationChanged(int)), zSlider, SLOT(setValue(int)));
////! [0]
//
////! [1]
    QHBoxLayout *mainLayout = new QHBoxLayout;
    mainLayout->addWidget(glWidget);
    mainLayout->addWidget(xSlider);
    mainLayout->addWidget(ySlider);
    mainLayout->addWidget(zSlider);
    setLayout(mainLayout);

    xSlider->setValue(0);
    ySlider->setValue(0);
    zSlider->setValue(0);
    setWindowTitle(tr("Hello GL"));
}
Ejemplo n.º 6
0
ArthurFrame::ArthurFrame(QWidget *parent)
    : QWidget(parent)
    , m_prefer_image(false)
{
#ifdef QT_OPENGL_SUPPORT
    glw = 0;
    m_use_opengl = false;
    QGLFormat f = QGLFormat::defaultFormat();
    f.setSampleBuffers(true);
    f.setStencil(true);
    f.setAlpha(true);
    f.setAlphaBufferSize(8);
    QGLFormat::setDefaultFormat(f);
#endif
    m_document = 0;
    m_show_doc = false;

    m_tile = QPixmap(128, 128);
    m_tile.fill(Qt::white);
    QPainter pt(&m_tile);
    QColor color(230, 230, 230);
    pt.fillRect(0, 0, 64, 64, color);
    pt.fillRect(64, 64, 64, 64, color);
    pt.end();

//     QPalette pal = palette();
//     pal.setBrush(backgroundRole(), m_tile);
//     setPalette(pal);

#ifdef Q_WS_X11
    QPixmap xRenderPixmap(1, 1);
    m_prefer_image = xRenderPixmap.pixmapData()->classId() == QPixmapData::X11Class && !xRenderPixmap.x11PictureHandle();
#endif
}
Ejemplo n.º 7
0
PixmapRenderer::PixmapRenderer(int width, int height, QGLWidget *shareWidget)
	: width_(width), height_(height), shareWidget_(shareWidget)
{
	QGLFormat fmt = QGLFormat::defaultFormat();
	fmt.setAlpha(true);
	fmt.setSampleBuffers(true);

	if (!QGLPixelBuffer::hasOpenGLPbuffers()) {
		throw std::runtime_error("OpenGL Pbuffer extension required.");
	}
	
	buffer_ = new QGLPixelBuffer(width_, height_, fmt, shareWidget_);
	buffer_->makeCurrent();	
	
	// Initialize GL
#ifndef KONSTRUKTOR_DB_UPDATER
	params_ = new ldraw_renderer::parameters(*Application::self()->renderer_params());
#else
	params_ = new ldraw_renderer::parameters();
	params_->set_stud_rendering_mode(ldraw_renderer::parameters::stud_regular);
#endif
	
	ldraw_renderer::renderer_opengl_factory ro(params_, ldraw_renderer::renderer_opengl_factory::mode_vbo);
	renderer_ = ro.create_renderer();
	renderer_->set_base_color(ldraw::color(7));
	renderer_->setup();
	
	glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
	glClearDepth(1.0f);
	
	glMatrixMode(GL_PROJECTION);
	glViewport(0, 0, width_, height_);
	
	buffer_->doneCurrent();
}
Ejemplo n.º 8
0
int main(int argc, char** argv)
{
  char *flnm;

  QApplication application(argc,argv);
  
  QGLFormat glFormat;
  glFormat.setSampleBuffers(true);
  glFormat.setDoubleBuffer(true);
  glFormat.setRgba(true);
  glFormat.setAlpha(true);

//  //-----------------------------
//  // did not work - still getting 8bit buffers
//  glFormat.setAlphaBufferSize(16);
//  glFormat.setRedBufferSize(16);
//  glFormat.setGreenBufferSize(16);
//  glFormat.setBlueBufferSize(16);
//  //-----------------------------

  flnm = argv[1];
  if (QString::compare(argv[1], "-stereo", Qt::CaseInsensitive) == 0)
    {
      flnm = argv[2];
      glFormat.setStereo(true);
    }
  QGLFormat::setDefaultFormat(glFormat);

  MainWindow mainwindow;
  mainwindow.show();
  
  // Run main loop.
  return application.exec();
}
Ejemplo n.º 9
0
GLContainer::GLContainer(QWidget *parent) :
    QAbstractScrollArea (parent),
    _ctrlPressed(false),
    _mousePressed(false),
    _sWidth(20),
    _sHeight(20),
    _prevNum(-1),
    _scrollMoved(false)
{
    QGLFormat format;
    format.setVersion(4, 0);
    format.setProfile(QGLFormat::CompatibilityProfile);
    format.setSampleBuffers(true);

    _glWidget = new GLWidget(format);
    _glWidget->setObjectName(QStringLiteral("myGLImageDisplay"));

    setViewport(_glWidget);

    horizontalScrollBar()->setSingleStep(10);
    horizontalScrollBar()->setPageStep(100);

    verticalScrollBar()->setSingleStep(10);
    verticalScrollBar()->setPageStep(100);

    connect(horizontalScrollBar(), SIGNAL(valueChanged(int)),this, SLOT(HScrollChanged(int)));
    connect(verticalScrollBar(),   SIGNAL(valueChanged(int)),this, SLOT(VScrollChanged(int)));

    setMouseTracking(true);

    _doubleClickTimer = new QTimer(this); connect(_doubleClickTimer, SIGNAL(timeout()), this, SLOT(DummyFunction()));
    _doubleClickTimeout = 100;

    this->_justInitialized = true;
}
Ejemplo n.º 10
0
void *
figure::f_main_loop(void) {

	QApplication * _pc_app;
	int i_argc = 1;
	char * ppc_argv[2] = { (char*) "toto", (char*) "ttut" };
	cout << "Creating app " << pthread_self() << endl;
	figure_app c_app(i_argc, ppc_argv);

#if 1
	QGLFormat glf = QGLFormat::defaultFormat();
	glf.setSampleBuffers(true);
	glf.setSamples(4);
	QGLFormat::setDefaultFormat(glf);
#endif

	c_app.f_new_window(_pc_core);
	//cout << "core: " <<_pc_core << endl;
	//glplot::window *_pc_win = new glplot::window(_pc_core);

	/* Affichage de notre premiere fenêtre de rendu OpenGL */
	//_pc_win->show();

	/* Registring application pointer */
	_pv_app = &c_app;
	/* Running QT Main LOOP */
	c_app.exec();
}
Ejemplo n.º 11
0
MuseBox::MuseBox(QWidget *parent) :
    QMainWindow(parent)
{
    //TODO add a splash screen here? would be totally fun!
    qmlRegisterType<TrackArrangementBackground>("TrackArrangement",1,0,"TrackArrangementBackground");
    qmlRegisterType<CursorRuler>("TrackArrangement",1,0,"CursorRuler");
    qmlRegisterType<PatternModel>("DataModel",1,0,"PatternModel");
    qmlRegisterType<NoteModel>("DataModel",1,0,"NoteModel");
    qmlRegisterType<PatternDisplay>("TrackArrangement",1,0,"PatternDisplay");
    qmlRegisterType<PatternNoteDisplay>("TrackArrangement",1,0,"PatternNoteDisplay");
    QmlApplicationViewer *view = new QmlApplicationViewer();
    view->rootContext()->setContextProperty("musebox", this);
    view->rootContext()->setContextProperty("trackModel", &this->trackModel);
    view->setSource(QUrl::fromLocalFile("qml/MuseBox/main.qml"));
    view->setResizeMode(QDeclarativeView::SizeRootObjectToView);


    QGLFormat format = QGLFormat::defaultFormat();
    format.setSampleBuffers(false);
    QGLWidget *glWidget = new QGLWidget(format);
    glWidget->setAutoFillBackground(false);
    view->setViewport(glWidget);

    setCentralWidget(view);
    Hardware::Init();
    view->rootContext()->setContextProperty("transposeMachine", Hardware::TransposeMachine);
    Hardware::StartAudio();
}
Ejemplo n.º 12
0
Archivo: main.cpp Proyecto: cedrus/qt4
int main(int argc, char **argv)
{
    QApplication a(argc, argv);

    QGLFormat f = QGLFormat::defaultFormat();
    f.setSampleBuffers(true);
    QGLFormat::setDefaultFormat(f);
    if (!QGLFormat::hasOpenGL()) {
	QMessageBox::information(0, "OpenGL samplebuffers",
				 "This system does not support OpenGL.");
        return 0;
    }

    GLWidget widget(0);

    if (!widget.format().sampleBuffers()) {
	QMessageBox::information(0, "OpenGL samplebuffers",
				 "This system does not have sample buffer support.");
        return 0;
    }

    widget.resize(640, 480);
    widget.show();

    return a.exec();
}
Ejemplo n.º 13
0
FMSampleTextView::FMSampleTextView ( QWidget* parent )
		: QGraphicsView ( parent ),
		hasPendingUpdate ( false )
{
#if 0
	QGLFormat glfmt;
	glfmt.setSampleBuffers ( true );
	QGLWidget *glwgt = new QGLWidget ( glfmt );
// 	qDebug()<<"GL:: A DR S"<<glwgt->format().alpha()<<glwgt->format().directRendering()<<glwgt->format().sampleBuffers();
// 	setViewport(glwgt);
	if ( glwgt->format().sampleBuffers() )
	{
		setViewport ( glwgt );
		qDebug() <<"opengl enabled - DirectRendering("<< glwgt->format().directRendering() <<") - SampleBuffers("<< glwgt->format().sampleBuffers() <<")";
	}
	else
	{
		qDebug() <<"opengl disabled - DirectRendering("<< glwgt->format().directRendering() <<") - SampleBuffers("<< glwgt->format().sampleBuffers() <<")";
		delete glwgt;
	}
#endif

	setInteractive ( false );
	setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
	setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
	theRect = 0;
	fPage = 0;
	isSelecting = false;
	isPanning = false;
	setAlignment ( Qt::AlignTop | Qt::AlignHCenter );
	setTransformationAnchor ( QGraphicsView::NoAnchor );
	setRenderHint ( QPainter::Antialiasing, true );
	setBackgroundBrush(Qt::white);
}
Ejemplo n.º 14
0
int main(int argc, char *argv[])
{
	QApplication a(argc, argv);
	
	QGLFormat glf = QGLFormat::defaultFormat();
	glf.setSampleBuffers(true);
	glf.setSamples(16);
	QGLFormat::setDefaultFormat(glf);
	
	a.setStyle("windowsxp");
	std::wstring arg = L"";
	#ifdef _WIN32
		LPWSTR wideArgText = GetCommandLineW();
		int wArgc;
		LPWSTR *wideArgs = CommandLineToArgvW(wideArgText, &wArgc);
		if (wArgc == 2) {
			arg = wideArgs[1];
		}
	#endif
	MainWindow *w = new MainWindow(arg);
	w->show();
	
	int exec = a.exec();
	delete w;
	#ifdef _WIN32
		LocalFree(wideArgs);
	#endif
	return exec;
}
Ejemplo n.º 15
0
GLWidget::GLWidget(QWidget *parent) :
    QGLWidget(QGLFormat(QGL::SampleBuffers),parent),
          m_camera( new Camera( this ) )
{
    setFocusPolicy(Qt::StrongFocus);
    glEnable(GL_MULTISAMPLE);
    glEnable(GL_STENCIL_FUNC);
    simTimer = new QTimer(this);
    connect(simTimer, SIGNAL(timeout()), this, SLOT(updateGL()));
    simTimer->start(0);

    // Initialize the camera position and orientation
    m_camera->setPosition( QVector3D( 5.0f, 5.0f, 5.0f ) );
    m_camera->setViewCenter( QVector3D( 0.0f, 0.0f, 0.0f ) );
    m_camera->setUpVector( QVector3D( 0.0f, 1.0f, 0.0f ) );

    QGLFormat glFormat;
    glFormat.setVersion( 3, 3 );
    glFormat.setProfile( QGLFormat::CoreProfile ); // Requires >=Qt-4.8.0
    glFormat.setSampleBuffers( true );
    glFormat.setSamples(16);

    this->setFormat(glFormat);

    scene = new Scene(this);
    scene->setCamera(m_camera);
    withshadow = true;
}
Ejemplo n.º 16
0
 void CQTOpenGLMainWindow::CreateOpenGLWidget(TConfigurationNode& t_tree) {
    /* Create user functions */
    m_pcUserFunctions = CreateUserFunctions(t_tree);
    /* Set up OpenGL features */
    QGLFormat cGLFormat = QGLFormat::defaultFormat();
    cGLFormat.setSampleBuffers(m_pcToggleAntiAliasingAction->isChecked());
    cGLFormat.setStencil(false);
    QGLFormat::setDefaultFormat(cGLFormat);
    /* Create the widget */
    QWidget* pcPlaceHolder = new QWidget(this);
    m_pcOpenGLWidget = new CQTOpenGLWidget(pcPlaceHolder, *m_pcUserFunctions);
    m_pcOpenGLWidget->setCursor(QCursor(Qt::OpenHandCursor));
    m_pcOpenGLWidget->GetCamera().Init(t_tree);
    m_pcOpenGLWidget->GetFrameGrabData().Init(t_tree);
    m_pcToggleAntiAliasingAction->setChecked(cGLFormat.sampleBuffers());
    /* Invert mouse controls? */
    bool bInvertMouse;
    GetNodeAttributeOrDefault(t_tree, "invert_mouse", bInvertMouse, false);
    m_pcOpenGLWidget->SetInvertMouse(bInvertMouse);
    /* Set the window as the central widget */
    CQTOpenGLLayout* pcQTOpenGLLayout = new CQTOpenGLLayout();
    pcQTOpenGLLayout->addWidget(m_pcOpenGLWidget);
    pcPlaceHolder->setLayout(pcQTOpenGLLayout);
    setCentralWidget(pcPlaceHolder);
 }
Ejemplo n.º 17
0
int main(int argc, char ** argv) {

    QApplication app(argc, argv);

#ifdef USE_QT4
	QGLFormat fmt;
	fmt.setSampleBuffers(true);
	QGLWidgetTest test(fmt);
#else
	QGLWidgetTest test;
	app.setMainWidget(&test);
#endif

	// if you want fullscreen support, plese uncomment the following line
	// test.setWindowState(test.windowState() ^ Qt::WindowFullScreen);
	test.show();
	test.setFocus();
#ifdef USE_QT4
	test.setWindowTitle("Path example - Press F1 for help");
#else
	test.setCaption("Path example - Press F1 for help");
#endif
    app.connect(&app, SIGNAL(lastWindowClosed()), &app, SLOT(quit()));
    return app.exec();
}
Ejemplo n.º 18
0
int main(int argc, char **argv)
{
  if (argc < 3) {
    fprintf(stderr, "Usage: %s <dataname> <ts> <tl>\n", argv[0]);
    return EXIT_FAILURE;
  }
  
  const std::string dataname = argv[1];
  const int ts = atoi(argv[2]), 
            tl = atoi(argv[3]), 
            span = 1;

  QApplication app(argc, argv); 

  QGLFormat fmt = QGLFormat::defaultFormat();
  fmt.setSampleBuffers(true);
  fmt.setSamples(16); 
  QGLFormat::setDefaultFormat(fmt); 
  
  VortexTransition vt;
  vt.LoadFromFile(dataname, ts, tl);
  vt.ConstructSequence();

  CStorylineWidget *widget = new CStorylineWidget;
  widget->SetVortexTrasition(&vt);
  widget->show();

  return app.exec(); 
}
Ejemplo n.º 19
0
//! [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;
}
Ejemplo n.º 20
0
int main(int argc, char **argv)
{
  std::string filename_vortex, filename_trace; 
  
  if (argc == 1) {
    fprintf(stderr, "Usage: %s <vortex_file> [trace_file]\n", argv[0]); 
    return EXIT_FAILURE;
  } 
  if (argc >= 2) filename_vortex = argv[1];
  if (argc >= 3) filename_trace = argv[2]; 

  QApplication app(argc, argv); 
  // glutInit(&argc, argv);

  QGLFormat fmt = QGLFormat::defaultFormat();
  fmt.setSampleBuffers(true);
  fmt.setSamples(16); 
  QGLFormat::setDefaultFormat(fmt); 

  CGLWidget *widget = new CGLWidget;
  widget->show(); 
  widget->LoadVortexLines(filename_vortex); 
  // widget->LoadVortexOjbectsFromTextFile(filename_vortex); 
  widget->LoadFieldLines(filename_trace);

  return app.exec(); 
}
Ejemplo n.º 21
0
QT_BEGIN_NAMESPACE

/*!
    Returns an OpenGL format for the window format specified by \a format.
*/
QGLFormat QGLFormat::fromSurfaceFormat(const QSurfaceFormat &format)
{
    QGLFormat retFormat;
    if (format.alphaBufferSize() >= 0)
        retFormat.setAlphaBufferSize(format.alphaBufferSize());
    if (format.blueBufferSize() >= 0)
        retFormat.setBlueBufferSize(format.blueBufferSize());
    if (format.greenBufferSize() >= 0)
        retFormat.setGreenBufferSize(format.greenBufferSize());
    if (format.redBufferSize() >= 0)
        retFormat.setRedBufferSize(format.redBufferSize());
    if (format.depthBufferSize() >= 0)
        retFormat.setDepthBufferSize(format.depthBufferSize());
    if (format.samples() > 1) {
        retFormat.setSampleBuffers(format.samples());
        retFormat.setSamples(true);
    }
    if (format.stencilBufferSize() > 0) {
        retFormat.setStencil(true);
        retFormat.setStencilBufferSize(format.stencilBufferSize());
    }
    retFormat.setDoubleBuffer(format.swapBehavior() != QSurfaceFormat::SingleBuffer);
    retFormat.setStereo(format.stereo());
    return retFormat;
}
Ejemplo n.º 22
0
int main(int argc, char *argv[])
{
// Depending on which is the recommended way for the platform, either use
// opengl graphics system or paint into QGLWidget.
#ifdef SHADEREFFECTS_USE_OPENGL_GRAPHICSSYSTEM
    QApplication::setGraphicsSystem("opengl");
#endif

    QApplication app(argc, argv);
    QmlApplicationViewer viewer;

#ifndef SHADEREFFECTS_USE_OPENGL_GRAPHICSSYSTEM
    QGLFormat format = QGLFormat::defaultFormat();
    format.setSampleBuffers(false);
    format.setSwapInterval(1);
    QGLWidget* glWidget = new QGLWidget(format);
    glWidget->setAutoFillBackground(false);
    viewer.setViewport(glWidget);
#endif

    viewer.setViewportUpdateMode(QGraphicsView::FullViewportUpdate);
    viewer.setAttribute(Qt::WA_OpaquePaintEvent);
    viewer.setAttribute(Qt::WA_NoSystemBackground);
    viewer.setOrientation(QmlApplicationViewer::ScreenOrientationAuto);
    viewer.setMainQmlFile(QLatin1String("qml/shadereffects/main.qml"));
    QObject::connect(viewer.engine(), SIGNAL(quit()), &viewer, SLOT(close()));
    viewer.showExpanded();

    return app.exec();
}
Ejemplo n.º 23
0
    QTM_USE_NAMESPACE
#endif
#endif


MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent)
{
    m_view = new QDeclarativeView(this);
    m_view->setAttribute(Qt::WA_NoSystemBackground);

#ifndef QT_NO_OPENGL
    // Use QGLWidget to get the opengl support if available
    QGLFormat format = QGLFormat::defaultFormat();
    format.setSampleBuffers(false);

    QGLWidget *glWidget = new QGLWidget(format);
    glWidget->setAutoFillBackground(false);
    m_view->setViewport(glWidget);     // ownership of glWidget is taken
#endif

    m_view->setSource(QUrl("qrc:/qml/SplashScreen.qml"));
    m_view->setResizeMode(QDeclarativeView::SizeRootObjectToView);
    setCentralWidget(m_view);

    // To delay the loading of main QML file so that the splash screen
    // would show, we use single shot timer.
    QTimer::singleShot(0, this, SLOT(initializeQMLComponent()));
}
Ejemplo n.º 24
0
QT_BEGIN_NAMESPACE

QGLFormat QGLFormat::fromPlatformWindowFormat(const QPlatformWindowFormat &format)
{
    QGLFormat retFormat;
    retFormat.setAccum(format.accum());
    if (format.accumBufferSize() >= 0)
        retFormat.setAccumBufferSize(format.accumBufferSize());
    retFormat.setAlpha(format.alpha());
    if (format.alphaBufferSize() >= 0)
        retFormat.setAlphaBufferSize(format.alphaBufferSize());
    if (format.blueBufferSize() >= 0)
        retFormat.setBlueBufferSize(format.blueBufferSize());
    retFormat.setDepth(format.depth());
    if (format.depthBufferSize() >= 0)
        retFormat.setDepthBufferSize(format.depthBufferSize());
    retFormat.setDirectRendering(format.directRendering());
    retFormat.setDoubleBuffer(format.doubleBuffer());
    if (format.greenBufferSize() >= 0)
        retFormat.setGreenBufferSize(format.greenBufferSize());
    if (format.redBufferSize() >= 0)
        retFormat.setRedBufferSize(format.redBufferSize());
    retFormat.setRgba(format.rgba());
    retFormat.setSampleBuffers(format.sampleBuffers());
    retFormat.setSamples(format.sampleBuffers());
    retFormat.setStencil(format.stencil());
    if (format.stencilBufferSize() >= 0)
        retFormat.setStencilBufferSize(format.stencilBufferSize());
    retFormat.setStereo(format.stereo());
    retFormat.setSwapInterval(format.swapInterval());
    return retFormat;
}
Ejemplo n.º 25
0
QGLFormat setContext() {
    QGLFormat glFormat;
    glFormat.setVersion(3, 3);
    glFormat.setProfile(QGLFormat::CoreProfile);
    glFormat.setSampleBuffers(true);
    return glFormat;

}
Ejemplo n.º 26
0
bool wzMainScreenSetup(int antialiasing, bool fullscreen, bool vsync, bool highDPI)
{
	debug(LOG_MAIN, "Qt initialization");
	//QGL::setPreferredPaintEngine(QPaintEngine::OpenGL); // Workaround for incorrect text rendering on many platforms, doesn't exist in Qt5…

	// Register custom WZ app event type
	wzAppQEventType = QEvent::registerEventType();

	// Setting up OpenGL
	QGLFormat format;
	format.setDoubleBuffer(true);
	//format.setAlpha(true);
	int w = pie_GetVideoBufferWidth();
	int h = pie_GetVideoBufferHeight();

	if (antialiasing)
	{
		format.setSampleBuffers(true);
		format.setSamples(antialiasing);
	}
	mainWindowPtr = new WzMainWindow(QSize(w, h), format, wzAppQEventType.load());
	WzMainWindow &mainwindow = *(mainWindowPtr.load());
	mainwindow.setMinimumResolution(QSize(800, 600));
	if (!mainwindow.context()->isValid())
	{
		QMessageBox::critical(nullptr, "Oops!", "Warzone2100 failed to create an OpenGL context. This probably means that your graphics drivers are out of date. Try updating them!");
		return false;
	}

	screenWidth = w;
	screenHeight = h;
	if (fullscreen)
	{
		mainwindow.resize(w, h);
		mainwindow.showFullScreen();
		if (w > mainwindow.width())
		{
			w = mainwindow.width();
		}
		if (h > mainwindow.height())
		{
			h = mainwindow.height();
		}
		pie_SetVideoBufferWidth(w);
		pie_SetVideoBufferHeight(h);
	}
	else
	{
		mainwindow.show();
		mainwindow.setMinimumSize(w, h);
		mainwindow.setMaximumSize(w, h);
	}

	mainwindow.setSwapInterval(vsync);
	mainwindow.setReadyToPaint();

	return true;
}
QGLFormat       getFormat()
{
    QGLFormat   glFormat;

    glFormat.setVersion( 3, 2 );
    glFormat.setProfile( QGLFormat::CoreProfile ); // Requires >= Qt-4.8.0
    glFormat.setSampleBuffers( true );

    return (glFormat);
}
Ejemplo n.º 28
0
Viewer::Viewer(QWidget* parent)
  : QGLViewer(CGAL::Qt::createOpenGLContext(),parent), wireframe(false), flatShading(true),
    edges(true), vertices(true), m_displayListCreated(false)
{
  QGLFormat newFormat = this->format();
  newFormat.setSampleBuffers(true);
  newFormat.setSamples(16);
  this->setFormat(newFormat);
   are_buffers_initialized = false;
}
Ejemplo n.º 29
0
bool wzMain2()
{
	debug(LOG_MAIN, "Qt initialization");
	QGL::setPreferredPaintEngine(QPaintEngine::OpenGL); // Workaround for incorrect text rendering on nany platforms.

	// Setting up OpenGL
	QGLFormat format;
	format.setDoubleBuffer(true);
	format.setAlpha(true);
	int w = pie_GetVideoBufferWidth();
	int h = pie_GetVideoBufferHeight();

	if (war_getFSAA())
	{
		format.setSampleBuffers(true);
		format.setSamples(war_getFSAA());
	}
	mainWindowPtr = new WzMainWindow(QSize(w, h), format);
	WzMainWindow &mainwindow = *mainWindowPtr;
	mainwindow.setMinimumResolution(QSize(800, 600));
	if (!mainwindow.context()->isValid())
	{
		QMessageBox::critical(NULL, "Oops!", "Warzone2100 failed to create an OpenGL context. This probably means that your graphics drivers are out of date. Try updating them!");
		return false;
	}

	screenWidth = w;
	screenHeight = h;
	if (war_getFullscreen())
	{
		mainwindow.resize(w,h);
		mainwindow.showFullScreen();
		if(w>mainwindow.width()) {
			w = mainwindow.width();
		}
		if(h>mainwindow.height()) {
			h = mainwindow.height();
		}
		pie_SetVideoBufferWidth(w);
		pie_SetVideoBufferHeight(h);
	}
	else
	{
		mainwindow.show();
		mainwindow.setMinimumSize(w, h);
		mainwindow.setMaximumSize(w, h);
	}

	mainwindow.setSwapInterval(war_GetVsync());
	war_SetVsync(mainwindow.swapInterval() > 0);

	mainwindow.setReadyToPaint();

	return true;
}
Ejemplo n.º 30
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);
    }