c++ - problem blending properly in openGL -


i'm trying draw 2d character sprite on top of 2d tilemap, when draw character he's got odd stuff behind him. isn't in sprite, think blending.

this how opengl set up:

void initgl(int width, int height)          // call right after our opengl window created. {      glviewport(0, 0, width, height);     glclearcolor(0.0f, 0.0f, 0.0f, 0.0f);       // clear background color black     glcleardepth(1.0);              // enables clearing of depth buffer     gldepthfunc(gl_less);               // type of depth test     gldisable(gl_depth_test);           // enables depth testing     //glshademodel(gl_smooth);          // enables smooth color shading     glenable(gl_texture_2d);                        // enable texture mapping ( new )     glshademodel(gl_flat);     glmatrixmode(gl_projection);     glenable(gl_blend);     glblendfunc(gl_one , gl_one_minus_src_alpha);     glhint(gl_perspective_correction_hint, gl_nicest);     glalphafunc(gl_greater, 0.5f);      glmatrixmode(gl_projection);//configuring projection matrix     glloadidentity();//reset matrix     glortho(0, width, 0, height, 0.0f, 100.0f);//set 2d projection matrix  } 

how should set work (i.e. drawing sprite without odd stuff behind him.

this talking about: http://i.stack.imgur.com/cmotj.png

ps: need able put transparent/semi-transparent images on top of each other , have whats behind them visible too

does sprite have premultiplied alpha? glblendfunc setup little unusual, if don't have premultiplied alpha causing issue.


Comments

Popular posts from this blog

php - What is the difference between $_SERVER['PATH_INFO'] and $_SERVER['ORIG_PATH_INFO']? -

fortran - Function return type mismatch -

queue - mq_receive: message too long -