Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: Moving mouse events = FPS drop. Bottleneck?  (Read 4039 times)

0 Members and 1 Guest are viewing this topic.

shadowlaw09

  • Newbie
  • *
  • Posts: 3
    • View Profile
Moving mouse events = FPS drop. Bottleneck?
« on: April 04, 2010, 03:26:49 am »
Hi, firstly the code:

Code: [Select]
#include <iostream>
#include <sstream>
#include <SFML/Graphics.hpp>
using namespace std;

template <class T>
inline static string toString (const T& t) {
  std::stringstream ss;
  ss << t;
  return ss.str();
}

int main() {
  sf::RenderWindow App(sf::VideoMode(800, 600, 32), "SFML OpenGL");
  sf::Clock Clock;

  glClearColor(0.f, 0.f, 0.f, 0.f);
  glMatrixMode(GL_PROJECTION);
  glLoadIdentity();
  gluPerspective(90.f, 1.f, 1.f, 500.f);

  sf::Event Event;
  sf::String fpsDisplay;  
  fpsDisplay.SetFont(sf::Font::GetDefaultFont());
  fpsDisplay.Move(10,10);

  App.SetFramerateLimit(60);
  App.UseVerticalSync(true);

  while (App.IsOpened()) {
    fpsDisplay.SetText("FPS: " + toString(1/App.GetFrameTime()));
    //cout << (1/App.GetFrameTime()) << endl;

    while (App.GetEvent(Event)) {
      //Irrelevant. An empty event polling will still cause a drop
      if (Event.Type == sf::Event::Closed) {App.Close();}
    }
    App.SetActive();
    glClear(GL_COLOR_BUFFER_BIT);
    App.Draw(fpsDisplay);
    App.Display();
  }
  return EXIT_SUCCESS;
}


Now, if I move my mouse wildly around in the window (just moving the mouse, not pressing anything), the frame rate drops from 60 to ~35-45. Is there a way around this or to fix this?

I don't want my game slowing down cause the user accidentally moves the mouse across the screen lol

Setup: SFML 1.5, VS Studio 2008, C++, Windows 7 64Bit

Thank you very much :)

Meseira

  • Newbie
  • *
  • Posts: 15
    • View Profile
Moving mouse events = FPS drop. Bottleneck?
« Reply #1 on: April 04, 2010, 04:38:03 am »
I use Ubuntu 9.04. I have tested your code but the frame rate stays close to 60... the same when the mouse is moving.

Your problem is strange. Did you try to lauch solely your program without any other program? Is there a difference if you put App.UseVerticalSync(false) ?

shadowlaw09

  • Newbie
  • *
  • Posts: 3
    • View Profile
Moving mouse events = FPS drop. Bottleneck?
« Reply #2 on: April 07, 2010, 02:00:24 am »
hmmm ... confused ... :roll:

I stopped development for a while after my previous post. Then only recently I have decided to upgrade to SFML 1.6 (Thank you Laurent :D). I tried running the same program again, and this time no problem.

So ... all is good.
Thx Meseira :D

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Moving mouse events = FPS drop. Bottleneck?
« Reply #3 on: April 07, 2010, 08:17:00 am »
Quote
Then only recently I have decided to upgrade to SFML 1.6 (Thank you Laurent :D). I tried running the same program again, and this time no problem.

This is wonderful, I released SFML 1.6 yesterday and it already solved 2 unexpected bugs :lol:
Laurent Gomila - SFML developer

Meseira

  • Newbie
  • *
  • Posts: 15
    • View Profile
Moving mouse events = FPS drop. Bottleneck?
« Reply #4 on: April 07, 2010, 11:07:44 am »
Quote from: "Laurent"
This is wonderful, I released SFML 1.6 yesterday and it already solved 2 unexpected bugs :lol:


You don't know how lucky you are, boy :)

shadowlaw09

  • Newbie
  • *
  • Posts: 3
    • View Profile
Moving mouse events = FPS drop. Bottleneck?
« Reply #5 on: April 08, 2010, 01:23:50 am »
hahaha I know :D

and once again, Thank you so much Laurent. SFML has been really great. Love it :D