Python API: Expose background drawing as argument for gpu.types.GPUOffScreen.draw_view3d() #105748

Merged
Jeroen Bakker merged 3 commits from Yuntoko/blender:expose-draw-background-pyapi into main 2023-04-17 09:28:12 +02:00
1 changed files with 11 additions and 4 deletions

View File

@ -290,7 +290,7 @@ static PyObject *pygpu_offscreen_texture_color_get(BPyGPUOffScreen *self, void *
PyDoc_STRVAR( PyDoc_STRVAR(
pygpu_offscreen_draw_view3d_doc, pygpu_offscreen_draw_view3d_doc,
".. method:: draw_view3d(scene, view_layer, view3d, region, view_matrix, projection_matrix, " ".. method:: draw_view3d(scene, view_layer, view3d, region, view_matrix, projection_matrix, "
"do_color_management=False)\n" "do_color_management=False, draw_background=True)\n"
"\n" "\n"
" Draw the 3d viewport in the offscreen object.\n" " Draw the 3d viewport in the offscreen object.\n"
"\n" "\n"
@ -307,7 +307,9 @@ PyDoc_STRVAR(
" :arg projection_matrix: Projection Matrix (e.g. ``camera.calc_matrix_camera(...)``).\n" " :arg projection_matrix: Projection Matrix (e.g. ``camera.calc_matrix_camera(...)``).\n"
" :type projection_matrix: :class:`mathutils.Matrix`\n" " :type projection_matrix: :class:`mathutils.Matrix`\n"
" :arg do_color_management: Color manage the output.\n" " :arg do_color_management: Color manage the output.\n"
" :type do_color_management: bool\n"); " :type do_color_management: bool\n"
" :arg draw_background: Draw background.\n"
" :type draw_background: bool\n");
static PyObject *pygpu_offscreen_draw_view3d(BPyGPUOffScreen *self, PyObject *args, PyObject *kwds) static PyObject *pygpu_offscreen_draw_view3d(BPyGPUOffScreen *self, PyObject *args, PyObject *kwds)
{ {
MatrixObject *py_mat_view, *py_mat_projection; MatrixObject *py_mat_view, *py_mat_projection;
@ -320,6 +322,7 @@ static PyObject *pygpu_offscreen_draw_view3d(BPyGPUOffScreen *self, PyObject *ar
ARegion *region; ARegion *region;
bool do_color_management = false; bool do_color_management = false;
bool draw_background = true;
BPY_GPU_OFFSCREEN_CHECK_OBJ(self); BPY_GPU_OFFSCREEN_CHECK_OBJ(self);
@ -331,6 +334,7 @@ static PyObject *pygpu_offscreen_draw_view3d(BPyGPUOffScreen *self, PyObject *ar
"view_matrix", "view_matrix",
"projection_matrix", "projection_matrix",
"do_color_management", "do_color_management",
"draw_background",
NULL, NULL,
}; };
static _PyArg_Parser _parser = { static _PyArg_Parser _parser = {
@ -342,6 +346,7 @@ static PyObject *pygpu_offscreen_draw_view3d(BPyGPUOffScreen *self, PyObject *ar
"O&" /* `projection_matrix` */ "O&" /* `projection_matrix` */
"|$" /* Optional keyword only arguments. */ "|$" /* Optional keyword only arguments. */
"O&" /* `do_color_management` */ "O&" /* `do_color_management` */
"O&" /* `draw_background` */
":draw_view3d", ":draw_view3d",
_keywords, _keywords,
0, 0,
@ -358,7 +363,9 @@ static PyObject *pygpu_offscreen_draw_view3d(BPyGPUOffScreen *self, PyObject *ar
Matrix_Parse4x4, Matrix_Parse4x4,
&py_mat_projection, &py_mat_projection,
PyC_ParseBool, PyC_ParseBool,
&do_color_management) || &do_color_management,
PyC_ParseBool,
&draw_background) ||
(!(scene = PyC_RNA_AsPointer(py_scene, "Scene")) || (!(scene = PyC_RNA_AsPointer(py_scene, "Scene")) ||
!(view_layer = PyC_RNA_AsPointer(py_view_layer, "ViewLayer")) || !(view_layer = PyC_RNA_AsPointer(py_view_layer, "ViewLayer")) ||
!(v3d = PyC_RNA_AsPointer(py_view3d, "SpaceView3D")) || !(v3d = PyC_RNA_AsPointer(py_view3d, "SpaceView3D")) ||
@ -397,7 +404,7 @@ static PyObject *pygpu_offscreen_draw_view3d(BPyGPUOffScreen *self, PyObject *ar
(const float(*)[4])py_mat_view->matrix, (const float(*)[4])py_mat_view->matrix,
(const float(*)[4])py_mat_projection->matrix, (const float(*)[4])py_mat_projection->matrix,
true, true,
true, draw_background,
"", "",
do_color_management, do_color_management,
true, true,