diff --git a/direct/src/showbase/ShowBase.py b/direct/src/showbase/ShowBase.py index a43196e679..a16e81e38c 100644 --- a/direct/src/showbase/ShowBase.py +++ b/direct/src/showbase/ShowBase.py @@ -17,7 +17,7 @@ import AngularEulerIntegrator import ClockObject import Transitions import Loader - +import time globalClock = ClockObject.ClockObject.getGlobalClock() @@ -396,7 +396,17 @@ class ShowBase: self.oobeVis.reparentTo(self.camera) self.oobeMode = 1 - + def screenshot(self, namePrefix='screenshot'): + # Get the current date and time to uniquify the image (down to the second) + date = time.ctime(time.time()) + # Get the current frame count to uniqify it even more + frameCount = globalClock.getFrameCount() + # Replace spaces with dashes because unix does not like spaces in the filename + date = date.replace(' ', '-') + date = date.replace(':', '-') + imageName = (namePrefix + '-' + date + '-' + str(frameCount) + '.pnm') + self.notify.info("Taking screenshot: " + imageName) + takeSnapshot(self.win, imageName) def run(self): self.taskMgr.run()