1 #ifndef RAYLIB_CPP_INCLUDE_TEXTURE_HPP_
2 #define RAYLIB_CPP_INCLUDE_TEXTURE_HPP_
6 #include "./raylib.hpp"
7 #include "./raylib-cpp-utils.hpp"
8 #include "./Vector2.hpp"
9 #include "./Material.hpp"
10 #include "./RaylibException.hpp"
51 Texture(const ::Image& image,
int layout) {
66 throw RaylibException(TextFormat(
"Failed to load Texture from file: %s", fileName.c_str()));
86 GETTERSETTER(
unsigned int, Id,
id)
87 GETTERSETTER(
int, Width, width)
88 GETTERSETTER(
int, Height, height)
89 GETTERSETTER(
int, Mipmaps, mipmaps)
90 GETTERSETTER(
int, Format, format)
100 if (
this == &other) {
120 return {
static_cast<float>(width),
static_cast<float>(height)};
127 set(::LoadTextureFromImage(image));
134 set(::LoadTextureCubemap(image, layoutType));
140 void Load(
const std::string& fileName) {
141 set(::LoadTexture(fileName.c_str()));
148 ::UnloadTexture(*
this);
155 ::UpdateTexture(*
this, pixels);
163 UpdateTextureRec(*
this, rec, pixels);
171 return ::LoadImageFromTexture(*
this);
185 ::GenTextureMipmaps(
this);
193 ::SetTextureFilter(*
this, filterMode);
201 ::SetTextureWrap(*
this, wrapMode);
216 ::DrawTexture(*
this, posX, posY, tint);
220 inline Texture&
Draw(::Vector2 position, ::Color tint = {255, 255, 255, 255}) {
221 ::DrawTextureV(*
this, position, tint);
225 inline Texture&
Draw(::Vector2 position,
float rotation,
float scale = 1.0f,
226 ::Color tint = {255, 255, 255, 255}) {
227 ::DrawTextureEx(*
this, position, rotation, scale, tint);
231 inline Texture&
Draw(::Rectangle sourceRec, ::Vector2 position = {0, 0},
232 ::Color tint = {255, 255, 255, 255}) {
233 ::DrawTextureRec(*
this, sourceRec, position, tint);
237 inline Texture&
Draw(::Vector2 tiling, ::Vector2 offset, ::Rectangle quad,
238 ::Color tint = {255, 255, 255, 255}) {
239 ::DrawTextureQuad(*
this, tiling, offset, quad, tint);
243 inline Texture&
Draw(::Rectangle sourceRec, ::Rectangle destRec, ::Vector2 origin = {0, 0},
244 float rotation = 0, ::Color tint = {255, 255, 255, 255}) {
245 ::DrawTexturePro(*
this, sourceRec, destRec, origin, rotation, tint);
249 inline Texture&
Draw(::NPatchInfo nPatchInfo, ::Rectangle destRec, ::Vector2 origin = {0, 0},
250 float rotation = 0, ::Color tint = {255, 255, 255, 255}) {
251 ::DrawTextureNPatch(*
this, nPatchInfo, destRec, origin, rotation, tint);
255 inline Texture&
Draw(::Vector3 position,
float width,
float height,
float length,
256 ::Color tint = {255, 255, 255, 255}) {
257 ::DrawCubeTexture(*
this, position, width, height, length, tint);
261 inline Texture& DrawTiled(::Rectangle sourceRec, ::Rectangle destRec, ::Vector2 origin = {0, 0},
262 float rotation = 0,
float scale = 1, Color tint = {255, 255, 255, 255}) {
263 ::DrawTextureTiled(*
this, sourceRec, destRec, origin, rotation, scale, tint);
267 inline Texture& DrawPoly(Vector2 center, Vector2 *points,
268 Vector2 *texcoords,
int pointsCount,
269 Color tint = {255, 255, 255, 255}) {
270 ::DrawTexturePoly(*
this, center, points, texcoords, pointsCount, tint);
278 ::SetMaterialTexture(material, mapType, *
this);
282 inline Texture&
SetMaterial(const ::Material& material,
int mapType = MATERIAL_MAP_NORMAL) {
283 ::SetMaterialTexture((::
Material*)(&material), mapType, *
this);
291 ::SetShapesTexture(*
this, source);
299 ::SetShaderValueTexture(shader, locIndex, *
this);
313 inline void set(const ::Texture& texture) {
315 width = texture.width;
316 height = texture.height;
317 mipmaps = texture.mipmaps;
318 format = texture.format;
323 typedef Texture Texture2D;
324 typedef Texture TextureCubemap;
328 #endif // RAYLIB_CPP_INCLUDE_TEXTURE_HPP_