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

Author Topic: Crash if I set vertex color  (Read 2674 times)

0 Members and 1 Guest are viewing this topic.

asdatapel

  • Jr. Member
  • **
  • Posts: 76
    • View Profile
Crash if I set vertex color
« on: March 15, 2014, 11:35:08 pm »
This is the weirdest bug I've ever seen...

Some code:
void Graph::update(SceneData dimens) {
    for (int x = 0; x <= dimens.screenWidth; x++) {
        points[x].position = sf::Vector2f( x, (dimens.xLow+(x*dimens.step)));
        points[x].color = sf::Color::Black;
    }
}
 

and

    Graph graph;
    graph.update(dimens);

    while (window.isOpen()){

        sf::Event event;
        while (window.pollEvent(event))
        {
            if (event.type == sf::Event::Closed)
                window.close();
        }

        window.clear(sf::Color::White);
        window.draw(xAxis);
        window.draw(yAxis);
        window.draw(graph.points);
        window.display();
    }
    return 0;
}

So when I run this, the graph draw fine and stays on the screen. However, if I move my mouse for more than a second it crashes. This does NOT happen when I run it using the CodeBlocks debugger, so the only info I have about the crash is from the Windows crash dialog, which says its in ntdll.dll. It also does not happen if I comment out

points[x].color = sf::Color::Black;
 

I have no idea what moving the mouse and setting the color have to do with each other, so...yeah.
Any ideas?

math1992

  • Jr. Member
  • **
  • Posts: 77
    • View Profile
    • Email
Re: Crash if I set vertex color
« Reply #1 on: March 16, 2014, 12:55:41 am »
Effectively this is weird. With the given code, I do not see any error, maybe it's somewhere else in your code.

Another possibility is: Did you recently change your SFML version and forgot to update the library file or header?
It's an error I made when changing from SFML 2.0 to 2.1 and when running a program, it was always crashing.

asdatapel

  • Jr. Member
  • **
  • Posts: 76
    • View Profile
Re: Crash if I set vertex color
« Reply #2 on: March 16, 2014, 01:50:30 am »
No, it doesn't seem to be that. I replaced all the dlls and made sure the linked stuff was from the same SFML build.

asdatapel

  • Jr. Member
  • **
  • Posts: 76
    • View Profile
Re: Crash if I set vertex color
« Reply #3 on: March 16, 2014, 02:17:21 am »
Wow...that was bad.


Turns out my array.resize() was too small. woops. Although I am wondering why the error only occurred after a few frames...

math1992

  • Jr. Member
  • **
  • Posts: 77
    • View Profile
    • Email
Re: Crash if I set vertex color
« Reply #4 on: March 16, 2014, 03:30:06 am »
Dunno. But by curiosity, what kind of graph are you trying to draw? Function? Special curve? or anything else?

asdatapel

  • Jr. Member
  • **
  • Posts: 76
    • View Profile
Re: Crash if I set vertex color
« Reply #5 on: March 16, 2014, 06:41:30 pm »
Any. Just trying to make a generic graphing program, like Desmos.