def on_draw(): glEnable(GL_CULL_FACE) glPolygonMode(GL_FRONT_AND_BACK, GL_LINE) window.clear() boxProgram.vars.modelview = Matrix().translate(0,0,-5).rotatex(-0.175).rotatez(rotation) boxProgram.vars.projection = Matrix.perspective(window.width, window.height, 40, 0.1, 100.0) rimProgram.vars.modelview = Matrix().translate(0,0,-5).rotatex(-0.175).rotatez(rotation) rimProgram.vars.projection = Matrix.perspective(window.width, window.height, 40, 0.1, 100.0) cornerProgram.vars.modelview = Matrix().translate(0,0,-5).rotatex(-0.175).rotatez(rotation) cornerProgram.vars.projection = Matrix.perspective(window.width, window.height, 40, 0.1, 100.0) with boxProgram: glPatchParameteri(GL_PATCH_VERTICES, 4); quadVbo.draw(GL_PATCHES) with rimProgram: glPatchParameteri(GL_PATCH_VERTICES, 6); rimVbo.draw(GL_PATCHES) with cornerProgram: glPatchParameteri(GL_PATCH_VERTICES, 6); cornerVbo.draw(GL_PATCHES) glPolygonMode(GL_FRONT_AND_BACK, GL_FILL) for label in allLabels: label.draw()
def on_draw(): glPolygonMode(GL_FRONT_AND_BACK, GL_LINE) window.clear() program.vars.modelview = Matrix().translate(0,0,-3).rotatex(-0.175).rotatez(rotation) program.vars.projection = Matrix.perspective(window.width, window.height, 60, 0.1, 100.0) with program: vbo.draw(GL_PATCHES)
def init_program(self): self.near = 0.25 self.far = 3.0 self.fov = 120.0 self.program = ShaderProgram( VertexShader.open(os.path.join(os.path.dirname(__file__) , 'opglex/shaders/simple.vert')), FragmentShader.open(os.path.join(os.path.dirname(__file__), 'opglex/shaders/simple.frag')), offset = [0.0, 0.0, 0.0], perspectiveMatrix = Matrix.perspective(self.width, self.height, self.fov, self.near, self.far) )
def on_draw(): glPolygonMode(GL_FRONT_AND_BACK, GL_LINE) window.clear() program.vars.modelview = Matrix().translate( 0, 0, -3).rotatex(-0.175).rotatez(rotation) program.vars.projection = Matrix.perspective(window.width, window.height, 60, 0.1, 100.0) with program: vbo.draw(GL_PATCHES)
def on_draw(): glPolygonMode(GL_FRONT_AND_BACK, GL_LINE) glEnable(GL_CULL_FACE) glCullFace(GL_BACK) window.clear() model = Matrix().translate(-0.5, 0.0, 0.0) program.vars.modelview = view.matrix * model program.vars.projection = Matrix.perspective(window.width, window.height, 60, 0.001, 2.0) with program: terrain.draw()
def on_draw(): glPolygonMode(GL_FRONT_AND_BACK, GL_LINE) window.clear() spacing = 2 trisProgram.vars.modelview = Matrix().translate(-spacing, 0, -5).rotatex(-0.175).rotatez(rotation) trisProgram.vars.projection = Matrix.perspective(window.width, window.height, 40, 0.1, 100.0) quadsProgram.vars.modelview = Matrix().translate(spacing, 0, -5).rotatex(-0.175).rotatez(rotation) quadsProgram.vars.projection = Matrix.perspective(window.width, window.height, 40, 0.1, 100.0) with trisProgram: glPatchParameteri(GL_PATCH_VERTICES, 3) triVbo.draw(GL_PATCHES) with quadsProgram: glPatchParameteri(GL_PATCH_VERTICES, 4) quadVbo.draw(GL_PATCHES) glPolygonMode(GL_FRONT_AND_BACK, GL_FILL) for label in allLabels: label.draw()
def on_draw(): window.clear() program = lod program.vars.modelview = Matrix().translate(0,0,-zoom).rotatex(-0.14).rotatez(rotation) program.vars.projection = Matrix.perspective(window.width, window.height, 60, 0.1, 200.0) program.vars.screen_size = float(window.width), float(window.height) glPolygonMode(GL_FRONT_AND_BACK, GL_LINE) with program: glPatchParameteri(GL_PATCH_VERTICES, 4); vbo.draw(GL_PATCHES) #vbo.draw(GL_QUADS) glPolygonMode(GL_FRONT_AND_BACK, GL_FILL) fps.draw()
def on_draw(): window.clear() program = lod program.vars.modelview = Matrix().translate( 0, 0, -zoom).rotatex(-0.14).rotatez(rotation) program.vars.projection = Matrix.perspective(window.width, window.height, 60, 0.1, 200.0) program.vars.screen_size = float(window.width), float(window.height) glPolygonMode(GL_FRONT_AND_BACK, GL_LINE) with program: glPatchParameteri(GL_PATCH_VERTICES, 4) vbo.draw(GL_PATCHES) #vbo.draw(GL_QUADS) glPolygonMode(GL_FRONT_AND_BACK, GL_FILL) fps.draw()
def on_draw(): window.clear() model = Matrix().rotatex(-0.25).translate(-0.5, -0.5, 0.0) projection = Matrix.perspective(window.width, window.height, 65, 0.0001, 100.0) modelview = view.matrix * model program.vars.mvp = projection * modelview program.vars.modelview = modelview program.vars.projection = projection program.vars.screen_size = float(window.width), float(window.height) #glPolygonMode(GL_FRONT_AND_BACK, GL_LINE) with nested(DepthTest, diffuse, terrain, program): vbo.draw(GL_PATCHES) ''' normals.vars.mvp = projection * modelview with nested(DepthTest, normals): vbo.draw(normals, GL_TRIANGLES) ''' fps.draw()
def on_resize(self, width, height): # Override the default on_resize handler to create a 3D projection self.projection = Matrix.perspective(width, height, 60, 0.1, 1000) glViewport(0, 0, width, height) glClearColor(0,0,0, 255) return pyglet.event.EVENT_HANDLED
def on_resize(self, w, h): # print 'resizing' self.program.vars['perspectiveMatrix'] = Matrix.perspective(w, h, self.fov, self.near, self.far) glViewport(0, 0, w, h)