2

I have typical Libgdx class with render() function.

In render() function i have 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(); 

in this function I have also:

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

and when the projection properities is changed line points are translated properly but line width is still the same!

Is there any way to change line width due to projection width and height ??

regards

mynameismarcin
  • 117
  • 1
  • 3
  • 10

2 Answers2

6

Line width is given in pixels, which is just not influenced by any projection transformations. So there is no easy way to make the line width dependent on the current projection transformation and you won't get around replacing your lines by real 2-dimensional geometry (i.e. rotated rectangles or something the like).

Christian Rau
  • 45,360
  • 10
  • 108
  • 185
  • thanks for nice answers. im means something You said. So maybe You know another way to draw line in open gl es with control this line width ? – mynameismarcin Sep 10 '12 at 11:14
0

You did not specify what camera type you use, but if it is a OrthographicCamera you can use zoom to modify the line width depending on the zoom factor of your camera:

For example when you have a 1 pixel width line when not zoomed in/out, you can use this:

OrthographicCamera camera = ...
int lineWidth = 1; // pixels

Gdx.gl10.glLineWidth(lineWidth / camera.zoom);
Veger
  • 37,240
  • 11
  • 105
  • 116