OS specific stuff in main loop

Srekel

06-12-2005 20:55:09

I'm trying to move away from startRendering() to a loop that basically does renderOneFrame() manually each frame. But it seems Windows likes to have it's messages pumped (or something), so I thought I should ask here to see if anyone knew what to do about it.

Is there a Pythonic way to implement this (I don't think it's in Ogre yet - http://www.ogre3d.org/phpBB2/viewtopic.php?t=15608)?

To explain my problem further, it seems that if I Alt-tab, I can't Alt-tab back. Which kinda sucks. ;) I might be looking for the wrong solution, if so, please tell. :)

Clay

06-12-2005 21:27:12

I'm not sure I fully understand if I understand what you are trying to do. If it's not supported in C++ Ogre then it probably doesn't work in PyOgre. With that said, the wx demo does something similar (calls renderOneFrame every loop). If you surround that code with your windowing library's render loop then it should work fine. With the windows API you need to do the dispach events loop. You could try the Win32 Extensions if that's what you are going for (but you won't have any chance to have a cross platform game with that).

I'm not sure if this helps.

When you say you cannot alt tab, do you mean that if you run one of the demos that you cannot alt-tab out of it then back in? Because that works perfectly for me under windows/directx 9 or OpenGL.

griminventions

11-01-2006 21:19:43

Was there any solution found for this? I'm at the same point now. But I definitely want a cross-platform-friendly way to do it. In my case, the window doesn't update or seem to receive any Windows events at all. :cry:

Srekel

12-01-2006 13:48:48

Nope, not really. I haven't touched the code for a while, and I haven't found any solutions.

If it is as Clay says, that there is an extension that allows you to do this for Windows, then it shouldn't be too hard I guess. As far as I understand, implementing crossplatform in Python goes something like this:


(pseudo-python)

mainGameLoop = None
import os
if "Windows" in os.version:
import win32extensions
mainGameLoop = windowsGameLoop
elif "linux" in os.version:
mainGameLoop = defaultGameLoop


### init other stuff

#start game
mainGameLoop()


I've read code similar to that in Dive Into Python, but I can't find it right now. If you haven't read the book, check it out here:
http://diveintopython.org/

griminventions

12-01-2006 15:25:18

I ended up using the root.startRendering() method, but I use only 1 framelistener and it calls my logic handlers. It's not bad at all. Same effect as a custom loop spinner, but no hassles with OS details or message pumping.

I bought that book a while back, btw. I added another free book to the PyOgre wiki called An Introduction to Python. It's very much for beginners, whereas Dive is more for intermediate level.

Thanks for the reply!

pjcast

14-01-2006 03:28:33

I don't know anything about python or pyOgre, but, the patch listed above has been applied to Ogre Cvs head (dagon). It adds void PlatformManager::messagePump( RenderWindow* rw ) to the pltform manager of Ogre core which delegates to OS specific message pumps.

Though, it currently only does anything useful with Win32 Ogre and GLX Linux Ogre, and does nothing on any other platform. This should provide a nice solution when using renderOneFrame or updating render targets yourself. I suppose it just needs to be wrapped into pyOgre. Just thought I'd post the update :D