Why Libgdx Gdx.gl10.glLineWidth (width); does not respond to changes in projection properties

I have a typical Libgdx class with the render () function.

In the render () function, I have a ShapeRenderer batch:

Gdx.gl10.glLineWidth(width); renderer.begin(ShapeType.Line); renderer.setColor(25,0, 0, alpha); renderer.line(point_x1, point_y1, point_x2, point_y2); renderer.end(); 

this function also has:

  camera.update(); renderer.setProjectionMatrix(camera.combined); 

and when you change the projection properties, the line points are translated correctly, but the line width remains the same !

Is it possible to change the line width due to the width and height of the projection?

considers

+2
source share
2 answers

The line width is set in pixels, which are simply not affected by any projection transforms. Thus, there is no easy way to make the line width dependent on the current transformation of the projection, and you will not be able to get around your lines using real two-dimensional geometry (i.e., Rotated rectangles or something like that).

+6
source

You did not indicate what type of camera you are using, but if it is OrthographicCamera , you can use zoom to change the line width depending on the zoom factor of your camera:

For example, when you have a line of width 1 pixel, if you did not zoom in / out, you can use this:

 OrthographicCamera camera = ... int lineWidth = 1; // pixels Gdx.gl10.glLineWidth(lineWidth / camera.zoom); 
0
source

All Articles