textures - OpenGL Fade in / fade out a texture2D -


i writing application displays .jpg files stored texture2d (rgb) in opengl. want smoothly change 1 texture2d next fading black, fading next texture.

after looking explanation wrote this.

void rendertexture() {   glmatrixmode(gl_modelview);    glenable(gl_texture_2d);   glbindtexture(gl_texture_2d, mtexture);    glusphere(mquad, 1.0f, 50, 50);    glbindtexture(gl_texture_2d, 0); }  void fadetoblack() {   glenable(gl_blend);   glblendfunc(gl_one, gl_one_minus_src_alpha);    (glfloat alpha = 1.0; alpha > 0.0; alpha -= 0.05)   {     glcolor4f(0.0, 0.0, 0.0, alpha);     rendertexture();      glflush();     glutswapbuffers();   }    gldisable(gl_blend); } 

unfortunately, not fade black instead switches black immediately. must have misunderstanding on how gl_blend working here. can please point out doing wrong?

** edit: did trick. lot j-p , benjamin pointers **

void fadetoblack() {   (glfloat alpha = 1.0; alpha > 0.0; alpha -= 0.001)   {     rendertexture();     glcolor4f(alpha, alpha, alpha, alpha);      glflush();     glutswapbuffers();   }   glcolor4f(1.0, 1.0, 1.0, 1.0); } 

the loop executing texture changes appear happen instantly.


Comments

Popular posts from this blog

c# - Better 64-bit byte array hash -

webrtc - Which ICE candidate am I using and why? -

php - Zend Framework / Skeleton-Application / Composer install issue -