cstool/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 "csutil/ref.h" 00024 #include "ivideo/graph3d.h" 00025 #include "ivideo/texture.h" 00026 #include "iengine/texture.h" 00027 00029 #define PIXMAP_TOP 0 00030 #define PIXMAP_LEFT 0 00031 #define PIXMAP_CENTER 1 00032 #define PIXMAP_BOTTOM 2 00033 #define PIXMAP_RIGHT 2 00034 00042 class csPixmap 00043 { 00044 public: 00046 virtual ~csPixmap() {} 00047 00049 virtual int Width() = 0; 00051 virtual int Height() = 0; 00053 virtual void Advance(csTicks ElapsedTime) = 0; 00055 virtual iTextureHandle *GetTextureHandle() = 0; 00056 00058 virtual void DrawScaled (iGraphics3D* g3d, int sx, int sy, int sw, int sh, 00059 uint8 Alpha = 0) = 0; 00061 inline void DrawScaledAlign (iGraphics3D* g3d, int sx, int sy, int sw, 00062 int sh, int alnx, int alny, uint8 Alpha = 0) 00063 { DrawScaled (g3d, sx - alnx * sw / 2, sy - alny * sh / 2, sw, sh, Alpha); } 00065 inline void Draw (iGraphics3D* g3d, int sx, int sy, uint8 Alpha = 0) 00066 { DrawScaled (g3d, sx, sy, Width(), Height(), Alpha); } 00068 inline void DrawAlign (iGraphics3D* g3d, int sx, int sy, int alnx, int alny, 00069 uint8 Alpha = 0) 00070 { DrawScaledAlign (g3d, sx, sy, Width(), Height(), alnx, alny, Alpha); } 00071 00078 virtual void DrawTiled (iGraphics3D* g3d, int sx, int sy, int sw, int sh, 00079 int orgx, int orgy, uint8 Alpha = 0) = 0; 00081 inline void DrawTiled (iGraphics3D* g3d, int sx, int sy, int w, int h, 00082 uint8 Alpha = 0) 00083 { DrawTiled (g3d, sx, sy, w, h, sx, sy, Alpha); } 00084 }; 00085 00087 class csSimplePixmap : public csPixmap 00088 { 00089 protected: 00090 csRef<iTextureHandle> hTex; 00091 int tx, ty, tw, th; 00092 00093 public: 00095 csSimplePixmap (iTextureHandle *hTexture); 00097 csSimplePixmap (iTextureHandle *hTexture, int x, int y, int w, int h); 00099 virtual ~csSimplePixmap (); 00100 00102 void SetTextureHandle (iTextureHandle *hTexture); 00104 inline void SetTextureRectangle (int x, int y, int w, int h) 00105 { tx = x; ty = y; tw = w; th = h; } 00106 00107 // implementation of csPixmap methods 00108 virtual void DrawScaled (iGraphics3D* g3d, int sx, int sy, int sw, int sh, 00109 uint8 Alpha = 0); 00110 virtual void DrawTiled (iGraphics3D* g3d, int sx, int sy, int sw, int sh, 00111 int orgx, int orgy, uint8 Alpha = 0); 00112 virtual int Width (); 00113 virtual int Height (); 00114 virtual void Advance(csTicks /*ElapsedTime*/) {} 00115 virtual iTextureHandle *GetTextureHandle (); 00116 }; 00117 00118 #endif // __CS_CSPIXMAP_H__
Generated for Crystal Space by doxygen 1.2.18