Hello
I am trying to obtain a simple fadeout effect by having a big textured quad cover the screen with the alpha that gradually increases until being full black… I don’t quite understand in what part of the drawing code I should alter the alpha… I have a wrapper class for textures, this is how I load a texture:
void GLTexture::LoadBMP(char *name)
{
// Create a place to store the texture
AUX_RGBImageRec *TextureImage[1];
// Set the pointer to NULL
memset(TextureImage,0,sizeof(void *)*1);
// Load the bitmap and assign our pointer to it
TextureImage[0] = auxDIBImageLoad(name);
// Just in case we want to use the width and height later
width = TextureImage[0]->sizeX;
height = TextureImage[0]->sizeY;
// Generate the OpenGL texture id
glGenTextures(1, &texture[0]);
// Bind this texture to its id
glBindTexture(GL_TEXTURE_2D, texture[0]);
// Use mipmapping filter
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR_MIPMAP_NEAREST);
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR);
// Generate the mipmaps
gluBuild2DMipmaps(GL_TEXTURE_2D, 3, TextureImage[0]->sizeX, TextureImage[0]->sizeY, GL_RGB, GL_UNSIGNED_BYTE, TextureImage[0]->data);
// Cleanup
if (TextureImage[0])
{
if (TextureImage[0]->data)
free(TextureImage[0]->data);
free(TextureImage[0]);
}
}
Then in the drawing section I enable glBlend and activate the texture:
gluOrtho2D(0, SCREEN_WIDTH, 0, SCREEN_HEIGHT);
glMatrixMode (GL_MODELVIEW);
glLoadIdentity();
glClearColor( 1.0f, 1.0f, 1.0f, 1.0f );
glEnable( GL_BLEND );
glBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA );
tex.Use();
//Draw the textured quad here
void GLTexture::Use()
{
glEnable(GL_TEXTURE_2D); // Enable texture mapping
glBindTexture(GL_TEXTURE_2D, texture[0]); // Bind the texture as the current one
}
Is there somewhere in this structure that I can implement said effect?
Thanks for your help