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

Pages: [1] 2
1
Network / Re: Http error 1001 in multithreaded application
« on: November 18, 2013, 04:38:48 pm »
Hmm... I must have overlooked that SFML defines its own HTTP status codes...

In that case you can probe for that code and connect your own sf::TcpSocket in the thread that fails and see what error code the socket returns from the connect. It's basically what sf::Http does anyway except that you have access to the return value of the connect() call.

Chances are, since you issue so many requests on separate connections to the same server, either it doesn't want to process any more of your requests, or a firewall kicked you out. If you are using your own server for testing it is a different story...

I'm testing on a public server. It has always been cooperative and returns status code 200, if a connection can be established. Maybe it imposes a limit on simultaneous connections? In any case, analyzing the socket sounds like a good idea.

2
Network / Re: Http error 1001 in multithreaded application
« on: November 18, 2013, 02:25:43 pm »
I'm using PPL so I don't have to write my own code to safely divide the queries between several threads.

By the way, error 1001 is sf::Http::Response::ConnectionFailed

http://sfml-dev.org/documentation/2.1/classsf_1_1Http_1_1Response.php

3
Network / Http error 1001 in multithreaded application
« on: November 17, 2013, 03:16:24 pm »
I'm using the Parallel Patterns Library to run several http clients in parallel in this manner:

concurrency::parallel_for_each(begin(queries), end(queries), [&](const std::pair<std::string, std::string> &p){
      try
      {
         sf::Http http("some_host_name");
         sf::Http::Request request("some_path_name" + p.second);
         auto response = http.sendRequest(request, sf::seconds(30));
         if (response.getBody().find(found_substring) != std::string::npos)
         {
            results.push(p.first);
         }
                        // some debug info gathering stuff omitted for brevity
      }
      catch (const std::exception &e)
      {
         // error handling code omitted for brevity
      }

   });


Note that both the "queries" and "results" are concurrency safe containers from the PPL.

The problem is that sometimes the above code gets stuck (it doesn't crash, just doesn't work properly). I've done some error checking and I've observed the following:
The problem is related to the SFML http client, which returns error code 1001 and times out. Once the problem occurs, the same thread will continue reporting error 1001 from its http clients. The problem takes some time to appear, usually after several thousand queries have been processed successfully.

Any tips on how I can diagnose and solve the problem?

4
Graphics / Re: sf::Lines type and anti-aliasing
« on: July 21, 2013, 03:01:49 pm »
http://imgur.com/kOYiVcd

and a code example that reproduces it

#include <SFML/Graphics.hpp>

int main()
{
   sf::ContextSettings settings;
   settings.antialiasingLevel = 4;
   sf::RenderWindow window(sf::VideoMode(250, 250), "SFML", sf::Style::Default, settings);
   window.setVerticalSyncEnabled(true);


   sf::VertexArray line(sf::Lines, 2);
   line[0].color = sf::Color::Black;
   line[1].color = sf::Color::Black;
   line[0].position = sf::Vector2f(50, 50);
   line[1].position = sf::Vector2f(200, 50);

   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(line);

      window.display();

   }

    return 0;
}


Maximizing the window will cause the line to be rendered correctly, at least on my computer.

5
Graphics / sf::Lines type and anti-aliasing
« on: July 21, 2013, 12:37:16 pm »
I'm using sf::VertexArray line(sf::Lines, 2) in my program and they appear as a "stretched" line that is wider than one pixel when anti-aliasing is turned on, whereas according to the documentation, they should always be one pixel wide.

Is there any way to have anti-aliasing turned on while avoiding the visual "stretching" of the lines?

6
Graphics / Re: How do I extract x and y from a Vector2f?
« on: May 04, 2013, 01:15:05 pm »
What exactly is confusing?

The <T>'s. And the <U>

7
Graphics / Re: How do I extract x and y from a Vector2f?
« on: May 04, 2013, 01:06:42 pm »
It looks like you should read more about C++, because accessing the X and Y components is really straightforward.
sf::Vector2f vector;
float x = vector.x;
float y = vector.y;

Thanks. I understand the concepts but the info on http://www.sfml-dev.org/documentation/2.0/classsf_1_1Vector2.php is just confusing for me.

8
Graphics / How do I extract x and y from a Vector2f?
« on: May 04, 2013, 01:02:52 pm »
sprite.getPosition() returns the x and y values of its position as Vector2f


Similarly, texture.GetSize() returns width and height as Vector2u.

I don't understand how I can extract the x and y values from Vector2f. How do I work with these?

9
General discussions / Re: Thank You
« on: May 01, 2013, 11:11:02 am »
I agree. SFML 2.0 is awesome and the tutorials are very good as well.

10
General / Re: Code::Blocks linker problems
« on: April 30, 2013, 10:56:41 am »
I found the problem

GCC 4.7 TDM (SJLJ) - 64 bits does not work on my Windows 7 x64.
GCC 4.7 TDM (SJLJ) - 32 bits works.

11
General / Re: Code::Blocks linker problems
« on: April 30, 2013, 10:29:11 am »
Can you provide the full error, since they can provide more details to what goes wrong. :)


Sure. The code that's causing these is copy pasted from the tutorial page.

Quote
||=== Tetris2, Debug ===|
obj\Debug\main.o||In function `main':|
E:\Coding\Tetris2\main.cpp|5|undefined reference to `sf::String::String(char const*, std::locale const&)'|
E:\Coding\Tetris2\main.cpp|5|undefined reference to `sf::VideoMode::VideoMode(unsigned int, unsigned int, unsigned int)'|
E:\Coding\Tetris2\main.cpp|5|undefined reference to `sf::RenderWindow::RenderWindow(sf::VideoMode, sf::String const&, unsigned int, sf::ContextSettings const&)'|
E:\Coding\Tetris2\main.cpp|6|undefined reference to `sf::CircleShape::CircleShape(float, unsigned int)'|
E:\Coding\Tetris2\main.cpp|7|undefined reference to `sf::Color::Green'|
E:\Coding\Tetris2\main.cpp|7|undefined reference to `sf::Shape::setFillColor(sf::Color const&)'|
E:\Coding\Tetris2\main.cpp|15|undefined reference to `sf::Window::close()'|
E:\Coding\Tetris2\main.cpp|12|undefined reference to `sf::Window::pollEvent(sf::Event&)'|
E:\Coding\Tetris2\main.cpp|18|undefined reference to `sf::Color::Color(unsigned char, unsigned char, unsigned char, unsigned char)'|
E:\Coding\Tetris2\main.cpp|18|undefined reference to `sf::RenderTarget::clear(sf::Color const&)'|
E:\Coding\Tetris2\main.cpp|19|undefined reference to `sf::RenderStates::Default'|
E:\Coding\Tetris2\main.cpp|19|undefined reference to `sf::RenderTarget::draw(sf::Drawable const&, sf::RenderStates const&)'|
E:\Coding\Tetris2\main.cpp|20|undefined reference to `sf::Window::display()'|
E:\Coding\Tetris2\main.cpp|9|undefined reference to `sf::Window::isOpen() const'|
E:\Coding\Tetris2\main.cpp|23|undefined reference to `sf::RenderWindow::~RenderWindow()'|
E:\Coding\Tetris2\main.cpp|5|undefined reference to `sf::RenderWindow::~RenderWindow()'|
E:\Coding\Tetris2\main.cpp|23|undefined reference to `sf::RenderWindow::~RenderWindow()'|
obj\Debug\main.o||In function `ZN2sf11CircleShapeD1Ev':|
E:\Coding\Tetris2\..\SFML-2.0\include\SFML\Graphics\CircleShape.hpp|41|undefined reference to `vtable for sf::CircleShape'|
E:\Coding\Tetris2\..\SFML-2.0\include\SFML\Graphics\CircleShape.hpp|41|undefined reference to `vtable for sf::CircleShape'|
E:\Coding\Tetris2\..\SFML-2.0\include\SFML\Graphics\CircleShape.hpp|41|undefined reference to `sf::Shape::~Shape()'|
||=== Build finished: 20 errors, 0 warnings (0 minutes, 0 seconds) ===|

12
General / Re: Code::Blocks linker problems
« on: April 30, 2013, 10:25:10 am »
It's not possible to input "sfml-graphics" into the "link libraries" field in my Code::Blocks (only into the "other linker options"). The "link libraries" field only accepts a direct path to the file.
Nope, that's just you thinking it can't take anything else. Don't use the ... button to choose a file, but simply enter sfml-graphics. ;)

You're right. It's weird but it's possible: http://imgur.com/a/pHV1X

May I suggest pointing this out in the tutorial? I first thought my version of Code::Blocks was different than the one in the tutorial screenshot.

Unfortunately that still doesn't fix the problem. What else could I be doing wrong?

13
General / Re: Code::Blocks linker problems
« on: April 30, 2013, 10:10:46 am »
The "link libraries" settings are not the same as in the tutorial. Compare the screenshots.

It's not possible to input "sfml-graphics" into the "link libraries" field in my Code::Blocks (only into the "other linker options"). The "link libraries" field only accepts a direct path to the file.

And the libraries to link are different between debug and release configurations. This is even written in red in the tutorial.

Like this? http://imgur.com/a/fIQvN
Unfortunately that doesn't work either.

14
General / Code::Blocks linker problems
« on: April 30, 2013, 09:47:18 am »
I've followed the instructions on http://www.sfml-dev.org/tutorials/2.0/start-cb.php but I'm getting an "undefined reference" error for every SFML in the code. I'm trying to use static libraries. What am I doing wrong?

This is how my Code::Blocks and the project folder are set up: http://imgur.com/a/laDFM

I'm on Win 7 and using the SFML-2.0-windows-gcc-4.7-tdm-64bits release.

Edit: speaking of different release versions, I have both "libgcc_s_sjlj-1.dll" and "libgcc_s_dw2-1.dll" in my MingW which came with Code::Blocks.


15
General / Re: I still can't create a window after reading the tutorial
« on: April 23, 2013, 03:45:58 pm »
The purpose of a nightly build is to provide a built version. You don't have to compile it, you already have the binaries.

You're right, the dll files are in the bin folder.

Pages: [1] 2
anything