MCPcopy Create free account
hub / github.com/carbonengine/trinity / PyInit

Function PyInit

trinity/Resources/TriTextureRes_Blue.cpp:17–73  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

15
16#if BLUE_WITH_PYTHON
17static PyObject* PyInit( PyObject* self, PyObject* args )
18{
19 TriTextureRes* pThis = BluePythonCast<TriTextureRes*>( self );
20
21
22 if( PyTuple_Size( args ) >= 4 )
23 {
24 // Option 1: constructor that makes a new, undefined-contents TriTextureRes of a given
25 // size, presumably to use locking or UpdateSubResource later on.
26 unsigned width = 0, height = 0, mipCount = 0, format = 0, usage = USAGE_CPU_READ;
27
28 if( !PyArg_ParseTuple( args, "iiii|i", &width, &height, &mipCount, &format, &usage ) )
29 {
30 PyErr_SetString( PyExc_RuntimeError, "Excpected width, height, mipCount, format, optional usage" );
31 return nullptr;
32 }
33
34 if( width && height && mipCount && format )
35 {
36 USE_MAIN_THREAD_RENDER_CONTEXT();
37 pThis->Create( width,
38 height,
39 mipCount,
40 static_cast<PixelFormat>( format ),
41 static_cast<BufferUsageFlags>( usage ),
42 renderContext );
43 }
44 Py_RETURN_NONE;
45 }
46
47 if( PyTuple_Size( args ) == 1 )
48 {
49 // Option 2: a live view of a (readable) renderTarget
50 PyObject* pySurface = NULL;
51
52 if( !PyArg_ParseTuple( args, "|O", &pySurface ) )
53 {
54 PyErr_SetString( PyExc_RuntimeError, "Excpected Tr2RenderTarget" );
55 return nullptr;
56 }
57
58 if( pySurface )
59 {
60 Tr2RenderTarget* renderTarget = nullptr;
61 if( BluePythonCast<Tr2RenderTarget*>( pySurface ) && BlueExtractArgument( pySurface, renderTarget, 0 ) )
62 {
63 pThis->SetTextureFromRT( renderTarget );
64 Py_RETURN_NONE;
65 }
66 }
67 Py_RETURN_NONE;
68 }
69
70 // Option 3: empty constructor, do nothing.
71
72 Py_RETURN_NONE;
73}
74

Callers

nothing calls this directly

Calls 2

SetTextureFromRTMethod · 0.80
CreateMethod · 0.45

Tested by

no test coverage detected