00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033 #ifndef KYRA_ENGINE_INCLUDED
00034 #define KYRA_ENGINE_INCLUDED
00035
00036 #include "SDL.h"
00037 #include "vault.h"
00038 #include "imagetree.h"
00039 #include "dirtyrectangle.h"
00040 #include "kyrabuild.h"
00041
00042 const int KyraVersionMajor = 2;
00043 const int KyraVersionMinor = 1;
00044 const int KyraVersionBuild = 3;
00045
00146 enum
00147 {
00148 KrQualityNone,
00149 KrQualityFast,
00150 KrQualityLinear,
00151 KrQualityAdaptive,
00152 };
00153
00157 class KrEngine
00158 {
00159 public:
00165 KrEngine( SDL_Surface* screen );
00166
00175 KrEngine( SDL_Surface* screen, const grinliz::Rectangle2I& bounds, const KrRGBA* extraFill );
00176
00189 KrEngine( SDL_Surface* screen, int nWindows, const grinliz::Rectangle2I* bounds, const KrRGBA* extraFill );
00190
00191 ~KrEngine();
00192
00199 KrImageTree* Tree() { return tree; }
00200
00209 KrResourceVault* Vault() { return vault; }
00210
00212 int NumWindows() { GLASSERT( nWindows <= KR_MAX_WINDOWS );
00213 return nWindows; }
00214
00216 int GetWindowFromPoint( int x, int y );
00217
00232 void Draw( bool updateRect = true, std::vector< grinliz::Rectangle2I >* rectangles = 0 );
00233
00237 const grinliz::Rectangle2I& ScreenBounds( int window=0 ) { return screenBounds[window]; }
00238
00241 const grinliz::Rectangle2I& FullScreenBounds() { return windowBounds; }
00242
00246 void InvalidateRectangle( const grinliz::Rectangle2I& rect, int window=0 )
00247 { dirtyRectangle[window].AddRectangle( rect ); }
00248
00249
00251 SDL_Surface* Surface() { return screen; }
00252
00254 void InvalidateScreen() { Tree()->Root()->Invalidate( KR_ALL_WINDOWS ); }
00255
00257 void QueryRenderDesc( std::string* desc );
00258
00259 static void QueryRenderDesc( SDL_Surface* surface, std::string* desc );
00260
00261
00267 void FillBackground( const KrRGBA* fillColor );
00268
00270 void FillBackgroundWindow( int window, const KrRGBA* fillColor );
00271
00273 void static Version( int* major, int* minor, int* patch )
00274 {
00275 *major = KyraVersionMajor;
00276 *minor = KyraVersionMinor;
00277 *patch = KyraVersionBuild;
00278 }
00279
00291 static void SetMaxOglTextureSize( int size ) { maxOglTextureSize = size; }
00292
00294 static int MaxOglTextureSize() { return maxOglTextureSize; }
00295
00296
00297
00298 KrDirtyRectangle* DirtyRectangle( int window ) { return &dirtyRectangle[window]; }
00299
00300
00301 void UpdateScreen( std::vector< grinliz::Rectangle2I >* rects );
00302
00303
00304 void Validate() { GLASSERT( nWindows >= 0 );
00305 GLASSERT( nWindows <= KR_MAX_WINDOWS );
00306 GLASSERT( windowBounds.IsValid() );
00307
00308 }
00309
00310
00311 void Restart( SDL_Surface* _screen,
00312 int _nWindows,
00313 const grinliz::Rectangle2I* bounds,
00314 const KrRGBA* extra );
00315
00316
00317 private:
00318 void Init( SDL_Surface* _screen,
00319 int _nWindows,
00320 const grinliz::Rectangle2I* bounds,
00321 const KrRGBA* extra);
00322
00323 void InitOpenGL();
00324
00325 static int maxOglTextureSize;
00326
00327 SDL_Surface* screen;
00328 int nWindows;
00329
00330 std::vector< SDL_Rect > sdlRects;
00331 KrDirtyRectangle dirtyRectangle[ KR_MAX_WINDOWS ];
00332 grinliz::Rectangle2I screenBounds[ KR_MAX_WINDOWS ];
00333 grinliz::Rectangle2I windowBounds;
00334
00335 KrImageTree* tree;
00336 KrResourceVault* vault;
00337
00338 KrPaintInfo paintInfo;
00339 bool fillBackground[ KR_MAX_WINDOWS ];
00340 KrRGBA backgroundColor[ KR_MAX_WINDOWS ];
00341 KrRGBA extraBackground;
00342 bool needFullScreenUpdate;
00343
00344 U32 splashStart;
00345 KrResourceVault *splashVault;
00346 KrSprite *splash, *splashText;
00347 };
00348
00349 #endif