Strange ortho clipping with depth test

Hey all!

So I’m trying to work with some 3d boxes in ortho and I’m stumped at the first hurdle.

I’m using an ortho camera and for some odd reason if I also use ofEnableDepthTest() in my code any objects I have created start clipping in the background like I’ve shown bellow.

58 am

bool camBool;
ofCamera cam;

void ofApp::setup(){
    camBool = false;
}

void ofApp::draw(){
    if (camBool) {
        cam.begin();
        cam.enableOrtho();
    }
    
    ofEnableDepthTest();
    
    if (!camBool) { ofTranslate(ofGetWidth()/2,ofGetHeight()/2); }
        
    ofRotateXDeg(ofMap(sin(ofGetElapsedTimef()),-1,1,-90,90));
    ofRotateZDeg(ofMap(sin(ofGetElapsedTimef() + 20),-1,1,-90,90));
    
    ofFill();
    ofSetColor(255);
    ofDrawBox(100);
    
    ofNoFill();
    ofSetLineWidth(3);
    ofSetColor(0);
    ofDrawBox(100);
    
    ofDisableDepthTest();
    
    if (camBool) { cam.end(); }
}

void ofApp::keyPressed(int key){
    camBool = !camBool;
}

Does anyone have a clue how to fix this?
Many thanks!

Hi @xX_n3c40_Xx,

I would think that maybe your clipping planes are the problem:
The camera clips what’s too far out, therefore doesn’t render it, but cuts the shape on the edges.

Try using the DrawFrustum method in order to visualise what the camera sees - also you need to create a different camera for that to work), or just check the getFarClip to check if it doesn’t come from that.

Hope it helps,

Best,

P