Home | History | Annotate | Download | only in flocking
      1 /*
      2  * Copyright (C) 2013 The Android Open Source Project
      3  *
      4  * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
      5  * in compliance with the License. You may obtain a copy of the License at
      6  *
      7  * http://www.apache.org/licenses/LICENSE-2.0
      8  *
      9  * Unless required by applicable law or agreed to in writing, software distributed under the License
     10  * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
     11  * or implied. See the License for the specific language governing permissions and limitations under
     12  * the License.
     13  */
     14 #ifndef FLOCKINGSCENE_H
     15 #define FLOCKINGSCENE_H
     16 
     17 #include <graphics/Program.h>
     18 
     19 #include "../Scene.h"
     20 #include "Boid.h"
     21 
     22 class FlockingScene : public Scene {
     23 public:
     24     FlockingScene(int width, int height);
     25     virtual ~FlockingScene() {};
     26     bool setUpTextures();
     27     bool setUpMeshes();
     28     bool tearDown();
     29     bool draw();
     30     static const int NUM_BOIDS = 100;
     31 protected:
     32     bool setUpPrograms();
     33     Matrix* setUpModelMatrix();
     34     Matrix* setUpViewMatrix();
     35     Matrix* setUpProjectionMatrix(float width, float height);
     36     bool updateSceneGraphs(int frame);
     37 private:
     38     Boid* mBoids[NUM_BOIDS];
     39     float mDisplayRatio;
     40     float mBoardWidth;
     41     float mBoardHeight;
     42     Program* mMainProgram;
     43     Program* mWaterProgram;
     44     static const constexpr float BOID_SCALE = 1.0f / 50.0f;
     45 };
     46 #endif
     47