I have a IOSurface backed texture which is limited to GL_TEXTURE_RECTANGLE_ARB and doesn't support mipmapping. I'm trying to copy this texture to another texture bound to GL_TEXTURE_2D and then perform mipmapping on that one instead. But I'm having problems copying my texture. I can't even get it to work by just copying it to another GL_TEXTURE_RECTANGLE_ARB. Here is my code:
var arbTexture = GLuint()
glGenTextures(1, &arbTexture)
/* Do some stuff to fill arbTexture with image data */
glEnable(GLenum(GL_TEXTURE_RECTANGLE_ARB))
glBindTexture(GLenum(GL_TEXTURE_RECTANGLE_ARB), arbTexture)
// At this point, if I return here, my arbTexture draws just fine
// Trying to copy to another texture (fbo and texture generated previously):
glBindFramebuffer(GLenum(GL_FRAMEBUFFER), fbo);
glFramebufferTexture2D(GLenum(GL_READ_FRAMEBUFFER), GLenum(GL_COLOR_ATTACHMENT0), GLenum(GL_TEXTURE_RECTANGLE_ARB), arbTexture, 0)
glFramebufferTexture2D(GLenum(GL_DRAW_FRAMEBUFFER), GLenum(GL_COLOR_ATTACHMENT1), GLenum(GL_TEXTURE_RECTANGLE_ARB), texture, 0)
glDrawBuffer(GLenum(GL_COLOR_ATTACHMENT1))
glBlitFramebuffer(0, 0, GLsizei(width), GLsizei(height), 0, 0, GLsizei(width), GLsizei(height), GLbitfield(GL_COLOR_BUFFER_BIT)
, GLenum(GL_NEAREST))
glBindTexture(GLenum(GL_TEXTURE_RECTANGLE_ARB), texture)
// At this point, the texture is all black