Browse Source

patch for cpp 17 & of 12

master
cailean 1 month ago
parent
commit
deae808571
  1. 167
      example_basic/bin/data/ofxpimapper.xml
  2. 2
      src/Sources/VideoSource.cpp
  3. 3
      src/Sources/VideoSource.h
  4. 89
      src/Types/Vec2.cpp
  5. 24
      src/Types/Vec2.h
  6. 72
      src/Types/Vec3.cpp
  7. 18
      src/Types/Vec3.h

167
example_basic/bin/data/ofxpimapper.xml

@ -1,4 +1,39 @@
<surfaces>
<surface type="0">
<vertices>
<vertex>
<x>452.000000000</x>
<y>221.000000000</y>
</vertex>
<vertex>
<x>1017.744750977</x>
<y>744.464965820</y>
</vertex>
<vertex>
<x>6.254730225</x>
<y>744.464965820</y>
</vertex>
</vertices>
<texCoords>
<texCoord>
<x>0.500000000</x>
<y>0.000000000</y>
</texCoord>
<texCoord>
<x>1.000000000</x>
<y>1.000000000</y>
</texCoord>
<texCoord>
<x>0.000000000</x>
<y>1.000000000</y>
</texCoord>
</texCoords>
<source>
<source-type>video</source-type>
<source-name>gene-nsynthesis-loop-c.mp4</source-name>
<source-loop>1</source-loop>
</source>
</surface>
<surface type="0">
<vertices>
<vertex>
@ -31,6 +66,138 @@
<source>
<source-type>video</source-type>
<source-name>gene-nsynthesis-loop-a.mp4</source-name>
<source-loop>1</source-loop>
</source>
</surface>
<surface type="2">
<vertices>
<vertex>
<x>-8.000000000</x>
<y>6.000000000</y>
</vertex>
<vertex>
<x>434.000000000</x>
<y>250.000000000</y>
</vertex>
<vertex>
<x>920.000000000</x>
<y>101.000000000</y>
</vertex>
<vertex>
<x>-4.000000000</x>
<y>397.000000000</y>
</vertex>
<vertex>
<x>508.000000000</x>
<y>385.000000000</y>
</vertex>
<vertex>
<x>920.000000000</x>
<y>385.000000000</y>
</vertex>
<vertex>
<x>2.254730225</x>
<y>745.464965820</y>
</vertex>
<vertex>
<x>508.000000000</x>
<y>669.000000000</y>
</vertex>
<vertex>
<x>920.000000000</x>
<y>669.000000000</y>
</vertex>
</vertices>
<texCoords>
<texCoord>
<x>0.000000000</x>
<y>0.000000000</y>
</texCoord>
<texCoord>
<x>0.500000000</x>
<y>0.000000000</y>
</texCoord>
<texCoord>
<x>1.000000000</x>
<y>0.000000000</y>
</texCoord>
<texCoord>
<x>0.000000000</x>
<y>0.500000000</y>
</texCoord>
<texCoord>
<x>0.500000000</x>
<y>0.500000000</y>
</texCoord>
<texCoord>
<x>1.000000000</x>
<y>0.500000000</y>
</texCoord>
<texCoord>
<x>0.000000000</x>
<y>1.000000000</y>
</texCoord>
<texCoord>
<x>0.500000000</x>
<y>1.000000000</y>
</texCoord>
<texCoord>
<x>1.000000000</x>
<y>1.000000000</y>
</texCoord>
</texCoords>
<source>
<source-type>none</source-type>
<source-name>none</source-name>
</source>
<properties>
<gridCols>2</gridCols>
<gridRows>2</gridRows>
</properties>
</surface>
<surface type="5">
<vertices>
<vertex>
<x>267.996795654</x>
<y>22.747558594</y>
</vertex>
<vertex>
<x>267.996795654</x>
<y>147.252563477</y>
</vertex>
<vertex>
<x>434.003723145</x>
<y>147.252563477</y>
</vertex>
<vertex>
<x>434.003723145</x>
<y>22.747558594</y>
</vertex>
</vertices>
<texCoords>
<texCoord>
<x>0.000000000</x>
<y>0.000000000</y>
</texCoord>
<texCoord>
<x>1.000000000</x>
<y>0.000000000</y>
</texCoord>
<texCoord>
<x>1.000000000</x>
<y>1.000000000</y>
</texCoord>
<texCoord>
<x>0.000000000</x>
<y>1.000000000</y>
</texCoord>
</texCoords>
<source>
<source-type>none</source-type>
<source-name>none</source-name>
</source>
<properties>
<perspectiveWarping>1</perspectiveWarping>
</properties>
</surface>
</surfaces>

2
src/Sources/VideoSource.cpp

@ -27,7 +27,7 @@ void VideoSource::loadVideo(std::string & filePath){
_omxPlayer = OMXPlayerCache::instance()->load(filePath);
texture = &(_omxPlayer->getTextureReference());
#else
_videoPlayer = make_unique<ofVideoPlayer>();
_videoPlayer = std::make_unique<ofVideoPlayer>();
_videoPlayer->load(filePath);
_videoPlayer->setLoopState(OF_LOOP_NORMAL);
_videoPlayer->play();

3
src/Sources/VideoSource.h

@ -2,6 +2,7 @@
#include "ofMain.h"
#include "BaseSource.h"
#include <memory>
#ifdef TARGET_RASPBERRY_PI
#include "ofxOMXPlayer.h"
@ -39,7 +40,7 @@ class VideoSource : public BaseSource {
#ifdef TARGET_RASPBERRY_PI
ofxOMXPlayer * _omxPlayer;
#else
unique_ptr<ofVideoPlayer> _videoPlayer;
std::unique_ptr<ofVideoPlayer> _videoPlayer;
bool _initialVolumeSet;
#endif

89
src/Types/Vec2.cpp

@ -1,85 +1,50 @@
#include "Vec2.h"
#if OF_VERSION_MAJOR == 0 && OF_VERSION_MINOR > 9
#include "glm/geometric.hpp"
#endif
#include "glm/geometric.hpp"
namespace ofx {
namespace piMapper {
Vec2::Vec2(){
Vec2(0.0f, 0.0f);
}
Vec2::Vec2() : x(0.0f), y(0.0f) {}
Vec2::Vec2(float ix, float iy){
x = ix;
y = iy;
}
#if OF_VERSION_MAJOR == 0 && OF_VERSION_MINOR <= 9
Vec2::Vec2(ofVec2f & src){
x = src.x;
y = src.y;
}
ofVec2f Vec2::toOf(){
return ofVec2f(x, y);
}
std::vector<ofVec2f> Vec2::toOf(std::vector<Vec2> & src){
std::vector<ofVec2f> retVal;
for(auto itm : src){
retVal.push_back(itm.toOf());
}
return retVal;
}
std::vector<Vec2> Vec2::fromOf(std::vector<ofVec2f> & src){
std::vector<Vec2> retVal;
for(auto itm : src){
retVal.push_back(Vec2(itm));
}
return retVal;
}
float Vec2::distance(const Vec2 & other){
ofVec2f v1(x, y);
ofVec2f v2(other.x, other.y);
return v1.distance(v2);
}
#else
Vec2::Vec2(glm::vec2 & src){
x = src.x;
y = src.y;
}
Vec2::Vec2(glm::vec2 & src){
x = src.x;
y = src.y;
}
glm::vec2 Vec2::toOf(){
return glm::vec2(x, y);
}
glm::vec2 Vec2::toOf(){
return glm::vec2(x, y);
}
std::vector<glm::vec2> Vec2::toOf(std::vector<Vec2> & src){
std::vector<glm::vec2> retVal;
for(auto itm : src){
retVal.push_back(itm.toOf());
}
return retVal;
std::vector<glm::vec2> Vec2::toOf(std::vector<Vec2> & src){
std::vector<glm::vec2> retVal;
for(auto itm : src){
retVal.push_back(itm.toOf());
}
return retVal;
}
std::vector<Vec2> Vec2::fromOf(std::vector<glm::vec2> & src){
std::vector<Vec2> retVal;
for(auto itm : src){
retVal.push_back(Vec2(itm));
}
return retVal;
std::vector<Vec2> Vec2::fromOf(std::vector<glm::vec2> & src){
std::vector<Vec2> retVal;
for(auto itm : src){
retVal.push_back(Vec2(itm));
}
return retVal;
}
float Vec2::distance(const Vec2 & other){
glm::vec2 v1(x, y);
glm::vec2 v2(other.x, other.y);
float Vec2::distance(const Vec2 & other){
glm::vec2 v1(x, y);
glm::vec2 v2(other.x, other.y);
return glm::distance(v1, v2);
}
#endif
return glm::distance(v1, v2);
}
void Vec2::operator=(const Vec2 & other){
x = other.x;

24
src/Types/Vec2.h

@ -1,12 +1,8 @@
#pragma once
#include <vector>
#include "glm/vec2.hpp"
#if OF_VERSION_MAJOR == 0 && OF_VERSION_MINOR <= 9
#include "ofVec2f.h"
#else
#include "glm/vec2.hpp"
#endif
namespace ofx {
namespace piMapper {
@ -16,18 +12,12 @@ public:
Vec2();
Vec2(float ix, float iy);
// TODO: Achieve this with templates
#if OF_VERSION_MAJOR == 0 && OF_VERSION_MINOR <= 9
Vec2(ofVec2f & src);
ofVec2f toOf();
static std::vector<ofVec2f> toOf(std::vector<Vec2> & src);
static std::vector<Vec2> fromOf(std::vector<ofVec2f> & src);
#else
Vec2(glm::vec2 & src);
glm::vec2 toOf();
static std::vector<glm::vec2> toOf(std::vector<Vec2> & src);
static std::vector<Vec2> fromOf(std::vector<glm::vec2> & src);
#endif
Vec2(glm::vec2 & src);
glm::vec2 toOf();
static std::vector<glm::vec2> toOf(std::vector<Vec2> & src);
static std::vector<Vec2> fromOf(std::vector<glm::vec2> & src);
float distance(const Vec2 & other);

72
src/Types/Vec3.cpp

@ -3,9 +3,8 @@
namespace ofx {
namespace piMapper {
Vec3::Vec3(){
Vec3(0.0f, 0.0f, 0.0f);
}
Vec3::Vec3() : x(0.0f), y(0.0f), z(0.0f) {}
Vec3::Vec3(float ix, float iy, float iz){
x = ix;
@ -13,59 +12,32 @@ Vec3::Vec3(float ix, float iy, float iz){
z = iz;
}
#if OF_VERSION_MAJOR == 0 && OF_VERSION_MINOR <= 9
Vec3::Vec3(ofVec3f & src){
x = src.x;
y = src.y;
z = src.z;
}
ofVec3f Vec3::toOf(){
return ofVec3f(x, y, z);
}
std::vector<ofVec3f> Vec3::toOf(std::vector<Vec3> & src){
std::vector<ofVec3f> retVal;
for(auto itm : src){
retVal.push_back(itm.toOf());
}
return retVal;
}
std::vector<Vec3> Vec3::fromOf(std::vector<ofVec3f> & src){
std::vector<Vec3> retVal;
for(auto itm : src){
retVal.push_back(Vec3(itm));
}
return retVal;
}
#else
Vec3::Vec3(glm::vec3 & src){
x = src.x;
y = src.y;
z = src.z;
}
Vec3::Vec3(glm::vec3 & src){
x = src.x;
y = src.y;
z = src.z;
}
glm::vec3 Vec3::toOf(){
return ofVec3f(x, y, z);
}
glm::vec3 Vec3::toOf(){
return ofVec3f(x, y, z);
}
std::vector<glm::vec3> Vec3::toOf(std::vector<Vec3> & src){
std::vector<glm::vec3> retVal;
for(auto itm : src){
retVal.push_back(itm.toOf());
}
return retVal;
std::vector<glm::vec3> Vec3::toOf(std::vector<Vec3> & src){
std::vector<glm::vec3> retVal;
for(auto itm : src){
retVal.push_back(itm.toOf());
}
return retVal;
}
std::vector<Vec3> Vec3::fromOf(std::vector<glm::vec3> & src){
std::vector<Vec3> retVal;
for(auto itm : src){
retVal.push_back(Vec3(itm));
}
return retVal;
std::vector<Vec3> Vec3::fromOf(std::vector<glm::vec3> & src){
std::vector<Vec3> retVal;
for(auto itm : src){
retVal.push_back(Vec3(itm));
}
#endif
return retVal;
}
void Vec3::operator=(const Vec3 & other){
x = other.x;

18
src/Types/Vec3.h

@ -16,18 +16,12 @@ public:
Vec3();
Vec3(float ix, float iy, float iz);
// TODO: achieve this with templates
#if OF_VERSION_MAJOR == 0 && OF_VERSION_MINOR <= 9
Vec3(ofVec3f & src);
ofVec3f toOf();
static std::vector<ofVec3f> toOf(std::vector<Vec3> & src);
static std::vector<Vec3> fromOf(std::vector<ofVec3f> & src);
#else
Vec3(glm::vec3 & src);
glm::vec3 toOf();
static std::vector<glm::vec3> toOf(std::vector<Vec3> & src);
static std::vector<Vec3> fromOf(std::vector<glm::vec3> & src);
#endif
Vec3(glm::vec3 & src);
glm::vec3 toOf();
static std::vector<glm::vec3> toOf(std::vector<Vec3> & src);
static std::vector<Vec3> fromOf(std::vector<glm::vec3> & src);
void operator=(const Vec3 & other);
void operator+=(const Vec3 & other);

Loading…
Cancel
Save