surface code audit
This commit is contained in:
parent
299e873c76
commit
9cf19f475c
@ -5,7 +5,7 @@
|
||||
// James Turk (jpt2433@rit.edu)
|
||||
//
|
||||
// Version:
|
||||
// $Id: Circle.hpp,v 1.1 2005/02/27 09:00:13 cozman Exp $
|
||||
// $Id: Circle.hpp,v 1.2 2005/03/03 09:25:19 cozman Exp $
|
||||
|
||||
#ifndef PHOTON_MATH_CIRCLE_HPP
|
||||
#define PHOTON_MATH_CIRCLE_HPP
|
||||
@ -22,7 +22,8 @@ class Rect;
|
||||
// Class: Circle
|
||||
// Defines geometric entity known as a circle.
|
||||
//
|
||||
// A plane curve everywhere equidistant from a given fixed point, the center. <http://dictionary.com>
|
||||
// A plane curve everywhere equidistant from a given fixed point, the center.
|
||||
// <http://dictionary.com>
|
||||
//
|
||||
// Operators:
|
||||
// - Circle == Circle
|
||||
@ -115,12 +116,26 @@ public:
|
||||
// Group: Accessors
|
||||
public:
|
||||
// Function: getCenter
|
||||
// Get center coordinate.
|
||||
// Get center <Point2>.
|
||||
//
|
||||
// Returns:
|
||||
// Center coordinate.
|
||||
// Center point.
|
||||
Point2 getCenter() const;
|
||||
|
||||
// Function: getCenterX
|
||||
// Get center x coordinate.
|
||||
//
|
||||
// Returns:
|
||||
// Center x coordinate.
|
||||
scalar getCenterX() const;
|
||||
|
||||
// Function: getCenterY
|
||||
// Get center y coordinate.
|
||||
//
|
||||
// Returns:
|
||||
// Center y coordinate.
|
||||
scalar getCenterY() const;
|
||||
|
||||
// Function: getRadius
|
||||
// Get radius of Circle.
|
||||
//
|
||||
|
@ -5,7 +5,7 @@
|
||||
// James Turk (jpt2433@rit.edu)
|
||||
//
|
||||
// Version:
|
||||
// $Id: Rect.hpp,v 1.1 2005/02/27 09:00:13 cozman Exp $
|
||||
// $Id: Rect.hpp,v 1.2 2005/03/03 09:25:19 cozman Exp $
|
||||
|
||||
#ifndef PHOTON_MATH_RECT_HPP
|
||||
#define PHOTON_MATH_RECT_HPP
|
||||
@ -16,11 +16,13 @@ namespace photon
|
||||
{
|
||||
namespace math
|
||||
{
|
||||
|
||||
class Circle;
|
||||
|
||||
// Class: Rect
|
||||
// Defines geometric entity known as a rectangle.
|
||||
//
|
||||
// A four-sided plane figure with four right angles. <http://dictionary.com>
|
||||
// A four-sided plane figure with four right angles. <http://dictionary.com>
|
||||
//
|
||||
// Operators:
|
||||
// - Rect == Rect
|
||||
@ -105,6 +107,16 @@ public:
|
||||
// True if Rect intersects rect, false otherwise.
|
||||
bool intersects(const Rect &rect) const;
|
||||
|
||||
// Function: intersects
|
||||
// Check for intersection between the <Rect> and <Circle>.
|
||||
//
|
||||
// Parameters:
|
||||
// circle - <Circle> with which to check for intersection.
|
||||
//
|
||||
// Returns:
|
||||
// True if Rect intersects circle, false otherwise.
|
||||
bool intersects(const Circle &circle) const;
|
||||
|
||||
// Function: contains
|
||||
// Check if a point is contained within the Rect.
|
||||
//
|
||||
|
@ -5,7 +5,7 @@
|
||||
// James Turk (jpt2433@rit.edu)
|
||||
//
|
||||
// Version:
|
||||
// $Id: Vector2.hpp,v 1.2 2005/03/01 07:51:23 cozman Exp $
|
||||
// $Id: Vector2.hpp,v 1.3 2005/03/03 09:25:19 cozman Exp $
|
||||
|
||||
#ifndef PHOTON_MATH_VECTOR2_HPP
|
||||
#define PHOTON_MATH_VECTOR2_HPP
|
||||
@ -158,7 +158,6 @@ public:
|
||||
// Angle of vector (in degrees).
|
||||
scalar getAngleDeg() const;
|
||||
|
||||
|
||||
// Function: getAngleRad
|
||||
// Angle of vector in radians, angle is calculated with respect to positive
|
||||
// X axis.
|
||||
|
@ -5,7 +5,7 @@
|
||||
// James Turk (jpt2433@rit.edu)
|
||||
//
|
||||
// Version:
|
||||
// $Id: math.hpp,v 1.3 2005/03/02 10:55:54 cozman Exp $
|
||||
// $Id: math.hpp,v 1.4 2005/03/03 09:25:19 cozman Exp $
|
||||
|
||||
#ifndef PHOTON_MATH_MATH_HPP
|
||||
#define PHOTON_MATH_MATH_HPP
|
||||
@ -24,7 +24,10 @@ class Vector2;
|
||||
// Title: Math Utilities
|
||||
|
||||
// Group: Constants
|
||||
const scalar Pi=3.1415926535897932384626433832795;
|
||||
|
||||
// Constant: PI
|
||||
// Defined constant for pi: 3.1415926535897932384626433832795
|
||||
const scalar PI=3.1415926535897932384626433832795;
|
||||
|
||||
// Group: Generic
|
||||
|
||||
@ -62,7 +65,7 @@ bool scalarCompare(scalar val1, scalar val2, scalar epsilon=0.000001);
|
||||
//
|
||||
// Returns:
|
||||
// Scalar distance between the two points.
|
||||
scalar distance(Vector2 v1, Vector2 v2);
|
||||
scalar distance(const Vector2& v1, const Vector2& v2);
|
||||
|
||||
// Group: Degrees/Radians
|
||||
|
||||
@ -74,6 +77,9 @@ scalar distance(Vector2 v1, Vector2 v2);
|
||||
//
|
||||
// Returns:
|
||||
// Radian equivalent of 'degrees'.
|
||||
//
|
||||
// See Also:
|
||||
// <radToDeg>
|
||||
scalar degToRad(scalar degrees);
|
||||
|
||||
// Function: radToDeg
|
||||
@ -84,9 +90,12 @@ scalar degToRad(scalar degrees);
|
||||
//
|
||||
// Returns:
|
||||
// Degree equivalent of 'radians'
|
||||
//
|
||||
// See Also:
|
||||
// <degToRad>
|
||||
scalar radToDeg(scalar radians);
|
||||
|
||||
//template implementation
|
||||
// clamp template implementation
|
||||
|
||||
template<typename T, typename C>
|
||||
T clamp(T val, C low, C high)
|
||||
|
@ -5,7 +5,7 @@
|
||||
// James Turk (jpt2433@rit.edu)
|
||||
//
|
||||
// Version:
|
||||
// $Id: ConfigFile.hpp,v 1.2 2005/02/16 06:58:05 cozman Exp $
|
||||
// $Id: ConfigFile.hpp,v 1.3 2005/03/03 09:25:19 cozman Exp $
|
||||
|
||||
#ifndef PHOTON_UTIL_CONFIGFILE_HPP
|
||||
#define PHOTON_UTIL_CONFIGFILE_HPP
|
||||
@ -122,6 +122,7 @@ public:
|
||||
const std::string& var,
|
||||
varType defVal) const;
|
||||
|
||||
// behind the scenes utils
|
||||
private:
|
||||
static std::string cleanString(const std::string& str);
|
||||
static std::string bracketString(const std::string& str);
|
||||
@ -164,14 +165,14 @@ ConfigFile::setVariable(const std::string& sec,
|
||||
{
|
||||
layout_.push_back( NamedSection( secBrac, Section() ) );
|
||||
|
||||
//search again, assert that it now exists
|
||||
// search again
|
||||
secIter = std::find_if( layout_.begin(),
|
||||
layout_.end(),
|
||||
std::bind2nd(StrPairEq<NamedSection>(), secBrac) );
|
||||
assert(secIter != layout_.end());
|
||||
std::bind2nd(StrPairEq<NamedSection>(),
|
||||
secBrac) );
|
||||
}
|
||||
|
||||
//search for variable
|
||||
// search for variable
|
||||
varIter = std::find_if( secIter->second.begin(),
|
||||
secIter->second.end(),
|
||||
std::bind2nd(StrPairEq<Variable>(), var) );
|
||||
|
@ -5,7 +5,7 @@
|
||||
// James Turk (jpt2433@rit.edu)
|
||||
//
|
||||
// Version:
|
||||
// $Id: FileBuffer.hpp,v 1.2 2005/02/16 06:58:06 cozman Exp $
|
||||
// $Id: FileBuffer.hpp,v 1.3 2005/03/03 09:25:20 cozman Exp $
|
||||
|
||||
#ifndef PHOTON_UTIL_FILEBUFFER_HPP
|
||||
#define PHOTON_UTIL_FILEBUFFER_HPP
|
||||
@ -45,7 +45,6 @@ public:
|
||||
// Destructor, calls <close>.
|
||||
~FileBuffer();
|
||||
|
||||
|
||||
// Group: General
|
||||
public:
|
||||
// Function: open
|
||||
|
@ -5,23 +5,23 @@
|
||||
// James Turk (jpt2433@rit.edu)
|
||||
//
|
||||
// Version:
|
||||
// $Id: RandGen.hpp,v 1.2 2005/02/16 06:58:06 cozman Exp $
|
||||
// $Id: RandGen.hpp,v 1.3 2005/03/03 09:25:20 cozman Exp $
|
||||
|
||||
#ifndef PHOTON_UTIL_RANDGEN_HPP
|
||||
#define PHOTON_UTIL_RANDGEN_HPP
|
||||
|
||||
namespace photon {
|
||||
namespace util {
|
||||
namespace photon
|
||||
{
|
||||
namespace util
|
||||
{
|
||||
|
||||
// Class: RandGen
|
||||
// Psuedorandom number generator class which uses Mersenne Twister.
|
||||
// MT19937 is described at <http://www.math.keio.ac.jp/matumoto/emt.html>.
|
||||
class RandGen
|
||||
{
|
||||
// Group: (Con/De)structors
|
||||
public:
|
||||
|
||||
// Group: (Con/De)structors
|
||||
|
||||
// Function: RandGen
|
||||
// Constructor for random generator, using time as seed.
|
||||
RandGen();
|
||||
@ -37,7 +37,8 @@ public:
|
||||
// <seed>
|
||||
RandGen(unsigned long seedVal);
|
||||
|
||||
// Group: General
|
||||
// Group: General
|
||||
public:
|
||||
|
||||
// Function: seed
|
||||
// Reseed random generator, a given seed will always turn out same string
|
||||
|
@ -5,7 +5,7 @@
|
||||
// James Turk (jpt2433@rit.edu)
|
||||
//
|
||||
// Version:
|
||||
// $Id: Singleton.hpp,v 1.4 2005/03/01 07:51:23 cozman Exp $
|
||||
// $Id: Singleton.hpp,v 1.5 2005/03/03 09:25:20 cozman Exp $
|
||||
|
||||
#ifndef PHOTON_UTIL_SINGLETON_HPP
|
||||
#define PHOTON_UTIL_SINGLETON_HPP
|
||||
@ -13,6 +13,8 @@
|
||||
#include <memory>
|
||||
#include <boost/utility.hpp>
|
||||
|
||||
#include "exceptions.hpp"
|
||||
|
||||
namespace photon
|
||||
{
|
||||
namespace util
|
||||
@ -67,7 +69,7 @@ public:
|
||||
static T& getInstance();
|
||||
|
||||
protected:
|
||||
virtual ~Singleton()=0;
|
||||
virtual ~Singleton()=0; // allow inheritance
|
||||
|
||||
private:
|
||||
static std::auto_ptr<T> instance_;
|
||||
@ -84,7 +86,10 @@ Singleton<T>::~Singleton()
|
||||
template<class T>
|
||||
void Singleton<T>::initialize()
|
||||
{
|
||||
assert(instance_.get() == 0);
|
||||
if(instance_.get() != 0)
|
||||
{
|
||||
throw PreconditionException("Attempt to double-initialize singleton.");
|
||||
}
|
||||
|
||||
instance_ = std::auto_ptr<T>(new T);
|
||||
}
|
||||
@ -92,7 +97,10 @@ void Singleton<T>::initialize()
|
||||
template<class T>
|
||||
void Singleton<T>::destroy()
|
||||
{
|
||||
assert(instance_.get() != 0);
|
||||
if(instance_.get() == 0)
|
||||
{
|
||||
throw PreconditionException("Attempt to destroy null singleton.");
|
||||
}
|
||||
|
||||
instance_.reset();
|
||||
}
|
||||
@ -100,9 +108,13 @@ void Singleton<T>::destroy()
|
||||
template<class T>
|
||||
T& Singleton<T>::getInstance()
|
||||
{
|
||||
assert(instance_.get() != 0);
|
||||
if(instance_.get() == 0)
|
||||
{
|
||||
throw PreconditionException("Attempt to get instance of uninitialized "
|
||||
"singleton.");
|
||||
}
|
||||
|
||||
return *instance_;
|
||||
return *instance_; //return dereferenced version
|
||||
}
|
||||
|
||||
template<class T>
|
||||
|
@ -5,7 +5,7 @@
|
||||
// James Turk (jpt2433@rit.edu)
|
||||
//
|
||||
// Version:
|
||||
// $Id: VersionInfo.hpp,v 1.4 2005/03/01 07:51:24 cozman Exp $
|
||||
// $Id: VersionInfo.hpp,v 1.5 2005/03/03 09:25:20 cozman Exp $
|
||||
|
||||
#ifndef PHOTON_UTIL_VERSIONINFO_HPP
|
||||
#define PHOTON_UTIL_VERSIONINFO_HPP
|
||||
@ -13,8 +13,10 @@
|
||||
#include <string>
|
||||
#include <ostream>
|
||||
|
||||
namespace photon {
|
||||
namespace util {
|
||||
namespace photon
|
||||
{
|
||||
namespace util
|
||||
{
|
||||
|
||||
// Class: VersionInfo
|
||||
// Class which stores version information, such as release numbers.
|
||||
|
@ -5,7 +5,7 @@
|
||||
// James Turk (jpt2433@rit.edu)
|
||||
//
|
||||
// Version:
|
||||
// $Id: Pen.hpp,v 1.1 2005/03/02 10:55:29 cozman Exp $
|
||||
// $Id: Pen.hpp,v 1.2 2005/03/03 09:25:47 cozman Exp $
|
||||
|
||||
#ifndef PHOTON_VIDEO_PEN_HPP
|
||||
#define PHOTON_VIDEO_PEN_HPP
|
||||
@ -56,7 +56,7 @@ public:
|
||||
//
|
||||
// See Also:
|
||||
// <setColor>
|
||||
Pen(Color color);
|
||||
Pen(const Color& color);
|
||||
|
||||
// Group: Color
|
||||
public:
|
||||
@ -75,7 +75,7 @@ public:
|
||||
//
|
||||
// Parameters:
|
||||
// color - <Color> to use for drawing.
|
||||
void setColor(Color color);
|
||||
void setColor(const Color& color);
|
||||
|
||||
// Group: Drawing
|
||||
public:
|
||||
@ -84,7 +84,7 @@ public:
|
||||
//
|
||||
// Parameters:
|
||||
// point - Point to draw.
|
||||
void drawPoint(math::Point2 point) const;
|
||||
void drawPoint(const math::Point2& point) const;
|
||||
|
||||
// Function: drawLine
|
||||
// Draw a line from one point to another.
|
||||
@ -92,7 +92,7 @@ public:
|
||||
// Parameters:
|
||||
// p1 - First endpoint of line.
|
||||
// p2 - Second endpoint of line.
|
||||
void drawLine(math::Point2 p1, math::Point2 p2) const;
|
||||
void drawLine(const math::Point2& p1, const math::Point2& p2) const;
|
||||
|
||||
// Function: drawVector
|
||||
// Draw a vector, including small arrow, with base at a given point.
|
||||
@ -100,7 +100,8 @@ public:
|
||||
// Parameters:
|
||||
// point - Base point for vector.
|
||||
// vector - Vector to draw.
|
||||
void drawVector(math::Point2 point, math::Vector2 vector) const;
|
||||
void drawVector(const math::Point2& point,
|
||||
const math::Vector2& vector) const;
|
||||
|
||||
// Function: drawRectangle
|
||||
// Draw an empty rectangle.
|
||||
|
@ -5,7 +5,7 @@
|
||||
// James Turk (jpt2433@rit.edu)
|
||||
//
|
||||
// Version:
|
||||
// $Id: AudioCore.cpp,v 1.1 2005/02/27 05:55:18 cozman Exp $
|
||||
// $Id: AudioCore.cpp,v 1.2 2005/03/03 09:25:47 cozman Exp $
|
||||
|
||||
#include "audio/AudioCore.hpp"
|
||||
|
||||
@ -27,8 +27,8 @@ std::string AudioCore::getAudioDeviceName() const
|
||||
|
||||
util::VersionInfo AudioCore::initOpenAL()
|
||||
{
|
||||
ALCdevice* device;
|
||||
ALCcontext* context;
|
||||
ALCdevice* device(0);
|
||||
ALCcontext* context(0);
|
||||
std::stringstream ss;
|
||||
std::string junks;
|
||||
char junkc;
|
||||
@ -53,8 +53,9 @@ util::VersionInfo AudioCore::initOpenAL()
|
||||
checkOpenALError());
|
||||
}
|
||||
|
||||
alcMakeContextCurrent(context);
|
||||
alcMakeContextCurrent(context); // context must be current to get version
|
||||
|
||||
// Version is in format "OpenAL 1.0"
|
||||
ss << alGetString(AL_VERSION);
|
||||
ss >> junks >> major >> junkc >> minor;
|
||||
return util::VersionInfo(major,minor,0);
|
||||
@ -86,7 +87,7 @@ std::string AudioCore::checkOpenALError()
|
||||
err = "OpenAL out of memory";
|
||||
break;
|
||||
default:
|
||||
err = "Unknown OpenAL error.";
|
||||
err = "Unknown OpenAL error";
|
||||
break;
|
||||
}
|
||||
|
||||
@ -95,6 +96,7 @@ std::string AudioCore::checkOpenALError()
|
||||
|
||||
void AudioCore::setDesiredDevice(const std::string& name)
|
||||
{
|
||||
// deviceName_ is used inside initOpenAL, must be set prior to construction
|
||||
deviceName_ = name;
|
||||
}
|
||||
|
||||
@ -102,13 +104,14 @@ std::string AudioCore::deviceName_;
|
||||
|
||||
AudioCore::AudioCore()
|
||||
{
|
||||
util::VersionInfo oalReq(1,0,0); // requires OpenAL 1.0
|
||||
util::VersionInfo oalReq(1,0,0); // requires OpenAL 1.0 (TODO: check?)
|
||||
|
||||
util::ensureVersion("OpenAL", initOpenAL(), oalReq);
|
||||
}
|
||||
|
||||
AudioCore::~AudioCore()
|
||||
{
|
||||
// retrieve both the context and device
|
||||
ALCcontext* context( alcGetCurrentContext() );
|
||||
ALCdevice* device( alcGetContextsDevice(context) );
|
||||
|
||||
|
@ -5,7 +5,7 @@
|
||||
// James Turk (jpt2433@rit.edu)
|
||||
//
|
||||
// Version:
|
||||
// $Id: Circle.cpp,v 1.1 2005/02/27 09:00:13 cozman Exp $
|
||||
// $Id: Circle.cpp,v 1.2 2005/03/03 09:25:47 cozman Exp $
|
||||
|
||||
#include "math/Circle.hpp"
|
||||
|
||||
@ -68,7 +68,7 @@ bool Circle::intersects(const Rect &rect) const
|
||||
{
|
||||
scalar newX;
|
||||
scalar newY;
|
||||
Rect circBound(center_-Vector2(radius_,radius_),2*radius_,2*radius_);
|
||||
Rect circBound(center_-Point2(radius_,radius_),2*radius_,2*radius_);
|
||||
|
||||
//reference of rects, 'rect' is shown as rect 5
|
||||
// _____________
|
||||
@ -124,6 +124,18 @@ Point2 Circle::getCenter() const
|
||||
return center_;
|
||||
}
|
||||
|
||||
scalar Circle::getCenterX() const
|
||||
{
|
||||
return center_.x;
|
||||
}
|
||||
|
||||
|
||||
scalar Circle::getCenterY() const
|
||||
{
|
||||
return center_.y;
|
||||
}
|
||||
|
||||
|
||||
scalar Circle::getRadius() const
|
||||
{
|
||||
return radius_;
|
||||
|
@ -5,12 +5,14 @@
|
||||
// James Turk (jpt2433@rit.edu)
|
||||
//
|
||||
// Version:
|
||||
// $Id: Rect.cpp,v 1.1 2005/02/27 09:00:13 cozman Exp $
|
||||
// $Id: Rect.cpp,v 1.2 2005/03/03 09:25:47 cozman Exp $
|
||||
|
||||
#include "math/Rect.hpp"
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
#include "math/Circle.hpp"
|
||||
|
||||
namespace photon
|
||||
{
|
||||
namespace math
|
||||
@ -75,6 +77,11 @@ bool Rect::intersects(const Rect &rect) const
|
||||
rect.topLeft_.y > bottomRight_.y);
|
||||
}
|
||||
|
||||
bool Rect::intersects(const Circle &circle) const
|
||||
{
|
||||
return circle.intersects(*this);
|
||||
}
|
||||
|
||||
bool Rect::contains(const Point2 &point) const
|
||||
{
|
||||
return point.x > topLeft_.x && point.x < bottomRight_.x &&
|
||||
|
@ -5,7 +5,7 @@
|
||||
// James Turk (jpt2433@rit.edu)
|
||||
//
|
||||
// Version:
|
||||
// $Id: math.cpp,v 1.1 2005/02/27 09:00:13 cozman Exp $
|
||||
// $Id: math.cpp,v 1.2 2005/03/03 09:25:47 cozman Exp $
|
||||
|
||||
#include "math/math.hpp"
|
||||
|
||||
@ -21,7 +21,7 @@ bool scalarCompare(scalar val1, scalar val2, scalar epsilon)
|
||||
return std::fabs(val1-val2) < epsilon;
|
||||
}
|
||||
|
||||
scalar distance(Vector2 v1, Vector2 v2)
|
||||
scalar distance(const Vector2& v1, const Vector2& v2)
|
||||
{
|
||||
return magnitude(v1-v2);
|
||||
}
|
||||
|
@ -5,7 +5,7 @@
|
||||
// James Turk (jpt2433@rit.edu)
|
||||
//
|
||||
// Version:
|
||||
// $Id: ConfigFile.cpp,v 1.4 2005/02/16 06:58:26 cozman Exp $
|
||||
// $Id: ConfigFile.cpp,v 1.5 2005/03/03 09:25:47 cozman Exp $
|
||||
|
||||
#include "util/ConfigFile.hpp"
|
||||
#include "exceptions.hpp"
|
||||
@ -17,8 +17,6 @@ namespace photon
|
||||
namespace util
|
||||
{
|
||||
|
||||
|
||||
|
||||
//(Con/De)structors
|
||||
|
||||
ConfigFile::ConfigFile()
|
||||
@ -42,7 +40,7 @@ void ConfigFile::open(const std::string& filename)
|
||||
filename_ = filename;
|
||||
if(filename_.empty())
|
||||
{
|
||||
throw PreconditionException("No filename in ConfigFile::open");
|
||||
throw PreconditionException("Empty filename in ConfigFile::open");
|
||||
}
|
||||
|
||||
std::string section, var, val, str, clean;
|
||||
|
@ -5,7 +5,7 @@
|
||||
// James Turk (jpt2433@rit.edu)
|
||||
//
|
||||
// Version:
|
||||
// $Id: RandGen.cpp,v 1.4 2005/02/16 06:58:26 cozman Exp $
|
||||
// $Id: RandGen.cpp,v 1.5 2005/03/03 09:25:47 cozman Exp $
|
||||
|
||||
// The source in this file is based on MT19937, with much of the source
|
||||
// replicated from mt19937ar.c, because of this the original license
|
||||
@ -57,8 +57,10 @@
|
||||
#include "util/RandGen.hpp"
|
||||
#include <ctime>
|
||||
|
||||
namespace photon {
|
||||
namespace util {
|
||||
namespace photon
|
||||
{
|
||||
namespace util
|
||||
{
|
||||
|
||||
//static consts
|
||||
const unsigned long RandGen::N;
|
||||
|
@ -5,7 +5,7 @@
|
||||
// James Turk (jpt2433@rit.edu)
|
||||
//
|
||||
// Version:
|
||||
// $Id: VersionInfo.cpp,v 1.5 2005/02/27 05:53:36 cozman Exp $
|
||||
// $Id: VersionInfo.cpp,v 1.6 2005/03/03 09:25:47 cozman Exp $
|
||||
|
||||
#include "util/VersionInfo.hpp"
|
||||
|
||||
@ -13,8 +13,10 @@
|
||||
|
||||
#include "exceptions.hpp"
|
||||
|
||||
namespace photon {
|
||||
namespace util {
|
||||
namespace photon
|
||||
{
|
||||
namespace util
|
||||
{
|
||||
|
||||
VersionInfo::VersionInfo(unsigned int maj, unsigned int min, unsigned int pat,
|
||||
std::string ext) :
|
||||
@ -27,20 +29,29 @@ VersionInfo::VersionInfo() :
|
||||
|
||||
bool VersionInfo::operator<(const VersionInfo &rhs) const
|
||||
{
|
||||
bool less(false);
|
||||
|
||||
//chained compares, compare numbers in order of importance
|
||||
if(this->major < rhs.major)
|
||||
return true;
|
||||
{
|
||||
less = true;
|
||||
}
|
||||
else if(this->major == rhs.major)
|
||||
{
|
||||
if(this->minor < rhs.minor)
|
||||
return true;
|
||||
{
|
||||
less = true;
|
||||
}
|
||||
else if(this->minor == rhs.minor)
|
||||
{
|
||||
if(this->patch < rhs.patch)
|
||||
return true;
|
||||
{
|
||||
less = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false; //if it reaches this point rhs is >=
|
||||
|
||||
return less; //false unless set to true within if-chain
|
||||
}
|
||||
|
||||
bool VersionInfo::operator<=(const VersionInfo &rhs) const
|
||||
@ -66,6 +77,7 @@ bool VersionInfo::operator>(const VersionInfo &rhs) const
|
||||
|
||||
std::ostream& operator<<(std::ostream &o, const VersionInfo &rhs)
|
||||
{
|
||||
// output major.minor.path [extra] (extra is only printed if not empty)
|
||||
return o << rhs.major << '.' << rhs.minor << '.' << rhs.patch <<
|
||||
(rhs.extra.empty() ? "" : " [" + rhs.extra + "]");
|
||||
}
|
||||
@ -80,7 +92,7 @@ void ensureVersion(const std::string& library,
|
||||
{
|
||||
ss << library << " version " << required << " required; " <<
|
||||
version << " used, please update.";
|
||||
throw APIError(ss.str());
|
||||
throw APIError(ss.str()); // throw APIError if requirement isn't met
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -5,7 +5,7 @@
|
||||
// James Turk (jpt2433@rit.edu)
|
||||
//
|
||||
// Version:
|
||||
// $Id: Pen.cpp,v 1.1 2005/03/02 10:55:29 cozman Exp $
|
||||
// $Id: Pen.cpp,v 1.2 2005/03/03 09:25:47 cozman Exp $
|
||||
|
||||
#include "video/Pen.hpp"
|
||||
|
||||
@ -28,7 +28,7 @@ Pen::Pen(ubyte r, ubyte g, ubyte b, ubyte a) :
|
||||
{
|
||||
}
|
||||
|
||||
Pen::Pen(Color color) :
|
||||
Pen::Pen(const Color& color) :
|
||||
color_(color)
|
||||
{
|
||||
}
|
||||
@ -38,12 +38,12 @@ void Pen::setColor(ubyte r, ubyte g, ubyte b, ubyte a)
|
||||
color_.setColor(r,g,b,a);
|
||||
}
|
||||
|
||||
void Pen::setColor(Color color)
|
||||
void Pen::setColor(const Color& color)
|
||||
{
|
||||
color_ = color;
|
||||
}
|
||||
|
||||
void Pen::drawPoint(math::Point2 point) const
|
||||
void Pen::drawPoint(const math::Point2& point) const
|
||||
{
|
||||
glBindTexture(GL_TEXTURE_2D,0);
|
||||
color_.makeGLColor();
|
||||
@ -53,7 +53,7 @@ void Pen::drawPoint(math::Point2 point) const
|
||||
glColor4ub(255,255,255,255);
|
||||
}
|
||||
|
||||
void Pen::drawLine(math::Point2 p1, math::Point2 p2) const
|
||||
void Pen::drawLine(const math::Point2& p1, const math::Point2& p2) const
|
||||
{
|
||||
glBindTexture(GL_TEXTURE_2D,0);
|
||||
color_.makeGLColor();
|
||||
@ -64,17 +64,18 @@ void Pen::drawLine(math::Point2 p1, math::Point2 p2) const
|
||||
glColor4ub(255,255,255,255);
|
||||
}
|
||||
|
||||
void Pen::drawVector(math::Point2 point, math::Vector2 vector) const
|
||||
void Pen::drawVector(const math::Point2& point,
|
||||
const math::Vector2& vector) const
|
||||
{
|
||||
double x2,y2,x3,y3,x4,y4;
|
||||
math::Vector2 v;
|
||||
x2 = point.x+vector.x;
|
||||
y2 = point.y+vector.y;
|
||||
//calculate an arrow (5pi/6)
|
||||
v.resolveRad(vector.getMagnitude()/5,vector.getAngleRad()+(5./6)*math::Pi);
|
||||
v.resolveRad(vector.getMagnitude()/5,vector.getAngleRad()+(5./6)*math::PI);
|
||||
x3 = x2+v.x;
|
||||
y3 = y2-v.y;
|
||||
v.resolveRad(vector.getMagnitude()/5,vector.getAngleRad()-(5./6)*math::Pi);
|
||||
v.resolveRad(vector.getMagnitude()/5,vector.getAngleRad()-(5./6)*math::PI);
|
||||
x4 = x2+v.x;
|
||||
y4 = y2-v.y;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user