Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Algorithm to only draw what the camera sees?

I'm making a 3D FPS with OpenGL and here is the basics of how it works. The game is a 3D array of cubes. I know the location of the player's current cube, aswell as the camera x,y,z and I know the x, y, z rotation of the camera too. Right now I just make a square around the player and render this and then add distant fog. The problem though, is that I'm still rendering everything that the player is in back of. How could I selectively only render what the player sees, not render everything within an X radius as Iam doing now.

Thanks

like image 842
jmasterx Avatar asked Oct 15 '22 00:10

jmasterx


2 Answers

You are talking about frustum culling, if i get you right. I suggest that you take a look at this tutorial. They provide nice demos and explain everything in detail.

like image 184
jwueller Avatar answered Oct 19 '22 12:10

jwueller


This sounds like you need to look into culling concepts.

like image 31
Robb Avatar answered Oct 19 '22 12:10

Robb