示例#1
0
void LoadTexture(Gfx::CGLDevice *device, const std::string &name)
{
    if (name.empty())
        return;

    Gfx::Texture tex = GetTexture(name);

    if (tex.Valid())
        return;

    CImage img;
    if (! img.Load(std::string("tex/") + name))
    {
        std::string err = img.GetError();
        GetLogger()->Error("Texture not loaded, error: %s!\n", err.c_str());
    }
    else
    {
        Gfx::TextureCreateParams texCreateParams;
        texCreateParams.mipmap = true;
        texCreateParams.minFilter = Gfx::TEX_MIN_FILTER_LINEAR_MIPMAP_LINEAR;
        texCreateParams.magFilter = Gfx::TEX_MAG_FILTER_LINEAR;

        tex = device->CreateTexture(&img, texCreateParams);
    }

    TEXS[name] = tex;
}