> For the complete documentation index, see [llms.txt](https://lua2.fatality.win/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://lua2.fatality.win/api/instances/draw/managed.md).

# Managed

This type represents a managed object. You cannot create an instance of this type directly.

Every object, that inherits from this type, must be `Create`d before use. The rendering system will only create them automatically, if you happen to lose a device object (e.g. minimize the game window, and then restore it) and only if you add your objects to manage table in [`draw`](https://lua.fatality.win/draw.html).

### obj﻿ <a href="#obj" id="obj"></a>

[<kbd><mark style="background-color:purple;">**Field**<mark style="background-color:purple;"></kbd>](#user-content-fn-1)[^1][<kbd><mark style="background-color:orange;">**Read only**<mark style="background-color:orange;"></kbd>](#user-content-fn-2)[^2]

Type: [`Ptr`](/api/types/ptr.md)

Pointer to a GPU object. If this object is not created, this field will be `nil`. You can use the value of this field to pass it to [`Command`](/api/instances/draw/layer/command.md) directly for example, or if you (for whatever reason we don't recommend you doing) want to have a direct control over the pointer - cast it to FFI's `cdata`.

***

## Create﻿ <a href="#create" id="create"></a>

[<kbd><mark style="background-color:purple;">**Method**<mark style="background-color:purple;"></kbd>](#user-content-fn-3)[^3]

Creates a managed object in GPU memory.

{% hint style="success" %}
You should `Create()` an object only once. Invoking this method after the object was created will be meaningless.
{% endhint %}

**Arguments**

None.

**Returns**

Nothing.

**Example**

```lua
tex:Create();
```

***

## Destroy﻿ <a href="#destroy" id="destroy"></a>

[<kbd><mark style="background-color:purple;">**Method**<mark style="background-color:purple;"></kbd>](#user-content-fn-3)[^3]

Destroys a managed object in GPU memory.

{% hint style="danger" %}
Never destroy a GPU object if it is being used in rendering (for example, when you have pushed some shape that uses a texture, and then destroyed that texture). This will lead to undefined behavior, and most likely, \*\***crash the game** \*\*.
{% endhint %}

**Arguments**

None.

**Returns**

Nothing.

**Example**

```lua
font:Destroy();
```

[^1]: This field is a regular field that must be accessed using a dot (.)

[^2]: This field is a read only field, and you cannot change its value. This does not apply to child fields, if any.

[^3]: This field is a method and must be invoked using a colon (:)


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://lua2.fatality.win/api/instances/draw/managed.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
