0

i´m new to openGL and want to draw lines on an GLSurfaceView.

I switched from canvas to openGL cause of the performance.

I know that OpenGL is more likely for 3D drawings, so pixel are not used because of this.

I want to draw 2D graphics like lines but need the dimensions in pixel, only x and y values without 3rd dimension.

Nicol Bolas
  • 449,505
  • 63
  • 781
  • 982
atpanos
  • 473
  • 6
  • 9

1 Answers1

0

Set properly your projection and view matrices. For first, use orthographic projection, second leave identity.

P = Diagonal(2 / W, 2 / H, 2 / (10 + 10), 1)
// Assume Znear=-10, ZFar=10, W and H are width and Height of the screen.

So coordinates you see will bew in cube -W/2 to W/2, -H/2 to H/2 and -10 to 10. You may even translate in view matrix to move origin from -W/2, -H/2 to 0, 0 translating view matrix: V = Translate(W/2, H/2, 0).

demi
  • 5,384
  • 6
  • 37
  • 57