def OnInit(self): #prepare and start the p3d-wx hybrid-engine mainloop self.wxevt_loop = wx.EventLoop() self.wxevt_old_loop = wx.EventLoop.GetActive() wx.EventLoop.SetActive(self.wxevt_loop) base.taskMgr.add(self._mainLoop, "MainLoopTask") #instantiate and assign the wx UI object self.win = P3dWxWindow(size=wx.Size(640, 480)) self.SetTopWindow(self.win) #show the wx window self.win.Show(True) # is essential to let make up wx window before P3D stuff self._mainLoop() #bind wx events self.win.Bind(wx.EVT_SIZE, self.onSize) self.win.Bind(wx.EVT_CLOSE, self.onClose) self.vetoActivate=False self.win.Bind(wx.EVT_ACTIVATE, self.onActivate) #open the p3d window undecorated to use in the wx frame window wp=WindowProperties().getDefault() wp.setUndecorated(True) wp.setOpen(True) wp.setParentWindow(self.win.getP3DSurface()) wp.setOrigin(0,0) wp.setForeground(True) wp.setSize(*self.win.getP3DSurfaceSize()) print ">>>opening p3dsurface" assert base.openDefaultWindow(props=wp) == True # return True
def OnInit(self): #prepare and start the p3d-wx hybrid-engine mainloop self.wxevt_loop = wx.EventLoop() self.wxevt_old_loop = wx.EventLoop.GetActive() wx.EventLoop.SetActive(self.wxevt_loop) base.taskMgr.add(self._mainLoop, "MainLoopTask") #instantiate and assign the wx UI object self.win = P3dWxWindow(size=wx.Size(640, 480)) self.SetTopWindow(self.win) #show the wx window self.win.Show(True) # is essential to let make up wx window before P3D stuff self._mainLoop() #bind wx events self.win.Bind(wx.EVT_SIZE, self.onSize) self.win.Bind(wx.EVT_CLOSE, self.onClose) self.vetoActivate = False self.win.Bind(wx.EVT_ACTIVATE, self.onActivate) #open the p3d window undecorated to use in the wx frame window wp = WindowProperties().getDefault() wp.setUndecorated(True) wp.setOpen(True) wp.setParentWindow(self.win.getP3DSurface()) wp.setOrigin(0, 0) wp.setForeground(True) wp.setSize(*self.win.getP3DSurfaceSize()) print ">>>opening p3dsurface" assert base.openDefaultWindow(props=wp) == True # return True
def setFullscreen(self, settings): """Set the window to fullscreen or windowed mode depending on the configuration in the settings variable""" props = WindowProperties() props.setFullscreen(settings.fullscreen) props.setUndecorated(settings.fullscreen) if settings.fullscreen: props.setSize(settings.windowSize[0], settings.windowSize[1]) base.win.requestProperties(props) base.taskMgr.step()
def makeGameEngine(self): ''' Creates a new game engine based on settings in GameSettings. Information for this came from here http://panda3d.org/phpbb2/viewtopic.php?t=2848''' LOG.debug("[GXMgr] Building game engine") # Temporary # TODO: Fix this props = WindowProperties() props.setFullscreen(False) props.setUndecorated(False) #screenx = int(base.pipe.getDisplayWidth()/2) - (int(self.ScreenWidth)/2) #screeny = int(base.pipe.getDisplayHeight()/2) - (int(self.ScreenHeight)/2) #self.TempScreenSizeRX = int(self.ScreenWidth) #self.TempScreenSizeRY = int(self.ScreenHeight) props.setOrigin(100,100) props.setSize(1024,768) base.win.requestProperties(props) # This was the old way that no longer works - I don't know why ## Create a new FrameBufferProperties object using our settings #fbProps = FrameBufferProperties() #fbProps.addProperties(FrameBufferProperties.getDefault()) #fbProps.setMultisamples(GameSettings().antiAlias) #fbProps.setAlphaBits(GameSettings().alphaBits) #fbProps.setDepthBits(GameSettings().colorDepth) #fbProps.setColorBits(24) # ## Create a WindowProperties object #winProps = WindowProperties( base.win.getProperties() ) #winProps.setFullscreen(GameSettings().fullscreen) #winProps.setUndecorated(GameSettings().fullscreen) #winProps.setSize(GameSettings().xRes,GameSettings().yRes) #winProps.setTitle('PSG - Project Space Game: Alpha') # ## Create the engine #base.graphicsEngine.makeOutput(base.pipe, # GraphicsPipe # 'mainGameOutput', # Name # 0, # Sort # fbProps, # FrameBufferProperties # winProps, # WindowProperties # GraphicsPipe.BFRequireWindow | GraphicsPipe.BFFbPropsOptional, # Flags # base.win.getGsg()) # GraphicsStateGaurdian ##base.openMainWindow(props=winProps, gsg=base.win.getGsg(), keepCamera=1) #base.openMainWindow() #base.graphicsEngine.openWindows() #base.win.requestProperties(winProps) ## The following code should proabably be moved somewhere else #showFPS = GameSettings().showFPS #base.setFrameRateMeter(showFPS)
def configure(self, widget, event): if self.showbase != None: x_offset, y_offset = self.translate_coordinates(widget, 0, 0) x, y = self.gtk_window.window.get_position() wp = WindowProperties().getDefault() wp.setOrigin(x + x_offset, y + y_offset) wp.setSize(self.get_allocation().width, self.get_allocation().height) wp.setUndecorated(True) # apply window property changes to the window self.showbase.win.requestProperties(wp) # for debugging purposes turn show the frame rate # to decide about the interval for calling self.step # with a gobject timeout self.showbase.setFrameRateMeter(True)