紋理映射座標glTexCoordPointer用法

來源:互聯網
上載者:User

 

 glTexCoordPointer(int size, int type, int stride, Buffer pointer);  設定頂點數組為紋理座標緩衝

其中: size:紋理頂點座標的分量個數;  //size: number of coordinates per vertex;   

              type:紋理座標的資料類型;short, int, float, double都可以;

              stride:位元影像的寬度,可以理解為相鄰的兩個紋理之間跨多少個位元組,一般為0,因為一般不會在紋理中再添加其他的信  息。//stride: offset between 2 consecutive vertices;

              pointer:存放紋理座標的數組,指明將繪製的第i個點(i<count)分別對應著貼圖的哪一個角,四個角分別用(0,1)(左上方)、(1,1)(右上方)、(1,0)(右下角)、(0,0)(左下角)表示。如
                                                 IntBuffer texCoords = IntBuffer.wrap(new int[]{
                                                
  0,1,1,1,1,0,0,0,               
                                                 });
                                                  gl.glTexCoordPointer(2, GL10.GL_FIXED, 0, texCoords);

注意:pointer是以頂點數組為參照的,而不是以繪製索引為參照!如
  gl.glVertexPointer(3, GL10.GL_FIXED, 0, vertices);
  gl.glTexCoordPointer(2, GL10.GL_FIXED, 0, texCoords);
  gl.glDrawElements(GL10.GL_TRIANGLE_STRIP, 4,  GL10.GL_UNSIGNED_BYTE, indices);
poInter以vertices中頂點的順序為參照,而不是indices所指定的順序。

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.