Skip to content

Commit 2d5d869

Browse files
committed
CMake Fix adding src cpp and Android Swarm
1 parent f03aba3 commit 2d5d869

File tree

3 files changed

+27
-24
lines changed

3 files changed

+27
-24
lines changed

examples/android/androidAdvanced3DExample/src/Swarm.cpp

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
Swarm::Swarm()
1313
{
1414
//constructor, let's set some defaults
15-
nParticles = 0;
15+
nParticles = 0;
1616
light.setAmbientColor(ofColor(0,0,0));
1717
}
1818

@@ -24,23 +24,23 @@ void Swarm::init(int _nParticles, float positionDispersion, float velocityDisper
2424
//
2525
if (nParticles > 0)
2626
{
27-
ofLog(OF_LOG_WARNING, "Swarm: Already initialised");
28-
27+
ofLog(OF_LOG_WARNING) << "Swarm: Already initialised";
28+
2929
//delete[] = delete array from memory
3030
delete[] positions;
3131
delete[] velocities;
3232
delete[] colors;
33-
33+
3434
//superfluous line of code..
3535
nParticles = 0;
3636
}
3737
///////////////////////////////////////////
38-
39-
38+
39+
4040
//Swarm's internal variable set from argument
41-
nParticles = _nParticles;
42-
43-
41+
nParticles = _nParticles;
42+
43+
4444
///////////////////////////////////////////
4545
// SETUP ARRAYS
4646
///////////////////////////////////////////
@@ -50,8 +50,8 @@ void Swarm::init(int _nParticles, float positionDispersion, float velocityDisper
5050
colors = new ofColor[nParticles];
5151
//
5252
///////////////////////////////////////////
53-
54-
53+
54+
5555
///////////////////////////////////////////
5656
// INITIALISE VALUES
5757
///////////////////////////////////////////
@@ -61,26 +61,26 @@ void Swarm::init(int _nParticles, float positionDispersion, float velocityDisper
6161
positions[i].x = (ofRandom(1.0f)-0.5f) * positionDispersion;
6262
positions[i].y = (ofRandom(1.0f)-0.5f) * positionDispersion;
6363
positions[i].z = (ofRandom(1.0f)-0.5f) * positionDispersion;
64-
64+
6565
velocities[i].x = (ofRandom(1.0f)-0.5f) * velocityDispersion;
6666
velocities[i].y = (ofRandom(1.0f)-0.5f) * velocityDispersion;
6767
velocities[i].z = (ofRandom(1.0f)-0.5f) * velocityDispersion;
68-
68+
6969
colors[i].r = ofRandom(255.0f);
7070
colors[i].g = ofRandom(255.0f);
7171
colors[i].b = 150.0f;
7272
colors[i].a = 255.0f;
7373
}
7474
//
7575
///////////////////////////////////////////
76-
76+
7777
}
7878

7979
void Swarm::customDraw()
8080
{
8181
///we run the update ourselves manually
8282
update();
83-
83+
8484
//we use the position of the first
8585
//particle as the position of the
8686
//light
@@ -97,17 +97,17 @@ void Swarm::customDraw()
9797
{
9898
ofPushStyle();
9999
ofSetColor(colors[i]);
100-
100+
101101
ofDrawSphere(positions[i], 1.0);
102-
102+
103103
ofPopStyle();
104104
}
105105
//
106106
///////////////////////////////////////////
107-
107+
108108
light.disable();
109109
ofDisableLighting();
110-
110+
111111
//render light as white sphere
112112
ofSetColor(255, 255, 255);
113113
ofDrawSphere(positions[0], 2.0);
@@ -118,16 +118,16 @@ void Swarm::customDraw()
118118

119119
void Swarm::update()
120120
{
121-
121+
122122
//calculate time past per frame
123123
float dt = ofGetElapsedTimef() - timeLastUpdate;
124124
timeLastUpdate = ofGetElapsedTimef();
125-
125+
126126
//update positions, velocities
127127
for (int i=0; i< nParticles; i++)
128128
{
129129
////////////////////////////////
130-
//
130+
//
131131
// MOTION MATHS
132132
//
133133
// 'Simple Harmonic Motion'
@@ -159,7 +159,7 @@ void Swarm::update()
159159
//v = v + (dt * a)
160160
//v = v + (dt * -k * x)
161161
//
162-
velocities[i] += - SPRING_CONSTANT * positions[i] * dt;
162+
velocities[i] += - SPRING_CONSTANT * positions[i] * dt;
163163
//
164164
/////////////////////////////////
165165

examples/android/androidAdvanced3DExample/src/main.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ std::shared_ptr<ofAppBaseWindow> baseWindow;
1313
int main(int argc, char **argv) {
1414
baseWindow = std::make_shared<ofAppAndroidWindow>();
1515
ofxAndroidWindowSettings settings;
16-
settings.glesVersion = 2;
16+
settings.glesVersion = 1;
1717
settings.setSize(1920, 1080);
1818
settings.windowMode = OF_WINDOW;
1919
settings.preserveContextOnPause = true;

scripts/templates/android/ofApp/src/CMakeLists.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,9 @@ add_library( ${PROJECT_NAME}
6969
${OF_APP_SRC_PATH}/ofApp.cpp
7070
)
7171

72+
file(GLOB_RECURSE APP_SRC CONFIGURE_DEPENDS "${OF_APP_SRC_PATH}/*.cpp")
73+
target_sources(${PROJECT_NAME} PRIVATE ${APP_SRC})
74+
7275
include_directories(
7376
${PRJ_SOURCE_PATH}/3d
7477
${PRJ_SOURCE_PATH}/app

0 commit comments

Comments
 (0)