本文整理汇总了C++中GLWidget::addObject方法的典型用法代码示例。如果您正苦于以下问题:C++ GLWidget::addObject方法的具体用法?C++ GLWidget::addObject怎么用?C++ GLWidget::addObject使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类GLWidget
的用法示例。
在下文中一共展示了GLWidget::addObject方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
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();
}