15 #include "callbackGraphicsWindow.h"
17 TypeHandle CallbackGraphicsWindow::_type_handle;
18 TypeHandle CallbackGraphicsWindow::WindowCallbackData::_type_handle;
19 TypeHandle CallbackGraphicsWindow::EventsCallbackData::_type_handle;
20 TypeHandle CallbackGraphicsWindow::PropertiesCallbackData::_type_handle;
21 TypeHandle CallbackGraphicsWindow::RenderCallbackData::_type_handle;
29 CallbackGraphicsWindow::
36 GraphicsWindow(engine, pipe, name, fb_prop, win_prop, flags, gsg, NULL)
38 #ifdef DO_MEMORY_USAGE
39 MemoryUsage::update_type(
this,
this);
44 _properties.set_origin(0, 0);
45 _properties.set_size(0, 0);
53 CallbackGraphicsWindow::
54 ~CallbackGraphicsWindow() {
69 nassertr(device >= 0 && device < (
int)_input_devices.size(), _input_devices[0]);
70 return _input_devices[device];
84 return add_input_device(device);
99 if (_render_callback != NULL) {
101 _render_callback->do_callback(&data);
111 _gsg->reset_if_new();
114 return _gsg->begin_frame(current_thread);
126 if (_render_callback != NULL) {
129 _gsg->set_state_and_transform(RenderState::make_empty(), _gsg->get_internal_transform());
130 _gsg->clear_before_callback();
133 _render_callback->do_callback(&data);
138 _gsg->end_frame(current_thread);
140 if (mode == FM_render) {
142 clear_cube_map_selection();
162 if (_render_callback != NULL) {
164 _render_callback->do_callback(&data);
182 if (_render_callback != NULL) {
184 _render_callback->do_callback(&data);
202 if (_events_callback != NULL) {
204 _events_callback->do_callback(&data);
219 if (_properties_callback != NULL) {
221 _properties_callback->do_callback(&data);
234 bool CallbackGraphicsWindow::
242 _fb_properties.set_rgb_color(1);
244 if (_fb_properties.get_color_bits() == 0) {
245 _fb_properties.set_color_bits(16);
259 bool CallbackGraphicsWindow::
260 do_reshape_request(
int x_origin,
int y_origin,
bool has_origin,
261 int x_size,
int y_size) {
268 properties.
set_size(x_size, y_size);
269 system_changed_properties(properties);
281 _window->GraphicsWindow::process_events();
291 _window->GraphicsWindow::set_properties_now(_properties);
301 switch (_callback_type) {
302 case RCT_begin_frame:
305 set_render_flag(render_flag);
314 _window->GraphicsWindow::begin_flip();
318 _window->GraphicsWindow::end_flip();
virtual void process_events()
Do whatever processing is necessary to ensure that the window responds to user events.
GraphicsWindowInputDevice & get_input_device(int device)
Returns a writable reference to the nth input device (mouse).
virtual void end_flip()
This function will be called within the draw thread after begin_flip() has been called on all windows...
virtual void set_properties_now(WindowProperties &properties)
Applies the requested set of properties to the window, if possible, for instance to request a change ...
virtual void begin_flip()
This function will be called within the draw thread after end_frame() has been called on all windows...
void set_size(const LVector2i &size)
Specifies the requested size of the window, in pixels.
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...
static Thread * get_current_thread()
Returns a pointer to the currently-executing Thread object.
A window, fullscreen or on a desktop, into which a graphics device sends its output for interactive d...
A container for the various kinds of properties we might ask to have on a graphics window before we o...
virtual void process_events()
Do whatever processing is necessary to ensure that the window responds to user events.
Similar to MutexHolder, but for a light mutex.
int create_input_device(const string &name)
Adds a new input device (mouse) to the window with the indicated name.
An object to create GraphicsOutputs that share a particular 3-D API.
virtual void upcall()
You should make this call during the callback if you want to continue the normal function that would ...
virtual void upcall()
You should make this call during the callback if you want to continue the normal function that would ...
void set_origin(const LPoint2i &origin)
Specifies the origin on the screen (in pixels, relative to the top-left corner) at which the window s...
bool get_render_flag() const
Returns the current setting of the render flag.
virtual void set_properties_now(WindowProperties &properties)
Applies the requested set of properties to the window, if possible, for instance to request a change ...
A thread; that is, a lightweight process.
virtual void begin_flip()
This function will be called within the draw thread after end_frame() has been called on all windows...
Encapsulates all the communication with a particular instance of a given rendering backend...
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...
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...
This class is the main interface to controlling the render process.
const FrameBufferProperties & get_fb_properties() const
Returns the framebuffer properties of the window.
TypeHandle is the identifier used to differentiate C++ class types.
virtual void end_flip()
This function will be called within the draw thread after begin_flip() has been called on all windows...
A container for the various kinds of properties we might ask to have on a graphics frameBuffer before...
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...
virtual void upcall()
You should make this call during the callback if you want to continue the normal function that would ...