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

Pages: 1 [2]
16
General / Is this a bad programming habit?
« on: December 15, 2014, 07:25:21 pm »
Hello, I would like to ask whether this habit is good or bad, I have read FAQ about using global variables, but I'm not sure does this situation is exactly the same bad as this described in wiki.

Let's assume I'm trying to write a player class, so i have a cpp and hpp file. In cpp file I write something like this:

#include "Player.hpp"

constexpr sf::Vector2f playerPos{100.0,300.0};

void Player::Player()
{
        player.setPosition(playerPos);
        ...
        ...
}

Someone may ask, why I'm doing something like this. Well when I have 6-7 parameters it's very nice to have them in one place, so configuration takes 3 seconds instead of 30, because I don't need to look for them. What should I do if this is not the best solution? I was thinking of static variable, but I'm not sure about this.

17
Network / Re: Network Chat Example - strange issue
« on: December 15, 2014, 06:02:06 pm »
The code on the wiki is questionable to say the least - note the wiki contains user contributions and are usually not written by anyone of the SFML Team - but it makes sense that your application consumes a lot of CPU time, because in the DoStuff function, which gets called in a separate thread, there's a while loop that iterates as fast as possible, meaning as fast as your CPU can go, meaning high CPU usage.

One of the main issue in this example is that the TCP socket always sends messages, even if it's not needed, it'll be sending and receiving the last message as fast as possible.
And then there's the whole global variables stuff etc.

Well, i have forgotten that non-staff code may be a little bad to learn from :) Thanks for help, all of you.

18
Network / Re: Network Chat Example - strange issue
« on: December 15, 2014, 04:55:26 pm »
Can you please post the code you are using (Complete and minimal) as well as the specs for your laptop?

Code of the program is the same as on the wiki.
Information about laptop:
ASUS X53S with NVIDIA GeForce GT 540M, Intel Core i5-2430M 2,4 GHz clock, operating system is Windows 7 Ultimate with SP1

19
Network / Network Chat Example - strange issue
« on: December 15, 2014, 04:00:41 pm »
Hello folks, I wanted to test network library from SFML, so I thought it would the best to use some kind of example. I have chosen code from this wiki site: https://github.com/SFML/SFML/wiki/Source:-Network-Chat-Example
It was working perfectly for my desktop computer and I didn't have any problems with it. After that I have taken code from the same website and tried to run the app on my laptop, but a very strange issue appeared.
Almost instantaneously I had 40% CPU usage, just from it and nothing showed up.

I did some test which showed that is it some kind of problem with compiling or linking, because I used this bugged exe app  on my desktop computer and it still didn't work.

The huge problem is:
1. I'm using the same IDE on both computers, it's Code::Blocks with MinGW compilator.
2. Computers have the same SFML files and the same operating systems.
3. Compiling process on my laptop doesn't return any errors or warnings.

Link to this bugged application: http://www.speedyshare.com/Ftye2/Network-app.rar

Have anybody seen something like this?

PS. I know my description may be a little chaotic, if you need anything more, please just tell me.

Pages: 1 [2]
anything