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

Pages: 1 ... 5 6 [7]
91
I've been using SFML for my project in Xcode and it was beautiful so I decided to port it to windows with Code::Blocks. Few road bumps but it now works fairly flawlessly.
Of course now I have 2 different versions on different OSes in different IDEs. I'd like to keep Xcode on my Mac for the semantic highlighting (which is quite amazing) which Code::Blocks sadly lacks.
Of course I can just copy my changed source files, move them with a flash drive and replace old files but that's a tad tedious.
I'm thinking of setting up a repository to keep source files the same for my stationary PC and for when I'm out in the world programming on my Mac laptop. (Granted Code::Blocks can handle repositories)

How would you handle this situation, or if you have, how did you manage?

92
General / Re: Strangest sf::sleep bug
« on: January 10, 2013, 12:27:17 am »
Ah good idea.
I just re-did the code to print out the average FPS every 101 frames.
Code: [Select]
#include <SFML/Graphics.hpp>
#include <iostream>

const float fps = 60;

float frames = 0;

int main (int argc, const char * argv[])
{
sf::RenderWindow window(sf::VideoMode(800, 600), "Server");
float fpsRatio = 1.0;
sf::Clock fpsClock;
while (window.isOpen())
{
window.clear();
window.display();

        sf::sleep(sf::seconds(1.0f/fps));

        frames += 1;
        if (frames > 100) {
            std::cout << "FPS: " << (1.0/(fpsClock.restart().asSeconds()/frames)) << " vs " << fps <<  std::endl;
            frames = 0;
        }
}

    return EXIT_SUCCESS;
}

Here's the output:
Quote
Child process PID: 2976

[debug][New Thread 2976.0xfb0]
[debug][New Thread 2976.0x13c4]
[debug][New Thread 2976.0x13b0]
[debug][New Thread 2976.0x414]
[debug][New Thread 2976.0x314]
[debug][New Thread 2976.0x1324]
[debug]FPS: 59.8948 vs 60
[debug]FPS: 60.2346 vs 60
[debug]FPS: 60.2345 vs 60
[debug]FPS: 60.2345 vs 60
[debug]FPS: 60.2345 vs 60
[debug]FPS: 60.2345 vs 60
[debug]FPS: 60.2346 vs 60
[debug]FPS: 60.2345 vs 60
[debug]FPS: 60.2294 vs 60
[debug]FPS: 40.4556 vs 60
[debug]FPS: 31.9996 vs 60
[debug]FPS: 32.0001 vs 60
[debug]FPS: 31.9991 vs 60
[debug]FPS: 31.9993 vs 60
The output looked fantastic, until I realized Google Chrome was open. Closed it and FPS dropped back down to the usual.

Perhaps there's just something wrong with my computer.  :-\

93
General / Re: Strangest sf::sleep bug
« on: January 09, 2013, 10:15:49 am »
I've attached the source below. Here's the code without having to unzip the source:
Code: [Select]
#include <SFML/Graphics.hpp>
#include <iostream>

const float fps = 60;
const bool autoFpsFixer = false;

int main (int argc, const char * argv[])
{
sf::RenderWindow window(sf::VideoMode(800, 600), "Server");
float fpsRatio = 1.0;
sf::Clock fpsClock;
while (window.isOpen())
{
window.clear();
window.display();

        sf::sleep(sf::seconds(1.0f/fps*fpsRatio));

        float fpsAmount = (1.0/fpsClock.restart().asSeconds());
        if (autoFpsFixer) { //Enable to make the fps fix itself
            fpsRatio -= 1.0-(fpsAmount/fps);
        }

        std::cout << "FPS: " << fpsAmount << " vs " << fps << " sleep amount: " << 1.0f/fps*fpsRatio <<  std::endl;
}

    return EXIT_SUCCESS;
}

This code produces the output:
Quote
[debug]FPS: 32.0051 vs 60 sleep amount: 0.0166667
[debug]FPS: 31.9969 vs 60 sleep amount: 0.0166667
[debug]FPS: 31.9795 vs 60 sleep amount: 0.0166667
[debug]FPS: 32.0215 vs 60 sleep amount: 0.0166667
[debug]FPS: 31.9714 vs 60 sleep amount: 0.0166667
[debug]FPS: 31.9724 vs 60 sleep amount: 0.0166667
[debug]FPS: 32.0544 vs 60 sleep amount: 0.0166667
[debug]FPS: 31.9959 vs 60 sleep amount: 0.0166667
[debug]FPS: 32.0041 vs 60 sleep amount: 0.0166667
[debug]FPS: 32 vs 60 sleep amount: 0.0166667
[debug]FPS: 31.999 vs 60 sleep amount: 0.0166667
[debug]FPS: 31.9785 vs 60 sleep amount: 0.0166667
[debug]FPS: 31.9918 vs 60 sleep amount: 0.0166667
[debug]FPS: 32.0184 vs 60 sleep amount: 0.0166667
FPS is the fps I'm getting, sleep amount is the amount it should be sleeping to be 60fps but isn't.

[attachment deleted by admin]

94
General / Strangest sf::sleep bug
« on: January 09, 2013, 09:04:25 am »
In my program I couldn't help noticing that the server was lagging behind the client. I have the server hosted on my pc machine and client on my mac.
CPU usage of the PC was 1% so I decided to track the main logic loop's FPS.
I have the sleep method set to 60 frames per second, but using the sf::clock I was able to see that the method was only running at half the speed. 30 frames per second.
I couldn't figure what in my code would cause such a delay. Then I got the idea to clock the sleep method itself. Turns out the sleep method was sleeping for twice as long as it was told to.

So I opened Google Chrome and went searching for an answer. I looked back at my debug console, and suddenly it was spitting out 60 fps instead of the 30. Perplexed, I closed Google Chrome and boom, back down to 30fps.
I re-opened Google Chrome, 60 fps. Closed Google Chrome, 30 fps.

I am unsure about the correlation between Google Chrome and the sf::sleep function... but right now it's an easy fix by just doubling my FPS to 120 so that it runs at 60fps (with Google Chrome closed).

My sleep code:
Code: [Select]
sf::sleep(sf::seconds(1.0f/fps));fps is a const float defined as 60.

If I'm not doing something blatantly wrong, I can provide further information. (Video, full source code, ect)

Edit:
On the plus side this bug has allowed me to make a stabilization formula that generates an FPS ratio dynamically to heighten or lower the sleep amount to produce an equal time step for the physics simulation. Thus keeping the client and server in sync wether the sleep function is malfunctioning or the burden of a heavy load is overtaking.

95
SFML projects / Re: SFGUI
« on: January 08, 2013, 09:44:08 am »
This looks amazing. I was thinking of using GUIchan for my game but this certainly seems much better due to the fact that it's SFML native!

But now I just found TGUI, and I'm stricken. I don't know which to use....

96
SFML projects / Re: Isometric Hexagonal Tile Map
« on: January 08, 2013, 09:41:30 am »
That looks way sweet. The style reminds me of an old MMO I use to play:


I love how your tiles merge seamlessly and you can vary the height.

97
General / Re: Can't get SFML with Code::Blocks working
« on: January 08, 2013, 09:35:57 am »
:D Thanks, worked perfectly!

I love all the work you've done. SFML is amazing. I ported my project from Processing to SFML C++ and it runs 20* faster! And I think SFML is easier too.

98
General / Can't get SFML with Code::Blocks working
« on: January 08, 2013, 07:42:48 am »
I've done the tutorial for setting up SFML with Code::Blocks 3 times already and I've ran into many issues. Most I was able to fix by downloading the latest Mingw and setting the compiler to it.

However I can now build static and dynamic builds of the example project perfectly, but when I run it, it just says the application stopped working.
Here's the output:
Quote
Checking for existence: C:\Users\Matthew\Desktop\SFML\Game Client\bin\Debug\Game Client.exe
Executing: "C:\Users\Matthew\Desktop\SFML\Game Client\bin\Debug\Game Client.exe"  (in C:\Users\Matthew\Desktop\SFML\Game Client\.)
Process terminated with status -1073741819 (0 minutes, 2 seconds)
In fact, stepping line-by-line in debugger mode shows it gets to the first line:
Quote
sf::RenderWindow window(sf::VideoMode(200, 200), "SFML works!");
Before stopping.

Any ideas?

Pages: 1 ... 5 6 [7]
anything