# engineCreateTexture (Client)

> Creates a texture from an image file in the resource or from image bytes in memory. The texture exists on this client only.

- **Platform**: MY Multiplayer (MYMP)
- **Kind**: Lua Function
- **Side**: Client
- **Category**: Textures
- **URL**: https://wiki.mymp.gg/en/engineCreateTexture

## Syntax

```lua
texture engineCreateTexture(string source [, string format = "unknown", bool mipmaps = true, string edge = "wrap"])
```

## Parameters

| Name | Type | Description |
| --- | --- | --- |
| `source` | `string` | A path to an image file in the resource, or a string holding the image file's bytes. |
| `format` | `string` | How the texture is kept: `unknown`, `argb`, `xrgb`, `rgb`, `dxt1`, `dxt2`, `dxt3`, `dxt4` or `dxt5`. Depth formats are refused. *(default: `"unknown"`)* |
| `mipmaps` | `bool` | Build mipmaps for the texture. *(default: `true`)* |
| `edge` | `string` | How it is sampled past its edges: `wrap`, `mirror`, `clamp`, `border` or `mirror-once`. *(default: `"wrap"`)* |

## Returns

The new `texture` element. Raises an error if the arguments are wrong or the texture could not be made.

The image is decoded in the background. `onClientAssetLoad` fires on the texture once it is ready, with `false` if it could not be decoded.

A blank texture is made with `engineCreateTexture(width, height [, format, edge, type])`: both sides from 1 to 16384 pixels, and `type` only `"2d"`.

## Example

```lua
local logo = engineCreateTexture("images/logo.png", "dxt5")

addEventHandler("onClientRender", root, function()
    dxDrawImage(20, 20, 128, 128, logo)
end)
```

### Coming from MTA

This is MTA's `dxCreateTexture` under another name. `3d` and `cube` textures cannot be made.

## See also

- [dxDrawImage (Client)](https://wiki.mymp.gg/en/dxDrawImage.md): Draws an image on the screen for one frame.
- [dxSetTexturePixels (Client)](https://wiki.mymp.gg/en/dxSetTexturePixels.md): Writes pixels into a texture made by a script or into a render target.
- [engineSetTxdTexture (Client)](https://wiki.mymp.gg/en/engineSetTxdTexture.md): Puts an image in a txd under a texture name, replacing the texture of that name or adding a new one. Everything that reads the txd follows: models, peds, landscapes, roads, particles, water and sky.
- [onClientAssetLoad (Client)](https://wiki.mymp.gg/en/onClientAssetLoad.md): Fired once when an asset a script started loading in the background is ready, or has failed.
