Skip to content

Commit

Permalink
SDL2/SDL_Surface: Updated.
Browse files Browse the repository at this point in the history
  • Loading branch information
mb4development authored and slouken committed Sep 18, 2024
1 parent 9585e1e commit 1efd490
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions SDL2/SDL_Surface.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,26 @@ typedef struct SDL_Surface
} SDL_Surface;
```

## Code examples

```c
/* This is meant to show how to edit a surface's pixels on the CPU, but
normally you should use SDL_FillRect() to wipe a surface's contents. */
void WipeSurface(SDL_Surface *surface)
{
/* This is fast for surfaces that don't require locking. */
/* Once locked, surface->pixels is safe to access. */
SDL_LockSurface(surface);

/* This assumes that color value zero is black. Use
SDL_MapRGBA() for more robust surface color mapping! */
/* height times pitch is the size of the surface's whole buffer. */
SDL_memset(surface->pixels, 0, surface->h * surface->pitch);

SDL_UnlockSurface(surface);
}
```
## Remarks
This structure should be treated as read-only, except for `pixels`, which,
Expand Down

0 comments on commit 1efd490

Please sign in to comment.