PDA

View Full Version : Transparency problem?



ironduke
05-10-2000, 08:33 AM
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);

Gorg
05-10-2000, 12:37 PM
You didn't specify a blending equation

ironduke
05-12-2000, 05:29 AM
what type of equation would I need?