Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4023714
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T10:37:57+00:00 2026-05-20T10:37:57+00:00

I am trying to implement frustum culling in my OpenGL 2d game. The only

  • 0

I am trying to implement frustum culling in my OpenGL 2d game. The only kind of geometric objects in my game at this point are rectangles, so I thought this would be pretty easy, but I am getting unexpected results. I have setup a symmetrical perspective projection with a field-of-view angle of 45 degrees, and near and far planes at 0.01 and 50 respectively. The eye vector is always parallel to the z-axis, the camera can only move along the x and y axes.

My idea was to get the rectangular area of the world space that is currently visible to the camera at the z-coordinate of the rectangle I am trying to cull. Because the camera is looking at the center of the frustum, I calculate the distance to the edges of this visible rectangular area as follows:

GLfloat maxDistance = givenRectangle.z * tanf(0.5 * (fovAngle * M_PI/180) );

Then I add and substract this distance to and from the x and y coordinates of the camera to get the maximum and minimum visible x and y, and then test the given rectangle to see if it’s in between these values.

My question is whether I am on the right track here, and why the above formula returns an absurdly small value (something*10^-37) when I have an object at z=5, which should clearly be visible with the Camera at (0,0,0)?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T10:37:57+00:00Added an answer on May 20, 2026 at 10:37 am

    Taking the problem from the top, I’ve checked your formula – see sketch to confirm I’ve understood you correctly.

    enter image description here

    Given that we know A and Z and want to solve for X, I first wrote:

    tan(A) = X/Z

    rearranging, I get:

    X = Z tan(A)

    Since Z = 5 and A = 22.5 degrees…

    X = 5* tan(22.5 degrees)

    X = 2.07106781

    So, it does seem as though you’ve got the maths right but your code wrong – maybe your tan function is expecting degrees rather than radians, or fovAngle hasn’t been set? I think you need to debug and hand-check each value.


    Going back to the wider problem of figuring out what does and does not lie inside your frustum, you might find that you can use a different test to answer the same question more elegantly. Many graphics coders use a “side-of-plane” test. Consider that your viewing frustum is a volume of space bounded by a set of 6 planes (4 for the sides of your viewport, a near clipping plane and a far clipping plane).

    Given a point on a plane and a normal for the plane, you can quite easily calculate the equation of a plane, which in turn makes it trivial to test whether a given point is “inside” (in the direction of the normal) a given plane. Iterate through all 6 planes and you’ll quickly rule a given point in or out of your viewing volume.

    The really neat thing about this test is how easily you can re-use it: any simple convex polygon you happen to want to do tests on (e.g. a rectangle) can be described as a set of planes, allowing you to re-use your “insider or outside” test. Very general.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Trying to implement an autocomplete based on this It looks like it's very straight
I'm trying implement Data Annotation to my Linq to SQL objects. The .dbml file
Trying to implement what I thought was a simple concept. I have a user
Trying to implement this gallery on my website. http://coffeescripter.com/code/ad-gallery/ It is noted in the
trying to implement a multiplayer. Using the sample from Game Center - Sending and
Trying to implement a shell, mainly piping. I've written this test case which I
When trying to implement a simple OpenGL application, I was surprised that while it
Im trying to implement a UnitofWork pattern using this Scott Allen tutorial My current
Im trying to implement this code: http://wcf.codeplex.com/wikipage?title=Getting%20started:%20Building%20a%20simple%20web%20api and want to add it to my
Trying to implement a timer for my game that I'm making. I have a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.