Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>The best way to do this is probably to split up the border into four trapezoidal quads, but since you explicitly mentioned you didn't want to go down that path, there are a couple of other options you could pursue.</p> <p>The next best method is probably to use the depth buffer: <a href="http://www.opengl.org/sdk/docs/man/xhtml/glEnable.xml" rel="nofollow"><code>glEnable(GL_DEPTH_TEST)</code></a>. Draw the inside quad first (with blending enabled). Then draw the outer quad, but using coordinates such that it's depth is greater than the first quad (it is "farther away"). If depth testing is enabled when the border quad is drawn, it will fail for the quad you already drew, since those pixels have a smaller depth value. Note that using this method, if you are writing to the depth buffer when rendering the things behind these quads, you may run into some issues with parts of the background being considered closer than the new quads. You can solve this for the inner quad by configuring the depth test to always succeed, even when the test fails: <a href="http://www.opengl.org/sdk/docs/man/xhtml/glDepthFunc.xml" rel="nofollow"><code>glDepthFunc(GL_ALWAYS)</code></a>. This won't help for the outer quad, however. In that case the next method might be helpful:</p> <p>You can use the stencil buffer in a similar manner to the depth buffer. When rendering the inside quad, you set the stencil value (or one bit of it at least) to a specific value:</p> <pre><code>glEnable(GL_STENCIL_TEST); glStencilFunc(GL_ALWAYS, 1, GLuint(-1); glStencilOp(GL_KEEP, GL_KEEP, GL_REPLACE); </code></pre> <p>Then when you draw the outer quad, configure the stencil test to succeed only if a fragment does not have that value:</p> <pre><code>glStencilFunc(GL_NOT_EQUAL, 1, 1); </code></pre> <p>Essentially, this is the same thing the version above was doing with the depth buffer, but uses the stencil buffer instead. You may want to take a look at the documentation for <a href="https://www.opengl.org/sdk/docs/man/xhtml/glStencilFunc.xml" rel="nofollow">glStencilFunc</a> and <a href="http://www.opengl.org/sdk/docs/man4/xhtml/glStencilOp.xml" rel="nofollow">glStencilOp</a>.</p> <p>There may be other ways to achieve this behavior, but all the other solutions I can think of involve using custom shaders, which you indicated is not acceptable. Personally, I'd just split up the border into 4 quads. Sure, it's 3 more quads than the other methods, but it doesn't require any extra OpenGL features or state changes.</p>
    singulars
    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. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      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