Crystal Space: cstool/cspixmap.h Source File (Crystal Space Public API Reference)

| ## Public API Reference

- Main Page
- Modules
- Namespaces
- Classes
- Files
- Related Pages

- File List
- File Members

# cstool/cspixmap.h

Go to the documentation of this file.

    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
    00027 #include "csextern.h"
    00028
    00029 #include "csutil/ref.h"
    00030
    00031 struct iGraphics3D;
    00032 struct iTextureHandle;
    00033
    00041 class CS_CRYSTALSPACE_EXPORT csPixmap
    00042 {
    00043 public:
    00045   virtual ~csPixmap() {}
    00046
    00048   virtual int Width() = 0;
    00050   virtual int Height() = 0;
    00052   virtual void Advance(csTicks ElapsedTime) = 0;
    00054   virtual iTextureHandle *GetTextureHandle() = 0;
    00055
    00057   virtual void DrawScaled (iGraphics3D* g3d, int sx, int sy, int sw, int sh,
    00058     uint8 Alpha = 0) = 0;
    00060   inline void DrawScaledAlign (iGraphics3D* g3d, int sx, int sy, int sw,
    00061       int sh, int alnx, int alny, uint8 Alpha = 0)
    00062     { DrawScaled (g3d, sx - alnx * sw / 2, sy - alny * sh / 2, sw, sh, Alpha); }
    00064   inline void Draw (iGraphics3D* g3d, int sx, int sy, uint8 Alpha = 0)
    00065     { DrawScaled (g3d, sx, sy, Width(), Height(), Alpha); }
    00067   inline void DrawAlign (iGraphics3D* g3d, int sx, int sy, int alnx, int alny,
    00068       uint8 Alpha = 0)
    00069     { DrawScaledAlign (g3d, sx, sy, Width(), Height(), alnx, alny, Alpha); }
    00070
    00077   virtual void DrawTiled (iGraphics3D* g3d, int sx, int sy, int sw, int sh,
    00078     int orgx, int orgy, uint8 Alpha = 0) = 0;
    00080   inline void DrawTiled (iGraphics3D* g3d, int sx, int sy, int w, int h,
    00081       uint8 Alpha = 0)
    00082   { DrawTiled (g3d, sx, sy, w, h, sx, sy, Alpha); }
    00083 };
    00084
    00086 class CS_CRYSTALSPACE_EXPORT csSimplePixmap : public csPixmap
    00087 {
    00088 protected:
    00089   csRef<iTextureHandle> hTex;
    00090   int tx, ty, tw, th;
    00091
    00092 public:
    00094   csSimplePixmap (iTextureHandle *hTexture);
    00096   csSimplePixmap (iTextureHandle *hTexture, int x, int y, int w, int h);
    00098   virtual ~csSimplePixmap ();
    00099
    00101   void SetTextureHandle (iTextureHandle *hTexture);
    00103   inline void SetTextureRectangle (int x, int y, int w, int h)
    00104   { tx = x; ty = y; tw = w; th = h; }
    00105
    00106   // implementation of csPixmap methods
    00107   virtual void DrawScaled (iGraphics3D* g3d, int sx, int sy, int sw, int sh,
    00108     uint8 Alpha = 0);
    00109   virtual void DrawTiled (iGraphics3D* g3d, int sx, int sy, int sw, int sh,
    00110     int orgx, int orgy, uint8 Alpha = 0);
    00111   virtual int Width ();
    00112   virtual int Height ();
    00113   virtual void Advance(csTicks /*ElapsedTime*/) {}
    00114   virtual iTextureHandle *GetTextureHandle ();
    00115 };
    00116
    00117 #endif // __CS_CSPIXMAP_H__