ClanSoft logo
ClanSoft logo

    CL_Surface

Image class in ClanLib.

Description

This class is used to draw 2D images onto the backbuffer or to a renderer target.

In ClanLib, a surface is understood to be an image represented in a form, where it is most suitable for as fast rendering as possible. Unlike many other libraries, it is not possible to get direct access to the surface data.

A surface uses a surface provider to load its data. It is passed at creation time, and you can either roll your own provider, or use one already available in ClanLib.

It is also possible to create a surface from a resource source. This will allow you to load an image using a resource ID instead of directly specifying the image in your source code.

Dynamic surfaces

If you have an image which changes very frequently (eg. each frame), you want to use a dynamic surface instead. The difference is that the surface won't cache the image, and it won't convert it to another image format more suitable for the display target. Note that this is only faster if you change your image very frequently - otherwise a normal surface is the best solution.

When constructing your own images, you will most likely find the canvas surface provider interesting. This class will make it easier to create a custom drawing area where you can draw your image.

All surfaceproviders is a renderer target. However, most of the normal surface providers are "read only", meaning that their image data will only remain intact during a lock session. This is because the providers consume less memory when the image is only available, when someone needs it. Only the canvas provider will not destroy the image.

A surface can blit (draw itself) itself to the backbuffer, or to a renderer target. This means that you can use the surface to draw one surface provider to another.

Class members

static CL_Surface *load(
         const char *resource_id,
        CL_ResourceManager *manager)
static CL_Surface *create( CL_SurfaceProvider *provider, bool delete_provider=false)
virtual void reload()
virtual CL_SurfaceProvider *get_provider()
virtual void put_screen( int x, int y, int spr_no=0, CL_DisplayCard *card=NULL)
virtual void put_screen( int x, int y, float scale_x, float scale_y, int spr_no=0, CL_DisplayCard *card=NULL)
virtual void put_screen( int x, int y, int size_x, int size_y, int spr_no=0, CL_DisplayCard *card=NULL)
virtual void put_target( int x, int y, int spr_no, CL_Target *target)
virtual unsigned int get_width()
virtual unsigned int get_height()
virtual unsigned int get_num_frames()
virtual bool is_video(CL_DisplayCard *card = NULL)
virtual bool is_loaded(CL_DisplayCard *card = NULL)
virtual bool convert_video(CL_DisplayCard *card = NULL)
virtual bool convert_system(CL_DisplayCard *card = NULL)
virtual void flush(CL_DisplayCard *card = NULL)

See Also

None


Back to index



This page was built using the Perceps documentation system.