Advertisement

05.09.2004 at 02:00PM PDT, ID: 20983278
[x]
Attachment Details

32-bit textures and alpha transparency (OpenGL)

Asked by rossryan in 3D Game Programming

Tags: opengl, transparency, alpha, texture

I think I'm going insane...

I'm loading bitmaps from a .Theme file. They are 32-bit. But, for some reason, OpenGL draws the transparent portions as black instead of clear. I'm using the BGRA extension, if that helps.


public void LoadTexture(Bitmap name, ref int target)
            {
                  //Debug.WriteLine(file.PixelFormat);                              
                  using(Bitmap bitmap = new Bitmap(name))
                  {
                        bitmap.RotateFlip(RotateFlipType.RotateNoneFlipY);
                        
                        Rectangle rectangle = new Rectangle(0, 0, bitmap.Width,
                              bitmap.Height);
                        BitmapData bitmapData = bitmap.LockBits(rectangle,
                              ImageLockMode.ReadOnly, PixelFormat.Format32bppArgb);

                        
                              
                        Gl.glGenTextures(1, out target);
                        Gl.glBindTexture(Gl.GL_TEXTURE_2D, target);
                        Gl.glTexParameteri(Gl.GL_TEXTURE_2D,
                              Gl.GL_TEXTURE_MAG_FILTER, Gl.GL_LINEAR);
                        Gl.glTexParameteri(Gl.GL_TEXTURE_2D,
                              Gl.GL_TEXTURE_MIN_FILTER, Gl.GL_LINEAR);
                        Glu.gluBuild2DMipmaps(Gl.GL_TEXTURE_2D, 3,
                              bitmapData.Width, bitmapData.Height,
                              Gl.GL_BGRA_EXT, Gl.GL_UNSIGNED_BYTE,
                              bitmapData.Scan0);
                        bitmap.UnlockBits(bitmapData);
                        
                              

                  }
            }

Any ideas why it displays as black?Start Free Trial
[+][-]05.09.2004 at 11:09PM PDT, ID: 11028735

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zone: 3D Game Programming
Tags: opengl, transparency, alpha, texture
Sign Up Now!
Solution Provided By: davebytes
Participating Experts: 2
Solution Grade: A
 
 
[+][-]05.09.2004 at 11:28PM PDT, ID: 11028824

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]05.09.2004 at 11:32PM PDT, ID: 11028837

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]05.16.2004 at 03:00AM PDT, ID: 11080426

Assisted solutions are selected by the member who asked the question as a comment that contributed to their question's solution.

Start your 7-day free trial to view this Assisted Solution or ask the Experts your question.

 
[+][-]05.16.2004 at 09:20AM PDT, ID: 11082064

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]05.17.2004 at 10:31PM PDT, ID: 11095486

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]05.17.2004 at 11:23PM PDT, ID: 11095643

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]05.17.2004 at 11:34PM PDT, ID: 11095690

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]05.17.2004 at 11:35PM PDT, ID: 11095693

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]05.17.2004 at 11:37PM PDT, ID: 11095697

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]06.10.2004 at 02:46AM PDT, ID: 11277607

Experts Exchange has a courteous staff of administrators who help members get the most out of the website by means of administrative comments like this one.

Start your 7-day free trial to view this Administrative Comment or ask the Experts your question.

 
[+][-]06.14.2004 at 05:50AM PDT, ID: 11305763

Experts Exchange has a courteous staff of administrators who help members get the most out of the website by means of administrative comments like this one.

Start your 7-day free trial to view this Administrative Comment or ask the Experts your question.

 
 
Loading Advertisement...
20080716-EE-VQP-32