"grayaii" <grayaii@[EMAIL PROTECTED]
> wrote in message
news:ab7f3ae6-e147-4e76-b675-8e400bd1e588@[EMAIL PROTECTED]
> 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!
Right idea, wrong texture environment function. I think you want MODULATE
GL_TEXTURE_ENV_MODE .
Enabling the alpha tests will determine how "sharp" (and where) the
transition from opaque to transparent is, as there will be intermediate
interpolated transparances between the two (when zoomed).
-jbw
jbw


|