Surface Class Reference

A rectangular image. More...

#include <surface.hpp>

List of all members.

Public Member Functions

 ~Surface ()
SurfacePtr clone () const
void hflip ()
 flip the surface horizontally
bool get_flipx () const
TexturePtr get_texture () const
SurfaceDataget_surface_data () const
int get_x () const
int get_y () const
int get_width () const
int get_height () const
Vector get_position () const
Vector get_size () const
 returns a vector containing width and height

Static Public Member Functions

static SurfacePtr create (const std::string &file)
static SurfacePtr create (const std::string &file, const Rect &rect)

Private Member Functions

 Surface (const std::string &file)
 Surface (const std::string &file, const Rect &rect)
 Surface (const Surface &)
Surfaceoperator= (const Surface &)

Private Attributes

TexturePtr texture
SurfaceDatasurface_data
Rect rect
bool flipx


Detailed Description

A rectangular image.

The class basically holds a reference to a texture with additional UV coordinates that specify a rectangular area on this texture

Definition at line 33 of file surface.hpp.


Constructor & Destructor Documentation

Surface::Surface ( const std::string &  file  )  [private]

Definition at line 38 of file surface.cpp.

References VideoSystem::new_surface_data(), and surface_data.

Referenced by clone(), and create().

00038                                       :
00039   texture(texture_manager->get(file)),
00040   surface_data(),
00041   rect(0, 0, 
00042       Size(texture->get_image_width(),
00043            texture->get_image_height())),
00044   flipx(false)
00045 {
00046   surface_data = VideoSystem::new_surface_data(*this);
00047 }

Surface::Surface ( const std::string &  file,
const Rect rect 
) [private]

Definition at line 49 of file surface.cpp.

References VideoSystem::new_surface_data(), and surface_data.

00049                                                          :
00050   texture(texture_manager->get(file, rect_)),
00051   surface_data(),
00052   rect(0, 0, Size(rect_.get_width(), rect_.get_height())),
00053   flipx(false)
00054 {
00055   surface_data = VideoSystem::new_surface_data(*this);
00056 }

Surface::Surface ( const Surface  )  [private]

Definition at line 58 of file surface.cpp.

References VideoSystem::new_surface_data(), and surface_data.

00058                                    :
00059   texture(rhs.texture),
00060   surface_data(),
00061   rect(rhs.rect),
00062   flipx(false)
00063 {
00064   surface_data = VideoSystem::new_surface_data(*this);
00065 }

Surface::~Surface (  ) 

Definition at line 67 of file surface.cpp.

References VideoSystem::free_surface_data(), and surface_data.


Member Function Documentation

SurfacePtr Surface::create ( const std::string &  file  )  [static]

Definition at line 27 of file surface.cpp.

References Surface().

Referenced by Background::Background(), CloudParticleSystem::CloudParticleSystem(), CometParticleSystem::CometParticleSystem(), GameSession::GameSession(), GhostParticleSystem::GhostParticleSystem(), InfoBox::InfoBox(), InfoBoxLine::InfoBoxLine(), Console::init_graphics(), LevelTime::LevelTime(), Tile::load_images(), Font::loadFontSurface(), Menu::Menu(), MouseCursor::MouseCursor(), SpriteData::parse_action(), Player::Player(), PlayerStatus::PlayerStatus(), RainParticleSystem::RainParticleSystem(), Background::set_image(), SnowParticleSystem::SnowParticleSystem(), TextScroller::TextScroller(), TitleScreen::TitleScreen(), and Yeti::Yeti().

00028 {
00029   return SurfacePtr(new Surface(file));
00030 }

SurfacePtr Surface::create ( const std::string &  file,
const Rect rect 
) [static]

Definition at line 33 of file surface.cpp.

References rect, and Surface().

00034 {
00035   return SurfacePtr(new Surface(file, rect));
00036 }

SurfacePtr Surface::clone (  )  const

Definition at line 73 of file surface.cpp.

References Surface().

00074 {
00075   SurfacePtr surface(new Surface(*this));
00076   return surface;
00077 }

void Surface::hflip (  ) 

flip the surface horizontally

Definition at line 80 of file surface.cpp.

References flipx.

00081 {
00082   flipx = !flipx;
00083 }

bool Surface::get_flipx (  )  const

Definition at line 85 of file surface.cpp.

References flipx.

Referenced by SDLRenderer::draw_surface(), SDLLightmap::draw_surface(), GLSurfaceData::get_uv_left(), and GLSurfaceData::get_uv_right().

00086 {
00087   return flipx;
00088 }

TexturePtr Surface::get_texture (  )  const

Definition at line 91 of file surface.cpp.

References texture.

Referenced by SDLRenderer::draw_surface(), SDLLightmap::draw_surface(), GLRenderer::draw_surface(), GLLightmap::draw_surface(), and SDLSurfaceData::SDLSurfaceData().

00092 {
00093   return texture;
00094 }

SurfaceData * Surface::get_surface_data (  )  const

Definition at line 97 of file surface.cpp.

References surface_data.

Referenced by SDLRenderer::draw_surface(), SDLLightmap::draw_surface(), GLRenderer::draw_surface(), and GLLightmap::draw_surface().

00098 {
00099   return surface_data;
00100 }

int Surface::get_x (  )  const

Definition at line 103 of file surface.cpp.

References Rect::left, and rect.

Referenced by get_position(), and SDLSurfaceData::SDLSurfaceData().

00104 {
00105   return rect.left;
00106 }

int Surface::get_y (  )  const

Definition at line 109 of file surface.cpp.

References rect, and Rect::top.

Referenced by get_position(), and SDLSurfaceData::SDLSurfaceData().

00110 {
00111   return rect.top;
00112 }

int Surface::get_width (  )  const

Definition at line 115 of file surface.cpp.

References Rect::get_width(), and rect.

Referenced by GLRenderer::draw_surface(), GLLightmap::draw_surface(), get_size(), and SDLSurfaceData::SDLSurfaceData().

00116 {
00117   return rect.get_width();
00118 }

int Surface::get_height (  )  const

Definition at line 121 of file surface.cpp.

References Rect::get_height(), and rect.

Referenced by GLRenderer::draw_surface(), GLLightmap::draw_surface(), get_size(), and SDLSurfaceData::SDLSurfaceData().

00122 {
00123   return rect.get_height();
00124 }

Vector Surface::get_position (  )  const

Definition at line 127 of file surface.cpp.

References get_x(), and get_y().

00128 {
00129   return Vector(get_x(), get_y()); 
00130 }

Vector Surface::get_size (  )  const

returns a vector containing width and height

Definition at line 133 of file surface.cpp.

References get_height(), and get_width().

00134 {
00135   return Vector(get_width(), get_height()); 
00136 }

Surface& Surface::operator= ( const Surface  )  [private]


Member Data Documentation

TexturePtr Surface::texture [private]

Definition at line 40 of file surface.hpp.

Referenced by get_texture().

SurfaceData* Surface::surface_data [private]

Definition at line 41 of file surface.hpp.

Referenced by get_surface_data(), Surface(), and ~Surface().

Rect Surface::rect [private]

Definition at line 42 of file surface.hpp.

Referenced by create(), get_height(), get_width(), get_x(), and get_y().

bool Surface::flipx [private]

Definition at line 43 of file surface.hpp.

Referenced by get_flipx(), and hflip().


The documentation for this class was generated from the following files:
Generated on Mon Jun 9 03:38:37 2014 for SuperTux by  doxygen 1.5.1