def draw_depth(camera, renderables, rend_target): rendfb, rendtex, _ = rend_target material = DepthMaterial() program = DepthMaterial().compile() with rendfb: gloo.clear(color=camera.clear_color) gloo.set_state(depth_test=True) gl.glEnable(gl.GL_CULL_FACE) gl.glCullFace(gl.GL_FRONT) for renderable in renderables: material.upload_camera(program, camera) material.upload_attributes(program, renderable._attributes) program['u_model'] = renderable.model_mat.T program.draw(gl.GL_TRIANGLES) gl.glCullFace(gl.GL_BACK) gl.glDisable(gl.GL_CULL_FACE)
def _test_setting_parameters(): # Set some parameters and get result clr = 1.0, 0.1, 0.2, 0.7 gl.glClearColor(*clr) assert_almost_equal(gl.glGetParameter(gl.GL_COLOR_CLEAR_VALUE), clr) # gl.glCullFace(gl.GL_FRONT) assert_equal(gl.glGetParameter(gl.GL_CULL_FACE_MODE), gl.GL_FRONT) gl.glCullFace(gl.GL_BACK) assert_equal(gl.glGetParameter(gl.GL_CULL_FACE_MODE), gl.GL_BACK) # gl.glDepthFunc(gl.GL_NOTEQUAL) assert_equal(gl.glGetParameter(gl.GL_DEPTH_FUNC), gl.GL_NOTEQUAL) # val = 0.2, 0.3 gl.glDepthRange(*val) assert_almost_equal(gl.glGetParameter(gl.GL_DEPTH_RANGE), val) gl.check_error()