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
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
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 = 4;
00082
00203 enum
00204 {
00205 KrQualityNone,
00206 KrQualityFast,
00207 KrQualityLinear,
00208 KrQualityAdaptive,
00209 };
00210
00214 class KrEngine
00215 {
00216 public:
00222 KrEngine( SDL_Surface* screen );
00223
00232 KrEngine( SDL_Surface* screen, const KrRect& bounds, const KrRGBA* extraFill );
00233
00246 KrEngine( SDL_Surface* screen, int nWindows, const KrRect* bounds, const KrRGBA* extraFill );
00247
00248 ~KrEngine() { delete tree;
00249 delete vault; }
00250
00257 KrImageTree* Tree() { return tree; }
00258
00267 KrResourceVault* Vault() { return vault; }
00268
00270 int NumWindows() { GLASSERT( nWindows <= KR_MAX_WINDOWS );
00271 return nWindows; }
00272
00274 int GetWindowFromPoint( int x, int y );
00275
00290 void Draw( bool updateRect = true, GlDynArray< KrRect >* rectangles = 0 );
00291
00295 const KrRect& ScreenBounds( int window=0 ) { return screenBounds[window]; }
00296
00299 const KrRect& FullScreenBounds() { return windowBounds; }
00300
00304 void InvalidateRectangle( const KrRect& rect, int window=0 ) { dirtyRectangle[window].AddRectangle( rect ); }
00305
00306
00308 SDL_Surface* Surface() { return screen; }
00309
00311 void InvalidateScreen() { Tree()->Root()->Invalidate( KR_ALL_WINDOWS ); }
00312
00314 void QueryRenderDesc( std::string* desc );
00315
00316 static void QueryRenderDesc( SDL_Surface* surface, std::string* desc );
00317
00318
00326 void StartSplash( U32 msec );
00327
00331 bool UpdateSplash( U32 msec );
00332
00335 void EndSplash();
00336
00337
00338
00344 void FillBackground( const KrRGBA* fillColor );
00345
00347 void FillBackgroundWindow( int window, const KrRGBA* fillColor );
00348
00350 void static Version( int* major, int* minor, int* patch )
00351 {
00352 *major = KyraVersionMajor;
00353 *minor = KyraVersionMinor;
00354 *patch = KyraVersionBuild;
00355 }
00356
00368 static void SetMaxOglTextureSize( int size ) { maxOglTextureSize = size; }
00369
00371 static int MaxOglTextureSize() { return maxOglTextureSize; }
00372
00373
00374
00375 KrDirtyRectangle* DirtyRectangle( int window ) { return &dirtyRectangle[window]; }
00376
00377
00378 void UpdateScreen( GlDynArray< KrRect >* rects );
00379
00380
00381 void Validate() { GLASSERT( nWindows >= 0 );
00382 GLASSERT( nWindows <= KR_MAX_WINDOWS );
00383 GLASSERT( windowBounds.IsValid() );
00384
00385 }
00386
00387 private:
00388 void Init( SDL_Surface* _screen,
00389 int _nWindows,
00390 const KrRect* bounds,
00391 const KrRGBA* extra );
00392
00393 void InitOpenGL();
00394
00395 static int maxOglTextureSize;
00396
00397 SDL_Surface* screen;
00398 int nWindows;
00399
00400 KrDirtyRectangle dirtyRectangle[ KR_MAX_WINDOWS ];
00401 KrRect screenBounds[ KR_MAX_WINDOWS ];
00402 KrRect windowBounds;
00403
00404 KrImageTree* tree;
00405 KrResourceVault* vault;
00406
00407 KrPaintInfo paintInfo;
00408 bool fillBackground[ KR_MAX_WINDOWS ];
00409 KrRGBA backgroundColor[ KR_MAX_WINDOWS ];
00410 KrRGBA extraBackground;
00411 bool needFullScreenUpdate;
00412
00413 U32 splashStart;
00414 KrResourceVault *splashVault;
00415 KrSprite *splash, *splashText;
00416 };
00417
00418 #endif