CrystalSpace

Public API Reference

Main Page | Modules | Class Hierarchy | Alphabetical List | Class List | File List | Class Members | File Members | Related Pages

cspixmap.h

00001 /*
00002     Crystal Space 3D engine: 2D pixmaps
00003     Copyright (C) 1998,1999 by Andrew Zabolotny <bit@eltech.ru>
00004 
00005     This library is free software; you can redistribute it and/or
00006     modify it under the terms of the GNU Library General Public
00007     License as published by the Free Software Foundation; either
00008     version 2 of the License, or (at your option) any later version.
00009 
00010     This library is distributed in the hope that it will be useful,
00011     but WITHOUT ANY WARRANTY; without even the implied warranty of
00012     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00013     Library General Public License for more details.
00014 
00015     You should have received a copy of the GNU Library General Public
00016     License along with this library; if not, write to the Free
00017     Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
00018 */
00019 
00020 #ifndef __CS_CSPIXMAP_H__
00021 #define __CS_CSPIXMAP_H__
00022 
00023 #include "csextern.h"
00024 
00025 #include "csutil/ref.h"
00026 #include "ivideo/graph3d.h"
00027 #include "ivideo/texture.h"
00028 #include "iengine/texture.h"
00029 
00031 #define PIXMAP_TOP      0
00032 #define PIXMAP_LEFT     0
00033 #define PIXMAP_CENTER   1
00034 #define PIXMAP_BOTTOM   2
00035 #define PIXMAP_RIGHT    2
00036 
00044 class CS_CSTOOL_EXPORT csPixmap
00045 {
00046 public:
00048   virtual ~csPixmap() {}
00049 
00051   virtual int Width() = 0;
00053   virtual int Height() = 0;
00055   virtual void Advance(csTicks ElapsedTime) = 0;
00057   virtual iTextureHandle *GetTextureHandle() = 0;
00058 
00060   virtual void DrawScaled (iGraphics3D* g3d, int sx, int sy, int sw, int sh,
00061     uint8 Alpha = 0) = 0;
00063   inline void DrawScaledAlign (iGraphics3D* g3d, int sx, int sy, int sw,
00064       int sh, int alnx, int alny, uint8 Alpha = 0)
00065     { DrawScaled (g3d, sx - alnx * sw / 2, sy - alny * sh / 2, sw, sh, Alpha); }
00067   inline void Draw (iGraphics3D* g3d, int sx, int sy, uint8 Alpha = 0)
00068     { DrawScaled (g3d, sx, sy, Width(), Height(), Alpha); }
00070   inline void DrawAlign (iGraphics3D* g3d, int sx, int sy, int alnx, int alny,
00071       uint8 Alpha = 0)
00072     { DrawScaledAlign (g3d, sx, sy, Width(), Height(), alnx, alny, Alpha); }
00073 
00080   virtual void DrawTiled (iGraphics3D* g3d, int sx, int sy, int sw, int sh,
00081     int orgx, int orgy, uint8 Alpha = 0) = 0;
00083   inline void DrawTiled (iGraphics3D* g3d, int sx, int sy, int w, int h,
00084       uint8 Alpha = 0)
00085   { DrawTiled (g3d, sx, sy, w, h, sx, sy, Alpha); }
00086 };
00087 
00089 class CS_CSTOOL_EXPORT csSimplePixmap : public csPixmap
00090 {
00091 protected:
00092   csRef<iTextureHandle> hTex;
00093   int tx, ty, tw, th;
00094 
00095 public:
00097   csSimplePixmap (iTextureHandle *hTexture);
00099   csSimplePixmap (iTextureHandle *hTexture, int x, int y, int w, int h);
00101   virtual ~csSimplePixmap ();
00102 
00104   void SetTextureHandle (iTextureHandle *hTexture);
00106   inline void SetTextureRectangle (int x, int y, int w, int h)
00107   { tx = x; ty = y; tw = w; th = h; }
00108 
00109   // implementation of csPixmap methods
00110   virtual void DrawScaled (iGraphics3D* g3d, int sx, int sy, int sw, int sh,
00111     uint8 Alpha = 0);
00112   virtual void DrawTiled (iGraphics3D* g3d, int sx, int sy, int sw, int sh,
00113     int orgx, int orgy, uint8 Alpha = 0);
00114   virtual int Width ();
00115   virtual int Height ();
00116   virtual void Advance(csTicks /*ElapsedTime*/) {}
00117   virtual iTextureHandle *GetTextureHandle ();
00118 };
00119 
00120 #endif // __CS_CSPIXMAP_H__

Generated for Crystal Space by doxygen 1.3.9.1