def render(self): gl.glUseProgram(self.programA) for i in range(args["resolution"]): gl.glUniform1i(self.slice_pos, i) gl.glBindFramebuffer(gl.GL_FRAMEBUFFER, self.framebufferA0[i]) gl.glClear(gl.GL_COLOR_BUFFER_BIT | gl.GL_DEPTH_BUFFER_BIT) gl.glDrawArrays(gl.GL_TRIANGLES, 0, 6)
def draw(self, uniforms, text, quad, textures=(), *args, **kwargs): glUseProgram(self) glDisable(GL_DEPTH_TEST) quad.enable() glUniform3f(self.uniforms[b'color'], 0.3, 0.3, 0.5) glUniformMatrix3fv( self.uniforms[b'transformation'], 1, GL_TRUE, text.get_transformation_matrix_2D().ctypes.data_as(POINTER(GLfloat)) ) textures.enable(slot=0) glUniform1i(self.uniforms[b'font_atlas'], 0) quad.draw() glBindBuffer(GL_ARRAY_BUFFER, 0) glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0) glBindTexture(GL_TEXTURE_2D, 0) glDisableVertexAttribArray(0) glEnable(GL_DEPTH_TEST)
def set_uniform(self, name, value): name = name.encode() valtype = type(value) if valtype == bool or valtype == int: glUniform1i(glGetUniformLocation(self.shader, name), int(value)) elif valtype == float: glUniform1f(glGetUniformLocation(self.shader, name), value) # elif valtype == VECTOR2_TYPE: # glUniform2fv(glGetUniformLocation(self.shader, name), 1, value) elif valtype == VECTOR3_TYPE: glUniform3fv(glGetUniformLocation(self.shader, name), 1, c_float(value[0]), c_float(value[1]), c_float(value[2])) elif valtype == VECTOR4_TYPE: glUniform4fv(glGetUniformLocation(self.shader, name), 1, c_float(value[0]), c_float(value[1]), c_float(value[2]), c_float(value[3])) elif valtype == MATRIX3_TYPE: glUniformMatrix3fv( glGetUniformLocation(self.shader, name), 1, GL_FALSE, c_float(value[0][0])) # Should this be value[0][0]? elif valtype == MATRIX4_TYPE: glUniformMatrix4fv( glGetUniformLocation(self.shader, name), 1, GL_FALSE, c_float(value[0][0])) # Should this be value[0][0]?
def uniform1i(self, name, value): self.use() loc = gl.glGetUniformLocation(self.handle, ctypes.create_string_buffer(name)) if loc < 0: logging.warning('Uniform {} is not in the shader.'.format(name)) return gl.glUniform1i(loc, value);
def render(self): gl.glUseProgram(self.programA) gl.glUniform1i(self.tex_pos_A, 0) for i in range(self.dimz): gl.glUniform1i(self.slice_pos_A, i) gl.glBindFramebuffer(gl.GL_FRAMEBUFFER, self.framebufferA0[i]) gl.glClear(gl.GL_COLOR_BUFFER_BIT | gl.GL_DEPTH_BUFFER_BIT) gl.glDrawArrays(gl.GL_TRIANGLES, 0, 6)
def uniform1i(self, name, value): self.use() loc = gl.glGetUniformLocation(self.handle, ctypes.create_string_buffer(name)) if loc < 0: logging.warning('Uniform %s is not in the shader.', name) return gl.glUniform1i(loc, value)
def setInt(self, name, value): if type(name) is not bytes: name = bytes(name, 'utf-8') loc = GL.glGetUniformLocation(self.handle, name) if not hasattr(value, '__len__'): GL.glUniform1i(loc, value) elif len(value) in range(1, 5): # Select the correct function { 1 : GL.glUniform1i, 2 : GL.glUniform2i, 3 : GL.glUniform3i, 4 : GL.glUniform4i # Retrieve uniform location, and set it }[len(value)](loc, value) else: raise ValueError("Shader.setInt '{}' should be length 1-4 not {}" .format(name, len(value)))
def on_draw(self): self.camera.update_matrices() # bind textures gl.glActiveTexture(gl.GL_TEXTURE0) gl.glBindTexture(gl.GL_TEXTURE_2D_ARRAY, self.texture_manager.texture_array) gl.glUniform1i(self.shader_sampler_location, 0) # draw stuff gl.glEnable(gl.GL_DEPTH_TEST) gl.glClearColor(0.0, 0.0, 0.0, 1.0) self.clear() gl.glDrawElements(gl.GL_TRIANGLES, len(self.grass.indices), gl.GL_UNSIGNED_INT, None)
def load_uniform_struct(self, struct, name=None): """ Upload a struct to the shader. Args: struct: name: Returns: """ for attribute_name in struct.__slots__: attribute = getattr(struct, attribute_name) full_name = name + '.' + attribute_name try: rows, *cols = attribute.shape # Could be problem if matrix is of shape (rows,), but that shouldn't be. except ValueError: # if attribute.dtype == GLfloat: # self.load_uniform_floats(attribute, name=full_name) # elif attribute.dtype == GLuint: # self.load_uniform_uints(attribute, name=full_name) # elif attribute.dtype == GLint: # self.load_uniform_ints(attribute, name=full_name) # else: raise TypeError( 'Not implemented yet. Only have for floats and uints.') else: if cols: # Is multi-dimensional. self.load_uniform_matrix(attribute, name=full_name) elif rows > 4: # Is 1-dimensional but longer than 4. self.load_uniform_array(attribute, name=full_name) elif attribute.dtype == GLfloat: # Is 1-dimensional, less than 4 and float. self.load_uniform_floats(*attribute, name=full_name) elif attribute.dtype == GLuint: self.load_uniform_uints(attribute, name=full_name) elif attribute.dtype == GLint: self.load_uniform_ints(attribute, name=full_name) else: # Is 1-dimensional, less than 4 and int/uint. location = self.uniform_location[name] glUniform1i( location, attribute) # Samplers should be set with integers.
def on_draw(self): self.camera.update_matrices() # bind textures gl.glActiveTexture(gl.GL_TEXTURE0) gl.glBindTexture(gl.GL_TEXTURE_2D_ARRAY, self.world.texture_manager.texture_array) gl.glUniform1i(self.shader_sampler_location, 0) # draw stuff gl.glEnable(gl.GL_DEPTH_TEST) gl.glEnable(gl.GL_CULL_FACE) gl.glClearColor(0.0, 0.0, 0.0, 1.0) self.clear() self.world.draw() gl.glFinish()
def draw(self, uniforms, entities, models, textures=(), lights=(), *args, **kwargs): glUseProgram(self) # PREPARE SHADER glUniformMatrix4fv( # ctypes.data_as must be here and not at initialization. self.uniforms[b'perspective'], 1, GL_TRUE, uniforms.get(b'perspective').ctypes.data_as(POINTER(GLfloat)) ) glUniformMatrix4fv( self.uniforms[b'view'], 1, GL_TRUE, uniforms.get(b'view').ctypes.data_as(POINTER(GLfloat)) ) for i, entity in enumerate(lights): glUniform3f(self.uniforms[b'light[' + bytes(str(i), 'utf-8') + b'].position'], *entity.location) glUniform3f(self.uniforms[b'light[' + bytes(str(i), 'utf-8') + b'].color'], *entity.color) glUniform1f(self.uniforms[b'light[' + bytes(str(i), 'utf-8') + b'].constant'], entity.attenuation[0]) glUniform1f(self.uniforms[b'light[' + bytes(str(i), 'utf-8') + b'].linear'], entity.attenuation[1]) glUniform1f(self.uniforms[b'light[' + bytes(str(i), 'utf-8') + b'].quadratic'], entity.attenuation[1]) # PREPARE MODELS for model_index, texture_mapping in self.entities.items(): model = models[model_index] model.enable() # PREPARE TEXTURES glActiveTexture(GL_TEXTURE0) glActiveTexture(GL_TEXTURE0 + 1) for texture_list, entity_list in texture_mapping.items(): if hasattr(texture_list, '__iter__'): glBindTexture(GL_TEXTURE_2D, textures[0]) glUniform1i(self.uniforms[b'diffuse_texture'], 0) glBindTexture(GL_TEXTURE_2D, textures[1]) glUniform1i(self.uniforms[b'specular_texture'], 1) # textures[0].enable(slot=0) # textures[1].enable(slot=1) else: textures[texture_list].enable(slot=0) glUniform1i(self.uniforms[b'diffuse_texture'], 0) # PREPARE ENTITIES for entity in entity_list: glUniformMatrix4fv( self.uniforms[b'transformation'], 1, GL_TRUE, entity.get_transformation_matrix().ctypes.data_as(POINTER(GLfloat)) ) model.draw() glBindBuffer(GL_ARRAY_BUFFER, 0) glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0) glBindTexture(GL_TEXTURE_2D, 0) glDisableVertexAttribArray(0) glDisableVertexAttribArray(1) glDisableVertexAttribArray(2)
def on_draw(self): # create projection matrix self.p_matrix.load_identity() self.p_matrix.perspective(90, float(self.width) / self.height, 0.1, 500) # create modelview matrix self.mv_matrix.load_identity() self.mv_matrix.translate(0, 0, -3) self.mv_matrix.rotate_2d(self.x, math.sin(self.x / 3 * 2) / 2) # modelviewprojection matrix mvp_matrix = self.p_matrix * self.mv_matrix self.shader.uniform_matrix(self.shader_matrix_location, mvp_matrix) # bind textures gl.glActiveTexture( gl.GL_TEXTURE0 ) # set our active texture unit to the first texture unit gl.glBindTexture(gl.GL_TEXTURE_2D_ARRAY, self.texture_manager. texture_array) # bind our texture manager's texture gl.glUniform1i( self.shader_sampler_location, 0 ) # tell our sampler our texture is bound to the first texture unit # draw stuff gl.glEnable( gl.GL_DEPTH_TEST ) # enable depth testing so faces are drawn in the right order gl.glClearColor(0.0, 0.0, 0.0, 1.0) self.clear() gl.glDrawElements(gl.GL_TRIANGLES, len(self.grass.indices), gl.GL_UNSIGNED_INT, None)
def __init__(self, window): super(GameMain, self).__init__(window, texture=None, color='#000000') self.config = gl.Config(double_buffer=True, major_version=3, minor_version=3, depth_size=16, sample_buffers=bool(options.ANTIALIASING), samples=options.ANTIALIASING) # Options self.options = window.options if self.options.INDIRECT_RENDERING and not gl.gl_info.have_version( 4, 2): raise RuntimeError( """Indirect Rendering is not supported on your hardware This feature is only supported on OpenGL 4.2+, but your driver doesnt seem to support it, Please disable "INDIRECT_RENDERING" in options.py""") # Pause menu self.show_pause = False self.back_to_game = GuiButton(self.on_back_to_game, self.window, self.window.width / 2, self.window.height / 2 + 35, 'Back to game') self.save_game = GuiButton(self.on_save_game, self.window, self.window.width / 2, self.window.height / 2, 'Save and quit to title') # F3 Debug Screen self.show_f3 = False self.f3 = pyglet.text.Label("", x=10, y=self.height - 10, font_size=16, color=(255, 255, 255, 255), width=self.width // 3, multiline=True) self.system_info = f"""Python: {platform.python_implementation()} {platform.python_version()} System: {platform.machine()} {platform.system()} {platform.release()} {platform.version()} CPU: {platform.processor()} Display: {gl.gl_info.get_renderer()} {gl.gl_info.get_version()}""" logging.info(f"System Info: {self.system_info}") # create shader logging.info("Compiling Shaders") if not self.options.COLORED_LIGHTING: self.shader = shader.Shader("shaders/alpha_lighting/vert.glsl", "shaders/alpha_lighting/frag.glsl") else: self.shader = shader.Shader("shaders/colored_lighting/vert.glsl", "shaders/colored_lighting/frag.glsl") self.shader_sampler_location = self.shader.find_uniform( b"u_TextureArraySampler") self.shader.use() # create textures logging.info("Creating Texture Array") self.texture_manager = texture_manager.TextureManager(16, 16, 256) # create world self.world = world.World(self.shader, None, self.texture_manager, self.options) # player stuff logging.info("Setting up player & camera") self.player = player.Player(self.world, self.shader, self.width, self.height) self.world.player = self.player # pyglet stuff pyglet.clock.schedule(self.player.update_interpolation) pyglet.clock.schedule_interval(self.update, 1 / 600) self.window.mouse_captured = False # misc stuff self.holding = 50 # bind textures gl.glActiveTexture(gl.GL_TEXTURE0) gl.glBindTexture(gl.GL_TEXTURE_2D_ARRAY, self.world.texture_manager.texture_array) gl.glUniform1i(self.shader_sampler_location, 0) # enable cool stuff gl.glEnable(gl.GL_DEPTH_TEST) gl.glEnable(gl.GL_CULL_FACE) gl.glBlendFunc(gl.GL_SRC_ALPHA, gl.GL_ONE_MINUS_SRC_ALPHA) if self.options.ANTIALIASING: gl.glEnable(gl.GL_MULTISAMPLE) gl.glEnable(gl.GL_SAMPLE_ALPHA_TO_COVERAGE) gl.glSampleCoverage(0.5, gl.GL_TRUE) # controls stuff self.controls = [0, 0, 0] # joystick stuff self.joystick_controller = joystick.Joystick_controller(self) # mouse and keyboard stuff self.keyboard_mouse = keyboard_mouse.Keyboard_Mouse(self) # music stuff logging.info("Loading audio") try: self.music = [ pyglet.media.load(os.path.join("audio/music", file)) for file in os.listdir("audio/music") if os.path.isfile(os.path.join("audio/music", file)) ] except: self.music = [] self.media_player = pyglet.media.Player() self.media_player.volume = 0.5 if len(self.music) > 0: self.media_player.queue(random.choice(self.music)) self.media_player.play() self.media_player.standby = False else: self.media_player.standby = True self.media_player.next_time = 0 # GPU command syncs self.fences = deque()
def __set_uniforms(self): # projection matrix (proj) proj_loc = gl.glGetUniformLocation(self.__prog.value, "proj") proj_matrix = self.__proj_matrix() proj_matrix_ptr = ct.cast( \ ct.pointer(np.ctypeslib.as_ctypes(proj_matrix)), ct.POINTER(ct.c_float) ) gl.glUniformMatrix4fv(proj_loc, 1, gl.GL_TRUE, proj_matrix_ptr) # voxel spacing voxel_spacing_loc = gl.glGetUniformLocation(self.__prog.value, "voxel_spacing") gl.glUniform3f(voxel_spacing_loc, self.__voxel_spacing[0]*self.__downsample, self.__voxel_spacing[1]*self.__downsample, self.__voxel_spacing[2]*self.__downsample) # voxel size voxel_size_loc = gl.glGetUniformLocation(self.__prog.value, "voxel_size") gl.glUniform3f(voxel_size_loc, self.__voxel_size[0]*self.__downsample, self.__voxel_size[1]*self.__downsample, self.__voxel_size[2]*self.__downsample) # data; not technically a "uniform" but a texture data_loc = gl.glGetUniformLocation(self.__prog.value, "data") gl.glUniform1i(data_loc, 0) gl.glActiveTexture(gl.GL_TEXTURE0) gl.glBindTexture(gl.GL_TEXTURE_BUFFER, self.__data_texture.value) # dims dims_loc = gl.glGetUniformLocation(self.__prog.value, "dims") gl.glUniform3i(dims_loc, self.__data.shape[0]/self.__downsample, self.__data.shape[1]/self.__downsample, self.__data.shape[2]/self.__downsample) # global_opacity global_opacity_loc = gl.glGetUniformLocation(self.__prog.value, "global_opacity") gl.glUniform1f(global_opacity_loc, self.__opacity) # min value min_value_loc = gl.glGetUniformLocation(self.__prog.value, "min_value") gl.glUniform1f(min_value_loc, self.__min_value) # saturation value saturation_value_loc = gl.glGetUniformLocation(self.__prog.value, "saturation_value") gl.glUniform1f(saturation_value_loc, self.__saturation_value) # downsample downsample_loc = gl.glGetUniformLocation(self.__prog.value, "downsample") gl.glUniform1i(downsample_loc, self.__downsample)
def _uint(uniform, data): gl.glUniform1i(uniform, data)
def render(self, draw_data): # perf: local for faster access io = self.io display_width, display_height = io.display_size fb_width = int(display_width * io.display_fb_scale[0]) fb_height = int(display_height * io.display_fb_scale[1]) if fb_width == 0 or fb_height == 0: return draw_data.scale_clip_rects(*io.display_fb_scale) # backup GL state # todo: provide cleaner version of this backup-restore code last_program = gl.GLint() gl.glGetIntegerv(gl.GL_CURRENT_PROGRAM, byref(last_program)) last_texture = gl.GLint() gl.glGetIntegerv(gl.GL_TEXTURE_BINDING_2D, byref(last_texture)) last_active_texture = gl.GLint() gl.glGetIntegerv(gl.GL_ACTIVE_TEXTURE, byref(last_active_texture)) last_array_buffer = gl.GLint() gl.glGetIntegerv(gl.GL_ARRAY_BUFFER_BINDING, byref(last_array_buffer)) last_element_array_buffer = gl.GLint() gl.glGetIntegerv(gl.GL_ELEMENT_ARRAY_BUFFER_BINDING, byref(last_element_array_buffer)) last_vertex_array = gl.GLint() gl.glGetIntegerv(gl.GL_VERTEX_ARRAY_BINDING, byref(last_vertex_array)) last_blend_src = gl.GLint() gl.glGetIntegerv(gl.GL_BLEND_SRC, byref(last_blend_src)) last_blend_dst = gl.GLint() gl.glGetIntegerv(gl.GL_BLEND_DST, byref(last_blend_dst)) last_blend_equation_rgb = gl.GLint() gl.glGetIntegerv(gl.GL_BLEND_EQUATION_RGB, byref(last_blend_equation_rgb)) last_blend_equation_alpha = gl.GLint() gl.glGetIntegerv(gl.GL_BLEND_EQUATION_ALPHA, byref(last_blend_equation_alpha)) last_viewport = (gl.GLint*4)() gl.glGetIntegerv(gl.GL_VIEWPORT, last_viewport) last_scissor_box = (gl.GLint*4)() gl.glGetIntegerv(gl.GL_SCISSOR_BOX, last_scissor_box) last_enable_blend = gl.GLint() gl.glIsEnabled(gl.GL_BLEND, byref(last_enable_blend)) last_enable_cull_face = gl.GLint() gl.glIsEnabled(gl.GL_CULL_FACE, byref(last_enable_cull_face)) last_enable_depth_test = gl.GLint() gl.glIsEnabled(gl.GL_DEPTH_TEST, byref(last_enable_depth_test)) last_enable_scissor_test = gl.GLint() gl.glIsEnabled(gl.GL_SCISSOR_TEST, byref(last_enable_scissor_test)) gl.glEnable(gl.GL_BLEND) gl.glBlendEquation(gl.GL_FUNC_ADD) gl.glBlendFunc(gl.GL_SRC_ALPHA, gl.GL_ONE_MINUS_SRC_ALPHA) gl.glDisable(gl.GL_CULL_FACE) gl.glDisable(gl.GL_DEPTH_TEST) gl.glEnable(gl.GL_SCISSOR_TEST) gl.glActiveTexture(gl.GL_TEXTURE0) gl.glViewport(0, 0, int(fb_width), int(fb_height)) ortho_projection = [ 2.0/display_width, 0.0, 0.0, 0.0, 0.0, 2.0/-display_height, 0.0, 0.0, 0.0, 0.0, -1.0, 0.0, -1.0, 1.0, 0.0, 1.0 ] gl.glUseProgram(self._shader_handle) gl.glUniform1i(self._attrib_location_tex, 0) gl.glUniformMatrix4fv(self._attrib_proj_mtx, 1, gl.GL_FALSE, (gl.GLfloat * 16)(*ortho_projection)) gl.glBindVertexArray(self._vao_handle) for commands in draw_data.commands_lists: idx_buffer_offset = 0 gl.glBindBuffer(gl.GL_ARRAY_BUFFER, self._vbo_handle) # todo: check this (sizes) gl.glBufferData(gl.GL_ARRAY_BUFFER, commands.vtx_buffer_size * imgui.VERTEX_SIZE, c_void_p(commands.vtx_buffer_data), gl.GL_STREAM_DRAW) gl.glBindBuffer(gl.GL_ELEMENT_ARRAY_BUFFER, self._elements_handle) # todo: check this (sizes) gl.glBufferData(gl.GL_ELEMENT_ARRAY_BUFFER, commands.idx_buffer_size * imgui.INDEX_SIZE, c_void_p(commands.idx_buffer_data), gl.GL_STREAM_DRAW) # todo: allow to iterate over _CmdList for command in commands.commands: gl.glBindTexture(gl.GL_TEXTURE_2D, command.texture_id) # todo: use named tuple x, y, z, w = command.clip_rect gl.glScissor(int(x), int(fb_height - w), int(z - x), int(w - y)) if imgui.INDEX_SIZE == 2: gltype = gl.GL_UNSIGNED_SHORT else: gltype = gl.GL_UNSIGNED_INT gl.glDrawElements(gl.GL_TRIANGLES, command.elem_count, gltype, c_void_p(idx_buffer_offset)) idx_buffer_offset += command.elem_count * imgui.INDEX_SIZE # restore modified GL state gl.glUseProgram(cast((c_int*1)(last_program), POINTER(c_uint)).contents) gl.glActiveTexture(cast((c_int*1)(last_active_texture), POINTER(c_uint)).contents) gl.glBindTexture(gl.GL_TEXTURE_2D, cast((c_int*1)(last_texture), POINTER(c_uint)).contents) gl.glBindVertexArray(cast((c_int*1)(last_vertex_array), POINTER(c_uint)).contents) gl.glBindBuffer(gl.GL_ARRAY_BUFFER, cast((c_int*1)(last_array_buffer), POINTER(c_uint)).contents) gl.glBindBuffer(gl.GL_ELEMENT_ARRAY_BUFFER, cast((c_int*1)(last_element_array_buffer), POINTER(c_uint)).contents) gl.glBlendEquationSeparate(cast((c_int*1)(last_blend_equation_rgb), POINTER(c_uint)).contents, cast((c_int*1)(last_blend_equation_alpha), POINTER(c_uint)).contents) gl.glBlendFunc(cast((c_int*1)(last_blend_src), POINTER(c_uint)).contents, cast((c_int*1)(last_blend_dst), POINTER(c_uint)).contents) if last_enable_blend: gl.glEnable(gl.GL_BLEND) else: gl.glDisable(gl.GL_BLEND) if last_enable_cull_face: gl.glEnable(gl.GL_CULL_FACE) else: gl.glDisable(gl.GL_CULL_FACE) if last_enable_depth_test: gl.glEnable(gl.GL_DEPTH_TEST) else: gl.glDisable(gl.GL_DEPTH_TEST) if last_enable_scissor_test: gl.glEnable(gl.GL_SCISSOR_TEST) else: gl.glDisable(gl.GL_SCISSOR_TEST) gl.glViewport(last_viewport[0], last_viewport[1], last_viewport[2], last_viewport[3]) gl.glScissor(last_scissor_box[0], last_scissor_box[1], last_scissor_box[2], last_scissor_box[3])
def render(self): gl.glUseProgram(self.programA) gl.glUniform1i(self.tex_pos_A_A, 1) gl.glUniform1i(self.tex_pos_A_B, 3) gl.glBindFramebuffer(gl.GL_FRAMEBUFFER, self.framebufferA0) gl.glClear(gl.GL_COLOR_BUFFER_BIT | gl.GL_DEPTH_BUFFER_BIT) gl.glDrawArrays(gl.GL_TRIANGLES, 0, 6) gl.glUseProgram(self.programB) gl.glUniform1i(self.tex_pos_B_A, 1) gl.glUniform1i(self.tex_pos_B_B, 3) gl.glBindFramebuffer(gl.GL_FRAMEBUFFER, self.framebufferB0) gl.glClear(gl.GL_COLOR_BUFFER_BIT | gl.GL_DEPTH_BUFFER_BIT) gl.glDrawArrays(gl.GL_TRIANGLES, 0, 6) gl.glUseProgram(self.programA) gl.glUniform1i(self.tex_pos_A_A, 0) gl.glUniform1i(self.tex_pos_A_B, 2) gl.glBindFramebuffer(gl.GL_FRAMEBUFFER, self.framebufferA1) gl.glClear(gl.GL_COLOR_BUFFER_BIT | gl.GL_DEPTH_BUFFER_BIT) gl.glDrawArrays(gl.GL_TRIANGLES, 0, 6) gl.glUseProgram(self.programB) gl.glUniform1i(self.tex_pos_B_A, 0) gl.glUniform1i(self.tex_pos_B_B, 2) gl.glBindFramebuffer(gl.GL_FRAMEBUFFER, self.framebufferB1) gl.glClear(gl.GL_COLOR_BUFFER_BIT | gl.GL_DEPTH_BUFFER_BIT) gl.glDrawArrays(gl.GL_TRIANGLES, 0, 6)
def load_uniform_sampler(self, **uniforms): self._assert_bound() for name, data in uniforms.items(): glUniform1i(self.uniform[name], data)