Note that there are some explanatory texts on larger screens.

plurals
  1. POOpenGL ignore object when blending?
    primarykey
    data
    text
    <p>I'm rendering a quad with an outline. I do this by rendering a quad of the required size in black, then rendering the "inner" quad smaller than the first. I also want this outlined quad to be transparent.</p> <p>My current attempt renders as so:</p> <p><a href="http://i39.tinypic.com/2eq993s.png" rel="nofollow noreferrer">http://i39.tinypic.com/2eq993s.png</a></p> <p>However the problem I have is that because I'm essentially rendering two quads on top of each other, the black "main" quad blends through to the smaller "inner" quad. I don't want this to happen as I want the blending to only blend the background and the "inner" quad colours.</p> <p>Other than rendering separate quads/triangles for the outline is there a way (ideally not using shaders as I'm using fixed pipeline) to make the blending ignore/not render the "main" quad when blending the "inner" quad?</p> <p>Relevant code:</p> <p>Blend mode:</p> <pre><code>glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA); glEnable( GL_BLEND ); </code></pre> <p>Rendering the box:</p> <pre><code>struct vertex { GLfloat x,y; }; void draw_box() { glPushMatrix(); glTranslatef( -3.0f, 1.12f, 1.0f ); // Draw a huge black quad const vertex vertices2[] = { { -1.0f, -1.0f }, { 0.0f, 0.0f }, { -1.0f, 0.0f }, { -1.0f, -1.0f }, { 0.0f, 0.0f }, { 0.0f, -1.0f }, }; glVertexPointer(2, GL_FLOAT, 0, vertices2); glColor4f(0.0f, 0.0f, 0.0f, 0.5f); glDrawArrays(GL_TRIANGLES, 0, 6); // Draw a smaller grey quad const GLfloat space = 0.04f; const vertex vertices3[] = { { -1.0f+space, -1.0f+space }, { 0.0f-space, 0.0f-space }, { -1.0f+space, 0.0f-space }, { -1.0f+space, -1.0f+space }, { 0.0f-space, 0.0f-space }, { 0.0f-space, -1.0f+space }, }; glVertexPointer(2, GL_FLOAT, 0, vertices3); glColor4f(0.5f, 0.5f, 0.5f, 0.5f); glDrawArrays(GL_TRIANGLES, 0, 6); glPopMatrix(); } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload