SFML community forums

Help => Window => Topic started by: The Good King on May 30, 2012, 11:39:44 pm

Title: Window Display Background Noise with VC++ 2008 and SFML 1.6 (RESOLVED)
Post by: The Good King on May 30, 2012, 11:39:44 pm
Hello,

 I am currently working on a game project using SFML 1.6 and Visual Studio 2008, and it seems sf::Window.Display() is causing a high-pitched background noise. Console applications work just fine with no noise, as well as the other SFML classes/functions.

 If I just create a window without invoking Display, again no noise is present. Only when I add a App.Display() invocation to the main game loop this high-pitched noise appears. Here is the code producing the noise:

#include <iostream>
#include <SFML/Window.hpp>

int main (){
   sf::Window App(sf::VideoMode(640, 480, 32), "Testits");
   sf::Event Main_Event;

   while(App.IsOpened()){
      while(App.GetEvent(Main_Event)){
         if(Main_Event.Type == sf::Event::Closed){
            App.Close();
         }
      }

      App.Display();
   }

   return 0;
}

 I tried looking up this issue on Google, but it seems only post on was made mentioning this problem. Unfortunately the poster asked several questions in his one post and thus received only one answer for one of the other issues he had.
Title: Re: Window Display Background Noise with VC++ 2008 and SFML 1.6
Post by: Laurent on May 30, 2012, 11:45:25 pm
This is the expected behaviour: you don't draw anything to the window so it can show anything.

Start reading the "Graphics" tutorials if you want to see something interesting in your window.
Title: Re: Window Display Background Noise with VC++ 2008 and SFML 1.6
Post by: The Good King on May 31, 2012, 12:24:20 am
 Sorry, I may have been a bit ambiguous there with my question: I do not mean visual noise, but audible noise as in a high-pitched continuous sound. This does not change if I add images to the Window, and I notice if I re-size the window the pitch of the noise changes inversely (smaller window equals higher pitch noise).
Title: Re: Window Display Background Noise with VC++ 2008 and SFML 1.6
Post by: eXpl0it3r on May 31, 2012, 01:50:20 am
This makes no sense at all and it's clearly not SFML fault because SFML only interferes with audio if you include the audio library.
Never had anything like and never heard of anything like this...  :-\
Title: Re: Window Display Background Noise with VC++ 2008 and SFML 1.6
Post by: The Good King on May 31, 2012, 03:55:13 am
This makes no sense at all and it's clearly not SFML fault because SFML only interferes with audio if you include the audio library.

 It only occurs with SFML-made windows whether the audio library is included or not (I've tried excluding it from the project linker and everywhere else). I should also note that while manipulating the window (if I hold the window selected down while re-sizing or moving) the noise pauses until I release it. I've tried this with different sound devices (headphones, speakers) to see if it was the device causing the noise, but to no avail. If need be I'd be happy to record a video which shows my project's settings/code as well as the odd noise that results.

 If this helps, My PC is an eMachines EL1850 running Windows 7 Home Premium SP1 (64-bit) with Realtek High-Def Audio.

 Also, is it normal for playing audio to skip while the window is out of focus?
Title: Re: Window Display Background Noise with VC++ 2008 and SFML 1.6
Post by: eXpl0it3r on May 31, 2012, 01:41:47 pm
That's a hardware problem. Your GPU is generating high pitched noises.
It should also happen with other applications that max out your GPU.
To 'fix' it you just need to set a framerate limit, so your GPU won't get maxed out and you won't hear a noise.

What graphics card are you using?
Title: Re: Window Display Background Noise with VC++ 2008 and SFML 1.6
Post by: The Good King on June 01, 2012, 03:48:23 am
That's a hardware problem. Your GPU is generating high pitched noises.
It should also happen with other applications that max out your GPU.
To 'fix' it you just need to set a framerate limit, so your GPU won't get maxed out and you won't hear a noise.

What graphics card are you using?

That definitely sounds like the likely cause, as this eMachine is quite incapable when it comes to graphics.

Here is my Graphics Card info:

(http://gpuz.techpowerup.com/12/05/31/h9g.png)

EDIT: I see the Window method for setting a max frame rate, should I set the parameter to 533 or?
Title: Re: Window Display Background Noise with VC++ 2008 and SFML 1.6
Post by: eXpl0it3r on June 01, 2012, 12:45:36 pm
That definitely sounds like the likely cause, as this eMachine is quite incapable when it comes to graphics.

It doesn't have to be the incapability of a card, because the one similar case I know of uses a not so bad Nvidia card.

EDIT: I see the Window method for setting a max frame rate, should I set the parameter to 533 or?
Use window.setFramerateLimit(60);. Your monitor will probably probably only display 60 frames per second anyway. And if you don't update & draw that much it would even run with ~30fps.
Title: Re: Window Display Background Noise with VC++ 2008 and SFML 1.6 (RESOLVED)
Post by: The Good King on June 01, 2012, 10:10:19 pm
 Setting the limit to 60 definitely reduced the noise to a low grumble, which I generally hear anyways when doing anything with a window. Further lowering it to 30 reduced it a bit more, but I think it seems for the time being that it will make at least some noise unless perhaps I replace the card entirely (which I am planning on doing).

 Thanks for all your help! I think we can call this one resolved.
Title: Re: Window Display Background Noise with VC++ 2008 and SFML 1.6 (RESOLVED)
Post by: void on July 18, 2012, 10:57:26 pm
I've had exactly the same problem wint Nvidia 8800 and SFML 2.0 and limiting frame rate to 60fps solved it outright.