2012-05-02 3 views
0

OpenGL 사용 및 GxBase 사용 텍스처를로드 중입니다.효율적인 OpenGL 텍스처로드 gxbase

if (Image.Load("ball.jpg")) 
{ 
    Image.FlipY(); 
    glBindTexture(GL_TEXTURE_2D, MyTexture[0]); 
    Image.gluBuild2DMipmaps(); 
} 

동일한 텍스처를 두 번로드하지 않도록하려면 어떻게해야합니까?

답변

0

나는 GxBase을 사용한 적이 있지만, 난 그냥 질감 식별자 (GLuints에 문자열)

먼저지도를 보면, 새로운로드로 이동하고 경우에 파일 이름을 매핑하는 맵을 유지하는 것 거기에, 그것을 다시로드하지 않고 텍스처 ID를 반환합니다. 그렇지 않으면로드 한 후 생성 된 텍스처 ID를 저장

시도 같은 :

std::map<std::string,GLuint> textures; 
... 

// Inside your method to load textures: 

if (textures.count(textureName) == 0) 
{ 
    // load texture 
    textures[textureName] = // the GLuint texture id 
} 
else 
{ 
    return textures[textureName]; 
} 
+0

기회 당신이에 대한 코드 조각을하거나에 대한 튜토리얼에 나를 인도? 감사 – HungryCoder

관련 문제