Skip to content

Commit

Permalink
#5 29.2 Implementing Textures
Browse files Browse the repository at this point in the history
Add ConstantColor class.
  • Loading branch information
mandyedi committed Nov 26, 2024
1 parent af36a97 commit f01eec9
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 0 deletions.
2 changes: 2 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,8 @@ set (SOURCE_SCENEBUILDERS
set (SOURCE_TEXTURES
src/Textures/Checker3D.cpp
src/Textures/Checker3D.h
src/Textures/ConstantColor.cpp
src/Textures/ConstantColor.h
src/Textures/Texture.cpp
src/Textures/Texture.h
)
Expand Down
17 changes: 17 additions & 0 deletions src/Textures/ConstantColor.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// Copyright (C) Kevin Suffern 2000-2007.
// This C++ code is for non-commercial purposes only.
// This C++ code is licensed under the GNU General Public License Version 2.
// See the file COPYING.txt for the full license.

// Copyright notice for changes since the originally published version:
// Copyright (C) Eduárd Mándy 2019-2021
// Though this C++ code was change in a large measure it still has the original copyright notice.
// This C++ code is for non-commercial purposes only.
// This C++ code is licensed under the GNU General Public License Version 2.
// See the file COPYING.txt for the full license.

#include "ConstantColor.h"

RGBColor ConstantColor::get_color(const ShadeRec& sr) const {
return color;
}
33 changes: 33 additions & 0 deletions src/Textures/ConstantColor.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
// Copyright (C) Kevin Suffern 2000-2007.
// This C++ code is for non-commercial purposes only.
// This C++ code is licensed under the GNU General Public License Version 2.
// See the file COPYING.txt for the full license.

// Copyright notice for changes since the originally published version:
// Copyright (C) Eduárd Mándy 2019-2021
// Though this C++ code was change in a large measure it still has the original copyright notice.
// This C++ code is for non-commercial purposes only.
// This C++ code is licensed under the GNU General Public License Version 2.
// See the file COPYING.txt for the full license.

#ifndef __CONSTANTCOLOR__
#define __CONSTANTCOLOR__

#include "Texture.h"
#include "../Utilities/RGBColor.h"

class ConstantColor : public Texture {
public:

void set_color(const RGBColor& c);

RGBColor get_color(const ShadeRec& sr) const override;

private:

RGBColor color = RGBColor::white;
};

inline void ConstantColor::set_color(const RGBColor &c) { color = c; }

#endif

0 comments on commit f01eec9

Please sign in to comment.