Advertisement

Alpha blending?

Started by January 19, 2001 01:09 PM
17 comments, last by Alazorn 23 years, 10 months ago
What the heck happened to ma code ???
Well Ill try again here :

int LoadGLTextures() //Loads bitmaps and converts to textures
{
int status=false;
char *names[10]={"Data/cubes_texture.bmp","Data/logo.bmp","Data/presents.bmp","Data/demo.bmp","Data/call.bmp","Data/force.bmp","Data/white.bmp","Data/env_back.bmp","Data/sky.bmp","Data/star.bmp"};
AUX_RGBImageRec *texture1[10];
memset(texture1,0,sizeof(void*)*10);
for (int a=0;a<=9;a++)
{
if (texture1Link
ARGHH, this forum realy sucks, Ill tell you whats inside that for loop

status=true;
glGenTextures(1, &texturesLink
Advertisement
What am I doing wrong??????????
quote: Original post by Alazorn

ARGHH, this forum realy sucks, Ill tell you whats inside that for loop

Don''t knock the forum. You have HTML stuff inside there so it''s getting eaten, it isn''t gamedev-forum specific
Put your code in [_source_] blocks, without the _''s.

Here it is:

  int LoadGLTextures() //Loads bitmaps and converts to textures{  int status=false;  char *names[10]={"Data/cubes_texture.bmp","Data/logo.bmp","Data/presents.bmp","Data/demo.bmp","Data/call.bmp","Data/force.bmp","Data/white.bmp","Data/env_back.bmp","Data/sky.bmp","Data/star.bmp"};  AUX_RGBImageRec *texture1[10];  memset(texture1,0,sizeof(void*)*10);  for (int  a=0;a<=9;a++)  {    if (texture1[a]http://=LoadBMP(names[a])) //Loads the texture    {      status=true;      glGenTextures(1, &textures[a]);         //Generates the texture      glBindTexture(GL_TEXTURE_2D,textures[a]); //Creates the texture      glTexImage2D(GL_TEXTURE_2D,0,3,texture1[a]->sizeX,texture1[a]->sizeY,0,GL_RGB,GL_UNSIGNED_BYTE,texture1[a]->data);      glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR); //Type of Zoom filter      glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR_MIPMAP_NEAREST); //Type of Min filter      gluBuild2DMipmaps(GL_TEXTURE_2D,3,texture1[a]->sizeX,texture1[a]->sizeY,GL_RGB,GL_UNSIGNED_BYTE,texture1[a]->data);    }    if (texture1[a])    {      if (texture1[a]->data)        free(texture1[a]->data);      free(texture1[a]);    }  }  return status;}     


If you want to load the r, g, b, a, you''ll need to write your own loader.
Um, cool so do you ppl have a loader for me?
Goto www.openil.org and use that. It can load almost any image format you can think of.

Zack

A moment enjoyed is not wasted.
-Gamers.com
A moment enjoyed is not wasted. -Gamers.com
Advertisement
Hum, ya I could use that but I realy liked the idea about having black as transparent, I just dont know how to code it?
Hey zedzeek, could you tell me how I can implement that black becomes completly transparent in my code?

I kinda got it to work if I start by drawing the images longest away on the z axis first and then draw closer,but that is hard to do if I rotate the scene a lot
There are two ways to do this.
1. Use the blending method.
2. Use the alphatest method

Here is the blending way:
        glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);glEnable(GL_BLEND);        


You need to sort and draw your scene back to front using this method.

Here is the alpha test way:
              glEnable(GL_ALPHA_TEST);glAlphaFunc(GL_GREATER, 0.0f );    

You don't need to sort yor scene using this method. I usually use 0.1f in the glAlphaFunc because it has a less blocky look.

If you have any more questions just email me,
Zack

A moment enjoyed is not wasted.
-Gamers.com

Edited by - zeotron on January 22, 2001 2:49:00 PM
A moment enjoyed is not wasted. -Gamers.com

This topic is closed to new replies.

Advertisement