Game Development Stack Exchange is a question and answer site for professional and independent game developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

What I want to implement next in my game is frustum culling. The issue that I'm having is creating a draw method that I can check which cubes in my vertex buffer I draw or not. What I want to do is loop through my list "cubes" and check for each bounding box that the cube has. I've done this before when I had each cube have a separate vertex buffer, but now when I try it with a chunk of cubes, it crashes my computer. I know why this happened so I won't bother explaining it.

      cubes.Add(new Cube.Grass(device, new Vector3(x, map[x, z] - y, z), grass));
      cubeBoundingBox(some Vector3s here);

So with these two lines I add the cube to the list and create a bounding box based on the position and size of the box. I'm sure there's a better way to do this.

    public void DrawMap(GameTime gameTime)
        ContainmentType CurrentContainmentType = ContainmentType.Disjoint;

        foreach (Cube block in cube.cubes)
            CurrentContainmentType = cam.frustum.Contains(cube.cubeBoundingBox);

            //some more stuff here

            if (CurrentContainmentType != ContainmentType.Disjoint)

This is my old method that almost worked. But now that I have all cubes stored in a single vertex buffer, this won't work. I'm kinda lost here. How can I loop through all the cubes in my list "cubes" in order to check if they need to be culled or not? Or would it make more sense to make a list of bounding boxes and loop through that list?

share|improve this question

Just iterate through the vertices with offset to the next first vertex of the next cube. Like this:

point[] linevertices = new point[6]; // line is made of 2 points

// Iterate through all lines
for(int i=0; i<6; i=i+2){
    // code
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.