Wiki Page Content

Differences between revisions 11 and 32 (spanning 21 versions)
Revision 11 as of 2010-11-01 04:43:31
Size: 3553
Editor: SheenaSmith
Comment: update content - old wiki
Revision 32 as of 2017-07-14 21:51:36
Size: 3391
Comment: Removed SDL_UpperBlit from Related Functions.
Deletions are marked like this. Additions are marked like this.
Line 2: Line 2:
#pragma disable-camelcase
||<tablewidth="100%" style="color: #FF0000;" :> DRAFT||
#pragma camelcase off
Line 11: Line 10:
||<style="color: #808080;">Uint32||<style="color: #808080;">'''flags'''||<style="color: #808080;">internal||
||[[SDL_PixelFormat]]*||'''format'''||the format of the pixels stored in the surface; ,,see [[SDL_PixelFormat]],, (read-only)||
||int||'''w, h'''||the surface width and height in pixels (read-only)||
||int||'''pitch'''||the length of a surface scanline in bytes (read-only)||
||void*||'''pixels'''||the pointer to the actual pixel data; the surface should be locked by [[SDL_LockSurface]]() before accessing this field (read-write)||
||<:bgcolor="#EDEDED"-3>''Application data associated with the surface''||
||void*||'''userdata'''||,,a pointer to user-specified content???,, (read-write)||
||<:bgcolor="#EDEDED"-3>''Information needed for surfaces requiring locks''||
||int||'''locked'''||read-only||
||void*||'''lock_data'''||read-only||
||<:bgcolor="#EDEDED"-3>''Clipping information''||
||[[SDL_Rect]]||'''clip_rect'''||the surface clip rectangle which can be set by [[SDL_SetClipRect]]() (read-only)||
||<:bgcolor="#EDEDED"-3>''Info for fast blit mapping to other surfaces''||
||<style="color: #808080;">SDL_!BlitMap*||<style="color: #808080;">'''map'''||<style="color: #808080;">internal||
||<:bgcolor="#EDEDED"-3>''Format version, bumped at every change to invalidate blit maps''||
||unsigned int ^Uint?^||'''format_version'''||<style="color: #808080;">internal||
||<:bgcolor="#EDEDED"-3>'',,Reference count --,, used when freeing surface''||
||int||'''refcount'''||read-mostly||
||<style="color: rgb(128, 128, 128);">Uint32 ||<style="color: rgb(128, 128, 128);">'''flags''' ||<style="color: rgb(128, 128, 128);">(internal use)||
||[[SDL_PixelFormat]]* ||'''format''' ||the format of the pixels stored in the surface; see [[SDL_PixelFormat]] for details (read-only) ||
||int ||'''w, h''' ||the width and height in pixels (read-only) ||
||int ||'''pitch''' ||the length of a row of pixels in bytes (read-only) ||
||void* ||'''pixels''' ||the pointer to the actual pixel data; see [[#Remarks|Remarks]] for details (read-write) ||
||void* ||'''userdata''' ||an arbitrary pointer you can set (read-write) ||
||<style="color: rgb(128, 128, 128);">int ||<style="color: rgb(128, 128, 128);">'''locked''' ||<style="color: rgb(128, 128, 128);">used for surfaces that require locking (internal use)||
||<style="color: rgb(128, 128, 128);">void* ||<style="color: rgb(128, 128, 128);">'''lock_data''' ||<style="color: rgb(128, 128, 128);">used for surfaces that require locking (internal use)||
||[[SDL_Rect]] ||'''clip_rect''' ||an [[SDL_Rect]] structure used to clip blits to the surface which can be set by [[SDL_SetClipRect]]() (read-only) ||
||<style="color: rgb(128, 128, 128);">SDL_!BlitMap* ||<style="color: rgb(128, 128, 128);">'''map''' ||<style="color: rgb(128, 128, 128);">info for fast blit mapping to other surfaces (internal use)||
||int ||'''refcount''' ||reference count that can be incremented by the application ||
Line 32: Line 25:
You can add your code example here /* This is meant to show how to edit a surface's pixels on the CPU, but
   normally you should use SDL_FillRect() to wipe a surface's contents. */
void WipeSurface(SDL_Surface *surface)
{
    /* This is fast for surfaces that don't require locking. */
    /* Once locked, surface->pixels is safe to access. */
    SDL_LockSurface(surface);

    /* This assumes that color value zero is black. Use
       SDL_MapRGBA() for more robust surface color mapping! */
    /* height times pitch is the size of the surface's whole buffer. */
    SDL_memset(surface->pixels, 0, surface->h * surface->pitch);

    SDL_UnlockSurface(surface);
}
Line 35: Line 42:
<<Color2(green,Should any of the User Comments from the old wiki be included here?)>>
Line 38: Line 43:
An [[SDL_Surface]] structure represents an area of graphical memory that can be drawn to.

This structure should be treated as read-only, except for '''pixels''' which, if not NULL, contains the raw pixel data for the surface.

== Related Structures ==
 .[[SDL_SDL_PixelFormat]]
 .[[SDL_Rect]]
With most surfaces you can access the pixels directly. Surfaces that have been optimized with [[SDL_SetSurfaceRLE]]() should be locked with [[SDL_LockSurface]]() before accessing '''pixels'''. When you are done you should call [[SDL_UnlockSurface]]() before blitting.
Line 47: Line 46:
 .[[SDL_BlendCircle]]
 .[[SDL_BlendEllipse]]
 .[[SDL_BlendFillCircle]]
 .[[SDL_BlendFillEllipse]]
 .[[SDL_BlendFillRect]]
 .[[SDL_BlendFillRects]]
 .[[SDL_BlendLine]]
 .[[SDL_BlendLines]]
 .[[SDL_BlendPoint]]
 .[[SDL_BlendPoints]]
 .[[SDL_BlendRect]]
 .[[SDL_BlendRects]]
 .[[SDL_ConvertSurface]]
 .[[SDL_CreateRGBSurface]]
 .[[SDL_CreateRGBSurfaceFrom]]
 .[[SDL_DrawCircle]]
 .[[SDL_DrawEllipse]]
 .[[SDL_DrawLine]]
 .[[SDL_DrawLines]]
 .[[SDL_DrawPoint]]
 .[[SDL_DrawPoints]]
 .[[SDL_DrawRect]]
 .[[SDL_DrawRects]]
 .[[SDL_FillCircle]]
 .[[SDL_FillEllipse]]
 .[[SDL_FillRect]]
 .[[SDL_FillRects]]
 .[[SDL_FreeSurface]]
 .[[SDL_GetClipRect]]
 .[[SDL_GetColorKey]]
 .[[SDL_GetSurfaceAlphaMod]]
 .[[SDL_GetSurfaceBlendMode]]
 .[[SDL_GetSurfaceColorMod]]
 .[[SDL_GetSurfaceScaleMode]]
 .[[SDL_LoadBMP_RW]]
 .[[SDL_LockSurface]]
 .[[SDL_LowerBlit]]
 .[[SDL_MUSTLOCK]]
 .[[SDL_SaveBMP_RW]]
 .[[SDL_SetClipRect]]
 .[[SDL_SetColorKey]]
 .[[SDL_SetSurfaceAlphaMod]]
 .[[SDL_SetSurfaceBlendMode]]
 .[[SDL_SetSurfaceColorMod]]
 .[[SDL_SetSurfacePalette]]
 .[[SDL_SetSurfaceRLE]]
 .[[SDL_SetSurfaceScaleMode]]
 .[[SDL_SoftStretch]]
 .[[SDL_UnlockSurface]]
 .[[SDL_UpperBlit]]
 . [[SDL_BlitSurface]]
 . [[SDL_ConvertSurface]]
 . [[SDL_CreateRGBSurface]]
 . [[SDL_CreateRGBSurfaceFrom]]
 . [[SDL_FillRect]]
 . [[SDL_FillRects]]
 . [[SDL_FreeSurface]]
 . [[SDL_GetClipRect]]
 . [[SDL_GetColorKey]]
 . [[SDL_GetSurfaceAlphaMod]]
 . [[SDL_GetSurfaceBlendMode]]
 . [[SDL_GetSurfaceColorMod]]
 . [[SDL_LoadBMP_RW]]
 . [[SDL_LockSurface]]
 . [[SDL_LowerBlit]]
 . [[SDL_MUSTLOCK]]
 . [[SDL_SaveBMP_RW]]
 . [[SDL_SetClipRect]]
 . [[SDL_SetColorKey]]
 . [[SDL_SetSurfaceAlphaMod]]
 . [[SDL_SetSurfaceBlendMode]]
 . [[SDL_SetSurfaceColorMod]]
 . [[SDL_SetSurfacePalette]]
 . [[SDL_SetSurfaceRLE]]
 . [[SDL_SoftStretch]]
 . [[SDL_UnlockSurface]]

SDL_Surface

A structure that contains a collection of pixels used in software blitting.

Data Fields

Uint32

flags

(internal use)

SDL_PixelFormat*

format

the format of the pixels stored in the surface; see SDL_PixelFormat for details (read-only)

int

w, h

the width and height in pixels (read-only)

int

pitch

the length of a row of pixels in bytes (read-only)

void*

pixels

the pointer to the actual pixel data; see Remarks for details (read-write)

void*

userdata

an arbitrary pointer you can set (read-write)

int

locked

used for surfaces that require locking (internal use)

void*

lock_data

used for surfaces that require locking (internal use)

SDL_Rect

clip_rect

an SDL_Rect structure used to clip blits to the surface which can be set by SDL_SetClipRect() (read-only)

SDL_BlitMap*

map

info for fast blit mapping to other surfaces (internal use)

int

refcount

reference count that can be incremented by the application

Code Examples

/* This is meant to show how to edit a surface's pixels on the CPU, but
   normally you should use SDL_FillRect() to wipe a surface's contents. */
void WipeSurface(SDL_Surface *surface)
{
    /* This is fast for surfaces that don't require locking. */
    /* Once locked, surface->pixels is safe to access. */
    SDL_LockSurface(surface);

    /* This assumes that color value zero is black. Use
       SDL_MapRGBA() for more robust surface color mapping! */
    /* height times pitch is the size of the surface's whole buffer. */
    SDL_memset(surface->pixels, 0, surface->h * surface->pitch);

    SDL_UnlockSurface(surface);
}

Remarks

With most surfaces you can access the pixels directly. Surfaces that have been optimized with SDL_SetSurfaceRLE() should be locked with SDL_LockSurface() before accessing pixels. When you are done you should call SDL_UnlockSurface() before blitting.


CategoryStruct, CategorySurface

None: SDL_Surface (last edited 2017-07-14 21:51:36 by PhilippWiesemann)

(Page Info.)
Feedback
Please include your contact information if you'd like to receive a reply.
Submit