opengl 点,线,多边形



  • 程序框架参考: https://qtdream.com/topic/1144/第八课-融合

    glDrawArrays(GL_POINTS,0, 24);
    

    0_1526974597754_fac01a5c-f126-4036-8aea-844899b75818-image.png

    单线

    glDrawArrays(GL_LINES,0, 24);
    

    0_1526974631169_1689c9c1-936c-4064-aa0d-09d888b4b25f-image.png

    循环线

    0_1526974730735_b5cdb6ec-c126-44aa-9c35-3ebef99d12bb-image.png

    条线

    glDrawArrays(GL_LINE_STRIP,0, 24);
    

    0_1526974817004_5c677b67-8603-4154-b207-0aa1b3e15818-image.png

    教程理解

    0_1526974952725_1f412253-cc9d-4c25-aea1-8eab3fb934c3-image.png

    多边形

    glDrawArrays(GL_POLYGON,0, 16);
    

    0_1526975290845_bea865ea-9a0c-42a4-af0d-c596923f85df-image.png

    三角形

    glDrawArrays(GL_TRIANGLES,0, 16);
    

    0_1526975361114_9ec21308-de21-484f-98b2-d73f0e01e9c0-image.png

    条样 三角形

    glDrawArrays(GL_TRIANGLE_STRIP,0, 4);
    

    0_1526975494707_f8153ceb-38ce-409a-85d1-aff1fb062af3-image.png

    扇形 三角形

    glDrawArrays(GL_TRIANGLE_FAN,0, 7);
    

    效果见 教程理解

    四边形

    glDrawArrays(GL_QUADS,0, 8);
    

    0_1526975834909_c8557d45-0da3-403d-92bf-b666961badfd-image.png

    条样 四边形

    glDrawArrays(GL_QUAD_STRIP,0, 6);
    

    效果见 教程理解

    教程理解

    0_1526975110166_8795caa7-20f1-4e52-a905-b003b82103db-image.png `


Log in to reply
 

走马观花

最近的回复

  • 诶 没有Linux吗??

    read more
  • 萌梦 男孩,女孩,和蛋

    menghome.png

    read more
  • 设计模式-工厂模式

    使用qt/qml来演示设计模式效果,便于学习理解

    1)定义创建对象的接口,封装对象的创建
    2)使具体化类的工作延迟到工厂子类中

    bg.png
    image.png

    1. 工厂类

    createProduct使用了参数来选择要创建哪个产品

    #ifndef FACTORY_H #define FACTORY_H #include <QObject> class Product; class QString; class Factory: public QObject { Q_OBJECT public: virtual ~Factory() = 0; virtual Product* createProduct(QString type) = 0; protected: Factory(); }; class ConcreteFactory: public Factory { Q_OBJECT public: ~ConcreteFactory(); ConcreteFactory(); public slots: Product* createProduct(QString type); }; #endif // FACTORY_H #include "factory.h" #include "product.h" #include <QtQml/qqml.h> Factory::~Factory() { } Factory::Factory() { qmlRegisterType<Product>("Product", 1, 0, "Product"); } ConcreteFactory::~ConcreteFactory() { } ConcreteFactory::ConcreteFactory() { } Product *ConcreteFactory::createProduct(QString type) { if(type == "boy") return static_cast<Product *>(new ConcreteProduct1()); else if(type == "girl") return static_cast<Product *>(new ConcreteProduct2()); return static_cast<Product *>(new ConcreteProduct1()); } 2 产品类

    一个产品是萌梦男,一个产品是萌梦女

    #ifndef PRODUCT_H #define PRODUCT_H #include <QObject> class Product: public QObject { Q_OBJECT public: virtual ~Product() = 0; Q_PROPERTY(QString icon READ icon NOTIFY iconChanged) QString m_icon; QString icon() const { return m_icon; } signals: void iconChanged(QString icon); protected: Product(); signals: public slots: }; class ConcreteProduct1: public Product { Q_OBJECT public: ~ConcreteProduct1(); ConcreteProduct1(); }; class ConcreteProduct2: public Product { Q_OBJECT public: ~ConcreteProduct2(); ConcreteProduct2(); }; #endif // PRODUCT_H #include "product.h" Product::~Product() { } Product::Product() { } ConcreteProduct1::~ConcreteProduct1() { } ConcreteProduct1::ConcreteProduct1() { m_icon = "qrc:/images/boy.png"; } ConcreteProduct2::~ConcreteProduct2() { } ConcreteProduct2::ConcreteProduct2() { m_icon = "qrc:/images/girl.png"; } 3. main.qml

    使用timer,canvas,listview等实现一个自动化生产的动画效果

    源代码

    Fork me on Gitee

    read more
  • blender建模 章鱼
    捕获2.PNG 😵

    read more

关注我们

微博
QQ群