---
name: "SDL_Surface"
section: "3"
platform: "linux"
package: "libsdl1.2-dev"
version: "1.2.15+dfsg2-8"
release: "Debian 12 (Bookworm)"
platforms: ["linux"]
url: "https://new.carta.tech/SDL_Surface"
---

# SDL\_Surface(3)

Graphical Surface Structure

## NAME

SDL\_Surface - Graphical Surface Structure

## STRUCTURE DEFINITION

```
typedef struct SDL_Surface {
        Uint32 flags;                           /* Read-only */
        SDL_PixelFormat *format;                /* Read-only */
        int w, h;                               /* Read-only */
        Uint16 pitch;                           /* Read-only */
        void *pixels;                           /* Read-write */
        /* clipping information */
        SDL_Rect clip_rect;                     /* Read-only */
        /* Reference count -- used when freeing surface */
        int refcount;                           /* Read-mostly */
	/* This structure also contains private fields not shown here */
} SDL_Surface;
```

## STRUCTURE DATA

- **flags**

  Surface flags

- **format**

  Pixel *format*

- **w, h**

  Width and height of the surface

- **pitch**

  Length of a surface scanline in bytes

- **pixels**

  Pointer to the actual pixel data

- **clip\_rect**

  surface clip *rectangle*

## DESCRIPTION

**SDL\_Surface**'s represent areas of "graphical" memory, memory that can be drawn to. The video framebuffer is returned as a **SDL\_Surface** by **SDL\_SetVideoMode** and **SDL\_GetVideoSurface**. Most of the fields should be pretty obvious. **w** and **h** are the width and height of the surface in pixels. **pixels** is a pointer to the actual pixel data, the surface should be *locked* before accessing this field. The **clip\_rect** field is the clipping rectangle as set by **SDL\_SetClipRect**.

The following are supported in the **flags** field.

- **SDL\_SWSURFACE**

  Surface is stored in system memory

- **SDL\_HWSURFACE**

  Surface is stored in video memory

- **SDL\_ASYNCBLIT**

  Surface uses asynchronous blits if possible

- **SDL\_ANYFORMAT**

  Allows any pixel-format (Display surface)

- **SDL\_HWPALETTE**

  Surface has exclusive palette

- **SDL\_DOUBLEBUF**

  Surface is double buffered (Display surface)

- **SDL\_FULLSCREEN**

  Surface is full screen (Display Surface)

- **SDL\_OPENGL**

  Surface has an OpenGL context (Display Surface)

- **SDL\_OPENGLBLIT**

  Surface supports OpenGL blitting (Display Surface)

- **SDL\_RESIZABLE**

  Surface is resizable (Display Surface)

- **SDL\_HWACCEL**

  Surface blit uses hardware acceleration

- **SDL\_SRCCOLORKEY**

  Surface use colorkey blitting

- **SDL\_RLEACCEL**

  Colorkey blitting is accelerated with RLE

- **SDL\_SRCALPHA**

  Surface blit uses alpha blending

- **SDL\_PREALLOC**

  Surface uses preallocated memory

## SEE ALSO

**SDL\_PixelFormat**
