OpenGL 'Blue Screen of Death' :(


19-02-2008 14:15:15

I Found a bug, i think. I've been developing a quick screensaver in PO, and compiling it with py2exe to produce an executable. I guess this could be a py2exe problem, but quite often ( apparently at random ) it crashes badly on exit, displaying that nasty blue-screen and restarting the PC, too quickly for me to see whats going on. When I force it to run in directX mode, everything seems fine ( including when compiled into an exe ). Also it runs fine in the interpreter in either openGL or directX. heres the code - based on the demo renderCreate:

import ogre.renderer.OGRE as ogre
import as OIS
import sys
import os
import os.path

def getPluginPath():
"""Return the absolute path to a valid plugins.cfg file."""

paths = [os.path.join(os.getcwd(), 'plugins.cfg'),
for path in paths:
if os.path.exists(path):
return path

"** Warning: Unable to locate a suitable plugins.cfg file.\n"
"** Warning: Please check your ogre installation and copy a\n"
"** Warning: working plugins.cfg file to the current directory.\n\n")
raise ogre.Exception(0, "can't locate the 'plugins.cfg' file", "")

class ApplicationFramework(object):
def __init__(self):

self.client = None
self.root = ogre.Root( getPluginPath() )
ogre.LogManager.getSingleton().setLogDetail( ogre.LoggingLevel.LL_LOW )
config = ogre.ConfigFile()
config.load('resources.cfg' )
section_iter = config.getSectionIterator()
while section_iter.hasMoreElements():
section_name = section_iter.peekNextKey()
settings = section_iter.getNext()
for item in settings:
ogre.ResourceGroupManager.getSingleton().addResourceLocation(item.value, item.key, section_name)
renList = self.root.getAvailableRenderers()
miscParams = ogre.NameValuePairList()
bOpenGL = False
for r in renList:
#print "Renederer",r.getName(), r, type(r)
if r.getName().startswith( "OpenGL" ) and bOpenGL:
self.root.setRenderSystem ( r )
miscParams["FSAA"] = "1"
#miscParams["Full Screen"] = "Yes"
miscParams["Full Screen"] = "Yes"
miscParams["VSYNC"] = "Yes"
miscParams["Video Mode"]= "1024 X 768 @ 32-bit colour"
#stdout.write("Using OpenGL renderer")
if r.getName().startswith('Direct') and not bOpenGL:
self.root.setRenderSystem ( r )
#stdout.write("Using DirectX renderer")
miscParams["VSYNC"] = "YES"
miscParams["Anti aliasing"] = "Level4"

self.renderWindow = self.root.createRenderWindow( "ScreenSaver", 1024, 768, True, miscParams )
self.sceneManager = self.root.createSceneManager(ogre.ST_GENERIC,"Test") = self.sceneManager.createCamera( "RootCam" ) = 5 (180, 300, 335),0,0)
ogre.TextureManager.getSingleton().defaultNumMipmaps = 5
self.viewport = self.renderWindow.addViewport( )
self.viewport.setBackgroundColour (ogre.ColourValue(0, 0, 0)) (0, 0, 100), 0, 0)



def createScene(self):
# Make a light
light = self.sceneManager.createLight('MainLight')
#light.setDirection( ogre.Vector3( 0, -1.0, 1.0) )
light.setPosition (10, 10, 10)

self.baseNode = self.sceneManager.getRootSceneNode().createChildSceneNode()

# create a plane
facings = [ogre.Vector3.NEGATIVE_UNIT_X, ogre.Vector3.UNIT_Z, ogre.Vector3.UNIT_X, ogre.Vector3.NEGATIVE_UNIT_Z]
for f in range(len(facings)):
facing = facings[f]
plane = ogre.Plane()
plane.normal = facing
plane.d = 100
ogre.MeshManager.getSingleton().createPlane( "__thumbnailPlane__" +str(f), ogre.ResourceGroupManager.DEFAULT_RESOURCE_GROUP_NAME,
plane, 80.0, 80.0, 1, 1, True, 1, 1.0, 1.0, ogre.Vector3.UNIT_Y )
planeEnt = self.sceneManager.createEntity( "LogoPlane"+str(f), "__thumbnailPlane__"+str(f))
planeEnt.setCastShadows( False )
planeEnt.setMaterialName( "Logo" )

# Create a node for it
n = self.baseNode.createChildSceneNode()
n.setPosition( facing * -100.0 )
n.attachObject( planeEnt )

def __del__(self):
"Clear variables, this should not actually be needed."
del self.sceneManager
del self.frameListener
del self.renderWindow
del self.root

def render(self):
return self.root.renderOneFrame()

def _createFrameListener(self):
self.frameListener = SimpleFrameListener(self.renderWindow,, self)

class SimpleFrameListener(ogre.FrameListener, ogre.WindowEventListener, OIS.KeyListener):
def __init__(self, renderWindow, camera, app):
OIS.KeyListener.__init__(self) = camera
self.renderWindow = renderWindow
self.toQuit = False = app

def setupInput(self):
windowHnd = self.renderWindow.getCustomAttributeInt("WINDOW")
self.InputManager = OIS.createPythonInputSystem([("WINDOW",str(windowHnd))])
self.Keyboard = self.InputManager.createInputObjectKeyboard( OIS.OISKeyboard, False )
self.Mouse = self.InputManager.createInputObjectMouse( OIS.OISMouse, False )
ogre.WindowEventUtilities.addWindowEventListener(self.renderWindow, self)

def keyPressed(self, arg):
self.toQuit = True

def frameStarted(self, frameEvent):
if self.toQuit:
return False

if self.Keyboard.isKeyDown(OIS.KC_ESCAPE):
return False

ms = self.Mouse.getMouseState()

if ms.X.rel or ms.Y.rel:
return False * frameEvent.timeSinceLastFrame )

return True

def __del__(self):
ogre.WindowEventUtilities.removeWindowEventListener(self.renderWindow, self)

def windowClosed(self, rw):
#Only close for window that created OIS (mWindow)
if( rw == self.renderWindow ):
if( self.InputManager ):
self.InputManager.destroyInputObjectMouse( self.Mouse )
self.InputManager.destroyInputObjectKeyboard( self.Keyboard )
if self.Joy:
self.InputManager.destroyInputObjectJoyStick( self.Joy )

def windowResized (self, rw):
[width, height, depth, left, top] = rw.getMetrics() # Note the wrapped function as default needs unsigned int's
ms = self.Mouse.getMouseState()
ms.width = width
ms.height = height

app = ApplicationFramework()
while app.render():

This problem only seems to occur when a compiled exe is produced, I'll update the drivers for my gfx card (NV Geforce 8800 GT) now and see if that solves the issue.


19-02-2008 14:28:03

It might be something to do with the order things are deleted from the C++ side being different depending on how the code is run. You don't appear to be calling "del" on the viewport but, I doubt thats the problem.


19-02-2008 15:11:33

Yeah, its a bit weird. However, looks like we're going to deploy a much simpler free customizable screensaver instead, which is a weight off my shoulders!

So if I was to insert the viewport deletion, where in the list should it appear? I'm guessing it should be the first thing deleted?


20-02-2008 13:06:33


I tried the same thing in pure C++ ogre with codeblocks, ie: skipping the config dialog and forcing an OpenGL renderer, and got the same result! a very nasty looking blue screen of death! So it looks like its a problem with Ogre itself - or perhaps my hardware setup ( although I've not noticed any problems with any other OpenGL applications on my system so far ).

I'll post on the main ogre forums and see what sinbad says.