00001 /*--License: 00002 Kyra Sprite Engine 00003 Copyright Lee Thomason (Grinning Lizard Software) 2001-2002 00004 www.grinninglizard.com/kyra 00005 www.sourceforge.net/projects/kyra 00006 00007 Kyra is provided under 2 licenses: 00008 00009 - The GPL, with no additional restrictions. 00010 - The LGPL, provided you display the Kyra splash screen, described below. 00011 00012 00013 --- GPL License -- 00014 This program is free software; you can redistribute it and/or 00015 modify it under the terms of the GNU General Public License 00016 as published by the Free Software Foundation; either version 2 00017 of the License, or (at your option) any later version. 00018 00019 This program is distributed in the hope that it will be useful, 00020 but WITHOUT ANY WARRANTY; without even the implied warranty of 00021 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00022 GNU General Public License for more details. 00023 00024 You should have received a copy of the GNU General Public License 00025 along with this program; if not, write to the Free Software 00026 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 00027 00028 The full text of the license can be found in license.txt 00029 00030 00031 --- LGPL License -- 00032 **Provided you kindly display the Kyra splash screen (details below), 00033 you may use the LGPL license:** 00034 00035 This library is free software; you can redistribute it and/or 00036 modify it under the terms of the GNU Lesser General Public 00037 License as published by the Free Software Foundation; either 00038 version 2.1 of the License, or (at your option) any later version. 00039 00040 This library is distributed in the hope that it will be useful, 00041 but WITHOUT ANY WARRANTY; without even the implied warranty of 00042 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00043 Lesser General Public License for more details. 00044 00045 You should have received a copy of the GNU Lesser General Public 00046 License along with this library; if not, write to the Free Software 00047 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 00048 00049 The full text of the license can be found in lgpl.txt 00050 00051 00052 --- Kyra Splash Screen. 00053 00054 It would be appreciate if you display the Kyra splash screen when using 00055 either license, however it is only required for the LGPL. All the 00056 resources for the splash are compiled into the library, and it can be 00057 accessed through the following API: 00058 00059 KrEngine::StartSplash 00060 KrEngine::UpdateSplash 00061 KrEngine::EndSplash 00062 00063 Full documentation is provided with the KrEngine class. The splash screen 00064 should be displayed for 2 seconds. 00065 00066 Thank you. 00067 */ 00068 00069 00070 #ifndef KYRA_CANVASRESOURCE_INCLUDED 00071 #define KYRA_CANVASRESOURCE_INCLUDED 00072 00073 #include "kyraresource.h" 00074 #include "../engine/krmath.h" 00075 #include "../util/glcirclelist.h" 00076 #include "pixelblock.h" 00077 00078 class KrCanvas; 00079 00083 class KrCanvasResource : public KrResource 00084 { 00085 public: 00104 KrCanvasResource( const std::string& name, 00105 int width, 00106 int height, 00107 int alphaSupport ); 00108 00109 virtual ~KrCanvasResource(); 00110 00111 virtual U32 Type() { return KYRATAG_CANVAS; } 00112 virtual const std::string& TypeName() { return canvasName; } 00113 virtual KrCanvasResource* ToCanvasResource(){ return this; } 00114 00115 int Width() { return pixelBlock.Width(); } 00116 int Height() { return pixelBlock.Height(); } 00117 KrRGBA* Pixels() { return pixelBlock.Pixels(); } 00118 int Alpha() { return pixelBlock.Alpha(); } 00119 00120 /* Draw a canvas resource. 00121 @param paintInfo Information about the target surface for drawing (optimizing). 00122 @param x X location in pixels. 00123 @param y Y location in pixels. 00124 @param cForm Color transformation applied to the drawing. 00125 @param clip A clipping rectangle, which can be null. 00126 */ 00127 void Draw( KrPaintInfo* paintInfo, 00128 const KrMatrix2& matrix, 00129 const KrColorTransform& cForm, 00130 const KrRect& clipping, 00131 int quality, 00132 int openGLZ ); 00133 00138 void Refresh(); 00139 00140 /* Do a HitTest (see KrImageTree::HitTest) in transformed 00141 coordinates. So the tree object that made this call 00142 has already transformed the x and y into local pixel coords. 00143 */ 00144 bool HitTestTransformed( int x, int y, int hitFlags ); 00145 00146 void CalculateBounds( const KrMatrix2& xForm, KrRect* bounds ) const; 00147 00148 // Canvases don't cache. 00149 virtual void CacheScale( GlFixed xScale, GlFixed yScale ) {} 00150 virtual bool IsScaleCached( GlFixed xScale, GlFixed yScale ) { return false; } 00151 virtual void FreeScaleCache() {} 00152 00153 // But they do collision map. 00154 virtual KrCollisionMap* GetCollisionMap( KrImage* state, int window ); 00155 00156 // For use by the Canvas objects: 00157 void AddCanvas( KrCanvas* canvas ); 00158 void RemoveCanvas( KrCanvas* canvas ); 00159 00160 private: 00161 static const std::string canvasName; 00162 static int canvasId; 00163 00164 KrPixelBlock pixelBlock; 00165 int numClients; 00166 GlCircleList<KrCanvas*> clients; 00167 GlDynArray<KrCollisionMap*> collisionMaps; 00168 }; 00169 00170 00171 #endif