# OpenGL OpenGL Draw lines and render them in perspective

## 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 ) 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

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 on other sites
here goes the attachment

##### 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.

## Create an account

Register a new account

• ### Forum Statistics

• Total Topics
627701
• Total Posts
2978698
• ### Similar Content

• A friend of mine and I are making a 2D game engine as a learning experience and to hopefully build upon the experience in the long run.

-What I'm using:
C++;. Since im learning this language while in college and its one of the popular language to make games with why not.     Visual Studios; Im using a windows so yea.     SDL or GLFW; was thinking about SDL since i do some research on it where it is catching my interest but i hear SDL is a huge package compared to GLFW, so i may do GLFW to start with as learning since i may get overwhelmed with SDL.
-Questions
Knowing what we want in the engine what should our main focus be in terms of learning. File managements, with headers, functions ect. How can i properly manage files with out confusing myself and my friend when sharing code. Alternative to Visual studios: My friend has a mac and cant properly use Vis studios, is there another alternative to it?

• Both functions are available since 3.0, and I'm currently using glMapBuffer(), which works fine.
But, I was wondering if anyone has experienced advantage in using glMapBufferRange(), which allows to specify the range of the mapped buffer. Could this be only a safety measure or does it improve performance?
Note: I'm not asking about glBufferSubData()/glBufferData. Those two are irrelevant in this case.
• By xhcao
Before using void glBindImageTexture(    GLuint unit, GLuint texture, GLint level, GLboolean layered, GLint layer, GLenum access, GLenum format), does need to make sure that texture is completeness.
• By cebugdev
hi guys,
are there any books, link online or any other resources that discusses on how to build special effects such as magic, lightning, etc. in OpenGL? i mean, yeah most of them are using particles but im looking for resources specifically on how to manipulate the particles to look like an effect that can be use for games,. i did fire particle before, and I want to learn how to do the other 'magic' as well.
Like are there one book or link(cant find in google) that atleast featured how to make different particle effects in OpenGL (or DirectX)? If there is no one stop shop for it, maybe ill just look for some tips on how to make a particle engine that is flexible enough to enable me to design different effects/magic
let me know if you guys have recommendations.
• By dud3
How do we rotate the camera around x axis 360 degrees, without having the strange effect as in my video below?
Mine behaves exactly the same way spherical coordinates would, I'm using euler angles.
Tried googling, but couldn't find a proper answer, guessing I don't know what exactly to google for, googled 'rotate 360 around x axis', got no proper answers.

References:
Code: https://pastebin.com/Hcshj3FQ
The video shows the difference between blender and my rotation:

• 21
• 14
• 12
• 10
• 12