Skip to content

Instantly share code, notes, and snippets.

@companje
Created May 21, 2012 19:01
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save companje/2763983 to your computer and use it in GitHub Desktop.
Save companje/2763983 to your computer and use it in GitHub Desktop.
RGB Cube with ofMesh and ofVbo
//////////////////////////////////////////////////////////////
// testApp.h
//////////////////////////////////////////////////////////////
#pragma once
#include "ofMain.h"
class testApp : public ofBaseApp {
public:
void setup();
void draw();
ofVbo vbo;
ofEasyCam camera;
};
//////////////////////////////////////////////////////////////
// testApp.cpp
//////////////////////////////////////////////////////////////
#include "testApp.h"
//--------------------------------------------------------------
void testApp::setup() {
ofBackground(0);
glEnable(GL_DEPTH_TEST);
ofMesh mesh;
char c[] = "011111101001111110100101110010000100"
"010011001000010110111011000100101001";
for (int i=0,x,y,z; i<72; i+=3) {
x = c[i+0]-'0';
y = c[i+1]-'0';
z = c[i+2]-'0';
mesh.addColor(ofFloatColor(x,y,z));
mesh.addVertex(ofVec3f(x*2-1,y*2-1,z*2-1));
}
vbo.setMesh(mesh, GL_STATIC_DRAW);
}
//--------------------------------------------------------------
void testApp::draw(){
camera.begin();
ofScale(100,100,100);
vbo.draw(GL_QUADS,0,24);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment