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);
137 ::UnloadTexture(*
this);
146 ::UpdateTexture(*
this, pixels);
154 UpdateTextureRec(*
this, rec, pixels);
162 return ::LoadImageFromTexture(*
this);
176 ::GenTextureMipmaps(
this);
184 ::SetTextureFilter(*
this, filterMode);
192 ::SetTextureWrap(*
this, wrapMode);
201 inline void Draw(
int posX = 0,
int posY = 0, ::
Color tint = {255, 255, 255, 255})
const {
202 ::DrawTexture(*
this, posX, posY, tint);
211 ::DrawTextureV(*
this, position, tint);
219 inline void Draw(::
Vector2 position,
float rotation,
float scale = 1.0f,
220 ::
Color tint = {255, 255, 255, 255})
const {
221 ::DrawTextureEx(*
this, position, rotation, scale, tint);
230 ::Color tint = {255, 255, 255, 255})
const {
231 ::DrawTextureRec(*
this, sourceRec, position, tint);
240 ::
Color tint = {255, 255, 255, 255})
const {
241 ::DrawTextureQuad(*
this, tiling, offset, quad, tint);
250 float rotation = 0,
::Color tint = {255, 255, 255, 255})
const {
251 ::DrawTexturePro(*
this, sourceRec, destRec, origin, rotation, tint);
260 float rotation = 0,
::Color tint = {255, 255, 255, 255})
const {
261 ::DrawTextureNPatch(*
this, nPatchInfo, destRec, origin, rotation, tint);
270 float rotation = 0,
float scale = 1,
Color tint = {255, 255, 255, 255})
const {
271 ::DrawTextureTiled(*
this, sourceRec, destRec, origin, rotation, scale, tint);
280 ::
Vector2 *texcoords,
int pointsCount,
281 ::
Color tint = {255, 255, 255, 255})
const {
282 ::DrawTexturePoly(*
this, center, points, texcoords, pointsCount, tint);
291 ::
Vector3 position,
float size,
292 ::
Color tint = {255, 255, 255, 255})
const {
303 ::
Color tint = {255, 255, 255, 255})
const {
304 DrawBillboardRec(camera, *
this, source, position, size, tint);
315 ::
Color tint = {255, 255, 255, 255})
const {
316 DrawBillboardPro(camera, *
this, source, position, up, size, origin, rotation, tint);
325 ::
Color color = {255, 255, 255, 255})
const {
326 ::DrawCubeTexture(*
this, position, width, height, length, color);
335 ::
Color color = {255, 255, 255, 255})
const {
336 ::DrawCubeTexture(*
this, position, dimensions.x, dimensions.y, dimensions.z, color);
345 ::
Color color = {255, 255, 255, 255})
const {
346 ::DrawCubeTextureRec(*
this, source, position, width, height, length, color);
355 ::
Color color = {255, 255, 255, 255})
const {
356 ::DrawCubeTextureRec(*
this, source, position, dimensions.x, dimensions.y, dimensions.z, color);
363 ::SetMaterialTexture(material, mapType, *
this);
368 ::SetMaterialTexture((::
Material*)(&material), mapType, *
this);
376 ::SetShapesTexture(*
this, source);
384 ::SetShaderValueTexture(shader, locIndex, *
this);
398 void set(const ::Texture& texture) {
400 width = texture.width;
401 height = texture.height;
402 mipmaps = texture.mipmaps;
403 format = texture.format;
408 typedef TextureUnmanaged Texture2DUnmanaged;
409 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.