Welcome, Guest. Please login or register. Did you miss your activation email?

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - maehze

Pages: [1]
1
Graphics / Re: White sprite
« on: November 17, 2012, 08:55:15 pm »
hmm, well upgrading to 2.0 may be the first step towards resolving this :)

I want to use a stable version of SFML.

2
Graphics / Re: White sprite
« on: November 16, 2012, 07:52:13 pm »
[...], BUT, you should use a rendertexture instead of capture() to do this sort of thing. [...]
I use the current version of SFML (1.6). sf::RenderTexture::capture() does only exist in 2.0.
Calling "display()" before "capture()" did not help, but now the background is black instead of white.

I can see the right background for a very short moment on startup.

3
Graphics / Re: White sprite
« on: November 15, 2012, 11:14:07 pm »
Quote
 for(unsigned int y=0; y < mCity->getGridSize().y; ++y)
            {
                cell.setFillColor(sf::Color::Red); break;
                cell.setPosition(x*scale, y*scale);
                mWindow->draw(cell);
            }

Shouldn't that break be conditional?

Well... it should not be there ;-)
I cleaned up the code before i posted it here and forgot this litte "break".
Original code:

                switch(grid[x + mCity->getGridSize().x * y])
                {
                    case(City::GridCellType::Free): cell.setFillColor(sf::Color::White); break;
                    case(City::GridCellType::PublicPlace): cell.setFillColor(sf::Color::Green); break;
                    case(City::GridCellType::PoliceStation): cell.setFillColor(sf::Color::Blue); break;
                    case(City::GridCellType::Building): cell.setFillColor(sf::Color::Black); break;
                    default: cell.setFillColor(sf::Color::Red); break;
                }

4
Graphics / White sprite
« on: November 15, 2012, 09:47:40 pm »
Problem: When mCity->getEntities is > 1 or mWindow->draw() is called twice the background is just white.
What the code does: It renders a grid once into gridSprite. Then every time gridSprite is drawed, after that some circles are drawed on this.
Code:
void CityGridViewer::paintCity()
{  
    // 1. Render grid if necessary
    static bool targetReady=false;
    static sf::Texture gridTex;
    static sf::Sprite gridSprite;

    if (!targetReady)
    {
        sf::RectangleShape cell;
        cell.setSize(sf::Vector2f(5,5));
        cell.setOutlineColor(sf::Color::Black);
        cell.setOutlineThickness(1);
        City::GridCellType const*const grid = mCity->getCityGrid(); // it returns a copy of the grid
        for(unsigned int x=0; x < mCity->getGridSize().x; ++x)
            for(unsigned int y=0; y < mCity->getGridSize().y; ++y)
            {
                cell.setFillColor(sf::Color::Red);
                cell.setPosition(x*scale, y*scale);
                mWindow->draw(cell);
            }

        sf::Image gridImage = mWindow->capture();
        gridTex.loadFromImage(gridImage);
        gridSprite.setTexture(gridTex);
        targetReady=true;
    }
    mWindow->draw( gridSprite );

    // 2. Render entities
    sf::CircleShape entity;
    entity.setFillColor(sf::Color::Red);
    entity.setRadius( 5 );
    for (auto& e : mCity->getEntities())
    {
        entity.setPosition( e.position.x, e.position.y );
        mWindow->draw(entity);
    }
}

Does anyone has an idea?
Additionally, i'm using win7 x64 and compile with msvc11 x86. I tested it on a x64 linux with gcc4.7 x64 and it worked...

Pages: [1]
anything