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 2 of 2

Thread: Blending Two Colours

  1. #1
    Newbie Newbie
    Join Date
    Oct 2012
    Posts
    2

    Blending Two Colours

    Hi Everyone,

    First post here so please be gentle

    I have a routine which draws a checked board to the screen. I have implemented this from a photoshop mockup which has the following layers

    -------------
    Checker
    -------------
    Checker Base
    -------------
    Base Texture
    -------------

    I have the base texture rendering correctly. I then iterate through my checkers and draw one "checker base" quad and a "checker" quad.

    The "checker base" is the same size/position it just acts as an underlay to the "checker".

    The "checker base" has RGBA (1.0, 1.0, 1.0, 0.2) so white with 20% transparency.

    Whilst the "checker" is either (r, g, b, 0.2) or (r, g, b, 0.8) depending on whether it is odd or even.

    Current blending is: glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA)

    Basically I want to optimize the above into one draw for each checker as opposed to two.

    How do I go about calculating the colour of the two merged quads "checker" and "checker base" ?

  2. #2
    Advanced Member Frequent Contributor
    Join Date
    Apr 2010
    Posts
    752
    Not sure if this is what you are looking for, but the OpenGL blending calculations are described on the man page for glBlendFunc.

Posting Permissions

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