Skip to content

Instantly share code, notes, and snippets.

@roxlu
Created February 4, 2012 22:57
Show Gist options
  • Select an option

  • Save roxlu/1740898 to your computer and use it in GitHub Desktop.

Select an option

Save roxlu/1740898 to your computer and use it in GitHub Desktop.
Light Rays 0.0 - most basic code: only a quad
#include "testApp.h"
void testApp::setup(){
ofBackground(33);
ofSetVerticalSync(true);
take_screenshot = false ;
// create quad width size "s", centered
float s = 1;
float hs = s * 0.5;
plane_data.addVertex(-hs,-hs,0);
plane_data.addVertex(hs,-hs,0);
plane_data.addVertex(hs,hs,0);
plane_data.addVertex(-hs,hs,0);
view.translate(0,0,-4);
}
void testApp::draw(){
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluPerspective(45.0f, 625.0f/469.0f, 0.1,100); // 625/469 is my window size
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
glMultMatrixf(view.getPtr());
// uses glBegin/glVertex3f/glEnd
plane_data.debugDraw(GL_QUADS);
if(take_screenshot) {
ofSaveScreen("light_rays_"+ofToString(ofGetHours()) +"_" +ofToString(ofGetMinutes()) +"_" +ofToString(ofGetSeconds()) +".png");
take_screenshot = false;
}
}
void testApp::keyPressed(int key){
if(key == ' ') {
take_screenshot = !take_screenshot;
}
}
#pragma once
#include "ofMain.h"
#include "Roxlu.h"
using namespace roxlu;
class testApp : public ofBaseApp{
public:
void setup();
void update();
void draw();
void keyPressed (int key);
bool take_screenshot;
Mat4 view;
VertexData plane_data;
VBO plane_vbo;
VAO plane_vao;
// not used in example
void keyReleased(int key);
void mouseMoved(int x, int y );
void mouseDragged(int x, int y, int button);
void mousePressed(int x, int y, int button);
void mouseReleased(int x, int y, int button);
void windowResized(int w, int h);
void dragEvent(ofDragInfo dragInfo);
void gotMessage(ofMessage msg);
};
@roxlu
Copy link
Author

roxlu commented Feb 4, 2012

result

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment