def _draw(self): p = self.parameters side = p.side height = side * numpy.sqrt(3) / 2. center = VisionEgg._get_center(p.position, p.anchor, (side, height)) position = numpy.array(center) hh = height / 2 ll = position - (hh, hh) lr = position - (-hh, hh) u = position + (0., hh) gl.glDisable(gl.GL_DEPTH_TEST) gl.glDisable(gl.GL_TEXTURE_2D) gl.glDisable(gl.GL_BLEND) gl.glColor(p.color) gl.glBegin(gl.GL_TRIANGLES) self._draw_vertices(ll, lr, u) gl.glEnd() gl.glColor(p.color_edge) if p.anti_aliasing: gl.glEnable(gl.GL_LINE_SMOOTH) gl.glLineWidth(p.width) gl.glBegin(gl.GL_LINE_STRIP) self._draw_vertices(ll, lr, u, ll) gl.glEnd() gl.glDisable(gl.GL_LINE_SMOOTH)
def draw_dots(xs,ys,zs): """Python method for drawing dots. May be replaced by a faster C version.""" if not (len(xs) == len(ys) == len(zs)): raise ValueError("All input arguments must be same length") gl.glBegin(gl.GL_POINTS) for i in xrange(len(xs)): gl.glVertex3f(xs[i],ys[i],zs[i]) gl.glEnd()
def _draw(self): p = self.parameters gl.glDisable(gl.GL_DEPTH_TEST) gl.glDisable(gl.GL_TEXTURE_2D) gl.glDisable(gl.GL_BLEND) gl.glColor(p.color) if p.anti_aliasing: gl.glEnable(gl.GL_LINE_SMOOTH) gl.glLineWidth(p.width) gl.glBegin(gl.GL_LINES) gl.glVertex(p.position) gl.glVertex(p.end) gl.glEnd() gl.glDisable(gl.GL_LINE_SMOOTH)
def draw(self): p = self.parameters if p.on: self._gl_color(*self._color) gl.glDisable(gl.GL_TEXTURE_2D) if p.depth_test: gl.glEnable(gl.GL_DEPTH_TEST) else: gl.glDisable(gl.GL_DEPTH_TEST) if p.blending_enabled: gl.glEnable(gl.GL_BLEND) else: gl.glDisable(gl.GL_BLEND) gl.glLineWidth(self._line_width) gl.glBegin(gl.GL_LINE_LOOP) for vertex in self._vertices: gl.glVertex(*vertex) gl.glEnd()
def draw(self): p = self.parameters # shorthand width = self.size[0] height = self.size[1] gl.glMatrixMode(gl.GL_PROJECTION) gl.glPushMatrix() gl.glLoadIdentity() gl.glOrtho(-width, width, -height, height, -200, 200) gl.glScalef(2, -2, 2) gl.glMatrixMode(gl.GL_MODELVIEW) if len(p.color)==3: gl.glColor3f(*p.color) elif len(p.color)==4: gl.glColor4f(*p.color) # this is necessary for the antialiasing gl.glDisable(gl.GL_DEPTH_TEST) gl.glDisable(gl.GL_TEXTURE_2D) gl.glEnable(gl.GL_LINE_SMOOTH) gl.glBlendFunc(gl.GL_SRC_ALPHA,gl.GL_ONE_MINUS_SRC_ALPHA) gl.glEnable(gl.GL_BLEND) gl.glLineWidth(p.line_width) # draw the polygon gl.glBegin(gl.GL_POLYGON) for point in p.points: gl.glVertex3f(point[0], point[1], 0.0) gl.glVertex3f(p.points[0][0], p.points[0][1], 0.0) gl.glEnd() # GL_LINE_STRIP gl.glDisable(gl.GL_LINE_SMOOTH) gl.glMatrixMode(gl.GL_PROJECTION) gl.glPopMatrix()
def draw(self): p = self.parameters # shorthand if p.on: if len(p.color) == 3: gl.glColor3f(*p.color) elif len(p.color) == 4: gl.glColor4f(*p.color) gl.glDisable(gl.GL_TEXTURE_2D) if p.depth_test: gl.glEnable(gl.GL_DEPTH_TEST) else: gl.glDisable(gl.GL_DEPTH_TEST) if p.blending_enabled: gl.glEnable(gl.GL_BLEND) else: gl.glDisable(gl.GL_BLEND) gl.glBegin(gl.GL_QUADS) gl.glVertex(*p.vertex1) gl.glVertex(*p.vertex2) gl.glVertex(*p.vertex3) gl.glVertex(*p.vertex4) gl.glEnd() # GL_QUADS
def draw(self): p = self.parameters # shorthand if p.on: if len(p.color)==3: gl.glColor3f(*p.color) elif len(p.color)==4: gl.glColor4f(*p.color) gl.glDisable(gl.GL_TEXTURE_2D) if p.depth_test: gl.glEnable(gl.GL_DEPTH_TEST) else: gl.glDisable(gl.GL_DEPTH_TEST) if p.blending_enabled: gl.glEnable(gl.GL_BLEND) else: gl.glDisable(gl.GL_BLEND) gl.glBegin(gl.GL_QUADS) gl.glVertex(*p.vertex1) gl.glVertex(*p.vertex2) gl.glVertex(*p.vertex3) gl.glVertex(*p.vertex4) gl.glEnd() # GL_QUADS
def _draw(self): p = self.parameters center = VisionEgg._get_center(p.position, p.anchor, (p.radius, p.radius)) gl.glDisable(gl.GL_DEPTH_TEST) gl.glDisable(gl.GL_TEXTURE_2D) gl.glDisable(gl.GL_BLEND) gl.glColor(p.color) start, end = p.start, p.end if end < start: start -= 360. start, end = map(numpy.deg2rad, (start, end)) frac = (end - start) / (2 * numpy.pi) num_triangles = float(p.num_triangles) * frac angles = numpy.linspace(start, end, num_triangles) verts = numpy.zeros((num_triangles, 2)) verts[:, 0] = center[0] + p.radius * numpy.cos(angles) verts[:, 1] = center[1] + p.radius * numpy.sin(angles) if p.disk: gl.glBegin(gl.GL_TRIANGLE_FAN) gl.glVertex(center) self._draw_vertices(*verts) gl.glEnd() if p.anti_aliasing: gl.glEnable(gl.GL_LINE_SMOOTH) gl.glBlendFunc(gl.GL_SRC_ALPHA, gl.GL_ONE_MINUS_SRC_ALPHA) gl.glEnable(gl.GL_BLEND) # Draw a second polygon in line mode, so the edges are anti-aliased gl.glPolygonMode(gl.GL_FRONT_AND_BACK, gl.GL_LINE) gl.glBegin(gl.GL_TRIANGLE_FAN) gl.glVertex(center) self._draw_vertices(*verts) gl.glEnd() gl.glPolygonMode(gl.GL_FRONT_AND_BACK, gl.GL_FILL) gl.glDisable(gl.GL_LINE_SMOOTH) if p.circle: if p.anti_aliasing: gl.glEnable(gl.GL_LINE_SMOOTH) gl.glColor(p.color_edge) gl.glLineWidth(p.circle_width) gl.glBegin(gl.GL_LINES) for i in range(verts.shape[0] - 1): self._draw_vertices(verts[i], verts[i + 1]) gl.glEnd() gl.glDisable(gl.GL_LINE_SMOOTH)
def _draw(self): p = self.parameters center = VisionEgg._get_center(p.position, p.anchor, (p.radius, p.radius)) gl.glDisable(gl.GL_DEPTH_TEST) gl.glDisable(gl.GL_TEXTURE_2D) gl.glDisable(gl.GL_BLEND) gl.glColor(p.color) start, end = p.start, p.end if end < start: start -= 360. start, end = map(numpy.deg2rad, (start, end)) frac = (end - start) / (2 * numpy.pi) num_triangles = float(p.num_triangles) * frac angles = numpy.linspace(start, end, num_triangles) verts = numpy.zeros((num_triangles, 2)) verts[:,0] = center[0] + p.radius * numpy.cos(angles) verts[:,1] = center[1] + p.radius * numpy.sin(angles) if p.disk: gl.glBegin(gl.GL_TRIANGLE_FAN) gl.glVertex(center) self._draw_vertices(*verts) gl.glEnd() if p.anti_aliasing: gl.glEnable(gl.GL_LINE_SMOOTH) gl.glBlendFunc(gl.GL_SRC_ALPHA, gl.GL_ONE_MINUS_SRC_ALPHA) gl.glEnable(gl.GL_BLEND) # Draw a second polygon in line mode, so the edges are anti-aliased gl.glPolygonMode(gl.GL_FRONT_AND_BACK, gl.GL_LINE) gl.glBegin(gl.GL_TRIANGLE_FAN) gl.glVertex(center) self._draw_vertices(*verts) gl.glEnd() gl.glPolygonMode(gl.GL_FRONT_AND_BACK, gl.GL_FILL) gl.glDisable(gl.GL_LINE_SMOOTH) if p.circle: if p.anti_aliasing: gl.glEnable(gl.GL_LINE_SMOOTH) gl.glColor(p.color_edge) gl.glLineWidth(p.circle_width) gl.glBegin(gl.GL_LINES) for i in range(verts.shape[0]-1): self._draw_vertices(verts[i], verts[i+1]) gl.glEnd() gl.glDisable(gl.GL_LINE_SMOOTH)
def draw(self): p = self.parameters # shorthand if p.center is not None: if not hasattr(VisionEgg.config,"_GAVE_CENTER_DEPRECATION"): logger = logging.getLogger('VisionEgg.MoreStimuli') logger.warning("Specifying Target2D by deprecated " "'center' parameter deprecated. Use " "'position' parameter instead. (Allows " "use of 'anchor' parameter to set to " "other values.)") VisionEgg.config._GAVE_CENTER_DEPRECATION = 1 p.anchor = 'center' p.position = p.center[0], p.center[1] # copy values (don't copy ref to tuple) if p.on: # calculate center center = VisionEgg._get_center(p.position,p.anchor,p.size) gl.glMatrixMode(gl.GL_MODELVIEW) gl.glPushMatrix() gl.glTranslate(center[0],center[1],0.0) gl.glRotate(p.orientation,0.0,0.0,1.0) if len(p.color)==3: gl.glColor3f(*p.color) elif len(p.color)==4: gl.glColor4f(*p.color) gl.glDisable(gl.GL_DEPTH_TEST) gl.glDisable(gl.GL_TEXTURE_2D) gl.glBlendFunc(gl.GL_SRC_ALPHA,gl.GL_ONE_MINUS_SRC_ALPHA) gl.glEnable(gl.GL_BLEND) w = p.size[0]/2.0 h = p.size[1]/2.0 gl.glBegin(gl.GL_QUADS) gl.glVertex3f(-w,-h, 0.0) gl.glVertex3f( w,-h, 0.0) gl.glVertex3f( w, h, 0.0) gl.glVertex3f(-w, h, 0.0) gl.glEnd() # GL_QUADS if p.anti_aliasing: if not self._gave_alpha_warning: if len(p.color) > 3 and p.color[3] != 1.0: logger = logging.getLogger('VisionEgg.MoreStimuli') logger.warning("The parameter anti_aliasing is " "set to true in the Target2D " "stimulus class, but the color " "parameter specifies an alpha " "value other than 1.0. To " "acheive anti-aliasing, ensure " "that the alpha value for the " "color parameter is 1.0.") self._gave_alpha_warning = 1 # We've already drawn a filled polygon (aliased), now # redraw the outline of the polygon (with # anti-aliasing). (Using GL_POLYGON_SMOOTH results in # artifactual lines where triangles were joined to # create quad, at least on some OpenGL # implementations.) # Calculate coverage value for each pixel of outline # and store as alpha gl.glEnable(gl.GL_LINE_SMOOTH) # Now specify how to use the alpha value gl.glBlendFunc(gl.GL_SRC_ALPHA,gl.GL_ONE_MINUS_SRC_ALPHA) gl.glEnable(gl.GL_BLEND) # Draw a second polygon in line mode, so the edges are anti-aliased gl.glPolygonMode(gl.GL_FRONT_AND_BACK,gl.GL_LINE) gl.glBegin(gl.GL_QUADS) gl.glVertex3f(-w,-h, 0.0); gl.glVertex3f( w,-h, 0.0); gl.glVertex3f( w, h, 0.0); gl.glVertex3f(-w, h, 0.0); gl.glEnd() # GL_QUADS # Set the polygon mode back to fill mode gl.glPolygonMode(gl.GL_FRONT_AND_BACK,gl.GL_FILL) gl.glDisable(gl.GL_LINE_SMOOTH) gl.glPopMatrix()
def draw(self): p = self.parameters # shorthand if p.center is not None: if not hasattr(VisionEgg.config, "_GAVE_CENTER_DEPRECATION"): logger = logging.getLogger('VisionEgg.MoreStimuli') logger.warning("Specifying Target2D by deprecated " "'center' parameter deprecated. Use " "'position' parameter instead. (Allows " "use of 'anchor' parameter to set to " "other values.)") VisionEgg.config._GAVE_CENTER_DEPRECATION = 1 p.anchor = 'center' p.position = p.center[0], p.center[ 1] # copy values (don't copy ref to tuple) if p.on: # calculate center center = VisionEgg._get_center(p.position, p.anchor, p.size) gl.glMatrixMode(gl.GL_MODELVIEW) gl.glPushMatrix() gl.glTranslate(center[0], center[1], 0.0) gl.glRotate(p.orientation, 0.0, 0.0, 1.0) if len(p.color) == 3: gl.glColor3f(*p.color) elif len(p.color) == 4: gl.glColor4f(*p.color) gl.glDisable(gl.GL_DEPTH_TEST) gl.glDisable(gl.GL_TEXTURE_2D) gl.glBlendFunc(gl.GL_SRC_ALPHA, gl.GL_ONE_MINUS_SRC_ALPHA) gl.glEnable(gl.GL_BLEND) w = p.size[0] / 2.0 h = p.size[1] / 2.0 gl.glBegin(gl.GL_QUADS) gl.glVertex3f(-w, -h, 0.0) gl.glVertex3f(w, -h, 0.0) gl.glVertex3f(w, h, 0.0) gl.glVertex3f(-w, h, 0.0) gl.glEnd() # GL_QUADS if p.anti_aliasing: if not self._gave_alpha_warning: if len(p.color) > 3 and p.color[3] != 1.0: logger = logging.getLogger('VisionEgg.MoreStimuli') logger.warning("The parameter anti_aliasing is " "set to true in the Target2D " "stimulus class, but the color " "parameter specifies an alpha " "value other than 1.0. To " "acheive anti-aliasing, ensure " "that the alpha value for the " "color parameter is 1.0.") self._gave_alpha_warning = 1 # We've already drawn a filled polygon (aliased), now # redraw the outline of the polygon (with # anti-aliasing). (Using GL_POLYGON_SMOOTH results in # artifactual lines where triangles were joined to # create quad, at least on some OpenGL # implementations.) # Calculate coverage value for each pixel of outline # and store as alpha gl.glEnable(gl.GL_LINE_SMOOTH) # Now specify how to use the alpha value gl.glBlendFunc(gl.GL_SRC_ALPHA, gl.GL_ONE_MINUS_SRC_ALPHA) gl.glEnable(gl.GL_BLEND) # Draw a second polygon in line mode, so the edges are anti-aliased gl.glPolygonMode(gl.GL_FRONT_AND_BACK, gl.GL_LINE) gl.glBegin(gl.GL_QUADS) gl.glVertex3f(-w, -h, 0.0) gl.glVertex3f(w, -h, 0.0) gl.glVertex3f(w, h, 0.0) gl.glVertex3f(-w, h, 0.0) gl.glEnd() # GL_QUADS # Set the polygon mode back to fill mode gl.glPolygonMode(gl.GL_FRONT_AND_BACK, gl.GL_FILL) gl.glDisable(gl.GL_LINE_SMOOTH) gl.glPopMatrix()
def draw(self): p = self.parameters # Shorthand if p.on: # Calculate center center = VisionEgg._get_center(p.position,p.anchor,p.size) gl.glMatrixMode(gl.GL_MODELVIEW) gl.glPushMatrix() gl.glTranslate(center[0],center[1],0.0) gl.glRotate(-p.orientation,0.0,0.0,1.0) if len(p.color)==3: gl.glColor3f(*p.color) elif len(p.color)==4: gl.glColor4f(*p.color) gl.glDisable(gl.GL_DEPTH_TEST) gl.glDisable(gl.GL_TEXTURE_2D) gl.glBlendFunc(gl.GL_SRC_ALPHA,gl.GL_ONE_MINUS_SRC_ALPHA) gl.glEnable(gl.GL_BLEND) w = p.size[0]/2.0 h = p.size[1]/2.0 gl.glBegin(gl.GL_QUADS) # Draw Rectangle gl.glVertex3f( 0.25*w, h, 0.0) gl.glVertex3f(-w, h, 0.0) gl.glVertex3f(-w,-h, 0.0) gl.glVertex3f( 0.25*w, -h, 0.0) gl.glEnd() # GL_QUADS gl.glBegin(gl.GL_TRIANGLES) # Draw Triangle gl.glVertex3f( 1.00*w, 0.0*h, 0.0) # Top gl.glVertex3f( 0.25*w,-3.0*h, 0.0) gl.glVertex3f( 0.25*w, 3.0*h, 0.0) gl.glEnd() # GL_QUADS if p.anti_aliasing: if not self._gave_alpha_warning: if len(p.color) > 3 and p.color[3] != 1.0: logger = logging.getLogger('VisionEgg.Arrow') logger.warning("The parameter anti_aliasing is " "set to true in the Arrow " "stimulus class, but the color " "parameter specifies an alpha " "value other than 1.0. To " "acheive anti-aliasing, ensure " "that the alpha value for the " "color parameter is 1.0.") self._gave_alpha_warning = 1 # We've already drawn a filled polygon (aliased), now redraw # the outline of the polygon (with anti-aliasing). (Using # GL_POLYGON_SMOOTH results in artifactual lines where # triangles were joined to create quad, at least on some OpenGL # implementations.) # Calculate coverage value for each pixel of outline # and store as alpha gl.glEnable(gl.GL_LINE_SMOOTH) # Now specify how to use the alpha value gl.glBlendFunc(gl.GL_SRC_ALPHA,gl.GL_ONE_MINUS_SRC_ALPHA) gl.glEnable(gl.GL_BLEND) # Draw a second polygon in line mode, so the edges are anti-aliased gl.glPolygonMode(gl.GL_FRONT_AND_BACK,gl.GL_LINE) gl.glBegin(gl.GL_QUADS) gl.glVertex3f( 0.25*w, h, 0.0) # Draw Rectangle gl.glVertex3f(-w, h, 0.0) gl.glVertex3f(-w,-h, 0.0) gl.glVertex3f( 0.25*w, -h, 0.0) gl.glVertex3f( 1.00*w, 0.0*h, 0.0) # Draw Triangle gl.glVertex3f( 0.25*w,-3.0*h, 0.0) gl.glVertex3f( 0.25*w, 3.0*h, 0.0) gl.glEnd() # GL_QUADS # Set the polygon mode back to fill mode gl.glPolygonMode(gl.GL_FRONT_AND_BACK,gl.GL_FILL) gl.glDisable(gl.GL_LINE_SMOOTH) gl.glPopMatrix()
def draw(self): p = self.parameters # shorthand if p.on: # calculate center center = VisionEgg._get_center(p.position,p.anchor,(p.radius, p.radius)) gl.glDisable(gl.GL_DEPTH_TEST) gl.glDisable(gl.GL_TEXTURE_2D) gl.glDisable(gl.GL_BLEND) if len(p.color)==3: gl.glColor3f(*p.color) elif len(p.color)==4: gl.glColor4f(*p.color) # Build filled circle from points # gl.glBegin(gl.GL_POINTS) # radius = int(math.ceil(p.radius)) # for i in range(-radius, radius): # for j in range(-radius, radius): # if(i * i + j * j < radius * radius): # gl.glVertex3f(p.position[0] + i, p.position[1] + j, 0.0) # gl.glEnd() # GL_POINTS # Build filled circle from triangles (this is typically faster # then the commented code above with the points) gl.glBegin(gl.GL_TRIANGLE_FAN) gl.glVertex3f(p.position[0], p.position[1], 0.0) angles = Numeric.arange(p.num_triangles)/float(p.num_triangles)*2.0*math.pi verts = Numeric.zeros( (p.num_triangles,2), Numeric.Float ) verts[:,0] = p.position[0] + p.radius * Numeric.cos(angles) verts[:,1] = p.position[1] + p.radius * Numeric.sin(angles) for i in range(verts.shape[0]): gl.glVertex2fv(verts[i]) gl.glVertex2fv(verts[0]) gl.glEnd() # GL_TRIANGLE_FAN if p.anti_aliasing: if not self._gave_alpha_warning: if len(p.color) > 3 and p.color[3] != 1.0: logger = logging.getLogger('VisionEgg.Arrow') logger.warning("The parameter anti_aliasing is " "set to true in the Arrow " "stimulus class, but the color " "parameter specifies an alpha " "value other than 1.0. To " "acheive anti-aliasing, ensure " "that the alpha value for the " "color parameter is 1.0.") self._gave_alpha_warning = 1 # We've already drawn a filled polygon (aliased), now redraw # the outline of the polygon (with anti-aliasing). (Using # GL_POLYGON_SMOOTH results in artifactual lines where # triangles were joined to create quad, at least on some OpenGL # implementations.) # Calculate coverage value for each pixel of outline # and store as alpha gl.glEnable(gl.GL_LINE_SMOOTH) # Now specify how to use the alpha value gl.glBlendFunc(gl.GL_SRC_ALPHA,gl.GL_ONE_MINUS_SRC_ALPHA) gl.glEnable(gl.GL_BLEND) # Draw a second polygon in line mode, so the edges are anti-aliased gl.glPolygonMode(gl.GL_FRONT_AND_BACK,gl.GL_LINE) gl.glBegin(gl.GL_TRIANGLE_FAN) gl.glVertex3f(p.position[0], p.position[1], 0.0) angles = Numeric.arange(p.num_triangles)/float(p.num_triangles)*2.0*math.pi verts = Numeric.zeros( (p.num_triangles,2), Numeric.Float ) verts[:,0] = p.position[0] + p.radius * Numeric.cos(angles) verts[:,1] = p.position[1] + p.radius * Numeric.sin(angles) for i in range(verts.shape[0]): gl.glVertex2fv(verts[i]) gl.glVertex2fv(verts[0]) gl.glEnd() # GL_TRIANGLE_FAN # Set the polygon mode back to fill mode gl.glPolygonMode(gl.GL_FRONT_AND_BACK,gl.GL_FILL) gl.glDisable(gl.GL_LINE_SMOOTH)
def draw(self): p = self.parameters # shorthand if p.on: # calculate center center = VisionEgg._get_center(p.position, p.anchor, p.size) if p.mask: gl.glActiveTextureARB(gl.GL_TEXTURE0_ARB) gl.glBindTexture(gl.GL_TEXTURE_1D, self._texture_object_id) gl.glEnable(gl.GL_TEXTURE_1D) gl.glDisable(gl.GL_TEXTURE_2D) if p.bit_depth != self.cached_bit_depth: self.calculate_bit_depth_dependencies() # Clear the modeview matrix gl.glMatrixMode(gl.GL_MODELVIEW) gl.glPushMatrix() # Rotate about the center of the texture gl.glTranslate(center[0], center[1], 0) gl.glRotate(p.orientation, 0, 0, 1) if p.depth is None: gl.glDisable(gl.GL_DEPTH_TEST) depth = 0.0 else: gl.glEnable(gl.GL_DEPTH_TEST) depth = p.depth # allow max_alpha value to control blending gl.glEnable(gl.GL_BLEND) gl.glBlendFunc(gl.GL_SRC_ALPHA, gl.GL_ONE_MINUS_SRC_ALPHA) if p.color2: gl.glTexEnvi(gl.GL_TEXTURE_ENV, gl.GL_TEXTURE_ENV_MODE, gl.GL_BLEND) gl.glTexEnvfv(gl.GL_TEXTURE_ENV, gl.GL_TEXTURE_ENV_COLOR, p.color2) ## alpha is ignored because the texture base internal format is luminance else: gl.glTexEnvi(gl.GL_TEXTURE_ENV, gl.GL_TEXTURE_ENV_MODE, gl.GL_MODULATE) if p.t0_time_sec_absolute is None and not p.ignore_time: p.t0_time_sec_absolute = VisionEgg.time_func() w = p.size[0] inc = w / float(p.num_samples) if p.ignore_time: phase = p.phase_at_t0 else: t_var = VisionEgg.time_func() - p.t0_time_sec_absolute phase = t_var * p.temporal_freq_hz * -360.0 + p.phase_at_t0 if p.recalculate_phase_tolerance is None or abs(self._last_phase - phase) > p.recalculate_phase_tolerance: self._last_phase = phase # we're re-drawing the phase at this angle floating_point_sin = ( numpy.sin( 2.0 * math.pi * p.spatial_freq * numpy.arange(0.0, w, inc, dtype=numpy.float) + (phase / 180.0 * math.pi) ) * 0.5 * p.contrast + p.pedestal ) floating_point_sin = numpy.clip( floating_point_sin, 0.0, 1.0 ) # allow square wave generation if contrast > 1 texel_data = (floating_point_sin * self.max_int_val).astype(self.numpy_dtype) # PyOpenGL 2.0.1.09 has a bug, so use our own wrapper _vegl.veglTexSubImage1D( gl.GL_TEXTURE_1D, # target 0, # level 0, # x offset p.num_samples, # width self.format, # format of new texel data self.gl_type, # type of new texel data texel_data, ) # new texel data if 0: compare_array = numpy.empty(texel_data.shape, dtype=texel_data.dtype) pixels = _vegl.veglGetTexImage( gl.GL_TEXTURE_1D, # target 0, # level self.format, # format self.gl_type, # type compare_array, ) assert numpy.allclose(compare_array, texel_data) h_w = p.size[0] / 2.0 h_h = p.size[1] / 2.0 l = -h_w r = h_w b = -h_h t = h_h # in the case of only color1, # the texel data multiplies color1 to produce a color # with color2, # the texel data linearly interpolates between color1 and color2 gl.glColor4f(p.color1[0], p.color1[1], p.color1[2], p.max_alpha) if p.mask: p.mask.draw_masked_quad( 0.0, 1.0, 0.0, 1.0, # l,r,b,t for texture coordinates l, r, b, t, # l,r,b,t in eye coordinates depth, ) # also in eye coordinates else: # draw unmasked quad gl.glBegin(gl.GL_QUADS) gl.glTexCoord2f(0.0, 0.0) gl.glVertex3f(l, b, depth) gl.glTexCoord2f(1.0, 0.0) gl.glVertex3f(r, b, depth) gl.glTexCoord2f(1.0, 1.0) gl.glVertex3f(r, t, depth) gl.glTexCoord2f(0.0, 1.0) gl.glVertex3f(l, t, depth) gl.glEnd() # GL_QUADS gl.glDisable(gl.GL_TEXTURE_1D) gl.glPopMatrix()
def draw(self): p = self.parameters # shorthand if p.on: if p.mask: gl.glActiveTextureARB(gl.GL_TEXTURE0_ARB) if p.depth_test: gl.glEnable(gl.GL_DEPTH_TEST) else: gl.glDisable(gl.GL_DEPTH_TEST) if p.polygon_offset_enabled: gl.glEnable(gl.GL_POLYGON_OFFSET_EXT) gl.glPolygonOffset(p.polygon_offset_factor, p.polygon_offset_units) gl.glBindTexture(gl.GL_TEXTURE_1D, self._texture_object_id) gl.glEnable(gl.GL_TEXTURE_1D) gl.glDisable(gl.GL_TEXTURE_2D) if p.bit_depth != self.cached_bit_depth: self.calculate_bit_depth_dependencies() # allow max_alpha value to control blending gl.glEnable(gl.GL_BLEND) gl.glBlendFunc(gl.GL_SRC_ALPHA, gl.GL_ONE_MINUS_SRC_ALPHA) if p.color2: gl.glTexEnvi(gl.GL_TEXTURE_ENV, gl.GL_TEXTURE_ENV_MODE, gl.GL_BLEND) gl.glTexEnvfv(gl.GL_TEXTURE_ENV, gl.GL_TEXTURE_ENV_COLOR, p.color2) ## alpha is ignored because the texture base internal format is luminance else: gl.glTexEnvi(gl.GL_TEXTURE_ENV, gl.GL_TEXTURE_ENV_MODE, gl.GL_MODULATE) if p.t0_time_sec_absolute is None and not p.ignore_time: p.t0_time_sec_absolute = VisionEgg.time_func() w = p.size[0] inc = w / float(p.num_samples) if p.ignore_time: phase = p.phase_at_t0 else: t_var = VisionEgg.time_func() - p.t0_time_sec_absolute phase = t_var * p.temporal_freq_hz * -360.0 + p.phase_at_t0 if p.recalculate_phase_tolerance is None or abs(self._last_phase - phase) > p.recalculate_phase_tolerance: self._last_phase = phase # we're re-drawing the phase at this angle floating_point_sin = ( numpy.sin( 2.0 * math.pi * p.spatial_freq * numpy.arange(0.0, w, inc, dtype=numpy.float) + (phase / 180.0 * math.pi) ) * 0.5 * p.contrast + p.pedestal ) floating_point_sin = numpy.clip( floating_point_sin, 0.0, 1.0 ) # allow square wave generation if contrast > 1 texel_data = (floating_point_sin * self.max_int_val).astype(self.numpy_dtype).tostring() gl.glTexSubImage1D( gl.GL_TEXTURE_1D, # target 0, # level 0, # x offset p.num_samples, # width self.format, # format of new texel data self.gl_type, # type of new texel data texel_data, ) # new texel data # in the case of only color1, # the texel data multiplies color1 to produce a color # with color2, # the texel data linearly interpolates between color1 and color2 gl.glColor4f(p.color1[0], p.color1[1], p.color1[2], p.max_alpha) if p.mask: p.mask.draw_masked_quad_3d( 0.0, 1.0, 0.0, 1.0, p.lowerleft, p.lowerright, p.upperright, p.upperleft # for texture coordinates ) else: # draw unmasked quad gl.glBegin(gl.GL_QUADS) gl.glTexCoord2f(0.0, 0.0) gl.glVertex(*p.lowerleft) gl.glTexCoord2f(1.0, 0.0) gl.glVertex(*p.lowerright) gl.glTexCoord2f(1.0, 1.0) gl.glVertex(*p.upperright) gl.glTexCoord2f(0.0, 1.0) gl.glVertex(*p.upperleft) gl.glEnd() # GL_QUADS gl.glDisable(gl.GL_TEXTURE_1D) if p.polygon_offset_enabled: gl.glDisable(gl.GL_POLYGON_OFFSET_EXT)
def draw(self): p = self.parameters # Shorthand if p.on: # Calculate center center = VisionEgg._get_center(p.position, p.anchor, p.size) gl.glMatrixMode(gl.GL_MODELVIEW) gl.glPushMatrix() gl.glTranslate(center[0], center[1], 0.0) gl.glRotate(-p.orientation, 0.0, 0.0, 1.0) if len(p.color) == 3: gl.glColor3f(*p.color) elif len(p.color) == 4: gl.glColor4f(*p.color) gl.glDisable(gl.GL_DEPTH_TEST) gl.glDisable(gl.GL_TEXTURE_2D) gl.glBlendFunc(gl.GL_SRC_ALPHA, gl.GL_ONE_MINUS_SRC_ALPHA) gl.glEnable(gl.GL_BLEND) w = p.size[0] / 2.0 h = p.size[1] / 2.0 gl.glBegin(gl.GL_QUADS) # Draw Rectangle gl.glVertex3f(0.25 * w, h, 0.0) gl.glVertex3f(-w, h, 0.0) gl.glVertex3f(-w, -h, 0.0) gl.glVertex3f(0.25 * w, -h, 0.0) gl.glEnd() # GL_QUADS gl.glBegin(gl.GL_TRIANGLES) # Draw Triangle gl.glVertex3f(1.00 * w, 0.0 * h, 0.0) # Top gl.glVertex3f(0.25 * w, -3.0 * h, 0.0) gl.glVertex3f(0.25 * w, 3.0 * h, 0.0) gl.glEnd() # GL_QUADS if p.anti_aliasing: if not self._gave_alpha_warning: if len(p.color) > 3 and p.color[3] != 1.0: logger = logging.getLogger('VisionEgg.Arrow') logger.warning("The parameter anti_aliasing is " "set to true in the Arrow " "stimulus class, but the color " "parameter specifies an alpha " "value other than 1.0. To " "acheive anti-aliasing, ensure " "that the alpha value for the " "color parameter is 1.0.") self._gave_alpha_warning = 1 # We've already drawn a filled polygon (aliased), now redraw # the outline of the polygon (with anti-aliasing). (Using # GL_POLYGON_SMOOTH results in artifactual lines where # triangles were joined to create quad, at least on some OpenGL # implementations.) # Calculate coverage value for each pixel of outline # and store as alpha gl.glEnable(gl.GL_LINE_SMOOTH) # Now specify how to use the alpha value gl.glBlendFunc(gl.GL_SRC_ALPHA, gl.GL_ONE_MINUS_SRC_ALPHA) gl.glEnable(gl.GL_BLEND) # Draw a second polygon in line mode, so the edges are anti-aliased gl.glPolygonMode(gl.GL_FRONT_AND_BACK, gl.GL_LINE) gl.glBegin(gl.GL_QUADS) gl.glVertex3f(0.25 * w, h, 0.0) # Draw Rectangle gl.glVertex3f(-w, h, 0.0) gl.glVertex3f(-w, -h, 0.0) gl.glVertex3f(0.25 * w, -h, 0.0) gl.glVertex3f(1.00 * w, 0.0 * h, 0.0) # Draw Triangle gl.glVertex3f(0.25 * w, -3.0 * h, 0.0) gl.glVertex3f(0.25 * w, 3.0 * h, 0.0) gl.glEnd() # GL_QUADS # Set the polygon mode back to fill mode gl.glPolygonMode(gl.GL_FRONT_AND_BACK, gl.GL_FILL) gl.glDisable(gl.GL_LINE_SMOOTH) gl.glPopMatrix()
def draw(self): p = self.parameters # shorthand if p.on: # calculate center center = VisionEgg._get_center(p.position, p.anchor, (p.radius, p.radius)) gl.glDisable(gl.GL_DEPTH_TEST) gl.glDisable(gl.GL_TEXTURE_2D) gl.glDisable(gl.GL_BLEND) if len(p.color) == 3: gl.glColor3f(*p.color) elif len(p.color) == 4: gl.glColor4f(*p.color) # Build filled circle from points # gl.glBegin(gl.GL_POINTS) # radius = int(math.ceil(p.radius)) # for i in range(-radius, radius): # for j in range(-radius, radius): # if(i * i + j * j < radius * radius): # gl.glVertex3f(p.position[0] + i, p.position[1] + j, 0.0) # gl.glEnd() # GL_POINTS # Build filled circle from triangles (this is typically faster # then the commented code above with the points) gl.glBegin(gl.GL_TRIANGLE_FAN) gl.glVertex3f(p.position[0], p.position[1], 0.0) angles = Numeric.arange(p.num_triangles) / float( p.num_triangles) * 2.0 * math.pi verts = Numeric.zeros((p.num_triangles, 2), Numeric.Float) verts[:, 0] = p.position[0] + p.radius * Numeric.cos(angles) verts[:, 1] = p.position[1] + p.radius * Numeric.sin(angles) for i in range(verts.shape[0]): gl.glVertex2fv(verts[i]) gl.glVertex2fv(verts[0]) gl.glEnd() # GL_TRIANGLE_FAN if p.anti_aliasing: if not self._gave_alpha_warning: if len(p.color) > 3 and p.color[3] != 1.0: logger = logging.getLogger('VisionEgg.Arrow') logger.warning("The parameter anti_aliasing is " "set to true in the Arrow " "stimulus class, but the color " "parameter specifies an alpha " "value other than 1.0. To " "acheive anti-aliasing, ensure " "that the alpha value for the " "color parameter is 1.0.") self._gave_alpha_warning = 1 # We've already drawn a filled polygon (aliased), now redraw # the outline of the polygon (with anti-aliasing). (Using # GL_POLYGON_SMOOTH results in artifactual lines where # triangles were joined to create quad, at least on some OpenGL # implementations.) # Calculate coverage value for each pixel of outline # and store as alpha gl.glEnable(gl.GL_LINE_SMOOTH) # Now specify how to use the alpha value gl.glBlendFunc(gl.GL_SRC_ALPHA, gl.GL_ONE_MINUS_SRC_ALPHA) gl.glEnable(gl.GL_BLEND) # Draw a second polygon in line mode, so the edges are anti-aliased gl.glPolygonMode(gl.GL_FRONT_AND_BACK, gl.GL_LINE) gl.glBegin(gl.GL_TRIANGLE_FAN) gl.glVertex3f(p.position[0], p.position[1], 0.0) angles = Numeric.arange(p.num_triangles) / float( p.num_triangles) * 2.0 * math.pi verts = Numeric.zeros((p.num_triangles, 2), Numeric.Float) verts[:, 0] = p.position[0] + p.radius * Numeric.cos(angles) verts[:, 1] = p.position[1] + p.radius * Numeric.sin(angles) for i in range(verts.shape[0]): gl.glVertex2fv(verts[i]) gl.glVertex2fv(verts[0]) gl.glEnd() # GL_TRIANGLE_FAN # Set the polygon mode back to fill mode gl.glPolygonMode(gl.GL_FRONT_AND_BACK, gl.GL_FILL) gl.glDisable(gl.GL_LINE_SMOOTH)
def draw(self): p = self.parameters # shorthand if p.on: # calculate center center = VisionEgg._get_center(p.position,p.anchor,p.size) if p.mask: gl.glActiveTextureARB(gl.GL_TEXTURE0_ARB) gl.glBindTexture(gl.GL_TEXTURE_1D,self._texture_object_id) gl.glEnable(gl.GL_TEXTURE_1D) gl.glDisable(gl.GL_TEXTURE_2D) if p.bit_depth != self.cached_bit_depth: self.calculate_bit_depth_dependencies() # Clear the modeview matrix gl.glMatrixMode(gl.GL_MODELVIEW) gl.glPushMatrix() # Rotate about the center of the texture gl.glTranslate(center[0], center[1], 0) gl.glRotate(p.orientation,0,0,1) if p.depth is None: gl.glDisable(gl.GL_DEPTH_TEST) depth = 0.0 else: gl.glEnable(gl.GL_DEPTH_TEST) depth = p.depth # allow max_alpha value to control blending gl.glEnable( gl.GL_BLEND ) gl.glBlendFunc( gl.GL_SRC_ALPHA, gl.GL_ONE_MINUS_SRC_ALPHA ) if p.color2: gl.glTexEnvi(gl.GL_TEXTURE_ENV, gl.GL_TEXTURE_ENV_MODE, gl.GL_BLEND) gl.glTexEnvfv(gl.GL_TEXTURE_ENV, gl.GL_TEXTURE_ENV_COLOR, p.color2) ## alpha is ignored because the texture base internal format is luminance else: gl.glTexEnvi(gl.GL_TEXTURE_ENV, gl.GL_TEXTURE_ENV_MODE, gl.GL_MODULATE) if p.t0_time_sec_absolute is None and not p.ignore_time: p.t0_time_sec_absolute = VisionEgg.time_func() w = p.size[0] inc = w/float(p.num_samples) if p.ignore_time: phase = p.phase_at_t0 else: t_var = VisionEgg.time_func() - p.t0_time_sec_absolute phase = t_var*p.temporal_freq_hz*-360.0 + p.phase_at_t0 if p.recalculate_phase_tolerance is None or abs(self._last_phase - phase) > p.recalculate_phase_tolerance: self._last_phase = phase # we're re-drawing the phase at this angle floating_point_sin = numpy.sin(2.0*math.pi*p.spatial_freq*numpy.arange(0.0,w,inc,dtype=numpy.float)+(phase/180.0*math.pi))*0.5*p.contrast+p.pedestal floating_point_sin = numpy.clip(floating_point_sin,0.0,1.0) # allow square wave generation if contrast > 1 texel_data = (floating_point_sin*self.max_int_val).astype(self.numpy_dtype) # PyOpenGL 2.0.1.09 has a bug, so use our own wrapper _vegl.veglTexSubImage1D(gl.GL_TEXTURE_1D, # target 0, # level 0, # x offset p.num_samples, # width self.format, # format of new texel data self.gl_type, # type of new texel data texel_data) # new texel data if 0: compare_array = numpy.empty(texel_data.shape,dtype=texel_data.dtype) pixels = _vegl.veglGetTexImage(gl.GL_TEXTURE_1D, # target 0, # level self.format, # format self.gl_type, # type compare_array) assert numpy.allclose( compare_array, texel_data ) h_w = p.size[0]/2.0 h_h = p.size[1]/2.0 l = -h_w r = h_w b = -h_h t = h_h # in the case of only color1, # the texel data multiplies color1 to produce a color # with color2, # the texel data linearly interpolates between color1 and color2 gl.glColor4f(p.color1[0],p.color1[1],p.color1[2],p.max_alpha) if p.mask: p.mask.draw_masked_quad(0.0,1.0,0.0,1.0, # l,r,b,t for texture coordinates l,r,b,t, # l,r,b,t in eye coordinates depth ) # also in eye coordinates else: # draw unmasked quad gl.glBegin(gl.GL_QUADS) gl.glTexCoord2f(0.0,0.0) gl.glVertex3f(l,b,depth) gl.glTexCoord2f(1.0,0.0) gl.glVertex3f(r,b,depth) gl.glTexCoord2f(1.0,1.0) gl.glVertex3f(r,t,depth) gl.glTexCoord2f(0.0,1.0) gl.glVertex3f(l,t,depth) gl.glEnd() # GL_QUADS gl.glDisable(gl.GL_TEXTURE_1D) gl.glPopMatrix()
def draw(self): p = self.parameters # shorthand if p.on: if p.mask: gl.glActiveTextureARB(gl.GL_TEXTURE0_ARB) if p.depth_test: gl.glEnable(gl.GL_DEPTH_TEST) else: gl.glDisable(gl.GL_DEPTH_TEST) if p.polygon_offset_enabled: gl.glEnable(gl.GL_POLYGON_OFFSET_EXT) gl.glPolygonOffset(p.polygon_offset_factor, p.polygon_offset_units) gl.glBindTexture(gl.GL_TEXTURE_1D,self._texture_object_id) gl.glEnable(gl.GL_TEXTURE_1D) gl.glDisable(gl.GL_TEXTURE_2D) if p.bit_depth != self.cached_bit_depth: self.calculate_bit_depth_dependencies() # allow max_alpha value to control blending gl.glEnable( gl.GL_BLEND ) gl.glBlendFunc( gl.GL_SRC_ALPHA, gl.GL_ONE_MINUS_SRC_ALPHA ) if p.color2: gl.glTexEnvi(gl.GL_TEXTURE_ENV, gl.GL_TEXTURE_ENV_MODE, gl.GL_BLEND) gl.glTexEnvfv(gl.GL_TEXTURE_ENV, gl.GL_TEXTURE_ENV_COLOR, p.color2) ## alpha is ignored because the texture base internal format is luminance else: gl.glTexEnvi(gl.GL_TEXTURE_ENV, gl.GL_TEXTURE_ENV_MODE, gl.GL_MODULATE) if p.t0_time_sec_absolute is None and not p.ignore_time: p.t0_time_sec_absolute = VisionEgg.time_func() w = p.size[0] inc = w/float(p.num_samples) if p.ignore_time: phase = p.phase_at_t0 else: t_var = VisionEgg.time_func() - p.t0_time_sec_absolute phase = t_var*p.temporal_freq_hz*-360.0 + p.phase_at_t0 if p.recalculate_phase_tolerance is None or abs(self._last_phase - phase) > p.recalculate_phase_tolerance: self._last_phase = phase # we're re-drawing the phase at this angle floating_point_sin = numpy.sin(2.0*math.pi*p.spatial_freq*numpy.arange(0.0,w,inc,dtype=numpy.float)+(phase/180.0*math.pi))*0.5*p.contrast+p.pedestal floating_point_sin = numpy.clip(floating_point_sin,0.0,1.0) # allow square wave generation if contrast > 1 texel_data = (floating_point_sin*self.max_int_val).astype(self.numpy_dtype).tostring() gl.glTexSubImage1D(gl.GL_TEXTURE_1D, # target 0, # level 0, # x offset p.num_samples, # width self.format, # format of new texel data self.gl_type, # type of new texel data texel_data) # new texel data # in the case of only color1, # the texel data multiplies color1 to produce a color # with color2, # the texel data linearly interpolates between color1 and color2 gl.glColor4f(p.color1[0],p.color1[1],p.color1[2],p.max_alpha) if p.mask: p.mask.draw_masked_quad_3d(0.0,1.0,0.0,1.0, # for texture coordinates p.lowerleft,p.lowerright,p.upperright,p.upperleft) else: # draw unmasked quad gl.glBegin(gl.GL_QUADS) gl.glTexCoord2f(0.0,0.0) gl.glVertex(*p.lowerleft) gl.glTexCoord2f(1.0,0.0) gl.glVertex(*p.lowerright) gl.glTexCoord2f(1.0,1.0) gl.glVertex(*p.upperright) gl.glTexCoord2f(0.0,1.0) gl.glVertex(*p.upperleft) gl.glEnd() # GL_QUADS gl.glDisable(gl.GL_TEXTURE_1D) if p.polygon_offset_enabled: gl.glDisable(gl.GL_POLYGON_OFFSET_EXT)
def draw(self): """Redraw the stimulus on every frame. """ p = self.parameters if p.texture != self._using_texture: # self._using_texture is from TextureStimulusBaseClass self._reload_texture() self.rebuild_display_list() if p.on: # Set OpenGL state variables if p.depth_test: gl.glEnable( gl.GL_DEPTH_TEST ) else: gl.glDisable( gl.GL_DEPTH_TEST ) gl.glEnable( gl.GL_TEXTURE_2D ) # Make sure textures are drawn gl.glEnable( gl.GL_BLEND ) # Contrast control implemented through blending # All of the contrast control stuff is somewhat arcane and # not very clear from reading the code, so here is how it # works in English. (Not that it makes it any more clear!) # # In the final "textured fragment" (before being blended # to the framebuffer), the color values are equal to those # of the texture (with the exception of texels around the # edges which have their amplitudes reduced due to # anti-aliasing and are intermediate between the color of # the texture and mid-gray), and the alpha value is set to # the contrast. Blending occurs, and by choosing the # appropriate values for glBlendFunc, adds the product of # fragment alpha (contrast) and fragment color to the # product of one minus fragment alpha (contrast) and what # was already in the framebuffer. gl.glBlendFunc( gl.GL_SRC_ALPHA, gl.GL_ONE_MINUS_SRC_ALPHA ) gl.glTexEnvi(gl.GL_TEXTURE_ENV, gl.GL_TEXTURE_ENV_MODE, gl.GL_DECAL) # clear modelview matrix gl.glMatrixMode(gl.GL_MODELVIEW) gl.glPushMatrix() try: gl.glColor4f(0.5,0.5,0.5,p.contrast) # Set the polygons' fragment color (implements contrast) if not self.constant_parameters.mipmaps_enabled: if p.texture_min_filter in TextureStimulusBaseClass._mipmap_modes: raise RuntimeError("Specified a mipmap mode in texture_min_filter, but mipmaps not enabled.") self.texture_object.set_min_filter( p.texture_min_filter ) self.texture_object.set_mag_filter( p.texture_mag_filter ) self.texture_object.set_wrap_mode_s( p.texture_wrap_s ) self.texture_object.set_wrap_mode_t( p.texture_wrap_t ) if 1: tex_phase = p.tex_phase % 1.0 # make 0 <= tex_phase < 1.0 TINY = 1.0e-10 tex = p.texture tex.update() if tex_phase < TINY: # it's effectively zero gl.glBegin(gl.GL_QUADS) gl.glTexCoord2f(tex.buf_lf,tex.buf_bf) gl.glVertex(*p.lowerleft) gl.glTexCoord2f(tex.buf_rf,tex.buf_bf) gl.glVertex(*p.lowerright) gl.glTexCoord2f(tex.buf_rf,tex.buf_tf) gl.glVertex(*p.upperright) gl.glTexCoord2f(tex.buf_lf,tex.buf_tf) gl.glVertex(*p.upperleft) gl.glEnd() # GL_QUADS else: # Convert tex_phase into texture buffer fraction buf_break_f = ( (tex.buf_rf - tex.buf_lf) * (1.0-tex_phase) ) + tex.buf_lf r = cgtypes.vec3(p.lowerright) l = cgtypes.vec3(p.lowerleft) quad_x_lower = (r-l)*tex_phase + l r = cgtypes.vec3(p.upperright) l = cgtypes.vec3(p.upperleft) quad_x_upper = (r-l)*tex_phase + l gl.glBegin(gl.GL_QUADS) # First quad gl.glTexCoord2f(buf_break_f,tex.buf_bf) gl.glVertex(*p.lowerleft) gl.glTexCoord2f(tex.buf_rf,tex.buf_bf) gl.glVertex(*quad_x_lower) gl.glTexCoord2f(tex.buf_rf,tex.buf_tf) gl.glVertex(*quad_x_upper) gl.glTexCoord2f(buf_break_f,tex.buf_tf) gl.glVertex(*p.upperleft) # Second quad gl.glTexCoord2f(tex.buf_lf,tex.buf_bf) gl.glVertex(*quad_x_lower) gl.glTexCoord2f(buf_break_f,tex.buf_bf) gl.glVertex(*p.lowerright) gl.glTexCoord2f(buf_break_f,tex.buf_tf) gl.glVertex(*p.upperright) gl.glTexCoord2f(tex.buf_lf,tex.buf_tf) gl.glVertex(*quad_x_upper) gl.glEnd() # GL_QUADS finally: gl.glMatrixMode(gl.GL_MODELVIEW) gl.glPopMatrix()