|
|
|
This class is the main interface to controlling the render process.
More...
#include "graphicsEngine.h"
List of all members.
Classes |
| class | LoadedTexture |
| class | RenderThread |
| class | WindowRenderer |
Public Types |
| enum | ThreadState {
TS_wait,
TS_do_frame,
TS_do_flip,
TS_do_release,
TS_do_windows,
TS_terminate,
TS_done
} |
Public Member Functions |
| | GraphicsEngine (Pipeline *pipeline=NULL) |
| | Creates a new GraphicsEngine object.
|
| | ~GraphicsEngine () |
| | Gracefully cleans up the graphics engine and its related threads and windows.
|
| bool | extract_texture_data (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.
|
| void | flip_frame () |
| | Waits for all the threads that started drawing their last frame to finish drawing, and then flips all the windows.
|
| bool | get_auto_flip () const |
| | Returns the current setting for the auto-flip flag.
|
| Loader * | get_default_loader () const |
| | Returns the Loader object that will be assigned to every GSG created with this GraphicsEngine.
|
| int | get_num_windows () const |
| | Returns the number of windows (or buffers) managed by the engine.
|
| bool | get_portal_cull () const |
| | Returns the current setting for the portal culling flag.
|
| const ReMutex & | get_render_lock () const |
| | Returns a ReMutex object that is held by the GraphicsEngine during the entire call to render_frame().
|
| GraphicsThreadingModel | get_threading_model () const |
| | Returns the threading model that will be applied to future objects.
|
| GraphicsOutput * | get_window (int n) const |
| | Returns the nth window or buffers managed by the engine, in sorted order.
|
| bool | is_empty () const |
| | Returns true if there are no windows or buffers managed by the engine, false if there is at least one.
|
| GraphicsOutput * | make_buffer (GraphicsOutput *host, const string &name, int sort, int x_size, int y_size) |
| | Syntactic shorthand for make_output.
|
| GraphicsOutput * | make_buffer (GraphicsStateGuardian *gsg, const string &name, int sort, int x_size, int y_size) |
| | Syntactic shorthand for make_output.
|
| GraphicsOutput * | make_output (GraphicsPipe *pipe, const string &name, int sort, const FrameBufferProperties &fb_prop, const WindowProperties &win_prop, int flags, GraphicsStateGuardian *gsg=NULL, GraphicsOutput *host=NULL) |
| | Creates a new window (or buffer) and returns it.
|
| GraphicsOutput * | make_parasite (GraphicsOutput *host, const string &name, int sort, int x_size, int y_size) |
| | Syntactic shorthand for make_buffer.
|
|
| MAKE_SEQ (get_windows, get_num_windows, get_window) |
| void | open_windows () |
| | Fully opens (or closes) any windows that have recently been requested open or closed, without rendering any frames.
|
| void | ready_flip () |
| | Waits for all the threads that started drawing their last frame to finish drawing.
|
| void | remove_all_windows () |
| | Removes and closes all windows from the engine.
|
| bool | remove_window (GraphicsOutput *window) |
| | Removes the indicated window or offscreen buffer from the set of windows that will be processed when render_frame() is called.
|
| void | render_frame () |
| | Renders the next frame in all the registered windows, and flips all of the frame buffers.
|
| void | reset_all_windows (bool swapchain) |
| | Resets the framebuffer of the current window.
|
| void | set_auto_flip (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.
|
| void | set_default_loader (Loader *loader) |
| | Sets the Loader object that will be assigned to every GSG created with this GraphicsEngine.
|
| void | set_portal_cull (bool value) |
| | Set this flag true to indicate the GraphicsEngine should start portal culling.
|
| void | set_threading_model (const GraphicsThreadingModel &threading_model) |
| | Specifies how future objects created via make_gsg(), make_buffer(), and make_window() will be threaded.
|
| void | sync_frame () |
| | Waits for all the threads that started drawing their last frame to finish drawing.
|
| void | texture_uploaded (Texture *tex) |
| | This method is called by the GraphicsStateGuardian after a texture has been successfully uploaded to graphics memory.
|
Static Public Member Functions |
| static void | do_cull (CullHandler *cull_handler, SceneSetup *scene_setup, GraphicsStateGuardian *gsg, Thread *current_thread) |
| | Fires off a cull traversal using the indicated camera.
|
|
static GraphicsEngine * | get_global_ptr () |
Friends |
|
class | GraphicsOutput |
|
class | WindowRenderer |
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.
Definition at line 58 of file graphicsEngine.h.
Constructor & Destructor Documentation
Member Function Documentation
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.
Definition at line 1069 of file graphicsEngine.cxx.
References GraphicsStateGuardian::extract_texture_data(), GraphicsThreadingModel::get_draw_name(), and GraphicsStateGuardian::get_threading_model().
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.
Definition at line 1030 of file graphicsEngine.cxx.
References Thread::get_current_thread().
Returns the current setting for the auto-flip flag.
See set_auto_flip.
Definition at line 60 of file graphicsEngine.I.
Returns the current setting for the portal culling flag.
Definition at line 85 of file graphicsEngine.I.
Returns a ReMutex object that is held by the GraphicsEngine during the entire call to render_frame().
While you hold this lock you can be confident that no part of the frame will be rendered (at least by the app thread).
Definition at line 26 of file graphicsEngine.I.
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.
Definition at line 245 of file graphicsEngine.cxx.
References GraphicsThreadingModel::get_draw_name(), GraphicsStateGuardian::get_engine(), GraphicsOutput::get_fb_properties(), GraphicsOutput::get_gsg(), GraphicsOutput::get_host(), GraphicsStateGuardian::get_pipe(), get_threading_model(), GraphicsStateGuardian::get_threading_model(), WindowProperties::get_x_size(), WindowProperties::get_y_size(), WindowProperties::has_size(), GraphicsStateGuardian::is_valid(), GraphicsOutput::is_valid(), GraphicsStateGuardian::needs_reset(), open_windows(), remove_window(), and FrameBufferProperties::subsumes().
Referenced by make_buffer(), and make_parasite().
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.
Definition at line 942 of file graphicsEngine.cxx.
References Thread::get_current_thread().
Referenced by make_output(), and render_frame().
Waits for all the threads that started drawing their last frame to finish drawing.
Returns when all threads have actually finished drawing, as opposed to 'sync_frame' we seems to return once all draw calls have been submitted. Calling 'flip_frame' after this function should immediately cause a buffer flip. This function will only work in opengl right now, for all other graphics pipelines it will simply return immediately. In opengl it's a bit of a hack: it will attempt to read a single pixel from the frame buffer to force the graphics card to finish drawing before it returns
Definition at line 1011 of file graphicsEngine.cxx.
References Thread::get_current_thread().
Removes and closes all windows from the engine.
This also cleans up and terminates any threads that have been started to service those windows.
Definition at line 563 of file graphicsEngine.cxx.
References ordered_vector< Key, Compare >::begin(), ordered_vector< Key, Compare >::end(), BamCache::flush_index(), Thread::get_current_thread(), BamCache::get_global_ptr(), AsyncTaskManager::get_global_ptr(), GraphicsOutput::get_gsg(), Thread::prepare_for_exit(), GraphicsStateGuardian::release_all(), VertexDataPage::stop_threads(), AsyncTaskManager::stop_threads(), and ordered_vector< Key, Compare >::swap().
Referenced by ~GraphicsEngine().
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.
Definition at line 500 of file graphicsEngine.cxx.
References ordered_vector< Key, Compare >::begin(), ordered_vector< Key, Compare >::end(), Thread::get_current_thread(), GraphicsOutput::get_gsg(), GraphicsStateGuardianBase::get_gsg(), GraphicsStateGuardian::get_prepared_objects(), and PreparedGraphicsObjects::release_all().
Referenced by make_output(), and GraphicsStateGuardian::remove_window().
Renders the next frame in all the registered windows, and flips all of the frame buffers.
Definition at line 673 of file graphicsEngine.cxx.
References ordered_vector< Key, Compare >::begin(), ClockObject::check_errors(), BamCache::consider_flush_index(), Thread::consider_yield(), Pipeline::cycle(), ordered_vector< Key, Compare >::end(), GeomCacheManager::flush_level(), CullableObject::flush_level(), CullTraverser::flush_level(), RenderState::flush_level(), TransformState::flush_level(), Thread::force_yield(), DisplayRegion::get_camera(), Thread::get_current_thread(), GraphicsOutput::get_delete_flag(), ClockObject::get_frame_count(), ClockObject::get_global_clock(), VertexDataPage::get_global_lru(), BamCache::get_global_ptr(), GeomVertexArrayData::get_independent_lru(), GraphicsOutput::get_num_active_display_regions(), RenderState::get_num_states(), TransformState::get_num_states(), RenderState::get_num_unused_states(), TransformState::get_num_unused_states(), VertexDataPage::get_pending_lru(), VertexDataPage::get_save_file(), Camera::get_scene(), GeomVertexArrayData::get_small_lru(), NodePath::get_top(), VertexDataSaveFile::get_total_file_size(), SimpleLru::get_total_size(), VertexDataSaveFile::get_used_file_size(), PStatClient::is_connected(), NodePath::is_empty(), Thread::is_true_threads(), GeomVertexArrayData::lru_epoch(), NodePath::node(), open_windows(), ordered_vector< Key, Compare >::push_back(), ordered_vector< Key, Compare >::reserve(), ordered_vector< Key, Compare >::size(), ordered_vector< Key, Compare >::swap(), and ClockObject::tick().
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.
Definition at line 47 of file graphicsEngine.I.
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.
Definition at line 986 of file graphicsEngine.cxx.
References Thread::get_current_thread().
The documentation for this class was generated from the following files:
| | |