def show(self, client, x_pos, y_pos, width, height):
glEnable(GL_TEXTURE_2D)
tex_id = client.bindTexture(self._image)
self._painter.begin(self._image)
self._painter.fillRect(self._image.rect(), self._background_color)
self._painter.setPen(self._text_color)
self._painter.setFont(self._font)
self._painter.drawText(self._rect, QtCore.Qt.TextExpandTabs | QtCore.Qt.TextSingleLine | \
QtCore.Qt.AlignLeft, self._text)
self._painter.end()
glTranslate(x_pos/width, y_pos/height, 0)
width_norm = self.width()/width
height_norm = self.height()/height
glBegin(GL_QUADS)
glTexCoord(0.0, 0.0); glVertex(-width_norm, height_norm, 0.0)
glTexCoord(1.0, 0.0); glVertex(width_norm, height_norm, 0.0)
glTexCoord(1.0, 1.0); glVertex(width_norm, -height_norm, 0.0)
glTexCoord(0.0, 1.0); glVertex(-width_norm, -height_norm, 0.0)
glEnd()
glTranslate(-x_pos/width, -y_pos/height, 0)
client.deleteTexture(tex_id)
glDisable(GL_TEXTURE_2D)
def show(self, client, x_pos, y_pos, width, height):
glEnable(GL_TEXTURE_2D)
tex_id = client.bindTexture(self._image)
self._painter.begin(self._image)
self._painter.fillRect(self._image.rect(), self._background_color)
self._painter.setPen(self._text_color)
self._painter.setFont(self._font)
self._painter.drawText(self._rect, QtCore.Qt.TextExpandTabs | QtCore.Qt.TextSingleLine | \
QtCore.Qt.AlignLeft, self._text)
self._painter.end()
glTranslate(x_pos/width, y_pos/height, 0)
width_norm = self.width()/width
height_norm = self.height()/height
glBegin(GL_QUADS)
glTexCoord(0.0, 0.0); glVertex(-width_norm, height_norm, 0.0)
glTexCoord(1.0, 0.0); glVertex(width_norm, height_norm, 0.0)
glTexCoord(1.0, 1.0); glVertex(width_norm, -height_norm, 0.0)
glTexCoord(0.0, 1.0); glVertex(-width_norm, -height_norm, 0.0)
glEnd()
glTranslate(-x_pos/width, -y_pos/height, 0)
client.deleteTexture(tex_id)
glDisable(GL_TEXTURE_2D)
To copy to clipboard, switch view to plain text mode
show is called as part of QGLWidget paintEvent.
Bookmarks