-1

I am trying to draw a simple cube in opengl using the mouse. Here's the basic step I followed:

1. Get mouse click coordinates. One,when the mouse is first clicked (say x1,y1) and the other, when the mouse is released i.e after the drag (say x2,y2).
2. Convert the 2d Coordinates to 3d using glUnproject.
3. Now that I have two points in 3d, I can easily render a Cube.

Everything went as planned, except I this was found while are drew the cube:
Link to the image: Here
The cube was half drawn,I dont know what's the problem here.

genpfault
  • 51,148
  • 11
  • 85
  • 139

1 Answers1

1

That looks like the whole scene is clipped at the backplane. Try moving the backplane further away from your camera. If you don't know what a backplane is take a look at this awesome article: http://www.lighthouse3d.com/tutorials/view-frustum-culling/

Marius
  • 2,234
  • 16
  • 18
  • glUnproject knows about the model,prespective and view matrix. And shouldn't the coordinates generated from unProjecting the 2d Values be inside the viewing range? Even if I try moving the backplane, the values of glUnproject will change as well which does no help. – user2922849 Oct 28 '13 at 16:32