Problem with Selection Buffer and Ortho mode


I’ve got a problem writing a hits checking in Ortho mode. In perspective mode all is OK but when I try to get hits (by selection buffer) from ortho mode I’m getting wrong postions. Could someone help with some code?
In my program it depends on camera position.
If camera is outside the room I’m checking hits from perspective mode but if it is inside I want to check this from ortho mode.

thanks in advance