Esempio n. 1
0
int main(int argc, char *argv[])
{
  qInstallMessageHandler(&handleMessageOutput);
  QApplication app(argc, argv);
  std::vector<QSurfaceFormat> formats;

#if !defined(QT_OPENGL_ES)
  {
    QSurfaceFormat glFormat;
    glFormat.setRenderableType(QSurfaceFormat::OpenGL);
    glFormat.setProfile(QSurfaceFormat::CoreProfile);
    glFormat.setVersion(4,3);
    formats.push_back(glFormat);
  }
#endif

#if defined(QT_OPENGL_ES)
  {
    QSurfaceFormat glesFormat;
    glesFormat.setRenderableType(QSurfaceFormat::OpenGLES);
    glesFormat.setProfile(QSurfaceFormat::CoreProfile);
    glesFormat.setVersion(3,0);
    formats.push_back(glesFormat);
  }
#endif

  // Find out which version we support
  QSurfaceFormat *format = getFirstSupported(formats);
  if (format == NULL)
  {
    QMessageBox::critical(0, "Critical Error", "No valid supported version of OpenGL found on device!");
    exit(-1);
  }

#ifdef    GL_DEBUG
  format->setOption(QSurfaceFormat::DebugContext);
#endif // GL_DEBUG
  format->setDepthBufferSize(0);

  // Set the widget up
  MainWidget *widget = new MainWidget;
  widget->setFormat(*format);

  // Set the window up
  MainWindow *window = new MainWindow;
  window->show();

  return app.exec();
}
Esempio n. 2
0
void RunTestInOpenGLOffscreenEnvironment(char const * testName, bool apiOpenGLES3,
                                         TestFunction const & fn)
{
  std::vector<char> buf(strlen(testName) + 1);
  strcpy(buf.data(), testName);
  char * raw = buf.data();

  int argc = 1;
  QApplication app(argc, &raw);

  QSurfaceFormat fmt;
  fmt.setAlphaBufferSize(8);
  fmt.setBlueBufferSize(8);
  fmt.setGreenBufferSize(8);
  fmt.setRedBufferSize(8);
  fmt.setStencilBufferSize(0);
  fmt.setSamples(0);
  fmt.setSwapBehavior(QSurfaceFormat::DoubleBuffer);
  fmt.setSwapInterval(1);
  fmt.setDepthBufferSize(16);
  if (apiOpenGLES3)
  {
    fmt.setProfile(QSurfaceFormat::CoreProfile);
    fmt.setVersion(3, 2);
  }
  else
  {
    fmt.setProfile(QSurfaceFormat::CompatibilityProfile);
    fmt.setVersion(2, 1);
  }

  auto surface = std::make_unique<QOffscreenSurface>();
  surface->setFormat(fmt);
  surface->create();

  auto context = std::make_unique<QOpenGLContext>();
  context->setFormat(fmt);
  context->create();
  context->makeCurrent(surface.get());

  if (fn)
    fn(apiOpenGLES3);

  context->doneCurrent();
  surface->destroy();

  QTimer::singleShot(0, &app, SLOT(quit()));
  app.exec();
}
Esempio n. 3
0
OpenGLWidget::OpenGLWidget(MainWindow* mainWindow)
    : QOpenGLWidget{mainWindow}
    , m_axisLegendScene{mainWindow->app()}
    , m_width{0}
    , m_height{0}
    , m_currentLocation{}
    , m_previousLocation{}
{
    this->setFocusPolicy(Qt::StrongFocus);

    m_contextMenu = new QMenu(this);

    QMenu* createMenu = m_contextMenu->addMenu("Create");
    createMenu->addAction(tr("Box"), this, SLOT(createBox()));
    createMenu->addAction(tr("Cylinder"), this, SLOT(createCylinder()));
    createMenu->addAction(tr("Cone"), this, SLOT(createCone()));
    createMenu->addAction(tr("Sphere"), this, SLOT(createSphere()));

    m_contextMenu->addAction(tr("Import Mesh"), this, SLOT(importMesh()));

    QSurfaceFormat format = this->format();
    format.setVersion(kOpenGLMajorVersion, kOpenGLMinorVersion);
    format.setProfile(QSurfaceFormat::CoreProfile);
    format.setDepthBufferSize(32);
    format.setSwapBehavior(QSurfaceFormat::DoubleBuffer);

    LOG(INFO) << fmt::format("Setting format with OpenGL version {}.{}", kOpenGLMajorVersion, kOpenGLMinorVersion);
    this->setFormat(format);
}
Esempio n. 4
0
MainWindow::MainWindow
(
    QWidget * parent
):
    QMainWindow(parent),
    m_ui(new Ui::MainWindow)
{
    m_ui->setupUi(this);

  // Setup OpenGL context format
    QSurfaceFormat format;
#ifdef __APPLE__
    // Get OpenGL 3.2/4.1 core context
    format.setVersion(3, 2);
    format.setProfile(QSurfaceFormat::CoreProfile);
#else
    // Get newest available compatibility context
#endif
    format.setDepthBufferSize(16);

    // Create OpenGL context and window
    m_canvas.reset(new gloperate_qt::QtOpenGLWindowBase(format));

    // Create widget container
    setCentralWidget(QWidget::createWindowContainer(m_canvas.get()));
    centralWidget()->setFocusPolicy(Qt::StrongFocus);
}
Esempio n. 5
0
int main(int argc, char *argv[])
{
    QApplication app(argc, argv);
    QApplication::setApplicationName("Editor");
    QApplication::setApplicationVersion("1.0");
#if C3_OS == C3_OS_WINDOWS_NT
	//Windows native theme looks so ugly
	app.setStyle("fusion");
#endif

    QCommandLineParser parser;
    parser.setApplicationDescription("The Editor");
    parser.addHelpOption();
    parser.addVersionOption();
    QCommandLineOption dataDirOption("root",
                                     "Root directory location.\nThis will override ENGINE_ROOT.",
                                     "path");
    parser.addOption(dataDirOption);
    parser.process(app);

    QProcessEnvironment env = QProcessEnvironment::systemEnvironment();
    QString absPath;
    if(!parser.value(dataDirOption).isEmpty())
    {
        absPath = parser.value(dataDirOption);
    }
    else if(env.contains("ENGINE_ROOT"))
        absPath = env.value("ENGINE_ROOT");
    else
        absPath = ".";
    QFileInfo dirInfo(absPath);
    if(!dirInfo.exists() || !dirInfo.isDir() || !QFileInfo::exists(absPath + "/Data"))
    {
        const char* msg = "Invalid root directory!";
        QMessageBox::critical(nullptr, app.applicationName(), msg);
        throw msg;
    }
    absPath = dirInfo.canonicalFilePath();
    EngineLoader.SetRootDirectory(absPath.toUtf8().constData());

    c3::RC.Loader = &EngineLoader;
    c3::RC.Loader->InitEngine();

    c3::FEditor EditorController;
    c3::RC.Editor = &EditorController;

    QSurfaceFormat format;
    format.setVersion(4, 5);
    format.setProfile(QSurfaceFormat::CoreProfile);
    format.setDepthBufferSize(24);
    format.setStencilBufferSize(8);
    QSurfaceFormat::setDefaultFormat(format);

    MainWindow mainWindow;
	c3::FLogDisplay* LogDisplay = static_cast<c3::FLogDisplay*>(EditorController.GetLogDisplay());
    QObject::connect(LogDisplay, &c3::FLogDisplay::LogRefreshed,
                     &mainWindow, &MainWindow::OnLogChanged);
	mainWindow.showMaximized();
    app.exec();
}
Esempio n. 6
0
int main(int argc, char *argv[])
{
    qputenv("PATH", qgetenv("PATH") + ":/usr/local/bin:/usr/bin");

    QApplication a(argc, argv);

    QSplashScreen s(QPixmap(":/application/splash"), Qt::WindowStaysOnTopHint);
    s.show();

    QApplication::setOrganizationName("Regulomics");
    QApplication::setApplicationName("QChromosome 4D Studio");
    QApplication::setWindowIcon(QIcon(":/application/icon"));

    QSurfaceFormat format;
    format.setDepthBufferSize(24);
    format.setVersion(4, 1);
    format.setProfile(QSurfaceFormat::CoreProfile);
    QSurfaceFormat::setDefaultFormat(format);

    QFontDatabase::addApplicationFont(":/fonts/Roboto-Regular");
    QFontDatabase::addApplicationFont(":/fonts/Roboto-Bold");
    QFontDatabase::addApplicationFont(":/fonts/RobotoMono-Regular");

    MainWindow w(a.arguments().mid(1));

    a.installEventFilter(&w);

    w.showMaximized();

    s.finish(&w);

    return a.exec();
}
Esempio n. 7
0
int main(int argc, char* argv[])
{
   QGuiApplication app(argc,argv);
   qmlRegisterType<Connector>("Connector", 1, 0, "Connector");
   app.setOrganizationName("QtProject");\
   app.setOrganizationDomain("qt-project.org");\
   app.setApplicationName(QFileInfo(app.applicationFilePath()).baseName());\
   QQuickView view;\
   if (qgetenv("QT_QUICK_CORE_PROFILE").toInt()) {\
       QSurfaceFormat f = view.format();\
       f.setProfile(QSurfaceFormat::CoreProfile);\
       f.setVersion(4, 4);\
       view.setFormat(f);\
   }\
   view.connect(view.engine(), SIGNAL(quit()), &app, SLOT(quit()));\
   new QQmlFileSelector(view.engine(), &view);\
   view.setSource(QUrl("qrc:///demos/tweetsearch/tweetsearch.qml")); \
   view.setResizeMode(QQuickView::SizeRootObjectToView);\
   if (QGuiApplication::platformName() == QLatin1String("qnx") || \
         QGuiApplication::platformName() == QLatin1String("eglfs")) {\
       view.showFullScreen();\
   } else {\
       view.show();\
   }\
   return app.exec();\
}
Esempio n. 8
0
int main(int argc, char** argv) try {
    QApplication app(argc, argv);
    app.setApplicationDisplayName("Interactive OpenBC sim. interface");
    QSurfaceFormat fmt;
    fmt.setDepthBufferSize(24);
    //if (QCoreApplication::arguments().contains(QStringLiteral("--multisample"))) {
        std::cout << "Using multisample" << std::endl;;
        fmt.setSamples(4);
    //}
    // Hard-coded to use the core profile.
    fmt.setVersion(3, 2);
    fmt.setProfile(QSurfaceFormat::CoreProfile);
    QSurfaceFormat::setDefaultFormat(fmt);
    
    MainWindow mainWindow;
    mainWindow.resize(mainWindow.sizeHint());
    int desktopArea = QApplication::desktop()->width()*QApplication::desktop()->height();
    int widgetArea = mainWindow.width()*mainWindow.height();
    if (((float)widgetArea / (float)desktopArea) < 0.75f) {
        mainWindow.show();
    } else {
        mainWindow.showMaximized();
    }
    return app.exec();
    
} catch (std::exception& e) {
    std::cout << "Caught exception: " << e.what() << std::endl;
} catch (...) {
    std::cout << "Caught unknown exception.\n";
}
Esempio n. 9
0
EffectsManager::EffectsManager(QObject *parent) : QObject(parent), QQuickImageProvider(QQuickImageProvider::Image)
{

    if (qgetenv("QT_QUICK_CORE_PROFILE").toInt()) {\
        QSurfaceFormat f = view.format();\
        f.setProfile(QSurfaceFormat::CoreProfile);\
        f.setVersion(4, 4);\
        view.setFormat(f);\
    }\
    //  view.connect(view.engine(), SIGNAL(quit()), &app, SLOT(quit()));
    new QQmlFileSelector(view.engine(), &view);
    view.engine()->rootContext()->setContextProperty("effectsControll", this);
    //view.engine()->addImageProvider("loader", cloneImg);
    view.setSource(QUrl("qrc:/mainEffectWindow.qml")); \
    view.setResizeMode(QQuickView::SizeRootObjectToView);
    //  view.setPersistentOpenGLContext(true);
    view.setColor("transparent");

    //addEffect("first",100,100);
    /* QStringList dataList;
        dataList.append("Item 1");
        QQmlContext *ctxt = view.rootContext();
        ctxt->setContextProperty("myModel", QVariant::fromValue(dataList));*/


    //viewsetFont(QFont("Segoe Script"));
/*
    QSize t_size(300,300);
    view.setMaximumSize(t_size);
    view.setMinimumSize(t_size);
*/
}
Esempio n. 10
0
int main(int argc, char *argv[])
{

    QApplication a(argc, argv);

    // Set OpenGL 3.2 and, optionally, 4-sample multisampling
    QSurfaceFormat format;
    format.setVersion(3, 2);
    format.setOption(QSurfaceFormat::DeprecatedFunctions, false);
    format.setProfile(QSurfaceFormat::CoreProfile);
    //format.setSamples(4);  // Uncomment for nice antialiasing. Not always supported.

    /*** AUTOMATIC TESTING: DO NOT MODIFY ***/
    /*** Check whether automatic testing is enabled */
    /***/ if (qgetenv("CIS277_AUTOTESTING") != nullptr) format.setSamples(0);

    QSurfaceFormat::setDefaultFormat(format);
    debugFormatVersion();

    MainWindow w;
    w.show();

    w.sendItems();

    return a.exec();
}
Esempio n. 11
0
int main(int argc, char *argv[])
{
    QApplication app(argc, argv);

    QSurfaceFormat fmt;
    fmt.setDepthBufferSize(24);
    if (QCoreApplication::arguments().contains(QStringLiteral("--multisample")))
        fmt.setSamples(4);
    if (QCoreApplication::arguments().contains(QStringLiteral("--coreprofile"))) {
        fmt.setVersion(3, 2);
        fmt.setProfile(QSurfaceFormat::CoreProfile);
    }
    QSurfaceFormat::setDefaultFormat(fmt);

    MainWindow mainWindow;
    mainWindow.resize(mainWindow.sizeHint());
    int desktopArea = QApplication::desktop()->width() *
                     QApplication::desktop()->height();
    int widgetArea = mainWindow.width() * mainWindow.height();
    if (((float)widgetArea / (float)desktopArea) < 0.75f)
        mainWindow.show();
    else
        mainWindow.showMaximized();
    return app.exec();
}
Esempio n. 12
0
File: main.cpp Progetto: JJ/ARehab
int main(int argc, char *argv[])
{
    QApplication app(argc, argv);

    Q_INIT_RESOURCE(ARehab_vTerapeuta);

    QSurfaceFormat format;
    format.setVersion(4, 3);
    format.setProfile(QSurfaceFormat::CoreProfile);
    format.setOption(QSurfaceFormat::DebugContext);
    format.setRenderableType(QSurfaceFormat::OpenGL);
    format.setDepthBufferSize(24);
    format.setStencilBufferSize(8);
    format.setSamples(4);
    format.setSwapInterval(0); //Disable VSync
    QSurfaceFormat::setDefaultFormat(format);

    ARehabGUIDesigner::ARehabMainWindow w;

    QFile styleFile(":/styles/main.qss");
    styleFile.open(QFile::ReadOnly);
    app.setStyleSheet(QLatin1String(styleFile.readAll()));
    styleFile.close();

    w.show();
    return (app.exec());
}
Esempio n. 13
0
void Viewer::setupCanvas()
{
    QSurfaceFormat format;

    format.setVersion(3, 2);
    format.setProfile(QSurfaceFormat::CoreProfile);
    format.setDepthBufferSize(16);

    // Create OpenGL context and window
    m_canvas.reset(new gloperate_qt::QtOpenGLWindow(*m_resourceManager, format));

    // Create widget container
    setCentralWidget(QWidget::createWindowContainer(m_canvas.get()));
    centralWidget()->setFocusPolicy(Qt::StrongFocus);

    // Setup event provider to translate Qt messages into gloperate events
    gloperate_qt::QtKeyEventProvider * keyProvider = new gloperate_qt::QtKeyEventProvider();
    keyProvider->setParent(m_canvas.get());
    gloperate_qt::QtMouseEventProvider * mouseProvider = new gloperate_qt::QtMouseEventProvider();
    mouseProvider->setParent(m_canvas.get());
    gloperate_qt::QtWheelEventProvider * wheelProvider = new gloperate_qt::QtWheelEventProvider();
    wheelProvider->setParent(m_canvas.get());

    m_canvas->installEventFilter(keyProvider);
    m_canvas->installEventFilter(mouseProvider);
    m_canvas->installEventFilter(wheelProvider);

    // Create input mapping for gloperate interaction techniques
    m_mapping.reset(new QtViewerMapping(m_canvas.get()));
    m_mapping->addProvider(keyProvider);
    m_mapping->addProvider(mouseProvider);
    m_mapping->addProvider(wheelProvider);
}
Esempio n. 14
0
int main(int argc, char* argv[])
{
    QApplication app(argc, argv);
    QVRManager manager(argc, argv);

    /* Load the model file */
    if (argc != 2) {
        std::cerr << argv[0] << ": requires model filename argument." << std::endl;
        return 1;
    }
    osg::ref_ptr<osgDB::ReaderWriter::Options> options = new osgDB::ReaderWriter::Options();
    options->setOptionString("noRotation");
    osg::ref_ptr<osg::Node> model = osgDB::readNodeFile(argv[1], options);
    if (!model) {
        std::cerr << argv[0] << ": no data loaded." << std::endl;
        return 1;
    }

    /* First set the default surface format that all windows will use */
    QSurfaceFormat format;
    format.setProfile(QSurfaceFormat::CompatibilityProfile); // OSG cannot handle core profiles
    format.setVersion(3, 3);
    QSurfaceFormat::setDefaultFormat(format);

    /* Then start QVR with your app */
    QVROSGViewer qvrapp(model);
    if (!manager.init(&qvrapp)) {
        std::cerr << "Cannot initialize QVR manager" << std::endl;
        return 1;
    }

    /* Enter the standard Qt loop */
    return app.exec();
}
Esempio n. 15
0
void GLViewer::setup()
{
    QSurfaceFormat format;

    format.setVersion(3, 2);
    format.setProfile(QSurfaceFormat::CoreProfile);

    format.setDepthBufferSize(16);

    m_canvas = new Canvas(format);
    m_canvas->setContinuousRepaint(true, 0);
    m_canvas->setSwapInterval(Canvas::VerticalSyncronization);

    m_canvas->setPainter(m_painter);

    QWidget *widget = QWidget::createWindowContainer(m_canvas);
    widget->setMinimumSize(1, 1);
    widget->setAutoFillBackground(false); // Important for overdraw, not occluding the scene.
    widget->setFocusPolicy(Qt::TabFocus);
    widget->setParent(this);

    QHBoxLayout *layout = new QHBoxLayout;
    layout->setContentsMargins(0, 0, 0, 0);
    layout->addWidget(widget);
    setLayout(layout);

    show();
}
Esempio n. 16
0
OGLViewer::OGLViewer(QWidget *parent)
	: QOpenGLWidget(parent), mTimeCount(0), mFps(30)
	, mSelectMode(OBJECT_SELECT)
	, mViewCamera(new PerspectiveCamera(Point3f(10, 6, 11),
                                     Point3f(0, 0, 0),
                                     Vector3f(0, 1, 0),
                                     width() / float(height())))
	, box_mesh(new TriangleMesh("../../scene/obj/cube_large.obj"))
	, model_mesh(new TriangleMesh("../../scene/obj/monkey.obj"))
{
	// Set surface format for current widget
	QSurfaceFormat format;
	format.setDepthBufferSize(32);
	format.setStencilBufferSize(8);
	format.setSamples(4);
	format.setVersion(4, 5);
	format.setProfile(QSurfaceFormat::CoreProfile);
	this->setFormat(format);

	// Link timer trigger
	/*process_time.start();
	QTimer *timer = new QTimer(this);
	//timer->setSingleShot(false);
	connect(timer, SIGNAL(timeout()), this, SLOT(update()));
	timer->start(0);*/
}
Esempio n. 17
0
OGLViewer::OGLViewer(QWidget *parent)
	: QOpenGLWidget(parent), tcount(0), fps(30)
	, simp_lv(1)
	, m_selectMode(OBJECT_SELECT)
{
	// Set surface format for current widget
	QSurfaceFormat format;
	format.setDepthBufferSize(32);
	format.setStencilBufferSize(8);
	format.setVersion(4, 5);
	format.setProfile(QSurfaceFormat::CoreProfile);
	this->setFormat(format);

	// Read obj file
	//box_mesh = new Mesh("../../scene/obj/cube_large.obj");
	//model_mesh = new Mesh("../../scene/obj/monkey.obj");
#ifdef _DEBUG
	hds_box = new HDS_Mesh("../../scene/obj/frog.obj");
#else
	hds_box = new HDS_Mesh("quad_cube.obj");
#endif
	//hds_box->reIndexing();
	//hds_box->validate();
	simp_mesh = new Simplification(simp_lv, hds_box);

	resetCamera();
}
Esempio n. 18
0
void KisOpenGL::initialize()
{
#ifdef HAVE_OPENGL
    dbgUI << "OpenGL: initializing";

    KisConfig cfg;

    QSurfaceFormat format;
    format.setProfile(QSurfaceFormat::CompatibilityProfile);
    format.setOptions(QSurfaceFormat::DeprecatedFunctions);
    format.setDepthBufferSize(24);
    format.setStencilBufferSize(8);
    format.setVersion(3, 2);
    // if (cfg.disableDoubleBuffering()) {
    if (false) {
        format.setSwapBehavior(QSurfaceFormat::SingleBuffer);
    }
    else {
        format.setSwapBehavior(QSurfaceFormat::DoubleBuffer);
    }
    format.setSwapInterval(0); // Disable vertical refresh syncing
    QSurfaceFormat::setDefaultFormat(format);

#endif
}
Esempio n. 19
0
void ccApplication::init()
{
	//See http://doc.qt.io/qt-5/qopenglwidget.html#opengl-function-calls-headers-and-qopenglfunctions
	/** Calling QSurfaceFormat::setDefaultFormat() before constructing the QApplication instance is mandatory
		on some platforms (for example, OS X) when an OpenGL core profile context is requested. This is to
		ensure that resource sharing between contexts stays functional as all internal contexts are created
		using the correct version and profile.
	**/
	{
		QSurfaceFormat format = QSurfaceFormat::defaultFormat();
		
		format.setSwapBehavior( QSurfaceFormat::DoubleBuffer );
		format.setStencilBufferSize( 0 );
		
#ifdef CC_GL_WINDOW_USE_QWINDOW
		format.setStereo( true );
#endif
		
#ifdef Q_OS_MAC
		format.setVersion( 2, 1 );	// must be 2.1 - see ccGLWindow::functions()
		format.setProfile( QSurfaceFormat::CoreProfile );
#endif
		
#ifdef QT_DEBUG
		format.setOption( QSurfaceFormat::DebugContext, true );
#endif
		
		QSurfaceFormat::setDefaultFormat( format );
	}
	
	// The 'AA_ShareOpenGLContexts' attribute must be defined BEFORE the creation of the Q(Gui)Application
	// DGM: this is mandatory to enable exclusive full screen for ccGLWidget (at least on Windows)
	QCoreApplication::setAttribute( Qt::AA_ShareOpenGLContexts );
}
OGLViewer::OGLViewer(QWidget *parent)
	: QOpenGLWidget(parent), tcount(0)
	, fps(30), timestep(1.0 / fps), isSim(false)
{
	// Set surface format for current widget
	QSurfaceFormat format;
	format.setDepthBufferSize(32);
	format.setStencilBufferSize(8);
	format.setVersion(4, 5);
	format.setProfile(QSurfaceFormat::CoreProfile);
	this->setFormat(format);

	// Link timer trigger
	process_time.start();
	QTimer *timer = new QTimer(this);
	/*timer->setSingleShot(false);*/
	connect(timer, SIGNAL(timeout()), this, SLOT(update()));
	timer->start(0);

	// Read obj file
#ifdef _DEBUG
	box_mesh = new Mesh("../../scene/obj/cube_huge.obj");
	poly_mesh = new Mesh("../../scene/obj/bunny_simple.obj");
	poly_bound = new Mesh("../../scene/obj/bunny_bound.obj");
#else
	box_mesh = new Mesh("cube_large.obj");
	poly_mesh = new Mesh("bunny_simple.obj");
	poly_bound = new Mesh("bunny_bound.obj");
#endif // _DEBUG
	poly_bound->refine(triangleList);
	mytree = new KdTreeAccel(triangleList);

	texW = sparkTex.getWidth();
	texH = sparkTex.getHeight();
	sparkTex.getPixelsRGBA(tex_pixels);

	// Initialize particle generators
	//Point3D newpos(0.0, 0.0, 0.0), vel(0.3, 1.0, 1.0), vel_var(0.3, 0.3, 0.3);
	ParticleGenerator* pg = new ParticleGenerator(
		3500, 1000, 20, timestep, 3, 0.6,
		2.0, 1.2,
		Point3D(0.0, 5.0, 0.0),
		Vector3D(0, -10, 0), Vector3D(1, 0, 0),
		ParticleGenerator::CONCENTRIC_DISK, 0.5);
	Vector3D* gravity = new Vector3D(0.0, -9.8, 0.0);
	Vector3D* wind = new Vector3D(0, 0.0, 0.0);
	pg->addForce(gravity);
	pg->addForce(wind);
	pgs.push_back(pg);
	pg->exportVBO(ptc_size, ptc_verts, ptc_vels, ptc_life, ptc_alive, true);
	pg->addCollision(mytree);
	

	resetCamera();

	// Initialize transform matrix
	matrix.setIdentity();// setRotation(20, 0, 0);
	matrix.exportVBO(model_mat);
}
int main(int argc, char* argv[]) {
    // read the header
    const auto header = sepia::read_header(sepia::filename_to_ifstream(filename));

    // create the Qt Application
    QGuiApplication app(argc, argv);

    // register Chameleon types
    qmlRegisterType<chameleon::background_cleaner>("Chameleon", 1, 0, "BackgroundCleaner");
    qmlRegisterType<chameleon::dvs_display>("Chameleon", 1, 0, "DvsDisplay");
    qmlRegisterType<chameleon::flow_display>("Chameleon", 1, 0, "FlowDisplay");

    // pass the header properties to qml
    QQmlApplicationEngine application_engine;
    application_engine.rootContext()->setContextProperty("header_width", header.width);
    application_engine.rootContext()->setContextProperty("header_height", header.height);

    // load the view and setup the window properties for OpenGL renderring
    application_engine.loadData(
#include "optical_flow.qml"
    );
    auto window = qobject_cast<QQuickWindow*>(application_engine.rootObjects().first());
    {
        QSurfaceFormat format;
        format.setDepthBufferSize(24);
        format.setStencilBufferSize(8);
        format.setVersion(3, 3);
        format.setProfile(QSurfaceFormat::CoreProfile);
        window->setFormat(format);
    }

    // retrieve pointers to the displays generated by qml
    auto dvs_display = window->findChild<chameleon::dvs_display*>("dvs_display");
    auto flow_display = window->findChild<chameleon::flow_display*>("flow_display");

    // create the event handling pipeline
    auto observable = sepia::make_observable<sepia::type::dvs>(
        sepia::filename_to_ifstream(filename),
        tarsier::make_replicate<sepia::dvs_event>(
            [&](sepia::dvs_event dvs_event) { dvs_display->push(dvs_event); },
            sepia::make_split<sepia::type::dvs>(
                tarsier::make_compute_flow<sepia::simple_event, flow_event>(
                    header.width,
                    header.height,
                    3,     // spatial window's radius
                    10000, // temporal window
                    8,     // minimum number of events in the spatio-temporal window required to trigger a flow event
                    [&](sepia::simple_event simple_event, float vx, float vy) -> flow_event {
                        return {simple_event.t, simple_event.x, simple_event.y, vx, vy};
                    },
                    [&](flow_event flow_event) { flow_display->push(flow_event); }),
                [](sepia::simple_event) {})),
        [](std::exception_ptr) {},
        []() { return true; });

    // run the Qt Application
    return app.exec();
}
Esempio n. 22
0
int main(int argc, char * argv[])
{
    QApplication app(argc, argv);

    ResourceManager resourceManager;
    resourceManager.addLoader(new QtTextureLoader());
    resourceManager.addStorer(new QtTextureStorer());

    // Initialize plugin manager
    PluginManager::init(QCoreApplication::applicationFilePath().toStdString());

    // Load example plugins
    PluginManager pluginManager;
#ifdef NDEBUG
    pluginManager.addPath("plugins");
#else
    pluginManager.addPath("plugins/debug");
#endif
    pluginManager.scan("painters");

    // Choose a painter
	std::string name = (argc > 1) ? argv[1] : "CubeScape";
    std::cout << "Trying to create painter '" << name << "'\n";

    gloperate::Painter * painter = nullptr;
    Plugin * plugin = pluginManager.plugin(name);

	if (!plugin)
	{
		globjects::fatal() << "Plugin '" << name << "' not found. Listing plugins found:";
		pluginManager.printPlugins();

		return 1;
	}

	painter = plugin->createPainter(resourceManager);

    // Create OpenGL window
    QSurfaceFormat format;
    format.setVersion(3, 2);
    format.setProfile(QSurfaceFormat::CoreProfile);
    format.setDepthBufferSize(24);

	QtOpenGLWindow * window = new QtOpenGLWindow(resourceManager, format);
	window->setPainter(painter);

	QRect rect = QApplication::desktop()->screenGeometry(); // used to center the mainwindow on desktop

    // Create main window
    QMainWindow mainWindow;
	mainWindow.setGeometry((rect.width() - 1280) / 2, (rect.height() - 720) / 2, 1280, 720);
    mainWindow.setCentralWidget(QWidget::createWindowContainer(window));
    mainWindow.centralWidget()->setFocusPolicy(Qt::StrongFocus);

    mainWindow.show();

    return app.exec();
}
Esempio n. 23
0
File: widget.cpp Progetto: RSATom/Qt
void Widget::start()
{
    QSurfaceFormat fmt;

    int idx = m_version->currentIndex();
    if (idx < 0)
        return;
    fmt.setVersion(versions[idx].major, versions[idx].minor);

    for (size_t i = 0; i < sizeof(profiles) / sizeof(Profile); ++i)
        if (static_cast<QRadioButton *>(m_profiles->itemAt(int(i))->widget())->isChecked()) {
            fmt.setProfile(profiles[i].profile);
            break;
        }

    bool forceGLSL110 = false;
    for (size_t i = 0; i < sizeof(options) / sizeof(Option); ++i)
        if (static_cast<QCheckBox *>(m_options->itemAt(int(i))->widget())->isChecked()) {
            if (options[i].option)
                fmt.setOption(options[i].option);
            else if (i == 3)
                forceGLSL110 = true;
        }

    for (size_t i = 0; i < sizeof(renderables) / sizeof(Renderable); ++i)
        if (static_cast<QRadioButton *>(m_renderables->itemAt(int(i))->widget())->isChecked()) {
            fmt.setRenderableType(renderables[i].renderable);
            break;
        }

    // The example rendering will need a depth buffer.
    fmt.setDepthBufferSize(16);

    m_output->clear();
    m_extensions->clear();
    qDebug() << "Requesting surface format" << fmt;

    m_renderWindowLayout->removeWidget(m_renderWindowContainer);
    delete m_renderWindowContainer;

    RenderWindow *renderWindow = new RenderWindow(fmt);
    if (!renderWindow->context()) {
        m_output->append(tr("Failed to create context"));
        delete renderWindow;
        m_renderWindowContainer = new QWidget;
        addRenderWindow();
        return;
    }
    m_surface = renderWindow;

    renderWindow->setForceGLSL110(forceGLSL110);
    connect(renderWindow, &RenderWindow::ready, this, &Widget::renderWindowReady);
    connect(renderWindow, &RenderWindow::error, this, &Widget::renderWindowError);

    m_renderWindowContainer = QWidget::createWindowContainer(renderWindow);
    addRenderWindow();
}
Esempio n. 24
0
int main(int argc, char ** argv)
{
	ShowWindow(GetConsoleWindow(), SW_HIDE);

	QApplication app(argc, argv);

	QSurfaceFormat format;
	format.setDepthBufferSize(4);
	format.setSamples(24);
	format.setVersion(4, 4);
	format.setRenderableType(QSurfaceFormat::OpenGL);

	OpenGLWidget window;
	window.setFormat(format);
	window.resize(WINDOW_WIDTH, WINDOW_HEIGHT);

	selector = new ShaderFinder();

	pane = new CollapsiblePanelWidget(&window);
	pane->setStyleSheet("background-color:white");
	pane->setWidgetResizable(true);
	pane->setGeometry(0, 0, WINDOW_WIDTH / 5, WINDOW_HEIGHT);
	pane->duration = 500;
	pane->config(QRect(0, 0, WINDOW_WIDTH / 5, WINDOW_HEIGHT), QRect(-WINDOW_WIDTH / 5, 0, WINDOW_WIDTH / 5, WINDOW_HEIGHT));

	paneBox = new QGroupBox();
	pane->setWidget(paneBox);

	paneLayout = new QVBoxLayout();
	paneLayout->setSpacing(10);
	paneLayout->setAlignment(Qt::AlignTop);
	paneLayout->addWidget(selector);

	pane->widget()->setLayout(paneLayout);
	pane->show();

	anim = new CollapsiblePanelWidget(&window);
	anim->setStyleSheet("background-color:white");
	anim->setWidgetResizable(true);
	anim->setGeometry(WINDOW_WIDTH * 0.8, 0, WINDOW_WIDTH / 5, WINDOW_HEIGHT);
	anim->duration = 500;
	anim->config(QRect(WINDOW_WIDTH * 0.8, 0, WINDOW_WIDTH / 5, WINDOW_HEIGHT), QRect(WINDOW_WIDTH, 0, WINDOW_WIDTH / 5, WINDOW_HEIGHT));

	animBox = new QGroupBox();
	anim->setWidget(animBox);

	animLayout = new QVBoxLayout();
	animLayout->setSpacing(10);
	animLayout->setAlignment(Qt::AlignTop);

	anim->widget()->setLayout(animLayout);
	anim->show();

	window.show();

	return app.exec();
}
ReplayRenderWidget::ReplayRenderWidget(QWidget *parent) :
   QOpenGLWidget(parent)
{
   QSurfaceFormat format;
   format.setDepthBufferSize(24);
   format.setStencilBufferSize(8);
   format.setVersion(4, 5);
   format.setProfile(QSurfaceFormat::CompatibilityProfile);
   setFormat(format);
}
Esempio n. 26
0
Quiddiards::Quiddiards(QWidget* parent)
	: QOpenGLWidget(parent)
{
	/* init parameters */
	QSurfaceFormat format;
	format.setDepthBufferSize(24);
	format.setStencilBufferSize(8);
	format.setVersion(3, 2);
	QSurfaceFormat::setDefaultFormat(format);
	initUI();
}
Esempio n. 27
0
PreviewPane::PreviewPane(QWidget *parent) : QOpenGLWidget(parent),
    _initialized(false)
{
    setMouseTracking(true);

    QSurfaceFormat format;
    format.setDepthBufferSize(24);
    format.setVersion(3, 3);
    format.setProfile(QSurfaceFormat::CoreProfile);
    setFormat(format);
}
Esempio n. 28
0
int main(int argc, char* argv[]) {

	std::vector<std::string> filenames;
	if(argc >= 2) {
		for(int i = 1; i < argc; ++i) {
			filenames.emplace_back(argv[1]);
		}
	} else {
		throw std::runtime_error("This program expects 1 argument to an audio file");
	}
	
	std::vector<boost::filesystem::path> paths;
	std::copy(filenames.begin(), filenames.end(), std::back_inserter(paths));
	
	for(auto&& path : paths) {
		if(!boost::filesystem::exists(path) || !boost::filesystem::is_regular_file(path)) {
			throw std::runtime_error(path.string() + "Does not exists or isn't a file");
		}
	}
	
	std::vector<std::vector<Real>> samples;
	std::transform(paths.begin(), paths.end(), std::back_inserter(samples), get_audio_data);
	
	std::vector<EnergyChunks> chunks;
	std::transform(paths.begin(), paths.end(), std::back_inserter(chunks), get_energy_chunks);
	
	int retval = 0;
	{
		int x = 0;
		
		QSurfaceFormat fmt;
		fmt.setVersion(3, 3);
		fmt.setProfile(QSurfaceFormat::CoreProfile);
		QSurfaceFormat::setDefaultFormat(fmt);
		
		QApplication qapp(x, nullptr);

		auto gui = std::make_shared<VisualizerWindow>();

		gui->show();
		
		std::vector<WaveformData> data;
		for(auto&& tuple : zip_range(samples, chunks)) {
			data.emplace_back(boost::get<0>(tuple), boost::get<1>(tuple));
		}
		
		gui->visualize(data);
		
		retval = qapp.exec();
	}
	
	return retval;
}
Esempio n. 29
0
void KisOpenGL::setDefaultFormat()
{
    QSurfaceFormat format;
#ifdef Q_OS_MAC
//    format.setProfile(QSurfaceFormat::CoreProfile);
//    format.setOptions(QSurfaceFormat::DeprecatedFunctions);
    format.setVersion(2, 1);
#else
    format.setProfile(QSurfaceFormat::CompatibilityProfile);
    format.setOptions(QSurfaceFormat::DeprecatedFunctions);
    format.setVersion(3, 0);
#endif
    format.setDepthBufferSize(24);
    format.setStencilBufferSize(8);
    format.setSwapBehavior(QSurfaceFormat::DoubleBuffer);
    KisConfig cfg;
    if (cfg.disableVSync()) {
        format.setSwapInterval(0); // Disable vertical refresh syncing
    }
    QSurfaceFormat::setDefaultFormat(format);
}
Esempio n. 30
0
int main(int argc, char * argv[])
{
    int result = -1;

    Application app(argc, argv);

    QSurfaceFormat format;
#ifdef NO_OPENGL_320
    format.setVersion(3, 0);
#else
    format.setVersion(3, 2);
    format.setProfile(QSurfaceFormat::CoreProfile);
#endif
    format.setDepthBufferSize(24);

    QScopedPointer<Viewer> viewer(new Viewer(format));
    result = app.exec();

    return result;
    // ToDo: QWidget seems to take double ownership of canvas and frees it doubled
}