Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.
Below there is a simple FadeIn method which does not work correctly.
I post it for you may know what is wrong. I use OpenGL 2D, double buffered mode.
Whenever I call fadein() I always get a black screen which is wrong for I expect the current screen to be faded in.
CTimer timer; // just a timer
double min_delay_per_step = min_delay / 9.0;
int nWidth = 640;
int nHeight = 480;
int nSize = 4 * 640 * 480;
unsigned char *pImage = new unsigned char[nSize];
unsigned char *pAlpha = new unsigned char[nSize];
glReadPixels(0,0,nWidth, nHeight, GL_RGBA, GL_UNSIGNED_BYTE,
int shift; // shift amount
for (int i=0; i <= 8; i++)
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
unsigned char *pSrc = pImage;
unsigned char *pDest = pAlpha;
shift = 8-i;
for (int j = 0; j < nWidth*nHeight; j++)
*pDest = *pSrc >> shift; // blue
*pDest = *pSrc >> shift; // green
*pDest = *pSrc >> shift; // red
pSrc++; pDest++; // alpha
glDrawPixels(nWidth, nHeight, GL_RGBA,
// simply swap opengl buffers (double buffered mode)
Some things are sufficent I know but I hope you can understand it well.
I am thankfull for any kind of help for I have gone mad over this.
0 · ·