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

Author Topic: Procedurally generated starfield  (Read 14076 times)

0 Members and 1 Guest are viewing this topic.

Dreded

  • Newbie
  • *
  • Posts: 3
    • View Profile
Re: Procedurally generated starfield
« Reply #15 on: September 01, 2013, 02:34:33 am »
Sorry meant to include the error...
Assertion failed: x + width <= m_size.x, file D:\developpement\sfml\sfml\src\SFML\Graphics\Texture.cpp, line 324

Ixrec

  • Hero Member
  • *****
  • Posts: 1241
    • View Profile
    • Email
Re: Procedurally generated starfield
« Reply #16 on: September 01, 2013, 03:02:47 am »
Wait, you're getting the error on the x axis?  Wtf...

Well I guess you can try this:
starsImage.create(screenDimensions.x+4, screenDimensions.y, sf::Color::Black);

If that doesn't work try changing my other hotfixes so they apply to the x axis instead of the y axis.

paxsentry

  • Newbie
  • *
  • Posts: 1
    • View Profile
    • Email
Re: Procedurally generated starfield
« Reply #17 on: June 04, 2017, 08:36:18 pm »
Just a little addition, these guards can help you to run just fine (windows build)

void Starfield::drawStarField(sf::Texture& texture)
{
    for (auto it = smallStars.begin(); it != smallStars.end(); ++it)
    {
        auto xCoord = it->getXPos();
        auto yCoord = it->getYPos();

        if ((xCoord > 0 && xCoord < 1280) && (yCoord > 0 && yCoord < 960))
            texture.update(smallStarImage, it->getXPos(), it->getYPos());
    }

    for (auto it = mediumStars.begin(); it != mediumStars.end(); ++it)
    {
        auto xCoord = it->getXPos();
        auto yCoord = it->getYPos();

        if ((xCoord > 0 && xCoord < 1279) && (yCoord > 0 && yCoord < 959))
            texture.update(mediumStarImage, it->getXPos(), it->getYPos());
    }

    for (auto it = largeStars.begin(); it != largeStars.end(); ++it)
    {
        auto xCoord = it->getXPos();
        auto yCoord = it->getYPos();

        if ((xCoord > 0 && xCoord < 1276) && (yCoord > 0 && yCoord < 956))
            texture.update(largeStarImage, it->getXPos(), it->getYPos());
    }
}