Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Object outside camera OpenGL

Tags:

c++

opengl

I'm using a Perspective View with gluPerspective and gluLookAt and I have the x,y world coordinates of an object. How can I determine if the object is outside the viewable area? Note that the camera is always moving around.

like image 851
Luís Jesus Avatar asked Sep 06 '26 11:09

Luís Jesus


1 Answers

First thing first: OpenGL doesn't have a camera. It just transforms vertices around. And gluLookAt just applies a transformation on the objects that's inverse to a movement of a thought camera.

The solution had already been given in the first comment by Robert Massaioli: In OpenGL a perspective transformation is described in terms of a frustum (gluPerpective just calculates frustum parameters and passes these to glFrustum). So by determining frustum culling of your objects, i.e. if they are culled, you determine if they're still visible.

like image 52
datenwolf Avatar answered Sep 08 '26 03:09

datenwolf



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!