OpenGL texture mapping fails in 3D view.

I am trying to display textures using Python and bgl in the 3D viewport. Although bgl texturemapping works when displaying in a panel, in the 3D view all textures come out black… Does anyone know why this is and if there is some way of getting around this? I’m trying to resurrect the old TranspRef script.

Sorry people I made a mistake in the image loading code, it loaded a black image.