Amiga Developer Site by i n n o i d e a | MorphOS | Amiga Developers | Compilers | Documents | Dev-HardFile v1.11 for UAE / real Amiga - readme - shot) | Unique/All Visitors: 77257/570053
Search manual for function in the   
SDL/SDL_LockSurface
NAME 

SDL_LockSurface- Lock a surface for directly access.

SYNOPSIS 



#include "SDL.h"


int SDL_LockSurface(SDL_Surface *surface);

DESCRIPTION 



SDL_LockSurface sets up a surface for directly accessing the pixels. Between
calls to SDL_LockSurface and SDL_UnlockSurface, you can write to and read from
surface->pixels, using the pixel format stored in surface->format. Once
you are done accessing the surface, you should use SDL_UnlockSurface to release
it.


Not all surfaces require locking. If SDL_MUSTLOCK(surface) evaluates to 0, then
you can read and write to the surface at any time, and the pixel format of the
surface will not change. 


No operating system or library calls should be made between lock/unlock pairs,
as critical system locks may be held during this time.


It should be noted, that since SDL 1.1.8 surface locks are recursive. This means
that you can lock a surface multiple times, but each lock must have a match
unlock. 



    .
    .
    SDL_LockSurface( surface );
    .
    /* Surface is locked */
    /* Direct pixel access on surface here */
    .
    SDL_LockSurface( surface );
    .
    /* More direct pixel access on surface */
    .
    SDL_UnlockSurface( surface );
    /* Surface is still locked */
    /* Note: Is versions < 1.1.8, the surface would have been */
    /* no longer locked at this stage                         */
    .
    SDL_UnlockSurface( surface );
    /* Surface is now unlocked */
    .
    .



 

RETURN VALUE 



SDL_LockSurface returns 0, or -1 if the surface couldn't be locked.

SEE ALSO 



SDL_UnlockSurface


20031117164614 - LouiSe - for (SDL/SDL_LockSurface)
Before writing or reading to a surface's pixels member, it should be "locked" if
required. This is especially important for using hardware surfaces. 

In order to see if a surface requires locking before use, call the function
SDL_MustLock. This function takes a single parameter: the SDL surface you wish
to access. It will return a non zero value if the surface must be locked. 

A surface may be locked with the function SDL_LockSurface. This function only
takes a single parameter, the SDL surface. This function will return a value
less than zero if there is an error. After locking a surface, it is important to
also unlock it. This is done with SDL_UnlockSurface, again passed the surface to
unlock. Here is the SDL lock and unlock code from the example program: 

	if(SDL_MUSTLOCK(screen)) {
		if(SDL_LockSurface(screen) < 0) 
			return;
	}
	
...

	if(SDL_MUSTLOCK(screen)) {
		SDL_UnlockSurface(screen);
	}


Note: In general it is a good idea to keep the surface locked for as short a
period as possible.
When drawing to a surface, the data is usually not displayed as you draw it. In
order to synchronize the data in an SDL surface, with the data on the screen,
you must call the SDL_Flip function. This functions again takes only the SDL
surface as a parameter.

Remember that surfaces only need to be locked when you want to access the pixel
data of a surface(the pixels member of the SDL_Surface structure). Surfaces
should remained locked only as long as needed. When a surface is locked, avoid
making any operating system or library calls. 

Logo by Emeric/SH
SDL/SDL_LockSurface

No examples found...


Functions with "S":
SDLKey
SDL_ActiveEvent
SDL_AddTimer
SDL_AudioCVT
SDL_AudioSpec
SDL_BlitSurface
SDL_BuildAudioCVT
SDL_CD
SDL_CDClose
SDL_CDEject
SDL_CDName
SDL_CDNumDrives
SDL_CDOpen
SDL_CDPause
SDL_CDPlay
SDL_CDPlayTracks
SDL_CDResume
SDL_CDStatus
SDL_CDStop
SDL_CDtrack
SDL_CloseAudio
SDL_Color
SDL_CondBroadcast
SDL_CondSignal
SDL_CondWait
SDL_CondWaitTimeout
SDL_ConvertAudio
SDL_ConvertSurface
SDL_CreateCond
SDL_CreateCursor
SDL_CreateMutex
SDL_CreateRGBSurface
SDL_CreateRGBSurfaceFrom
SDL_CreateSemaphore
SDL_CreateThread
SDL_CreateYUVOverlay
SDL_Delay
SDL_DestroyCond
SDL_DestroyMutex
SDL_DestroySemaphore
SDL_DisplayFormat
SDL_DisplayFormatAlpha
SDL_DisplayYUVOverlay
SDL_EnableKeyRepeat
SDL_EnableUNICODE
SDL_Event
SDL_EventState
SDL_FillRect
SDL_Flip
SDL_FreeCursor
SDL_FreeSurface
SDL_FreeWAV
SDL_FreeYUVOverlay
SDL_GL_GetAttribute
SDL_GL_GetProcAddress
SDL_GL_LoadLibrary
SDL_GL_SetAttribute
SDL_GL_SwapBuffers
SDL_GLattr
SDL_GetAppState
SDL_GetAudioStatus
SDL_GetClipRect
SDL_GetCursor
SDL_GetEventFilter
SDL_GetGamma
SDL_GetGammaRamp
SDL_GetKeyName
SDL_GetKeyState
SDL_GetModState
SDL_GetMouseState
SDL_GetRGB
SDL_GetRGBA
SDL_GetRelativeMouseState
SDL_GetThreadID
SDL_GetTicks
SDL_GetVideoInfo
SDL_GetVideoSurface
SDL_Init
SDL_InitSubSystem
SDL_JoyAxisEvent
SDL_JoyBallEvent
SDL_JoyButtonEvent
SDL_JoyHatEvent
SDL_JoystickClose
SDL_JoystickEventState
SDL_JoystickGetAxis
SDL_JoystickGetBall
SDL_JoystickGetButton
SDL_JoystickGetHat
SDL_JoystickIndex
SDL_JoystickName
SDL_JoystickNumAxes
SDL_JoystickNumBalls
SDL_JoystickNumButtons
SDL_JoystickNumHats
SDL_JoystickOpen
SDL_JoystickOpened
SDL_JoystickUpdate
SDL_KeyboardEvent
SDL_KillThread
SDL_ListModes
SDL_LoadBMP
SDL_LoadWAV
SDL_LockAudio
SDL_LockSurface
SDL_LockYUVOverlay
SDL_MapRGB
SDL_MapRGBA
SDL_MixAudio
SDL_MouseButtonEvent
SDL_MouseMotionEvent
SDL_NumJoysticks
SDL_OpenAudio
SDL_Overlay
SDL_Palette
SDL_PauseAudio
SDL_PeepEvents
SDL_PixelFormat
SDL_PollEvent
SDL_PumpEvents
SDL_PushEvent
SDL_Quit
SDL_QuitEvent
SDL_QuitSubSystem
SDL_RWFromFile
SDL_Rect
SDL_RemoveTimer
SDL_ResizeEvent
SDL_SaveBMP
SDL_SemPost
SDL_SemTryWait
SDL_SemValue
SDL_SemWait
SDL_SemWaitTimeout
SDL_SetAlpha
SDL_SetClipRect
SDL_SetColorKey
SDL_SetColors
SDL_SetCursor
SDL_SetEventFilter
SDL_SetGamma
SDL_SetGammaRamp
SDL_SetModState
SDL_SetPalette
SDL_SetTimer
SDL_SetVideoMode
SDL_ShowCursor
SDL_Surface
SDL_SysWMEvent
SDL_ThreadID
SDL_UnlockAudio
SDL_UnlockSurface
SDL_UnlockYUVOverlay
SDL_UpdateRect
SDL_UpdateRects
SDL_UserEvent
SDL_VideoDriverName
SDL_VideoInfo
SDL_VideoModeOK
SDL_WM_GetCaption
SDL_WM_GrabInput
SDL_WM_IconifyWindow
SDL_WM_SetCaption
SDL_WM_SetIcon
SDL_WM_ToggleFullScreen
SDL_WaitEvent
SDL_WaitThread
SDL_WarpMouse
SDL_WasInit
SDL_keysym
SDL_mutexP
SDL_mutexV

Last 15 uploaded Examples:

20071229151342 AmiSSL/X509_STORE_CTX_cleanup
20070708011052 GeekGadgets/getlogin
20060705053954 AmigaOS/OpenWorkbenchObjectA
20050801035639 SDL/SDL_Surface
20050727092732 BlitzBasic/LSL
20050718102843 SDL/SDL_WarpMouse
20050718072844 GeekGadgets/fread
20050714051528 SDL/SDL_ActiveEvent
20050714051514 SDL/SDL_ActiveEvent
20050701171401 GeekGadgets/errno
20050701171347 GeekGadgets/errno
20050627101951 SDL/SDL_FreeSurface
20050623152729 GeekGadgets/fork
20050619153102 GeekGadgets/tcdrain
20050615182849 AmigaOS/OpenScreen

Last 25 posts:

20050613235812 SDL/SDL_SetGammaRamp
20050526065000 AmiTCP/unistd.h
20050413041558 AmiSSL/X509_STORE_set_default_paths
20050409155750 AmigaDOS/Status
20050129230614 MUI/Calendar.mcc
20050128185620 GeekGadgets/hstrerror
20041126154558 BlitzBasic/LoadBank
20041123170704 GeekGadgets/gcvt
20041105222909 AmigaOS/CheckSignal
20040712190839 SDL/SDL_SetVideoMode
20040627090529 SDL/SDL_Init
20040519133228 GeekGadgets/fork
20040407124555 AmigaOS/AllocMem
20040403101120 GeekGadgets/inet_ntoa
20040327172814 GeekGadgets/random
20040327172714 GeekGadgets/srandom
20040313211937 BlitzBasic/ANALYZEDISK
20040303135237 GeekGadgets/mktemp
20040301131355 GeekGadgets/realpath
20040301123615 GeekGadgets/gcvt
20040301114000 GeekGadgets/htonl
20040301100209 GeekGadgets/realpath
20040229095437 GeekGadgets/time
20040211132618 GeekGadgets/getpid
20040209102818 AmigaOS/OpenWindow




Amiga.sf
AMIGIFT

Locations of visitors to this page

Page took 0.639287 seconds to load.