Home | Download | Screen shots | Discussion | Documentation
--- | --- | --- | --- | ---

Main Page | Modules | Namespace List | Class Hierarchy | Class List | Namespace Members | Class Members | Related Pages

# openvrml::rendering_context Class Reference

List of all members.

## Detailed Description

Information needed during a render traversal.

The members could be arguments to the Node::render method, but there may be many arguments, and adding an argument requires changing nearly every file in the core.

WARNING: This is a concrete base class that is passed by value, not by reference. The idea is to pass everything exactly as if it were a normal argument to the render function. This has some consequences...

First off, the members should be primitives or pointers. There shouldn't be anything that requires a lot of work to copy. Calling render() should be cheap. Secondly, while adding a new member to this class is less work than adding a new argument to every node::render call, it still requires a recompile of nearly the whole core. That's because pass-by-value needs to know the exact size of what's being passed. Thirdly, you can't subclass this class. It's concrete. If you pass a subclass it will just get truncated.

Why do it this way? Because it makes writing the node::render method easier. We don't have to maintain a stack of states, we just use the call stack instead. That means no heap allocation and deallocation, which is very cool. Also, we don't have to pop the stack at the end of the method. Alternatively, I could have used the "initialization is resource acquisition" pattern, but I felt this was cleaner.

Author:
  Christopher K. St. John

See also:
  node::render

  browser::render

## Public Member Functions
| rendering_context ()
| Constructs an empty render context.
| rendering_context (bounding_volume::intersection cull_flag, mat4f &modelview)
| Constructs and initializes a render context.
const mat4f & | matrix () const
| Returns a reference to the modelview matrix.
void | matrix (mat4f &modelview)
| Sets the modelview matrix.
## Public Attributes
bounding_volume::intersection | cull_flag
| Track the results of intersecting node bounds with the view volume.
bool | draw_bounding_spheres
| Draw the bounding volumes or not.
## Private Attributes
mat4f * | modelview

## Constructor & Destructor Documentation

openvrml::rendering_context::rendering_context | ( |  | ) |

| Constructs an empty render context. An empty context should not be passed to VrmlNode::render. This constructor is useful only for debugging and experimentation.

openvrml::rendering_context::rendering_context | ( | bounding_volume::intersection | cull_flag,
|  | mat4f & | modelview
| ) |

  | Constructs and initializes a render context. Parameters:
  | cull_flag | the cull flag argument will normally be bounding_volume::partial.
  | modelview | The modelview matrix. The transform can be affine, but the rendering code may take advantage of an orthogonal transform if one is passed in.
See also: cull_flag

## Member Function Documentation

const mat4f & openvrml::rendering_context::matrix | ( |  | ) | const

| Returns a reference to the modelview matrix. Returns: the modelview matrix.

void openvrml::rendering_context::matrix | ( | mat4f & | modelview | ) |

  | Sets the modelview matrix. A rendering_context retains a pointer to the passed matrix; it does not make a copy. All memory management is up to the caller. In practice, the passed-in array will generally be a local variable in the node::render method. Parameters:
  | modelview | the modelview matrix. Must be at least affine, although the render code may optimize for orthogonal transforms.

## Member Data Documentation

mat4f * openvrml::rendering_context::modelview`[private]`

| The current modelview matrix.

bounding_volume::Intersection openvrml::rendering_context::cull_flag

| Track the results of intersecting node bounds with the view volume. Setting to bounding_volume::inside means that all the last tested bounding volume was completely inside the view volume, so all the contained bounding volumes must also be inside and we can skip further testing. bounding_volume::partial means that the last test indicated that the bounding volume intersected the view volume, so some of the children may be visible and we must continue testing. bounding_volume::outside means the last test indicated the bounding volume was completely outside the view volume. However, there's normally no reason to call set with bounding_volume::outside, since the render method returns immediately. But who knows; it might be useful some day, so it's an allowed value. Setting the cull flag to bounding_volume::inside in the Browser at the top of the traversal has the effect of disabling the culling tests. The behavior is undefined if the flag is not one of the allowed values. See also: browser bounding_volume

bool openvrml::rendering_context::draw_bounding_spheres

| Draw the bounding volumes or not. If true, then the renderer may draw the bounding volumes for each primitive. Or maybe not, so you shouldn't depend on this behavior. It does look kinda cool though.