annotate testApp.cpp @ 2:8c4903923021

added voiceIdOffset command param
author Henrik Ekeus <hekeus@eecs.qmul.ac.uk>
date Tue, 24 Jan 2012 14:41:27 +0000
parents 2db9be889344
children
rev   line source
hekeus@0 1 #include "testApp.h"
hekeus@0 2
hekeus@0 3
hekeus@0 4 //--------------------------------------------------------------
hekeus@0 5 void testApp::setup(){
hekeus@0 6 counter = 0;
hekeus@0 7 ofSetCircleResolution(50);
hekeus@0 8 ofBackground(255,255,255);
hekeus@0 9 bSmooth = false;
hekeus@0 10 ofSetWindowTitle("graphics example");
hekeus@0 11
hekeus@0 12 ofSetFrameRate(60); // if vertical sync is off, we can go a bit fast... this caps the framerate at 60fps.
hekeus@0 13 }
hekeus@0 14
hekeus@0 15 //--------------------------------------------------------------
hekeus@0 16 void testApp::update(){
hekeus@0 17 counter = counter + 0.033f;
hekeus@0 18 }
hekeus@0 19
hekeus@0 20 //--------------------------------------------------------------
hekeus@0 21 void testApp::draw(){
hekeus@0 22
hekeus@0 23 //--------------------------- circles
hekeus@0 24 //let's draw a circle:
hekeus@0 25 ofSetColor(255,130,0);
hekeus@0 26 float radius = 50 + 10 * sin(counter);
hekeus@0 27 ofFill(); // draw "filled shapes"
hekeus@0 28 ofCircle(100,400,radius);
hekeus@0 29
hekeus@0 30 // now just an outline
hekeus@0 31 ofNoFill();
hekeus@0 32 ofSetColor(0xCCCCCC);
hekeus@0 33 ofCircle(100,400,80);
hekeus@0 34
hekeus@0 35 // use the bitMap type
hekeus@0 36 // note, this can be slow on some graphics cards
hekeus@0 37 // because it is using glDrawPixels which varies in
hekeus@0 38 // speed from system to system. try using ofTrueTypeFont
hekeus@0 39 // if this bitMap type slows you down.
hekeus@0 40 ofSetColor(0x000000);
hekeus@0 41 ofDrawBitmapString("circle", 75,500);
hekeus@0 42
hekeus@0 43
hekeus@0 44 //--------------------------- rectangles
hekeus@0 45 ofFill();
hekeus@0 46 for (int i = 0; i < 200; i++){
hekeus@0 47 ofSetColor((int)ofRandom(0,255),(int)ofRandom(0,255),(int)ofRandom(0,255));
hekeus@0 48 ofRect(ofRandom(250,350),ofRandom(350,450),ofRandom(10,20),ofRandom(10,20));
hekeus@0 49 }
hekeus@0 50 ofSetColor(0x000000);
hekeus@0 51 ofDrawBitmapString("rectangles", 275,500);
hekeus@0 52
hekeus@0 53 //--------------------------- transparency
hekeus@0 54 ofSetColor(0x00FF33);
hekeus@0 55 ofRect(400,350,100,100);
hekeus@0 56 // alpha is usually turned off - for speed puposes. let's turn it on!
hekeus@0 57 ofEnableAlphaBlending();
hekeus@0 58 ofSetColor(255,0,0,127); // red, 50% transparent
hekeus@0 59 ofRect(450,430,100,33);
hekeus@0 60 ofSetColor(255,0,0,(int)(counter * 10.0f) % 255); // red, variable transparent
hekeus@0 61 ofRect(450,370,100,33);
hekeus@0 62 ofDisableAlphaBlending();
hekeus@0 63
hekeus@0 64 ofSetColor(0x000000);
hekeus@0 65 ofDrawBitmapString("transparency", 410,500);
hekeus@0 66
hekeus@0 67 //--------------------------- lines
hekeus@0 68 // a bunch of red lines, make them smooth if the flag is set
hekeus@0 69
hekeus@0 70 if (bSmooth){
hekeus@0 71 ofEnableSmoothing();
hekeus@0 72 }
hekeus@0 73
hekeus@0 74 ofSetColor(0xFF0000);
hekeus@0 75 for (int i = 0; i < 20; i++){
hekeus@0 76 ofLine(600,300 + (i*5),800, 250 + (i*10));
hekeus@0 77 }
hekeus@0 78
hekeus@0 79 if (bSmooth){
hekeus@0 80 ofDisableSmoothing();
hekeus@0 81 }
hekeus@0 82
hekeus@0 83 ofSetColor(0x000000);
hekeus@0 84 ofDrawBitmapString("lines\npress 's' to toggle smoothness", 600,500);
hekeus@0 85
hekeus@0 86 }
hekeus@0 87
hekeus@0 88
hekeus@0 89 //--------------------------------------------------------------
hekeus@0 90 void testApp::keyPressed (int key){
hekeus@0 91 if (key == 's'){
hekeus@0 92 bSmooth = !bSmooth;
hekeus@0 93 }
hekeus@0 94 }
hekeus@0 95
hekeus@0 96 //--------------------------------------------------------------
hekeus@0 97 void testApp::keyReleased (int key){
hekeus@0 98
hekeus@0 99 }
hekeus@0 100
hekeus@0 101 //--------------------------------------------------------------
hekeus@0 102 void testApp::mouseMoved(int x, int y ){
hekeus@0 103 }
hekeus@0 104
hekeus@0 105 //--------------------------------------------------------------
hekeus@0 106 void testApp::mouseDragged(int x, int y, int button){
hekeus@0 107 }
hekeus@0 108
hekeus@0 109 //--------------------------------------------------------------
hekeus@0 110 void testApp::mousePressed(int x, int y, int button){
hekeus@0 111 }
hekeus@0 112
hekeus@0 113
hekeus@0 114 //--------------------------------------------------------------
hekeus@0 115 void testApp::mouseReleased(int x, int y, int button){
hekeus@0 116
hekeus@0 117 }
hekeus@0 118
hekeus@0 119 //--------------------------------------------------------------
hekeus@0 120 void testApp::windowResized(int w, int h){
hekeus@0 121
hekeus@0 122 }