当前位置: 首页>>代码示例>>C++>>正文


C++ GLWidget::addObject方法代码示例

本文整理汇总了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();
}
开发者ID:DavidNicholls,项目名称:opencamlib,代码行数:60,代码来源:vbo_tst.cpp


注:本文中的GLWidget::addObject方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。