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 - moyk

Pages: [1]
1
The error code translates into 0xC00000FD which is connected to a stack overflow error. Try using a std::vector instead of an array, so the data is dynamically allocated on the heap instead of the stack.

Good to know! I think maybe that explains some of the warnings visual studio is giving me lmao

2
The array is also VERY large to be calling draw() on for each square - this is usually a source for a bottleneck and keeping the number of times you call draw() to a minimum is preferable. To do this you could look at using a vertex array https://www.sfml-dev.org/tutorials/2.5/graphics-vertex-array.php

Thank you! That's exactly what I needed!

Now if only I could figure out what's wrong with the rest of my code...

3
Hi! So I'm a java developer, trying to slowly rip off the garbage collection training wheels by moving to some languages closer to C, so forgive me If I'm doing something incredibly stupid. I'm trying to write a fluid dynamics simulation (Google Mike Ash fluid dynamics, he wrote this crazy article detailing the process)

Long story short; I'm trying to draw the cells to the screen with their density being the alpha channel of the color like this:

   sf::RenderWindow window(sf::VideoMode(N*SCALE, N*SCALE), "Fluid");
   while (window.isOpen()) {
      sf::Event event;
      while (window.pollEvent(event)) {
         if (event.type == sf::Event::Closed) window.close();
      }

      step(fs);

      window.clear(sf::Color::Black);
      sf::RectangleShape square(sf::Vector2f(SCALE, SCALE));
      square.setFillColor(sf::Color(125, 0, 255));

      int x = 0;
      int y = 0;
      for (float d : fs.density) {
         square.setPosition(x*SCALE,y*SCALE);
         float alpha = d * 255;
         square.setFillColor(sf::Color(125, 0, 255, alpha));
         window.draw(square);
         x++;
         if (x % N == 0) {
            x = 0;
            y++;
         }
      }
      
      window.display();

changing the color of the square for some reason results in that crash "exited with code -1073741571" that normally happens when the window gets destroyed in some ungraceful fashion. I should note that that array is 65536 (256^2) elements big, so I'm sure I should probably be doing something completely differently here, I'm just at a loss as to what.

Pages: [1]
anything