rResourceTexture Class Reference

#include <rTexture.h>

Collaboration diagram for rResourceTexture:

Collaboration graph
[legend]

List of all members.

Public Member Functions

 rResourceTexture ()
 Use this if you want to create an empty texture object (ie if you're not sure if you actually want to store a texture).
 rResourceTexture (tResourcePath const &path, bool repx=false, bool repy=false)
 Get a resource from the repository.
 rResourceTexture (rResourceTexture const &other)
 Copy constructor.
rResourceTextureoperator= (rResourceTexture const &other)
 Assignment is safe.
 ~rResourceTexture ()
 This releases the texture if it's not used anymore.
bool Valid ()
 Check if this object stores a texture.
void Select ()
 Use this texture in OpenGL.
tResourcePath const & Path ()

Private Types

typedef InternalTex tex_t
typedef std::list< InternalTex * > texlist_t

Private Attributes

InternalTextex_
bool repx_
bool repy_

Static Private Attributes

static texlist_t textures

Friends

class InternalTex

Classes

class  InternalTex


Detailed Description

Class that implements fetching and caching textures from resource paths.

This class manages its own usecount and is therefore safe to copy and move around.

Definition at line 187 of file rTexture.h.


Member Typedef Documentation

typedef InternalTex rResourceTexture::tex_t [private]

Definition at line 202 of file rTexture.h.

typedef std::list<InternalTex *> rResourceTexture::texlist_t [private]

Definition at line 203 of file rTexture.h.


Constructor & Destructor Documentation

rResourceTexture::rResourceTexture (  )  [inline]

Use this if you want to create an empty texture object (ie if you're not sure if you actually want to store a texture).

Definition at line 210 of file rTexture.h.

00210 : tex_(0) {}

rResourceTexture::rResourceTexture ( tResourcePath const &  path,
bool  repx = false,
bool  repy = false 
)

Get a resource from the repository.

Definition at line 798 of file rTexture.cpp.

References tex_, textures, rResourceTexture::InternalTex::Use(), and tResourcePath::Valid().

00798                                                                                   : repx_(repx), repy_(repy) {
00799     if(!path.Valid()) {
00800         tex_ = 0;
00801         return;
00802     }
00803     for(texlist_t::iterator iter = textures.begin(); iter != textures.end(); ++iter) {
00804         if((*iter)->path_ == path) {
00805             tex_ = *iter;
00806             tex_->Use();
00807             return;
00808         }
00809     }
00810     tex_ = new tex_t(path);
00811 }

Here is the call graph for this function:

rResourceTexture::rResourceTexture ( rResourceTexture const &  other  )  [inline]

Copy constructor.

Definition at line 215 of file rTexture.h.

References tex_, and rResourceTexture::InternalTex::Use().

00215 : tex_(other.tex_) {if(tex_) tex_->Use();}

Here is the call graph for this function:

rResourceTexture::~rResourceTexture (  )  [inline]

This releases the texture if it's not used anymore.

Definition at line 219 of file rTexture.h.

References rResourceTexture::InternalTex::Release(), and tex_.

00219 {if(tex_) tex_->Release();}

Here is the call graph for this function:


Member Function Documentation

rResourceTexture & rResourceTexture::operator= ( rResourceTexture const &  other  ) 

Assignment is safe.

Definition at line 830 of file rTexture.cpp.

References rResourceTexture::InternalTex::Release(), repx_, repy_, tex_, and rResourceTexture::InternalTex::Use().

00830                                                                            {
00831     if(tex_ != other.tex_) {
00832         repx_ = other.repx_;
00833         repy_ = other.repy_;
00834         if(tex_) {
00835             tex_->Release();
00836         }
00837         tex_ = other.tex_;
00838         if(tex_) {
00839             tex_->Use();
00840         }
00841     }
00842     return *this;
00843 }

Here is the call graph for this function:

bool rResourceTexture::Valid (  )  [inline]

Check if this object stores a texture.

Definition at line 221 of file rTexture.h.

References tex_.

Referenced by rGradient::BeginDraw(), and rGradient::DrawAt().

00221 {return tex_;}

Here is the caller graph for this function:

void rResourceTexture::Select (  ) 

Use this texture in OpenGL.

Definition at line 845 of file rTexture.cpp.

References GL_CLAMP_TO_EDGE, repx_, repy_, rITexture::Select(), tERR_WARN, and tex_.

Referenced by rGradient::BeginDraw().

00845                               {
00846 #ifndef DEDICATED
00847     if(tex_) {
00848         tex_->Select();
00849         // Override the actual tecture's settings
00850         if(repx_)
00851             glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_WRAP_S,GL_REPEAT);
00852         else
00853             glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_WRAP_S,GL_CLAMP_TO_EDGE);
00854         if(repy_)
00855             glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_WRAP_T,GL_REPEAT);
00856         else
00857             glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_WRAP_T,GL_CLAMP_TO_EDGE);
00858     } else {
00859         tERR_WARN("Trying to select a resource texture that's not loaded");
00860     }
00861 #endif
00862 }

Here is the call graph for this function:

Here is the caller graph for this function:

tResourcePath const& rResourceTexture::Path (  )  [inline]

Get the actual texture. This object retains ownership of the texture, though Get the path this texture was fetched from

Definition at line 226 of file rTexture.h.

References rResourceTexture::InternalTex::path_, and tex_.

00226 {return tex_->path_;}


Friends And Related Function Documentation

friend class InternalTex [friend]

Definition at line 189 of file rTexture.h.


Member Data Documentation

rResourceTexture::texlist_t rResourceTexture::textures [static, private]

Definition at line 204 of file rTexture.h.

Referenced by rResourceTexture::InternalTex::InternalTex(), rResourceTexture::InternalTex::Release(), and rResourceTexture().

InternalTex* rResourceTexture::tex_ [private]

Definition at line 205 of file rTexture.h.

Referenced by operator=(), Path(), rResourceTexture(), Select(), Valid(), and ~rResourceTexture().

bool rResourceTexture::repx_ [private]

Definition at line 207 of file rTexture.h.

Referenced by operator=(), and Select().

bool rResourceTexture::repy_ [private]

Definition at line 207 of file rTexture.h.

Referenced by operator=(), and Select().


The documentation for this class was generated from the following files:
Generated on Sat Mar 15 23:53:38 2008 for Armagetron Advanced by  doxygen 1.5.4