Subversion Repositories Kolibri OS

Rev

Blame | Last modification | View Log | RSS feed

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