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

Class PWPostProcessing

pymaze/post_processing.py:39–226  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

37
38#
39class PWPostProcessing(PWConstants):
40 def __init__(self):
41 self.buffer = 0
42 self.color_texture = 0
43 self.depth_texture = 0
44 self.__createPassBuffer()
45
46 # --------
47
48 self.quad = PWVaoData()
49 self.__createPassQuad()
50
51
52 def getColorAttachment(self):
53 return self.color_texture;
54
55
56 def getDepthAttachment(self):
57 return self.depth_texture;
58
59
60 def __createPassBuffer(self):
61 self.buffer = glGenFramebuffers(1)
62 glBindFramebuffer(GL_FRAMEBUFFER, self.buffer)
63
64 # -------- Add color attachment
65
66 self.color_texture = glGenTextures(1)
67 glBindTexture(GL_TEXTURE_2D, self.color_texture)
68
69 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, self.d_resolution.x, self.d_resolution.y, 0, GL_RGB, GL_UNSIGNED_BYTE, None)
70 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR)
71 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR)
72 glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, self.color_texture, 0)
73
74 # -------- Add depth attachment
75
76 self.depth_texture = glGenTextures(1)
77 glBindTexture(GL_TEXTURE_2D, self.depth_texture)
78
79 glTexImage2D(GL_TEXTURE_2D, 0, GL_DEPTH_COMPONENT, self.d_resolution.x, self.d_resolution.y, 0, GL_DEPTH_COMPONENT, GL_FLOAT, None)
80 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST)
81 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST)
82 glFramebufferTexture2D(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_TEXTURE_2D, self.depth_texture, 0)
83
84 # --------
85
86 if glCheckFramebufferStatus(GL_FRAMEBUFFER) != GL_FRAMEBUFFER_COMPLETE:
87 print("Framebuffer Error!")
88 # TODO: Make GL utility functions
89
90
91 def __createPassQuad(self):
92 self.quad.vao = glGenVertexArrays(1)
93 glBindVertexArray(self.quad.vao)
94
95 # Position(3), Texture(2)
96 vertices = np.array([-1.0, 1.0, 0.0, 1.0,

Callers 1

__init__Method · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected