Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Increasing the width of line drawn using Shape Renderer in LibGDX

Tags:

libgdx

I am drawing a line using Shape Renderer in LibGDX and i am using Orthographic Camera in my code, so to increase the width i used

camera = new OrthographicCamera();
int lineWidth = 8; // pixels
Gdx.gl10.glLineWidth(lineWidth / camera.zoom);

Now, I get a wider line. But the problem arises when the screen power goes off and then turns on, the line becomes the normal one again. How to keep the width constant?

like image 918
Chandrasekhar Malladi Avatar asked Sep 06 '13 05:09

Chandrasekhar Malladi


1 Answers

ShapeRenderer has the method rectLine that is intended to be used to draw thick lines. It draws a rotated filled rectangle with the smaller opposite sides centered on the points passed to it (as coordinates or as Vector2 objects). The method has the parameter width to set the line width.

You can see the documentation here

Example:

shapeRenderer.rectLine(new Vector2(x1,y1),new Vector2(x2,y2),lineWidth);
like image 91
Airton da Fonseca Granero Avatar answered Nov 15 '22 10:11

Airton da Fonseca Granero