🎉 Celebrating 25 Years of GameDev.net! 🎉

Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!

[Declaring modelview matrix as a member variable of the mainwidget class messed up the objects rendering]

Started by
1 comment, last by Alberth 1 year, 11 months ago

Hello guys,

I hope you're all doing well.

Okay so I have developed an application where I rotate an object using quaternion.

In my mainwidget.cpp, I have a paintGL() methods in which I rotate the object.

I declared the modelview matrix as a local variable in the paintGL() methods, everything seemed to work fine.

I used this modelview matrix to render a cube and two coordinate systems that are attached to it.

But when I declared it as a member variable of the class mainwidget ( in the mainwidget.h), everything became messed up: one of the coordinate system became detached from the cube.

I didn't understand what happened exactly.

Does anyone have an idea about what's happening or what's wrong with what I've done ?

Ps: I use Qt6.

Thank you all.

Advertisement

You likely made more changes than you think you made.

There is a very simple way to handle these problems. Start with the previous working version, and ADD (ie not move) the matrix to the main widget as well. If all is well, both matrices should stay in sync, so run both computations and compare results of both paths. If it deviates (too much), crash or something.

As you now have the point where things go haywire, you can use a debugger to find out why.

Once you fixed things and both computations are indeed staying in sync, you can remove the old one, and purely rely on the “new” computation instead.

This topic is closed to new replies.

Advertisement