From a1a7c5e718850bc27031ab1caa898460c382f935 Mon Sep 17 00:00:00 2001 From: Roberto De Ioris Date: Sun, 11 Jun 2017 11:07:49 +0200 Subject: [PATCH] added create_transient_texture() --- .../UnrealEnginePython/Private/UEPyModule.cpp | 1 + .../Private/UEPyTexture.cpp | 19 +++++++++++++++++++ .../UnrealEnginePython/Private/UEPyTexture.h | 4 +++- 3 files changed, 23 insertions(+), 1 deletion(-) diff --git a/Source/UnrealEnginePython/Private/UEPyModule.cpp b/Source/UnrealEnginePython/Private/UEPyModule.cpp index 1c85b36c6..5ced64eb3 100644 --- a/Source/UnrealEnginePython/Private/UEPyModule.cpp +++ b/Source/UnrealEnginePython/Private/UEPyModule.cpp @@ -152,6 +152,7 @@ static PyMethodDef unreal_engine_methods[] = { { "compress_image_array", py_unreal_engine_compress_image_array, METH_VARARGS, "" }, { "create_checkerboard_texture", py_unreal_engine_create_checkerboard_texture, METH_VARARGS, "" }, + { "create_transient_texture", py_unreal_engine_create_transient_texture, METH_VARARGS, "" }, // slate diff --git a/Source/UnrealEnginePython/Private/UEPyTexture.cpp b/Source/UnrealEnginePython/Private/UEPyTexture.cpp index 2a8447bac..dbe7a944b 100644 --- a/Source/UnrealEnginePython/Private/UEPyTexture.cpp +++ b/Source/UnrealEnginePython/Private/UEPyTexture.cpp @@ -143,3 +143,22 @@ PyObject *py_unreal_engine_create_checkerboard_texture(PyObject * self, PyObject return (PyObject *)ret; } +PyObject *py_unreal_engine_create_transient_texture(PyObject * self, PyObject * args) { + int width; + int height; + int format = PF_B8G8R8A8; + if (!PyArg_ParseTuple(args, "ii|i:create_transient_texture", &width, &height, &format)) { + return NULL; + } + + + UTexture2D *texture = UTexture2D::CreateTransient(width, height, (EPixelFormat)format); + texture->UpdateResource(); + + ue_PyUObject *ret = ue_get_python_wrapper(texture); + if (!ret) + return PyErr_Format(PyExc_Exception, "uobject is in invalid state"); + Py_INCREF(ret); + return (PyObject *)ret; +} + diff --git a/Source/UnrealEnginePython/Private/UEPyTexture.h b/Source/UnrealEnginePython/Private/UEPyTexture.h index b5ee0b395..315930409 100644 --- a/Source/UnrealEnginePython/Private/UEPyTexture.h +++ b/Source/UnrealEnginePython/Private/UEPyTexture.h @@ -10,4 +10,6 @@ PyObject *py_ue_texture_get_width(ue_PyUObject *, PyObject *); PyObject *py_ue_texture_get_height(ue_PyUObject *, PyObject *); PyObject *py_unreal_engine_compress_image_array(PyObject *, PyObject *); -PyObject *py_unreal_engine_create_checkerboard_texture(PyObject *, PyObject *); \ No newline at end of file +PyObject *py_unreal_engine_create_checkerboard_texture(PyObject *, PyObject *); + +PyObject *py_unreal_engine_create_transient_texture(PyObject *, PyObject *); \ No newline at end of file