def gl_fillarea(self, vertices):

        fa = self.fillAttributes
        clear = 0
        polystipple = 0
        npts = len(vertices)/2
        if fa.fillstyle == 0: # clear region
            clear = 1
            glPolygonMode(GL_FRONT_AND_BACK, GL_FILL)
        elif fa.fillstyle == 1: # hollow
            glPolygonMode(GL_FRONT_AND_BACK, GL_LINE)
        elif fa.fillstyle >= 2: # solid
            glPolygonMode(GL_FRONT_AND_BACK, GL_FILL)
    #       elif fa.fillstyle > 2: # hatched
    # This is commented out since PyOpenGL does not currently support
    # glPolygonStipple!
    #               if fa.fillstyle > 6: fa.fillstyle = 6
    #               t = self.hatchfills
    #               print t
    #               tp = t.patterns
    #               print tp, "patterns"
    #               fill = self.hatchfills.patterns[fa.fillstyle]
    #               print fill, "fill"
    #               polystipple = 1
    #               glEnable(GL_POLYGON_STIPPLE)
    #               glPolygonStipple(fill)
        if not clear:
            self.colorManager.setDrawingColor(fa.color)
        else:
            self.colorManager.setDrawingColor(0)
        openglutil.glPlot(vertices, GL_POLYGON)
        if polystipple:
            glDisable(GL_POLYGON_STIPPLE)
    def gl_polyline(self, vertices):

        # First, set all relevant attributes
        la = self.lineAttributes
        glPointSize(1.0)
        glDisable(GL_LINE_SMOOTH)
        glLineWidth(la.linewidth)
        stipple = 0
        clear = 0
        npts = len(vertices)/2
        if la.linestyle == 0:
            clear = 1 # "clear" linestyle, don't draw!
        elif la.linestyle == 1:
            pass # solid line
        elif 2 <= la.linestyle < len(self.linestyles.patterns):
            glEnable(GL_LINE_STIPPLE)
            stipple = 1
            glLineStipple(1,self.linestyles.patterns[la.linestyle])
        if not clear:
            self.colorManager.setDrawingColor(la.color)
        else:
            self.colorManager.setDrawingColor(0)
        openglutil.glPlot(vertices, GL_LINE_STRIP)
        if stipple:
            glDisable(GL_LINE_STIPPLE)
def drawchar(char, font, size, aspect):

    # draw character with origin at bottom left corner of character box
    charstrokes = font[ord(char) - ord(" ")]
    for i in xrange(len(charstrokes[0])):
        vertex = Numeric.zeros((len(charstrokes[0][i]), 2), Numeric.Float64)
        vertex[:, 0] = size * charstrokes[0][i] / 27.0
        vertex[:, 1] = size * charstrokes[1][i] * aspect / 27.0
        openglutil.glPlot(vertex.flat, GL_LINE_STRIP)
    def gl_polymarker(self, vertices):

        # IRAF only implements points for poly marker, that makes it simple
        ma = self.markerAttributes
        clear = 0
        npts = len(vertices)/2
        glPointSize(1)
        if not clear:
            self.colorManager.setDrawingColor(ma.color)
        else:
            self.colorManager.setDrawingColor(0)
        openglutil.glPlot(vertices, GL_POINTS)