sdlCreateRgbSurface function

Pointer<SdlSurface> sdlCreateRgbSurface(
  1. int flags,
  2. int width,
  3. int height,
  4. int depth,
  5. int rmask,
  6. int gmask,
  7. int bmask,
  8. int amask,
)

Allocate a new RGB surface.

If depth is 4 or 8 bits, an empty palette is allocated for the surface. If depth is greater than 8 bits, the pixel format is set using the RGBAmask parameters.

The RGBAmask parameters are the bitmasks used to extract that color from a pixel. For instance, Rmask being 0xFF000000 means the red data is stored in the most significant byte. Using zeros for the RGB masks sets a default value, based on the depth. For example:

SDL_CreateRGBSurface(0,w,h,32,0,0,0,0);

However, using zero for the Amask results in an Amask of 0.

By default surfaces with an alpha mask are set up for blending as with:

SDL_SetSurfaceBlendMode(surface, SDL_BLENDMODE_BLEND)

You can change this by calling SDL_SetSurfaceBlendMode() and selecting a different blendMode.

\param flags the flags are unused and should be set to 0 \param width the width of the surface \param height the height of the surface \param depth the depth of the surface in bits \param Rmask the red mask for the pixels \param Gmask the green mask for the pixels \param Bmask the blue mask for the pixels \param Amask the alpha mask for the pixels \returns the new SDL_Surface structure that is created or NULL if it fails; call SDL_GetError() for more information.

\since This function is available since SDL 2.0.0.

\sa SDL_CreateRGBSurfaceFrom \sa SDL_CreateRGBSurfaceWithFormat \sa SDL_FreeSurface

extern DECLSPEC SDL_Surface *SDLCALL SDL_CreateRGBSurface (Uint32 flags, int width, int height, int depth, Uint32 Rmask, Uint32 Gmask, Uint32 Bmask, Uint32 Amask)

Implementation

Pointer<SdlSurface> sdlCreateRgbSurface(int flags, int width, int height,
    int depth, int rmask, int gmask, int bmask, int amask) {
  final sdlCreateRgbSurfaceLookupFunction = libSdl2.lookupFunction<
      Pointer<SdlSurface> Function(Uint32 flags, Int32 width, Int32 height,
          Int32 depth, Uint32 rmask, Uint32 gmask, Uint32 bmask, Uint32 amask),
      Pointer<SdlSurface> Function(int flags, int width, int height, int depth,
          int rmask, int gmask, int bmask, int amask)>('SDL_CreateRGBSurface');
  return sdlCreateRgbSurfaceLookupFunction(
      flags, width, height, depth, rmask, gmask, bmask, amask);
}