Jump to content
  • Advertisement
Sign in to follow this  
alireza.pir

OpenGL OpenGL ES - Dashed Lines

This topic is 746 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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?

Share this post


Link to post
Share on other sites
Advertisement

http://perso.esiee.fr/~perrotol/TheRedBook-1.0/chapter02.html

 

search for: 

Stippled Lines

 

 

and sample code:

glPushAttrib(GL_ENABLE_BIT); 
# glPushAttrib is done to return everything to normal after drawing

glLineStipple(1, 0xAAAA);  # [1]
glEnable(GL_LINE_STIPPLE);
glBegin(GL_LINES);
glVertex3f(-.5,.5,-.5);
glVertex3f(.5,.5,-.5);
glEnd();

glPopAttrib();

thus i dont know what it draws

Share this post


Link to post
Share on other sites
search for: 
Stippled Lines

 

There's no stippled lines in OpenGL ES.

 

 

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

 

Yes, you should texture it.

Make small 1D texture (4-8 pixels wide), large enough to hold desired dash pattern.

Add texture coordinates to your line vertices. Line's first vertex S coord can be at texture's 0, and second vertex S coord should be set depending on line's length, and how dense you want dash pattern. Enable texture wrapping, so pattern will be repeated along line.

Draw with blending or alpha test, depending on your needs.

Share this post


Link to post
Share on other sites

 

search for: 
Stippled Lines

 

There's no stippled lines in OpenGL ES.

 

 

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

 

Yes, you should texture it.

Make small 1D texture (4-8 pixels wide), large enough to hold desired dash pattern.

Add texture coordinates to your line vertices. Line's first vertex S coord can be at texture's 0, and second vertex S coord should be set depending on line's length, and how dense you want dash pattern. Enable texture wrapping, so pattern will be repeated along line.

Draw with blending or alpha test, depending on your needs.

 

 

Thanks, Is There Any Tutorial Or Link for How to Do this? or Could You give me a simple code?

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!