Advertisement

Big question from a newbie (transparent??)

Started by July 02, 2000 07:03 AM
5 comments, last by KappaMic 24 years, 4 months ago
I have a big/little problem... (I''M A NEWBIE!!!!!!) 1) I want a picture to rotate on the screen... ok 2) i want the black pixels to be trasparent (only the true black!!! 0,0,0 ) My routine works, but also the image is trasparent. The black is fully trasparent, the image a bit. What it''s wrong ???? Can someone fix my code ??????? Please, I WANT TO LEARN!!!!!!!!!!!!!! procedure DrawGLScene(); begin glClear(GL_COLOR_BUFFER_BIT or GL_DEPTH_BUFFER_BIT); // Clear The Screen And The Depth Buffer glLoadIdentity(); // Reset The View glDisable(GL_DEPTH_TEST); glBindTexture(GL_TEXTURE_2D, texture[1]); // the background glBegin(GL_QUADS); glNormal3f(-2.0, 0.0, 0.0); glTexCoord2f(0.0, 0.0); glVertex3f(-3.0, -3.0, -3.0); glTexCoord2f(3.0, 0.0); glVertex3f(-3.0, 3.0, -3.0); glTexCoord2f(3.0, 3.0); glVertex3f( 3.0, 3.0, -3.0); //1 glTexCoord2f(0.0, 3.0); glVertex3f( 3.0, -3.0, -3.0); glEnd(); glEnable(GL_DEPTH_TEST); glTranslatef(0.0,0.0,-5.0); glRotatef(xrot,1.0,0.0,0.0); glRotatef(yrot,0.0,1.0,0.0); glRotatef(zrot,0.0,0.0,1.0); glEnable(GL_BLEND); glBlendFunc(GL_ONE,GL_ONE); // ?????????????????????? what can i do ???? it doens''t work!!!!!!!!!!!!!!!!!!! glBindTexture(GL_TEXTURE_2D, texture[0]); // first draw the the bitmap glBegin(GL_QUADS); glNormal3f(-1.0, 0.0, 0.0); glTexCoord2f(0.0, 0.0); glVertex3f(-1.0, -1.0, -1.0); glTexCoord2f(1.0, 0.0); glVertex3f(-1.0, -1.0, 1.0); glTexCoord2f(1.0, 1.0); glVertex3f(-1.0, 1.0, 1.0); glTexCoord2f(0.0, 1.0); glVertex3f(-1.0, 1.0, -1.0); glEnd(); glBindTexture(GL_TEXTURE_2D, texture[2]); // then the mask the mask glBegin(GL_QUADS); glNormal3f(-1.0, 0.0, 0.0); glTexCoord2f(0.0, 0.0); glVertex3f(-1.0, -1.0, -1.0); glTexCoord2f(1.0, 0.0); glVertex3f(-1.0, -1.0, 1.0); glTexCoord2f(1.0, 1.0); glVertex3f(-1.0, 1.0, 1.0); glTexCoord2f(0.0, 1.0); glVertex3f(-1.0, 1.0, -1.0); glEnd(); glDisable(GL_Blend); xrot := xrot + 0.5; yrot := yrot + 2.7; zrot := zrot + 0.3; end; procedure InitGL(Width: GLsizei; Height: GLsizei); // This Will Be Called Right After The GL Window Is Created var fWidth, fHeight: GLfloat; begin LoadGLTextures(); // Load The Texture(s) glEnable(GL_TEXTURE_2D); // Enable Texture Mapping glClearColor(0.0, 0.0, 0.0, 0.0); // Clear The Background Color To Black glClearDepth(1.0); // Enables Clearing Of The Depth Buffer glDepthFunc(GL_LESS); // The Type Of Depth Test To Do glEnable(GL_DEPTH_TEST); // Enables Depth Testing glShadeModel(GL_SMOOTH); // Enables Smooth Color Shading glMatrixMode(GL_PROJECTION); glLoadIdentity(); // Reset The Projection Matrix fWidth := Width; fHeight := Height; gluPerspective(45.0,fWidth/fHeight,0.1,100.0); // Calculate The Aspect Ratio Of The Window glMatrixMode(GL_MODELVIEW); end;
Please post code between the code tags (FAQ), you probably are clearing the buffer with 0, 0, 0, 0.5f. This means black and alpha of 0.5 so everything will be semi transparent
Advertisement
That was me
quote: Original post by Anonymous Poster

Please post code between the code tags (FAQ), you probably are clearing the buffer with 0, 0, 0, 0.5f. This means black and alpha of 0.5 so everything will be semi transparent


sorry for the inconvenient...
I''m cleaning the buffer with 0,0,0,0 so?



Actually, the best way to do this is to load textures which have an alpha channel which is used to mask the image. You can''t use bitmaps for this so you will need something such as the .tga, .sgi, or .png formats to do the trick. Nate (nate.scuzzy.net) has a .tga loader which you could download and use.

Morgan
I might be completely wrong but I think what you need to do is check out the tutorial on masking.I haven''t read it yet myself so as I already said I could be wrong...

-=Jimmy=-
-=Jimmy=-
Advertisement
What I was talking about is exactly what the masking tutorial does, but the mask (alpha channel) is built into the texture, meaning that the texture is rendered masked without having to render it twice (as the masking tutorial does) which can slow down your app.

Morgan

This topic is closed to new replies.

Advertisement