SimpleScenario::SimpleScenario(string textureSrc) : GLPiece("Scenario") {
    GLfloat light_position[] = { 1.0, 1.0, 1.0, 0.0 };
    glLightfv(GL_LIGHT0, GL_POSITION, light_position);
    glEnable(GL_LIGHTING);
    glEnable(GL_LIGHT0);

	glGenTextures( 1, &texture );
	texture = loadTextureRAW(textureSrc);
}
Пример #2
0
/**
 * Get the tile id for the OpenStreetMap coordinates
 */
int FlyerMapBuilder::getTile(int x,int y)
{
    // Load default texture if it has not been loaded yet
    if(0 == defaultTexture)
    {
        defaultTexture = loadTextureRAW("default.bmp");
    }

    // Outside bounds of map
    if(x < 0 || y < 0 || x > numTiles - 1 
            || y > numTiles - 1)
    {
        return defaultTexture;
    }

    {
        sf::Lock DownloadLock(DownloadMutex);
        // Find Row
        OSMTextureMap::iterator firstKey = downloadedTiles.find(x);
        if(downloadedTiles.end() != firstKey)
        {
            // Find Column
            TextureMap::iterator secondKey = (*firstKey).second.find(y);
            if((*firstKey).second.end() != secondKey)
            {
                // Texture hasn't been loaded yet 
                if(0 == (*secondKey).second)
                {
                    GLuint result = loadTextureRAW(builderThreadA.getFilenameString(zoom,x,y));
                    if(result != 0)
                    {
                        (*secondKey).second = result;
                        return (*secondKey).second;
                    }
                }
                // Texture is downloading
                else if(-1 == (*secondKey).second)
                {
                    return defaultTexture;
                }
                // Texture is loaded
                else
                { 
                    return (*secondKey).second;
                }
            }
        }
    }
    
    // Texture has not been found or is not being downloaded
    std::pair<int,int> newTile(x,y);
    {
        sf::Lock DownloadLock(DownloadMutex);
        downloadedTiles[x][y] = -1;
    }
    // Put texture in queue to be downloaded
    {
        sf::Lock QueueLock(QueueMutex);
        tileQueue.push_back(newTile);
    }

    return defaultTexture;
}