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 = 7;
00082
00205 enum
00206 {
00207 KrQualityNone,
00208 KrQualityFast,
00209 KrQualityLinear,
00210 KrQualityAdaptive,
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;
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
00328 void StartSplash( U32 msec );
00329
00333 bool UpdateSplash( U32 msec );
00334
00337 void EndSplash();
00338
00339
00340
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
00377 KrDirtyRectangle* DirtyRectangle( int window ) { return &dirtyRectangle[window]; }
00378
00379
00380 void UpdateScreen( GlDynArray< KrRect >* rects );
00381
00382
00383 void Validate() { GLASSERT( nWindows >= 0 );
00384 GLASSERT( nWindows <= KR_MAX_WINDOWS );
00385 GLASSERT( windowBounds.IsValid() );
00386
00387 }
00388
00389 private:
00390 void Init( SDL_Surface* _screen,
00391 int _nWindows,
00392 const KrRect* bounds,
00393 const KrRGBA* extra );
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 ];
00412 KrRGBA extraBackground;
00413 bool needFullScreenUpdate;
00414
00415 U32 splashStart;
00416 KrResourceVault *splashVault;
00417 KrSprite *splash, *splashText;
00418 };
00419
00420 #endif