Stuttering cause by change in position of the view.
-
Hello,
(Forewarning: I'm fairly new to coding and even newer to Qt) I'm currently working on a project with a friend. We are building a game using Qt Widgets Application. The game involves moving a character (QGrpahicsRectItem) across the screen. We have a "platform" (another rect item) which the character "walks" upon. We recently added a feature so that as the character moves horizontally the view tracks him using the centerOn() command. For my friend who is using linux, this works beautifully. For me however, on windows, as soon as I start to move to the right so that the view has to track me, a weird stuttering occurs. This stuttering only occurs when the view is being moved. So if I stand still and just jump up (there is a function for that), it runs normally. But anytime the the view's position is changed, the stuttering occurs.
What do I mean by stuttering? Essentially it looks like my character is moving in slow motion. It's as if the program is sleeping a split second before every interval of motion.
And again, this only happens on my computer.
Any guidance towards fixing this would be highly appreciated =)
Thanks in advance.
-
Thanks for the reply!
My drivers are up to date. I actually use my computer for some gaming and have no issues at all (Mostly R6 Siege on low end graphics). When I first ran into this issue I was certain it was just to much information for my computer to be handling for whatever reason. But then my friend with the lower end laptop in terms of GPU and CPU ran it without any issue, I began to wonder if it was a Qt/windows setting that was affecting Qt.
I tried searching all over various forums for a similar issue and the closest I got was some issues with VSync needing to be turned off, though that trail lead me no where as well.
I truly don't think this is a problem with the quality of my computer as I have put it through far worse and it performed far better.
Any other ideas?
-
@Pistrix
Since I can't imagine this is "supposed to happen", do you have a simple, cut-down code case for us to see, just in case you're doing something "odd" in your code?(Also, do you happen to have access to a different Windows PC to test it on, to see whether the behaviour does have something to do with your setup?)
-
Alrighty, I don't have another windows computer to test it on at the moment, though I might be able to this weekend. As far as a cut down code goes, I don't have one and the program is rather large with quite a few headers. The best I could come up with linking you the github.
I can try and explain how the program works a bit clearer. We have a rect item that is of class type Character. There are member functions MoveRight, MoveLeft, MoveUP (jump), and gravity(). Each of these functions is linked using slots and timers. We have one timer that is linked to each of these functions. By pressing "D" or "A" bool for moving left and right are activated so that the Characters position is updated. To keep the view centered on the character, all I did is have the centerOn(Character) command added to the gravity member function so that everytime gravity is called (hence also moving left and right) the view follows. And it works in the sense that the view does track the Character only with a delay.
It's as if the view position and the Character position can't both be updates so there is pause as it switches from updating the view and updating the character position.
Let me know if you want the github link.