Hi,
I’m trying to draw simple image in 3D viewport. It works quite well, but it displays image on every 3D view.
Here is code for to display image I use:
def draw_IR_preview(self, context, region):
if region.type == 'WINDOW':
viewWidth = region.width
viewHeight = region.height
x1 = 0
y1 = 0
x2 = viewWidth
y2 = viewHeight
color=[1,1,1,1]
try:
img = bpy.data.images['ir.bmp']
img.reload()
except:
img = bpy.data.images.load(os.path.join(exportPath, 'ir.bmp'))
img.gl_load(bgl.GL_NEAREST, bgl.GL_NEAREST)
bgl.glBindTexture(bgl.GL_TEXTURE_2D, img.bindcode)
bgl.glEnable(bgl.GL_TEXTURE_2D)
bgl.glEnable(bgl.GL_BLEND)
bgl.glBegin(bgl.GL_QUADS)
bgl.glTexCoord2f(0,0)
bgl.glVertex2f(x1,y1)
bgl.glTexCoord2f(0,1)
bgl.glVertex2f(x1,y2)
bgl.glTexCoord2f(1,1)
bgl.glVertex2f(x2,y2)
bgl.glTexCoord2f(1,0)
bgl.glVertex2f(x2,y1)
bgl.glEnd()
Is there any way to draw on specific 3D view instead of all?