root.renderOneFrame() produces a black screen with nothing on it

236 views
Skip to first unread message

sjl

unread,
Oct 20, 2009, 7:48:06 PM10/20/09
to Python Ogre Developers
I am on Ubuntu 9.04, using pythonOgre1-6, nvidia 180 drivers.
I am not using the SampleFramework.

Everything seems to work well with self.root.startRendering().
However, when I replace self.root.startRendering() with

while(self.root.renderOneFrame()):
pass

I get a black screen with nothing rendered on it. The window does
respond to keyboard and mouse and there are no error messages.

Have anyone seen this before?

I can reproduce the problem with basic tutorial 6. Here's the code,
comment out self.root.startRendering() and uncomment the loop below
it in startRenderLoop to see the behavior.

import ogre.renderer.OGRE as ogre
import ogre.io.OIS as OIS
import ogre.gui.CEGUI as CEGUI

import time

class ExitListener(ogre.FrameListener):

def __init__(self, keyboard):
ogre.FrameListener.__init__(self)
self.keyboard = keyboard

def frameStarted(self, evt):
self.keyboard.capture()
return not self.keyboard.isKeyDown(OIS.KC_ESCAPE)

class Application(object):

def go(self):
self.createRoot()
self.defineResources()
self.setupRenderSystem()
self.createRenderWindow()
self.initializeResourceGroups()
self.setupScene()
self.setupInputSystem()
self.setupCEGUI()
self.createFrameListener()
self.startRenderLoop()
self.cleanUp()

def createRoot(self):
self.root = ogre.Root()
pass

def defineResources(self):
cf = ogre.ConfigFile()
cf.load("resources.cfg")
seci = cf.getSectionIterator()
while seci.hasMoreElements():
secName = seci.peekNextKey()
settings = seci.getNext()
for item in settings:
typeName = item.key
archName = item.value
ogre.ResourceGroupManager.getSingleton
().addResourceLocation(archName, typeName, secName)


def setupRenderSystem(self):
if not self.root.restoreConfig() and not
self.root.showConfigDialog():

return False


def createRenderWindow(self):
self.root.initialise(True, "Tutorial 6 Render Window")
pass

def initializeResourceGroups(self):
ogre.TextureManager.getSingleton().setDefaultNumMipmaps(5)
ogre.ResourceGroupManager.getSingleton
().initialiseAllResourceGroups()
pass

def setupScene(self):
self.sceneManager = self.root.createSceneManager
(ogre.ST_GENERIC, "Default SceneManager")
self.camera = self.sceneManager.createCamera("Camera")
self.camera.position = (0, 150, -500)
self.camera.lookAt((0,0,0))
self.camera.nearClipDistance = 5
self.viewPort = self.root.getAutoCreatedWindow().addViewport
(self.camera)
self.sceneManager.ambientLight = (1.0, 1.0, 1.0)

# Setup a mesh entity and attach it to the root scene node.
self.ent1 = self.sceneManager.createEntity ('Robot',
'robot.mesh')
self.node1 = self.sceneManager.getRootSceneNode
().createChildSceneNode ('RobotNode')
self.node1.attachObject (self.ent1)

# Setup a second mesh entity as a child node.
self.ent2 = self.sceneManager.createEntity ('Robot2',
'robot.mesh')
self.node2 = self.node1.createChildSceneNode ('RobotNode2',
(50, 0, 0))
self.node2.attachObject (self.ent2)


def setupInputSystem(self):
windowHandle = 0
renderWindow = self.root.getAutoCreatedWindow()
windowHandle = renderWindow.getCustomAttributeInt("WINDOW")
paramList = [("WINDOW", str(windowHandle))]
self.inputManager = OIS.createPythonInputSystem(paramList)
try:
self.keyboard = self.inputManager.createInputObjectKeyboard
(OIS.OISKeyboard, False)
# self.mouse = self.inputManager.createInputObjectMouse
(OIS.OISMouse, False)
# self.joystick =
self.inputManager.createInputObjectJoyStick(OIS.OISJoyStick, False)
except Exception, e:
raise e

pass

def setupCEGUI(self):
sceneManager = self.root.getSceneManager("Default
SceneManager")
renderWindow = self.root.getAutoCreatedWindow()

# CEGUI setup
self.renderer = CEGUI.OgreCEGUIRenderer(renderWindow,
ogre.RENDER_QUEUE_OVERLAY, False, 3000, sceneManager)
self.system = CEGUI.System(self.renderer)
pass

def createFrameListener(self):
self.exitListener = ExitListener(self.keyboard)
self.root.addFrameListener(self.exitListener)

pass

def startRenderLoop(self):
self.root.startRendering()
#while(self.root.renderOneFrame()):
#time.sleep(0.1)
#pass

def cleanUp(self):
self.inputManager.destroyInputObjectKeyboard(self.keyboard)
# self.inputManager.destroyInputObjectMouse(self.mouse)
# self.inputManager.destroyInputObjectJoyStick(self.joystick)
OIS.InputManager.destroyInputSystem(self.inputManager)
self.inputManager = None

del self.renderer
del self.system

del self.exitListener
del self.root

pass


if __name__ == '__main__':
try:
ta = Application()
ta.go()
except ogre.OgreException, e:
print e

Andy Miller

unread,
Oct 20, 2009, 8:33:35 PM10/20/09
to python-ogre...@googlegroups.com
Have a look at Demo_Basic and Demo_Spinner in the demos/ogre directory as these both use the renderOneFrame method..  You will note that you have to 'pump' WindowEventUtilities on each frame as well..

Andy

2009/10/21 sjl <sushil...@gmail.com>

sjl

unread,
Oct 21, 2009, 8:51:15 PM10/21/09
to Python Ogre Developers
Thanks much. It was the WindowEventUtilities that needed pumping.
The following works well:

weu = ogre.WindowEventUtilities()
weu.messagePump()
while(self.root.renderOneFrame()):
weu.messagePump()
time.sleep(0.0001)

Cheers
--sushil

On Oct 20, 5:33 pm, Andy Miller <nzmill...@gmail.com> wrote:
> Have a look at Demo_Basic and Demo_Spinner in the demos/ogre directory as
> these both use the renderOneFrame method..  You will note that you have to
> 'pump' WindowEventUtilities on each frame as well..
> Andy
>
> 2009/10/21 sjl <sushil.lo...@gmail.com>

sjl

unread,
Oct 21, 2009, 8:51:41 PM10/21/09
to Python Ogre Developers
Thanks much. It was the WindowEventUtilities that needed pumping.
The following works well:

weu = ogre.WindowEventUtilities()
weu.messagePump()
while(self.root.renderOneFrame()):
weu.messagePump()
time.sleep(0.0001)

Cheers
--sushil

On Oct 20, 5:33 pm, Andy Miller <nzmill...@gmail.com> wrote:
> Have a look at Demo_Basic and Demo_Spinner in the demos/ogre directory as
> these both use the renderOneFrame method..  You will note that you have to
> 'pump' WindowEventUtilities on each frame as well..
> Andy
>
> 2009/10/21 sjl <sushil.lo...@gmail.com>
Reply all
Reply to author
Forward
0 new messages