>SDL_CreateRGBSurface<
/TITLE
NAME="GENERATOR"
CONTENT="Modular DocBook HTML Stylesheet Version 1.64
REL="HOME"
TITLE="SDL Library Documentation"
REL="UP"
TITLE="Video"
REL="PREVIOUS"
TITLE="SDL_GetRGBA"
HREF="sdlgetrgba.html"><
LINK
REL="NEXT"
TITLE="SDL_CreateRGBSurfaceFrom"
HREF="sdlcreatergbsurfacefrom.html"><
/HEAD
CLASS="REFENTRY"
BGCOLOR="#FFF8DC"
TEXT="#000000"
LINK="#0000ee"
VLINK="#551a8b"
ALINK="#ff0000"
CLASS="NAVHEADER"
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
COLSPAN="3"
ALIGN="center"
>SDL Library Documentation<
/TH
WIDTH="10%"
ALIGN="left"
VALIGN="bottom"
HREF="sdlgetrgba.html"
WIDTH="80%"
ALIGN="center"
VALIGN="bottom"
WIDTH="10%"
ALIGN="right"
VALIGN="bottom"
HREF="sdlcreatergbsurfacefrom.html"
ALIGN="LEFT"
NAME="SDLCREATERGBSURFACE"
CLASS="REFNAMEDIV"
NAME="AEN1358"
>SDL_CreateRGBSurface -- Create an empty SDL_Surface<
/DIV
CLASS="REFSYNOPSISDIV"
NAME="AEN1361"
CLASS="FUNCSYNOPSIS"
NAME="AEN1362"
CLASS="FUNCSYNOPSISINFO"
CLASS="FUNCDEF"
CLASS="FSFUNC"
>
(Uint32 flags, int
width, int
height, int depth, Uint32 Rmask, Uint32 Gmask, Uint32 Bmask, Uint32 Amask
);<
/CODE
CLASS="REFSECT1"
NAME="AEN1368"
>Allocate an empty surface
(must be called after <
A
HREF="sdlsetvideomode.html"
CLASS="PARAMETER"
> is
8 bits an empty palette is allocated
for the surface, otherwise a
'packed-pixel' <
A
HREF="sdlpixelformat.html"
CLASS="STRUCTNAME"
> is created using the <
TT
CLASS="PARAMETER"
>'s provided (see <A
HREF="sdlpixelformat.html"
><SPAN
CLASS="STRUCTNAME"
>SDL_PixelFormat</SPAN
></A
>). The <TT
CLASS="PARAMETER"
><I
>flags</I
></TT
> specifies the type of surface that should be created, it is an OR'd combination of the following possible values.<
/P
CLASS="INFORMALTABLE"
NAME="AEN1380"
BORDER="1"
CLASS="CALSTABLE"
ALIGN="LEFT"
VALIGN="TOP"
CLASS="LITERAL"
ALIGN="LEFT"
VALIGN="TOP"
>SDL will create the surface in system memory. This improves the performance of pixel level access, however you may not be able to take advantage of some types of hardware blitting.<
/TD
ALIGN="LEFT"
VALIGN="TOP"
CLASS="LITERAL"
ALIGN="LEFT"
VALIGN="TOP"
>SDL will attempt to create the surface in video memory. This will allow SDL to take advantage of Video-&#
62;Video blits
(which are often accelerated
).<
/TD
ALIGN="LEFT"
VALIGN="TOP"
CLASS="LITERAL"
ALIGN="LEFT"
VALIGN="TOP"
>This flag turns on colourkeying for blits from this surface. If
CLASS="LITERAL"
> is also specified and colourkeyed blits
are hardware-accelerated, then SDL will attempt to place the surface in
video memory.
HREF="sdlsetcolorkey.html"
CLASS="FUNCTION"
>
to set or
clear this flag after surface creation.<
/TD
ALIGN="LEFT"
VALIGN="TOP"
CLASS="LITERAL"
ALIGN="LEFT"
VALIGN="TOP"
>This flag turns on alpha-blending for blits from this surface. If
CLASS="LITERAL"
> is also specified and alpha-blending blits
are hardware-accelerated, then the surface will be placed in video memory if
possible.
HREF="sdlsetalpha.html"
CLASS="FUNCTION"
> to
set or
clear this flag after surface creation.<
/TD
CLASS="NOTE"
CLASS="NOTE"
>If an alpha-channel is specified
(that is, if <
TT
CLASS="PARAMETER"
> is
CLASS="LITERAL"
> flag is automatically
set. You may remove this flag by calling
HREF="sdlsetalpha.html"
CLASS="FUNCTION"
>
after surface creation.<
/P
CLASS="REFSECT1"
NAME="AEN1411"
>Returns the created surface, or <
SPAN
CLASS="RETURNVALUE"
CLASS="REFSECT1"
NAME="AEN1415"
CLASS="PROGRAMLISTING"
> /* Create a 32-bit surface with the bytes of each pixel in R,G,B,A order,
as expected by OpenGL for textures */
SDL_Surface *surface;
Uint32 rmask, gmask, bmask, amask;
/* SDL interprets each pixel as a 32-bit number, so our masks must depend
on the endianness (byte order) of the machine */
#if SDL_BYTEORDER == SDL_BIG_ENDIAN
rmask = 0xff000000;
gmask = 0x00ff0000;
bmask = 0x0000ff00;
amask = 0x000000ff;
#else
rmask = 0x000000ff;
gmask = 0x0000ff00;
bmask = 0x00ff0000;
amask = 0xff000000;
#endif
surface = SDL_CreateRGBSurface(SDL_SWSURFACE, width, height, 32,
rmask, gmask, bmask, amask);
if(surface == NULL) {
fprintf(stderr, "CreateRGBSurface failed: %s\n", SDL_GetError());
exit(1);
CLASS="REFSECT1"
NAME="AEN1418"
HREF="sdlcreatergbsurfacefrom.html"
CLASS="FUNCTION"
>SDL_CreateRGBSurfaceFrom<
/TT
>,
HREF="sdlfreesurface.html"
CLASS="FUNCTION"
>,
HREF="sdlsetvideomode.html"
CLASS="FUNCTION"
>,
HREF="sdllocksurface.html"
CLASS="FUNCTION"
>,
HREF="sdlpixelformat.html"
CLASS="STRUCTNAME"
>,
HREF="sdlsurface.html"
CLASS="STRUCTNAME"
>
HREF="sdlsetalpha.html"
CLASS="FUNCTION"
>
HREF="sdlsetcolorkey.html"
CLASS="FUNCTION"
CLASS="NAVFOOTER"
ALIGN="LEFT"
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
WIDTH="33%"
ALIGN="left"
VALIGN="top"
HREF="sdlgetrgba.html"
WIDTH="34%"
ALIGN="center"
VALIGN="top"
HREF="index.html"
WIDTH="33%"
ALIGN="right"
VALIGN="top"
HREF="sdlcreatergbsurfacefrom.html"
WIDTH="33%"
ALIGN="left"
VALIGN="top"
WIDTH="34%"
ALIGN="center"
VALIGN="top"
HREF="video.html"
WIDTH="33%"
ALIGN="right"
VALIGN="top"
>SDL_CreateRGBSurfaceFrom<
/TD
>