PDA

View Full Version : Rendering Lines Speed Perspective Correction



Victor Hugo
05-22-2009, 02:46 AM
Hi All,

I need to render some lines "roads" with perspective correction.

I was doing this with glLineWidthx and glDrawElements, but with this I get now perspective correction on the line, same line width at start cap and at end cap.

So I though I could use triangle strips or triangles to render the road. Let's say I define a rectangle in the world, this way I get my perspective correction done by OpenGLES.

I 'm doing something like this:

vertice[0][0] = x1 - half_line_world_width; vertice[0][1] = y1;
vertice[1][0] = x1 + half_line_world_width; vertice[1][1] = y1;
vertice[2][0] = x2 + half_line_world_width; vertice[2][1] = y2;
vertice[3][0] = x2 - half_line_world_width; vertice[3][1] = y2;

using vertices indices ( 1,2,0,3 ) then,

I call glDrawElements.

It's works fine for 80% of the roads, but some of them doesn't have the correct width.

Could someone help me doing this or another approach ?

I also want to do this with texture mapping using a pre-computed antialiased texture mapped on the triangle strip to reach antialiased rendering.

Thanks in advance,

Victor