Commit 7ae41f65 authored by Robert Menzel's avatar Robert Menzel

removed deprecated and unsupported functions and updated lodepng

parent dedbf29b
This diff is collapsed.
/***********************************************************************
* Copyright 2011-2012 Computer Graphics Group RWTH Aachen University. *
* All rights reserved. *
* Distributed under the terms of the MIT License (see LICENSE.TXT). *
**********************************************************************/
// See http://www.graphics.rwth-aachen.de/redmine/projects/acgl/wiki/ACGL_compile_time_settings
// for a comment what unsupported means.
#ifdef ACGL_INCLUDE_UNSUPPORTED
#ifndef ACGL_ANIMATIONS_EASEFUNCTIONS_HH
#define ACGL_ANIMATIONS_EASEFUNCTIONS_HH
#include <ACGL/ACGL.hh>
#include <ACGL/Math/Math.hh>
#include <ACGL/Base/Macros.hh>
namespace ACGL
{
namespace Animations
{
class EaseFunction
{
public:
virtual ~EaseFunction(){}
virtual float value(const float _progress) = 0;
};
ACGL_SMARTPOINTER_TYPEDEFS(EaseFunction)
/*
float Linear(float progress, ease_function_parameter& parameter);
float InQuad(float progress, ease_function_parameter& parameter);
float OutQuad(float progress, ease_function_parameter& parameter);
float InOutQuad(float progress, ease_function_parameter& parameter);
float BlendLinear(float progress, ease_function_parameter& parameter);
float BlendSin(float progress, ease_function_parameter& parameter);
float BlendCos(float progress, ease_function_parameter& parameter);
float BlendSinDamped(float progress, ease_function_parameter& parameter);
float BlendCosDamped(float progress, ease_function_parameter& parameter);
*/
namespace EaseFunctions{
class Linear : public EaseFunction
{
public:
Linear(){ }
virtual ~Linear(){}
virtual float value(const float _progress)
{
return _progress;
}
};
class InQuad : public EaseFunction
{
public:
InQuad(){ }
virtual ~InQuad(){}
virtual float value(const float _progress)
{
return _progress*_progress;
}
};
class OutQuad : public EaseFunction
{
public:
OutQuad(){ }
virtual ~OutQuad(){}
virtual float value(const float _progress)
{
return 1.0f-_progress*_progress;
}
};
class InOutQuad : public EaseFunction
{
public:
InOutQuad(){ }
virtual ~InOutQuad(){}
virtual float value(const float _progress)
{
if(_progress < 0.5)
return 2.0f*_progress*_progress;
else
return 1.0f-2.0f*pow(_progress-1.0f,2.0f);
}
};
class Sin : public EaseFunction
{
public:
Sin(float _frequency = 1.0f) :
mFrequency(_frequency) { }
virtual ~Sin(){}
virtual float value(const float _progress)
{
return sin(0.5f*(float)M_PI*mFrequency*_progress);
}
float mFrequency;
};
class BlendLinear : public EaseFunction
{
public:
BlendLinear(){ }
virtual ~BlendLinear(){}
virtual float value(const float _progress)
{
return 2.0f*Math::Functions::min(_progress, 1.0f-_progress);
}
};
class BlendSin : public EaseFunction
{
public:
BlendSin(){ }
virtual ~BlendSin(){}
virtual float value(const float _progress)
{
return sin(20*(float)M_PI*_progress);
}
};
class BlendCos : public EaseFunction
{
public:
BlendCos(){ }
virtual ~BlendCos(){}
virtual float value(const float _progress)
{
return cos(6*(float)M_PI*_progress)-1.0f;
}
};
class BlendSinDamped : public EaseFunction
{
public:
BlendSinDamped(){ }
virtual ~BlendSinDamped(){}
virtual float value(const float _progress)
{
return 2.0f*Math::Functions::min(_progress, 1.0f-_progress)*sin(10.0f*(float)M_PI*_progress);
}
};
class BlendCosDamped : public EaseFunction
{
public:
BlendCosDamped(){ }
virtual ~BlendCosDamped(){}
virtual float value(const float _progress)
{
return 2.0f*Math::Functions::min(_progress, 1.0f-_progress)*cos(10.0f*(float)M_PI*_progress);
}
};
}
}
}
#endif // ACGL_ANIMATIONS_EASEFUNCTIONS_HH
#endif
/***********************************************************************
* Copyright 2011-2012 Computer Graphics Group RWTH Aachen University. *
* All rights reserved. *
* Distributed under the terms of the MIT License (see LICENSE.TXT). *
**********************************************************************/
// See http://www.graphics.rwth-aachen.de/redmine/projects/acgl/wiki/ACGL_compile_time_settings
// for a comment what unsupported means.
#ifdef ACGL_INCLUDE_UNSUPPORTED
#ifndef ACGL_ANIMATIONS_INTERPOLATOR_HH
#define ACGL_ANIMATIONS_INTERPOLATOR_HH
#include <ACGL/ACGL.hh>
#include <ACGL/Animations/EaseFunctions.hh>
#include <ACGL/Scene/NURBSCurve.hh>
#include <ACGL/Types.hh>
#include <ACGL/Base/Macros.hh>
#include <vector>
namespace ACGL
{
namespace Animations
{
class BlendInterpolator
{
public:
virtual void blend(const void* value, const float progress) = 0;
};
ACGL_SMARTPOINTER_TYPEDEFS(BlendInterpolator)
struct interpolator_blend_t
{
EaseFunction* ease_function;
BlendInterpolator* interpolator;
float start, end;
};
typedef std::vector<interpolator_blend_t> BlendVector;
// Interpolator *************************************************************************************
template <class T>
class LinearInterpolator : public BlendInterpolator
{
public:
LinearInterpolator() :
mStartValue(),
mEndValue(),
mDiffValue(),
mSetStartPoint(true)
{
}
LinearInterpolator(const T& _end_value) :
mStartValue(),
mEndValue(_end_value),
mDiffValue(),
mSetStartPoint(true)
{
}
LinearInterpolator(const T& _start_value, const T& _end_value) :
mStartValue(_start_value),
mEndValue(_end_value),
mDiffValue(_end_value - _start_value),
mSetStartPoint(false)
{
}
inline void init(const T& _initValue)
{
if(mSetStartPoint)
{
mStartValue = _initValue;
mDiffValue = mEndValue-mStartValue;
}
}
inline const T interpolate(const float _progress)
{
return mStartValue + mDiffValue*_progress;
}
inline const T& finish()
{
return mEndValue;
}
virtual void blend(const void* _value, const float _progress)
{
*((T*)_value) += mEndValue*_progress;
}
protected:
private:
T mStartValue;
T mEndValue;
T mDiffValue;
bool mSetStartPoint;
};
typedef LinearInterpolator<float> LinearInterpolatorFloat;
typedef LinearInterpolator<glm::vec2> LinearInterpolatorVec2;
typedef LinearInterpolator<glm::vec3> LinearInterpolatorVec3;
template <class T>
class LinearPathInterpolator
{
public:
LinearPathInterpolator()
{
}
inline void init(const T& init_value)
{
}
inline const T interpolate(float _progress)
{
//TODO: This es very UGLY, implement a better way to find the current keypoint.
unsigned int i = 0;
for(i = 0 ;i < mKeypoints.size();i++)
{
if(mKeypoints[i].time >= _progress)
break;
}
if(i == 0)
{
return mKeypoints[0].data;
}else if(i < mKeypoints.size())
{
float val = (_progress-mKeypoints[i-1].time)
/(mKeypoints[i].time-mKeypoints[i-1].time);
return mKeypoints[i-1].data*(1.0f-val)+mKeypoints[i].data*val;
}
}
inline const T& finish()
{
return mKeypoints[mKeypoints.size()-1].data;
}
void insertControlPoint(const T& _data, const float _time)
{
unsigned int i = 0;
while(i < mKeypoints.size() && mKeypoints[i].time < _time) i++;
key_point_t keyPoint = {_data, _time};
mKeypoints.insert( mKeypoints.begin()+i, keyPoint );
}
protected:
private:
struct key_point_t{T data;float time;};
std::vector<key_point_t> mKeypoints;
};
typedef LinearPathInterpolator<float> LinearPathInterpolatorFloat;
typedef LinearPathInterpolator<glm::vec2> LinearPathInterpolatorVec2;
typedef LinearPathInterpolator<glm::vec3> LinearPathInterpolatorVec3;
template<class T, ACGL::uint_t DATA_DIMENSION>
class NURBSPathInterpolator
{
public:
NURBSPathInterpolator(ACGL::Scene::NURBSCurve<DATA_DIMENSION> curve) :
curve(curve)
{
}
void init(T& init_value)
{
// insert_control_point(data, 0.0f);
}
const T interpolate(float progress)
{
curve.insertKnot(progress);
// TODO: Interpolation code is missing
return T();
}
const T& finish()
{
return T();
}
inline ACGL::Scene::NURBSCurve<DATA_DIMENSION>& get_curve()
{
return curve;
}
protected:
private:
ACGL::Scene::NURBSCurve<DATA_DIMENSION> curve;
};
template <class T, class OffsetType, class DataOperations>
class LinearPathSpeedInterpolator
{
public:
LinearPathSpeedInterpolator() :
mKeypoints(),
mOffset(0.0f, 0.0f),
mCurrentPosition(1)
{
}
inline void init(const T& init_value)
{
mCurrentPosition = 0;
}
inline float interpolate(T& _data, const float _distance)
{
if(mCurrentPosition == mKeypoints.size())
return 0.0f;
//Get the next target point
T source, target;
if(mCurrentPosition == 0)
{
source = _data;
target = DataOperations::applyStartOffset(mKeypoints[mCurrentPosition], mKeypoints[mCurrentPosition+1], mOffset);
}else{
source = DataOperations::applyStartOffset(mKeypoints[mCurrentPosition-1], mKeypoints[mCurrentPosition], mOffset);
if(mCurrentPosition == mKeypoints.size()-1)
{
target = DataOperations::applyOffset(mKeypoints[mCurrentPosition-1], mKeypoints[mCurrentPosition], mOffset);
}else{
target = DataOperations::applyOffset(mKeypoints[mCurrentPosition-1], mKeypoints[mCurrentPosition], mKeypoints[mCurrentPosition+1], mOffset);
}
}
bool next;
T newPosition = DataOperations::getNewPosition(_data, source, target, _distance, next);
float realDistance = DataOperations::distance(_data, newPosition);
_data = newPosition;
//If we reached the next control point and there are keypoints left
if(next)
{
mCurrentPosition++;
return realDistance+interpolate(_data, _distance-realDistance);
}else
{
return realDistance;
}
}
inline bool finished()
{
return mCurrentPosition == mKeypoints.size();
}
inline OffsetType& getOffset()
{
return mOffset;
}
void appendControlPoint(const T& _data)
{
mKeypoints.push_back(_data);
}
protected:
private:
std::vector<T> mKeypoints;
OffsetType mOffset;
unsigned int mCurrentPosition;
};
}
}
#endif // INTERPOLATOR_HH
#endif
......@@ -12,6 +12,9 @@
*
* DON'T INCLUDE THIS DIRECTLY! Include <ACGL/Math.hh> instead!
*/
#ifndef ACGL_MATH_HH
#warning "Include Math.hh instead of Constants.hh directly"
#endif
#include <ACGL/ACGL.hh>
......@@ -20,7 +23,7 @@
#ifndef M_PI
// M_PI is not defined on e.g. VS2010 (isn't part of the standart), so in that case it gets defined here
// outside of the namespace because some code might expect it to be in math.h which is oviously not in our namespace...
// outside of the namespace because some code might expect it to be in math.h which is obviously not in our namespace...
#define M_PI 3.14159265358979323846
#endif
......@@ -40,33 +43,11 @@ template<> inline double INF<double> (void) { return INF_DOUBLE; }
template<> inline int_t INF<int_t> (void) { return INF_INT; }
template<> inline short_t INF<short_t> (void) { return INF_SHORT; }
//gets used for some floating-point comparisions
const float EPSILON_FLOAT = 0.0005f;
const double EPSILON_DOUBLE = 0.0005;
const float SQUARED_EPSILON_FLOAT = 0.00000025f;
const double SQUARED_EPSILON_DOUBLE = 0.00000025;
template<typename T> inline T EPSILON(void) { return T(); }
template<> inline float EPSILON<float> (void) { return EPSILON_FLOAT; }
template<> inline double EPSILON<double>(void) { return EPSILON_DOUBLE; }
template<typename T> inline T SQUARED_EPSILON(void) { return T(); }
template<> inline float SQUARED_EPSILON<float> (void) { return SQUARED_EPSILON_FLOAT; }
template<> inline double SQUARED_EPSILON<double>(void) { return SQUARED_EPSILON_DOUBLE; }
//Sine and Cosine stuff
const float PI_FLOAT = (float) M_PI;
const double PI_DOUBLE = (double) M_PI;
template<typename T> inline T PI(void) { return T(); }
template<> inline float PI<float> (void) { return PI_FLOAT; }
template<> inline double PI<double>(void) { return PI_DOUBLE; }
//constants to change from degree to radians and back
const float DEG_TO_RAD_FLOAT = PI_FLOAT / 180.0f;
const double DEG_TO_RAD_DOUBLE = PI_DOUBLE / 180.0 ;
const float RAD_TO_DEG_FLOAT = 180.0f / PI_FLOAT;
const double RAD_TO_DEG_DOUBLE = 180.0 / PI_DOUBLE;
const float DEG_TO_RAD_FLOAT = M_PI / 180.0f;
const double DEG_TO_RAD_DOUBLE = M_PI / 180.0 ;
const float RAD_TO_DEG_FLOAT = 180.0f / M_PI;
const double RAD_TO_DEG_DOUBLE = 180.0 / M_PI;
template<typename T> inline T DEG_TO_RAD(void) { return T(); }
template<> inline float DEG_TO_RAD<float> (void) { return DEG_TO_RAD_FLOAT; }
......
......@@ -12,6 +12,9 @@
*
* DON'T INCLUDE THIS DIRECTLY! Include <ACGL/Math.hh> instead!
*/
#ifndef ACGL_MATH_HH
#warning "Include Math.hh instead of Functions.hh directly"
#endif
#include <ACGL/ACGL.hh>
#include <ACGL/Math/Constants.hh>
......@@ -68,34 +71,9 @@ inline double atan2Deg(double a, double b) {return (::atan2(a, b) * Constants::R
inline int32_t round(float a) {return (int32_t) ( (a < 0.5f)? ceil(a-0.5f) : floor(a+0.5f) );}
inline int32_t round(double a) {return (int32_t) ( (a < 0.5 )? ceil(a-0.5 ) : floor(a+0.5 ) );}
inline float pow(float a, float b) { return ::powf(a, b); }
inline double pow(double a, double b) { return ::pow(a, b); }
inline float ceil(float a) {return ::ceilf(a);}
inline double ceil(double a) {return ::ceil(a);}
inline float floor(float a) {return ::floorf(a);}
inline double floor(double a) {return ::floor(a);}
inline float sqrt(float a) {return(::sqrtf(a));}
inline double sqrt(double a) {return(::sqrt (a));}
inline float sig(float a) {return(a < 0.0f ? -1.0f : 1.0f);}
inline double sig(double a) {return(a < 0.0 ? -1.0 : 1.0 );}
inline float abs(float a) {return(a < 0.0f ? -a : a);}
inline double abs(double a) {return(a < 0.0 ? -a : a);}
inline int_t abs(int_t a) {return(a < 0 ? -a : a);}
inline double randD (double _from = 0.0, double _to = 1.0) { return (_to - _from) * (double(rand()) / double(RAND_MAX)) + _from; }
inline int32_t randI32 (int32_t _from = 0, int32_t _to = 1) { return (rand() % (_to - _from + 1)) + _from; }
template<typename T>
inline T max(T a, T b) {return(a > b ? a : b);}
template<typename T>
inline T min(T a, T b) {return(a < b ? a : b);}
inline uint_t ring(int_t a, uint_t mod) {bool b = a < 0; a = abs(a) % mod; return(b ? mod - a : a);}
/**
......
/***********************************************************************
* Copyright 2011-2012 Computer Graphics Group RWTH Aachen University. *
* All rights reserved. *
* Distributed under the terms of the MIT License (see LICENSE.TXT). *
**********************************************************************/
#pragma once
#include <ACGL/ACGL.hh>
#include <ACGL/OpenGL/Controller/ShaderControlFile.hh>
#include <ACGL/OpenGL/Controller/ShaderProgramControlFiles.hh>
#include <ACGL/OpenGL/Controller/VertexArrayObjectControlFile.hh>
/***********************************************************************
* Copyright 2011-2013 Computer Graphics Group RWTH Aachen University. *
* All rights reserved. *
* Distributed under the terms of the MIT License (see LICENSE.TXT). *
**********************************************************************/
#pragma once
#include <ACGL/OpenGL/Creator/ShaderCreator.hh>
namespace ACGL{
namespace OpenGL{
typedef ACGL::OpenGL::ShaderCreator ShaderControlFile;
#ifdef _MSC_VER
#pragma message(__FILE__" : warning: ShaderControlFile is deprecated, use ShaderCreator instead (same interface)")
#else
#warning "ShaderControlFile is deprecated, use ShaderCreator instead (same interface)"
#endif
}
}
/***********************************************************************
* Copyright 2011-2013 Computer Graphics Group RWTH Aachen University. *
* All rights reserved. *
* Distributed under the terms of the MIT License (see LICENSE.TXT). *
**********************************************************************/
#pragma once
#include <ACGL/OpenGL/Creator/ShaderProgramCreator.hh>
namespace ACGL{
namespace OpenGL{
typedef ACGL::OpenGL::ShaderProgramCreator ShaderProgramControlFiles;
#ifdef _MSC_VER
#pragma message(__FILE__" : warning: ShaderProgramControlFiles is deprecated, use ShaderProgramCreator instead (same interface)")
#else
#warning "ShaderProgramControlFiles is deprecated, use ShaderProgramCreator instead (same interface)"
#endif
}
}
/***********************************************************************
* Copyright 2011-2013 Computer Graphics Group RWTH Aachen University. *
* All rights reserved. *
* Distributed under the terms of the MIT License (see LICENSE.TXT). *
**********************************************************************/
#pragma once
#include <ACGL/OpenGL/Creator/VertexArrayObjectCreator.hh>
namespace ACGL{
namespace OpenGL{
typedef ACGL::OpenGL::VertexArrayObjectCreator VertexArrayObjectControlFile;
#ifdef _MSC_VER
#pragma message(__FILE__" : warning: VertexArrayObjectControlFile is deprecated, use VertexArrayObjectCreator instead (same interface)")
#else
#warning "VertexArrayObjectControlFile is deprecated, use VertexArrayObjectCreator instead (same interface)"
#endif
}
}
......@@ -7,9 +7,6 @@
#ifndef ACGL_OPENGL_DATA_GEOMETRYDATA_HH
#define ACGL_OPENGL_DATA_GEOMETRYDATA_HH
/**
*/
#include <ACGL/ACGL.hh>
#include <ACGL/Base/Macros.hh>
......
......@@ -72,6 +72,105 @@ void ACGLRegisterDefaultDebugCallback();
//! default debug callback
void APIENTRY ACGL_KHR_default_debug_callback( GLenum _source, GLenum _type, GLuint _id, GLenum _severity, GLsizei _length, const GLchar *_message, void *_userParam);
///////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////
///
/// Error checking, mostly for internal use. Use Debug callbacks if available!
///
///////////////////////////////////////////////////////////////////////////////////////////////////
/// ///////////////////////////////////////////////////////////////////////////////////////////////
// for every OpenGL error enum this will return a human readable version of it
// similar to gluErrorString, but that function is not available on all plattforms
// (read: iOS)
const GLubyte* acglErrorString( GLenum _errorCode );
/*
* This function can be used outside of the ACGL framework to check always(!) for
* OpenGL errors. It will print the errors and return the error code of the last one.
* Each OpenGL command can only throw one error, errors can only stack up if this
* function or glGetError was not called often enough (and some OpenGL implementations
* will forget old errors if new ones occur).
*/
#define openGLError() openGLError_( __FILE__, __LINE__ )
/*
* This function is used internally in ACGL - but not directly. It gets called from all
* other rare/common/critical error checks. The __FILE__ __LINE macros have to be used in
* those to get the correct values from the caller file, if we would use the macro
* above we could get the file/line from this file, which isn't helping.
*/
GLenum openGLError_( const char *_fileName, const unsigned long _lineNumber );
/*
* NOTE: Explicit error checks are not needed anymore on desktop systems! Use KHR_debug
* callback instead (ACGL registers a default callback automatically).
*
*
*
* Inside of ACGL we distinguish between rare, common and critical errors. Each kind can be
* switched off which turns the function into nothing after compiler optimization. If an
* error check is turned off it will always behave as if there was no error, even if there