Created
April 19, 2017 13:21
-
-
Save MortimerGoro/89ebaacf61367e495ebe1087aeeb444b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if self.fbo_texture != layer.texture_id { | |
// Attach external texture to the used later in BlitFramebuffer. | |
gl::BindFramebuffer(gl::FRAMEBUFFER, self.fbo_id); | |
gl::FramebufferTexture2D(gl::FRAMEBUFFER, gl::COLOR_ATTACHMENT0, gl::TEXTURE_2D, layer.texture_id, 0); | |
self.fbo_texture = layer.texture_id; | |
} | |
let texture_size = layer.texture_size.unwrap_or_else(|| { | |
(self.render_size.width as u32, self.render_size.height as u32) | |
}); | |
// BlitFramebuffer: external texture to gvr pixel buffer. | |
gvr::gvr_frame_bind_buffer(self.frame, 0); | |
gl::BindFramebuffer(gl::READ_FRAMEBUFFER, self.fbo_id); | |
gl::BlitFramebuffer(0, 0, texture_size.0 as i32, texture_size.1 as i32, | |
0, 0, self.render_size.width, self.render_size.height, | |
gl::COLOR_BUFFER_BIT, gl::LINEAR); | |
gvr::gvr_frame_unbind(self.frame); | |
// Set up uvs. | |
gvr::gvr_buffer_viewport_set_source_uv(self.left_eye_vp, gvr_texture_bounds(&layer.left_bounds)); | |
gvr::gvr_buffer_viewport_set_source_uv(self.right_eye_vp, gvr_texture_bounds(&layer.right_bounds)); | |
// Submit frame. | |
gvr::gvr_frame_submit(mem::transmute(&self.frame), self.viewport_list, self.synced_head_matrix); | |
// Restore bound fbo. | |
gl::BindFramebuffer(gl::FRAMEBUFFER, current_fbo as u32); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment