|
|
On Mon, Feb 2, 2009 at 2:15 PM, Donny Viszneki <donny.viszneki@xxxxxxxxx> wrote:
> I haven't looked at the SDL texture API yet, but "streamable" versus
> "static" probably refers to whether or not memory mapped buffer
> objects were used/available when the texture was created. You would
> have to "lock" the static type of texture because texture memory
> download and upload are atomic. If that's the case, perhaps another
> API could be provided to keep a local copy of static textures so that
> it only had to be uploaded (perhaps it already does this, even.)
>From the 1.3 SDL_video.h:
/**
* \enum SDL_TextureAccess
*
* \brief The access pattern allowed for a texture
*/
typedef enum
{
SDL_TEXTUREACCESS_STATIC, /**< Changes rarely, not lockable */
SDL_TEXTUREACCESS_STREAMING /**< Changes frequently, lockable */
} SDL_TextureAccess;
/**
* \fn void SDL_LockTexture(SDL_TextureID textureID, const SDL_Rect
*rect, int markDirty, void **pixels, int *pitch)
*
* \brief Lock a portion of the texture for pixel access.
*
* \param textureID The texture to lock for access, which was created
with SDL_TEXTUREACCESS_STREAMING.
* \param rect A pointer to the rectangle to lock for access. If the
rect is NULL, the entire texture will be locked.
* \param markDirty If this is nonzero, the locked area will be marked
dirty when the texture is unlocked.
* \param pixels This is filled in with a pointer to the locked
pixels, appropriately offset by the locked area.
* \param pitch This is filled in with the pitch of the locked pixels.
*
* \return 0 on success, or -1 if the texture is not valid or was
created with SDL_TEXTUREACCESS_STATIC
*
* \sa SDL_DirtyTexture()
* \sa SDL_UnlockTexture()
*/
extern DECLSPEC int SDLCALL SDL_LockTexture(SDL_TextureID textureID,
const SDL_Rect * rect,
int markDirty, void **pixels,
int *pitch);
There's also a curious SDL_QueryTexturePixels call to actually get to
the pixel, which, well, isn't all that curious, but says that you can
try it without locking the texture first (still has to be a streamable
texture), which makes for a bit of a weird API. If you use that, you
have to provide a fallback when locking is required... I would have
rather just said "you have to lock all the time", and made locking a
noop when unnecessary.
I'm hoping there isn't a serious speed advantage when
SDL_QueryTexturePixels can be used without locking, this would be
really strange.
--
http://pphaneuf.livejournal.com/
_______________________________________________
SDL mailing list
SDL@xxxxxxxxxxxxxxxx
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org
|
|