PDA

View Full Version : how to draw a dashed line in open gl es 2?



guihazan
10-18-2012, 02:29 PM
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

V-man
10-19-2012, 09:06 PM
There are no global variables.

Draw a line and apply a texture to it with an alpha channel. Turn on blending.

guihazan
10-22-2012, 08:37 AM
Hi, thanks. Is this the same approach used to draw an antialiased line?

CRasterImage
10-22-2012, 01:22 PM
use stippling perhaps?

guihazan
10-23-2012, 07:45 AM
There's no stippling in Open GL ES 2... :-(