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

x, y, z point in view?

This topic is 6034 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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