I created this but it appeared to be slow.
There is a loop used to draw the both sides of the terrain, the segments on the road, the road itself and the lanes.
` public static void DrawPolygon4( CanvasRenderer ctx, double xloc, double yloc, double x2loc, double y2loc, double x3loc, double y3loc, double x4loc, double y4loc, ColorValue colr ) {
double newX, newY, newX2, newY2, newX3, newY3, newX4, newY4;
newX = xloc / iGetViewportWidth;
newY = yloc / iGetViewportHeight;
newX2 = x2loc / iGetViewportWidth;
newY2 = y2loc / iGetViewportHeight;
newX3 = x3loc / iGetViewportWidth;
newY3 = y3loc / iGetViewportHeight;
newX4 = x4loc / iGetViewportWidth;
newY4 = y4loc / iGetViewportHeight;
var vertices = new CanvasRenderer.TriangleVertex[ 3 ]
{
new CanvasRenderer.TriangleVertex( new Vector2F( (float)newX, (float)newY), colr ),
new CanvasRenderer.TriangleVertex( new Vector2F( (float)newX2, (float)newY2), colr ),
new CanvasRenderer.TriangleVertex( new Vector2F( (float)newX3, (float)newY3), colr )
};
ctx.AddTriangles( vertices );
var vertices2 = new CanvasRenderer.TriangleVertex[ 3 ]
{
new CanvasRenderer.TriangleVertex( new Vector2F( (float)newX3, (float)newY3), colr ),
new CanvasRenderer.TriangleVertex( new Vector2F( (float)newX4, (float)newY4), colr ),
new CanvasRenderer.TriangleVertex( new Vector2F( (float)newX, (float)newY), colr )
};
ctx.AddTriangles( vertices2 );
}`
If i do not press on the acceleration, the frame rate will go to 60. This screen the car is not moving.
Once the acceleration is done, the frame rate will drop.
If i commented out the codes to draw the roads, i get high frame rate.
Is there a way to render these faster?
Note that i did not write the codes, i just ported them into NeoAxis.