Xrb::Render Namespace Reference

Houses all of the basic rendering primitives used by XuqRijBuh. More...


Functions

void DrawLine (RenderContext const &render_context, FloatVector2 const &from, FloatVector2 const &to, Color const &color)
 Draws a line between from and to in the given color.
void DrawArrow (RenderContext const &render_context, FloatVector2 const &from, FloatVector2 const &to, Color const &color)
 Draws an arrow with tail at from and head at to, in the given color.
void DrawPolygon (RenderContext const &render_context, FloatVector2 const &center, Float radius, Float angle, Color const &color, Uint32 vertex_count)
 Draws a regular polygon.
void DrawCircle (RenderContext const &render_context, FloatMatrix2 const &transformation, FloatVector2 const &center, Float radius, Color const &color)
 Draws a circle with the given center and radius, in the given color.
void DrawCircularArc (RenderContext const &render_context, FloatMatrix2 const &transformation, FloatVector2 const &center, Float radius, Float start_angle, Float end_angle, Color const &color)
 Draws a circular arc with the given center and radius, start angle and end angle, in the given color.
void DrawScreenRect (RenderContext const &render_context, Color const &color, ScreenCoordRect const &screen_rect)
 Fills the given rectangle with the given color.
void DrawScreenRectTexture (RenderContext const &render_context, GLTexture const *gl_texture, ScreenCoordRect const &screen_rect, FloatSimpleTransform2 const &transformation=FloatSimpleTransform2::ms_identity)
 Maps the given texture to the given rectangle.
void SetupTextureUnits (GLuint gltexture_handle, Color const &color_mask, Color const &color_bias)
 Sets up texture units 0 and 1 for texturing, color masking and color biasing.


Detailed Description

Houses all of the basic rendering primitives used by XuqRijBuh.

The rendering primitives are

All functions requires a RenderContext (with a few exceptions).

Some functions operate using the existing OpenGL modelview matrix, while others reset it to the identity.

None of the functions change the OpenGL projection matrix. However, it should be noted that each function depends on the projection matrix being set up in a particular mode. Specifically, there are two types of modes currently: in-Widget rendering, and in-WorldView rendering. In-Widget rendering takes place when the projection matrix is set up to make the modelview coordinates exactly coincide with the screen's pixel coordinates (though in a right-handed coordinate system). The in-WorldView rendering mode assumes the projection matrix is set up so that the zooming, scaling, and positioning of the view is taken into account, and so the modelview coordinates represent actual world coordinates.


Function Documentation

void Xrb::Render::DrawLine ( RenderContext const &  render_context,
FloatVector2 const &  from,
FloatVector2 const &  to,
Color const &  color 
)

Draws a line between from and to in the given color.

Obliterates the modelview matrix.

Parameters:
render_context The required RenderContext.
from One of the line's endpoints, in modelspace.
to The other of the line's endpoints, in modelspace.
color The color to use to render the line.

Definition at line 19 of file xrb_render.cpp.

References Xrb::Dim::A, Xrb::RenderContext::ColorBias(), Xrb::RenderContext::MaskAndBiasWouldResultInNoOp(), Xrb::RenderContext::MaskedColor(), and SetupTextureUnits().

void Xrb::Render::DrawArrow ( RenderContext const &  render_context,
FloatVector2 const &  from,
FloatVector2 const &  to,
Color const &  color 
)

Draws an arrow with tail at from and head at to, in the given color.

The size of the arrow's head is proportional to its length.

Obliterates the modelview matrix.

Parameters:
render_context The required RenderContext.
from The tail endpoint of the arrow, in modelspace.
to The head endpoint of the arrow, in modelspace.
color The color to use to render the arrow.

Definition at line 48 of file xrb_render.cpp.

References Xrb::Dim::A, Xrb::RenderContext::ColorBias(), Xrb::RenderContext::MaskAndBiasWouldResultInNoOp(), Xrb::RenderContext::MaskedColor(), Xrb::PerpendicularVector2(), and SetupTextureUnits().

void Xrb::Render::DrawPolygon ( RenderContext const &  render_context,
FloatVector2 const &  center,
Float  radius,
Float  angle,
Color const &  color,
Uint32  vertex_count 
)

Draws a regular polygon.

The vertices of the polygon will be placed on the bounding circle specified by center and radius.

Obliterates the modelview matrix.

Parameters:
render_context The required RenderContext.
center The center of the bounding circle that the polygon's vertices will lay upon, in modelspace.
radius The radius of the bounding circle that the polygon's vertices will lay upon, in modelspace.
angle The angle at which the first vertex will be placed upon the bounding circle.
color The color to use to render the polygon.
vertex_count The number of vertices the polygon should have.

Definition at line 91 of file xrb_render.cpp.

References Xrb::RenderContext::ColorBias(), Xrb::RenderContext::MaskAndBiasWouldResultInNoOp(), Xrb::RenderContext::MaskedColor(), Xrb::Math::Radians(), and SetupTextureUnits().

Referenced by DrawCircle().

void Xrb::Render::DrawCircle ( RenderContext const &  render_context,
FloatMatrix2 const &  transformation,
FloatVector2 const &  center,
Float  radius,
Color const &  color 
)

Draws a circle with the given center and radius, in the given color.

The number of lines used to draw the circle is dependent on transformation. The larger the circle appears, the more lines will be used to draw it. No more than 30 lines and no less than 6 lines will be used to draw the circle.

Obliterates the modelview matrix.

Parameters:
render_context The required RenderContext.
transformation The world-to-screen transformation matrix which is used to calculate the necessary number of lines to use to draw the circle.
center The center of the circle, in modelspace.
radius The radius of the circle, in modelspace.
color The color to use to render the circle.

Definition at line 137 of file xrb_render.cpp.

References DrawPolygon(), Xrb::RenderContext::MaskAndBiasWouldResultInNoOp(), Xrb::Max(), and Xrb::Vector< Float, 2 >::ms_zero.

void Xrb::Render::DrawCircularArc ( RenderContext const &  render_context,
FloatMatrix2 const &  transformation,
FloatVector2 const &  center,
Float  radius,
Float  start_angle,
Float  end_angle,
Color const &  color 
)

Draws a circular arc with the given center and radius, start angle and end angle, in the given color.

The number of lines used to draw the arc is dependent on transformation. The larger the arc appears, the more lines will be used to draw it. No more than 30 lines per full 360 degree arc, and no less than 6 lines per full 360 degree arc will be used to draw the circular arc.

Obliterates the modelview matrix.

Parameters:
render_context The required RenderContext.
transformation The world-to-screen transformation matrix which is used to calculate the necessary number of lines to use to draw the circular arc.
center The center of the circle that the arc lies on, in modelspace.
radius The radius of the circle that the arc lies on, in modelspace.
start_angle The angle at which to start the arc, in modelspace, where 0 degrees is along the positive X axis, and degrees increase to move counterclockwise.
end_angle The angle at which to end the arc, in modelspace, where 0 degrees is along the positive X axis, and degrees increase to move counterclockwise. The total angle spanned by end_angle - start_angle can be greater than 360 if desired.
color The color to use to render the arc.

Definition at line 181 of file xrb_render.cpp.

References Xrb::Math::Ceiling(), Xrb::RenderContext::ColorBias(), Xrb::RenderContext::MaskAndBiasWouldResultInNoOp(), Xrb::RenderContext::MaskedColor(), Xrb::Vector< Float, 2 >::ms_zero, Xrb::Math::Radians(), and SetupTextureUnits().

void Xrb::Render::DrawScreenRect ( RenderContext const &  render_context,
Color const &  color,
ScreenCoordRect const &  screen_rect 
)

Fills the given rectangle with the given color.

Obliterates the modelview matrix.

Parameters:
render_context The required RenderContext.
color The color to use to render the rectangle.
screen_rect The screen-coordinate rectangle to fill.

Definition at line 274 of file xrb_render.cpp.

References Xrb::Rect< T >::BottomLeft(), Xrb::Rect< T >::BottomRight(), Xrb::RenderContext::ColorBias(), Xrb::RenderContext::MaskAndBiasWouldResultInNoOp(), Xrb::RenderContext::MaskedColor(), SetupTextureUnits(), Xrb::Rect< T >::TopLeft(), Xrb::Rect< T >::TopRight(), Xrb::Dim::X, and Xrb::Dim::Y.

Referenced by Xrb::WidgetBackgroundColored::Draw().

void Xrb::Render::DrawScreenRectTexture ( RenderContext const &  render_context,
GLTexture const *  gl_texture,
ScreenCoordRect const &  screen_rect,
FloatSimpleTransform2 const &  transformation = FloatSimpleTransform2::ms_identity 
)

Maps the given texture to the given rectangle.

Obliterates the modelview matrix.

Parameters:
render_context The required RenderContext.
gl_texture A pointer to the GLTexture which should be used.
screen_rect The screen rectangle to be filled with the texture.
transformation An optional transformation to the texture coordinates (e.g. for flipping horizontally, vertically, or scaling the texture).

Definition at line 316 of file xrb_render.cpp.

References Xrb::Rect< T >::BottomLeft(), Xrb::Rect< T >::BottomRight(), Xrb::RenderContext::ColorBias(), Xrb::RenderContext::ColorMask(), Xrb::GLTexture::Handle(), Xrb::RenderContext::MaskAndBiasWouldResultInNoOp(), SetupTextureUnits(), Xrb::Rect< T >::TopLeft(), Xrb::Rect< T >::TopRight(), Xrb::Dim::X, and Xrb::Dim::Y.

Referenced by Xrb::WidgetBackgroundStylized::Draw(), and Xrb::WidgetBackgroundTextured::Draw().

void Xrb::Render::SetupTextureUnits ( GLuint  gltexture_handle,
Color const &  color_mask,
Color const &  color_bias 
)

Sets up texture units 0 and 1 for texturing, color masking and color biasing.

This setup is done in so many places that it was deemed function-worthy, eliminating possible copy/paste errors.

Parameters:
gltexture_handle The OpenGL texture handle to bind to texture unit 0.
color_mask The masking color modulate the bound texture with.
color_bias The color bias to interpolate the results of texture unit 0 with.
Note:
When this function returns, texture unit 1 will be active.

Definition at line 372 of file xrb_render.cpp.

References Xrb::Dim::B, Xrb::Dim::G, and Xrb::Dim::R.

Referenced by DrawArrow(), DrawCircularArc(), DrawLine(), DrawPolygon(), DrawScreenRect(), and DrawScreenRectTexture().


Hosted by SourceForge.net Logo -- Generated on Fri Aug 21 21:46:39 2009 for XuqRijBuh by doxygen 1.5.8