- Main Page
- Classes
- Files
- Directories
- Related Pages

- Class List
- Class Hierarchy
- Class Members

# KrEngine Class Reference

The core of the Kyra system. More...

`#include <engine.h>`

List of all members.

## Public Member Functions
| KrEngine (SDL_Surface *screen)
| Creates an engine that renders to the entire screen.
| KrEngine (SDL_Surface *screen, const grinliz::Rectangle2I &bounds, const KrRGBA *extraFill)
| Sets up an engine that renders to a rectangle on the screen, instead of the entire screen.
| KrEngine (SDL_Surface *screen, int nWindows, const grinliz::Rectangle2I *bounds, const KrRGBA *extraFill)
| Sets up an engine that renders to multiple "windows" on the same surface.
KrImageTree * | Tree ()
| Fetch the ImageTree.
KrResourceVault * | Vault ()
| Fetch a vault.
int | NumWindows ()
| How many windows does this engine have?
int | GetWindowFromPoint (int x, int y)
| Given a point (in screen coordinates), what window is it in? -1 if none.
void | Draw (bool updateRect=true, std::vector< grinliz::Rectangle2I > *rectangles=0)
| Once everything is ready to go, sprites and such are updated, call this method to put it all on the screen.
const grinliz::Rectangle2I & | ScreenBounds (int window=0)
| Return the bounds we are drawing to.
const grinliz::Rectangle2I & | FullScreenBounds ()
| Retrun the bounds of the entire screen surface.
void | InvalidateRectangle (const grinliz::Rectangle2I &rect, int window=0)
| Pass in a rectangle that should be invalidated.
SDL_Surface * | Surface ()
| Query the surface pointer used by this engine.
void | InvalidateScreen ()
| Invalidate everything and mark for repaint. Follow with call to Draw().
void | QueryRenderDesc (std::string *desc)
| Get a text description of the current rendering mode.
void | FillBackground (const KrRGBA *fillColor)
| Will fill the background with the specified color before drawing Images.
void | FillBackgroundWindow (int window, const KrRGBA *fillColor)
| Set the fill of a particular backrgound window.
## Static Public Member Functions
static void | Version (int *major, int *minor, int *patch)
| Get the major, minor, and patch version of the engine.
static void | SetMaxOglTextureSize (int size)
| Set the maximize size of an OpenGL texture.
static int | MaxOglTextureSize ()
| Query the current max texture size. (0 is no Kyra imposed limit.).

## Detailed Description

The core of the Kyra system.

Instantiate an Engine to start using the sprite engine.

## Constructor & Destructor Documentation

KrEngine::KrEngine | ( | SDL_Surface * | screen | ) |

Creates an engine that renders to the entire screen.

Parameters:

  | screen | The SDL surface to use. If the surface is an OpenGL surface, Kyra will use the OpenGL library to draw with.

KrEngine::KrEngine | ( | SDL_Surface * | screen,
|  | const grinliz::Rectangle2I & | bounds,
|  | const KrRGBA * | extraFill |
| ) |  |  |

Sets up an engine that renders to a rectangle on the screen, instead of the entire screen.

Parameters:

  | screen | The SDL surface to use.
  | bounds | The area the engine will draw to.
  | extraFill | If this is not null, the screen not covered by the bounds will be filled with this color. This gives a background color to "extra" screen.

KrEngine::KrEngine | ( | SDL_Surface * | screen,
|  | int | nWindows,
|  | const grinliz::Rectangle2I * | bounds,
|  | const KrRGBA * | extraFill |
| ) |  |  |

Sets up an engine that renders to multiple "windows" on the same surface.

No window may overlap another. Each window is oriented with 0,0 as its upper left hand coordinate.

Parameters:

  | screen | The SDL surface to use.
  | nWindows | The number of Kyra "windows" (viewports) to render to.
  | bounds | An array of rectangles that define the windows.
  | extraFill | If this is not null, the screen not covered by the bounds will be filled with this color. This gives a background color to "extra" screen.

## Member Function Documentation

void KrEngine::Draw | ( | bool | updateRect = `true`,
|  | std::vector< grinliz::Rectangle2I > * | rectangles = `0` |
| ) |  |  |

Once everything is ready to go, sprites and such are updated, call this method to put it all on the screen.

Parameters:

  | updateRect | If true, SDL_UpdateRects will automatically be called in the Draw() method. Normally, this is the desired behavior. Only set to false if you will call SDL_UpdateRects, SDL_Flip, or something equivalent after you post process the buffer.
  | rectangles | If wish the update rectangles to be returned to the calling application, pass in a DynArray.

void KrEngine::FillBackground | ( | const KrRGBA * | fillColor | ) |

Will fill the background with the specified color before drawing Images.

If the Images let no background screen show through, NULL should be passed in to turn this feature off for a performance improvement.

void KrEngine::InvalidateRectangle | ( | const grinliz::Rectangle2I & | rect,
|  | int | window = `0` |
| ) |  |  | `[inline]`

Pass in a rectangle that should be invalidated.

Only used for unusual circumstances - primarily to clear a user-draw.

const grinliz::Rectangle2I& KrEngine::ScreenBounds | ( | int | window = `0` | ) | `[inline]`

Return the bounds we are drawing to.

(Not necessarily the entire screen.) Set by the constructor.

static void KrEngine::SetMaxOglTextureSize | ( | int | size | ) | `[inline, static]`

Set the maximize size of an OpenGL texture.

This is the max size of either the x or y axis, so this limits memory usage to effectively:

max texture memory used = size * size * 4

Useful to contain memory usage of large sprites. Quality, of course, will suffer if the size is constrained. Set to 0 (the default) to limit the largest size to that allowed by the driver.

Note: This is static. The effect is global.

KrImageTree* KrEngine::Tree | ( |  | ) | `[inline]`

Fetch the ImageTree.

Even though it lives in the Engine, the Tree will be managed by the user.

The KrImageTree returned is owned by the engine. It should not be deleted by the client code.

KrResourceVault* KrEngine::Vault | ( |  | ) | `[inline]`

Fetch a vault.

Every engine needs a vault and there is nothing special about this one, except that it is managed with the engine and will be created and deleted at the correct time.

The KrResourceVault is owned by the engine. It should not be deleted by the client code.

The documentation for this class was generated from the following file:

- engine.h