3.1 The lg_surface class

This video handler is used to display non-animated objects.



lg_surface Class Definition


class lg_surface: public lg_video_handler
{
	protected:
		//whoa, this is some secret stuff...
		//look at the source code for the protected listing....

	public:
		lg_surface();
		~lg_surface();
		
		int load_image(char *fname, int mode, lg_color *color);
		void destroy ();
		void create_text (char *str, TTF_Font *font);
		virtual int render ();
		virtual char* get_pixel_map ();
		virtual void get_rect_map(lg_rect *rect);	
};



Methods



int load_image(char *fname, int mode, lg_color *color);
char *fname this is the image filename.

int mode if 0 is passed, then the whole image will be opaque, and the lg_color *color parameter can be set to NULL. If LF_CO_TRANSPARENT is passed, then lg_color *color will define the color to consider transparent.

This function loads an image onto the surface.

void destroy ();
Frees up the resources used by this surface.

void create_text (char *str, TTF_Font *font);
char *str string to be printed on the surface.

TTF_Font this should be a true type font already loaded in memory using the SDL_TTF library.

This method destroys the current surface, if there's one, and prints text with transparent background.

virtual int render ();
Virtual function. See 2.3 The lg_video_handler class

virtual char* get_pixel_map ();
Virtual function. See 2.3 The lg_video_handler class

virtual void get_rect_map(lg_rect *rect);
Virtual function. See 2.3 The lg_video_handler class



Back to Home