Esempio n. 1
0
File: trees.py Progetto: Knio/miru
    def _draw(self):
        corner = c = self.octree.corner
        w = self.octree.width

        gl.glPushAttrib( gl.GL_ENABLE_BIT )
        gl.glEnable( gl.GL_COLOR_MATERIAL )

        if self.octree._child_nodes is None:
            if self.list_id:
                gl.glCallList(self.list_id)
            else:
                self.list_id = gl.glGenLists(1)
                gl.glNewList(self.list_id, gl.GL_COMPILE)

                gl.glColor3f(*self.color)
                gl.glBegin(gl.GL_LINE_LOOP)
                gl.glVertex3f(*c)
                gl.glVertex3f(*(c + (0,w,0)))
                gl.glVertex3f(*(c + (0,w,w)))
                gl.glVertex3f(*(c + (0,0,w)))
                gl.glEnd()

                c = corner + (w,0,0)

                gl.glBegin(gl.GL_LINE_LOOP)
                gl.glVertex3f(*c)
                gl.glVertex3f(*(c + (0,w,0)))
                gl.glVertex3f(*(c + (0,w,w)))
                gl.glVertex3f(*(c + (0,0,w)))
                gl.glEnd()

                gl.glBegin(gl.GL_LINES)
                gl.glVertex3f(*c)
                gl.glVertex3f(*(c - (w,0,0)))
                gl.glVertex3f(*(c + (0,w,0)))
                gl.glVertex3f(*(corner + (0,w,0)))
                gl.glVertex3f(*(c + (0,w,w)))
                gl.glVertex3f(*(corner + (0,w,w)))
                gl.glVertex3f(*(c + (0,0,w)))
                gl.glVertex3f(*(corner + (0,0,w)))
                gl.glEnd()

                gl.glEndList()

        # This could be optimized of course
        if self.octree._child_nodes is not None:
            r = self.color[0] + 0.14
            if r < 1.0:
                r = r % 1.0
            else:
                r = 1.0
            b = max((self.color[2] - 0.14), 0)
            for node in self.octree._child_nodes.values():
                if not self._cache.has_key(id(node)):
                    self._cache[id(node)] = OctreeDebug(node, color=(r,0,b))
                debugNode = self._cache[id(node)]
                debugNode._draw()
        gl.glColor3f(1,1,1)

        gl.glPopAttrib()
Esempio n. 2
0
 def _draw_wireframe_display_list(self, dl):
     pgl.glPushAttrib(pgl.GL_ENABLE_BIT | pgl.GL_POLYGON_BIT)
     pgl.glPolygonMode(pgl.GL_FRONT_AND_BACK, pgl.GL_LINE)
     pgl.glEnable(pgl.GL_POLYGON_OFFSET_LINE)
     pgl.glPolygonOffset(-0.005, -50.0)
     pgl.glCallList(dl)
     pgl.glPopAttrib()
Esempio n. 3
0
    def draw_points(self):
        self.points_lock.acquire()

        try:
            from pyglet.gl import glCallList, glBegin, GL_LINE_STRIP, glColor4f, glVertex2f, glEnd

            # line from previous iterate to next iterate of function
            glBegin(GL_LINE_STRIP)
            glColor4f(1, 1, 1, 0.3)

            state_index = self.state_indices[0]

            for i in [1, 2]:
                state_previous = self.point.state[state_index]
                self.point.state = self.system.iterate(self.point.state, self.point.parameters)

                glVertex2f(state_previous, state_previous)
                glVertex2f(state_previous, self.point.state[state_index])

            glEnd()

            # call display lists, doesn't work in init_points()
            if self.server.iteration <= 1:
                glCallList(self.iterate_list)
                glCallList(self.reflection_list)
        except Exception, detail:
            print "draw_points()", type(detail), detail
Esempio n. 4
0
 def _draw_wireframe_display_list(self, dl):
     pgl.glPushAttrib(pgl.GL_ENABLE_BIT | pgl.GL_POLYGON_BIT)
     pgl.glPolygonMode(pgl.GL_FRONT_AND_BACK, pgl.GL_LINE)
     pgl.glEnable(pgl.GL_POLYGON_OFFSET_LINE)
     pgl.glPolygonOffset(-0.005, -50.0)
     pgl.glCallList(dl)
     pgl.glPopAttrib()
 def gl_render(self):
     """ Call all of the commands in the current list.
     """
     try:
         gl.glCallList(self.handle)
     except gl.GLException as e_msg:
         print("Got GL Exception on call list: " + str(e_msg))
     self.built = True
Esempio n. 6
0
 def gl_render(self):
     """ Call all of the commands in the current list.
     """
     try:
         gl.glCallList(self.handle)
     except gl.GLException as e_msg:
         print("Got GL Exception on call list: " + str(e_msg))
     self.built = True
Esempio n. 7
0
 def display(self, mode_2d=False):
     glEnable(GL_LINE_SMOOTH)
     orig_linewidth = (GLfloat)()
     glGetFloatv(GL_LINE_WIDTH, orig_linewidth)
     glLineWidth(3.0)
     glCallList(self.display_list)
     glLineWidth(orig_linewidth)
     glDisable(GL_LINE_SMOOTH)
Esempio n. 8
0
    def _text_glyphs_gl(self):
        if not self._text_dlist:
            dl_index = glGenLists(1)
            glNewList(dl_index, GL_COMPILE)

            # stime=getTime()

            # self._text_box._te_start_gl()

            ###
            glActiveTexture(GL_TEXTURE0)
            glEnable(GL_TEXTURE_2D)
            glBindTexture(GL_TEXTURE_2D,
                          self._text_box._current_glfont.atlas.texid)
            glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE)
            glTranslatef(self._position[0], -self._position[1], 0)
            glPushMatrix()

            ###

            getLineInfoByIndex = self._text_document.getLineInfoByIndex
            active_text_style_dlist = self._current_font_display_lists.get
            cell_width, cell_height = self._cell_size
            num_cols, num_rows = self._shape
            line_spacing = self._text_box._getPixelTextLineSpacing()
            line_count = self.getRowCountWithText()

            glColor4f(*self._text_box._toRGBA(self._font_color))

            for r in range(line_count):
                cline, line_length, line_display_list, line_ords = getLineInfoByIndex(
                    r)
                if line_display_list[0] == 0:
                    line_display_list[0:line_length] = [
                        active_text_style_dlist(c) for c in line_ords
                    ]

                glTranslatef(
                    cline._trans_left * cell_width,
                    -int(line_spacing / 2.0 + cline._trans_top * cell_height),
                    0)
                glCallLists(line_length, GL_UNSIGNED_INT,
                            line_display_list[0:line_length].ctypes)
                cline._trans_left = 0
                glTranslatef(
                    -line_length * cell_width - cline._trans_left * cell_width,
                    -cell_height +
                    int(line_spacing / 2.0 + cline._trans_top * cell_height),
                    0)

                ###
            glPopMatrix()
            glBindTexture(GL_TEXTURE_2D, 0)
            glDisable(GL_TEXTURE_2D)

            glEndList()
            self._text_dlist = dl_index
        glCallList(self._text_dlist)
Esempio n. 9
0
    def draw(self, win=None):
        
        #set the window to draw to
        if win==None: win=self.win
        if win.winType=='pyglet': win.winHandle.switch_to()
        
        #work out next default depth
        if self.depth==0:
            thisDepth = self.win._defDepth
            self.win._defDepth += _depthIncrements[self.win.winType]
        else:
            thisDepth=self.depth

        GL.glPushMatrix()

        #scale and rotate
        prevScale = self.win.setScale(self._winScale)
        GL.glTranslatef(self._posRendered[0],self._posRendered[1],thisDepth)#NB depth is set already
        GL.glRotatef(self.ori,0.0,0.0,1.0)
        self.win.setScale('pix',None, prevScale)
        
        if self._useShaders: #then rgb needs to be set as glColor
            #setup color
            desiredRGB = (self.rgb*self.contrast+1)/2.0#RGB in range 0:1 and scaled for contrast
            if numpy.any(desiredRGB**2.0>1.0):
                desiredRGB=[0.6,0.6,0.4]
            GL.glColor4f(desiredRGB[0],desiredRGB[1],desiredRGB[2], self.opacity)
        else: #color is set in texture, so set glColor to white
            GL.glColor4f(1,1,1,1)

        GL.glDisable(GL.GL_DEPTH_TEST) #should text have a depth or just on top?
        #update list if necss and then call it
        if self.win.winType=='pyglet':
            
            #and align based on x anchor
            if self.alignHoriz=='right':
                GL.glTranslatef(-self.width,0,0)#NB depth is set already
            if self.alignHoriz in ['center', 'centre']:
                GL.glTranslatef(-self.width/2,0,0)#NB depth is set already
                
            #unbind the mask texture regardless
            GL.glActiveTexture(GL.GL_TEXTURE1)
            GL.glEnable(GL.GL_TEXTURE_2D)
            GL.glBindTexture(GL.GL_TEXTURE_2D, 0)
            #unbind the main texture
            GL.glActiveTexture(GL.GL_TEXTURE0)
            GL.glEnable(GL.GL_TEXTURE_2D)
            #then allow pyglet to bind and use texture during drawing
            
            self.glyphStr.draw()            
            GL.glDisable(GL.GL_TEXTURE_2D) 
        else: 
            #for pygame we should (and can) use a drawing list   
            if self.needUpdate: self._updateList()
            GL.glCallList(self._listID)
        GL.glEnable(GL.GL_DEPTH_TEST)                   # Enables Depth Testing
        GL.glPopMatrix()
Esempio n. 10
0
    def _text_glyphs_gl(self):
        if not self._text_dlist:
            dl_index = glGenLists(1)
            glNewList(dl_index, GL_COMPILE)

            # stime=getTime()

            # self._text_box._te_start_gl()

            ###
            glActiveTexture(GL_TEXTURE0)
            glEnable(GL_TEXTURE_2D)
            glBindTexture(
                GL_TEXTURE_2D, self._text_box._current_glfont.atlas.texid)
            glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE)
            glTranslatef(self._position[0], -self._position[1], 0)
            glPushMatrix()

            ###

            getLineInfoByIndex = self._text_document.getLineInfoByIndex
            active_text_style_dlist = self._current_font_display_lists.get
            cell_width, cell_height = self._cell_size
            num_cols, num_rows = self._shape
            line_spacing = self._text_box._getPixelTextLineSpacing()
            line_count = self.getRowCountWithText()

            glColor4f(*self._text_box._toRGBA(self._font_color))

            for r in range(line_count):
                cline, line_length, line_display_list, line_ords = getLineInfoByIndex(
                    r)
                if line_display_list[0] == 0:
                    line_display_list[0:line_length] = [
                        active_text_style_dlist(c) for c in line_ords]

                glTranslatef(cline._trans_left * cell_width, -
                             int(line_spacing/2.0 + cline._trans_top * cell_height), 0)
                glCallLists(line_length, GL_UNSIGNED_INT,
                            line_display_list[0:line_length].ctypes)
                cline._trans_left = 0
                glTranslatef(-line_length * cell_width - cline._trans_left * cell_width, -
                             cell_height + int(line_spacing/2.0 + cline._trans_top * cell_height), 0)

                ###
            glPopMatrix()
            glBindTexture(GL_TEXTURE_2D, 0)
            glDisable(GL_TEXTURE_2D)

            glEndList()
            self._text_dlist = dl_index
        glCallList(self._text_dlist)
Esempio n. 11
0
    def multi_draw(*args, **kwargs):
        gl.glEnable(gl.GL_BLEND)
        gl.glBlendFunc(gl.GL_ONE, gl.GL_ONE)
        gl.glEnable(gl.GL_LINE_SMOOTH)
        gl.glEnable(gl.GL_POINT_SMOOTH)
        gl.glClearColor(0, 0, 0, 0)
        gl.glColor4f(1, 1, 1, 1)

        gl.glClear(gl.GL_COLOR_BUFFER_BIT)

        if not buffers:
            buffers.append(image.get_buffer_manager())
        x, y, w, h = buffers[0].get_viewport()

        #Draw lowres version
        gl.glViewport(0, 0, 256, 256)
        func(*args, **kwargs)
        ctex[0] = buffers[0].get_color_buffer().texture

        #Lay down copies of lowres version
        gl.glViewport(x, y, w, h)
        gl.glClear(gl.GL_COLOR_BUFFER_BIT)
        gl.glBindTexture(ctex[0].target, ctex[0].id)
        gl.glEnable(gl.GL_TEXTURE_2D)
        gl.glTexParameteri(gl.GL_TEXTURE_2D, gl.GL_TEXTURE_MAG_FILTER,
                           gl.GL_LINEAR)
        if not disp_list:
            disp_list.append(gl.glGenLists(1))
            gl.glNewList(disp_list[0], gl.GL_COMPILE)
            for u in range(-3, 4, 3):
                for v in range(-3, 4, 3):
                    gl.glColor4f(1, 1, 1, (20.0 - u**2 - v**2) / 72)
                    gl.glBegin(gl.GL_QUADS)
                    gl.glTexCoord2f(0, 0)
                    gl.glVertex3f(u, v, -.5)
                    gl.glTexCoord2f(1, 0)
                    gl.glVertex3f(u + w, v, -.5)
                    gl.glTexCoord2f(1, 1)
                    gl.glVertex3f(u + w, v + h, -.5)
                    gl.glTexCoord2f(0, 1)
                    gl.glVertex3f(u, v + h, -.5)
                    gl.glEnd()
            gl.glEndList()
        gl.glCallList(disp_list[0])
        gl.glDisable(gl.GL_TEXTURE_2D)

        #Draw real thing
        gl.glColor4f(1, 1, 1, 1)
        func(*args, **kwargs)
Esempio n. 12
0
    def _textgrid_lines_gl(self):
        if self._line_color:
            if not self._gridlines_dlist:                
                dl_index = glGenLists(1)        
                glNewList(dl_index, GL_COMPILE)           

                glLineWidth(self._line_width)
                glColor4f(*self._text_box._toRGBA(self._line_color))                   
                glBegin(GL_LINES)
                for x in self._col_lines:
                    for y in self._row_lines:
                        if x == 0:
                            glVertex2i(x,y)
                            glVertex2i(int(self._size[0]), y)
                        if y == 0:
                            glVertex2i(x, y)
                            glVertex2i(x, int(-self._size[1]))                        
                glEnd()
                glColor4f(0.0,0.0,0.0,1.0)
                glEndList() 
                self._gridlines_dlist=dl_index
            glCallList(self._gridlines_dlist) 
Esempio n. 13
0
    def _textgrid_lines_gl(self):
        if self._line_color:
            if not self._gridlines_dlist:
                dl_index = glGenLists(1)
                glNewList(dl_index, GL_COMPILE)

                glLineWidth(self._line_width)
                glColor4f(*self._text_box._toRGBA(self._line_color))
                glBegin(GL_LINES)
                for x in self._col_lines:
                    for y in self._row_lines:
                        if x == 0:
                            glVertex2i(x, y)
                            glVertex2i(int(self._size[0]), y)
                        if y == 0:
                            glVertex2i(x, y)
                            glVertex2i(x, int(-self._size[1]))
                glEnd()
                glColor4f(0.0, 0.0, 0.0, 1.0)
                glEndList()
                self._gridlines_dlist = dl_index
            glCallList(self._gridlines_dlist)
Esempio n. 14
0
 def draw(self):
     gl.glCallList(self.list)
     gl.glColor3f(1.0, 1.0, 1.0)
Esempio n. 15
0
 def draw(self):
     gl.glCallList(self.list)
Esempio n. 16
0
 def display(self, mode_2d=False):
     glCallList(self.display_list)
Esempio n. 17
0
 def _draw_solid_display_list(self, dl):
     pgl.glPushAttrib(pgl.GL_ENABLE_BIT | pgl.GL_POLYGON_BIT)
     pgl.glPolygonMode(pgl.GL_FRONT_AND_BACK, pgl.GL_FILL)
     pgl.glCallList(dl)
     pgl.glPopAttrib()
Esempio n. 18
0
 def render(self):
     gl.glCallList(self.disp_list)
Esempio n. 19
0
 def draw(self):
     gl.glPointSize(5.0)
     gl.glCallList(self.list)
     gl.glColor3f(1.0, 1.0, 1.0)
Esempio n. 20
0
 def __call__(self):
     gl.glCallList(self.id)
Esempio n. 21
0
 def __call__(self):
     if not self.compiled:
         return Exception('Not compiled!')
     from pyglet import gl
     gl.glCallList(self._list_id)
Esempio n. 22
0
 def draw(self):
     gl.glCallList( self.list_id )
Esempio n. 23
0
 def __call__(self):
     if not self.compiled:
         return Exception('Not compiled!')
     from pyglet import gl
     gl.glCallList(self._list_id)
Esempio n. 24
0
 def draw(self):
     gl.glColor3f(*self.color)
     gl.glCallList(self.square)
     gl.glFlush()
Esempio n. 25
0
 def draw(self):
     glCallList(self.list)
Esempio n. 26
0
    def render(self, scene):
        """ Add a ring to the view.

        :param scene: The view to render the model into
        :type scene: pyglet_helper.objects.View
        """
        if self.degenerate:
            return
        # The number of subdivisions around the hoop's radial direction.
        if self.thickness:
            band_coverage = scene.pixel_coverage(self.pos, self.thickness)
        else:
            band_coverage = scene.pixel_coverage(self.pos, self.radius * 0.1)
        if band_coverage < 0:
            band_coverage = 1000
        bands = sqrt(band_coverage * 4.0)
        bands = clamp(4, bands, 40)
        # The number of subdivisions around the hoop's tangential direction.
        ring_coverage = scene.pixel_coverage(self.pos, self.radius)
        if ring_coverage < 0:
            ring_coverage = 1000
        rings = sqrt(ring_coverage * 4.0)
        rings = clamp(4, rings, 80)
        slices = int(rings)
        inner_slices = int(bands)
        radius = self.radius
        inner_radius = self.thickness

        # Create the vertex and normal arrays.
        vertices = []
        normals = []

        outer_angle_step = 2 * pi / (slices - 1)
        inner_angle_step = 2 * pi / (inner_slices - 1)
        outer_angle = 0.
        for i in range(slices):
            cos_outer_angle = cos(outer_angle)
            sin_outer_angle = sin(outer_angle)
            inner_angle = 0.
            for j in range(inner_slices):
                cos_inner_angle = cos(inner_angle)
                sin_inner_angle = sin(inner_angle)

                diameter = (radius + inner_radius * cos_inner_angle)
                vertex_x = diameter * cos_outer_angle
                vertex_y = diameter * sin_outer_angle
                vertex_z = inner_radius * sin_inner_angle

                normal_x = cos_outer_angle * cos_inner_angle
                normal_y = sin_outer_angle * cos_inner_angle
                normal_z = sin_inner_angle

                vertices.extend([vertex_x, vertex_y, vertex_z])
                normals.extend([normal_x, normal_y, normal_z])
                inner_angle += inner_angle_step
            outer_angle += outer_angle_step

        # Create ctypes arrays of the lists
        vertices = (gl.GLfloat *len(vertices))(*vertices)
        normals = (gl.GLfloat * len(normals))(*normals)

        # Create a list of triangle indices.
        indices = []
        for i in range(slices - 1):
            for j in range(inner_slices - 1):
                pos = i * inner_slices + j
                indices.extend([pos, pos + inner_slices, pos + inner_slices +
                                1])
                indices.extend([pos, pos + inner_slices + 1, pos + 1])
        indices = (gl.GLuint * len(indices))(*indices)

        # Compile a display list
        self.list = gl.glGenLists(1)
        gl.glNewList(self.list, gl.GL_COMPILE)
        self.color.gl_set(self.opacity)

        gl.glPushClientAttrib(gl.GL_CLIENT_VERTEX_ARRAY_BIT)
        gl.glEnableClientState(gl.GL_VERTEX_ARRAY)
        gl.glEnableClientState(gl.GL_NORMAL_ARRAY)
        self.model_world_transform(scene.gcf,
                                   Vector([self.radius, self.radius,
                                           self.radius])).gl_mult()

        gl.glVertexPointer(3, gl.GL_FLOAT, 0, vertices)
        gl.glNormalPointer(gl.GL_FLOAT, 0, normals)
        gl.glDrawElements(gl.GL_TRIANGLES, len(indices), gl.GL_UNSIGNED_INT,
                          indices)
        gl.glPopClientAttrib()

        gl.glEndList()
        gl.glCallList(self.list)
Esempio n. 27
0
    def _text_glyphs_gl(self):
        if not self._text_dlist:            
            dl_index = glGenLists(1)        
            glNewList(dl_index, GL_COMPILE)           

            #stime=getTime()

            #self._text_box._te_start_gl()                         
    
            ###
            glActiveTexture(GL_TEXTURE0)        
            glEnable( GL_TEXTURE_2D )
            glBindTexture( GL_TEXTURE_2D, self._text_box._current_glfont.atlas.texid)
            glTexEnvf(GL_TEXTURE_ENV,GL_TEXTURE_ENV_MODE,GL_MODULATE )
            glTranslatef( self._position[0], -self._position[1], 0 )
            glPushMatrix()

            ###
            
            hjust=self._horz_justification
            vjust=self._vert_justification
            pad_left_proportion=0     
            pad_top_proportion=0     
            if hjust=='center':
                pad_left_proportion=0.5
            elif hjust=='right':
                pad_left_proportion=1.0
            if vjust=='center':
                pad_top_proportion=0.5
            elif vjust=='bottom':
                pad_top_proportion=1.0
            
            getLineInfoByIndex=self._text_document.getLineInfoByIndex
            active_text_style_dlist=self._current_font_display_lists.get
            cell_width,cell_height=self._cell_size
            num_cols,num_rows=self._shape
            line_spacing=self._text_box._getPixelTextLineSpacing()
            line_count=min(num_rows,self._text_document.getParsedLineCount())
            apply_padding=pad_left_proportion or (pad_top_proportion and line_count>1)
            trans_left=0
            trans_top=0
            glColor4f(*self._text_box._toRGBA(self._font_color))    

            for r in range(line_count):            
                line_length,line_display_list,line_ords=getLineInfoByIndex(r)
                if line_display_list[0]==0: 
                    line_display_list[0:line_length]=[active_text_style_dlist(c) for c in line_ords] 
                    
                if apply_padding:
                    empty_cell_count=num_cols-line_length
                    empty_line_count=num_rows-line_count
                    trans_left=int((empty_cell_count+1)*pad_left_proportion)*cell_width
                    trans_top=int(empty_line_count*pad_top_proportion)*cell_height
                    
                glTranslatef(trans_left,-int(line_spacing/2.0+trans_top),0)
                glCallLists(line_length,GL_UNSIGNED_INT,line_display_list[0:line_length].ctypes)
                glTranslatef(-line_length*cell_width-trans_left,-cell_height+int(line_spacing/2.0+trans_top),0)
    
                ###
            glPopMatrix()       
            glBindTexture( GL_TEXTURE_2D,0 )
            glDisable( GL_TEXTURE_2D ) 

            glEndList()            
            #print 'GL_TIME: %.3f'%((etime-stime)*1000.0)
            self._text_dlist=dl_index
        glCallList(self._text_dlist) 
Esempio n. 28
0
 def _draw_solid_display_list(self, dl):
     pgl.glPushAttrib(pgl.GL_ENABLE_BIT | pgl.GL_POLYGON_BIT)
     pgl.glPolygonMode(pgl.GL_FRONT_AND_BACK, pgl.GL_FILL)
     pgl.glCallList(dl)
     pgl.glPopAttrib()
Esempio n. 29
0
    def draw(self, win=None):

        #set the window to draw to
        if win == None: win = self.win
        if win.winType == 'pyglet': win.winHandle.switch_to()

        #work out next default depth
        if self.depth == 0:
            thisDepth = self.win._defDepth
            self.win._defDepth += _depthIncrements[self.win.winType]
        else:
            thisDepth = self.depth

        GL.glPushMatrix()

        #scale and rotate
        prevScale = self.win.setScale(self._winScale)
        GL.glTranslatef(self._posRendered[0], self._posRendered[1],
                        thisDepth)  #NB depth is set already
        GL.glRotatef(self.ori, 0.0, 0.0, 1.0)
        self.win.setScale('pix', None, prevScale)

        if self._useShaders:  #then rgb needs to be set as glColor
            #setup color
            desiredRGB = (self.rgb * self.contrast +
                          1) / 2.0  #RGB in range 0:1 and scaled for contrast
            if numpy.any(desiredRGB**2.0 > 1.0):
                desiredRGB = [0.6, 0.6, 0.4]
            GL.glColor4f(desiredRGB[0], desiredRGB[1], desiredRGB[2],
                         self.opacity)
        else:  #color is set in texture, so set glColor to white
            GL.glColor4f(1, 1, 1, 1)

        GL.glDisable(
            GL.GL_DEPTH_TEST)  #should text have a depth or just on top?
        #update list if necss and then call it
        if self.win.winType == 'pyglet':

            #and align based on x anchor
            if self.alignHoriz == 'right':
                GL.glTranslatef(-self.width, 0, 0)  #NB depth is set already
            if self.alignHoriz in ['center', 'centre']:
                GL.glTranslatef(-self.width / 2, 0,
                                0)  #NB depth is set already

            #unbind the mask texture regardless
            GL.glActiveTexture(GL.GL_TEXTURE1)
            GL.glEnable(GL.GL_TEXTURE_2D)
            GL.glBindTexture(GL.GL_TEXTURE_2D, 0)
            #unbind the main texture
            GL.glActiveTexture(GL.GL_TEXTURE0)
            GL.glEnable(GL.GL_TEXTURE_2D)
            #then allow pyglet to bind and use texture during drawing

            self.glyphStr.draw()
            GL.glDisable(GL.GL_TEXTURE_2D)
        else:
            #for pygame we should (and can) use a drawing list
            if self.needUpdate: self._updateList()
            GL.glCallList(self._listID)
        GL.glEnable(GL.GL_DEPTH_TEST)  # Enables Depth Testing
        GL.glPopMatrix()