opengl es - Issues drawing multiple image textures with some disapearing -


i'm looking use opengl blend 4 images screen. first image contains background , other 3 images contain cartoon transparency. goal render 4 images @ once. @ every call render i'm updating top 3 images new images compose new frame.

i'm new opengl , far i'm able achieve blending images i'm noticing horrible issues when render. i'm seeing of top 3 images missing or rendered cropped invisible man...

each lines represents different image.

image cropped issue:
enter image description here

image cropped , 1 image missing:
enter image description here

how should like:
enter image description here

any figuring out issue appreciate it! below code i'm using.

here code use render images.

void moviepreview::preparetexture (gluint texture, glint format, int w, int h) {     // bind generated texture     glbindtexture(gl_texture_2d, texture);     gltexparameterf(gl_texture_2d, gl_texture_min_filter, gl_linear);     gltexparameterf(gl_texture_2d,  gl_texture_mag_filter, gl_linear);     glshademodel(gl_flat);     //glshademodel(gl_smooth);      glteximage2d(gl_texture_2d, 0, format, w, h, 0, format, gl_unsigned_byte, 0);      if (gl_rgba == format)     {         //glcolor4f(1.0f, 1.0f, 1.0f, 1.0f);     }      // crop texture rectangle     glint rect[] = {0, h, w, -h};     gltexparameteriv(gl_texture_2d, gl_texture_crop_rect_oes, rect);     gldrawtexioes(0, 0, 0, w, h); }  void moviepreview::resize (int w, int h) {     logi("native_gl_resize %d %d", w, h);      // init open gl     //glclearcolor(1.0, 1.0, 1.0, 1.0);     glenable(gl_texture_2d);     glenable(gl_blend);     gldisable(gl_dither);     gldisable(gl_lighting);     gldisable(gl_depth_test);     gldisable(gl_color_material);     gldisable(gl_fog);     gldisable(gl_cull_face);     gldisable(gl_stencil_test);     gldisable(gl_color_logic_op);     gldisable(gl_alpha_test);      //glblendfunc(gl_one, gl_one_minus_src_alpha);//new     glblendfunc(gl_src_alpha, gl_one_minus_src_alpha);//new     //glblendfunc(gl_src_alpha, gl_one_minus_dst_alpha);      // generate 1 texture object     glgentextures(max_textures, mtexture);     check_gl_error("glgentextures");      int frameheight = h;//image.rows;     int framewidth = w;//image.cols;      // first texture our background texture     preparetexture(mtexture[0], gl_rgba, mbg.cols, mbg.rows);     preparetexture(mtexture[1], gl_rgba, framewidth, frameheight);     preparetexture(mtexture[2], gl_rgba, framewidth, frameheight);     preparetexture(mtexture[3], gl_rgba, framewidth, frameheight);      msurfacewidth = w;     msurfaceheight = h; }  void moviepreview::render (int64_t* imageids, const int images) {     int                   = 0;     double sleepduration    = 0;      glclear(gl_color_buffer_bit | gl_depth_buffer_bit);      // todo try see if can away loading bg     // since doesn't change might worth loading once ,     // it...     //glbindtexture(gl_texture_2d, mtexture[0]);     //gltexsubimage2d(gl_texture_2d, 0, 0, 0, mbg.cols, mbg.rows, gl_rgba, gl_unsigned_byte, mbg.ptr());     //gldrawtexioes(0, 0, 0, msurfacewidth, msurfaceheight);      // todo pass image batch loader     // load images     (i=0; i<images; i++)     {         if (0 < imageids[i])         {             sprintf(mtemppath, "%s/f1_%lld.png",mprojectpath.c_str(), imageids[i]);             mimageloader[i].loadimage(mtemppath);         }     }      if (0 < mframeduration)     {         // here try control suggested frame rate         // set. calculate since last show image time         // if should sleep or not...         if (0 < mlastdrawtimestamp) {             sleepduration = mframeduration - (now_ms() - mlastdrawtimestamp);         }          if (0 < sleepduration) {             usleep((long)sleepduration*nano_in_ms);         }     }      // draw images     = 0;     (i=0; i<images; i++)     {         if (0 < imageids[i])         {             cv::mat img = mimageloader[i].getimage();             if (!img.empty())             {                 glbindtexture(gl_texture_2d, mtexture[i+1]);                 gltexsubimage2d(gl_texture_2d, 0, 0, 0, img.cols, img.rows, gl_rgba, gl_unsigned_byte, img.ptr());                 gldrawtexioes(0, 0, 0, img.cols, img.rows);             }         }     }      mlastdrawtimestamp = now_ms(); } 

the issue ended being image sources getting modified thread while opengl trying draw them...


Comments

Popular posts from this blog

java - nested exception is org.hibernate.exception.SQLGrammarException: could not extract ResultSet Hibernate+SpringMVC -

sql - Postgresql tables exists, but getting "relation does not exist" when querying -

asp.net mvc - breakpoint on javascript in CSHTML? -