4 >SDL_CreateRGBSurface</TITLE
7 CONTENT="Modular DocBook HTML Stylesheet Version 1.76b+
10 TITLE="SDL Library Documentation"
11 HREF="index.html"><LINK
14 HREF="video.html"><LINK
17 HREF="sdlgetrgba.html"><LINK
19 TITLE="SDL_CreateRGBSurfaceFrom"
20 HREF="sdlcreatergbsurfacefrom.html"></HEAD
31 SUMMARY="Header navigation table"
40 >SDL Library Documentation</TH
48 HREF="sdlgetrgba.html"
62 HREF="sdlcreatergbsurfacefrom.html"
73 NAME="SDLCREATERGBSURFACE"
75 >SDL_CreateRGBSurface</H1
83 >SDL_CreateRGBSurface -- Create an empty SDL_Surface</DIV
85 CLASS="REFSYNOPSISDIV"
99 CLASS="FUNCSYNOPSISINFO"
100 >#include "SDL.h"</PRE
107 >SDL_CreateRGBSurface</B
109 >(Uint32 flags, int width, int height, int depth, Uint32 Rmask, Uint32 Gmask, Uint32 Bmask, Uint32 Amask);</CODE
123 >Allocate an empty surface (must be called after <A
124 HREF="sdlsetvideomode.html"
133 > is 8 bits an empty palette is allocated for the surface, otherwise a 'packed-pixel' <A
134 HREF="sdlpixelformat.html"
137 >SDL_PixelFormat</SPAN
139 > is created using the <TT
145 HREF="sdlpixelformat.html"
148 >SDL_PixelFormat</SPAN
155 > specifies the type of surface that should be created, it is an OR'd combination of the following possible values.</P
157 CLASS="INFORMALTABLE"
178 >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
191 >SDL will attempt to create the surface in video memory. This will allow SDL to take advantage of Video->Video blits (which are often accelerated).</TD
204 >This flag turns on colourkeying for blits from this surface. If
208 > is also specified and colourkeyed blits
209 are hardware-accelerated, then SDL will attempt to place the surface in
212 HREF="sdlsetcolorkey.html"
218 to set or clear this flag after surface creation.</TD
231 >This flag turns on alpha-blending for blits from this surface. If
235 > is also specified and alpha-blending blits
236 are hardware-accelerated, then the surface will be placed in video memory if
239 HREF="sdlsetalpha.html"
245 set or clear this flag after surface creation.</TD
259 >If an alpha-channel is specified (that is, if <TT
265 nonzero), then the <TT
268 > flag is automatically
269 set. You may remove this flag by calling
271 HREF="sdlsetalpha.html"
277 after surface creation.</P
289 >Returns the created surface, or <SPAN
302 CLASS="PROGRAMLISTING"
303 > /* Create a 32-bit surface with the bytes of each pixel in R,G,B,A order,
304 as expected by OpenGL for textures */
305 SDL_Surface *surface;
306 Uint32 rmask, gmask, bmask, amask;
308 /* SDL interprets each pixel as a 32-bit number, so our masks must depend
309 on the endianness (byte order) of the machine */
310 #if SDL_BYTEORDER == SDL_BIG_ENDIAN
322 surface = SDL_CreateRGBSurface(SDL_SWSURFACE, width, height, 32,
323 rmask, gmask, bmask, amask);
324 if(surface == NULL) {
325 fprintf(stderr, "CreateRGBSurface failed: %s\n", SDL_GetError());
338 HREF="sdlcreatergbsurfacefrom.html"
341 >SDL_CreateRGBSurfaceFrom</TT
345 HREF="sdlfreesurface.html"
352 HREF="sdlsetvideomode.html"
355 >SDL_SetVideoMode</TT
359 HREF="sdllocksurface.html"
366 HREF="sdlpixelformat.html"
369 >SDL_PixelFormat</SPAN
373 HREF="sdlsurface.html"
380 HREF="sdlsetalpha.html"
387 HREF="sdlsetcolorkey.html"
399 SUMMARY="Footer navigation table"
410 HREF="sdlgetrgba.html"
428 HREF="sdlcreatergbsurfacefrom.html"
452 >SDL_CreateRGBSurfaceFrom</TD