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

Thread: how to draw a dashed line in open gl es 2?

Hybrid View

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

    how to draw a dashed line in open gl es 2?

    Hi,

    I'm trying to do that but it doesn't work. This is the fragment code i tried:

    "precision mediump float;" \
    "uniform vec4 a_Color; bool on; " \
    "void main() {gl_FragColor = on == true ? a_Color : vec4(0,0,0,0); on = !on;}"

    However, seems that "bool" is not "global', and thus, nothing is drawn at all. I also tried to use position.x % 2 == 0, but my glsl language is 1.0 and thus does not support it.

    thanks

    guich

  2. #2
    Super Moderator OpenGL Guru
    Join Date
    Feb 2000
    Location
    Montreal, Canada
    Posts
    4,264
    There are no global variables.

    Draw a line and apply a texture to it with an alpha channel. Turn on blending.
    ------------------------------
    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);

  3. #3
    Junior Member Newbie
    Join Date
    Sep 2012
    Posts
    25
    Hi, thanks. Is this the same approach used to draw an antialiased line?

  4. #4
    Junior Member Regular Contributor
    Join Date
    Oct 2007
    Location
    Phoenix, AZ
    Posts
    109
    use stippling perhaps?

  5. #5
    Junior Member Newbie
    Join Date
    Sep 2012
    Posts
    25
    There's no stippling in Open GL ES 2... :-(

Posting Permissions

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