Exemplo n.º 1
0
static PyObject *bpygpu_offscreen_free(BPyGPUOffScreen *self)
{
  BPY_GPU_OFFSCREEN_CHECK_OBJ(self);

  GPU_offscreen_free(self->ofs);
  self->ofs = NULL;
  Py_RETURN_NONE;
}
Exemplo n.º 2
0
static PyObject *pygpu_offscreen_draw_view3d(BPy_GPUOffScreen *self, PyObject *args, PyObject *kwds)
{
    static const char *kwlist[] = {"scene", "view3d", "region", "projection_matrix", "modelview_matrix", NULL};

    MatrixObject *py_mat_modelview, *py_mat_projection;
    PyObject *py_scene, *py_region, *py_view3d;

    Scene *scene;
    View3D *v3d;
    ARegion *ar;
    GPUFX *fx;
    GPUFXSettings fx_settings;
    void *rv3d_mats;

    BPY_GPU_OFFSCREEN_CHECK_OBJ(self);

    if (!PyArg_ParseTupleAndKeywords(
                args, kwds, "OOOO&O&:draw_view3d", (char **)(kwlist),
                &py_scene, &py_view3d, &py_region,
                pygpu_offscreen_check_matrix, &py_mat_projection,
                pygpu_offscreen_check_matrix, &py_mat_modelview) ||
            (!(scene    = PyC_RNA_AsPointer(py_scene, "Scene")) ||
             !(v3d      = PyC_RNA_AsPointer(py_view3d, "SpaceView3D")) ||
             !(ar       = PyC_RNA_AsPointer(py_region, "Region"))))
    {
        return NULL;
    }

    fx = GPU_fx_compositor_create();

    fx_settings = v3d->fx_settings;  /* full copy */

    ED_view3d_draw_offscreen_init(scene, v3d);

    rv3d_mats = ED_view3d_mats_rv3d_backup(ar->regiondata);

    GPU_offscreen_bind(self->ofs, true); /* bind */

    ED_view3d_draw_offscreen(
        scene, v3d, ar, GPU_offscreen_width(self->ofs), GPU_offscreen_height(self->ofs),
        (float(*)[4])py_mat_modelview->matrix, (float(*)[4])py_mat_projection->matrix,
        false, true, true, "",
        fx, &fx_settings,
        self->ofs);

    GPU_fx_compositor_destroy(fx);
    GPU_offscreen_unbind(self->ofs, true); /* unbind */

    ED_view3d_mats_rv3d_restore(ar->regiondata, rv3d_mats);
    MEM_freeN(rv3d_mats);

    Py_RETURN_NONE;
}
Exemplo n.º 3
0
static PyObject *bpygpu_offscreen_unbind(BPyGPUOffScreen *self, PyObject *args, PyObject *kwds)
{
  bool restore = true;

  BPY_GPU_OFFSCREEN_CHECK_OBJ(self);

  static const char *_keywords[] = {"restore", NULL};
  static _PyArg_Parser _parser = {"|O&:unbind", _keywords, 0};
  if (!_PyArg_ParseTupleAndKeywordsFast(args, kwds, &_parser, PyC_ParseBool, &restore)) {
    return NULL;
  }

  GPU_offscreen_unbind(self->ofs, restore);
  Py_RETURN_NONE;
}
Exemplo n.º 4
0
static PyObject *pygpu_offscreen_unbind(BPy_GPUOffScreen *self, PyObject *args, PyObject *kwds)
{
    static const char *kwlist[] = {"restore", NULL};
    bool restore = true;

    BPY_GPU_OFFSCREEN_CHECK_OBJ(self);

    if (!PyArg_ParseTupleAndKeywords(
                args, kwds, "|O&:unbind", (char **)(kwlist),
                PyC_ParseBool, &restore))
    {
        return NULL;
    }

    GPU_offscreen_unbind(self->ofs, restore);
    Py_RETURN_NONE;
}
Exemplo n.º 5
0
static PyObject *bpygpu_offscreen_bind(BPyGPUOffScreen *self, PyObject *args, PyObject *kwds)
{
  BPY_GPU_OFFSCREEN_CHECK_OBJ(self);
  bool save = true;

  static const char *_keywords[] = {"save", NULL};
  static _PyArg_Parser _parser = {"|O&:bind", _keywords, 0};
  if (!_PyArg_ParseTupleAndKeywordsFast(args, kwds, &_parser, PyC_ParseBool, &save)) {
    return NULL;
  }

  GPU_offscreen_bind(self->ofs, save);

  self->is_saved = save;
  Py_INCREF(self);

  return (PyObject *)self;
}
Exemplo n.º 6
0
static PyObject *bpygpu_offscreen_draw_view3d(BPyGPUOffScreen *self,
                                              PyObject *args,
                                              PyObject *kwds)
{
  MatrixObject *py_mat_view, *py_mat_projection;
  PyObject *py_scene, *py_view_layer, *py_region, *py_view3d;

  struct Depsgraph *depsgraph;
  struct Scene *scene;
  struct ViewLayer *view_layer;
  View3D *v3d;
  ARegion *ar;
  struct RV3DMatrixStore *rv3d_mats;

  BPY_GPU_OFFSCREEN_CHECK_OBJ(self);

  static const char *_keywords[] = {
      "scene", "view_layer", "view3d", "region", "view_matrix", "projection_matrix", NULL};

  static _PyArg_Parser _parser = {"OOOOO&O&:draw_view3d", _keywords, 0};
  if (!_PyArg_ParseTupleAndKeywordsFast(args,
                                        kwds,
                                        &_parser,
                                        &py_scene,
                                        &py_view_layer,
                                        &py_view3d,
                                        &py_region,
                                        Matrix_Parse4x4,
                                        &py_mat_view,
                                        Matrix_Parse4x4,
                                        &py_mat_projection) ||
      (!(scene = PyC_RNA_AsPointer(py_scene, "Scene")) ||
       !(view_layer = PyC_RNA_AsPointer(py_view_layer, "ViewLayer")) ||
       !(v3d = PyC_RNA_AsPointer(py_view3d, "SpaceView3D")) ||
       !(ar = PyC_RNA_AsPointer(py_region, "Region")))) {
    return NULL;
  }

  BLI_assert(BKE_id_is_in_global_main(&scene->id));

  depsgraph = BKE_scene_get_depsgraph(scene, view_layer, true);

  rv3d_mats = ED_view3d_mats_rv3d_backup(ar->regiondata);

  GPU_offscreen_bind(self->ofs, true);

  ED_view3d_draw_offscreen(depsgraph,
                           scene,
                           v3d->shading.type,
                           v3d,
                           ar,
                           GPU_offscreen_width(self->ofs),
                           GPU_offscreen_height(self->ofs),
                           (float(*)[4])py_mat_view->matrix,
                           (float(*)[4])py_mat_projection->matrix,
                           false,
                           true,
                           "",
                           true,
                           self->ofs,
                           NULL);

  GPU_offscreen_unbind(self->ofs, true);

  ED_view3d_mats_rv3d_restore(ar->regiondata, rv3d_mats);
  MEM_freeN(rv3d_mats);

  Py_RETURN_NONE;
}
Exemplo n.º 7
0
static PyObject *bpygpu_offscreen_color_texture_get(BPyGPUOffScreen *self, void *UNUSED(type))
{
  BPY_GPU_OFFSCREEN_CHECK_OBJ(self);
  GPUTexture *texture = GPU_offscreen_color_texture(self->ofs);
  return PyLong_FromLong(GPU_texture_opengl_bindcode(texture));
}
Exemplo n.º 8
0
static PyObject *bpygpu_offscreen_height_get(BPyGPUOffScreen *self, void *UNUSED(type))
{
  BPY_GPU_OFFSCREEN_CHECK_OBJ(self);
  return PyLong_FromLong(GPU_offscreen_height(self->ofs));
}
Exemplo n.º 9
0
static PyObject *pygpu_offscreen_color_texture_get(BPy_GPUOffScreen *self, void *UNUSED(type))
{
    BPY_GPU_OFFSCREEN_CHECK_OBJ(self);
    return PyLong_FromLong(GPU_offscreen_color_texture(self->ofs));
}