Panda3D

displayRegionDrawCallbackData.cxx
Go to the documentation of this file.
1 /**
2 * PANDA 3D SOFTWARE
3 * Copyright (c) Carnegie Mellon University. All rights reserved.
4 *
5 * All use of this software is subject to the terms of the revised BSD
6 * license. You should have received a copy of this license along
7 * with this source code in a file named "LICENSE."
8 *
9 * @file displayRegionDrawCallbackData.cxx
10 * @author drose
11 * @date 2009-03-13
12 */
13
14 #include "displayRegionDrawCallbackData.h"
15
16 #include "config_display.h"
17 #include "cullResult.h"
18 #include "displayRegion.h"
19 #include "graphicsOutput.h"
20 #include "graphicsStateGuardian.h"
21 #include "sceneSetup.h"
22
23 TypeHandle DisplayRegionDrawCallbackData::_type_handle;
24
25
26 /**
27 *
28 */
29 DisplayRegionDrawCallbackData::
30 DisplayRegionDrawCallbackData(CullResult *cull_result, SceneSetup *scene_setup) :
31 _cull_result(cull_result),
32 _scene_setup(scene_setup)
33 {
34 }
35
36 /**
37 *
38 */
39 void DisplayRegionDrawCallbackData::
40 output(std::ostream &out) const {
41 out << get_type() << "(" << (void *)_cull_result << ", "
42 << (void *)_scene_setup << ")";
43 }
44
45 /**
46 * You should make this call during the callback if you want to continue the
47 * normal rendering function that would have been done in the absence of a
48 * callback.
49 *
50 * Specifically, this method will draw all of the objects in the CullResult
51 * list that have been built up for the DisplayRegion during the cull
52 * traversal.
53 */
54 void DisplayRegionDrawCallbackData::
55 upcall() {
56 Thread *current_thread = Thread::get_current_thread();
57 DisplayRegion *dr = _scene_setup->get_display_region();
58 GraphicsStateGuardian *gsg = dr->get_window()->get_gsg();
59
60 if (_cull_result == nullptr || _scene_setup == nullptr) {
61 // Nothing to see here.
62
63 } else if (dr->is_stereo()) {
64 // We don't actually draw the stereo DisplayRegions. These are just
65 // placeholders; we draw the individual left and right eyes instead. (We
66 // might still clear the stereo DisplayRegions, though, since it's
67 // probably faster to clear right and left channels in one pass, than to
68 // clear them in two separate passes.)
69
70 } else if (!gsg->set_scene(_scene_setup)) {
71 // The scene or lens is inappropriate somehow.
72 display_cat.error()
73 << gsg->get_type() << " cannot render scene with specified lens.\n";
74
75 } else {
76 // Tell the GSG to forget its state.
77 gsg->clear_state_and_transform();
78
79 if (gsg->begin_scene()) {
80 _cull_result->draw(current_thread);
81 gsg->end_scene();
82 }
83 }
84 }
CullResult
This stores the result of a BinCullHandler traversal: an ordered collection of CullBins,...
Definition: cullResult.h:44
CullResult::draw
void draw(Thread *current_thread)
Asks all the bins to draw themselves in the correct order.
Definition: cullResult.cxx:290
DisplayRegionDrawCallbackData::upcall
virtual void upcall()
You should make this call during the callback if you want to continue the normal rendering function t...
Definition: displayRegionDrawCallbackData.cxx:55
DisplayRegion
A rectangular subregion within a window for rendering into.
Definition: displayRegion.h:57
DisplayRegion::is_stereo
is_stereo
Returns true if this is a StereoDisplayRegion, false otherwise.
Definition: displayRegion.h:90
DisplayRegion::get_window
get_window
Returns the GraphicsOutput that this DisplayRegion is ultimately associated with, or NULL if no windo...
Definition: displayRegion.h:88
GraphicsStateGuardian
Encapsulates all the communication with a particular instance of a given rendering backend.
Definition: graphicsStateGuardian.h:65
GraphicsStateGuardian::set_scene
set_scene
Sets the SceneSetup object that indicates the initial camera position, etc.
Definition: graphicsStateGuardian.h:290
GraphicsStateGuardian::clear_state_and_transform
virtual void clear_state_and_transform()
Forgets the current graphics state and current transform, so that the next call to set_state_and_tran...
Definition: graphicsStateGuardian.cxx:2179
GraphicsStateGuardian::end_scene
virtual void end_scene()
Called between begin_frame() and end_frame() to mark the end of drawing commands for a "scene" (usual...
Definition: graphicsStateGuardian.cxx:2300
GraphicsStateGuardian::begin_scene
virtual bool begin_scene()
Called between begin_frame() and end_frame() to mark the beginning of drawing commands for a "scene" ...
Definition: graphicsStateGuardian.cxx:2289
SceneSetup
This object holds the camera position, etc., and other general setup information for rendering a part...
Definition: sceneSetup.h:32
SceneSetup::get_display_region
DisplayRegion * get_display_region() const
Returns the display region for the scene.
Definition: sceneSetup.I:42
Thread
A thread; that is, a lightweight process.
Definition: thread.h:46
Thread::get_current_thread
get_current_thread
Returns a pointer to the currently-executing Thread object.
Definition: thread.h:109
TypeHandle
TypeHandle is the identifier used to differentiate C++ class types.
Definition: typeHandle.h:81
config_display.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
cullResult.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
displayRegionDrawCallbackData.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
displayRegion.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
graphicsOutput.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
graphicsStateGuardian.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
sceneSetup.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.