Example #1
0
 def draw(self, context, render=False):
     if self.image is None:
         return
     bgl.glPushAttrib(bgl.GL_ENABLE_BIT)
     p0 = self.pts[0]
     p1 = self.pts[1]
     bgl.glEnable(bgl.GL_BLEND)
     bgl.glColor4f(*self.colour)
     bgl.glRectf(p0.x, p0.y, p1.x, p1.y)
     self.image.gl_load()
     bgl.glEnable(bgl.GL_BLEND)
     bgl.glBindTexture(bgl.GL_TEXTURE_2D, self.image.bindcode[0])
     bgl.glTexParameteri(bgl.GL_TEXTURE_2D, bgl.GL_TEXTURE_MIN_FILTER, bgl.GL_NEAREST)
     bgl.glTexParameteri(bgl.GL_TEXTURE_2D, bgl.GL_TEXTURE_MAG_FILTER, bgl.GL_NEAREST)
     bgl.glEnable(bgl.GL_TEXTURE_2D)
     bgl.glBlendFunc(bgl.GL_SRC_ALPHA, bgl.GL_ONE_MINUS_SRC_ALPHA)
     # bgl.glColor4f(1, 1, 1, 1)
     bgl.glBegin(bgl.GL_QUADS)
     bgl.glTexCoord2d(0, 0)
     bgl.glVertex2d(p0.x, p0.y)
     bgl.glTexCoord2d(0, 1)
     bgl.glVertex2d(p0.x, p1.y)
     bgl.glTexCoord2d(1, 1)
     bgl.glVertex2d(p1.x, p1.y)
     bgl.glTexCoord2d(1, 0)
     bgl.glVertex2d(p1.x, p0.y)
     bgl.glEnd()
     self.image.gl_free()
     bgl.glDisable(bgl.GL_TEXTURE_2D)
Example #2
0
def draw_texture(x, y, w, h, texture, mode=None):
    mode_bak = bgl.Buffer(bgl.GL_INT, 1)
    bgl.glGetIntegerv(bgl.GL_DRAW_BUFFER, mode_bak)
    if mode is not None:
        bgl.glDrawBuffer(mode)

    bgl.glEnable(bgl.GL_TEXTURE_2D)
    bgl.glBindTexture(bgl.GL_TEXTURE_2D, texture)

    bgl.glColor4d(1.0, 1.0, 1.0, 1.0)
    bgl.glBegin(bgl.GL_TRIANGLE_FAN)
    bgl.glTexCoord2d(0.0, 0.0)
    bgl.glVertex2i(x, y)
    bgl.glTexCoord2d(1.0, 0.0)
    bgl.glVertex2i(x + w, y)
    bgl.glTexCoord2d(1.0, 1.0)
    bgl.glVertex2i(x + w, y + h)
    bgl.glTexCoord2d(0.0, 1.0)
    bgl.glVertex2i(x, y + h)
    bgl.glEnd()

    bgl.glDisable(bgl.GL_TEXTURE_2D)
    bgl.glBindTexture(bgl.GL_TEXTURE_2D, 0)

    if mode is not None:
        bgl.glDrawBuffer(mode_bak[0])
Example #3
0
def draw_texture(x, y, w, h, texture, mode=None):
    mode_bak = bgl.Buffer(bgl.GL_INT, 1)
    bgl.glGetIntegerv(bgl.GL_DRAW_BUFFER, mode_bak)
    if mode is not None:
        bgl.glDrawBuffer(mode)

    bgl.glEnable(bgl.GL_TEXTURE_2D)
    bgl.glBindTexture(bgl.GL_TEXTURE_2D, texture)

    bgl.glColor4d(1.0, 1.0, 1.0, 1.0)
    bgl.glBegin(bgl.GL_TRIANGLE_FAN)
    bgl.glTexCoord2d(0.0, 0.0)
    bgl.glVertex2i(x, y)
    bgl.glTexCoord2d(1.0, 0.0)
    bgl.glVertex2i(x + w, y)
    bgl.glTexCoord2d(1.0, 1.0)
    bgl.glVertex2i(x + w, y + h)
    bgl.glTexCoord2d(0.0, 1.0)
    bgl.glVertex2i(x, y + h)
    bgl.glEnd()

    bgl.glDisable(bgl.GL_TEXTURE_2D)
    bgl.glBindTexture(bgl.GL_TEXTURE_2D, 0)

    if mode is not None:
        bgl.glDrawBuffer(mode_bak[0])
Example #4
0
    def renderTexture(texture, x, y, width, height):
        bgl.glEnable(bgl.GL_BLEND)
        #bgl.glBlendFunc(bgl.GL_SRC_ALPHA, bgl.GL_ONE_MINUS_SRC_ALPHA)

        texture.gl_load()
        bgl.glBindTexture(bgl.GL_TEXTURE_2D, texture.bindcode[0])

        bgl.glEnable(bgl.GL_TEXTURE_2D)
        bgl.glTexParameteri(bgl.GL_TEXTURE_2D, bgl.GL_TEXTURE_MIN_FILTER, bgl.GL_NEAREST)
        bgl.glTexParameteri(bgl.GL_TEXTURE_2D, bgl.GL_TEXTURE_MAG_FILTER, bgl.GL_NEAREST)

        bgl.glColor4f(1, 1, 1, 1)

        bgl.glBegin(bgl.GL_QUADS)
        bgl.glTexCoord2d(0, 0)
        bgl.glVertex2d(x, y)
        bgl.glTexCoord2d(0, 1)
        bgl.glVertex2d(x, y + height)
        bgl.glTexCoord2d(1, 1)
        bgl.glVertex2d(x + width, y + height)
        bgl.glTexCoord2d(1, 0)
        bgl.glVertex2d(x + width , y)
        bgl.glEnd()

        texture.gl_free()
Example #5
0
    def renderTexture(texture, x, y, width, height):
        bgl.glEnable(bgl.GL_BLEND)
        #bgl.glBlendFunc(bgl.GL_SRC_ALPHA, bgl.GL_ONE_MINUS_SRC_ALPHA)

        texture.gl_load()
        bgl.glBindTexture(bgl.GL_TEXTURE_2D, texture.bindcode[0])

        bgl.glEnable(bgl.GL_TEXTURE_2D)
        bgl.glTexParameteri(bgl.GL_TEXTURE_2D, bgl.GL_TEXTURE_MIN_FILTER,
                            bgl.GL_NEAREST)
        bgl.glTexParameteri(bgl.GL_TEXTURE_2D, bgl.GL_TEXTURE_MAG_FILTER,
                            bgl.GL_NEAREST)

        bgl.glColor4f(1, 1, 1, 1)

        bgl.glBegin(bgl.GL_QUADS)
        bgl.glTexCoord2d(0, 0)
        bgl.glVertex2d(x, y)
        bgl.glTexCoord2d(0, 1)
        bgl.glVertex2d(x, y + height)
        bgl.glTexCoord2d(1, 1)
        bgl.glVertex2d(x + width, y + height)
        bgl.glTexCoord2d(1, 0)
        bgl.glVertex2d(x + width, y)
        bgl.glEnd()

        texture.gl_free()
Example #6
0
    def draw_button_icon(self):
        if self.icon != "":
            bgl.glEnable(bgl.GL_BLEND)
            texture = bpy.data.images.load(filepath=self.icon)
            err = texture.gl_load(filter=bgl.GL_NEAREST, mag=bgl.GL_NEAREST)
            assert not err, 'OpenGL error: %i' % err

            bgl.glBindTexture(bgl.GL_TEXTURE_2D, texture.bindcode[0])
            bgl.glEnable(bgl.GL_TEXTURE_2D)
            bgl.glBlendFunc(bgl.GL_SRC_ALPHA, bgl.GL_ONE_MINUS_SRC_ALPHA)

            bgl.glColor4f(1, 1, 1, 1)
            bgl.glBegin(bgl.GL_QUADS)
            bgl.glTexCoord2d(0, 0)
            bgl.glVertex2d(self.x_location + ICON_MARGIN_X, self.y_location)
            bgl.glTexCoord2d(0, 1)
            bgl.glVertex2d(self.x_location + ICON_MARGIN_X,
                           self.y_location + ICON_HEIGHT)
            bgl.glTexCoord2d(1, 1)
            bgl.glVertex2d(self.x_location + ICON_MARGIN_X + ICON_WIDTH,
                           self.y_location + ICON_HEIGHT)
            bgl.glTexCoord2d(1, 0)
            bgl.glVertex2d(self.x_location + ICON_MARGIN_X + ICON_WIDTH,
                           self.y_location)
            bgl.glEnd()
            bgl.glDisable(bgl.GL_TEXTURE_2D)
            bgl.glDisable(bgl.GL_BLEND)

            texture.gl_free()
Example #7
0
    def draw_textured(self):
        """ call this draw function only if morphs uses texture """
        if self.texture != None:

            self.texture.gl_load()
            bgl.glBindTexture(bgl.GL_TEXTURE_2D, self.texture.bindcode)
            bgl.glTexParameteri(bgl.GL_TEXTURE_2D, bgl.GL_TEXTURE_MIN_FILTER, bgl.GL_NEAREST)

            bgl.glTexParameteri(bgl.GL_TEXTURE_2D, bgl.GL_TEXTURE_MAG_FILTER, bgl.GL_NEAREST) #GL_LINEAR seems to be used in Blender for background images

            bgl.glEnable(bgl.GL_TEXTURE_2D)

            #bgl.glBlendFunc(bgl.GL_SRC_ALPHA, bgl.GL_ONE_MINUS_SRC_ALPHA)


            bgl.glColor4f(*self.color)
            bgl.glBegin(bgl.GL_QUADS)
            bgl.glTexCoord2d(0,0)
            bgl.glVertex2d(self.get_position().x,self.get_position().y)
            bgl.glTexCoord2d(0,1)
            bgl.glVertex2d(self.get_position().x,self.get_position().y+self.get_height())
            bgl.glTexCoord2d(1,1)
            bgl.glVertex2d(self.get_position().x+self.get_width(),self.get_position().y+self.get_height())
            bgl.glTexCoord2d(1,0)
            bgl.glVertex2d(self.get_position().x+self.get_width(),self.get_position().y)
            bgl.glEnd()
            bgl.glDisable(bgl.GL_BLEND)
            bgl.glDisable(bgl.GL_TEXTURE_2D)
            self.texture.gl_free()

        return
def drawMenuItem(item, x, y, width, height):
    global iconWidth
    global iconHeight

    iconMarginX = 4
    iconMarginY = 4
    textMarginX = 6

    textHeight = 16
    textWidth = 72

    bgl.glEnable(bgl.GL_BLEND)
    if item['highlighted']:
        bgl.glColor4f(0.555, 0.555, 0.555, 0.8)
    else:
        bgl.glColor4f(0.447, 0.447, 0.447, 0.8)

    bgl.glRectf(x, y, x + width, y + height)

    texture = item['icon']
    texture.gl_load()
    bgl.glColor4f(0.0, 0.0, 1.0, 0.5)
    #bgl.glLineWidth(1.5)

    #------ TEXTURE ---------#
    bgl.glEnable(bgl.GL_BLEND)
    bgl.glBindTexture(bgl.GL_TEXTURE_2D, texture.bindcode[0])
    bgl.glTexParameteri(bgl.GL_TEXTURE_2D, bgl.GL_TEXTURE_MIN_FILTER,
                        bgl.GL_NEAREST)
    bgl.glTexParameteri(
        bgl.GL_TEXTURE_2D, bgl.GL_TEXTURE_MAG_FILTER, bgl.GL_NEAREST
    )  #GL_LINEAR seems to be used in Blender for background images
    bgl.glEnable(bgl.GL_TEXTURE_2D)
    bgl.glBlendFunc(bgl.GL_SRC_ALPHA, bgl.GL_ONE_MINUS_SRC_ALPHA)

    bgl.glColor4f(1, 1, 1, 1)
    bgl.glBegin(bgl.GL_QUADS)
    bgl.glTexCoord2d(0, 0)
    bgl.glVertex2d(x + iconMarginX, y)
    bgl.glTexCoord2d(0, 1)
    bgl.glVertex2d(x + iconMarginX, y + iconHeight)
    bgl.glTexCoord2d(1, 1)
    bgl.glVertex2d(x + iconMarginX + iconWidth, y + iconHeight)
    bgl.glTexCoord2d(1, 0)
    bgl.glVertex2d(x + iconMarginX + iconWidth, y)
    bgl.glEnd()

    texture.gl_free()

    # draw some text
    font_id = 0
    blf.position(font_id, x + iconMarginX + iconWidth + textMarginX,
                 y + iconHeight * 0.5 - 0.25 * textHeight, 0)
    blf.size(font_id, textHeight, textWidth)
    blf.draw(font_id, item['text'])
Example #9
0
def drawMenuItem(item, x, y, width, height):
    global iconWidth
    global iconHeight

    iconMarginX = 4
    iconMarginY = 4
    textMarginX = 6

    textHeight = 16
    textWidth = 72

    bgl.glEnable(bgl.GL_BLEND)
    if item["highlighted"]:
        bgl.glColor4f(0.555, 0.555, 0.555, 0.8)
    else:
        bgl.glColor4f(0.447, 0.447, 0.447, 0.8)

    bgl.glRectf(x, y, x + width, y + height)

    texture = item["icon"]
    texture.gl_load()
    bgl.glColor4f(0.0, 0.0, 1.0, 0.5)
    # bgl.glLineWidth(1.5)

    # ------ TEXTURE ---------#
    bgl.glEnable(bgl.GL_BLEND)
    bgl.glBindTexture(bgl.GL_TEXTURE_2D, texture.bindcode)
    bgl.glTexParameteri(bgl.GL_TEXTURE_2D, bgl.GL_TEXTURE_MIN_FILTER, bgl.GL_NEAREST)
    bgl.glTexParameteri(
        bgl.GL_TEXTURE_2D, bgl.GL_TEXTURE_MAG_FILTER, bgl.GL_NEAREST
    )  # GL_LINEAR seems to be used in Blender for background images
    bgl.glEnable(bgl.GL_TEXTURE_2D)
    bgl.glBlendFunc(bgl.GL_SRC_ALPHA, bgl.GL_ONE_MINUS_SRC_ALPHA)

    bgl.glColor4f(1, 1, 1, 1)
    bgl.glBegin(bgl.GL_QUADS)
    bgl.glTexCoord2d(0, 0)
    bgl.glVertex2d(x + iconMarginX, y)
    bgl.glTexCoord2d(0, 1)
    bgl.glVertex2d(x + iconMarginX, y + iconHeight)
    bgl.glTexCoord2d(1, 1)
    bgl.glVertex2d(x + iconMarginX + iconWidth, y + iconHeight)
    bgl.glTexCoord2d(1, 0)
    bgl.glVertex2d(x + iconMarginX + iconWidth, y)
    bgl.glEnd()

    texture.gl_free()

    # draw some text
    font_id = 0
    blf.position(font_id, x + iconMarginX + iconWidth + textMarginX, y + iconHeight * 0.5 - 0.25 * textHeight, 0)
    blf.size(font_id, textHeight, textWidth)
    blf.draw(font_id, item["text"])
Example #10
0
    def draw(self, highlighted: bool):
        bgl.glEnable(bgl.GL_BLEND)
        if highlighted:
            bgl.glColor4f(0.555, 0.555, 0.555, 0.8)
        else:
            bgl.glColor4f(0.447, 0.447, 0.447, 0.8)

        bgl.glRectf(self.x, self.y, self.x + self.width, self.y + self.height)

        texture = self.icon
        err = texture.gl_load(filter=bgl.GL_NEAREST, mag=bgl.GL_NEAREST)
        assert not err, 'OpenGL error: %i' % err

        bgl.glColor4f(0.0, 0.0, 1.0, 0.5)
        # bgl.glLineWidth(1.5)

        # ------ TEXTURE ---------#
        bgl.glBindTexture(bgl.GL_TEXTURE_2D, texture.bindcode[0])
        bgl.glEnable(bgl.GL_TEXTURE_2D)
        bgl.glBlendFunc(bgl.GL_SRC_ALPHA, bgl.GL_ONE_MINUS_SRC_ALPHA)

        bgl.glColor4f(1, 1, 1, 1)
        bgl.glBegin(bgl.GL_QUADS)
        bgl.glTexCoord2d(0, 0)
        bgl.glVertex2d(self.x + self.icon_margin_x, self.y)
        bgl.glTexCoord2d(0, 1)
        bgl.glVertex2d(self.x + self.icon_margin_x, self.y + ICON_HEIGHT)
        bgl.glTexCoord2d(1, 1)
        bgl.glVertex2d(self.x + self.icon_margin_x + ICON_WIDTH,
                       self.y + ICON_HEIGHT)
        bgl.glTexCoord2d(1, 0)
        bgl.glVertex2d(self.x + self.icon_margin_x + ICON_WIDTH, self.y)
        bgl.glEnd()
        bgl.glDisable(bgl.GL_TEXTURE_2D)
        bgl.glDisable(bgl.GL_BLEND)

        texture.gl_free()

        # draw some text
        font_id = 0
        blf.position(
            font_id,
            self.x + self.icon_margin_x + ICON_WIDTH + self.text_margin_x,
            self.y + ICON_HEIGHT * 0.5 - 0.25 * self.text_height, 0)
        blf.size(font_id, self.text_height, self.text_width)
        blf.draw(font_id, self.label_text)
Example #11
0
def aabox_with_texture(v1: Float2, v2: Float2):
    """Draw an axis-aligned box with a texture."""

    bgl.glColor4f(1.0, 1.0, 1.0, 1.0)

    bgl.glEnable(bgl.GL_TEXTURE_2D)
    bgl.glBegin(bgl.GL_QUADS)
    bgl.glTexCoord2d(0, 0)
    bgl.glVertex2d(v1[0], v1[1])
    bgl.glTexCoord2d(0, 1)
    bgl.glVertex2d(v1[0], v2[1])
    bgl.glTexCoord2d(1, 1)
    bgl.glVertex2d(v2[0], v2[1])
    bgl.glTexCoord2d(1, 0)
    bgl.glVertex2d(v2[0], v1[1])
    bgl.glEnd()
    bgl.glDisable(bgl.GL_TEXTURE_2D)
Example #12
0
def draw(self,context):

    global iterations
    global texture
    global height
    global width
    texture.gl_load()
    bgl.glEnable(bgl.GL_BLEND)
    bgl.glColor4f(0.0, 0.0, 0.0, 0.5)
    bgl.glLineWidth(1.5)

    #------ TEXTURE ---------#

    bgl.glBindTexture(bgl.GL_TEXTURE_2D, texture.bindcode)
    bgl.glTexParameteri(bgl.GL_TEXTURE_2D, bgl.GL_TEXTURE_MIN_FILTER, bgl.GL_NEAREST)

    bgl.glTexParameteri(bgl.GL_TEXTURE_2D, bgl.GL_TEXTURE_MAG_FILTER, bgl.GL_NEAREST) #GL_LINEAR seems to be used in Blender for background images

    bgl.glEnable(bgl.GL_TEXTURE_2D)

    #bgl.glBlendFunc(bgl.GL_SRC_ALPHA, bgl.GL_ONE_MINUS_SRC_ALPHA)


    bgl.glColor4f(1,1,1,1)
    bgl.glBegin(bgl.GL_QUADS)
    bgl.glTexCoord2d(0,0)
    bgl.glVertex2d(0 + iterations ,100 )
    bgl.glTexCoord2d(0,1)
    bgl.glVertex2d(0+iterations ,100 + height)
    bgl.glTexCoord2d(1,1)
    bgl.glVertex2d(0 + iterations + width, 100 + height )
    bgl.glTexCoord2d(1,0)
    bgl.glVertex2d(0 + iterations + width , 100)
    bgl.glEnd()
    bgl.glDisable(bgl.GL_BLEND)
    bgl.glDisable(bgl.GL_TEXTURE_2D)
    texture.gl_free()

    # restore opengl defaults
    bgl.glLineWidth(1)
    bgl.glDisable(bgl.GL_BLEND)
    bgl.glColor4f(0.0, 0.0, 0.0, 1.0)
Example #13
0
def draw_callback_px(self, context):
    #print("mouse points", len(self.mouse_path))

    #font_id = 0  # XXX, need to find out how best to get this.

    # draw some text
    #blf.position(font_id, 15, 30, 0)
    #blf.size(font_id, 20, 72)
    #blf.draw(font_id, "Hello Word " + str(len(self.mouse_path)))

    image = context.window_manager.love2d3d.image_front  # Image ID
    if image == "":
        return
    self.image = context.blend_data.images[image]  # Get image

    # 50% alpha, 2 pixel width line
    #bgl.glLineWidth(0)
    bgl.glEnable(bgl.GL_BLEND)
    #bgl.glClearColor(0.0, 0.0, 0.0, 0.0);
    #bgl.glBlendFunc(bgl.GL_SRC_ALPHA, bgl.GL_ONE_MINUS_SRC_ALPHA)
    self.image.gl_load()
    bgl.glBindTexture(bgl.GL_TEXTURE_2D, self.image.bindcode[0])
    bgl.glColor4f(1.0, 1.0, 1.0, 0.5)
    bgl.glEnable(bgl.GL_TEXTURE_2D)
    bgl.glTexParameteri(bgl.GL_TEXTURE_2D, bgl.GL_TEXTURE_MIN_FILTER,
                        bgl.GL_NEAREST)
    bgl.glTexParameteri(bgl.GL_TEXTURE_2D, bgl.GL_TEXTURE_MAG_FILTER,
                        bgl.GL_NEAREST)
    #bgl.glTexParameteri(bgl.GL_TEXTURE_2D, bgl.GL_TEXTURE_MIN_FILTER, bgl.GL_LINEAR)
    #bgl.glTexParameteri(bgl.GL_TEXTURE_2D, bgl.GL_TEXTURE_MAG_FILTER, bgl.GL_LINEAR)

    #self.image.bind()
    #bgl.glLineWidth(2)

    #    bgl.glBegin(bgl.GL_LINE_STRIP)
    #    for x, y in self.mouse_path:
    #        bgl.glVertex2i(x, y)
    #
    #    bgl.glEnd()
    #camera = context.space_data.camera.location
    #sclip = context.space_data.clip_start
    #eclip = context.space_data.clip_end
    #lens = context.space_data.lens
    #pers = context.region_data.perspective_matrix
    #fovy = math.atan(pers[5]) * 2
    #aspect = pers[5] / pers[0]
    #bgl.gluPerspective(fovy, aspect, sclip, eclip);
    bgl.glMatrixMode(bgl.GL_MODELVIEW)
    #print(context.region_data.view_matrix)
    #ob = context.active_object
    #buff = bgl.Buffer(bgl.GL_FLOAT, [4, 4], context.region_data.view_matrix.transposed())
    #buff = bgl.Buffer(bgl.GL_FLOAT, [4, 4], ob.matrix_world.transposed())
    #mat = Matrix.Identity(4)
    mat = Matrix.Translation(context.space_data.cursor_location)
    view_align = context.window_manager.love2d3d.view_align
    if view_align:
        iview = Matrix(
            context.region_data.view_matrix).inverted_safe().to_3x3().to_4x4()
    else:
        iview = Matrix.Identity(4)
    buff = bgl.Buffer(bgl.GL_FLOAT, [4, 4], (mat * iview).transposed())
    bgl.glLoadMatrixf(buff)
    #bgl.glLoadIdentity()
    #camera = context.region_data.view_location
    #bgl.gluLookAt(camera.x, camera.y, camera.z, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0)
    bgl.glMatrixMode(bgl.GL_PROJECTION)
    #bgl.glLoadIdentity();
    buff = bgl.Buffer(bgl.GL_FLOAT, [4, 4],
                      context.region_data.perspective_matrix.transposed())
    bgl.glLoadMatrixf(buff)

    scale = context.window_manager.love2d3d.scale
    w, h = self.image.size
    w *= scale
    h *= scale
    #lb = location_3d_to_region_2d(context.region, context.space_data.region_3d, (-w / 2.0, 0, -h / 2.0))
    #rb = location_3d_to_region_2d(context.region, context.space_data.region_3d, (w / 2.0, 0, -h / 2.0))
    #rt = location_3d_to_region_2d(context.region, context.space_data.region_3d, (w / 2.0, 0, h / 2.0))
    #lt = location_3d_to_region_2d(context.region, context.space_data.region_3d, (-w / 2.0, 0, h /2.0))
    if view_align:
        lb = Vector((-w / 2.0, -h / 2.0, 0))
        rb = Vector((w / 2.0, -h / 2.0, 0))
        rt = Vector((w / 2.0, h / 2.0, 0))
        lt = Vector((-w / 2.0, h / 2.0, 0))
    else:
        lb = Vector((-w / 2.0, 0, -h / 2.0))
        rb = Vector((w / 2.0, 0, -h / 2.0))
        rt = Vector((w / 2.0, 0, h / 2.0))
        lt = Vector((-w / 2.0, 0, h / 2.0))
    #print(lt)
    bgl.glBegin(bgl.GL_QUADS)
    bgl.glTexCoord2d(0.0, 0.0)
    bgl.glVertex3f(lb.x, lb.y, lb.z)
    bgl.glTexCoord2d(1.0, 0.0)
    bgl.glVertex3f(rb.x, rb.y, lb.z)
    bgl.glTexCoord2d(1.0, 1.0)
    bgl.glVertex3f(rt.x, rt.y, rt.z)
    bgl.glTexCoord2d(0.0, 1.0)
    bgl.glVertex3f(lt.x, lt.y, lt.z)
    bgl.glEnd()
    self.image.gl_free()
    # restore opengl defaults
    bgl.glLineWidth(1)
    bgl.glDisable(bgl.GL_TEXTURE_2D)
    bgl.glDisable(bgl.GL_BLEND)
    bgl.glColor4f(0.0, 0.0, 0.0, 1.0)