Skip to content

Commit a1a7c5e

Browse files
author
Roberto De Ioris
committed
added create_transient_texture()
1 parent e15b946 commit a1a7c5e

File tree

3 files changed

+23
-1
lines changed

3 files changed

+23
-1
lines changed

Source/UnrealEnginePython/Private/UEPyModule.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,7 @@ static PyMethodDef unreal_engine_methods[] = {
152152

153153
{ "compress_image_array", py_unreal_engine_compress_image_array, METH_VARARGS, "" },
154154
{ "create_checkerboard_texture", py_unreal_engine_create_checkerboard_texture, METH_VARARGS, "" },
155+
{ "create_transient_texture", py_unreal_engine_create_transient_texture, METH_VARARGS, "" },
155156

156157
// slate
157158

Source/UnrealEnginePython/Private/UEPyTexture.cpp

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,3 +143,22 @@ PyObject *py_unreal_engine_create_checkerboard_texture(PyObject * self, PyObject
143143
return (PyObject *)ret;
144144
}
145145

146+
PyObject *py_unreal_engine_create_transient_texture(PyObject * self, PyObject * args) {
147+
int width;
148+
int height;
149+
int format = PF_B8G8R8A8;
150+
if (!PyArg_ParseTuple(args, "ii|i:create_transient_texture", &width, &height, &format)) {
151+
return NULL;
152+
}
153+
154+
155+
UTexture2D *texture = UTexture2D::CreateTransient(width, height, (EPixelFormat)format);
156+
texture->UpdateResource();
157+
158+
ue_PyUObject *ret = ue_get_python_wrapper(texture);
159+
if (!ret)
160+
return PyErr_Format(PyExc_Exception, "uobject is in invalid state");
161+
Py_INCREF(ret);
162+
return (PyObject *)ret;
163+
}
164+

Source/UnrealEnginePython/Private/UEPyTexture.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,6 @@ PyObject *py_ue_texture_get_width(ue_PyUObject *, PyObject *);
1010
PyObject *py_ue_texture_get_height(ue_PyUObject *, PyObject *);
1111

1212
PyObject *py_unreal_engine_compress_image_array(PyObject *, PyObject *);
13-
PyObject *py_unreal_engine_create_checkerboard_texture(PyObject *, PyObject *);
13+
PyObject *py_unreal_engine_create_checkerboard_texture(PyObject *, PyObject *);
14+
15+
PyObject *py_unreal_engine_create_transient_texture(PyObject *, PyObject *);

0 commit comments

Comments
 (0)