| 97 | self.vao.render({'mesh':moderngl.TRIANGLES, 'grid':moderngl.LINES}[self.mode]) |
| 98 | |
| 99 | class MarkText: |
| 100 | def __init__(self, vts, ids, os, h, color): |
| 101 | self.vts, self.ids, self.color, self.os, self.h = vts, ids, color, os, h |
| 102 | self.blend, self.box, self.visible, self.mode = 1, None, True, 'grid' |
| 103 | |
| 104 | def on_ctx(self, ctx, prog): |
| 105 | self.ctx = ctx |
| 106 | vts, ids, os = self.vts, self.ids, self.os |
| 107 | buf = self.buf = np.zeros((len(vts), 6), dtype=np.float32) |
| 108 | buf[:,0:3], buf[:,3:6] = vts, os |
| 109 | self.vbo = ctx.buffer(buf.tobytes()) |
| 110 | ibo = ctx.buffer(ids.tobytes()) |
| 111 | content = [(self.vbo, '3f 3f', 'v_vert', 'v_pos')] |
| 112 | self.vao = ctx.vertex_array(prog, content, ibo) |
| 113 | self.prog = prog |
| 114 | |
| 115 | def set_style(self, mode=None, blend=None, color=None, visible=None): |
| 116 | if not visible is None: self.visible = visible |
| 117 | if not color is None: self.color = color |
| 118 | |
| 119 | def draw(self, mvp, light, bright, scatter): |
| 120 | if not self.visible: return |
| 121 | self.ctx.line_width = 2 |
| 122 | self.prog['mv'].write(mvp[0].astype(np.float32).tobytes()) |
| 123 | self.prog['proj'].write(mvp[1].astype(np.float32).tobytes()) |
| 124 | self.prog['f_color'].write(np.array(self.color).astype(np.float32).tobytes()) |
| 125 | self.prog['h'].value = self.h |
| 126 | self.vao.render(moderngl.LINES) |
| 127 | |
| 128 | class Manager: |
| 129 | def __init__(self): |