Created
May 21, 2012 19:01
-
-
Save companje/2763983 to your computer and use it in GitHub Desktop.
RGB Cube with ofMesh and ofVbo
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
////////////////////////////////////////////////////////////// | |
// 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