Exemplo n.º 1
0
int main( int argc, char **argv ) {
    QApplication a( argc, argv );
    OctreeNode n1;
    GLWidget *w = new GLWidget();
    GLData* g = w->addObject();
    
    GLData* rnd = w->addObject();
    RandomSource src( rnd );
    QObject::connect( w->timer, SIGNAL(timeout()), &src, SLOT(timeOutSlot()) );
    
    std::cout << " genVBO()\n";
    /*
    g->setTriangles(); 
    g->setPosition(1,0,-6);
    g->setUsageStaticDraw();
    g->addVertex(-1.0f,-1.0f, 0.0f,  1.0f,0.0f,0.0f, boost::bind(&OctreeNode::indexSwap, &n1, _1, _2) ); 
    g->addVertex( 1.0f,-1.0f, 0.0f,  0.0f,1.0f,0.0f, boost::bind(&OctreeNode::indexSwap, &n1, _1, _2) );
    g->addVertex( 0.0f, 1.0f, 0.0f,  0.0f,0.0f,1.0f, boost::bind(&OctreeNode::indexSwap, &n1, _1, _2) );
    g->addVertex( 1.0f, 1.0f, 0.0f,  1.0f,0.0f,1.0f, boost::bind(&OctreeNode::indexSwap, &n1, _1, _2) );
    g->addVertex( -1.0f, 1.0f, 0.0f,  1.0f,1.0f,1.0f, boost::bind(&OctreeNode::indexSwap, &n1, _1, _2) );
    g->addVertex( -2.0f, 0.0f, 0.0f,  1.0f,1.0f,1.0f, boost::bind(&OctreeNode::indexSwap, &n1, _1, _2) );
    std::vector<GLuint> poly(3);
    //poly.resize(3);
    poly[0]=0; poly[1]=1; poly[2]=2;
    g->addPolygon( poly );
    poly[0]=2; poly[1]=1; poly[2]=3;
    g->addPolygon( poly );
    poly[0]=0; poly[1]=2; poly[2]=4;
    g->addPolygon( poly );
    poly[0]=0; poly[1]=5; poly[2]=4;
    g->addPolygon( poly );
    g->print();
    //std::cout << "removePolygon()\n";
    //g.removePolygon(0);
    std::cout << "removeVertex(4)\n";
    g->removeVertex(4);
    g->print();
*/
    // now try a quad.
    OctreeNode n2;
    GLData* q = w->addObject();
    q->setQuads();
    q->setPosition(2,0,-6);
    q->setUsageStaticDraw(); 
    q->addVertex(-3.0f,0.0f,0.0f,0.0f,0.0f,1.0f, boost::bind(&OctreeNode::indexSwap, &n2, _1, _2));
    q->addVertex(-3.0f,1.0f,0.0f,0.0f,0.0f,1.0f, boost::bind(&OctreeNode::indexSwap, &n2, _1, _2));
    q->addVertex(-4.0f,1.0f,0.0f,0.0f,0.0f,1.0f, boost::bind(&OctreeNode::indexSwap, &n2, _1, _2));
    q->addVertex(-4.0f,0.0f,0.0f,0.0f,0.0f,1.0f, boost::bind(&OctreeNode::indexSwap, &n2, _1, _2));
    std::vector<GLuint> quad(4);
    quad[0]=0; quad[1]=1; quad[2]=2; quad[3]=3;
    q->addPolygon(quad);
    
    q->print();
    std::cout << "Q removeVertex(3)\n";
    //q->removeVertex(0);
    q->print();
    
    w->show();
    return a.exec();
}
Exemplo n.º 2
0
/* \x41\x41\x41\x41\x41\x41\x41 */
TempleWin::TempleWin(QWidget *parent)
    : QMainWindow(parent) {

    lang = new TempleLang();
    std::cout << "==========" << std::endl;
    //menu
    QAction *quit = new QAction("&Quit", this);

    QMenu *file;
    file = menuBar()->addMenu("&File");
    file->addAction(quit);

    connect(quit, SIGNAL(triggered()), qApp, SLOT(quit()));

    //toolbar
    QToolBar *tb = new QToolBar("TOOLBAR");

    TBar *tbw = new TBar(this, lang);
    tb->addWidget(tbw);
    tb->setMovable(false);
    addToolBar(Qt::RightToolBarArea, tb);

    GLWidget *widGl = new GLWidget(this, lang);
    widGl->show();
    widGl->resize(200,200);
    setCentralWidget(widGl);
}
Exemplo n.º 3
0
int main(int argc, char* argv[])
{
    QApplication a(argc, argv);
    GLWidget w;
    w.show();

    return a.exec();
}
Exemplo n.º 4
0
int main(int argc, char *argv[])
{
    QApplication a(argc, argv);
    GLWidget widget;
    widget.show();
    //widget.showFullScreen();

    return a.exec();
}
Exemplo n.º 5
0
int main(int argc, char *argv[])
{
    QApplication app(argc, argv);
    GLWidget mainwin;
    mainwin.resize(500,500);
    mainwin.show();

    return app.exec();
}
Exemplo n.º 6
0
int main(int argc, char *argv[]) {
    
    QApplication app(argc, argv);
    
    GLWidget window;
    window.resize(800,600);
    window.show();
    
    return app.exec();
}
Exemplo n.º 7
0
/** void QWidget::show()
 * bind/QWidget.h:31
 */
static int GLWidget_show(lua_State *L) {
  try {
    GLWidget *self = *((GLWidget **)dub_checksdata(L, 1, "mimas.GLWidget"));
    self->show();
    return 0;
  } catch (std::exception &e) {
    lua_pushfstring(L, "show: %s", e.what());
  } catch (...) {
    lua_pushfstring(L, "show: Unknown exception");
  }
  return dub_error(L);
}
Exemplo n.º 8
0
int main( int argc, char ** argv )
{
    QApplication a( argc, argv );

    QSurfaceFormat format;
    format.setDepthBufferSize(16);
    QSurfaceFormat::setDefaultFormat(format);

    // Two top-level windows with two QOpenGLWidget children in each.
    // The rendering for the four QOpenGLWidgets happens on four separate threads.

    GLWidget topLevelGlWidget;
    QPoint pos = QApplication::desktop()->availableGeometry(&topLevelGlWidget).topLeft() + QPoint(200, 200);
    topLevelGlWidget.setWindowTitle(QStringLiteral("Threaded QOpenGLWidget example top level"));
    topLevelGlWidget.resize(200, 200);
    topLevelGlWidget.move(pos);
    topLevelGlWidget.show();

    const QString glInfo = getGlString(topLevelGlWidget.context()->functions(), GL_VENDOR)
        + QLatin1Char('/') + getGlString(topLevelGlWidget.context()->functions(), GL_RENDERER);

    const bool supportsThreading = !glInfo.contains(QLatin1String("nouveau"), Qt::CaseInsensitive)
        && !glInfo.contains(QLatin1String("ANGLE"), Qt::CaseInsensitive)
        && !glInfo.contains(QLatin1String("llvmpipe"), Qt::CaseInsensitive);

    const QString toolTip = supportsThreading ? glInfo : glInfo + QStringLiteral("\ndoes not support threaded OpenGL.");
    topLevelGlWidget.setToolTip(toolTip);

    QScopedPointer<MainWindow> mw1;
    QScopedPointer<MainWindow> mw2;
    if (!QApplication::arguments().contains(QStringLiteral("--single"))) {
        if (supportsThreading) {
            pos += QPoint(100, 100);
            mw1.reset(new MainWindow);
            mw1->setToolTip(toolTip);
            mw1->move(pos);
            mw1->setWindowTitle(QStringLiteral("Threaded QOpenGLWidget example #1"));
            mw1->show();
            pos += QPoint(100, 100);
            mw2.reset(new MainWindow);
            mw2->setToolTip(toolTip);
            mw2->move(pos);
            mw2->setWindowTitle(QStringLiteral("Threaded QOpenGLWidget example #2"));
            mw2->show();
        } else {
            qWarning() << toolTip;
        }
    }

    return a.exec();
}
Exemplo n.º 9
0
int main(int argc, char** argv) {
    Q_INIT_RESOURCE(texture);

    QApplication a(argc, argv);

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

    GLWidget glwidget;
    glwidget.show();

    return a.exec();
}
Exemplo n.º 10
0
int main(int argc, char** argv) {
    QApplication a(argc, argv);

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

    GLWidget glWidget;
    qreal pixelRatio = glWidget.devicePixelRatio();
    cout << "pixel ratio: " << pixelRatio << std::endl;
    glWidget.resize(640/pixelRatio,480/pixelRatio);
    glWidget.show();

    return a.exec();
}
Exemplo n.º 11
0
int main(int argc, char **argv)
{
    QApplication app(argc, argv);
    GLWidget *window = new GLWidget;
    window->show();
    return app.exec();
	/*Vector v(1, 0, 0);
	Vector n(0, 0, 1);
	double ang = 2 * pi;
	//rotate(v, Quaternion(n, ang));
	rotate1(v, n, ang);
	std::cout << v.x() << " " << v.y() << " " << v.z() << '\n';
	int tmp;
	std::cin >> tmp;
	return 0;*/
}
Exemplo n.º 12
0
int main(int argc, char *argv[])
{
    QApplication a(argc, argv);
    QSurfaceFormat format;
    format.setDepthBufferSize(24);
    format.setVersion(3,3);
    format.setProfile(QSurfaceFormat::CoreProfile);
    QSurfaceFormat::setDefaultFormat(format);

    a.setApplicationName("PS6");

#ifndef QT_NO_OPENGL
    GLWidget w;
    w.show();
#else
    QLabel note("OpenGL Support required");
    note.show;
#endif
    return a.exec();
}
Exemplo n.º 13
0
int glwidgettest(int argc, char* argv[])
{
  // Set up the default format for our GL contexts.
  QSurfaceFormat defaultFormat = QSurfaceFormat::defaultFormat();
  defaultFormat.setSamples(4);
  QSurfaceFormat::setDefaultFormat(defaultFormat);

  QApplication app(argc, argv);
  GLWidget widget;
  widget.setGeometry(10, 10, 250, 250);
  widget.show();

  GeometryNode* geometry = new GeometryNode;
  SphereGeometry* spheres = new SphereGeometry;
  geometry->addDrawable(spheres);
  spheres->addSphere(Vector3f(0, 0, 0), Vector3ub(255, 0, 0), 0.5);
  spheres->addSphere(Vector3f(2, 0, 0), Vector3ub(0, 255, 0), 1.5);
  spheres->addSphere(Vector3f(0, 2, 1), Vector3ub(0, 0, 255), 1.0);
  widget.renderer().scene().rootNode().addChild(geometry);

  // Make sure the widget renders the scene, and store it in a QImage.
  widget.raise();
  widget.repaint();

  // Run the application for a while, and then quit so we can save an image.
  QTimer timer;
  timer.setSingleShot(true);
  app.connect(&timer, SIGNAL(timeout()), SLOT(quit()));
  timer.start(200);
  app.exec();

  // Grab the frame buffer of the GLWidget and save it to a QImage.
  QImage image = widget.grabFramebuffer();

  // Set up the image regression test.
  ImageRegressionTest test(argc, argv);

  // Do the image threshold test, printing output to the std::cout for ctest.
  return test.imageThresholdTest(image, std::cout);
}
Exemplo n.º 14
0
int main(int argc, char** argv) {

	// Do projective reconstruction
	bool is_projective = true;

	// Assume noise free
	bool has_outliers = false;

	// Read 2D points from text file

	Mat_<double> x1, x2;
	int npts;

	if (argc < 2) {
		help();
		exit(0);
	} else {
		ifstream myfile(argv[1]);
		if (!myfile.is_open()) {
			cout << "Unable to read file: " << argv[1] << endl;
			exit(0);

		} else {
			string line;

			// Read number of points
			getline(myfile, line);
			npts = (int) atof(line.c_str());
			x1 = Mat_<double>(2, npts);
			x2 = Mat_<double>(2, npts);

			// Read the point coordinates
			for (int i = 0; i < npts; ++i) {
				getline(myfile, line);
				stringstream s(line);
				string cord;

				s >> cord;
				x1(0, i) = atof(cord.c_str());
				s >> cord;
				x1(1, i) = atof(cord.c_str());

				s >> cord;
				x2(0, i) = atof(cord.c_str());
				s >> cord;
				x2(1, i) = atof(cord.c_str());

			}

			myfile.close();

		}
	}

	// Call the reconstruction function

	vector < Mat_<double> > points2d;
	points2d.push_back(x1);
	points2d.push_back(x2);
	Mat_<double> points3d_estimated;
	vector < Mat > Ps_estimated;

	reconstruct(points2d, Ps_estimated, points3d_estimated, is_projective,
			has_outliers);

	// Print output

	cout << endl;
	cout << "Projection Matrix of View 1: " << endl;
	cout << "============================ " << endl;
	cout << Ps_estimated[0] << endl << endl;
	cout << "Projection Matrix of View 1: " << endl;
	cout << "============================ " << endl;
	cout << Ps_estimated[1] << endl << endl;
	cout << "Reconstructed 3D points: " << endl;
	cout << "======================== " << endl;
	cout << points3d_estimated << endl;

	// Display 3D points using Qt widget

	// Create the structure
	vector<Vec3f> struct_coords;
	for (int i = 0; i < npts; ++i) {
		Vec3f point3d((float) points3d_estimated(0, i),
				(float) points3d_estimated(1, i),
				(float) points3d_estimated(2, i));
		struct_coords.push_back(point3d);
	}

	// Qt stuff
	QApplication app(argc, argv);
	GLWidget window;
	window.AddNewStructure(struct_coords);
	window.resize(800, 600);
	window.show();
	return app.exec();

}
Exemplo n.º 15
0
int qttextlabeltest(int argc, char *argv[])
{
  // Set up the default format for our GL contexts.
  QGLFormat defaultFormat = QGLFormat::defaultFormat();
  defaultFormat.setSampleBuffers(true);
  QGLFormat::setDefaultFormat(defaultFormat);

  // Create and show widget
  QApplication app(argc, argv);
  GLWidget widget;
  widget.setGeometry(10, 10, 500, 500);
  widget.show();

  // Create scene
  GeometryNode *geometry = new GeometryNode;
  widget.renderer().scene().rootNode().addChild(geometry);

  // Add a small sphere at the origin for reference:
  SphereGeometry *spheres = new SphereGeometry;
  spheres->addSphere(Vector3f::Zero(), Vector3ub(128, 128, 128), 0.1f);
  geometry->addDrawable(spheres);

  // Default text property:
  TextProperties tprop;

  // Test alignment:
  TextLabel3D *l3 = NULL;
  TextLabel2D *l2 = NULL;

  // 3D:
  tprop.setColorRgb(255, 0, 0);
  tprop.setAlign(TextProperties::HLeft, TextProperties::VTop);
  l3 = new TextLabel3D;
  l3->setText("Upper Left Anchor");
  l3->setAnchor(Vector3f::Zero());
  l3->setTextProperties(tprop);
  geometry->addDrawable(l3);

  tprop.setColorRgb(0, 255, 0);
  tprop.setAlign(TextProperties::HLeft, TextProperties::VBottom);
  l3 = new TextLabel3D;
  l3->setText("Bottom Left Anchor");
  l3->setAnchor(Vector3f::Zero());
  l3->setTextProperties(tprop);
  geometry->addDrawable(l3);

  tprop.setColorRgb(0, 0, 255);
  tprop.setAlign(TextProperties::HRight, TextProperties::VTop);
  l3 = new TextLabel3D;
  l3->setText("Upper Right Anchor");
  l3->setAnchor(Vector3f::Zero());
  l3->setTextProperties(tprop);
  geometry->addDrawable(l3);

  tprop.setColorRgb(255, 255, 0);
  tprop.setAlign(TextProperties::HRight, TextProperties::VBottom);
  l3 = new TextLabel3D;
  l3->setText("Bottom Right Anchor");
  l3->setAnchor(Vector3f::Zero());
  l3->setTextProperties(tprop);
  geometry->addDrawable(l3);

  tprop.setColorRgba(255, 255, 255, 220);
  tprop.setRotationDegreesCW(90.f);
  tprop.setAlign(TextProperties::HCenter, TextProperties::VCenter);
  l3 = new TextLabel3D;
  l3->setText("Centered Anchor (3D)");
  l3->setAnchor(Vector3f::Zero());
  l3->setTextProperties(tprop);
  l3->setRenderPass(Avogadro::Rendering::TranslucentPass);
  geometry->addDrawable(l3);
  tprop.setRotationDegreesCW(0.f);
  tprop.setAlpha(255);

  // 2D:
  tprop.setColorRgb(255, 0, 0);
  tprop.setAlign(TextProperties::HLeft, TextProperties::VTop);
  l2 = new TextLabel2D;
  l2->setText("Upper Left Corner");
  l2->setAnchor(Vector2i(0, widget.height()));
  l2->setTextProperties(tprop);
  geometry->addDrawable(l2);

  tprop.setColorRgb(0, 255, 0);
  tprop.setAlign(TextProperties::HLeft, TextProperties::VBottom);
  l2 = new TextLabel2D;
  l2->setText("Bottom Left Corner");
  l2->setAnchor(Vector2i(0, 0));
  l2->setTextProperties(tprop);
  geometry->addDrawable(l2);

  tprop.setColorRgb(0, 0, 255);
  tprop.setAlign(TextProperties::HRight, TextProperties::VTop);
  l2 = new TextLabel2D;
  l2->setText("Upper Right Corner");
  l2->setAnchor(Vector2i(widget.width(), widget.height()));
  l2->setTextProperties(tprop);
  geometry->addDrawable(l2);

  tprop.setColorRgb(255, 255, 0);
  tprop.setAlign(TextProperties::HRight, TextProperties::VBottom);
  l2 = new TextLabel2D;
  l2->setText("Bottom Right Corner");
  l2->setAnchor(Vector2i(widget.width(), 0));
  l2->setTextProperties(tprop);
  geometry->addDrawable(l2);

  tprop.setColorRgba(255, 255, 255, 220);
  tprop.setAlign(TextProperties::HCenter, TextProperties::VCenter);
  l2 = new TextLabel2D;
  l2->setText("Centered Anchor (2D)");
  l2->setAnchor(Vector2i(widget.width() / 2, widget.height() / 2));
  l2->setTextProperties(tprop);
  geometry->addDrawable(l2);

  // Test the TextLabel3D's radius feature:
  spheres->addSphere(Vector3f(0.f, 6.f, 0.f), Vector3ub(255, 255, 255), 1.f);

  tprop.setColorRgba(255, 128, 64, 255);
  tprop.setRotationDegreesCW(90.f);
  l3 = new TextLabel3D;
  l3->setText("Clipped");
  l3->setAnchor(Vector3f(0.f, 6.f, 0.f));
  l3->setTextProperties(tprop);
  geometry->addDrawable(l3);

  tprop.setColorRgba(64, 128, 255, 255);
  tprop.setRotationDegreesCW(45.f);
  l3 = new TextLabel3D;
  l3->setText("Projected");
  l3->setAnchor(Vector3f(0.f, 6.f, 0.f));
  l3->setTextProperties(tprop);
  l3->setRadius(1.f);
  geometry->addDrawable(l3);

  // Make sure the widget renders the scene, and store it in a QImage.
  widget.raise();
  widget.repaint();

  // Run the application for a while, and then quit so we can save an image.
  QTimer timer;
  timer.setSingleShot(true);
  app.connect(&timer, SIGNAL(timeout()), SLOT(quit()));
  timer.start(200);
  app.exec();

  // Grab the frame buffer of the GLWidget and save it to a QImage.
  QImage image = widget.grabFrameBuffer(false);

  // Set up the image regression test.
  ImageRegressionTest test(argc, argv);

  // Do the image threshold test, printing output to the std::cout for ctest.
  return test.imageThresholdTest(image, std::cout);
}