add OMAP layer handling
[sdl_omap.git] / docs / html / sdlcreatergbsurface.html
CommitLineData
e14743d1 1<HTML
2><HEAD
3><TITLE
4>SDL_CreateRGBSurface</TITLE
5><META
6NAME="GENERATOR"
7CONTENT="Modular DocBook HTML Stylesheet Version 1.76b+
8"><LINK
9REL="HOME"
10TITLE="SDL Library Documentation"
11HREF="index.html"><LINK
12REL="UP"
13TITLE="Video"
14HREF="video.html"><LINK
15REL="PREVIOUS"
16TITLE="SDL_GetRGBA"
17HREF="sdlgetrgba.html"><LINK
18REL="NEXT"
19TITLE="SDL_CreateRGBSurfaceFrom"
20HREF="sdlcreatergbsurfacefrom.html"></HEAD
21><BODY
22CLASS="REFENTRY"
23BGCOLOR="#FFF8DC"
24TEXT="#000000"
25LINK="#0000ee"
26VLINK="#551a8b"
27ALINK="#ff0000"
28><DIV
29CLASS="NAVHEADER"
30><TABLE
31SUMMARY="Header navigation table"
32WIDTH="100%"
33BORDER="0"
34CELLPADDING="0"
35CELLSPACING="0"
36><TR
37><TH
38COLSPAN="3"
39ALIGN="center"
40>SDL Library Documentation</TH
41></TR
42><TR
43><TD
44WIDTH="10%"
45ALIGN="left"
46VALIGN="bottom"
47><A
48HREF="sdlgetrgba.html"
49ACCESSKEY="P"
50>Prev</A
51></TD
52><TD
53WIDTH="80%"
54ALIGN="center"
55VALIGN="bottom"
56></TD
57><TD
58WIDTH="10%"
59ALIGN="right"
60VALIGN="bottom"
61><A
62HREF="sdlcreatergbsurfacefrom.html"
63ACCESSKEY="N"
64>Next</A
65></TD
66></TR
67></TABLE
68><HR
69ALIGN="LEFT"
70WIDTH="100%"></DIV
71><H1
72><A
73NAME="SDLCREATERGBSURFACE"
74></A
75>SDL_CreateRGBSurface</H1
76><DIV
77CLASS="REFNAMEDIV"
78><A
79NAME="AEN1773"
80></A
81><H2
82>Name</H2
83>SDL_CreateRGBSurface&nbsp;--&nbsp;Create an empty SDL_Surface</DIV
84><DIV
85CLASS="REFSYNOPSISDIV"
86><A
87NAME="AEN1776"
88></A
89><H2
90>Synopsis</H2
91><DIV
92CLASS="FUNCSYNOPSIS"
93><A
94NAME="AEN1777"
95></A
96><P
97></P
98><PRE
99CLASS="FUNCSYNOPSISINFO"
100>#include "SDL.h"</PRE
101><P
102><CODE
103><CODE
104CLASS="FUNCDEF"
105>SDL_Surface *<B
106CLASS="FSFUNC"
107>SDL_CreateRGBSurface</B
108></CODE
109>(Uint32 flags, int width, int height, int depth, Uint32 Rmask, Uint32 Gmask, Uint32 Bmask, Uint32 Amask);</CODE
110></P
111><P
112></P
113></DIV
114></DIV
115><DIV
116CLASS="REFSECT1"
117><A
118NAME="AEN1783"
119></A
120><H2
121>Description</H2
122><P
123>Allocate an empty surface (must be called after <A
124HREF="sdlsetvideomode.html"
125>SDL_SetVideoMode</A
126>)</P
127><P
128>If <TT
129CLASS="PARAMETER"
130><I
131>depth</I
132></TT
133> is 8 bits an empty palette is allocated for the surface, otherwise a 'packed-pixel' <A
134HREF="sdlpixelformat.html"
135><SPAN
136CLASS="STRUCTNAME"
137>SDL_PixelFormat</SPAN
138></A
139> is created using the <TT
140CLASS="PARAMETER"
141><I
142>[RGBA]mask</I
143></TT
144>'s provided (see <A
145HREF="sdlpixelformat.html"
146><SPAN
147CLASS="STRUCTNAME"
148>SDL_PixelFormat</SPAN
149></A
150>). The <TT
151CLASS="PARAMETER"
152><I
153>flags</I
154></TT
155> specifies the type of surface that should be created, it is an OR'd combination of the following possible values.</P
156><DIV
157CLASS="INFORMALTABLE"
158><A
159NAME="AEN1795"
160></A
161><P
162></P
163><TABLE
164BORDER="1"
165CLASS="CALSTABLE"
166><TBODY
167><TR
168><TD
169ALIGN="LEFT"
170VALIGN="TOP"
171><TT
172CLASS="LITERAL"
173>SDL_SWSURFACE</TT
174></TD
175><TD
176ALIGN="LEFT"
177VALIGN="TOP"
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
179></TR
180><TR
181><TD
182ALIGN="LEFT"
183VALIGN="TOP"
184><TT
185CLASS="LITERAL"
186>SDL_HWSURFACE</TT
187></TD
188><TD
189ALIGN="LEFT"
190VALIGN="TOP"
191>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
192></TR
193><TR
194><TD
195ALIGN="LEFT"
196VALIGN="TOP"
197><TT
198CLASS="LITERAL"
199>SDL_SRCCOLORKEY</TT
200></TD
201><TD
202ALIGN="LEFT"
203VALIGN="TOP"
204>This flag turns on colourkeying for blits from this surface. If
205<TT
206CLASS="LITERAL"
207>SDL_HWSURFACE</TT
208> is also specified and colourkeyed blits
209are hardware-accelerated, then SDL will attempt to place the surface in
210video memory.
211Use <A
212HREF="sdlsetcolorkey.html"
213><TT
214CLASS="FUNCTION"
215>SDL_SetColorKey</TT
216></A
217>
218to set or clear this flag after surface creation.</TD
219></TR
220><TR
221><TD
222ALIGN="LEFT"
223VALIGN="TOP"
224><TT
225CLASS="LITERAL"
226>SDL_SRCALPHA</TT
227></TD
228><TD
229ALIGN="LEFT"
230VALIGN="TOP"
231>This flag turns on alpha-blending for blits from this surface. If
232<TT
233CLASS="LITERAL"
234>SDL_HWSURFACE</TT
235> is also specified and alpha-blending blits
236are hardware-accelerated, then the surface will be placed in video memory if
237possible.
238Use <A
239HREF="sdlsetalpha.html"
240><TT
241CLASS="FUNCTION"
242>SDL_SetAlpha</TT
243></A
244> to
245set or clear this flag after surface creation.</TD
246></TR
247></TBODY
248></TABLE
249><P
250></P
251></DIV
252><DIV
253CLASS="NOTE"
254><BLOCKQUOTE
255CLASS="NOTE"
256><P
257><B
258>Note: </B
259>If an alpha-channel is specified (that is, if <TT
260CLASS="PARAMETER"
261><I
262>Amask</I
263></TT
264> is
265nonzero), then the <TT
266CLASS="LITERAL"
267>SDL_SRCALPHA</TT
268> flag is automatically
269set. You may remove this flag by calling
270<A
271HREF="sdlsetalpha.html"
272><TT
273CLASS="FUNCTION"
274>SDL_SetAlpha</TT
275></A
276>
277after surface creation.</P
278></BLOCKQUOTE
279></DIV
280></DIV
281><DIV
282CLASS="REFSECT1"
283><A
284NAME="AEN1826"
285></A
286><H2
287>Return Value</H2
288><P
289>Returns the created surface, or <SPAN
290CLASS="RETURNVALUE"
291>NULL</SPAN
292> upon error.</P
293></DIV
294><DIV
295CLASS="REFSECT1"
296><A
297NAME="AEN1830"
298></A
299><H2
300>Example</H2
301><PRE
302CLASS="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;
307
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
311 rmask = 0xff000000;
312 gmask = 0x00ff0000;
313 bmask = 0x0000ff00;
314 amask = 0x000000ff;
315#else
316 rmask = 0x000000ff;
317 gmask = 0x0000ff00;
318 bmask = 0x00ff0000;
319 amask = 0xff000000;
320#endif
321
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());
326 exit(1);
327 }</PRE
328></DIV
329><DIV
330CLASS="REFSECT1"
331><A
332NAME="AEN1833"
333></A
334><H2
335>See Also</H2
336><P
337><A
338HREF="sdlcreatergbsurfacefrom.html"
339><TT
340CLASS="FUNCTION"
341>SDL_CreateRGBSurfaceFrom</TT
342></A
343>,
344<A
345HREF="sdlfreesurface.html"
346><TT
347CLASS="FUNCTION"
348>SDL_FreeSurface</TT
349></A
350>,
351<A
352HREF="sdlsetvideomode.html"
353><TT
354CLASS="FUNCTION"
355>SDL_SetVideoMode</TT
356></A
357>,
358<A
359HREF="sdllocksurface.html"
360><TT
361CLASS="FUNCTION"
362>SDL_LockSurface</TT
363></A
364>,
365<A
366HREF="sdlpixelformat.html"
367><SPAN
368CLASS="STRUCTNAME"
369>SDL_PixelFormat</SPAN
370></A
371>,
372<A
373HREF="sdlsurface.html"
374><SPAN
375CLASS="STRUCTNAME"
376>SDL_Surface</SPAN
377></A
378>
379<A
380HREF="sdlsetalpha.html"
381><TT
382CLASS="FUNCTION"
383>SDL_SetAlpha</TT
384></A
385>
386<A
387HREF="sdlsetcolorkey.html"
388><TT
389CLASS="FUNCTION"
390>SDL_SetColorKey</TT
391></A
392></P
393></DIV
394><DIV
395CLASS="NAVFOOTER"
396><HR
397ALIGN="LEFT"
398WIDTH="100%"><TABLE
399SUMMARY="Footer navigation table"
400WIDTH="100%"
401BORDER="0"
402CELLPADDING="0"
403CELLSPACING="0"
404><TR
405><TD
406WIDTH="33%"
407ALIGN="left"
408VALIGN="top"
409><A
410HREF="sdlgetrgba.html"
411ACCESSKEY="P"
412>Prev</A
413></TD
414><TD
415WIDTH="34%"
416ALIGN="center"
417VALIGN="top"
418><A
419HREF="index.html"
420ACCESSKEY="H"
421>Home</A
422></TD
423><TD
424WIDTH="33%"
425ALIGN="right"
426VALIGN="top"
427><A
428HREF="sdlcreatergbsurfacefrom.html"
429ACCESSKEY="N"
430>Next</A
431></TD
432></TR
433><TR
434><TD
435WIDTH="33%"
436ALIGN="left"
437VALIGN="top"
438>SDL_GetRGBA</TD
439><TD
440WIDTH="34%"
441ALIGN="center"
442VALIGN="top"
443><A
444HREF="video.html"
445ACCESSKEY="U"
446>Up</A
447></TD
448><TD
449WIDTH="33%"
450ALIGN="right"
451VALIGN="top"
452>SDL_CreateRGBSurfaceFrom</TD
453></TR
454></TABLE
455></DIV
456></BODY
457></HTML
458>