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: Polygon Masking

Hybrid View

  1. #1
    Junior Member Newbie
    Join Date
    Sep 2012
    Posts
    4

    Polygon Masking

    Hello,

    So, I've been trying to do this for the past few days:
    I need to render a GL_POLYGON with it's content masked.
    glPolygonStipple() is exactly the function I need but unfortunately it's not supported anymore.
    Please note that I want to be able to change the color of the solid areas, so that I can load the pattern from a file but change it's color dynamically.
    I'm almost sure that the solution has to do with textures but I don't know exactly what to do.

    Thanks in advance,
    Jason

    I hope that I describe my problem correctly.

  2. #2
    Super Moderator OpenGL Guru
    Join Date
    Feb 2000
    Location
    Montreal, Canada
    Posts
    4,264
    You can stick with GL 1.1 to 2.1 if you really want that function.
    If you want to use modern GL, then you can use a texture that an alpha value or some specific value in the RGB layer. In your fragment shader, you just need to kill the fragment with the discard command.

    Code :
    if(texture.a==0.0)
       discard;
     
    etc etc.
    ------------------------------
    Sig: http://glhlib.sourceforge.net
    an open source GLU replacement library. Much more modern than GLU.
    float matrix[16], inverse_matrix[16];
    glhLoadIdentityf2(matrix);
    glhTranslatef2(matrix, 0.0, 0.0, 5.0);
    glhRotateAboutXf2(matrix, angleInRadians);
    glhScalef2(matrix, 1.0, 1.0, -1.0);
    glhQuickInvertMatrixf2(matrix, inverse_matrix);
    glUniformMatrix4fv(uniformLocation1, 1, FALSE, matrix);
    glUniformMatrix4fv(uniformLocation2, 1, FALSE, inverse_matrix);

Tags for this Thread

Posting Permissions

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