home *** CD-ROM | disk | FTP | other *** search
/ RISCWORLD 7 / RISCWORLD_VOL7.iso / Software / Issue4 / SDL / gcc346 / !SDL / man / SDL_CreateRGBSurface.3 < prev    next >
Encoding:
Text File  |  2006-09-20  |  4.1 KB  |  115 lines

  1. <!-- manual page source format generated by PolyglotMan v3.0.8+X.Org, -->
  2. <!-- available at http://polyglotman.sourceforge.net/ -->
  3.  
  4. <html>
  5. <head>
  6. <title>"SDL_CreateRGBSurface"("3") manual page</title>
  7. </head>
  8. <body bgcolor='#efefef' text='black' link='blue' vlink='#551A8B' alink='red'>
  9. <a href='#toc'>Table of Contents</a><p>
  10.  
  11. <h2><a name='sect0' href='#toc0'>Name</a></h2>
  12. SDL_CreateRGBSurface- Create an empty SDL_Surface 
  13. <h2><a name='sect1' href='#toc1'>Synopsis</a></h2>
  14. <p>
  15. <b>#include "SDL.h"
  16. <p>
  17. </b><b>SDL_Surface *<b>SDL_CreateRGBSurface</b></b>(<b>Uint32 flags, int width, int height,
  18. int depth, Uint32 Rmask, Uint32 Gmask, Uint32 Bmask, Uint32 Amask</b>); 
  19. <h2><a name='sect2' href='#toc2'>Description</a></h2>
  20. <p>
  21. Allocate
  22. an empty surface (must be called after <i>SDL_SetVideoMode</i>) <p>
  23. If <b>depth</b> is 8
  24. bits an empty palette is allocated for the surface, otherwise a 'packed-pixel'
  25. <i><b>SDL_PixelFormat</b></i> is created using the <b>[RGBA]mask</b>'s provided (see <i><b>SDL_PixelFormat</b></i>).
  26. The <b>flags</b> specifies the type of surface that should be created, it is an
  27. OR'd combination of the following possible values. 
  28. <dl>
  29.  
  30. <dt><b>SDL_SWSURFACE</b> </dt>
  31. <dd>SDL will
  32. create the surface in system memory. This improves the performance of pixel
  33. level access, however you may not be able to take advantage of some types
  34. of hardware blitting. </dd>
  35.  
  36. <dt><b>SDL_HWSURFACE</b> </dt>
  37. <dd>SDL will attempt to create the surface
  38. in video memory. This will allow SDL to take advantage of Video->Video blits
  39. (which are often accelerated). </dd>
  40.  
  41. <dt><b>SDL_SRCCOLORKEY</b> </dt>
  42. <dd>This flag turns on colourkeying
  43. for blits from this surface. If <b>SDL_HWSURFACE</b> is also specified and colourkeyed
  44. blits are hardware-accelerated, then SDL will attempt to place the surface
  45. in video memory. Use <i><b>SDL_SetColorKey</b></i> to set or clear this flag after surface
  46. creation. </dd>
  47.  
  48. <dt><b>SDL_SRCALPHA</b> </dt>
  49. <dd>This flag turns on alpha-blending for blits from this
  50. surface. If <b>SDL_HWSURFACE</b> is also specified and alpha-blending blits are
  51. hardware-accelerated, then the surface will be placed in video memory if
  52. possible. Use <i><b>SDL_SetAlpha</b></i> to set or clear this flag after surface creation.
  53. </dd>
  54. </dl>
  55. <p>
  56. <blockquote><b>Note:   <p>
  57. If an alpha-channel is specified (that is, if <b>Amask</b></b> is nonzero),
  58. then the <b>SDL_SRCALPHA</b> flag is automatically set. You may remove this flag
  59. by calling <i><b>SDL_SetAlpha</b></i> after surface creation. </blockquote>
  60.  
  61. <h2><a name='sect3' href='#toc3'>Return Value</a></h2>
  62. <p>
  63. Returns the
  64. created surface, or <b>NULL</b> upon error. 
  65. <h2><a name='sect4' href='#toc4'>Example</a></h2>
  66. <p>
  67. <br>
  68. <pre>CW    /* Create a 32-bit surface with the bytes of each pixel in R,G,B,A
  69. order,
  70.        as expected by OpenGL for textures */
  71.     SDL_Surface *surface;
  72.     Uint32 rmask, gmask, bmask, amask;
  73.     /* SDL interprets each pixel as a 32-bit number, so our masks must depend
  74.        on the endianness (byte order) of the machine */
  75. #if SDL_BYTEORDER == SDL_BIG_ENDIAN
  76.     rmask = 0xff000000;
  77.     gmask = 0x00ff0000;
  78.     bmask = 0x0000ff00;
  79.     amask = 0x000000ff;
  80. #else
  81.     rmask = 0x000000ff;
  82.     gmask = 0x0000ff00;
  83.     bmask = 0x00ff0000;
  84.     amask = 0xff000000;
  85. #endif
  86.     surface = SDL_CreateRGBSurface(SDL_SWSURFACE, width, height, 32,
  87.                                    rmask, gmask, bmask, amask);
  88.     if(surface == NULL) {
  89.         fprintf(stderr, "CreateRGBSurface failed: %s
  90. ", SDL_GetError());
  91.         exit(1);
  92.     }
  93. </pre><p>
  94.  
  95. <h2><a name='sect5' href='#toc5'>See Also</a></h2>
  96. <p>
  97. <i><b>SDL_CreateRGBSurfaceFrom</b></i>, <i><b>SDL_FreeSurface</b></i>, <i><b>SDL_SetVideoMode</b></i>, <i><b>SDL_LockSurface</b></i>,
  98. <i><b>SDL_PixelFormat</b></i>, <i><b>SDL_Surface</b></i> <i><b>SDL_SetAlpha</b></i> <i><b>SDL_SetColorKey</b></i> 
  99. <!--
  100.   
  101.  <p>
  102.  
  103. <hr><p>
  104. <a name='toc'><b>Table of Contents</b></a><p>
  105. <ul>
  106. <li><a name='toc0' href='#sect0'>Name</a></li>
  107. <li><a name='toc1' href='#sect1'>Synopsis</a></li>
  108. <li><a name='toc2' href='#sect2'>Description</a></li>
  109. <li><a name='toc3' href='#sect3'>Return Value</a></li>
  110. <li><a name='toc4' href='#sect4'>Example</a></li>
  111. <li><a name='toc5' href='#sect5'>See Also</a></li>
  112. </ul>
  113. </body>
  114. </html>
  115.