1#ifndef RAYLIB_CPP_INCLUDE_MATERIAL_HPP_
2#define RAYLIB_CPP_INCLUDE_MATERIAL_HPP_
9#include "./raylib-cpp-utils.hpp"
10#include "./raylib.hpp"
32 other.params[0] = 0.0f;
33 other.params[1] = 0.0f;
34 other.params[2] = 0.0f;
35 other.params[3] = 0.0f;
43 static std::vector<Material>
Load(
const std::string_view fileName) {
46 ::Material* materials = ::LoadMaterials(fileName.data(), &count);
47 return std::vector<Material>(materials, materials + count);
50 GETTERSETTER(::Shader,
Shader, shader)
51 GETTERSETTER(::MaterialMap*, Maps, maps)
80 if (maps !=
nullptr) {
81 ::UnloadMaterial(*
this);
90 ::SetMaterialTexture(
this, mapType, texture);
97 void DrawMesh(const ::Mesh& mesh, ::Matrix transform)
const {
::DrawMesh(mesh, *
this, transform); }
102 void DrawMesh(const ::Mesh& mesh, ::Matrix* transforms,
int instances)
const {
103 ::DrawMeshInstanced(mesh, *
this, transforms, instances);
109 inline void DrawMesh(const ::Mesh& mesh, std::span<::Matrix> transforms)
const {
110 ::DrawMeshInstanced(mesh, *
this, transforms.data(),
static_cast<int>(transforms.size()));
116 [[nodiscard]]
bool IsValid()
const { return ::IsMaterialValid(*
this); }
118 void set(const ::Material& material) {
119 shader = material.shader;
120 maps = material.maps;
121 params[0] = material.params[0];
122 params[1] = material.params[1];
123 params[2] = material.params[2];
124 params[3] = material.params[3];
void DrawMesh(const ::Mesh &mesh, std::span<::Matrix > transforms) const
Draw multiple mesh instances with material and different transforms.
bool IsValid() const
Check if material is ready.
Material & SetTexture(int mapType, const ::Texture2D &texture)
Set texture for a material map type (MAP_DIFFUSE, MAP_SPECULAR...)
void Unload()
Unload material from memory.
Material()
Load default material (Supports: DIFFUSE, SPECULAR, NORMAL maps)
void DrawMesh(const ::Mesh &mesh, ::Matrix *transforms, int instances) const
Draw multiple mesh instances with material and different transforms.
void DrawMesh(const ::Mesh &mesh, ::Matrix transform) const
Draw a 3d mesh with material and transform.
static std::vector< Material > Load(const std::string_view fileName)
Load materials from model file.
All raylib-cpp classes and functions appear in the raylib namespace.