1 #ifndef RAYLIB_CPP_INCLUDE_TEXTUREUNMANAGED_HPP_
2 #define RAYLIB_CPP_INCLUDE_TEXTUREUNMANAGED_HPP_
6 #include "./raylib.hpp"
7 #include "./raylib-cpp-utils.hpp"
8 #include "./Vector2.hpp"
9 #include "./Material.hpp"
10 #include "./RaylibException.hpp"
11 #include "./Image.hpp"
34 int width,
int height,
36 int format = PIXELFORMAT_UNCOMPRESSED_R8G8B8A8)
37 : ::
Texture{id, width, height, mipmaps, format} {
45 ::
Texture{texture.id, texture.width, texture.height, texture.mipmaps, texture.format} {
79 ::
Texture{other.id, other.width, other.height, other.mipmaps, other.format} {
83 GETTERSETTER(
unsigned int, Id,
id)
84 GETTERSETTER(
int, Width, width)
85 GETTERSETTER(
int, Height, height)
86 GETTERSETTER(
int, Mipmaps, mipmaps)
87 GETTERSETTER(
int, Format, format)
98 return {
static_cast<float>(width),
static_cast<float>(height)};
104 void Load(const ::Image& image) {
105 set(::LoadTextureFromImage(image));
114 void Load(const ::Image& image,
int layoutType) {
115 set(::LoadTextureCubemap(image, layoutType));
124 void Load(
const std::string& fileName) {
125 set(::LoadTexture(fileName.c_str()));
127 throw RaylibException(
"Failed to load Texture from file: " + fileName);
135 ::UnloadTexture(*
this);
142 ::UpdateTexture(*
this, pixels);
150 UpdateTextureRec(*
this, rec, pixels);
158 return ::LoadImageFromTexture(*
this);
172 ::GenTextureMipmaps(
this);
180 ::SetTextureFilter(*
this, filterMode);
188 ::SetTextureWrap(*
this, wrapMode);
197 inline void Draw(
int posX = 0,
int posY = 0, ::
Color tint = {255, 255, 255, 255})
const {
198 ::DrawTexture(*
this, posX, posY, tint);
207 ::DrawTextureV(*
this, position, tint);
215 inline void Draw(::
Vector2 position,
float rotation,
float scale = 1.0f,
216 ::
Color tint = {255, 255, 255, 255})
const {
217 ::DrawTextureEx(*
this, position, rotation, scale, tint);
226 ::Color tint = {255, 255, 255, 255})
const {
227 ::DrawTextureRec(*
this, sourceRec, position, tint);
236 ::
Color tint = {255, 255, 255, 255})
const {
237 ::DrawTextureQuad(*
this, tiling, offset, quad, tint);
246 float rotation = 0,
::Color tint = {255, 255, 255, 255})
const {
247 ::DrawTexturePro(*
this, sourceRec, destRec, origin, rotation, tint);
256 float rotation = 0,
::Color tint = {255, 255, 255, 255})
const {
257 ::DrawTextureNPatch(*
this, nPatchInfo, destRec, origin, rotation, tint);
266 float rotation = 0,
float scale = 1,
Color tint = {255, 255, 255, 255})
const {
267 ::DrawTextureTiled(*
this, sourceRec, destRec, origin, rotation, scale, tint);
276 ::
Vector2 *texcoords,
int pointsCount,
277 ::
Color tint = {255, 255, 255, 255})
const {
278 ::DrawTexturePoly(*
this, center, points, texcoords, pointsCount, tint);
287 ::
Vector3 position,
float size,
288 ::
Color tint = {255, 255, 255, 255})
const {
299 ::
Color tint = {255, 255, 255, 255})
const {
300 DrawBillboardRec(camera, *
this, source, position, size, tint);
311 ::
Color tint = {255, 255, 255, 255})
const {
312 DrawBillboardPro(camera, *
this, source, position, up, size, origin, rotation, tint);
321 ::
Color color = {255, 255, 255, 255})
const {
322 ::DrawCubeTexture(*
this, position, width, height, length, color);
331 ::
Color color = {255, 255, 255, 255})
const {
332 ::DrawCubeTexture(*
this, position, dimensions.x, dimensions.y, dimensions.z, color);
341 ::
Color color = {255, 255, 255, 255})
const {
342 ::DrawCubeTextureRec(*
this, source, position, width, height, length, color);
351 ::
Color color = {255, 255, 255, 255})
const {
352 ::DrawCubeTextureRec(*
this, source, position, dimensions.x, dimensions.y, dimensions.z, color);
359 ::SetMaterialTexture(material, mapType, *
this);
364 ::SetMaterialTexture((::
Material*)(&material), mapType, *
this);
372 ::SetShapesTexture(*
this, source);
380 ::SetShaderValueTexture(shader, locIndex, *
this);
394 void set(const ::Texture& texture) {
396 width = texture.width;
397 height = texture.height;
398 mipmaps = texture.mipmaps;
399 format = texture.format;
404 typedef TextureUnmanaged Texture2DUnmanaged;
405 typedef TextureUnmanaged TextureCubemapUnmanaged;
Image type, bpp always RGBA (32bit)
Exception used for most raylib-related exceptions.
A Texture that is not managed by the C++ garbage collector.
void DrawBillboard(const ::Camera &camera, ::Vector3 position, float size, ::Color tint={255, 255, 255, 255}) const
Draw a billboard texture.
TextureUnmanaged & SetFilter(int filterMode)
Set texture scaling filter mode.
TextureUnmanaged & Update(::Rectangle rec, const void *pixels)
Update GPU texture rectangle with new data.
void Load(const ::Image &image, int layoutType)
Load cubemap from image, multiple image cubemap layouts supported.
TextureUnmanaged & Update(const void *pixels)
Update GPU texture with new data.
inline ::Image GetData() const
Get pixel data from GPU texture and return an Image.
TextureUnmanaged & SetShaderValue(const ::Shader &shader, int locIndex)
Set shader uniform value for texture (sampler2d)
void DrawPoly(::Vector2 center, ::Vector2 *points, ::Vector2 *texcoords, int pointsCount, ::Color tint={255, 255, 255, 255}) const
Draw a textured polygon.
TextureUnmanaged(const ::Image &image, int layout)
Load cubemap from image, multiple image cubemap layouts supported.
void DrawCube(::Vector3 position, ::Vector3 dimensions, ::Color color={255, 255, 255, 255}) const
Draw cube textured, with dimensions.
void Draw(::NPatchInfo nPatchInfo, ::Rectangle destRec, ::Vector2 origin={0, 0}, float rotation=0, ::Color tint={255, 255, 255, 255}) const
Draws a texture (or part of it) that stretches or shrinks nicely.
TextureUnmanaged(unsigned int id, int width, int height, int mipmaps=1, int format=PIXELFORMAT_UNCOMPRESSED_R8G8B8A8)
Move/Create a texture structure manually.
bool IsReady() const
Determines whether or not the Texture has been loaded and is ready.
void Load(const ::Image &image)
Load texture from image data.
void Draw(::Rectangle sourceRec, ::Rectangle destRec, ::Vector2 origin={0, 0}, float rotation=0, ::Color tint={255, 255, 255, 255}) const
Draw a part of a texture defined by a rectangle with 'pro' parameters.
void DrawBillboard(const ::Camera &camera, ::Rectangle source, Vector3 position, ::Vector3 up, Vector2 size, Vector2 origin, float rotation=0.0f, ::Color tint={255, 255, 255, 255}) const
Draw a billboard texture defined by source and rotation.
void Load(const std::string &fileName)
Load texture from file into GPU memory (VRAM)
void Draw(int posX=0, int posY=0, ::Color tint={255, 255, 255, 255}) const
Draw a Texture2D.
TextureUnmanaged & SetMaterial(::Material *material, int mapType=MATERIAL_MAP_NORMAL)
Set texture for a material map type (MAP_DIFFUSE, MAP_SPECULAR...)
TextureUnmanaged & GenMipmaps()
Generate GPU mipmaps for a texture.
void Draw(::Rectangle sourceRec, ::Vector2 position={0, 0}, ::Color tint={255, 255, 255, 255}) const
Draw a part of a texture defined by a rectangle.
inline ::Vector2 GetSize() const
Retrieve the width and height of the texture.
void Draw(::Vector2 position, ::Color tint={255, 255, 255, 255}) const
Draw a Texture2D with position defined as Vector2.
void Draw(::Vector2 tiling, ::Vector2 offset, ::Rectangle quad, ::Color tint={255, 255, 255, 255}) const
Draw texture quad with tiling and offset parameters.
void Draw(::Vector2 position, float rotation, float scale=1.0f, ::Color tint={255, 255, 255, 255}) const
Draw a Texture2D with extended parameters.
TextureUnmanaged()
Default texture constructor.
void DrawTiled(::Rectangle sourceRec, ::Rectangle destRec, ::Vector2 origin={0, 0}, float rotation=0, float scale=1, Color tint={255, 255, 255, 255}) const
Draw part of a texture (defined by a rectangle) with rotation and scale tiled into dest.
TextureUnmanaged & SetWrap(int wrapMode)
Set texture wrapping mode.
void DrawCube(::Rectangle source, ::Vector3 position, ::Vector3 dimensions, ::Color color={255, 255, 255, 255}) const
Draw cube with a region of a texture, with dimensions.
TextureUnmanaged(const std::string &fileName)
Load texture from file into GPU memory (VRAM)
void Unload()
Unload texture from GPU memory (VRAM)
void DrawCube(::Rectangle source, ::Vector3 position, float width, float height, float length, ::Color color={255, 255, 255, 255}) const
Draw cube with a region of a texture.
void DrawCube(::Vector3 position, float width, float height, float length, ::Color color={255, 255, 255, 255}) const
Draw cube textured.
TextureUnmanaged(const ::Texture &texture)
Creates a texture object based on the given Texture struct data.
TextureUnmanaged(const ::Image &image)
Creates a texture from the given Image.
TextureUnmanaged & SetShapes(const ::Rectangle &source)
Set texture and rectangle to be used on shapes drawing.
void DrawBillboard(const ::Camera &camera, ::Rectangle source, ::Vector3 position, ::Vector2 size, ::Color tint={255, 255, 255, 255}) const
Draw a billboard texture defined by source.
All raylib-cpp classes and functions appear in the raylib namespace.