Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Graphics > OpenGL 3D API > Another Transpa...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 1 of 5 Topic 4891 of 5017
Post > Topic >>

Another Transparency Problem using png

by grayaii <grayaii@[EMAIL PROTECTED] > Aug 27, 2008 at 08:20 AM

Hi,
I've been struggling with getting my texture's transparent areas to be
actually transparent, but they always appear black.
I've searched and tried most the suggestions here in this forum and no
luck (just doing a search for "transparency" gets a bunch of hits with
a bunch of good solutions, but I just can't seem to get it to work for
me).

In a nutshell, here is what I'm doing (I'm using C# with CsGL):
// Init my textures:
CsGL.OpenGL.OpenGLTexture2D m_texture1;
CsGL.OpenGL.OpenGLTexture2D m_texture2;
m_texture1 = new OpenGLTexture2D("myImage1.PNG");
m_texture2 = new OpenGLTexture2D("myImage2.PNG");

// Draw my textures:
public void Render()
{
	GL.glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
	GL.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT);

        GL.glEnable(GL.GL_BLEND);
        GL.glDisable(GL.GL_DEPTH_TEST);
        GL.glEnable(GL.GL_ALPHA_TEST);

        GL.glBlendFunc(GL.GL_SRC_ALPHA, GL.GL_ONE_MINUS_SRC_ALPHA);

        // Some of the different things I've tried:
        //GL.glColor4f(1.0f, 0.0f, 1.0f, 1.0f);

        //GL.glAlphaFunc(GL.GL_GREATER, 0.0f);
        //GL.glAlphaFunc(GL.GL_NOTEQUAL, 1.0f);
        //GL.glDisable(GL.GL_ALPHA_TEST);

        //GL.glTexEnvf(GL.GL_TEXTURE_ENV, GL.GL_TEXTURE_ENV_MODE,
GL.GL_COMBINE_ARB);
        //GL.glTexEnvf(GL.GL_TEXTURE_ENV, GL.GL_COMBINE_RGB_ARB,
GL.GL_ADD);

       // Draw texture1:
       m_texture1.Bind()
       GL.glBegin(GL.GL_QUADS);
       ... the ususal glTexCoord2f and glVertex2f code ...
       GL.glEnd();

       // Draw texture2:
       m_texture2.Bind()
       GL.glBegin(GL.GL_QUADS);
       ... the ususal glTexCoord2f and glVertex2f code ...
       GL.glEnd();
}
I've tried a bunch of different combinations  of glAlphaFunc,
glTexEnvf, and glColor4f (I left some commented out...), but the
transparent areas of the png files always show up as black.  I would
expect that when texture2 is drawn, I'd be able to see texture1 under
it.

I would like to take advantage of png's alpha channel, and NOT use bmp
files. I feel I'm soooo close to a solution, but after a week of
banging my head and trying different things I feel I need to post
here.
Thanks in advance!
 




 5 Posts in Topic:
Another Transparency Problem using png
grayaii <grayaii@[EMAI  2008-08-27 08:20:44 
Re: Another Transparency Problem using png
"jbwest" <jb  2008-08-27 10:40:55 
Re: Another Transparency Problem using png
grayaii <grayaii@[EMAI  2008-08-27 11:31:01 
Re: Another Transparency Problem using png
mi76 <mi333@[EMAIL PRO  2008-08-28 01:01:30 
Re: Another Transparency Problem using png
grayaii <grayaii@[EMAI  2008-08-27 18:03:29 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Fri Nov 21 7:25:58 CST 2008.