Results 1 to 3 of 3

Thread: Texture and blending question

  1. #1
    Junior Member Newbie
    Join Date
    Oct 2003
    Location
    Kent, WA, USA
    Posts
    21

    Texture and blending question

    I am attempting to create 2D sprites using textures on polygons in orthographic projection mode. Obviously this would require blending to make most of the texture and polygon invisible, leaving just the sprite to be drawn over whatever background.

    So, I used glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA) and decal texturing mode. My texture wass a 32-bit TGA with an alpha channel painted on it randomly, just for testing purposes. When I tried it all out, the transparent parts of my texture had the color of the polygon they're drawn on showing through, rather than what's behind the polygon. I tried calling glColor4f(0.0,0.0,0.0,0.0) before drawing the textured polygon, but that just made the whole polygon invisible, texture and all. What's the problem, and how can I get what I want?

  2. #2
    Senior Member OpenGL Pro
    Join Date
    Feb 2002
    Location
    Bonn, Germany
    Posts
    1,633

    Re: Texture and blending question

    Try
    Code :
    glTexEnvi(GL_TEXTURE_ENV,GL_TEXTURE_ENV_MODE,GL_REPLACE);
    glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
    glEnable(GL_BLEND);
    This will eliminate vertex colors. If you want to be able to still colorize textured objects, use
    Code :
    glTexEnvi(GL_TEXTURE_ENV,GL_TEXTURE_ENV_MODE,[B]GL_MODULATE[/B]);
    glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
    glEnable(GL_BLEND);
    But then you'll have to watch the alpha channel when specifying colors. Ie instead of
    glColor4ub(255,0,0,0);
    use
    glColor4ub(255,0,0,255);

    [This message has been edited by zeckensack (edited 10-27-2003).]

  3. #3
    Junior Member Newbie
    Join Date
    Oct 2003
    Location
    Kent, WA, USA
    Posts
    21

    Re: Texture and blending question

    Thank you, sir. May you live long and have many cubs.

Similar Threads

  1. some question about blending
    By Lee_Jennifer_82 in forum OpenGL: Basic Coding
    Replies: 3
    Last Post: 11-06-2015, 10:30 PM
  2. Yet Another Blending Question.
    By Spock in forum OpenGL: Basic Coding
    Replies: 13
    Last Post: 12-10-2008, 09:44 AM
  3. Question about texture blending
    By Alessandro_dup1 in forum OpenGL: GLSL
    Replies: 10
    Last Post: 10-25-2005, 10:08 AM
  4. blending question
    By XFire in forum OpenGL: Basic Coding
    Replies: 12
    Last Post: 09-19-2002, 03:07 PM
  5. Blending Question?
    By ironduke in forum OpenGL: Advanced Coding
    Replies: 2
    Last Post: 08-31-2000, 08:17 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Proudly hosted by Digital Ocean