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) {
45 GETTERSETTER(
unsigned int, Id,
id)
46 GETTERSETTER(
int, Width, width)
47 GETTERSETTER(
int, Height, height)
48 GETTERSETTER(
int, Mipmaps, mipmaps)
49 GETTERSETTER(
int, Format, format)
60 return {
static_cast<float>(width),
static_cast<float>(height)};
67 set(::LoadTextureFromImage(image));
74 set(::LoadTextureCubemap(image, layoutType));
80 void Load(
const std::string& fileName) {
81 set(::LoadTexture(fileName.c_str()));
88 ::UnloadTexture(*
this);
95 ::UpdateTexture(*
this, pixels);
103 UpdateTextureRec(*
this, rec, pixels);
111 return ::GetTextureData(*
this);
125 ::GenTextureMipmaps(
this);
133 ::SetTextureFilter(*
this, filterMode);
141 ::SetTextureWrap(*
this, wrapMode);
156 ::DrawTexture(*
this, posX, posY, tint);
160 inline Texture&
Draw(::Vector2 position, ::Color tint = {255, 255, 255, 255}) {
161 ::DrawTextureV(*
this, position, tint);
165 inline Texture&
Draw(::Vector2 position,
float rotation,
float scale = 1.0f,
166 ::Color tint = {255, 255, 255, 255}) {
167 ::DrawTextureEx(*
this, position, rotation, scale, tint);
171 inline Texture&
Draw(::Rectangle sourceRec, ::Vector2 position = {0, 0},
172 ::Color tint = {255, 255, 255, 255}) {
173 ::DrawTextureRec(*
this, sourceRec, position, tint);
177 inline Texture&
Draw(::Vector2 tiling, ::Vector2 offset, ::Rectangle quad,
178 ::Color tint = {255, 255, 255, 255}) {
179 ::DrawTextureQuad(*
this, tiling, offset, quad, tint);
183 inline Texture&
Draw(::Rectangle sourceRec, ::Rectangle destRec, ::Vector2 origin = {0, 0},
184 float rotation = 0, ::Color tint = {255, 255, 255, 255}) {
185 ::DrawTexturePro(*
this, sourceRec, destRec, origin, rotation, tint);
189 inline Texture&
Draw(::NPatchInfo nPatchInfo, ::Rectangle destRec, ::Vector2 origin = {0, 0},
190 float rotation = 0, ::Color tint = {255, 255, 255, 255}) {
191 ::DrawTextureNPatch(*
this, nPatchInfo, destRec, origin, rotation, tint);
195 inline Texture&
Draw(::Vector3 position,
float width,
float height,
float length,
196 ::Color tint = {255, 255, 255, 255}) {
197 ::DrawCubeTexture(*
this, position, width, height, length, tint);
201 inline Texture& DrawTiled(::Rectangle sourceRec, ::Rectangle destRec, ::Vector2 origin = {0, 0},
202 float rotation = 0,
float scale = 1, Color tint = {255, 255, 255, 255}) {
203 ::DrawTextureTiled(*
this, sourceRec, destRec, origin, rotation, scale, tint);
207 inline Texture& DrawPoly(Vector2 center, Vector2 *points,
208 Vector2 *texcoords,
int pointsCount,
209 Color tint = {255, 255, 255, 255}) {
210 ::DrawTexturePoly(*
this, center, points, texcoords, pointsCount, tint);
218 ::SetMaterialTexture(material, mapType, *
this);
222 inline Texture&
SetMaterial(const ::Material& material,
int mapType = MATERIAL_MAP_NORMAL) {
223 ::SetMaterialTexture((::
Material*)(&material), mapType, *
this);
228 inline void set(const ::Texture& texture) {
230 width = texture.width;
231 height = texture.height;
232 mipmaps = texture.mipmaps;
233 format = texture.format;
238 typedef Texture Texture2D;
239 typedef Texture TextureCubemap;
243 #endif // RAYLIB_CPP_INCLUDE_TEXTURE_HPP_