Vegastrike 0.5.1 rc1  1.0
Original sources for Vegastrike Evolved
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
GuiTexture Class Reference

#include <guitexture.h>

Public Member Functions

bool read (const std::string &fileName)
 
void draw (const Rect &rect) const
 
 GuiTexture (void)
 
 ~GuiTexture (void)
 

Protected Attributes

class Texturem_texture
 

Detailed Description

Definition at line 31 of file guitexture.h.

Constructor & Destructor Documentation

GuiTexture::GuiTexture ( void  )

Definition at line 73 of file guitexture.cpp.

73  :
74  m_texture( NULL )
75 {}
GuiTexture::~GuiTexture ( void  )

Definition at line 77 of file guitexture.cpp.

References m_texture.

78 {
79  if (m_texture) delete m_texture;
80 }

Member Function Documentation

void GuiTexture::draw ( const Rect rect) const

Definition at line 53 of file guitexture.cpp.

References Rect::bottom(), GFXBegin(), GFXColor4f(), GFXEnd(), GFXQUAD, GFXTexCoord2f(), GFXVertexf(), Rect::left(), Rect::right(), Rect::top(), and Vector.

Referenced by StaticImageDisplay::draw(), and Window::drawBackground().

54 {
55  //Don't draw unless there is something usable.
56  if ( m_texture == NULL || !m_texture->LoadSuccess() )
57  return;
59  GFXBegin( GFXQUAD );
60  GFXColor4f( 1, 1, 1, 1 );
61  GFXTexCoord2f( 0, 1 );
62  GFXVertexf( Vector( rect.left(), rect.top(), 0.00f ) );
63  GFXTexCoord2f( 0, 0 );
64  GFXVertexf( Vector( rect.left(), rect.bottom(), 0.00f ) );
65  GFXTexCoord2f( 1, 0 );
66  GFXVertexf( Vector( rect.right(), rect.bottom(), 0.00f ) );
67  GFXTexCoord2f( 1, 1 );
68  GFXVertexf( Vector( rect.right(), rect.top(), 0.00f ) );
69  GFXEnd();
70 }
bool GuiTexture::read ( const std::string &  fileName)

Definition at line 39 of file guitexture.cpp.

References BILINEAR, Texture::LoadSuccess(), and BaseUtil::Texture().

Referenced by Window::setTexture(), and StaticImageDisplay::setTexture().

40 {
41  Texture*oldTexture( m_texture );
42  m_texture = new Texture( fileName.c_str(), 0, BILINEAR );
43  if (m_texture && !m_texture->LoadSuccess() && oldTexture) {
44  delete m_texture;
45  m_texture = oldTexture;
46  } else {
47  delete oldTexture;
48  }
49  return m_texture->LoadSuccess();
50 }

Member Data Documentation

class Texture* GuiTexture::m_texture
protected

Definition at line 49 of file guitexture.h.

Referenced by ~GuiTexture().


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