電腦圖形學(二)輸出圖元_18_顯示列表_2_執行OpenGL顯示表

來源:互聯網
上載者:User

標籤:

執行OpenGL顯示表採用下面的語句可執行一個顯示表:
glCallList (listID);
下面的程式段用於建立並執行一個顯示表。我們先在xy平面上建立以(200,200)為中心座標、半徑為150的圓周上六個等距頂點描述的規則六邊形的顯示表。然而調用glCallList來顯示該六邊形。
const double TWO_PI = 6.2831853; GLuint regHex; GLdouble theta; GLint x, y, k; /* Set up a display list for a regular hexagon.  * Vertices for the hexagon are six equally spaced  * points around the circumference of a circle.  */ regHex = glGenLists (1); // Get an identifier for the display list. glNewList (regHex, GL_COMPILE);    glBegin (GL_POLYGON);      for (k = 0; k < 6; k++) {         theta = TWO_PI * k / 6.0;         x = 200 + 150 * cos (theta);         y = 200 + 150 * sin (theta);         glVertex2i (x, y);   } glEnd ( ); glEndList (); glCallList (regHex);
使用下列兩條語句可以執行多個顯示表:
 glListBase (offsetValue); glCallLists (nLists, arrayDataType, listIDArray);
要執行的顯示表數量賦給參數 nLists,而參數 listIDArray是顯示表標識的數組。一般而言,listIDArray可包含任意多的元素,而無效的標識會被忽略。同樣,listIDArray中的元素可指定為多種資料格式,而參數 arrayDataType用來指出資料類型,例如GL_BYTE,GL_INT,GL_FLOAT, GL_3_BYTES或GL_4_ BYTES。顯示表標識通過將 listIDArray中一個元素的值與 offsetValue的整數值相加而得。 offsetValue的預設值為0。
    這種指定要執行的一串顯示表的機制使我們能建立一組相關的顯示表,其標識用符號名或編碼形成。一個典型的例子是一個字型檔集,其中每一顯示表標識是一個字元的ASCII值。在定義幾個字型檔時,使用 glListBase函數中的 offsetVaiue來獲得數組 listIDArray中描述的特定字型檔。

電腦圖形學(二)輸出圖元_18_顯示列表_2_執行OpenGL顯示表

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.