How to Avoid Motion Blur in SDL 2 Games? - c++

I'm making a game in SDL 2 and whenever something moves on the screen, it becomes blurry. I tried to catch it on a screen shot but I don't seem to be able to. My question is: is it because of the game or because of my monitor. The blur appears both when I'm running the game on 230 FPS w/o V-Sync and when is caped at 60 with V-Sync.
PS Monitor refresh rate: 60 Hz

I've found the answer. It's because of the monitor. Probably because of the refresh rate. If I move a window on the screen I see the same blur.

Related

Qt5: Drawing some graphics on top of QOpenGLWidget

I'm building an app which uses Qt5 that aims to display a video from a digital camera (using Gstramer pipeline). Then with the help of QPainter I'm drawing some graphics on top of it (some text shapes, and icons).
The thing is that the video refresh rate is ~30 FPS, and I only need to update the graphics in ~10 FPS or so. Currently I redraw the graphics overlay for every video frame which is very wasteful in terms of CPU.
Is there a better approach in which I can re-use the overlay from the previous frame, and only update the background (the frame from the camera)?
One idea that I had was to paint the overlay into a QImage, and then just paint the image onto the QOpenGLWidget, but it just feels wrong.
Thank you...

How to prevent screen tearing with OpenGL + GLFW?

I am working on a graphical application that supports multiple operating systems and graphical back ends. The window is created with GLFW and the graphics API is chosen at runtime. When running the program on windows and using OpenGL, Vsync seems to be broken. The frame rate is locked at 60 fps, however, screen tearing artifacts appear. Following GLFW documentation, glfwSwapInterval(0); should unlock the frame rate from the default of using VSync. That works as expected. Using glfwSwapInterval(1); should lock the frame rate to match the monitors refresh rate. Not calling glfwSwapInterval(); at all should default to using VSync. While frame rate is correcly locked / unlocked using these calls, I experienced extremely interesting behaviours.
When glfwSwapInterval(); isn't called at all, VSync is set as default. But the wait for the next frame happens at the first draw call! One would think that the delay for the next frame would happen at glfwSwapBuffers(). No screen artifacts are visible what so ever.
When calling glfwSwapInterval(1);, Vsync is set and the delay for the next frame happens at glfwSwapBuffers()! That's great, however, when explicitly setting VSync, screen tearing artifacts appear.
Right now, not calling glfwSwapInterval() for using VSync seems to be a hacky solution, but :
The user wouldn't be able to disable VSync without window reconstruction,
The profiler identifies the first draw call taking way too long, as VSync wait time is somehow happening there.
I have tried fiddling with GPU driver settings and testing the code on multiple machines. The problem is persistent across machines if using windows and OpenGL.
If anyone can make any sense of this, please share, or if I am misunderstanding something, I would greatly appreciate some pointers in the right direction.
EDIT:
Some other detail: the tearing happens at a specific horizontal line. The rest of the frame seems to work properly.
After doing some more tests, it seems that everything is working as intended on integrated graphics. Correct me if I am wrong, but it looks like it is a graphics driver issue.

Pygame, when I press a key a surface blits and when I repress it it dissapears. Why such a delay making the surface disappear?

I have a surface that enters a blit stack(a stack that has items to blit to the screen) when I press a key. When I repress that key it is taken off the blit stack and disappears from the display. But whenever and only whenever I try to take it off there's a little delay in it disappearing from the pygame.display. I switched from pygame.display.update() to pygame.display.flip() and it's a bit faster but are there any other tricks to speeding this up? I'm on a slow computer btw.
You can use .convert() when your loading images if you're using external images but it would help to see some code https://www.pygame.org/docs/ref/surface.html#pygame.Surface.convert

cocos2d game becomes slow after checking notification center in IOS7

After upgraded to ios7, I found the Cocos2d application run slowly (or frame skipped) after checking the notification center.
Reproduce the problem:
Launch a cocos2d game, better with some fast moving sprites
Swipe down from the top of the screen to drop down the notifaction center, then swipe it up.
Now the game becomes like frame skipped. (slow). But after a while, or after some operation within the game, the frame speed recovers.
I tested on iphone5.
Anyone see the same problem? Any idea how it happens?
EDIT:
Since this problem only happens in rare case, I d like to close it.

QTimer for QGLWidget, incorrect drawing and timing on other machines

I have two timers to repaint a QGLWidget and determine the FPS
QObject::connect(&fpsTimer, SIGNAL(timeout()), this, SLOT(updateFps()));
fpsTimer.start(1000);
QObject::connect(&updateTimer, SIGNAL(timeout()), this, SLOT(updatePanel()));
updateTimer.start(0);
void GLPanel::updatePanel()
{
updateBuffers();
updateGL();
frameCount++;
}
I also update the vbos with new data each and every frame.
On my machine with Qt installed I get a consistent 60 FPS since the update timer will fire based off the GUI thread. I have tried setting it to update every 15ms instead of relying on the GUI thread with no luck. On other machines it ramps up to around 1000 FPS.
Another problem I am having is that my points are not drawing correctly on other machines. They are drawn in the wrong place and colors. As to whether this is related to Qt or OpenGL...?
Any ideas on what would cause this?
Other machines after clicking in the middle of the screen
Other machines
Working Dev Machine after clicking on a point
Working Dev Machine
They are both supposed to look exactly the same.
Your drawing timer is using interval of 0 ms. So the program tries to draw as fast as possible. That's why the other computers have very high frame rates. Your computer is most probably using the display driver's vsync setting. Vsync will synchronize the drawing to the refresh rate of the monitor, that's why the 60 Hz framerate. So you can limit the other computers' frame rate to 60 by using the vsync setting.
However, some old and cheap display cards do not support the vsync at all. Then you need to change the timer's interval, for example to 15 ms. It won't produce as good results as vsync, but it is much better than drawing at 1000 Hz.