Browse Source

Create separate methods for creating triangle and quad surfaces

master
Krisjanis Rijnieks 9 years ago
parent
commit
15a9940e57
  1. 16
      src/Surfaces/SurfaceFactory.cpp
  2. 3
      src/Surfaces/SurfaceFactory.h

16
src/Surfaces/SurfaceFactory.cpp

@ -14,7 +14,15 @@ SurfaceFactory * SurfaceFactory::instance(){
BaseSurface * SurfaceFactory::createSurface(int type){
if(type == SurfaceType::TRIANGLE_SURFACE){
return createTriangleSurface();
}else if(type == SurfaceType::QUAD_SURFACE){
return createQuadSurface();
}else{
throw runtime_error("Undefined surface type");
}
}
TriangleSurface * SurfaceFactory::createTriangleSurface(){
vector <ofVec2f> vertices;
float margin = 50.0f;
vertices.push_back(ofVec2f((float)ofGetWidth() / 2.0f, margin));
@ -34,9 +42,9 @@ BaseSurface * SurfaceFactory::createSurface(int type){
}
return triangleSurface;
}
}else if(type == SurfaceType::QUAD_SURFACE){
QuadSurface * SurfaceFactory::createQuadSurface(){
vector <ofVec2f> vertices;
float margin = 50.0f;
vertices.push_back(ofVec2f(margin, margin));
@ -58,10 +66,6 @@ BaseSurface * SurfaceFactory::createSurface(int type){
}
return quadSurface;
}else{
throw runtime_error("Undefined surface type");
}
}
} // namespace piMapper

3
src/Surfaces/SurfaceFactory.h

@ -19,6 +19,9 @@ class SurfaceFactory {
private:
static SurfaceFactory * _instance;
TriangleSurface * createTriangleSurface();
QuadSurface * createQuadSurface();
};
} // namespace piMapper

Loading…
Cancel
Save