This topic is now archived and is closed to further replies.


x, y, z point in view?

Recommended Posts

Guest Anonymous Poster
Do a search for frustum culling.

Share this post

Link to post
Share on other sites
use gluProject on the point and check if x is >= 0 and < viewport[2] and y is >= 0 and y is < viewport[3]. the z part is just for depth testing. You don''t need it.

example code: (Am I nice or what?)

inline bool pointisonscreen(float x, float y, float z)
GLdouble modelMatrix[16];
GLdouble projMatrix[16];
GLdouble sx,sy,sz;
GLint viewport[4];

glGetDoublev(GL_MODELVIEW_MATRIX, modelMatrix);
glGetDoublev(GL_PROJECTION_MATRIX, projMatrix);
glGetIntegerv(GL_VIEWPORT, viewport);


if(sx >= 0 && sx < viewport[2] && sy >= 0 && sy < viewport[3])
return true;
return false;

I just threw that together. I can''t say for sure that it will work.

Share this post

Link to post
Share on other sites