Main Page   Class Hierarchy   Compound List   File List   Compound Members  

engine.h

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_ENGINE_INCLUDED
00071 #define KYRA_ENGINE_INCLUDED
00072 
00073 #include "SDL.h"
00074 #include "vault.h"
00075 #include "imagetree.h"
00076 #include "dirtyrectangle.h"
00077 #include "kyrabuild.h"
00078 
00079 const int KyraVersionMajor = 2;
00080 const int KyraVersionMinor = 0;
00081 const int KyraVersionBuild = 7;
00082 
00205 enum
00206 {
00207         KrQualityNone,          // Use the parent quality, if available.
00208         KrQualityFast,          // Nearest neighbor algorithm.
00209         KrQualityLinear,        // Bi-linear interpolation
00210         KrQualityAdaptive,      // Bi-linear or oversample
00211 };
00212 
00216 class KrEngine
00217 {
00218   public:
00224         KrEngine( SDL_Surface* screen );
00225         
00234         KrEngine( SDL_Surface* screen, const KrRect& bounds, const KrRGBA* extraFill );
00235 
00248         KrEngine( SDL_Surface* screen, int nWindows, const KrRect* bounds, const KrRGBA* extraFill );
00249         
00250         ~KrEngine()                                                     {       delete tree;            // Note that the tree must be deleted before the vault.
00251                                                                                         delete vault; }
00252 
00259         KrImageTree*            Tree()                  { return tree; }
00260 
00269         KrResourceVault*        Vault()                 { return vault; }
00270 
00272         int NumWindows()                                        {       GLASSERT( nWindows <= KR_MAX_WINDOWS );
00273                                                                                         return nWindows; }
00274 
00276         int GetWindowFromPoint( int x, int y );
00277         
00292         void Draw( bool updateRect = true, GlDynArray< KrRect >* rectangles = 0 );
00293         
00297         const KrRect& ScreenBounds( int window=0 )      { return screenBounds[window]; }
00298 
00301         const KrRect& FullScreenBounds()        { return windowBounds; }
00302 
00306         void InvalidateRectangle( const KrRect& rect, int window=0 )    { dirtyRectangle[window].AddRectangle( rect ); }
00307 
00308 
00310         SDL_Surface*    Surface()       { return screen; }
00311 
00313         void InvalidateScreen() { Tree()->Root()->Invalidate( KR_ALL_WINDOWS ); }
00314 
00316         void QueryRenderDesc( std::string* desc );
00317 
00318         static void QueryRenderDesc( SDL_Surface* surface, std::string* desc );
00319 
00320         // ------------- The splash screen. ---------- //
00328         void StartSplash( U32 msec );
00329 
00333         bool UpdateSplash( U32 msec );
00334 
00337         void EndSplash();
00338 
00339 
00340         // ------------- Engine Options ----------- //
00346         void FillBackground( const KrRGBA* fillColor );
00347 
00349         void FillBackgroundWindow( int window, const KrRGBA* fillColor );
00350 
00352         void static Version( int* major, int* minor, int* patch )       
00353         { 
00354                 *major = KyraVersionMajor;
00355                 *minor = KyraVersionMinor;
00356                 *patch = KyraVersionBuild;
00357         }
00358 
00370         static void SetMaxOglTextureSize( int size )    { maxOglTextureSize = size; }
00371 
00373         static int MaxOglTextureSize()                                  { return maxOglTextureSize; }
00374 
00375         //----------------------------------
00376         // For use by the engine components:
00377         KrDirtyRectangle*       DirtyRectangle( int window )    { return &dirtyRectangle[window]; }
00378 
00379         // Call SDL_Rect for each rectangle.
00380         void UpdateScreen( GlDynArray< KrRect >* rects );
00381 
00382         // Debugging: try to see if this is corrupted
00383         void Validate() {   GLASSERT( nWindows >= 0 );
00384                                                 GLASSERT( nWindows <= KR_MAX_WINDOWS );
00385                                                 GLASSERT( windowBounds.IsValid() );
00386                                                 //GLOUTPUT( "Engine Validated (nWindows=%d)\n", nWindows );
00387                                 }
00388 
00389   private:
00390         void Init(      SDL_Surface* _screen,           // The SDL surface
00391                                 int _nWindows,                          // number of windows
00392                                 const KrRect* bounds,           // rect for each window
00393                                 const KrRGBA* extra );          // The color for non-window areas, if specified.
00394 
00395         void InitOpenGL();
00396 
00397         static int maxOglTextureSize;
00398 
00399         SDL_Surface* screen;
00400         int nWindows;
00401 
00402         KrDirtyRectangle        dirtyRectangle[ KR_MAX_WINDOWS ];
00403         KrRect                          screenBounds[ KR_MAX_WINDOWS ];
00404         KrRect                          windowBounds;
00405 
00406         KrImageTree*            tree;
00407         KrResourceVault*        vault;
00408 
00409         KrPaintInfo                     paintInfo;
00410         bool                            fillBackground[ KR_MAX_WINDOWS ];
00411         KrRGBA                          backgroundColor[ KR_MAX_WINDOWS ];      // The background color of each window
00412         KrRGBA                          extraBackground;                                        // The background color outside of the windows
00413         bool                            needFullScreenUpdate;
00414 
00415         U32                                     splashStart;
00416         KrResourceVault         *splashVault;
00417         KrSprite                        *splash, *splashText;
00418 };
00419 
00420 #endif

Generated on Mon Sep 15 12:01:10 2003 for Kyra by doxygen1.2.11.1 written by Dimitri van Heesch, © 1997-2001