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.


Topics - DashWave

Pages: [1]
1
Network / [SOLVED]Difference between remote port and bind port
« on: December 15, 2013, 01:46:44 am »
I'm trying to implement UDP hole punching to allow peer-to-peer connections but I don't understand exactly how UDP endpoints work. Specifically, what is the difference between the the_port in

sf::Packet packet;
sf::IpAddress ip;
unsigned short the_port;
socket.receive(packet, ip, the_port);
 

and

socket.bind(the_port);
 

2
System / [SOLVED] Strange sf::Clock issue with SFML 2.1
« on: December 13, 2013, 02:55:42 pm »
Hey guys,

I've always used sf::Clock to get the delta time between frames to allow for frame-independent movement. On a new project of mine, however, I have encountered some odd behaviour:

        sf::Clock frameClock;
        double timeLast = 0.1;
        while (window.isOpen())
        {
                //This code works correctly.
                const double timeNow = frameClock.getElapsedTime().asMilliseconds() / 16.66666667;
                const double delta = timeNow - timeLast;
                timeLast = timeNow;
 

        sf::Clock frameClock;
        while (window.isOpen())
        {
                //This code works incorrectly; "delta" is all over the place and my sprites move at visibly different
                //speeds at different times.
                const double delta = frameClock.restart().asMilliseconds() / 16.66666667;
 

This is very strange considering I've used the latter method in other projects where it worked correctly. The only difference between this project and the others is, in the others, frameClock is a member of a class.

I looked at the source of sf::Clock on git and it appears to be doing exactly what the former method does. I tried to debug using VS2012 but I don't have pdb files for SFML and I'm unsure as to how to acquire them although I presume one has to compile from source.

For my entire main.cpp, see http://pastebin.com/xK46pjyC.

3
Graphics / [SOLVED] Static RenderWindow Access Vialation
« on: September 07, 2013, 07:19:37 pm »
Hey,

I've been using SFML to create a game. I've decided to make the main game class completely static because passing around parent classes in C++ is somewhat messy. This does, of course, mean that all classes have access to the game class even if they don't deserve it but I'm willing to make that sacrifice.

When I tried to add a static RenderWindow to the class, however, I started getting access violations at 0x00000004 on the initializer line in the implementation of the class.

Here's the code necessary to reproduce the problem:
StaticClass.h:
#include <SFML/Graphics.hpp>

class StaticClass
{
public:
        static sf::RenderWindow renderWindow;
};
StaticClass.cpp:
#include "StaticClass.h"

sf::RenderWindow StaticClass::renderWindow;

Is this a bug? I don't get an access violation if I replace the class of the static member variable; I changed it to sf::Text and everything worked.

Thanks.

Edit: I'm using SFML 2.1

Pages: [1]
anything