Lazarus

Programming => Graphics and Multimedia => OpenGL => Topic started by: deadbeef on February 20, 2022, 04:55:30 pm

Title: How to calculate which cube sides to cull?
Post by: deadbeef on February 20, 2022, 04:55:30 pm
I have all my cube faces sorted by (+X -X +Y -Y +Z -Z) in a single ibo and render them using glMultiDrawElements which allows me to select which sides to draw but I can't seem to find a way to select which faces I need.
The values involved should be the cameras position and viewing angle in combination with the chunks center position but how to calculate this exactly?
This would only need to work from outside the chunk but having something that works inside as well would be nice too.
Title: Re: How to calculate which cube sides to cull?
Post by: ChrisR on February 28, 2022, 05:21:55 am
The triangle winding order defines the front versus back face. The default is counter clockwise.
  https://www.khronos.org/opengl/wiki/Face_Culling
Here are a couple of Lazarus demos (meshProj_gl.lpi and cube_gl.lpi are the OpenGL variant, the other projects use Metal).
  https://github.com/neurolabusc/Metal-Demos/tree/master/mesh
and
  https://github.com/neurolabusc/Metal-Demos/tree/master/cube
Title: Re: How to calculate which cube sides to cull?
Post by: Mathias on March 06, 2022, 05:29:54 pm
https://wiki.delphigl.com/index.php/Lazarus_-_OpenGL_3.3_Tutorial

TinyPortal © 2005-2018