____                _       __
    / __ )____  _____   | |     / /___ ___________
   / __  / __ \/ ___/   | | /| / / __ `/ ___/ ___/
  / /_/ / /_/ (__  )    | |/ |/ / /_/ / /  (__  )
 /_____/\____/____/     |__/|__/\__,_/_/  /____/

       A futuristic real-time strategy game.
          This file is part of Bos Wars.
(C) Copyright 2001-2007 by the Bos Wars and Stratagus Project. Distributed under the "GNU General Public License"

CGraphic Class Reference

#include <video.h>

Inheritance diagram for CGraphic:

gcn::Image CPlayerColorGraphic

List of all members.

Public Member Functions

void DrawClip (int x, int y) const
void DrawSub (int gx, int gy, int w, int h, int x, int y) const
void DrawSubClip (int gx, int gy, int w, int h, int x, int y) const
void DrawSubTrans (int gx, int gy, int w, int h, int x, int y, unsigned char alpha) const
void DrawSubClipTrans (int gx, int gy, int w, int h, int x, int y, unsigned char alpha) const
void DrawFrame (unsigned frame, int x, int y) const
void DoDrawFrameClip (GLuint *textures, unsigned frame, int x, int y) const
void DrawFrameClip (unsigned frame, int x, int y) const
void DrawFrameTrans (unsigned frame, int x, int y, int alpha) const
void DrawFrameClipTrans (unsigned frame, int x, int y, int alpha) const
void DrawFrameX (unsigned frame, int x, int y) const
void DoDrawFrameClipX (GLuint *textures, unsigned frame, int x, int y) const
void DrawFrameClipX (unsigned frame, int x, int y) const
void DrawFrameTransX (unsigned frame, int x, int y, int alpha) const
void DrawFrameClipTransX (unsigned frame, int x, int y, int alpha) const
CGraphicClone () const
void Load ()
void Flip ()
void UseDisplayFormat ()
void Resize (int w, int h)
bool TransparentPixel (int x, int y)
void MakeShadow ()
bool IsLoaded () const
virtual void * _getData () const
virtual int getWidth () const
virtual int getHeight () const

Static Public Member Functions

static CGraphicNew (const std::string &file, int w=0, int h=0)
static CGraphicForceNew (const std::string &file, int w=0, int h=0)
static void Free (CGraphic *g)

Public Attributes

std::string File
 Filename.
std::string HashFile
 Filename used in hash.
SDL_Surface * Surface
 Surface.
SDL_Surface * SurfaceFlip
 Flipped surface.
int Width
 Width of a frame.
int Height
 Height of a frame.
int NumFrames
 Number of frames.
int GraphicWidth
 Original graphic width.
int GraphicHeight
 Original graphic height.
int Refs
 Uses of this graphic.
bool Resized
 Image has been resized.
GLfloat TextureWidth
 Width of the texture.
GLfloat TextureHeight
 Height of the texture.
GLuint * Textures
 Texture names.
int NumTextures
 Number of textures.

Protected Member Functions

 CGraphic ()
 ~CGraphic ()

Friends

void MakeFontColorTextures (CFont *font)
void CleanFonts (void)
void ReloadFonts (void)
 Cleanup the font module.


Detailed Description

Definition at line 42 of file video.h.


Constructor & Destructor Documentation

CGraphic::CGraphic (  )  [inline, protected]

Definition at line 44 of file video.h.

CGraphic::~CGraphic (  )  [inline, protected]

Definition at line 50 of file video.h.


Member Function Documentation

void CGraphic::DrawClip ( int  x,
int  y 
) const

Video draw the graphic clipped.

Parameters:
x X screen position
y Y screen position

Definition at line 71 of file graphic.cpp.

References CLIP_RECTANGLE, DrawSub(), Height, and Width.

Referenced by CButtonPanel::Draw(), CViewport::DrawMapBackgroundInViewport(), DrawPatch(), DrawPatchIcons(), DrawPatchTileIcons(), EditorUpdateDisplay(), and ShowTitleImage().

void CGraphic::DrawSub ( int  gx,
int  gy,
int  w,
int  h,
int  x,
int  y 
) const

Video draw part of graphic.

Parameters:
gx X offset into object
gy Y offset into object
w width to display
h height to display
x X screen position
y Y screen position

Definition at line 91 of file graphic.cpp.

References DrawTexture(), Surface, Textures, TheScreen, and UseOpenGL.

Referenced by DrawClip(), DrawFrame(), DrawSubClip(), DrawSubTrans(), and VideoDrawChar().

void CGraphic::DrawSubClip ( int  gx,
int  gy,
int  w,
int  h,
int  x,
int  y 
) const

Video draw part of graphic clipped.

Parameters:
gx X offset into object
gy Y offset into object
w width to display
h height to display
x X screen position
y Y screen position

Definition at line 113 of file graphic.cpp.

References CLIP_RECTANGLE, and DrawSub().

Referenced by DrawFrameClip().

void CGraphic::DrawSubTrans ( int  gx,
int  gy,
int  w,
int  h,
int  x,
int  y,
unsigned char  alpha 
) const

Video draw part of graphic with alpha.

Parameters:
gx X offset into object
gy Y offset into object
w width to display
h height to display
x X screen position
y Y screen position
alpha Alpha

Definition at line 132 of file graphic.cpp.

References DrawSub(), Surface, and UseOpenGL.

Referenced by DrawFrameTrans(), and DrawSubClipTrans().

void CGraphic::DrawSubClipTrans ( int  gx,
int  gy,
int  w,
int  h,
int  x,
int  y,
unsigned char  alpha 
) const

Video draw part of graphic with alpha and clipped.

Parameters:
gx X offset into object
gy Y offset into object
w width to display
h height to display
x X screen position
y Y screen position
alpha Alpha

Definition at line 159 of file graphic.cpp.

References CLIP_RECTANGLE, and DrawSubTrans().

Referenced by DrawFrameClipTrans().

void CGraphic::DrawFrame ( unsigned  frame,
int  x,
int  y 
) const

Draw graphic object unclipped.

Parameters:
frame number of frame (object index)
x x coordinate on the screen
y y coordinate on the screen

Definition at line 175 of file graphic.cpp.

References DrawSub(), DrawTexture(), GraphicWidth, Height, Surface, Textures, UseOpenGL, and Width.

Referenced by DrawFrameTrans(), and DrawMenuButton().

void CGraphic::DoDrawFrameClip ( GLuint *  textures,
unsigned  frame,
int  x,
int  y 
) const

void CGraphic::DrawFrameClip ( unsigned  frame,
int  x,
int  y 
) const

Draw graphic object clipped.

Parameters:
frame number of frame (object index)
x x coordinate on the screen
y y coordinate on the screen

Definition at line 223 of file graphic.cpp.

References DoDrawFrameClip(), DrawSubClip(), Height, Surface, Textures, UseOpenGL, and Width.

Referenced by CDecoVarSpriteBar::Draw(), GraphicAnimation::draw(), DrawConstructionShadow(), DrawCosts(), DrawCursor(), DrawFogOfWarTile(), DrawFrameClipTrans(), CIcon::DrawIcon(), MissileType::DrawMissileType(), DrawPieMenu(), CPlayerColorGraphic::DrawPlayerColorFrameClip(), DrawPopup(), and DrawShadow().

void CGraphic::DrawFrameTrans ( unsigned  frame,
int  x,
int  y,
int  alpha 
) const

Definition at line 234 of file graphic.cpp.

References DrawFrame(), DrawSubTrans(), Height, Surface, UseOpenGL, and Width.

void CGraphic::DrawFrameClipTrans ( unsigned  frame,
int  x,
int  y,
int  alpha 
) const

void CGraphic::DrawFrameX ( unsigned  frame,
int  x,
int  y 
) const

Draw graphic object unclipped and flipped in X direction.

Parameters:
frame number of frame (object index)
x x coordinate on the screen
y y coordinate on the screen

Definition at line 293 of file graphic.cpp.

References DrawTexture(), GraphicWidth, Height, SurfaceFlip, Textures, TheScreen, UseOpenGL, and Width.

Referenced by DrawFrameTransX().

void CGraphic::DoDrawFrameClipX ( GLuint *  textures,
unsigned  frame,
int  x,
int  y 
) const

void CGraphic::DrawFrameClipX ( unsigned  frame,
int  x,
int  y 
) const

Draw graphic object clipped and flipped in X direction.

Parameters:
frame number of frame (object index)
x x coordinate on the screen
y y coordinate on the screen

Definition at line 359 of file graphic.cpp.

References CLIP_RECTANGLE, DoDrawFrameClipX(), Height, SurfaceFlip, Textures, TheScreen, UseOpenGL, and Width.

Referenced by DrawConstructionShadow(), DrawFrameClipTransX(), MissileType::DrawMissileType(), CPlayerColorGraphic::DrawPlayerColorFrameClipX(), and DrawShadow().

void CGraphic::DrawFrameTransX ( unsigned  frame,
int  x,
int  y,
int  alpha 
) const

Definition at line 388 of file graphic.cpp.

References DrawFrameX(), Height, Surface, SurfaceFlip, TheScreen, UseOpenGL, and Width.

void CGraphic::DrawFrameClipTransX ( unsigned  frame,
int  x,
int  y,
int  alpha 
) const

CGraphic * CGraphic::New ( const std::string &  file,
int  w = 0,
int  h = 0 
) [static]

Make a new graphic object.

Parameters:
file Filename
w Width of a frame (optional)
h Height of a frame (optional)
Returns:
New graphic object

Reimplemented in CPlayerColorGraphic.

Definition at line 487 of file graphic.cpp.

References Assert, ExitFatal(), File, GraphicHash, HashFile, Height, Refs, and Width.

Referenced by CclDefineCursor(), CclDefineMissileType(), CclSetFogOfWarGraphics(), CPatchType::load(), LoadDecorations(), ParseButtonStyleProperties(), PatchLoadIcons(), ShowTitleImage(), and tolua_stratagus_CGraphic_New00().

CGraphic * CGraphic::ForceNew ( const std::string &  file,
int  w = 0,
int  h = 0 
) [static]

Make a new graphic object. Don't reuse a graphic from the hash table.

Parameters:
file Filename
w Width of a frame (optional)
h Height of a frame (optional)
Returns:
New graphic object

Reimplemented in CPlayerColorGraphic.

Definition at line 559 of file graphic.cpp.

References ExitFatal(), File, GraphicHash, HashCount, HashFile, Height, sprintf_s(), and Width.

Referenced by Clone(), LoadConstructions(), and LoadUnitTypeSprite().

CGraphic * CGraphic::Clone (  )  const

Clone a graphic

Definition at line 582 of file graphic.cpp.

References File, ForceNew(), Height, IsLoaded(), Load(), and Width.

Referenced by CreatePatchIcons().

void CGraphic::Free ( CGraphic g  )  [static]

void CGraphic::Load ( void   ) 

void CGraphic::Flip (  ) 

Flip graphic and store in graphic->SurfaceFlip

Definition at line 778 of file graphic.cpp.

References Surface, SurfaceFlip, and UseOpenGL.

Referenced by MissileType::LoadMissileSprite(), and LoadUnitTypeSprite().

void CGraphic::UseDisplayFormat (  ) 

Convert the SDL surface to the display format

Definition at line 833 of file graphic.cpp.

References Surface, SurfaceFlip, and UseOpenGL.

Referenced by CUserInterface::Load().

void CGraphic::Resize ( int  w,
int  h 
)

Resize a graphic

Parameters:
w New width of graphic.
h New height of graphic.

Definition at line 1084 of file graphic.cpp.

References Assert, data, FreeSurface(), GraphicHeight, GraphicWidth, Height, int(), Load(), MakeTexture(), NumTextures, Resized, Surface, SurfaceFlip, Textures, UseOpenGL, and Width.

Referenced by CreatePatchIcons(), and ShowTitleImage().

bool CGraphic::TransparentPixel ( int  x,
int  y 
)

Check if a pixel is transparent

Parameters:
x X coordinate
y Y coordinate
Returns:
True if the pixel is transparent, False otherwise

Definition at line 1231 of file graphic.cpp.

References Surface.

Referenced by OnGraphic().

void CGraphic::MakeShadow (  ) 

Make shadow sprite

Todo:
FIXME: 32bpp

Definition at line 1264 of file graphic.cpp.

References MakeTexture(), NumTextures, Surface, SurfaceFlip, Textures, and UseOpenGL.

Referenced by LoadUnitTypeSprite().

bool CGraphic::IsLoaded (  )  const [inline]

Definition at line 91 of file video.h.

References Surface.

Referenced by Clone(), CFont::IsLoaded(), and MissileType::LoadMissileSprite().

virtual void* CGraphic::_getData (  )  const [inline, virtual]

Gets the data of the Image. Image data can be different things depending on what ImageLoader you use. If you for instance use the SDLImageLoader then an SDL_Surface will be returned.

Returns:
a void pointer to the Image data.
See also:
SDLImageLoader, AllegroImageLoader

Reimplemented from gcn::Image.

Definition at line 94 of file video.h.

References Surface.

virtual int CGraphic::getWidth (  )  const [inline, virtual]

Gets the width of the Image.

Returns:
the image width

Reimplemented from gcn::Image.

Definition at line 95 of file video.h.

References Width.

Referenced by DrawCursor().

virtual int CGraphic::getHeight (  )  const [inline, virtual]

Gets the height of the Image.

Returns:
the image height

Reimplemented from gcn::Image.

Definition at line 96 of file video.h.

References Height.

Referenced by DrawCursor().


Friends And Related Function Documentation

void MakeFontColorTextures ( CFont font  )  [friend]

Make font bitmap.

Parameters:
font Font number

Definition at line 714 of file font.cpp.

void CleanFonts ( void   )  [friend]

Clean up the font module.

Definition at line 902 of file font.cpp.

void ReloadFonts ( void   )  [friend]

Cleanup the font module.

Reload OpenGL fonts

Definition at line 790 of file font.cpp.


Member Data Documentation

std::string CGraphic::File

std::string CGraphic::HashFile

Filename used in hash.

Definition at line 99 of file video.h.

Referenced by CPlayerColorGraphic::ForceNew(), ForceNew(), Free(), CPlayerColorGraphic::New(), and New().

SDL_Surface* CGraphic::Surface

SDL_Surface* CGraphic::SurfaceFlip

Uses of this graphic.

Definition at line 107 of file video.h.

Referenced by Free(), CPlayerColorGraphic::New(), and New().

Image has been resized.

Definition at line 108 of file video.h.

Referenced by Resize().

Width of the texture.

Definition at line 109 of file video.h.

Referenced by DrawTexture(), and MakeTextures().

Height of the texture.

Definition at line 110 of file video.h.

Referenced by DrawTexture(), and MakeTextures().

Number of textures.

Definition at line 112 of file video.h.

Referenced by CleanFonts(), Free(), FreeOpenGLFonts(), FreeOpenGLGraphics(), MakeShadow(), MakeTextures(), and Resize().


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

Generated on Sat Feb 21 00:28:23 2009 for Bos Wars by  doxygen 1.5.6