Stroke and fill in 3D primative

Hey,

So I’m coming over from processing and I’m trying to use 3D in openframeworks. All I want to do is have a box with a particular fill and a stroke with another fill. But apparently OF doesn’t support strokes so most people suggest you use the following code:

ofSetColor(100);
    ofFill();
    ofDrawBox(100);
    
    ofNoFill();
    ofSetLineWidth(10);
    ofSetColor(0);
    ofDrawBox(100);

The only problem with this code is it overlays a wireframe on top of the box instead of making the strokes of the box a particular color.

Does anyone know how to make it look like this instead (this one is made in processing)

Many thanks!

Hi @xX_n3c40_Xx,

I think you are missing ofEnableDepthTest, which will “Turns on depth testing so rendering happens according to z-depth rather than draw order.” :

ofBackground(255,255);
   
   ofEnableDepthTest();
   ofSetColor(100);
   ofFill();
   ofDrawBox(100);
   
   ofNoFill();
   ofSetLineWidth(10);
   ofSetColor(0);
   ofDrawBox(100);
   ofDisableDepthTest();

Gives you :

Hope this helps,

Best,

P

1 Like

That worked perfectly, thank you!

Much appriciated,
xXnXx