Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'doc/python_api')
-rw-r--r--doc/python_api/examples/gpu.6.py33
-rw-r--r--doc/python_api/sphinx_doc_gen.py35
2 files changed, 40 insertions, 28 deletions
diff --git a/doc/python_api/examples/gpu.6.py b/doc/python_api/examples/gpu.6.py
index be164a03028..5576b2d0bfe 100644
--- a/doc/python_api/examples/gpu.6.py
+++ b/doc/python_api/examples/gpu.6.py
@@ -29,3 +29,36 @@ def draw():
bpy.types.SpaceView3D.draw_handler_add(draw, (), 'WINDOW', 'POST_PIXEL')
+
+"""
+3D Image
+--------
+
+Similar to the 2D Image shader, but works with 3D positions for the image vertices.
+To use this example you have to provide an image that should be displayed.
+"""
+import bpy
+import gpu
+from gpu_extras.batch import batch_for_shader
+
+IMAGE_NAME = "Untitled"
+image = bpy.data.images[IMAGE_NAME]
+texture = gpu.texture.from_image(image)
+
+shader = gpu.shader.from_builtin('3D_IMAGE')
+batch = batch_for_shader(
+ shader, 'TRIS',
+ {
+ "pos": ((0, 0, 0), (0, 1, 1), (1, 1, 1), (1, 1, 1), (1, 0, 0), (0, 0, 0)),
+ "texCoord": ((0, 0), (0, 1), (1, 1), (1, 1), (1, 0), (0, 0)),
+ },
+)
+
+
+def draw():
+ shader.bind()
+ shader.uniform_sampler("image", texture)
+ batch.draw(shader)
+
+
+bpy.types.SpaceView3D.draw_handler_add(draw, (), 'WINDOW', 'POST_VIEW')
diff --git a/doc/python_api/sphinx_doc_gen.py b/doc/python_api/sphinx_doc_gen.py
index d87d8b71ce5..0a20bd83c22 100644
--- a/doc/python_api/sphinx_doc_gen.py
+++ b/doc/python_api/sphinx_doc_gen.py
@@ -1200,34 +1200,17 @@ def pycontext2sphinx(basepath):
del write_contex_cls
# end
- # nasty, get strings directly from Blender because there is no other way to get it
- import ctypes
-
- context_strings = (
- "screen_context_dir",
- "view3d_context_dir",
- "buttons_context_dir",
- "image_context_dir",
- "node_context_dir",
- "text_context_dir",
- "clip_context_dir",
- "sequencer_context_dir",
- "file_context_dir",
- )
+ # Internal API call only intended to be used to extract context members.
+ from _bpy import context_members
+ context_member_map = context_members()
+ del context_members
# Track unique for `context_strings` to validate `context_type_map`.
unique_context_strings = set()
- blend_cdll = ctypes.CDLL("")
- for ctx_str in context_strings:
+ for ctx_str, ctx_members in sorted(context_member_map.items()):
subsection = "%s Context" % ctx_str.split("_")[0].title()
fw("\n%s\n%s\n\n" % (subsection, (len(subsection) * '-')))
-
- attr = ctypes.addressof(getattr(blend_cdll, ctx_str))
- c_char_p_p = ctypes.POINTER(ctypes.c_char_p)
- char_array = c_char_p_p.from_address(attr)
- i = 0
- while char_array[i] is not None:
- member = ctypes.string_at(char_array[i]).decode(encoding="ascii")
+ for member in ctx_members:
unique_all_len = len(unique)
unique.add(member)
member_visited = unique_all_len == len(unique)
@@ -1247,7 +1230,6 @@ def pycontext2sphinx(basepath):
"Error: context key %r not found in context_type_map; update %s" %
(member, __file__)) from None
fw(" :type: %s :class:`bpy.types.%s`\n\n" % ("sequence of " if is_seq else "", member_type))
- i += 1
# generate typemap...
# for member in sorted(unique_context_strings):
@@ -2173,10 +2155,7 @@ def rna2sphinx(basepath):
# context
if "bpy.context" not in EXCLUDE_MODULES:
- # one of a kind, context doc (uses ctypes to extract info!)
- # doesn't work on mac and windows
- if PLATFORM not in {"darwin", "windows"}:
- pycontext2sphinx(basepath)
+ pycontext2sphinx(basepath)
# internal modules
write_rst_bpy(basepath) # bpy, disabled by default