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"
17 Texture(const ::Texture& texture) {
30 Texture(const ::Image& image,
int layout) {
57 GETTERSETTER(
unsigned int, Id,
id)
58 GETTERSETTER(
int, Width, width)
59 GETTERSETTER(
int, Height, height)
60 GETTERSETTER(
int, Mipmaps, mipmaps)
61 GETTERSETTER(
int, Format, format)
91 return {
static_cast<float>(width),
static_cast<float>(height)};
98 set(::LoadTextureFromImage(image));
105 set(::LoadTextureCubemap(image, layoutType));
111 void Load(
const std::string& fileName) {
112 set(::LoadTexture(fileName.c_str()));
119 ::UnloadTexture(*
this);
126 ::UpdateTexture(*
this, pixels);
134 UpdateTextureRec(*
this, rec, pixels);
142 return ::LoadImageFromTexture(*
this);
156 ::GenTextureMipmaps(
this);
164 ::SetTextureFilter(*
this, filterMode);
172 ::SetTextureWrap(*
this, wrapMode);
187 ::DrawTexture(*
this, posX, posY, tint);
191 inline Texture&
Draw(::Vector2 position, ::Color tint = {255, 255, 255, 255}) {
192 ::DrawTextureV(*
this, position, tint);
196 inline Texture&
Draw(::Vector2 position,
float rotation,
float scale = 1.0f,
197 ::Color tint = {255, 255, 255, 255}) {
198 ::DrawTextureEx(*
this, position, rotation, scale, tint);
202 inline Texture&
Draw(::Rectangle sourceRec, ::Vector2 position = {0, 0},
203 ::Color tint = {255, 255, 255, 255}) {
204 ::DrawTextureRec(*
this, sourceRec, position, tint);
208 inline Texture&
Draw(::Vector2 tiling, ::Vector2 offset, ::Rectangle quad,
209 ::Color tint = {255, 255, 255, 255}) {
210 ::DrawTextureQuad(*
this, tiling, offset, quad, tint);
214 inline Texture&
Draw(::Rectangle sourceRec, ::Rectangle destRec, ::Vector2 origin = {0, 0},
215 float rotation = 0, ::Color tint = {255, 255, 255, 255}) {
216 ::DrawTexturePro(*
this, sourceRec, destRec, origin, rotation, tint);
220 inline Texture&
Draw(::NPatchInfo nPatchInfo, ::Rectangle destRec, ::Vector2 origin = {0, 0},
221 float rotation = 0, ::Color tint = {255, 255, 255, 255}) {
222 ::DrawTextureNPatch(*
this, nPatchInfo, destRec, origin, rotation, tint);
226 inline Texture&
Draw(::Vector3 position,
float width,
float height,
float length,
227 ::Color tint = {255, 255, 255, 255}) {
228 ::DrawCubeTexture(*
this, position, width, height, length, tint);
232 inline Texture& DrawTiled(::Rectangle sourceRec, ::Rectangle destRec, ::Vector2 origin = {0, 0},
233 float rotation = 0,
float scale = 1, Color tint = {255, 255, 255, 255}) {
234 ::DrawTextureTiled(*
this, sourceRec, destRec, origin, rotation, scale, tint);
238 inline Texture& DrawPoly(Vector2 center, Vector2 *points,
239 Vector2 *texcoords,
int pointsCount,
240 Color tint = {255, 255, 255, 255}) {
241 ::DrawTexturePoly(*
this, center, points, texcoords, pointsCount, tint);
249 ::SetMaterialTexture(material, mapType, *
this);
253 inline Texture&
SetMaterial(const ::Material& material,
int mapType = MATERIAL_MAP_NORMAL) {
254 ::SetMaterialTexture((::
Material*)(&material), mapType, *
this);
262 ::SetShapesTexture(*
this, source);
270 ::SetShaderValueTexture(shader, locIndex, *
this);
275 inline void set(const ::Texture& texture) {
277 width = texture.width;
278 height = texture.height;
279 mipmaps = texture.mipmaps;
280 format = texture.format;
285 typedef Texture Texture2D;
286 typedef Texture TextureCubemap;
290 #endif // RAYLIB_CPP_INCLUDE_TEXTURE_HPP_