raylib-cpp
C++ object-oriented wrapper library for raylib.
Material.hpp
1 /*
2 * LICENSE: zlib/libpng
3 *
4 * raylib-cpp is licensed under an unmodified zlib/libpng license, which is an OSI-certified,
5 * BSD-like license that allows static linking with closed source software:
6 *
7 * Copyright (c) 2020 Rob Loach (@RobLoach)
8 *
9 * This software is provided "as-is", without any express or implied warranty. In no event
10 * will the authors be held liable for any damages arising from the use of this software.
11 *
12 * Permission is granted to anyone to use this software for any purpose, including commercial
13 * applications, and to alter it and redistribute it freely, subject to the following restrictions:
14 *
15 * 1. The origin of this software must not be misrepresented; you must not claim that you
16 * wrote the original software. If you use this software in a product, an acknowledgment
17 * in the product documentation would be appreciated but is not required.
18 *
19 * 2. Altered source versions must be plainly marked as such, and must not be misrepresented
20 * as being the original software.
21 *
22 * 3. This notice may not be removed or altered from any source distribution.
23 */
24 
25 #ifndef RAYLIB_CPP_INCLUDE_MATERIAL_HPP_
26 #define RAYLIB_CPP_INCLUDE_MATERIAL_HPP_
27 
28 #include <string>
29 #include <vector>
30 
31 #include "./raylib.hpp"
32 #include "./raylib-cpp-utils.hpp"
33 
34 namespace raylib {
35 class Material : public ::Material {
36  public:
37  Material(::Material material) {
38  set(material);
39  }
40 
45  set(LoadMaterialDefault());
46  }
47 
49  Unload();
50  }
51 
55  static std::vector<Material> Load(const std::string& fileName) {
56  int count = 0;
57  ::Material* materials = ::LoadMaterials(fileName.c_str(), &count);
58  return std::vector<Material>(materials, materials + count);
59  }
60 
61  GETTERSETTER(::Shader, Shader, shader)
62  GETTERSETTER(::MaterialMap*, Maps, maps)
63  GETTERSETTER(float*, Params, params)
64 
65  Material& operator=(const ::Material& material) {
66  set(material);
67  return *this;
68  }
69 
70  Material& operator=(const Material& material) {
71  set(material);
72  return *this;
73  }
74 
78  inline void Unload() {
79  ::UnloadMaterial(*this);
80  }
81 
85  inline Material& SetTexture(int mapType, ::Texture2D texture) {
86  ::SetMaterialTexture(this, mapType, texture);
87  return *this;
88  }
89 
90  protected:
91  inline void set(::Material material) {
92  shader = material.shader;
93  maps = material.maps;
94  params = material.params;
95  }
96 };
97 } // namespace raylib
98 
99 #endif // RAYLIB_CPP_INCLUDE_MATERIAL_HPP_
raylib
Provides all the classes associated with raylib-cpp.
Definition: AudioDevice.hpp:31
raylib::Material::~Material
~Material()
Definition: Material.hpp:48
raylib::Material::SetTexture
Material & SetTexture(int mapType, ::Texture2D texture)
Set texture for a material map type (MAP_DIFFUSE, MAP_SPECULAR...)
Definition: Material.hpp:85
raylib::Material::Load
static std::vector< Material > Load(const std::string &fileName)
Load materials from model file.
Definition: Material.hpp:55
raylib::Material::operator=
Material & operator=(const Material &material)
Definition: Material.hpp:70
raylib::Material::Material
Material(::Material material)
Definition: Material.hpp:37
raylib::Material::Material
Material()
Load default material (Supports: DIFFUSE, SPECULAR, NORMAL maps)
Definition: Material.hpp:44
raylib::Shader
Definition: Shader.hpp:35
raylib::Material::Unload
void Unload()
Unload material from memory.
Definition: Material.hpp:78
raylib::Texture
Definition: Texture.hpp:36
raylib::Material::set
void set(::Material material)
Definition: Material.hpp:91
raylib::Material
Definition: Material.hpp:35