MCPcopy Create free account
hub / github.com/Blakkis/PyGLMaze / PWDebug

Class PWDebug

pymaze/debug.py:6–86  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

4from shaders import *
5
6class PWDebug(PWConstants):
7 MAX_LINES = 8192
8
9 # Draw commands
10 __draw_list = []
11
12 # Data
13 __vao = None
14 __stride = 0
15 __data = None
16
17
18 @classmethod
19 def initDebugger(cls):
20 cls.__stride = (cls.d_fsize * 4) * 2
21 cls.__data = np.array([0] * 8 * cls.MAX_LINES, dtype='float32')
22
23 # --------
24
25 cls.__vao = PWVaoData()
26 cls.__vao.count = 1
27
28 cls.__vao.vao = glGenVertexArrays(1)
29 glBindVertexArray(cls.__vao.vao)
30
31 cls.__vao.data = glGenBuffers(1)
32 glBindBuffer(GL_ARRAY_BUFFER, cls.__vao.data)
33 glBufferData(GL_ARRAY_BUFFER, cls.__data, GL_STREAM_DRAW)
34
35 glEnableVertexAttribArray(0)
36 glVertexAttribPointer(0, 4, GL_FLOAT, GL_FALSE, cls.d_fsize * 4, None)
37
38
39 @classmethod
40 def drawLine(cls, _from, _to, grey = 1.0):
41 if cls.__vao.count >= cls.MAX_LINES - 1:
42 return
43
44 ofs = cls.__vao.count * 8
45 cls.__data[ofs + 0] = _from.x
46 cls.__data[ofs + 1] = _from.y
47 cls.__data[ofs + 2] = _from.z
48 cls.__data[ofs + 3] = grey
49
50 cls.__data[ofs + 4] = _to.x
51 cls.__data[ofs + 5] = _to.y
52 cls.__data[ofs + 6] = _to.z
53 cls.__data[ofs + 7] = grey
54
55 # Update line count
56 cls.__vao.count += 1
57
58
59 @classmethod
60 def drawDebug(cls, camera):
61 if not cls.__vao.count:
62 return
63

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected