0
所以我使用glBegin(GL_QUADS)創建了一個四邊形,然後繪製頂點,現在我想將紋理座標數組傳遞給我的着色器,以便我可以將紋理應用到我的四邊形。使用glVertexAttribPointer的openGL
所以我有一些麻煩得到正確的語法。
首先,我做的值
GLfloat coords[4][2];
coords[0][0] = 0;
coords[0][1] = 0;
coords[1][0] = 1;
coords[1][1] = 0;
coords[2][0] = 1;
coords[2][1] = 1;
coords[3][0] = 0;
coords[3][1] = 1;
,然後的二維數組我試圖把它變成我的着色器,我有VEC 2 texcoordIn
一個屬性GLint texcoord = glGetAttribLocation(shader->programID(), "texcoordIn");
glEnableVertexAttribArray(texcoord);
glVertexAttribPointer(texcoord, ???, GL_FLOAT, ???, ???, coords);
所以我很困惑,我應該把參數放到我用'???'標記的glVertexAttribPointer中我也想知道是否允許我像第一個那樣將紋理座標表示爲二維數組。
感謝您的幫助!我仍然遇到麻煩。它似乎並不像我的2d'coord'數組實際上在做任何事情(四元組變成空白)。我很自信,我的內部着色器代碼是正確的。 – user1782677 2013-02-09 01:21:55
@ user1782677:如果您發佈着色器的代碼,唯一的辦法就是說明。 – datenwolf 2013-02-09 01:24:23