Using Front and Rear camera at the same time
Akhilesh-Gogikar opened this issue · 1 comments
Hi @terryky
I have been trying to get 2 cameras working at the same time. Looks like you have utilizes camera 2 api so it's possible. For some reason merely duplicating the pipeline to the srctex isn't working for a second camera.
I think the issue is with the hardware buffer. Or something only one camera works at a time. I think the pipeline to the srctex can be simplified to be available as an api. Could you give me some pointers, I have been stuck at it for a month now. Thanks!
Hi,
After much trial and error I figured that why not pass the tex_cameras directly to render_frame() and it works! The problem I think is with how I have written the CropCameraTexture Function:
void
AppEngine::CropCameraTexture (void)
{
texture_2d_t srctex = glctx.tex_camera;
texture_2d_t srctex1 = glctx.tex_camera1;
if (!glctx.tex_camera_valid)
srctex = glctx.tex_static;
if (!glctx.tex_camera1_valid)
srctex1 = glctx.tex_static1;
/* render to square FBO */
render_target_t *rtarget = &glctx.rtarget_crop;
set_render_target (rtarget);
set_2d_projection_matrix (rtarget->width, rtarget->height);
glClear (GL_COLOR_BUFFER_BIT);
int draw_x, draw_y, draw_w, draw_h;
adjust_texture (rtarget->width, rtarget->height, srctex.width, srctex.height,
&draw_x, &draw_y, &draw_w, &draw_h, 1);
/* when we use inner camera, enable horizontal flip. */
int flip = m_camera_facing ? RENDER2D_FLIP_H : 0;
flip |= RENDER2D_FLIP_V;
draw_2d_texture_ex (&srctex, draw_x, draw_y, draw_w, draw_h, flip);
/* reset to the default framebuffer */
rtarget = &glctx.rtarget_main;
set_render_target (rtarget);
set_2d_projection_matrix (rtarget->width, rtarget->height);
}
Can you point out the error so that I can use tex_input directly?