def draw_points(self): gl.glDisable(gl.GL_BLEND) gl.glEnable(gl.GL_DEPTH_TEST) gl.glDepthMask(gl.GL_TRUE) self.program_points.draw('points')
def _test_setting_stuff(): # Set stuff to touch functions gl.glClear(gl.GL_COLOR_BUFFER_BIT) # gl.glBlendColor(1.0, 1.0, 1.0, 1.0) gl.glBlendEquation(gl.GL_FUNC_ADD) gl.glBlendEquationSeparate(gl.GL_FUNC_ADD, gl.GL_FUNC_ADD) gl.glBlendFunc(gl.GL_ONE, gl.GL_ZERO) gl.glBlendFuncSeparate(gl.GL_ONE, gl.GL_ZERO, gl.GL_ONE, gl.GL_ZERO) # gl.glClearColor(0.0, 0.0, 0.0, 1.0) gl.glClearDepth(1) gl.glClearStencil(0) # gl.glColorMask(True, True, True, True) gl.glDepthMask(False) gl.glStencilMask(255) gl.glStencilMaskSeparate(gl.GL_FRONT, 128) # gl.glStencilFunc(gl.GL_ALWAYS, 0, 255) gl.glStencilFuncSeparate(gl.GL_FRONT, gl.GL_ALWAYS, 0, 255) gl.glStencilOp(gl.GL_KEEP, gl.GL_KEEP, gl.GL_KEEP) gl.glStencilOpSeparate(gl.GL_FRONT, gl.GL_KEEP, gl.GL_KEEP, gl.GL_KEEP) # gl.glFrontFace(gl.GL_CW) gl.glHint(gl.GL_GENERATE_MIPMAP_HINT, gl.GL_FASTEST) gl.glLineWidth(2.0) gl.glPolygonOffset(0.0, 0.0) gl.glSampleCoverage(1.0, False) # And getting stuff try: with use_log_level('error', print_msg=False): r, p = gl.glGetShaderPrecisionFormat(gl.GL_FRAGMENT_SHADER, gl.GL_HIGH_FLOAT) gl.check_error() # Sometimes the func is there but OpenGL errs except Exception: pass # accept if the function is not there ... # We should catch RuntimeError and GL.error.NullFunctionError, # but PyOpenGL may not be available. # On Travis this function was not there on one machine according # to PyOpenGL, but our desktop backend worked fine ... # v = gl.glGetParameter(gl.GL_VERSION) assert_true(isinstance(v, string_types)) assert_true(len(v) > 0) gl.check_error()
def draw_model(self): gl.glEnable(gl.GL_DEPTH_TEST) gl.glDepthMask(gl.GL_TRUE) gl.glFrontFace(gl.GL_CCW) gl.glDisable(gl.GL_BLEND) gl.glBlendFunc(gl.GL_ZERO, gl.GL_ZERO) if self.render_params['transparent']: gl.glEnable(gl.GL_BLEND) gl.glDepthMask(gl.GL_FALSE) gl.glBlendFunc(gl.GL_SRC_ALPHA, gl.GL_ONE_MINUS_SRC_ALPHA) self.program_solids.draw('triangles')
def on_paint(self, event): gl.glClear(gl.GL_COLOR_BUFFER_BIT | gl.GL_DEPTH_BUFFER_BIT) with self.program as prog: # Filled cube gl.glDisable(gl.GL_BLEND) gl.glEnable(gl.GL_DEPTH_TEST) gl.glEnable(gl.GL_POLYGON_OFFSET_FILL) prog['u_color'] = 1, 1, 1, 1 prog.draw(gl.GL_TRIANGLES, self.filled_buf) # Outline gl.glDisable(gl.GL_POLYGON_OFFSET_FILL) gl.glEnable(gl.GL_BLEND) gl.glDepthMask(gl.GL_FALSE) prog['u_color'] = 0, 0, 0, 1 prog.draw(gl.GL_LINES, self.outline_buf) gl.glDepthMask(gl.GL_TRUE)
def draw(self, mode="triangle_strip"): """ Draw collection """ gl.glDepthMask(gl.GL_FALSE) Collection.draw(self, mode) gl.glDepthMask(gl.GL_TRUE)
def draw(self, mode="triangles"): """ Draw collection """ gl.glDepthMask(0) Collection.draw(self, mode) gl.glDepthMask(1)