Results 1 to 2 of 2

Thread: FadeOut effect/semi transparency

  1. #1
    Junior Member Newbie
    Join Date
    Nov 2011
    Location
    AK
    Posts
    17

    FadeOut effect/semi transparency

    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:

    Code :
     
    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:
    Code :
     
        	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
    Code :
     
    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

  2. #2
    Member Contributor
    Join Date
    Oct 2011
    Posts
    73

    Re: FadeOut effect/semi transparency

    You don't need textures for this effect. You can draw a black quad that covers your screen (look for "full screen quad") and use blending to achieve the effect while you manipulate the vertex color's alpha each frame (or however you wish).

    Also, this:

    Code :
     // 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);

    has to be the strangest way of saying:
    Code :
     // Create a place to store the texture
        AUX_RGBImageRec * TextureImage = auxDIBImageLoad(name);

Similar Threads

  1. Problem:PNG-Semi-Transparency & Sub-Pixel-Movement
    By HeldOT in forum OpenGL: Basic Coding
    Replies: 2
    Last Post: 09-17-2010, 06:03 AM
  2. Masking and semi-transparency together
    By AE in forum OpenGL: Advanced Coding
    Replies: 6
    Last Post: 03-30-2005, 06:40 PM
  3. Weird ghosting effect in textures with some transparency.
    By dodgyposse in forum OpenGL: Advanced Coding
    Replies: 12
    Last Post: 02-27-2002, 04:45 AM
  4. Fadeout on the whole frame
    By fabos in forum OpenGL: Advanced Coding
    Replies: 2
    Last Post: 04-05-2001, 08:55 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Proudly hosted by Digital Ocean