Skip to content

Instantly share code, notes, and snippets.

@roxlu
Created July 11, 2011 09:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save roxlu/1075588 to your computer and use it in GitHub Desktop.
Save roxlu/1075588 to your computer and use it in GitHub Desktop.
#include "testApp.h"
void testApp::setup(){
ofBackground(33,33,33);
light.enable();
// light.setDirectional();
// light.setSpotlight(45.0, 0.2f);
light.setPointLight();
light.setPosition(0,0,150);
ofFloatColor ambient_color(1.0, 0.0, 0.0);
ofFloatColor diffuse_color(1.0, 1.0, 1.0);
ofFloatColor specular_color(0.0, 1.0, 0.0);
light.setAmbientColor(ambient_color);
light.setDiffuseColor(diffuse_color);
light.setSpecularColor(specular_color);
glEnable(GL_DEPTH_TEST);
glEnable(GL_CULL_FACE);
ofEnableLighting();
}
void testApp::draw(){
cam.begin();
// rotate around origin of view space
float xx = 0;
float yy = sin(ofGetElapsedTimef()*0.4)*150;
float zz = cos(ofGetElapsedTimef()*0.4)*150;
light.enable();
light.setPosition(xx,yy,zz);
light.draw();
// Why is the point drawn at a different position then the light?
glPointSize(7);
glColor3f(0,1,0);
glBegin(GL_POINTS);
glVertex3f(xx,yy,zz);
glEnd();
glPointSize(1);
// draw a box
ofPushStyle();
ofRotateY(45);
ofSetColor(255,255,255);
ofBox(0,0,10,220);
ofPopStyle();
}
void testApp::keyPressed(int key){
if(key == 'p') {
to_pdf = !to_pdf;
}
}
void testApp::update(){
}
//--------------------------------------------------------------
void testApp::keyReleased(int key){
}
//--------------------------------------------------------------
void testApp::mouseMoved(int x, int y ){
}
//--------------------------------------------------------------
void testApp::mouseDragged(int x, int y, int button){
}
//--------------------------------------------------------------
void testApp::mousePressed(int x, int y, int button){
}
//--------------------------------------------------------------
void testApp::mouseReleased(int x, int y, int button){
}
//--------------------------------------------------------------
void testApp::windowResized(int w, int h){
}
//--------------------------------------------------------------
void testApp::gotMessage(ofMessage msg){
}
//--------------------------------------------------------------
void testApp::dragEvent(ofDragInfo dragInfo){
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment