I just completed an OpenGL wrapper class, but at one point, i could not see any better solution that using this goto.
void COpenGL::LoadTexture(BYTE *pTex, UINT w, UINT h, UINT bpp, UINT format)
{
if(!IsInitialized())
return;
if(Texture.ID == 0){
CreateTexture();
goto LoadTexJmp;
}
if(Texture.ID != 0){
glBindTexture(GL_TEXTURE_2D, Texture.ID);
if(Texture.Width != w || Texture.Height != h || Texture.BPP != bpp || Texture.Format != format){
DeleteTexture();
CreateTexture();
LoadTexJmp:
Texture.Width = w;
Texture.Height = h;
Texture.BPP = bpp;
Texture.Format = format;
glTexImage2D(GL_TEXTURE_2D, 0, Texture.BPP, Texture.Width, Texture.Height, 0, Texture.Format, GL_UNSIGNED_BYTE, pTex);
} else {
glTexSubImage2D(GL_TEXTURE_2D, 0, 0,0, Texture.Width, Texture.Height, Texture.Format, GL_UNSIGNED_BYTE, pTex);
}
}
}
Any idea?