def on_mouse_motion(x, y, rx, ry): with nested(ripples.framebuffer, Color): glColor4f(0.0, 1.5, 3.0, 1.0) glLineWidth(1.0) glBegin(GL_LINES) glVertex3f(x, y, 0) glVertex3f(x+rx, y+ry, 0) glEnd()
def on_mouse_motion(x, y, rx, ry): with nested(ripples.framebuffer, Color): glColor4f(0.0, 1.5, 3.0, 1.0) glLineWidth(1.0) glBegin(GL_LINES) glVertex3f(x, y, 0) glVertex3f(x + rx, y + ry, 0) glEnd()
def on_mouse_press(x, y, button, modifiers): with nested(ripples.framebuffer, Color): glColor4f(0.0, 1.5, 3.0, 1.0) glBegin(GL_QUADS) size = 1.0 glVertex3f(x + size, y + size, 0) glVertex3f(x + size, y - size, 0) glVertex3f(x - size, y - size, 0) glVertex3f(x - size, y + size, 0) glEnd()
def rain(delta): x = random.randint(0, ripples.width) y = random.randint(0, ripples.height) size = random.random() * 0.5 with nested(ripples.framebuffer, Color): glPointSize(size) glBegin(GL_POINTS) glColor4f(0.2, 0.2, 0.2, 1.0) glVertex3f(x, y, 0) glEnd()
def step(self): self.framebuffer.textures[0] = self.tex1 self.tex1.unit = GL_TEXTURE0 self.tex2.unit = GL_TEXTURE1 self.tex3.unit = GL_TEXTURE2 with nested(self.framebuffer, self.program, self.tex2, self.tex3): quad(self.width, self.height, 0, 0) self.tex1, self.tex2, self.tex3 = self.tex2, self.tex3, self.tex1
def on_mouse_press(x, y, button, modifiers): with nested(ripples.framebuffer, Color): glColor4f(0.0, 1.5, 3.0, 1.0) glBegin(GL_QUADS) size = 1.0 glVertex3f(x+size, y+size, 0) glVertex3f(x+size, y-size, 0) glVertex3f(x-size, y-size, 0) glVertex3f(x-size, y+size, 0) glEnd()
def on_draw(): window.clear() with nested(projection, Lighting): glClearColor(0.0,0.0,0.0,0.0) glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT) glPushMatrix() glTranslatef(0, 0, -2) glRotatef(angle, 0.0, 1.0, 0.0) vbo.draw() glPopMatrix()
def rain(delta): x = random.randint(0, ripples.width) y = random.randint(0, ripples.height) size = random.random() * 1.5 with nested(ripples.framebuffer, Color): glBegin(GL_QUADS) glColor4f(0.0, size/2, size, 1.0) glVertex3f(x+size, y+size, 0) glVertex3f(x+size, y-size, 0) glVertex3f(x-size, y-size, 0) glVertex3f(x-size, y+size, 0) glEnd()
def on_draw(): window.clear() with nested(projection, Lighting): glClearColor(0.0, 0.0, 0.0, 0.0) glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT) glPushMatrix() glTranslatef(0, 0, -2) glRotatef(angle, 0.0, 1.0, 0.0) vbo.draw() glPopMatrix()
def rain(delta): x = random.randint(0, ripples.width) y = random.randint(0, ripples.height) size = random.random() * 1.5 with nested(ripples.framebuffer, Color): glBegin(GL_QUADS) glColor4f(0.0, size / 2, size, 1.0) glVertex3f(x + size, y + size, 0) glVertex3f(x + size, y - size, 0) glVertex3f(x - size, y - size, 0) glVertex3f(x - size, y + size, 0) glEnd()
def on_draw(): window.clear() with nested(projection, Lighting, bunny.vbo): glClearColor(0.0,0.0,0.0,0.0) glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT) glPushMatrix() glTranslatef(0, 0, -400) glRotatef(angle, 0.0, 1.0, 0.0) for x, y, z in positions: glPushMatrix() glTranslatef(x, y, z) bunny.vbo.draw(bind=False) glPopMatrix() glPopMatrix() fps.draw()
def on_draw(): window.clear() heightmap.update_from(texture) with nested(projection, Color, sun): glColor3f(0.5, 0.5, 0.5) glPushMatrix() glTranslatef(0, 0, -1) glRotatef(20, 1, 0, 0) glRotatef(angle, 0.0, 1.0, 0.0) glTranslatef(-0.5, 0, -0.5) heightmap.draw() glPopMatrix() texture.draw(10, 10) heightmap.vertex_texture.draw(148, 10) heightmap.normal_texture.draw(286, 10)
def on_draw(): window.clear() with nested(projection, Lighting, bunny.vbo): glClearColor(0.0, 0.0, 0.0, 0.0) glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT) glPushMatrix() glTranslatef(0, 0, -400) glRotatef(angle, 0.0, 1.0, 0.0) for x, y, z in positions: glPushMatrix() glTranslatef(x, y, z) bunny.vbo.draw(bind=False) glPopMatrix() glPopMatrix() fps.draw()
def on_draw(): window.clear() ripples.step() processor.copy(ripples.result, height_texture) gaussian.filter(height_texture, 2) heightmap.update_from(height_texture) with nested(projection, Color, sun): glColor3f(7/256.0, 121/256.0, 208/256.0) glPushMatrix() glTranslatef(0, 0, -1) glRotatef(10, 1, 0, 0) glRotatef(angle, 0.0, 1.0, 0.0) glTranslatef(-0.5, 0, -0.5) heightmap.draw() glPopMatrix() fps.draw() ripples.result.draw() heightmap.vertex_texture.draw(2*width, 0, scale=0.5) heightmap.normal_texture.draw(4*width, 0, scale=0.5)
def update_from(self, source): with nested(self.fbo, self.view, source, self.program): quad(self.width, self.height, 0, 0) self.vbo.vertices.copy_from(self.vertex_texture) self.vbo.normals.copy_from(self.normal_texture)