trying to get Phong shading model working, having very large color values come back though
git-svn-id: svn://anubis/fart/trunk@72 7f9b0f55-74a9-4bce-be96-3c2cd072584d
This commit is contained in:
1 parent
8677680577
commit
41b4354d52
10 files changed
+73
-10
No files matched your search
+17
-2
@@ -19,12 +19,21 @@ Color::Color(double r, double g, double b)
|
||||
this->b = b;
|
||||
}
|
||||
|
||||
Color Color::operator*(double scale)
|
||||
Color Color::operator*(const Color & other) const
|
||||
{
|
||||
Color result;
|
||||
result.r = r * other.r;
|
||||
result.g = g * other.g;
|
||||
result.b = b * other.b;
|
||||
return result;
|
||||
}
|
||||
|
||||
Color Color::operator*(double scale) const
|
||||
{
|
||||
return Color(r * scale, g * scale, b * scale);
|
||||
}
|
||||
|
||||
Color Color::operator/(double scale)
|
||||
Color Color::operator/(double scale) const
|
||||
{
|
||||
return Color(r / scale, g / scale, b / scale);
|
||||
}
|
||||
@@ -52,3 +61,9 @@ Color operator-(const Color & c1, const Color & c2)
|
||||
{
|
||||
return Color(c1.r - c2.r, c1.g - c2.g, c1.b - c2.b);
|
||||
}
|
||||
|
||||
std::ostream & operator<<(std::ostream & out, const Color & color)
|
||||
{
|
||||
out << "[" << color.r << ", " << color.g << ", " << color.b << "]";
|
||||
return out;
|
||||
}
|
||||
+6
-2
@@ -2,6 +2,8 @@
|
||||
#ifndef COLOR_H
|
||||
#define COLOR_H COLOR_H
|
||||
|
||||
#include <iostream>
|
||||
|
||||
class Color
|
||||
{
|
||||
public:
|
||||
@@ -10,8 +12,9 @@ class Color
|
||||
Color();
|
||||
Color(double r, double g, double b);
|
||||
|
||||
Color operator*(double scale);
|
||||
Color operator/(double scale);
|
||||
Color operator*(const Color & other) const;
|
||||
Color operator*(double scale) const;
|
||||
Color operator/(double scale) const;
|
||||
Color & operator+=(const Color & other);
|
||||
Color & operator-=(const Color & other);
|
||||
|
||||
@@ -24,6 +27,7 @@ class Color
|
||||
|
||||
Color operator+(const Color & c1, const Color & c2);
|
||||
Color operator-(const Color & c1, const Color & c2);
|
||||
std::ostream & operator<<(std::ostream & out, const Color & color);
|
||||
|
||||
#endif
|
||||
|
||||
Reference in new issue
Block a user