Rendering to Texture with bgl in Python
I am not an openGL expert. The documentation links to OpenGL 2.1. I don't think this version supports render to texture.

import bpy
import bgl

viewport_info = bgl.Buffer(bgl.GL_INT, 4)
bgl.glGetIntegerv(bgl.GL_VIEWPORT, viewport_info)

WIDTH  = 400
HEIGHT = 400

img = bpy.data.images.get("texture")
img.gl_load(0, bgl.GL_NEAREST, bgl.GL_NEAREST)
tex = img.bindcode

out = bpy.data.images.new("output", WIDTH, HEIGHT)
buffer = bgl.Buffer(bgl.GL_FLOAT, WIDTH * HEIGHT * 4)

bgl.glDisable(bgl.GL_SCISSOR_TEST)
bgl.glViewport(0, 0, HEIGHT, WIDTH)

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

bgl.glMatrixMode(bgl.GL_PROJECTION)
bgl.glPushMatrix()
bgl.glLoadIdentity()
bgl.gluOrtho2D(0, 1, 0, 1)

bgl.glClearDepth(1.0)
bgl.glClearColor(0.0, 0.0, 0.0, 0.0)
bgl.glClear(
    bgl.GL_COLOR_BUFFER_BIT |
    bgl.GL_DEPTH_BUFFER_BIT
)

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

bgl.glBegin(bgl.GL_TRIANGLES)

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

bgl.glEnd()

bgl.glCopyTexImage2D(
    bgl.GL_TEXTURE_2D, #target
    0, #level
    bgl.GL_RGBA, #internalformat
    0, #x
    0, #y
    WIDTH,
    HEIGHT,
    0 #border
)

bgl.glBegin(bgl.GL_QUADS)

bgl.glColor3f(1.0, 1.0, 1.0)
bgl.glTexCoord2f(0.0, 0.0)
bgl.glVertex2f(0.0, 0.5)
bgl.glTexCoord2f(1.0, 0.0)
bgl.glVertex2f(0.5, 0.5)
bgl.glTexCoord2f(1.0, 1.0)
bgl.glVertex2f(0.5, 1.0)
bgl.glTexCoord2f(0.0, 1.0)
bgl.glVertex2f(0.0, 1.0)

bgl.glEnd()

bgl.glFinish()
#bgl.glGetTexImage(bgl.GL_TEXTURE_2D, 0, bgl.GL_RGBA, bgl.GL_FLOAT, buffer)
bgl.glReadPixels(0, 0, WIDTH, HEIGHT , bgl.GL_RGBA, bgl.GL_FLOAT, buffer)
out.pixels = buffer[:]
img.gl_free()

#reset
bgl.glEnable(bgl.GL_SCISSOR_TEST)

#necessary(?)
bgl.glViewport(*tuple(viewport_info))

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


Result