| Dirty Rect Functions | |||||||||||||||||||||||||||||||||||||||||||
|
Primitives Polygon Transform Surface Drawing Dirty Rect Palette Control Misc Defines Types Extended Arguments Index Credits |
void SPG_EnableDirty(SPG_bool enable) - Enables or disables automatic generation of dirty rects by the graphics primitives. Each primitive as well as SPG_Blit() and the transform functions create their own dirty rects and add them to the front table (see SPG_DirtyInit()). You should disable dirty rects when drawing to surfaces other than your display surface. void SPG_DirtyInit(Uint16 maxsize) - Initializes the dirty rect system. There are two tables that are set to the specified size. The front table is the one that receives all the added rects from primitives. The back table is used to preserve these rects for the next frame, so that they can be updated too. Each dirty rect must be updated once to show the new drawing there, then again in the next frame so that the old drawing can be erased from the display. void SPG_DirtyAdd(SDL_Rect* rect) - Adds a given rect to the front table. These rects must be clipped (see SPG_DirtyClip()) or else SDL_UpdateRects(), called by SPG_DirtyUpdate(), will crash. SPG_DirtyTable* SPG_DirtyUpdate(SDL_Surface* screen) - This call updates the dirty rects on the given display surface. It returns the table of rects so that you can loop through them and redraw the background and whatever else you need. Example: SPG_DirtyTable* table = SPG_DirtyUpdate(screen); int i; for(i = 0; i < table->count; i++) { // Blit background to table->rects[i] SDL_BlitSurface(mybackground, &bgrect, screen, &(table->rects[i]); } void SPG_DirtySwap() - Swaps the front and back tables. This should be done after SPG_DirtyUpdate() and after you reblit the background. In the next frame, the front table will have the old rects as well as any new ones. SPG_bool SPG_DirtyEnabled() - Returns 1 if automatic dirty rect creation is enabled. SPG_DirtyTable* SPG_DirtyMake(Uint16 maxsize) - Allocates a new dirty rect table (using malloc) and returns a pointer to it. void SPG_DirtyAddTo(SPG_DirtyTable* table, SDL_Rect* rect) - Adds a given rect to a table. void SPG_DirtyFree(SPG_DirtyTable* table) - Correctly frees a table created with SPG_DirtyMake(). SPG_DirtyTable* SPG_DirtyGet() - Returns the current front table. Be aware that SPG_DirtySwap() changes this, so you cannot rely on always having a pointer to the front table unless you call this function each time you need to access the front table. void SPG_DirtyClear(SPG_DirtyTable* table) - Resets a table to a clean, empty state. void SPG_DirtyLevel(Uint16 optimizationLevel) - Sets the level of optimization used when dirty rects are merged by SPG_DirtyAdd(). void SPG_DirtyClip(SDL_Surface* screen, SDL_Rect* rect) - Changes the given rect so that it is clipped to within the screen. |
||||||||||||||||||||||||||||||||||||||||||