Using Panda3D with GTK as a simple renderer

I wanted to create a program sort of like Open3Mod, except cross platform to use as a 3D model viewer and format exchange tool. I was hoping to use GTK for my GUI, and Panda3D as my renderer to save myself some time on implementation.

I found this forum topic which looks like someone has been able to render a Panda3D window inside of a GTK application:

There are several code snippets, but just refer to the first one.

With that said, I noticed that when I try to drag the window around my desktop the window-drag stutters horribly. For that matter the entire desktop stutters horribly. Would anyone have an idea where to start looking for the cause of that problem? I don’t mind doing the legwork, but if someone can offer some ideas to help point me in the right direction, that’d be great.

I’m working on Linux Mint 18.3, I have an 8 core ryzen and a GTX 970 with latest NVidia proprietary drivers.

I’m using Panda3D version 1.10.0.dev14



It would help to find out what is actually happening while the window is being moved. Is Python code being run that does something to the Panda window? Is Panda doing any rendering? (It may help to enable debug messaging in your Config.prc file via notify-level-display debug)

An updated observation on the behavior I’m seeing. What’s really happening is that when I pick the panda-gtk window to drag it, it doesn’t actually move until I stop moving the mouse cursor. Then the window appears in the new location instantly. When I’m running this panda-gtk window, all the applications on my desktop behave the same way - until I close the panda-gtk window, then everything returns to normal. I think the reason I thought I saw stuttering before is that I don’t always move the mouse in a single fluid motion. It basically moves the window any time the pointer slows down enough to be “stopped”.

Here is a pastebin link to the log:

[Let me know if it doesn’t work, first time I’ve tried pastebin]

For what its worth, it doesn’t log much after initializing, and really nothing while moving the window.



OK another update. I have a feeling there is some issue here related to interaction between GTK and Panda3D.

The way the program works, it sets up a python function sort of like this one below in the taskMgr to process GTK events:

def gtk_iteration(self, *args, **kw):
    """ We handle the gtk events in this task added to Panda TaskManager """
    print 'entering gtk_iteration {}'.format(str(self.event_id))
    self.event_id += 1


    print 'exiting gtk_iteration'
    return Task.cont

What I find happens if I move any window at all, this function doesn’t appear to even enter. So for example, if I start this program and then also start any other program on my desktop, say calculator, and move calculator continuously the output spam above stops. And the last thing I see is “exiting gtk_iteration”, so I dont think it should be stuck in GTK.

But basically it’s stuck somewhere, what I find is that when I stop moving the other window, the log spam resumes. I put it in a spreadsheet, and I’m fairly certain the taskMgr is blocked, because there is never a gap in the number sequence (unless the taskMgr can queue?)

I know this is getting outside things strictly Panda3D, but any ideas would be appreciated :slightly_smiling_face:



Perhaps you could give some code we could run to try and reproduce the problem?

It might be that Panda is trying to do too much while the window is being moved, and that this is causing delays in calling the GTK event loop.

Hey Thanks for your response!

I’ve played with it a bit, and found that your guess is probably right. If I stick a sleep in the task which updates GTK, then the other applications seem to perform better as well, and I can even drag the panda window smoothly. I tried an experiment with a video game I own running in a window, and it more or less does the same thing - other desktop apps performance is sticky.

I’m thinking now that this is just expected behavior for running an app this way on the desktop - forcing GTK to check its events at 30fps or more is pathologically bad for desktop performance.

With that said, I’m going to try to use GTK signals to cause panda to update instead. I’m making a desktop app so that will probably be enough for most purposes. It really only needs to update if the user wants to change the view.