OpenGL code not working in 2.77

I have a routine to draw textures on screen. It works perfect in 2.76 but is not working in 2.77. Why?


# -------------------------------------------------------------
# Draw a texture on screen
#
# out: bpy.data.images from: bpy.data.images.load(path) 
# -------------------------------------------------------------
def draw_texture(posx, posy, out, width=16, height=16, alpha=True):
    try:
        viewport_info = bgl.Buffer(bgl.GL_INT, 4)
        bgl.glGetIntegerv(bgl.GL_VIEWPORT, viewport_info)


        bgl.glMatrixMode(bgl.GL_PROJECTION)
        bgl.glPushMatrix()
        bgl.glLoadIdentity()


        bgl.glMatrixMode(bgl.GL_MODELVIEW)
        bgl.glPushMatrix()
        bgl.glLoadIdentity()


        # defines ortographic view
        bgl.glViewport(posx, posy, width, height)
        bgl.gluOrtho2D(0.0, width, 0.0, height)


        # Bind texture
        out.gl_load(0, bgl.GL_NEAREST, bgl.GL_NEAREST)
        bgl.glColor3f(1.0, 1.0, 1.0)
        bgl.glEnable(bgl.GL_TEXTURE_2D)
        # API change since 2.77.0
        if bpy.app.version >= (2, 77, 0):
            tex = out.bindcode[0]
        else:
            tex = out.bindcode


        bgl.glBindTexture(bgl.GL_TEXTURE_2D, tex)


        # defines drawing area
        if alpha is True:
            bgl.glEnable(bgl.GL_BLEND)


        bgl.glBegin(bgl.GL_QUADS)


        bgl.glTexCoord2f(0.0, 0.0)
        bgl.glVertex2f(0.0, 0.0)


        bgl.glTexCoord2f(1.0, 0.0)
        bgl.glVertex2f(width, 0.0)


        bgl.glTexCoord2f(1.0, 1.0)
        bgl.glVertex2f(width, height)


        bgl.glTexCoord2f(0.0, 1.0)
        bgl.glVertex2f(0.0, height)


        bgl.glEnd()


        # -----------------------
        # restore opengl defaults
        # -----------------------
        bgl.glDisable(bgl.GL_TEXTURE_2D)


        bgl.glMatrixMode(bgl.GL_PROJECTION)
        bgl.glPopMatrix()


        bgl.glMatrixMode(bgl.GL_MODELVIEW)
        bgl.glPopMatrix()


        bgl.glLineWidth(1)
        bgl.glDisable(bgl.GL_BLEND)
        bgl.glColor4f(0.0, 0.0, 0.0, 1.0)


        # defines ortographic view
        bgl.glViewport(viewport_info[0], viewport_info[1], viewport_info[2], viewport_info[3])


        return True


    except:
        print("Unexpected error:" + str(sys.exc_info()))
        return False

I have seen an API change in bindcode, but it is not working.