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

Pages: [1]
1
Window / Speed issues with Joystick event processing
« on: August 16, 2011, 10:05:09 pm »
Hello,

I'm still having this weird problem where joystick polling drastically slows down the game (huge fps drop, stuttering, etc). I'm using the basic while loop to poll events, nothing too fancy.
The problem disappears if I comment out the ProcessJoystickEvents() call in WindowImpl.cpp

Chances are it's a problem on my side, but I'm wondering if anyone had experienced the same issue and maybe knows how to resolve it.

Here's what I get after quickly profiling a minimal sfml app:
http://img703.imageshack.us/img703/9109/sleepyk.png

I'm using win7, lastest SFML2, VS2010

Thanks

2
Window / Weird stuttering and freezing
« on: July 28, 2011, 12:13:39 pm »
Hi,

My window doesn't seem to refresh correctly  (stuttering / freezing) when I try to display some sprites.
The strange thing is that it only happens when there is between about 2442 and 2507 sprites.
Even stranger, the problem disappears when I use Fraps or some other overlay to display the fps count.

Here's the code:
Code: [Select]

#include <SFML/Graphics.hpp>
#include <vector>

//#define SPRITES 2442
#define SPRITES 2500
//#define SPRITES 2507

#define WIDTH 1024
#define HEIGHT 768

inline float frand(const float min, const float max)
{
    return ((float(rand()) / float(RAND_MAX)) * (max - min)) + min;
}

void main()
{
sf::RenderWindow window(sf::VideoMode(WIDTH, HEIGHT), "Bench");

sf::Image image;
image.LoadFromFile("sprite1.png"); // 64x64
image.SetSmooth(true);
float originX = image.GetWidth() / 2.0f;
float originY = image.GetHeight() / 2.0f;

std::vector<sf::Sprite*> sprites;
for(int i = 0; i < SPRITES; ++i)
{
sf::Sprite* sprite;
sprite = new sf::Sprite(image);
sprite->SetBlendMode(sf::Blend::Alpha);
sprite->SetPosition(frand(0, WIDTH), frand(0, HEIGHT));
sprite->SetOrigin(originX, originY);
sprites.push_back(sprite);
}

sf::Clock timer;
unsigned int lastTime = 0, frameTime = 0, delta = 0;
float step = 1000.0f / 60;

sf::Sprite* sprite;
sf::Event evt;
while (window.IsOpened())
{
while (window.PollEvent(evt))
{
if (evt.Type == sf::Event::Closed)
window.Close();
}
frameTime = timer.GetElapsedTime();
delta = frameTime - lastTime;
if (delta >= step)
{
window.Clear();
lastTime = frameTime;
for (std::vector<sf::Sprite*>::iterator it = sprites.begin(), itEnd = sprites.end(); it != itEnd; ++it)
{
sprite = *it;
sprite->Rotate(1);
window.Draw(*sprite);
}
window.Display();
}
}

}


I doesn't look like it's graphics related because the animation "continues" during the freezes.

I'm using SMLF2, static libs, VS 2010, Win7, ATI graphics card.

Thanks in advance  :)

Pages: [1]