Results 1 to 3 of 3

Thread: Transparency problem?

  1. #1

    Transparency problem?

    I am drawing an image, which is loaded from a png file to a larger texture using glTexSubImage, the problem is the sub Image transparent area is drawn black and not transparent?

    glClearColor(0.0f, 0.0f, 0.0f, 1.0f) ;
    glShadeModel(GL_FLAT);
    glEnable(GL_DEPTH_TEST);

    int x,y;
    for(x =0; x < 128; x++)
    {
    for(y = 0; y < 128; y++)
    {
    Tile[x][y][0] = 255;
    Tile[x][y][1] = 0;
    Tile[x][y][2] = 0;
    Tile[x][y][3] = 255;

    }
    }



    //SubTile[0] = auxDIBImageLoad("E:\\Grass.bmp");
    //SubTile[1] = auxDIBImageLoad("E:\\Wheat.bmp");

    pngLoadRaw("E:\\Grass.png",&info[0]);
    pngLoadRaw("E:\\Grass_topleft.png",&info[1]);

    glPixelStorei(GL_UNPACK_ALIGNMENT, 1);

    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);


    glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE) ;

    glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 128, 128,
    0, GL_RGBA, GL_UNSIGNED_BYTE,Tile) ;

    glTexSubImage2D(GL_TEXTURE_2D,0,0,0,64,64,GL_RGB,G L_UNSIGNED_BYTE,info[0].Data);
    glTexSubImage2D(GL_TEXTURE_2D,0,0,64,64,64,GL_RGB, GL_UNSIGNED_BYTE,info[0].Data);
    glTexSubImage2D(GL_TEXTURE_2D,0,64,0,64,64,GL_RGB, GL_UNSIGNED_BYTE,info[0].Data);
    glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
    glEnable(GL_BLEND);
    glTexSubImage2D(GL_TEXTURE_2D,0,64,0,64,64,GL_RGBA ,GL_UNSIGNED_BYTE,info[1].Data);

  2. #2
    Senior Member Frequent Contributor
    Join Date
    Feb 2000
    Posts
    569

    Re: Transparency problem?

    You didn't specify a blending equation

  3. #3

    Re: Transparency problem?

    what type of equation would I need?

Similar Threads

  1. problem with transparency
    By alex2 in forum OpenGL: Basic Coding
    Replies: 13
    Last Post: 04-12-2011, 08:21 AM
  2. Transparency problem
    By betwixt in forum OpenGL: Basic Coding
    Replies: 2
    Last Post: 03-14-2010, 09:09 PM
  3. Transparency problem
    By Viper00 in forum OpenGL: Basic Coding
    Replies: 4
    Last Post: 12-26-2003, 08:46 AM
  4. problem with transparency
    By dcd in forum OpenGL: Advanced Coding
    Replies: 4
    Last Post: 08-14-2002, 05:01 AM
  5. Transparency problem
    By Roach in forum OpenGL: Basic Coding
    Replies: 4
    Last Post: 10-05-2000, 05:22 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