Is there a way to priorotise meshes that intersect to pick which one is shown?

I have a window that I want to put in a wall, although when I do, the wall shows through it, like so:

[28910-screen+shot+2014-07-09+at+16.45.52.png|28910]

The window being the selected mesh in the above picture. The pink section is the wall.

I need the wall to stop displaying inside the bounds of the window, like so:

[28911-screen+shot+2014-07-09+at+16.52.53.png|28911]

The problem with the approach I took above is that I had to do that by hand, in blender, and the window now has to be in the specific spot in which I cut a hole for it in the wall.

My game relies on the player placing the window, So I was wondering if there was a way to achieve the above effect with a flat plane instead of one with a hole specifically cut out for it.

I feel like this is either something very obvious that I am oblivious to, or something that is just not possible, but I don’t even know how to describe what I’m trying to do so any help would be greatly appreciated, I hope people can understand what I’m getting at.

You might be able to use a depth mask