0

I have an application that shows a 3D model via WebGL. It's possible to rotate, translate and zoom. Now I would like to render a 2D mouse cursor. Of course I can't just add a polygon to this 3D space, because the polygon would behave as a 3D object when the user uses transformation operations.

I thought about drawing on the near clipping plane, because I think the polygon wouldn't be affected by transformations. But I can't figure out how I can get the near plane coordinates of the triangle for drawing.

I would like to calculate the triangle coordinates on the near clipping plane and set the new vertices of the triangle inside of the buffer.

Does anyone know how I can achieve this? Is there another way to draw a 2D polygon in a 3D room?

Peter O.
  • 32,158
  • 14
  • 82
  • 96
Sincostan
  • 361
  • 2
  • 11
  • Render the cursor without applying view projection transforms or just use CSS/JavaScript and style the natural cursor / replace it by a `div`. – LJᛃ Mar 18 '15 at 16:49
  • what LJ_1102 said. WebGL does 2D just fine. See http://webglfundamentals.org There's no reason to use 3D shaders for 2D problems. Just make 2D shaders when you need to do 2D or use CSS/JavaScript or in fact you can also [just set the pointer with CSS](https://developer.mozilla.org/en-US/docs/Web/CSS/cursor). – gman Mar 19 '15 at 10:28
  • 1
    I can´t really use css in this context, because of multiple modes e.g. virtual reality mode (via oculus). However "Billboarding" solved my problem and I guess that´s what LJ_1102 meant. I found a really good explanation [link](http://www.lighthouse3d.com/opengl/billboarding/index.php?billCheat) – Sincostan Mar 19 '15 at 15:31

0 Answers0