ofSetBoxResolution() has no effect

With other primitives setting the resolution works fine, but not with the box.

        ofSetBoxResolution(4, 8, 3);
        ofDrawBox(0, -H/5, 0, H*2/3, H/3, H/30);
        ofSetBoxResolution(2, 2, 2);
        ofDrawBox(0, H/5, 0, H*2/3, H/3, H/30);

Here’s the full program, which I thought could be used to generate images for the OF documentation:

.h

#pragma once

#include "ofMain.h"

class ofApp : public ofBaseApp {
    private:
        int imagesTotal {12};
        int imagesCurr {0};
        bool saved {true};
        void setDefaults();
        
    public:
        void setup();
        void update();
        void draw();

        void keyPressed(int) {}
        void keyReleased(int) {}
        void mouseMoved(int, int) {}
        void mouseDragged(int, int, int) {}
        void mousePressed(int, int, int);
        void mouseReleased(int, int, int) {}
        void mouseEntered(int, int) {}
        void mouseExited(int, int) {}
        void windowResized(int, int) {}
        void dragEvent(ofDragInfo) {}
        void gotMessage(ofMessage) {}
};

.cpp

#include "ofApp.h"

//--------------------------------------------------------------
void ofApp::setDefaults() {
    ofSetIcoSphereResolution(2);
    ofSetBoxResolution(2, 2, 2);
    ofSetConeResolution(9, 3, 2);
    ofSetCylinderResolution(8, 4, 2);
    ofSetPlaneResolution(6, 4);
    ofSetSphereResolution(20);
}

//--------------------------------------------------------------
void ofApp::setup() {
    // Note: expecting a square canvas like 600x600
    cout << "click to generate images" << endl;
    ofBackground(255);
}

//--------------------------------------------------------------
void ofApp::update() {
}

//--------------------------------------------------------------
void ofApp::draw() {
    setDefaults();
    string fileName;
    int W {ofGetWidth()};
    int H {ofGetHeight()};
    ofNoFill();
    ofSetColor(80);
    ofTranslate(W/2, H/2);
    ofRotateDeg(30, 1, 1, 0);
    switch(imagesCurr) {
        // ---- ICOSPHERE
        case 0:
            fileName = "ofDrawIcoSphere.png";
            ofDrawIcoSphere(H/3);
            break;

        case 1:
            fileName = "ofSetIcoSphereResolution.png";
            ofTranslate(-W/4, -H/4);
            ofSetIcoSphereResolution(0);
            ofDrawIcoSphere(H/6);
            ofTranslate(W/4, H/4);
            ofSetIcoSphereResolution(1);
            ofDrawIcoSphere(H/6);
            ofTranslate(W/4, H/4);
            ofSetIcoSphereResolution(2);
            ofDrawIcoSphere(H/6);
            break;

        // ---- BOX
        case 2:
            fileName = "ofDrawBox.png";
            ofDrawBox(0, 0, 0, H*2/3, H/3, H/30);
            break;
            
        case 3:
            fileName = "ofSetBoxResolution.png";
            ofSetBoxResolution(4, 8, 3);
            ofDrawBox(0, -H/5, 0, H*2/3, H/3, H/30);
            ofSetBoxResolution(2, 2, 2);
            ofDrawBox(0, H/5, 0, H*2/3, H/3, H/30);
            break;

        // ---- CONE
        case 4:
            fileName = "ofDrawCone.png";
            ofDrawCone(0, 0, 0, 200, 400);
            break;
            
        case 5:
            fileName = "ofSetConeResolution.png";
            ofTranslate(-W * 0.15f, -H * 0.15f);
            ofSetConeResolution(5, 10, 2);
            ofDrawCone(0, 0, 0, H/4, H/2);
            ofTranslate(W * 0.3f, H * 0.3f);
            ofSetConeResolution(20, 30, 8);
            ofDrawCone(0, 0, 0, H/4, H/2);
            break;

        // ---- CYLINDER
        case 6:
            fileName = "ofDrawCylinder.png";
            ofDrawCylinder(0, 0, H/6, H*2/3);
            break;
            
        case 7:
            fileName = "ofSetCylinderResolution.png";
            ofSetCylinderResolution(5, 10, 2);
            ofDrawCylinder(-H/4, 0, H/6, H*2/3);
            ofSetCylinderResolution(10, 5, 2);
            ofDrawCylinder(H/4, 0, H/6, H*2/3);
            break;

        // ---- PLANE
        case 8:
            fileName = "ofDrawPlane.png";
            ofDrawPlane(0, 0, H*2/3, H/6);
            break;
            
        case 9:
            fileName = "ofSetPlaneResolution.png";
            ofSetPlaneResolution(10, 10);
            ofDrawPlane(0, -H/4, H*2/3, H/6);
            ofSetPlaneResolution(2, 2);
            ofDrawPlane(0, H/4, H*2/3, H/6);
            break;

        // ---- SPHERE
        case 10:
            fileName = "ofDrawSphere.png";
            ofDrawSphere(0, 0, H/3);
            break;
            
        case 11:
            fileName = "ofSetSphereResolution.png";            
            ofSetSphereResolution(10);
            ofDrawSphere(-H/5, -H/5, H/5);
            ofSetSphereResolution(3);
            ofDrawSphere(H/5, H/5, H/5);
            break;
    }
    if(!saved) {
        cout << imagesCurr << ". " << fileName << endl;
        ofSaveScreen(fileName);
        saved = true;
    }
}

//--------------------------------------------------------------
void ofApp::mousePressed(int, int, int) {
    imagesCurr = (imagesCurr + 1) % imagesTotal;
    saved = false;
}

the problem was that we use a specific mesh to draw a box wireframe so it draws a nice contour instead of the triangles of each face, i’ve changed so when the resolution is != of the default 1,1,1 it’ll use the triangles version to draw which is less confusing than what it was doing until now but it might not do what you expect since the drawing will contain all the triangles faces

Ah I see. No problem, then maybe it should just be mentioned in the documentation as to why the faces are not visible, and I could show that by making an ofMesh::box() you can actually get the faces if you want.

Do you think this idea of making a program to generate images for all the functions in the documentation makes sense? I think it would make the documentation better and (obviously) more visual.

By the way, if ofDrawBox() always makes beautiful boxes, does ofSetBoxResolution() have an effect somewhere? Maybe if you were using a shader to bend the geometry?

i’ve changed this in master already and now if the res!=1 you won’t get a nice outline but the triangles which i think is much more predictable than before.

ofDrawBox only draws using the contour version when using ofNoFill otherwise it uses the normal version which can be useful in cases like what you said or for example with lighting per vertex as it’s used in the multilightexample