I did not bring a gift
In most (?) cultures, a person above you in a hierarchical structure should not expect gifts from you, especially if his income is significantly higher than yours - unless he is doing you some great favor. A dinner invitation is not a great favor meriting a gift from you.
Do you think these behaviors were rude?
The only part which may have been rude is "talking shop" in the presence of his family. And even that depends on subtle aspects of your relationship with your supervisor and whether or not he hinted he might be interested in seeing the result.
It couldn't have been significantly rude, because you only did it at the end of the meeting. So, either a bit rude or not rude at all.
I was very clumsy.
Whether you had been rude or not, you weren't clumsy. You're berating yourself well beyond what your actions merit, even under the worst possible interpretation.
Could I write something as thank you letter and apologize about not being prepared?
That sounds like too much. But when you next meet, you can tell him you what you feel; you can even say you're sorry (whether that's merited or not). He will likely tell you that it's all fine and say there's nothing for you to be sorry about.
If you're not meeting him for a long time, then it's ok to send a thank-you email for the gift (assuming it's not completely trivial gift like some chocolate); and you can tell him how you feel as a secondary point in such a message - but don't over-dramatize things.
I do not know what should I do right now. I am feeling so embarrassed.
Consider some breathing exercising, or light physical activity, to reduce tension. Until you next meet your Professor.