Panda3D Manual: Graphics Buffers and Windows
<<prev | top | next>> |
We'll now describe in detail what functions are specific to buffers and windows in Panda. ## GraphicsBuffer and ParasiteBuffer Use these if you want to do off-screen rendering. You must pass `True` when you create it if you want to get a texture from it. Otherwise, there is no difference in functionality than a GraphicsOutput. The only difference between a `GraphicsBuffer` and a `ParasiteBuffer` is that a `ParasiteBuffer` does not create it own framebuffer space. To create a `ParasiteBuffer` you call `makeParasite()` from the graphics engine.
    makeParasite(host, name,sort, xSize, ySize)
The arguments `name`, `sort`, `xSize`, and `ySize` mean the same things they mean for makeWindow and makeBuffer. The new argument `host` is the GraphicsOutput object whose space in memory it will use. Any rendering done to the parasite is done to the same space in memory as its host. The function makeTextureBuffer sometimes returns a `ParasiteBuffer` for space saving reasons. It is also useful for APIs that don't support offscreen rendering. `ParasiteBuffer` objects are automatically setup for calls to `getTexture()` since their contents get cleared when `host` draws itself. ## GraphicsWindows Unlike `GraphicsBuffer` objects `GraphicsWindow` objects have a lot more functionality than `GraphicsOutput` objects. The most basic of these functions is `hasKeyboard()` and `hasPointer()` which returns whether or not this window has the focus of keyboard and pointer respectively. Any calls to keyboard or pointer functions when you do not have control of them generates an error. You can get the number of input devices for this window by using `getNumInputDevices()`. In the absence of a joystick, etc. there is usually only one input device, the 'keyboard/mouse' device. If the API you are using supports it, you can move a mouse to a certain place in the window by using `movePointer(device, x,y)` where `device` is the name of the device that holds the mouse (most probabaly 'keyboard/mouse') and `x` and `y` represent the screen position where you want to move the pointer. It returns `True` if it was succesful, and `False` otherwise. You can also ask a window if it `isFullscreen()` and if it `isClosed()`. It is important to note that a window is not automatically opened after a call to makeWindow and is not automatically closed after a call to closeWindow. In order to get the full set of properties for a given window you use the function `getProperties()`. This returns a `WindowProperties` object that holds all the information for the given screen. See the API documentation for the full functionality of the `WindowProperties` class. If you want to change these properties, use `getRequestedProperties()` and apply the proper `WindowProperties` functions. To run panda3d in full screen, rather than a window, do the following:
    wp = WindowProperties()
    wp.setFullscreen(True)
    base.win.requestProperties(wp)
Alternatively, you can modify the fullscreen configuration variable before importing `direct.directbase.DirectStart`:
    from pandac.PandaModules import loadPrcFileData
    loadPrcFileData("", """fullscreen 1
    win-size 1024 768""")

    from direct.showbase.DirectObject import DirectObject   # for event handling
    import direct.directbase.DirectStart
    import sys

    class World(DirectObject):
       def __init__(self):
          self.accept("escape",sys.exit)

    w= World()
    run()
If a requested change is not possible or invalid, you can call `getRejectedProperties()`. It returns a `WindowProperties` object that holds all of the properties that could not be changed. Windows can also send Events when the user changes a property of the window. You can get the name of this event by calling `getWindowEvent()`. Initially, all windows send the same event when changed. If you want to setup events for a certain window, use `setWindowEvent(name)` where `name` is the name of the event you want sent when this window gets changed externally. For more advanced functionality see `GraphicsWindow` in the API documentation.
<<prev | top | next>> |