-
Notifications
You must be signed in to change notification settings - Fork 940
Expand file tree
/
Copy pathfast_render.py
More file actions
42 lines (37 loc) · 1.37 KB
/
fast_render.py
File metadata and controls
42 lines (37 loc) · 1.37 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
import ctypes
import numpy as np
from numpy.ctypeslib import ndpointer
lib = ctypes.CDLL('./utils/fast_render/build/libfast_render.so')
c_render_texture_loop = lib.render_texture_loop
c_render_texture_loop.argtypes = [
ndpointer(ctypes.c_double, flags='C_CONTIGUOUS'), # tri_depth
ctypes.c_int,
ndpointer(ctypes.c_double, flags='C_CONTIGUOUS'), # tri_tex
ctypes.c_int,
ctypes.c_int,
ndpointer(ctypes.c_int, flags='C_CONTIGUOUS'), # triangles
ctypes.c_int,
ctypes.c_int,
ndpointer(ctypes.c_double, flags='C_CONTIGUOUS'), # vertices
ctypes.c_int,
ctypes.c_int,
ndpointer(ctypes.c_double, flags='C_CONTIGUOUS'), # depth_buffer
ctypes.c_int,
ctypes.c_int,
ndpointer(ctypes.c_double, flags='C_CONTIGUOUS'), # image
ctypes.c_int,
ctypes.c_int,
]
def render_texture_loop(tri_depth, tri_tex, triangles, vertices, depth_buffer, image):
if len(image.shape) == 2:
image_channels = 1
else:
image_channels = image.shape[2]
c_render_texture_loop(
tri_depth, tri_depth.shape[0],
tri_tex, tri_tex.shape[1], tri_tex.shape[0],
triangles, triangles.shape[1], triangles.shape[0],
vertices, vertices.shape[1], vertices.shape[0],
depth_buffer, depth_buffer.shape[1], depth_buffer.shape[0],
image, image.shape[1], image.shape[0], image_channels
)