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

Pages: [1]
1
Window / Re: Set icon from resource
« on: August 31, 2013, 03:42:25 am »
Thanks for the answers.

I haven't researched how to embed an image in the binary with gcc yet, but I know that at least the icon can be stored as a C array and obviously compiled into the binary, then it's easier to get the address.

Searching for set icon on this forum it seems it's a largely unsolved problem, cross platform but even just windows (embedded resource).

If nothing quick and simple comes up I won't spend too much time on that for linux.

Edit: if anybody wonder, here is where and how I used it for Windows: https://github.com/shazbits/wiretap/blob/master/src/src/ProfileViewer/main.cpp

2
Window / Set icon from resource
« on: August 31, 2013, 12:28:23 am »
Visual Studio let us import an icon into the resource and when building it the icon will be used for the program's icon (the actual executable icon) but in order to set the icon on the window title bar (left side) and for when we do alt-tab, we need to set it at runtime.

I didn't find a way to set the icon with sfml with icon being in the resources (not loading an external .ico or .png file).

So I've done this for windows:

#ifdef WIN32
    HICON hIcon = LoadIcon(hInstance, MAKEINTRESOURCE(IDI_ICON1));
    if(hIcon)
    {
        SendMessage(windowgetSystemHandle(), WM_SETICON, ICON_BIG, (LPARAM)hIcon);
    }
#endif

Is there a way to do this with SFML? I don't know if it can be done with Linux, I could add a #else and do it for Linux but I'd rather not if SFML can or will do it.

Any word?

Thanks!

3
Network / Re: Issue with non-blocking socket and getRemoteAddress()
« on: August 20, 2013, 01:23:04 am »
Thanks for the info.

I am now able to use non-blocking connect and blocking send.
I put my project (a real-time profiler/viewer) on github: https://github.com/shazbits/wiretap

Let me know if you want to list it somewhere. I added your libs (and license) to my repo, I hope that's ok with you.

Finally if you think something's not right with the way I connect/send, I'd appreciate any comments.
https://github.com/shazbits/wiretap/blob/326ef668afb0f434495f1945ee4459fb21a1ab0d/src/src/Profiler/WiretapProfiler.cpp#L57

4
Network / Issue with non-blocking socket and getRemoteAddress()
« on: August 19, 2013, 02:56:53 am »
I have an issue with socket::connect() and socket::getRemoteAddres() in non-blocking mode (SFML 2.1 32bits Windows 7).

I'm trying to use a non-blocking socket on my client, because I don't want it to block on connect() when there is no host listening on the chosen port, as it's called every frame.

Basically my update loop is something like this:

while (isRunning)
{
    Update();
    SendData();
}

void SendData()
{
    // try to connect
    // if connected then do some socket.send()
}
 

The problem is that getRemoteAddress doesn't return None, even though it is not connected.
The documentation states: It the socket is not connected, this function returns sf::IpAddress::None.
http://www.sfml-dev.org/documentation/2.1/classsf_1_1TcpSocket.php#a7904ca6ab9e018021e305a3aeb7a1b9a

Here is how to reproduce the problem/bug:
sf::TcpSocket socket;
sf::Socket::Status socketStatus = sf::Socket::Error;
while (true)
{
        if (socketStatus != sf::Socket::Done)
        {
                socket.disconnect();
                socket.setBlocking(false);
                socketStatus = socket.connect(viewerIPAddress, viewerPort);
                sf::IpAddress remoteAddr = socket.getRemoteAddress();
                printf("ip: %s\n", remoteAddr.toString().c_str()); // if it couldn't connect it should be None
        }
}
 

Not that this is not exactly the code I'm running, I don't have a while loop trying to connect again and again, it's done only once per SendData() call, but this simpler example showcases the problem.

I was relying on what documentation says to know if my socket was connected (so I could send the data or try again to connect, without blocking the execution of the program).

Thanks for the help.

Pages: [1]
anything