2010-05-21 19 views
0

我正在將紋理貼圖映射到立方體上的正方形。出於某種原因,t軸倒置,0表示頂部,1表示底部。任何想法爲什麼發生這種情況?OpenGL-ES紋理圖集。 t軸是倒立的

此外,我必須以順時針順序而不是逆時針指定紋理座標。我正在使用逆時針繞組。下面是我使用的頂點,索引和紋理座標。

float vertices[] = { 
    // Front face 
    -width, -height, depth, // 0 
    width, -height, depth, // 1 
    width, height, depth, // 2 
    -width, height, depth, // 3 

      // Back Face 
      width, -height, -depth, // 4 
      -width, -height, -depth, // 5 
      -width, height, -depth, // 6 
      width, height, -depth, // 7 

      // Left face 
      -width, -height, -depth, // 8 
      -width, -height, depth, // 9 
      -width, height, depth, // 10 
      -width, height, -depth, // 11 

      // Right face 
      width, -height, depth, // 12 
      width, -height, -depth, // 13 
      width, height, -depth, // 14 
      width, height, depth, // 15 

      // Top face 
      -width, height, depth, // 16 
      width, height, depth, // 17 
      width, height, -depth, // 18 
      -width, height, -depth, // 19 

      // Bottom face 
      -width, -height, -depth, // 20 
      width, -height, -depth, // 21 
      width, -height, depth, // 22 
      -width, -height, depth, // 23 
    }; 

    short indices[] = { 
     // Front // Back 
     0,1,2, 0,2,3, 4,5,6, 4,6,7, 
     // Left // Right 
     8,9,10, 8,10,11, 12,13,14, 12,14,15, 
     // Top // Bottom 
     16,17,18, 16,18,19, 20,21,22, 20,22,23, 
    }; 


    float textures[] = { 
    // Front 
    0.0f, 0.0f, 0.25f, 0.0f, 0.25f, 0.25f, 0.0f, 0.25f, 
     // Back 
    0.25f, 0.0f, 0.50f, 0.0f, 0.50f, 0.25f, 0.25f, 0.25f, 
     // Left 
    0.50f, 0.0f, 0.75f, 0.0f, 0.75f, 0.25f, 0.50f, 0.25f, 
     // Right 
    0.75f, 0.0f, 1f, 0.0f, 1f, 0.25f, 0.75f, 0.25f, 
     // Top 
    0.0f, 0.25f, 0.25f, 0.25f, 0.25f, 0.50f, 0.0f, 0.50f, 
     // Bottom 
    0.25f, 0.25f, 0.50f, 0.25f, 0.50f, 0.50f, 0.25f, 0.50f, 
    }; 

我的質地 - 在MSPAINT創建一個256x256的.png文件。

alt text http://www.freeimagehosting.net/uploads/9a87120b99.png

+0

那麼,你的問題到底是什麼?您的帖子中沒有問號。下面是一般的OpenGL提示(我沒有使用opengl-es): 如果你使用索引基元,那麼你只需要8個(不是24個)頂點來創建一個立方體。使用超過8會使事情變得不必要的複雜。如果紋理是顛倒的,則問題可能出現在紋理加載代碼中(在調用glBindTexture2D的代碼中) - 可能最先加載最下面的一行像素。渲染/紋理紋理以2D方式進行屏幕顯示,看看它是否正確。 確保你沒有打破投影轉換的地方。 – SigTerm 2010-05-21 03:18:20

+0

我在這個問題的建議中使用了24個頂點。 http://stackoverflow.com/questions/2854237/opengl-es-texture-map-all-faces-of-an-8-vertex-cube/2854444#2854444。另外,我不太清楚渲染/紋理貼圖的意思。 – Feet 2010-05-21 03:36:31

回答

0

所以之後在網絡上還沒有更多的搜索,似乎OpenGL的呈現圖像開始在底部掃描線,這意味着你需要反轉的Y/T座標。或者在查看原始圖像時使用左上角的原點。