EDIT2: Solved by removing gl depth test.

EDIT: I just discovered GL_CULL_FACE, and I have to see if that can fix it.

I was following the icosahedron example in the documentation to try to convert it to a box renderer. So it creates the vbo inserting with setVertexData, setColorData and setIndexData.

I have a method called insert_cube(), which takes a position and edge length, and inserts 8 vertices, 8 colors, and 6 faces (using GL_QUADS). The code is below:

```
#include "ofApp.h"
vector<ofFloatColor> colors;
vector<glm::vec3> verts;
vector<ofIndexType> faces;
ofVbo vbo;
ofEasyCam cam;
void insert_cube(glm::vec3 p, float edge) {
float l = edge / 2;
auto v0 = p + glm::vec3( l, l, l);
auto v1 = p + glm::vec3(-l, l, l);
auto v2 = p + glm::vec3(-l, l, -l);
auto v3 = p + glm::vec3( l, l, -l);
auto v4 = p + glm::vec3( l, -l, l);
auto v5 = p + glm::vec3(-l, -l, l);
auto v6 = p + glm::vec3(-l, -l, -l);
auto v7 = p + glm::vec3( l, -l, -l);
verts.insert(verts.end(), {v0, v1, v2, v3, v4, v5, v6, v7});
ofFloatColor c(1, 1, 1, 0.5);
colors.insert(colors.end(), { c, c, c, c, c, c, c, c});
unsigned int d = verts.size() - 8;
faces.insert(faces.end(), { d+0, d+1, d+2, d+3 });
faces.insert(faces.end(), { d+3, d+2, d+6, d+7 });
faces.insert(faces.end(), { d+7, d+6, d+5, d+4 });
faces.insert(faces.end(), { d+4, d+5, d+1, d+0 });
faces.insert(faces.end(), { d+6, d+2, d+1, d+5 });
faces.insert(faces.end(), { d+3, d+7, d+4, d+0 });
}
int cubes = 0;
void ofApp::setup(){
ofSetBackgroundColor(10); glEnable(GL_DEPTH_TEST);
insert_cube(glm::vec3(0, 0, 0), 20.0f); cubes++;
insert_cube(glm::vec3(0, 0, 50), 20.0f); cubes++;
insert_cube(glm::vec3(0, 50, 50), 20.0f); cubes++;
insert_cube(glm::vec3(0, 100, 50), 20.0f); cubes++;
vbo.setVertexData(verts.data(), 8*cubes, GL_STATIC_DRAW);
vbo.setColorData(colors.data(), 8*cubes, GL_STATIC_DRAW);
vbo.setIndexData(faces.data(), (6*4)*cubes, GL_STATIC_DRAW);
}
void ofApp::update(){}
void ofApp::draw(){
cam.begin();
glEnable(GL_DEPTH_TEST);
vbo.drawElements(GL_QUADS, (6*4)*cubes);
cam.end();
}
```

For some reason, on 1 side, it is partially translucent:

And from the opposite perspective, it’s not transparent at all.

I’ve been messing with the clockwise/counterclockwise orientation of the face data, having cut up a cube with paper and labelling the vertices. I’m almost certain I have the orientation of the face data correct, but I still can’t seem to get it to render correctly.

I’ve tried using GL_TRIANGLES, and that resulted in the same image.

Any suggestions for what I might be missing? I have no idea at this point.

Thanks.

I’m attempting to get something like this with ofBox():

but using ofBox is too slow for many boxes.