Wednesday, July 6, 2016

OpenGL ES - Dashed Lines

Leave a Comment

im Using OpenGlEs10 for My Android Game Development, I Want to Draw Dashed-lines Now Im Using This Code to Draw My Line:

        gl.glColor4f(1.0f, 0.0f, 0.0f, 1.0f);         // gl.glBlendFunc(GL10.GL_SRC_ALPHA, GL10.GL_ONE_MINUS_SRC_ALPHA);         gl.glLineWidth(4.0f);         gl.glVertexPointer(2, GL10.GL_FLOAT, 0, mBufDestVertices);         gl.glDrawArrays(GL10.GL_LINE_LOOP, 0, mDesPoly.getNumPoints()); 

How Should I Change It? Does I have to Texture The line? And if so, How?

2 Answers

Answers 1

You don't have to use a texture, you can simply use the function glLineStipple(GLint factor, GLushort pattern) and then call glEnable(GL_LINE_STIPPLE).

For more information about glLineStipple and its arguments you can have a look at this.

Answers 2

I recommend to use a 1D texture (performance: use alpha testing instead of blending)

don't forget to: set texture filter to GL_NEAREST texture wrapping to GL_REPEAT

If You Enjoyed This, Take 5 Seconds To Share It

0 comments:

Post a Comment