comparison testApp.cpp @ 0:2db9be889344

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