2016-10-02 26 views
0

我需要進行以下操作,但我不確定要如何進行歸檔。製作灰色塊測試卡片模式

我需要它看起來像這樣:

Image of what i need

這是我迄今所做的:

所有的
 float tempHeight = height * 0.20f; 
    float tempWidth = width * 0.20f; 
    float increase = 0; 
    float colour = 0.20f; 
    float temp = 0; 
    tempHeight = tempHeight/3; 

for(int y = 0; y < 5; y++) {    
      gl2.glBegin(GL2.GL_QUADS); 
       gl2.glColor3f(colour, colour, colour); // Set the current drawing color 
       gl2.glVertex3f(0, height * 0.20f + temp, 0.0f); // Top Left 
       gl2.glVertex3f(width * 0.20f , height * 0.20f + temp, 0.0f); // Top Right 
       gl2.glVertex3f(width * 0.20f , temp, 0.0f); // Bottom Right 
       gl2.glVertex3f(0, temp, 0.0f); // Bottom Left 
      gl2.glEnd(); 


     for(int a = 0; a < 4; a++) { 

       gl2.glBegin(GL2.GL_QUADS); 
        gl2.glColor3f(colour,colour,colour); 

       if (a == 0 || a == 2 || a == 3) { 
        gl2.glColor3f(1f, 0f, 0f); 
       } 
       gl2.glVertex3f(tempWidth, tempHeight + increase, 0.0f); // Top Left 
       gl2.glVertex3f(tempWidth * 2 , tempHeight + increase, 0.0f); // Top Right 
       gl2.glVertex3f(tempWidth * 2 , tempHeight * a , 0.0f); // Bottom Right 
       gl2.glVertex3f(tempWidth, tempHeight * a , 0.0f); // Bottom Left 
      gl2.glEnd(); 
      }    
      increase = tempHeight;    
      colour = colour + 0.20f; 
     // tempWidth = tempWidth + width * 0.20f; 
      temp = temp + height * 0.20f; 
      // tempHeight = tempHeight + height * 0.20f; 
      for(int b = 0; b < 5; b++) { 

      } 
     } 

} 

回答

0

首先,你應該避免deprecated OpenGL。如果你想要的話,你可以從mine的hello三角形開始,然後進行實驗。

其次,你所問的是相對容易的,你必須聲明你想要的形狀相匹配的頂點幾何形狀,即:

enter image description here

然後,使其5次(在此例如),並在每次需要時間:通過上傳將會增加你的幾何形狀的每個頂點的矩陣

  • 改變位置

  • 設置不同的顏色,將您的片段着色器被用來遮陽的幾何

如果您有任何問題,請不要猶豫,問