Python GPU: Add new methods to port the code templates in the manual
This commit adds a new API tha allow to replace the bgl API in the exemples on: https://docs.blender.org/api/current/gpu.html **Overview (New API):** ``` gpu.state: active_framebuffer_get GPUFramebuffer: read_color GPUOffscreen: texture_color ``` Reviewed By: brecht Differential Revision: https://developer.blender.org/D11031
This commit is contained in:
@@ -53,6 +53,8 @@
|
||||
#include "../generic/py_capi_utils.h"
|
||||
|
||||
#include "gpu_py.h"
|
||||
#include "gpu_py_texture.h"
|
||||
|
||||
#include "gpu_py_offscreen.h" /* own include */
|
||||
|
||||
/* Define the free method to avoid breakage. */
|
||||
@@ -264,6 +266,18 @@ static PyObject *pygpu_offscreen_color_texture_get(BPyGPUOffScreen *self, void *
|
||||
return PyLong_FromLong(GPU_texture_opengl_bindcode(texture));
|
||||
}
|
||||
|
||||
PyDoc_STRVAR(pygpu_offscreen_texture_color_doc,
|
||||
"The color texture attached.\n"
|
||||
"\n"
|
||||
":type: :class:`gpu.types.GPUTexture`");
|
||||
static PyObject *pygpu_offscreen_texture_color_get(BPyGPUOffScreen *self, void *UNUSED(type))
|
||||
{
|
||||
BPY_GPU_OFFSCREEN_CHECK_OBJ(self);
|
||||
GPUTexture *texture = GPU_offscreen_color_texture(self->ofs);
|
||||
GPU_texture_ref(texture);
|
||||
return BPyGPUTexture_CreatePyObject(texture);
|
||||
}
|
||||
|
||||
PyDoc_STRVAR(
|
||||
pygpu_offscreen_draw_view3d_doc,
|
||||
".. method:: draw_view3d(scene, view_layer, view3d, region, view_matrix, projection_matrix)\n"
|
||||
@@ -385,6 +399,11 @@ static PyGetSetDef pygpu_offscreen__tp_getseters[] = {
|
||||
(setter)NULL,
|
||||
pygpu_offscreen_color_texture_doc,
|
||||
NULL},
|
||||
{"texture_color",
|
||||
(getter)pygpu_offscreen_texture_color_get,
|
||||
(setter)NULL,
|
||||
pygpu_offscreen_texture_color_doc,
|
||||
NULL},
|
||||
{"width", (getter)pygpu_offscreen_width_get, (setter)NULL, pygpu_offscreen_width_doc, NULL},
|
||||
{"height", (getter)pygpu_offscreen_height_get, (setter)NULL, pygpu_offscreen_height_doc, NULL},
|
||||
{NULL, NULL, NULL, NULL, NULL} /* Sentinel */
|
||||
|
Reference in New Issue
Block a user