예제 #1
0
        def draw(self):
            if self.parameters.on:
                gl.glDisable(gl.GL_TEXTURE_2D)
                gl.glDisable(gl.GL_BLEND)
                gl.glDisable(gl.GL_DEPTH_TEST)

                gl.glMatrixMode(gl.GL_MODELVIEW)
                gl.glPushMatrix()
                gl.glTranslate(self.parameters.lowerleft[0],self.parameters.lowerleft[1],0.0)

                c = self.parameters.color

                if len(c)==3:
                    gl.glColor3f(*c)
                elif len(c)==4:
                    gl.glColor4f(*c)
                gl.glDisable(gl.GL_TEXTURE_2D)

                gl.glRasterPos3f(0.0,0.0,0.0)
                for char in self.parameters.text:
                    glut.glutBitmapCharacter(self.parameters.font,ord(char))
                gl.glPopMatrix()
예제 #2
0
        def draw(self):
            if self.parameters.on:
                gl.glDisable(gl.GL_TEXTURE_2D)
                gl.glDisable(gl.GL_DEPTH_TEST)

                gl.glMatrixMode(gl.GL_MODELVIEW)
                gl.glPushMatrix()
                gl.glTranslate(self.parameters.lowerleft[0],
                               self.parameters.lowerleft[1], 0.0)
                gl.glRotate(self.parameters.orientation, 0.0, 0.0, 1.0)

                c = self.parameters.color
                if len(c) == 3:
                    gl.glColor3f(*c)
                elif len(c) == 4:
                    gl.glColor4f(*c)

                gl.glLineWidth(self.parameters.linewidth)

                if self.parameters.anti_aliasing:
                    gl.glEnable(gl.GL_BLEND)
                    gl.glBlendFunc(gl.GL_SRC_ALPHA, gl.GL_ONE_MINUS_SRC_ALPHA)
                    gl.glEnable(gl.GL_LINE_SMOOTH)
                else:
                    gl.glDisable(gl.GL_BLEND)

    ##            # This code successfully draws a box...
    ##            gl.glBegin(gl.GL_QUADS)
    ##            gl.glVertex2f(0.0,0.0)
    ##            gl.glVertex2f(0.0,0.1)
    ##            gl.glVertex2f(0.1,0.1)
    ##            gl.glVertex2f(0.1,0.0)
    ##            gl.glEnd()

    # But this code does not draw the string!?!
                for char in self.parameters.text:
                    glut.glutStrokeCharacter(self.parameters.font, ord(char))
                gl.glPopMatrix()
예제 #3
0
        def draw(self):
            if self.parameters.on:
                gl.glDisable(gl.GL_TEXTURE_2D)
                gl.glDisable(gl.GL_BLEND)
                gl.glDisable(gl.GL_DEPTH_TEST)

                gl.glMatrixMode(gl.GL_MODELVIEW)
                gl.glPushMatrix()
                gl.glTranslate(self.parameters.lowerleft[0],
                               self.parameters.lowerleft[1], 0.0)

                c = self.parameters.color

                if len(c) == 3:
                    gl.glColor3f(*c)
                elif len(c) == 4:
                    gl.glColor4f(*c)
                gl.glDisable(gl.GL_TEXTURE_2D)

                gl.glRasterPos3f(0.0, 0.0, 0.0)
                for char in self.parameters.text:
                    glut.glutBitmapCharacter(self.parameters.font, ord(char))
                gl.glPopMatrix()
예제 #4
0
        def draw(self):
            if self.parameters.on:
                gl.glDisable(gl.GL_TEXTURE_2D)
                gl.glDisable(gl.GL_DEPTH_TEST)

                gl.glMatrixMode(gl.GL_MODELVIEW)
                gl.glPushMatrix()
                gl.glTranslate(self.parameters.lowerleft[0],self.parameters.lowerleft[1],0.0)
                gl.glRotate(self.parameters.orientation,0.0,0.0,1.0)

                c = self.parameters.color
                if len(c)==3:
                    gl.glColor3f(*c)
                elif len(c)==4:
                    gl.glColor4f(*c)

                gl.glLineWidth(self.parameters.linewidth)

                if self.parameters.anti_aliasing:
                    gl.glEnable(gl.GL_BLEND)
                    gl.glBlendFunc(gl.GL_SRC_ALPHA,gl.GL_ONE_MINUS_SRC_ALPHA)
                    gl.glEnable(gl.GL_LINE_SMOOTH)
                else:
                    gl.glDisable(gl.GL_BLEND)

    ##            # This code successfully draws a box...
    ##            gl.glBegin(gl.GL_QUADS)
    ##            gl.glVertex2f(0.0,0.0)
    ##            gl.glVertex2f(0.0,0.1)
    ##            gl.glVertex2f(0.1,0.1)
    ##            gl.glVertex2f(0.1,0.0)
    ##            gl.glEnd()

                # But this code does not draw the string!?!
                for char in self.parameters.text:
                    glut.glutStrokeCharacter(self.parameters.font,ord(char))
                gl.glPopMatrix()
예제 #5
0
    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
예제 #6
0
    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()
예제 #7
0
    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
예제 #8
0
    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()
예제 #9
0
    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)
예제 #10
0
    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()
예제 #11
0
    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()
예제 #12
0
    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)
예제 #13
0
    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()
예제 #14
0
    def draw(self):
        p = self.parameters  # shorthand
        if p.center is not None:
            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.bgcolor) == 3:
                gl.glColor3f(*p.bgcolor)
            elif len(p.bgcolor) == 4:
                gl.glColor4f(*p.bgcolor)
            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  #grid half-size
            h = p.size[1] / 2.0
            m = p.size[0] / p.grid[0]  #cell size
            n = p.size[1] / p.grid[1]
            i = range(p.grid[0])  #grid index
            j = range(p.grid[1])
            #draw colorful cell
            #           vertices_list = [((-w+column*m, h-(row+1)*n, 0.0),(-w+column*m, h-row*n, 0.0),\
            #                         (-w+(column+1)*m, h-row*n, 0.0),(-w+(column+1)*m, h-row*n, 0.0))\
            #                         for column in j for row in i]
            vertices_list = [((-w+column*m, h-(row+1)*n, 0.0),(-w+column*m, h-row*n, 0.0),\
                              (-w+(column+1)*m, h-row*n, 0.0),(-w+(column+1)*m, h-(row+1)*n, 0.0))\
                         for column in j for row in i]
            colors_list = [
                colormap(p.colorindex[row, column], color=p.cellcolor) * 4
                for column in j for row in i
            ]
            #flattening the vertices and colors
            vertices_flat = [
                num for tuple in vertices_list for vertex in tuple
                for num in vertex
            ]
            colors_flat = [num for tuple in colors_list for num in tuple]
            vertices = np.array(vertices_flat)
            colors = np.array(colors_flat)
            vertices.shape = (-1, 3)
            colors.shape = (-1, 3)
            gl.glVertexPointerd(vertices)
            gl.glColorPointerd(colors)
            gl.glEnableClientState(gl.GL_VERTEX_ARRAY)
            gl.glEnableClientState(gl.GL_COLOR_ARRAY)
            gl.glDisable(gl.GL_LIGHTING)
            gl.glDrawArrays(gl.GL_QUADS, 0, p.grid[0] * p.grid[1] * 4)

            #draw grid lines
            if p.drawline:
                if len(p.linecolor) == 3:
                    gl.glColor3f(*p.linecolor)
                elif len(p.linecolor) == 4:
                    gl.glColor4f(*p.linecolor)

                row_list = [((-w, h - i * n), (w, h - i * n))
                            for i in range(p.grid[1] + 1)]
                col_list = [((-w + i * m, h), (-w + i * m, -h))
                            for i in range(p.grid[0] + 1)]
                ver_row_flat = [
                    num for tuple in row_list for vertex in tuple
                    for num in vertex
                ]
                ver_col_flat = [
                    num for tuple in col_list for vertex in tuple
                    for num in vertex
                ]
                vertices_row = np.array(ver_row_flat)
                vertices_col = np.array(ver_col_flat)
                vertices_row.shape = (-1, 2)
                vertices_col.shape = (-1, 2)

                gl.glEnableClientState(gl.GL_VERTEX_ARRAY)
                gl.glDisableClientState(gl.GL_COLOR_ARRAY)
                gl.glVertexPointerd(vertices_row)
                gl.glDrawArrays(gl.GL_LINES, 0, (p.grid[1] + 1) * 2)
                gl.glVertexPointerd(vertices_col)
                gl.glDrawArrays(gl.GL_LINES, 0, (p.grid[0] + 1) * 2)

#                gl.glBegin(gl.GL_LINES);
#                for i in range(p.grid[1] + 1):
#                    gl.glVertex2f(-w, h - i * n)
#                    gl.glVertex2f(w, h - i * n)
#                for i in range(p.grid[0] + 1):
#                    gl.glVertex2f(-w + i * m, h)
#                    gl.glVertex2f(-w + i * m, -h)
#                gl.glEnd();
            gl.glPopMatrix()
예제 #15
0
    def draw(self):
        # XXX This method is not speed-optimized. I just wrote it to
        # get the job done. (Nonetheless, it seems faster than the C
        # version commented out above.)

        p = self.parameters # shorthand
        if p.center is not None:
            if not hasattr(VisionEgg.config,"_GAVE_CENTER_DEPRECATION"):
                logger = logging.getLogger('VisionEgg.Dots')
                logger.warning("Specifying DotArea2D 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)

            if p.anti_aliasing:
                if len(p.color) == 4 and not self._gave_alpha_warning:
                    if p.color[3] != 1.0:
                        logger = logging.getLogger('VisionEgg.Dots')
                        logger.warning("The parameter anti_aliasing is "
                                       "set to true in the DotArea2D "
                                       "stimulus class, but the color "
                                       "parameter specifies an alpha "
                                       "value other than 1.0.  To "
                                       "acheive the best anti-aliasing, "
                                       "ensure that the alpha value for "
                                       "the color parameter is 1.0.")
                        self._gave_alpha_warning = 1
                gl.glEnable( gl.GL_POINT_SMOOTH )
                # allow max_alpha value to control blending
                gl.glEnable( gl.GL_BLEND )
                gl.glBlendFunc( gl.GL_SRC_ALPHA, gl.GL_ONE_MINUS_SRC_ALPHA )
            else:
                gl.glDisable( gl.GL_BLEND )

            now_sec = VisionEgg.time_func()
            if self.start_times_sec is not None:
                # compute extinct dots and generate new positions
                replace_indices = Numeric.nonzero( Numeric.greater( now_sec - self.start_times_sec, p.dot_lifespan_sec) )
                Numeric.put( self.start_times_sec, replace_indices, now_sec )

                new_x_positions = RandomArray.uniform(0.0,1.0,
                                                      (len(replace_indices),))
                Numeric.put( self.x_positions, replace_indices, new_x_positions )

                new_y_positions = RandomArray.uniform(0.0,1.0,
                                                      (len(replace_indices),))
                Numeric.put( self.y_positions, replace_indices, new_y_positions )

                new_random_directions_radians = RandomArray.uniform(0.0,2*math.pi,
                                                                    (len(replace_indices),))
                Numeric.put( self.random_directions_radians, replace_indices, new_random_directions_radians )
            else:
                # initialize dot extinction values to random (uniform) distribution
                self.start_times_sec = RandomArray.uniform( now_sec - p.dot_lifespan_sec, now_sec,
                                                            (self.constant_parameters.num_dots,))

            signal_num_dots = int(round(p.signal_fraction * self.constant_parameters.num_dots))
            time_delta_sec = now_sec - self.last_time_sec
            self.last_time_sec = now_sec # reset for next loop
            x_increment_normalized =  math.cos(p.signal_direction_deg/180.0*math.pi) * p.velocity_pixels_per_sec / p.size[0] * time_delta_sec
            y_increment_normalized = -math.sin(p.signal_direction_deg/180.0*math.pi) * p.velocity_pixels_per_sec / p.size[1] * time_delta_sec
            self.x_positions[:signal_num_dots] += x_increment_normalized
            self.y_positions[:signal_num_dots] += y_increment_normalized

            num_random_dots = self.constant_parameters.num_dots - signal_num_dots
            random_x_increment_normalized =  Numeric.cos(self.random_directions_radians[signal_num_dots:]) * p.velocity_pixels_per_sec / p.size[0] * time_delta_sec
            random_y_increment_normalized = -Numeric.sin(self.random_directions_radians[signal_num_dots:]) * p.velocity_pixels_per_sec / p.size[1] * time_delta_sec
            self.x_positions[signal_num_dots:] += random_x_increment_normalized
            self.y_positions[signal_num_dots:] += random_y_increment_normalized

            self.x_positions = Numeric.fmod( self.x_positions, 1.0 ) # wrap
            self.y_positions = Numeric.fmod( self.y_positions, 1.0 )

            self.x_positions = Numeric.fmod( self.x_positions+1, 1.0 ) # wrap again for values < 1
            self.y_positions = Numeric.fmod( self.y_positions+1, 1.0 )

            xs = (self.x_positions - 0.5) * p.size[0] + center[0]
            ys = (self.y_positions - 0.5) * p.size[1] + center[1]

            if len(p.color)==3:
                gl.glColor3f(*p.color)
            elif len(p.color)==4:
                gl.glColor4f(*p.color)
            gl.glPointSize(p.dot_size)

            # Clear the modeview matrix
            gl.glMatrixMode(gl.GL_MODELVIEW)
            gl.glPushMatrix()

            gl.glDisable(gl.GL_TEXTURE_2D)

            if p.depth is None:
                depth = 0.0
            else:
                gl.glEnable(gl.GL_DEPTH_TEST)
                depth = p.depth
            zs = (depth,)*len(xs) # make N tuple with repeat value of depth
            draw_dots(xs,ys,zs)
            if p.anti_aliasing:
                gl.glDisable( gl.GL_POINT_SMOOTH ) # turn off
            gl.glPopMatrix()
예제 #16
0
    def draw(self):
        # XXX This method is not speed-optimized. I just wrote it to
        # get the job done. (Nonetheless, it seems faster than the C
        # version commented out above.)

        p = self.parameters  # shorthand
        if p.center is not None:
            if not hasattr(VisionEgg.config, "_GAVE_CENTER_DEPRECATION"):
                logger = logging.getLogger('VisionEgg.Dots')
                logger.warning("Specifying DotArea2D 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)

            if p.anti_aliasing:
                if len(p.color) == 4 and not self._gave_alpha_warning:
                    if p.color[3] != 1.0:
                        logger = logging.getLogger('VisionEgg.Dots')
                        logger.warning("The parameter anti_aliasing is "
                                       "set to true in the DotArea2D "
                                       "stimulus class, but the color "
                                       "parameter specifies an alpha "
                                       "value other than 1.0.  To "
                                       "acheive the best anti-aliasing, "
                                       "ensure that the alpha value for "
                                       "the color parameter is 1.0.")
                        self._gave_alpha_warning = 1
                gl.glEnable(gl.GL_POINT_SMOOTH)
                # allow max_alpha value to control blending
                gl.glEnable(gl.GL_BLEND)
                gl.glBlendFunc(gl.GL_SRC_ALPHA, gl.GL_ONE_MINUS_SRC_ALPHA)
            else:
                gl.glDisable(gl.GL_BLEND)

            now_sec = VisionEgg.time_func()
            if self.start_times_sec is not None:
                # compute extinct dots and generate new positions
                replace_indices = Numeric.nonzero(
                    Numeric.greater(now_sec - self.start_times_sec,
                                    p.dot_lifespan_sec))
                Numeric.put(self.start_times_sec, replace_indices, now_sec)

                new_x_positions = RandomArray.uniform(0.0, 1.0,
                                                      (len(replace_indices), ))
                Numeric.put(self.x_positions, replace_indices, new_x_positions)

                new_y_positions = RandomArray.uniform(0.0, 1.0,
                                                      (len(replace_indices), ))
                Numeric.put(self.y_positions, replace_indices, new_y_positions)

                new_random_directions_radians = RandomArray.uniform(
                    0.0, 2 * math.pi, (len(replace_indices), ))
                Numeric.put(self.random_directions_radians, replace_indices,
                            new_random_directions_radians)
            else:
                # initialize dot extinction values to random (uniform) distribution
                self.start_times_sec = RandomArray.uniform(
                    now_sec - p.dot_lifespan_sec, now_sec,
                    (self.constant_parameters.num_dots, ))

            signal_num_dots = int(
                round(p.signal_fraction * self.constant_parameters.num_dots))
            time_delta_sec = now_sec - self.last_time_sec
            self.last_time_sec = now_sec  # reset for next loop
            x_increment_normalized = math.cos(
                p.signal_direction_deg / 180.0 * math.pi
            ) * p.velocity_pixels_per_sec / p.size[0] * time_delta_sec
            y_increment_normalized = -math.sin(
                p.signal_direction_deg / 180.0 * math.pi
            ) * p.velocity_pixels_per_sec / p.size[1] * time_delta_sec
            self.x_positions[:signal_num_dots] += x_increment_normalized
            self.y_positions[:signal_num_dots] += y_increment_normalized

            num_random_dots = self.constant_parameters.num_dots - signal_num_dots
            random_x_increment_normalized = Numeric.cos(
                self.random_directions_radians[signal_num_dots:]
            ) * p.velocity_pixels_per_sec / p.size[0] * time_delta_sec
            random_y_increment_normalized = -Numeric.sin(
                self.random_directions_radians[signal_num_dots:]
            ) * p.velocity_pixels_per_sec / p.size[1] * time_delta_sec
            self.x_positions[signal_num_dots:] += random_x_increment_normalized
            self.y_positions[signal_num_dots:] += random_y_increment_normalized

            self.x_positions = Numeric.fmod(self.x_positions, 1.0)  # wrap
            self.y_positions = Numeric.fmod(self.y_positions, 1.0)

            self.x_positions = Numeric.fmod(self.x_positions + 1,
                                            1.0)  # wrap again for values < 1
            self.y_positions = Numeric.fmod(self.y_positions + 1, 1.0)

            xs = (self.x_positions - 0.5) * p.size[0] + center[0]
            ys = (self.y_positions - 0.5) * p.size[1] + center[1]

            if len(p.color) == 3:
                gl.glColor3f(*p.color)
            elif len(p.color) == 4:
                gl.glColor4f(*p.color)
            gl.glPointSize(p.dot_size)

            # Clear the modeview matrix
            gl.glMatrixMode(gl.GL_MODELVIEW)
            gl.glPushMatrix()

            gl.glDisable(gl.GL_TEXTURE_2D)

            if p.depth is None:
                depth = 0.0
            else:
                gl.glEnable(gl.GL_DEPTH_TEST)
                depth = p.depth
            zs = (depth, ) * len(xs)  # make N tuple with repeat value of depth
            draw_dots(xs, ys, zs)
            if p.anti_aliasing:
                gl.glDisable(gl.GL_POINT_SMOOTH)  # turn off
            gl.glPopMatrix()
예제 #17
0
    def draw(self):
        p = self.parameters # shorthand
        if p.center is not None:
            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.bgcolor)==3:
                gl.glColor3f(*p.bgcolor)
            elif len(p.bgcolor)==4:
                gl.glColor4f(*p.bgcolor)
            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 #grid half-size
            h = p.size[1]/2.0
            m = p.size[0]/p.grid[0] #cell size
            n = p.size[1]/p.grid[1]
            i = range(p.grid[0]) #grid index
            j = range(p.grid[1])
            #draw colorful cell
#           vertices_list = [((-w+column*m, h-(row+1)*n, 0.0),(-w+column*m, h-row*n, 0.0),\
#                         (-w+(column+1)*m, h-row*n, 0.0),(-w+(column+1)*m, h-row*n, 0.0))\
#                         for column in j for row in i]
            vertices_list = [((-w+column*m, h-(row+1)*n, 0.0),(-w+column*m, h-row*n, 0.0),\
                              (-w+(column+1)*m, h-row*n, 0.0),(-w+(column+1)*m, h-(row+1)*n, 0.0))\
                         for column in j for row in i]
            colors_list = [colormap(p.colorindex[row,column],color=p.cellcolor)*4 for column in j for row in i]
            #flattening the vertices and colors
            vertices_flat = [num for tuple in vertices_list for vertex in tuple for num in vertex]
            colors_flat = [num for tuple in colors_list for num in tuple]
            vertices = np.array(vertices_flat)
            colors = np.array(colors_flat)
            vertices.shape = (-1, 3)
            colors.shape   = (-1, 3)
            gl.glVertexPointerd(vertices)
            gl.glColorPointerd(colors)
            gl.glEnableClientState(gl.GL_VERTEX_ARRAY)
            gl.glEnableClientState(gl.GL_COLOR_ARRAY)
            gl.glDisable(gl.GL_LIGHTING)
            gl.glDrawArrays(gl.GL_QUADS,0,p.grid[0]*p.grid[1]*4)
                        
            #draw grid lines
            if p.drawline:
                if len(p.linecolor) == 3:
                    gl.glColor3f(*p.linecolor)
                elif len(p.linecolor) == 4:
                    gl.glColor4f(*p.linecolor)
                
                row_list = [((-w, h - i * n),(w, h - i * n)) for i in range(p.grid[1] + 1)]
                col_list = [((-w + i * m, h),(-w + i * m, -h)) for i in range(p.grid[0] + 1)]
                ver_row_flat = [num for tuple in row_list for vertex in tuple for num in vertex]
                ver_col_flat = [num for tuple in col_list for vertex in tuple for num in vertex]
                vertices_row = np.array(ver_row_flat)
                vertices_col = np.array(ver_col_flat)
                vertices_row.shape = (-1,2)
                vertices_col.shape = (-1,2)
                
                gl.glEnableClientState(gl.GL_VERTEX_ARRAY)
                gl.glDisableClientState(gl.GL_COLOR_ARRAY)
                gl.glVertexPointerd(vertices_row)
                gl.glDrawArrays(gl.GL_LINES,0,(p.grid[1] + 1)*2)
                gl.glVertexPointerd(vertices_col)
                gl.glDrawArrays(gl.GL_LINES,0,(p.grid[0] + 1)*2)
                
#                gl.glBegin(gl.GL_LINES);
#                for i in range(p.grid[1] + 1):
#                    gl.glVertex2f(-w, h - i * n)
#                    gl.glVertex2f(w, h - i * n)
#                for i in range(p.grid[0] + 1):
#                    gl.glVertex2f(-w + i * m, h)
#                    gl.glVertex2f(-w + i * m, -h)
#                gl.glEnd();
            gl.glPopMatrix()