Panda3D
Public Member Functions | Static Public Member Functions

GraphicsEngine Class Reference

This class is the main interface to controlling the render process. More...

Inheritance diagram for GraphicsEngine:
ReferenceCount MemoryBase

List of all members.

Public Member Functions

 GraphicsEngine (Pipeline pipeline)
 Creates a new GraphicsEngine object.
 GraphicsEngine ()
 Creates a new GraphicsEngine object.
bool extractTextureData (Texture tex, GraphicsStateGuardian gsg)
 Asks the indicated GraphicsStateGuardian to retrieve the texture memory image of the indicated texture and store it in the texture's ram_image field.
 flipFrame ()
 Waits for all the threads that started drawing their last frame to finish drawing, and then flips all the windows.
bool getAutoFlip ()
 Returns the current setting for the auto-flip flag.
PandaLoader getDefaultLoader ()
 Returns the Loader object that will be assigned to every GSG created with this GraphicsEngine.
int getNumWindows ()
 Returns the number of windows (or buffers) managed by the engine.
bool getPortalCull ()
 Returns the current setting for the portal culling flag.
int getRefCount ()
 Returns the current reference count.
GraphicsThreadingModel getThreadingModel ()
 Returns the threading model that will be applied to future objects.
GraphicsOutput getWindow (int n)
 Returns the nth window or buffers managed by the engine, in sorted order.
list getWindows ()
bool isEmpty ()
 Returns true if there are no windows or buffers managed by the engine, false if there is at least one.
GraphicsOutput makeBuffer (GraphicsOutput host, string name, int sort, int x_size, int y_size)
 Syntactic shorthand for make_output.
GraphicsOutput makeBuffer (GraphicsStateGuardian gsg, string name, int sort, int x_size, int y_size)
 Syntactic shorthand for make_output.
GraphicsOutput makeOutput (GraphicsPipe pipe, string name, int sort, FrameBufferProperties const fb_prop, WindowProperties const win_prop, int flags, GraphicsStateGuardian gsg, GraphicsOutput host)
 Creates a new window (or buffer) and returns it.
GraphicsOutput makeOutput (GraphicsPipe pipe, string name, int sort, FrameBufferProperties const fb_prop, WindowProperties const win_prop, int flags)
 Creates a new window (or buffer) and returns it.
GraphicsOutput makeOutput (GraphicsPipe pipe, string name, int sort, FrameBufferProperties const fb_prop, WindowProperties const win_prop, int flags, GraphicsStateGuardian gsg)
 Creates a new window (or buffer) and returns it.
GraphicsOutput makeParasite (GraphicsOutput host, string name, int sort, int x_size, int y_size)
 Syntactic shorthand for make_buffer.
 openWindows ()
 Fully opens (or closes) any windows that have recently been requested open or closed, without rendering any frames.
 ref ()
 Explicitly increments the reference count.
 removeAllWindows ()
 Removes and closes all windows from the engine.
bool removeWindow (GraphicsOutput window)
 Removes the indicated window or offscreen buffer from the set of windows that will be processed when render_frame() is called.
 renderFrame ()
 Renders the next frame in all the registered windows, and flips all of the frame buffers.
 resetAllWindows (bool swapchain)
 Resets the framebuffer of the current window.
 setAutoFlip (bool auto_flip)
 Set this flag true to indicate the GraphicsEngine should automatically cause windows to sync and flip as soon as they have finished drawing, rather than waiting for all of the windows to finish drawing first so they can flip together.
 setDefaultLoader (PandaLoader loader)
 Sets the Loader object that will be assigned to every GSG created with this GraphicsEngine.
 setPortalCull (bool value)
 Set this flag true to indicate the GraphicsEngine should start portal culling.
 setThreadingModel (GraphicsThreadingModel const threading_model)
 Specifies how future objects created via make_gsg(), make_buffer(), and make_window() will be threaded.
 syncFrame ()
 Waits for all the threads that started drawing their last frame to finish drawing.
bool testRefCountIntegrity ()
 Does some easy checks to make sure that the reference count isn't completely bogus.
bool testRefCountNonzero ()
 Does some easy checks to make sure that the reference count isn't zero, or completely bogus.
bool unref ()
 Explicitly decrements the reference count.

Static Public Member Functions

static TypeHandle getClassType ()
static GraphicsEngine getGlobalPtr ()

Detailed Description

This class is the main interface to controlling the render process.

There is typically only one GraphicsEngine in an application, and it synchronizes rendering to all all of the active windows; although it is possible to have multiple GraphicsEngine objects if multiple synchronicity groups are required.

The GraphicsEngine is responsible for managing the various cull and draw threads. The application simply calls engine->render_frame() and considers it done.


Constructor & Destructor Documentation

GraphicsEngine ( Pipeline  pipeline)

Creates a new GraphicsEngine object.

The Pipeline is normally left to default to NULL, which indicates the global render pipeline, but it may be any Pipeline you choose.

Creates a new GraphicsEngine object.

The Pipeline is normally left to default to NULL, which indicates the global render pipeline, but it may be any Pipeline you choose.


Member Function Documentation

bool extractTextureData ( Texture  tex,
GraphicsStateGuardian  gsg 
)

Asks the indicated GraphicsStateGuardian to retrieve the texture memory image of the indicated texture and store it in the texture's ram_image field.

The image can then be written to disk via Texture.write(), or otherwise manipulated on the CPU.

This is useful for retrieving the contents of a texture that has been somehow generated on the graphics card, instead of having been loaded the normal way via Texture.read() or Texture.load(). It is particularly useful for getting the data associated with a compressed texture image.

Since this requires a round-trip to the draw thread, it may require waiting for the current thread to finish rendering if it is called in a multithreaded environment. However, you can call this several consecutive times on different textures for little additional cost.

If the texture has not yet been loaded to the GSG in question, it will be loaded immediately.

The return value is true if the operation is successful, false otherwise.

flipFrame ( )

Waits for all the threads that started drawing their last frame to finish drawing, and then flips all the windows.

It is not usually necessary to call this explicitly, unless you need to see the previous frame right away.

bool getAutoFlip ( )

Returns the current setting for the auto-flip flag.

See set_auto_flip.

static TypeHandle getClassType ( ) [static, inherited]

Reimplemented in NodeReferenceCount, TypedReferenceCount, VirtualFile, VirtualFileComposite, VirtualFileMount, VirtualFileMountMultifile, VirtualFileMountSystem, VirtualFileSimple, HTTPChannel, VirtualFileHTTP, VirtualFileMountHTTP, VrpnClient, ClientBase, PGItem, PandaNode, PGButton, PGTop, PGEntry, PGMouseWatcherBackground, MouseWatcherRegion, PGMouseWatcherParameter, TypedWritableReferenceCount, PGVirtualFrame, PGSliderBar, PGScrollFrame, PGWaitBar, FilterProperties, AudioSound, AudioManager, BamCacheRecord, CallbackObject, CachedTypedWritableReferenceCount, ClockObject, CopyOnWriteObject, NodeCachedReferenceCount, PythonCallbackObject, LerpFunctor, IntLerpFunctor, FloatLerpFunctor, SimpleLerpFunctorPoint2, SimpleLerpFunctorPoint3, SimpleLerpFunctorPoint4, SimpleLerpFunctorVBase2, SimpleLerpFunctorVBase3, SimpleLerpFunctorVBase4, SimpleLerpFunctorVec2, SimpleLerpFunctorVec3, SimpleLerpFunctorVec4, IntQueryLerpFunctor, FloatQueryLerpFunctor, SimpleQueryLerpFunctorPoint2, SimpleQueryLerpFunctorPoint3, SimpleQueryLerpFunctorPoint4, SimpleQueryLerpFunctorVBase2, SimpleQueryLerpFunctorVBase3, SimpleQueryLerpFunctorVBase4, SimpleQueryLerpFunctorVec2, SimpleQueryLerpFunctorVec3, SimpleQueryLerpFunctorVec4, MultiLerpFunctor, LerpBlendType, EaseInBlendType, EaseOutBlendType, EaseInOutBlendType, NoBlendType, Lerp, AutonomousLerp, ButtonThrower, DataNode, MouseInterfaceNode, DriveInterface, MouseSubregion, MouseWatcherGroup, MouseWatcher, Trackball, Transform2SG, TextFont, DynamicTextPage, Texture, DynamicTextFont, GeomTextGlyph, Geom, StaticTextFont, TextNode, ParametricCurve, CubicCurveseg, PiecewiseCurve, HermiteCurve, NurbsCurve, RopeNode, SheetNode, BoundingVolume, GeometricBoundingVolume, FiniteBoundingVolume, BoundingBox, BoundingHexahedron, BoundingLine, BoundingPlane, BoundingSphere, OmniBoundingVolume, DisplayRegionBase, GraphicsOutputBase, GraphicsStateGuardianBase, InternalName, GeomVertexArrayFormat, GeomVertexFormat, GeomVertexArrayData, GeomVertexArrayDataHandle, VertexTransform, TransformTable, TransformBlendTable, VertexSlider, SliderTable, GeomVertexData, AnimateVerticesRequest, AsyncTask, GeomPrimitive, TextureStage, GeomLines, GeomLinestrips, GeomPoints, GeomTriangles, GeomTrifans, GeomTristrips, Material, Lens, OrthographicLens, MatrixLens, PerspectiveLens, Shader, TextureReloadRequest, UserVertexSlider, UserVertexTransform, VideoTexture, AsyncTaskBase, AsyncTaskChain, AsyncTaskManager, AsyncTaskPause, AsyncTaskSequence, EventStoreValueBase, EventStoreTypedRefCount, Event, PointerEventList, PythonTask, Thread, ExternalThread, MainThread, PythonThread, WindowHandle.OSHandle, WindowHandle, OSHandle, DisplayRegion, GraphicsDevice, GraphicsPipe, GraphicsStateGuardian, StereoDisplayRegion, GraphicsOutput, GraphicsBuffer, GraphicsWindow, NativeWindowHandle, ParasiteBuffer, AnalogNode, ButtonNode, DialNode, MouseAndKeyboard, TrackerNode, VirtualMouse, CollisionHandler, CollisionSolid, CollisionNode, CollisionEntry, CollisionHandlerEvent, CollisionHandlerHighestEvent, CollisionHandlerPhysical, CollisionHandlerFloor, CollisionHandlerGravity, CollisionHandlerPusher, CollisionHandlerFluidPusher, CollisionHandlerQueue, CollisionDSSolid, CollisionBox, CollisionSphere, CollisionInvSphere, CollisionRay, CollisionLine, CollisionPlane, CollisionPolygon, CollisionParabola, CollisionFloorMesh, CollisionSegment, CollisionTube, CollisionVisualizer, CharacterJoint, MovingPartMatrix, CharacterSlider, MovingPartScalar, CharacterVertexSlider, JointVertexTransform, Character, PartBundleNode, CharacterJointBundle, PartBundle, CharacterJointEffect, RenderEffect, AnimGroup, AnimBundle, AnimBundleNode, PartGroup, AnimControl, AnimChannelBase, AnimChannelACMatrixSwitchType, AnimChannelACScalarSwitchType, AnimChannelMatrixDynamic, AnimChannelMatrixXfmTable, AnimChannelScalarDynamic, AnimChannelScalarTable, AnimPreloadTable, BindAnimRequest, ModelLoadRequest, MovingPartBase, MovingPartACMatrixSwitchType, MovingPartACScalarSwitchType, FFMpegTexture, FrameRateMeter, SceneGraphAnalyzerMeter, MovieTexture, NodeVertexTransform, RigidBodyCombiner, PipeOcclusionCullTraverser, CullTraverser, MovieVideo, MovieVideoCursor, MovieAudio, MovieAudioCursor, InkblotVideo, InkblotVideoCursor, FfmpegVideo, FfmpegVideoCursor, FfmpegAudio, FfmpegAudioCursor, MicrophoneAudio, UserDataAudio, UserDataAudioCursor, TransformState, RenderAttrib, RenderModeAttrib, TexMatrixAttrib, RenderState, AlphaTestAttrib, AntialiasAttrib, RenderEffects, TransparencyAttrib, AudioVolumeAttrib, AuxBitplaneAttrib, AuxSceneData, BillboardEffect, LensNode, Camera, PlaneNode, ClipPlaneAttrib, ColorAttrib, ColorBlendAttrib, ColorScaleAttrib, ColorWriteAttrib, CompassEffect, CullBinAttrib, CullFaceAttrib, GeomNode, DecalEffect, DepthOffsetAttrib, DepthTestAttrib, DepthWriteAttrib, EventStorePandaNode, Fog, FogAttrib, Light, LightAttrib, LightRampAttrib, PandaLoader, MaterialAttrib, ModelFlattenRequest, ModelNode, ModelRoot, TextureAttrib, TexGenAttrib, PolylightNode, PolylightEffect, ShaderInput, ShaderAttrib, ShowBoundsEffect, TexProjectorEffect, ScissorEffect, PosLerpFunctor, HprLerpFunctor, ScaleLerpFunctor, ColorLerpFunctor, PosHprLerpFunctor, HprScaleLerpFunctor, PosHprScaleLerpFunctor, ColorScaleLerpFunctor, PortalNode, RescaleNormalAttrib, ScissorAttrib, ShadeModelAttrib, StencilAttrib, UvScrollNode, LightNode, AmbientLight, CallbackNode, LightLensNode, DirectionalLight, LODNode, FadeLODNode, PointLight, SelectiveChildNode, SequenceNode, Spotlight, SwitchNode, RecorderBase, MouseRecorder, RecorderController, and SocketStreamRecorder.

PandaLoader getDefaultLoader ( )

Returns the Loader object that will be assigned to every GSG created with this GraphicsEngine.

See GraphicsStateGuardian.set_loader().

static GraphicsEngine getGlobalPtr ( ) [static]
int getNumWindows ( )

Returns the number of windows (or buffers) managed by the engine.

bool getPortalCull ( )

Returns the current setting for the portal culling flag.

int getRefCount ( ) [inherited]

Returns the current reference count.

GraphicsThreadingModel getThreadingModel ( )

Returns the threading model that will be applied to future objects.

See set_threading_model().

GraphicsOutput getWindow ( int  n)

Returns the nth window or buffers managed by the engine, in sorted order.

list getWindows ( )
bool isEmpty ( )

Returns true if there are no windows or buffers managed by the engine, false if there is at least one.

GraphicsOutput makeBuffer ( GraphicsOutput  host,
string  name,
int  sort,
int  x_size,
int  y_size 
)

Syntactic shorthand for make_output.

This is the preferred way to create an offscreen buffer, when you already have an onscreen window or another buffer to start with. For the first parameter, pass an existing GraphicsOutput object, e.g. the main window; this allows the buffer to adapt itself to that window's framebuffer properties, and allows maximum sharing of resources.

GraphicsOutput makeBuffer ( GraphicsStateGuardian  gsg,
string  name,
int  sort,
int  x_size,
int  y_size 
)

Syntactic shorthand for make_output.

This flavor accepts a GSG rather than a GraphicsOutput as the first parameter, which is too limiting and disallows the possibility of creating a ParasiteBuffer if the user's graphics hardware prefers that. It also attempts to request specific framebuffer properties and may therefore do a poorer job of sharing the GSG between the old buffer and the new.

For these reasons, this variant is a poor choice unless you are creating an offscreen buffer for the first time, without an onscreen window already in existence. If you already have an onscreen window, you should use the other flavor of make_buffer() instead, which accepts a GraphicsOutput as the first parameter.

GraphicsOutput makeOutput ( GraphicsPipe  pipe,
string  name,
int  sort,
FrameBufferProperties const  fb_prop,
WindowProperties const  win_prop,
int  flags,
GraphicsStateGuardian  gsg,
GraphicsOutput  host 
)

Creates a new window (or buffer) and returns it.

The GraphicsEngine becomes the owner of the window, it will persist at least until remove_window() is called later.

If a null pointer is supplied for the gsg, then this routine will create a new gsg.

This routine is only called from the app thread.

GraphicsOutput makeOutput ( GraphicsPipe  pipe,
string  name,
int  sort,
FrameBufferProperties const  fb_prop,
WindowProperties const  win_prop,
int  flags,
GraphicsStateGuardian  gsg 
)

Creates a new window (or buffer) and returns it.

The GraphicsEngine becomes the owner of the window, it will persist at least until remove_window() is called later.

If a null pointer is supplied for the gsg, then this routine will create a new gsg.

This routine is only called from the app thread.

GraphicsOutput makeOutput ( GraphicsPipe  pipe,
string  name,
int  sort,
FrameBufferProperties const  fb_prop,
WindowProperties const  win_prop,
int  flags 
)

Creates a new window (or buffer) and returns it.

The GraphicsEngine becomes the owner of the window, it will persist at least until remove_window() is called later.

If a null pointer is supplied for the gsg, then this routine will create a new gsg.

This routine is only called from the app thread.

GraphicsOutput makeParasite ( GraphicsOutput  host,
string  name,
int  sort,
int  x_size,
int  y_size 
)

Syntactic shorthand for make_buffer.

openWindows ( )

Fully opens (or closes) any windows that have recently been requested open or closed, without rendering any frames.

It is not necessary to call this explicitly, since windows will be automatically opened or closed when the next frame is rendered, but you may call this if you want your windows now without seeing a frame go by.

ref ( ) [inherited]

Explicitly increments the reference count.

User code should avoid using ref() and unref() directly, which can result in missed reference counts. Instead, let a PointerTo object manage the reference counting automatically.

This function is const, even though it changes the object, because generally fiddling with an object's reference count isn't considered part of fiddling with the object. An object might be const in other ways, but we still need to accurately count the number of references to it.

removeAllWindows ( )

Removes and closes all windows from the engine.

This also cleans up and terminates any threads that have been started to service those windows.

bool removeWindow ( GraphicsOutput  window)

Removes the indicated window or offscreen buffer from the set of windows that will be processed when render_frame() is called.

This also closes the window if it is open, and removes the window from its GraphicsPipe, allowing the window to be destructed if there are no other references to it. (However, the window may not be actually closed until next frame, if it is controlled by a sub-thread.)

The return value is true if the window was removed, false if it was not found.

Unlike remove_all_windows(), this function does not terminate any of the threads that may have been started to service this window; they are left running (since you might open a new window later on these threads). If your intention is to clean up before shutting down, it is better to call remove_all_windows() then to call remove_window() one at a time.

renderFrame ( )

Renders the next frame in all the registered windows, and flips all of the frame buffers.

resetAllWindows ( bool  swapchain)

Resets the framebuffer of the current window.

This is currently used by DirectX 8 only. It calls a reset_window function on each active window to release/create old/new framebuffer

setAutoFlip ( bool  auto_flip)

Set this flag true to indicate the GraphicsEngine should automatically cause windows to sync and flip as soon as they have finished drawing, rather than waiting for all of the windows to finish drawing first so they can flip together.

This only affects the timing of when the flip occurs. If this is true (the default), the flip occurs before render_frame() returns. If this is false, the flip occurs whenever flip_frame() is called, or at the beginning of the next call to render_frame(), if flip_frame() is never called.

setDefaultLoader ( PandaLoader  loader)

Sets the Loader object that will be assigned to every GSG created with this GraphicsEngine.

See GraphicsStateGuardian.set_loader().

setPortalCull ( bool  value)

Set this flag true to indicate the GraphicsEngine should start portal culling.

setThreadingModel ( GraphicsThreadingModel const  threading_model)

Specifies how future objects created via make_gsg(), make_buffer(), and make_window() will be threaded.

This does not affect any already-created objects.

syncFrame ( )

Waits for all the threads that started drawing their last frame to finish drawing.

The windows are not yet flipped when this returns; see also flip_frame(). It is not usually necessary to call this explicitly, unless you need to see the previous frame right away.

bool testRefCountIntegrity ( ) [inherited]

Does some easy checks to make sure that the reference count isn't completely bogus.

Returns true if ok, false otherwise.

Reimplemented in NodeReferenceCount, CachedTypedWritableReferenceCount, and NodeCachedReferenceCount.

bool testRefCountNonzero ( ) [inherited]

Does some easy checks to make sure that the reference count isn't zero, or completely bogus.

Returns true if ok, false otherwise.

bool unref ( ) [inherited]

Explicitly decrements the reference count.

Note that the object will not be implicitly deleted by unref() simply because the reference count drops to zero. (Having a member function delete itself is problematic.) However, see the helper function unref_delete().

User code should avoid using ref() and unref() directly, which can result in missed reference counts. Instead, let a PointerTo object manage the reference counting automatically.

This function is const, even though it changes the object, because generally fiddling with an object's reference count isn't considered part of fiddling with the object. An object might be const in other ways, but we still need to accurately count the number of references to it.

The return value is true if the new reference count is nonzero, false if it is zero.

Reimplemented in GeomVertexArrayFormat, and GeomVertexFormat.

 All Classes Namespaces Functions Variables Enumerations Enumerator Properties