Kanzi Graphics Engine
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros
kzu_shared_image_texture.h File Reference

Shared 2D image texture. More...

Typedefs

typedef kzsError(* kzuSharedImageTextureExternalTextureCreateFunction )(struct KzuSharedImageTexture *imageTexture, kzUint *out_textureHandle)
 Callback for creating external texture. More...
 

Functions

kzsError kzuSharedImageTextureCreate (const struct KzuResourceManager *resourceManager, kzString name, enum KzuTextureChannels channels, kzUint width, kzUint height, void *clientBuffer, void *userData, kzBool isExternalTexture, struct KzuSharedImageTexture **out_imageTexture)
 Creates a shared 2D image texture that can perform data updates asynchronously. More...
 
kzsError kzuSharedImageTextureCreateExternal (const struct KzuResourceManager *resourceManager, kzString name, kzUint width, kzUint height, void *userData, kzUint externalTextureHandle, kzuSharedImageTextureExternalTextureCreateFunction externalTextureCreator, struct KzuSharedImageTexture **out_imageTexture)
 Creates a shared 2D image texture that shares texture data with a texture created in the same or another OpenGL context. More...
 
kzsError kzuSharedImageTextureRegisterToFactory (const struct KzuFactory *factory)
 Registers shared image texture type to factory. More...
 
struct KzuTexturekzuSharedImageTextureToTexture (const struct KzuSharedImageTexture *imageTexture)
 Converts 2D image texture to texture. More...
 
struct KzuSharedImageTexturekzuSharedImageTextureFromTexture (const struct KzuTexture *texture)
 Converts texture to 2D image texture. More...
 
struct KzuGPUResourcekzuSharedImageTextureToGPUResource (const struct KzuSharedImageTexture *imageTexture)
 Converts 2D image texture to GPU resource. More...
 
struct KzuSharedImageTexturekzuSharedImageTextureFromGPUResource (const struct KzuGPUResource *gpuResource)
 Converts GPU resource to 2D image texture. More...
 
struct KzuResourcekzuSharedImageTextureToResource (const struct KzuSharedImageTexture *imageTexture)
 Converts 2D image texture to resource. More...
 
struct KzuSharedImageTexturekzuSharedImageTextureFromResource (const struct KzuResource *resource)
 Converts resource to 2D image texture. More...
 
kzsError kzuSharedImageTextureLock (struct KzuSharedImageTexture *imageTexture)
 Locks data update. More...
 
kzsError kzuSharedImageTextureUpdate (struct KzuSharedImageTexture *imageTexture, void *data, kzUint dataSize)
 Performs the data update for image texture. More...
 
kzsError kzuSharedImageTextureUnlock (struct KzuSharedImageTexture *imageTexture)
 Unlocks data update for image texture. More...
 
voidkzuSharedImageTextureGetUserData (const struct KzuSharedImageTexture *imageTexture)
 Gets user data. More...
 

Variables

const KzuResourceType KZU_RESOURCE_TYPE_SHARED_IMAGE_TEXTURE
 Resource type identifier for shared 2D image texture. More...
 

Detailed Description

Shared 2D image texture.

Copyright 2008-2019 by Rightware. All rights reserved.

Typedef Documentation

typedef kzsError(* kzuSharedImageTextureExternalTextureCreateFunction)(struct KzuSharedImageTexture *imageTexture, kzUint *out_textureHandle)

Callback for creating external texture.

On Android, OpenGL context is recreated when resumed.

Function Documentation

kzsError kzuSharedImageTextureCreate ( const struct KzuResourceManager resourceManager,
kzString  name,
enum KzuTextureChannels  channels,
kzUint  width,
kzUint  height,
void clientBuffer,
void userData,
kzBool  isExternalTexture,
struct KzuSharedImageTexture **  out_imageTexture 
)

Creates a shared 2D image texture that can perform data updates asynchronously.

It's by default an RGBA8 texture, unless otherwise specified in client buffer.

Parameters
widthWidth of the texture.
heightHeight of the texture.
clientBufferClient buffer to perform the data upload, for example Android GraphicBuffer. When KZ_NULL, ignored.
userDataPlatform specific user data of the client buffer, directly EGL config when utilizing. When KZ_NULL, ignored.
isExternalTextureIs texture external, can be utilized when retrieving data non-RGB format such as YUV and doing the conversion on GPU via EXTERNAL_TEXTURE_OES extension. When using external textures in OpenGL shader, user must make sure that sampler uniform is type of samplerExternalOES instead of sampler2D and extension #extension GL_OES_EGL_image_external : require has been specified.
kzsError kzuSharedImageTextureCreateExternal ( const struct KzuResourceManager resourceManager,
kzString  name,
kzUint  width,
kzUint  height,
void userData,
kzUint  externalTextureHandle,
kzuSharedImageTextureExternalTextureCreateFunction  externalTextureCreator,
struct KzuSharedImageTexture **  out_imageTexture 
)

Creates a shared 2D image texture that shares texture data with a texture created in the same or another OpenGL context.

When using external textures in OpenGL shader, user must make sure that sampler uniform is type of samplerExternalOES instead of sampler2D and extension #extension GL_OES_EGL_image_external : require has been specified.

Parameters
externalTextureHandleTexture handle of the texture being shared.
kzsError kzuSharedImageTextureRegisterToFactory ( const struct KzuFactory factory)

Registers shared image texture type to factory.

struct KzuTexture* kzuSharedImageTextureToTexture ( const struct KzuSharedImageTexture imageTexture)

Converts 2D image texture to texture.

struct KzuSharedImageTexture* kzuSharedImageTextureFromTexture ( const struct KzuTexture texture)

Converts texture to 2D image texture.

struct KzuGPUResource* kzuSharedImageTextureToGPUResource ( const struct KzuSharedImageTexture imageTexture)

Converts 2D image texture to GPU resource.

struct KzuSharedImageTexture* kzuSharedImageTextureFromGPUResource ( const struct KzuGPUResource gpuResource)

Converts GPU resource to 2D image texture.

struct KzuResource* kzuSharedImageTextureToResource ( const struct KzuSharedImageTexture imageTexture)

Converts 2D image texture to resource.

struct KzuSharedImageTexture* kzuSharedImageTextureFromResource ( const struct KzuResource resource)

Converts resource to 2D image texture.

kzsError kzuSharedImageTextureLock ( struct KzuSharedImageTexture imageTexture)

Locks data update.

When locked, data can be safely updated in separate thread / process.

kzsError kzuSharedImageTextureUpdate ( struct KzuSharedImageTexture imageTexture,
void data,
kzUint  dataSize 
)

Performs the data update for image texture.

Must be called between Lock and Unlock.

kzsError kzuSharedImageTextureUnlock ( struct KzuSharedImageTexture imageTexture)

Unlocks data update for image texture.

When unlocked, main thread can safely take the data into use.

void* kzuSharedImageTextureGetUserData ( const struct KzuSharedImageTexture imageTexture)

Gets user data.

Variable Documentation

const KzuResourceType KZU_RESOURCE_TYPE_SHARED_IMAGE_TEXTURE

Resource type identifier for shared 2D image texture.