PIXNET Logo登入

阿勇的blog

跳到主文

歡迎光臨阿勇在痞客邦的小天地

部落格全站分類:不設分類

  • 相簿
  • 部落格
  • 留言
  • 名片
  • 3月 11 週一 201323:07
  • immediate mode? display list? vertex array?

immediate mode
  • The easiest way to do drawing in OpenGL is using the Immediate Mode. For this, you use the glBegin() function which takes as one parameter the “mode” or type of object you want to draw.
  • glBegin(GL_LINE_LOOP);//start drawing a line loop
        glVertex3f(-1.0f,0.0f,0.0f);//left of window
        glVertex3f(0.0f,-1.0f,0.0f);//bottom of window
        glVertex3f(1.0f,0.0f,0.0f);//right of window
        glVertex3f(0.0f,1.0f,0.0f);//top of window
    glEnd();//end drawing of line loop
  • display list
  • Display list is a group of OpenGL commands that have been stored (compiled) for later execution. Once a display list is created, all vertex and pixel data are evaluated and copied into the display list memory on the server machine. It is only one time process. After the display list has been prepared (compiled), you can reuse it repeatedly without re-evaluating and re-transmitting data over and over again to draw each frame.
  • // create one display list
    GLuint index = glGenLists(1);
    // compile the display list, store a triangle in it
    glNewList(index, GL_COMPILE);
        glBegin(GL_TRIANGLES);
            glVertex3fv(v0);
            glVertex3fv(v1);
            glVertex3fv(v2);
        glEnd();
    glEndList();
    ...
    // draw the display list
    glCallList(index);
  • vertex array
  • This means that your vertices and vertex attributes and indices are in RAM.
  • glEnableClientState(GL_VERTEX_ARRAY);
    glEnableClientState(GL_COLOR_ARRAY);
    glColorPointer(3, GL_FLOAT, 0, Colors);
    glVertexPointer(3, GL_FLOAT, 0, Vertices);
    glDrawArrays(GL_TRIANGLES, 0, 3);
    glDisableClientState(GL_VERTEX_ARRAY);
    glDisableClientState(GL_COLOR_ARRAY);
  • (繼續閱讀...)
    文章標籤

    阿勇 發表在 痞客邦 留言(0) 人氣(13)

    • 個人分類:opengl
    ▲top
    • 3月 10 週日 201320:55
    • OpenGL Blend



    glBlendFunc — specify pixel arithmetic
    void glBlendFunc(GLenum sfactor, GLenum dfactor);void glBlendFunci(GLuint buf, GLenum sfactor, GLenum dfactor);Parameters
    bufFor glBlendFunci, specifies the index of the draw buffer for which to set the blend function.sfactor
    (繼續閱讀...)
    文章標籤

    阿勇 發表在 痞客邦 留言(0) 人氣(37)

    • 個人分類:opengl
    ▲top
    • 3月 10 週日 201317:51
    • Qt5 + OpenGL



    前幾天發現在Qt5裡,所有的fixed function pipeline都不能編譯了。稍微google了一下,才發現,原來Qt5所有precompile的安裝包,都是用ANGLE layer來實作OpenGL ES2,也就是你要寫的是OpenGL ES2,而不是OpenGL。所以一些fixed function pipeline的function,例如glBegin/glEnd都不能用了。
    (繼續閱讀...)
    文章標籤

    阿勇 發表在 痞客邦 留言(0) 人氣(6)

    • 個人分類:Qt
    ▲top
    • 3月 08 週五 201322:22
    • Color Button for Qt (part 2)




    void ColorButton::setColor(QColor color)
    {
    QPixmap pixmap(this->iconSize());
    pixmap.fill(color);
    this->setIcon(QIcon(pixmap));
    selectedColor = color;
    this->update();
    }
    void ColorButton::init(QColor color)
    {
    colorDialog.setCurrentColor(color);
    QObject::connect(this, SIGNAL(clicked()),
    &colorDialog, SLOT(open()));
    QObject::connect(&colorDialog, SIGNAL(colorSelected(QColor)),
    this, SLOT(setColor(QColor)));
    setColor(color);
    }
    void ColorButton::paintEvent(QPaintEvent *event)
    {
    QPushButton::paintEvent(event);
    QPainter painter(this);
    painter.setCompositionMode(QPainter::CompositionMode_Screen);
    painter.fillRect(0, 0, this->width(), this->height(), selectedColor);
    }
    (繼續閱讀...)
    文章標籤

    阿勇 發表在 痞客邦 留言(0) 人氣(11)

    • 個人分類:Qt
    ▲top
    • 3月 08 週五 201314:33
    • Color Button for Qt



    void ColorButton::setColor(QColor color)
    {
    QPixmap pixmap(this->iconSize());
    pixmap.fill(color);
    QPainter painter;
    painter.begin(&pixmap);
    painter.setPen(0xffffff-color.rgb());
    painter.drawRect(0,0, pixmap.width()-1, pixmap.height()-1);
    painter.end();
    this->setIcon(QIcon(pixmap));
    }
    void ColorButton::init(QColor color)
    {
    colorDialog.setCurrentColor(color);
    QObject::connect(this, SIGNAL(clicked()),
    &colorDialog, SLOT(open()));
    QObject::connect(&colorDialog, SIGNAL(colorSelected(QColor)),
    this, SLOT(setColor(QColor)));
    setColor(color);
    }
    (繼續閱讀...)
    文章標籤

    阿勇 發表在 痞客邦 留言(0) 人氣(6)

    • 個人分類:Qt
    ▲top
    • 3月 04 週一 201313:49
    • 在Qt中,使用系統預設的圖示


    QStyle定義了一些系統視窗相關的風格,像是圖示和gui的樣式。 qApp->style()->standardIcon(QStyle::SP_MediaVolumeMuted
    (繼續閱讀...)
    文章標籤

    阿勇 發表在 痞客邦 留言(0) 人氣(21)

    • 個人分類:Qt
    ▲top
    • 3月 02 週六 201320:32
    • 3D text on Qt with OpenGL (part 2)



    這一篇,是把上一篇的文章改成一個class
    header file
    (繼續閱讀...)
    文章標籤

    阿勇 發表在 痞客邦 留言(0) 人氣(7)

    • 個人分類:Qt
    ▲top
    • 3月 02 週六 201316:55
    • Qt 讀取非系統字型

    使用QFontDatabase::addApplicationFont,可以直接讀取字型 檔(ttc, ttf)。

    #include <QFontDatabase>
    QString loadFontFromFile(QString path)
    {
    static QString font;
    static bool loaded = false;
    if(!loaded)
    {
    loaded = true;
    int loadedFontID = QFontDatabase::addApplicationFont(path);
    QStringList loadedFontFamilies = QFontDatabase::applicationFontFamilies(loadedFontID);
    if(!loadedFontFamilies.empty())
    font = loadedFontFamilies.at(0);
    }
    return font;
    }
    QString fontName = loadFontFromFile(":/font/font2.TTC");
    QFont font(fontName);
    (繼續閱讀...)
    文章標籤

    阿勇 發表在 痞客邦 留言(0) 人氣(130)

    • 個人分類:Qt
    ▲top
    • 3月 01 週五 201314:20
    • 3D text on Qt with OpenGL



    利用QPainterPath算出polygon之後,就可以畫出邊框
    QPainterPath path;
    path.addText(QPointF(0, 0), QFont("Arial", 100), QString::fromUtf8("你要不要喝紅茶ˊ_>ˋ?"));
    GLuint id = glGenLists(1);
    glNewList(id, GL_COMPILE);
    foreach(QPolygonF polygon, path.toSubpathPolygons()){
    glBegin(GL_LINE_LOOP);
    foreach(QPointF point, polygon){
    glVertex3f(point.rx(), -point.ry(), 0);
    }
    glEnd();
    }
    glEndList();
    (繼續閱讀...)
    文章標籤

    阿勇 發表在 痞客邦 留言(2) 人氣(42)

    • 個人分類:Qt
    ▲top
    • 2月 23 週六 201317:24
    • 可在mac和windows上執行的安裝光碟

    首先建一個iso檔
    hdiutil makehybrid /source/folder/name/ -o outputfile.iso
    打開檔案
    hdiutil attach -readwrite outputfile.iso
    將需要的檔案丟入光碟裡
    (繼續閱讀...)
    文章標籤

    阿勇 發表在 痞客邦 留言(0) 人氣(5)

    • 個人分類:mac
    ▲top
    «1...34513»

    個人資訊

    阿勇
    暱稱:
    阿勇
    分類:
    不設分類
    好友:
    累積中
    地區:

    熱門文章

    • (0)Cordova速記
    • (0)Cordova run simulation
    • (5)swift速記
    • (1)cordova發布到andriod
    • (4)迷香
    • (11)notification results in “unrecognized selector sent to instance…”
    • (0)分開設定xcode的configureration
    • (10)關於doesNotRecognizeSelector引起的exception crash
    • (1)在SQL中,當二個鍵同時相等時,唯一鍵成立。
    • (56)防止繼承的delegate跟原本的衝突(how to extend a protocol for a delegate in objective C)

    文章分類

    • 替代役的日子 (5)
    • 黑色鈣片 (4)
    • java (3)
    • picasa (1)
    • lua (1)
    • mingw (1)
    • nsis (1)
    • squirrel (1)
    • freetype (1)
    • bitmap font (7)
    • windows (5)
    • c (1)
    • NetBeans (2)
    • uml (1)
    • html5 (1)
    • Wheel Light (4)
    • Qt (26)
    • opengl (6)
    • chrome (2)
    • hg (2)
    • mac (4)
    • apns (1)
    • python (4)
    • php (2)
    • SQL (4)
    • iOS (3)
    • xcode (4)
    • Objective-C (8)
    • phonegap (1)
    • swift (1)
    • cordova (2)
    • 未分類文章 (1)

    最新文章

    • Cordova速記
    • Cordova run simulation
    • swift速記
    • cordova發布到andriod
    • 迷香
    • notification results in “unrecognized selector sent to instance…”
    • 分開設定xcode的configureration
    • 關於doesNotRecognizeSelector引起的exception crash
    • 在SQL中,當二個鍵同時相等時,唯一鍵成立。
    • 防止繼承的delegate跟原本的衝突(how to extend a protocol for a delegate in objective C)

    動態訂閱

    文章精選

    文章搜尋

    誰來我家

    參觀人氣

    • 本日人氣:
    • 累積人氣: