CL_GraphicContext Class Reference
[clanDisplay Display]

Interface to drawing graphics. More...

#include <graphic_context.h>

Inheritance diagram for CL_GraphicContext:
Inheritance graph
[legend]

List of all members.

Public Member Functions

Construction

 CL_GraphicContext ()
 Constructs a null instance.
 CL_GraphicContext (CL_GraphicContextProvider *provider)
 Constructs a GraphicContext.
 ~CL_GraphicContext ()
Attributes

bool is_null () const
 Returns true if this object is invalid.
void throw_if_null () const
 Throw an exception if this object is invalid.
CL_Texture get_texture (int index) const
 Returns the currently selected texture for the specified index.
std::vector< CL_Textureget_textures () const
 Returns the currently selected textures.
CL_BlendMode get_blend_mode () const
 Returns the blending mode description.
CL_BufferControl get_buffer_control () const
 Returns the buffer control description.
CL_PolygonRasterizer get_polygon_rasterizer () const
 Returns the polygon rasterizer setup.
CL_FrameBuffer get_write_frame_buffer () const
 Returns the currently selected write frame buffer.
CL_FrameBuffer get_read_frame_buffer () const
 Returns the currently selected read frame buffer.
CL_Pen get_pen () const
 Returns the currently selected pen.
int get_width () const
 Returns the current width of the context.
int get_height () const
 Returns the current height of the context.
CL_Size get_size () const
 Returns the current size of the context.
CL_Rect get_cliprect () const
 Returns the current clipping rectangle used on the graphic context.
const CL_Mat4fget_modelview () const
 Returns the current effective modelview matrix.
CL_Size get_max_texture_size () const
 Returns the maximum size of a texture this graphic context supports.
CL_GraphicContextProviderget_provider ()
 Returns the provider for this graphic context.
const
CL_GraphicContextProvider
*const 
get_provider () const
Operations

CL_PixelBuffer get_pixeldata (const CL_Rect &rect, CL_TextureFormat pixel_format=cl_abgr8, bool clamp=true) const
 Return the content of the read buffer into a pixel buffer.
CL_PixelBuffer get_pixeldata (CL_TextureFormat pixel_format=cl_abgr8, bool clamp=true) const
 Return the content of the read buffer into a pixel buffer.
void set_frame_buffer (const CL_FrameBuffer &write_buffer)
 Sets the current frame buffer.
void set_frame_buffer (const CL_FrameBuffer &write_buffer, const CL_FrameBuffer &read_buffer)
void reset_frame_buffer ()
 Resets the current frame buffer to be the initial frame buffer.
void set_texture (int unit_index, const CL_Texture &texture)
 Select texture into index.
void set_textures (std::vector< CL_Texture > &textures)
 Select textures.
void reset_texture (int unit_index)
 Remove texture from index.
void reset_textures ()
 Remove all selected textures.
void set_program_object (CL_StandardProgram standard_program)
 Set active program object to the standard program specified.
void set_program_object (const CL_ProgramObject &program, int program_matrix_flags=cl_program_matrix_all_standard)
 Set active program object.
void reset_program_object ()
 Remove active program object.
void set_blend_mode (const CL_BlendMode &blend_mode)
 Set blending modes.
void reset_blend_mode ()
 Reset blending to the default.
void set_buffer_control (const CL_BufferControl &buffer_control)
 Set buffer control states.
void reset_buffer_control ()
 Set default buffer control states.
void set_pen (const CL_Pen &pen)
 Select pen.
void reset_pen ()
 Reset pen settings to defaults.
void set_polygon_rasterizer (const CL_PolygonRasterizer &raster)
 Set polygon rasterizer settings.
void reset_polygon_rasterizer ()
 Reset polygon rasterizer settings to defaults.
void draw_primitives (CL_PrimitivesType type, int num_vertices, const CL_PrimitivesArray &array)
 Draw primitives on gc.
void set_primitives_array (const CL_PrimitivesArray &array)
 Set the primitives array on the gc.
void draw_primitives_array (CL_PrimitivesType type, int num_vertices)
 Draws primitives from the current assigned primitives array.
void draw_primitives_array (CL_PrimitivesType type, int offset, int num_vertices)
 Draw primitives array.
void draw_primitives_array_instanced (CL_PrimitivesType type, int offset, int num_vertices, int instance_count)
 Draw primitives array instanced.
void draw_primitives_elements (CL_PrimitivesType type, int count, unsigned int *indices)
 Draw primitives elements.
void draw_primitives_elements (CL_PrimitivesType type, int count, unsigned short *indices)
 Draw primitives elements.
void draw_primitives_elements (CL_PrimitivesType type, int count, unsigned char *indices)
 Draw primitives elements.
void draw_primitives_elements_instanced (CL_PrimitivesType type, int count, unsigned int *indices, int instance_count)
 Draw primitives elements instanced.
void draw_primitives_elements_instanced (CL_PrimitivesType type, int count, unsigned short *indices, int instance_count)
 Draw primitives elements instanced.
void draw_primitives_elements_instanced (CL_PrimitivesType type, int count, unsigned char *indices, int instance_count)
 Draw primitives elements instanced.
void draw_primitives_elements (CL_PrimitivesType type, int count, CL_ElementArrayBuffer &element_array, CL_VertexAttributeDataType indices_type, void *offset=0)
 Draw primitives elements.
void draw_primitives_elements_instanced (CL_PrimitivesType type, int count, CL_ElementArrayBuffer &element_array, CL_VertexAttributeDataType indices_type, void *offset, int instance_count)
 Draw primitives elements instanced.
void reset_primitives_array ()
 Reset the primitives arrays.
void draw_pixels (float x, float y, const CL_PixelBuffer &pixel_buffer, const CL_Rect &src_rect, const CL_Colorf &color=CL_Colorf::white)
 Draw pixel buffer on gc.
void draw_pixels (float x, float y, float zoom_x, float zoom_y, const CL_PixelBuffer &pixel_buffer, const CL_Rect &src_rect, const CL_Colorf &color=CL_Colorf::white)
 Draw pixels.
void clear (const CL_Colorf &color=CL_Colorf::black)
 Clears the whole context using the specified color.
void clear_stencil (int value=0)
 Clear the stencil buffer.
void clear_depth (float value=0)
 Clear the depth buffer.
void set_cliprect (const CL_Rect &rect)
 Set the current clipping rectangle.
void push_cliprect (const CL_Rect &rect)
 Push current clipping rectangle to stack.
void push_cliprect ()
 Push cliprect.
void pop_cliprect ()
 Pop current clipping rectangle from the stack.
void reset_cliprect ()
 Removes the set clipping rectangle and empties the cliprect stack.
void set_map_mode (CL_MapMode mode)
 Set the projection mapping mode.
void set_viewport (const CL_Rectf &viewport)
 Set the viewport to be used in user projection map mode.
void set_projection (const CL_Mat4f &matrix)
 Set the projection matrix to be used in user projection map mode.
void set_modelview (const CL_Mat4f &matrix)
 Sets the model view matrix to a new matrix.
void mult_modelview (const CL_Mat4f &matrix)
 Multiplies the passed matrix onto the model view matrix.
void push_modelview ()
 Pushes current model view matrix onto the model view stack.
void set_translate (float x, float y, float z=0.0)
 Sets a translate offset matrix, ignoring any earlier model view settings.
void mult_translate (float x, float y, float z=0.0)
 Adds the translate offset.
void push_translate (float x, float y, float z=0.0)
 Push translation offset onto model view stack.
void set_rotate (const CL_Angle &angle, float x=0.0, float y=0.0, float z=1.0, bool normalize=true)
 Sets a rotation matrix, ignoring any earlier model view settings.
void mult_rotate (const CL_Angle &angle, float x=0.0, float y=0.0, float z=1.0, bool normalize=true)
 Adds a rotation matrix to existing model view.
void push_rotate (const CL_Angle &angle, float x=0.0, float y=0.0, float z=1.0)
 Pushes a rotation matrix onto model view stack.
void set_scale (float x, float y, float z=1.0)
 Sets a scale matrix, ignoring any earlier model view settings.
void mult_scale (float x, float y, float z=1.0)
 Adds a scale matrix to existing model view.
void push_scale (float x, float y, float z=1.0)
 Pushes a scale matrix onto model view stack.
void pop_modelview ()
 Pops last pushed model view matrix off the stack and makes it the active one.
void flush_batcher ()
 Flushes the render batcher currently active.
void set_batcher (CL_RenderBatcher *batcher)
 Specifies which render batcher is to be currently active.
Events

CL_Signal_v0sig_gc_destruction_imminent ()
 Called when the last GC in the thread is about to be destroyed.

Implementation



class CL_PrimitivesArray
class CL_Sprite_Impl
class CL_Image
class CL_GlyphCache
class CL_Draw

Detailed Description

Interface to drawing graphics.


Constructor & Destructor Documentation

CL_GraphicContext::CL_GraphicContext (  ) 

Constructs a null instance.

CL_GraphicContext::CL_GraphicContext ( CL_GraphicContextProvider provider  ) 

Constructs a GraphicContext.

Parameters:
provider = Graphic Context Provider
CL_GraphicContext::~CL_GraphicContext (  ) 

Member Function Documentation

void CL_GraphicContext::clear ( const CL_Colorf color = CL_Colorf::black  ) 

Clears the whole context using the specified color.

void CL_GraphicContext::clear_depth ( float  value = 0  ) 

Clear the depth buffer.

Parameters:
value,: value to clear to. Range 0.0 - 1.0.
void CL_GraphicContext::clear_stencil ( int  value = 0  ) 

Clear the stencil buffer.

Parameters:
value value to clear to.
void CL_GraphicContext::draw_pixels ( float  x,
float  y,
float  zoom_x,
float  zoom_y,
const CL_PixelBuffer pixel_buffer,
const CL_Rect src_rect,
const CL_Colorf color = CL_Colorf::white 
)

Draw pixels.

Note, For OpenGL targets this is slow. Consider drawing a texture with a pixelbuffer object (created via CL_PixelBuffer(gc, ...) )

Parameters:
x = value
y = value
zoom_x = value
zoom_y = value
pixel_buffer = Pixel Buffer Ref
src_rect = Source rect
color = Colorf
void CL_GraphicContext::draw_pixels ( float  x,
float  y,
const CL_PixelBuffer pixel_buffer,
const CL_Rect src_rect,
const CL_Colorf color = CL_Colorf::white 
)

Draw pixel buffer on gc.

Note, For OpenGL targets this is slow. Consider drawing a texture with a pixelbuffer object (created via CL_PixelBuffer(gc, ...) )

void CL_GraphicContext::draw_primitives ( CL_PrimitivesType  type,
int  num_vertices,
const CL_PrimitivesArray array 
)

Draw primitives on gc.

void CL_GraphicContext::draw_primitives_array ( CL_PrimitivesType  type,
int  num_vertices 
)

Draws primitives from the current assigned primitives array.

void CL_GraphicContext::draw_primitives_array ( CL_PrimitivesType  type,
int  offset,
int  num_vertices 
)

Draw primitives array.

Parameters:
type = Primitives Type
offset = value
num_vertices = value
void CL_GraphicContext::draw_primitives_array_instanced ( CL_PrimitivesType  type,
int  offset,
int  num_vertices,
int  instance_count 
)

Draw primitives array instanced.

Parameters:
type = Primitives Type
offset = value
num_vertices = value
instance_count = number of instances drawn
void CL_GraphicContext::draw_primitives_elements ( CL_PrimitivesType  type,
int  count,
unsigned int *  indices 
)

Draw primitives elements.

Parameters:
type = Primitives Type
count = value
indices = value
void CL_GraphicContext::draw_primitives_elements ( CL_PrimitivesType  type,
int  count,
unsigned short *  indices 
)

Draw primitives elements.

Parameters:
type = Primitives Type
count = value
indices = short
void CL_GraphicContext::draw_primitives_elements ( CL_PrimitivesType  type,
int  count,
unsigned char *  indices 
)

Draw primitives elements.

Parameters:
type = Primitives Type
count = value
indices = char
void CL_GraphicContext::draw_primitives_elements ( CL_PrimitivesType  type,
int  count,
CL_ElementArrayBuffer element_array,
CL_VertexAttributeDataType  indices_type,
void *  offset = 0 
)

Draw primitives elements.

Parameters:
type = Primitives Type
count = value
element_array = Element Array Buffer
indices_type = Vertex Attribute Data Type
offset = void
void CL_GraphicContext::draw_primitives_elements_instanced ( CL_PrimitivesType  type,
int  count,
unsigned int *  indices,
int  instance_count 
)

Draw primitives elements instanced.

Parameters:
type = Primitives Type
count = value
indices = value
instance_count = number of instances drawn
void CL_GraphicContext::draw_primitives_elements_instanced ( CL_PrimitivesType  type,
int  count,
unsigned char *  indices,
int  instance_count 
)

Draw primitives elements instanced.

Parameters:
type = Primitives Type
count = value
indices = char
instance_count = number of instances drawn
void CL_GraphicContext::draw_primitives_elements_instanced ( CL_PrimitivesType  type,
int  count,
CL_ElementArrayBuffer element_array,
CL_VertexAttributeDataType  indices_type,
void *  offset,
int  instance_count 
)

Draw primitives elements instanced.

Parameters:
type = Primitives Type
count = value
element_array = Element Array Buffer
indices_type = Vertex Attribute Data Type
offset = void
instance_count = number of instances drawn
void CL_GraphicContext::draw_primitives_elements_instanced ( CL_PrimitivesType  type,
int  count,
unsigned short *  indices,
int  instance_count 
)

Draw primitives elements instanced.

Parameters:
type = Primitives Type
count = value
indices = short
instance_count = number of instances drawn
void CL_GraphicContext::flush_batcher (  ) 

Flushes the render batcher currently active.

CL_BlendMode CL_GraphicContext::get_blend_mode (  )  const

Returns the blending mode description.

Returns:
The blend mode.
CL_BufferControl CL_GraphicContext::get_buffer_control (  )  const

Returns the buffer control description.

Returns:
The buffer control
CL_Rect CL_GraphicContext::get_cliprect (  )  const

Returns the current clipping rectangle used on the graphic context.

int CL_GraphicContext::get_height (  )  const

Returns the current height of the context.

CL_Size CL_GraphicContext::get_max_texture_size (  )  const

Returns the maximum size of a texture this graphic context supports.

It returns CL_Size(0,0) if there is no known limitation to the max texture size.

const CL_Mat4f& CL_GraphicContext::get_modelview (  )  const

Returns the current effective modelview matrix.

CL_Pen CL_GraphicContext::get_pen (  )  const

Returns the currently selected pen.

Returns:
The pen.
CL_PixelBuffer CL_GraphicContext::get_pixeldata ( const CL_Rect rect,
CL_TextureFormat  pixel_format = cl_abgr8,
bool  clamp = true 
) const

Return the content of the read buffer into a pixel buffer.

CL_PixelBuffer CL_GraphicContext::get_pixeldata ( CL_TextureFormat  pixel_format = cl_abgr8,
bool  clamp = true 
) const

Return the content of the read buffer into a pixel buffer.

CL_PolygonRasterizer CL_GraphicContext::get_polygon_rasterizer (  )  const

Returns the polygon rasterizer setup.

Returns:
The polygon rasterizer
CL_GraphicContextProvider* CL_GraphicContext::get_provider (  ) 

Returns the provider for this graphic context.

const CL_GraphicContextProvider* const CL_GraphicContext::get_provider (  )  const
CL_FrameBuffer CL_GraphicContext::get_read_frame_buffer (  )  const

Returns the currently selected read frame buffer.

Returns:
The frame buffer. Use frame_buffer.is_null() to determine if the frame buffer was not selected
CL_Size CL_GraphicContext::get_size (  )  const

Returns the current size of the context.

CL_Texture CL_GraphicContext::get_texture ( int  index  )  const

Returns the currently selected texture for the specified index.

Parameters:
index = 0 to x, the index of the texture
Returns:
The texture. Use texture.is_null() to determine if the texture was not selected
std::vector<CL_Texture> CL_GraphicContext::get_textures (  )  const

Returns the currently selected textures.

Returns:
The selected textures (placed at unit_index 0 to size()-1). These may contain null textures if textures were not selected
int CL_GraphicContext::get_width (  )  const

Returns the current width of the context.

CL_FrameBuffer CL_GraphicContext::get_write_frame_buffer (  )  const

Returns the currently selected write frame buffer.

Returns:
The frame buffer. Use frame_buffer.is_null() to determine if the frame buffer was not selected
bool CL_GraphicContext::is_null (  )  const [inline]

Returns true if this object is invalid.

Reimplemented in CL_GraphicContext_GL, CL_GraphicContext_GL1, and CL_GraphicContext_SWRender.

void CL_GraphicContext::mult_modelview ( const CL_Mat4f matrix  ) 

Multiplies the passed matrix onto the model view matrix.

void CL_GraphicContext::mult_rotate ( const CL_Angle angle,
float  x = 0.0,
float  y = 0.0,
float  z = 1.0,
bool  normalize = true 
)

Adds a rotation matrix to existing model view.

void CL_GraphicContext::mult_scale ( float  x,
float  y,
float  z = 1.0 
)

Adds a scale matrix to existing model view.

void CL_GraphicContext::mult_translate ( float  x,
float  y,
float  z = 0.0 
)

Adds the translate offset.

This offset will affect any subsequent display operations on the current displaycard, by translating the position of the display operation with the offset. The offset will be offset by any previous offsets pushed onto the stack, eg. it inherits the previous offset.

void CL_GraphicContext::pop_cliprect (  ) 

Pop current clipping rectangle from the stack.

void CL_GraphicContext::pop_modelview (  ) 

Pops last pushed model view matrix off the stack and makes it the active one.

void CL_GraphicContext::push_cliprect ( const CL_Rect rect  ) 

Push current clipping rectangle to stack.

If a rectangle is passed, it afterwards sets clipping rectangle to the union of the current rectangle and the passed rectangle.

void CL_GraphicContext::push_cliprect (  ) 

Push cliprect.

void CL_GraphicContext::push_modelview (  ) 

Pushes current model view matrix onto the model view stack.

void CL_GraphicContext::push_rotate ( const CL_Angle angle,
float  x = 0.0,
float  y = 0.0,
float  z = 1.0 
)

Pushes a rotation matrix onto model view stack.

void CL_GraphicContext::push_scale ( float  x,
float  y,
float  z = 1.0 
)

Pushes a scale matrix onto model view stack.

void CL_GraphicContext::push_translate ( float  x,
float  y,
float  z = 0.0 
)

Push translation offset onto model view stack.

This function is a convenience function for calling push_modelview, then mult_translate.

This offset will affect any subsequent display operations on the current displaycard, by translating the position of the display operation with the offset. The offset will be offset by any previous offsets pushed onto the stack, eg. it inherits the previous offset.

void CL_GraphicContext::reset_blend_mode (  ) 

Reset blending to the default.

void CL_GraphicContext::reset_buffer_control (  ) 

Set default buffer control states.

void CL_GraphicContext::reset_cliprect (  ) 

Removes the set clipping rectangle and empties the cliprect stack.

void CL_GraphicContext::reset_frame_buffer (  ) 

Resets the current frame buffer to be the initial frame buffer.

void CL_GraphicContext::reset_pen (  ) 

Reset pen settings to defaults.

void CL_GraphicContext::reset_polygon_rasterizer (  ) 

Reset polygon rasterizer settings to defaults.

void CL_GraphicContext::reset_primitives_array (  ) 

Reset the primitives arrays.

void CL_GraphicContext::reset_program_object (  ) 

Remove active program object.

void CL_GraphicContext::reset_texture ( int  unit_index  ) 

Remove texture from index.

Parameters:
unit_index = 0 to x, the index of the texture
void CL_GraphicContext::reset_textures (  ) 

Remove all selected textures.

void CL_GraphicContext::set_batcher ( CL_RenderBatcher batcher  ) 

Specifies which render batcher is to be currently active.

If the render batcher is already active, nothing happens. If a different render batcher is currently active, it is flushed before the new batcher is made active.

void CL_GraphicContext::set_blend_mode ( const CL_BlendMode blend_mode  ) 

Set blending modes.

void CL_GraphicContext::set_buffer_control ( const CL_BufferControl buffer_control  ) 

Set buffer control states.

void CL_GraphicContext::set_cliprect ( const CL_Rect rect  ) 

Set the current clipping rectangle.

void CL_GraphicContext::set_frame_buffer ( const CL_FrameBuffer write_buffer  ) 

Sets the current frame buffer.

void CL_GraphicContext::set_frame_buffer ( const CL_FrameBuffer write_buffer,
const CL_FrameBuffer read_buffer 
)
void CL_GraphicContext::set_map_mode ( CL_MapMode  mode  ) 

Set the projection mapping mode.

void CL_GraphicContext::set_modelview ( const CL_Mat4f matrix  ) 

Sets the model view matrix to a new matrix.

void CL_GraphicContext::set_pen ( const CL_Pen pen  ) 

Select pen.

void CL_GraphicContext::set_polygon_rasterizer ( const CL_PolygonRasterizer raster  ) 

Set polygon rasterizer settings.

void CL_GraphicContext::set_primitives_array ( const CL_PrimitivesArray array  ) 

Set the primitives array on the gc.

void CL_GraphicContext::set_program_object ( const CL_ProgramObject program,
int  program_matrix_flags = cl_program_matrix_all_standard 
)

Set active program object.

Parameters:
program = Program to set
program_matrix_flags = Which matricies will be set in the program object ( CL_ProgramMatrixFlags bitmask flags)
void CL_GraphicContext::set_program_object ( CL_StandardProgram  standard_program  ) 

Set active program object to the standard program specified.

void CL_GraphicContext::set_projection ( const CL_Mat4f matrix  ) 

Set the projection matrix to be used in user projection map mode.

void CL_GraphicContext::set_rotate ( const CL_Angle angle,
float  x = 0.0,
float  y = 0.0,
float  z = 1.0,
bool  normalize = true 
)

Sets a rotation matrix, ignoring any earlier model view settings.

void CL_GraphicContext::set_scale ( float  x,
float  y,
float  z = 1.0 
)

Sets a scale matrix, ignoring any earlier model view settings.

void CL_GraphicContext::set_texture ( int  unit_index,
const CL_Texture texture 
)

Select texture into index.

Parameters:
unit_index = 0 to x, the index of this texture
texture = The texture to select. This can be an empty texture CL_Texture()
void CL_GraphicContext::set_textures ( std::vector< CL_Texture > &  textures  ) 

Select textures.

Only textures units from 0 to textures.size()-1 are set.

Parameters:
textures = The texture to select (placed at unit_index 0 to texture.size()-1). These may contain null textures
void CL_GraphicContext::set_translate ( float  x,
float  y,
float  z = 0.0 
)

Sets a translate offset matrix, ignoring any earlier model view settings.

This offset will affect any subsequent display operations on the current displaycard, by translating the position of the display operation with the offset.

void CL_GraphicContext::set_viewport ( const CL_Rectf viewport  ) 

Set the viewport to be used in user projection map mode.

CL_Signal_v0& CL_GraphicContext::sig_gc_destruction_imminent (  ) 

Called when the last GC in the thread is about to be destroyed.

void CL_GraphicContext::throw_if_null (  )  const

Throw an exception if this object is invalid.

Reimplemented in CL_GraphicContext_GL, CL_GraphicContext_GL1, and CL_GraphicContext_SWRender.


Friends And Related Function Documentation

friend class CL_Draw [friend]
friend class CL_GlyphCache [friend]
friend class CL_Image [friend]
friend class CL_PrimitivesArray [friend]
friend class CL_Sprite_Impl [friend]

The documentation for this class was generated from the following file: