How do I find if something is within my field of view

I would like to be able to get this as a function with an objects 3D coordinates and size so I would know if I have to bother rendering it.

This is typically called “frustum culling”, this site has an explanation and I’m sure there are many others.

    // bsphere position (in view space)
    vec3 center =;
    float radius = boundingsphere.w;
    vec3 position = (modelview * vec4(center, 1)).xyz;

    float A = 1.0f / tan(FieldOfView * AspectRatio / 2.0f);
    float B = 1.0f / tan(FieldOfView / 2.0f);

    // camera frustum face normals
    vec3 normal_L = normalize(vec3(-A, 0, 1));
    vec3 normal_R = normalize(vec3(+A, 0, 1));
    vec3 normal_T = normalize(vec3(0, +B, 1));
    vec3 normal_B = normalize(vec3(0, -B, 1));

    // distances of bounding sphere to camera frustum faces
    float distance_L = dot(position, normal_L);
    float distance_R = dot(position, normal_R);
    float distance_T = dot(position, normal_T);
    float distance_B = dot(position, normal_B);

    // cull invisible objects
    bool visible = false;

    if (distance_L > radius)
    if (distance_R > radius)
    if (distance_T > radius)
    if (distance_B > radius)
	visible = true;

i use a bounding sphere for every mesh, transform it into view/eye space, and check if the frustum planes exclude the bounding sphere entirely … if yes, i dont have to draw the mesh