title: load different textures type using assimp
body: <p>By default I load everything like this</p>
  
  <pre><code>for(int g = 0; g &lt; faces.size(); g++)
  {
  
      glMaterialfv(GL_FRONT, GL_SPECULAR, materials[g].Ks);
      glMaterialfv(GL_FRONT, GL_DIFFUSE, materials[g].Kd);
      glMaterialfv(GL_FRONT, GL_AMBIENT, materials[g].Ka);
      glMaterialf(GL_FRONT, GL_SHININESS, materials[g].Ns);
  
      Texture t;
      getTexture(&amp;t, materials[g].pict);
  
      glBindTexture(GL_TEXTURE_2D, t.texID);
  
      glBegin(GL_TRIANGLES);
  
      for(int f = 0; f &lt; faces[g].size(); f++)
      {
          glNormal3f(normals[faces[g][f].vn1 - 1].x, normals[faces[g][f].vn1 - 1].y, normals[faces[g][f].vn1 - 1].z);
          glTexCoord2f(texCoords[faces[g][f].vt1 - 1].u, texCoords[faces[g][f].vt1 - 1].v);
          glVertex3f(vertices[faces[g][f].v1 - 1].x, vertices[faces[g][f].v1 - 1].y, vertices[faces[g][f].v1 - 1].z);
  
          glNormal3f(normals[faces[g][f].vn2 - 1].x, normals[faces[g][f].vn2 - 1].y, normals[faces[g][f].vn2 - 1].z);
          glTexCoord2f(texCoords[faces[g][f].vt2 - 1].u, texCoords[faces[g][f].vt2 - 1].v);
          glVertex3f(vertices[faces[g][f].v2 - 1].x, vertices[faces[g][f].v2 - 1].y, vertices[faces[g][f].v2 - 1].z);
  
          glNormal3f(normals[faces[g][f].vn3 - 1].x, normals[faces[g][f].vn3 - 1].y, normals[faces[g][f].vn3 - 1].z);
          glTexCoord2f(texCoords[faces[g][f].vt3 - 1].u, texCoords[faces[g][f].vt3 - 1].v);
          glVertex3f(vertices[faces[g][f].v3 - 1].x, vertices[faces[g][f].v3 - 1].y, vertices[faces[g][f].v3 - 1].z);
      }
  
      glEnd();
  }
  </code></pre>
  
  <p>It was very very slow so I decided to use assimp. 
  The model itself is loaded well.But they don't have any textures at all(well something like color exist)
  <img src="https://i.stack.imgur.com/wHpEb.png" alt="enter image description here"></p>
  
  <p>I load materials like this</p>
  
  <pre><code> for (unsigned int i = 0 ; i &lt; pScene-&gt;mNumMaterials ; i++) {
      const aiMaterial* pMaterial = pScene-&gt;mMaterials[i];
  
      m_Textures[i] = NULL;
      //GL_SHININESS GL_SPECULAR GL_DIFFUSE GL_AMBIENT
      if (pMaterial-&gt;GetTextureCount(aiTextureType_DIFFUSE) &gt; 0) {
          aiString Path;
  
          if (pMaterial-&gt;GetTexture(aiTextureType_DIFFUSE, 0, &amp;Path, NULL, NULL, NULL, NULL, NULL) == AI_SUCCESS) {
              std::string FullPath = Dir + "/" + Path.data;
              m_Textures[i] = new Texture();
              if (!LoadTGA(m_Textures[i], const_cast&lt;char*&gt;(FullPath.c_str())))
              {
                  printf("Error loading texture '%s'\n", FullPath.c_str());
                  delete m_Textures[i];
                  m_Textures[i] = NULL;
                  Ret = false;
              }
              else {
                  printf("Loaded texture '%s'\n", FullPath.c_str());
                  glGenTextures(1, &amp;m_Textures[i]-&gt;texID);
                  glBindTexture(GL_TEXTURE_2D, m_Textures[i]-&gt;texID);
                  glTexImage2D(GL_TEXTURE_2D, 
                                  0, 
                                  m_Textures[i]-&gt;bpp / 8, 
                                  m_Textures[i]-&gt;width, 
                                  m_Textures[i]-&gt;height, 
                                  0, 
                                  m_Textures[i]-&gt;type, 
                                  GL_UNSIGNED_BYTE, 
                                  m_Textures[i]-&gt;imageData);
                  glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
                  glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
              }
          }
      }
  }
  </code></pre>
  
  <p>I set <code>aiTextureType</code> as diffuse, but in my .obj file there are also <code>shininess, specular, ambient</code> materials.</p>
  
  <p>I draw everything like this</p>
  
  <pre><code>glEnableVertexAttribArray(0);
  glEnableVertexAttribArray(1);
  glEnableVertexAttribArray(2);
  
  for (unsigned int i = 0 ; i &lt; m_Entries.size() ; i++) {
      glBindBuffer(GL_ARRAY_BUFFER, m_Entries[i].VB);
      glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, sizeof(TVertex), 0);
      glVertexAttribPointer(1, 2, GL_FLOAT, GL_FALSE, sizeof(TVertex), (const GLvoid*)12);
      glVertexAttribPointer(2, 3, GL_FLOAT, GL_FALSE, sizeof(TVertex), (const GLvoid*)20);
  
      glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, m_Entries[i].IB);
  
      const unsigned int MaterialIndex = m_Entries[i].MaterialIndex;
  
      if (MaterialIndex &lt; m_Textures.size() &amp;&amp; m_Textures[MaterialIndex]) {
          glClientActiveTexture(GL_TEXTURE0);
          glBindTexture(GL_TEXTURE_2D, m_Textures[MaterialIndex]-&gt;texID);
      }
  
      glDrawElements(GL_TRIANGLES, m_Entries[i].NumIndices, GL_UNSIGNED_INT, 0);
  }
  
  glDisableVertexAttribArray(0);
  glDisableVertexAttribArray(1);
  glDisableVertexAttribArray(2);
  </code></pre>
  
  <p>So how to load other types of materials?</p>