Skip to content

Commit 87f1e5f

Browse files
authored
PI / TWO_PI -> glm versions in examples (#8423)
1 parent b95bebc commit 87f1e5f

File tree

4 files changed

+71
-71
lines changed
  • examples

4 files changed

+71
-71
lines changed

examples/3d/3DPrimitivesExample/src/ofApp.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ void ofApp::draw() {
178178
box.transformGL();
179179
for (int i = 0; i < ofBoxPrimitive::SIDES_TOTAL; i++) {
180180
ofPushMatrix();
181-
ofTranslate(boxSides[i].getNormal(0) * sin(ofGetElapsedTimef()) * 50);
181+
ofTranslate(boxSides[i].getNormal(0) * sin(ofGetElapsedTimef()) * 50.0f);
182182
boxSides[i].draw();
183183
ofPopMatrix();
184184
}
@@ -294,13 +294,13 @@ void ofApp::draw() {
294294
cylinder.transformGL();
295295
ofPushMatrix(); {
296296
if (topCap.getNumNormals() > 0) {
297-
ofTranslate(topCap.getNormal(0) * (cos(ofGetElapsedTimef() * 5) + 1)*.5f * 100);
297+
ofTranslate(topCap.getNormal(0) * (cos(ofGetElapsedTimef() * 5) + 1)*.5f * 100.0f);
298298
topCap.draw();
299299
}
300300
} ofPopMatrix();
301301
ofPushMatrix(); {
302302
if (bottomCap.getNumNormals() > 0) {
303-
ofTranslate(bottomCap.getNormal(0) * (cos(ofGetElapsedTimef() * 4) + 1)*.5f * 100);
303+
ofTranslate(bottomCap.getNormal(0) * (cos(ofGetElapsedTimef() * 4) + 1)*.5f * 100.0f);
304304
bottomCap.draw();
305305
}
306306
} ofPopMatrix();
@@ -341,7 +341,7 @@ void ofApp::draw() {
341341
cone.transformGL();
342342
ofPushMatrix();
343343
if (bottomCap.getNumNormals() > 0) {
344-
ofTranslate(bottomCap.getNormal(0) * cone.getHeight()*.5);
344+
ofTranslate(bottomCap.getNormal(0) * (float)cone.getHeight()*.5f);
345345
ofRotateDeg( glm::degrees( sin(ofGetElapsedTimef() * 5) ), 1, 0, 0);
346346
bottomCap.draw();
347347
}

examples/3d/normalsExample/src/ofApp.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@ void ofApp::setup(){
2222

2323
//loop around and make verts in a circle, with a bit of a z-wave
2424
for (int i = 0; i < max; i++){
25-
float step = 2*PI/max; // step size around circle
26-
float theta = ofMap(i, 0, max-1, 0, 2*PI - step); //map i as circle divisions to actual radian values around the circle (note we don't go quite all the way around by one step, because it will be the same as where we started, so we'll just index that starting vertex when we make faces)
25+
float step = glm::two_pi<float>()/max; // step size around circle
26+
float theta = ofMap(i, 0, max-1, 0, glm::two_pi<float>() - step); //map i as circle divisions to actual radian values around the circle (note we don't go quite all the way around by one step, because it will be the same as where we started, so we'll just index that starting vertex when we make faces)
2727

2828
float prevTheta = theta - step; //one step back
2929
float nextTheta = theta + step; // one step forward
@@ -52,7 +52,7 @@ void ofApp::setup(){
5252

5353
//add a color too
5454
ofColor c;
55-
c.setHsb(40 + 30*sin(2*theta+PI),255,255,255);
55+
c.setHsb(40 + 30*sin(2*theta+glm::pi<float>()),255,255,255);
5656
mesh.addColor(c);
5757
}
5858

examples/android/androidCompositeExample/ofApp/src/main/cpp/ofApp.cpp

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -58,10 +58,10 @@ void ofApp::setup(){
5858
volume = 0.1f;
5959
bNoise = false;
6060
initialBufferSize = 256;
61-
61+
6262
lAudio = new float[initialBufferSize];
6363
rAudio = new float[initialBufferSize];
64-
64+
6565
memset(lAudio, 0, initialBufferSize * sizeof(float));
6666
memset(rAudio, 0, initialBufferSize * sizeof(float));
6767

@@ -95,7 +95,7 @@ void ofApp::draw(){
9595
int b = 128 + 50 * sinf(ofGetElapsedTimef());
9696

9797
ofBackground(r,g,b);
98-
98+
9999
if( doShader ){
100100
shader.begin();
101101
//we want to pass in some varrying values to animate our type / color
@@ -122,7 +122,7 @@ void ofApp::draw(){
122122
ofVertex(20+i*10,ofGetHeight() / 2 + 250 + rAudio[i]*500.0f);
123123
}
124124
ofEndShape(false);
125-
125+
126126
//finally draw our text
127127
text.draw();
128128

@@ -133,13 +133,13 @@ void ofApp::draw(){
133133
}
134134

135135
//--------------------------------------------------------------
136-
void ofApp::keyPressed (int key){
137-
136+
void ofApp::keyPressed (int key){
137+
138138
}
139139

140140
//--------------------------------------------------------------
141-
void ofApp::keyReleased(int key){
142-
141+
void ofApp::keyReleased(int key){
142+
143143
}
144144

145145
//--------------------------------------------------------------
@@ -182,7 +182,7 @@ void ofApp::touchMoved(int x, int y, int id){
182182
float height = (float)ofGetHeight();
183183
float heightPct = ((height-y) / height);
184184
targetFrequency = 2000.0f * heightPct;
185-
phaseAdderTarget = (targetFrequency / (float) sampleRate) * TWO_PI;
185+
phaseAdderTarget = (targetFrequency / (float) sampleRate) * glm::two_pi<float>();
186186
}
187187

188188
//--------------------------------------------------------------
@@ -248,8 +248,8 @@ void ofApp::audioOut(ofSoundBuffer & buffer){
248248

249249
// sin (n) seems to have trouble when n is very large, so we
250250
// keep phase in the range of 0-TWO_PI like this:
251-
while (phase > TWO_PI){
252-
phase -= TWO_PI;
251+
while (phase > glm::two_pi<float>()){
252+
phase -= glm::two_pi<float>();
253253
}
254254

255255
if ( bNoise == true){

0 commit comments

Comments
 (0)