Ejemplo n.º 1
0
void RiftAppSkeleton::LoadTexturesFromFile()
{
    Timer t;
    const std::string texdir("../textures/");
    const std::vector<std::string> texturenames = GetListOfFilesFromDirectory(texdir);
    for (std::vector<std::string>::const_iterator it = texturenames.begin();
        it != texturenames.end();
        ++it)
    {
        const std::string& s = *it;
        const std::string fullName = texdir + s;

        GLuint texId = 0;
        GLuint width = 0;
        GLuint height = 0;
        ///@todo Case insensitivity?
        if (hasEnding(fullName, ".jpg"))
            texId = LoadTextureFromJpg(fullName.c_str(), &width, &height);
        else if (hasEnding(fullName, ".png"))
            texId = LoadTextureFromPng(fullName.c_str(), &width, &height);

        textureChannel tc = {texId, width, height};
        m_texLibrary[s] = tc;
    }
    std::cout << "Textures loaded in " << t.seconds() << " seconds." << std::endl;

    m_shaderToyScene.SetTextureLibraryPointer(&m_texLibrary);
}
Ejemplo n.º 2
0
void BMFont::initGL()
{
    for (std::vector<std::string>::const_iterator it = m_pageNames.begin();
        it != m_pageNames.end();
        ++it)
    {
        const std::string& tf = *it;
        const std::string fp = "../textures/" + tf;
        if (hasEnding(tf, ".png"))
        {
            GLuint width = 0;
            GLuint height = 0;
            const GLuint texId = LoadTextureFromPng(fp.c_str(), &width, &height);
            ///@todo check width/height
            m_texturePages.push_back(texId);
        }
    }
}