Pyrogenesis  13997
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Public Member Functions | Private Types | Private Member Functions | Private Attributes | Friends | List of all members
CTexture Class Reference

Represents a texture object. More...

#include <TextureManager.h>

Public Member Functions

 ~CTexture ()
 
size_t GetWidth () const
 Returns the width (in pixels) of the current texture. More...
 
size_t GetHeight () const
 Returns the height (in pixels) of the current texture. More...
 
bool HasAlpha () const
 Returns whether the current texture has an alpha channel. More...
 
u32 GetBaseColour () const
 Returns the ARGB value of the lowest mipmap level (i.e. More...
 
void Bind (size_t unit=0)
 Bind the texture to the given GL texture unit. More...
 
Handle GetHandle ()
 Returns a ogl_tex handle, for later binding. More...
 
bool TryLoad ()
 Attempt to load the texture data quickly, as with Bind(). More...
 
bool IsLoaded ()
 Returns whether the texture data is currently loaded. More...
 
void Prefetch ()
 Activate the prefetching optimisation for this texture. More...
 

Private Types

enum  {
  UNLOADED, PREFETCH_NEEDS_LOADING, PREFETCH_NEEDS_CONVERTING, PREFETCH_IS_CONVERTING,
  HIGH_NEEDS_CONVERTING, HIGH_IS_CONVERTING, LOADED
}
 

Private Member Functions

 CTexture (Handle handle, const CTextureProperties &props, CTextureManagerImpl *textureManager)
 
 NONCOPYABLE (CTexture)
 
void SetHandle (Handle handle, bool takeOwnership=false)
 Replace the Handle stored by this object. More...
 

Private Attributes

const CTextureProperties m_Properties
 
Handle m_Handle
 
u32 m_BaseColour
 
enum CTexture:: { ... }  m_State
 
CTextureManagerImplm_TextureManager
 
boost::weak_ptr< CTexturem_Self
 

Friends

class CTextureManagerImpl
 
struct TextureCacheCmp
 
struct TPequal_to
 
struct TPhash
 

Detailed Description

Represents a texture object.

The texture data may or may not have been loaded yet. Before it has been loaded, all operations will act on a default 1x1-pixel grey texture instead.

Definition at line 191 of file TextureManager.h.

Member Enumeration Documentation

anonymous enum
private
Enumerator
UNLOADED 
PREFETCH_NEEDS_LOADING 
PREFETCH_NEEDS_CONVERTING 
PREFETCH_IS_CONVERTING 
HIGH_NEEDS_CONVERTING 
HIGH_IS_CONVERTING 
LOADED 

Definition at line 274 of file TextureManager.h.

Constructor & Destructor Documentation

CTexture::CTexture ( Handle  handle,
const CTextureProperties props,
CTextureManagerImpl textureManager 
)
explicitprivate

Definition at line 509 of file TextureManager.cpp.

CTexture::~CTexture ( )

Definition at line 518 of file TextureManager.cpp.

Member Function Documentation

void CTexture::Bind ( size_t  unit = 0)

Bind the texture to the given GL texture unit.

If the texture data hasn't been loaded yet, this may wait a short while to load it. If loading takes too long then it will return sooner and the data will be loaded in a background thread, so this does not guarantee the texture really will be loaded.

Definition at line 524 of file TextureManager.cpp.

u32 CTexture::GetBaseColour ( ) const

Returns the ARGB value of the lowest mipmap level (i.e.

the average of the whole texture). Returns 0 if the texture has no mipmaps.

Definition at line 607 of file TextureManager.cpp.

Handle CTexture::GetHandle ( )

Returns a ogl_tex handle, for later binding.

See comments from Bind().

Definition at line 529 of file TextureManager.cpp.

size_t CTexture::GetHeight ( ) const

Returns the height (in pixels) of the current texture.

Definition at line 593 of file TextureManager.cpp.

size_t CTexture::GetWidth ( ) const

Returns the width (in pixels) of the current texture.

Definition at line 586 of file TextureManager.cpp.

bool CTexture::HasAlpha ( ) const

Returns whether the current texture has an alpha channel.

Definition at line 600 of file TextureManager.cpp.

bool CTexture::IsLoaded ( )

Returns whether the texture data is currently loaded.

Definition at line 569 of file TextureManager.cpp.

CTexture::NONCOPYABLE ( CTexture  )
private
void CTexture::Prefetch ( )

Activate the prefetching optimisation for this texture.

Use this if it is likely the texture will be needed in the near future. It will be loaded in the background so that it is likely to be ready when it is used by Bind().

Definition at line 558 of file TextureManager.cpp.

void CTexture::SetHandle ( Handle  handle,
bool  takeOwnership = false 
)
private

Replace the Handle stored by this object.

If takeOwnership is true, it will not increment the Handle's reference count.

Definition at line 574 of file TextureManager.cpp.

bool CTexture::TryLoad ( )

Attempt to load the texture data quickly, as with Bind().

Returns whether the texture data is currently loaded.

Definition at line 540 of file TextureManager.cpp.

Friends And Related Function Documentation

friend class CTextureManagerImpl
friend

Definition at line 193 of file TextureManager.h.

friend struct TextureCacheCmp
friend

Definition at line 194 of file TextureManager.h.

friend struct TPequal_to
friend

Definition at line 195 of file TextureManager.h.

friend struct TPhash
friend

Definition at line 196 of file TextureManager.h.

Member Data Documentation

u32 CTexture::m_BaseColour
private

Definition at line 272 of file TextureManager.h.

Handle CTexture::m_Handle
private

Definition at line 271 of file TextureManager.h.

const CTextureProperties CTexture::m_Properties
private

Definition at line 269 of file TextureManager.h.

boost::weak_ptr<CTexture> CTexture::m_Self
private

Definition at line 288 of file TextureManager.h.

enum { ... } CTexture::m_State
CTextureManagerImpl* CTexture::m_TextureManager
private

Definition at line 284 of file TextureManager.h.


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