I'm trying to render to a frame buffer. I did this:
renderer.gl_context.make_current();
renderer.gl.GenFramebuffers(1, &mut fbo);
renderer.gl.BindFramebuffer(gl::FRAMEBUFFER, fbo);
renderer.gl.GenTextures(1, &mut tex);
renderer.gl.BindTexture(gl::TEXTURE_2D, tex);
renderer.gl.TexImage2D(
gl::TEXTURE_2D,
0,
gl::RGB as i32,
width as i32,
height as i32,
0,
gl::RGB,
gl::UNSIGNED_BYTE,
std::ptr::null() as *const libc::c_void,
);
renderer.gl.TexParameteri(
gl::TEXTURE_2D,
gl::TEXTURE_MIN_FILTER,
gl::LINEAR.try_into().unwrap(),
);
renderer.gl.TexParameteri(
gl::TEXTURE_2D,
gl::TEXTURE_MAG_FILTER,
gl::LINEAR.try_into().unwrap(),
);
renderer.gl.FramebufferTexture2D(
gl::FRAMEBUFFER,
gl::COLOR_ATTACHMENT0,
gl::TEXTURE_2D,
tex,
0,
);
but the drawing code makes use of other textures as well, and they are bound to GL_TEXTURE0 to GL_TEXTURE_2. I'm always calling renderer.gl.BindFramebuffer(gl::FRAMEBUFFER, fbo) before drawing, but the drawing calls use GL_TEXTURE0 to GL_TEXTURE_2, so where is the tex texture bound? Should I bind it to a texture unit before drawing? Should this texture unit be different from GL_TEXTURE0 to GL_TEXTURE_2?