Blender V5.3
gpu_py_framebuffer.cc File Reference
#include <Python.h>
#include "GPU_context.hh"
#include "GPU_framebuffer.hh"
#include "GPU_init_exit.hh"
#include "../generic/py_capi_utils.hh"
#include "../generic/python_compat.hh"
#include "../generic/python_utildefines.hh"
#include "../mathutils/mathutils.hh"
#include "gpu_py.hh"
#include "gpu_py_buffer.hh"
#include "gpu_py_framebuffer.hh"
#include "gpu_py_texture.hh"

Go to the source code of this file.

Classes

struct  blender::PyFrameBufferStackContext

Namespaces

namespace  blender
 BMesh Iterators.

Macros

#define BPYGPU_FB_MAX_COLOR_ATTACHMENT   6

Functions

Public API
PyObject * blender::BPyGPUFrameBuffer_CreatePyObject (gpu::FrameBuffer *fb, bool shared_reference)

gpu::FrameBuffer Common Utilities

#define PYGPU_FRAMEBUFFER_CHECK_OBJ(bpygpu)
#define GPU_PY_FRAMEBUFFER_STACK_LEN   16
static int blender::pygpu_framebuffer_valid_check (BPyGPUFrameBuffer *bpygpu_fb)
static void blender::pygpu_framebuffer_free_if_possible (gpu::FrameBuffer *fb)
static void blender::pygpu_framebuffer_free_safe (BPyGPUFrameBuffer *self)
static bool blender::pygpu_framebuffer_stack_push_and_bind_or_error (gpu::FrameBuffer *fb)
static bool blender::pygpu_framebuffer_stack_pop_and_restore_or_error (gpu::FrameBuffer *fb)

Stack (Context Manager)

Safer alternative to ensure balanced push/pop calls.

static PyMethodDef blender::pygpu_framebuffer_stack_context__tp_methods []
static PyTypeObject blender::FramebufferStackContext_Type
static void blender::pygpu_framebuffer_stack_context__tp_dealloc (PyFrameBufferStackContext *self)
static PyObject * blender::pygpu_framebuffer_stack_context_enter (PyFrameBufferStackContext *self)
static PyObject * blender::pygpu_framebuffer_stack_context_exit (PyFrameBufferStackContext *self, PyObject *)
 blender::PyDoc_STRVAR (pygpu_framebuffer_bind_doc, ".. method:: bind()\n" "\n" " Context manager to ensure balanced bind calls, even in the case of an error.\n")
static PyObject * blender::pygpu_framebuffer_bind (BPyGPUFrameBuffer *self)

GPUFramebuffer Type

static PyGetSetDef blender::pygpu_framebuffer__tp_getseters []
static PyMethodDef blender::pygpu_framebuffer__tp_methods []
PyTypeObject blender::BPyGPUFrameBuffer_Type
static bool blender::pygpu_framebuffer_new_parse_arg (PyObject *o, GPUAttachment *r_attach)
static PyObject * blender::pygpu_framebuffer__tp_new (PyTypeObject *, PyObject *args, PyObject *kwds)
 blender::PyDoc_STRVAR (pygpu_framebuffer_is_bound_doc, "Checks if this is the active frame-buffer in the context.\n" "\n" ":type: bool\n")
static PyObject * blender::pygpu_framebuffer_is_bound (BPyGPUFrameBuffer *self, void *)
 blender::PyDoc_STRVAR (pygpu_framebuffer_clear_doc, ".. method:: clear(*, color=None, depth=None, stencil=None)\n" "\n" " Fill color, depth and stencil textures with specific value.\n" " Common values: color=(0.0, 0.0, 0.0, 1.0), depth=1.0, stencil=0.\n" "\n" " :param color: Sequence of 3 or 4 floats representing ``(r, g, b, a)``.\n" " :type color: Sequence[float] | None\n" " :param depth: depth value.\n" " :type depth: float | None\n" " :param stencil: stencil value.\n" " :type stencil: int | None\n")
static PyObject * blender::pygpu_framebuffer_clear (BPyGPUFrameBuffer *self, PyObject *args, PyObject *kwds)
 blender::PyDoc_STRVAR (pygpu_framebuffer_viewport_set_doc, ".. method:: viewport_set(x, y, xsize, ysize)\n" "\n" " Set the viewport for this framebuffer object.\n" " Note: The viewport state is not saved upon framebuffer rebind.\n" "\n" " :param x: Lower left corner x of the viewport rectangle, in pixels.\n" " :type x: int\n" " :param y: Lower left corner y of the viewport rectangle, in pixels.\n" " :type y: int\n" " :param xsize: Width of the viewport.\n" " :type xsize: int\n" " :param ysize: Height of the viewport.\n" " :type ysize: int\n")
static PyObject * blender::pygpu_framebuffer_viewport_set (BPyGPUFrameBuffer *self, PyObject *args)
 blender::PyDoc_STRVAR (pygpu_framebuffer_viewport_get_doc, ".. method:: viewport_get()\n" "\n" " Returns position and dimension to current viewport.\n" "\n" " :return: The viewport as ``(x, y, width, height)``.\n" " :rtype: tuple[int, int, int, int]\n")
static PyObject * blender::pygpu_framebuffer_viewport_get (BPyGPUFrameBuffer *self)
 blender::PyDoc_STRVAR (pygpu_framebuffer_read_color_doc, ".. method:: read_color(x, y, xsize, ysize, channels, slot, format, *, data=None)\n" "\n" " Read a block of pixels from the frame buffer.\n" "\n" " :param x: Lower left corner x of a rectangular block of pixels.\n" " :type x: int\n" " :param y: Lower left corner y of a rectangular block of pixels.\n" " :type y: int\n" " :param xsize: Width of the pixel rectangle.\n" " :type xsize: int\n" " :param ysize: Height of the pixel rectangle.\n" " :type ysize: int\n" " :param channels: Number of components to read.\n" " :type channels: int\n" " :param slot: The framebuffer slot to read data from.\n" " :type slot: int\n" " :param format: The format that describes the content of a single channel.\n" " ``UINT_24_8`` is deprecated, use ``FLOAT`` instead.\n" " :type format: " PYDOC_DATAFORMAT_LITERAL "\n" " :param data: Optional Buffer object to fill with the pixels values.\n" " :type data: :class:`gpu.types.Buffer` | None\n" " :return: The Buffer with the read pixels.\n" " :rtype: :class:`gpu.types.Buffer`\n")
static PyObject * blender::pygpu_framebuffer_read_color (BPyGPUFrameBuffer *self, PyObject *args, PyObject *kwds)
 blender::PyDoc_STRVAR (pygpu_framebuffer_read_depth_doc, ".. method:: read_depth(x, y, xsize, ysize, *, data=None)\n" "\n" " Read a pixel depth block from the frame buffer.\n" "\n" " :param x: Lower left corner x of a rectangular block of pixels.\n" " :type x: int\n" " :param y: Lower left corner y of a rectangular block of pixels.\n" " :type y: int\n" " :param xsize: Width of the pixel rectangle.\n" " :type xsize: int\n" " :param ysize: Height of the pixel rectangle.\n" " :type ysize: int\n" " :param data: Optional Buffer object to fill with the pixels values.\n" " :type data: :class:`gpu.types.Buffer` | None\n" " :return: The Buffer with the read pixels.\n" " :rtype: :class:`gpu.types.Buffer`\n")
static PyObject * blender::pygpu_framebuffer_read_depth (BPyGPUFrameBuffer *self, PyObject *args, PyObject *kwds)
static void blender::BPyGPUFrameBuffer__tp_dealloc (BPyGPUFrameBuffer *self)
 blender::PyDoc_STRVAR (pygpu_framebuffer__tp_doc, ".. class:: GPUFrameBuffer\n" "\n" " This object gives access to framebuffer functionalities.\n" " When a 'layer' is specified in a argument, a single layer of a 3D or array " "texture is attached to the frame-buffer.\n" " For cube map textures, layer is translated into a cube map face.\n" "\n" " .. method:: __init__(*, depth_slot=None, color_slots=None)\n" "\n" " :param depth_slot: GPUTexture to attach or a ``dict`` containing keywords: " "'texture', 'layer' and 'mip'.\n" " :type depth_slot: :class:`gpu.types.GPUTexture` | dict[str, int | " ":class:`gpu.types.GPUTexture`] | None\n" " :param color_slots: Tuple where each item can be a GPUTexture or a ``dict`` " "containing keywords: 'texture', 'layer' and 'mip'.\n" " :type color_slots: :class:`gpu.types.GPUTexture` | " "dict[str, int | :class:`gpu.types.GPUTexture`] | " "Sequence[:class:`gpu.types.GPUTexture` | dict[str, int | " ":class:`gpu.types.GPUTexture`]] | " "None\n")

Detailed Description

This file defines the framebuffer functionalities of the 'gpu' module used for off-screen OpenGL rendering.

  • Use bpygpu_ for local API.
  • Use BPyGPU for public API.

Definition in file gpu_py_framebuffer.cc.

Macro Definition Documentation

◆ BPYGPU_FB_MAX_COLOR_ATTACHMENT

#define BPYGPU_FB_MAX_COLOR_ATTACHMENT   6

◆ GPU_PY_FRAMEBUFFER_STACK_LEN

#define GPU_PY_FRAMEBUFFER_STACK_LEN   16

◆ PYGPU_FRAMEBUFFER_CHECK_OBJ

#define PYGPU_FRAMEBUFFER_CHECK_OBJ ( bpygpu)