Panda3D
|
This special window object doesn't represent a window in its own right, but instead hooks into some third-party API for creating and rendering to windows via callbacks. More...
#include "callbackGraphicsWindow.h"
Classes | |
class | EventsCallbackData |
class | PropertiesCallbackData |
class | RenderCallbackData |
class | WindowCallbackData |
Public Types | |
enum | RenderCallbackType { RCT_begin_frame, RCT_end_frame, RCT_begin_flip, RCT_end_flip } |
Public Member Functions | |
virtual void | begin_flip () |
This function will be called within the draw thread after end_frame() has been called on all windows, to initiate the exchange of the front and back buffers. | |
virtual bool | begin_frame (FrameMode mode, Thread *current_thread) |
This function will be called within the draw thread before beginning rendering for a given frame. | |
void | clear_events_callback () |
Removes the callback set by an earlier call to set_events_callback(). | |
void | clear_properties_callback () |
Removes the callback set by an earlier call to set_properties_callback(). | |
void | clear_render_callback () |
Removes the callback set by an earlier call to set_render_callback(). | |
int | create_input_device (const string &name) |
Adds a new input device (mouse) to the window with the indicated name. | |
virtual void | end_flip () |
This function will be called within the draw thread after begin_flip() has been called on all windows, to finish the exchange of the front and back buffers. | |
virtual void | end_frame (FrameMode mode, Thread *current_thread) |
This function will be called within the draw thread after rendering is completed for a given frame. | |
virtual TypeHandle | force_init_type () |
CallbackObject * | get_events_callback () const |
Returns the CallbackObject set by set_events_callback(). | |
GraphicsWindowInputDevice & | get_input_device (int device) |
Returns a writable reference to the nth input device (mouse). | |
CallbackObject * | get_properties_callback () const |
Returns the CallbackObject set by set_properties_callback(). | |
CallbackObject * | get_render_callback () const |
Returns the CallbackObject set by set_render_callback(). | |
virtual TypeHandle | get_type () const |
virtual void | process_events () |
Do whatever processing is necessary to ensure that the window responds to user events. | |
void | set_events_callback (CallbackObject *object) |
Sets the CallbackObject that will be notified when this window is polled for window events, including mouse and keyboard events, as well as window resize events and other system-generated events. | |
void | set_properties_callback (CallbackObject *object) |
Sets the CallbackObject that will be notified when this window receives a property change request from user code (e.g. | |
virtual void | set_properties_now (WindowProperties &properties) |
Applies the requested set of properties to the window, if possible, for instance to request a change in size or minimization status. | |
void | set_render_callback (CallbackObject *object) |
Sets the CallbackObject that will be notified when this window is invoked (in the draw thread) to render its contents, and/or flip the graphics buffers. | |
Static Public Member Functions | |
static TypeHandle | get_class_type () |
static void | init_type () |
Protected Member Functions | |
CallbackGraphicsWindow (GraphicsEngine *engine, GraphicsPipe *pipe, const string &name, const FrameBufferProperties &fb_prop, const WindowProperties &win_prop, int flags, GraphicsStateGuardian *gsg) | |
Use GraphicsEngine::make_output() to construct a CallbackGraphicsWindow. | |
virtual bool | do_reshape_request (int x_origin, int y_origin, bool has_origin, int x_size, int y_size) |
Called from the window thread in response to a request from within the code (via request_properties()) to change the size and/or position of the window. | |
virtual bool | open_window () |
Opens the window right now. | |
Friends | |
class | GraphicsEngine |
This special window object doesn't represent a window in its own right, but instead hooks into some third-party API for creating and rendering to windows via callbacks.
This can be used to allow Panda to render into an already-created OpenGL context, for instance.
Definition at line 30 of file callbackGraphicsWindow.h.
CallbackGraphicsWindow::CallbackGraphicsWindow | ( | GraphicsEngine * | engine, |
GraphicsPipe * | pipe, | ||
const string & | name, | ||
const FrameBufferProperties & | fb_prop, | ||
const WindowProperties & | win_prop, | ||
int | flags, | ||
GraphicsStateGuardian * | gsg | ||
) | [protected] |
Use GraphicsEngine::make_output() to construct a CallbackGraphicsWindow.
Definition at line 30 of file callbackGraphicsWindow.cxx.
References WindowProperties::set_origin(), and WindowProperties::set_size().
void CallbackGraphicsWindow::begin_flip | ( | ) | [virtual] |
This function will be called within the draw thread after end_frame() has been called on all windows, to initiate the exchange of the front and back buffers.
This should instruct the window to prepare for the flip at the next video sync, but it should not wait.
We have the two separate functions, begin_flip() and end_flip(), to make it easier to flip all of the windows at the same time.
Reimplemented from GraphicsOutput.
Definition at line 156 of file callbackGraphicsWindow.cxx.
bool CallbackGraphicsWindow::begin_frame | ( | FrameMode | mode, |
Thread * | current_thread | ||
) | [virtual] |
This function will be called within the draw thread before beginning rendering for a given frame.
It should do whatever setup is required, and return true if the frame should be rendered, or false if it should be skipped.
Reimplemented from GraphicsOutput.
Definition at line 97 of file callbackGraphicsWindow.cxx.
References GraphicsOutput::get_fb_properties(), and CallbackGraphicsWindow::RenderCallbackData::get_render_flag().
void CallbackGraphicsWindow::clear_events_callback | ( | ) | [inline] |
Removes the callback set by an earlier call to set_events_callback().
Definition at line 44 of file callbackGraphicsWindow.I.
References set_events_callback().
void CallbackGraphicsWindow::clear_properties_callback | ( | ) | [inline] |
Removes the callback set by an earlier call to set_properties_callback().
Definition at line 89 of file callbackGraphicsWindow.I.
References set_properties_callback().
void CallbackGraphicsWindow::clear_render_callback | ( | ) | [inline] |
Removes the callback set by an earlier call to set_render_callback().
Definition at line 127 of file callbackGraphicsWindow.I.
References set_render_callback().
int CallbackGraphicsWindow::create_input_device | ( | const string & | name | ) |
Adds a new input device (mouse) to the window with the indicated name.
Returns the index of the new device.
Definition at line 81 of file callbackGraphicsWindow.cxx.
References GraphicsWindow::add_input_device(), and GraphicsWindowInputDevice::pointer_and_keyboard().
bool CallbackGraphicsWindow::do_reshape_request | ( | int | x_origin, |
int | y_origin, | ||
bool | has_origin, | ||
int | x_size, | ||
int | y_size | ||
) | [protected, virtual] |
Called from the window thread in response to a request from within the code (via request_properties()) to change the size and/or position of the window.
Returns true if the window is successfully changed, or false if there was a problem.
Reimplemented from GraphicsWindow.
Definition at line 255 of file callbackGraphicsWindow.cxx.
References WindowProperties::set_origin(), WindowProperties::set_size(), and GraphicsWindow::system_changed_properties().
void CallbackGraphicsWindow::end_flip | ( | ) | [virtual] |
This function will be called within the draw thread after begin_flip() has been called on all windows, to finish the exchange of the front and back buffers.
This should cause the window to wait for the flip, if necessary.
Reimplemented from GraphicsOutput.
Definition at line 176 of file callbackGraphicsWindow.cxx.
void CallbackGraphicsWindow::end_frame | ( | FrameMode | mode, |
Thread * | current_thread | ||
) | [virtual] |
This function will be called within the draw thread after rendering is completed for a given frame.
It should do whatever finalization is required.
Reimplemented from GraphicsOutput.
Definition at line 125 of file callbackGraphicsWindow.cxx.
References GraphicsOutput::clear_cube_map_selection(), and GraphicsOutput::trigger_flip().
CallbackObject * CallbackGraphicsWindow::get_events_callback | ( | ) | const [inline] |
Returns the CallbackObject set by set_events_callback().
Definition at line 54 of file callbackGraphicsWindow.I.
GraphicsWindowInputDevice & CallbackGraphicsWindow::get_input_device | ( | int | device | ) |
Returns a writable reference to the nth input device (mouse).
This is intended to be used for the window implementation to record mouse and keyboard input information for the Panda system.
Definition at line 67 of file callbackGraphicsWindow.cxx.
CallbackObject * CallbackGraphicsWindow::get_properties_callback | ( | ) | const [inline] |
Returns the CallbackObject set by set_properties_callback().
Definition at line 99 of file callbackGraphicsWindow.I.
CallbackObject * CallbackGraphicsWindow::get_render_callback | ( | ) | const [inline] |
Returns the CallbackObject set by set_render_callback().
Definition at line 137 of file callbackGraphicsWindow.I.
bool CallbackGraphicsWindow::open_window | ( | ) | [protected, virtual] |
Opens the window right now.
Called from the window thread. Returns true if the window is successfully opened, or false if there was a problem.
Reimplemented from GraphicsWindow.
Definition at line 230 of file callbackGraphicsWindow.cxx.
void CallbackGraphicsWindow::process_events | ( | ) | [virtual] |
Do whatever processing is necessary to ensure that the window responds to user events.
Also, honor any requests recently made via request_properties().
This function is called only within the window thread.
Reimplemented from GraphicsWindow.
Definition at line 196 of file callbackGraphicsWindow.cxx.
void CallbackGraphicsWindow::set_events_callback | ( | CallbackObject * | object | ) | [inline] |
Sets the CallbackObject that will be notified when this window is polled for window events, including mouse and keyboard events, as well as window resize events and other system-generated events.
This callback will receive a CallbackGraphicsWindow::EventsCallbackData.
This callback should process any system-generated events, and call data->upcall() to process requested property change requests made via request_properties().
Definition at line 33 of file callbackGraphicsWindow.I.
Referenced by clear_events_callback().
void CallbackGraphicsWindow::set_properties_callback | ( | CallbackObject * | object | ) | [inline] |
Sets the CallbackObject that will be notified when this window receives a property change request from user code (e.g.
via request_properties).
This callback will receive a CallbackGraphicsWindow::PropertiesCallbackData, which provides a get_properties() method that returns a modifiable reference to a WindowsProperties object. This object will contain only those properties requested by user code. The callback should handle any of the requests it finds, including and especially set_open(), and remove them from the object when it has handled them. Any unhandled properties should be left unchanged in the properties object.
Definition at line 78 of file callbackGraphicsWindow.I.
Referenced by clear_properties_callback().
void CallbackGraphicsWindow::set_properties_now | ( | WindowProperties & | properties | ) | [virtual] |
Applies the requested set of properties to the window, if possible, for instance to request a change in size or minimization status.
Reimplemented from GraphicsWindow.
Definition at line 213 of file callbackGraphicsWindow.cxx.
void CallbackGraphicsWindow::set_render_callback | ( | CallbackObject * | object | ) | [inline] |
Sets the CallbackObject that will be notified when this window is invoked (in the draw thread) to render its contents, and/or flip the graphics buffers.
This callback will actually serve several different functions. It receivces a RenderCallbackData, and you can query data->get_callback_type() to return the actual function of each particular callback.
Definition at line 116 of file callbackGraphicsWindow.I.
Referenced by clear_render_callback().