SceneTexture(getDrawable(R.drawable.myDrawable)) // Creating a SceneTexture from drawable in resources SceneTexture(Color.valueOf(Color.BLACK)) // Creating a plain black SceneTexture
class SceneTexture
SceneTexture
(
width
, height
, numberOfMips
, samplerConfig
, color
)
|
Signature
constructor(width: Int, height: Int, numberOfMips: Int, samplerConfig: SamplerConfig = SamplerConfig(), color: Color?) Parameters Returns |
SceneTexture
(
image
, samplerConfig
)
|
Signature
constructor(image: Image, samplerConfig: SamplerConfig = SamplerConfig()) Parameters
image:
Image
samplerConfig:
SamplerConfig Returns |
SceneTexture
(
bitmap
, samplerConfig
)
|
Signature
constructor(bitmap: Bitmap, samplerConfig: SamplerConfig = SamplerConfig()) Parameters
bitmap:
Bitmap
samplerConfig:
SamplerConfig Returns |
SceneTexture
(
drawable
)
| |
SceneTexture
(
color
, samplerConfig
)
|
Signature
constructor(color: Color, samplerConfig: SamplerConfig = SamplerConfig()) Parameters
color:
Color
samplerConfig:
SamplerConfig Returns |
handle
: Long
[Get] |
Signature
var handle: Long |
clear
(
r
, g
, b
, a
)
|
Clears the texture with a solid color specified by RGBA float values.
Signature
fun clear(r: Float, g: Float, b: Float, a: Float) Parameters
r:
Float
g:
Float
b:
Float
a:
Float
|
destroy
()
|
Signature
fun destroy() |
nativeHandle
()
|
Signature
fun nativeHandle(): Long Returns
Long
|
update
(
buffer
, width
, height
, strideInBytes
)
|
Updates the texture with new data.
Signature
fun update(buffer: ByteBuffer, width: Int, height: Int, strideInBytes: Int) Parameters
buffer:
ByteBuffer
width:
Int
height:
Int
strideInBytes:
Int
|
DEFAULT_TEXTURE_SIZE
: Int
[Get] |
Default texture size for non-bitmap resources (e.g., vector drawables).
Signature
const val DEFAULT_TEXTURE_SIZE: Int = 256 |
calculateMips
(
w
, h
)
|
Calculates the number of mipmap levels for a texture of the given dimensions.
Mipmaps are smaller versions of a texture used for rendering at different distances, which improves rendering quality and performance.
Signature
fun calculateMips(w: Int, h: Int): Int Parameters
w:
Int
h:
Int
Returns
Int
|
createFromPlatformImage
(
w
, h
, mips
, platformImage
, samplerConfig
)
DeprecatedUse SceneTexture constructor and SceneTexture.update instead. |
Signature
fun createFromPlatformImage(w: Int, h: Int, mips: Int, platformImage: Long, samplerConfig: SamplerConfig = SamplerConfig()): SceneTexture Parameters Returns |
fromBitmapWithScaling
(
originalBitmap
, targetWidth
, targetHeight
, scale
, samplerConfig
)
|
Helper to create a SceneTexture from a bitmap with optional scaling.
Signature
fun fromBitmapWithScaling(originalBitmap: Bitmap, targetWidth: Int?, targetHeight: Int?, scale: Float?, samplerConfig: SamplerConfig): SceneTexture Parameters
originalBitmap:
Bitmap
targetWidth:
Int?
targetHeight:
Int?
scale:
Float?
samplerConfig:
SamplerConfig Returns |
fromResource
(
context
, resourceId
, targetWidth
, targetHeight
, scale
, samplerConfig
)
|
Creates a SceneTexture from an Android drawable resource, automatically converting it to a bitmap and optionally scaling it.
This is a convenience method that handles the common pattern of loading a drawable resource, decoding it to a bitmap, optionally scaling it, and creating a texture.
Size behavior:
Supported resource types:
Example usage:
// Use original bitmap size or intrinsic drawable size val texture = SceneTexture.fromResource(context, R.drawable.my_bitmap) // Scale to 50% of original size val halfSize = SceneTexture.fromResource(context, R.drawable.my_bitmap, scale = 0.5f) // Force specific dimensions (good for vector/shape drawables) val fixedSize = SceneTexture.fromResource(context, R.drawable.my_shape, 512, 512)
Signature
fun fromResource(context: Context, resourceId: Int, targetWidth: Int? = null, targetHeight: Int? = null, scale: Float? = null, samplerConfig: SamplerConfig = SamplerConfig()): SceneTexture Parameters
context:
Context
resourceId:
Int
targetWidth:
Int?
targetHeight:
Int?
scale:
Float?
Throws
IllegalArgumentException
|