Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 7 of 7

Thread: Opengl 1.1 and transparent textures

  1. #1
    Intern Contributor
    Join Date
    Nov 2010
    Posts
    81

    Opengl 1.1 and transparent textures

    Hi,

    does Microsoft's implementation of OpenGL 1.1 support transparent textures?
    In my application they don't seem to work, so I would like to know if it's a known limitation.
    Thanks

  2. #2
    Intern Newbie
    Join Date
    Jan 2010
    Location
    Romania
    Posts
    46

    Re: Opengl 1.1 and transparent textures

    "transparent textures"... try glBlendFunc() with the corresponding blending coeficients that you want and then glEnable(GL_BLEND) before rendering the transparent primitives you want.

    Also, take care about the depth testing (even though a texture is "transparent" it can still write to the depth buffer if you "let it", which might not be what you want, because it will "hide" everything behind it, be it transparent or not).


    sum-up (just one incomplete example, play with the params):

    glDisable(GL_DEPTH_TEST);
    glEnable(GL_BLEND);
    glBlendFunc(GL_ONE,GL_ONE);
    glBegin(...);
    glVertex...
    ... ...
    ... ...
    glEnd();

  3. #3
    Intern Contributor
    Join Date
    Nov 2010
    Posts
    81

    Re: Opengl 1.1 and transparent textures

    Hi,

    my code works with hardware acceleration, but it doesn't work without it.

    Here are the steps I do:

    1) I clear the scene with a alpha 0

    gl.ClearColor(0, 0, 0, 0);
    gl.Clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT);

    2) draw some geometry

    3) read it into a texture:

    gl.BindTexture(gl.TEXTURE_2D, myTexture);

    gl.TexImage2D(gl.TEXTURE_2D, 0, gl.RGBA8, texSize, texSize, 0, gl.RGBA, gl.UNSIGNED_BYTE, null);
    gl.TexParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.NEAREST);

    gl.TexParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.NEAREST);
    gl.CopyTexSubImage2D(gl.TEXTURE_2D, 0, 0, 0, 0, 0, texSize, texSize);

    4) clear again color and depth buffer

    5) draw my real scene

    6) draw the texture (created at step 3) over it:

    gl.Enable(gl.BLEND);
    gl.Disable(gl.DEPTH_TEST);
    gl.Enable(gl.TEXTURE_2D);
    gl.BindTexture(gl.TEXTURE_2D, myTexture);
    // draw a Quad with the textures coordinates


    The texture should be transparent in the empty areas (of step 2) but, if hdw acceleration if OFF, it is black and covers my scene.

    With hdw acceleation on, the texture is correctly transparent.

  4. #4
    Super Moderator OpenGL Lord
    Join Date
    Dec 2003
    Location
    Grenoble - France
    Posts
    5,655

    Re: Opengl 1.1 and transparent textures

    The code above can only provide transparent area if you have a destinaton alpha on the framebuffer.
    If you don't ask for it explicitely, it may or may not be present.
    See point here :
    http://www.opengl.org/resources/faq/...y.htm#blen0050

    Ie. with Microsoft software implementation of OpenGL 1.1, there is no destination alpha.

    Try using mesa3D instead.

  5. #5
    Intern Contributor
    Join Date
    Nov 2010
    Posts
    81

    Re: Opengl 1.1 and transparent textures

    Hi,

    but I'm not using DST_ALPHA anywhere...

  6. #6
    Super Moderator OpenGL Lord
    Join Date
    Dec 2003
    Location
    Grenoble - France
    Posts
    5,655

    Re: Opengl 1.1 and transparent textures

    Yes you do, indirectly :
    2) draw some geometry
    3) read it into a texture
    ... now DST_ALPHA from your first pass becomes SRC_ALPHA in the second pass.

  7. #7
    Intern Contributor
    Join Date
    Nov 2010
    Posts
    81

    Re: Opengl 1.1 and transparent textures

    Ok, thank you

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •