Jump to content
  • Advertisement
Sign in to follow this  

OpenGL OpenGL Draw lines and render them in perspective

This topic is 2706 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

Hi all, this is my first post, and i'm learning OpenGL, and to do so, i wanted to start a project...

Basically, i'm developing an android app that eventually (i hope :P) will be somehting like this[0] but using data from OpenStreetMap.

I'm currently stuck with the street rendering.

As i have vertex coordinates (latitude and longitude of the nodes that form the street) i started using them to render the streets using GL_LINE_STRIP.
Also, using glLineWidth so they look like streets instead of pathways :P

When i got familiar with that, i started to play with the gluLookAt function... and here is where my problems started. Lines do not play nice with perspective.

As i found reading other forums and every result google gave me, i have no option but to use GL_QUADS to render rectangles that look like lines.

This sounded logical, until i started to think in all different shapes that a street can have. That's why i'm here, seeking for advice.

How can i think this ? how can i get the needed vertex to draw the quad, based on the information that i do have ? also, is there any other way of doing what i want to do ? or rendering the quads is the only way ?

I'm attaching an image to explain a little better. The blue dots are the data i have (coords for the x and y position of each vertex), the red dots are the ones i need to figure out where to place them so i can render the quad (being the grey parts in the image)

Hope someone can give me some pointers because i'm a bit lost here :(

Thank you very much in advance.

Kind regards

[0] - http://media.shinyplastic.com/prodimg/garmin-885t.jpg

Share this post

Link to post
Share on other sites
Given the input data you have, you can compute the mesh data procedurally. (If the minimum interior angle allowed is ~90 degrees, and if the width is relatively small relative to the segment lengths, the process is actually fairly straightforward.)

I don't know how this fits in with the Android side of things, but in theory at least, the geometry you're looking for can easily be generated with a little vector math.

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!